From bc08a919d2b58930c99818ec1d629c4c712c02ae Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 25 Apr 2012 12:49:49 +1000 Subject: TONY: Created skeleton engine --- engines/configure.engines | 1 + engines/engines.mk | 5 +++ engines/plugins_table.h | 3 ++ engines/tony/detection.cpp | 93 +++++++++++++++++++++++++++++++++++++++++ engines/tony/detection_tables.h | 43 +++++++++++++++++++ engines/tony/module.mk | 13 ++++++ engines/tony/tony.cpp | 39 +++++++++++++++++ engines/tony/tony.h | 80 +++++++++++++++++++++++++++++++++++ 8 files changed, 277 insertions(+) create mode 100644 engines/tony/detection.cpp create mode 100644 engines/tony/detection_tables.h create mode 100644 engines/tony/module.mk create mode 100644 engines/tony/tony.cpp create mode 100644 engines/tony/tony.h (limited to 'engines') diff --git a/engines/configure.engines b/engines/configure.engines index 6e8db01e66..4d416381bf 100644 --- a/engines/configure.engines +++ b/engines/configure.engines @@ -43,5 +43,6 @@ add_engine tinsel "Tinsel" yes add_engine toltecs "3 Skulls of the Toltecs" no add_engine toon "Toonstruck" yes add_engine touche "Touche: The Adventures of the Fifth Musketeer" yes +add_engine tony "Tony Tough and the Night of Roasted Moths" no add_engine tsage "TsAGE" yes add_engine tucker "Bud Tucker in Double Trouble" yes diff --git a/engines/engines.mk b/engines/engines.mk index 9939506b86..bf6fa7a09d 100644 --- a/engines/engines.mk +++ b/engines/engines.mk @@ -197,6 +197,11 @@ DEFINES += -DENABLE_TOLTECS=$(ENABLE_TOLTECS) MODULES += engines/toltecs endif +ifdef ENABLE_TONY +DEFINES += -DENABLE_TONY=$(ENABLE_TONY) +MODULES += engines/tony +endif + ifdef ENABLE_TOON DEFINES += -DENABLE_TOON=$(ENABLE_TOON) MODULES += engines/toon diff --git a/engines/plugins_table.h b/engines/plugins_table.h index fac956755e..d75c4a78b9 100644 --- a/engines/plugins_table.h +++ b/engines/plugins_table.h @@ -89,6 +89,9 @@ LINK_PLUGIN(TINSEL) #if PLUGIN_ENABLED_STATIC(TOLTECS) LINK_PLUGIN(TOLTECS) #endif +#if PLUGIN_ENABLED_STATIC(TONY) +LINK_PLUGIN(TONY) +#endif #if PLUGIN_ENABLED_STATIC(TOON) LINK_PLUGIN(TOON) #endif diff --git a/engines/tony/detection.cpp b/engines/tony/detection.cpp new file mode 100644 index 0000000000..58d16842d4 --- /dev/null +++ b/engines/tony/detection.cpp @@ -0,0 +1,93 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * + */ + +#include "base/plugins.h" + +#include "engines/advancedDetector.h" +#include "common/system.h" + +#include "tony/tony.h" + + +namespace Tony { + +struct TonyGameDescription { + ADGameDescription desc; +}; + +uint32 TonyEngine::getFeatures() const { + return _gameDescription->desc.flags; +} + +Common::Language TonyEngine::getLanguage() const { + return _gameDescription->desc.language; +} + +} + +static const PlainGameDescriptor tonyGames[] = { + {"tony", "Tony Tough and the Night of Roasted Moths"}, + {0, 0} +}; + +#include "tony/detection_tables.h" + +class TonyMetaEngine : public AdvancedMetaEngine { +public: + TonyMetaEngine() : AdvancedMetaEngine(Tony::gameDescriptions, sizeof(Tony::TonyGameDescription), tonyGames) { + } + + virtual const char *getName() const { + return "Tony Engine"; + } + + virtual const char *getOriginalCopyright() const { + return "Tony Engine (C) Protonic Interactive"; + } + + virtual bool hasFeature(MetaEngineFeature f) const; + virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const; +}; + +bool TonyMetaEngine::hasFeature(MetaEngineFeature f) const { + return false; +} + +bool Tony::TonyEngine::hasFeature(EngineFeature f) const { + return + (f == kSupportsRTL); +} + +bool TonyMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const { + const Tony::TonyGameDescription *gd = (const Tony::TonyGameDescription *)desc; + if (gd) { + *engine = new Tony::TonyEngine(syst, gd); + } + return gd != 0; +} + +#if PLUGIN_ENABLED_DYNAMIC(TONY) + REGISTER_PLUGIN_DYNAMIC(TONY, PLUGIN_TYPE_ENGINE, TonyMetaEngine); +#else + REGISTER_PLUGIN_STATIC(TONY, PLUGIN_TYPE_ENGINE, TonyMetaEngine); +#endif diff --git a/engines/tony/detection_tables.h b/engines/tony/detection_tables.h new file mode 100644 index 0000000000..bb660dd862 --- /dev/null +++ b/engines/tony/detection_tables.h @@ -0,0 +1,43 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +namespace Tony { + +static const TonyGameDescription gameDescriptions[] = { + + { + // Tony Tough English Demo + { + "tony", + "Demo", + AD_ENTRY1s("roasted.mpr", "06203dbbc85fdd1e6dc8fc211c1a6207", 14972409), + Common::EN_ANY, + Common::kPlatformPC, + ADGF_DEMO, + GUIO1(GUIO_NONE) + }, + }, + + { AD_TABLE_END_MARKER } +}; + +} // End of namespace Tony diff --git a/engines/tony/module.mk b/engines/tony/module.mk new file mode 100644 index 0000000000..840fbc0dbf --- /dev/null +++ b/engines/tony/module.mk @@ -0,0 +1,13 @@ +MODULE := engines/tony + +MODULE_OBJS := \ + detection.o \ + tony.o + +# This module can be built as a plugin +ifeq ($(ENABLE_TONY), DYNAMIC_PLUGIN) +PLUGIN := 1 +endif + +# Include common rules +include $(srcdir)/rules.mk diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp new file mode 100644 index 0000000000..523147c848 --- /dev/null +++ b/engines/tony/tony.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "tony/tony.h" + +namespace Tony { + +TonyEngine *_vm; + +TonyEngine::TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc) { +} + +TonyEngine::~TonyEngine() { +} + +Common::Error TonyEngine::run() { + return Common::kNoError; +} + +} // End of namespace Tony diff --git a/engines/tony/tony.h b/engines/tony/tony.h new file mode 100644 index 0000000000..5aa0de95a3 --- /dev/null +++ b/engines/tony/tony.h @@ -0,0 +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. + * + */ + +#ifndef TONY_H +#define TONY_H + +#include "common/scummsys.h" +#include "common/system.h" +#include "common/error.h" +#include "common/events.h" +#include "common/keyboard.h" +#include "common/util.h" +#include "engines/engine.h" + +/** + * This is the namespace of the Tony engine. + * + * Status of this engine: In Development + * + * Games using this engine: + * - Tony Tough + */ +namespace Tony { + +enum { + kTonyDebugAnimations = 1 << 0, + kTonyDebugActions = 1 << 1, + kTonyDebugSound = 1 << 2, + kTonyDebugMusic = 2 << 3 +}; + +#define DEBUG_BASIC 1 +#define DEBUG_INTERMEDIATE 2 +#define DEBUG_DETAILED 3 + +struct TonyGameDescription; + +class TonyEngine : public Engine { +protected: + // Engine APIs + virtual Common::Error run(); + virtual bool hasFeature(EngineFeature f) const; +public: + TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc); + virtual ~TonyEngine(); + + const TonyGameDescription *_gameDescription; + uint32 getGameID() const; + uint32 getFeatures() const; + Common::Language getLanguage() const; + uint16 getVersion() const; + uint32 getFlags() const; + Common::Platform getPlatform() const; +}; + +// Global reference to the TonyEngine object +extern TonyEngine *_vm; + +} // End of namespace Tony + +#endif /* TONY_H */ -- cgit v1.2.3 From 7003d4996a926d912816f19c3afd634e17cef095 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 25 Apr 2012 17:06:26 +1000 Subject: TONY: Imported mpal.h file, and translated the comments --- engines/tony/mpal.h | 750 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 750 insertions(+) create mode 100644 engines/tony/mpal.h (limited to 'engines') diff --git a/engines/tony/mpal.h b/engines/tony/mpal.h new file mode 100644 index 0000000000..f0aa5e79e2 --- /dev/null +++ b/engines/tony/mpal.h @@ -0,0 +1,750 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * + */ + +/************************************************************************** + * 様様様様様様様様様様様様様様様様様 * + * ... Spyral Software snc * + * . x#""*$Nu -= We create much MORE than ALL =- * + * d*#R$. R ^#$o 様様様様様様様様様様様様様様様様様 * + * .F ^$k $ "$b * + * ." $b u "$ #$L * + * P $c :*$L"$L '$k Project: MPAL................... * + * d @$N. $. d ^$b^$k $c * + * F 4 "$c '$ $ #$u#$u '$ Module: MPAL Main Include file. * + * 4 4k *N #b .> '$N'*$u * * + * M $L #$ $ 8 "$c'#$b.. .@ Author: Giovanni Bajo.......... * + * M '$u "$u :" *$. "#*#" * + * M '$N. " F ^$k Desc: Main Include file for * + * 4> ^R$oue# d using MPAL.DLL......... * + * '$ "" @ ....................... * + * #b u# * + * $b .@" OS: [ ] DOS [X] WIN95 [ ] OS/2 * + * #$u .d" * + * '*$e. .zR".@ 様様様様様様様様様様様様様様様様様 * + * "*$$beooee$*" @"M This source code is * + * """ '$.? Copyright (C) Spyral Software * + * '$d> ALL RIGHTS RESERVED * + * '$> 様様様様様様様様様様様様様様様様様 * + * * + **************************************************************************/ + + +/****************************************************************************\ +* Copyright Notice +\****************************************************************************/ + +/* + * A Spyral Software Production: + * + * MPAL - MultiPurpose Adventure Language + * (C) 1997 Giovanni Bajo and Luca Giusti + * ALL RIGHTS RESERVED + * + * + */ + + +/****************************************************************************\ +* General Introduction +\****************************************************************************/ + +/* + * MPAL (MultiPurpose Adventure Language) is a high level language + * for the definition of adventure. Through the use of MPAL you can describe + * storyboard the adventure, and then use it with any user interface. + * In fact, unlike many other similar products, MPAL is not programmed through + * the whole adventure, but are defined only the locations, objects, as they may + * interact with each other, etc.. thus making MPAL useful for any type of adventure. + */ + +/****************************************************************************\ +* Structure +\****************************************************************************/ + +/* + * MPAL consists of two main files: MPAL.DLL and MPAL.H + * The first is the DLL that contains the code to interface with MPAL + * adventures, the second is the header that defines the prototypes + * functions. MPAL is compiled for Win32, and it can therefore be used with + * any compiler that supports Win32 DLL (Watcom C++, Visual C++, + * Delphi, etc.), and therefore compatible with both Windows 95 and Windows NT. + * + * To use the DLL, and 'obviously need to create a library for symbols to export. + * + */ + + +/****************************************************************************\ +* Custom Functions +\****************************************************************************/ + +/* + * A custom function and a function specified by the program that uses the + * library, to perform the particular code. The custom functions are + * retrieved from the library as specified in the source MPAL, and in particular + * in defining the behavior of an item with some action. + * + * To use the custom functions, you need to prepare an array of + * pointers to functions (such as using the type casting LPCUSTOMFUNCTION, + * (defined below), and pass it as second parameter to mpalInit (). Note you + * must specify the size of the array, as elements of pointers and which do not + * contain the same: the library will call it only those functions specified in + * the source MPAL. It can be useful, for debugging reasons, do not bet + * the shares of arrays used to debugging function, to avoid unpleasant crash, + * if it has been made an error in source and / or some oversight in the code. + * + */ + +#ifndef __MPAL_H +#define __MPAL_H + +#include "common/rect.h" + +/****************************************************************************\ +* Macro definitions and structures +\****************************************************************************/ + +/* OK value for the error codes */ +#define OK 0 + +#define MAXFRAMES 400 // frame animation of an object +#define MAXPATTERN 40 // pattern of animation of an object + +#define MAXPOLLINGLOCATIONS 64 + +#define EXPORT +#define LPSTR char * + +/****************************************************************************\ +* enum QueryCoordinates +* --------------------- +* Description: Macro for use with queries that may refer to X and Y co-ordinates +\****************************************************************************/ + +enum QueryCoordinates { + MPQ_X, + MPQ_Y +}; + + +/****************************************************************************\ +* enum QueryTypes +* --------------- +* Description: Query can be used with mpalQuery (). In practice corresponds +* all claims that can do at the library +\****************************************************************************/ + +enum QueryTypes { + /* General Query */ + MPQ_VERSION=10, + + MPQ_GLOBAL_VAR=50, + MPQ_RESOURCE, + MPQ_MESSAGE, + + /* Query on leases */ + MPQ_LOCATION_IMAGE=100, + MPQ_LOCATION_SIZE, + + /* Queries about items */ + MPQ_ITEM_LIST=200, + MPQ_ITEM_DATA, + MPQ_ITEM_PATTERN, + MPQ_ITEM_NAME, + MPQ_ITEM_IS_ACTIVE, + + /* Query dialog */ + MPQ_DIALOG_PERIOD=300, + MPQ_DIALOG_WAITFORCHOICE, + MPQ_DIALOG_SELECTLIST, + MPQ_DIALOG_SELECTION, + + /* Query execution */ + MPQ_DO_ACTION=400, + MPQ_DO_DIALOG +}; + + +/****************************************************************************\ +* typedef ITEM +* ------------ +* Description: Framework to manage the animation of an item +\****************************************************************************/ + +typedef struct { + char *frames[MAXFRAMES]; + Common::Rect frameslocations[MAXFRAMES]; + Common::Rect bbox[MAXFRAMES]; + short pattern[MAXPATTERN][MAXFRAMES]; + short speed; + char numframe; + char numpattern; + char curframe; + char curpattern; + short destX, destY; + signed char Zvalue; + short objectID; + char TAG; +} ITEM; +typedef ITEM *LPITEM; + + +/****************************************************************************\ +* typedef LPCUSTOMFUNCTION +* ------------------------ +* Description: Define a custom function, to use the language MPAL +* to perform various controls as a result of an action +\****************************************************************************/ + +typedef void (*LPCUSTOMFUNCTION)(uint32, uint32, uint32, uint32); +typedef LPCUSTOMFUNCTION *LPLPCUSTOMFUNCTION; + + +/****************************************************************************\ +* typedef LPITEMIRQFUNCTION +* ------------------------- +* Description: Define an IRQ of an item that is called when the +* pattern changes or the status of an item +\****************************************************************************/ + +typedef void (*LPITEMIRQFUNCTION)(uint32, int, int); +typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; + + +/****************************************************************************\ +* Macrofunctions query +\****************************************************************************/ + +/****************************************************************************\ +* +* Function: uint32 mpalQueryVersion(void); +* +* Description: Gets the current version of MPAL +* +* Return: Version number (0x1232 = 1.2.3b) +* +\****************************************************************************/ + +#define mpalQueryVersion() \ + (uint16)mpalQuery(MPQ_VERSION) + + + +/****************************************************************************\ +* +* Function: uint32 mpalQueryGlobalVar(LPSTR lpszVarName); +* +* Description: Gets the numerical value of a global variable +* +* Input: LPSTR lpszVarName Nome della variabile (ASCIIZ) +* +* Return: Valore della variabile +* +* Note: This query was implemented for debugging. The program, +* if well designed, should not need to access variables from +* within the library. +* +\****************************************************************************/ + +#define mpalQueryGlobalVar(lpszVarName) \ + (uint32)mpalQuery(MPQ_GLOBAL_VAR,(LPSTR)(lpszVarName)) + + + +/****************************************************************************\ +* +* Function: HGLOBAL mpalQueryResource(uint32 dwResId); +* +* Description: Provides access to a resource inside the .MPC file +* +* Input: uint32 dwResId ID della risorsa +* +* Return: Handle to a memory area containing the resource, +* ready for use. +* +\****************************************************************************/ + +#define mpalQueryResource(dwResId) \ + (HGLOBAL)mpalQuery(MPQ_RESOURCE,(uint32)(dwResId)) + + + +/****************************************************************************\ +* +* Function: LPSTR mpalQueryMessage(uint32 nMsg); +* +* Description: Returns a message. +* +* Input: uint32 nMsg Message number +* +* Return: ASCIIZ message +* +* Note: The returned pointer must be freed with GlobalFree() +* after use. The message will be in ASCIIZ format. +* +\****************************************************************************/ + +#define mpalQueryMessage(nMsg) \ + (LPSTR)mpalQuery(MPQ_MESSAGE,(uint32)(nMsg)) + + + +/****************************************************************************\ +* +* Function: HGLOBAL mpalQueryLocationImage(uint32 nLoc); +* +* Description: Provides a image image +* +* Input: uint32 nLoc Locazion number +* +* Return: Returns a picture handle +* +\****************************************************************************/ + +#define mpalQueryLocationImage(nLoc) \ + (HGLOBAL)mpalQuery(MPQ_LOCATION_IMAGE,(uint32)(nLoc)) + + + +/****************************************************************************\ +* +* Function: uint32 mpalQueryLocationSize(uint32 nLoc, uint32 dwCoord); +* +* Description: Request the x or y size of a location in pixels +* +* Input: uint32 nLoc Location number +* uint32 dwCoord MPQ_Xr o MPQ_Y +* +* Return: Size +* +\****************************************************************************/ + +#define mpalQueryLocationSize(nLoc,dwCoord) \ + (uint32)mpalQuery(MPQ_LOCATION_SIZE,(uint32)(nLoc),(uint32)(dwCoord)) + + + +/****************************************************************************\ +* +* Function: LPuint32 mpalQueryItemList(uint32 nLoc); +* +* Description: Provides the list of objects in the lease. +* +* Input: uint32 nLoc Location number +* +* Return: List of objects (accessible by Item [0], Item [1], etc.) +* +\****************************************************************************/ + +#define mpalQueryItemList(nLoc) \ + (LPuint32)mpalQuery(MPQ_ITEM_LIST,(uint32)(nLoc)) + + + +/****************************************************************************\ +* +* Function: LPBKGANIM mpalQueryItemData(uint32 nItem); +* +* Description: Provides information on an item +*e +* Input: uint32 nItem Item number +* +* Return: structure filled with requested information +* +\****************************************************************************/ + +#define mpalQueryItemData(nItem) \ + (LPITEM)mpalQuery(MPQ_ITEM_DATA,(uint32)(nItem)) + + + +/****************************************************************************\ +* +* Function: uint32 mpalQueryItemPattern(uint32 nItem); +* +* Description: Provides the current pattern of an item +* +* Input: uint32 nItem Item number +* +* Return: Number of animation patterns to be executed. +* +* Note: By default, the pattern of 0 indicates that we should +* do nothing. +* +\****************************************************************************/ + +#define mpalQueryItemPattern(nItem) \ + (uint32)mpalQuery(MPQ_ITEM_PATTERN,(uint32)(nItem)) + + + +/****************************************************************************\ +* +* Function: bool mpalQueryItemIsActive(uint32 nItem); +* +* Description: Returns true if an item is active +* +* Input: uint32 nItem Item number +* +* Return: TRUE if the item is active, FALSE otherwise +* +\****************************************************************************/ + +#define mpalQueryItemIsActive(nItem) \ + (bool)mpalQuery(MPQ_ITEM_IS_ACTIVE,(uint32)(nItem)) + + +/****************************************************************************\ +* +* Function: void mpalQueryItemName(uint32 nItem, LPSTR lpszName); +* +* Description: Returns the name of an item +* +* Input: uint32 nItem Item number +* LPSTR lpszName Pointer to a buffer of at least 33 bytes +* that will be filled with the name +* +* Note: If the item is not active (ie. if its status or number +* is less than or equal to 0), the string will be empty. +* +\****************************************************************************/ + +#define mpalQueryItemName(nItem,lpszName) \ + (uint32)mpalQuery(MPQ_ITEM_NAME,(uint32)(nItem),(LPSTR)(lpszName)) + + + +/****************************************************************************\ +* +* Function: LPSTR mpalQueryDialogPeriod(uint32 nDialog, uint32 nPeriod); +* +* Description: Returns a sentence of dialog. +* +* Input: uint32 nDialog Dialog number +* uint32 nPeriod Number of words +* +* Return: A pointer to the string of words, or NULL on failure. +* +* Note: The string must be freed after use by GlobalFree (). +* +* Unlike normal messages, the sentences of dialogue +* are formed by a single string terminated with 0. +* +\****************************************************************************/ + +#define mpalQueryDialogPeriod(nPeriod) \ + (LPSTR)mpalQuery(MPQ_DIALOG_PERIOD,(uint32)(nPeriod)) + + + +/****************************************************************************\ +* +* Function: int mpalQueryDialogWaitForChoice(void); +* +* Description: Wait until the moment in which the need is signaled +* to make a choice by the user. +* +* Return: Number of choice to be made, or -1 if the dialogue is finished. +* +\****************************************************************************/ + +#define mpalQueryDialogWaitForChoice() \ + (int)mpalQuery(MPQ_DIALOG_WAITFORCHOICE) + + + +/****************************************************************************\ +* +* Function: LPuint32 mpalQueryDialogSelectList(uint32 nChoice); +* +* Description: Requires a list of various options for some choice within +* the current dialog. + +* Input: uint32 nChoice Choice number +* +* Return: A pointer to an array containing the data matched to each option. +* +* Note: The figure 'a uint32 specified in the source to which MPAL +* You can 'assign meaning that the more' suits. +* +* The pointer msut be freed after use by GlobalFree(). +* +\****************************************************************************/ + +#define mpalQueryDialogSelectList(nChoice) \ + (LPuint32)mpalQuery(MPQ_DIALOG_SELECTLIST,(uint32)(nChoice)) + + + +/****************************************************************************\ +* +* Function: bool mpalQueryDialogSelection(uint32 nChoice, uint32 dwData); +* +* Description: Warns the library that the user has selected, in a certain +* choice of the current dialog, corresponding option +* at a certain given. +* +* Input: uint32 nChoice Choice number of the choice that +* was in progress +* uint32 dwData Option that was selected by the user. +* +* Return: TRUE if all OK, FALSE on failure. +* +* Note: After execution of this query, MPAL continue +* Groups according to the execution of the dialogue. And necessary so the game +* remains on hold again for another Chosen by mpalQueryDialogWaitForChoice (). +* +\****************************************************************************/ + +#define mpalQueryDialogSelection(nChoice,dwData) \ + (bool)mpalQuery(MPQ_DIALOG_SELECTION,(uint32)(nChoice),(uint32)(dwData)) + + + +/****************************************************************************\ +* +* Function: HANDLE mpalQueryDoAction(uint32 nAction, uint32 nItem, +* uint32 dwParam); +* +* Description: Warns the library an action was performed on a Object. +* The library will call 'custom functions, if necessary. +* +* Input: uint32 nAction Action number +* uint32 nItem Item number +* uint32 dwParam Action parameter +* +* Return: Handle to the thread that is performing the action, or +* INVALID_HANDLE_VALUE if the action is not 'defined for +* the item, or the item and 'off. +* +* Note: The parameter is used primarily to implement actions +* as "U.S." involving two objects together. The action will be executed only +* if the item is active, ie if its status is a positive number greater than 0. +* +\****************************************************************************/ + +#define mpalQueryDoAction(nAction,nItem,dwParam) \ + (HANDLE)mpalQuery(MPQ_DO_ACTION,(uint32)(nAction),(uint32)(nItem),(uint32)(dwParam)) + + + +/****************************************************************************\ +* +* Function: HANDLE mpalQueryDoDialog(uint32 nDialog, uint32 nGroup); +* +* Description: Warns the library a dialogue was required. +* +* Input: uint32 nDialog Dialog number +* uint32 nGroup Group number to use +* +* Return: Handle to the thread that is running the box, or +* INVALID_HANDLE_VALUE if the dialogue does not exist. +* +\****************************************************************************/ + +#define mpalQueryDoDialog(nDialog,nGroup) \ + (HANDLE)mpalQuery(MPQ_DO_DIALOG,(uint32)(nDialog),(uint32)(nGroup)) + + + +/****************************************************************************\ +* Functions exported DLL +\****************************************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + +/****************************************************************************\ +* +* Function: bool mpalInit(LPSTR lpszMpcFileName, LPSTR lpszMprFileName, +* LPLPCUSTOMFUNCTION lplpcfArray); +* +* Description: Initializes the MPAL library, and opens an .MPC file, which +* will be 'used for all queries +* +* Input: LPSTR lpszMpcFileName Name of the .MPC file, including extension +* LPSTR lpszMprFileName Name of the .MPR file, including extension +* LPLPCUSTOMFUNCTION Array of pointers to custom functions +* +* Return: TRUE if all OK, FALSE on failure +* +\****************************************************************************/ + +bool EXPORT mpalInit(LPSTR lpszFileName, LPSTR lpszMprFileName, + LPLPCUSTOMFUNCTION lplpcfArray); + + + +/****************************************************************************\ +* +* Function: uint32 mpalQuery(uint16 wQueryType, ...); +* +* Description: This is the general function to communicate with the library, +* To request information about what is in the .MPC file +* +* Input: uint16 wQueryType Type of query. The list is in +* the QueryTypes enum. +* +* Return: 4 bytes depending on the type of query +* +* Note: I _strongly_ recommended to use macros defined above to use +* the query, since it helps avoid any unpleasant bugs due to +* forgeting parameters. +* +\****************************************************************************/ + +uint32 EXPORT mpalQuery(uint16 wQueryType, ...); + + + +/****************************************************************************\ +* +* Function: bool mpalExecuteScript(int nScript); +* +* Description: Execute a script. The script runs on multitasking by a thread. +* +* Input: int nScript Script number to run +* +* Return: TRUE if the script 'was launched, FALSE on failure +* +\****************************************************************************/ + +bool EXPORT mpalExecuteScript(int nScript); + + + +/****************************************************************************\ +* +* Function: uint32 mpalGetError(void); +* +* Description: Returns the current MPAL error code +* +* Return: Error code +* +\****************************************************************************/ + +uint32 EXPORT mpalGetError(void); + + + +/****************************************************************************\ +* +* Function: void mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCustom); +* +* Description: Install a custom routine That will be called by MPAL +* every time the pattern of an item has-been changed. +* +* Input: LPITEMIRQFUNCTION lpiifCustom Custom function to install +* +\****************************************************************************/ + +void EXPORT mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCustom); + + +/****************************************************************************\ +* +* Function: bool mpalStartIdlePoll(int nLoc); +* +* Description: Process the idle actions of the items on one location. +* +* Input: int nLoc Number of the location whose items +* must be processed for idle actions. +* +* Return: TRUE if all OK, and FALSE if it exceeded the maximum limit. +* +* Note: The maximum number of locations that can be polled +* simultaneously is defined defined by MAXPOLLINGFUNCIONS +* +\****************************************************************************/ + +bool EXPORT mpalStartIdlePoll(int nLoc); + + +/****************************************************************************\ +* +* Function: bool mpalEndIdlePoll(int nLoc); +* +* Description: Stop processing the idle actions of the items on one location. +* +* Input: int nLoc Number of the location +* +* Return: TRUE if all OK, FALSE if the specified location was not +* in the process of polling +* +\****************************************************************************/ + +bool EXPORT mpalEndIdlePoll(int nLoc); + + + +/****************************************************************************\ +* +* Function: int mpalLoadState(LPBYTE buf); +* +* Description: Load a save state from a buffer. +* +* Input: LPBYTE buf Buffer where to store the state +* +* Return: Length of the state in bytes +* +\****************************************************************************/ + +int EXPORT mpalLoadState(byte *buf); + + + +/****************************************************************************\ +* +* Function: void mpalSaveState(LPBYTE buf); +* +* Description: Store the save state into a buffer. The buffer must be +* length at least the size specified with mpalGetSaveStateSize +* +* Input: LPBYTE buf Buffer where to store the state +* +\****************************************************************************/ + +void EXPORT mpalSaveState(byte *buf); + + + +/****************************************************************************\ +* +* Function: int mpalGetSaveStateSize(void); +* +* Description: Acquire the length of a save state +* +* Return: Length in bytes +* +\****************************************************************************/ + +int EXPORT mpalGetSaveStateSize(void); + + +#ifdef __cplusplus +} +#endif + +#endif + -- cgit v1.2.3 From 637be83cf5b129b7e55de97c5988f4dfa3c397bf Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 26 Apr 2012 09:43:55 +1000 Subject: TONY: Start of work converting over MPAL sub-system --- engines/tony/lzo/lzo1x.h | 198 +++ engines/tony/lzo/lzoconf.h | 398 ++++++ engines/tony/module.mk | 6 +- engines/tony/mpal.h | 23 +- engines/tony/mpal/expr.cpp | 471 +++++++ engines/tony/mpal/expr.h | 116 ++ engines/tony/mpal/loadmpc.cpp | 720 ++++++++++ engines/tony/mpal/loadmpc.h | 83 ++ engines/tony/mpal/lzo1x.h | 188 +++ engines/tony/mpal/mpal.cpp | 3071 +++++++++++++++++++++++++++++++++++++++++ engines/tony/mpal/mpal.h | 769 +++++++++++ engines/tony/mpal/mpaldll.h | 418 ++++++ engines/tony/mpal/stubs.cpp | 140 ++ engines/tony/mpal/stubs.h | 121 ++ engines/tony/tony.cpp | 45 +- engines/tony/tony.h | 14 +- 16 files changed, 6765 insertions(+), 16 deletions(-) create mode 100644 engines/tony/lzo/lzo1x.h create mode 100644 engines/tony/lzo/lzoconf.h create mode 100644 engines/tony/mpal/expr.cpp create mode 100644 engines/tony/mpal/expr.h create mode 100644 engines/tony/mpal/loadmpc.cpp create mode 100644 engines/tony/mpal/loadmpc.h create mode 100644 engines/tony/mpal/lzo1x.h create mode 100644 engines/tony/mpal/mpal.cpp create mode 100644 engines/tony/mpal/mpal.h create mode 100644 engines/tony/mpal/mpaldll.h create mode 100644 engines/tony/mpal/stubs.cpp create mode 100644 engines/tony/mpal/stubs.h (limited to 'engines') diff --git a/engines/tony/lzo/lzo1x.h b/engines/tony/lzo/lzo1x.h new file mode 100644 index 0000000000..e481b33fa4 --- /dev/null +++ b/engines/tony/lzo/lzo1x.h @@ -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. + * + */ +/* lzo1x.h -- public interface of the LZO1X compression algorithm + + This file is part of the LZO real-time data compression library. + + Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer + + The LZO library is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + The LZO library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with the LZO library; see the file COPYING. + If not, write to the Free Software Foundation, Inc., + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + Markus F.X.J. Oberhumer + + http://wildsau.idv.uni-linz.ac.at/mfx/lzo.html + */ + + +#ifndef __LZO1X_H +#define __LZO1X_H + +#ifndef __LZOCONF_H +#include "lzoconf.h" +#endif + +namespace Tony { + +namespace LZO { + +#ifdef __cplusplus +extern "C" { +#endif + + +/*********************************************************************** +// +************************************************************************/ + +/* Memory required for the wrkmem parameter. + * When the required size is 0, you can also pass a NULL pointer. + */ + +#define LZO1X_MEM_COMPRESS LZO1X_1_MEM_COMPRESS +#define LZO1X_MEM_DECOMPRESS (0) +#define LZO1X_MEM_OPTIMIZE (0) + + +/* decompression */ +LZO_EXTERN(int) +lzo1x_decompress ( const lzo_byte *src, lzo_uint src_len, + lzo_byte *dst, lzo_uint *dst_len, + lzo_voidp wrkmem /* NOT USED */ ); + +/* safe decompression with overrun testing */ +LZO_EXTERN(int) +lzo1x_decompress_safe ( const lzo_byte *src, lzo_uint src_len, + lzo_byte *dst, lzo_uint *dst_len, + lzo_voidp wrkmem /* NOT USED */ ); + + +/*********************************************************************** +// +************************************************************************/ + +#define LZO1X_1_MEM_COMPRESS ((lzo_uint32) (16384L * lzo_sizeof_dict_t)) + +LZO_EXTERN(int) +lzo1x_1_compress ( const lzo_byte *src, lzo_uint src_len, + lzo_byte *dst, lzo_uint *dst_len, + lzo_voidp wrkmem ); + + +/*********************************************************************** +// special compressor versions +************************************************************************/ + +/* this version needs only 8 kB work memory */ +#define LZO1X_1_11_MEM_COMPRESS ((lzo_uint32) (2048L * lzo_sizeof_dict_t)) + +LZO_EXTERN(int) +lzo1x_1_11_compress ( const lzo_byte *src, lzo_uint src_len, + lzo_byte *dst, lzo_uint *dst_len, + lzo_voidp wrkmem ); + + +/* this version needs 16 kB work memory */ +#define LZO1X_1_12_MEM_COMPRESS ((lzo_uint32) (4096L * lzo_sizeof_dict_t)) + +LZO_EXTERN(int) +lzo1x_1_12_compress ( const lzo_byte *src, lzo_uint src_len, + lzo_byte *dst, lzo_uint *dst_len, + lzo_voidp wrkmem ); + + +/* use this version if you need a little more compression speed */ +#define LZO1X_1_15_MEM_COMPRESS ((lzo_uint32) (32768L * lzo_sizeof_dict_t)) + +LZO_EXTERN(int) +lzo1x_1_15_compress ( const lzo_byte *src, lzo_uint src_len, + lzo_byte *dst, lzo_uint *dst_len, + lzo_voidp wrkmem ); + + +/*********************************************************************** +// better compression ratio at the cost of more memory and time +************************************************************************/ + +#define LZO1X_999_MEM_COMPRESS ((lzo_uint32) (14 * 16384L * sizeof(short))) + +#if !defined(LZO_999_UNSUPPORTED) +LZO_EXTERN(int) +lzo1x_999_compress ( const lzo_byte *src, lzo_uint src_len, + lzo_byte *dst, lzo_uint *dst_len, + lzo_voidp wrkmem ); +#endif + + +/*********************************************************************** +// +************************************************************************/ + +#if !defined(LZO_999_UNSUPPORTED) +LZO_EXTERN(int) +lzo1x_999_compress_dict ( const lzo_byte *in , lzo_uint in_len, + lzo_byte *out, lzo_uint *out_len, + lzo_voidp wrkmem, + const lzo_byte *dict, lzo_uint dict_len ); + +LZO_EXTERN(int) +lzo1x_999_compress_level ( const lzo_byte *in , lzo_uint in_len, + lzo_byte *out, lzo_uint *out_len, + lzo_voidp wrkmem, + const lzo_byte *dict, lzo_uint dict_len, + lzo_progress_callback_t cb, + int compression_level ); +#endif + +LZO_EXTERN(int) +lzo1x_decompress_dict_safe ( const lzo_byte *in, lzo_uint in_len, + lzo_byte *out, lzo_uint *out_len, + lzo_voidp wrkmem /* NOT USED */, + const lzo_byte *dict, lzo_uint dict_len ); + + +/*********************************************************************** +// optimize a compressed data block +************************************************************************/ + +LZO_EXTERN(int) +lzo1x_optimize ( lzo_byte *in , lzo_uint in_len, + lzo_byte *out, lzo_uint *out_len, + lzo_voidp wrkmem ); + + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +} // End of namespace LZO + +} // End of namespace Tony + +#endif /* already included */ + diff --git a/engines/tony/lzo/lzoconf.h b/engines/tony/lzo/lzoconf.h new file mode 100644 index 0000000000..9dfcfb0cbc --- /dev/null +++ b/engines/tony/lzo/lzoconf.h @@ -0,0 +1,398 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ +/* lzoconf.h -- configuration for the LZO real-time data compression library + + This file is part of the LZO real-time data compression library. + + Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer + + The LZO library is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + The LZO library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with the LZO library; see the file COPYING. + If not, write to the Free Software Foundation, Inc., + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + Markus F.X.J. Oberhumer + + http://wildsau.idv.uni-linz.ac.at/mfx/lzo.html + */ + + +#ifndef __LZOCONF_H +#define __LZOCONF_H + +namespace Tony { + +namespace LZO { + +#define LZO_VERSION 0x1060 +#define LZO_VERSION_STRING "1.06" +#define LZO_VERSION_DATE "Nov 29 1999" + +/* internal Autoconf configuration file - only used when building LZO */ +#if defined(LZO_HAVE_CONFIG_H) +# include +#endif +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +/*********************************************************************** +// LZO requires a conforming +************************************************************************/ + +#if !defined(CHAR_BIT) || (CHAR_BIT != 8) +# error "invalid CHAR_BIT" +#endif +#if !defined(UCHAR_MAX) || !defined(UINT_MAX) || !defined(ULONG_MAX) +# error "check your compiler installation" +#endif +#if (USHRT_MAX < 1 ) || (UINT_MAX < 1) || (ULONG_MAX < 1) +# error "your limits.h macros are broken" +#endif + +/* workaround a cpp bug under hpux 10.20 */ +#define LZO_0xffffffffL 4294967295ul + + +/*********************************************************************** +// architecture defines +************************************************************************/ + +#if !defined(__LZO_WIN) && !defined(__LZO_DOS) && !defined(__LZO_OS2) +# if defined(__WINDOWS__) || defined(_WINDOWS) || defined(_Windows) +# define __LZO_WIN +# elif defined(__WIN32__) || defined(_WIN32) || defined(WIN32) +# define __LZO_WIN +# elif defined(__NT__) || defined(__NT_DLL__) || defined(__WINDOWS_386__) +# define __LZO_WIN +# elif defined(__DOS__) || defined(__MSDOS__) || defined(MSDOS) +# define __LZO_DOS +# elif defined(__OS2__) || defined(__OS2V2__) || defined(OS2) +# define __LZO_OS2 +# elif defined(__palmos__) +# define __LZO_PALMOS +# elif defined(__TOS__) || defined(__atarist__) +# define __LZO_TOS +# endif +#endif + +#if (UINT_MAX < LZO_0xffffffffL) +# if defined(__LZO_WIN) +# define __LZO_WIN16 +# elif defined(__LZO_DOS) +# define __LZO_DOS16 +# elif defined(__LZO_PALMOS) +# define __LZO_PALMOS16 +# elif defined(__LZO_TOS) +# define __LZO_TOS16 +# elif defined(__C166__) +# else +# error "16-bit target not supported - contact me for porting hints" +# endif +#endif + +#if !defined(__LZO_i386) +# if defined(__LZO_DOS) || defined(__LZO_WIN16) +# define __LZO_i386 +# elif defined(__i386__) || defined(__386__) || defined(_M_IX86) +# define __LZO_i386 +# endif +#endif + +#if defined(__LZO_STRICT_16BIT) +# if (UINT_MAX < LZO_0xffffffffL) +# include +# endif +#endif + + +/*********************************************************************** +// integral and pointer types +************************************************************************/ + +/* Integral types with 32 bits or more */ +#if !defined(LZO_UINT32_MAX) +# if (UINT_MAX >= LZO_0xffffffffL) + typedef unsigned int lzo_uint32; + typedef int lzo_int32; +# define LZO_UINT32_MAX UINT_MAX +# define LZO_INT32_MAX INT_MAX +# define LZO_INT32_MIN INT_MIN +# elif (ULONG_MAX >= LZO_0xffffffffL) + typedef unsigned long lzo_uint32; + typedef long lzo_int32; +# define LZO_UINT32_MAX ULONG_MAX +# define LZO_INT32_MAX LONG_MAX +# define LZO_INT32_MIN LONG_MIN +# else +# error "lzo_uint32" +# endif +#endif + +/* lzo_uint is used like size_t */ +#if !defined(LZO_UINT_MAX) +# if (UINT_MAX >= LZO_0xffffffffL) + typedef unsigned int lzo_uint; + typedef int lzo_int; +# define LZO_UINT_MAX UINT_MAX +# define LZO_INT_MAX INT_MAX +# define LZO_INT_MIN INT_MIN +# elif (ULONG_MAX >= LZO_0xffffffffL) + typedef unsigned long lzo_uint; + typedef long lzo_int; +# define LZO_UINT_MAX ULONG_MAX +# define LZO_INT_MAX LONG_MAX +# define LZO_INT_MIN LONG_MIN +# else +# error "lzo_uint" +# endif +#endif + + +/* Memory model that allows to access memory at offsets of lzo_uint. */ +#if !defined(__LZO_MMODEL) +# if (LZO_UINT_MAX <= UINT_MAX) +# define __LZO_MMODEL +# elif defined(__LZO_DOS16) || defined(__LZO_WIN16) +# define __LZO_MMODEL __huge +# define LZO_999_UNSUPPORTED +# elif defined(__LZO_PALMOS16) || defined(__LZO_TOS16) +# define __LZO_MMODEL +# else +# error "__LZO_MMODEL" +# endif +#endif + +/* no typedef here because of const-pointer issues */ +#define lzo_byte unsigned char __LZO_MMODEL +#define lzo_bytep unsigned char __LZO_MMODEL * +#define lzo_charp char __LZO_MMODEL * +#define lzo_voidp void __LZO_MMODEL * +#define lzo_shortp short __LZO_MMODEL * +#define lzo_ushortp unsigned short __LZO_MMODEL * +#define lzo_uint32p lzo_uint32 __LZO_MMODEL * +#define lzo_int32p lzo_int32 __LZO_MMODEL * +#define lzo_uintp lzo_uint __LZO_MMODEL * +#define lzo_intp lzo_int __LZO_MMODEL * +#define lzo_voidpp lzo_voidp __LZO_MMODEL * +#define lzo_bytepp lzo_bytep __LZO_MMODEL * + +typedef int lzo_bool; + +#ifndef lzo_sizeof_dict_t +# define lzo_sizeof_dict_t sizeof(lzo_bytep) +#endif + + +/*********************************************************************** +// function types +************************************************************************/ + +/* linkage */ +#if !defined(__LZO_EXTERN_C) +# ifdef __cplusplus +# define __LZO_EXTERN_C extern "C" +# else +# define __LZO_EXTERN_C extern +# endif +#endif + +/* calling conventions */ +#if !defined(__LZO_CDECL) +# if defined(__LZO_DOS16) || defined(__LZO_WIN16) +# define __LZO_CDECL __far __cdecl +# elif defined(__LZO_i386) && defined(_MSC_VER) +# define __LZO_CDECL __cdecl +# elif defined(__LZO_i386) && defined(__WATCOMC__) +# define __LZO_CDECL __near __cdecl +# else +# define __LZO_CDECL +# endif +#endif +#if !defined(__LZO_ENTRY) +# define __LZO_ENTRY __LZO_CDECL +#endif + +/* DLL export information */ +#if !defined(__LZO_EXPORT1) +# define __LZO_EXPORT1 +#endif +#if !defined(__LZO_EXPORT2) +# define __LZO_EXPORT2 +#endif + +/* calling convention for C functions */ +#if !defined(LZO_PUBLIC) +# define LZO_PUBLIC(_rettype) __LZO_EXPORT1 _rettype __LZO_EXPORT2 __LZO_ENTRY +#endif +#if !defined(LZO_EXTERN) +# define LZO_EXTERN(_rettype) __LZO_EXTERN_C LZO_PUBLIC(_rettype) +#endif +#if !defined(LZO_PRIVATE) +# define LZO_PRIVATE(_rettype) static _rettype __LZO_ENTRY +#endif + +/* cdecl calling convention for assembler functions */ +#if !defined(LZO_PUBLIC_CDECL) +# define LZO_PUBLIC_CDECL(_rettype) \ + __LZO_EXPORT1 _rettype __LZO_EXPORT2 __LZO_CDECL +#endif +#if !defined(LZO_EXTERN_CDECL) +# define LZO_EXTERN_CDECL(_rettype) __LZO_EXTERN_C LZO_PUBLIC_CDECL(_rettype) +#endif + + +typedef int +(__LZO_ENTRY *lzo_compress_t) ( const lzo_byte *src, lzo_uint src_len, + lzo_byte *dst, lzo_uint *dst_len, + lzo_voidp wrkmem ); + +typedef int +(__LZO_ENTRY *lzo_decompress_t) ( const lzo_byte *src, lzo_uint src_len, + lzo_byte *dst, lzo_uint *dst_len, + lzo_voidp wrkmem ); + +typedef int +(__LZO_ENTRY *lzo_optimize_t) ( lzo_byte *src, lzo_uint src_len, + lzo_byte *dst, lzo_uint *dst_len, + lzo_voidp wrkmem ); + +typedef int +(__LZO_ENTRY *lzo_compress_dict_t)(const lzo_byte *src, lzo_uint src_len, + lzo_byte *dst, lzo_uint *dst_len, + lzo_voidp wrkmem, + const lzo_byte *dict, lzo_uint dict_len ); + +typedef int +(__LZO_ENTRY *lzo_decompress_dict_t)(const lzo_byte *src, lzo_uint src_len, + lzo_byte *dst, lzo_uint *dst_len, + lzo_voidp wrkmem, + const lzo_byte *dict, lzo_uint dict_len ); + + +/* a progress indicator callback function */ +typedef void (__LZO_ENTRY *lzo_progress_callback_t) (lzo_uint, lzo_uint); + + +/*********************************************************************** +// error codes and prototypes +************************************************************************/ + +/* Error codes for the compression/decompression functions. Negative + * values are errors, positive values will be used for special but + * normal events. + */ +#define LZO_E_OK 0 +#define LZO_E_ERROR (-1) +#define LZO_E_OUT_OF_MEMORY (-2) /* not used right now */ +#define LZO_E_NOT_COMPRESSIBLE (-3) /* not used right now */ +#define LZO_E_INPUT_OVERRUN (-4) +#define LZO_E_OUTPUT_OVERRUN (-5) +#define LZO_E_LOOKBEHIND_OVERRUN (-6) +#define LZO_E_EOF_NOT_FOUND (-7) +#define LZO_E_INPUT_NOT_CONSUMED (-8) + + +/* lzo_init() should be the first function you call. + * Check the return code ! + * + * lzo_init() is a macro to allow checking that the library and the + * compiler's view of various types are consistent. + */ +#define lzo_init() __lzo_init2(LZO_VERSION,(int)sizeof(short),(int)sizeof(int),\ + (int)sizeof(long),(int)sizeof(lzo_uint32),(int)sizeof(lzo_uint),\ + (int)lzo_sizeof_dict_t,(int)sizeof(char *),(int)sizeof(lzo_voidp),\ + (int)sizeof(lzo_compress_t)) +LZO_EXTERN(int) __lzo_init2(unsigned,int,int,int,int,int,int,int,int,int); + +/* version functions (useful for shared libraries) */ +LZO_EXTERN(unsigned) lzo_version(void); +LZO_EXTERN(const char *) lzo_version_string(void); +LZO_EXTERN(const char *) lzo_version_date(void); +LZO_EXTERN(const lzo_charp) _lzo_version_string(void); +LZO_EXTERN(const lzo_charp) _lzo_version_date(void); + +/* string functions */ +LZO_EXTERN(int) +lzo_memcmp(const lzo_voidp _s1, const lzo_voidp _s2, lzo_uint _len); +LZO_EXTERN(lzo_voidp) +lzo_memcpy(lzo_voidp _dest, const lzo_voidp _src, lzo_uint _len); +LZO_EXTERN(lzo_voidp) +lzo_memmove(lzo_voidp _dest, const lzo_voidp _src, lzo_uint _len); +LZO_EXTERN(lzo_voidp) +lzo_memset(lzo_voidp _s, int _c, lzo_uint _len); + +/* checksum functions */ +LZO_EXTERN(lzo_uint32) +lzo_adler32(lzo_uint32 _adler, const lzo_byte *_buf, lzo_uint _len); +LZO_EXTERN(lzo_uint32) +lzo_crc32(lzo_uint32 _c, const lzo_byte *_buf, lzo_uint _len); + +/* memory allocation functions */ +LZO_EXTERN(lzo_bytep) lzo_alloc(lzo_uint _nelems, lzo_uint _size); +LZO_EXTERN(lzo_bytep) lzo_malloc(lzo_uint _size); +LZO_EXTERN(void) lzo_free(lzo_voidp _ptr); + +extern lzo_bytep (__LZO_ENTRY *lzo_alloc_hook) (lzo_uint,lzo_uint); +extern void (__LZO_ENTRY *lzo_free_hook) (lzo_voidp); + +/* misc. */ +LZO_EXTERN(lzo_bool) lzo_assert(int _expr); +LZO_EXTERN(int) _lzo_config_check(void); +typedef union { lzo_bytep p; lzo_uint u; } __lzo_pu_u; +typedef union { lzo_bytep p; lzo_uint32 u32; } __lzo_pu32_u; + +/* align a char pointer on a boundary that is a multiple of `size' */ +LZO_EXTERN(unsigned) __lzo_align_gap(const lzo_voidp _ptr, lzo_uint _size); +#define LZO_PTR_ALIGN_UP(_ptr,_size) \ + ((_ptr) + (lzo_uint) __lzo_align_gap((const lzo_voidp)(_ptr),(lzo_uint)(_size))) + +/* deprecated - only for backward compatibility */ +#define LZO_ALIGN(_ptr,_size) LZO_PTR_ALIGN_UP(_ptr,_size) + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +} // end of namespace MPAL + +} // end of namespace Tony + +#endif /* already included */ + diff --git a/engines/tony/module.mk b/engines/tony/module.mk index 840fbc0dbf..d592fac68b 100644 --- a/engines/tony/module.mk +++ b/engines/tony/module.mk @@ -2,7 +2,11 @@ MODULE := engines/tony MODULE_OBJS := \ detection.o \ - tony.o + tony.o \ + mpal\expr.o \ + mpal\loadmpc.o \ + mpal\mpal.o \ + mpal\stubs.o # This module can be built as a plugin ifeq ($(ENABLE_TONY), DYNAMIC_PLUGIN) diff --git a/engines/tony/mpal.h b/engines/tony/mpal.h index f0aa5e79e2..0c15ef5b50 100644 --- a/engines/tony/mpal.h +++ b/engines/tony/mpal.h @@ -120,6 +120,10 @@ #include "common/rect.h" +namespace Tony { + +namespace MPAL { + /****************************************************************************\ * Macro definitions and structures \****************************************************************************/ @@ -197,10 +201,10 @@ typedef struct { Common::Rect bbox[MAXFRAMES]; short pattern[MAXPATTERN][MAXFRAMES]; short speed; - char numframe; - char numpattern; - char curframe; - char curpattern; + uint8 numframe; + uint8 numpattern; + uint8 curframe; + uint8 curpattern; short destX, destY; signed char Zvalue; short objectID; @@ -568,13 +572,9 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; /****************************************************************************\ -* Functions exported DLL +* MPAL Interface Functions \****************************************************************************/ -#ifdef __cplusplus -extern "C" { -#endif - /****************************************************************************\ * * Function: bool mpalInit(LPSTR lpszMpcFileName, LPSTR lpszMprFileName, @@ -741,10 +741,9 @@ void EXPORT mpalSaveState(byte *buf); int EXPORT mpalGetSaveStateSize(void); +} // end of namespace MPAL -#ifdef __cplusplus -} -#endif +} // end of namespace #endif diff --git a/engines/tony/mpal/expr.cpp b/engines/tony/mpal/expr.cpp new file mode 100644 index 0000000000..0faf91744c --- /dev/null +++ b/engines/tony/mpal/expr.cpp @@ -0,0 +1,471 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * + */ +/************************************************************************** + * 様様様様様様様様様様様様様様様様様 * + * ... Spyral Software snc * + * . x#""*$Nu -= We create much MORE than ALL =- * + * d*#R$. R ^#$o 様様様様様様様様様様様様様様様様様 * + * .F ^$k $ "$b * + * ." $b u "$ #$L * + * P $c :*$L"$L '$k Project: MPAL................... * + * d @$N. $. d ^$b^$k $c * + * F 4 "$c '$ $ #$u#$u '$ Module: Expression gestor...... * + * 4 4k *N #b .> '$N'*$u * * + * M $L #$ $ 8 "$c'#$b.. .@ Author: Giovanni Bajo.......... * + * M '$u "$u :" *$. "#*#" * + * M '$N. " F ^$k Desc: Gestisce le espressioni * + * 4> ^R$oue# d matematiche............ * + * '$ "" @ ....................... * + * #b u# * + * $b .@" OS: [ ] DOS [X] WIN95 [ ] OS/2 * + * #$u .d" * + * '*$e. .zR".@ 様様様様様様様様様様様様様様様様様 * + * "*$$beooee$*" @"M This source code is * + * """ '$.? Copyright (C) Spyral Software * + * '$d> ALL RIGHTS RESERVED * + * '$> 様様様様様様様様様様様様様様様様様 * + * * + **************************************************************************/ + +#include "mpal.h" +#include "mpaldll.h" +#include "stubs.h" + +/* +#include "lzo1x.h" +*/ + +namespace Tony { + +namespace MPAL { + +/****************************************************************************\ +* Operazioni matematiche gestite +\****************************************************************************/ + +#define OP_MUL ((1<<4)|0) +#define OP_DIV ((1<<4)|1) +#define OP_MODULE ((1<<4)|2) +#define OP_ADD ((2<<4)|0) +#define OP_SUB ((2<<4)|1) +#define OP_SHL ((3<<4)|0) +#define OP_SHR ((3<<4)|1) +#define OP_MINOR ((4<<4)|0) +#define OP_MAJOR ((4<<4)|1) +#define OP_MINEQ ((4<<4)|2) +#define OP_MAJEQ ((4<<4)|3) +#define OP_EQUAL ((5<<4)|0) +#define OP_NOEQUAL ((5<<4)|1) +#define OP_BITAND ((6<<4)|0) +#define OP_BITXOR ((7<<4)|0) +#define OP_BITOR ((8<<4)|0) +#define OP_AND ((9<<4)|0) +#define OP_OR ((10<<4)|0) + + +/****************************************************************************\ +* enum ExprListTypes +* ------------------ +* Description: Tipi di oggetto che possono essere contenuti in una struttura +* EXPRESSION. +\****************************************************************************/ + +enum ExprListTypes +{ + ELT_NUMBER=1, + ELT_VAR=2, + ELT_PARENTH=3, + ELT_PARENTH2=4 +}; + + +/****************************************************************************\ +* Structures +\****************************************************************************/ + +/****************************************************************************\ +* typedef EXPRESSION +* ------------------ +* Description: Struttura per gestire le operazioni matematiche +\****************************************************************************/ + +typedef struct { + byte type; // Tipo di oggetto (vedi enum ExprListTypes) + byte unary; // Unary operatore (NON SUPPORTATO) + + union { + int num; // Numero (se type==ELT_NUMBER) + char *name; // Nome variabile (se type==ELT_VAR) + HGLOBAL son; // Handle a espressione (type==ELT_PARENTH) + byte *pson; // Handle lockato (type==ELT_PARENTH2) + } val; + + byte symbol; // Simbolo matematico (vedi #define OP_*) + +} EXPRESSION; +typedef EXPRESSION* LPEXPRESSION; + + +/****************************************************************************\ +* +* Function: LPEXPRESSION DuplicateExpression(HGLOBAL h); +* +* Description: Duplica un'espressione matematica. L'espressione duplicata +* sara' formata da memoria non swappabile. +* +* Input: HGLOBAL h Handle dell'espressione originale +* +* Return: Pointer all'espressione clone della prima +* +\****************************************************************************/ + +static byte *DuplicateExpression(HGLOBAL h) { + int i, num; + byte *orig, *clone; + LPEXPRESSION one, two; + + orig=(byte *)GlobalLock(h); + + num=*(byte *)orig; + one=(LPEXPRESSION)(orig+1); + + clone=GlobalAlloc(GMEM_FIXED,sizeof(EXPRESSION)*num+1); + two=(LPEXPRESSION)(clone+1); + + CopyMemory(clone,orig,sizeof(EXPRESSION)*num+1); + + for (i=0;itype==ELT_PARENTH) { + two->type=ELT_PARENTH2; + two->val.pson=DuplicateExpression(two->val.son); + } + + one++; + two++; + } + + GlobalUnlock(h); + return clone; +} + +static int Compute(int a, int b, byte symbol) { + switch (symbol) { + case OP_MUL: + return a*b; + case OP_DIV: + return a/b; + case OP_MODULE: + return a%b; + case OP_ADD: + return a+b; + case OP_SUB: + return a-b; + case OP_SHL: + return a<>b; + case OP_MINOR: + return ab; + case OP_MINEQ: + return a<=b; + case OP_MAJEQ: + return a>=b; + case OP_EQUAL: + return a==b; + case OP_NOEQUAL: + return a!=b; + case OP_BITAND: + return a&b; + case OP_BITXOR: + return a^b; + case OP_BITOR: + return a|b; + case OP_AND: + return a&&b; + case OP_OR: + return a||b; + default: + mpalError=1; + break; + } + + return 0; +} + +static void Solve(LPEXPRESSION one, int num) { + LPEXPRESSION two, three; + int j; + + while (num>1) { + two=one+1; + if ((two->symbol==0) || (one->symbol&0xF0) <= (two->symbol&0xF0)) { + two->val.num=Compute(one->val.num,two->val.num,one->symbol); + CopyMemory(one,two,(num-1)*sizeof(EXPRESSION)); + num--; + } else { + j=1; + three=two+1; + while ((three->symbol!=0) && (two->symbol&0xF0)>(three->symbol&0xF0)) { + two++; + three++; + j++; + } + + three->val.num=Compute(two->val.num,three->val.num,two->symbol); + CopyMemory(two,three,(num-j-1)*sizeof(EXPRESSION)); + num--; + } + } +} + + +/****************************************************************************\ +* +* Function: int EvaluateAndFreeExpression(byte *expr); +* +* Description: Calcola il risultato di una espressione matematica, sosti- +* tuendo ad eventuali variabili il valore corrente. +* +* Input: byte *expr Pointer all'espressione duplicata +* tramite DuplicateExpression +* +* Return: Valore dell'espressione +* +\****************************************************************************/ + +static int EvaluateAndFreeExpression(byte *expr) { + int i,num,val; + LPEXPRESSION one,cur; + + num=*expr; + one=(LPEXPRESSION)(expr+1); + + // 1) Sostituzioni delle variabili + for (i=0,cur=one;itype==ELT_VAR) { + cur->type=ELT_NUMBER; + cur->val.num=varGetValue(cur->val.name); + } + } + + // 2) Sostituzioni delle parentesi (tramite ricorsione) + for (i=0,cur=one;itype==ELT_PARENTH2) { + cur->type=ELT_NUMBER; + cur->val.num=EvaluateAndFreeExpression(cur->val.pson); + } + } + + // 3) Risoluzione algebrica + Solve(one,num); + val=one->val.num; + GlobalFree(expr); + + return val; +} + +/****************************************************************************\ +* +* Function: byte *ParseExpression(byte *buf, HGLOBAL *h); +* +* Description: Esegue il parsing da file .MPC di un'espressione matematica. +* +* Input: byte *buf Buffer contenente l'espressione +* compilata. +* HGLOBAL *h Pointer a un handle che, alla fine +* dell'esecuzione, puntera' alla +* zona di memoria contenete l'espres- +* sione parsata +* +* Return: Puntatore al buffer subito dopo l'espressione, o NULL in caso +* di errore. +* +\****************************************************************************/ + +byte *ParseExpression(byte *lpBuf, HGLOBAL *h) { + LPEXPRESSION cur; + byte *start; + uint32 num, i; + + num=*lpBuf; + lpBuf++; + + if (num==0) + return NULL; + + *h=GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT,num*sizeof(EXPRESSION)+1); + if (*h==NULL) + return NULL; + + start=(byte *)GlobalLock(*h); + *start=(byte)num; + + cur=(LPEXPRESSION)(start+1); + + for (i=0;itype=*(lpBuf); + cur->unary=*(lpBuf+1); + lpBuf+=2; + switch (cur->type) { + case ELT_NUMBER: + cur->val.num=*(int *)lpBuf; + lpBuf+=4; + break; + + case ELT_VAR: + cur->val.name=(char *)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,(*lpBuf)+1); + if (cur->val.name==NULL) + return NULL; + CopyMemory(cur->val.name,lpBuf+1,*lpBuf); + lpBuf+=*lpBuf+1; + break; + + case ELT_PARENTH: + lpBuf=ParseExpression(lpBuf,&cur->val.son); + if (lpBuf==NULL) + return NULL; + break; + + default: + return NULL; + } + + cur->symbol=*lpBuf; + lpBuf++; + + cur++; + } + + if (*lpBuf!=0) + return NULL; + + lpBuf++; + + return lpBuf; +} + + +/****************************************************************************\ +* +* Function: int EvaluateExpression(HGLOBAL h); +* +* Description: Calcola il valore di un'espressione matematica +* +* Input: HGLOBAL h Handle all'espressione +* +* Return: Valore numerico +* +\****************************************************************************/ + +int EvaluateExpression(HGLOBAL h) { + int ret; + + LockVar(); + ret=EvaluateAndFreeExpression(DuplicateExpression(h)); + UnlockVar(); + + return ret; +} + + +/****************************************************************************\ +* +* Function: bool CompareExpressions(HGLOBAL h1, HGLOBAL h2); +* +* Description: Confronta due espressioni matematiche tra loro +* +* Input: HGLOBAL h1,h2 Espressioni da confrontare +* +* Return: true se sono uguali, false se sono diverse +* +\****************************************************************************/ + +bool CompareExpressions(HGLOBAL h1, HGLOBAL h2) { + int i,num1,num2; + byte *e1, *e2; + LPEXPRESSION one, two; + + e1=(byte *)GlobalLock(h1); + e2=(byte *)GlobalLock(h2); + + num1=*(byte *)e1; + num2=*(byte *)e2; + + if (num1 != num2) { + GlobalUnlock(h1); + GlobalUnlock(h2); + return false; + } + + one=(LPEXPRESSION)(e1+1); + two=(LPEXPRESSION)(e2+1); + + for (i=0;itype!=two->type || (i!=num1-1 && one->symbol!=two->symbol)) { + GlobalUnlock(h1); + GlobalUnlock(h2); + return false; + } + + switch (one->type) { + case ELT_NUMBER: + if (one->val.num != two->val.num) { + GlobalUnlock(h1); + GlobalUnlock(h2); + return false; + } + break; + + case ELT_VAR: + if (strcmp(one->val.name, two->val.name)!=0) { + GlobalUnlock(h1); + GlobalUnlock(h2); + return false; + } + break; + + case ELT_PARENTH: + if (!CompareExpressions(one->val.son,two->val.son)) { + GlobalUnlock(h1); + GlobalUnlock(h2); + return false; + } + break; + } + + one++; + two++; + } + + GlobalUnlock(h1); + GlobalUnlock(h2); + + return true; +} + + +} // end of namespace MPAL + +} // end of namespace Tony diff --git a/engines/tony/mpal/expr.h b/engines/tony/mpal/expr.h new file mode 100644 index 0000000000..d54f17b088 --- /dev/null +++ b/engines/tony/mpal/expr.h @@ -0,0 +1,116 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * + */ +/************************************************************************** + * 様様様様様様様様様様様様様様様様様 * + * ... Spyral Software snc * + * . x#""*$Nu -= We create much MORE than ALL =- * + * d*#R$. R ^#$o 様様様様様様様様様様様様様様様様様 * + * .F ^$k $ "$b * + * ." $b u "$ #$L * + * P $c :*$L"$L '$k Project: MPAL................... * + * d @$N. $. d ^$b^$k $c * + * F 4 "$c '$ $ #$u#$u '$ Module: Expression gestor heade * + * 4 4k *N #b .> '$N'*$u * * + * M $L #$ $ 8 "$c'#$b.. .@ Author: Giovanni Bajo.......... * + * M '$u "$u :" *$. "#*#" * + * M '$N. " F ^$k Desc: Gestisce le espressioni * + * 4> ^R$oue# d matematiche............ * + * '$ "" @ ....................... * + * #b u# * + * $b .@" OS: [ ] DOS [X] WIN95 [ ] OS/2 * + * #$u .d" * + * '*$e. .zR".@ 様様様様様様様様様様様様様様様様様 * + * "*$$beooee$*" @"M This source code is * + * """ '$.? Copyright (C) Spyral Software * + * '$d> ALL RIGHTS RESERVED * + * '$> 様様様様様様様様様様様様様様様様様 * + * * + **************************************************************************/ + +#ifndef MPAL_EXPR_H +#define MPAL_EXPR_H + +namespace Tony { + +namespace MPAL { + +/****************************************************************************\ +* Prototipi di funzione +\****************************************************************************/ + +/****************************************************************************\ +* +* Function: byte *ParseExpression(byte *buf, HGLOBAL *h); +* +* Description: Esegue il parsing da file .MPC di un'espressione matematica. +* +* Input: byte *buf Buffer contenente l'espressione +* compilata. +* HGLOBAL *h Pointer a un handle che, alla fine +* dell'esecuzione, puntera' alla +* zona di memoria contenete l'espres- +* sione parsata +* +* Return: Puntatore al buffer subito dopo l'espressione, o NULL in caso +* di errore. +* +\****************************************************************************/ + +byte *ParseExpression(byte *lpBuf, HGLOBAL *h); + + +/****************************************************************************\ +* +* Function: int EvaluateExpression(HGLOBAL h); +* +* Description: Calcola il valore di un'espressione matematica +* +* Input: HGLOBAL h Handle all'espressione +* +* Return: Valore numerico +* +\****************************************************************************/ + +int EvaluateExpression(HGLOBAL h); + + +/****************************************************************************\ +* +* Function: bool CompareExpressions(HGLOBAL h1, HGLOBAL h2); +* +* Description: Confronta due espressioni matematiche tra loro +* +* Input: HGLOBAL h1,h2 Espressioni da confrontare +* +* Return: TRUE se sono uguali, FALSE se sono diverse +* +\****************************************************************************/ + +bool CompareExpressions(HGLOBAL h1, HGLOBAL h2); + + +} // end of namespace MPAL + +} // end of namespace Tony + +#endif diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp new file mode 100644 index 0000000000..f9426c8d58 --- /dev/null +++ b/engines/tony/mpal/loadmpc.cpp @@ -0,0 +1,720 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * + */ +/************************************************************************** + * 様様様様様様様様様様様様様様様様様 * + * ... Spyral Software snc * + * . x#""*$Nu -= We create much MORE than ALL =- * + * d*#R$. R ^#$o 様様様様様様様様様様様様様様様様様 * + * .F ^$k $ "$b * + * ." $b u "$ #$L * + * P $c :*$L"$L '$k Project: MPAL................... * + * d @$N. $. d ^$b^$k $c * + * F 4 "$c '$ $ #$u#$u '$ Module: MPC Loader............. * + * 4 4k *N #b .> '$N'*$u * * + * M $L #$ $ 8 "$c'#$b.. .@ Author: Giovanni Bajo.......... * + * M '$u "$u :" *$. "#*#" * + * M '$N. " F ^$k Desc: Legge un file compilato * + * 4> ^R$oue# d di MPAL................ * + * '$ "" @ ....................... * + * #b u# * + * $b .@" OS: [ ] DOS [X] WIN95 [ ] OS/2 * + * #$u .d" * + * '*$e. .zR".@ 様様様様様様様様様様様様様様様様様 * + * "*$$beooee$*" @"M This source code is * + * """ '$.? Copyright (C) Spyral Software * + * '$d> ALL RIGHTS RESERVED * + * '$> 様様様様様様様様様様様様様様様様様 * + * * + **************************************************************************/ + +/* +#include "lzo1x.h" +*/ +#include "mpal.h" +#include "mpaldll.h" + +namespace Tony { + +namespace MPAL { + + +/****************************************************************************\ +* Funzioni statiche +\****************************************************************************/ + +static bool CompareCommands(struct command *cmd1, struct command *cmd2) { + if (cmd1->type == 2 && cmd2->type == 2) { + if (strcmp(cmd1->lpszVarName,cmd2->lpszVarName)==0 && + CompareExpressions(cmd1->expr,cmd2->expr)) + return true; + else + return false; + } else + return (memcmp(cmd1,cmd2,sizeof(struct command))==0); +} + + +/****************************************************************************\ +* +* Function: LPBTYE ParseScript(byte *lpBuf, LPMPALSCRIPT lpmsScript); +* +* Description: Esegue il parsing da file .MPC di uno script e inserisce il +* tutto dentro una struttura +* +* Input: byte *lpBuf Buffer contenente lo script compilato +* LPMPALSCRIPT lpmsScript Puntatore a una struttura che verra' +* riempita con i dati dello script +* lato +* +* Return: Puntatore al buffer dopo l'item, o NULL in caso di errore +* +\****************************************************************************/ + +static byte *ParseScript(byte *lpBuf, LPMPALSCRIPT lpmsScript) { + int curCmd,j,len; + uint i; + + lpmsScript->nObj=*(int *)lpBuf; + lpBuf+=4; + + lpmsScript->nMoments=*(uint16 *)lpBuf; + lpBuf+=2; + + curCmd=0; + + for (i=0;inMoments;i++) { + lpmsScript->Moment[i].dwTime=*(int *)lpBuf; lpBuf+=4; + lpmsScript->Moment[i].nCmds=*lpBuf; lpBuf++; + + for (j=0;jMoment[i].nCmds;j++) { + lpmsScript->Command[curCmd].type=*lpBuf; lpBuf++; + switch (lpmsScript->Command[curCmd].type) { + case 1: + lpmsScript->Command[curCmd].nCf =*(uint16 *)(lpBuf); lpBuf+=2; + lpmsScript->Command[curCmd].arg1=*(int *)(lpBuf); lpBuf+=4; + lpmsScript->Command[curCmd].arg2=*(int *)(lpBuf); lpBuf+=4; + lpmsScript->Command[curCmd].arg3=*(int *)(lpBuf); lpBuf+=4; + lpmsScript->Command[curCmd].arg4=*(int *)(lpBuf); lpBuf+=4; + break; + + case 2: // Variable assign + len=*lpBuf; lpBuf++; + lpmsScript->Command[curCmd].lpszVarName=(char *)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,len+1); + if (lpmsScript->Command[curCmd].lpszVarName==NULL) + return NULL; + CopyMemory(lpmsScript->Command[curCmd].lpszVarName, lpBuf, len); + lpBuf+=len; + + lpBuf=ParseExpression(lpBuf,&lpmsScript->Command[curCmd].expr); + if (lpBuf==NULL) + return NULL; + break; + + default: + return NULL; + } + + lpmsScript->Moment[i].CmdNum[j]=curCmd; + curCmd++; + } + } + + return lpBuf; +} + + +/****************************************************************************\ +* +* Function: byte *ParseDialog(byte *lpBuf, LPMPALDIALOG lpmdDialog); +* +* Description: Esegue il parsing da file .MPC di un dialog, e inserisce il +* tutto dentro una struttura +* +* Input: byte *lpBuf Buffer contenente il dialogo compi- +* lato +* LPMPALDIALOG lpmdDialog Puntatore a una struttura che verra' +* riempita con i dati del dialogo +* compilato +* +* Return: Puntatore al buffer dopo il dialogo, o NULL in caso di errore +* +\****************************************************************************/ + +static byte *ParseDialog(byte *lpBuf, LPMPALDIALOG lpmdDialog) { + uint32 i,j,z,kk; + uint32 num,num2,num3; + byte *lpLock; + uint32 curCmd; + uint32 len; + + lpmdDialog->nObj=*(int *)lpBuf; + lpBuf+=4; + + /* Periodi */ + num=*(uint16 *)lpBuf; lpBuf+=2; + + if (num >= MAX_PERIODS_PER_DIALOG-1) { + Common::String msg = Common::String::format("Too much periods in dialog #%d",lpmdDialog->nObj); + MessageBox(msg); + } + + for (i=0;iPeriodNums[i]=*(uint16 *)lpBuf; lpBuf+=2; + lpmdDialog->Periods[i]=GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT,*lpBuf+1); + lpLock = (byte *)GlobalLock(lpmdDialog->Periods[i]); + CopyMemory(lpLock,lpBuf+1,*lpBuf); + GlobalUnlock(lpmdDialog->Periods[i]); + lpBuf+=(*lpBuf)+1; + } + + lpmdDialog->PeriodNums[i]=0; + lpmdDialog->Periods[i]=NULL; + + /* Gruppi */ + num=*(uint16 *)lpBuf; lpBuf+=2; + curCmd=0; + + if (num >= MAX_GROUPS_PER_DIALOG) { + Common::String msg = Common::String::format("Too much groups in dialog #%d",lpmdDialog->nObj); + MessageBox(msg); + } + + for (i=0;iGroup[i].num=*(uint16 *)lpBuf; lpBuf+=2; + lpmdDialog->Group[i].nCmds=*lpBuf; lpBuf++; + + if (lpmdDialog->Group[i].nCmds >= MAX_COMMANDS_PER_GROUP) { + Common::String msg = Common::String::format("Too much commands in group #%d in dialog #%d",lpmdDialog->Group[i].num,lpmdDialog->nObj); + MessageBox(msg); + } + + for (j=0;jGroup[i].nCmds;j++) { + lpmdDialog->Command[curCmd].type=*lpBuf; + lpBuf++; + + switch (lpmdDialog->Command[curCmd].type) { + // Call custom function + case 1: + lpmdDialog->Command[curCmd].nCf =*(uint16 *)(lpBuf); lpBuf+=2; + lpmdDialog->Command[curCmd].arg1=*(int *)(lpBuf); lpBuf+=4; + lpmdDialog->Command[curCmd].arg2=*(int *)(lpBuf); lpBuf+=4; + lpmdDialog->Command[curCmd].arg3=*(int *)(lpBuf); lpBuf+=4; + lpmdDialog->Command[curCmd].arg4=*(int *)(lpBuf); lpBuf+=4; + break; + + // Variable assign + case 2: + len=*lpBuf; + lpBuf++; + lpmdDialog->Command[curCmd].lpszVarName=(char *)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,len+1); + if (lpmdDialog->Command[curCmd].lpszVarName==NULL) + return NULL; + CopyMemory(lpmdDialog->Command[curCmd].lpszVarName,lpBuf,len); + lpBuf+=len; + + lpBuf=ParseExpression(lpBuf,&lpmdDialog->Command[curCmd].expr); + if (lpBuf==NULL) + return NULL; + break; + + // Do Choice + case 3: + lpmdDialog->Command[curCmd].nChoice=*(uint16 *)lpBuf; lpBuf+=2; + break; + + default: + return NULL; + } + + for (kk=0;kkCommand[kk],&lpmdDialog->Command[curCmd])) { + lpmdDialog->Group[i].CmdNum[j]=kk; + break; + } + } + + if (kk==curCmd) { + lpmdDialog->Group[i].CmdNum[j]=curCmd; + curCmd++; + } + } + } + + if (curCmd >= MAX_COMMANDS_PER_DIALOG) { + Common::String msg = Common::String::format("Too much commands in dialog #%d",lpmdDialog->nObj); + MessageBox(msg); + } + + /* Choices */ + num=*(uint16 *)lpBuf; lpBuf+=2; + + if (num >= MAX_CHOICES_PER_DIALOG) { + Common::String msg = Common::String::format("Too much choices in dialog #%d",lpmdDialog->nObj); + MessageBox(msg); + } + + for (i=0;iChoice[i].nChoice=*(uint16 *)lpBuf; lpBuf+=2; + + num2=*lpBuf++; + + if (num2 >= MAX_SELECTS_PER_CHOICE) { + Common::String msg = Common::String::format("Too much selects in choice #%d in dialog #%d",lpmdDialog->Choice[i].nChoice,lpmdDialog->nObj); + MessageBox(msg); + } + + for (j=0;jChoice[i].Select[j].when=NULL; + break; + + case 1: + lpBuf=ParseExpression(lpBuf,&lpmdDialog->Choice[i].Select[j].when); + if (lpBuf==NULL) + return NULL; + break; + + case 2: + return NULL; + } + + // Attrib + lpmdDialog->Choice[i].Select[j].attr=*lpBuf++; + + // Data + lpmdDialog->Choice[i].Select[j].dwData=*(uint32 *)lpBuf; lpBuf+=4; + + // PlayGroup + num3=*lpBuf; *lpBuf++; + + if (num3 >= MAX_PLAYGROUPS_PER_SELECT) { + Common::String msg = Common::String::format("Too much playgroups in select #%d in choice #%d in dialog #%d",j,lpmdDialog->Choice[i].nChoice,lpmdDialog->nObj); + MessageBox(msg); + } + + for (z=0;zChoice[i].Select[j].wPlayGroup[z]=*(uint16 *)lpBuf; lpBuf+=2; + } + + lpmdDialog->Choice[i].Select[j].wPlayGroup[num3]=0; + } + + // Segna l'ultimo select + lpmdDialog->Choice[i].Select[num2].dwData=0; + } + + lpmdDialog->Choice[num].nChoice=0; + + return lpBuf; +} + +/****************************************************************************\ +* +* Function: byte *ParseItem(byte *lpBuf, LPMPALITEM lpmiItem); +* +* Description: Esegue il parsing da file .MPC di un item, e inserisce il +* tutto dentro una struttura +* +* Input: byte *lpBuf Buffer contenete l'item compilato +* LPMPALITEM lpmiItem Puntatore a una struttura che verra' +* riempita con i dati dell'item +* compilato +* +* Return: Puntatore al buffer dopo l'item, o NULL in caso di errore +* +* Note: E' necessario che la struttura passata come parametro sia +* stata completamente inizializzata a 0 (con una ZeroMemory, +* ad esempio). +* +\****************************************************************************/ + +static byte *ParseItem(byte *lpBuf, LPMPALITEM lpmiItem) { + byte len; + uint32 i,j,kk; + uint32 curCmd; + + lpmiItem->nObj=*(int *)lpBuf; + lpBuf+=4; + + len=*lpBuf; + lpBuf++; + CopyMemory(lpmiItem->lpszDescribe,lpBuf, MIN((byte)127, len)); + lpBuf+=len; + + if (len >= MAX_DESCRIBE_SIZE) { + Common::String msg = Common::String::format("Describe too long in item #%d",lpmiItem->nObj); + MessageBox(msg); + } + + lpmiItem->nActions=*lpBuf; + lpBuf++; + + /* Alloca le azioni */ + if (lpmiItem->nActions>0) + lpmiItem->Action = (ItemAction *)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,sizeof(struct ItemAction)*(int)lpmiItem->nActions); + + curCmd=0; + + for (i=0;inActions;i++) { + lpmiItem->Action[i].num=*lpBuf; + lpBuf++; + + lpmiItem->Action[i].wParm=*(uint16 *)lpBuf; + lpBuf+=2; + + if (lpmiItem->Action[i].num==0xFF) { + lpmiItem->Action[i].wTime=*(uint16 *)lpBuf; + lpBuf+=2; + + lpmiItem->Action[i].perc=*lpBuf; + lpBuf++; + } + + + if (*lpBuf==0) { + lpBuf++; + lpmiItem->Action[i].when=NULL; + } else { + lpBuf++; + lpBuf=ParseExpression(lpBuf,&lpmiItem->Action[i].when); + if (lpBuf==NULL) + return NULL; + } + + lpmiItem->Action[i].nCmds=*lpBuf; + lpBuf++; + + if (lpmiItem->Action[i].nCmds >= MAX_COMMANDS_PER_ACTION) { + Common::String msg = Common::String::format("Too much commands in action #%d in item #%d",lpmiItem->Action[i].num,lpmiItem->nObj); + MessageBox(msg); + } + + for (j=0;jAction[i].nCmds;j++) { + lpmiItem->Command[curCmd].type=*lpBuf; + lpBuf++; + switch (lpmiItem->Command[curCmd].type) { + case 1: // Call custom function + lpmiItem->Command[curCmd].nCf =*(uint16 *)(lpBuf); lpBuf+=2; + lpmiItem->Command[curCmd].arg1=*(int *)(lpBuf); lpBuf+=4; + lpmiItem->Command[curCmd].arg2=*(int *)(lpBuf); lpBuf+=4; + lpmiItem->Command[curCmd].arg3=*(int *)(lpBuf); lpBuf+=4; + lpmiItem->Command[curCmd].arg4=*(int *)(lpBuf); lpBuf+=4; + break; + + case 2: // Variable assign + len=*lpBuf; + lpBuf++; + lpmiItem->Command[curCmd].lpszVarName=(char *)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,len+1); + if (lpmiItem->Command[curCmd].lpszVarName==NULL) + return NULL; + CopyMemory(lpmiItem->Command[curCmd].lpszVarName,lpBuf,len); + lpBuf+=len; + + lpBuf=ParseExpression(lpBuf,&lpmiItem->Command[curCmd].expr); + if (lpBuf==NULL) + return NULL; + break; + + default: + return NULL; + } + + for (kk=0;kkCommand[kk],&lpmiItem->Command[curCmd])) { + lpmiItem->Action[i].CmdNum[j]=kk; + break; + } + } + + if (kk==curCmd) { + lpmiItem->Action[i].CmdNum[j]=curCmd; + curCmd++; + + if (curCmd >= MAX_COMMANDS_PER_ITEM) { + Common::String msg = Common::String::format("Too much commands in item #%d",lpmiItem->nObj); + MessageBox(msg); + curCmd=0; + } + } + } + } + + lpmiItem->dwRes=*(uint32 *)lpBuf; lpBuf+=4; + + return lpBuf; +} + + +/****************************************************************************\ +* +* Function: byte *ParseLocation(byte *buf, LPMPALLOCATIONN lpmlLocation) +* +* Description: Esegue il parsing da file .MPC di una locazione, riempendo +* una struttura +* +* Input: byte *buf Buffer contenente la locazione +* compilata +* LPMPALLOCATION +* lpmlLocation Pointer alla struttura che verra' +* riempita con i dati sulla locazione +* +* Return: Puntatore al buffer dopo l'item, o NULL in caso di errore +* +\****************************************************************************/ + +static byte *ParseLocation(byte *lpBuf, LPMPALLOCATION lpmlLocation) { + lpmlLocation->nObj=*(int *)lpBuf; + lpBuf+=4; + lpmlLocation->dwXlen=*(uint16 *)lpBuf; + lpBuf+=2; + lpmlLocation->dwYlen=*(uint16 *)lpBuf; + lpBuf+=2; + lpmlLocation->dwPicRes=*(uint32 *)lpBuf; + lpBuf+=4; + + return lpBuf; +} + +/*static int CompareMoments(int * a, int * b) { + if (*a<*b) + return -1; + else if (*a>*b) + return 1; + else + return 0; +}*/ + +/****************************************************************************\ +* Funzioni globali +\****************************************************************************/ + +/****************************************************************************\ +* +* Function: bool ParseMpc(byte *lpBuf); +* +* Description: Legge e interpreta un file MPC, e crea le strutture per le +* varie direttive nelle variabili globali +* +* Input: byte *lpBuf Immagine in memoria del file MPC, +* escluso l'header +* +* Return: true se tutto OK, false in caso di errore. +* +\****************************************************************************/ + +bool ParseMpc(byte *lpBuf) { + uint16 i,j; + uint16 wLen; + byte *lpTemp, *lpTemp2; + + // Oggetti dummy. Definiti static per evitare stack overflow + static MPALITEM dummyitem; + static MPALLOCATION dummylocation; + static MPALSCRIPT dummyscript; + static MPALDIALOG dummydialog; + + /* 1. Variabili */ + if (lpBuf[0]!='V' || lpBuf[1]!='A' || lpBuf[2]!='R' || lpBuf[3]!='S') + return false; + + lpBuf+=4; + nVars=*(uint16 *)lpBuf; + lpBuf+=2; + + hVars=GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT,sizeof(MPALVAR)*(uint32)nVars); + if (hVars==NULL) + return false; + + lpmvVars=(LPMPALVAR)GlobalLock(hVars); + + for (i=0;ilpszVarName,lpBuf,MIN(wLen, (uint16)32)); + lpBuf+=wLen; + lpmvVars->dwVal=*(int *)lpBuf; + lpBuf+=4; + + lpBuf++; // Salta 'ext' + lpmvVars++; + } + + GlobalUnlock(hVars); + + /* 2. Messaggi */ + if (lpBuf[0]!='M' || lpBuf[1]!='S' || lpBuf[2]!='G' || lpBuf[3]!='S') + return false; + + lpBuf+=4; + nMsgs=*(uint16 *)lpBuf; + lpBuf+=2; + +#ifdef NEED_LOCK_MSGS + hMsgs=GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT,sizeof(MPALMSG)*(uint32)nMsgs); + if (hMsgs==NULL) + return false; + + lpmmMsgs=(LPMPALMSG)GlobalLock(hMsgs); +#else + lpmmMsgs=(LPMPALMSG)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,sizeof(MPALMSG)*(uint32)nMsgs); + if (lpmmMsgs==NULL) + return false; +#endif + + for (i=0;iwNum=*(uint16 *)lpBuf; + lpBuf+=2; + + for (j=0;lpBuf[j]!=0;) + j+=lpBuf[j]+1; + + lpmmMsgs->hText=GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT,j+1); + lpTemp2=lpTemp=(byte *)GlobalLock(lpmmMsgs->hText); + + for (j=0;lpBuf[j]!=0;) { + CopyMemory(lpTemp,&lpBuf[j+1],lpBuf[j]); + lpTemp+=lpBuf[j]; + *lpTemp++='\0'; + j+=lpBuf[j]+1; + } + + lpBuf+=j+1; + *lpTemp='\0'; + + GlobalUnlock(lpmmMsgs->hText); + lpmmMsgs++; + } + +#ifdef NEED_LOCK_MSGS + GlobalUnlock(hMsgs); +#endif + + /* 3. Oggetti */ + if (lpBuf[0]!='O' || lpBuf[1]!='B' || lpBuf[2]!='J' || lpBuf[3]!='S') + return false; + + lpBuf+=4; + nObjs=*(uint16 *)lpBuf; + lpBuf+=2; + + // Controlla i dialoghi + nDialogs=0; + hDialogs=lpmdDialogs=NULL; + if (*((const char *)lpBuf+2)==6 && strncmp((const char *)lpBuf+3,"Dialog",6)==0) { + nDialogs=*(uint16 *)lpBuf; lpBuf+=2; + + hDialogs=GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT,(uint32)nDialogs*sizeof(MPALDIALOG)); + if (hDialogs==NULL) + return false; + + lpmdDialogs=(LPMPALDIALOG)GlobalLock(hDialogs); + + for (i=0;i '$N'*$u * * + * M $L #$ $ 8 "$c'#$b.. .@ Author: Giovanni Bajo.......... * + * M '$u "$u :" *$. "#*#" * + * M '$N. " F ^$k Desc: Legge un file compilato * + * 4> ^R$oue# d MPC.................... * + * '$ "" @ ....................... * + * #b u# * + * $b .@" OS: [ ] DOS [X] WIN95 [ ] OS/2 * + * #$u .d" * + * '*$e. .zR".@ 様様様様様様様様様様様様様様様様様 * + * "*$$beooee$*" @"M This source code is * + * """ '$.? Copyright (C) Spyral Software * + * '$d> ALL RIGHTS RESERVED * + * '$> 様様様様様様様様様様様様様様様様様 * + * * + **************************************************************************/ + +#ifndef __LOADMPC_H +#define __LOADMPC_H + +namespace Tony { + +namespace MPAL { + +/****************************************************************************\ +* Prototipi di funzione +\****************************************************************************/ + +/****************************************************************************\ +* +* Function: BOOL ParseMpc(LPBYTE lpBuf); +* +* Description: Legge e interpreta un file MPC, e crea le strutture per le +* varie direttive nelle variabili globali +* +* Input: LPBYTE lpBuf Immagine in memoria del file MPC, +* escluso l'header +* +* Return: TRUE se tutto OK, FALSE in caso di errore. +* +\****************************************************************************/ + +bool ParseMpc(const byte *lpBuf); + + +} // end of namespace MPAL + +} // end of namespace Tony + +#endif + diff --git a/engines/tony/mpal/lzo1x.h b/engines/tony/mpal/lzo1x.h new file mode 100644 index 0000000000..83b547428c --- /dev/null +++ b/engines/tony/mpal/lzo1x.h @@ -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. + * + * + */ +/* lzo1x.h -- public interface of the LZO1X compression algorithm + + This file is part of the LZO real-time data compression library. + + Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer + + The LZO library is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + The LZO library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with the LZO library; see the file COPYING. + If not, write to the Free Software Foundation, Inc., + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + Markus F.X.J. Oberhumer + + http://wildsau.idv.uni-linz.ac.at/mfx/lzo.html + */ + + +#ifndef __LZO1X_H +#define __LZO1X_H + +#ifndef __LZOCONF_H +#include "lzoconf.h" +#endif + +namespace Tony { + +namespace MPAL { + +/*********************************************************************** +// +************************************************************************/ + +/* Memory required for the wrkmem parameter. + * When the required size is 0, you can also pass a NULL pointer. + */ + +#define LZO1X_MEM_COMPRESS LZO1X_1_MEM_COMPRESS +#define LZO1X_MEM_DECOMPRESS (0) +#define LZO1X_MEM_OPTIMIZE (0) + + +/* decompression */ +LZO_EXTERN(int) +lzo1x_decompress ( const lzo_byte *src, lzo_uint src_len, + lzo_byte *dst, lzo_uint *dst_len, + lzo_voidp wrkmem /* NOT USED */ ); + +/* safe decompression with overrun testing */ +LZO_EXTERN(int) +lzo1x_decompress_safe ( const lzo_byte *src, lzo_uint src_len, + lzo_byte *dst, lzo_uint *dst_len, + lzo_voidp wrkmem /* NOT USED */ ); + + +/*********************************************************************** +// +************************************************************************/ + +#define LZO1X_1_MEM_COMPRESS ((lzo_uint32) (16384L * lzo_sizeof_dict_t)) + +LZO_EXTERN(int) +lzo1x_1_compress ( const lzo_byte *src, lzo_uint src_len, + lzo_byte *dst, lzo_uint *dst_len, + lzo_voidp wrkmem ); + + +/*********************************************************************** +// special compressor versions +************************************************************************/ + +/* this version needs only 8 kB work memory */ +#define LZO1X_1_11_MEM_COMPRESS ((lzo_uint32) (2048L * lzo_sizeof_dict_t)) + +LZO_EXTERN(int) +lzo1x_1_11_compress ( const lzo_byte *src, lzo_uint src_len, + lzo_byte *dst, lzo_uint *dst_len, + lzo_voidp wrkmem ); + + +/* this version needs 16 kB work memory */ +#define LZO1X_1_12_MEM_COMPRESS ((lzo_uint32) (4096L * lzo_sizeof_dict_t)) + +LZO_EXTERN(int) +lzo1x_1_12_compress ( const lzo_byte *src, lzo_uint src_len, + lzo_byte *dst, lzo_uint *dst_len, + lzo_voidp wrkmem ); + + +/* use this version if you need a little more compression speed */ +#define LZO1X_1_15_MEM_COMPRESS ((lzo_uint32) (32768L * lzo_sizeof_dict_t)) + +LZO_EXTERN(int) +lzo1x_1_15_compress ( const lzo_byte *src, lzo_uint src_len, + lzo_byte *dst, lzo_uint *dst_len, + lzo_voidp wrkmem ); + + +/*********************************************************************** +// better compression ratio at the cost of more memory and time +************************************************************************/ + +#define LZO1X_999_MEM_COMPRESS ((lzo_uint32) (14 * 16384L * sizeof(short))) + +#if !defined(LZO_999_UNSUPPORTED) +LZO_EXTERN(int) +lzo1x_999_compress ( const lzo_byte *src, lzo_uint src_len, + lzo_byte *dst, lzo_uint *dst_len, + lzo_voidp wrkmem ); +#endif + + +/*********************************************************************** +// +************************************************************************/ + +#if !defined(LZO_999_UNSUPPORTED) +LZO_EXTERN(int) +lzo1x_999_compress_dict ( const lzo_byte *in , lzo_uint in_len, + lzo_byte *out, lzo_uint *out_len, + lzo_voidp wrkmem, + const lzo_byte *dict, lzo_uint dict_len ); + +LZO_EXTERN(int) +lzo1x_999_compress_level ( const lzo_byte *in , lzo_uint in_len, + lzo_byte *out, lzo_uint *out_len, + lzo_voidp wrkmem, + const lzo_byte *dict, lzo_uint dict_len, + lzo_progress_callback_t cb, + int compression_level ); +#endif + +LZO_EXTERN(int) +lzo1x_decompress_dict_safe ( const lzo_byte *in, lzo_uint in_len, + lzo_byte *out, lzo_uint *out_len, + lzo_voidp wrkmem /* NOT USED */, + const lzo_byte *dict, lzo_uint dict_len ); + + +/*********************************************************************** +// optimize a compressed data block +************************************************************************/ + +LZO_EXTERN(int) +lzo1x_optimize ( lzo_byte *in , lzo_uint in_len, + lzo_byte *out, lzo_uint *out_len, + lzo_voidp wrkmem ); + + +} // end of namespace MPAL + +} // end of namespace Tony + +#endif /* already included */ diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp new file mode 100644 index 0000000000..2fd9f3b9c3 --- /dev/null +++ b/engines/tony/mpal/mpal.cpp @@ -0,0 +1,3071 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * + */ +/************************************************************************** + * 様様様様様様様様様様様様様様様様様 * + * ... Spyral Software snc * + * . x#""*$Nu -= We create much MORE than ALL =- * + * d*#R$. R ^#$o 様様様様様様様様様様様様様様様様様 * + * .F ^$k $ "$b * + * ." $b u "$ #$L * + * P $c :*$L"$L '$k Project: MPAL................... * + * d @$N. $. d ^$b^$k $c * + * F 4 "$c '$ $ #$u#$u '$ Module: Mpal Query Library..... * + * 4 4k *N #b .> '$N'*$u * * + * M $L #$ $ 8 "$c'#$b.. .@ Author: Giovanni Bajo.......... * + * M '$u "$u :" *$. "#*#" * + * M '$N. " F ^$k Desc: Libreria principale di * + * 4> ^R$oue# d MPAL, contenente il * + * '$ "" @ codice per le query.... * + * #b u# * + * $b .@" OS: [ ] DOS [X] WIN95 [ ] OS/2 * + * #$u .d" * + * '*$e. .zR".@ 様様様様様様様様様様様様様様様様様 * + * "*$$beooee$*" @"M This source code is * + * """ '$.? Copyright (C) Spyral Software * + * '$d> ALL RIGHTS RESERVED * + * '$> 様様様様様様様様様様様様様様様様様 * + * * + **************************************************************************/ + +#include "common/scummsys.h" +#include "common/file.h" +#include "common/savefile.h" +#include "common/system.h" +#include "mpal.h" +#include "mpaldll.h" +#include "stubs.h" +#include "tony/tony.h" +#include "tony/lzo/lzo1x.h" + +namespace Tony { + +namespace MPAL { + +using namespace Tony::LZO; + +/****************************************************************************\ +* Copyright +\****************************************************************************/ + +const char *mpalCopyright = + "\n\nMPAL - MultiPurpose Adventure Language for Windows 95\n" + "Copyright 1997-98 Giovanni Bajo and Luca Giusti\n" + "ALL RIGHTS RESERVED\n" + "\n" + "\n"; + +/****************************************************************************\ +* Structures +\****************************************************************************/ + +/****************************************************************************\ +* typedef CFCALL +* -------------- +* Description: Descrizione di una chiamata a una custom function +\****************************************************************************/ + +typedef struct { + int nCf; + + int arg1, arg2, arg3, arg4; +} CFCALL; +typedef CFCALL* LPCFCALL; +typedef LPCFCALL* LPLPCFCALL; + + +/****************************************************************************\ +* Global variables +\****************************************************************************/ + +uint32 mpalError; + +static bool bInit=false; +static byte * lpMpcImage; + +LPITEMIRQFUNCTION lpiifCustom=NULL; + +LPLPCUSTOMFUNCTION lplpFunctions=NULL; +uint16 nObjs; + +uint16 nVars; +HGLOBAL hVars; +LPMPALVAR lpmvVars; + +uint16 nMsgs; +HGLOBAL hMsgs; +LPMPALMSG lpmmMsgs; + +uint16 nDialogs; +HGLOBAL hDialogs; +LPMPALDIALOG lpmdDialogs; + +uint16 nItems; +HGLOBAL hItems; +LPMPALITEM lpmiItems; + +uint16 nLocations; +HGLOBAL hLocations; +LPMPALLOCATION lpmlLocations; + +uint16 nScripts; +HGLOBAL hScripts; +LPMPALSCRIPT lpmsScripts; + +Common::File hMpr; +uint16 nResources; +uint32 * lpResources; + +bool bExecutingAction; +bool bExecutingDialog; + +uint32 nPollingLocations[MAXPOLLINGLOCATIONS]; +HANDLE hEndPollingLocations[MAXPOLLINGLOCATIONS]; +HANDLE PollingThreads[MAXPOLLINGLOCATIONS]; + +HANDLE hAskChoice; +HANDLE hDoneChoice; + +uint32 nExecutingAction; + +uint32 nExecutingDialog; +uint32 nExecutingChoice; +uint32 nSelectedChoice; + + +/****************************************************************************\ +* Static functions +\****************************************************************************/ + +/****************************************************************************\ +* +* Function: void LockVar(void); +* +* Description: Locka le variabili per accederci +* +\****************************************************************************/ + +void LockVar(void) { + lpmvVars=(LPMPALVAR)GlobalLock(hVars); +} + +/****************************************************************************\ +* +* Function: void UnlockVar(void); +* +* Description: Unlocka le variabili dopo l'uso +* +\****************************************************************************/ + +void UnlockVar(void) { + GlobalUnlock(hVars); +} + + +/****************************************************************************\ +* +* Function: void LockMsg(void); +* +* Description: Locka i messaggi per accederci +* +\****************************************************************************/ + +static void LockMsg(void) { +#ifdef NEED_LOCK_MSGS + lpmmMsgs=(LPMPALMSG)GlobalLock(hMsgs); +#endif +} + + +/****************************************************************************\ +* +* Function: void UnlockMsg(void); +* +* Description: Unlocka i messaggi dopo l'uso +* +\****************************************************************************/ + +static void UnlockMsg(void) { +#ifdef NEED_LOCK_MSGS + GlobalUnlock(hMsgs); +#endif +} + + +/****************************************************************************\ +* +* Function: void LockDialogs(void); +* +* Description: Locka i dialoghi per accederci +* +\****************************************************************************/ + +static void LockDialogs(void) { + lpmdDialogs=(LPMPALDIALOG)GlobalLock(hDialogs); +} + + +/****************************************************************************\ +* +* Function: void UnlockDialogs(void); +* +* Description: Unlocka i dialoghi dopo l'uso +* +\****************************************************************************/ + +static void UnlockDialogs(void) { + GlobalUnlock(hDialogs); +} + + +/****************************************************************************\ +* +* Function: void LockLocations(void); +* +* Description: Locka le strutture di dati sulle locazioni +* +\****************************************************************************/ + +static void LockLocations(void) { + lpmlLocations=(LPMPALLOCATION)GlobalLock(hLocations); +} + + +/****************************************************************************\ +* +* Function: void UnlockLocations(void); +* +* Description: Unlocka le strutture di dati sulle locazioni +* +\****************************************************************************/ + +static void UnlockLocations(void) { + GlobalUnlock(hLocations); +} + + +/****************************************************************************\ +* +* Function: void LockItems(void); +* +* Description: Locka le strutture di dati sugli item +* +\****************************************************************************/ + +static void LockItems(void) { + lpmiItems=(LPMPALITEM)GlobalLock(hItems); +} + + +/****************************************************************************\ +* +* Function: void UnlockItems(void); +* +* Description: Unlocka le strutture di dati sugli item +* +\****************************************************************************/ + +static void UnlockItems(void) { + GlobalUnlock(hItems); +} + +/****************************************************************************\ +* +* Function: void LockScripts(void); +* +* Description: Locka le strutture di dati sugli script +* +\****************************************************************************/ + +static void LockScripts(void) { + lpmsScripts=(LPMPALSCRIPT)GlobalLock(hScripts); +} + + +/****************************************************************************\ +* +* Function: void UnlockScripts(void); +* +* Description: Unlocka le strutture di dati sugli script +* +\****************************************************************************/ + +static void UnlockScripts(void) { + GlobalUnlock(hScripts); +} + + + + + +/****************************************************************************\ +* +* Function: int varGetValue(char * lpszVarName); +* +* Description: Restituisce il valore corrente di una variabile globale +* +* Input: char * lpszVarName Nome della variabile +* +* Return: Valore corrente +* +* Note: Prima di questa funzione, bisogna richiamare LockVar() che +* locka le variabili globali per l'utilizzo. Dopo inoltre bi- +* sogna ricordarsi di chiamare UnlockVar() +* +\****************************************************************************/ + +int32 varGetValue(const char *lpszVarName) { + int i; + LPMPALVAR v=lpmvVars; + + for (i=0;ilpszVarName)==0) + return v->dwVal; + + mpalError=1; + return 0; +} + + +/****************************************************************************\ +* +* Function: void varSetValue(char * lpszVarName, int val); +* +* Description: Setta un nuovo valore per una variabile globale di MPAL +* +* Input: char * lpszVarName Nome della variabile +* int val Valore da settare +* +\****************************************************************************/ + +void varSetValue(const char *lpszVarName, int32 val) { + int i; + LPMPALVAR v=lpmvVars; + + for (i=0;ilpszVarName)==0) { + v->dwVal=val; + if (lpiifCustom!=NULL && strncmp(v->lpszVarName,"Pattern.",8)==0) { + i=0; + sscanf(v->lpszVarName,"Pattern.%u",&i); + lpiifCustom(i,val,-1); + } else if (lpiifCustom!=NULL && strncmp(v->lpszVarName,"Status.",7)==0) { + i=0; + sscanf(v->lpszVarName,"Status.%u",&i); + lpiifCustom(i,-1,val); + } + return; + } + + mpalError=1; + return; +} + + +/****************************************************************************\ +* +* Function: int locGetOrderFromNum(uint32 nLoc); +* +* Description: Trova l'indice della locazione #nLoc all'interno dell'array +* delle strutture delle locazioni +* +* Input: uint32 nLoc Numero della locazione da cercare +* +* Return: Indice, o -1 se la locazione non e' presente +* +* Note: Per funzionare, la funzione necessita che le locazioni siano +* state lockate con LockLoc() +* +\****************************************************************************/ + +static int locGetOrderFromNum(uint32 nLoc) { + int i; + LPMPALLOCATION loc=lpmlLocations; + + for (i=0;inObj==nLoc) + return i; + + return -1; +} + +/****************************************************************************\ +* +* Function: int msgGetOrderFromNum(uint32 nMsg); +* +* Description: Trova l'indice del messaggio #nMsg all'interno dell'array +* delle strutture dei messaggi +* +* Input: uint32 nMsg Numero del messaggio da cercare +* +* Return: Indice, o -1 se il messaggio non e' presente +* +* Note: Per funzionare, la funzione necessita che i messaggi siano +* stati lockati con LockMsg() +* +\****************************************************************************/ + +static int msgGetOrderFromNum(uint32 nMsg) { + int i; + LPMPALMSG msg=lpmmMsgs; + + for (i=0;iwNum==nMsg) + return i; + + return -1; +} + + +/****************************************************************************\ +* +* Function: int itemGetOrderFromNum(uint32 nItem); +* +* Description: Trova l'indice dell'item #nItem all'interno dell'array delle +* strutture degli item +* +* Input: uint32 nItem Numero dell'item da cercare +* +* Return: Indice, o -1 se l'item non e' presente +* +* Note: Per funzionare, questa funzione necessita che gli item siano +* stati lockati tramite LockItem() +* +\****************************************************************************/ + +static int itemGetOrderFromNum(uint32 nItem) { + int i; + LPMPALITEM item=lpmiItems; + + for (i=0;inObj==nItem) + return i; + + return -1; +} + + +/****************************************************************************\ +* +* Function: int scriptGetOrderFromNum(uint32 nScript); +* +* Description: Trova l'indice dello script #nScript all'interno dell'array +* delle strutture degli script +* +* Input: uint32 nScript Numero dello script da cercare +* +* Return: Indice, o -1 se lo script non e' presente +* +* Note: Per funzionare, questa funzione necessita che gli script siano +* stati lockati tramite LockScript() +* +\****************************************************************************/ + +static int scriptGetOrderFromNum(uint32 nScript) { + int i; + LPMPALSCRIPT script=lpmsScripts; + + for (i=0;inObj==nScript) + return i; + + return -1; +} + + +/****************************************************************************\ +* +* Function: int dialogGetOrderFromNum(uint32 nDialog); +* +* Description: Trova l'indice del dialog #nDialog all'interno dell'array +* delle strutture dei dialog +* +* Input: uint32 nDialog Numero del dialog da cercare +* +* Return: Indice, o -1 se il dialog non e' presente +* +* Note: Per funzionare, questa funzione necessita che i dialog siano +* stati lockati tramite LockDialogs() +* +\****************************************************************************/ + +static int dialogGetOrderFromNum(uint32 nDialog) { + int i; + LPMPALDIALOG dialog=lpmdDialogs; + + for (i=0;inObj==nDialog) + return i; + + return -1; +} + + + +/****************************************************************************\ +* +* Function: char * DuplicateMessage(uint32 nMsgOrd); +* +* Description: Duplica un messaggio +* +* Input: uint32 nMsgOrd Indice del messaggio dentro l'array +* di strutture dei messaggi +* +* Return: Pointer al messaggio duplicato (che puo' essere liberato +* con GlobalFree()). +* +\****************************************************************************/ + +static char *DuplicateMessage(uint32 nMsgOrd) { + const char *origmsg; + char *clonemsg; + int j; + + if (nMsgOrd == (uint32)-1) + return NULL; + + origmsg = (const char *)GlobalLock(lpmmMsgs[nMsgOrd].hText); + + j=0; + while (origmsg[j]!='\0' || origmsg[j+1]!='\0') + j++; + j+=2; + + clonemsg=(char *)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,j); + if (clonemsg==NULL) + return NULL; + + CopyMemory(clonemsg, origmsg, j); + GlobalUnlock(lpmmMsgs[nMsgOrd].hText); + + return clonemsg; +} + + +/****************************************************************************\ +* +* Function: char * DuplicateDialogPeriod(uint32 nDlgOrd, uint32 nPeriod); +* +* Description: Duplica una frase di un dialog +* +* Input: uint32 nDlgOrd Indice del dialogo dentro l'array di +* strutture dei dialoghi +* +* uint32 nPeriod Numero della frase da duplicare +* +* Return: Pointer alla frase duplicata (che puo' essere liberata con +* GlobalFree()). +* +\****************************************************************************/ + +static char *DuplicateDialogPeriod(uint32 nPeriod) { + const char *origmsg; + char *clonemsg; + LPMPALDIALOG dialog=lpmdDialogs+nExecutingDialog; + int i,j; + + for (j=0;dialog->Periods[j]!=NULL;j++) + if (dialog->PeriodNums[j]==nPeriod) { + /* Trovata la frase, va duplicata */ + origmsg = (const char *)GlobalLock(dialog->Periods[j]); + + /* Calcola la lunghezza e alloca la memoria */ + i=0; + while (origmsg[i]!='\0') i++; + + clonemsg = (char *)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,i+1); + if (clonemsg==NULL) + return NULL; + + CopyMemory(clonemsg, origmsg, i); + + GlobalUnlock(dialog->Periods[j]); + + return clonemsg; + } + + return NULL; +} + + + +/****************************************************************************\ +* +* Function: HGLOBAL resLoad(uint32 dwId); +* +* Description: Carica una risorsa dal file MPR +* +* Input: uint32 dwId ID della risorsa da caricare +* +* Return: Handle alla memoria in cui si trova la risorsa +* +\****************************************************************************/ + +HGLOBAL resLoad(uint32 dwId) { + int i; + HGLOBAL h; + char head[4]; + uint32 nBytesRead; + uint32 nSizeComp, nSizeDecomp; + byte *temp, *buf; + + for (i=0;iChoice[i].Select[j].dwData!=0;j++) + if (dialog->Choice[i].Select[j].curActive) + num++; + + /* Se sono 0, e' un errore */ + if (num==0) + return NULL; + + sl= (uint32 *)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,sizeof(uint32)*(num+1)); + if (sl==NULL) + return NULL; + + /* Copia il dato di ogni select attivo dentro la lista */ + k=0; + for (j=0;dialog->Choice[i].Select[j].dwData!=0;j++) + if (dialog->Choice[i].Select[j].curActive) + sl[k++]=dialog->Choice[i].Select[j].dwData; + + sl[k] = (uint32)NULL; + return sl; +} + +static uint32 *GetItemList(uint32 nLoc) { + uint32 *il; + uint32 num,i,j; + LPMPALVAR v=lpmvVars; + + num=0; + for (i=0;ilpszVarName,"Location",8)==0 && v->dwVal==nLoc) + num++; + } + + il=(uint32 *)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,sizeof(uint32)*(num+1)); + if (il==NULL) + return NULL; + + v=lpmvVars; + j=0; + for (i=0;ilpszVarName,"Location",8)==0 && v->dwVal==nLoc) { + sscanf(v->lpszVarName,"Location.%u",&il[j]); + j++; + } + } + + il[j] = (uint32)NULL; + return il; +} + +static LPITEM GetItemData(uint32 nOrdItem) { + LPMPALITEM curitem=lpmiItems+nOrdItem; + LPITEM ret; + HGLOBAL hDat; + char *dat; + int i,j; + char *patlength; + uint32 dim; + + // Lo zeroinit e' obbligatorio!!!! + ret = (LPITEM)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,sizeof(ITEM)); + if (ret==NULL) + return NULL; + ret->speed=150; + + hDat = resLoad(curitem->dwRes); + dat = (char *)GlobalLock(hDat); + + if (dat[0]=='D' && dat[1]=='A' && dat[2]=='T') { + i=dat[3]; // Versione!! Per ora 1.0 + dat+=4; + + if (i>=0x10) { // Dalla 1.0 c'e' il punto di destinazione per ogni oggetto + ret->destX=*(uint16 *)dat; + ret->destY=*(uint16 *)(dat+2); + dat+=4; + } + + if (i>=0x11) {// Dalla 1.1 c'e' la velocita' di animazione + ret->speed=*(uint16 *)dat; + dat+=2; + } else + ret->speed=150; + } + + ret->numframe=*dat++; + ret->numpattern=*dat++; + ret->Zvalue=*dat++; + + // Carica le coordinate left&top di ogni frame + for (i=0;inumframe;i++) { + ret->frameslocations[i].left=*(short*)(dat); + ret->frameslocations[i].top=*(short*)(dat+2); + dat+=4; + } + + // Carica le dimensioni di ogni frame e calcola right&bottom + for (i=0;inumframe;i++) { + ret->frameslocations[i].right=*(uint16 *)(dat)+ret->frameslocations[i].left; + ret->frameslocations[i].bottom=*(uint16 *)(dat+2)+ret->frameslocations[i].top; + dat+=4; + } + + // Carica i bounding box di ogni frame + for (i=0;inumframe;i++) { + ret->bbox[i].left=*(uint16 *)(dat); + ret->bbox[i].top=*(uint16 *)(dat+2); + ret->bbox[i].right=*(uint16 *)(dat+4); + ret->bbox[i].bottom=*(uint16 *)(dat+6); + dat+=8; + } + + // Carica i pattern di animazione + patlength = dat; + dat+=ret->numpattern; + + for (i=1;inumpattern;i++) { + for (j=0;jpattern[i][j]=dat[j]; + ret->pattern[i][patlength[i]]=255; // Termina i pattern + dat+=patlength[i]; + } + + // Carica i singoli frame di animazione + for (i=1;inumframe;i++) { + dim=(uint32)(ret->frameslocations[i].right-ret->frameslocations[i].left)* + (uint32)(ret->frameslocations[i].bottom-ret->frameslocations[i].top); + ret->frames[i]=(char *)GlobalAlloc(GMEM_FIXED,dim); + + if (ret->frames[i]==NULL) + return NULL; + CopyMemory(ret->frames[i], dat, dim); + dat+=dim; + } + + // Controlla se siamo arrivati fino alla fine del file + i=*(uint16 *)dat; + if (i!=0xABCD) + return NULL; + + GlobalUnlock(hDat); + GlobalFree(hDat); + + return ret; +} + + +/****************************************************************************\ +* +* Function: void PASCAL CustomThread(LPCFCALL p); +* +* Description: Thread che richiama una funzione custom. Viene usato negli +* script, in modo che ciascuna funzione venga eseguita senza +* ritardare le altre +* +* Input: LPCFCALL p Struttura che definisce la chiamata +* +* Note: La struttura passata come parametro viene freeata con +* GlobalFree() alla fine dell'esecuzione. +* +\****************************************************************************/ + +void PASCAL CustomThread(LPCFCALL p) { + lplpFunctions[p->nCf](p->arg1,p->arg2,p->arg3,p->arg4); + GlobalFree(p); + ExitThread(1); +// _endthread(); +} + + +/****************************************************************************\ +* +* Function: void PASCAL ScriptThread(LPMPALSCRIPT s); +* +* Description: Esegue uno script. Questa funzione e' pensata come starting +* point per un thread +* +* Input: LPMPALSCRIPT s Script da eseguire +* +* Note: Lo script passato come parametro viene, alla fine dell'ese- +* cuzione, freeato con una GlobalFree() +* +\****************************************************************************/ + +void PASCAL ScriptThread(LPMPALSCRIPT s) { + uint i,j,k; + uint32 dwStartTime = timeGetTime(); + uint32 dwCurTime; + uint32 dwId; + static HANDLE cfHandles[MAX_COMMANDS_PER_MOMENT]; + int numHandles; + LPCFCALL p; + +// warning("PlayScript(): Moments: %u\n",s->nMoments); + for (i=0;inMoments;i++) { + // Dorme il tempo necessario per arrivare al momento successivo + if (s->Moment[i].dwTime==-1) { + WaitForMultipleObjects(numHandles,cfHandles,true,INFINITE); + dwStartTime=timeGetTime(); + } else { + dwCurTime=timeGetTime(); + if (dwCurTime < dwStartTime+(s->Moment[i].dwTime*100)) { + // warning("PlayScript(): Sleeping %lums\n",dwStartTime+(s->Moment[i].dwTime*100)-dwCurTime); + Sleep(dwStartTime+(s->Moment[i].dwTime*100)-dwCurTime); + } + } + + numHandles=0; + for (j=0;jMoment[i].nCmds;j++) { + k=s->Moment[i].CmdNum[j]; + + switch (s->Command[k].type) { + case 1: + p=(LPCFCALL)GlobalAlloc(GMEM_FIXED,sizeof(CFCALL)); + if (p==NULL) { + mpalError=1; + ExitThread(0); +// _endthread(); + } + + p->nCf=s->Command[k].nCf; + p->arg1=s->Command[k].arg1; + p->arg2=s->Command[k].arg2; + p->arg3=s->Command[k].arg3; + p->arg4=s->Command[k].arg4; + + // !!! Nuova gestione dei thread + if ((cfHandles[numHandles++]=CreateThread(NULL,10240,(LPTHREAD_START_ROUTINE)CustomThread,(void *)p,0,&dwId))==NULL) { + //if ((cfHandles[numHandles++]=(void*)_beginthread(CustomThread, 10240, (void *)p))==(void*)-1) + mpalError=1; + ExitThread(0); +// _endthread(); + } + break; + + case 2: + LockVar(); + varSetValue( + s->Command[k].lpszVarName, + EvaluateExpression(s->Command[k].expr) + ); + UnlockVar(); + break; + + default: + mpalError=1; + GlobalFree(s); + ExitThread(0); +// _endthread(); + } + } + } + + GlobalFree(s); + ExitThread(1); + //_endthread(); +} + + +/****************************************************************************\ +* +* Function: void PASCAL ActionThread(LPMPALITEM item); +* +* Description: Thread che esegue una azione su un item. Il thread +* esegue sempre l'azione 0, per cui e' necessario creare +* un item nuovo in cui l'azione 0 sia quella richiesta. +* Inoltre non viene controllata l'espressione when, ma viene +* sempre eseguita l'azione. +* +* Input: LPMPALITEM item Item che contiene l'azione +* +\****************************************************************************/ + +void PASCAL ActionThread(LPMPALITEM item) { + int j,k; + + for (j=0;jAction[item->dwRes].nCmds;j++) { + k=item->Action[item->dwRes].CmdNum[j]; + + switch (item->Command[k].type) { + case 1: + // Funzione custom + lplpFunctions[item->Command[k].nCf]( + item->Command[k].arg1, + item->Command[k].arg2, + item->Command[k].arg3, + item->Command[k].arg4 + ); + break; + + case 2: + // Variable assign + LockVar(); + varSetValue(item->Command[k].lpszVarName,EvaluateExpression(item->Command[k].expr)); + UnlockVar(); + break; + + default: + mpalError=1; + ExitThread(0); +// _endthread(); + } + } + + GlobalFree(item); + //bExecutingAction=false; + + ExitThread(1); +// _endthread(); +} + +void PASCAL ShutUpActionThread(HANDLE hThread) { + WaitForSingleObject(hThread,INFINITE); + bExecutingAction=false; + + ExitThread(1); +// _endthread(); +} + +/****************************************************************************\ +* +* Function: void PASCAL LocationPollThread(uint32 id); +* +* Description: Esegue il polling di una locazione (starting point di un +* thread). +* +* Input: uint32 id Indice per gli array relativi ai +* polling degli item delle locazioni +* +\****************************************************************************/ + +void PASCAL LocationPollThread(uint32 id) { + uint32 *il; + int i,j,k; + int numitems; + int nRealItems; + LPMPALITEM curItem,newItem; + int nIdleActions; + uint32 curTime; + uint32 dwSleepTime; + uint32 dwId; + + typedef struct { + uint32 nItem, nAction; + + uint16 wTime; + byte perc; + HGLOBAL when; + byte nCmds; + uint16 CmdNum[MAX_COMMANDS_PER_ACTION]; + + uint32 dwLastTime; + } MYACTION; + + typedef struct { + uint32 nItem; + HANDLE hThread; + } MYTHREAD; + + MYACTION *MyActions; + MYTHREAD *MyThreads; + + /* Tanto per cominciare, e' necessario richiedere la lista degli item + presenti nella locazione. */ + il = mpalQueryItemList(nPollingLocations[id]); + + /* Contiamo gli items */ + for (numitems=0;il[numitems]!=0;numitems++) + ; + + /* Cerchiamo gli items della locazione senza idle actions e li eliminiamo + dalla lista */ + LockItems(); + nIdleActions=0; + nRealItems=0; + for (i=0;inActions;j++) + if (curItem->Action[j].num==0xFF) + k++; + + nIdleActions+=k; + + if (k==0) + /* Possiamo eliminare questo item dalla lista */ + il[i] = (uint32)NULL; + else + nRealItems++; + } + UnlockItems(); + + /* Se non e' rimasto nessuno possiamo uscire */ + if (nRealItems==0) { + GlobalFree(il); + ExitThread(0); +// _endthread(); + } + + MyThreads=(MYTHREAD*)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,nRealItems*sizeof(MYTHREAD)); + if (MyThreads==NULL) { + GlobalFree(il); + ExitThread(0); +// _endthread(); + } + + /* Inizializziamo le routine random */ + //curTime=timeGetTime(); + //srand(curTime); + + + /* Abbiamo appurato che esiste almeno un item che contiene idle actions. + Ora creaiamo le copie speculari delle idle actions */ + MyActions=(MYACTION*)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,nIdleActions*sizeof(MYACTION)); + if (MyActions==NULL) { + GlobalFree(MyThreads); + GlobalFree(il); + ExitThread(0); +// _endthread(); + } + + LockItems(); + k=0; + + for (i=0;inActions;j++) + if (curItem->Action[j].num==0xFF) { + MyActions[k].nItem=il[i]; + MyActions[k].nAction=j; + + MyActions[k].wTime=curItem->Action[j].wTime; + MyActions[k].perc=curItem->Action[j].perc; + MyActions[k].when=curItem->Action[j].when; + MyActions[k].nCmds=curItem->Action[j].nCmds; + CopyMemory(MyActions[k].CmdNum, curItem->Action[j].CmdNum, + MAX_COMMANDS_PER_ACTION*sizeof(uint16)); + + MyActions[k].dwLastTime=timeGetTime(); + k++; + } + } + + UnlockItems(); + + /* La item list non ci serve piu' */ + GlobalFree(il); + + + /* Eccoci al ciclo principale. */ + while (1) { + /* Cerchiamo tra tutte le idle actions quella a cui manca meno tempo per + l'esecuzione */ + curTime=timeGetTime(); + dwSleepTime=(uint32)-1L; + + for (k=0;k=MyActions[k].dwLastTime+MyActions[k].wTime) { + dwSleepTime=0; + break; + } else + dwSleepTime=MIN(dwSleepTime,MyActions[k].dwLastTime+MyActions[k].wTime-curTime); + + /* Ci addormentiamo, ma controllando sempre l'evento che viene settato + quando viene richiesta la nostra chiusura */ + k=WaitForSingleObject(hEndPollingLocations[id],dwSleepTime); + if (k==WAIT_OBJECT_0) + break; + + for (i=0;i=MyActions[k].dwLastTime+MyActions[k].wTime) { + MyActions[k].dwLastTime+=MyActions[k].wTime; + + /* E' il momento di tirare il nostro dado virtuale, e controllare + se la sorte e' dalla parte della idle action */ + byte randomVal = (byte)_vm->_randomSource.getRandomNumber(99); + if (randomVal < MyActions[k].perc) { + /* Controlliamo se c'e' una action in esecuzione sull'item */ + if ((bExecutingAction) && (nExecutingAction==MyActions[k].nItem)) + continue; + + /* Controlliamo se c'e' gia' un'altra idle function in esecuzione + sullo stesso item */ + for (i=0;iAction[j].when!=NULL) + if (!EvaluateExpression(curItem->Action[j].when)) { + UnlockItems(); + continue; + } + + /* Ok, possiamo eseguire la azione. Per comodita' lo facciamo in + un nuovo thread */ + newItem=(LPMPALITEM)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,sizeof(MPALITEM)); + if (newItem==false) { + GlobalFree(MyThreads); + GlobalFree(MyActions); + ExitThread(0); +// _endthread(); + } + + CopyMemory(newItem,curItem,sizeof(MPALITEM)); + UnlockItems(); + + /* Copiamo l'azione nella #0 */ +// newItem->Action[0].nCmds=curItem->Action[j].nCmds; +// CopyMemory(newItem->Action[0].CmdNum,curItem->Action[j].CmdNum,newItem->Action[0].nCmds*sizeof(newItem->Action[0].CmdNum[0])); + newItem->dwRes=j; + + /* Creaiamo l'action thread. Provvedera' lui a liberare la memoria + allocata per il nuovo item */ + for (i=0;iGroup[i].num!=0;i++) + if (dialog->Group[i].num==nGroup) { + /* Cicla eseguendo i comandi del gruppo */ + for (j=0;jGroup[i].nCmds;j++) { + k=dialog->Group[i].CmdNum[j]; + + switch (dialog->Command[k].type) { + /* Funzione custom: la richiama */ + case 1: + lplpFunctions[dialog->Command[k].nCf]( + dialog->Command[k].arg1, + dialog->Command[k].arg2, + dialog->Command[k].arg3, + dialog->Command[k].arg4 + ); + break; + + /* Variabile: la setta */ + case 2: + LockVar(); + varSetValue(dialog->Command[k].lpszVarName,EvaluateExpression(dialog->Command[k].expr)); + UnlockVar(); + break; + + /* DoChoice: richiama la funzione di scelta */ + case 3: + DoChoice((uint32)dialog->Command[k].nChoice); + break; + + default: + mpalError=1; + UnlockDialogs(); + ExitThread(0); +// _endthread(); + } + } + + /* Abbiamo eseguito il gruppo. Possiamo uscire alla funzione chiamante. + Se il gruppo era il primo chiamato, allora automaticamente il + thread viene chiuso, altrimenti si ritorno al gruppo chiamante. */ + UnlockDialogs(); + return; + } + + /* Se siamo qui, vuol dire che non abbiamo trovato il gruppo richiesto */ + mpalError=1; + UnlockDialogs(); + ExitThread(0); +// _endthread(); +} + + +/****************************************************************************\ +* +* Function: void DoChoice(uint32 nChoice); +* +* Description: Esegue una scelta nel dialogo corrente +* +* Input: uint32 nChoice Numero della scelta da eseguire +* +\****************************************************************************/ + +void DoChoice(uint32 nChoice) { + LPMPALDIALOG dialog; + int i,j,k; + + /* Locka i dialoghi */ + LockDialogs(); + + /* Trova il puntatore al dialogo corrente */ + dialog=lpmdDialogs+nExecutingDialog; + + /* Cerca la scelta richiesta tra quelle nel dialogo */ + for (i=0;dialog->Choice[i].nChoice!=0;i++) + if (dialog->Choice[i].nChoice==nChoice) + break; + + /* Se non l'ha trovata, esce con errore */ + if (dialog->Choice[i].nChoice==0) { + /* Se siamo qui, non abbiamo trovato la choice richiesta */ + mpalError=1; + UnlockDialogs(); + ExitThread(0); +// _endthread(); + } + + /* Abbiamo trova la choice richiesta. Ricordiamoci qual e' nella + variabile globale */ + nExecutingChoice=i; + + while (1) { + nExecutingChoice=i; + + k=0; + /* Calcoliamo le when expression di ciascun select, per vedere se sono + attivi o disattivi */ + for (j=0;dialog->Choice[i].Select[j].dwData!=0;j++) + if (dialog->Choice[i].Select[j].when==NULL) { + dialog->Choice[i].Select[j].curActive=1; + k++; + } else if (EvaluateExpression(dialog->Choice[i].Select[j].when)) { + dialog->Choice[i].Select[j].curActive=1; + k++; + } else + dialog->Choice[i].Select[j].curActive=0; + + /* Se non ci sono scelte attivate, la scelta e' finita */ + if (k==0) { + UnlockDialogs(); + break; + } + + /* Avvertiamo il gioco che c'e' una scelta da far fare all'utente, + e restiamo in attesa della risposta */ + ResetEvent(hDoneChoice); + SetEvent(hAskChoice); + WaitForSingleObject(hDoneChoice,INFINITE); + + /* Ora che la scelta e' stata effettuata, possiamo eseguire i gruppi + associati con la scelta */ + j=nSelectedChoice; + for (k=0;dialog->Choice[i].Select[j].wPlayGroup[k]!=0;k++) + GroupThread(dialog->Choice[i].Select[j].wPlayGroup[k]); + + /* Controllo sugli attributi */ + if (dialog->Choice[i].Select[j].attr&(1<<0)) { + /* Bit 0 settato: fine della scelta */ + UnlockDialogs(); + break; + } + + if (dialog->Choice[i].Select[j].attr&(1<<1)) { + /* Bit 1 settato: fine del dialogo */ + UnlockDialogs(); + ExitThread(1); +// _endthread(); + } + + /* Fine della scelta senza attributi: bisogna rifarla */ + } + + /* Se siamo qui, abbiamo trovato un end choice. Ritorna al gruppo chiamante */ + return; +} + + + +/****************************************************************************\ +* +* Function: HANDLE DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam); +* +* Description: Esegue una azione su un certo item +* +* Input: uint32 nAction Numero dell'azione +* uint32 ordItem Indice dell'item nelle strutture +* degli item +* uint32 dwParam Eventuale parametro per l'azione +* +* Return: Handle del thread che sta eseguendo l'azione, oppure +* INVALID_HANDLE_VALUE se l'azione non e' definita, o l'item +* e' disattivato. +* +* Note: Si puo' ottenere l'indice dell'item a partire dal suo numero +* tramite la funzione itemGetOrderFromNum(). +* Gli item devono essere lockati, perche' questa funzione +* funzioni, tramite LockItem(); +* +\****************************************************************************/ + +static HANDLE DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { + LPMPALITEM item=lpmiItems; + int i; + LPMPALITEM newitem; + uint32 dwId; + HANDLE h; + + item+=ordItem; + Common::String buf = Common::String::format("Status.%u", item->nObj); + if (varGetValue(buf.c_str())<=0) + return INVALID_HANDLE_VALUE; + + for (i=0;inActions;i++) { + if (item->Action[i].num!=nAction) + continue; + + if (item->Action[i].wParm!=dwParam) + continue; + + if (item->Action[i].when!=NULL) { + if (!EvaluateExpression(item->Action[i].when)) + continue; + } + + // Ora abbiamo trova l'azione giusta che deve essere eseguita. + // Duplichiamo l'item corrente e copiamo la azione #i nella #0 + newitem=(LPMPALITEM)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,sizeof(MPALITEM)); + if (newitem==NULL) + return INVALID_HANDLE_VALUE; + + // Nella nuova versione scriviamo il numero dell'azione in dwRes + CopyMemory(newitem,item,sizeof(MPALITEM)); +/* newitem->Action[0].nCmds=item->Action[i].nCmds; + CopyMemory(newitem->Action[0].CmdNum,item->Action[i].CmdNum,newitem->Action[0].nCmds*sizeof(newitem->Action[0].CmdNum[0])); +*/ + newitem->dwRes=i; + + // E finalmente possiamo richiamare il thread, che eseguira' l'azione + // 0 dell'item, e poi liberera' la memoria con la GlobalFree() + +/* !!! Nuova gestione dei thread +*/ + if ((h=CreateThread(NULL,10240,(LPTHREAD_START_ROUTINE)ActionThread,(void *)newitem,0,&dwId))==NULL) + return INVALID_HANDLE_VALUE; + + if ((h=CreateThread(NULL,10240,(LPTHREAD_START_ROUTINE)ShutUpActionThread,(void *)h,0,&dwId))==NULL) + return INVALID_HANDLE_VALUE; + +/* + if ((h=(void*)_beginthread(ActionThread,10240,(void *)newitem))==(void*)-1) + return INVALID_HANDLE_VALUE; + + if ((h=(void*)_beginthread(ShutUpActionThread,10240,(void *)h))==(void*)-1) + return INVALID_HANDLE_VALUE; + +*/ + nExecutingAction=item->nObj; + bExecutingAction=true; + + return h; + } + + return INVALID_HANDLE_VALUE; +} + + +/****************************************************************************\ +* +* Function: HANDLE DoDialog(uint32 nDlgOrd, uint32 nGroup); +* +* Description: Esegue un dialogo in un thread +* +* Input: uint32 nDlgOrd Indice del dialogo da eseguire +* all'interno dell'array di strutture +* dei dialoghi +* uint32 nGroup Numero del gruppo da eseguire +* +* Return: Handle del thread che sta eseguendo il dialogo, o +* INVALID_HANDLE_VALUE in caso di errore +* +* Note: Il dialogo viene eseguito in un thread creato apposta, che +* deve informa tramite un evento quando e' necessario far +* fare una scelta all'utente. I dati sulle scelte possono +* essere richiesti tramite le varie query. +* +\****************************************************************************/ + +static HANDLE DoDialog(uint32 nDlgOrd, uint32 nGroup) { +// LPMPALDIALOG dialog=lpmdDialogs+nDlgOrd; + uint32 dwId; + HANDLE h; + + /* Si ricorda nella variabile globale qual e' il dialogo in esecuzione */ + nExecutingDialog=nDlgOrd; + + /* Attiva la flag per indicare che c'e' un dialogo in esecuzione */ + bExecutingDialog=true; + + ResetEvent(hAskChoice); + ResetEvent(hDoneChoice); + + /* Crea un thread in cui esegue un gruppo del dialogo */ + + // !!! Nuova gestione dei thread + if ((h=CreateThread(NULL,10240,(LPTHREAD_START_ROUTINE)GroupThread,(void *)nGroup,0,&dwId))==NULL) + // if ((h=(void*)_beginthread(GroupThread,10240,(void *)nGroup))==(void*)-1) + return INVALID_HANDLE_VALUE; + + /* Crea un thread che attende la fine del dialogo e rimette a posto le + variabili globali */ + // !!! Nuova gestione dei thread + if (CreateThread(NULL,10240,(LPTHREAD_START_ROUTINE)ShutUpDialogThread,(void *)h,0,&dwId)==NULL) { + //if ((h=(void*)_beginthread(ShutUpDialogThread,10240,(void *)h))==(void*)-1) + TerminateThread(h,0); + CloseHandle(h); + return INVALID_HANDLE_VALUE; + } + + return h; +} + + +/****************************************************************************\ +* +* Function: bool DoSelection(uint32 nChoice, uint32 dwData); +* +* Description: Prende nota del select scelto dall'utente, e avverte il +* thread che stava eseguendo il dialogo che puo' continuare. +* +* Input: uint32 nChoice Numero della scelta che era in corso +* uint32 dwData Dato abbinato al select selezionato +* +* Return: true se tutto OK, false in caso di errore +* +\****************************************************************************/ + +bool DoSelection(uint32 i, uint32 dwData) { + LPMPALDIALOG dialog=lpmdDialogs+nExecutingDialog; + int j; + + for (j=0;dialog->Choice[i].Select[j].dwData!=0;j++) + if (dialog->Choice[i].Select[j].dwData==dwData && dialog->Choice[i].Select[j].curActive!=0) + break; + + if (dialog->Choice[i].Select[j].dwData==0) + return false; + + nSelectedChoice=j; + SetEvent(hDoneChoice); + return true; +} + + + +/****************************************************************************\ +* Exported functions +\****************************************************************************/ + +/****************************************************************************\ +* +* Function: bool mpalInit(char * lpszMpcFileName, char * lpszMprFileName, +* LPLPCUSTOMFUNCTION lplpcfArray); +* +* Description: Inizializza la libreria MPAL, e apre un file .MPC, che +* verra' utilizzato per tutte le query +* +* Input: char * lpszMpcFileName Nome del file .MPC, comprensivo di +* estensione +* char * lpszMprFileName Nome del file .MPR, comprensivo di +* estensione +* LPLPCUSTOMFUNCTION +* lplpcfArray Array di pointer a funzioni custom +* +* Return: true se tutto OK, false in caso di errore +* +\****************************************************************************/ + +bool mpalInit(char * lpszMpcFileName, char * lpszMprFileName, LPLPCUSTOMFUNCTION lplpcfArray) { + Common::File hMpc; + byte buf[5]; + uint32 nBytesRead; + bool bCompress; + uint32 dwSizeDecomp, dwSizeComp; + byte *cmpbuf; + + //printf("Item: %lu\n",sizeof(MPALITEM)); + //printf("Script: %lu\n",sizeof(MPALSCRIPT)); + //printf("Dialog: %lu\n",sizeof(MPALDIALOG)); + + /* Si salva l'array delle funzioni custom */ + lplpFunctions=lplpcfArray; + + /* Apre il file MPC in lettura */ + if (!hMpc.open(lpszMpcFileName)) + return false; + + /* Legge e controlla l'header */ + nBytesRead = hMpc.read(buf, 5); + if (nBytesRead !=5) + return false; + + if (buf[0]!='M' || buf[1]!='P' || buf[2]!='C' || buf[3]!=0x20) + return false; + + bCompress=buf[4]; + + /* Legge la dimensione del file decompresso, e alloca la memoria */ + dwSizeDecomp = hMpc.readUint32LE(); + if (hMpc.err()) + return false; + + lpMpcImage = (byte *)GlobalAlloc(GMEM_FIXED,dwSizeDecomp+16); + if (lpMpcImage==NULL) + return false; + + if (bCompress) { + /* Se il file e' compresso, guarda quanto e' grande e alloca la + memoria temporanea per la decompressione */ + dwSizeComp = hMpc.readUint32LE(); + if (nBytesRead != 4) + return false; + + cmpbuf = (byte *)GlobalAlloc(GMEM_FIXED,dwSizeComp); + if (cmpbuf==NULL) + return false; + + nBytesRead = hMpc.read(cmpbuf, dwSizeComp); + if (nBytesRead != dwSizeComp) + return false; + + /* Decomprime l'immagine */ + lzo1x_decompress(cmpbuf,dwSizeComp,lpMpcImage,(lzo_uint*)&nBytesRead,NULL); + if (nBytesRead != dwSizeDecomp) + return false; + + GlobalFree(cmpbuf); + } else { + /* Se il file non e' compresso, lo legge all'interno della memoria gia' + allocata */ + nBytesRead = hMpc.read(lpMpcImage, dwSizeDecomp); + if (nBytesRead != dwSizeDecomp) + return false; + } + + /* Chiude il file */ + hMpc.close(); + + /* Parsa l'immagine */ + if (ParseMpc(lpMpcImage)==false) + return false; + + GlobalFree(lpMpcImage); + + /* Calcola utilizzo di memoria */ + /* + { + char errbuf[256]; + wsprintf(errbuf,"Utilizzo in RAM: VAR %lu, MSG %lu, DLG %lu, ITM %lu, LOC %lu, SCR %lu", + nVars*sizeof(MPALVAR), + nMsgs*sizeof(MPALMSG), + nDialogs*sizeof(MPALDIALOG), + nItems*sizeof(MPALITEM), + nLocations*sizeof(MPALLOCATION), + nScripts*sizeof(MPALSCRIPT)); + MessageBox(NULL,errbuf,"Dump",MB_OK); + } +*/ + + /* Apre il file MPR in lettura */ + if (!hMpr.open(lpszMprFileName)) + return false; + + /* Si posiziona a 8 byte dalla fine del file */ + hMpr.seek(-12, SEEK_END); + + dwSizeComp = hMpr.readUint32LE(); + if (hMpr.err()) + return false; + + nResources = hMpr.readUint32LE(); + if (hMpr.err()) + return false; + + nBytesRead = hMpr.read(buf, 4); + if (hMpr.err()) + return false; + + if (buf[0] !='E' || buf[1] != 'N' || buf[2] != 'D' || buf[3] != '0') + return false; + + /* Si posiziona all'inizio dell'header delle risorse */ + hMpr.seek(-(12 + (int)dwSizeComp), SEEK_END); + + lpResources = (uint32 *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, nResources * 8); + if (lpResources==NULL) + return false; + + cmpbuf = GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, dwSizeComp); + if (cmpbuf==NULL) + return false; + + nBytesRead = hMpr.read(cmpbuf, dwSizeComp); + if (nBytesRead != dwSizeComp) + return false; + + lzo1x_decompress((byte *)cmpbuf,dwSizeComp,(byte *)lpResources, (uint32 *)&nBytesRead, NULL); + if (nBytesRead != (uint32)nResources*8) + return false; + + GlobalFree(cmpbuf); + + /* Si riposiziona all'inizio lasciando il file di risorse aperto */ + hMpr.seek(0, SEEK_SET); + + /* Non c'e' nessuna azione ne' dialogo in esecuzione */ + bExecutingAction = false; + bExecutingDialog = false; + + /* Non c'e' nessuna locazione in polling */ + Common::fill(nPollingLocations, nPollingLocations + MAXPOLLINGLOCATIONS, 0); + + /* Crea l'evento che verra' utilizzato per avvertire il gioco che c'e' + da effettuare una scelta */ + hAskChoice=CreateEvent(NULL, true, false, NULL); + hDoneChoice=CreateEvent(NULL, true, false, NULL); + + return true; +} + +/****************************************************************************\ +* +* Function: uint32 mpalQuery(uint16 wQueryType, ...); +* +* Description: Questa e' la funzione generale per comunicare con la libreria, +* per richiedere informazioni riguardo a quanto si trova nel +* file .MPC +* +* Input: uint16 wQueryType Tipo di query. La lista e' in +* enum QueryTypes +* +* Return: 4 bytes che dipendono dal tipo di query +* +* Note: E' _FORTEMENTE_ consigliato utilizzare le macro +* definite sopra per utilizzare le query, dato che +* permettono di evitare spiacevoli bug dovuti a dimenticanze +* di parametri. +* +\****************************************************************************/ + +#define GETARG(type) va_arg(v,type) + +uint32 mpalQuery(uint16 wQueryType, ...) { + uint32 dwRet; int x,y,z; char * n; + va_list v; + Common::String buf; + + mpalError=OK; + va_start(v,wQueryType); + + switch (wQueryType) { + /* + * uint32 mpalQuery(MPQ_VERSION); + */ + case MPQ_VERSION: + dwRet = HEX_VERSION; + break; + + /* + * uint32 mpalQuery(MPQ_GLOBAL_VAR, char * lpszVarName); + */ + case MPQ_GLOBAL_VAR: + LockVar(); + dwRet=(uint32)varGetValue(GETARG(char *)); + UnlockVar(); + break; + + /* + * char * mpalQuery(MPQ_MESSAGE, uint32 nMsg); + */ + case MPQ_MESSAGE: + LockMsg(); + dwRet=(uint32)DuplicateMessage(msgGetOrderFromNum(GETARG(uint32))); + UnlockMsg(); + break; + + /* + * uint32 mpalQuery(MPQ_ITEM_PATTERN, uint32 nItem); + */ + case MPQ_ITEM_PATTERN: + LockVar(); + buf = Common::String::format("Pattern.%u", GETARG(uint32)); + dwRet = (uint32)varGetValue(buf.c_str()); + UnlockVar(); + break; + + /* + * uint32 mpalQuery(MPQ_LOCATION_SIZE, uint32 nLoc, uint32 dwCoord); + */ + case MPQ_LOCATION_SIZE: + LockLocations(); + x=locGetOrderFromNum(GETARG(uint32)); + y=GETARG(uint32); + if (x!=-1) { + if (y==MPQ_X) + dwRet=lpmlLocations[x].dwXlen; + else if (y==MPQ_Y) + dwRet=lpmlLocations[x].dwYlen; + else + mpalError=1; + } else + mpalError=1; + UnlockLocations(); + break; + + /* + * HGLOBAL mpalQuery(MPQ_LOCATION_IMAGE, uint32 nLoc); + */ + case MPQ_LOCATION_IMAGE: + LockLocations(); + x=locGetOrderFromNum(GETARG(uint32)); + dwRet=(uint32)resLoad(lpmlLocations[x].dwPicRes); + UnlockLocations(); + break; + + /* + * HGLOBAL mpalQuery(MPQ_RESOURCE, uint32 dwRes); + */ + case MPQ_RESOURCE: + dwRet=(uint32)resLoad(GETARG(uint32)); + break; + + /* + * uint32 mpalQuery(MPQ_ITEM_LIST, uint32 nLoc); + */ + case MPQ_ITEM_LIST: + LockVar(); + dwRet=(uint32)GetItemList(GETARG(uint32)); + LockVar(); + break; + + /* + * LPITEM mpalQuery(MPQ_ITEM_DATA, uint32 nItem); + */ + case MPQ_ITEM_DATA: + LockItems(); + dwRet=(uint32)GetItemData(itemGetOrderFromNum(GETARG(uint32))); + UnlockItems(); + break; + + /* + * bool mpalQuery(MPQ_ITEM_IS_ACTIVE, uint32 nItem); + */ + case MPQ_ITEM_IS_ACTIVE: + LockVar(); + x=GETARG(uint32); + buf = Common::String::format("Status.%u", x); + if (varGetValue(buf.c_str()) <= 0) + dwRet = (uint32)false; + else + dwRet = (uint32)true; + UnlockVar(); + break; + + + /* + * uint32 mpalQuery(MPQ_ITEM_NAME, uint32 nItem, char * lpszName); + */ + case MPQ_ITEM_NAME: + LockVar(); + x=GETARG(uint32); + n=GETARG(char *); + buf = Common::String::format("Status.%u", x); + if (varGetValue(buf.c_str()) <= 0) + n[0]='\0'; + else { + LockItems(); + y=itemGetOrderFromNum(x); + CopyMemory(n, (char *)(lpmiItems+y)->lpszDescribe, MAX_DESCRIBE_SIZE); + UnlockItems(); + } + + UnlockVar(); + break; + + + /* + * char * mpalQuery(MPQ_DIALOG_PERIOD, uint32 nDialog, uint32 nPeriod); + */ + case MPQ_DIALOG_PERIOD: + LockDialogs(); + y=GETARG(uint32); + dwRet=(uint32)DuplicateDialogPeriod(y); + UnlockDialogs(); + break; + + + /* + * void mpalQuery(MPQ_DIALOG_WAITFORCHOICE); + */ + case MPQ_DIALOG_WAITFORCHOICE: + WaitForSingleObject(hAskChoice,INFINITE); + ResetEvent(hAskChoice); + + if (bExecutingDialog) + dwRet=(uint32)nExecutingChoice; + else + dwRet=(uint32)((int)-1); + break; + + + /* + * uint32 *mpalQuery(MPQ_DIALOG_SELECTLIST, uint32 nChoice); + */ + case MPQ_DIALOG_SELECTLIST: + LockDialogs(); + dwRet=(uint32)GetSelectList(GETARG(uint32)); + UnlockDialogs(); + break; + + /* + * bool mpalQuery(MPQ_DIALOG_SELECTION, uint32 nChoice, uint32 dwData); + */ + case MPQ_DIALOG_SELECTION: + LockDialogs(); + x=GETARG(uint32); + y=GETARG(uint32); + dwRet=(uint32)DoSelection(x,y); + UnlockDialogs(); + break; + + + /* + * int mpalQuery(MPQ_DO_ACTION, uint32 nAction, uint32 nItem, uint32 dwParam); + */ + case MPQ_DO_ACTION: + /* + if (bExecutingAction) + { + dwRet=(uint32)INVALID_HANDLE_VALUE; + break; + } + */ + + LockItems(); + LockVar(); + x=GETARG(uint32); + z=GETARG(uint32); + y=itemGetOrderFromNum(z); + if (y!=-1) { + dwRet=(uint32)DoAction(x,y,GETARG(uint32)); + } else { + dwRet=(uint32)INVALID_HANDLE_VALUE; + mpalError=1; + } + UnlockVar(); + UnlockItems(); + break; + + /* + * int mpalQuery(MPQ_DO_DIALOG, uint32 nDialog, uint32 nGroup); + */ + case MPQ_DO_DIALOG: + if (bExecutingDialog) + break; + + LockDialogs(); + + x=dialogGetOrderFromNum(GETARG(uint32)); + y=GETARG(uint32); + dwRet=(uint32)DoDialog(x,y); + UnlockDialogs(); + break; + + /* + * DEFAULT -> ERROR + */ + default: + mpalError=1; + break; + } + + va_end(v); + + return dwRet; +} + + +/****************************************************************************\ +* +* Function: uint32 mpalGetError(void); +* +* Description: Ritorna il codice di errore corrente di MPAL +* +* Return: Codice di errore +* +\****************************************************************************/ + +uint32 mpalGetError(void) { + return mpalError; +} + + +/****************************************************************************\ +* +* Function: void mpalExecuteScript(int nScript); +* +* Description: Esegue uno script. Lo script viene eseguito in multitasking +* tramite un thread. +* +* Input: int nScript Numero dello script da eseguire +* +* Return: true se lo script e' stato avviato, false in caso di errore +* +\****************************************************************************/ + +bool EXPORT mpalExecuteScript(int nScript) { + int n; + LPMPALSCRIPT s; + uint32 dwId; + + LockScripts(); + n=scriptGetOrderFromNum(nScript); + s=(LPMPALSCRIPT)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,sizeof(MPALSCRIPT)); + if (s==NULL) + return false; + + CopyMemory(s, lpmsScripts+n, sizeof(MPALSCRIPT)); + UnlockScripts(); + +// !!! Nuova gestione dei thread + if (CreateThread(NULL,10240,(LPTHREAD_START_ROUTINE)ScriptThread,(void *)s,0,&dwId)==NULL) + //if ((void*)_beginthread(ScriptThread,10240,(void *)s)==(void*)-1) + return false; + + return true; +} + + +/****************************************************************************\ +* +* Function: void mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCustom); +* +* Description: Install a custom routine that will be called by MPAL every +* time the pattern of an item has been changed. +* +* Input: LPITEMIRQFUNCTION lpiifCustom Custom function to install +* +\****************************************************************************/ + +void EXPORT mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCus) { + lpiifCustom=lpiifCus; +} + + +/****************************************************************************\ +* +* Function: bool mpalStartIdlePoll(int nLoc); +* +* Description: Process the idle actions of the items on one location. +* +* Input: int nLoc Number of the location whose items +* must be processed for idle actions. +* +* Return: true se tutto OK, false se si e' superato il limite massimo. +* +* Note: Il numero massimo delle locazione che e' possibile pollare +* contemporaneamente e' contenuto nel define MAXPOLLINGFUNCIONS +* +\****************************************************************************/ + +bool EXPORT mpalStartIdlePoll(int nLoc) { + uint32 i; + uint32 dwId; + + for (i=0;iwriteString("\n

\n

\n"); + + if (strcmp(MsgComments[i].pComment, "###") != 0 && strncmp(MsgComments[i].pComment, "@@@", 3) != 0) { + f->writeString(Common::String::format("%s\n", MsgComments[i].pComment)); + f->writeString("

\n

\n\n"); + } else + bDontOutput=true; + return; + } +} + +void OutputEndMsgComment(uint16 wNum, Common::OutSaveFile *f) { + int i; + + for (i=0;MsgComments[i].wEnd!=0;i++) + if (MsgComments[i].wEnd == wNum) { +warning("End: %d\n", wNum); + + if (strcmp(MsgComments[i].pComment, "###") != 0 && strncmp(MsgComments[i].pComment, "@@@", 3) != 0) { + f->writeString("
\n

\n"); + } else + bDontOutput=false; + + f->writeString("

\n

\n\n"); + return; + } +} + + +int OutputStartOther(uint16 wNum, Common::OutSaveFile *f) { + int i; + + for (i=0;MsgComments[i].wStart!=0;i++) + if (MsgComments[i].wStart <= wNum && MsgComments[i].wEnd >= wNum) { + if (strncmp(MsgComments[i].pComment, "@@@", 3) == 0) { + if (MsgComments[i].wStart == wNum) { + f->writeString(Common::String::format("%s\n", MsgComments[i].pComment+4)); + f->writeString("

\n

\n

\n"); + } + + return 1; + } + } + + return 0; +} + + +void OutputEndOther(uint16 wNum, Common::OutSaveFile *f) { + int i; + + for (i=0;MsgComments[i].wStart!=0;i++) + if (MsgComments[i].wEnd == wNum && strncmp(MsgComments[i].pComment, "@@@", 3) == 0) { + f->writeString("
\n

\n"); + break; + } +} + + +void mpalDumpMessages(void) { + int i,j; + char *lpMessage; + char *p; + char *lpPeriods[30]; + char fname[64]; + char frase[2048]; + int nPeriods; + Common::OutSaveFile *f, *v1; + + v1 = g_system->getSavefileManager()->openForSaving("voicelist.txt"); + + LockMsg(); + + bDontOutput=false; + + warning("Dumping MESSAGES.HTM...\n"); + + f = g_system->getSavefileManager()->openForSaving("Messages.htm"); + f->writeString("\n\n\n"); + + for (i=0;iwriteString(Common::String::format("%s\n", fname)); + f->writeString("\t\n"); + f->writeString(Common::String::format("\t\t\n", fname)); + f->writeString(Common::String::format("\t\t\n", frase)); + f->writeString("\t\n"); + } + } + + OutputEndMsgComment(lpmmMsgs[i].wNum, f); + + GlobalUnlock(lpmmMsgs[i].hText); + } + } + + f->writeString("
%s %s
\n\n\n"); + + f->finalize(); + v1->finalize(); + delete f; + delete v1; + + UnlockMsg(); +} + + + +void mpalDumpOthers(void) { + int i,j; + char *lpMessage; + char *p; + char *lpPeriods[30]; + char fname[64]; + char frase[2048]; + int nPeriods; + + Common::OutSaveFile *f, *v1; + + v1 = g_system->getSavefileManager()->openForSaving("voicelist.txt"); + f = g_system->getSavefileManager()->openForSaving("Others.htm"); + LockMsg(); + + bDontOutput=false; + + warning("Dumping OTHERS.HTM...\n"); + + f->writeString("\n\n"); + + for (i=0;iwriteString(Common::String::format("%s\n", fname)); + f->writeString("\t\n"); + f->writeString(Common::String::format("\t\t %s \n", fname)); + f->writeString(Common::String::format("\t\t %s \n", frase)); + f->writeString("\t\n"); + } + } + } + + OutputEndOther(lpmmMsgs[i].wNum, f); + + GlobalUnlock(lpmmMsgs[i].hText); + } + } + + f->writeString("\n\n"); + + f->finalize(); + v1->finalize(); + + delete f; + delete v1; + UnlockMsg(); +} + + +#if 0 // English names +char *DLG10[] = { "Tony", NULL }; +char *DLG51[] = { "Tony", "Butch", "Dudley" }; +char *DLG52[] = { "Tony", NULL }; +char *DLG61[] = { "Tony", "Old lady 1", NULL }; +char *DLG71[] = { "Tony", "Timothy", "Convict", NULL, NULL, "Jack (with microphone)", "Old lady 1", NULL }; +char *DLG90[] = { "Tony", "Bearded lady", NULL }; +char *DLG110[] = { "Tony", "Lorenz", NULL }; +char *DLG111[] = { "Tony", "Lorenz", NULL }; +char *DLG130[] = { "Tony", "Piranha", NULL }; +char *DLG150[] = { "Tony", "Rufus", "Snowman", NULL }; +char *DLG151[] = { "Tony", "Rufus", "Snowman", NULL }; +char *DLG152[] = { "Tony", "Rufus", "Snowman", NULL }; +char *DLG153[] = { "Tony", "Rufus", "Snowman", NULL }; +char *DLG154[] = { "Tony", "Rufus", "Snowman", NULL }; +char *DLG160[] = { "Tony", "Shmiley", NULL }; +char *DLG161[] = { "Tony", "Shmiley", NULL }; +char *DLG162[] = { "Tony", "Shmiley", NULL }; +char *DLG163[] = { "Tony", "Shmiley", NULL }; +char *DLG180[] = { "Tony", "Beast", NULL }; +char *DLG190[] = { "Tony", "Beast", NULL }; +char *DLG191[] = { "Tony", "Beast", NULL }; +char *DLG201[] = { "Tony", NULL }; +char *DLG210[] = { "Tony", "Mortimer", NULL }; +char *DLG211[] = { "Tony", "Mortimer", NULL }; +char *DLG212[] = { "Tony", "Mortimer", NULL }; +char *DLG240[] = { "Tony", "Isabella", NULL }; +char *DLG250[] = { "Tony", "Bartender", "Sad pirate", "Anchorman", "Biff", NULL }; +char *DLG251[] = { "Tony", "Bartender", "Sad pirate", "Anchorman", "Biff", NULL }; +char *DLG260[] = { "Tony", "Captain", "Captain (tale)", NULL }; +char *DLG270[] = { "Tony", "Egghead", NULL }; +char *DLG271[] = { "Tony", "Egghead", NULL }; +char *DLG272[] = { "Tony", "Egghead", NULL }; +char *DLG290[] = { "Tony", "Old lady 2", NULL }; +char *DLG310[] = { "Tony", "Wally", NULL }; +char *DLG330[] = { "Tony", "Polly", "Captain (off scene)", NULL }; +char *DLG340[] = { "Tony", "Randall", NULL }; +char *DLG360[] = { "Tony", NULL }; +char *DLG361[] = { "Tony", NULL }; +char *DLG370[] = { "Tony", "Gatekeeper", NULL }; +char *DLG371[] = { "Tony", "Gatekeeper", NULL }; +char *DLG372[] = { "Tony", "Gatekeeper", NULL }; +char *DLG373[] = { "Tony", "Gatekeeper", NULL }; +char *DLG380[] = { "Tony", NULL }; +char *DLG410[] = { "Tony", "Gwendel", NULL }; +char *DLG430[] = { "Tony", "Harold", "Chuck", "Pigeons", "Housekeeper (off scene)", NULL }; +char *DLG460[] = { "Tony", NULL }; +char *DLG470[] = { "Tony", "Housekeeper", "Mirror", NULL }; +char *DLG471[] = { "Tony", "Housekeeper", "Mirror", NULL }; +char *DLG472[] = { "Tony", "Housekeeper", "Mirror", NULL }; +char *DLG473[] = { "Tony", "Housekeeper", "Mirror", NULL }; +char *DLG474[] = { "Tony", "Housekeeper", "Mirror", NULL }; +char *DLG480[] = { "Tony", "Pin-up", NULL }; +char *DLG490[] = { "Tony", "Gwendel", NULL }; +char *DLG530[] = { "Tony", "Harold", "Chuck", NULL }; +char *DLG550[] = { "Tony", "Mr. Wishing Well", "Tony (from the top of the well)", NULL }; +char *DLG560[] = { "Tony", "Superintendent", NULL }; +char *DLG590[] = { "Tony", "Pantagruel", NULL }; +char *DLG600[] = { "Tony", "Jack", "Jack", NULL, "Jack", NULL, NULL, NULL, "Storyteller", "Mr. Wishing Well", NULL }; +#endif + +#if 0 // Polish names +char *DLG10[] = { "Tony", NULL }; +char *DLG51[] = { "Tony", "Butch", "Dudley" }; +char *DLG52[] = { "Tony", NULL }; +char *DLG61[] = { "Tony", "Staruszka 1", NULL }; +char *DLG71[] = { "Tony", "Timothy", "Skazaniec", NULL, NULL, "ebster (przez mikrofon)", "Staruszka 1", NULL }; +char *DLG90[] = { "Tony", "Kobieta z Brod", NULL }; +char *DLG110[] = { "Tony", "Lorenz", NULL }; +char *DLG111[] = { "Tony", "Lorenz", NULL }; +char *DLG130[] = { "Tony", "Pirania", NULL }; +char *DLG150[] = { "Tony", "Rufus", "Bawan", NULL }; +char *DLG151[] = { "Tony", "Rufus", "Bawan", NULL }; +char *DLG152[] = { "Tony", "Rufus", "Bawan", NULL }; +char *DLG153[] = { "Tony", "Rufus", "Bawan", NULL }; +char *DLG154[] = { "Tony", "Rufus", "Bawan", NULL }; +char *DLG160[] = { "Tony", "miechozol", NULL }; +char *DLG161[] = { "Tony", "miechozol", NULL }; +char *DLG162[] = { "Tony", "miechozol", NULL }; +char *DLG163[] = { "Tony", "miechozol", NULL }; +char *DLG180[] = { "Tony", "Wycz", NULL }; +char *DLG190[] = { "Tony", "Wycz", NULL }; +char *DLG191[] = { "Tony", "Wycz", NULL }; +char *DLG201[] = { "Tony", NULL }; +char *DLG210[] = { "Tony", "Mortimer (Okropny)", NULL }; +char *DLG211[] = { "Tony", "Mortimer (Okropny)", NULL }; +char *DLG212[] = { "Tony", "Mortimer (Okropny)", NULL }; +char *DLG240[] = { "Tony", "Isabella", NULL }; +char *DLG250[] = { "Tony", "Barman", "Smutny Pirat", "Wodzirej", "Biff", NULL }; +char *DLG251[] = { "Tony", "Barman", "Smutny Pirat", "Wodzirej", "Biff", NULL }; +char *DLG260[] = { "Tony", "Kapitan", "Captain (opowie)", NULL }; +char *DLG270[] = { "Tony", "Jajogowy", NULL }; +char *DLG271[] = { "Tony", "Jajogowy", NULL }; +char *DLG272[] = { "Tony", "Jajogowy", NULL }; +char *DLG290[] = { "Tony", "Staruszka 2", NULL }; +char *DLG310[] = { "Tony", "Wally", NULL }; +char *DLG330[] = { "Tony", "Polly", "Kapitan (zza sceny)", NULL }; +char *DLG340[] = { "Tony", "Randall", NULL }; +char *DLG360[] = { "Tony", NULL }; +char *DLG361[] = { "Tony", NULL }; +char *DLG370[] = { "Tony", "Stranik", NULL }; +char *DLG371[] = { "Tony", "Stranik", NULL }; +char *DLG372[] = { "Tony", "Stranik", NULL }; +char *DLG373[] = { "Tony", "Stranik", NULL }; +char *DLG380[] = { "Tony", NULL }; +char *DLG410[] = { "Tony", "Gwendel", NULL }; +char *DLG430[] = { "Tony", "Harold", "Chuck", "Pigeons", "Gospodyni (zza sceny)", NULL }; +char *DLG460[] = { "Tony", NULL }; +char *DLG470[] = { "Tony", "Gospodyni", "Mirror", NULL }; +char *DLG471[] = { "Tony", "Gospodyni", "Mirror", NULL }; +char *DLG472[] = { "Tony", "Gospodyni", "Mirror", NULL }; +char *DLG473[] = { "Tony", "Gospodyni", "Mirror", NULL }; +char *DLG474[] = { "Tony", "Gospodyni", "Mirror", NULL }; +char *DLG480[] = { "Tony", "Pin-up", NULL }; +char *DLG490[] = { "Tony", "Gwendel", NULL }; +char *DLG530[] = { "Tony", "Harold", "Chuck", NULL }; +char *DLG550[] = { "Tony", "Pan Studnia ycze", "Tony (nad studni)", NULL }; +char *DLG560[] = { "Tony", "Inspektor", NULL }; +char *DLG590[] = { "Tony", "Pantaloniarz", NULL }; +char *DLG600[] = { "Tony", "ebster", "ebster", NULL, "ebster", NULL, NULL, NULL, "Narrator", "Pan Studnia ycze", NULL }; +#endif // Polish + + +#if 0 // Russian +char *DLG10[] = { "呷辷", NULL }; +char *DLG51[] = { "呷辷", "蒼", "釣粳" }; +char *DLG52[] = { "呷辷", NULL }; +char *DLG61[] = { "呷辷", "剪瑁齪袱 1", NULL }; +char *DLG71[] = { "呷辷", "呎跪鱶", "暦黽粤迯", NULL, NULL, "剃繩 ( 跏褓銓鉈鉤)", "剪瑁齪袱 1", NULL }; +char *DLG90[] = { "呷辷", "綜韲籥鰰 聽逋蓁", NULL }; +char *DLG110[] = { "呷辷", "鮪鞳逍", NULL }; +char *DLG111[] = { "呷辷", "鮪鞳逍", NULL }; +char *DLG130[] = { "呷辷", "蒡琿", NULL }; +char *DLG150[] = { "呷辷", "偕齣", "剄繝鈞蒻", NULL }; +char *DLG151[] = { "呷辷", "偕齣", "剄繝鈞蒻", NULL }; +char *DLG152[] = { "呷辷", "偕齣", "剄繝鈞蒻", NULL }; +char *DLG153[] = { "呷辷", "偕齣", "剄繝鈞蒻", NULL }; +char *DLG154[] = { "呷辷", "偕齣", "剄繝鈞蒻", NULL }; +char *DLG160[] = { "呷辷", "懋珸謌", NULL }; +char *DLG161[] = { "呷辷", "懋珸謌", NULL }; +char *DLG162[] = { "呷辷", "懋珸謌", NULL }; +char *DLG163[] = { "呷辷", "懋珸謌", NULL }; +char *DLG180[] = { "呷辷", "恣粮礦", NULL }; +char *DLG190[] = { "呷辷", "恣粮礦", NULL }; +char *DLG191[] = { "呷辷", "恣粮礦", NULL }; +char *DLG201[] = { "呷辷", NULL }; +char *DLG210[] = { "呷辷", "野頏蓐辮", NULL }; +char *DLG211[] = { "呷辷", "野頏蓐辮", NULL }; +char *DLG212[] = { "呷辷", "野頏蓐辮", NULL }; +char *DLG240[] = { "呷辷", "泌珀繼諤", NULL }; +char *DLG250[] = { "呷辷", "操韭纃", "註齣鴉 闊鞐", "代糂蓍", "争", NULL }; +char *DLG251[] = { "呷辷", "操韭纃", "註齣鴉 闊鞐", "代糂蓍", "争", NULL }; +char *DLG260[] = { "呷辷", "圃闊鰰", "圃闊鰰 (鞐髑袱)", NULL }; +char *DLG270[] = { "呷辷", "煢繝鉉鈞", NULL }; +char *DLG271[] = { "呷辷", "煢繝鉉鈞", NULL }; +char *DLG272[] = { "呷辷", "煢繝鉉鈞", NULL }; +char *DLG290[] = { "呷辷", "剪瑁齪袱 2", NULL }; +char *DLG310[] = { "呷辷", "嚴諡", NULL }; +char *DLG330[] = { "呷辷", "鉉謌", "圃闊鰰 (艢 髢纃鉗)", NULL }; +char *DLG340[] = { "呷辷", "傴辟琺", NULL }; +char *DLG360[] = { "呷辷", NULL }; +char *DLG361[] = { "呷辷", NULL }; +char *DLG370[] = { "呷辷", "韆碚瑩辷", NULL }; +char *DLG371[] = { "呷辷", "韆碚瑩辷", NULL }; +char *DLG372[] = { "呷辷", "韆碚瑩辷", NULL }; +char *DLG373[] = { "呷辷", "韆碚瑩辷", NULL }; +char *DLG380[] = { "呷辷", NULL }; +char *DLG410[] = { "呷辷", "窒纃粤譛", NULL }; +char *DLG430[] = { "呷辷", "逐韲譛", "怙", "Pigeons", "Housekeeper (off scene)", NULL }; +char *DLG460[] = { "呷辷", NULL }; +char *DLG470[] = { "呷辷", "Housekeeper", "Mirror", NULL }; +char *DLG471[] = { "呷辷", "Housekeeper", "Mirror", NULL }; +char *DLG472[] = { "呷辷", "Housekeeper", "Mirror", NULL }; +char *DLG473[] = { "呷辷", "Housekeeper", "Mirror", NULL }; +char *DLG474[] = { "呷辷", "Housekeeper", "Mirror", NULL }; +char *DLG480[] = { "呷辷", "Pin-up", NULL }; +char *DLG490[] = { "呷辷", "窒纃粤譛", NULL }; +char *DLG530[] = { "呷辷", "逐韲譛", "怙", NULL }; +char *DLG550[] = { "呷辷", "虫髀鈔蓁 菩謗粤 聽諤辷", "呷辷 ( 矼頽蓁 褌謗糜)", NULL }; +char *DLG560[] = { "呷辷", "沃琺辷 銛鞐逶", NULL }; +char *DLG590[] = { "呷辷", "琿鰰竦譛", NULL }; +char *DLG600[] = { "呷辷", "剃繩", "剃繩", NULL, "剃繩", NULL, NULL, NULL, "俥髑袱范蒻", "虫髀鈔蓁 菩謗粤 聽諤辷", NULL }; +#endif // Russian + + +#if 0 // Czech names +char *DLG10[] = { "Tony", NULL }; +char *DLG51[] = { "Tony", "Butch", "Dudley" }; +char *DLG52[] = { "Tony", NULL }; +char *DLG61[] = { "Tony", "Star pan 1", NULL }; +char *DLG71[] = { "Tony", "Timothy", "Trestanec", NULL, NULL, "Jack (s mikrofonem)", "Star pan 1", NULL }; +char *DLG90[] = { "Tony", "Vousat ena", NULL }; +char *DLG110[] = { "Tony", "Lorenz", NULL }; +char *DLG111[] = { "Tony", "Lorenz", NULL }; +char *DLG130[] = { "Tony", "Piraa", NULL }; +char *DLG150[] = { "Tony", "Rufus", "Snhulk", NULL }; +char *DLG151[] = { "Tony", "Rufus", "Snhulk", NULL }; +char *DLG152[] = { "Tony", "Rufus", "Snhulk", NULL }; +char *DLG153[] = { "Tony", "Rufus", "Snhulk", NULL }; +char *DLG154[] = { "Tony", "Rufus", "Snhulk", NULL }; +char *DLG160[] = { "Tony", "Shmiley", NULL }; +char *DLG161[] = { "Tony", "Shmiley", NULL }; +char *DLG162[] = { "Tony", "Shmiley", NULL }; +char *DLG163[] = { "Tony", "Shmiley", NULL }; +char *DLG180[] = { "Tony", "Zv逖e", NULL }; +char *DLG190[] = { "Tony", "Zv逖e", NULL }; +char *DLG191[] = { "Tony", "Zv逖e", NULL }; +char *DLG201[] = { "Tony", NULL }; +char *DLG210[] = { "Tony", "Mortimer", NULL }; +char *DLG211[] = { "Tony", "Mortimer", NULL }; +char *DLG212[] = { "Tony", "Mortimer", NULL }; +char *DLG240[] = { "Tony", "Isabella", NULL }; +char *DLG250[] = { "Tony", "Barman", "Smutn pirt", "Modertor", "Biff", NULL }; +char *DLG251[] = { "Tony", "Barman", "Smutn pirt", "Modertor", "Biff", NULL }; +char *DLG260[] = { "Tony", "Kapitn", "Kapitn (pbh)", NULL }; +char *DLG270[] = { "Tony", "Intelektul", NULL }; +char *DLG271[] = { "Tony", "Intelektul", NULL }; +char *DLG272[] = { "Tony", "Intelektul", NULL }; +char *DLG290[] = { "Tony", "Star pan 2", NULL }; +char *DLG310[] = { "Tony", "Wally", NULL }; +char *DLG330[] = { "Tony", "Lra", "Kapitn (mimo scnu)", NULL }; +char *DLG340[] = { "Tony", "Randall", NULL }; +char *DLG360[] = { "Tony", NULL }; +char *DLG361[] = { "Tony", NULL }; +char *DLG370[] = { "Tony", "Strn", NULL }; +char *DLG371[] = { "Tony", "Strn", NULL }; +char *DLG372[] = { "Tony", "Strn", NULL }; +char *DLG373[] = { "Tony", "Strn", NULL }; +char *DLG380[] = { "Tony", NULL }; +char *DLG410[] = { "Tony", "Gwendel", NULL }; +char *DLG430[] = { "Tony", "Harold", "Chuck", "Pigeons", "Housekeeper (off scene)", NULL }; +char *DLG460[] = { "Tony", NULL }; +char *DLG470[] = { "Tony", "Housekeeper", "Mirror", NULL }; +char *DLG471[] = { "Tony", "Housekeeper", "Mirror", NULL }; +char *DLG472[] = { "Tony", "Housekeeper", "Mirror", NULL }; +char *DLG473[] = { "Tony", "Housekeeper", "Mirror", NULL }; +char *DLG474[] = { "Tony", "Housekeeper", "Mirror", NULL }; +char *DLG480[] = { "Tony", "Pin-up", NULL }; +char *DLG490[] = { "Tony", "Gwendel", NULL }; +char *DLG530[] = { "Tony", "Harold", "Chuck", NULL }; +char *DLG550[] = { "Tony", "Pan Studna pn", "Tony (z vrcholu studny)", NULL }; +char *DLG560[] = { "Tony", "Sprvce", NULL }; +char *DLG590[] = { "Tony", "Pantagruel", NULL }; +char *DLG600[] = { "Tony", "Jack", "Jack", NULL, "Jack", NULL, NULL, NULL, "Vyprav跏", "Pan Studna pn", NULL }; +#endif // Czech names + +#if 1 // Deutsch names +char *DLG10[] = { "Tony", NULL }; +char *DLG51[] = { "Tony", "Butch", "Dudley" }; +char *DLG52[] = { "Tony", NULL }; +char *DLG61[] = { "Tony", "Alte Dame 1", NULL }; +char *DLG71[] = { "Tony", "Timothy", "Strfling", NULL, NULL, "Jack (mit Mikrofon)", "Alte Dame 1", NULL }; +char *DLG90[] = { "Tony", "Brtige Dame", NULL }; +char *DLG110[] = { "Tony", "Lorenz", NULL }; +char *DLG111[] = { "Tony", "Lorenz", NULL }; +char *DLG130[] = { "Tony", "Piranha", NULL }; +char *DLG150[] = { "Tony", "Rufus", "Schneemann", NULL }; +char *DLG151[] = { "Tony", "Rufus", "Schneemann", NULL }; +char *DLG152[] = { "Tony", "Rufus", "Schneemann", NULL }; +char *DLG153[] = { "Tony", "Rufus", "Schneemann", NULL }; +char *DLG154[] = { "Tony", "Rufus", "Schneemann", NULL }; +char *DLG160[] = { "Tony", "Shmiley", NULL }; +char *DLG161[] = { "Tony", "Shmiley", NULL }; +char *DLG162[] = { "Tony", "Shmiley", NULL }; +char *DLG163[] = { "Tony", "Shmiley", NULL }; +char *DLG180[] = { "Tony", "Biest", NULL }; +char *DLG190[] = { "Tony", "Biest", NULL }; +char *DLG191[] = { "Tony", "Biest", NULL }; +char *DLG201[] = { "Tony", NULL }; +char *DLG210[] = { "Tony", "Mortimer", NULL }; +char *DLG211[] = { "Tony", "Mortimer", NULL }; +char *DLG212[] = { "Tony", "Mortimer", NULL }; +char *DLG240[] = { "Tony", "Isabella", NULL }; +char *DLG250[] = { "Tony", "Barmann", "Trauriger Pirat", "Chefanimateur", "Biff", NULL }; +char *DLG251[] = { "Tony", "Barmann", "Trauriger Pirat", "Chefanimateur", "Biff", NULL }; +char *DLG260[] = { "Tony", "Kapitn", "Kapitn (Erzhlung)", NULL }; +char *DLG270[] = { "Tony", "Eierkopf", NULL }; +char *DLG271[] = { "Tony", "Eierkopf", NULL }; +char *DLG272[] = { "Tony", "Eierkopf", NULL }; +char *DLG290[] = { "Tony", "Alte Dame 2", NULL }; +char *DLG310[] = { "Tony", "Wally", NULL }; +char *DLG330[] = { "Tony", "Polly", "Kapitn (im Off)", NULL }; +char *DLG340[] = { "Tony", "Randall", NULL }; +char *DLG360[] = { "Tony", NULL }; +char *DLG361[] = { "Tony", NULL }; +char *DLG370[] = { "Tony", "Pfrtner", NULL }; +char *DLG371[] = { "Tony", "Pfrtner", NULL }; +char *DLG372[] = { "Tony", "Pfrtner", NULL }; +char *DLG373[] = { "Tony", "Pfrtner", NULL }; +char *DLG380[] = { "Tony", NULL }; +char *DLG410[] = { "Tony", "Gwendel", NULL }; +char *DLG430[] = { "Tony", "Harold", "Chuck", "Pigeons", "Housekeeper (off scene)", NULL }; +char *DLG460[] = { "Tony", NULL }; +char *DLG470[] = { "Tony", "Housekeeper", "Mirror", NULL }; +char *DLG471[] = { "Tony", "Housekeeper", "Mirror", NULL }; +char *DLG472[] = { "Tony", "Housekeeper", "Mirror", NULL }; +char *DLG473[] = { "Tony", "Housekeeper", "Mirror", NULL }; +char *DLG474[] = { "Tony", "Housekeeper", "Mirror", NULL }; +char *DLG480[] = { "Tony", "Pin-up", NULL }; +char *DLG490[] = { "Tony", "Gwendel", NULL }; +char *DLG530[] = { "Tony", "Harold", "Chuck", NULL }; +char *DLG550[] = { "Tony", "Herr Wunschbrunnen", "Tony (ber dem Brunnen)", NULL }; +char *DLG560[] = { "Tony", "Verwalter", NULL }; +char *DLG590[] = { "Tony", "Pantagruel", NULL }; +char *DLG600[] = { "Tony", "Jack", "Jack", NULL, "Jack", NULL, NULL, NULL, "Erzhler", "Herr Wunschbrunnen", NULL }; +#endif + + +#define HANDLE_DIALOG(num) \ +case num: \ + if (nPers >= sizeof(DLG##num) / sizeof(char*) || DLG##num[nPers]==NULL) \ + { \ + warning("ERROR: Il personaggio #%d non esiste nel dialogo %d!\n", nPers, nDlg); \ + return "ERROR"; \ + } \ + else \ + return DLG##num[nPers]; + + +char *GetPersonName(uint16 nDlg, int nPers) +{ + switch (nDlg) + { + HANDLE_DIALOG(10); + HANDLE_DIALOG(51); + HANDLE_DIALOG(52); + HANDLE_DIALOG(61); + HANDLE_DIALOG(71); + HANDLE_DIALOG(90); + HANDLE_DIALOG(110); + HANDLE_DIALOG(111); + HANDLE_DIALOG(130); + HANDLE_DIALOG(150); + HANDLE_DIALOG(151); + HANDLE_DIALOG(152); + HANDLE_DIALOG(153); + HANDLE_DIALOG(154); + HANDLE_DIALOG(160); + HANDLE_DIALOG(161); + HANDLE_DIALOG(162); + HANDLE_DIALOG(163); + HANDLE_DIALOG(180); + HANDLE_DIALOG(190); + HANDLE_DIALOG(191); + HANDLE_DIALOG(201); + HANDLE_DIALOG(210); + HANDLE_DIALOG(211); + HANDLE_DIALOG(212); + HANDLE_DIALOG(240); + HANDLE_DIALOG(250); + HANDLE_DIALOG(251); + HANDLE_DIALOG(260); + HANDLE_DIALOG(270); + HANDLE_DIALOG(271); + HANDLE_DIALOG(272); + HANDLE_DIALOG(290); + HANDLE_DIALOG(310); + HANDLE_DIALOG(330); + HANDLE_DIALOG(340); + HANDLE_DIALOG(360); + HANDLE_DIALOG(361); + HANDLE_DIALOG(370); + HANDLE_DIALOG(371); + HANDLE_DIALOG(372); + HANDLE_DIALOG(373); + HANDLE_DIALOG(380); + HANDLE_DIALOG(410); + HANDLE_DIALOG(430); + HANDLE_DIALOG(460); + HANDLE_DIALOG(470); + HANDLE_DIALOG(471); + HANDLE_DIALOG(472); + HANDLE_DIALOG(473); + HANDLE_DIALOG(474); + HANDLE_DIALOG(480); + HANDLE_DIALOG(490); + HANDLE_DIALOG(530); + HANDLE_DIALOG(550); + HANDLE_DIALOG(560); + HANDLE_DIALOG(590); + HANDLE_DIALOG(600); + + default: + warning("ERROR: Il dialogo %d non esiste!\n", nDlg); + return "ERROR"; + } +} + +void mpalDumpDialog(LPMPALDIALOG dlg) { + char dfn[64]; + char fname[64]; + int g,c,j; + struct command* curCmd; + char *frase; char *p; + char copia[2048]; + bool bAtLeastOne; + Common::OutSaveFile *f, *v1; + + v1 = g_system->getSavefileManager()->openForSaving("voicelist.txt"); + + sprintf(dfn,"DIALOG%03d.HTM",dlg->nObj); + warning("Dumping %s...\n", dfn); + + f = g_system->getSavefileManager()->openForSaving(dfn); + + f->writeString("\n\n"); + + for (g=0;dlg->Group[g].num != 0; g++) { + bAtLeastOne = false; + + for (c=0;cGroup[g].nCmds; c++) { + curCmd = &dlg->Command[dlg->Group[g].CmdNum[c]]; + if (curCmd->type == 1 && curCmd->nCf == 71) { + bAtLeastOne=true; + break; + } + } + + if (!bAtLeastOne) + continue; + + f->writeString(Common::String::format("

\n

Group %d

\n

\n", g)); + f->writeString("\n"); + + for (c=0;cGroup[g].nCmds; c++) { + curCmd = &dlg->Command[dlg->Group[g].CmdNum[c]]; + + // Se una funzione custom, e richiama la SendDialogMessage(nPers, nMsg) + if (curCmd->type == 1 && curCmd->nCf == 71) { + sprintf(fname, "%03d-%05d.WAV", dlg->nObj, curCmd->arg2); + + for (j=0;dlg->Periods[j]!=NULL;j++) + if (dlg->PeriodNums[j] == curCmd->arg2) + break; + + if (dlg->Periods[j]==NULL) + warning("ERROR: Dialogo %d, Periodo %d non trovato!\n", (int)dlg->nObj, (int)curCmd->arg2); + else { + frase = (char *)GlobalLock(dlg->Periods[j]); + strcpy(copia, frase); + GlobalUnlock(dlg->Periods[j]); + + while ((p=strchr(copia,'^')) != NULL) + *p = '\"'; + + p = frase; + while (*p == ' ') p++; + if (*p == '\0') + continue; + + v1->writeString(Common::String::format("%s\n", fname)); + f->writeString("\t\n"); + f->writeString(Common::String::format("\t\t\n", fname)); + f->writeString(Common::String::format("\t\t\n", + GetPersonName(dlg->nObj, curCmd->arg1))); + f->writeString(Common::String::format("\t\t\n",copia)); + f->writeString("\t\n"); + //fprintf(f, "(%s) <%s> %s\n", fname, GetPersonName(dlg->nObj, curCmd->arg1), copia); + } + } + } + + f->writeString("
%s %s %s

\n"); + //fprintf(f,"\n\n\n\n"); + } + + f->finalize(); + v1->finalize(); + delete f; + delete v1; +} + +void mpalDumpDialogs(void) { + int i; + + LockDialogs(); + + for (i=0;i '$N'*$u * * + * M $L #$ $ 8 "$c'#$b.. .@ Author: Giovanni Bajo.......... * + * M '$u "$u :" *$. "#*#" * + * M '$N. " F ^$k Desc: Main Include file for * + * 4> ^R$oue# d using MPAL.DLL......... * + * '$ "" @ ....................... * + * #b u# * + * $b .@" OS: [ ] DOS [X] WIN95 [ ] OS/2 * + * #$u .d" * + * '*$e. .zR".@ 様様様様様様様様様様様様様様様様様 * + * "*$$beooee$*" @"M This source code is * + * """ '$.? Copyright (C) Spyral Software * + * '$d> ALL RIGHTS RESERVED * + * '$> 様様様様様様様様様様様様様様様様様 * + * * + **************************************************************************/ + + +/****************************************************************************\ +* Copyright Notice +\****************************************************************************/ + +/* + * A Spyral Software Production: + * + * MPAL - MultiPurpose Adventure Language + * (C) 1997 Giovanni Bajo and Luca Giusti + * ALL RIGHTS RESERVED + * + * + */ + + +/****************************************************************************\ +* General Introduction +\****************************************************************************/ + +/* + * MPAL (MultiPurpose Adventure Language) is a high level language + * for the definition of adventure. Through the use of MPAL you can describe + * storyboard the adventure, and then use it with any user interface. + * In fact, unlike many other similar products, MPAL is not programmed through + * the whole adventure, but are defined only the locations, objects, as they may + * interact with each other, etc.. thus making MPAL useful for any type of adventure. + */ + +/****************************************************************************\ +* Structure +\****************************************************************************/ + +/* + * MPAL consists of two main files: MPAL.DLL and MPAL.H + * The first is the DLL that contains the code to interface with MPAL + * adventures, the second is the header that defines the prototypes + * functions. MPAL is compiled for Win32, and it can therefore be used with + * any compiler that supports Win32 DLL (Watcom C++, Visual C++, + * Delphi, etc.), and therefore compatible with both Windows 95 and Windows NT. + * + * To use the DLL, and 'obviously need to create a library for symbols to export. + * + */ + + +/****************************************************************************\ +* Custom Functions +\****************************************************************************/ + +/* + * A custom function and a function specified by the program that uses the + * library, to perform the particular code. The custom functions are + * retrieved from the library as specified in the source MPAL, and in particular + * in defining the behavior of an item with some action. + * + * To use the custom functions, you need to prepare an array of + * pointers to functions (such as using the type casting LPCUSTOMFUNCTION, + * (defined below), and pass it as second parameter to mpalInit (). Note you + * must specify the size of the array, as elements of pointers and which do not + * contain the same: the library will call it only those functions specified in + * the source MPAL. It can be useful, for debugging reasons, do not bet + * the shares of arrays used to debugging function, to avoid unpleasant crash, + * if it has been made an error in source and / or some oversight in the code. + * + */ + +#ifndef __MPAL_H +#define __MPAL_H + +#include "common/scummsys.h" +#include "common/rect.h" + +/****************************************************************************\ +* Macro definitions and structures +\****************************************************************************/ + +/* OK value for the error codes */ +#define OK 0 + +#define MAXFRAMES 400 // frame animation of an object +#define MAXPATTERN 40 // pattern of animation of an object + +#define MAXPOLLINGLOCATIONS 64 + +#define EXPORT +#define LPSTR char * + +/****************************************************************************\ +* enum QueryCoordinates +* --------------------- +* Description: Macro for use with queries that may refer to X and Y co-ordinates +\****************************************************************************/ + +enum QueryCoordinates { + MPQ_X, + MPQ_Y +}; + + +/****************************************************************************\ +* enum QueryTypes +* --------------- +* Description: Query can be used with mpalQuery (). In practice corresponds +* all claims that can do at the library +\****************************************************************************/ + +enum QueryTypes { + /* General Query */ + MPQ_VERSION=10, + + MPQ_GLOBAL_VAR=50, + MPQ_RESOURCE, + MPQ_MESSAGE, + + /* Query on leases */ + MPQ_LOCATION_IMAGE=100, + MPQ_LOCATION_SIZE, + + /* Queries about items */ + MPQ_ITEM_LIST=200, + MPQ_ITEM_DATA, + MPQ_ITEM_PATTERN, + MPQ_ITEM_NAME, + MPQ_ITEM_IS_ACTIVE, + + /* Query dialog */ + MPQ_DIALOG_PERIOD=300, + MPQ_DIALOG_WAITFORCHOICE, + MPQ_DIALOG_SELECTLIST, + MPQ_DIALOG_SELECTION, + + /* Query execution */ + MPQ_DO_ACTION=400, + MPQ_DO_DIALOG +}; + + +/****************************************************************************\ +* typedef ITEM +* ------------ +* Description: Framework to manage the animation of an item +\****************************************************************************/ + +typedef struct { + char *frames[MAXFRAMES]; + Common::Rect frameslocations[MAXFRAMES]; + Common::Rect bbox[MAXFRAMES]; + short pattern[MAXPATTERN][MAXFRAMES]; + short speed; + char numframe; + char numpattern; + char curframe; + char curpattern; + short destX, destY; + signed char Zvalue; + short objectID; + char TAG; +} ITEM; +typedef ITEM *LPITEM; + + +/****************************************************************************\ +* typedef LPCUSTOMFUNCTION +* ------------------------ +* Description: Define a custom function, to use the language MPAL +* to perform various controls as a result of an action +\****************************************************************************/ + +typedef void (*LPCUSTOMFUNCTION)(uint32, uint32, uint32, uint32); +typedef LPCUSTOMFUNCTION *LPLPCUSTOMFUNCTION; + + +/****************************************************************************\ +* typedef LPITEMIRQFUNCTION +* ------------------------- +* Description: Define an IRQ of an item that is called when the +* pattern changes or the status of an item +\****************************************************************************/ + +typedef void (*LPITEMIRQFUNCTION)(uint32, int, int); +typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; + + +/****************************************************************************\ +* Macrofunctions query +\****************************************************************************/ + +/****************************************************************************\ +* +* Function: uint32 mpalQueryVersion(void); +* +* Description: Gets the current version of MPAL +* +* Return: Version number (0x1232 = 1.2.3b) +* +\****************************************************************************/ + +#define mpalQueryVersion() \ + (uint16)mpalQuery(MPQ_VERSION) + + + +/****************************************************************************\ +* +* Function: uint32 mpalQueryGlobalVar(LPSTR lpszVarName); +* +* Description: Gets the numerical value of a global variable +* +* Input: LPSTR lpszVarName Nome della variabile (ASCIIZ) +* +* Return: Valore della variabile +* +* Note: This query was implemented for debugging. The program, +* if well designed, should not need to access variables from +* within the library. +* +\****************************************************************************/ + +#define mpalQueryGlobalVar(lpszVarName) \ + (uint32)mpalQuery(MPQ_GLOBAL_VAR,(LPSTR)(lpszVarName)) + + + +/****************************************************************************\ +* +* Function: HGLOBAL mpalQueryResource(uint32 dwResId); +* +* Description: Provides access to a resource inside the .MPC file +* +* Input: uint32 dwResId ID della risorsa +* +* Return: Handle to a memory area containing the resource, +* ready for use. +* +\****************************************************************************/ + +#define mpalQueryResource(dwResId) \ + (HGLOBAL)mpalQuery(MPQ_RESOURCE,(uint32)(dwResId)) + + + +/****************************************************************************\ +* +* Function: LPSTR mpalQueryMessage(uint32 nMsg); +* +* Description: Returns a message. +* +* Input: uint32 nMsg Message number +* +* Return: ASCIIZ message +* +* Note: The returned pointer must be freed with GlobalFree() +* after use. The message will be in ASCIIZ format. +* +\****************************************************************************/ + +#define mpalQueryMessage(nMsg) \ + (LPSTR)mpalQuery(MPQ_MESSAGE,(uint32)(nMsg)) + + + +/****************************************************************************\ +* +* Function: HGLOBAL mpalQueryLocationImage(uint32 nLoc); +* +* Description: Provides a image image +* +* Input: uint32 nLoc Locazion number +* +* Return: Returns a picture handle +* +\****************************************************************************/ + +#define mpalQueryLocationImage(nLoc) \ + (HGLOBAL)mpalQuery(MPQ_LOCATION_IMAGE,(uint32)(nLoc)) + + + +/****************************************************************************\ +* +* Function: uint32 mpalQueryLocationSize(uint32 nLoc, uint32 dwCoord); +* +* Description: Request the x or y size of a location in pixels +* +* Input: uint32 nLoc Location number +* uint32 dwCoord MPQ_Xr o MPQ_Y +* +* Return: Size +* +\****************************************************************************/ + +#define mpalQueryLocationSize(nLoc,dwCoord) \ + (uint32)mpalQuery(MPQ_LOCATION_SIZE,(uint32)(nLoc),(uint32)(dwCoord)) + + + +/****************************************************************************\ +* +* Function: uint32 * mpalQueryItemList(uint32 nLoc); +* +* Description: Provides the list of objects in the lease. +* +* Input: uint32 nLoc Location number +* +* Return: List of objects (accessible by Item [0], Item [1], etc.) +* +\****************************************************************************/ + +#define mpalQueryItemList(nLoc) \ + (uint32 *)mpalQuery(MPQ_ITEM_LIST,(uint32)(nLoc)) + + + +/****************************************************************************\ +* +* Function: LPBKGANIM mpalQueryItemData(uint32 nItem); +* +* Description: Provides information on an item +*e +* Input: uint32 nItem Item number +* +* Return: structure filled with requested information +* +\****************************************************************************/ + +#define mpalQueryItemData(nItem) \ + (LPITEM)mpalQuery(MPQ_ITEM_DATA,(uint32)(nItem)) + + + +/****************************************************************************\ +* +* Function: uint32 mpalQueryItemPattern(uint32 nItem); +* +* Description: Provides the current pattern of an item +* +* Input: uint32 nItem Item number +* +* Return: Number of animation patterns to be executed. +* +* Note: By default, the pattern of 0 indicates that we should +* do nothing. +* +\****************************************************************************/ + +#define mpalQueryItemPattern(nItem) \ + (uint32)mpalQuery(MPQ_ITEM_PATTERN,(uint32)(nItem)) + + + +/****************************************************************************\ +* +* Function: bool mpalQueryItemIsActive(uint32 nItem); +* +* Description: Returns true if an item is active +* +* Input: uint32 nItem Item number +* +* Return: TRUE if the item is active, FALSE otherwise +* +\****************************************************************************/ + +#define mpalQueryItemIsActive(nItem) \ + (bool)mpalQuery(MPQ_ITEM_IS_ACTIVE,(uint32)(nItem)) + + +/****************************************************************************\ +* +* Function: void mpalQueryItemName(uint32 nItem, LPSTR lpszName); +* +* Description: Returns the name of an item +* +* Input: uint32 nItem Item number +* LPSTR lpszName Pointer to a buffer of at least 33 bytes +* that will be filled with the name +* +* Note: If the item is not active (ie. if its status or number +* is less than or equal to 0), the string will be empty. +* +\****************************************************************************/ + +#define mpalQueryItemName(nItem,lpszName) \ + (uint32)mpalQuery(MPQ_ITEM_NAME,(uint32)(nItem),(LPSTR)(lpszName)) + + + +/****************************************************************************\ +* +* Function: LPSTR mpalQueryDialogPeriod(uint32 nDialog, uint32 nPeriod); +* +* Description: Returns a sentence of dialog. +* +* Input: uint32 nDialog Dialog number +* uint32 nPeriod Number of words +* +* Return: A pointer to the string of words, or NULL on failure. +* +* Note: The string must be freed after use by GlobalFree (). +* +* Unlike normal messages, the sentences of dialogue +* are formed by a single string terminated with 0. +* +\****************************************************************************/ + +#define mpalQueryDialogPeriod(nPeriod) \ + (LPSTR)mpalQuery(MPQ_DIALOG_PERIOD,(uint32)(nPeriod)) + + + +/****************************************************************************\ +* +* Function: int mpalQueryDialogWaitForChoice(void); +* +* Description: Wait until the moment in which the need is signaled +* to make a choice by the user. +* +* Return: Number of choice to be made, or -1 if the dialogue is finished. +* +\****************************************************************************/ + +#define mpalQueryDialogWaitForChoice() \ + (int)mpalQuery(MPQ_DIALOG_WAITFORCHOICE) + + + +/****************************************************************************\ +* +* Function: uint32 * mpalQueryDialogSelectList(uint32 nChoice); +* +* Description: Requires a list of various options for some choice within +* the current dialog. + +* Input: uint32 nChoice Choice number +* +* Return: A pointer to an array containing the data matched to each option. +* +* Note: The figure 'a uint32 specified in the source to which MPAL +* You can 'assign meaning that the more' suits. +* +* The pointer msut be freed after use by GlobalFree(). +* +\****************************************************************************/ + +#define mpalQueryDialogSelectList(nChoice) \ + (uint32 *)mpalQuery(MPQ_DIALOG_SELECTLIST,(uint32)(nChoice)) + + + +/****************************************************************************\ +* +* Function: bool mpalQueryDialogSelection(uint32 nChoice, uint32 dwData); +* +* Description: Warns the library that the user has selected, in a certain +* choice of the current dialog, corresponding option +* at a certain given. +* +* Input: uint32 nChoice Choice number of the choice that +* was in progress +* uint32 dwData Option that was selected by the user. +* +* Return: TRUE if all OK, FALSE on failure. +* +* Note: After execution of this query, MPAL continue +* Groups according to the execution of the dialogue. And necessary so the game +* remains on hold again for another Chosen by mpalQueryDialogWaitForChoice (). +* +\****************************************************************************/ + +#define mpalQueryDialogSelection(nChoice,dwData) \ + (bool)mpalQuery(MPQ_DIALOG_SELECTION,(uint32)(nChoice),(uint32)(dwData)) + + + +/****************************************************************************\ +* +* Function: HANDLE mpalQueryDoAction(uint32 nAction, uint32 nItem, +* uint32 dwParam); +* +* Description: Warns the library an action was performed on a Object. +* The library will call 'custom functions, if necessary. +* +* Input: uint32 nAction Action number +* uint32 nItem Item number +* uint32 dwParam Action parameter +* +* Return: Handle to the thread that is performing the action, or +* INVALID_HANDLE_VALUE if the action is not 'defined for +* the item, or the item and 'off. +* +* Note: The parameter is used primarily to implement actions +* as "U.S." involving two objects together. The action will be executed only +* if the item is active, ie if its status is a positive number greater than 0. +* +\****************************************************************************/ + +#define mpalQueryDoAction(nAction,nItem,dwParam) \ + (HANDLE)mpalQuery(MPQ_DO_ACTION,(uint32)(nAction),(uint32)(nItem),(uint32)(dwParam)) + + + +/****************************************************************************\ +* +* Function: HANDLE mpalQueryDoDialog(uint32 nDialog, uint32 nGroup); +* +* Description: Warns the library a dialogue was required. +* +* Input: uint32 nDialog Dialog number +* uint32 nGroup Group number to use +* +* Return: Handle to the thread that is running the box, or +* INVALID_HANDLE_VALUE if the dialogue does not exist. +* +\****************************************************************************/ + +#define mpalQueryDoDialog(nDialog,nGroup) \ + (HANDLE)mpalQuery(MPQ_DO_DIALOG,(uint32)(nDialog),(uint32)(nGroup)) + + + +/****************************************************************************\ +* Functions exported DLL +\****************************************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + +/****************************************************************************\ +* +* Function: bool mpalInit(LPSTR lpszMpcFileName, LPSTR lpszMprFileName, +* LPLPCUSTOMFUNCTION lplpcfArray); +* +* Description: Initializes the MPAL library, and opens an .MPC file, which +* will be 'used for all queries +* +* Input: LPSTR lpszMpcFileName Name of the .MPC file, including extension +* LPSTR lpszMprFileName Name of the .MPR file, including extension +* LPLPCUSTOMFUNCTION Array of pointers to custom functions +* +* Return: TRUE if all OK, FALSE on failure +* +\****************************************************************************/ + +bool EXPORT mpalInit(LPSTR lpszFileName, LPSTR lpszMprFileName, + LPLPCUSTOMFUNCTION lplpcfArray); + + + +/****************************************************************************\ +* +* Function: uint32 mpalQuery(uint16 wQueryType, ...); +* +* Description: This is the general function to communicate with the library, +* To request information about what is in the .MPC file +* +* Input: uint16 wQueryType Type of query. The list is in +* the QueryTypes enum. +* +* Return: 4 bytes depending on the type of query +* +* Note: I _strongly_ recommended to use macros defined above to use +* the query, since it helps avoid any unpleasant bugs due to +* forgeting parameters. +* +\****************************************************************************/ + +uint32 EXPORT mpalQuery(uint16 wQueryType, ...); + + + +/****************************************************************************\ +* +* Function: bool mpalExecuteScript(int nScript); +* +* Description: Execute a script. The script runs on multitasking by a thread. +* +* Input: int nScript Script number to run +* +* Return: TRUE if the script 'was launched, FALSE on failure +* +\****************************************************************************/ + +bool EXPORT mpalExecuteScript(int nScript); + + + +/****************************************************************************\ +* +* Function: uint32 mpalGetError(void); +* +* Description: Returns the current MPAL error code +* +* Return: Error code +* +\****************************************************************************/ + +uint32 EXPORT mpalGetError(void); + + + +/****************************************************************************\ +* +* Function: void mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCustom); +* +* Description: Install a custom routine That will be called by MPAL +* every time the pattern of an item has-been changed. +* +* Input: LPITEMIRQFUNCTION lpiifCustom Custom function to install +* +\****************************************************************************/ + +void EXPORT mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCustom); + + +/****************************************************************************\ +* +* Function: bool mpalStartIdlePoll(int nLoc); +* +* Description: Process the idle actions of the items on one location. +* +* Input: int nLoc Number of the location whose items +* must be processed for idle actions. +* +* Return: TRUE if all OK, and FALSE if it exceeded the maximum limit. +* +* Note: The maximum number of locations that can be polled +* simultaneously is defined defined by MAXPOLLINGFUNCIONS +* +\****************************************************************************/ + +bool EXPORT mpalStartIdlePoll(int nLoc); + + +/****************************************************************************\ +* +* Function: bool mpalEndIdlePoll(int nLoc); +* +* Description: Stop processing the idle actions of the items on one location. +* +* Input: int nLoc Number of the location +* +* Return: TRUE if all OK, FALSE if the specified location was not +* in the process of polling +* +\****************************************************************************/ + +bool EXPORT mpalEndIdlePoll(int nLoc); + + + +/****************************************************************************\ +* +* Function: int mpalLoadState(LPBYTE buf); +* +* Description: Load a save state from a buffer. +* +* Input: LPBYTE buf Buffer where to store the state +* +* Return: Length of the state in bytes +* +\****************************************************************************/ + +int EXPORT mpalLoadState(byte *buf); + + + +/****************************************************************************\ +* +* Function: void mpalSaveState(LPBYTE buf); +* +* Description: Store the save state into a buffer. The buffer must be +* length at least the size specified with mpalGetSaveStateSize +* +* Input: LPBYTE buf Buffer where to store the state +* +\****************************************************************************/ + +void EXPORT mpalSaveState(byte *buf); + + + +/****************************************************************************\ +* +* Function: int mpalGetSaveStateSize(void); +* +* Description: Acquire the length of a save state +* +* Return: Length in bytes +* +\****************************************************************************/ + +int EXPORT mpalGetSaveStateSize(void); + +#ifdef __cplusplus +} +#endif + +/****************************************************************************\ +* +* Function: void LockVar(void); +* +* Description: Locka le variabili per accederci +* +\****************************************************************************/ + +extern void LockVar(void); + +/****************************************************************************\ +* +* Function: void UnlockVar(void); +* +* Description: Unlocka le variabili dopo l'uso +* +\****************************************************************************/ + +extern void UnlockVar(void); + +#endif + diff --git a/engines/tony/mpal/mpaldll.h b/engines/tony/mpal/mpaldll.h new file mode 100644 index 0000000000..8a52f1ed90 --- /dev/null +++ b/engines/tony/mpal/mpaldll.h @@ -0,0 +1,418 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * + */ +/************************************************************************** + * 様様様様様様様様様様様様様様様様様 * + * ... Spyral Software snc * + * . x#""*$Nu -= We create much MORE than ALL =- * + * d*#R$. R ^#$o 様様様様様様様様様様様様様様様様様 * + * .F ^$k $ "$b * + * ." $b u "$ #$L * + * P $c :*$L"$L '$k Project: MPAL................... * + * d @$N. $. d ^$b^$k $c * + * F 4 "$c '$ $ #$u#$u '$ Module: MPAL DLL Header........ * + * 4 4k *N #b .> '$N'*$u * * + * M $L #$ $ 8 "$c'#$b.. .@ Author: Giovanni Bajo.......... * + * M '$u "$u :" *$. "#*#" * + * M '$N. " F ^$k Desc: Header per i moduli per * + * 4> ^R$oue# d la DLL di query di MPAL * + * '$ "" @ ....................... * + * #b u# * + * $b .@" OS: [ ] DOS [X] WIN95 [ ] OS/2 * + * #$u .d" * + * '*$e. .zR".@ 様様様様様様様様様様様様様様様様様 * + * "*$$beooee$*" @"M This source code is * + * """ '$.? Copyright (C) Spyral Software * + * '$d> ALL RIGHTS RESERVED * + * '$> 様様様様様様様様様様様様様様様様様 * + * * + **************************************************************************/ + +#ifndef __MPALDLL_H +#define __MPALDLL_H + +#include "common/file.h" +#include "stubs.h" + +namespace Tony { + +namespace MPAL { + +/****************************************************************************\ +* Defines +\****************************************************************************/ + +#define HEX_VERSION 0x0170 + +/* + SICURA + +#define MAX_ACTIONS_PER_ITEM 40 +#define MAX_COMMANDS_PER_ITEM 256 +#define MAX_COMMANDS_PER_ACTION 64 +#define MAX_DESCRIBE_SIZE 128 +*/ + +#define MAX_ACTIONS_PER_ITEM 40 +#define MAX_COMMANDS_PER_ITEM 128 +#define MAX_COMMANDS_PER_ACTION 128 +#define MAX_DESCRIBE_SIZE 64 + + + +#define MAX_MOMENTS_PER_SCRIPT 256 +#define MAX_COMMANDS_PER_SCRIPT 256 +#define MAX_COMMANDS_PER_MOMENT 32 + + + + + +/* + Versione sicura! + +#define MAX_GROUPS_PER_DIALOG 128 +#define MAX_COMMANDS_PER_DIALOG 640 +#define MAX_COMMANDS_PER_GROUP 64 +#define MAX_CHOICES_PER_DIALOG 64 +#define MAX_SELECTS_PER_CHOICE 33 +#define MAX_PLAYGROUPS_PER_SELECT 9 +#define MAX_PERIODS_PER_DIALOG 640 + +*/ + +#define MAX_GROUPS_PER_DIALOG 128 +#define MAX_COMMANDS_PER_DIALOG 480 +#define MAX_COMMANDS_PER_GROUP 64 +#define MAX_CHOICES_PER_DIALOG 64 +#define MAX_SELECTS_PER_CHOICE 64 +#define MAX_PLAYGROUPS_PER_SELECT 9 +#define MAX_PERIODS_PER_DIALOG 400 + +/* + Prima di Rufus: + +#define MAX_GROUPS_PER_DIALOG 128 +#define MAX_COMMANDS_PER_DIALOG 512 +#define MAX_COMMANDS_PER_GROUP 32 +#define MAX_CHOICES_PER_DIALOG 64 +#define MAX_SELECTS_PER_CHOICE 32 +#define MAX_PLAYGROUPS_PER_SELECT 4 +#define MAX_PERIODS_PER_DIALOG 512 +*/ + +#define NEED_LOCK_MSGS + + +/****************************************************************************\ +* Strutture +\****************************************************************************/ + +#include "common/pack-start.h" + +/****************************************************************************\ +* typedef MPALVAR +* --------------- +* Description: Variabile globale di MPAL +\****************************************************************************/ + +struct MPALVAR { + uint32 dwVal; // Valore della variabile + char lpszVarName[33]; // Nome della variabile +} PACKED_STRUCT; +typedef MPALVAR* LPMPALVAR; +typedef LPMPALVAR* LPLPMPALVAR; + + +/****************************************************************************\ +* typedef MPALMSG +* --------------- +* Description: Messaggio di MPAL +\****************************************************************************/ + +struct MPALMSG { + HGLOBAL hText; // Handle al testo del messaggio + uint16 wNum; // Numero del messaggio +} PACKED_STRUCT; +typedef MPALMSG* LPMPALMSG; +typedef LPMPALMSG* LPLPMPALMSG; + + +/****************************************************************************\ +* typedef MPALLOCATION +* -------------------- +* Description: Locazione di MPAL +\****************************************************************************/ + +struct MPALLOCATION { + uint32 nObj; // Numero della locazione + uint32 dwXlen, dwYlen; // Dimensione + uint32 dwPicRes; // Risorsa che contiene l'immagine +} PACKED_STRUCT; +typedef MPALLOCATION* LPMPALLOCATION; +typedef LPMPALLOCATION* LPLPMPALLOCATION; + + +/****************************************************************************\ +* struct command +* -------------- +* Description: Gestisce un comando, cioe' le tag utilizzate dalle OnAction +* negli item, dalle Time negli script e dai Group nei Dialog +\****************************************************************************/ + +struct command { + /* + * Tipi di comandi riconosciuti: + * + * #1 -> Chiamata a funzione custom (ITEM, SCRIPT, DIALOG) + * #2 -> Assegnazione di variabile (ITEM, SCRIPT, DIALOG) + * #3 -> Esecuzione di una scelta (DIALOG) + * + */ + byte type; // Tipo di comando + + union { + int32 nCf; // Numero funzione custom [#1] + char *lpszVarName; // Nome variabile [#2] + int32 nChoice; // Numero di scelta da fare [#3] + }; + + union { + int32 arg1; // Argomento 1 funzione custom [#1] + HGLOBAL expr; // Espressione da assegnare alla + // variabile [#2] + }; + + int32 arg2,arg3,arg4; // Argomenti per funzione custom [#1] +} PACKED_STRUCT; + +/****************************************************************************\ +* typedef MPALDIALOG +* ------------------ +* Description: Dialog di MPAL +\****************************************************************************/ + +struct MPALDIALOG { + uint32 nObj; // Numero dialog + + struct command Command[MAX_COMMANDS_PER_DIALOG]; + + struct { + uint16 num; + + byte nCmds; + uint16 CmdNum[MAX_COMMANDS_PER_GROUP]; + + } Group[MAX_GROUPS_PER_DIALOG]; + + struct { + // L'ultima choice ha nChoice==0 + uint16 nChoice; + + // Non c'e' il numero di Select (siamo abbastanza avari di RAM). L'ultimo + // select ha dwData==0 + struct { + HGLOBAL when; + uint32 dwData; + uint16 wPlayGroup[MAX_PLAYGROUPS_PER_SELECT]; + + // Bit 0=endchoice Bit 1=enddialog + byte attr; + + // Modificata a run-time: 0 se il select e' correntemente disabilitato, + // 1 se e' correntemente attivato + byte curActive; + } Select[MAX_SELECTS_PER_CHOICE]; + + } Choice[MAX_CHOICES_PER_DIALOG]; + + uint16 PeriodNums[MAX_PERIODS_PER_DIALOG]; + HGLOBAL Periods[MAX_PERIODS_PER_DIALOG]; + +} PACKED_STRUCT; +typedef MPALDIALOG* LPMPALDIALOG; +typedef LPMPALDIALOG* LPLPMPALDIALOG; + +/****************************************************************************\ +* typedef MPALITEM +* ---------------- +* Description: Item di MPAL +\****************************************************************************/ + +struct ItemAction { + byte num; // Numero dell'azione + uint16 wTime; // In caso di idle, il tempo che deve passare + byte perc; // Percentuale di eseguire l'idle + HGLOBAL when; // Espressione da calcolare: se !=0, allora + // l'azione puo' essere eseguita + uint16 wParm; // Parametro per l'azione + + byte nCmds; // Numero comandi da eseguire + uint32 CmdNum[MAX_COMMANDS_PER_ACTION]; // Comando da eseguire +} PACKED_STRUCT; + +struct MPALITEM { + uint32 nObj; // Numero item + + byte lpszDescribe[MAX_DESCRIBE_SIZE]; // Nome + byte nActions; // Numero delle azioni gestite + uint32 dwRes; // Risorsa che contiene frame e pattern + + struct command Command[MAX_COMMANDS_PER_ITEM]; + + // Array di strutture contenenti le varie azioni gestite. In pratica, di + // ogni azione sappiamo quali comandi eseguire, tra quelli definiti nella + // struttura qui sopra +/* + struct + { + byte num; // Numero dell'azione + uint16 wTime; // In caso di idle, il tempo che deve passare + byte perc; // Percentuale di eseguire l'idle + HGLOBAL when; // Espressione da calcolare: se !=0, allora + // l'azione puo' essere eseguita + uint16 wParm; // Parametro per l'azione + + byte nCmds; // Numero comandi da eseguire + uint32 CmdNum[MAX_COMMANDS_PER_ACTION]; // Comando da eseguire + + } Action[MAX_ACTIONS_PER_ITEM]; + */ + struct ItemAction *Action; + +} PACKED_STRUCT; +typedef MPALITEM* LPMPALITEM; +typedef LPMPALITEM* LPLPMPALITEM; + + +/****************************************************************************\ +* typedef MPALSCRIPT +* ------------------ +* Description: Script di MPAL +\****************************************************************************/ + +struct MPALSCRIPT { + uint32 nObj; + + uint32 nMoments; + + struct command Command[MAX_COMMANDS_PER_SCRIPT]; + + struct { + int32 dwTime; + + byte nCmds; + uint32 CmdNum[MAX_COMMANDS_PER_MOMENT]; + + } Moment[MAX_MOMENTS_PER_SCRIPT]; + +} PACKED_STRUCT; +typedef MPALSCRIPT* LPMPALSCRIPT; +typedef LPMPALSCRIPT* LPLPMPALSCRIPT; + +#include "common/pack-end.h" + +/****************************************************************************\ +* Variabili globali +\****************************************************************************/ + +extern uint32 mpalError; +extern LPLPCUSTOMFUNCTION lplpFunctions; +extern uint16 nObjs; + +extern uint16 nVars; +extern HGLOBAL hVars; +extern LPMPALVAR lpmvVars; + +extern uint16 nMsgs; +extern HGLOBAL hMsgs; +extern LPMPALMSG lpmmMsgs; + +extern uint16 nDialogs; +extern HGLOBAL hDialogs; +extern LPMPALDIALOG lpmdDialogs; + +extern uint16 nItems; +extern HGLOBAL hItems; +extern LPMPALITEM lpmiItems; + +extern uint16 nLocations; +extern HGLOBAL hLocations; +extern LPMPALLOCATION lpmlLocations; + +extern uint16 nScripts; +extern HGLOBAL hScripts; +extern LPMPALSCRIPT lpmsScripts; + +extern Common::File hMpr; +extern uint16 nResources; +extern uint32 * lpResources; + +/****************************************************************************\ +* Prototipi di funzione +\****************************************************************************/ + +/****************************************************************************\ +* +* Function: int32 varGetValue(const char *lpszVarName); +* +* Description: Restituisce il valore corrente di una variabile globale +* +* Input: const char *lpszVarName Nome della variabile +* +* Return: Valore corrente +* +* Note: Prima di questa funzione, bisogna richiamare LockVar() che +* locka le variabili globali per l'utilizzo. Dopo inoltre bi- +* sogna ricordarsi di chiamare UnlockVar() +* +\****************************************************************************/ + +int32 varGetValue(const char *lpszVarName); + + +/****************************************************************************\ +* +* Function: void varSetValue(const char *lpszVarName, int32 val); +* +* Description: Setta un nuovo valore per una variabile globale di MPAL +* +* Input: const char *lpszVarName Nome della variabile +* int32 val Valore da settare +* +\****************************************************************************/ + +void varSetValue(const char *lpszVarName, int32 val); + +/****************************************************************************\ +* Includes the various modules +\****************************************************************************/ + +} // end of namespace MPAL + +} // end of namespace Tony + +#include "loadmpc.h" +#include "expr.h" + +#endif + diff --git a/engines/tony/mpal/stubs.cpp b/engines/tony/mpal/stubs.cpp new file mode 100644 index 0000000000..342678b856 --- /dev/null +++ b/engines/tony/mpal/stubs.cpp @@ -0,0 +1,140 @@ +e/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * + */ + +#ifndef TONY_MPAL_STUBS +#define TONY_MPAL_STUBS + +/****************************************************************************\ +* This file contains stubs and mappings for things used by the MPAL +* library that are handled differently under ScummVM +\****************************************************************************/ + +#include "common/algorithm.h" +#include "common/system.h" +#include "engines/engine.h" +#include "tony/tony.h" +#include "stubs.h" + +namespace Tony { + +namespace MPAL { + +/** + * Allocates a memory block + */ +byte *GlobalAlloc(uint16 flags, int size) { + byte *result = (byte *)malloc(size); + + if (flags & GMEM_ZEROINIT) + Common::fill(result, result + size, 0); + + return result; +} + +/** + * Lock a global handle + * @param h Global handle + * @remarks Since HGLOBALs are directly representing the pointers anyway, + * simply return it + */ +void *GlobalLock(HGLOBAL h) { + return h; +} + +/** + * Unlock a global handle + * @param h Global handle + * @remarks Since HGLOBALs are directly representing the pointers anyway, + * the unlock method doesn't need to do anything + */ +void GlobalUnlock(HGLOBAL h) { +} + +/** + * Free a globally allocated memory block + * @param h Global handle + */ +void GlobalFree(HGLOBAL h) { + free(h); +} + +/** + * Display a message + * @param msg Message to display + */ +void MessageBox(const Common::String &msg) { + + _vm->GUIError(msg); +} + +/** + * Gets the current time in milliseconds + */ +uint32 timeGetTime() { + return g_system->getMillis(); +} + +HANDLE CreateThread(void *lpThreadAttributes, size_t dwStackSize, + LPTHREAD_START_ROUTINE lpStartAddress, void *lpParameter, + uint32 dwCreationFlags, uint32 *lpThreadId) { + *lpThreadId = 0; + return 0; +} + +void ExitThread(HANDLE ThreadId) { +} + +void TerminateThread(HANDLE ThreadId, uint32 dwExitCode) { + +} + +void CloseHandle(HANDLE ThreadId) { + +} + +void Sleep(uint32 time) { +} + +int WaitForSingleObject(HANDLE ThreadId, uint32 dwSleepTime) { + return 0; +} + +uint32 WaitForMultipleObjects(uint32 nCount, const HANDLE *lpHandles, bool bWaitAll, uint32 dwMilliseconds) { + return 0; +} + +HANDLE CreateEvent(void *lpEventAttributes, bool bManualReset, bool bInitialState, const char *lpName) { + return 0; +} + +void SetEvent(HANDLE hEvent) { +} + +void ResetEvent(HANDLE hEvent) { +} + +} // end of namespace MPAL + +} // end of namespace Tony + +#endif diff --git a/engines/tony/mpal/stubs.h b/engines/tony/mpal/stubs.h new file mode 100644 index 0000000000..d66e12d00d --- /dev/null +++ b/engines/tony/mpal/stubs.h @@ -0,0 +1,121 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * + */ + +/****************************************************************************\ +* This file contains stubs and mappings for things used by the MPAL +* library that are handled differently under ScummVM +\****************************************************************************/ + +#ifndef MPAL_STUBS +#define MPAL_STUBS + +#include "common/scummsys.h" +#include "common/algorithm.h" + +namespace Tony { + +namespace MPAL { + +/****************************************************************************\ +* Types +\****************************************************************************/ + +typedef void *HGLOBAL; +typedef void *HANDLE; + +typedef uint32 (__stdcall *LPTHREAD_START_ROUTINE)(void *lpThreadParameter); + +/****************************************************************************\ +* Defines +\****************************************************************************/ + +#define GMEM_FIXED 1 +#define GMEM_MOVEABLE 2 +#define GMEM_ZEROINIT 4 + +#define MB_OK 1 + +#define PASCAL + +/****************************************************************************\ +* Templates +\****************************************************************************/ + +/** + * Copies data from the range [first, last) to [dst, dst + (last - first)). + * It requires the range [dst, dst + (last - first)) to be valid. + * It also requires dst not to be in the range [first, last). + */ +template +Out CopyMemory(Out dst, In first, int size) { + return Common::copy(first, first + size, dst); +} + +/****************************************************************************\ +* Methods +\****************************************************************************/ + +extern byte *GlobalAlloc(uint16 flags, int size); + +extern void *GlobalLock(HGLOBAL h); + +extern void GlobalUnlock(HGLOBAL h); + +extern void GlobalFree(HGLOBAL h); + +extern void MessageBox(const Common::String &msg); + +extern uint32 timeGetTime(); + +#define INFINITE 0xffffffff +#define WAIT_OBJECT_0 -2 +// Horrendously bad cast +#define INVALID_HANDLE_VALUE (void *)-3 + +extern HANDLE CreateThread(void *lpThreadAttributes, size_t dwStackSize, + LPTHREAD_START_ROUTINE lpStartAddress, void *lpParameter, + uint32 dwCreationFlags, uint32 *lpThreadId); + +extern void ExitThread(int ThreadId); + +extern void TerminateThread(HANDLE ThreadId, uint32 dwExitCode); + +extern void CloseHandle(HANDLE ThreadId); + +extern void Sleep(uint32 time); + +extern int WaitForSingleObject(HANDLE ThreadId, uint32 dwSleepTime); + +extern uint32 WaitForMultipleObjects(uint32 nCount, const HANDLE *lpHandles, bool bWaitAll, uint32 dwMilliseconds); + +extern HANDLE CreateEvent(void *lpEventAttributes, bool bManualReset, bool bInitialState, const char *lpName); + +extern void SetEvent(HANDLE hEvent); + +extern void ResetEvent(HANDLE hEvent); + +} // end of namespace MPAL + +} // end of namespace Tony + +#endif diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 523147c848..2d4385a5e6 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -20,20 +20,63 @@ * */ +#include "common/scummsys.h" +#include "common/algorithm.h" +#include "common/file.h" #include "tony/tony.h" +#include "tony/mpal/mpal.h" namespace Tony { TonyEngine *_vm; -TonyEngine::TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc) { +TonyEngine::TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc) : Engine(syst), + _gameDescription(gameDesc), _randomSource("tony") { + _vm = this; } TonyEngine::~TonyEngine() { } +/** + * Run the game + */ Common::Error TonyEngine::run() { + Common::ErrorCode result = Init(); + if (result != Common::kNoError) + return result; + + /* + Play(); + Close(); +*/ + return Common::kNoError; +} + +/** + * Initialise the game + */ +Common::ErrorCode TonyEngine::Init() { + // Initialise the function list + Common::fill(FuncList, FuncList + sizeof(FuncList), (LPCUSTOMFUNCTION)NULL); + + // Initializes MPAL system, passing the custom functions list + Common::File f; + if (!f.open("ROASTED.MPC")) + return Common::kReadingFailed; + f.close(); + + if (!mpalInit("ROASTED.MPC", "ROASTED.MPR", FuncList)) + return Common::kUnknownError; + return Common::kNoError; } +/** + * Display an error message + */ +void TonyEngine::GUIError(const Common::String &msg) { + GUIErrorMessage(msg); +} + } // End of namespace Tony diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 5aa0de95a3..cfb6748716 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -26,11 +26,12 @@ #include "common/scummsys.h" #include "common/system.h" #include "common/error.h" -#include "common/events.h" -#include "common/keyboard.h" +#include "common/random.h" #include "common/util.h" #include "engines/engine.h" +#include "tony/mpal.h" + /** * This is the namespace of the Tony engine. * @@ -41,6 +42,8 @@ */ namespace Tony { +using namespace MPAL; + enum { kTonyDebugAnimations = 1 << 0, kTonyDebugActions = 1 << 1, @@ -55,10 +58,15 @@ enum { struct TonyGameDescription; class TonyEngine : public Engine { +private: + Common::ErrorCode Init(); protected: // Engine APIs virtual Common::Error run(); virtual bool hasFeature(EngineFeature f) const; +public: + LPCUSTOMFUNCTION FuncList[300]; + Common::RandomSource _randomSource; public: TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc); virtual ~TonyEngine(); @@ -70,6 +78,8 @@ public: uint16 getVersion() const; uint32 getFlags() const; Common::Platform getPlatform() const; + + void GUIError(const Common::String &msg); }; // Global reference to the TonyEngine object -- cgit v1.2.3 From f955745ebf9aba0525de8196dc90de99fce6eab3 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 27 Apr 2012 01:32:46 +1000 Subject: TONY: Extra compilation changes and stubs so core MPAL code compiles --- engines/tony/lzo/stubs.cpp | 41 +++ engines/tony/module.mk | 1 + engines/tony/mpal.h | 749 -------------------------------------------- engines/tony/mpal/loadmpc.h | 2 +- engines/tony/mpal/mpal.cpp | 2 +- engines/tony/mpal/mpal.h | 12 +- engines/tony/mpal/stubs.cpp | 9 +- engines/tony/tony.h | 2 +- 8 files changed, 57 insertions(+), 761 deletions(-) create mode 100644 engines/tony/lzo/stubs.cpp delete mode 100644 engines/tony/mpal.h (limited to 'engines') diff --git a/engines/tony/lzo/stubs.cpp b/engines/tony/lzo/stubs.cpp new file mode 100644 index 0000000000..4a27f8cc18 --- /dev/null +++ b/engines/tony/lzo/stubs.cpp @@ -0,0 +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 contains temporary stubs for LZO functions +\****************************************************************************/ + +#include "lzo1x.h" + +namespace Tony { + +namespace LZO { + +int lzo1x_decompress( const lzo_byte *src, lzo_uint src_len, lzo_byte *dst, lzo_uint *dst_len, + lzo_voidp wrkmem /* NOT USED */ ) { + return 0; +} + +} // end of namespace LZO + +} // end of namespace Tony diff --git a/engines/tony/module.mk b/engines/tony/module.mk index d592fac68b..1b67312d39 100644 --- a/engines/tony/module.mk +++ b/engines/tony/module.mk @@ -3,6 +3,7 @@ MODULE := engines/tony MODULE_OBJS := \ detection.o \ tony.o \ + lzo\stubs.o \ mpal\expr.o \ mpal\loadmpc.o \ mpal\mpal.o \ diff --git a/engines/tony/mpal.h b/engines/tony/mpal.h deleted file mode 100644 index 0c15ef5b50..0000000000 --- a/engines/tony/mpal.h +++ /dev/null @@ -1,749 +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. - * - * - */ - -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * ... Spyral Software snc * - * . x#""*$Nu -= We create much MORE than ALL =- * - * d*#R$. R ^#$o 様様様様様様様様様様様様様様様様様 * - * .F ^$k $ "$b * - * ." $b u "$ #$L * - * P $c :*$L"$L '$k Project: MPAL................... * - * d @$N. $. d ^$b^$k $c * - * F 4 "$c '$ $ #$u#$u '$ Module: MPAL Main Include file. * - * 4 4k *N #b .> '$N'*$u * * - * M $L #$ $ 8 "$c'#$b.. .@ Author: Giovanni Bajo.......... * - * M '$u "$u :" *$. "#*#" * - * M '$N. " F ^$k Desc: Main Include file for * - * 4> ^R$oue# d using MPAL.DLL......... * - * '$ "" @ ....................... * - * #b u# * - * $b .@" OS: [ ] DOS [X] WIN95 [ ] OS/2 * - * #$u .d" * - * '*$e. .zR".@ 様様様様様様様様様様様様様様様様様 * - * "*$$beooee$*" @"M This source code is * - * """ '$.? Copyright (C) Spyral Software * - * '$d> ALL RIGHTS RESERVED * - * '$> 様様様様様様様様様様様様様様様様様 * - * * - **************************************************************************/ - - -/****************************************************************************\ -* Copyright Notice -\****************************************************************************/ - -/* - * A Spyral Software Production: - * - * MPAL - MultiPurpose Adventure Language - * (C) 1997 Giovanni Bajo and Luca Giusti - * ALL RIGHTS RESERVED - * - * - */ - - -/****************************************************************************\ -* General Introduction -\****************************************************************************/ - -/* - * MPAL (MultiPurpose Adventure Language) is a high level language - * for the definition of adventure. Through the use of MPAL you can describe - * storyboard the adventure, and then use it with any user interface. - * In fact, unlike many other similar products, MPAL is not programmed through - * the whole adventure, but are defined only the locations, objects, as they may - * interact with each other, etc.. thus making MPAL useful for any type of adventure. - */ - -/****************************************************************************\ -* Structure -\****************************************************************************/ - -/* - * MPAL consists of two main files: MPAL.DLL and MPAL.H - * The first is the DLL that contains the code to interface with MPAL - * adventures, the second is the header that defines the prototypes - * functions. MPAL is compiled for Win32, and it can therefore be used with - * any compiler that supports Win32 DLL (Watcom C++, Visual C++, - * Delphi, etc.), and therefore compatible with both Windows 95 and Windows NT. - * - * To use the DLL, and 'obviously need to create a library for symbols to export. - * - */ - - -/****************************************************************************\ -* Custom Functions -\****************************************************************************/ - -/* - * A custom function and a function specified by the program that uses the - * library, to perform the particular code. The custom functions are - * retrieved from the library as specified in the source MPAL, and in particular - * in defining the behavior of an item with some action. - * - * To use the custom functions, you need to prepare an array of - * pointers to functions (such as using the type casting LPCUSTOMFUNCTION, - * (defined below), and pass it as second parameter to mpalInit (). Note you - * must specify the size of the array, as elements of pointers and which do not - * contain the same: the library will call it only those functions specified in - * the source MPAL. It can be useful, for debugging reasons, do not bet - * the shares of arrays used to debugging function, to avoid unpleasant crash, - * if it has been made an error in source and / or some oversight in the code. - * - */ - -#ifndef __MPAL_H -#define __MPAL_H - -#include "common/rect.h" - -namespace Tony { - -namespace MPAL { - -/****************************************************************************\ -* Macro definitions and structures -\****************************************************************************/ - -/* OK value for the error codes */ -#define OK 0 - -#define MAXFRAMES 400 // frame animation of an object -#define MAXPATTERN 40 // pattern of animation of an object - -#define MAXPOLLINGLOCATIONS 64 - -#define EXPORT -#define LPSTR char * - -/****************************************************************************\ -* enum QueryCoordinates -* --------------------- -* Description: Macro for use with queries that may refer to X and Y co-ordinates -\****************************************************************************/ - -enum QueryCoordinates { - MPQ_X, - MPQ_Y -}; - - -/****************************************************************************\ -* enum QueryTypes -* --------------- -* Description: Query can be used with mpalQuery (). In practice corresponds -* all claims that can do at the library -\****************************************************************************/ - -enum QueryTypes { - /* General Query */ - MPQ_VERSION=10, - - MPQ_GLOBAL_VAR=50, - MPQ_RESOURCE, - MPQ_MESSAGE, - - /* Query on leases */ - MPQ_LOCATION_IMAGE=100, - MPQ_LOCATION_SIZE, - - /* Queries about items */ - MPQ_ITEM_LIST=200, - MPQ_ITEM_DATA, - MPQ_ITEM_PATTERN, - MPQ_ITEM_NAME, - MPQ_ITEM_IS_ACTIVE, - - /* Query dialog */ - MPQ_DIALOG_PERIOD=300, - MPQ_DIALOG_WAITFORCHOICE, - MPQ_DIALOG_SELECTLIST, - MPQ_DIALOG_SELECTION, - - /* Query execution */ - MPQ_DO_ACTION=400, - MPQ_DO_DIALOG -}; - - -/****************************************************************************\ -* typedef ITEM -* ------------ -* Description: Framework to manage the animation of an item -\****************************************************************************/ - -typedef struct { - char *frames[MAXFRAMES]; - Common::Rect frameslocations[MAXFRAMES]; - Common::Rect bbox[MAXFRAMES]; - short pattern[MAXPATTERN][MAXFRAMES]; - short speed; - uint8 numframe; - uint8 numpattern; - uint8 curframe; - uint8 curpattern; - short destX, destY; - signed char Zvalue; - short objectID; - char TAG; -} ITEM; -typedef ITEM *LPITEM; - - -/****************************************************************************\ -* typedef LPCUSTOMFUNCTION -* ------------------------ -* Description: Define a custom function, to use the language MPAL -* to perform various controls as a result of an action -\****************************************************************************/ - -typedef void (*LPCUSTOMFUNCTION)(uint32, uint32, uint32, uint32); -typedef LPCUSTOMFUNCTION *LPLPCUSTOMFUNCTION; - - -/****************************************************************************\ -* typedef LPITEMIRQFUNCTION -* ------------------------- -* Description: Define an IRQ of an item that is called when the -* pattern changes or the status of an item -\****************************************************************************/ - -typedef void (*LPITEMIRQFUNCTION)(uint32, int, int); -typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; - - -/****************************************************************************\ -* Macrofunctions query -\****************************************************************************/ - -/****************************************************************************\ -* -* Function: uint32 mpalQueryVersion(void); -* -* Description: Gets the current version of MPAL -* -* Return: Version number (0x1232 = 1.2.3b) -* -\****************************************************************************/ - -#define mpalQueryVersion() \ - (uint16)mpalQuery(MPQ_VERSION) - - - -/****************************************************************************\ -* -* Function: uint32 mpalQueryGlobalVar(LPSTR lpszVarName); -* -* Description: Gets the numerical value of a global variable -* -* Input: LPSTR lpszVarName Nome della variabile (ASCIIZ) -* -* Return: Valore della variabile -* -* Note: This query was implemented for debugging. The program, -* if well designed, should not need to access variables from -* within the library. -* -\****************************************************************************/ - -#define mpalQueryGlobalVar(lpszVarName) \ - (uint32)mpalQuery(MPQ_GLOBAL_VAR,(LPSTR)(lpszVarName)) - - - -/****************************************************************************\ -* -* Function: HGLOBAL mpalQueryResource(uint32 dwResId); -* -* Description: Provides access to a resource inside the .MPC file -* -* Input: uint32 dwResId ID della risorsa -* -* Return: Handle to a memory area containing the resource, -* ready for use. -* -\****************************************************************************/ - -#define mpalQueryResource(dwResId) \ - (HGLOBAL)mpalQuery(MPQ_RESOURCE,(uint32)(dwResId)) - - - -/****************************************************************************\ -* -* Function: LPSTR mpalQueryMessage(uint32 nMsg); -* -* Description: Returns a message. -* -* Input: uint32 nMsg Message number -* -* Return: ASCIIZ message -* -* Note: The returned pointer must be freed with GlobalFree() -* after use. The message will be in ASCIIZ format. -* -\****************************************************************************/ - -#define mpalQueryMessage(nMsg) \ - (LPSTR)mpalQuery(MPQ_MESSAGE,(uint32)(nMsg)) - - - -/****************************************************************************\ -* -* Function: HGLOBAL mpalQueryLocationImage(uint32 nLoc); -* -* Description: Provides a image image -* -* Input: uint32 nLoc Locazion number -* -* Return: Returns a picture handle -* -\****************************************************************************/ - -#define mpalQueryLocationImage(nLoc) \ - (HGLOBAL)mpalQuery(MPQ_LOCATION_IMAGE,(uint32)(nLoc)) - - - -/****************************************************************************\ -* -* Function: uint32 mpalQueryLocationSize(uint32 nLoc, uint32 dwCoord); -* -* Description: Request the x or y size of a location in pixels -* -* Input: uint32 nLoc Location number -* uint32 dwCoord MPQ_Xr o MPQ_Y -* -* Return: Size -* -\****************************************************************************/ - -#define mpalQueryLocationSize(nLoc,dwCoord) \ - (uint32)mpalQuery(MPQ_LOCATION_SIZE,(uint32)(nLoc),(uint32)(dwCoord)) - - - -/****************************************************************************\ -* -* Function: LPuint32 mpalQueryItemList(uint32 nLoc); -* -* Description: Provides the list of objects in the lease. -* -* Input: uint32 nLoc Location number -* -* Return: List of objects (accessible by Item [0], Item [1], etc.) -* -\****************************************************************************/ - -#define mpalQueryItemList(nLoc) \ - (LPuint32)mpalQuery(MPQ_ITEM_LIST,(uint32)(nLoc)) - - - -/****************************************************************************\ -* -* Function: LPBKGANIM mpalQueryItemData(uint32 nItem); -* -* Description: Provides information on an item -*e -* Input: uint32 nItem Item number -* -* Return: structure filled with requested information -* -\****************************************************************************/ - -#define mpalQueryItemData(nItem) \ - (LPITEM)mpalQuery(MPQ_ITEM_DATA,(uint32)(nItem)) - - - -/****************************************************************************\ -* -* Function: uint32 mpalQueryItemPattern(uint32 nItem); -* -* Description: Provides the current pattern of an item -* -* Input: uint32 nItem Item number -* -* Return: Number of animation patterns to be executed. -* -* Note: By default, the pattern of 0 indicates that we should -* do nothing. -* -\****************************************************************************/ - -#define mpalQueryItemPattern(nItem) \ - (uint32)mpalQuery(MPQ_ITEM_PATTERN,(uint32)(nItem)) - - - -/****************************************************************************\ -* -* Function: bool mpalQueryItemIsActive(uint32 nItem); -* -* Description: Returns true if an item is active -* -* Input: uint32 nItem Item number -* -* Return: TRUE if the item is active, FALSE otherwise -* -\****************************************************************************/ - -#define mpalQueryItemIsActive(nItem) \ - (bool)mpalQuery(MPQ_ITEM_IS_ACTIVE,(uint32)(nItem)) - - -/****************************************************************************\ -* -* Function: void mpalQueryItemName(uint32 nItem, LPSTR lpszName); -* -* Description: Returns the name of an item -* -* Input: uint32 nItem Item number -* LPSTR lpszName Pointer to a buffer of at least 33 bytes -* that will be filled with the name -* -* Note: If the item is not active (ie. if its status or number -* is less than or equal to 0), the string will be empty. -* -\****************************************************************************/ - -#define mpalQueryItemName(nItem,lpszName) \ - (uint32)mpalQuery(MPQ_ITEM_NAME,(uint32)(nItem),(LPSTR)(lpszName)) - - - -/****************************************************************************\ -* -* Function: LPSTR mpalQueryDialogPeriod(uint32 nDialog, uint32 nPeriod); -* -* Description: Returns a sentence of dialog. -* -* Input: uint32 nDialog Dialog number -* uint32 nPeriod Number of words -* -* Return: A pointer to the string of words, or NULL on failure. -* -* Note: The string must be freed after use by GlobalFree (). -* -* Unlike normal messages, the sentences of dialogue -* are formed by a single string terminated with 0. -* -\****************************************************************************/ - -#define mpalQueryDialogPeriod(nPeriod) \ - (LPSTR)mpalQuery(MPQ_DIALOG_PERIOD,(uint32)(nPeriod)) - - - -/****************************************************************************\ -* -* Function: int mpalQueryDialogWaitForChoice(void); -* -* Description: Wait until the moment in which the need is signaled -* to make a choice by the user. -* -* Return: Number of choice to be made, or -1 if the dialogue is finished. -* -\****************************************************************************/ - -#define mpalQueryDialogWaitForChoice() \ - (int)mpalQuery(MPQ_DIALOG_WAITFORCHOICE) - - - -/****************************************************************************\ -* -* Function: LPuint32 mpalQueryDialogSelectList(uint32 nChoice); -* -* Description: Requires a list of various options for some choice within -* the current dialog. - -* Input: uint32 nChoice Choice number -* -* Return: A pointer to an array containing the data matched to each option. -* -* Note: The figure 'a uint32 specified in the source to which MPAL -* You can 'assign meaning that the more' suits. -* -* The pointer msut be freed after use by GlobalFree(). -* -\****************************************************************************/ - -#define mpalQueryDialogSelectList(nChoice) \ - (LPuint32)mpalQuery(MPQ_DIALOG_SELECTLIST,(uint32)(nChoice)) - - - -/****************************************************************************\ -* -* Function: bool mpalQueryDialogSelection(uint32 nChoice, uint32 dwData); -* -* Description: Warns the library that the user has selected, in a certain -* choice of the current dialog, corresponding option -* at a certain given. -* -* Input: uint32 nChoice Choice number of the choice that -* was in progress -* uint32 dwData Option that was selected by the user. -* -* Return: TRUE if all OK, FALSE on failure. -* -* Note: After execution of this query, MPAL continue -* Groups according to the execution of the dialogue. And necessary so the game -* remains on hold again for another Chosen by mpalQueryDialogWaitForChoice (). -* -\****************************************************************************/ - -#define mpalQueryDialogSelection(nChoice,dwData) \ - (bool)mpalQuery(MPQ_DIALOG_SELECTION,(uint32)(nChoice),(uint32)(dwData)) - - - -/****************************************************************************\ -* -* Function: HANDLE mpalQueryDoAction(uint32 nAction, uint32 nItem, -* uint32 dwParam); -* -* Description: Warns the library an action was performed on a Object. -* The library will call 'custom functions, if necessary. -* -* Input: uint32 nAction Action number -* uint32 nItem Item number -* uint32 dwParam Action parameter -* -* Return: Handle to the thread that is performing the action, or -* INVALID_HANDLE_VALUE if the action is not 'defined for -* the item, or the item and 'off. -* -* Note: The parameter is used primarily to implement actions -* as "U.S." involving two objects together. The action will be executed only -* if the item is active, ie if its status is a positive number greater than 0. -* -\****************************************************************************/ - -#define mpalQueryDoAction(nAction,nItem,dwParam) \ - (HANDLE)mpalQuery(MPQ_DO_ACTION,(uint32)(nAction),(uint32)(nItem),(uint32)(dwParam)) - - - -/****************************************************************************\ -* -* Function: HANDLE mpalQueryDoDialog(uint32 nDialog, uint32 nGroup); -* -* Description: Warns the library a dialogue was required. -* -* Input: uint32 nDialog Dialog number -* uint32 nGroup Group number to use -* -* Return: Handle to the thread that is running the box, or -* INVALID_HANDLE_VALUE if the dialogue does not exist. -* -\****************************************************************************/ - -#define mpalQueryDoDialog(nDialog,nGroup) \ - (HANDLE)mpalQuery(MPQ_DO_DIALOG,(uint32)(nDialog),(uint32)(nGroup)) - - - -/****************************************************************************\ -* MPAL Interface Functions -\****************************************************************************/ - -/****************************************************************************\ -* -* Function: bool mpalInit(LPSTR lpszMpcFileName, LPSTR lpszMprFileName, -* LPLPCUSTOMFUNCTION lplpcfArray); -* -* Description: Initializes the MPAL library, and opens an .MPC file, which -* will be 'used for all queries -* -* Input: LPSTR lpszMpcFileName Name of the .MPC file, including extension -* LPSTR lpszMprFileName Name of the .MPR file, including extension -* LPLPCUSTOMFUNCTION Array of pointers to custom functions -* -* Return: TRUE if all OK, FALSE on failure -* -\****************************************************************************/ - -bool EXPORT mpalInit(LPSTR lpszFileName, LPSTR lpszMprFileName, - LPLPCUSTOMFUNCTION lplpcfArray); - - - -/****************************************************************************\ -* -* Function: uint32 mpalQuery(uint16 wQueryType, ...); -* -* Description: This is the general function to communicate with the library, -* To request information about what is in the .MPC file -* -* Input: uint16 wQueryType Type of query. The list is in -* the QueryTypes enum. -* -* Return: 4 bytes depending on the type of query -* -* Note: I _strongly_ recommended to use macros defined above to use -* the query, since it helps avoid any unpleasant bugs due to -* forgeting parameters. -* -\****************************************************************************/ - -uint32 EXPORT mpalQuery(uint16 wQueryType, ...); - - - -/****************************************************************************\ -* -* Function: bool mpalExecuteScript(int nScript); -* -* Description: Execute a script. The script runs on multitasking by a thread. -* -* Input: int nScript Script number to run -* -* Return: TRUE if the script 'was launched, FALSE on failure -* -\****************************************************************************/ - -bool EXPORT mpalExecuteScript(int nScript); - - - -/****************************************************************************\ -* -* Function: uint32 mpalGetError(void); -* -* Description: Returns the current MPAL error code -* -* Return: Error code -* -\****************************************************************************/ - -uint32 EXPORT mpalGetError(void); - - - -/****************************************************************************\ -* -* Function: void mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCustom); -* -* Description: Install a custom routine That will be called by MPAL -* every time the pattern of an item has-been changed. -* -* Input: LPITEMIRQFUNCTION lpiifCustom Custom function to install -* -\****************************************************************************/ - -void EXPORT mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCustom); - - -/****************************************************************************\ -* -* Function: bool mpalStartIdlePoll(int nLoc); -* -* Description: Process the idle actions of the items on one location. -* -* Input: int nLoc Number of the location whose items -* must be processed for idle actions. -* -* Return: TRUE if all OK, and FALSE if it exceeded the maximum limit. -* -* Note: The maximum number of locations that can be polled -* simultaneously is defined defined by MAXPOLLINGFUNCIONS -* -\****************************************************************************/ - -bool EXPORT mpalStartIdlePoll(int nLoc); - - -/****************************************************************************\ -* -* Function: bool mpalEndIdlePoll(int nLoc); -* -* Description: Stop processing the idle actions of the items on one location. -* -* Input: int nLoc Number of the location -* -* Return: TRUE if all OK, FALSE if the specified location was not -* in the process of polling -* -\****************************************************************************/ - -bool EXPORT mpalEndIdlePoll(int nLoc); - - - -/****************************************************************************\ -* -* Function: int mpalLoadState(LPBYTE buf); -* -* Description: Load a save state from a buffer. -* -* Input: LPBYTE buf Buffer where to store the state -* -* Return: Length of the state in bytes -* -\****************************************************************************/ - -int EXPORT mpalLoadState(byte *buf); - - - -/****************************************************************************\ -* -* Function: void mpalSaveState(LPBYTE buf); -* -* Description: Store the save state into a buffer. The buffer must be -* length at least the size specified with mpalGetSaveStateSize -* -* Input: LPBYTE buf Buffer where to store the state -* -\****************************************************************************/ - -void EXPORT mpalSaveState(byte *buf); - - - -/****************************************************************************\ -* -* Function: int mpalGetSaveStateSize(void); -* -* Description: Acquire the length of a save state -* -* Return: Length in bytes -* -\****************************************************************************/ - -int EXPORT mpalGetSaveStateSize(void); - -} // end of namespace MPAL - -} // end of namespace - -#endif - diff --git a/engines/tony/mpal/loadmpc.h b/engines/tony/mpal/loadmpc.h index 8763fbf95b..fc03e43b40 100644 --- a/engines/tony/mpal/loadmpc.h +++ b/engines/tony/mpal/loadmpc.h @@ -72,7 +72,7 @@ namespace MPAL { * \****************************************************************************/ -bool ParseMpc(const byte *lpBuf); +bool ParseMpc(byte *lpBuf); } // end of namespace MPAL diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 2fd9f3b9c3..f068f0fabf 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -153,7 +153,7 @@ uint32 nSelectedChoice; /****************************************************************************\ -* Static functions +* Internal functions \****************************************************************************/ /****************************************************************************\ diff --git a/engines/tony/mpal/mpal.h b/engines/tony/mpal/mpal.h index 73e2dec50f..70b49a1fd9 100644 --- a/engines/tony/mpal/mpal.h +++ b/engines/tony/mpal/mpal.h @@ -114,12 +114,16 @@ * */ -#ifndef __MPAL_H -#define __MPAL_H +#ifndef TONY_MPAL_H +#define TONY_MPAL_H #include "common/scummsys.h" #include "common/rect.h" +namespace Tony { + +namespace MPAL { + /****************************************************************************\ * Macro definitions and structures \****************************************************************************/ @@ -765,5 +769,9 @@ extern void LockVar(void); extern void UnlockVar(void); +} // end of namespace MPAL + +} // end of namespace Tony + #endif diff --git a/engines/tony/mpal/stubs.cpp b/engines/tony/mpal/stubs.cpp index 342678b856..c25dd2ab43 100644 --- a/engines/tony/mpal/stubs.cpp +++ b/engines/tony/mpal/stubs.cpp @@ -1,4 +1,4 @@ -e/* ScummVM - Graphic Adventure Engine +/* ScummVM - Graphic Adventure Engine * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT @@ -21,9 +21,6 @@ e/* ScummVM - Graphic Adventure Engine * */ -#ifndef TONY_MPAL_STUBS -#define TONY_MPAL_STUBS - /****************************************************************************\ * This file contains stubs and mappings for things used by the MPAL * library that are handled differently under ScummVM @@ -101,7 +98,7 @@ HANDLE CreateThread(void *lpThreadAttributes, size_t dwStackSize, return 0; } -void ExitThread(HANDLE ThreadId) { +void ExitThread(int ThreadId) { } void TerminateThread(HANDLE ThreadId, uint32 dwExitCode) { @@ -136,5 +133,3 @@ void ResetEvent(HANDLE hEvent) { } // end of namespace MPAL } // end of namespace Tony - -#endif diff --git a/engines/tony/tony.h b/engines/tony/tony.h index cfb6748716..804e489d82 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -30,7 +30,7 @@ #include "common/util.h" #include "engines/engine.h" -#include "tony/mpal.h" +#include "tony/mpal/mpal.h" /** * This is the namespace of the Tony engine. -- cgit v1.2.3 From f0d4b200d7b10a1f4a32e24459c9ed97e1484d2b Mon Sep 17 00:00:00 2001 From: Torbj旦rn Andersson Date: Fri, 27 Apr 2012 00:35:53 +0200 Subject: TONY: Change backslash to slash I assume slash works in Windows (since we use it in other engines), and I know backslash doesn't work in Linux because it failed for me. --- engines/tony/module.mk | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'engines') diff --git a/engines/tony/module.mk b/engines/tony/module.mk index 1b67312d39..578f58090c 100644 --- a/engines/tony/module.mk +++ b/engines/tony/module.mk @@ -3,11 +3,11 @@ MODULE := engines/tony MODULE_OBJS := \ detection.o \ tony.o \ - lzo\stubs.o \ - mpal\expr.o \ - mpal\loadmpc.o \ - mpal\mpal.o \ - mpal\stubs.o + lzo/stubs.o \ + mpal/expr.o \ + mpal/loadmpc.o \ + mpal/mpal.o \ + mpal/stubs.o # This module can be built as a plugin ifeq ($(ENABLE_TONY), DYNAMIC_PLUGIN) -- cgit v1.2.3 From ff71cda42448efaa50f7e98473087fec9c8ddb8d Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 29 Apr 2012 09:14:45 +1000 Subject: TONY: Further work on LZO integration --- engines/tony/lzo/lzo1x.h | 198 ------------------ engines/tony/lzo/lzoconf.h | 398 ----------------------------------- engines/tony/lzo/stubs.cpp | 41 ---- engines/tony/module.mk | 1 + engines/tony/mpal/lzo.cpp | 509 +++++++++++++++++++++++++++++++++++++++++++++ engines/tony/mpal/lzo.h | 100 +++++++++ engines/tony/mpal/lzo1x.h | 188 ----------------- engines/tony/mpal/mpal.cpp | 14 +- engines/tony/tony.cpp | 2 +- 9 files changed, 617 insertions(+), 834 deletions(-) delete mode 100644 engines/tony/lzo/lzo1x.h delete mode 100644 engines/tony/lzo/lzoconf.h delete mode 100644 engines/tony/lzo/stubs.cpp create mode 100644 engines/tony/mpal/lzo.cpp create mode 100644 engines/tony/mpal/lzo.h delete mode 100644 engines/tony/mpal/lzo1x.h (limited to 'engines') diff --git a/engines/tony/lzo/lzo1x.h b/engines/tony/lzo/lzo1x.h deleted file mode 100644 index e481b33fa4..0000000000 --- a/engines/tony/lzo/lzo1x.h +++ /dev/null @@ -1,198 +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. - * - */ -/* lzo1x.h -- public interface of the LZO1X compression algorithm - - This file is part of the LZO real-time data compression library. - - Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer - - The LZO library is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - The LZO library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with the LZO library; see the file COPYING. - If not, write to the Free Software Foundation, Inc., - 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - Markus F.X.J. Oberhumer - - http://wildsau.idv.uni-linz.ac.at/mfx/lzo.html - */ - - -#ifndef __LZO1X_H -#define __LZO1X_H - -#ifndef __LZOCONF_H -#include "lzoconf.h" -#endif - -namespace Tony { - -namespace LZO { - -#ifdef __cplusplus -extern "C" { -#endif - - -/*********************************************************************** -// -************************************************************************/ - -/* Memory required for the wrkmem parameter. - * When the required size is 0, you can also pass a NULL pointer. - */ - -#define LZO1X_MEM_COMPRESS LZO1X_1_MEM_COMPRESS -#define LZO1X_MEM_DECOMPRESS (0) -#define LZO1X_MEM_OPTIMIZE (0) - - -/* decompression */ -LZO_EXTERN(int) -lzo1x_decompress ( const lzo_byte *src, lzo_uint src_len, - lzo_byte *dst, lzo_uint *dst_len, - lzo_voidp wrkmem /* NOT USED */ ); - -/* safe decompression with overrun testing */ -LZO_EXTERN(int) -lzo1x_decompress_safe ( const lzo_byte *src, lzo_uint src_len, - lzo_byte *dst, lzo_uint *dst_len, - lzo_voidp wrkmem /* NOT USED */ ); - - -/*********************************************************************** -// -************************************************************************/ - -#define LZO1X_1_MEM_COMPRESS ((lzo_uint32) (16384L * lzo_sizeof_dict_t)) - -LZO_EXTERN(int) -lzo1x_1_compress ( const lzo_byte *src, lzo_uint src_len, - lzo_byte *dst, lzo_uint *dst_len, - lzo_voidp wrkmem ); - - -/*********************************************************************** -// special compressor versions -************************************************************************/ - -/* this version needs only 8 kB work memory */ -#define LZO1X_1_11_MEM_COMPRESS ((lzo_uint32) (2048L * lzo_sizeof_dict_t)) - -LZO_EXTERN(int) -lzo1x_1_11_compress ( const lzo_byte *src, lzo_uint src_len, - lzo_byte *dst, lzo_uint *dst_len, - lzo_voidp wrkmem ); - - -/* this version needs 16 kB work memory */ -#define LZO1X_1_12_MEM_COMPRESS ((lzo_uint32) (4096L * lzo_sizeof_dict_t)) - -LZO_EXTERN(int) -lzo1x_1_12_compress ( const lzo_byte *src, lzo_uint src_len, - lzo_byte *dst, lzo_uint *dst_len, - lzo_voidp wrkmem ); - - -/* use this version if you need a little more compression speed */ -#define LZO1X_1_15_MEM_COMPRESS ((lzo_uint32) (32768L * lzo_sizeof_dict_t)) - -LZO_EXTERN(int) -lzo1x_1_15_compress ( const lzo_byte *src, lzo_uint src_len, - lzo_byte *dst, lzo_uint *dst_len, - lzo_voidp wrkmem ); - - -/*********************************************************************** -// better compression ratio at the cost of more memory and time -************************************************************************/ - -#define LZO1X_999_MEM_COMPRESS ((lzo_uint32) (14 * 16384L * sizeof(short))) - -#if !defined(LZO_999_UNSUPPORTED) -LZO_EXTERN(int) -lzo1x_999_compress ( const lzo_byte *src, lzo_uint src_len, - lzo_byte *dst, lzo_uint *dst_len, - lzo_voidp wrkmem ); -#endif - - -/*********************************************************************** -// -************************************************************************/ - -#if !defined(LZO_999_UNSUPPORTED) -LZO_EXTERN(int) -lzo1x_999_compress_dict ( const lzo_byte *in , lzo_uint in_len, - lzo_byte *out, lzo_uint *out_len, - lzo_voidp wrkmem, - const lzo_byte *dict, lzo_uint dict_len ); - -LZO_EXTERN(int) -lzo1x_999_compress_level ( const lzo_byte *in , lzo_uint in_len, - lzo_byte *out, lzo_uint *out_len, - lzo_voidp wrkmem, - const lzo_byte *dict, lzo_uint dict_len, - lzo_progress_callback_t cb, - int compression_level ); -#endif - -LZO_EXTERN(int) -lzo1x_decompress_dict_safe ( const lzo_byte *in, lzo_uint in_len, - lzo_byte *out, lzo_uint *out_len, - lzo_voidp wrkmem /* NOT USED */, - const lzo_byte *dict, lzo_uint dict_len ); - - -/*********************************************************************** -// optimize a compressed data block -************************************************************************/ - -LZO_EXTERN(int) -lzo1x_optimize ( lzo_byte *in , lzo_uint in_len, - lzo_byte *out, lzo_uint *out_len, - lzo_voidp wrkmem ); - - - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -} // End of namespace LZO - -} // End of namespace Tony - -#endif /* already included */ - diff --git a/engines/tony/lzo/lzoconf.h b/engines/tony/lzo/lzoconf.h deleted file mode 100644 index 9dfcfb0cbc..0000000000 --- a/engines/tony/lzo/lzoconf.h +++ /dev/null @@ -1,398 +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. - * - */ -/* lzoconf.h -- configuration for the LZO real-time data compression library - - This file is part of the LZO real-time data compression library. - - Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer - - The LZO library is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - The LZO library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with the LZO library; see the file COPYING. - If not, write to the Free Software Foundation, Inc., - 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - Markus F.X.J. Oberhumer - - http://wildsau.idv.uni-linz.ac.at/mfx/lzo.html - */ - - -#ifndef __LZOCONF_H -#define __LZOCONF_H - -namespace Tony { - -namespace LZO { - -#define LZO_VERSION 0x1060 -#define LZO_VERSION_STRING "1.06" -#define LZO_VERSION_DATE "Nov 29 1999" - -/* internal Autoconf configuration file - only used when building LZO */ -#if defined(LZO_HAVE_CONFIG_H) -# include -#endif -#include - -#ifdef __cplusplus -extern "C" { -#endif - - -/*********************************************************************** -// LZO requires a conforming -************************************************************************/ - -#if !defined(CHAR_BIT) || (CHAR_BIT != 8) -# error "invalid CHAR_BIT" -#endif -#if !defined(UCHAR_MAX) || !defined(UINT_MAX) || !defined(ULONG_MAX) -# error "check your compiler installation" -#endif -#if (USHRT_MAX < 1 ) || (UINT_MAX < 1) || (ULONG_MAX < 1) -# error "your limits.h macros are broken" -#endif - -/* workaround a cpp bug under hpux 10.20 */ -#define LZO_0xffffffffL 4294967295ul - - -/*********************************************************************** -// architecture defines -************************************************************************/ - -#if !defined(__LZO_WIN) && !defined(__LZO_DOS) && !defined(__LZO_OS2) -# if defined(__WINDOWS__) || defined(_WINDOWS) || defined(_Windows) -# define __LZO_WIN -# elif defined(__WIN32__) || defined(_WIN32) || defined(WIN32) -# define __LZO_WIN -# elif defined(__NT__) || defined(__NT_DLL__) || defined(__WINDOWS_386__) -# define __LZO_WIN -# elif defined(__DOS__) || defined(__MSDOS__) || defined(MSDOS) -# define __LZO_DOS -# elif defined(__OS2__) || defined(__OS2V2__) || defined(OS2) -# define __LZO_OS2 -# elif defined(__palmos__) -# define __LZO_PALMOS -# elif defined(__TOS__) || defined(__atarist__) -# define __LZO_TOS -# endif -#endif - -#if (UINT_MAX < LZO_0xffffffffL) -# if defined(__LZO_WIN) -# define __LZO_WIN16 -# elif defined(__LZO_DOS) -# define __LZO_DOS16 -# elif defined(__LZO_PALMOS) -# define __LZO_PALMOS16 -# elif defined(__LZO_TOS) -# define __LZO_TOS16 -# elif defined(__C166__) -# else -# error "16-bit target not supported - contact me for porting hints" -# endif -#endif - -#if !defined(__LZO_i386) -# if defined(__LZO_DOS) || defined(__LZO_WIN16) -# define __LZO_i386 -# elif defined(__i386__) || defined(__386__) || defined(_M_IX86) -# define __LZO_i386 -# endif -#endif - -#if defined(__LZO_STRICT_16BIT) -# if (UINT_MAX < LZO_0xffffffffL) -# include -# endif -#endif - - -/*********************************************************************** -// integral and pointer types -************************************************************************/ - -/* Integral types with 32 bits or more */ -#if !defined(LZO_UINT32_MAX) -# if (UINT_MAX >= LZO_0xffffffffL) - typedef unsigned int lzo_uint32; - typedef int lzo_int32; -# define LZO_UINT32_MAX UINT_MAX -# define LZO_INT32_MAX INT_MAX -# define LZO_INT32_MIN INT_MIN -# elif (ULONG_MAX >= LZO_0xffffffffL) - typedef unsigned long lzo_uint32; - typedef long lzo_int32; -# define LZO_UINT32_MAX ULONG_MAX -# define LZO_INT32_MAX LONG_MAX -# define LZO_INT32_MIN LONG_MIN -# else -# error "lzo_uint32" -# endif -#endif - -/* lzo_uint is used like size_t */ -#if !defined(LZO_UINT_MAX) -# if (UINT_MAX >= LZO_0xffffffffL) - typedef unsigned int lzo_uint; - typedef int lzo_int; -# define LZO_UINT_MAX UINT_MAX -# define LZO_INT_MAX INT_MAX -# define LZO_INT_MIN INT_MIN -# elif (ULONG_MAX >= LZO_0xffffffffL) - typedef unsigned long lzo_uint; - typedef long lzo_int; -# define LZO_UINT_MAX ULONG_MAX -# define LZO_INT_MAX LONG_MAX -# define LZO_INT_MIN LONG_MIN -# else -# error "lzo_uint" -# endif -#endif - - -/* Memory model that allows to access memory at offsets of lzo_uint. */ -#if !defined(__LZO_MMODEL) -# if (LZO_UINT_MAX <= UINT_MAX) -# define __LZO_MMODEL -# elif defined(__LZO_DOS16) || defined(__LZO_WIN16) -# define __LZO_MMODEL __huge -# define LZO_999_UNSUPPORTED -# elif defined(__LZO_PALMOS16) || defined(__LZO_TOS16) -# define __LZO_MMODEL -# else -# error "__LZO_MMODEL" -# endif -#endif - -/* no typedef here because of const-pointer issues */ -#define lzo_byte unsigned char __LZO_MMODEL -#define lzo_bytep unsigned char __LZO_MMODEL * -#define lzo_charp char __LZO_MMODEL * -#define lzo_voidp void __LZO_MMODEL * -#define lzo_shortp short __LZO_MMODEL * -#define lzo_ushortp unsigned short __LZO_MMODEL * -#define lzo_uint32p lzo_uint32 __LZO_MMODEL * -#define lzo_int32p lzo_int32 __LZO_MMODEL * -#define lzo_uintp lzo_uint __LZO_MMODEL * -#define lzo_intp lzo_int __LZO_MMODEL * -#define lzo_voidpp lzo_voidp __LZO_MMODEL * -#define lzo_bytepp lzo_bytep __LZO_MMODEL * - -typedef int lzo_bool; - -#ifndef lzo_sizeof_dict_t -# define lzo_sizeof_dict_t sizeof(lzo_bytep) -#endif - - -/*********************************************************************** -// function types -************************************************************************/ - -/* linkage */ -#if !defined(__LZO_EXTERN_C) -# ifdef __cplusplus -# define __LZO_EXTERN_C extern "C" -# else -# define __LZO_EXTERN_C extern -# endif -#endif - -/* calling conventions */ -#if !defined(__LZO_CDECL) -# if defined(__LZO_DOS16) || defined(__LZO_WIN16) -# define __LZO_CDECL __far __cdecl -# elif defined(__LZO_i386) && defined(_MSC_VER) -# define __LZO_CDECL __cdecl -# elif defined(__LZO_i386) && defined(__WATCOMC__) -# define __LZO_CDECL __near __cdecl -# else -# define __LZO_CDECL -# endif -#endif -#if !defined(__LZO_ENTRY) -# define __LZO_ENTRY __LZO_CDECL -#endif - -/* DLL export information */ -#if !defined(__LZO_EXPORT1) -# define __LZO_EXPORT1 -#endif -#if !defined(__LZO_EXPORT2) -# define __LZO_EXPORT2 -#endif - -/* calling convention for C functions */ -#if !defined(LZO_PUBLIC) -# define LZO_PUBLIC(_rettype) __LZO_EXPORT1 _rettype __LZO_EXPORT2 __LZO_ENTRY -#endif -#if !defined(LZO_EXTERN) -# define LZO_EXTERN(_rettype) __LZO_EXTERN_C LZO_PUBLIC(_rettype) -#endif -#if !defined(LZO_PRIVATE) -# define LZO_PRIVATE(_rettype) static _rettype __LZO_ENTRY -#endif - -/* cdecl calling convention for assembler functions */ -#if !defined(LZO_PUBLIC_CDECL) -# define LZO_PUBLIC_CDECL(_rettype) \ - __LZO_EXPORT1 _rettype __LZO_EXPORT2 __LZO_CDECL -#endif -#if !defined(LZO_EXTERN_CDECL) -# define LZO_EXTERN_CDECL(_rettype) __LZO_EXTERN_C LZO_PUBLIC_CDECL(_rettype) -#endif - - -typedef int -(__LZO_ENTRY *lzo_compress_t) ( const lzo_byte *src, lzo_uint src_len, - lzo_byte *dst, lzo_uint *dst_len, - lzo_voidp wrkmem ); - -typedef int -(__LZO_ENTRY *lzo_decompress_t) ( const lzo_byte *src, lzo_uint src_len, - lzo_byte *dst, lzo_uint *dst_len, - lzo_voidp wrkmem ); - -typedef int -(__LZO_ENTRY *lzo_optimize_t) ( lzo_byte *src, lzo_uint src_len, - lzo_byte *dst, lzo_uint *dst_len, - lzo_voidp wrkmem ); - -typedef int -(__LZO_ENTRY *lzo_compress_dict_t)(const lzo_byte *src, lzo_uint src_len, - lzo_byte *dst, lzo_uint *dst_len, - lzo_voidp wrkmem, - const lzo_byte *dict, lzo_uint dict_len ); - -typedef int -(__LZO_ENTRY *lzo_decompress_dict_t)(const lzo_byte *src, lzo_uint src_len, - lzo_byte *dst, lzo_uint *dst_len, - lzo_voidp wrkmem, - const lzo_byte *dict, lzo_uint dict_len ); - - -/* a progress indicator callback function */ -typedef void (__LZO_ENTRY *lzo_progress_callback_t) (lzo_uint, lzo_uint); - - -/*********************************************************************** -// error codes and prototypes -************************************************************************/ - -/* Error codes for the compression/decompression functions. Negative - * values are errors, positive values will be used for special but - * normal events. - */ -#define LZO_E_OK 0 -#define LZO_E_ERROR (-1) -#define LZO_E_OUT_OF_MEMORY (-2) /* not used right now */ -#define LZO_E_NOT_COMPRESSIBLE (-3) /* not used right now */ -#define LZO_E_INPUT_OVERRUN (-4) -#define LZO_E_OUTPUT_OVERRUN (-5) -#define LZO_E_LOOKBEHIND_OVERRUN (-6) -#define LZO_E_EOF_NOT_FOUND (-7) -#define LZO_E_INPUT_NOT_CONSUMED (-8) - - -/* lzo_init() should be the first function you call. - * Check the return code ! - * - * lzo_init() is a macro to allow checking that the library and the - * compiler's view of various types are consistent. - */ -#define lzo_init() __lzo_init2(LZO_VERSION,(int)sizeof(short),(int)sizeof(int),\ - (int)sizeof(long),(int)sizeof(lzo_uint32),(int)sizeof(lzo_uint),\ - (int)lzo_sizeof_dict_t,(int)sizeof(char *),(int)sizeof(lzo_voidp),\ - (int)sizeof(lzo_compress_t)) -LZO_EXTERN(int) __lzo_init2(unsigned,int,int,int,int,int,int,int,int,int); - -/* version functions (useful for shared libraries) */ -LZO_EXTERN(unsigned) lzo_version(void); -LZO_EXTERN(const char *) lzo_version_string(void); -LZO_EXTERN(const char *) lzo_version_date(void); -LZO_EXTERN(const lzo_charp) _lzo_version_string(void); -LZO_EXTERN(const lzo_charp) _lzo_version_date(void); - -/* string functions */ -LZO_EXTERN(int) -lzo_memcmp(const lzo_voidp _s1, const lzo_voidp _s2, lzo_uint _len); -LZO_EXTERN(lzo_voidp) -lzo_memcpy(lzo_voidp _dest, const lzo_voidp _src, lzo_uint _len); -LZO_EXTERN(lzo_voidp) -lzo_memmove(lzo_voidp _dest, const lzo_voidp _src, lzo_uint _len); -LZO_EXTERN(lzo_voidp) -lzo_memset(lzo_voidp _s, int _c, lzo_uint _len); - -/* checksum functions */ -LZO_EXTERN(lzo_uint32) -lzo_adler32(lzo_uint32 _adler, const lzo_byte *_buf, lzo_uint _len); -LZO_EXTERN(lzo_uint32) -lzo_crc32(lzo_uint32 _c, const lzo_byte *_buf, lzo_uint _len); - -/* memory allocation functions */ -LZO_EXTERN(lzo_bytep) lzo_alloc(lzo_uint _nelems, lzo_uint _size); -LZO_EXTERN(lzo_bytep) lzo_malloc(lzo_uint _size); -LZO_EXTERN(void) lzo_free(lzo_voidp _ptr); - -extern lzo_bytep (__LZO_ENTRY *lzo_alloc_hook) (lzo_uint,lzo_uint); -extern void (__LZO_ENTRY *lzo_free_hook) (lzo_voidp); - -/* misc. */ -LZO_EXTERN(lzo_bool) lzo_assert(int _expr); -LZO_EXTERN(int) _lzo_config_check(void); -typedef union { lzo_bytep p; lzo_uint u; } __lzo_pu_u; -typedef union { lzo_bytep p; lzo_uint32 u32; } __lzo_pu32_u; - -/* align a char pointer on a boundary that is a multiple of `size' */ -LZO_EXTERN(unsigned) __lzo_align_gap(const lzo_voidp _ptr, lzo_uint _size); -#define LZO_PTR_ALIGN_UP(_ptr,_size) \ - ((_ptr) + (lzo_uint) __lzo_align_gap((const lzo_voidp)(_ptr),(lzo_uint)(_size))) - -/* deprecated - only for backward compatibility */ -#define LZO_ALIGN(_ptr,_size) LZO_PTR_ALIGN_UP(_ptr,_size) - - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -} // end of namespace MPAL - -} // end of namespace Tony - -#endif /* already included */ - diff --git a/engines/tony/lzo/stubs.cpp b/engines/tony/lzo/stubs.cpp deleted file mode 100644 index 4a27f8cc18..0000000000 --- a/engines/tony/lzo/stubs.cpp +++ /dev/null @@ -1,41 +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 contains temporary stubs for LZO functions -\****************************************************************************/ - -#include "lzo1x.h" - -namespace Tony { - -namespace LZO { - -int lzo1x_decompress( const lzo_byte *src, lzo_uint src_len, lzo_byte *dst, lzo_uint *dst_len, - lzo_voidp wrkmem /* NOT USED */ ) { - return 0; -} - -} // end of namespace LZO - -} // end of namespace Tony diff --git a/engines/tony/module.mk b/engines/tony/module.mk index 578f58090c..ba32a97e56 100644 --- a/engines/tony/module.mk +++ b/engines/tony/module.mk @@ -7,6 +7,7 @@ MODULE_OBJS := \ mpal/expr.o \ mpal/loadmpc.o \ mpal/mpal.o \ + mpal/lzo.o \ mpal/stubs.o # This module can be built as a plugin diff --git a/engines/tony/mpal/lzo.cpp b/engines/tony/mpal/lzo.cpp new file mode 100644 index 0000000000..5f4b2d40f1 --- /dev/null +++ b/engines/tony/mpal/lzo.cpp @@ -0,0 +1,509 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * + */ +/* minilzo.c -- mini subset of the LZO real-time data compression library + + This file is part of the LZO real-time data compression library. + + Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer + All Rights Reserved. + + The LZO library is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + The LZO library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with the LZO library; see the file COPYING. + If not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + Markus F.X.J. Oberhumer + + http://www.oberhumer.com/opensource/lzo/ + */ + +#include "lzo.h" + +namespace Tony { + +namespace MPAL { + +#define pd(a,b) ((uint32) ((a)-(b))) + +#define TEST_IP (ip < ip_end) +#define TEST_OP 1 +#define NEED_IP(x) ((void) 0) +#define NEED_OP(x) ((void) 0) +#define TEST_LB(m_pos) ((void) 0) + +#define M2_MAX_OFFSET 0x0800 + +/** + * Decompresses an LZO compressed resource + */ +int lzo1x_decompress(const byte *in , uint32 in_len, byte *out, uint32 *out_len) { + register byte *op; + register const byte *ip; + register uint32 t = 0; +#if defined(COPY_DICT) + uint32 m_off; + const byte *dict_end; +#else + register const byte *m_pos; +#endif + + const byte * const ip_end = in + in_len; +#if defined(HAVE_ANY_OP) + byte * const op_end = out + *out_len; +#endif +#if defined(LZO1Z) + uint32 last_m_off = 0; +#endif + +#if defined(COPY_DICT) + if (dict) + { + if (dict_len > M4_MAX_OFFSET) + { + dict += dict_len - M4_MAX_OFFSET; + dict_len = M4_MAX_OFFSET; + } + dict_end = dict + dict_len; + } + else + { + dict_len = 0; + dict_end = NULL; + } +#endif + + *out_len = 0; + + op = out; + ip = in; + + if (*ip > 17) + { + t = *ip++ - 17; + if (t < 4) + goto match_next; + assert(t > 0); NEED_OP(t); NEED_IP(t+1); + do *op++ = *ip++; while (--t > 0); + goto first_literal_run; + } + + while (TEST_IP && TEST_OP) + { + t = *ip++; + if (t >= 16) + goto match; + if (t == 0) + { + NEED_IP(1); + while (*ip == 0) + { + t += 255; + ip++; + NEED_IP(1); + } + t += 15 + *ip++; + } + assert(t > 0); NEED_OP(t+3); NEED_IP(t+4); +#if defined(LZO_UNALIGNED_OK_8) && defined(LZO_UNALIGNED_OK_4) + t += 3; + if (t >= 8) do + { + UA_COPY64(op,ip); + op += 8; ip += 8; t -= 8; + } while (t >= 8); + if (t >= 4) + { + UA_COPY32(op,ip); + op += 4; ip += 4; t -= 4; + } + if (t > 0) + { + *op++ = *ip++; + if (t > 1) { *op++ = *ip++; if (t > 2) { *op++ = *ip++; } } + } +#elif defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4) +#if !defined(LZO_UNALIGNED_OK_4) + if (PTR_ALIGNED2_4(op,ip)) + { +#endif + UA_COPY32(op,ip); + op += 4; ip += 4; + if (--t > 0) + { + if (t >= 4) + { + do { + UA_COPY32(op,ip); + op += 4; ip += 4; t -= 4; + } while (t >= 4); + if (t > 0) do *op++ = *ip++; while (--t > 0); + } + else + do *op++ = *ip++; while (--t > 0); + } +#if !defined(LZO_UNALIGNED_OK_4) + } + else +#endif +#endif +#if !defined(LZO_UNALIGNED_OK_4) && !defined(LZO_UNALIGNED_OK_8) + { + *op++ = *ip++; *op++ = *ip++; *op++ = *ip++; + do *op++ = *ip++; while (--t > 0); + } +#endif + +first_literal_run: + + t = *ip++; + if (t >= 16) + goto match; +#if defined(COPY_DICT) +#if defined(LZO1Z) + m_off = (1 + M2_MAX_OFFSET) + (t << 6) + (*ip++ >> 2); + last_m_off = m_off; +#else + m_off = (1 + M2_MAX_OFFSET) + (t >> 2) + (*ip++ << 2); +#endif + NEED_OP(3); + t = 3; COPY_DICT(t,m_off) +#else +#if defined(LZO1Z) + t = (1 + M2_MAX_OFFSET) + (t << 6) + (*ip++ >> 2); + m_pos = op - t; + last_m_off = t; +#else + m_pos = op - (1 + M2_MAX_OFFSET); + m_pos -= t >> 2; + m_pos -= *ip++ << 2; +#endif + TEST_LB(m_pos); NEED_OP(3); + *op++ = *m_pos++; *op++ = *m_pos++; *op++ = *m_pos; +#endif + goto match_done; + + do { +match: + if (t >= 64) + { +#if defined(COPY_DICT) +#if defined(LZO1X) + m_off = 1 + ((t >> 2) & 7) + (*ip++ << 3); + t = (t >> 5) - 1; +#elif defined(LZO1Y) + m_off = 1 + ((t >> 2) & 3) + (*ip++ << 2); + t = (t >> 4) - 3; +#elif defined(LZO1Z) + m_off = t & 0x1f; + if (m_off >= 0x1c) + m_off = last_m_off; + else + { + m_off = 1 + (m_off << 6) + (*ip++ >> 2); + last_m_off = m_off; + } + t = (t >> 5) - 1; +#endif +#else +#if defined(LZO1X) + m_pos = op - 1; + m_pos -= (t >> 2) & 7; + m_pos -= *ip++ << 3; + t = (t >> 5) - 1; +#elif defined(LZO1Y) + m_pos = op - 1; + m_pos -= (t >> 2) & 3; + m_pos -= *ip++ << 2; + t = (t >> 4) - 3; +#elif defined(LZO1Z) + { + uint32 off = t & 0x1f; + m_pos = op; + if (off >= 0x1c) + { + assert(last_m_off > 0); + m_pos -= last_m_off; + } + else + { + off = 1 + (off << 6) + (*ip++ >> 2); + m_pos -= off; + last_m_off = off; + } + } + t = (t >> 5) - 1; +#endif + TEST_LB(m_pos); assert(t > 0); NEED_OP(t+3-1); + goto copy_match; +#endif + } + else if (t >= 32) + { + t &= 31; + if (t == 0) + { + NEED_IP(1); + while (*ip == 0) + { + t += 255; + ip++; + NEED_IP(1); + } + t += 31 + *ip++; + } +#if defined(COPY_DICT) +#if defined(LZO1Z) + m_off = 1 + (ip[0] << 6) + (ip[1] >> 2); + last_m_off = m_off; +#else + m_off = 1 + (ip[0] >> 2) + (ip[1] << 6); +#endif +#else +#if defined(LZO1Z) + { + uint32 off = 1 + (ip[0] << 6) + (ip[1] >> 2); + m_pos = op - off; + last_m_off = off; + } +#elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN) + m_pos = op - 1; + m_pos -= UA_GET16(ip) >> 2; +#else + m_pos = op - 1; + m_pos -= (ip[0] >> 2) + (ip[1] << 6); +#endif +#endif + ip += 2; + } + else if (t >= 16) + { +#if defined(COPY_DICT) + m_off = (t & 8) << 11; +#else + m_pos = op; + m_pos -= (t & 8) << 11; +#endif + t &= 7; + if (t == 0) + { + NEED_IP(1); + while (*ip == 0) + { + t += 255; + ip++; + NEED_IP(1); + } + t += 7 + *ip++; + } +#if defined(COPY_DICT) +#if defined(LZO1Z) + m_off += (ip[0] << 6) + (ip[1] >> 2); +#else + m_off += (ip[0] >> 2) + (ip[1] << 6); +#endif + ip += 2; + if (m_off == 0) + goto eof_found; + m_off += 0x4000; +#if defined(LZO1Z) + last_m_off = m_off; +#endif +#else +#if defined(LZO1Z) + m_pos -= (ip[0] << 6) + (ip[1] >> 2); +#elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN) + m_pos -= UA_GET16(ip) >> 2; +#else + m_pos -= (ip[0] >> 2) + (ip[1] << 6); +#endif + ip += 2; + if (m_pos == op) + goto eof_found; + m_pos -= 0x4000; +#if defined(LZO1Z) + last_m_off = pd((const byte *)op, m_pos); +#endif +#endif + } + else + { +#if defined(COPY_DICT) +#if defined(LZO1Z) + m_off = 1 + (t << 6) + (*ip++ >> 2); + last_m_off = m_off; +#else + m_off = 1 + (t >> 2) + (*ip++ << 2); +#endif + NEED_OP(2); + t = 2; COPY_DICT(t,m_off) +#else +#if defined(LZO1Z) + t = 1 + (t << 6) + (*ip++ >> 2); + m_pos = op - t; + last_m_off = t; +#else + m_pos = op - 1; + m_pos -= t >> 2; + m_pos -= *ip++ << 2; +#endif + TEST_LB(m_pos); NEED_OP(2); + *op++ = *m_pos++; *op++ = *m_pos; +#endif + goto match_done; + } + +#if defined(COPY_DICT) + + NEED_OP(t+3-1); + t += 3-1; COPY_DICT(t,m_off) + +#else + + TEST_LB(m_pos); assert(t > 0); NEED_OP(t+3-1); +#if defined(LZO_UNALIGNED_OK_8) && defined(LZO_UNALIGNED_OK_4) + if (op - m_pos >= 8) + { + t += (3 - 1); + if (t >= 8) do + { + UA_COPY64(op,m_pos); + op += 8; m_pos += 8; t -= 8; + } while (t >= 8); + if (t >= 4) + { + UA_COPY32(op,m_pos); + op += 4; m_pos += 4; t -= 4; + } + if (t > 0) + { + *op++ = m_pos[0]; + if (t > 1) { *op++ = m_pos[1]; if (t > 2) { *op++ = m_pos[2]; } } + } + } + else +#elif defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4) +#if !defined(LZO_UNALIGNED_OK_4) + if (t >= 2 * 4 - (3 - 1) && PTR_ALIGNED2_4(op,m_pos)) + { + assert((op - m_pos) >= 4); +#else + if (t >= 2 * 4 - (3 - 1) && (op - m_pos) >= 4) + { +#endif + UA_COPY32(op,m_pos); + op += 4; m_pos += 4; t -= 4 - (3 - 1); + do { + UA_COPY32(op,m_pos); + op += 4; m_pos += 4; t -= 4; + } while (t >= 4); + if (t > 0) do *op++ = *m_pos++; while (--t > 0); + } + else +#endif + { +copy_match: + *op++ = *m_pos++; *op++ = *m_pos++; + do *op++ = *m_pos++; while (--t > 0); + } + +#endif + +match_done: +#if defined(LZO1Z) + t = ip[-1] & 3; +#else + t = ip[-2] & 3; +#endif + if (t == 0) + break; + +match_next: + assert(t > 0); assert(t < 4); NEED_OP(t); NEED_IP(t+1); +#if 0 + do *op++ = *ip++; while (--t > 0); +#else + *op++ = *ip++; + if (t > 1) { *op++ = *ip++; if (t > 2) { *op++ = *ip++; } } +#endif + t = *ip++; + } while (TEST_IP && TEST_OP); + } + +#if defined(HAVE_TEST_IP) || defined(HAVE_TEST_OP) + *out_len = pd(op, out); + return LZO_E_EOF_NOT_FOUND; +#endif + +eof_found: + assert(t == 1); + *out_len = pd(op, out); + return (ip == ip_end ? LZO_E_OK : + (ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN)); + +#if defined(HAVE_NEED_IP) +input_overrun: + *out_len = pd(op, out); + return LZO_E_INPUT_OVERRUN; +#endif + +#if defined(HAVE_NEED_OP) +output_overrun: + *out_len = pd(op, out); + return LZO_E_OUTPUT_OVERRUN; +#endif + +#if defined(LZO_TEST_OVERRUN_LOOKBEHIND) +lookbehind_overrun: + *out_len = pd(op, out); + return LZO_E_LOOKBEHIND_OVERRUN; +#endif +} + +} // end of namespace MPAL + +} // end of namespace Tony diff --git a/engines/tony/mpal/lzo.h b/engines/tony/mpal/lzo.h new file mode 100644 index 0000000000..1d20c8e96e --- /dev/null +++ b/engines/tony/mpal/lzo.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. + * + * + */ +/* minilzo.c -- mini subset of the LZO real-time data compression library + + This file is part of the LZO real-time data compression library. + + Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer + All Rights Reserved. + + The LZO library is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + The LZO library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with the LZO library; see the file COPYING. + If not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + Markus F.X.J. Oberhumer + + http://www.oberhumer.com/opensource/lzo/ + */ + +#ifndef TONY_MPAL_LZO_H +#define TONY_MPAL_LZO_H + +#include "common/scummsys.h" + +namespace Tony { + +namespace MPAL { + +/* Error codes for the compression/decompression functions. Negative + * values are errors, positive values will be used for special but + * normal events. + */ +#define LZO_E_OK 0 +#define LZO_E_ERROR (-1) +#define LZO_E_OUT_OF_MEMORY (-2) /* [lzo_alloc_func_t failure] */ +#define LZO_E_NOT_COMPRESSIBLE (-3) /* [not used right now] */ +#define LZO_E_INPUT_OVERRUN (-4) +#define LZO_E_OUTPUT_OVERRUN (-5) +#define LZO_E_LOOKBEHIND_OVERRUN (-6) +#define LZO_E_EOF_NOT_FOUND (-7) +#define LZO_E_INPUT_NOT_CONSUMED (-8) +#define LZO_E_NOT_YET_IMPLEMENTED (-9) /* [not used right now] */ +#define LZO_E_INVALID_ARGUMENT (-10) + + +/** + * Decompresses an LZO compressed resource + */ +int lzo1x_decompress(const byte *src, uint32 src_len, byte *dst, uint32 *dst_len); + +} // end of namespace MPAL + +} // end of namespace Tony + +#endif /* already included */ diff --git a/engines/tony/mpal/lzo1x.h b/engines/tony/mpal/lzo1x.h deleted file mode 100644 index 83b547428c..0000000000 --- a/engines/tony/mpal/lzo1x.h +++ /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. - * - * - */ -/* lzo1x.h -- public interface of the LZO1X compression algorithm - - This file is part of the LZO real-time data compression library. - - Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer - - The LZO library is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - The LZO library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with the LZO library; see the file COPYING. - If not, write to the Free Software Foundation, Inc., - 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - Markus F.X.J. Oberhumer - - http://wildsau.idv.uni-linz.ac.at/mfx/lzo.html - */ - - -#ifndef __LZO1X_H -#define __LZO1X_H - -#ifndef __LZOCONF_H -#include "lzoconf.h" -#endif - -namespace Tony { - -namespace MPAL { - -/*********************************************************************** -// -************************************************************************/ - -/* Memory required for the wrkmem parameter. - * When the required size is 0, you can also pass a NULL pointer. - */ - -#define LZO1X_MEM_COMPRESS LZO1X_1_MEM_COMPRESS -#define LZO1X_MEM_DECOMPRESS (0) -#define LZO1X_MEM_OPTIMIZE (0) - - -/* decompression */ -LZO_EXTERN(int) -lzo1x_decompress ( const lzo_byte *src, lzo_uint src_len, - lzo_byte *dst, lzo_uint *dst_len, - lzo_voidp wrkmem /* NOT USED */ ); - -/* safe decompression with overrun testing */ -LZO_EXTERN(int) -lzo1x_decompress_safe ( const lzo_byte *src, lzo_uint src_len, - lzo_byte *dst, lzo_uint *dst_len, - lzo_voidp wrkmem /* NOT USED */ ); - - -/*********************************************************************** -// -************************************************************************/ - -#define LZO1X_1_MEM_COMPRESS ((lzo_uint32) (16384L * lzo_sizeof_dict_t)) - -LZO_EXTERN(int) -lzo1x_1_compress ( const lzo_byte *src, lzo_uint src_len, - lzo_byte *dst, lzo_uint *dst_len, - lzo_voidp wrkmem ); - - -/*********************************************************************** -// special compressor versions -************************************************************************/ - -/* this version needs only 8 kB work memory */ -#define LZO1X_1_11_MEM_COMPRESS ((lzo_uint32) (2048L * lzo_sizeof_dict_t)) - -LZO_EXTERN(int) -lzo1x_1_11_compress ( const lzo_byte *src, lzo_uint src_len, - lzo_byte *dst, lzo_uint *dst_len, - lzo_voidp wrkmem ); - - -/* this version needs 16 kB work memory */ -#define LZO1X_1_12_MEM_COMPRESS ((lzo_uint32) (4096L * lzo_sizeof_dict_t)) - -LZO_EXTERN(int) -lzo1x_1_12_compress ( const lzo_byte *src, lzo_uint src_len, - lzo_byte *dst, lzo_uint *dst_len, - lzo_voidp wrkmem ); - - -/* use this version if you need a little more compression speed */ -#define LZO1X_1_15_MEM_COMPRESS ((lzo_uint32) (32768L * lzo_sizeof_dict_t)) - -LZO_EXTERN(int) -lzo1x_1_15_compress ( const lzo_byte *src, lzo_uint src_len, - lzo_byte *dst, lzo_uint *dst_len, - lzo_voidp wrkmem ); - - -/*********************************************************************** -// better compression ratio at the cost of more memory and time -************************************************************************/ - -#define LZO1X_999_MEM_COMPRESS ((lzo_uint32) (14 * 16384L * sizeof(short))) - -#if !defined(LZO_999_UNSUPPORTED) -LZO_EXTERN(int) -lzo1x_999_compress ( const lzo_byte *src, lzo_uint src_len, - lzo_byte *dst, lzo_uint *dst_len, - lzo_voidp wrkmem ); -#endif - - -/*********************************************************************** -// -************************************************************************/ - -#if !defined(LZO_999_UNSUPPORTED) -LZO_EXTERN(int) -lzo1x_999_compress_dict ( const lzo_byte *in , lzo_uint in_len, - lzo_byte *out, lzo_uint *out_len, - lzo_voidp wrkmem, - const lzo_byte *dict, lzo_uint dict_len ); - -LZO_EXTERN(int) -lzo1x_999_compress_level ( const lzo_byte *in , lzo_uint in_len, - lzo_byte *out, lzo_uint *out_len, - lzo_voidp wrkmem, - const lzo_byte *dict, lzo_uint dict_len, - lzo_progress_callback_t cb, - int compression_level ); -#endif - -LZO_EXTERN(int) -lzo1x_decompress_dict_safe ( const lzo_byte *in, lzo_uint in_len, - lzo_byte *out, lzo_uint *out_len, - lzo_voidp wrkmem /* NOT USED */, - const lzo_byte *dict, lzo_uint dict_len ); - - -/*********************************************************************** -// optimize a compressed data block -************************************************************************/ - -LZO_EXTERN(int) -lzo1x_optimize ( lzo_byte *in , lzo_uint in_len, - lzo_byte *out, lzo_uint *out_len, - lzo_voidp wrkmem ); - - -} // end of namespace MPAL - -} // end of namespace Tony - -#endif /* already included */ diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index f068f0fabf..e07669849e 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -51,18 +51,16 @@ #include "common/file.h" #include "common/savefile.h" #include "common/system.h" +#include "tony/tony.h" +#include "lzo.h" #include "mpal.h" #include "mpaldll.h" #include "stubs.h" -#include "tony/tony.h" -#include "tony/lzo/lzo1x.h" namespace Tony { namespace MPAL { -using namespace Tony::LZO; - /****************************************************************************\ * Copyright \****************************************************************************/ @@ -653,7 +651,7 @@ HGLOBAL resLoad(uint32 dwId) { if (nBytesRead != nSizeComp) return NULL; - lzo1x_decompress(temp, nSizeComp, buf, (lzo_uint*)&nBytesRead, NULL); + lzo1x_decompress(temp, nSizeComp, buf, &nBytesRead); if (nBytesRead != nSizeDecomp) return NULL; @@ -1709,7 +1707,7 @@ bool mpalInit(char * lpszMpcFileName, char * lpszMprFileName, LPLPCUSTOMFUNCTION /* Se il file e' compresso, guarda quanto e' grande e alloca la memoria temporanea per la decompressione */ dwSizeComp = hMpc.readUint32LE(); - if (nBytesRead != 4) + if (hMpc.err()) return false; cmpbuf = (byte *)GlobalAlloc(GMEM_FIXED,dwSizeComp); @@ -1721,7 +1719,7 @@ bool mpalInit(char * lpszMpcFileName, char * lpszMprFileName, LPLPCUSTOMFUNCTION return false; /* Decomprime l'immagine */ - lzo1x_decompress(cmpbuf,dwSizeComp,lpMpcImage,(lzo_uint*)&nBytesRead,NULL); + lzo1x_decompress(cmpbuf, dwSizeComp, lpMpcImage, &nBytesRead); if (nBytesRead != dwSizeDecomp) return false; @@ -1795,7 +1793,7 @@ bool mpalInit(char * lpszMpcFileName, char * lpszMprFileName, LPLPCUSTOMFUNCTION if (nBytesRead != dwSizeComp) return false; - lzo1x_decompress((byte *)cmpbuf,dwSizeComp,(byte *)lpResources, (uint32 *)&nBytesRead, NULL); + lzo1x_decompress((const byte *)cmpbuf, dwSizeComp, (byte *)lpResources, (uint32 *)&nBytesRead); if (nBytesRead != (uint32)nResources*8) return false; diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 2d4385a5e6..04e1a881ec 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -58,7 +58,7 @@ Common::Error TonyEngine::run() { */ Common::ErrorCode TonyEngine::Init() { // Initialise the function list - Common::fill(FuncList, FuncList + sizeof(FuncList), (LPCUSTOMFUNCTION)NULL); + Common::fill(FuncList, FuncList + 300, (LPCUSTOMFUNCTION)NULL); // Initializes MPAL system, passing the custom functions list Common::File f; -- cgit v1.2.3 From a2c4b4ca68aa15a763281ce7092178d78603d161 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 29 Apr 2012 10:16:56 +1000 Subject: TONY: LZO decompression now working correctly --- engines/tony/mpal/lzo.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines') diff --git a/engines/tony/mpal/lzo.cpp b/engines/tony/mpal/lzo.cpp index 5f4b2d40f1..6cd755fc93 100644 --- a/engines/tony/mpal/lzo.cpp +++ b/engines/tony/mpal/lzo.cpp @@ -77,6 +77,7 @@ namespace MPAL { #define TEST_LB(m_pos) ((void) 0) #define M2_MAX_OFFSET 0x0800 +#define LZO1X /** * Decompresses an LZO compressed resource -- cgit v1.2.3 From 40680deaa5f94b1644cf277b8c9a89796a1ff815 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 29 Apr 2012 10:49:14 +1000 Subject: TONY: Removed deprecated lzo/stubs.o from makefile --- engines/tony/module.mk | 1 - engines/tony/tony.cpp | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/tony/module.mk b/engines/tony/module.mk index ba32a97e56..b4d0d7321d 100644 --- a/engines/tony/module.mk +++ b/engines/tony/module.mk @@ -3,7 +3,6 @@ MODULE := engines/tony MODULE_OBJS := \ detection.o \ tony.o \ - lzo/stubs.o \ mpal/expr.o \ mpal/loadmpc.o \ mpal/mpal.o \ diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 04e1a881ec..0708b45497 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -69,6 +69,9 @@ Common::ErrorCode TonyEngine::Init() { if (!mpalInit("ROASTED.MPC", "ROASTED.MPR", FuncList)) return Common::kUnknownError; + // Initialise the update resources + _resUpdate.Init("ROASTED.MPU"); + return Common::kNoError; } -- cgit v1.2.3 From f21bfe1c41148368f30b0602a8e8820fbd543543 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 29 Apr 2012 11:01:40 +1000 Subject: TONY: Added resource update manager --- engines/tony/module.mk | 1 + engines/tony/tony.h | 2 + engines/tony/utils.cpp | 114 +++++++++++++++++++++++++++++++++++++++++++++++++ engines/tony/utils.h | 54 +++++++++++++++++++++++ 4 files changed, 171 insertions(+) create mode 100644 engines/tony/utils.cpp create mode 100644 engines/tony/utils.h (limited to 'engines') diff --git a/engines/tony/module.mk b/engines/tony/module.mk index b4d0d7321d..0ec4563207 100644 --- a/engines/tony/module.mk +++ b/engines/tony/module.mk @@ -3,6 +3,7 @@ MODULE := engines/tony MODULE_OBJS := \ detection.o \ tony.o \ + utils.o \ mpal/expr.o \ mpal/loadmpc.o \ mpal/mpal.o \ diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 804e489d82..9bf5f4cb98 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -31,6 +31,7 @@ #include "engines/engine.h" #include "tony/mpal/mpal.h" +#include "tony/utils.h" /** * This is the namespace of the Tony engine. @@ -67,6 +68,7 @@ protected: public: LPCUSTOMFUNCTION FuncList[300]; Common::RandomSource _randomSource; + RMResUpdate _resUpdate; public: TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc); virtual ~TonyEngine(); diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp new file mode 100644 index 0000000000..1368111a05 --- /dev/null +++ b/engines/tony/utils.cpp @@ -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. + * + */ + +#include "tony/utils.h" +#include "mpal/lzo.h" + +namespace Tony { + +/****************************************************************************\ +* Resource Update +\****************************************************************************/ + +RMResUpdate::RMResUpdate() { + _infos = NULL; +} + +RMResUpdate::~RMResUpdate() { + if (_infos) { + delete[] _infos; + _infos = NULL; + } + + if (_hFile.isOpen()) + _hFile.close(); +} + +void RMResUpdate::Init(const Common::String &fileName) { + // Open the resource update file + if (!_hFile.open(fileName)) + // It doesn't exist, so exit immediately + return; + + uint8 version; + uint32 i; + + version = _hFile.readByte(); + _numUpd = _hFile.readUint32LE(); + + _infos = new ResUpdInfo[_numUpd]; + + // Load the index of the resources in the file + for (i=0; i<_numUpd; ++i) { + ResUpdInfo &info = _infos[i]; + + info.dwRes = _hFile.readUint32LE(); + info.offset = _hFile.readUint32LE(); + info.size = _hFile.readUint32LE(); + info.cmpSize = _hFile.readUint32LE(); + } +} + +const byte *RMResUpdate::QueryResource(uint32 dwRes) { + // If there isn't an update file, return NULL + if (!_hFile.isOpen()) + return NULL; + + uint32 i; + for (i=0; i < _numUpd; ++i) + if (_infos[i].dwRes == dwRes) + // Found the index + break; + + if (i==_numUpd) + // Couldn't find a matching resource, so return NULL + return NULL; + + const ResUpdInfo &info = _infos[i]; + byte *cmpBuf = new byte[info.cmpSize]; + uint32 dwRead; + + // Move to the correct offset and read in the compressed data + _hFile.seek(info.offset); + dwRead = _hFile.read(cmpBuf, info.cmpSize); + + if (info.cmpSize > dwRead) { + // Error occurred reading data, so return NULL + delete[] cmpBuf; + return NULL; + } + + // Allocate space for the output resource + byte *lpDestBuf = new byte[info.size]; + uint32 dwSize; + + // Decompress the data + MPAL::lzo1x_decompress(cmpBuf, info.cmpSize, lpDestBuf, &dwSize); + + // Delete buffer for compressed data + delete [] cmpBuf; + + // Return the resource + return lpDestBuf; +} + +} // End of namespace Tony diff --git a/engines/tony/utils.h b/engines/tony/utils.h new file mode 100644 index 0000000000..b1afcca074 --- /dev/null +++ b/engines/tony/utils.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. + * + */ + +#ifndef TONY_UTILS_H +#define TONY_UTILS_H + +#include "common/scummsys.h" +#include "common/file.h" +#include "common/str.h" + +namespace Tony { + +class RMResUpdate { + struct ResUpdInfo { + uint32 dwRes; + uint32 offset; + uint32 size; + uint32 cmpSize; + }; + + uint32 _numUpd; + ResUpdInfo *_infos; + Common::File _hFile; + +public: + RMResUpdate(); + ~RMResUpdate(); + + void Init(const Common::String &fileName); + const byte *QueryResource(uint32 dwRes); +}; + +} // End of namespace Tony + +#endif /* TONY_H */ -- cgit v1.2.3 From dd89597f880b9119ef0174cf9c61e662c129e266 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 29 Apr 2012 11:23:02 +1000 Subject: TONY: Added voice database initialisation, as well as stubs for music init --- engines/tony/tony.cpp | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++ engines/tony/tony.h | 17 ++++++++++++ 2 files changed, 88 insertions(+) (limited to 'engines') diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 0708b45497..0eacbb5ff4 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -22,6 +22,7 @@ #include "common/scummsys.h" #include "common/algorithm.h" +#include "common/config-manager.h" #include "common/file.h" #include "tony/tony.h" #include "tony/mpal/mpal.h" @@ -36,6 +37,8 @@ TonyEngine::TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc) : Eng } TonyEngine::~TonyEngine() { + // Close the voice database + CloseVoiceDatabase(); } /** @@ -72,6 +75,12 @@ Common::ErrorCode TonyEngine::Init() { // Initialise the update resources _resUpdate.Init("ROASTED.MPU"); + // Initialise the music + InitMusic(); + + if (!OpenVoiceDatabase()) + return Common::kReadingFailed; + return Common::kNoError; } @@ -82,4 +91,66 @@ void TonyEngine::GUIError(const Common::String &msg) { GUIErrorMessage(msg); } +void TonyEngine::InitMusic() { + warning("TODO: TonyEngine::InitMusic"); +} + +void TonyEngine::CloseMusic() { + warning("TODO: TonyEngine::CloseMusic"); +} + +void TonyEngine::PauseSound(bool bPause) { +} + +void TonyEngine::SetMusicVolume(int nChannel, int volume) { +} + +int TonyEngine::GetMusicVolume(int nChannel) { + return 255; +} + +bool TonyEngine::OpenVoiceDatabase() { + char id[4]; + uint32 numfiles; + + // Add the voices folder to the search directory list + const Common::FSNode gameDataDir(ConfMan.get("path")); + SearchMan.addSubDirectoryMatching(gameDataDir, "voices"); + + // Open the voices database + if (!_vdbFP.open("voices.vdb")) + return false; + + _vdbFP.seek(-8, SEEK_END); + numfiles = _vdbFP.readUint32LE(); + _vdbFP.read(id, 4); + + if (id[0] != 'V' || id[1] != 'D' || id[2] != 'B' || id[3] != '1') { + _vdbFP.close(); + return false; + } + + // Read in the index + _vdbFP.seek(-8 - (numfiles * VOICE_HEADER_SIZE), SEEK_END); + + for (uint32 i = 0; i < numfiles; ++i) { + VoiceHeader vh; + vh.offset = _vdbFP.readUint32LE(); + vh.code = _vdbFP.readUint32LE(); + vh.parts = _vdbFP.readUint32LE(); + + _voices.push_back(vh); + } + + return true; +} + +void TonyEngine::CloseVoiceDatabase() { + if (_vdbFP.isOpen()) + _vdbFP.close(); + + if (_voices.size() > 0) + _voices.clear(); +} + } // End of namespace Tony diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 9bf5f4cb98..77b1596112 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -25,6 +25,7 @@ #include "common/scummsys.h" #include "common/system.h" +#include "common/array.h" #include "common/error.h" #include "common/random.h" #include "common/util.h" @@ -58,9 +59,23 @@ enum { struct TonyGameDescription; +struct VoiceHeader { + int offset; + int code; + int parts; +}; +#define VOICE_HEADER_SIZE 12 + class TonyEngine : public Engine { private: Common::ErrorCode Init(); + void InitMusic(); + void CloseMusic(); + void PauseSound(bool bPause); + void SetMusicVolume(int nChannel, int volume); + int GetMusicVolume(int nChannel); + bool OpenVoiceDatabase(); + void CloseVoiceDatabase(); protected: // Engine APIs virtual Common::Error run(); @@ -69,6 +84,8 @@ public: LPCUSTOMFUNCTION FuncList[300]; Common::RandomSource _randomSource; RMResUpdate _resUpdate; + Common::File _vdbFP; + Common::Array _voices; public: TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc); virtual ~TonyEngine(); -- cgit v1.2.3 From 4784367debbaeae656f3bdec5a146b821150a2d0 Mon Sep 17 00:00:00 2001 From: Torbj旦rn Andersson Date: Sun, 29 Apr 2012 08:44:15 +0200 Subject: TONY: Remove __stdcall to make it build on Linux --- engines/tony/mpal/stubs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/tony/mpal/stubs.h b/engines/tony/mpal/stubs.h index d66e12d00d..f41d222b8a 100644 --- a/engines/tony/mpal/stubs.h +++ b/engines/tony/mpal/stubs.h @@ -43,7 +43,7 @@ namespace MPAL { typedef void *HGLOBAL; typedef void *HANDLE; -typedef uint32 (__stdcall *LPTHREAD_START_ROUTINE)(void *lpThreadParameter); +typedef uint32 (*LPTHREAD_START_ROUTINE)(void *lpThreadParameter); /****************************************************************************\ * Defines -- cgit v1.2.3 From 118f5ca0102144b5c282f012def6c96c69052bc1 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 29 Apr 2012 23:19:30 +1000 Subject: TONY: Implemented RMGameBoxes class and all dependent classes --- engines/tony/loc.cpp | 269 ++++++++++++ engines/tony/loc.h | 127 ++++++ engines/tony/module.mk | 3 + engines/tony/mpal/expr.cpp | 4 +- engines/tony/mpal/loadmpc.cpp | 2 + engines/tony/mpal/memory.cpp | 145 +++++++ engines/tony/mpal/memory.h | 82 ++++ engines/tony/mpal/mpal.cpp | 12 +- engines/tony/mpal/mpaldll.h | 1 + engines/tony/mpal/mpalutils.cpp | 106 +++++ engines/tony/mpal/mpalutils.h | 69 ++++ engines/tony/mpal/stubs.cpp | 39 -- engines/tony/mpal/stubs.h | 12 +- engines/tony/tony.cpp | 4 + engines/tony/tony.h | 5 + engines/tony/utils.cpp | 885 +++++++++++++++++++++++++++++++++++++++- engines/tony/utils.h | 247 ++++++++++- 17 files changed, 1952 insertions(+), 60 deletions(-) create mode 100644 engines/tony/loc.cpp create mode 100644 engines/tony/loc.h create mode 100644 engines/tony/mpal/memory.cpp create mode 100644 engines/tony/mpal/memory.h create mode 100644 engines/tony/mpal/mpalutils.cpp create mode 100644 engines/tony/mpal/mpalutils.h (limited to 'engines') diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp new file mode 100644 index 0000000000..a40248f57d --- /dev/null +++ b/engines/tony/loc.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. + * + */ +/************************************************************************** + * 様様様様様様様様様様様様様様様様様 * + * Nayma Software srl * + * e -= We create much MORE than ALL =- * + * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * + * .d" d$$$$$b "b. * + * .z$* d$$$$$$$L ^*$c. * + * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * + * ^*$b 4$$$$$$$$$F .d$*" * + * ^$$. 4$$$$$$$$$F .$P" Module: Loc.CPP.............. * + * *$. '$$$$$$$$$ 4$P 4 * + * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * + * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * + * z$" "" #$F^ "" '$c Desc: Classi di gestione * + * z$$beu .ue=" $ "=e.. .zed$$c dei dati di una loca- * + * "#$e z$*" . `. ^*Nc e$"" zione................ * + * "$$". .r" ^4. .^$$" ..................... * + * ^.@*"6L=\ebu^+C$"*b." * + * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * + * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * + * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * + * * + * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * + * * + **************************************************************************/ + +#include "tony/loc.h" +#include "tony/utils.h" +#include "tony/mpal/lzo.h" +#include "tony/mpal/mpalutils.h" + +namespace Tony { + +using namespace ::Tony::MPAL; + +/****************************************************************************\ +* RMBox Methods +\****************************************************************************/ + +void RMBox::ReadFromStream(RMDataStream &ds) { + uint16 w; + int i; + byte b; + + // Bbox + ds >> left; + ds >> top; + ds >> right; + ds >> bottom; + + // Adiacenza + for (i = 0; i < MAXBOXES; i++) + { + ds >> adj[i]; + } + + // Misc + ds >> numhotspot; + ds >> Zvalue; + ds >> b; + attivo = b; + ds >> b; + bReversed = b; + + // Spazio di espansione + ds+=30; + + // Hotspots + for (i = 0; i < numhotspot; i++) { + ds >> w; hotspot[i].hotx = w; + ds >> w; hotspot[i].hoty = w; + ds >> w; hotspot[i].destination = w; + } +} + +RMDataStream& operator>>(RMDataStream &ds, RMBox &box) { + box.ReadFromStream(ds); + + return ds; +} + +/****************************************************************************\ +* RMBoxLoc Methods +\****************************************************************************/ + +void RMBoxLoc::ReadFromStream(RMDataStream& ds) { + int i; + char buf[2]; + byte ver; + + // ID and versione + ds >> buf[0] >> buf[1] >> ver; + assert(buf[0] == 'B' && buf[1] == 'X'); + assert(ver == 3); + + // Numero dei box + ds >> numbbox; + + // Alloca la memoria per i box + boxes = new RMBox[numbbox]; + + // Li legge da disco + for (i = 0; i < numbbox; i++) + ds >> boxes[i]; +} + + +void RMBoxLoc::RecalcAllAdj(void) { + int i, j; + + for (i = 0; i < numbbox; i++) { + Common::fill(boxes[i].adj, boxes[i].adj + MAXBOXES, 0); + + for (j=0; j < boxes[i].numhotspot; j++) + if (boxes[boxes[i].hotspot[j].destination].attivo) + boxes[i].adj[boxes[i].hotspot[j].destination] = 1; + } +} + +RMDataStream &operator>>(RMDataStream &ds, RMBoxLoc &bl) { + bl.ReadFromStream(ds); + + return ds; +} + +/****************************************************************************\ +* RMGameBoxes methods +\****************************************************************************/ + +void RMGameBoxes::Init(void) { + int i; + RMString fn; + RMDataStream ds; + + // Load boxes from disk + m_nLocBoxes = 130; + for (i=1; i <= m_nLocBoxes; i++) { + RMRes res(10000 + i); + + ds.OpenBuffer(res); + + m_allBoxes[i] = new RMBoxLoc(); + ds >> *m_allBoxes[i]; + + m_allBoxes[i]->RecalcAllAdj(); + + ds.Close(); + } +} + +void RMGameBoxes::Close(void) { +} + +RMBoxLoc *RMGameBoxes::GetBoxes(int nLoc) { + return m_allBoxes[nLoc]; +} + +bool RMGameBoxes::IsInBox(int nLoc, int nBox, RMPoint pt) { + RMBoxLoc *cur = GetBoxes(nLoc); + + if ((pt.x >= cur->boxes[nBox].left) && (pt.x <= cur->boxes[nBox].right) && + (pt.y >= cur->boxes[nBox].top) && (pt.y <= cur->boxes[nBox].bottom)) + return true; + else + return false; +} + +int RMGameBoxes::WhichBox(int nLoc, RMPoint punto) { + int i; + RMBoxLoc *cur = GetBoxes(nLoc); + + if (!cur) return -1; + + for (i=0; inumbbox; i++) + if (cur->boxes[i].attivo) + if ((punto.x >= cur->boxes[i].left) && (punto.x <= cur->boxes[i].right) && + (punto.y >= cur->boxes[i].top) && (punto.y <= cur->boxes[i].bottom)) + return i; + + return -1; +} + +void RMGameBoxes::ChangeBoxStatus(int nLoc, int nBox, int status) { + m_allBoxes[nLoc]->boxes[nBox].attivo=status; + m_allBoxes[nLoc]->RecalcAllAdj(); +} + + +int RMGameBoxes::GetSaveStateSize(void) { + int size; + int i; + + size=4; + + for (i=1; i <= m_nLocBoxes; i++) { + size += 4; + size += m_allBoxes[i]->numbbox; + } + + return size; +} + +void RMGameBoxes::SaveState(byte *state) { + int i,j; + + // Save the number of locations with boxes + WRITE_LE_UINT32(state, m_nLocBoxes); + state += 4; + + // For each location, write out the number of boxes and their status + for (i=1; i <= m_nLocBoxes; i++) { + WRITE_LE_UINT32(state, m_allBoxes[i]->numbbox); + state+=4; + + for (j=0; j < m_allBoxes[i]->numbbox; j++) + *state++ = m_allBoxes[i]->boxes[j].attivo; + } +} + +void RMGameBoxes::LoadState(byte *state) { + int i,j; + int nloc,nbox; + + // Load number of locations with box + nloc = *(int*)state; + state+=4; + + // Controlla che siano meno di quelli correnti + assert(nloc <= m_nLocBoxes); + + // Per ogni locazione, salva il numero di box e il loro stato + for (i = 1; i <= nloc; i++) { + nbox = READ_LE_UINT32(state); + state += 4; + + for (j=0; jnumbbox) + m_allBoxes[i]->boxes[j].attivo = *state; + + state++; + } + + m_allBoxes[i]->RecalcAllAdj(); + } +} + +} // End of namespace Tony diff --git a/engines/tony/loc.h b/engines/tony/loc.h new file mode 100644 index 0000000000..e09a7389d9 --- /dev/null +++ b/engines/tony/loc.h @@ -0,0 +1,127 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ +/************************************************************************** + * 様様様様様様様様様様様様様様様様様 * + * Nayma Software srl * + * e -= We create much MORE than ALL =- * + * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * + * .d" d$$$$$b "b. * + * .z$* d$$$$$$$L ^*$c. * + * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * + * ^*$b 4$$$$$$$$$F .d$*" * + * ^$$. 4$$$$$$$$$F .$P" Module: Loc.CPP.............. * + * *$. '$$$$$$$$$ 4$P 4 * + * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * + * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * + * z$" "" #$F^ "" '$c Desc: Classi di gestione * + * z$$beu .ue=" $ "=e.. .zed$$c dei dati di una loca- * + * "#$e z$*" . `. ^*Nc e$"" zione................ * + * "$$". .r" ^4. .^$$" ..................... * + * ^.@*"6L=\ebu^+C$"*b." * + * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * + * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * + * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * + * * + * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * + * * + **************************************************************************/ + +#ifndef TONY_LOC_H +#define TONY_LOC_H + +#include "common/scummsys.h" +#include "utils.h" + +namespace Tony { + +#define MAXBOXES 50 // Non si puo' cambiare, comanda cosi' il boxed +#define MAXHOTSPOT 20 // Idem + +class RMBox { +public: + struct T_HOTSPOT { + int hotx, hoty; // coordinate HotSpot + int destination; // destinazione HotSpot + }; + +public: + int left,top,right,bottom; // Vertici BoundingBox + int adj[MAXBOXES]; // Lista di adjacenza + int numhotspot; // Numero HotSpot + uint8 Zvalue; // Zvalue per quel BoundingBox + T_HOTSPOT hotspot[MAXHOTSPOT]; // Lista degli HotSpot + + bool attivo; + bool bReversed; + +private: + void ReadFromStream(RMDataStream &ds); + +public: + friend RMDataStream &operator>>(RMDataStream &ds, RMBox &box); +}; + + +class RMBoxLoc { +public: + int numbbox; + RMBox *boxes; + +private: + void ReadFromStream(RMDataStream& ds); + +public: + friend RMDataStream& operator >>(RMDataStream &ds, RMBoxLoc &bl); + void RecalcAllAdj(void); +}; + + +class RMGameBoxes { +protected: + RMBoxLoc *m_allBoxes[200]; + int m_nLocBoxes; + +public: + void Init(void); + void Close(void); + + // Prende i box di una locazione + RMBoxLoc *GetBoxes(int nLoc); + + // Calcola in quale box si trova il punto + int WhichBox(int nLoc, RMPoint pt); + + // Controlla che il punto sia dentro un certo box + bool IsInBox(int nLoc, int nBox, RMPoint pt); + + // Cambia lo stato di un box + void ChangeBoxStatus(int nLoc, int nBox, int status); + + // Salvataggi + int GetSaveStateSize(void); + void SaveState(byte *buf); + void LoadState(byte *buf); +}; + +} // End of namespace Tony + +#endif /* TONY_H */ diff --git a/engines/tony/module.mk b/engines/tony/module.mk index 0ec4563207..6aeb0a1583 100644 --- a/engines/tony/module.mk +++ b/engines/tony/module.mk @@ -2,11 +2,14 @@ MODULE := engines/tony MODULE_OBJS := \ detection.o \ + loc.o \ tony.o \ utils.o \ mpal/expr.o \ mpal/loadmpc.o \ + mpal/memory.o \ mpal/mpal.o \ + mpal/mpalutils.o \ mpal/lzo.o \ mpal/stubs.o diff --git a/engines/tony/mpal/expr.cpp b/engines/tony/mpal/expr.cpp index 0faf91744c..2f0e890af9 100644 --- a/engines/tony/mpal/expr.cpp +++ b/engines/tony/mpal/expr.cpp @@ -48,8 +48,10 @@ **************************************************************************/ #include "mpal.h" +#include "memory.h" #include "mpaldll.h" #include "stubs.h" +#include "tony/tony.h" /* #include "lzo1x.h" @@ -149,7 +151,7 @@ static byte *DuplicateExpression(HGLOBAL h) { num=*(byte *)orig; one=(LPEXPRESSION)(orig+1); - clone=GlobalAlloc(GMEM_FIXED,sizeof(EXPRESSION)*num+1); + clone = (byte *)GlobalAlloc(GMEM_FIXED, sizeof(EXPRESSION)*num+1); two=(LPEXPRESSION)(clone+1); CopyMemory(clone,orig,sizeof(EXPRESSION)*num+1); diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index f9426c8d58..ff94dbae8d 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -52,6 +52,8 @@ */ #include "mpal.h" #include "mpaldll.h" +#include "memory.h" +#include "tony/tony.h" namespace Tony { diff --git a/engines/tony/mpal/memory.cpp b/engines/tony/mpal/memory.cpp new file mode 100644 index 0000000000..604e61ed24 --- /dev/null +++ b/engines/tony/mpal/memory.cpp @@ -0,0 +1,145 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * + */ + +#include "common/textconsole.h" +#include "tony/mpal/memory.h" + +namespace Tony { + +namespace MPAL { + +/****************************************************************************\ +* MemoryItem methods +\****************************************************************************/ + +/** + * Constructor + * @param Data sizee + */ +MemoryItem::MemoryItem(uint32 size) { + _size = size; + _buffer = (size == 0) ? NULL : new byte[size]; +} + +/** + * Destructor + */ +MemoryItem::~MemoryItem() { + delete[] _buffer; +} + +/** + * Returns a pointer to the resource + */ +MemoryItem::operator void *() { + return DataPointer(); +} + +/****************************************************************************\ +* MemoryManager methods +\****************************************************************************/ + +MemoryManager::MemoryManager() { +} + +/** + * Destructor + */ +MemoryManager::~MemoryManager() { + Common::List::iterator i; + for (i = _memoryBlocks.begin(); i != _memoryBlocks.end(); ++i) { + MemoryItem *item = *i; + delete item; + } +} + +/** + * Allocates a new memory block + * @returns Returns a MemoryItem instance for the new block + */ +MemoryItem &MemoryManager::allocate(uint32 size) { + MemoryItem *newItem = new MemoryItem(size); + _memoryBlocks.push_back(newItem); + + return *newItem; +} + +/** + * Allocates a new memory block and returns it's data pointer + * @returns Data pointer to allocated block + */ +HGLOBAL MemoryManager::alloc(uint32 size) { + MemoryItem &newItem = allocate(size); + return (HGLOBAL)newItem.DataPointer(); +} + +/** + * Returns a reference to the MemoryItem for a gien byte pointer + * @param block Byte pointer + */ +MemoryItem &MemoryManager::getItem(HGLOBAL handle) { + Common::List::iterator i; + for (i = _memoryBlocks.begin(); i != _memoryBlocks.end(); ++i) { + MemoryItem *item = *i; + if (item->DataPointer() == handle) + return *item; + } + + error("Could not locate a memory block"); +} + +/** + * Square bracketes operator + * @param block Byte pointer + */ +MemoryItem &MemoryManager::operator[](HGLOBAL handle) { + return getItem(handle); +} + +/** + * Returns a size of a memory block given it's pointer + */ +uint32 MemoryManager::getSize(HGLOBAL handle) { + MemoryItem &item = getItem(handle); + return item.Size(); +} + +/** + * Erases a given item + */ +void MemoryManager::erase(MemoryItem &item) { + delete item; + _memoryBlocks.remove(&item); +} + +/** + * Erases a given item + */ +void MemoryManager::erase(HGLOBAL handle) { + MemoryItem &item = getItem(handle); + erase(item); +} + +} // end of namespace MPAL + +} // end of namespace Tony diff --git a/engines/tony/mpal/memory.h b/engines/tony/mpal/memory.h new file mode 100644 index 0000000000..dde2e8908c --- /dev/null +++ b/engines/tony/mpal/memory.h @@ -0,0 +1,82 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * + */ + +#ifndef TONY_MPAL_MEMORY +#define TONY_MPAL_MEMORY + +#include "common/scummsys.h" +#include "common/list.h" + +namespace Tony { + +namespace MPAL { + +typedef void *HANDLE; +typedef HANDLE HGLOBAL; + +class MemoryItem { +protected: + void *_buffer; + uint32 _size; +public: + MemoryItem(uint32 size); + virtual ~MemoryItem(); + + uint32 Size() { return _size; } + void *DataPointer() { return _buffer; } + bool IsValid() { return _buffer != NULL; } + + // Casting for access to data + operator void *(); +}; + +class MemoryManager { +private: + Common::List _memoryBlocks; +public: + MemoryManager(); + virtual ~MemoryManager(); + + MemoryItem &allocate(uint32 size); + HGLOBAL alloc(uint32 size); + MemoryItem &getItem(HGLOBAL handle); + MemoryItem &operator[](HGLOBAL handle); + void erase(MemoryItem &item); + void erase(HGLOBAL handle); + + uint32 getSize(HANDLE handle); +}; + +// defines +#define GlobalAlloc(flags, size) _vm->_memoryManager.alloc(size) +#define GlobalAllocate(size) _vm->_memoryManager.allocate(size) +#define GlobalFree(handle) _vm->_memoryManager.erase(handle) +#define GlobalLock(handle) (_vm->_memoryManager.getItem(handle).DataPointer()) +#define GlobalUnlock(handle) {} +#define GlobalSize(handle) (_vm->_memoryManager.getItem(handle).Size()) + +} // end of namespace MPAL + +} // end of namespace Tony + +#endif diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index e07669849e..b4b37e7723 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -860,7 +860,7 @@ void PASCAL ScriptThread(LPMPALSCRIPT s) { uint32 dwCurTime; uint32 dwId; static HANDLE cfHandles[MAX_COMMANDS_PER_MOMENT]; - int numHandles; + int numHandles = 0; LPCFCALL p; // warning("PlayScript(): Moments: %u\n",s->nMoments); @@ -1785,7 +1785,7 @@ bool mpalInit(char * lpszMpcFileName, char * lpszMprFileName, LPLPCUSTOMFUNCTION if (lpResources==NULL) return false; - cmpbuf = GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, dwSizeComp); + cmpbuf = (byte *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, dwSizeComp); if (cmpbuf==NULL) return false; @@ -1840,12 +1840,14 @@ bool mpalInit(char * lpszMpcFileName, char * lpszMprFileName, LPLPCUSTOMFUNCTION #define GETARG(type) va_arg(v,type) uint32 mpalQuery(uint16 wQueryType, ...) { - uint32 dwRet; int x,y,z; char * n; + uint32 dwRet = 0; + int x,y,z; + char *n; va_list v; Common::String buf; - mpalError=OK; - va_start(v,wQueryType); + mpalError = OK; + va_start(v, wQueryType); switch (wQueryType) { /* diff --git a/engines/tony/mpal/mpaldll.h b/engines/tony/mpal/mpaldll.h index 8a52f1ed90..ee3820531a 100644 --- a/engines/tony/mpal/mpaldll.h +++ b/engines/tony/mpal/mpaldll.h @@ -51,6 +51,7 @@ #define __MPALDLL_H #include "common/file.h" +#include "memory.h" #include "stubs.h" namespace Tony { diff --git a/engines/tony/mpal/mpalutils.cpp b/engines/tony/mpal/mpalutils.cpp new file mode 100644 index 0000000000..2e3bd07383 --- /dev/null +++ b/engines/tony/mpal/mpalutils.cpp @@ -0,0 +1,106 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * + */ + +#include "tony/mpal/mpalutils.h" +#include "tony/tony.h" + +namespace Tony { + +namespace MPAL { + +/****************************************************************************\ +* RMRes methods +\****************************************************************************/ + +/** + * Constructor + * @param resId MPAL resource to open + */ +RMRes::RMRes(uint32 resID) { + m_h = _vm->_resUpdate.QueryResource(resID); + if (m_h == NULL) + m_h = mpalQueryResource(resID); + if (m_h != NULL) + m_buf = (byte *)GlobalLock(m_h); +} + +/** + * Destructor + */ +RMRes::~RMRes() { + if (m_h != NULL) { + GlobalUnlock(m_h); + GlobalFree(m_h); + } +} + +/** + * Returns a pointer to the resource + */ +const byte *RMRes::DataPointer() { + return m_buf; +} + +/** + * Returns a pointer to the resource + */ +RMRes::operator const byte *() { + return DataPointer(); +} + +/** + * Returns the size of the resource + */ +unsigned int RMRes::Size() { + return GlobalSize(m_h); +} + +/****************************************************************************\ +* RMResRaw methods +\****************************************************************************/ + +RMResRaw::RMResRaw(uint32 resID) : RMRes(resID) { +} + +RMResRaw::~RMResRaw() { +} + +const byte *RMResRaw::DataPointer() { + return m_buf + 8; +} + +RMResRaw::operator const byte *() { + return DataPointer(); +} + +int RMResRaw::Width() { + return READ_LE_UINT16(m_buf + 4); +} + +int RMResRaw::Height() { + return READ_LE_UINT16(m_buf + 6); +} + +} // end of namespace MPAL + +} // end of namespace Tony diff --git a/engines/tony/mpal/mpalutils.h b/engines/tony/mpal/mpalutils.h new file mode 100644 index 0000000000..cb8d4ec97d --- /dev/null +++ b/engines/tony/mpal/mpalutils.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. + * + * + */ + +#ifndef TONY_MPAL_MPALUTILS +#define TONY_MPAL_MPALUTILS + +#include "common/scummsys.h" +#include "memory.h" +#include "stubs.h" + +namespace Tony { + +namespace MPAL { + +class RMRes { +protected: + HGLOBAL m_h; + byte *m_buf; + +public: + RMRes(uint32 resID); + virtual ~RMRes(); + + // Attributes + unsigned int Size(); + const byte *DataPointer(); + bool IsValid() { return m_h != NULL; } + + // Casting for access to data + operator const byte*(); +}; + +class RMResRaw : public RMRes { +public: + RMResRaw(uint32 resID); + virtual ~RMResRaw(); + + const byte *DataPointer(); + operator const byte*(); + + int Width(); + int Height(); +}; + +} // end of namespace MPAL + +} // end of namespace Tony + +#endif diff --git a/engines/tony/mpal/stubs.cpp b/engines/tony/mpal/stubs.cpp index c25dd2ab43..054ed55c68 100644 --- a/engines/tony/mpal/stubs.cpp +++ b/engines/tony/mpal/stubs.cpp @@ -36,45 +36,6 @@ namespace Tony { namespace MPAL { -/** - * Allocates a memory block - */ -byte *GlobalAlloc(uint16 flags, int size) { - byte *result = (byte *)malloc(size); - - if (flags & GMEM_ZEROINIT) - Common::fill(result, result + size, 0); - - return result; -} - -/** - * Lock a global handle - * @param h Global handle - * @remarks Since HGLOBALs are directly representing the pointers anyway, - * simply return it - */ -void *GlobalLock(HGLOBAL h) { - return h; -} - -/** - * Unlock a global handle - * @param h Global handle - * @remarks Since HGLOBALs are directly representing the pointers anyway, - * the unlock method doesn't need to do anything - */ -void GlobalUnlock(HGLOBAL h) { -} - -/** - * Free a globally allocated memory block - * @param h Global handle - */ -void GlobalFree(HGLOBAL h) { - free(h); -} - /** * Display a message * @param msg Message to display diff --git a/engines/tony/mpal/stubs.h b/engines/tony/mpal/stubs.h index f41d222b8a..be856790bc 100644 --- a/engines/tony/mpal/stubs.h +++ b/engines/tony/mpal/stubs.h @@ -31,6 +31,7 @@ #include "common/scummsys.h" #include "common/algorithm.h" +#include "tony/mpal/memory.h" namespace Tony { @@ -40,9 +41,6 @@ namespace MPAL { * Types \****************************************************************************/ -typedef void *HGLOBAL; -typedef void *HANDLE; - typedef uint32 (*LPTHREAD_START_ROUTINE)(void *lpThreadParameter); /****************************************************************************\ @@ -75,14 +73,6 @@ Out CopyMemory(Out dst, In first, int size) { * Methods \****************************************************************************/ -extern byte *GlobalAlloc(uint16 flags, int size); - -extern void *GlobalLock(HGLOBAL h); - -extern void GlobalUnlock(HGLOBAL h); - -extern void GlobalFree(HGLOBAL h); - extern void MessageBox(const Common::String &msg); extern uint32 timeGetTime(); diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 0eacbb5ff4..d5a5e467df 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -78,9 +78,13 @@ Common::ErrorCode TonyEngine::Init() { // Initialise the music InitMusic(); + // Initialise the voices database if (!OpenVoiceDatabase()) return Common::kReadingFailed; + // Initialise the boxes + _theBoxes.Init(); + return Common::kNoError; } diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 77b1596112..384b7a1f4c 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -32,6 +32,8 @@ #include "engines/engine.h" #include "tony/mpal/mpal.h" +#include "tony/mpal/memory.h" +#include "tony/loc.h" #include "tony/utils.h" /** @@ -83,9 +85,12 @@ protected: public: LPCUSTOMFUNCTION FuncList[300]; Common::RandomSource _randomSource; + MPAL::MemoryManager _memoryManager; RMResUpdate _resUpdate; Common::File _vdbFP; Common::Array _voices; + // Bounding box list manager + RMGameBoxes _theBoxes; public: TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc); virtual ~TonyEngine(); diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index 1368111a05..76d168e27a 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -19,12 +19,889 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ +/************************************************************************** + * 様様様様様様様様様様様様様様様様様 * + * Nayma Software srl * + * e -= We create much MORE than ALL =- * + * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * + * .d" d$$$$$b "b. * + * .z$* d$$$$$$$L ^*$c. * + * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * + * ^*$b 4$$$$$$$$$F .d$*" * + * ^$$. 4$$$$$$$$$F .$P" Module: Loc.CPP.............. * + * *$. '$$$$$$$$$ 4$P 4 * + * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * + * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * + * z$" "" #$F^ "" '$c Desc: Classi di gestione * + * z$$beu .ue=" $ "=e.. .zed$$c dei dati di una loca- * + * "#$e z$*" . `. ^*Nc e$"" zione................ * + * "$$". .r" ^4. .^$$" ..................... * + * ^.@*"6L=\ebu^+C$"*b." * + * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * + * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * + * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * + * * + * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * + * * + **************************************************************************/ #include "tony/utils.h" -#include "mpal/lzo.h" +#include "tony/tony.h" +#include "tony/mpal/lzo.h" namespace Tony { +/****************************************************************************\ +* RMString methods +\****************************************************************************/ + +/** + * Constructor + */ +RMString::RMString() { + m_string=NULL; + m_length=0; + m_realLength=0; +} + +/** + * Destructor + */ +RMString::~RMString() { + if (m_string != NULL) + delete[] m_string; +} + +/** + * Copy constructor + */ +RMString::RMString(const RMString &str) { + // Richiama l'overload su '=' per copiare + m_string = NULL; + m_length = 0; + m_realLength = 0; + *this = str; +} + +/** + * Constructor from a char * + */ +RMString::RMString(const char* str) { + // Use the overloaded '=' when copying + m_string = NULL; + m_length = 0; + m_realLength = 0; + *this = str; +} + +/** + * Constructor with a single passed character + */ +RMString::RMString(const int ch) { + // Use the overloaded '=' when copying + m_string = NULL; + m_length = 0; + m_realLength = 0; + *this = ch; +} + +/** + * Returns the length of the string + * @returns Length + */ +int RMString::Length() { + return m_length; +} + +/** + * Gets the character at the given index + * @param nIndex Position of the character to return + * @returns Character + */ +char RMString::GetAt(int nIndex) { + assert(nIndex < m_length); + return m_string[nIndex]; +} + +/** + * Sets the character at the given index + * @param nIndex Position of the character to change + * @param c Character + */ +void RMString::SetAt(int nIndex, char c) { + assert(nIndex < m_length); + m_string[nIndex] = c; +} + +/** + * Overloaded square brackets operator for accessing characters within the string + * @param nIndex Position of the charactre to reference + * @params Reference to the character + */ +char &RMString::operator[](int nIndex) { + assert(nIndex < m_length); + return m_string[nIndex]; +} + +/** + * Copies a string + * @param str String to copy + * @returns Refrence to our string + */ +const RMString &RMString::operator=(const RMString &str) { + // Set the new length + m_length = str.m_length; + + // If the source is empty, then destroy the current string buffer + if (m_length == 0) { + if (m_realLength > 0) { + delete[] m_string; + m_string = NULL; + m_realLength = 0; + } + } else { + // Resize if necessary + Resize(m_length + 1); + + // Copy the string + Common::copy(str.m_string, str.m_string + m_length + 1, m_string); + } + + return *this; +} + +/** + * Copies a char * string + * @param str String to copy + * @returns Refrence to our string + */ +const RMString& RMString::operator=(const char* str) { + // If the source is empty, then destroy the current string buffer + if (str == NULL) { + if (m_realLength > 0) { + delete[] m_string; + m_string = NULL; + m_realLength = m_length = 0; + } + } else { + // Calculate the new length + m_length = strlen(str); + + // Resize if necessary + Resize(m_length + 1); + + // Copy the string + Common::copy(str, str + m_length + 1, m_string); + } + + return *this; +} + +/** + * Forms a string from a passed character + * @param ch Character to copy + * @returns Refrence to our string + */ +const RMString& RMString::operator=(const int ch) { + if (ch=='\0') { + // Destroy the current string + if (m_realLength > 0) { + delete [] m_string; + m_string=NULL; + m_length=m_realLength=0; + } + } else { + // Resize if necessary + Resize(2); + + m_string[0] = ch; + m_string[1] = '\0'; + m_length = 1; + } + + return *this; +} + +/** + * Concatenate a string into the current one + * @param str String to concatenate + * @param size Length of the string + */ +void RMString::Connect(const char *str, int size) { + int nlen; + + if (size > 0) { + // Calculate the new lenght + nlen=m_length+size; + + // Resize + Resize(nlen + 1, true); + + // Linkage with '\0' + Common::copy(str, str + size + 1, m_string + m_length); + + // Save the new length + m_length = nlen; + } +} + +/** + * Concatenate a string + * @param str String to concatenate + * @returns Refrence to our string + */ +const RMString &RMString::operator+=(RMString &str) { + Connect(str,str.Length()); + return *this; +} + +/** + * Concatenate a string + * @param str String to concatenate + * @returns Refrence to our string + */ +const RMString &RMString::operator+=(const char *str) { + Connect(str,strlen(str)); + return *this; +} + +/** + * Concatenate a character + * @param ch Character to concatenate + * @returns Refrence to our string + */ +const RMString &RMString::operator+=(const int ch) { + char str[2]; + + // Create a simple string buffer to hold the single character + str[0] = ch; + str[1] = '\0'; + + Connect(str, 1); + return *this; +} + +/** + * Casts a string as char * + * @returns char * reference to string + */ +RMString::operator char*() const { + return m_string; +} + +/** + * Resize a string as necessary + * @param size New size necessary (in bytes) + * @param bMaintain If TRUE we must keep the original string, + if FALSE we can destroy. + */ +void RMString::Resize(int size, bool bMantain) { + if (m_realLength == 0) { + m_string = new char[size]; + m_realLength = size; + } else if (size > m_realLength) { + if (bMantain) { + char* app; + + app = new char[size]; + Common::copy(m_string, m_string + m_length + 1, app); + delete[] m_string; + m_string = app; + } else { + delete[] m_string; + m_string = new char[size]; + } + } +} + +/** + * Compacts the string to occupy less memory if possible. + */ +void RMString::Compact(void) { + if (m_realLength + 1 > m_length) { + char *app; + + app = new char[m_length + 1]; + Common::copy(m_string, m_string + m_length + 1, app); + + delete[] m_string; + m_string = app; + } +} + +/** + * Operator to concatenate two strings + */ +RMString operator+(const RMString &str1, const RMString &str2) { + RMString ret(str1); + + return (ret += str2); +} + +/** + * Operator to concatenate a character to a string + */ +RMString operator+(RMString &str, const int ch) { + RMString ret(str); + + return (ret += ch); +} + +RMString operator+(const int ch, RMString &str) { + RMString ret(ch); + + return (ret += str); +} + +/** + * Operator to concatenate a char * string to an RMString + */ +RMString operator+(RMString &str, const char *s) { + RMString ret(str); + + return (ret += s); +} + +RMString operator+(const char *s, RMString &str) { + RMString ret(s); + + return (ret+=str); +} + +/** + * Extracts a string from a data stream + * @param df data stream + * @param var String + */ +RMDataStream &operator>>(RMDataStream &df, RMString &var) { + uint8 len; + int i; + + df >> len; + var.Resize(len + 1); + var.m_length=len+1; + + for (i = 0; i < len; i++) + df >> var[i]; + + var[i] = '\0'; + var.m_length = len; + + return df; +} + +/** + * Formats a string + */ +void RMString::Format(char* str, ...) { + warning("TODO: Refactor RMString::Format if needed"); + /* + static char buf[2048]; + va_list argList; + + va_start(argList,str); + wvsprintf(buf,str,argList); + va_end(argList); + *this = buf; +*/ +} + +/****************************************************************************\ +* RMDataStream methods +\****************************************************************************/ + +/** + * Constructor + */ +RMDataStream::RMDataStream() { + m_length = 0; + m_pos = 0; + m_bError = false; +} + +/** + * Destructor + */ +RMDataStream::~RMDataStream() { + Close(); +} + +/** + * Close a stream + */ +void RMDataStream::Close(void) { + m_length = 0; + m_pos = 0; +} + +/** + * Takes the address of the buffer from which will be read the data. + * @param lpBuf Data buffer + * @param size Size of the buffer + * @remarks If the length of the buffer is not known, and cannot be + * specified, then EOF() and Seek() to end won't work. + */ +void RMDataStream::OpenBuffer(const byte *lpBuf, int size) { + m_length = size; + m_buf = lpBuf; + m_bError = false; + m_pos = 0; +} + +/** + * Returns the length of the stream + * @returns Stream length + */ +int RMDataStream::Length() { + return m_length; +} + +/** + * Determines if the end of the stream has been reached + * @returns TRUE if end of stream reached, FALSE if not + */ +bool RMDataStream::IsEOF() { + return (m_pos >= m_length); +} + +/** + * Extracts data from the stream + * @param df Stream + * @param var Variable of a supported type + * @returns Value read from the stream + */ +RMDataStream &operator>>(RMDataStream &df, char &var) { + df.Read(&var, 1); + return df; +} + +/** + * Extracts data from the stream + * @param df Stream + * @param var Variable of a supported type + * @returns Value read from the stream + */ +RMDataStream &operator>>(RMDataStream &df, uint8 &var) { + df.Read(&var, 1); + return df; +} + +/** + * Extracts data from the stream + * @param df Stream + * @param var Variable of a supported type + * @returns Value read from the stream + */ +RMDataStream &operator>>(RMDataStream &df, uint16 &var) { + uint16 v; + df.Read(&v, 2); + + var = FROM_LE_16(v); + return df; +} + +/** + * Extracts data from the stream + * @param df Stream + * @param var Variable of a supported type + * @returns Value read from the stream + */ +RMDataStream &operator>>(RMDataStream &df, int16 &var) { + uint16 v; + df.Read(&v, 2); + + var = (int16)FROM_LE_16(v); + return df; +} + +/** + * Extracts data from the stream + * @param df Stream + * @param var Variable of a supported type + * @returns Value read from the stream + */ +RMDataStream &operator>>(RMDataStream &df, int &var) { + uint32 v; + df.Read(&v, 4); + + var = (int)FROM_LE_32(v); + return df; +} + +/** + * Extracts data from the stream + * @param df Stream + * @param var Variable of a supported type + * @returns Value read from the stream + */ +RMDataStream &operator>>(RMDataStream &df, uint32 &var) { + uint32 v; + df.Read(&v, 4); + + var = FROM_LE_32(v); + return df; +} + +/** + * Reads a series of data from the stream in a buffer + * @param lpBuf Data buffer + * @param size Size of the buffer + * @returns TRUE if we have reached the end, FALSE if not + */ +bool RMDataStream::Read(void *lpBuf, int size) { + byte *dest = (byte *)lpBuf; + + if ((m_pos + size) > m_length) { + Common::copy(m_buf + m_pos, m_buf + m_pos + (m_length - m_pos), dest); + + return true; + } else { + Common::copy(m_buf + m_pos, m_buf + m_pos + size, dest); + + m_pos += size; + return false; + } +} + +/** + * Skips a number of bytes in the stream + * @param nBytres Number of bytes to skip + * @returns The stream + */ +RMDataStream &RMDataStream::operator+=(int nBytes) { + m_pos+=nBytes; + return *this; +} + +/** + * Seeks to a position within the stream + * @param nBytes Number of bytes from specified origin + * @param origin Origin to do offset from + * @returns The absolute current position in bytes + */ +int RMDataStream::Seek(int nBytes, RMDSPos origin) { + switch (origin) { + case CUR: + break; + + case START: + m_pos=0; + break; + + case END: + if (m_length == SIZENOTKNOWN) + return m_pos; + m_pos=m_length; + break; + } + + m_pos+=nBytes; + return m_pos; +} + +/** + * Returns the current position of the stream + * @returns The current position + */ +int RMDataStream::Pos() { + return m_pos; +} + +/** + * Check if an error occurred during reading the stream + * @returns TRUE if there was an error, false otherwise + */ +bool RMDataStream::IsError() { + return m_bError; +} + +/** + * Sets an error code for the stream + * @param code Error code + */ +void RMDataStream::SetError(int code) { + m_bError = true; + m_ecode = code; +} + +/** + * Returns the error code for the stream + * @returns Error code + */ +int RMDataStream::GetError() { + return m_ecode; +} + +/****************************************************************************\ +* RMPoint methods +\****************************************************************************/ + +/** + * Constructor + */ +RMPoint::RMPoint() { + x = y = 0; +} + +/** + * Copy constructor + */ +RMPoint::RMPoint(const RMPoint &p) { + x=p.x; + y=p.y; +} + +/** + * Constructor with integer parameters + */ +RMPoint::RMPoint(int x1, int y1) { + x = x1; + y = y1; +} + +/** + * Copy operator + */ +RMPoint &RMPoint::operator=(RMPoint p) { + x = p.x; + y = p.y; + + return *this; +} + +/** + * Offsets the point by another point + */ +void RMPoint::Offset(RMPoint p) { + x += p.x; + y += p.y; +} + +/** + * Offsets the point by a specified offset + */ +void RMPoint::Offset(int xOff, int yOff) { + x += xOff; + y += yOff; +} + +/** + * Sums together two points + */ +RMPoint operator+(RMPoint p1, RMPoint p2) { + RMPoint p(p1); + + return (p += p2); +} + +/** + * Subtracts two points + */ +RMPoint operator-(RMPoint p1, RMPoint p2) { + RMPoint p(p1); + + return (p -= p2); +} + +/** + * Sum (offset) of a point + */ +RMPoint &RMPoint::operator+=(RMPoint p) { + Offset(p); + return *this; +} + +/** + * Subtract (offset) of a point + */ +RMPoint& RMPoint::operator-=(RMPoint p) { + Offset(-p); + return *this; +} + +/** + * Inverts a point + */ +RMPoint RMPoint::operator-() { + RMPoint p; + + p.x = -x; + p.y = -y; + + return p; +} + +/** + * Equality operator + */ +bool RMPoint::operator==(RMPoint p) { + return ((x == p.x) && (y == p.y)); +} + +/** + * Not equal operator + */ +bool RMPoint::operator!=(RMPoint p) { + return ((x != p.x) || (y != p.y)); +} + +/** + * Reads a point from a stream + */ +RMDataStream &operator>>(RMDataStream &ds, RMPoint &p) { + ds >> p.x >> p.y; + return ds; +} + +/****************************************************************************\ +* RMRect methods +\****************************************************************************/ + +RMRect::RMRect() { + SetEmpty(); +} + +void RMRect::SetEmpty(void) { + x1 = y1 = x2 = y2 = 0; +} + +RMRect::RMRect(RMPoint p1, RMPoint p2) { + SetRect(p1, p2); +} + +RMRect::RMRect(int X1, int Y1, int X2, int Y2) { + SetRect(X1, Y1, X2, Y2); +} + +RMRect::RMRect(const RMRect &rc) { + CopyRect(rc); +} + +void RMRect::SetRect(RMPoint p1, RMPoint p2) { + x1 = p1.x; + y1 = p1.y; + x2 = p2.x; + y2 = p2.y; +} + +void RMRect::SetRect(int X1, int Y1, int X2, int Y2) { + x1 = X1; + y1 = Y1; + x2 = X2; + y2 = Y2; +} + +void RMRect::SetRect(const RMRect &rc) { + CopyRect(rc); +} + +void RMRect::CopyRect(const RMRect &rc) { + x1 = rc.x1; + y1 = rc.y1; + x2 = rc.x2; + y2 = rc.y2; +} + +RMPoint &RMRect::TopLeft() { + // FIXME: This seems very bad + return *((RMPoint *)this); +} + +RMPoint& RMRect::BottomRight() { + // FIXME: This seems very bad + return *((RMPoint*)this + 1); +} + +RMPoint RMRect::Center() { + return RMPoint((x2 - x1) / 2,(y2 - y1) / 2); +} + +int RMRect::Width() { + return x2 - x1; +} + +int RMRect::Height() { + return y2 - y1; +} + +int RMRect::Size() { + return Width() * Height(); +} + +bool RMRect::IsEmpty() { + return (x1 == 0 && y1 == 0 && x2 == 0 && y2 == 0); +} + +const RMRect& RMRect::operator=(const RMRect &rc) { + CopyRect(rc); + return *this; +} + +void RMRect::Offset(int xOff, int yOff) { + x1 += xOff; + y1 += yOff; + x2 += xOff; + y2 += yOff; +} + +void RMRect::Offset(RMPoint p) { + x1 += p.x; + y1 += p.y; + x2 += p.x; + y2 += p.y; +} + +const RMRect &RMRect::operator+=(RMPoint p) { + Offset(p); + return *this; +} + +const RMRect &RMRect::operator-=(RMPoint p) { + Offset(-p); + return *this; +} + +RMRect operator+(const RMRect &rc, RMPoint p) { + RMRect r(rc); + return (r += p); +} + +RMRect operator-(const RMRect& rc, RMPoint p) { + RMRect r(rc); + + return (r -= p); +} + +RMRect operator+(RMPoint p, const RMRect& rc) { + RMRect r(rc); + + return (r+=p); +} + +RMRect operator-(RMPoint p, const RMRect& rc) { + RMRect r(rc); + + return (r+=p); +} + +bool RMRect::operator==(const RMRect& rc) { + return ((x1 == rc.x1) && (y1 == rc.y1) && (x2 == rc.x2) && (y2 == rc.y2)); +} + +bool RMRect::operator!=(const RMRect& rc) { + return ((x1 != rc.x1) || (y1 != rc.y1) || (x2 != rc.x2) || (y2 != rc.y2)); +} + +void RMRect::NormalizeRect(void) { + SetRect(MIN(x1,x2), MIN(y1,y2), MAX(x1,x2), MAX(y1,y2)); +} + +RMDataStream &operator>>(RMDataStream &ds, RMRect &rc) { + ds >> rc.x1 >> rc.y1 >> rc.x2 >> rc.y2; + return ds; +} + + /****************************************************************************\ * Resource Update \****************************************************************************/ @@ -68,7 +945,7 @@ void RMResUpdate::Init(const Common::String &fileName) { } } -const byte *RMResUpdate::QueryResource(uint32 dwRes) { +HGLOBAL RMResUpdate::QueryResource(uint32 dwRes) { // If there isn't an update file, return NULL if (!_hFile.isOpen()) return NULL; @@ -98,7 +975,8 @@ const byte *RMResUpdate::QueryResource(uint32 dwRes) { } // Allocate space for the output resource - byte *lpDestBuf = new byte[info.size]; + HGLOBAL destBuf = GlobalAllocate(info.size); + byte *lpDestBuf = (byte *)GlobalLock(destBuf); uint32 dwSize; // Decompress the data @@ -108,6 +986,7 @@ const byte *RMResUpdate::QueryResource(uint32 dwRes) { delete [] cmpBuf; // Return the resource + GlobalUnlock(destBuf); return lpDestBuf; } diff --git a/engines/tony/utils.h b/engines/tony/utils.h index b1afcca074..bec42b343b 100644 --- a/engines/tony/utils.h +++ b/engines/tony/utils.h @@ -19,16 +19,261 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ +/************************************************************************** + * 様様様様様様様様様様様様様様様様様 * + * Nayma Software srl * + * e -= We create much MORE than ALL =- * + * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * + * .d" d$$$$$b "b. * + * .z$* d$$$$$$$L ^*$c. * + * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * + * ^*$b 4$$$$$$$$$F .d$*" * + * ^$$. 4$$$$$$$$$F .$P" Module: Loc.CPP.............. * + * *$. '$$$$$$$$$ 4$P 4 * + * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * + * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * + * z$" "" #$F^ "" '$c Desc: Classi di gestione * + * z$$beu .ue=" $ "=e.. .zed$$c dei dati di una loca- * + * "#$e z$*" . `. ^*Nc e$"" zione................ * + * "$$". .r" ^4. .^$$" ..................... * + * ^.@*"6L=\ebu^+C$"*b." * + * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * + * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * + * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * + * * + * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * + * * + **************************************************************************/ #ifndef TONY_UTILS_H #define TONY_UTILS_H #include "common/scummsys.h" #include "common/file.h" +#include "common/rect.h" #include "common/str.h" +#include "tony/mpal/memory.h" namespace Tony { +using namespace ::Tony::MPAL; + +/** + * Data stream for reading data + */ +class RMDataStream { +protected: + const byte *m_buf; + int m_length; + int m_pos; + bool m_bError; + int m_ecode; + +public: + enum RMDSPos { + CUR, + START, + END + }; + +private: + enum { + SIZENOTKNOWN = 0x7FFFFFFF + }; + +public: + // Constructor and destructor + RMDataStream(); + virtual ~RMDataStream(); + + // Loading buffer + void OpenBuffer(const byte *buf, int size = SIZENOTKNOWN); + void Close(void); + + // Attributi + int Length(); + virtual int Pos(); + + // EOF + virtual bool IsEOF(); + + // Read methods + friend RMDataStream &operator>>(RMDataStream &df, char &var); + friend RMDataStream &operator>>(RMDataStream &df, byte &var); + friend RMDataStream &operator>>(RMDataStream &df, uint16 &var); + friend RMDataStream &operator>>(RMDataStream &df, int16 &var); + friend RMDataStream &operator>>(RMDataStream &df, int &var); + friend RMDataStream &operator>>(RMDataStream &df, uint32 &var); + + // Lettura generica + virtual bool Read(void *buf, int size); + + // Skipping & Seeking + virtual RMDataStream &operator+=(int nBytes); + virtual int Seek(int nBytes, RMDSPos origin = CUR); + + // Gestione errori + void SetError(int ecode); + int GetError(); + bool IsError(); +}; + +/** + * String class + */ +class RMString { +private: + char *m_string; + int m_length; + int m_realLength; + +public: + RMString(); + ~RMString(); + + // Assignment constructors + RMString(const RMString &str); + RMString(const char *str); + RMString(const int ch); + + // Metodi generici + int Length(); + void Compact(); + + // Access characters within string + char GetAt(int nIndex); + void SetAt(int nIndex, char c); + char& operator[](int nIndex); + + // String cast + operator char*() const; + + // String assignments + const RMString &operator=(const RMString &str); + const RMString &operator=(const char *str); + const RMString &operator=(const int ch); + + // String concatenation + const RMString &operator+=(RMString &str); + const RMString &operator+=(const char *str); + const RMString &operator+=(const int ch); + + // Concatentation of string or character + friend RMString operator+(const RMString &str1, const RMString &str2); + + friend RMString operator+(RMString& str, const int ch); + friend RMString operator+(const int ch, RMString &str); + + friend RMString operator+(RMString &str, const char *s); + friend RMString operator+(const char *s, RMString &str); + + // Estrazione da data stream + friend RMDataStream& operator>>(RMDataStream& df, RMString &var); + + // Formattazione di stringa + void Format(char *str, ...); + +private: + void Resize(int size, bool bMantain = false); + void Connect(const char* str, int size); +}; + +/** + * Point class + */ +class RMPoint { +public: + int x, y; + +public: + // Constructor + RMPoint(); + RMPoint(const RMPoint &p); + RMPoint(int x1, int y1); + + // Copia + RMPoint& operator=(RMPoint p); + + // Set + void Set(int x1, int y1) { x=x1; y=y1; } + + // Offset + void Offset(int xOff, int yOff); + void Offset(RMPoint p); + friend RMPoint operator+(RMPoint p1, RMPoint p2); + friend RMPoint operator-(RMPoint p1, RMPoint p2); + RMPoint &operator+=(RMPoint p); + RMPoint &operator-=(RMPoint p); + RMPoint operator-(); + + // Confronti + bool operator==(RMPoint p); + bool operator!=(RMPoint p); + + // Casting a POINT + operator Common::Point() const; + + // Extraction from data streams + friend RMDataStream& operator>>(RMDataStream &ds, RMPoint &p); +}; + +class RMRect { +public: + int x1,y1; + int x2,y2; + +public: + RMRect(); + RMRect(int x1, int y1, int x2, int y2); + RMRect(RMPoint p1, RMPoint p2); + RMRect(const RMRect &rc); + + // Attributes + RMPoint &TopLeft(); + RMPoint &BottomRight(); + RMPoint Center(); + int Width(); + int Height(); + bool IsEmpty(); + int Size(); + + // Set + void SetRect(int x1, int y1, int x2, int y2); + void SetRect(RMPoint p1, RMPoint p2); + void SetEmpty(void); + + // Copiers + void SetRect(const RMRect &rc); + void CopyRect(const RMRect &rc); + const RMRect &operator=(const RMRect &rc); + + // Offset + void Offset(int xOff, int yOff); + void Offset(RMPoint p); + friend RMRect operator+(const RMRect &rc, RMPoint p); + friend RMRect operator-(const RMRect &rc, RMPoint p); + friend RMRect operator+(RMPoint p, const RMRect &rc); + friend RMRect operator-(RMPoint p, const RMRect &rc); + const RMRect &operator+=(RMPoint p); + const RMRect &operator-=(RMPoint p); + + // Comparison + bool operator==(const RMRect &rc); + bool operator!=(const RMRect &rc); + + // Normalise + void NormalizeRect(); + + // Point in rect + bool PtInRect(RMPoint pt) { return (pt.x>=x1 && pt.x<=x2 && pt.y>=y1 && pt.y<=y2); } + + // Extract from data stream + friend RMDataStream &operator>>(RMDataStream& ds, RMRect &rc); +}; + +/** + * Resource update manager + */ class RMResUpdate { struct ResUpdInfo { uint32 dwRes; @@ -46,7 +291,7 @@ public: ~RMResUpdate(); void Init(const Common::String &fileName); - const byte *QueryResource(uint32 dwRes); + HGLOBAL QueryResource(uint32 dwRes); }; } // End of namespace Tony -- cgit v1.2.3 From b0eef829728183b7ea170b30a33eca091bcc4574 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 30 Apr 2012 09:27:12 +1000 Subject: TONY: Added include files for graphics engine and all dependent classes --- engines/tony/adv.h | 70 ++++++ engines/tony/font.h | 399 +++++++++++++++++++++++++++++++++ engines/tony/game.cpp | 54 +++++ engines/tony/game.h | 285 +++++++++++++++++++++++ engines/tony/gfxcore.cpp | 54 +++++ engines/tony/gfxcore.h | 547 +++++++++++++++++++++++++++++++++++++++++++++ engines/tony/gfxengine.cpp | 53 +++++ engines/tony/gfxengine.h | 167 ++++++++++++++ engines/tony/input.cpp | 54 +++++ engines/tony/input.h | 116 ++++++++++ engines/tony/inventory.h | 212 ++++++++++++++++++ engines/tony/loc.cpp | 8 +- engines/tony/loc.h | 488 +++++++++++++++++++++++++++++++++++++++- engines/tony/module.mk | 5 + engines/tony/mpal/memory.h | 4 + engines/tony/mpal/stubs.h | 4 - engines/tony/resid.h | 76 +++++++ engines/tony/sound.cpp | 54 +++++ engines/tony/sound.h | 254 +++++++++++++++++++++ engines/tony/tony.cpp | 3 + engines/tony/tony.h | 2 + engines/tony/tonychar.h | 448 +++++++++++++++++++++++++++++++++++++ engines/tony/utils.cpp | 10 +- engines/tony/utils.h | 10 +- 24 files changed, 3354 insertions(+), 23 deletions(-) create mode 100644 engines/tony/adv.h create mode 100644 engines/tony/font.h create mode 100644 engines/tony/game.cpp create mode 100644 engines/tony/game.h create mode 100644 engines/tony/gfxcore.cpp create mode 100644 engines/tony/gfxcore.h create mode 100644 engines/tony/gfxengine.cpp create mode 100644 engines/tony/gfxengine.h create mode 100644 engines/tony/input.cpp create mode 100644 engines/tony/input.h create mode 100644 engines/tony/inventory.h create mode 100644 engines/tony/resid.h create mode 100644 engines/tony/sound.cpp create mode 100644 engines/tony/sound.h create mode 100644 engines/tony/tonychar.h (limited to 'engines') diff --git a/engines/tony/adv.h b/engines/tony/adv.h new file mode 100644 index 0000000000..b29e4eb0cd --- /dev/null +++ b/engines/tony/adv.h @@ -0,0 +1,70 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ +/************************************************************************** + * 様様様様様様様様様様様様様様様様様 * + * Nayma Software srl * + * e -= We create much MORE than ALL =- * + * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * + * .d" d$$$$$b "b. * + * .z$* d$$$$$$$L ^*$c. * + * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * + * ^*$b 4$$$$$$$$$F .d$*" * + * ^$$. 4$$$$$$$$$F .$P" Module: ADV.CPP.............. * + * *$. '$$$$$$$$$ 4$P 4 * + * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * + * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * + * z$" "" #$F^ "" '$c * + * z$$beu .ue=" $ "=e.. .zed$$c * + * "#$e z$*" . `. ^*Nc e$"" * + * "$$". .r" ^4. .^$$" * + * ^.@*"6L=\ebu^+C$"*b." * + * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * + * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * + * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * + * * + * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * + * * + **************************************************************************/ + +#ifndef TONY_ADV_H +#define TONY_ADV_H + +namespace Tony { + +// Tony's actions +enum RMTonyAction { + TA_GOTO = 0, + TA_TAKE, + TA_USE, + TA_EXAMINE, + TA_TALK, + TA_PALESATI, + + TA_COMBINE = 10, + TA_RECEIVECOMBINE, + TA_COMBINEGIVE, + TA_RECEIVECOMBINEGIVE +}; + +} // End of namespace Tony + +#endif diff --git a/engines/tony/font.h b/engines/tony/font.h new file mode 100644 index 0000000000..348e7618ea --- /dev/null +++ b/engines/tony/font.h @@ -0,0 +1,399 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ +/************************************************************************** + * 様様様様様様様様様様様様様様様様様 * + * Nayma Software srl * + * e -= We create much MORE than ALL =- * + * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * + * .d" d$$$$$b "b. * + * .z$* d$$$$$$$L ^*$c. * + * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * + * ^*$b 4$$$$$$$$$F .d$*" * + * ^$$. 4$$$$$$$$$F .$P" Module: Font.CPP............. * + * *$. '$$$$$$$$$ 4$P 4 * + * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * + * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * + * z$" "" #$F^ "" '$c * + * z$$beu .ue=" $ "=e.. .zed$$c * + * "#$e z$*" . `. ^*Nc e$"" * + * "$$". .r" ^4. .^$$" * + * ^.@*"6L=\ebu^+C$"*b." * + * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * + * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * + * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * + * * + * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * + * * + **************************************************************************/ + +#ifndef TONY_FONT_H +#define TONY_FONT_H + +#include "common/system.h" +#include "tony/gfxcore.h" +#include "tony/resid.h" + +namespace Tony { + +class RMInventory; + +/** + * Gestisce un font, in cui ha varie surface per ogni lettera + */ +class RMFont : public RMGfxTaskSetPrior { +protected: + int nLetters; + RMGfxSourceBuffer8RLEByte *m_letter; +public: + int m_fontDimx,m_fontDimy; + +private: + int m_dimx,m_dimy; + + class RMFontPrimitive : public RMGfxPrimitive { + public: + RMFontPrimitive() : RMGfxPrimitive() {} + RMFontPrimitive(RMGfxTask *task) : RMGfxPrimitive(task) {} + + virtual RMGfxPrimitive* Duplicate() { return new RMFontPrimitive(*this); } + + int m_nChar; + }; + +protected: + // Caricamento del font + void Load(uint32 resID, int nChars, int dimx, int dimy, uint32 palResID = RES_F_PAL); + void Load(const byte *buf, int nChars, int dimx, int dimy, uint32 palResID = RES_F_PAL); + + // Scaricamente del font (anche da distruttore) + void Unload(void); + +protected: + // Conversione (da overloadare) + virtual int ConvertToLetter(int nChar) = 0; + + // Lunghezza dei caratteri (da overloadare) + virtual int LetterLength(int nChar, int nNext=0) = 0; + +public: + virtual int LetterHeight(void) = 0; + +public: + RMFont(); + virtual ~RMFont(); + + // Inizializzazione e chiusura + virtual void Init(void) = 0; + virtual void Close(void); + + // Funzione del task da overloadare + void Draw(RMGfxTargetBuffer &bigBug, RMGfxPrimitive *prim); + + // Crea una primitiva per una lettera + RMGfxPrimitive *MakeLetterPrimitive(byte bChar, int& nLength); + + // Lunghezza in pixel di una stringa con il font corrente + int StringLen(RMString text); + int StringLen(char bChar, char bNext=0); +}; + + +class RMFontColor : public virtual RMFont { +private: + byte m_r,m_g,m_b; + +public: + RMFontColor(); + virtual ~RMFontColor(); + virtual void SetBaseColor(byte r, byte g, byte b); +}; + + +class RMFontWithTables : public virtual RMFont { +protected: + int cTable[256]; + int lTable[256]; + int lDefault; + int hDefault; + signed char l2Table[256][256]; + +protected: + // Overload dei metodi + int ConvertToLetter(int nChar) { return cTable[nChar]; } + int LetterLength(int nChar, int nNext=0) { return (nChar!=-1 ? lTable[nChar]+l2Table[nChar][nNext] : lDefault); } + +public: + int LetterHeight() { return hDefault; } + virtual ~RMFontWithTables() {} +}; + + +class RMFontParla : public RMFontColor, public RMFontWithTables { +public: + void Init(void); + virtual ~RMFontParla() {} +}; + +class RMFontObj : public RMFontColor, public RMFontWithTables { +private: + void SetBothCase(int nChar, int nNext, signed char spiazz); + +public: + void Init(void); + virtual ~RMFontObj() {} +}; + +class RMFontMacc : public RMFontColor, public RMFontWithTables { +public: + void Init(void); + virtual ~RMFontMacc() {} +}; + +class RMFontCredits : public RMFontColor, public RMFontWithTables { +public: + void Init(void); + virtual ~RMFontCredits() {} + virtual void SetBaseColor(byte r, byte g, byte b) {} +}; + +/** + * Gestisce una scritta su schermo, con tutte le possibilita' di formattazione disponibile + */ +class RMText : public RMGfxWoodyBuffer { +private: + static RMFontColor *m_fonts[4]; + static RMGfxClearTask m_clear; + static OSystem::MutexRef m_cs; + int maxLineLength; + +public: + enum HORALIGN { + HLEFT, + HLEFTPAR, + HCENTER, + HRIGHT + }; + + enum VERALIGN { + VTOP, + VCENTER, + VBOTTOM + }; + +private: + HORALIGN aHorType; + VERALIGN aVerType; + byte m_r,m_g,m_b; + +protected: + virtual void ClipOnScreen(RMGfxPrimitive* prim); + +public: + RMText(); + virtual ~RMText(); + + // Setta il tipo di allineamento + void SetAlignType(HORALIGN aHor, VERALIGN aVer) { aHorType=aHor; aVerType=aVer; } + + // Setta la lunghezza massima di una linea in pixel (utilizzato per formattare il testo) + void SetMaxLineLength(int max); + + // Scrive un testo + void WriteText(RMString text, int font, int *time = NULL); + void WriteText(RMString text, RMFontColor* font, int *time = NULL); + + // Overloading della funzione ereditata da RMGfxTask per decidere + // quando eliminare un oggetto dalla OTLIST + virtual bool RemoveThis(void); + + // Overloading del Draw per centrare la scritta, se necessario + virtual void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); + + // Setta il colore di base + void SetColor(byte r, byte g, byte b) { m_r=r; m_g=g; m_b=b; } +}; + +/** + * Gestisce il testo di un dialogo + */ +class RMTextDialog : public RMText +{ + protected: + int m_startTime; + int m_time; + bool m_bSkipStatus; + RMPoint dst; + HANDLE hEndDisplay; + bool m_bShowed; + bool m_bForceTime; + bool m_bForceNoTime; + HANDLE hCustomSkip; + HANDLE hCustomSkip2; + RMInput* m_input; + bool m_bAlwaysDisplay; + bool m_bNoTab; + + public: + RMTextDialog(); + virtual ~RMTextDialog(); + + // Scrive un testo + void WriteText(RMString text, int font, int *time=NULL); + void WriteText(RMString text, RMFontColor* font, int *time=NULL); + + // Overloading della funzione ereditata da RMGfxTask per decidere + // quando eliminare un oggetto dalla OTLIST + virtual bool RemoveThis(void); + + // Overloading della funzione di deregistrazione, utilizzata per capire + // quando ci leviamo di torno + virtual void Unregister(void); + + // Overloading del Draw per centrare la scritta, se necessario + virtual void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); + + // Setta la posizione + void SetPosition(RMPoint pt) { dst=pt; } + + // Aspetta che venga finita la visualizzazione + void WaitForEndDisplay(void); + void SetCustomSkipHandle(HANDLE hCustomSkip); + void SetCustomSkipHandle2(HANDLE hCustomSkip); + void SetSkipStatus(bool bEnabled); + void SetForcedTime(uint32 dwTime); + void SetNoTab(void); + void ForceTime(void); + void ForceNoTime(void); + void SetAlwaysDisplay(void); + + // Setta il dispositivo di input, per permettere skip da mouse + void SetInput(RMInput* input); + + void Show(void); + void Hide(void); +}; + +class RMTextDialogScrolling : public RMTextDialog { +protected: + RMLocation* curLoc; + RMPoint startScroll; + + virtual void ClipOnScreen(RMGfxPrimitive* prim); + +public: + RMTextDialogScrolling(); + RMTextDialogScrolling(RMLocation* loc); + virtual ~RMTextDialogScrolling(); + + virtual void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); +}; + + +/****************************************************************************\ +* class RMTextItemName +* -------------------- +* Description: Gestisce il nome dell'oggetto selezionato su schermo +\****************************************************************************/ + +class RMTextItemName : protected RMText { +protected: + RMPoint m_mpos; + RMPoint m_curscroll; + RMItem* m_item; + RMString m_itemName; + +public: + RMTextItemName(); + virtual ~RMTextItemName(); + + void SetMouseCoord(RMPoint m) { m_mpos=m; } + + void DoFrame(RMGfxTargetBuffer &bigBuf, RMLocation &loc, RMPointer &ptr, RMInventory &inv); + virtual void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); + + RMPoint GetHotspot() { if (m_item==NULL) return m_mpos+m_curscroll; else return m_item->Hotspot(); } + RMItem* GetSelectedItem() { return m_item; } + bool IsItemSelected() { return m_item!=NULL; } + bool IsNormalItemSelected() { return m_item!=NULL && m_itemName.Length()>0; } + + virtual bool RemoveThis() { return true; } +}; + + +/** + * Gestisce la schermata di scelta delle voci di un dialogo + */ +class RMDialogChoice : public RMGfxWoodyBuffer { +private: + int m_curSelection; + int m_numChoices; + RMText* m_drawedStrings; + RMPoint *m_ptDrawStrings; + int m_curAdded; + bool m_bShow; + RMGfxSourceBuffer8 DlgText; + RMGfxSourceBuffer8 DlgTextLine; + RMPoint m_ptDrawPos; + HANDLE hUnreg; + bool bRemoveFromOT; + +protected: + void Prepare(void); + void SetSelected(int pos); + +public: + bool RemoveThis(void); + void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); + void Unregister(void); + +public: + // Inizializzazione + RMDialogChoice(); + virtual ~RMDialogChoice(); + + // Inizializzazione e chiusura + void Init(void); + void Close(void); + + // Setta il numero delle frasi possibili, che dovranno essere poi aggiunte + // con AddChoice() + void SetNumChoices(int num); + + // Aggiunge una stringa con la scelta + void AddChoice(RMString string); + + // Mostra e nasconde la scelta, con eventuali animazioni + // NOTA: Se non viene passato parametro alla Show(), obbligo del + // chiamante assicurarsi che la classe venga inserita alla OTlist + void Show(RMGfxTargetBuffer* bigBuf = NULL); + void Hide(void); + + // Polling di aggiornamento + void DoFrame(RMPoint ptMousePos); + + // Ritorna la voce attualmente selezionata, o -1 se nessuna selezionata + int GetSelection(void); +}; + +} // End of namespace Tony + +#endif diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp new file mode 100644 index 0000000000..48827cbc2a --- /dev/null +++ b/engines/tony/game.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. + * + */ +/************************************************************************** + * 様様様様様様様様様様様様様様様様様 * + * Nayma Software srl * + * e -= We create much MORE than ALL =- * + * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * + * .d" d$$$$$b "b. * + * .z$* d$$$$$$$L ^*$c. * + * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * + * ^*$b 4$$$$$$$$$F .d$*" * + * ^$$. 4$$$$$$$$$F .$P" Module: Loc.CPP.............. * + * *$. '$$$$$$$$$ 4$P 4 * + * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * + * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * + * z$" "" #$F^ "" '$c * + * z$$beu .ue=" $ "=e.. .zed$$c * + * "#$e z$*" . `. ^*Nc e$"" * + * "$$". .r" ^4. .^$$" * + * ^.@*"6L=\ebu^+C$"*b." * + * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * + * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * + * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * + * * + * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * + * * + **************************************************************************/ + +#include "tony/game.h" + +namespace Tony { + + + +} // End of namespace Tony diff --git a/engines/tony/game.h b/engines/tony/game.h new file mode 100644 index 0000000000..28f9489267 --- /dev/null +++ b/engines/tony/game.h @@ -0,0 +1,285 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ +/************************************************************************** + * 様様様様様様様様様様様様様様様様様 * + * Nayma Software srl * + * e -= We create much MORE than ALL =- * + * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * + * .d" d$$$$$b "b. * + * .z$* d$$$$$$$L ^*$c. * + * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * + * ^*$b 4$$$$$$$$$F .d$*" * + * ^$$. 4$$$$$$$$$F .$P" Module: Game.CPP............. * + * *$. '$$$$$$$$$ 4$P 4 * + * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * + * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * + * z$" "" #$F^ "" '$c * + * z$$beu .ue=" $ "=e.. .zed$$c * + * "#$e z$*" . `. ^*Nc e$"" * + * "$$". .r" ^4. .^$$" * + * ^.@*"6L=\ebu^+C$"*b." * + * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * + * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * + * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * + * * + * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * + * * + **************************************************************************/ + +#ifndef TONY_GAME_H +#define TONY_GAME_H + +#include "tony/adv.h" +#include "tony/gfxcore.h" +#include "tony/input.h" +#include "tony/loc.h" +#include "tony/utils.h" + +namespace Tony { + +class RMPointer : public RMGfxTask { +private: + RMGfxSourceBuffer8 *m_pointer[16]; + RMPoint m_hotspot[16]; + RMPoint m_pos; + + RMItem *m_specialPointer[16]; + + int m_nCurPointer; + int m_nCurSpecialPointer; + + RMGfxSourceBuffer8 *m_nCurCustomPointer; + +public: + enum POINTER { + PTR_NONE = 0, + PTR_FRECCIASU, + PTR_FRECCIAGIU, + PTR_FRECCIASINISTRA, + PTR_FRECCIADESTRA, + PTR_FRECCIAMAPPA, + PTR_CUSTOM + }; + +public: + // Constructor & destructor + RMPointer(); + virtual ~RMPointer(); + + // Initialisation + void Init(void); + + // Deinitialisation + void Close(void); + + // Process a frame + void DoFrame(RMGfxTargetBuffer *bigBuf); + + // Overloading of priorities + int Priority(); + + // Overloading draw method + void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + + // Sets the current co-ordinates + void SetCoord(RMPoint pt) { m_pos = pt; } + + // Overloading of the method to see if rising from the list + bool RemoveThis(); + + // Sets a new action as current + void SetAction(RMTonyAction action) { m_nCurPointer = action; } + + // Sets a new pointer + void SetSpecialPointer(POINTER ptr) { + m_nCurSpecialPointer=ptr; + if (m_nCurSpecialPointer && m_nCurSpecialPointer != PTR_CUSTOM) m_specialPointer[ptr-1]->SetPattern(1); + } + POINTER GetSpecialPointer(void) { return (POINTER)m_nCurSpecialPointer; } + + // Set the new custom pointer + void SetCustomPointer(RMGfxSourceBuffer8 *ptr) { m_nCurCustomPointer = ptr; } + + // Return the current action to be applied according to the pointer + int CurAction(void); +}; + +class RMOptionButton: public RMGfxTaskSetPrior { +public: + RMRect m_rect; + RMGfxSourceBuffer16 *m_buf; + bool m_bActive; + bool m_bHasGfx; + bool m_bDoubleState; + +public: + RMOptionButton(uint32 dwRes, RMPoint pt, bool bDoubleState = false); + RMOptionButton(RMRect pt); + virtual ~RMOptionButton(); + + bool DoFrame(RMPoint mousePos, bool bLeftClick, bool bRightClick); + void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + void AddToList(RMGfxTargetBuffer &bigBuf); + bool IsActive() { return m_bActive; } + void SetActiveState(bool bState) { m_bActive=bState; } +}; + +class RMOptionSlide : public RMGfxTaskSetPrior { +private: + RMOptionButton* m_PushLeft; + RMOptionButton* m_PushRight; + RMGfxSourceBuffer16* m_SliderCenter; + RMGfxSourceBuffer16* m_SliderLeft; + RMGfxSourceBuffer16* m_SliderRight; + RMGfxSourceBuffer16* m_SliderSingle; + int m_nSlideSize; + RMPoint m_pos; + int m_nValue; + int m_nMax; + int m_nStep; + +public: + RMOptionSlide(RMPoint pt, int m_nRange=100, int m_nStartValue=0, int slideSize=300); + virtual ~RMOptionSlide(); + + bool DoFrame(RMPoint mousePos, bool bLeftClick, bool bRightClick); + void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); + void AddToList(RMGfxTargetBuffer& bigBuf); + + int GetValue() { return m_nValue; } +}; + +class RMOptionScreen : public RMGfxWoodyBuffer { +private: + RMGfxSourceBuffer16 *m_menu; + RMGfxSourceBuffer16 *m_QuitConfirm; + RMGfxSourceBuffer16 *m_HideLoadSave; + RMOptionButton *m_ButtonQuitYes; + RMOptionButton *m_ButtonQuitNo; + RMOptionButton *m_ButtonExit; + RMOptionButton *m_ButtonQuit; + RMOptionButton *m_ButtonLoad; + RMOptionButton *m_ButtonSave; + RMOptionButton *m_ButtonGameMenu; + RMOptionButton *m_ButtonGfxMenu; + RMOptionButton *m_ButtonSoundMenu; + RMGfxSourceBuffer8 *m_SaveEasy; + RMGfxSourceBuffer8 *m_SaveHard; + RMGfxSourceBuffer16 *m_curThumb[6]; + RMString m_curThumbName[6]; + byte m_curThumbDiff[6]; + RMOptionButton *m_ButtonSave_States[6]; + RMOptionButton *m_ButtonSave_ArrowLeft; + RMOptionButton *m_ButtonSave_ArrowRight; + RMOptionButton *m_ButtonGfx_Tips; + + RMOptionButton *m_ButtonSound_DubbingOn; + RMOptionButton *m_ButtonSound_MusicOn; + RMOptionButton *m_ButtonSound_SFXOn; + + RMOptionSlide *m_SlideTonySpeed; + RMOptionSlide *m_SlideTextSpeed; + + + int m_statePos; + bool m_bEditSaveName; + int m_nEditPos; + char m_EditName[256]; + + union { + RMOptionButton *m_ButtonGame_Lock; + RMOptionButton *m_ButtonGfx_Anni30; + RMOptionSlide *m_SliderSound_Music; + }; + union { + RMOptionButton *m_ButtonGame_TimerizedText; + RMOptionButton *m_ButtonGfx_AntiAlias; + RMOptionSlide *m_SliderSound_SFX; + }; + union { + RMOptionButton *m_ButtonGame_Scrolling; + RMOptionButton *m_ButtonGfx_Sottotitoli; + RMOptionSlide *m_SliderSound_Dubbing; + }; + union { + RMOptionButton *m_ButtonGame_InterUp; + RMOptionButton *m_ButtonGfx_Trans; + }; + + int m_FadeStep; + bool m_bExit; + bool m_bQuitConfirm; + int m_FadeY; + int m_FadeTime; + bool m_bLoadMenuOnly; + bool m_bNoLoadSave; + bool m_bAlterGfx; + + enum STATE { + MENUGAME, + MENUGFX, + MENUSOUND, + MENULOAD, + MENUSAVE + }; + + STATE m_nState; + STATE m_nLastState; + +public: + RMOptionScreen(); + virtual ~RMOptionScreen(); + + bool Init(RMGfxTargetBuffer& bigBuf); + bool InitLoadMenuOnly(RMGfxTargetBuffer &bigBuf, bool bAlternateGfx = false); + bool InitSaveMenuOnly(RMGfxTargetBuffer &bigBuf, bool bAlternateGfx = false); + bool InitNoLoadSave(RMGfxTargetBuffer &bigBuf); + void ReInit(RMGfxTargetBuffer &bigBuf); + bool Close(); + bool IsClosing(); + + // Metodi in overloading da RMGfxTask + int Priority(); + void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + bool RemoveThis(); + + // Polling per l'option screen + void DoFrame(RMInput *m_input); + +protected: + + // Inizializza tutto per il nuovo stato + void InitState(void); + void CloseState(void); + void ChangeState(STATE newState); + + // Ridisegna tutto il menu delle opzioni + void RefreshAll(void); + void RefreshThumbnails(void); + + // Carica lo screenshot per il salvataggio + bool LoadThumbnailFromSaveState(int numState, byte *lpDestBuf, RMString &name, byte &diff); +}; + +} // End of namespace Tony + +#endif diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp new file mode 100644 index 0000000000..731521832f --- /dev/null +++ b/engines/tony/gfxcore.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. + * + */ +/************************************************************************** + * 様様様様様様様様様様様様様様様様様 * + * Nayma Software srl * + * e -= We create much MORE than ALL =- * + * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * + * .d" d$$$$$b "b. * + * .z$* d$$$$$$$L ^*$c. * + * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * + * ^*$b 4$$$$$$$$$F .d$*" * + * ^$$. 4$$$$$$$$$F .$P" Module: GfxCore.CPP.......... * + * *$. '$$$$$$$$$ 4$P 4 * + * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * + * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * + * z$" "" #$F^ "" '$c * + * z$$beu .ue=" $ "=e.. .zed$$c * + * "#$e z$*" . `. ^*Nc e$"" * + * "$$". .r" ^4. .^$$" * + * ^.@*"6L=\ebu^+C$"*b." * + * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * + * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * + * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * + * * + * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * + * * + **************************************************************************/ + +#include "tony/gfxEngine.h" + +namespace Tony { + + + +} // End of namespace Tony diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h new file mode 100644 index 0000000000..313e471cdf --- /dev/null +++ b/engines/tony/gfxcore.h @@ -0,0 +1,547 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ +/************************************************************************** + * 様様様様様様様様様様様様様様様様様 * + * Nayma Software srl * + * e -= We create much MORE than ALL =- * + * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * + * .d" d$$$$$b "b. * + * .z$* d$$$$$$$L ^*$c. * + * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * + * ^*$b 4$$$$$$$$$F .d$*" * + * ^$$. 4$$$$$$$$$F .$P" Module: GfxCore.CPP.......... * + * *$. '$$$$$$$$$ 4$P 4 * + * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * + * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * + * z$" "" #$F^ "" '$c * + * z$$beu .ue=" $ "=e.. .zed$$c * + * "#$e z$*" . `. ^*Nc e$"" * + * "$$". .r" ^4. .^$$" * + * ^.@*"6L=\ebu^+C$"*b." * + * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * + * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * + * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * + * * + * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * + * * + **************************************************************************/ + +#ifndef TONY_GFXCORE_H +#define TONY_GFXCORE_H + +#include "common/system.h" +#include "tony/utils.h" + +namespace Tony { + +/****************************************************************************\ +* Prototipi di classi +\****************************************************************************/ + +// Nome della classe Albero genealogico Astratto? +class RMGfxTask; // Si +class RMGfxTaskSetPrior; // Task Si +class RMGfxBuffer; // +class RMGfxSourceBuffer; // TaskP+[Buffer] Si +class RMGfxTargetBuffer; // [Buffer] +class RMGfxSourceBufferPal; // Source Si +class RMGfxSourceBuffer4; // SourcePal +class RMGfxSourceBuffer8; // SourcePal +class RMGfxSourceBuffer16; // Source +class RMGfxWoodyBuffer; // Source16+Target +class RMGfxClearTask; // Task + + +/** + * Graphics buffer + */ +class RMGfxBuffer { +protected: + int m_dimx, m_dimy; + byte *m_buf; + byte *m_origBuf; + bool m_bUseDDraw; + +public: + RMGfxBuffer(); + RMGfxBuffer(int dimx, int dimy, int nBpp, bool bUseDDraw = false); + virtual ~RMGfxBuffer(); + + // Attributes + int Dimx() { return m_dimx; } + int Dimy() { return m_dimy; } + + // Creation + virtual void Create(int dimx, int dimy, int nBpp, bool bUseDDraw = false); + virtual void Destroy(void); + + // Buffer access + void Lock(void); + void Unlock(void); + + // These are valid only if the buffer is locked + operator byte *(); + operator void *(); + + // Getting the offset for a given Y position + void OffsetY(int nLines, int nBpp); +}; + +/** + * Graphics primitive + */ +class RMGfxPrimitive { +public: + RMGfxTask *m_task; + +protected: + RMRect m_src; + RMRect m_dst; + +bool m_bStretch; + byte m_bFlag; + +public: + RMGfxPrimitive() { m_bFlag = 0; m_task = NULL; m_src.SetEmpty(); m_dst.SetEmpty(); } + + RMGfxPrimitive(RMGfxTask *task) { + m_task = task; m_bFlag = 0; + } + + RMGfxPrimitive(RMGfxTask *task, RMRect &src, RMRect &dst) { + m_task = task; m_src = src; m_dst = dst; m_bFlag = 0; + m_bStretch = (src.Width() != dst.Width() || src.Height() != dst.Height()); + } + + RMGfxPrimitive(RMGfxTask *task, RMPoint &src, RMRect &dst) { + m_task = task; m_src.TopLeft() = src; m_dst = dst; m_bFlag = 0; + } + + RMGfxPrimitive(RMGfxTask *task, RMPoint &src, RMPoint &dst) { + m_task = task; m_src.TopLeft() = src; m_dst.TopLeft() = dst; m_bFlag = 0; + } + + RMGfxPrimitive(RMGfxTask *task, RMRect &src, RMPoint &dst) { + m_task = task; m_src = src; m_dst.TopLeft() = dst; m_bFlag = 0; + } + + RMGfxPrimitive(RMGfxTask *task, RMRect &dst) { + m_task = task; m_dst = dst; m_src.SetEmpty(); m_bFlag = 0; + } + + RMGfxPrimitive(RMGfxTask *task, RMPoint &dst) { + m_task = task; m_dst.TopLeft() = dst; m_src.SetEmpty(); m_bFlag = 0; + } + + void SetFlag(byte bFlag) { m_bFlag=bFlag; } + void SetTask(RMGfxTask *task) { m_task = task; } + void SetSrc(RMRect &src) { m_src = src; } + void SetSrc(RMPoint &src) { m_src.TopLeft() = src; } + void SetDst(RMRect &dst) { m_dst = dst; } + void SetDst(RMPoint &dst) { m_dst.TopLeft() = dst; } + void SetStrecth(bool bStretch) { m_bStretch = bStretch; } + + bool HaveDst() { return !m_dst.IsEmpty(); } + RMRect &Dst() { return m_dst; } + + bool HaveSrc() { return !m_src.IsEmpty(); } + RMRect &Src() { return m_src; } + + // Flags + bool IsFlipped() { return m_bFlag&1; } + + // Duplicate + virtual RMGfxPrimitive* Duplicate() { return new RMGfxPrimitive(*this); } +}; + + +/** + * Graphic drawing task + */ +class RMGfxTask { +protected: + int m_nPrior; + int m_nInList; + +public: + // Costruttore standard + RMGfxTask(); + + virtual int Priority(); + virtual void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) = 0; + virtual bool RemoveThis(); + + // Registration + virtual void Register(void) { m_nInList++; } + virtual void Unregister(void) { m_nInList--; assert(m_nInList>=0); } +}; + + +/** + * Graphic drawing with priority + */ +class RMGfxTaskSetPrior : public RMGfxTask { +public: + void SetPriority(int nPrior); +}; + + +/** + * Task that cleans the destination buffer + */ +class RMGfxClearTask : public RMGfxTask { +public: + int Priority(); + void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); + bool RemoveThis(); +}; + + +/** + * Task that draws a coloured box + */ +class RMGfxBox : public RMGfxTaskSetPrior { +protected: + uint16 wFillColor; + +public: + void SetColor(byte r, byte g, byte b); + void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + bool RemoveThis(); +}; + + +/** + * Buffer source for the design, which is a task. This is an abstract base. + */ +class RMGfxSourceBuffer : public virtual RMGfxBuffer, public RMGfxTaskSetPrior { +public: + // Carica i dati della surface a basso livello + virtual int Init(uint32 resID, int dimx, int dimy, bool bLoadPalette = false); + virtual int Init(byte *buf, int dimx, int dimy, bool bLoadPalette = false); + virtual void Init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette = false); + + virtual ~RMGfxSourceBuffer(); + +protected: + virtual void PrepareImage(void); + bool Clip2D(int &x1, int &y1, int &u, int &v, int &width, int &height, bool bUseSrc, RMGfxTargetBuffer *buf); + void OffsetY(int nLines) { RMGfxBuffer::OffsetY(nLines,Bpp()); } + +public: + virtual int Bpp() = 0; +}; + + +/** + * 16-bit colour source + */ +class RMGfxSourceBuffer16 : public RMGfxSourceBuffer { +protected: + virtual void PrepareImage(void); + bool m_bTrasp0; + +public: + RMGfxSourceBuffer16(bool bUseTrasp = false); + RMGfxSourceBuffer16(int dimx, int dimy, bool bUseDDraw = false); + virtual ~RMGfxSourceBuffer16(); + + // Inizializzazione + void Create(int dimx, int dimy, bool bUseDDraw = false); + + int Bpp(); + virtual void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); +}; + + +/** + * Buffer source with palette + */ +class RMGfxSourceBufferPal : public RMGfxSourceBuffer { +protected: + // The size of the palette is (1<MpalCode()); return *this; } + RMInventory& operator+=(RMItem &item) { AddItem(item.MpalCode()); return *this; } + RMInventory& operator+=(int code) { AddItem(code); return *this; } + + // Rimozione di oggetto + void RemoveItem(int code); + + // Siamo sopra un oggetto? + RMItem* WhichItemIsIn(RMPoint mpt); + bool ItemInFocus(RMPoint mpt); + + // Cambia l'icona di un oggetto + void ChangeItemStatus(uint32 dwCode, uint32 dwStatus); + + // Salvataggio + int GetSaveStateSize(void); + void SaveState(byte *state); + int LoadState(byte *state); +}; + + +class RMInterface : public RMGfxSourceBuffer8RLEByte { +private: + bool m_bActive; + RMPoint m_mpos; + RMPoint m_openPos; + RMPoint m_openStart; + RMText m_hints[5]; + RMGfxSourceBuffer8RLEByte m_hotzone[5]; + RMRect m_hotbbox[5]; + bool m_bPalesati; + int m_lastHotZone; + +protected: + // Dice su quale zona calda si trova il punto + int OnWhichBox(RMPoint pt); + +public: + virtual ~RMInterface(); + + // Il solito DoFrame (polling del motore grafico) + void DoFrame(RMGfxTargetBuffer& bigBuf, RMPoint mousepos); + + // TRUE se attiva (non si pu selezionare oggetti) + bool Active(); + + // Inizializzazione + void Init(void); + void Close(void); + + // Resetta l'interfaccia + void Reset(void); + + // Avverte dei click e rilasci del mouse + void Clicked(RMPoint mousepos); + bool Released(RMPoint mousepos, RMTonyAction &action); + + // Attiva o disattiva il quinto verbo + void SetPalesati(bool bOn); + bool GetPalesati(void); + + // Overloading del Draw per il posizionamente + virtual void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); +}; + +} // End of namespace Tony + +#endif diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index a40248f57d..83c48bb938 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -32,10 +32,10 @@ * *$. '$$$$$$$$$ 4$P 4 * * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c Desc: Classi di gestione * - * z$$beu .ue=" $ "=e.. .zed$$c dei dati di una loca- * - * "#$e z$*" . `. ^*Nc e$"" zione................ * - * "$$". .r" ^4. .^$$" ..................... * + * z$" "" #$F^ "" '$c * + * z$$beu .ue=" $ "=e.. .zed$$c * + * "#$e z$*" . `. ^*Nc e$"" * + * "$$". .r" ^4. .^$$" * * ^.@*"6L=\ebu^+C$"*b." * * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * diff --git a/engines/tony/loc.h b/engines/tony/loc.h index e09a7389d9..1cae9edb1e 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -32,10 +32,10 @@ * *$. '$$$$$$$$$ 4$P 4 * * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c Desc: Classi di gestione * - * z$$beu .ue=" $ "=e.. .zed$$c dei dati di una loca- * - * "#$e z$*" . `. ^*Nc e$"" zione................ * - * "$$". .r" ^4. .^$$" ..................... * + * z$" "" #$F^ "" '$c * + * z$$beu .ue=" $ "=e.. .zed$$c * + * "#$e z$*" . `. ^*Nc e$"" * + * "$$". .r" ^4. .^$$" * * ^.@*"6L=\ebu^+C$"*b." * * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * @@ -49,10 +49,269 @@ #define TONY_LOC_H #include "common/scummsys.h" -#include "utils.h" +#include "common/system.h" +#include "tony/mpal/stubs.h" +#include "tony/sound.h" +#include "tony/utils.h" namespace Tony { +/****************************************************************************\ +* Various defines +\****************************************************************************/ + +/** + * Valid colour modes + */ +typedef enum { + CM_256, + CM_65K +} RMColorMode; + + +/****************************************************************************\ +* Class declarations +\****************************************************************************/ + +/** + * Generic palette + */ +class RMPalette { +public: + byte m_data[1024]; + +public: + friend RMDataStream &operator>>(RMDataStream &ds, RMPalette &pal); +}; + + +/** + * Sound effect of an object + */ +class RMSfx { +public: + RMString m_name; + FPSFX *m_fx; + bool m_bPlayingLoop; + +public: + RMSfx(); + virtual ~RMSfx(); + + friend RMDataStream& operator>>(RMDataStream &ds, RMSfx &sfx); + + void Play(bool bLoop = false); + void SetVolume(int vol); + void Pause(bool bPause); + void Stop(void); + + void ReadFromStream(RMDataStream& ds, bool bLOX = false); +}; + + +/** + * Object pattern + */ +class RMPattern { +public: + // Type of slot + enum RMSlotType { + DUMMY1 = 0, + DUMMY2, + SPRITE, + SOUND, + COMMAND, + SPECIAL + }; + + // Class slot + class RMSlot { + private: + RMPoint m_pos; // Child co-ordinates + + public: + RMSlotType m_type; + int m_data; + byte m_flag; + + public: + friend RMDataStream& operator>>(RMDataStream& ds, RMSlot& slot); + + RMPoint Pos() { return m_pos; } + + void ReadFromStream(RMDataStream& ds, bool bLOX = false); + }; + +public: + RMString m_name; + +private: + int m_speed; + RMPoint m_pos; // Coordinate babbo + RMPoint m_curPos; // Coordinate babbo+figlio + int m_bLoop; + int m_nSlots; + int m_nCurSlot; + int m_nCurSprite; + + RMSlot *m_slots; + + uint32 m_nStartTime; + +public: + RMPattern(); + virtual ~RMPattern(); + + friend RMDataStream& operator>>(RMDataStream& ds, RMPattern& pat); + + // A warning that the pattern now and the current + int Init(RMSfx* sfx, bool bPlayP0=false, byte* bFlag=NULL); + + // Update the pattern, checking to see if it's time to change slot and executing + // any associated commands + int Update(HANDLE hEndPattern, byte& bFlag, RMSfx* sfx); + + // Stop a sound effect + void StopSfx(RMSfx *sfx); + + // Reads the position of the pattern + RMPoint Pos() { return m_curPos; } + + void ReadFromStream(RMDataStream& ds, bool bLOX = false); + +private: + void UpdateCoord(void); +}; + + +/** + * Sprite (frame) animation of an item + */ +class RMSprite : public RMGfxTask { +public: + RMString m_name; + RMRect m_rcBox; + +protected: + RMGfxSourceBuffer* m_buf; + +public: + RMSprite(); + virtual ~RMSprite(); + + void Init(RMGfxSourceBuffer* buf); + friend RMDataStream& operator>>(RMDataStream& ds, RMSprite& sprite); + void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); + void SetPalette(byte *lpBuf); + void GetSizeFromStream(RMDataStream& ds, int* dimx, int* dimy); + void LOXGetSizeFromStream(RMDataStream& ds, int* dimx, int* dimy); + + void ReadFromStream(RMDataStream& ds, bool bLOX = false); +}; + + +/** + * Data on an item + */ +class RMItem : public RMGfxTask { +public: + RMString m_name; + +protected: + int m_z; + RMPoint m_pos; // Coordinate nonno + RMColorMode m_cm; + RMPoint m_curScroll; + + byte m_FX; + byte m_FXparm; + + virtual int GetCurPattern() { return m_nCurPattern; } + +private: + int m_nCurPattern; + int m_mpalCode; + RMPoint m_hot; + RMRect m_rcBox; + int m_nSprites,m_nSfx,m_nPatterns; + byte m_bPal; + RMPalette m_pal; + + RMSprite *m_sprites; + RMSfx *m_sfx; + RMPattern *m_patterns; + + byte m_bCurFlag; + int m_nCurSprite; + bool m_bIsActive; + HANDLE m_hEndPattern; + bool m_bInitCurPattern; + +public: + RMPoint CalculatePos(void); + +public: + RMItem(); + virtual ~RMItem(); + + friend RMDataStream& operator>>(RMDataStream &ds, RMItem &item); + + // Processa l'oggetto per fare andare avanti eventuale animazioni. Ritorna TRUE se dovr + // essere ridisegnato il prossimo frame + bool DoFrame(RMGfxTargetBuffer *bigBuf, bool bAddToList = true); + + // Setta la posizione corrente di scrolling + void SetScrollPosition(RMPoint scroll); + + // Overloading della funzione per la rimozione da ot list + virtual bool RemoveThis(); + + // Overloading del draw + virtual void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + + // Overloading della priorit: la Z + virtual int Priority() { return m_z; } + + // Numero di pattern + int NumPattern() { return m_nPatterns; } + + // Setta un nuovo pattern di animazione, cambiando bruscamente da quello corrente + virtual void SetPattern(int nPattern, bool bPlayP0 = false); + + // Setta un nuovo status. + void SetStatus(int nStatus); + + bool IsIn(RMPoint pt, int* size=NULL); + RMPoint Hotspot() { return m_hot; } + bool GetName(RMString& name); + int MpalCode() { return m_mpalCode; } + + // Scarica l'item + void Unload(void); + + // Aspetta la fine del pattern in play + void WaitForEndPattern(HANDLE hCustomSkip = INVALID_HANDLE_VALUE); + + // Setta un nuovo hotspot per l'oggetto + void ChangeHotspot(RMPoint pt); + + void SetInitCurPattern(bool status) { m_bInitCurPattern=status; } + + void PlaySfx(int nSfx); + +void ReadFromStream(RMDataStream& ds, bool bLOX=false); + + void PauseSound(bool bPause); + +protected: + // Crea una primitiva che ha come task l'item stesso + virtual RMGfxPrimitive *NewItemPrimitive(); + + // Alloca la memoria per gli sprites + virtual RMGfxSourceBuffer* NewItemSpriteBuffer(int dimx, int dimy, bool bPreRLE); +}; + + #define MAXBOXES 50 // Non si puo' cambiare, comanda cosi' il boxed #define MAXHOTSPOT 20 // Idem @@ -122,6 +381,225 @@ public: void LoadState(byte *buf); }; +class RMCharacter : protected RMItem { +public: + enum PATTERNS { + PAT_STANDUP = 1, + PAT_STANDDOWN, + PAT_STANDLEFT, + PAT_STANDRIGHT, + PAT_WALKUP, + PAT_WALKDOWN, + PAT_WALKLEFT, + PAT_WALKRIGHT + }; + +private: + enum STATUS { + STAND, + WALK + }; + + signed short walkcount; + int dx, dy, olddx, olddy; + float fx, fy, slope; + RMPoint linestart, lineend, pathend; + signed char walkspeed, walkstatus; + char minpath; + short nextbox; + short path[MAXBOXES]; + short pathlenght, pathcount; + int curbox; + + STATUS status; + int curSpeed; + bool bEndOfPath; + HANDLE hEndOfPath; + OSystem::MutexRef csMove; + int curLocation; + bool bRemoveFromOT; + bool bMovingWithoutMinpath; + RMGameBoxes *theBoxes; + + RMPoint m_fixedScroll; + +private: + int InWhichBox(RMPoint pt); + + short FindPath(short source, short destination); + RMPoint Searching(char UP, char DOWN, char RIGHT, char LEFT, RMPoint punto); + RMPoint NearestPoint(RMPoint punto); + + void GoTo(RMPoint destcoord, bool bReversed=false); + short ScanLine(RMPoint punto); + RMPoint InvScanLine(RMPoint punto); + RMPoint NearestHotSpot(int sourcebox, int destbox); + + void NewBoxEntered(int nBox); + +protected: + bool bMoving; + bool bDrawNow; + bool bNeedToStop; +// virtual RMGfxPrimitive* NewItemPrimitive(); + +public: + RMCharacter(); + virtual ~RMCharacter(); + + void LinkToBoxes(RMGameBoxes* theBoxes); + + virtual bool RemoveThis(void); + + // Aggiorna la posizione del personaggio + void DoFrame(RMGfxTargetBuffer* bigBuf, int loc); + + // Overloading del Draw + void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); + + // TRUE se si appena fermato + bool EndOfPath() { return bEndOfPath; } + + // Cambia il pattern del personaggio per fermarlo + virtual void Stop(void); + + // Controlla se il personaggio si sta muovendo + bool IsMoving() { return bMoving; } + + // Muove il personaggio a una certa posizione + bool Move(RMPoint pt); + + // Posiziona il personaggio a una certa posizione SENZA farlo muovere + void SetPosition(RMPoint pt, int newloc=-1); + + // Aspetta la fine del movimento + void WaitForEndMovement(void) { if (bMoving) WaitForSingleObject(hEndOfPath, INFINITE); } + + void SetFixedScroll(RMPoint fix) { m_fixedScroll = fix; } + void SetSpeed(int speed) { curSpeed=speed; } +}; + + +class RMWipe : public RMGfxTask { +private: + bool m_bFading; + bool m_bEndFade; + bool m_bUnregister; + HANDLE m_hUnregistered; + int m_nFadeStep; + HANDLE m_hEndOfFade; + bool m_bMustRegister; + + RMItem m_wip0r; + +public: + RMWipe(); + virtual ~RMWipe(); + + void DoFrame(RMGfxTargetBuffer& bigBuf); + void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); + + void InitFade(int type); + void CloseFade(void); + void WaitForFadeEnd(void); + + virtual void Unregister(void); + virtual bool RemoveThis(void); + virtual int Priority(void); +}; + + +/** + * Location + */ +class RMLocation : public RMGfxTaskSetPrior { +public: + RMString m_name; // Nome + + private: + RMColorMode m_cmode; // Color mode + RMGfxSourceBuffer* m_buf; // Immagine della locazione + + int m_nItems; // Numero oggetti +RMItem* m_items; // Oggetti + + RMPoint m_curScroll; // Posizione corrente di scroll + RMPoint m_fixedScroll; + +public: + // @@@@@@@@@@@@@@@@@@@@@@@ + RMPoint TEMPTonyStart; + RMPoint TEMPGetTonyStart() { return TEMPTonyStart; } + + int TEMPNumLoc; + int TEMPGetNumLoc() { return TEMPNumLoc; } + +public: + RMLocation(); + virtual ~RMLocation(); + + // Caricamento da disco + bool Load(char *lpszFileName); + bool Load(HANDLE hFile); + bool Load(byte *buf); + bool Load(RMDataStream &ds); + bool LoadLOX(RMDataStream &ds); + + // Scaricamento + void Unload(void); + + // Overloading del Draw + void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + + // Prepara un frame disegnando la locazione e tutti i suoi item + void DoFrame(RMGfxTargetBuffer *bigBuf); + + // Si fa dare il numero dell'item + RMItem* WhichItemIsIn(RMPoint pt); + + // Si fa dare un elemento dal suo codice MPAL + RMItem* GetItemFromCode(uint32 dwCode); + + // Setta la posizione corrente di scrolling + void SetScrollPosition(RMPoint &scroll); + + // Setta un offset aggiuntivo di scrolling da aggiungere sempre + void SetFixedScroll(RMPoint &scroll); + + // Aggiorna le coordinate di scrolling in modo da visualizzare sempre il punto fornito + void UpdateScrolling(RMPoint ptShowThis); + + // Legge la posizione di scrolling corrente + RMPoint ScrollPosition() { return m_curScroll; } + + // Pausa sonoro + void PauseSound(bool bPause); +}; + + +/** + * MPAL message, composed of more ASCIIZ + */ +class RMMessage { +private: + char *lpMessage; + char *lpPeriods[256]; + int nPeriods; + +private: + void ParseMessage(void); + +public: + RMMessage(uint32 dwId); + virtual ~RMMessage(); + + bool IsValid() { return lpMessage != NULL; } + int NumPeriods() { return nPeriods; } + char *Period(int num) { return lpPeriods[num]; } + char *operator[](int num) { return lpPeriods[num]; } +}; + + } // End of namespace Tony #endif /* TONY_H */ diff --git a/engines/tony/module.mk b/engines/tony/module.mk index 6aeb0a1583..cbc07d27b7 100644 --- a/engines/tony/module.mk +++ b/engines/tony/module.mk @@ -2,7 +2,12 @@ MODULE := engines/tony MODULE_OBJS := \ detection.o \ + game.o \ + gfxcore.o \ + gfxengine.o \ + input.o \ loc.o \ + sound.o \ tony.o \ utils.o \ mpal/expr.o \ diff --git a/engines/tony/mpal/memory.h b/engines/tony/mpal/memory.h index dde2e8908c..fde0d33b3e 100644 --- a/engines/tony/mpal/memory.h +++ b/engines/tony/mpal/memory.h @@ -75,6 +75,10 @@ public: #define GlobalUnlock(handle) {} #define GlobalSize(handle) (_vm->_memoryManager.getItem(handle).Size()) +#define GMEM_FIXED 1 +#define GMEM_MOVEABLE 2 +#define GMEM_ZEROINIT 4 + } // end of namespace MPAL } // end of namespace Tony diff --git a/engines/tony/mpal/stubs.h b/engines/tony/mpal/stubs.h index be856790bc..a8d3253ddb 100644 --- a/engines/tony/mpal/stubs.h +++ b/engines/tony/mpal/stubs.h @@ -47,10 +47,6 @@ typedef uint32 (*LPTHREAD_START_ROUTINE)(void *lpThreadParameter); * Defines \****************************************************************************/ -#define GMEM_FIXED 1 -#define GMEM_MOVEABLE 2 -#define GMEM_ZEROINIT 4 - #define MB_OK 1 #define PASCAL diff --git a/engines/tony/resid.h b/engines/tony/resid.h new file mode 100644 index 0000000000..01ed9b9bd2 --- /dev/null +++ b/engines/tony/resid.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. + * + */ +/* + * ResID.H - Include per le risorse MPAL + * + * Coded by Giovanni Bajo - Nayma/Prograph + * + * (C) 1997-98, Nayma Software + * (C) 1998, Prograph Research srl + * + */ + +/* + Da 10500 in poi ci sono gli .OGG per l'inventario e i ritagli +*/ +#ifndef TONY_RESID_H +#define TONY_RESID_H + + +#define RES_I_INTERFACE 10300 +#define RES_I_INTERPAL 10301 +#define RES_I_INTERPPAL 10302 +#define RES_I_INTERP1 10303 +#define RES_I_INTERP2 10304 +#define RES_I_INTERP3 10305 +#define RES_I_INTERP4 10306 +#define RES_I_INTERP5 10307 + +#define RES_I_DLGTEXT 10350 +#define RES_I_DLGTEXTLINE 10351 +#define RES_I_DLGTEXTPAL 10352 + +#define RES_I_MINIINTER 10360 + +#define RES_P_PAL 10410 +#define RES_P_GO 10400 +#define RES_P_TAKE 10401 +#define RES_P_USE 10402 +#define RES_P_EXAM 10403 +#define RES_P_TALK 10404 + +#define RES_P_PAP1 10420 +#define RES_P_PAP2 10421 +#define RES_P_PAP3 10422 +#define RES_P_PAP4 10423 +#define RES_P_FRMAP 10424 + +#define RES_F_PAL 10700 +#define RES_F_PARL 10701 +#define RES_F_OBJ 10702 +#define RES_F_MACC 10703 +#define RES_F_CREDITS 10704 +#define RES_F_CPAL 10705 + +#define RES_W_CERCHIO 10800 + +#endif diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp new file mode 100644 index 0000000000..5d940b3145 --- /dev/null +++ b/engines/tony/sound.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. + * + */ +/************************************************************************** + * 様様様様様様様様様様様様様様様様様 * + * Nayma Software srl * + * e -= We create much MORE than ALL =- * + * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * + * .d" d$$$$$b "b. * + * .z$* d$$$$$$$L ^*$c. * + * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * + * ^*$b 4$$$$$$$$$F .d$*" * + * ^$$. 4$$$$$$$$$F .$P" Module: Sound.CPP............ * + * *$. '$$$$$$$$$ 4$P 4 * + * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * + * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * + * z$" "" #$F^ "" '$c * + * z$$beu .ue=" $ "=e.. .zed$$c * + * "#$e z$*" . `. ^*Nc e$"" * + * "$$". .r" ^4. .^$$" * + * ^.@*"6L=\ebu^+C$"*b." * + * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * + * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * + * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * + * * + * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * + * * + **************************************************************************/ + +#include "tony/game.h" + +namespace Tony { + + + +} // End of namespace Tony diff --git a/engines/tony/sound.h b/engines/tony/sound.h new file mode 100644 index 0000000000..75a70553ef --- /dev/null +++ b/engines/tony/sound.h @@ -0,0 +1,254 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ +/************************************************************************** + * 様様様様様様様様様様様様様様様様様 * + * Nayma Software srl * + * e -= We create much MORE than ALL =- * + * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * + * .d" d$$$$$b "b. * + * .z$* d$$$$$$$L ^*$c. * + * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * + * ^*$b 4$$$$$$$$$F .d$*" * + * ^$$. 4$$$$$$$$$F .$P" Module: Sound.CPP............ * + * *$. '$$$$$$$$$ 4$P 4 * + * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * + * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * + * z$" "" #$F^ "" '$c * + * z$$beu .ue=" $ "=e.. .zed$$c * + * "#$e z$*" . `. ^*Nc e$"" * + * "$$". .r" ^4. .^$$" * + * ^.@*"6L=\ebu^+C$"*b." * + * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * + * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * + * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * + * * + * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * + * * + **************************************************************************/ + +#ifndef TONY_SOUND_H +#define TONY_SOUND_H + +#include "tony/gfxcore.h" +#include "tony/loc.h" +#include "tony/utils.h" + +namespace Tony { + +class FPSFX; + +enum CODECS { + FPCODEC_RAW, + FPCODEC_ADPCM, + FPCODEC_WAV +}; + +class FPSFX { + +/****************************************************************************\ +* Attributi +\****************************************************************************/ + +private: +/* + HWND hwnd; + LPDIRECTSOUND lpDS; + LPDIRECTSOUNDBUFFER lpDSBuffer; // Buffer DirectSound +*/ + bool bSoundSupported; // TRUE se il suono e' attivo + bool bFileLoaded; // TRUE se e' stato aperto un file + bool bLoop; // TRUE se bisogna loopare l'effetto sonoro + bool bPaused; + int lastVolume; + + bool bStereo; // TRUE se stereo + bool b16bit; // TRUE se 16 bit + uint32 dwFreq; // Frequenza originale di campionamento + +// CODEC* lpCodec; // CODEC da utilizzare. + bool bIsPlaying; // TRUE se si sta playando l'effetto sonoro + + bool bIsVoice; + +// LPDIRECTSOUNDNOTIFY lpDSNotify; // Notify degli hotspot nel buffer +// DSBPOSITIONNOTIFY dspnHot[2]; + +public: +// HANDLE hEndOfBuffer; + +private: + + +/****************************************************************************\ +* Metodi +\****************************************************************************/ + +public: + +/****************************************************************************\ +* +* Function: FPSFX(LPDIRECTSOUND lpDS, bool bSoundOn); +* +* Description: Costruttore di default. *NON* bisogna dichiarare direttamente +* un oggetto, ma crearlo piuttosto tramite FPSOUND::CreateSfx() +* +\****************************************************************************/ + + FPSFX(void * /*LPDIRECTSOUND */lpDS, uint32 /*HWND*/ hwnd, bool bSoundOn); + + +/****************************************************************************\ +* +* Function: ~FPSFX(); +* +* Description: Distruttore di default. Si preoccupa anche di fermare il sound +* effect eventualmente in esecuzione, e disallocare la memoria +* da esso occupata. +* +\****************************************************************************/ + + ~FPSFX(); + + +/****************************************************************************\ +* +* Function: Release(); +* +* Description: Rilascia la memoria dell'oggetto. Deve essere richiamata quando +* l'oggetto non serve piu' e **SOLO SE** l'oggetto e' stato +* creato con la FPSOUND::CreateStream(). +* +* Note: Eventuali puntatori all'oggetto non sono piu' validi dopo +* questa chiamata. +* +\****************************************************************************/ + + void Release(); + + +/****************************************************************************\ +* +* Function: bool LoadFile(char *lpszFileName, uint32 dwCodec=FPCODEC_RAW); +* +* Description: Apre un file di effetto sonoro e lo carica. +* +* Input: char *lpszFile Nome del file di sfx da aprire +* uint32 dwCodec CODEC da utilizzare per decomprimere +* i campioni sonori +* +* Return: TRUE se tutto OK, FALSE in caso di errore +* +\****************************************************************************/ + + bool LoadFile(char *lpszFileName, uint32 dwCodec = FPCODEC_RAW); + bool LoadFile(byte *lpBuf, uint32 dwCodec); + bool LoadVoiceFromVDB(HANDLE hvdb); + + +/****************************************************************************\ +* +* Function: bool Play(); +* +* Description: Suona lo sfx caricato. +* +* Return: TRUE se tutto OK, FALSE in caso di errore. +* +\****************************************************************************/ + + bool Play(); + + +/****************************************************************************\ +* +* Function: bool Stop(); +* +* Description: Ferma il play dello sfx. +* +* Return: TRUE se tutto OK, FALSE in caso di errore. +* +\****************************************************************************/ + + bool Stop(); + + +/****************************************************************************\ +* +* Function: void Pause(bool bPause); +* +* Description: Pause dell'effetto sonoro +* +\****************************************************************************/ + + void Pause(bool bPause); + + +/****************************************************************************\ +* +* Function: bool SetLoop(bool bLoop); +* +* Description: Attiva o disattiva il loop dello sfx. +* +* Input: bool bLoop TRUE per attivare il loop, FALSE per +* disattivarlo +* +* Note: Il loop deve essere attivato PRIMA di eseguire il play +* dello sfx. Qualsiasi modifica effettuata durante il play +* non avra' effetto fino a che lo sfx non viene fermato, +* e poi rimesso in play. +* +\****************************************************************************/ + + void SetLoop(bool bLoop); + + + +/****************************************************************************\ +* +* Function: void SetVolume(int dwVolume); +* +* Description: Cambia il volume dello sfx +* +* Input: int dwVolume Volume da settare (0-63) +* +\****************************************************************************/ + + void SetVolume(int dwVolume); + + + +/****************************************************************************\ +* +* Function: void GetVolume(int * lpdwVolume); +* +* Description: Chiede il volume dello sfx +* +* Input: int * lpdwVolume Variabile in cui verra' inserito +* il volume corrente +* +\****************************************************************************/ + + void GetVolume(int * lpdwVolume); +}; + +} // End of namespace Tony + +#endif diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index d5a5e467df..a370c8efaf 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -85,6 +85,9 @@ Common::ErrorCode TonyEngine::Init() { // Initialise the boxes _theBoxes.Init(); + // Link to the custom graphics engine + + return Common::kNoError; } diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 384b7a1f4c..a372260c34 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -33,6 +33,7 @@ #include "tony/mpal/mpal.h" #include "tony/mpal/memory.h" +#include "tony/gfxEngine.h" #include "tony/loc.h" #include "tony/utils.h" @@ -91,6 +92,7 @@ public: Common::Array _voices; // Bounding box list manager RMGameBoxes _theBoxes; + RMGfxEngine _theEngine; public: TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc); virtual ~TonyEngine(); diff --git a/engines/tony/tonychar.h b/engines/tony/tonychar.h new file mode 100644 index 0000000000..9d3c0202d0 --- /dev/null +++ b/engines/tony/tonychar.h @@ -0,0 +1,448 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ +/************************************************************************** + * 様様様様様様様様様様様様様様様様様 * + * Nayma Software srl * + * e -= We create much MORE than ALL =- * + * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * + * .d" d$$$$$b "b. * + * .z$* d$$$$$$$L ^*$c. * + * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * + * ^*$b 4$$$$$$$$$F .d$*" * + * ^$$. 4$$$$$$$$$F .$P" Module: TonyChar.CPP......... * + * *$. '$$$$$$$$$ 4$P 4 * + * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * + * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * + * z$" "" #$F^ "" '$c * + * z$$beu .ue=" $ "=e.. .zed$$c * + * "#$e z$*" . `. ^*Nc e$"" * + * "$$". .r" ^4. .^$$" * + * ^.@*"6L=\ebu^+C$"*b." * + * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * + * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * + * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * + * * + * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * + * * + **************************************************************************/ + +#ifndef TONY_TONYCHAR_H +#define TONY_TONYCHAR_H + +#include "tony/mpal/stubs.h" + +namespace Tony { + +class RMTony : public RMCharacter { +private: + enum DIRECTION { + UP, DOWN, LEFT, RIGHT + }; + +public: + enum TALKTYPE { + TALK_NORMAL, + TALK_FIANCHI, + TALK_CANTA, + TALK_RIDE, + TALK_SIINDICA, + TALK_SPAVENTATO, + TALK_SPAVENTATO2, + TALK_CONBICCHIERE, + TALK_CONMARTELLO, + TALK_CONVERME, + TALK_CONCORDA, + TALK_CONCONIGLIO, + TALK_CONRICETTA, + TALK_CONCARTE, + TALK_CONPUPAZZO, + TALK_CONPUPAZZOSTATIC, + TALK_CONCONIGLIOSTATIC, + TALK_CONRICETTASTATIC, + TALK_CONCARTESTATIC, + TALK_CONTACCUINOSTATIC, + TALK_CONMEGAFONOSTATIC, + TALK_CONBARBASTATIC, + TALK_RIDE2, + TALK_SCHIFATO, + TALK_NAAH, + TALK_MACBETH1, + TALK_MACBETH2, + TALK_MACBETH3, + TALK_MACBETH4, + TALK_MACBETH5, + TALK_MACBETH6, + TALK_MACBETH7, + TALK_MACBETH8, + TALK_MACBETH9, + TALK_SPAVENTATOSTATIC, + TALK_CONSEGRETARIA + }; + +private: + bool m_bShow; + bool m_bShowOmbra; + bool m_bCorpoDavanti; + RMGfxSourceBuffer8AB m_ombra; + bool m_bActionPending; + RMItem *m_ActionItem; + int m_Action; + int m_ActionParm; + static bool m_bAction; + + bool m_bPastorella; + + bool m_bIsStaticTalk; + bool m_bIsTalking; + int m_nPatB4Talking; + TALKTYPE m_nTalkType; + DIRECTION m_TalkDirection; + RMPoint m_nBodyOffset; + + int m_nTimeLastStep; + + RMItem m_body; + HANDLE hActionThread; + +protected: + // Overload dell'allocazione degli sprites per cambiare il tipo + virtual RMGfxSourceBuffer* NewItemSpriteBuffer(int dimx, int dimy, bool bPreRLE); + + // Thread che aspetta la fine di un azione + static uint32 WaitEndOfAction(HANDLE hThread); + +public: // per farlo rialzare, altrimenti private + enum PATTERNS { + PAT_TAKEUP_UP1 = 9, + PAT_TAKEUP_UP2, + PAT_TAKEUP_MID1, + PAT_TAKEUP_MID2, + PAT_TAKEUP_DOWN1, + PAT_TAKEUP_DOWN2, + + PAT_TAKELEFT_UP1, + PAT_TAKELEFT_UP2, + PAT_TAKELEFT_MID1, + PAT_TAKELEFT_MID2, + PAT_TAKELEFT_DOWN1, + PAT_TAKELEFT_DOWN2, + + PAT_TAKERIGHT_UP1, + PAT_TAKERIGHT_UP2, + PAT_TAKERIGHT_MID1, + PAT_TAKERIGHT_MID2, + PAT_TAKERIGHT_DOWN1, + PAT_TAKERIGHT_DOWN2, + + PAT_SIRIALZALEFT, + PAT_PERTERRALEFT, + PAT_SIRIALZARIGHT, + PAT_PERTERRARIGHT, + + // Pastorella! + PAT_PAST_WALKUP, + PAT_PAST_WALKDOWN, + PAT_PAST_WALKLEFT, + PAT_PAST_WALKRIGHT, + + PAT_PAST_STANDUP, + PAT_PAST_STANDDOWN, + PAT_PAST_STANDLEFT, + PAT_PAST_STANDRIGHT, + + // Parlata + PAT_TALK_UP, + PAT_TALK_DOWN, + PAT_TALK_LEFT, + PAT_TALK_RIGHT, + + // Testa statica + PAT_TESTA_UP, + PAT_TESTA_DOWN, + PAT_TESTA_LEFT, + PAT_TESTA_RIGHT, + + // Risata + PAT_RIDELEFT_START, + PAT_RIDELEFT_LOOP, + PAT_RIDELEFT_END, + PAT_RIDERIGHT_START, + PAT_RIDERIGHT_LOOP, + PAT_RIDERIGHT_END, + + // Parlata da pastorella + PAT_PAST_TALKUP, + PAT_PAST_TALKDOWN, + PAT_PAST_TALKLEFT, + PAT_PAST_TALKRIGHT, + + // Spavento + PAT_SPAVENTOLEFT_START, + PAT_SPAVENTOLEFT_LOOP, + PAT_SPAVENTOLEFT_END, + PAT_SPAVENTORIGHT_START, + PAT_SPAVENTORIGHT_LOOP, + PAT_SPAVENTORIGHT_END, + PAT_SPAVENTODOWN_START, + PAT_SPAVENTODOWN_LOOP, + PAT_SPAVENTODOWN_END, + + // Con oggetti: corpo completo + PAT_CONBICCHIERE, + PAT_CONCORDA, + PAT_CONVERME, + PAT_CONMARTELLO, + + // Suona il fischietto + PAT_FISCHIETTORIGHT, + + // Testa con barba + PAT_TALKBARBA_LEFT, + PAT_TALKBARBA_RIGHT, + + // Sniff + PAT_SNIFFA_LEFT, + PAT_SNIFFA_RIGHT, + + // Schifato + PAT_SCHIFATOLEFT_START, + PAT_SCHIFATOLEFT_LOOP, + PAT_SCHIFATOLEFT_END, + PAT_SCHIFATORIGHT_START, + PAT_SCHIFATORIGHT_LOOP, + PAT_SCHIFATORIGHT_END, + PAT_NAAHLEFT_START, + PAT_NAAHLEFT_LOOP, + PAT_NAAHLEFT_END, + PAT_NAAHRIGHT_START, + PAT_NAAHRIGHT_LOOP, + PAT_NAAHRIGHT_END, + + // Stand spaventato + PAT_SPAVENTOLEFT_STAND, + PAT_SPAVENTORIGHT_STAND, + PAT_SPAVENTODOWN_STAND, + + PAT_PUTLEFT_UP1, + PAT_PUTLEFT_UP2, + PAT_PUTRIGHT_UP1, + PAT_PUTRIGHT_UP2, + PAT_PUTLEFT_MID1, + PAT_PUTLEFT_MID2, + PAT_PUTRIGHT_MID1, + PAT_PUTRIGHT_MID2, + PAT_PUTLEFT_DOWN1, + PAT_PUTLEFT_DOWN2, + PAT_PUTRIGHT_DOWN1, + PAT_PUTRIGHT_DOWN2, + PAT_PUTUP_UP1, + PAT_PUTUP_UP2, + PAT_PUTUP_MID1, + PAT_PUTUP_MID2, + PAT_PUTUP_DOWN1, + PAT_PUTUP_DOWN2, + + PAT_CONSEGRETARIA + }; + + enum BODYPATTERNS { + BPAT_STANDUP = 1, + BPAT_STANDDOWN, + BPAT_STANDLEFT, + BPAT_STANDRIGHT, + + BPAT_MARTELLO, + BPAT_PUPAZZO, + BPAT_VERME, + BPAT_BICCHIERE, + + BPAT_CANTALEFT_START, + BPAT_CANTALEFT_LOOP, + BPAT_CANTALEFT_END, + + BPAT_FIANCHILEFT_START, + BPAT_FIANCHILEFT_LOOP, + BPAT_FIANCHILEFT_END, + BPAT_FIANCHIRIGHT_START, + BPAT_FIANCHIRIGHT_LOOP, + BPAT_FIANCHIRIGHT_END, + BPAT_FIANCHIUP_START, + BPAT_FIANCHIUP_LOOP, + BPAT_FIANCHIUP_END, + BPAT_FIANCHIDOWN_START, + BPAT_FIANCHIDOWN_LOOP, + BPAT_FIANCHIDOWN_END, + + BPAT_RIDELEFT, + BPAT_RIDERIGHT, + + BPAT_SIINDICALEFT, + BPAT_SIINDICARIGHT, + + BPAT_SPAVENTODOWN_START, + BPAT_SPAVENTODOWN_LOOP, + BPAT_SPAVENTODOWN_END, + BPAT_SPAVENTOLEFT_START, + BPAT_SPAVENTOLEFT_LOOP, + BPAT_SPAVENTOLEFT_END, + BPAT_SPAVENTORIGHT_START, + BPAT_SPAVENTORIGHT_LOOP, + BPAT_SPAVENTORIGHT_END, + BPAT_SPAVENTOUP_START, + BPAT_SPAVENTOUP_LOOP, + BPAT_SPAVENTOUP_END, + + BPAT_CORDA, + + BPAT_CONCONIGLIOLEFT_START, + BPAT_CONCONIGLIOLEFT_LOOP, + BPAT_CONCONIGLIOLEFT_END, + BPAT_CONCONIGLIORIGHT_START, + BPAT_CONCONIGLIORIGHT_LOOP, + BPAT_CONCONIGLIORIGHT_END, + + BPAT_CONRICETTALEFT_START, + BPAT_CONRICETTALEFT_LOOP, + BPAT_CONRICETTALEFT_END, + BPAT_CONRICETTARIGHT_START, + BPAT_CONRICETTARIGHT_LOOP, + BPAT_CONRICETTARIGHT_END, + + BPAT_CONCARTELEFT_START, + BPAT_CONCARTELEFT_LOOP, + BPAT_CONCARTELEFT_END, + BPAT_CONCARTERIGHT_START, + BPAT_CONCARTERIGHT_LOOP, + BPAT_CONCARTERIGHT_END, + + BPAT_CONPUPAZZOLEFT_START, + BPAT_CONPUPAZZOLEFT_LOOP, + BPAT_CONPUPAZZOLEFT_END, + BPAT_CONPUPAZZORIGHT_START, + BPAT_CONPUPAZZORIGHT_LOOP, + BPAT_CONPUPAZZORIGHT_END, + + BPAT_CONTACCUINOLEFT_START, + BPAT_CONTACCUINOLEFT_LOOP, + BPAT_CONTACCUINOLEFT_END, + BPAT_CONTACCUINORIGHT_START, + BPAT_CONTACCUINORIGHT_LOOP, + BPAT_CONTACCUINORIGHT_END, + + BPAT_CONMEGAFONOLEFT_START, + BPAT_CONMEGAFONOLEFT_LOOP, + BPAT_CONMEGAFONOLEFT_END, + BPAT_CONMEGAFONORIGHT_START, + BPAT_CONMEGAFONORIGHT_LOOP, + BPAT_CONMEGAFONORIGHT_END, + + BPAT_CONBARBALEFT_START, + BPAT_CONBARBALEFT_END, + BPAT_CONBARBARIGHT_START, + BPAT_CONBARBARIGHT_END, + BPAT_CONBARBALEFT_STATIC, + BPAT_CONBARBARIGHT_STATIC, + + BPAT_MACBETH1, + BPAT_MACBETH2, + BPAT_MACBETH3, + BPAT_MACBETH4, + BPAT_MACBETH5, + BPAT_MACBETH6, + BPAT_MACBETH7, + BPAT_MACBETH8, + BPAT_MACBETH9, + + BPAT_CONSEGRETARIA + }; + +public: + // Inizializza Tony + void Init(void); + + // Libera tutta la memoria + void Close(void); + + // Fa un frame di Tony, aggiornando il movimento, etc + void DoFrame(RMGfxTargetBuffer *bigBuf, int curLoc); + + // Metodi di Draw, che controlla la variabile di show + void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + + // Mostra o nascondi + void Show(void); + void Hide(bool bShowOmbra = false); + + // Si muove e fa un azione, se necessario + void MoveAndDoAction(RMPoint dst, RMItem *item, int nAction, int nActionParm = 0); + + // Ferma Tony (dalla parte giusta rispetto a un eventuale oggetto) + virtual void Stop(void); + void StopNoAction(void); + + // Setta un pattern + void SetPattern(int npatt, bool bPlayP0 = false); + + // Legge il pattern corrente + int GetCurPattern(); + + // Attende la fine di un pattern + void WaitForEndPattern(HANDLE hCustomSkip = INVALID_HANDLE_VALUE) { RMCharacter::WaitForEndPattern(hCustomSkip);} + + // Controlla se si trova in azione + bool InAction() { return (m_bActionPending&&m_Action != 0) | m_bAction; } + + // Controlla se c' da aggiornare il movimento di scrolling + bool MustUpdateScrolling() { return ((!InAction()) || (IsMoving())); } + + // Prende la posizione di Tony + RMPoint Position() { return m_pos; } + + // Setta la posizione di scrolling + void SetScrollPosition(RMPoint pt) { RMCharacter::SetScrollPosition(pt); } + + // Setta l'animazione di Take + void Take(int nWhere, int nPart); + void Put(int nWhere, int nPart); + + // Start e End Talk + void StartTalk(TALKTYPE nTalkType); + void EndTalk(void); + + // Start e End Static + void StartStatic(TALKTYPE nTalkType); + void EndStatic(TALKTYPE nTalkType); + + // Tony si traveste! + void SetPastorella(bool bIsPast) { m_bPastorella=bIsPast; } + int GetPastorella(void) { return m_bPastorella; } + + // Esegue una azione + void ExecuteAction(int nAction, int nActionItem, int nParm); + + void PlaySfx(int nSfx) { RMItem::PlaySfx(nSfx); } +}; + + +} // End of namespace Tony + +#endif diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index 76d168e27a..48dcb9392a 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -28,14 +28,14 @@ * .z$* d$$$$$$$L ^*$c. * * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * * ^*$b 4$$$$$$$$$F .d$*" * - * ^$$. 4$$$$$$$$$F .$P" Module: Loc.CPP.............. * + * ^$$. 4$$$$$$$$$F .$P" Module: Utils.CPP............ * * *$. '$$$$$$$$$ 4$P 4 * * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c Desc: Classi di gestione * - * z$$beu .ue=" $ "=e.. .zed$$c dei dati di una loca- * - * "#$e z$*" . `. ^*Nc e$"" zione................ * - * "$$". .r" ^4. .^$$" ..................... * + * z$" "" #$F^ "" '$c * + * z$$beu .ue=" $ "=e.. .zed$$c * + * "#$e z$*" . `. ^*Nc e$"" * + * "$$". .r" ^4. .^$$" * * ^.@*"6L=\ebu^+C$"*b." * * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * diff --git a/engines/tony/utils.h b/engines/tony/utils.h index bec42b343b..54e4cd0eae 100644 --- a/engines/tony/utils.h +++ b/engines/tony/utils.h @@ -28,14 +28,14 @@ * .z$* d$$$$$$$L ^*$c. * * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * * ^*$b 4$$$$$$$$$F .d$*" * - * ^$$. 4$$$$$$$$$F .$P" Module: Loc.CPP.............. * + * ^$$. 4$$$$$$$$$F .$P" Module: Utils.CPP............ * * *$. '$$$$$$$$$ 4$P 4 * * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c Desc: Classi di gestione * - * z$$beu .ue=" $ "=e.. .zed$$c dei dati di una loca- * - * "#$e z$*" . `. ^*Nc e$"" zione................ * - * "$$". .r" ^4. .^$$" ..................... * + * z$" "" #$F^ "" '$c * + * z$$beu .ue=" $ "=e.. .zed$$c * + * "#$e z$*" . `. ^*Nc e$"" * + * "$$". .r" ^4. .^$$" * * ^.@*"6L=\ebu^+C$"*b." * * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * -- cgit v1.2.3 From 68bcaa61b9eb1108028b3db072ade95431b9f14f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 30 Apr 2012 23:16:19 +1000 Subject: TONY: More header files and functionality added --- engines/tony/adv.h | 35 + engines/tony/custom.cpp | 2511 +++++++++++++++++++++++++++++++++++++++++++ engines/tony/custom.h | 106 ++ engines/tony/detection.cpp | 4 + engines/tony/font.h | 12 +- engines/tony/game.cpp | 1148 ++++++++++++++++++++ engines/tony/gfxcore.h | 2 +- engines/tony/gfxengine.h | 4 +- engines/tony/input.h | 2 +- engines/tony/loc.h | 6 +- engines/tony/module.mk | 1 + engines/tony/mpal/lzo.cpp | 14 + engines/tony/mpal/lzo.h | 11 + engines/tony/mpal/stubs.cpp | 10 + engines/tony/mpal/stubs.h | 8 + engines/tony/sound.h | 365 ++++++- engines/tony/tony.cpp | 68 +- engines/tony/tony.h | 94 +- engines/tony/tonychar.h | 1 + engines/tony/utils.cpp | 2 +- engines/tony/window.h | 134 +++ 21 files changed, 4512 insertions(+), 26 deletions(-) create mode 100644 engines/tony/custom.cpp create mode 100644 engines/tony/custom.h create mode 100644 engines/tony/window.h (limited to 'engines') diff --git a/engines/tony/adv.h b/engines/tony/adv.h index b29e4eb0cd..aab7df24af 100644 --- a/engines/tony/adv.h +++ b/engines/tony/adv.h @@ -48,8 +48,24 @@ #ifndef TONY_ADV_H #define TONY_ADV_H +#include "tony/mpal/memory.h" +#include "tony/gfxcore.h" + + namespace Tony { +// X & Y dimensions of the adventure +#define RM_SX 640 +#define RM_SY 480 + +// Dimensioni X&Y del bigbuf +#define RM_BBX (RM_SX) +#define RM_BBY (RM_SY) + +// Skipping X&Y +#define RM_SKIPY ((RM_BBY - RM_SY) / 2) +#define RM_SKIPX 0 + // Tony's actions enum RMTonyAction { TA_GOTO = 0, @@ -65,6 +81,25 @@ enum RMTonyAction { TA_RECEIVECOMBINEGIVE }; +// Funzioni globali +HANDLE MainLoadLocation(int nLoc, RMPoint pt, RMPoint start); +HANDLE MainUnloadLocation(bool bDoOnExit); +void MainLinkGraphicTask(RMGfxTask *task); +void MainFreeze(void); +void MainUnfreeze(void); +void MainWaitFrame(void); +void MainShowMouse(void); +void MainHideMouse(void); +void MainEnableInput(void); +void MainDisableInput(void); +void MainPlayMusic(int nChannel, const char *fn, int nFX, bool bLoop, int nSync); +void MainInitWipe(int type); +void MainCloseWipe(void); +void MainWaitWipeEnd(void); +void MainEnableGUI(void); +void MainDisableGUI(void); +void MainSetPalesati(bool bPalesati); + } // End of namespace Tony #endif diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp new file mode 100644 index 0000000000..55f6cbe77d --- /dev/null +++ b/engines/tony/custom.cpp @@ -0,0 +1,2511 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * + */ +/************************************************************************** + * 様様様様様様様様様様様様様様様様様 * + * Nayma Software srl * + * e -= We create much MORE than ALL =- * + * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * + * .d" d$$$$$b "b. * + * .z$* d$$$$$$$L ^*$c. * + * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * + * ^*$b 4$$$$$$$$$F .d$*" * + * ^$$. 4$$$$$$$$$F .$P" Module: Custom.CPP........... * + * *$. '$$$$$$$$$ 4$P 4 * + * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * + * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * + * z$" "" #$F^ "" '$c Desc: Custom functions..... * + * z$$beu .ue=" $ "=e.. .zed$$c ..................... * + * "#$e z$*" . `. ^*Nc e$"" ..................... * + * "$$". .r" ^4. .^$$" ..................... * + * ^.@*"6L=\ebu^+C$"*b." * + * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * + * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * + * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * + * * + * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * + * * + ************************************************************************** + */ + +#include "common/system.h" +#include "common/savefile.h" +#include "tony/mpal/mpal.h" +#include "tony/mpal/memory.h" +#include "tony/adv.h" +#include "tony/custom.h" +#include "tony/font.h" +#include "tony/game.h" +#include "tony/gfxcore.h" +#include "tony/tony.h" +#include "tony/tonychar.h" +#include "tony/utils.h" + +namespace Tony { + +extern bool bPatIrqFreeze; + +RMTony *Tony; +RMPointer *Pointer; +RMGameBoxes *Boxes; +RMLocation *Loc; +RMInventory *Inventory; +RMInput *Input; + +HANDLE (*LoadLocation)(int, RMPoint, RMPoint start); +HANDLE (*UnloadLocation)(bool bDoOnExit); +void (*LinkGraphicTask)(RMGfxTask *task); +void (*Freeze)(void); +void (*Unfreeze)(void); +void (*WaitFrame)(void); +void (*PlayMusic)(int nChannel, const char *fileName, int nFX, bool bLoop, int nSync); +void (*WaitWipeEnd)(void); +void (*CloseWipe)(void); +void (*InitWipe)(int type); +void (*EnableGUI)(void); +void (*DisableGUI)(void); +void (*SetPalesati)(bool bpal); + +uint32 dwTonyNumTexts = 0; +bool bTonyInTexts = false; +bool bStaticTalk = false; +RMTony::TALKTYPE nTonyNextTalkType; + +RMPoint StartLocPos[256]; +OSystem::MutexRef cs[10]; +OSystem::MutexRef vdb; +HANDLE mut[10]; + +bool bSkipIdle = false; +HANDLE hSkipIdle; + +int lastMusic = 0, lastTappeto = 0; + +int tappeti[200]; + +#define T_GRILLI 1 +#define T_GRILLIOV 2 +#define T_GRILLIVENTO 3 +#define T_GRILLIVENTO1 4 +#define T_VENTO 5 +#define T_MARE 6 +#define T_MAREMETA 7 + +char* tappetiFile[] = { + "None", + "1.ADP", // Grilli.WAV + "2.ADP", // Grilli-Ovattati.WAV + "3.ADP", // Grilli-Vento.WAV + "3.ADP", // Grilli-Vento1.WAV + "5.ADP", // Vento1.WAV + "4.ADP", // Mare1.WAV + "6.ADP" // Mare1.WAV met volume +}; + +struct { + uint32 code; + RMItem *item; + byte r, g, b; + int talkpattern; + int standpattern; + int starttalkpattern, endtalkpattern; + int numtexts; + + void Save(Common::OutSaveFile *f) { + f->writeUint32LE(code); + f->writeUint32LE(0); + f->writeByte(r); + f->writeByte(g); + f->writeByte(b); + f->writeUint32LE(talkpattern); + f->writeUint32LE(standpattern); + f->writeUint32LE(starttalkpattern); + f->writeUint32LE(endtalkpattern); + f->writeUint32LE(numtexts); + } + void Load(Common::InSaveFile *f) { + code = f->readUint32LE(); + f->readUint32LE(); + item = NULL; + r = f->readByte(); + g = f->readByte(); + b = f->readByte(); + talkpattern = f->readUint32LE(); + standpattern = f->readUint32LE(); + starttalkpattern = f->readUint32LE(); + endtalkpattern = f->readUint32LE(); + numtexts = f->readUint32LE(); + } +} Character[16]; + +struct { + uint32 code; + RMItem *item; + byte r, g, b; + int x, y; + int numtalks[10]; + int curgroup; + int numtexts; + bool bInTexts; + int curTalk; + bool bAlwaysBack; + + void Save(Common::OutSaveFile *f) { + f->writeUint32LE(code); + f->writeUint32LE(0); + f->writeByte(r); + f->writeByte(g); + f->writeByte(b); + f->writeUint32LE(x); + f->writeUint32LE(y); + for (int i = 0; i < 10; ++i) + f->writeUint32LE(numtalks[i]); + f->writeUint32LE(curgroup); + f->writeUint32LE(numtexts); + f->writeByte(bInTexts); + f->writeUint32LE(curTalk); + f->writeByte(bAlwaysBack); + } + void Load(Common::InSaveFile *f) { + code = f->readUint32LE(); + f->readUint32LE(); + item = NULL; + r = f->readByte(); + g = f->readByte(); + b = f->readByte(); + x = f->readUint32LE(); + y = f->readUint32LE(); + for (int i = 0; i < 10; ++i) + numtalks[i] = f->readUint32LE(); + curgroup = f->readUint32LE(); + numtexts = f->readUint32LE(); + bInTexts = f->readByte(); + curTalk = f->readUint32LE(); + bAlwaysBack = f->readByte(); + } +} MCharacter[10]; + +bool IsMChar[16]; + +bool bAlwaysDisplay; + +RMPoint saveTonyPos; +int saveTonyLoc; + +RMTextDialog *curBackText = NULL; +bool bTonyIsSpeaking = false; + +int curChangedHotspot = 0; + +struct { + uint32 dwCode; + uint32 nX,nY; + + void Save(Common::OutSaveFile *f) { + f->writeUint32LE(dwCode); + f->writeUint32LE(nX); + f->writeUint32LE(nY); + } + void Load(Common::InSaveFile *f) { + dwCode = f->readUint32LE(); + nX = f->readUint32LE(); + nY = f->readUint32LE(); + } +} ChangedHotspot[256]; + +void ReapplyChangedHotspot(void) { + int i; + for (i = 0; iGetItemFromCode(ChangedHotspot[i].dwCode)->ChangeHotspot(RMPoint(ChangedHotspot[i].nX, ChangedHotspot[i].nY)); +} + +void SaveChangedHotspot(Common::OutSaveFile *f) { + f->writeByte(curChangedHotspot); + if (curChangedHotspot > 0) { + for (int i = 0; i < curChangedHotspot; ++i) + ChangedHotspot[i].Save(f); + } +} + +void LoadChangedHotspot(Common::InSaveFile *f) { + curChangedHotspot = f->readByte(); + + if (curChangedHotspot > 0) { + for (int i = 0; i < curChangedHotspot; ++i) + ChangedHotspot[i].Load(f); + } +} + + +/* + Classi richieste per le funzioni custom! + + Tony (per muoverlo) -> si puo' fare tramite MPAL l'animazione? Penso proprio di s + + SendMessage -> Direi che basta theEngine.SendMessage() + ChangeLocation -> theEngine.ChangeLocation() + AddInventory -> theEngine.AddInventory() +*/ + +void MCharResetCodes(void) { + for (int i = 0; i < 10; i++) + MCharacter[i].item = Loc->GetItemFromCode(MCharacter[i].code); + for (int i = 0; i < 10; i++) + Character[i].item = Loc->GetItemFromCode(Character[i].code); +} + +void CharsSaveAll(Common::OutSaveFile *f) { + for (int i = 0; i < 10; i++) { + f->writeByte(IsMChar[i]); + if (IsMChar[i]) { + MCharacter[i].Save(f); + } else { + Character[i].Save(f); + } + } +} + +void CharsLoadAll(Common::InSaveFile *f) { + for (int i = 0; i < 10; i++) { + IsMChar[i] = f->readByte(); + if (IsMChar[i]) + MCharacter[i].Load(f); + else + Character[i].Load(f); + } +} + +DECLARE_CUSTOM_FUNCTION(FaceToMe)(uint32, uint32, uint32, uint32) { + Tony->SetPattern(Tony->PAT_STANDDOWN); +} + +DECLARE_CUSTOM_FUNCTION(BackToMe)(uint32, uint32, uint32, uint32) { + Tony->SetPattern(Tony->PAT_STANDUP); +} + +DECLARE_CUSTOM_FUNCTION(LeftToMe)(uint32, uint32, uint32, uint32) { + Tony->SetPattern(Tony->PAT_STANDLEFT); +} + +DECLARE_CUSTOM_FUNCTION(RightToMe)(uint32, uint32, uint32, uint32) { + Tony->SetPattern(Tony->PAT_STANDRIGHT); +} + + +DECLARE_CUSTOM_FUNCTION(TonySetPalesati)(uint32 bStatus, uint32, uint32, uint32) { + SetPalesati(bStatus); +} + +DECLARE_CUSTOM_FUNCTION(MySleep)(uint32 dwTime, uint32, uint32, uint32) { + if (bSkipIdle) return; + Sleep(dwTime); +} + +DECLARE_CUSTOM_FUNCTION(SetAlwaysDisplay)(uint32 val, uint32, uint32, uint32) { + bAlwaysDisplay = (val != 0); +} + + +DECLARE_CUSTOM_FUNCTION(SetPointer)(uint32 dwPointer, uint32, uint32, uint32) { + switch (dwPointer) { + case 1: + Pointer->SetSpecialPointer(Pointer->PTR_FRECCIASU); + break; + case 2: + Pointer->SetSpecialPointer(Pointer->PTR_FRECCIAGIU); + break; + case 3: + Pointer->SetSpecialPointer(Pointer->PTR_FRECCIASINISTRA); + break; + case 4: + Pointer->SetSpecialPointer(Pointer->PTR_FRECCIADESTRA); + break; + case 5: + Pointer->SetSpecialPointer(Pointer->PTR_FRECCIAMAPPA); + break; + + default: + Pointer->SetSpecialPointer(Pointer->PTR_NONE); + break; + } +} + +VoiceHeader *SearchVoiceHeader(uint32 codehi, uint32 codelo) { + uint i; + int code; + + code = (codehi << 16) | codelo; + + if (_vm->_voices.size() == 0) + return NULL; + + for (i = 0; i < _vm->_voices.size(); i++) + if (_vm->_voices[i].code == code) + return &_vm->_voices[i]; + + return NULL; +} + + +DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(uint32 dwMessage, uint32 nX, uint32 nY, uint32) { + RMMessage msg(dwMessage); + int i; + int curOffset = 0; + + if (bSkipIdle) return; + + if (!msg.IsValid()) + return; + + VoiceHeader *curVoc = SearchVoiceHeader(0, dwMessage); + FPSFX *voice = NULL; + if (curVoc) { + // Si posiziona all'interno del database delle voci all'inizio della prima + curOffset = curVoc->offset; + + // PRIMA VOLTA PREALLOCA + g_system->lockMutex(vdb); + //fseek(_vm->m_vdbFP, curOffset, SEEK_SET); + _vm->_vdbFP.seek(curOffset); + _vm->_theSound.CreateSfx(&voice); + voice->LoadVoiceFromVDB(_vm->_vdbFP); +// curOffset = ftell(_vm->m_vdbFP); + curOffset = _vm->_vdbFP.pos(); + + voice->SetLoop(false); + g_system->unlockMutex(vdb); + } + + if (nTonyNextTalkType != Tony->TALK_NORMAL) { + Tony->StartTalk(nTonyNextTalkType); + if (!bStaticTalk) + nTonyNextTalkType = Tony->TALK_NORMAL; + } else { + if (msg.NumPeriods() > 1) + Tony->StartTalk(Tony->TALK_FIANCHI); + else + Tony->StartTalk(Tony->TALK_NORMAL); + } + + if (curBackText) + curBackText->Hide(); + bTonyIsSpeaking = true; + + for (i = 0; i < msg.NumPeriods() && !bSkipIdle; i++) { + RMTextDialog text; + + text.SetInput(Input); + + // Allineamento + text.SetAlignType(RMText::HCENTER,RMText::VBOTTOM); + + // Colore + text.SetColor(0,255,0); + + // Scrive il testo + text.WriteText(msg[i],0); + + // Setta la posizione + if (nX == 0 && nY == 0) + text.SetPosition(Tony->Position() - RMPoint(0, 130) - Loc->ScrollPosition()); + else + text.SetPosition(RMPoint(nX, nY) - Loc->ScrollPosition()); + + // Setta l'always display + if (bAlwaysDisplay) { text.SetAlwaysDisplay(); text.ForceTime(); } + + // Registra il testo + LinkGraphicTask(&text); + + if (curVoc) { + if (i == 0) { + voice->Play(); + text.SetCustomSkipHandle2(voice->hEndOfBuffer); + } else { + g_system->lockMutex(vdb); + // fseek(_vm->m_vdbFP, curOffset, SEEK_SET); + _vm->_vdbFP.seek(curOffset); + _vm->_theSound.CreateSfx(&voice); + voice->LoadVoiceFromVDB(_vm->_vdbFP); + // curOffset = ftell(_vm->m_vdbFP); + curOffset = _vm->_vdbFP.pos(); + voice->SetLoop(false); + voice->Play(); + text.SetCustomSkipHandle2(voice->hEndOfBuffer); + g_system->unlockMutex(vdb); + } + } + + // Aspetta la fine della visualizzazione + text.SetCustomSkipHandle(hSkipIdle); + text.WaitForEndDisplay(); + + if (curVoc) { + voice->Stop(); + voice->Release(); + voice=NULL; + } + } + + bTonyIsSpeaking = false; + if (curBackText) + curBackText->Show(); + + Tony->EndTalk(); +} + +DECLARE_CUSTOM_FUNCTION(ChangeBoxStatus)(uint32 nLoc, uint32 nBox, uint32 nStatus, uint32) { + Boxes->ChangeBoxStatus(nLoc,nBox,nStatus); +} + + +DECLARE_CUSTOM_FUNCTION(CustLoadLocation)(uint32 nLoc, uint32 tX, uint32 tY, uint32 bUseStartPos) { + HANDLE h; + + Freeze(); + + curChangedHotspot = 0; + if (bUseStartPos != 0) + LoadLocation(nLoc, RMPoint(tX, tY), StartLocPos[nLoc]); + else + LoadLocation(nLoc, RMPoint(tX, tY), RMPoint(-1, -1)); + + Unfreeze(); + h = mpalQueryDoAction(0, nLoc, 0); + + // On Enter? + if (h != INVALID_HANDLE_VALUE) + WaitForSingleObject(h, INFINITE); +} + + +RMPoint SFM_pt; +int SFM_nLoc; + +DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgStart)(uint32 nMsg, uint32 nFont, uint32, uint32) { + RMMessage msg(nMsg); + RMGfxClearTask clear; + int i; + + SFM_nLoc = Loc->TEMPGetNumLoc(); + SFM_pt = Tony->Position(); + + if (bSkipIdle) return; + + UnloadLocation(false); + Tony->Hide(); + Unfreeze(); + + for (i = 0; i < msg.NumPeriods() && !bSkipIdle; i++) { + RMTextDialog text; + + text.SetInput(Input); + + // Allineamento + text.SetAlignType(RMText::HCENTER,RMText::VCENTER); + + // Forza il testo a scomparire a tempo + text.ForceTime(); + + // Colore + text.SetColor(255,255,255); + + // Scrive il testo + if (nFont== 0) + text.WriteText(msg[i],1); + else if (nFont==1) + text.WriteText(msg[i],0); + + // Setta la posizione + text.SetPosition(RMPoint(320,240)); + + text.SetAlwaysDisplay(); + text.ForceTime(); + + // Registra il testo + LinkGraphicTask(&clear); + LinkGraphicTask(&text); + + // Aspetta la fine della visualizzazione + text.SetCustomSkipHandle(hSkipIdle); + text.WaitForEndDisplay(); + } +} + +DECLARE_CUSTOM_FUNCTION(ClearScreen)(uint32, uint32, uint32, uint32) { + RMGfxClearTask clear; + + LinkGraphicTask(&clear); + WaitFrame(); +} + +DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgEnd)(uint32 bNotEnableTony, uint32, uint32, uint32) { + Freeze(); + LoadLocation(SFM_nLoc,RMPoint(SFM_pt.x,SFM_pt.y),RMPoint(-1,-1)); + if (!bNotEnableTony) + Tony->Show(); + Unfreeze(); + + MCharResetCodes(); + ReapplyChangedHotspot(); +} + + +DECLARE_CUSTOM_FUNCTION(SendFullscreenMessage)(uint32 nMsg, uint32 nFont, uint32, uint32) { + SendFullscreenMsgStart(nMsg,nFont,0,0); + SendFullscreenMsgEnd(0, 0, 0, 0); +} + +bool bNoOcchioDiBue = false; + +DECLARE_CUSTOM_FUNCTION(NoOcchioDiBue)(uint32, uint32, uint32, uint32) { + bNoOcchioDiBue = true; +} + +DECLARE_CUSTOM_FUNCTION(CloseLocation)(uint32, uint32, uint32, uint32) { + if (!bNoOcchioDiBue) { + InitWipe(1); + WaitWipeEnd(); + } + + _vm->StopMusic(4); + + // On Exit e lascia freezzato + UnloadLocation(true); + Unfreeze(); +} + + +DECLARE_CUSTOM_FUNCTION(ChangeLocation)(uint32 nLoc, uint32 tX, uint32 tY, uint32 bUseStartPos) { + HANDLE h; + + if (!bNoOcchioDiBue) { + InitWipe(1); + WaitWipeEnd(); + } + + if (lastTappeto != tappeti[nLoc]) { + _vm->StopMusic(4); + } + + // On Exit e lascia freezzato + UnloadLocation(true); + + curChangedHotspot = 0; + if (bUseStartPos != 0) + LoadLocation(nLoc, RMPoint(tX, tY), StartLocPos[nLoc]); + else + LoadLocation(nLoc, RMPoint(tX, tY), RMPoint(-1, -1)); + + if (lastTappeto != tappeti[nLoc]) { + lastTappeto = tappeti[nLoc]; + if (lastTappeto != 0) + _vm->PlayMusic(4, tappetiFile[lastTappeto], 0, true, 2000); + } + + if (!bNoOcchioDiBue) { + InitWipe(2); + } + + Unfreeze(); + + + h = mpalQueryDoAction(0,nLoc,0); + + if (!bNoOcchioDiBue) { + WaitWipeEnd(); + CloseWipe(); + } + + bNoOcchioDiBue = false; + + // On Enter? + if (h != INVALID_HANDLE_VALUE) + WaitForSingleObject(h,INFINITE); + +} + +DECLARE_CUSTOM_FUNCTION(SetLocStartPosition)(uint32 nLoc, uint32 lX, uint32 lY, uint32) { + StartLocPos[nLoc].Set(lX,lY); +} + +DECLARE_CUSTOM_FUNCTION(SaveTonyPosition)(uint32, uint32, uint32, uint32) { + saveTonyPos = Tony->Position(); + saveTonyLoc = Loc->TEMPGetNumLoc(); +} + +DECLARE_CUSTOM_FUNCTION(RestoreTonyPosition)(uint32, uint32, uint32, uint32) { + ChangeLocation(saveTonyLoc, saveTonyPos.x, saveTonyPos.y, 0); + MCharResetCodes(); +} + + +DECLARE_CUSTOM_FUNCTION(DisableInput)(uint32, uint32, uint32, uint32) { + MainDisableInput(); +} + + +DECLARE_CUSTOM_FUNCTION(EnableInput)(uint32, uint32, uint32, uint32) { + MainEnableInput(); +} + +DECLARE_CUSTOM_FUNCTION(StopTony)(uint32, uint32, uint32, uint32) { + Tony->StopNoAction(); +} + + +DECLARE_CUSTOM_FUNCTION(CustEnableGUI)(uint32, uint32, uint32, uint32) { + EnableGUI(); +} + +DECLARE_CUSTOM_FUNCTION(CustDisableGUI)(uint32, uint32, uint32, uint32) +{ + DisableGUI(); +} + + +void TonyGenericTake1(uint32 nDirection) { + Freeze(); + Tony->Take(nDirection,0); + Unfreeze(); + + if (!bSkipIdle) + Tony->WaitForEndPattern(); +} + +void TonyGenericTake2(uint32 nDirection) { + Freeze(); + Tony->Take(nDirection,1); + Unfreeze(); + + if (!bSkipIdle) + Tony->WaitForEndPattern(); + + Freeze(); + Tony->Take(nDirection,2); + Unfreeze(); +} + +void TonyGenericPut1(uint32 nDirection) { + Freeze(); + Tony->Put(nDirection,0); + Unfreeze(); + + if (!bSkipIdle) + Tony->WaitForEndPattern(); +} + +void TonyGenericPut2(uint32 nDirection) { + Freeze(); + Tony->Put(nDirection,1); + Unfreeze(); + + if (!bSkipIdle) + Tony->WaitForEndPattern(); + + Freeze(); + Tony->Put(nDirection,2); + Unfreeze(); +} + + +DECLARE_CUSTOM_FUNCTION(TonyTakeUp1)(uint32, uint32, uint32, uint32) { + TonyGenericTake1(0); +} + + +DECLARE_CUSTOM_FUNCTION(TonyTakeMid1)(uint32, uint32, uint32, uint32) { + TonyGenericTake1(1); +} + +DECLARE_CUSTOM_FUNCTION(TonyTakeDown1)(uint32, uint32, uint32, uint32) { + TonyGenericTake1(2); +} + + + +DECLARE_CUSTOM_FUNCTION(TonyTakeUp2)(uint32, uint32, uint32, uint32) { + TonyGenericTake2(0); +} + + +DECLARE_CUSTOM_FUNCTION(TonyTakeMid2)(uint32, uint32, uint32, uint32) { + TonyGenericTake2(1); +} + +DECLARE_CUSTOM_FUNCTION(TonyTakeDown2)(uint32, uint32, uint32, uint32) { + TonyGenericTake2(2); +} + + + + + + + +DECLARE_CUSTOM_FUNCTION(TonyPutUp1)(uint32, uint32, uint32, uint32) { + TonyGenericPut1(0); +} + + +DECLARE_CUSTOM_FUNCTION(TonyPutMid1)(uint32, uint32, uint32, uint32) { + TonyGenericPut1(1); +} + +DECLARE_CUSTOM_FUNCTION(TonyPutDown1)(uint32, uint32, uint32, uint32) { + TonyGenericPut1(2); +} + +DECLARE_CUSTOM_FUNCTION(TonyPutUp2)(uint32, uint32, uint32, uint32) { + TonyGenericPut2(0); +} + + +DECLARE_CUSTOM_FUNCTION(TonyPutMid2)(uint32, uint32, uint32, uint32) { + TonyGenericPut2(1); +} + +DECLARE_CUSTOM_FUNCTION(TonyPutDown2)(uint32, uint32, uint32, uint32) { + TonyGenericPut2(2); +} + + + +DECLARE_CUSTOM_FUNCTION(TonyPerTerra)(uint32 dwParte, uint32, uint32, uint32) { + if (dwParte== 0) + Tony->SetPattern(Tony->PAT_PERTERRALEFT); + else + Tony->SetPattern(Tony->PAT_PERTERRARIGHT); +} + +DECLARE_CUSTOM_FUNCTION(TonySiRialza)(uint32 dwParte, uint32, uint32, uint32) { + if (dwParte== 0) + Tony->SetPattern(Tony->PAT_SIRIALZALEFT); + else + Tony->SetPattern(Tony->PAT_SIRIALZARIGHT); + + if (!bSkipIdle) + Tony->WaitForEndPattern(); +} + +DECLARE_CUSTOM_FUNCTION(TonyPastorella)(uint32 bIsPast, uint32, uint32, uint32) { + Tony->SetPastorella(bIsPast); +} + +DECLARE_CUSTOM_FUNCTION(TonyFischietto)(uint32, uint32, uint32, uint32) { + Tony->SetPattern(Tony->PAT_FISCHIETTORIGHT); + if (!bSkipIdle) + Tony->WaitForEndPattern(); + Tony->SetPattern(Tony->PAT_STANDRIGHT); +} + + +void TonySetNumTexts(uint32 dwText) { + dwTonyNumTexts=dwText; + bTonyInTexts = false; +} + +DECLARE_CUSTOM_FUNCTION(TonyRide)(uint32 dwText, uint32, uint32, uint32) { + TonySetNumTexts(dwText); + nTonyNextTalkType = Tony->TALK_RIDE; +} + +DECLARE_CUSTOM_FUNCTION(TonyRidacchia)(uint32 dwText, uint32, uint32, uint32) { + TonySetNumTexts(dwText); + nTonyNextTalkType = Tony->TALK_RIDE2; +} + +DECLARE_CUSTOM_FUNCTION(TonyFianchi)(uint32 dwText, uint32, uint32, uint32) { + TonySetNumTexts(dwText); + nTonyNextTalkType = Tony->TALK_FIANCHI; +} + +DECLARE_CUSTOM_FUNCTION(TonyCanta)(uint32 dwText, uint32, uint32, uint32) { + TonySetNumTexts(dwText); + nTonyNextTalkType = Tony->TALK_CANTA; +} + +DECLARE_CUSTOM_FUNCTION(TonySiIndica)(uint32 dwText, uint32, uint32, uint32) { + TonySetNumTexts(dwText); + nTonyNextTalkType = Tony->TALK_SIINDICA; +} + +DECLARE_CUSTOM_FUNCTION(TonySpaventatoConMani)(uint32 dwText, uint32, uint32, uint32) { + TonySetNumTexts(dwText); + nTonyNextTalkType = Tony->TALK_SPAVENTATO; +} + +DECLARE_CUSTOM_FUNCTION(TonySpaventatoSenzaMani)(uint32 dwText, uint32, uint32, uint32) { + TonySetNumTexts(dwText); + nTonyNextTalkType = Tony->TALK_SPAVENTATO2; +} + +DECLARE_CUSTOM_FUNCTION(TonyConMartello)(uint32 dwText, uint32, uint32, uint32) { + TonySetNumTexts(dwText); + nTonyNextTalkType = Tony->TALK_CONMARTELLO; + Tony->SetPattern(Tony->PAT_CONMARTELLO); +} + +DECLARE_CUSTOM_FUNCTION(TonyConBicchiere)(uint32 dwText, uint32, uint32, uint32) { + TonySetNumTexts(dwText); + nTonyNextTalkType = Tony->TALK_CONBICCHIERE; + Tony->SetPattern(Tony->PAT_CONBICCHIERE); +} + +DECLARE_CUSTOM_FUNCTION(TonyConVerme)(uint32 dwText, uint32, uint32, uint32) { + TonySetNumTexts(dwText); + nTonyNextTalkType = Tony->TALK_CONVERME; + Tony->SetPattern(Tony->PAT_CONVERME); +} + +DECLARE_CUSTOM_FUNCTION(TonyConCorda)(uint32 dwText, uint32, uint32, uint32) { + TonySetNumTexts(dwText); + nTonyNextTalkType = Tony->TALK_CONCORDA; + Tony->SetPattern(Tony->PAT_CONCORDA); +} + +DECLARE_CUSTOM_FUNCTION(TonyConSegretaria)(uint32 dwText, uint32, uint32, uint32) { + TonySetNumTexts(dwText); + nTonyNextTalkType = Tony->TALK_CONSEGRETARIA; + Tony->SetPattern(Tony->PAT_CONSEGRETARIA); +} + +DECLARE_CUSTOM_FUNCTION(TonyConConiglioANIM)(uint32 dwText, uint32, uint32, uint32) { + TonySetNumTexts(dwText); + nTonyNextTalkType = Tony->TALK_CONCONIGLIO; +} + +DECLARE_CUSTOM_FUNCTION(TonyConRicettaANIM)(uint32 dwText, uint32, uint32, uint32) { + TonySetNumTexts(dwText); + nTonyNextTalkType = Tony->TALK_CONRICETTA; +} + +DECLARE_CUSTOM_FUNCTION(TonyConCarteANIM)(uint32 dwText, uint32, uint32, uint32) { + TonySetNumTexts(dwText); + nTonyNextTalkType = Tony->TALK_CONCARTE; +} + +DECLARE_CUSTOM_FUNCTION(TonyConPupazzoANIM)(uint32 dwText, uint32, uint32, uint32) { + TonySetNumTexts(dwText); + nTonyNextTalkType = Tony->TALK_CONPUPAZZO; +} + +DECLARE_CUSTOM_FUNCTION(TonyConPupazzoStart)(uint32, uint32, uint32, uint32) { + nTonyNextTalkType = Tony->TALK_CONPUPAZZOSTATIC; + bStaticTalk = true; + Tony->StartStatic(Tony->TALK_CONPUPAZZOSTATIC); +} + +DECLARE_CUSTOM_FUNCTION(TonyConPupazzoEnd)(uint32, uint32, uint32, uint32) { + Tony->EndStatic(Tony->TALK_CONPUPAZZOSTATIC); + bStaticTalk = false; + nTonyNextTalkType = Tony->TALK_NORMAL; +} + +DECLARE_CUSTOM_FUNCTION(TonyConConiglioStart)(uint32, uint32, uint32, uint32) { + nTonyNextTalkType = Tony->TALK_CONCONIGLIOSTATIC; + bStaticTalk = true; + Tony->StartStatic(Tony->TALK_CONCONIGLIOSTATIC); +} + +DECLARE_CUSTOM_FUNCTION(TonyConConiglioEnd)(uint32, uint32, uint32, uint32) { + Tony->EndStatic(Tony->TALK_CONCONIGLIOSTATIC); + bStaticTalk = false; + nTonyNextTalkType = Tony->TALK_NORMAL; +} + +DECLARE_CUSTOM_FUNCTION(TonyConRicettaStart)(uint32, uint32, uint32, uint32) { + nTonyNextTalkType = Tony->TALK_CONRICETTASTATIC; + bStaticTalk = true; + Tony->StartStatic(Tony->TALK_CONRICETTASTATIC); +} + +DECLARE_CUSTOM_FUNCTION(TonyConRicettaEnd)(uint32, uint32, uint32, uint32) { + Tony->EndStatic(Tony->TALK_CONRICETTASTATIC); + bStaticTalk = false; + nTonyNextTalkType = Tony->TALK_NORMAL; +} + +DECLARE_CUSTOM_FUNCTION(TonyConCarteStart)(uint32, uint32, uint32, uint32) { + nTonyNextTalkType = Tony->TALK_CONCARTESTATIC; + bStaticTalk = true; + Tony->StartStatic(Tony->TALK_CONCARTESTATIC); +} + +DECLARE_CUSTOM_FUNCTION(TonyConCarteEnd)(uint32, uint32, uint32, uint32) { + Tony->EndStatic(Tony->TALK_CONCARTESTATIC); + bStaticTalk = false; + nTonyNextTalkType = Tony->TALK_NORMAL; +} + +DECLARE_CUSTOM_FUNCTION(TonyConTaccuinoStart)(uint32, uint32, uint32, uint32) { + nTonyNextTalkType = Tony->TALK_CONTACCUINOSTATIC; + bStaticTalk = true; + Tony->StartStatic(Tony->TALK_CONTACCUINOSTATIC); +} + +DECLARE_CUSTOM_FUNCTION(TonyConTaccuinoEnd)(uint32, uint32, uint32, uint32) { + Tony->EndStatic(Tony->TALK_CONTACCUINOSTATIC); + bStaticTalk = false; + nTonyNextTalkType = Tony->TALK_NORMAL; +} + +DECLARE_CUSTOM_FUNCTION(TonyConMegafonoStart)(uint32, uint32, uint32, uint32) { + nTonyNextTalkType = Tony->TALK_CONMEGAFONOSTATIC; + bStaticTalk = true; + Tony->StartStatic(Tony->TALK_CONMEGAFONOSTATIC); +} + +DECLARE_CUSTOM_FUNCTION(TonyConMegafonoEnd)(uint32, uint32, uint32, uint32) { + Tony->EndStatic(Tony->TALK_CONMEGAFONOSTATIC); + bStaticTalk = false; + nTonyNextTalkType = Tony->TALK_NORMAL; +} + +DECLARE_CUSTOM_FUNCTION(TonyConBarbaStart)(uint32, uint32, uint32, uint32) { + nTonyNextTalkType = Tony->TALK_CONBARBASTATIC; + bStaticTalk = true; + Tony->StartStatic(Tony->TALK_CONBARBASTATIC); +} + +DECLARE_CUSTOM_FUNCTION(TonyConBarbaEnd)(uint32, uint32, uint32, uint32) { + Tony->EndStatic(Tony->TALK_CONBARBASTATIC); + bStaticTalk = false; + nTonyNextTalkType = Tony->TALK_NORMAL; +} + +DECLARE_CUSTOM_FUNCTION(TonySpaventatoStart)(uint32, uint32, uint32, uint32) { + nTonyNextTalkType = Tony->TALK_SPAVENTATOSTATIC; + bStaticTalk = true; + Tony->StartStatic(Tony->TALK_SPAVENTATOSTATIC); +} + +DECLARE_CUSTOM_FUNCTION(TonySpaventatoEnd)(uint32, uint32, uint32, uint32) { + Tony->EndStatic(Tony->TALK_SPAVENTATOSTATIC); + bStaticTalk = false; + nTonyNextTalkType = Tony->TALK_NORMAL; +} + + + +DECLARE_CUSTOM_FUNCTION(TonySchifato)(uint32 dwText, uint32, uint32, uint32) { + TonySetNumTexts(dwText); + nTonyNextTalkType = Tony->TALK_SCHIFATO; +} + +DECLARE_CUSTOM_FUNCTION(TonySniffaLeft)(uint32, uint32, uint32, uint32) { + Tony->SetPattern(Tony->PAT_SNIFFA_LEFT); + Tony->WaitForEndPattern(); + LeftToMe(0, 0, 0, 0); +} + +DECLARE_CUSTOM_FUNCTION(TonySniffaRight)(uint32, uint32, uint32, uint32) { + Tony->SetPattern(Tony->PAT_SNIFFA_RIGHT); + Tony->WaitForEndPattern(); + RightToMe(0, 0, 0, 0); +} + +DECLARE_CUSTOM_FUNCTION(TonyNaah)(uint32 dwText, uint32, uint32, uint32) { + TonySetNumTexts(dwText); + nTonyNextTalkType = Tony->TALK_NAAH; +} + +DECLARE_CUSTOM_FUNCTION(TonyMacbeth)(uint32 nPos, uint32, uint32, uint32) { + switch (nPos) { + case 1: + nTonyNextTalkType = Tony->TALK_MACBETH1; + break; + case 2: + nTonyNextTalkType = Tony->TALK_MACBETH2; + break; + case 3: + nTonyNextTalkType = Tony->TALK_MACBETH3; + break; + case 4: + nTonyNextTalkType = Tony->TALK_MACBETH4; + break; + case 5: + nTonyNextTalkType = Tony->TALK_MACBETH5; + break; + case 6: + nTonyNextTalkType = Tony->TALK_MACBETH6; + break; + case 7: + nTonyNextTalkType = Tony->TALK_MACBETH7; + break; + case 8: + nTonyNextTalkType = Tony->TALK_MACBETH8; + break; + case 9: + nTonyNextTalkType = Tony->TALK_MACBETH9; + break; + } +} + + +DECLARE_CUSTOM_FUNCTION(EnableTony)(uint32, uint32, uint32, uint32) { + Tony->Show(); +} + +DECLARE_CUSTOM_FUNCTION(DisableTony)(uint32 bShowOmbra, uint32, uint32, uint32) { + Tony->Hide(bShowOmbra); +} + +DECLARE_CUSTOM_FUNCTION(WaitForPatternEnd)(uint32 nItem, uint32, uint32, uint32) { + RMItem *item = Loc->GetItemFromCode(nItem); + + if (!bSkipIdle && item != NULL) + item->WaitForEndPattern(hSkipIdle); +} + + +DECLARE_CUSTOM_FUNCTION(SetTonyPosition)(uint32 nX, uint32 nY, uint32 nLoc, uint32) { + Tony->SetPosition(RMPoint(nX,nY),nLoc); +} + +DECLARE_CUSTOM_FUNCTION(MoveTonyAndWait)(uint32 nX, uint32 nY, uint32, uint32) { + Tony->Move(RMPoint(nX,nY)); + + if (!bSkipIdle) + Tony->WaitForEndMovement(); +} + +DECLARE_CUSTOM_FUNCTION(MoveTony)(uint32 nX, uint32 nY, uint32, uint32) { + Tony->Move(RMPoint(nX,nY)); +} + +DECLARE_CUSTOM_FUNCTION(ScrollLocation)(uint32 nX, uint32 nY, uint32 sX, uint32 sY) { + int lx, ly; + RMPoint pt; + + // Prende le coordinate di quanto scrollare + lx=*((int*)&nX); + ly=*((int*)&nY); + + pt=Loc->ScrollPosition(); + + while ((lx != 0 || ly != 0) && !bSkipIdle) { + if (lx>0) { + lx -= (int32)sX; if (lx<0) lx = 0; + pt.Offset((int32)sX, 0); + } else if (lx<0) { + lx += (int32)sX; if (lx>0) lx = 0; + pt.Offset(-(int32)sX, 0); + } + + if (ly > 0) { + ly-=sY; if (ly<0) ly = 0; + pt.Offset(0,sY); + } + else if (ly<0) + { + ly+=sY; if (ly>0) ly = 0; + pt.Offset(0, -(int32)sY); + } + + WaitFrame(); + + Freeze(); + Loc->SetScrollPosition(pt); + Tony->SetScrollPosition(pt); + Unfreeze(); + + } +} + +DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(uint32 nX, uint32 nY, uint32 sX, uint32 sY) { + int lx, ly; + RMPoint pt,startpt; + uint32 dwStartTime,dwCurTime,dwTotalTime; + uint32 stepX, stepY; + int dimx,dimy; + + // Prende le coordinate di quanto scrollare + lx=*((int*)&nX); + ly=*((int*)&nY); + dimx=lx; + dimy=ly; + if (lx<0) dimx = -lx; + if (ly<0) dimy = -ly; + + stepX = sX; + stepY = sY; + + startpt = Loc->ScrollPosition(); + + dwStartTime = timeGetTime(); + + if (sX) + dwTotalTime = dimx*(1000/35)/sX; + else + dwTotalTime = dimy*(1000/35)/sY; + + while ((lx != 0 || ly != 0) && !bSkipIdle) + { + dwCurTime=timeGetTime()-dwStartTime; + if (dwCurTime>dwTotalTime) + break; + + pt = startpt; + + if (sX) { + if (lx > 0) + pt.x += (dimx * dwCurTime) / dwTotalTime; + else + pt.x -= (dimx * dwCurTime) / dwTotalTime; + } else { + if (ly > 0) + pt.y += (dimy*dwCurTime) / dwTotalTime; + else + pt.y -= (dimy*dwCurTime) / dwTotalTime; + + } + +/* + sX = stepX * (dwCurTime-dwLastTime) / (1000/35); + sY = stepY * (dwCurTime-dwLastTime) / (1000/35); + + if (lx>0) + { + lx-=sX; if (lx<0) lx = 0; + pt.Offset(sX,0); + } + else if (lx<0) + { + lx+=sX; if (lx>0) lx = 0; + pt.Offset(-sX,0); + } + + if (ly>0) + { + ly-=sY; if (ly<0) ly = 0; + pt.Offset(0,sY); + } + else if (ly<0) + { + ly+=sY; if (ly>0) ly = 0; + pt.Offset(0,-sY); + } +*/ + WaitFrame(); + + Freeze(); + Loc->SetScrollPosition(pt); + Tony->SetScrollPosition(pt); + Unfreeze(); + + } + + + // Setta la posizione finale + if (sX) { + if (lx>0) + pt.x = startpt.x + dimx; + else + pt.x = startpt.x - dimx; + } else { + if (ly>0) + pt.y = startpt.y + dimy; + else + pt.y = startpt.y - dimy; + + } + + Freeze(); + Loc->SetScrollPosition(pt); + Tony->SetScrollPosition(pt); + Unfreeze(); +} + + +DECLARE_CUSTOM_FUNCTION(ChangeHotspot)(uint32 dwCode, uint32 nX, uint32 nY, uint32) { + int i; + + for (i = 0; i < curChangedHotspot; i++) + if (ChangedHotspot[i].dwCode == dwCode) { + ChangedHotspot[i].nX=nX; + ChangedHotspot[i].nY=nY; + break; + } + + if (i == curChangedHotspot) { + ChangedHotspot[i].dwCode=dwCode; + ChangedHotspot[i].nX=nX; + ChangedHotspot[i].nY=nY; + curChangedHotspot++; + } + + Loc->GetItemFromCode(dwCode)->ChangeHotspot(RMPoint(nX,nY)); +} + + +DECLARE_CUSTOM_FUNCTION(AutoSave)(uint32, uint32, uint32, uint32) { + _vm->AutoSave(); +} + +DECLARE_CUSTOM_FUNCTION(Abort)(uint32, uint32, uint32, uint32) { + _vm->Abort(); +} + +DECLARE_CUSTOM_FUNCTION(TremaSchermo)(uint32 nScosse, uint32, uint32, uint32) { + uint32 i; + uint32 curTime = _vm->GetTime(); + int dirx,diry; + + dirx = 1; + diry = 1; + + while (_vm->GetTime() < curTime + nScosse) { + WaitFrame(); + + Freeze(); + Loc->SetFixedScroll(RMPoint(1 * dirx, 1 * diry)); + Tony->SetFixedScroll(RMPoint(1 * dirx, 1 * diry)); + Unfreeze(); + + i = _vm->_randomSource.getRandomNumber(2); + + if (i == 0 || i == 2) + dirx = -dirx; + else if (i == 1 || i == 2) + diry = -diry; + } + + Freeze(); + Loc->SetFixedScroll(RMPoint(0, 0)); + Tony->SetFixedScroll(RMPoint(0, 0)); + Unfreeze(); +} + + + +/* + * Personaggi + */ + +DECLARE_CUSTOM_FUNCTION(CharSetCode)(uint32 nChar, uint32 nCode, uint32, uint32) { + assert(nChar < 16); + Character[nChar].code = nCode; + Character[nChar].item = Loc->GetItemFromCode(nCode); + Character[nChar].r = 255; + Character[nChar].g = 255; + Character[nChar].b = 255; + Character[nChar].talkpattern = 0; + Character[nChar].starttalkpattern = 0; + Character[nChar].endtalkpattern = 0; + Character[nChar].standpattern = 0; + + IsMChar[nChar] = false; +} + +DECLARE_CUSTOM_FUNCTION(CharSetColor)(uint32 nChar, uint32 r, uint32 g, uint32 b) { + assert(nChar<16); + Character[nChar].r = r; + Character[nChar].g = g; + Character[nChar].b = b; +} + +DECLARE_CUSTOM_FUNCTION(CharSetTalkPattern)(uint32 nChar, uint32 tp, uint32 sp, uint32) { + assert(nChar<16); + Character[nChar].talkpattern = tp; + Character[nChar].standpattern = sp; +} + +DECLARE_CUSTOM_FUNCTION(CharSetStartEndTalkPattern)(uint32 nChar, uint32 sp, uint32 ep, uint32) { + assert(nChar<16); + Character[nChar].starttalkpattern=sp; + Character[nChar].endtalkpattern=ep; +} + +DECLARE_CUSTOM_FUNCTION(CharSendMessage)(uint32 nChar, uint32 dwMessage, uint32 bIsBack, uint32) { + RMMessage msg(dwMessage); + int i; + RMPoint pt; + RMTextDialog *text; + int curOffset = 0; + + assert(nChar<16); + pt=Character[nChar].item->CalculatePos()-RMPoint(-60,20)-Loc->ScrollPosition(); + + if (Character[nChar].starttalkpattern != 0) { + Freeze(); + Character[nChar].item->SetPattern(Character[nChar].starttalkpattern); + Unfreeze(); + Character[nChar].item->WaitForEndPattern(); + } + + Freeze(); + Character[nChar].item->SetPattern(Character[nChar].talkpattern); + Unfreeze(); + + VoiceHeader *curVoc = SearchVoiceHeader(0, dwMessage); + FPSFX *voice = NULL; + if (curVoc) { + // Si posiziona all'interno del database delle voci all'inizio della prima +// fseek(_vm->m_vdbFP, curVoc->offset, SEEK_SET); + g_system->lockMutex(vdb); + _vm->_vdbFP.seek(curVoc->offset); + curOffset = curVoc->offset; + g_system->unlockMutex(vdb); + } + + for (i = 0; iHide(); + } else + text = new RMTextDialog; + + text->SetInput(Input); + + // Skipping + text->SetSkipStatus(!bIsBack); + + // Allineamento + text->SetAlignType(RMText::HCENTER,RMText::VBOTTOM); + + // Colore + text->SetColor(Character[nChar].r,Character[nChar].g,Character[nChar].b); + + // Scrive il testo + text->WriteText(msg[i],0); + + // Setta la posizione + text->SetPosition(pt); + + // Setta l'always display + if (bAlwaysDisplay) { text->SetAlwaysDisplay(); text->ForceTime(); } + + // Registra il testo + LinkGraphicTask(text); + + if (curVoc) { + g_system->lockMutex(vdb); + _vm->_theSound.CreateSfx(&voice); + _vm->_vdbFP.seek(curOffset); + voice->LoadVoiceFromVDB(_vm->_vdbFP); + voice->SetLoop(false); + if (bIsBack) voice->SetVolume(55); + voice->Play(); + text->SetCustomSkipHandle2(voice->hEndOfBuffer); + curOffset = _vm->_vdbFP.pos(); + g_system->unlockMutex(vdb); + } + + // Aspetta la fine della visualizzazione + text->SetCustomSkipHandle(hSkipIdle); + text->WaitForEndDisplay(); + + if (curVoc) { + voice->Stop(); + voice->Release(); + voice=NULL; + } + + + curBackText=NULL; + delete text; + } + + if (Character[nChar].endtalkpattern != 0) { + Freeze(); + Character[nChar].item->SetPattern(Character[nChar].endtalkpattern); + Unfreeze(); + Character[nChar].item->WaitForEndPattern(); + } + + Freeze(); + Character[nChar].item->SetPattern(Character[nChar].standpattern); + Unfreeze(); +} + +DECLARE_CUSTOM_FUNCTION(AddInventory)(uint32 dwCode, uint32, uint32, uint32) { + Inventory->AddItem(dwCode); +} + +DECLARE_CUSTOM_FUNCTION(RemoveInventory)(uint32 dwCode, uint32, uint32, uint32) { + Inventory->RemoveItem(dwCode); +} + +DECLARE_CUSTOM_FUNCTION(ChangeInventoryStatus)(uint32 dwCode, uint32 dwStatus, uint32, uint32) { + Inventory->ChangeItemStatus(dwCode,dwStatus); +} + + + + +/* + * Mastri Personaggi + */ + +DECLARE_CUSTOM_FUNCTION(MCharSetCode)(uint32 nChar, uint32 nCode, uint32, uint32) { + assert(nChar < 10); + MCharacter[nChar].code=nCode; + if (nCode== 0) + MCharacter[nChar].item=NULL; + else + MCharacter[nChar].item=Loc->GetItemFromCode(nCode); + MCharacter[nChar].r=255; + MCharacter[nChar].g=255; + MCharacter[nChar].b=255; + MCharacter[nChar].x=-1; + MCharacter[nChar].y=-1; + MCharacter[nChar].bAlwaysBack = 0; + + for (int i = 0; i < 10; i++) + MCharacter[nChar].numtalks[i] = 1; + + MCharacter[nChar].curgroup = 0; + + IsMChar[nChar] = true; +} + +DECLARE_CUSTOM_FUNCTION(MCharResetCode)(uint32 nChar, uint32, uint32, uint32) { + MCharacter[nChar].item=Loc->GetItemFromCode(MCharacter[nChar].code); +} + + +DECLARE_CUSTOM_FUNCTION(MCharSetPosition)(uint32 nChar, uint32 nX, uint32 nY, uint32) { + assert(nChar < 10); + MCharacter[nChar].x=nX; + MCharacter[nChar].y=nY; +} + + +DECLARE_CUSTOM_FUNCTION(MCharSetColor)(uint32 nChar, uint32 r, uint32 g, uint32 b) { + assert(nChar < 10); + MCharacter[nChar].r=r; + MCharacter[nChar].g=g; + MCharacter[nChar].b=b; +} + + +DECLARE_CUSTOM_FUNCTION(MCharSetNumTalksInGroup)(uint32 nChar, uint32 nGroup, uint32 nTalks, uint32) { + assert(nChar < 10); + assert(nGroup < 10); + + MCharacter[nChar].numtalks[nGroup]=nTalks; +} + + +DECLARE_CUSTOM_FUNCTION(MCharSetCurrentGroup)(uint32 nChar, uint32 nGroup, uint32, uint32) +{ + assert(nChar < 10); + assert(nGroup < 10); + + MCharacter[nChar].curgroup = nGroup; +} + +DECLARE_CUSTOM_FUNCTION(MCharSetNumTexts)(uint32 nChar, uint32 nTexts, uint32, uint32) { + assert(nChar < 10); + + MCharacter[nChar].numtexts=nTexts-1; + MCharacter[nChar].bInTexts = false; +} + +DECLARE_CUSTOM_FUNCTION(MCharSetAlwaysBack)(uint32 nChar, uint32 bAlwaysBack, uint32, uint32) { + assert(nChar < 10); + + MCharacter[nChar].bAlwaysBack=bAlwaysBack; +} + + +DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(uint32 nChar, uint32 dwMessage, uint32 bIsBack, uint32 nFont) { + RMMessage msg(dwMessage); + int i; + int parm; + RMPoint pt; + HANDLE h; + RMTextDialog *text; + int curOffset = 0; + + assert(nChar < 10); + + bIsBack |= MCharacter[nChar].bAlwaysBack ? 1 : 0; + + // Calcola la posizione del testo in base al frame corrente + if (MCharacter[nChar].x==-1) + pt=MCharacter[nChar].item->CalculatePos()-RMPoint(-60,20)-Loc->ScrollPosition(); + else + pt=RMPoint(MCharacter[nChar].x,MCharacter[nChar].y); + + // Parametro per le azioni speciali: random tra le parlate + parm = (MCharacter[nChar].curgroup * 10) + _vm->_randomSource.getRandomNumber( + MCharacter[nChar].numtalks[MCharacter[nChar].curgroup] - 1) + 1; + + // Cerca di eseguire la funzione custom per inizializzare la parlata + if (MCharacter[nChar].item) { + h = mpalQueryDoAction(30,MCharacter[nChar].item->MpalCode(), parm); + if (h != INVALID_HANDLE_VALUE) + WaitForSingleObject(h,INFINITE); + } + + VoiceHeader *curVoc = SearchVoiceHeader(0, dwMessage); + FPSFX *voice = NULL; + if (curVoc) { + // Si posiziona all'interno del database delle voci all'inizio della prima + g_system->lockMutex(vdb); + // fseek(_vm->m_vdbFP, curVoc->offset, SEEK_SET); + _vm->_vdbFP.seek(curVoc->offset); + curOffset = curVoc->offset; + g_system->unlockMutex(vdb); + } + + for (i = 0; i < msg.NumPeriods() && !bSkipIdle; i++) { + // Crea l'oggetto diverso se back o no + if (bIsBack) { + curBackText=text = new RMTextDialogScrolling(Loc); + if (bTonyIsSpeaking) + curBackText->Hide(); + } + else + text = new RMTextDialog; + + text->SetInput(Input); + + // Skipping + text->SetSkipStatus(!bIsBack); + + // Allineamento + text->SetAlignType(RMText::HCENTER,RMText::VBOTTOM); + + // Colore + text->SetColor(MCharacter[nChar].r,MCharacter[nChar].g,MCharacter[nChar].b); + + // Scrive il testo + text->WriteText(msg[i],nFont); + + // Setta la posizione + text->SetPosition(pt); + + // Setta l'always display + if (bAlwaysDisplay) { text->SetAlwaysDisplay(); text->ForceTime(); } + + // Registra il testo + LinkGraphicTask(text); + + if (curVoc) { + g_system->lockMutex(vdb); + _vm->_theSound.CreateSfx(&voice); + _vm->_vdbFP.seek(curOffset); + voice->LoadVoiceFromVDB(_vm->_vdbFP); + voice->SetLoop(false); + if (bIsBack) voice->SetVolume(55); + voice->Play(); + text->SetCustomSkipHandle2(voice->hEndOfBuffer); + curOffset = _vm->_vdbFP.pos(); + g_system->unlockMutex(vdb); + } + + // Aspetta la fine della visualizzazione + text->SetCustomSkipHandle(hSkipIdle); + text->WaitForEndDisplay(); + + if (curVoc) { + voice->Stop(); + voice->Release(); + voice=NULL; + } + + curBackText=NULL; + delete text; + } + + + // Cerca di eseguire la funzione custom per chiudere la parlata + if (MCharacter[nChar].item) { + h=mpalQueryDoAction(31,MCharacter[nChar].item->MpalCode(),parm); + if (h!=INVALID_HANDLE_VALUE) + WaitForSingleObject(h,INFINITE); + } +} + + + + + + +/* + * Dialoghi + */ + +int curDialog; + +DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(uint32 nPers, uint32 nMsg, uint32, uint32) { + LPSTR string; + RMTextDialog* text; + int parm; + HANDLE h; + bool bIsBack = false; + + // La SendDialogMessage pu andare in background se un personaggio in MCHAR settato + // con la SetAlwaysBack + if (nPers != 0 && IsMChar[nPers] && MCharacter[nPers].bAlwaysBack) + bIsBack = true; + + VoiceHeader *curVoc = SearchVoiceHeader(curDialog, nMsg); + FPSFX *voice = NULL; + + if (curVoc) { + // Si posiziona all'interno del database delle voci all'inizio della prima + g_system->lockMutex(vdb); +// fseek(_vm->m_vdbFP, curVoc->offset, SEEK_SET); + _vm->_vdbFP.seek(curVoc->offset); + _vm->_theSound.CreateSfx(&voice); + voice->LoadVoiceFromVDB(_vm->_vdbFP); + voice->SetLoop(false); + if (bIsBack) voice->SetVolume(55); + g_system->unlockMutex(vdb); + } + + string=mpalQueryDialogPeriod(nMsg); + + if (nPers == 0) { + text = new RMTextDialog; + text->SetColor(0,255,0); + text->SetPosition(Tony->Position()-RMPoint(0,130)-Loc->ScrollPosition()); + text->WriteText(string,0); + + if (dwTonyNumTexts > 0) { + if (!bTonyInTexts) { + if (nTonyNextTalkType != Tony->TALK_NORMAL) { + Tony->StartTalk(nTonyNextTalkType); + if (!bStaticTalk) + nTonyNextTalkType = Tony->TALK_NORMAL; + } else + Tony->StartTalk(Tony->TALK_NORMAL); + + bTonyInTexts = true; + } + dwTonyNumTexts--; + } else { + Tony->StartTalk(nTonyNextTalkType); + if (!bStaticTalk) + nTonyNextTalkType = Tony->TALK_NORMAL; + } + } else if (!IsMChar[nPers]) { + RMPoint pt; + + text = new RMTextDialog; + + pt=Character[nPers].item->CalculatePos()-RMPoint(-60,20)-Loc->ScrollPosition(); + + if (Character[nPers].starttalkpattern != 0) { + Freeze(); + Character[nPers].item->SetPattern(Character[nPers].starttalkpattern); + Unfreeze(); + Character[nPers].item->WaitForEndPattern(); + } + + Character[nPers].item->SetPattern(Character[nPers].talkpattern); + + text->SetColor(Character[nPers].r,Character[nPers].g,Character[nPers].b); + text->WriteText(string,0); + text->SetPosition(pt); + } else { + RMPoint pt; + + if (MCharacter[nPers].x==-1) + pt=MCharacter[nPers].item->CalculatePos()-RMPoint(-60,20)-Loc->ScrollPosition(); + else + pt=RMPoint(MCharacter[nPers].x,MCharacter[nPers].y); + + // Parametro per le azioni speciali: random tra le parlate + parm = (MCharacter[nPers].curgroup * 10) + _vm->_randomSource.getRandomNumber( + MCharacter[nPers].numtalks[MCharacter[nPers].curgroup] - 1) + 1; + + if (MCharacter[nPers].numtexts != 0 && MCharacter[nPers].bInTexts) { + MCharacter[nPers].numtexts--; + } else { + // Cerca di eseguire la funzione custom per inizializzare la parlata + h = mpalQueryDoAction(30, MCharacter[nPers].item->MpalCode(), parm); + if (h != INVALID_HANDLE_VALUE) + WaitForSingleObject(h,INFINITE); + + MCharacter[nPers].curTalk = parm; + + if (MCharacter[nPers].numtexts != 0) { + MCharacter[nPers].bInTexts = true; + MCharacter[nPers].numtexts--; + } + } + + if (MCharacter[nPers].bAlwaysBack) { + text = curBackText = new RMTextDialogScrolling(Loc); + if (bTonyIsSpeaking) + curBackText->Hide(); + bIsBack = true; + } else + text = new RMTextDialog; + + text->SetSkipStatus(!MCharacter[nPers].bAlwaysBack); + text->SetColor(MCharacter[nPers].r,MCharacter[nPers].g,MCharacter[nPers].b); + text->WriteText(string,0); + text->SetPosition(pt); + } + + if (!bSkipIdle) { + text->SetInput(Input); + if (bAlwaysDisplay) { text->SetAlwaysDisplay(); text->ForceTime(); } + text->SetAlignType(RMText::HCENTER,RMText::VBOTTOM); + LinkGraphicTask(text); + + if (curVoc) { + voice->Play(); + text->SetCustomSkipHandle2(voice->hEndOfBuffer); + } + + // Aspetta la fine della visualizzazione + text->SetCustomSkipHandle(hSkipIdle); + text->WaitForEndDisplay(); + } + + if (curVoc) { + voice->Stop(); + voice->Release(); + voice=NULL; + } + + if (nPers != 0) { + if (!IsMChar[nPers]) { + if (Character[nPers].endtalkpattern != 0) { + Freeze(); + Character[nPers].item->SetPattern(Character[nPers].endtalkpattern); + Unfreeze(); + Character[nPers].item->WaitForEndPattern(); + } + + Character[nPers].item->SetPattern(Character[nPers].standpattern); + delete text; + } else { + if ((MCharacter[nPers].bInTexts && MCharacter[nPers].numtexts== 0) || !MCharacter[nPers].bInTexts) { + // Cerca di eseguire la funzione custom per chiudere la parlata + MCharacter[nPers].curTalk = (MCharacter[nPers].curTalk%10) + MCharacter[nPers].curgroup*10; + h=mpalQueryDoAction(31,MCharacter[nPers].item->MpalCode(),MCharacter[nPers].curTalk); + if (h!=INVALID_HANDLE_VALUE) + WaitForSingleObject(h,INFINITE); + + MCharacter[nPers].bInTexts = false; + MCharacter[nPers].numtexts = 0; + } + + curBackText = NULL; + delete text; + } + } else { + if ((dwTonyNumTexts== 0 && bTonyInTexts) || !bTonyInTexts) { + Tony->EndTalk(); + dwTonyNumTexts = 0; + bTonyInTexts = false; + } + + delete text; + } + + GlobalFree(string); +} + + +// @@@@ QUESTA NON SI PUO' SKIPPARE!!!!!!!!!!!!!!!!!!! + +DECLARE_CUSTOM_FUNCTION(StartDialog)(uint32 nDialog, uint32 nStartGroup, uint32, uint32) { + int nChoice; + uint32 *sl; + int i,num; + char* string; + RMDialogChoice dc; + int sel; + + curDialog = nDialog; + + // Chiama l'MPAL per iniziare il dialogo + mpalQueryDoDialog(nDialog,nStartGroup); + + // Aspetta che una scelta si presenti + while ((nChoice=mpalQueryDialogWaitForChoice()) != -1) { + // Si fa dare la lista di opzioni e le conta + sl=mpalQueryDialogSelectList(nChoice); + for (num = 0; sl[num] != 0; num++) + ; + + // Se c'e' una sola opzione, la fa automaticamente, e aspetta la prossima scelta + if (num==1) + { + mpalQueryDialogSelection(nChoice,sl[0]); + GlobalFree(sl); + continue; + } + + // Crea una scelta per il dialogo + dc.Init(); + dc.SetNumChoices(num); + + // Scrive tutte le possibili opzioni + for (i = 0;i < num; i++) { + string = mpalQueryDialogPeriod(sl[i]); + assert(string != NULL); + dc.AddChoice(string); + GlobalFree(string); + } + + // Attiva l'oggetto + LinkGraphicTask(&dc); + dc.Show(); + + // Disegna il puntatore + Pointer->SetSpecialPointer(Pointer->PTR_NONE); + MainShowMouse(); + + while (!(Input->MouseLeftClicked() && ((sel = dc.GetSelection()) != -1))) { + WaitFrame(); + Freeze(); + dc.DoFrame(Input->MousePos()); + Unfreeze(); + } + + // Nascondi il puntatore + MainHideMouse(); + + dc.Hide(); + mpalQueryDialogSelection(nChoice, sl[sel]); + + // Chiude la scelta + dc.Close(); + + GlobalFree(sl); + } +} + + + + + +/* + * Sync tra idle e mpal + */ + +DECLARE_CUSTOM_FUNCTION(TakeOwnership)(uint32 num, uint32, uint32, uint32) { +// EnterCriticalSection(&cs[num]); + WaitForSingleObject(mut[num],INFINITE); +} + +DECLARE_CUSTOM_FUNCTION(ReleaseOwnership)(uint32 num, uint32, uint32, uint32) { +// LeaveCriticalSection(&cs[num]); +// g_system->unlockMutex(mut[num]); + warning("TODO: ReleaseOwnership"); +} + + + + + + + + + + + +/* + * Musica + * ------ + * + * Effetti di fade supportati: + * + * nFX = 0 - La nuova musica si sostituisce a quella vecchia + * nFX=1 - La nuova musica si interfade con quella vecchia + * nFX=2 - La nuova musica subentra a tempo con quella vecchia + * + */ + +int curSonoriz = 0; + +bool bFadeOutStop; + +void ThreadFadeInMusic(void *nMusic) { + int i; + int nChannel = (int)nMusic; + + debug("Start FadeIn Music\n"); + + for (i = 0; i < 16; i++) { + _vm->SetMusicVolume(nChannel, i * 4); + Sleep(100); + } + _vm->SetMusicVolume(nChannel, 64); + + debug("End FadeIn Music\n"); + _endthread(); +} + +void ThreadFadeOutMusic(void *nMusic) { + int i; + int nChannel = (int)nMusic; + int startVolume = _vm->GetMusicVolume(nChannel); + + debug("Start FadeOut Music\n"); + + for (i = 16; i > 0 && !bFadeOutStop; i--) { + if (i * 4 < startVolume) + _vm->SetMusicVolume(nChannel, i * 4); + Sleep(100); + } + + if (!bFadeOutStop) + _vm->SetMusicVolume(nChannel, 0); + + // Se uno stacchetto ferma tutto + if (nChannel == 2) + _vm->StopMusic(2); + + debug("End FadeOut Music\n"); + + _endthread(); +} + +DECLARE_CUSTOM_FUNCTION(FadeInSonoriz)(uint32, uint32, uint32, uint32) { + _beginthread(ThreadFadeInMusic, 10240, (void*)curSonoriz); +} + +DECLARE_CUSTOM_FUNCTION(FadeOutSonoriz)(uint32, uint32, uint32, uint32) { + bFadeOutStop = false; + _beginthread(ThreadFadeOutMusic, 10240, (void *)curSonoriz); +} + +DECLARE_CUSTOM_FUNCTION(FadeOutStacchetto)(uint32, uint32, uint32, uint32) { + bFadeOutStop = false; + _beginthread(ThreadFadeOutMusic, 10240, (void*)2); +} + +DECLARE_CUSTOM_FUNCTION(FadeInStacchetto)(uint32, uint32, uint32, uint32) { + _beginthread(ThreadFadeInMusic, 10240, (void*)2); +} + +DECLARE_CUSTOM_FUNCTION(StopSonoriz)(uint32, uint32, uint32, uint32) { + _vm->StopMusic(curSonoriz); +} + +DECLARE_CUSTOM_FUNCTION(StopStacchetto)(uint32, uint32, uint32, uint32) { + _vm->StopMusic(2); +} + +DECLARE_CUSTOM_FUNCTION(MuteSonoriz)(uint32, uint32, uint32, uint32) { + _vm->SetMusicVolume(curSonoriz, 0); +} + +DECLARE_CUSTOM_FUNCTION(DemuteSonoriz)(uint32, uint32, uint32, uint32) { + bFadeOutStop = true; + _vm->SetMusicVolume(curSonoriz, 64); +} + +DECLARE_CUSTOM_FUNCTION(MuteStacchetto)(uint32, uint32, uint32, uint32) { + _vm->SetMusicVolume(2, 0); +} + +DECLARE_CUSTOM_FUNCTION(DemuteStacchetto)(uint32, uint32, uint32, uint32) { + _vm->SetMusicVolume(2, 64); +} + +struct { + const char *name; + int sync; +} musicFiles[] = +{ +/* + { "PREGAME1.ADP", 0 }, { "SONO1.ADP", 0 }, + { "SONO2.ADP", 0 }, { "SONO3.ADP", 0 }, + { "CADUTA.ADP",0 }, { "RISVEGLIO.ADP", 0 }, + { "BACKGROUND.ADP", 0 }, { "PREGAME3.ADP", 0 }, + { "BARBUTA1.ADP", 2450 }, { "BARBUTA2.ADP", 0 }, +*/ + { "00.ADP", 0 }, { "01.ADP", 0 }, + { "02.ADP", 0 }, { "03.ADP", 0 }, + { "04.ADP",0 }, { "05.ADP", 0 }, + { "06.ADP", 0 }, { "07.ADP", 0 }, + { "08.ADP", 2450 }, { "09.ADP", 0 }, + +/* + { "BARBUTA3.ADP", 0 }, { "15-RUFUS.ADP", 0 }, + { "20-MAMMA.ADP", 0 }, { "32-MAMMARADIO.ADP", 0 }, + { "24-TUNNELOV-MIDI.ADP", 0 }, { "34-RAZZO.ADP", 0 }, + { "27-ZUCC1.ADP", 0 }, { "BEAST.ADP", 0 }, + { "22-MORTIMER.ADP", 0 }, { "25-PUB-OVATTATO.ADP", 0 }, +*/ + { "10.ADP", 0 }, { "11.ADP", 0 }, + { "12.ADP", 0 }, { "13.ADP", 0 }, + { "14.ADP", 0 }, { "15.ADP", 0 }, + { "16.ADP", 0 }, { "17.ADP", 0 }, + { "18.ADP", 0 }, { "19.ADP", 0 }, +/* + { "25-PUB.ADP", 0 }, { "ALBERGO.ADP", 0 }, + { "37.ADP", 0 }, { "26-PIRAT.ADP", 0 }, + { "LORENZBACK.ADP", 0 }, { "LORENZ3.ADP", 0 }, + { "CASTLE.ADP", 0 }, { "53-BACKR.ADP", 0 }, + { "16-SMIL1.ADP", 1670 }, { "16-SMIL2.ADP", 0 }, +*/ + { "20.ADP", 0 }, { "21.ADP", 0 }, + { "22.ADP", 0 }, { "23.ADP", 0 }, + { "24.ADP", 0 }, { "25.ADP", 0 }, + { "26.ADP", 0 }, { "27.ADP", 0 }, + { "28.ADP", 1670 }, { "29.ADP", 0 }, +/* + { "16-SMILE.ADP", 0 }, { "16-DIALOG2.ADP", 0 }, + { "07-SHAKE1.ADP", 2900 }, { "07-SHAKE2.ADP", 0 }, + { "07-SHAKE3.ADP", 0 }, { "46-BEEE.ADP", 0 }, + { "434748.ADP", 0 }, { "TORRE.ADP", 0 }, + { "50-DRAGO.ADP", 0 }, { "56-OPERA.ADP", 0 }, +*/ + { "30.ADP", 0 }, { "31.ADP", 0 }, + { "32.ADP", 2900 }, { "33.ADP", 0 }, + { "34.ADP", 0 }, { "35.ADP", 0 }, + { "36.ADP", 0 }, { "37.ADP", 0 }, + { "38.ADP", 0 }, { "39.ADP", 0 }, +/* + { "FLAUTARP.ADP", 0 }, { "01-2001.ADP", 1920 }, + { "02-INTROPANORAMICA.ADP", 1560 }, { "03-PANORAMICA.ADP", 1920 }, + { "04-INTERNI.ADP", 1920 }, { "05-CADEPIUMA.ADP", 1920 }, + { "06-SCENDESCALE.ADP", 1920 }, { "07-THRILL.ADP", 1920 }, + { "08-CADUTAZUCCA.ADP", 1920 }, { "09-PIUMAALEGGIA.ADP", 1920 }, +*/ + { "40.ADP", 0 }, { "41.ADP", 1920 }, + { "42.ADP", 1560 }, { "43.ADP", 1920 }, + { "44.ADP", 1920 }, { "45.ADP", 1920 }, + { "46.ADP", 1920 }, { "47.ADP", 1920 }, + { "48.ADP", 1920 }, { "49.ADP", 1920 }, + +/* + { "10-JACKZUCCONA.ADP", 1920 }, { "11-JACKIMPRECAALLAGRANDELUNA.ADP", 1920 }, + { "12-GRANDELUNALOGO.ADP", 1920 }, { "60-BACKGROUND.ADP", 0 }, + { "TONYSTAR.ADP", 0 }, { "FUNNY.ADP", 0 }, + { "60-INIZIODIALOGO.ADP", 0 }, { "60-DIALOGO.ADP", 0 }, + { "60-JACKFELICE.ADP", 0 }, { "24-TONYVIOLENTATO.ADP", 0 } +*/ + + { "50.ADP", 1920 }, { "51.ADP", 1920 }, + { "52.ADP", 1920 }, { "53.ADP", 0 }, + { "54.ADP", 0 }, { "55.ADP", 0 }, + { "56.ADP", 0 }, { "57.ADP", 0 }, + { "58.ADP", 0 }, { "59.ADP", 0 } + +}; + + +const char *staccFileNames[] = { +/* + "05-MUCCA.ADP", "06-HALOW.ADP", + "LETTERAINIZIO.ADP", "LETTERAPAURA.ADP", + "LETTERAFINE.ADP", "PREGAME2.ADP", + "07-TIMOT.ADP", "15-SHOTRUFUS.ADP", + "15-SHOTTONY.ADP", "27-ZUCC2.ADP", +*/ + "S00.ADP", "S01.ADP", + "S02.ADP", "S03.ADP", + "S04.ADP", "S05.ADP", + "S06.ADP", "S07.ADP", + "S08.ADP", "S09.ADP", + +/* + "53-DLOGO.ADP", "16-DIALOG1.ADP", + "TORRE1.ADP", "GARG1.ADP", + "LORENZ1.ADP", "24-FIGHT.ADP", + "08-MACBETH-PREPARA.ADP", "08-MACBETH-RECITA.ADP", + "GATTO1.ADP" +*/ + "S10.ADP", "S11.ADP", + "S12.ADP", "S13.ADP", + "S14.ADP", "S15.ADP", + "S16.ADP", "S17.ADP", + "S18.ADP" +}; + + +void CustPlayMusic(uint32 nChannel, const char *mFN, uint32 nFX, bool bLoop, int nSync = 0) { + if (nSync == 0) + nSync = 2000; + debug("Start CustPlayMusic\n"); + PlayMusic(nChannel, mFN, nFX, bLoop, nSync); + debug("End CustPlayMusic\n"); +} + +DECLARE_CUSTOM_FUNCTION(PlaySonoriz)(uint32 nMusic, uint32 nFX, uint32 bNoLoop, uint32) { + if (nFX == 0 || nFX == 1 || nFX==2) { + debug("PlaySonoriz stop fadeout\n"); + bFadeOutStop = true; + } + + lastMusic = nMusic; + CustPlayMusic(curSonoriz, musicFiles[nMusic].name, nFX, bNoLoop ? false : true, musicFiles[nMusic].sync); +} + +DECLARE_CUSTOM_FUNCTION(PlayStacchetto)(uint32 nMusic, uint32 nFX, uint32 bLoop, uint32) { + CustPlayMusic(2,staccFileNames[nMusic],nFX,bLoop); +} + +DECLARE_CUSTOM_FUNCTION(PlayItemSfx)(uint32 nItem, uint32 nSFX, uint32, uint32) { + if (nItem== 0) { + Tony->PlaySfx(nSFX); + } else { + RMItem *item = Loc->GetItemFromCode(nItem); + if (item) + item->PlaySfx(nSFX); + } +} + + +void RestoreMusic(void) { + PlaySonoriz(lastMusic, 0, 0, 0); + if (lastTappeto != 0) + CustPlayMusic(4, tappetiFile[lastTappeto], 0, true); +} + +void SaveMusic(Common::OutSaveFile *f) { + f->writeByte(lastMusic); + f->writeByte(lastTappeto); +} + +void LoadMusic(Common::InSaveFile *f) { + lastMusic = f->readByte(); + lastTappeto = f->readByte(); +} + + +DECLARE_CUSTOM_FUNCTION(StacchettoFadeStart)(uint32 nStacc, uint32 bLoop, uint32, uint32) { + FadeOutSonoriz(0, 0, 0, 0); + MuteStacchetto(0, 0, 0, 0); + PlayStacchetto(nStacc, 0, bLoop, 0); + FadeInStacchetto(0, 0, 0, 0); +} + +DECLARE_CUSTOM_FUNCTION(StacchettoFadeEnd)(uint32 nStacc, uint32 bLoop, uint32, uint32) { + FadeOutStacchetto(0, 0, 0, 0); + FadeInSonoriz(0, 0, 0, 0); +} + + + + +DECLARE_CUSTOM_FUNCTION(MustSkipIdleStart)(uint32, uint32, uint32, uint32) { + bSkipIdle = true; + SetEvent(hSkipIdle); +} + +DECLARE_CUSTOM_FUNCTION(MustSkipIdleEnd)(uint32, uint32, uint32, uint32) { + bSkipIdle = false; + ResetEvent(hSkipIdle); +} + +DECLARE_CUSTOM_FUNCTION(PatIrqFreeze)(uint32 bStatus, uint32, uint32, uint32) { + bPatIrqFreeze = bStatus; +} + +DECLARE_CUSTOM_FUNCTION(OpenInitLoadMenu)(uint32 , uint32, uint32, uint32) { + Freeze(); + _vm->OpenInitLoadMenu(); + Unfreeze(); +} + +DECLARE_CUSTOM_FUNCTION(OpenInitOptions)(uint32 , uint32, uint32, uint32) { + Freeze(); + _vm->OpenInitOptions(); + Unfreeze(); +} + + +DECLARE_CUSTOM_FUNCTION(DoCredits)(uint32 nMsg, uint32 dwTime, uint32, uint32) { + RMMessage msg(nMsg); + RMTextDialog *text; + HANDLE hDisable = CreateEvent(NULL, true, false, NULL); + int i; + uint32 startTime; + + text = new RMTextDialog[msg.NumPeriods()]; + + for (i = 0; i < msg.NumPeriods(); i++) { + text[i].SetInput(Input); + + // Allineamento + if (msg[i][0] == '@') { + text[i].SetAlignType(RMText::HCENTER, RMText::VTOP); + text[i].WriteText(&msg[i][1], 3); + text[i].SetPosition(RMPoint(414, 70 + i * 26)); // 70 + } else { + text[i].SetAlignType(RMText::HLEFT,RMText::VTOP); + text[i].WriteText(msg[i], 3); + text[i].SetPosition(RMPoint(260, 70 + i * 26)); + } + + + // Setta la posizione + text[i].SetAlwaysDisplay(); + text[i].SetForcedTime(dwTime * 1000); + text[i].SetNoTab(); + + // Aspetta la fine della visualizzazione + text[i].SetCustomSkipHandle(hDisable); + + // Registra il testo + LinkGraphicTask(&text[i]); + } + + startTime = _vm->GetTime(); + + while (startTime + dwTime * 1000 > _vm->GetTime()) { + WaitFrame(); + if (Input->MouseLeftClicked() || Input->MouseRightClicked()) + break; + if ((GetAsyncKeyState(Common::KEYCODE_TAB) & 0x8001) == 0x8001) + break; + } + + SetEvent(hDisable); + + WaitFrame(); + WaitFrame(); + + delete[] text; +} + + + +BEGIN_CUSTOM_FUNCTION_MAP() + + ASSIGN( 1, CustLoadLocation) + ASSIGN( 2, MySleep) + ASSIGN( 3, SetPointer) + ASSIGN( 5, MoveTony) + ASSIGN( 6, FaceToMe) + ASSIGN( 7, BackToMe) + ASSIGN( 8, LeftToMe) + ASSIGN( 9, RightToMe) + ASSIGN( 10, SendTonyMessage) + ASSIGN( 11, ChangeBoxStatus) + ASSIGN( 12, ChangeLocation) + ASSIGN( 13, DisableTony) + ASSIGN( 14, EnableTony) + ASSIGN( 15, WaitForPatternEnd) + ASSIGN( 16, SetLocStartPosition) + ASSIGN( 17, ScrollLocation) + ASSIGN( 18, MoveTonyAndWait) + ASSIGN( 19, ChangeHotspot) + ASSIGN( 20, AddInventory) + ASSIGN( 21, RemoveInventory) + ASSIGN( 22, ChangeInventoryStatus) + ASSIGN( 23, SetTonyPosition) + ASSIGN( 24, SendFullscreenMessage) + ASSIGN( 25, SaveTonyPosition) + ASSIGN( 26, RestoreTonyPosition) + ASSIGN( 27, DisableInput) + ASSIGN( 28, EnableInput) + ASSIGN( 29, StopTony) + + ASSIGN( 30, TonyTakeUp1) + ASSIGN( 31, TonyTakeMid1) + ASSIGN( 32, TonyTakeDown1) + ASSIGN( 33, TonyTakeUp2) + ASSIGN( 34, TonyTakeMid2) + ASSIGN( 35, TonyTakeDown2) + + ASSIGN( 72, TonyPutUp1) + ASSIGN( 73, TonyPutMid1) + ASSIGN( 74, TonyPutDown1) + ASSIGN( 75, TonyPutUp2) + ASSIGN( 76, TonyPutMid2) + ASSIGN( 77, TonyPutDown2) + + ASSIGN( 36, TonyPerTerra) + ASSIGN( 37, TonySiRialza) + ASSIGN( 38, TonyPastorella) + ASSIGN( 39, TonyFischietto) + + ASSIGN( 40, TonyRide) + ASSIGN( 41, TonyFianchi) + ASSIGN( 42, TonyCanta) + ASSIGN( 43, TonySiIndica) + ASSIGN( 44, TonySpaventatoConMani) + ASSIGN( 49, TonySpaventatoSenzaMani) + ASSIGN( 45, TonyConBicchiere) + ASSIGN( 46, TonyConVerme) + ASSIGN( 47, TonyConMartello) + ASSIGN( 48, TonyConCorda) + ASSIGN( 90, TonyConConiglioANIM) + ASSIGN( 91, TonyConRicettaANIM) + ASSIGN( 92, TonyConCarteANIM) + ASSIGN( 93, TonyConPupazzoANIM) + ASSIGN( 94, TonyConPupazzoStart) + ASSIGN( 95, TonyConPupazzoEnd) + ASSIGN( 96, TonyConConiglioStart) + ASSIGN( 97, TonyConConiglioEnd) + ASSIGN( 98, TonyConRicettaStart) + ASSIGN( 99, TonyConRicettaEnd) + ASSIGN(100, TonyConCarteStart) + ASSIGN(101, TonyConCarteEnd) + ASSIGN(102, TonyConTaccuinoStart) + ASSIGN(103, TonyConTaccuinoEnd) + ASSIGN(104, TonyConMegafonoStart) + ASSIGN(105, TonyConMegafonoEnd) + ASSIGN(106, TonyConBarbaStart) + ASSIGN(107, TonyConBarbaEnd) + ASSIGN(108, TonyRidacchia) + ASSIGN(109, TonySchifato) + ASSIGN(110, TonyNaah) + ASSIGN(111, TonyMacbeth) + ASSIGN(112, TonySniffaLeft) + ASSIGN(113, TonySniffaRight) + ASSIGN(114, TonySpaventatoStart) + ASSIGN(115, TonySpaventatoEnd) + ASSIGN(116, TonyConSegretaria) + + ASSIGN( 50, CharSetCode) + ASSIGN( 51, CharSetColor) + ASSIGN( 52, CharSetTalkPattern) + ASSIGN( 53, CharSendMessage) + ASSIGN( 54, CharSetStartEndTalkPattern) + + ASSIGN( 60, MCharSetCode) + ASSIGN( 61, MCharSetColor) + ASSIGN( 62, MCharSetCurrentGroup) + ASSIGN( 63, MCharSetNumTalksInGroup) + ASSIGN( 64, MCharSetNumTexts) + ASSIGN( 65, MCharSendMessage) + ASSIGN( 66, MCharSetPosition) + ASSIGN( 67, MCharSetAlwaysBack) + ASSIGN( 68, MCharResetCode) + + ASSIGN( 70, StartDialog) + ASSIGN( 71, SendDialogMessage) + + ASSIGN( 80, TakeOwnership) + ASSIGN( 81, ReleaseOwnership) + + ASSIGN( 86, PlaySonoriz) + ASSIGN( 87, PlayStacchetto) + ASSIGN( 88, FadeInSonoriz) + ASSIGN( 89, FadeOutSonoriz) + ASSIGN(123, FadeInStacchetto) + ASSIGN(124, FadeOutStacchetto) + ASSIGN(125, MuteSonoriz) + ASSIGN(126, DemuteSonoriz) + ASSIGN(127, MuteStacchetto) + ASSIGN(128, DemuteStacchetto) + ASSIGN( 84, StopSonoriz) + ASSIGN( 85, StopStacchetto) + ASSIGN( 83, PlayItemSfx) + ASSIGN(129, StacchettoFadeStart) + ASSIGN(130, StacchettoFadeEnd) + + ASSIGN(120, TremaSchermo) + ASSIGN(121, AutoSave) + ASSIGN(122, Abort) + ASSIGN(131, NoOcchioDiBue) + ASSIGN(132, SendFullscreenMsgStart) + ASSIGN(133, SendFullscreenMsgEnd) + ASSIGN(134, CustEnableGUI) + ASSIGN(135, CustDisableGUI) + ASSIGN(136, ClearScreen) + ASSIGN(137, PatIrqFreeze) + ASSIGN(138, TonySetPalesati) + ASSIGN(139, OpenInitLoadMenu) + ASSIGN(140, OpenInitOptions) + ASSIGN(141, SyncScrollLocation) + ASSIGN(142, CloseLocation) + ASSIGN(143, SetAlwaysDisplay) + ASSIGN(144, DoCredits) + + ASSIGN( 200, MustSkipIdleStart); + ASSIGN( 201, MustSkipIdleEnd); + +END_CUSTOM_FUNCTION_MAP() + +void SetupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation *loc, RMInventory *inv, RMInput *input) { + Tony = tony; + Pointer = ptr; + Boxes = box; + Loc = loc; + Inventory = inv; + Input = input; + + LoadLocation = MainLoadLocation; + UnloadLocation = MainUnloadLocation; + LinkGraphicTask = MainLinkGraphicTask; + Freeze = MainFreeze; + Unfreeze = MainUnfreeze; + WaitFrame = MainWaitFrame; + PlayMusic = MainPlayMusic; + InitWipe = MainInitWipe; + CloseWipe = MainCloseWipe; + WaitWipeEnd = MainWaitWipeEnd; + DisableGUI = MainDisableGUI; + EnableGUI = MainEnableGUI; + SetPalesati = MainSetPalesati; + + g_system->lockMutex(vdb); + + bAlwaysDisplay = false; + int i; +/* + for (i = 0;i < 10; i++) + InitializeCriticalSection(&cs[i]); + for (i = 0;i < 10; i++) + mut[i] = CreateMutex(NULL, false, NULL); +*/ + for (i = 0; i < 200; i++) + tappeti[i] = 0; + + tappeti[6] = T_GRILLI; + tappeti[7] = T_GRILLI; + tappeti[8] = T_GRILLIOV; + tappeti[10] = T_GRILLI; + tappeti[12] = T_GRILLI; + tappeti[13] = T_GRILLIOV; + tappeti[15] = T_GRILLI; + tappeti[16] = T_GRILLIVENTO; + tappeti[18] = T_GRILLI; + tappeti[19] = T_GRILLIVENTO; + tappeti[20] = T_GRILLI; + tappeti[23] = T_GRILLI; + tappeti[26] = T_MAREMETA; + tappeti[27] = T_GRILLI; + tappeti[28] = T_GRILLIVENTO; + tappeti[31] = T_GRILLI; + tappeti[33] = T_MARE; + tappeti[35] = T_MARE; + tappeti[36] = T_GRILLI; + tappeti[37] = T_GRILLI; + tappeti[40] = T_GRILLI; + tappeti[41] = T_GRILLI; + tappeti[42] = T_GRILLI; + tappeti[45] = T_GRILLI; + tappeti[51] = T_GRILLI; + tappeti[52] = T_GRILLIVENTO1; + tappeti[53] = T_GRILLI; + tappeti[54] = T_GRILLI; + tappeti[57] = T_VENTO; + tappeti[58] = T_VENTO; + tappeti[60] = T_VENTO; + + + + // Crea l'evento per skippare le idle + hSkipIdle = CreateEvent(NULL, true, false, NULL); +} + +} // end of namespace Tony diff --git a/engines/tony/custom.h b/engines/tony/custom.h new file mode 100644 index 0000000000..ee85c8dd41 --- /dev/null +++ b/engines/tony/custom.h @@ -0,0 +1,106 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * + */ +/************************************************************************** + * 様様様様様様様様様様様様様様様様様 * + * Nayma Software srl * + * e -= We create much MORE than ALL =- * + * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * + * .d" d$$$$$b "b. * + * .z$* d$$$$$$$L ^*$c. * + * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * + * ^*$b 4$$$$$$$$$F .d$*" * + * ^$$. 4$$$$$$$$$F .$P" Module: Custom.CPP........... * + * *$. '$$$$$$$$$ 4$P 4 * + * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * + * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * + * z$" "" #$F^ "" '$c Desc: Custom functions..... * + * z$$beu .ue=" $ "=e.. .zed$$c ..................... * + * "#$e z$*" . `. ^*Nc e$"" ..................... * + * "$$". .r" ^4. .^$$" ..................... * + * ^.@*"6L=\ebu^+C$"*b." * + * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * + * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * + * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * + * * + * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * + * * + ************************************************************************** + +/** RCS + * + * $Id: $ + * + **/ + +#ifndef TONY_CUSTOM_H +#define TONY_CUSTOM_H + +#include "tony/mpal/mpal.h" + +namespace Tony { + +using namespace MPAL; + +/* + * Defines + */ + +typedef uint32 HWND; + +typedef void __declspec(dllexport) (*INIT_CUSTOM_FUNCTION_TYPE)(HWND, LPCUSTOMFUNCTION *); + +#define INIT_CUSTOM_FUNCTION MapCustomFunctions +#define INIT_CUSTOM_FUNCTION_STRING "MapCustomFunctions" + +#define DECLARE_CUSTOM_FUNCTION(x) void x + +#define BEGIN_CUSTOM_FUNCTION_MAP() \ + static void AssignError(HWND hWnd, int num) { \ + error("Custom function %u has been already assigned!", num); \ + } \ + void INIT_CUSTOM_FUNCTION(HWND hWnd, LPCUSTOMFUNCTION *lpMap) \ + { + + +#define END_CUSTOM_FUNCTION_MAP() \ + } + + +#define ASSIGN(num,func) \ + if (lpMap[num]!=NULL) \ + AssignError(hWnd,num); \ + lpMap[num]=func; + +class RMTony; +class RMPointer; +class RMGameBoxes; +class RMLocation; +class RMInventory; +class RMInput; + +void INIT_CUSTOM_FUNCTION(HWND hWnd, LPCUSTOMFUNCTION *lpMap); +void SetupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation *loc, RMInventory *inv, RMInput *input); + +#endif + +} // end of namespace Tony diff --git a/engines/tony/detection.cpp b/engines/tony/detection.cpp index 58d16842d4..6be0ca302c 100644 --- a/engines/tony/detection.cpp +++ b/engines/tony/detection.cpp @@ -43,6 +43,10 @@ Common::Language TonyEngine::getLanguage() const { return _gameDescription->desc.language; } +bool TonyEngine::getIsDemo() const { + return _gameDescription->desc.flags & ADGF_DEMO; +} + } static const PlainGameDescriptor tonyGames[] = { diff --git a/engines/tony/font.h b/engines/tony/font.h index 348e7618ea..57a8b1c4fb 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -55,6 +55,8 @@ namespace Tony { class RMInventory; +class RMLoc; +class RMItem; /** * Gestisce un font, in cui ha varie surface per ogni lettera @@ -318,7 +320,7 @@ class RMTextItemName : protected RMText { protected: RMPoint m_mpos; RMPoint m_curscroll; - RMItem* m_item; + RMItem *m_item; RMString m_itemName; public: @@ -330,10 +332,10 @@ public: void DoFrame(RMGfxTargetBuffer &bigBuf, RMLocation &loc, RMPointer &ptr, RMInventory &inv); virtual void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); - RMPoint GetHotspot() { if (m_item==NULL) return m_mpos+m_curscroll; else return m_item->Hotspot(); } - RMItem* GetSelectedItem() { return m_item; } - bool IsItemSelected() { return m_item!=NULL; } - bool IsNormalItemSelected() { return m_item!=NULL && m_itemName.Length()>0; } + RMPoint GetHotspot(); + RMItem *GetSelectedItem(); + bool IsItemSelected(); + bool IsNormalItemSelected(); virtual bool RemoveThis() { return true; } }; diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 48827cbc2a..d759ef510a 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -45,10 +45,1158 @@ * * **************************************************************************/ +#include "common/file.h" +#include "common/savefile.h" +#include "tony/mpal/lzo.h" +#include "tony/mpal/memory.h" +#include "tony/mpal/mpal.h" +#include "tony/mpal/mpalutils.h" +#include "tony/mpal/stubs.h" +#include "tony/custom.h" #include "tony/game.h" +#include "tony/gfxengine.h" +#include "tony/tony.h" namespace Tony { +using namespace MPAL; +/****************************************/ +/* Variabili globali di configurazione */ +/****************************************/ + +// FIXME: Move into a class instance +bool bCfgInvLocked; +bool bCfgInvNoScroll; +bool bCfgTimerizedText; +bool bCfgInvUp; +bool bCfgAnni30; +bool bCfgAntiAlias; +bool bCfgSottotitoli; +bool bCfgTransparence; +bool bCfgInterTips; +bool bCfgDubbing; +bool bCfgMusic; +bool bCfgSFX; +int nCfgTonySpeed; +int nCfgTextSpeed; +int nCfgDubbingVolume; +int nCfgMusicVolume; +int nCfgSFXVolume; +bool bSkipSfxNoLoop; + +bool bPatIrqFreeze; + +/****************************************/ +/* Funzioni globali per la DLL Custom */ +/****************************************/ + +static char path_buffer[_MAX_PATH]; +static char drive[_MAX_DRIVE]; +static char dir[_MAX_DIR]; +static char fname[_MAX_FNAME]; +static char ext[_MAX_EXT]; + +HANDLE MainLoadLocation(int nLoc, RMPoint pt, RMPoint start) { + return _vm->GetEngine()->LoadLocation(nLoc,pt,start); +} + +HANDLE MainUnloadLocation(bool bDoOnExit) { + return _vm->GetEngine()->UnloadLocation(bDoOnExit); +} + +void MainLinkGraphicTask(RMGfxTask *task) { + _vm->GetEngine()->LinkGraphicTask(task); +} + +void MainFreeze(void) { + _vm->GetEngine()->Freeze(); +} + +void MainUnfreeze(void) { + _vm->GetEngine()->Unfreeze(); +} + +void MainWaitFrame(void) { + WaitForSingleObject(_vm->m_hEndOfFrame, INFINITE); +} + +void MainShowMouse(void) { + _vm->GetEngine()->EnableMouse(); +} + +void MainHideMouse(void) { + _vm->GetEngine()->DisableMouse(); +} + +void MainPlayMusic(int nChannel, char* filename, int nFX, bool bLoop, int nSync) { + _vm->PlayMusic(nChannel, filename, nFX, bLoop, nSync); +} + +void MainDisableInput(void) { + _vm->GetEngine()->DisableInput(); +} + +void MainEnableInput(void) { + _vm->GetEngine()->EnableInput(); +} + +void MainInitWipe(int type) { + _vm->GetEngine()->InitWipe(type); +} + +void MainCloseWipe(void) { + _vm->GetEngine()->CloseWipe(); +} + +void MainWaitWipeEnd(void) { + _vm->GetEngine()->WaitWipeEnd(); +} + +void MainEnableGUI(void) { + _vm->GetEngine()->m_bGUIInterface = true; + _vm->GetEngine()->m_bGUIInventory = true; + _vm->GetEngine()->m_bGUIOption = true; +} + +void MainDisableGUI(void) { + _vm->GetEngine()->m_bGUIInterface = false; + _vm->GetEngine()->m_bGUIInventory = false; + _vm->GetEngine()->m_bGUIOption = false; +} + +void MainSetPalesati(bool bPalesati) { + _vm->GetEngine()->SetPalesati(bPalesati); +} + +/****************************************************************************\ +* Metodi di RMOptionButton +\****************************************************************************/ + +RMOptionButton::RMOptionButton(uint32 dwRes, RMPoint pt, bool bDoubleState) { + RMResRaw raw(dwRes); + assert(raw.IsValid()); + m_buf = new RMGfxSourceBuffer16(false); + m_buf->Init(raw, raw.Width(), raw.Height()); + + m_rect.SetRect(pt.x, pt.y, pt.x + raw.Width() - 1, pt.y + raw.Height() - 1); + m_bActive = false; + m_bHasGfx = true; + m_bDoubleState = bDoubleState; +} + +RMOptionButton::RMOptionButton(RMRect pt) { + m_rect = pt; + m_bActive = false; + m_bHasGfx = false; + m_bDoubleState = false; +} + +RMOptionButton::~RMOptionButton() { + if (m_bHasGfx) + delete m_buf; +} + +bool RMOptionButton::DoFrame(RMPoint mousePos, bool bLeftClick, bool bRightClick) { + if (!m_bDoubleState) { + if (m_rect.PtInRect(mousePos)) { + if (!m_bActive) { + m_bActive=true; + return true; + } + } else { + if (m_bActive) { + m_bActive=false; + return true; + } + } + } else { + if (bLeftClick && m_rect.PtInRect(mousePos)) { + m_bActive = !m_bActive; + return true; + } + } + + return false; +} + + + +void RMOptionButton::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + if (!m_bActive) + return; + + if (m_bHasGfx) + m_buf->Draw(bigBuf,prim); +} + +void RMOptionButton::AddToList(RMGfxTargetBuffer &bigBuf) { + if (m_bHasGfx) + bigBuf.AddPrim(new RMGfxPrimitive(this, m_rect)); +} + + +/****************************************************************************\ +* RMOptionSlide methods +\****************************************************************************/ + +#define INIT_GFX16_FROMRAW(dwRes, buf16) \ + raw = new RMResRaw(dwRes); \ + assert(raw->IsValid()); \ + assert((buf16) == NULL); \ + (buf16) = new RMGfxSourceBuffer16(false); \ + (buf16)->Init(*raw,raw->Width(),raw->Height()); \ + delete raw; + +#define INIT_GFX8_FROMRAW(dwRes, buf8) \ + raw = new RMResRaw(dwRes); \ + assert(raw->IsValid()); \ + assert((buf8) == NULL); \ + (buf8) = new RMGfxSourceBuffer8RLEByte(); \ + (buf8)->Init(*raw, raw->Width(), raw->Height(), true); \ + delete raw; + +/****************************************************************************\ +* Metodi di RMGfxEngine +\****************************************************************************/ + +bool bIdleExited; + +void ExitAllIdles(int nCurLoc) { + // Chiude le idle + bSkipSfxNoLoop = true; + mpalEndIdlePoll(nCurLoc); + bIdleExited = true; + bSkipSfxNoLoop = false; + ExitThread(0); +} + + +RMGfxEngine::RMGfxEngine() { + // Crea il big buffer dove verranno disegnati i frame + m_bigBuf.Create(RM_BBX, RM_BBY, 16); + m_bigBuf.OffsetY(RM_SKIPY); +} + +RMGfxEngine::~RMGfxEngine() { + // Chiude il buffer + m_bigBuf.Destroy(); +} + +void RMGfxEngine::OpenOptionScreen(int type) { + bool bRes; + + switch (type) { + case 0: + bRes=m_opt.Init(m_bigBuf); + break; + case 1: + bRes=m_opt.InitLoadMenuOnly(m_bigBuf, true); + break; + case 2: + bRes=m_opt.InitNoLoadSave(m_bigBuf); + break; + case 3: + bRes=m_opt.InitLoadMenuOnly(m_bigBuf, false); + break; + case 4: + bRes=m_opt.InitSaveMenuOnly(m_bigBuf, false); + break; + } + + if (bRes) { + _vm->PauseSound(true); + + DisableInput(); + m_inv.EndCombine(); + m_curActionObj=0; + m_curAction=TA_GOTO; + m_point.SetAction(m_curAction); + m_point.SetSpecialPointer(RMPointer::PTR_NONE); + m_point.SetCustomPointer(NULL); + EnableMouse(); + _vm->GrabThumbnail(); + + // Esce la IDLE onde evitare la morte prematura in caricamento + m_bMustEnterMenu = true; + if (type == 1 || type == 2) { + bIdleExited = true; + } else { + m_tony.StopNoAction(); + + uint32 id; + bIdleExited = false; + CreateThread(NULL, 10240, (LPTHREAD_START_ROUTINE)ExitAllIdles, (void *)m_nCurLoc, 0, &id); + } + } +} + +void RMGfxEngine::DoFrame(bool bDrawLocation) { + g_system->lockMutex(csMainLoop); + + // Poll dei dispositivi di input + m_input.Poll(); + + if (m_bMustEnterMenu && bIdleExited) { + m_bOption = true; + m_bMustEnterMenu = false; + bIdleExited = false; + } + + if (m_bOption) { + m_opt.DoFrame(&m_input); + m_bOption = !m_opt.IsClosing(); + if (!m_bOption) { + DisableMouse(); + EnableInput(); + mpalStartIdlePoll(m_nCurLoc); + _vm->PauseSound(false); + } + } + + if (bDrawLocation && m_bLocationLoaded) { + // Locazione e oggetti + m_loc.DoFrame(&m_bigBuf); + + // Controlla gli input del mouse + if (m_bInput && !m_tony.InAction()) { + // Se siamo sull'inventario, lui che controlla tutti gli input + if (m_inv.HaveFocus(m_input.MousePos()) && !m_inter.Active()) { + // CLICK SINISTRO + // ************** + if (m_input.MouseLeftClicked()/* && m_itemName.IsItemSelected()*/) { + // Left click attiva il combine, se siamo su un oggetto + if (m_inv.LeftClick(m_input.MousePos(),m_curActionObj)) { + m_curAction=TA_COMBINE; + m_point.SetAction(m_curAction); + } + } + else + + // CLICK DESTRO + // ************ + if (m_input.MouseRightClicked()) { + if(m_itemName.IsItemSelected()) { + m_curActionObj=0; + m_inv.RightClick(m_input.MousePos()); + } else + m_inv.RightClick(m_input.MousePos()); + } else + + // RILASCIO DESTRO + // *************** + if (m_input.MouseRightReleased()) { + if (m_inv.RightRelease(m_input.MousePos(), m_curAction)) { + m_tony.MoveAndDoAction(m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), m_curAction); + + m_curAction=TA_GOTO; + m_point.SetAction(m_curAction); + } + } + } else { + // Menu Opzioni + // ************ + if (m_bGUIOption) { + if (!m_tony.InAction() && m_bInput) { + if ((m_input.MouseLeftClicked() && m_input.MousePos().x < 3 && m_input.MousePos().y < 3)) { + OpenOptionScreen(0); + goto SKIPCLICKSINISTRO; + } else if ((GetAsyncKeyState(Common::KEYCODE_ESCAPE) & 0x8001) == 0x8001) + OpenOptionScreen(0); + else if (!_vm->getIsDemo()) { + if ((GetAsyncKeyState(Common::KEYCODE_F3) & 0x8001)==0x8001) + OpenOptionScreen(3); + else if ((GetAsyncKeyState(Common::KEYCODE_F2) & 0x8001)==0x8001) + OpenOptionScreen(4); + } + } + } + + // CLICK SINISTRO + // ************** + if (m_input.MouseLeftClicked() && !m_inter.Active()) { + // Se clicko dentro un oggetto, esegui l'azione + //if (m_itemName.IsItemSelected()) + { + if (m_curAction!=TA_COMBINE) + m_tony.MoveAndDoAction(m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), m_point.CurAction()); + else if (m_itemName.GetSelectedItem() != NULL) + m_tony.MoveAndDoAction(m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), TA_COMBINE, m_curActionObj); + } + + if (m_curAction==TA_COMBINE) { + m_inv.EndCombine(); + m_point.SetSpecialPointer(RMPointer::PTR_NONE); + } + + m_curAction=TA_GOTO; + m_point.SetAction(m_curAction); + } + +SKIPCLICKSINISTRO: + // CLICK DESTRO + // ************ + if (m_curAction == TA_COMBINE) { + // Durante il combine, lo annulla. + if (m_input.MouseRightClicked()) { + m_inv.EndCombine(); + m_curActionObj = 0; + m_curAction = TA_GOTO; + m_point.SetAction(m_curAction); + m_point.SetSpecialPointer(RMPointer::PTR_NONE); + } + } else if (m_input.MouseRightClicked() && m_itemName.IsItemSelected() && m_point.GetSpecialPointer() == RMPointer::PTR_NONE) { + if (m_bGUIInterface) { + // Prima di aprire l'interfaccia, rimette GOTO + m_curAction = TA_GOTO; + m_curActionObj = 0; + m_point.SetAction(m_curAction); + m_inter.Clicked(m_input.MousePos()); + } + } + + + // RILASCIO DESTRO + // *************** + if (m_input.MouseRightReleased()) { + if (m_bGUIInterface) { + if (m_inter.Released(m_input.MousePos(), m_curAction)) { + m_point.SetAction(m_curAction); + m_tony.MoveAndDoAction(m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), m_curAction); + + m_curAction=TA_GOTO; + m_point.SetAction(m_curAction); + } + } + } + } + + // Aggiorna il nome sotto il puntatore del mouse + m_itemName.SetMouseCoord(m_input.MousePos()); + if (!m_inter.Active() && !m_inv.MiniActive()) + m_itemName.DoFrame(m_bigBuf, m_loc, m_point, m_inv); + } + + // Inventario & interfaccia + m_inter.DoFrame(m_bigBuf, m_input.MousePos()); + m_inv.DoFrame(m_bigBuf, m_point, m_input.MousePos(), (!m_tony.InAction() && !m_inter.Active() && m_bGUIInventory)); + } + + // Anima Tony + m_tony.DoFrame(&m_bigBuf, m_nCurLoc); + + // Aggiorna lo scrolling per tenere Tony dentro lo schermo + if (m_tony.MustUpdateScrolling() && m_bLocationLoaded) { + RMPoint showThis=m_tony.Position(); + showThis.y -= 60; + m_loc.UpdateScrolling(showThis); + } + + if (m_bLocationLoaded) + m_tony.SetScrollPosition(m_loc.ScrollPosition()); + + if ((!m_tony.InAction() && m_bInput) || m_bAlwaysDrawMouse) { + m_point.SetCoord(m_input.MousePos()); + m_point.DoFrame(&m_bigBuf); + } + + // ********************** + // Disegna la lista di OT + // ********************** + m_bigBuf.DrawOT(); + +#define FSTEP (480/32) + + // Wipe + if (m_bWiping) + { + switch (m_nWipeType) { + case 1: + if (!(m_rcWipeEllipse.bottom-m_rcWipeEllipse.top>=FSTEP*2)) { + SetEvent(m_hWipeEvent); + m_nWipeType=3; + break; + } + + m_rcWipeEllipse.top+=FSTEP; + m_rcWipeEllipse.left+=FSTEP; + m_rcWipeEllipse.right-=FSTEP; + m_rcWipeEllipse.bottom-=FSTEP; + break; + + case 2: + if (!(m_rcWipeEllipse.bottom-m_rcWipeEllipse.top<480-FSTEP)) { + SetEvent(m_hWipeEvent); + m_nWipeType=3; + break; + } + + m_rcWipeEllipse.top-=FSTEP; + m_rcWipeEllipse.left-=FSTEP; + m_rcWipeEllipse.right+=FSTEP; + m_rcWipeEllipse.bottom+=FSTEP; + break; + } + } + + g_system->unlockMutex(csMainLoop); +} + + +void RMGfxEngine::InitCustomDll(void) { + SetupGlobalVars(&m_tony, &m_point, &_vm->_theBoxes, &m_loc, &m_inv, &m_input); +} + +void RMGfxEngine::ItemIrq(uint32 dwItem, int nPattern, int nStatus) { + static RMGfxEngine *This = NULL; + RMItem *item; + + // Inizializzazione! + if ((int)dwItem == -1) + { + This=(RMGfxEngine*)nPattern; + return; + } + + if (This->m_bLocationLoaded) { + item = This->m_loc.GetItemFromCode(dwItem); + if (item != NULL) { + if (nPattern != -1) { + if (bPatIrqFreeze) + MainFreeze(); + item->SetPattern(nPattern, true); + if (bPatIrqFreeze) + MainUnfreeze(); + } + if (nStatus!=-1) + item->SetStatus(nStatus); + } + } +} + +/* + // WINBUG: This is a special case for the file open/save dialog, + // which sometimes pumps while it is coming up but before it has + // disabled the main window. + HWND hWndFocus = ::GetFocus(); + bool bEnableParent = false; + m_ofn.hwndOwner = PreModal(); + AfxUnhookWindowCreate(); + if (m_ofn.hwndOwner != NULL && ::IsWindowEnabled(m_ofn.hwndOwner)) + { + bEnableParent = true; + ::EnableWindow(m_ofn.hwndOwner, false); + } + + _AFX_THREAD_STATE* pThreadState = AfxGetThreadState(); + assert(pThreadState->m_pAlternateWndInit == NULL); + + if (m_ofn.Flags & OFN_EXPLORER) + pThreadState->m_pAlternateWndInit = this; + else + AfxHookWindowCreate(this); + + int nResult; + if (m_bOpenFileDialog) + nResult = ::GetOpenFileName(&m_ofn); + else + nResult = ::GetSaveFileName(&m_ofn); + + if (nResult) + assert(pThreadState->m_pAlternateWndInit == NULL); + pThreadState->m_pAlternateWndInit = NULL; + + // WINBUG: Second part of special case for file open/save dialog. + if (bEnableParent) + ::EnableWindow(m_ofn.hwndOwner, true); + if (::IsWindow(hWndFocus)) + ::SetFocus(hWndFocus); +*/ + + +void RMGfxEngine::SelectLocation(RMPoint ptTonyStart, RMPoint start) { +#if 0 + OPENFILENAME ofn; + char lpszFileName[512]; + + // @@@ Con TonyStart=-1,-1 allora usa la posizione scritta nella locazione + + // Sceglie la locazione + ZeroMemory(lpszFileName,512); + ZeroMemory(&ofn,sizeof(ofn)); + ofn.lStructSize=sizeof(ofn); + ofn.hwndOwner=NULL; + ofn.lpstrFilter="Locazione (*.LOC)\0*.LOC\0Locazione ottimizzata (*.LOX)\0*.LOX\0Tutti i files (*.*)\0*.*\0"; + ofn.lpstrCustomFilter=NULL; + ofn.nFilterIndex=1; + ofn.lpstrFile=lpszFileName; + ofn.nMaxFile=512; + ofn.lpstrInitialDir=NULL; + ofn.lpstrTitle="Load Location"; + ofn.Flags=OFN_FILEMUSTEXIST|OFN_HIDEREADONLY|OFN_PATHMUSTEXIST; + + if (!GetOpenFileName(&ofn)) + assert(0); + + // Carica la locazione + m_loc.Load(lpszFileName); + m_bLocationLoaded = true; + m_nCurLoc=m_loc.TEMPGetNumLoc(); + + if (ptTonyStart.x==-1 && ptTonyStart.y==-1) + InitForNewLocation(m_loc.TEMPGetNumLoc(),m_loc.TEMPGetTonyStart(),RMPoint(-1,-1)); + else + InitForNewLocation(m_loc.TEMPGetNumLoc(),ptTonyStart,start); +#endif +} + +void RMGfxEngine::InitForNewLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { + if (start.x == -1 || start.y == -1) { + start.x = ptTonyStart.x-RM_SX/2; + start.y = ptTonyStart.y-RM_SY/2; + } + + m_loc.SetScrollPosition(start); + + if (ptTonyStart.x==0 && ptTonyStart.y==0) { + } else { + m_tony.SetPosition(ptTonyStart, nLoc); + m_tony.SetScrollPosition(start); + } + + m_curAction=TA_GOTO; + m_point.SetCustomPointer(NULL); + m_point.SetSpecialPointer(RMPointer::PTR_NONE); + m_point.SetAction(m_curAction); + m_inter.Reset(); + m_inv.Reset(); + + mpalStartIdlePoll(m_nCurLoc); +} + +HANDLE RMGfxEngine::LoadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { + bool bLoaded; + int i; + + m_nCurLoc=nLoc; + + bLoaded = false; + for (i = 0; i < 5; i++) { + // Retry sul loading della locazione + RMRes res(m_nCurLoc); + if (!res.IsValid()) + continue; +#if 0 + // codice per dumpare una locazione in caso serva una modifica + if (nLoc == 106) + { + FILE *f = fopen("loc106.lox", "wb"); + fwrite(res.DataPointer(), res.Size(), 1, f); + fclose(f); + } +#endif + m_loc.Load(res); + InitForNewLocation(nLoc, ptTonyStart, start); + bLoaded = true; + break; + } + + if (!bLoaded) + SelectLocation(ptTonyStart, start); + + if (m_bOption) + m_opt.ReInit(m_bigBuf); + + m_bLocationLoaded = true; + + // On Enter per la locazion + return INVALID_HANDLE_VALUE; //mpalQueryDoAction(0, m_nCurLoc, 0); +} + +HANDLE RMGfxEngine::UnloadLocation(bool bDoOnExit) { + HANDLE h; + + // Scarica tutta la memoria della locazione + mpalEndIdlePoll(m_nCurLoc); + + // On Exit? + if (bDoOnExit) { + h = mpalQueryDoAction(1, m_nCurLoc, 0); + if (h != INVALID_HANDLE_VALUE) + WaitForSingleObject(h, INFINITE); + } + + MainFreeze(); + + m_bLocationLoaded = false; + + m_bigBuf.ClearOT(); + m_loc.Unload(); + + return INVALID_HANDLE_VALUE; +} + +void RMGfxEngine::Init() { + // Screen loading + RMResRaw *raw; + RMGfxSourceBuffer16 *load = NULL; + INIT_GFX16_FROMRAW(20038, load); + m_bigBuf.AddPrim(new RMGfxPrimitive(load)); + m_bigBuf.DrawOT(); + m_bigBuf.ClearOT(); + delete load; + _vm->m_wnd.GetNewFrame(*this, NULL); + + + + bPatIrqFreeze = true; + + // GUI attivabile + m_bGUIOption = true; + m_bGUIInterface = true; + m_bGUIInventory = true; + + bSkipSfxNoLoop = false; + m_bMustEnterMenu = false; + bIdleExited = false; + m_bOption = false; + m_bWiping = false; + m_hWipeEvent=CreateEvent(NULL, false, false, NULL); + + // Crea l'evento di freeze + g_system->lockMutex(csMainLoop); + + // Inizializza la funzione di IRQ di Item per l'MPAL + ItemIrq((uint32)-1, (uint32)this, 0); + mpalInstallItemIrq(ItemIrq); + + // Inizializza DirectInput + m_input.Init(/*hInst*/); + + // Inizializza il puntatore del mouse + m_point.Init(); + + // Inizializza Tony + m_tony.Init(); + m_tony.LinkToBoxes(&_vm->_theBoxes); + + // Inizializza l'inventario e l'interfaccia + m_inv.Init(); + m_inter.Init(); + + // Carica la locazione e setta le priorit @@@@@ + m_bLocationLoaded = false; +/* + m_nCurLoc=1; + RMRes res(m_nCurLoc); + m_loc.Load(res); + m_loc.SetPriority(1); + m_tony.SetPosition(RMPoint(201,316),1); + //m_tony.SetPosition(RMPoint(522,305),2); + //m_tony.SetPosition(RMPoint(158,398),4); + m_tony.SetPattern(m_tony.PAT_STANDDOWN); + m_curAction=TA_GOTO; +*/ + EnableInput(); + + // Inizio del gioco + //m_tony.ExecuteAction(4,1,0); //PREGAME + + m_tony.ExecuteAction(20,1,0); + +// theLog << "Seleziona la locazione\n"; + //LoadLocation(1,RMPoint(201,316),RMPoint(-1,-1)); + //SelectLocation(); + //LoadLocation(5,RMPoint(685,338),RMPoint(-1,-1)); + //LoadLocation(7,RMPoint(153,424),RMPoint(-1,-1)); + //LoadLocation(70,RMPoint(10,10),RMPoint(-1,-1)); + //LoadLocation(20,RMPoint(112,348),RMPoint(-1,-1)); + //LoadLocation(26,RMPoint(95,456),RMPoint(-1,-1)); + //LoadLocation(12,RMPoint(221,415),RMPoint(-1,-1)); + //LoadLocation(25,RMPoint(221,415),RMPoint(-1,-1)); + //LoadLocation(16,RMPoint(111,438),RMPoint(-1,-1)); + //LoadLocation(60,RMPoint(18,302),RMPoint(-1,-1)); + + // CASTELLO + + //LoadLocation(40,RMPoint(233,441),RMPoint(-1,-1)); +} + +void RMGfxEngine::Close(void) { + m_bigBuf.ClearOT(); + + m_inter.Close(); + m_inv.Close(); + m_tony.Close(); + m_point.Close(); + m_input.Close(); +} + +void RMGfxEngine::SwitchFullscreen(bool bFull) { + m_input.SwitchFullscreen(bFull); +} + +void RMGfxEngine::GDIControl(bool bCon) +{ + m_input.GDIControl(bCon); +} + +/* +void RMGfxEngine::OptionScreen(void) +{ + if (!m_bOption) + { + if (m_opt.Init(m_bigBuf)) + { + m_bOption = true; + DisableInput(); + EnableMouse(); + } + } + else + { + if (m_opt.Close()) + { + m_bOption = false; + DisableMouse(); + EnableInput(); + } + } +} +*/ + +void RMGfxEngine::EnableInput(void) { + m_bInput = true; +} + +void RMGfxEngine::DisableInput(void) { + m_bInput = false; + m_inter.Reset(); +} + +void RMGfxEngine::EnableMouse(void) { + m_bAlwaysDrawMouse = true; +} + +void RMGfxEngine::DisableMouse(void) { + m_bAlwaysDrawMouse = false; +} + +void RMGfxEngine::Freeze(void) { + g_system->lockMutex(csMainLoop); +} + +void RMGfxEngine::Unfreeze(void) { + g_system->unlockMutex(csMainLoop); +} + +void CharsSaveAll(Common::OutSaveFile *fp); +void CharsLoadAll(Common::InSaveFile *fp); +void MCharResetCodes(void); +void SaveChangedHotspot(Common::OutSaveFile *f); +void LoadChangedHotspot(Common::InSaveFile *f); +void ReapplyChangedHotspot(void); + +void RestoreMusic(void); +void SaveMusic(Common::OutSaveFile *f); +void LoadMusic(Common::InSaveFile *f); + +unsigned char wrkmem[LZO1X_999_MEM_COMPRESS]; + +void RMGfxEngine::SaveState(const char *fn, byte *curThumb, const char *name, bool bFastCompress) { + Common::OutSaveFile *f; + byte *state, *statecmp; + byte *thumbcmp; + uint32 thumbsizecmp, thumbsize; + uint32 size, sizecmp; + int i; + char buf[4]; + RMPoint tp = m_tony.Position(); + + // Salvataggio: variabili mpal + locazione corrente + posizione di tony + inventario + + // Per ora salviamo solo lo stato MPAL + size = mpalGetSaveStateSize(); + state = new byte[size]; + statecmp = new byte[size*2]; + mpalSaveState(state); + + thumbcmp = new byte[160*120*4]; + thumbsize = 160*120*2; + + if (bFastCompress) { + lzo1x_1_compress(state, size, statecmp, &sizecmp, wrkmem); + lzo1x_1_compress(curThumb, thumbsize, thumbcmp, &thumbsizecmp, wrkmem); + } else { + lzo1x_999_compress(state, size, statecmp, &sizecmp, wrkmem); + lzo1x_999_compress(curThumb, thumbsize, thumbcmp, &thumbsizecmp, wrkmem); + } + + buf[0] = 'R'; + buf[1] = 'M'; + buf[2] = 'S'; + buf[3] = 0x7; + + f = g_system->getSavefileManager()->openForSaving(fn); + if (f == NULL) + return; + + f->write(buf, 4); + f->writeUint32LE(thumbsizecmp); + f->write(thumbcmp, thumbsizecmp); + + // Livello di difficolt + i = mpalQueryGlobalVar("VERSIONEFACILE"); + f->writeByte(i); + + i = strlen(name); + f->writeByte(i); + f->write(name, i); + + f->writeUint32LE(m_nCurLoc); + f->writeUint32LE(tp.x); + f->writeUint32LE(tp.y); + f->writeUint32LE(size); + f->writeUint32LE(sizecmp); + + f->write(statecmp, sizecmp); + + delete [] state; + delete [] statecmp; + delete [] thumbcmp; + + // inventario + size = m_inv.GetSaveStateSize(); + state = new byte[size]; + m_inv.SaveState(state); + + f->writeUint32LE(size); + f->write(state, size); + delete[] state; + + // boxes + size = _vm->_theBoxes.GetSaveStateSize(); + state = new byte[size]; + _vm->_theBoxes.SaveState(state); + f->writeUint32LE(size); + f->write(state, size); + delete[] state; + + // New Ver5 + bool bStat; + + // Salva lo stato della pastorella e del palesati + bStat = m_tony.GetPastorella(); + f->writeByte(bStat); + bStat = m_inter.GetPalesati(); + f->writeByte(bStat); + + // Salva gli mchar + CharsSaveAll(f); + + // Salva le opzioni + f->writeByte(bCfgInvLocked); + f->writeByte(bCfgInvNoScroll); + f->writeByte(bCfgTimerizedText); + f->writeByte(bCfgInvUp); + f->writeByte(bCfgAnni30); + f->writeByte(bCfgAntiAlias); + f->writeByte(bCfgSottotitoli); + f->writeByte(bCfgTransparence); + f->writeByte(bCfgInterTips); + f->writeByte(bCfgDubbing); + f->writeByte(bCfgMusic); + f->writeByte(bCfgSFX); + f->writeByte(nCfgTonySpeed); + f->writeByte(nCfgTextSpeed); + f->writeByte(nCfgDubbingVolume); + f->writeByte(nCfgMusicVolume); + f->writeByte(nCfgSFXVolume); + + // Salva gli hotspot + SaveChangedHotspot(f); + + // Salva la musica + SaveMusic(f); + + f->finalize(); + delete f; +} + +void RMGfxEngine::LoadState(const char *fn) { + // PROBLEMA: Bisognerebbe caricare la locazione in un thread a parte per fare la OnEnter ... + Common::InSaveFile *f; + byte *state, *statecmp; + uint32 size, sizecmp; + char buf[4]; + RMPoint tp; + int loc; + int ver; + int i; + + f = g_system->getSavefileManager()->openForLoading(fn); + if (f == NULL) + return; + + f->read(buf, 4); + if (buf[0] != 'R' || buf[1] != 'M' || buf[2] != 'S') { + delete f; + return; + } + + ver = buf[3]; + + if (ver != 0x1 && ver != 0x2 && ver != 0x3 && ver != 0x4 && ver != 0x5 && ver != 0x6 && ver != 0x7) { + delete f; + return; + } + + if (ver >= 0x3) { + // C' il thumbnail. Se ver >= 5, compresso + if (ver >= 0x5) { + i = 0; + i = f->readUint32LE(); + f->seek(i, SEEK_CUR); + } else + f->seek(160 * 120 * 2, SEEK_CUR); + } + + if (ver >= 0x5) { + // Skip del livello di difficolt + f->seek(1, SEEK_CUR); + } + + if (ver >= 0x4) { // Skippa il nome, che non serve a nessuno + i = f->readByte(); + f->seek(i, SEEK_CUR); + } + + loc = f->readUint32LE(); + tp.x = f->readUint32LE(); + tp.y = f->readUint32LE(); + size = f->readUint32LE(); + + if (ver >= 0x5) { + // Stato MPAL compresso! + sizecmp = f->readUint32LE(); + state = new byte[size]; + statecmp = new byte[sizecmp]; + f->read(statecmp, sizecmp); + lzo1x_decompress(statecmp, sizecmp, state, &size); + + delete[] statecmp; + } else { + state = new byte[size]; + f->read(state, size); + } + + mpalLoadState(state); + delete[] state; + + + // inventario + size = f->readUint32LE(); + state = new byte[size]; + f->read(state, size); + + m_inv.LoadState(state); + delete[] state; + + if (ver >= 0x2) { // Versione 2: box please + size = f->readUint32LE(); + state = new byte[size]; + f->read(state, size); + _vm->_theBoxes.LoadState(state); + delete[] state; + } + + if (ver >= 5) { + // Versione 5: + bool bStat = false; + + bStat = f->readByte(); + m_tony.SetPastorella(bStat); + bStat = f->readByte(); + m_inter.SetPalesati(bStat); + + CharsLoadAll(f); + } + + if (ver >= 6) { + // Carica le opzioni + bCfgInvLocked = f->readByte(); + bCfgInvNoScroll = f->readByte(); + bCfgTimerizedText = f->readByte(); + bCfgInvUp = f->readByte(); + bCfgAnni30 = f->readByte(); + bCfgAntiAlias = f->readByte(); + bCfgSottotitoli = f->readByte(); + bCfgTransparence = f->readByte(); + bCfgInterTips = f->readByte(); + bCfgDubbing = f->readByte(); + bCfgMusic = f->readByte(); + bCfgSFX = f->readByte(); + nCfgTonySpeed = f->readByte(); + nCfgTextSpeed = f->readByte(); + nCfgDubbingVolume = f->readByte(); + nCfgMusicVolume = f->readByte(); + nCfgSFXVolume = f->readByte(); + + // Carica gli hotspot + LoadChangedHotspot(f); + } + + if (ver >= 7) { + LoadMusic(f); + } + + delete f; + + UnloadLocation(false); + LoadLocation(loc, tp, RMPoint(-1, -1)); + m_tony.SetPattern(RMTony::PAT_STANDRIGHT); + MainUnfreeze(); + + // Le versioni vecchie necessitano di On enter + if (ver < 5) + mpalQueryDoAction(0, loc, 0); + else { + // In quelle nuove, ci basta resettare gli mcode + MCharResetCodes(); + } + + if (ver >= 6) + ReapplyChangedHotspot(); + + RestoreMusic(); + + m_bGUIInterface = true; + m_bGUIInventory = true; + m_bGUIOption = true; +} + +void RMGfxEngine::PauseSound(bool bPause) { + if (m_bLocationLoaded) + m_loc.PauseSound(bPause); +} + +void RMGfxEngine::InitWipe(int type) { + m_bWiping = true; + m_nWipeType=type; + m_nWipeStep=0; + + if (m_nWipeType==1) + m_rcWipeEllipse = Common::Rect(80, 0, 640 - 80, 480); + else if (m_nWipeType == 2) + m_rcWipeEllipse = Common::Rect(320 - FSTEP, 240 - FSTEP, 320 + FSTEP, 240 + FSTEP); +} + +void RMGfxEngine::CloseWipe(void) { + m_bWiping = false; +} + +void RMGfxEngine::WaitWipeEnd(void) { + WaitForSingleObject(m_hWipeEvent, INFINITE); +} } // End of namespace Tony diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index 313e471cdf..f5553d21c6 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -237,7 +237,7 @@ class RMGfxSourceBuffer : public virtual RMGfxBuffer, public RMGfxTaskSetPrior { public: // Carica i dati della surface a basso livello virtual int Init(uint32 resID, int dimx, int dimy, bool bLoadPalette = false); - virtual int Init(byte *buf, int dimx, int dimy, bool bLoadPalette = false); + virtual int Init(const byte *buf, int dimx, int dimy, bool bLoadPalette = false); virtual void Init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette = false); virtual ~RMGfxSourceBuffer(); diff --git a/engines/tony/gfxengine.h b/engines/tony/gfxengine.h index 317056315e..2019cf01c9 100644 --- a/engines/tony/gfxengine.h +++ b/engines/tony/gfxengine.h @@ -145,8 +145,8 @@ public: void Unfreeze(void); // State management - void SaveState(char *fn, byte *curThumb, char *name, bool bFastCompress = false); - void LoadState(char *fn); + void SaveState(const char *fn, byte *curThumb, const char *name, bool bFastCompress = false); + void LoadState(const char *fn); // Selects a location void SelectLocation(RMPoint ptTonyStart=RMPoint(-1,-1), RMPoint start=RMPoint(-1,-1)); diff --git a/engines/tony/input.h b/engines/tony/input.h index 6ea56024a9..554b10628b 100644 --- a/engines/tony/input.h +++ b/engines/tony/input.h @@ -75,7 +75,7 @@ public: ~RMInput(); // Class initialisation - void Init(uint32 hInst); + void Init(/*uint32 hInst*/); // Closes the class void Close(void); diff --git a/engines/tony/loc.h b/engines/tony/loc.h index 1cae9edb1e..73effc85c1 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -541,7 +541,7 @@ public: // Caricamento da disco bool Load(char *lpszFileName); bool Load(HANDLE hFile); - bool Load(byte *buf); + bool Load(const byte *buf); bool Load(RMDataStream &ds); bool LoadLOX(RMDataStream &ds); @@ -561,10 +561,10 @@ public: RMItem* GetItemFromCode(uint32 dwCode); // Setta la posizione corrente di scrolling - void SetScrollPosition(RMPoint &scroll); + void SetScrollPosition(const RMPoint &scroll); // Setta un offset aggiuntivo di scrolling da aggiungere sempre - void SetFixedScroll(RMPoint &scroll); + void SetFixedScroll(const RMPoint &scroll); // Aggiorna le coordinate di scrolling in modo da visualizzare sempre il punto fornito void UpdateScrolling(RMPoint ptShowThis); diff --git a/engines/tony/module.mk b/engines/tony/module.mk index cbc07d27b7..7c2c7928a8 100644 --- a/engines/tony/module.mk +++ b/engines/tony/module.mk @@ -1,6 +1,7 @@ MODULE := engines/tony MODULE_OBJS := \ + custom.o \ detection.o \ game.o \ gfxcore.o \ diff --git a/engines/tony/mpal/lzo.cpp b/engines/tony/mpal/lzo.cpp index 6cd755fc93..17b059455c 100644 --- a/engines/tony/mpal/lzo.cpp +++ b/engines/tony/mpal/lzo.cpp @@ -63,6 +63,7 @@ */ #include "lzo.h" +#include "common/textconsole.h" namespace Tony { @@ -505,6 +506,19 @@ lookbehind_overrun: #endif } +int lzo1x_1_compress(const byte *src, uint32 src_len, byte *dst, uint32 *dst_len, void *wrkmem) { + warning("TODO: lzo1x_1_compress"); + return 0; +} + +/** + * better compression ratio at the cost of more memory and time + */ +int lzo1x_999_compress(const byte *src, uint32 src_len, byte *dst, uint32 *dst_len, void *wrkmem) { + warning("TODO: lzo1x_999_compress"); + return 0; +} + } // end of namespace MPAL } // end of namespace Tony diff --git a/engines/tony/mpal/lzo.h b/engines/tony/mpal/lzo.h index 1d20c8e96e..ebb1c4b516 100644 --- a/engines/tony/mpal/lzo.h +++ b/engines/tony/mpal/lzo.h @@ -87,12 +87,23 @@ namespace MPAL { #define LZO_E_NOT_YET_IMPLEMENTED (-9) /* [not used right now] */ #define LZO_E_INVALID_ARGUMENT (-10) +#define LZO1X_999_MEM_COMPRESS ((uint32) (14 * 16384L * sizeof(uint16))) /** * Decompresses an LZO compressed resource */ int lzo1x_decompress(const byte *src, uint32 src_len, byte *dst, uint32 *dst_len); +/** + * Comrpess a data block into an LZO stream + */ +int lzo1x_1_compress(const byte *src, uint32 src_len, byte *dst, uint32 *dst_len, void *wrkmem); + +/** + * better compression ratio at the cost of more memory and time + */ +int lzo1x_999_compress(const byte *src, uint32 src_len, byte *dst, uint32 *dst_len, void *wrkmem); + } // end of namespace MPAL } // end of namespace Tony diff --git a/engines/tony/mpal/stubs.cpp b/engines/tony/mpal/stubs.cpp index 054ed55c68..ea93265ec9 100644 --- a/engines/tony/mpal/stubs.cpp +++ b/engines/tony/mpal/stubs.cpp @@ -59,9 +59,15 @@ HANDLE CreateThread(void *lpThreadAttributes, size_t dwStackSize, return 0; } +void _beginthread(LPTHREAD_ROUTINE lpStartAddress, size_t dwStackSize, void *lpParameter) { +} + void ExitThread(int ThreadId) { } +void _endthread() { +} + void TerminateThread(HANDLE ThreadId, uint32 dwExitCode) { } @@ -91,6 +97,10 @@ void SetEvent(HANDLE hEvent) { void ResetEvent(HANDLE hEvent) { } +uint16 GetAsyncKeyState(Common::KeyCode kc) { + return 0; +} + } // end of namespace MPAL } // end of namespace Tony diff --git a/engines/tony/mpal/stubs.h b/engines/tony/mpal/stubs.h index a8d3253ddb..9a22b65b7a 100644 --- a/engines/tony/mpal/stubs.h +++ b/engines/tony/mpal/stubs.h @@ -31,6 +31,7 @@ #include "common/scummsys.h" #include "common/algorithm.h" +#include "common/keyboard.h" #include "tony/mpal/memory.h" namespace Tony { @@ -42,6 +43,7 @@ namespace MPAL { \****************************************************************************/ typedef uint32 (*LPTHREAD_START_ROUTINE)(void *lpThreadParameter); +typedef void (*LPTHREAD_ROUTINE)(void *lpThreadParameter); /****************************************************************************\ * Defines @@ -82,8 +84,12 @@ extern HANDLE CreateThread(void *lpThreadAttributes, size_t dwStackSize, LPTHREAD_START_ROUTINE lpStartAddress, void *lpParameter, uint32 dwCreationFlags, uint32 *lpThreadId); +extern void _beginthread(LPTHREAD_ROUTINE lpStartAddress, size_t dwStackSize, void *lpParameter); + extern void ExitThread(int ThreadId); +extern void _endthread(); + extern void TerminateThread(HANDLE ThreadId, uint32 dwExitCode); extern void CloseHandle(HANDLE ThreadId); @@ -100,6 +106,8 @@ extern void SetEvent(HANDLE hEvent); extern void ResetEvent(HANDLE hEvent); +extern uint16 GetAsyncKeyState(Common::KeyCode kc); + } // end of namespace MPAL } // end of namespace Tony diff --git a/engines/tony/sound.h b/engines/tony/sound.h index 75a70553ef..c966c93888 100644 --- a/engines/tony/sound.h +++ b/engines/tony/sound.h @@ -54,7 +54,9 @@ namespace Tony { +class FPSTREAM; class FPSFX; +class CODEC; enum CODECS { FPCODEC_RAW, @@ -62,6 +64,144 @@ enum CODECS { FPCODEC_WAV }; + +/****************************************************************************\ +***************************************************************************** +* class FPSound +* ------------- +* Description: Sound driver per Falling Pumpkins +***************************************************************************** +\****************************************************************************/ + +class FPSOUND { + +private: + + bool bSoundSupported; +/* + LPDIRECTSOUND lpDS; + LPDIRECTSOUNDBUFFER lpDSBPrimary; + DSCAPS dscaps; + HWND hwnd; +*/ + +/****************************************************************************\ +* Metodi +\****************************************************************************/ + +public: + +/****************************************************************************\ +* +* Function: FPSOUND::FPSOUND(); +* +* Description: Costruttore di default. Inizializza gli attributi. +* +\****************************************************************************/ + + FPSOUND(); + + +/****************************************************************************\ +* +* Function: FPSOUND::~FPSOUND(); +* +* Description: Deinizializza l'oggetto, disallocando la memoria. +* +\****************************************************************************/ + + ~FPSOUND(); + + +/****************************************************************************\ +* +* Function: bool FPSOUND::Init(HWND hWnd); +* +* Description: Inizializza l'oggetto, e prepara tutto il necessario per +* creare stream e effetti sonori. +* +* Input: HWND hWnd Handle della finestra principale +* +* Return: True se tutto OK, FALSE in caso di errore. +* +\****************************************************************************/ + + + bool Init(/*HWND hWnd*/); + + +/****************************************************************************\ +* +* Function: bool CreateStream(FPSTREAM** lplpStream); +* +* Description: Alloca un oggetti di tipo FPSTREAM, e ritorna il suo +* puntatore dopo averlo inizializzato. +* +* Input: FPSTREAM** lplpStream Conterra' il pointer all'oggetto +* appena creato. +* +* Return: TRUE se tutto OK, FALSE in caso di errore +* +* Note: L'utilizzo di funzioni del tipo CreateStream(), CreateSfx(), +* sono dovute al fatto che i costruttori delle classi FPSTREAM +* e FPSFX richiedono che DirectSound sia gia' stato +* inzializzato. In questo modo quindi si evitano dei bugs +* che si verrebbero a creare se venisse dichiarata un oggetto +* di tipo FPSTREAM o FPSFX globale (o cmq prima della +* inizializzazione di DirectSound). +* +\****************************************************************************/ + + bool CreateStream(FPSTREAM **lplpStream); + + + +/****************************************************************************\ +* +* Function: bool CreateSfx(FPSFX** lplpSfx); +* +* Description: Alloca un oggetti di tipo FPSFX e ritorna il suo +* puntatore dopo averlo inizializzato. +* +* Input: FPSFX** lplpSfx Conterra' il pointer all'oggetto +* appena creato. +* +* Return: TRUE se tutto OK, FALSE in caso di errore +* +* Note: Vedi le note di CreateStream() +* +\****************************************************************************/ + + bool CreateSfx(FPSFX **lplpSfx); + + + +/****************************************************************************\ +* +* Function: void SetMasterVolume(int dwVolume); +* +* Description: Setta il volume generale +* +* Input: int dwVolume Volume da settare (0-63) +* +\****************************************************************************/ + + void SetMasterVolume(int dwVolume); + + +/****************************************************************************\ +* +* Function: void GetMasterVolume(LPINT lpdwVolume); +* +* Description: Richiede il volume generale +* +* Input: LPINT lpdwVolume Variabile che conterra' il volume (0-63) +* +\****************************************************************************/ + + void GetMasterVolume(int *lpdwVolume); +}; + class FPSFX { /****************************************************************************\ @@ -93,7 +233,7 @@ private: // DSBPOSITIONNOTIFY dspnHot[2]; public: -// HANDLE hEndOfBuffer; + HANDLE hEndOfBuffer; private: @@ -159,9 +299,9 @@ public: * \****************************************************************************/ - bool LoadFile(char *lpszFileName, uint32 dwCodec = FPCODEC_RAW); - bool LoadFile(byte *lpBuf, uint32 dwCodec); - bool LoadVoiceFromVDB(HANDLE hvdb); + bool LoadFile(char *lpszFileName, uint32 dwCodec = FPCODEC_RAW); + bool LoadFile(byte *lpBuf, uint32 dwCodec); + bool LoadVoiceFromVDB(Common::File &hvdb); /****************************************************************************\ @@ -249,6 +389,223 @@ public: void GetVolume(int * lpdwVolume); }; +class FPSTREAM { + +/****************************************************************************\ +* Attributi +\****************************************************************************/ + +private: + +/* + HWND hwnd; + LPDIRECTSOUND lpDS; + LPDIRECTSOUNDBUFFER lpDSBuffer; // Buffer DirectSound circolare + LPDIRECTSOUNDNOTIFY lpDSNotify; // Notify degli hotspot nel buffer +*/ + byte *lpTempBuffer; // Buffer temporaneo per decompressione + + uint32 dwBufferSize; // Dimensione del buffer in bytes + uint32 dwSize; // Dimensione dello stream in bytes + uint32 dwCodec; // CODEC utilizzato + + HANDLE hThreadEnd; // Evento per chiudere il thread + HANDLE hFile; // Handle del file di stream + HANDLE hPlayThread; // Handle del thread di play + HANDLE hHot1, hHot2, hHot3; // Eventi settati da DirectSoundNotify + HANDLE hPlayThread_PlayFast; + HANDLE hPlayThread_PlayNormal; + + bool bSoundSupported; // TRUE se il suono e' attivo + bool bFileLoaded; // TRUE se e' stato aperto un file + bool bLoop; // TRUE se bisogna loopare lo stream + bool bDoFadeOut; // TRUE se bisogna fare un fade out + bool bSyncExit; + bool bPaused; + int lastVolume; + FPSTREAM *SyncToPlay; +// DSBPOSITIONNOTIFY dspnHot[3]; + + CODEC *lpCodec; // CODEC da utilizzare. + bool CreateBuffer(int nBufSize); + +public: + bool bIsPlaying; // TRUE se si sta playando lo stream + +private: + + static void PlayThread(FPSTREAM *This); + +/****************************************************************************\ +* Metodi +\****************************************************************************/ + +public: + +/****************************************************************************\ +* +* Function: FPSTREAM(LPDIRECTSOUND lpDS, bool bSoundOn); +* +* Description: Costruttore di default. *NON* bisogna dichiarare direttamente +* un oggetto, ma crearlo piuttosto tramite FPSOUND::CreateStream() +* +\****************************************************************************/ + + FPSTREAM(void * /*LPDIRECTSOUND*/ lpDS, uint32 /*HWND hWnd */, bool bSoundOn); + + +/****************************************************************************\ +* +* Function: ~FPSTREAM(); +* +* Description: Distruttore di default. Si preoccupa anche di fermare stream +* eventualmente in esecuzione, e disallocare la memoria da +* essi occupata. +* +\****************************************************************************/ + + ~FPSTREAM(); + + +/****************************************************************************\ +* +* Function: Release(); +* +* Description: Rilascia la memoria dell'oggetto. Deve essere richiamata quando +* l'oggetto non serve piu' e **SOLO SE** l'oggetto e' stato +* creato con la FPSOUND::CreateStream(). +* +* Note: Eventuali puntatori all'oggetto non sono piu' validi dopo +* questa chiamata. +* +\****************************************************************************/ + + void Release(); + + +/****************************************************************************\ +* +* Function: bool LoadFile(char *lpszFileName, uint32 dwCodec=FPCODEC_RAW); +* +* Description: Apre un file di stream. +* +* Input: char *lpszFile Nome del file di stream da aprire +* uint32 dwCodec CODEC da utilizzare per decomprimere +* i campioni sonori +* +* Return: TRUE se tutto OK, FALSE in caso di errore +* +\****************************************************************************/ + + bool LoadFile(char *lpszFileName, uint32 dwCodec = FPCODEC_RAW, int nSync = 2000); + + + +/****************************************************************************\ +* +* Function: UnloadFile(); +* +* Description: Chiude un file di stream eventualmente aperto. E' necessario +* richiamare questa funzione per disallocare la memoria +* occupata dallo stream. +* +* Return: Il distruttore della classe per sicurezza richiama la +* UnloadFile() se non e' stata richiamata esplicitamente. +* +\****************************************************************************/ + + bool UnloadFile(); + + +/****************************************************************************\ +* +* Function: bool Play(); +* +* Description: Suona lo stream caricato. +* +* Return: TRUE se tutto OK, FALSE in caso di errore. +* +\****************************************************************************/ + + bool Play(); + void PlayFast(void); + void Prefetch(void); + + +/****************************************************************************\ +* +* Function: bool Stop(); +* +* Description: Ferma il play dello stream. +* +* Return: TRUE se tutto OK, FALSE in caso di errore. +* +\****************************************************************************/ + + bool Stop(bool bSync = false); + void WaitForSync(FPSTREAM* toplay); + + +/****************************************************************************\ +* +* Function: void Pause(bool bPause); +* +* Description: Pause dell'effetto sonoro +* +\****************************************************************************/ + + void Pause(bool bPause); + + +/****************************************************************************\ +* +* Function: bool SetLoop(bool bLoop); +* +* Description: Attiva o disattiva il loop dello stream. +* +* Input: bool bLoop TRUE per attivare il loop, FALSE per +* disattivarlo +* +* Note: Il loop deve essere attivato PRIMA di eseguire il play +* dello stream. Qualsiasi modifica effettuata durante il play +* non avra' effetto fino a che lo stream non viene fermato, +* e poi rimesso in play. +* +\****************************************************************************/ + + void SetLoop(bool bLoop); + + + +/****************************************************************************\ +* +* Function: void SetVolume(int dwVolume); +* +* Description: Cambia il volume dello stream +* +* Input: int dwVolume Volume da settare (0-63) +* +\****************************************************************************/ + + void SetVolume(int dwVolume); + + + +/****************************************************************************\ +* +* Function: void GetVolume(LPINT lpdwVolume); +* +* Description: Chiede il volume dello stream +* +* Input: LPINT lpdwVolume Variabile in cui verra' inserito +* il volume corrente +* +\****************************************************************************/ + + void GetVolume(int *lpdwVolume); +}; + + } // End of namespace Tony #endif diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index a370c8efaf..e27cb6d9d3 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -49,10 +49,9 @@ Common::Error TonyEngine::run() { if (result != Common::kNoError) return result; - /* Play(); Close(); -*/ + return Common::kNoError; } @@ -60,6 +59,12 @@ Common::Error TonyEngine::run() { * Initialise the game */ Common::ErrorCode TonyEngine::Init() { + m_hEndOfFrame = CreateEvent(NULL, false, false, NULL); + + m_bPaused = false; + m_bDrawLocation = true; + m_startTime = g_system->getMillis(); + // Initialise the function list Common::fill(FuncList, FuncList + 300, (LPCUSTOMFUNCTION)NULL); @@ -98,6 +103,60 @@ void TonyEngine::GUIError(const Common::String &msg) { GUIErrorMessage(msg); } +char nextMusic[_MAX_PATH]; +bool nextLoop; +int nextChannel; +int nextSync; +int curChannel; +int flipflop=0; +OSystem::MutexRef csMusic; + + +void TonyEngine::PlayMusic(int nChannel, char* fn, int nFX, bool bLoop, int nSync) { + warning("TonyEngine::PlayMusic"); +} + +void TonyEngine::PlaySFX(int nChannel, int nFX) { + warning("TonyEngine::PlaySFX"); +} + +void TonyEngine::StopMusic(int nChannel) { + warning("TonyEngine::StopMusic"); +} + +void TonyEngine::StopSFX(int nChannel) { + warning("TonyEngine::StopSFX"); +} + +void TonyEngine::PlayUtilSFX(int nChannel, int nFX) { + warning("TonyEngine::PlayUtilSFX"); +} + +void TonyEngine::StopUtilSFX(int nChannel) { + warning("TonyEngine::StopUtilSFX"); +} + +void TonyEngine::PreloadSFX(int nChannel, char* fn) { + warning("TonyEngine::PreloadSFX"); +} + +FPSFX *TonyEngine::CreateSFX(byte *buf) { + warning("TonyEngine::CreateSFX"); + return NULL; +} + +void TonyEngine::PreloadUtilSFX(int nChannel, char *fn) { + warning("TonyEngine::PreloadUtilSFX"); +} + +void TonyEngine::UnloadAllSFX(void) { + warning("TonyEngine::UnloadAllSFX"); +} + +void TonyEngine::UnloadAllUtilSFX(void) { + warning("TonyEngine::UnloadAllUtilSFX"); +} + void TonyEngine::InitMusic() { warning("TODO: TonyEngine::InitMusic"); } @@ -160,4 +219,9 @@ void TonyEngine::CloseVoiceDatabase() { _voices.clear(); } +void TonyEngine::GrabThumbnail(void) { + //m_wnd.GrabThumbnail(m_curThumbnail); + warning("TODO: TonyEngine::GrabThumbnail"); +} + } // End of namespace Tony diff --git a/engines/tony/tony.h b/engines/tony/tony.h index a372260c34..f3b840faf5 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -36,6 +36,7 @@ #include "tony/gfxEngine.h" #include "tony/loc.h" #include "tony/utils.h" +#include "tony/window.h" /** * This is the namespace of the Tony engine. @@ -72,11 +73,9 @@ struct VoiceHeader { class TonyEngine : public Engine { private: Common::ErrorCode Init(); + void InitMusic(); void CloseMusic(); - void PauseSound(bool bPause); - void SetMusicVolume(int nChannel, int volume); - int GetMusicVolume(int nChannel); bool OpenVoiceDatabase(); void CloseVoiceDatabase(); protected: @@ -88,24 +87,105 @@ public: Common::RandomSource _randomSource; MPAL::MemoryManager _memoryManager; RMResUpdate _resUpdate; + HANDLE m_hEndOfFrame; Common::File _vdbFP; Common::Array _voices; + FPSOUND _theSound; // Bounding box list manager RMGameBoxes _theBoxes; RMGfxEngine _theEngine; + RMWindow m_wnd; + bool m_bPaused; + bool m_bDrawLocation; + int m_startTime; + uint16 *m_curThumbnail; + + bool m_bQuitNow; + bool m_bTimeFreezed; + int m_nTimeFreezed; + + enum DATADIR { + DD_BASE = 1, + DD_SAVE, + DD_SHOTS, + DD_MUSIC, + DD_LAYER, + DD_UTILSFX, + DD_VOICES, + DD_BASE2 + }; public: TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc); virtual ~TonyEngine(); const TonyGameDescription *_gameDescription; - uint32 getGameID() const; uint32 getFeatures() const; Common::Language getLanguage() const; uint16 getVersion() const; - uint32 getFlags() const; - Common::Platform getPlatform() const; - + bool getIsDemo() const; + RMGfxEngine *GetEngine() { return &_theEngine; } void GUIError(const Common::String &msg); + + void Play(); + void Close(); + void Abort(); + + void GetDataDirectory(DATADIR dir, char *path); + + void SwitchFullscreen(bool bFull); + void OptionScreen(void); + + void ShowLocation(void) { m_bDrawLocation = true; } + void HideLocation(void) { m_bDrawLocation = false; } + + // Mette o leva la pausa + void Pause(bool bPause); + bool IsPaused() { return m_bPaused; } + + // Reads the time + uint32 GetTime(void); + void FreezeTime(void); + void UnfreezeTime(void); + + // Music + // ****** + void PlayMusic(int nChannel, char *fn, int nFX, bool bLoop, int nSync); + void StopMusic(int nChannel); + + void PlaySFX(int nSfx, int nFX = 0); + void StopSFX(int nSfx); + + void PlayUtilSFX(int nSfx, int nFX = 0); + void StopUtilSFX(int nSfx); + + FPSFX *CreateSFX(byte *buf); + + void PreloadSFX(int nSfx, char *fn); + void UnloadAllSFX(void); + + void PreloadUtilSFX(int nSfx, char *fn); + void UnloadAllUtilSFX(void); + + // Ferma tutta la parte audio + void PauseSound(bool bPause); + + void SetMusicVolume(int nChannel, int volume); + int GetMusicVolume(int nChannel); + + // Salvataggio + void AutoSave(void); + void SaveState(int n, char *name); + void LoadState(int n); + void GetSaveStateFileName(int n, char* buf); + + // Prende il thumbnail + void GrabThumbnail(void); + uint16 *GetThumbnail(void) { return m_curThumbnail; } + + void Quit(void) { m_bQuitNow = true; } + + void OpenInitLoadMenu(void); + void OpenInitOptions(void); }; // Global reference to the TonyEngine object diff --git a/engines/tony/tonychar.h b/engines/tony/tonychar.h index 9d3c0202d0..9806fd5e58 100644 --- a/engines/tony/tonychar.h +++ b/engines/tony/tonychar.h @@ -49,6 +49,7 @@ #define TONY_TONYCHAR_H #include "tony/mpal/stubs.h" +#include "tony/loc.h" namespace Tony { diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index 48dcb9392a..360b7a6f32 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -980,7 +980,7 @@ HGLOBAL RMResUpdate::QueryResource(uint32 dwRes) { uint32 dwSize; // Decompress the data - MPAL::lzo1x_decompress(cmpBuf, info.cmpSize, lpDestBuf, &dwSize); + lzo1x_decompress(cmpBuf, info.cmpSize, lpDestBuf, &dwSize); // Delete buffer for compressed data delete [] cmpBuf; diff --git a/engines/tony/window.h b/engines/tony/window.h new file mode 100644 index 0000000000..d248ffb871 --- /dev/null +++ b/engines/tony/window.h @@ -0,0 +1,134 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ +/************************************************************************** + * 様様様様様様様様様様様様様様様様様 * + * Nayma Software srl * + * e -= We create much MORE than ALL =- * + * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * + * .d" d$$$$$b "b. * + * .z$* d$$$$$$$L ^*$c. * + * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * + * ^*$b 4$$$$$$$$$F .d$*" * + * ^$$. 4$$$$$$$$$F .$P" Module: Window.HPP........... * + * *$. '$$$$$$$$$ 4$P 4 * + * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * + * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * + * z$" "" #$F^ "" '$c Desc: Classi per la gestione * + * z$$beu .ue=" $ "=e.. .zed$$c di una finestra Direct + * "#$e z$*" . `. ^*Nc e$"" Draw................. * + * "$$". .r" ^4. .^$$" ..................... * + * ^.@*"6L=\ebu^+C$"*b." * + * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * + * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * + * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * + * * + * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * + * * + **************************************************************************/ + +#ifndef TONY_WINDOW_H +#define TONY_WINDOW_H + +#include "common/scummsys.h" +#include "common/rect.h" + +namespace Tony { + +typedef uint32 HWND; + +class RMWindow { +private: + bool Lock(/*DDSURFACEDESC& ddsd */); + void Unlock(/*DDSURFACEDESC& ddsd */); + + // Inizializza DirectDraw + void DDInit(void); + + // Chiude DirectDraw + void DDClose(void); + + // Repaint grafico tramite DirectDraw + void Repaint(void); + + // Window Proc principale che richiama la WindowProc dentro la classe +// friend LRESULT CALLBACK GlobalWindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); + + // Procedura di gestione messaggi +// LRESULT WindowProc(UINT msg, WPARAM wParam, LPARAM lParam); + +protected: + HWND m_hWnd; + bool m_bFullscreen; + + void * /*LPDIRECTDRAW*/ m_DD; + void * /*LPDIRECTDRAWSURFACE*/ m_Primary; + void * /*LPDIRECTDRAWSURFACE*/ m_Back; + void * /*LPDIRECTDRAWCLIPPER*/ m_MainClipper; + void * /*LPDIRECTDRAWCLIPPER*/ m_BackClipper; + + int fps, fcount; + int lastsecond, lastfcount; + + int mskRed, mskGreen, mskBlue; + + bool m_bGrabScreenshot; + bool m_bGrabThumbnail; + bool m_bGrabMovie; + uint16 *m_wThumbBuf; + + void CreateBWPrecalcTable(void); + void UpdatePixelFormat(void); + void WipeEffect(Common::Rect &rcBoundEllipse); + + public: + RMWindow() { m_Primary = NULL; m_Back = NULL; }; + ~RMWindow() { Close(); } + + // Inizializzazione + void Init(/*HINSTANCE hInst*/); + void InitDirectDraw(void); + void Close(void); + + // Switch tra windowed e fullscreen + void SwitchFullscreen(bool bFull); + + // Legge il prossimo frame + void GetNewFrame(byte *lpBuf, Common::Rect *rcBoundEllipse); + + // Avverte di grabbare un thumbnail per il salvataggio +// void GrabThumbnail(uint16 *buf); + + operator HWND() { return m_hWnd; } + + // Modi pixel format + // MODE1: 1555 + // MODE2: 5515 + // MODE3: 5551 + bool ISMODE1() { return (mskRed == 0x7C00 && mskGreen == 0x3E0 && mskBlue== 0x1F); } + bool ISMODE2() { return (mskRed == 0xF800 && mskGreen == 0x7E0 && mskBlue== 0x1F); } + bool ISMODE3() { return (mskRed == 0xF800 && mskGreen == 0x7C0 && mskBlue== 0x3E); } + bool ISMODE4() { return (mskBlue == 0xF800 && mskGreen == 0x7E0 && mskRed== 0x1F); } +}; + +} // End of namespace Tony + +#endif /* TONY_WINDOW_H */ -- cgit v1.2.3 From 7d9156b12faf36197e8c3e97532675dcb9094f19 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 1 May 2012 23:00:03 +1000 Subject: TONY: Implemented GfxEngine code --- engines/tony/game.cpp | 32 +- engines/tony/game.h | 37 ++ engines/tony/gfxengine.cpp | 949 +++++++++++++++++++++++++++++++++++++++++++++ engines/tony/tony.cpp | 29 +- 4 files changed, 1020 insertions(+), 27 deletions(-) (limited to 'engines') diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index d759ef510a..acafbbf7c8 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -236,26 +236,6 @@ void RMOptionButton::AddToList(RMGfxTargetBuffer &bigBuf) { } -/****************************************************************************\ -* RMOptionSlide methods -\****************************************************************************/ - -#define INIT_GFX16_FROMRAW(dwRes, buf16) \ - raw = new RMResRaw(dwRes); \ - assert(raw->IsValid()); \ - assert((buf16) == NULL); \ - (buf16) = new RMGfxSourceBuffer16(false); \ - (buf16)->Init(*raw,raw->Width(),raw->Height()); \ - delete raw; - -#define INIT_GFX8_FROMRAW(dwRes, buf8) \ - raw = new RMResRaw(dwRes); \ - assert(raw->IsValid()); \ - assert((buf8) == NULL); \ - (buf8) = new RMGfxSourceBuffer8RLEByte(); \ - (buf8)->Init(*raw, raw->Width(), raw->Height(), true); \ - delete raw; - /****************************************************************************\ * Metodi di RMGfxEngine \****************************************************************************/ @@ -284,23 +264,23 @@ RMGfxEngine::~RMGfxEngine() { } void RMGfxEngine::OpenOptionScreen(int type) { - bool bRes; + bool bRes = false; switch (type) { case 0: - bRes=m_opt.Init(m_bigBuf); + bRes = m_opt.Init(m_bigBuf); break; case 1: - bRes=m_opt.InitLoadMenuOnly(m_bigBuf, true); + bRes = m_opt.InitLoadMenuOnly(m_bigBuf, true); break; case 2: - bRes=m_opt.InitNoLoadSave(m_bigBuf); + bRes = m_opt.InitNoLoadSave(m_bigBuf); break; case 3: - bRes=m_opt.InitLoadMenuOnly(m_bigBuf, false); + bRes = m_opt.InitLoadMenuOnly(m_bigBuf, false); break; case 4: - bRes=m_opt.InitSaveMenuOnly(m_bigBuf, false); + bRes = m_opt.InitSaveMenuOnly(m_bigBuf, false); break; } diff --git a/engines/tony/game.h b/engines/tony/game.h index 28f9489267..593203e443 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -56,6 +56,43 @@ namespace Tony { +#define INIT_GFX16_FROMRAW(dwRes, buf16) \ + raw = new RMResRaw(dwRes); \ + assert(raw->IsValid()); \ + assert((buf16) == NULL); \ + (buf16) = new RMGfxSourceBuffer16(false); \ + (buf16)->Init(*raw,raw->Width(),raw->Height()); \ + delete raw; + +#define INIT_GFX8_FROMRAW(dwRes, buf8) \ + raw = new RMResRaw(dwRes); \ + assert(raw->IsValid()); \ + assert((buf8) == NULL); \ + (buf8) = new RMGfxSourceBuffer8RLEByte(); \ + (buf8)->Init(*raw, raw->Width(), raw->Height(), true); \ + delete raw; + +extern bool bCfgInvLocked; +extern bool bCfgInvNoScroll; +extern bool bCfgTimerizedText; +extern bool bCfgInvUp; +extern bool bCfgAnni30; +extern bool bCfgAntiAlias; +extern bool bCfgSottotitoli; +extern bool bCfgTransparence; +extern bool bCfgInterTips; +extern bool bCfgDubbing; +extern bool bCfgMusic; +extern bool bCfgSFX; +extern int nCfgTonySpeed; +extern int nCfgTextSpeed; +extern int nCfgDubbingVolume; +extern int nCfgMusicVolume; +extern int nCfgSFXVolume; +extern bool bSkipSfxNoLoop; + +extern bool bPatIrqFreeze; + class RMPointer : public RMGfxTask { private: RMGfxSourceBuffer8 *m_pointer[16]; diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 02ee7c8e8e..b8accda7c6 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -45,9 +45,958 @@ * * **************************************************************************/ +#include "common/savefile.h" +#include "tony/mpal/lzo.h" +#include "tony/mpal/mpalutils.h" +#include "tony/custom.h" #include "tony/gfxEngine.h" +#include "tony/tony.h" namespace Tony { +extern bool bIdleExited; +extern bool bPatIrqFreeze; +extern bool bSkipSfxNoLoop; + +extern void ExitAllIdles(int nCurLoc); + +/****************************************************************************\ +* Metodi di RMGfxEngine +\****************************************************************************/ + +RMGfxEngine::RMGfxEngine() { + // Crea il big buffer dove verranno disegnati i frame + m_bigBuf.Create(RM_BBX,RM_BBY,16); + m_bigBuf.OffsetY(RM_SKIPY); +} + +RMGfxEngine::~RMGfxEngine() { + // Chiude il buffer + m_bigBuf.Destroy(); +} + +void RMGfxEngine::OpenOptionScreen(int type) { + bool bRes = false; + + switch (type) { + case 0: + bRes = m_opt.Init(m_bigBuf); + break; + case 1: + bRes = m_opt.InitLoadMenuOnly(m_bigBuf,true); + break; + case 2: + bRes = m_opt.InitNoLoadSave(m_bigBuf); + break; + case 3: + bRes = m_opt.InitLoadMenuOnly(m_bigBuf,false); + break; + case 4: + bRes = m_opt.InitSaveMenuOnly(m_bigBuf,false); + break; + } + + if (bRes) { + _vm->PauseSound(true); + + DisableInput(); + m_inv.EndCombine(); + m_curActionObj = 0; + m_curAction = TA_GOTO; + m_point.SetAction(m_curAction); + m_point.SetSpecialPointer(RMPointer::PTR_NONE); + m_point.SetCustomPointer(NULL); + EnableMouse(); + _vm->GrabThumbnail(); + + // Esce la IDLE onde evitare la morte prematura in caricamento + m_bMustEnterMenu = true; + if (type == 1 || type == 2) { + bIdleExited = true; + } else { + m_tony.StopNoAction(); + + uint32 id; + bIdleExited = false; + CreateThread(NULL, 10240, (LPTHREAD_START_ROUTINE)ExitAllIdles, (void *)m_nCurLoc, 0, &id); + } + } +} + +void RMGfxEngine::DoFrame(bool bDrawLocation) { + g_system->lockMutex(csMainLoop); + + // Poll dei dispositivi di input + m_input.Poll(); + + if (m_bMustEnterMenu && bIdleExited) { + m_bOption = true; + m_bMustEnterMenu = false; + bIdleExited = false; + } + + if (m_bOption) { + m_opt.DoFrame(&m_input); + m_bOption = !m_opt.IsClosing(); + if (!m_bOption) { + DisableMouse(); + EnableInput(); + mpalStartIdlePoll(m_nCurLoc); + _vm->PauseSound(false); + } + } + + if (bDrawLocation && m_bLocationLoaded) { + // Locazione e oggetti + m_loc.DoFrame(&m_bigBuf); + + // Controlla gli input del mouse + if (m_bInput && !m_tony.InAction()) { + // Se siamo sull'inventario, lui che controlla tutti gli input + if (m_inv.HaveFocus(m_input.MousePos()) && !m_inter.Active()) { + // CLICK SINISTRO + // ************** + if (m_input.MouseLeftClicked()/* && m_itemName.IsItemSelected()*/) { + // Left click attiva il combine, se siamo su un oggetto + if (m_inv.LeftClick(m_input.MousePos(),m_curActionObj)) { + m_curAction = TA_COMBINE; + m_point.SetAction(m_curAction); + } + } + else + + // CLICK DESTRO + // ************ + if (m_input.MouseRightClicked()) { + if(m_itemName.IsItemSelected()) { + m_curActionObj=0; + m_inv.RightClick(m_input.MousePos()); + } else + m_inv.RightClick(m_input.MousePos()); + } else + + // RILASCIO DESTRO + // *************** + if (m_input.MouseRightReleased()) { + if (m_inv.RightRelease(m_input.MousePos(), m_curAction)) { + m_tony.MoveAndDoAction(m_itemName.GetHotspot(),m_itemName.GetSelectedItem(),m_curAction); + + m_curAction = TA_GOTO; + m_point.SetAction(m_curAction); + } + } + } else { + // Menu Opzioni + // ************ + if (m_bGUIOption) { + if (!m_tony.InAction() && m_bInput) { + if ((m_input.MouseLeftClicked() && m_input.MousePos().x < 3 && m_input.MousePos().y < 3)) { + OpenOptionScreen(0); + goto SKIPCLICKSINISTRO; + } else if ((GetAsyncKeyState(Common::KEYCODE_ESCAPE)&0x8001) == 0x8001) + OpenOptionScreen(0); + else if (_vm->getIsDemo()) { + if ((GetAsyncKeyState(Common::KEYCODE_F3) & 0x8001) == 0x8001) + OpenOptionScreen(3); + else if ((GetAsyncKeyState(Common::KEYCODE_F2) & 0x8001) == 0x8001) + OpenOptionScreen(4); + } + } + } + + // CLICK SINISTRO + // ************** + if (m_input.MouseLeftClicked() && !m_inter.Active()) + { + // Se clicko dentro un oggetto, esegui l'azione + //if (m_itemName.IsItemSelected()) + { + if (m_curAction != TA_COMBINE) + m_tony.MoveAndDoAction(m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), m_point.CurAction()); + else if (m_itemName.GetSelectedItem() != NULL) + m_tony.MoveAndDoAction(m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), TA_COMBINE, m_curActionObj); + } + + if (m_curAction == TA_COMBINE) { + m_inv.EndCombine(); + m_point.SetSpecialPointer(RMPointer::PTR_NONE); + } + + m_curAction = TA_GOTO; + m_point.SetAction(m_curAction); + } + +SKIPCLICKSINISTRO: + // CLICK DESTRO + // ************ + if (m_curAction == TA_COMBINE) { + // Durante il combine, lo annulla. + if (m_input.MouseRightClicked()) { + m_inv.EndCombine(); + m_curActionObj = 0; + m_curAction = TA_GOTO; + m_point.SetAction(m_curAction); + m_point.SetSpecialPointer(RMPointer::PTR_NONE); + } + } else if (m_input.MouseRightClicked() && m_itemName.IsItemSelected() && m_point.GetSpecialPointer() == RMPointer::PTR_NONE) { + if (m_bGUIInterface) { + // Prima di aprire l'interfaccia, rimette GOTO + m_curAction = TA_GOTO; + m_curActionObj = 0; + m_point.SetAction(m_curAction); + m_inter.Clicked(m_input.MousePos()); + } + } + + + // RILASCIO DESTRO + // *************** + if (m_input.MouseRightReleased()) { + if (m_bGUIInterface) { + if (m_inter.Released(m_input.MousePos(),m_curAction)) { + m_point.SetAction(m_curAction); + m_tony.MoveAndDoAction(m_itemName.GetHotspot(),m_itemName.GetSelectedItem(), m_curAction); + + m_curAction = TA_GOTO; + m_point.SetAction(m_curAction); + } + } + } + } + + // Aggiorna il nome sotto il puntatore del mouse + m_itemName.SetMouseCoord(m_input.MousePos()); + if (!m_inter.Active() && !m_inv.MiniActive()) + m_itemName.DoFrame(m_bigBuf,m_loc,m_point,m_inv); + } + + // Inventario & interfaccia + m_inter.DoFrame(m_bigBuf, m_input.MousePos()); + m_inv.DoFrame(m_bigBuf, m_point, m_input.MousePos(), (!m_tony.InAction() && !m_inter.Active() && m_bGUIInventory)); + } + + // Anima Tony + m_tony.DoFrame(&m_bigBuf,m_nCurLoc); + + // Aggiorna lo scrolling per tenere Tony dentro lo schermo + if (m_tony.MustUpdateScrolling() && m_bLocationLoaded) { + RMPoint showThis = m_tony.Position(); + showThis.y -= 60; + m_loc.UpdateScrolling(showThis); + } + + if (m_bLocationLoaded) + m_tony.SetScrollPosition(m_loc.ScrollPosition()); + + if ((!m_tony.InAction() && m_bInput) || m_bAlwaysDrawMouse) { + m_point.SetCoord(m_input.MousePos()); + m_point.DoFrame(&m_bigBuf); + } + + // ********************** + // Disegna la lista di OT + // ********************** + m_bigBuf.DrawOT(); + +#define FSTEP (480/32) + + // Wipe + if (m_bWiping) { + switch (m_nWipeType) { + case 1: + if (!(m_rcWipeEllipse.bottom - m_rcWipeEllipse.top >= FSTEP * 2)) { + SetEvent(m_hWipeEvent); + m_nWipeType = 3; + break; + } + + m_rcWipeEllipse.top += FSTEP; + m_rcWipeEllipse.left += FSTEP; + m_rcWipeEllipse.right -= FSTEP; + m_rcWipeEllipse.bottom -= FSTEP; + break; + + case 2: + if (!(m_rcWipeEllipse.bottom - m_rcWipeEllipse.top < 480 - FSTEP)) { + SetEvent(m_hWipeEvent); + m_nWipeType = 3; + break; + } + + m_rcWipeEllipse.top -= FSTEP; + m_rcWipeEllipse.left -= FSTEP; + m_rcWipeEllipse.right += FSTEP; + m_rcWipeEllipse.bottom += FSTEP; + break; + } + } + + g_system->unlockMutex(csMainLoop); +} + + +void RMGfxEngine::InitCustomDll(void) { + SetupGlobalVars(&m_tony, &m_point, &_vm->_theBoxes, &m_loc, &m_inv, &m_input); +} + +void RMGfxEngine::ItemIrq(uint32 dwItem, int nPattern, int nStatus) { + static RMGfxEngine *This = NULL; + RMItem *item; + + // Inizializzazione! + if ((int)dwItem == -1) { + This = (RMGfxEngine*)nPattern; + return; + } + + if (This->m_bLocationLoaded) { + item=This->m_loc.GetItemFromCode(dwItem); + if (item != NULL) { + if (nPattern!=-1) { + if (bPatIrqFreeze) + MainFreeze(); + item->SetPattern(nPattern,true); + if (bPatIrqFreeze) + MainUnfreeze(); + } + if (nStatus!=-1) + item->SetStatus(nStatus); + } + } +} + +/* + // WINBUG: This is a special case for the file open/save dialog, + // which sometimes pumps while it is coming up but before it has + // disabled the main window. + HWND hWndFocus = ::GetFocus(); + bool bEnableParent = false; + m_ofn.hwndOwner = PreModal(); + AfxUnhookWindowCreate(); + if (m_ofn.hwndOwner != NULL && ::IsWindowEnabled(m_ofn.hwndOwner)) + { + bEnableParent = true; + ::EnableWindow(m_ofn.hwndOwner, false); + } + + _AFX_THREAD_STATE* pThreadState = AfxGetThreadState(); + ASSERT(pThreadState->m_pAlternateWndInit == NULL); + + if (m_ofn.Flags & OFN_EXPLORER) + pThreadState->m_pAlternateWndInit = this; + else + AfxHookWindowCreate(this); + + int nResult; + if (m_bOpenFileDialog) + nResult = ::GetOpenFileName(&m_ofn); + else + nResult = ::GetSaveFileName(&m_ofn); + + if (nResult) + ASSERT(pThreadState->m_pAlternateWndInit == NULL); + pThreadState->m_pAlternateWndInit = NULL; + + // WINBUG: Second part of special case for file open/save dialog. + if (bEnableParent) + ::EnableWindow(m_ofn.hwndOwner, true); + if (::IsWindow(hWndFocus)) + ::SetFocus(hWndFocus); +*/ + + +void RMGfxEngine::SelectLocation(RMPoint ptTonyStart, RMPoint start) { +#if 0 + OPENFILENAME ofn; + char lpszFileName[512]; + + // @@@ Con TonyStart=-1,-1 allora usa la posizione scritta nella locazione + + // Sceglie la locazione + ZeroMemory(lpszFileName,512); + ZeroMemory(&ofn,sizeof(ofn)); + ofn.lStructSize=sizeof(ofn); + ofn.hwndOwner=NULL; + ofn.lpstrFilter="Locazione (*.LOC)\0*.LOC\0Locazione ottimizzata (*.LOX)\0*.LOX\0Tutti i files (*.*)\0*.*\0"; + ofn.lpstrCustomFilter=NULL; + ofn.nFilterIndex=1; + ofn.lpstrFile=lpszFileName; + ofn.nMaxFile=512; + ofn.lpstrInitialDir=NULL; + ofn.lpstrTitle="Load Location"; + ofn.Flags=OFN_FILEMUSTEXIST|OFN_HIDEREADONLY|OFN_PATHMUSTEXIST; + + if (!GetOpenFileName(&ofn)) + ASSERT(0); + + // Carica la locazione + m_loc.Load(lpszFileName); + m_bLocationLoaded = true; + m_nCurLoc=m_loc.TEMPGetNumLoc(); + + if (ptTonyStart.x==-1 && ptTonyStart.y==-1) + InitForNewLocation(m_loc.TEMPGetNumLoc(),m_loc.TEMPGetTonyStart(),RMPoint(-1,-1)); + else + InitForNewLocation(m_loc.TEMPGetNumLoc(),ptTonyStart,start); +#endif +} + +void RMGfxEngine::InitForNewLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { + if (start.x == -1 || start.y == -1) { + start.x = ptTonyStart.x-RM_SX / 2; + start.y = ptTonyStart.y-RM_SY / 2; + } + + m_loc.SetScrollPosition(start); + + if (ptTonyStart.x==0 && ptTonyStart.y == 0) { + } else { + m_tony.SetPosition(ptTonyStart,nLoc); + m_tony.SetScrollPosition(start); + } + + m_curAction = TA_GOTO; + m_point.SetCustomPointer(NULL); + m_point.SetSpecialPointer(RMPointer::PTR_NONE); + m_point.SetAction(m_curAction); + m_inter.Reset(); + m_inv.Reset(); + + mpalStartIdlePoll(m_nCurLoc); +} + +HANDLE RMGfxEngine::LoadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { + bool bLoaded; + int i; + + m_nCurLoc=nLoc; + + bLoaded = false; + for (i=0; i < 5; i++) { + // Retry sul loading della locazione + RMRes res(m_nCurLoc); + if (!res.IsValid()) + continue; +#if 0 + // codice per dumpare una locazione in caso serva una modifica + if (nLoc == 106) + { + FILE *f = fopen("loc106.lox", "wb"); + fwrite(res.DataPointer(), res.Size(), 1, f); + fclose(f); + } +#endif + m_loc.Load(res); + InitForNewLocation(nLoc,ptTonyStart,start); + bLoaded = true; + break; + } + + if (!bLoaded) + SelectLocation(ptTonyStart,start); + + if (m_bOption) + m_opt.ReInit(m_bigBuf); + + m_bLocationLoaded = true; + + // On Enter per la locazion + return INVALID_HANDLE_VALUE; //mpalQueryDoAction(0,m_nCurLoc,0); +} + +HANDLE RMGfxEngine::UnloadLocation(bool bDoOnExit) +{ + HANDLE h; + + // Scarica tutta la memoria della locazione + mpalEndIdlePoll(m_nCurLoc); + + // On Exit? + if (bDoOnExit) + { + h=mpalQueryDoAction(1,m_nCurLoc,0); + if (h!=INVALID_HANDLE_VALUE) + WaitForSingleObject(h,INFINITE); + } + + MainFreeze(); + + m_bLocationLoaded = false; + + m_bigBuf.ClearOT(); + m_loc.Unload(); + + return INVALID_HANDLE_VALUE; +} + +void RMGfxEngine::Init(/*HINSTANCE hInst*/) { +/* + //RECUPERARE UNA LOCAZIONE: + + RMRes res(5); + ASSERT(res.IsValid()); + FILE *f; + f=fopen("c:\\code\\rm\\new\\pippo.loc","wb"); + fwrite(res,1,5356900,f); + fclose(f); +*/ + + // Schermata di loading + RMResRaw *raw; + RMGfxSourceBuffer16 *load = NULL; + INIT_GFX16_FROMRAW(20038, load); + m_bigBuf.AddPrim(new RMGfxPrimitive(load)); + m_bigBuf.DrawOT(); + m_bigBuf.ClearOT(); + delete load; + _vm->m_wnd.GetNewFrame(*this, NULL); + + + + bPatIrqFreeze = true; + + // GUI attivabile + m_bGUIOption = true; + m_bGUIInterface = true; + m_bGUIInventory = true; + + bSkipSfxNoLoop = false; + m_bMustEnterMenu = false; + bIdleExited = false; + m_bOption = false; + m_bWiping = false; + m_hWipeEvent = CreateEvent(NULL, false, false, NULL); + + // Inizializza la funzione di IRQ di Item per l'MPAL + ItemIrq((uint32)-1, (uint32)this, 0); + mpalInstallItemIrq(ItemIrq); + + // Inizializza DirectInput + m_input.Init(/*hInst*/); + + // Inizializza il puntatore del mouse + m_point.Init(); + + // Inizializza Tony + m_tony.Init(); + m_tony.LinkToBoxes(&_vm->_theBoxes); + + // Inizializza l'inventario e l'interfaccia + m_inv.Init(); + m_inter.Init(); + + // Carica la locazione e setta le priorit @@@@@ + m_bLocationLoaded = false; +/* + m_nCurLoc=1; + RMRes res(m_nCurLoc); + m_loc.Load(res); + m_loc.SetPriority(1); + m_tony.SetPosition(RMPoint(201,316),1); + //m_tony.SetPosition(RMPoint(522,305),2); + //m_tony.SetPosition(RMPoint(158,398),4); + m_tony.SetPattern(m_tony.PAT_STANDDOWN); + m_curAction=TA_GOTO; +*/ + EnableInput(); + + // Inizio del gioco + //m_tony.ExecuteAction(4,1,0); //PREGAME + + m_tony.ExecuteAction(20,1,0); + +// theLog << "Seleziona la locazione\n"; + //LoadLocation(1,RMPoint(201,316),RMPoint(-1,-1)); + //SelectLocation(); + //LoadLocation(5,RMPoint(685,338),RMPoint(-1,-1)); + //LoadLocation(7,RMPoint(153,424),RMPoint(-1,-1)); + //LoadLocation(70,RMPoint(10,10),RMPoint(-1,-1)); + //LoadLocation(20,RMPoint(112,348),RMPoint(-1,-1)); + //LoadLocation(26,RMPoint(95,456),RMPoint(-1,-1)); + //LoadLocation(12,RMPoint(221,415),RMPoint(-1,-1)); + //LoadLocation(25,RMPoint(221,415),RMPoint(-1,-1)); + //LoadLocation(16,RMPoint(111,438),RMPoint(-1,-1)); + //LoadLocation(60,RMPoint(18,302),RMPoint(-1,-1)); + + // CASTELLO + + //LoadLocation(40,RMPoint(233,441),RMPoint(-1,-1)); +} + +void RMGfxEngine::Close(void) +{ + m_bigBuf.ClearOT(); + + m_inter.Close(); + m_inv.Close(); + m_tony.Close(); + m_point.Close(); + m_input.Close(); +} + +void RMGfxEngine::SwitchFullscreen(bool bFull) +{ + m_input.SwitchFullscreen(bFull); +} + +void RMGfxEngine::GDIControl(bool bCon) +{ + m_input.GDIControl(bCon); +} + +/* +void RMGfxEngine::OptionScreen(void) +{ + if (!m_bOption) + { + if (m_opt.Init(m_bigBuf)) + { + m_bOption = true; + DisableInput(); + EnableMouse(); + } + } + else + { + if (m_opt.Close()) + { + m_bOption = false; + DisableMouse(); + EnableInput(); + } + } +} +*/ + +void RMGfxEngine::EnableInput(void) +{ + m_bInput = true; +} + +void RMGfxEngine::DisableInput(void) +{ + m_bInput = false; + m_inter.Reset(); +} + +void RMGfxEngine::EnableMouse(void) +{ + m_bAlwaysDrawMouse = true; +} + +void RMGfxEngine::DisableMouse(void) +{ + m_bAlwaysDrawMouse = false; +} + +void RMGfxEngine::Freeze(void) +{ + g_system->lockMutex(csMainLoop); +} + +void RMGfxEngine::Unfreeze(void) +{ + g_system->unlockMutex(csMainLoop); +} + +void CharsSaveAll(Common::OutSaveFile *f); +void CharsLoadAll(Common::InSaveFile *f); +void MCharResetCodes(void); +void SaveChangedHotspot(Common::OutSaveFile *f); +void LoadChangedHotspot(Common::InSaveFile *f); +void ReapplyChangedHotspot(void); + +void RestoreMusic(void); +void SaveMusic(Common::OutSaveFile *f); +void LoadMusic(Common::InSaveFile *f); + +unsigned char wrkmem[LZO1X_999_MEM_COMPRESS]; + +void RMGfxEngine::SaveState(const char *fn, byte *curThumb, const char *name, bool bFastCompress) { + Common::OutSaveFile *f; + byte *state, *statecmp; + byte *thumbcmp; + uint thumbsizecmp, thumbsize; + uint size, sizecmp; + int i; + char buf[4]; + RMPoint tp = m_tony.Position(); + + // Salvataggio: variabili mpal + locazione corrente + posizione di tony + inventario + + // Per ora salviamo solo lo stato MPAL + size=mpalGetSaveStateSize(); + state = new byte[size]; + statecmp = new byte[size*2]; + mpalSaveState(state); + + thumbcmp = new byte[160 * 120 * 4]; + thumbsize = 160 * 120 * 2; + + if (bFastCompress) { + lzo1x_1_compress(state,size,statecmp,&sizecmp,wrkmem); + lzo1x_1_compress(curThumb,thumbsize,thumbcmp,&thumbsizecmp,wrkmem); + } else { + lzo1x_999_compress(state,size,statecmp,&sizecmp,wrkmem); + lzo1x_999_compress(curThumb,thumbsize,thumbcmp,&thumbsizecmp,wrkmem); + } + + buf[0] = 'R'; + buf[1] = 'M'; + buf[2] = 'S'; + buf[3] = 0x7; + + f = g_system->getSavefileManager()->openForSaving(fn); + if (f==NULL) return; + f->write(buf, 4); + f->writeUint32LE(thumbsizecmp); + f->write(thumbcmp, thumbsizecmp); + + // Livello di difficolt + i = mpalQueryGlobalVar("VERSIONEFACILE"); + f->writeByte(i); + + i=strlen(name); + f->writeByte(i); + f->write(name, i); + f->writeUint32LE(m_nCurLoc); + f->writeUint32LE(tp.x); + f->writeUint32LE(tp.y); + f->writeUint32LE(size); + f->writeUint32LE(sizecmp); + f->write(statecmp, sizecmp); + delete[] state; + delete[] statecmp; + delete[] thumbcmp; + + // inventario + size = m_inv.GetSaveStateSize(); + state = new byte[size]; + m_inv.SaveState(state); + f->writeUint32LE(size); + f->write(state, size); + delete[] state; + + // boxes + size = _vm->_theBoxes.GetSaveStateSize(); + state = new byte[size]; + _vm->_theBoxes.SaveState(state); + f->writeUint32LE(size); + f->write(state, size); + delete[] state; + + // New Ver5 + bool bStat; + + // Salva lo stato della pastorella e del palesati + bStat = m_tony.GetPastorella(); + f->writeByte(bStat); + bStat = m_inter.GetPalesati(); + f->writeByte(bStat); + + // Salva gli mchar + CharsSaveAll(f); + + // Salva le opzioni + f->writeByte(bCfgInvLocked); + f->writeByte(bCfgInvNoScroll); + f->writeByte(bCfgTimerizedText); + f->writeByte(bCfgInvUp); + f->writeByte(bCfgAnni30); + f->writeByte(bCfgAntiAlias); + f->writeByte(bCfgSottotitoli); + f->writeByte(bCfgTransparence); + f->writeByte(bCfgInterTips); + f->writeByte(bCfgDubbing); + f->writeByte(bCfgMusic); + f->writeByte(bCfgSFX); + f->writeByte(nCfgTonySpeed); + f->writeByte(nCfgTextSpeed); + f->writeByte(nCfgDubbingVolume); + f->writeByte(nCfgMusicVolume); + f->writeByte(nCfgSFXVolume); + + // Salva gli hotspot + SaveChangedHotspot(f); + + // Salva la musica + SaveMusic(f); + + f->finalize(); + delete f; +} + +void RMGfxEngine::LoadState(const char *fn) { + // PROBLEMA: Bisognerebbe caricare la locazione in un thread a parte per fare la OnEnter ... + Common::InSaveFile *f; + byte *state, *statecmp; + uint size, sizecmp; + char buf[4]; + RMPoint tp; + int loc; + int ver; + int i; + + f = g_system->getSavefileManager()->openForLoading(fn); + if (f == NULL) return; + f->read(buf, 4); + if (buf[0] != 'R' || buf[1] != 'M' || buf[2] != 'S') { + delete f; + return; + } + + ver = buf[3]; + + if (ver != 0x1 && ver != 0x2 && ver != 0x3 && ver != 0x4 && ver != 0x5 && ver != 0x6 && ver != 0x7) { + delete f; + return; + } + + if (ver >= 0x3) { + // C' il thumbnail. Se ver >= 5, compresso + if (ver >= 0x5) { + i = 0; + i = f->readUint32LE(); + f->seek(i); + } else + f->seek(160 * 120 * 2, SEEK_CUR); + } + + if (ver >= 0x5) { + // Skip del livello di difficolt + f->seek(1, SEEK_CUR); + } + + if (ver >= 0x4) { // Skippa il nome, che non serve a nessuno + i = f->readByte(); + f->seek(i, SEEK_CUR); + } + + loc = f->readUint32LE(); + loc = f->readUint32LE(); + tp.x = f->readUint32LE(); + tp.y = f->readUint32LE(); + size = f->readUint32LE(); + + if (ver >= 0x5) { + // Stato MPAL compresso! + sizecmp = f->readUint32LE(); + state = new byte[size]; + statecmp = new byte[sizecmp]; + f->read(statecmp, sizecmp); + lzo1x_decompress(statecmp,sizecmp,state,&size); + delete[] statecmp; + } else { + state = new byte[size]; + f->read(state, size); + } + + mpalLoadState(state); + delete[] state; + + + // inventario + size = f->readUint32LE(); + state = new byte[size]; + f->read(state, size); + m_inv.LoadState(state); + delete[] state; + + if (ver >= 0x2) { // Versione 2: box please + size = f->readUint32LE(); + state = new byte[size]; + f->read(state, size); + _vm->_theBoxes.LoadState(state); + delete[] state; + } + + if (ver >= 5) { + // Versione 5: + bool bStat = false; + + bStat = f->readByte(); + m_tony.SetPastorella(bStat); + bStat = f->readByte(); + m_inter.SetPalesati(bStat); + + CharsLoadAll(f); + } + + if (ver >= 6) { + // Carica le opzioni + bCfgInvLocked = f->readByte(); + bCfgInvNoScroll = f->readByte(); + bCfgTimerizedText = f->readByte(); + bCfgInvUp = f->readByte(); + bCfgAnni30 = f->readByte(); + bCfgAntiAlias = f->readByte(); + bCfgSottotitoli = f->readByte(); + bCfgTransparence = f->readByte(); + bCfgInterTips = f->readByte(); + bCfgDubbing = f->readByte(); + bCfgMusic = f->readByte(); + bCfgSFX = f->readByte(); + nCfgTonySpeed = f->readByte(); + nCfgTextSpeed = f->readByte(); + nCfgDubbingVolume = f->readByte(); + nCfgMusicVolume = f->readByte(); + nCfgSFXVolume = f->readByte(); + + // Carica gli hotspot + LoadChangedHotspot(f); + } + + if (ver >= 7) { + LoadMusic(f); + } + + delete f; + + UnloadLocation(false); + LoadLocation(loc,tp,RMPoint(-1, -1)); + m_tony.SetPattern(RMTony::PAT_STANDRIGHT); + MainUnfreeze(); + + // Le versioni vecchie necessitano di On enter + if (ver < 5) + mpalQueryDoAction(0,loc,0); + else { + // In quelle nuove, ci basta resettare gli mcode + MCharResetCodes(); + } + + if (ver >= 6) + ReapplyChangedHotspot(); + + RestoreMusic(); + + m_bGUIInterface = true; + m_bGUIInventory = true; + m_bGUIOption = true; +} + +void RMGfxEngine::PauseSound(bool bPause) { + if (m_bLocationLoaded) + m_loc.PauseSound(bPause); +} + +void RMGfxEngine::InitWipe(int type) { + m_bWiping = true; + m_nWipeType=type; + m_nWipeStep=0; + + if (m_nWipeType == 1) + m_rcWipeEllipse = Common::Rect(80, 0, 640 - 80, 480); + else if (m_nWipeType == 2) + m_rcWipeEllipse = Common::Rect(320 - FSTEP, 240 - FSTEP, 320 + FSTEP, 240 + FSTEP); +} + +void RMGfxEngine::CloseWipe(void) { + m_bWiping = false; +} + +void RMGfxEngine::WaitWipeEnd(void) { + WaitForSingleObject(m_hWipeEvent,INFINITE); +} } // End of namespace Tony diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index e27cb6d9d3..edad3690e9 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -25,6 +25,7 @@ #include "common/config-manager.h" #include "common/file.h" #include "tony/tony.h" +#include "tony/game.h" #include "tony/mpal/mpal.h" namespace Tony { @@ -91,7 +92,33 @@ Common::ErrorCode TonyEngine::Init() { _theBoxes.Init(); // Link to the custom graphics engine - + _theEngine.InitCustomDll(); + + // Inizializza il gfxEngine + _theEngine.Init(); + + // Memoria per il thumbnail + m_curThumbnail = new uint16[160 * 120]; + + // Configurazione di default + bCfgInvLocked = false; + bCfgInvNoScroll = false; + bCfgTimerizedText = true; + bCfgInvUp = false; + bCfgAnni30 = false; + bCfgAntiAlias = false; + bCfgTransparence = true; + bCfgInterTips = true; + bCfgSottotitoli = true; + nCfgTonySpeed = 3; + nCfgTextSpeed = 5; + bCfgDubbing = true; + bCfgMusic = true; + bCfgSFX = true; + nCfgDubbingVolume = 10; + nCfgMusicVolume = 7; + nCfgSFXVolume = 10; + m_bQuitNow = false; return Common::kNoError; } -- cgit v1.2.3 From c831248e652a892fe49f8ab7778ea5f5e1aa1ee8 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 1 May 2012 23:44:02 +1000 Subject: TONY: Cleanup of GfxEngine, and added RMTony class methods --- engines/tony/game.cpp | 944 ----------------------- engines/tony/module.mk | 1 + engines/tony/tony.cpp | 94 +++ engines/tony/tony.h | 9 + engines/tony/tonychar.cpp | 1813 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 1917 insertions(+), 944 deletions(-) create mode 100644 engines/tony/tonychar.cpp (limited to 'engines') diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index acafbbf7c8..109eefab24 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -235,948 +235,4 @@ void RMOptionButton::AddToList(RMGfxTargetBuffer &bigBuf) { bigBuf.AddPrim(new RMGfxPrimitive(this, m_rect)); } - -/****************************************************************************\ -* Metodi di RMGfxEngine -\****************************************************************************/ - -bool bIdleExited; - -void ExitAllIdles(int nCurLoc) { - // Chiude le idle - bSkipSfxNoLoop = true; - mpalEndIdlePoll(nCurLoc); - bIdleExited = true; - bSkipSfxNoLoop = false; - ExitThread(0); -} - - -RMGfxEngine::RMGfxEngine() { - // Crea il big buffer dove verranno disegnati i frame - m_bigBuf.Create(RM_BBX, RM_BBY, 16); - m_bigBuf.OffsetY(RM_SKIPY); -} - -RMGfxEngine::~RMGfxEngine() { - // Chiude il buffer - m_bigBuf.Destroy(); -} - -void RMGfxEngine::OpenOptionScreen(int type) { - bool bRes = false; - - switch (type) { - case 0: - bRes = m_opt.Init(m_bigBuf); - break; - case 1: - bRes = m_opt.InitLoadMenuOnly(m_bigBuf, true); - break; - case 2: - bRes = m_opt.InitNoLoadSave(m_bigBuf); - break; - case 3: - bRes = m_opt.InitLoadMenuOnly(m_bigBuf, false); - break; - case 4: - bRes = m_opt.InitSaveMenuOnly(m_bigBuf, false); - break; - } - - if (bRes) { - _vm->PauseSound(true); - - DisableInput(); - m_inv.EndCombine(); - m_curActionObj=0; - m_curAction=TA_GOTO; - m_point.SetAction(m_curAction); - m_point.SetSpecialPointer(RMPointer::PTR_NONE); - m_point.SetCustomPointer(NULL); - EnableMouse(); - _vm->GrabThumbnail(); - - // Esce la IDLE onde evitare la morte prematura in caricamento - m_bMustEnterMenu = true; - if (type == 1 || type == 2) { - bIdleExited = true; - } else { - m_tony.StopNoAction(); - - uint32 id; - bIdleExited = false; - CreateThread(NULL, 10240, (LPTHREAD_START_ROUTINE)ExitAllIdles, (void *)m_nCurLoc, 0, &id); - } - } -} - -void RMGfxEngine::DoFrame(bool bDrawLocation) { - g_system->lockMutex(csMainLoop); - - // Poll dei dispositivi di input - m_input.Poll(); - - if (m_bMustEnterMenu && bIdleExited) { - m_bOption = true; - m_bMustEnterMenu = false; - bIdleExited = false; - } - - if (m_bOption) { - m_opt.DoFrame(&m_input); - m_bOption = !m_opt.IsClosing(); - if (!m_bOption) { - DisableMouse(); - EnableInput(); - mpalStartIdlePoll(m_nCurLoc); - _vm->PauseSound(false); - } - } - - if (bDrawLocation && m_bLocationLoaded) { - // Locazione e oggetti - m_loc.DoFrame(&m_bigBuf); - - // Controlla gli input del mouse - if (m_bInput && !m_tony.InAction()) { - // Se siamo sull'inventario, lui che controlla tutti gli input - if (m_inv.HaveFocus(m_input.MousePos()) && !m_inter.Active()) { - // CLICK SINISTRO - // ************** - if (m_input.MouseLeftClicked()/* && m_itemName.IsItemSelected()*/) { - // Left click attiva il combine, se siamo su un oggetto - if (m_inv.LeftClick(m_input.MousePos(),m_curActionObj)) { - m_curAction=TA_COMBINE; - m_point.SetAction(m_curAction); - } - } - else - - // CLICK DESTRO - // ************ - if (m_input.MouseRightClicked()) { - if(m_itemName.IsItemSelected()) { - m_curActionObj=0; - m_inv.RightClick(m_input.MousePos()); - } else - m_inv.RightClick(m_input.MousePos()); - } else - - // RILASCIO DESTRO - // *************** - if (m_input.MouseRightReleased()) { - if (m_inv.RightRelease(m_input.MousePos(), m_curAction)) { - m_tony.MoveAndDoAction(m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), m_curAction); - - m_curAction=TA_GOTO; - m_point.SetAction(m_curAction); - } - } - } else { - // Menu Opzioni - // ************ - if (m_bGUIOption) { - if (!m_tony.InAction() && m_bInput) { - if ((m_input.MouseLeftClicked() && m_input.MousePos().x < 3 && m_input.MousePos().y < 3)) { - OpenOptionScreen(0); - goto SKIPCLICKSINISTRO; - } else if ((GetAsyncKeyState(Common::KEYCODE_ESCAPE) & 0x8001) == 0x8001) - OpenOptionScreen(0); - else if (!_vm->getIsDemo()) { - if ((GetAsyncKeyState(Common::KEYCODE_F3) & 0x8001)==0x8001) - OpenOptionScreen(3); - else if ((GetAsyncKeyState(Common::KEYCODE_F2) & 0x8001)==0x8001) - OpenOptionScreen(4); - } - } - } - - // CLICK SINISTRO - // ************** - if (m_input.MouseLeftClicked() && !m_inter.Active()) { - // Se clicko dentro un oggetto, esegui l'azione - //if (m_itemName.IsItemSelected()) - { - if (m_curAction!=TA_COMBINE) - m_tony.MoveAndDoAction(m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), m_point.CurAction()); - else if (m_itemName.GetSelectedItem() != NULL) - m_tony.MoveAndDoAction(m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), TA_COMBINE, m_curActionObj); - } - - if (m_curAction==TA_COMBINE) { - m_inv.EndCombine(); - m_point.SetSpecialPointer(RMPointer::PTR_NONE); - } - - m_curAction=TA_GOTO; - m_point.SetAction(m_curAction); - } - -SKIPCLICKSINISTRO: - // CLICK DESTRO - // ************ - if (m_curAction == TA_COMBINE) { - // Durante il combine, lo annulla. - if (m_input.MouseRightClicked()) { - m_inv.EndCombine(); - m_curActionObj = 0; - m_curAction = TA_GOTO; - m_point.SetAction(m_curAction); - m_point.SetSpecialPointer(RMPointer::PTR_NONE); - } - } else if (m_input.MouseRightClicked() && m_itemName.IsItemSelected() && m_point.GetSpecialPointer() == RMPointer::PTR_NONE) { - if (m_bGUIInterface) { - // Prima di aprire l'interfaccia, rimette GOTO - m_curAction = TA_GOTO; - m_curActionObj = 0; - m_point.SetAction(m_curAction); - m_inter.Clicked(m_input.MousePos()); - } - } - - - // RILASCIO DESTRO - // *************** - if (m_input.MouseRightReleased()) { - if (m_bGUIInterface) { - if (m_inter.Released(m_input.MousePos(), m_curAction)) { - m_point.SetAction(m_curAction); - m_tony.MoveAndDoAction(m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), m_curAction); - - m_curAction=TA_GOTO; - m_point.SetAction(m_curAction); - } - } - } - } - - // Aggiorna il nome sotto il puntatore del mouse - m_itemName.SetMouseCoord(m_input.MousePos()); - if (!m_inter.Active() && !m_inv.MiniActive()) - m_itemName.DoFrame(m_bigBuf, m_loc, m_point, m_inv); - } - - // Inventario & interfaccia - m_inter.DoFrame(m_bigBuf, m_input.MousePos()); - m_inv.DoFrame(m_bigBuf, m_point, m_input.MousePos(), (!m_tony.InAction() && !m_inter.Active() && m_bGUIInventory)); - } - - // Anima Tony - m_tony.DoFrame(&m_bigBuf, m_nCurLoc); - - // Aggiorna lo scrolling per tenere Tony dentro lo schermo - if (m_tony.MustUpdateScrolling() && m_bLocationLoaded) { - RMPoint showThis=m_tony.Position(); - showThis.y -= 60; - m_loc.UpdateScrolling(showThis); - } - - if (m_bLocationLoaded) - m_tony.SetScrollPosition(m_loc.ScrollPosition()); - - if ((!m_tony.InAction() && m_bInput) || m_bAlwaysDrawMouse) { - m_point.SetCoord(m_input.MousePos()); - m_point.DoFrame(&m_bigBuf); - } - - // ********************** - // Disegna la lista di OT - // ********************** - m_bigBuf.DrawOT(); - -#define FSTEP (480/32) - - // Wipe - if (m_bWiping) - { - switch (m_nWipeType) { - case 1: - if (!(m_rcWipeEllipse.bottom-m_rcWipeEllipse.top>=FSTEP*2)) { - SetEvent(m_hWipeEvent); - m_nWipeType=3; - break; - } - - m_rcWipeEllipse.top+=FSTEP; - m_rcWipeEllipse.left+=FSTEP; - m_rcWipeEllipse.right-=FSTEP; - m_rcWipeEllipse.bottom-=FSTEP; - break; - - case 2: - if (!(m_rcWipeEllipse.bottom-m_rcWipeEllipse.top<480-FSTEP)) { - SetEvent(m_hWipeEvent); - m_nWipeType=3; - break; - } - - m_rcWipeEllipse.top-=FSTEP; - m_rcWipeEllipse.left-=FSTEP; - m_rcWipeEllipse.right+=FSTEP; - m_rcWipeEllipse.bottom+=FSTEP; - break; - } - } - - g_system->unlockMutex(csMainLoop); -} - - -void RMGfxEngine::InitCustomDll(void) { - SetupGlobalVars(&m_tony, &m_point, &_vm->_theBoxes, &m_loc, &m_inv, &m_input); -} - -void RMGfxEngine::ItemIrq(uint32 dwItem, int nPattern, int nStatus) { - static RMGfxEngine *This = NULL; - RMItem *item; - - // Inizializzazione! - if ((int)dwItem == -1) - { - This=(RMGfxEngine*)nPattern; - return; - } - - if (This->m_bLocationLoaded) { - item = This->m_loc.GetItemFromCode(dwItem); - if (item != NULL) { - if (nPattern != -1) { - if (bPatIrqFreeze) - MainFreeze(); - item->SetPattern(nPattern, true); - if (bPatIrqFreeze) - MainUnfreeze(); - } - if (nStatus!=-1) - item->SetStatus(nStatus); - } - } -} - -/* - // WINBUG: This is a special case for the file open/save dialog, - // which sometimes pumps while it is coming up but before it has - // disabled the main window. - HWND hWndFocus = ::GetFocus(); - bool bEnableParent = false; - m_ofn.hwndOwner = PreModal(); - AfxUnhookWindowCreate(); - if (m_ofn.hwndOwner != NULL && ::IsWindowEnabled(m_ofn.hwndOwner)) - { - bEnableParent = true; - ::EnableWindow(m_ofn.hwndOwner, false); - } - - _AFX_THREAD_STATE* pThreadState = AfxGetThreadState(); - assert(pThreadState->m_pAlternateWndInit == NULL); - - if (m_ofn.Flags & OFN_EXPLORER) - pThreadState->m_pAlternateWndInit = this; - else - AfxHookWindowCreate(this); - - int nResult; - if (m_bOpenFileDialog) - nResult = ::GetOpenFileName(&m_ofn); - else - nResult = ::GetSaveFileName(&m_ofn); - - if (nResult) - assert(pThreadState->m_pAlternateWndInit == NULL); - pThreadState->m_pAlternateWndInit = NULL; - - // WINBUG: Second part of special case for file open/save dialog. - if (bEnableParent) - ::EnableWindow(m_ofn.hwndOwner, true); - if (::IsWindow(hWndFocus)) - ::SetFocus(hWndFocus); -*/ - - -void RMGfxEngine::SelectLocation(RMPoint ptTonyStart, RMPoint start) { -#if 0 - OPENFILENAME ofn; - char lpszFileName[512]; - - // @@@ Con TonyStart=-1,-1 allora usa la posizione scritta nella locazione - - // Sceglie la locazione - ZeroMemory(lpszFileName,512); - ZeroMemory(&ofn,sizeof(ofn)); - ofn.lStructSize=sizeof(ofn); - ofn.hwndOwner=NULL; - ofn.lpstrFilter="Locazione (*.LOC)\0*.LOC\0Locazione ottimizzata (*.LOX)\0*.LOX\0Tutti i files (*.*)\0*.*\0"; - ofn.lpstrCustomFilter=NULL; - ofn.nFilterIndex=1; - ofn.lpstrFile=lpszFileName; - ofn.nMaxFile=512; - ofn.lpstrInitialDir=NULL; - ofn.lpstrTitle="Load Location"; - ofn.Flags=OFN_FILEMUSTEXIST|OFN_HIDEREADONLY|OFN_PATHMUSTEXIST; - - if (!GetOpenFileName(&ofn)) - assert(0); - - // Carica la locazione - m_loc.Load(lpszFileName); - m_bLocationLoaded = true; - m_nCurLoc=m_loc.TEMPGetNumLoc(); - - if (ptTonyStart.x==-1 && ptTonyStart.y==-1) - InitForNewLocation(m_loc.TEMPGetNumLoc(),m_loc.TEMPGetTonyStart(),RMPoint(-1,-1)); - else - InitForNewLocation(m_loc.TEMPGetNumLoc(),ptTonyStart,start); -#endif -} - -void RMGfxEngine::InitForNewLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { - if (start.x == -1 || start.y == -1) { - start.x = ptTonyStart.x-RM_SX/2; - start.y = ptTonyStart.y-RM_SY/2; - } - - m_loc.SetScrollPosition(start); - - if (ptTonyStart.x==0 && ptTonyStart.y==0) { - } else { - m_tony.SetPosition(ptTonyStart, nLoc); - m_tony.SetScrollPosition(start); - } - - m_curAction=TA_GOTO; - m_point.SetCustomPointer(NULL); - m_point.SetSpecialPointer(RMPointer::PTR_NONE); - m_point.SetAction(m_curAction); - m_inter.Reset(); - m_inv.Reset(); - - mpalStartIdlePoll(m_nCurLoc); -} - -HANDLE RMGfxEngine::LoadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { - bool bLoaded; - int i; - - m_nCurLoc=nLoc; - - bLoaded = false; - for (i = 0; i < 5; i++) { - // Retry sul loading della locazione - RMRes res(m_nCurLoc); - if (!res.IsValid()) - continue; -#if 0 - // codice per dumpare una locazione in caso serva una modifica - if (nLoc == 106) - { - FILE *f = fopen("loc106.lox", "wb"); - fwrite(res.DataPointer(), res.Size(), 1, f); - fclose(f); - } -#endif - m_loc.Load(res); - InitForNewLocation(nLoc, ptTonyStart, start); - bLoaded = true; - break; - } - - if (!bLoaded) - SelectLocation(ptTonyStart, start); - - if (m_bOption) - m_opt.ReInit(m_bigBuf); - - m_bLocationLoaded = true; - - // On Enter per la locazion - return INVALID_HANDLE_VALUE; //mpalQueryDoAction(0, m_nCurLoc, 0); -} - -HANDLE RMGfxEngine::UnloadLocation(bool bDoOnExit) { - HANDLE h; - - // Scarica tutta la memoria della locazione - mpalEndIdlePoll(m_nCurLoc); - - // On Exit? - if (bDoOnExit) { - h = mpalQueryDoAction(1, m_nCurLoc, 0); - if (h != INVALID_HANDLE_VALUE) - WaitForSingleObject(h, INFINITE); - } - - MainFreeze(); - - m_bLocationLoaded = false; - - m_bigBuf.ClearOT(); - m_loc.Unload(); - - return INVALID_HANDLE_VALUE; -} - -void RMGfxEngine::Init() { - // Screen loading - RMResRaw *raw; - RMGfxSourceBuffer16 *load = NULL; - INIT_GFX16_FROMRAW(20038, load); - m_bigBuf.AddPrim(new RMGfxPrimitive(load)); - m_bigBuf.DrawOT(); - m_bigBuf.ClearOT(); - delete load; - _vm->m_wnd.GetNewFrame(*this, NULL); - - - - bPatIrqFreeze = true; - - // GUI attivabile - m_bGUIOption = true; - m_bGUIInterface = true; - m_bGUIInventory = true; - - bSkipSfxNoLoop = false; - m_bMustEnterMenu = false; - bIdleExited = false; - m_bOption = false; - m_bWiping = false; - m_hWipeEvent=CreateEvent(NULL, false, false, NULL); - - // Crea l'evento di freeze - g_system->lockMutex(csMainLoop); - - // Inizializza la funzione di IRQ di Item per l'MPAL - ItemIrq((uint32)-1, (uint32)this, 0); - mpalInstallItemIrq(ItemIrq); - - // Inizializza DirectInput - m_input.Init(/*hInst*/); - - // Inizializza il puntatore del mouse - m_point.Init(); - - // Inizializza Tony - m_tony.Init(); - m_tony.LinkToBoxes(&_vm->_theBoxes); - - // Inizializza l'inventario e l'interfaccia - m_inv.Init(); - m_inter.Init(); - - // Carica la locazione e setta le priorit @@@@@ - m_bLocationLoaded = false; -/* - m_nCurLoc=1; - RMRes res(m_nCurLoc); - m_loc.Load(res); - m_loc.SetPriority(1); - m_tony.SetPosition(RMPoint(201,316),1); - //m_tony.SetPosition(RMPoint(522,305),2); - //m_tony.SetPosition(RMPoint(158,398),4); - m_tony.SetPattern(m_tony.PAT_STANDDOWN); - m_curAction=TA_GOTO; -*/ - EnableInput(); - - // Inizio del gioco - //m_tony.ExecuteAction(4,1,0); //PREGAME - - m_tony.ExecuteAction(20,1,0); - -// theLog << "Seleziona la locazione\n"; - //LoadLocation(1,RMPoint(201,316),RMPoint(-1,-1)); - //SelectLocation(); - //LoadLocation(5,RMPoint(685,338),RMPoint(-1,-1)); - //LoadLocation(7,RMPoint(153,424),RMPoint(-1,-1)); - //LoadLocation(70,RMPoint(10,10),RMPoint(-1,-1)); - //LoadLocation(20,RMPoint(112,348),RMPoint(-1,-1)); - //LoadLocation(26,RMPoint(95,456),RMPoint(-1,-1)); - //LoadLocation(12,RMPoint(221,415),RMPoint(-1,-1)); - //LoadLocation(25,RMPoint(221,415),RMPoint(-1,-1)); - //LoadLocation(16,RMPoint(111,438),RMPoint(-1,-1)); - //LoadLocation(60,RMPoint(18,302),RMPoint(-1,-1)); - - // CASTELLO - - //LoadLocation(40,RMPoint(233,441),RMPoint(-1,-1)); -} - -void RMGfxEngine::Close(void) { - m_bigBuf.ClearOT(); - - m_inter.Close(); - m_inv.Close(); - m_tony.Close(); - m_point.Close(); - m_input.Close(); -} - -void RMGfxEngine::SwitchFullscreen(bool bFull) { - m_input.SwitchFullscreen(bFull); -} - -void RMGfxEngine::GDIControl(bool bCon) -{ - m_input.GDIControl(bCon); -} - -/* -void RMGfxEngine::OptionScreen(void) -{ - if (!m_bOption) - { - if (m_opt.Init(m_bigBuf)) - { - m_bOption = true; - DisableInput(); - EnableMouse(); - } - } - else - { - if (m_opt.Close()) - { - m_bOption = false; - DisableMouse(); - EnableInput(); - } - } -} -*/ - -void RMGfxEngine::EnableInput(void) { - m_bInput = true; -} - -void RMGfxEngine::DisableInput(void) { - m_bInput = false; - m_inter.Reset(); -} - -void RMGfxEngine::EnableMouse(void) { - m_bAlwaysDrawMouse = true; -} - -void RMGfxEngine::DisableMouse(void) { - m_bAlwaysDrawMouse = false; -} - -void RMGfxEngine::Freeze(void) { - g_system->lockMutex(csMainLoop); -} - -void RMGfxEngine::Unfreeze(void) { - g_system->unlockMutex(csMainLoop); -} - -void CharsSaveAll(Common::OutSaveFile *fp); -void CharsLoadAll(Common::InSaveFile *fp); -void MCharResetCodes(void); -void SaveChangedHotspot(Common::OutSaveFile *f); -void LoadChangedHotspot(Common::InSaveFile *f); -void ReapplyChangedHotspot(void); - -void RestoreMusic(void); -void SaveMusic(Common::OutSaveFile *f); -void LoadMusic(Common::InSaveFile *f); - -unsigned char wrkmem[LZO1X_999_MEM_COMPRESS]; - -void RMGfxEngine::SaveState(const char *fn, byte *curThumb, const char *name, bool bFastCompress) { - Common::OutSaveFile *f; - byte *state, *statecmp; - byte *thumbcmp; - uint32 thumbsizecmp, thumbsize; - uint32 size, sizecmp; - int i; - char buf[4]; - RMPoint tp = m_tony.Position(); - - // Salvataggio: variabili mpal + locazione corrente + posizione di tony + inventario - - // Per ora salviamo solo lo stato MPAL - size = mpalGetSaveStateSize(); - state = new byte[size]; - statecmp = new byte[size*2]; - mpalSaveState(state); - - thumbcmp = new byte[160*120*4]; - thumbsize = 160*120*2; - - if (bFastCompress) { - lzo1x_1_compress(state, size, statecmp, &sizecmp, wrkmem); - lzo1x_1_compress(curThumb, thumbsize, thumbcmp, &thumbsizecmp, wrkmem); - } else { - lzo1x_999_compress(state, size, statecmp, &sizecmp, wrkmem); - lzo1x_999_compress(curThumb, thumbsize, thumbcmp, &thumbsizecmp, wrkmem); - } - - buf[0] = 'R'; - buf[1] = 'M'; - buf[2] = 'S'; - buf[3] = 0x7; - - f = g_system->getSavefileManager()->openForSaving(fn); - if (f == NULL) - return; - - f->write(buf, 4); - f->writeUint32LE(thumbsizecmp); - f->write(thumbcmp, thumbsizecmp); - - // Livello di difficolt - i = mpalQueryGlobalVar("VERSIONEFACILE"); - f->writeByte(i); - - i = strlen(name); - f->writeByte(i); - f->write(name, i); - - f->writeUint32LE(m_nCurLoc); - f->writeUint32LE(tp.x); - f->writeUint32LE(tp.y); - f->writeUint32LE(size); - f->writeUint32LE(sizecmp); - - f->write(statecmp, sizecmp); - - delete [] state; - delete [] statecmp; - delete [] thumbcmp; - - // inventario - size = m_inv.GetSaveStateSize(); - state = new byte[size]; - m_inv.SaveState(state); - - f->writeUint32LE(size); - f->write(state, size); - delete[] state; - - // boxes - size = _vm->_theBoxes.GetSaveStateSize(); - state = new byte[size]; - _vm->_theBoxes.SaveState(state); - f->writeUint32LE(size); - f->write(state, size); - delete[] state; - - // New Ver5 - bool bStat; - - // Salva lo stato della pastorella e del palesati - bStat = m_tony.GetPastorella(); - f->writeByte(bStat); - bStat = m_inter.GetPalesati(); - f->writeByte(bStat); - - // Salva gli mchar - CharsSaveAll(f); - - // Salva le opzioni - f->writeByte(bCfgInvLocked); - f->writeByte(bCfgInvNoScroll); - f->writeByte(bCfgTimerizedText); - f->writeByte(bCfgInvUp); - f->writeByte(bCfgAnni30); - f->writeByte(bCfgAntiAlias); - f->writeByte(bCfgSottotitoli); - f->writeByte(bCfgTransparence); - f->writeByte(bCfgInterTips); - f->writeByte(bCfgDubbing); - f->writeByte(bCfgMusic); - f->writeByte(bCfgSFX); - f->writeByte(nCfgTonySpeed); - f->writeByte(nCfgTextSpeed); - f->writeByte(nCfgDubbingVolume); - f->writeByte(nCfgMusicVolume); - f->writeByte(nCfgSFXVolume); - - // Salva gli hotspot - SaveChangedHotspot(f); - - // Salva la musica - SaveMusic(f); - - f->finalize(); - delete f; -} - -void RMGfxEngine::LoadState(const char *fn) { - // PROBLEMA: Bisognerebbe caricare la locazione in un thread a parte per fare la OnEnter ... - Common::InSaveFile *f; - byte *state, *statecmp; - uint32 size, sizecmp; - char buf[4]; - RMPoint tp; - int loc; - int ver; - int i; - - f = g_system->getSavefileManager()->openForLoading(fn); - if (f == NULL) - return; - - f->read(buf, 4); - if (buf[0] != 'R' || buf[1] != 'M' || buf[2] != 'S') { - delete f; - return; - } - - ver = buf[3]; - - if (ver != 0x1 && ver != 0x2 && ver != 0x3 && ver != 0x4 && ver != 0x5 && ver != 0x6 && ver != 0x7) { - delete f; - return; - } - - if (ver >= 0x3) { - // C' il thumbnail. Se ver >= 5, compresso - if (ver >= 0x5) { - i = 0; - i = f->readUint32LE(); - f->seek(i, SEEK_CUR); - } else - f->seek(160 * 120 * 2, SEEK_CUR); - } - - if (ver >= 0x5) { - // Skip del livello di difficolt - f->seek(1, SEEK_CUR); - } - - if (ver >= 0x4) { // Skippa il nome, che non serve a nessuno - i = f->readByte(); - f->seek(i, SEEK_CUR); - } - - loc = f->readUint32LE(); - tp.x = f->readUint32LE(); - tp.y = f->readUint32LE(); - size = f->readUint32LE(); - - if (ver >= 0x5) { - // Stato MPAL compresso! - sizecmp = f->readUint32LE(); - state = new byte[size]; - statecmp = new byte[sizecmp]; - f->read(statecmp, sizecmp); - lzo1x_decompress(statecmp, sizecmp, state, &size); - - delete[] statecmp; - } else { - state = new byte[size]; - f->read(state, size); - } - - mpalLoadState(state); - delete[] state; - - - // inventario - size = f->readUint32LE(); - state = new byte[size]; - f->read(state, size); - - m_inv.LoadState(state); - delete[] state; - - if (ver >= 0x2) { // Versione 2: box please - size = f->readUint32LE(); - state = new byte[size]; - f->read(state, size); - _vm->_theBoxes.LoadState(state); - delete[] state; - } - - if (ver >= 5) { - // Versione 5: - bool bStat = false; - - bStat = f->readByte(); - m_tony.SetPastorella(bStat); - bStat = f->readByte(); - m_inter.SetPalesati(bStat); - - CharsLoadAll(f); - } - - if (ver >= 6) { - // Carica le opzioni - bCfgInvLocked = f->readByte(); - bCfgInvNoScroll = f->readByte(); - bCfgTimerizedText = f->readByte(); - bCfgInvUp = f->readByte(); - bCfgAnni30 = f->readByte(); - bCfgAntiAlias = f->readByte(); - bCfgSottotitoli = f->readByte(); - bCfgTransparence = f->readByte(); - bCfgInterTips = f->readByte(); - bCfgDubbing = f->readByte(); - bCfgMusic = f->readByte(); - bCfgSFX = f->readByte(); - nCfgTonySpeed = f->readByte(); - nCfgTextSpeed = f->readByte(); - nCfgDubbingVolume = f->readByte(); - nCfgMusicVolume = f->readByte(); - nCfgSFXVolume = f->readByte(); - - // Carica gli hotspot - LoadChangedHotspot(f); - } - - if (ver >= 7) { - LoadMusic(f); - } - - delete f; - - UnloadLocation(false); - LoadLocation(loc, tp, RMPoint(-1, -1)); - m_tony.SetPattern(RMTony::PAT_STANDRIGHT); - MainUnfreeze(); - - // Le versioni vecchie necessitano di On enter - if (ver < 5) - mpalQueryDoAction(0, loc, 0); - else { - // In quelle nuove, ci basta resettare gli mcode - MCharResetCodes(); - } - - if (ver >= 6) - ReapplyChangedHotspot(); - - RestoreMusic(); - - m_bGUIInterface = true; - m_bGUIInventory = true; - m_bGUIOption = true; -} - -void RMGfxEngine::PauseSound(bool bPause) { - if (m_bLocationLoaded) - m_loc.PauseSound(bPause); -} - -void RMGfxEngine::InitWipe(int type) { - m_bWiping = true; - m_nWipeType=type; - m_nWipeStep=0; - - if (m_nWipeType==1) - m_rcWipeEllipse = Common::Rect(80, 0, 640 - 80, 480); - else if (m_nWipeType == 2) - m_rcWipeEllipse = Common::Rect(320 - FSTEP, 240 - FSTEP, 320 + FSTEP, 240 + FSTEP); -} - -void RMGfxEngine::CloseWipe(void) { - m_bWiping = false; -} - -void RMGfxEngine::WaitWipeEnd(void) { - WaitForSingleObject(m_hWipeEvent, INFINITE); -} - } // End of namespace Tony diff --git a/engines/tony/module.mk b/engines/tony/module.mk index 7c2c7928a8..cbd44d467e 100644 --- a/engines/tony/module.mk +++ b/engines/tony/module.mk @@ -10,6 +10,7 @@ MODULE_OBJS := \ loc.o \ sound.o \ tony.o \ + tonychar.o \ utils.o \ mpal/expr.o \ mpal/loadmpc.o \ diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index edad3690e9..ea555972d0 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -251,4 +251,98 @@ void TonyEngine::GrabThumbnail(void) { warning("TODO: TonyEngine::GrabThumbnail"); } +void TonyEngine::Play(void) { + warning("TODO TonyEngine::Play"); + +#if 0 + MSG msg; + + do { + // Se siamo in pausa, entra nel loop appropriato + if (m_bPaused) + PauseLoop(); + + // Redraw del graphic engine + theEngine.DoFrame(m_bDrawLocation); + + // Avverte che finito un frame + PulseEvent(m_hEndOfFrame); + + // Passa il buffer dall'engine alla finestra + if (!m_bPaused) { + if (!theEngine.m_bWiping) + m_wnd.GetNewFrame(theEngine, NULL); + else + m_wnd.GetNewFrame(theEngine, &theEngine.m_rcWipeEllipse); + } + + // Loop minchia dei messaggi + if (PeekMessage(&msg, m_wnd, 0, 0, true)) { + if (!TranslateAccelerator(m_wnd, m_hacc, &msg)) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + } + } while (msg.message != WM_QUIT && !m_bQuitNow); +#endif +} + + + +void TonyEngine::Close(void) { + CloseMusic(); + CloseHandle(m_hEndOfFrame); + _theBoxes.Close(); + _theEngine.Close(); + m_wnd.Close(); +} + +void TonyEngine::SwitchFullscreen(bool bFull) { + m_wnd.SwitchFullscreen(bFull); + _theEngine.SwitchFullscreen(bFull); +} + +void TonyEngine::GDIControl(bool bCon) { + _theEngine.GDIControl(bCon); +} + + +void TonyEngine::PauseLoop(void) { + warning("TODO: TonyEngine::PauseLoop"); + +#if 0 + MSG msg; + int st,et; + + st = timeGetTime(); + + while (m_bPaused && GetMessage(&msg,m_wnd,0,0)) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + + et = timeGetTime(); + + m_startTime += et - st; +#endif +} + +void TonyEngine::Pause(bool bPause) { + // Se non e' cambiato lo stato di pausing, non fare nulla + if (m_bPaused == bPause) + return; + +warning("TODO: TonyEninge::Pause"); +/* + m_bPaused = bPause; + theEngine.GDIControl(m_bPaused); + + if (m_bPaused) { + SetWindowText(m_wnd, "Tony Tough and the night of Roasted Moths - PAUSED"); + } else { + SetWindowText(m_wnd, "Tony Tough and the night of Roasted Moths"); + } +*/ +} + } // End of namespace Tony diff --git a/engines/tony/tony.h b/engines/tony/tony.h index f3b840faf5..dd7e558820 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -126,6 +126,15 @@ public: RMGfxEngine *GetEngine() { return &_theEngine; } void GUIError(const Common::String &msg); + // Avverte che siamo guidati dal GDI + void GDIControl(bool bCon); + + // Loop che gestisce i messaggi quando siamo in pausa + void PauseLoop(void); + + // Carica un modulo e le sue funzioni custom + void InitCustomDll(LPCUSTOMFUNCTION *FuncList); + void Play(); void Close(); void Abort(); diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp new file mode 100644 index 0000000000..493f10ef29 --- /dev/null +++ b/engines/tony/tonychar.cpp @@ -0,0 +1,1813 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ +/************************************************************************** + * 様様様様様様様様様様様様様様様様様 * + * Nayma Software srl * + * e -= We create much MORE than ALL =- * + * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * + * .d" d$$$$$b "b. * + * .z$* d$$$$$$$L ^*$c. * + * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * + * ^*$b 4$$$$$$$$$F .d$*" * + * ^$$. 4$$$$$$$$$F .$P" Module: TonyChar.CPP......... * + * *$. '$$$$$$$$$ 4$P 4 * + * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * + * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * + * z$" "" #$F^ "" '$c * + * z$$beu .ue=" $ "=e.. .zed$$c * + * "#$e z$*" . `. ^*Nc e$"" * + * "$$". .r" ^4. .^$$" * + * ^.@*"6L=\ebu^+C$"*b." * + * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * + * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * + * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * + * * + * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * + * * + **************************************************************************/ + +#include "tony/mpal/memory.h" +#include "tony/mpal/mpalutils.h" +#include "tony/game.h" +#include "tony/tonychar.h" +#include "tony/tony.h" + +namespace Tony { + +/****************************************************************************\ +* Metodi di RMTony +\****************************************************************************/ + +bool RMTony::m_bAction = false; + +uint32 RMTony::WaitEndOfAction(HANDLE hThread) { + WaitForSingleObject(hThread, INFINITE); + m_bAction = false; + + return 1; +} + +RMGfxSourceBuffer *RMTony::NewItemSpriteBuffer(int dimx, int dimy, bool bPreRLE) { + RMGfxSourceBuffer8RLE *spr; + + assert(m_cm == CM_256); + spr = new RMGfxSourceBuffer8RLEByteAA; + spr->SetAlphaBlendColor(1); + if (bPreRLE) + spr->SetAlreadyCompressed(); + return spr; +} + +void RMTony::Init(void) { + RMRes tony(0); + RMRes body(9999); + RMDataStream ds; + + // Apre il buffer + ds.OpenBuffer(tony); + + // Legge dallo stream l'oggetto corrente (cio Tony) + ReadFromStream(ds, true); // da OGX + + // Chiude il buffer + ds.Close(); + + // Legge il corpo di Tony + ds.OpenBuffer(body); + m_body.ReadFromStream(ds, true); // da OGX + ds.Close(); + m_body.SetPattern(0); + + // Mostra Tony di default + m_bShow=m_bShowOmbra = true; + + // Nessuna azione in attesa + m_bActionPending = false; + m_bAction = false; + + m_bPastorella = false; + m_bIsTalking = false; + m_bIsStaticTalk = false; + + m_nTimeLastStep = _vm->GetTime(); +} + + +void RMTony::Close(void) { + // Disalloca @@@ Manca la disallocazione di un item + m_ombra.Destroy(); +} + +void RMTony::DoFrame(RMGfxTargetBuffer *bigBuf, int curLoc) { + if (!m_nInList && m_bShow) + bigBuf->AddPrim(new RMGfxPrimitive(this)); + + SetSpeed(nCfgTonySpeed); + + // Esegue il movimento normale del personaggio + int time = _vm->GetTime(); + + do { + m_nTimeLastStep += (1000 / 40); + RMCharacter::DoFrame(bigBuf, curLoc); + + } while (time > m_nTimeLastStep + (1000 / 40)); + + // Controlla se siamo alla fine del percorso + if (EndOfPath() && m_bActionPending) { + // Bisogna eseguire l'azione sulla quale abbiamo clickato + m_bActionPending = false; + } + + if (m_bIsTalking || m_bIsStaticTalk) + m_body.DoFrame(bigBuf, false); +} + +void RMTony::Show(void) { + m_bShow = true; + m_bShowOmbra = true; +} + +void RMTony::Hide(bool bShowOmbra) { + m_bShow = false; + m_bShowOmbra = bShowOmbra; +} + + +void RMTony::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + // Richiama il Draw() della classe madre se tony visibile + if (m_bShow && bDrawNow) { + if (m_bCorpoDavanti) { + prim->Dst().SetEmpty(); + prim->Dst().Offset(-44, -134); + if (m_bPastorella) + prim->Dst().Offset(1, 4); + RMCharacter::Draw(bigBuf, prim); + } + + if (m_bIsTalking || m_bIsStaticTalk) { + // Offset inverso per lo scrolling + prim->Dst().SetEmpty(); + prim->Dst().Offset(-m_curScroll); + prim->Dst().Offset(m_pos); + prim->Dst().Offset(-44, -134); + prim->Dst() += m_nBodyOffset; + m_body.Draw(bigBuf, prim); + } + + if (!m_bCorpoDavanti) { + prim->Dst().SetEmpty(); + prim->Dst().Offset(-44, -134); + if (m_bPastorella) + prim->Dst().Offset(0, 3); + RMCharacter::Draw(bigBuf, prim); + } + } +} + +void RMTony::MoveAndDoAction(RMPoint dst, RMItem *item, int nAction, int nActionParm) { + // Fa il movimento normale, ma si ricorda se deve poi eseguire un azione + if (item == NULL) { + m_bActionPending = false; + m_ActionItem = NULL; + } else { + m_ActionItem = item; + m_Action = nAction; + m_ActionParm = nActionParm; + m_bActionPending = true; + } + + if (!RMCharacter::Move(dst)) { + m_bActionPending = false; + m_ActionItem = NULL; + } +} + + +void RMTony::ExecuteAction(int nAction, int nActionItem, int nParm) { + HANDLE hThread; + + if (nAction == TA_COMBINE) { + hThread = mpalQueryDoAction(TA_COMBINE, nParm, nActionItem); + + // Se fallito il combine, proviamo con il ReceiveCombine + if (hThread == INVALID_HANDLE_VALUE) { + hThread = mpalQueryDoAction(TA_RECEIVECOMBINE, nActionItem, nParm); + + // Se fallito il receive, andiamo con quelli generici + // @@@ CombineGive! + if (hThread == INVALID_HANDLE_VALUE) { + hThread = mpalQueryDoAction(TA_COMBINE, nParm, 0); + + if (hThread == INVALID_HANDLE_VALUE){ + hThread = mpalQueryDoAction(TA_RECEIVECOMBINE, nActionItem, 0); + } + } + } + } else { + // Esegue l'azione + hThread = mpalQueryDoAction(nAction, nActionItem, 0); + } + + if (hThread != INVALID_HANDLE_VALUE) { + uint32 id; + m_bAction = true; + CreateThread(NULL, 10240,(LPTHREAD_START_ROUTINE)WaitEndOfAction, (void *)hThread, 0, &id); + hActionThread = hThread; + } else if (nAction != TA_GOTO) { + uint32 id; + + if (nAction == TA_TALK) { + hThread = mpalQueryDoAction(6, 1, 0); + m_bAction = true; + CreateThread(NULL,10240,(LPTHREAD_START_ROUTINE)WaitEndOfAction, (void *)hThread,0,&id); + hActionThread=hThread; + } else if (nAction == TA_PALESATI) { + hThread = mpalQueryDoAction(7, 1, 0); + m_bAction = true; + CreateThread(NULL,10240,(LPTHREAD_START_ROUTINE)WaitEndOfAction,(void *)hThread, 0, &id); + hActionThread=hThread; + } else { + hThread = mpalQueryDoAction(5, 1, 0); + m_bAction = true; + CreateThread(NULL, 10240, (LPTHREAD_START_ROUTINE)WaitEndOfAction, (void *)hThread, 0, &id); + hActionThread = hThread; + } + } +} + + +void RMTony::StopNoAction(void) { + if (m_bAction) + WaitForSingleObject(hActionThread, INFINITE); + + m_bActionPending = false; + m_ActionItem = NULL; + Stop(); +} + +void RMTony::Stop(void) { + HANDLE hThread; + + if (m_ActionItem != NULL) { + // Richiama l'MPAL per scegliere la direzione + hThread = mpalQueryDoAction(21, m_ActionItem->MpalCode(), 0); + + if (hThread==INVALID_HANDLE_VALUE) + RMCharacter::Stop(); + else { + bNeedToStop = false; // Se facciamo la OnWhichDirection, almeno dopo non dobbiamo fare la Stop() + bMoving = false; + WaitForSingleObject(hThread, INFINITE); // @@@ Mettere un assert dopo 10 secondi + } + } else { + RMCharacter::Stop(); + } + + if (!m_bActionPending) + return; + + m_bActionPending = false; + + ExecuteAction(m_Action, m_ActionItem->MpalCode(), m_ActionParm); + + m_ActionItem=NULL; +} + + +int RMTony::GetCurPattern(void) { + int nPatt=RMCharacter::GetCurPattern(); + + if (!m_bPastorella) + return nPatt; + + switch (nPatt) { + case PAT_PAST_STANDUP: + return PAT_STANDUP; + case PAT_PAST_STANDDOWN: + return PAT_STANDDOWN; + case PAT_PAST_STANDLEFT: + return PAT_STANDLEFT; + case PAT_PAST_STANDRIGHT: + return PAT_STANDRIGHT; + + case PAT_PAST_WALKUP: + return PAT_WALKUP; + case PAT_PAST_WALKDOWN: + return PAT_WALKDOWN; + case PAT_PAST_WALKLEFT: + return PAT_WALKLEFT; + case PAT_PAST_WALKRIGHT: + return PAT_WALKRIGHT; + } + + return nPatt; +} + +void RMTony::SetPattern(int nPatt, bool bPlayP0) { + if (m_bPastorella) { + switch (nPatt) { + case PAT_STANDUP: + nPatt=PAT_PAST_STANDUP; + break; + case PAT_STANDDOWN: + nPatt=PAT_PAST_STANDDOWN; + break; + case PAT_STANDLEFT: + nPatt=PAT_PAST_STANDLEFT; + break; + case PAT_STANDRIGHT: + nPatt=PAT_PAST_STANDRIGHT; + break; + case PAT_WALKUP: + nPatt=PAT_PAST_WALKUP; + break; + case PAT_WALKDOWN: + nPatt=PAT_PAST_WALKDOWN; + break; + case PAT_WALKLEFT: + nPatt=PAT_PAST_WALKLEFT; + break; + case PAT_WALKRIGHT: + nPatt=PAT_PAST_WALKRIGHT; + break; + } + } + + RMCharacter::SetPattern(nPatt, bPlayP0); +} + + +void RMTony::Take(int nWhere, int nPart) { + if (nPart == 0) { + switch (GetCurPattern()) { + case PAT_STANDDOWN: + assert(0); // Non esiste il prende mentre sei in StandDown + break; + + case PAT_STANDUP: + switch (nWhere) { + case 0: + SetPattern(PAT_TAKEUP_UP1); + break; + case 1: + SetPattern(PAT_TAKEUP_MID1); + break; + case 2: + SetPattern(PAT_TAKEUP_DOWN1); + break; + } + break; + + case PAT_STANDRIGHT: + switch (nWhere) { + case 0: + SetPattern(PAT_TAKERIGHT_UP1); + break; + case 1: + SetPattern(PAT_TAKERIGHT_MID1); + break; + case 2: + SetPattern(PAT_TAKERIGHT_DOWN1); + break; + } + break; + + + case PAT_STANDLEFT: + switch (nWhere) { + case 0: + SetPattern(PAT_TAKELEFT_UP1); + break; + case 1: + SetPattern(PAT_TAKELEFT_MID1); + break; + case 2: + SetPattern(PAT_TAKELEFT_DOWN1); + break; + } + break; + } + } else if (nPart == 1) { + SetPattern(GetCurPattern()+1); + } else if (nPart == 2) { + switch (GetCurPattern()) { + case PAT_TAKEUP_UP2: + case PAT_TAKEUP_MID2: + case PAT_TAKEUP_DOWN2: + SetPattern(PAT_STANDUP); + break; + + case PAT_TAKELEFT_UP2: + case PAT_TAKELEFT_MID2: + case PAT_TAKELEFT_DOWN2: + SetPattern(PAT_STANDLEFT); + break; + + case PAT_TAKERIGHT_UP2: + case PAT_TAKERIGHT_MID2: + case PAT_TAKERIGHT_DOWN2: + SetPattern(PAT_STANDRIGHT); + break; + } + } +} + + +void RMTony::Put(int nWhere, int nPart) { + if (nPart == 0) { + switch (GetCurPattern()) { + case PAT_STANDDOWN: + //assert(0); // Non esiste il prende mentre sei in StandDown + break; + + case PAT_STANDUP: + switch (nWhere) { + case 0: + SetPattern(PAT_PUTUP_UP1); + break; + case 1: + SetPattern(PAT_PUTUP_MID1); + break; + case 2: + SetPattern(PAT_PUTUP_DOWN1); + break; + } + break; + + case PAT_STANDRIGHT: + switch (nWhere) { + case 0: + SetPattern(PAT_PUTRIGHT_UP1); + break; + case 1: + SetPattern(PAT_PUTRIGHT_MID1); + break; + case 2: + SetPattern(PAT_PUTRIGHT_DOWN1); + break; + } + break; + + + case PAT_STANDLEFT: + switch (nWhere) { + case 0: + SetPattern(PAT_PUTLEFT_UP1); + break; + case 1: + SetPattern(PAT_PUTLEFT_MID1); + break; + case 2: + SetPattern(PAT_PUTLEFT_DOWN1); + break; + } + break; + } + } else if (nPart == 1) { + SetPattern(GetCurPattern()+1); + } else if (nPart == 2) { + switch (GetCurPattern()) { + case PAT_PUTUP_UP2: + case PAT_PUTUP_MID2: + case PAT_PUTUP_DOWN2: + SetPattern(PAT_STANDUP); + break; + + case PAT_PUTLEFT_UP2: + case PAT_PUTLEFT_MID2: + case PAT_PUTLEFT_DOWN2: + SetPattern(PAT_STANDLEFT); + break; + + case PAT_PUTRIGHT_UP2: + case PAT_PUTRIGHT_MID2: + case PAT_PUTRIGHT_DOWN2: + SetPattern(PAT_STANDRIGHT); + break; + } + } +} + + +void RMTony::StartTalk(TALKTYPE nTalkType) { + int headStartPat = 0, bodyStartPat = 0; + int headLoopPat = 0, bodyLoopPat = 0; + + assert(!m_bIsTalking); + + m_bIsTalking = true; + m_nPatB4Talking = GetCurPattern(); + m_nTalkType = nTalkType; + + // Setta la direzione di parlata SOLO se non siamo in una static animation (perch l'ha gi fatto) + if (!m_bIsStaticTalk) { + switch (m_nPatB4Talking) { + case PAT_STANDDOWN: + m_TalkDirection=DOWN; + break; + + case PAT_TAKELEFT_UP2: + case PAT_TAKELEFT_MID2: + case PAT_TAKELEFT_DOWN2: + case PAT_SIRIALZALEFT: + case PAT_STANDLEFT: + m_TalkDirection=LEFT; + break; + + case PAT_TAKERIGHT_UP2: + case PAT_TAKERIGHT_MID2: + case PAT_TAKERIGHT_DOWN2: + case PAT_SIRIALZARIGHT: + case PAT_STANDRIGHT: + m_TalkDirection=RIGHT; + break; + + case PAT_TAKEUP_UP2: + case PAT_TAKEUP_MID2: + case PAT_TAKEUP_DOWN2: + case PAT_STANDUP: + m_TalkDirection=UP; + break; + } + + // Mette davanti il corpo di default + m_bCorpoDavanti = true; + } + + if (m_bPastorella) { + // Da pastorella, c' un solo parlato + MainFreeze(); + switch (m_TalkDirection) { + case UP: + SetPattern(PAT_PAST_TALKUP); + break; + + case DOWN: + SetPattern(PAT_PAST_TALKDOWN); + break; + + case LEFT: + SetPattern(PAT_PAST_TALKLEFT); + break; + + case RIGHT: + SetPattern(PAT_PAST_TALKRIGHT); + break; + } + MainUnfreeze(); + return; + } + + headStartPat = bodyStartPat = 0; + bodyLoopPat = 0; + + switch (nTalkType) { + case TALK_NORMAL: + m_bCorpoDavanti = false; + headStartPat = 0; + bodyStartPat = 0; + + switch (m_TalkDirection) { + case DOWN: + headLoopPat = PAT_TALK_DOWN; + bodyLoopPat = BPAT_STANDDOWN; + m_nBodyOffset.Set(4, 53); + break; + + case LEFT: + headLoopPat = PAT_TALK_LEFT; + bodyLoopPat = BPAT_STANDLEFT; + m_nBodyOffset.Set(6, 56); + break; + + case RIGHT: + headLoopPat = PAT_TALK_RIGHT; + bodyLoopPat = BPAT_STANDRIGHT; + m_nBodyOffset.Set(6, 56); + break; + + case UP: + headLoopPat = PAT_TALK_UP; + bodyLoopPat = BPAT_STANDUP; + m_nBodyOffset.Set(6, 53); + break; + } + break; + + case TALK_FIANCHI: + m_bCorpoDavanti = false; + switch (m_TalkDirection) { + case UP: + m_nBodyOffset.Set(2, 42); + headStartPat = PAT_TESTA_UP; + bodyStartPat = BPAT_FIANCHIUP_START; + headLoopPat = PAT_TALK_UP; + bodyLoopPat = BPAT_FIANCHIUP_LOOP; + break; + + case DOWN: + m_nBodyOffset.Set(2, 48); + headStartPat = PAT_TESTA_DOWN; + bodyStartPat = BPAT_FIANCHIDOWN_START; + headLoopPat = PAT_TALK_DOWN; + bodyLoopPat = BPAT_FIANCHIDOWN_LOOP; + break; + + case LEFT: + m_nBodyOffset.Set(-3, 53); + headStartPat = PAT_TESTA_LEFT; + bodyStartPat = BPAT_FIANCHILEFT_START; + headLoopPat = PAT_TALK_LEFT; + bodyLoopPat = BPAT_FIANCHILEFT_LOOP; + break; + + case RIGHT: + m_nBodyOffset.Set(2, 53); + headStartPat = PAT_TESTA_RIGHT; + bodyStartPat = BPAT_FIANCHIRIGHT_START; + headLoopPat = PAT_TALK_RIGHT; + bodyLoopPat = BPAT_FIANCHIRIGHT_LOOP; + break; + } + break; + + + case TALK_CANTA: + m_nBodyOffset.Set(-10, 25); + headStartPat = PAT_TESTA_LEFT; + bodyStartPat = BPAT_CANTALEFT_START; + headLoopPat = PAT_TALK_LEFT; + bodyLoopPat = BPAT_CANTALEFT_LOOP; + break; + + case TALK_RIDE: + m_bCorpoDavanti = false; + switch (m_TalkDirection) { + case UP: + case DOWN: + case LEFT: + m_nBodyOffset.Set(6, 56); + headStartPat = PAT_RIDELEFT_START; + bodyStartPat = BPAT_STANDLEFT; + headLoopPat = PAT_RIDELEFT_LOOP; + bodyLoopPat = BPAT_RIDELEFT; + break; + + case RIGHT: + m_nBodyOffset.Set(6, 56); + headStartPat = PAT_RIDERIGHT_START; + bodyStartPat = BPAT_STANDRIGHT; + headLoopPat = PAT_RIDERIGHT_LOOP; + bodyLoopPat = BPAT_RIDERIGHT; + break; + } + break; + + case TALK_RIDE2: + m_bCorpoDavanti = false; + switch (m_TalkDirection) { + case UP: + case DOWN: + case LEFT: + m_nBodyOffset.Set(6, 56); + headStartPat = PAT_RIDELEFT_START; + bodyStartPat = BPAT_STANDLEFT; + headLoopPat = PAT_RIDELEFT_LOOP; + break; + + case RIGHT: + m_nBodyOffset.Set(6, 56); + headStartPat = PAT_RIDERIGHT_START; + bodyStartPat = BPAT_STANDRIGHT; + headLoopPat = PAT_RIDERIGHT_LOOP; + bodyLoopPat = BPAT_RIDERIGHT; + break; + } + break; + + + case TALK_SIINDICA: + switch (m_TalkDirection) { + case UP: + case DOWN: + case LEFT: + m_nBodyOffset.Set(-4, 40); + headLoopPat = PAT_TALK_LEFT; + bodyLoopPat = BPAT_SIINDICALEFT; + break; + + case RIGHT: + m_nBodyOffset.Set(5, 40); + headLoopPat = PAT_TALK_RIGHT; + bodyLoopPat = BPAT_SIINDICARIGHT; + break; + } + break; + + case TALK_SPAVENTATO: + switch (m_TalkDirection) { + case UP: + m_nBodyOffset.Set(-4, -11); + headStartPat = PAT_TESTA_UP; + bodyStartPat = BPAT_SPAVENTOUP_START; + headLoopPat = PAT_TALK_UP; + bodyLoopPat = BPAT_SPAVENTOUP_LOOP; + break; + + case DOWN: + m_nBodyOffset.Set(-5, 45); + headStartPat = PAT_SPAVENTODOWN_START; + bodyStartPat = BPAT_SPAVENTODOWN_START; + headLoopPat = PAT_SPAVENTODOWN_LOOP; + bodyLoopPat = BPAT_SPAVENTODOWN_LOOP; + break; + + case RIGHT: + m_nBodyOffset.Set(-4, 41); + headStartPat = PAT_SPAVENTORIGHT_START; + bodyStartPat = BPAT_SPAVENTORIGHT_START; + headLoopPat = PAT_SPAVENTORIGHT_LOOP; + bodyLoopPat = BPAT_SPAVENTORIGHT_LOOP; + break; + + case LEFT: + m_nBodyOffset.Set(-10, 41); + headStartPat = PAT_SPAVENTOLEFT_START; + bodyStartPat = BPAT_SPAVENTOLEFT_START; + headLoopPat = PAT_SPAVENTOLEFT_LOOP; + bodyLoopPat = BPAT_SPAVENTOLEFT_LOOP; + break; + } + break; + + case TALK_SPAVENTATO2: + m_bCorpoDavanti = false; + switch (m_TalkDirection) { + case UP: + bodyStartPat = BPAT_STANDUP; + bodyLoopPat = BPAT_STANDUP; + m_nBodyOffset.Set(6, 53); + + headStartPat = PAT_TESTA_UP; + headLoopPat = PAT_TALK_UP; + break; + + case DOWN: + bodyStartPat = BPAT_STANDDOWN; + bodyLoopPat = BPAT_STANDDOWN; + m_nBodyOffset.Set(4, 53); + + headStartPat = PAT_SPAVENTODOWN_START; + headLoopPat = PAT_SPAVENTODOWN_LOOP; + break; + + case RIGHT: + bodyStartPat = BPAT_STANDRIGHT; + bodyLoopPat = BPAT_STANDRIGHT; + m_nBodyOffset.Set(6, 56); + + headStartPat = PAT_SPAVENTORIGHT_START; + headLoopPat = PAT_SPAVENTORIGHT_LOOP; + break; + + case LEFT: + bodyStartPat = BPAT_STANDLEFT; + bodyLoopPat = BPAT_STANDLEFT; + m_nBodyOffset.Set(6, 56); + + headStartPat = PAT_SPAVENTOLEFT_START; + headLoopPat = PAT_SPAVENTOLEFT_LOOP; + break; + } + break; + + case TALK_CONBICCHIERE: + m_nBodyOffset.Set(4, 53); + headLoopPat = PAT_TALK_DOWN; + bodyLoopPat = BPAT_BICCHIERE; + break; + case TALK_CONVERME: + m_nBodyOffset.Set(9, 56); + headLoopPat = PAT_TALK_RIGHT; + bodyLoopPat = BPAT_VERME; + break; + case TALK_CONMARTELLO: + m_nBodyOffset.Set(6, 56); + headLoopPat = PAT_TALK_LEFT; + bodyLoopPat = BPAT_MARTELLO; + break; + case TALK_CONCORDA: + m_nBodyOffset.Set(-3, 38); + headLoopPat = PAT_TALK_RIGHT; + bodyLoopPat = BPAT_CORDA; + break; + case TALK_CONSEGRETARIA: + m_nBodyOffset.Set(-17, 12); + headLoopPat = PAT_TALK_RIGHT; + bodyLoopPat = BPAT_CONSEGRETARIA; + break; + + case TALK_CONCONIGLIO: + switch (m_TalkDirection) { + case LEFT: + case UP: + m_nBodyOffset.Set(-21, -5); + bodyStartPat = BPAT_CONCONIGLIOLEFT_START; + headLoopPat = PAT_TALK_LEFT; + bodyLoopPat = BPAT_CONCONIGLIOLEFT_LOOP; + break; + + case DOWN: + case RIGHT: + m_nBodyOffset.Set(-4, -5); + bodyStartPat = BPAT_CONCONIGLIORIGHT_START; + headLoopPat = PAT_TALK_RIGHT; + bodyLoopPat = BPAT_CONCONIGLIORIGHT_LOOP; + break; + } + break; + + case TALK_CONRICETTA: + switch (m_TalkDirection) { + case LEFT: + case UP: + m_nBodyOffset.Set(-61, -7); + bodyStartPat = BPAT_CONRICETTALEFT_START; + headLoopPat = PAT_TALK_LEFT; + bodyLoopPat = BPAT_CONRICETTALEFT_LOOP; + break; + + case DOWN: + case RIGHT: + m_nBodyOffset.Set(-5, -7); + bodyStartPat = BPAT_CONRICETTARIGHT_START; + headLoopPat = PAT_TALK_RIGHT; + bodyLoopPat = BPAT_CONRICETTARIGHT_LOOP; + break; + } + break; + + case TALK_CONCARTE: + switch (m_TalkDirection) { + case LEFT: + case UP: + m_nBodyOffset.Set(-34, -2); + bodyStartPat = BPAT_CONCARTELEFT_START; + headLoopPat = PAT_TALK_LEFT; + bodyLoopPat = BPAT_CONCARTELEFT_LOOP; + break; + + case DOWN: + case RIGHT: + m_nBodyOffset.Set(-4, -2); + bodyStartPat = BPAT_CONCARTERIGHT_START; + headLoopPat = PAT_TALK_RIGHT; + bodyLoopPat = BPAT_CONCARTERIGHT_LOOP; + break; + } + break; + + case TALK_CONPUPAZZO: + switch (m_TalkDirection) { + case LEFT: + case UP: + m_nBodyOffset.Set(-35, 2); + bodyStartPat = BPAT_CONPUPAZZOLEFT_START; + headLoopPat = PAT_TALK_LEFT; + bodyLoopPat = BPAT_CONPUPAZZOLEFT_LOOP; + break; + + case DOWN: + case RIGHT: + m_nBodyOffset.Set(-14, 2); + bodyStartPat = BPAT_CONPUPAZZORIGHT_START; + headLoopPat = PAT_TALK_RIGHT; + bodyLoopPat = BPAT_CONPUPAZZORIGHT_LOOP; + break; + } + break; + + case TALK_CONPUPAZZOSTATIC: + case TALK_CONRICETTASTATIC: + case TALK_CONCONIGLIOSTATIC: + case TALK_CONCARTESTATIC: + case TALK_CONTACCUINOSTATIC: + case TALK_CONMEGAFONOSTATIC: + switch (m_TalkDirection) { + case LEFT: + case UP: + headLoopPat = PAT_TALK_LEFT; + break; + + case DOWN: + case RIGHT: + headLoopPat = PAT_TALK_RIGHT; + break; + } + break; + + // La barba l'unico caso in cui la testa animata a parte + // mentre il corpo quello standard + case TALK_CONBARBASTATIC: + switch (m_TalkDirection) { + case LEFT: + case UP: + headLoopPat = PAT_TALKBARBA_LEFT; + bodyLoopPat = BPAT_STANDLEFT; + m_nBodyOffset.Set(6, 56); + break; + + case DOWN: + case RIGHT: + headLoopPat = PAT_TALKBARBA_RIGHT; + bodyLoopPat = BPAT_STANDRIGHT; + m_nBodyOffset.Set(6, 56); + break; + } + break; + + case TALK_SCHIFATO: + switch (m_TalkDirection) { + case LEFT: + case UP: + m_nBodyOffset.Set(6, 56); + headStartPat = PAT_SCHIFATOLEFT_START; + bodyStartPat = BPAT_STANDLEFT; + headLoopPat = PAT_SCHIFATOLEFT_LOOP; + break; + + case DOWN: + case RIGHT: + m_nBodyOffset.Set(6, 56); + headStartPat = PAT_SCHIFATORIGHT_START; + bodyStartPat = BPAT_STANDRIGHT; + headLoopPat = PAT_SCHIFATORIGHT_LOOP; + break; + } + break; + + case TALK_NAAH: + switch (m_TalkDirection) { + case LEFT: + case UP: + m_nBodyOffset.Set(6, 56); + headStartPat = PAT_NAAHLEFT_START; + bodyStartPat = BPAT_STANDLEFT; + headLoopPat = PAT_NAAHLEFT_LOOP; + break; + + case DOWN: + case RIGHT: + m_nBodyOffset.Set(6, 56); + headStartPat = PAT_NAAHRIGHT_START; + bodyStartPat = BPAT_STANDRIGHT; + headLoopPat = PAT_NAAHRIGHT_LOOP; + break; + } + break; + + case TALK_MACBETH1: + m_nBodyOffset.Set(-33, -1); + headLoopPat = PAT_TALK_LEFT; + bodyLoopPat = BPAT_MACBETH1; + break; + case TALK_MACBETH2: + m_nBodyOffset.Set(-33, -1); + headLoopPat = PAT_TALK_LEFT; + bodyLoopPat = BPAT_MACBETH2; + break; + case TALK_MACBETH3: + m_nBodyOffset.Set(-33, -1); + headLoopPat = PAT_TALK_LEFT; + bodyLoopPat = BPAT_MACBETH3; + break; + case TALK_MACBETH4: + m_nBodyOffset.Set(-33, -1); + headLoopPat = PAT_TALK_LEFT; + bodyLoopPat = BPAT_MACBETH4; + break; + case TALK_MACBETH5: + m_nBodyOffset.Set(-33, -1); + headLoopPat = PAT_TALK_LEFT; + bodyLoopPat = BPAT_MACBETH5; + break; + case TALK_MACBETH6: + m_nBodyOffset.Set(-33, -1); + headLoopPat = PAT_TALK_LEFT; + bodyLoopPat = BPAT_MACBETH6; + break; + case TALK_MACBETH7: + m_nBodyOffset.Set(-33, -1); + headLoopPat = PAT_TALK_LEFT; + bodyLoopPat = BPAT_MACBETH7; + break; + case TALK_MACBETH8: + m_nBodyOffset.Set(-33, -1); + headLoopPat = PAT_TALK_LEFT; + bodyLoopPat = BPAT_MACBETH8; + break; + case TALK_MACBETH9: + m_nBodyOffset.Set(-33, -1); + headLoopPat = PAT_TALK_LEFT; + bodyLoopPat = BPAT_MACBETH9; + break; + + case TALK_SPAVENTATOSTATIC: + m_bCorpoDavanti = false; + switch (m_TalkDirection) { + case DOWN: + bodyStartPat = BPAT_STANDDOWN; + bodyLoopPat = BPAT_STANDDOWN; + m_nBodyOffset.Set(4, 53); + + headStartPat = PAT_SPAVENTODOWN_STAND; + headLoopPat = PAT_SPAVENTODOWN_LOOP; + break; + + case RIGHT: + bodyStartPat = BPAT_STANDRIGHT; + bodyLoopPat = BPAT_STANDRIGHT; + m_nBodyOffset.Set(6, 56); + + headStartPat = PAT_SPAVENTORIGHT_STAND; + headLoopPat = PAT_SPAVENTORIGHT_LOOP; + break; + + case LEFT: + bodyStartPat = BPAT_STANDLEFT; + bodyLoopPat = BPAT_STANDLEFT; + m_nBodyOffset.Set(6, 56); + + headStartPat = PAT_SPAVENTOLEFT_STAND; + headLoopPat = PAT_SPAVENTOLEFT_LOOP; + break; + } + break; + } + + // Esegue il set dei pattern vero e proprio + if (headStartPat != 0 || bodyStartPat != 0) { + MainFreeze(); + SetPattern(headStartPat); + m_body.SetPattern(bodyStartPat); + MainUnfreeze(); + + if (bodyStartPat!=0) + m_body.WaitForEndPattern(); + if (headStartPat!=0) + WaitForEndPattern(); + } + + MainFreeze(); + SetPattern(headLoopPat); + if (bodyLoopPat) + m_body.SetPattern(bodyLoopPat); + MainUnfreeze(); +} + + +void RMTony::EndTalk(void) { + int headStandPat = 0; + int headEndPat = 0; + int bodyEndPat = 0; + int finalPat = 0; + bool bStatic = false; + + bodyEndPat = 0; + headEndPat = 0; + + switch (m_TalkDirection) { + case UP: + finalPat = PAT_STANDUP; + headStandPat = PAT_TESTA_UP; + break; + + case DOWN: + finalPat = PAT_STANDDOWN; + headStandPat = PAT_TESTA_DOWN; + break; + + case LEFT: + finalPat = PAT_STANDLEFT; + headStandPat = PAT_TESTA_LEFT; + break; + + case RIGHT: + finalPat = PAT_STANDRIGHT; + headStandPat = PAT_TESTA_RIGHT; + break; + } + + if (m_bPastorella) { + MainFreeze(); + SetPattern(finalPat); + MainUnfreeze(); + m_bIsTalking = false; + return; + } + + + bStatic = false; + switch (m_nTalkType) { + case TALK_NORMAL: + bodyEndPat = 0; + break; + + case TALK_FIANCHI: + switch (m_TalkDirection) { + case UP: + bodyEndPat = BPAT_FIANCHIUP_END; + break; + + case DOWN: + bodyEndPat = BPAT_FIANCHIDOWN_END; + break; + + case LEFT: + bodyEndPat = BPAT_FIANCHILEFT_END; + break; + + case RIGHT: + bodyEndPat = BPAT_FIANCHIRIGHT_END; + break; + } + break; + + case TALK_CANTA: + bodyEndPat = BPAT_CANTALEFT_END; + break; + + case TALK_RIDE: + case TALK_RIDE2: + if (m_TalkDirection==LEFT) + headEndPat = PAT_RIDELEFT_END; + else if (m_TalkDirection==RIGHT) + headEndPat = PAT_RIDERIGHT_END; + + bodyEndPat = 0; + break; + + case TALK_SCHIFATO: + switch (m_TalkDirection) { + case UP: + case LEFT: + headEndPat = PAT_SCHIFATOLEFT_END; + break; + + case DOWN: + case RIGHT: + headEndPat = PAT_SCHIFATORIGHT_END; + break; + } + + bodyEndPat = 0; + break; + + case TALK_NAAH: + switch (m_TalkDirection) { + case UP: + case LEFT: + headEndPat = PAT_NAAHLEFT_END; + break; + + case DOWN: + case RIGHT: + headEndPat = PAT_NAAHRIGHT_END; + break; + } + + bodyEndPat = 0; + break; + + case TALK_SIINDICA: + break; + + case TALK_SPAVENTATO: + switch (m_TalkDirection) { + case UP: + bodyEndPat = BPAT_SPAVENTOUP_END; + break; + + case DOWN: + headEndPat = PAT_SPAVENTODOWN_END; + bodyEndPat = BPAT_SPAVENTODOWN_END; + break; + + case RIGHT: + headEndPat = PAT_SPAVENTORIGHT_END; + bodyEndPat = BPAT_SPAVENTORIGHT_END; + break; + + case LEFT: + headEndPat = PAT_SPAVENTOLEFT_END; + bodyEndPat = BPAT_SPAVENTOLEFT_END; + break; + } + break; + + case TALK_SPAVENTATO2: + switch (m_TalkDirection) { + case UP: + bodyEndPat = 0; + break; + + case DOWN: + headEndPat = PAT_SPAVENTODOWN_END; + bodyEndPat = 0; + break; + + case RIGHT: + headEndPat = PAT_SPAVENTORIGHT_END; + bodyEndPat = 0; + break; + + case LEFT: + headEndPat = PAT_SPAVENTOLEFT_END; + bodyEndPat = 0; + break; + } + break; + + case TALK_CONCONIGLIO: + switch (m_TalkDirection) { + case UP: + case LEFT: + finalPat = PAT_STANDLEFT; + bodyEndPat = BPAT_CONCONIGLIOLEFT_END; + break; + + case RIGHT: + case DOWN: + finalPat = PAT_STANDRIGHT; + bodyEndPat = BPAT_CONCONIGLIORIGHT_END; + break; + } + break; + + case TALK_CONRICETTA: + switch (m_TalkDirection) { + case UP: + case LEFT: + finalPat = PAT_STANDLEFT; + bodyEndPat = BPAT_CONRICETTALEFT_END; + break; + + case RIGHT: + case DOWN: + finalPat = PAT_STANDRIGHT; + bodyEndPat = BPAT_CONRICETTARIGHT_END; + break; + } + break; + + case TALK_CONCARTE: + switch (m_TalkDirection) { + case UP: + case LEFT: + finalPat = PAT_STANDLEFT; + bodyEndPat = BPAT_CONCARTELEFT_END; + break; + + case RIGHT: + case DOWN: + finalPat = PAT_STANDRIGHT; + bodyEndPat = BPAT_CONCARTERIGHT_END; + break; + } + break; + + case TALK_CONPUPAZZO: + switch (m_TalkDirection) { + case UP: + case LEFT: + finalPat = PAT_STANDLEFT; + bodyEndPat = BPAT_CONPUPAZZOLEFT_END; + break; + + case RIGHT: + case DOWN: + finalPat = PAT_STANDRIGHT; + bodyEndPat = BPAT_CONPUPAZZORIGHT_END; + break; + } + break; + + case TALK_CONVERME: + finalPat = PAT_CONVERME; + break; + case TALK_CONCORDA: + finalPat = PAT_CONCORDA; + break; + case TALK_CONSEGRETARIA: + finalPat = PAT_CONSEGRETARIA; + break; + case TALK_CONMARTELLO: + finalPat = PAT_CONMARTELLO; + break; + case TALK_CONBICCHIERE: + finalPat = PAT_CONBICCHIERE; + break; + + case TALK_MACBETH1: + case TALK_MACBETH2: + case TALK_MACBETH3: + case TALK_MACBETH4: + case TALK_MACBETH5: + case TALK_MACBETH6: + case TALK_MACBETH7: + case TALK_MACBETH8: + finalPat = 0; + break; + + case TALK_SPAVENTATOSTATIC: + switch (m_TalkDirection) { + case DOWN: + headStandPat = PAT_SPAVENTODOWN_STAND; + bodyEndPat = 0; + break; + + case RIGHT: + headStandPat = PAT_SPAVENTORIGHT_STAND; + bodyEndPat = 0; + break; + + case LEFT: + headStandPat = PAT_SPAVENTOLEFT_STAND; + bodyEndPat = 0; + break; + } + break; + } + + // Gestisce la fine di una animazione static lasciando tutto invariato + if (m_bIsStaticTalk) { + if (m_nTalkType == TALK_CONBARBASTATIC) { + MainFreeze(); + SetPattern(0); + if (m_TalkDirection == UP || m_TalkDirection == LEFT) { + m_body.SetPattern(BPAT_CONBARBALEFT_STATIC); + m_nBodyOffset.Set(-41, -14); + } else if (m_TalkDirection == DOWN || m_TalkDirection == RIGHT) { + m_body.SetPattern(BPAT_CONBARBARIGHT_STATIC); + m_nBodyOffset.Set(-26, -14); + } + MainUnfreeze(); + } else { + MainFreeze(); + SetPattern(headStandPat); + MainUnfreeze(); + + m_body.WaitForEndPattern(); + } + + m_bIsTalking = false; + return; + } + + // Set dei pattern + if (headEndPat != 0 && bodyEndPat != 0) { + MainFreeze(); + SetPattern(headEndPat); + MainUnfreeze(); + + m_body.WaitForEndPattern(); + + MainFreeze(); + m_body.SetPattern(bodyEndPat); + MainUnfreeze(); + + WaitForEndPattern(); + m_body.WaitForEndPattern(); + } else if (bodyEndPat != 0) { + MainFreeze(); + SetPattern(headStandPat); + MainUnfreeze(); + + m_body.WaitForEndPattern(); + + MainFreeze(); + m_body.SetPattern(bodyEndPat); + MainUnfreeze(); + + m_body.WaitForEndPattern(); + } else if (headEndPat != 0) { + m_body.WaitForEndPattern(); + + MainFreeze(); + SetPattern(headEndPat); + MainUnfreeze(); + + WaitForEndPattern(); + } else { + m_body.WaitForEndPattern(); + } + + if (finalPat != 0) { + MainFreeze(); + m_body.SetPattern(0); + SetPattern(finalPat); + MainUnfreeze(); + } + + m_bIsTalking = false; +} + +void RMTony::StartStatic(TALKTYPE nTalk) { + int nPat = 0; + int headPat = 0, headLoopPat = 0; + int bodyStartPat = 0; + int bodyLoopPat = 0; + + nPat = GetCurPattern(); + + headLoopPat = -1; + + switch (nPat) { + case PAT_STANDDOWN: + m_TalkDirection=DOWN; + headPat = PAT_TESTA_RIGHT; + break; + + case PAT_TAKELEFT_UP2: + case PAT_TAKELEFT_MID2: + case PAT_TAKELEFT_DOWN2: + case PAT_SIRIALZALEFT: + case PAT_STANDLEFT: + m_TalkDirection=LEFT; + headPat = PAT_TESTA_LEFT; + break; + + case PAT_TAKERIGHT_UP2: + case PAT_TAKERIGHT_MID2: + case PAT_TAKERIGHT_DOWN2: + case PAT_SIRIALZARIGHT: + case PAT_STANDRIGHT: + m_TalkDirection=RIGHT; + headPat = PAT_TESTA_RIGHT; + break; + + case PAT_TAKEUP_UP2: + case PAT_TAKEUP_MID2: + case PAT_TAKEUP_DOWN2: + case PAT_STANDUP: + m_TalkDirection=UP; + headPat = PAT_TESTA_LEFT; + break; + } + + m_bCorpoDavanti = true; + + switch (nTalk) { + case TALK_CONCONIGLIOSTATIC: + switch (m_TalkDirection) { + case UP: + case LEFT: + m_nBodyOffset.Set(-21, -5); + bodyStartPat = BPAT_CONCONIGLIOLEFT_START; + bodyLoopPat = BPAT_CONCONIGLIOLEFT_LOOP; + break; + + case DOWN: + case RIGHT: + m_nBodyOffset.Set(-4, -5); + bodyStartPat = BPAT_CONCONIGLIORIGHT_START; + bodyLoopPat = BPAT_CONCONIGLIORIGHT_LOOP; + break; + } + break; + + case TALK_CONCARTESTATIC: + switch (m_TalkDirection) { + case UP: + case LEFT: + m_nBodyOffset.Set(-34, -2); + bodyStartPat = BPAT_CONCARTELEFT_START; + bodyLoopPat = BPAT_CONCARTELEFT_LOOP; + break; + + case DOWN: + case RIGHT: + m_nBodyOffset.Set(-4, -2); + bodyStartPat = BPAT_CONCARTERIGHT_START; + bodyLoopPat = BPAT_CONCARTERIGHT_LOOP; + break; + } + break; + + case TALK_CONRICETTASTATIC: + switch (m_TalkDirection) { + case UP: + case LEFT: + m_nBodyOffset.Set(-61, -7); + bodyStartPat = BPAT_CONRICETTALEFT_START; + bodyLoopPat = BPAT_CONRICETTALEFT_LOOP; + break; + + case DOWN: + case RIGHT: + m_nBodyOffset.Set(-5, -7); + bodyStartPat = BPAT_CONRICETTARIGHT_START; + bodyLoopPat = BPAT_CONRICETTARIGHT_LOOP; + break; + } + break; + + case TALK_CONPUPAZZOSTATIC: + switch (m_TalkDirection) { + case UP: + case LEFT: + m_nBodyOffset.Set(-35, 2); + bodyStartPat = BPAT_CONPUPAZZOLEFT_START; + bodyLoopPat = BPAT_CONPUPAZZOLEFT_LOOP; + break; + + case DOWN: + case RIGHT: + m_nBodyOffset.Set(-14, 2); + bodyStartPat = BPAT_CONPUPAZZORIGHT_START; + bodyLoopPat = BPAT_CONPUPAZZORIGHT_LOOP; + break; + } + break; + + case TALK_CONTACCUINOSTATIC: + switch (m_TalkDirection) { + case UP: + case LEFT: + m_nBodyOffset.Set(-16, -9); + bodyStartPat = BPAT_CONTACCUINOLEFT_START; + bodyLoopPat = BPAT_CONTACCUINOLEFT_LOOP; + break; + + case DOWN: + case RIGHT: + m_nBodyOffset.Set(-6, -9); + bodyStartPat = BPAT_CONTACCUINORIGHT_START; + bodyLoopPat = BPAT_CONTACCUINORIGHT_LOOP; + break; + } + break; + + case TALK_CONMEGAFONOSTATIC: + switch (m_TalkDirection) { + case UP: + case LEFT: + m_nBodyOffset.Set(-41, -8); + bodyStartPat = BPAT_CONMEGAFONOLEFT_START; + bodyLoopPat = BPAT_CONMEGAFONOLEFT_LOOP; + break; + + case DOWN: + case RIGHT: + m_nBodyOffset.Set(-14, -8); + bodyStartPat = BPAT_CONMEGAFONORIGHT_START; + bodyLoopPat = BPAT_CONMEGAFONORIGHT_LOOP; + break; + } + break; + + case TALK_CONBARBASTATIC: + switch (m_TalkDirection) { + case UP: + case LEFT: + m_nBodyOffset.Set(-41, -14); + bodyStartPat = BPAT_CONBARBALEFT_START; + bodyLoopPat = BPAT_STANDLEFT; + headLoopPat = PAT_TALKBARBA_LEFT; + headPat = 0; + break; + + case DOWN: + case RIGHT: + m_nBodyOffset.Set(-26, -14); + bodyStartPat = BPAT_CONBARBARIGHT_START; + bodyLoopPat = BPAT_STANDRIGHT; + headLoopPat = PAT_TALKBARBA_RIGHT; + headPat = 0; + break; + } + break; + + case TALK_SPAVENTATOSTATIC: + switch (m_TalkDirection) { + case DOWN: + headPat = PAT_SPAVENTODOWN_START; + bodyLoopPat = BPAT_STANDDOWN; + bodyStartPat = BPAT_STANDDOWN; + headLoopPat = PAT_SPAVENTODOWN_STAND; + m_nBodyOffset.Set(4, 53); + break; + + case LEFT: + headPat = PAT_SPAVENTOLEFT_START; + bodyLoopPat = BPAT_STANDLEFT; + bodyStartPat = BPAT_STANDLEFT; + headLoopPat = PAT_SPAVENTOLEFT_STAND; + m_nBodyOffset.Set(6, 56); + break; + + case RIGHT: + headPat = PAT_SPAVENTORIGHT_START; + bodyLoopPat = BPAT_STANDRIGHT; + bodyStartPat = BPAT_STANDRIGHT; + headLoopPat = PAT_SPAVENTORIGHT_STAND; + m_nBodyOffset.Set(6, 56); + break; + } + } + + // e vai con i pattern + m_bIsStaticTalk = true; + + MainFreeze(); + SetPattern(headPat); + m_body.SetPattern(bodyStartPat); + MainUnfreeze(); + + m_body.WaitForEndPattern(); + WaitForEndPattern(); + + MainFreeze(); + if (headLoopPat != -1) + SetPattern(headLoopPat); + m_body.SetPattern(bodyLoopPat); + MainUnfreeze(); +} + + +void RMTony::EndStatic(TALKTYPE nTalk) { + int bodyEndPat = 0; + int finalPat = 0; + int headEndPat = 0; + + switch (m_TalkDirection) { + case UP: + case LEFT: + finalPat = PAT_STANDLEFT; + break; + + case RIGHT: + case DOWN: + finalPat = PAT_STANDRIGHT; + break; + } + + switch (nTalk) { + case TALK_CONPUPAZZOSTATIC: + switch (m_TalkDirection) { + case UP: case LEFT: + bodyEndPat = BPAT_CONPUPAZZOLEFT_END; + break; + + case DOWN: + case RIGHT: + bodyEndPat = BPAT_CONPUPAZZORIGHT_END; + break; + } + break; + + case TALK_CONRICETTASTATIC: + switch (m_TalkDirection) { + case UP: + case LEFT: + bodyEndPat = BPAT_CONRICETTALEFT_END; + break; + + case DOWN: + case RIGHT: + bodyEndPat = BPAT_CONRICETTARIGHT_END; + break; + } + break; + + case TALK_CONCONIGLIOSTATIC: + switch (m_TalkDirection) { + case UP: + case LEFT: + bodyEndPat = BPAT_CONCONIGLIOLEFT_END; + break; + + case DOWN: + case RIGHT: + bodyEndPat = BPAT_CONCONIGLIORIGHT_END; + break; + } + break; + + case TALK_CONCARTESTATIC: + switch (m_TalkDirection) { + case UP: + case LEFT: + bodyEndPat = BPAT_CONCARTELEFT_END; + break; + + case DOWN: + case RIGHT: + bodyEndPat = BPAT_CONCARTERIGHT_END; + break; + } + break; + + case TALK_CONTACCUINOSTATIC: + switch (m_TalkDirection) { + case UP: + case LEFT: + bodyEndPat = BPAT_CONTACCUINOLEFT_END; + break; + + case DOWN: + case RIGHT: + bodyEndPat = BPAT_CONTACCUINORIGHT_END; + break; + } + break; + + case TALK_CONMEGAFONOSTATIC: + switch (m_TalkDirection) { + case UP: + case LEFT: + bodyEndPat = BPAT_CONMEGAFONOLEFT_END; + break; + + case DOWN: + case RIGHT: + bodyEndPat = BPAT_CONMEGAFONORIGHT_END; + break; + } + break; + + case TALK_CONBARBASTATIC: + switch (m_TalkDirection) { + case UP: + case LEFT: + bodyEndPat = BPAT_CONBARBALEFT_END; + break; + + case DOWN: + case RIGHT: + bodyEndPat = BPAT_CONBARBARIGHT_END; + break; + } + break; + + case TALK_SPAVENTATOSTATIC: + switch (m_TalkDirection) { + case LEFT: + headEndPat = PAT_SPAVENTOLEFT_END; + break; + + case DOWN: + headEndPat = PAT_SPAVENTODOWN_END; + break; + + case RIGHT: + headEndPat = PAT_SPAVENTORIGHT_END; + break; + } + break; + } + + if (headEndPat != 0) { + MainFreeze(); + SetPattern(headEndPat); + MainUnfreeze(); + + WaitForEndPattern(); + } else { + // Play please + MainFreeze(); + m_body.SetPattern(bodyEndPat); + MainUnfreeze(); + + m_body.WaitForEndPattern(); + } + + MainFreeze(); + SetPattern(finalPat); + m_body.SetPattern(0); + MainUnfreeze(); + + m_bIsStaticTalk = false; +} + +} // End of namespace Tony -- cgit v1.2.3 From bc2b9449869088be4f6c55ff03ccfa9a267a8c6a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 2 May 2012 00:23:41 +1000 Subject: TONY: Added code from Inventory.cpp --- engines/tony/font.h | 12 +- engines/tony/gfxcore.h | 28 +- engines/tony/inventory.cpp | 943 +++++++++++++++++++++++++++++++++++++++++++++ engines/tony/inventory.h | 5 +- engines/tony/module.mk | 1 + engines/tony/utils.cpp | 8 +- engines/tony/utils.h | 8 +- 7 files changed, 976 insertions(+), 29 deletions(-) create mode 100644 engines/tony/inventory.cpp (limited to 'engines') diff --git a/engines/tony/font.h b/engines/tony/font.h index 57a8b1c4fb..a8a9aabb19 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -54,9 +54,12 @@ namespace Tony { +class RMInput; class RMInventory; -class RMLoc; class RMItem; +class RMLoc; +class RMLocation; +class RMPointer; /** * Gestisce un font, in cui ha varie surface per ogni lettera @@ -237,8 +240,7 @@ public: /** * Gestisce il testo di un dialogo */ -class RMTextDialog : public RMText -{ +class RMTextDialog : public RMText { protected: int m_startTime; int m_time; @@ -250,7 +252,7 @@ class RMTextDialog : public RMText bool m_bForceNoTime; HANDLE hCustomSkip; HANDLE hCustomSkip2; - RMInput* m_input; + RMInput *m_input; bool m_bAlwaysDisplay; bool m_bNoTab; @@ -296,7 +298,7 @@ class RMTextDialog : public RMText class RMTextDialogScrolling : public RMTextDialog { protected: - RMLocation* curLoc; + RMLocation *curLoc; RMPoint startScroll; virtual void ClipOnScreen(RMGfxPrimitive* prim); diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index f5553d21c6..2e4f9830ed 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -127,37 +127,37 @@ public: m_task = task; m_bFlag = 0; } - RMGfxPrimitive(RMGfxTask *task, RMRect &src, RMRect &dst) { + RMGfxPrimitive(RMGfxTask *task, const RMRect &src, RMRect &dst) { m_task = task; m_src = src; m_dst = dst; m_bFlag = 0; m_bStretch = (src.Width() != dst.Width() || src.Height() != dst.Height()); } - RMGfxPrimitive(RMGfxTask *task, RMPoint &src, RMRect &dst) { + RMGfxPrimitive(RMGfxTask *task, const RMPoint &src, RMRect &dst) { m_task = task; m_src.TopLeft() = src; m_dst = dst; m_bFlag = 0; } - RMGfxPrimitive(RMGfxTask *task, RMPoint &src, RMPoint &dst) { + RMGfxPrimitive(RMGfxTask *task, const RMPoint &src, RMPoint &dst) { m_task = task; m_src.TopLeft() = src; m_dst.TopLeft() = dst; m_bFlag = 0; } - RMGfxPrimitive(RMGfxTask *task, RMRect &src, RMPoint &dst) { + RMGfxPrimitive(RMGfxTask *task, const RMRect &src, RMPoint &dst) { m_task = task; m_src = src; m_dst.TopLeft() = dst; m_bFlag = 0; } - RMGfxPrimitive(RMGfxTask *task, RMRect &dst) { + RMGfxPrimitive(RMGfxTask *task, const RMRect &dst) { m_task = task; m_dst = dst; m_src.SetEmpty(); m_bFlag = 0; } - RMGfxPrimitive(RMGfxTask *task, RMPoint &dst) { + RMGfxPrimitive(RMGfxTask *task, const RMPoint &dst) { m_task = task; m_dst.TopLeft() = dst; m_src.SetEmpty(); m_bFlag = 0; } void SetFlag(byte bFlag) { m_bFlag=bFlag; } void SetTask(RMGfxTask *task) { m_task = task; } - void SetSrc(RMRect &src) { m_src = src; } - void SetSrc(RMPoint &src) { m_src.TopLeft() = src; } - void SetDst(RMRect &dst) { m_dst = dst; } - void SetDst(RMPoint &dst) { m_dst.TopLeft() = dst; } + void SetSrc(const RMRect &src) { m_src = src; } + void SetSrc(const RMPoint &src) { m_src.TopLeft() = src; } + void SetDst(const RMRect &dst) { m_dst = dst; } + void SetDst(const RMPoint &dst) { m_dst.TopLeft() = dst; } void SetStrecth(bool bStretch) { m_bStretch = bStretch; } bool HaveDst() { return !m_dst.IsEmpty(); } @@ -292,7 +292,7 @@ public: virtual void Init(RMDataStream& ds, int dimx, int dimy, bool bLoadPalette = false); int LoadPaletteWA(uint32 resID, bool bSwapped = false); - int LoadPaletteWA(byte *buf, bool bSwapped = false); + int LoadPaletteWA(const byte *buf, bool bSwapped = false); int LoadPalette(uint32 resID); int LoadPalette(byte *buf); }; @@ -365,7 +365,7 @@ public: // Overload of the initialization method virtual void Init(RMDataStream& ds, int dimx, int dimy, bool bLoadPalette = false); - virtual int Init(byte *buf, int dimx, int dimy, bool bLoadPalette = false); + virtual int Init(const byte *buf, int dimx, int dimy, bool bLoadPalette = false); // Draw image with RLE decompression void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); @@ -447,8 +447,8 @@ public: void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); // Overloaded initialisation methods - virtual void Init(RMDataStream& ds, int dimx, int dimy, bool bLoadPalette = false); - virtual int Init(byte *buf, int dimx, int dimy, bool bLoadPalette = false); + virtual void Init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette = false); + virtual int Init(const byte *buf, int dimx, int dimy, bool bLoadPalette = false); virtual ~RMGfxSourceBuffer8RLEByteAA(); }; diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp new file mode 100644 index 0000000000..2ce88b1cec --- /dev/null +++ b/engines/tony/inventory.cpp @@ -0,0 +1,943 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ +/************************************************************************** + * 様様様様様様様様様様様様様様様様様 * + * Nayma Software srl * + * e -= We create much MORE than ALL =- * + * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * + * .d" d$$$$$b "b. * + * .z$* d$$$$$$$L ^*$c. * + * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * + * ^*$b 4$$$$$$$$$F .d$*" * + * ^$$. 4$$$$$$$$$F .$P" Module: Inventory.CPP........ * + * *$. '$$$$$$$$$ 4$P 4 * + * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * + * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * + * z$" "" #$F^ "" '$c * + * z$$beu .ue=" $ "=e.. .zed$$c * + * "#$e z$*" . `. ^*Nc e$"" * + * "$$". .r" ^4. .^$$" * + * ^.@*"6L=\ebu^+C$"*b." * + * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * + * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * + * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * + * * + * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * + * * + **************************************************************************/ + +#include "common/textconsole.h" +#include "tony/mpal/mpalutils.h" +#include "tony/inventory.h" +#include "tony/game.h" +#include "tony/tony.h" + +namespace Tony { + + +/****************************************************************************\ +* RMInventory Methods +\****************************************************************************/ + +RMInventory::RMInventory() { + m_items = NULL; + m_state = CLOSED; + m_bCombining = false; +} + +RMInventory::~RMInventory() { + Close(); +} + +bool RMInventory::CheckPointInside(RMPoint &pt) { + if (!bCfgInvUp) + return pt.y > RM_SY - 70; + else + return pt.y < 70; +} + + + +void RMInventory::Init(void) { + int i,j; + int curres; + + // Crea il buffer principale + Create(RM_SX, 68); + SetPriority(185); + + // Pulisce l'inventario + m_nInv = 0; + m_curPos = 0; + m_bCombining = false; + + // Nuovi oggetti + m_nItems = 78; // @@@ Numero di oggetti prendibili + m_items = new RMInventoryItem[m_nItems+1]; + + curres = 10500; + + // Loop sugli oggetti + for (i = 0; i <= m_nItems; i++) { + // Carica l'oggetto da risorsa + RMRes res(curres); + RMDataStream ds; + + assert(res.IsValid()); + + // Non deve inizializzare il cur pattern dell'oggetto dell'inventario leggendolo da MPAL! + // Glelo mettiamo noi a MANO, e non c'entra nulla con l'oggetto in MPAL + m_items[i].icon.SetInitCurPattern(false); + ds.OpenBuffer(res); + ds >> m_items[i].icon; + ds.Close(); + + // Mette di default a pattern 1 + m_items[i].status=1; + m_items[i].icon.SetPattern(1); + m_items[i].icon.DoFrame(this, false); + + curres++; + if (i == 0 || i == 28 || i == 29) continue; + + m_items[i].pointer=new RMGfxSourceBuffer8RLEByteAA[m_items[i].icon.NumPattern()]; + + for (j=0;j> miniInterface; + miniInterface.SetPattern(1); + ds.Close(); + + // Crea il testo per gli hints sulla mini interfaccia + m_hints[0].SetAlignType(RMText::HCENTER,RMText::VTOP); + m_hints[1].SetAlignType(RMText::HCENTER,RMText::VTOP); + m_hints[2].SetAlignType(RMText::HCENTER,RMText::VTOP); + + // Il testo viene preso da MPAL per la traduzione + RMMessage msg1(15); + RMMessage msg2(13); + RMMessage msg3(14); + + m_hints[0].WriteText(msg1[0],1); + m_hints[1].WriteText(msg2[0],1); + m_hints[2].WriteText(msg3[0],1); + +/* + m_hints[0].WriteText("Examine",1); + m_hints[1].WriteText("Talk",1); + m_hints[2].WriteText("Use",1); +*/ + + // Prepara il primo inventario + Prepare(); + DrawOT(); + ClearOT(); +} + +void RMInventory::Close(void) { + // Ciao memoria + if (m_items != NULL) { + delete[] m_items; + m_items = NULL; + } + + Destroy(); +} + +void RMInventory::Reset(void) { + m_state = CLOSED; + EndCombine(); +} + +void RMInventory::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + if (m_state == OPENING || m_state == CLOSING) + prim->SetDst(RMPoint(0, m_curPutY)); + else + prim->SetDst(RMPoint(0, m_curPutY)); + + g_system->lockMutex(m_csModifyInterface); + RMGfxWoodyBuffer::Draw(bigBuf, prim); + g_system->unlockMutex(m_csModifyInterface); + + if (m_state == SELECTING) { + RMPoint pos; + RMPoint pos2; + + if (!bCfgInvUp) { + pos.Set((m_nSelectObj+1)*64 - 20,RM_SY - 113); + pos2.Set((m_nSelectObj+1)*64 + 34,RM_SY - 150); + } else { + pos.Set((m_nSelectObj+1)*64 - 20, 72 - 4); // la parte marrone sta in alto :( + pos2.Set((m_nSelectObj+1)*64 + 34, 119 - 4); + } + + RMGfxPrimitive p(prim->m_task, pos); + RMGfxPrimitive p2(prim->m_task, pos2); + + // Disegna l'interfaccina stupida + miniInterface.Draw(bigBuf,&p); + + if (bCfgInterTips) { + if (miniAction == 1) // Esamina + m_hints[0].Draw(bigBuf, &p2); + else if (miniAction == 2) // Parla + m_hints[1].Draw(bigBuf, &p2); + else if (miniAction == 3) // Usa + m_hints[2].Draw(bigBuf, &p2); + } + } +} + +bool RMInventory::RemoveThis(void) { + if (m_state == CLOSED) + return true; + + return false; +} + +void RMInventory::RemoveItem(int code) { + int i; + + for (i=0;ilockMutex(m_csModifyInterface); + + Common::copy_backward(&m_inv[i + 1], &m_inv[i + 1] + (m_nInv - i), &m_inv[i]); +// m_inv[m_nInv-1]=0; + m_nInv--; + + Prepare(); + DrawOT(); + ClearOT(); + g_system->unlockMutex(m_csModifyInterface); + return; + } + + //MessageBox(NULL,"Specified object is not in the inventory","INTERNAL ERROR",MB_OK|MB_ICONEXCLAMATION); +} + +void RMInventory::AddItem(int code) { + if (code <= 10000 && code >= 10101) + { + // Se siamo qui, vuol dire che stiamo aggiungendo un oggetto che non dovrebbe essere + // nell'inventario + warning("Cannot find a valid icon for this item, and then it will not be added to the inventory"); + } else { + g_system->lockMutex(m_csModifyInterface); + if (m_curPos+8 == m_nInv) + { + // Sfondiamo l'inventario! Attivo il pattern di lampeggio + m_items[28].icon.SetPattern(2); + } + + m_inv[m_nInv++]=code-10000; + + Prepare(); + DrawOT(); + ClearOT(); + g_system->unlockMutex(m_csModifyInterface); + } +}; + +void RMInventory::ChangeItemStatus(uint32 code, uint32 dwStatus) { + if (code <= 10000 && code >= 10101) { + error("Specified object code is not valid"); + } else { + g_system->lockMutex(m_csModifyInterface); + m_items[code - 10000].icon.SetPattern(dwStatus); + m_items[code - 10000].status = dwStatus; + + Prepare(); + DrawOT(); + ClearOT(); + g_system->unlockMutex(m_csModifyInterface); + } +} + + +void RMInventory::Prepare(void) +{ + int i; + + for (i = 1; i < RM_SX / 64 - 1; i++) { + if (i - 1 + m_curPos < m_nInv) + AddPrim(new RMGfxPrimitive(&m_items[m_inv[i - 1 + m_curPos]].icon, RMPoint(i * 64, 0))); + else + AddPrim(new RMGfxPrimitive(&m_items[0].icon, RMPoint(i * 64, 0))); + } + + // Frecce + AddPrim(new RMGfxPrimitive(&m_items[29].icon, RMPoint(0, 0))); + AddPrim(new RMGfxPrimitive(&m_items[28].icon, RMPoint(640 - 64, 0))); + + //AddPrim(new RMGfxPrimitive(&m_items[0].icon,RMPoint(0,0))); +} + +bool RMInventory::MiniActive(void) { + return m_state == SELECTING; +} + +bool RMInventory::HaveFocus(RMPoint mpos) { + // In fase di combine abbiamo il focus solo se siamo su una freccia (per poter scrollare) + if (m_state == OPENED && m_bCombining && CheckPointInside(mpos) && (mpos.x < 64 || mpos.x > RM_SX - 64)) + return true; + + // Se l'inventario aperto, abbiamo il focus quando ci andiamo sopra + if (m_state == OPENED && !m_bCombining && CheckPointInside(mpos)) + return true; + + // Se stiamo selezionando un verbo (quindi tasto destro premuto), abbiamo il focus alltime + if (m_state == SELECTING) + return true; + + return false; +} + +void RMInventory::EndCombine(void) { + m_bCombining = false; +} + +bool RMInventory::LeftClick(RMPoint mpos, int& nCombineObj) { + int n; + + // Il click sinistro prende in mano un oggetto dell'inventario per utilizzarlo con lo sfondo + n=mpos.x / 64; + + if (m_state == OPENED) { + if (n > 0 && n < RM_SX / 64 - 1 && m_inv[n - 1 + m_curPos] != 0) { + m_bCombining = true; //m_state=COMBINING; + m_nCombine = m_inv[n - 1 + m_curPos]; + nCombineObj = m_nCombine + 10000; + + _vm->PlayUtilSFX(1); + return true; + } + } + + // Click sulla freccia destra + if ((m_state == OPENED) && m_bBlinkingRight) + { + g_system->lockMutex(m_csModifyInterface); + m_curPos++; + + if (m_curPos+8 >= m_nInv) { + m_bBlinkingRight = false; + m_items[28].icon.SetPattern(1); + } + + if (m_curPos > 0) { + m_bBlinkingLeft = true; + m_items[29].icon.SetPattern(2); + } + + Prepare(); + DrawOT(); + ClearOT(); + g_system->unlockMutex(m_csModifyInterface); + } + // Click sulla freccia sinistra + else if ((m_state == OPENED) && m_bBlinkingLeft) { + assert(m_curPos>0); + g_system->lockMutex(m_csModifyInterface); + m_curPos--; + + if (m_curPos == 0) { + m_bBlinkingLeft = false; + m_items[29].icon.SetPattern(1); + } + + if (m_curPos + 8 < m_nInv) { + m_bBlinkingRight = true; + m_items[28].icon.SetPattern(2); + } + + Prepare(); + DrawOT(); + ClearOT(); + g_system->unlockMutex(m_csModifyInterface); + } + + + return false; +} + + +void RMInventory::RightClick(RMPoint mpos) { + int n; + + assert(CheckPointInside(mpos)); + + if (m_state == OPENED && !m_bCombining) { + // Apre l'interfaccina contestuale + n = mpos.x / 64; + + if (n > 0 && n < RM_SX / 64-1 && m_inv[n-1+m_curPos]!=0) + { + m_state=SELECTING; + miniAction=0; + m_nSelectObj=n-1; + + _vm->PlayUtilSFX(0); + } + } + + if ((m_state == OPENED) && m_bBlinkingRight) { + g_system->lockMutex(m_csModifyInterface); + m_curPos += 7; + if (m_curPos + 8 > m_nInv) + m_curPos = m_nInv - 8; + + if (m_curPos + 8 <= m_nInv) { + m_bBlinkingRight = false; + m_items[28].icon.SetPattern(1); + } + + if (m_curPos>0) { + m_bBlinkingLeft = true; + m_items[29].icon.SetPattern(2); + } + + Prepare(); + DrawOT(); + ClearOT(); + g_system->unlockMutex(m_csModifyInterface); + } else if ((m_state == OPENED) && m_bBlinkingLeft) { + assert(m_curPos > 0); + g_system->lockMutex(m_csModifyInterface); + m_curPos -= 7; + if (m_curPos < 0) m_curPos = 0; + + if (m_curPos == 0) { + m_bBlinkingLeft = false; + m_items[29].icon.SetPattern(1); + } + + if (m_curPos + 8 < m_nInv) { + m_bBlinkingRight = true; + m_items[28].icon.SetPattern(2); + } + + Prepare(); + DrawOT(); + ClearOT(); + g_system->unlockMutex(m_csModifyInterface); + } +} + +bool RMInventory::RightRelease(RMPoint mpos, RMTonyAction& curAction) { + if (m_state == SELECTING) { + m_state = OPENED; + + if (miniAction == 1) { // Esamina + curAction = TA_EXAMINE; + return true; + } else if (miniAction == 2) { // Parla + curAction = TA_TALK; + return true; + } else if (miniAction == 3) { // Usa + curAction = TA_USE; + return true; + } + } + + return false; +} + +#define INVSPEED 20 + +void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpos, bool bCanOpen) { + int i; + bool bNeedRedraw = false; + + if (m_state != CLOSED) { + // Pulisce l'OTList + g_system->lockMutex(m_csModifyInterface); + ClearOT(); + + // Fa il DoFrame di tutti gli oggetti contenuti attualmente nell'inventario + // @@@ forse bisognerebbe farlo di tutti gli oggetti takeable? Probabilmente non serve a nulla + for (i = 0; i < m_nInv; i++) + if (m_items[m_inv[i]].icon.DoFrame(this, false) && (i >= m_curPos && i <= m_curPos + 7)) + bNeedRedraw = true; + + if ((m_state == CLOSING || m_state == OPENING || m_state == OPENED) && CheckPointInside(mpos)) { + if (mpos.x > RM_SX - 64) { + if (m_curPos + 8 < m_nInv && !m_bBlinkingRight) { + m_items[28].icon.SetPattern(3); + m_bBlinkingRight = true; + bNeedRedraw = true; + } + } else if (m_bBlinkingRight) { + m_items[28].icon.SetPattern(2); + m_bBlinkingRight = false; + bNeedRedraw = true; + } + + if (mpos.x < 64) { + if (m_curPos > 0 && !m_bBlinkingLeft) { + m_items[29].icon.SetPattern(3); + m_bBlinkingLeft = true; + bNeedRedraw = true; + } + } else if (m_bBlinkingLeft) { + m_items[29].icon.SetPattern(2); + m_bBlinkingLeft = false; + bNeedRedraw = true; + } + } + + if (m_items[28].icon.DoFrame(this, false)) + bNeedRedraw = true; + + if (m_items[29].icon.DoFrame(this, false)) + bNeedRedraw = true; + + if (bNeedRedraw) + Prepare(); + + g_system->unlockMutex(m_csModifyInterface); + } + + if ((GetAsyncKeyState(Common::KEYCODE_i) & 0x8001) == 0x8001) { + bCfgInvLocked = !bCfgInvLocked; + } + + if (m_bCombining) {//m_state == COMBINING) + ptr.SetCustomPointer(&m_items[m_nCombine].pointer[m_items[m_nCombine].status - 1]); + ptr.SetSpecialPointer(RMPointer::PTR_CUSTOM); + } + + if (!bCfgInvUp) { + if ((m_state == CLOSED) && (mpos.y > RM_SY - 10 || bCfgInvLocked) && bCanOpen) { + if (!bCfgInvNoScroll) { + m_state = OPENING; + m_curPutY = RM_SY - 1; + m_curPutTime=_vm->GetTime(); + } else { + m_state = OPENED; + m_curPutY = RM_SY - 68; + } + } else if (m_state == OPENED) { + if ((mpos.y < RM_SY - 70 && !bCfgInvLocked) || !bCanOpen) { + if (!bCfgInvNoScroll) { + m_state = CLOSING; + m_curPutY = RM_SY - 68; + m_curPutTime = _vm->GetTime(); + } else { + m_state = CLOSED; + } + } + } else if (m_state == OPENING) { + while (m_curPutTime + INVSPEED < _vm->GetTime()) { + m_curPutY -= 3; + m_curPutTime += INVSPEED; + } + + if (m_curPutY <= RM_SY - 68) { + m_state = OPENED; + m_curPutY = RM_SY - 68; + } + + } else if (m_state == CLOSING) { + while (m_curPutTime + INVSPEED < _vm->GetTime()) { + m_curPutY += 3; + m_curPutTime += INVSPEED; + } + + if (m_curPutY > 480) + m_state = CLOSED; + } + } else { + if ((m_state == CLOSED) && (mpos.y<10 || bCfgInvLocked) && bCanOpen) { + if (!bCfgInvNoScroll) { + m_state = OPENING; + m_curPutY =- 68; + m_curPutTime = _vm->GetTime(); + } else { + m_state = OPENED; + m_curPutY = 0; + } + } + else if (m_state == OPENED) { + if ((mpos.y>70 && !bCfgInvLocked) || !bCanOpen) { + if (!bCfgInvNoScroll) { + m_state = CLOSING; + m_curPutY = -2; + m_curPutTime = _vm->GetTime(); + } else { + m_state = CLOSED; + } + } + } else if (m_state == OPENING) { + while (m_curPutTime + INVSPEED < _vm->GetTime()) { + m_curPutY += 3; + m_curPutTime += INVSPEED; + } + + if (m_curPutY >= 0) { + m_state = OPENED; + m_curPutY = 0; + } + } else if (m_state == CLOSING) { + while (m_curPutTime + INVSPEED < _vm->GetTime()) { + m_curPutY -= 3; + m_curPutTime += INVSPEED; + } + + if (m_curPutY < -68) + m_state = CLOSED; + } + } + + if (m_state == SELECTING) { + int startx = (m_nSelectObj + 1) * 64 - 20; + int starty; + + if (!bCfgInvUp) + starty=RM_SY-109; + else + starty=70; + + // Controlla se si trova su uno dei verbi + if (mpos.y > starty && mpos.y < starty + 45) { + if (mpos.x > startx && mpos.x < startx + 40) { + if (miniAction !=1 ) { + miniInterface.SetPattern(2); + miniAction = 1; + _vm->PlayUtilSFX(1); + } + } else if (mpos.x >= startx + 40 && mpos.x < startx + 80) { + if (miniAction != 2) { + miniInterface.SetPattern(3); + miniAction = 2; + _vm->PlayUtilSFX(1); + } + } else if (mpos.x >= startx + 80 && mpos.x < startx + 108) { + if (miniAction != 3) { + miniInterface.SetPattern(4); + miniAction = 3; + _vm->PlayUtilSFX(1); + } + } else { + miniInterface.SetPattern(1); + miniAction = 0; + } + } else { + miniInterface.SetPattern(1); + miniAction = 0; + } + + // Aggiorna la miniinterface + miniInterface.DoFrame(&bigBuf, false); + } + + if ((m_state!= CLOSED) && !m_nInList) { + bigBuf.AddPrim(new RMGfxPrimitive(this)); + } +} + + +bool RMInventory::ItemInFocus(RMPoint mpt) { + if ((m_state == OPENED || m_state == OPENING) && CheckPointInside(mpt)) + return true; + else + return false; +} + +RMItem *RMInventory::WhichItemIsIn(RMPoint mpt) { + int n; + + if (m_state == OPENED) { + if (CheckPointInside(mpt)) { + n=mpt.x / 64; + if (n>0 && n < RM_SX / 64 - 1 && m_inv[n - 1 + m_curPos] != 0 && (!m_bCombining || m_inv[n - 1 + m_curPos] != m_nCombine)) + return &m_items[m_inv[n - 1 + m_curPos]].icon; + } + } + + return NULL; +} + + + +int RMInventory::GetSaveStateSize(void) { + // m_inv pattern m_nInv + return 256*4 + 256*4 + 4 ; +} + +void RMInventory::SaveState(byte *state) { + int i, x; + + WRITE_LE_UINT32(state, m_nInv); state += 4; + Common::copy(m_inv, m_inv + 256, (uint32 *)state); state += 256 * 4; + + for (i = 0; i < 256; i++) { + if (i < m_nItems) + x = m_items[i].status; + else + x = 0; + + WRITE_LE_UINT32(state, x); state += 4; + } +} + +int RMInventory::LoadState(byte *state) { + int i, x; + + m_nInv = READ_LE_UINT32(state); state += 4; + Common::copy((uint32 *)state, (uint32 *)state + 256, m_inv); state += 256 * 4; + + for (i = 0; i < 256; i++) { + x = READ_LE_UINT32(state); state += 4; + + if (i < m_nItems) { + m_items[i].status = x; + m_items[i].icon.SetPattern(x); + } + } + + m_curPos = 0; + m_bCombining = false; + + m_items[29].icon.SetPattern(1); + + if (m_nInv > 8) + m_items[28].icon.SetPattern(2); + else + m_items[28].icon.SetPattern(1); + + Prepare(); + DrawOT(); + ClearOT(); + + return GetSaveStateSize(); +} + + +/****************************************************************************\ +* RMInterface methods +\****************************************************************************/ + +RMInterface::~RMInterface() { + +} + +bool RMInterface::Active() { + return m_bActive; +} + +int RMInterface::OnWhichBox(RMPoint pt) { + int max, i; + + pt -= m_openStart; + + // Controlla quanti verbi bisogna considerare + max = 4; if (m_bPalesati) max = 5; + + // Cerca il verbo + for (i = 0; i < max; i++) + if (m_hotbbox[i].PtInRect(pt)) + return i; + + // Nessun verbo trovato + return -1; +} + +void RMInterface::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + int h; + + prim->Dst().TopLeft() = m_openStart; + RMGfxSourceBuffer8RLEByte::Draw(bigBuf, prim); + + // Controlla se c'e' da disegnare una zona calda + h = OnWhichBox(m_mpos); + if (h != -1) { + prim->Dst().TopLeft() = m_openStart; + m_hotzone[h].Draw(bigBuf, prim); + + if (m_lastHotZone != h) { + m_lastHotZone = h; + _vm->PlayUtilSFX(1); + } + + if (bCfgInterTips) { + prim->Dst().TopLeft() = m_openStart + RMPoint(70, 177); + m_hints[h].Draw(bigBuf,prim); + } + } else + m_lastHotZone = -1; + +} + + +void RMInterface::DoFrame(RMGfxTargetBuffer &bigBuf, RMPoint mousepos) { + // Se c' bisogna, schedula nella OT list + if (!m_nInList && m_bActive) + bigBuf.AddPrim(new RMGfxPrimitive(this)); + + m_mpos = mousepos; +} + +void RMInterface::Clicked(RMPoint mousepos) { + m_bActive = true; + m_openPos = mousepos; + + // Calcola l'angolo in alto a sinistra dell'interfaccia + m_openStart = m_openPos - RMPoint(m_dimx / 2, m_dimy / 2); + m_lastHotZone = -1; + + // La tiene dentro lo schermo + if (m_openStart.x < 0) m_openStart.x = 0; + if (m_openStart.y < 0) m_openStart.y = 0; + if (m_openStart.x+m_dimx > RM_SX) m_openStart.x = RM_SX - m_dimx; + if (m_openStart.y+m_dimy > RM_SY) m_openStart.y = RM_SY - m_dimy; + + // Play dell'effetto sonoro + _vm->PlayUtilSFX(0); +} + +bool RMInterface::Released(RMPoint mousepos, RMTonyAction &action) { + if (!m_bActive) + return false; + + m_bActive = false; + + switch (OnWhichBox(mousepos)) { + case 0: + action = TA_TAKE; + break; + + case 1: + action = TA_TALK; + break; + + case 2: + action = TA_USE; + break; + + case 3: + action = TA_EXAMINE; + break; + + case 4: + action = TA_PALESATI; + break; + + default: // Nessun verbo + return false; + } + + return true; +} + +void RMInterface::Reset(void) { + m_bActive = false; +} + +void RMInterface::SetPalesati(bool bOn) { + m_bPalesati=bOn; +} + +bool RMInterface::GetPalesati(void) { + return m_bPalesati; +} + +void RMInterface::Init(void) { + int i; + RMResRaw inter(RES_I_INTERFACE); + RMRes pal(RES_I_INTERPPAL); + + SetPriority(191); + + RMGfxSourceBuffer::Init(inter, inter.Width(), inter.Height()); + LoadPaletteWA(RES_I_INTERPAL); + + for (i = 0; i < 5; i++) { + RMResRaw part(RES_I_INTERP1 + i); + + m_hotzone[i].Init(part, part.Width(), part.Height()); + m_hotzone[i].LoadPaletteWA(pal); + } + + m_hotbbox[0].SetRect(126, 123, 159, 208); // prendi + m_hotbbox[1].SetRect(90, 130, 125, 186); // parla + m_hotbbox[2].SetRect(110, 60, 152, 125); + m_hotbbox[3].SetRect(56, 51, 93, 99); + m_hotbbox[4].SetRect(51, 105, 82, 172); + + m_hints[0].SetAlignType(RMText::HRIGHT, RMText::VTOP); + m_hints[1].SetAlignType(RMText::HRIGHT, RMText::VTOP); + m_hints[2].SetAlignType(RMText::HRIGHT, RMText::VTOP); + m_hints[3].SetAlignType(RMText::HRIGHT, RMText::VTOP); + m_hints[4].SetAlignType(RMText::HRIGHT, RMText::VTOP); + + // Il testo viene preso da MPAL per la traduzione + RMMessage msg0(12); + RMMessage msg1(13); + RMMessage msg2(14); + RMMessage msg3(15); + RMMessage msg4(16); + + m_hints[0].WriteText(msg0[0], 1); + m_hints[1].WriteText(msg1[0], 1); + m_hints[2].WriteText(msg2[0], 1); + m_hints[3].WriteText(msg3[0], 1); + m_hints[4].WriteText(msg4[0], 1); +/* + m_hints[0].WriteText("Take",1); + m_hints[1].WriteText("Talk",1); + m_hints[2].WriteText("Use",1); + m_hints[3].WriteText("Examine",1); + m_hints[4].WriteText("Palesati",1); +*/ + m_bActive = false; + m_bPalesati = false; +} + +void RMInterface::Close(void) { + int i; + + Destroy(); + + for (i = 0; i < 5; i++) + m_hotzone[i].Destroy(); +} + +} // End of namespace Tony diff --git a/engines/tony/inventory.h b/engines/tony/inventory.h index 5ec67f6228..3d8650773f 100644 --- a/engines/tony/inventory.h +++ b/engines/tony/inventory.h @@ -51,6 +51,7 @@ #include "common/scummsys.h" #include "common/system.h" #include "tony/font.h" +#include "tony/game.h" #include "tony/gfxcore.h" #include "tony/loc.h" @@ -79,7 +80,7 @@ protected: int m_inv[256]; int m_nInv; int m_curPutY; - int m_curPutTime; + uint32 m_curPutTime; int m_curPos; STATE m_state; @@ -134,7 +135,7 @@ public: // Gestisce il tasto destro del mouse (solo quando c'ha focus) void RightClick(RMPoint mpos); - bool RightRelease(RMPoint mpos, RMTonyAction& curAction); + bool RightRelease(RMPoint mpos, RMTonyAction &curAction); // Avverte che finito il combine void EndCombine(void); diff --git a/engines/tony/module.mk b/engines/tony/module.mk index cbd44d467e..f7d8b1e8c1 100644 --- a/engines/tony/module.mk +++ b/engines/tony/module.mk @@ -7,6 +7,7 @@ MODULE_OBJS := \ gfxcore.o \ gfxengine.o \ input.o \ + inventory.o \ loc.o \ sound.o \ tony.o \ diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index 360b7a6f32..43a129b92a 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -816,19 +816,19 @@ RMPoint RMRect::Center() { return RMPoint((x2 - x1) / 2,(y2 - y1) / 2); } -int RMRect::Width() { +int RMRect::Width() const { return x2 - x1; } -int RMRect::Height() { +int RMRect::Height() const { return y2 - y1; } -int RMRect::Size() { +int RMRect::Size() const { return Width() * Height(); } -bool RMRect::IsEmpty() { +bool RMRect::IsEmpty() const { return (x1 == 0 && y1 == 0 && x2 == 0 && y2 == 0); } diff --git a/engines/tony/utils.h b/engines/tony/utils.h index 54e4cd0eae..bd4b152f1f 100644 --- a/engines/tony/utils.h +++ b/engines/tony/utils.h @@ -232,10 +232,10 @@ public: RMPoint &TopLeft(); RMPoint &BottomRight(); RMPoint Center(); - int Width(); - int Height(); - bool IsEmpty(); - int Size(); + int Width() const; + int Height() const; + bool IsEmpty() const; + int Size() const; // Set void SetRect(int x1, int y1, int x2, int y2); -- cgit v1.2.3 From 4300db9ee4798d43eb2214db87b575ed12640458 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 2 May 2012 23:35:32 +1000 Subject: TONY: Implemented font.cpp methods --- engines/tony/gfxcore.h | 2 +- engines/tony/module.mk | 1 + engines/tony/mpal/stubs.cpp | 3 +++ engines/tony/mpal/stubs.h | 2 ++ 4 files changed, 7 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index 2e4f9830ed..b6a10ab778 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -288,7 +288,7 @@ protected: public: virtual ~RMGfxSourceBufferPal(); - virtual int Init(byte *buf, int dimx, int dimy, bool bLoadPalette = false); + virtual int Init(const byte *buf, int dimx, int dimy, bool bLoadPalette = false); virtual void Init(RMDataStream& ds, int dimx, int dimy, bool bLoadPalette = false); int LoadPaletteWA(uint32 resID, bool bSwapped = false); diff --git a/engines/tony/module.mk b/engines/tony/module.mk index f7d8b1e8c1..690b1f4713 100644 --- a/engines/tony/module.mk +++ b/engines/tony/module.mk @@ -3,6 +3,7 @@ MODULE := engines/tony MODULE_OBJS := \ custom.o \ detection.o \ + font.o \ game.o \ gfxcore.o \ gfxengine.o \ diff --git a/engines/tony/mpal/stubs.cpp b/engines/tony/mpal/stubs.cpp index ea93265ec9..9d4a87d61c 100644 --- a/engines/tony/mpal/stubs.cpp +++ b/engines/tony/mpal/stubs.cpp @@ -97,6 +97,9 @@ void SetEvent(HANDLE hEvent) { void ResetEvent(HANDLE hEvent) { } +void PulseEvent(HANDLE hEvent) { +} + uint16 GetAsyncKeyState(Common::KeyCode kc) { return 0; } diff --git a/engines/tony/mpal/stubs.h b/engines/tony/mpal/stubs.h index 9a22b65b7a..5c50b76db1 100644 --- a/engines/tony/mpal/stubs.h +++ b/engines/tony/mpal/stubs.h @@ -106,6 +106,8 @@ extern void SetEvent(HANDLE hEvent); extern void ResetEvent(HANDLE hEvent); +extern void PulseEvent(HANDLE hEvent); + extern uint16 GetAsyncKeyState(Common::KeyCode kc); } // end of namespace MPAL -- cgit v1.2.3 From 2eb9ebd8aa28fabfc443b85507d3c85b6525684e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 3 May 2012 00:49:59 +1000 Subject: TONY: Implemented loc.cpp and font.cpp methods --- engines/tony/font.cpp | 2510 +++++++++++++++++++++++++++++++++++++++++++++++++ engines/tony/loc.cpp | 2071 +++++++++++++++++++++++++++++++++++++++- engines/tony/loc.h | 5 +- engines/tony/utils.h | 50 + 4 files changed, 4622 insertions(+), 14 deletions(-) create mode 100644 engines/tony/font.cpp (limited to 'engines') diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp new file mode 100644 index 0000000000..2996b30f04 --- /dev/null +++ b/engines/tony/font.cpp @@ -0,0 +1,2510 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ +/************************************************************************** + * 様様様様様様様様様様様様様様様様様 * + * Nayma Software srl * + * e -= We create much MORE than ALL =- * + * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * + * .d" d$$$$$b "b. * + * .z$* d$$$$$$$L ^*$c. * + * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * + * ^*$b 4$$$$$$$$$F .d$*" * + * ^$$. 4$$$$$$$$$F .$P" Module: Font.CPP............. * + * *$. '$$$$$$$$$ 4$P 4 * + * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * + * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * + * z$" "" #$F^ "" '$c * + * z$$beu .ue=" $ "=e.. .zed$$c * + * "#$e z$*" . `. ^*Nc e$"" * + * "$$". .r" ^4. .^$$" * + * ^.@*"6L=\ebu^+C$"*b." * + * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * + * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * + * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * + * * + * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * + * * + **************************************************************************/ + +#include "common/textconsole.h" +#include "tony/mpal/mpalutils.h" +#include "tony/mpal/stubs.h" +#include "tony/font.h" +#include "tony/input.h" +#include "tony/inventory.h" +#include "tony/loc.h" +#include "tony/tony.h" + +namespace Tony { + +/****************************************************************************\ +* Metodi di RMFont +\****************************************************************************/ + +RMFont::RMFont() { + m_letter = NULL; +} + +RMFont::~RMFont() { + Unload(); +} + +/****************************************************************************\ +* +* Function: void RMFont::Load(byte *buf, int nChars, int dimx, int dimy); +* +* Description: Carica un font da buffer +* +* Input: byte *buf Buffer contenente il font +* int nChars Numero di caratteri (max 256) +* int dimx,dimy Dimensione in pixel di un carattere +* +\****************************************************************************/ + +void DumpFontBMP(const char *filename, const byte *buf, int nChars, int charX, int charY, byte *pal) { + error("DumpFontBMP not supported in ScummVM"); +} + + +void RMFont::Load(const byte *buf, int nChars, int dimx, int dimy, uint32 palResID) { + m_letter = new RMGfxSourceBuffer8RLEByte[nChars]; + +#if 0 + if (nChars == 112 && palResID == RES_F_PAL) + { + // Font parla + DumpFontBMP("font_parla.bmp", buf, nChars, dimx, dimy, RMRes(palResID)); + } + else if (nChars == 102 && palResID == RES_F_PAL) + { + // Font macc + DumpFontBMP("font_macc.bmp", buf, nChars, dimx, dimy, RMRes(palResID)); + } + else if (nChars == 85 && palResID == RES_F_PAL) + { + // Font obj + DumpFontBMP("font_obj.bmp", buf, nChars, dimx, dimy, RMRes(palResID)); + } + else if (nChars == 112 && palResID == RES_F_CPAL) + { + // Font credits + DumpFontBMP("font_credits.bmp", buf, nChars, dimx, dimy, RMRes(palResID)); + } +#endif + + // Carichiamoce 'sto font + for (int i = 0; i < nChars; i++) + { + // Inizializza il buffer con le lettere + m_letter[i].Init(buf + i * (dimx * dimy + 8) + 8, dimx, dimy); + m_letter[i].LoadPaletteWA(palResID); + } + + m_fontDimx = dimx; + m_fontDimy = dimy; + + nLetters=nChars; +} + + +void RMFont::Unload(void) { + if (m_letter != NULL) { + delete[] m_letter; + m_letter = NULL; + } +} + + +RMGfxPrimitive *RMFont::MakeLetterPrimitive(byte bChar, int &nLength) { + RMFontPrimitive *prim; + int nLett; + + // Converte da carattere a lettera + nLett = ConvertToLetter(bChar); + + // Crea la primitiva per il font + prim = new RMFontPrimitive(this); + prim->m_nChar = nLett; + + // Si fa' dare la lunghezza della lettera in pixel + nLength = LetterLength(bChar); + + return prim; +} + +void RMFont::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim2) { + RMFontPrimitive *prim = (RMFontPrimitive *)prim2; + + // Richiama la Draw della lettera assegnata alla primitiva + if (prim->m_nChar != -1) + m_letter[prim->m_nChar].Draw(bigBuf,prim); +} + +void RMFont::Close(void) { + Unload(); +} + +int RMFont::StringLen(RMString text) { + int len, i; + + len = 0; + for (i = 0; i < text.Length() - 1; i++) + len += LetterLength(text[i], text[i + 1]); + len += LetterLength(text[i]); + + return len; +} + +int RMFont::StringLen(char bChar, char bNext) { + return LetterLength(bChar, bNext); +} + +/****************************************************************************\ +* Metodi di RMFontColor +\****************************************************************************/ + +RMFontColor::RMFontColor() : RMFont() { + m_r = m_g = m_b = 255; +} + +RMFontColor::~RMFontColor() { + +} + +void RMFontColor::SetBaseColor(byte r1, byte g1, byte b1) { + int r = (int)r1 << 16; + int g = (int)g1 << 16; + int b = (int)b1 << 16; + + int rstep = r / 14; + int gstep = g / 14; + int bstep = b / 14; + + int i; + byte pal[768*3]; + + // Controlla se siamo gia' sul colore giusto + if (m_r == r1 && m_g == g1 && m_b == b1) + return; + + m_r = r1; + m_g = g1; + m_b = b1; + + // Costruisce la nuova palette per il font + for (i = 1; i < 16; i++) { + pal[i * 3 + 0] = r >> 16; + pal[i * 3 + 1] = g >> 16; + pal[i * 3 + 2] = b >> 16; + + r -= rstep; + g -= gstep; + b -= bstep; + } + + pal[15*3 + 0] += 8; + pal[15*3 + 1] += 8; + pal[15*3 + 2] += 8; + + // La mette in tutte le lettere + for (i = 0; i < nLetters; i++) + m_letter[i].LoadPaletteWA(pal); +} + + +/***************************************************************************\ +* Metodi di RMFontParla +\****************************************************************************/ + +void RMFontParla::Init(void) { + int i; + + // bernie: numero di caratteri nel font + int nchars = + 112 // base + + 18 // polish + + 66 // russian + + 30 // czech + + 8 // french + + 5; // deutsch + + Load(RES_F_PARL, nchars, 20, 20); + + // Inizializziamo le tabelline del cazzo + lDefault = 13; + hDefault = 18; + Common::fill(&l2Table[0][0], &l2Table[0][0] + (256 * 256), '\0'); + for (i = 0; i < 256; i++) + { + cTable[i] = -1; + lTable[i] = lDefault; + } + + for (i = 0; i < 26; i++) + cTable['A' + i] = i + 0; + + for (i = 0; i < 26; i++) + cTable['a' + i] = i + 26; + + for (i = 0; i < 10; i++) + cTable['0' + i] = i + 52; + + cTable[';'] = 62; + cTable[','] = 63; + cTable['.'] = 64; + cTable[':'] = 65; + cTable['-'] = 66; + cTable['_'] = 67; + cTable['+'] = 68; + cTable['<'] = 69; + cTable['>'] = 70; + cTable['!'] = 71; + //cTable['!'] = 72; Esclamativo alla rovescia + cTable['?'] = 73; + //cTable['?'] = 74; Interrogativo alla rovescia + cTable['('] = 75; + cTable[')'] = 76; + cTable['\"'] = 77; + cTable['^'] = 77; + cTable['/'] = 78; + cTable[''] = 79; + cTable['$'] = 80; + cTable['%'] = 81; + cTable['&'] = 82; + cTable['='] = 83; + cTable[''] = 84; + cTable[''] = 85; + cTable[''] = 86; + cTable[''] = 87; + cTable[''] = 88; + cTable[''] = 89; + cTable[''] = 89; + cTable[''] = 90; + cTable[''] = 91; + cTable[''] = 92; + cTable[''] = 93; + cTable[''] = 94; + cTable[''] = 95; + cTable[''] = 96; + cTable[''] = 97; + cTable[''] = 98; + cTable[''] = 99; + //cTable[' '] = 100; e cerchietto + //cTable[' '] = 101; i cerchietto + //cTable[' '] = 102; o cerchietto + //cTable[' '] = 103; u cerchietto + cTable[''] = 104; + cTable[''] = 105; + cTable[''] = 106; + cTable[''] = 107; + cTable[''] = 108; + cTable[''] = 109; + //cTable[''] = 110; integrale + cTable['\''] = 111; + + // Un po' di lunghezze + lTable[' '] = 9; + lTable['\''] = 5; + lTable['.'] = 5; + lTable[','] = 5; + lTable[':'] = 5; + lTable[';'] = 5; + lTable['!'] = 5; + lTable['?'] = 10; + lTable['\"'] = 5; + lTable['^'] = 5; + lTable['('] = 7; + lTable[')'] = 7; + + lTable['4'] = 10; + + lTable['a'] = 14; + lTable['b'] = 15; + lTable['c'] = 12; + lTable['e'] = 12; + lTable['i'] = 6; + lTable[''] = 6; + lTable['l'] = 5; + lTable['m'] = 16; + lTable['n'] = 12; + lTable['o'] = 11; + lTable['p'] = 11; + lTable['s'] = 12; + lTable['u'] = 12; + + lTable['E'] = 10; + lTable['F'] = 11; + + + // Polish characters + //AaCcEeLlNnOoSsZzZz + //ス謎戊3剔囀 + + cTable[''] = 112; + cTable[''] = 113; + cTable[''] = 114; + cTable[''] = 115; + cTable[''] = 116; + cTable[''] = 117; + cTable[''] = 118; + cTable[''] = 119; + cTable[''] = 120; + cTable[''] = 121; + cTable[''] = 122; + cTable[''] = 123; + cTable[''] = 124; + cTable[''] = 125; + cTable[''] = 126; + cTable[''] = 127; + cTable[''] = 128; + cTable[''] = 129; + + lTable[''] = 14; + lTable[''] = 16; + lTable[''] = 12; + lTable[''] = 12; + lTable[''] = 11; + lTable[''] = 12; + lTable[''] = 14; + lTable[''] = 9; + lTable[''] = 10; + lTable[''] = 11; + lTable[''] = 13; + lTable[''] = 11; + lTable[''] = 12; + lTable[''] = 12; + lTable[''] = 13; + lTable[''] = 13; + lTable[''] = 14; + lTable[''] = 13; + +#ifdef FONT_RUSSIAN + // Russian Characters + // WARNING: Il russo usa molti dei caratteri ISO-Latin-1 che servono + // per le altre traduzioni. Per compilare Tony in altre lingue, + // commentare via queste definizioni. + + cTable[''] = 130; + cTable[''] = 131; + cTable[''] = 132; + cTable[''] = 133; + cTable[''] = 134; + cTable[''] = 135; + cTable[''] = 136; + cTable[''] = 137; + cTable[''] = 138; + cTable[''] = 139; + cTable[''] = 140; + cTable[''] = 141; + cTable[''] = 142; + cTable[''] = 143; + cTable[''] = 144; + cTable[''] = 145; + cTable[''] = 146; + cTable[''] = 147; + cTable[''] = 148; + cTable[''] = 149; + cTable[''] = 150; + cTable[''] = 151; + cTable[''] = 152; + cTable[''] = 153; + cTable[''] = 154; + cTable[''] = 155; + cTable[''] = 156; + cTable[''] = 157; + cTable[''] = 158; + cTable[''] = 159; + cTable[''] = 160; + cTable[''] = 161; + cTable[''] = 162; + + cTable[''] = 163; + cTable[''] = 164; + cTable[''] = 165; + cTable[''] = 166; + cTable[''] = 167; + cTable[''] = 168; + cTable[''] = 169; + cTable[''] = 170; + cTable[''] = 171; + cTable[''] = 172; + cTable[''] = 173; + cTable[''] = 174; + cTable[''] = 175; + cTable[''] = 176; + cTable[''] = 177; + cTable[''] = 178; + cTable[''] = 179; + cTable[''] = 180; + cTable[''] = 181; + cTable[''] = 182; + cTable[''] = 183; + cTable[''] = 184; + cTable[''] = 185; + cTable[''] = 186; + cTable[''] = 187; + cTable[''] = 188; + cTable[''] = 189; + cTable[''] = 190; + cTable[''] = 191; + cTable[''] = 192; + cTable[''] = 193; + cTable[''] = 194; + cTable[''] = 195; + + lTable[''] = 13; + lTable[''] = 15; + lTable[''] = 15; + lTable[''] = 11; + lTable[''] = 15; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 15; + lTable[''] = 10; + lTable[''] = 13; + lTable[''] = 13; + lTable[''] = 12; + lTable[''] = 13; + lTable[''] = 14; + lTable[''] = 14; + lTable[''] = 13; + lTable[''] = 11; + lTable[''] = 12; + lTable[''] = 12; + lTable[''] = 18; + lTable[''] = 11; + lTable[''] = 13; + lTable[''] = 12; + lTable[''] = 13; + lTable[''] = 12; + lTable[''] = 17; + lTable[''] = 18; + lTable[''] = 16; + lTable[''] = 18; + lTable[''] = 19; + lTable[''] = 11; + lTable[''] = 16; + lTable[''] = 14; + + lTable[''] = 14; + lTable[''] = 15; + lTable[''] = 10; + lTable[''] = 12; + lTable[''] = 13; + lTable[''] = 12; + lTable[''] = 12; + lTable[''] = 12; + lTable[''] = 10; + lTable[''] = 10; + lTable[''] = 10; + lTable[''] = 11; + lTable[''] = 12; + lTable[''] = 12; + lTable[''] = 12; + lTable[''] = 12; + lTable[''] = 10; + lTable[''] = 11; + lTable[''] = 10; + lTable[''] = 14; + lTable[''] = 8; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 12; + lTable[''] = 10; + lTable[''] = 15; + lTable[''] = 16; + lTable[''] = 14; + lTable[''] = 16; + lTable[''] = 16; + lTable[''] = 9; + lTable[''] = 15; + lTable[''] = 14; + +#endif // FONT_RUSSIAN + +#ifdef FONT_CZECH + + cTable[''] = 196; + cTable[''] = 197; + cTable[''] = 198; + cTable[''] = 199; + cTable[''] = 200; + cTable[''] = 201; + cTable[''] = 202; + cTable[''] = 203; + cTable[''] = 204; + cTable[''] = 205; + cTable[''] = 206; + cTable[''] = 207; + cTable[''] = 208; + cTable[''] = 209; + cTable[''] = 210; + + cTable[''] = 211; + cTable[''] = 212; + cTable[''] = 213; + cTable[''] = 214; + cTable[''] = 215; + cTable[''] = 216; + cTable[''] = 217; + cTable[''] = 218; + cTable[''] = 219; + cTable[''] = 220; + cTable[''] = 221; + cTable[''] = 222; + cTable[''] = 223; + cTable[''] = 224; + cTable[''] = 225; + + lTable[''] = 11; + lTable[''] = 12; + lTable[''] = 12; + lTable[''] = 14; + lTable[''] = 13; + lTable[''] = 11; + lTable[''] = 13; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 15; + lTable[''] = 19; + lTable[''] = 10; + lTable[''] = 13; + lTable[''] = 13; + lTable[''] = 13; + + lTable[''] = 12; + lTable[''] = 12; + lTable[''] = 12; + lTable[''] = 12; + lTable[''] = 13; + lTable[''] = 11; + lTable[''] = 15; + lTable[''] = 7; + lTable[''] = 12; + lTable[''] = 17; + lTable[''] = 16; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 13; + lTable[''] = 13; + +#endif // FONT_CZECH + +#ifdef FONT_FRENCH + cTable[''] = 226; + cTable[''] = 227; + cTable[''] = 228; + cTable[''] = 229; + cTable[''] = 230; + cTable[''] = 231; + cTable[''] = 232; + cTable[''] = 233; + + lTable[''] = 15; + lTable[''] = 12; + lTable[''] = 12; + lTable[''] = 9; + lTable[''] = 13; + lTable[''] = 13; + lTable[''] = 11; + lTable[''] = 11; + +#endif // FONT_FRENCH + +#ifdef FONT_GERMAN + cTable[''] = 234; + // 'SS' = 235 + cTable[''] = 236; + cTable[''] = 237; + cTable[''] = 238; + + lTable[''] = 15; + +#endif // FONT_GERMAN +} + + +/***************************************************************************\ +* Metodi di RMFontMacc +\****************************************************************************/ + +void RMFontMacc::Init(void) { + int i; + + // bernie: numero di caratteri nel font + int nchars = + 102 // base + + 18 // polish + + 66 // russian + + 30 // czech + + 8 // francais + + 5; // deutsch + + + Load(RES_F_MACC, nchars, 11, 16); + + // Default + lDefault = 10; + hDefault = 17; + Common::fill(&l2Table[0][0], &l2Table[0][0] + (256 * 256), '\0'); + + for (i = 0; i < 256; i++) { + cTable[i] = -1; + lTable[i] = lDefault; + } + + for (i = 0; i < 26; i++) + cTable['A'+i] = i + 0; + + for (i = 0; i < 26; i++) + cTable['a'+i] = i + 26; + + for (i = 0; i < 10; i++) + cTable['0'+i] = i + 52; + + cTable['!'] = 62; + //cTable['!'] = 63; // ! rovescia + cTable['\"'] = 64; + cTable['$'] = 65; + cTable['%'] = 66; + cTable['&'] = 67; + cTable['/'] = 68; + cTable['('] = 69; + cTable[')'] = 70; + cTable['='] = 71; + cTable['?'] = 72; + //cTable['?'] = 73; // ? rovescia + cTable['*'] = 74; + cTable['+'] = 75; + cTable[''] = 76; + cTable[';'] = 77; + cTable[','] = 78; + cTable['.'] = 79; + cTable[':'] = 80; + cTable['-'] = 81; + cTable['<'] = 82; + cTable[' > '] = 83; + cTable['/'] = 84; + cTable[''] = 85; + cTable[''] = 86; + cTable[''] = 87; + cTable[''] = 88; + cTable[''] = 89; + cTable[''] = 90; + //cTable[''] = 91; // e col pallino + cTable[''] = 92; + cTable[''] = 93; + //cTable[''] = 94; // i col pallino + cTable[''] = 95; + cTable[''] = 96; + //cTable[''] = 97; // o col pallino + cTable[''] = 98; + cTable[''] = 99; + //cTable[''] = 100; // u col pallino + cTable[''] = 101; + + // Polish characters + //AaCcEeLlNnOoSsZzZz + //ス謎戊3剔囀 + + cTable[''] = 102; + cTable[''] = 103; + cTable[''] = 104; + cTable[''] = 105; + cTable[''] = 106; + cTable[''] = 107; + cTable[''] = 108; + cTable[''] = 109; + cTable[''] = 110; + cTable[''] = 111; + cTable[''] = 112; + cTable[''] = 113; + cTable[''] = 114; + cTable[''] = 115; + cTable[''] = 116; + cTable[''] = 117; + cTable[''] = 118; + cTable[''] = 119; + + lTable[''] = 14; + lTable[''] = 16; + lTable[''] = 12; + lTable[''] = 12; + lTable[''] = 11; + lTable[''] = 12; + lTable[''] = 14; + lTable[''] = 9; + lTable[''] = 10; + lTable[''] = 11; + lTable[''] = 13; + lTable[''] = 11; + lTable[''] = 12; + lTable[''] = 12; + lTable[''] = 13; + lTable[''] = 13; + lTable[''] = 14; + lTable[''] = 13; + + +#ifdef FONT_RUSSIAN + // Russian Characters + // WARNING: Il russo usa molti dei caratteri ISO-Latin-1 che servono + // per le altre traduzioni. Per compilare Tony in altre lingue, + // commentare via queste definizioni. + + cTable[''] = 120; + cTable[''] = 121; + cTable[''] = 122; + cTable[''] = 123; + cTable[''] = 124; + cTable[''] = 125; + cTable[''] = 126; + cTable[''] = 127; + cTable[''] = 128; + cTable[''] = 129; + cTable[''] = 130; + cTable[''] = 131; + cTable[''] = 132; + cTable[''] = 133; + cTable[''] = 134; + cTable[''] = 135; + cTable[''] = 136; + cTable[''] = 137; + cTable[''] = 138; + cTable[''] = 139; + cTable[''] = 140; + cTable[''] = 141; + cTable[''] = 142; + cTable[''] = 143; + cTable[''] = 144; + cTable[''] = 145; + cTable[''] = 146; + cTable[''] = 147; + cTable[''] = 148; + cTable[''] = 149; + cTable[''] = 150; + cTable[''] = 151; + cTable[''] = 152; + + cTable[''] = 153; + cTable[''] = 154; + cTable[''] = 155; + cTable[''] = 156; + cTable[''] = 157; + cTable[''] = 158; + cTable[''] = 159; + cTable[''] = 160; + cTable[''] = 161; + cTable[''] = 162; + cTable[''] = 163; + cTable[''] = 164; + cTable[''] = 165; + cTable[''] = 166; + cTable[''] = 167; + cTable[''] = 168; + cTable[''] = 169; + cTable[''] = 170; + cTable[''] = 171; + cTable[''] = 172; + cTable[''] = 173; + cTable[''] = 174; + cTable[''] = 175; + cTable[''] = 176; + cTable[''] = 177; + cTable[''] = 178; + cTable[''] = 179; + cTable[''] = 180; + cTable[''] = 181; + cTable[''] = 182; + cTable[''] = 183; + cTable[''] = 184; + cTable[''] = 185; + + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 9; + lTable[''] = 10; + lTable[''] = 10; + lTable[''] = 10; + lTable[''] = 11; + lTable[''] = 10; + lTable[''] = 10; + lTable[''] = 10; + lTable[''] = 11; + lTable[''] = 9; + lTable[''] = 11; + lTable[''] = 10; + lTable[''] = 11; + lTable[''] = 8; + lTable[''] = 10; + lTable[''] = 10; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 10; + lTable[''] = 10; + lTable[''] = 10; + lTable[''] = 10; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 11; + + lTable[''] = 10; + lTable[''] = 10; + lTable[''] = 11; + lTable[''] = 10; + lTable[''] = 9; + lTable[''] = 10; + lTable[''] = 9; + lTable[''] = 10; + lTable[''] = 9; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 10; + lTable[''] = 9; + lTable[''] = 11; + lTable[''] = 10; + lTable[''] = 9; + lTable[''] = 11; + lTable[''] = 10; + lTable[''] = 11; + lTable[''] = 10; + lTable[''] = 10; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 10; + lTable[''] = 10; + lTable[''] = 10; + lTable[''] = 9; + lTable[''] = 11; + lTable[''] = 11; + +#endif // FONT_RUSSIAN + +#ifdef FONT_CZECH + + cTable[''] = 186; + cTable[''] = 187; + cTable[''] = 188; + cTable[''] = 189; + cTable[''] = 190; + cTable[''] = 191; + cTable[''] = 192; + cTable[''] = 193; + cTable[''] = 194; + cTable[''] = 195; + cTable[''] = 196; + cTable[''] = 197; + cTable[''] = 198; + cTable[''] = 199; + cTable[''] = 200; + + cTable[''] = 201; + cTable[''] = 202; + cTable[''] = 203; + cTable[''] = 204; + cTable[''] = 205; + cTable[''] = 206; + cTable[''] = 207; + cTable[''] = 208; + cTable[''] = 209; + cTable[''] = 210; + cTable[''] = 211; + cTable[''] = 212; + cTable[''] = 213; + cTable[''] = 214; + cTable[''] = 215; + + lTable[''] = 10; + lTable[''] = 10; + lTable[''] = 10; + lTable[''] = 11; + lTable[''] = 9; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 9; + lTable[''] = 10; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 11; + + lTable[''] = 10; + lTable[''] = 9; + lTable[''] = 10; + lTable[''] = 10; + lTable[''] = 9; + lTable[''] = 11; + lTable[''] = 10; + lTable[''] = 9; + lTable[''] = 10; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 10; + lTable[''] = 11; + lTable[''] = 11; + +#endif // FONT_CZECH + +#ifdef FONT_FRENCH + + cTable[''] = 226; + cTable[''] = 227; + cTable[''] = 228; + cTable[''] = 229; + cTable[''] = 230; + cTable[''] = 231; + cTable[''] = 232; + cTable[''] = 233; + + lTable[''] = 10; + lTable[''] = 10; + lTable[''] = 10; + lTable[''] = 8; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 10; + lTable[''] = 10; + +#endif // FONT_FRENCH + +#ifdef FONT_GERMAN + cTable[''] = 234; + // 'SS' = 235 + cTable[''] = 236; + cTable[''] = 237; + cTable[''] = 238; + + lTable[''] = 11; +#endif // FONT_GERMAN +} + +/***************************************************************************\ +* Metodi di RMFontCredits +\****************************************************************************/ + +void RMFontCredits::Init(void) { + int i; + + // bernie: numero di caratteri nel font + int nchars = + 112 // base + + 18 // polish + + 66 // russian + + 30 // czech + + 8 // french + + 2; // deutsch + + + Load(RES_F_CREDITS, nchars, 27, 28, RES_F_CPAL); + + // Default + lDefault=10; + hDefault=28; + Common::fill(&l2Table[0][0], &l2Table[0][0] + (256 * 256), '\0'); + + for (i = 0; i < 256; i++) + { + cTable[i] = -1; + lTable[i] = lDefault; + } + + for (i = 0; i < 26; i++) + cTable['A' + i] = i + 0; + + for (i = 0; i < 26; i++) + cTable['a' + i] = i + 26; + + + + cTable[''] = 52; + cTable[''] = 53; +// cTable[''] = 54; // a ^ +// cTable[''] = 55; // a pallini + cTable[''] = 56; + cTable[''] = 57; +// cTable[''] = 58; // e ^ +// cTable[''] = 59; // e pallini + cTable[''] = 60; + cTable[''] = 61; +// cTable[''] = 62; // i ^ +// cTable[''] = 63; // i pallini + cTable[''] = 64; + cTable[''] = 65; +// cTable[''] = 66; // o ^ +// cTable[''] = 67; // o pallini + cTable[''] = 68; + cTable[''] = 69; +// cTable[''] = 70; // u ^ +// cTable[''] = 71; // u pallini +// cTable[''] = 72; // y pallini + cTable[''] = 73; + cTable[''] = 74; +// cTable[''] = 75; // o barrato +// cTable[''] = 76; // ac + cTable[''] = 77; +// cTable[''] = 78; // ? rovesciato + cTable['?'] = 79; +// cTable[''] = 80; // ! rovesciato + cTable['!'] = 81; +// cTable[''] = 82; // 1/2 +// cTable[''] = 83; // 1/4 + cTable['('] = 84; + cTable[')'] = 85; + cTable[''] = 86; + cTable[''] = 87; +// cTable[''] = 88; // AE + cTable[':'] = 89; + cTable['%'] = 90; + cTable['&'] = 91; + cTable['/'] = 92; + cTable['+'] = 93; + cTable[';'] = 94; + cTable[','] = 95; + cTable['^'] = 96; + cTable['='] = 97; + cTable['_'] = 98; + cTable['*'] = 99; + cTable['.'] = 100; + + for (i = 0; i < 10; i++) + cTable['0'+i] = i+101; + cTable['\''] = 111; + + lTable[' '] = 11; + lTable[''] = lTable['A'] = 19; + lTable['B'] = 15; + lTable['C'] = 14; + lTable['D'] = 13; + lTable['E'] = 14; + lTable['F'] = 13; + lTable['G'] = 16; + lTable['H'] = 15; + lTable['I'] = 5; + lTable['J'] = 8; + lTable['K'] = 15; + lTable['L'] = 13; + lTable['M'] = 17; + lTable['N'] = 15; + lTable[''] = lTable['O'] = 14; + lTable['P'] = 12; + lTable['Q'] = 14; + lTable['R'] = 14; + lTable['S'] = 15; + lTable['T'] = 11; + lTable[''] = lTable['U'] = 12; + lTable['V'] = 12; + lTable['W'] = 16; + lTable['X'] = 12; + lTable['Y'] = 13; + lTable['Z'] = 14; + + lTable['a'] = 11; + lTable['b'] = 9; + lTable['c'] = 9; + lTable['d'] = 10; + lTable['e'] = 9; + lTable['f'] = 8; + lTable['g'] = 9; + lTable['h'] = 10; + lTable['i'] = 5; + lTable['j'] = 6; + lTable['k'] = 12; + lTable['l'] = 6; + lTable['m'] = 14; + lTable['n'] = 10; + lTable['o'] = 11; + lTable['p'] = 11; + lTable['q'] = 9; + lTable['r'] = 9; + lTable['s'] = 9; + lTable['t'] = 6; + lTable['u'] = 9; + lTable['v'] = 10; + lTable['w'] = 14; + lTable['x'] = 9; + lTable['y'] = 10; + lTable['z'] = 9; + + lTable['0'] = 12; + lTable['1'] = 8; + lTable['2'] = 10; + lTable['3'] = 11; + lTable['4'] = 12; + lTable['5'] = 11; + lTable['6'] = 12; + lTable['7'] = 10; + lTable['8'] = 11; + lTable['9'] = 10; + + lTable['/'] = 10; + lTable['^'] = 9; + lTable[','] = 5; + lTable['.'] = 5; + lTable[';'] = 5; + lTable[':'] = 5; + lTable['\''] = 5; + + + + // Polish characters + //AaCcEeLlNnOoSsZzZz + //ス謎戊3剔囀 + + cTable[''] = 112; + cTable[''] = 113; + cTable[''] = 114; + cTable[''] = 115; + cTable[''] = 116; + cTable[''] = 117; + cTable[''] = 118; + cTable[''] = 119; + cTable[''] = 120; + cTable[''] = 121; + cTable[''] = 122; + cTable[''] = 123; + cTable[''] = 124; + cTable[''] = 125; + cTable[''] = 126; + cTable[''] = 127; + cTable[''] = 128; + cTable[''] = 129; + + lTable[''] = 20; + lTable[''] = 12; + lTable[''] = 15; + lTable[''] = 10; + lTable[''] = 15; + lTable[''] = 10; + lTable[''] = 14; + lTable[''] = 11; + lTable[''] = 16; + lTable[''] = 10; + lTable[''] = 15; + lTable[''] = 11; + lTable[''] = 15; + lTable[''] = 10; + lTable[''] = 15; + lTable[''] = 10; + lTable[''] = 15; + lTable[''] = 10; + + +#ifdef FONT_RUSSIAN + // Russian Characters + // WARNING: Il russo usa molti dei caratteri ISO-Latin-1 che servono + // per le altre traduzioni. Per compilare Tony in altre lingue, + // commentare via queste definizioni. + + cTable[''] = 130; + cTable[''] = 131; + cTable[''] = 132; + cTable[''] = 133; + cTable[''] = 134; + cTable[''] = 135; + cTable[''] = 136; + cTable[''] = 137; + cTable[''] = 138; + cTable[''] = 139; + cTable[''] = 140; + cTable[''] = 141; + cTable[''] = 142; + cTable[''] = 143; + cTable[''] = 144; + cTable[''] = 145; + cTable[''] = 146; + cTable[''] = 147; + cTable[''] = 148; + cTable[''] = 149; + cTable[''] = 150; + cTable[''] = 151; + cTable[''] = 152; + cTable[''] = 153; + cTable[''] = 154; + cTable[''] = 155; + cTable[''] = 156; + cTable[''] = 157; + cTable[''] = 158; + cTable[''] = 159; + cTable[''] = 160; + cTable[''] = 161; + cTable[''] = 162; + + cTable[''] = 163; + cTable[''] = 164; + cTable[''] = 165; + cTable[''] = 166; + cTable[''] = 167; + cTable[''] = 168; + cTable[''] = 169; + cTable[''] = 170; + cTable[''] = 171; + cTable[''] = 172; + cTable[''] = 173; + cTable[''] = 174; + cTable[''] = 175; + cTable[''] = 176; + cTable[''] = 177; + cTable[''] = 178; + cTable[''] = 179; + cTable[''] = 180; + cTable[''] = 181; + cTable[''] = 182; + cTable[''] = 183; + cTable[''] = 184; + cTable[''] = 185; + cTable[''] = 186; + cTable[''] = 187; + cTable[''] = 188; + cTable[''] = 189; + cTable[''] = 190; + cTable[''] = 191; + cTable[''] = 192; + cTable[''] = 193; + cTable[''] = 194; + cTable[''] = 195; + + lTable[''] = 20; + lTable[''] = 16; + lTable[''] = 16; + lTable[''] = 14; + lTable[''] = 22; + lTable[''] = 15; + lTable[''] = 15; + lTable[''] = 20; + lTable[''] = 12; + lTable[''] = 16; + lTable[''] = 16; + lTable[''] = 16; + lTable[''] = 22; + lTable[''] = 18; + lTable[''] = 16; + lTable[''] = 15; + lTable[''] = 14; + lTable[''] = 13; + lTable[''] = 15; + lTable[''] = 12; + lTable[''] = 14; + lTable[''] = 15; + lTable[''] = 13; + lTable[''] = 16; + lTable[''] = 14; + lTable[''] = 23; + lTable[''] = 23; + lTable[''] = 10; + lTable[''] = 12; + lTable[''] = 16; + lTable[''] = 12; + lTable[''] = 20; + lTable[''] = 15; + + lTable[''] = 12; + lTable[''] = 10; + lTable[''] = 10; + lTable[''] = 11; + lTable[''] = 16; + lTable[''] = 10; + lTable[''] = 11; + lTable[''] = 13; + lTable[''] = 12; + lTable[''] = 13; + lTable[''] = 13; + lTable[''] = 12; + lTable[''] = 13; + lTable[''] = 14; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 12; + lTable[''] = 10; + lTable[''] = 10; + lTable[''] = 10; + lTable[''] = 11; + lTable[''] = 10; + lTable[''] = 11; + lTable[''] = 10; + lTable[''] = 15; + lTable[''] = 15; + lTable[''] = 10; + lTable[''] = 12; + lTable[''] = 16; + lTable[''] = 11; + lTable[''] = 13; + lTable[''] = 11; + +#endif // FONT_RUSSIAN + +#ifdef FONT_CZECH + + cTable[''] = 196; + cTable[''] = 197; + cTable[''] = 198; + cTable[''] = 199; + cTable[''] = 200; + cTable[''] = 201; + cTable[''] = 202; + cTable[''] = 203; + cTable[''] = 204; + cTable[''] = 205; + cTable[''] = 206; + cTable[''] = 207; + cTable[''] = 208; + cTable[''] = 209; + cTable[''] = 210; + + cTable[''] = 211; + cTable[''] = 212; + cTable[''] = 213; + cTable[''] = 214; + cTable[''] = 215; + cTable[''] = 216; + cTable[''] = 217; + cTable[''] = 218; + cTable[''] = 219; + cTable[''] = 220; + cTable[''] = 221; + cTable[''] = 222; + cTable[''] = 223; + cTable[''] = 224; + cTable[''] = 225; + + lTable[''] = 15; + lTable[''] = 15; + lTable[''] = 15; + lTable[''] = 15; + lTable[''] = 15; + lTable[''] = 14; + lTable[''] = 20; + lTable[''] = 7; + lTable[''] = 15; + lTable[''] = 20; + lTable[''] = 19; + lTable[''] = 16; + lTable[''] = 15; + lTable[''] = 13; + lTable[''] = 13; + + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 10; + lTable[''] = 12; + lTable[''] = 6; + lTable[''] = 10; + lTable[''] = 15; + lTable[''] = 12; + lTable[''] = 11; + lTable[''] = 11; + lTable[''] = 10; + lTable[''] = 10; + +#endif // FONT_CZECH + +#ifdef FONT_FRENCH + + cTable[''] = 226; + cTable[''] = 227; + cTable[''] = 228; + cTable[''] = 229; + cTable[''] = 230; + cTable[''] = 231; + cTable[''] = 232; + cTable[''] = 233; + + lTable[''] = 12; + lTable[''] = 10; + lTable[''] = 10; + lTable[''] = 6; + lTable[''] = 10; + lTable[''] = 10; + lTable[''] = 11; + lTable[''] = 11; + +#endif // FONT_FRENCH + +#ifdef FONT_GERMAN + cTable[''] = 234; + // 'SS' = 235 + + // old chars overrides + cTable[''] = cTable[''] = 55; + cTable[''] = cTable[''] = 67; + cTable[''] = cTable[''] = 71; + + lTable[''] = 11; + +#endif // FONT_GERMAN +} + + + +/***************************************************************************\ +* Metodi di RMFontObj +\****************************************************************************/ + +#define TOUPPER(a) ((a) >='a'&&(a)<='z'?(a)+'A'-'a':(a)) +#define TOLOWER(a) ((a) >='A'&&(a)<='Z'?(a)+'a'-'A':(a)) + +void RMFontObj::SetBothCase(int nChar, int nNext, signed char spiazz) { + l2Table[TOUPPER(nChar)][TOUPPER(nNext)] = spiazz; + l2Table[TOUPPER(nChar)][TOLOWER(nNext)] = spiazz; + l2Table[TOLOWER(nChar)][TOUPPER(nNext)] = spiazz; + l2Table[TOLOWER(nChar)][TOLOWER(nNext)] = spiazz; +} + + +void RMFontObj::Init(void) { + int i; + + //bernie: numero di caratteri nel font (solo maiuscolo) + int nchars = + 85 // base + + 9 // polish + + 33 // russian + + 15 // czech + + 0 // francais (no uppercase chars) + + 1; // deutsch + + + Load(RES_F_OBJ, nchars, 25, 30); + + // Inizializziamo le tabelline del cazzo + lDefault = 26; + hDefault = 30; + Common::fill(&l2Table[0][0], &l2Table[0][0] + (256 * 256), '\0'); + + for (i = 0; i < 256; i++) + { + cTable[i] = -1; + lTable[i] = lDefault; + } + + for (i = 0; i < 26; i++) + { + cTable['A'+i] = i+0; + cTable['a'+i] = i+0; + } + + for (i = 0; i < 10; i++) + cTable['0'+i] = i+26; + + cTable[','] = 36; + cTable[';'] = 37; + cTable['.'] = 38; + cTable[':'] = 39; + cTable['-'] = 40; + cTable['+'] = 41; + cTable['!'] = 42; + // cTable['!'] = 43; Esclamativo alla rovescia + cTable['?'] = 44; + //cTable['?'] = 45; Interrogativo alla rovescia + cTable['/'] = 46; + cTable['('] = 47; + cTable[')'] = 48; + cTable['='] = 49; + cTable['\''] = 50; + cTable['\"'] = 51; + cTable[''] = 52; + cTable['$'] = 53; + cTable['%'] = 54; + cTable['&'] = 55; + cTable['^'] = 56; + cTable['*'] = 57; + cTable['<'] = 58; + cTable[' > '] = 59; + cTable[''] = 60; + cTable[''] = 61; + cTable[''] = 62; + cTable[''] = 63; + //cTable[''] = 64; integrale + cTable[''] = 65; + cTable[''] = 66; + cTable[''] = 67; + cTable[''] = 68; + cTable[''] = 69; + cTable[''] = cTable[''] = 70; + cTable[''] = 71; + cTable[''] = 72; + cTable[''] = 73; + //cTable[' '] = 74; e cerchietto + cTable[''] = 75; + cTable[''] = 76; + //cTable[' '] = 77; i cerchietto + cTable[''] = 78; + cTable[''] = cTable[''] = 79; + //cTable[' '] = 80; o cerchietto + cTable[''] = 81; + cTable[''] = cTable[''] = 82; + //cTable[' '] = 83; u cerchietto + //cTable[' '] = 84; y dieresi + + /* Un po' di lunghezze */ + lTable[' '] = 11; + lTable['.'] = 8; + lTable['-'] = 12; + lTable['\''] = 8; + lTable['0'] = 20; + lTable['1'] = 20; + lTable['2'] = 15; + lTable['3'] = 20; + lTable['4'] = 20; + lTable['5'] = 20; + lTable['6'] = 20; + lTable['7'] = 20; + lTable['8'] = 20; + lTable['9'] = 20; + + + lTable['a'] = lTable['A'] = lTable[''] = lTable[''] = 17; + lTable['b'] = lTable['B'] = 17; + lTable['c'] = lTable['C'] = 19; + lTable['d'] = lTable['D'] = 17; + lTable['e'] = lTable['E'] = 15; + lTable['f'] = lTable['F'] = 17; + lTable['g'] = lTable['G'] = 19; + lTable['i'] = lTable['I'] = 16; + lTable['h'] = lTable['H'] = 17; + lTable['k'] = lTable['K'] = 17; + lTable['l'] = lTable['L'] = 14; + lTable['m'] = lTable['M'] = 19; + lTable['n'] = lTable['N'] = 17; + lTable['o'] = lTable['O'] = lTable[''] = lTable[''] = 19; + lTable['p'] = lTable['P'] = 17; + lTable['q'] = lTable['Q'] = 19; + lTable['r'] = lTable['R'] = 14; + lTable['s'] = lTable['S'] = 13; + lTable['t'] = lTable['T'] = 15; + lTable['u'] = lTable['U'] = lTable[''] = lTable[''] = 15; + lTable['v'] = lTable['V'] = 13; + lTable['x'] = lTable['X'] = 15; + lTable['y'] = lTable['Y'] = 13; + lTable['w'] = lTable['W'] = 19; + lTable['z'] = lTable['Z'] = 20; + lTable[''] = 17; + + /* Casi particolari */ + SetBothCase('C','C',2); + SetBothCase('A','T',-2); + SetBothCase('R','S',2); + SetBothCase('H','I',-2); + SetBothCase('T','S',2); + SetBothCase('O','R',2); + SetBothCase('O','L',2); + SetBothCase('O','G',2); + SetBothCase('Z','A',-1); + SetBothCase('R','R',1); + SetBothCase('R','U',3); + + + // Polish characters + //ス謎戊3剔囀 + //AaCcEeLlNnOoSsZzZz + cTable[''] = cTable[''] = 85; + lTable[''] = lTable[''] = 20; + + cTable[''] = cTable[''] = 86; + lTable[''] = lTable[''] = 22; + + cTable[''] = cTable[''] = 87; + lTable[''] = lTable[''] = 17; + + cTable[''] = cTable[''] = 88; + lTable[''] = lTable[''] = 19; + + cTable[''] = cTable[''] = 89; + lTable[''] = lTable[''] = 17; + + cTable[''] = cTable[''] = 90; + lTable[''] = lTable[''] = 22; + + cTable[''] = cTable[''] = 91; + lTable[''] = lTable[''] = 15; + + cTable[''] = cTable[''] = 92; + lTable[''] = lTable[''] = 21; + + cTable[''] = cTable[''] = 93; + lTable[''] = lTable[''] = 21; + + +#ifdef FONT_RUSSIAN + // Russian Characters + // WARNING: Il russo usa molti dei caratteri ISO-Latin-1 che servono + // per le altre traduzioni. Per compilare Tony in altre lingue, + // commentare via queste definizioni. + + cTable[''] = cTable[''] = 85; + lTable[''] = lTable[''] = 20; + + cTable[''] = cTable[''] =94; + cTable[''] = cTable[''] =95; + cTable[''] = cTable[''] =96; + cTable[''] = cTable[''] =97; + cTable[''] = cTable[''] =98; + cTable[''] = cTable[''] =99; + cTable[''] = cTable[''] =100; + cTable[''] = cTable[''] =101; + cTable[''] = cTable[''] =102; + cTable[''] = cTable[''] =103; + cTable[''] = cTable[''] =104; + cTable[''] = cTable[''] =105; + cTable[''] = cTable[''] =106; + cTable[''] = cTable[''] =107; + cTable[''] = cTable[''] =108; + cTable[''] = cTable[''] =109; + cTable[''] = cTable[''] =110; + cTable[''] = cTable[''] =111; + cTable[''] = cTable[''] =112; + cTable[''] = cTable[''] =113; + cTable[''] = cTable[''] =114; + cTable[''] = cTable[''] =115; + cTable[''] = cTable[''] =116; + cTable[''] = cTable[''] =117; + cTable[''] = cTable[''] =118; + cTable[''] = cTable[''] =119; + cTable[''] = cTable[''] =120; + cTable[''] = cTable[''] =121; + cTable[''] = cTable[''] =122; + cTable[''] = cTable[''] =123; + cTable[''] = cTable[''] =124; + cTable[''] = cTable[''] =125; + cTable[''] = cTable[''] =126; + + + lTable[''] = lTable[''] = 18; + lTable[''] = lTable[''] = 18; + lTable[''] = lTable[''] = 18; + lTable[''] = lTable[''] = 17; + lTable[''] = lTable[''] = 16; + lTable[''] = lTable[''] = 18; + lTable[''] = lTable[''] = 18; + lTable[''] = lTable[''] = 20; + lTable[''] = lTable[''] = 18; + lTable[''] = lTable[''] = 18; + lTable[''] = lTable[''] = 18; + lTable[''] = lTable[''] = 18; + lTable[''] = lTable[''] = 16; + lTable[''] = lTable[''] = 18; + lTable[''] = lTable[''] = 15; + lTable[''] = lTable[''] = 22; + lTable[''] = lTable[''] = 15; + lTable[''] = lTable[''] = 18; + lTable[''] = lTable[''] = 22; + lTable[''] = lTable[''] = 19; + lTable[''] = lTable[''] = 16; + lTable[''] = lTable[''] = 21; + lTable[''] = lTable[''] = 20; + lTable[''] = lTable[''] = 16; + lTable[''] = lTable[''] = 16; + lTable[''] = lTable[''] = 19; + lTable[''] = lTable[''] = 22; + lTable[''] = lTable[''] = 18; + lTable[''] = lTable[''] = 19; + lTable[''] = lTable[''] = 19; + lTable[''] = lTable[''] = 15; + lTable[''] = lTable[''] = 18; + lTable[''] = lTable[''] = 18; + +#endif // FONT_RUSSIAN + +#ifdef FONT_CZECH + // rep. ceca characters + + cTable[''] = cTable[''] = 127; + cTable[''] = cTable[''] = 128; + cTable[''] = cTable[''] = 129; + cTable[''] = cTable[''] = 130; + cTable[''] = cTable[''] = 131; + cTable[''] = cTable[''] = 132; + cTable[''] = cTable[''] = 133; + cTable[''] = cTable[''] = 134; + cTable[''] = cTable[''] = 135; + cTable[''] = cTable[''] = 136; + cTable[''] = cTable[''] = 137; + cTable[''] = cTable[''] = 138; + cTable[''] = cTable[''] = 139; + cTable[''] = cTable[''] = 140; + cTable[''] = cTable[''] = 141; + + lTable[''] = lTable[''] =17; + lTable[''] = lTable[''] =15; + lTable[''] = lTable[''] =22; + lTable[''] = lTable[''] =18; + lTable[''] = lTable[''] =21; + lTable[''] = lTable[''] =16; + lTable[''] = lTable[''] =18; + lTable[''] = lTable[''] =19; + lTable[''] = lTable[''] =17; + lTable[''] = lTable[''] =23; + lTable[''] = lTable[''] =24; + lTable[''] = lTable[''] =17; + lTable[''] = lTable[''] =22; + lTable[''] = lTable[''] =16; + lTable[''] = lTable[''] =16; + +#endif // FONT_CZECH + +#ifdef FONT_FRENCH + + // traduci le lettere accentate in lettere normali + + cTable[''] = cTable[''] = cTable[''] = 0; // a + lTable[''] = lTable[''] = lTable[''] = 17; + + cTable[''] = cTable[''] = 4; // e + lTable[''] = lTable[''] = 15; + + cTable[''] = cTable[''] = cTable[''] = 8; // i + lTable[''] = lTable[''] = lTable[''] = 16; + + cTable[''] = cTable[''] = cTable[''] = cTable[''] = 14; // o + lTable[''] = lTable[''] = lTable[''] = lTable[''] = 19; + + cTable[''] = cTable[''] = 20; // u + lTable[''] = lTable[''] = 15; + +#endif // FONT_FRENCH + +#ifdef FONT_GERMAN + cTable[''] = 142; + // SS = 143 + + lTable[''] = 24; +#endif // FONT_GERMAN +} + + +/****************************************************************************\ +* Metodi di RMText +\****************************************************************************/ + +RMFontColor *RMText::m_fonts[4] = { NULL, NULL, NULL, NULL }; +OSystem::MutexRef RMText::m_cs; +RMGfxClearTask RMText::m_clear; + +RMText::RMText() { + // Colore di default: bianco + m_r = m_g = m_b = 255; + + // Lunghezza di default + maxLineLength = 350; + + m_bTrasp0 = true; + aHorType = HCENTER; + aVerType = VTOP; + SetPriority(150); +} + +RMText::~RMText() { + +} + +void RMText::SetMaxLineLength(int max) { + maxLineLength = max; +} + +bool RMText::RemoveThis() { + // Qui possiamo fare i controlli sul numero di frame, sul tempo trascorso + // etc. + return true; +} + + +void RMText::WriteText(RMString text, int nFont, int *time) { + // Inizializza i font (una volta sola) + if (m_fonts[0] == NULL) { + m_fonts[0] = new RMFontParla; m_fonts[0]->Init(); + m_fonts[1] = new RMFontObj; m_fonts[1]->Init(); + m_fonts[2] = new RMFontMacc; m_fonts[2]->Init(); + m_fonts[3] = new RMFontCredits; m_fonts[3]->Init(); + } + + g_system->lockMutex(m_cs); + WriteText(text,m_fonts[nFont],time); + g_system->unlockMutex(m_cs); +} + + +void RMText::WriteText(RMString text, RMFontColor *font, int *time) { + RMGfxPrimitive *prim; + char *p, *old_p; + int i, j, x, y; + int len; + int numchar; + int width, height; + char *string; + int numlines; + + // Setta il colore di base + font->SetBaseColor(m_r, m_g, m_b); + + // Si autodistrugge il buffer prima di iniziare + Destroy(); + + // Se la stringa vuota, non fare nulla + if (text == NULL || text[0] == '\0') + return; + + // Divide la frase in linee. In questo ciclo, X contiene la lunghezza massima raggiunta da una linea + // e I il numero delle linee + string=p = text; + i = j = x = 0; + while (*p != '\0') { + j += font->StringLen(*p); + if (j > (((aHorType == HLEFTPAR) && (i > 0)) ? maxLineLength - 25 : maxLineLength)) { + j -= font->StringLen(*p, p[1]); + if (j > x) x = j; + + // Torna indietro al primo spazio utile + // + // BERNIE: nella versione originale le frasi contenenti + // parole che superano la larghezza di una riga causavano + // l'interruzione dell'intera frase. + // Questo workaround e' parziale: la parola troppo lunga + // viene spezzata bruscamente e si perde una lettera. + // Oltre allo spazio e' ammesso il wrap sul carattere '-'. + // + old_p = p; + while (*p != ' ' && *p != '-' && p > string) p--; + + if (p == string) + p = old_p; + + // Controlla se sono tutti spazi fino alla fine + while (*p == ' ' && *p != '\0') p++; + if (*p == '\0') + break; + p--; + i++; + *p = '\0'; + j = 0; + } + p++; + } + + if (j > x) x = j; + + i++; + numlines = i; + + // X=Lunghezza della linea piu' lunga. Controlla se puo' essere puttata a X1 + //x+=font->StringLen(-1)+1; // Meglio esagerare per sicurezza + x += 8; + + // Posizione di partenza per la surface: X1,Y + width = x; + height = (numlines - 1) * font->LetterHeight() + font->m_fontDimy; + + // Crea la surface + Create(width, height); + //AddPrim(new RMGfxPrimitive(&m_clear)); + Common::fill(m_buf, m_buf + width * height * 2, 0); + + p = string; + + y = 0; + numchar = 0; + for (; i > 0; i--) { + // Misura la lunghezza della linea + x = 0; + j = font->StringLen(RMString(p)); + + switch (aHorType) { + case HLEFT: + x = 0; + break; + + case HLEFTPAR: + if (i == numlines) + x=0; + else + x = 25; + break; + + case HCENTER: + x = width / 2 - j / 2; + break; + + case HRIGHT: + x = width - j - 1; + break; + } + + while (*p != '\0') { + if (*p == ' ') { + x += font->StringLen(*p); + p++; + continue; + } + + prim = font->MakeLetterPrimitive(*p, len); + prim->Dst().x1 = x; + prim->Dst().y1 = y; + AddPrim(prim); + + numchar++; + + x += font->StringLen(*p, p[1]); + p++; + } + p++; + y += font->LetterHeight(); + } + + if (time != NULL) + *time = 1000 + numchar * (11 - nCfgTextSpeed) * 14; +} + +void RMText::ClipOnScreen(RMGfxPrimitive *prim) { + // Cerca di non farlo uscire dallo schermo + if (prim->Dst().x1 < 5) prim->Dst().x1 = 5; + if (prim->Dst().y1 < 5) prim->Dst().y1 = 5; + if (prim->Dst().x1+m_dimx > 635) prim->Dst().x1 = 635 - m_dimx; + if (prim->Dst().y1+m_dimy > 475) prim->Dst().y1 = 475 - m_dimy; +} + +void RMText::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + // Allinea orizzontalmente + if (aHorType == HCENTER) + prim->Dst().TopLeft() -= RMPoint(m_dimx / 2, 0); + else if (aHorType == HRIGHT) + prim->Dst().TopLeft() -= RMPoint(m_dimx, 0); + + + // Alinea verticalemente + switch (aVerType) { + case VTOP: + break; + + case VCENTER: + prim->Dst().y1-=m_dimy/2; + break; + + case VBOTTOM: + prim->Dst().y1-=m_dimy; + break; + } + + ClipOnScreen(prim); + + RMGfxWoodyBuffer::Draw(bigBuf,prim); +} + +/****************************************************************************\ +* Metodi di RMTextDialog +\****************************************************************************/ + +RMTextDialog::RMTextDialog() : RMText() { + m_startTime = 0; + dst = RMPoint(0,0); + + m_bSkipStatus = true; + m_bShowed = true; + m_bForceTime = false; + m_bForceNoTime = false; + m_bAlwaysDisplay = false; + m_bNoTab = false; + hCustomSkip = INVALID_HANDLE_VALUE; + hCustomSkip2 = INVALID_HANDLE_VALUE; + m_input = NULL; + + // Crea l'evento di fine displaying + hEndDisplay = CreateEvent(NULL, false, false, NULL); +} + +RMTextDialog::~RMTextDialog() { + CloseHandle(hEndDisplay); +} + +void RMTextDialog::Show(void) { + m_bShowed = true; +} + +void RMTextDialog::Hide(void) { + m_bShowed = false; +} + +void RMTextDialog::WriteText(RMString text, int font, int *time) { + RMText::WriteText(text,font,&m_time); + + if (time != NULL) + *time = m_time; +} + +void RMTextDialog::WriteText(RMString text, RMFontColor *font, int *time) { + RMText::WriteText(text,font,&m_time); + + if (time != NULL) + *time = m_time; +} + + +void RMTextDialog::SetSkipStatus(bool bEnabled) { + m_bSkipStatus=bEnabled; +} + +void RMTextDialog::ForceTime(void) { + m_bForceTime = true; +} + +void RMTextDialog::ForceNoTime(void) { + m_bForceNoTime = true; +} + +void RMTextDialog::SetNoTab(void) { + m_bNoTab = true; +} + +void RMTextDialog::SetForcedTime(uint32 dwTime) { + m_time = dwTime; +} + +void RMTextDialog::SetAlwaysDisplay(void) { + m_bAlwaysDisplay = true; +} + +bool RMTextDialog::RemoveThis(void) { + // Frase NON di background + if (m_bSkipStatus) { + if (!(bCfgDubbing && hCustomSkip2 != INVALID_HANDLE_VALUE)) + if (bCfgTimerizedText) { + if (!m_bForceNoTime) + if (_vm->GetTime() > (uint32)m_time + m_startTime) + return true; + } + + if (!m_bNoTab) + if ((GetAsyncKeyState(Common::KEYCODE_TAB) & 0x8001) == 0x8001) + return true; + + if (!m_bNoTab) + if (m_input) + if (m_input->MouseLeftClicked() || m_input->MouseRightClicked()) + return true; + } + // Frase di background + else { + if (!(bCfgDubbing && hCustomSkip2 != INVALID_HANDLE_VALUE)) + if (!m_bForceNoTime) + if (_vm->GetTime() > (uint32)m_time + m_startTime) + return true; + } + + // Se il tempo forzato + if (m_bForceTime) + if (_vm->GetTime() > (uint32)m_time + m_startTime) + return true; + + if (hCustomSkip != INVALID_HANDLE_VALUE) + if (WaitForSingleObject(hCustomSkip, 0) == WAIT_OBJECT_0) + return true; + + if (bCfgDubbing && hCustomSkip2 != INVALID_HANDLE_VALUE) + if (WaitForSingleObject(hCustomSkip2,0) == WAIT_OBJECT_0) + return true; + + return false; +} + +void RMTextDialog::Unregister(void) { + RMGfxTask::Unregister(); + assert(m_nInList == 0); + SetEvent(hEndDisplay); +} + +void RMTextDialog::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + if (m_startTime == 0) + m_startTime = _vm->GetTime(); + + if (m_bShowed) { + if (bCfgSottotitoli || m_bAlwaysDisplay) { + prim->Dst().TopLeft() = dst; + RMText::Draw(bigBuf, prim); + } + } +} + +void RMTextDialog::SetCustomSkipHandle(HANDLE hCustom) { + hCustomSkip = hCustom; +} + +void RMTextDialog::SetCustomSkipHandle2(HANDLE hCustom) { + hCustomSkip2 = hCustom; +} + +void RMTextDialog::WaitForEndDisplay(void) { + WaitForSingleObject(hEndDisplay, INFINITE); +} + +void RMTextDialog::SetInput(RMInput *input) { + m_input = input; +} + +/****************************************************************************\ +* Metodi di RMTextDialogScrolling +\****************************************************************************/ + +RMTextDialogScrolling::RMTextDialogScrolling() { + curLoc = NULL; +} + +RMTextDialogScrolling::RMTextDialogScrolling(RMLocation *loc) { + curLoc = loc; + startScroll = loc->ScrollPosition(); +} + +RMTextDialogScrolling::~RMTextDialogScrolling() { +} + +void RMTextDialogScrolling::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + RMPoint curDst; + + curDst = dst; + + if (curLoc != NULL) + dst -= curLoc->ScrollPosition() - startScroll; + + RMTextDialog::Draw(bigBuf, prim); + + dst = curDst; +} + +void RMTextDialogScrolling::ClipOnScreen(RMGfxPrimitive *prim) { + // Non dobbiamo fare nulla! +} + + +/****************************************************************************\ +* Metodi di RMTextItemName +\****************************************************************************/ + +RMTextItemName::RMTextItemName() : RMText() { + m_item = NULL; + SetPriority(220); +} + +RMTextItemName::~RMTextItemName() { + +} + +void RMTextItemName::DoFrame(RMGfxTargetBuffer& bigBuf, RMLocation &loc, RMPointer &ptr, RMInventory &inv) { + RMString itemName; + RMItem *lastItem = m_item; + + // Si aggiunge alla lista se c'e' bisogno + if (!m_nInList) + bigBuf.AddPrim(new RMGfxPrimitive(this)); + + // Aggiorna le coordinate di scrolling + m_curscroll = loc.ScrollPosition(); + + // Controlla se siamo sopra l'inventario + if (inv.ItemInFocus(m_mpos)) + m_item = inv.WhichItemIsIn(m_mpos); + else + m_item = loc.WhichItemIsIn(m_mpos); + + itemName = ""; + + // Si fa dare il nuovo nome + if (m_item != NULL) + m_item->GetName(itemName); + + // Se lo scrive + WriteText(itemName, 1); + + // Se e' diverso dal precedente, e' il caso di aggiornare anche il puntatore con la WhichPointer + if (lastItem != m_item) + { + if (m_item == NULL) + ptr.SetSpecialPointer(RMPointer::PTR_NONE); + else { + HANDLE hThread = mpalQueryDoAction(20, m_item->MpalCode(), 0); + if (hThread == INVALID_HANDLE_VALUE) + ptr.SetSpecialPointer(RMPointer::PTR_NONE); + else + WaitForSingleObject(hThread,INFINITE); + } + } +} + + +void RMTextItemName::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + // Se non c'e' testo, e' inutile continuare + if (m_buf == NULL) + return; + + // Setta come coordinate destinazione quelle del mouse + prim->Dst().TopLeft() = m_mpos-RMPoint(0, 30); + + RMText::Draw(bigBuf,prim); +} + + +/****************************************************************************\ +* Metodi di RMDialogChoice +\****************************************************************************/ + +RMDialogChoice::RMDialogChoice() { + RMResRaw dlg1(RES_I_DLGTEXT); + RMResRaw dlg2(RES_I_DLGTEXTLINE); + RMRes dlgpal(RES_I_DLGTEXTPAL); + + DlgText.Init(dlg1, dlg1.Width(), dlg1.Height()); + DlgTextLine.Init(dlg2, dlg2.Width(), dlg2.Height()); + + DlgText.LoadPaletteWA(dlgpal); + DlgTextLine.LoadPaletteWA(dlgpal); + + hUnreg=CreateEvent(NULL, false, false, NULL); + bRemoveFromOT = false; +} + +RMDialogChoice::~RMDialogChoice() { + CloseHandle(hUnreg); +} + +void RMDialogChoice::Unregister(void) { + RMGfxWoodyBuffer::Unregister(); + assert(!m_nInList); + PulseEvent(hUnreg); + + bRemoveFromOT = false; +} + +void RMDialogChoice::Init(void) +{ + m_numChoices = 0; + m_drawedStrings = NULL; + m_ptDrawStrings = NULL; + m_curSelection = -1; + + Create(640, 477); + SetPriority(140); +} + + +void RMDialogChoice::Close(void) { + if (m_drawedStrings != NULL) { + delete[] m_drawedStrings; + m_drawedStrings = NULL; + } + + if (m_ptDrawStrings != NULL) { + delete[] m_ptDrawStrings; + m_ptDrawStrings = NULL; + } + + Destroy(); +} + +void RMDialogChoice::SetNumChoices(int num) { + int i; + + m_numChoices = num; + m_curAdded = 0; + + // Alloca lo spazio per le stringhe disegnate + m_drawedStrings = new RMText[num]; + m_ptDrawStrings = new RMPoint[num]; + + // Le inizializza + for (i = 0; i < m_numChoices; i++) { + m_drawedStrings[i].SetColor(0, 255, 0); + m_drawedStrings[i].SetAlignType(RMText::HLEFTPAR, RMText::VTOP); + m_drawedStrings[i].SetMaxLineLength(600); + m_drawedStrings[i].SetPriority(10); + } +} + +void RMDialogChoice::AddChoice(RMString string) { + // Si disegna la stringa + assert(m_curAdded < m_numChoices); + m_drawedStrings[m_curAdded++].WriteText(string,0); +} + +void RMDialogChoice::Prepare(void) { + int i; + RMPoint ptPos; + + AddPrim(new RMGfxPrimitive(&DlgText,RMPoint(0,0))); + AddPrim(new RMGfxPrimitive(&DlgTextLine,RMPoint(0,155))); + AddPrim(new RMGfxPrimitive(&DlgTextLine,RMPoint(0,155+83))); + AddPrim(new RMGfxPrimitive(&DlgTextLine,RMPoint(0,155+83+83))); + AddPrim(new RMGfxPrimitive(&DlgTextLine,RMPoint(0,155+83+83+83))); + + ptPos.Set(20,90); + + for (i = 0; i < m_numChoices; i++) { + AddPrim(new RMGfxPrimitive(&m_drawedStrings[i], ptPos)); + m_ptDrawStrings[i] = ptPos; + ptPos.Offset(0,m_drawedStrings[i].Dimy() + 15); + } + + DrawOT(); + ClearOT(); + + m_ptDrawPos.Set(0,480-ptPos.y); +} + +void RMDialogChoice::SetSelected(int pos) { + //uint16 * buf = (uint16 *)m_buf; + RMGfxBox box; + RMRect rc; + + if (pos == m_curSelection) + return; + + box.SetPriority(5); + + if (m_curSelection != -1) { + box.SetColor(0xCC, 0xCC, 0xFF); + rc.TopLeft()=RMPoint(18, m_ptDrawStrings[m_curSelection].y); + rc.BottomRight() = rc.TopLeft() + RMPoint(597, m_drawedStrings[m_curSelection].Dimy()); + AddPrim(new RMGfxPrimitive(&box, rc)); + + AddPrim(new RMGfxPrimitive(&m_drawedStrings[m_curSelection], m_ptDrawStrings[m_curSelection])); + DrawOT(); + ClearOT(); + } + + if (pos != -1) { + box.SetColor(100, 100, 100); + rc.TopLeft()=RMPoint(18, m_ptDrawStrings[pos].y); + rc.BottomRight() = rc.TopLeft()+RMPoint(597, m_drawedStrings[pos].Dimy()); + AddPrim(new RMGfxPrimitive(&box, rc)); + AddPrim(new RMGfxPrimitive(&m_drawedStrings[pos], m_ptDrawStrings[pos])); + } + + DrawOT(); + ClearOT(); + + m_curSelection = pos; +} + +void RMDialogChoice::Show(RMGfxTargetBuffer *bigBuf) { + Prepare(); + m_bShow = false; + + if (!m_nInList && bigBuf != NULL) + bigBuf->AddPrim(new RMGfxPrimitive(this)); + + if (0) { + m_bShow = true; + } else { + RMPoint destpt; + int deltay; + int starttime = _vm->GetTime(); + int elaps; + + deltay=480 - m_ptDrawPos.y; + destpt = m_ptDrawPos; + m_ptDrawPos.Set(0, 480); + + if (!m_nInList && bigBuf != NULL) + bigBuf->AddPrim(new RMGfxPrimitive(this)); + m_bShow = true; + + elaps = 0; + while (elaps < 700) { + MainWaitFrame(); + MainFreeze(); + elaps = _vm->GetTime() - starttime; + m_ptDrawPos.y = 480 - ((deltay * 100) / 700 * elaps) / 100; + MainUnfreeze(); + } + + m_ptDrawPos.y = destpt.y; + } +} + +void RMDialogChoice::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + if (m_bShow == false) + return; + + prim->SetDst(m_ptDrawPos); + RMGfxSourceBuffer16::Draw(bigBuf, prim); +} + + +void RMDialogChoice::Hide(void) { + if (1) { + int deltay; + int starttime = _vm->GetTime(); + int elaps; + + deltay=480 - m_ptDrawPos.y; + elaps = 0; + while (elaps < 700) { + MainWaitFrame(); + MainFreeze(); + elaps=_vm->GetTime()-starttime; + m_ptDrawPos.y=480-((deltay*100)/700*(700-elaps))/100; + MainUnfreeze(); + } + } + + m_bShow = false; + bRemoveFromOT = true; + WaitForSingleObject(hUnreg, INFINITE); +} + + +bool RMDialogChoice::RemoveThis(void) { + return bRemoveFromOT; +} + +void RMDialogChoice::DoFrame(RMPoint ptMousePos) { + int i; + + if (ptMousePos.y > m_ptDrawPos.y) { + for (i = 0; i < m_numChoices; i++) { + if ((ptMousePos.y >= m_ptDrawPos.y+m_ptDrawStrings[i].y) && (ptMousePos.y < m_ptDrawPos.y+m_ptDrawStrings[i].y+m_drawedStrings[i].Dimy())) { + SetSelected(i); + break; + } + } + + if (i == m_numChoices) + SetSelected(-1); + } +} + +int RMDialogChoice::GetSelection(void) { + return m_curSelection; +} + +} // End of namespace Tony diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 83c48bb938..141b993714 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -45,14 +45,1615 @@ * * **************************************************************************/ -#include "tony/loc.h" -#include "tony/utils.h" -#include "tony/mpal/lzo.h" +#include "common/scummsys.h" #include "tony/mpal/mpalutils.h" +#include "tony/adv.h" +#include "tony/loc.h" +#include "tony/tony.h" + +namespace Tony { + +using namespace ::Tony::MPAL; + +static char rcsid[] = "$Id: $"; + +extern bool bSkipSfxNoLoop; + + +/****************************************************************************\ +* Metodi di RMPalette +\****************************************************************************/ + +/****************************************************************************\ +* +* Function: friend RMDataStream &operator>>(RMDataStream &ds, +* RMPalette& pal); +* +* Description: Operatore di estrazione di palette da data stream +* +* Input: RMDataStream &ds Data stream +* RMPalette& pal Palette di destinazione +* +* Return: Reference allo stream +* +\****************************************************************************/ + +RMDataStream &operator>>(RMDataStream &ds, RMPalette &pal) { + ds.Read(pal.m_data,1024); + return ds; +} + +/****************************************************************************\ +* Metodi di RMSlot +\****************************************************************************/ + +/****************************************************************************\ +* +* Function: friend RMDataStream &operator>>(RMDataStream &ds, +* RMSlot& slot) +* +* Description: Operatore per estrarre uno slot di un pattern da un data +* stream +* +* Input: RMDataStream &ds Data stream +* RMSlot& slot Slot di destinazione +* +* Return: Reference allo stream +* +\****************************************************************************/ + +RMDataStream &operator>>(RMDataStream &ds, RMPattern::RMSlot &slot) { + slot.ReadFromStream(ds); + return ds; +} + + +void RMPattern::RMSlot::ReadFromStream(RMDataStream &ds, bool bLOX) { + byte type; + + // Type + ds >> type; + m_type = (RMPattern::RMSlotType)type; + + // Dati + ds >> m_data; + + // Posizione + ds >> m_pos; + + // Flag generica + ds >> m_flag; +} + + +/****************************************************************************\ +* Metodi di RMPattern +\****************************************************************************/ + +/****************************************************************************\ +* +* Function: friend RMDataStream &operator>>(RMDataStream &ds, +* RMPattern& pat) +* +* Description: Operatore per estrarre un pattern da un data stream +* +* Input: RMDataStream &ds Data stream +* RMPattern& pat Pattern di destinazione +* +* Return: Reference allo stream +* +\****************************************************************************/ + +RMDataStream &operator>>(RMDataStream &ds, RMPattern &pat) { + pat.ReadFromStream(ds); + return ds; +} + +void RMPattern::ReadFromStream(RMDataStream &ds, bool bLOX) { + int i; + + // Nome del pattern + if (!bLOX) + ds >> m_name; + + // Velocita' + ds >> m_speed; + + // Posizione + ds >> m_pos; + + // Flag di loop del pattern + ds >> m_bLoop; + + // Numero di slot + ds >> m_nSlots; + + // Creazione e lettura degli slot + m_slots = new RMSlot[m_nSlots]; + + for (i = 0; i < m_nSlots && !ds.IsError(); i++) { + if (bLOX) + m_slots[i].ReadFromStream(ds, true); + else + m_slots[i].ReadFromStream(ds, false); + } +} + +void RMPattern::UpdateCoord(void) { + m_curPos = m_pos + m_slots[m_nCurSlot].Pos(); +} + +void RMPattern::StopSfx(RMSfx *sfx) { + for (int i = 0; i < m_nSlots; i++) { + if (m_slots[i].m_type == SOUND) { + if (sfx[m_slots[i].m_data].m_name[0] == '_') + sfx[m_slots[i].m_data].Stop(); + else if (bSkipSfxNoLoop) + sfx[m_slots[i].m_data].Stop(); + } + } +} + +int RMPattern::Init(RMSfx *sfx, bool bPlayP0, byte *bFlag) { + int i; + + // Prendiamo il tempo corrente + m_nStartTime = _vm->GetTime(); + m_nCurSlot = 0; + + // Cerca il primo frame nel pattern + i = 0; + while (m_slots[i].m_type != SPRITE) { + assert(i + 1 < m_nSlots); + i++; + } + + m_nCurSlot = i; + m_nCurSprite = m_slots[i].m_data; + if (bFlag) + *bFlag = m_slots[i].m_flag; + + // Calcola le coordinate correnti + UpdateCoord(); + + // Controlla per il sonoro: + // Se sta alla slot 0, lo playa + // Se speed = 0, deve suonare solo se va in loop '_', oppure se specificato dal parametro + // Se speed! = 0, suona solo quelli in loop + for (i = 0;i < m_nSlots; i++) { + if (m_slots[i].m_type == SOUND) { + if (i == 0) + { + if (sfx[m_slots[i].m_data].m_name[0]=='_') + { + sfx[m_slots[i].m_data].SetVolume(m_slots[i].Pos().x); + sfx[m_slots[i].m_data].Play(true); + } + else + { + sfx[m_slots[i].m_data].SetVolume(m_slots[i].Pos().x); + sfx[m_slots[i].m_data].Play(); + } + } + else if (m_speed == 0) { + if (bPlayP0) { + sfx[m_slots[i].m_data].SetVolume(m_slots[i].Pos().x); + sfx[m_slots[i].m_data].Play(); + } else if (sfx[m_slots[i].m_data].m_name[0] == '_') { + sfx[m_slots[i].m_data].SetVolume(m_slots[i].Pos().x); + sfx[m_slots[i].m_data].Play(true); + } + } else { + if (m_bLoop && sfx[m_slots[i].m_data].m_name[0] == '_') { + sfx[m_slots[i].m_data].SetVolume(m_slots[i].Pos().x); + sfx[m_slots[i].m_data].Play(true); + } + } + } + } + + return m_nCurSprite; +} + +int RMPattern::Update(HANDLE hEndPattern, byte &bFlag, RMSfx *sfx) { + int CurTime = _vm->GetTime(); + + // Se la speed e' 0, il pattern non avanza mai + if (m_speed == 0) { + PulseEvent(hEndPattern); + bFlag=m_slots[m_nCurSlot].m_flag; + return m_nCurSprite; + } + + // E' arrivato il momento di cambiare slot? + while (m_nStartTime + m_speed <= (uint32)CurTime) { + m_nStartTime += m_speed; + if (m_slots[m_nCurSlot].m_type == SPRITE) + m_nCurSlot++; + if (m_nCurSlot == m_nSlots) { + m_nCurSlot = 0; + bFlag = m_slots[m_nCurSlot].m_flag; + PulseEvent(hEndPattern); + + // @@@ Se non c'e' loop avverte che il pattern e' finito + // Se non c'e' loop rimane sull'ultimo frame + if (!m_bLoop) { + m_nCurSlot = m_nSlots - 1; + bFlag = m_slots[m_nCurSlot].m_flag; + return m_nCurSprite; + } + } + + for (;;) { + switch (m_slots[m_nCurSlot].m_type) { + case SPRITE: + // Legge il prossimo sprite + m_nCurSprite = m_slots[m_nCurSlot].m_data; + + // Aggiorna le coordinate babbo+figlio + UpdateCoord(); + break; + + case SOUND: + if (sfx != NULL) { + sfx[m_slots[m_nCurSlot].m_data].SetVolume(m_slots[m_nCurSlot].Pos().x); + + if (sfx[m_slots[m_nCurSlot].m_data].m_name[0] != '_') + sfx[m_slots[m_nCurSlot].m_data].Play(false); + else + sfx[m_slots[m_nCurSlot].m_data].Play(true); + } + break; + + case COMMAND: + assert(0); + break; + + default: + assert(0); + break; + } + + if (m_slots[m_nCurSlot].m_type == SPRITE) + break; + m_nCurSlot++; + } + } + + // Ritorna lo sprite corrente + bFlag=m_slots[m_nCurSlot].m_flag; + return m_nCurSprite; +} + +RMPattern::RMPattern() { + m_slots = NULL; +} + +RMPattern::~RMPattern() { + if (m_slots != NULL) + { + delete[] m_slots; + m_slots = NULL; + } +} + + + + +/****************************************************************************\ +* Metodi di RMSprite +\****************************************************************************/ + +/****************************************************************************\ +* +* Function: friend RMDataStream &operator>>(RMDataStream &ds, +* RMSprite& sprite) +* +* Description: Operatore per estrarre uno sprite da un data stream +* +* Input: RMDataStream &ds Data stream +* RMItem &item Sprite di destinazione +* +* Return: Reference allo stream +* +\****************************************************************************/ + +RMDataStream &operator>>(RMDataStream &ds, RMSprite &sprite) { + sprite.ReadFromStream(ds); + return ds; +} + +void RMSprite::Init(RMGfxSourceBuffer *buf) { + m_buf = buf; +} + +void RMSprite::LOXGetSizeFromStream(RMDataStream &ds, int *dimx, int *dimy) { + int pos = ds.Pos(); + + ds >> *dimx >> *dimy; + + ds.Seek(pos, ds.START); +} + +void RMSprite::GetSizeFromStream(RMDataStream &ds, int *dimx, int *dimy) { + int pos = ds.Pos(); + + ds >> m_name; + ds >> *dimx >> *dimy; + + ds.Seek(pos, ds.START); +} + +void RMSprite::ReadFromStream(RMDataStream &ds, bool bLOX) { + int dimx,dimy; + + // Nome dello sprite + if (!bLOX) + ds >> m_name; + + // Dimensioni + ds >> dimx >> dimy; + + // Bouding box + ds >> m_rcBox; + + // Spazio inutilizzato + if (!bLOX) + ds+=32; + + // Crezione del buffer e lettura + m_buf->Init(ds, dimx,dimy); +} + +void RMSprite::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + m_buf->Draw(bigBuf, prim); +} + +void RMSprite::SetPalette(byte *buf) { + ((RMGfxSourceBufferPal*)m_buf)->LoadPalette(buf); +} + +RMSprite::RMSprite() { + m_buf= NULL; +} + +RMSprite::~RMSprite() { + if (m_buf) { + delete m_buf; + m_buf = NULL; + } +} + + +/****************************************************************************\ +* Metodi di RMSfx +\****************************************************************************/ + +/****************************************************************************\ +* +* Function: friend RMDataStream &operator>>(RMDataStream &ds, +* RMSfx &sfx) +* +* Description: Operatore per estrarre uno sfx da un data stream +* +* Input: RMDataStream &ds Data stream +* RMSfx &sfx Sfx di destinazione +* +* Return: Reference allo stream +* +\****************************************************************************/ + +RMDataStream &operator>>(RMDataStream &ds, RMSfx &sfx) { + sfx.ReadFromStream(ds); + return ds; +} + +void RMSfx::ReadFromStream(RMDataStream &ds, bool bLOX) { + char id[4]; + int size; + byte *raw; + + // Nome dello sfx + ds >> m_name; + + ds >> size; + + // Carica l'effetto sonoro dal buffer + ds.Read(id,4); + + // Controlla che sia un riff + assert(id[0] == 'R' && id[1] == 'I' && id[2] == 'F' && id[3] == 'F'); + + // Legge la dimensione + ds >> size; + + // Carica il wav + raw = new byte[size]; + ds.Read(raw, size); + + // Crea l'effetto sonoro + m_fx = _vm->CreateSFX(raw); + m_fx->SetLoop(false); + + // Cancella il buffer che non serve pi a nessuno + delete[] raw; +} + +RMSfx::RMSfx() { + m_fx = NULL; + m_bPlayingLoop = false; +} + +RMSfx::~RMSfx() { + if (m_fx) { + m_fx->Release(); + m_fx = NULL; + } +} + +void RMSfx::Play(bool bLoop) { + if (m_fx && !m_bPlayingLoop) { + m_fx->SetLoop(bLoop); + m_fx->Play(); + + if (bLoop) + m_bPlayingLoop=true; + } +} + +void RMSfx::SetVolume(int vol) { + if (m_fx) { + m_fx->SetVolume(vol); + } +} + +void RMSfx::Pause(bool bPause) { + if (m_fx) { + m_fx->Pause(bPause); + } +} + +void RMSfx::Stop(void) { + if (m_fx) { + m_fx->Stop(); + m_bPlayingLoop = false; + } +} + + + +/****************************************************************************\ +* Metodi di RMItem +\****************************************************************************/ + +/****************************************************************************\ +* +* Function: friend RMDataStream &operator>>(RMDataStream &ds, +* RMItem &item) +* +* Description: Operatore per estrarre un item da un data stream +* +* Input: RMDataStream &ds Data stream +* RMItem &item Item di destinazione +* +* Return: Reference allo stream +* +\****************************************************************************/ + +RMDataStream &operator>>(RMDataStream &ds, RMItem &item) { + item.ReadFromStream(ds); + return ds; +} + + +RMGfxSourceBuffer *RMItem::NewItemSpriteBuffer(int dimx, int dimy, bool bPreRLE) { + if (m_cm == CM_256) { + RMGfxSourceBuffer8RLE *spr; + + if (m_FX == 2) { // AB + spr = new RMGfxSourceBuffer8RLEWordAB; + } else if (m_FX == 1) { // OMBRA+AA + if (dimx == -1 || dimx > 255) + spr = new RMGfxSourceBuffer8RLEWordAA; + else + spr = new RMGfxSourceBuffer8RLEByteAA; + + spr->SetAlphaBlendColor(m_FXparm); + if (bPreRLE) + spr->SetAlreadyCompressed(); + } else { + if (dimx == -1 || dimx > 255) + spr = new RMGfxSourceBuffer8RLEWord; + else + spr = new RMGfxSourceBuffer8RLEByte; + + if (bPreRLE) + spr->SetAlreadyCompressed(); + } + + return spr; + } else + return new RMGfxSourceBuffer16; +} + +bool RMItem::IsIn(RMPoint pt, int *size) { + RMRect rc; + + if (!m_bIsActive) + return false; + + // Cerca il rettangolo giusto da usare, che quello dello sprite se ce l'ha, altrimenti + // quello generico dell'oggeto + if (m_nCurPattern != 0 && !m_sprites[m_nCurSprite].m_rcBox.IsEmpty()) + rc=m_sprites[m_nCurSprite].m_rcBox + CalculatePos(); + else if (!m_rcBox.IsEmpty()) + rc = m_rcBox; + // Se non ha box, esce subito + else + return false; + + if (size != NULL) + *size = rc.Size(); + + return rc.PtInRect(pt + m_curScroll); +} + + +void RMItem::ReadFromStream(RMDataStream &ds, bool bLOX) { + int i, dimx, dimy; + byte cm; + + // Codice mpal + ds >> m_mpalCode; + + // Nome dell'oggetto + ds >> m_name; + + // Z (signed) + ds >> m_z; + + // Posizione nonno + ds >> m_pos; + + // Hotspot + ds >> m_hot; + + // Bounding box + ds >> m_rcBox; + + // Numero sprite, effetti sonori e pattern + ds >> m_nSprites >> m_nSfx >> m_nPatterns; + + // Color mode + ds >> cm; m_cm=(RMColorMode)cm; + + // Flag di presenza della palette differnziata + ds >> m_bPal; + + if (m_cm == CM_256) { + // Se c'e' la palette, leggiamola + if (m_bPal) + ds >> m_pal; + } + + // Dati MPAL + if (!bLOX) + ds += 20; + + ds >> m_FX; + ds >> m_FXparm; + + if (!bLOX) + ds += 106; + + // Creazione delle classi + if (m_nSprites > 0) + m_sprites = new RMSprite[m_nSprites]; + if (m_nSfx > 0) + m_sfx = new RMSfx[m_nSfx]; + m_patterns = new RMPattern[m_nPatterns+1]; + + // Lettura delle classi + if (!ds.IsError()) + for (i = 0; i < m_nSprites && !ds.IsError(); i++) { + // Carica lo sprite + if (bLOX) { + m_sprites[i].LOXGetSizeFromStream(ds, &dimx, &dimy); + m_sprites[i].Init(NewItemSpriteBuffer(dimx, dimy, true)); + m_sprites[i].ReadFromStream(ds, true); + } else { + m_sprites[i].GetSizeFromStream(ds, &dimx, &dimy); + m_sprites[i].Init(NewItemSpriteBuffer(dimx, dimy, false)); + m_sprites[i].ReadFromStream(ds, false); + } + + if (m_cm == CM_256 && m_bPal) + m_sprites[i].SetPalette(m_pal.m_data); + } + + if (!ds.IsError()) + for (i = 0;i < m_nSfx && !ds.IsError(); i++) { + if (bLOX) + m_sfx[i].ReadFromStream(ds, true); + else + m_sfx[i].ReadFromStream(ds, false); + } + + // Leggiamo i pattern a partire dal pattern 1 + if (!ds.IsError()) + for (i = 1;i <= m_nPatterns && !ds.IsError(); i++) { + if (bLOX) + m_patterns[i].ReadFromStream(ds, true); + else + m_patterns[i].ReadFromStream(ds, false); + } + + // Inizializza il curpattern + if (m_bInitCurPattern) + SetPattern(mpalQueryItemPattern(m_mpalCode)); + + // Inizializza lo stato di attivazione + m_bIsActive=mpalQueryItemIsActive(m_mpalCode); +} + + +RMGfxPrimitive *RMItem::NewItemPrimitive() { + return new RMGfxPrimitive(this); +} + +void RMItem::SetScrollPosition(RMPoint scroll) { + m_curScroll = scroll; +} + +bool RMItem::DoFrame(RMGfxTargetBuffer *bigBuf, bool bAddToList) { + int oldSprite = m_nCurSprite; + + // Pattern 0 = Non disegnare nulla! + if (m_nCurPattern == 0) + return false; + + // Facciamo un update del pattern, che ci ritorna anche il frame corrente + if (m_nCurPattern != 0) + m_nCurSprite=m_patterns[m_nCurPattern].Update(m_hEndPattern,m_bCurFlag, m_sfx); + + // Se la funzione ha ritornato -1, vuol dire che il pattern e' finito + if (m_nCurSprite == -1) { + // Mettiamo il pattern 0, e usciamo. La classe si auto-deregistrera' della OT list + m_nCurPattern = 0; + return false; + } + + // Se non siamo in OT list, mettiamoci + if (!m_nInList && bAddToList) + bigBuf->AddPrim(NewItemPrimitive()); + + return oldSprite != m_nCurSprite; +} + +RMPoint RMItem::CalculatePos(void) { + return m_pos + m_patterns[m_nCurPattern].Pos(); +} + +void RMItem::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + // Se CurSprite == -1, allora e' finito il pattern + if (m_nCurSprite == -1) + return; + + // Settiamo la flag + prim->SetFlag(m_bCurFlag); + + // Offset inverso per lo scrolling + prim->Dst().Offset(-m_curScroll); + + // Dobbiamo sparaflashare le coordinate dell'item dentro la primitiva. + // Si calcola nonno+(babbo+figlio) + prim->Dst().Offset(CalculatePos()); + + // No stretching, please + prim->SetStrecth(false); + + // Ora la passiamo alla routine di drawing generica per surface + m_sprites[m_nCurSprite].Draw(bigBuf, prim); +} + + +bool RMItem::RemoveThis() { + // Rimuove dalla OT list se il frame corrente e' -1 (pattern finito) + return (m_nCurSprite == -1); +} + + +void RMItem::SetStatus(int nStatus) { + m_bIsActive = (nStatus>0); +} + +void RMItem::SetPattern(int nPattern, bool bPlayP0) { + int i; + + assert(nPattern >= 0 && nPattern <= m_nPatterns); + + if (m_sfx) + if (m_nCurPattern>0) + m_patterns[m_nCurPattern].StopSfx(m_sfx); + + // Si ricorda il pattern corrente + m_nCurPattern = nPattern; + + // Inizia il pattern per cominciare l'animazione + if (m_nCurPattern != 0) + m_nCurSprite = m_patterns[m_nCurPattern].Init(m_sfx, bPlayP0, &m_bCurFlag); + else { + m_nCurSprite = -1; + + // Cerca l'effetto sonoro per il pattern 0 + if (bPlayP0) + for (i = 0;i < m_nSfx; i++) + if (strcmp(m_sfx[i].m_name, "p0") == 0) + m_sfx[i].Play(); + } +} + + +bool RMItem::GetName(RMString& name) +{ + char buf[256]; + + mpalQueryItemName(m_mpalCode, buf); + name = buf; + if (buf[0] == '\0') + return false; + return true; +} + + +void RMItem::Unload(void) { + if (m_patterns != NULL) + { + delete[] m_patterns; + m_patterns = NULL; + } + + if (m_sprites != NULL) { + delete[] m_sprites; + m_sprites = NULL; + } + + if (m_sfx != NULL) { + delete[] m_sfx; + m_sfx = NULL; + } +} + +RMItem::RMItem() { + m_bCurFlag = 0; + m_patterns = NULL; + m_sprites = NULL; + m_sfx= NULL; + m_curScroll.Set(0, 0); + m_bInitCurPattern=true; + m_nCurPattern = 0; + + m_hEndPattern = CreateEvent(NULL, false, false, NULL); +} + +RMItem::~RMItem() { + Unload(); + CloseHandle(m_hEndPattern); +} + +void RMItem::WaitForEndPattern(HANDLE hCustomSkip) { + if (m_nCurPattern != 0) { + if (hCustomSkip == INVALID_HANDLE_VALUE) + WaitForSingleObject(m_hEndPattern,INFINITE); + else { + HANDLE h[2]; + + h[0] = hCustomSkip; + h[1] = m_hEndPattern; + WaitForMultipleObjects(2, h, false, INFINITE); + } + } +} + +void RMItem::ChangeHotspot(RMPoint pt) { + m_hot = pt; +} + +void RMItem::PlaySfx(int nSfx) { + if (nSfx < m_nSfx) + m_sfx[nSfx].Play(); +} + +void RMItem::PauseSound(bool bPause) { + int i; + + for (i = 0; i < m_nSfx; i++) + m_sfx[i].Pause(bPause); +} + + + +/****************************************************************************\ +* Metodi di RMWipe +\****************************************************************************/ + + +RMWipe::RMWipe() { + m_hUnregistered=CreateEvent(NULL,false,false,NULL); + m_hEndOfFade=CreateEvent(NULL,false,false,NULL); +} + +RMWipe::~RMWipe() { + CloseHandle(m_hUnregistered); + CloseHandle(m_hEndOfFade); +} + +int RMWipe::Priority(void) { + return 200; +} + +void RMWipe::Unregister(void) { + RMGfxTask::Unregister(); + assert(m_nInList == 0); + SetEvent(m_hUnregistered); +} + +bool RMWipe::RemoveThis(void) { + return m_bUnregister; +} + +void RMWipe::WaitForFadeEnd(void) { + WaitForSingleObject(m_hEndOfFade, INFINITE); + m_bEndFade = true; + m_bFading = false; + MainWaitFrame(); + MainWaitFrame(); +} + +void RMWipe::CloseFade(void) { +// m_bUnregister=true; +// WaitForSingleObject(m_hUnregistered,INFINITE); + m_wip0r.Unload(); +} + +void RMWipe::InitFade(int type) { + // Attiva il fade + m_bUnregister = false; + m_bEndFade = false; + + m_nFadeStep = 0; + + m_bMustRegister = true; + + RMRes res(RES_W_CERCHIO); + RMDataStream ds; + + ds.OpenBuffer(res); + ds >> m_wip0r; + ds.Close(); + + m_wip0r.SetPattern(1); + + m_bFading = true; +} + +void RMWipe::DoFrame(RMGfxTargetBuffer &bigBuf) { + if (m_bMustRegister) { + bigBuf.AddPrim(new RMGfxPrimitive(this)); + m_bMustRegister = false; + } + + if (m_bFading) + { + m_wip0r.DoFrame(&bigBuf, false); + + m_nFadeStep++; + + if (m_nFadeStep == 10) { + SetEvent(m_hEndOfFade); + } + } +} + +void RMWipe::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + if (m_bFading) { + m_wip0r.Draw(bigBuf, prim); + } + + if (m_bEndFade) + Common::fill((byte *)bigBuf, (byte *)bigBuf + bigBuf.Dimx() * bigBuf.Dimy() * 2, 0x0); +} + + + +/****************************************************************************\ +* Metodi di RMCharacter +\****************************************************************************/ + +/***************************************************************************/ +/* Cerca il percorso minimo tra due nodi del grafo di connessione dei BOX */ +/* Restituisce il percorso lungo pathlenght nel vettore path[] */ +/***************************************************************************/ + +short RMCharacter::FindPath(short source, short destination) { + // FIXME: Refactor + static RMBox BOX[MAXBOXES]; // Matrice di Adjacenza + static short COSTO[MAXBOXES]; // Costi per Nodo + static short VALIDO[MAXBOXES]; // 0:non valido 1:valido 2:saturo + static short NEXT[MAXBOXES]; // Prossimo Nodo + short i, j, k, costominimo, fine, errore = 0; + RMBoxLoc *cur; + + g_system->lockMutex(csMove); + + if (source == -1 || destination == -1) { + g_system->unlockMutex(csMove); + return 0; + } + + // Si fa dare i box + cur = theBoxes->GetBoxes(curLocation); + + // Effettua una copia di riserva per lavorarci + for (i = 0; i < cur->numbbox; i++) + memcpy(&BOX[i], &cur->boxes[i], sizeof(RMBox)); + + // Invalida tutti i Nodi + for (i = 0; i < cur->numbbox; i++) + VALIDO[i] = 0; + + // Prepara sorgente e variabili globali alla procedura + COSTO[source] = 0; + VALIDO[source] = 1; + fine = 0; + + // Ricerca del percorso minimo + while(!fine) { + costominimo = 32000; // risetta il costo minimo + errore = 1; // errore possibile + + // 1 ciclo : ricerca di possibili nuovi nodi + for (i = 0; i < cur->numbbox; i++) + if (VALIDO[i] == 1) { + errore = 0; // errore sfatato + j = 0; + while (((BOX[i].adj[j]) != 1) && (j < cur->numbbox)) + j++; + + if (j >= cur->numbbox) + VALIDO[i] = 2; // nodo saturo? + else { + NEXT[i] = j; + if (COSTO[i] + 1 < costominimo) + costominimo = COSTO[i] + 1; + } + } + + if (errore) + fine = 1; // tutti i nodi saturi + + // 2 ciclo : aggiunta nuovi nodi trovati , saturazione nodi vecchi + for (i = 0; i < cur->numbbox; i++) + if ((VALIDO[i] == 1) && ((COSTO[i] + 1) == costominimo)) { + BOX[i].adj[NEXT[i]] = 2; + COSTO[NEXT[i]] = costominimo; + VALIDO[NEXT[i]] = 1; + for (j = 0; j < cur->numbbox; j++) + if (BOX[j].adj[NEXT[i]] == 1) + BOX[j].adj[NEXT[i]] = 0; + + if (NEXT[i] == destination) + fine = 1; + } + } + + // Estrazione del percorso dalla matrice di adiacenza modificata + if (!errore) { + pathlenght = COSTO[destination]; + k = pathlenght; + path[k] = destination; + + while (path[k] != source) { + i = 0; + while (BOX[i].adj[path[k]] != 2) + i++; + k--; + path[k] = i; + } + + pathlenght++; + } + + g_system->unlockMutex(csMove); + + return !errore; +} + + +void RMCharacter::GoTo(RMPoint destcoord, bool bReversed) { + if (m_pos == destcoord) { + if (minpath == 0) { + Stop(); + PulseEvent(hEndOfPath); + return; + } + } + + status = WALK; + linestart = m_pos; + lineend = destcoord; + dx = linestart.x - lineend.x; + dy = linestart.y - lineend.y; + fx = dx; + fy = dy; + dx = ABS(dx); + dy = ABS(dy); + walkspeed = curSpeed; + walkcount = 0; + + if (bReversed) { + while (0) ; + } + + int nPatt = GetCurPattern(); + + if (dx > dy) { + slope = fy / fx; + if (lineend.x < linestart.x) + walkspeed = -walkspeed; + walkstatus = 1; + + // Cambia il proprio pattern per la nuova direzione + bNeedToStop = true; + if ((walkspeed < 0 && !bReversed) || (walkspeed >= 0 && bReversed)) { + if (nPatt != PAT_WALKLEFT) + SetPattern(PAT_WALKLEFT); + } else { + if (nPatt != PAT_WALKRIGHT) + SetPattern(PAT_WALKRIGHT); + } + } else { + slope = fx / fy; + if (lineend.y < linestart.y) + walkspeed = -walkspeed; + walkstatus = 0; + + bNeedToStop=true; + if ((walkspeed < 0 && !bReversed) || (walkspeed >= 0 && bReversed)) { + if (nPatt != PAT_WALKUP) + SetPattern(PAT_WALKUP); + } else { + if (nPatt != PAT_WALKDOWN) + SetPattern(PAT_WALKDOWN); + } + } + + olddx = dx; + olddy = dy; + + // ResetEvent(hTonyEndMovement); @@@ +} + + +RMPoint RMCharacter::Searching(char UP, char DOWN, char RIGHT, char LEFT, RMPoint punto) { + short passi, minimo; + RMPoint nuovo, trovato; + minimo = 32000; + + if (UP) { + nuovo = punto; + passi = 0; + while((InWhichBox(nuovo) == -1) && (nuovo.y >= 0)) { nuovo.y--; passi++; } + if ((InWhichBox(nuovo) != -1) && (passi < minimo)&& + FindPath(InWhichBox(m_pos), InWhichBox(nuovo))) { + minimo = passi; + nuovo.y--; // to avoid error? + trovato = nuovo; + } + } + + if (DOWN) { + nuovo = punto; + passi = 0; + while ((InWhichBox(nuovo) == -1) && (nuovo.y < 480)) { nuovo.y++; passi++; } + if ((InWhichBox(nuovo) != -1) && (passi < minimo) && + FindPath(InWhichBox(m_pos), InWhichBox(nuovo))) { + minimo = passi; + nuovo.y++; // to avoid error? + trovato = nuovo; + } + } + + if (RIGHT) { + nuovo = punto; + passi = 0; + while ((InWhichBox(nuovo) == -1) && (nuovo.x < 640)) { nuovo.x++; passi++; } + if ((InWhichBox(nuovo) != -1) && (passi < minimo) && + FindPath(InWhichBox(m_pos), InWhichBox(nuovo))) { + minimo = passi; + nuovo.x++; // to avoid error? + trovato = nuovo; + } + } + + if (LEFT) { + nuovo = punto; + passi = 0; + while ((InWhichBox(nuovo) == -1) && (nuovo.x >= 0)) { nuovo.x--; passi++; } + if ((InWhichBox(nuovo) != -1) && (passi < minimo) && + FindPath(InWhichBox(m_pos), InWhichBox(nuovo))) { + minimo = passi; + nuovo.x--; // to avoid error? + trovato = nuovo; + } + } + + if (minimo == 32000) trovato = punto; + return trovato; +} + + +RMPoint RMCharacter::NearestPoint(RMPoint punto) { +/* + RMPoint tofind; + signed short difx,dify; + + difx = m_pos.x-punto.x; + dify = m_pos.y-punto.y; + + if ((difx>0) && (dify>0)) tofind=Searching(0,1,1,0,punto); + if ((difx>0) && (dify<0)) tofind=Searching(1,0,1,0,punto); + if ((difx<0) && (dify>0)) tofind=Searching(0,1,0,1,punto); + if ((difx<0) && (dify<0)) tofind=Searching(1,0,0,1,punto); + + // potrebbero essere tolti? Pensaci @@@@ + if ((difx= = 0) && (dify>0)) tofind=Searching(0,1,1,1,punto); + if ((difx= = 0) && (dify<0)) tofind=Searching(1,0,1,1,punto); + if ((dify= = 0) && (difx>0)) tofind=Searching(1,1,1,0,punto); + if ((dify= = 0) && (difx<0)) tofind=Searching(1,1,0,1,punto); + + if ((dify= = 0) && (difx= = 0)) tofind=punto; + + return tofind; +*/ + return Searching(1, 1, 1, 1, punto); +} + + +short RMCharacter::ScanLine(RMPoint punto) { + int Ldx, Ldy, Lcount; + float Lfx, Lfy, Lslope; + RMPoint Lstart, Lend, Lscan; + signed char Lspeed, Lstatus; + + Lstart = m_pos; + Lend = punto; + Ldx = Lstart.x-Lend.x; + Ldy = Lstart.y-Lend.y; + Lfx = Ldx; + Lfy = Ldy; + Ldx = ABS(Ldx); + Ldy = ABS(Ldy); + Lspeed = 1; + Lcount = 0; + + if (Ldx > Ldy) { + Lslope = Lfy / Lfx; + if (Lend.x < Lstart.x) Lspeed = -Lspeed; + Lstatus = 1; + } else { + Lslope = Lfx / Lfy; + if (Lend.y < Lstart.y) Lspeed =- Lspeed; + Lstatus = 0; + } + + Lscan = Lstart; // Inizio scansione + while (InWhichBox(Lscan) != -1) { + Lcount++; + if (Lstatus) { + Ldx = Lspeed * Lcount; + Ldy = Lslope * Ldx; + } else { + Ldy = Lspeed * Lcount; + Ldx = Lslope * Ldy; + } + + Lscan.x = Lstart.x + Ldx; + Lscan.y = Lstart.y + Ldy; + + if ((ABS(Lscan.x - Lend.x) <= 1) && (ABS(Lscan.y - Lend.y) <= 1)) return 1; + } + + return 0; +} -namespace Tony { +// Calcola intersezioni tra la traiettoria rettilinea ed il pi vicino BBOX +RMPoint RMCharacter::InvScanLine(RMPoint punto) { + int Ldx, Ldy, Lcount; + float Lfx, Lfy, Lslope; + RMPoint Lstart, Lend, Lscan; + signed char Lspeed, Lstatus, Lbox = -1; -using namespace ::Tony::MPAL; + Lstart = punto; // Exchange! + Lend = m_pos; // :-) + Ldx = Lstart.x - Lend.x; + Ldy = Lstart.y - Lend.y; + Lfx = Ldx; + Lfy = Ldy; + Ldx = ABS(Ldx); + Ldy = ABS(Ldy); + Lspeed = 1; + Lcount = 0; + + if (Ldx > Ldy) { + Lslope = Lfy / Lfx; + if (Lend.x < Lstart.x) Lspeed = -Lspeed; + Lstatus=1; + } else { + Lslope = Lfx / Lfy; + if (Lend.y < Lstart.y) Lspeed = -Lspeed; + Lstatus = 0; + } + Lscan = Lstart; + + for (;;) { + if (InWhichBox(Lscan) != -1) { + if (InWhichBox(Lscan) != Lbox) { + if (InWhichBox(m_pos) == InWhichBox(Lscan) || FindPath(InWhichBox(m_pos),InWhichBox(Lscan))) + return Lscan; + else + Lbox = InWhichBox(Lscan); + } + } + + Lcount++; + if (Lstatus) { + Ldx = Lspeed * Lcount; + Ldy = Lslope * Ldx; + } else { + Ldy = Lspeed * Lcount; + Ldx = Lslope * Ldy; + } + Lscan.x = Lstart.x + Ldx; + Lscan.y = Lstart.y + Ldy; + } +} + + +/***************************************************************************/ +/* Ritorna la coordinata dell'HotSpot di uscita pi vicino al giocatore */ +/***************************************************************************/ + +RMPoint RMCharacter::NearestHotSpot(int sourcebox, int destbox) { + RMPoint puntocaldo; + short cc; + int x, y, distanzaminima; + distanzaminima = 10000000; + RMBoxLoc *cur = theBoxes->GetBoxes(curLocation); + + for (cc = 0; cc < cur->boxes[sourcebox].numhotspot; cc++) + if ((cur->boxes[sourcebox].hotspot[cc].destination) == destbox) { + x = ABS(cur->boxes[sourcebox].hotspot[cc].hotx - m_pos.x); + y = ABS(cur->boxes[sourcebox].hotspot[cc].hoty - m_pos.y); + + if ((x * x + y * y) < distanzaminima) { + distanzaminima = x * x + y * y; + puntocaldo.x = cur->boxes[sourcebox].hotspot[cc].hotx; + puntocaldo.y = cur->boxes[sourcebox].hotspot[cc].hoty; + } + } + + return puntocaldo; +} + +void RMCharacter::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + if (bDrawNow) { + prim->Dst() += m_fixedScroll; + + RMItem::Draw(bigBuf, prim); + } +} + +void RMCharacter::NewBoxEntered(int nBox) { + RMBoxLoc *cur; + bool bOldReverse; + + // Richiama la On ExitBox + mpalQueryDoAction(3, curLocation, curbox); + + cur = theBoxes->GetBoxes(curLocation); + bOldReverse = cur->boxes[curbox].bReversed; + curbox = nBox; + + // Se cambiata la Z, dobbiamo rimuoverlo dalla OT + if (cur->boxes[curbox].Zvalue != m_z) { + bRemoveFromOT = true; + m_z = cur->boxes[curbox].Zvalue; + } + + // Gestisce l'inversione del movimento SOLO se non siamo nel percorso minimo: se siamo in percorso + // minimo direttamente la DoFrame a farlo + if (bMovingWithoutMinpath) { + if ((cur->boxes[curbox].bReversed && !bOldReverse) || (!cur->boxes[curbox].bReversed && bOldReverse)) { + switch (GetCurPattern()) { + case PAT_WALKUP: + SetPattern(PAT_WALKDOWN); + break; + case PAT_WALKDOWN: + SetPattern(PAT_WALKUP); + break; + case PAT_WALKRIGHT: + SetPattern(PAT_WALKLEFT); + break; + case PAT_WALKLEFT: + SetPattern(PAT_WALKRIGHT); + break; + } + } + } + + // Richiama la On EnterBox + mpalQueryDoAction(2, curLocation, curbox); +} + +void RMCharacter::DoFrame(RMGfxTargetBuffer* bigBuf, int loc) { + bool bEndNow; + + bEndNow = false; + bEndOfPath = false; + bDrawNow = (curLocation == loc); + + g_system->lockMutex(csMove); + + // Se stiamo camminando... + if (status != STAND) { + // Se stiamo andando in orizzontale + if (walkstatus == 1) { + dx = walkspeed * walkcount; + dy = slope * dx; + m_pos.x = linestart.x + dx; + m_pos.y = linestart.y + dy; + + // Destra + if (((walkspeed > 0) && (m_pos.x > lineend.x)) || ((walkspeed < 0) && (m_pos.x < lineend.x))) { + m_pos = lineend; + status = STAND; + bEndNow = true; + } + } + + // Se stiamo andando in verticale + if (walkstatus == 0) { + dy = walkspeed * walkcount; + dx = slope * dy; + m_pos.x = linestart.x + dx; + m_pos.y = linestart.y + dy; + + // Basso + if (((walkspeed > 0) && (m_pos.y > lineend.y)) || ((walkspeed < 0) && (m_pos.y < lineend.y))) { + m_pos = lineend; + status = STAND; + bEndNow = true; + } + } + + // Controlla se il personaggio uscito dai BOX per errore, nel qual caso + // lo fa rientrare subito + if (InWhichBox(m_pos) == -1) { + m_pos.x = linestart.x + olddx; + m_pos.y = linestart.y + olddy; + } + + // Se siamo appena arrivati alla destinazione temporanea ed finito il percorso minimo, + // ci fermiamo definitivamente + if (bEndNow && minpath == 0) { + if (!bEndOfPath) + Stop(); + bEndOfPath = true; + PulseEvent(hEndOfPath); + } + + walkcount++; + + // Aggiorna la Z del personaggio @@@ bisognerebbe rimuoverlo solo se cambiata la Z + + // Controlla se abbiamo cambiato box + if (!theBoxes->IsInBox(curLocation, curbox, m_pos)) + NewBoxEntered(InWhichBox(m_pos)); + + // Aggiorna le vecchie coordinate + olddx = dx; + olddy = dy; + } + + // Se siamo fermi + if (status == STAND) { + // Controlliamo se c' ancora percorso minimo da calcolare + if (minpath == 1) { + RMBoxLoc *cur = theBoxes->GetBoxes(curLocation); + + // Se dobbiamo ancora attraversare un box + if (pathcount < pathlenght) { + // Controlliamo che il box su cui stiamo entrando sia attivo + if (cur->boxes[path[pathcount-1]].attivo) { + // Muoviti in linea retta verso l'hotspot pi vicino, tenendo conto del reversing please + // NEWBOX = path[pathcount-1] + GoTo(NearestHotSpot(path[pathcount-1], path[pathcount]), cur->boxes[path[pathcount-1]].bReversed); + pathcount++; + } else { + // Se il box disattivato, possiamo solo bloccare tutto + // @@@ Questo non dovrebbe pi avvenire, dato che abbiamo migliorato + // la ricerca del percorso minimo + minpath = 0; + if (!bEndOfPath) + Stop(); + bEndOfPath = true; + PulseEvent(hEndOfPath); + } + } else { + // Se siamo gi entrati nell'ultimo box, dobbiamo solo muoverci in linea retta verso il + // punto di arrivo + // NEWBOX = InWhichBox(pathend) + minpath = 0; + GoTo(pathend, cur->boxes[InWhichBox(pathend)].bReversed); + } + } + } + + g_system->unlockMutex(csMove); + + // Richiama il DoFrame dell'item + RMItem::DoFrame(bigBuf); +} + +void RMCharacter::Stop(void) { + bMoving = false; + + // Non si sa mai... + status = STAND; + minpath = 0; + + if (!bNeedToStop) + return; + + bNeedToStop = false; + + switch (GetCurPattern()) { + case PAT_WALKUP: + SetPattern(PAT_STANDUP); + break; + + case PAT_WALKDOWN: + SetPattern(PAT_STANDDOWN); + break; + + case PAT_WALKLEFT: + SetPattern(PAT_STANDLEFT); + break; + + case PAT_WALKRIGHT: + SetPattern(PAT_STANDRIGHT); + break; + + default: +// assert(0); +// MessageBox(NULL,"E' lo stesso errore di prima, ma non crasha","Ehi!",MB_OK); + SetPattern(PAT_STANDDOWN); + break; + } +} + +inline int RMCharacter::InWhichBox(RMPoint pt) { + return theBoxes->WhichBox(curLocation,pt); +} + + +bool RMCharacter::Move(RMPoint pt) { + RMPoint dest; + int numbox; + + bMoving = true; + + // Se 0,0, non fare nulla, anzi fermati + if (pt.x == 0 && pt.y == 0) { + minpath = 0; + status = STAND; + Stop(); + return true; + } + + // Se clicko fuori dai box + numbox = InWhichBox(pt); + if (numbox == -1) { + // Trova il punto pi vicino dentro i box + dest = NearestPoint(pt); + + // ???!?? + if (dest == pt) + dest = InvScanLine(pt); + + pt = dest; + numbox = InWhichBox(pt); + } + + RMBoxLoc *cur = theBoxes->GetBoxes(curLocation); + + minpath = 0; + status = STAND; + bMovingWithoutMinpath = true; + if (ScanLine(pt)) + GoTo(pt, cur->boxes[numbox].bReversed); + else if (FindPath(InWhichBox(m_pos), InWhichBox(pt))) { + bMovingWithoutMinpath = false; + minpath = 1; + pathcount = 1; + pathend = pt; + } else { + // @@@ Questo caso se un hotspot dentro un box + // ma non c' un path per arrivarci. Usiamo quindi + // la invscanline per cercare un punto intorno + dest = InvScanLine(pt); + pt = dest; + + if (ScanLine(pt)) + GoTo(pt,cur->boxes[numbox].bReversed); + else if (FindPath(InWhichBox(m_pos), InWhichBox(pt))) { + bMovingWithoutMinpath = false; + minpath = 1; + pathcount = 1; + pathend = pt; + return true; + } else + return false; + } + + return true; +} + +void RMCharacter::SetPosition(RMPoint pt, int newloc) { + RMBoxLoc *box; + + minpath = 0; + status = STAND; + m_pos = pt; + + if (newloc != -1) + curLocation = newloc; + + // Aggiorna la Z del personaggio + box = theBoxes->GetBoxes(curLocation); + curbox = InWhichBox(m_pos); + assert(curbox != -1); + m_z = box->boxes[curbox].Zvalue; + bRemoveFromOT = true; +} + +bool RMCharacter::RemoveThis(void) { + if (bRemoveFromOT) + return true; + + return RMItem::RemoveThis(); +} + +RMCharacter::RMCharacter() { +// InitializeCriticalSection(&csMove); + hEndOfPath = CreateEvent(NULL, false, false, NULL); + minpath = 0; + curSpeed = 3; + bRemoveFromOT = false; + bMoving = false; + + m_pos.Set(0, 0); +} + +RMCharacter::~RMCharacter() { +// DeleteCriticalSection(&csMove); + CloseHandle(hEndOfPath); +} + +void RMCharacter::LinkToBoxes(RMGameBoxes *boxes) { + theBoxes = boxes; +} /****************************************************************************\ * RMBox Methods @@ -94,7 +1695,7 @@ void RMBox::ReadFromStream(RMDataStream &ds) { } } -RMDataStream& operator>>(RMDataStream &ds, RMBox &box) { +RMDataStream &operator>>(RMDataStream &ds, RMBox &box) { box.ReadFromStream(ds); return ds; @@ -104,7 +1705,7 @@ RMDataStream& operator>>(RMDataStream &ds, RMBox &box) { * RMBoxLoc Methods \****************************************************************************/ -void RMBoxLoc::ReadFromStream(RMDataStream& ds) { +void RMBoxLoc::ReadFromStream(RMDataStream &ds) { int i; char buf[2]; byte ver; @@ -132,7 +1733,7 @@ void RMBoxLoc::RecalcAllAdj(void) { for (i = 0; i < numbbox; i++) { Common::fill(boxes[i].adj, boxes[i].adj + MAXBOXES, 0); - for (j=0; j < boxes[i].numhotspot; j++) + for (j = 0; j < boxes[i].numhotspot; j++) if (boxes[boxes[i].hotspot[j].destination].attivo) boxes[i].adj[boxes[i].hotspot[j].destination] = 1; } @@ -192,7 +1793,7 @@ int RMGameBoxes::WhichBox(int nLoc, RMPoint punto) { if (!cur) return -1; - for (i=0; inumbbox; i++) + for (i = 0; inumbbox; i++) if (cur->boxes[i].attivo) if ((punto.x >= cur->boxes[i].left) && (punto.x <= cur->boxes[i].right) && (punto.y >= cur->boxes[i].top) && (punto.y <= cur->boxes[i].bottom)) @@ -233,7 +1834,7 @@ void RMGameBoxes::SaveState(byte *state) { WRITE_LE_UINT32(state, m_allBoxes[i]->numbbox); state+=4; - for (j=0; j < m_allBoxes[i]->numbbox; j++) + for (j = 0; j < m_allBoxes[i]->numbbox; j++) *state++ = m_allBoxes[i]->boxes[j].attivo; } } @@ -254,8 +1855,7 @@ void RMGameBoxes::LoadState(byte *state) { nbox = READ_LE_UINT32(state); state += 4; - for (j=0; jnumbbox) m_allBoxes[i]->boxes[j].attivo = *state; @@ -266,4 +1866,451 @@ void RMGameBoxes::LoadState(byte *state) { } } +/****************************************************************************\ +* Metodi di RMLocation +\****************************************************************************/ + +/****************************************************************************\ +* +* Function: RMLocation::RMLocation(); +* +* Description: Costruttore standard +* +\****************************************************************************/ + +RMLocation::RMLocation() { + m_nItems = 0; + m_items = NULL; + m_buf = NULL; +} + + +/****************************************************************************\ +* +* Function: bool RMLocation::Load(char *lpszFileName); +* +* Description: Carica una locazione (.LOC) da un file di cui viene fornito +* il pathname. +* +* Input: char *lpszFileName Nome del file di dati +* +* Return: true se tutto OK, false in caso di errore +* +\****************************************************************************/ + +bool RMLocation::Load(const char *lpszFileName) { + Common::File f; + bool bRet; + + // Apre il file in lettura + if (!f.open(lpszFileName)) + return false; + + // Lo passa alla routine di loading da file aperto + bRet = Load(f); + + // Chiude il file + f.close(); + + return bRet; +} + + +/****************************************************************************\ +* +* Function: bool RMLocation::Load(HANDLE hFile); +* +* Description: Carica una locazione (.LOC) da un handle di file aperto +* +* Input: HANDLE hFile Handle del file +* +* Return: true se tutto OK, false in caso di errore +* +\****************************************************************************/ + +bool RMLocation::Load(Common::File &file) { + int size; +// byte *buf; +// uint32 dwReadBytes; + bool bRet; + + // Calcola la lunghezza del file + size = file.size(); + file.seek(0); + +/* + // Alloca la memoria per caricare il file in memoria + buf=(LPBYTE)GlobalAlloc(GMEM_FIXED,size); + + // Legge il file in memoria + ReadFile(hFile,buf,size,&dwReadBytes,0); + + // Parsing del file, utilizzando la funzione di load da memorira + bRet=Load(buf); + + // Free della memoria + GlobalFree(buf); +*/ + + RMFileStreamSlow fs; + + fs.OpenFile(file); + bRet = Load(fs); + fs.Close(); + + return bRet; +} + + +bool RMLocation::Load(const byte *buf) { + RMDataStream ds; + bool bRet; + + ds.OpenBuffer(buf); + bRet = Load(ds); + ds.Close(); + return bRet; +} + + + +/****************************************************************************\ +* +* Function: bool RMLocation::Load(byte *buf); +* +* Description: Carica una locazione (.LOC) parsando il file gia' caricato +* in memoria. +* +* Input: byte *buf Buffer con il file caricato +* +* Return: true se ok, false in caso di errore +* +\****************************************************************************/ + +bool RMLocation::Load(RMDataStream &ds) { + char id[3]; + int dimx, dimy; + byte ver; + byte cm; + int i; + + // Controlla l'ID + ds >> id[0] >> id[1] >> id[2]; + + // Controlla se siamo in un LOX + if (id[0] == 'L' && id[1] == 'O' && id[2] == 'X') + return LoadLOX(ds); + + // Altrimenti, controlla che sia un LOC normale + if (id[0] != 'L' || id[1] != 'O' || id[2] != 'C') + return false; + + // Versione + ds >> ver; + assert(ver == 6); + + // Nome della locazione + ds >> m_name; + + // Skippa i salvataggi MPAL (64 bytes) + ds >> TEMPNumLoc; + ds >> TEMPTonyStart.x >> TEMPTonyStart.y; + ds += 64 - 4 * 3; + + // Skippa il flag di background associato (?!) + ds += 1; + + // Dimensioni della locazione + ds >> dimx >> dimy; + m_curScroll.Set(0, 0); + + // Legge il color mode + ds >> cm; m_cmode = (RMColorMode)cm; + + // Inizializza il source buffer e leggi la locazione dentro + switch (m_cmode) { + case CM_256: + m_buf = new RMGfxSourceBuffer8; + break; + + case CM_65K: + m_buf = new RMGfxSourceBuffer16; + break; + + default: + assert(0); + break; + }; + + // Inizializza la surface, caricando anche la palette se necessario + m_buf->Init(ds, dimx, dimy, true); + + // Controlla le dimensioni della locazione +// assert(dimy!=512); + + // Numero oggetti + ds >> m_nItems; + + // Creazione e lettura degli oggetti + if (m_nItems > 0) + m_items = new RMItem[m_nItems]; + + + _vm->FreezeTime(); + for (i = 0;i < m_nItems && !ds.IsError(); i++) + ds >> m_items[i]; + _vm->UnfreezeTime(); + + // Setta i pattern iniziali @@@ doppione!! + //for (i = 0;i> ver; + assert(ver == 1); + + // Nome locazione + ds >> m_name; + + // Numero loc + ds >> TEMPNumLoc; + ds >> TEMPTonyStart.x >> TEMPTonyStart.y; + + // Dimensioni + ds >> dimx >> dimy; + m_curScroll.Set(0, 0); + + // Color mode sempre 65K + m_cmode = CM_65K; + m_buf = new RMGfxSourceBuffer16; + + // Inizializza la surface, caricando anche la palette se necessario + m_buf->Init(ds, dimx, dimy, true); + + // Controlla le dimensioni della locazione +// assert(dimy!=512); + + // Numero oggetti + ds >> m_nItems; + + // Creazione e lettura degli oggetti + if (m_nItems > 0) + m_items = new RMItem[m_nItems]; + + for (i = 0; i < m_nItems && !ds.IsError(); i++) + m_items[i].ReadFromStream(ds, true); + + return ds.IsError(); +} + + + +/****************************************************************************\ +* +* Function: void RMLocation::Draw(RMGfxTargetBuffer* bigBuf, +* RMGfxPrimitive* prim); +* +* Description: Metodo di drawing in overloading da RMGfxSourceBuffer8 +* +\****************************************************************************/ + +void RMLocation::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + // Setta la posizione sorgente dello scrolling + if (m_buf->Dimy()>RM_SY || m_buf->Dimx()>RM_SX) { + prim->SetSrc(RMRect(m_curScroll,m_curScroll+RMPoint(640,480))); + } + + prim->SetDst(m_fixedScroll); + + // Richiama il metodo di drawing della classe dell'immagine, che disegner il background + // della locazione + m_buf->Draw(bigBuf, prim); +} + + +/****************************************************************************\ +* +* Function: void RMLocation::DoFrame(void); +* +* Description: Prepara un frame, aggiungendo alla OTList la locazione stessa +* e tutti gli item che hanno cambiato frame di animazione +* +\****************************************************************************/ + +void RMLocation::DoFrame(RMGfxTargetBuffer *bigBuf) { + int i; + + // Se la locazione non e' in OT list, la aggiunge + if (!m_nInList) + bigBuf->AddPrim(new RMGfxPrimitive(this)); + + // Processa tutti gli item della locazione + for (i = 0;i < m_nItems; i++) + m_items[i].DoFrame(bigBuf); +} + + +RMItem *RMLocation::GetItemFromCode(uint32 dwCode) { + int i; + + for (i = 0; i < m_nItems; i++) + if (m_items[i].MpalCode() == (int)dwCode) + return &m_items[i]; + + return NULL; +} + +RMItem *RMLocation::WhichItemIsIn(RMPoint pt) { + int found = -1; + int foundSize = 0; + int size; + + for (int i = 0; i < m_nItems; i++) { + size = 0; + if (m_items[i].IsIn(pt, &size)) { + if (found == -1 || size < foundSize) { + foundSize = size; + found = i; + } + } + } + + if (found == -1) + return NULL; + else + return &m_items[found]; +} + + +RMLocation::~RMLocation() { + Unload(); +} + +void RMLocation::Unload(void) { + // Cancella la memoria + if (m_items) { + delete[] m_items; + m_items = NULL; + } + + // Cancella il buffer + if (m_buf) { + delete m_buf; + m_buf = NULL; + } +} + +void RMLocation::UpdateScrolling(RMPoint ptShowThis) { + RMPoint oldScroll = m_curScroll; + + if (m_curScroll.x + 250 > ptShowThis.x) { + m_curScroll.x = ptShowThis.x - 250; + } else if (m_curScroll.x + RM_SX - 250 < ptShowThis.x) { + m_curScroll.x = ptShowThis.x + 250 - RM_SX; + } else if (ABS(m_curScroll.x + RM_SX / 2 - ptShowThis.x) > 32 && m_buf->Dimx() > RM_SX) { + if (m_curScroll.x + RM_SX / 2 < ptShowThis.x) + m_curScroll.x++; + else + m_curScroll.x--; + } + + if (m_curScroll.y + 180 > ptShowThis.y) { + m_curScroll.y = ptShowThis.y - 180; + } else if (m_curScroll.y + RM_SY - 180 < ptShowThis.y) { + m_curScroll.y = ptShowThis.y + 180 - RM_SY; + } else if (ABS(m_curScroll.y + RM_SY / 2 - ptShowThis.y) > 16 && m_buf->Dimy() > RM_SY) { + if (m_curScroll.y + RM_SY / 2 < ptShowThis.y) + m_curScroll.y++; + else + m_curScroll.y--; + } + + if (m_curScroll.x < 0) m_curScroll.x = 0; + if (m_curScroll.y < 0) m_curScroll.y = 0; + if (m_curScroll.x + RM_SX > m_buf->Dimx()) m_curScroll.x = m_buf->Dimx() - RM_SX; + if (m_curScroll.y + RM_SY > m_buf->Dimy()) m_curScroll.y = m_buf->Dimy() - RM_SY; + + if (oldScroll != m_curScroll) + for (int i = 0; i < m_nItems; i++) + m_items[i].SetScrollPosition(m_curScroll); +} + +void RMLocation::SetFixedScroll(const RMPoint &scroll) { + m_fixedScroll = scroll; + + for (int i = 0; i < m_nItems; i++) + m_items[i].SetScrollPosition(m_curScroll - m_fixedScroll); +} + +void RMLocation::SetScrollPosition(const RMPoint &scroll) { + RMPoint pt = scroll; + if (pt.x < 0) pt.x = 0; + if (pt.y < 0) pt.y = 0; + if (pt.x + RM_SX>m_buf->Dimx()) pt.x = m_buf->Dimx() - RM_SX; + if (pt.y + RM_SY>m_buf->Dimy()) pt.y = m_buf->Dimy() - RM_SY; + + m_curScroll = pt; + + for (int i = 0; i < m_nItems; i++) + m_items[i].SetScrollPosition(m_curScroll); +} + + +void RMLocation::PauseSound(bool bPause) { + int i; + + for (i = 0; i < m_nItems; i++) + m_items[i].PauseSound(bPause); +} + + +/****************************************************************************\ +* Metodi di RMMessage +\****************************************************************************/ + +RMMessage::RMMessage(uint32 dwId) { + lpMessage=mpalQueryMessage(dwId); + assert(lpMessage != NULL); + + if (lpMessage) + ParseMessage(); +} + +RMMessage::~RMMessage() { + if (lpMessage) + GlobalFree(lpMessage); +} + +void RMMessage::ParseMessage(void) { + char *p; + + assert(lpMessage != NULL); + + nPeriods = 1; + p = lpPeriods[0] = lpMessage; + + for (;;) { + // Trova la fine del periodo corrente + while (*p != '\0') + p++; + + // Se c'e' un altro '\0' siamo alla fine del messaggio + p++; + if (*p == '\0') + break; + + // Altrimenti c'e' un altro periodo, e ci ricordiamo il suo inizio + lpPeriods[nPeriods++] = p; + } +} + } // End of namespace Tony diff --git a/engines/tony/loc.h b/engines/tony/loc.h index 73effc85c1..c5c7859e73 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -50,6 +50,7 @@ #include "common/scummsys.h" #include "common/system.h" +#include "common/file.h" #include "tony/mpal/stubs.h" #include "tony/sound.h" #include "tony/utils.h" @@ -539,8 +540,8 @@ public: virtual ~RMLocation(); // Caricamento da disco - bool Load(char *lpszFileName); - bool Load(HANDLE hFile); + bool Load(const char *lpszFileName); + bool Load(Common::File &file); bool Load(const byte *buf); bool Load(RMDataStream &ds); bool LoadLOX(RMDataStream &ds); diff --git a/engines/tony/utils.h b/engines/tony/utils.h index bd4b152f1f..f9c9e614ac 100644 --- a/engines/tony/utils.h +++ b/engines/tony/utils.h @@ -118,6 +118,56 @@ public: bool IsError(); }; + +/** + * Data stream per lettura di dati aperto da file + */ +class RMFileStream : public RMDataStream { +private: + byte *m_buf; + +public: + RMFileStream(); + virtual ~RMFileStream(); + + // Apre lo stream da file + bool OpenFile(const char *lpFN); + bool OpenFile(Common::File &file); + + void Close(void); +}; + + +class RMFileStreamSlow : public RMDataStream { +private: + Common::File f; + bool bMustClose; + +public: + RMFileStreamSlow(); + virtual ~RMFileStreamSlow(); + + bool OpenFile(const char *lpFN); + bool OpenFile(Common::File &file); + + void Close(void); + + RMDataStream& operator+=(int nBytes); + int Seek(int nBytes, RMDSPos where = CUR); + + int Pos(); + virtual bool IsEOF(); + + bool Read(void *buf, int size); + + friend RMFileStreamSlow& operator>>(RMFileStreamSlow &df, char &var); + friend RMFileStreamSlow& operator>>(RMFileStreamSlow &df, byte &var); + friend RMFileStreamSlow& operator>>(RMFileStreamSlow &df, uint16 &var); + friend RMFileStreamSlow& operator>>(RMFileStreamSlow &df, int16 &var); + friend RMFileStreamSlow& operator>>(RMFileStreamSlow &df, int &var); + friend RMFileStreamSlow& operator>>(RMFileStreamSlow &df, uint32 &var); +}; + /** * String class */ -- cgit v1.2.3 From 4ec3ccaf8af41dae15e4bc9a93299e70a4010dad Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 3 May 2012 01:36:08 +1000 Subject: TONY: Implemented other classes in game.cpp --- engines/tony/game.cpp | 1249 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 1247 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 109eefab24..d5047766bb 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -47,6 +47,7 @@ #include "common/file.h" #include "common/savefile.h" +#include "common/textconsole.h" #include "tony/mpal/lzo.h" #include "tony/mpal/memory.h" #include "tony/mpal/mpal.h" @@ -98,7 +99,7 @@ static char fname[_MAX_FNAME]; static char ext[_MAX_EXT]; HANDLE MainLoadLocation(int nLoc, RMPoint pt, RMPoint start) { - return _vm->GetEngine()->LoadLocation(nLoc,pt,start); + return _vm->GetEngine()->LoadLocation(nLoc, pt,start); } HANDLE MainUnloadLocation(bool bDoOnExit) { @@ -201,7 +202,7 @@ bool RMOptionButton::DoFrame(RMPoint mousePos, bool bLeftClick, bool bRightClick if (!m_bDoubleState) { if (m_rect.PtInRect(mousePos)) { if (!m_bActive) { - m_bActive=true; + m_bActive = true; return true; } } else { @@ -235,4 +236,1248 @@ void RMOptionButton::AddToList(RMGfxTargetBuffer &bigBuf) { bigBuf.AddPrim(new RMGfxPrimitive(this, m_rect)); } +/****************************************************************************\ +* Metodi di RMOptionSlide +\****************************************************************************/ + +RMOptionSlide::RMOptionSlide(RMPoint pt, int nRange, int nStartValue, int slideSize) { + RMResRaw *raw; + + m_pos = pt; + m_nSlideSize = slideSize; + m_nMax = nRange; + m_nStep = 100 / m_nMax; + m_nValue = nStartValue; + + m_SliderCenter = NULL; + m_SliderLeft = NULL; + m_SliderRight = NULL; + m_SliderSingle = NULL; + + // Sliders + INIT_GFX16_FROMRAW(20029, m_SliderCenter); + INIT_GFX16_FROMRAW(20030, m_SliderLeft); + INIT_GFX16_FROMRAW(20031, m_SliderRight); + INIT_GFX16_FROMRAW(20032, m_SliderSingle); + + // Buttons + m_PushLeft = new RMOptionButton(RMRect(pt.x - 23, pt.y, pt.x - 23 + 22, pt.y + 26)); + m_PushRight = new RMOptionButton(RMRect(pt.x + m_nSlideSize, pt.y, pt.x + m_nSlideSize + 5 + 22, pt.y + 26)); +} + + +RMOptionSlide::~RMOptionSlide() { + delete m_SliderCenter; + m_SliderCenter = NULL; + delete m_SliderLeft; + m_SliderLeft = NULL; + delete m_SliderRight; + m_SliderRight = NULL; + delete m_SliderSingle; + m_SliderSingle = NULL; + + delete m_PushLeft; + m_PushLeft = NULL; + delete m_PushRight; + m_PushRight = NULL; +} + +bool RMOptionSlide::DoFrame(RMPoint mousePos, bool bLeftClick, bool bRightClick) { + bool bRefresh = false; + + // Doframe dei bottoni + m_PushLeft->DoFrame(mousePos, bLeftClick, bRightClick); + m_PushRight->DoFrame(mousePos, bLeftClick, bRightClick); + + if (m_PushLeft->IsActive()) { + if (bLeftClick) { + bRefresh = true; + m_nValue--; + } else if (bRightClick) { + bRefresh = true; + m_nValue -= 3; + } + if (m_nValue < 1) + m_nValue = 1; + } else if (m_PushRight->IsActive()) { + bRefresh = true; + + if (bLeftClick) { + bRefresh = true; + m_nValue++; + } else if (bRightClick) { + bRefresh = true; + m_nValue += 3; + } + if (m_nValue > m_nMax) + m_nValue = m_nMax; + } + + return bRefresh; +} + +void RMOptionSlide::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + int i; + int val; + + RMPoint pos; + pos = m_pos; + pos.x += 4; + pos.y += 4; + + val = m_nValue * m_nStep; + if (val < 1) val = 1; + else if (val > 100) val = 100; + + if (val == 1) { + prim->SetDst(pos); + m_SliderSingle->Draw(bigBuf, prim); + } else { + prim->SetDst(pos); + m_SliderLeft->Draw(bigBuf, prim); + pos.x += 3; + + for (i = 1; i < val - 1; i++) { + prim->SetDst(pos); + m_SliderCenter->Draw(bigBuf, prim); + pos.x += 3; + } + + prim->SetDst(pos); + m_SliderRight->Draw(bigBuf, prim); + pos.x += 3; + } +} + +void RMOptionSlide::AddToList(RMGfxTargetBuffer &bigBuf) { + bigBuf.AddPrim(new RMGfxPrimitive(this)); +} + + + +/****************************************************************************\ +* Metodi di RMOptionScreen +\****************************************************************************/ + +RMOptionScreen::RMOptionScreen(void) { + m_nState = MENUGAME; + m_menu = NULL; + m_HideLoadSave = NULL; + m_QuitConfirm = NULL; + + Create(RM_SX, RM_SY); + + m_ButtonExit = NULL; + m_ButtonLoad = NULL; + m_ButtonSave = NULL; + m_ButtonGameMenu = NULL; + m_ButtonGfxMenu = NULL; + m_ButtonSoundMenu = NULL; + m_ButtonSave_ArrowLeft = NULL; + m_ButtonSave_ArrowRight = NULL; + m_bEditSaveName = false; + + int i; + + for (i = 0; i < 6; i++) { + m_curThumb[i] = NULL; + m_ButtonSave_States[i] = NULL; + } + + m_statePos = 0; +} + +RMOptionScreen::~RMOptionScreen(void) { +} + +void RMOptionScreen::RefreshAll(void) { + ClearOT(); + + AddPrim(new RMGfxPrimitive(m_menu)); + + if (m_bNoLoadSave) + AddPrim(new RMGfxPrimitive(m_HideLoadSave,RMPoint(0, 401))); + + if (m_bQuitConfirm) + { + AddPrim(new RMGfxPrimitive(m_QuitConfirm,RMPoint(270, 200))); + m_ButtonQuitYes->AddToList(*this); + m_ButtonQuitNo->AddToList(*this); + } + + m_ButtonExit->AddToList(*this); + + if (m_nState == MENUGAME || m_nState == MENUGFX || m_nState == MENUSOUND) { + m_ButtonQuit->AddToList(*this); + m_ButtonLoad->AddToList(*this); + m_ButtonSave->AddToList(*this); + } + + if (m_nState == MENUGAME) { + m_ButtonGame_Lock->AddToList(*this); + m_ButtonGame_TimerizedText->AddToList(*this); + m_ButtonGame_Scrolling->AddToList(*this); + m_ButtonGame_InterUp->AddToList(*this); + m_SlideTextSpeed->AddToList(*this); + m_SlideTonySpeed->AddToList(*this); + } else if (m_nState == MENUGFX) { + m_ButtonGfx_Anni30->AddToList(*this); + m_ButtonGfx_AntiAlias->AddToList(*this); + m_ButtonGfx_Sottotitoli->AddToList(*this); + m_ButtonGfx_Trans->AddToList(*this); + m_ButtonGfx_Tips->AddToList(*this); + } else if (m_nState == MENUSOUND) { + m_SliderSound_Dubbing->AddToList(*this); + m_SliderSound_Music->AddToList(*this); + m_SliderSound_SFX->AddToList(*this); + m_ButtonSound_DubbingOn->AddToList(*this); + m_ButtonSound_MusicOn->AddToList(*this); + m_ButtonSound_SFXOn->AddToList(*this); + } + + RMGfxSourceBuffer16 *thumb = NULL; + RMText* title = NULL; + RMText* num[6] = { NULL, NULL, NULL, NULL, NULL, NULL }; + int i; + + if (m_nState == MENULOAD || m_nState == MENUSAVE) { + title = new RMText; + if (m_nState == MENULOAD) { + RMMessage msg(10); + title->WriteText(msg[0], 1); + } else { + RMMessage msg(11); + title->WriteText(msg[0], 1); + } + + AddPrim(new RMGfxPrimitive(title, RMPoint(320, 10))); + + if (m_curThumbDiff[0] == 0) AddPrim(new RMGfxPrimitive(m_SaveHard, RMPoint(48, 57))); + else if (m_curThumbDiff[0] == 1) AddPrim(new RMGfxPrimitive(m_SaveEasy, RMPoint(48, 57))); + if (m_curThumbDiff[1] == 0) AddPrim(new RMGfxPrimitive(m_SaveHard, RMPoint(240, 57))); + else if (m_curThumbDiff[1] == 1) AddPrim(new RMGfxPrimitive(m_SaveEasy,RMPoint(240, 57))); + if (m_curThumbDiff[2] == 0) AddPrim(new RMGfxPrimitive(m_SaveHard,RMPoint(432, 57))); + else if (m_curThumbDiff[2] == 1) AddPrim(new RMGfxPrimitive(m_SaveEasy,RMPoint(432, 57))); + if (m_curThumbDiff[3] == 0) AddPrim(new RMGfxPrimitive(m_SaveHard,RMPoint(48, 239))); + else if (m_curThumbDiff[3] == 1) AddPrim(new RMGfxPrimitive(m_SaveEasy,RMPoint(48, 239))); + if (m_curThumbDiff[4] == 0) AddPrim(new RMGfxPrimitive(m_SaveHard,RMPoint(240, 239))); + else if (m_curThumbDiff[4] == 1) AddPrim(new RMGfxPrimitive(m_SaveEasy,RMPoint(240, 239))); + if (m_curThumbDiff[5] == 0) AddPrim(new RMGfxPrimitive(m_SaveHard,RMPoint(432, 239))); + else if (m_curThumbDiff[5] == 1) AddPrim(new RMGfxPrimitive(m_SaveEasy,RMPoint(432, 239))); + + if (m_curThumb[0] && !(m_bEditSaveName && m_nEditPos == 0)) AddPrim(new RMGfxPrimitive(m_curThumb[0], RMPoint(48, 57))); + if (m_curThumb[1] && !(m_bEditSaveName && m_nEditPos == 1)) AddPrim(new RMGfxPrimitive(m_curThumb[1], RMPoint(240, 57))); + if (m_curThumb[2] && !(m_bEditSaveName && m_nEditPos == 2)) AddPrim(new RMGfxPrimitive(m_curThumb[2], RMPoint(432, 57))); + if (m_curThumb[3] && !(m_bEditSaveName && m_nEditPos == 3)) AddPrim(new RMGfxPrimitive(m_curThumb[3], RMPoint(48, 239))); + if (m_curThumb[4] && !(m_bEditSaveName && m_nEditPos == 4)) AddPrim(new RMGfxPrimitive(m_curThumb[4], RMPoint(240, 239))); + if (m_curThumb[5] && !(m_bEditSaveName && m_nEditPos == 5)) AddPrim(new RMGfxPrimitive(m_curThumb[5], RMPoint(432, 239))); + + if (m_bEditSaveName) { + thumb = new RMGfxSourceBuffer16; + thumb->Init((byte *)_vm->GetThumbnail(), 640 / 4, 480 / 4); + + switch (m_nEditPos) { + case 0: AddPrim(new RMGfxPrimitive(thumb,RMPoint(48, 57))); break; + case 1: AddPrim(new RMGfxPrimitive(thumb,RMPoint(240, 57))); break; + case 2: AddPrim(new RMGfxPrimitive(thumb,RMPoint(432, 57))); break; + case 3: AddPrim(new RMGfxPrimitive(thumb,RMPoint(48, 239))); break; + case 4: AddPrim(new RMGfxPrimitive(thumb,RMPoint(240, 239))); break; + case 5: AddPrim(new RMGfxPrimitive(thumb,RMPoint(432, 239))); break; + } + } + + for (i = 0; i < 6; i++) { + RMString s; + + if (m_bEditSaveName && m_nEditPos == i) + s.Format("%02d)%s*", m_statePos + i, m_EditName); + else { + if (m_statePos == 0 && i == 0) + s.Format("Autosave"); + else + s.Format("%02d)%s", m_statePos + i, m_curThumbName[i]); + } + + num[i] = new RMText; + num[i]->SetAlignType(RMText::HLEFT, RMText::VTOP); + num[i]->WriteText(s, 2); + } + + AddPrim(new RMGfxPrimitive(num[0], RMPoint(55 - 3, 180 + 14))); + AddPrim(new RMGfxPrimitive(num[1], RMPoint(247 - 3, 180 + 14))); + AddPrim(new RMGfxPrimitive(num[2],RMPoint(439 - 3, 180 + 14))); + AddPrim(new RMGfxPrimitive(num[3],RMPoint(55 - 3, 362 + 14))); + AddPrim(new RMGfxPrimitive(num[4],RMPoint(247 - 3, 362 + 14))); + AddPrim(new RMGfxPrimitive(num[5],RMPoint(439 - 3, 362 + 14))); + + m_ButtonSave_ArrowLeft->AddToList(*this); + m_ButtonSave_ArrowRight->AddToList(*this); + } + + DrawOT(); + + if (m_nState == MENULOAD || m_nState == MENUSAVE) { + if (thumb) delete thumb; + if (title) delete title; + + for (i = 0; i < 6; i++) + if (num[i]) delete num[i]; + } +} + +void RMOptionScreen::RefreshThumbnails(void) { + int i; + + for (i = 0; i < 6; i++) { + if (m_curThumb[i]) + delete m_curThumb[i]; + + m_curThumb[i] = new RMGfxSourceBuffer16; + m_curThumb[i]->Create(640 / 4, 480 / 4); + if (!LoadThumbnailFromSaveState(m_statePos + i, *m_curThumb[i], m_curThumbName[i], m_curThumbDiff[i])) { + delete m_curThumb[i]; + m_curThumb[i] = NULL; + m_curThumbName[i] = ""; + m_curThumbDiff[i] = 11; + } + } +} + + +void RMOptionScreen::InitState(void) { + RMResRaw *raw; + + if (m_nState == MENUGAME || m_nState == MENUGFX || m_nState == MENUSOUND) + raw = new RMResRaw(20000 + m_nState); + else if (m_nState == MENULOAD || m_nState == MENUSAVE) { + if (m_bAlterGfx) + raw = new RMResRaw(20024); + else + raw = new RMResRaw(20003); + } else { + error("Invalid state"); + } + + assert(raw->IsValid()); + assert(m_menu == NULL); + m_menu = new RMGfxSourceBuffer16(false); + m_menu->Init(*raw, raw->Width(), raw->Height()); + delete raw; + + if (m_nState == MENULOAD || m_nState == MENUSAVE) { + if (m_bAlterGfx) { + assert(m_ButtonExit == NULL); + m_ButtonExit = new RMOptionButton(20025, RMPoint(561, 406)); + } + else + { + assert(m_ButtonExit == NULL); + m_ButtonExit = new RMOptionButton(20012, RMPoint(560, 404)); + } + + INIT_GFX8_FROMRAW(20036, m_SaveEasy); + INIT_GFX8_FROMRAW(20037, m_SaveHard); + + RefreshThumbnails(); + + assert(m_ButtonSave_States[0] == NULL); + m_ButtonSave_States[0] = new RMOptionButton(RMRect(48, 57, 48 + 160, 57 + 120)); + assert(m_ButtonSave_States[1] == NULL); + m_ButtonSave_States[1] = new RMOptionButton(RMRect(240, 57, 240 + 160, 57 + 120)); + assert(m_ButtonSave_States[2] == NULL); + m_ButtonSave_States[2] = new RMOptionButton(RMRect(432, 57, 432 + 160, 57 + 120)); + assert(m_ButtonSave_States[3] == NULL); + m_ButtonSave_States[3] = new RMOptionButton(RMRect(48, 239, 48 + 160, 239 + 120)); + assert(m_ButtonSave_States[4] == NULL); + m_ButtonSave_States[4] = new RMOptionButton(RMRect(240, 239, 240 + 160, 239 + 120)); + assert(m_ButtonSave_States[5] == NULL); + m_ButtonSave_States[5] = new RMOptionButton(RMRect(432, 239, 432 + 160, 239 + 120)); + + if (m_bAlterGfx) { + assert(m_ButtonSave_ArrowLeft == NULL); + m_ButtonSave_ArrowLeft = new RMOptionButton(20026,RMPoint(3,196)); + assert(m_ButtonSave_ArrowRight == NULL); + m_ButtonSave_ArrowRight = new RMOptionButton(20027, RMPoint(601, 197)); + } else { + assert(m_ButtonSave_ArrowLeft == NULL); + m_ButtonSave_ArrowLeft = new RMOptionButton(20013, RMPoint(0, 197)); + assert(m_ButtonSave_ArrowRight == NULL); + m_ButtonSave_ArrowRight = new RMOptionButton(20014,RMPoint(601, 197)); + } + } else if (m_nState == MENUGAME || m_nState == MENUGFX || m_nState == MENUSOUND) { + assert(m_ButtonExit == NULL); + m_ButtonExit = new RMOptionButton(20005, RMPoint(560, 405)); + assert(m_ButtonQuit == NULL); + m_ButtonQuit = new RMOptionButton(20020, RMPoint(7, 408)); + assert(m_ButtonLoad == NULL); + m_ButtonLoad = new RMOptionButton(20006, RMPoint(231, 401)); + assert(m_ButtonSave == NULL); + m_ButtonSave = new RMOptionButton(20007, RMPoint(325, 401)); + + assert(m_ButtonGameMenu == NULL); + m_ButtonGameMenu = new RMOptionButton(RMRect(24, 32, 118, 64)); + assert(m_ButtonGfxMenu == NULL); + m_ButtonGfxMenu = new RMOptionButton(RMRect(118, 32, 212, 64)); + assert(m_ButtonSoundMenu == NULL); + m_ButtonSoundMenu = new RMOptionButton(RMRect(212, 32, 306, 64)); + + raw = new RMResRaw(20021); + assert(raw->IsValid()); + assert(m_QuitConfirm == NULL); + m_QuitConfirm = new RMGfxSourceBuffer16(false); + m_QuitConfirm->Init(*raw, raw->Width(), raw->Height()); + delete raw; + + assert(m_ButtonQuitYes == NULL); + m_ButtonQuitYes = new RMOptionButton(20022, RMPoint(281, 265)); + m_ButtonQuitYes->SetPriority(30); + assert(m_ButtonQuitNo == NULL); + m_ButtonQuitNo = new RMOptionButton(20023,RMPoint(337, 264)); + m_ButtonQuitNo->SetPriority(30); + + if (m_bNoLoadSave) { + raw = new RMResRaw(20028); + assert(raw->IsValid()); + assert(m_HideLoadSave == NULL); + m_HideLoadSave = new RMGfxSourceBuffer16(false); + m_HideLoadSave->Init(*raw, raw->Width(), raw->Height()); + delete raw; + } + + // Menu GAME + if (m_nState == MENUGAME) { + assert(m_ButtonGame_Lock == NULL); + m_ButtonGame_Lock = new RMOptionButton(20008,RMPoint(176, 262), true); + m_ButtonGame_Lock->SetActiveState(bCfgInvLocked); + assert(m_ButtonGame_TimerizedText == NULL); + m_ButtonGame_TimerizedText = new RMOptionButton(20009,RMPoint(463, 273), true); + m_ButtonGame_TimerizedText->SetActiveState(!bCfgTimerizedText); + assert(m_ButtonGame_Scrolling == NULL); + m_ButtonGame_Scrolling = new RMOptionButton(20010, RMPoint(315, 263), true); + m_ButtonGame_Scrolling->SetActiveState(bCfgInvNoScroll); + assert(m_ButtonGame_InterUp == NULL); + m_ButtonGame_InterUp = new RMOptionButton(20011,RMPoint(36, 258), true); + m_ButtonGame_InterUp->SetActiveState(bCfgInvUp); + + assert(m_SlideTextSpeed == NULL); + m_SlideTextSpeed = new RMOptionSlide(RMPoint(165, 122), 10, nCfgTextSpeed); + assert(m_SlideTonySpeed == NULL); + m_SlideTonySpeed = new RMOptionSlide(RMPoint(165, 226), 5, nCfgTonySpeed); + } + // Menu Graphics + else if (m_nState == MENUGFX) { + assert(m_ButtonGfx_Anni30 == NULL); + m_ButtonGfx_Anni30 = new RMOptionButton(20015,RMPoint(247, 178), true); + m_ButtonGfx_Anni30->SetActiveState(bCfgAnni30); + assert(m_ButtonGfx_AntiAlias == NULL); + m_ButtonGfx_AntiAlias = new RMOptionButton(20016, RMPoint(430, 83), true); + m_ButtonGfx_AntiAlias->SetActiveState(!bCfgAntiAlias); + assert(m_ButtonGfx_Sottotitoli == NULL); + m_ButtonGfx_Sottotitoli = new RMOptionButton(20017,RMPoint(98, 82), true); + m_ButtonGfx_Sottotitoli->SetActiveState(!bCfgSottotitoli); + assert(m_ButtonGfx_Tips == NULL); + m_ButtonGfx_Tips = new RMOptionButton(20018,RMPoint(431, 246), true); + m_ButtonGfx_Tips->SetActiveState(bCfgInterTips); + assert(m_ButtonGfx_Trans == NULL); + m_ButtonGfx_Trans = new RMOptionButton(20019,RMPoint(126, 271), true); + m_ButtonGfx_Trans->SetActiveState(!bCfgTransparence); + + } else if (m_nState == MENUSOUND) { + assert(m_SliderSound_Dubbing == NULL); + m_SliderSound_Dubbing = new RMOptionSlide(RMPoint(165, 122), 10, nCfgDubbingVolume); + assert(m_SliderSound_Music == NULL); + m_SliderSound_Music = new RMOptionSlide(RMPoint(165, 226), 10, nCfgMusicVolume); + assert(m_SliderSound_SFX == NULL); + m_SliderSound_SFX = new RMOptionSlide(RMPoint(165, 330), 10, nCfgSFXVolume); + + assert(m_ButtonSound_DubbingOn == NULL); + m_ButtonSound_DubbingOn = new RMOptionButton(20033, RMPoint(339, 75), true); + m_ButtonSound_DubbingOn->SetActiveState(bCfgDubbing); + assert(m_ButtonSound_MusicOn == NULL); + m_ButtonSound_MusicOn = new RMOptionButton(20034,RMPoint(338, 179), true); + m_ButtonSound_MusicOn->SetActiveState(bCfgMusic); + assert(m_ButtonSound_SFXOn == NULL); + m_ButtonSound_SFXOn = new RMOptionButton(20035,RMPoint(338, 283), true); + m_ButtonSound_SFXOn->SetActiveState(bCfgSFX); + } + } + + RefreshAll(); +} + +void RMOptionScreen::CloseState(void) { + delete m_menu; + m_menu = NULL; + + delete m_ButtonExit; + m_ButtonExit = false; + + if (m_nState == MENULOAD || m_nState == MENUSAVE) { + int i; + + for (i = 0; i < 6; i++) { + if (m_curThumb[i] != NULL) { + delete m_curThumb[i]; + m_curThumb[i] = NULL; + } + + delete m_ButtonSave_States[i]; + m_ButtonSave_States[i] = NULL; + } + + delete m_ButtonSave_ArrowLeft; + m_ButtonSave_ArrowLeft = NULL; + delete m_ButtonSave_ArrowRight; + m_ButtonSave_ArrowRight = NULL; + + delete m_SaveEasy; + m_SaveEasy = NULL; + delete m_SaveHard; + m_SaveHard = NULL; + } + + if (m_nState == MENUGAME || m_nState == MENUGFX || m_nState == MENUSOUND) { + delete m_ButtonQuit; + m_ButtonQuit = NULL; + delete m_ButtonLoad; + m_ButtonLoad = NULL; + delete m_ButtonSave; + m_ButtonSave = NULL; + delete m_ButtonGameMenu; + m_ButtonGameMenu = NULL; + delete m_ButtonGfxMenu; + m_ButtonGfxMenu = NULL; + delete m_ButtonSoundMenu; + m_ButtonSoundMenu = NULL; + delete m_QuitConfirm; + m_QuitConfirm = NULL; + delete m_ButtonQuitYes; + m_ButtonQuitYes = NULL; + delete m_ButtonQuitNo; + m_ButtonQuitNo = NULL; + + if (m_bNoLoadSave) { + delete m_HideLoadSave; + m_HideLoadSave = NULL; + } + + if (m_nState == MENUGAME) { + bCfgInvLocked = m_ButtonGame_Lock->IsActive(); + delete m_ButtonGame_Lock; + m_ButtonGame_Lock = NULL; + + bCfgTimerizedText = !m_ButtonGame_TimerizedText->IsActive(); + delete m_ButtonGame_TimerizedText; + m_ButtonGame_TimerizedText = NULL; + + bCfgInvNoScroll = m_ButtonGame_Scrolling->IsActive(); + delete m_ButtonGame_Scrolling; + m_ButtonGame_Scrolling = NULL; + + bCfgInvUp = m_ButtonGame_InterUp->IsActive(); + delete m_ButtonGame_InterUp; + m_ButtonGame_InterUp = NULL; + + nCfgTextSpeed = m_SlideTextSpeed->GetValue(); + delete m_SlideTextSpeed; + m_SlideTextSpeed = NULL; + + nCfgTonySpeed = m_SlideTonySpeed->GetValue(); + delete m_SlideTonySpeed; + m_SlideTonySpeed = NULL; + } else if (m_nState == MENUGFX) { + bCfgAnni30 = m_ButtonGfx_Anni30->IsActive(); + delete m_ButtonGfx_Anni30; + m_ButtonGfx_Anni30 = NULL; + + bCfgAntiAlias = !m_ButtonGfx_AntiAlias->IsActive(); + delete m_ButtonGfx_AntiAlias; + m_ButtonGfx_AntiAlias = NULL; + + bCfgSottotitoli = !m_ButtonGfx_Sottotitoli->IsActive(); + delete m_ButtonGfx_Sottotitoli; + m_ButtonGfx_Sottotitoli = NULL; + + bCfgInterTips = m_ButtonGfx_Tips->IsActive(); + delete m_ButtonGfx_Tips; + m_ButtonGfx_Tips = NULL; + + bCfgTransparence = !m_ButtonGfx_Trans->IsActive(); + delete m_ButtonGfx_Trans; + m_ButtonGfx_Trans = NULL; + } else if (m_nState == MENUSOUND) { + nCfgDubbingVolume = m_SliderSound_Dubbing->GetValue(); + delete m_SliderSound_Dubbing; + m_SliderSound_Dubbing = NULL; + + nCfgMusicVolume = m_SliderSound_Music->GetValue(); + delete m_SliderSound_Music; + m_SliderSound_Music = NULL; + + nCfgSFXVolume = m_SliderSound_SFX->GetValue(); + delete m_SliderSound_SFX; + m_SliderSound_SFX = NULL; + + bCfgDubbing = m_ButtonSound_DubbingOn->IsActive(); + delete m_ButtonSound_DubbingOn; + m_ButtonSound_DubbingOn = NULL; + + bCfgMusic = m_ButtonSound_MusicOn->IsActive(); + delete m_ButtonSound_MusicOn; + m_ButtonSound_MusicOn = NULL; + + bCfgSFX = m_ButtonSound_SFXOn->IsActive(); + delete m_ButtonSound_SFXOn; + m_ButtonSound_SFXOn = NULL; + } + } +} + +void RMOptionScreen::ReInit(RMGfxTargetBuffer &bigBuf) { + bigBuf.AddPrim(new RMGfxPrimitive(this)); +} + +bool RMOptionScreen::Init(RMGfxTargetBuffer &bigBuf) { + if (m_FadeStep != 0) + return false; + + m_FadeStep = 1; + m_FadeY = -20; + m_FadeTime = -1; + m_bExit = false; + m_bLoadMenuOnly = false; + m_bNoLoadSave = false; + m_bAlterGfx = false; + + bigBuf.AddPrim(new RMGfxPrimitive(this)); + + if (m_nState == MENULOAD || m_nState == MENUSAVE) + m_nState = MENUGAME; + InitState(); + + return true; +} + +bool RMOptionScreen::InitLoadMenuOnly(RMGfxTargetBuffer &bigBuf, bool bAlternateGfx) { + if (m_FadeStep != 0) + return false; + + m_FadeStep = 1; + m_FadeY = -20; + m_FadeTime = -1; + m_bExit = false; + m_bLoadMenuOnly = true; + m_bNoLoadSave = false; + m_bAlterGfx = bAlternateGfx; + + bigBuf.AddPrim(new RMGfxPrimitive(this)); + + m_nState = MENULOAD; + InitState(); + + return true; +} + +bool RMOptionScreen::InitSaveMenuOnly(RMGfxTargetBuffer &bigBuf, bool bAlternateGfx) { + if (m_FadeStep != 0) + return false; + + m_FadeStep = 1; + m_FadeY = -20; + m_FadeTime = -1; + m_bExit = false; + m_bLoadMenuOnly = true; + m_bNoLoadSave = false; + m_bAlterGfx = bAlternateGfx; + + bigBuf.AddPrim(new RMGfxPrimitive(this)); + + m_nState = MENUSAVE; + InitState(); + + return true; +} + +bool RMOptionScreen::InitNoLoadSave(RMGfxTargetBuffer &bigBuf) { + if (m_FadeStep != 0) + return false; + + m_FadeStep = 1; + m_FadeY = -20; + m_FadeTime = -1; + m_bExit = false; + m_bLoadMenuOnly = false; + m_bNoLoadSave = true; + + bigBuf.AddPrim(new RMGfxPrimitive(this)); + + m_nState = MENUGAME; + InitState(); + + return true; +} + +bool RMOptionScreen::Close(void) { + if (m_FadeStep != 6) + return false; + + // Inizia il fade out + m_FadeStep++; + m_FadeTime = _vm->GetTime(); + return true; +} + +bool RMOptionScreen::IsClosing(void) { + return m_bExit; +} + +int RMOptionScreen::Priority() { + // Appena sotto il mouse + return 190; +} + +void RMOptionScreen::ChangeState(STATE newState) { + CloseState(); + m_nLastState = m_nState; + m_nState = newState; + InitState(); +} + +void RMOptionScreen::DoFrame(RMInput *input) { + bool bLeftClick, bRightClick; + RMPoint mousePos; + bool bRefresh; + int i; + + // Se non completamente aperto, non fare nulla + if (m_FadeStep != 6) + return; + + // Legge l'input + mousePos = input->MousePos(); + bLeftClick = input->MouseLeftClicked(); + bRightClick = input->MouseRightClicked(); + + bRefresh = false; + + if (m_bQuitConfirm) { + bRefresh |= m_ButtonQuitYes->DoFrame(mousePos, bLeftClick, bRightClick); + bRefresh |= m_ButtonQuitNo->DoFrame(mousePos, bLeftClick, bRightClick); + } else { + bRefresh |= m_ButtonExit->DoFrame(mousePos, bLeftClick, bRightClick); + + // Controlla se ha clickato sull'uscita + if (m_nState == MENUGAME || m_nState == MENUGFX || m_nState == MENUSOUND) { + // bottoni senza grafica... + m_ButtonGameMenu->DoFrame(mousePos, bLeftClick, bRightClick); + m_ButtonGfxMenu->DoFrame(mousePos, bLeftClick, bRightClick); + m_ButtonSoundMenu->DoFrame(mousePos, bLeftClick, bRightClick); + + // bottoni con grafica + if (!m_bNoLoadSave) + { +#ifndef DEMO + bRefresh |= m_ButtonLoad->DoFrame(mousePos, bLeftClick, bRightClick); + bRefresh |= m_ButtonSave->DoFrame(mousePos, bLeftClick, bRightClick); +#endif + bRefresh |= m_ButtonQuit->DoFrame(mousePos, bLeftClick, bRightClick); + } + } + + switch (m_nState) { + case MENUGAME: + bRefresh |= m_ButtonGame_Lock->DoFrame(mousePos, bLeftClick, bRightClick); + bRefresh |= m_ButtonGame_TimerizedText->DoFrame(mousePos, bLeftClick, bRightClick); + bRefresh |= m_ButtonGame_Scrolling->DoFrame(mousePos, bLeftClick, bRightClick); + bRefresh |= m_ButtonGame_InterUp->DoFrame(mousePos, bLeftClick, bRightClick); + bRefresh |= m_SlideTextSpeed->DoFrame(mousePos, bLeftClick, bRightClick); + bRefresh |= m_SlideTonySpeed->DoFrame(mousePos, bLeftClick, bRightClick); + break; + + case MENUGFX: + bRefresh |= m_ButtonGfx_Anni30->DoFrame(mousePos, bLeftClick, bRightClick); + bRefresh |= m_ButtonGfx_AntiAlias->DoFrame(mousePos, bLeftClick, bRightClick); + bRefresh |= m_ButtonGfx_Sottotitoli->DoFrame(mousePos, bLeftClick, bRightClick); + bRefresh |= m_ButtonGfx_Tips->DoFrame(mousePos, bLeftClick, bRightClick); + bRefresh |= m_ButtonGfx_Trans->DoFrame(mousePos, bLeftClick, bRightClick); + break; + + case MENUSOUND: + bRefresh |= m_SliderSound_Dubbing->DoFrame(mousePos, bLeftClick, bRightClick); + bRefresh |= m_SliderSound_Music->DoFrame(mousePos, bLeftClick, bRightClick); + bRefresh |= m_SliderSound_SFX->DoFrame(mousePos, bLeftClick, bRightClick); + bRefresh |= m_ButtonSound_DubbingOn->DoFrame(mousePos, bLeftClick, bRightClick); + bRefresh |= m_ButtonSound_MusicOn->DoFrame(mousePos, bLeftClick, bRightClick); + bRefresh |= m_ButtonSound_SFXOn->DoFrame(mousePos, bLeftClick, bRightClick); + break; + + case MENULOAD: + case MENUSAVE: + for (i=0;i<6;i++) + m_ButtonSave_States[i]->DoFrame(mousePos, bLeftClick, bRightClick); + + if (m_statePos > 0) + bRefresh |= m_ButtonSave_ArrowLeft->DoFrame(mousePos, bLeftClick, bRightClick); + if (m_statePos < 90) + bRefresh |= m_ButtonSave_ArrowRight->DoFrame(mousePos, bLeftClick, bRightClick); + break; + } + } + +#define KEYPRESS(c) ((GetAsyncKeyState(c)&0x8001)==0x8001) +#define PROCESS_CHAR(cod,c) if (KEYPRESS(cod)) { \ + m_EditName[strlen(m_EditName) +1 ] = '\0'; m_EditName[strlen(m_EditName)] = c; bRefresh = true; } + + /**************** STATO BOTTONI **************/ + if (m_bEditSaveName) { + if (KEYPRESS(Common::KEYCODE_BACKSPACE)) { + if (m_EditName[0] != '\0') { + m_EditName[strlen(m_EditName) - 1] = '\0'; + bRefresh = true; + } + } + + for (i=0;i<26 && strlen(m_EditName)<12;i++) + if ((GetAsyncKeyState(Common::KEYCODE_LSHIFT) & 0x8000) || + (GetAsyncKeyState(Common::KEYCODE_RSHIFT) & 0x8000)) { + PROCESS_CHAR((Common::KeyCode)((int)'a' + i), i + 'A'); + } else { + PROCESS_CHAR((Common::KeyCode)((int)'a' + i), i + 'a'); + } + + for (i = 0; i < 10 && strlen(m_EditName) < 12; i++) + PROCESS_CHAR((Common::KeyCode)((int)'0' + i), i + '0'); + + if (strlen(m_EditName) < 12) + PROCESS_CHAR(Common::KEYCODE_SPACE,' '); + + if (strlen(m_EditName)<12) PROCESS_CHAR(Common::KEYCODE_KP0, '0'); + if (strlen(m_EditName)<12) PROCESS_CHAR(Common::KEYCODE_KP1, '1'); + if (strlen(m_EditName)<12) PROCESS_CHAR(Common::KEYCODE_KP2, '2'); + if (strlen(m_EditName)<12) PROCESS_CHAR(Common::KEYCODE_KP3, '3'); + if (strlen(m_EditName)<12) PROCESS_CHAR(Common::KEYCODE_KP4, '4'); + if (strlen(m_EditName)<12) PROCESS_CHAR(Common::KEYCODE_KP5, '5'); + if (strlen(m_EditName)<12) PROCESS_CHAR(Common::KEYCODE_KP6, '6'); + if (strlen(m_EditName)<12) PROCESS_CHAR(Common::KEYCODE_KP7, '7'); + if (strlen(m_EditName)<12) PROCESS_CHAR(Common::KEYCODE_KP8, '8'); + if (strlen(m_EditName)<12) PROCESS_CHAR(Common::KEYCODE_KP9, '9'); + + // ANNULLA + if (KEYPRESS(Common::KEYCODE_ESCAPE)) { + m_bEditSaveName = false; + bRefresh = true; + } + + // OK + if (KEYPRESS(Common::KEYCODE_RETURN)) { + m_bEditSaveName = false; + _vm->SaveState(m_statePos + m_nEditPos, m_EditName); + Close(); + } + + } else if (bLeftClick) { + if (m_nState == MENULOAD || m_nState == MENUSAVE) { + if (m_ButtonExit->IsActive()) { + if (m_bLoadMenuOnly) { + // Se solo il menu di loading, chiudiamo + Close(); + } else { + ChangeState(m_nLastState); + bRefresh = true; + } + } else if (m_ButtonSave_ArrowLeft->IsActive()) { + if (m_statePos > 0) { + m_statePos -= 6; + if (m_statePos < 0) m_statePos = 0; + m_ButtonSave_ArrowLeft->SetActiveState(false); + bRefresh = true; + RefreshThumbnails(); + } + } else if (m_ButtonSave_ArrowRight->IsActive()) { + if (m_statePos < 90) { + m_statePos += 6; + if (m_statePos > 90) m_statePos = 90; + m_ButtonSave_ArrowRight->SetActiveState(false); + bRefresh = true; + RefreshThumbnails(); + } + } else { + for (i = 0; i < 6; i++) + if (m_ButtonSave_States[i]->IsActive()) { + // C' da effettuare il salvataggio o il caricamento!!!! + if (m_nState == MENULOAD && m_curThumb[i] != NULL) { + // Caricamento + _vm->LoadState(m_statePos+i); + Close(); + } else if (m_nState == MENUSAVE && (m_statePos != 0 || i != 0)) { + // Attiva la modalit di editing + m_bEditSaveName = true; + m_nEditPos = i; + strcpy(m_EditName, m_curThumbName[i]); + bRefresh = true; + + //_vm->SaveState(m_statePos+i,"No name"); + //Close(); + } + + break; + } + } + } + + if (m_nState == MENUGAME || m_nState == MENUGFX || m_nState == MENUSOUND) { + if (m_bQuitConfirm) { + if (m_ButtonQuitNo->IsActive()) { + m_bQuitConfirm = false; + bRefresh = true; + } else if (m_ButtonQuitYes->IsActive()) { + m_bQuitConfirm = false; + bRefresh = true; + + _vm->Quit(); + } + } else { + if (m_ButtonQuit->IsActive()) { + m_bQuitConfirm = true; + m_ButtonQuitNo->SetActiveState(false); + m_ButtonQuitYes->SetActiveState(false); + bRefresh = true; + } else if (m_ButtonExit->IsActive()) + Close(); + else if (m_ButtonLoad->IsActive()) { + ChangeState(MENULOAD); + bRefresh = true; + } else if (m_ButtonSave->IsActive()) { + ChangeState(MENUSAVE); + bRefresh = true; + } else if (m_ButtonGameMenu->IsActive() && m_nState != MENUGAME) { + ChangeState(MENUGAME); + bRefresh = true; + } else if (m_ButtonGfxMenu->IsActive() && m_nState != MENUGFX) { + ChangeState(MENUGFX); + bRefresh = true; + } else if (m_ButtonSoundMenu->IsActive() && m_nState != MENUSOUND) { + ChangeState(MENUSOUND); + bRefresh = true; + } + + if (m_nState == MENUGFX) { + // Queste opzioni hanno effetto immediato + if (m_ButtonGfx_Anni30->IsActive()) + bCfgAnni30 = true; + else + bCfgAnni30 = false; + + if (m_ButtonGfx_AntiAlias->IsActive()) + bCfgAntiAlias = false; + else + bCfgAntiAlias = true; + + if (m_ButtonGfx_Trans->IsActive()) + bCfgTransparence = false; + else + bCfgTransparence = true; + } + } + } + } + + if (m_nState == MENUGAME || m_nState == MENUGFX || m_nState == MENUSOUND) + if (!m_bQuitConfirm && KEYPRESS(Common::KEYCODE_ESCAPE)) + Close(); + + if (bRefresh) + RefreshAll(); +} + + +void RMOptionScreen::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + int curTime = _vm->GetTime(); + +#define FADE_SPEED 20 +#define SYNC (curTime-m_FadeTime) / 25 + + if (m_bExit) + return; + + switch (m_FadeStep) { + // Discesa veloce + case 1: + if (m_FadeTime == -1) + m_FadeY += FADE_SPEED; + else + m_FadeY += FADE_SPEED*SYNC; + if (m_FadeY > 480) + { + m_FadeY = 480; + m_FadeStep++; + } + + // Setta la parte da disegnare per lo scrolling + prim->SetSrc(RMRect(0, 480 - m_FadeY, 640, 480)); + break; + + // Rimbalzo 1 + case 2: + m_FadeY -= FADE_SPEED / 2 * SYNC; + if (m_FadeY < 400) { + m_FadeY = 400; + m_FadeStep++; + } + + prim->SetSrc(RMRect(0, 480 - m_FadeY, 640, 480)); + break; + + case 3: + m_FadeY -= FADE_SPEED / 4 * SYNC; + if (m_FadeY < 380) { + m_FadeY = 380; + m_FadeStep++; + } + + prim->SetSrc(RMRect(0, 480 - m_FadeY, 640, 480)); + break; + + // Rimbalzo 1 - 2 + case 4: + m_FadeY += FADE_SPEED / 3 * SYNC; + if (m_FadeY > 420) { + m_FadeY = 420; + m_FadeStep++; + } + + prim->SetSrc(RMRect(0, 480 - m_FadeY, 640, 480)); + break; + + case 5: + m_FadeY += FADE_SPEED / 2 * SYNC; + if (m_FadeY > 480) { + m_FadeY = 480; + m_FadeStep++; + _vm->HideLocation(); + } + + prim->SetSrc(RMRect(0, 480 - m_FadeY, 640, 480)); + break; + + // Menu ON + case 6: + break; + + // Menu OFF + case 7: + _vm->ShowLocation(); + m_FadeStep++; + break; + + case 8: + m_FadeY -= FADE_SPEED * SYNC; + if (m_FadeY < 0) { + m_FadeY = 0; + m_FadeStep++; + } + prim->SetSrc(RMRect(0, 480 - m_FadeY, 640, 480)); + break; + + // Ciao ciao! + case 9: + m_bExit = true; + m_FadeStep = 0; + + // Libera la memoria + CloseState(); + return; + + default: + m_FadeStep = 0; + break; + } + + m_FadeTime = curTime; + + RMGfxWoodyBuffer::Draw(bigBuf,prim); +} + +bool RMOptionScreen::RemoveThis() { + if (m_bExit) + return true; + + return false; +} + + +bool RMOptionScreen::LoadThumbnailFromSaveState(int nState, byte *lpDestBuf, RMString& name, byte &diff) { + char buf[256]; + char namebuf[256]; int i; + Common::File f; + char id[4]; + + // Pulisce la destinazione + Common::fill(lpDestBuf, lpDestBuf + 160 * 120 * 2, 0); + name = "No name"; + diff = 10; + + // Si fa dare il nome del salvataggio + _vm->GetSaveStateFileName(nState, buf); + + // Guarda se esiste + if (f.open(buf)) + return false; + + // Controlla se giusto l'header + f.read(id, 4); + if (id[0] != 'R' || id[1] != 'M' || id[2] != 'S') { + f.close(); + return false; + } + + if (id[3] < 0x3) { + // Versione vecchia, niente screenshot + f.close(); + return true; + } + + // legge lo screenshot + if (id[3] >= 0x5) { + byte *cmpbuf; + uint32 cmpsize, size; + + cmpbuf = new byte[160 * 120 * 4]; + + // Se la versione >= 5, compresso! + cmpsize = f.readUint32LE(); + f.read(cmpbuf, cmpsize); + + lzo1x_decompress(cmpbuf,cmpsize,lpDestBuf,&size); + + delete[] cmpbuf; + } else + f.read(lpDestBuf, 160 * 120 * 2); + + if (id[3] >= 0x5) { + // Legge il livello di difficolt + diff = f.readByte(); + } + + if (id[3] < 0x4) { + // Versione vecchia, niente nome + f.close(); + return true; + } + + i = f.readByte(); + f.read(namebuf, i); + namebuf[i] = '\0'; + name = namebuf; + + f.close(); + return true; +} + + +/****************************************************************************\ +* Metodi di RMPointer +\****************************************************************************/ + +RMPointer::RMPointer() { + Common::fill(m_pointer, m_pointer + 16, (RMGfxSourceBuffer8 *)NULL); +} + +RMPointer::~RMPointer() { + Close(); +} + +void RMPointer::Init(void) { + int i; + + for (i = 0; i < 5; i++) { + RMResRaw res(RES_P_GO + i); + + m_pointer[i] = new RMGfxSourceBuffer8RLEByteAA; + m_pointer[i]->Init(res, res.Width(), res.Height(), false); + m_pointer[i]->LoadPaletteWA(RES_P_PAL); + } + + for (i = 0; i < 5; i++) { + RMRes res(RES_P_PAP1 + i); + RMDataStream ds; + + ds.OpenBuffer(res); + m_specialPointer[i] = new RMItem; + ds >> *m_specialPointer[i]; + } + + //m_hotspot[0].Set(19,5); + m_hotspot[0].Set(5, 1); + m_hotspot[1].Set(32, 28); + m_hotspot[2].Set(45, 23); + m_hotspot[3].Set(35, 25); + m_hotspot[4].Set(32, 28); + + // Default=GO + m_nCurPointer = 0; + m_nCurSpecialPointer = 0; +} + +void RMPointer::Close(void) { + int i; + + for (i = 0; i < 1; i++) + if (m_pointer[i] != NULL) + delete m_pointer[i], m_pointer[i] = NULL; +} + + +int RMPointer::Priority() { + // Priorita' minima: davanti a tutto + return 200; +} + +void RMPointer::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + int n; + + // Controlla il pointer + n = m_nCurPointer; + if (n == TA_COMBINE) n = TA_USE; + + // Copia le coordinate di destinazione nella primitiva + prim->SetDst(m_pos); + + if (m_pos.x >= 0 && m_pos.y >= 0 && m_pos.x < RM_SX && m_pos.y < RM_SY) { + // Richiama il draw del puntatore + prim->Dst()-=m_hotspot[n]; + + if (m_nCurSpecialPointer == 0) { + m_pointer[n]->Draw(bigBuf,prim); + } else { + if (m_nCurSpecialPointer == PTR_CUSTOM) + m_nCurCustomPointer->Draw(bigBuf, prim); + else + // Richiama il draw sul puntatore speciale + m_specialPointer[m_nCurSpecialPointer-1]->Draw(bigBuf, prim); + } + } +} + +void RMPointer::DoFrame(RMGfxTargetBuffer *bigBuf) { + // Si aggiunge alla lista delle primitive + bigBuf->AddPrim(new RMGfxPrimitive(this)); + + // Se c'e' un puntatore speciale, fa la DoFrame + if (m_nCurSpecialPointer!=0 && m_nCurSpecialPointer!=PTR_CUSTOM) + m_specialPointer[m_nCurSpecialPointer-1]->DoFrame(bigBuf,false); +} + +bool RMPointer::RemoveThis() { + // Si leva sempre dalla lista di OT, per supportare la DisableInput + return true; +} + +int RMPointer::CurAction(void) { + if (m_nCurSpecialPointer != 0) + return 0; + + return m_nCurPointer; +} + } // End of namespace Tony -- cgit v1.2.3 From 07a16ab2f38c6993addcd659a15dd054f776fa85 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 3 May 2012 09:23:54 +1000 Subject: TONY: Implemented gfxcore.cpp methods --- engines/tony/gfxcore.cpp | 1809 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1809 insertions(+) (limited to 'engines') diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 731521832f..dfdee30ac6 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -49,6 +49,1815 @@ namespace Tony { +static char rcsid[] = "$Id: $"; +/****************************************************************************\ +* Metodi di RMGfxTask +\****************************************************************************/ + +RMGfxTask::RMGfxTask() { + m_nPrior = 0; + m_nInList = 0; +} + +int RMGfxTask::Priority() { + return m_nPrior; +} + +bool RMGfxTask::RemoveThis() { + return true; +} + + +/****************************************************************************\ +* Metodi di RMGfxTaskSetPrior +\****************************************************************************/ + +void RMGfxTaskSetPrior::SetPriority(int nPrior) { + m_nPrior = nPrior; +} + + +/****************************************************************************\ +* Metodi di RMGfxBuffer +\****************************************************************************/ + +RMGfxBuffer::RMGfxBuffer() { + m_dimx = m_dimy = 0; + m_bUseDDraw = false; + m_origBuf = m_buf = NULL; +} + +RMGfxBuffer::~RMGfxBuffer() { + Destroy(); +} + +void RMGfxBuffer::Create(int dimx, int dimy, int nBpp, bool bUseDDraw) { + // Distruggi il buffer se esiste di gia' + if (m_buf != NULL) + Destroy(); + + // Copia i parametri nei membri privati + m_dimx = dimx; + m_dimy = dimy; + m_bUseDDraw = bUseDDraw; + + if (!m_bUseDDraw) { + // Alloca il buffer + m_origBuf = m_buf = new byte[m_dimx * m_dimy * nBpp / 8]; + assert(m_buf != NULL); + Common::fill(m_origBuf, m_origBuf + m_dimx * m_dimy * nBpp / 8, 0); + } +} + +void RMGfxBuffer::Destroy(void) { + if (!m_bUseDDraw) { + if (m_origBuf != NULL && m_origBuf == m_buf) { + delete[] m_origBuf; + m_origBuf = m_buf = NULL; + } + } +} + +void RMGfxBuffer::Lock(void) { + if (m_bUseDDraw) { + // Gestisce l'accelerazione + } +} + +void RMGfxBuffer::Unlock(void) { + if (m_bUseDDraw) { + // Gestisce l'accelerazione + } +} + +void RMGfxBuffer::OffsetY(int nLines, int nBpp) { + m_buf += nLines*Dimx() * nBpp / 8; +} + + +/****************************************************************************\ +* Metodi di RMGfxSourceBuffer +\****************************************************************************/ + +/****************************************************************************\ +* +* Function: +* +* Description: +* +* Input: +* +* Return: +* +\****************************************************************************/ + +int RMGfxSourceBuffer::Init(const byte *buf, int dimx, int dimy, bool bLoadPalette) { + Create(dimx, dimy, Bpp()); + CopyMemory(m_buf, buf, dimx * dimy * Bpp() / 8); + + // Richiama la funzione di preparazione della surface (ereditata) + PrepareImage(); + + return dimx * dimy * Bpp() / 8; +} + + +void RMGfxSourceBuffer::Init(RMDataStream& ds, int dimx, int dimy, bool bLoadPalette) { + Create(dimx, dimy,Bpp()); + ds.Read(m_buf, dimx * dimy*Bpp() / 8); + + // Richiama la funzione di preparazione della surface (ereditata) + PrepareImage(); +} + +RMGfxSourceBuffer::~RMGfxSourceBuffer() { +} + +void RMGfxSourceBuffer::PrepareImage(void) { + // Non fa nulla: puo' essere overloadata se necessaria +} + +bool RMGfxSourceBuffer::Clip2D(int &x1, int &y1, int &u, int &v, int &width, int &height, bool bUseSrc, RMGfxTargetBuffer* buf) { + int destw, desth; + +/* + OBSOLETE CODE: + + if (buf == NULL) + { + destw=RM_SX; + desth=RM_SY; + } + else + { + destw = buf->Dimx(); + desth = buf->Dimy(); + } +*/ + destw = buf->Dimx(); + desth = buf->Dimy(); + + if (!bUseSrc) { + u = v = 0; + width = m_dimx; + height = m_dimy; + } + + if (x1 > destw - 1) return false; + if (y1 > desth - 1) return false; + + if (x1 < 0) { + width += x1; + if (width < 0) return false; + u -= x1; + x1 = 0; + } + + if (y1 < 0) { + height += y1; + if (height < 0) return false; + v -= y1; + y1 = 0; + } + + if (x1 + width - 1 > destw - 1) + width = destw - x1; + + if (y1 + height - 1 > desth - 1) + height = desth - y1; + + return true; +} + + +/****************************************************************************\ +* Metodi di RMGfxWoodyBuffer +\****************************************************************************/ + +RMGfxWoodyBuffer::~RMGfxWoodyBuffer() { + +} + +void RMGfxWoodyBuffer::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + // Prima si fa disegnare tramite la propria OT list + DrawOT(); + + // Poi disegna se stesso nel target buffer + RMGfxSourceBuffer16::Draw(bigBuf, prim); +} + + + +/****************************************************************************\ +* Metodi di RMGfxTargetBuffer +\****************************************************************************/ + +RMGfxClearTask RMGfxTargetBuffer::taskClear; + +RMGfxTargetBuffer::RMGfxTargetBuffer() { + otlist = NULL; +// InitializeCriticalSection(&csModifyingOT); +} + +RMGfxTargetBuffer::~RMGfxTargetBuffer() { + ClearOT(); +// DeleteCriticalSection(&csModifyingOT); +} + + +void RMGfxTargetBuffer::ClearOT(void) { + OTList *cur, *n; + + g_system->lockMutex(csModifyingOT); + + cur = otlist; + + while (cur != NULL) { + cur->prim->m_task->Unregister(); + delete cur->prim; + n = cur->next; + delete cur; + cur = n; + } + + otlist = NULL; + + g_system->unlockMutex(csModifyingOT); +} + +void RMGfxTargetBuffer::DrawOT(void) { + OTList *cur; + OTList *prev; + OTList *next; + RMGfxPrimitive *myprim; + + prev = NULL; + cur = otlist; + + // Lock del buffer per accederci + Lock(); + g_system->lockMutex(csModifyingOT); + + while (cur != NULL) { + // Richiama la draw sul task, passandogli una copia della primitiva + myprim=cur->prim->Duplicate(); + cur->prim->m_task->Draw(*this, myprim); + delete myprim; + + // Controlla se e' arrivato il momento di rimuovere il task dalla OTlist + if (cur->prim->m_task->RemoveThis()) { + // Deregistra il task + cur->prim->m_task->Unregister(); + + // Cancella il task liberando la memoria + delete cur->prim; + next=cur->next; + delete cur; + + // Se era il primo elemento, aggiorna la testa della lista + if (prev == NULL) + otlist = next; + // Altrimenti aggiorna il puntatore al successivo dell'elemento precedente + else + prev->next = next; + + cur = next; + } else { + // Aggiorna il puntatore al precedente e scorre la lista + prev = cur; + cur = cur->next; + } + } + + g_system->unlockMutex(csModifyingOT); + + // Unlock dopo la scrittura + Unlock(); +} + +void RMGfxTargetBuffer::AddPrim(RMGfxPrimitive *prim) { + int nPrior; + OTList *cur, *n; + + g_system->lockMutex(csModifyingOT); + + // Avverte che e' in lista di OT + prim->m_task->Register(); + + // Controlla la sua priorita' + nPrior = prim->m_task->Priority(); + n = new OTList(prim); + + // Lista vuota + if (otlist == NULL) { + otlist = n; + otlist->next = NULL; + } + // Inserimento in testa + else if (nPrior < otlist->prim->m_task->Priority()) + { + n->next = otlist; + otlist = n; + } else { + cur = otlist; + while (cur->next != NULL && nPrior > cur->next->prim->m_task->Priority()) + cur=cur->next; + + n->next = cur->next; + cur->next = n; + } + + g_system->unlockMutex(csModifyingOT); +} + +/****************************************************************************\ +* Metodi di RMGfxSourceBufferPal +\****************************************************************************/ + +RMGfxSourceBufferPal::~RMGfxSourceBufferPal() { + +} + +int RMGfxSourceBufferPal::LoadPaletteWA(const byte *buf, bool bSwapped) { + int i; + + if (bSwapped) + for (i = 0; i < (1 << Bpp()); i++) { + m_pal[i * 3 + 0] = buf[i * 3 + 2]; + m_pal[i * 3 + 1] = buf[i * 3 + 1]; + m_pal[i * 3 + 2] = buf[i * 3 + 0]; + } + else + CopyMemory(m_pal,buf,(1<> 3) << 10) | + (((int)m_pal[i * 3 + 1] >> 3) << 5) | + (((int)m_pal[i * 3 + 2] >> 3) << 0); + } +} + +int RMGfxSourceBufferPal::Init(const byte *buf, int dimx, int dimy, bool bLoadPalette) { + int read; + + // Carica l'immagine RAW + read = RMGfxSourceBuffer::Init(buf, dimx, dimy); + + // Carica la palette se necessario + if (bLoadPalette) + read += LoadPaletteWA(&buf[read]); + + return read; +} + +void RMGfxSourceBufferPal::Init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette) { + // Carica l'immagine RAW + RMGfxSourceBuffer::Init(ds, dimx, dimy); + + // Carica la palette se necessario + if (bLoadPalette) { + byte *suxpal = new byte[256 * 3]; + ds.Read(suxpal, 256 * 3); + LoadPaletteWA(suxpal); + delete[] suxpal; + } +} + + + +/****************************************************************************\ +* Metodi di RMGfxSourceBuffer4 +\****************************************************************************/ + +void RMGfxSourceBuffer4::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +} + + + +/****************************************************************************\ +* Metodi di RMGfxSourceBuffer8 +\****************************************************************************/ + +RMGfxSourceBuffer8::~RMGfxSourceBuffer8() { + +} + +void RMGfxSourceBuffer8::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + int x, y, width, height, u, v; + int bufx = bigBuf.Dimx(); + uint16 *buf = bigBuf; + byte *raw = m_buf; + + // Destination nel buffer + RMRect dst; + if (prim->HaveDst()) + dst=prim->Dst(); + + // Esegue il clip + if (prim->HaveSrc()) { + u = prim->Src().x1; + v = prim->Src().y1; + + width = prim->Src().Width(); + height = prim->Src().Height(); + } + + if (!Clip2D(dst.x1, dst.y1, u, v, width, height, prim->HaveSrc(), &bigBuf)) + return; + + // Offset iniziale nel buffer + buf += dst.y1 * bufx + dst.x1; + + // Passaggio normale + if (m_bTrasp0) { + for (y = 0; y < height; y++) { + raw = m_buf + (y + v) * m_dimx + u; + + for (x = 0; x < width; x++) { + if (*raw) *buf = m_palFinal[*raw]; + buf++; + raw++; + } + + buf += bufx - width; + } + } else { + for (y = 0; y < height; y++) { + raw = m_buf + (y + v) * m_dimx + u; + + for (x = 0;x> 10) & 0x1F) +#define GETGREEN(x) (((x) >> 5) & 0x1F) +#define GETBLUE(x) ((x) & 0x1F) + + +/****************************************************************************\ +* Metodi di RMGfxSourceBuffer8AB +\****************************************************************************/ + +RMGfxSourceBuffer8AB::~RMGfxSourceBuffer8AB() { + +} + +inline int RMGfxSourceBuffer8AB::CalcTrasp(int fore, int back) +{ + int r,g,b; + + r = (GETRED(fore) >> 2) + (GETRED(back) >> 1); + g = (GETGREEN(fore) >> 2) + (GETGREEN(back) >> 1); + b = (GETBLUE(fore) >> 2) + (GETBLUE(back) >> 1); + + if (r > 0x1F) r = 0x1F; + if (g > 0x1F) g = 0x1F; + if (b > 0x1F) b = 0x1F; + + return (r<<10)|(g<<5)|b; +} + + +void RMGfxSourceBuffer8AB::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + int x, y, width, height, u, v; + int bufx=bigBuf.Dimx(); + uint16 *buf = bigBuf; + byte *raw = m_buf; + + // Destination nel buffer + RMRect dst; + if (prim->HaveDst()) + dst = prim->Dst(); + + // Esegue il clip + if (prim->HaveSrc()) { + u=prim->Src().x1; + v=prim->Src().y1; + + width = prim->Src().Width(); + height = prim->Src().Height(); + } + + if (!Clip2D(dst.x1, dst.y1, u, v, width, height, prim->HaveSrc(), &bigBuf)) + return; + + // Offset iniziale nel buffer + buf += dst.y1 * bufx + dst.x1; + + // Passaggio normale + if (m_bTrasp0) { + for (y = 0; y < height; y++) { + raw = m_buf + (y + v) * m_dimx + u; + + for (x = 0; x < width; x++) { + if (*raw) *buf = CalcTrasp(m_palFinal[*raw], *buf); + buf++; + raw++; + } + + buf += bufx - width; + } + } else { + for (y = 0; y < height; y++) { + raw = m_buf + (y+v) * m_dimx + u; + + for (x = 0; x < width; x += 2) { + buf[0] = CalcTrasp(m_palFinal[raw[0]], buf[0]); + buf[1] = CalcTrasp(m_palFinal[raw[1]], buf[1]); + + buf += 2; + raw += 2; + } + + buf += bufx - width; + } + } + + return; +} + + + +/****************************************************************************\ +* Metodi di RMGfxSourceBuffer8RLE +\****************************************************************************/ + +byte RMGfxSourceBuffer8RLE::MegaRLEBuf[512 * 1024]; + +void RMGfxSourceBuffer8RLE::SetAlphaBlendColor(int color) { + alphaBlendColor = color; +} + +RMGfxSourceBuffer8RLE::RMGfxSourceBuffer8RLE() { + alphaBlendColor = -1; + bNeedRLECompress = true; +} + +RMGfxSourceBuffer8RLE::~RMGfxSourceBuffer8RLE() { + if (m_buf != NULL) { + delete m_buf; + m_buf = NULL; + } +} + + +int RMGfxSourceBuffer8RLE::Init(const byte *buf, int dimx, int dimy, bool bLoadPalette) { + return RMGfxSourceBufferPal::Init(buf, dimx, dimy, bLoadPalette); +} + +void RMGfxSourceBuffer8RLE::Init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette) { + if (bNeedRLECompress) { + RMGfxSourceBufferPal::Init(ds, dimx, dimy,bLoadPalette); + } else { + int size; + + ds >> size; + m_buf = new byte[size]; + ds.Read(m_buf, size); + + m_dimx = dimx; + m_dimy = dimy; + } +} + +void RMGfxSourceBuffer8RLE::PreparePalette(void) { + // Richiama il metodo padre + RMGfxSourceBuffer8::PreparePalette(); + + // Si salva gli RGB di alpha blending + if (alphaBlendColor != -1) { + alphaR = (m_palFinal[alphaBlendColor] >> 10) & 0x1F; + alphaG = (m_palFinal[alphaBlendColor] >> 5) & 0x1F; + alphaB = (m_palFinal[alphaBlendColor]) & 0x1F; + } +} + +void RMGfxSourceBuffer8RLE::PrepareImage(void) { + // Richiama il metodo padre + RMGfxSourceBuffer::PrepareImage(); + + // Comprime + CompressRLE(); +} + +void RMGfxSourceBuffer8RLE::SetAlreadyCompressed(void) { + bNeedRLECompress = false; +} + + +void RMGfxSourceBuffer8RLE::CompressRLE(void) { + int x, y; + byte *startline; + byte *cur; + byte curdata; + byte *src; + byte *startsrc; + int rep; + + // Esegue la compressione RLE, per linee + cur = MegaRLEBuf; + src = m_buf; + for (y = 0;y < m_dimy; y++) { + // Si salva l'inizio della linea + startline = cur; + + // Lascia lo spazio per la lunghezza della linea + cur += 2; + + // Si parte dallo spazio vuoto + curdata = 0; + rep = 0; + startsrc = src; + for (x = 0; x < m_dimx;) { + if ((curdata == 0 && *src == 0) || (curdata == 1 && *src == alphaBlendColor) + || (curdata == 2 && (*src != alphaBlendColor && *src != 0))) { + src++; + rep++; + x++; + } else { + if (curdata == 0) { + RLEWriteTrasp(cur, rep); + curdata++; + } + else if (curdata == 1) { + RLEWriteAlphaBlend(cur, rep); + curdata++; + } else { + RLEWriteData(cur, rep, startsrc); + curdata = 0; + } + + rep = 0; + startsrc = src; + } + } + + // Dati in sospeso? + if (curdata == 1) { + RLEWriteAlphaBlend(cur, rep); + RLEWriteData(cur, 0, NULL); + } + + if (curdata == 2) { + RLEWriteData(cur, rep, startsrc); + } + + // Fine linea + RLEWriteEOL(cur); + + // Scrive la lunghezza della linea + WRITE_LE_UINT16(startline, (uint16)(cur - startline)); + } + + // Cancella l'immagine originale + delete[] m_buf; + + // Ci copia l'immagine compressa + x = cur - MegaRLEBuf; + m_buf = new byte[x]; + CopyMemory(m_buf, MegaRLEBuf, x); +} + +void RMGfxSourceBuffer8RLE::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + int y; + byte *src; + uint16 *buf = bigBuf; + int x1, y1, u, v, width, height; + + // Clippiamo lo sprite + x1=prim->Dst().x1; + y1=prim->Dst().y1; + if (!Clip2D(x1,y1,u,v,width,height,false,&bigBuf)) + return; + + // Andiamo avanti di V linee nell'immagine RLE + src = m_buf; + for (y = 0;yIsFlipped()) + { +// Annulliamo il clipping orizzontale +// width = m_dimx; +// x1=prim->Dst().x1; + + // Flippiamo il clipping + u = m_dimx - (width+u); + x1 = (prim->Dst().x1 + m_dimx - 1) - u; + + for (y = 0;y 0) { + CopyMemory(cur, src, rep); + cur += rep; + src += rep; + } + + return; +} + +void RMGfxSourceBuffer8RLEByte::RLEWriteEOL(byte *&cur) { + *cur ++= 0xFF; +} + +void RMGfxSourceBuffer8RLEByte::RLEDecompressLine(uint16 *dst, byte *src, int nStartSkip, int nLength) { + int i, n; + int r, g, b; + + if (nStartSkip == 0) + goto RLEByteDoTrasp; + + while (1) { + assert(nStartSkip > 0); + + // TRASP + n = *src++; + if (n == 0xFF) + return; + + if (n >= nStartSkip) { + dst += n - nStartSkip; + nLength -= n - nStartSkip; + if (nLength > 0) + goto RLEByteDoAlpha; + else + return; + } + nStartSkip -= n; + + + assert(nStartSkip > 0); + + // ALPHA + n = *src++; + if (n >= nStartSkip) { + n -= nStartSkip; + goto RLEByteDoAlpha2; + } + nStartSkip -= n; + + assert(nStartSkip > 0); + + // DATA + n = *src++; + if (n >= nStartSkip) { + src += nStartSkip; + n -= nStartSkip; + goto RLEByteDoCopy2; + } + nStartSkip -= n; + src += n; + } + + + while (1) { +RLEByteDoTrasp: + // Via il trasp di merda + n = *src++; + + // EOL? + if (n == 0xFF) + return; + + dst += n; + nLength -= n; + if (nLength <= 0) + return; + +RLEByteDoAlpha: + // Alpha + n = *src++; + +RLEByteDoAlpha2: + if (n > nLength) + n = nLength; + for (i = 0; i < n; i++) + { + r=(*dst >> 10) & 0x1F; + g=(*dst >> 5) & 0x1F; + b=*dst & 0x1F; + + r=(r >> 2) + (alphaR >> 1); + g=(g >> 2) + (alphaG >> 1); + b=(b >> 2) + (alphaB >> 1); + + *dst++=(r<<10)|(g<<5)|b; + } + + nLength -= n; + if (!nLength) + return; + assert(nLength > 0); + +//RLEByteDoCopy: + // Copia la roba + n = *src++; + +RLEByteDoCopy2: + if (n > nLength) + n = nLength; + + for (i = 0; i < n; i++) + *dst ++= m_palFinal[*src++]; + + nLength -= n; + if (!nLength) + return; + assert(nLength > 0); + } +} + +void RMGfxSourceBuffer8RLEByte::RLEDecompressLineFlipped(uint16 *dst, byte *src, int nStartSkip, int nLength) { + int i, n; + int r, g, b; + + if (nStartSkip == 0) + goto RLEByteFlippedDoTrasp; + + while (1) { + assert(nStartSkip > 0); + + // TRASP + n = *src++; + if (n == 0xFF) + return; + + if (n >= nStartSkip) { + dst -= n - nStartSkip; + nLength -= n - nStartSkip; + if (nLength > 0) + goto RLEByteFlippedDoAlpha; + else + return; + } + nStartSkip -= n; + + + assert(nStartSkip > 0); + + // ALPHA + n = *src++; + if (n >= nStartSkip) { + n -= nStartSkip; + goto RLEByteFlippedDoAlpha2; + } + nStartSkip -= n; + + assert(nStartSkip > 0); + + // DATA + n = *src++; + if (n >= nStartSkip){ + src += nStartSkip; + n -= nStartSkip; + goto RLEByteFlippedDoCopy2; + } + nStartSkip -= n; + src += n; + } + + + while (1) { +RLEByteFlippedDoTrasp: + // Via il trasp di merda + n = *src++; + + // EOL? + if (n == 0xFF) + return; + + dst -= n; + nLength -= n; + if (nLength <= 0) + return; + +RLEByteFlippedDoAlpha: + // Alpha + n = *src++; + +RLEByteFlippedDoAlpha2: + if (n > nLength) + n = nLength; + for (i = 0; i < n; i++) { + r=(*dst >> 10) & 0x1F; + g=(*dst >> 5) & 0x1F; + b=*dst & 0x1F; + + r=(r >> 2) + (alphaR >> 1); + g=(g >> 2) + (alphaG >> 1); + b=(b >> 2) + (alphaB >> 1); + + *dst--=(r << 10) | (g << 5) | b; + } + + nLength -= n; + if (!nLength) + return; + assert(nLength > 0); + +//RLEByteFlippedDoCopy: + // Copia la roba + n = *src++; + +RLEByteFlippedDoCopy2: + if (n > nLength) + n = nLength; + + for (i = 0; i < n; i++) + *dst --= m_palFinal[*src++]; + + nLength -= n; + if (!nLength) + return; + assert(nLength > 0); + } +} + + +/****************************************************************************\ +* Metodi di RMGfxSourceBuffer8RLEWord +\****************************************************************************/ + +RMGfxSourceBuffer8RLEWord::~RMGfxSourceBuffer8RLEWord(){ + +} + +void RMGfxSourceBuffer8RLEWord::RLEWriteTrasp(byte *&cur, int rep) { + WRITE_LE_UINT16(cur, rep); + cur += 2; +} + +void RMGfxSourceBuffer8RLEWord::RLEWriteAlphaBlend(byte *&cur, int rep) { + WRITE_LE_UINT16(cur, rep); + cur += 2; +} + +void RMGfxSourceBuffer8RLEWord::RLEWriteData(byte *&cur, int rep, byte *src) { + WRITE_LE_UINT16(cur, rep); + cur += 2; + + if (rep > 0) { + CopyMemory(cur, src,rep); + cur += rep; + src +=rep; + } +} + +void RMGfxSourceBuffer8RLEWord::RLEWriteEOL(byte *&cur) { + *cur ++= 0xFF; + *cur ++= 0xFF; +} + +void RMGfxSourceBuffer8RLEWord::RLEDecompressLine(uint16 *dst, byte *src, int nStartSkip, int nLength) { + int i, n; + int r, g, b; + + if (nStartSkip == 0) + goto RLEWordDoTrasp; + + while (1) { + assert(nStartSkip > 0); + + // TRASP + n = READ_LE_UINT16(src); + src += 2; + + if (n == 0xFFFF) + return; + + if (n >= nStartSkip) { + dst += n - nStartSkip; + nLength -= n - nStartSkip; + + if (nLength > 0) + goto RLEWordDoAlpha; + else + return; + } + nStartSkip -= n; + + assert(nStartSkip > 0); + + // ALPHA + n = READ_LE_UINT16(src); + src += 2; + + if (n >= nStartSkip) { + n -= nStartSkip; + goto RLEWordDoAlpha2; + } + nStartSkip -= n; + + // DATA + n = READ_LE_UINT16(src); + src += 2; + + if (n>=nStartSkip) + { + src += nStartSkip; + n -= nStartSkip; + goto RLEWordDoCopy2; + } + nStartSkip -= n; + src += n; + } + + + while (1) + { +RLEWordDoTrasp: + // Via il trasp di merda + n = READ_LE_UINT16(src); + src += 2; + + // EOL? + if (n == 0xFFFF) + return; + + dst += n; + + nLength -= n; + if (nLength <= 0) + return; + +RLEWordDoAlpha: + n = READ_LE_UINT16(src); + src += 2; + +RLEWordDoAlpha2: + + if (n > nLength) + n = nLength; + + for (i = 0; i < n; i++) { + r=(*dst >> 10) & 0x1F; + g=(*dst >> 5) & 0x1F; + b=*dst & 0x1F; + + r=(r >> 2) + (alphaR >> 1); + g=(g >> 2) + (alphaG >> 1); + b=(b >> 2) + (alphaB >> 1); + + *dst++=(r<<10)|(g<<5)|b; + } + + nLength -= n; + if (!nLength) + return; + + assert(nLength > 0); + +//RLEWordDoCopy: + // Copia la roba + n = READ_LE_UINT16(src); + src += 2; + +RLEWordDoCopy2: + if (n > nLength) + n = nLength; + + for (i = 0; i < n; i++) + *dst ++= m_palFinal[*src++]; + + nLength -= n; + if (!nLength) + return; + + assert(nLength > 0); + + } +} + +void RMGfxSourceBuffer8RLEWord::RLEDecompressLineFlipped(uint16 *dst, byte *src, int nStartSkip, int nLength) { + int i,n; + int r,g,b; + + if (nStartSkip == 0) + goto RLEWordFlippedDoTrasp; + + while (1) { + assert(nStartSkip > 0); + + // TRASP + n = READ_LE_UINT16(src); + src += 2; + + if (n == 0xFFFF) + return; + + if (n>=nStartSkip) + { + dst -= n - nStartSkip; + nLength -= n - nStartSkip; + + if (nLength > 0) + goto RLEWordFlippedDoAlpha; + else + return; + } + nStartSkip -= n; + + assert(nStartSkip > 0); + + // ALPHA + n = READ_LE_UINT16(src); + src += 2; + + if (n>=nStartSkip) + { + n -= nStartSkip; + goto RLEWordFlippedDoAlpha2; + } + nStartSkip -= n; + + // DATA + n = READ_LE_UINT16(src); + src += 2; + + if (n >= nStartSkip) { + src += nStartSkip; + n -= nStartSkip; + goto RLEWordFlippedDoCopy2; + } + nStartSkip -= n; + src += n; + } + + + while (1) { +RLEWordFlippedDoTrasp: + // Via il trasp di merda + n = READ_LE_UINT16(src); + src += 2; + + // EOL? + if (n == 0xFFFF) + return; + + dst -= n; + + nLength -= n; + if (nLength <= 0) + return; + +RLEWordFlippedDoAlpha: + n = READ_LE_UINT16(src); + src += 2; + +RLEWordFlippedDoAlpha2: + + if (n > nLength) + n = nLength; + + for (i = 0; i < n; i++) { + r=(*dst >> 10) & 0x1F; + g=(*dst >> 5) & 0x1F; + b=*dst & 0x1F; + + r=(r >> 2) + (alphaR >> 1); + g=(g >> 2) + (alphaG >> 1); + b=(b >> 2) + (alphaB >> 1); + + *dst--=(r << 10) | (g << 5) | b; + } + + nLength -= n; + if (!nLength) + return; + + assert(nLength > 0); + +//RLEWordFlippedDoCopy: + // Copia la roba + n = READ_LE_UINT16(src); + src += 2; + +RLEWordFlippedDoCopy2: + if (n > nLength) + n = nLength; + + for (i = 0;i 0); + } +} + +/****************************************************************************\ +* Metodi di RMGfxSourceBuffer8RLEWord +\****************************************************************************/ + +RMGfxSourceBuffer8RLEWordAB::~RMGfxSourceBuffer8RLEWordAB() { + +} + +void RMGfxSourceBuffer8RLEWordAB::RLEDecompressLine(uint16 *dst, byte *src, int nStartSkip, int nLength) { + int i, n; + int r, g, b, r2, g2, b2; + + if (!bCfgTransparence) { + RMGfxSourceBuffer8RLEWord::RLEDecompressLine(dst, src, nStartSkip, nLength); + return; + } + + if (nStartSkip == 0) + goto RLEWordDoTrasp; + + while (1) { + assert(nStartSkip > 0); + + // TRASP + n = READ_LE_UINT16(src); + src += 2; + + if (n == 0xFFFF) + return; + + if (n >= nStartSkip) { + dst += n - nStartSkip; + nLength -= n - nStartSkip; + + if (nLength > 0) + goto RLEWordDoAlpha; + else + return; + } + nStartSkip -= n; + + assert(nStartSkip > 0); + + // ALPHA + n = READ_LE_UINT16(src); + src += 2; + + if (n >= nStartSkip) { + n -= nStartSkip; + goto RLEWordDoAlpha2; + } + nStartSkip -= n; + + // DATA + n = READ_LE_UINT16(src); + src += 2; + + if (n >= nStartSkip) + { + src += nStartSkip; + n -= nStartSkip; + goto RLEWordDoCopy2; + } + nStartSkip -= n; + src += n; + } + + + while (1) { +RLEWordDoTrasp: + // Via il trasp di merda + n = READ_LE_UINT16(src); + src += 2; + + // EOL? + if (n == 0xFFFF) + return; + + dst += n; + + nLength -= n; + if (nLength <= 0) + return; + +RLEWordDoAlpha: + n = READ_LE_UINT16(src); + src += 2; + +RLEWordDoAlpha2: + + if (n > nLength) + n = nLength; + + // @@@ NON DOVREBBE ESSERCI!!!!! + for (i = 0; i < n; i++) { + r=(*dst >> 10) & 0x1F; + g=(*dst >> 5) & 0x1F; + b=*dst & 0x1F; + + r=(r >> 2) + (alphaR >> 1); + g=(g >> 2) + (alphaG >> 1); + b=(b >> 2) + (alphaB >> 1); + + *dst++=(r<<10)|(g<<5)|b; + } + + nLength -= n; + if (!nLength) + return; + + assert(nLength > 0); + +//RLEWordDoCopy: + // Copia la roba + n = READ_LE_UINT16(src); + src += 2; + +RLEWordDoCopy2: + if (n > nLength) + n = nLength; + + for (i = 0; i < n; i++) { + r=(*dst >> 10) & 0x1F; + g=(*dst >> 5) & 0x1F; + b=*dst & 0x1F; + + r2=(m_palFinal[*src] >> 10) & 0x1F; + g2=(m_palFinal[*src] >> 5) & 0x1F; + b2 = m_palFinal[*src] & 0x1F; + + r=(r >> 1) + (r2 >> 1); + g=(g >> 1) + (g2 >> 1); + b=(b >> 1) + (b2 >> 1); + + *dst ++= (r << 10) | (g << 5) | b; + src++; + } + + nLength -= n; + if (!nLength) + return; + + assert(nLength > 0); + + } +} + + +/****************************************************************************\ +* Metodi di RMGfxSourceBuffer8AA +\****************************************************************************/ + +byte RMGfxSourceBuffer8AA::MegaAABuf[256*1024]; +byte RMGfxSourceBuffer8AA::MegaAABuf2[64*1024]; + +void RMGfxSourceBuffer8AA::PrepareImage(void) { + // Richiama il metodo padre + RMGfxSourceBuffer::PrepareImage(); + + // Prepara il buffer di antialiasing + CalculateAA(); +} + + +void RMGfxSourceBuffer8AA::CalculateAA(void) { + // Io suxo tu suxi egli suxa noi suxiamo voi suxate essi suxano ---> ANTI ALIASING SUX! + // ************************************************************ + + int x,y; + byte *src, *srcaa; + + /* Prima passata: cerchiamo i bordi */ + Common::fill(MegaAABuf, MegaAABuf + m_dimx * m_dimy, 0); + + src = m_buf; + srcaa=MegaAABuf; + for (y = 0;y < m_dimy; y++) { + for (x = 0; x < m_dimx; x++) { + if (*src == 0) { + if ((y > 0 && src[-m_dimx] != 0) || + (y 0 && src[-1] != 0) || + (x 0 && srcaa[-m_dimx]==1) || + (y 0 && srcaa[-1]==1) || + (xDst().x1; + y1 = prim->Dst().y1; + if (!Clip2D(x1, y1, u, v, width, height, false, &bigBuf)) + return; + + // Andiamo avanti di V linee nell'immagine RLE + src = m_buf; + for (y = 0; y < v; y++) + src += READ_LE_UINT16(src); + + // Annulliamo il clipping orizzontale + + // Flippiamo il clipping + if (prim->IsFlipped()) { + u = m_dimx - (width + u); + x1 = (prim->Dst().x1 + m_dimx - 1) - u; + } +// width = m_dimx; +// x1=prim->Dst().x1; + + + // Posizionamoci nel buffer di destinazione + buf = bigBuf; + buf += y1 * bigBuf.Dimx(); + + if (prim->IsFlipped()) + step = -1; + else + step = 1; + + // Looppone + buf += bigBuf.Dimx(); // skippa la prima linea + for (y = 1; y < height - 1; y++) { +/* + if (prim->IsFlipped()) + mybuf=&buf[x1+m_dimx-1]; + else +*/ + mybuf=&buf[x1]; + + for (x = 0; x < width; x++, mybuf += step) + if (m_aabuf[(y + v) * m_dimx + x + u] == 2 && x != 0 && x != width - 1) { + r = GETRED(mybuf[1]) + GETRED(mybuf[-1]) + GETRED(mybuf[-bigBuf.Dimx()]) + GETRED(mybuf[bigBuf.Dimx()]); + g = GETGREEN(mybuf[1]) + GETGREEN(mybuf[-1]) + GETGREEN(mybuf[-bigBuf.Dimx()]) + GETGREEN(mybuf[bigBuf.Dimx()]); + b = GETBLUE(mybuf[1]) + GETBLUE(mybuf[-1]) + GETBLUE(mybuf[-bigBuf.Dimx()]) + GETBLUE(mybuf[bigBuf.Dimx()]); + + r += GETRED(mybuf[0]); + g += GETGREEN(mybuf[0]); + b += GETBLUE(mybuf[0]); + + r /= 5; + g /= 5; + b /= 5; + + if (r > 31) r = 31; + if (g > 31) g = 31; + if (b > 31) b = 31; + + mybuf[0]=(r<<10)|(g<<5)|b; + } + + // Skippa alla linea successiva + buf += bigBuf.Dimx(); + } + +// Posizionamoci nel buffer di destinazione + buf = bigBuf; + buf += y1*bigBuf.Dimx(); + + // Looppone + buf+=bigBuf.Dimx(); + for (y = 1; y < height - 1; y++) { +/* + if (prim->IsFlipped()) + mybuf=&buf[x1+m_dimx-1]; + else +*/ + mybuf=&buf[x1]; + + for (x = 0;x < width; x++, mybuf += step) + if (m_aabuf[(y + v) * m_dimx + x + u] == 1 && x != 0 && x != width - 1) { + r = GETRED(mybuf[1]) + GETRED(mybuf[-1]) + GETRED(mybuf[-bigBuf.Dimx()]) + GETRED(mybuf[bigBuf.Dimx()]); + g = GETGREEN(mybuf[1]) + GETGREEN(mybuf[-1]) + GETGREEN(mybuf[-bigBuf.Dimx()]) + GETGREEN(mybuf[bigBuf.Dimx()]); + b = GETBLUE(mybuf[1]) + GETBLUE(mybuf[-1]) + GETBLUE(mybuf[-bigBuf.Dimx()]) + GETBLUE(mybuf[bigBuf.Dimx()]); + + r += GETRED(mybuf[0]) * 2; + g += GETGREEN(mybuf[0]) * 2; + b += GETBLUE(mybuf[0]) * 2; + + r /= 6; + g /= 6; + b /= 6; + + if (r > 31) r = 31; + if (g > 31) g = 31; + if (b > 31) b = 31; + + mybuf[0]=(r<<10)|(g<<5)|b; + } + + // Skippa alla linea successiva + buf += bigBuf.Dimx(); + } +} + + + +void RMGfxSourceBuffer8AA::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + RMGfxSourceBuffer8::Draw(bigBuf, prim); + DrawAA(bigBuf, prim); +} + + +/****************************************************************************\ +* Metodi di RMGfxSourceBuffer8RLEAA +\****************************************************************************/ + +RMGfxSourceBuffer8RLEByteAA::~RMGfxSourceBuffer8RLEByteAA() { + +} + +void RMGfxSourceBuffer8RLEByteAA::PrepareImage(void) { + RMGfxSourceBuffer::PrepareImage(); + CalculateAA(); + CompressRLE(); +} + +void RMGfxSourceBuffer8RLEByteAA::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + RMGfxSourceBuffer8RLE::Draw(bigBuf,prim); + if (bCfgAntiAlias) + DrawAA(bigBuf,prim); +} + +int RMGfxSourceBuffer8RLEByteAA::Init(const byte *buf, int dimx, int dimy, bool bLoadPalette) { + return RMGfxSourceBuffer8RLE::Init(buf, dimx, dimy, bLoadPalette); +} + +void RMGfxSourceBuffer8RLEByteAA::Init(RMDataStream& ds, int dimx, int dimy, bool bLoadPalette) { + RMGfxSourceBuffer8RLE::Init(ds, dimx, dimy,bLoadPalette); + + if (!bNeedRLECompress) { + // Carica la maschera di antialiasing + m_aabuf = new byte[dimx * dimy]; + ds.Read(m_aabuf, dimx * dimy); + } +} + + +RMGfxSourceBuffer8RLEWordAA::~RMGfxSourceBuffer8RLEWordAA() { + +} + +void RMGfxSourceBuffer8RLEWordAA::PrepareImage(void) { + RMGfxSourceBuffer::PrepareImage(); + CalculateAA(); + CompressRLE(); +} + +void RMGfxSourceBuffer8RLEWordAA::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + RMGfxSourceBuffer8RLE::Draw(bigBuf,prim); + if (bCfgAntiAlias) + DrawAA(bigBuf,prim); +} + +int RMGfxSourceBuffer8RLEWordAA::Init(byte *buf, int dimx, int dimy, bool bLoadPalette) { + return RMGfxSourceBuffer8RLE::Init(buf, dimx, dimy,bLoadPalette); +} + +void RMGfxSourceBuffer8RLEWordAA::Init(RMDataStream& ds, int dimx, int dimy, bool bLoadPalette) { + RMGfxSourceBuffer8RLE::Init(ds, dimx, dimy,bLoadPalette); + + if (!bNeedRLECompress) { + // Carica la maschera di antialiasing + m_aabuf = new byte[dimx * dimy]; + ds.Read(m_aabuf, dimx * dimy); + } +} + + +/****************************************************************************\ +* Metodi di RMGfxSourceBuffer16 +\****************************************************************************/ + +RMGfxSourceBuffer16::RMGfxSourceBuffer16(bool bTrasp0) { + m_bTrasp0=bTrasp0; +} + +RMGfxSourceBuffer16::~RMGfxSourceBuffer16() { +} + +void RMGfxSourceBuffer16::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + int x,y; + uint16 *buf = bigBuf; + uint16 *raw = (uint16*)m_buf; + int dimx, dimy; + int u,v; + int x1,y1; + + dimx = m_dimx; + dimy = m_dimy; + u = 0; + v = 0; + x1 = 0; + y1 = 0; + + if (prim->HaveSrc()) { + u = prim->Src().x1; + v = prim->Src().y1; + dimx = prim->Src().Width(); + dimy = prim->Src().Height(); + } + + if (prim->HaveDst()) { + x1 = prim->Dst().x1; + y1 = prim->Dst().y1; + } + + if (!Clip2D(x1, y1, u, v, dimx, dimy, true, &bigBuf)) + return; + + raw += v * m_dimx+u; + buf += y1 * bigBuf.Dimx() + x1; + + if (m_bTrasp0) { + for (y = 0; y < dimy; y++) { + for (x = 0; x < dimx;) { + while (x>= 3; + g >>= 3; + b >>= 3; + wFillColor = (r << 10) | (g << 5) | b; +} + +void RMGfxBox::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + int i, j; + uint16 *buf = bigBuf; + RMRect rcDst; + + // Prende il rettangolo di destinazione + rcDst = prim->Dst(); + buf += rcDst.y1*bigBuf.Dimx() + rcDst.x1; + + // Fa il suo bravo loop di put + for (j = 0; j < rcDst.Height(); j++) { + for (i = 0; i < rcDst.Width(); i++) + *buf ++= wFillColor; + + buf += bigBuf.Dimx() - rcDst.Width(); + } +} + } // End of namespace Tony -- cgit v1.2.3 From cb1b1c453d133104511afaecad28434231a7be24 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 3 May 2012 13:14:46 +1000 Subject: TONY: Added GfxCoreInline.hpp methods --- engines/tony/gfxcore.cpp | 143 +++++++++++++++++++++++++++++++++++++++++++++-- engines/tony/gfxcore.h | 2 +- 2 files changed, 140 insertions(+), 5 deletions(-) (limited to 'engines') diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index dfdee30ac6..4842126c59 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -46,6 +46,7 @@ **************************************************************************/ #include "tony/gfxEngine.h" +#include "tony/mpal/mpalutils.h" namespace Tony { @@ -133,10 +134,22 @@ void RMGfxBuffer::Unlock(void) { } void RMGfxBuffer::OffsetY(int nLines, int nBpp) { - m_buf += nLines*Dimx() * nBpp / 8; + m_buf += nLines* Dimx() * nBpp / 8; } +inline RMGfxBuffer::operator byte *() { + return m_buf; +} + +inline RMGfxBuffer::operator void *() { + return (void *)m_buf; +} + +inline RMGfxBuffer::RMGfxBuffer(int dimx, int dimy, int nBpp, bool bUseDDraw) { + Create(dimx, dimy, nBpp, bUseDDraw); +} + /****************************************************************************\ * Metodi di RMGfxSourceBuffer \****************************************************************************/ @@ -231,6 +244,20 @@ bool RMGfxSourceBuffer::Clip2D(int &x1, int &y1, int &u, int &v, int &width, int return true; } +/****************************************************************************\ +* +* Function: void RMGfxSourceBuffer::Init(uint32 resID, int dimx, int dimy); +* +* Description: Carica una surface partendo dall'ID della risorsa +* +* Input: uint32 resID ID della risorsa +* int dimx, dimy Dimensione del buffer +* +\****************************************************************************/ + +inline int RMGfxSourceBuffer::Init(uint32 resID, int dimx, int dimy, bool bLoadPalette) { + return Init(RMRes(resID), dimx, dimy, bLoadPalette); +} /****************************************************************************\ * Metodi di RMGfxWoodyBuffer @@ -248,6 +275,14 @@ void RMGfxWoodyBuffer::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { RMGfxSourceBuffer16::Draw(bigBuf, prim); } +inline RMGfxWoodyBuffer::RMGfxWoodyBuffer() { + +} + +inline RMGfxWoodyBuffer::RMGfxWoodyBuffer(int dimx, int dimy, bool bUseDDraw) + : RMGfxBuffer(dimx,dimy,16,bUseDDraw) { + +} /****************************************************************************\ @@ -372,6 +407,11 @@ void RMGfxTargetBuffer::AddPrim(RMGfxPrimitive *prim) { g_system->unlockMutex(csModifyingOT); } +inline void RMGfxTargetBuffer::AddClearTask(void) { + AddPrim(new RMGfxPrimitive(&taskClear)); +} + + /****************************************************************************\ * Metodi di RMGfxSourceBufferPal \****************************************************************************/ @@ -397,8 +437,7 @@ int RMGfxSourceBufferPal::LoadPaletteWA(const byte *buf, bool bSwapped) { return (1<> 10) & 0x1F) @@ -1827,6 +1919,29 @@ void RMGfxSourceBuffer16::PrepareImage(void) { } +inline RMGfxSourceBuffer16::RMGfxSourceBuffer16(int dimx, int dimy, bool bUseDDraw) + : RMGfxBuffer(dimx,dimy,16,bUseDDraw) { + SetPriority(0); +} + +/****************************************************************************\ +* +* Function: int RMGfxSourceBuffer16::Bpp(); +* +* Description: Ritorna il numero di bit per pixel della surface +* +* Return: Bit per pixel +* +\****************************************************************************/ + +inline int RMGfxSourceBuffer16::Bpp() { + return 16; +} + +inline void RMGfxSourceBuffer16::Create(int dimx, int dimy, bool bUseDDraw) { + RMGfxBuffer::Create(dimx,dimy,16,bUseDDraw); +} + /****************************************************************************\ * Metodi di RMGfxBox \****************************************************************************/ @@ -1860,4 +1975,24 @@ void RMGfxBox::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { } } + +/****************************************************************************\ +* Metodi di RMGfxClearTask +\****************************************************************************/ + +inline int RMGfxClearTask::Priority() { + // Priorita' massima (deve essere fatto per primo) + return 1; +} + +inline void RMGfxClearTask::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *) { + // Pulisce tutto il target buffer + Common::fill((byte *)bigBuf, (byte *)bigBuf + (bigBuf.Dimx() * bigBuf.Dimy() * 2), 0x0); +} + +inline bool RMGfxClearTask::RemoveThis() { + // Il task di clear si disattiva sempre + return true; +} + } // End of namespace Tony diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index b6a10ab778..708e3adfa8 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -294,7 +294,7 @@ public: int LoadPaletteWA(uint32 resID, bool bSwapped = false); int LoadPaletteWA(const byte *buf, bool bSwapped = false); int LoadPalette(uint32 resID); - int LoadPalette(byte *buf); + int LoadPalette(const byte *buf); }; -- cgit v1.2.3 From fde1f13676273405cd2d686f1e0ae53834c049ff Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 3 May 2012 13:32:09 +1000 Subject: TONY: Implemented stubs for Input.cpp methods --- engines/tony/input.cpp | 253 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 253 insertions(+) (limited to 'engines') diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp index 367317bd88..72c7bf06f7 100644 --- a/engines/tony/input.cpp +++ b/engines/tony/input.cpp @@ -49,6 +49,259 @@ namespace Tony { +#define DIRELEASE(x) if (x) { (x)->Release(); (x)=NULL; } +void RMInput::DIInit(/*HINSTANCE hInst*/) { +#ifdef REFACTOR_ME + HRESULT err; + + // Crea l'oggetto madre + err = DirectInputCreate(hInst, DIRECTINPUT_VERSION, &m_DI, NULL); + if (err!=DI_OK) + { + MessageBox(theGame.m_wnd,"Error initializing DirectInput!","RMInput::DIInit()",MB_OK); + assert(0); + } + + // Crea il device del mouse + // ************************ + err=m_DI->CreateDevice(GUID_SysMouse,&m_DIDMouse,NULL); + if (err!=DI_OK) + { + MessageBox(theGame.m_wnd,"Error creating mouse device!","RMInput::DIInit()",MB_OK); + assert(0); + } + + // Setta il data format + err=m_DIDMouse->SetDataFormat(&c_dfDIMouse); + if (err!=DI_OK) + { + MessageBox(theGame.m_wnd,"Error setting mouse data format!","RMInput::DIInit()",MB_OK); + assert(0); + } + + // Setta il cooperative level + err=m_DIDMouse->SetCooperativeLevel(theGame.m_wnd,DISCL_FOREGROUND|DISCL_NONEXCLUSIVE); + if (err!=DI_OK) + { + MessageBox(theGame.m_wnd,"Error setting cooperative level!","RMInput::DIInit()",MB_OK); + assert(0); + } + + // Crea il device della tastiera + // ***************************** + err=m_DI->CreateDevice(GUID_SysKeyboard,&m_DIDKeyboard,NULL); + if (err!=DI_OK) + { + MessageBox(theGame.m_wnd,"Error creating keyboard device!","RMInput::DIInit()",MB_OK); + assert(0); + } + + // Setta il data format + err=m_DIDKeyboard->SetDataFormat(&c_dfDIKeyboard); + if (err!=DI_OK) + { + MessageBox(theGame.m_wnd,"Error setting keyboard data format!","RMInput::DIInit()",MB_OK); + assert(0); + } + + // Setta il cooperative level + err=m_DIDKeyboard->SetCooperativeLevel(theGame.m_wnd,DISCL_FOREGROUND|DISCL_NONEXCLUSIVE); + if (err!=DI_OK) + { + MessageBox(theGame.m_wnd,"Error setting cooperative level!","RMInput::DIInit()",MB_OK); + assert(0); + } +#endif +} + +void RMInput::SwitchFullscreen(bool bFull) { +#ifdef REFACTOR_ME + HRESULT err; + + // Il camping del mouse e' attivo solo in fullscreen + m_bClampMouse=bFull; + + // Prima di tutto leviamo l'acquiring ai device, altrimenti non possiamo cambiare il + // cooperative level + Unacquire(); + + if (bFull) + { + // Setta il cooperative level + err=m_DIDMouse->SetCooperativeLevel(theGame.m_wnd,DISCL_FOREGROUND|DISCL_EXCLUSIVE); + if (err!=DI_OK) + { + MessageBox(theGame.m_wnd,"Error setting cooperative level!","RMInput::DIInit()",MB_OK); + assert(0); + } + } + else + { + // Setta il cooperative level + err=m_DIDMouse->SetCooperativeLevel(theGame.m_wnd,DISCL_FOREGROUND|DISCL_EXCLUSIVE); + if (err!=DI_OK) + { + MessageBox(theGame.m_wnd,"Error setting cooperative level!","RMInput::DIInit()",MB_OK); + assert(0); + } + } +#endif +} + +void RMInput::DIClose(void) +{ +#ifdef REFACTOR_ME + DIRELEASE(m_DIDMouse); + DIRELEASE(m_DI); +#endif +} + + +bool RMInput::Acquire(void) { +#ifdef REFACTOR_ME + HRESULT err; + + if (m_DIDMouse == NULL) + return true; + + // Inizializza la posizione del mouse + POINT pt; + RECT rc; + GetWindowRect(theGame.m_wnd,&rc); + GetCursorPos(&pt); + m_mX=pt.x-rc.left-GetSystemMetrics(SM_CXDLGFRAME); + m_mY=pt.y-rc.top-(GetSystemMetrics(SM_CYDLGFRAME)+GetSystemMetrics(SM_CYCAPTION)); + + err=m_DIDMouse->Acquire(); + if (err!=DI_OK) + return false; + + err=m_DIDKeyboard->Acquire(); + if (err!=DI_OK) + return false; +#endif + return true; +} + +void RMInput::Unacquire(void) { +#ifdef REFACTOR_ME + if (m_DIDMouse!=NULL) + m_DIDMouse->Unacquire(); + + if (m_DIDKeyboard!=NULL) + m_DIDKeyboard->Unacquire(); +#endif +} + + +void RMInput::GDIControl(bool bCon) { +#ifdef REFACTOR_ME + if (bCon) + { + Unacquire(); + ShowCursor(true); + } + else + { + ShowCursor(false); + Acquire(); + } +#endif +} + +void RMInput::Poll(void) { +#ifdef REFACTOR_ME + HRESULT err; + bool mLastLeft, mLastRight; + + mLastLeft=MouseLeft(); + mLastRight=MouseRight(); + m_bLeftClickMouse=m_bLeftReleaseMouse=m_bRightClickMouse=m_bRightReleaseMouse=false; + + // Legge lo stato del mouse + while (1) + { + ZeroMemory(&m_mState,sizeof(m_mState)); + err=m_DIDMouse->GetDeviceState(sizeof(m_mState),&m_mState); + if (err==DI_OK) + break; + else if (err==DIERR_INPUTLOST || err==DIERR_NOTACQUIRED) + { + ZeroMemory(&m_mState,sizeof(m_mState)); + // Se l'acquire non funziona (ad esempio, quando siamo in background, allora lasciamo perdere + if (!Acquire()) + return; + } + else + break; + } + + // Aggiorna le coordinate del mouse + m_mX+=m_mState.lX; + m_mY+=m_mState.lY; + + // Clamp dei valori sui bordi della finestra + if (m_bClampMouse) + { + if (m_mX<0) m_mX=0; + if (m_mY<0) m_mY=0; + if (m_mX>=640) m_mX=639; + if (m_mY>=480) m_mY=479; + } + + // Controlla se e' cambiato lo stato dei bottoni + if (mLastLeft && !MouseLeft()) + m_bLeftReleaseMouse=true; + + if (!mLastLeft && MouseLeft()) + m_bLeftClickMouse=true; + + if (mLastRight && !MouseRight()) + m_bRightReleaseMouse=true; + + if (!mLastRight && MouseRight()) + m_bRightClickMouse=true; +#endif +} + + +RMInput::RMInput() { + m_bClampMouse = false; +} + +RMInput::~RMInput() { + +} + +void RMInput::Init(/*HINSTANCE hInst*/) { +#ifdef REFACTOR_ME + DIInit(hInst); +#ifdef STARTFULLSCREEN + SwitchFullscreen(true); +#endif + Acquire(); +#endif +} + +void RMInput::Close(void) { + Unacquire(); + DIClose(); +} + + +bool RMInput::MouseLeft() { + return false; +#ifdef REFACTOR_ME + return (m_mState.rgbButtons[0] & 0x80); +#endif +} + +bool RMInput::MouseRight() { + return false; +#ifdef REFACTOR_ME + return (m_mState.rgbButtons[1] & 0x80); +#endif +} } // End of namespace Tony -- cgit v1.2.3 From ba2711b5e39e495c4cfb1187710605bb9fbf10b1 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 3 May 2012 21:43:00 +1000 Subject: TONY: Implemented methods of sound.cpp (mostly stubbed out) --- engines/tony/input.h | 2 +- engines/tony/sound.cpp | 2230 ++++++++++++++++++++++++++++++++++++++++++++++++ engines/tony/sound.h | 17 +- 3 files changed, 2243 insertions(+), 6 deletions(-) (limited to 'engines') diff --git a/engines/tony/input.h b/engines/tony/input.h index 554b10628b..bff6dcd396 100644 --- a/engines/tony/input.h +++ b/engines/tony/input.h @@ -65,7 +65,7 @@ private: private: // Inizializza DirectInput - void DIInit(uint32 hInst); + void DIInit(/*uint32 hInst*/); // Deinizializza DirectInput void DIClose(void); diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index 5d940b3145..e757ac4115 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -45,10 +45,2240 @@ * * **************************************************************************/ +#include "common/textconsole.h" #include "tony/game.h" +#include "tony/tony.h" namespace Tony { +extern bool bCfgMusic; +extern bool bCfgSFX; +extern bool bCfgDubbing; +extern int nCfgSFXVolume; +extern int nCfgMusicVolume; +extern int nCfgDubbingVolume; +/****************************************************************************\ +* Defines +\****************************************************************************/ + +/* Massimo numero di bytes da decodificare in una singola chiamata a CODEC */ +#define MAXDECODESIZE (44100 * 2 * 2) + +#define RELEASE(x) {if ((x) != NULL) { (x)->Release(); x = NULL; }} + +/****************************************************************************\ +***************************************************************************** +* class CODEC (ABSTRACT) +* ----------- +* Description: classe base per CODEC. +***************************************************************************** +\****************************************************************************/ + +class CODEC { +protected: + bool bEndReached; + +public: + bool bLoop; + CODEC(bool bLoop = true); + virtual ~CODEC(); + virtual uint32 Decompress(HANDLE hStream, void *lpBuf, uint32 dwSize) = 0; + virtual uint32 Decompress(Common::File &fp, void *lpBuf, uint32 dwSize) = 0; + virtual void LoopReset() = 0; + bool EndOfStream(); +}; + + +/****************************************************************************\ +***************************************************************************** +* class CODECRAW +* -------------- +* Description: CODEC di play da disco di campioni puri +***************************************************************************** +\****************************************************************************/ + +class CODECRAW : public CODEC { +public: + CODECRAW(bool bLoop = true); + virtual ~CODECRAW(); + virtual uint32 Decompress(HANDLE hStream, void *lpBuf, uint32 dwSize); + virtual uint32 Decompress(Common::File &fp, void *lpBuf, uint32 dwSize); + virtual void LoopReset(); +}; + + +/****************************************************************************\ +***************************************************************************** +* class CODECADPCM +* ---------------- +* Description: CODEC per play di compressione ADPCM +***************************************************************************** +\****************************************************************************/ + +class CODECADPCM : public CODECRAW { +protected: + byte *lpTemp; + static int indexTable[16]; + static int stepSizeTable[89]; + +public: + CODECADPCM(bool bLoop = true, byte *lpTempBuffer = NULL); + virtual ~CODECADPCM(); + virtual uint32 Decompress(HANDLE hStream, void *lpBuf, uint32 dwSize) = 0; + virtual uint32 Decompress(Common::File &fp, void *lpBuf, uint32 dwSize) = 0; + virtual void LoopReset() = 0; +}; + +class CODECADPCMSTEREO : public CODECADPCM { +protected: + int valpred[2], index[2]; + +public: + CODECADPCMSTEREO(bool bLoop = true, byte *lpTempBuffer = NULL); + virtual ~CODECADPCMSTEREO(); + virtual uint32 Decompress(HANDLE hStream, void *lpBuf, uint32 dwSize); + virtual uint32 Decompress(Common::File &fp, void *lpBuf, uint32 dwSize); + virtual void LoopReset(); +}; + +class CODECADPCMMONO : public CODECADPCM { +protected: + int valpred, index; + +public: + CODECADPCMMONO(bool bLoop = true, byte *lpTempBuffer = NULL); + virtual ~CODECADPCMMONO(); + virtual uint32 Decompress(HANDLE hStream, void *lpBuf, uint32 dwSize); + virtual uint32 Decompress(Common::File &fp, void *lpBuf, uint32 dwSize); + virtual void LoopReset(); +}; + +/****************************************************************************\ +* Metodi per CODEC +\****************************************************************************/ + + +/****************************************************************************\ +* +* Function: CODEC::CODEC(bool loop = true); +* +* Description: Costruttore standard. E' possibile specificare se si vuole +* attivare o disattivare il loop (che di default e' attivo). +* +* Input: bool loop true se si vuole attivare il loop, +* false per disattivarlo +* +\****************************************************************************/ + +CODEC::CODEC(bool loop) { + bLoop = loop; + bEndReached = false; +} + +CODEC::~CODEC() +{ + +} + +/****************************************************************************\ +* +* Function: bool CODEC::EndOfStream() +* +* Description: Informa se abbiamo raggiunto la fine dello stream +* +* Return: true se siamo arrivati alla fine, false altrimenti +* +\****************************************************************************/ + +bool CODEC::EndOfStream() { + return bEndReached; +} + + +/****************************************************************************\ +* Metodi per CODECRAW +\****************************************************************************/ + +/****************************************************************************\ +* +* Function: CODECRAW::CODECRAW(bool loop = true); +* +* Description: Costruttore standard. Richiama solamente il costruttore della +* classe astratta CODEC. +* +* Input: bool loop true se si vuole attivare il loop, +* false per disattivarlo +* +\****************************************************************************/ + +CODECRAW::CODECRAW(bool loop) : CODEC(loop) { +} + +CODECRAW::~CODECRAW() { + +} + +/****************************************************************************\ +* +* Function: CODECRAW::LoopReset(); +* +* Description: Resetta il playing prima di iniziare di nuovo il file. +* Nel caso dei file RAW non fa nulla. +* +\****************************************************************************/ + +void CODECRAW::LoopReset() { +} + +/****************************************************************************\ +* +* Function: uint32 CODECRAW::Decompress(HANDLE hStream, void *lpBuf, +* uint32 dwSize) +* +* Description: Gestisce il formato RAW: semplicemente copia dal file +* stream nel buffer. +* +* Return: Se e' stata raggiunta la fine del file, indica quale byte, +* tra quelli letti, e' l'inizio del nuovo loop. Altrimenti +* il valore non e' determinato. +* +\****************************************************************************/ + +uint32 CODECRAW::Decompress(HANDLE hStream, void *buf, uint32 dwSize) { +#if 0 + byte *lpBuf = (byte *)buf; + uint32 dwRead; + uint32 dwEOF; + + bEndReached = false; + dwEOF = 0; + ReadFile(hStream,lpBuf,dwSize, &dwRead, NULL); + + if (dwRead>4)&0xF; + } + else + delta=cache&0xF; + + /* Trova il nuovo indice */ + index+=indexTable[delta]; + if (index<0) index = 0; + if (index>88) index=88; + + /* Legge il segno e lo separa dall'ampliamento */ + sign=delta&8; + delta=delta&7; + + /* Trova la differenza dal valore precedente */ + vpdiff=step>>3; + if (delta&4) vpdiff+=step; + if (delta&2) vpdiff+=step>>1; + if (delta&1) vpdiff+=step>>2; + + if (sign) + valpred-=vpdiff; + else + valpred+=vpdiff; + + /* Controlla i limiti del valore trovato */ + if (valpred > 32767) + valpred = 32767; + else if (valpred<-32768) + valpred=-32768; + + /* Aggiorna lo step */ + step=stepSizeTable[index]; + + /* Scrive il valore trovato */ + *lpBuf++ = (signed short)valpred; + + bufferstep=!bufferstep; + } + + return eof/2; +#endif + return 0; +} + +uint32 CODECADPCMMONO::Decompress(Common::File &fp, void *buf, uint32 dwSize) { + uint16 *lpBuf = (uint16 *)buf; + byte *inp; + int bufferstep; + int cache; + int delta; + int sign; + int vpdiff; + uint32 eof, i; + int step; + + bufferstep = 1; + step = stepSizeTable[index]; + + /* Richiama il CODEC RAW per leggere da disco lo stream con loop. La + chiamata e' possibile perche' abbiamo ereditato CODECADPCM da CODECRAW, + e non semplicemente da CODEC. */ + eof = CODECRAW::Decompress(fp, lpTemp, dwSize / 4); + inp = lpTemp; + + eof *= 2; + + /* Se bisogna loopare subito lo fa */ + if (EndOfStream() && eof == 0) { + LoopReset(); + bufferstep = 1; + step = stepSizeTable[index]; + } else if (!EndOfStream()) + eof = 0; + + dwSize /= 2; + for (i = 0;i < dwSize; i++) { + /* Controlla se siamo alla fine del file, e bisogna loopare */ + if (eof != 0 && i == eof) { + LoopReset(); + bufferstep=1; + step = stepSizeTable[index]; + } + + /* Legge il delta (4 bit) */ + if (bufferstep) { + cache = *inp++; + delta = (cache>>4)&0xF; + } else + delta=cache&0xF; + + /* Trova il nuovo indice */ + index += indexTable[delta]; + if (index < 0) index = 0; + if (index > 88) index=88; + + /* Legge il segno e lo separa dall'ampliamento */ + sign = delta&8; + delta = delta&7; + + /* Trova la differenza dal valore precedente */ + vpdiff = step >> 3; + if (delta&4) vpdiff+=step; + if (delta&2) vpdiff+=step >> 1; + if (delta&1) vpdiff+=step >> 2; + + if (sign) + valpred -= vpdiff; + else + valpred += vpdiff; + + /* Controlla i limiti del valore trovato */ + if (valpred > 32767) + valpred = 32767; + else if (valpred < -32768) + valpred =- 32768; + + /* Aggiorna lo step */ + step = stepSizeTable[index]; + + /* Scrive il valore trovato */ + *lpBuf ++= (signed short)valpred; + + bufferstep = !bufferstep; + } + + return eof / 2; +} + +uint32 CODECADPCMSTEREO::Decompress(HANDLE hFile, void *buf, uint32 dwSize) { + uint16 *lpBuf = (uint16 *)buf; + byte *inp; + int bufferstep; + int cache; + int delta; + int sign; + int vpdiff; + uint32 eof, i; + int step[2]; + + bufferstep = 1; + step[0] = stepSizeTable[index[0]]; + step[1] = stepSizeTable[index[1]]; + + /* Richiama il CODEC RAW per leggere da disco lo stream con loop. La + chiamata e' possibile perche' abbiamo ereditato CODECADPCM da CODECRAW, + e non semplicemente da CODEC. */ + eof = CODECRAW::Decompress(hFile, lpTemp, dwSize / 4); + inp = lpTemp; + + eof *= 2; + + /* Se bisogna loopare subito lo fa */ + if (EndOfStream() && eof == 0) { + LoopReset(); + bufferstep = 1; + step[0] = stepSizeTable[index[0]]; + step[1] = stepSizeTable[index[1]]; + } else if (!EndOfStream()) + eof = 0; + + dwSize /= 2; + for (i = 0; i < dwSize; i++) { + /* Controlla se siamo alla fine del file, e bisogna loopare */ + if (eof != 0 && i == eof) { + LoopReset(); + bufferstep=1; + step[0] = stepSizeTable[index[0]]; + step[1] = stepSizeTable[index[1]]; + } + + /* Legge il delta (4 bit) */ + if (bufferstep) { + cache = *inp++; + delta = cache & 0xF; + } else + delta = (cache >> 4) & 0xF; + + /* Trova il nuovo indice */ + index[bufferstep]+=indexTable[delta]; + if (index[bufferstep] < 0) index[bufferstep] = 0; + if (index[bufferstep] > 88) index[bufferstep] = 88; + + /* Legge il segno e lo separa dall'ampliamento */ + sign = delta & 8; + delta = delta & 7; + + /* Trova la differenza dal valore precedente */ + vpdiff = step[bufferstep] >> 3; + if (delta & 4) vpdiff += step[bufferstep]; + if (delta & 2) vpdiff += step[bufferstep]>>1; + if (delta & 1) vpdiff += step[bufferstep]>>2; + + if (sign) + valpred[bufferstep]-=vpdiff; + else + valpred[bufferstep]+=vpdiff; + + /* Controlla i limiti del valore trovato */ + if (valpred[bufferstep] > 32767) + valpred[bufferstep] = 32767; + else if (valpred[bufferstep] < -32768) + valpred[bufferstep] = -32768; + + /* Aggiorna lo step */ + step[bufferstep] = stepSizeTable[index[bufferstep]]; + + /* Scrive il valore trovato */ + *lpBuf ++= (signed short)valpred[bufferstep]; + + bufferstep=!bufferstep; + } + + return eof / 2; +} + + +uint32 CODECADPCMSTEREO::Decompress(Common::File &fp, void *buf, uint32 dwSize) { + uint16 *lpBuf = (uint16 *)buf; + byte *inp; + int bufferstep; + int cache; + int delta; + int sign; + int vpdiff; + uint32 eof,i; + int step[2]; + + bufferstep = 1; + step[0] = stepSizeTable[index[0]]; + step[1] = stepSizeTable[index[1]]; + + /* Richiama il CODEC RAW per leggere da disco lo stream con loop. La + chiamata e' possibile perche' abbiamo ereditato CODECADPCM da CODECRAW, + e non semplicemente da CODEC. */ + eof = CODECRAW::Decompress(fp, lpTemp, dwSize / 4); + inp = lpTemp; + + eof *= 2; + /* Se bisogna loopare subito lo fa */ + if (EndOfStream() && eof == 0) { + LoopReset(); + bufferstep = 1; + step[0] = stepSizeTable[index[0]]; + step[1] = stepSizeTable[index[1]]; + } else if (!EndOfStream()) + eof = 0; + + dwSize /= 2; + for (i = 0; i < dwSize; i++) { + /* Controlla se siamo alla fine del file, e bisogna loopare */ + if (eof != 0 && i==eof) { + LoopReset(); + bufferstep=1; + step[0] = stepSizeTable[index[0]]; + step[1] = stepSizeTable[index[1]]; + } + + /* Legge il delta (4 bit) */ + if (bufferstep) { + cache = *inp++; + delta = cache & 0xF; + } else + delta = (cache >> 4) & 0xF; + + /* Trova il nuovo indice */ + index[bufferstep] += indexTable[delta]; + if (index[bufferstep] < 0) index[bufferstep] = 0; + if (index[bufferstep] > 88) index[bufferstep] = 88; + + /* Legge il segno e lo separa dall'ampliamento */ + sign = delta & 8; + delta = delta & 7; + + /* Trova la differenza dal valore precedente */ + vpdiff = step[bufferstep]>>3; + if (delta & 4) vpdiff += step[bufferstep]; + if (delta & 2) vpdiff += step[bufferstep] >> 1; + if (delta & 1) vpdiff += step[bufferstep] >> 2; + + if (sign) + valpred[bufferstep]-=vpdiff; + else + valpred[bufferstep]+=vpdiff; + + /* Controlla i limiti del valore trovato */ + if (valpred[bufferstep] > 32767) + valpred[bufferstep] = 32767; + else if (valpred[bufferstep] < -32768) + valpred[bufferstep] = -32768; + + /* Aggiorna lo step */ + step[bufferstep] = stepSizeTable[index[bufferstep]]; + + /* Scrive il valore trovato */ + *lpBuf ++= (signed short)valpred[bufferstep]; + + bufferstep = !bufferstep; + } + + return eof / 2; +} + + +/****************************************************************************\ +* Metodi per FPSOUND +\****************************************************************************/ + +/****************************************************************************\ +* +* Function: FPSOUND::FPSOUND(); +* +* Description: Costruttore di default. Inizializza gli attributi. +* +\****************************************************************************/ + +FPSOUND::FPSOUND() { + lpDS = NULL; + lpDSBPrimary = NULL; +} + + +/****************************************************************************\ +* +* Function: bool FPSOUND::Init(HWND hWnd); +* +* Description: Inizializza l'oggetto, e prepara tutto il necessario per +* creare stream e effetti sonori. +* +* Input: HWND hWnd Handle della finestra principale +* +* Return: True se tutto OK, false in caso di errore. +* +\****************************************************************************/ + +bool FPSOUND::Init(/*HWND hWnd*/) { +#ifdef REFACTOR_ME + HRESULT err; + static DSBUFFERDESC dsbdesc; + static PCMWAVEFORMAT pcmwf; + static char errbuf[128]; + + /* Salva l'handle della finestra nella variabile globale. DirectSound ha + bisogno dell'handle per effetuare il multitasking sonoro. */ + hwnd = hWnd; + + /* Di default, disabilita il sonoro. Se non troveremo problemi, lo + riabiliteremo alla fine della routine */ + bSoundSupported = false; + + /* Crea un oggetto DirectSound. Usiamo il driver sonoro settato di default. + In realta' sarebbe possibile richiedere una lista delle schede sonore + presenti, e lasciare scegliere all'utente quale utilizzare, ma mi sembra + una perdita di tempo. */ + if ((err = DirectSoundCreate(NULL, &lpDS, NULL)) != DS_OK) { + return false; + } + + /* Richiede le caratteristiche del driver sonoro */ + dscaps.dwSize = sizeof(dscaps); + lpDS->GetCaps(&dscaps); + + /* Controlla se siamo in emulazione, e in caso affermativo avverte l'utente */ + if ((dscaps.dwFlags & DSCAPS_EMULDRIVER)) + error("The current sound driver is not directly supported by DirectSound. This will slow down sound performance of the game."); + + /* Setta il livello di cooperazione a esclusivo. In questo modo il gioco + sara' il solo ad accedere alla scheda sonora mentre e' in escuzione, ed + eventuali player in background saranno automaticamente stoppati. + Inoltre in questo modo e' possibile settare il formato di output sonoro + del primary buffer */ + if ((err = lpDS->SetCooperativeLevel(hWnd, DSSCL_PRIORITY)) != DS_OK) { + MessageBox(hwnd,"Cannot set exclusive mode!","soundInit()", MB_OK); + return false; + } + + + /* Crea il primary buffer. In realta' DirectSound la farebbe automaticamente, + ma noi vogliamo il pointer al primary perche' dobbiamo settare il + formato di output */ + ZeroMemory(&dsbdesc,sizeof(dsbdesc)); + dsbdesc.dwSize=sizeof(dsbdesc); + dsbdesc.dwFlags=DSBCAPS_CTRLVOLUME|DSBCAPS_PRIMARYBUFFER; + if (lpDS->CreateSoundBuffer(&dsbdesc, &lpDSBPrimary, NULL) != DS_OK) { + MessageBox(hwnd,"Cannot create primary buffer!","soundInit()", MB_OK); + return false; + } + + /* Settiamo il formato del buffer primario. L'ideale sarebbe 16bit 44khz + stereo, ma dobbiamo anche controllare che cio' sia permesso dalla scheda + sonora, guardando nelle caratteristiche che abbiamo richiesto sopra. + Inoltre in seguito sara' possibile lasciare scegliere all'utente il + formato da utilizzare */ + pcmwf.wBitsPerSample = ((dscaps.dwFlags&DSCAPS_PRIMARY16BIT) != 0 ? 16 : 8); + pcmwf.wf.wFormatTag = WAVE_FORMAT_PCM; + pcmwf.wf.nChannels = ((dscaps.dwFlags&DSCAPS_PRIMARYSTEREO) != 0 ? 2 : 1); + pcmwf.wf.nSamplesPerSec = 44100; + pcmwf.wf.nBlockAlign = (pcmwf.wBitsPerSample / 8) * pcmwf.wf.nChannels; + pcmwf.wf.nAvgBytesPerSec = (uint32)pcmwf.wf.nBlockAlign * (uint32)pcmwf.wf.nSamplesPerSec; + + if ((err = lpDSBPrimary->SetFormat((LPWAVEFORMATEX) & pcmwf)) != DS_OK) { + wsprintf(errbuf,"Error setting the output format (%lx)",err); + MessageBox(hwnd,errbuf,"soundInit()", MB_OK); + return false; + } + + /* Controlla che il driver DirectSound supporti buffer secondari con + play di stream 16bit, 44khz stereo */ + if (dscaps.dwMaxSecondarySampleRate != 0 && dscaps.dwMaxSecondarySampleRate < 44100) { + wsprintf(errbuf,"Driver does not support 16bit 44khz stereo mixing! (%lu)",dscaps.dwMaxSecondarySampleRate); + MessageBox(hwnd,errbuf,"soundInit()", MB_OK); + return false; + } + + /* Tutto OK. */ + bSoundSupported = true; +#endif + return true; +} + + +/****************************************************************************\ +* +* Function: FPSOUND::~FPSOUND(); +* +* Description: Deinizializza l'oggetto, disallocando la memoria. +* +\****************************************************************************/ + +FPSOUND::~FPSOUND() { +#ifdef REFACTOR_ME + RELEASE(lpDSBPrimary); + RELEASE(lpDS); +#endif +} + + +/****************************************************************************\ +* +* Function: bool CreateStream(FPSTREAM** lplpStream); +* +* Description: Alloca un oggetti di tipo FPSTREAM, e ritorna il suo +* puntatore dopo averlo inizializzato. +* +* Input: FPSTREAM** lplpStream Conterra' il pointer all'oggetto +* appena creato. +* +* Return: true se tutto OK, false in caso di errore +* +* Note: L'utilizzo di funzioni del tipo CreateStream(), CreateSfx(), +* sono dovute al fatto che i costruttori delle classi FPSTREAM +* e FPSFX richiedono che DirectSound sia gia' stato +* inzializzato. In questo modo quindi si evitano dei bugs +* che si verrebbero a creare se venisse dichiarata un oggetto +* di tipo FPSTREAM o FPSFX globale (o cmq prima della +* inizializzazione di DirectSound). +* +\****************************************************************************/ + +bool FPSOUND::CreateStream(FPSTREAM **lplpStream) { + (*lplpStream) = new FPSTREAM(lpDS, hwnd, bSoundSupported); + + return (*lplpStream != NULL); +} + + + +/****************************************************************************\ +* +* Function: bool CreateSfx(FPSFX** lplpSfx); +* +* Description: Alloca un oggetti di tipo FPSFX e ritorna il suo +* puntatore dopo averlo inizializzato. +* +* Input: FPSFX** lplpSfx Conterra' il pointer all'oggetto +* appena creato. +* +* Return: true se tutto OK, false in caso di errore +* +* Note: Vedi le note di CreateStream() +* +\****************************************************************************/ + +bool FPSOUND::CreateSfx(FPSFX **lplpSfx) { + (*lplpSfx) = new FPSFX(lpDS, hwnd, bSoundSupported); + + return (*lplpSfx != NULL); +} + + + +/****************************************************************************\ +* +* Function: void SetMasterVolume(int dwVolume); +* +* Description: Setta il volume generale +* +* Input: int dwVolume Volume da settare (0-63) +* +\****************************************************************************/ + +void FPSOUND::SetMasterVolume(int dwVolume) { +#ifdef REFACTOR_ME + + if (!bSoundSupported) + return; + + if (dwVolume > 63) dwVolume = 63; + if (dwVolume < 0) dwVolume = 0; + + lpDSBPrimary->SetVolume(dwVolume * (DSBVOLUME_MAX - DSBVOLUME_MIN) / 64 + DSBVOLUME_MIN); +#endif +} + + +/****************************************************************************\ +* +* Function: void GetMasterVolume(int *lpdwVolume); +* +* Description: Richiede il volume generale +* +* Input: int *lpdwVolume Variabile che conterra' il volume (0-63) +* +\****************************************************************************/ + +void FPSOUND::GetMasterVolume(int *lpdwVolume) { +#ifdef REFACTOR_ME + if (!bSoundSupported) + return; + + lpDSBPrimary->GetVolume((uint32 *)lpdwVolume); + *lpdwVolume -= (DSBVOLUME_MIN); + *lpdwVolume *= 64; + *lpdwVolume /= (DSBVOLUME_MAX - DSBVOLUME_MIN); +#endif +} + + +/****************************************************************************\ +* Metodi di FPSFX +\****************************************************************************/ + +/****************************************************************************\ +* +* Function: FPSFX(LPDIRECTSOUND lpDS, bool bSoundOn); +* +* Description: Costruttore di default. *NON* bisogna dichiarare direttamente +* un oggetto, ma crearlo piuttosto tramite FPSOUND::CreateSfx() +* +\****************************************************************************/ + +FPSFX::FPSFX(LPDIRECTSOUND lpds, HWND hWnd, bool bSoundOn) { +#ifdef REFACTOR_ME + + static char errbuf[128]; + + //hwnd=hWnd; + bSoundSupported = bSoundOn; + bFileLoaded = false; + bIsPlaying = false; + bPaused = false; + lpDSBuffer = NULL; + lpDSNotify = NULL; + lpDS = lpds; + lastVolume = 63; + hEndOfBuffer = INVALID_HANDLE_VALUE; + bIsVoice = false; + + if (bSoundSupported == false) + return; + + /* Poich non abbiamo ancora nessun dato sull'effetto sonoro, non possiamo fare nulla */ +#endif +} + + +/****************************************************************************\ +* +* Function: ~FPSFX(); +* +* Description: Distruttore di default. Si preoccupa anche di fermare il sound +* effect eventualmente in esecuzione, e disallocare la memoria +* da esso occupata. +* +\****************************************************************************/ + +FPSFX::~FPSFX() { +#ifdef REFACTOR_ME + + if (!bSoundSupported) + return; + + if (bIsPlaying) + Stop(); + + RELEASE(lpDSNotify); + + if (hEndOfBuffer != INVALID_HANDLE_VALUE) + CloseHandle(hEndOfBuffer); + + RELEASE(lpDSBuffer); +#endif +} + + +/****************************************************************************\ +* +* Function: Release(); +* +* Description: Rilascia la memoria dell'oggetto. Deve essere richiamata quando +* l'oggetto non serve piu' e **SOLO SE** l'oggetto e' stato +* creato con la FPSOUND::CreateStream(). +* +* Note: Eventuali puntatori all'oggetto non sono piu' validi dopo +* questa chiamata. +* +\****************************************************************************/ + +void FPSFX::Release() { + delete this; +// return NULL; +} + + + +/****************************************************************************\ +* +* Function: bool LoadFile(byte *lpBuf); +* +* Description: Apre un file di effetto sonoro e lo carica. +* +* Input: byte *lpBuf Buffer dove si trova l'sfx +* uint32 dwCoded CODEC da utilizzare per decomprimere +* i campioni sonori +* +* Return: true se tutto OK, false in caso di errore +* +\****************************************************************************/ + +bool FPSFX::LoadFile(byte *lpBuf, uint32 dwCodec) { +#ifdef REFACTOR_ME + static PCMWAVEFORMAT pcmwf; + static DSBUFFERDESC dsbdesc; + static HRESULT err; + static char errbuf[128]; + uint32 dwHi; + struct WAVH { + int nChunckSize; + uint16 wFormatTag; + uint16 nChannels; + int nSamplesPerSec; + int nAvgBytesPerSec; + uint16 nBlockAlign; + uint16 nBitsPerSample; + } *WAVHeader; + uint32 dwSize; + void *lpLock; + + if (!bSoundSupported) + return true; + + /* Nel buffer troviamo un file WAV completo, almeno per ora */ + if (dwCodec != FPCODEC_WAV) + return false; + + if (lpBuf[0] != 'W' || lpBuf[1] != 'A' || lpBuf[2] != 'V' || lpBuf[3] != 'E') + return false; + if (lpBuf[4] != 'f' || lpBuf[5] != 'm' || lpBuf[6] != 't' || lpBuf[7] != ' ') + return false; + + WAVHeader = (WAVH*)(lpBuf+8); + lpBuf += 8 + sizeof(WAVH); + + if (lpBuf[0] != 'd' || lpBuf[1] != 'a' || lpBuf[2] != 't' || lpBuf[3] != 'a') + return false; + lpBuf += 4; + + dwSize = *(uint32*)lpBuf; + lpBuf += 4; + + b16bit = (WAVHeader->nBitsPerSample == 16); + bStereo = (WAVHeader->nChannels == 2); + dwFreq = WAVHeader->nSamplesPerSec; + + /* Setta le strutture necessarie per la creazione di un secondary buffer + Attiviamo inoltre il controllo del volume, in modo da poter abbassare + e alzare il volume della musica indipendentemente da quello generale. + Proviamo a buttarlo in sound ram. */ + pcmwf.wBitsPerSample = (b16bit ? 16 : 8); + pcmwf.wf.wFormatTag=WAVE_FORMAT_PCM; + pcmwf.wf.nChannels = (bStereo ? 2 : 1); + pcmwf.wf.nSamplesPerSec = dwFreq; + pcmwf.wf.nBlockAlign = (pcmwf.wBitsPerSample / 8) * pcmwf.wf.nChannels; + pcmwf.wf.nAvgBytesPerSec = (uint32)pcmwf.wf.nBlockAlign * (uint32)pcmwf.wf.nSamplesPerSec; + + dsbdesc.dwSize = sizeof(dsbdesc); + dsbdesc.dwFlags = DSBCAPS_CTRLVOLUME | DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLPOSITIONNOTIFY; + dsbdesc.dwBufferBytes = dwSize; + dsbdesc.lpwfxFormat = (LPWAVEFORMATEX)&pcmwf; + + if ((err = lpDS->CreateSoundBuffer(&dsbdesc, &lpDSBuffer, NULL)) != DS_OK) { + wsprintf(errbuf,"Error creating the secondary buffer (%lx)",err); + MessageBox(hwnd,errbuf,"FPSFX::FPSFX()", MB_OK); + return false; + } + + // Riempie il buffer + if ((err = lpDSBuffer->Lock(0,dwSize, &lpLock,(uint32 *)&dwHi, NULL, NULL, 0)) != DS_OK) { + MessageBox(hwnd,"Cannot lock sfx buffer!","FPSFX::LoadFile()", MB_OK); + return false; + } + + /* Decomprime i dati dello stream direttamente dentro il buffer lockato */ + CopyMemory(lpLock, lpBuf, dwSize); + + /* Unlocka il buffer */ + lpDSBuffer->Unlock(lpLock, dwSize, NULL, NULL); + + /* Setta volume iniziale */ + SetVolume(lastVolume); + + bFileLoaded = true; +#endif + return true; +} + + +/****************************************************************************\ +* +* Function: bool LoadFile(LPSTR lpszFileName, uint32 dwCodec=FPCODEC_RAW); +* +* Description: Apre un file di effetto sonoro e lo carica. +* +* Input: LPSTR lpszFile Nome del file di sfx da aprire +* uint32 dwCodec CODEC da utilizzare per decomprimere +* i campioni sonori +* +* Return: true se tutto OK, false in caso di errore +* +\****************************************************************************/ + +bool FPSFX::LoadVoiceFromVDB(Common::File &vdbFP) { +#ifdef REFACTOR_ME + uint32 dwSize; + static PCMWAVEFORMAT pcmwf; + static DSBUFFERDESC dsbdesc; + byte *lpTempBuffer; + static HRESULT err; + uint32 dwHi; + void *lpBuf; + static char errbuf[128]; + + if (!bSoundSupported) + return true; + + b16bit = true; + bStereo = false; + bIsVoice = true; + +// fread(&dwSize,1,4,vdbFP); +// fread(&dwFreq,1,4,vdbFP); + ReadFile(vdbFP, &dwSize,4, &dwHi, NULL); + ReadFile(vdbFP, &dwFreq,4, &dwHi, NULL); + + dwSize *= 4; + + /* Setta le strutture necessarie per la creazione di un secondary buffer + Attiviamo inoltre il controllo del volume, in modo da poter abbassare + e alzare il volume della musica indipendentemente da quello generale. + Proviamo a buttarlo in sound ram. */ + pcmwf.wBitsPerSample = (b16bit ? 16 : 8); + pcmwf.wf.wFormatTag=WAVE_FORMAT_PCM; + pcmwf.wf.nChannels = (bStereo ? 2 : 1); + pcmwf.wf.nSamplesPerSec = dwFreq; + pcmwf.wf.nBlockAlign = (pcmwf.wBitsPerSample / 8) * pcmwf.wf.nChannels; + pcmwf.wf.nAvgBytesPerSec = (uint32)pcmwf.wf.nBlockAlign * (uint32)pcmwf.wf.nSamplesPerSec; + + dsbdesc.dwSize = sizeof(dsbdesc); + dsbdesc.dwFlags = DSBCAPS_CTRLVOLUME | DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLPOSITIONNOTIFY; + dsbdesc.dwBufferBytes = dwSize; + dsbdesc.lpwfxFormat = (LPWAVEFORMATEX)&pcmwf; + + if ((err = lpDS->CreateSoundBuffer(&dsbdesc, &lpDSBuffer, NULL)) != DS_OK) { + wsprintf(errbuf,"Error creating the secondary buffer (%lx)",err); + MessageBox(hwnd,errbuf,"FPSFX::FPSFX()", MB_OK); + return false; + } + + /* Alloca un buffer temporaneo */ + lpTempBuffer = (byte *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, dwSize); + if (lpTempBuffer == NULL) + return false; + + lpCodec = new CODECADPCMMONO(bLoop, lpTempBuffer); + + /* Riempie il buffer */ + if ((err = lpDSBuffer->Lock(0,dwSize, &lpBuf,(uint32 *)&dwHi, NULL, NULL, 0)) != DS_OK) { + MessageBox(hwnd,"Cannot lock sfx buffer!","FPSFX::LoadFile()", MB_OK); + return false; + } + + /* Decomprime i dati dello stream direttamente dentro il buffer lockato */ + lpCodec->Decompress(vdbFP, lpBuf, dwSize); + + /* Unlocka il buffer */ + lpDSBuffer->Unlock(lpBuf, dwSize, NULL, NULL); + + delete lpCodec; + + /* Crea il notify per avvertire quando raggiungiamo la fine della voce */ + err = lpDSBuffer->QueryInterface(IID_IDirectSoundNotify,(void **)&lpDSNotify); + if (FAILED(err)) { + wsprintf(errbuf,"Error creating notify object! (%lx)",err); + MessageBox(hwnd,errbuf,"FPSFX::LoadVoiceFromVDB()", MB_OK); + return false; + } + + hEndOfBuffer = CreateEvent(NULL, false, false, NULL); + + dspnHot[0].dwOffset = DSBPN_OFFSETSTOP; + dspnHot[0].hEventNotify = hEndOfBuffer; + + lpDSNotify->SetNotificationPositions(1, dspnHot); + + /* Tutto a posto, possiamo uscire */ + bFileLoaded = true; + SetVolume(62); + +#endif + return true; +} + + +bool FPSFX::LoadFile(LPSTR lpszFileName, uint32 dwCodec) { +#ifdef REFACTOR_ME + static PCMWAVEFORMAT pcmwf; + static DSBUFFERDESC dsbdesc; + static HRESULT err; + static char errbuf[128]; + Common::File file; + uint32 dwSize; + byte *lpTempBuffer; + void *lpBuf; + uint32 dwHi; + struct { + char id[4]; + int freq; + int nChan; + } ADPHead; + + if (!bSoundSupported) + return true; + + /* Apre il file di stream in lettura */ + if (!file.open(lpszFileName)) { + warning("FPSFX::LoadFile() : Cannot open sfx file!"); + return false; + } + + /* Leggiamo l'header */ + file.read(ADPHead.id, 4); + ADPHead.freq = file.readUint32LE(); + ADPHead.nChan = file.readUint32LE(); + + if (ADPHead.id[0] != 'A' || ADPHead.id[1] != 'D' || ADPHead.id[2] != 'P' || ADPHead.id[3] != 0x10) { + warning("FPSFX::LoadFile() : Invalid ADP header!"); + file.close(); + return false; + } + + b16bit = true; + bStereo = (ADPHead.nChan == 2); + dwFreq = ADPHead.freq; + + /* Si salva la lunghezza dello stream */ + dwSize = file.size() - 12 /*sizeof(ADPHead)*/; + file.seek(0); + + if (dwCodec == FPCODEC_ADPCM) + dwSize *= 4; + + /* Setta le strutture necessarie per la creazione di un secondary buffer + Attiviamo inoltre il controllo del volume, in modo da poter abbassare + e alzare il volume della musica indipendentemente da quello generale. + Proviamo a buttarlo in sound ram. */ + pcmwf.wBitsPerSample = (b16bit ? 16 : 8); + pcmwf.wf.wFormatTag = WAVE_FORMAT_PCM; + pcmwf.wf.nChannels = (bStereo ? 2 : 1); + pcmwf.wf.nSamplesPerSec = dwFreq; + pcmwf.wf.nBlockAlign = (pcmwf.wBitsPerSample / 8) * pcmwf.wf.nChannels; + pcmwf.wf.nAvgBytesPerSec = (uint32)pcmwf.wf.nBlockAlign * (uint32)pcmwf.wf.nSamplesPerSec; + + dsbdesc.dwSize=sizeof(dsbdesc); + dsbdesc.dwFlags = DSBCAPS_CTRLVOLUME | DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLPOSITIONNOTIFY; + dsbdesc.dwBufferBytes = dwSize; + dsbdesc.lpwfxFormat = (LPWAVEFORMATEX) & pcmwf; + + if ((err = lpDS->CreateSoundBuffer(&dsbdesc, &lpDSBuffer, NULL)) != DS_OK) { + wsprintf(errbuf,"Error creating the secondary buffer (%lx)",err); + MessageBox(hwnd,errbuf,"FPSFX::FPSFX()", MB_OK); + return false; + } + + /* Alloca un buffer temporaneo */ + lpTempBuffer = (byte *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, dwSize); + if (lpTempBuffer == NULL) + return false; + + switch (dwCodec) { + case FPCODEC_RAW: + lpCodec = new CODECRAW(bLoop); + break; + + case FPCODEC_ADPCM: + if (bStereo) + lpCodec = new CODECADPCMSTEREO(bLoop,lpTempBuffer); + else + lpCodec = new CODECADPCMMONO(bLoop,lpTempBuffer); + break; + + default: + return false;G + } + + /* Riempie il buffer */ + if ((err = lpDSBuffer->Lock(0, dwSize, &lpBuf, (uint32 *)&dwHi, NULL, NULL, 0)) != DS_OK) { + MessageBox(hwnd,"Cannot lock sfx buffer!","FPSFX::LoadFile()", MB_OK); + return false; + } + + /* Decomprime i dati dello stream direttamente dentro il buffer lockato */ + lpCodec->Decompress(file, lpBuf, dwSize); + + /* Unlocka il buffer */ + lpDSBuffer->Unlock(lpBuf, dwSize, NULL, NULL); + + delete lpCodec; + file.close(); + + /* Tutto a posto, possiamo uscire */ + bFileLoaded = true; +#endif + return true; +} + + +/****************************************************************************\ +* +* Function: bool Play(); +* +* Description: Suona lo sfx caricato. +* +* Return: true se tutto OK, false in caso di errore. +* +\****************************************************************************/ + +bool FPSFX::Play() { +#ifdef REFACTOR_ME + if (bFileLoaded) { + if (hEndOfBuffer != INVALID_HANDLE_VALUE) + ResetEvent(hEndOfBuffer); + + lpDSBuffer->SetCurrentPosition(0); + bIsPlaying = true; + + if (!bPaused) { + lpDSBuffer->Play(0, 0, (bLoop ? DSBPLAY_LOOPING : 0)); + } + } +#endif + return true; +} + + +/****************************************************************************\ +* +* Function: bool Stop(void); +* +* Description: Ferma il play dello sfx. +* +* Return: true se tutto OK, false in caso di errore. +* +\****************************************************************************/ + +bool FPSFX::Stop(void) { +#ifdef REFACTOR_ME + if (bFileLoaded) { + if (bPaused || bIsPlaying) { + lpDSBuffer->Stop(); + } + + bIsPlaying = false; + bPaused = false; + } +#endif + return true; +} + + + +/****************************************************************************\ +* +* Function: bool SetLoop(bool bLoop); +* +* Description: Attiva o disattiva il loop dello sfx. +* +* Input: bool bLoop true per attivare il loop, false per +* disattivarlo +* +* Note: Il loop deve essere attivato PRIMA di eseguire il play +* dello sfx. Qualsiasi modifica effettuata durante il play +* non avra' effetto fino a che lo sfx non viene fermato, +* e poi rimesso in play. +* +\****************************************************************************/ + +void FPSFX::SetLoop(bool bLop) { + bLoop = bLop; +} + +void FPSFX::Pause(bool bPause) { +#ifdef REFACTOR_ME + if (bFileLoaded) { + if (bPause && bIsPlaying) { + lpDSBuffer->Stop(); + } else if (!bPause && bPaused) { + if (bIsPlaying && bLoop) + lpDSBuffer->Play(0, 0, (bLoop ? DSBPLAY_LOOPING : 0)); + } + + // Trucchetto per risettare il volume secondo le + // possibili nuove configurazioni sonore + SetVolume(lastVolume); + bPaused = bPause; + } +#endif +} + + +/****************************************************************************\ +* +* Function: void SetVolume(int dwVolume); +* +* Description: Cambia il volume dello sfx +* +* Input: int dwVolume Volume da settare (0-63) +* +\****************************************************************************/ + +void FPSFX::SetVolume(int dwVolume) { + if (dwVolume > 63) dwVolume = 63; + if (dwVolume < 0) dwVolume = 0; + + lastVolume = dwVolume; + + if (bIsVoice) { + if (!bCfgDubbing) dwVolume = 0; + else { + dwVolume -= (10 - nCfgDubbingVolume) * 2; + if (dwVolume<0) dwVolume = 0; + } + } else { + if (!bCfgSFX) dwVolume = 0; + else { + dwVolume -= (10 - nCfgSFXVolume) * 2; + if (dwVolume < 0) dwVolume = 0; + } + } +#ifdef REFACTOR_ME + if (bFileLoaded) + lpDSBuffer->SetVolume(dwVolume * (DSBVOLUME_MAX-DSBVOLUME_MIN) / 64 + DSBVOLUME_MIN); +#endif +} + + + +/****************************************************************************\ +* +* Function: void GetVolume(int *lpdwVolume); +* +* Description: Chiede il volume dello sfx +* +* Input: int *lpdwVolume Variabile in cui verra' inserito +* il volume corrente +* +\****************************************************************************/ + +void FPSFX::GetVolume(int *lpdwVolume) { +#ifdef REFACTOR_ME + if (bFileLoaded) + lpDSBuffer->GetVolume((uint32 *)lpdwVolume); + + *lpdwVolume -= (DSBVOLUME_MIN); + *lpdwVolume *= 64; + *lpdwVolume /= (DSBVOLUME_MAX - DSBVOLUME_MIN); +#endregion +} + + + + +/****************************************************************************\ +* Metodi di FPSTREAM +\****************************************************************************/ + +/****************************************************************************\ +* +* Function: FPSTREAM(LPDIRECTSOUND lpDS, bool bSoundOn); +* +* Description: Costruttore di default. *NON* bisogna dichiarare direttamente +* un oggetto, ma crearlo piuttosto tramite FPSOUND::CreateStream() +* +\****************************************************************************/ + +FPSTREAM::FPSTREAM(LPDIRECTSOUND LPDS, HWND hWnd, bool bSoundOn) { + //hwnd=hWnd; + lpDS=LPDS; + bSoundSupported = bSoundOn; + bFileLoaded = false; + bIsPlaying = false; + bPaused = false; + bSyncExit = false; + lpDSBuffer = NULL; + lpDSNotify = NULL; + hHot1 = hHot2 = hHot3 = hPlayThread_PlayFast = hPlayThread_PlayNormal = NULL; +} + +bool FPSTREAM::CreateBuffer(int nBufSize) { +#ifdef REFACTOR_ME + static PCMWAVEFORMAT pcmwf; + static DSBUFFERDESC dsbdesc; + static HRESULT err; + static char errbuf[128]; + + if (bSoundSupported == false) + return true; + + /* Setta le strutture necessarie per la creazione di un secondary buffer + per lo stream lungo esattamente 1 secondo di musica. Attiviamo inoltre + il controllo del volume, in modo da poter abbassare e alzare il volume + della musica indipendentemente da quello generale. Ovviamente si tratta + di un buffer in RAM */ + pcmwf.wBitsPerSample = 16; + pcmwf.wf.wFormatTag=WAVE_FORMAT_PCM; + pcmwf.wf.nChannels = 2; + pcmwf.wf.nSamplesPerSec = 44100; + pcmwf.wf.nBlockAlign = (pcmwf.wBitsPerSample / 8) * pcmwf.wf.nChannels; + pcmwf.wf.nAvgBytesPerSec = (uint32)pcmwf.wf.nBlockAlign * (uint32)pcmwf.wf.nSamplesPerSec; + + dsbdesc.dwSize = sizeof(dsbdesc); + dsbdesc.dwFlags = DSBCAPS_CTRLVOLUME | DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLPOSITIONNOTIFY; + dwBufferSize=dsbdesc.dwBufferBytes = (((uint32)(pcmwf.wf.nAvgBytesPerSec * nBufSize) / 1000 + 31) / 32) * 32; + dsbdesc.lpwfxFormat = (LPWAVEFORMATEX) & pcmwf; + + if ((err = lpDS->CreateSoundBuffer(&dsbdesc, &lpDSBuffer, NULL)) != DS_OK) { + wsprintf(errbuf,"Error creating the secondary buffer (%lx)",err); + MessageBox(hwnd,errbuf,"FPSTREAM::FPSTREAM()", MB_OK); + bSoundSupported = false; + return false; + } + SetVolume(63); + + + /* Crea il notify per avvertire quando vengono raggiunte le posizioni chiave + all'interno dello stream. Le posizioni chiave si trovano rispettivamente + subito dopo l'inizio e subito dopo la meta' del buffer */ + err = lpDSBuffer->QueryInterface(IID_IDirectSoundNotify,(void **)&lpDSNotify); + + if (FAILED(err)) { + wsprintf(errbuf,"Error creating notify object! (%lx)",err); + MessageBox(hwnd,errbuf,"FPSTREAM::FPSTREAM()", MB_OK); + bSoundSupported = false; + return false; + } + + hHot1=CreateEvent(NULL, false, false, NULL); + hHot2=CreateEvent(NULL, false, false, NULL); + hHot3=CreateEvent(NULL, false, false, NULL); + hPlayThread_PlayFast = CreateEvent(NULL, false, false, NULL); + + dspnHot[0].dwOffset = 32; + dspnHot[0].hEventNotify = hHot1; + + dspnHot[1].dwOffset = dwBufferSize / 2 + 32; + dspnHot[1].hEventNotify = hHot2; + + dspnHot[2].dwOffset = dwBufferSize - 32; //DSBPN_OFFSETSTOP; + dspnHot[2].hEventNotify = hHot3; + + lpDSNotify->SetNotificationPositions(3,dspnHot); +#endif + return true; +} + + +/****************************************************************************\ +* +* Function: ~FPSTREAM(); +* +* Description: Distruttore di default. Richiama anche la CloseFile() se ce +* ne e' bisogno. +* +\****************************************************************************/ + +FPSTREAM::~FPSTREAM() { + if (!bSoundSupported) + return; + + if (bIsPlaying) + Stop(); + + if (bFileLoaded) + UnloadFile(); + + if (hHot1) { + CloseHandle(hHot1); + hHot1 = NULL; + } + if (hHot2) { + CloseHandle(hHot2); + hHot2 = NULL; + } + if (hHot3) { + CloseHandle(hHot3); + hHot3 = NULL; + } + if (hPlayThread_PlayFast) { + CloseHandle(hPlayThread_PlayFast); + hPlayThread_PlayFast = NULL; + } + if (hPlayThread_PlayNormal) { + CloseHandle(hPlayThread_PlayNormal); + hPlayThread_PlayNormal = NULL; + } + + SyncToPlay = NULL; + + RELEASE(lpDSNotify); + RELEASE(lpDSBuffer); +} + + +/****************************************************************************\ +* +* Function: Release(); +* +* Description: Rilascia la memoria dell'oggetto. Deve essere richiamata quando +* l'oggetto non serve piu' e **SOLO SE** l'oggetto e' stato +* creato con la FPSOUND::CreateStream(). +* +* Note: Eventuali puntatori all'oggetto non sono piu' validi dopo +* questa chiamata. +* +\****************************************************************************/ + +FPSTREAM::Release() { + delete this; + return NULL; +} + + +/****************************************************************************\ +* +* Function: bool LoadFile(LPSTREAM lpszFileName, uint32 dwCodec=FPCODEC_RAW); +* +* Description: Apre un file di stream. +* +* Input: LPSTR lpszFile Nome del file di stream da aprire +* uint32 dwCodec CODEC da utilizzare per decomprimere +* i campioni sonori +* +* Return: true se tutto OK, false in caso di errore +* +\****************************************************************************/ + +bool FPSTREAM::LoadFile(const char *lpszFileName, uint32 dwCodType, int nBufSize) { +#ifdef REFACTOR_ME + HRESULT err; + void *lpBuf; + uint32 dwHi; + + if (!bSoundSupported) + return true; + + /* Si salva il tipo di codec */ + dwCodec = dwCodType; + + /* Crea il buffer */ + if (!CreateBuffer(nBufSize)) + return true; + + /* Apre il file di stream in lettura */ + if (!_file.open(lpszFileName)) + //MessageBox(hwnd,"Cannot open stream file!","FPSTREAM::LoadFile()", MB_OK); + return false; + } + + /* Si salva la lunghezza dello stream */ + dwSize = _file.size(); + _file.seek(0); + + /* Tutto a posto, possiamo uscire */ + bFileLoaded = true; + bIsPlaying = false; + bPaused = false; +#endif + return true; +} + + +/****************************************************************************\ +* +* Function: UnloadFile(); +* +* Description: Chiude un file di stream eventualmente aperto. E' necessario +* richiamare questa funzione per disallocare la memoria +* occupata dallo stream. +* +* Return: Il distruttore della classe per sicurezza richiama la +* UnloadFile() se non e' stata richiamata esplicitamente. +* +\****************************************************************************/ + +bool FPSTREAM::UnloadFile() { + if (!bSoundSupported || !bFileLoaded) + return true; + + /* Chiude gli handle del file di stream */ + _file.close(); + + RELEASE(lpDSNotify); + RELEASE(lpDSBuffer); + + /* Si ricorda che non c'e' piu' nessun file in memoria */ + bFileLoaded = false; + + return true; +} + +/****************************************************************************\ +* +* Function: bool Play(); +* +* Description: Suona lo stream caricato. +* +* Return: true se tutto OK, false in caso di errore. +* +\****************************************************************************/ + +void FPSTREAM::Prefetch(void) { +#ifdef REFACTOR_ME + uint32 dwId; + void *lpBuf; + uint32 dwHi; + HRESULT err; + + if (!bSoundSupported || !bFileLoaded) + return; + + /* Alloca un buffer temporaneo */ + lpTempBuffer = (byte *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, dwBufferSize / 2); + if (lpTempBuffer == NULL) + return; + + switch (dwCodec) { + case FPCODEC_RAW: + lpCodec = new CODECRAW(bLoop); + break; + + case FPCODEC_ADPCM: + lpCodec = new CODECADPCMSTEREO(bLoop); + break; + + default: + return; + } + + /* Posiziona lo stream file all'inizio */ + _file.seek(0); + + /* Riempie il buffer per avere i dati gia' pronti */ + if ((err = lpDSBuffer->Lock(0, dwBufferSize / 2, &lpBuf, (uint32 *)&dwHi, NULL, NULL, 0)) != DS_OK) { + MessageBox(hwnd,"Cannot lock stream buffer!","soundLoadStream()", MB_OK); + return; + } + + /* Decomprime i dati dello stream direttamente dentro il buffer lockato */ + lpCodec->Decompress(hFile, lpBuf, dwBufferSize / 2); + + /* Unlocka il buffer */ + lpDSBuffer->Unlock(lpBuf, dwBufferSize / 2, NULL, NULL); + + /* Crea il thread che fa il play dello stream */ + hThreadEnd = CreateEvent(NULL, false, false, NULL); + hPlayThread = CreateThread(NULL, 10240, (LPTHREAD_START_ROUTINE)PlayThread, (void *)this, 0, &dwId); + SetThreadPriority(hPlayThread, THREAD_PRIORITY_HIGHEST); + + /* Start il play del buffer DirectSound */ + lpDSBuffer->SetCurrentPosition(0); + bIsPlaying = true; + + dspnHot[0].dwOffset = 32; + dspnHot[0].hEventNotify = hHot1; + + dspnHot[1].dwOffset = dwBufferSize / 2 + 32; + dspnHot[1].hEventNotify = hHot2; + + dspnHot[2].dwOffset = dwBufferSize - 32; //DSBPN_OFFSETSTOP; + dspnHot[2].hEventNotify = hHot3; + + if (FAILED(lpDSNotify->SetNotificationPositions(3,dspnHot))) { + int a=1; + } +#endif +} + +void FPSTREAM::PlayFast(void) { +#ifdef REFACTOR_ME + dspnHot[0].dwOffset = 32; + dspnHot[0].hEventNotify = hHot1; + + dspnHot[1].dwOffset = dwBufferSize / 2 + 32; + dspnHot[1].hEventNotify = hHot2; + + dspnHot[2].dwOffset = dwBufferSize-32; //DSBPN_OFFSETSTOP; + dspnHot[2].hEventNotify = hHot3; + + lpDSBuffer->Stop(); + + if (FAILED(lpDSNotify->SetNotificationPositions(3,dspnHot))) { + warning("PlayFast SNP failed!"); + } + + if (FAILED(lpDSBuffer->Play(0, 0, DSBPLAY_LOOPING))) { + warning("PlayFast failed!\n"); + } +#endif +} + +bool FPSTREAM::Play() { +#ifdef REFACTOR_ME + uint32 dwId; + void *lpBuf; + uint32 dwHi; + HRESULT err; + + if (!bSoundSupported || !bFileLoaded) + return false; + + /* Alloca un buffer temporaneo */ + lpTempBuffer = (byte *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, dwBufferSize / 2); + if (lpTempBuffer == NULL) + return false; + + switch (dwCodec) { + case FPCODEC_RAW: + lpCodec = new CODECRAW(bLoop); + break; + + case FPCODEC_ADPCM: + lpCodec = new CODECADPCMSTEREO(bLoop); + break; + + default: + return false; + } + + /* Posiziona lo stream file all'inizio */ + _file.seek(0); + lpDSBuffer->Stop(); + lpDSBuffer->SetCurrentPosition(0); + + /* Riempie il buffer per avere i dati gia' pronti */ + if ((err = lpDSBuffer->Lock(0,dwBufferSize/2, &lpBuf,(uint32 *)&dwHi, NULL, NULL, 0)) != DS_OK) { + error("Cannot lock stream buffer!","soundLoadStream()"); + } + + /* Decomprime i dati dello stream direttamente dentro il buffer lockato */ + lpCodec->Decompress(hFile, lpBuf, dwBufferSize / 2); + + /* Unlocka il buffer */ + lpDSBuffer->Unlock(lpBuf, dwBufferSize / 2, NULL, NULL); + + /* Crea il thread che fa il play dello stream */ + hThreadEnd = CreateEvent(NULL, false, false, NULL); + hPlayThread = CreateThread(NULL, 10240, (LPTHREAD_START_ROUTINE)PlayThread, (void *)this, 0, &dwId); + SetThreadPriority(hPlayThread, THREAD_PRIORITY_HIGHEST); + + SetEvent(hPlayThread_PlayFast); + +#if 0 + /* Start il play del buffer DirectSound */ + lpDSBuffer->SetCurrentPosition(0); + + dspnHot[0].dwOffset = 32; + dspnHot[0].hEventNotify = hHot1; + + dspnHot[1].dwOffset = dwBufferSize/2+32; + dspnHot[1].hEventNotify = hHot2; + + dspnHot[2].dwOffset = dwBufferSize-32; //DSBPN_OFFSETSTOP; + dspnHot[2].hEventNotify = hHot3; + + if (FAILED(lpDSNotify->SetNotificationPositions(3,dspnHot))) + { + int a=1; + } + + + lpDSBuffer->Play(0, 0,DSBPLAY_LOOPING); +#endif + + bIsPlaying = true; +#endif + return true; +} + + +/****************************************************************************\ +* +* Function: bool Stop(bool bSync); +* +* Description: Ferma il play dello stream. +* +* Return: true se tutto OK, false in caso di errore. +* +\****************************************************************************/ + +bool FPSTREAM::Stop(bool bSync) { + if (!bSoundSupported) + return true; + + if (!bFileLoaded) + return false; + + if (!bIsPlaying) + return false; + + if (bSync) { +// bSyncExit = true; +// lpDSBuffer->Stop(); +// lpDSBuffer->Play(0, 0, 0); + return true; + } else { + /* Ferma il buffer DirectSound */ + lpDSBuffer->Stop(); + + /* Avverte il thread che deve uscire e aspetta che si chiuda */ + SetEvent(hThreadEnd); + WaitForSingleObject(hPlayThread, INFINITE); + + /* Chiude l'handle del thread e disalloca la memoria temporanea */ + CloseHandle(hPlayThread); + CloseHandle(hThreadEnd); + GlobalFree(lpTempBuffer); + + /* Disalloca e chiude il CODEC */ + delete lpCodec; + + bIsPlaying = false; + bPaused = false; + } + + return true; +} + +void FPSTREAM::WaitForSync(FPSTREAM *toplay) { +#ifdef REFACTOR_ME + if (!bSoundSupported) + return; + + if (!bFileLoaded) + return; + + if (!bIsPlaying) + return; + + SyncToPlay = toplay; + bSyncExit = true; + + char buf[1024]; + sprintf(buf, "Wait for sync: %x (SyncToPlay: [%x]=%x, SyncExit: [%x]=%d) MyThread: 0x%x\n", + this->lpDSBuffer, &this->SyncToPlay, SyncToPlay, &bSyncExit, bSyncExit, GetCurrentThreadId()); + warning(buf); + + WaitForSingleObject(hPlayThread, INFINITE); + + /* Chiude l'handle del thread e disalloca la memoria temporanea */ + CloseHandle(hPlayThread); + CloseHandle(hThreadEnd); + GlobalFree(lpTempBuffer); + + /* Disalloca e chiude il CODEC */ + delete lpCodec; +#endif + bIsPlaying = false; +} + +/****************************************************************************\ +* +* Function: void FPSTREAM::PlayThread(); +* +* Description: Thread che si occupa del play dello stream +* +\****************************************************************************/ + +void PASCAL FPSTREAM::PlayThread(FPSTREAM *This) { +#ifdef REFACTOR_ME + byte *lpLockBuf; + uint32 dwResult; + byte *lpLockBuf2; + uint32 dwResult2; + bool cicla = true; + uint32 countEnd; + bool bPrecache; + char buf[1024]; + + /* Eventi che segnalano quando bisogna eseguire qualcosa */ + HANDLE hList[5] = { This->hThreadEnd, This->hHot1, This->hHot2, This->hHot3, This->hPlayThread_PlayFast }; + + bPrecache = true; + countEnd = 0; + while (cicla) { + if (This->lpCodec->EndOfStream() && This->lpCodec->bLoop == false) { + countEnd++; + if (countEnd==3) + break; + } + + /* Decomprime i dati che stanno per essere scritti dentro il buffer temporaneo */ + if (This->lastVolume == 0) + ZeroMemory(This->lpTempBuffer, This->dwBufferSize / 2); + else if (bPrecache) + This->lpCodec->Decompress(This->_file, This->lpTempBuffer, This->dwBufferSize / 2); + + bPrecache = false; + + /* Attende il set di un evento. Dato che sono tutti in automatic reset, + non c'e' bisogno di resettarlo dopo */ + +// uint32 dwBufStatus; +// This->lpDSBuffer->GetStatus(&dwBufStatus); + + +// sprintf(buf, "WFMO: %x (buf status: %x) MyThread: 0x%x\n", This->lpDSBuffer, dwBufStatus, GetCurrentThreadId()); +// warning(buf); + dwResult = WaitForMultipleObjects(5, hList, false, INFINITE); + +/* uint32 dwPlay, dwWrite; + This->lpDSBuffer->GetCurrentPosition(&dwPlay, &dwWrite); + sprintf(buf, "CP Play: %u, Write: %u\n", dwPlay, dwWrite); + warning(buf); */ + + /* Fa uno switch per stabilire quale evento e' stato settato */ + switch (dwResult - WAIT_OBJECT_0) { + case 0: + /* Bisogna uscire dal thread */ + cicla = false; + break; + + case 1: + /* Bisogna riempire la seconda meta' del buffer */ +// if (dwPlay >= This->dspnHot[0].dwOffset && dwPlay <= This->dspnHot[0].dwOffset+1024 ) + { +// sprintf(buf, "Prima met buffer: %x\n", This->lpDSBuffer); +// warning(buf); + This->lpDSBuffer->Lock(This->dwBufferSize/2,This->dwBufferSize/2,(void **)&lpLockBuf, &dwResult,(void **)&lpLockBuf2, &dwResult2, 0); + // sprintf(buf, "LockedBuf: dwResult=%x, dwBufferSize/2=%x, lpLockBuf2=%x, dwResult2=%x\n", dwResult, This->dwBufferSize/2, lpLockBuf2, dwResult2); + // warning(buf); + CopyMemory(lpLockBuf,This->lpTempBuffer,This->dwBufferSize/2); + This->lpDSBuffer->Unlock(lpLockBuf,This->dwBufferSize/2,lpLockBuf2, 0); + bPrecache = true; + } + break; + + case 2: + /* Bisogna riempire la prima meta' del buffer */ +// if (dwPlay >= This->dspnHot[1].dwOffset && dwPlay <= This->dspnHot[1].dwOffset+1024 ) + { +// sprintf(buf, "Seconda met buffer: %x\n", This->lpDSBuffer); +// warning(buf); + This->lpDSBuffer->Lock(0,This->dwBufferSize/2,(void **)&lpLockBuf, &dwResult, NULL, NULL, 0); + CopyMemory(lpLockBuf,This->lpTempBuffer,This->dwBufferSize/2); + This->lpDSBuffer->Unlock(lpLockBuf,This->dwBufferSize/2, NULL, NULL); + bPrecache = true; + } + break; + + case 3: + { +// sprintf(buf, "End of buffer %x (SyncToPlay [%x]=%x, SyncExit: [%x]=%d)\n", This->lpDSBuffer, &This->SyncToPlay, This->SyncToPlay, &This->bSyncExit, This->bSyncExit); +// warning(buf); + if (This->bSyncExit) { +// sprintf(buf, "Go with sync (Buffer: %x) MyThread: %x!\n", This->SyncToPlay->lpDSBuffer, GetCurrentThreadId()); +// warning(buf); + //This->SyncToPlay->PlayFast(); + SetEvent(This->SyncToPlay->hPlayThread_PlayFast); + // Transfer immediatly control to the other threads + Sleep(0); + This->bSyncExit = false; + cicla = false; + break; + } + } + break; + + case 4: + This->PlayFast(); + break; + } + } + + /* Ferma il buffer DirectSound */ +// sprintf(buf, "Exiting thread. Buffer = %x, MyThread = 0x%x\n", This->lpDSBuffer, GetCurrentThreadId()); +// warning(buf); + This->lpDSBuffer->Stop(); +#endif + ExitThread(0); +} + + +/****************************************************************************\ +* +* Function: bool SetLoop(bool bLoop); +* +* Description: Attiva o disattiva il loop dello stream. +* +* Input: bool bLoop true per attivare il loop, false per +* disattivarlo +* +* Note: Il loop deve essere attivato PRIMA di eseguire il play +* dello stream. Qualsiasi modifica effettuata durante il play +* non avra' effetto fino a che lo stream non viene fermato, +* e poi rimesso in play. +* +\****************************************************************************/ + +void FPSTREAM::SetLoop(bool loop) { + bLoop = loop; +} + + +void FPSTREAM::Pause(bool bPause) { + if (bFileLoaded) { + if (bPause && bIsPlaying) { + lpDSBuffer->Stop(); + bIsPlaying = false; + bPaused = true; + } else if (!bPause && bPaused) { + dspnHot[0].dwOffset = 32; + dspnHot[0].hEventNotify = hHot1; + + dspnHot[1].dwOffset = dwBufferSize / 2 + 32; + dspnHot[1].hEventNotify = hHot2; + + dspnHot[2].dwOffset = dwBufferSize-32; //DSBPN_OFFSETSTOP; + dspnHot[2].hEventNotify = hHot3; + + if (FAILED(lpDSNotify->SetNotificationPositions(3,dspnHot))) { + int a = 1; + } + + lpDSBuffer->Play(0, 0, bLoop); + bIsPlaying = true; + bPaused = false; + + // Trucchetto per risettare il volume secondo le + // possibili nuove configurazioni sonore + SetVolume(lastVolume); + } + } +} + + +/****************************************************************************\ +* +* Function: void SetVolume(int dwVolume); +* +* Description: Cambia il volume dello stream +* +* Input: int dwVolume Volume da settare (0-63) +* +\****************************************************************************/ + +void FPSTREAM::SetVolume(int dwVolume) { +#ifdef REFACTOR_ME + if (dwVolume > 63) dwVolume = 63; + if (dwVolume < 0) dwVolume = 0; + + lastVolume = dwVolume; + + if (!bCfgMusic) dwVolume = 0; + else { + dwVolume -= (10 - nCfgMusicVolume) * 2; + if (dwVolume<0) dwVolume = 0; + } + + if (lpDSBuffer) + lpDSBuffer->SetVolume(dwVolume * (DSBVOLUME_MAX - DSBVOLUME_MIN) / 64 + DSBVOLUME_MIN); +#endif +} + + + +/****************************************************************************\ +* +* Function: void GetVolume(int *lpdwVolume); +* +* Description: Chiede il volume dello stream +* +* Input: int *lpdwVolume Variabile in cui verra' inserito +* il volume corrente +* +\****************************************************************************/ + +void FPSTREAM::GetVolume(int *lpdwVolume) { +#ifdef REFACTOR_ME + if (lpDSBuffer) + lpDSBuffer->GetVolume((uint32 *)lpdwVolume); + *lpdwVolume -= (DSBVOLUME_MIN); + *lpdwVolume *= 64; + *lpdwVolume /= (DSBVOLUME_MAX - DSBVOLUME_MIN); +#endregion +} + } // End of namespace Tony diff --git a/engines/tony/sound.h b/engines/tony/sound.h index c966c93888..7ed8f97b3e 100644 --- a/engines/tony/sound.h +++ b/engines/tony/sound.h @@ -48,12 +48,21 @@ #ifndef TONY_SOUND_H #define TONY_SOUND_H +#include "common/file.h" #include "tony/gfxcore.h" #include "tony/loc.h" #include "tony/utils.h" namespace Tony { +// Dummy type declarations +typedef void *LPDIRECTSOUND; +typedef void *LPDIRECTSOUNDBUFFER; +typedef uint32 HWND; +struct DSCAPS { +}; + + class FPSTREAM; class FPSFX; class CODEC; @@ -78,12 +87,10 @@ class FPSOUND { private: bool bSoundSupported; -/* LPDIRECTSOUND lpDS; LPDIRECTSOUNDBUFFER lpDSBPrimary; DSCAPS dscaps; HWND hwnd; -*/ /****************************************************************************\ * Metodi @@ -301,7 +308,7 @@ public: bool LoadFile(char *lpszFileName, uint32 dwCodec = FPCODEC_RAW); bool LoadFile(byte *lpBuf, uint32 dwCodec); - bool LoadVoiceFromVDB(Common::File &hvdb); + bool LoadVoiceFromVDB(Common::File &vdbFP); /****************************************************************************\ @@ -410,7 +417,7 @@ private: uint32 dwCodec; // CODEC utilizzato HANDLE hThreadEnd; // Evento per chiudere il thread - HANDLE hFile; // Handle del file di stream + Common::File _file; // Handle del file di stream HANDLE hPlayThread; // Handle del thread di play HANDLE hHot1, hHot2, hHot3; // Eventi settati da DirectSoundNotify HANDLE hPlayThread_PlayFast; @@ -497,7 +504,7 @@ public: * \****************************************************************************/ - bool LoadFile(char *lpszFileName, uint32 dwCodec = FPCODEC_RAW, int nSync = 2000); + bool LoadFile(const char *lpszFileName, uint32 dwCodec = FPCODEC_RAW, int nSync = 2000); -- cgit v1.2.3 From a2982a0b20027f658c9b47266a8ddbec74a15878 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 3 May 2012 22:49:30 +1000 Subject: TONY: Engine is now compiling and linking again --- engines/tony/adv.h | 2 +- engines/tony/font.cpp | 27 + engines/tony/game.cpp | 2 +- engines/tony/gfxcore.cpp | 46 +- engines/tony/gfxengine.cpp | 14 +- engines/tony/module.mk | 1 + engines/tony/sound.cpp | 38 +- engines/tony/tony.cpp | 79 ++- engines/tony/tony.h | 4 +- engines/tony/utils.cpp | 130 ++++- engines/tony/utils.h | 4 +- engines/tony/window.cpp | 1255 ++++++++++++++++++++++++++++++++++++++++++++ engines/tony/window.h | 27 +- 13 files changed, 1570 insertions(+), 59 deletions(-) create mode 100644 engines/tony/window.cpp (limited to 'engines') diff --git a/engines/tony/adv.h b/engines/tony/adv.h index aab7df24af..9a5ecd5072 100644 --- a/engines/tony/adv.h +++ b/engines/tony/adv.h @@ -92,7 +92,7 @@ void MainShowMouse(void); void MainHideMouse(void); void MainEnableInput(void); void MainDisableInput(void); -void MainPlayMusic(int nChannel, const char *fn, int nFX, bool bLoop, int nSync); +void MainPlayMusic(int nChannel, const char *filename, int nFX, bool bLoop, int nSync); void MainInitWipe(int type); void MainCloseWipe(void); void MainWaitWipeEnd(void); diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 2996b30f04..a0500047b6 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -125,6 +125,14 @@ void RMFont::Load(const byte *buf, int nChars, int dimx, int dimy, uint32 palRes nLetters=nChars; } +void RMFont::Load(uint32 resID, int nChars, int dimx, int dimy, uint32 palResID) { + RMRes res(resID); + + if ((int)res.Size() < nChars * (dimy * dimx + 8)) + nChars = res.Size() / (dimy * dimx + 8); + + Load(res, nChars, dimx, dimy, palResID); +} void RMFont::Unload(void) { if (m_letter != NULL) { @@ -2273,6 +2281,25 @@ void RMTextItemName::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { RMText::Draw(bigBuf,prim); } +RMPoint RMTextItemName::GetHotspot() { + if (m_item == NULL) + return m_mpos + m_curscroll; + else + return m_item->Hotspot(); +} + +RMItem *RMTextItemName::GetSelectedItem() { + return m_item; +} + +bool RMTextItemName::IsItemSelected() { + return m_item != NULL; +} + +bool RMTextItemName::IsNormalItemSelected() { + return m_item != NULL && m_itemName.Length() > 0; +} + /****************************************************************************\ * Metodi di RMDialogChoice diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index d5047766bb..00bb81dcf4 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -130,7 +130,7 @@ void MainHideMouse(void) { _vm->GetEngine()->DisableMouse(); } -void MainPlayMusic(int nChannel, char* filename, int nFX, bool bLoop, int nSync) { +void MainPlayMusic(int nChannel, const char *filename, int nFX, bool bLoop, int nSync) { _vm->PlayMusic(nChannel, filename, nFX, bLoop, nSync); } diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 4842126c59..1d289fbecc 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -138,15 +138,15 @@ void RMGfxBuffer::OffsetY(int nLines, int nBpp) { } -inline RMGfxBuffer::operator byte *() { +RMGfxBuffer::operator byte *() { return m_buf; } -inline RMGfxBuffer::operator void *() { +RMGfxBuffer::operator void *() { return (void *)m_buf; } -inline RMGfxBuffer::RMGfxBuffer(int dimx, int dimy, int nBpp, bool bUseDDraw) { +RMGfxBuffer::RMGfxBuffer(int dimx, int dimy, int nBpp, bool bUseDDraw) { Create(dimx, dimy, nBpp, bUseDDraw); } @@ -255,7 +255,7 @@ bool RMGfxSourceBuffer::Clip2D(int &x1, int &y1, int &u, int &v, int &width, int * \****************************************************************************/ -inline int RMGfxSourceBuffer::Init(uint32 resID, int dimx, int dimy, bool bLoadPalette) { +int RMGfxSourceBuffer::Init(uint32 resID, int dimx, int dimy, bool bLoadPalette) { return Init(RMRes(resID), dimx, dimy, bLoadPalette); } @@ -275,11 +275,11 @@ void RMGfxWoodyBuffer::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { RMGfxSourceBuffer16::Draw(bigBuf, prim); } -inline RMGfxWoodyBuffer::RMGfxWoodyBuffer() { +RMGfxWoodyBuffer::RMGfxWoodyBuffer() { } -inline RMGfxWoodyBuffer::RMGfxWoodyBuffer(int dimx, int dimy, bool bUseDDraw) +RMGfxWoodyBuffer::RMGfxWoodyBuffer(int dimx, int dimy, bool bUseDDraw) : RMGfxBuffer(dimx,dimy,16,bUseDDraw) { } @@ -407,7 +407,7 @@ void RMGfxTargetBuffer::AddPrim(RMGfxPrimitive *prim) { g_system->unlockMutex(csModifyingOT); } -inline void RMGfxTargetBuffer::AddClearTask(void) { +void RMGfxTargetBuffer::AddClearTask(void) { AddPrim(new RMGfxPrimitive(&taskClear)); } @@ -486,11 +486,11 @@ void RMGfxSourceBufferPal::Init(RMDataStream &ds, int dimx, int dimy, bool bLoad } } -inline int RMGfxSourceBufferPal::LoadPalette(uint32 resID) { +int RMGfxSourceBufferPal::LoadPalette(uint32 resID) { return LoadPalette(RMRes(resID)); } -inline int RMGfxSourceBufferPal::LoadPaletteWA(uint32 resID, bool bSwapped) { +int RMGfxSourceBufferPal::LoadPaletteWA(uint32 resID, bool bSwapped) { return LoadPaletteWA(RMRes(resID), bSwapped); } @@ -501,7 +501,7 @@ inline int RMGfxSourceBufferPal::LoadPaletteWA(uint32 resID, bool bSwapped) { void RMGfxSourceBuffer4::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { } -inline RMGfxSourceBuffer4::RMGfxSourceBuffer4(int dimx, int dimy, bool bUseDDraw) +RMGfxSourceBuffer4::RMGfxSourceBuffer4(int dimx, int dimy, bool bUseDDraw) : RMGfxBuffer(dimx,dimy,4,bUseDDraw) { SetPriority(0); } @@ -516,11 +516,11 @@ inline RMGfxSourceBuffer4::RMGfxSourceBuffer4(int dimx, int dimy, bool bUseDDraw * \****************************************************************************/ -inline int RMGfxSourceBuffer4::Bpp() { +int RMGfxSourceBuffer4::Bpp() { return 4; } -inline void RMGfxSourceBuffer4::Create(int dimx, int dimy, bool bUseDDraw) { +void RMGfxSourceBuffer4::Create(int dimx, int dimy, bool bUseDDraw) { RMGfxBuffer::Create(dimx,dimy,4,bUseDDraw); } @@ -589,12 +589,12 @@ void RMGfxSourceBuffer8::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { } } -inline RMGfxSourceBuffer8::RMGfxSourceBuffer8(int dimx, int dimy, bool bUseDDraw) +RMGfxSourceBuffer8::RMGfxSourceBuffer8(int dimx, int dimy, bool bUseDDraw) : RMGfxBuffer(dimx,dimy,8,bUseDDraw) { SetPriority(0); } -inline RMGfxSourceBuffer8::RMGfxSourceBuffer8(bool bTrasp0) { +RMGfxSourceBuffer8::RMGfxSourceBuffer8(bool bTrasp0) { m_bTrasp0=bTrasp0; } @@ -609,11 +609,11 @@ inline RMGfxSourceBuffer8::RMGfxSourceBuffer8(bool bTrasp0) { * \****************************************************************************/ -inline int RMGfxSourceBuffer8::Bpp() { +int RMGfxSourceBuffer8::Bpp() { return 8; } -inline void RMGfxSourceBuffer8::Create(int dimx, int dimy, bool bUseDDraw) { +void RMGfxSourceBuffer8::Create(int dimx, int dimy, bool bUseDDraw) { RMGfxBuffer::Create(dimx, dimy, 8, bUseDDraw); } @@ -630,7 +630,7 @@ RMGfxSourceBuffer8AB::~RMGfxSourceBuffer8AB() { } -inline int RMGfxSourceBuffer8AB::CalcTrasp(int fore, int back) +int RMGfxSourceBuffer8AB::CalcTrasp(int fore, int back) { int r,g,b; @@ -1919,7 +1919,7 @@ void RMGfxSourceBuffer16::PrepareImage(void) { } -inline RMGfxSourceBuffer16::RMGfxSourceBuffer16(int dimx, int dimy, bool bUseDDraw) +RMGfxSourceBuffer16::RMGfxSourceBuffer16(int dimx, int dimy, bool bUseDDraw) : RMGfxBuffer(dimx,dimy,16,bUseDDraw) { SetPriority(0); } @@ -1934,11 +1934,11 @@ inline RMGfxSourceBuffer16::RMGfxSourceBuffer16(int dimx, int dimy, bool bUseDDr * \****************************************************************************/ -inline int RMGfxSourceBuffer16::Bpp() { +int RMGfxSourceBuffer16::Bpp() { return 16; } -inline void RMGfxSourceBuffer16::Create(int dimx, int dimy, bool bUseDDraw) { +void RMGfxSourceBuffer16::Create(int dimx, int dimy, bool bUseDDraw) { RMGfxBuffer::Create(dimx,dimy,16,bUseDDraw); } @@ -1980,17 +1980,17 @@ void RMGfxBox::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { * Metodi di RMGfxClearTask \****************************************************************************/ -inline int RMGfxClearTask::Priority() { +int RMGfxClearTask::Priority() { // Priorita' massima (deve essere fatto per primo) return 1; } -inline void RMGfxClearTask::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *) { +void RMGfxClearTask::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *) { // Pulisce tutto il target buffer Common::fill((byte *)bigBuf, (byte *)bigBuf + (bigBuf.Dimx() * bigBuf.Dimy() * 2), 0x0); } -inline bool RMGfxClearTask::RemoveThis() { +bool RMGfxClearTask::RemoveThis() { // Il task di clear si disattiva sempre return true; } diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index b8accda7c6..d4ea8ee821 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -58,15 +58,25 @@ extern bool bIdleExited; extern bool bPatIrqFreeze; extern bool bSkipSfxNoLoop; -extern void ExitAllIdles(int nCurLoc); /****************************************************************************\ * Metodi di RMGfxEngine \****************************************************************************/ +bool bIdleExited; + +void ExitAllIdles(int nCurLoc) { + // Chiude le idle + bSkipSfxNoLoop = true; + mpalEndIdlePoll(nCurLoc); + bIdleExited = true; + bSkipSfxNoLoop = false; + ExitThread(0); +} + RMGfxEngine::RMGfxEngine() { // Crea il big buffer dove verranno disegnati i frame - m_bigBuf.Create(RM_BBX,RM_BBY,16); + m_bigBuf.Create(RM_BBX, RM_BBY, 16); m_bigBuf.OffsetY(RM_SKIPY); } diff --git a/engines/tony/module.mk b/engines/tony/module.mk index 690b1f4713..af0b3acd2c 100644 --- a/engines/tony/module.mk +++ b/engines/tony/module.mk @@ -14,6 +14,7 @@ MODULE_OBJS := \ tony.o \ tonychar.o \ utils.o \ + window.o \ mpal/expr.o \ mpal/loadmpc.o \ mpal/memory.o \ diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index e757ac4115..a5293eecb2 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -505,7 +505,7 @@ uint32 CODECADPCMMONO::Decompress(Common::File &fp, void *buf, uint32 dwSize) { uint16 *lpBuf = (uint16 *)buf; byte *inp; int bufferstep; - int cache; + int cache = 0; int delta; int sign; int vpdiff; @@ -545,12 +545,12 @@ uint32 CODECADPCMMONO::Decompress(Common::File &fp, void *buf, uint32 dwSize) { cache = *inp++; delta = (cache>>4)&0xF; } else - delta=cache&0xF; + delta = cache & 0xF; /* Trova il nuovo indice */ index += indexTable[delta]; if (index < 0) index = 0; - if (index > 88) index=88; + if (index > 88) index = 88; /* Legge il segno e lo separa dall'ampliamento */ sign = delta&8; @@ -558,9 +558,9 @@ uint32 CODECADPCMMONO::Decompress(Common::File &fp, void *buf, uint32 dwSize) { /* Trova la differenza dal valore precedente */ vpdiff = step >> 3; - if (delta&4) vpdiff+=step; - if (delta&2) vpdiff+=step >> 1; - if (delta&1) vpdiff+=step >> 2; + if (delta&4) vpdiff += step; + if (delta&2) vpdiff += step >> 1; + if (delta&1) vpdiff += step >> 2; if (sign) valpred -= vpdiff; @@ -1551,12 +1551,10 @@ void FPSFX::GetVolume(int *lpdwVolume) { *lpdwVolume -= (DSBVOLUME_MIN); *lpdwVolume *= 64; *lpdwVolume /= (DSBVOLUME_MAX - DSBVOLUME_MIN); -#endregion +#endif } - - /****************************************************************************\ * Metodi di FPSTREAM \****************************************************************************/ @@ -1571,6 +1569,7 @@ void FPSFX::GetVolume(int *lpdwVolume) { \****************************************************************************/ FPSTREAM::FPSTREAM(LPDIRECTSOUND LPDS, HWND hWnd, bool bSoundOn) { +#ifdef REFACTOR_ME //hwnd=hWnd; lpDS=LPDS; bSoundSupported = bSoundOn; @@ -1581,6 +1580,7 @@ FPSTREAM::FPSTREAM(LPDIRECTSOUND LPDS, HWND hWnd, bool bSoundOn) { lpDSBuffer = NULL; lpDSNotify = NULL; hHot1 = hHot2 = hHot3 = hPlayThread_PlayFast = hPlayThread_PlayNormal = NULL; +#endif } bool FPSTREAM::CreateBuffer(int nBufSize) { @@ -1661,6 +1661,8 @@ bool FPSTREAM::CreateBuffer(int nBufSize) { \****************************************************************************/ FPSTREAM::~FPSTREAM() { +#ifdef REFACTOR_ME + if (!bSoundSupported) return; @@ -1695,6 +1697,7 @@ FPSTREAM::~FPSTREAM() { RELEASE(lpDSNotify); RELEASE(lpDSBuffer); +#endif } @@ -1711,9 +1714,9 @@ FPSTREAM::~FPSTREAM() { * \****************************************************************************/ -FPSTREAM::Release() { +void FPSTREAM::Release() { delete this; - return NULL; +// return NULL; } @@ -1780,6 +1783,8 @@ bool FPSTREAM::LoadFile(const char *lpszFileName, uint32 dwCodType, int nBufSize \****************************************************************************/ bool FPSTREAM::UnloadFile() { +#ifdef REFACTOR_ME + if (!bSoundSupported || !bFileLoaded) return true; @@ -1791,7 +1796,7 @@ bool FPSTREAM::UnloadFile() { /* Si ricorda che non c'e' piu' nessun file in memoria */ bFileLoaded = false; - +#endif return true; } @@ -1985,6 +1990,8 @@ bool FPSTREAM::Play() { \****************************************************************************/ bool FPSTREAM::Stop(bool bSync) { +#ifdef REFACTOR_ME + if (!bSoundSupported) return true; @@ -2018,7 +2025,7 @@ bool FPSTREAM::Stop(bool bSync) { bIsPlaying = false; bPaused = false; } - +#endif return true; } @@ -2199,6 +2206,8 @@ void FPSTREAM::SetLoop(bool loop) { void FPSTREAM::Pause(bool bPause) { +#ifdef REFACTOR_ME + if (bFileLoaded) { if (bPause && bIsPlaying) { lpDSBuffer->Stop(); @@ -2227,6 +2236,7 @@ void FPSTREAM::Pause(bool bPause) { SetVolume(lastVolume); } } +#endif } @@ -2278,7 +2288,7 @@ void FPSTREAM::GetVolume(int *lpdwVolume) { *lpdwVolume -= (DSBVOLUME_MIN); *lpdwVolume *= 64; *lpdwVolume /= (DSBVOLUME_MAX - DSBVOLUME_MIN); -#endregion +#endif } } // End of namespace Tony diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index ea555972d0..0a2143ba8b 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -139,7 +139,7 @@ int flipflop=0; OSystem::MutexRef csMusic; -void TonyEngine::PlayMusic(int nChannel, char* fn, int nFX, bool bLoop, int nSync) { +void TonyEngine::PlayMusic(int nChannel, const char *fn, int nFX, bool bLoop, int nSync) { warning("TonyEngine::PlayMusic"); } @@ -202,6 +202,46 @@ int TonyEngine::GetMusicVolume(int nChannel) { return 255; } + +void TonyEngine::GetSaveStateFileName(int n, char *buf) { + RMString name; + + if (n > 0) + name.Format("%02d", n); + else + name.Format("autosave"); + + name += ".sav"; +} + +void TonyEngine::AutoSave(void) { + char buf[256]; + + GrabThumbnail(); + MainWaitFrame(); + MainWaitFrame(); + MainFreeze(); + GetSaveStateFileName(0,buf); + _theEngine.SaveState(buf, (byte *)m_curThumbnail, "Autosave", true); + MainUnfreeze(); +} + + +void TonyEngine::SaveState(int n, const char *name) { + char buf[256]; + + GetSaveStateFileName(n, buf); + _theEngine.SaveState(buf,(byte *)m_curThumbnail, name); +} + + +void TonyEngine::LoadState(int n) { + char buf[256]; + + GetSaveStateFileName(n, buf); + _theEngine.LoadState(buf); +} + bool TonyEngine::OpenVoiceDatabase() { char id[4]; uint32 numfiles; @@ -251,6 +291,21 @@ void TonyEngine::GrabThumbnail(void) { warning("TODO: TonyEngine::GrabThumbnail"); } +void TonyEngine::OptionScreen(void) { +} + +void TonyEngine::OpenInitLoadMenu(void) { + _theEngine.OpenOptionScreen(1); +} + +void TonyEngine::OpenInitOptions(void) { + _theEngine.OpenOptionScreen(2); +} + +void TonyEngine::Abort(void) { + m_bQuitNow = true; +} + void TonyEngine::Play(void) { warning("TODO TonyEngine::Play"); @@ -314,14 +369,14 @@ void TonyEngine::PauseLoop(void) { MSG msg; int st,et; - st = timeGetTime(); + st = GetTime(); while (m_bPaused && GetMessage(&msg,m_wnd,0,0)) { TranslateMessage(&msg); DispatchMessage(&msg); } - et = timeGetTime(); + et = GetTime(); m_startTime += et - st; #endif @@ -345,4 +400,22 @@ warning("TODO: TonyEninge::Pause"); */ } +void TonyEngine::FreezeTime(void) { + m_bTimeFreezed = true; + m_nTimeFreezed = GetTime() - m_startTime; +} + +void TonyEngine::UnfreezeTime(void) +{ + m_bTimeFreezed = false; +} + + +/** + * Returns the millisecond timer + */ +uint32 TonyEngine::GetTime() { + return g_system->getMillis(); +} + } // End of namespace Tony diff --git a/engines/tony/tony.h b/engines/tony/tony.h index dd7e558820..06fe357c0d 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -158,7 +158,7 @@ public: // Music // ****** - void PlayMusic(int nChannel, char *fn, int nFX, bool bLoop, int nSync); + void PlayMusic(int nChannel, const char *fn, int nFX, bool bLoop, int nSync); void StopMusic(int nChannel); void PlaySFX(int nSfx, int nFX = 0); @@ -183,7 +183,7 @@ public: // Salvataggio void AutoSave(void); - void SaveState(int n, char *name); + void SaveState(int n, const char *name); void LoadState(int n); void GetSaveStateFileName(int n, char* buf); diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index 43a129b92a..69ad5633d7 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -292,8 +292,8 @@ RMString::operator char*() const { /** * Resize a string as necessary * @param size New size necessary (in bytes) - * @param bMaintain If TRUE we must keep the original string, - if FALSE we can destroy. + * @param bMaintain If true we must keep the original string, + if false we can destroy. */ void RMString::Resize(int size, bool bMantain) { if (m_realLength == 0) { @@ -406,6 +406,122 @@ void RMString::Format(char* str, ...) { */ } +/****************************************************************************\ +* Metodi di RMFileStreamSlow +\****************************************************************************/ + +RMFileStreamSlow::RMFileStreamSlow() : RMDataStream() { + _stream = NULL; +} + +RMFileStreamSlow::~RMFileStreamSlow() { + Close(); +} + +void RMFileStreamSlow::Close() { + delete _stream; +} + +bool RMFileStreamSlow::OpenFile(Common::File &file) { + _stream = file.readStream(file.size()); + + m_length = _stream->pos(); + + return true; +} + + +bool RMFileStreamSlow::OpenFile(const char *lpFN) { + // Apre il file in lettura + Common::File f; + if (!f.open(lpFN)) + return false; + + m_length = f.size(); + _stream = f.readStream(f.size()); + + return true; +} + + +RMDataStream& RMFileStreamSlow::operator+=(int nBytes) { + Seek(nBytes); + return *this; +} + +int RMFileStreamSlow::Pos() { + return _stream->pos(); +} + +bool RMFileStreamSlow::IsEOF() { + return (Pos() >= m_length); +} + + +int RMFileStreamSlow::Seek(int nBytes, RMDSPos where) { + switch (where) { + case START: + return _stream->seek(nBytes); + + case END: + return _stream->seek(nBytes, SEEK_END); + + case CUR: + return _stream->seek(nBytes, SEEK_CUR); + + default: + return 0; + } +} + + +bool RMFileStreamSlow::Read(void *buf, int size) { + uint32 dwRead; + + dwRead = _stream->read(buf, size); + return ((int)dwRead == size); +} + + +RMFileStreamSlow &operator>>(RMFileStreamSlow &df, char &var) { + df.Read(&var, 1); + return df; +} + +RMFileStreamSlow &operator>>(RMFileStreamSlow &df, byte &var) { + df.Read(&var,1); + return df; +} + +RMFileStreamSlow &operator>>(RMFileStreamSlow &df, uint16 &var) { + uint16 v; + df.Read(&v, 2); + v = FROM_LE_16(v); + return df; +} + +RMFileStreamSlow &operator>>(RMFileStreamSlow &df, int16 &var) { + uint16 v; + df.Read(&v, 2); + var = (int16)FROM_LE_16(v); + return df; +} + +RMFileStreamSlow &operator>>(RMFileStreamSlow &df, int &var) { + int v; + df.Read(&v,4); + var = FROM_LE_32(v); + return df; +} + +RMFileStreamSlow &operator>>(RMFileStreamSlow &df, uint32 &var) { + uint32 v; + df.Read(&v, 4); + var = FROM_LE_32(v); + return df; +} + + /****************************************************************************\ * RMDataStream methods \****************************************************************************/ @@ -458,7 +574,7 @@ int RMDataStream::Length() { /** * Determines if the end of the stream has been reached - * @returns TRUE if end of stream reached, FALSE if not + * @returns true if end of stream reached, false if not */ bool RMDataStream::IsEOF() { return (m_pos >= m_length); @@ -546,7 +662,7 @@ RMDataStream &operator>>(RMDataStream &df, uint32 &var) { * Reads a series of data from the stream in a buffer * @param lpBuf Data buffer * @param size Size of the buffer - * @returns TRUE if we have reached the end, FALSE if not + * @returns true if we have reached the end, false if not */ bool RMDataStream::Read(void *lpBuf, int size) { byte *dest = (byte *)lpBuf; @@ -609,7 +725,7 @@ int RMDataStream::Pos() { /** * Check if an error occurred during reading the stream - * @returns TRUE if there was an error, false otherwise + * @returns true if there was an error, false otherwise */ bool RMDataStream::IsError() { return m_bError; @@ -714,7 +830,7 @@ RMPoint &RMPoint::operator+=(RMPoint p) { /** * Subtract (offset) of a point */ -RMPoint& RMPoint::operator-=(RMPoint p) { +RMPoint &RMPoint::operator-=(RMPoint p) { Offset(-p); return *this; } @@ -807,7 +923,7 @@ RMPoint &RMRect::TopLeft() { return *((RMPoint *)this); } -RMPoint& RMRect::BottomRight() { +RMPoint &RMRect::BottomRight() { // FIXME: This seems very bad return *((RMPoint*)this + 1); } diff --git a/engines/tony/utils.h b/engines/tony/utils.h index f9c9e614ac..0ce4e83f27 100644 --- a/engines/tony/utils.h +++ b/engines/tony/utils.h @@ -140,9 +140,7 @@ public: class RMFileStreamSlow : public RMDataStream { private: - Common::File f; - bool bMustClose; - + Common::SeekableReadStream *_stream; public: RMFileStreamSlow(); virtual ~RMFileStreamSlow(); diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp new file mode 100644 index 0000000000..ab68030b90 --- /dev/null +++ b/engines/tony/window.cpp @@ -0,0 +1,1255 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ +/************************************************************************** + * 様様様様様様様様様様様様様様様様様 * + * Nayma Software srl * + * e -= We create much MORE than ALL =- * + * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * + * .d" d$$$$$b "b. * + * .z$* d$$$$$$$L ^*$c. * + * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * + * ^*$b 4$$$$$$$$$F .d$*" * + * ^$$. 4$$$$$$$$$F .$P" Module: Window.HPP........... * + * *$. '$$$$$$$$$ 4$P 4 * + * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * + * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * + * z$" "" #$F^ "" '$c Desc: Classi per la gestione * + * z$$beu .ue=" $ "=e.. .zed$$c di una finestra Direct + * "#$e z$*" . `. ^*Nc e$"" Draw................. * + * "$$". .r" ^4. .^$$" ..................... * + * ^.@*"6L=\ebu^+C$"*b." * + * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * + * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * + * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * + * * + * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * + * * + **************************************************************************/ + +#include "tony/window.h" +#include "tony/game.h" +#include "tony/tony.h" + +namespace Tony { + +#define DDRELEASE(x) if (x) { (x)->Release(); (x)=NULL; } + +// Tabella per il b&w. Globale per accederci dalla roba ASM +static uint16 m_wPrecalcTable[0x10000]; + +/****************************************************************************\ +* Metodi di RMWindow +\****************************************************************************/ + +#ifdef REFACTOR_ME +LRESULT CALLBACK GlobalWindowProc(HWND hWnd, uint32 msg, uint16 wParam, int32 lParam) { + if ((HWND)theGame.m_wnd == NULL) + return DefWindowProc(hWnd, msg, wParam, lParam); + + switch (msg) { + case WM_CREATE: + return 0; + + case WM_CLOSE: + PostQuitMessage(0); + return 0; + + default: + return theGame.m_wnd.WindowProc(msg, wParam, lParam); + } +} +#endif + +#ifdef REFACTOR_ME +LRESULT RMWindow::WindowProc(uint32 msg, uint16 wParam, int32 lParam) { + switch (msg) { + case WM_ACTIVATE: + if (LOWORD(wParam)!=WA_INACTIVE) + theGame.Pause(false); + else + theGame.Pause(true); + return 0; + + case WM_ENTERMENULOOP: + case WM_ENTERSIZEMOVE: + if (!m_bFullscreen) + theGame.Pause(true); + return 0; + + case WM_EXITMENULOOP: + case WM_EXITSIZEMOVE: + if (!m_bFullscreen) + theGame.Pause(false); + return 0; +/* + case WM_KEYDOWN: + switch (wParam) + { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + if (GetAsyncKeyState(VK_CONTROL)&0x8000) + theGame.SaveState(wParam-'0'); + else if (GetAsyncKeyState(VK_SHIFT)&0x8000) + theGame.LoadState(wParam-'0'); + return 0; + } + return 0; +*/ + + case WM_PAINT: +// Repaint(); + ValidateRect(m_hWnd, NULL); + return 0; + + case WM_COMMAND: + switch LOWORD(wParam) { +/* + case ID_OPTIONS: + theGame.OptionScreen(); + break; +*/ + + case ID_FULLSCREEN: + theGame.SwitchFullscreen(!m_bFullscreen); + break; +/* + case ID_ENABLEINPUT: + theGame.GetEngine()->EnableInput(); + break; +*/ + case ID_SCREENSHOT: + m_bGrabScreenshot = true; +// m_bGrabMovie = !m_bGrabMovie; + break; + + case ID_MOVIE: +// m_bGrabMovie = !m_bGrabMovie; + break; +/* + case ID_BLACKWHITE: + m_bBlackWhite = !m_bBlackWhite; + break; +*/ + default: + return DefWindowProc(m_hWnd, msg, wParam, lParam); + } + return 0; + + case WM_SYSKEYDOWN: + if (m_bFullscreen) + return 0; + else + return DefWindowProc(m_hWnd ,msg, wParam, lParam); + + default: + if (m_hWnd != NULL) // Fix del bug visto da BoundsChecker + return DefWindowProc(m_hWnd, msg, wParam, lParam); + return 0; + } +} +#endif + +/* +HANDLE hWaitFlip; +bool bExitThread; + +void DoFlipThread(LPDIRECTDRAWSURFACE lpDDSPrimary) +{ + bExitThread=false; + + while (1) + { + WaitForSingleObject(hWaitFlip,INFINITE); + if (bExitThread) _endthread(); + lpDDSPrimary->Flip(NULL,DDFLIP_WAIT); + } +} +*/ + +void RMWindow::InitDirectDraw(void) { +#ifdef REFACTOR_ME + DDInit(); + + ShowCursor(false); + ShowWindow(m_hWnd, SW_SHOW); + UpdateWindow(m_hWnd); +#endif +} + +void RMWindow::Init(/*HINSTANCE hInst*/) { +#ifdef REFACTOR_ME + WNDCLASS wc; + + // Registra la classe di finestra + wc.style = CS_HREDRAW|CS_VREDRAW; + wc.lpfnWndProc = GlobalWindowProc; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hInstance = hInst; + wc.hIcon = LoadIcon(hInst,MAKEINTRESOURCE(IDI_ICON1)); + wc.hCursor = LoadCursor(NULL,IDC_ARROW); + wc.hbrBackground = NULL; + wc.lpszMenuName = NULL; + wc.lpszClassName = "RMClass"; + RegisterClass(&wc); + + m_hWnd = CreateWindow( + "RMClass", + "Tony Tough and the night of Roasted Moths", + WS_OVERLAPPEDWINDOW & (~WS_THICKFRAME) & (~WS_BORDER) & (~WS_MAXIMIZEBOX), + 50, 50, + RM_SX + GetSystemMetrics(SM_CXDLGFRAME) * 2, + RM_SY + GetSystemMetrics(SM_CYDLGFRAME) * 2 + GetSystemMetrics(SM_CYMENU) + GetSystemMetrics(SM_CYCAPTION), + NULL, + NULL, + hInst, + NULL + ); + + if (m_hWnd == NULL) { + int err = GetLastError(); + RMString str; + + str.Format("error: %u",err); + MessageBox(NULL,str,"sux",MB_OK); + + assert(0); + } + + // Inizializza la finestra directdraw + //DDInit(); + + // Inizializza i conteggi degli FPS + fps = lastfcount = fcount = lastsecond = 0; + + m_bGrabScreenshot = false; + m_bGrabThumbnail = false; + m_bGrabMovie = false; + + //hWaitFlip = CreateEvent(NULL,false,false, NULL); +#endif +}; + +void RMWindow::Close(void) { + DDClose(); +#ifdef REFACTOR_ME + DestroyWindow(m_hWnd); +#endif +} + +void RMWindow::GrabThumbnail(uint16 *thumbmem) { + m_bGrabThumbnail = true; + m_wThumbBuf = thumbmem; +} + +float RGB_to_HSL(float r,float g, float b, float *h, float *s, float *l) { + float v; + float m; + float vm; + float r2, g2, b2; + + if (r > g) v = r; else v = g; + if (v > b) v = v; else v = b; + if (r < b) m = r; else m = b; + if (m < b) m = m; else m = b; + + if ((*l = (m + v) / 2.0f) <= 0.0f) return *l; + if ((*s = vm = v - m) > 0.0f) { + *s /= (*l <= 0.5f) ? (v + m) : (2.0f - v - m) ; + } else + return *l; + + r2 = (v - r) / vm; + g2 = (v - g) / vm; + b2 = (v - b) / vm; + + if (r == v) + *h = (g == m ? 5.0f + b2 : 1.0f - g2); + else if (g == v) + *h = (b == m ? 1.0f + r2 : 3.0f - b2); + else + *h = (r == m ? 3.0f + g2 : 5.0f - r2); + + *h /= 6; + + return *l; +} + +#define ITOF(val) (float)((float)(val) / 31.0f) +#define FTOI(val) (int)(((float)(val) * 31.0f + 0.5f)) + +void RMWindow::CreateBWPrecalcTable(void) { +#define CLAMP(var, min, max) var = (var < min ? min : (var > max ? max : var)); + + int i; + int r, g, b; + int min, max; + int shiftR, shiftG, shiftB; + + // Calcola i valori di shift in base alle maschere + for (shiftR = 15; (mskRed & (1 << shiftR)) == 0; shiftR--) + ; + for (shiftG = 15; (mskGreen & (1 << shiftG)) == 0; shiftG--) + ; + for (shiftB = 15; (mskBlue & (1 << shiftB)) == 0; shiftB--) + ; + + shiftR -= 4; + shiftG -= 4; + shiftB -= 4; + + // @@@ CLAMP inutile (in teoria) + CLAMP(shiftR, 0, 15); + CLAMP(shiftG, 0, 15); + CLAMP(shiftB, 0, 15); + + for (i = 0;i<0x10000;i++) + { + r=(i >> shiftR) & 0x1F; + g=(i >> shiftG) & 0x1F; + b=(i >> shiftB) & 0x1F; + +#if 1 + if (r < g) min=r; else min = g; + if (b < min) min = b; + if (r > g) max = r; else max = g; + if (b > max) max = b; + min = (min + max) / 2; +#else + // Nuova formula B&W. L'immagine pi fedele all'originale, ma l'effetto peggiore + float fr, fg, fb; + + fr = (float)r / 63.0f; + fg = (float)g / 63.0f; + fb = (float)b / 63.0f; + + min = (int)((fr*0.11f + fg*0.69f + fb*0.33f)*63.f); +#endif + + /* + RGB_to_HSL(ITOF(r), ITOF(g), ITOF(b), &h, &s, &l); + min = FTOI(l); + */ + + r = min + 8 - 8; + g = min + 5 - 8; + b = min + 0 - 8; + + CLAMP(r, 0, 31); + CLAMP(g, 0, 31); + CLAMP(b, 0, 31); + + m_wPrecalcTable[i] = (b << shiftB) | (g << shiftG) | (r << shiftR); + } +} + + +void RMWindow::DDClose(void) { +#ifdef REFACTOR_ME + DDRELEASE(m_Back); + DDRELEASE(m_Primary); + DDRELEASE(m_MainClipper); + DDRELEASE(m_BackClipper); + DDRELEASE(m_DD); +#endif +} + +void RMWindow::DDInit(void) { +#ifdef REFACTOR_ME + HRESULT err; + + // Crea DirectDraw + err = DirectDrawCreate(NULL, &m_DD, NULL); + assert(err == DD_OK); + + // Crea il clipper + err = DirectDrawCreateClipper(0, &m_MainClipper, NULL); + err=DirectDrawCreateClipper(0, &m_BackClipper, NULL); + + // Lo associa alla finestra + m_MainClipper->SetHWnd(0, m_hWnd); + + // Setta la cooperazione a normal + m_DD->SetCooperativeLevel(m_hWnd, DDSCL_NORMAL); + +#ifdef STARTFULLSCREEN + // Di default in fullscreen + m_bFullscreen=false; // Fa finta, per obbligarlo a cambiare + m_Primary=m_Back=NULL; + SwitchFullscreen(true); +#else + // Di default in finestra + m_bFullscreen = true; // Fa finta, per obbligarlo a cambiare + m_Primary = m_Back = NULL; + SwitchFullscreen(false); +#endif + +/* + if (!ISMODE1() && !ISMODE2() && !ISMODE3() && !ISMODE4()) + { + RMString str; + str.Format("Graphic mode not supported: %04x %04x %04x",mskRed,mskGreen,mskBlue); + MessageBox(m_hWnd,str,"Debug",MB_OK); + } +*/ +#endif +} + + +void RMWindow::SwitchFullscreen(bool bFull) { +#ifdef REFACTOR_ME + HRESULT err; + DDSURFACEDESC ddsd; + DDSCAPS ddscaps; + DDBLTFX ddbltfx; + Common::Rect rcWin; + + // Se non c'e' niente da fare, esci + if (bFull == m_bFullscreen) + return; + + // Termina il thread di flipping + //bExitThread = true; + + // Rilascia le superfici create in precedenza (se ce n'erano) + DDRELEASE(m_Back); + DDRELEASE(m_Primary); + + // Legge le coordinate della finestra + if (m_bFullscreen) { + rcWin.left = 50; + rcWin.top = 50; + } else { + GetWindowRect(m_hWnd, &rcWin); + } + + if (bFull) { + // Setta la risoluzione + m_DD->SetCooperativeLevel(m_hWnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_ALLOWREBOOT); + m_DD->SetDisplayMode(RM_SX, RM_SY, 16); + + // A tutto schermo, possiamo creare una catena di flipping + ZeroMemory(&ddsd, sizeof(ddsd)); + ddsd.dwSize = sizeof(ddsd); + ddsd.dwFlags = DDSD_CAPS|DDSD_BACKBUFFERCOUNT; + ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP; + ddsd.dwBackBufferCount = 1; + if ((err=m_DD->CreateSurface(&ddsd, &m_Primary, NULL)) != DD_OK) { + //wsprintf(errbuf,"Error creating primary surface2 (%lx)",err); + //MessageBox(hWnd,errbuf,"grSwitchFullscreen()",MB_OK); + assert(0); + } + + ddscaps.dwCaps = DDSCAPS_BACKBUFFER; + if ((err=m_Primary->GetAttachedSurface(&ddscaps, &m_Back)) != DD_OK) { + //wsprintf(errbuf,"Error getting attached surface2 (%lx)",err); + //MessageBox(hWnd,errbuf,"grSwitchFullscreen()",MB_OK); + assert(0); + } + + // Pulisce i buffer + ddbltfx.dwSize = sizeof(ddbltfx); + ddbltfx.dwFillColor = 0; + m_Back->Blt(NULL, NULL, NULL,DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx); + + ddbltfx.dwSize=sizeof(ddbltfx); + ddbltfx.dwFillColor = 0; + m_Primary->Blt(NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx); + + // Inizializza il thread + //_beginthread((void (*)(void*))DoFlipThread,10240,(void*)m_Primary); + } else { + // In windowed, non possiamo fare flipping (purtroppo) + m_DD->RestoreDisplayMode(); + m_DD->SetCooperativeLevel(m_hWnd,DDSCL_NORMAL); + + ZeroMemory(&ddsd,sizeof(ddsd)); + ddsd.dwSize=sizeof(ddsd); + ddsd.dwFlags=DDSD_CAPS; + ddsd.ddsCaps.dwCaps=DDSCAPS_PRIMARYSURFACE; + if ((err=m_DD->CreateSurface(&ddsd,&m_Primary, NULL)) != DD_OK) { + //wsprintf(errbuf,"Error creating primary surface (%lx)",err); + //MessageBox(hWnd,errbuf,"ChangeResolution()",MB_OK); + assert(0); + } + + ZeroMemory(&ddsd,sizeof(ddsd)); + ddsd.dwSize=sizeof(ddsd); + ddsd.dwFlags=DDSD_CAPS|DDSD_WIDTH|DDSD_HEIGHT; + ddsd.ddsCaps.dwCaps=DDSCAPS_OFFSCREENPLAIN; // se puo', in video memory + ddsd.dwWidth=RM_SX; + ddsd.dwHeight=RM_SY; + if ((err=m_DD->CreateSurface(&ddsd,&m_Back, NULL)) != DD_OK) { + //wsprintf(errbuf,"Error creating backbuffer surface (%lx)",err); + //MessageBox(hWnd,errbuf,"ChangeResolution()",MB_OK); + assert(0); + } + + // Pulizia per favore + ddbltfx.dwSize = sizeof(ddbltfx); + ddbltfx.dwFillColor = 0; + m_Back->Blt(NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx); + } + + // Posiziona e ridimensiona la finestra + if (bFull) { + SetWindowPos(m_hWnd, HWND_TOP, 0, 0, RM_SX, RM_SY, 0); + + // Disabilita il clipper (non necessario) + m_Primary->SetClipper(NULL); + } else { + SetWindowPos(m_hWnd, HWND_TOP, rcWin.left, rcWin.top, RM_SX + GetSystemMetrics(SM_CXDLGFRAME) * 2, + RM_SY + GetSystemMetrics(SM_CYDLGFRAME) * 2 + GetSystemMetrics(SM_CYCAPTION), 0); + + m_Primary->SetClipper(m_MainClipper); + //m_Primary->SetClipper(NULL); + } + + // Si ricorda il nuovo stato + m_bFullscreen = bFull; + InvalidateRect(m_hWnd, NULL, false); + + // Legge il nuovo pixel format + UpdatePixelFormat(); +#endif +} + +void RMWindow::UpdatePixelFormat(void) { +#ifdef REFACTOR_ME + DDPIXELFORMAT ddpf; + + // Si fa ridare il nuovo pixel format + ddpf.dwSize = sizeof(ddpf); + m_Primary->GetPixelFormat(&ddpf); + + // Copia le componenti dei colori + mskRed = ddpf.dwRBitMask; + mskGreen = ddpf.dwGBitMask; + mskBlue = ddpf.dwBBitMask; + + // Ricalcola la tabella per l'effetto b&w + CreateBWPrecalcTable(); +#endif +} + + +void RMWindow::Repaint(void) { +#ifdef REFACTOR_ME + Common::Rect rcWin; + HRESULT err; + + if (m_Primary==NULL) + return; + + // Se siamo a tutto schermo, basta un flip + if (m_bFullscreen) { + m_DD->WaitForVerticalBlank(DDWAITVB_BLOCKBEGIN, NULL); + + // Flippa flappa + while (1) { + //err=m_Primary->Flip(NULL,DDFLIP_WAIT); + err = m_Primary->BltFast(0, 0, m_Back, NULL, DDBLTFAST_WAIT); + + if (err==DD_OK) + break; + else if (err == DDERR_SURFACELOST) { + //MessageBox(NULL,"Primary lost!","RMWindow::Repaint()",MB_OK); + m_Primary->Restore(); + return; + } + } + } + // Altrimenti bisogna andare di blit + else { + // Si calcola il rettangolo effettivamente visibile + GetWindowRect(m_hWnd, &rcWin); + OffsetRect(&rcWin, GetSystemMetrics(SM_CXDLGFRAME), GetSystemMetrics(SM_CYDLGFRAME) + GetSystemMetrics(SM_CYCAPTION)); + + // Aggiusta le dimensioni del rettangolo + rcWin.right = rcWin.left + RM_SX; + rcWin.bottom = rcWin.top + RM_SY; + + // Blit del back nel primary + while (1) { + err = m_Primary->Blt(&rcWin, m_Back, NULL,DDBLT_WAIT, NULL); + if (err == DD_OK) + break; + else if (err == DDERR_SURFACELOST) { + //MessageBox(NULL,"Primary lost!","RMWindow::Repaint()",MB_OK); + m_Primary->Restore(); + return; + } + } + } +#endif +} + + +void RMWindow::Unlock(DDSURFACEDESC &ddsd) { +#ifdef REFACTOR_ME + m_Back->Unlock(ddsd.lpSurface); +#endif +} + +void RMWindow::WipeEffect(Common::Rect &rcBoundEllipse) { +#ifdef REFACTOR_ME + Common::Rect rcScreen; + HRGN hrgnCombined; + HRGN hrgnScreen; + HRGN hrgnEllipse; + uint32 dwDataSize; + RGNDATA *rgnData; + + SetRect(&rcScreen, 0, 0, 640, 480); + + hrgnScreen = CreateRectRgnIndirect(&rcScreen); + hrgnEllipse = CreateEllipticRgnIndirect(&rcBoundEllipse); + hrgnCombined = CreateRectRgnIndirect(&rcScreen); + + CombineRgn(hrgnCombined, hrgnScreen, hrgnEllipse, RGN_DIFF); + + dwDataSize = GetRegionData(hrgnCombined, 0, NULL); + rgnData = (RGNDATA *)new char[dwDataSize]; + GetRegionData(hrgnCombined, dwDataSize, rgnData); + + m_BackClipper->SetClipList(rgnData, 0); + m_Back->SetClipper(m_BackClipper); + + DDBLTFX ddbltfx; + ddbltfx.dwSize=sizeof(ddbltfx); + ddbltfx.dwFillColor = 0; + m_Back->Blt(NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx); + + m_Back->SetClipper(NULL); + delete [] rgnData; + DeleteObject(hrgnCombined); + DeleteObject(hrgnEllipse); + DeleteObject(hrgnScreen); +#endif +} + +bool RMWindow::Lock(DDSURFACEDESC &ddsd) { +#ifdef REFACTOR_ME + HRESULT err; + + // Lock della surface + ddsd.dwSize = sizeof(ddsd); + while (1) { + err = m_Back->Lock(NULL,&ddsd,DDLOCK_WAIT|DDLOCK_WRITEONLY|DDLOCK_NOSYSLOCK, NULL); + if (err==DD_OK) + break; + else if (err==DDERR_SURFACELOST) { +// MessageBox(NULL,"Primary lost!","RMWindow::Repaint()",MB_OK); + m_Back->Restore(); + return false; + } + } +#endif + return true; +} + +void RMWindow::GetNewFrame(byte *lpBuf, Common::Rect *rcBoundEllipse) { +#ifdef REFACTOR_ME + HRESULT err; + DDSURFACEDESC ddsd; + int x,y; + byte *dest; + uint16 *destw; + RMString s; + uint16 *src,src2; + + if (GetAsyncKeyState(VK_F7)&0x8001) + goto DOFRAMERATE; + + if (!Lock(ddsd)) + return; + + // Copia del buffer + src = (uint16 *)lpBuf; + dest = (byte *)ddsd.lpSurface; +// src+=RM_SKIPY*RM_BBX; Lo skipY e' integrato nell'offseting del bigbuffer + + if (ISMODE2()) { + // 565 RGB, Marco - Matrox G200 + int lineinc = (ddsd.lPitch / 2 - RM_SX) * 2; + int lineinc2 = (RM_BBX - RM_SKIPX - RM_SX) * 2; + destw = (uint16 *)dest; + + if (bCfgAnni30) { + __asm { + pushad + + mov y,RM_SY + mov esi,src + mov edi,dest + + //ALIGN 4 + line30: + mov x,RM_SX + add esi,RM_SKIPX*2 + + line302: + mov eax,[esi] ; U 1 + mov ebx,[esi+4] ; V + mov ecx,eax ; U 2 + mov edx,ebx ; V + and eax,0x7FE07FE0 ; U 3 + and ebx,0x7FE07FE0 ; V + and ecx,0x001F001F ; U 4 + and edx,0x001F001F ; V + shl eax,1 ; U 5 + shl ebx,1 ; V + or eax,ecx ; U 6 + or ebx,edx ; V + + // Codice B&W - Pairato + mov ecx,eax + mov edx,ebx + and eax,0xFFFF + and ebx,0xFFFF + shr ecx,16 + shr edx,16 + mov eax,[offset m_wPrecalcTable + eax*2] + mov ebx,[offset m_wPrecalcTable + ebx*2] + mov ecx,[offset m_wPrecalcTable + ecx*2] + mov edx,[offset m_wPrecalcTable + edx*2] + shl ecx,16 + shl edx,16 + and eax,0xFFFF + and ebx,0xFFFF + or eax,ecx + or ebx,edx + + mov [edi],eax ; U 7 + mov [edi+4],ebx ; V + add esi,8 ; U 8 + add edi,8 ; V + sub x,4 ; U 9 + jnz line302 ; V + + add esi,lineinc2 + add edi,lineinc + + dec y + jnz line30 + + popad + } + + } else { + __asm { + pushad + + mov y,RM_SY + mov esi,src + mov edi,dest + + //ALIGN 4 + line: + mov x,RM_SX + add esi,RM_SKIPX*2 + + line2: + mov eax,[esi] ; U 1 + mov ebx,[esi+4] ; V + mov ecx,eax ; U 2 + mov edx,ebx ; V + and eax,0x7FE07FE0 ; U 3 + and ebx,0x7FE07FE0 ; V + and ecx,0x001F001F ; U 4 + and edx,0x001F001F ; V + shl eax,1 ; U 5 + shl ebx,1 ; V + or eax,ecx ; U 6 + or ebx,edx ; V + mov [edi],eax ; U 7 + mov [edi+4],ebx ; V + add esi,8 ; U 8 + add edi,8 ; V + sub x,4 ; U 9 + jnz line2 ; V + + add esi,lineinc2 + add edi,lineinc + + dec y + jnz line + + popad + } + } + } else if (ISMODE3()) { + // 5551 RGB + int lineinc = (ddsd.lPitch / 2 - RM_SX) * 2; + int lineinc2 = (RM_BBX - RM_SKIPX - RM_SX) * 2; + destw=(uint16 *)dest; + + if (bCfgAnni30) { + __asm { + mov y,RM_SY + mov esi,src + mov edi,dest + + aline30: + mov x,RM_SX + add esi,RM_SKIPX*2 + + aline302: + mov eax,[esi] ; U 1 + mov ebx,[esi+4] ; V + shl eax,1 ; U 2 + shl ebx,1 ; V + + // Codice B&W - Pairato + mov ecx,eax + mov edx,ebx + and eax,0xFFFF + and ebx,0xFFFF + shr ecx,16 + shr edx,16 + mov eax,[offset m_wPrecalcTable + eax*2] + mov ebx,[offset m_wPrecalcTable + ebx*2] + mov ecx,[offset m_wPrecalcTable + ecx*2] + mov edx,[offset m_wPrecalcTable + edx*2] + shl ecx,16 + shl edx,16 + and eax,0xFFFF + and ebx,0xFFFF + or eax,ecx + or ebx,edx + + mov [edi],eax ; U 3 + mov [edi+4],ebx ; V + add esi,8 ; U 4 + add edi,8 ; V + sub x,4 ; U 5 + jnz aline302 ; V + + add esi,lineinc2 + add edi,lineinc + + dec y + jnz aline30 + } + } else { + __asm { + mov y,RM_SY + mov esi,src + mov edi,dest + + aline: + mov x,RM_SX + add esi,RM_SKIPX*2 + + aline2: + mov eax,[esi] ; U 1 + mov ebx,[esi+4] ; V + shl eax,1 ; U 2 + shl ebx,1 ; V + mov [edi],eax ; U 3 + mov [edi+4],ebx ; V + add esi,8 ; U 4 + add edi,8 ; V + sub x,4 ; U 5 + jnz aline2 ; V + + add esi,lineinc2 + add edi,lineinc + + dec y + jnz aline + } + } + } else if (ISMODE4()) { + // 565 BGR - Intergraph + int lineinc=(ddsd.lPitch / 2 - RM_SX) * 2; + int lineinc2=(RM_BBX - RM_SKIPX - RM_SX) * 2; + destw=(uint16 *)dest; + + if (bCfgAnni30) // Manca supporto per Intergraph ... non so pairarlo!!! :) + { + __asm { + mov y,RM_SY + mov esi,src + mov edi,dest + + //ALIGN 4 + intersux30: + mov ecx,RM_SX + add esi,RM_SKIPX*2 + + intersux302: + mov eax,[esi] ; U 1 0BBBBBGGGGGRRRRR 0BBBBBGGGGGRRRRR + add esi,4 ; V + mov ebx,eax ; U 2 0BBBBBGGGGGRRRRR 0BBBBBGGGGGRRRRR + mov edx,eax ; V 0BBBBBGGGGGRRRRR 0BBBBBGGGGGRRRRR + shl eax,11 ; U 3 RRRRR0BBBBBGGGGG RRRRR00000000000 + and ebx,0x03E003E0 ; V 000000GGGGG00000 000000GGGGG00000 + and edx,0x7C007C00 ; U 4 0BBBBB0000000000 0BBBBB0000000000 + and eax,0xF800F800 ; V RRRRR00000000000 RRRRR00000000000 + shr edx,10 ; U 5 00000000000BBBBB 00000000000BBBBB + add ebx,ebx ; V 00000GGGGG000000 00000GGGGG000000 + or eax,edx ; U 6 RRRRR000000BBBBB RRRRR000000BBBBB + add edi,4 ; V + or eax,ebx ; U 7 RRRRRGGGGG0BBBBB RRRRRGGGGG0BBBBB + sub ecx,2 ; V + mov [edi-4],eax ; U 8 + jnz intersux302 ; V + + add esi,lineinc2 + add edi,lineinc + + dec y + jnz intersux30 + } + } else { + __asm { + mov y,RM_SY + mov esi,src + mov edi,dest + + //ALIGN 4 + intersux: + mov ecx,RM_SX + add esi,RM_SKIPX*2 + + intersux2: + mov eax,[esi] ; U 1 0BBBBBGGGGGRRRRR 0BBBBBGGGGGRRRRR + add esi,4 ; V + mov ebx,eax ; U 2 0BBBBBGGGGGRRRRR 0BBBBBGGGGGRRRRR + mov edx,eax ; V 0BBBBBGGGGGRRRRR 0BBBBBGGGGGRRRRR + shl eax,11 ; U 3 RRRRR0BBBBBGGGGG RRRRR00000000000 + and ebx,0x03E003E0 ; V 000000GGGGG00000 000000GGGGG00000 + and edx,0x7C007C00 ; U 4 0BBBBB0000000000 0BBBBB0000000000 + and eax,0xF800F800 ; V RRRRR00000000000 RRRRR00000000000 + shr edx,10 ; U 5 00000000000BBBBB 00000000000BBBBB + add ebx,ebx ; V 00000GGGGG000000 00000GGGGG000000 + or eax,edx ; U 6 RRRRR000000BBBBB RRRRR000000BBBBB + add edi,4 ; V + or eax,ebx ; U 7 RRRRRGGGGG0BBBBB RRRRRGGGGG0BBBBB + sub ecx,2 ; V + mov [edi-4],eax ; U 8 + jnz intersux2 ; V + + add esi,lineinc2 + add edi,lineinc + + dec y + jnz intersux + } + } + } else { + // 555 RGB - Computer di Bagio, nVidia Riva 128 + int lineinc = (ddsd.lPitch / 2 - RM_SX) * 2; + int lineinc2 = (RM_BBX - RM_SKIPX - RM_SX) * 2; + destw=(uint16 *)dest; + + if (bCfgAnni30) { + __asm { + mov y,RM_SY + mov esi,src + mov edi,dest + + bagioline30: + mov x,RM_SX + add esi,RM_SKIPX*2 + + bagioline302: + mov eax,[esi] ; U 1 + mov ebx,[esi+4] ; V + + // Codice B&W - Pairato + mov ecx,eax + mov edx,ebx + and eax,0xFFFF + and ebx,0xFFFF + shr ecx,16 + shr edx,16 + mov eax,[offset m_wPrecalcTable + eax*2] + mov ebx,[offset m_wPrecalcTable + ebx*2] + mov ecx,[offset m_wPrecalcTable + ecx*2] + mov edx,[offset m_wPrecalcTable + edx*2] + shl ecx,16 + shl edx,16 + and eax,0xFFFF + and ebx,0xFFFF + or eax,ecx + or ebx,edx + + mov [edi],eax ; U 3 + mov [edi+4],ebx ; V + add esi,8 ; U 4 + add edi,8 ; V + sub x,4 ; U 5 + jnz bagioline302 ; V + + add esi,lineinc2 + add edi,lineinc + + dec y + jnz bagioline30 + } + } else { + for (y = 0; y < RM_SY; y++) { + CopyMemory(dest, src + RM_SKIPX, RM_SX * 2); + dest += ddsd.lPitch; + src += RM_BBX; + } + } + } + + + // Unlock + Unlock(ddsd); + + // Effetto di wipe + if (rcBoundEllipse) { + WipeEffect(*rcBoundEllipse); + } + + // Repaint + Repaint(); + +DOFRAMERATE: + + // Conteggio per gli FPS + fcount++; + + if (lastsecond + 1000 < _vm->GetTime()) { + lastsecond = _vm->GetTime(); + fps=fcount - lastfcount; + lastfcount = fcount; + + if (!m_bFullscreen) { + s.Format("Tony Tough and the night of Roasted Moths - %u FPS",fps); + SetWindowText(m_hWnd,s); + } + } if (!_vm->getIsDemo()) { + if (m_bGrabScreenshot || m_bGrabMovie) { + RMSnapshot snapshot; + + snapshot.GrabScreenshot(lpBuf); + m_bGrabScreenshot = false; + } + + if (m_bGrabThumbnail) { + RMSnapshot snapshot; + + snapshot.GrabScreenshot(lpBuf, 4, m_wThumbBuf); + m_bGrabThumbnail = false; + } + } +#endif +} + + +/****************************************************************************\ +* Metodi di RMSnapshot +\****************************************************************************/ + +char RMSnapshot::bufDrive[_MAX_DRIVE]; +char RMSnapshot::bufDir[_MAX_DIR]; +char RMSnapshot::bufName[_MAX_FNAME]; +char RMSnapshot::bufExt[_MAX_EXT]; +char RMSnapshot::filename[512]; +byte RMSnapshot::rgb[RM_SX * RM_SY * 3]; + +bool RMSnapshot::GetFreeSnapName(char *fn) { +#ifdef REFACTOR_ME + int i, j, k; + HANDLE h; + + theGame.GetDataDirectory(RMGame::DD_SHOTS, fn); + _splitpath(fn, bufDrive, bufDir, NULL, NULL); + + for (i = 1; i < 10; i++) { + wsprintf(bufName,"rm%d00",i); + _makepath(fn,bufDrive,bufDir,bufName,".bmp"); + h = CreateFile(fn,GENERIC_READ,FILE_SHARE_READ, NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL, NULL); + if (h == INVALID_HANDLE_VALUE) + break; + CloseHandle(h); + } + + i--; + + for (j = 1; j < 10; j++) { + wsprintf(bufName,"rm%d%d0",i,j); + _makepath(fn,bufDrive,bufDir,bufName,".bmp"); + h=CreateFile(fn,GENERIC_READ,FILE_SHARE_READ, NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL, NULL); + if (h==INVALID_HANDLE_VALUE) + break; + CloseHandle(h); + } + + j--; + + for (k = 0; k < 10; k++) { + wsprintf(bufName,"rm%d%d%d",i,j,k); + _makepath(fn,bufDrive,bufDir,bufName,".bmp"); + h = CreateFile(fn,GENERIC_READ,FILE_SHARE_READ, NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL, NULL); + if (h==INVALID_HANDLE_VALUE) + break; + CloseHandle(h); + } + + if (k == 10) { + k = 0; + j++; + if (j == 10) { + j = 0; + i++; + if (i == 10) + return false; + } + + wsprintf(bufName,"rm%d%d%d",i,j,k); + _makepath(fn,bufDrive,bufDir,bufName,".bmp"); + } +#endif + return true; +} + +void RMSnapshot::GrabScreenshot(byte *lpBuf, int dezoom, uint16 *lpDestBuf) { +#ifdef REFACTOR_ME + uint16 *src = (uint16 *)lpBuf; + + int dimx = RM_SX / dezoom; + int dimy = RM_SY / dezoom; + + int u, v, curv; + + uint16 appo; + uint32 k = 0; + int sommar, sommab, sommag; + uint16 *cursrc; + + if (lpDestBuf == NULL) + src += (RM_SY - 1) * RM_BBX; + + if (dezoom == 1 && 0) { // @@@ NON E' TESTATA MOLTO BENE!!! + byte *curOut = rgb; + + for (int y = 0; y < dimy; y++) { + for (int x = 0; x < dimx; x++) { + cursrc = &src[RM_SKIPX + x]; + + *curOut++ = ((*cursrc) & 0x1F) << 3; + *curOut++ = (((*cursrc) >> 5) & 0x1F) << 3; + *curOut++ = (((*cursrc) >> 10) & 0x1F) << 3; + + if (lpDestBuf) + *lpDestBuf++ = *cursrc; + } + + if (lpDestBuf == NULL) + src -= RM_BBX; + else + src += RM_BBX; + } + } else { + for (int y = 0; y < dimy; y++) { + for(int x = 0; x < dimx; x++) { + cursrc = &src[RM_SKIPX + x * dezoom]; + sommar = sommab = sommag = 0; + + for (v = 0; v < dezoom; v++) + for (u = 0; u < dezoom; u++) { + if (lpDestBuf == NULL) + curv = -v; + else + curv = v; + + sommab += cursrc[curv*RM_BBX + u] & 0x1F; + sommag += (cursrc[curv*RM_BBX + u] >> 5) & 0x1F; + sommar += (cursrc[curv*RM_BBX + u] >> 10) & 0x1F; + } + + rgb[k + 0] = (byte) (sommab * 8 / (dezoom * dezoom)); + rgb[k + 1] = (byte) (sommag * 8 / (dezoom * dezoom)); + rgb[k + 2] = (byte) (sommar * 8 / (dezoom * dezoom)); + + if (lpDestBuf!=NULL) + lpDestBuf[k/3] = ((int)rgb[k+0]>>3) | (((int)rgb[k+1]>>3)<<5) | (((int)rgb[k+2]>>3)<<10); + + k+=3; + } + + if (lpDestBuf == NULL) + src -= RM_BBX * dezoom; + else + src += RM_BBX * dezoom; + } + } + + + if (lpDestBuf == NULL) { + if (!GetFreeSnapName(filename)) + return; + + HANDLE hFile = CreateFile(filename, + GENERIC_WRITE, + 0, + NULL, + CREATE_ALWAYS, + FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, + NULL); + + BITMAPFILEHEADER bmfHeader; + bmfHeader.bfType = ((uint16) ('M' << 8) | 'B'); + bmfHeader.bfSize = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + dimx * dimy * 3; + bmfHeader.bfReserved1 = 0; + bmfHeader.bfReserved2 = 0; + bmfHeader.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER); + + BITMAPINFOHEADER bmiHeader; + bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + bmiHeader.biWidth = dimx; + bmiHeader.biHeight = dimy; + bmiHeader.biPlanes = 1; + bmiHeader.biBitCount = 24; + bmiHeader.biCompression = BI_RGB; + bmiHeader.biSizeImage = dimx * dimy * 3; + bmiHeader.biXPelsPerMeter = 0xB12; + bmiHeader.biYPelsPerMeter = 0xB12; + bmiHeader.biClrUsed = 0; + bmiHeader.biClrImportant = 0; + + uint32 dwWritten; + WriteFile(hFile, &bmfHeader, sizeof(BITMAPFILEHEADER), &dwWritten, NULL); + WriteFile(hFile, &bmiHeader, sizeof(BITMAPINFOHEADER), &dwWritten, NULL); + + WriteFile(hFile, rgb, dimx * dimy * 3, &dwWritten, NULL); + CloseHandle(hFile); + } +#endif +} + +} // End of namespace Tony diff --git a/engines/tony/window.h b/engines/tony/window.h index d248ffb871..25aef5c619 100644 --- a/engines/tony/window.h +++ b/engines/tony/window.h @@ -50,15 +50,36 @@ #include "common/scummsys.h" #include "common/rect.h" +#include "tony/adv.h" namespace Tony { typedef uint32 HWND; +struct DDSURFACEDESC { +}; + +class RMSnapshot { +private: + // Buffer per la creazione dei path + static char bufDrive[_MAX_DRIVE], bufDir[_MAX_DIR], bufName[_MAX_FNAME], bufExt[_MAX_EXT]; + static char filename[512]; + + // Buffer per la conversione a RGB + static byte rgb[RM_SX * RM_SY * 3]; + +private: + bool GetFreeSnapName(char *fn); + +public: + // Prende uno screenshot + void GrabScreenshot(byte *lpBuf, int dezoom = 1, uint16 *lpDestBuf = NULL); +}; + class RMWindow { private: - bool Lock(/*DDSURFACEDESC& ddsd */); - void Unlock(/*DDSURFACEDESC& ddsd */); + bool Lock(DDSURFACEDESC &ddsd); + void Unlock(DDSURFACEDESC &ddsd); // Inizializza DirectDraw void DDInit(void); @@ -115,7 +136,7 @@ protected: void GetNewFrame(byte *lpBuf, Common::Rect *rcBoundEllipse); // Avverte di grabbare un thumbnail per il salvataggio -// void GrabThumbnail(uint16 *buf); + void GrabThumbnail(uint16 *buf); operator HWND() { return m_hWnd; } -- cgit v1.2.3 From 6d0f1fca46c8bd9b5b4e7ccaf6631850c29d1447 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 3 May 2012 23:08:19 +1000 Subject: TONY: Formatting fixes --- engines/tony/custom.cpp | 94 +++++++++++++++++++++------------------------- engines/tony/font.cpp | 40 +++++++------------- engines/tony/game.cpp | 22 +++++------ engines/tony/gfxcore.cpp | 87 +++++++++++++++++------------------------- engines/tony/gfxengine.cpp | 74 +++++++++--------------------------- engines/tony/input.cpp | 50 ++++++++---------------- engines/tony/inventory.cpp | 24 +++++------- engines/tony/loc.cpp | 29 +++++--------- engines/tony/mpal/mpal.cpp | 6 +-- engines/tony/tonychar.cpp | 6 +-- engines/tony/window.cpp | 15 +++----- 11 files changed, 163 insertions(+), 284 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 55f6cbe77d..209fc11212 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -218,7 +218,7 @@ int curChangedHotspot = 0; struct { uint32 dwCode; - uint32 nX,nY; + uint32 nX, nY; void Save(Common::OutSaveFile *f) { f->writeUint32LE(dwCode); @@ -629,7 +629,7 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(uint32 nLoc, uint32 tX, uint32 tY, uint3 Unfreeze(); - h = mpalQueryDoAction(0,nLoc,0); + h = mpalQueryDoAction(0, nLoc,0); if (!bNoOcchioDiBue) { WaitWipeEnd(); @@ -1079,18 +1079,18 @@ DECLARE_CUSTOM_FUNCTION(WaitForPatternEnd)(uint32 nItem, uint32, uint32, uint32) DECLARE_CUSTOM_FUNCTION(SetTonyPosition)(uint32 nX, uint32 nY, uint32 nLoc, uint32) { - Tony->SetPosition(RMPoint(nX,nY),nLoc); + Tony->SetPosition(RMPoint(nX, nY), nLoc); } DECLARE_CUSTOM_FUNCTION(MoveTonyAndWait)(uint32 nX, uint32 nY, uint32, uint32) { - Tony->Move(RMPoint(nX,nY)); + Tony->Move(RMPoint(nX, nY)); if (!bSkipIdle) Tony->WaitForEndMovement(); } DECLARE_CUSTOM_FUNCTION(MoveTony)(uint32 nX, uint32 nY, uint32, uint32) { - Tony->Move(RMPoint(nX,nY)); + Tony->Move(RMPoint(nX, nY)); } DECLARE_CUSTOM_FUNCTION(ScrollLocation)(uint32 nX, uint32 nY, uint32 sX, uint32 sY) { @@ -1103,22 +1103,20 @@ DECLARE_CUSTOM_FUNCTION(ScrollLocation)(uint32 nX, uint32 nY, uint32 sX, uint32 pt=Loc->ScrollPosition(); - while ((lx != 0 || ly != 0) && !bSkipIdle) { - if (lx>0) { - lx -= (int32)sX; if (lx<0) lx = 0; + while ((lx != 0 || ly != 0) && !bSkipIdle) { + if (lx > 0) { + lx -= (int32)sX; if (lx < 0) lx = 0; pt.Offset((int32)sX, 0); - } else if (lx<0) { - lx += (int32)sX; if (lx>0) lx = 0; + } else if (lx < 0) { + lx += (int32)sX; if (lx > 0) lx = 0; pt.Offset(-(int32)sX, 0); } if (ly > 0) { - ly-=sY; if (ly<0) ly = 0; - pt.Offset(0,sY); - } - else if (ly<0) - { - ly+=sY; if (ly>0) ly = 0; + ly -= sY; if (ly < 0) ly = 0; + pt.Offset(0, sY); + } else if (ly < 0) { + ly += sY; if (ly > 0) ly = 0; pt.Offset(0, -(int32)sY); } @@ -1134,18 +1132,18 @@ DECLARE_CUSTOM_FUNCTION(ScrollLocation)(uint32 nX, uint32 nY, uint32 sX, uint32 DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(uint32 nX, uint32 nY, uint32 sX, uint32 sY) { int lx, ly; - RMPoint pt,startpt; - uint32 dwStartTime,dwCurTime,dwTotalTime; + RMPoint pt, startpt; + uint32 dwStartTime, dwCurTime, dwTotalTime; uint32 stepX, stepY; - int dimx,dimy; + int dimx, dimy; // Prende le coordinate di quanto scrollare lx=*((int*)&nX); ly=*((int*)&nY); - dimx=lx; - dimy=ly; - if (lx<0) dimx = -lx; - if (ly<0) dimy = -ly; + dimx = lx; + dimy = ly; + if (lx < 0) dimx = -lx; + if (ly < 0) dimy = -ly; stepX = sX; stepY = sY; @@ -1155,13 +1153,12 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(uint32 nX, uint32 nY, uint32 sX, uin dwStartTime = timeGetTime(); if (sX) - dwTotalTime = dimx*(1000/35)/sX; + dwTotalTime = dimx * (1000 / 35) / sX; else - dwTotalTime = dimy*(1000/35)/sY; + dwTotalTime = dimy * (1000 / 35) / sY; - while ((lx != 0 || ly != 0) && !bSkipIdle) - { - dwCurTime=timeGetTime()-dwStartTime; + while ((lx != 0 || ly != 0) && !bSkipIdle) { + dwCurTime = _vm->GetTime() - dwStartTime; if (dwCurTime>dwTotalTime) break; @@ -1181,28 +1178,22 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(uint32 nX, uint32 nY, uint32 sX, uin } /* - sX = stepX * (dwCurTime-dwLastTime) / (1000/35); - sY = stepY * (dwCurTime-dwLastTime) / (1000/35); + sX = stepX * (dwCurTime-dwLastTime) / (1000 / 35); + sY = stepY * (dwCurTime-dwLastTime) / (1000 / 35); - if (lx>0) - { - lx-=sX; if (lx<0) lx = 0; + if (lx > 0) { + lx-=sX; if (lx < 0) lx = 0; pt.Offset(sX,0); - } - else if (lx<0) - { - lx+=sX; if (lx>0) lx = 0; + } else if (lx < 0) { + lx+=sX; if (lx > 0) lx = 0; pt.Offset(-sX,0); } - if (ly>0) - { + if (ly > 0) { ly-=sY; if (ly<0) ly = 0; pt.Offset(0,sY); - } - else if (ly<0) - { - ly+=sY; if (ly>0) ly = 0; + } else if (ly<0) { + ly+=sY; if (ly > 0) ly = 0; pt.Offset(0,-sY); } */ @@ -1218,12 +1209,12 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(uint32 nX, uint32 nY, uint32 sX, uin // Setta la posizione finale if (sX) { - if (lx>0) + if (lx > 0) pt.x = startpt.x + dimx; else pt.x = startpt.x - dimx; } else { - if (ly>0) + if (ly > 0) pt.y = startpt.y + dimy; else pt.y = startpt.y - dimy; @@ -1254,7 +1245,7 @@ DECLARE_CUSTOM_FUNCTION(ChangeHotspot)(uint32 dwCode, uint32 nX, uint32 nY, uint curChangedHotspot++; } - Loc->GetItemFromCode(dwCode)->ChangeHotspot(RMPoint(nX,nY)); + Loc->GetItemFromCode(dwCode)->ChangeHotspot(RMPoint(nX, nY)); } @@ -1274,7 +1265,7 @@ DECLARE_CUSTOM_FUNCTION(TremaSchermo)(uint32 nScosse, uint32, uint32, uint32) { dirx = 1; diry = 1; - while (_vm->GetTime() < curTime + nScosse) { + while (_vm->GetTime() < curTime + nScosse) { WaitFrame(); Freeze(); @@ -1359,7 +1350,7 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(uint32 nChar, uint32 dwMessage, uint32 VoiceHeader *curVoc = SearchVoiceHeader(0, dwMessage); FPSFX *voice = NULL; - if (curVoc) { + if (curVoc) { // Si posiziona all'interno del database delle voci all'inizio della prima // fseek(_vm->m_vdbFP, curVoc->offset, SEEK_SET); g_system->lockMutex(vdb); @@ -1734,7 +1725,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(uint32 nPers, uint32 nMsg, uint32, ui parm = (MCharacter[nPers].curgroup * 10) + _vm->_randomSource.getRandomNumber( MCharacter[nPers].numtalks[MCharacter[nPers].curgroup] - 1) + 1; - if (MCharacter[nPers].numtexts != 0 && MCharacter[nPers].bInTexts) { + if (MCharacter[nPers].numtexts != 0 && MCharacter[nPers].bInTexts) { MCharacter[nPers].numtexts--; } else { // Cerca di eseguire la funzione custom per inizializzare la parlata @@ -1849,9 +1840,8 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(uint32 nDialog, uint32 nStartGroup, uint32, ; // Se c'e' una sola opzione, la fa automaticamente, e aspetta la prossima scelta - if (num==1) - { - mpalQueryDialogSelection(nChoice,sl[0]); + if (num == 1) { + mpalQueryDialogSelection(nChoice, sl[0]); GlobalFree(sl); continue; } diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index a0500047b6..4bfddc8d68 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -89,31 +89,24 @@ void RMFont::Load(const byte *buf, int nChars, int dimx, int dimy, uint32 palRes m_letter = new RMGfxSourceBuffer8RLEByte[nChars]; #if 0 - if (nChars == 112 && palResID == RES_F_PAL) - { + if (nChars == 112 && palResID == RES_F_PAL) { // Font parla DumpFontBMP("font_parla.bmp", buf, nChars, dimx, dimy, RMRes(palResID)); } - else if (nChars == 102 && palResID == RES_F_PAL) - { + else if (nChars == 102 && palResID == RES_F_PAL) { // Font macc DumpFontBMP("font_macc.bmp", buf, nChars, dimx, dimy, RMRes(palResID)); - } - else if (nChars == 85 && palResID == RES_F_PAL) - { + } else if (nChars == 85 && palResID == RES_F_PAL) { // Font obj DumpFontBMP("font_obj.bmp", buf, nChars, dimx, dimy, RMRes(palResID)); - } - else if (nChars == 112 && palResID == RES_F_CPAL) - { + } else if (nChars == 112 && palResID == RES_F_CPAL) { // Font credits DumpFontBMP("font_credits.bmp", buf, nChars, dimx, dimy, RMRes(palResID)); } #endif // Carichiamoce 'sto font - for (int i = 0; i < nChars; i++) - { + for (int i = 0; i < nChars; i++) { // Inizializza il buffer con le lettere m_letter[i].Init(buf + i * (dimx * dimy + 8) + 8, dimx, dimy); m_letter[i].LoadPaletteWA(palResID); @@ -261,8 +254,7 @@ void RMFontParla::Init(void) { lDefault = 13; hDefault = 18; Common::fill(&l2Table[0][0], &l2Table[0][0] + (256 * 256), '\0'); - for (i = 0; i < 256; i++) - { + for (i = 0; i < 256; i++) { cTable[i] = -1; lTable[i] = lDefault; } @@ -1042,8 +1034,7 @@ void RMFontCredits::Init(void) { hDefault=28; Common::fill(&l2Table[0][0], &l2Table[0][0] + (256 * 256), '\0'); - for (i = 0; i < 256; i++) - { + for (i = 0; i < 256; i++) { cTable[i] = -1; lTable[i] = lDefault; } @@ -1514,20 +1505,18 @@ void RMFontObj::Init(void) { hDefault = 30; Common::fill(&l2Table[0][0], &l2Table[0][0] + (256 * 256), '\0'); - for (i = 0; i < 256; i++) - { + for (i = 0; i < 256; i++) { cTable[i] = -1; lTable[i] = lDefault; } - for (i = 0; i < 26; i++) - { - cTable['A'+i] = i+0; - cTable['a'+i] = i+0; + for (i = 0; i < 26; i++) { + cTable['A' + i] = i+0; + cTable['a' + i] = i+0; } for (i = 0; i < 10; i++) - cTable['0'+i] = i+26; + cTable['0' + i] = i + 26; cTable[','] = 36; cTable[';'] = 37; @@ -2255,8 +2244,7 @@ void RMTextItemName::DoFrame(RMGfxTargetBuffer& bigBuf, RMLocation &loc, RMPoint WriteText(itemName, 1); // Se e' diverso dal precedente, e' il caso di aggiornare anche il puntatore con la WhichPointer - if (lastItem != m_item) - { + if (lastItem != m_item) { if (m_item == NULL) ptr.SetSpecialPointer(RMPointer::PTR_NONE); else { @@ -2395,7 +2383,7 @@ void RMDialogChoice::Prepare(void) { ptPos.Set(20,90); - for (i = 0; i < m_numChoices; i++) { + for (i = 0; i < m_numChoices; i++) { AddPrim(new RMGfxPrimitive(&m_drawedStrings[i], ptPos)); m_ptDrawStrings[i] = ptPos; ptPos.Offset(0,m_drawedStrings[i].Dimy() + 15); diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 00bb81dcf4..6853c53bf0 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -398,8 +398,7 @@ void RMOptionScreen::RefreshAll(void) { if (m_bNoLoadSave) AddPrim(new RMGfxPrimitive(m_HideLoadSave,RMPoint(0, 401))); - if (m_bQuitConfirm) - { + if (m_bQuitConfirm) { AddPrim(new RMGfxPrimitive(m_QuitConfirm,RMPoint(270, 200))); m_ButtonQuitYes->AddToList(*this); m_ButtonQuitNo->AddToList(*this); @@ -568,9 +567,7 @@ void RMOptionScreen::InitState(void) { if (m_bAlterGfx) { assert(m_ButtonExit == NULL); m_ButtonExit = new RMOptionButton(20025, RMPoint(561, 406)); - } - else - { + } else { assert(m_ButtonExit == NULL); m_ButtonExit = new RMOptionButton(20012, RMPoint(560, 404)); } @@ -974,12 +971,12 @@ void RMOptionScreen::DoFrame(RMInput *input) { m_ButtonSoundMenu->DoFrame(mousePos, bLeftClick, bRightClick); // bottoni con grafica - if (!m_bNoLoadSave) - { -#ifndef DEMO - bRefresh |= m_ButtonLoad->DoFrame(mousePos, bLeftClick, bRightClick); - bRefresh |= m_ButtonSave->DoFrame(mousePos, bLeftClick, bRightClick); -#endif + if (!m_bNoLoadSave) { + if (!_vm->getIsDemo()) { + bRefresh |= m_ButtonLoad->DoFrame(mousePos, bLeftClick, bRightClick); + bRefresh |= m_ButtonSave->DoFrame(mousePos, bLeftClick, bRightClick); + } + bRefresh |= m_ButtonQuit->DoFrame(mousePos, bLeftClick, bRightClick); } } @@ -1207,8 +1204,7 @@ void RMOptionScreen::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { m_FadeY += FADE_SPEED; else m_FadeY += FADE_SPEED*SYNC; - if (m_FadeY > 480) - { + if (m_FadeY > 480) { m_FadeY = 480; m_FadeStep++; } diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 1d289fbecc..a25c28a03d 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -198,13 +198,10 @@ bool RMGfxSourceBuffer::Clip2D(int &x1, int &y1, int &u, int &v, int &width, int /* OBSOLETE CODE: - if (buf == NULL) - { + if (buf == NULL) { destw=RM_SX; desth=RM_SY; - } - else - { + } else { destw = buf->Dimx(); desth = buf->Dimy(); } @@ -391,8 +388,7 @@ void RMGfxTargetBuffer::AddPrim(RMGfxPrimitive *prim) { otlist->next = NULL; } // Inserimento in testa - else if (nPrior < otlist->prim->m_task->Priority()) - { + else if (nPrior < otlist->prim->m_task->Priority()) { n->next = otlist; otlist = n; } else { @@ -452,8 +448,7 @@ int RMGfxSourceBufferPal::LoadPalette(const byte *buf) { void RMGfxSourceBufferPal::PreparePalette(void) { int i; - for (i = 0; i < 256; i++) - { + for (i = 0; i < 256; i++) { m_palFinal[i] = (((int)m_pal[i * 3 + 0] >> 3) << 10) | (((int)m_pal[i * 3 + 1] >> 3) << 5) | (((int)m_pal[i * 3 + 2] >> 3) << 0); @@ -575,16 +570,15 @@ void RMGfxSourceBuffer8::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { for (y = 0; y < height; y++) { raw = m_buf + (y + v) * m_dimx + u; - for (x = 0;xIsFlipped()) - { + if (prim->IsFlipped()) { // Annulliamo il clipping orizzontale // width = m_dimx; // x1=prim->Dst().x1; @@ -877,30 +870,26 @@ void RMGfxSourceBuffer8RLE::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim u = m_dimx - (width+u); x1 = (prim->Dst().x1 + m_dimx - 1) - u; - for (y = 0;y= nStartSkip) { + if (n >= nStartSkip) { dst += n - nStartSkip; nLength -= n - nStartSkip; if (nLength > 0) @@ -1012,8 +1001,7 @@ RLEByteDoAlpha: RLEByteDoAlpha2: if (n > nLength) n = nLength; - for (i = 0; i < n; i++) - { + for (i = 0; i < n; i++) { r=(*dst >> 10) & 0x1F; g=(*dst >> 5) & 0x1F; b=*dst & 0x1F; @@ -1022,7 +1010,7 @@ RLEByteDoAlpha2: g=(g >> 2) + (alphaG >> 1); b=(b >> 2) + (alphaB >> 1); - *dst++=(r<<10)|(g<<5)|b; + *dst ++= (r << 10) | (g << 5) | b; } nLength -= n; @@ -1233,8 +1221,7 @@ void RMGfxSourceBuffer8RLEWord::RLEDecompressLine(uint16 *dst, byte *src, int nS n = READ_LE_UINT16(src); src += 2; - if (n>=nStartSkip) - { + if (n >= nStartSkip) { src += nStartSkip; n -= nStartSkip; goto RLEWordDoCopy2; @@ -1244,8 +1231,7 @@ void RMGfxSourceBuffer8RLEWord::RLEDecompressLine(uint16 *dst, byte *src, int nS } - while (1) - { + while (1) { RLEWordDoTrasp: // Via il trasp di merda n = READ_LE_UINT16(src); @@ -1326,8 +1312,7 @@ void RMGfxSourceBuffer8RLEWord::RLEDecompressLineFlipped(uint16 *dst, byte *src, if (n == 0xFFFF) return; - if (n>=nStartSkip) - { + if (n >= nStartSkip) { dst -= n - nStartSkip; nLength -= n - nStartSkip; @@ -1344,8 +1329,7 @@ void RMGfxSourceBuffer8RLEWord::RLEDecompressLineFlipped(uint16 *dst, byte *src, n = READ_LE_UINT16(src); src += 2; - if (n>=nStartSkip) - { + if (n >= nStartSkip) { n -= nStartSkip; goto RLEWordFlippedDoAlpha2; } @@ -1440,7 +1424,7 @@ void RMGfxSourceBuffer8RLEWordAB::RLEDecompressLine(uint16 *dst, byte *src, int int i, n; int r, g, b, r2, g2, b2; - if (!bCfgTransparence) { + if (!bCfgTransparence) { RMGfxSourceBuffer8RLEWord::RLEDecompressLine(dst, src, nStartSkip, nLength); return; } @@ -1485,8 +1469,7 @@ void RMGfxSourceBuffer8RLEWordAB::RLEDecompressLine(uint16 *dst, byte *src, int n = READ_LE_UINT16(src); src += 2; - if (n >= nStartSkip) - { + if (n >= nStartSkip) { src += nStartSkip; n -= nStartSkip; goto RLEWordDoCopy2; @@ -1549,18 +1532,18 @@ RLEWordDoCopy2: if (n > nLength) n = nLength; - for (i = 0; i < n; i++) { - r=(*dst >> 10) & 0x1F; - g=(*dst >> 5) & 0x1F; - b=*dst & 0x1F; + for (i = 0; i < n; i++) { + r = (*dst >> 10) & 0x1F; + g = (*dst >> 5) & 0x1F; + b = *dst & 0x1F; - r2=(m_palFinal[*src] >> 10) & 0x1F; - g2=(m_palFinal[*src] >> 5) & 0x1F; + r2 = (m_palFinal[*src] >> 10) & 0x1F; + g2 = (m_palFinal[*src] >> 5) & 0x1F; b2 = m_palFinal[*src] & 0x1F; - r=(r >> 1) + (r2 >> 1); - g=(g >> 1) + (g2 >> 1); - b=(b >> 1) + (b2 >> 1); + r = (r >> 1) + (r2 >> 1); + g = (g >> 1) + (g2 >> 1); + b = (b >> 1) + (b2 >> 1); *dst ++= (r << 10) | (g << 5) | b; src++; diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index d4ea8ee821..77a196f853 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -139,7 +139,7 @@ void RMGfxEngine::DoFrame(bool bDrawLocation) { // Poll dei dispositivi di input m_input.Poll(); - if (m_bMustEnterMenu && bIdleExited) { + if (m_bMustEnterMenu && bIdleExited) { m_bOption = true; m_bMustEnterMenu = false; bIdleExited = false; @@ -216,8 +216,7 @@ void RMGfxEngine::DoFrame(bool bDrawLocation) { // CLICK SINISTRO // ************** - if (m_input.MouseLeftClicked() && !m_inter.Active()) - { + if (m_input.MouseLeftClicked() && !m_inter.Active()) { // Se clicko dentro un oggetto, esegui l'azione //if (m_itemName.IsItemSelected()) { @@ -383,8 +382,7 @@ void RMGfxEngine::ItemIrq(uint32 dwItem, int nPattern, int nStatus) { bool bEnableParent = false; m_ofn.hwndOwner = PreModal(); AfxUnhookWindowCreate(); - if (m_ofn.hwndOwner != NULL && ::IsWindowEnabled(m_ofn.hwndOwner)) - { + if (m_ofn.hwndOwner != NULL && ::IsWindowEnabled(m_ofn.hwndOwner)) { bEnableParent = true; ::EnableWindow(m_ofn.hwndOwner, false); } @@ -489,8 +487,7 @@ HANDLE RMGfxEngine::LoadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { continue; #if 0 // codice per dumpare una locazione in caso serva una modifica - if (nLoc == 106) - { + if (nLoc == 106) { FILE *f = fopen("loc106.lox", "wb"); fwrite(res.DataPointer(), res.Size(), 1, f); fclose(f); @@ -514,19 +511,17 @@ HANDLE RMGfxEngine::LoadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { return INVALID_HANDLE_VALUE; //mpalQueryDoAction(0,m_nCurLoc,0); } -HANDLE RMGfxEngine::UnloadLocation(bool bDoOnExit) -{ +HANDLE RMGfxEngine::UnloadLocation(bool bDoOnExit) { HANDLE h; // Scarica tutta la memoria della locazione mpalEndIdlePoll(m_nCurLoc); // On Exit? - if (bDoOnExit) - { - h=mpalQueryDoAction(1,m_nCurLoc,0); - if (h!=INVALID_HANDLE_VALUE) - WaitForSingleObject(h,INFINITE); + if (bDoOnExit) { + h = mpalQueryDoAction(1, m_nCurLoc, 0); + if (h != INVALID_HANDLE_VALUE) + WaitForSingleObject(h, INFINITE); } MainFreeze(); @@ -633,8 +628,7 @@ void RMGfxEngine::Init(/*HINSTANCE hInst*/) { //LoadLocation(40,RMPoint(233,441),RMPoint(-1,-1)); } -void RMGfxEngine::Close(void) -{ +void RMGfxEngine::Close(void) { m_bigBuf.ClearOT(); m_inter.Close(); @@ -644,68 +638,36 @@ void RMGfxEngine::Close(void) m_input.Close(); } -void RMGfxEngine::SwitchFullscreen(bool bFull) -{ +void RMGfxEngine::SwitchFullscreen(bool bFull) { m_input.SwitchFullscreen(bFull); } -void RMGfxEngine::GDIControl(bool bCon) -{ +void RMGfxEngine::GDIControl(bool bCon) { m_input.GDIControl(bCon); } -/* -void RMGfxEngine::OptionScreen(void) -{ - if (!m_bOption) - { - if (m_opt.Init(m_bigBuf)) - { - m_bOption = true; - DisableInput(); - EnableMouse(); - } - } - else - { - if (m_opt.Close()) - { - m_bOption = false; - DisableMouse(); - EnableInput(); - } - } -} -*/ - -void RMGfxEngine::EnableInput(void) -{ +void RMGfxEngine::EnableInput(void) { m_bInput = true; } -void RMGfxEngine::DisableInput(void) -{ +void RMGfxEngine::DisableInput(void) { m_bInput = false; m_inter.Reset(); } -void RMGfxEngine::EnableMouse(void) -{ +void RMGfxEngine::EnableMouse(void) { m_bAlwaysDrawMouse = true; } -void RMGfxEngine::DisableMouse(void) -{ +void RMGfxEngine::DisableMouse(void) { m_bAlwaysDrawMouse = false; } -void RMGfxEngine::Freeze(void) -{ +void RMGfxEngine::Freeze(void) { g_system->lockMutex(csMainLoop); } -void RMGfxEngine::Unfreeze(void) -{ +void RMGfxEngine::Unfreeze(void) { g_system->unlockMutex(csMainLoop); } diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp index 72c7bf06f7..25f271d7eb 100644 --- a/engines/tony/input.cpp +++ b/engines/tony/input.cpp @@ -57,8 +57,7 @@ void RMInput::DIInit(/*HINSTANCE hInst*/) { // Crea l'oggetto madre err = DirectInputCreate(hInst, DIRECTINPUT_VERSION, &m_DI, NULL); - if (err!=DI_OK) - { + if (err!=DI_OK) { MessageBox(theGame.m_wnd,"Error initializing DirectInput!","RMInput::DIInit()",MB_OK); assert(0); } @@ -66,24 +65,21 @@ void RMInput::DIInit(/*HINSTANCE hInst*/) { // Crea il device del mouse // ************************ err=m_DI->CreateDevice(GUID_SysMouse,&m_DIDMouse,NULL); - if (err!=DI_OK) - { + if (err!=DI_OK) { MessageBox(theGame.m_wnd,"Error creating mouse device!","RMInput::DIInit()",MB_OK); assert(0); } // Setta il data format err=m_DIDMouse->SetDataFormat(&c_dfDIMouse); - if (err!=DI_OK) - { + if (err!=DI_OK) { MessageBox(theGame.m_wnd,"Error setting mouse data format!","RMInput::DIInit()",MB_OK); assert(0); } // Setta il cooperative level err=m_DIDMouse->SetCooperativeLevel(theGame.m_wnd,DISCL_FOREGROUND|DISCL_NONEXCLUSIVE); - if (err!=DI_OK) - { + if (err!=DI_OK) { MessageBox(theGame.m_wnd,"Error setting cooperative level!","RMInput::DIInit()",MB_OK); assert(0); } @@ -91,24 +87,21 @@ void RMInput::DIInit(/*HINSTANCE hInst*/) { // Crea il device della tastiera // ***************************** err=m_DI->CreateDevice(GUID_SysKeyboard,&m_DIDKeyboard,NULL); - if (err!=DI_OK) - { + if (err!=DI_OK) { MessageBox(theGame.m_wnd,"Error creating keyboard device!","RMInput::DIInit()",MB_OK); assert(0); } // Setta il data format err=m_DIDKeyboard->SetDataFormat(&c_dfDIKeyboard); - if (err!=DI_OK) - { + if (err!=DI_OK) { MessageBox(theGame.m_wnd,"Error setting keyboard data format!","RMInput::DIInit()",MB_OK); assert(0); } // Setta il cooperative level err=m_DIDKeyboard->SetCooperativeLevel(theGame.m_wnd,DISCL_FOREGROUND|DISCL_NONEXCLUSIVE); - if (err!=DI_OK) - { + if (err!=DI_OK) { MessageBox(theGame.m_wnd,"Error setting cooperative level!","RMInput::DIInit()",MB_OK); assert(0); } @@ -126,22 +119,17 @@ void RMInput::SwitchFullscreen(bool bFull) { // cooperative level Unacquire(); - if (bFull) - { + if (bFull) { // Setta il cooperative level err=m_DIDMouse->SetCooperativeLevel(theGame.m_wnd,DISCL_FOREGROUND|DISCL_EXCLUSIVE); - if (err!=DI_OK) - { + if (err!=DI_OK) { MessageBox(theGame.m_wnd,"Error setting cooperative level!","RMInput::DIInit()",MB_OK); assert(0); } - } - else - { + } else { // Setta il cooperative level err=m_DIDMouse->SetCooperativeLevel(theGame.m_wnd,DISCL_FOREGROUND|DISCL_EXCLUSIVE); - if (err!=DI_OK) - { + if (err!=DI_OK) { MessageBox(theGame.m_wnd,"Error setting cooperative level!","RMInput::DIInit()",MB_OK); assert(0); } @@ -197,13 +185,10 @@ void RMInput::Unacquire(void) { void RMInput::GDIControl(bool bCon) { #ifdef REFACTOR_ME - if (bCon) - { + if (bCon) { Unacquire(); ShowCursor(true); - } - else - { + } else { ShowCursor(false); Acquire(); } @@ -220,14 +205,12 @@ void RMInput::Poll(void) { m_bLeftClickMouse=m_bLeftReleaseMouse=m_bRightClickMouse=m_bRightReleaseMouse=false; // Legge lo stato del mouse - while (1) - { + while (1) { ZeroMemory(&m_mState,sizeof(m_mState)); err=m_DIDMouse->GetDeviceState(sizeof(m_mState),&m_mState); if (err==DI_OK) break; - else if (err==DIERR_INPUTLOST || err==DIERR_NOTACQUIRED) - { + else if (err==DIERR_INPUTLOST || err==DIERR_NOTACQUIRED) { ZeroMemory(&m_mState,sizeof(m_mState)); // Se l'acquire non funziona (ad esempio, quando siamo in background, allora lasciamo perdere if (!Acquire()) @@ -242,8 +225,7 @@ void RMInput::Poll(void) { m_mY+=m_mState.lY; // Clamp dei valori sui bordi della finestra - if (m_bClampMouse) - { + if (m_bClampMouse) { if (m_mX<0) m_mX=0; if (m_mY<0) m_mY=0; if (m_mX>=640) m_mX=639; diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index 2ce88b1cec..50969afca8 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -121,8 +121,7 @@ void RMInventory::Init(void) { m_items[i].pointer=new RMGfxSourceBuffer8RLEByteAA[m_items[i].icon.NumPattern()]; - for (j=0;jlockMutex(m_csModifyInterface); Common::copy_backward(&m_inv[i + 1], &m_inv[i + 1] + (m_nInv - i), &m_inv[i]); @@ -254,15 +252,13 @@ void RMInventory::RemoveItem(int code) { } void RMInventory::AddItem(int code) { - if (code <= 10000 && code >= 10101) - { + if (code <= 10000 && code >= 10101) { // Se siamo qui, vuol dire che stiamo aggiungendo un oggetto che non dovrebbe essere // nell'inventario warning("Cannot find a valid icon for this item, and then it will not be added to the inventory"); } else { g_system->lockMutex(m_csModifyInterface); - if (m_curPos+8 == m_nInv) - { + if (m_curPos + 8 == m_nInv) { // Sfondiamo l'inventario! Attivo il pattern di lampeggio m_items[28].icon.SetPattern(2); } @@ -352,8 +348,7 @@ bool RMInventory::LeftClick(RMPoint mpos, int& nCombineObj) { } // Click sulla freccia destra - if ((m_state == OPENED) && m_bBlinkingRight) - { + if ((m_state == OPENED) && m_bBlinkingRight) { g_system->lockMutex(m_csModifyInterface); m_curPos++; @@ -408,11 +403,10 @@ void RMInventory::RightClick(RMPoint mpos) { // Apre l'interfaccina contestuale n = mpos.x / 64; - if (n > 0 && n < RM_SX / 64-1 && m_inv[n-1+m_curPos]!=0) - { - m_state=SELECTING; - miniAction=0; - m_nSelectObj=n-1; + if (n > 0 && n < RM_SX / 64 - 1 && m_inv[n - 1 + m_curPos] != 0) { + m_state = SELECTING; + miniAction = 0; + m_nSelectObj = n - 1; _vm->PlayUtilSFX(0); } diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 141b993714..3d86b78f31 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -222,20 +222,15 @@ int RMPattern::Init(RMSfx *sfx, bool bPlayP0, byte *bFlag) { // Se speed! = 0, suona solo quelli in loop for (i = 0;i < m_nSlots; i++) { if (m_slots[i].m_type == SOUND) { - if (i == 0) - { - if (sfx[m_slots[i].m_data].m_name[0]=='_') - { + if (i == 0) { + if (sfx[m_slots[i].m_data].m_name[0] == '_') { sfx[m_slots[i].m_data].SetVolume(m_slots[i].Pos().x); sfx[m_slots[i].m_data].Play(true); - } - else - { - sfx[m_slots[i].m_data].SetVolume(m_slots[i].Pos().x); + } else { + sfx[m_slots[i].m_data].SetVolume(m_slots[i].Pos().x); sfx[m_slots[i].m_data].Play(); } - } - else if (m_speed == 0) { + } else if (m_speed == 0) { if (bPlayP0) { sfx[m_slots[i].m_data].SetVolume(m_slots[i].Pos().x); sfx[m_slots[i].m_data].Play(); @@ -330,8 +325,7 @@ RMPattern::RMPattern() { } RMPattern::~RMPattern() { - if (m_slots != NULL) - { + if (m_slots != NULL) { delete[] m_slots; m_slots = NULL; } @@ -807,8 +801,7 @@ bool RMItem::GetName(RMString& name) void RMItem::Unload(void) { - if (m_patterns != NULL) - { + if (m_patterns != NULL) { delete[] m_patterns; m_patterns = NULL; } @@ -943,8 +936,7 @@ void RMWipe::DoFrame(RMGfxTargetBuffer &bigBuf) { m_bMustRegister = false; } - if (m_bFading) - { + if (m_bFading) { m_wip0r.DoFrame(&bigBuf, false); m_nFadeStep++; @@ -1671,8 +1663,7 @@ void RMBox::ReadFromStream(RMDataStream &ds) { ds >> bottom; // Adiacenza - for (i = 0; i < MAXBOXES; i++) - { + for (i = 0; i < MAXBOXES; i++) { ds >> adj[i]; } @@ -2174,7 +2165,7 @@ RMItem *RMLocation::WhichItemIsIn(RMPoint pt) { int foundSize = 0; int size; - for (int i = 0; i < m_nItems; i++) { + for (int i = 0; i < m_nItems; i++) { size = 0; if (m_items[i].IsIn(pt, &size)) { if (found == -1 || size < foundSize) { diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index b4b37e7723..74dbedd90f 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -2902,10 +2902,8 @@ case num: \ return DLG##num[nPers]; -char *GetPersonName(uint16 nDlg, int nPers) -{ - switch (nDlg) - { +char *GetPersonName(uint16 nDlg, int nPers) { + switch (nDlg) { HANDLE_DIALOG(10); HANDLE_DIALOG(51); HANDLE_DIALOG(52); diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index 493f10ef29..7809d9c080 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -126,7 +126,7 @@ void RMTony::DoFrame(RMGfxTargetBuffer *bigBuf, int curLoc) { // Esegue il movimento normale del personaggio int time = _vm->GetTime(); - do { + do { m_nTimeLastStep += (1000 / 40); RMCharacter::DoFrame(bigBuf, curLoc); @@ -155,8 +155,8 @@ void RMTony::Hide(bool bShowOmbra) { void RMTony::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { // Richiama il Draw() della classe madre se tony visibile - if (m_bShow && bDrawNow) { - if (m_bCorpoDavanti) { + if (m_bShow && bDrawNow) { + if (m_bCorpoDavanti) { prim->Dst().SetEmpty(); prim->Dst().Offset(-44, -134); if (m_bPastorella) diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index ab68030b90..a6dd20b875 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -102,8 +102,7 @@ LRESULT RMWindow::WindowProc(uint32 msg, uint16 wParam, int32 lParam) { return 0; /* case WM_KEYDOWN: - switch (wParam) - { + switch (wParam) { case '0': case '1': case '2': @@ -180,12 +179,10 @@ LRESULT RMWindow::WindowProc(uint32 msg, uint16 wParam, int32 lParam) { HANDLE hWaitFlip; bool bExitThread; -void DoFlipThread(LPDIRECTDRAWSURFACE lpDDSPrimary) -{ +void DoFlipThread(LPDIRECTDRAWSURFACE lpDDSPrimary) { bExitThread=false; - while (1) - { + while (1) { WaitForSingleObject(hWaitFlip,INFINITE); if (bExitThread) _endthread(); lpDDSPrimary->Flip(NULL,DDFLIP_WAIT); @@ -330,8 +327,7 @@ void RMWindow::CreateBWPrecalcTable(void) { CLAMP(shiftG, 0, 15); CLAMP(shiftB, 0, 15); - for (i = 0;i<0x10000;i++) - { + for (i = 0; i < 0x10000; i++) { r=(i >> shiftR) & 0x1F; g=(i >> shiftG) & 0x1F; b=(i >> shiftB) & 0x1F; @@ -412,8 +408,7 @@ void RMWindow::DDInit(void) { #endif /* - if (!ISMODE1() && !ISMODE2() && !ISMODE3() && !ISMODE4()) - { + if (!ISMODE1() && !ISMODE2() && !ISMODE3() && !ISMODE4()) { RMString str; str.Format("Graphic mode not supported: %04x %04x %04x",mskRed,mskGreen,mskBlue); MessageBox(m_hWnd,str,"Debug",MB_OK); -- cgit v1.2.3 From 5b2c69b1f291b1ee3d7f3be4ffd40e427b437ac6 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 4 May 2012 00:11:38 +1000 Subject: TONY: Implemented some missing and incorrect init code --- engines/tony/custom.cpp | 7 ++-- engines/tony/font.cpp | 6 ++-- engines/tony/gfxcore.cpp | 5 ++- engines/tony/gfxengine.cpp | 3 ++ engines/tony/inventory.cpp | 2 ++ engines/tony/loc.cpp | 4 +-- engines/tony/mpal/mpal.cpp | 8 ++--- engines/tony/tony.cpp | 82 ++++++++++++++++++++++++++++++++++++++++------ engines/tony/tony.h | 33 ++++++++++++------- 9 files changed, 114 insertions(+), 36 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 209fc11212..6f6e7a1534 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -2447,13 +2447,14 @@ void SetupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation EnableGUI = MainEnableGUI; SetPalesati = MainSetPalesati; - g_system->lockMutex(vdb); + vdb = g_system->createMutex(); bAlwaysDisplay = false; int i; -/* + for (i = 0;i < 10; i++) - InitializeCriticalSection(&cs[i]); + cs[i] = g_system->createMutex(); +/* for (i = 0;i < 10; i++) mut[i] = CreateMutex(NULL, false, NULL); */ diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 4bfddc8d68..ec5a78731b 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -702,7 +702,7 @@ void RMFontMacc::Init(void) { cTable[':'] = 80; cTable['-'] = 81; cTable['<'] = 82; - cTable[' > '] = 83; + cTable['>'] = 83; cTable['/'] = 84; cTable[''] = 85; cTable[''] = 86; @@ -1541,7 +1541,7 @@ void RMFontObj::Init(void) { cTable['^'] = 56; cTable['*'] = 57; cTable['<'] = 58; - cTable[' > '] = 59; + cTable['>'] = 59; cTable[''] = 60; cTable[''] = 61; cTable[''] = 62; @@ -1847,6 +1847,8 @@ void RMText::WriteText(RMString text, int nFont, int *time) { m_fonts[1] = new RMFontObj; m_fonts[1]->Init(); m_fonts[2] = new RMFontMacc; m_fonts[2]->Init(); m_fonts[3] = new RMFontCredits; m_fonts[3]->Init(); + + m_cs = g_system->createMutex(); } g_system->lockMutex(m_cs); diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index a25c28a03d..b5dc79687a 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -290,15 +290,14 @@ RMGfxClearTask RMGfxTargetBuffer::taskClear; RMGfxTargetBuffer::RMGfxTargetBuffer() { otlist = NULL; -// InitializeCriticalSection(&csModifyingOT); + csModifyingOT = g_system->createMutex(); } RMGfxTargetBuffer::~RMGfxTargetBuffer() { ClearOT(); -// DeleteCriticalSection(&csModifyingOT); + g_system->deleteMutex(csModifyingOT); } - void RMGfxTargetBuffer::ClearOT(void) { OTList *cur, *n; diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 77a196f853..940fb2afe8 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -572,6 +572,9 @@ void RMGfxEngine::Init(/*HINSTANCE hInst*/) { m_bWiping = false; m_hWipeEvent = CreateEvent(NULL, false, false, NULL); + // Crea l'evento di freeze + csMainLoop = g_system->createMutex(); + // Inizializza la funzione di IRQ di Item per l'MPAL ItemIrq((uint32)-1, (uint32)this, 0); mpalInstallItemIrq(ItemIrq); diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index 50969afca8..1442708d56 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -62,10 +62,12 @@ RMInventory::RMInventory() { m_items = NULL; m_state = CLOSED; m_bCombining = false; + m_csModifyInterface = g_system->createMutex(); } RMInventory::~RMInventory() { Close(); + g_system->deleteMutex(m_csModifyInterface); } bool RMInventory::CheckPointInside(RMPoint &pt) { diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 3d86b78f31..c6a54aa1ef 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -1628,7 +1628,7 @@ bool RMCharacter::RemoveThis(void) { } RMCharacter::RMCharacter() { -// InitializeCriticalSection(&csMove); + csMove = g_system->createMutex(); hEndOfPath = CreateEvent(NULL, false, false, NULL); minpath = 0; curSpeed = 3; @@ -1639,7 +1639,7 @@ RMCharacter::RMCharacter() { } RMCharacter::~RMCharacter() { -// DeleteCriticalSection(&csMove); + g_system->deleteMutex(csMove); CloseHandle(hEndOfPath); } diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 74dbedd90f..610dd59984 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -626,13 +626,13 @@ HGLOBAL resLoad(uint32 dwId) { uint32 nSizeComp, nSizeDecomp; byte *temp, *buf; - for (i=0;iSetLoop(false); + break; + + case 1: + m_sfx[nChannel]->SetLoop(true); + break; + } + + m_sfx[nChannel]->Play(); } void TonyEngine::StopMusic(int nChannel) { - warning("TonyEngine::StopMusic"); + warning("TODO TonyEngine::StopMusic"); } void TonyEngine::StopSFX(int nChannel) { - warning("TonyEngine::StopSFX"); + warning("TODO TonyEngine::StopSFX"); } void TonyEngine::PlayUtilSFX(int nChannel, int nFX) { - warning("TonyEngine::PlayUtilSFX"); + warning("TODO TonyEngine::PlayUtilSFX"); } void TonyEngine::StopUtilSFX(int nChannel) { - warning("TonyEngine::StopUtilSFX"); + warning("TODO TonyEngine::StopUtilSFX"); } void TonyEngine::PreloadSFX(int nChannel, char* fn) { - warning("TonyEngine::PreloadSFX"); + if (m_sfx[nChannel] != NULL) { + m_sfx[nChannel]->Stop(); + m_sfx[nChannel]->Release(); + m_sfx[nChannel] = NULL; + } + + _theSound.CreateSfx(&m_sfx[nChannel]); + +/* + // Mette il path giusto + GetDataDirectory(DD_UTILSFX, path_buffer); + _splitpath(path_buffer,drive,dir,NULL,NULL); + _splitpath(fn,NULL,NULL,fname,ext); + _makepath(path_buffer,drive,dir,fname,ext); + + m_sfx[nChannel]->LoadFile(path_buffer, FPCODEC_ADPCM); +*/ + m_sfx[nChannel]->LoadFile(fn, FPCODEC_ADPCM); } FPSFX *TonyEngine::CreateSFX(byte *buf) { - warning("TonyEngine::CreateSFX"); - return NULL; + FPSFX *sfx; + + _theSound.CreateSfx(&sfx); + sfx->LoadFile(buf,FPCODEC_WAV); + return sfx; } void TonyEngine::PreloadUtilSFX(int nChannel, char *fn) { @@ -185,11 +218,40 @@ void TonyEngine::UnloadAllUtilSFX(void) { } void TonyEngine::InitMusic() { - warning("TODO: TonyEngine::InitMusic"); + int i; + + _theSound.Init(/*m_wnd*/); + _theSound.SetMasterVolume(63); + + for (i = 0; i < 6; i++) + _theSound.CreateStream(&m_stream[i]); + + for (i = 0; i < MAX_SFX_CHANNELS; i++) { + m_sfx[i] = m_utilSfx[i] = NULL; + } + + // Crea la critical section per la musica + csMusic = g_system->createMutex(); + + // Carica effetti sonori +// PreloadUtilSFX(0,"AccendiOpzione.ADP"); +// PreloadUtilSFX(1,"ApriInterfaccia.ADP"); + + PreloadUtilSFX(0, "U01.ADP"); // invertiti!! + PreloadUtilSFX(1, "U02.ADP"); } void TonyEngine::CloseMusic() { - warning("TODO: TonyEngine::CloseMusic"); + for (int i = 0; i < 6; i++) { + m_stream[i]->Stop(); + m_stream[i]->UnloadFile(); + m_stream[i]->Release(); + } + + g_system->deleteMutex(csMusic); + + UnloadAllSFX(); + UnloadAllUtilSFX(); } void TonyEngine::PauseSound(bool bPause) { diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 06fe357c0d..1c08028b91 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -63,6 +63,8 @@ enum { struct TonyGameDescription; +#define MAX_SFX_CHANNELS 32 + struct VoiceHeader { int offset; int code; @@ -91,18 +93,6 @@ public: Common::File _vdbFP; Common::Array _voices; FPSOUND _theSound; - // Bounding box list manager - RMGameBoxes _theBoxes; - RMGfxEngine _theEngine; - RMWindow m_wnd; - bool m_bPaused; - bool m_bDrawLocation; - int m_startTime; - uint16 *m_curThumbnail; - - bool m_bQuitNow; - bool m_bTimeFreezed; - int m_nTimeFreezed; enum DATADIR { DD_BASE = 1, @@ -114,6 +104,25 @@ public: DD_VOICES, DD_BASE2 }; + + FPSTREAM *m_stream[6]; + FPSFX *m_sfx[MAX_SFX_CHANNELS]; + FPSFX *m_utilSfx[MAX_SFX_CHANNELS]; + RMGfxEngine theEngine; + RMFont *fonts[2]; + bool m_bPaused; + bool m_bDrawLocation; + int m_startTime; + uint16 *m_curThumbnail; + + // Bounding box list manager + RMGameBoxes _theBoxes; + RMGfxEngine _theEngine; + RMWindow m_wnd; + + bool m_bQuitNow; + bool m_bTimeFreezed; + int m_nTimeFreezed; public: TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc); virtual ~TonyEngine(); -- cgit v1.2.3 From a75b873fdedd2167b4b6a47b1dd2988ce2e5d11c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 4 May 2012 21:30:45 +1000 Subject: TONY: Added virtual destructors to classes using virtual methods --- engines/tony/custom.h | 10 +--------- engines/tony/font.h | 4 ++-- engines/tony/gfxcore.h | 8 ++++++++ engines/tony/tony.h | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.h b/engines/tony/custom.h index ee85c8dd41..57d726f70e 100644 --- a/engines/tony/custom.h +++ b/engines/tony/custom.h @@ -44,13 +44,7 @@ * * * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * * * - ************************************************************************** - -/** RCS - * - * $Id: $ - * - **/ + **************************************************************************/ #ifndef TONY_CUSTOM_H #define TONY_CUSTOM_H @@ -67,8 +61,6 @@ using namespace MPAL; typedef uint32 HWND; -typedef void __declspec(dllexport) (*INIT_CUSTOM_FUNCTION_TYPE)(HWND, LPCUSTOMFUNCTION *); - #define INIT_CUSTOM_FUNCTION MapCustomFunctions #define INIT_CUSTOM_FUNCTION_STRING "MapCustomFunctions" diff --git a/engines/tony/font.h b/engines/tony/font.h index a8a9aabb19..33332db9f0 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -78,8 +78,8 @@ private: public: RMFontPrimitive() : RMGfxPrimitive() {} RMFontPrimitive(RMGfxTask *task) : RMGfxPrimitive(task) {} - - virtual RMGfxPrimitive* Duplicate() { return new RMFontPrimitive(*this); } + virtual ~RMFontPrimitive() { } + virtual RMGfxPrimitive *Duplicate() { return new RMFontPrimitive(*this); } int m_nChar; }; diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index 708e3adfa8..0f2c2553ec 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -152,6 +152,8 @@ public: m_task = task; m_dst.TopLeft() = dst; m_src.SetEmpty(); m_bFlag = 0; } + virtual ~RMGfxPrimitive() { } + void SetFlag(byte bFlag) { m_bFlag=bFlag; } void SetTask(RMGfxTask *task) { m_task = task; } void SetSrc(const RMRect &src) { m_src = src; } @@ -185,6 +187,7 @@ protected: public: // Costruttore standard RMGfxTask(); + virtual ~RMGfxTask() { } virtual int Priority(); virtual void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) = 0; @@ -201,6 +204,7 @@ public: */ class RMGfxTaskSetPrior : public RMGfxTask { public: + virtual ~RMGfxTaskSetPrior() { } void SetPriority(int nPrior); }; @@ -210,6 +214,8 @@ public: */ class RMGfxClearTask : public RMGfxTask { public: + virtual ~RMGfxClearTask() { } + int Priority(); void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); bool RemoveThis(); @@ -224,6 +230,8 @@ protected: uint16 wFillColor; public: + virtual ~RMGfxBox() { } + void SetColor(byte r, byte g, byte b); void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); bool RemoveThis(); diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 1c08028b91..95cd4fbbdc 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -33,7 +33,7 @@ #include "tony/mpal/mpal.h" #include "tony/mpal/memory.h" -#include "tony/gfxEngine.h" +#include "tony/gfxengine.h" #include "tony/loc.h" #include "tony/utils.h" #include "tony/window.h" -- cgit v1.2.3 From 557c43c2dbd6d830332be8c8b69c7660d53d665f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 4 May 2012 21:40:44 +1000 Subject: TONY: Converted anonymous structs to have explicit names --- engines/tony/adv.h | 7 +++++++ engines/tony/custom.cpp | 23 +++++++++++++---------- engines/tony/game.cpp | 8 ++++---- engines/tony/window.cpp | 8 ++++---- engines/tony/window.h | 2 +- 5 files changed, 29 insertions(+), 19 deletions(-) (limited to 'engines') diff --git a/engines/tony/adv.h b/engines/tony/adv.h index 9a5ecd5072..bcf62a0c24 100644 --- a/engines/tony/adv.h +++ b/engines/tony/adv.h @@ -66,6 +66,13 @@ namespace Tony { #define RM_SKIPY ((RM_BBY - RM_SY) / 2) #define RM_SKIPX 0 +// Name lengths +// FIXME: Some of these can likely be removed when refactoring is completed +#define MAX_DRIVE 10 +#define MAX_DIR 255 +#define MAX_FNAME 100 +#define MAX_EXT 10 + // Tony's actions enum RMTonyAction { TA_GOTO = 0, diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 6f6e7a1534..d710667db6 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -110,7 +110,7 @@ int tappeti[200]; #define T_MARE 6 #define T_MAREMETA 7 -char* tappetiFile[] = { +const char *tappetiFile[] = { "None", "1.ADP", // Grilli.WAV "2.ADP", // Grilli-Ovattati.WAV @@ -121,7 +121,7 @@ char* tappetiFile[] = { "6.ADP" // Mare1.WAV met volume }; -struct { +struct CharacterStruct { uint32 code; RMItem *item; byte r, g, b; @@ -155,9 +155,10 @@ struct { endtalkpattern = f->readUint32LE(); numtexts = f->readUint32LE(); } -} Character[16]; +}; +CharacterStruct Character[16]; -struct { +struct MCharacterStruct { uint32 code; RMItem *item; byte r, g, b; @@ -202,7 +203,8 @@ struct { curTalk = f->readUint32LE(); bAlwaysBack = f->readByte(); } -} MCharacter[10]; +}; +MCharacterStruct MCharacter[10]; bool IsMChar[16]; @@ -216,7 +218,7 @@ bool bTonyIsSpeaking = false; int curChangedHotspot = 0; -struct { +struct ChangedHotspotStruct { uint32 dwCode; uint32 nX, nY; @@ -230,7 +232,8 @@ struct { nX = f->readUint32LE(); nY = f->readUint32LE(); } -} ChangedHotspot[256]; +}; +ChangedHotspotStruct ChangedHotspot[256]; void ReapplyChangedHotspot(void) { int i; @@ -2015,11 +2018,11 @@ DECLARE_CUSTOM_FUNCTION(DemuteStacchetto)(uint32, uint32, uint32, uint32) { _vm->SetMusicVolume(2, 64); } -struct { +struct MusicFileEntry { const char *name; int sync; -} musicFiles[] = -{ +}; +const MusicFileEntry musicFiles[] = { /* { "PREGAME1.ADP", 0 }, { "SONO1.ADP", 0 }, { "SONO2.ADP", 0 }, { "SONO3.ADP", 0 }, diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 6853c53bf0..a1737cb089 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -93,10 +93,10 @@ bool bPatIrqFreeze; /****************************************/ static char path_buffer[_MAX_PATH]; -static char drive[_MAX_DRIVE]; -static char dir[_MAX_DIR]; -static char fname[_MAX_FNAME]; -static char ext[_MAX_EXT]; +static char drive[MAX_DRIVE]; +static char dir[MAX_DIR]; +static char fname[MAX_FNAME]; +static char ext[MAX_EXT]; HANDLE MainLoadLocation(int nLoc, RMPoint pt, RMPoint start) { return _vm->GetEngine()->LoadLocation(nLoc, pt,start); diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index a6dd20b875..248542ada6 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -1069,10 +1069,10 @@ DOFRAMERATE: * Metodi di RMSnapshot \****************************************************************************/ -char RMSnapshot::bufDrive[_MAX_DRIVE]; -char RMSnapshot::bufDir[_MAX_DIR]; -char RMSnapshot::bufName[_MAX_FNAME]; -char RMSnapshot::bufExt[_MAX_EXT]; +char RMSnapshot::bufDrive[MAX_DRIVE]; +char RMSnapshot::bufDir[MAX_DIR]; +char RMSnapshot::bufName[MAX_FNAME]; +char RMSnapshot::bufExt[MAX_EXT]; char RMSnapshot::filename[512]; byte RMSnapshot::rgb[RM_SX * RM_SY * 3]; diff --git a/engines/tony/window.h b/engines/tony/window.h index 25aef5c619..da8c5dc824 100644 --- a/engines/tony/window.h +++ b/engines/tony/window.h @@ -61,7 +61,7 @@ struct DDSURFACEDESC { class RMSnapshot { private: // Buffer per la creazione dei path - static char bufDrive[_MAX_DRIVE], bufDir[_MAX_DIR], bufName[_MAX_FNAME], bufExt[_MAX_EXT]; + static char bufDrive[MAX_DRIVE], bufDir[MAX_DIR], bufName[MAX_FNAME], bufExt[MAX_EXT]; static char filename[512]; // Buffer per la conversione a RGB -- cgit v1.2.3 From 5498f9a0b770ed8985ace1da232b505c650d70a7 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 4 May 2012 22:03:03 +1000 Subject: TONY: Fix invalid casts and remove some unused variables --- engines/tony/adv.h | 1 + engines/tony/game.cpp | 8 ++------ engines/tony/tony.cpp | 2 +- engines/tony/utils.cpp | 9 +++------ engines/tony/utils.h | 2 +- 5 files changed, 8 insertions(+), 14 deletions(-) (limited to 'engines') diff --git a/engines/tony/adv.h b/engines/tony/adv.h index bcf62a0c24..6d675c2bbe 100644 --- a/engines/tony/adv.h +++ b/engines/tony/adv.h @@ -70,6 +70,7 @@ namespace Tony { // FIXME: Some of these can likely be removed when refactoring is completed #define MAX_DRIVE 10 #define MAX_DIR 255 +#define MAX_PATH 255 #define MAX_FNAME 100 #define MAX_EXT 10 diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index a1737cb089..884dda5587 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -92,11 +92,7 @@ bool bPatIrqFreeze; /* Funzioni globali per la DLL Custom */ /****************************************/ -static char path_buffer[_MAX_PATH]; -static char drive[MAX_DRIVE]; -static char dir[MAX_DIR]; -static char fname[MAX_FNAME]; -static char ext[MAX_EXT]; +static char path_buffer[MAX_PATH]; HANDLE MainLoadLocation(int nLoc, RMPoint pt, RMPoint start) { return _vm->GetEngine()->LoadLocation(nLoc, pt,start); @@ -494,7 +490,7 @@ void RMOptionScreen::RefreshAll(void) { if (m_statePos == 0 && i == 0) s.Format("Autosave"); else - s.Format("%02d)%s", m_statePos + i, m_curThumbName[i]); + s.Format("%02d)%s", m_statePos + i, (const char *)m_curThumbName[i]); } num[i] = new RMText; diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 9dda1b9d4d..1415b86ef8 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -130,7 +130,7 @@ void TonyEngine::GUIError(const Common::String &msg) { GUIErrorMessage(msg); } -char nextMusic[_MAX_PATH]; +char nextMusic[MAX_PATH]; bool nextLoop; int nextChannel; int nextSync; diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index 69ad5633d7..7a750c2975 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -393,17 +393,14 @@ RMDataStream &operator>>(RMDataStream &df, RMString &var) { /** * Formats a string */ -void RMString::Format(char* str, ...) { - warning("TODO: Refactor RMString::Format if needed"); - /* +void RMString::Format(const char *str, ...) { static char buf[2048]; va_list argList; - va_start(argList,str); - wvsprintf(buf,str,argList); + va_start(argList, str); + vsprintf(buf, str, argList); va_end(argList); *this = buf; -*/ } /****************************************************************************\ diff --git a/engines/tony/utils.h b/engines/tony/utils.h index 0ce4e83f27..c8ffe062ea 100644 --- a/engines/tony/utils.h +++ b/engines/tony/utils.h @@ -219,7 +219,7 @@ public: friend RMDataStream& operator>>(RMDataStream& df, RMString &var); // Formattazione di stringa - void Format(char *str, ...); + void Format(const char *str, ...); private: void Resize(int size, bool bMantain = false); -- cgit v1.2.3 From 9482eac1f2fc7202eb4aaa72f63552bd35f5c66e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 4 May 2012 22:09:24 +1000 Subject: TONY: Some formatting fixes --- engines/tony/gfxcore.cpp | 5 +--- engines/tony/gfxengine.cpp | 4 +-- engines/tony/loc.cpp | 2 -- engines/tony/mpal/mpal.cpp | 70 +++++++++++++++++++++++----------------------- engines/tony/mpal/mpal.h | 2 +- 5 files changed, 39 insertions(+), 44 deletions(-) (limited to 'engines') diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index b5dc79687a..9f725f2523 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -45,14 +45,11 @@ * * **************************************************************************/ -#include "tony/gfxEngine.h" +#include "tony/gfxengine.h" #include "tony/mpal/mpalutils.h" namespace Tony { -static char rcsid[] = "$Id: $"; - - /****************************************************************************\ * Metodi di RMGfxTask \****************************************************************************/ diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 940fb2afe8..dd557efafd 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -49,7 +49,7 @@ #include "tony/mpal/lzo.h" #include "tony/mpal/mpalutils.h" #include "tony/custom.h" -#include "tony/gfxEngine.h" +#include "tony/gfxengine.h" #include "tony/tony.h" namespace Tony { @@ -934,7 +934,7 @@ void RMGfxEngine::LoadState(const char *fn) { // Le versioni vecchie necessitano di On enter if (ver < 5) - mpalQueryDoAction(0,loc,0); + mpalQueryDoAction(0, loc, 0); else { // In quelle nuove, ci basta resettare gli mcode MCharResetCodes(); diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index c6a54aa1ef..84e56a108d 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -55,8 +55,6 @@ namespace Tony { using namespace ::Tony::MPAL; -static char rcsid[] = "$Id: $"; - extern bool bSkipSfxNoLoop; diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 610dd59984..6ec08f9d26 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -868,9 +868,9 @@ void PASCAL ScriptThread(LPMPALSCRIPT s) { // Dorme il tempo necessario per arrivare al momento successivo if (s->Moment[i].dwTime==-1) { WaitForMultipleObjects(numHandles,cfHandles,true,INFINITE); - dwStartTime=timeGetTime(); + dwStartTime = timeGetTime(); } else { - dwCurTime=timeGetTime(); + dwCurTime = timeGetTime(); if (dwCurTime < dwStartTime+(s->Moment[i].dwTime*100)) { // warning("PlayScript(): Sleeping %lums\n",dwStartTime+(s->Moment[i].dwTime*100)-dwCurTime); Sleep(dwStartTime+(s->Moment[i].dwTime*100)-dwCurTime); @@ -1043,23 +1043,23 @@ void PASCAL LocationPollThread(uint32 id) { /* Cerchiamo gli items della locazione senza idle actions e li eliminiamo dalla lista */ LockItems(); - nIdleActions=0; - nRealItems=0; - for (i=0;inActions;j++) - if (curItem->Action[j].num==0xFF) + for (j = 0; j < curItem->nActions; j++) + if (curItem->Action[j].num == 0xFF) k++; - nIdleActions+=k; + nIdleActions += k; - if (k==0) + if (k == 0) /* Possiamo eliminare questo item dalla lista */ il[i] = (uint32)NULL; else @@ -1068,28 +1068,28 @@ void PASCAL LocationPollThread(uint32 id) { UnlockItems(); /* Se non e' rimasto nessuno possiamo uscire */ - if (nRealItems==0) { + if (nRealItems == 0) { GlobalFree(il); ExitThread(0); // _endthread(); } - MyThreads=(MYTHREAD*)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,nRealItems*sizeof(MYTHREAD)); - if (MyThreads==NULL) { + MyThreads=(MYTHREAD *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, nRealItems * sizeof(MYTHREAD)); + if (MyThreads == NULL) { GlobalFree(il); ExitThread(0); // _endthread(); } /* Inizializziamo le routine random */ - //curTime=timeGetTime(); + //curTime = timeGetTime(); //srand(curTime); /* Abbiamo appurato che esiste almeno un item che contiene idle actions. Ora creaiamo le copie speculari delle idle actions */ - MyActions=(MYACTION*)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,nIdleActions*sizeof(MYACTION)); - if (MyActions==NULL) { + MyActions = (MYACTION *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, nIdleActions * sizeof(MYACTION)); + if (MyActions == NULL) { GlobalFree(MyThreads); GlobalFree(il); ExitThread(0); @@ -1097,27 +1097,27 @@ void PASCAL LocationPollThread(uint32 id) { } LockItems(); - k=0; + k = 0; - for (i=0;inActions;j++) - if (curItem->Action[j].num==0xFF) { - MyActions[k].nItem=il[i]; - MyActions[k].nAction=j; + for (j = 0; j < curItem->nActions; j++) + if (curItem->Action[j].num == 0xFF) { + MyActions[k].nItem = il[i]; + MyActions[k].nAction = j; - MyActions[k].wTime=curItem->Action[j].wTime; - MyActions[k].perc=curItem->Action[j].perc; - MyActions[k].when=curItem->Action[j].when; - MyActions[k].nCmds=curItem->Action[j].nCmds; + MyActions[k].wTime = curItem->Action[j].wTime; + MyActions[k].perc = curItem->Action[j].perc; + MyActions[k].when = curItem->Action[j].when; + MyActions[k].nCmds = curItem->Action[j].nCmds; CopyMemory(MyActions[k].CmdNum, curItem->Action[j].CmdNum, - MAX_COMMANDS_PER_ACTION*sizeof(uint16)); + MAX_COMMANDS_PER_ACTION * sizeof(uint16)); - MyActions[k].dwLastTime=timeGetTime(); + MyActions[k].dwLastTime = timeGetTime(); k++; } } @@ -1132,7 +1132,7 @@ void PASCAL LocationPollThread(uint32 id) { while (1) { /* Cerchiamo tra tutte le idle actions quella a cui manca meno tempo per l'esecuzione */ - curTime=timeGetTime(); + curTime = timeGetTime(); dwSleepTime=(uint32)-1L; for (k=0;kAction[0].nCmds=curItem->Action[j].nCmds; +// newItem->Action[0].nCmds = curItem->Action[j].nCmds; // CopyMemory(newItem->Action[0].CmdNum,curItem->Action[j].CmdNum,newItem->Action[0].nCmds*sizeof(newItem->Action[0].CmdNum[0])); newItem->dwRes=j; diff --git a/engines/tony/mpal/mpal.h b/engines/tony/mpal/mpal.h index 70b49a1fd9..26c4283018 100644 --- a/engines/tony/mpal/mpal.h +++ b/engines/tony/mpal/mpal.h @@ -271,7 +271,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; \****************************************************************************/ #define mpalQueryGlobalVar(lpszVarName) \ - (uint32)mpalQuery(MPQ_GLOBAL_VAR,(LPSTR)(lpszVarName)) + (uint32)mpalQuery(MPQ_GLOBAL_VAR,(const char *)(lpszVarName)) -- cgit v1.2.3 From 23cd3b7730c292539649578d1aea373812e6b4ce Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 4 May 2012 22:28:51 +1000 Subject: TONY: Fixed many warnings identified by gcc --- engines/tony/game.cpp | 2 - engines/tony/input.cpp | 5 +- engines/tony/inventory.cpp | 2 +- engines/tony/mpal/loadmpc.cpp | 8 +- engines/tony/mpal/mpal.cpp | 609 +++++++++++++++++++++--------------------- engines/tony/mpal/mpal.h | 2 +- engines/tony/sound.cpp | 6 +- engines/tony/sound.h | 2 +- engines/tony/tony.cpp | 4 +- engines/tony/tony.h | 6 +- engines/tony/tonychar.cpp | 12 + 11 files changed, 331 insertions(+), 327 deletions(-) (limited to 'engines') diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 884dda5587..b4b4253d08 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -92,8 +92,6 @@ bool bPatIrqFreeze; /* Funzioni globali per la DLL Custom */ /****************************************/ -static char path_buffer[MAX_PATH]; - HANDLE MainLoadLocation(int nLoc, RMPoint pt, RMPoint start) { return _vm->GetEngine()->LoadLocation(nLoc, pt,start); } diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp index 25f271d7eb..09b15fa127 100644 --- a/engines/tony/input.cpp +++ b/engines/tony/input.cpp @@ -45,7 +45,7 @@ * * **************************************************************************/ -#include "tony/gfxEngine.h" +#include "tony/gfxengine.h" namespace Tony { @@ -137,8 +137,7 @@ void RMInput::SwitchFullscreen(bool bFull) { #endif } -void RMInput::DIClose(void) -{ +void RMInput::DIClose(void) { #ifdef REFACTOR_ME DIRELEASE(m_DIDMouse); DIRELEASE(m_DI); diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index 1442708d56..ade9c0eb34 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -272,7 +272,7 @@ void RMInventory::AddItem(int code) { ClearOT(); g_system->unlockMutex(m_csModifyInterface); } -}; +} void RMInventory::ChangeItemStatus(uint32 code, uint32 dwStatus) { if (code <= 10000 && code >= 10101) { diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index ff94dbae8d..484f1ad2a0 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -527,16 +527,10 @@ static byte *ParseLocation(byte *lpBuf, LPMPALLOCATION lpmlLocation) { \****************************************************************************/ bool ParseMpc(byte *lpBuf) { - uint16 i,j; + uint16 i, j; uint16 wLen; byte *lpTemp, *lpTemp2; - // Oggetti dummy. Definiti static per evitare stack overflow - static MPALITEM dummyitem; - static MPALLOCATION dummylocation; - static MPALSCRIPT dummyscript; - static MPALDIALOG dummydialog; - /* 1. Variabili */ if (lpBuf[0]!='V' || lpBuf[1]!='A' || lpBuf[2]!='R' || lpBuf[3]!='S') return false; diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 6ec08f9d26..d767dbe381 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -356,20 +356,20 @@ int32 varGetValue(const char *lpszVarName) { \****************************************************************************/ void varSetValue(const char *lpszVarName, int32 val) { - int i; + uint i; LPMPALVAR v=lpmvVars; for (i=0;ilpszVarName)==0) { v->dwVal=val; - if (lpiifCustom!=NULL && strncmp(v->lpszVarName,"Pattern.",8)==0) { - i=0; - sscanf(v->lpszVarName,"Pattern.%u",&i); + if (lpiifCustom!=NULL && strncmp(v->lpszVarName,"Pattern.",8) == 0) { + i = 0; + sscanf(v->lpszVarName, "Pattern.%u", &i); lpiifCustom(i,val,-1); - } else if (lpiifCustom!=NULL && strncmp(v->lpszVarName,"Status.",7)==0) { - i=0; - sscanf(v->lpszVarName,"Status.%u",&i); - lpiifCustom(i,-1,val); + } else if (lpiifCustom!=NULL && strncmp(v->lpszVarName, "Status.", 7) == 0) { + i = 0; + sscanf(v->lpszVarName,"Status.%u", &i); + lpiifCustom(i, -1, val); } return; } @@ -1648,7 +1648,7 @@ bool DoSelection(uint32 i, uint32 dwData) { /****************************************************************************\ * -* Function: bool mpalInit(char * lpszMpcFileName, char * lpszMprFileName, +* Function: bool mpalInit(LPSTR lpszMpcFileName, LPSTR lpszMprFileName, * LPLPCUSTOMFUNCTION lplpcfArray); * * Description: Inizializza la libreria MPAL, e apre un file .MPC, che @@ -1665,7 +1665,7 @@ bool DoSelection(uint32 i, uint32 dwData) { * \****************************************************************************/ -bool mpalInit(char * lpszMpcFileName, char * lpszMprFileName, LPLPCUSTOMFUNCTION lplpcfArray) { +bool mpalInit(const char * lpszMpcFileName, const char * lpszMprFileName, LPLPCUSTOMFUNCTION lplpcfArray) { Common::File hMpc; byte buf[5]; uint32 nBytesRead; @@ -2281,11 +2281,12 @@ int mpalLoadState(byte *buf) { bool bDontOutput; -struct { +struct MsgCommentsStruct { uint16 wStart; uint16 wEnd; char *pComment; -} MsgComments[] = { +}; +MsgCommentsStruct MsgComments[] = { { 10, 16, "###" }, { 560, 563, "@@@ BUTCH & DUDLEY:" }, { 551, 553, "@@@ JACK'S LETTER (JACK'S VOICE):" }, @@ -2584,310 +2585,310 @@ void mpalDumpOthers(void) { #if 0 // English names -char *DLG10[] = { "Tony", NULL }; -char *DLG51[] = { "Tony", "Butch", "Dudley" }; -char *DLG52[] = { "Tony", NULL }; -char *DLG61[] = { "Tony", "Old lady 1", NULL }; -char *DLG71[] = { "Tony", "Timothy", "Convict", NULL, NULL, "Jack (with microphone)", "Old lady 1", NULL }; -char *DLG90[] = { "Tony", "Bearded lady", NULL }; -char *DLG110[] = { "Tony", "Lorenz", NULL }; -char *DLG111[] = { "Tony", "Lorenz", NULL }; -char *DLG130[] = { "Tony", "Piranha", NULL }; -char *DLG150[] = { "Tony", "Rufus", "Snowman", NULL }; -char *DLG151[] = { "Tony", "Rufus", "Snowman", NULL }; -char *DLG152[] = { "Tony", "Rufus", "Snowman", NULL }; -char *DLG153[] = { "Tony", "Rufus", "Snowman", NULL }; -char *DLG154[] = { "Tony", "Rufus", "Snowman", NULL }; -char *DLG160[] = { "Tony", "Shmiley", NULL }; -char *DLG161[] = { "Tony", "Shmiley", NULL }; -char *DLG162[] = { "Tony", "Shmiley", NULL }; -char *DLG163[] = { "Tony", "Shmiley", NULL }; -char *DLG180[] = { "Tony", "Beast", NULL }; -char *DLG190[] = { "Tony", "Beast", NULL }; -char *DLG191[] = { "Tony", "Beast", NULL }; -char *DLG201[] = { "Tony", NULL }; -char *DLG210[] = { "Tony", "Mortimer", NULL }; -char *DLG211[] = { "Tony", "Mortimer", NULL }; -char *DLG212[] = { "Tony", "Mortimer", NULL }; -char *DLG240[] = { "Tony", "Isabella", NULL }; -char *DLG250[] = { "Tony", "Bartender", "Sad pirate", "Anchorman", "Biff", NULL }; -char *DLG251[] = { "Tony", "Bartender", "Sad pirate", "Anchorman", "Biff", NULL }; -char *DLG260[] = { "Tony", "Captain", "Captain (tale)", NULL }; -char *DLG270[] = { "Tony", "Egghead", NULL }; -char *DLG271[] = { "Tony", "Egghead", NULL }; -char *DLG272[] = { "Tony", "Egghead", NULL }; -char *DLG290[] = { "Tony", "Old lady 2", NULL }; -char *DLG310[] = { "Tony", "Wally", NULL }; -char *DLG330[] = { "Tony", "Polly", "Captain (off scene)", NULL }; -char *DLG340[] = { "Tony", "Randall", NULL }; -char *DLG360[] = { "Tony", NULL }; -char *DLG361[] = { "Tony", NULL }; -char *DLG370[] = { "Tony", "Gatekeeper", NULL }; -char *DLG371[] = { "Tony", "Gatekeeper", NULL }; -char *DLG372[] = { "Tony", "Gatekeeper", NULL }; -char *DLG373[] = { "Tony", "Gatekeeper", NULL }; -char *DLG380[] = { "Tony", NULL }; -char *DLG410[] = { "Tony", "Gwendel", NULL }; -char *DLG430[] = { "Tony", "Harold", "Chuck", "Pigeons", "Housekeeper (off scene)", NULL }; -char *DLG460[] = { "Tony", NULL }; -char *DLG470[] = { "Tony", "Housekeeper", "Mirror", NULL }; -char *DLG471[] = { "Tony", "Housekeeper", "Mirror", NULL }; -char *DLG472[] = { "Tony", "Housekeeper", "Mirror", NULL }; -char *DLG473[] = { "Tony", "Housekeeper", "Mirror", NULL }; -char *DLG474[] = { "Tony", "Housekeeper", "Mirror", NULL }; -char *DLG480[] = { "Tony", "Pin-up", NULL }; -char *DLG490[] = { "Tony", "Gwendel", NULL }; -char *DLG530[] = { "Tony", "Harold", "Chuck", NULL }; -char *DLG550[] = { "Tony", "Mr. Wishing Well", "Tony (from the top of the well)", NULL }; -char *DLG560[] = { "Tony", "Superintendent", NULL }; -char *DLG590[] = { "Tony", "Pantagruel", NULL }; -char *DLG600[] = { "Tony", "Jack", "Jack", NULL, "Jack", NULL, NULL, NULL, "Storyteller", "Mr. Wishing Well", NULL }; +const char *DLG10[] = { "Tony", NULL }; +const char *DLG51[] = { "Tony", "Butch", "Dudley" }; +const char *DLG52[] = { "Tony", NULL }; +const char *DLG61[] = { "Tony", "Old lady 1", NULL }; +const char *DLG71[] = { "Tony", "Timothy", "Convict", NULL, NULL, "Jack (with microphone)", "Old lady 1", NULL }; +const char *DLG90[] = { "Tony", "Bearded lady", NULL }; +const char *DLG110[] = { "Tony", "Lorenz", NULL }; +const char *DLG111[] = { "Tony", "Lorenz", NULL }; +const char *DLG130[] = { "Tony", "Piranha", NULL }; +const char *DLG150[] = { "Tony", "Rufus", "Snowman", NULL }; +const char *DLG151[] = { "Tony", "Rufus", "Snowman", NULL }; +const char *DLG152[] = { "Tony", "Rufus", "Snowman", NULL }; +const char *DLG153[] = { "Tony", "Rufus", "Snowman", NULL }; +const char *DLG154[] = { "Tony", "Rufus", "Snowman", NULL }; +const char *DLG160[] = { "Tony", "Shmiley", NULL }; +const char *DLG161[] = { "Tony", "Shmiley", NULL }; +const char *DLG162[] = { "Tony", "Shmiley", NULL }; +const char *DLG163[] = { "Tony", "Shmiley", NULL }; +const char *DLG180[] = { "Tony", "Beast", NULL }; +const char *DLG190[] = { "Tony", "Beast", NULL }; +const char *DLG191[] = { "Tony", "Beast", NULL }; +const char *DLG201[] = { "Tony", NULL }; +const char *DLG210[] = { "Tony", "Mortimer", NULL }; +const char *DLG211[] = { "Tony", "Mortimer", NULL }; +const char *DLG212[] = { "Tony", "Mortimer", NULL }; +const char *DLG240[] = { "Tony", "Isabella", NULL }; +const char *DLG250[] = { "Tony", "Bartender", "Sad pirate", "Anchorman", "Biff", NULL }; +const char *DLG251[] = { "Tony", "Bartender", "Sad pirate", "Anchorman", "Biff", NULL }; +const char *DLG260[] = { "Tony", "Captain", "Captain (tale)", NULL }; +const char *DLG270[] = { "Tony", "Egghead", NULL }; +const char *DLG271[] = { "Tony", "Egghead", NULL }; +const char *DLG272[] = { "Tony", "Egghead", NULL }; +const char *DLG290[] = { "Tony", "Old lady 2", NULL }; +const char *DLG310[] = { "Tony", "Wally", NULL }; +const char *DLG330[] = { "Tony", "Polly", "Captain (off scene)", NULL }; +const char *DLG340[] = { "Tony", "Randall", NULL }; +const char *DLG360[] = { "Tony", NULL }; +const char *DLG361[] = { "Tony", NULL }; +const char *DLG370[] = { "Tony", "Gatekeeper", NULL }; +const char *DLG371[] = { "Tony", "Gatekeeper", NULL }; +const char *DLG372[] = { "Tony", "Gatekeeper", NULL }; +const char *DLG373[] = { "Tony", "Gatekeeper", NULL }; +const char *DLG380[] = { "Tony", NULL }; +const char *DLG410[] = { "Tony", "Gwendel", NULL }; +const char *DLG430[] = { "Tony", "Harold", "Chuck", "Pigeons", "Housekeeper (off scene)", NULL }; +const char *DLG460[] = { "Tony", NULL }; +const char *DLG470[] = { "Tony", "Housekeeper", "Mirror", NULL }; +const char *DLG471[] = { "Tony", "Housekeeper", "Mirror", NULL }; +const char *DLG472[] = { "Tony", "Housekeeper", "Mirror", NULL }; +const char *DLG473[] = { "Tony", "Housekeeper", "Mirror", NULL }; +const char *DLG474[] = { "Tony", "Housekeeper", "Mirror", NULL }; +const char *DLG480[] = { "Tony", "Pin-up", NULL }; +const char *DLG490[] = { "Tony", "Gwendel", NULL }; +const char *DLG530[] = { "Tony", "Harold", "Chuck", NULL }; +const char *DLG550[] = { "Tony", "Mr. Wishing Well", "Tony (from the top of the well)", NULL }; +const char *DLG560[] = { "Tony", "Superintendent", NULL }; +const char *DLG590[] = { "Tony", "Pantagruel", NULL }; +const char *DLG600[] = { "Tony", "Jack", "Jack", NULL, "Jack", NULL, NULL, NULL, "Storyteller", "Mr. Wishing Well", NULL }; #endif #if 0 // Polish names -char *DLG10[] = { "Tony", NULL }; -char *DLG51[] = { "Tony", "Butch", "Dudley" }; -char *DLG52[] = { "Tony", NULL }; -char *DLG61[] = { "Tony", "Staruszka 1", NULL }; -char *DLG71[] = { "Tony", "Timothy", "Skazaniec", NULL, NULL, "ebster (przez mikrofon)", "Staruszka 1", NULL }; -char *DLG90[] = { "Tony", "Kobieta z Brod", NULL }; -char *DLG110[] = { "Tony", "Lorenz", NULL }; -char *DLG111[] = { "Tony", "Lorenz", NULL }; -char *DLG130[] = { "Tony", "Pirania", NULL }; -char *DLG150[] = { "Tony", "Rufus", "Bawan", NULL }; -char *DLG151[] = { "Tony", "Rufus", "Bawan", NULL }; -char *DLG152[] = { "Tony", "Rufus", "Bawan", NULL }; -char *DLG153[] = { "Tony", "Rufus", "Bawan", NULL }; -char *DLG154[] = { "Tony", "Rufus", "Bawan", NULL }; -char *DLG160[] = { "Tony", "miechozol", NULL }; -char *DLG161[] = { "Tony", "miechozol", NULL }; -char *DLG162[] = { "Tony", "miechozol", NULL }; -char *DLG163[] = { "Tony", "miechozol", NULL }; -char *DLG180[] = { "Tony", "Wycz", NULL }; -char *DLG190[] = { "Tony", "Wycz", NULL }; -char *DLG191[] = { "Tony", "Wycz", NULL }; -char *DLG201[] = { "Tony", NULL }; -char *DLG210[] = { "Tony", "Mortimer (Okropny)", NULL }; -char *DLG211[] = { "Tony", "Mortimer (Okropny)", NULL }; -char *DLG212[] = { "Tony", "Mortimer (Okropny)", NULL }; -char *DLG240[] = { "Tony", "Isabella", NULL }; -char *DLG250[] = { "Tony", "Barman", "Smutny Pirat", "Wodzirej", "Biff", NULL }; -char *DLG251[] = { "Tony", "Barman", "Smutny Pirat", "Wodzirej", "Biff", NULL }; -char *DLG260[] = { "Tony", "Kapitan", "Captain (opowie)", NULL }; -char *DLG270[] = { "Tony", "Jajogowy", NULL }; -char *DLG271[] = { "Tony", "Jajogowy", NULL }; -char *DLG272[] = { "Tony", "Jajogowy", NULL }; -char *DLG290[] = { "Tony", "Staruszka 2", NULL }; -char *DLG310[] = { "Tony", "Wally", NULL }; -char *DLG330[] = { "Tony", "Polly", "Kapitan (zza sceny)", NULL }; -char *DLG340[] = { "Tony", "Randall", NULL }; -char *DLG360[] = { "Tony", NULL }; -char *DLG361[] = { "Tony", NULL }; -char *DLG370[] = { "Tony", "Stranik", NULL }; -char *DLG371[] = { "Tony", "Stranik", NULL }; -char *DLG372[] = { "Tony", "Stranik", NULL }; -char *DLG373[] = { "Tony", "Stranik", NULL }; -char *DLG380[] = { "Tony", NULL }; -char *DLG410[] = { "Tony", "Gwendel", NULL }; -char *DLG430[] = { "Tony", "Harold", "Chuck", "Pigeons", "Gospodyni (zza sceny)", NULL }; -char *DLG460[] = { "Tony", NULL }; -char *DLG470[] = { "Tony", "Gospodyni", "Mirror", NULL }; -char *DLG471[] = { "Tony", "Gospodyni", "Mirror", NULL }; -char *DLG472[] = { "Tony", "Gospodyni", "Mirror", NULL }; -char *DLG473[] = { "Tony", "Gospodyni", "Mirror", NULL }; -char *DLG474[] = { "Tony", "Gospodyni", "Mirror", NULL }; -char *DLG480[] = { "Tony", "Pin-up", NULL }; -char *DLG490[] = { "Tony", "Gwendel", NULL }; -char *DLG530[] = { "Tony", "Harold", "Chuck", NULL }; -char *DLG550[] = { "Tony", "Pan Studnia ycze", "Tony (nad studni)", NULL }; -char *DLG560[] = { "Tony", "Inspektor", NULL }; -char *DLG590[] = { "Tony", "Pantaloniarz", NULL }; -char *DLG600[] = { "Tony", "ebster", "ebster", NULL, "ebster", NULL, NULL, NULL, "Narrator", "Pan Studnia ycze", NULL }; +const char *DLG10[] = { "Tony", NULL }; +const char *DLG51[] = { "Tony", "Butch", "Dudley" }; +const char *DLG52[] = { "Tony", NULL }; +const char *DLG61[] = { "Tony", "Staruszka 1", NULL }; +const char *DLG71[] = { "Tony", "Timothy", "Skazaniec", NULL, NULL, "ebster (przez mikrofon)", "Staruszka 1", NULL }; +const char *DLG90[] = { "Tony", "Kobieta z Brod", NULL }; +const char *DLG110[] = { "Tony", "Lorenz", NULL }; +const char *DLG111[] = { "Tony", "Lorenz", NULL }; +const char *DLG130[] = { "Tony", "Pirania", NULL }; +const char *DLG150[] = { "Tony", "Rufus", "Bawan", NULL }; +const char *DLG151[] = { "Tony", "Rufus", "Bawan", NULL }; +const char *DLG152[] = { "Tony", "Rufus", "Bawan", NULL }; +const char *DLG153[] = { "Tony", "Rufus", "Bawan", NULL }; +const char *DLG154[] = { "Tony", "Rufus", "Bawan", NULL }; +const char *DLG160[] = { "Tony", "miechozol", NULL }; +const char *DLG161[] = { "Tony", "miechozol", NULL }; +const char *DLG162[] = { "Tony", "miechozol", NULL }; +const char *DLG163[] = { "Tony", "miechozol", NULL }; +const char *DLG180[] = { "Tony", "Wycz", NULL }; +const char *DLG190[] = { "Tony", "Wycz", NULL }; +const char *DLG191[] = { "Tony", "Wycz", NULL }; +const char *DLG201[] = { "Tony", NULL }; +const char *DLG210[] = { "Tony", "Mortimer (Okropny)", NULL }; +const char *DLG211[] = { "Tony", "Mortimer (Okropny)", NULL }; +const char *DLG212[] = { "Tony", "Mortimer (Okropny)", NULL }; +const char *DLG240[] = { "Tony", "Isabella", NULL }; +const char *DLG250[] = { "Tony", "Barman", "Smutny Pirat", "Wodzirej", "Biff", NULL }; +const char *DLG251[] = { "Tony", "Barman", "Smutny Pirat", "Wodzirej", "Biff", NULL }; +const char *DLG260[] = { "Tony", "Kapitan", "Captain (opowie)", NULL }; +const char *DLG270[] = { "Tony", "Jajogowy", NULL }; +const char *DLG271[] = { "Tony", "Jajogowy", NULL }; +const char *DLG272[] = { "Tony", "Jajogowy", NULL }; +const char *DLG290[] = { "Tony", "Staruszka 2", NULL }; +const char *DLG310[] = { "Tony", "Wally", NULL }; +const char *DLG330[] = { "Tony", "Polly", "Kapitan (zza sceny)", NULL }; +const char *DLG340[] = { "Tony", "Randall", NULL }; +const char *DLG360[] = { "Tony", NULL }; +const char *DLG361[] = { "Tony", NULL }; +const char *DLG370[] = { "Tony", "Stranik", NULL }; +const char *DLG371[] = { "Tony", "Stranik", NULL }; +const char *DLG372[] = { "Tony", "Stranik", NULL }; +const char *DLG373[] = { "Tony", "Stranik", NULL }; +const char *DLG380[] = { "Tony", NULL }; +const char *DLG410[] = { "Tony", "Gwendel", NULL }; +const char *DLG430[] = { "Tony", "Harold", "Chuck", "Pigeons", "Gospodyni (zza sceny)", NULL }; +const char *DLG460[] = { "Tony", NULL }; +const char *DLG470[] = { "Tony", "Gospodyni", "Mirror", NULL }; +const char *DLG471[] = { "Tony", "Gospodyni", "Mirror", NULL }; +const char *DLG472[] = { "Tony", "Gospodyni", "Mirror", NULL }; +const char *DLG473[] = { "Tony", "Gospodyni", "Mirror", NULL }; +const char *DLG474[] = { "Tony", "Gospodyni", "Mirror", NULL }; +const char *DLG480[] = { "Tony", "Pin-up", NULL }; +const char *DLG490[] = { "Tony", "Gwendel", NULL }; +const char *DLG530[] = { "Tony", "Harold", "Chuck", NULL }; +const char *DLG550[] = { "Tony", "Pan Studnia ycze", "Tony (nad studni)", NULL }; +const char *DLG560[] = { "Tony", "Inspektor", NULL }; +const char *DLG590[] = { "Tony", "Pantaloniarz", NULL }; +const char *DLG600[] = { "Tony", "ebster", "ebster", NULL, "ebster", NULL, NULL, NULL, "Narrator", "Pan Studnia ycze", NULL }; #endif // Polish #if 0 // Russian -char *DLG10[] = { "呷辷", NULL }; -char *DLG51[] = { "呷辷", "蒼", "釣粳" }; -char *DLG52[] = { "呷辷", NULL }; -char *DLG61[] = { "呷辷", "剪瑁齪袱 1", NULL }; -char *DLG71[] = { "呷辷", "呎跪鱶", "暦黽粤迯", NULL, NULL, "剃繩 ( 跏褓銓鉈鉤)", "剪瑁齪袱 1", NULL }; -char *DLG90[] = { "呷辷", "綜韲籥鰰 聽逋蓁", NULL }; -char *DLG110[] = { "呷辷", "鮪鞳逍", NULL }; -char *DLG111[] = { "呷辷", "鮪鞳逍", NULL }; -char *DLG130[] = { "呷辷", "蒡琿", NULL }; -char *DLG150[] = { "呷辷", "偕齣", "剄繝鈞蒻", NULL }; -char *DLG151[] = { "呷辷", "偕齣", "剄繝鈞蒻", NULL }; -char *DLG152[] = { "呷辷", "偕齣", "剄繝鈞蒻", NULL }; -char *DLG153[] = { "呷辷", "偕齣", "剄繝鈞蒻", NULL }; -char *DLG154[] = { "呷辷", "偕齣", "剄繝鈞蒻", NULL }; -char *DLG160[] = { "呷辷", "懋珸謌", NULL }; -char *DLG161[] = { "呷辷", "懋珸謌", NULL }; -char *DLG162[] = { "呷辷", "懋珸謌", NULL }; -char *DLG163[] = { "呷辷", "懋珸謌", NULL }; -char *DLG180[] = { "呷辷", "恣粮礦", NULL }; -char *DLG190[] = { "呷辷", "恣粮礦", NULL }; -char *DLG191[] = { "呷辷", "恣粮礦", NULL }; -char *DLG201[] = { "呷辷", NULL }; -char *DLG210[] = { "呷辷", "野頏蓐辮", NULL }; -char *DLG211[] = { "呷辷", "野頏蓐辮", NULL }; -char *DLG212[] = { "呷辷", "野頏蓐辮", NULL }; -char *DLG240[] = { "呷辷", "泌珀繼諤", NULL }; -char *DLG250[] = { "呷辷", "操韭纃", "註齣鴉 闊鞐", "代糂蓍", "争", NULL }; -char *DLG251[] = { "呷辷", "操韭纃", "註齣鴉 闊鞐", "代糂蓍", "争", NULL }; -char *DLG260[] = { "呷辷", "圃闊鰰", "圃闊鰰 (鞐髑袱)", NULL }; -char *DLG270[] = { "呷辷", "煢繝鉉鈞", NULL }; -char *DLG271[] = { "呷辷", "煢繝鉉鈞", NULL }; -char *DLG272[] = { "呷辷", "煢繝鉉鈞", NULL }; -char *DLG290[] = { "呷辷", "剪瑁齪袱 2", NULL }; -char *DLG310[] = { "呷辷", "嚴諡", NULL }; -char *DLG330[] = { "呷辷", "鉉謌", "圃闊鰰 (艢 髢纃鉗)", NULL }; -char *DLG340[] = { "呷辷", "傴辟琺", NULL }; -char *DLG360[] = { "呷辷", NULL }; -char *DLG361[] = { "呷辷", NULL }; -char *DLG370[] = { "呷辷", "韆碚瑩辷", NULL }; -char *DLG371[] = { "呷辷", "韆碚瑩辷", NULL }; -char *DLG372[] = { "呷辷", "韆碚瑩辷", NULL }; -char *DLG373[] = { "呷辷", "韆碚瑩辷", NULL }; -char *DLG380[] = { "呷辷", NULL }; -char *DLG410[] = { "呷辷", "窒纃粤譛", NULL }; -char *DLG430[] = { "呷辷", "逐韲譛", "怙", "Pigeons", "Housekeeper (off scene)", NULL }; -char *DLG460[] = { "呷辷", NULL }; -char *DLG470[] = { "呷辷", "Housekeeper", "Mirror", NULL }; -char *DLG471[] = { "呷辷", "Housekeeper", "Mirror", NULL }; -char *DLG472[] = { "呷辷", "Housekeeper", "Mirror", NULL }; -char *DLG473[] = { "呷辷", "Housekeeper", "Mirror", NULL }; -char *DLG474[] = { "呷辷", "Housekeeper", "Mirror", NULL }; -char *DLG480[] = { "呷辷", "Pin-up", NULL }; -char *DLG490[] = { "呷辷", "窒纃粤譛", NULL }; -char *DLG530[] = { "呷辷", "逐韲譛", "怙", NULL }; -char *DLG550[] = { "呷辷", "虫髀鈔蓁 菩謗粤 聽諤辷", "呷辷 ( 矼頽蓁 褌謗糜)", NULL }; -char *DLG560[] = { "呷辷", "沃琺辷 銛鞐逶", NULL }; -char *DLG590[] = { "呷辷", "琿鰰竦譛", NULL }; -char *DLG600[] = { "呷辷", "剃繩", "剃繩", NULL, "剃繩", NULL, NULL, NULL, "俥髑袱范蒻", "虫髀鈔蓁 菩謗粤 聽諤辷", NULL }; +const char *DLG10[] = { "呷辷", NULL }; +const char *DLG51[] = { "呷辷", "蒼", "釣粳" }; +const char *DLG52[] = { "呷辷", NULL }; +const char *DLG61[] = { "呷辷", "剪瑁齪袱 1", NULL }; +const char *DLG71[] = { "呷辷", "呎跪鱶", "暦黽粤迯", NULL, NULL, "剃繩 ( 跏褓銓鉈鉤)", "剪瑁齪袱 1", NULL }; +const char *DLG90[] = { "呷辷", "綜韲籥鰰 聽逋蓁", NULL }; +const char *DLG110[] = { "呷辷", "鮪鞳逍", NULL }; +const char *DLG111[] = { "呷辷", "鮪鞳逍", NULL }; +const char *DLG130[] = { "呷辷", "蒡琿", NULL }; +const char *DLG150[] = { "呷辷", "偕齣", "剄繝鈞蒻", NULL }; +const char *DLG151[] = { "呷辷", "偕齣", "剄繝鈞蒻", NULL }; +const char *DLG152[] = { "呷辷", "偕齣", "剄繝鈞蒻", NULL }; +const char *DLG153[] = { "呷辷", "偕齣", "剄繝鈞蒻", NULL }; +const char *DLG154[] = { "呷辷", "偕齣", "剄繝鈞蒻", NULL }; +const char *DLG160[] = { "呷辷", "懋珸謌", NULL }; +const char *DLG161[] = { "呷辷", "懋珸謌", NULL }; +const char *DLG162[] = { "呷辷", "懋珸謌", NULL }; +const char *DLG163[] = { "呷辷", "懋珸謌", NULL }; +const char *DLG180[] = { "呷辷", "恣粮礦", NULL }; +const char *DLG190[] = { "呷辷", "恣粮礦", NULL }; +const char *DLG191[] = { "呷辷", "恣粮礦", NULL }; +const char *DLG201[] = { "呷辷", NULL }; +const char *DLG210[] = { "呷辷", "野頏蓐辮", NULL }; +const char *DLG211[] = { "呷辷", "野頏蓐辮", NULL }; +const char *DLG212[] = { "呷辷", "野頏蓐辮", NULL }; +const char *DLG240[] = { "呷辷", "泌珀繼諤", NULL }; +const char *DLG250[] = { "呷辷", "操韭纃", "註齣鴉 闊鞐", "代糂蓍", "争", NULL }; +const char *DLG251[] = { "呷辷", "操韭纃", "註齣鴉 闊鞐", "代糂蓍", "争", NULL }; +const char *DLG260[] = { "呷辷", "圃闊鰰", "圃闊鰰 (鞐髑袱)", NULL }; +const char *DLG270[] = { "呷辷", "煢繝鉉鈞", NULL }; +const char *DLG271[] = { "呷辷", "煢繝鉉鈞", NULL }; +const char *DLG272[] = { "呷辷", "煢繝鉉鈞", NULL }; +const char *DLG290[] = { "呷辷", "剪瑁齪袱 2", NULL }; +const char *DLG310[] = { "呷辷", "嚴諡", NULL }; +const char *DLG330[] = { "呷辷", "鉉謌", "圃闊鰰 (艢 髢纃鉗)", NULL }; +const char *DLG340[] = { "呷辷", "傴辟琺", NULL }; +const char *DLG360[] = { "呷辷", NULL }; +const char *DLG361[] = { "呷辷", NULL }; +const char *DLG370[] = { "呷辷", "韆碚瑩辷", NULL }; +const char *DLG371[] = { "呷辷", "韆碚瑩辷", NULL }; +const char *DLG372[] = { "呷辷", "韆碚瑩辷", NULL }; +const char *DLG373[] = { "呷辷", "韆碚瑩辷", NULL }; +const char *DLG380[] = { "呷辷", NULL }; +const char *DLG410[] = { "呷辷", "窒纃粤譛", NULL }; +const char *DLG430[] = { "呷辷", "逐韲譛", "怙", "Pigeons", "Housekeeper (off scene)", NULL }; +const char *DLG460[] = { "呷辷", NULL }; +const char *DLG470[] = { "呷辷", "Housekeeper", "Mirror", NULL }; +const char *DLG471[] = { "呷辷", "Housekeeper", "Mirror", NULL }; +const char *DLG472[] = { "呷辷", "Housekeeper", "Mirror", NULL }; +const char *DLG473[] = { "呷辷", "Housekeeper", "Mirror", NULL }; +const char *DLG474[] = { "呷辷", "Housekeeper", "Mirror", NULL }; +const char *DLG480[] = { "呷辷", "Pin-up", NULL }; +const char *DLG490[] = { "呷辷", "窒纃粤譛", NULL }; +const char *DLG530[] = { "呷辷", "逐韲譛", "怙", NULL }; +const char *DLG550[] = { "呷辷", "虫髀鈔蓁 菩謗粤 聽諤辷", "呷辷 ( 矼頽蓁 褌謗糜)", NULL }; +const char *DLG560[] = { "呷辷", "沃琺辷 銛鞐逶", NULL }; +const char *DLG590[] = { "呷辷", "琿鰰竦譛", NULL }; +const char *DLG600[] = { "呷辷", "剃繩", "剃繩", NULL, "剃繩", NULL, NULL, NULL, "俥髑袱范蒻", "虫髀鈔蓁 菩謗粤 聽諤辷", NULL }; #endif // Russian #if 0 // Czech names -char *DLG10[] = { "Tony", NULL }; -char *DLG51[] = { "Tony", "Butch", "Dudley" }; -char *DLG52[] = { "Tony", NULL }; -char *DLG61[] = { "Tony", "Star pan 1", NULL }; -char *DLG71[] = { "Tony", "Timothy", "Trestanec", NULL, NULL, "Jack (s mikrofonem)", "Star pan 1", NULL }; -char *DLG90[] = { "Tony", "Vousat ena", NULL }; -char *DLG110[] = { "Tony", "Lorenz", NULL }; -char *DLG111[] = { "Tony", "Lorenz", NULL }; -char *DLG130[] = { "Tony", "Piraa", NULL }; -char *DLG150[] = { "Tony", "Rufus", "Snhulk", NULL }; -char *DLG151[] = { "Tony", "Rufus", "Snhulk", NULL }; -char *DLG152[] = { "Tony", "Rufus", "Snhulk", NULL }; -char *DLG153[] = { "Tony", "Rufus", "Snhulk", NULL }; -char *DLG154[] = { "Tony", "Rufus", "Snhulk", NULL }; -char *DLG160[] = { "Tony", "Shmiley", NULL }; -char *DLG161[] = { "Tony", "Shmiley", NULL }; -char *DLG162[] = { "Tony", "Shmiley", NULL }; -char *DLG163[] = { "Tony", "Shmiley", NULL }; -char *DLG180[] = { "Tony", "Zv逖e", NULL }; -char *DLG190[] = { "Tony", "Zv逖e", NULL }; -char *DLG191[] = { "Tony", "Zv逖e", NULL }; -char *DLG201[] = { "Tony", NULL }; -char *DLG210[] = { "Tony", "Mortimer", NULL }; -char *DLG211[] = { "Tony", "Mortimer", NULL }; -char *DLG212[] = { "Tony", "Mortimer", NULL }; -char *DLG240[] = { "Tony", "Isabella", NULL }; -char *DLG250[] = { "Tony", "Barman", "Smutn pirt", "Modertor", "Biff", NULL }; -char *DLG251[] = { "Tony", "Barman", "Smutn pirt", "Modertor", "Biff", NULL }; -char *DLG260[] = { "Tony", "Kapitn", "Kapitn (pbh)", NULL }; -char *DLG270[] = { "Tony", "Intelektul", NULL }; -char *DLG271[] = { "Tony", "Intelektul", NULL }; -char *DLG272[] = { "Tony", "Intelektul", NULL }; -char *DLG290[] = { "Tony", "Star pan 2", NULL }; -char *DLG310[] = { "Tony", "Wally", NULL }; -char *DLG330[] = { "Tony", "Lra", "Kapitn (mimo scnu)", NULL }; -char *DLG340[] = { "Tony", "Randall", NULL }; -char *DLG360[] = { "Tony", NULL }; -char *DLG361[] = { "Tony", NULL }; -char *DLG370[] = { "Tony", "Strn", NULL }; -char *DLG371[] = { "Tony", "Strn", NULL }; -char *DLG372[] = { "Tony", "Strn", NULL }; -char *DLG373[] = { "Tony", "Strn", NULL }; -char *DLG380[] = { "Tony", NULL }; -char *DLG410[] = { "Tony", "Gwendel", NULL }; -char *DLG430[] = { "Tony", "Harold", "Chuck", "Pigeons", "Housekeeper (off scene)", NULL }; -char *DLG460[] = { "Tony", NULL }; -char *DLG470[] = { "Tony", "Housekeeper", "Mirror", NULL }; -char *DLG471[] = { "Tony", "Housekeeper", "Mirror", NULL }; -char *DLG472[] = { "Tony", "Housekeeper", "Mirror", NULL }; -char *DLG473[] = { "Tony", "Housekeeper", "Mirror", NULL }; -char *DLG474[] = { "Tony", "Housekeeper", "Mirror", NULL }; -char *DLG480[] = { "Tony", "Pin-up", NULL }; -char *DLG490[] = { "Tony", "Gwendel", NULL }; -char *DLG530[] = { "Tony", "Harold", "Chuck", NULL }; -char *DLG550[] = { "Tony", "Pan Studna pn", "Tony (z vrcholu studny)", NULL }; -char *DLG560[] = { "Tony", "Sprvce", NULL }; -char *DLG590[] = { "Tony", "Pantagruel", NULL }; -char *DLG600[] = { "Tony", "Jack", "Jack", NULL, "Jack", NULL, NULL, NULL, "Vyprav跏", "Pan Studna pn", NULL }; +const char *DLG10[] = { "Tony", NULL }; +const char *DLG51[] = { "Tony", "Butch", "Dudley" }; +const char *DLG52[] = { "Tony", NULL }; +const char *DLG61[] = { "Tony", "Star pan 1", NULL }; +const char *DLG71[] = { "Tony", "Timothy", "Trestanec", NULL, NULL, "Jack (s mikrofonem)", "Star pan 1", NULL }; +const char *DLG90[] = { "Tony", "Vousat ena", NULL }; +const char *DLG110[] = { "Tony", "Lorenz", NULL }; +const char *DLG111[] = { "Tony", "Lorenz", NULL }; +const char *DLG130[] = { "Tony", "Piraa", NULL }; +const char *DLG150[] = { "Tony", "Rufus", "Snhulk", NULL }; +const char *DLG151[] = { "Tony", "Rufus", "Snhulk", NULL }; +const char *DLG152[] = { "Tony", "Rufus", "Snhulk", NULL }; +const char *DLG153[] = { "Tony", "Rufus", "Snhulk", NULL }; +const char *DLG154[] = { "Tony", "Rufus", "Snhulk", NULL }; +const char *DLG160[] = { "Tony", "Shmiley", NULL }; +const char *DLG161[] = { "Tony", "Shmiley", NULL }; +const char *DLG162[] = { "Tony", "Shmiley", NULL }; +const char *DLG163[] = { "Tony", "Shmiley", NULL }; +const char *DLG180[] = { "Tony", "Zv逖e", NULL }; +const char *DLG190[] = { "Tony", "Zv逖e", NULL }; +const char *DLG191[] = { "Tony", "Zv逖e", NULL }; +const char *DLG201[] = { "Tony", NULL }; +const char *DLG210[] = { "Tony", "Mortimer", NULL }; +const char *DLG211[] = { "Tony", "Mortimer", NULL }; +const char *DLG212[] = { "Tony", "Mortimer", NULL }; +const char *DLG240[] = { "Tony", "Isabella", NULL }; +const char *DLG250[] = { "Tony", "Barman", "Smutn pirt", "Modertor", "Biff", NULL }; +const char *DLG251[] = { "Tony", "Barman", "Smutn pirt", "Modertor", "Biff", NULL }; +const char *DLG260[] = { "Tony", "Kapitn", "Kapitn (pbh)", NULL }; +const char *DLG270[] = { "Tony", "Intelektul", NULL }; +const char *DLG271[] = { "Tony", "Intelektul", NULL }; +const char *DLG272[] = { "Tony", "Intelektul", NULL }; +const char *DLG290[] = { "Tony", "Star pan 2", NULL }; +const char *DLG310[] = { "Tony", "Wally", NULL }; +const char *DLG330[] = { "Tony", "Lra", "Kapitn (mimo scnu)", NULL }; +const char *DLG340[] = { "Tony", "Randall", NULL }; +const char *DLG360[] = { "Tony", NULL }; +const char *DLG361[] = { "Tony", NULL }; +const char *DLG370[] = { "Tony", "Strn", NULL }; +const char *DLG371[] = { "Tony", "Strn", NULL }; +const char *DLG372[] = { "Tony", "Strn", NULL }; +const char *DLG373[] = { "Tony", "Strn", NULL }; +const char *DLG380[] = { "Tony", NULL }; +const char *DLG410[] = { "Tony", "Gwendel", NULL }; +const char *DLG430[] = { "Tony", "Harold", "Chuck", "Pigeons", "Housekeeper (off scene)", NULL }; +const char *DLG460[] = { "Tony", NULL }; +const char *DLG470[] = { "Tony", "Housekeeper", "Mirror", NULL }; +const char *DLG471[] = { "Tony", "Housekeeper", "Mirror", NULL }; +const char *DLG472[] = { "Tony", "Housekeeper", "Mirror", NULL }; +const char *DLG473[] = { "Tony", "Housekeeper", "Mirror", NULL }; +const char *DLG474[] = { "Tony", "Housekeeper", "Mirror", NULL }; +const char *DLG480[] = { "Tony", "Pin-up", NULL }; +const char *DLG490[] = { "Tony", "Gwendel", NULL }; +const char *DLG530[] = { "Tony", "Harold", "Chuck", NULL }; +const char *DLG550[] = { "Tony", "Pan Studna pn", "Tony (z vrcholu studny)", NULL }; +const char *DLG560[] = { "Tony", "Sprvce", NULL }; +const char *DLG590[] = { "Tony", "Pantagruel", NULL }; +const char *DLG600[] = { "Tony", "Jack", "Jack", NULL, "Jack", NULL, NULL, NULL, "Vyprav跏", "Pan Studna pn", NULL }; #endif // Czech names #if 1 // Deutsch names -char *DLG10[] = { "Tony", NULL }; -char *DLG51[] = { "Tony", "Butch", "Dudley" }; -char *DLG52[] = { "Tony", NULL }; -char *DLG61[] = { "Tony", "Alte Dame 1", NULL }; -char *DLG71[] = { "Tony", "Timothy", "Strfling", NULL, NULL, "Jack (mit Mikrofon)", "Alte Dame 1", NULL }; -char *DLG90[] = { "Tony", "Brtige Dame", NULL }; -char *DLG110[] = { "Tony", "Lorenz", NULL }; -char *DLG111[] = { "Tony", "Lorenz", NULL }; -char *DLG130[] = { "Tony", "Piranha", NULL }; -char *DLG150[] = { "Tony", "Rufus", "Schneemann", NULL }; -char *DLG151[] = { "Tony", "Rufus", "Schneemann", NULL }; -char *DLG152[] = { "Tony", "Rufus", "Schneemann", NULL }; -char *DLG153[] = { "Tony", "Rufus", "Schneemann", NULL }; -char *DLG154[] = { "Tony", "Rufus", "Schneemann", NULL }; -char *DLG160[] = { "Tony", "Shmiley", NULL }; -char *DLG161[] = { "Tony", "Shmiley", NULL }; -char *DLG162[] = { "Tony", "Shmiley", NULL }; -char *DLG163[] = { "Tony", "Shmiley", NULL }; -char *DLG180[] = { "Tony", "Biest", NULL }; -char *DLG190[] = { "Tony", "Biest", NULL }; -char *DLG191[] = { "Tony", "Biest", NULL }; -char *DLG201[] = { "Tony", NULL }; -char *DLG210[] = { "Tony", "Mortimer", NULL }; -char *DLG211[] = { "Tony", "Mortimer", NULL }; -char *DLG212[] = { "Tony", "Mortimer", NULL }; -char *DLG240[] = { "Tony", "Isabella", NULL }; -char *DLG250[] = { "Tony", "Barmann", "Trauriger Pirat", "Chefanimateur", "Biff", NULL }; -char *DLG251[] = { "Tony", "Barmann", "Trauriger Pirat", "Chefanimateur", "Biff", NULL }; -char *DLG260[] = { "Tony", "Kapitn", "Kapitn (Erzhlung)", NULL }; -char *DLG270[] = { "Tony", "Eierkopf", NULL }; -char *DLG271[] = { "Tony", "Eierkopf", NULL }; -char *DLG272[] = { "Tony", "Eierkopf", NULL }; -char *DLG290[] = { "Tony", "Alte Dame 2", NULL }; -char *DLG310[] = { "Tony", "Wally", NULL }; -char *DLG330[] = { "Tony", "Polly", "Kapitn (im Off)", NULL }; -char *DLG340[] = { "Tony", "Randall", NULL }; -char *DLG360[] = { "Tony", NULL }; -char *DLG361[] = { "Tony", NULL }; -char *DLG370[] = { "Tony", "Pfrtner", NULL }; -char *DLG371[] = { "Tony", "Pfrtner", NULL }; -char *DLG372[] = { "Tony", "Pfrtner", NULL }; -char *DLG373[] = { "Tony", "Pfrtner", NULL }; -char *DLG380[] = { "Tony", NULL }; -char *DLG410[] = { "Tony", "Gwendel", NULL }; -char *DLG430[] = { "Tony", "Harold", "Chuck", "Pigeons", "Housekeeper (off scene)", NULL }; -char *DLG460[] = { "Tony", NULL }; -char *DLG470[] = { "Tony", "Housekeeper", "Mirror", NULL }; -char *DLG471[] = { "Tony", "Housekeeper", "Mirror", NULL }; -char *DLG472[] = { "Tony", "Housekeeper", "Mirror", NULL }; -char *DLG473[] = { "Tony", "Housekeeper", "Mirror", NULL }; -char *DLG474[] = { "Tony", "Housekeeper", "Mirror", NULL }; -char *DLG480[] = { "Tony", "Pin-up", NULL }; -char *DLG490[] = { "Tony", "Gwendel", NULL }; -char *DLG530[] = { "Tony", "Harold", "Chuck", NULL }; -char *DLG550[] = { "Tony", "Herr Wunschbrunnen", "Tony (ber dem Brunnen)", NULL }; -char *DLG560[] = { "Tony", "Verwalter", NULL }; -char *DLG590[] = { "Tony", "Pantagruel", NULL }; -char *DLG600[] = { "Tony", "Jack", "Jack", NULL, "Jack", NULL, NULL, NULL, "Erzhler", "Herr Wunschbrunnen", NULL }; +const char *DLG10[] = { "Tony", NULL }; +const char *DLG51[] = { "Tony", "Butch", "Dudley" }; +const char *DLG52[] = { "Tony", NULL }; +const char *DLG61[] = { "Tony", "Alte Dame 1", NULL }; +const char *DLG71[] = { "Tony", "Timothy", "Strfling", NULL, NULL, "Jack (mit Mikrofon)", "Alte Dame 1", NULL }; +const char *DLG90[] = { "Tony", "Brtige Dame", NULL }; +const char *DLG110[] = { "Tony", "Lorenz", NULL }; +const char *DLG111[] = { "Tony", "Lorenz", NULL }; +const char *DLG130[] = { "Tony", "Piranha", NULL }; +const char *DLG150[] = { "Tony", "Rufus", "Schneemann", NULL }; +const char *DLG151[] = { "Tony", "Rufus", "Schneemann", NULL }; +const char *DLG152[] = { "Tony", "Rufus", "Schneemann", NULL }; +const char *DLG153[] = { "Tony", "Rufus", "Schneemann", NULL }; +const char *DLG154[] = { "Tony", "Rufus", "Schneemann", NULL }; +const char *DLG160[] = { "Tony", "Shmiley", NULL }; +const char *DLG161[] = { "Tony", "Shmiley", NULL }; +const char *DLG162[] = { "Tony", "Shmiley", NULL }; +const char *DLG163[] = { "Tony", "Shmiley", NULL }; +const char *DLG180[] = { "Tony", "Biest", NULL }; +const char *DLG190[] = { "Tony", "Biest", NULL }; +const char *DLG191[] = { "Tony", "Biest", NULL }; +const char *DLG201[] = { "Tony", NULL }; +const char *DLG210[] = { "Tony", "Mortimer", NULL }; +const char *DLG211[] = { "Tony", "Mortimer", NULL }; +const char *DLG212[] = { "Tony", "Mortimer", NULL }; +const char *DLG240[] = { "Tony", "Isabella", NULL }; +const char *DLG250[] = { "Tony", "Barmann", "Trauriger Pirat", "Chefanimateur", "Biff", NULL }; +const char *DLG251[] = { "Tony", "Barmann", "Trauriger Pirat", "Chefanimateur", "Biff", NULL }; +const char *DLG260[] = { "Tony", "Kapitn", "Kapitn (Erzhlung)", NULL }; +const char *DLG270[] = { "Tony", "Eierkopf", NULL }; +const char *DLG271[] = { "Tony", "Eierkopf", NULL }; +const char *DLG272[] = { "Tony", "Eierkopf", NULL }; +const char *DLG290[] = { "Tony", "Alte Dame 2", NULL }; +const char *DLG310[] = { "Tony", "Wally", NULL }; +const char *DLG330[] = { "Tony", "Polly", "Kapitn (im Off)", NULL }; +const char *DLG340[] = { "Tony", "Randall", NULL }; +const char *DLG360[] = { "Tony", NULL }; +const char *DLG361[] = { "Tony", NULL }; +const char *DLG370[] = { "Tony", "Pfrtner", NULL }; +const char *DLG371[] = { "Tony", "Pfrtner", NULL }; +const char *DLG372[] = { "Tony", "Pfrtner", NULL }; +const char *DLG373[] = { "Tony", "Pfrtner", NULL }; +const char *DLG380[] = { "Tony", NULL }; +const char *DLG410[] = { "Tony", "Gwendel", NULL }; +const char *DLG430[] = { "Tony", "Harold", "Chuck", "Pigeons", "Housekeeper (off scene)", NULL }; +const char *DLG460[] = { "Tony", NULL }; +const char *DLG470[] = { "Tony", "Housekeeper", "Mirror", NULL }; +const char *DLG471[] = { "Tony", "Housekeeper", "Mirror", NULL }; +const char *DLG472[] = { "Tony", "Housekeeper", "Mirror", NULL }; +const char *DLG473[] = { "Tony", "Housekeeper", "Mirror", NULL }; +const char *DLG474[] = { "Tony", "Housekeeper", "Mirror", NULL }; +const char *DLG480[] = { "Tony", "Pin-up", NULL }; +const char *DLG490[] = { "Tony", "Gwendel", NULL }; +const char *DLG530[] = { "Tony", "Harold", "Chuck", NULL }; +const char *DLG550[] = { "Tony", "Herr Wunschbrunnen", "Tony (ber dem Brunnen)", NULL }; +const char *DLG560[] = { "Tony", "Verwalter", NULL }; +const char *DLG590[] = { "Tony", "Pantagruel", NULL }; +const char *DLG600[] = { "Tony", "Jack", "Jack", NULL, "Jack", NULL, NULL, NULL, "Erzhler", "Herr Wunschbrunnen", NULL }; #endif @@ -2902,7 +2903,7 @@ case num: \ return DLG##num[nPers]; -char *GetPersonName(uint16 nDlg, int nPers) { +const char *GetPersonName(uint16 nDlg, int nPers) { switch (nDlg) { HANDLE_DIALOG(10); HANDLE_DIALOG(51); @@ -2964,7 +2965,7 @@ char *GetPersonName(uint16 nDlg, int nPers) { HANDLE_DIALOG(600); default: - warning("ERROR: Il dialogo %d non esiste!\n", nDlg); + warning("ERROR: Il dialogo %d non esiste!\n", (int)nDlg); return "ERROR"; } } diff --git a/engines/tony/mpal/mpal.h b/engines/tony/mpal/mpal.h index 26c4283018..d800be60b8 100644 --- a/engines/tony/mpal/mpal.h +++ b/engines/tony/mpal/mpal.h @@ -595,7 +595,7 @@ extern "C" { * \****************************************************************************/ -bool EXPORT mpalInit(LPSTR lpszFileName, LPSTR lpszMprFileName, +bool EXPORT mpalInit(const char *lpszFileName, const char *lpszMprFileName, LPLPCUSTOMFUNCTION lplpcfArray); diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index a5293eecb2..7c340be86e 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -589,7 +589,7 @@ uint32 CODECADPCMSTEREO::Decompress(HANDLE hFile, void *buf, uint32 dwSize) { uint16 *lpBuf = (uint16 *)buf; byte *inp; int bufferstep; - int cache; + int cache = 0; int delta; int sign; int vpdiff; @@ -677,7 +677,7 @@ uint32 CODECADPCMSTEREO::Decompress(Common::File &fp, void *buf, uint32 dwSize) uint16 *lpBuf = (uint16 *)buf; byte *inp; int bufferstep; - int cache; + int cache = 0; int delta; int sign; int vpdiff; @@ -1289,7 +1289,7 @@ bool FPSFX::LoadVoiceFromVDB(Common::File &vdbFP) { } -bool FPSFX::LoadFile(LPSTR lpszFileName, uint32 dwCodec) { +bool FPSFX::LoadFile(const char *lpszFileName, uint32 dwCodec) { #ifdef REFACTOR_ME static PCMWAVEFORMAT pcmwf; static DSBUFFERDESC dsbdesc; diff --git a/engines/tony/sound.h b/engines/tony/sound.h index 7ed8f97b3e..8853e1a344 100644 --- a/engines/tony/sound.h +++ b/engines/tony/sound.h @@ -306,7 +306,7 @@ public: * \****************************************************************************/ - bool LoadFile(char *lpszFileName, uint32 dwCodec = FPCODEC_RAW); + bool LoadFile(const char *lpszFileName, uint32 dwCodec = FPCODEC_RAW); bool LoadFile(byte *lpBuf, uint32 dwCodec); bool LoadVoiceFromVDB(Common::File &vdbFP); diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 1415b86ef8..45545875e1 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -176,7 +176,7 @@ void TonyEngine::StopUtilSFX(int nChannel) { warning("TODO TonyEngine::StopUtilSFX"); } -void TonyEngine::PreloadSFX(int nChannel, char* fn) { +void TonyEngine::PreloadSFX(int nChannel, const char *fn) { if (m_sfx[nChannel] != NULL) { m_sfx[nChannel]->Stop(); m_sfx[nChannel]->Release(); @@ -205,7 +205,7 @@ FPSFX *TonyEngine::CreateSFX(byte *buf) { return sfx; } -void TonyEngine::PreloadUtilSFX(int nChannel, char *fn) { +void TonyEngine::PreloadUtilSFX(int nChannel, const char *fn) { warning("TonyEngine::PreloadUtilSFX"); } diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 95cd4fbbdc..51cfdf74f3 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -178,10 +178,10 @@ public: FPSFX *CreateSFX(byte *buf); - void PreloadSFX(int nSfx, char *fn); + void PreloadSFX(int nSfx, const char *fn); void UnloadAllSFX(void); - void PreloadUtilSFX(int nSfx, char *fn); + void PreloadUtilSFX(int nSfx, const char *fn); void UnloadAllUtilSFX(void); // Ferma tutta la parte audio @@ -194,7 +194,7 @@ public: void AutoSave(void); void SaveState(int n, const char *name); void LoadState(int n); - void GetSaveStateFileName(int n, char* buf); + void GetSaveStateFileName(int n, char *buf); // Prende il thumbnail void GrabThumbnail(void); diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index 7809d9c080..b7ecb3c0d4 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -1357,6 +1357,9 @@ void RMTony::EndTalk(void) { break; } break; + + default: + break; } // Gestisce la fine di una animazione static lasciando tutto invariato @@ -1634,6 +1637,9 @@ void RMTony::StartStatic(TALKTYPE nTalk) { m_nBodyOffset.Set(6, 56); break; } + + default: + break; } // e vai con i pattern @@ -1783,8 +1789,14 @@ void RMTony::EndStatic(TALKTYPE nTalk) { case RIGHT: headEndPat = PAT_SPAVENTORIGHT_END; break; + + default: + break; } break; + + default: + break; } if (headEndPat != 0) { -- cgit v1.2.3 From 9c2ccc4f9c0f4e27209ac876bf2112fd2a6e2987 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 4 May 2012 22:39:30 +1000 Subject: TONY: Further bugfixes for gcc warnings --- engines/tony/mpal/mpal.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index d767dbe381..55d70b2e18 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -97,7 +97,6 @@ typedef LPCFCALL* LPLPCFCALL; uint32 mpalError; -static bool bInit=false; static byte * lpMpcImage; LPITEMIRQFUNCTION lpiifCustom=NULL; @@ -786,11 +785,11 @@ static LPITEM GetItemData(uint32 nOrdItem) { patlength = dat; dat+=ret->numpattern; - for (i=1;inumpattern;i++) { - for (j=0;jpattern[i][j]=dat[j]; - ret->pattern[i][patlength[i]]=255; // Termina i pattern - dat+=patlength[i]; + for (i = 1; i < ret->numpattern; i++) { + for (j = 0; j < patlength[i]; j++) + ret->pattern[i][j] = dat[j]; + ret->pattern[i][(int)patlength[i]] = 255; // Termina i pattern + dat += patlength[i]; } // Carica i singoli frame di animazione @@ -2284,9 +2283,9 @@ bool bDontOutput; struct MsgCommentsStruct { uint16 wStart; uint16 wEnd; - char *pComment; + const char *pComment; }; -MsgCommentsStruct MsgComments[] = { +const MsgCommentsStruct MsgComments[] = { { 10, 16, "###" }, { 560, 563, "@@@ BUTCH & DUDLEY:" }, { 551, 553, "@@@ JACK'S LETTER (JACK'S VOICE):" }, @@ -2894,7 +2893,7 @@ const char *DLG600[] = { "Tony", "Jack", "Jack", NULL, "Jack", NULL, NULL, NULL, #define HANDLE_DIALOG(num) \ case num: \ - if (nPers >= sizeof(DLG##num) / sizeof(char*) || DLG##num[nPers]==NULL) \ + if (nPers >= (int)(sizeof(DLG##num) / sizeof(const char *)) || DLG##num[nPers] == NULL) \ { \ warning("ERROR: Il personaggio #%d non esiste nel dialogo %d!\n", nPers, nDlg); \ return "ERROR"; \ -- cgit v1.2.3 From 3184a5a874f3cfaa75424e7efb21f1cca3702988 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 4 May 2012 22:58:42 +1000 Subject: TONY: Fix warnings about return values not being used --- engines/tony/custom.cpp | 6 +++--- engines/tony/loc.cpp | 4 ++-- engines/tony/mpal/mpal.h | 11 ++++++++--- engines/tony/tonychar.cpp | 10 ++++++++++ engines/tony/window.cpp | 2 +- 5 files changed, 24 insertions(+), 9 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index d710667db6..3400235563 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -1833,7 +1833,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(uint32 nDialog, uint32 nStartGroup, uint32, curDialog = nDialog; // Chiama l'MPAL per iniziare il dialogo - mpalQueryDoDialog(nDialog,nStartGroup); + mpalQueryDoDialogU32(nDialog, nStartGroup); // Aspetta che una scelta si presenti while ((nChoice=mpalQueryDialogWaitForChoice()) != -1) { @@ -1844,7 +1844,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(uint32 nDialog, uint32 nStartGroup, uint32, // Se c'e' una sola opzione, la fa automaticamente, e aspetta la prossima scelta if (num == 1) { - mpalQueryDialogSelection(nChoice, sl[0]); + mpalQueryDialogSelectionU32(nChoice, sl[0]); GlobalFree(sl); continue; } @@ -1880,7 +1880,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(uint32 nDialog, uint32 nStartGroup, uint32, MainHideMouse(); dc.Hide(); - mpalQueryDialogSelection(nChoice, sl[sel]); + mpalQueryDialogSelectionU32(nChoice, sl[sel]); // Chiude la scelta dc.Close(); diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 84e56a108d..62249da255 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -1349,7 +1349,7 @@ void RMCharacter::NewBoxEntered(int nBox) { bool bOldReverse; // Richiama la On ExitBox - mpalQueryDoAction(3, curLocation, curbox); + mpalQueryDoActionU32(3, curLocation, curbox); cur = theBoxes->GetBoxes(curLocation); bOldReverse = cur->boxes[curbox].bReversed; @@ -1383,7 +1383,7 @@ void RMCharacter::NewBoxEntered(int nBox) { } // Richiama la On EnterBox - mpalQueryDoAction(2, curLocation, curbox); + mpalQueryDoActionU32(2, curLocation, curbox); } void RMCharacter::DoFrame(RMGfxTargetBuffer* bigBuf, int loc) { diff --git a/engines/tony/mpal/mpal.h b/engines/tony/mpal/mpal.h index d800be60b8..e66f1fdb7e 100644 --- a/engines/tony/mpal/mpal.h +++ b/engines/tony/mpal/mpal.h @@ -523,7 +523,8 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; #define mpalQueryDialogSelection(nChoice,dwData) \ (bool)mpalQuery(MPQ_DIALOG_SELECTION,(uint32)(nChoice),(uint32)(dwData)) - +#define mpalQueryDialogSelectionU32(nChoice, dwData) \ + mpalQuery(MPQ_DIALOG_SELECTION,(uint32)(nChoice),(uint32)(dwData)) /****************************************************************************\ * @@ -547,9 +548,11 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * \****************************************************************************/ -#define mpalQueryDoAction(nAction,nItem,dwParam) \ - (HANDLE)mpalQuery(MPQ_DO_ACTION,(uint32)(nAction),(uint32)(nItem),(uint32)(dwParam)) +#define mpalQueryDoAction(nAction, nItem, dwParam) \ + (HANDLE)mpalQuery(MPQ_DO_ACTION, (uint32)(nAction), (uint32)(nItem), (uint32)(dwParam)) +#define mpalQueryDoActionU32(nAction, nItem, dwParam) \ + mpalQuery(MPQ_DO_ACTION, (uint32)(nAction), (uint32)(nItem), (uint32)(dwParam)) /****************************************************************************\ @@ -569,6 +572,8 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; #define mpalQueryDoDialog(nDialog,nGroup) \ (HANDLE)mpalQuery(MPQ_DO_DIALOG,(uint32)(nDialog),(uint32)(nGroup)) +#define mpalQueryDoDialogU32(nDialog, nGroup) \ + mpalQuery(MPQ_DO_DIALOG,(uint32)(nDialog),(uint32)(nGroup)) /****************************************************************************\ diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index b7ecb3c0d4..12a8c8eabb 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -1061,6 +1061,9 @@ void RMTony::StartTalk(TALKTYPE nTalkType) { headStartPat = PAT_SPAVENTOLEFT_STAND; headLoopPat = PAT_SPAVENTOLEFT_LOOP; break; + + default: + break; } break; } @@ -1355,6 +1358,10 @@ void RMTony::EndTalk(void) { headStandPat = PAT_SPAVENTOLEFT_STAND; bodyEndPat = 0; break; + + + default: + break; } break; @@ -1636,6 +1643,9 @@ void RMTony::StartStatic(TALKTYPE nTalk) { headLoopPat = PAT_SPAVENTORIGHT_STAND; m_nBodyOffset.Set(6, 56); break; + + default: + break; } default: diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index 248542ada6..41821ccacc 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -252,7 +252,7 @@ void RMWindow::Init(/*HINSTANCE hInst*/) { //hWaitFlip = CreateEvent(NULL,false,false, NULL); #endif -}; +} void RMWindow::Close(void) { DDClose(); -- cgit v1.2.3 From e628da0cccbba04c9d19b28b46e97107ab66beb7 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 4 May 2012 23:20:01 +1000 Subject: TONY: Fix some inconsistent allocation/deallocations --- engines/tony/mpal/memory.cpp | 6 +++--- engines/tony/mpal/memory.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/memory.cpp b/engines/tony/mpal/memory.cpp index 604e61ed24..de6e918a38 100644 --- a/engines/tony/mpal/memory.cpp +++ b/engines/tony/mpal/memory.cpp @@ -127,9 +127,9 @@ uint32 MemoryManager::getSize(HGLOBAL handle) { /** * Erases a given item */ -void MemoryManager::erase(MemoryItem &item) { +void MemoryManager::erase(MemoryItem *item) { delete item; - _memoryBlocks.remove(&item); + _memoryBlocks.remove(item); } /** @@ -137,7 +137,7 @@ void MemoryManager::erase(MemoryItem &item) { */ void MemoryManager::erase(HGLOBAL handle) { MemoryItem &item = getItem(handle); - erase(item); + erase(&item); } } // end of namespace MPAL diff --git a/engines/tony/mpal/memory.h b/engines/tony/mpal/memory.h index fde0d33b3e..ebf42b6207 100644 --- a/engines/tony/mpal/memory.h +++ b/engines/tony/mpal/memory.h @@ -36,14 +36,14 @@ typedef HANDLE HGLOBAL; class MemoryItem { protected: - void *_buffer; + byte *_buffer; uint32 _size; public: MemoryItem(uint32 size); virtual ~MemoryItem(); uint32 Size() { return _size; } - void *DataPointer() { return _buffer; } + void *DataPointer() { return (void *)_buffer; } bool IsValid() { return _buffer != NULL; } // Casting for access to data @@ -61,7 +61,7 @@ public: HGLOBAL alloc(uint32 size); MemoryItem &getItem(HGLOBAL handle); MemoryItem &operator[](HGLOBAL handle); - void erase(MemoryItem &item); + void erase(MemoryItem *item); void erase(HGLOBAL handle); uint32 getSize(HANDLE handle); -- cgit v1.2.3 From 5ab27cdacd0b93e4c1de613833edf1894820d2b4 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 4 May 2012 23:38:34 +1000 Subject: TONY: Fix Valgrind identified leaks in memory allocator and dialog parsing --- engines/tony/mpal/loadmpc.cpp | 115 ++++++++++++++++++++++-------------------- 1 file changed, 59 insertions(+), 56 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index 484f1ad2a0..c88f485b95 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -66,7 +66,7 @@ namespace MPAL { static bool CompareCommands(struct command *cmd1, struct command *cmd2) { if (cmd1->type == 2 && cmd2->type == 2) { - if (strcmp(cmd1->lpszVarName,cmd2->lpszVarName)==0 && + if (strcmp(cmd1->lpszVarName, cmd2->lpszVarName) == 0 && CompareExpressions(cmd1->expr,cmd2->expr)) return true; else @@ -169,94 +169,97 @@ static byte *ParseDialog(byte *lpBuf, LPMPALDIALOG lpmdDialog) { uint32 curCmd; uint32 len; - lpmdDialog->nObj=*(int *)lpBuf; - lpBuf+=4; + lpmdDialog->nObj = READ_LE_UINT32(lpBuf); + lpBuf += 4; /* Periodi */ - num=*(uint16 *)lpBuf; lpBuf+=2; + num = READ_LE_UINT16(lpBuf); lpBuf += 2; - if (num >= MAX_PERIODS_PER_DIALOG-1) { - Common::String msg = Common::String::format("Too much periods in dialog #%d",lpmdDialog->nObj); + if (num >= MAX_PERIODS_PER_DIALOG - 1) { + Common::String msg = Common::String::format("Too much periods in dialog #%d", lpmdDialog->nObj); MessageBox(msg); } - for (i=0;iPeriodNums[i]=*(uint16 *)lpBuf; lpBuf+=2; - lpmdDialog->Periods[i]=GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT,*lpBuf+1); + for (i = 0; i < num; i++) { + lpmdDialog->PeriodNums[i] = READ_LE_UINT16(lpBuf); lpBuf += 2; + lpmdDialog->Periods[i] = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, *lpBuf + 1); lpLock = (byte *)GlobalLock(lpmdDialog->Periods[i]); - CopyMemory(lpLock,lpBuf+1,*lpBuf); + Common::copy(lpBuf + 1, lpBuf + 1 + *lpBuf, lpLock); + lpLock[*lpBuf] = '\0'; GlobalUnlock(lpmdDialog->Periods[i]); - lpBuf+=(*lpBuf)+1; + lpBuf += (*lpBuf) + 1; } - lpmdDialog->PeriodNums[i]=0; - lpmdDialog->Periods[i]=NULL; + lpmdDialog->PeriodNums[i] = 0; + lpmdDialog->Periods[i] = NULL; /* Gruppi */ - num=*(uint16 *)lpBuf; lpBuf+=2; - curCmd=0; + num = READ_LE_UINT16(lpBuf); lpBuf += 2; + curCmd = 0; if (num >= MAX_GROUPS_PER_DIALOG) { - Common::String msg = Common::String::format("Too much groups in dialog #%d",lpmdDialog->nObj); + Common::String msg = Common::String::format("Too much groups in dialog #%d", lpmdDialog->nObj); MessageBox(msg); } - for (i=0;iGroup[i].num=*(uint16 *)lpBuf; lpBuf+=2; - lpmdDialog->Group[i].nCmds=*lpBuf; lpBuf++; + for (i = 0; i < num; i++) { + lpmdDialog->Group[i].num = READ_LE_UINT16(lpBuf); lpBuf += 2; + lpmdDialog->Group[i].nCmds = *lpBuf; lpBuf++; if (lpmdDialog->Group[i].nCmds >= MAX_COMMANDS_PER_GROUP) { Common::String msg = Common::String::format("Too much commands in group #%d in dialog #%d",lpmdDialog->Group[i].num,lpmdDialog->nObj); MessageBox(msg); } - for (j=0;jGroup[i].nCmds;j++) { - lpmdDialog->Command[curCmd].type=*lpBuf; + for (j = 0; j < lpmdDialog->Group[i].nCmds; j++) { + lpmdDialog->Command[curCmd].type = *lpBuf; lpBuf++; switch (lpmdDialog->Command[curCmd].type) { // Call custom function case 1: - lpmdDialog->Command[curCmd].nCf =*(uint16 *)(lpBuf); lpBuf+=2; - lpmdDialog->Command[curCmd].arg1=*(int *)(lpBuf); lpBuf+=4; - lpmdDialog->Command[curCmd].arg2=*(int *)(lpBuf); lpBuf+=4; - lpmdDialog->Command[curCmd].arg3=*(int *)(lpBuf); lpBuf+=4; - lpmdDialog->Command[curCmd].arg4=*(int *)(lpBuf); lpBuf+=4; + lpmdDialog->Command[curCmd].nCf = READ_LE_UINT16(lpBuf); lpBuf += 2; + lpmdDialog->Command[curCmd].arg1 = READ_LE_UINT32(lpBuf); lpBuf += 4; + lpmdDialog->Command[curCmd].arg2 = READ_LE_UINT32(lpBuf); lpBuf += 4; + lpmdDialog->Command[curCmd].arg3 = READ_LE_UINT32(lpBuf); lpBuf += 4; + lpmdDialog->Command[curCmd].arg4 = READ_LE_UINT32(lpBuf); lpBuf += 4; break; // Variable assign case 2: - len=*lpBuf; + len = *lpBuf; lpBuf++; - lpmdDialog->Command[curCmd].lpszVarName=(char *)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,len+1); - if (lpmdDialog->Command[curCmd].lpszVarName==NULL) + lpmdDialog->Command[curCmd].lpszVarName = (char *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, len + 1); + if (lpmdDialog->Command[curCmd].lpszVarName == NULL) return NULL; - CopyMemory(lpmdDialog->Command[curCmd].lpszVarName,lpBuf,len); - lpBuf+=len; - lpBuf=ParseExpression(lpBuf,&lpmdDialog->Command[curCmd].expr); - if (lpBuf==NULL) + Common::copy(lpBuf, lpBuf + len, lpmdDialog->Command[curCmd].lpszVarName); + lpmdDialog->Command[curCmd].lpszVarName[len] = '\0'; + lpBuf += len; + + lpBuf=ParseExpression(lpBuf, &lpmdDialog->Command[curCmd].expr); + if (lpBuf == NULL) return NULL; break; // Do Choice case 3: - lpmdDialog->Command[curCmd].nChoice=*(uint16 *)lpBuf; lpBuf+=2; + lpmdDialog->Command[curCmd].nChoice = READ_LE_UINT16(lpBuf); lpBuf += 2; break; default: return NULL; } - for (kk=0;kkCommand[kk],&lpmdDialog->Command[curCmd])) { - lpmdDialog->Group[i].CmdNum[j]=kk; + for (kk = 0;kk < curCmd; kk++) { + if (CompareCommands(&lpmdDialog->Command[kk], &lpmdDialog->Command[curCmd])) { + lpmdDialog->Group[i].CmdNum[j] = kk; break; } } - if (kk==curCmd) { - lpmdDialog->Group[i].CmdNum[j]=curCmd; + if (kk == curCmd) { + lpmdDialog->Group[i].CmdNum[j] = curCmd; curCmd++; } } @@ -268,33 +271,33 @@ static byte *ParseDialog(byte *lpBuf, LPMPALDIALOG lpmdDialog) { } /* Choices */ - num=*(uint16 *)lpBuf; lpBuf+=2; + num=*(uint16 *)lpBuf; lpBuf += 2; if (num >= MAX_CHOICES_PER_DIALOG) { Common::String msg = Common::String::format("Too much choices in dialog #%d",lpmdDialog->nObj); MessageBox(msg); } - for (i=0;iChoice[i].nChoice=*(uint16 *)lpBuf; lpBuf+=2; + for (i = 0; i < num; i++) { + lpmdDialog->Choice[i].nChoice = READ_LE_UINT16(lpBuf); lpBuf += 2; - num2=*lpBuf++; + num2 = *lpBuf++; if (num2 >= MAX_SELECTS_PER_CHOICE) { Common::String msg = Common::String::format("Too much selects in choice #%d in dialog #%d",lpmdDialog->Choice[i].nChoice,lpmdDialog->nObj); MessageBox(msg); } - for (j=0;jChoice[i].Select[j].when=NULL; + lpmdDialog->Choice[i].Select[j].when = NULL; break; case 1: - lpBuf=ParseExpression(lpBuf,&lpmdDialog->Choice[i].Select[j].when); - if (lpBuf==NULL) + lpBuf = ParseExpression(lpBuf,&lpmdDialog->Choice[i].Select[j].when); + if (lpBuf == NULL) return NULL; break; @@ -303,31 +306,31 @@ static byte *ParseDialog(byte *lpBuf, LPMPALDIALOG lpmdDialog) { } // Attrib - lpmdDialog->Choice[i].Select[j].attr=*lpBuf++; + lpmdDialog->Choice[i].Select[j].attr = *lpBuf++; // Data - lpmdDialog->Choice[i].Select[j].dwData=*(uint32 *)lpBuf; lpBuf+=4; + lpmdDialog->Choice[i].Select[j].dwData = READ_LE_UINT32(lpBuf); lpBuf += 4; // PlayGroup - num3=*lpBuf; *lpBuf++; + num3 = *lpBuf; *lpBuf++; if (num3 >= MAX_PLAYGROUPS_PER_SELECT) { - Common::String msg = Common::String::format("Too much playgroups in select #%d in choice #%d in dialog #%d",j,lpmdDialog->Choice[i].nChoice,lpmdDialog->nObj); + Common::String msg = Common::String::format("Too much playgroups in select #%d in choice #%d in dialog #%d", j, lpmdDialog->Choice[i].nChoice, lpmdDialog->nObj); MessageBox(msg); } - for (z=0;zChoice[i].Select[j].wPlayGroup[z]=*(uint16 *)lpBuf; lpBuf+=2; + for (z = 0; z < num3; z++) { + lpmdDialog->Choice[i].Select[j].wPlayGroup[z] = READ_LE_UINT16(lpBuf); lpBuf += 2; } - lpmdDialog->Choice[i].Select[j].wPlayGroup[num3]=0; + lpmdDialog->Choice[i].Select[j].wPlayGroup[num3] = 0; } // Segna l'ultimo select - lpmdDialog->Choice[i].Select[num2].dwData=0; + lpmdDialog->Choice[i].Select[num2].dwData = 0; } - lpmdDialog->Choice[num].nChoice=0; + lpmdDialog->Choice[num].nChoice = 0; return lpBuf; } -- cgit v1.2.3 From a511b828e416c657e01a86e931016d4a4b7d49b9 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 5 May 2012 00:29:44 +1000 Subject: TONY: Initial fixes for some of the Valgrind reported errors --- engines/tony/mpal/expr.cpp | 10 +-- engines/tony/mpal/expr.h | 2 +- engines/tony/mpal/loadmpc.cpp | 173 ++++++++++++++++++++---------------------- engines/tony/mpal/loadmpc.h | 2 +- engines/tony/mpal/memory.cpp | 12 ++- engines/tony/mpal/memory.h | 8 +- engines/tony/mpal/mpal.cpp | 2 +- 7 files changed, 105 insertions(+), 104 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/expr.cpp b/engines/tony/mpal/expr.cpp index 2f0e890af9..0ca02d2931 100644 --- a/engines/tony/mpal/expr.cpp +++ b/engines/tony/mpal/expr.cpp @@ -306,18 +306,18 @@ static int EvaluateAndFreeExpression(byte *expr) { * \****************************************************************************/ -byte *ParseExpression(byte *lpBuf, HGLOBAL *h) { +const byte *ParseExpression(const byte *lpBuf, HGLOBAL *h) { LPEXPRESSION cur; byte *start; uint32 num, i; - num=*lpBuf; + num = *lpBuf; lpBuf++; - if (num==0) + if (num == 0) return NULL; - *h=GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT,num*sizeof(EXPRESSION)+1); + *h = GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT, num * sizeof(EXPRESSION) + 1); if (*h==NULL) return NULL; @@ -441,7 +441,7 @@ bool CompareExpressions(HGLOBAL h1, HGLOBAL h2) { break; case ELT_VAR: - if (strcmp(one->val.name, two->val.name)!=0) { + if (strcmp(one->val.name, two->val.name) != 0) { GlobalUnlock(h1); GlobalUnlock(h2); return false; diff --git a/engines/tony/mpal/expr.h b/engines/tony/mpal/expr.h index d54f17b088..582f6d381d 100644 --- a/engines/tony/mpal/expr.h +++ b/engines/tony/mpal/expr.h @@ -76,7 +76,7 @@ namespace MPAL { * \****************************************************************************/ -byte *ParseExpression(byte *lpBuf, HGLOBAL *h); +const byte *ParseExpression(const byte *lpBuf, HGLOBAL *h); /****************************************************************************\ diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index c88f485b95..b08a5f2b3d 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -67,12 +67,12 @@ namespace MPAL { static bool CompareCommands(struct command *cmd1, struct command *cmd2) { if (cmd1->type == 2 && cmd2->type == 2) { if (strcmp(cmd1->lpszVarName, cmd2->lpszVarName) == 0 && - CompareExpressions(cmd1->expr,cmd2->expr)) + CompareExpressions(cmd1->expr, cmd2->expr)) return true; else return false; } else - return (memcmp(cmd1,cmd2,sizeof(struct command))==0); + return (memcmp(cmd1, cmd2, sizeof(struct command)) == 0); } @@ -92,7 +92,7 @@ static bool CompareCommands(struct command *cmd1, struct command *cmd2) { * \****************************************************************************/ -static byte *ParseScript(byte *lpBuf, LPMPALSCRIPT lpmsScript) { +static const byte *ParseScript(const byte *lpBuf, LPMPALSCRIPT lpmsScript) { int curCmd,j,len; uint i; @@ -127,7 +127,7 @@ static byte *ParseScript(byte *lpBuf, LPMPALSCRIPT lpmsScript) { CopyMemory(lpmsScript->Command[curCmd].lpszVarName, lpBuf, len); lpBuf+=len; - lpBuf=ParseExpression(lpBuf,&lpmsScript->Command[curCmd].expr); + lpBuf = ParseExpression(lpBuf, &lpmsScript->Command[curCmd].expr); if (lpBuf==NULL) return NULL; break; @@ -162,16 +162,13 @@ static byte *ParseScript(byte *lpBuf, LPMPALSCRIPT lpmsScript) { * \****************************************************************************/ -static byte *ParseDialog(byte *lpBuf, LPMPALDIALOG lpmdDialog) { +static const byte *ParseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { uint32 i,j,z,kk; uint32 num,num2,num3; byte *lpLock; uint32 curCmd; uint32 len; - lpmdDialog->nObj = READ_LE_UINT32(lpBuf); - lpBuf += 4; - /* Periodi */ num = READ_LE_UINT16(lpBuf); lpBuf += 2; @@ -185,7 +182,6 @@ static byte *ParseDialog(byte *lpBuf, LPMPALDIALOG lpmdDialog) { lpmdDialog->Periods[i] = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, *lpBuf + 1); lpLock = (byte *)GlobalLock(lpmdDialog->Periods[i]); Common::copy(lpBuf + 1, lpBuf + 1 + *lpBuf, lpLock); - lpLock[*lpBuf] = '\0'; GlobalUnlock(lpmdDialog->Periods[i]); lpBuf += (*lpBuf) + 1; } @@ -234,10 +230,9 @@ static byte *ParseDialog(byte *lpBuf, LPMPALDIALOG lpmdDialog) { return NULL; Common::copy(lpBuf, lpBuf + len, lpmdDialog->Command[curCmd].lpszVarName); - lpmdDialog->Command[curCmd].lpszVarName[len] = '\0'; lpBuf += len; - lpBuf=ParseExpression(lpBuf, &lpmdDialog->Command[curCmd].expr); + lpBuf = ParseExpression(lpBuf, &lpmdDialog->Command[curCmd].expr); if (lpBuf == NULL) return NULL; break; @@ -355,7 +350,7 @@ static byte *ParseDialog(byte *lpBuf, LPMPALDIALOG lpmdDialog) { * \****************************************************************************/ -static byte *ParseItem(byte *lpBuf, LPMPALITEM lpmiItem) { +static const byte *ParseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { byte len; uint32 i,j,kk; uint32 curCmd; @@ -403,8 +398,8 @@ static byte *ParseItem(byte *lpBuf, LPMPALITEM lpmiItem) { lpmiItem->Action[i].when=NULL; } else { lpBuf++; - lpBuf=ParseExpression(lpBuf,&lpmiItem->Action[i].when); - if (lpBuf==NULL) + lpBuf = ParseExpression(lpBuf,&lpmiItem->Action[i].when); + if (lpBuf == NULL) return NULL; } @@ -489,7 +484,7 @@ static byte *ParseItem(byte *lpBuf, LPMPALITEM lpmiItem) { * \****************************************************************************/ -static byte *ParseLocation(byte *lpBuf, LPMPALLOCATION lpmlLocation) { +static const byte *ParseLocation(const byte *lpBuf, LPMPALLOCATION lpmlLocation) { lpmlLocation->nObj=*(int *)lpBuf; lpBuf+=4; lpmlLocation->dwXlen=*(uint16 *)lpBuf; @@ -529,32 +524,32 @@ static byte *ParseLocation(byte *lpBuf, LPMPALLOCATION lpmlLocation) { * \****************************************************************************/ -bool ParseMpc(byte *lpBuf) { +bool ParseMpc(const byte *lpBuf) { uint16 i, j; uint16 wLen; byte *lpTemp, *lpTemp2; /* 1. Variabili */ - if (lpBuf[0]!='V' || lpBuf[1]!='A' || lpBuf[2]!='R' || lpBuf[3]!='S') + if (lpBuf[0] != 'V' || lpBuf[1] != 'A' || lpBuf[2] != 'R' || lpBuf[3] != 'S') return false; - lpBuf+=4; - nVars=*(uint16 *)lpBuf; - lpBuf+=2; + lpBuf += 4; + nVars = READ_LE_UINT16(lpBuf); + lpBuf += 2; - hVars=GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT,sizeof(MPALVAR)*(uint32)nVars); - if (hVars==NULL) + hVars = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof(MPALVAR) * (uint32)nVars); + if (hVars == NULL) return false; - lpmvVars=(LPMPALVAR)GlobalLock(hVars); + lpmvVars = (LPMPALVAR)GlobalLock(hVars); - for (i=0;ilpszVarName,lpBuf,MIN(wLen, (uint16)32)); - lpBuf+=wLen; - lpmvVars->dwVal=*(int *)lpBuf; - lpBuf+=4; + CopyMemory(lpmvVars->lpszVarName, lpBuf, MIN(wLen, (uint16)32)); + lpBuf += wLen; + lpmvVars->dwVal = READ_LE_UINT32(lpBuf); + lpBuf += 4; lpBuf++; // Salta 'ext' lpmvVars++; @@ -563,44 +558,44 @@ bool ParseMpc(byte *lpBuf) { GlobalUnlock(hVars); /* 2. Messaggi */ - if (lpBuf[0]!='M' || lpBuf[1]!='S' || lpBuf[2]!='G' || lpBuf[3]!='S') + if (lpBuf[0] != 'M' || lpBuf[1] != 'S' || lpBuf[2] != 'G' || lpBuf[3] != 'S') return false; - lpBuf+=4; - nMsgs=*(uint16 *)lpBuf; - lpBuf+=2; + lpBuf += 4; + nMsgs = READ_LE_UINT16(lpBuf); + lpBuf += 2; #ifdef NEED_LOCK_MSGS - hMsgs=GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT,sizeof(MPALMSG)*(uint32)nMsgs); - if (hMsgs==NULL) + hMsgs = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof(MPALMSG) * (uint32)nMsgs); + if (hMsgs == NULL) return false; - lpmmMsgs=(LPMPALMSG)GlobalLock(hMsgs); + lpmmMsgs = (LPMPALMSG)GlobalLock(hMsgs); #else lpmmMsgs=(LPMPALMSG)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,sizeof(MPALMSG)*(uint32)nMsgs); if (lpmmMsgs==NULL) return false; #endif - for (i=0;iwNum=*(uint16 *)lpBuf; - lpBuf+=2; + for (i = 0; i < nMsgs; i++) { + lpmmMsgs->wNum = READ_LE_UINT16(lpBuf); + lpBuf += 2; - for (j=0;lpBuf[j]!=0;) - j+=lpBuf[j]+1; + for (j = 0; lpBuf[j] != 0;) + j += lpBuf[j] + 1; - lpmmMsgs->hText=GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT,j+1); - lpTemp2=lpTemp=(byte *)GlobalLock(lpmmMsgs->hText); + lpmmMsgs->hText = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, j + 1); + lpTemp2 = lpTemp = (byte *)GlobalLock(lpmmMsgs->hText); - for (j=0;lpBuf[j]!=0;) { - CopyMemory(lpTemp,&lpBuf[j+1],lpBuf[j]); - lpTemp+=lpBuf[j]; - *lpTemp++='\0'; - j+=lpBuf[j]+1; + for (j = 0; lpBuf[j] != 0;) { + CopyMemory(lpTemp, &lpBuf[j + 1], lpBuf[j]); + lpTemp += lpBuf[j]; + *lpTemp ++= '\0'; + j += lpBuf[j] + 1; } - lpBuf+=j+1; - *lpTemp='\0'; + lpBuf += j + 1; + *lpTemp = '\0'; GlobalUnlock(lpmmMsgs->hText); lpmmMsgs++; @@ -611,87 +606,87 @@ bool ParseMpc(byte *lpBuf) { #endif /* 3. Oggetti */ - if (lpBuf[0]!='O' || lpBuf[1]!='B' || lpBuf[2]!='J' || lpBuf[3]!='S') + if (lpBuf[0] != 'O' || lpBuf[1] != 'B' || lpBuf[2] != 'J' || lpBuf[3] != 'S') return false; - lpBuf+=4; - nObjs=*(uint16 *)lpBuf; - lpBuf+=2; + lpBuf += 4; + nObjs = READ_LE_UINT16(lpBuf); + lpBuf += 2; // Controlla i dialoghi - nDialogs=0; - hDialogs=lpmdDialogs=NULL; - if (*((const char *)lpBuf+2)==6 && strncmp((const char *)lpBuf+3,"Dialog",6)==0) { - nDialogs=*(uint16 *)lpBuf; lpBuf+=2; + nDialogs = 0; + hDialogs = lpmdDialogs = NULL; + if (*((const byte *)lpBuf + 2) == 6 && strncmp((const char *)lpBuf + 3, "Dialog", 6) == 0) { + nDialogs = READ_LE_UINT16(lpBuf); lpBuf += 2; - hDialogs=GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT,(uint32)nDialogs*sizeof(MPALDIALOG)); - if (hDialogs==NULL) + hDialogs = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)nDialogs * sizeof(MPALDIALOG)); + if (hDialogs == NULL) return false; - lpmdDialogs=(LPMPALDIALOG)GlobalLock(hDialogs); + lpmdDialogs = (LPMPALDIALOG)GlobalLock(hDialogs); - for (i=0;iDataPointer(); + Common::fill(dataP, dataP + size, 0); + } + _memoryBlocks.push_back(newItem); return *newItem; @@ -88,8 +94,8 @@ MemoryItem &MemoryManager::allocate(uint32 size) { * Allocates a new memory block and returns it's data pointer * @returns Data pointer to allocated block */ -HGLOBAL MemoryManager::alloc(uint32 size) { - MemoryItem &newItem = allocate(size); +HGLOBAL MemoryManager::alloc(uint32 size, uint flags) { + MemoryItem &newItem = allocate(size, flags); return (HGLOBAL)newItem.DataPointer(); } diff --git a/engines/tony/mpal/memory.h b/engines/tony/mpal/memory.h index ebf42b6207..6fd55e7ce5 100644 --- a/engines/tony/mpal/memory.h +++ b/engines/tony/mpal/memory.h @@ -57,8 +57,8 @@ public: MemoryManager(); virtual ~MemoryManager(); - MemoryItem &allocate(uint32 size); - HGLOBAL alloc(uint32 size); + MemoryItem &allocate(uint32 size, uint flags); + HGLOBAL alloc(uint32 size, uint flags); MemoryItem &getItem(HGLOBAL handle); MemoryItem &operator[](HGLOBAL handle); void erase(MemoryItem *item); @@ -68,8 +68,8 @@ public: }; // defines -#define GlobalAlloc(flags, size) _vm->_memoryManager.alloc(size) -#define GlobalAllocate(size) _vm->_memoryManager.allocate(size) +#define GlobalAlloc(flags, size) _vm->_memoryManager.alloc(size, flags) +#define GlobalAllocate(size) _vm->_memoryManager.allocate(size, 0) #define GlobalFree(handle) _vm->_memoryManager.erase(handle) #define GlobalLock(handle) (_vm->_memoryManager.getItem(handle).DataPointer()) #define GlobalUnlock(handle) {} diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 55d70b2e18..ec38083a76 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -1735,7 +1735,7 @@ bool mpalInit(const char * lpszMpcFileName, const char * lpszMprFileName, LPLPCU hMpc.close(); /* Parsa l'immagine */ - if (ParseMpc(lpMpcImage)==false) + if (ParseMpc(lpMpcImage) == false) return false; GlobalFree(lpMpcImage); -- cgit v1.2.3 From fe0fa0f86b44d6f6766386fa070c84c6f358ccb9 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 5 May 2012 00:35:16 +1000 Subject: TONY: Added accidentally cut line --- engines/tony/mpal/loadmpc.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'engines') diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index b08a5f2b3d..cdcf91abc4 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -169,6 +169,8 @@ static const byte *ParseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { uint32 curCmd; uint32 len; + lpmdDialog->nObj = READ_LE_UINT32(lpBuf); lpBuf += 4; + /* Periodi */ num = READ_LE_UINT16(lpBuf); lpBuf += 2; -- cgit v1.2.3 From 3454a0a9c3738b09ac8de417297cb1f8adb0d2da Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 5 May 2012 00:40:23 +1000 Subject: TONY: A few more compiler warning fixes --- engines/tony/gfxengine.cpp | 2 +- engines/tony/mpal/loadmpc.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index dd557efafd..6b5105bc35 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -934,7 +934,7 @@ void RMGfxEngine::LoadState(const char *fn) { // Le versioni vecchie necessitano di On enter if (ver < 5) - mpalQueryDoAction(0, loc, 0); + mpalQueryDoActionU32(0, loc, 0); else { // In quelle nuove, ci basta resettare gli mcode MCharResetCodes(); diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index cdcf91abc4..27ef3f99c5 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -546,7 +546,7 @@ bool ParseMpc(const byte *lpBuf) { lpmvVars = (LPMPALVAR)GlobalLock(hVars); for (i = 0; i < nVars; i++) { - wLen=*(byte *)lpBuf; + wLen = *(const byte *)lpBuf; lpBuf++; CopyMemory(lpmvVars->lpszVarName, lpBuf, MIN(wLen, (uint16)32)); lpBuf += wLen; -- cgit v1.2.3 From 657d93ea8f5e123024c4618b8a3dc441a9f45cbc Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 5 May 2012 09:31:21 +1000 Subject: TONY: Fix some Valgrind identified warnings --- engines/tony/font.cpp | 562 +++++++++++++++++++++++----------------------- engines/tony/gfxcore.cpp | 4 +- engines/tony/tonychar.cpp | 22 +- 3 files changed, 294 insertions(+), 294 deletions(-) (limited to 'engines') diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index ec5a78731b..c4f589a21d 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -286,38 +286,38 @@ void RMFontParla::Init(void) { cTable['\"'] = 77; cTable['^'] = 77; cTable['/'] = 78; - cTable[''] = 79; + cTable[(byte)''] = 79; cTable['$'] = 80; cTable['%'] = 81; cTable['&'] = 82; cTable['='] = 83; - cTable[''] = 84; - cTable[''] = 85; - cTable[''] = 86; - cTable[''] = 87; - cTable[''] = 88; - cTable[''] = 89; - cTable[''] = 89; - cTable[''] = 90; - cTable[''] = 91; - cTable[''] = 92; - cTable[''] = 93; - cTable[''] = 94; - cTable[''] = 95; - cTable[''] = 96; - cTable[''] = 97; - cTable[''] = 98; - cTable[''] = 99; + cTable[(byte)''] = 84; + cTable[(byte)''] = 85; + cTable[(byte)''] = 86; + cTable[(byte)''] = 87; + cTable[(byte)''] = 88; + cTable[(byte)''] = 89; + cTable[(byte)''] = 89; + cTable[(byte)''] = 90; + cTable[(byte)''] = 91; + cTable[(byte)''] = 92; + cTable[(byte)''] = 93; + cTable[(byte)''] = 94; + cTable[(byte)''] = 95; + cTable[(byte)''] = 96; + cTable[(byte)''] = 97; + cTable[(byte)''] = 98; + cTable[(byte)''] = 99; //cTable[' '] = 100; e cerchietto //cTable[' '] = 101; i cerchietto //cTable[' '] = 102; o cerchietto //cTable[' '] = 103; u cerchietto - cTable[''] = 104; - cTable[''] = 105; - cTable[''] = 106; - cTable[''] = 107; - cTable[''] = 108; - cTable[''] = 109; + cTable[(byte)''] = 104; + cTable[(byte)''] = 105; + cTable[(byte)''] = 106; + cTable[(byte)''] = 107; + cTable[(byte)''] = 108; + cTable[(byte)''] = 109; //cTable[''] = 110; integrale cTable['\''] = 111; @@ -359,43 +359,43 @@ void RMFontParla::Init(void) { //AaCcEeLlNnOoSsZzZz //ス謎戊3剔囀 - cTable[''] = 112; - cTable[''] = 113; - cTable[''] = 114; - cTable[''] = 115; - cTable[''] = 116; - cTable[''] = 117; - cTable[''] = 118; - cTable[''] = 119; - cTable[''] = 120; - cTable[''] = 121; - cTable[''] = 122; - cTable[''] = 123; - cTable[''] = 124; - cTable[''] = 125; - cTable[''] = 126; - cTable[''] = 127; - cTable[''] = 128; - cTable[''] = 129; - - lTable[''] = 14; - lTable[''] = 16; - lTable[''] = 12; - lTable[''] = 12; - lTable[''] = 11; - lTable[''] = 12; - lTable[''] = 14; - lTable[''] = 9; - lTable[''] = 10; - lTable[''] = 11; - lTable[''] = 13; - lTable[''] = 11; - lTable[''] = 12; - lTable[''] = 12; - lTable[''] = 13; - lTable[''] = 13; - lTable[''] = 14; - lTable[''] = 13; + cTable[(byte)''] = 112; + cTable[(byte)''] = 113; + cTable[(byte)''] = 114; + cTable[(byte)''] = 115; + cTable[(byte)''] = 116; + cTable[(byte)''] = 117; + cTable[(byte)''] = 118; + cTable[(byte)''] = 119; + cTable[(byte)''] = 120; + cTable[(byte)''] = 121; + cTable[(byte)''] = 122; + cTable[(byte)''] = 123; + cTable[(byte)''] = 124; + cTable[(byte)''] = 125; + cTable[(byte)''] = 126; + cTable[(byte)''] = 127; + cTable[(byte)''] = 128; + cTable[(byte)''] = 129; + + lTable[(byte)''] = 14; + lTable[(byte)''] = 16; + lTable[(byte)''] = 12; + lTable[(byte)''] = 12; + lTable[(byte)''] = 11; + lTable[(byte)''] = 12; + lTable[(byte)''] = 14; + lTable[(byte)''] = 9; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 13; + lTable[(byte)''] = 11; + lTable[(byte)''] = 12; + lTable[(byte)''] = 12; + lTable[(byte)''] = 13; + lTable[(byte)''] = 13; + lTable[(byte)''] = 14; + lTable[(byte)''] = 13; #ifdef FONT_RUSSIAN // Russian Characters @@ -403,241 +403,241 @@ void RMFontParla::Init(void) { // per le altre traduzioni. Per compilare Tony in altre lingue, // commentare via queste definizioni. - cTable[''] = 130; - cTable[''] = 131; - cTable[''] = 132; - cTable[''] = 133; - cTable[''] = 134; - cTable[''] = 135; - cTable[''] = 136; - cTable[''] = 137; - cTable[''] = 138; - cTable[''] = 139; - cTable[''] = 140; - cTable[''] = 141; - cTable[''] = 142; - cTable[''] = 143; - cTable[''] = 144; - cTable[''] = 145; - cTable[''] = 146; - cTable[''] = 147; - cTable[''] = 148; - cTable[''] = 149; - cTable[''] = 150; - cTable[''] = 151; - cTable[''] = 152; - cTable[''] = 153; - cTable[''] = 154; - cTable[''] = 155; - cTable[''] = 156; - cTable[''] = 157; - cTable[''] = 158; - cTable[''] = 159; - cTable[''] = 160; - cTable[''] = 161; - cTable[''] = 162; - - cTable[''] = 163; - cTable[''] = 164; - cTable[''] = 165; - cTable[''] = 166; - cTable[''] = 167; - cTable[''] = 168; - cTable[''] = 169; - cTable[''] = 170; - cTable[''] = 171; - cTable[''] = 172; - cTable[''] = 173; - cTable[''] = 174; - cTable[''] = 175; - cTable[''] = 176; - cTable[''] = 177; - cTable[''] = 178; - cTable[''] = 179; - cTable[''] = 180; - cTable[''] = 181; - cTable[''] = 182; - cTable[''] = 183; - cTable[''] = 184; - cTable[''] = 185; - cTable[''] = 186; - cTable[''] = 187; - cTable[''] = 188; - cTable[''] = 189; - cTable[''] = 190; - cTable[''] = 191; - cTable[''] = 192; - cTable[''] = 193; - cTable[''] = 194; - cTable[''] = 195; - - lTable[''] = 13; - lTable[''] = 15; - lTable[''] = 15; - lTable[''] = 11; - lTable[''] = 15; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 15; - lTable[''] = 10; - lTable[''] = 13; - lTable[''] = 13; - lTable[''] = 12; - lTable[''] = 13; - lTable[''] = 14; - lTable[''] = 14; - lTable[''] = 13; - lTable[''] = 11; - lTable[''] = 12; - lTable[''] = 12; - lTable[''] = 18; - lTable[''] = 11; - lTable[''] = 13; - lTable[''] = 12; - lTable[''] = 13; - lTable[''] = 12; - lTable[''] = 17; - lTable[''] = 18; - lTable[''] = 16; - lTable[''] = 18; - lTable[''] = 19; - lTable[''] = 11; - lTable[''] = 16; - lTable[''] = 14; - - lTable[''] = 14; - lTable[''] = 15; - lTable[''] = 10; - lTable[''] = 12; - lTable[''] = 13; - lTable[''] = 12; - lTable[''] = 12; - lTable[''] = 12; - lTable[''] = 10; - lTable[''] = 10; - lTable[''] = 10; - lTable[''] = 11; - lTable[''] = 12; - lTable[''] = 12; - lTable[''] = 12; - lTable[''] = 12; - lTable[''] = 10; - lTable[''] = 11; - lTable[''] = 10; - lTable[''] = 14; - lTable[''] = 8; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 12; - lTable[''] = 10; - lTable[''] = 15; - lTable[''] = 16; - lTable[''] = 14; - lTable[''] = 16; - lTable[''] = 16; - lTable[''] = 9; - lTable[''] = 15; - lTable[''] = 14; + cTable[(byte)''] = 130; + cTable[(byte)''] = 131; + cTable[(byte)''] = 132; + cTable[(byte)''] = 133; + cTable[(byte)''] = 134; + cTable[(byte)''] = 135; + cTable[(byte)''] = 136; + cTable[(byte)''] = 137; + cTable[(byte)''] = 138; + cTable[(byte)''] = 139; + cTable[(byte)''] = 140; + cTable[(byte)''] = 141; + cTable[(byte)''] = 142; + cTable[(byte)''] = 143; + cTable[(byte)''] = 144; + cTable[(byte)''] = 145; + cTable[(byte)''] = 146; + cTable[(byte)''] = 147; + cTable[(byte)''] = 148; + cTable[(byte)''] = 149; + cTable[(byte)''] = 150; + cTable[(byte)''] = 151; + cTable[(byte)''] = 152; + cTable[(byte)''] = 153; + cTable[(byte)''] = 154; + cTable[(byte)''] = 155; + cTable[(byte)''] = 156; + cTable[(byte)''] = 157; + cTable[(byte)''] = 158; + cTable[(byte)''] = 159; + cTable[(byte)''] = 160; + cTable[(byte)''] = 161; + cTable[(byte)''] = 162; + + cTable[(byte)''] = 163; + cTable[(byte)''] = 164; + cTable[(byte)''] = 165; + cTable[(byte)''] = 166; + cTable[(byte)''] = 167; + cTable[(byte)''] = 168; + cTable[(byte)''] = 169; + cTable[(byte)''] = 170; + cTable[(byte)''] = 171; + cTable[(byte)''] = 172; + cTable[(byte)''] = 173; + cTable[(byte)''] = 174; + cTable[(byte)''] = 175; + cTable[(byte)''] = 176; + cTable[(byte)''] = 177; + cTable[(byte)''] = 178; + cTable[(byte)''] = 179; + cTable[(byte)''] = 180; + cTable[(byte)''] = 181; + cTable[(byte)''] = 182; + cTable[(byte)''] = 183; + cTable[(byte)''] = 184; + cTable[(byte)''] = 185; + cTable[(byte)''] = 186; + cTable[(byte)''] = 187; + cTable[(byte)''] = 188; + cTable[(byte)''] = 189; + cTable[(byte)''] = 190; + cTable[(byte)''] = 191; + cTable[(byte)''] = 192; + cTable[(byte)''] = 193; + cTable[(byte)''] = 194; + cTable[(byte)''] = 195; + + lTable[(byte)''] = 13; + lTable[(byte)''] = 15; + lTable[(byte)''] = 15; + lTable[(byte)''] = 11; + lTable[(byte)''] = 15; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 15; + lTable[(byte)''] = 10; + lTable[(byte)''] = 13; + lTable[(byte)''] = 13; + lTable[(byte)''] = 12; + lTable[(byte)''] = 13; + lTable[(byte)''] = 14; + lTable[(byte)''] = 14; + lTable[(byte)''] = 13; + lTable[(byte)''] = 11; + lTable[(byte)''] = 12; + lTable[(byte)''] = 12; + lTable[(byte)''] = 18; + lTable[(byte)''] = 11; + lTable[(byte)''] = 13; + lTable[(byte)''] = 12; + lTable[(byte)''] = 13; + lTable[(byte)''] = 12; + lTable[(byte)''] = 17; + lTable[(byte)''] = 18; + lTable[(byte)''] = 16; + lTable[(byte)''] = 18; + lTable[(byte)''] = 19; + lTable[(byte)''] = 11; + lTable[(byte)''] = 16; + lTable[(byte)''] = 14; + + lTable[(byte)''] = 14; + lTable[(byte)''] = 15; + lTable[(byte)''] = 10; + lTable[(byte)''] = 12; + lTable[(byte)''] = 13; + lTable[(byte)''] = 12; + lTable[(byte)''] = 12; + lTable[(byte)''] = 12; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 12; + lTable[(byte)''] = 12; + lTable[(byte)''] = 12; + lTable[(byte)''] = 12; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 14; + lTable[(byte)''] = 8; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 12; + lTable[(byte)''] = 10; + lTable[(byte)''] = 15; + lTable[(byte)''] = 16; + lTable[(byte)''] = 14; + lTable[(byte)''] = 16; + lTable[(byte)''] = 16; + lTable[(byte)''] = 9; + lTable[(byte)''] = 15; + lTable[(byte)''] = 14; #endif // FONT_RUSSIAN #ifdef FONT_CZECH - cTable[''] = 196; - cTable[''] = 197; - cTable[''] = 198; - cTable[''] = 199; - cTable[''] = 200; - cTable[''] = 201; - cTable[''] = 202; - cTable[''] = 203; - cTable[''] = 204; - cTable[''] = 205; - cTable[''] = 206; - cTable[''] = 207; - cTable[''] = 208; - cTable[''] = 209; - cTable[''] = 210; - - cTable[''] = 211; - cTable[''] = 212; - cTable[''] = 213; - cTable[''] = 214; - cTable[''] = 215; - cTable[''] = 216; - cTable[''] = 217; - cTable[''] = 218; - cTable[''] = 219; - cTable[''] = 220; - cTable[''] = 221; - cTable[''] = 222; - cTable[''] = 223; - cTable[''] = 224; - cTable[''] = 225; - - lTable[''] = 11; - lTable[''] = 12; - lTable[''] = 12; - lTable[''] = 14; - lTable[''] = 13; - lTable[''] = 11; - lTable[''] = 13; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 15; - lTable[''] = 19; - lTable[''] = 10; - lTable[''] = 13; - lTable[''] = 13; - lTable[''] = 13; - - lTable[''] = 12; - lTable[''] = 12; - lTable[''] = 12; - lTable[''] = 12; - lTable[''] = 13; - lTable[''] = 11; - lTable[''] = 15; - lTable[''] = 7; - lTable[''] = 12; - lTable[''] = 17; - lTable[''] = 16; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 13; - lTable[''] = 13; + cTable[(byte)''] = 196; + cTable[(byte)''] = 197; + cTable[(byte)''] = 198; + cTable[(byte)''] = 199; + cTable[(byte)''] = 200; + cTable[(byte)''] = 201; + cTable[(byte)''] = 202; + cTable[(byte)''] = 203; + cTable[(byte)''] = 204; + cTable[(byte)''] = 205; + cTable[(byte)''] = 206; + cTable[(byte)''] = 207; + cTable[(byte)''] = 208; + cTable[(byte)''] = 209; + cTable[(byte)''] = 210; + + cTable[(byte)''] = 211; + cTable[(byte)''] = 212; + cTable[(byte)''] = 213; + cTable[(byte)''] = 214; + cTable[(byte)''] = 215; + cTable[(byte)''] = 216; + cTable[(byte)''] = 217; + cTable[(byte)''] = 218; + cTable[(byte)''] = 219; + cTable[(byte)''] = 220; + cTable[(byte)''] = 221; + cTable[(byte)''] = 222; + cTable[(byte)''] = 223; + cTable[(byte)''] = 224; + cTable[(byte)''] = 225; + + lTable[(byte)''] = 11; + lTable[(byte)''] = 12; + lTable[(byte)''] = 12; + lTable[(byte)''] = 14; + lTable[(byte)''] = 13; + lTable[(byte)''] = 11; + lTable[(byte)''] = 13; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 15; + lTable[(byte)''] = 19; + lTable[(byte)''] = 10; + lTable[(byte)''] = 13; + lTable[(byte)''] = 13; + lTable[(byte)''] = 13; + + lTable[(byte)''] = 12; + lTable[(byte)''] = 12; + lTable[(byte)''] = 12; + lTable[(byte)''] = 12; + lTable[(byte)''] = 13; + lTable[(byte)''] = 11; + lTable[(byte)''] = 15; + lTable[(byte)''] = 7; + lTable[(byte)''] = 12; + lTable[(byte)''] = 17; + lTable[(byte)''] = 16; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 13; + lTable[(byte)''] = 13; #endif // FONT_CZECH #ifdef FONT_FRENCH - cTable[''] = 226; - cTable[''] = 227; - cTable[''] = 228; - cTable[''] = 229; - cTable[''] = 230; - cTable[''] = 231; - cTable[''] = 232; - cTable[''] = 233; - - lTable[''] = 15; - lTable[''] = 12; - lTable[''] = 12; - lTable[''] = 9; - lTable[''] = 13; - lTable[''] = 13; - lTable[''] = 11; - lTable[''] = 11; + cTable[(byte)''] = 226; + cTable[(byte)''] = 227; + cTable[(byte)''] = 228; + cTable[(byte)''] = 229; + cTable[(byte)''] = 230; + cTable[(byte)''] = 231; + cTable[(byte)''] = 232; + cTable[(byte)''] = 233; + + lTable[(byte)''] = 15; + lTable[(byte)''] = 12; + lTable[(byte)''] = 12; + lTable[(byte)''] = 9; + lTable[(byte)''] = 13; + lTable[(byte)''] = 13; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; #endif // FONT_FRENCH #ifdef FONT_GERMAN - cTable[''] = 234; + cTable[(byte)''] = 234; // 'SS' = 235 - cTable[''] = 236; - cTable[''] = 237; - cTable[''] = 238; + cTable[(byte)''] = 236; + cTable[(byte)''] = 237; + cTable[(byte)''] = 238; - lTable[''] = 15; + lTable[(byte)''] = 15; #endif // FONT_GERMAN } diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 9f725f2523..5737a6af45 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -1832,7 +1832,7 @@ RMGfxSourceBuffer16::~RMGfxSourceBuffer16() { } void RMGfxSourceBuffer16::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { - int x,y; + int x, y; uint16 *buf = bigBuf; uint16 *raw = (uint16*)m_buf; int dimx, dimy; @@ -1881,7 +1881,7 @@ void RMGfxSourceBuffer16::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) } } else { for (y = 0; y < dimy; y++) { - CopyMemory(buf, raw, dimx * 2); + Common::copy(raw, raw + dimx, buf); buf += bigBuf.Dimx(); raw += m_dimx; } diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index 12a8c8eabb..a2648318fe 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -82,6 +82,17 @@ void RMTony::Init(void) { RMRes body(9999); RMDataStream ds; + // Mostra Tony di default + m_bShow=m_bShowOmbra = true; + + // Nessuna azione in attesa + m_bActionPending = false; + m_bAction = false; + + m_bPastorella = false; + m_bIsTalking = false; + m_bIsStaticTalk = false; + // Apre il buffer ds.OpenBuffer(tony); @@ -97,17 +108,6 @@ void RMTony::Init(void) { ds.Close(); m_body.SetPattern(0); - // Mostra Tony di default - m_bShow=m_bShowOmbra = true; - - // Nessuna azione in attesa - m_bActionPending = false; - m_bAction = false; - - m_bPastorella = false; - m_bIsTalking = false; - m_bIsStaticTalk = false; - m_nTimeLastStep = _vm->GetTime(); } -- cgit v1.2.3 From 0b249c042f8c3f70188d3ce97516fe1290c30504 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 5 May 2012 09:38:22 +1000 Subject: TONY: Correct some initialisation of the character arrays --- engines/tony/font.cpp | 324 +++++++++++++++++++++++++------------------------- 1 file changed, 162 insertions(+), 162 deletions(-) (limited to 'engines') diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index c4f589a21d..f28d4f6eea 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -1534,37 +1534,37 @@ void RMFontObj::Init(void) { cTable['='] = 49; cTable['\''] = 50; cTable['\"'] = 51; - cTable[''] = 52; - cTable['$'] = 53; - cTable['%'] = 54; - cTable['&'] = 55; - cTable['^'] = 56; - cTable['*'] = 57; - cTable['<'] = 58; - cTable['>'] = 59; - cTable[''] = 60; - cTable[''] = 61; - cTable[''] = 62; - cTable[''] = 63; - //cTable[''] = 64; integrale - cTable[''] = 65; - cTable[''] = 66; - cTable[''] = 67; - cTable[''] = 68; - cTable[''] = 69; - cTable[''] = cTable[''] = 70; - cTable[''] = 71; - cTable[''] = 72; - cTable[''] = 73; - //cTable[' '] = 74; e cerchietto - cTable[''] = 75; - cTable[''] = 76; - //cTable[' '] = 77; i cerchietto - cTable[''] = 78; - cTable[''] = cTable[''] = 79; - //cTable[' '] = 80; o cerchietto - cTable[''] = 81; - cTable[''] = cTable[''] = 82; + cTable[(byte)''] = 52; + cTable[(byte)'$'] = 53; + cTable[(byte)'%'] = 54; + cTable[(byte)'&'] = 55; + cTable[(byte)'^'] = 56; + cTable[(byte)'*'] = 57; + cTable[(byte)'<'] = 58; + cTable[(byte)'>'] = 59; + cTable[(byte)''] = 60; + cTable[(byte)''] = 61; + cTable[(byte)''] = 62; + cTable[(byte)''] = 63; + //cTable[(byte)''] = 64; integrale + cTable[(byte)''] = 65; + cTable[(byte)''] = 66; + cTable[(byte)''] = 67; + cTable[(byte)''] = 68; + cTable[(byte)''] = 69; + cTable[(byte)''] = cTable[(byte)''] = 70; + cTable[(byte)''] = 71; + cTable[(byte)''] = 72; + cTable[(byte)''] = 73; + //cTable[(byte)' '] = 74; e cerchietto + cTable[(byte)''] = 75; + cTable[(byte)''] = 76; + //cTable[(byte)' '] = 77; i cerchietto + cTable[(byte)''] = 78; + cTable[(byte)''] = cTable[(byte)''] = 79; + //cTable[(byte)' '] = 80; o cerchietto + cTable[(byte)''] = 81; + cTable[(byte)''] = cTable[(byte)''] = 82; //cTable[' '] = 83; u cerchietto //cTable[' '] = 84; y dieresi @@ -1610,7 +1610,7 @@ void RMFontObj::Init(void) { lTable['y'] = lTable['Y'] = 13; lTable['w'] = lTable['W'] = 19; lTable['z'] = lTable['Z'] = 20; - lTable[''] = 17; + lTable[(byte)''] = 17; /* Casi particolari */ SetBothCase('C','C',2); @@ -1629,32 +1629,32 @@ void RMFontObj::Init(void) { // Polish characters //ス謎戊3剔囀 //AaCcEeLlNnOoSsZzZz - cTable[''] = cTable[''] = 85; - lTable[''] = lTable[''] = 20; + cTable[(byte)''] = cTable[(byte)''] = 85; + lTable[(byte)''] = lTable[(byte)''] = 20; - cTable[''] = cTable[''] = 86; - lTable[''] = lTable[''] = 22; + cTable[(byte)''] = cTable[(byte)''] = 86; + lTable[(byte)''] = lTable[(byte)''] = 22; - cTable[''] = cTable[''] = 87; - lTable[''] = lTable[''] = 17; + cTable[(byte)''] = cTable[(byte)''] = 87; + lTable[(byte)''] = lTable[(byte)''] = 17; - cTable[''] = cTable[''] = 88; - lTable[''] = lTable[''] = 19; + cTable[(byte)''] = cTable[(byte)''] = 88; + lTable[(byte)''] = lTable[(byte)''] = 19; - cTable[''] = cTable[''] = 89; - lTable[''] = lTable[''] = 17; + cTable[(byte)''] = cTable[(byte)''] = 89; + lTable[(byte)''] = lTable[(byte)''] = 17; - cTable[''] = cTable[''] = 90; - lTable[''] = lTable[''] = 22; + cTable[(byte)''] = cTable[(byte)''] = 90; + lTable[(byte)''] = lTable[(byte)''] = 22; - cTable[''] = cTable[''] = 91; - lTable[''] = lTable[''] = 15; + cTable[(byte)''] = cTable[(byte)''] = 91; + lTable[(byte)''] = lTable[(byte)''] = 15; - cTable[''] = cTable[''] = 92; - lTable[''] = lTable[''] = 21; + cTable[(byte)''] = cTable[(byte)''] = 92; + lTable[(byte)''] = lTable[(byte)''] = 21; - cTable[''] = cTable[''] = 93; - lTable[''] = lTable[''] = 21; + cTable[(byte)''] = cTable[(byte)''] = 93; + lTable[(byte)''] = lTable[(byte)''] = 21; #ifdef FONT_RUSSIAN @@ -1663,114 +1663,114 @@ void RMFontObj::Init(void) { // per le altre traduzioni. Per compilare Tony in altre lingue, // commentare via queste definizioni. - cTable[''] = cTable[''] = 85; - lTable[''] = lTable[''] = 20; - - cTable[''] = cTable[''] =94; - cTable[''] = cTable[''] =95; - cTable[''] = cTable[''] =96; - cTable[''] = cTable[''] =97; - cTable[''] = cTable[''] =98; - cTable[''] = cTable[''] =99; - cTable[''] = cTable[''] =100; - cTable[''] = cTable[''] =101; - cTable[''] = cTable[''] =102; - cTable[''] = cTable[''] =103; - cTable[''] = cTable[''] =104; - cTable[''] = cTable[''] =105; - cTable[''] = cTable[''] =106; - cTable[''] = cTable[''] =107; - cTable[''] = cTable[''] =108; - cTable[''] = cTable[''] =109; - cTable[''] = cTable[''] =110; - cTable[''] = cTable[''] =111; - cTable[''] = cTable[''] =112; - cTable[''] = cTable[''] =113; - cTable[''] = cTable[''] =114; - cTable[''] = cTable[''] =115; - cTable[''] = cTable[''] =116; - cTable[''] = cTable[''] =117; - cTable[''] = cTable[''] =118; - cTable[''] = cTable[''] =119; - cTable[''] = cTable[''] =120; - cTable[''] = cTable[''] =121; - cTable[''] = cTable[''] =122; - cTable[''] = cTable[''] =123; - cTable[''] = cTable[''] =124; - cTable[''] = cTable[''] =125; - cTable[''] = cTable[''] =126; - - - lTable[''] = lTable[''] = 18; - lTable[''] = lTable[''] = 18; - lTable[''] = lTable[''] = 18; - lTable[''] = lTable[''] = 17; - lTable[''] = lTable[''] = 16; - lTable[''] = lTable[''] = 18; - lTable[''] = lTable[''] = 18; - lTable[''] = lTable[''] = 20; - lTable[''] = lTable[''] = 18; - lTable[''] = lTable[''] = 18; - lTable[''] = lTable[''] = 18; - lTable[''] = lTable[''] = 18; - lTable[''] = lTable[''] = 16; - lTable[''] = lTable[''] = 18; - lTable[''] = lTable[''] = 15; - lTable[''] = lTable[''] = 22; - lTable[''] = lTable[''] = 15; - lTable[''] = lTable[''] = 18; - lTable[''] = lTable[''] = 22; - lTable[''] = lTable[''] = 19; - lTable[''] = lTable[''] = 16; - lTable[''] = lTable[''] = 21; - lTable[''] = lTable[''] = 20; - lTable[''] = lTable[''] = 16; - lTable[''] = lTable[''] = 16; - lTable[''] = lTable[''] = 19; - lTable[''] = lTable[''] = 22; - lTable[''] = lTable[''] = 18; - lTable[''] = lTable[''] = 19; - lTable[''] = lTable[''] = 19; - lTable[''] = lTable[''] = 15; - lTable[''] = lTable[''] = 18; - lTable[''] = lTable[''] = 18; + cTable[(byte)''] = cTable[(byte)''] = 85; + lTable[(byte)''] = lTable[(byte)''] = 20; + + cTable[(byte)''] = cTable[(byte)''] =94; + cTable[(byte)''] = cTable[(byte)''] =95; + cTable[(byte)''] = cTable[(byte)''] =96; + cTable[(byte)''] = cTable[(byte)''] =97; + cTable[(byte)''] = cTable[(byte)''] =98; + cTable[(byte)''] = cTable[(byte)''] =99; + cTable[(byte)''] = cTable[(byte)''] =100; + cTable[(byte)''] = cTable[(byte)''] =101; + cTable[(byte)''] = cTable[(byte)''] =102; + cTable[(byte)''] = cTable[(byte)''] =103; + cTable[(byte)''] = cTable[(byte)''] =104; + cTable[(byte)''] = cTable[(byte)''] =105; + cTable[(byte)''] = cTable[(byte)''] =106; + cTable[(byte)''] = cTable[(byte)''] =107; + cTable[(byte)''] = cTable[(byte)''] =108; + cTable[(byte)''] = cTable[(byte)''] =109; + cTable[(byte)''] = cTable[(byte)''] =110; + cTable[(byte)''] = cTable[(byte)''] =111; + cTable[(byte)''] = cTable[(byte)''] =112; + cTable[(byte)''] = cTable[(byte)''] =113; + cTable[(byte)''] = cTable[(byte)''] =114; + cTable[(byte)''] = cTable[(byte)''] =115; + cTable[(byte)''] = cTable[(byte)''] =116; + cTable[(byte)''] = cTable[(byte)''] =117; + cTable[(byte)''] = cTable[(byte)''] =118; + cTable[(byte)''] = cTable[(byte)''] =119; + cTable[(byte)''] = cTable[(byte)''] =120; + cTable[(byte)''] = cTable[(byte)''] =121; + cTable[(byte)''] = cTable[(byte)''] =122; + cTable[(byte)''] = cTable[(byte)''] =123; + cTable[(byte)''] = cTable[(byte)''] =124; + cTable[(byte)''] = cTable[(byte)''] =125; + cTable[(byte)''] = cTable[(byte)''] =126; + + + lTable[(byte)''] = lTable[(byte)''] = 18; + lTable[(byte)''] = lTable[(byte)''] = 18; + lTable[(byte)''] = lTable[(byte)''] = 18; + lTable[(byte)''] = lTable[(byte)''] = 17; + lTable[(byte)''] = lTable[(byte)''] = 16; + lTable[(byte)''] = lTable[(byte)''] = 18; + lTable[(byte)''] = lTable[(byte)''] = 18; + lTable[(byte)''] = lTable[(byte)''] = 20; + lTable[(byte)''] = lTable[(byte)''] = 18; + lTable[(byte)''] = lTable[(byte)''] = 18; + lTable[(byte)''] = lTable[(byte)''] = 18; + lTable[(byte)''] = lTable[(byte)''] = 18; + lTable[(byte)''] = lTable[(byte)''] = 16; + lTable[(byte)''] = lTable[(byte)''] = 18; + lTable[(byte)''] = lTable[(byte)''] = 15; + lTable[(byte)''] = lTable[(byte)''] = 22; + lTable[(byte)''] = lTable[(byte)''] = 15; + lTable[(byte)''] = lTable[(byte)''] = 18; + lTable[(byte)''] = lTable[(byte)''] = 22; + lTable[(byte)''] = lTable[(byte)''] = 19; + lTable[(byte)''] = lTable[(byte)''] = 16; + lTable[(byte)''] = lTable[(byte)''] = 21; + lTable[(byte)''] = lTable[(byte)''] = 20; + lTable[(byte)''] = lTable[(byte)''] = 16; + lTable[(byte)''] = lTable[(byte)''] = 16; + lTable[(byte)''] = lTable[(byte)''] = 19; + lTable[(byte)''] = lTable[(byte)''] = 22; + lTable[(byte)''] = lTable[(byte)''] = 18; + lTable[(byte)''] = lTable[(byte)''] = 19; + lTable[(byte)''] = lTable[(byte)''] = 19; + lTable[(byte)''] = lTable[(byte)''] = 15; + lTable[(byte)''] = lTable[(byte)''] = 18; + lTable[(byte)''] = lTable[(byte)''] = 18; #endif // FONT_RUSSIAN #ifdef FONT_CZECH // rep. ceca characters - cTable[''] = cTable[''] = 127; - cTable[''] = cTable[''] = 128; - cTable[''] = cTable[''] = 129; - cTable[''] = cTable[''] = 130; - cTable[''] = cTable[''] = 131; - cTable[''] = cTable[''] = 132; - cTable[''] = cTable[''] = 133; - cTable[''] = cTable[''] = 134; - cTable[''] = cTable[''] = 135; - cTable[''] = cTable[''] = 136; - cTable[''] = cTable[''] = 137; - cTable[''] = cTable[''] = 138; - cTable[''] = cTable[''] = 139; - cTable[''] = cTable[''] = 140; - cTable[''] = cTable[''] = 141; - - lTable[''] = lTable[''] =17; - lTable[''] = lTable[''] =15; - lTable[''] = lTable[''] =22; - lTable[''] = lTable[''] =18; - lTable[''] = lTable[''] =21; - lTable[''] = lTable[''] =16; - lTable[''] = lTable[''] =18; - lTable[''] = lTable[''] =19; - lTable[''] = lTable[''] =17; - lTable[''] = lTable[''] =23; - lTable[''] = lTable[''] =24; - lTable[''] = lTable[''] =17; - lTable[''] = lTable[''] =22; - lTable[''] = lTable[''] =16; - lTable[''] = lTable[''] =16; + cTable[(byte)''] = cTable[(byte)''] = 127; + cTable[(byte)''] = cTable[(byte)''] = 128; + cTable[(byte)''] = cTable[(byte)''] = 129; + cTable[(byte)''] = cTable[(byte)''] = 130; + cTable[(byte)''] = cTable[(byte)''] = 131; + cTable[(byte)''] = cTable[(byte)''] = 132; + cTable[(byte)''] = cTable[(byte)''] = 133; + cTable[(byte)''] = cTable[(byte)''] = 134; + cTable[(byte)''] = cTable[(byte)''] = 135; + cTable[(byte)''] = cTable[(byte)''] = 136; + cTable[(byte)''] = cTable[(byte)''] = 137; + cTable[(byte)''] = cTable[(byte)''] = 138; + cTable[(byte)''] = cTable[(byte)''] = 139; + cTable[(byte)''] = cTable[(byte)''] = 140; + cTable[(byte)''] = cTable[(byte)''] = 141; + + lTable[(byte)''] = lTable[(byte)''] =17; + lTable[(byte)''] = lTable[(byte)''] =15; + lTable[(byte)''] = lTable[(byte)''] =22; + lTable[(byte)''] = lTable[(byte)''] =18; + lTable[(byte)''] = lTable[(byte)''] =21; + lTable[(byte)''] = lTable[(byte)''] =16; + lTable[(byte)''] = lTable[(byte)''] =18; + lTable[(byte)''] = lTable[(byte)''] =19; + lTable[(byte)''] = lTable[(byte)''] =17; + lTable[(byte)''] = lTable[(byte)''] =23; + lTable[(byte)''] = lTable[(byte)''] =24; + lTable[(byte)''] = lTable[(byte)''] =17; + lTable[(byte)''] = lTable[(byte)''] =22; + lTable[(byte)''] = lTable[(byte)''] =16; + lTable[(byte)''] = lTable[(byte)''] =16; #endif // FONT_CZECH @@ -1778,20 +1778,20 @@ void RMFontObj::Init(void) { // traduci le lettere accentate in lettere normali - cTable[''] = cTable[''] = cTable[''] = 0; // a - lTable[''] = lTable[''] = lTable[''] = 17; + cTable[(byte)''] = cTable[(byte)''] = cTable[(byte)''] = 0; // a + lTable[(byte)''] = lTable[(byte)''] = lTable[(byte)''] = 17; - cTable[''] = cTable[''] = 4; // e - lTable[''] = lTable[''] = 15; + cTable[(byte)''] = cTable[(byte)''] = 4; // e + lTable[(byte)''] = lTable[(byte)''] = 15; - cTable[''] = cTable[''] = cTable[''] = 8; // i - lTable[''] = lTable[''] = lTable[''] = 16; + cTable[(byte)''] = cTable[(byte)''] = cTable[(byte)''] = 8; // i + lTable[(byte)''] = lTable[(byte)''] = lTable[(byte)''] = 16; - cTable[''] = cTable[''] = cTable[''] = cTable[''] = 14; // o - lTable[''] = lTable[''] = lTable[''] = lTable[''] = 19; + cTable[(byte)''] = cTable[(byte)''] = cTable[(byte)''] = cTable[(byte)''] = 14; // o + lTable[(byte)''] = lTable[(byte)''] = lTable[(byte)''] = lTable[(byte)''] = 19; - cTable[''] = cTable[''] = 20; // u - lTable[''] = lTable[''] = 15; + cTable[(byte)''] = cTable[(byte)''] = 20; // u + lTable[(byte)''] = lTable[(byte)''] = 15; #endif // FONT_FRENCH -- cgit v1.2.3 From bff40634924d809a549e79890d5e7f37f51fd432 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 5 May 2012 09:42:26 +1000 Subject: TONY: Correct some more chararcter array initialisations --- engines/tony/font.cpp | 546 +++++++++++++++++++++++++------------------------- 1 file changed, 273 insertions(+), 273 deletions(-) (limited to 'engines') diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index f28d4f6eea..59a2e8cfc4 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -695,7 +695,7 @@ void RMFontMacc::Init(void) { //cTable['?'] = 73; // ? rovescia cTable['*'] = 74; cTable['+'] = 75; - cTable[''] = 76; + cTable[(byte)''] = 76; cTable[';'] = 77; cTable[','] = 78; cTable['.'] = 79; @@ -704,65 +704,65 @@ void RMFontMacc::Init(void) { cTable['<'] = 82; cTable['>'] = 83; cTable['/'] = 84; - cTable[''] = 85; - cTable[''] = 86; - cTable[''] = 87; - cTable[''] = 88; - cTable[''] = 89; - cTable[''] = 90; - //cTable[''] = 91; // e col pallino - cTable[''] = 92; - cTable[''] = 93; - //cTable[''] = 94; // i col pallino - cTable[''] = 95; - cTable[''] = 96; - //cTable[''] = 97; // o col pallino - cTable[''] = 98; - cTable[''] = 99; - //cTable[''] = 100; // u col pallino - cTable[''] = 101; + cTable[(byte)''] = 85; + cTable[(byte)''] = 86; + cTable[(byte)''] = 87; + cTable[(byte)''] = 88; + cTable[(byte)''] = 89; + cTable[(byte)''] = 90; + //cTable[(byte)''] = 91; // e col pallino + cTable[(byte)''] = 92; + cTable[(byte)''] = 93; + //cTable[(byte)''] = 94; // i col pallino + cTable[(byte)''] = 95; + cTable[(byte)''] = 96; + //cTable[(byte)''] = 97; // o col pallino + cTable[(byte)''] = 98; + cTable[(byte)''] = 99; + //cTable[(byte)''] = 100; // u col pallino + cTable[(byte)''] = 101; // Polish characters //AaCcEeLlNnOoSsZzZz //ス謎戊3剔囀 - cTable[''] = 102; - cTable[''] = 103; - cTable[''] = 104; - cTable[''] = 105; - cTable[''] = 106; - cTable[''] = 107; - cTable[''] = 108; - cTable[''] = 109; - cTable[''] = 110; - cTable[''] = 111; - cTable[''] = 112; - cTable[''] = 113; - cTable[''] = 114; - cTable[''] = 115; - cTable[''] = 116; - cTable[''] = 117; - cTable[''] = 118; - cTable[''] = 119; + cTable[(byte)''] = 102; + cTable[(byte)''] = 103; + cTable[(byte)''] = 104; + cTable[(byte)''] = 105; + cTable[(byte)''] = 106; + cTable[(byte)''] = 107; + cTable[(byte)''] = 108; + cTable[(byte)''] = 109; + cTable[(byte)''] = 110; + cTable[(byte)''] = 111; + cTable[(byte)''] = 112; + cTable[(byte)''] = 113; + cTable[(byte)''] = 114; + cTable[(byte)''] = 115; + cTable[(byte)''] = 116; + cTable[(byte)''] = 117; + cTable[(byte)''] = 118; + cTable[(byte)''] = 119; - lTable[''] = 14; - lTable[''] = 16; - lTable[''] = 12; - lTable[''] = 12; - lTable[''] = 11; - lTable[''] = 12; - lTable[''] = 14; - lTable[''] = 9; - lTable[''] = 10; - lTable[''] = 11; - lTable[''] = 13; - lTable[''] = 11; - lTable[''] = 12; - lTable[''] = 12; - lTable[''] = 13; - lTable[''] = 13; - lTable[''] = 14; - lTable[''] = 13; + lTable[(byte)''] = 14; + lTable[(byte)''] = 16; + lTable[(byte)''] = 12; + lTable[(byte)''] = 12; + lTable[(byte)''] = 11; + lTable[(byte)''] = 12; + lTable[(byte)''] = 14; + lTable[(byte)''] = 9; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 13; + lTable[(byte)''] = 11; + lTable[(byte)''] = 12; + lTable[(byte)''] = 12; + lTable[(byte)''] = 13; + lTable[(byte)''] = 13; + lTable[(byte)''] = 14; + lTable[(byte)''] = 13; #ifdef FONT_RUSSIAN @@ -771,242 +771,242 @@ void RMFontMacc::Init(void) { // per le altre traduzioni. Per compilare Tony in altre lingue, // commentare via queste definizioni. - cTable[''] = 120; - cTable[''] = 121; - cTable[''] = 122; - cTable[''] = 123; - cTable[''] = 124; - cTable[''] = 125; - cTable[''] = 126; - cTable[''] = 127; - cTable[''] = 128; - cTable[''] = 129; - cTable[''] = 130; - cTable[''] = 131; - cTable[''] = 132; - cTable[''] = 133; - cTable[''] = 134; - cTable[''] = 135; - cTable[''] = 136; - cTable[''] = 137; - cTable[''] = 138; - cTable[''] = 139; - cTable[''] = 140; - cTable[''] = 141; - cTable[''] = 142; - cTable[''] = 143; - cTable[''] = 144; - cTable[''] = 145; - cTable[''] = 146; - cTable[''] = 147; - cTable[''] = 148; - cTable[''] = 149; - cTable[''] = 150; - cTable[''] = 151; - cTable[''] = 152; - - cTable[''] = 153; - cTable[''] = 154; - cTable[''] = 155; - cTable[''] = 156; - cTable[''] = 157; - cTable[''] = 158; - cTable[''] = 159; - cTable[''] = 160; - cTable[''] = 161; - cTable[''] = 162; - cTable[''] = 163; - cTable[''] = 164; - cTable[''] = 165; - cTable[''] = 166; - cTable[''] = 167; - cTable[''] = 168; - cTable[''] = 169; - cTable[''] = 170; - cTable[''] = 171; - cTable[''] = 172; - cTable[''] = 173; - cTable[''] = 174; - cTable[''] = 175; - cTable[''] = 176; - cTable[''] = 177; - cTable[''] = 178; - cTable[''] = 179; - cTable[''] = 180; - cTable[''] = 181; - cTable[''] = 182; - cTable[''] = 183; - cTable[''] = 184; - cTable[''] = 185; - - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 9; - lTable[''] = 10; - lTable[''] = 10; - lTable[''] = 10; - lTable[''] = 11; - lTable[''] = 10; - lTable[''] = 10; - lTable[''] = 10; - lTable[''] = 11; - lTable[''] = 9; - lTable[''] = 11; - lTable[''] = 10; - lTable[''] = 11; - lTable[''] = 8; - lTable[''] = 10; - lTable[''] = 10; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 10; - lTable[''] = 10; - lTable[''] = 10; - lTable[''] = 10; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 11; - - lTable[''] = 10; - lTable[''] = 10; - lTable[''] = 11; - lTable[''] = 10; - lTable[''] = 9; - lTable[''] = 10; - lTable[''] = 9; - lTable[''] = 10; - lTable[''] = 9; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 10; - lTable[''] = 9; - lTable[''] = 11; - lTable[''] = 10; - lTable[''] = 9; - lTable[''] = 11; - lTable[''] = 10; - lTable[''] = 11; - lTable[''] = 10; - lTable[''] = 10; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 10; - lTable[''] = 10; - lTable[''] = 10; - lTable[''] = 9; - lTable[''] = 11; - lTable[''] = 11; + cTable[(byte)''] = 120; + cTable[(byte)''] = 121; + cTable[(byte)''] = 122; + cTable[(byte)''] = 123; + cTable[(byte)''] = 124; + cTable[(byte)''] = 125; + cTable[(byte)''] = 126; + cTable[(byte)''] = 127; + cTable[(byte)''] = 128; + cTable[(byte)''] = 129; + cTable[(byte)''] = 130; + cTable[(byte)''] = 131; + cTable[(byte)''] = 132; + cTable[(byte)''] = 133; + cTable[(byte)''] = 134; + cTable[(byte)''] = 135; + cTable[(byte)''] = 136; + cTable[(byte)''] = 137; + cTable[(byte)''] = 138; + cTable[(byte)''] = 139; + cTable[(byte)''] = 140; + cTable[(byte)''] = 141; + cTable[(byte)''] = 142; + cTable[(byte)''] = 143; + cTable[(byte)''] = 144; + cTable[(byte)''] = 145; + cTable[(byte)''] = 146; + cTable[(byte)''] = 147; + cTable[(byte)''] = 148; + cTable[(byte)''] = 149; + cTable[(byte)''] = 150; + cTable[(byte)''] = 151; + cTable[(byte)''] = 152; + + cTable[(byte)''] = 153; + cTable[(byte)''] = 154; + cTable[(byte)''] = 155; + cTable[(byte)''] = 156; + cTable[(byte)''] = 157; + cTable[(byte)''] = 158; + cTable[(byte)''] = 159; + cTable[(byte)''] = 160; + cTable[(byte)''] = 161; + cTable[(byte)''] = 162; + cTable[(byte)''] = 163; + cTable[(byte)''] = 164; + cTable[(byte)''] = 165; + cTable[(byte)''] = 166; + cTable[(byte)''] = 167; + cTable[(byte)''] = 168; + cTable[(byte)''] = 169; + cTable[(byte)''] = 170; + cTable[(byte)''] = 171; + cTable[(byte)''] = 172; + cTable[(byte)''] = 173; + cTable[(byte)''] = 174; + cTable[(byte)''] = 175; + cTable[(byte)''] = 176; + cTable[(byte)''] = 177; + cTable[(byte)''] = 178; + cTable[(byte)''] = 179; + cTable[(byte)''] = 180; + cTable[(byte)''] = 181; + cTable[(byte)''] = 182; + cTable[(byte)''] = 183; + cTable[(byte)''] = 184; + cTable[(byte)''] = 185; + + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 9; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 9; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 8; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 9; + lTable[(byte)''] = 10; + lTable[(byte)''] = 9; + lTable[(byte)''] = 10; + lTable[(byte)''] = 9; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 9; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 9; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 9; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; #endif // FONT_RUSSIAN #ifdef FONT_CZECH - cTable[''] = 186; - cTable[''] = 187; - cTable[''] = 188; - cTable[''] = 189; - cTable[''] = 190; - cTable[''] = 191; - cTable[''] = 192; - cTable[''] = 193; - cTable[''] = 194; - cTable[''] = 195; - cTable[''] = 196; - cTable[''] = 197; - cTable[''] = 198; - cTable[''] = 199; - cTable[''] = 200; - - cTable[''] = 201; - cTable[''] = 202; - cTable[''] = 203; - cTable[''] = 204; - cTable[''] = 205; - cTable[''] = 206; - cTable[''] = 207; - cTable[''] = 208; - cTable[''] = 209; - cTable[''] = 210; - cTable[''] = 211; - cTable[''] = 212; - cTable[''] = 213; - cTable[''] = 214; - cTable[''] = 215; - - lTable[''] = 10; - lTable[''] = 10; - lTable[''] = 10; - lTable[''] = 11; - lTable[''] = 9; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 9; - lTable[''] = 10; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 11; - - lTable[''] = 10; - lTable[''] = 9; - lTable[''] = 10; - lTable[''] = 10; - lTable[''] = 9; - lTable[''] = 11; - lTable[''] = 10; - lTable[''] = 9; - lTable[''] = 10; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 10; - lTable[''] = 11; - lTable[''] = 11; + cTable[(byte)''] = 186; + cTable[(byte)''] = 187; + cTable[(byte)''] = 188; + cTable[(byte)''] = 189; + cTable[(byte)''] = 190; + cTable[(byte)''] = 191; + cTable[(byte)''] = 192; + cTable[(byte)''] = 193; + cTable[(byte)''] = 194; + cTable[(byte)''] = 195; + cTable[(byte)''] = 196; + cTable[(byte)''] = 197; + cTable[(byte)''] = 198; + cTable[(byte)''] = 199; + cTable[(byte)''] = 200; + + cTable[(byte)''] = 201; + cTable[(byte)''] = 202; + cTable[(byte)''] = 203; + cTable[(byte)''] = 204; + cTable[(byte)''] = 205; + cTable[(byte)''] = 206; + cTable[(byte)''] = 207; + cTable[(byte)''] = 208; + cTable[(byte)''] = 209; + cTable[(byte)''] = 210; + cTable[(byte)''] = 211; + cTable[(byte)''] = 212; + cTable[(byte)''] = 213; + cTable[(byte)''] = 214; + cTable[(byte)''] = 215; + + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 9; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 9; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + + lTable[(byte)''] = 10; + lTable[(byte)''] = 9; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 9; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 9; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; #endif // FONT_CZECH #ifdef FONT_FRENCH - cTable[''] = 226; - cTable[''] = 227; - cTable[''] = 228; - cTable[''] = 229; - cTable[''] = 230; - cTable[''] = 231; - cTable[''] = 232; - cTable[''] = 233; + cTable[(byte)''] = 226; + cTable[(byte)''] = 227; + cTable[(byte)''] = 228; + cTable[(byte)''] = 229; + cTable[(byte)''] = 230; + cTable[(byte)''] = 231; + cTable[(byte)''] = 232; + cTable[(byte)''] = 233; - lTable[''] = 10; - lTable[''] = 10; - lTable[''] = 10; - lTable[''] = 8; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 10; - lTable[''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 8; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; #endif // FONT_FRENCH #ifdef FONT_GERMAN - cTable[''] = 234; + cTable[(byte)''] = 234; // 'SS' = 235 - cTable[''] = 236; - cTable[''] = 237; - cTable[''] = 238; + cTable[(byte)''] = 236; + cTable[(byte)''] = 237; + cTable[(byte)''] = 238; - lTable[''] = 11; + lTable[(byte)''] = 11; #endif // FONT_GERMAN } -- cgit v1.2.3 From cd41c55799d8fa1df83b0cee07169f23b0db27a6 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 5 May 2012 09:47:45 +1000 Subject: TONY: More corrections for font initislisations --- engines/tony/font.cpp | 540 +++++++++++++++++++++++++------------------------- 1 file changed, 270 insertions(+), 270 deletions(-) (limited to 'engines') diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 59a2e8cfc4..60c7b8d525 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -1047,32 +1047,32 @@ void RMFontCredits::Init(void) { - cTable[''] = 52; - cTable[''] = 53; + cTable[(byte)''] = 52; + cTable[(byte)''] = 53; // cTable[''] = 54; // a ^ // cTable[''] = 55; // a pallini - cTable[''] = 56; - cTable[''] = 57; + cTable[(byte)''] = 56; + cTable[(byte)''] = 57; // cTable[''] = 58; // e ^ // cTable[''] = 59; // e pallini cTable[''] = 60; cTable[''] = 61; // cTable[''] = 62; // i ^ // cTable[''] = 63; // i pallini - cTable[''] = 64; - cTable[''] = 65; + cTable[(byte)''] = 64; + cTable[(byte)''] = 65; // cTable[''] = 66; // o ^ // cTable[''] = 67; // o pallini - cTable[''] = 68; - cTable[''] = 69; + cTable[(byte)''] = 68; + cTable[(byte)''] = 69; // cTable[''] = 70; // u ^ // cTable[''] = 71; // u pallini // cTable[''] = 72; // y pallini - cTable[''] = 73; - cTable[''] = 74; + cTable[(byte)''] = 73; + cTable[(byte)''] = 74; // cTable[''] = 75; // o barrato // cTable[''] = 76; // ac - cTable[''] = 77; + cTable[(byte)''] = 77; // cTable[''] = 78; // ? rovesciato cTable['?'] = 79; // cTable[''] = 80; // ! rovesciato @@ -1081,8 +1081,8 @@ void RMFontCredits::Init(void) { // cTable[''] = 83; // 1/4 cTable['('] = 84; cTable[')'] = 85; - cTable[''] = 86; - cTable[''] = 87; + cTable[(byte)''] = 86; + cTable[(byte)''] = 87; // cTable[''] = 88; // AE cTable[':'] = 89; cTable['%'] = 90; @@ -1102,7 +1102,7 @@ void RMFontCredits::Init(void) { cTable['\''] = 111; lTable[' '] = 11; - lTable[''] = lTable['A'] = 19; + lTable[(byte)''] = lTable['A'] = 19; lTable['B'] = 15; lTable['C'] = 14; lTable['D'] = 13; @@ -1181,43 +1181,43 @@ void RMFontCredits::Init(void) { //AaCcEeLlNnOoSsZzZz //ス謎戊3剔囀 - cTable[''] = 112; - cTable[''] = 113; - cTable[''] = 114; - cTable[''] = 115; - cTable[''] = 116; - cTable[''] = 117; - cTable[''] = 118; - cTable[''] = 119; - cTable[''] = 120; - cTable[''] = 121; - cTable[''] = 122; - cTable[''] = 123; - cTable[''] = 124; - cTable[''] = 125; - cTable[''] = 126; - cTable[''] = 127; - cTable[''] = 128; - cTable[''] = 129; + cTable[(byte)''] = 112; + cTable[(byte)''] = 113; + cTable[(byte)''] = 114; + cTable[(byte)''] = 115; + cTable[(byte)''] = 116; + cTable[(byte)''] = 117; + cTable[(byte)''] = 118; + cTable[(byte)''] = 119; + cTable[(byte)''] = 120; + cTable[(byte)''] = 121; + cTable[(byte)''] = 122; + cTable[(byte)''] = 123; + cTable[(byte)''] = 124; + cTable[(byte)''] = 125; + cTable[(byte)''] = 126; + cTable[(byte)''] = 127; + cTable[(byte)''] = 128; + cTable[(byte)''] = 129; - lTable[''] = 20; - lTable[''] = 12; - lTable[''] = 15; - lTable[''] = 10; - lTable[''] = 15; - lTable[''] = 10; - lTable[''] = 14; - lTable[''] = 11; - lTable[''] = 16; - lTable[''] = 10; - lTable[''] = 15; - lTable[''] = 11; - lTable[''] = 15; - lTable[''] = 10; - lTable[''] = 15; - lTable[''] = 10; - lTable[''] = 15; - lTable[''] = 10; + lTable[(byte)''] = 20; + lTable[(byte)''] = 12; + lTable[(byte)''] = 15; + lTable[(byte)''] = 10; + lTable[(byte)''] = 15; + lTable[(byte)''] = 10; + lTable[(byte)''] = 14; + lTable[(byte)''] = 11; + lTable[(byte)''] = 16; + lTable[(byte)''] = 10; + lTable[(byte)''] = 15; + lTable[(byte)''] = 11; + lTable[(byte)''] = 15; + lTable[(byte)''] = 10; + lTable[(byte)''] = 15; + lTable[(byte)''] = 10; + lTable[(byte)''] = 15; + lTable[(byte)''] = 10; #ifdef FONT_RUSSIAN @@ -1226,244 +1226,244 @@ void RMFontCredits::Init(void) { // per le altre traduzioni. Per compilare Tony in altre lingue, // commentare via queste definizioni. - cTable[''] = 130; - cTable[''] = 131; - cTable[''] = 132; - cTable[''] = 133; - cTable[''] = 134; - cTable[''] = 135; - cTable[''] = 136; - cTable[''] = 137; - cTable[''] = 138; - cTable[''] = 139; - cTable[''] = 140; - cTable[''] = 141; - cTable[''] = 142; - cTable[''] = 143; - cTable[''] = 144; - cTable[''] = 145; - cTable[''] = 146; - cTable[''] = 147; - cTable[''] = 148; - cTable[''] = 149; - cTable[''] = 150; - cTable[''] = 151; - cTable[''] = 152; - cTable[''] = 153; - cTable[''] = 154; - cTable[''] = 155; - cTable[''] = 156; - cTable[''] = 157; - cTable[''] = 158; - cTable[''] = 159; - cTable[''] = 160; - cTable[''] = 161; - cTable[''] = 162; - - cTable[''] = 163; - cTable[''] = 164; - cTable[''] = 165; - cTable[''] = 166; - cTable[''] = 167; - cTable[''] = 168; - cTable[''] = 169; - cTable[''] = 170; - cTable[''] = 171; - cTable[''] = 172; - cTable[''] = 173; - cTable[''] = 174; - cTable[''] = 175; - cTable[''] = 176; - cTable[''] = 177; - cTable[''] = 178; - cTable[''] = 179; - cTable[''] = 180; - cTable[''] = 181; - cTable[''] = 182; - cTable[''] = 183; - cTable[''] = 184; - cTable[''] = 185; - cTable[''] = 186; - cTable[''] = 187; - cTable[''] = 188; - cTable[''] = 189; - cTable[''] = 190; - cTable[''] = 191; - cTable[''] = 192; - cTable[''] = 193; - cTable[''] = 194; - cTable[''] = 195; - - lTable[''] = 20; - lTable[''] = 16; - lTable[''] = 16; - lTable[''] = 14; - lTable[''] = 22; - lTable[''] = 15; - lTable[''] = 15; - lTable[''] = 20; - lTable[''] = 12; - lTable[''] = 16; - lTable[''] = 16; - lTable[''] = 16; - lTable[''] = 22; - lTable[''] = 18; - lTable[''] = 16; - lTable[''] = 15; - lTable[''] = 14; - lTable[''] = 13; - lTable[''] = 15; - lTable[''] = 12; - lTable[''] = 14; - lTable[''] = 15; - lTable[''] = 13; - lTable[''] = 16; - lTable[''] = 14; - lTable[''] = 23; - lTable[''] = 23; - lTable[''] = 10; - lTable[''] = 12; - lTable[''] = 16; - lTable[''] = 12; - lTable[''] = 20; - lTable[''] = 15; - - lTable[''] = 12; - lTable[''] = 10; - lTable[''] = 10; - lTable[''] = 11; - lTable[''] = 16; - lTable[''] = 10; - lTable[''] = 11; - lTable[''] = 13; - lTable[''] = 12; - lTable[''] = 13; - lTable[''] = 13; - lTable[''] = 12; - lTable[''] = 13; - lTable[''] = 14; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 12; - lTable[''] = 10; - lTable[''] = 10; - lTable[''] = 10; - lTable[''] = 11; - lTable[''] = 10; - lTable[''] = 11; - lTable[''] = 10; - lTable[''] = 15; - lTable[''] = 15; - lTable[''] = 10; - lTable[''] = 12; - lTable[''] = 16; - lTable[''] = 11; - lTable[''] = 13; - lTable[''] = 11; + cTable[(byte)''] = 130; + cTable[(byte)''] = 131; + cTable[(byte)''] = 132; + cTable[(byte)''] = 133; + cTable[(byte)''] = 134; + cTable[(byte)''] = 135; + cTable[(byte)''] = 136; + cTable[(byte)''] = 137; + cTable[(byte)''] = 138; + cTable[(byte)''] = 139; + cTable[(byte)''] = 140; + cTable[(byte)''] = 141; + cTable[(byte)''] = 142; + cTable[(byte)''] = 143; + cTable[(byte)''] = 144; + cTable[(byte)''] = 145; + cTable[(byte)''] = 146; + cTable[(byte)''] = 147; + cTable[(byte)''] = 148; + cTable[(byte)''] = 149; + cTable[(byte)''] = 150; + cTable[(byte)''] = 151; + cTable[(byte)''] = 152; + cTable[(byte)''] = 153; + cTable[(byte)''] = 154; + cTable[(byte)''] = 155; + cTable[(byte)''] = 156; + cTable[(byte)''] = 157; + cTable[(byte)''] = 158; + cTable[(byte)''] = 159; + cTable[(byte)''] = 160; + cTable[(byte)''] = 161; + cTable[(byte)''] = 162; + + cTable[(byte)''] = 163; + cTable[(byte)''] = 164; + cTable[(byte)''] = 165; + cTable[(byte)''] = 166; + cTable[(byte)''] = 167; + cTable[(byte)''] = 168; + cTable[(byte)''] = 169; + cTable[(byte)''] = 170; + cTable[(byte)''] = 171; + cTable[(byte)''] = 172; + cTable[(byte)''] = 173; + cTable[(byte)''] = 174; + cTable[(byte)''] = 175; + cTable[(byte)''] = 176; + cTable[(byte)''] = 177; + cTable[(byte)''] = 178; + cTable[(byte)''] = 179; + cTable[(byte)''] = 180; + cTable[(byte)''] = 181; + cTable[(byte)''] = 182; + cTable[(byte)''] = 183; + cTable[(byte)''] = 184; + cTable[(byte)''] = 185; + cTable[(byte)''] = 186; + cTable[(byte)''] = 187; + cTable[(byte)''] = 188; + cTable[(byte)''] = 189; + cTable[(byte)''] = 190; + cTable[(byte)''] = 191; + cTable[(byte)''] = 192; + cTable[(byte)''] = 193; + cTable[(byte)''] = 194; + cTable[(byte)''] = 195; + + lTable[(byte)''] = 20; + lTable[(byte)''] = 16; + lTable[(byte)''] = 16; + lTable[(byte)''] = 14; + lTable[(byte)''] = 22; + lTable[(byte)''] = 15; + lTable[(byte)''] = 15; + lTable[(byte)''] = 20; + lTable[(byte)''] = 12; + lTable[(byte)''] = 16; + lTable[(byte)''] = 16; + lTable[(byte)''] = 16; + lTable[(byte)''] = 22; + lTable[(byte)''] = 18; + lTable[(byte)''] = 16; + lTable[(byte)''] = 15; + lTable[(byte)''] = 14; + lTable[(byte)''] = 13; + lTable[(byte)''] = 15; + lTable[(byte)''] = 12; + lTable[(byte)''] = 14; + lTable[(byte)''] = 15; + lTable[(byte)''] = 13; + lTable[(byte)''] = 16; + lTable[(byte)''] = 14; + lTable[(byte)''] = 23; + lTable[(byte)''] = 23; + lTable[(byte)''] = 10; + lTable[(byte)''] = 12; + lTable[(byte)''] = 16; + lTable[(byte)''] = 12; + lTable[(byte)''] = 20; + lTable[(byte)''] = 15; + + lTable[(byte)''] = 12; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 16; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 13; + lTable[(byte)''] = 12; + lTable[(byte)''] = 13; + lTable[(byte)''] = 13; + lTable[(byte)''] = 12; + lTable[(byte)''] = 13; + lTable[(byte)''] = 14; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 12; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 15; + lTable[(byte)''] = 15; + lTable[(byte)''] = 10; + lTable[(byte)''] = 12; + lTable[(byte)''] = 16; + lTable[(byte)''] = 11; + lTable[(byte)''] = 13; + lTable[(byte)''] = 11; #endif // FONT_RUSSIAN #ifdef FONT_CZECH - cTable[''] = 196; - cTable[''] = 197; - cTable[''] = 198; - cTable[''] = 199; - cTable[''] = 200; - cTable[''] = 201; - cTable[''] = 202; - cTable[''] = 203; - cTable[''] = 204; - cTable[''] = 205; - cTable[''] = 206; - cTable[''] = 207; - cTable[''] = 208; - cTable[''] = 209; - cTable[''] = 210; - - cTable[''] = 211; - cTable[''] = 212; - cTable[''] = 213; - cTable[''] = 214; - cTable[''] = 215; - cTable[''] = 216; - cTable[''] = 217; - cTable[''] = 218; - cTable[''] = 219; - cTable[''] = 220; - cTable[''] = 221; - cTable[''] = 222; - cTable[''] = 223; - cTable[''] = 224; - cTable[''] = 225; - - lTable[''] = 15; - lTable[''] = 15; - lTable[''] = 15; - lTable[''] = 15; - lTable[''] = 15; - lTable[''] = 14; - lTable[''] = 20; - lTable[''] = 7; - lTable[''] = 15; - lTable[''] = 20; - lTable[''] = 19; - lTable[''] = 16; - lTable[''] = 15; - lTable[''] = 13; - lTable[''] = 13; - - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 10; - lTable[''] = 12; - lTable[''] = 6; - lTable[''] = 10; - lTable[''] = 15; - lTable[''] = 12; - lTable[''] = 11; - lTable[''] = 11; - lTable[''] = 10; - lTable[''] = 10; + cTable[(byte)''] = 196; + cTable[(byte)''] = 197; + cTable[(byte)''] = 198; + cTable[(byte)''] = 199; + cTable[(byte)''] = 200; + cTable[(byte)''] = 201; + cTable[(byte)''] = 202; + cTable[(byte)''] = 203; + cTable[(byte)''] = 204; + cTable[(byte)''] = 205; + cTable[(byte)''] = 206; + cTable[(byte)''] = 207; + cTable[(byte)''] = 208; + cTable[(byte)''] = 209; + cTable[(byte)''] = 210; + + cTable[(byte)''] = 211; + cTable[(byte)''] = 212; + cTable[(byte)''] = 213; + cTable[(byte)''] = 214; + cTable[(byte)''] = 215; + cTable[(byte)''] = 216; + cTable[(byte)''] = 217; + cTable[(byte)''] = 218; + cTable[(byte)''] = 219; + cTable[(byte)''] = 220; + cTable[(byte)''] = 221; + cTable[(byte)''] = 222; + cTable[(byte)''] = 223; + cTable[(byte)''] = 224; + cTable[(byte)''] = 225; + + lTable[(byte)''] = 15; + lTable[(byte)''] = 15; + lTable[(byte)''] = 15; + lTable[(byte)''] = 15; + lTable[(byte)''] = 15; + lTable[(byte)''] = 14; + lTable[(byte)''] = 20; + lTable[(byte)''] = 7; + lTable[(byte)''] = 15; + lTable[(byte)''] = 20; + lTable[(byte)''] = 19; + lTable[(byte)''] = 16; + lTable[(byte)''] = 15; + lTable[(byte)''] = 13; + lTable[(byte)''] = 13; + + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 12; + lTable[(byte)''] = 6; + lTable[(byte)''] = 10; + lTable[(byte)''] = 15; + lTable[(byte)''] = 12; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; #endif // FONT_CZECH #ifdef FONT_FRENCH - cTable[''] = 226; - cTable[''] = 227; - cTable[''] = 228; - cTable[''] = 229; - cTable[''] = 230; - cTable[''] = 231; - cTable[''] = 232; - cTable[''] = 233; - - lTable[''] = 12; - lTable[''] = 10; - lTable[''] = 10; - lTable[''] = 6; - lTable[''] = 10; - lTable[''] = 10; - lTable[''] = 11; - lTable[''] = 11; + cTable[(byte)''] = 226; + cTable[(byte)''] = 227; + cTable[(byte)''] = 228; + cTable[(byte)''] = 229; + cTable[(byte)''] = 230; + cTable[(byte)''] = 231; + cTable[(byte)''] = 232; + cTable[(byte)''] = 233; + + lTable[(byte)''] = 12; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 6; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; #endif // FONT_FRENCH #ifdef FONT_GERMAN - cTable[''] = 234; + cTable[(byte)''] = 234; // 'SS' = 235 // old chars overrides - cTable[''] = cTable[''] = 55; - cTable[''] = cTable[''] = 67; - cTable[''] = cTable[''] = 71; + cTable[(byte)''] = cTable[(byte)''] = 55; + cTable[(byte)''] = cTable[(byte)''] = 67; + cTable[(byte)''] = cTable[(byte)''] = 71; - lTable[''] = 11; + lTable[(byte)''] = 11; #endif // FONT_GERMAN } -- cgit v1.2.3 From 91328fce56144caf15abc8995b68a5a5a0562f0a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 5 May 2012 09:56:06 +1000 Subject: TONY: Fixed some more Valgrid identified errors --- engines/tony/font.cpp | 4 ++-- engines/tony/mpal/mpal.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 60c7b8d525..42540a2620 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -1055,8 +1055,8 @@ void RMFontCredits::Init(void) { cTable[(byte)''] = 57; // cTable[''] = 58; // e ^ // cTable[''] = 59; // e pallini - cTable[''] = 60; - cTable[''] = 61; + cTable[(byte)''] = 60; + cTable[(byte)''] = 61; // cTable[''] = 62; // i ^ // cTable[''] = 63; // i pallini cTable[(byte)''] = 64; diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index ec38083a76..5f88eef268 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -1518,7 +1518,7 @@ static HANDLE DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { return INVALID_HANDLE_VALUE; // Nella nuova versione scriviamo il numero dell'azione in dwRes - CopyMemory(newitem,item,sizeof(MPALITEM)); + Common::copy((byte *)item, (byte *)item + sizeof(MPALITEM), (byte *)newitem); /* newitem->Action[0].nCmds=item->Action[i].nCmds; CopyMemory(newitem->Action[0].CmdNum,item->Action[i].CmdNum,newitem->Action[0].nCmds*sizeof(newitem->Action[0].CmdNum[0])); */ -- cgit v1.2.3 From 734fae9193fdabd6dcac5f40f765d904c030f7d1 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 5 May 2012 10:32:43 +1000 Subject: TONY: Fixed some memory leaks identified by Valgrind --- engines/tony/gfxcore.cpp | 5 +++-- engines/tony/gfxengine.cpp | 3 +++ engines/tony/inventory.cpp | 13 ++++++++++--- engines/tony/loc.cpp | 8 ++++++++ engines/tony/loc.h | 3 +++ 5 files changed, 27 insertions(+), 5 deletions(-) (limited to 'engines') diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 5737a6af45..de78b51a4e 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -709,11 +709,12 @@ void RMGfxSourceBuffer8RLE::SetAlphaBlendColor(int color) { RMGfxSourceBuffer8RLE::RMGfxSourceBuffer8RLE() { alphaBlendColor = -1; bNeedRLECompress = true; + m_buf = NULL; } RMGfxSourceBuffer8RLE::~RMGfxSourceBuffer8RLE() { if (m_buf != NULL) { - delete m_buf; + delete[] m_buf; m_buf = NULL; } } @@ -833,7 +834,7 @@ void RMGfxSourceBuffer8RLE::CompressRLE(void) { // Ci copia l'immagine compressa x = cur - MegaRLEBuf; m_buf = new byte[x]; - CopyMemory(m_buf, MegaRLEBuf, x); + Common::copy(MegaRLEBuf, MegaRLEBuf + x, m_buf); } void RMGfxSourceBuffer8RLE::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 6b5105bc35..7f2515af7b 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -78,11 +78,14 @@ RMGfxEngine::RMGfxEngine() { // Crea il big buffer dove verranno disegnati i frame m_bigBuf.Create(RM_BBX, RM_BBY, 16); m_bigBuf.OffsetY(RM_SKIPY); + + csMainLoop = NULL; } RMGfxEngine::~RMGfxEngine() { // Chiude il buffer m_bigBuf.Destroy(); + g_system->deleteMutex(csMainLoop); } void RMGfxEngine::OpenOptionScreen(int type) { diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index ade9c0eb34..50e4dd9411 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -63,6 +63,7 @@ RMInventory::RMInventory() { m_state = CLOSED; m_bCombining = false; m_csModifyInterface = g_system->createMutex(); + m_nItems = 0; } RMInventory::~RMInventory() { @@ -94,7 +95,7 @@ void RMInventory::Init(void) { // Nuovi oggetti m_nItems = 78; // @@@ Numero di oggetti prendibili - m_items = new RMInventoryItem[m_nItems+1]; + m_items = new RMInventoryItem[m_nItems + 1]; curres = 10500; @@ -114,14 +115,15 @@ void RMInventory::Init(void) { ds.Close(); // Mette di default a pattern 1 - m_items[i].status=1; + m_items[i].pointer = NULL; + m_items[i].status = 1; m_items[i].icon.SetPattern(1); m_items[i].icon.DoFrame(this, false); curres++; if (i == 0 || i == 28 || i == 29) continue; - m_items[i].pointer=new RMGfxSourceBuffer8RLEByteAA[m_items[i].icon.NumPattern()]; + m_items[i].pointer = new RMGfxSourceBuffer8RLEByteAA[m_items[i].icon.NumPattern()]; for (j = 0; j < m_items[i].icon.NumPattern(); j++) { RMResRaw raw(curres); @@ -174,6 +176,11 @@ void RMInventory::Init(void) { void RMInventory::Close(void) { // Ciao memoria if (m_items != NULL) { + // Delete the item pointers + for (int i = 0; i <= m_nItems; i++) + delete[] m_items[i].pointer; + + // Delete the items array delete[] m_items; m_items = NULL; } diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 62249da255..b5a233391a 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -1694,6 +1694,14 @@ RMDataStream &operator>>(RMDataStream &ds, RMBox &box) { * RMBoxLoc Methods \****************************************************************************/ +RMBoxLoc::RMBoxLoc() { + boxes = NULL; +} + +RMBoxLoc::~RMBoxLoc() { + delete[] boxes; +} + void RMBoxLoc::ReadFromStream(RMDataStream &ds) { int i; char buf[2]; diff --git a/engines/tony/loc.h b/engines/tony/loc.h index c5c7859e73..c176367cd4 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -350,6 +350,9 @@ private: void ReadFromStream(RMDataStream& ds); public: + RMBoxLoc(); + virtual ~RMBoxLoc(); + friend RMDataStream& operator >>(RMDataStream &ds, RMBoxLoc &bl); void RecalcAllAdj(void); }; -- cgit v1.2.3 From 046620054f3b2817b366e3e3bc01b4a84206dd6f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 5 May 2012 10:56:56 +1000 Subject: TONY: Fix some Valgrind identified memory leaks --- engines/tony/font.cpp | 12 ++++++++++++ engines/tony/font.h | 1 + engines/tony/loc.cpp | 12 +++++++++++- engines/tony/loc.h | 6 +++++- engines/tony/tony.cpp | 1 + 5 files changed, 30 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 42540a2620..28e8f14d38 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -1829,6 +1829,18 @@ RMText::~RMText() { } +void RMText::Unload() { + if (m_fonts[0] != NULL) { + delete m_fonts[0]; + delete m_fonts[1]; + delete m_fonts[2]; + delete m_fonts[3]; + m_fonts[0] = m_fonts[1] = m_fonts[2] = m_fonts[3] = 0; + + g_system->unlockMutex(m_cs); + } +} + void RMText::SetMaxLineLength(int max) { maxLineLength = max; } diff --git a/engines/tony/font.h b/engines/tony/font.h index 33332db9f0..3012502d4c 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -215,6 +215,7 @@ protected: public: RMText(); virtual ~RMText(); + static void Unload(); // Setta il tipo di allineamento void SetAlignType(HORALIGN aHor, VERALIGN aVer) { aHorType=aHor; aVerType=aVer; } diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index b5a233391a..4bb1832102 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -1746,6 +1746,16 @@ RMDataStream &operator>>(RMDataStream &ds, RMBoxLoc &bl) { * RMGameBoxes methods \****************************************************************************/ +RMGameBoxes::RMGameBoxes() { + m_nLocBoxes = 0; + Common::fill(m_allBoxes, m_allBoxes + GAME_BOXES_SIZE, (RMBoxLoc *)NULL); +} + +RMGameBoxes::~RMGameBoxes() { + for (int i = 1; i <= m_nLocBoxes; ++i) + delete m_allBoxes[i]; +} + void RMGameBoxes::Init(void) { int i; RMString fn; @@ -1753,7 +1763,7 @@ void RMGameBoxes::Init(void) { // Load boxes from disk m_nLocBoxes = 130; - for (i=1; i <= m_nLocBoxes; i++) { + for (i = 1; i <= m_nLocBoxes; i++) { RMRes res(10000 + i); ds.OpenBuffer(res); diff --git a/engines/tony/loc.h b/engines/tony/loc.h index c176367cd4..9ed1a284d1 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -357,13 +357,17 @@ public: void RecalcAllAdj(void); }; +#define GAME_BOXES_SIZE 200 class RMGameBoxes { protected: - RMBoxLoc *m_allBoxes[200]; + RMBoxLoc *m_allBoxes[GAME_BOXES_SIZE]; int m_nLocBoxes; public: + RMGameBoxes(); + ~RMGameBoxes(); + void Init(void); void Close(void); diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 45545875e1..9ff306ca46 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -410,6 +410,7 @@ void TonyEngine::Close(void) { CloseMusic(); CloseHandle(m_hEndOfFrame); _theBoxes.Close(); + RMText::Unload(); _theEngine.Close(); m_wnd.Close(); } -- cgit v1.2.3 From e0a7b421857636d5cad2e74c971a676733e48c5b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 5 May 2012 11:15:38 +1000 Subject: TONY: Fixed some more Valgrind identified memory leaks --- engines/tony/game.cpp | 9 ++++++--- engines/tony/tony.cpp | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index b4b4253d08..1fe5956ffe 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -1412,9 +1412,12 @@ void RMPointer::Init(void) { void RMPointer::Close(void) { int i; - for (i = 0; i < 1; i++) - if (m_pointer[i] != NULL) - delete m_pointer[i], m_pointer[i] = NULL; + for (i = 0; i < 5; i++) { + if (m_pointer[i] != NULL) { + delete m_pointer[i]; + m_pointer[i] = NULL; + } + } } diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 9ff306ca46..f4e2f9f1c6 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -413,6 +413,7 @@ void TonyEngine::Close(void) { RMText::Unload(); _theEngine.Close(); m_wnd.Close(); + delete[] m_curThumbnail; } void TonyEngine::SwitchFullscreen(bool bFull) { -- cgit v1.2.3 From fbee927c6a648ee1e3f162f0ec6b9d298619dd9f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 5 May 2012 11:56:59 +1000 Subject: TONY: Fix another memory leak identified by Valgrind --- engines/tony/game.cpp | 6 ++++++ engines/tony/gfxcore.h | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 1fe5956ffe..03cc80d93d 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -1371,6 +1371,7 @@ bool RMOptionScreen::LoadThumbnailFromSaveState(int nState, byte *lpDestBuf, RMS RMPointer::RMPointer() { Common::fill(m_pointer, m_pointer + 16, (RMGfxSourceBuffer8 *)NULL); + Common::fill(m_specialPointer, m_specialPointer + 16, (RMItem *)NULL); } RMPointer::~RMPointer() { @@ -1417,6 +1418,11 @@ void RMPointer::Close(void) { delete m_pointer[i]; m_pointer[i] = NULL; } + + if (m_specialPointer[i] != NULL) { + delete m_specialPointer[i]; + m_specialPointer[i] = NULL; + } } } diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index 0f2c2553ec..88f2d6ed22 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -195,7 +195,7 @@ public: // Registration virtual void Register(void) { m_nInList++; } - virtual void Unregister(void) { m_nInList--; assert(m_nInList>=0); } + virtual void Unregister(void) { m_nInList--; assert(m_nInList >= 0); } }; -- cgit v1.2.3 From aa603d5a6719764e785e4bd096f16493f7ec7f6c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 5 May 2012 20:29:37 +1000 Subject: TONY: Fix a crash from objects being destroyed in the wrong order --- engines/tony/tony.cpp | 1 - engines/tony/tony.h | 3 +-- engines/tony/window.cpp | 11 ++++++++++- engines/tony/window.h | 4 ++-- 4 files changed, 13 insertions(+), 6 deletions(-) (limited to 'engines') diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index f4e2f9f1c6..457ba57153 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -410,7 +410,6 @@ void TonyEngine::Close(void) { CloseMusic(); CloseHandle(m_hEndOfFrame); _theBoxes.Close(); - RMText::Unload(); _theEngine.Close(); m_wnd.Close(); delete[] m_curThumbnail; diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 51cfdf74f3..c64bc884d6 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -108,7 +108,6 @@ public: FPSTREAM *m_stream[6]; FPSFX *m_sfx[MAX_SFX_CHANNELS]; FPSFX *m_utilSfx[MAX_SFX_CHANNELS]; - RMGfxEngine theEngine; RMFont *fonts[2]; bool m_bPaused; bool m_bDrawLocation; @@ -117,8 +116,8 @@ public: // Bounding box list manager RMGameBoxes _theBoxes; - RMGfxEngine _theEngine; RMWindow m_wnd; + RMGfxEngine _theEngine; bool m_bQuitNow; bool m_bTimeFreezed; diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index 41821ccacc..ae8d3612c3 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -57,9 +57,18 @@ namespace Tony { static uint16 m_wPrecalcTable[0x10000]; /****************************************************************************\ -* Metodi di RMWindow +* RMWindow Methods \****************************************************************************/ +RMWindow::RMWindow() { + m_Primary = NULL; m_Back = NULL; +} + +RMWindow::~RMWindow() { + Close(); + RMText::Unload(); +} + #ifdef REFACTOR_ME LRESULT CALLBACK GlobalWindowProc(HWND hWnd, uint32 msg, uint16 wParam, int32 lParam) { if ((HWND)theGame.m_wnd == NULL) diff --git a/engines/tony/window.h b/engines/tony/window.h index da8c5dc824..5949450e8f 100644 --- a/engines/tony/window.h +++ b/engines/tony/window.h @@ -121,8 +121,8 @@ protected: void WipeEffect(Common::Rect &rcBoundEllipse); public: - RMWindow() { m_Primary = NULL; m_Back = NULL; }; - ~RMWindow() { Close(); } + RMWindow(); + ~RMWindow(); // Inizializzazione void Init(/*HINSTANCE hInst*/); -- cgit v1.2.3 From 07c1369f98009a2d9f8b49a9f68ace7354469cba Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 5 May 2012 20:54:21 +1000 Subject: TONY: Created dummy event loop and started work on converting RMWindow class --- engines/tony/gfxengine.cpp | 2 +- engines/tony/tony.cpp | 38 ++-- engines/tony/tony.h | 2 +- engines/tony/window.cpp | 538 +-------------------------------------------- engines/tony/window.h | 67 ++---- 5 files changed, 60 insertions(+), 587 deletions(-) (limited to 'engines') diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 7f2515af7b..27db5c18bf 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -557,7 +557,7 @@ void RMGfxEngine::Init(/*HINSTANCE hInst*/) { m_bigBuf.DrawOT(); m_bigBuf.ClearOT(); delete load; - _vm->m_wnd.GetNewFrame(*this, NULL); + _vm->_window.GetNewFrame(*this, NULL); diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 457ba57153..293646e3f8 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -23,6 +23,7 @@ #include "common/scummsys.h" #include "common/algorithm.h" #include "common/config-manager.h" +#include "common/events.h" #include "common/file.h" #include "tony/tony.h" #include "tony/game.h" @@ -66,6 +67,9 @@ Common::ErrorCode TonyEngine::Init() { m_bDrawLocation = true; m_startTime = g_system->getMillis(); + // Initialise the graphics window + _window.Init(); + // Initialise the function list Common::fill(FuncList, FuncList + 300, (LPCUSTOMFUNCTION)NULL); @@ -220,7 +224,7 @@ void TonyEngine::UnloadAllUtilSFX(void) { void TonyEngine::InitMusic() { int i; - _theSound.Init(/*m_wnd*/); + _theSound.Init(/*_window*/); _theSound.SetMasterVolume(63); for (i = 0; i < 6; i++) @@ -349,7 +353,7 @@ void TonyEngine::CloseVoiceDatabase() { } void TonyEngine::GrabThumbnail(void) { - //m_wnd.GrabThumbnail(m_curThumbnail); + //_window.GrabThumbnail(m_curThumbnail); warning("TODO: TonyEngine::GrabThumbnail"); } @@ -369,8 +373,16 @@ void TonyEngine::Abort(void) { } void TonyEngine::Play(void) { - warning("TODO TonyEngine::Play"); - + // Main game loop + while (!shouldQuit() && !m_bQuitNow) { + g_system->delayMillis(50); + _window.Repaint(); + + Common::Event evt; + while (g_system->getEventManager()->pollEvent(evt)) + ; + } + #if 0 MSG msg; @@ -388,14 +400,14 @@ void TonyEngine::Play(void) { // Passa il buffer dall'engine alla finestra if (!m_bPaused) { if (!theEngine.m_bWiping) - m_wnd.GetNewFrame(theEngine, NULL); + _window.GetNewFrame(theEngine, NULL); else - m_wnd.GetNewFrame(theEngine, &theEngine.m_rcWipeEllipse); + _window.GetNewFrame(theEngine, &theEngine.m_rcWipeEllipse); } // Loop minchia dei messaggi - if (PeekMessage(&msg, m_wnd, 0, 0, true)) { - if (!TranslateAccelerator(m_wnd, m_hacc, &msg)) { + if (PeekMessage(&msg, _window, 0, 0, true)) { + if (!TranslateAccelerator(_window, m_hacc, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } @@ -411,12 +423,12 @@ void TonyEngine::Close(void) { CloseHandle(m_hEndOfFrame); _theBoxes.Close(); _theEngine.Close(); - m_wnd.Close(); + _window.Close(); delete[] m_curThumbnail; } void TonyEngine::SwitchFullscreen(bool bFull) { - m_wnd.SwitchFullscreen(bFull); + _window.SwitchFullscreen(bFull); _theEngine.SwitchFullscreen(bFull); } @@ -434,7 +446,7 @@ void TonyEngine::PauseLoop(void) { st = GetTime(); - while (m_bPaused && GetMessage(&msg,m_wnd,0,0)) { + while (m_bPaused && GetMessage(&msg,_window,0,0)) { TranslateMessage(&msg); DispatchMessage(&msg); } @@ -456,9 +468,9 @@ warning("TODO: TonyEninge::Pause"); theEngine.GDIControl(m_bPaused); if (m_bPaused) { - SetWindowText(m_wnd, "Tony Tough and the night of Roasted Moths - PAUSED"); + SetWindowText(_window, "Tony Tough and the night of Roasted Moths - PAUSED"); } else { - SetWindowText(m_wnd, "Tony Tough and the night of Roasted Moths"); + SetWindowText(_window, "Tony Tough and the night of Roasted Moths"); } */ } diff --git a/engines/tony/tony.h b/engines/tony/tony.h index c64bc884d6..e1526db026 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -116,7 +116,7 @@ public: // Bounding box list manager RMGameBoxes _theBoxes; - RMWindow m_wnd; + RMWindow _window; RMGfxEngine _theEngine; bool m_bQuitNow; diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index ae8d3612c3..c05af6b5e0 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -45,6 +45,8 @@ * * **************************************************************************/ +#include "common/scummsys.h" +#include "util.h" #include "tony/window.h" #include "tony/game.h" #include "tony/tony.h" @@ -61,7 +63,7 @@ static uint16 m_wPrecalcTable[0x10000]; \****************************************************************************/ RMWindow::RMWindow() { - m_Primary = NULL; m_Back = NULL; + } RMWindow::~RMWindow() { @@ -69,188 +71,9 @@ RMWindow::~RMWindow() { RMText::Unload(); } -#ifdef REFACTOR_ME -LRESULT CALLBACK GlobalWindowProc(HWND hWnd, uint32 msg, uint16 wParam, int32 lParam) { - if ((HWND)theGame.m_wnd == NULL) - return DefWindowProc(hWnd, msg, wParam, lParam); - - switch (msg) { - case WM_CREATE: - return 0; - - case WM_CLOSE: - PostQuitMessage(0); - return 0; - - default: - return theGame.m_wnd.WindowProc(msg, wParam, lParam); - } -} -#endif - -#ifdef REFACTOR_ME -LRESULT RMWindow::WindowProc(uint32 msg, uint16 wParam, int32 lParam) { - switch (msg) { - case WM_ACTIVATE: - if (LOWORD(wParam)!=WA_INACTIVE) - theGame.Pause(false); - else - theGame.Pause(true); - return 0; - - case WM_ENTERMENULOOP: - case WM_ENTERSIZEMOVE: - if (!m_bFullscreen) - theGame.Pause(true); - return 0; - - case WM_EXITMENULOOP: - case WM_EXITSIZEMOVE: - if (!m_bFullscreen) - theGame.Pause(false); - return 0; -/* - case WM_KEYDOWN: - switch (wParam) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - if (GetAsyncKeyState(VK_CONTROL)&0x8000) - theGame.SaveState(wParam-'0'); - else if (GetAsyncKeyState(VK_SHIFT)&0x8000) - theGame.LoadState(wParam-'0'); - return 0; - } - return 0; -*/ - - case WM_PAINT: -// Repaint(); - ValidateRect(m_hWnd, NULL); - return 0; - - case WM_COMMAND: - switch LOWORD(wParam) { -/* - case ID_OPTIONS: - theGame.OptionScreen(); - break; -*/ - - case ID_FULLSCREEN: - theGame.SwitchFullscreen(!m_bFullscreen); - break; -/* - case ID_ENABLEINPUT: - theGame.GetEngine()->EnableInput(); - break; -*/ - case ID_SCREENSHOT: - m_bGrabScreenshot = true; -// m_bGrabMovie = !m_bGrabMovie; - break; - - case ID_MOVIE: -// m_bGrabMovie = !m_bGrabMovie; - break; -/* - case ID_BLACKWHITE: - m_bBlackWhite = !m_bBlackWhite; - break; -*/ - default: - return DefWindowProc(m_hWnd, msg, wParam, lParam); - } - return 0; - - case WM_SYSKEYDOWN: - if (m_bFullscreen) - return 0; - else - return DefWindowProc(m_hWnd ,msg, wParam, lParam); - - default: - if (m_hWnd != NULL) // Fix del bug visto da BoundsChecker - return DefWindowProc(m_hWnd, msg, wParam, lParam); - return 0; - } -} -#endif - -/* -HANDLE hWaitFlip; -bool bExitThread; - -void DoFlipThread(LPDIRECTDRAWSURFACE lpDDSPrimary) { - bExitThread=false; - while (1) { - WaitForSingleObject(hWaitFlip,INFINITE); - if (bExitThread) _endthread(); - lpDDSPrimary->Flip(NULL,DDFLIP_WAIT); - } -} -*/ - -void RMWindow::InitDirectDraw(void) { -#ifdef REFACTOR_ME - DDInit(); - - ShowCursor(false); - ShowWindow(m_hWnd, SW_SHOW); - UpdateWindow(m_hWnd); -#endif -} - -void RMWindow::Init(/*HINSTANCE hInst*/) { -#ifdef REFACTOR_ME - WNDCLASS wc; - - // Registra la classe di finestra - wc.style = CS_HREDRAW|CS_VREDRAW; - wc.lpfnWndProc = GlobalWindowProc; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - wc.hInstance = hInst; - wc.hIcon = LoadIcon(hInst,MAKEINTRESOURCE(IDI_ICON1)); - wc.hCursor = LoadCursor(NULL,IDC_ARROW); - wc.hbrBackground = NULL; - wc.lpszMenuName = NULL; - wc.lpszClassName = "RMClass"; - RegisterClass(&wc); - - m_hWnd = CreateWindow( - "RMClass", - "Tony Tough and the night of Roasted Moths", - WS_OVERLAPPEDWINDOW & (~WS_THICKFRAME) & (~WS_BORDER) & (~WS_MAXIMIZEBOX), - 50, 50, - RM_SX + GetSystemMetrics(SM_CXDLGFRAME) * 2, - RM_SY + GetSystemMetrics(SM_CYDLGFRAME) * 2 + GetSystemMetrics(SM_CYMENU) + GetSystemMetrics(SM_CYCAPTION), - NULL, - NULL, - hInst, - NULL - ); - - if (m_hWnd == NULL) { - int err = GetLastError(); - RMString str; - - str.Format("error: %u",err); - MessageBox(NULL,str,"sux",MB_OK); - - assert(0); - } - - // Inizializza la finestra directdraw - //DDInit(); +void RMWindow::Init() { + initGraphics(RM_SX, RM_SY, false); // Inizializza i conteggi degli FPS fps = lastfcount = fcount = lastsecond = 0; @@ -258,361 +81,20 @@ void RMWindow::Init(/*HINSTANCE hInst*/) { m_bGrabScreenshot = false; m_bGrabThumbnail = false; m_bGrabMovie = false; - - //hWaitFlip = CreateEvent(NULL,false,false, NULL); -#endif } void RMWindow::Close(void) { - DDClose(); -#ifdef REFACTOR_ME - DestroyWindow(m_hWnd); -#endif } void RMWindow::GrabThumbnail(uint16 *thumbmem) { - m_bGrabThumbnail = true; - m_wThumbBuf = thumbmem; -} - -float RGB_to_HSL(float r,float g, float b, float *h, float *s, float *l) { - float v; - float m; - float vm; - float r2, g2, b2; - - if (r > g) v = r; else v = g; - if (v > b) v = v; else v = b; - if (r < b) m = r; else m = b; - if (m < b) m = m; else m = b; - - if ((*l = (m + v) / 2.0f) <= 0.0f) return *l; - if ((*s = vm = v - m) > 0.0f) { - *s /= (*l <= 0.5f) ? (v + m) : (2.0f - v - m) ; - } else - return *l; - - r2 = (v - r) / vm; - g2 = (v - g) / vm; - b2 = (v - b) / vm; - - if (r == v) - *h = (g == m ? 5.0f + b2 : 1.0f - g2); - else if (g == v) - *h = (b == m ? 1.0f + r2 : 3.0f - b2); - else - *h = (r == m ? 3.0f + g2 : 5.0f - r2); - - *h /= 6; - - return *l; -} - -#define ITOF(val) (float)((float)(val) / 31.0f) -#define FTOI(val) (int)(((float)(val) * 31.0f + 0.5f)) - -void RMWindow::CreateBWPrecalcTable(void) { -#define CLAMP(var, min, max) var = (var < min ? min : (var > max ? max : var)); - - int i; - int r, g, b; - int min, max; - int shiftR, shiftG, shiftB; - - // Calcola i valori di shift in base alle maschere - for (shiftR = 15; (mskRed & (1 << shiftR)) == 0; shiftR--) - ; - for (shiftG = 15; (mskGreen & (1 << shiftG)) == 0; shiftG--) - ; - for (shiftB = 15; (mskBlue & (1 << shiftB)) == 0; shiftB--) - ; - - shiftR -= 4; - shiftG -= 4; - shiftB -= 4; - - // @@@ CLAMP inutile (in teoria) - CLAMP(shiftR, 0, 15); - CLAMP(shiftG, 0, 15); - CLAMP(shiftB, 0, 15); - - for (i = 0; i < 0x10000; i++) { - r=(i >> shiftR) & 0x1F; - g=(i >> shiftG) & 0x1F; - b=(i >> shiftB) & 0x1F; - -#if 1 - if (r < g) min=r; else min = g; - if (b < min) min = b; - if (r > g) max = r; else max = g; - if (b > max) max = b; - min = (min + max) / 2; -#else - // Nuova formula B&W. L'immagine pi fedele all'originale, ma l'effetto peggiore - float fr, fg, fb; - - fr = (float)r / 63.0f; - fg = (float)g / 63.0f; - fb = (float)b / 63.0f; - - min = (int)((fr*0.11f + fg*0.69f + fb*0.33f)*63.f); -#endif - - /* - RGB_to_HSL(ITOF(r), ITOF(g), ITOF(b), &h, &s, &l); - min = FTOI(l); - */ - - r = min + 8 - 8; - g = min + 5 - 8; - b = min + 0 - 8; - - CLAMP(r, 0, 31); - CLAMP(g, 0, 31); - CLAMP(b, 0, 31); - - m_wPrecalcTable[i] = (b << shiftB) | (g << shiftG) | (r << shiftR); - } -} - - -void RMWindow::DDClose(void) { -#ifdef REFACTOR_ME - DDRELEASE(m_Back); - DDRELEASE(m_Primary); - DDRELEASE(m_MainClipper); - DDRELEASE(m_BackClipper); - DDRELEASE(m_DD); -#endif -} - -void RMWindow::DDInit(void) { -#ifdef REFACTOR_ME - HRESULT err; - - // Crea DirectDraw - err = DirectDrawCreate(NULL, &m_DD, NULL); - assert(err == DD_OK); - - // Crea il clipper - err = DirectDrawCreateClipper(0, &m_MainClipper, NULL); - err=DirectDrawCreateClipper(0, &m_BackClipper, NULL); - - // Lo associa alla finestra - m_MainClipper->SetHWnd(0, m_hWnd); - - // Setta la cooperazione a normal - m_DD->SetCooperativeLevel(m_hWnd, DDSCL_NORMAL); - -#ifdef STARTFULLSCREEN - // Di default in fullscreen - m_bFullscreen=false; // Fa finta, per obbligarlo a cambiare - m_Primary=m_Back=NULL; - SwitchFullscreen(true); -#else - // Di default in finestra - m_bFullscreen = true; // Fa finta, per obbligarlo a cambiare - m_Primary = m_Back = NULL; - SwitchFullscreen(false); -#endif - -/* - if (!ISMODE1() && !ISMODE2() && !ISMODE3() && !ISMODE4()) { - RMString str; - str.Format("Graphic mode not supported: %04x %04x %04x",mskRed,mskGreen,mskBlue); - MessageBox(m_hWnd,str,"Debug",MB_OK); - } -*/ -#endif + warning("TODO: RMWindow::GrabThumbnail"); } - -void RMWindow::SwitchFullscreen(bool bFull) { -#ifdef REFACTOR_ME - HRESULT err; - DDSURFACEDESC ddsd; - DDSCAPS ddscaps; - DDBLTFX ddbltfx; - Common::Rect rcWin; - - // Se non c'e' niente da fare, esci - if (bFull == m_bFullscreen) - return; - - // Termina il thread di flipping - //bExitThread = true; - - // Rilascia le superfici create in precedenza (se ce n'erano) - DDRELEASE(m_Back); - DDRELEASE(m_Primary); - - // Legge le coordinate della finestra - if (m_bFullscreen) { - rcWin.left = 50; - rcWin.top = 50; - } else { - GetWindowRect(m_hWnd, &rcWin); - } - - if (bFull) { - // Setta la risoluzione - m_DD->SetCooperativeLevel(m_hWnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_ALLOWREBOOT); - m_DD->SetDisplayMode(RM_SX, RM_SY, 16); - - // A tutto schermo, possiamo creare una catena di flipping - ZeroMemory(&ddsd, sizeof(ddsd)); - ddsd.dwSize = sizeof(ddsd); - ddsd.dwFlags = DDSD_CAPS|DDSD_BACKBUFFERCOUNT; - ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP; - ddsd.dwBackBufferCount = 1; - if ((err=m_DD->CreateSurface(&ddsd, &m_Primary, NULL)) != DD_OK) { - //wsprintf(errbuf,"Error creating primary surface2 (%lx)",err); - //MessageBox(hWnd,errbuf,"grSwitchFullscreen()",MB_OK); - assert(0); - } - - ddscaps.dwCaps = DDSCAPS_BACKBUFFER; - if ((err=m_Primary->GetAttachedSurface(&ddscaps, &m_Back)) != DD_OK) { - //wsprintf(errbuf,"Error getting attached surface2 (%lx)",err); - //MessageBox(hWnd,errbuf,"grSwitchFullscreen()",MB_OK); - assert(0); - } - - // Pulisce i buffer - ddbltfx.dwSize = sizeof(ddbltfx); - ddbltfx.dwFillColor = 0; - m_Back->Blt(NULL, NULL, NULL,DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx); - - ddbltfx.dwSize=sizeof(ddbltfx); - ddbltfx.dwFillColor = 0; - m_Primary->Blt(NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx); - - // Inizializza il thread - //_beginthread((void (*)(void*))DoFlipThread,10240,(void*)m_Primary); - } else { - // In windowed, non possiamo fare flipping (purtroppo) - m_DD->RestoreDisplayMode(); - m_DD->SetCooperativeLevel(m_hWnd,DDSCL_NORMAL); - - ZeroMemory(&ddsd,sizeof(ddsd)); - ddsd.dwSize=sizeof(ddsd); - ddsd.dwFlags=DDSD_CAPS; - ddsd.ddsCaps.dwCaps=DDSCAPS_PRIMARYSURFACE; - if ((err=m_DD->CreateSurface(&ddsd,&m_Primary, NULL)) != DD_OK) { - //wsprintf(errbuf,"Error creating primary surface (%lx)",err); - //MessageBox(hWnd,errbuf,"ChangeResolution()",MB_OK); - assert(0); - } - - ZeroMemory(&ddsd,sizeof(ddsd)); - ddsd.dwSize=sizeof(ddsd); - ddsd.dwFlags=DDSD_CAPS|DDSD_WIDTH|DDSD_HEIGHT; - ddsd.ddsCaps.dwCaps=DDSCAPS_OFFSCREENPLAIN; // se puo', in video memory - ddsd.dwWidth=RM_SX; - ddsd.dwHeight=RM_SY; - if ((err=m_DD->CreateSurface(&ddsd,&m_Back, NULL)) != DD_OK) { - //wsprintf(errbuf,"Error creating backbuffer surface (%lx)",err); - //MessageBox(hWnd,errbuf,"ChangeResolution()",MB_OK); - assert(0); - } - - // Pulizia per favore - ddbltfx.dwSize = sizeof(ddbltfx); - ddbltfx.dwFillColor = 0; - m_Back->Blt(NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx); - } - - // Posiziona e ridimensiona la finestra - if (bFull) { - SetWindowPos(m_hWnd, HWND_TOP, 0, 0, RM_SX, RM_SY, 0); - - // Disabilita il clipper (non necessario) - m_Primary->SetClipper(NULL); - } else { - SetWindowPos(m_hWnd, HWND_TOP, rcWin.left, rcWin.top, RM_SX + GetSystemMetrics(SM_CXDLGFRAME) * 2, - RM_SY + GetSystemMetrics(SM_CYDLGFRAME) * 2 + GetSystemMetrics(SM_CYCAPTION), 0); - - m_Primary->SetClipper(m_MainClipper); - //m_Primary->SetClipper(NULL); - } - - // Si ricorda il nuovo stato - m_bFullscreen = bFull; - InvalidateRect(m_hWnd, NULL, false); - - // Legge il nuovo pixel format - UpdatePixelFormat(); -#endif -} - -void RMWindow::UpdatePixelFormat(void) { -#ifdef REFACTOR_ME - DDPIXELFORMAT ddpf; - - // Si fa ridare il nuovo pixel format - ddpf.dwSize = sizeof(ddpf); - m_Primary->GetPixelFormat(&ddpf); - - // Copia le componenti dei colori - mskRed = ddpf.dwRBitMask; - mskGreen = ddpf.dwGBitMask; - mskBlue = ddpf.dwBBitMask; - - // Ricalcola la tabella per l'effetto b&w - CreateBWPrecalcTable(); -#endif -} - - +/** + * Repaint the screen + */ void RMWindow::Repaint(void) { -#ifdef REFACTOR_ME - Common::Rect rcWin; - HRESULT err; - - if (m_Primary==NULL) - return; - - // Se siamo a tutto schermo, basta un flip - if (m_bFullscreen) { - m_DD->WaitForVerticalBlank(DDWAITVB_BLOCKBEGIN, NULL); - - // Flippa flappa - while (1) { - //err=m_Primary->Flip(NULL,DDFLIP_WAIT); - err = m_Primary->BltFast(0, 0, m_Back, NULL, DDBLTFAST_WAIT); - - if (err==DD_OK) - break; - else if (err == DDERR_SURFACELOST) { - //MessageBox(NULL,"Primary lost!","RMWindow::Repaint()",MB_OK); - m_Primary->Restore(); - return; - } - } - } - // Altrimenti bisogna andare di blit - else { - // Si calcola il rettangolo effettivamente visibile - GetWindowRect(m_hWnd, &rcWin); - OffsetRect(&rcWin, GetSystemMetrics(SM_CXDLGFRAME), GetSystemMetrics(SM_CYDLGFRAME) + GetSystemMetrics(SM_CYCAPTION)); - - // Aggiusta le dimensioni del rettangolo - rcWin.right = rcWin.left + RM_SX; - rcWin.bottom = rcWin.top + RM_SY; - - // Blit del back nel primary - while (1) { - err = m_Primary->Blt(&rcWin, m_Back, NULL,DDBLT_WAIT, NULL); - if (err == DD_OK) - break; - else if (err == DDERR_SURFACELOST) { - //MessageBox(NULL,"Primary lost!","RMWindow::Repaint()",MB_OK); - m_Primary->Restore(); - return; - } - } - } -#endif + g_system->updateScreen(); } diff --git a/engines/tony/window.h b/engines/tony/window.h index 5949450e8f..2edf409ad0 100644 --- a/engines/tony/window.h +++ b/engines/tony/window.h @@ -81,28 +81,7 @@ private: bool Lock(DDSURFACEDESC &ddsd); void Unlock(DDSURFACEDESC &ddsd); - // Inizializza DirectDraw - void DDInit(void); - - // Chiude DirectDraw - void DDClose(void); - - // Repaint grafico tramite DirectDraw - void Repaint(void); - - // Window Proc principale che richiama la WindowProc dentro la classe -// friend LRESULT CALLBACK GlobalWindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); - - // Procedura di gestione messaggi -// LRESULT WindowProc(UINT msg, WPARAM wParam, LPARAM lParam); - protected: - HWND m_hWnd; - bool m_bFullscreen; - - void * /*LPDIRECTDRAW*/ m_DD; - void * /*LPDIRECTDRAWSURFACE*/ m_Primary; - void * /*LPDIRECTDRAWSURFACE*/ m_Back; void * /*LPDIRECTDRAWCLIPPER*/ m_MainClipper; void * /*LPDIRECTDRAWCLIPPER*/ m_BackClipper; @@ -117,37 +96,37 @@ protected: uint16 *m_wThumbBuf; void CreateBWPrecalcTable(void); - void UpdatePixelFormat(void); void WipeEffect(Common::Rect &rcBoundEllipse); - public: - RMWindow(); - ~RMWindow(); +public: + RMWindow(); + ~RMWindow(); - // Inizializzazione - void Init(/*HINSTANCE hInst*/); - void InitDirectDraw(void); - void Close(void); + // Inizializzazione + void Init(/*HINSTANCE hInst*/); + void InitDirectDraw(void); + void Close(void); - // Switch tra windowed e fullscreen - void SwitchFullscreen(bool bFull); + // Repaint grafico tramite DirectDraw + void Repaint(void); - // Legge il prossimo frame - void GetNewFrame(byte *lpBuf, Common::Rect *rcBoundEllipse); + // Switch tra windowed e fullscreen + void SwitchFullscreen(bool bFull) {} - // Avverte di grabbare un thumbnail per il salvataggio - void GrabThumbnail(uint16 *buf); + // Legge il prossimo frame + void GetNewFrame(byte *lpBuf, Common::Rect *rcBoundEllipse); - operator HWND() { return m_hWnd; } + // Avverte di grabbare un thumbnail per il salvataggio + void GrabThumbnail(uint16 *buf); - // Modi pixel format - // MODE1: 1555 - // MODE2: 5515 - // MODE3: 5551 - bool ISMODE1() { return (mskRed == 0x7C00 && mskGreen == 0x3E0 && mskBlue== 0x1F); } - bool ISMODE2() { return (mskRed == 0xF800 && mskGreen == 0x7E0 && mskBlue== 0x1F); } - bool ISMODE3() { return (mskRed == 0xF800 && mskGreen == 0x7C0 && mskBlue== 0x3E); } - bool ISMODE4() { return (mskBlue == 0xF800 && mskGreen == 0x7E0 && mskRed== 0x1F); } + // Modi pixel format + // MODE1: 1555 + // MODE2: 5515 + // MODE3: 5551 + bool ISMODE1() { return (mskRed == 0x7C00 && mskGreen == 0x3E0 && mskBlue== 0x1F); } + bool ISMODE2() { return (mskRed == 0xF800 && mskGreen == 0x7E0 && mskBlue== 0x1F); } + bool ISMODE3() { return (mskRed == 0xF800 && mskGreen == 0x7C0 && mskBlue== 0x3E); } + bool ISMODE4() { return (mskBlue == 0xF800 && mskGreen == 0x7E0 && mskRed== 0x1F); } }; } // End of namespace Tony -- cgit v1.2.3 From 5625846bf2a0015e212ea2f1d97543cbba81e0c7 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 5 May 2012 22:32:40 +1000 Subject: TONY: Further conversion work on window conversion --- engines/tony/window.cpp | 480 ++++-------------------------------------------- engines/tony/window.h | 13 +- 2 files changed, 34 insertions(+), 459 deletions(-) (limited to 'engines') diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index c05af6b5e0..8e23ec8aa5 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -55,9 +55,6 @@ namespace Tony { #define DDRELEASE(x) if (x) { (x)->Release(); (x)=NULL; } -// Tabella per il b&w. Globale per accederci dalla roba ASM -static uint16 m_wPrecalcTable[0x10000]; - /****************************************************************************\ * RMWindow Methods \****************************************************************************/ @@ -71,7 +68,9 @@ RMWindow::~RMWindow() { RMText::Unload(); } - +/** + * Initialises the graphics window + */ void RMWindow::Init() { initGraphics(RM_SX, RM_SY, false); @@ -83,6 +82,9 @@ void RMWindow::Init() { m_bGrabMovie = false; } +/** + * Close the window + */ void RMWindow::Close(void) { } @@ -97,467 +99,47 @@ void RMWindow::Repaint(void) { g_system->updateScreen(); } - -void RMWindow::Unlock(DDSURFACEDESC &ddsd) { -#ifdef REFACTOR_ME - m_Back->Unlock(ddsd.lpSurface); -#endif +bool RMWindow::Lock() { + return true; } -void RMWindow::WipeEffect(Common::Rect &rcBoundEllipse) { -#ifdef REFACTOR_ME - Common::Rect rcScreen; - HRGN hrgnCombined; - HRGN hrgnScreen; - HRGN hrgnEllipse; - uint32 dwDataSize; - RGNDATA *rgnData; - - SetRect(&rcScreen, 0, 0, 640, 480); - - hrgnScreen = CreateRectRgnIndirect(&rcScreen); - hrgnEllipse = CreateEllipticRgnIndirect(&rcBoundEllipse); - hrgnCombined = CreateRectRgnIndirect(&rcScreen); - - CombineRgn(hrgnCombined, hrgnScreen, hrgnEllipse, RGN_DIFF); - - dwDataSize = GetRegionData(hrgnCombined, 0, NULL); - rgnData = (RGNDATA *)new char[dwDataSize]; - GetRegionData(hrgnCombined, dwDataSize, rgnData); - - m_BackClipper->SetClipList(rgnData, 0); - m_Back->SetClipper(m_BackClipper); - - DDBLTFX ddbltfx; - ddbltfx.dwSize=sizeof(ddbltfx); - ddbltfx.dwFillColor = 0; - m_Back->Blt(NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx); - - m_Back->SetClipper(NULL); - delete [] rgnData; - DeleteObject(hrgnCombined); - DeleteObject(hrgnEllipse); - DeleteObject(hrgnScreen); -#endif +void RMWindow::Unlock() { } -bool RMWindow::Lock(DDSURFACEDESC &ddsd) { -#ifdef REFACTOR_ME - HRESULT err; +/** + * Wipes an area of the screen + */ +void RMWindow::WipeEffect(Common::Rect &rcBoundEllipse) { + if ((rcBoundEllipse.left == 0) && (rcBoundEllipse.top == 0) && + (rcBoundEllipse.right == RM_SX) && (rcBoundEllipse.bottom == RM_SY)) { + // Full screen clear wanted, so use shortcut method + g_system->fillScreen(0); + } else { + // Clear the designated area a line at a time + byte line[RM_SX]; + Common::fill(line, line + RM_SX, 0); - // Lock della surface - ddsd.dwSize = sizeof(ddsd); - while (1) { - err = m_Back->Lock(NULL,&ddsd,DDLOCK_WAIT|DDLOCK_WRITEONLY|DDLOCK_NOSYSLOCK, NULL); - if (err==DD_OK) - break; - else if (err==DDERR_SURFACELOST) { -// MessageBox(NULL,"Primary lost!","RMWindow::Repaint()",MB_OK); - m_Back->Restore(); - return false; + // Loop through each line + for (int yp = rcBoundEllipse.top; yp < rcBoundEllipse.bottom; ++yp) { + g_system->copyRectToScreen(line, RM_SX, rcBoundEllipse.left, yp, rcBoundEllipse.width(), 1); } } -#endif - return true; } void RMWindow::GetNewFrame(byte *lpBuf, Common::Rect *rcBoundEllipse) { -#ifdef REFACTOR_ME - HRESULT err; - DDSURFACEDESC ddsd; - int x,y; - byte *dest; - uint16 *destw; - RMString s; - uint16 *src,src2; - - if (GetAsyncKeyState(VK_F7)&0x8001) - goto DOFRAMERATE; - - if (!Lock(ddsd)) - return; - - // Copia del buffer - src = (uint16 *)lpBuf; - dest = (byte *)ddsd.lpSurface; -// src+=RM_SKIPY*RM_BBX; Lo skipY e' integrato nell'offseting del bigbuffer - - if (ISMODE2()) { - // 565 RGB, Marco - Matrox G200 - int lineinc = (ddsd.lPitch / 2 - RM_SX) * 2; - int lineinc2 = (RM_BBX - RM_SKIPX - RM_SX) * 2; - destw = (uint16 *)dest; - - if (bCfgAnni30) { - __asm { - pushad - - mov y,RM_SY - mov esi,src - mov edi,dest - - //ALIGN 4 - line30: - mov x,RM_SX - add esi,RM_SKIPX*2 - - line302: - mov eax,[esi] ; U 1 - mov ebx,[esi+4] ; V - mov ecx,eax ; U 2 - mov edx,ebx ; V - and eax,0x7FE07FE0 ; U 3 - and ebx,0x7FE07FE0 ; V - and ecx,0x001F001F ; U 4 - and edx,0x001F001F ; V - shl eax,1 ; U 5 - shl ebx,1 ; V - or eax,ecx ; U 6 - or ebx,edx ; V - - // Codice B&W - Pairato - mov ecx,eax - mov edx,ebx - and eax,0xFFFF - and ebx,0xFFFF - shr ecx,16 - shr edx,16 - mov eax,[offset m_wPrecalcTable + eax*2] - mov ebx,[offset m_wPrecalcTable + ebx*2] - mov ecx,[offset m_wPrecalcTable + ecx*2] - mov edx,[offset m_wPrecalcTable + edx*2] - shl ecx,16 - shl edx,16 - and eax,0xFFFF - and ebx,0xFFFF - or eax,ecx - or ebx,edx - - mov [edi],eax ; U 7 - mov [edi+4],ebx ; V - add esi,8 ; U 8 - add edi,8 ; V - sub x,4 ; U 9 - jnz line302 ; V - - add esi,lineinc2 - add edi,lineinc - - dec y - jnz line30 - - popad - } - - } else { - __asm { - pushad - - mov y,RM_SY - mov esi,src - mov edi,dest - - //ALIGN 4 - line: - mov x,RM_SX - add esi,RM_SKIPX*2 - - line2: - mov eax,[esi] ; U 1 - mov ebx,[esi+4] ; V - mov ecx,eax ; U 2 - mov edx,ebx ; V - and eax,0x7FE07FE0 ; U 3 - and ebx,0x7FE07FE0 ; V - and ecx,0x001F001F ; U 4 - and edx,0x001F001F ; V - shl eax,1 ; U 5 - shl ebx,1 ; V - or eax,ecx ; U 6 - or ebx,edx ; V - mov [edi],eax ; U 7 - mov [edi+4],ebx ; V - add esi,8 ; U 8 - add edi,8 ; V - sub x,4 ; U 9 - jnz line2 ; V - - add esi,lineinc2 - add edi,lineinc - - dec y - jnz line - - popad - } - } - } else if (ISMODE3()) { - // 5551 RGB - int lineinc = (ddsd.lPitch / 2 - RM_SX) * 2; - int lineinc2 = (RM_BBX - RM_SKIPX - RM_SX) * 2; - destw=(uint16 *)dest; - - if (bCfgAnni30) { - __asm { - mov y,RM_SY - mov esi,src - mov edi,dest - - aline30: - mov x,RM_SX - add esi,RM_SKIPX*2 - - aline302: - mov eax,[esi] ; U 1 - mov ebx,[esi+4] ; V - shl eax,1 ; U 2 - shl ebx,1 ; V - - // Codice B&W - Pairato - mov ecx,eax - mov edx,ebx - and eax,0xFFFF - and ebx,0xFFFF - shr ecx,16 - shr edx,16 - mov eax,[offset m_wPrecalcTable + eax*2] - mov ebx,[offset m_wPrecalcTable + ebx*2] - mov ecx,[offset m_wPrecalcTable + ecx*2] - mov edx,[offset m_wPrecalcTable + edx*2] - shl ecx,16 - shl edx,16 - and eax,0xFFFF - and ebx,0xFFFF - or eax,ecx - or ebx,edx - - mov [edi],eax ; U 3 - mov [edi+4],ebx ; V - add esi,8 ; U 4 - add edi,8 ; V - sub x,4 ; U 5 - jnz aline302 ; V - - add esi,lineinc2 - add edi,lineinc - - dec y - jnz aline30 - } - } else { - __asm { - mov y,RM_SY - mov esi,src - mov edi,dest - - aline: - mov x,RM_SX - add esi,RM_SKIPX*2 - - aline2: - mov eax,[esi] ; U 1 - mov ebx,[esi+4] ; V - shl eax,1 ; U 2 - shl ebx,1 ; V - mov [edi],eax ; U 3 - mov [edi+4],ebx ; V - add esi,8 ; U 4 - add edi,8 ; V - sub x,4 ; U 5 - jnz aline2 ; V - - add esi,lineinc2 - add edi,lineinc - - dec y - jnz aline - } - } - } else if (ISMODE4()) { - // 565 BGR - Intergraph - int lineinc=(ddsd.lPitch / 2 - RM_SX) * 2; - int lineinc2=(RM_BBX - RM_SKIPX - RM_SX) * 2; - destw=(uint16 *)dest; - - if (bCfgAnni30) // Manca supporto per Intergraph ... non so pairarlo!!! :) - { - __asm { - mov y,RM_SY - mov esi,src - mov edi,dest - - //ALIGN 4 - intersux30: - mov ecx,RM_SX - add esi,RM_SKIPX*2 - - intersux302: - mov eax,[esi] ; U 1 0BBBBBGGGGGRRRRR 0BBBBBGGGGGRRRRR - add esi,4 ; V - mov ebx,eax ; U 2 0BBBBBGGGGGRRRRR 0BBBBBGGGGGRRRRR - mov edx,eax ; V 0BBBBBGGGGGRRRRR 0BBBBBGGGGGRRRRR - shl eax,11 ; U 3 RRRRR0BBBBBGGGGG RRRRR00000000000 - and ebx,0x03E003E0 ; V 000000GGGGG00000 000000GGGGG00000 - and edx,0x7C007C00 ; U 4 0BBBBB0000000000 0BBBBB0000000000 - and eax,0xF800F800 ; V RRRRR00000000000 RRRRR00000000000 - shr edx,10 ; U 5 00000000000BBBBB 00000000000BBBBB - add ebx,ebx ; V 00000GGGGG000000 00000GGGGG000000 - or eax,edx ; U 6 RRRRR000000BBBBB RRRRR000000BBBBB - add edi,4 ; V - or eax,ebx ; U 7 RRRRRGGGGG0BBBBB RRRRRGGGGG0BBBBB - sub ecx,2 ; V - mov [edi-4],eax ; U 8 - jnz intersux302 ; V - - add esi,lineinc2 - add edi,lineinc - - dec y - jnz intersux30 - } - } else { - __asm { - mov y,RM_SY - mov esi,src - mov edi,dest - - //ALIGN 4 - intersux: - mov ecx,RM_SX - add esi,RM_SKIPX*2 - - intersux2: - mov eax,[esi] ; U 1 0BBBBBGGGGGRRRRR 0BBBBBGGGGGRRRRR - add esi,4 ; V - mov ebx,eax ; U 2 0BBBBBGGGGGRRRRR 0BBBBBGGGGGRRRRR - mov edx,eax ; V 0BBBBBGGGGGRRRRR 0BBBBBGGGGGRRRRR - shl eax,11 ; U 3 RRRRR0BBBBBGGGGG RRRRR00000000000 - and ebx,0x03E003E0 ; V 000000GGGGG00000 000000GGGGG00000 - and edx,0x7C007C00 ; U 4 0BBBBB0000000000 0BBBBB0000000000 - and eax,0xF800F800 ; V RRRRR00000000000 RRRRR00000000000 - shr edx,10 ; U 5 00000000000BBBBB 00000000000BBBBB - add ebx,ebx ; V 00000GGGGG000000 00000GGGGG000000 - or eax,edx ; U 6 RRRRR000000BBBBB RRRRR000000BBBBB - add edi,4 ; V - or eax,ebx ; U 7 RRRRRGGGGG0BBBBB RRRRRGGGGG0BBBBB - sub ecx,2 ; V - mov [edi-4],eax ; U 8 - jnz intersux2 ; V - - add esi,lineinc2 - add edi,lineinc - - dec y - jnz intersux - } - } + if (rcBoundEllipse == NULL) { + // Full screen update + g_system->copyRectToScreen(lpBuf, RM_SX, 0, 0, RM_SX, RM_SY); } else { - // 555 RGB - Computer di Bagio, nVidia Riva 128 - int lineinc = (ddsd.lPitch / 2 - RM_SX) * 2; - int lineinc2 = (RM_BBX - RM_SKIPX - RM_SX) * 2; - destw=(uint16 *)dest; - - if (bCfgAnni30) { - __asm { - mov y,RM_SY - mov esi,src - mov edi,dest - - bagioline30: - mov x,RM_SX - add esi,RM_SKIPX*2 - - bagioline302: - mov eax,[esi] ; U 1 - mov ebx,[esi+4] ; V - - // Codice B&W - Pairato - mov ecx,eax - mov edx,ebx - and eax,0xFFFF - and ebx,0xFFFF - shr ecx,16 - shr edx,16 - mov eax,[offset m_wPrecalcTable + eax*2] - mov ebx,[offset m_wPrecalcTable + ebx*2] - mov ecx,[offset m_wPrecalcTable + ecx*2] - mov edx,[offset m_wPrecalcTable + edx*2] - shl ecx,16 - shl edx,16 - and eax,0xFFFF - and ebx,0xFFFF - or eax,ecx - or ebx,edx - - mov [edi],eax ; U 3 - mov [edi+4],ebx ; V - add esi,8 ; U 4 - add edi,8 ; V - sub x,4 ; U 5 - jnz bagioline302 ; V - - add esi,lineinc2 - add edi,lineinc - - dec y - jnz bagioline30 - } - } else { - for (y = 0; y < RM_SY; y++) { - CopyMemory(dest, src + RM_SKIPX, RM_SX * 2); - dest += ddsd.lPitch; - src += RM_BBX; - } - } - } - - - // Unlock - Unlock(ddsd); - - // Effetto di wipe - if (rcBoundEllipse) { - WipeEffect(*rcBoundEllipse); - } - - // Repaint - Repaint(); - -DOFRAMERATE: - - // Conteggio per gli FPS - fcount++; - - if (lastsecond + 1000 < _vm->GetTime()) { - lastsecond = _vm->GetTime(); - fps=fcount - lastfcount; - lastfcount = fcount; - - if (!m_bFullscreen) { - s.Format("Tony Tough and the night of Roasted Moths - %u FPS",fps); - SetWindowText(m_hWnd,s); - } - } if (!_vm->getIsDemo()) { - if (m_bGrabScreenshot || m_bGrabMovie) { - RMSnapshot snapshot; - - snapshot.GrabScreenshot(lpBuf); - m_bGrabScreenshot = false; - } - - if (m_bGrabThumbnail) { - RMSnapshot snapshot; - - snapshot.GrabScreenshot(lpBuf, 4, m_wThumbBuf); - m_bGrabThumbnail = false; - } + // Update a screen section + g_system->copyRectToScreen(lpBuf, RM_SX, rcBoundEllipse->left, rcBoundEllipse->top, + rcBoundEllipse->width(), rcBoundEllipse->height()); } -#endif } /****************************************************************************\ -* Metodi di RMSnapshot +* RMSnapshot Methods \****************************************************************************/ char RMSnapshot::bufDrive[MAX_DRIVE]; diff --git a/engines/tony/window.h b/engines/tony/window.h index 2edf409ad0..5190fc4d16 100644 --- a/engines/tony/window.h +++ b/engines/tony/window.h @@ -78,8 +78,8 @@ public: class RMWindow { private: - bool Lock(DDSURFACEDESC &ddsd); - void Unlock(DDSURFACEDESC &ddsd); + bool Lock(); + void Unlock(); protected: void * /*LPDIRECTDRAWCLIPPER*/ m_MainClipper; @@ -119,14 +119,7 @@ public: // Avverte di grabbare un thumbnail per il salvataggio void GrabThumbnail(uint16 *buf); - // Modi pixel format - // MODE1: 1555 - // MODE2: 5515 - // MODE3: 5551 - bool ISMODE1() { return (mskRed == 0x7C00 && mskGreen == 0x3E0 && mskBlue== 0x1F); } - bool ISMODE2() { return (mskRed == 0xF800 && mskGreen == 0x7E0 && mskBlue== 0x1F); } - bool ISMODE3() { return (mskRed == 0xF800 && mskGreen == 0x7C0 && mskBlue== 0x3E); } - bool ISMODE4() { return (mskBlue == 0xF800 && mskGreen == 0x7E0 && mskRed== 0x1F); } + int getFps() const { return fps; } }; } // End of namespace Tony -- cgit v1.2.3 From 4fc57f13491781893edf4b4aa6e477b0e0fc02b8 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 5 May 2012 22:33:13 +1000 Subject: TONY: Added some class field initialisations --- engines/tony/gfxengine.cpp | 2 +- engines/tony/loc.cpp | 25 +++++++++++++++++++++++-- engines/tony/tony.cpp | 40 ++++++++++++++-------------------------- 3 files changed, 38 insertions(+), 29 deletions(-) (limited to 'engines') diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 27db5c18bf..f98942403d 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -288,7 +288,7 @@ SKIPCLICKSINISTRO: } // Anima Tony - m_tony.DoFrame(&m_bigBuf,m_nCurLoc); + m_tony.DoFrame(&m_bigBuf, m_nCurLoc); // Aggiorna lo scrolling per tenere Tony dentro lo schermo if (m_tony.MustUpdateScrolling() && m_bLocationLoaded) { diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 4bb1832102..9a2f4cfe6a 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -819,10 +819,21 @@ RMItem::RMItem() { m_bCurFlag = 0; m_patterns = NULL; m_sprites = NULL; - m_sfx= NULL; + m_sfx = NULL; m_curScroll.Set(0, 0); - m_bInitCurPattern=true; + m_bInitCurPattern = true; m_nCurPattern = 0; + m_z = 0; + m_cm = CM_256; + m_FX = 0; + m_FXparm = 0; + m_mpalCode = 0; + m_nSprites = 0; + m_nSfx = 0; + m_nPatterns = 0; + m_hEndPattern = 0; + m_bPal = 0; + m_nCurSprite = 0; m_hEndPattern = CreateEvent(NULL, false, false, NULL); } @@ -1632,6 +1643,16 @@ RMCharacter::RMCharacter() { curSpeed = 3; bRemoveFromOT = false; bMoving = false; + curLocation = 0; + curbox = 0; + dx = dy = 0; + olddx = olddy = 0; + fx = fy = slope = 0; + walkspeed = walkstatus = 0; + nextbox = 0; + pathlenght = pathcount = 0; + status = STAND; + theBoxes = NULL; m_pos.Set(0, 0); } diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 293646e3f8..cf746dc978 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -375,45 +375,33 @@ void TonyEngine::Abort(void) { void TonyEngine::Play(void) { // Main game loop while (!shouldQuit() && !m_bQuitNow) { + // Se siamo in pausa, entra nel loop appropriato + if (m_bPaused) + PauseLoop(); + g_system->delayMillis(50); - _window.Repaint(); Common::Event evt; while (g_system->getEventManager()->pollEvent(evt)) ; - } -#if 0 - MSG msg; + // Call the engine to handle the next frame + _theEngine.DoFrame(m_bDrawLocation); - do { - // Se siamo in pausa, entra nel loop appropriato - if (m_bPaused) - PauseLoop(); - - // Redraw del graphic engine - theEngine.DoFrame(m_bDrawLocation); - - // Avverte che finito un frame + // Warns that a frame is finished PulseEvent(m_hEndOfFrame); - // Passa il buffer dall'engine alla finestra + // Handle drawing the frame if (!m_bPaused) { - if (!theEngine.m_bWiping) - _window.GetNewFrame(theEngine, NULL); + if (!_theEngine.m_bWiping) + _window.GetNewFrame(_theEngine, NULL); else - _window.GetNewFrame(theEngine, &theEngine.m_rcWipeEllipse); + _window.GetNewFrame(_theEngine, &_theEngine.m_rcWipeEllipse); } - // Loop minchia dei messaggi - if (PeekMessage(&msg, _window, 0, 0, true)) { - if (!TranslateAccelerator(_window, m_hacc, &msg)) { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - } - } while (msg.message != WM_QUIT && !m_bQuitNow); -#endif + // Paint the frame onto the screen + _window.Repaint(); + } } -- cgit v1.2.3 From 162cc47c71767b264f157e3ebf9d61eea1f6bd97 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 5 May 2012 22:45:57 +1000 Subject: TONY: Fix screen initialisation to be in 16-bit mode --- engines/tony/window.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index 8e23ec8aa5..d5c9925111 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -72,7 +72,8 @@ RMWindow::~RMWindow() { * Initialises the graphics window */ void RMWindow::Init() { - initGraphics(RM_SX, RM_SY, false); + Graphics::PixelFormat pixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0); + initGraphics(RM_SX, RM_SY, false, &pixelFormat); // Inizializza i conteggi degli FPS fps = lastfcount = fcount = lastsecond = 0; -- cgit v1.2.3 From f7fd9e3d23260e5bab2750b37ef3b154b12ba232 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 5 May 2012 23:21:38 +1000 Subject: TONY: Fix display of the initial loading screen --- engines/tony/window.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'engines') diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index d5c9925111..36278a4f05 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -117,25 +117,21 @@ void RMWindow::WipeEffect(Common::Rect &rcBoundEllipse) { g_system->fillScreen(0); } else { // Clear the designated area a line at a time - byte line[RM_SX]; + uint16 line[RM_SX]; Common::fill(line, line + RM_SX, 0); // Loop through each line for (int yp = rcBoundEllipse.top; yp < rcBoundEllipse.bottom; ++yp) { - g_system->copyRectToScreen(line, RM_SX, rcBoundEllipse.left, yp, rcBoundEllipse.width(), 1); + g_system->copyRectToScreen((const byte *)&line[0], RM_SX * 2, rcBoundEllipse.left, yp, rcBoundEllipse.width(), 1); } } } void RMWindow::GetNewFrame(byte *lpBuf, Common::Rect *rcBoundEllipse) { - if (rcBoundEllipse == NULL) { - // Full screen update - g_system->copyRectToScreen(lpBuf, RM_SX, 0, 0, RM_SX, RM_SY); - } else { - // Update a screen section - g_system->copyRectToScreen(lpBuf, RM_SX, rcBoundEllipse->left, rcBoundEllipse->top, - rcBoundEllipse->width(), rcBoundEllipse->height()); - } + Common::Rect bounds = (rcBoundEllipse) ? *rcBoundEllipse : Common::Rect(0, 0, RM_SX, RM_SY); + + // Update a screen section + g_system->copyRectToScreen(lpBuf, RM_SX * 2, bounds.left, bounds.top, bounds.width(), bounds.height()); } -- cgit v1.2.3 From 607855cfbc892d4ecfa34f2c469a10e310e51124 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 5 May 2012 23:51:04 +1000 Subject: TONY: Formatting and endian fixes --- engines/tony/mpal/mpal.cpp | 629 ++++++++++++++++++++++----------------------- 1 file changed, 313 insertions(+), 316 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 5f88eef268..b977feb03b 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -311,9 +311,6 @@ static void UnlockScripts(void) { } - - - /****************************************************************************\ * * Function: int varGetValue(char * lpszVarName); @@ -334,11 +331,11 @@ int32 varGetValue(const char *lpszVarName) { int i; LPMPALVAR v=lpmvVars; - for (i=0;ilpszVarName)==0) + for (i = 0; i < nVars; v++, i++) + if (strcmp(lpszVarName, v->lpszVarName) == 0) return v->dwVal; - mpalError=1; + mpalError = 1; return 0; } @@ -356,16 +353,16 @@ int32 varGetValue(const char *lpszVarName) { void varSetValue(const char *lpszVarName, int32 val) { uint i; - LPMPALVAR v=lpmvVars; + LPMPALVAR v = lpmvVars; - for (i=0;ilpszVarName)==0) { - v->dwVal=val; - if (lpiifCustom!=NULL && strncmp(v->lpszVarName,"Pattern.",8) == 0) { + for (i = 0; i < nVars; v++, i++) + if (strcmp(lpszVarName, v->lpszVarName) == 0) { + v->dwVal = val; + if (lpiifCustom != NULL && strncmp(v->lpszVarName, "Pattern.", 8) == 0) { i = 0; sscanf(v->lpszVarName, "Pattern.%u", &i); - lpiifCustom(i,val,-1); - } else if (lpiifCustom!=NULL && strncmp(v->lpszVarName, "Status.", 7) == 0) { + lpiifCustom(i, val, -1); + } else if (lpiifCustom != NULL && strncmp(v->lpszVarName, "Status.", 7) == 0) { i = 0; sscanf(v->lpszVarName,"Status.%u", &i); lpiifCustom(i, -1, val); @@ -373,7 +370,7 @@ void varSetValue(const char *lpszVarName, int32 val) { return; } - mpalError=1; + mpalError = 1; return; } @@ -396,10 +393,10 @@ void varSetValue(const char *lpszVarName, int32 val) { static int locGetOrderFromNum(uint32 nLoc) { int i; - LPMPALLOCATION loc=lpmlLocations; + LPMPALLOCATION loc = lpmlLocations; - for (i=0;inObj==nLoc) + for (i = 0; i < nLocations; i++,loc++) + if (loc->nObj == nLoc) return i; return -1; @@ -425,8 +422,8 @@ static int msgGetOrderFromNum(uint32 nMsg) { int i; LPMPALMSG msg=lpmmMsgs; - for (i=0;iwNum==nMsg) + for (i = 0; i < nMsgs; i++, msg++) + if (msg->wNum == nMsg) return i; return -1; @@ -453,8 +450,8 @@ static int itemGetOrderFromNum(uint32 nItem) { int i; LPMPALITEM item=lpmiItems; - for (i=0;inObj==nItem) + for (i = 0; i < nItems; i++, item++) + if (item->nObj == nItem) return i; return -1; @@ -479,10 +476,10 @@ static int itemGetOrderFromNum(uint32 nItem) { static int scriptGetOrderFromNum(uint32 nScript) { int i; - LPMPALSCRIPT script=lpmsScripts; + LPMPALSCRIPT script = lpmsScripts; - for (i=0;inObj==nScript) + for (i = 0; i < nScripts; i++,script++) + if (script->nObj == nScript) return i; return -1; @@ -509,8 +506,8 @@ static int dialogGetOrderFromNum(uint32 nDialog) { int i; LPMPALDIALOG dialog=lpmdDialogs; - for (i=0;inObj==nDialog) + for (i = 0; i < nDialogs; i++, dialog++) + if (dialog->nObj == nDialog) return i; return -1; @@ -542,13 +539,13 @@ static char *DuplicateMessage(uint32 nMsgOrd) { origmsg = (const char *)GlobalLock(lpmmMsgs[nMsgOrd].hText); - j=0; - while (origmsg[j]!='\0' || origmsg[j+1]!='\0') + j = 0; + while (origmsg[j] != '\0' || origmsg[j+1] != '\0') j++; - j+=2; + j += 2; - clonemsg=(char *)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,j); - if (clonemsg==NULL) + clonemsg=(char *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, j); + if (clonemsg == NULL) return NULL; CopyMemory(clonemsg, origmsg, j); @@ -580,17 +577,17 @@ static char *DuplicateDialogPeriod(uint32 nPeriod) { LPMPALDIALOG dialog=lpmdDialogs+nExecutingDialog; int i,j; - for (j=0;dialog->Periods[j]!=NULL;j++) - if (dialog->PeriodNums[j]==nPeriod) { + for (j = 0; dialog->Periods[j] != NULL; j++) + if (dialog->PeriodNums[j] == nPeriod) { /* Trovata la frase, va duplicata */ origmsg = (const char *)GlobalLock(dialog->Periods[j]); /* Calcola la lunghezza e alloca la memoria */ - i=0; - while (origmsg[i]!='\0') i++; + i = 0; + while (origmsg[i] != '\0') i++; - clonemsg = (char *)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,i+1); - if (clonemsg==NULL) + clonemsg = (char *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, i + 1); + if (clonemsg == NULL) return NULL; CopyMemory(clonemsg, origmsg, i); @@ -644,7 +641,7 @@ HGLOBAL resLoad(uint32 dwId) { h = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, nSizeDecomp + (nSizeDecomp / 1024) * 16); buf = (byte *)GlobalLock(h); - temp = (byte *)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,nSizeComp); + temp = (byte *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT,nSizeComp); nBytesRead = hMpr.read(temp, nSizeComp); if (nBytesRead != nSizeComp) @@ -668,24 +665,24 @@ static uint32 *GetSelectList(uint32 i) { LPMPALDIALOG dialog=lpmdDialogs+nExecutingDialog; /* Conta quanti select attivi ci sono */ - num=0; - for (j=0;dialog->Choice[i].Select[j].dwData!=0;j++) + num = 0; + for (j = 0; dialog->Choice[i].Select[j].dwData != 0; j++) if (dialog->Choice[i].Select[j].curActive) num++; /* Se sono 0, e' un errore */ - if (num==0) + if (num == 0) return NULL; - sl= (uint32 *)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,sizeof(uint32)*(num+1)); - if (sl==NULL) + sl= (uint32 *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(uint32) * (num + 1)); + if (sl == NULL) return NULL; /* Copia il dato di ogni select attivo dentro la lista */ - k=0; - for (j=0;dialog->Choice[i].Select[j].dwData!=0;j++) + k = 0; + for (j = 0; dialog->Choice[i].Select[j].dwData != 0; j++) if (dialog->Choice[i].Select[j].curActive) - sl[k++]=dialog->Choice[i].Select[j].dwData; + sl[k++] = dialog->Choice[i].Select[j].dwData; sl[k] = (uint32)NULL; return sl; @@ -694,23 +691,23 @@ static uint32 *GetSelectList(uint32 i) { static uint32 *GetItemList(uint32 nLoc) { uint32 *il; uint32 num,i,j; - LPMPALVAR v=lpmvVars; + LPMPALVAR v = lpmvVars; - num=0; - for (i=0;ilpszVarName,"Location",8)==0 && v->dwVal==nLoc) + num = 0; + for (i = 0; i < nVars; i++,v++) { + if (strncmp(v->lpszVarName,"Location",8) == 0 && v->dwVal == nLoc) num++; } - il=(uint32 *)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,sizeof(uint32)*(num+1)); - if (il==NULL) + il=(uint32 *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(uint32) * (num + 1)); + if (il == NULL) return NULL; - v=lpmvVars; - j=0; - for (i=0;ilpszVarName,"Location",8)==0 && v->dwVal==nLoc) { - sscanf(v->lpszVarName,"Location.%u",&il[j]); + v = lpmvVars; + j = 0; + for (i = 0; i < nVars; i++,v++) { + if (strncmp(v->lpszVarName,"Location",8) == 0 && v->dwVal == nLoc) { + sscanf(v->lpszVarName, "Location.%u", &il[j]); j++; } } @@ -720,38 +717,38 @@ static uint32 *GetItemList(uint32 nLoc) { } static LPITEM GetItemData(uint32 nOrdItem) { - LPMPALITEM curitem=lpmiItems+nOrdItem; + LPMPALITEM curitem = lpmiItems+nOrdItem; LPITEM ret; HGLOBAL hDat; char *dat; - int i,j; + int i, j; char *patlength; uint32 dim; // Lo zeroinit e' obbligatorio!!!! - ret = (LPITEM)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,sizeof(ITEM)); - if (ret==NULL) + ret = (LPITEM)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(ITEM)); + if (ret == NULL) return NULL; - ret->speed=150; + ret->speed = 150; hDat = resLoad(curitem->dwRes); dat = (char *)GlobalLock(hDat); - if (dat[0]=='D' && dat[1]=='A' && dat[2]=='T') { - i=dat[3]; // Versione!! Per ora 1.0 - dat+=4; + if (dat[0] == 'D' && dat[1] == 'A' && dat[2] == 'T') { + i = dat[3]; // Versione!! Per ora 1.0 + dat += 4; - if (i>=0x10) { // Dalla 1.0 c'e' il punto di destinazione per ogni oggetto - ret->destX=*(uint16 *)dat; - ret->destY=*(uint16 *)(dat+2); + if (i >= 0x10) { // Dalla 1.0 c'e' il punto di destinazione per ogni oggetto + ret->destX = (int16)READ_LE_UINT16(dat); + ret->destY = (int16)READ_LE_UINT16(dat + 2); dat+=4; } - if (i>=0x11) {// Dalla 1.1 c'e' la velocita' di animazione - ret->speed=*(uint16 *)dat; - dat+=2; + if (i >= 0x11) {// Dalla 1.1 c'e' la velocita' di animazione + ret->speed = READ_LE_UINT16(dat); + dat += 2; } else - ret->speed=150; + ret->speed = 150; } ret->numframe=*dat++; @@ -759,25 +756,25 @@ static LPITEM GetItemData(uint32 nOrdItem) { ret->Zvalue=*dat++; // Carica le coordinate left&top di ogni frame - for (i=0;inumframe;i++) { - ret->frameslocations[i].left=*(short*)(dat); - ret->frameslocations[i].top=*(short*)(dat+2); - dat+=4; + for (i = 0; i < ret->numframe; i++) { + ret->frameslocations[i].left = (int16)READ_LE_UINT16(dat); + ret->frameslocations[i].top = (int16)READ_LE_UINT16(dat + 2); + dat += 4; } // Carica le dimensioni di ogni frame e calcola right&bottom - for (i=0;inumframe;i++) { - ret->frameslocations[i].right=*(uint16 *)(dat)+ret->frameslocations[i].left; - ret->frameslocations[i].bottom=*(uint16 *)(dat+2)+ret->frameslocations[i].top; + for (i = 0; i < ret->numframe; i++) { + ret->frameslocations[i].right = (int16)READ_LE_UINT16(dat) + ret->frameslocations[i].left; + ret->frameslocations[i].bottom = (int16)READ_LE_UINT16(dat + 2) + ret->frameslocations[i].top; dat+=4; } // Carica i bounding box di ogni frame - for (i=0;inumframe;i++) { - ret->bbox[i].left=*(uint16 *)(dat); - ret->bbox[i].top=*(uint16 *)(dat+2); - ret->bbox[i].right=*(uint16 *)(dat+4); - ret->bbox[i].bottom=*(uint16 *)(dat+6); + for (i = 0; i < ret->numframe; i++) { + ret->bbox[i].left = (int16)READ_LE_UINT16(dat); + ret->bbox[i].top = (int16)READ_LE_UINT16(dat + 2); + ret->bbox[i].right = (int16)READ_LE_UINT16(dat + 4); + ret->bbox[i].bottom = (int16)READ_LE_UINT16(dat + 6); dat+=8; } @@ -793,20 +790,20 @@ static LPITEM GetItemData(uint32 nOrdItem) { } // Carica i singoli frame di animazione - for (i=1;inumframe;i++) { - dim=(uint32)(ret->frameslocations[i].right-ret->frameslocations[i].left)* + for (i = 1; i < ret->numframe; i++) { + dim=(uint32)(ret->frameslocations[i].right-ret->frameslocations[i].left) * (uint32)(ret->frameslocations[i].bottom-ret->frameslocations[i].top); ret->frames[i]=(char *)GlobalAlloc(GMEM_FIXED,dim); - if (ret->frames[i]==NULL) + if (ret->frames[i] == NULL) return NULL; CopyMemory(ret->frames[i], dat, dim); - dat+=dim; + dat += dim; } // Controlla se siamo arrivati fino alla fine del file - i=*(uint16 *)dat; - if (i!=0xABCD) + i = READ_LE_UINT16(dat); + if (i != 0xABCD) return NULL; GlobalUnlock(hDat); @@ -832,7 +829,7 @@ static LPITEM GetItemData(uint32 nOrdItem) { \****************************************************************************/ void PASCAL CustomThread(LPCFCALL p) { - lplpFunctions[p->nCf](p->arg1,p->arg2,p->arg3,p->arg4); + lplpFunctions[p->nCf](p->arg1, p->arg2, p->arg3, p->arg4); GlobalFree(p); ExitThread(1); // _endthread(); @@ -863,28 +860,28 @@ void PASCAL ScriptThread(LPMPALSCRIPT s) { LPCFCALL p; // warning("PlayScript(): Moments: %u\n",s->nMoments); - for (i=0;inMoments;i++) { + for (i = 0; i < s->nMoments; i++) { // Dorme il tempo necessario per arrivare al momento successivo - if (s->Moment[i].dwTime==-1) { - WaitForMultipleObjects(numHandles,cfHandles,true,INFINITE); + if (s->Moment[i].dwTime == -1) { + WaitForMultipleObjects(numHandles, cfHandles, true, INFINITE); dwStartTime = timeGetTime(); } else { dwCurTime = timeGetTime(); - if (dwCurTime < dwStartTime+(s->Moment[i].dwTime*100)) { + if (dwCurTime < dwStartTime + (s->Moment[i].dwTime * 100)) { // warning("PlayScript(): Sleeping %lums\n",dwStartTime+(s->Moment[i].dwTime*100)-dwCurTime); - Sleep(dwStartTime+(s->Moment[i].dwTime*100)-dwCurTime); + Sleep(dwStartTime+(s->Moment[i].dwTime * 100) - dwCurTime); } } - numHandles=0; - for (j=0;jMoment[i].nCmds;j++) { + numHandles = 0; + for (j = 0;jMoment[i].nCmds; j++) { k=s->Moment[i].CmdNum[j]; switch (s->Command[k].type) { case 1: - p=(LPCFCALL)GlobalAlloc(GMEM_FIXED,sizeof(CFCALL)); - if (p==NULL) { - mpalError=1; + p=(LPCFCALL)GlobalAlloc(GMEM_FIXED, sizeof(CFCALL)); + if (p == NULL) { + mpalError = 1; ExitThread(0); // _endthread(); } @@ -896,9 +893,9 @@ void PASCAL ScriptThread(LPMPALSCRIPT s) { p->arg4=s->Command[k].arg4; // !!! Nuova gestione dei thread - if ((cfHandles[numHandles++]=CreateThread(NULL,10240,(LPTHREAD_START_ROUTINE)CustomThread,(void *)p,0,&dwId))==NULL) { + if ((cfHandles[numHandles++] = CreateThread(NULL, 10240, (LPTHREAD_START_ROUTINE)CustomThread,(void *)p, 0, &dwId)) == NULL) { //if ((cfHandles[numHandles++]=(void*)_beginthread(CustomThread, 10240, (void *)p))==(void*)-1) - mpalError=1; + mpalError = 1; ExitThread(0); // _endthread(); } @@ -914,7 +911,7 @@ void PASCAL ScriptThread(LPMPALSCRIPT s) { break; default: - mpalError=1; + mpalError = 1; GlobalFree(s); ExitThread(0); // _endthread(); @@ -943,9 +940,9 @@ void PASCAL ScriptThread(LPMPALSCRIPT s) { \****************************************************************************/ void PASCAL ActionThread(LPMPALITEM item) { - int j,k; + int j, k; - for (j=0;jAction[item->dwRes].nCmds;j++) { + for (j = 0;jAction[item->dwRes].nCmds; j++) { k=item->Action[item->dwRes].CmdNum[j]; switch (item->Command[k].type) { @@ -962,27 +959,27 @@ void PASCAL ActionThread(LPMPALITEM item) { case 2: // Variable assign LockVar(); - varSetValue(item->Command[k].lpszVarName,EvaluateExpression(item->Command[k].expr)); + varSetValue(item->Command[k].lpszVarName, EvaluateExpression(item->Command[k].expr)); UnlockVar(); break; default: - mpalError=1; + mpalError = 1; ExitThread(0); // _endthread(); } } GlobalFree(item); - //bExecutingAction=false; + //bExecutingAction = false; ExitThread(1); // _endthread(); } void PASCAL ShutUpActionThread(HANDLE hThread) { - WaitForSingleObject(hThread,INFINITE); - bExecutingAction=false; + WaitForSingleObject(hThread, INFINITE); + bExecutingAction = false; ExitThread(1); // _endthread(); @@ -1036,7 +1033,7 @@ void PASCAL LocationPollThread(uint32 id) { il = mpalQueryItemList(nPollingLocations[id]); /* Contiamo gli items */ - for (numitems=0;il[numitems]!=0;numitems++) + for (numitems = 0; il[numitems] != 0; numitems++) ; /* Cerchiamo gli items della locazione senza idle actions e li eliminiamo @@ -1051,7 +1048,7 @@ void PASCAL LocationPollThread(uint32 id) { curItem = lpmiItems + ord; - k=0; + k = 0; for (j = 0; j < curItem->nActions; j++) if (curItem->Action[j].num == 0xFF) k++; @@ -1132,49 +1129,49 @@ void PASCAL LocationPollThread(uint32 id) { /* Cerchiamo tra tutte le idle actions quella a cui manca meno tempo per l'esecuzione */ curTime = timeGetTime(); - dwSleepTime=(uint32)-1L; + dwSleepTime=(uint32) - 1L; - for (k=0;k=MyActions[k].dwLastTime+MyActions[k].wTime) { - dwSleepTime=0; + for (k = 0;k= MyActions[k].dwLastTime + MyActions[k].wTime) { + dwSleepTime = 0; break; } else - dwSleepTime=MIN(dwSleepTime,MyActions[k].dwLastTime+MyActions[k].wTime-curTime); + dwSleepTime = MIN(dwSleepTime,MyActions[k].dwLastTime+MyActions[k].wTime-curTime); /* Ci addormentiamo, ma controllando sempre l'evento che viene settato quando viene richiesta la nostra chiusura */ - k=WaitForSingleObject(hEndPollingLocations[id],dwSleepTime); - if (k==WAIT_OBJECT_0) + k = WaitForSingleObject(hEndPollingLocations[id], dwSleepTime); + if (k == WAIT_OBJECT_0) break; - for (i=0;i=MyActions[k].dwLastTime+MyActions[k].wTime) { - MyActions[k].dwLastTime+=MyActions[k].wTime; + for (k = 0; k < nIdleActions; k++) + if (curTime >= MyActions[k].dwLastTime + MyActions[k].wTime) { + MyActions[k].dwLastTime += MyActions[k].wTime; /* E' il momento di tirare il nostro dado virtuale, e controllare se la sorte e' dalla parte della idle action */ byte randomVal = (byte)_vm->_randomSource.getRandomNumber(99); if (randomVal < MyActions[k].perc) { /* Controlliamo se c'e' una action in esecuzione sull'item */ - if ((bExecutingAction) && (nExecutingAction==MyActions[k].nItem)) + if ((bExecutingAction) && (nExecutingAction == MyActions[k].nItem)) continue; /* Controlliamo se c'e' gia' un'altra idle function in esecuzione sullo stesso item */ - for (i=0;iAction[j].when!=NULL) + if (curItem->Action[j].when != NULL) if (!EvaluateExpression(curItem->Action[j].when)) { UnlockItems(); continue; @@ -1191,15 +1188,15 @@ void PASCAL LocationPollThread(uint32 id) { /* Ok, possiamo eseguire la azione. Per comodita' lo facciamo in un nuovo thread */ - newItem=(LPMPALITEM)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,sizeof(MPALITEM)); - if (newItem==false) { + newItem=(LPMPALITEM)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MPALITEM)); + if (newItem == false) { GlobalFree(MyThreads); GlobalFree(MyActions); ExitThread(0); // _endthread(); } - CopyMemory(newItem,curItem,sizeof(MPALITEM)); + CopyMemory(newItem,curItem, sizeof(MPALITEM)); UnlockItems(); /* Copiamo l'azione nella #0 */ @@ -1209,15 +1206,15 @@ void PASCAL LocationPollThread(uint32 id) { /* Creaiamo l'action thread. Provvedera' lui a liberare la memoria allocata per il nuovo item */ - for (i=0;iGroup[i].num!=0;i++) + for (i = 0; dialog->Group[i].num != 0; i++) if (dialog->Group[i].num==nGroup) { /* Cicla eseguendo i comandi del gruppo */ - for (j=0;jGroup[i].nCmds;j++) { + for (j = 0; j < dialog->Group[i].nCmds; j++) { k=dialog->Group[i].CmdNum[j]; switch (dialog->Command[k].type) { @@ -1348,7 +1345,7 @@ void PASCAL GroupThread(uint32 nGroup) { break; default: - mpalError=1; + mpalError = 1; UnlockDialogs(); ExitThread(0); // _endthread(); @@ -1363,7 +1360,7 @@ void PASCAL GroupThread(uint32 nGroup) { } /* Se siamo qui, vuol dire che non abbiamo trovato il gruppo richiesto */ - mpalError=1; + mpalError = 1; UnlockDialogs(); ExitThread(0); // _endthread(); @@ -1391,14 +1388,14 @@ void DoChoice(uint32 nChoice) { dialog=lpmdDialogs+nExecutingDialog; /* Cerca la scelta richiesta tra quelle nel dialogo */ - for (i=0;dialog->Choice[i].nChoice!=0;i++) - if (dialog->Choice[i].nChoice==nChoice) + for (i = 0; dialog->Choice[i].nChoice != 0; i++) + if (dialog->Choice[i].nChoice == nChoice) break; /* Se non l'ha trovata, esce con errore */ - if (dialog->Choice[i].nChoice==0) { + if (dialog->Choice[i].nChoice == 0) { /* Se siamo qui, non abbiamo trovato la choice richiesta */ - mpalError=1; + mpalError = 1; UnlockDialogs(); ExitThread(0); // _endthread(); @@ -1406,26 +1403,26 @@ void DoChoice(uint32 nChoice) { /* Abbiamo trova la choice richiesta. Ricordiamoci qual e' nella variabile globale */ - nExecutingChoice=i; + nExecutingChoice = i; while (1) { - nExecutingChoice=i; + nExecutingChoice = i; - k=0; + k = 0; /* Calcoliamo le when expression di ciascun select, per vedere se sono attivi o disattivi */ - for (j=0;dialog->Choice[i].Select[j].dwData!=0;j++) - if (dialog->Choice[i].Select[j].when==NULL) { - dialog->Choice[i].Select[j].curActive=1; + for (j = 0; dialog->Choice[i].Select[j].dwData != 0; j++) + if (dialog->Choice[i].Select[j].when == NULL) { + dialog->Choice[i].Select[j].curActive = 1; k++; } else if (EvaluateExpression(dialog->Choice[i].Select[j].when)) { - dialog->Choice[i].Select[j].curActive=1; + dialog->Choice[i].Select[j].curActive = 1; k++; } else - dialog->Choice[i].Select[j].curActive=0; + dialog->Choice[i].Select[j].curActive = 0; /* Se non ci sono scelte attivate, la scelta e' finita */ - if (k==0) { + if (k == 0) { UnlockDialogs(); break; } @@ -1434,22 +1431,22 @@ void DoChoice(uint32 nChoice) { e restiamo in attesa della risposta */ ResetEvent(hDoneChoice); SetEvent(hAskChoice); - WaitForSingleObject(hDoneChoice,INFINITE); + WaitForSingleObject(hDoneChoice, INFINITE); /* Ora che la scelta e' stata effettuata, possiamo eseguire i gruppi associati con la scelta */ j=nSelectedChoice; - for (k=0;dialog->Choice[i].Select[j].wPlayGroup[k]!=0;k++) + for (k = 0; dialog->Choice[i].Select[j].wPlayGroup[k] != 0; k++) GroupThread(dialog->Choice[i].Select[j].wPlayGroup[k]); /* Controllo sugli attributi */ - if (dialog->Choice[i].Select[j].attr&(1<<0)) { + if (dialog->Choice[i].Select[j].attr & (1 << 0)) { /* Bit 0 settato: fine della scelta */ UnlockDialogs(); break; } - if (dialog->Choice[i].Select[j].attr&(1<<1)) { + if (dialog->Choice[i].Select[j].attr & (1 << 1)) { /* Bit 1 settato: fine del dialogo */ UnlockDialogs(); ExitThread(1); @@ -1488,7 +1485,7 @@ void DoChoice(uint32 nChoice) { \****************************************************************************/ static HANDLE DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { - LPMPALITEM item=lpmiItems; + LPMPALITEM item = lpmiItems; int i; LPMPALITEM newitem; uint32 dwId; @@ -1496,25 +1493,25 @@ static HANDLE DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { item+=ordItem; Common::String buf = Common::String::format("Status.%u", item->nObj); - if (varGetValue(buf.c_str())<=0) + if (varGetValue(buf.c_str()) <= 0) return INVALID_HANDLE_VALUE; - for (i=0;inActions;i++) { - if (item->Action[i].num!=nAction) + for (i = 0; i < item->nActions; i++) { + if (item->Action[i].num != nAction) continue; - if (item->Action[i].wParm!=dwParam) + if (item->Action[i].wParm != dwParam) continue; - if (item->Action[i].when!=NULL) { + if (item->Action[i].when != NULL) { if (!EvaluateExpression(item->Action[i].when)) continue; } // Ora abbiamo trova l'azione giusta che deve essere eseguita. // Duplichiamo l'item corrente e copiamo la azione #i nella #0 - newitem=(LPMPALITEM)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,sizeof(MPALITEM)); - if (newitem==NULL) + newitem=(LPMPALITEM)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MPALITEM)); + if (newitem == NULL) return INVALID_HANDLE_VALUE; // Nella nuova versione scriviamo il numero dell'azione in dwRes @@ -1522,29 +1519,29 @@ static HANDLE DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { /* newitem->Action[0].nCmds=item->Action[i].nCmds; CopyMemory(newitem->Action[0].CmdNum,item->Action[i].CmdNum,newitem->Action[0].nCmds*sizeof(newitem->Action[0].CmdNum[0])); */ - newitem->dwRes=i; + newitem->dwRes = i; // E finalmente possiamo richiamare il thread, che eseguira' l'azione // 0 dell'item, e poi liberera' la memoria con la GlobalFree() /* !!! Nuova gestione dei thread */ - if ((h=CreateThread(NULL,10240,(LPTHREAD_START_ROUTINE)ActionThread,(void *)newitem,0,&dwId))==NULL) + if ((h = CreateThread(NULL, 10240, (LPTHREAD_START_ROUTINE)ActionThread, (void *)newitem, 0, &dwId)) == NULL) return INVALID_HANDLE_VALUE; - if ((h=CreateThread(NULL,10240,(LPTHREAD_START_ROUTINE)ShutUpActionThread,(void *)h,0,&dwId))==NULL) + if ((h = CreateThread(NULL, 10240,(LPTHREAD_START_ROUTINE)ShutUpActionThread, (void *)h, 0, &dwId)) == NULL) return INVALID_HANDLE_VALUE; /* - if ((h=(void*)_beginthread(ActionThread,10240,(void *)newitem))==(void*)-1) + if ((h=(void*)_beginthread(ActionThread, 10240,(void *)newitem))==(void*)-1) return INVALID_HANDLE_VALUE; - if ((h=(void*)_beginthread(ShutUpActionThread,10240,(void *)h))==(void*)-1) + if ((h=(void*)_beginthread(ShutUpActionThread, 10240,(void *)h))==(void*)-1) return INVALID_HANDLE_VALUE; */ - nExecutingAction=item->nObj; - bExecutingAction=true; + nExecutingAction = item->nObj; + bExecutingAction = true; return h; } @@ -1580,10 +1577,10 @@ static HANDLE DoDialog(uint32 nDlgOrd, uint32 nGroup) { HANDLE h; /* Si ricorda nella variabile globale qual e' il dialogo in esecuzione */ - nExecutingDialog=nDlgOrd; + nExecutingDialog = nDlgOrd; /* Attiva la flag per indicare che c'e' un dialogo in esecuzione */ - bExecutingDialog=true; + bExecutingDialog = true; ResetEvent(hAskChoice); ResetEvent(hDoneChoice); @@ -1591,16 +1588,16 @@ static HANDLE DoDialog(uint32 nDlgOrd, uint32 nGroup) { /* Crea un thread in cui esegue un gruppo del dialogo */ // !!! Nuova gestione dei thread - if ((h=CreateThread(NULL,10240,(LPTHREAD_START_ROUTINE)GroupThread,(void *)nGroup,0,&dwId))==NULL) - // if ((h=(void*)_beginthread(GroupThread,10240,(void *)nGroup))==(void*)-1) + if ((h = CreateThread(NULL, 10240, (LPTHREAD_START_ROUTINE)GroupThread, (void *)nGroup, 0, &dwId)) == NULL) + // if ((h=(void*)_beginthread(GroupThread, 10240,(void *)nGroup))==(void*)-1) return INVALID_HANDLE_VALUE; /* Crea un thread che attende la fine del dialogo e rimette a posto le variabili globali */ // !!! Nuova gestione dei thread - if (CreateThread(NULL,10240,(LPTHREAD_START_ROUTINE)ShutUpDialogThread,(void *)h,0,&dwId)==NULL) { - //if ((h=(void*)_beginthread(ShutUpDialogThread,10240,(void *)h))==(void*)-1) - TerminateThread(h,0); + if (CreateThread(NULL, 10240,(LPTHREAD_START_ROUTINE)ShutUpDialogThread,(void *)h, 0, &dwId) == NULL) { + //if ((h=(void*)_beginthread(ShutUpDialogThread, 10240,(void *)h))==(void*)-1) + TerminateThread(h, 0); CloseHandle(h); return INVALID_HANDLE_VALUE; } @@ -1627,14 +1624,14 @@ bool DoSelection(uint32 i, uint32 dwData) { LPMPALDIALOG dialog=lpmdDialogs+nExecutingDialog; int j; - for (j=0;dialog->Choice[i].Select[j].dwData!=0;j++) - if (dialog->Choice[i].Select[j].dwData==dwData && dialog->Choice[i].Select[j].curActive!=0) + for (j = 0; dialog->Choice[i].Select[j].dwData != 0; j++) + if (dialog->Choice[i].Select[j].dwData == dwData && dialog->Choice[i].Select[j].curActive != 0) break; - if (dialog->Choice[i].Select[j].dwData==0) + if (dialog->Choice[i].Select[j].dwData == 0) return false; - nSelectedChoice=j; + nSelectedChoice = j; SetEvent(hDoneChoice); return true; } @@ -1664,7 +1661,7 @@ bool DoSelection(uint32 i, uint32 dwData) { * \****************************************************************************/ -bool mpalInit(const char * lpszMpcFileName, const char * lpszMprFileName, LPLPCUSTOMFUNCTION lplpcfArray) { +bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, LPLPCUSTOMFUNCTION lplpcfArray) { Common::File hMpc; byte buf[5]; uint32 nBytesRead; @@ -1672,9 +1669,9 @@ bool mpalInit(const char * lpszMpcFileName, const char * lpszMprFileName, LPLPCU uint32 dwSizeDecomp, dwSizeComp; byte *cmpbuf; - //printf("Item: %lu\n",sizeof(MPALITEM)); - //printf("Script: %lu\n",sizeof(MPALSCRIPT)); - //printf("Dialog: %lu\n",sizeof(MPALDIALOG)); + //printf("Item: %lu\n", sizeof(MPALITEM)); + //printf("Script: %lu\n", sizeof(MPALSCRIPT)); + //printf("Dialog: %lu\n", sizeof(MPALDIALOG)); /* Si salva l'array delle funzioni custom */ lplpFunctions=lplpcfArray; @@ -1685,13 +1682,13 @@ bool mpalInit(const char * lpszMpcFileName, const char * lpszMprFileName, LPLPCU /* Legge e controlla l'header */ nBytesRead = hMpc.read(buf, 5); - if (nBytesRead !=5) + if (nBytesRead != 5) return false; - if (buf[0]!='M' || buf[1]!='P' || buf[2]!='C' || buf[3]!=0x20) + if (buf[0] != 'M' || buf[1] != 'P' || buf[2] != 'C' || buf[3] != 0x20) return false; - bCompress=buf[4]; + bCompress = buf[4]; /* Legge la dimensione del file decompresso, e alloca la memoria */ dwSizeDecomp = hMpc.readUint32LE(); @@ -1699,7 +1696,7 @@ bool mpalInit(const char * lpszMpcFileName, const char * lpszMprFileName, LPLPCU return false; lpMpcImage = (byte *)GlobalAlloc(GMEM_FIXED,dwSizeDecomp+16); - if (lpMpcImage==NULL) + if (lpMpcImage == NULL) return false; if (bCompress) { @@ -1710,7 +1707,7 @@ bool mpalInit(const char * lpszMpcFileName, const char * lpszMprFileName, LPLPCU return false; cmpbuf = (byte *)GlobalAlloc(GMEM_FIXED,dwSizeComp); - if (cmpbuf==NULL) + if (cmpbuf == NULL) return false; nBytesRead = hMpc.read(cmpbuf, dwSizeComp); @@ -1781,11 +1778,11 @@ bool mpalInit(const char * lpszMpcFileName, const char * lpszMprFileName, LPLPCU hMpr.seek(-(12 + (int)dwSizeComp), SEEK_END); lpResources = (uint32 *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, nResources * 8); - if (lpResources==NULL) + if (lpResources == NULL) return false; cmpbuf = (byte *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, dwSizeComp); - if (cmpbuf==NULL) + if (cmpbuf == NULL) return false; nBytesRead = hMpr.read(cmpbuf, dwSizeComp); @@ -1810,8 +1807,8 @@ bool mpalInit(const char * lpszMpcFileName, const char * lpszMprFileName, LPLPCU /* Crea l'evento che verra' utilizzato per avvertire il gioco che c'e' da effettuare una scelta */ - hAskChoice=CreateEvent(NULL, true, false, NULL); - hDoneChoice=CreateEvent(NULL, true, false, NULL); + hAskChoice = CreateEvent(NULL, true, false, NULL); + hDoneChoice = CreateEvent(NULL, true, false, NULL); return true; } @@ -1840,7 +1837,7 @@ bool mpalInit(const char * lpszMpcFileName, const char * lpszMprFileName, LPLPCU uint32 mpalQuery(uint16 wQueryType, ...) { uint32 dwRet = 0; - int x,y,z; + int x, y, z; char *n; va_list v; Common::String buf; @@ -1861,7 +1858,7 @@ uint32 mpalQuery(uint16 wQueryType, ...) { */ case MPQ_GLOBAL_VAR: LockVar(); - dwRet=(uint32)varGetValue(GETARG(char *)); + dwRet = (uint32)varGetValue(GETARG(char *)); UnlockVar(); break; @@ -1870,7 +1867,7 @@ uint32 mpalQuery(uint16 wQueryType, ...) { */ case MPQ_MESSAGE: LockMsg(); - dwRet=(uint32)DuplicateMessage(msgGetOrderFromNum(GETARG(uint32))); + dwRet = (uint32)DuplicateMessage(msgGetOrderFromNum(GETARG(uint32))); UnlockMsg(); break; @@ -1889,17 +1886,17 @@ uint32 mpalQuery(uint16 wQueryType, ...) { */ case MPQ_LOCATION_SIZE: LockLocations(); - x=locGetOrderFromNum(GETARG(uint32)); - y=GETARG(uint32); - if (x!=-1) { - if (y==MPQ_X) - dwRet=lpmlLocations[x].dwXlen; - else if (y==MPQ_Y) - dwRet=lpmlLocations[x].dwYlen; + x = locGetOrderFromNum(GETARG(uint32)); + y = GETARG(uint32); + if (x != -1) { + if (y == MPQ_X) + dwRet = lpmlLocations[x].dwXlen; + else if (y == MPQ_Y) + dwRet = lpmlLocations[x].dwYlen; else - mpalError=1; + mpalError = 1; } else - mpalError=1; + mpalError = 1; UnlockLocations(); break; @@ -1908,8 +1905,8 @@ uint32 mpalQuery(uint16 wQueryType, ...) { */ case MPQ_LOCATION_IMAGE: LockLocations(); - x=locGetOrderFromNum(GETARG(uint32)); - dwRet=(uint32)resLoad(lpmlLocations[x].dwPicRes); + x = locGetOrderFromNum(GETARG(uint32)); + dwRet = (uint32)resLoad(lpmlLocations[x].dwPicRes); UnlockLocations(); break; @@ -1917,7 +1914,7 @@ uint32 mpalQuery(uint16 wQueryType, ...) { * HGLOBAL mpalQuery(MPQ_RESOURCE, uint32 dwRes); */ case MPQ_RESOURCE: - dwRet=(uint32)resLoad(GETARG(uint32)); + dwRet = (uint32)resLoad(GETARG(uint32)); break; /* @@ -1925,7 +1922,7 @@ uint32 mpalQuery(uint16 wQueryType, ...) { */ case MPQ_ITEM_LIST: LockVar(); - dwRet=(uint32)GetItemList(GETARG(uint32)); + dwRet = (uint32)GetItemList(GETARG(uint32)); LockVar(); break; @@ -1934,7 +1931,7 @@ uint32 mpalQuery(uint16 wQueryType, ...) { */ case MPQ_ITEM_DATA: LockItems(); - dwRet=(uint32)GetItemData(itemGetOrderFromNum(GETARG(uint32))); + dwRet = (uint32)GetItemData(itemGetOrderFromNum(GETARG(uint32))); UnlockItems(); break; @@ -1943,7 +1940,7 @@ uint32 mpalQuery(uint16 wQueryType, ...) { */ case MPQ_ITEM_IS_ACTIVE: LockVar(); - x=GETARG(uint32); + x = GETARG(uint32); buf = Common::String::format("Status.%u", x); if (varGetValue(buf.c_str()) <= 0) dwRet = (uint32)false; @@ -1958,14 +1955,14 @@ uint32 mpalQuery(uint16 wQueryType, ...) { */ case MPQ_ITEM_NAME: LockVar(); - x=GETARG(uint32); + x = GETARG(uint32); n=GETARG(char *); buf = Common::String::format("Status.%u", x); if (varGetValue(buf.c_str()) <= 0) n[0]='\0'; else { LockItems(); - y=itemGetOrderFromNum(x); + y = itemGetOrderFromNum(x); CopyMemory(n, (char *)(lpmiItems+y)->lpszDescribe, MAX_DESCRIBE_SIZE); UnlockItems(); } @@ -1979,8 +1976,8 @@ uint32 mpalQuery(uint16 wQueryType, ...) { */ case MPQ_DIALOG_PERIOD: LockDialogs(); - y=GETARG(uint32); - dwRet=(uint32)DuplicateDialogPeriod(y); + y = GETARG(uint32); + dwRet = (uint32)DuplicateDialogPeriod(y); UnlockDialogs(); break; @@ -1989,13 +1986,13 @@ uint32 mpalQuery(uint16 wQueryType, ...) { * void mpalQuery(MPQ_DIALOG_WAITFORCHOICE); */ case MPQ_DIALOG_WAITFORCHOICE: - WaitForSingleObject(hAskChoice,INFINITE); + WaitForSingleObject(hAskChoice, INFINITE); ResetEvent(hAskChoice); if (bExecutingDialog) - dwRet=(uint32)nExecutingChoice; + dwRet = (uint32)nExecutingChoice; else - dwRet=(uint32)((int)-1); + dwRet = (uint32)((int)-1); break; @@ -2004,7 +2001,7 @@ uint32 mpalQuery(uint16 wQueryType, ...) { */ case MPQ_DIALOG_SELECTLIST: LockDialogs(); - dwRet=(uint32)GetSelectList(GETARG(uint32)); + dwRet = (uint32)GetSelectList(GETARG(uint32)); UnlockDialogs(); break; @@ -2013,9 +2010,9 @@ uint32 mpalQuery(uint16 wQueryType, ...) { */ case MPQ_DIALOG_SELECTION: LockDialogs(); - x=GETARG(uint32); - y=GETARG(uint32); - dwRet=(uint32)DoSelection(x,y); + x = GETARG(uint32); + y = GETARG(uint32); + dwRet = (uint32)DoSelection(x,y); UnlockDialogs(); break; @@ -2027,21 +2024,21 @@ uint32 mpalQuery(uint16 wQueryType, ...) { /* if (bExecutingAction) { - dwRet=(uint32)INVALID_HANDLE_VALUE; + dwRet = (uint32)INVALID_HANDLE_VALUE; break; } */ LockItems(); LockVar(); - x=GETARG(uint32); - z=GETARG(uint32); - y=itemGetOrderFromNum(z); + x = GETARG(uint32); + z = GETARG(uint32); + y = itemGetOrderFromNum(z); if (y!=-1) { - dwRet=(uint32)DoAction(x,y,GETARG(uint32)); + dwRet = (uint32)DoAction(x, y, GETARG(uint32)); } else { - dwRet=(uint32)INVALID_HANDLE_VALUE; - mpalError=1; + dwRet = (uint32)INVALID_HANDLE_VALUE; + mpalError = 1; } UnlockVar(); UnlockItems(); @@ -2056,9 +2053,9 @@ uint32 mpalQuery(uint16 wQueryType, ...) { LockDialogs(); - x=dialogGetOrderFromNum(GETARG(uint32)); - y=GETARG(uint32); - dwRet=(uint32)DoDialog(x,y); + x = dialogGetOrderFromNum(GETARG(uint32)); + y = GETARG(uint32); + dwRet = (uint32)DoDialog(x, y); UnlockDialogs(); break; @@ -2066,7 +2063,7 @@ uint32 mpalQuery(uint16 wQueryType, ...) { * DEFAULT -> ERROR */ default: - mpalError=1; + mpalError = 1; break; } @@ -2110,17 +2107,17 @@ bool EXPORT mpalExecuteScript(int nScript) { uint32 dwId; LockScripts(); - n=scriptGetOrderFromNum(nScript); - s=(LPMPALSCRIPT)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,sizeof(MPALSCRIPT)); - if (s==NULL) + n = scriptGetOrderFromNum(nScript); + s = (LPMPALSCRIPT)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MPALSCRIPT)); + if (s == NULL) return false; CopyMemory(s, lpmsScripts+n, sizeof(MPALSCRIPT)); UnlockScripts(); // !!! Nuova gestione dei thread - if (CreateThread(NULL,10240,(LPTHREAD_START_ROUTINE)ScriptThread,(void *)s,0,&dwId)==NULL) - //if ((void*)_beginthread(ScriptThread,10240,(void *)s)==(void*)-1) + if (CreateThread(NULL, 10240,(LPTHREAD_START_ROUTINE)ScriptThread,(void *)s, 0, &dwId) == NULL) + //if ((void*)_beginthread(ScriptThread, 10240,(void *)s)==(void*)-1) return false; return true; @@ -2139,7 +2136,7 @@ bool EXPORT mpalExecuteScript(int nScript) { \****************************************************************************/ void EXPORT mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCus) { - lpiifCustom=lpiifCus; + lpiifCustom = lpiifCus; } @@ -2163,18 +2160,18 @@ bool EXPORT mpalStartIdlePoll(int nLoc) { uint32 i; uint32 dwId; - for (i=0;iwriteString("\n

\n

\n"); if (strcmp(MsgComments[i].pComment, "###") != 0 && strncmp(MsgComments[i].pComment, "@@@", 3) != 0) { f->writeString(Common::String::format("%s\n", MsgComments[i].pComment)); - f->writeString("

\n

\n\n"); + f->writeString("

\n

\n

\n"); } else - bDontOutput=true; + bDontOutput = true; return; } } @@ -2360,16 +2357,16 @@ warning("Start: %d\n", wNum); void OutputEndMsgComment(uint16 wNum, Common::OutSaveFile *f) { int i; - for (i=0;MsgComments[i].wEnd!=0;i++) + for (i = 0; MsgComments[i].wEnd != 0; i++) if (MsgComments[i].wEnd == wNum) { warning("End: %d\n", wNum); if (strcmp(MsgComments[i].pComment, "###") != 0 && strncmp(MsgComments[i].pComment, "@@@", 3) != 0) { f->writeString("
\n

\n"); } else - bDontOutput=false; + bDontOutput = false; - f->writeString("

\n

\n\n"); + f->writeString("

\n

\n

\n"); return; } } @@ -2378,12 +2375,12 @@ warning("End: %d\n", wNum); int OutputStartOther(uint16 wNum, Common::OutSaveFile *f) { int i; - for (i=0;MsgComments[i].wStart!=0;i++) + for (i = 0; MsgComments[i].wStart != 0; i++) if (MsgComments[i].wStart <= wNum && MsgComments[i].wEnd >= wNum) { if (strncmp(MsgComments[i].pComment, "@@@", 3) == 0) { if (MsgComments[i].wStart == wNum) { - f->writeString(Common::String::format("%s\n", MsgComments[i].pComment+4)); - f->writeString("

\n

\n

\n"); + f->writeString(Common::String::format("%s\n", MsgComments[i].pComment + 4)); + f->writeString("

\n

\n

\n"); } return 1; @@ -2397,7 +2394,7 @@ int OutputStartOther(uint16 wNum, Common::OutSaveFile *f) { void OutputEndOther(uint16 wNum, Common::OutSaveFile *f) { int i; - for (i=0;MsgComments[i].wStart!=0;i++) + for (i = 0; MsgComments[i].wStart != 0; i++) if (MsgComments[i].wEnd == wNum && strncmp(MsgComments[i].pComment, "@@@", 3) == 0) { f->writeString("
\n

\n"); break; @@ -2406,7 +2403,7 @@ void OutputEndOther(uint16 wNum, Common::OutSaveFile *f) { void mpalDumpMessages(void) { - int i,j; + int i, j; char *lpMessage; char *p; char *lpPeriods[30]; @@ -2419,50 +2416,50 @@ void mpalDumpMessages(void) { LockMsg(); - bDontOutput=false; + bDontOutput = false; warning("Dumping MESSAGES.HTM...\n"); f = g_system->getSavefileManager()->openForSaving("Messages.htm"); - f->writeString("\n\n\n"); + f->writeString("\n\n
\n"); - for (i=0;igetSavefileManager()->openForSaving("Others.htm"); LockMsg(); - bDontOutput=false; + bDontOutput = false; warning("Dumping OTHERS.HTM...\n"); f->writeString("\n\n"); - for (i=0;igetSavefileManager()->openForSaving("voicelist.txt"); - sprintf(dfn,"DIALOG%03d.HTM",dlg->nObj); + sprintf(dfn,"DIALOG%03d.HTM", dlg->nObj); warning("Dumping %s...\n", dfn); f = g_system->getSavefileManager()->openForSaving(dfn); f->writeString("\n\n"); - for (g=0;dlg->Group[g].num != 0; g++) { + for (g = 0;dlg->Group[g].num != 0; g++) { bAtLeastOne = false; - for (c=0;cGroup[g].nCmds; c++) { + for (c = 0; cGroup[g].nCmds; c++) { curCmd = &dlg->Command[dlg->Group[g].CmdNum[c]]; if (curCmd->type == 1 && curCmd->nCf == 71) { - bAtLeastOne=true; + bAtLeastOne = true; break; } } @@ -3003,27 +3000,27 @@ void mpalDumpDialog(LPMPALDIALOG dlg) { continue; f->writeString(Common::String::format("

\n

Group %d

\n

\n", g)); - f->writeString("

\n"); + f->writeString("
\n"); - for (c=0;cGroup[g].nCmds; c++) { + for (c = 0;cGroup[g].nCmds; c++) { curCmd = &dlg->Command[dlg->Group[g].CmdNum[c]]; // Se una funzione custom, e richiama la SendDialogMessage(nPers, nMsg) if (curCmd->type == 1 && curCmd->nCf == 71) { sprintf(fname, "%03d-%05d.WAV", dlg->nObj, curCmd->arg2); - for (j=0;dlg->Periods[j]!=NULL;j++) + for (j = 0; dlg->Periods[j] != NULL; j++) if (dlg->PeriodNums[j] == curCmd->arg2) break; - if (dlg->Periods[j]==NULL) + if (dlg->Periods[j] == NULL) warning("ERROR: Dialogo %d, Periodo %d non trovato!\n", (int)dlg->nObj, (int)curCmd->arg2); else { frase = (char *)GlobalLock(dlg->Periods[j]); strcpy(copia, frase); GlobalUnlock(dlg->Periods[j]); - while ((p=strchr(copia,'^')) != NULL) + while ((p = strchr(copia,'^')) != NULL) *p = '\"'; p = frase; @@ -3034,7 +3031,7 @@ void mpalDumpDialog(LPMPALDIALOG dlg) { v1->writeString(Common::String::format("%s\n", fname)); f->writeString("\t\n"); f->writeString(Common::String::format("\t\t\n", fname)); - f->writeString(Common::String::format("\t\t\n", + f->writeString(Common::String::format("\t\t\n", GetPersonName(dlg->nObj, curCmd->arg1))); f->writeString(Common::String::format("\t\t\n",copia)); f->writeString("\t\n"); @@ -3058,7 +3055,7 @@ void mpalDumpDialogs(void) { LockDialogs(); - for (i=0;i CoroHashMap; +static CoroHashMap *s_coroFuncs = 0; + +static void changeCoroStats(const char *func, int change) { + if (!s_coroFuncs) + s_coroFuncs = new CoroHashMap(); + + (*s_coroFuncs)[func] += change; +} + +static void displayCoroStats() { + debug("%d active coros", s_coroCount); + + // Loop over s_coroFuncs and print info about active coros + if (!s_coroFuncs) + return; + for (CoroHashMap::const_iterator it = s_coroFuncs->begin(); + it != s_coroFuncs->end(); ++it) { + if (it->_value != 0) + debug(" %3d x %s", it->_value, it->_key.c_str()); + } +} + +} +#endif + +CoroBaseContext::CoroBaseContext(const char *func) + : _line(0), _sleep(0), _subctx(0) { +#if COROUTINE_DEBUG + _funcName = func; + changeCoroStats(_funcName, +1); + s_coroCount++; +#endif +} + +CoroBaseContext::~CoroBaseContext() { +#if COROUTINE_DEBUG + s_coroCount--; + changeCoroStats(_funcName, -1); + debug("Deleting coro in %s at %p (subctx %p)", + _funcName, (void *)this, (void *)_subctx); + displayCoroStats(); +#endif + delete _subctx; +} + +} // End of namespace Tony diff --git a/engines/tony/coroutine.h b/engines/tony/coroutine.h new file mode 100644 index 0000000000..24742a22f9 --- /dev/null +++ b/engines/tony/coroutine.h @@ -0,0 +1,271 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TONY_COROUTINE_H +#define TONY_COROUTINE_H + +#include "common/scummsys.h" +#include "common/util.h" // for SCUMMVM_CURRENT_FUNCTION + +namespace Tony { + +/** + * @defgroup TonyCoroutines Coroutine support for Tony engine + * + * The following is loosely based on an article by Simon Tatham: + * . + * However, many improvements and tweaks have been made, in particular + * by taking advantage of C++ features not available in C. + */ +//@{ + + +// Enable this macro to enable some debugging support in the coroutine code. +//#define COROUTINE_DEBUG 1 + +/** + * The core of any coroutine context which captures the 'state' of a coroutine. + * Private use only. + */ +struct CoroBaseContext { + int _line; + int _sleep; + CoroBaseContext *_subctx; +#if COROUTINE_DEBUG + const char *_funcName; +#endif + CoroBaseContext(const char *func); + ~CoroBaseContext(); +}; + +typedef CoroBaseContext *CoroContext; + + +// FIXME: Document this! +extern CoroContext nullContext; + +/** + * Wrapper class which holds a pointer to a pointer to a CoroBaseContext. + * The interesting part is the destructor, which kills the context being held, + * but ONLY if the _sleep val of that context is zero. This way, a coroutine + * can just 'return' w/o having to worry about freeing the allocated context + * (in Simon Tatham's original code, one had to use a special macro to + * return from a coroutine). + */ +class CoroContextHolder { + CoroContext &_ctx; +public: + CoroContextHolder(CoroContext &ctx) : _ctx(ctx) { + assert(ctx); + assert(ctx->_sleep >= 0); + ctx->_sleep = 0; + } + ~CoroContextHolder() { + if (_ctx && _ctx->_sleep == 0) { + delete _ctx; + _ctx = 0; + } + } +}; + + +#define CORO_PARAM CoroContext &coroParam + + +/** + * Begin the declaration of a coroutine context. + * This allows declaring variables which are 'persistent' during the + * lifetime of the coroutine. An example use would be: + * + * CORO_BEGIN_CONTEXT; + * int var; + * char *foo; + * CORO_END_CONTEXT(_ctx); + * + * It is not possible to initialize variables here, due to the way this + * macro is implemented. Furthermore, to use the variables declared in + * the coroutine context, you have to access them via the context variable + * name that was specified as parameter to CORO_END_CONTEXT, e.g. + * _ctx->var = 0; + * + * @see CORO_END_CONTEXT + * + * @note We declare a variable 'DUMMY' to allow the user to specify an 'empty' + * context, and so compilers won't complain about ";" following the macro. + */ +#define CORO_BEGIN_CONTEXT \ + struct CoroContextTag : CoroBaseContext { \ + CoroContextTag() : CoroBaseContext(SCUMMVM_CURRENT_FUNCTION) {} \ + int DUMMY + +/** + * End the declaration of a coroutine context. + * @param x name of the coroutine context + * @see CORO_BEGIN_CONTEXT + */ +#define CORO_END_CONTEXT(x) } *x = (CoroContextTag *)coroParam + +/** + * Begin the code section of a coroutine. + * @param x name of the coroutine context + * @see CORO_BEGIN_CODE + */ +#define CORO_BEGIN_CODE(x) \ + if (&coroParam == &nullContext) assert(!nullContext);\ + if (!x) {coroParam = x = new CoroContextTag();}\ + CoroContextHolder tmpHolder(coroParam);\ + switch (coroParam->_line) { case 0:; + +/** + * End the code section of a coroutine. + * @see CORO_END_CODE + */ +#define CORO_END_CODE \ + if (&coroParam == &nullContext) { \ + delete nullContext; \ + nullContext = NULL; \ + } \ + } + +/** + * Sleep for the specified number of scheduler cycles. + */ +#define CORO_SLEEP(delay) do {\ + coroParam->_line = __LINE__;\ + coroParam->_sleep = delay;\ + assert(&coroParam != &nullContext);\ + return; case __LINE__:;\ + } while (0) + +#define CORO_GIVE_WAY do { g_scheduler->giveWay(); CORO_SLEEP(1); } while (0) +#define CORO_RESCHEDULE do { g_scheduler->reschedule(); CORO_SLEEP(1); } while (0) + +/** + * Stop the currently running coroutine and all calling coroutines. + * + * This sets _sleep to -1 rather than 0 so that the context doesn't get + * deleted by CoroContextHolder, since we want CORO_INVOKE_ARGS to + * propogate the _sleep value and return immediately (the scheduler will + * then delete the entire coroutine's state, including all subcontexts). + */ +#define CORO_KILL_SELF() \ + do { if (&coroParam != &nullContext) { coroParam->_sleep = -1; } return; } while (0) + + +/** + * This macro is to be used in conjunction with CORO_INVOKE_ARGS and + * similar macros for calling coroutines-enabled subroutines. + */ +#define CORO_SUBCTX coroParam->_subctx + +/** + * Invoke another coroutine. + * + * If the subcontext still exists after the coroutine is invoked, it has + * either yielded/slept or killed itself, and so we copy the _sleep value + * to our own context and return (execution will continue at the case + * statement below, where we loop and call the coroutine again). + * If the subcontext is null, the coroutine ended normally, and we can + * simply break out of the loop and continue execution. + * + * @param subCoro name of the coroutine-enabled function to invoke + * @param ARGS list of arguments to pass to subCoro + * + * @note ARGS must be surrounded by parentheses, and the first argument + * in this list must always be CORO_SUBCTX. For example, the + * regular function call + * myFunc(a, b); + * becomes the following: + * CORO_INVOKE_ARGS(myFunc, (CORO_SUBCTX, a, b)); + */ +#define CORO_INVOKE_ARGS(subCoro, ARGS) \ + do {\ + coroParam->_line = __LINE__;\ + coroParam->_subctx = 0;\ + do {\ + subCoro ARGS;\ + if (!coroParam->_subctx) break;\ + coroParam->_sleep = coroParam->_subctx->_sleep;\ + assert(&coroParam != &nullContext);\ + return; case __LINE__:;\ + } while (1);\ + } while (0) + +/** + * Invoke another coroutine. Similar to CORO_INVOKE_ARGS, + * but allows specifying a return value which is returned + * if invoked coroutine yields (thus causing the current + * coroutine to yield, too). + */ +#define CORO_INVOKE_ARGS_V(subCoro, RESULT, ARGS) \ + do {\ + coroParam->_line = __LINE__;\ + coroParam->_subctx = 0;\ + do {\ + subCoro ARGS;\ + if (!coroParam->_subctx) break;\ + coroParam->_sleep = coroParam->_subctx->_sleep;\ + assert(&coroParam != &nullContext);\ + return RESULT; case __LINE__:;\ + } while (1);\ + } while (0) + +/** + * Convenience wrapper for CORO_INVOKE_ARGS for invoking a coroutine + * with no parameters. + */ +#define CORO_INVOKE_0(subCoroutine) \ + CORO_INVOKE_ARGS(subCoroutine,(CORO_SUBCTX)) + +/** + * Convenience wrapper for CORO_INVOKE_ARGS for invoking a coroutine + * with one parameter. + */ +#define CORO_INVOKE_1(subCoroutine, a0) \ + CORO_INVOKE_ARGS(subCoroutine,(CORO_SUBCTX,a0)) + +/** + * Convenience wrapper for CORO_INVOKE_ARGS for invoking a coroutine + * with two parameters. + */ +#define CORO_INVOKE_2(subCoroutine, a0,a1) \ + CORO_INVOKE_ARGS(subCoroutine,(CORO_SUBCTX,a0,a1)) + +/** + * Convenience wrapper for CORO_INVOKE_ARGS for invoking a coroutine + * with three parameters. + */ +#define CORO_INVOKE_3(subCoroutine, a0,a1,a2) \ + CORO_INVOKE_ARGS(subCoroutine,(CORO_SUBCTX,a0,a1,a2)) + +/** + * Convenience wrapper for CORO_INVOKE_ARGS for invoking a coroutine + * with four parameters. + */ +#define CORO_INVOKE_4(subCoroutine, a0,a1,a2,a3) \ + CORO_INVOKE_ARGS(subCoroutine,(CORO_SUBCTX,a0,a1,a2,a3)) + +//@} + +} // End of namespace Tony + +#endif // TONY_COROUTINE_H diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 3400235563..1d28fa9ece 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -297,38 +297,38 @@ void CharsLoadAll(Common::InSaveFile *f) { } } -DECLARE_CUSTOM_FUNCTION(FaceToMe)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(FaceToMe)(CORO_PARAM, uint32, uint32, uint32, uint32) { Tony->SetPattern(Tony->PAT_STANDDOWN); } -DECLARE_CUSTOM_FUNCTION(BackToMe)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(BackToMe)(CORO_PARAM, uint32, uint32, uint32, uint32) { Tony->SetPattern(Tony->PAT_STANDUP); } -DECLARE_CUSTOM_FUNCTION(LeftToMe)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(LeftToMe)(CORO_PARAM, uint32, uint32, uint32, uint32) { Tony->SetPattern(Tony->PAT_STANDLEFT); } -DECLARE_CUSTOM_FUNCTION(RightToMe)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(RightToMe)(CORO_PARAM, uint32, uint32, uint32, uint32) { Tony->SetPattern(Tony->PAT_STANDRIGHT); } -DECLARE_CUSTOM_FUNCTION(TonySetPalesati)(uint32 bStatus, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonySetPalesati)(CORO_PARAM, uint32 bStatus, uint32, uint32, uint32) { SetPalesati(bStatus); } -DECLARE_CUSTOM_FUNCTION(MySleep)(uint32 dwTime, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(MySleep)(CORO_PARAM, uint32 dwTime, uint32, uint32, uint32) { if (bSkipIdle) return; Sleep(dwTime); } -DECLARE_CUSTOM_FUNCTION(SetAlwaysDisplay)(uint32 val, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(SetAlwaysDisplay)(CORO_PARAM, uint32 val, uint32, uint32, uint32) { bAlwaysDisplay = (val != 0); } -DECLARE_CUSTOM_FUNCTION(SetPointer)(uint32 dwPointer, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(SetPointer)(CORO_PARAM, uint32 dwPointer, uint32, uint32, uint32) { switch (dwPointer) { case 1: Pointer->SetSpecialPointer(Pointer->PTR_FRECCIASU); @@ -369,7 +369,7 @@ VoiceHeader *SearchVoiceHeader(uint32 codehi, uint32 codelo) { } -DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(uint32 dwMessage, uint32 nX, uint32 nY, uint32) { +DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX, uint32 nY, uint32) { RMMessage msg(dwMessage); int i; int curOffset = 0; @@ -476,12 +476,12 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(uint32 dwMessage, uint32 nX, uint32 nY, Tony->EndTalk(); } -DECLARE_CUSTOM_FUNCTION(ChangeBoxStatus)(uint32 nLoc, uint32 nBox, uint32 nStatus, uint32) { +DECLARE_CUSTOM_FUNCTION(ChangeBoxStatus)(CORO_PARAM, uint32 nLoc, uint32 nBox, uint32 nStatus, uint32) { Boxes->ChangeBoxStatus(nLoc,nBox,nStatus); } -DECLARE_CUSTOM_FUNCTION(CustLoadLocation)(uint32 nLoc, uint32 tX, uint32 tY, uint32 bUseStartPos) { +DECLARE_CUSTOM_FUNCTION(CustLoadLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint32 tY, uint32 bUseStartPos) { HANDLE h; Freeze(); @@ -504,7 +504,7 @@ DECLARE_CUSTOM_FUNCTION(CustLoadLocation)(uint32 nLoc, uint32 tX, uint32 tY, uin RMPoint SFM_pt; int SFM_nLoc; -DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgStart)(uint32 nMsg, uint32 nFont, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgStart)(CORO_PARAM, uint32 nMsg, uint32 nFont, uint32, uint32) { RMMessage msg(nMsg); RMGfxClearTask clear; int i; @@ -554,14 +554,14 @@ DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgStart)(uint32 nMsg, uint32 nFont, uint3 } } -DECLARE_CUSTOM_FUNCTION(ClearScreen)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(ClearScreen)(CORO_PARAM, uint32, uint32, uint32, uint32) { RMGfxClearTask clear; LinkGraphicTask(&clear); WaitFrame(); } -DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgEnd)(uint32 bNotEnableTony, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgEnd)(CORO_PARAM, uint32 bNotEnableTony, uint32, uint32, uint32) { Freeze(); LoadLocation(SFM_nLoc,RMPoint(SFM_pt.x,SFM_pt.y),RMPoint(-1,-1)); if (!bNotEnableTony) @@ -573,18 +573,25 @@ DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgEnd)(uint32 bNotEnableTony, uint32, uin } -DECLARE_CUSTOM_FUNCTION(SendFullscreenMessage)(uint32 nMsg, uint32 nFont, uint32, uint32) { - SendFullscreenMsgStart(nMsg,nFont,0,0); - SendFullscreenMsgEnd(0, 0, 0, 0); +DECLARE_CUSTOM_FUNCTION(SendFullscreenMessage)(CORO_PARAM, uint32 nMsg, uint32 nFont, uint32, uint32) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + CORO_INVOKE_4(SendFullscreenMsgStart, nMsg, nFont, 0, 0); + CORO_INVOKE_4(SendFullscreenMsgEnd, 0, 0, 0, 0); + + CORO_END_CODE; } bool bNoOcchioDiBue = false; -DECLARE_CUSTOM_FUNCTION(NoOcchioDiBue)(uint32, uint32, uint32, uint32) { - bNoOcchioDiBue = true; +DECLARE_CUSTOM_FUNCTION(NoOcchioDiBue)(CORO_PARAM, uint32, uint32, uint32, uint32) { + bNoOcchioDiBue = true; } -DECLARE_CUSTOM_FUNCTION(CloseLocation)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(CloseLocation)(CORO_PARAM, uint32, uint32, uint32, uint32) { if (!bNoOcchioDiBue) { InitWipe(1); WaitWipeEnd(); @@ -598,7 +605,7 @@ DECLARE_CUSTOM_FUNCTION(CloseLocation)(uint32, uint32, uint32, uint32) { } -DECLARE_CUSTOM_FUNCTION(ChangeLocation)(uint32 nLoc, uint32 tX, uint32 tY, uint32 bUseStartPos) { +DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint32 tY, uint32 bUseStartPos) { HANDLE h; if (!bNoOcchioDiBue) { @@ -647,40 +654,48 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(uint32 nLoc, uint32 tX, uint32 tY, uint3 } -DECLARE_CUSTOM_FUNCTION(SetLocStartPosition)(uint32 nLoc, uint32 lX, uint32 lY, uint32) { +DECLARE_CUSTOM_FUNCTION(SetLocStartPosition)(CORO_PARAM, uint32 nLoc, uint32 lX, uint32 lY, uint32) { StartLocPos[nLoc].Set(lX,lY); } -DECLARE_CUSTOM_FUNCTION(SaveTonyPosition)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(SaveTonyPosition)(CORO_PARAM, uint32, uint32, uint32, uint32) { saveTonyPos = Tony->Position(); saveTonyLoc = Loc->TEMPGetNumLoc(); } -DECLARE_CUSTOM_FUNCTION(RestoreTonyPosition)(uint32, uint32, uint32, uint32) { - ChangeLocation(saveTonyLoc, saveTonyPos.x, saveTonyPos.y, 0); +DECLARE_CUSTOM_FUNCTION(RestoreTonyPosition)(CORO_PARAM, uint32, uint32, uint32, uint32) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + CORO_INVOKE_4(ChangeLocation, saveTonyLoc, saveTonyPos.x, saveTonyPos.y, 0); + MCharResetCodes(); + + CORO_END_CODE; } -DECLARE_CUSTOM_FUNCTION(DisableInput)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(DisableInput)(CORO_PARAM, uint32, uint32, uint32, uint32) { MainDisableInput(); } -DECLARE_CUSTOM_FUNCTION(EnableInput)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(EnableInput)(CORO_PARAM, uint32, uint32, uint32, uint32) { MainEnableInput(); } -DECLARE_CUSTOM_FUNCTION(StopTony)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(StopTony)(CORO_PARAM, uint32, uint32, uint32, uint32) { Tony->StopNoAction(); } -DECLARE_CUSTOM_FUNCTION(CustEnableGUI)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(CustEnableGUI)(CORO_PARAM, uint32, uint32, uint32, uint32) { EnableGUI(); } -DECLARE_CUSTOM_FUNCTION(CustDisableGUI)(uint32, uint32, uint32, uint32) +DECLARE_CUSTOM_FUNCTION(CustDisableGUI)(CORO_PARAM, uint32, uint32, uint32, uint32) { DisableGUI(); } @@ -731,31 +746,31 @@ void TonyGenericPut2(uint32 nDirection) { } -DECLARE_CUSTOM_FUNCTION(TonyTakeUp1)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyTakeUp1)(CORO_PARAM, uint32, uint32, uint32, uint32) { TonyGenericTake1(0); } -DECLARE_CUSTOM_FUNCTION(TonyTakeMid1)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyTakeMid1)(CORO_PARAM, uint32, uint32, uint32, uint32) { TonyGenericTake1(1); } -DECLARE_CUSTOM_FUNCTION(TonyTakeDown1)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyTakeDown1)(CORO_PARAM, uint32, uint32, uint32, uint32) { TonyGenericTake1(2); } -DECLARE_CUSTOM_FUNCTION(TonyTakeUp2)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyTakeUp2)(CORO_PARAM, uint32, uint32, uint32, uint32) { TonyGenericTake2(0); } -DECLARE_CUSTOM_FUNCTION(TonyTakeMid2)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyTakeMid2)(CORO_PARAM, uint32, uint32, uint32, uint32) { TonyGenericTake2(1); } -DECLARE_CUSTOM_FUNCTION(TonyTakeDown2)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyTakeDown2)(CORO_PARAM, uint32, uint32, uint32, uint32) { TonyGenericTake2(2); } @@ -765,42 +780,42 @@ DECLARE_CUSTOM_FUNCTION(TonyTakeDown2)(uint32, uint32, uint32, uint32) { -DECLARE_CUSTOM_FUNCTION(TonyPutUp1)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyPutUp1)(CORO_PARAM, uint32, uint32, uint32, uint32) { TonyGenericPut1(0); } -DECLARE_CUSTOM_FUNCTION(TonyPutMid1)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyPutMid1)(CORO_PARAM, uint32, uint32, uint32, uint32) { TonyGenericPut1(1); } -DECLARE_CUSTOM_FUNCTION(TonyPutDown1)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyPutDown1)(CORO_PARAM, uint32, uint32, uint32, uint32) { TonyGenericPut1(2); } -DECLARE_CUSTOM_FUNCTION(TonyPutUp2)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyPutUp2)(CORO_PARAM, uint32, uint32, uint32, uint32) { TonyGenericPut2(0); } -DECLARE_CUSTOM_FUNCTION(TonyPutMid2)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyPutMid2)(CORO_PARAM, uint32, uint32, uint32, uint32) { TonyGenericPut2(1); } -DECLARE_CUSTOM_FUNCTION(TonyPutDown2)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyPutDown2)(CORO_PARAM, uint32, uint32, uint32, uint32) { TonyGenericPut2(2); } -DECLARE_CUSTOM_FUNCTION(TonyPerTerra)(uint32 dwParte, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyPerTerra)(CORO_PARAM, uint32 dwParte, uint32, uint32, uint32) { if (dwParte== 0) Tony->SetPattern(Tony->PAT_PERTERRALEFT); else Tony->SetPattern(Tony->PAT_PERTERRARIGHT); } -DECLARE_CUSTOM_FUNCTION(TonySiRialza)(uint32 dwParte, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonySiRialza)(CORO_PARAM, uint32 dwParte, uint32, uint32, uint32) { if (dwParte== 0) Tony->SetPattern(Tony->PAT_SIRIALZALEFT); else @@ -810,11 +825,11 @@ DECLARE_CUSTOM_FUNCTION(TonySiRialza)(uint32 dwParte, uint32, uint32, uint32) { Tony->WaitForEndPattern(); } -DECLARE_CUSTOM_FUNCTION(TonyPastorella)(uint32 bIsPast, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyPastorella)(CORO_PARAM, uint32 bIsPast, uint32, uint32, uint32) { Tony->SetPastorella(bIsPast); } -DECLARE_CUSTOM_FUNCTION(TonyFischietto)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyFischietto)(CORO_PARAM, uint32, uint32, uint32, uint32) { Tony->SetPattern(Tony->PAT_FISCHIETTORIGHT); if (!bSkipIdle) Tony->WaitForEndPattern(); @@ -827,182 +842,182 @@ void TonySetNumTexts(uint32 dwText) { bTonyInTexts = false; } -DECLARE_CUSTOM_FUNCTION(TonyRide)(uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyRide)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); nTonyNextTalkType = Tony->TALK_RIDE; } -DECLARE_CUSTOM_FUNCTION(TonyRidacchia)(uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyRidacchia)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); nTonyNextTalkType = Tony->TALK_RIDE2; } -DECLARE_CUSTOM_FUNCTION(TonyFianchi)(uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyFianchi)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); nTonyNextTalkType = Tony->TALK_FIANCHI; } -DECLARE_CUSTOM_FUNCTION(TonyCanta)(uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyCanta)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); nTonyNextTalkType = Tony->TALK_CANTA; } -DECLARE_CUSTOM_FUNCTION(TonySiIndica)(uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonySiIndica)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); nTonyNextTalkType = Tony->TALK_SIINDICA; } -DECLARE_CUSTOM_FUNCTION(TonySpaventatoConMani)(uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonySpaventatoConMani)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); nTonyNextTalkType = Tony->TALK_SPAVENTATO; } -DECLARE_CUSTOM_FUNCTION(TonySpaventatoSenzaMani)(uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonySpaventatoSenzaMani)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); nTonyNextTalkType = Tony->TALK_SPAVENTATO2; } -DECLARE_CUSTOM_FUNCTION(TonyConMartello)(uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyConMartello)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); nTonyNextTalkType = Tony->TALK_CONMARTELLO; Tony->SetPattern(Tony->PAT_CONMARTELLO); } -DECLARE_CUSTOM_FUNCTION(TonyConBicchiere)(uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyConBicchiere)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); nTonyNextTalkType = Tony->TALK_CONBICCHIERE; Tony->SetPattern(Tony->PAT_CONBICCHIERE); } -DECLARE_CUSTOM_FUNCTION(TonyConVerme)(uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyConVerme)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); nTonyNextTalkType = Tony->TALK_CONVERME; Tony->SetPattern(Tony->PAT_CONVERME); } -DECLARE_CUSTOM_FUNCTION(TonyConCorda)(uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyConCorda)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); nTonyNextTalkType = Tony->TALK_CONCORDA; Tony->SetPattern(Tony->PAT_CONCORDA); } -DECLARE_CUSTOM_FUNCTION(TonyConSegretaria)(uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyConSegretaria)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); nTonyNextTalkType = Tony->TALK_CONSEGRETARIA; Tony->SetPattern(Tony->PAT_CONSEGRETARIA); } -DECLARE_CUSTOM_FUNCTION(TonyConConiglioANIM)(uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyConConiglioANIM)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); nTonyNextTalkType = Tony->TALK_CONCONIGLIO; } -DECLARE_CUSTOM_FUNCTION(TonyConRicettaANIM)(uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyConRicettaANIM)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); nTonyNextTalkType = Tony->TALK_CONRICETTA; } -DECLARE_CUSTOM_FUNCTION(TonyConCarteANIM)(uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyConCarteANIM)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); nTonyNextTalkType = Tony->TALK_CONCARTE; } -DECLARE_CUSTOM_FUNCTION(TonyConPupazzoANIM)(uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyConPupazzoANIM)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); nTonyNextTalkType = Tony->TALK_CONPUPAZZO; } -DECLARE_CUSTOM_FUNCTION(TonyConPupazzoStart)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyConPupazzoStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { nTonyNextTalkType = Tony->TALK_CONPUPAZZOSTATIC; bStaticTalk = true; Tony->StartStatic(Tony->TALK_CONPUPAZZOSTATIC); } -DECLARE_CUSTOM_FUNCTION(TonyConPupazzoEnd)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyConPupazzoEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { Tony->EndStatic(Tony->TALK_CONPUPAZZOSTATIC); bStaticTalk = false; nTonyNextTalkType = Tony->TALK_NORMAL; } -DECLARE_CUSTOM_FUNCTION(TonyConConiglioStart)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyConConiglioStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { nTonyNextTalkType = Tony->TALK_CONCONIGLIOSTATIC; bStaticTalk = true; Tony->StartStatic(Tony->TALK_CONCONIGLIOSTATIC); } -DECLARE_CUSTOM_FUNCTION(TonyConConiglioEnd)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyConConiglioEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { Tony->EndStatic(Tony->TALK_CONCONIGLIOSTATIC); bStaticTalk = false; nTonyNextTalkType = Tony->TALK_NORMAL; } -DECLARE_CUSTOM_FUNCTION(TonyConRicettaStart)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyConRicettaStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { nTonyNextTalkType = Tony->TALK_CONRICETTASTATIC; bStaticTalk = true; Tony->StartStatic(Tony->TALK_CONRICETTASTATIC); } -DECLARE_CUSTOM_FUNCTION(TonyConRicettaEnd)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyConRicettaEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { Tony->EndStatic(Tony->TALK_CONRICETTASTATIC); bStaticTalk = false; nTonyNextTalkType = Tony->TALK_NORMAL; } -DECLARE_CUSTOM_FUNCTION(TonyConCarteStart)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyConCarteStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { nTonyNextTalkType = Tony->TALK_CONCARTESTATIC; bStaticTalk = true; Tony->StartStatic(Tony->TALK_CONCARTESTATIC); } -DECLARE_CUSTOM_FUNCTION(TonyConCarteEnd)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyConCarteEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { Tony->EndStatic(Tony->TALK_CONCARTESTATIC); bStaticTalk = false; nTonyNextTalkType = Tony->TALK_NORMAL; } -DECLARE_CUSTOM_FUNCTION(TonyConTaccuinoStart)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyConTaccuinoStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { nTonyNextTalkType = Tony->TALK_CONTACCUINOSTATIC; bStaticTalk = true; Tony->StartStatic(Tony->TALK_CONTACCUINOSTATIC); } -DECLARE_CUSTOM_FUNCTION(TonyConTaccuinoEnd)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyConTaccuinoEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { Tony->EndStatic(Tony->TALK_CONTACCUINOSTATIC); bStaticTalk = false; nTonyNextTalkType = Tony->TALK_NORMAL; } -DECLARE_CUSTOM_FUNCTION(TonyConMegafonoStart)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyConMegafonoStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { nTonyNextTalkType = Tony->TALK_CONMEGAFONOSTATIC; bStaticTalk = true; Tony->StartStatic(Tony->TALK_CONMEGAFONOSTATIC); } -DECLARE_CUSTOM_FUNCTION(TonyConMegafonoEnd)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyConMegafonoEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { Tony->EndStatic(Tony->TALK_CONMEGAFONOSTATIC); bStaticTalk = false; nTonyNextTalkType = Tony->TALK_NORMAL; } -DECLARE_CUSTOM_FUNCTION(TonyConBarbaStart)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyConBarbaStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { nTonyNextTalkType = Tony->TALK_CONBARBASTATIC; bStaticTalk = true; Tony->StartStatic(Tony->TALK_CONBARBASTATIC); } -DECLARE_CUSTOM_FUNCTION(TonyConBarbaEnd)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyConBarbaEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { Tony->EndStatic(Tony->TALK_CONBARBASTATIC); bStaticTalk = false; nTonyNextTalkType = Tony->TALK_NORMAL; } -DECLARE_CUSTOM_FUNCTION(TonySpaventatoStart)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonySpaventatoStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { nTonyNextTalkType = Tony->TALK_SPAVENTATOSTATIC; bStaticTalk = true; Tony->StartStatic(Tony->TALK_SPAVENTATOSTATIC); } -DECLARE_CUSTOM_FUNCTION(TonySpaventatoEnd)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonySpaventatoEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { Tony->EndStatic(Tony->TALK_SPAVENTATOSTATIC); bStaticTalk = false; nTonyNextTalkType = Tony->TALK_NORMAL; @@ -1010,29 +1025,43 @@ DECLARE_CUSTOM_FUNCTION(TonySpaventatoEnd)(uint32, uint32, uint32, uint32) { -DECLARE_CUSTOM_FUNCTION(TonySchifato)(uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonySchifato)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); nTonyNextTalkType = Tony->TALK_SCHIFATO; } -DECLARE_CUSTOM_FUNCTION(TonySniffaLeft)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonySniffaLeft)(CORO_PARAM, uint32, uint32, uint32, uint32) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + Tony->SetPattern(Tony->PAT_SNIFFA_LEFT); Tony->WaitForEndPattern(); - LeftToMe(0, 0, 0, 0); + CORO_INVOKE_4(LeftToMe, 0, 0, 0, 0); + + CORO_END_CODE; } -DECLARE_CUSTOM_FUNCTION(TonySniffaRight)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonySniffaRight)(CORO_PARAM, uint32, uint32, uint32, uint32) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + Tony->SetPattern(Tony->PAT_SNIFFA_RIGHT); Tony->WaitForEndPattern(); - RightToMe(0, 0, 0, 0); + CORO_INVOKE_4(RightToMe, 0, 0, 0, 0); + + CORO_END_CODE; } -DECLARE_CUSTOM_FUNCTION(TonyNaah)(uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyNaah)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); nTonyNextTalkType = Tony->TALK_NAAH; } -DECLARE_CUSTOM_FUNCTION(TonyMacbeth)(uint32 nPos, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyMacbeth)(CORO_PARAM, uint32 nPos, uint32, uint32, uint32) { switch (nPos) { case 1: nTonyNextTalkType = Tony->TALK_MACBETH1; @@ -1065,15 +1094,15 @@ DECLARE_CUSTOM_FUNCTION(TonyMacbeth)(uint32 nPos, uint32, uint32, uint32) { } -DECLARE_CUSTOM_FUNCTION(EnableTony)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(EnableTony)(CORO_PARAM, uint32, uint32, uint32, uint32) { Tony->Show(); } -DECLARE_CUSTOM_FUNCTION(DisableTony)(uint32 bShowOmbra, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(DisableTony)(CORO_PARAM, uint32 bShowOmbra, uint32, uint32, uint32) { Tony->Hide(bShowOmbra); } -DECLARE_CUSTOM_FUNCTION(WaitForPatternEnd)(uint32 nItem, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(WaitForPatternEnd)(CORO_PARAM, uint32 nItem, uint32, uint32, uint32) { RMItem *item = Loc->GetItemFromCode(nItem); if (!bSkipIdle && item != NULL) @@ -1081,22 +1110,22 @@ DECLARE_CUSTOM_FUNCTION(WaitForPatternEnd)(uint32 nItem, uint32, uint32, uint32) } -DECLARE_CUSTOM_FUNCTION(SetTonyPosition)(uint32 nX, uint32 nY, uint32 nLoc, uint32) { +DECLARE_CUSTOM_FUNCTION(SetTonyPosition)(CORO_PARAM, uint32 nX, uint32 nY, uint32 nLoc, uint32) { Tony->SetPosition(RMPoint(nX, nY), nLoc); } -DECLARE_CUSTOM_FUNCTION(MoveTonyAndWait)(uint32 nX, uint32 nY, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(MoveTonyAndWait)(CORO_PARAM, uint32 nX, uint32 nY, uint32, uint32) { Tony->Move(RMPoint(nX, nY)); if (!bSkipIdle) Tony->WaitForEndMovement(); } -DECLARE_CUSTOM_FUNCTION(MoveTony)(uint32 nX, uint32 nY, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(MoveTony)(CORO_PARAM, uint32 nX, uint32 nY, uint32, uint32) { Tony->Move(RMPoint(nX, nY)); } -DECLARE_CUSTOM_FUNCTION(ScrollLocation)(uint32 nX, uint32 nY, uint32 sX, uint32 sY) { +DECLARE_CUSTOM_FUNCTION(ScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, uint32 sX, uint32 sY) { int lx, ly; RMPoint pt; @@ -1133,7 +1162,7 @@ DECLARE_CUSTOM_FUNCTION(ScrollLocation)(uint32 nX, uint32 nY, uint32 sX, uint32 } } -DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(uint32 nX, uint32 nY, uint32 sX, uint32 sY) { +DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, uint32 sX, uint32 sY) { int lx, ly; RMPoint pt, startpt; uint32 dwStartTime, dwCurTime, dwTotalTime; @@ -1231,7 +1260,7 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(uint32 nX, uint32 nY, uint32 sX, uin } -DECLARE_CUSTOM_FUNCTION(ChangeHotspot)(uint32 dwCode, uint32 nX, uint32 nY, uint32) { +DECLARE_CUSTOM_FUNCTION(ChangeHotspot)(CORO_PARAM, uint32 dwCode, uint32 nX, uint32 nY, uint32) { int i; for (i = 0; i < curChangedHotspot; i++) @@ -1252,15 +1281,15 @@ DECLARE_CUSTOM_FUNCTION(ChangeHotspot)(uint32 dwCode, uint32 nX, uint32 nY, uint } -DECLARE_CUSTOM_FUNCTION(AutoSave)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(AutoSave)(CORO_PARAM, uint32, uint32, uint32, uint32) { _vm->AutoSave(); } -DECLARE_CUSTOM_FUNCTION(Abort)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(Abort)(CORO_PARAM, uint32, uint32, uint32, uint32) { _vm->Abort(); } -DECLARE_CUSTOM_FUNCTION(TremaSchermo)(uint32 nScosse, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TremaSchermo)(CORO_PARAM, uint32 nScosse, uint32, uint32, uint32) { uint32 i; uint32 curTime = _vm->GetTime(); int dirx,diry; @@ -1296,7 +1325,7 @@ DECLARE_CUSTOM_FUNCTION(TremaSchermo)(uint32 nScosse, uint32, uint32, uint32) { * Personaggi */ -DECLARE_CUSTOM_FUNCTION(CharSetCode)(uint32 nChar, uint32 nCode, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(CharSetCode)(CORO_PARAM, uint32 nChar, uint32 nCode, uint32, uint32) { assert(nChar < 16); Character[nChar].code = nCode; Character[nChar].item = Loc->GetItemFromCode(nCode); @@ -1311,26 +1340,26 @@ DECLARE_CUSTOM_FUNCTION(CharSetCode)(uint32 nChar, uint32 nCode, uint32, uint32) IsMChar[nChar] = false; } -DECLARE_CUSTOM_FUNCTION(CharSetColor)(uint32 nChar, uint32 r, uint32 g, uint32 b) { +DECLARE_CUSTOM_FUNCTION(CharSetColor)(CORO_PARAM, uint32 nChar, uint32 r, uint32 g, uint32 b) { assert(nChar<16); Character[nChar].r = r; Character[nChar].g = g; Character[nChar].b = b; } -DECLARE_CUSTOM_FUNCTION(CharSetTalkPattern)(uint32 nChar, uint32 tp, uint32 sp, uint32) { +DECLARE_CUSTOM_FUNCTION(CharSetTalkPattern)(CORO_PARAM, uint32 nChar, uint32 tp, uint32 sp, uint32) { assert(nChar<16); Character[nChar].talkpattern = tp; Character[nChar].standpattern = sp; } -DECLARE_CUSTOM_FUNCTION(CharSetStartEndTalkPattern)(uint32 nChar, uint32 sp, uint32 ep, uint32) { +DECLARE_CUSTOM_FUNCTION(CharSetStartEndTalkPattern)(CORO_PARAM, uint32 nChar, uint32 sp, uint32 ep, uint32) { assert(nChar<16); Character[nChar].starttalkpattern=sp; Character[nChar].endtalkpattern=ep; } -DECLARE_CUSTOM_FUNCTION(CharSendMessage)(uint32 nChar, uint32 dwMessage, uint32 bIsBack, uint32) { +DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMessage, uint32 bIsBack, uint32) { RMMessage msg(dwMessage); int i; RMPoint pt; @@ -1433,15 +1462,15 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(uint32 nChar, uint32 dwMessage, uint32 Unfreeze(); } -DECLARE_CUSTOM_FUNCTION(AddInventory)(uint32 dwCode, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(AddInventory)(CORO_PARAM, uint32 dwCode, uint32, uint32, uint32) { Inventory->AddItem(dwCode); } -DECLARE_CUSTOM_FUNCTION(RemoveInventory)(uint32 dwCode, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(RemoveInventory)(CORO_PARAM, uint32 dwCode, uint32, uint32, uint32) { Inventory->RemoveItem(dwCode); } -DECLARE_CUSTOM_FUNCTION(ChangeInventoryStatus)(uint32 dwCode, uint32 dwStatus, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(ChangeInventoryStatus)(CORO_PARAM, uint32 dwCode, uint32 dwStatus, uint32, uint32) { Inventory->ChangeItemStatus(dwCode,dwStatus); } @@ -1452,7 +1481,7 @@ DECLARE_CUSTOM_FUNCTION(ChangeInventoryStatus)(uint32 dwCode, uint32 dwStatus, u * Mastri Personaggi */ -DECLARE_CUSTOM_FUNCTION(MCharSetCode)(uint32 nChar, uint32 nCode, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(MCharSetCode)(CORO_PARAM, uint32 nChar, uint32 nCode, uint32, uint32) { assert(nChar < 10); MCharacter[nChar].code=nCode; if (nCode== 0) @@ -1474,19 +1503,19 @@ DECLARE_CUSTOM_FUNCTION(MCharSetCode)(uint32 nChar, uint32 nCode, uint32, uint32 IsMChar[nChar] = true; } -DECLARE_CUSTOM_FUNCTION(MCharResetCode)(uint32 nChar, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(MCharResetCode)(CORO_PARAM, uint32 nChar, uint32, uint32, uint32) { MCharacter[nChar].item=Loc->GetItemFromCode(MCharacter[nChar].code); } -DECLARE_CUSTOM_FUNCTION(MCharSetPosition)(uint32 nChar, uint32 nX, uint32 nY, uint32) { +DECLARE_CUSTOM_FUNCTION(MCharSetPosition)(CORO_PARAM, uint32 nChar, uint32 nX, uint32 nY, uint32) { assert(nChar < 10); MCharacter[nChar].x=nX; MCharacter[nChar].y=nY; } -DECLARE_CUSTOM_FUNCTION(MCharSetColor)(uint32 nChar, uint32 r, uint32 g, uint32 b) { +DECLARE_CUSTOM_FUNCTION(MCharSetColor)(CORO_PARAM, uint32 nChar, uint32 r, uint32 g, uint32 b) { assert(nChar < 10); MCharacter[nChar].r=r; MCharacter[nChar].g=g; @@ -1494,7 +1523,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSetColor)(uint32 nChar, uint32 r, uint32 g, uint32 } -DECLARE_CUSTOM_FUNCTION(MCharSetNumTalksInGroup)(uint32 nChar, uint32 nGroup, uint32 nTalks, uint32) { +DECLARE_CUSTOM_FUNCTION(MCharSetNumTalksInGroup)(CORO_PARAM, uint32 nChar, uint32 nGroup, uint32 nTalks, uint32) { assert(nChar < 10); assert(nGroup < 10); @@ -1502,7 +1531,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSetNumTalksInGroup)(uint32 nChar, uint32 nGroup, ui } -DECLARE_CUSTOM_FUNCTION(MCharSetCurrentGroup)(uint32 nChar, uint32 nGroup, uint32, uint32) +DECLARE_CUSTOM_FUNCTION(MCharSetCurrentGroup)(CORO_PARAM, uint32 nChar, uint32 nGroup, uint32, uint32) { assert(nChar < 10); assert(nGroup < 10); @@ -1510,21 +1539,21 @@ DECLARE_CUSTOM_FUNCTION(MCharSetCurrentGroup)(uint32 nChar, uint32 nGroup, uint3 MCharacter[nChar].curgroup = nGroup; } -DECLARE_CUSTOM_FUNCTION(MCharSetNumTexts)(uint32 nChar, uint32 nTexts, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(MCharSetNumTexts)(CORO_PARAM, uint32 nChar, uint32 nTexts, uint32, uint32) { assert(nChar < 10); MCharacter[nChar].numtexts=nTexts-1; MCharacter[nChar].bInTexts = false; } -DECLARE_CUSTOM_FUNCTION(MCharSetAlwaysBack)(uint32 nChar, uint32 bAlwaysBack, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(MCharSetAlwaysBack)(CORO_PARAM, uint32 nChar, uint32 bAlwaysBack, uint32, uint32) { assert(nChar < 10); MCharacter[nChar].bAlwaysBack=bAlwaysBack; } -DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(uint32 nChar, uint32 dwMessage, uint32 bIsBack, uint32 nFont) { +DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMessage, uint32 bIsBack, uint32 nFont) { RMMessage msg(dwMessage); int i; int parm; @@ -1645,7 +1674,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(uint32 nChar, uint32 dwMessage, uint32 int curDialog; -DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(uint32 nPers, uint32 nMsg, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg, uint32, uint32) { LPSTR string; RMTextDialog* text; int parm; @@ -1822,7 +1851,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(uint32 nPers, uint32 nMsg, uint32, ui // @@@@ QUESTA NON SI PUO' SKIPPARE!!!!!!!!!!!!!!!!!!! -DECLARE_CUSTOM_FUNCTION(StartDialog)(uint32 nDialog, uint32 nStartGroup, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGroup, uint32, uint32) { int nChoice; uint32 *sl; int i,num; @@ -1897,12 +1926,12 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(uint32 nDialog, uint32 nStartGroup, uint32, * Sync tra idle e mpal */ -DECLARE_CUSTOM_FUNCTION(TakeOwnership)(uint32 num, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TakeOwnership)(CORO_PARAM, uint32 num, uint32, uint32, uint32) { // EnterCriticalSection(&cs[num]); WaitForSingleObject(mut[num],INFINITE); } -DECLARE_CUSTOM_FUNCTION(ReleaseOwnership)(uint32 num, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(ReleaseOwnership)(CORO_PARAM, uint32 num, uint32, uint32, uint32) { // LeaveCriticalSection(&cs[num]); // g_system->unlockMutex(mut[num]); warning("TODO: ReleaseOwnership"); @@ -1975,46 +2004,46 @@ void ThreadFadeOutMusic(void *nMusic) { _endthread(); } -DECLARE_CUSTOM_FUNCTION(FadeInSonoriz)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(FadeInSonoriz)(CORO_PARAM, uint32, uint32, uint32, uint32) { _beginthread(ThreadFadeInMusic, 10240, (void*)curSonoriz); } -DECLARE_CUSTOM_FUNCTION(FadeOutSonoriz)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(FadeOutSonoriz)(CORO_PARAM, uint32, uint32, uint32, uint32) { bFadeOutStop = false; _beginthread(ThreadFadeOutMusic, 10240, (void *)curSonoriz); } -DECLARE_CUSTOM_FUNCTION(FadeOutStacchetto)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(FadeOutStacchetto)(CORO_PARAM, uint32, uint32, uint32, uint32) { bFadeOutStop = false; _beginthread(ThreadFadeOutMusic, 10240, (void*)2); } -DECLARE_CUSTOM_FUNCTION(FadeInStacchetto)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(FadeInStacchetto)(CORO_PARAM, uint32, uint32, uint32, uint32) { _beginthread(ThreadFadeInMusic, 10240, (void*)2); } -DECLARE_CUSTOM_FUNCTION(StopSonoriz)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(StopSonoriz)(CORO_PARAM, uint32, uint32, uint32, uint32) { _vm->StopMusic(curSonoriz); } -DECLARE_CUSTOM_FUNCTION(StopStacchetto)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(StopStacchetto)(CORO_PARAM, uint32, uint32, uint32, uint32) { _vm->StopMusic(2); } -DECLARE_CUSTOM_FUNCTION(MuteSonoriz)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(MuteSonoriz)(CORO_PARAM, uint32, uint32, uint32, uint32) { _vm->SetMusicVolume(curSonoriz, 0); } -DECLARE_CUSTOM_FUNCTION(DemuteSonoriz)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(DemuteSonoriz)(CORO_PARAM, uint32, uint32, uint32, uint32) { bFadeOutStop = true; _vm->SetMusicVolume(curSonoriz, 64); } -DECLARE_CUSTOM_FUNCTION(MuteStacchetto)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(MuteStacchetto)(CORO_PARAM, uint32, uint32, uint32, uint32) { _vm->SetMusicVolume(2, 0); } -DECLARE_CUSTOM_FUNCTION(DemuteStacchetto)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(DemuteStacchetto)(CORO_PARAM, uint32, uint32, uint32, uint32) { _vm->SetMusicVolume(2, 64); } @@ -2139,7 +2168,7 @@ void CustPlayMusic(uint32 nChannel, const char *mFN, uint32 nFX, bool bLoop, int debug("End CustPlayMusic\n"); } -DECLARE_CUSTOM_FUNCTION(PlaySonoriz)(uint32 nMusic, uint32 nFX, uint32 bNoLoop, uint32) { +DECLARE_CUSTOM_FUNCTION(PlaySonoriz)(CORO_PARAM, uint32 nMusic, uint32 nFX, uint32 bNoLoop, uint32) { if (nFX == 0 || nFX == 1 || nFX==2) { debug("PlaySonoriz stop fadeout\n"); bFadeOutStop = true; @@ -2149,11 +2178,11 @@ DECLARE_CUSTOM_FUNCTION(PlaySonoriz)(uint32 nMusic, uint32 nFX, uint32 bNoLoop, CustPlayMusic(curSonoriz, musicFiles[nMusic].name, nFX, bNoLoop ? false : true, musicFiles[nMusic].sync); } -DECLARE_CUSTOM_FUNCTION(PlayStacchetto)(uint32 nMusic, uint32 nFX, uint32 bLoop, uint32) { +DECLARE_CUSTOM_FUNCTION(PlayStacchetto)(CORO_PARAM, uint32 nMusic, uint32 nFX, uint32 bLoop, uint32) { CustPlayMusic(2,staccFileNames[nMusic],nFX,bLoop); } -DECLARE_CUSTOM_FUNCTION(PlayItemSfx)(uint32 nItem, uint32 nSFX, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(PlayItemSfx)(CORO_PARAM, uint32 nItem, uint32 nSFX, uint32, uint32) { if (nItem== 0) { Tony->PlaySfx(nSFX); } else { @@ -2165,7 +2194,7 @@ DECLARE_CUSTOM_FUNCTION(PlayItemSfx)(uint32 nItem, uint32 nSFX, uint32, uint32) void RestoreMusic(void) { - PlaySonoriz(lastMusic, 0, 0, 0); + PlaySonoriz(nullContext, lastMusic, 0, 0, 0); if (lastTappeto != 0) CustPlayMusic(4, tappetiFile[lastTappeto], 0, true); } @@ -2181,49 +2210,63 @@ void LoadMusic(Common::InSaveFile *f) { } -DECLARE_CUSTOM_FUNCTION(StacchettoFadeStart)(uint32 nStacc, uint32 bLoop, uint32, uint32) { - FadeOutSonoriz(0, 0, 0, 0); - MuteStacchetto(0, 0, 0, 0); - PlayStacchetto(nStacc, 0, bLoop, 0); - FadeInStacchetto(0, 0, 0, 0); +DECLARE_CUSTOM_FUNCTION(StacchettoFadeStart)(CORO_PARAM, uint32 nStacc, uint32 bLoop, uint32, uint32) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + CORO_INVOKE_4(FadeOutSonoriz, 0, 0, 0, 0); + CORO_INVOKE_4(MuteStacchetto, 0, 0, 0, 0); + CORO_INVOKE_4(PlayStacchetto, nStacc, 0, bLoop, 0); + CORO_INVOKE_4(FadeInStacchetto, 0, 0, 0, 0); + + CORO_END_CODE; } -DECLARE_CUSTOM_FUNCTION(StacchettoFadeEnd)(uint32 nStacc, uint32 bLoop, uint32, uint32) { - FadeOutStacchetto(0, 0, 0, 0); - FadeInSonoriz(0, 0, 0, 0); +DECLARE_CUSTOM_FUNCTION(StacchettoFadeEnd)(CORO_PARAM, uint32 nStacc, uint32 bLoop, uint32, uint32) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + CORO_INVOKE_4(FadeOutStacchetto, 0, 0, 0, 0); + CORO_INVOKE_4(FadeInSonoriz, 0, 0, 0, 0); + + CORO_END_CODE; } -DECLARE_CUSTOM_FUNCTION(MustSkipIdleStart)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(MustSkipIdleStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { bSkipIdle = true; SetEvent(hSkipIdle); } -DECLARE_CUSTOM_FUNCTION(MustSkipIdleEnd)(uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(MustSkipIdleEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { bSkipIdle = false; ResetEvent(hSkipIdle); } -DECLARE_CUSTOM_FUNCTION(PatIrqFreeze)(uint32 bStatus, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(PatIrqFreeze)(CORO_PARAM, uint32 bStatus, uint32, uint32, uint32) { bPatIrqFreeze = bStatus; } -DECLARE_CUSTOM_FUNCTION(OpenInitLoadMenu)(uint32 , uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(OpenInitLoadMenu)(CORO_PARAM, uint32, uint32, uint32, uint32) { Freeze(); _vm->OpenInitLoadMenu(); Unfreeze(); } -DECLARE_CUSTOM_FUNCTION(OpenInitOptions)(uint32 , uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(OpenInitOptions)(CORO_PARAM, uint32, uint32, uint32, uint32) { Freeze(); _vm->OpenInitOptions(); Unfreeze(); } -DECLARE_CUSTOM_FUNCTION(DoCredits)(uint32 nMsg, uint32 dwTime, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(DoCredits)(CORO_PARAM, uint32 nMsg, uint32 dwTime, uint32, uint32) { RMMessage msg(nMsg); RMTextDialog *text; HANDLE hDisable = CreateEvent(NULL, true, false, NULL); diff --git a/engines/tony/custom.h b/engines/tony/custom.h index 57d726f70e..a9f4ac2aab 100644 --- a/engines/tony/custom.h +++ b/engines/tony/custom.h @@ -67,10 +67,10 @@ typedef uint32 HWND; #define DECLARE_CUSTOM_FUNCTION(x) void x #define BEGIN_CUSTOM_FUNCTION_MAP() \ - static void AssignError(HWND hWnd, int num) { \ + static void AssignError(int num) { \ error("Custom function %u has been already assigned!", num); \ } \ - void INIT_CUSTOM_FUNCTION(HWND hWnd, LPCUSTOMFUNCTION *lpMap) \ + void INIT_CUSTOM_FUNCTION(LPCUSTOMFUNCTION *lpMap) \ { @@ -78,10 +78,10 @@ typedef uint32 HWND; } -#define ASSIGN(num,func) \ - if (lpMap[num]!=NULL) \ - AssignError(hWnd,num); \ - lpMap[num]=func; +#define ASSIGN(num, func) \ + if (lpMap[num] != NULL) \ + AssignError(num); \ + lpMap[num] = func; class RMTony; class RMPointer; @@ -90,7 +90,7 @@ class RMLocation; class RMInventory; class RMInput; -void INIT_CUSTOM_FUNCTION(HWND hWnd, LPCUSTOMFUNCTION *lpMap); +void INIT_CUSTOM_FUNCTION(LPCUSTOMFUNCTION *lpMap); void SetupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation *loc, RMInventory *inv, RMInput *input); #endif diff --git a/engines/tony/module.mk b/engines/tony/module.mk index af0b3acd2c..24e7f70557 100644 --- a/engines/tony/module.mk +++ b/engines/tony/module.mk @@ -1,6 +1,7 @@ MODULE := engines/tony MODULE_OBJS := \ + coroutine.o \ custom.o \ detection.o \ font.o \ @@ -10,6 +11,7 @@ MODULE_OBJS := \ input.o \ inventory.o \ loc.o \ + sched.o \ sound.o \ tony.o \ tonychar.o \ diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index b977feb03b..3757cdddcf 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -51,11 +51,12 @@ #include "common/file.h" #include "common/savefile.h" #include "common/system.h" +#include "tony/sched.h" #include "tony/tony.h" -#include "lzo.h" -#include "mpal.h" -#include "mpaldll.h" -#include "stubs.h" +#include "tony/mpal/lzo.h" +#include "tony/mpal/mpal.h" +#include "tony/mpal/mpaldll.h" +#include "tony/mpal/stubs.h" namespace Tony { @@ -829,7 +830,10 @@ static LPITEM GetItemData(uint32 nOrdItem) { \****************************************************************************/ void PASCAL CustomThread(LPCFCALL p) { - lplpFunctions[p->nCf](p->arg1, p->arg2, p->arg3, p->arg4); + // FIXME: Convert to proper corotuine call + warning("FIXME: CustomThread call"); + + lplpFunctions[p->nCf](nullContext, p->arg1, p->arg2, p->arg3, p->arg4); GlobalFree(p); ExitThread(1); // _endthread(); @@ -939,50 +943,69 @@ void PASCAL ScriptThread(LPMPALSCRIPT s) { * \****************************************************************************/ -void PASCAL ActionThread(LPMPALITEM item) { - int j, k; +void ActionThread(CORO_PARAM, const void *param) { + // COROUTINE + CORO_BEGIN_CONTEXT; + int j, k; + CORO_END_CONTEXT(_ctx); - for (j = 0;jAction[item->dwRes].nCmds; j++) { - k=item->Action[item->dwRes].CmdNum[j]; + const LPMPALITEM item = *(const LPMPALITEM *)param; - switch (item->Command[k].type) { - case 1: - // Funzione custom - lplpFunctions[item->Command[k].nCf]( - item->Command[k].arg1, - item->Command[k].arg2, - item->Command[k].arg3, - item->Command[k].arg4 - ); - break; + CORO_BEGIN_CODE(_ctx); + + mpalError = 0; + for (_ctx->j = 0; _ctx->j < item->Action[item->dwRes].nCmds; _ctx->j++) { + _ctx->k = item->Action[item->dwRes].CmdNum[_ctx->j]; + + if (item->Command[_ctx->k].type == 1) { + // Custom function + CORO_INVOKE_4(lplpFunctions[item->Command[_ctx->k].nCf], + item->Command[_ctx->k].arg1, + item->Command[_ctx->k].arg2, + item->Command[_ctx->k].arg3, + item->Command[_ctx->k].arg4 - case 2: + ); + } else if (item->Command[_ctx->k].type == 2) { // Variable assign LockVar(); - varSetValue(item->Command[k].lpszVarName, EvaluateExpression(item->Command[k].expr)); + varSetValue(item->Command[_ctx->k].lpszVarName, EvaluateExpression(item->Command[_ctx->k].expr)); UnlockVar(); break; - default: + } else { mpalError = 1; - ExitThread(0); -// _endthread(); + break; } } GlobalFree(item); - //bExecutingAction = false; + + CORO_KILL_SELF(); - ExitThread(1); -// _endthread(); + CORO_END_CODE; } -void PASCAL ShutUpActionThread(HANDLE hThread) { +/** + * This thread monitors a created action to detect when it ends. + * @remarks Since actions can spawn sub-actions, this needs to be a + * separate thread to determine when the outer action is done + */ +void ShutUpActionThread(CORO_PARAM, const void *param) { + // COROUTINE + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + HANDLE hThread = *(const HANDLE *)param; + + CORO_BEGIN_CODE(_ctx); + WaitForSingleObject(hThread, INFINITE); bExecutingAction = false; - ExitThread(1); -// _endthread(); + CORO_KILL_SELF(); + + CORO_END_CODE; } /****************************************************************************\ @@ -1241,7 +1264,8 @@ void PASCAL LocationPollThread(uint32 id) { */ // Set idle skip on - lplpFunctions[200](0, 0, 0, 0); + // FIXME: Convert to co-routine + lplpFunctions[200](nullContext, 0, 0, 0, 0); for (i = 0; i < nRealItems; i++) if (MyThreads[i].nItem != 0) { @@ -1252,7 +1276,8 @@ void PASCAL LocationPollThread(uint32 id) { } // Set idle skip off - lplpFunctions[201](0, 0, 0, 0); + // FIXME: Convert to co-routine + lplpFunctions[201](nullContext, 0, 0, 0, 0); /* Abbiamo finito */ GlobalFree(MyThreads); @@ -1324,7 +1349,9 @@ void PASCAL GroupThread(uint32 nGroup) { switch (dialog->Command[k].type) { /* Funzione custom: la richiama */ case 1: + // FIXME: Convert to co-routine lplpFunctions[dialog->Command[k].nCf]( + nullContext, dialog->Command[k].arg1, dialog->Command[k].arg2, dialog->Command[k].arg3, @@ -1488,8 +1515,7 @@ static HANDLE DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { LPMPALITEM item = lpmiItems; int i; LPMPALITEM newitem; - uint32 dwId; - HANDLE h; + PROCESS *h; item+=ordItem; Common::String buf = Common::String::format("Status.%u", item->nObj); @@ -1510,7 +1536,7 @@ static HANDLE DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { // Ora abbiamo trova l'azione giusta che deve essere eseguita. // Duplichiamo l'item corrente e copiamo la azione #i nella #0 - newitem=(LPMPALITEM)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MPALITEM)); + newitem = (LPMPALITEM)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MPALITEM)); if (newitem == NULL) return INVALID_HANDLE_VALUE; @@ -1524,12 +1550,11 @@ static HANDLE DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { // E finalmente possiamo richiamare il thread, che eseguira' l'azione // 0 dell'item, e poi liberera' la memoria con la GlobalFree() -/* !!! Nuova gestione dei thread -*/ - if ((h = CreateThread(NULL, 10240, (LPTHREAD_START_ROUTINE)ActionThread, (void *)newitem, 0, &dwId)) == NULL) + // !!! New thread management + if ((h = g_scheduler->createProcess(ActionThread, newitem)) == NULL) return INVALID_HANDLE_VALUE; - if ((h = CreateThread(NULL, 10240,(LPTHREAD_START_ROUTINE)ShutUpActionThread, (void *)h, 0, &dwId)) == NULL) + if ((h = g_scheduler->createProcess(0, ShutUpActionThread, &h, sizeof(PROCESS *))) == NULL) return INVALID_HANDLE_VALUE; /* @@ -1543,7 +1568,7 @@ static HANDLE DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { nExecutingAction = item->nObj; bExecutingAction = true; - return h; + return (HANDLE)h; } return INVALID_HANDLE_VALUE; @@ -1674,7 +1699,7 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, LPLPCUST //printf("Dialog: %lu\n", sizeof(MPALDIALOG)); /* Si salva l'array delle funzioni custom */ - lplpFunctions=lplpcfArray; + lplpFunctions = lplpcfArray; /* Apre il file MPC in lettura */ if (!hMpc.open(lpszMpcFileName)) diff --git a/engines/tony/mpal/mpal.h b/engines/tony/mpal/mpal.h index e66f1fdb7e..3c2e62d992 100644 --- a/engines/tony/mpal/mpal.h +++ b/engines/tony/mpal/mpal.h @@ -119,6 +119,7 @@ #include "common/scummsys.h" #include "common/rect.h" +#include "tony/coroutine.h" namespace Tony { @@ -220,7 +221,7 @@ typedef ITEM *LPITEM; * to perform various controls as a result of an action \****************************************************************************/ -typedef void (*LPCUSTOMFUNCTION)(uint32, uint32, uint32, uint32); +typedef void (*LPCUSTOMFUNCTION)(CORO_PARAM, uint32, uint32, uint32, uint32); typedef LPCUSTOMFUNCTION *LPLPCUSTOMFUNCTION; diff --git a/engines/tony/sched.cpp b/engines/tony/sched.cpp new file mode 100644 index 0000000000..7f259b7a5b --- /dev/null +++ b/engines/tony/sched.cpp @@ -0,0 +1,498 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Process scheduler. + */ + +#include "common/textconsole.h" +#include "common/util.h" +#include "tony/sched.h" + +namespace Tony { + +Scheduler *g_scheduler = 0; + +//--------------------- FUNCTIONS ------------------------ + +Scheduler::Scheduler() { + processList = NULL; + pFreeProcesses = NULL; + pCurrent = NULL; + +#ifdef DEBUG + // diagnostic process counters + numProcs = 0; + maxProcs = 0; +#endif + + pRCfunction = 0; + + active = new PROCESS; + active->pPrevious = NULL; + active->pNext = NULL; + + g_scheduler = this; // FIXME HACK +} + +Scheduler::~Scheduler() { + // Kill all running processes (i.e. free memory allocated for their state). + PROCESS *pProc = active->pNext; + while (pProc != NULL) { + delete pProc->state; + pProc->state = 0; + pProc = pProc->pNext; + } + + free(processList); + processList = NULL; + + delete active; + active = 0; +} + +/** + * Kills all processes and places them on the free list. + */ +void Scheduler::reset() { + +#ifdef DEBUG + // clear number of process in use + numProcs = 0; +#endif + + if (processList == NULL) { + // first time - allocate memory for process list + processList = (PROCESS *)calloc(MAX_PROCESSES, sizeof(PROCESS)); + + // make sure memory allocated + if (processList == NULL) { + error("Cannot allocate memory for process data"); + } + + // fill with garbage + memset(processList, 'S', MAX_PROCESSES * sizeof(PROCESS)); + } + + // Kill all running processes (i.e. free memory allocated for their state). + PROCESS *pProc = active->pNext; + while (pProc != NULL) { + delete pProc->state; + pProc->state = 0; + pProc = pProc->pNext; + } + + // no active processes + pCurrent = active->pNext = NULL; + + // place first process on free list + pFreeProcesses = processList; + + // link all other processes after first + for (int i = 1; i <= NUM_PROCESS; i++) { + processList[i - 1].pNext = (i == NUM_PROCESS) ? NULL : processList + i; + processList[i - 1].pPrevious = (i == 1) ? active : processList + (i - 2); + } +} + + +#ifdef DEBUG +/** + * Shows the maximum number of process used at once. + */ +void Scheduler::printStats() { + debug("%i process of %i used", maxProcs, NUM_PROCESS); +} +#endif + +#ifdef DEBUG +/** + * Checks both the active and free process list to insure all the links are valid, + * and that no processes have been lost + */ +void Scheduler::CheckStack() { + Common::List pList; + + // Check both the active and free process lists + for (int i = 0; i < 2; ++i) { + PROCESS *p = (i == 0) ? active : pFreeProcesses; + + if (p != NULL) { + // Make sure the linkages are correct + while (p->pNext != NULL) { + assert(p->pNext->pPrevious == p); + pList.push_back(p); + p = p->pNext; + } + pList.push_back(p); + } + } + + // Make sure all processes are accounted for + for (int idx = 0; idx < NUM_PROCESS; idx++) { + bool found = false; + for (Common::List::iterator i = pList.begin(); i != pList.end(); ++i) { + PROCESS *pTemp = *i; + if (*i == &processList[idx]) { + found = true; + break; + } + } + + assert(found); + } +} +#endif + +/** + * Give all active processes a chance to run + */ +void Scheduler::schedule() { + // start dispatching active process list + PROCESS *pNext; + PROCESS *pProc = active->pNext; + while (pProc != NULL) { + pNext = pProc->pNext; + + if (--pProc->sleepTime <= 0) { + // process is ready for dispatch, activate it + pCurrent = pProc; + pProc->coroAddr(pProc->state, pProc->param); + + if (!pProc->state || pProc->state->_sleep <= 0) { + // Coroutine finished + pCurrent = pCurrent->pPrevious; + killProcess(pProc); + } else { + pProc->sleepTime = pProc->state->_sleep; + } + + // pCurrent may have been changed + pNext = pCurrent->pNext; + pCurrent = NULL; + } + + pProc = pNext; + } +} + +/** + * Reschedules all the processes to run again this query + */ +void Scheduler::rescheduleAll() { + assert(pCurrent); + + // Unlink current process + pCurrent->pPrevious->pNext = pCurrent->pNext; + if (pCurrent->pNext) + pCurrent->pNext->pPrevious = pCurrent->pPrevious; + + // Add process to the start of the active list + pCurrent->pNext = active->pNext; + active->pNext->pPrevious = pCurrent; + active->pNext = pCurrent; + pCurrent->pPrevious = active; +} + +/** + * If the specified process has already run on this tick, make it run + * again on the current tick. + */ +void Scheduler::reschedule(PPROCESS pReSchedProc) { + // If not currently processing the schedule list, then no action is needed + if (!pCurrent) + return; + + if (!pReSchedProc) + pReSchedProc = pCurrent; + + PPROCESS pEnd; + + // Find the last process in the list. + // But if the target process is down the list from here, do nothing + for (pEnd = pCurrent; pEnd->pNext != NULL; pEnd = pEnd->pNext) { + if (pEnd->pNext == pReSchedProc) + return; + } + + assert(pEnd->pNext == NULL); + + // Could be in the middle of a KillProc()! + // Dying process was last and this process was penultimate + if (pReSchedProc->pNext == NULL) + return; + + // If we're moving the current process, move it back by one, so that the next + // schedule() iteration moves to the now next one + if (pCurrent == pReSchedProc) + pCurrent = pCurrent->pPrevious; + + // Unlink the process, and add it at the end + pReSchedProc->pPrevious->pNext = pReSchedProc->pNext; + pReSchedProc->pNext->pPrevious = pReSchedProc->pPrevious; + pEnd->pNext = pReSchedProc; + pReSchedProc->pPrevious = pEnd; + pReSchedProc->pNext = NULL; +} + +/** + * Moves the specified process to the end of the dispatch queue + * allowing it to run again within the current game cycle. + * @param pGiveProc Which process + */ +void Scheduler::giveWay(PPROCESS pReSchedProc) { + // If not currently processing the schedule list, then no action is needed + if (!pCurrent) + return; + + if (!pReSchedProc) + pReSchedProc = pCurrent; + + // If the process is already at the end of the queue, nothing has to be done + if (!pReSchedProc->pNext) + return; + + PPROCESS pEnd; + + // Find the last process in the list. + for (pEnd = pCurrent; pEnd->pNext != NULL; pEnd = pEnd->pNext) + ; + assert(pEnd->pNext == NULL); + + + // If we're moving the current process, move it back by one, so that the next + // schedule() iteration moves to the now next one + if (pCurrent == pReSchedProc) + pCurrent = pCurrent->pPrevious; + + // Unlink the process, and add it at the end + pReSchedProc->pPrevious->pNext = pReSchedProc->pNext; + pReSchedProc->pNext->pPrevious = pReSchedProc->pPrevious; + pEnd->pNext = pReSchedProc; + pReSchedProc->pPrevious = pEnd; + pReSchedProc->pNext = NULL; +} + +/** + * Creates a new process. + * + * @param pid process identifier + * @param CORO_ADDR coroutine start address + * @param pParam process specific info + * @param sizeParam size of process specific info + */ +PROCESS *Scheduler::createProcess(int pid, CORO_ADDR coroAddr, const void *pParam, int sizeParam) { + PROCESS *pProc; + + // get a free process + pProc = pFreeProcesses; + + // trap no free process + assert(pProc != NULL); // Out of processes + +#ifdef DEBUG + // one more process in use + if (++numProcs > maxProcs) + maxProcs = numProcs; +#endif + + // get link to next free process + pFreeProcesses = pProc->pNext; + if (pFreeProcesses) + pFreeProcesses->pPrevious = NULL; + + if (pCurrent != NULL) { + // place new process before the next active process + pProc->pNext = pCurrent->pNext; + if (pProc->pNext) + pProc->pNext->pPrevious = pProc; + + // make this new process the next active process + pCurrent->pNext = pProc; + pProc->pPrevious = pCurrent; + + } else { // no active processes, place process at head of list + pProc->pNext = active->pNext; + pProc->pPrevious = active; + + if (pProc->pNext) + pProc->pNext->pPrevious = pProc; + active->pNext = pProc; + + } + + // set coroutine entry point + pProc->coroAddr = coroAddr; + + // clear coroutine state + pProc->state = 0; + + // wake process up as soon as possible + pProc->sleepTime = 1; + + // set new process id + pProc->pid = pid; + + // set new process specific info + if (sizeParam) { + assert(sizeParam > 0 && sizeParam <= PARAM_SIZE); + + // set new process specific info + memcpy(pProc->param, pParam, sizeParam); + } + + // return created process + return pProc; +} + +/** + * Kills the specified process. + * + * @param pKillProc which process to kill + */ +void Scheduler::killProcess(PROCESS *pKillProc) { + // make sure a valid process pointer + assert(pKillProc >= processList && pKillProc <= processList + NUM_PROCESS - 1); + + // can not kill the current process using killProcess ! + assert(pCurrent != pKillProc); + +#ifdef DEBUG + // one less process in use + --numProcs; + assert(numProcs >= 0); +#endif + + // Free process' resources + if (pRCfunction != NULL) + (pRCfunction)(pKillProc); + + delete pKillProc->state; + pKillProc->state = 0; + + // Take the process out of the active chain list + pKillProc->pPrevious->pNext = pKillProc->pNext; + if (pKillProc->pNext) + pKillProc->pNext->pPrevious = pKillProc->pPrevious; + + // link first free process after pProc + pKillProc->pNext = pFreeProcesses; + if (pFreeProcesses) + pKillProc->pNext->pPrevious = pKillProc; + pKillProc->pPrevious = NULL; + + // make pKillProc the first free process + pFreeProcesses = pKillProc; +} + + + +/** + * Returns a pointer to the currently running process. + */ +PROCESS *Scheduler::getCurrentProcess() { + return pCurrent; +} + +/** + * Returns the process identifier of the specified process. + * + * @param pProc which process + */ +int Scheduler::getCurrentPID() const { + PROCESS *pProc = pCurrent; + + // make sure a valid process pointer + assert(pProc >= processList && pProc <= processList + NUM_PROCESS - 1); + + // return processes PID + return pProc->pid; +} + +/** + * Kills any process matching the specified PID. The current + * process cannot be killed. + * + * @param pidKill process identifier of process to kill + * @param pidMask mask to apply to process identifiers before comparison + * @return The number of processes killed is returned. + */ +int Scheduler::killMatchingProcess(int pidKill, int pidMask) { + int numKilled = 0; + PROCESS *pProc, *pPrev; // process list pointers + + for (pProc = active->pNext, pPrev = active; pProc != NULL; pPrev = pProc, pProc = pProc->pNext) { + if ((pProc->pid & pidMask) == pidKill) { + // found a matching process + + // dont kill the current process + if (pProc != pCurrent) { + // kill this process + numKilled++; + + // Free the process' resources + if (pRCfunction != NULL) + (pRCfunction)(pProc); + + delete pProc->state; + pProc->state = 0; + + // make prev point to next to unlink pProc + pPrev->pNext = pProc->pNext; + if (pProc->pNext) + pPrev->pNext->pPrevious = pPrev; + + // link first free process after pProc + pProc->pNext = pFreeProcesses; + pProc->pPrevious = NULL; + pFreeProcesses->pPrevious = pProc; + + // make pProc the first free process + pFreeProcesses = pProc; + + // set to a process on the active list + pProc = pPrev; + } + } + } + +#ifdef DEBUG + // adjust process in use + numProcs -= numKilled; + assert(numProcs >= 0); +#endif + + // return number of processes killed + return numKilled; +} + +/** + * Set pointer to a function to be called by killProcess(). + * + * May be called by a resource allocator, the function supplied is + * called by killProcess() to allow the resource allocator to free + * resources allocated to the dying process. + * + * @param pFunc Function to be called by killProcess() + */ +void Scheduler::setResourceCallback(VFPTRPP pFunc) { + pRCfunction = pFunc; +} + +} // End of namespace Tony diff --git a/engines/tony/sched.h b/engines/tony/sched.h new file mode 100644 index 0000000000..9bc6d052da --- /dev/null +++ b/engines/tony/sched.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. + * + * Data structures used by the process scheduler + */ + +#ifndef TONY_SCHED_H +#define TONY_SCHED_H + +#include "tony/coroutine.h" + +namespace Tony { + +// the size of process specific info +#define PARAM_SIZE 32 + +// the maximum number of processes +#define NUM_PROCESS 100 +#define MAX_PROCESSES 100 + +typedef void (*CORO_ADDR)(CoroContext &, const void *); + +/** process structure */ +struct PROCESS { + PROCESS *pNext; ///< pointer to next process in active or free list + PROCESS *pPrevious; ///< pointer to previous process in active or free list + + CoroContext state; ///< the state of the coroutine + CORO_ADDR coroAddr; ///< the entry point of the coroutine + + int sleepTime; ///< number of scheduler cycles to sleep + int pid; ///< process ID + char param[PARAM_SIZE]; ///< process specific info +}; +typedef PROCESS *PPROCESS; + +struct INT_CONTEXT; + +/** + * Create and manage "processes" (really coroutines). + */ +class Scheduler { +public: + /** Pointer to a function of the form "void function(PPROCESS)" */ + typedef void (*VFPTRPP)(PROCESS *); + +private: + + /** list of all processes */ + PROCESS *processList; + + /** active process list - also saves scheduler state */ + PROCESS *active; + + /** pointer to free process list */ + PROCESS *pFreeProcesses; + + /** the currently active process */ + PROCESS *pCurrent; + +#ifdef DEBUG + // diagnostic process counters + int numProcs; + int maxProcs; + + void CheckStack(); +#endif + + /** + * Called from killProcess() to enable other resources + * a process may be allocated to be released. + */ + VFPTRPP pRCfunction; + + +public: + + Scheduler(); + ~Scheduler(); + + void reset(); + + #ifdef DEBUG + void printStats(); + #endif + + void schedule(); + void rescheduleAll(); + void reschedule(PPROCESS pReSchedProc = NULL); + void giveWay(PPROCESS pReSchedProc = NULL); + + PROCESS *createProcess(int pid, CORO_ADDR coroAddr, const void *pParam, int sizeParam); + PROCESS *createProcess(CORO_ADDR coroAddr, const void *pParam) { + return createProcess(0, coroAddr, &pParam, sizeof(void *)); + } + void killProcess(PROCESS *pKillProc); + + PROCESS *getCurrentProcess(); + int getCurrentPID() const; + int killMatchingProcess(int pidKill, int pidMask = -1); + + + void setResourceCallback(VFPTRPP pFunc); + +}; + +extern Scheduler *g_scheduler; // FIXME: Temporary global var, to be used until everything has been OOifyied + +} // End of namespace Tony + +#endif // TONY_SCHED_H diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index cf746dc978..ab6592342d 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -26,6 +26,7 @@ #include "common/events.h" #include "common/file.h" #include "tony/tony.h" +#include "tony/custom.h" #include "tony/game.h" #include "tony/mpal/mpal.h" @@ -67,11 +68,15 @@ Common::ErrorCode TonyEngine::Init() { m_bDrawLocation = true; m_startTime = g_system->getMillis(); + // Reset the scheduler + _scheduler.reset(); + // Initialise the graphics window _window.Init(); // Initialise the function list Common::fill(FuncList, FuncList + 300, (LPCUSTOMFUNCTION)NULL); + InitCustomFunctionMap(); // Initializes MPAL system, passing the custom functions list Common::File f; @@ -127,6 +132,10 @@ Common::ErrorCode TonyEngine::Init() { return Common::kNoError; } +void TonyEngine::InitCustomFunctionMap() { + INIT_CUSTOM_FUNCTION(FuncList); +} + /** * Display an error message */ @@ -385,6 +394,9 @@ void TonyEngine::Play(void) { while (g_system->getEventManager()->pollEvent(evt)) ; + // Call any scheduled processes + _scheduler.schedule(); + // Call the engine to handle the next frame _theEngine.DoFrame(m_bDrawLocation); @@ -468,8 +480,7 @@ void TonyEngine::FreezeTime(void) { m_nTimeFreezed = GetTime() - m_startTime; } -void TonyEngine::UnfreezeTime(void) -{ +void TonyEngine::UnfreezeTime(void) { m_bTimeFreezed = false; } diff --git a/engines/tony/tony.h b/engines/tony/tony.h index e1526db026..1eafe54afb 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -35,6 +35,7 @@ #include "tony/mpal/memory.h" #include "tony/gfxengine.h" #include "tony/loc.h" +#include "tony/sched.h" #include "tony/utils.h" #include "tony/window.h" @@ -80,6 +81,7 @@ private: void CloseMusic(); bool OpenVoiceDatabase(); void CloseVoiceDatabase(); + void InitCustomFunctionMap(); protected: // Engine APIs virtual Common::Error run(); @@ -93,6 +95,7 @@ public: Common::File _vdbFP; Common::Array _voices; FPSOUND _theSound; + Scheduler _scheduler; enum DATADIR { DD_BASE = 1, @@ -140,9 +143,6 @@ public: // Loop che gestisce i messaggi quando siamo in pausa void PauseLoop(void); - // Carica un modulo e le sue funzioni custom - void InitCustomDll(LPCUSTOMFUNCTION *FuncList); - void Play(); void Close(); void Abort(); diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index a2648318fe..e4f334d0e5 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -224,7 +224,7 @@ void RMTony::ExecuteAction(int nAction, int nActionItem, int nParm) { } } } else { - // Esegue l'azione + // Perform the action hThread = mpalQueryDoAction(nAction, nActionItem, 0); } -- cgit v1.2.3 From 4c8ce3bec99db9d0b63dd65f1c7a89cbe41a679b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 6 May 2012 12:54:57 +1000 Subject: TONY: Implemented Scheduler::waitForSingleObject method This will be the coroutine version of the threading method. With this, the main menu of the demo is now shown. --- engines/tony/mpal/mpal.cpp | 7 ++++--- engines/tony/sched.cpp | 42 +++++++++++++++++++++++++++++++++++++++--- engines/tony/sched.h | 11 +++++++++-- 3 files changed, 52 insertions(+), 8 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 3757cdddcf..78111753ce 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -996,11 +996,12 @@ void ShutUpActionThread(CORO_PARAM, const void *param) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); - HANDLE hThread = *(const HANDLE *)param; + int pid = *(const int *)param; CORO_BEGIN_CODE(_ctx); - WaitForSingleObject(hThread, INFINITE); + CORO_INVOKE_2(_vm->_scheduler.waitForSingleObject, pid, INFINITE); + bExecutingAction = false; CORO_KILL_SELF(); @@ -1554,7 +1555,7 @@ static HANDLE DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { if ((h = g_scheduler->createProcess(ActionThread, newitem)) == NULL) return INVALID_HANDLE_VALUE; - if ((h = g_scheduler->createProcess(0, ShutUpActionThread, &h, sizeof(PROCESS *))) == NULL) + if ((h = g_scheduler->createProcess(ShutUpActionThread, &h->pid, sizeof(int))) == NULL) return INVALID_HANDLE_VALUE; /* diff --git a/engines/tony/sched.cpp b/engines/tony/sched.cpp index 7f259b7a5b..0f397316f6 100644 --- a/engines/tony/sched.cpp +++ b/engines/tony/sched.cpp @@ -21,6 +21,7 @@ * Process scheduler. */ +#include "common/system.h" #include "common/textconsole.h" #include "common/util.h" #include "tony/sched.h" @@ -42,7 +43,8 @@ Scheduler::Scheduler() { maxProcs = 0; #endif - pRCfunction = 0; + pRCfunction = NULL; + pidCounter = 0; active = new PROCESS; active->pPrevious = NULL; @@ -289,6 +291,40 @@ void Scheduler::giveWay(PPROCESS pReSchedProc) { pReSchedProc->pNext = NULL; } +/** + * Continously makes a given process wait for another process to finish + * + * @param pid Process identifier + * @param duration Duration in milliseconds + */ +void Scheduler::waitForSingleObject(CORO_PARAM, int pid, int duration) { + CORO_BEGIN_CONTEXT; + uint32 endTime; + PROCESS *pProc; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + _ctx->endTime = (duration == INFINITE) ? INFINITE : g_system->getMillis() + duration; + + // Outer loop for doing checks until expiry + while (g_system->getMillis() < _ctx->endTime) { + // Check to see if a process with the given Id exists + _ctx->pProc = active->pNext; + while ((_ctx->pProc != NULL) && (_ctx->pProc->pid == pid)) + _ctx->pProc = _ctx->pProc->pNext; + + if (_ctx->pProc == NULL) + // No match process found, so it's okay to break out of loop + break; + + // Sleep until the next cycle + CORO_SLEEP(1); + } + + CORO_END_CODE; +} + /** * Creates a new process. * @@ -297,7 +333,7 @@ void Scheduler::giveWay(PPROCESS pReSchedProc) { * @param pParam process specific info * @param sizeParam size of process specific info */ -PROCESS *Scheduler::createProcess(int pid, CORO_ADDR coroAddr, const void *pParam, int sizeParam) { +PROCESS *Scheduler::createProcess(CORO_ADDR coroAddr, const void *pParam, int sizeParam) { PROCESS *pProc; // get a free process @@ -347,7 +383,7 @@ PROCESS *Scheduler::createProcess(int pid, CORO_ADDR coroAddr, const void *pPara pProc->sleepTime = 1; // set new process id - pProc->pid = pid; + pProc->pid = ++pidCounter; // set new process specific info if (sizeParam) { diff --git a/engines/tony/sched.h b/engines/tony/sched.h index 9bc6d052da..cffa0f9328 100644 --- a/engines/tony/sched.h +++ b/engines/tony/sched.h @@ -35,6 +35,8 @@ namespace Tony { #define NUM_PROCESS 100 #define MAX_PROCESSES 100 +#define INFINITE 0xffffffff + typedef void (*CORO_ADDR)(CoroContext &, const void *); /** process structure */ @@ -75,6 +77,10 @@ private: /** the currently active process */ PROCESS *pCurrent; + /** Auto-incrementing process Id */ + int pidCounter; + + #ifdef DEBUG // diagnostic process counters int numProcs; @@ -105,10 +111,11 @@ public: void rescheduleAll(); void reschedule(PPROCESS pReSchedProc = NULL); void giveWay(PPROCESS pReSchedProc = NULL); + void waitForSingleObject(CORO_PARAM, int pid, int duration); - PROCESS *createProcess(int pid, CORO_ADDR coroAddr, const void *pParam, int sizeParam); + PROCESS *createProcess(CORO_ADDR coroAddr, const void *pParam, int sizeParam); PROCESS *createProcess(CORO_ADDR coroAddr, const void *pParam) { - return createProcess(0, coroAddr, &pParam, sizeof(void *)); + return createProcess(coroAddr, &pParam, sizeof(void *)); } void killProcess(PROCESS *pKillProc); -- cgit v1.2.3 From 20a47ff7c9bba866ccfb0df232de58c9cc8d6880 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 6 May 2012 12:55:20 +1000 Subject: TONY: Default Tony screen to 1x scaler --- engines/tony/window.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index 36278a4f05..8ac36a5693 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -73,7 +73,7 @@ RMWindow::~RMWindow() { */ void RMWindow::Init() { Graphics::PixelFormat pixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0); - initGraphics(RM_SX, RM_SY, false, &pixelFormat); + initGraphics(RM_SX, RM_SY, true, &pixelFormat); // Inizializza i conteggi degli FPS fps = lastfcount = fcount = lastsecond = 0; -- cgit v1.2.3 From 770e55d06578f7f51959ea331da7baaaaa0e360d Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 6 May 2012 15:18:03 +1000 Subject: TONY: Further conversion of initially launched threads to processes. This includes all the dependent routines that they call. --- engines/tony/adv.h | 3 +- engines/tony/custom.cpp | 61 ++++++--- engines/tony/game.cpp | 4 +- engines/tony/gfxengine.cpp | 37 ++++-- engines/tony/gfxengine.h | 2 +- engines/tony/mpal/mpal.cpp | 310 ++++++++++++++++++++++++--------------------- engines/tony/mpal/mpal.h | 3 +- engines/tony/sched.cpp | 19 ++- engines/tony/sched.h | 8 +- engines/tony/tonychar.cpp | 32 +++-- engines/tony/tonychar.h | 5 +- 11 files changed, 284 insertions(+), 200 deletions(-) (limited to 'engines') diff --git a/engines/tony/adv.h b/engines/tony/adv.h index 6d675c2bbe..056934e932 100644 --- a/engines/tony/adv.h +++ b/engines/tony/adv.h @@ -49,6 +49,7 @@ #define TONY_ADV_H #include "tony/mpal/memory.h" +#include "tony/coroutine.h" #include "tony/gfxcore.h" @@ -91,7 +92,7 @@ enum RMTonyAction { // Funzioni globali HANDLE MainLoadLocation(int nLoc, RMPoint pt, RMPoint start); -HANDLE MainUnloadLocation(bool bDoOnExit); +void MainUnloadLocation(CORO_PARAM, bool bDoOnExit, HANDLE *result); void MainLinkGraphicTask(RMGfxTask *task); void MainFreeze(void); void MainUnfreeze(void); diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 1d28fa9ece..2683634012 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -72,7 +72,7 @@ RMInventory *Inventory; RMInput *Input; HANDLE (*LoadLocation)(int, RMPoint, RMPoint start); -HANDLE (*UnloadLocation)(bool bDoOnExit); +void (*UnloadLocation)(CORO_PARAM, bool bDoOnExit, HANDLE *result); void (*LinkGraphicTask)(RMGfxTask *task); void (*Freeze)(void); void (*Unfreeze)(void); @@ -505,20 +505,27 @@ RMPoint SFM_pt; int SFM_nLoc; DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgStart)(CORO_PARAM, uint32 nMsg, uint32 nFont, uint32, uint32) { - RMMessage msg(nMsg); - RMGfxClearTask clear; - int i; + CORO_BEGIN_CONTEXT; + RMMessage *msg; + RMGfxClearTask clear; + int i; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + _ctx->msg = new RMMessage(nMsg); SFM_nLoc = Loc->TEMPGetNumLoc(); SFM_pt = Tony->Position(); - if (bSkipIdle) return; + if (bSkipIdle) + return; - UnloadLocation(false); + CORO_INVOKE_2(UnloadLocation, false, NULL); Tony->Hide(); Unfreeze(); - for (i = 0; i < msg.NumPeriods() && !bSkipIdle; i++) { + for (_ctx->i = 0; _ctx->i < _ctx->msg->NumPeriods() && !bSkipIdle; _ctx->i++) { RMTextDialog text; text.SetInput(Input); @@ -533,25 +540,29 @@ DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgStart)(CORO_PARAM, uint32 nMsg, uint32 text.SetColor(255,255,255); // Scrive il testo - if (nFont== 0) - text.WriteText(msg[i],1); - else if (nFont==1) - text.WriteText(msg[i],0); + if (nFont == 0) + text.WriteText((*_ctx->msg)[_ctx->i], 1); + else if (nFont == 1) + text.WriteText((*_ctx->msg)[_ctx->i], 0); // Setta la posizione - text.SetPosition(RMPoint(320,240)); + text.SetPosition(RMPoint(320, 240)); text.SetAlwaysDisplay(); text.ForceTime(); // Registra il testo - LinkGraphicTask(&clear); + LinkGraphicTask(&_ctx->clear); LinkGraphicTask(&text); // Aspetta la fine della visualizzazione text.SetCustomSkipHandle(hSkipIdle); text.WaitForEndDisplay(); } + + delete _ctx->msg; + + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(ClearScreen)(CORO_PARAM, uint32, uint32, uint32, uint32) { @@ -592,6 +603,11 @@ DECLARE_CUSTOM_FUNCTION(NoOcchioDiBue)(CORO_PARAM, uint32, uint32, uint32, uint3 } DECLARE_CUSTOM_FUNCTION(CloseLocation)(CORO_PARAM, uint32, uint32, uint32, uint32) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + if (!bNoOcchioDiBue) { InitWipe(1); WaitWipeEnd(); @@ -600,13 +616,19 @@ DECLARE_CUSTOM_FUNCTION(CloseLocation)(CORO_PARAM, uint32, uint32, uint32, uint3 _vm->StopMusic(4); // On Exit e lascia freezzato - UnloadLocation(true); + CORO_INVOKE_2(UnloadLocation, true, NULL); Unfreeze(); + + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint32 tY, uint32 bUseStartPos) { - HANDLE h; + CORO_BEGIN_CONTEXT; + HANDLE h; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); if (!bNoOcchioDiBue) { InitWipe(1); @@ -618,7 +640,7 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint } // On Exit e lascia freezzato - UnloadLocation(true); + CORO_INVOKE_2(UnloadLocation, true, NULL); curChangedHotspot = 0; if (bUseStartPos != 0) @@ -639,7 +661,7 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint Unfreeze(); - h = mpalQueryDoAction(0, nLoc,0); + _ctx->h = mpalQueryDoAction(0, nLoc, 0); if (!bNoOcchioDiBue) { WaitWipeEnd(); @@ -649,9 +671,10 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint bNoOcchioDiBue = false; // On Enter? - if (h != INVALID_HANDLE_VALUE) - WaitForSingleObject(h,INFINITE); + if (_ctx->h != INVALID_HANDLE_VALUE) + WaitForSingleObject(_ctx->h, INFINITE); + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(SetLocStartPosition)(CORO_PARAM, uint32 nLoc, uint32 lX, uint32 lY, uint32) { diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 03cc80d93d..4eef8b0c96 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -96,8 +96,8 @@ HANDLE MainLoadLocation(int nLoc, RMPoint pt, RMPoint start) { return _vm->GetEngine()->LoadLocation(nLoc, pt,start); } -HANDLE MainUnloadLocation(bool bDoOnExit) { - return _vm->GetEngine()->UnloadLocation(bDoOnExit); +void MainUnloadLocation(CORO_PARAM, bool bDoOnExit, HANDLE *result) { + _vm->GetEngine()->UnloadLocation(coroParam, bDoOnExit, result); } void MainLinkGraphicTask(RMGfxTask *task) { diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index f98942403d..1858221350 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -65,13 +65,21 @@ extern bool bSkipSfxNoLoop; bool bIdleExited; -void ExitAllIdles(int nCurLoc) { +void ExitAllIdles(CORO_PARAM, int nCurLoc) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + // Chiude le idle bSkipSfxNoLoop = true; - mpalEndIdlePoll(nCurLoc); + + CORO_INVOKE_2(mpalEndIdlePoll, nCurLoc, NULL); + bIdleExited = true; bSkipSfxNoLoop = false; - ExitThread(0); + + CORO_END_CODE; } RMGfxEngine::RMGfxEngine() { @@ -514,17 +522,21 @@ HANDLE RMGfxEngine::LoadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { return INVALID_HANDLE_VALUE; //mpalQueryDoAction(0,m_nCurLoc,0); } -HANDLE RMGfxEngine::UnloadLocation(bool bDoOnExit) { - HANDLE h; +void RMGfxEngine::UnloadLocation(CORO_PARAM, bool bDoOnExit, HANDLE *result) { + CORO_BEGIN_CONTEXT; + HANDLE h; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); // Scarica tutta la memoria della locazione - mpalEndIdlePoll(m_nCurLoc); + CORO_INVOKE_2(mpalEndIdlePoll, m_nCurLoc, NULL); // On Exit? if (bDoOnExit) { - h = mpalQueryDoAction(1, m_nCurLoc, 0); - if (h != INVALID_HANDLE_VALUE) - WaitForSingleObject(h, INFINITE); + _ctx->h = mpalQueryDoAction(1, m_nCurLoc, 0); + if (_ctx->h != INVALID_HANDLE_VALUE) + WaitForSingleObject(_ctx->h, INFINITE); } MainFreeze(); @@ -534,7 +546,10 @@ HANDLE RMGfxEngine::UnloadLocation(bool bDoOnExit) { m_bigBuf.ClearOT(); m_loc.Unload(); - return INVALID_HANDLE_VALUE; + if (result != NULL) + *result = INVALID_HANDLE_VALUE; + + CORO_END_CODE; } void RMGfxEngine::Init(/*HINSTANCE hInst*/) { @@ -930,7 +945,7 @@ void RMGfxEngine::LoadState(const char *fn) { delete f; - UnloadLocation(false); + UnloadLocation(nullContext, false, NULL); LoadLocation(loc,tp,RMPoint(-1, -1)); m_tony.SetPattern(RMTony::PAT_STANDRIGHT); MainUnfreeze(); diff --git a/engines/tony/gfxengine.h b/engines/tony/gfxengine.h index 2019cf01c9..42b2050046 100644 --- a/engines/tony/gfxengine.h +++ b/engines/tony/gfxengine.h @@ -138,7 +138,7 @@ public: // Manage a location HANDLE LoadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start); - HANDLE UnloadLocation(bool bDoOnExit=true); + void UnloadLocation(CORO_PARAM, bool bDoOnExit, HANDLE *result); // Freeze and unfreeze void Freeze(void); diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 78111753ce..851de7cb0c 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -138,7 +138,7 @@ bool bExecutingDialog; uint32 nPollingLocations[MAXPOLLINGLOCATIONS]; HANDLE hEndPollingLocations[MAXPOLLINGLOCATIONS]; -HANDLE PollingThreads[MAXPOLLINGLOCATIONS]; +uint32 PollingThreads[MAXPOLLINGLOCATIONS]; HANDLE hAskChoice; HANDLE hDoneChoice; @@ -996,7 +996,7 @@ void ShutUpActionThread(CORO_PARAM, const void *param) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); - int pid = *(const int *)param; + uint32 pid = *(const uint32 *)param; CORO_BEGIN_CODE(_ctx); @@ -1021,17 +1021,7 @@ void ShutUpActionThread(CORO_PARAM, const void *param) { * \****************************************************************************/ -void PASCAL LocationPollThread(uint32 id) { - uint32 *il; - int i,j,k; - int numitems; - int nRealItems; - LPMPALITEM curItem,newItem; - int nIdleActions; - uint32 curTime; - uint32 dwSleepTime; - uint32 dwId; - +void LocationPollThread(CORO_PARAM, const void *param) { typedef struct { uint32 nItem, nAction; @@ -1046,59 +1036,77 @@ void PASCAL LocationPollThread(uint32 id) { typedef struct { uint32 nItem; - HANDLE hThread; + uint32 hThread; } MYTHREAD; - MYACTION *MyActions; - MYTHREAD *MyThreads; + CORO_BEGIN_CONTEXT; + uint32 *il; + int i, j, k; + int numitems; + int nRealItems; + LPMPALITEM curItem,newItem; + int nIdleActions; + uint32 curTime; + uint32 dwSleepTime; + uint32 dwId; + int ord; + bool delayExpired; + + MYACTION *MyActions; + MYTHREAD *MyThreads; + CORO_END_CONTEXT(_ctx); + + uint32 id = *((const uint32 *)param); + + CORO_BEGIN_CODE(_ctx); /* Tanto per cominciare, e' necessario richiedere la lista degli item presenti nella locazione. */ - il = mpalQueryItemList(nPollingLocations[id]); + _ctx->il = mpalQueryItemList(nPollingLocations[id]); /* Contiamo gli items */ - for (numitems = 0; il[numitems] != 0; numitems++) + for (_ctx->numitems = 0; _ctx->il[_ctx->numitems] != 0; _ctx->numitems++) ; /* Cerchiamo gli items della locazione senza idle actions e li eliminiamo dalla lista */ LockItems(); - nIdleActions = 0; - nRealItems = 0; - for (i = 0; i < numitems; i++) { - int ord = itemGetOrderFromNum(il[i]); + _ctx->nIdleActions = 0; + _ctx->nRealItems = 0; + for (_ctx->i = 0; _ctx->i < _ctx->numitems; _ctx->i++) { + _ctx->ord = itemGetOrderFromNum(_ctx->il[_ctx->i]); - if (ord == -1) continue; + if (_ctx->ord == -1) continue; - curItem = lpmiItems + ord; + _ctx->curItem = lpmiItems + _ctx->ord; - k = 0; - for (j = 0; j < curItem->nActions; j++) - if (curItem->Action[j].num == 0xFF) - k++; + _ctx->k = 0; + for (_ctx->j = 0; _ctx->j < _ctx->curItem->nActions; _ctx->j++) + if (_ctx->curItem->Action[_ctx->j].num == 0xFF) + _ctx->k++; - nIdleActions += k; + _ctx->nIdleActions += _ctx->k; - if (k == 0) + if (_ctx->k == 0) /* Possiamo eliminare questo item dalla lista */ - il[i] = (uint32)NULL; + _ctx->il[_ctx->i] = (uint32)NULL; else - nRealItems++; + _ctx->nRealItems++; } UnlockItems(); /* Se non e' rimasto nessuno possiamo uscire */ - if (nRealItems == 0) { - GlobalFree(il); - ExitThread(0); -// _endthread(); + if (_ctx->nRealItems == 0) { + GlobalFree(_ctx->il); + CORO_KILL_SELF(); + return; } - MyThreads=(MYTHREAD *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, nRealItems * sizeof(MYTHREAD)); - if (MyThreads == NULL) { - GlobalFree(il); - ExitThread(0); -// _endthread(); + _ctx->MyThreads = (MYTHREAD *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, _ctx->nRealItems * sizeof(MYTHREAD)); + if (_ctx->MyThreads == NULL) { + GlobalFree(_ctx->il); + CORO_KILL_SELF(); + return; } /* Inizializziamo le routine random */ @@ -1108,142 +1116,147 @@ void PASCAL LocationPollThread(uint32 id) { /* Abbiamo appurato che esiste almeno un item che contiene idle actions. Ora creaiamo le copie speculari delle idle actions */ - MyActions = (MYACTION *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, nIdleActions * sizeof(MYACTION)); - if (MyActions == NULL) { - GlobalFree(MyThreads); - GlobalFree(il); - ExitThread(0); -// _endthread(); + _ctx->MyActions = (MYACTION *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, _ctx->nIdleActions * sizeof(MYACTION)); + if (_ctx->MyActions == NULL) { + GlobalFree(_ctx->MyThreads); + GlobalFree(_ctx->il); + CORO_KILL_SELF(); + return; } LockItems(); - k = 0; + _ctx->k = 0; - for (i = 0; i < numitems; i++) { - if (il[i] == 0) + for (_ctx->i = 0; _ctx->i < _ctx->numitems; _ctx->i++) { + if (_ctx->il[_ctx->i] == 0) continue; - curItem = lpmiItems + itemGetOrderFromNum(il[i]); + _ctx->curItem = lpmiItems + itemGetOrderFromNum(_ctx->il[_ctx->i]); - for (j = 0; j < curItem->nActions; j++) - if (curItem->Action[j].num == 0xFF) { - MyActions[k].nItem = il[i]; - MyActions[k].nAction = j; + for (_ctx->j = 0; _ctx->j < _ctx->curItem->nActions; _ctx->j++) + if (_ctx->curItem->Action[_ctx->j].num == 0xFF) { + _ctx->MyActions[_ctx->k].nItem = _ctx->il[_ctx->i]; + _ctx->MyActions[_ctx->k].nAction = _ctx->j; - MyActions[k].wTime = curItem->Action[j].wTime; - MyActions[k].perc = curItem->Action[j].perc; - MyActions[k].when = curItem->Action[j].when; - MyActions[k].nCmds = curItem->Action[j].nCmds; - CopyMemory(MyActions[k].CmdNum, curItem->Action[j].CmdNum, + _ctx->MyActions[_ctx->k].wTime = _ctx->curItem->Action[_ctx->j].wTime; + _ctx->MyActions[_ctx->k].perc = _ctx->curItem->Action[_ctx->j].perc; + _ctx->MyActions[_ctx->k].when = _ctx->curItem->Action[_ctx->j].when; + _ctx->MyActions[_ctx->k].nCmds = _ctx->curItem->Action[_ctx->j].nCmds; + CopyMemory(_ctx->MyActions[_ctx->k].CmdNum, _ctx->curItem->Action[_ctx->j].CmdNum, MAX_COMMANDS_PER_ACTION * sizeof(uint16)); - MyActions[k].dwLastTime = timeGetTime(); - k++; + _ctx->MyActions[_ctx->k].dwLastTime = timeGetTime(); + _ctx->k++; } } UnlockItems(); /* La item list non ci serve piu' */ - GlobalFree(il); + GlobalFree(_ctx->il); /* Eccoci al ciclo principale. */ while (1) { /* Cerchiamo tra tutte le idle actions quella a cui manca meno tempo per l'esecuzione */ - curTime = timeGetTime(); - dwSleepTime=(uint32) - 1L; + _ctx->curTime = timeGetTime(); + _ctx->dwSleepTime = (uint32)-1L; - for (k = 0;k= MyActions[k].dwLastTime + MyActions[k].wTime) { - dwSleepTime = 0; + for (_ctx->k = 0;_ctx->k<_ctx->nIdleActions;_ctx->k++) + if (_ctx->curTime >= _ctx->MyActions[_ctx->k].dwLastTime + _ctx->MyActions[_ctx->k].wTime) { + _ctx->dwSleepTime = 0; break; } else - dwSleepTime = MIN(dwSleepTime,MyActions[k].dwLastTime+MyActions[k].wTime-curTime); + _ctx->dwSleepTime = MIN(_ctx->dwSleepTime, _ctx->MyActions[_ctx->k].dwLastTime + _ctx->MyActions[_ctx->k].wTime - _ctx->curTime); /* Ci addormentiamo, ma controllando sempre l'evento che viene settato quando viene richiesta la nostra chiusura */ - k = WaitForSingleObject(hEndPollingLocations[id], dwSleepTime); - if (k == WAIT_OBJECT_0) + _ctx->k = WaitForSingleObject(hEndPollingLocations[id], _ctx->dwSleepTime); + if (_ctx->k == WAIT_OBJECT_0) break; - for (i = 0; i < nRealItems; i++) - if (MyThreads[i].nItem != 0) { - if (WaitForSingleObject(MyThreads[i].hThread, 0) == WAIT_OBJECT_0) - MyThreads[i].nItem = 0; + for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) + if (_ctx->MyThreads[_ctx->i].nItem != 0) { + CORO_INVOKE_3(_vm->_scheduler.waitForSingleObject, _ctx->MyThreads[_ctx->i].hThread, 0, &_ctx->delayExpired); + + // if result ) == WAIT_OBJECT_0) + if (!_ctx->delayExpired) + _ctx->MyThreads[_ctx->i].nItem = 0; } - curTime = timeGetTime(); + _ctx->curTime = timeGetTime(); /* Cerchiamo all'interno delle idle actions quale e' necessario eseguire */ - for (k = 0; k < nIdleActions; k++) - if (curTime >= MyActions[k].dwLastTime + MyActions[k].wTime) { - MyActions[k].dwLastTime += MyActions[k].wTime; + for (_ctx->k = 0; _ctx->k < _ctx->nIdleActions; _ctx->k++) + if (_ctx->curTime >= _ctx->MyActions[_ctx->k].dwLastTime + _ctx->MyActions[_ctx->k].wTime) { + _ctx->MyActions[_ctx->k].dwLastTime += _ctx->MyActions[_ctx->k].wTime; - /* E' il momento di tirare il nostro dado virtuale, e controllare + /* E' _ctx->il momento di tirare _ctx->il nostro dado virtuale, e controllare se la sorte e' dalla parte della idle action */ byte randomVal = (byte)_vm->_randomSource.getRandomNumber(99); - if (randomVal < MyActions[k].perc) { + if (randomVal < _ctx->MyActions[_ctx->k].perc) { /* Controlliamo se c'e' una action in esecuzione sull'item */ - if ((bExecutingAction) && (nExecutingAction == MyActions[k].nItem)) + if ((bExecutingAction) && (nExecutingAction == _ctx->MyActions[_ctx->k].nItem)) continue; /* Controlliamo se c'e' gia' un'altra idle function in esecuzione sullo stesso item */ - for (i = 0; i < nRealItems; i++) - if (MyThreads[i].nItem == MyActions[k].nItem) + for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) + if (_ctx->MyThreads[_ctx->i].nItem == _ctx->MyActions[_ctx->k].nItem) break; - if (i < nRealItems) + if (_ctx->i < _ctx->nRealItems) continue; /* Ok, siamo gli unici :) */ LockItems(); - curItem=lpmiItems+itemGetOrderFromNum(MyActions[k].nItem); + _ctx->curItem=lpmiItems+itemGetOrderFromNum(_ctx->MyActions[_ctx->k].nItem); /* Controlliamo se c'e' un esperessione WhenExecute */ - j=MyActions[k].nAction; - if (curItem->Action[j].when != NULL) - if (!EvaluateExpression(curItem->Action[j].when)) { + _ctx->j=_ctx->MyActions[_ctx->k].nAction; + if (_ctx->curItem->Action[_ctx->j].when != NULL) + if (!EvaluateExpression(_ctx->curItem->Action[_ctx->j].when)) { UnlockItems(); continue; } /* Ok, possiamo eseguire la azione. Per comodita' lo facciamo in un nuovo thread */ - newItem=(LPMPALITEM)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MPALITEM)); - if (newItem == false) { - GlobalFree(MyThreads); - GlobalFree(MyActions); - ExitThread(0); -// _endthread(); + _ctx->newItem = (LPMPALITEM)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MPALITEM)); + if (_ctx->newItem == false) { + GlobalFree(_ctx->MyThreads); + GlobalFree(_ctx->MyActions); + + CORO_KILL_SELF(); + return; } - CopyMemory(newItem,curItem, sizeof(MPALITEM)); + CopyMemory(_ctx->newItem,_ctx->curItem, sizeof(MPALITEM)); UnlockItems(); /* Copiamo l'azione nella #0 */ -// newItem->Action[0].nCmds = curItem->Action[j].nCmds; -// CopyMemory(newItem->Action[0].CmdNum,curItem->Action[j].CmdNum,newItem->Action[0].nCmds*sizeof(newItem->Action[0].CmdNum[0])); - newItem->dwRes=j; +// _ctx->newItem->Action[0].nCmds = _ctx->curItem->Action[_ctx->j].nCmds; +// CopyMemory(_ctx->newItem->Action[0].CmdNum,_ctx->curItem->Action[_ctx->j].CmdNum,_ctx->newItem->Action[0].nCmds*sizeof(_ctx->newItem->Action[0].CmdNum[0])); + _ctx->newItem->dwRes=_ctx->j; /* Creaiamo l'action thread. Provvedera' lui a liberare la memoria - allocata per il nuovo item */ - for (i = 0; i < nRealItems; i++) - if (MyThreads[i].nItem == 0) + allocata per _ctx->il nuovo item */ + for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) + if (_ctx->MyThreads[_ctx->i].nItem == 0) break; - MyThreads[i].nItem=MyActions[k].nItem; + _ctx->MyThreads[_ctx->i].nItem = _ctx->MyActions[_ctx->k].nItem; // !!! Nuova gestione dei thread - if ((MyThreads[i].hThread = CreateThread(NULL, 10240, (LPTHREAD_START_ROUTINE)ActionThread,(void *)newItem, 0, &dwId)) == NULL) { - //if ((MyThreads[i].hThread=(void*)_beginthread(ActionThread, 10240,(void *)newItem))==(void*)-1) - GlobalFree(newItem); - GlobalFree(MyThreads); - GlobalFree(MyActions); - ExitThread(0); -// _endthread(); + if ((_ctx->MyThreads[_ctx->i].hThread = _vm->_scheduler.createProcess(ActionThread, &_ctx->newItem, sizeof(LPMPALITEM))) == 0) { + //if ((_ctx->MyThreads[_ctx->i].hThread=(void*)_beginthread(ActionThread, 10240,(void *)_ctx->newItem))==(void*)-1) + GlobalFree(_ctx->newItem); + GlobalFree(_ctx->MyThreads); + GlobalFree(_ctx->MyActions); + + CORO_KILL_SELF(); + return; } /* Skippa tutte le idle action dello stesso item */ @@ -1251,16 +1264,16 @@ void PASCAL LocationPollThread(uint32 id) { } } - /* Chiude tutti i thread interni */ + /* Chiude tutti _ctx->i thread interni */ /* CODICE OBSOLETO: ANDIAMO DI SKIP CHE RULLA - for (i = 0; i < nRealItems; i++) - if (MyThreads[i].nItem != 0) { - TerminateThread(MyThreads[i].hThread, 0); - CloseHandle(MyThreads[i].hThread); + for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) + if (_ctx->MyThreads[_ctx->i].nItem != 0) { + TerminateThread(_ctx->MyThreads[_ctx->i].hThread, 0); + CloseHandle(_ctx->MyThreads[_ctx->i].hThread); } */ @@ -1268,23 +1281,28 @@ void PASCAL LocationPollThread(uint32 id) { // FIXME: Convert to co-routine lplpFunctions[200](nullContext, 0, 0, 0, 0); - for (i = 0; i < nRealItems; i++) - if (MyThreads[i].nItem != 0) { - if (WaitForSingleObject(MyThreads[i].hThread,5000) != WAIT_OBJECT_0) - TerminateThread(MyThreads[i].hThread, 0); + for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) + if (_ctx->MyThreads[_ctx->i].nItem != 0) { + CORO_INVOKE_3(_vm->_scheduler.waitForSingleObject, _ctx->MyThreads[_ctx->i].hThread, 5000, &_ctx->delayExpired); - CloseHandle(MyThreads[i].hThread); +/* + //if (result != WAIT_OBJECT_0) + if (_ctx->delayExpired) + TerminateThread(_ctx->MyThreads[_ctx->i].hThread, 0); +*/ + _vm->_scheduler.killMatchingProcess(_ctx->MyThreads[_ctx->i].hThread); } // Set idle skip off - // FIXME: Convert to co-routine - lplpFunctions[201](nullContext, 0, 0, 0, 0); + CORO_INVOKE_4(lplpFunctions[201], 0, 0, 0, 0); /* Abbiamo finito */ - GlobalFree(MyThreads); - GlobalFree(MyActions); - ExitThread(1); -//endthread(); + GlobalFree(_ctx->MyThreads); + GlobalFree(_ctx->MyActions); + + CORO_KILL_SELF(); + + CORO_END_CODE; } @@ -1516,7 +1534,7 @@ static HANDLE DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { LPMPALITEM item = lpmiItems; int i; LPMPALITEM newitem; - PROCESS *h; + uint32 h; item+=ordItem; Common::String buf = Common::String::format("Status.%u", item->nObj); @@ -1552,10 +1570,10 @@ static HANDLE DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { // 0 dell'item, e poi liberera' la memoria con la GlobalFree() // !!! New thread management - if ((h = g_scheduler->createProcess(ActionThread, newitem)) == NULL) + if ((h = g_scheduler->createProcess(ActionThread, &newitem, sizeof(LPMPALITEM))) == NULL) return INVALID_HANDLE_VALUE; - if ((h = g_scheduler->createProcess(ShutUpActionThread, &h->pid, sizeof(int))) == NULL) + if ((h = g_scheduler->createProcess(ShutUpActionThread, &h, sizeof(uint32))) == NULL) return INVALID_HANDLE_VALUE; /* @@ -2182,7 +2200,7 @@ void EXPORT mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCus) { * \****************************************************************************/ -bool EXPORT mpalStartIdlePoll(int nLoc) { +bool mpalStartIdlePoll(int nLoc) { uint32 i; uint32 dwId; @@ -2196,7 +2214,7 @@ bool EXPORT mpalStartIdlePoll(int nLoc) { hEndPollingLocations[i] = CreateEvent(NULL, true, false, NULL); // !!! Nuova gestione dei thread - if ((PollingThreads[i] = CreateThread(NULL, 10240, (LPTHREAD_START_ROUTINE)LocationPollThread,(void *)i, 0, &dwId)) == NULL) + if ((PollingThreads[i] = _vm->_scheduler.createProcess(LocationPollThread, &i, sizeof(uint32))) == 0) // if ((hEndPollingLocations[i]=(void*)_beginthread(LocationPollThread, 10240,(void *)i))==(void*)-1) return false; @@ -2222,22 +2240,32 @@ bool EXPORT mpalStartIdlePoll(int nLoc) { * \****************************************************************************/ -bool EXPORT mpalEndIdlePoll(int nLoc) { - uint32 i; +void mpalEndIdlePoll(CORO_PARAM, int nLoc, bool *result) { + CORO_BEGIN_CONTEXT; + int i; + CORO_END_CONTEXT(_ctx); - for (i = 0; i < MAXPOLLINGLOCATIONS; i++) - if (nPollingLocations[i] == (uint32)nLoc) { - SetEvent(hEndPollingLocations[i]); + CORO_BEGIN_CODE(_ctx); + + for (_ctx->i = 0; _ctx->i < MAXPOLLINGLOCATIONS; _ctx->i++) { + if (nPollingLocations[_ctx->i] == (uint32)nLoc) { + SetEvent(hEndPollingLocations[_ctx->i]); - WaitForSingleObject(PollingThreads[i], INFINITE); + CORO_INVOKE_2(_vm->_scheduler.waitForSingleObject, PollingThreads[_ctx->i], INFINITE); - CloseHandle(hEndPollingLocations[i]); - nPollingLocations[i] = 0; + CloseHandle(hEndPollingLocations[_ctx->i]); + nPollingLocations[_ctx->i] = 0; - return true; + if (result) + *result = true; + return; + } } - return false; + if (result) + *result = false; + + CORO_END_CODE; } diff --git a/engines/tony/mpal/mpal.h b/engines/tony/mpal/mpal.h index 3c2e62d992..9da963d39e 100644 --- a/engines/tony/mpal/mpal.h +++ b/engines/tony/mpal/mpal.h @@ -704,8 +704,7 @@ bool EXPORT mpalStartIdlePoll(int nLoc); * \****************************************************************************/ -bool EXPORT mpalEndIdlePoll(int nLoc); - +void mpalEndIdlePoll(CORO_PARAM, int nLoc, bool *result); /****************************************************************************\ diff --git a/engines/tony/sched.cpp b/engines/tony/sched.cpp index 0f397316f6..421f4d1ac7 100644 --- a/engines/tony/sched.cpp +++ b/engines/tony/sched.cpp @@ -294,10 +294,11 @@ void Scheduler::giveWay(PPROCESS pReSchedProc) { /** * Continously makes a given process wait for another process to finish * - * @param pid Process identifier - * @param duration Duration in milliseconds + * @param pid Process identifier + * @param duration Duration in milliseconds + * @param expired Set to true if delay period expired */ -void Scheduler::waitForSingleObject(CORO_PARAM, int pid, int duration) { +void Scheduler::waitForSingleObject(CORO_PARAM, int pid, int duration, bool *expired) { CORO_BEGIN_CONTEXT; uint32 endTime; PROCESS *pProc; @@ -306,6 +307,8 @@ void Scheduler::waitForSingleObject(CORO_PARAM, int pid, int duration) { CORO_BEGIN_CODE(_ctx); _ctx->endTime = (duration == INFINITE) ? INFINITE : g_system->getMillis() + duration; + if (expired) + *expired = false; // Outer loop for doing checks until expiry while (g_system->getMillis() < _ctx->endTime) { @@ -314,9 +317,13 @@ void Scheduler::waitForSingleObject(CORO_PARAM, int pid, int duration) { while ((_ctx->pProc != NULL) && (_ctx->pProc->pid == pid)) _ctx->pProc = _ctx->pProc->pNext; - if (_ctx->pProc == NULL) + if (_ctx->pProc == NULL) { // No match process found, so it's okay to break out of loop + if (expired) + *expired = true; + break; + } // Sleep until the next cycle CORO_SLEEP(1); @@ -333,7 +340,7 @@ void Scheduler::waitForSingleObject(CORO_PARAM, int pid, int duration) { * @param pParam process specific info * @param sizeParam size of process specific info */ -PROCESS *Scheduler::createProcess(CORO_ADDR coroAddr, const void *pParam, int sizeParam) { +uint32 Scheduler::createProcess(CORO_ADDR coroAddr, const void *pParam, int sizeParam) { PROCESS *pProc; // get a free process @@ -394,7 +401,7 @@ PROCESS *Scheduler::createProcess(CORO_ADDR coroAddr, const void *pParam, int si } // return created process - return pProc; + return pProc->pid; } /** diff --git a/engines/tony/sched.h b/engines/tony/sched.h index cffa0f9328..54f44aa5fd 100644 --- a/engines/tony/sched.h +++ b/engines/tony/sched.h @@ -41,7 +41,7 @@ typedef void (*CORO_ADDR)(CoroContext &, const void *); /** process structure */ struct PROCESS { - PROCESS *pNext; ///< pointer to next process in active or free list + PROCESS *pNext; ///< pointer to next process in active or free list PROCESS *pPrevious; ///< pointer to previous process in active or free list CoroContext state; ///< the state of the coroutine @@ -111,10 +111,10 @@ public: void rescheduleAll(); void reschedule(PPROCESS pReSchedProc = NULL); void giveWay(PPROCESS pReSchedProc = NULL); - void waitForSingleObject(CORO_PARAM, int pid, int duration); + void waitForSingleObject(CORO_PARAM, int pid, int duration, bool *delay = NULL); - PROCESS *createProcess(CORO_ADDR coroAddr, const void *pParam, int sizeParam); - PROCESS *createProcess(CORO_ADDR coroAddr, const void *pParam) { + uint32 createProcess(CORO_ADDR coroAddr, const void *pParam, int sizeParam); + uint32 createProcess(CORO_ADDR coroAddr, const void *pParam) { return createProcess(coroAddr, &pParam, sizeof(void *)); } void killProcess(PROCESS *pKillProc); diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index e4f334d0e5..de6189876b 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -59,11 +59,19 @@ namespace Tony { bool RMTony::m_bAction = false; -uint32 RMTony::WaitEndOfAction(HANDLE hThread) { - WaitForSingleObject(hThread, INFINITE); +void RMTony::WaitEndOfAction(CORO_PARAM, const void *param) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + uint32 pid = *(const uint32 *)param; + + CORO_BEGIN_CODE(_ctx); + + CORO_INVOKE_2(_vm->_scheduler.waitForSingleObject, pid, INFINITE); + m_bAction = false; - return 1; + CORO_END_CODE; } RMGfxSourceBuffer *RMTony::NewItemSpriteBuffer(int dimx, int dimy, bool bPreRLE) { @@ -205,6 +213,7 @@ void RMTony::MoveAndDoAction(RMPoint dst, RMItem *item, int nAction, int nAction void RMTony::ExecuteAction(int nAction, int nActionItem, int nParm) { HANDLE hThread; + uint32 pid; if (nAction == TA_COMBINE) { hThread = mpalQueryDoAction(TA_COMBINE, nParm, nActionItem); @@ -229,27 +238,28 @@ void RMTony::ExecuteAction(int nAction, int nActionItem, int nParm) { } if (hThread != INVALID_HANDLE_VALUE) { - uint32 id; m_bAction = true; - CreateThread(NULL, 10240,(LPTHREAD_START_ROUTINE)WaitEndOfAction, (void *)hThread, 0, &id); + pid = (uint32)hThread; + _vm->_scheduler.createProcess(WaitEndOfAction, &pid, sizeof(uint32)); hActionThread = hThread; } else if (nAction != TA_GOTO) { - uint32 id; - if (nAction == TA_TALK) { hThread = mpalQueryDoAction(6, 1, 0); m_bAction = true; - CreateThread(NULL,10240,(LPTHREAD_START_ROUTINE)WaitEndOfAction, (void *)hThread,0,&id); - hActionThread=hThread; + pid = (uint32)hThread; + _vm->_scheduler.createProcess(WaitEndOfAction, &pid, sizeof(uint32)); + hActionThread = hThread; } else if (nAction == TA_PALESATI) { hThread = mpalQueryDoAction(7, 1, 0); m_bAction = true; - CreateThread(NULL,10240,(LPTHREAD_START_ROUTINE)WaitEndOfAction,(void *)hThread, 0, &id); + pid = (uint32)hThread; + _vm->_scheduler.createProcess(WaitEndOfAction, &pid, sizeof(uint32)); hActionThread=hThread; } else { hThread = mpalQueryDoAction(5, 1, 0); m_bAction = true; - CreateThread(NULL, 10240, (LPTHREAD_START_ROUTINE)WaitEndOfAction, (void *)hThread, 0, &id); + pid = (uint32)hThread; + _vm->_scheduler.createProcess(WaitEndOfAction, &pid, sizeof(uint32)); hActionThread = hThread; } } diff --git a/engines/tony/tonychar.h b/engines/tony/tonychar.h index 9806fd5e58..266b34e697 100644 --- a/engines/tony/tonychar.h +++ b/engines/tony/tonychar.h @@ -49,6 +49,7 @@ #define TONY_TONYCHAR_H #include "tony/mpal/stubs.h" +#include "tony/coroutine.h" #include "tony/loc.h" namespace Tony { @@ -128,8 +129,8 @@ protected: // Overload dell'allocazione degli sprites per cambiare il tipo virtual RMGfxSourceBuffer* NewItemSpriteBuffer(int dimx, int dimy, bool bPreRLE); - // Thread che aspetta la fine di un azione - static uint32 WaitEndOfAction(HANDLE hThread); + // Thread which waits for the end of an action + static void WaitEndOfAction(CORO_PARAM, const void *param); public: // per farlo rialzare, altrimenti private enum PATTERNS { -- cgit v1.2.3 From 8bfc60f5c9bdba4b1f37fcf42df4b0aa360c325f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 6 May 2012 16:39:42 +1000 Subject: TONY: Refactored RMInput class to use ScummVM event loop --- engines/tony/gfxengine.cpp | 2 - engines/tony/input.cpp | 254 ++++++++------------------------------------- engines/tony/input.h | 37 +++---- engines/tony/mpal/mpal.cpp | 1 - engines/tony/tony.cpp | 4 - 5 files changed, 55 insertions(+), 243 deletions(-) (limited to 'engines') diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 1858221350..acf6339e73 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -660,11 +660,9 @@ void RMGfxEngine::Close(void) { } void RMGfxEngine::SwitchFullscreen(bool bFull) { - m_input.SwitchFullscreen(bFull); } void RMGfxEngine::GDIControl(bool bCon) { - m_input.GDIControl(bCon); } void RMGfxEngine::EnableInput(void) { diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp index 09b15fa127..b6793695f3 100644 --- a/engines/tony/input.cpp +++ b/engines/tony/input.cpp @@ -51,238 +51,68 @@ namespace Tony { #define DIRELEASE(x) if (x) { (x)->Release(); (x)=NULL; } -void RMInput::DIInit(/*HINSTANCE hInst*/) { -#ifdef REFACTOR_ME - HRESULT err; - - // Crea l'oggetto madre - err = DirectInputCreate(hInst, DIRECTINPUT_VERSION, &m_DI, NULL); - if (err!=DI_OK) { - MessageBox(theGame.m_wnd,"Error initializing DirectInput!","RMInput::DIInit()",MB_OK); - assert(0); - } - - // Crea il device del mouse - // ************************ - err=m_DI->CreateDevice(GUID_SysMouse,&m_DIDMouse,NULL); - if (err!=DI_OK) { - MessageBox(theGame.m_wnd,"Error creating mouse device!","RMInput::DIInit()",MB_OK); - assert(0); - } - - // Setta il data format - err=m_DIDMouse->SetDataFormat(&c_dfDIMouse); - if (err!=DI_OK) { - MessageBox(theGame.m_wnd,"Error setting mouse data format!","RMInput::DIInit()",MB_OK); - assert(0); - } - - // Setta il cooperative level - err=m_DIDMouse->SetCooperativeLevel(theGame.m_wnd,DISCL_FOREGROUND|DISCL_NONEXCLUSIVE); - if (err!=DI_OK) { - MessageBox(theGame.m_wnd,"Error setting cooperative level!","RMInput::DIInit()",MB_OK); - assert(0); - } - - // Crea il device della tastiera - // ***************************** - err=m_DI->CreateDevice(GUID_SysKeyboard,&m_DIDKeyboard,NULL); - if (err!=DI_OK) { - MessageBox(theGame.m_wnd,"Error creating keyboard device!","RMInput::DIInit()",MB_OK); - assert(0); - } - - // Setta il data format - err=m_DIDKeyboard->SetDataFormat(&c_dfDIKeyboard); - if (err!=DI_OK) { - MessageBox(theGame.m_wnd,"Error setting keyboard data format!","RMInput::DIInit()",MB_OK); - assert(0); - } - - // Setta il cooperative level - err=m_DIDKeyboard->SetCooperativeLevel(theGame.m_wnd,DISCL_FOREGROUND|DISCL_NONEXCLUSIVE); - if (err!=DI_OK) { - MessageBox(theGame.m_wnd,"Error setting cooperative level!","RMInput::DIInit()",MB_OK); - assert(0); - } -#endif -} - -void RMInput::SwitchFullscreen(bool bFull) { -#ifdef REFACTOR_ME - HRESULT err; - - // Il camping del mouse e' attivo solo in fullscreen - m_bClampMouse=bFull; - - // Prima di tutto leviamo l'acquiring ai device, altrimenti non possiamo cambiare il - // cooperative level - Unacquire(); - - if (bFull) { - // Setta il cooperative level - err=m_DIDMouse->SetCooperativeLevel(theGame.m_wnd,DISCL_FOREGROUND|DISCL_EXCLUSIVE); - if (err!=DI_OK) { - MessageBox(theGame.m_wnd,"Error setting cooperative level!","RMInput::DIInit()",MB_OK); - assert(0); - } - } else { - // Setta il cooperative level - err=m_DIDMouse->SetCooperativeLevel(theGame.m_wnd,DISCL_FOREGROUND|DISCL_EXCLUSIVE); - if (err!=DI_OK) { - MessageBox(theGame.m_wnd,"Error setting cooperative level!","RMInput::DIInit()",MB_OK); - assert(0); - } - } -#endif -} - -void RMInput::DIClose(void) { -#ifdef REFACTOR_ME - DIRELEASE(m_DIDMouse); - DIRELEASE(m_DI); -#endif -} - - -bool RMInput::Acquire(void) { -#ifdef REFACTOR_ME - HRESULT err; - - if (m_DIDMouse == NULL) - return true; - - // Inizializza la posizione del mouse - POINT pt; - RECT rc; - GetWindowRect(theGame.m_wnd,&rc); - GetCursorPos(&pt); - m_mX=pt.x-rc.left-GetSystemMetrics(SM_CXDLGFRAME); - m_mY=pt.y-rc.top-(GetSystemMetrics(SM_CYDLGFRAME)+GetSystemMetrics(SM_CYCAPTION)); - - err=m_DIDMouse->Acquire(); - if (err!=DI_OK) - return false; - - err=m_DIDKeyboard->Acquire(); - if (err!=DI_OK) - return false; -#endif - return true; -} +RMInput::RMInput() { + _clampMouse = false; + _mousePos.Set(0, 0); + _leftButton = _rightButton = false;; -void RMInput::Unacquire(void) { -#ifdef REFACTOR_ME - if (m_DIDMouse!=NULL) - m_DIDMouse->Unacquire(); - - if (m_DIDKeyboard!=NULL) - m_DIDKeyboard->Unacquire(); -#endif + _leftClickMouse = _leftReleaseMouse = false; + _rightClickMouse = _rightReleaseMouse = false; } +RMInput::~RMInput() { -void RMInput::GDIControl(bool bCon) { -#ifdef REFACTOR_ME - if (bCon) { - Unacquire(); - ShowCursor(true); - } else { - ShowCursor(false); - Acquire(); - } -#endif } void RMInput::Poll(void) { -#ifdef REFACTOR_ME - HRESULT err; - bool mLastLeft, mLastRight; - - mLastLeft=MouseLeft(); - mLastRight=MouseRight(); - m_bLeftClickMouse=m_bLeftReleaseMouse=m_bRightClickMouse=m_bRightReleaseMouse=false; - - // Legge lo stato del mouse - while (1) { - ZeroMemory(&m_mState,sizeof(m_mState)); - err=m_DIDMouse->GetDeviceState(sizeof(m_mState),&m_mState); - if (err==DI_OK) + _leftClickMouse = _leftReleaseMouse = _rightClickMouse = _rightReleaseMouse = false; + + // Get pending events + while (g_system->getEventManager()->pollEvent(_event)) { + switch (_event.type) { + case Common::EVENT_MOUSEMOVE: + case Common::EVENT_LBUTTONDOWN: + case Common::EVENT_LBUTTONUP: + case Common::EVENT_RBUTTONDOWN: + case Common::EVENT_RBUTTONUP: + _mousePos.Set(_event.mouse.x, _event.mouse.y); + + if (_event.type == Common::EVENT_LBUTTONDOWN) { + _leftButton = true; + _leftClickMouse = true; + } else if (_event.type == Common::EVENT_LBUTTONUP) { + _leftButton = false; + _leftReleaseMouse = true; + } else if (_event.type == Common::EVENT_RBUTTONDOWN) { + _rightButton = true; + _rightClickMouse = true; + } else if (_event.type == Common::EVENT_RBUTTONDOWN) { + _rightButton = false; + _rightReleaseMouse = true; + } else + continue; + + // Since a mouse button has changed, don't do any further event processing this frame + return; + + default: break; - else if (err==DIERR_INPUTLOST || err==DIERR_NOTACQUIRED) { - ZeroMemory(&m_mState,sizeof(m_mState)); - // Se l'acquire non funziona (ad esempio, quando siamo in background, allora lasciamo perdere - if (!Acquire()) - return; } - else - break; - } - - // Aggiorna le coordinate del mouse - m_mX+=m_mState.lX; - m_mY+=m_mState.lY; - - // Clamp dei valori sui bordi della finestra - if (m_bClampMouse) { - if (m_mX<0) m_mX=0; - if (m_mY<0) m_mY=0; - if (m_mX>=640) m_mX=639; - if (m_mY>=480) m_mY=479; - } - - // Controlla se e' cambiato lo stato dei bottoni - if (mLastLeft && !MouseLeft()) - m_bLeftReleaseMouse=true; - - if (!mLastLeft && MouseLeft()) - m_bLeftClickMouse=true; - - if (mLastRight && !MouseRight()) - m_bRightReleaseMouse=true; - - if (!mLastRight && MouseRight()) - m_bRightClickMouse=true; -#endif + } } - -RMInput::RMInput() { - m_bClampMouse = false; -} - -RMInput::~RMInput() { - -} - -void RMInput::Init(/*HINSTANCE hInst*/) { -#ifdef REFACTOR_ME - DIInit(hInst); -#ifdef STARTFULLSCREEN - SwitchFullscreen(true); -#endif - Acquire(); -#endif +void RMInput::Init() { } void RMInput::Close(void) { - Unacquire(); - DIClose(); } - bool RMInput::MouseLeft() { - return false; -#ifdef REFACTOR_ME - return (m_mState.rgbButtons[0] & 0x80); -#endif + return _leftButton; } bool RMInput::MouseRight() { - return false; -#ifdef REFACTOR_ME - return (m_mState.rgbButtons[1] & 0x80); -#endif + return _rightButton; } } // End of namespace Tony diff --git a/engines/tony/input.h b/engines/tony/input.h index bff6dcd396..dce35141c5 100644 --- a/engines/tony/input.h +++ b/engines/tony/input.h @@ -48,25 +48,23 @@ #ifndef TONY_INPUT_H #define TONY_INPUT_H +#include "common/events.h" #include "tony/utils.h" namespace Tony { class RMInput { private: -// LPDIRECTINPUT m_DI; -// LPDIRECTINPUTDEVICE m_DIDKeyboard, m_DIDMouse; + Common::Event _event; + RMPoint _mousePos; // DIMOUSESTATE m_mState; - int m_mX, m_mY; - bool m_bClampMouse; + bool _clampMouse; + bool _leftButton, _rightButton; - bool m_bLeftClickMouse, m_bLeftReleaseMouse, m_bRightClickMouse, m_bRightReleaseMouse; + bool _leftClickMouse, _leftReleaseMouse, _rightClickMouse, _rightReleaseMouse; private: - // Inizializza DirectInput - void DIInit(/*uint32 hInst*/); - // Deinizializza DirectInput void DIClose(void); @@ -83,29 +81,20 @@ public: // Polling (must be performed once per frame) void Poll(void); - // Aquire the DirectInput device - bool Acquire(void); - - // Deacquires the device - void Unacquire(void); - // Reading of the mouse - RMPoint MousePos() { return RMPoint(m_mX, m_mY); } + RMPoint MousePos() { return _mousePos; } // Current status of the mouse buttons bool MouseLeft(); bool MouseRight(); // Events of mouse clicks - bool MouseLeftClicked() { return m_bLeftClickMouse; } - bool MouseRightClicked() { return m_bRightClickMouse; } - bool MouseBothClicked() { return m_bLeftClickMouse&&m_bRightClickMouse; } - bool MouseLeftReleased() { return m_bLeftReleaseMouse; } - bool MouseRightReleased() { return m_bRightReleaseMouse; } - bool MouseBothReleased() { return m_bLeftReleaseMouse&&m_bRightReleaseMouse; } - - // Warns when changing from full screen to windowed - void SwitchFullscreen(bool bFull); + bool MouseLeftClicked() { return _leftClickMouse; } + bool MouseRightClicked() { return _rightClickMouse; } + bool MouseBothClicked() { return _leftClickMouse && _rightClickMouse; } + bool MouseLeftReleased() { return _leftReleaseMouse; } + bool MouseRightReleased() { return _rightReleaseMouse; } + bool MouseBothReleased() { return _leftReleaseMouse && _rightReleaseMouse; } // Warns when we are in the GDI loop void GDIControl(bool bCon); diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 851de7cb0c..9000693292 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -2202,7 +2202,6 @@ void EXPORT mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCus) { bool mpalStartIdlePoll(int nLoc) { uint32 i; - uint32 dwId; for (i = 0; i < MAXPOLLINGLOCATIONS; i++) if (nPollingLocations[i] == (uint32)nLoc) diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index ab6592342d..01d0cf9add 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -390,10 +390,6 @@ void TonyEngine::Play(void) { g_system->delayMillis(50); - Common::Event evt; - while (g_system->getEventManager()->pollEvent(evt)) - ; - // Call any scheduled processes _scheduler.schedule(); -- cgit v1.2.3 From 156d8cdb733fe03688da9e2e9844b722681bed7f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 6 May 2012 21:24:55 +1000 Subject: TONY: Bugfix for waitForSingleObject, and added action process debug information --- engines/tony/custom.cpp | 14 +++++++------- engines/tony/custom.h | 16 +++++++++------- engines/tony/mpal/mpal.cpp | 18 ++++++++++++++++-- engines/tony/mpal/mpal.h | 3 ++- engines/tony/sched.cpp | 2 +- engines/tony/tony.cpp | 10 ++++++++-- engines/tony/tony.h | 1 + 7 files changed, 44 insertions(+), 20 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 2683634012..dadc84e606 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -1680,7 +1680,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes // Cerca di eseguire la funzione custom per chiudere la parlata if (MCharacter[nChar].item) { - h=mpalQueryDoAction(31,MCharacter[nChar].item->MpalCode(),parm); + h = mpalQueryDoAction(31,MCharacter[nChar].item->MpalCode(),parm); if (h!=INVALID_HANDLE_VALUE) WaitForSingleObject(h,INFINITE); } @@ -1724,7 +1724,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg g_system->unlockMutex(vdb); } - string=mpalQueryDialogPeriod(nMsg); + string = mpalQueryDialogPeriod(nMsg); if (nPers == 0) { text = new RMTextDialog; @@ -1847,7 +1847,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg if ((MCharacter[nPers].bInTexts && MCharacter[nPers].numtexts== 0) || !MCharacter[nPers].bInTexts) { // Cerca di eseguire la funzione custom per chiudere la parlata MCharacter[nPers].curTalk = (MCharacter[nPers].curTalk%10) + MCharacter[nPers].curgroup*10; - h=mpalQueryDoAction(31,MCharacter[nPers].item->MpalCode(),MCharacter[nPers].curTalk); + h = mpalQueryDoAction(31,MCharacter[nPers].item->MpalCode(),MCharacter[nPers].curTalk); if (h!=INVALID_HANDLE_VALUE) WaitForSingleObject(h,INFINITE); @@ -1872,7 +1872,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg } -// @@@@ QUESTA NON SI PUO' SKIPPARE!!!!!!!!!!!!!!!!!!! +// @@@@ This cannot be skipped!!!!!!!!!!!!!!!!!!! DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGroup, uint32, uint32) { int nChoice; @@ -1888,9 +1888,9 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr mpalQueryDoDialogU32(nDialog, nStartGroup); // Aspetta che una scelta si presenti - while ((nChoice=mpalQueryDialogWaitForChoice()) != -1) { + while ((nChoice = mpalQueryDialogWaitForChoice()) != -1) { // Si fa dare la lista di opzioni e le conta - sl=mpalQueryDialogSelectList(nChoice); + sl = mpalQueryDialogSelectList(nChoice); for (num = 0; sl[num] != 0; num++) ; @@ -1906,7 +1906,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr dc.SetNumChoices(num); // Scrive tutte le possibili opzioni - for (i = 0;i < num; i++) { + for (i = 0; i < num; i++) { string = mpalQueryDialogPeriod(sl[i]); assert(string != NULL); dc.AddChoice(string); diff --git a/engines/tony/custom.h b/engines/tony/custom.h index a9f4ac2aab..4b9701cec4 100644 --- a/engines/tony/custom.h +++ b/engines/tony/custom.h @@ -49,6 +49,7 @@ #ifndef TONY_CUSTOM_H #define TONY_CUSTOM_H +#include "common/str.h" #include "tony/mpal/mpal.h" namespace Tony { @@ -70,18 +71,19 @@ typedef uint32 HWND; static void AssignError(int num) { \ error("Custom function %u has been already assigned!", num); \ } \ - void INIT_CUSTOM_FUNCTION(LPCUSTOMFUNCTION *lpMap) \ + void INIT_CUSTOM_FUNCTION(LPCUSTOMFUNCTION *lpMap, Common::String *lpStrMap) \ { -#define END_CUSTOM_FUNCTION_MAP() \ +#define END_CUSTOM_FUNCTION_MAP() \ } -#define ASSIGN(num, func) \ - if (lpMap[num] != NULL) \ - AssignError(num); \ - lpMap[num] = func; +#define ASSIGN(num, func) \ + if (lpMap[num] != NULL) \ + AssignError(num); \ + lpMap[num] = func; \ + lpStrMap[num] = #func; class RMTony; class RMPointer; @@ -90,7 +92,7 @@ class RMLocation; class RMInventory; class RMInput; -void INIT_CUSTOM_FUNCTION(LPCUSTOMFUNCTION *lpMap); +void INIT_CUSTOM_FUNCTION(LPCUSTOMFUNCTION *lpMap, Common::String *lpStrMap); void SetupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation *loc, RMInventory *inv, RMInput *input); #endif diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 9000693292..26cbf3652d 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -102,7 +102,8 @@ static byte * lpMpcImage; LPITEMIRQFUNCTION lpiifCustom=NULL; -LPLPCUSTOMFUNCTION lplpFunctions=NULL; +LPLPCUSTOMFUNCTION lplpFunctions = NULL; +Common::String * lplpFunctionStrings = NULL; uint16 nObjs; uint16 nVars; @@ -959,6 +960,12 @@ void ActionThread(CORO_PARAM, const void *param) { if (item->Command[_ctx->k].type == 1) { // Custom function + debugC(DEBUG_DETAILED, kTonyDebugActions, "Action Process %d Call=%s params=%d,%d,%d,%d", + _vm->_scheduler.getCurrentPID(), lplpFunctionStrings[item->Command[_ctx->k].nCf].c_str(), + item->Command[_ctx->k].arg1, item->Command[_ctx->k].arg2, + item->Command[_ctx->k].arg3, item->Command[_ctx->k].arg4 + ); + CORO_INVOKE_4(lplpFunctions[item->Command[_ctx->k].nCf], item->Command[_ctx->k].arg1, item->Command[_ctx->k].arg2, @@ -968,6 +975,9 @@ void ActionThread(CORO_PARAM, const void *param) { ); } else if (item->Command[_ctx->k].type == 2) { // Variable assign + debugC(DEBUG_DETAILED, kTonyDebugActions, "Action Process %d Variable=%s", + _vm->_scheduler.getCurrentPID(), item->Command[_ctx->k].lpszVarName); + LockVar(); varSetValue(item->Command[_ctx->k].lpszVarName, EvaluateExpression(item->Command[_ctx->k].expr)); UnlockVar(); @@ -981,6 +991,8 @@ void ActionThread(CORO_PARAM, const void *param) { GlobalFree(item); + debugC(DEBUG_DETAILED, kTonyDebugActions, "Action Process %d ended", _vm->_scheduler.getCurrentPID()); + CORO_KILL_SELF(); CORO_END_CODE; @@ -1705,7 +1717,8 @@ bool DoSelection(uint32 i, uint32 dwData) { * \****************************************************************************/ -bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, LPLPCUSTOMFUNCTION lplpcfArray) { +bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, + LPLPCUSTOMFUNCTION lplpcfArray, Common::String *lpcfStrings) { Common::File hMpc; byte buf[5]; uint32 nBytesRead; @@ -1719,6 +1732,7 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, LPLPCUST /* Si salva l'array delle funzioni custom */ lplpFunctions = lplpcfArray; + lplpFunctionStrings = lpcfStrings; /* Apre il file MPC in lettura */ if (!hMpc.open(lpszMpcFileName)) diff --git a/engines/tony/mpal/mpal.h b/engines/tony/mpal/mpal.h index 9da963d39e..c9f8625744 100644 --- a/engines/tony/mpal/mpal.h +++ b/engines/tony/mpal/mpal.h @@ -119,6 +119,7 @@ #include "common/scummsys.h" #include "common/rect.h" +#include "common/str.h" #include "tony/coroutine.h" namespace Tony { @@ -602,7 +603,7 @@ extern "C" { \****************************************************************************/ bool EXPORT mpalInit(const char *lpszFileName, const char *lpszMprFileName, - LPLPCUSTOMFUNCTION lplpcfArray); + LPLPCUSTOMFUNCTION lplpcfArray, Common::String *lpcfStrings); diff --git a/engines/tony/sched.cpp b/engines/tony/sched.cpp index 421f4d1ac7..f8a7fd2538 100644 --- a/engines/tony/sched.cpp +++ b/engines/tony/sched.cpp @@ -314,7 +314,7 @@ void Scheduler::waitForSingleObject(CORO_PARAM, int pid, int duration, bool *exp while (g_system->getMillis() < _ctx->endTime) { // Check to see if a process with the given Id exists _ctx->pProc = active->pNext; - while ((_ctx->pProc != NULL) && (_ctx->pProc->pid == pid)) + while ((_ctx->pProc != NULL) && (_ctx->pProc->pid != pid)) _ctx->pProc = _ctx->pProc->pNext; if (_ctx->pProc == NULL) { diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 01d0cf9add..a4a478d40d 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -23,6 +23,7 @@ #include "common/scummsys.h" #include "common/algorithm.h" #include "common/config-manager.h" +#include "common/debug-channels.h" #include "common/events.h" #include "common/file.h" #include "tony/tony.h" @@ -37,6 +38,11 @@ TonyEngine *_vm; TonyEngine::TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc), _randomSource("tony") { _vm = this; + + DebugMan.addDebugChannel(kTonyDebugAnimations, "animations", "Animations debugging"); + DebugMan.addDebugChannel(kTonyDebugActions, "actions", "Actions debugging"); + DebugMan.addDebugChannel(kTonyDebugSound, "sound", "Sound debugging"); + DebugMan.addDebugChannel(kTonyDebugMusic, "music", "Music debugging"); } TonyEngine::~TonyEngine() { @@ -84,7 +90,7 @@ Common::ErrorCode TonyEngine::Init() { return Common::kReadingFailed; f.close(); - if (!mpalInit("ROASTED.MPC", "ROASTED.MPR", FuncList)) + if (!mpalInit("ROASTED.MPC", "ROASTED.MPR", FuncList, FuncListStrings)) return Common::kUnknownError; // Initialise the update resources @@ -133,7 +139,7 @@ Common::ErrorCode TonyEngine::Init() { } void TonyEngine::InitCustomFunctionMap() { - INIT_CUSTOM_FUNCTION(FuncList); + INIT_CUSTOM_FUNCTION(FuncList, FuncListStrings); } /** diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 1eafe54afb..3c7e8fe6b2 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -88,6 +88,7 @@ protected: virtual bool hasFeature(EngineFeature f) const; public: LPCUSTOMFUNCTION FuncList[300]; + Common::String FuncListStrings[300]; Common::RandomSource _randomSource; MPAL::MemoryManager _memoryManager; RMResUpdate _resUpdate; -- cgit v1.2.3 From 0b8974ec4ab37ef056ac50c098d3fe8045ec172b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 6 May 2012 23:51:11 +1000 Subject: TONY: Beginnings of converting dialog processes to coroutines --- engines/tony/custom.cpp | 70 +++--- engines/tony/mpal/mpal.cpp | 585 ++++++++++++++++++++++---------------------- engines/tony/mpal/mpal.h | 8 +- engines/tony/mpal/stubs.cpp | 2 + engines/tony/sched.cpp | 3 + 5 files changed, 335 insertions(+), 333 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index dadc84e606..e7878c5a5d 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -1699,7 +1699,7 @@ int curDialog; DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg, uint32, uint32) { LPSTR string; - RMTextDialog* text; + RMTextDialog *text; int parm; HANDLE h; bool bIsBack = false; @@ -1875,70 +1875,80 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg // @@@@ This cannot be skipped!!!!!!!!!!!!!!!!!!! DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGroup, uint32, uint32) { - int nChoice; - uint32 *sl; - int i,num; - char* string; - RMDialogChoice dc; - int sel; + CORO_BEGIN_CONTEXT; + uint32 nChoice; + uint32 *sl; + int i, num; + char *string; + RMDialogChoice dc; + int sel; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); curDialog = nDialog; - // Chiama l'MPAL per iniziare il dialogo + // Call MPAL to start the dialog mpalQueryDoDialogU32(nDialog, nStartGroup); - // Aspetta che una scelta si presenti - while ((nChoice = mpalQueryDialogWaitForChoice()) != -1) { + // Wait until a choice is selected + mpalQueryDialogWaitForChoice(&_ctx->nChoice); + while (_ctx->nChoice != -1) { // Si fa dare la lista di opzioni e le conta - sl = mpalQueryDialogSelectList(nChoice); - for (num = 0; sl[num] != 0; num++) + _ctx->sl = mpalQueryDialogSelectList(_ctx->nChoice); + for (_ctx->num = 0; _ctx->sl[_ctx->num] != 0; _ctx->num++) ; // Se c'e' una sola opzione, la fa automaticamente, e aspetta la prossima scelta - if (num == 1) { - mpalQueryDialogSelectionU32(nChoice, sl[0]); - GlobalFree(sl); + if (_ctx->num == 1) { + mpalQueryDialogSelectionU32(_ctx->nChoice, _ctx->sl[0]); + GlobalFree(_ctx->sl); continue; } // Crea una scelta per il dialogo - dc.Init(); - dc.SetNumChoices(num); + _ctx->dc.Init(); + _ctx->dc.SetNumChoices(_ctx->num); // Scrive tutte le possibili opzioni - for (i = 0; i < num; i++) { - string = mpalQueryDialogPeriod(sl[i]); - assert(string != NULL); - dc.AddChoice(string); - GlobalFree(string); + for (_ctx->i = 0; _ctx->i < _ctx->num; _ctx->i++) { + _ctx->string = mpalQueryDialogPeriod(_ctx->sl[_ctx->i]); + assert(_ctx->string != NULL); + _ctx->dc.AddChoice(_ctx->string); + GlobalFree(_ctx->string); } // Attiva l'oggetto - LinkGraphicTask(&dc); - dc.Show(); + LinkGraphicTask(&_ctx->dc); + _ctx->dc.Show(); // Disegna il puntatore Pointer->SetSpecialPointer(Pointer->PTR_NONE); MainShowMouse(); - while (!(Input->MouseLeftClicked() && ((sel = dc.GetSelection()) != -1))) { + while (!(Input->MouseLeftClicked() && ((_ctx->sel = _ctx->dc.GetSelection()) != -1))) { WaitFrame(); Freeze(); - dc.DoFrame(Input->MousePos()); + _ctx->dc.DoFrame(Input->MousePos()); Unfreeze(); } // Nascondi il puntatore MainHideMouse(); - dc.Hide(); - mpalQueryDialogSelectionU32(nChoice, sl[sel]); + _ctx->dc.Hide(); + mpalQueryDialogSelectionU32(_ctx->nChoice, _ctx->sl[_ctx->sel]); // Chiude la scelta - dc.Close(); + _ctx->dc.Close(); + + GlobalFree(_ctx->sl); - GlobalFree(sl); + // Wait for the next choice to be made + mpalQueryDialogWaitForChoice(&_ctx->nChoice); } + + CORO_END_CODE; } diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 26cbf3652d..592c4788df 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -1335,93 +1335,101 @@ void LocationPollThread(CORO_PARAM, const void *param) { * \****************************************************************************/ -void PASCAL ShutUpDialogThread(HANDLE hThread) { - WaitForSingleObject(hThread, INFINITE); +void ShutUpDialogThread(CORO_PARAM, const void *param) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + uint32 pid = *(const uint32 *)param; + + CORO_BEGIN_CODE(_ctx); + + CORO_INVOKE_2(_vm->_scheduler.waitForSingleObject, pid, INFINITE); bExecutingDialog = false; nExecutingDialog = 0; nExecutingChoice = 0; SetEvent(hAskChoice); - ExitThread(1); -// _endthread(); + + CORO_KILL_SELF(); + + CORO_END_CODE; } +void DoChoice(CORO_PARAM, uint32 nChoice); -/****************************************************************************\ -* -* Function: void GroupThread(uint32 nGroup); -* -* Description: Esegue un gruppo del dialogo corrente. Puo' essere lo -* starting point di un thread. -* -* Input: uint32 nGroup Numero del gruppo da eseguire -* -\****************************************************************************/ -void DoChoice(uint32 nChoice); +/** + * Executes a group of the current dialog. Can 'be the Starting point of a process. + * @parm nGroup Number of the group to perform + */ +void GroupThread(CORO_PARAM, const void *param) { + CORO_BEGIN_CONTEXT; + LPMPALDIALOG dialog; + int i, j, k; + int type; + CORO_END_CONTEXT(_ctx); -void PASCAL GroupThread(uint32 nGroup) { - LPMPALDIALOG dialog; - int i, j, k; + uint32 nGroup = *(const uint32 *)param; + + CORO_BEGIN_CODE(_ctx); - /* Locka i dialoghi */ + // Lock the _ctx->dialog LockDialogs(); - /* Trova il puntatore al dialogo corrente */ - dialog = lpmdDialogs+nExecutingDialog; - - /* Cerca il gruppo richiesto all'interno del dialogo */ - for (i = 0; dialog->Group[i].num != 0; i++) - if (dialog->Group[i].num==nGroup) { - /* Cicla eseguendo i comandi del gruppo */ - for (j = 0; j < dialog->Group[i].nCmds; j++) { - k=dialog->Group[i].CmdNum[j]; - - switch (dialog->Command[k].type) { - /* Funzione custom: la richiama */ - case 1: - // FIXME: Convert to co-routine - lplpFunctions[dialog->Command[k].nCf]( - nullContext, - dialog->Command[k].arg1, - dialog->Command[k].arg2, - dialog->Command[k].arg3, - dialog->Command[k].arg4 + // Find the pointer to the current _ctx->dialog + _ctx->dialog = lpmdDialogs + nExecutingDialog; + + // Search inside the group requesting the _ctx->dialog + for (_ctx->i = 0; _ctx->dialog->Group[_ctx->i].num != 0; _ctx->i++) { + if (_ctx->dialog->Group[_ctx->i].num == nGroup) { + // Cycle through executing the commands of the group + for (_ctx->j = 0; _ctx->j < _ctx->dialog->Group[_ctx->i].nCmds; _ctx->j++) { + _ctx->k = _ctx->dialog->Group[_ctx->i].CmdNum[_ctx->j]; + + _ctx->type = _ctx->dialog->Command[_ctx->k].type; + if (_ctx->type == 1) { + // Call custom function + CORO_INVOKE_4(lplpFunctions[_ctx->dialog->Command[_ctx->k].nCf], + _ctx->dialog->Command[_ctx->k].arg1, + _ctx->dialog->Command[_ctx->k].arg2, + _ctx->dialog->Command[_ctx->k].arg3, + _ctx->dialog->Command[_ctx->k].arg4 ); - break; - /* Variabile: la setta */ - case 2: + } else if (_ctx->type == 2) { + // Set a variable LockVar(); - varSetValue(dialog->Command[k].lpszVarName,EvaluateExpression(dialog->Command[k].expr)); + varSetValue(_ctx->dialog->Command[_ctx->k].lpszVarName, EvaluateExpression(_ctx->dialog->Command[_ctx->k].expr)); UnlockVar(); - break; - - /* DoChoice: richiama la funzione di scelta */ - case 3: - DoChoice((uint32)dialog->Command[k].nChoice); - break; - - default: + + } else if (_ctx->type == 3) { + // DoChoice: call the chosen function + CORO_INVOKE_1(DoChoice, (uint32)_ctx->dialog->Command[_ctx->k].nChoice); + + } else { mpalError = 1; UnlockDialogs(); - ExitThread(0); -// _endthread(); + + CORO_KILL_SELF(); + return; + } } - } - /* Abbiamo eseguito il gruppo. Possiamo uscire alla funzione chiamante. - Se il gruppo era il primo chiamato, allora automaticamente il - thread viene chiuso, altrimenti si ritorno al gruppo chiamante. */ - UnlockDialogs(); - return; + /* The gruop is finished, so we can return to the calling function. + * If the group was the first called, then the process will automatically + * end. Otherwise it returns to the caller method + */ + return; + } } /* Se siamo qui, vuol dire che non abbiamo trovato il gruppo richiesto */ mpalError = 1; UnlockDialogs(); - ExitThread(0); -// _endthread(); + + CORO_KILL_SELF(); + + CORO_END_CODE; } @@ -1435,52 +1443,58 @@ void PASCAL GroupThread(uint32 nGroup) { * \****************************************************************************/ -void DoChoice(uint32 nChoice) { - LPMPALDIALOG dialog; - int i,j,k; +void DoChoice(CORO_PARAM, uint32 nChoice) { + CORO_BEGIN_CONTEXT; + LPMPALDIALOG dialog; + int i, j, k; + uint32 nGroup; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); - /* Locka i dialoghi */ + /* Locka _ctx->i dialoghi */ LockDialogs(); /* Trova il puntatore al dialogo corrente */ - dialog=lpmdDialogs+nExecutingDialog; + _ctx->dialog=lpmdDialogs+nExecutingDialog; /* Cerca la scelta richiesta tra quelle nel dialogo */ - for (i = 0; dialog->Choice[i].nChoice != 0; i++) - if (dialog->Choice[i].nChoice == nChoice) + for (_ctx->i = 0; _ctx->dialog->Choice[_ctx->i].nChoice != 0; _ctx->i++) + if (_ctx->dialog->Choice[_ctx->i].nChoice == nChoice) break; /* Se non l'ha trovata, esce con errore */ - if (dialog->Choice[i].nChoice == 0) { + if (_ctx->dialog->Choice[_ctx->i].nChoice == 0) { /* Se siamo qui, non abbiamo trovato la choice richiesta */ mpalError = 1; UnlockDialogs(); - ExitThread(0); -// _endthread(); + + CORO_KILL_SELF(); + return; } /* Abbiamo trova la choice richiesta. Ricordiamoci qual e' nella variabile globale */ - nExecutingChoice = i; + nExecutingChoice = _ctx->i; while (1) { - nExecutingChoice = i; + nExecutingChoice = _ctx->i; - k = 0; + _ctx->k = 0; /* Calcoliamo le when expression di ciascun select, per vedere se sono attivi o disattivi */ - for (j = 0; dialog->Choice[i].Select[j].dwData != 0; j++) - if (dialog->Choice[i].Select[j].when == NULL) { - dialog->Choice[i].Select[j].curActive = 1; - k++; - } else if (EvaluateExpression(dialog->Choice[i].Select[j].when)) { - dialog->Choice[i].Select[j].curActive = 1; - k++; + for (_ctx->j = 0; _ctx->dialog->Choice[_ctx->i].Select[_ctx->j].dwData != 0; _ctx->j++) + if (_ctx->dialog->Choice[_ctx->i].Select[_ctx->j].when == NULL) { + _ctx->dialog->Choice[_ctx->i].Select[_ctx->j].curActive = 1; + _ctx->k++; + } else if (EvaluateExpression(_ctx->dialog->Choice[_ctx->i].Select[_ctx->j].when)) { + _ctx->dialog->Choice[_ctx->i].Select[_ctx->j].curActive = 1; + _ctx->k++; } else - dialog->Choice[i].Select[j].curActive = 0; + _ctx->dialog->Choice[_ctx->i].Select[_ctx->j].curActive = 0; /* Se non ci sono scelte attivate, la scelta e' finita */ - if (k == 0) { + if (_ctx->k == 0) { UnlockDialogs(); break; } @@ -1491,31 +1505,36 @@ void DoChoice(uint32 nChoice) { SetEvent(hAskChoice); WaitForSingleObject(hDoneChoice, INFINITE); - /* Ora che la scelta e' stata effettuata, possiamo eseguire i gruppi + /* Ora che la scelta e' stata effettuata, possiamo eseguire _ctx->i gruppi associati con la scelta */ - j=nSelectedChoice; - for (k = 0; dialog->Choice[i].Select[j].wPlayGroup[k] != 0; k++) - GroupThread(dialog->Choice[i].Select[j].wPlayGroup[k]); + _ctx->j = nSelectedChoice; + for (_ctx->k = 0; _ctx->dialog->Choice[_ctx->i].Select[_ctx->j].wPlayGroup[_ctx->k] != 0; _ctx->k++) { + _ctx->nGroup = _ctx->dialog->Choice[_ctx->i].Select[_ctx->j].wPlayGroup[_ctx->k]; + CORO_INVOKE_1(GroupThread, &_ctx->nGroup); + } /* Controllo sugli attributi */ - if (dialog->Choice[i].Select[j].attr & (1 << 0)) { + if (_ctx->dialog->Choice[_ctx->i].Select[_ctx->j].attr & (1 << 0)) { /* Bit 0 settato: fine della scelta */ UnlockDialogs(); break; } - if (dialog->Choice[i].Select[j].attr & (1 << 1)) { + if (_ctx->dialog->Choice[_ctx->i].Select[_ctx->j].attr & (1 << 1)) { /* Bit 1 settato: fine del dialogo */ UnlockDialogs(); - ExitThread(1); -// _endthread(); + + CORO_KILL_SELF(); + return; } /* Fine della scelta senza attributi: bisogna rifarla */ } - /* Se siamo qui, abbiamo trovato un end choice. Ritorna al gruppo chiamante */ + // If we're here, we found an end choice. Return to the caller group return; + + CORO_END_CODE; } @@ -1605,57 +1624,40 @@ static HANDLE DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { return INVALID_HANDLE_VALUE; } +/** + * Shows a dialog in a separate process. + * + * @param nDlgOrd The index of the dialog in the dialog list + * @param nGroup Number of the group to perform + * @returns The process Id of the process running the dialog + * or INVALID_HANDLE_VALUE on error + * @remarks The dialogue runs in a thread created on purpose, + * so that must inform through an event and when 'necessary to you make a choice. + * The data on the choices may be obtained through various queries. + */ +static uint32 DoDialog(uint32 nDlgOrd, uint32 nGroup) { + uint32 h; -/****************************************************************************\ -* -* Function: HANDLE DoDialog(uint32 nDlgOrd, uint32 nGroup); -* -* Description: Esegue un dialogo in un thread -* -* Input: uint32 nDlgOrd Indice del dialogo da eseguire -* all'interno dell'array di strutture -* dei dialoghi -* uint32 nGroup Numero del gruppo da eseguire -* -* Return: Handle del thread che sta eseguendo il dialogo, o -* INVALID_HANDLE_VALUE in caso di errore -* -* Note: Il dialogo viene eseguito in un thread creato apposta, che -* deve informa tramite un evento quando e' necessario far -* fare una scelta all'utente. I dati sulle scelte possono -* essere richiesti tramite le varie query. -* -\****************************************************************************/ - -static HANDLE DoDialog(uint32 nDlgOrd, uint32 nGroup) { -// LPMPALDIALOG dialog=lpmdDialogs+nDlgOrd; - uint32 dwId; - HANDLE h; - - /* Si ricorda nella variabile globale qual e' il dialogo in esecuzione */ + // Store the running dialog in a global variable nExecutingDialog = nDlgOrd; - /* Attiva la flag per indicare che c'e' un dialogo in esecuzione */ + // Enables the flag to indicate that there is' a running dialogue bExecutingDialog = true; ResetEvent(hAskChoice); ResetEvent(hDoneChoice); - /* Crea un thread in cui esegue un gruppo del dialogo */ + // Create a thread that performs the dialogue group - // !!! Nuova gestione dei thread - if ((h = CreateThread(NULL, 10240, (LPTHREAD_START_ROUTINE)GroupThread, (void *)nGroup, 0, &dwId)) == NULL) - // if ((h=(void*)_beginthread(GroupThread, 10240,(void *)nGroup))==(void*)-1) - return INVALID_HANDLE_VALUE; + // Create the process + if ((h = _vm->_scheduler.createProcess(GroupThread, &nGroup, sizeof(uint32))) == 0) + return 0; - /* Crea un thread che attende la fine del dialogo e rimette a posto le - variabili globali */ - // !!! Nuova gestione dei thread - if (CreateThread(NULL, 10240,(LPTHREAD_START_ROUTINE)ShutUpDialogThread,(void *)h, 0, &dwId) == NULL) { - //if ((h=(void*)_beginthread(ShutUpDialogThread, 10240,(void *)h))==(void*)-1) - TerminateThread(h, 0); - CloseHandle(h); - return INVALID_HANDLE_VALUE; + // Create a thread that waits until the end of the dialog process, and will restore the global variables + if (_vm->_scheduler.createProcess(ShutUpDialogThread, &h, sizeof(uint32)) == 0) { + // Something went wrong, so kill the previously started dialog process + _vm->_scheduler.killMatchingProcess(h); + return 0; } return h; @@ -1893,243 +1895,230 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, #define GETARG(type) va_arg(v,type) -uint32 mpalQuery(uint16 wQueryType, ...) { - uint32 dwRet = 0; - int x, y, z; - char *n; - va_list v; - Common::String buf; +void mpalQueryInner(CORO_PARAM, uint16 wQueryType, uint32 *dwRet, va_list v) { + CORO_BEGIN_CONTEXT; + int x, y, z; + char *n; + Common::String buf; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); mpalError = OK; - va_start(v, wQueryType); - switch (wQueryType) { - /* - * uint32 mpalQuery(MPQ_VERSION); - */ - case MPQ_VERSION: - dwRet = HEX_VERSION; - break; + if (wQueryType == MPQ_VERSION) { + /* + * uint32 mpalQuery(MPQ_VERSION); + */ + *dwRet = HEX_VERSION; - /* - * uint32 mpalQuery(MPQ_GLOBAL_VAR, char * lpszVarName); - */ - case MPQ_GLOBAL_VAR: + } else if (wQueryType == MPQ_GLOBAL_VAR) { + /* + * uint32 mpalQuery(MPQ_GLOBAL_VAR, char * lpszVarName); + */ LockVar(); - dwRet = (uint32)varGetValue(GETARG(char *)); + *dwRet = (uint32)varGetValue(GETARG(char *)); UnlockVar(); - break; - /* - * char * mpalQuery(MPQ_MESSAGE, uint32 nMsg); - */ - case MPQ_MESSAGE: + } else if (wQueryType == MPQ_MESSAGE) { + /* + * char * mpalQuery(MPQ_MESSAGE, uint32 nMsg); + */ LockMsg(); - dwRet = (uint32)DuplicateMessage(msgGetOrderFromNum(GETARG(uint32))); + *dwRet = (uint32)DuplicateMessage(msgGetOrderFromNum(GETARG(uint32))); UnlockMsg(); - break; - - /* - * uint32 mpalQuery(MPQ_ITEM_PATTERN, uint32 nItem); - */ - case MPQ_ITEM_PATTERN: + + } else if (wQueryType == MPQ_ITEM_PATTERN) { + /* + * uint32 mpalQuery(MPQ_ITEM_PATTERN, uint32 nItem); + */ LockVar(); - buf = Common::String::format("Pattern.%u", GETARG(uint32)); - dwRet = (uint32)varGetValue(buf.c_str()); + _ctx->buf = Common::String::format("Pattern.%u", GETARG(uint32)); + *dwRet = (uint32)varGetValue(_ctx->buf.c_str()); UnlockVar(); - break; - - /* - * uint32 mpalQuery(MPQ_LOCATION_SIZE, uint32 nLoc, uint32 dwCoord); - */ - case MPQ_LOCATION_SIZE: + + } else if (wQueryType == MPQ_LOCATION_SIZE) { + /* + * uint32 mpalQuery(MPQ_LOCATION_SIZE, uint32 nLoc, uint32 dwCoord); + */ LockLocations(); - x = locGetOrderFromNum(GETARG(uint32)); - y = GETARG(uint32); - if (x != -1) { - if (y == MPQ_X) - dwRet = lpmlLocations[x].dwXlen; - else if (y == MPQ_Y) - dwRet = lpmlLocations[x].dwYlen; + _ctx->x = locGetOrderFromNum(GETARG(uint32)); + _ctx->y = GETARG(uint32); + if (_ctx->x != -1) { + if (_ctx->y == MPQ_X) + *dwRet = lpmlLocations[_ctx->x].dwXlen; + else if (_ctx->y == MPQ_Y) + *dwRet = lpmlLocations[_ctx->x].dwYlen; else mpalError = 1; } else mpalError = 1; UnlockLocations(); - break; - - /* - * HGLOBAL mpalQuery(MPQ_LOCATION_IMAGE, uint32 nLoc); - */ - case MPQ_LOCATION_IMAGE: + + } else if (wQueryType == MPQ_LOCATION_IMAGE) { + /* + * HGLOBAL mpalQuery(MPQ_LOCATION_IMAGE, uint32 nLoc); + */ LockLocations(); - x = locGetOrderFromNum(GETARG(uint32)); - dwRet = (uint32)resLoad(lpmlLocations[x].dwPicRes); + _ctx->x = locGetOrderFromNum(GETARG(uint32)); + *dwRet = (uint32)resLoad(lpmlLocations[_ctx->x].dwPicRes); UnlockLocations(); - break; - /* - * HGLOBAL mpalQuery(MPQ_RESOURCE, uint32 dwRes); - */ - case MPQ_RESOURCE: - dwRet = (uint32)resLoad(GETARG(uint32)); - break; + } else if (wQueryType == MPQ_RESOURCE) { + /* + * HGLOBAL mpalQuery(MPQ_RESOURCE, uint32 dwRes); + */ + *dwRet = (uint32)resLoad(GETARG(uint32)); - /* - * uint32 mpalQuery(MPQ_ITEM_LIST, uint32 nLoc); - */ - case MPQ_ITEM_LIST: + } else if (wQueryType == MPQ_ITEM_LIST) { + /* + * uint32 mpalQuery(MPQ_ITEM_LIST, uint32 nLoc); + */ LockVar(); - dwRet = (uint32)GetItemList(GETARG(uint32)); + *dwRet = (uint32)GetItemList(GETARG(uint32)); LockVar(); - break; - /* - * LPITEM mpalQuery(MPQ_ITEM_DATA, uint32 nItem); - */ - case MPQ_ITEM_DATA: + } else if (wQueryType == MPQ_ITEM_DATA) { + /* + * LPITEM mpalQuery(MPQ_ITEM_DATA, uint32 nItem); + */ LockItems(); - dwRet = (uint32)GetItemData(itemGetOrderFromNum(GETARG(uint32))); + *dwRet = (uint32)GetItemData(itemGetOrderFromNum(GETARG(uint32))); UnlockItems(); - break; - /* - * bool mpalQuery(MPQ_ITEM_IS_ACTIVE, uint32 nItem); - */ - case MPQ_ITEM_IS_ACTIVE: + } else if (wQueryType == MPQ_ITEM_IS_ACTIVE) { + /* + * bool mpalQuery(MPQ_ITEM_IS_ACTIVE, uint32 nItem); + */ LockVar(); - x = GETARG(uint32); - buf = Common::String::format("Status.%u", x); - if (varGetValue(buf.c_str()) <= 0) - dwRet = (uint32)false; + _ctx->x = GETARG(uint32); + _ctx->buf = Common::String::format("Status.%u", _ctx->x); + if (varGetValue(_ctx->buf.c_str()) <= 0) + *dwRet = (uint32)false; else - dwRet = (uint32)true; + *dwRet = (uint32)true; UnlockVar(); - break; - - /* - * uint32 mpalQuery(MPQ_ITEM_NAME, uint32 nItem, char * lpszName); - */ - case MPQ_ITEM_NAME: + } else if (wQueryType == MPQ_ITEM_NAME) { + /* + * uint32 mpalQuery(MPQ_ITEM_NAME, uint32 nItem, char * lpszName); + */ LockVar(); - x = GETARG(uint32); - n=GETARG(char *); - buf = Common::String::format("Status.%u", x); - if (varGetValue(buf.c_str()) <= 0) - n[0]='\0'; + _ctx->x = GETARG(uint32); + _ctx->n = GETARG(char *); + _ctx->buf = Common::String::format("Status.%u", _ctx->x); + if (varGetValue(_ctx->buf.c_str()) <= 0) + _ctx->n[0]='\0'; else { LockItems(); - y = itemGetOrderFromNum(x); - CopyMemory(n, (char *)(lpmiItems+y)->lpszDescribe, MAX_DESCRIBE_SIZE); + _ctx->y = itemGetOrderFromNum(_ctx->x); + CopyMemory(_ctx->n, (char *)(lpmiItems+_ctx->y)->lpszDescribe, MAX_DESCRIBE_SIZE); UnlockItems(); } UnlockVar(); - break; - - /* - * char * mpalQuery(MPQ_DIALOG_PERIOD, uint32 nDialog, uint32 nPeriod); - */ - case MPQ_DIALOG_PERIOD: + } else if (wQueryType == MPQ_DIALOG_PERIOD) { + /* + * char * mpalQuery(MPQ_DIALOG_PERIOD, uint32 nDialog, uint32 nPeriod); + */ LockDialogs(); - y = GETARG(uint32); - dwRet = (uint32)DuplicateDialogPeriod(y); + _ctx->y = GETARG(uint32); + *dwRet = (uint32)DuplicateDialogPeriod(_ctx->y); UnlockDialogs(); - break; - - /* - * void mpalQuery(MPQ_DIALOG_WAITFORCHOICE); - */ - case MPQ_DIALOG_WAITFORCHOICE: + } else if (wQueryType == MPQ_DIALOG_WAITFORCHOICE) { + /* + * void mpalQuery(MPQ_DIALOG_WAITFORCHOICE); + */ WaitForSingleObject(hAskChoice, INFINITE); ResetEvent(hAskChoice); if (bExecutingDialog) - dwRet = (uint32)nExecutingChoice; + *dwRet = (uint32)nExecutingChoice; else - dwRet = (uint32)((int)-1); - break; - + *dwRet = (uint32)((int)-1); - /* - * uint32 *mpalQuery(MPQ_DIALOG_SELECTLIST, uint32 nChoice); - */ - case MPQ_DIALOG_SELECTLIST: + } else if (wQueryType == MPQ_DIALOG_SELECTLIST) { + /* + * uint32 *mpalQuery(MPQ_DIALOG_SELECTLIST, uint32 nChoice); + */ LockDialogs(); - dwRet = (uint32)GetSelectList(GETARG(uint32)); + *dwRet = (uint32)GetSelectList(GETARG(uint32)); UnlockDialogs(); break; - /* - * bool mpalQuery(MPQ_DIALOG_SELECTION, uint32 nChoice, uint32 dwData); - */ - case MPQ_DIALOG_SELECTION: + } else if (wQueryType == MPQ_DIALOG_SELECTION) { + /* + * bool mpalQuery(MPQ_DIALOG_SELECTION, uint32 nChoice, uint32 dwData); + */ LockDialogs(); - x = GETARG(uint32); - y = GETARG(uint32); - dwRet = (uint32)DoSelection(x,y); + _ctx->x = GETARG(uint32); + _ctx->y = GETARG(uint32); + *dwRet = (uint32)DoSelection(_ctx->x,_ctx->y); UnlockDialogs(); - break; - - - /* - * int mpalQuery(MPQ_DO_ACTION, uint32 nAction, uint32 nItem, uint32 dwParam); - */ - case MPQ_DO_ACTION: - /* - if (bExecutingAction) - { - dwRet = (uint32)INVALID_HANDLE_VALUE; - break; - } - */ + } else if (wQueryType == MPQ_DO_ACTION) { + /* + * int mpalQuery(MPQ_DO_ACTION, uint32 nAction, uint32 nItem, uint32 dwParam); + */ LockItems(); LockVar(); - x = GETARG(uint32); - z = GETARG(uint32); - y = itemGetOrderFromNum(z); - if (y!=-1) { - dwRet = (uint32)DoAction(x, y, GETARG(uint32)); + _ctx->x = GETARG(uint32); + _ctx->z = GETARG(uint32); + _ctx->y = itemGetOrderFromNum(_ctx->z); + if (_ctx->y!=-1) { + *dwRet = (uint32)DoAction(_ctx->x, _ctx->y, GETARG(uint32)); } else { - dwRet = (uint32)INVALID_HANDLE_VALUE; + *dwRet = (uint32)INVALID_HANDLE_VALUE; mpalError = 1; } UnlockVar(); UnlockItems(); - break; - /* - * int mpalQuery(MPQ_DO_DIALOG, uint32 nDialog, uint32 nGroup); - */ - case MPQ_DO_DIALOG: - if (bExecutingDialog) - break; + } else if (wQueryType == MPQ_DO_DIALOG) { + /* + * int mpalQuery(MPQ_DO_DIALOG, uint32 nDialog, uint32 nGroup); + */ + if (!bExecutingDialog) { + LockDialogs(); - LockDialogs(); - - x = dialogGetOrderFromNum(GETARG(uint32)); - y = GETARG(uint32); - dwRet = (uint32)DoDialog(x, y); - UnlockDialogs(); - break; - - /* - * DEFAULT -> ERROR - */ - default: + _ctx->x = dialogGetOrderFromNum(GETARG(uint32)); + _ctx->y = GETARG(uint32); + *dwRet = DoDialog(_ctx->x, _ctx->y); + UnlockDialogs(); + } + } else { + /* + * DEFAULT -> ERROR + */ mpalError = 1; - break; } + CORO_END_CODE; +} + +uint32 mpalQuery(uint16 wQueryType, ...) { + uint32 dwRet; + va_list v; + va_start(v, wQueryType); + + mpalQueryInner(nullContext, wQueryType, &dwRet, v); + va_end(v); return dwRet; } +void mpalQueryCoro(CORO_PARAM, uint32 *dwRet, uint16 wQueryType, ...) { + va_list v; + va_start(v, wQueryType); + + mpalQueryInner(coroParam, wQueryType, dwRet, v); + + va_end(v); +} + /****************************************************************************\ * diff --git a/engines/tony/mpal/mpal.h b/engines/tony/mpal/mpal.h index c9f8625744..5517a6518c 100644 --- a/engines/tony/mpal/mpal.h +++ b/engines/tony/mpal/mpal.h @@ -474,10 +474,8 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * \****************************************************************************/ -#define mpalQueryDialogWaitForChoice() \ - (int)mpalQuery(MPQ_DIALOG_WAITFORCHOICE) - - +#define mpalQueryDialogWaitForChoice(dwRet) \ + CORO_INVOKE_2(mpalQueryCoro, dwRet, MPQ_DIALOG_WAITFORCHOICE) /****************************************************************************\ * @@ -627,7 +625,7 @@ bool EXPORT mpalInit(const char *lpszFileName, const char *lpszMprFileName, uint32 EXPORT mpalQuery(uint16 wQueryType, ...); - +void mpalQueryCoro(CORO_PARAM, uint32 *dwRet, uint16 wQueryType, ...); /****************************************************************************\ * diff --git a/engines/tony/mpal/stubs.cpp b/engines/tony/mpal/stubs.cpp index 9d4a87d61c..0fc01d4d07 100644 --- a/engines/tony/mpal/stubs.cpp +++ b/engines/tony/mpal/stubs.cpp @@ -80,10 +80,12 @@ void Sleep(uint32 time) { } int WaitForSingleObject(HANDLE ThreadId, uint32 dwSleepTime) { + warning("TODO: Old style WaitForSingleObject"); return 0; } uint32 WaitForMultipleObjects(uint32 nCount, const HANDLE *lpHandles, bool bWaitAll, uint32 dwMilliseconds) { + warning("TODO: Old style WaitForMultipleObjects"); return 0; } diff --git a/engines/tony/sched.cpp b/engines/tony/sched.cpp index f8a7fd2538..41531bf225 100644 --- a/engines/tony/sched.cpp +++ b/engines/tony/sched.cpp @@ -299,6 +299,9 @@ void Scheduler::giveWay(PPROCESS pReSchedProc) { * @param expired Set to true if delay period expired */ void Scheduler::waitForSingleObject(CORO_PARAM, int pid, int duration, bool *expired) { + if (!pCurrent) + error("Called Scheduler::waitForSingleObject from the main process"); + CORO_BEGIN_CONTEXT; uint32 endTime; PROCESS *pProc; -- cgit v1.2.3 From 8527302057052e784c3ea32ca8eebb0220bf15e6 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 8 May 2012 08:25:33 +1000 Subject: TONY: Added support for threading events to scheduler, converted more procs to coroutines --- engines/tony/custom.cpp | 610 +++++++++++++++++++++++++++++--------------- engines/tony/loc.cpp | 31 ++- engines/tony/loc.h | 5 +- engines/tony/mpal/mpal.cpp | 27 +- engines/tony/mpal/stubs.cpp | 4 + engines/tony/sched.cpp | 182 ++++++++++++- engines/tony/sched.h | 25 +- engines/tony/tonychar.cpp | 194 +++++++++----- engines/tony/tonychar.h | 18 +- 9 files changed, 771 insertions(+), 325 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index e7878c5a5d..800b5d8d50 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -370,50 +370,62 @@ VoiceHeader *SearchVoiceHeader(uint32 codehi, uint32 codelo) { DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX, uint32 nY, uint32) { - RMMessage msg(dwMessage); - int i; - int curOffset = 0; + CORO_BEGIN_CONTEXT; + RMMessage *msg; + int i; + int curOffset; + VoiceHeader *curVoc; + FPSFX *voice; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + _ctx->curOffset = 0; if (bSkipIdle) return; - if (!msg.IsValid()) + _ctx->msg = new RMMessage(dwMessage); + if (!_ctx->msg->IsValid()) { + delete _ctx->msg; return; + } - VoiceHeader *curVoc = SearchVoiceHeader(0, dwMessage); - FPSFX *voice = NULL; - if (curVoc) { + _ctx->curVoc = SearchVoiceHeader(0, dwMessage); + _ctx->voice = NULL; + if (_ctx->curVoc) { // Si posiziona all'interno del database delle voci all'inizio della prima - curOffset = curVoc->offset; + _ctx->curOffset = _ctx->curVoc->offset; // PRIMA VOLTA PREALLOCA g_system->lockMutex(vdb); - //fseek(_vm->m_vdbFP, curOffset, SEEK_SET); - _vm->_vdbFP.seek(curOffset); - _vm->_theSound.CreateSfx(&voice); - voice->LoadVoiceFromVDB(_vm->_vdbFP); -// curOffset = ftell(_vm->m_vdbFP); - curOffset = _vm->_vdbFP.pos(); - - voice->SetLoop(false); + //fseek(_vm->m_vdbFP, _ctx->curOffset, SEEK_SET); + _vm->_vdbFP.seek(_ctx->curOffset); + _vm->_theSound.CreateSfx(&_ctx->voice); + _ctx->voice->LoadVoiceFromVDB(_vm->_vdbFP); +// _ctx->curOffset = ftell(_vm->m_vdbFP); + _ctx->curOffset = _vm->_vdbFP.pos(); + + _ctx->voice->SetLoop(false); g_system->unlockMutex(vdb); } if (nTonyNextTalkType != Tony->TALK_NORMAL) { - Tony->StartTalk(nTonyNextTalkType); + CORO_INVOKE_1(Tony->StartTalk, nTonyNextTalkType); + if (!bStaticTalk) nTonyNextTalkType = Tony->TALK_NORMAL; } else { - if (msg.NumPeriods() > 1) - Tony->StartTalk(Tony->TALK_FIANCHI); + if (_ctx->msg->NumPeriods() > 1) + CORO_INVOKE_1(Tony->StartTalk, Tony->TALK_FIANCHI); else - Tony->StartTalk(Tony->TALK_NORMAL); + CORO_INVOKE_1(Tony->StartTalk, Tony->TALK_NORMAL); } if (curBackText) curBackText->Hide(); bTonyIsSpeaking = true; - for (i = 0; i < msg.NumPeriods() && !bSkipIdle; i++) { + for (_ctx->i = 0; _ctx->i < _ctx->msg->NumPeriods() && !bSkipIdle; _ctx->i++) { RMTextDialog text; text.SetInput(Input); @@ -425,7 +437,7 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX text.SetColor(0,255,0); // Scrive il testo - text.WriteText(msg[i],0); + text.WriteText((*_ctx->msg)[_ctx->i],0); // Setta la posizione if (nX == 0 && nY == 0) @@ -439,21 +451,21 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX // Registra il testo LinkGraphicTask(&text); - if (curVoc) { - if (i == 0) { - voice->Play(); - text.SetCustomSkipHandle2(voice->hEndOfBuffer); + if (_ctx->curVoc) { + if (_ctx->i == 0) { + _ctx->voice->Play(); + text.SetCustomSkipHandle2(_ctx->voice->hEndOfBuffer); } else { g_system->lockMutex(vdb); - // fseek(_vm->m_vdbFP, curOffset, SEEK_SET); - _vm->_vdbFP.seek(curOffset); - _vm->_theSound.CreateSfx(&voice); - voice->LoadVoiceFromVDB(_vm->_vdbFP); - // curOffset = ftell(_vm->m_vdbFP); - curOffset = _vm->_vdbFP.pos(); - voice->SetLoop(false); - voice->Play(); - text.SetCustomSkipHandle2(voice->hEndOfBuffer); + // fseek(_vm->m_vdbFP, _ctx->curOffset, SEEK_SET); + _vm->_vdbFP.seek(_ctx->curOffset); + _vm->_theSound.CreateSfx(&_ctx->voice); + _ctx->voice->LoadVoiceFromVDB(_vm->_vdbFP); + // _ctx->curOffset = ftell(_vm->m_vdbFP); + _ctx->curOffset = _vm->_vdbFP.pos(); + _ctx->voice->SetLoop(false); + _ctx->voice->Play(); + text.SetCustomSkipHandle2(_ctx->voice->hEndOfBuffer); g_system->unlockMutex(vdb); } } @@ -462,10 +474,10 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX text.SetCustomSkipHandle(hSkipIdle); text.WaitForEndDisplay(); - if (curVoc) { - voice->Stop(); - voice->Release(); - voice=NULL; + if (_ctx->curVoc) { + _ctx->voice->Stop(); + _ctx->voice->Release(); + _ctx->voice=NULL; } } @@ -473,7 +485,10 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX if (curBackText) curBackText->Show(); - Tony->EndTalk(); + CORO_INVOKE_0(Tony->EndTalk); + delete _ctx->msg; + + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(ChangeBoxStatus)(CORO_PARAM, uint32 nLoc, uint32 nBox, uint32 nStatus, uint32) { @@ -718,134 +733,164 @@ DECLARE_CUSTOM_FUNCTION(CustEnableGUI)(CORO_PARAM, uint32, uint32, uint32, uint3 EnableGUI(); } -DECLARE_CUSTOM_FUNCTION(CustDisableGUI)(CORO_PARAM, uint32, uint32, uint32, uint32) -{ - DisableGUI(); +DECLARE_CUSTOM_FUNCTION(CustDisableGUI)(CORO_PARAM, uint32, uint32, uint32, uint32) { + DisableGUI(); } -void TonyGenericTake1(uint32 nDirection) { + +void TonyGenericTake1(CORO_PARAM, uint32 nDirection) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + Freeze(); - Tony->Take(nDirection,0); + Tony->Take(nDirection, 0); Unfreeze(); if (!bSkipIdle) - Tony->WaitForEndPattern(); + CORO_INVOKE_0(Tony->WaitForEndPattern); + + CORO_END_CODE; } -void TonyGenericTake2(uint32 nDirection) { +void TonyGenericTake2(CORO_PARAM, uint32 nDirection) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + Freeze(); - Tony->Take(nDirection,1); + Tony->Take(nDirection, 1); Unfreeze(); if (!bSkipIdle) - Tony->WaitForEndPattern(); + CORO_INVOKE_0(Tony->WaitForEndPattern); Freeze(); Tony->Take(nDirection,2); Unfreeze(); + + CORO_END_CODE; } -void TonyGenericPut1(uint32 nDirection) { +void TonyGenericPut1(CORO_PARAM, uint32 nDirection) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + Freeze(); - Tony->Put(nDirection,0); + Tony->Put(nDirection, 0); Unfreeze(); if (!bSkipIdle) - Tony->WaitForEndPattern(); + CORO_INVOKE_0(Tony->WaitForEndPattern); + + CORO_END_CODE; } -void TonyGenericPut2(uint32 nDirection) { +void TonyGenericPut2(CORO_PARAM, uint32 nDirection) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + Freeze(); Tony->Put(nDirection,1); Unfreeze(); if (!bSkipIdle) - Tony->WaitForEndPattern(); + CORO_INVOKE_0(Tony->WaitForEndPattern); Freeze(); Tony->Put(nDirection,2); Unfreeze(); + + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(TonyTakeUp1)(CORO_PARAM, uint32, uint32, uint32, uint32) { - TonyGenericTake1(0); + TonyGenericTake1(coroParam, 0); } DECLARE_CUSTOM_FUNCTION(TonyTakeMid1)(CORO_PARAM, uint32, uint32, uint32, uint32) { - TonyGenericTake1(1); + TonyGenericTake1(coroParam, 1); } DECLARE_CUSTOM_FUNCTION(TonyTakeDown1)(CORO_PARAM, uint32, uint32, uint32, uint32) { - TonyGenericTake1(2); + TonyGenericTake1(coroParam, 2); } DECLARE_CUSTOM_FUNCTION(TonyTakeUp2)(CORO_PARAM, uint32, uint32, uint32, uint32) { - TonyGenericTake2(0); + TonyGenericTake2(coroParam, 0); } DECLARE_CUSTOM_FUNCTION(TonyTakeMid2)(CORO_PARAM, uint32, uint32, uint32, uint32) { - TonyGenericTake2(1); + TonyGenericTake2(coroParam, 1); } DECLARE_CUSTOM_FUNCTION(TonyTakeDown2)(CORO_PARAM, uint32, uint32, uint32, uint32) { - TonyGenericTake2(2); + TonyGenericTake2(coroParam, 2); } - - - - DECLARE_CUSTOM_FUNCTION(TonyPutUp1)(CORO_PARAM, uint32, uint32, uint32, uint32) { - TonyGenericPut1(0); + TonyGenericPut1(coroParam, 0); } DECLARE_CUSTOM_FUNCTION(TonyPutMid1)(CORO_PARAM, uint32, uint32, uint32, uint32) { - TonyGenericPut1(1); + TonyGenericPut1(coroParam, 1); } DECLARE_CUSTOM_FUNCTION(TonyPutDown1)(CORO_PARAM, uint32, uint32, uint32, uint32) { - TonyGenericPut1(2); + TonyGenericPut1(coroParam, 2); } DECLARE_CUSTOM_FUNCTION(TonyPutUp2)(CORO_PARAM, uint32, uint32, uint32, uint32) { - TonyGenericPut2(0); + TonyGenericPut2(coroParam, 0); } DECLARE_CUSTOM_FUNCTION(TonyPutMid2)(CORO_PARAM, uint32, uint32, uint32, uint32) { - TonyGenericPut2(1); + TonyGenericPut2(coroParam, 1); } DECLARE_CUSTOM_FUNCTION(TonyPutDown2)(CORO_PARAM, uint32, uint32, uint32, uint32) { - TonyGenericPut2(2); + TonyGenericPut2(coroParam, 2); } - DECLARE_CUSTOM_FUNCTION(TonyPerTerra)(CORO_PARAM, uint32 dwParte, uint32, uint32, uint32) { - if (dwParte== 0) + if (dwParte == 0) Tony->SetPattern(Tony->PAT_PERTERRALEFT); else Tony->SetPattern(Tony->PAT_PERTERRARIGHT); } DECLARE_CUSTOM_FUNCTION(TonySiRialza)(CORO_PARAM, uint32 dwParte, uint32, uint32, uint32) { - if (dwParte== 0) + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + if (dwParte == 0) Tony->SetPattern(Tony->PAT_SIRIALZALEFT); else Tony->SetPattern(Tony->PAT_SIRIALZARIGHT); if (!bSkipIdle) - Tony->WaitForEndPattern(); + CORO_INVOKE_0(Tony->WaitForEndPattern); + + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(TonyPastorella)(CORO_PARAM, uint32 bIsPast, uint32, uint32, uint32) { @@ -853,10 +898,18 @@ DECLARE_CUSTOM_FUNCTION(TonyPastorella)(CORO_PARAM, uint32 bIsPast, uint32, uint } DECLARE_CUSTOM_FUNCTION(TonyFischietto)(CORO_PARAM, uint32, uint32, uint32, uint32) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + Tony->SetPattern(Tony->PAT_FISCHIETTORIGHT); if (!bSkipIdle) - Tony->WaitForEndPattern(); + CORO_INVOKE_0(Tony->WaitForEndPattern); + Tony->SetPattern(Tony->PAT_STANDRIGHT); + + CORO_END_CODE; } @@ -951,101 +1004,212 @@ DECLARE_CUSTOM_FUNCTION(TonyConPupazzoANIM)(CORO_PARAM, uint32 dwText, uint32, u } DECLARE_CUSTOM_FUNCTION(TonyConPupazzoStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + nTonyNextTalkType = Tony->TALK_CONPUPAZZOSTATIC; bStaticTalk = true; - Tony->StartStatic(Tony->TALK_CONPUPAZZOSTATIC); + CORO_INVOKE_1(Tony->StartStatic, Tony->TALK_CONPUPAZZOSTATIC); + + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(TonyConPupazzoEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { - Tony->EndStatic(Tony->TALK_CONPUPAZZOSTATIC); + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + CORO_INVOKE_1(Tony->EndStatic, Tony->TALK_CONPUPAZZOSTATIC); bStaticTalk = false; nTonyNextTalkType = Tony->TALK_NORMAL; + + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(TonyConConiglioStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + nTonyNextTalkType = Tony->TALK_CONCONIGLIOSTATIC; bStaticTalk = true; - Tony->StartStatic(Tony->TALK_CONCONIGLIOSTATIC); + CORO_INVOKE_1(Tony->StartStatic, Tony->TALK_CONCONIGLIOSTATIC); + + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(TonyConConiglioEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { - Tony->EndStatic(Tony->TALK_CONCONIGLIOSTATIC); + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + CORO_INVOKE_1(Tony->EndStatic, Tony->TALK_CONCONIGLIOSTATIC); bStaticTalk = false; nTonyNextTalkType = Tony->TALK_NORMAL; + + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(TonyConRicettaStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + nTonyNextTalkType = Tony->TALK_CONRICETTASTATIC; bStaticTalk = true; - Tony->StartStatic(Tony->TALK_CONRICETTASTATIC); + CORO_INVOKE_1(Tony->StartStatic, Tony->TALK_CONRICETTASTATIC); + + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(TonyConRicettaEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { - Tony->EndStatic(Tony->TALK_CONRICETTASTATIC); + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + CORO_INVOKE_1(Tony->EndStatic, Tony->TALK_CONRICETTASTATIC); bStaticTalk = false; nTonyNextTalkType = Tony->TALK_NORMAL; + + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(TonyConCarteStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + nTonyNextTalkType = Tony->TALK_CONCARTESTATIC; bStaticTalk = true; - Tony->StartStatic(Tony->TALK_CONCARTESTATIC); + CORO_INVOKE_1(Tony->StartStatic, Tony->TALK_CONCARTESTATIC); + + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(TonyConCarteEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { - Tony->EndStatic(Tony->TALK_CONCARTESTATIC); + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + CORO_INVOKE_1(Tony->EndStatic, Tony->TALK_CONCARTESTATIC); bStaticTalk = false; nTonyNextTalkType = Tony->TALK_NORMAL; + + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(TonyConTaccuinoStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + nTonyNextTalkType = Tony->TALK_CONTACCUINOSTATIC; bStaticTalk = true; - Tony->StartStatic(Tony->TALK_CONTACCUINOSTATIC); + CORO_INVOKE_1(Tony->StartStatic, Tony->TALK_CONTACCUINOSTATIC); + + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(TonyConTaccuinoEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { - Tony->EndStatic(Tony->TALK_CONTACCUINOSTATIC); + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + CORO_INVOKE_1(Tony->EndStatic, Tony->TALK_CONTACCUINOSTATIC); bStaticTalk = false; nTonyNextTalkType = Tony->TALK_NORMAL; + + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(TonyConMegafonoStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + nTonyNextTalkType = Tony->TALK_CONMEGAFONOSTATIC; bStaticTalk = true; - Tony->StartStatic(Tony->TALK_CONMEGAFONOSTATIC); + CORO_INVOKE_1(Tony->StartStatic, Tony->TALK_CONMEGAFONOSTATIC); + + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(TonyConMegafonoEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { - Tony->EndStatic(Tony->TALK_CONMEGAFONOSTATIC); + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + CORO_INVOKE_1(Tony->EndStatic, Tony->TALK_CONMEGAFONOSTATIC); bStaticTalk = false; nTonyNextTalkType = Tony->TALK_NORMAL; + + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(TonyConBarbaStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + nTonyNextTalkType = Tony->TALK_CONBARBASTATIC; bStaticTalk = true; - Tony->StartStatic(Tony->TALK_CONBARBASTATIC); + CORO_INVOKE_1(Tony->StartStatic, Tony->TALK_CONBARBASTATIC); + + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(TonyConBarbaEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { - Tony->EndStatic(Tony->TALK_CONBARBASTATIC); + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + CORO_INVOKE_1(Tony->EndStatic, Tony->TALK_CONBARBASTATIC); bStaticTalk = false; nTonyNextTalkType = Tony->TALK_NORMAL; + + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(TonySpaventatoStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + nTonyNextTalkType = Tony->TALK_SPAVENTATOSTATIC; bStaticTalk = true; - Tony->StartStatic(Tony->TALK_SPAVENTATOSTATIC); + CORO_INVOKE_1(Tony->StartStatic, Tony->TALK_SPAVENTATOSTATIC); + + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(TonySpaventatoEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { - Tony->EndStatic(Tony->TALK_SPAVENTATOSTATIC); + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + CORO_INVOKE_1(Tony->EndStatic, Tony->TALK_SPAVENTATOSTATIC); bStaticTalk = false; nTonyNextTalkType = Tony->TALK_NORMAL; -} + CORO_END_CODE; +} DECLARE_CUSTOM_FUNCTION(TonySchifato)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { @@ -1060,7 +1224,7 @@ DECLARE_CUSTOM_FUNCTION(TonySniffaLeft)(CORO_PARAM, uint32, uint32, uint32, uint CORO_BEGIN_CODE(_ctx); Tony->SetPattern(Tony->PAT_SNIFFA_LEFT); - Tony->WaitForEndPattern(); + CORO_INVOKE_0(Tony->WaitForEndPattern); CORO_INVOKE_4(LeftToMe, 0, 0, 0, 0); CORO_END_CODE; @@ -1073,7 +1237,7 @@ DECLARE_CUSTOM_FUNCTION(TonySniffaRight)(CORO_PARAM, uint32, uint32, uint32, uin CORO_BEGIN_CODE(_ctx); Tony->SetPattern(Tony->PAT_SNIFFA_RIGHT); - Tony->WaitForEndPattern(); + CORO_INVOKE_0(Tony->WaitForEndPattern); CORO_INVOKE_4(RightToMe, 0, 0, 0, 0); CORO_END_CODE; @@ -1126,10 +1290,18 @@ DECLARE_CUSTOM_FUNCTION(DisableTony)(CORO_PARAM, uint32 bShowOmbra, uint32, uint } DECLARE_CUSTOM_FUNCTION(WaitForPatternEnd)(CORO_PARAM, uint32 nItem, uint32, uint32, uint32) { - RMItem *item = Loc->GetItemFromCode(nItem); + CORO_BEGIN_CONTEXT; + RMItem *item; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + _ctx->item = Loc->GetItemFromCode(nItem); - if (!bSkipIdle && item != NULL) - item->WaitForEndPattern(hSkipIdle); + if (!bSkipIdle && _ctx->item != NULL) + CORO_INVOKE_1(_ctx->item->WaitForEndPattern, hSkipIdle); + + CORO_END_CODE; } @@ -1383,106 +1555,119 @@ DECLARE_CUSTOM_FUNCTION(CharSetStartEndTalkPattern)(CORO_PARAM, uint32 nChar, ui } DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMessage, uint32 bIsBack, uint32) { - RMMessage msg(dwMessage); - int i; - RMPoint pt; - RMTextDialog *text; - int curOffset = 0; + CORO_BEGIN_CONTEXT; + RMMessage *msg; + int i; + RMPoint pt; + RMTextDialog *text; + int curOffset; + VoiceHeader *curVoc; + FPSFX *voice; + CORO_END_CONTEXT(_ctx); - assert(nChar<16); - pt=Character[nChar].item->CalculatePos()-RMPoint(-60,20)-Loc->ScrollPosition(); + CORO_BEGIN_CODE(_ctx); + + _ctx->msg = new RMMessage(dwMessage); + _ctx->curOffset = 0; + + assert(nChar < 16); + _ctx->pt = Character[nChar].item->CalculatePos() - RMPoint(-60, 20) - Loc->ScrollPosition(); if (Character[nChar].starttalkpattern != 0) { Freeze(); Character[nChar].item->SetPattern(Character[nChar].starttalkpattern); Unfreeze(); - Character[nChar].item->WaitForEndPattern(); + + CORO_INVOKE_0(Character[nChar].item->WaitForEndPattern); } Freeze(); Character[nChar].item->SetPattern(Character[nChar].talkpattern); Unfreeze(); - VoiceHeader *curVoc = SearchVoiceHeader(0, dwMessage); - FPSFX *voice = NULL; - if (curVoc) { + _ctx->curVoc = SearchVoiceHeader(0, dwMessage); + _ctx->voice = NULL; + if (_ctx->curVoc) { // Si posiziona all'interno del database delle voci all'inizio della prima -// fseek(_vm->m_vdbFP, curVoc->offset, SEEK_SET); +// fseek(_vm->m_vdbFP, _ctx->curVoc->offset, SEEK_SET); g_system->lockMutex(vdb); - _vm->_vdbFP.seek(curVoc->offset); - curOffset = curVoc->offset; + _vm->_vdbFP.seek(_ctx->curVoc->offset); + _ctx->curOffset = _ctx->curVoc->offset; g_system->unlockMutex(vdb); } - for (i = 0; ii = 0; _ctx->i<_ctx->msg->NumPeriods() && !bSkipIdle; _ctx->i++) { if (bIsBack) { - curBackText = text = new RMTextDialogScrolling(Loc); + curBackText = _ctx->text = new RMTextDialogScrolling(Loc); if (bTonyIsSpeaking) curBackText->Hide(); } else - text = new RMTextDialog; + _ctx->text = new RMTextDialog; - text->SetInput(Input); + _ctx->text->SetInput(Input); // Skipping - text->SetSkipStatus(!bIsBack); + _ctx->text->SetSkipStatus(!bIsBack); // Allineamento - text->SetAlignType(RMText::HCENTER,RMText::VBOTTOM); + _ctx->text->SetAlignType(RMText::HCENTER,RMText::VBOTTOM); // Colore - text->SetColor(Character[nChar].r,Character[nChar].g,Character[nChar].b); + _ctx->text->SetColor(Character[nChar].r,Character[nChar].g,Character[nChar].b); // Scrive il testo - text->WriteText(msg[i],0); + _ctx->text->WriteText((*_ctx->msg)[_ctx->i],0); // Setta la posizione - text->SetPosition(pt); + _ctx->text->SetPosition(_ctx->pt); // Setta l'always display - if (bAlwaysDisplay) { text->SetAlwaysDisplay(); text->ForceTime(); } + if (bAlwaysDisplay) { _ctx->text->SetAlwaysDisplay(); _ctx->text->ForceTime(); } // Registra il testo - LinkGraphicTask(text); + LinkGraphicTask(_ctx->text); - if (curVoc) { + if (_ctx->curVoc) { g_system->lockMutex(vdb); - _vm->_theSound.CreateSfx(&voice); - _vm->_vdbFP.seek(curOffset); - voice->LoadVoiceFromVDB(_vm->_vdbFP); - voice->SetLoop(false); - if (bIsBack) voice->SetVolume(55); - voice->Play(); - text->SetCustomSkipHandle2(voice->hEndOfBuffer); - curOffset = _vm->_vdbFP.pos(); + _vm->_theSound.CreateSfx(&_ctx->voice); + _vm->_vdbFP.seek(_ctx->curOffset); + _ctx->voice->LoadVoiceFromVDB(_vm->_vdbFP); + _ctx->voice->SetLoop(false); + if (bIsBack) _ctx->voice->SetVolume(55); + _ctx->voice->Play(); + _ctx->text->SetCustomSkipHandle2(_ctx->voice->hEndOfBuffer); + _ctx->curOffset = _vm->_vdbFP.pos(); g_system->unlockMutex(vdb); } // Aspetta la fine della visualizzazione - text->SetCustomSkipHandle(hSkipIdle); - text->WaitForEndDisplay(); + _ctx->text->SetCustomSkipHandle(hSkipIdle); + _ctx->text->WaitForEndDisplay(); - if (curVoc) { - voice->Stop(); - voice->Release(); - voice=NULL; + if (_ctx->curVoc) { + _ctx->voice->Stop(); + _ctx->voice->Release(); + _ctx->voice=NULL; } curBackText=NULL; - delete text; + delete _ctx->text; } if (Character[nChar].endtalkpattern != 0) { Freeze(); Character[nChar].item->SetPattern(Character[nChar].endtalkpattern); Unfreeze(); - Character[nChar].item->WaitForEndPattern(); + CORO_INVOKE_0(Character[nChar].item->WaitForEndPattern); } Freeze(); Character[nChar].item->SetPattern(Character[nChar].standpattern); Unfreeze(); + delete _ctx->msg; + + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(AddInventory)(CORO_PARAM, uint32 dwCode, uint32, uint32, uint32) { @@ -1698,97 +1883,104 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes int curDialog; DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg, uint32, uint32) { - LPSTR string; - RMTextDialog *text; - int parm; - HANDLE h; - bool bIsBack = false; + CORO_BEGIN_CONTEXT; + LPSTR string; + RMTextDialog *text; + int parm; + HANDLE h; + bool bIsBack; + VoiceHeader *curVoc; + FPSFX *voice; + RMPoint pt; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + _ctx->bIsBack = false; // La SendDialogMessage pu andare in background se un personaggio in MCHAR settato // con la SetAlwaysBack if (nPers != 0 && IsMChar[nPers] && MCharacter[nPers].bAlwaysBack) - bIsBack = true; + _ctx->bIsBack = true; - VoiceHeader *curVoc = SearchVoiceHeader(curDialog, nMsg); - FPSFX *voice = NULL; + _ctx->curVoc = SearchVoiceHeader(curDialog, nMsg); + _ctx->voice = NULL; - if (curVoc) { + if (_ctx->curVoc) { // Si posiziona all'interno del database delle voci all'inizio della prima g_system->lockMutex(vdb); -// fseek(_vm->m_vdbFP, curVoc->offset, SEEK_SET); - _vm->_vdbFP.seek(curVoc->offset); - _vm->_theSound.CreateSfx(&voice); - voice->LoadVoiceFromVDB(_vm->_vdbFP); - voice->SetLoop(false); - if (bIsBack) voice->SetVolume(55); +// fseek(_vm->m_vdbFP, _ctx->curVoc->offset, SEEK_SET); + _vm->_vdbFP.seek(_ctx->curVoc->offset); + _vm->_theSound.CreateSfx(&_ctx->voice); + _ctx->voice->LoadVoiceFromVDB(_vm->_vdbFP); + _ctx->voice->SetLoop(false); + if (_ctx->bIsBack) _ctx->voice->SetVolume(55); g_system->unlockMutex(vdb); } - string = mpalQueryDialogPeriod(nMsg); + _ctx->string = mpalQueryDialogPeriod(nMsg); if (nPers == 0) { - text = new RMTextDialog; - text->SetColor(0,255,0); - text->SetPosition(Tony->Position()-RMPoint(0,130)-Loc->ScrollPosition()); - text->WriteText(string,0); + _ctx->text = new RMTextDialog; + _ctx->text->SetColor(0,255,0); + _ctx->text->SetPosition(Tony->Position()-RMPoint(0,130)-Loc->ScrollPosition()); + _ctx->text->WriteText(_ctx->string,0); if (dwTonyNumTexts > 0) { if (!bTonyInTexts) { if (nTonyNextTalkType != Tony->TALK_NORMAL) { - Tony->StartTalk(nTonyNextTalkType); + CORO_INVOKE_1(Tony->StartTalk, nTonyNextTalkType); if (!bStaticTalk) nTonyNextTalkType = Tony->TALK_NORMAL; } else - Tony->StartTalk(Tony->TALK_NORMAL); + CORO_INVOKE_1(Tony->StartTalk, Tony->TALK_NORMAL); bTonyInTexts = true; } dwTonyNumTexts--; } else { - Tony->StartTalk(nTonyNextTalkType); + CORO_INVOKE_1(Tony->StartTalk, nTonyNextTalkType); if (!bStaticTalk) nTonyNextTalkType = Tony->TALK_NORMAL; } } else if (!IsMChar[nPers]) { - RMPoint pt; - - text = new RMTextDialog; + _ctx->text = new RMTextDialog; - pt=Character[nPers].item->CalculatePos()-RMPoint(-60,20)-Loc->ScrollPosition(); + _ctx->pt = Character[nPers].item->CalculatePos() - RMPoint(-60, 20) - Loc->ScrollPosition(); if (Character[nPers].starttalkpattern != 0) { Freeze(); Character[nPers].item->SetPattern(Character[nPers].starttalkpattern); Unfreeze(); - Character[nPers].item->WaitForEndPattern(); + CORO_INVOKE_0(Character[nPers].item->WaitForEndPattern); } Character[nPers].item->SetPattern(Character[nPers].talkpattern); - text->SetColor(Character[nPers].r,Character[nPers].g,Character[nPers].b); - text->WriteText(string,0); - text->SetPosition(pt); + _ctx->text->SetColor(Character[nPers].r, Character[nPers].g,Character[nPers].b); + _ctx->text->WriteText(_ctx->string, 0); + _ctx->text->SetPosition(_ctx->pt); } else { RMPoint pt; - if (MCharacter[nPers].x==-1) - pt=MCharacter[nPers].item->CalculatePos()-RMPoint(-60,20)-Loc->ScrollPosition(); + if (MCharacter[nPers].x == -1) + pt = MCharacter[nPers].item->CalculatePos() - RMPoint(-60, 20) - Loc->ScrollPosition(); else - pt=RMPoint(MCharacter[nPers].x,MCharacter[nPers].y); + pt = RMPoint(MCharacter[nPers].x, MCharacter[nPers].y); // Parametro per le azioni speciali: random tra le parlate - parm = (MCharacter[nPers].curgroup * 10) + _vm->_randomSource.getRandomNumber( + _ctx->parm = (MCharacter[nPers].curgroup * 10) + _vm->_randomSource.getRandomNumber( MCharacter[nPers].numtalks[MCharacter[nPers].curgroup] - 1) + 1; if (MCharacter[nPers].numtexts != 0 && MCharacter[nPers].bInTexts) { MCharacter[nPers].numtexts--; } else { // Cerca di eseguire la funzione custom per inizializzare la parlata - h = mpalQueryDoAction(30, MCharacter[nPers].item->MpalCode(), parm); - if (h != INVALID_HANDLE_VALUE) - WaitForSingleObject(h,INFINITE); + _ctx->h = mpalQueryDoAction(30, MCharacter[nPers].item->MpalCode(), _ctx->parm); + if (_ctx->h != INVALID_HANDLE_VALUE) + WaitForSingleObject(_ctx->h,INFINITE); - MCharacter[nPers].curTalk = parm; + MCharacter[nPers].curTalk = _ctx->parm; if (MCharacter[nPers].numtexts != 0) { MCharacter[nPers].bInTexts = true; @@ -1797,39 +1989,39 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg } if (MCharacter[nPers].bAlwaysBack) { - text = curBackText = new RMTextDialogScrolling(Loc); + _ctx->text = curBackText = new RMTextDialogScrolling(Loc); if (bTonyIsSpeaking) curBackText->Hide(); - bIsBack = true; + _ctx->bIsBack = true; } else - text = new RMTextDialog; + _ctx->text = new RMTextDialog; - text->SetSkipStatus(!MCharacter[nPers].bAlwaysBack); - text->SetColor(MCharacter[nPers].r,MCharacter[nPers].g,MCharacter[nPers].b); - text->WriteText(string,0); - text->SetPosition(pt); + _ctx->text->SetSkipStatus(!MCharacter[nPers].bAlwaysBack); + _ctx->text->SetColor(MCharacter[nPers].r,MCharacter[nPers].g,MCharacter[nPers].b); + _ctx->text->WriteText(_ctx->string,0); + _ctx->text->SetPosition(pt); } if (!bSkipIdle) { - text->SetInput(Input); - if (bAlwaysDisplay) { text->SetAlwaysDisplay(); text->ForceTime(); } - text->SetAlignType(RMText::HCENTER,RMText::VBOTTOM); - LinkGraphicTask(text); - - if (curVoc) { - voice->Play(); - text->SetCustomSkipHandle2(voice->hEndOfBuffer); + _ctx->text->SetInput(Input); + if (bAlwaysDisplay) { _ctx->text->SetAlwaysDisplay(); _ctx->text->ForceTime(); } + _ctx->text->SetAlignType(RMText::HCENTER,RMText::VBOTTOM); + LinkGraphicTask(_ctx->text); + + if (_ctx->curVoc) { + _ctx->voice->Play(); + _ctx->text->SetCustomSkipHandle2(_ctx->voice->hEndOfBuffer); } // Aspetta la fine della visualizzazione - text->SetCustomSkipHandle(hSkipIdle); - text->WaitForEndDisplay(); + _ctx->text->SetCustomSkipHandle(hSkipIdle); + _ctx->text->WaitForEndDisplay(); } - if (curVoc) { - voice->Stop(); - voice->Release(); - voice=NULL; + if (_ctx->curVoc) { + _ctx->voice->Stop(); + _ctx->voice->Release(); + _ctx->voice=NULL; } if (nPers != 0) { @@ -1838,37 +2030,39 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg Freeze(); Character[nPers].item->SetPattern(Character[nPers].endtalkpattern); Unfreeze(); - Character[nPers].item->WaitForEndPattern(); + CORO_INVOKE_0(Character[nPers].item->WaitForEndPattern); } Character[nPers].item->SetPattern(Character[nPers].standpattern); - delete text; + delete _ctx->text; } else { if ((MCharacter[nPers].bInTexts && MCharacter[nPers].numtexts== 0) || !MCharacter[nPers].bInTexts) { // Cerca di eseguire la funzione custom per chiudere la parlata MCharacter[nPers].curTalk = (MCharacter[nPers].curTalk%10) + MCharacter[nPers].curgroup*10; - h = mpalQueryDoAction(31,MCharacter[nPers].item->MpalCode(),MCharacter[nPers].curTalk); - if (h!=INVALID_HANDLE_VALUE) - WaitForSingleObject(h,INFINITE); + _ctx->h = mpalQueryDoAction(31,MCharacter[nPers].item->MpalCode(),MCharacter[nPers].curTalk); + if (_ctx->h!=INVALID_HANDLE_VALUE) + WaitForSingleObject(_ctx->h,INFINITE); MCharacter[nPers].bInTexts = false; MCharacter[nPers].numtexts = 0; } curBackText = NULL; - delete text; + delete _ctx->text; } } else { if ((dwTonyNumTexts== 0 && bTonyInTexts) || !bTonyInTexts) { - Tony->EndTalk(); + CORO_INVOKE_0(Tony->EndTalk); dwTonyNumTexts = 0; bTonyInTexts = false; } - delete text; + delete _ctx->text; } - GlobalFree(string); + GlobalFree(_ctx->string); + + CORO_END_CODE; } diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 9a2f4cfe6a..e6914ebc87 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -705,8 +705,9 @@ bool RMItem::DoFrame(RMGfxTargetBuffer *bigBuf, bool bAddToList) { return false; // Facciamo un update del pattern, che ci ritorna anche il frame corrente + // FIXME: Get rid of HANDLE cast if (m_nCurPattern != 0) - m_nCurSprite=m_patterns[m_nCurPattern].Update(m_hEndPattern,m_bCurFlag, m_sfx); + m_nCurSprite = m_patterns[m_nCurPattern].Update((HANDLE)m_hEndPattern, m_bCurFlag, m_sfx); // Se la funzione ha ritornato -1, vuol dire che il pattern e' finito if (m_nCurSprite == -1) { @@ -831,30 +832,36 @@ RMItem::RMItem() { m_nSprites = 0; m_nSfx = 0; m_nPatterns = 0; - m_hEndPattern = 0; m_bPal = 0; m_nCurSprite = 0; - m_hEndPattern = CreateEvent(NULL, false, false, NULL); + m_hEndPattern = _vm->_scheduler.createEvent(false, false); } RMItem::~RMItem() { - Unload(); - CloseHandle(m_hEndPattern); + Unload(); + _vm->_scheduler.closeEvent(m_hEndPattern); } -void RMItem::WaitForEndPattern(HANDLE hCustomSkip) { +//FIXME: Pass uint32 directly for hCustomSkip +void RMItem::WaitForEndPattern(CORO_PARAM, HANDLE hCustomSkip) { + CORO_BEGIN_CONTEXT; + uint32 h[2]; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + if (m_nCurPattern != 0) { if (hCustomSkip == INVALID_HANDLE_VALUE) - WaitForSingleObject(m_hEndPattern,INFINITE); + CORO_INVOKE_2(_vm->_scheduler.waitForSingleObject, m_hEndPattern, INFINITE); else { - HANDLE h[2]; - - h[0] = hCustomSkip; - h[1] = m_hEndPattern; - WaitForMultipleObjects(2, h, false, INFINITE); + _ctx->h[0] = (uint32)hCustomSkip; + _ctx->h[1] = m_hEndPattern; + CORO_INVOKE_4(_vm->_scheduler.waitForMultipleObjects, 2, &_ctx->h[0], false, INFINITE); } } + + CORO_END_CODE; } void RMItem::ChangeHotspot(RMPoint pt) { diff --git a/engines/tony/loc.h b/engines/tony/loc.h index 9ed1a284d1..3a312a0d3c 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -52,6 +52,7 @@ #include "common/system.h" #include "common/file.h" #include "tony/mpal/stubs.h" +#include "tony/sched.h" #include "tony/sound.h" #include "tony/utils.h" @@ -245,7 +246,7 @@ private: byte m_bCurFlag; int m_nCurSprite; bool m_bIsActive; - HANDLE m_hEndPattern; + uint32 m_hEndPattern; bool m_bInitCurPattern; public: @@ -291,7 +292,7 @@ public: void Unload(void); // Aspetta la fine del pattern in play - void WaitForEndPattern(HANDLE hCustomSkip = INVALID_HANDLE_VALUE); + void WaitForEndPattern(CORO_PARAM, HANDLE hCustomSkip = INVALID_HANDLE_VALUE); // Setta un nuovo hotspot per l'oggetto void ChangeHotspot(RMPoint pt); diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 592c4788df..c5ded67c81 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -141,8 +141,8 @@ uint32 nPollingLocations[MAXPOLLINGLOCATIONS]; HANDLE hEndPollingLocations[MAXPOLLINGLOCATIONS]; uint32 PollingThreads[MAXPOLLINGLOCATIONS]; -HANDLE hAskChoice; -HANDLE hDoneChoice; +uint32 hAskChoice; +uint32 hDoneChoice; uint32 nExecutingAction; @@ -1349,7 +1349,7 @@ void ShutUpDialogThread(CORO_PARAM, const void *param) { nExecutingDialog = 0; nExecutingChoice = 0; - SetEvent(hAskChoice); + _vm->_scheduler.setEvent(hAskChoice); CORO_KILL_SELF(); @@ -1501,9 +1501,9 @@ void DoChoice(CORO_PARAM, uint32 nChoice) { /* Avvertiamo il gioco che c'e' una scelta da far fare all'utente, e restiamo in attesa della risposta */ - ResetEvent(hDoneChoice); - SetEvent(hAskChoice); - WaitForSingleObject(hDoneChoice, INFINITE); + _vm->_scheduler.resetEvent(hDoneChoice); + _vm->_scheduler.setEvent(hAskChoice); + CORO_INVOKE_2(_vm->_scheduler.waitForSingleObject, hDoneChoice, INFINITE); /* Ora che la scelta e' stata effettuata, possiamo eseguire _ctx->i gruppi associati con la scelta */ @@ -1644,8 +1644,8 @@ static uint32 DoDialog(uint32 nDlgOrd, uint32 nGroup) { // Enables the flag to indicate that there is' a running dialogue bExecutingDialog = true; - ResetEvent(hAskChoice); - ResetEvent(hDoneChoice); + _vm->_scheduler.resetEvent(hAskChoice); + _vm->_scheduler.resetEvent(hDoneChoice); // Create a thread that performs the dialogue group @@ -1690,7 +1690,7 @@ bool DoSelection(uint32 i, uint32 dwData) { return false; nSelectedChoice = j; - SetEvent(hDoneChoice); + _vm->_scheduler.setEvent(hDoneChoice); return true; } @@ -1867,8 +1867,8 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, /* Crea l'evento che verra' utilizzato per avvertire il gioco che c'e' da effettuare una scelta */ - hAskChoice = CreateEvent(NULL, true, false, NULL); - hDoneChoice = CreateEvent(NULL, true, false, NULL); + hAskChoice = _vm->_scheduler.createEvent(true, false); + hDoneChoice = _vm->_scheduler.createEvent(true, false); return true; } @@ -2031,8 +2031,9 @@ void mpalQueryInner(CORO_PARAM, uint16 wQueryType, uint32 *dwRet, va_list v) { /* * void mpalQuery(MPQ_DIALOG_WAITFORCHOICE); */ - WaitForSingleObject(hAskChoice, INFINITE); - ResetEvent(hAskChoice); + CORO_INVOKE_2(_vm->_scheduler.waitForSingleObject, hAskChoice, INFINITE); + + _vm->_scheduler.resetEvent(hAskChoice); if (bExecutingDialog) *dwRet = (uint32)nExecutingChoice; diff --git a/engines/tony/mpal/stubs.cpp b/engines/tony/mpal/stubs.cpp index 0fc01d4d07..58ecc6d6d9 100644 --- a/engines/tony/mpal/stubs.cpp +++ b/engines/tony/mpal/stubs.cpp @@ -90,16 +90,20 @@ uint32 WaitForMultipleObjects(uint32 nCount, const HANDLE *lpHandles, bool bWait } HANDLE CreateEvent(void *lpEventAttributes, bool bManualReset, bool bInitialState, const char *lpName) { + warning("TODO: Refactor call to old style CreateEvent method"); return 0; } void SetEvent(HANDLE hEvent) { + warning("TODO: Refactor call to old style SetEvent method"); } void ResetEvent(HANDLE hEvent) { + warning("TODO: Refactor call to old style ResetEvent method"); } void PulseEvent(HANDLE hEvent) { + warning("TODO: Refactor call to old style PulseEvent method"); } uint16 GetAsyncKeyState(Common::KeyCode kc) { diff --git a/engines/tony/sched.cpp b/engines/tony/sched.cpp index 41531bf225..199f5991ce 100644 --- a/engines/tony/sched.cpp +++ b/engines/tony/sched.cpp @@ -67,6 +67,11 @@ Scheduler::~Scheduler() { delete active; active = 0; + + // Clear the event list + Common::List::iterator i; + for (i = _events.begin(); i != _events.end(); ++i) + delete (*i); } /** @@ -292,39 +297,52 @@ void Scheduler::giveWay(PPROCESS pReSchedProc) { } /** - * Continously makes a given process wait for another process to finish + * Continously makes a given process wait for another process to finish or event to signal. * - * @param pid Process identifier + * @param pid Process/Event identifier * @param duration Duration in milliseconds - * @param expired Set to true if delay period expired + * @param expired If specified, set to true if delay period expired */ -void Scheduler::waitForSingleObject(CORO_PARAM, int pid, int duration, bool *expired) { +void Scheduler::waitForSingleObject(CORO_PARAM, int pid, uint32 duration, bool *expired) { if (!pCurrent) error("Called Scheduler::waitForSingleObject from the main process"); CORO_BEGIN_CONTEXT; uint32 endTime; - PROCESS *pProc; + PROCESS *pProcess; + EVENT *pEvent; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); _ctx->endTime = (duration == INFINITE) ? INFINITE : g_system->getMillis() + duration; if (expired) - *expired = false; + // Presume it will expire + *expired = true; // Outer loop for doing checks until expiry while (g_system->getMillis() < _ctx->endTime) { - // Check to see if a process with the given Id exists - _ctx->pProc = active->pNext; - while ((_ctx->pProc != NULL) && (_ctx->pProc->pid != pid)) - _ctx->pProc = _ctx->pProc->pNext; + // Check to see if a process or event with the given Id exists + _ctx->pProcess = getProcess(pid); + _ctx->pEvent = !_ctx->pProcess ? getEvent(pid) : NULL; - if (_ctx->pProc == NULL) { - // No match process found, so it's okay to break out of loop + // If there's no active process or event, presume it's a process that's finished, + // so the waiting can immediately exit + if ((_ctx->pProcess == NULL) && (_ctx->pEvent == NULL)) { if (expired) - *expired = true; + *expired = false; + break; + } + + // If a process was found, don't go into the if statement, and keep waiting. + // Likewise if it's an event that's not yet signalled + if ((_ctx->pEvent != NULL) && _ctx->pEvent->signalled) { + // Unless the event is flagged for manual reset, reset it now + if (!_ctx->pEvent->manualReset) + _ctx->pEvent->signalled = false; + if (expired) + *expired = false; break; } @@ -335,6 +353,76 @@ void Scheduler::waitForSingleObject(CORO_PARAM, int pid, int duration, bool *exp CORO_END_CODE; } +/** + * Continously makes a given process wait for given prcesses to finished or events to be set + * + * @param nCount Number of Id's being passed + * @param evtList List of pids to wait for + * @param bWaitAll Specifies whether all or any of the processes/events + * @param duration Duration in milliseconds + * @param expired Set to true if delay period expired + */ +void Scheduler::waitForMultipleObjects(CORO_PARAM, int nCount, uint32 *pidList, bool bWaitAll, + uint32 duration, bool *expired) { + if (!pCurrent) + error("Called Scheduler::waitForMultipleEvents from the main process"); + + CORO_BEGIN_CONTEXT; + uint32 endTime; + bool signalled; + bool pidSignalled; + int i; + PROCESS *pProcess; + EVENT *pEvent; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + _ctx->endTime = (duration == INFINITE) ? INFINITE : g_system->getMillis() + duration; + if (expired) + // Presume that delay will expire + *expired = true; + + // Outer loop for doing checks until expiry + while (g_system->getMillis() < _ctx->endTime) { + _ctx->signalled = bWaitAll; + + for (_ctx->i = 0; _ctx->i < nCount; ++_ctx->i) { + _ctx->pProcess = getProcess(pidList[_ctx->i]); + _ctx->pEvent = !_ctx->pProcess ? getEvent(pidList[_ctx->i]) : NULL; + + // Determine the signalled state + _ctx->pidSignalled = (_ctx->pProcess) || !_ctx->pEvent ? false : _ctx->pEvent->signalled; + + if (bWaitAll && _ctx->pidSignalled) + _ctx->signalled = false; + else if (!bWaitAll & _ctx->pidSignalled) + _ctx->signalled = true; + } + + // At this point, if the signalled variable is set, waiting is finished + if (_ctx->signalled) { + // Automatically reset any events not flagged for manual reset + for (_ctx->i = 0; _ctx->i < nCount; ++_ctx->i) { + _ctx->pEvent = getEvent(pidList[_ctx->i]); + + if (_ctx->pEvent->manualReset) + _ctx->pEvent->signalled = false; + } + + if (expired) + *expired = false; + break; + } + + // Sleep until the next cycle + CORO_SLEEP(1); + } + + CORO_END_CODE; +} + + /** * Creates a new process. * @@ -541,4 +629,72 @@ void Scheduler::setResourceCallback(VFPTRPP pFunc) { pRCfunction = pFunc; } +PROCESS *Scheduler::getProcess(uint32 pid) { + PROCESS *pProc = active->pNext; + while ((pProc != NULL) && (pProc->pid != pid)) + pProc = pProc->pNext; + + return pProc; +} + +EVENT *Scheduler::getEvent(uint32 pid) { + Common::List::iterator i; + for (i = _events.begin(); i != _events.end(); ++i) { + EVENT *evt = *i; + if (evt->pid == pid) + return evt; + } + + return NULL; +} + + +/** + * Creates a new event object + * @param bManualReset Events needs to be manually reset. Otherwise, events + * will be automatically reset after a process waits on the event finishes + * @param bInitialState Specifies whether the event is signalled or not initially + */ +uint32 Scheduler::createEvent(bool bManualReset, bool bInitialState) { + EVENT *evt = new EVENT(); + evt->pid = ++pidCounter; + evt->manualReset = bManualReset; + evt->signalled = bInitialState; + + _events.push_back(evt); + return evt->pid; +} + +/** + * Destroys the given event + * @param pidEvent Event PID + */ +void Scheduler::closeEvent(uint32 pidEvent) { + EVENT *evt = getEvent(pidEvent); + if (evt) { + _events.remove(evt); + delete evt; + } +} + +/** + * Sets the event + * @param pidEvent Event PID + */ +void Scheduler::setEvent(uint32 pidEvent) { + EVENT *evt = getEvent(pidEvent); + if (evt) + evt->signalled = true; +} + +/** + * Resets the event + * @param pidEvent Event PID + */ +void Scheduler::resetEvent(uint32 pidEvent) { + EVENT *evt = getEvent(pidEvent); + if (evt) + evt->signalled = false; +} + } // End of namespace Tony diff --git a/engines/tony/sched.h b/engines/tony/sched.h index 54f44aa5fd..80df1eb942 100644 --- a/engines/tony/sched.h +++ b/engines/tony/sched.h @@ -24,6 +24,7 @@ #ifndef TONY_SCHED_H #define TONY_SCHED_H +#include "common/list.h" #include "tony/coroutine.h" namespace Tony { @@ -48,13 +49,20 @@ struct PROCESS { CORO_ADDR coroAddr; ///< the entry point of the coroutine int sleepTime; ///< number of scheduler cycles to sleep - int pid; ///< process ID + uint32 pid; ///< process ID char param[PARAM_SIZE]; ///< process specific info }; typedef PROCESS *PPROCESS; struct INT_CONTEXT; +/** Event structure */ +struct EVENT { + uint32 pid; + bool manualReset; + bool signalled; +}; + /** * Create and manage "processes" (really coroutines). */ @@ -80,6 +88,8 @@ private: /** Auto-incrementing process Id */ int pidCounter; + /** Event list */ + Common::List _events; #ifdef DEBUG // diagnostic process counters @@ -95,7 +105,8 @@ private: */ VFPTRPP pRCfunction; - + PROCESS *getProcess(uint32 pid); + EVENT *getEvent(uint32 pid); public: Scheduler(); @@ -111,7 +122,9 @@ public: void rescheduleAll(); void reschedule(PPROCESS pReSchedProc = NULL); void giveWay(PPROCESS pReSchedProc = NULL); - void waitForSingleObject(CORO_PARAM, int pid, int duration, bool *delay = NULL); + void waitForSingleObject(CORO_PARAM, int pid, uint32 duration, bool *expired = NULL); + void waitForMultipleObjects(CORO_PARAM, int nCount, uint32 *pidList, bool bWaitAll, + uint32 duration, bool *expired = NULL); uint32 createProcess(CORO_ADDR coroAddr, const void *pParam, int sizeParam); uint32 createProcess(CORO_ADDR coroAddr, const void *pParam) { @@ -123,9 +136,13 @@ public: int getCurrentPID() const; int killMatchingProcess(int pidKill, int pidMask = -1); - void setResourceCallback(VFPTRPP pFunc); + /* Event methods */ + uint32 createEvent(bool bManualReset, bool bInitialState); + void closeEvent(uint32 pidEvent); + void setEvent(uint32 pidEvent); + void resetEvent(uint32 pidEvent); }; extern Scheduler *g_scheduler; // FIXME: Temporary global var, to be used until everything has been OOifyied diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index de6189876b..073ebf2be4 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -519,10 +519,8 @@ void RMTony::Put(int nWhere, int nPart) { } -void RMTony::StartTalk(TALKTYPE nTalkType) { - int headStartPat = 0, bodyStartPat = 0; - int headLoopPat = 0, bodyLoopPat = 0; - +bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &bodyStartPat, + int &headLoopPat, int &bodyLoopPat) { assert(!m_bIsTalking); m_bIsTalking = true; @@ -585,7 +583,7 @@ void RMTony::StartTalk(TALKTYPE nTalkType) { break; } MainUnfreeze(); - return; + return false; } headStartPat = bodyStartPat = 0; @@ -1077,35 +1075,47 @@ void RMTony::StartTalk(TALKTYPE nTalkType) { } break; } +} + +void RMTony::StartTalk(CORO_PARAM, TALKTYPE nTalkType) { + CORO_BEGIN_CONTEXT; + int headStartPat, bodyStartPat; + int headLoopPat, bodyLoopPat; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + _ctx->headStartPat = _ctx->bodyStartPat = 0; + _ctx->headLoopPat = _ctx->bodyLoopPat = 0; + + if (!StartTalkCalculate(nTalkType, _ctx->headStartPat, _ctx->bodyStartPat, + _ctx->headLoopPat, _ctx->bodyLoopPat)) + return; // Esegue il set dei pattern vero e proprio - if (headStartPat != 0 || bodyStartPat != 0) { + if (_ctx->headStartPat != 0 || _ctx->bodyStartPat != 0) { MainFreeze(); - SetPattern(headStartPat); - m_body.SetPattern(bodyStartPat); + SetPattern(_ctx->headStartPat); + m_body.SetPattern(_ctx->bodyStartPat); MainUnfreeze(); - if (bodyStartPat!=0) - m_body.WaitForEndPattern(); - if (headStartPat!=0) - WaitForEndPattern(); + if (_ctx->bodyStartPat != 0) + CORO_INVOKE_0(m_body.WaitForEndPattern); + if (_ctx->headStartPat != 0) + CORO_INVOKE_0(WaitForEndPattern); } MainFreeze(); - SetPattern(headLoopPat); - if (bodyLoopPat) - m_body.SetPattern(bodyLoopPat); + SetPattern(_ctx->headLoopPat); + if (_ctx->bodyLoopPat) + m_body.SetPattern(_ctx->bodyLoopPat); MainUnfreeze(); -} + CORO_END_CODE; +} -void RMTony::EndTalk(void) { - int headStandPat = 0; - int headEndPat = 0; - int bodyEndPat = 0; - int finalPat = 0; - bool bStatic = false; +bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPat, int &finalPat, bool &bStatic) { bodyEndPat = 0; headEndPat = 0; @@ -1136,7 +1146,7 @@ void RMTony::EndTalk(void) { SetPattern(finalPat); MainUnfreeze(); m_bIsTalking = false; - return; + return false; } @@ -1379,6 +1389,28 @@ void RMTony::EndTalk(void) { break; } + return true; +} + +void RMTony::EndTalk(CORO_PARAM) { + CORO_BEGIN_CONTEXT; + int headStandPat, headEndPat; + int bodyEndPat, finalPat; + bool bStatic; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + _ctx->headStandPat = _ctx->headEndPat = 0; + _ctx->bodyEndPat = _ctx->finalPat = 0; + _ctx->bStatic = false; + + _ctx->bodyEndPat = 0; + _ctx->headEndPat = 0; + + if (!EndTalkCalculate(_ctx->headStandPat, _ctx->headEndPat, _ctx->bodyEndPat, _ctx->finalPat, _ctx->bStatic)) + return; + // Gestisce la fine di una animazione static lasciando tutto invariato if (m_bIsStaticTalk) { if (m_nTalkType == TALK_CONBARBASTATIC) { @@ -1394,10 +1426,10 @@ void RMTony::EndTalk(void) { MainUnfreeze(); } else { MainFreeze(); - SetPattern(headStandPat); + SetPattern(_ctx->headStandPat); MainUnfreeze(); - m_body.WaitForEndPattern(); + CORO_INVOKE_0(m_body.WaitForEndPattern); } m_bIsTalking = false; @@ -1405,60 +1437,58 @@ void RMTony::EndTalk(void) { } // Set dei pattern - if (headEndPat != 0 && bodyEndPat != 0) { + if (_ctx->headEndPat != 0 && _ctx->bodyEndPat != 0) { MainFreeze(); - SetPattern(headEndPat); + SetPattern(_ctx->headEndPat); MainUnfreeze(); - m_body.WaitForEndPattern(); + CORO_INVOKE_0(m_body.WaitForEndPattern); MainFreeze(); - m_body.SetPattern(bodyEndPat); + m_body.SetPattern(_ctx->bodyEndPat); MainUnfreeze(); - WaitForEndPattern(); - m_body.WaitForEndPattern(); - } else if (bodyEndPat != 0) { + CORO_INVOKE_0(WaitForEndPattern); + CORO_INVOKE_0(m_body.WaitForEndPattern); + } else if (_ctx->bodyEndPat != 0) { MainFreeze(); - SetPattern(headStandPat); + SetPattern(_ctx->headStandPat); MainUnfreeze(); - m_body.WaitForEndPattern(); + CORO_INVOKE_0(m_body.WaitForEndPattern); MainFreeze(); - m_body.SetPattern(bodyEndPat); + m_body.SetPattern(_ctx->bodyEndPat); MainUnfreeze(); - m_body.WaitForEndPattern(); - } else if (headEndPat != 0) { - m_body.WaitForEndPattern(); + CORO_INVOKE_0(m_body.WaitForEndPattern); + } else if (_ctx->headEndPat != 0) { + CORO_INVOKE_0(m_body.WaitForEndPattern); MainFreeze(); - SetPattern(headEndPat); + SetPattern(_ctx->headEndPat); MainUnfreeze(); - WaitForEndPattern(); + CORO_INVOKE_0(WaitForEndPattern); } else { - m_body.WaitForEndPattern(); + CORO_INVOKE_0(m_body.WaitForEndPattern); } - if (finalPat != 0) { + if (_ctx->finalPat != 0) { MainFreeze(); m_body.SetPattern(0); - SetPattern(finalPat); + SetPattern(_ctx->finalPat); MainUnfreeze(); } m_bIsTalking = false; -} -void RMTony::StartStatic(TALKTYPE nTalk) { - int nPat = 0; - int headPat = 0, headLoopPat = 0; - int bodyStartPat = 0; - int bodyLoopPat = 0; + CORO_END_CODE; +} - nPat = GetCurPattern(); +void RMTony::StartStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat, + int &bodyStartPat, int &bodyLoopPat) { + int nPat = GetCurPattern(); headLoopPat = -1; @@ -1661,31 +1691,41 @@ void RMTony::StartStatic(TALKTYPE nTalk) { default: break; } +} + +void RMTony::StartStatic(CORO_PARAM, TALKTYPE nTalk) { + CORO_BEGIN_CONTEXT; + int headPat, headLoopPat; + int bodyStartPat, bodyLoopPat; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + _ctx->headPat = _ctx->headLoopPat = 0; + _ctx->bodyStartPat = _ctx->bodyLoopPat = 0; // e vai con i pattern m_bIsStaticTalk = true; MainFreeze(); - SetPattern(headPat); - m_body.SetPattern(bodyStartPat); + SetPattern(_ctx->headPat); + m_body.SetPattern(_ctx->bodyStartPat); MainUnfreeze(); - m_body.WaitForEndPattern(); - WaitForEndPattern(); + CORO_INVOKE_0(m_body.WaitForEndPattern); + CORO_INVOKE_0(WaitForEndPattern); MainFreeze(); - if (headLoopPat != -1) - SetPattern(headLoopPat); - m_body.SetPattern(bodyLoopPat); + if (_ctx->headLoopPat != -1) + SetPattern(_ctx->headLoopPat); + m_body.SetPattern(_ctx->bodyLoopPat); MainUnfreeze(); -} + CORO_END_CODE; +} -void RMTony::EndStatic(TALKTYPE nTalk) { - int bodyEndPat = 0; - int finalPat = 0; - int headEndPat = 0; +void RMTony::EndStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, int &headEndPat) { switch (m_TalkDirection) { case UP: case LEFT: @@ -1818,28 +1858,46 @@ void RMTony::EndStatic(TALKTYPE nTalk) { default: break; } +} + +void RMTony::EndStatic(CORO_PARAM, TALKTYPE nTalk) { + CORO_BEGIN_CONTEXT; + int bodyEndPat; + int finalPat; + int headEndPat; + CORO_END_CONTEXT(_ctx); - if (headEndPat != 0) { + CORO_BEGIN_CODE(_ctx); + + _ctx->bodyEndPat = 0; + _ctx->finalPat = 0; + _ctx->headEndPat = 0; + + EndStaticCalculate(nTalk, _ctx->bodyEndPat, _ctx->finalPat, _ctx->headEndPat); + + if (_ctx->headEndPat != 0) { MainFreeze(); - SetPattern(headEndPat); + SetPattern(_ctx->headEndPat); MainUnfreeze(); - WaitForEndPattern(); + CORO_INVOKE_0(WaitForEndPattern); } else { // Play please MainFreeze(); - m_body.SetPattern(bodyEndPat); + m_body.SetPattern(_ctx->bodyEndPat); MainUnfreeze(); - m_body.WaitForEndPattern(); + CORO_INVOKE_0(m_body.WaitForEndPattern); } MainFreeze(); - SetPattern(finalPat); + SetPattern(_ctx->finalPat); m_body.SetPattern(0); MainUnfreeze(); m_bIsStaticTalk = false; + + CORO_END_CODE; } } // End of namespace Tony diff --git a/engines/tony/tonychar.h b/engines/tony/tonychar.h index 266b34e697..2cbcf60a00 100644 --- a/engines/tony/tonychar.h +++ b/engines/tony/tonychar.h @@ -408,7 +408,9 @@ public: int GetCurPattern(); // Attende la fine di un pattern - void WaitForEndPattern(HANDLE hCustomSkip = INVALID_HANDLE_VALUE) { RMCharacter::WaitForEndPattern(hCustomSkip);} + void WaitForEndPattern(CORO_PARAM, HANDLE hCustomSkip = INVALID_HANDLE_VALUE) { + RMCharacter::WaitForEndPattern(coroParam, hCustomSkip); + } // Controlla se si trova in azione bool InAction() { return (m_bActionPending&&m_Action != 0) | m_bAction; } @@ -427,12 +429,18 @@ public: void Put(int nWhere, int nPart); // Start e End Talk - void StartTalk(TALKTYPE nTalkType); - void EndTalk(void); + bool StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &bodyStartPat, + int &headLoopPat, int &bodyLoopPat); + void StartTalk(CORO_PARAM, TALKTYPE nTalkType); + bool EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPat, int &finalPat, bool &bStatic); + void EndTalk(CORO_PARAM); // Start e End Static - void StartStatic(TALKTYPE nTalkType); - void EndStatic(TALKTYPE nTalkType); + void StartStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat, + int &bodyStartPat, int &bodyLoopPat); + void StartStatic(CORO_PARAM, TALKTYPE nTalkType); + void EndStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, int &headEndPat); + void EndStatic(CORO_PARAM, TALKTYPE nTalkType); // Tony si traveste! void SetPastorella(bool bIsPast) { m_bPastorella=bIsPast; } -- cgit v1.2.3 From a254f100253bda1b23f280226b7b4d909206d49c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 8 May 2012 09:32:21 +1000 Subject: TONY: Added support for Windows-style threading events to scheduler --- engines/tony/custom.cpp | 9 +++++- engines/tony/loc.cpp | 30 ++++++++++++++------ engines/tony/loc.h | 4 +-- engines/tony/mpal/mpal.cpp | 50 ++++++++++++++++---------------- engines/tony/sched.cpp | 71 ++++++++++++++++++++++++++++++++++++++++++++-- engines/tony/sched.h | 4 ++- engines/tony/tony.cpp | 2 +- engines/tony/tonychar.cpp | 14 +++++---- 8 files changed, 137 insertions(+), 47 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 800b5d8d50..18a92899df 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -1310,10 +1310,17 @@ DECLARE_CUSTOM_FUNCTION(SetTonyPosition)(CORO_PARAM, uint32 nX, uint32 nY, uint3 } DECLARE_CUSTOM_FUNCTION(MoveTonyAndWait)(CORO_PARAM, uint32 nX, uint32 nY, uint32, uint32) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + Tony->Move(RMPoint(nX, nY)); if (!bSkipIdle) - Tony->WaitForEndMovement(); + CORO_INVOKE_0(Tony->WaitForEndMovement); + + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(MoveTony)(CORO_PARAM, uint32 nX, uint32 nY, uint32, uint32) { diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index e6914ebc87..4eced3fbd5 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -835,12 +835,12 @@ RMItem::RMItem() { m_bPal = 0; m_nCurSprite = 0; - m_hEndPattern = _vm->_scheduler.createEvent(false, false); + m_hEndPattern = g_scheduler->createEvent(false, false); } RMItem::~RMItem() { Unload(); - _vm->_scheduler.closeEvent(m_hEndPattern); + g_scheduler->closeEvent(m_hEndPattern); } //FIXME: Pass uint32 directly for hCustomSkip @@ -853,11 +853,11 @@ void RMItem::WaitForEndPattern(CORO_PARAM, HANDLE hCustomSkip) { if (m_nCurPattern != 0) { if (hCustomSkip == INVALID_HANDLE_VALUE) - CORO_INVOKE_2(_vm->_scheduler.waitForSingleObject, m_hEndPattern, INFINITE); + CORO_INVOKE_2(g_scheduler->waitForSingleObject, m_hEndPattern, INFINITE); else { _ctx->h[0] = (uint32)hCustomSkip; _ctx->h[1] = m_hEndPattern; - CORO_INVOKE_4(_vm->_scheduler.waitForMultipleObjects, 2, &_ctx->h[0], false, INFINITE); + CORO_INVOKE_4(g_scheduler->waitForMultipleObjects, 2, &_ctx->h[0], false, INFINITE); } } @@ -1082,7 +1082,7 @@ void RMCharacter::GoTo(RMPoint destcoord, bool bReversed) { if (m_pos == destcoord) { if (minpath == 0) { Stop(); - PulseEvent(hEndOfPath); + g_scheduler->pulseEvent(hEndOfPath); return; } } @@ -1458,7 +1458,7 @@ void RMCharacter::DoFrame(RMGfxTargetBuffer* bigBuf, int loc) { if (!bEndOfPath) Stop(); bEndOfPath = true; - PulseEvent(hEndOfPath); + g_scheduler->pulseEvent(hEndOfPath); } walkcount++; @@ -1496,7 +1496,7 @@ void RMCharacter::DoFrame(RMGfxTargetBuffer* bigBuf, int loc) { if (!bEndOfPath) Stop(); bEndOfPath = true; - PulseEvent(hEndOfPath); + g_scheduler->pulseEvent(hEndOfPath); } } else { // Se siamo gi entrati nell'ultimo box, dobbiamo solo muoverci in linea retta verso il @@ -1636,6 +1636,18 @@ void RMCharacter::SetPosition(RMPoint pt, int newloc) { bRemoveFromOT = true; } +void RMCharacter::WaitForEndMovement(CORO_PARAM) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + if (bMoving) + CORO_INVOKE_2(g_scheduler->waitForSingleObject, hEndOfPath, INFINITE); + + CORO_END_CODE; +} + bool RMCharacter::RemoveThis(void) { if (bRemoveFromOT) return true; @@ -1645,7 +1657,7 @@ bool RMCharacter::RemoveThis(void) { RMCharacter::RMCharacter() { csMove = g_system->createMutex(); - hEndOfPath = CreateEvent(NULL, false, false, NULL); + hEndOfPath = g_scheduler->createEvent(false, false); minpath = 0; curSpeed = 3; bRemoveFromOT = false; @@ -1666,7 +1678,7 @@ RMCharacter::RMCharacter() { RMCharacter::~RMCharacter() { g_system->deleteMutex(csMove); - CloseHandle(hEndOfPath); + g_scheduler->closeEvent(hEndOfPath); } void RMCharacter::LinkToBoxes(RMGameBoxes *boxes) { diff --git a/engines/tony/loc.h b/engines/tony/loc.h index 3a312a0d3c..153ef7f18c 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -423,7 +423,7 @@ private: STATUS status; int curSpeed; bool bEndOfPath; - HANDLE hEndOfPath; + uint32 hEndOfPath; OSystem::MutexRef csMove; int curLocation; bool bRemoveFromOT; @@ -482,7 +482,7 @@ public: void SetPosition(RMPoint pt, int newloc=-1); // Aspetta la fine del movimento - void WaitForEndMovement(void) { if (bMoving) WaitForSingleObject(hEndOfPath, INFINITE); } + void WaitForEndMovement(CORO_PARAM); void SetFixedScroll(RMPoint fix) { m_fixedScroll = fix; } void SetSpeed(int speed) { curSpeed=speed; } diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index c5ded67c81..0cea50a3d3 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -961,7 +961,7 @@ void ActionThread(CORO_PARAM, const void *param) { if (item->Command[_ctx->k].type == 1) { // Custom function debugC(DEBUG_DETAILED, kTonyDebugActions, "Action Process %d Call=%s params=%d,%d,%d,%d", - _vm->_scheduler.getCurrentPID(), lplpFunctionStrings[item->Command[_ctx->k].nCf].c_str(), + g_scheduler->getCurrentPID(), lplpFunctionStrings[item->Command[_ctx->k].nCf].c_str(), item->Command[_ctx->k].arg1, item->Command[_ctx->k].arg2, item->Command[_ctx->k].arg3, item->Command[_ctx->k].arg4 ); @@ -976,7 +976,7 @@ void ActionThread(CORO_PARAM, const void *param) { } else if (item->Command[_ctx->k].type == 2) { // Variable assign debugC(DEBUG_DETAILED, kTonyDebugActions, "Action Process %d Variable=%s", - _vm->_scheduler.getCurrentPID(), item->Command[_ctx->k].lpszVarName); + g_scheduler->getCurrentPID(), item->Command[_ctx->k].lpszVarName); LockVar(); varSetValue(item->Command[_ctx->k].lpszVarName, EvaluateExpression(item->Command[_ctx->k].expr)); @@ -991,7 +991,7 @@ void ActionThread(CORO_PARAM, const void *param) { GlobalFree(item); - debugC(DEBUG_DETAILED, kTonyDebugActions, "Action Process %d ended", _vm->_scheduler.getCurrentPID()); + debugC(DEBUG_DETAILED, kTonyDebugActions, "Action Process %d ended", g_scheduler->getCurrentPID()); CORO_KILL_SELF(); @@ -1012,7 +1012,7 @@ void ShutUpActionThread(CORO_PARAM, const void *param) { CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_2(_vm->_scheduler.waitForSingleObject, pid, INFINITE); + CORO_INVOKE_2(g_scheduler->waitForSingleObject, pid, INFINITE); bExecutingAction = false; @@ -1190,7 +1190,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) if (_ctx->MyThreads[_ctx->i].nItem != 0) { - CORO_INVOKE_3(_vm->_scheduler.waitForSingleObject, _ctx->MyThreads[_ctx->i].hThread, 0, &_ctx->delayExpired); + CORO_INVOKE_3(g_scheduler->waitForSingleObject, _ctx->MyThreads[_ctx->i].hThread, 0, &_ctx->delayExpired); // if result ) == WAIT_OBJECT_0) if (!_ctx->delayExpired) @@ -1261,7 +1261,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { _ctx->MyThreads[_ctx->i].nItem = _ctx->MyActions[_ctx->k].nItem; // !!! Nuova gestione dei thread - if ((_ctx->MyThreads[_ctx->i].hThread = _vm->_scheduler.createProcess(ActionThread, &_ctx->newItem, sizeof(LPMPALITEM))) == 0) { + if ((_ctx->MyThreads[_ctx->i].hThread = g_scheduler->createProcess(ActionThread, &_ctx->newItem, sizeof(LPMPALITEM))) == 0) { //if ((_ctx->MyThreads[_ctx->i].hThread=(void*)_beginthread(ActionThread, 10240,(void *)_ctx->newItem))==(void*)-1) GlobalFree(_ctx->newItem); GlobalFree(_ctx->MyThreads); @@ -1295,14 +1295,14 @@ void LocationPollThread(CORO_PARAM, const void *param) { for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) if (_ctx->MyThreads[_ctx->i].nItem != 0) { - CORO_INVOKE_3(_vm->_scheduler.waitForSingleObject, _ctx->MyThreads[_ctx->i].hThread, 5000, &_ctx->delayExpired); + CORO_INVOKE_3(g_scheduler->waitForSingleObject, _ctx->MyThreads[_ctx->i].hThread, 5000, &_ctx->delayExpired); /* //if (result != WAIT_OBJECT_0) if (_ctx->delayExpired) TerminateThread(_ctx->MyThreads[_ctx->i].hThread, 0); */ - _vm->_scheduler.killMatchingProcess(_ctx->MyThreads[_ctx->i].hThread); + g_scheduler->killMatchingProcess(_ctx->MyThreads[_ctx->i].hThread); } // Set idle skip off @@ -1343,13 +1343,13 @@ void ShutUpDialogThread(CORO_PARAM, const void *param) { CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_2(_vm->_scheduler.waitForSingleObject, pid, INFINITE); + CORO_INVOKE_2(g_scheduler->waitForSingleObject, pid, INFINITE); bExecutingDialog = false; nExecutingDialog = 0; nExecutingChoice = 0; - _vm->_scheduler.setEvent(hAskChoice); + g_scheduler->setEvent(hAskChoice); CORO_KILL_SELF(); @@ -1501,9 +1501,9 @@ void DoChoice(CORO_PARAM, uint32 nChoice) { /* Avvertiamo il gioco che c'e' una scelta da far fare all'utente, e restiamo in attesa della risposta */ - _vm->_scheduler.resetEvent(hDoneChoice); - _vm->_scheduler.setEvent(hAskChoice); - CORO_INVOKE_2(_vm->_scheduler.waitForSingleObject, hDoneChoice, INFINITE); + g_scheduler->resetEvent(hDoneChoice); + g_scheduler->setEvent(hAskChoice); + CORO_INVOKE_2(g_scheduler->waitForSingleObject, hDoneChoice, INFINITE); /* Ora che la scelta e' stata effettuata, possiamo eseguire _ctx->i gruppi associati con la scelta */ @@ -1644,19 +1644,19 @@ static uint32 DoDialog(uint32 nDlgOrd, uint32 nGroup) { // Enables the flag to indicate that there is' a running dialogue bExecutingDialog = true; - _vm->_scheduler.resetEvent(hAskChoice); - _vm->_scheduler.resetEvent(hDoneChoice); + g_scheduler->resetEvent(hAskChoice); + g_scheduler->resetEvent(hDoneChoice); // Create a thread that performs the dialogue group // Create the process - if ((h = _vm->_scheduler.createProcess(GroupThread, &nGroup, sizeof(uint32))) == 0) + if ((h = g_scheduler->createProcess(GroupThread, &nGroup, sizeof(uint32))) == 0) return 0; // Create a thread that waits until the end of the dialog process, and will restore the global variables - if (_vm->_scheduler.createProcess(ShutUpDialogThread, &h, sizeof(uint32)) == 0) { + if (g_scheduler->createProcess(ShutUpDialogThread, &h, sizeof(uint32)) == 0) { // Something went wrong, so kill the previously started dialog process - _vm->_scheduler.killMatchingProcess(h); + g_scheduler->killMatchingProcess(h); return 0; } @@ -1690,7 +1690,7 @@ bool DoSelection(uint32 i, uint32 dwData) { return false; nSelectedChoice = j; - _vm->_scheduler.setEvent(hDoneChoice); + g_scheduler->setEvent(hDoneChoice); return true; } @@ -1867,8 +1867,8 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, /* Crea l'evento che verra' utilizzato per avvertire il gioco che c'e' da effettuare una scelta */ - hAskChoice = _vm->_scheduler.createEvent(true, false); - hDoneChoice = _vm->_scheduler.createEvent(true, false); + hAskChoice = g_scheduler->createEvent(true, false); + hDoneChoice = g_scheduler->createEvent(true, false); return true; } @@ -2031,9 +2031,9 @@ void mpalQueryInner(CORO_PARAM, uint16 wQueryType, uint32 *dwRet, va_list v) { /* * void mpalQuery(MPQ_DIALOG_WAITFORCHOICE); */ - CORO_INVOKE_2(_vm->_scheduler.waitForSingleObject, hAskChoice, INFINITE); + CORO_INVOKE_2(g_scheduler->waitForSingleObject, hAskChoice, INFINITE); - _vm->_scheduler.resetEvent(hAskChoice); + g_scheduler->resetEvent(hAskChoice); if (bExecutingDialog) *dwRet = (uint32)nExecutingChoice; @@ -2217,7 +2217,7 @@ bool mpalStartIdlePoll(int nLoc) { hEndPollingLocations[i] = CreateEvent(NULL, true, false, NULL); // !!! Nuova gestione dei thread - if ((PollingThreads[i] = _vm->_scheduler.createProcess(LocationPollThread, &i, sizeof(uint32))) == 0) + if ((PollingThreads[i] = g_scheduler->createProcess(LocationPollThread, &i, sizeof(uint32))) == 0) // if ((hEndPollingLocations[i]=(void*)_beginthread(LocationPollThread, 10240,(void *)i))==(void*)-1) return false; @@ -2254,7 +2254,7 @@ void mpalEndIdlePoll(CORO_PARAM, int nLoc, bool *result) { if (nPollingLocations[_ctx->i] == (uint32)nLoc) { SetEvent(hEndPollingLocations[_ctx->i]); - CORO_INVOKE_2(_vm->_scheduler.waitForSingleObject, PollingThreads[_ctx->i], INFINITE); + CORO_INVOKE_2(g_scheduler->waitForSingleObject, PollingThreads[_ctx->i], INFINITE); CloseHandle(hEndPollingLocations[_ctx->i]); nPollingLocations[_ctx->i] = 0; diff --git a/engines/tony/sched.cpp b/engines/tony/sched.cpp index 199f5991ce..2671b01b7f 100644 --- a/engines/tony/sched.cpp +++ b/engines/tony/sched.cpp @@ -51,6 +51,8 @@ Scheduler::Scheduler() { active->pNext = NULL; g_scheduler = this; // FIXME HACK + + reset(); } Scheduler::~Scheduler() { @@ -102,6 +104,7 @@ void Scheduler::reset() { while (pProc != NULL) { delete pProc->state; pProc->state = 0; + pProc->waiting = false; pProc = pProc->pNext; } @@ -315,6 +318,9 @@ void Scheduler::waitForSingleObject(CORO_PARAM, int pid, uint32 duration, bool * CORO_BEGIN_CODE(_ctx); + // Signal as waiting + pCurrent->waiting = true; + _ctx->endTime = (duration == INFINITE) ? INFINITE : g_system->getMillis() + duration; if (expired) // Presume it will expire @@ -350,6 +356,9 @@ void Scheduler::waitForSingleObject(CORO_PARAM, int pid, uint32 duration, bool * CORO_SLEEP(1); } + // Signal waiting is done + pCurrent->waiting = false; + CORO_END_CODE; } @@ -378,6 +387,9 @@ void Scheduler::waitForMultipleObjects(CORO_PARAM, int nCount, uint32 *pidList, CORO_BEGIN_CODE(_ctx); + // Signal as waiting + pCurrent->waiting = true; + _ctx->endTime = (duration == INFINITE) ? INFINITE : g_system->getMillis() + duration; if (expired) // Presume that delay will expire @@ -419,6 +431,9 @@ void Scheduler::waitForMultipleObjects(CORO_PARAM, int nCount, uint32 *pidList, CORO_SLEEP(1); } + // Signal waiting is done + pCurrent->waiting = false; + CORO_END_CODE; } @@ -567,12 +582,12 @@ int Scheduler::getCurrentPID() const { * @param pidMask mask to apply to process identifiers before comparison * @return The number of processes killed is returned. */ -int Scheduler::killMatchingProcess(int pidKill, int pidMask) { +int Scheduler::killMatchingProcess(uint32 pidKill, int pidMask) { int numKilled = 0; PROCESS *pProc, *pPrev; // process list pointers for (pProc = active->pNext, pPrev = active; pProc != NULL; pPrev = pProc, pProc = pProc->pNext) { - if ((pProc->pid & pidMask) == pidKill) { + if ((pProc->pid & (uint32)pidMask) == pidKill) { // found a matching process // dont kill the current process @@ -697,4 +712,56 @@ void Scheduler::resetEvent(uint32 pidEvent) { evt->signalled = false; } +/** + * Temporarily sets a given event to true, and then runs all waiting processes, allowing any + * processes waiting on the event to be fired. It then immediately resets the event again. + * @param pidEvent Event PID + * + * @remarks Should not be run inside of another process + */ +void Scheduler::pulseEvent(uint32 pidEvent) { + EVENT *evt = getEvent(pidEvent); + if (!evt) + return; + + // Set the event as true + evt->signalled = true; + + // start dispatching active process list for any processes that are currently waiting + PROCESS *pOriginal = pCurrent; + PROCESS *pNext; + PROCESS *pProc = active->pNext; + while (pProc != NULL) { + pNext = pProc->pNext; + + // Only call processes that are currently waiting (either in waitForSingleObject or + // waitForMultipleObjects). If one is found, execute it immediately + if (pProc->waiting) { + // Dispatch the process + pCurrent = pProc; + pProc->coroAddr(pProc->state, pProc->param); + + if (!pProc->state || pProc->state->_sleep <= 0) { + // Coroutine finished + pCurrent = pCurrent->pPrevious; + killProcess(pProc); + } else { + pProc->sleepTime = pProc->state->_sleep; + } + + // pCurrent may have been changed + pNext = pCurrent->pNext; + pCurrent = NULL; + } + + pProc = pNext; + } + + // Restore the original current process (if one was active) + pCurrent = pOriginal; + + // Reset the event back to non-signalled + evt->signalled = false; +} + } // End of namespace Tony diff --git a/engines/tony/sched.h b/engines/tony/sched.h index 80df1eb942..3997cb2c47 100644 --- a/engines/tony/sched.h +++ b/engines/tony/sched.h @@ -50,6 +50,7 @@ struct PROCESS { int sleepTime; ///< number of scheduler cycles to sleep uint32 pid; ///< process ID + bool waiting; ///< process is currently in a waiting state char param[PARAM_SIZE]; ///< process specific info }; typedef PROCESS *PPROCESS; @@ -134,7 +135,7 @@ public: PROCESS *getCurrentProcess(); int getCurrentPID() const; - int killMatchingProcess(int pidKill, int pidMask = -1); + int killMatchingProcess(uint32 pidKill, int pidMask = -1); void setResourceCallback(VFPTRPP pFunc); @@ -143,6 +144,7 @@ public: void closeEvent(uint32 pidEvent); void setEvent(uint32 pidEvent); void resetEvent(uint32 pidEvent); + void pulseEvent(uint32 pidEvent); }; extern Scheduler *g_scheduler; // FIXME: Temporary global var, to be used until everything has been OOifyied diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index a4a478d40d..d0bce68c3b 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -36,7 +36,7 @@ namespace Tony { TonyEngine *_vm; TonyEngine::TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc) : Engine(syst), - _gameDescription(gameDesc), _randomSource("tony") { + _gameDescription(gameDesc), _randomSource("tony"), _scheduler() { _vm = this; DebugMan.addDebugChannel(kTonyDebugAnimations, "animations", "Animations debugging"); diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index 073ebf2be4..ad13d49d54 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -67,7 +67,7 @@ void RMTony::WaitEndOfAction(CORO_PARAM, const void *param) { CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_2(_vm->_scheduler.waitForSingleObject, pid, INFINITE); + CORO_INVOKE_2(g_scheduler->waitForSingleObject, pid, INFINITE); m_bAction = false; @@ -240,26 +240,26 @@ void RMTony::ExecuteAction(int nAction, int nActionItem, int nParm) { if (hThread != INVALID_HANDLE_VALUE) { m_bAction = true; pid = (uint32)hThread; - _vm->_scheduler.createProcess(WaitEndOfAction, &pid, sizeof(uint32)); + g_scheduler->createProcess(WaitEndOfAction, &pid, sizeof(uint32)); hActionThread = hThread; } else if (nAction != TA_GOTO) { if (nAction == TA_TALK) { hThread = mpalQueryDoAction(6, 1, 0); m_bAction = true; pid = (uint32)hThread; - _vm->_scheduler.createProcess(WaitEndOfAction, &pid, sizeof(uint32)); + g_scheduler->createProcess(WaitEndOfAction, &pid, sizeof(uint32)); hActionThread = hThread; } else if (nAction == TA_PALESATI) { hThread = mpalQueryDoAction(7, 1, 0); m_bAction = true; pid = (uint32)hThread; - _vm->_scheduler.createProcess(WaitEndOfAction, &pid, sizeof(uint32)); + g_scheduler->createProcess(WaitEndOfAction, &pid, sizeof(uint32)); hActionThread=hThread; } else { hThread = mpalQueryDoAction(5, 1, 0); m_bAction = true; pid = (uint32)hThread; - _vm->_scheduler.createProcess(WaitEndOfAction, &pid, sizeof(uint32)); + g_scheduler->createProcess(WaitEndOfAction, &pid, sizeof(uint32)); hActionThread = hThread; } } @@ -1074,7 +1074,9 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; } break; - } + } + + return true; } void RMTony::StartTalk(CORO_PARAM, TALKTYPE nTalkType) { -- cgit v1.2.3 From 26898dd7ad399a641f63eabf04aa2d839f8508fc Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 9 May 2012 00:42:27 +1000 Subject: TONY: Completed bulk of initial coro refactoring --- engines/tony/adv.h | 4 +- engines/tony/custom.cpp | 622 ++++++++++++++++++++++++------------------ engines/tony/font.cpp | 167 +++++++----- engines/tony/font.h | 25 +- engines/tony/game.cpp | 8 +- engines/tony/gfxengine.cpp | 90 +++--- engines/tony/gfxengine.h | 8 +- engines/tony/loc.cpp | 45 +-- engines/tony/loc.h | 10 +- engines/tony/mpal/loadmpc.cpp | 59 ++-- engines/tony/mpal/mpal.cpp | 156 ++++++----- engines/tony/mpal/stubs.cpp | 70 ----- engines/tony/mpal/stubs.h | 36 +-- engines/tony/sched.cpp | 34 +++ engines/tony/sched.h | 4 +- engines/tony/sound.cpp | 3 +- engines/tony/sound.h | 2 +- engines/tony/tony.cpp | 35 ++- engines/tony/tony.h | 8 +- engines/tony/tonychar.cpp | 38 ++- engines/tony/tonychar.h | 8 +- 21 files changed, 772 insertions(+), 660 deletions(-) (limited to 'engines') diff --git a/engines/tony/adv.h b/engines/tony/adv.h index 056934e932..22205cf05b 100644 --- a/engines/tony/adv.h +++ b/engines/tony/adv.h @@ -96,7 +96,7 @@ void MainUnloadLocation(CORO_PARAM, bool bDoOnExit, HANDLE *result); void MainLinkGraphicTask(RMGfxTask *task); void MainFreeze(void); void MainUnfreeze(void); -void MainWaitFrame(void); +void MainWaitFrame(CORO_PARAM); void MainShowMouse(void); void MainHideMouse(void); void MainEnableInput(void); @@ -104,7 +104,7 @@ void MainDisableInput(void); void MainPlayMusic(int nChannel, const char *filename, int nFX, bool bLoop, int nSync); void MainInitWipe(int type); void MainCloseWipe(void); -void MainWaitWipeEnd(void); +void MainWaitWipeEnd(CORO_PARAM); void MainEnableGUI(void); void MainDisableGUI(void); void MainSetPalesati(bool bPalesati); diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 18a92899df..9d46d7e6b7 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -56,6 +56,7 @@ #include "tony/font.h" #include "tony/game.h" #include "tony/gfxcore.h" +#include "tony/sched.h" #include "tony/tony.h" #include "tony/tonychar.h" #include "tony/utils.h" @@ -76,9 +77,9 @@ void (*UnloadLocation)(CORO_PARAM, bool bDoOnExit, HANDLE *result); void (*LinkGraphicTask)(RMGfxTask *task); void (*Freeze)(void); void (*Unfreeze)(void); -void (*WaitFrame)(void); +void (*WaitFrame)(CORO_PARAM); void (*PlayMusic)(int nChannel, const char *fileName, int nFX, bool bLoop, int nSync); -void (*WaitWipeEnd)(void); +void (*WaitWipeEnd)(CORO_PARAM); void (*CloseWipe)(void); void (*InitWipe)(int type); void (*EnableGUI)(void); @@ -96,7 +97,7 @@ OSystem::MutexRef vdb; HANDLE mut[10]; bool bSkipIdle = false; -HANDLE hSkipIdle; +uint32 hSkipIdle; int lastMusic = 0, lastTappeto = 0; @@ -319,8 +320,16 @@ DECLARE_CUSTOM_FUNCTION(TonySetPalesati)(CORO_PARAM, uint32 bStatus, uint32, uin } DECLARE_CUSTOM_FUNCTION(MySleep)(CORO_PARAM, uint32 dwTime, uint32, uint32, uint32) { - if (bSkipIdle) return; - Sleep(dwTime); + CORO_BEGIN_CONTEXT; + int i; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + if (!bSkipIdle) + CORO_INVOKE_1(g_scheduler->sleep, dwTime); + + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(SetAlwaysDisplay)(CORO_PARAM, uint32 val, uint32, uint32, uint32) { @@ -376,6 +385,7 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX int curOffset; VoiceHeader *curVoc; FPSFX *voice; + RMTextDialog text; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -422,39 +432,38 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX } if (curBackText) - curBackText->Hide(); + CORO_INVOKE_0(curBackText->Hide); + bTonyIsSpeaking = true; for (_ctx->i = 0; _ctx->i < _ctx->msg->NumPeriods() && !bSkipIdle; _ctx->i++) { - RMTextDialog text; - - text.SetInput(Input); + _ctx->text.SetInput(Input); // Allineamento - text.SetAlignType(RMText::HCENTER,RMText::VBOTTOM); + _ctx->text.SetAlignType(RMText::HCENTER,RMText::VBOTTOM); // Colore - text.SetColor(0,255,0); + _ctx->text.SetColor(0,255,0); // Scrive il testo - text.WriteText((*_ctx->msg)[_ctx->i],0); + _ctx->text.WriteText((*_ctx->msg)[_ctx->i],0); // Setta la posizione if (nX == 0 && nY == 0) - text.SetPosition(Tony->Position() - RMPoint(0, 130) - Loc->ScrollPosition()); + _ctx->text.SetPosition(Tony->Position() - RMPoint(0, 130) - Loc->ScrollPosition()); else - text.SetPosition(RMPoint(nX, nY) - Loc->ScrollPosition()); + _ctx->text.SetPosition(RMPoint(nX, nY) - Loc->ScrollPosition()); // Setta l'always display - if (bAlwaysDisplay) { text.SetAlwaysDisplay(); text.ForceTime(); } + if (bAlwaysDisplay) { _ctx->text.SetAlwaysDisplay(); _ctx->text.ForceTime(); } // Registra il testo - LinkGraphicTask(&text); + LinkGraphicTask(&_ctx->text); if (_ctx->curVoc) { if (_ctx->i == 0) { _ctx->voice->Play(); - text.SetCustomSkipHandle2(_ctx->voice->hEndOfBuffer); + _ctx->text.SetCustomSkipHandle2(_ctx->voice->hEndOfBuffer); } else { g_system->lockMutex(vdb); // fseek(_vm->m_vdbFP, _ctx->curOffset, SEEK_SET); @@ -465,14 +474,14 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX _ctx->curOffset = _vm->_vdbFP.pos(); _ctx->voice->SetLoop(false); _ctx->voice->Play(); - text.SetCustomSkipHandle2(_ctx->voice->hEndOfBuffer); + _ctx->text.SetCustomSkipHandle2(_ctx->voice->hEndOfBuffer); g_system->unlockMutex(vdb); } } // Aspetta la fine della visualizzazione - text.SetCustomSkipHandle(hSkipIdle); - text.WaitForEndDisplay(); + _ctx->text.SetCustomSkipHandle(hSkipIdle); + CORO_INVOKE_0(_ctx->text.WaitForEndDisplay); if (_ctx->curVoc) { _ctx->voice->Stop(); @@ -497,7 +506,11 @@ DECLARE_CUSTOM_FUNCTION(ChangeBoxStatus)(CORO_PARAM, uint32 nLoc, uint32 nBox, u DECLARE_CUSTOM_FUNCTION(CustLoadLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint32 tY, uint32 bUseStartPos) { - HANDLE h; + CORO_BEGIN_CONTEXT; + uint32 h; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); Freeze(); @@ -508,11 +521,13 @@ DECLARE_CUSTOM_FUNCTION(CustLoadLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, ui LoadLocation(nLoc, RMPoint(tX, tY), RMPoint(-1, -1)); Unfreeze(); - h = mpalQueryDoAction(0, nLoc, 0); + _ctx->h = mpalQueryDoActionU32(0, nLoc, 0); // On Enter? - if (h != INVALID_HANDLE_VALUE) - WaitForSingleObject(h, INFINITE); + if (_ctx->h != INVALID_PID_VALUE) + CORO_INVOKE_2(g_scheduler->waitForSingleObject, _ctx->h, INFINITE); + + CORO_END_CODE; } @@ -524,6 +539,7 @@ DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgStart)(CORO_PARAM, uint32 nMsg, uint32 RMMessage *msg; RMGfxClearTask clear; int i; + RMTextDialog text; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -541,38 +557,36 @@ DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgStart)(CORO_PARAM, uint32 nMsg, uint32 Unfreeze(); for (_ctx->i = 0; _ctx->i < _ctx->msg->NumPeriods() && !bSkipIdle; _ctx->i++) { - RMTextDialog text; - - text.SetInput(Input); + _ctx->text.SetInput(Input); // Allineamento - text.SetAlignType(RMText::HCENTER,RMText::VCENTER); + _ctx->text.SetAlignType(RMText::HCENTER,RMText::VCENTER); // Forza il testo a scomparire a tempo - text.ForceTime(); + _ctx->text.ForceTime(); // Colore - text.SetColor(255,255,255); + _ctx->text.SetColor(255,255,255); // Scrive il testo if (nFont == 0) - text.WriteText((*_ctx->msg)[_ctx->i], 1); + _ctx->text.WriteText((*_ctx->msg)[_ctx->i], 1); else if (nFont == 1) - text.WriteText((*_ctx->msg)[_ctx->i], 0); + _ctx->text.WriteText((*_ctx->msg)[_ctx->i], 0); // Setta la posizione - text.SetPosition(RMPoint(320, 240)); + _ctx->text.SetPosition(RMPoint(320, 240)); - text.SetAlwaysDisplay(); - text.ForceTime(); + _ctx->text.SetAlwaysDisplay(); + _ctx->text.ForceTime(); // Registra il testo LinkGraphicTask(&_ctx->clear); - LinkGraphicTask(&text); + LinkGraphicTask(&_ctx->text); // Aspetta la fine della visualizzazione - text.SetCustomSkipHandle(hSkipIdle); - text.WaitForEndDisplay(); + _ctx->text.SetCustomSkipHandle(hSkipIdle); + CORO_INVOKE_0(_ctx->text.WaitForEndDisplay); } delete _ctx->msg; @@ -581,10 +595,18 @@ DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgStart)(CORO_PARAM, uint32 nMsg, uint32 } DECLARE_CUSTOM_FUNCTION(ClearScreen)(CORO_PARAM, uint32, uint32, uint32, uint32) { - RMGfxClearTask clear; + CORO_BEGIN_CONTEXT; + char buf[256]; + RMGfxClearTask clear; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + LinkGraphicTask(&_ctx->clear); + + CORO_INVOKE_0(WaitFrame); - LinkGraphicTask(&clear); - WaitFrame(); + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgEnd)(CORO_PARAM, uint32 bNotEnableTony, uint32, uint32, uint32) { @@ -625,7 +647,7 @@ DECLARE_CUSTOM_FUNCTION(CloseLocation)(CORO_PARAM, uint32, uint32, uint32, uint3 if (!bNoOcchioDiBue) { InitWipe(1); - WaitWipeEnd(); + CORO_INVOKE_0(WaitWipeEnd); } _vm->StopMusic(4); @@ -640,14 +662,14 @@ DECLARE_CUSTOM_FUNCTION(CloseLocation)(CORO_PARAM, uint32, uint32, uint32, uint3 DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint32 tY, uint32 bUseStartPos) { CORO_BEGIN_CONTEXT; - HANDLE h; + uint32 h; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); if (!bNoOcchioDiBue) { InitWipe(1); - WaitWipeEnd(); + CORO_INVOKE_0(WaitWipeEnd); } if (lastTappeto != tappeti[nLoc]) { @@ -676,18 +698,18 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint Unfreeze(); - _ctx->h = mpalQueryDoAction(0, nLoc, 0); + _ctx->h = mpalQueryDoActionU32(0, nLoc, 0); if (!bNoOcchioDiBue) { - WaitWipeEnd(); + CORO_INVOKE_0(WaitWipeEnd); CloseWipe(); } bNoOcchioDiBue = false; // On Enter? - if (_ctx->h != INVALID_HANDLE_VALUE) - WaitForSingleObject(_ctx->h, INFINITE); + if (_ctx->h != INVALID_PID_VALUE) + CORO_INVOKE_2(g_scheduler->waitForSingleObject, _ctx->h, INFINITE); CORO_END_CODE; } @@ -725,7 +747,7 @@ DECLARE_CUSTOM_FUNCTION(EnableInput)(CORO_PARAM, uint32, uint32, uint32, uint32) } DECLARE_CUSTOM_FUNCTION(StopTony)(CORO_PARAM, uint32, uint32, uint32, uint32) { - Tony->StopNoAction(); + Tony->StopNoAction(coroParam); } @@ -1328,114 +1350,123 @@ DECLARE_CUSTOM_FUNCTION(MoveTony)(CORO_PARAM, uint32 nX, uint32 nY, uint32, uint } DECLARE_CUSTOM_FUNCTION(ScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, uint32 sX, uint32 sY) { - int lx, ly; - RMPoint pt; + CORO_BEGIN_CONTEXT; + int lx, ly; + RMPoint pt; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); // Prende le coordinate di quanto scrollare - lx=*((int*)&nX); - ly=*((int*)&nY); + _ctx->lx = (int32)nX; + _ctx->ly = (int32)nY; - pt=Loc->ScrollPosition(); + _ctx->pt = Loc->ScrollPosition(); - while ((lx != 0 || ly != 0) && !bSkipIdle) { - if (lx > 0) { - lx -= (int32)sX; if (lx < 0) lx = 0; - pt.Offset((int32)sX, 0); - } else if (lx < 0) { - lx += (int32)sX; if (lx > 0) lx = 0; - pt.Offset(-(int32)sX, 0); + while ((_ctx->lx != 0 || _ctx->ly != 0) && !bSkipIdle) { + if (_ctx->lx > 0) { + _ctx->lx -= (int32)sX; if (_ctx->lx < 0) _ctx->lx = 0; + _ctx->pt.Offset((int32)sX, 0); + } else if (_ctx->lx < 0) { + _ctx->lx += (int32)sX; if (_ctx->lx > 0) _ctx->lx = 0; + _ctx->pt.Offset(-(int32)sX, 0); } - if (ly > 0) { - ly -= sY; if (ly < 0) ly = 0; - pt.Offset(0, sY); - } else if (ly < 0) { - ly += sY; if (ly > 0) ly = 0; - pt.Offset(0, -(int32)sY); + if (_ctx->ly > 0) { + _ctx->ly -= sY; if (_ctx->ly < 0) _ctx->ly = 0; + _ctx->pt.Offset(0, sY); + } else if (_ctx->ly < 0) { + _ctx->ly += sY; if (_ctx->ly > 0) _ctx->ly = 0; + _ctx->pt.Offset(0, -(int32)sY); } - WaitFrame(); + CORO_INVOKE_0(WaitFrame); Freeze(); - Loc->SetScrollPosition(pt); - Tony->SetScrollPosition(pt); + Loc->SetScrollPosition(_ctx->pt); + Tony->SetScrollPosition(_ctx->pt); Unfreeze(); - } + + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, uint32 sX, uint32 sY) { - int lx, ly; - RMPoint pt, startpt; - uint32 dwStartTime, dwCurTime, dwTotalTime; - uint32 stepX, stepY; - int dimx, dimy; + CORO_BEGIN_CONTEXT; + int lx, ly; + RMPoint pt, startpt; + uint32 dwStartTime, dwCurTime, dwTotalTime; + uint32 stepX, stepY; + int dimx, dimy; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); // Prende le coordinate di quanto scrollare - lx=*((int*)&nX); - ly=*((int*)&nY); - dimx = lx; - dimy = ly; - if (lx < 0) dimx = -lx; - if (ly < 0) dimy = -ly; + _ctx->lx=*((int*)&nX); + _ctx->ly=*((int*)&nY); + _ctx->dimx = _ctx->lx; + _ctx->dimy = _ctx->ly; + if (_ctx->lx < 0) _ctx->dimx = -_ctx->lx; + if (_ctx->ly < 0) _ctx->dimy = -_ctx->ly; - stepX = sX; - stepY = sY; + _ctx->stepX = sX; + _ctx->stepY = sY; - startpt = Loc->ScrollPosition(); + _ctx->startpt = Loc->ScrollPosition(); - dwStartTime = timeGetTime(); + _ctx->dwStartTime = _vm->GetTime(); if (sX) - dwTotalTime = dimx * (1000 / 35) / sX; + _ctx->dwTotalTime = _ctx->dimx * (1000 / 35) / sX; else - dwTotalTime = dimy * (1000 / 35) / sY; + _ctx->dwTotalTime = _ctx->dimy * (1000 / 35) / sY; - while ((lx != 0 || ly != 0) && !bSkipIdle) { - dwCurTime = _vm->GetTime() - dwStartTime; - if (dwCurTime>dwTotalTime) + while ((_ctx->lx != 0 || _ctx->ly != 0) && !bSkipIdle) { + _ctx->dwCurTime = _vm->GetTime() - _ctx->dwStartTime; + if (_ctx->dwCurTime > _ctx->dwTotalTime) break; - pt = startpt; + _ctx->pt = _ctx->startpt; if (sX) { - if (lx > 0) - pt.x += (dimx * dwCurTime) / dwTotalTime; + if (_ctx->lx > 0) + _ctx->pt.x += (_ctx->dimx * _ctx->dwCurTime) / _ctx->dwTotalTime; else - pt.x -= (dimx * dwCurTime) / dwTotalTime; + _ctx->pt.x -= (_ctx->dimx * _ctx->dwCurTime) / _ctx->dwTotalTime; } else { - if (ly > 0) - pt.y += (dimy*dwCurTime) / dwTotalTime; + if (_ctx->ly > 0) + _ctx->pt.y += (_ctx->dimy*_ctx->dwCurTime) / _ctx->dwTotalTime; else - pt.y -= (dimy*dwCurTime) / dwTotalTime; + _ctx->pt.y -= (_ctx->dimy*_ctx->dwCurTime) / _ctx->dwTotalTime; } /* - sX = stepX * (dwCurTime-dwLastTime) / (1000 / 35); - sY = stepY * (dwCurTime-dwLastTime) / (1000 / 35); - - if (lx > 0) { - lx-=sX; if (lx < 0) lx = 0; - pt.Offset(sX,0); - } else if (lx < 0) { - lx+=sX; if (lx > 0) lx = 0; - pt.Offset(-sX,0); + sX = _ctx->stepX * (_ctx->dwCurTime-dwLastTime) / (1000 / 35); + sY = _ctx->stepY * (_ctx->dwCurTime-dwLastTime) / (1000 / 35); + + if (_ctx->lx > 0) { + _ctx->lx-=sX; if (_ctx->lx < 0) _ctx->lx = 0; + _ctx->pt.Offset(sX,0); + } else if (_ctx->lx < 0) { + _ctx->lx+=sX; if (_ctx->lx > 0) _ctx->lx = 0; + _ctx->pt.Offset(-sX,0); } - if (ly > 0) { - ly-=sY; if (ly<0) ly = 0; - pt.Offset(0,sY); - } else if (ly<0) { - ly+=sY; if (ly > 0) ly = 0; - pt.Offset(0,-sY); + if (_ctx->ly > 0) { + _ctx->ly-=sY; if (_ctx->ly<0) _ctx->ly = 0; + _ctx->pt.Offset(0,sY); + } else if (_ctx->ly<0) { + _ctx->ly+=sY; if (_ctx->ly > 0) _ctx->ly = 0; + _ctx->pt.Offset(0,-sY); } */ - WaitFrame(); + CORO_INVOKE_0(WaitFrame); Freeze(); - Loc->SetScrollPosition(pt); - Tony->SetScrollPosition(pt); + Loc->SetScrollPosition(_ctx->pt); + Tony->SetScrollPosition(_ctx->pt); Unfreeze(); } @@ -1443,22 +1474,23 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui // Setta la posizione finale if (sX) { - if (lx > 0) - pt.x = startpt.x + dimx; + if (_ctx->lx > 0) + _ctx->pt.x = _ctx->startpt.x + _ctx->dimx; else - pt.x = startpt.x - dimx; + _ctx->pt.x = _ctx->startpt.x - _ctx->dimx; } else { - if (ly > 0) - pt.y = startpt.y + dimy; + if (_ctx->ly > 0) + _ctx->pt.y = _ctx->startpt.y + _ctx->dimy; else - pt.y = startpt.y - dimy; - + _ctx->pt.y = _ctx->startpt.y - _ctx->dimy; } Freeze(); - Loc->SetScrollPosition(pt); - Tony->SetScrollPosition(pt); + Loc->SetScrollPosition(_ctx->pt); + Tony->SetScrollPosition(_ctx->pt); Unfreeze(); + + CORO_END_CODE; } @@ -1484,7 +1516,7 @@ DECLARE_CUSTOM_FUNCTION(ChangeHotspot)(CORO_PARAM, uint32 dwCode, uint32 nX, uin DECLARE_CUSTOM_FUNCTION(AutoSave)(CORO_PARAM, uint32, uint32, uint32, uint32) { - _vm->AutoSave(); + _vm->AutoSave(coroParam); } DECLARE_CUSTOM_FUNCTION(Abort)(CORO_PARAM, uint32, uint32, uint32, uint32) { @@ -1492,33 +1524,41 @@ DECLARE_CUSTOM_FUNCTION(Abort)(CORO_PARAM, uint32, uint32, uint32, uint32) { } DECLARE_CUSTOM_FUNCTION(TremaSchermo)(CORO_PARAM, uint32 nScosse, uint32, uint32, uint32) { - uint32 i; - uint32 curTime = _vm->GetTime(); - int dirx,diry; + CORO_BEGIN_CONTEXT; + uint32 i; + uint32 curTime; + int dirx,diry; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + _ctx->curTime = _vm->GetTime(); - dirx = 1; - diry = 1; + _ctx->dirx = 1; + _ctx->diry = 1; - while (_vm->GetTime() < curTime + nScosse) { - WaitFrame(); + while (_vm->GetTime() < _ctx->curTime + nScosse) { + CORO_INVOKE_0(WaitFrame); Freeze(); - Loc->SetFixedScroll(RMPoint(1 * dirx, 1 * diry)); - Tony->SetFixedScroll(RMPoint(1 * dirx, 1 * diry)); + Loc->SetFixedScroll(RMPoint(1 * _ctx->dirx, 1 * _ctx->diry)); + Tony->SetFixedScroll(RMPoint(1 * _ctx->dirx, 1 * _ctx->diry)); Unfreeze(); - i = _vm->_randomSource.getRandomNumber(2); + _ctx->i = _vm->_randomSource.getRandomNumber(2); - if (i == 0 || i == 2) - dirx = -dirx; - else if (i == 1 || i == 2) - diry = -diry; + if (_ctx->i == 0 || _ctx->i == 2) + _ctx->dirx = -_ctx->dirx; + else if (_ctx->i == 1 || _ctx->i == 2) + _ctx->diry = -_ctx->diry; } Freeze(); Loc->SetFixedScroll(RMPoint(0, 0)); Tony->SetFixedScroll(RMPoint(0, 0)); Unfreeze(); + + CORO_END_CODE; } @@ -1607,7 +1647,7 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess if (bIsBack) { curBackText = _ctx->text = new RMTextDialogScrolling(Loc); if (bTonyIsSpeaking) - curBackText->Hide(); + CORO_INVOKE_0(curBackText->Hide); } else _ctx->text = new RMTextDialog; @@ -1649,7 +1689,7 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess // Aspetta la fine della visualizzazione _ctx->text->SetCustomSkipHandle(hSkipIdle); - _ctx->text->WaitForEndDisplay(); + CORO_INVOKE_0(_ctx->text->WaitForEndDisplay); if (_ctx->curVoc) { _ctx->voice->Stop(); @@ -1769,13 +1809,22 @@ DECLARE_CUSTOM_FUNCTION(MCharSetAlwaysBack)(CORO_PARAM, uint32 nChar, uint32 bAl DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMessage, uint32 bIsBack, uint32 nFont) { - RMMessage msg(dwMessage); - int i; - int parm; - RMPoint pt; - HANDLE h; - RMTextDialog *text; - int curOffset = 0; + CORO_BEGIN_CONTEXT; + RMMessage *msg; + int i; + int parm; + RMPoint pt; + uint32 h; + RMTextDialog *text; + int curOffset; + VoiceHeader *curVoc; + FPSFX *voice; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + _ctx->msg = new RMMessage(dwMessage); + _ctx->curOffset = 0; assert(nChar < 10); @@ -1783,99 +1832,103 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes // Calcola la posizione del testo in base al frame corrente if (MCharacter[nChar].x==-1) - pt=MCharacter[nChar].item->CalculatePos()-RMPoint(-60,20)-Loc->ScrollPosition(); + _ctx->pt=MCharacter[nChar].item->CalculatePos()-RMPoint(-60,20)-Loc->ScrollPosition(); else - pt=RMPoint(MCharacter[nChar].x,MCharacter[nChar].y); + _ctx->pt=RMPoint(MCharacter[nChar].x,MCharacter[nChar].y); // Parametro per le azioni speciali: random tra le parlate - parm = (MCharacter[nChar].curgroup * 10) + _vm->_randomSource.getRandomNumber( + _ctx->parm = (MCharacter[nChar].curgroup * 10) + _vm->_randomSource.getRandomNumber( MCharacter[nChar].numtalks[MCharacter[nChar].curgroup] - 1) + 1; // Cerca di eseguire la funzione custom per inizializzare la parlata if (MCharacter[nChar].item) { - h = mpalQueryDoAction(30,MCharacter[nChar].item->MpalCode(), parm); - if (h != INVALID_HANDLE_VALUE) - WaitForSingleObject(h,INFINITE); + _ctx->h = mpalQueryDoActionU32(30, MCharacter[nChar].item->MpalCode(), _ctx->parm); + if (_ctx->h != INVALID_PID_VALUE) { + CORO_INVOKE_2(g_scheduler->waitForSingleObject, _ctx->h, INFINITE); + } } - VoiceHeader *curVoc = SearchVoiceHeader(0, dwMessage); - FPSFX *voice = NULL; - if (curVoc) { + _ctx->curVoc = SearchVoiceHeader(0, dwMessage); + _ctx->voice = NULL; + if (_ctx->curVoc) { // Si posiziona all'interno del database delle voci all'inizio della prima g_system->lockMutex(vdb); // fseek(_vm->m_vdbFP, curVoc->offset, SEEK_SET); - _vm->_vdbFP.seek(curVoc->offset); - curOffset = curVoc->offset; + _vm->_vdbFP.seek(_ctx->curVoc->offset); + _ctx->curOffset = _ctx->curVoc->offset; g_system->unlockMutex(vdb); } - for (i = 0; i < msg.NumPeriods() && !bSkipIdle; i++) { + for (_ctx->i = 0; _ctx->i < _ctx->msg->NumPeriods() && !bSkipIdle; _ctx->i++) { // Crea l'oggetto diverso se back o no if (bIsBack) { - curBackText=text = new RMTextDialogScrolling(Loc); + curBackText=_ctx->text = new RMTextDialogScrolling(Loc); if (bTonyIsSpeaking) - curBackText->Hide(); + CORO_INVOKE_0(curBackText->Hide); } else - text = new RMTextDialog; + _ctx->text = new RMTextDialog; - text->SetInput(Input); + _ctx->text->SetInput(Input); // Skipping - text->SetSkipStatus(!bIsBack); + _ctx->text->SetSkipStatus(!bIsBack); // Allineamento - text->SetAlignType(RMText::HCENTER,RMText::VBOTTOM); + _ctx->text->SetAlignType(RMText::HCENTER,RMText::VBOTTOM); // Colore - text->SetColor(MCharacter[nChar].r,MCharacter[nChar].g,MCharacter[nChar].b); + _ctx->text->SetColor(MCharacter[nChar].r,MCharacter[nChar].g,MCharacter[nChar].b); // Scrive il testo - text->WriteText(msg[i],nFont); + _ctx->text->WriteText((*_ctx->msg)[_ctx->i], nFont); // Setta la posizione - text->SetPosition(pt); + _ctx->text->SetPosition(_ctx->pt); // Setta l'always display - if (bAlwaysDisplay) { text->SetAlwaysDisplay(); text->ForceTime(); } + if (bAlwaysDisplay) { _ctx->text->SetAlwaysDisplay(); _ctx->text->ForceTime(); } // Registra il testo - LinkGraphicTask(text); + LinkGraphicTask(_ctx->text); - if (curVoc) { + if (_ctx->curVoc) { g_system->lockMutex(vdb); - _vm->_theSound.CreateSfx(&voice); - _vm->_vdbFP.seek(curOffset); - voice->LoadVoiceFromVDB(_vm->_vdbFP); - voice->SetLoop(false); - if (bIsBack) voice->SetVolume(55); - voice->Play(); - text->SetCustomSkipHandle2(voice->hEndOfBuffer); - curOffset = _vm->_vdbFP.pos(); + _vm->_theSound.CreateSfx(&_ctx->voice); + _vm->_vdbFP.seek(_ctx->curOffset); + _ctx->voice->LoadVoiceFromVDB(_vm->_vdbFP); + _ctx->voice->SetLoop(false); + if (bIsBack) _ctx->voice->SetVolume(55); + _ctx->voice->Play(); + _ctx->text->SetCustomSkipHandle2(_ctx->voice->hEndOfBuffer); + _ctx->curOffset = _vm->_vdbFP.pos(); g_system->unlockMutex(vdb); } // Aspetta la fine della visualizzazione - text->SetCustomSkipHandle(hSkipIdle); - text->WaitForEndDisplay(); + _ctx->text->SetCustomSkipHandle(hSkipIdle); + CORO_INVOKE_0(_ctx->text->WaitForEndDisplay); - if (curVoc) { - voice->Stop(); - voice->Release(); - voice=NULL; + if (_ctx->curVoc) { + _ctx->voice->Stop(); + _ctx->voice->Release(); + _ctx->voice = NULL; } - curBackText=NULL; - delete text; + curBackText = NULL; + delete _ctx->text; + delete _ctx->msg; } // Cerca di eseguire la funzione custom per chiudere la parlata if (MCharacter[nChar].item) { - h = mpalQueryDoAction(31,MCharacter[nChar].item->MpalCode(),parm); - if (h!=INVALID_HANDLE_VALUE) - WaitForSingleObject(h,INFINITE); + _ctx->h = mpalQueryDoActionU32(31, MCharacter[nChar].item->MpalCode(), _ctx->parm); + if (_ctx->h != INVALID_PID_VALUE) + CORO_INVOKE_2(g_scheduler->waitForSingleObject, _ctx->h, INFINITE); } + + CORO_END_CODE; } @@ -1894,7 +1947,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg LPSTR string; RMTextDialog *text; int parm; - HANDLE h; + uint32 h; bool bIsBack; VoiceHeader *curVoc; FPSFX *voice; @@ -1968,12 +2021,10 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg _ctx->text->WriteText(_ctx->string, 0); _ctx->text->SetPosition(_ctx->pt); } else { - RMPoint pt; - if (MCharacter[nPers].x == -1) - pt = MCharacter[nPers].item->CalculatePos() - RMPoint(-60, 20) - Loc->ScrollPosition(); + _ctx->pt = MCharacter[nPers].item->CalculatePos() - RMPoint(-60, 20) - Loc->ScrollPosition(); else - pt = RMPoint(MCharacter[nPers].x, MCharacter[nPers].y); + _ctx->pt = RMPoint(MCharacter[nPers].x, MCharacter[nPers].y); // Parametro per le azioni speciali: random tra le parlate _ctx->parm = (MCharacter[nPers].curgroup * 10) + _vm->_randomSource.getRandomNumber( @@ -1983,9 +2034,9 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg MCharacter[nPers].numtexts--; } else { // Cerca di eseguire la funzione custom per inizializzare la parlata - _ctx->h = mpalQueryDoAction(30, MCharacter[nPers].item->MpalCode(), _ctx->parm); - if (_ctx->h != INVALID_HANDLE_VALUE) - WaitForSingleObject(_ctx->h,INFINITE); + _ctx->h = mpalQueryDoActionU32(30, MCharacter[nPers].item->MpalCode(), _ctx->parm); + if (_ctx->h != INVALID_PID_VALUE) + CORO_INVOKE_2(g_scheduler->waitForSingleObject, _ctx->h, INFINITE); MCharacter[nPers].curTalk = _ctx->parm; @@ -1998,7 +2049,8 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg if (MCharacter[nPers].bAlwaysBack) { _ctx->text = curBackText = new RMTextDialogScrolling(Loc); if (bTonyIsSpeaking) - curBackText->Hide(); + CORO_INVOKE_0(curBackText->Hide); + _ctx->bIsBack = true; } else _ctx->text = new RMTextDialog; @@ -2006,7 +2058,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg _ctx->text->SetSkipStatus(!MCharacter[nPers].bAlwaysBack); _ctx->text->SetColor(MCharacter[nPers].r,MCharacter[nPers].g,MCharacter[nPers].b); _ctx->text->WriteText(_ctx->string,0); - _ctx->text->SetPosition(pt); + _ctx->text->SetPosition(_ctx->pt); } if (!bSkipIdle) { @@ -2022,7 +2074,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg // Aspetta la fine della visualizzazione _ctx->text->SetCustomSkipHandle(hSkipIdle); - _ctx->text->WaitForEndDisplay(); + CORO_INVOKE_0(_ctx->text->WaitForEndDisplay); } if (_ctx->curVoc) { @@ -2046,9 +2098,9 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg if ((MCharacter[nPers].bInTexts && MCharacter[nPers].numtexts== 0) || !MCharacter[nPers].bInTexts) { // Cerca di eseguire la funzione custom per chiudere la parlata MCharacter[nPers].curTalk = (MCharacter[nPers].curTalk%10) + MCharacter[nPers].curgroup*10; - _ctx->h = mpalQueryDoAction(31,MCharacter[nPers].item->MpalCode(),MCharacter[nPers].curTalk); - if (_ctx->h!=INVALID_HANDLE_VALUE) - WaitForSingleObject(_ctx->h,INFINITE); + _ctx->h = mpalQueryDoActionU32(31,MCharacter[nPers].item->MpalCode(),MCharacter[nPers].curTalk); + if (_ctx->h != INVALID_PID_VALUE) + CORO_INVOKE_2(g_scheduler->waitForSingleObject, _ctx->h, INFINITE); MCharacter[nPers].bInTexts = false; MCharacter[nPers].numtexts = 0; @@ -2121,14 +2173,14 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr // Attiva l'oggetto LinkGraphicTask(&_ctx->dc); - _ctx->dc.Show(); + CORO_INVOKE_0(_ctx->dc.Show); // Disegna il puntatore Pointer->SetSpecialPointer(Pointer->PTR_NONE); MainShowMouse(); while (!(Input->MouseLeftClicked() && ((_ctx->sel = _ctx->dc.GetSelection()) != -1))) { - WaitFrame(); + CORO_INVOKE_0(WaitFrame); Freeze(); _ctx->dc.DoFrame(Input->MousePos()); Unfreeze(); @@ -2137,7 +2189,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr // Nascondi il puntatore MainHideMouse(); - _ctx->dc.Hide(); + CORO_INVOKE_0(_ctx->dc.Hide); mpalQueryDialogSelectionU32(_ctx->nChoice, _ctx->sl[_ctx->sel]); // Chiude la scelta @@ -2162,7 +2214,8 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr DECLARE_CUSTOM_FUNCTION(TakeOwnership)(CORO_PARAM, uint32 num, uint32, uint32, uint32) { // EnterCriticalSection(&cs[num]); - WaitForSingleObject(mut[num],INFINITE); +// WaitForSingleObject(mut[num],INFINITE); + warning("TODO"); } DECLARE_CUSTOM_FUNCTION(ReleaseOwnership)(CORO_PARAM, uint32 num, uint32, uint32, uint32) { @@ -2197,33 +2250,50 @@ int curSonoriz = 0; bool bFadeOutStop; -void ThreadFadeInMusic(void *nMusic) { - int i; - int nChannel = (int)nMusic; +void ThreadFadeInMusic(CORO_PARAM, const void *nMusic) { + CORO_BEGIN_CONTEXT; + int i; + CORO_END_CONTEXT(_ctx); + + int nChannel = *(const int *)nMusic; + + CORO_BEGIN_CODE(_ctx); debug("Start FadeIn Music\n"); - for (i = 0; i < 16; i++) { - _vm->SetMusicVolume(nChannel, i * 4); - Sleep(100); + for (_ctx->i = 0; _ctx->i < 16; _ctx->i++) { + _vm->SetMusicVolume(nChannel, _ctx->i * 4); + + CORO_INVOKE_1(g_scheduler->sleep, 100); } _vm->SetMusicVolume(nChannel, 64); debug("End FadeIn Music\n"); - _endthread(); + + CORO_KILL_SELF(); + + CORO_END_CODE; } -void ThreadFadeOutMusic(void *nMusic) { - int i; - int nChannel = (int)nMusic; - int startVolume = _vm->GetMusicVolume(nChannel); +void ThreadFadeOutMusic(CORO_PARAM, const void *nMusic) { + CORO_BEGIN_CONTEXT; + int i; + int startVolume; + CORO_END_CONTEXT(_ctx); + + int nChannel = *(const int *)nMusic; + + CORO_BEGIN_CODE(_ctx); + + _ctx->startVolume = _vm->GetMusicVolume(nChannel); debug("Start FadeOut Music\n"); - for (i = 16; i > 0 && !bFadeOutStop; i--) { - if (i * 4 < startVolume) - _vm->SetMusicVolume(nChannel, i * 4); - Sleep(100); + for (_ctx->i = 16; _ctx->i > 0 && !bFadeOutStop; _ctx->i--) { + if (_ctx->i * 4 < _ctx->startVolume) + _vm->SetMusicVolume(nChannel, _ctx->i * 4); + + CORO_INVOKE_1(g_scheduler->sleep, 100); } if (!bFadeOutStop) @@ -2235,25 +2305,29 @@ void ThreadFadeOutMusic(void *nMusic) { debug("End FadeOut Music\n"); - _endthread(); + CORO_KILL_SELF(); + + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(FadeInSonoriz)(CORO_PARAM, uint32, uint32, uint32, uint32) { - _beginthread(ThreadFadeInMusic, 10240, (void*)curSonoriz); + g_scheduler->createProcess(ThreadFadeInMusic, &curSonoriz, sizeof(int)); } DECLARE_CUSTOM_FUNCTION(FadeOutSonoriz)(CORO_PARAM, uint32, uint32, uint32, uint32) { bFadeOutStop = false; - _beginthread(ThreadFadeOutMusic, 10240, (void *)curSonoriz); + g_scheduler->createProcess(ThreadFadeOutMusic, &curSonoriz, sizeof(int)); } DECLARE_CUSTOM_FUNCTION(FadeOutStacchetto)(CORO_PARAM, uint32, uint32, uint32, uint32) { bFadeOutStop = false; - _beginthread(ThreadFadeOutMusic, 10240, (void*)2); + int channel = 2; + g_scheduler->createProcess(ThreadFadeOutMusic, &channel, sizeof(int)); } DECLARE_CUSTOM_FUNCTION(FadeInStacchetto)(CORO_PARAM, uint32, uint32, uint32, uint32) { - _beginthread(ThreadFadeInMusic, 10240, (void*)2); + int channel = 2; + g_scheduler->createProcess(ThreadFadeInMusic, &channel, sizeof(int)); } DECLARE_CUSTOM_FUNCTION(StopSonoriz)(CORO_PARAM, uint32, uint32, uint32, uint32) { @@ -2475,12 +2549,12 @@ DECLARE_CUSTOM_FUNCTION(StacchettoFadeEnd)(CORO_PARAM, uint32 nStacc, uint32 bLo DECLARE_CUSTOM_FUNCTION(MustSkipIdleStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { bSkipIdle = true; - SetEvent(hSkipIdle); + g_scheduler->setEvent(hSkipIdle); } DECLARE_CUSTOM_FUNCTION(MustSkipIdleEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { bSkipIdle = false; - ResetEvent(hSkipIdle); + g_scheduler->resetEvent(hSkipIdle); } DECLARE_CUSTOM_FUNCTION(PatIrqFreeze)(CORO_PARAM, uint32 bStatus, uint32, uint32, uint32) { @@ -2488,70 +2562,94 @@ DECLARE_CUSTOM_FUNCTION(PatIrqFreeze)(CORO_PARAM, uint32 bStatus, uint32, uint32 } DECLARE_CUSTOM_FUNCTION(OpenInitLoadMenu)(CORO_PARAM, uint32, uint32, uint32, uint32) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + Freeze(); - _vm->OpenInitLoadMenu(); + CORO_INVOKE_0(_vm->OpenInitLoadMenu); Unfreeze(); + + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(OpenInitOptions)(CORO_PARAM, uint32, uint32, uint32, uint32) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + Freeze(); - _vm->OpenInitOptions(); + CORO_INVOKE_0(_vm->OpenInitOptions); Unfreeze(); + + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(DoCredits)(CORO_PARAM, uint32 nMsg, uint32 dwTime, uint32, uint32) { - RMMessage msg(nMsg); - RMTextDialog *text; - HANDLE hDisable = CreateEvent(NULL, true, false, NULL); - int i; - uint32 startTime; + CORO_BEGIN_CONTEXT; + RMMessage *msg; + RMTextDialog *text; + uint32 hDisable; + int i; + uint32 startTime; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + _ctx->msg = new RMMessage(nMsg); + _ctx->hDisable = g_scheduler->createEvent(true, false); - text = new RMTextDialog[msg.NumPeriods()]; + _ctx->text = new RMTextDialog[_ctx->msg->NumPeriods()]; - for (i = 0; i < msg.NumPeriods(); i++) { - text[i].SetInput(Input); + for (_ctx->i = 0; _ctx->i < _ctx->msg->NumPeriods(); _ctx->i++) { + _ctx->text[_ctx->i].SetInput(Input); // Allineamento - if (msg[i][0] == '@') { - text[i].SetAlignType(RMText::HCENTER, RMText::VTOP); - text[i].WriteText(&msg[i][1], 3); - text[i].SetPosition(RMPoint(414, 70 + i * 26)); // 70 + if ((*_ctx->msg)[_ctx->i][0] == '@') { + _ctx->text[_ctx->i].SetAlignType(RMText::HCENTER, RMText::VTOP); + _ctx->text[_ctx->i].WriteText(_ctx->msg[_ctx->i][1], 3); + _ctx->text[_ctx->i].SetPosition(RMPoint(414, 70 + _ctx->i * 26)); // 70 } else { - text[i].SetAlignType(RMText::HLEFT,RMText::VTOP); - text[i].WriteText(msg[i], 3); - text[i].SetPosition(RMPoint(260, 70 + i * 26)); + _ctx->text[_ctx->i].SetAlignType(RMText::HLEFT,RMText::VTOP); + _ctx->text[_ctx->i].WriteText((*_ctx->msg)[_ctx->i], 3); + _ctx->text[_ctx->i].SetPosition(RMPoint(260, 70 + _ctx->i * 26)); } // Setta la posizione - text[i].SetAlwaysDisplay(); - text[i].SetForcedTime(dwTime * 1000); - text[i].SetNoTab(); + _ctx->text[_ctx->i].SetAlwaysDisplay(); + _ctx->text[_ctx->i].SetForcedTime(dwTime * 1000); + _ctx->text[_ctx->i].SetNoTab(); // Aspetta la fine della visualizzazione - text[i].SetCustomSkipHandle(hDisable); + _ctx->text[_ctx->i].SetCustomSkipHandle(_ctx->hDisable); // Registra il testo - LinkGraphicTask(&text[i]); + LinkGraphicTask(&_ctx->text[_ctx->i]); } - startTime = _vm->GetTime(); + _ctx->startTime = _vm->GetTime(); - while (startTime + dwTime * 1000 > _vm->GetTime()) { - WaitFrame(); + while (_ctx->startTime + dwTime * 1000 > _vm->GetTime()) { + CORO_INVOKE_0(WaitFrame); if (Input->MouseLeftClicked() || Input->MouseRightClicked()) break; if ((GetAsyncKeyState(Common::KEYCODE_TAB) & 0x8001) == 0x8001) break; } - SetEvent(hDisable); + g_scheduler->setEvent(_ctx->hDisable); + + CORO_INVOKE_0(WaitFrame); + CORO_INVOKE_0(WaitFrame); - WaitFrame(); - WaitFrame(); + delete[] _ctx->text; + delete _ctx->msg; - delete[] text; + CORO_END_CODE; } @@ -2776,7 +2874,7 @@ void SetupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation // Crea l'evento per skippare le idle - hSkipIdle = CreateEvent(NULL, true, false, NULL); + hSkipIdle = g_scheduler->createEvent(true, false); } } // end of namespace Tony diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 28e8f14d38..d04e1f0a13 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -2048,23 +2048,23 @@ RMTextDialog::RMTextDialog() : RMText() { m_bForceNoTime = false; m_bAlwaysDisplay = false; m_bNoTab = false; - hCustomSkip = INVALID_HANDLE_VALUE; - hCustomSkip2 = INVALID_HANDLE_VALUE; + hCustomSkip = INVALID_PID_VALUE; + hCustomSkip2 = INVALID_PID_VALUE; m_input = NULL; // Crea l'evento di fine displaying - hEndDisplay = CreateEvent(NULL, false, false, NULL); + hEndDisplay = g_scheduler->createEvent(false, false); } RMTextDialog::~RMTextDialog() { - CloseHandle(hEndDisplay); + g_scheduler->closeEvent(hEndDisplay); } void RMTextDialog::Show(void) { m_bShowed = true; } -void RMTextDialog::Hide(void) { +void RMTextDialog::Hide(CORO_PARAM) { m_bShowed = false; } @@ -2084,7 +2084,7 @@ void RMTextDialog::WriteText(RMString text, RMFontColor *font, int *time) { void RMTextDialog::SetSkipStatus(bool bEnabled) { - m_bSkipStatus=bEnabled; + m_bSkipStatus = bEnabled; } void RMTextDialog::ForceTime(void) { @@ -2107,53 +2107,70 @@ void RMTextDialog::SetAlwaysDisplay(void) { m_bAlwaysDisplay = true; } -bool RMTextDialog::RemoveThis(void) { +void RMTextDialog::RemoveThis(CORO_PARAM, bool &result) { + CORO_BEGIN_CONTEXT; + bool expired; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + // Presume successful result + result = true; + // Frase NON di background if (m_bSkipStatus) { - if (!(bCfgDubbing && hCustomSkip2 != INVALID_HANDLE_VALUE)) + if (!(bCfgDubbing && hCustomSkip2 != INVALID_PID_VALUE)) if (bCfgTimerizedText) { if (!m_bForceNoTime) if (_vm->GetTime() > (uint32)m_time + m_startTime) - return true; + return; } if (!m_bNoTab) if ((GetAsyncKeyState(Common::KEYCODE_TAB) & 0x8001) == 0x8001) - return true; + return; if (!m_bNoTab) if (m_input) if (m_input->MouseLeftClicked() || m_input->MouseRightClicked()) - return true; + return; } // Frase di background else { - if (!(bCfgDubbing && hCustomSkip2 != INVALID_HANDLE_VALUE)) + if (!(bCfgDubbing && hCustomSkip2 != INVALID_PID_VALUE)) if (!m_bForceNoTime) if (_vm->GetTime() > (uint32)m_time + m_startTime) - return true; + return; } // Se il tempo forzato if (m_bForceTime) if (_vm->GetTime() > (uint32)m_time + m_startTime) - return true; + return; - if (hCustomSkip != INVALID_HANDLE_VALUE) - if (WaitForSingleObject(hCustomSkip, 0) == WAIT_OBJECT_0) - return true; + if (hCustomSkip != INVALID_PID_VALUE) { + CORO_INVOKE_3(g_scheduler->waitForSingleObject, hCustomSkip, 0, &_ctx->expired); + // == WAIT_OBJECT_0 + if (!_ctx->expired) + return; + } + + if (bCfgDubbing && hCustomSkip2 != INVALID_PID_VALUE) { + CORO_INVOKE_3(g_scheduler->waitForSingleObject, hCustomSkip2, 0, &_ctx->expired); + // == WAIT_OBJECT_0 + if (!_ctx->expired) + return; + } - if (bCfgDubbing && hCustomSkip2 != INVALID_HANDLE_VALUE) - if (WaitForSingleObject(hCustomSkip2,0) == WAIT_OBJECT_0) - return true; + result = false; - return false; + CORO_END_CODE; } void RMTextDialog::Unregister(void) { RMGfxTask::Unregister(); assert(m_nInList == 0); - SetEvent(hEndDisplay); + g_scheduler->setEvent(hEndDisplay); } void RMTextDialog::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { @@ -2168,16 +2185,16 @@ void RMTextDialog::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { } } -void RMTextDialog::SetCustomSkipHandle(HANDLE hCustom) { +void RMTextDialog::SetCustomSkipHandle(uint32 hCustom) { hCustomSkip = hCustom; } -void RMTextDialog::SetCustomSkipHandle2(HANDLE hCustom) { +void RMTextDialog::SetCustomSkipHandle2(uint32 hCustom) { hCustomSkip2 = hCustom; } -void RMTextDialog::WaitForEndDisplay(void) { - WaitForSingleObject(hEndDisplay, INFINITE); +void RMTextDialog::WaitForEndDisplay(CORO_PARAM) { + g_scheduler->waitForSingleObject(coroParam, hEndDisplay, INFINITE); } void RMTextDialog::SetInput(RMInput *input) { @@ -2231,9 +2248,16 @@ RMTextItemName::~RMTextItemName() { } -void RMTextItemName::DoFrame(RMGfxTargetBuffer& bigBuf, RMLocation &loc, RMPointer &ptr, RMInventory &inv) { - RMString itemName; - RMItem *lastItem = m_item; +void RMTextItemName::DoFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation &loc, RMPointer &ptr, RMInventory &inv) { + CORO_BEGIN_CONTEXT; + RMString itemName; + RMItem *lastItem; + uint32 hThread; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + _ctx->lastItem = m_item; // Si aggiunge alla lista se c'e' bisogno if (!m_nInList) @@ -2248,27 +2272,29 @@ void RMTextItemName::DoFrame(RMGfxTargetBuffer& bigBuf, RMLocation &loc, RMPoint else m_item = loc.WhichItemIsIn(m_mpos); - itemName = ""; + _ctx->itemName = ""; // Si fa dare il nuovo nome if (m_item != NULL) - m_item->GetName(itemName); + m_item->GetName(_ctx->itemName); // Se lo scrive - WriteText(itemName, 1); + WriteText(_ctx->itemName, 1); // Se e' diverso dal precedente, e' il caso di aggiornare anche il puntatore con la WhichPointer - if (lastItem != m_item) { + if (_ctx->lastItem != m_item) { if (m_item == NULL) ptr.SetSpecialPointer(RMPointer::PTR_NONE); else { - HANDLE hThread = mpalQueryDoAction(20, m_item->MpalCode(), 0); - if (hThread == INVALID_HANDLE_VALUE) + _ctx->hThread = mpalQueryDoActionU32(20, m_item->MpalCode(), 0); + if (_ctx->hThread == INVALID_PID_VALUE) ptr.SetSpecialPointer(RMPointer::PTR_NONE); else - WaitForSingleObject(hThread,INFINITE); + CORO_INVOKE_2(g_scheduler->waitForSingleObject, _ctx->hThread, INFINITE); } } + + CORO_END_CODE; } @@ -2318,18 +2344,18 @@ RMDialogChoice::RMDialogChoice() { DlgText.LoadPaletteWA(dlgpal); DlgTextLine.LoadPaletteWA(dlgpal); - hUnreg=CreateEvent(NULL, false, false, NULL); + hUnreg = g_scheduler->createEvent(false, false); bRemoveFromOT = false; } RMDialogChoice::~RMDialogChoice() { - CloseHandle(hUnreg); + g_scheduler->closeEvent(hUnreg); } void RMDialogChoice::Unregister(void) { RMGfxWoodyBuffer::Unregister(); assert(!m_nInList); - PulseEvent(hUnreg); + g_scheduler->pulseEvent(hUnreg); bRemoveFromOT = false; } @@ -2444,7 +2470,16 @@ void RMDialogChoice::SetSelected(int pos) { m_curSelection = pos; } -void RMDialogChoice::Show(RMGfxTargetBuffer *bigBuf) { +void RMDialogChoice::Show(CORO_PARAM, RMGfxTargetBuffer *bigBuf) { + CORO_BEGIN_CONTEXT; + RMPoint destpt; + int deltay; + int starttime; + int elaps; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + Prepare(); m_bShow = false; @@ -2454,30 +2489,28 @@ void RMDialogChoice::Show(RMGfxTargetBuffer *bigBuf) { if (0) { m_bShow = true; } else { - RMPoint destpt; - int deltay; - int starttime = _vm->GetTime(); - int elaps; - - deltay=480 - m_ptDrawPos.y; - destpt = m_ptDrawPos; + _ctx->starttime = _vm->GetTime(); + _ctx->deltay = 480 - m_ptDrawPos.y; + _ctx->destpt = m_ptDrawPos; m_ptDrawPos.Set(0, 480); if (!m_nInList && bigBuf != NULL) bigBuf->AddPrim(new RMGfxPrimitive(this)); m_bShow = true; - elaps = 0; - while (elaps < 700) { - MainWaitFrame(); + _ctx->elaps = 0; + while (_ctx->elaps < 700) { + CORO_INVOKE_0(MainWaitFrame); MainFreeze(); - elaps = _vm->GetTime() - starttime; - m_ptDrawPos.y = 480 - ((deltay * 100) / 700 * elaps) / 100; + _ctx->elaps = _vm->GetTime() - _ctx->starttime; + m_ptDrawPos.y = 480 - ((_ctx->deltay * 100) / 700 * _ctx->elaps) / 100; MainUnfreeze(); } - m_ptDrawPos.y = destpt.y; + m_ptDrawPos.y = _ctx->destpt.y; } + + CORO_END_CODE; } void RMDialogChoice::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { @@ -2489,26 +2522,34 @@ void RMDialogChoice::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { } -void RMDialogChoice::Hide(void) { - if (1) { +void RMDialogChoice::Hide(CORO_PARAM) { + CORO_BEGIN_CONTEXT; int deltay; - int starttime = _vm->GetTime(); + int starttime; int elaps; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); - deltay=480 - m_ptDrawPos.y; - elaps = 0; - while (elaps < 700) { - MainWaitFrame(); + if (1) { + _ctx->starttime = _vm->GetTime(); + + _ctx->deltay = 480 - m_ptDrawPos.y; + _ctx->elaps = 0; + while (_ctx->elaps < 700) { + CORO_INVOKE_0(MainWaitFrame); MainFreeze(); - elaps=_vm->GetTime()-starttime; - m_ptDrawPos.y=480-((deltay*100)/700*(700-elaps))/100; + _ctx->elaps = _vm->GetTime()-_ctx->starttime; + m_ptDrawPos.y = 480 - ((_ctx->deltay * 100) / 700 * (700 - _ctx->elaps)) / 100; MainUnfreeze(); } } m_bShow = false; bRemoveFromOT = true; - WaitForSingleObject(hUnreg, INFINITE); + CORO_INVOKE_2(g_scheduler->waitForSingleObject, hUnreg, INFINITE); + + CORO_END_CODE; } diff --git a/engines/tony/font.h b/engines/tony/font.h index 3012502d4c..0306c6c673 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -51,6 +51,7 @@ #include "common/system.h" #include "tony/gfxcore.h" #include "tony/resid.h" +#include "tony/sched.h" namespace Tony { @@ -247,12 +248,12 @@ class RMTextDialog : public RMText { int m_time; bool m_bSkipStatus; RMPoint dst; - HANDLE hEndDisplay; + uint32 hEndDisplay; bool m_bShowed; bool m_bForceTime; bool m_bForceNoTime; - HANDLE hCustomSkip; - HANDLE hCustomSkip2; + uint32 hCustomSkip; + uint32 hCustomSkip2; RMInput *m_input; bool m_bAlwaysDisplay; bool m_bNoTab; @@ -267,7 +268,7 @@ class RMTextDialog : public RMText { // Overloading della funzione ereditata da RMGfxTask per decidere // quando eliminare un oggetto dalla OTLIST - virtual bool RemoveThis(void); + virtual void RemoveThis(CORO_PARAM, bool &result); // Overloading della funzione di deregistrazione, utilizzata per capire // quando ci leviamo di torno @@ -280,9 +281,9 @@ class RMTextDialog : public RMText { void SetPosition(RMPoint pt) { dst=pt; } // Aspetta che venga finita la visualizzazione - void WaitForEndDisplay(void); - void SetCustomSkipHandle(HANDLE hCustomSkip); - void SetCustomSkipHandle2(HANDLE hCustomSkip); + void WaitForEndDisplay(CORO_PARAM); + void SetCustomSkipHandle(uint32 hCustomSkip); + void SetCustomSkipHandle2(uint32 hCustomSkip); void SetSkipStatus(bool bEnabled); void SetForcedTime(uint32 dwTime); void SetNoTab(void); @@ -294,7 +295,7 @@ class RMTextDialog : public RMText { void SetInput(RMInput* input); void Show(void); - void Hide(void); + void Hide(CORO_PARAM); }; class RMTextDialogScrolling : public RMTextDialog { @@ -332,7 +333,7 @@ public: void SetMouseCoord(RMPoint m) { m_mpos=m; } - void DoFrame(RMGfxTargetBuffer &bigBuf, RMLocation &loc, RMPointer &ptr, RMInventory &inv); + void DoFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation &loc, RMPointer &ptr, RMInventory &inv); virtual void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); RMPoint GetHotspot(); @@ -358,7 +359,7 @@ private: RMGfxSourceBuffer8 DlgText; RMGfxSourceBuffer8 DlgTextLine; RMPoint m_ptDrawPos; - HANDLE hUnreg; + uint32 hUnreg; bool bRemoveFromOT; protected: @@ -389,8 +390,8 @@ public: // Mostra e nasconde la scelta, con eventuali animazioni // NOTA: Se non viene passato parametro alla Show(), obbligo del // chiamante assicurarsi che la classe venga inserita alla OTlist - void Show(RMGfxTargetBuffer* bigBuf = NULL); - void Hide(void); + void Show(CORO_PARAM, RMGfxTargetBuffer* bigBuf = NULL); + void Hide(CORO_PARAM); // Polling di aggiornamento void DoFrame(RMPoint ptMousePos); diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 4eef8b0c96..59196ec18a 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -112,8 +112,8 @@ void MainUnfreeze(void) { _vm->GetEngine()->Unfreeze(); } -void MainWaitFrame(void) { - WaitForSingleObject(_vm->m_hEndOfFrame, INFINITE); +void MainWaitFrame(CORO_PARAM) { + g_scheduler->waitForSingleObject(coroParam, _vm->m_hEndOfFrame, INFINITE); } void MainShowMouse(void) { @@ -144,8 +144,8 @@ void MainCloseWipe(void) { _vm->GetEngine()->CloseWipe(); } -void MainWaitWipeEnd(void) { - _vm->GetEngine()->WaitWipeEnd(); +void MainWaitWipeEnd(CORO_PARAM) { + _vm->GetEngine()->WaitWipeEnd(coroParam); } void MainEnableGUI(void) { diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index acf6339e73..12de3573eb 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -65,10 +65,12 @@ extern bool bSkipSfxNoLoop; bool bIdleExited; -void ExitAllIdles(CORO_PARAM, int nCurLoc) { +void ExitAllIdles(CORO_PARAM, const void *param) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); + int nCurLoc = *(const int *)param; + CORO_BEGIN_CODE(_ctx); // Chiude le idle @@ -96,28 +98,27 @@ RMGfxEngine::~RMGfxEngine() { g_system->deleteMutex(csMainLoop); } -void RMGfxEngine::OpenOptionScreen(int type) { - bool bRes = false; - - switch (type) { - case 0: - bRes = m_opt.Init(m_bigBuf); - break; - case 1: - bRes = m_opt.InitLoadMenuOnly(m_bigBuf,true); - break; - case 2: - bRes = m_opt.InitNoLoadSave(m_bigBuf); - break; - case 3: - bRes = m_opt.InitLoadMenuOnly(m_bigBuf,false); - break; - case 4: - bRes = m_opt.InitSaveMenuOnly(m_bigBuf,false); - break; - } +void RMGfxEngine::OpenOptionScreen(CORO_PARAM, int type) { + CORO_BEGIN_CONTEXT; + bool bRes; + CORO_END_CONTEXT(_ctx); - if (bRes) { + CORO_BEGIN_CODE(_ctx); + + _ctx->bRes = false; + + if (type == 0) + _ctx->bRes = m_opt.Init(m_bigBuf); + else if (type == 1) + _ctx->bRes = m_opt.InitLoadMenuOnly(m_bigBuf, true); + else if (type == 2) + _ctx->bRes = m_opt.InitNoLoadSave(m_bigBuf); + else if (type == 3) + _ctx->bRes = m_opt.InitLoadMenuOnly(m_bigBuf, false); + else if (type == 4) + _ctx->bRes = m_opt.InitSaveMenuOnly(m_bigBuf, false); + + if (_ctx->bRes) { _vm->PauseSound(true); DisableInput(); @@ -135,16 +136,23 @@ void RMGfxEngine::OpenOptionScreen(int type) { if (type == 1 || type == 2) { bIdleExited = true; } else { - m_tony.StopNoAction(); + CORO_INVOKE_0(m_tony.StopNoAction); - uint32 id; bIdleExited = false; - CreateThread(NULL, 10240, (LPTHREAD_START_ROUTINE)ExitAllIdles, (void *)m_nCurLoc, 0, &id); + + g_scheduler->createProcess(ExitAllIdles, &m_nCurLoc, sizeof(int)); } } + + CORO_END_CODE; } -void RMGfxEngine::DoFrame(bool bDrawLocation) { +void RMGfxEngine::DoFrame(CORO_PARAM, bool bDrawLocation) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + g_system->lockMutex(csMainLoop); // Poll dei dispositivi di input @@ -212,15 +220,15 @@ void RMGfxEngine::DoFrame(bool bDrawLocation) { if (m_bGUIOption) { if (!m_tony.InAction() && m_bInput) { if ((m_input.MouseLeftClicked() && m_input.MousePos().x < 3 && m_input.MousePos().y < 3)) { - OpenOptionScreen(0); + OpenOptionScreen(nullContext, 0); goto SKIPCLICKSINISTRO; } else if ((GetAsyncKeyState(Common::KEYCODE_ESCAPE)&0x8001) == 0x8001) - OpenOptionScreen(0); + OpenOptionScreen(nullContext, 0); else if (_vm->getIsDemo()) { if ((GetAsyncKeyState(Common::KEYCODE_F3) & 0x8001) == 0x8001) - OpenOptionScreen(3); + OpenOptionScreen(nullContext, 3); else if ((GetAsyncKeyState(Common::KEYCODE_F2) & 0x8001) == 0x8001) - OpenOptionScreen(4); + OpenOptionScreen(nullContext, 4); } } } @@ -287,7 +295,7 @@ SKIPCLICKSINISTRO: // Aggiorna il nome sotto il puntatore del mouse m_itemName.SetMouseCoord(m_input.MousePos()); if (!m_inter.Active() && !m_inv.MiniActive()) - m_itemName.DoFrame(m_bigBuf,m_loc,m_point,m_inv); + CORO_INVOKE_4(m_itemName.DoFrame, m_bigBuf, m_loc, m_point, m_inv); } // Inventario & interfaccia @@ -325,7 +333,7 @@ SKIPCLICKSINISTRO: switch (m_nWipeType) { case 1: if (!(m_rcWipeEllipse.bottom - m_rcWipeEllipse.top >= FSTEP * 2)) { - SetEvent(m_hWipeEvent); + g_scheduler->setEvent(m_hWipeEvent); m_nWipeType = 3; break; } @@ -338,7 +346,7 @@ SKIPCLICKSINISTRO: case 2: if (!(m_rcWipeEllipse.bottom - m_rcWipeEllipse.top < 480 - FSTEP)) { - SetEvent(m_hWipeEvent); + g_scheduler->setEvent(m_hWipeEvent); m_nWipeType = 3; break; } @@ -352,6 +360,8 @@ SKIPCLICKSINISTRO: } g_system->unlockMutex(csMainLoop); + + CORO_END_CODE; } @@ -524,7 +534,7 @@ HANDLE RMGfxEngine::LoadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { void RMGfxEngine::UnloadLocation(CORO_PARAM, bool bDoOnExit, HANDLE *result) { CORO_BEGIN_CONTEXT; - HANDLE h; + uint32 h; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -534,9 +544,9 @@ void RMGfxEngine::UnloadLocation(CORO_PARAM, bool bDoOnExit, HANDLE *result) { // On Exit? if (bDoOnExit) { - _ctx->h = mpalQueryDoAction(1, m_nCurLoc, 0); - if (_ctx->h != INVALID_HANDLE_VALUE) - WaitForSingleObject(_ctx->h, INFINITE); + _ctx->h = mpalQueryDoActionU32(1, m_nCurLoc, 0); + if (_ctx->h != INVALID_PID_VALUE) + CORO_INVOKE_2(g_scheduler->waitForSingleObject, _ctx->h, INFINITE); } MainFreeze(); @@ -588,7 +598,7 @@ void RMGfxEngine::Init(/*HINSTANCE hInst*/) { bIdleExited = false; m_bOption = false; m_bWiping = false; - m_hWipeEvent = CreateEvent(NULL, false, false, NULL); + m_hWipeEvent = g_scheduler->createEvent(false, false); // Crea l'evento di freeze csMainLoop = g_system->createMutex(); @@ -986,8 +996,8 @@ void RMGfxEngine::CloseWipe(void) { m_bWiping = false; } -void RMGfxEngine::WaitWipeEnd(void) { - WaitForSingleObject(m_hWipeEvent,INFINITE); +void RMGfxEngine::WaitWipeEnd(CORO_PARAM) { + g_scheduler->waitForSingleObject(coroParam, m_hWipeEvent, INFINITE); } } // End of namespace Tony diff --git a/engines/tony/gfxengine.h b/engines/tony/gfxengine.h index 42b2050046..11d591b408 100644 --- a/engines/tony/gfxengine.h +++ b/engines/tony/gfxengine.h @@ -85,7 +85,7 @@ private: OSystem::MutexRef csMainLoop; int m_nWipeType; - HANDLE m_hWipeEvent; + uint32 m_hWipeEvent; int m_nWipeStep; bool m_bMustEnterMenu; @@ -103,7 +103,7 @@ public: virtual ~RMGfxEngine(); // Draw the next frame - void DoFrame(bool bDrawLocation); + void DoFrame(CORO_PARAM, bool bDrawLocation); // Initialises the graphics engine void Init(); @@ -118,7 +118,7 @@ public: void GDIControl(bool bCon); // Warns when entering or exits the options menu - void OpenOptionScreen(int type); + void OpenOptionScreen(CORO_PARAM, int type); // Enables or disables mouse input void EnableInput(void); @@ -157,7 +157,7 @@ public: // Wipe void InitWipe(int type); void CloseWipe(void); - void WaitWipeEnd(void); + void WaitWipeEnd(CORO_PARAM); void SetPalesati(bool bpal) { m_inter.SetPalesati(bpal); } }; diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 4eced3fbd5..a412f9cfd2 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -248,12 +248,12 @@ int RMPattern::Init(RMSfx *sfx, bool bPlayP0, byte *bFlag) { return m_nCurSprite; } -int RMPattern::Update(HANDLE hEndPattern, byte &bFlag, RMSfx *sfx) { +int RMPattern::Update(uint32 hEndPattern, byte &bFlag, RMSfx *sfx) { int CurTime = _vm->GetTime(); // Se la speed e' 0, il pattern non avanza mai if (m_speed == 0) { - PulseEvent(hEndPattern); + g_scheduler->pulseEvent(hEndPattern); bFlag=m_slots[m_nCurSlot].m_flag; return m_nCurSprite; } @@ -266,7 +266,8 @@ int RMPattern::Update(HANDLE hEndPattern, byte &bFlag, RMSfx *sfx) { if (m_nCurSlot == m_nSlots) { m_nCurSlot = 0; bFlag = m_slots[m_nCurSlot].m_flag; - PulseEvent(hEndPattern); + + g_scheduler->pulseEvent(hEndPattern); // @@@ Se non c'e' loop avverte che il pattern e' finito // Se non c'e' loop rimane sull'ultimo frame @@ -705,9 +706,8 @@ bool RMItem::DoFrame(RMGfxTargetBuffer *bigBuf, bool bAddToList) { return false; // Facciamo un update del pattern, che ci ritorna anche il frame corrente - // FIXME: Get rid of HANDLE cast if (m_nCurPattern != 0) - m_nCurSprite = m_patterns[m_nCurPattern].Update((HANDLE)m_hEndPattern, m_bCurFlag, m_sfx); + m_nCurSprite = m_patterns[m_nCurPattern].Update(m_hEndPattern, m_bCurFlag, m_sfx); // Se la funzione ha ritornato -1, vuol dire che il pattern e' finito if (m_nCurSprite == -1) { @@ -844,7 +844,7 @@ RMItem::~RMItem() { } //FIXME: Pass uint32 directly for hCustomSkip -void RMItem::WaitForEndPattern(CORO_PARAM, HANDLE hCustomSkip) { +void RMItem::WaitForEndPattern(CORO_PARAM, uint32 hCustomSkip) { CORO_BEGIN_CONTEXT; uint32 h[2]; CORO_END_CONTEXT(_ctx); @@ -852,10 +852,10 @@ void RMItem::WaitForEndPattern(CORO_PARAM, HANDLE hCustomSkip) { CORO_BEGIN_CODE(_ctx); if (m_nCurPattern != 0) { - if (hCustomSkip == INVALID_HANDLE_VALUE) + if (hCustomSkip == INVALID_PID_VALUE) CORO_INVOKE_2(g_scheduler->waitForSingleObject, m_hEndPattern, INFINITE); else { - _ctx->h[0] = (uint32)hCustomSkip; + _ctx->h[0] = hCustomSkip; _ctx->h[1] = m_hEndPattern; CORO_INVOKE_4(g_scheduler->waitForMultipleObjects, 2, &_ctx->h[0], false, INFINITE); } @@ -888,13 +888,13 @@ void RMItem::PauseSound(bool bPause) { RMWipe::RMWipe() { - m_hUnregistered=CreateEvent(NULL,false,false,NULL); - m_hEndOfFade=CreateEvent(NULL,false,false,NULL); + m_hUnregistered = g_scheduler->createEvent(false, false); + m_hEndOfFade = g_scheduler->createEvent(false, false); } RMWipe::~RMWipe() { - CloseHandle(m_hUnregistered); - CloseHandle(m_hEndOfFade); + g_scheduler->closeEvent(m_hUnregistered); + g_scheduler->closeEvent(m_hEndOfFade); } int RMWipe::Priority(void) { @@ -904,19 +904,28 @@ int RMWipe::Priority(void) { void RMWipe::Unregister(void) { RMGfxTask::Unregister(); assert(m_nInList == 0); - SetEvent(m_hUnregistered); + g_scheduler->setEvent(m_hUnregistered); } bool RMWipe::RemoveThis(void) { return m_bUnregister; } -void RMWipe::WaitForFadeEnd(void) { - WaitForSingleObject(m_hEndOfFade, INFINITE); +void RMWipe::WaitForFadeEnd(CORO_PARAM) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + CORO_INVOKE_2(g_scheduler->waitForSingleObject, m_hEndOfFade, INFINITE); + m_bEndFade = true; m_bFading = false; - MainWaitFrame(); - MainWaitFrame(); + + CORO_INVOKE_0(MainWaitFrame); + CORO_INVOKE_0(MainWaitFrame); + + CORO_END_CODE; } void RMWipe::CloseFade(void) { @@ -958,7 +967,7 @@ void RMWipe::DoFrame(RMGfxTargetBuffer &bigBuf) { m_nFadeStep++; if (m_nFadeStep == 10) { - SetEvent(m_hEndOfFade); + g_scheduler->setEvent(m_hEndOfFade); } } } diff --git a/engines/tony/loc.h b/engines/tony/loc.h index 153ef7f18c..744dab3c25 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -171,7 +171,7 @@ public: // Update the pattern, checking to see if it's time to change slot and executing // any associated commands - int Update(HANDLE hEndPattern, byte& bFlag, RMSfx* sfx); + int Update(uint32 hEndPattern, byte &bFlag, RMSfx *sfx); // Stop a sound effect void StopSfx(RMSfx *sfx); @@ -292,7 +292,7 @@ public: void Unload(void); // Aspetta la fine del pattern in play - void WaitForEndPattern(CORO_PARAM, HANDLE hCustomSkip = INVALID_HANDLE_VALUE); + void WaitForEndPattern(CORO_PARAM, uint32 hCustomSkip = INVALID_PID_VALUE); // Setta un nuovo hotspot per l'oggetto void ChangeHotspot(RMPoint pt); @@ -494,9 +494,9 @@ private: bool m_bFading; bool m_bEndFade; bool m_bUnregister; - HANDLE m_hUnregistered; + uint32 m_hUnregistered; int m_nFadeStep; - HANDLE m_hEndOfFade; + uint32 m_hEndOfFade; bool m_bMustRegister; RMItem m_wip0r; @@ -510,7 +510,7 @@ public: void InitFade(int type); void CloseFade(void); - void WaitForFadeEnd(void); + void WaitForFadeEnd(CORO_PARAM); virtual void Unregister(void); virtual bool RemoveThis(void); diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index 27ef3f99c5..9d6ef19e55 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -174,10 +174,8 @@ static const byte *ParseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { /* Periodi */ num = READ_LE_UINT16(lpBuf); lpBuf += 2; - if (num >= MAX_PERIODS_PER_DIALOG - 1) { - Common::String msg = Common::String::format("Too much periods in dialog #%d", lpmdDialog->nObj); - MessageBox(msg); - } + if (num >= MAX_PERIODS_PER_DIALOG - 1) + error("Too much periods in dialog #%d", lpmdDialog->nObj); for (i = 0; i < num; i++) { lpmdDialog->PeriodNums[i] = READ_LE_UINT16(lpBuf); lpBuf += 2; @@ -195,19 +193,15 @@ static const byte *ParseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { num = READ_LE_UINT16(lpBuf); lpBuf += 2; curCmd = 0; - if (num >= MAX_GROUPS_PER_DIALOG) { - Common::String msg = Common::String::format("Too much groups in dialog #%d", lpmdDialog->nObj); - MessageBox(msg); - } + if (num >= MAX_GROUPS_PER_DIALOG) + error("Too much groups in dialog #%d", lpmdDialog->nObj); for (i = 0; i < num; i++) { lpmdDialog->Group[i].num = READ_LE_UINT16(lpBuf); lpBuf += 2; lpmdDialog->Group[i].nCmds = *lpBuf; lpBuf++; - if (lpmdDialog->Group[i].nCmds >= MAX_COMMANDS_PER_GROUP) { - Common::String msg = Common::String::format("Too much commands in group #%d in dialog #%d",lpmdDialog->Group[i].num,lpmdDialog->nObj); - MessageBox(msg); - } + if (lpmdDialog->Group[i].nCmds >= MAX_COMMANDS_PER_GROUP) + error("Too much commands in group #%d in dialog #%d",lpmdDialog->Group[i].num,lpmdDialog->nObj); for (j = 0; j < lpmdDialog->Group[i].nCmds; j++) { lpmdDialog->Command[curCmd].type = *lpBuf; @@ -262,28 +256,22 @@ static const byte *ParseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { } } - if (curCmd >= MAX_COMMANDS_PER_DIALOG) { - Common::String msg = Common::String::format("Too much commands in dialog #%d",lpmdDialog->nObj); - MessageBox(msg); - } + if (curCmd >= MAX_COMMANDS_PER_DIALOG) + error("Too much commands in dialog #%d",lpmdDialog->nObj); /* Choices */ num=*(uint16 *)lpBuf; lpBuf += 2; - if (num >= MAX_CHOICES_PER_DIALOG) { - Common::String msg = Common::String::format("Too much choices in dialog #%d",lpmdDialog->nObj); - MessageBox(msg); - } + if (num >= MAX_CHOICES_PER_DIALOG) + error("Too much choices in dialog #%d",lpmdDialog->nObj); for (i = 0; i < num; i++) { lpmdDialog->Choice[i].nChoice = READ_LE_UINT16(lpBuf); lpBuf += 2; num2 = *lpBuf++; - if (num2 >= MAX_SELECTS_PER_CHOICE) { - Common::String msg = Common::String::format("Too much selects in choice #%d in dialog #%d",lpmdDialog->Choice[i].nChoice,lpmdDialog->nObj); - MessageBox(msg); - } + if (num2 >= MAX_SELECTS_PER_CHOICE) + error("Too much selects in choice #%d in dialog #%d",lpmdDialog->Choice[i].nChoice,lpmdDialog->nObj); for (j = 0; j < num2; j++) { // When @@ -311,10 +299,8 @@ static const byte *ParseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { // PlayGroup num3 = *lpBuf; *lpBuf++; - if (num3 >= MAX_PLAYGROUPS_PER_SELECT) { - Common::String msg = Common::String::format("Too much playgroups in select #%d in choice #%d in dialog #%d", j, lpmdDialog->Choice[i].nChoice, lpmdDialog->nObj); - MessageBox(msg); - } + if (num3 >= MAX_PLAYGROUPS_PER_SELECT) + error("Too much playgroups in select #%d in choice #%d in dialog #%d", j, lpmdDialog->Choice[i].nChoice, lpmdDialog->nObj); for (z = 0; z < num3; z++) { lpmdDialog->Choice[i].Select[j].wPlayGroup[z] = READ_LE_UINT16(lpBuf); lpBuf += 2; @@ -365,10 +351,8 @@ static const byte *ParseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { CopyMemory(lpmiItem->lpszDescribe,lpBuf, MIN((byte)127, len)); lpBuf+=len; - if (len >= MAX_DESCRIBE_SIZE) { - Common::String msg = Common::String::format("Describe too long in item #%d",lpmiItem->nObj); - MessageBox(msg); - } + if (len >= MAX_DESCRIBE_SIZE) + error("Describe too long in item #%d",lpmiItem->nObj); lpmiItem->nActions=*lpBuf; lpBuf++; @@ -408,10 +392,8 @@ static const byte *ParseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { lpmiItem->Action[i].nCmds=*lpBuf; lpBuf++; - if (lpmiItem->Action[i].nCmds >= MAX_COMMANDS_PER_ACTION) { - Common::String msg = Common::String::format("Too much commands in action #%d in item #%d",lpmiItem->Action[i].num,lpmiItem->nObj); - MessageBox(msg); - } + if (lpmiItem->Action[i].nCmds >= MAX_COMMANDS_PER_ACTION) + error("Too much commands in action #%d in item #%d",lpmiItem->Action[i].num,lpmiItem->nObj); for (j=0;jAction[i].nCmds;j++) { lpmiItem->Command[curCmd].type=*lpBuf; @@ -455,9 +437,8 @@ static const byte *ParseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { curCmd++; if (curCmd >= MAX_COMMANDS_PER_ITEM) { - Common::String msg = Common::String::format("Too much commands in item #%d",lpmiItem->nObj); - MessageBox(msg); - curCmd=0; + error("Too much commands in item #%d",lpmiItem->nObj); + //curCmd=0; } } } diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 0cea50a3d3..d6230d7768 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -137,9 +137,9 @@ uint32 * lpResources; bool bExecutingAction; bool bExecutingDialog; -uint32 nPollingLocations[MAXPOLLINGLOCATIONS]; -HANDLE hEndPollingLocations[MAXPOLLINGLOCATIONS]; -uint32 PollingThreads[MAXPOLLINGLOCATIONS]; +uint32 nPollingLocations[MAXPOLLINGLOCATIONS]; +uint32 hEndPollingLocations[MAXPOLLINGLOCATIONS]; +uint32 PollingThreads[MAXPOLLINGLOCATIONS]; uint32 hAskChoice; uint32 hDoneChoice; @@ -830,14 +830,20 @@ static LPITEM GetItemData(uint32 nOrdItem) { * \****************************************************************************/ -void PASCAL CustomThread(LPCFCALL p) { - // FIXME: Convert to proper corotuine call - warning("FIXME: CustomThread call"); +void CustomThread(CORO_PARAM, const void *param) { + CORO_BEGIN_CONTEXT; + LPCFCALL p; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + _ctx->p = *(LPCFCALL *)param; - lplpFunctions[p->nCf](nullContext, p->arg1, p->arg2, p->arg3, p->arg4); - GlobalFree(p); - ExitThread(1); -// _endthread(); + CORO_INVOKE_4(lplpFunctions[_ctx->p->nCf], _ctx->p->arg1, _ctx->p->arg2, _ctx->p->arg3, _ctx->p->arg4); + + GlobalFree(_ctx->p); + + CORO_END_CODE; } @@ -855,78 +861,87 @@ void PASCAL CustomThread(LPCFCALL p) { * \****************************************************************************/ -void PASCAL ScriptThread(LPMPALSCRIPT s) { - uint i,j,k; - uint32 dwStartTime = timeGetTime(); - uint32 dwCurTime; - uint32 dwId; - static HANDLE cfHandles[MAX_COMMANDS_PER_MOMENT]; - int numHandles = 0; - LPCFCALL p; +void ScriptThread(CORO_PARAM, const void *param) { + CORO_BEGIN_CONTEXT; + uint i, j, k; + uint32 dwStartTime; + uint32 dwCurTime; + uint32 dwId; + int numHandles; + LPCFCALL p; + CORO_END_CONTEXT(_ctx); + + static uint32 cfHandles[MAX_COMMANDS_PER_MOMENT]; + LPMPALSCRIPT s = *(const LPMPALSCRIPT *)param; + + CORO_BEGIN_CODE(_ctx); + + _ctx->dwStartTime = _vm->GetTime(); + _ctx->numHandles = 0; // warning("PlayScript(): Moments: %u\n",s->nMoments); - for (i = 0; i < s->nMoments; i++) { + for (_ctx->i = 0; _ctx->i < s->nMoments; _ctx->i++) { // Dorme il tempo necessario per arrivare al momento successivo - if (s->Moment[i].dwTime == -1) { - WaitForMultipleObjects(numHandles, cfHandles, true, INFINITE); - dwStartTime = timeGetTime(); + if (s->Moment[_ctx->i].dwTime == -1) { + CORO_INVOKE_4(g_scheduler->waitForMultipleObjects, _ctx->numHandles, cfHandles, true, INFINITE); + _ctx->dwStartTime = _vm->GetTime(); } else { - dwCurTime = timeGetTime(); - if (dwCurTime < dwStartTime + (s->Moment[i].dwTime * 100)) { - // warning("PlayScript(): Sleeping %lums\n",dwStartTime+(s->Moment[i].dwTime*100)-dwCurTime); - Sleep(dwStartTime+(s->Moment[i].dwTime * 100) - dwCurTime); + _ctx->dwCurTime = _vm->GetTime(); + if (_ctx->dwCurTime < _ctx->dwStartTime + (s->Moment[_ctx->i].dwTime * 100)) { + // warning("PlayScript(): Sleeping %lums\n",_ctx->dwStartTime+(s->Moment[_ctx->i].dwTime*100)-_ctx->dwCurTime); + CORO_INVOKE_1(g_scheduler->sleep, _ctx->dwStartTime+(s->Moment[_ctx->i].dwTime * 100) - _ctx->dwCurTime); } } - numHandles = 0; - for (j = 0;jMoment[i].nCmds; j++) { - k=s->Moment[i].CmdNum[j]; + _ctx->numHandles = 0; + for (_ctx->j = 0; _ctx->jMoment[_ctx->i].nCmds; _ctx->j++) { + _ctx->k = s->Moment[_ctx->i].CmdNum[_ctx->j]; - switch (s->Command[k].type) { - case 1: - p=(LPCFCALL)GlobalAlloc(GMEM_FIXED, sizeof(CFCALL)); - if (p == NULL) { + if (s->Command[_ctx->k].type == 1) { + _ctx->p=(LPCFCALL)GlobalAlloc(GMEM_FIXED, sizeof(CFCALL)); + if (_ctx->p == NULL) { mpalError = 1; - ExitThread(0); -// _endthread(); + + CORO_KILL_SELF(); + return; } - p->nCf=s->Command[k].nCf; - p->arg1=s->Command[k].arg1; - p->arg2=s->Command[k].arg2; - p->arg3=s->Command[k].arg3; - p->arg4=s->Command[k].arg4; + _ctx->p->nCf=s->Command[_ctx->k].nCf; + _ctx->p->arg1=s->Command[_ctx->k].arg1; + _ctx->p->arg2=s->Command[_ctx->k].arg2; + _ctx->p->arg3=s->Command[_ctx->k].arg3; + _ctx->p->arg4=s->Command[_ctx->k].arg4; // !!! Nuova gestione dei thread - if ((cfHandles[numHandles++] = CreateThread(NULL, 10240, (LPTHREAD_START_ROUTINE)CustomThread,(void *)p, 0, &dwId)) == NULL) { - //if ((cfHandles[numHandles++]=(void*)_beginthread(CustomThread, 10240, (void *)p))==(void*)-1) + if ((cfHandles[_ctx->numHandles++] = g_scheduler->createProcess(CustomThread, &_ctx->p, sizeof(LPCFCALL))) == 0) { mpalError = 1; - ExitThread(0); -// _endthread(); - } - break; - case 2: + CORO_KILL_SELF(); + return; + } + } else if (s->Command[_ctx->k].type == 2) { LockVar(); varSetValue( - s->Command[k].lpszVarName, - EvaluateExpression(s->Command[k].expr) + s->Command[_ctx->k].lpszVarName, + EvaluateExpression(s->Command[_ctx->k].expr) ); UnlockVar(); - break; - default: + } else { mpalError = 1; GlobalFree(s); - ExitThread(0); -// _endthread(); + + CORO_KILL_SELF(); + return; } } } GlobalFree(s); - ExitThread(1); - //_endthread(); + + CORO_KILL_SELF(); + + CORO_END_CODE; } @@ -1063,6 +1078,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { uint32 dwId; int ord; bool delayExpired; + bool expired; MYACTION *MyActions; MYTHREAD *MyThreads; @@ -1122,7 +1138,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { } /* Inizializziamo le routine random */ - //curTime = timeGetTime(); + //curTime = _vm->GetTime(); //srand(curTime); @@ -1157,7 +1173,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { CopyMemory(_ctx->MyActions[_ctx->k].CmdNum, _ctx->curItem->Action[_ctx->j].CmdNum, MAX_COMMANDS_PER_ACTION * sizeof(uint16)); - _ctx->MyActions[_ctx->k].dwLastTime = timeGetTime(); + _ctx->MyActions[_ctx->k].dwLastTime = _vm->GetTime(); _ctx->k++; } } @@ -1172,7 +1188,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { while (1) { /* Cerchiamo tra tutte le idle actions quella a cui manca meno tempo per l'esecuzione */ - _ctx->curTime = timeGetTime(); + _ctx->curTime = _vm->GetTime(); _ctx->dwSleepTime = (uint32)-1L; for (_ctx->k = 0;_ctx->k<_ctx->nIdleActions;_ctx->k++) @@ -1184,8 +1200,11 @@ void LocationPollThread(CORO_PARAM, const void *param) { /* Ci addormentiamo, ma controllando sempre l'evento che viene settato quando viene richiesta la nostra chiusura */ - _ctx->k = WaitForSingleObject(hEndPollingLocations[id], _ctx->dwSleepTime); - if (_ctx->k == WAIT_OBJECT_0) + + CORO_INVOKE_3(g_scheduler->waitForSingleObject, hEndPollingLocations[id], _ctx->dwSleepTime, &_ctx->expired); + + //if (_ctx->k == WAIT_OBJECT_0) + if (!_ctx->expired) break; for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) @@ -1197,7 +1216,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { _ctx->MyThreads[_ctx->i].nItem = 0; } - _ctx->curTime = timeGetTime(); + _ctx->curTime = _vm->GetTime(); /* Cerchiamo all'interno delle idle actions quale e' necessario eseguire */ for (_ctx->k = 0; _ctx->k < _ctx->nIdleActions; _ctx->k++) @@ -2163,10 +2182,9 @@ bool EXPORT mpalExecuteScript(int nScript) { CopyMemory(s, lpmsScripts+n, sizeof(MPALSCRIPT)); UnlockScripts(); -// !!! Nuova gestione dei thread - if (CreateThread(NULL, 10240,(LPTHREAD_START_ROUTINE)ScriptThread,(void *)s, 0, &dwId) == NULL) - //if ((void*)_beginthread(ScriptThread, 10240,(void *)s)==(void*)-1) - return false; + // !!! Nuova gestione dei thread + if (g_scheduler->createProcess(ScriptThread, &s, sizeof(LPMPALSCRIPT)) == INVALID_PID_VALUE) + return false; return true; } @@ -2213,9 +2231,9 @@ bool mpalStartIdlePoll(int nLoc) { for (i = 0; i < MAXPOLLINGLOCATIONS; i++) { if (nPollingLocations[i] == 0) { - nPollingLocations[i]=nLoc; + nPollingLocations[i] = nLoc; - hEndPollingLocations[i] = CreateEvent(NULL, true, false, NULL); + hEndPollingLocations[i] = g_scheduler->createEvent(true, false); // !!! Nuova gestione dei thread if ((PollingThreads[i] = g_scheduler->createProcess(LocationPollThread, &i, sizeof(uint32))) == 0) // if ((hEndPollingLocations[i]=(void*)_beginthread(LocationPollThread, 10240,(void *)i))==(void*)-1) @@ -2252,11 +2270,11 @@ void mpalEndIdlePoll(CORO_PARAM, int nLoc, bool *result) { for (_ctx->i = 0; _ctx->i < MAXPOLLINGLOCATIONS; _ctx->i++) { if (nPollingLocations[_ctx->i] == (uint32)nLoc) { - SetEvent(hEndPollingLocations[_ctx->i]); + g_scheduler->setEvent(hEndPollingLocations[_ctx->i]); CORO_INVOKE_2(g_scheduler->waitForSingleObject, PollingThreads[_ctx->i], INFINITE); - CloseHandle(hEndPollingLocations[_ctx->i]); + g_scheduler->closeEvent(hEndPollingLocations[_ctx->i]); nPollingLocations[_ctx->i] = 0; if (result) diff --git a/engines/tony/mpal/stubs.cpp b/engines/tony/mpal/stubs.cpp index 58ecc6d6d9..23bc18b0ea 100644 --- a/engines/tony/mpal/stubs.cpp +++ b/engines/tony/mpal/stubs.cpp @@ -36,76 +36,6 @@ namespace Tony { namespace MPAL { -/** - * Display a message - * @param msg Message to display - */ -void MessageBox(const Common::String &msg) { - - _vm->GUIError(msg); -} - -/** - * Gets the current time in milliseconds - */ -uint32 timeGetTime() { - return g_system->getMillis(); -} - -HANDLE CreateThread(void *lpThreadAttributes, size_t dwStackSize, - LPTHREAD_START_ROUTINE lpStartAddress, void *lpParameter, - uint32 dwCreationFlags, uint32 *lpThreadId) { - *lpThreadId = 0; - return 0; -} - -void _beginthread(LPTHREAD_ROUTINE lpStartAddress, size_t dwStackSize, void *lpParameter) { -} - -void ExitThread(int ThreadId) { -} - -void _endthread() { -} - -void TerminateThread(HANDLE ThreadId, uint32 dwExitCode) { - -} - -void CloseHandle(HANDLE ThreadId) { - -} - -void Sleep(uint32 time) { -} - -int WaitForSingleObject(HANDLE ThreadId, uint32 dwSleepTime) { - warning("TODO: Old style WaitForSingleObject"); - return 0; -} - -uint32 WaitForMultipleObjects(uint32 nCount, const HANDLE *lpHandles, bool bWaitAll, uint32 dwMilliseconds) { - warning("TODO: Old style WaitForMultipleObjects"); - return 0; -} - -HANDLE CreateEvent(void *lpEventAttributes, bool bManualReset, bool bInitialState, const char *lpName) { - warning("TODO: Refactor call to old style CreateEvent method"); - return 0; -} - -void SetEvent(HANDLE hEvent) { - warning("TODO: Refactor call to old style SetEvent method"); -} - -void ResetEvent(HANDLE hEvent) { - warning("TODO: Refactor call to old style ResetEvent method"); -} - -void PulseEvent(HANDLE hEvent) { - warning("TODO: Refactor call to old style PulseEvent method"); -} - uint16 GetAsyncKeyState(Common::KeyCode kc) { return 0; } diff --git a/engines/tony/mpal/stubs.h b/engines/tony/mpal/stubs.h index 5c50b76db1..082974898c 100644 --- a/engines/tony/mpal/stubs.h +++ b/engines/tony/mpal/stubs.h @@ -71,42 +71,8 @@ Out CopyMemory(Out dst, In first, int size) { * Methods \****************************************************************************/ -extern void MessageBox(const Common::String &msg); - -extern uint32 timeGetTime(); - -#define INFINITE 0xffffffff -#define WAIT_OBJECT_0 -2 // Horrendously bad cast -#define INVALID_HANDLE_VALUE (void *)-3 - -extern HANDLE CreateThread(void *lpThreadAttributes, size_t dwStackSize, - LPTHREAD_START_ROUTINE lpStartAddress, void *lpParameter, - uint32 dwCreationFlags, uint32 *lpThreadId); - -extern void _beginthread(LPTHREAD_ROUTINE lpStartAddress, size_t dwStackSize, void *lpParameter); - -extern void ExitThread(int ThreadId); - -extern void _endthread(); - -extern void TerminateThread(HANDLE ThreadId, uint32 dwExitCode); - -extern void CloseHandle(HANDLE ThreadId); - -extern void Sleep(uint32 time); - -extern int WaitForSingleObject(HANDLE ThreadId, uint32 dwSleepTime); - -extern uint32 WaitForMultipleObjects(uint32 nCount, const HANDLE *lpHandles, bool bWaitAll, uint32 dwMilliseconds); - -extern HANDLE CreateEvent(void *lpEventAttributes, bool bManualReset, bool bInitialState, const char *lpName); - -extern void SetEvent(HANDLE hEvent); - -extern void ResetEvent(HANDLE hEvent); - -extern void PulseEvent(HANDLE hEvent); +#define INVALID_HANDLE_VALUE (void *)-1 extern uint16 GetAsyncKeyState(Common::KeyCode kc); diff --git a/engines/tony/sched.cpp b/engines/tony/sched.cpp index 2671b01b7f..c447afa094 100644 --- a/engines/tony/sched.cpp +++ b/engines/tony/sched.cpp @@ -437,6 +437,40 @@ void Scheduler::waitForMultipleObjects(CORO_PARAM, int nCount, uint32 *pidList, CORO_END_CODE; } +/** + * Make the active process sleep for the given duration in milliseconds + * @param duration Duration in milliseconds + * @remarks This duration won't be precise, since it relies on the frequency the + * scheduler is called. + */ +void Scheduler::sleep(CORO_PARAM, uint32 duration) { + if (!pCurrent) + error("Called Scheduler::waitForSingleObject from the main process"); + + CORO_BEGIN_CONTEXT; + uint32 endTime; + PROCESS *pProcess; + EVENT *pEvent; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + // Signal as waiting + pCurrent->waiting = true; + + _ctx->endTime = g_system->getMillis() + duration; + + // Outer loop for doing checks until expiry + while (g_system->getMillis() < _ctx->endTime) { + // Sleep until the next cycle + CORO_SLEEP(1); + } + + // Signal waiting is done + pCurrent->waiting = false; + + CORO_END_CODE; +} /** * Creates a new process. diff --git a/engines/tony/sched.h b/engines/tony/sched.h index 3997cb2c47..a9868edad0 100644 --- a/engines/tony/sched.h +++ b/engines/tony/sched.h @@ -37,6 +37,7 @@ namespace Tony { #define MAX_PROCESSES 100 #define INFINITE 0xffffffff +#define INVALID_PID_VALUE 0 typedef void (*CORO_ADDR)(CoroContext &, const void *); @@ -125,7 +126,8 @@ public: void giveWay(PPROCESS pReSchedProc = NULL); void waitForSingleObject(CORO_PARAM, int pid, uint32 duration, bool *expired = NULL); void waitForMultipleObjects(CORO_PARAM, int nCount, uint32 *pidList, bool bWaitAll, - uint32 duration, bool *expired = NULL); + uint32 duration, bool *expired = NULL); + void Scheduler::sleep(CORO_PARAM, uint32 duration); uint32 createProcess(CORO_ADDR coroAddr, const void *pParam, int sizeParam); uint32 createProcess(CORO_ADDR coroAddr, const void *pParam) { diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index 7c340be86e..b376d14149 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -2179,8 +2179,9 @@ void PASCAL FPSTREAM::PlayThread(FPSTREAM *This) { // sprintf(buf, "Exiting thread. Buffer = %x, MyThread = 0x%x\n", This->lpDSBuffer, GetCurrentThreadId()); // warning(buf); This->lpDSBuffer->Stop(); -#endif + ExitThread(0); +#endif } diff --git a/engines/tony/sound.h b/engines/tony/sound.h index 8853e1a344..e263c7ee51 100644 --- a/engines/tony/sound.h +++ b/engines/tony/sound.h @@ -240,7 +240,7 @@ private: // DSBPOSITIONNOTIFY dspnHot[2]; public: - HANDLE hEndOfBuffer; + uint32 hEndOfBuffer; private: diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index d0bce68c3b..ef27f509b9 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -68,7 +68,7 @@ Common::Error TonyEngine::run() { * Initialise the game */ Common::ErrorCode TonyEngine::Init() { - m_hEndOfFrame = CreateEvent(NULL, false, false, NULL); + m_hEndOfFrame = g_scheduler->createEvent(false, false); m_bPaused = false; m_bDrawLocation = true; @@ -295,16 +295,22 @@ void TonyEngine::GetSaveStateFileName(int n, char *buf) { name += ".sav"; } -void TonyEngine::AutoSave(void) { - char buf[256]; +void TonyEngine::AutoSave(CORO_PARAM) { + CORO_BEGIN_CONTEXT; + char buf[256]; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); GrabThumbnail(); - MainWaitFrame(); - MainWaitFrame(); + CORO_INVOKE_0(MainWaitFrame); + CORO_INVOKE_0(MainWaitFrame); MainFreeze(); - GetSaveStateFileName(0,buf); - _theEngine.SaveState(buf, (byte *)m_curThumbnail, "Autosave", true); + GetSaveStateFileName(0, _ctx->buf); + _theEngine.SaveState(_ctx->buf, (byte *)m_curThumbnail, "Autosave", true); MainUnfreeze(); + + CORO_END_CODE; } @@ -375,12 +381,12 @@ void TonyEngine::GrabThumbnail(void) { void TonyEngine::OptionScreen(void) { } -void TonyEngine::OpenInitLoadMenu(void) { - _theEngine.OpenOptionScreen(1); +void TonyEngine::OpenInitLoadMenu(CORO_PARAM) { + _theEngine.OpenOptionScreen(coroParam, 1); } -void TonyEngine::OpenInitOptions(void) { - _theEngine.OpenOptionScreen(2); +void TonyEngine::OpenInitOptions(CORO_PARAM) { + _theEngine.OpenOptionScreen(coroParam, 2); } void TonyEngine::Abort(void) { @@ -400,10 +406,11 @@ void TonyEngine::Play(void) { _scheduler.schedule(); // Call the engine to handle the next frame - _theEngine.DoFrame(m_bDrawLocation); + // FIXME: This needs to be moved into it's own process + _theEngine.DoFrame(nullContext, m_bDrawLocation); // Warns that a frame is finished - PulseEvent(m_hEndOfFrame); + g_scheduler->pulseEvent(m_hEndOfFrame); // Handle drawing the frame if (!m_bPaused) { @@ -422,7 +429,7 @@ void TonyEngine::Play(void) { void TonyEngine::Close(void) { CloseMusic(); - CloseHandle(m_hEndOfFrame); + g_scheduler->closeEvent(m_hEndOfFrame); _theBoxes.Close(); _theEngine.Close(); _window.Close(); diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 3c7e8fe6b2..fdb92e3795 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -92,7 +92,7 @@ public: Common::RandomSource _randomSource; MPAL::MemoryManager _memoryManager; RMResUpdate _resUpdate; - HANDLE m_hEndOfFrame; + uint32 m_hEndOfFrame; Common::File _vdbFP; Common::Array _voices; FPSOUND _theSound; @@ -191,7 +191,7 @@ public: int GetMusicVolume(int nChannel); // Salvataggio - void AutoSave(void); + void AutoSave(CORO_PARAM); void SaveState(int n, const char *name); void LoadState(int n); void GetSaveStateFileName(int n, char *buf); @@ -202,8 +202,8 @@ public: void Quit(void) { m_bQuitNow = true; } - void OpenInitLoadMenu(void); - void OpenInitOptions(void); + void OpenInitLoadMenu(CORO_PARAM); + void OpenInitOptions(CORO_PARAM); }; // Global reference to the TonyEngine object diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index ad13d49d54..ea233233d2 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -212,6 +212,7 @@ void RMTony::MoveAndDoAction(RMPoint dst, RMItem *item, int nAction, int nAction void RMTony::ExecuteAction(int nAction, int nActionItem, int nParm) { + // fixme: See if hThread can be converted to uint32 HANDLE hThread; uint32 pid; @@ -241,53 +242,64 @@ void RMTony::ExecuteAction(int nAction, int nActionItem, int nParm) { m_bAction = true; pid = (uint32)hThread; g_scheduler->createProcess(WaitEndOfAction, &pid, sizeof(uint32)); - hActionThread = hThread; + hActionThread = pid; } else if (nAction != TA_GOTO) { if (nAction == TA_TALK) { hThread = mpalQueryDoAction(6, 1, 0); m_bAction = true; pid = (uint32)hThread; g_scheduler->createProcess(WaitEndOfAction, &pid, sizeof(uint32)); - hActionThread = hThread; + hActionThread = pid; } else if (nAction == TA_PALESATI) { hThread = mpalQueryDoAction(7, 1, 0); m_bAction = true; pid = (uint32)hThread; g_scheduler->createProcess(WaitEndOfAction, &pid, sizeof(uint32)); - hActionThread=hThread; + hActionThread = pid; } else { hThread = mpalQueryDoAction(5, 1, 0); m_bAction = true; pid = (uint32)hThread; g_scheduler->createProcess(WaitEndOfAction, &pid, sizeof(uint32)); - hActionThread = hThread; + hActionThread = pid; } } } -void RMTony::StopNoAction(void) { +void RMTony::StopNoAction(CORO_PARAM) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + if (m_bAction) - WaitForSingleObject(hActionThread, INFINITE); + CORO_INVOKE_2(g_scheduler->waitForSingleObject, hActionThread, INFINITE); m_bActionPending = false; m_ActionItem = NULL; - Stop(); + CORO_INVOKE_0(Stop); + + CORO_END_CODE; } -void RMTony::Stop(void) { - HANDLE hThread; +void RMTony::Stop(CORO_PARAM) { + CORO_BEGIN_CONTEXT; + uint32 hThread; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); if (m_ActionItem != NULL) { // Richiama l'MPAL per scegliere la direzione - hThread = mpalQueryDoAction(21, m_ActionItem->MpalCode(), 0); + _ctx->hThread = mpalQueryDoActionU32(21, m_ActionItem->MpalCode(), 0); - if (hThread==INVALID_HANDLE_VALUE) + if (_ctx->hThread == INVALID_PID_VALUE) RMCharacter::Stop(); else { bNeedToStop = false; // Se facciamo la OnWhichDirection, almeno dopo non dobbiamo fare la Stop() bMoving = false; - WaitForSingleObject(hThread, INFINITE); // @@@ Mettere un assert dopo 10 secondi + CORO_INVOKE_2(g_scheduler->waitForSingleObject, _ctx->hThread, INFINITE); // @@@ Mettere un assert dopo 10 secondi } } else { RMCharacter::Stop(); @@ -301,6 +313,8 @@ void RMTony::Stop(void) { ExecuteAction(m_Action, m_ActionItem->MpalCode(), m_ActionParm); m_ActionItem=NULL; + + CORO_END_CODE; } diff --git a/engines/tony/tonychar.h b/engines/tony/tonychar.h index 2cbcf60a00..98f247f688 100644 --- a/engines/tony/tonychar.h +++ b/engines/tony/tonychar.h @@ -123,7 +123,7 @@ private: int m_nTimeLastStep; RMItem m_body; - HANDLE hActionThread; + uint32 hActionThread; protected: // Overload dell'allocazione degli sprites per cambiare il tipo @@ -398,8 +398,8 @@ public: void MoveAndDoAction(RMPoint dst, RMItem *item, int nAction, int nActionParm = 0); // Ferma Tony (dalla parte giusta rispetto a un eventuale oggetto) - virtual void Stop(void); - void StopNoAction(void); + virtual void Stop(CORO_PARAM); + void StopNoAction(CORO_PARAM); // Setta un pattern void SetPattern(int npatt, bool bPlayP0 = false); @@ -408,7 +408,7 @@ public: int GetCurPattern(); // Attende la fine di un pattern - void WaitForEndPattern(CORO_PARAM, HANDLE hCustomSkip = INVALID_HANDLE_VALUE) { + void WaitForEndPattern(CORO_PARAM, uint32 hCustomSkip = INVALID_PID_VALUE) { RMCharacter::WaitForEndPattern(coroParam, hCustomSkip); } -- cgit v1.2.3 From 5a069cdc861538fe763de48de8628d7d754f7959 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 9 May 2012 23:15:41 +1000 Subject: TONY: Refactored out usage of nullContext in favour of proper coroutines --- engines/tony/adv.h | 4 +- engines/tony/custom.cpp | 34 +++-- engines/tony/font.cpp | 16 +- engines/tony/game.cpp | 170 ++++++++++----------- engines/tony/game.h | 2 +- engines/tony/gfxengine.cpp | 206 +++++++++++++------------ engines/tony/gfxengine.h | 6 +- engines/tony/loc.cpp | 4 +- engines/tony/mpal/mpal.cpp | 368 ++++++++++++++++++++++++++++++++------------- engines/tony/mpal/mpal.h | 59 ++++---- engines/tony/mpal/stubs.h | 3 - engines/tony/sound.cpp | 6 +- engines/tony/tony.cpp | 77 +++++++--- engines/tony/tony.h | 3 +- engines/tony/tonychar.cpp | 37 ++--- engines/tony/window.cpp | 8 +- 16 files changed, 601 insertions(+), 402 deletions(-) (limited to 'engines') diff --git a/engines/tony/adv.h b/engines/tony/adv.h index 22205cf05b..a1b21c1e08 100644 --- a/engines/tony/adv.h +++ b/engines/tony/adv.h @@ -91,8 +91,8 @@ enum RMTonyAction { }; // Funzioni globali -HANDLE MainLoadLocation(int nLoc, RMPoint pt, RMPoint start); -void MainUnloadLocation(CORO_PARAM, bool bDoOnExit, HANDLE *result); +uint32 MainLoadLocation(int nLoc, RMPoint pt, RMPoint start); +void MainUnloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result); void MainLinkGraphicTask(RMGfxTask *task); void MainFreeze(void); void MainUnfreeze(void); diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 9d46d7e6b7..150e199fc8 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -72,8 +72,8 @@ RMLocation *Loc; RMInventory *Inventory; RMInput *Input; -HANDLE (*LoadLocation)(int, RMPoint, RMPoint start); -void (*UnloadLocation)(CORO_PARAM, bool bDoOnExit, HANDLE *result); +uint32 (*LoadLocation)(int, RMPoint, RMPoint start); +void (*UnloadLocation)(CORO_PARAM, bool bDoOnExit, uint32 *result); void (*LinkGraphicTask)(RMGfxTask *task); void (*Freeze)(void); void (*Unfreeze)(void); @@ -521,7 +521,7 @@ DECLARE_CUSTOM_FUNCTION(CustLoadLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, ui LoadLocation(nLoc, RMPoint(tX, tY), RMPoint(-1, -1)); Unfreeze(); - _ctx->h = mpalQueryDoActionU32(0, nLoc, 0); + _ctx->h = mpalQueryDoAction(0, nLoc, 0); // On Enter? if (_ctx->h != INVALID_PID_VALUE) @@ -698,7 +698,7 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint Unfreeze(); - _ctx->h = mpalQueryDoActionU32(0, nLoc, 0); + _ctx->h = mpalQueryDoAction(0, nLoc, 0); if (!bNoOcchioDiBue) { CORO_INVOKE_0(WaitWipeEnd); @@ -1842,7 +1842,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes // Cerca di eseguire la funzione custom per inizializzare la parlata if (MCharacter[nChar].item) { - _ctx->h = mpalQueryDoActionU32(30, MCharacter[nChar].item->MpalCode(), _ctx->parm); + _ctx->h = mpalQueryDoAction(30, MCharacter[nChar].item->MpalCode(), _ctx->parm); if (_ctx->h != INVALID_PID_VALUE) { CORO_INVOKE_2(g_scheduler->waitForSingleObject, _ctx->h, INFINITE); } @@ -1923,7 +1923,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes // Cerca di eseguire la funzione custom per chiudere la parlata if (MCharacter[nChar].item) { - _ctx->h = mpalQueryDoActionU32(31, MCharacter[nChar].item->MpalCode(), _ctx->parm); + _ctx->h = mpalQueryDoAction(31, MCharacter[nChar].item->MpalCode(), _ctx->parm); if (_ctx->h != INVALID_PID_VALUE) CORO_INVOKE_2(g_scheduler->waitForSingleObject, _ctx->h, INFINITE); } @@ -2034,7 +2034,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg MCharacter[nPers].numtexts--; } else { // Cerca di eseguire la funzione custom per inizializzare la parlata - _ctx->h = mpalQueryDoActionU32(30, MCharacter[nPers].item->MpalCode(), _ctx->parm); + _ctx->h = mpalQueryDoAction(30, MCharacter[nPers].item->MpalCode(), _ctx->parm); if (_ctx->h != INVALID_PID_VALUE) CORO_INVOKE_2(g_scheduler->waitForSingleObject, _ctx->h, INFINITE); @@ -2098,7 +2098,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg if ((MCharacter[nPers].bInTexts && MCharacter[nPers].numtexts== 0) || !MCharacter[nPers].bInTexts) { // Cerca di eseguire la funzione custom per chiudere la parlata MCharacter[nPers].curTalk = (MCharacter[nPers].curTalk%10) + MCharacter[nPers].curgroup*10; - _ctx->h = mpalQueryDoActionU32(31,MCharacter[nPers].item->MpalCode(),MCharacter[nPers].curTalk); + _ctx->h = mpalQueryDoAction(31,MCharacter[nPers].item->MpalCode(),MCharacter[nPers].curTalk); if (_ctx->h != INVALID_PID_VALUE) CORO_INVOKE_2(g_scheduler->waitForSingleObject, _ctx->h, INFINITE); @@ -2142,7 +2142,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr curDialog = nDialog; // Call MPAL to start the dialog - mpalQueryDoDialogU32(nDialog, nStartGroup); + mpalQueryDoDialog(nDialog, nStartGroup); // Wait until a choice is selected mpalQueryDialogWaitForChoice(&_ctx->nChoice); @@ -2154,7 +2154,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr // Se c'e' una sola opzione, la fa automaticamente, e aspetta la prossima scelta if (_ctx->num == 1) { - mpalQueryDialogSelectionU32(_ctx->nChoice, _ctx->sl[0]); + mpalQueryDialogSelection(_ctx->nChoice, _ctx->sl[0]); GlobalFree(_ctx->sl); continue; } @@ -2190,7 +2190,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr MainHideMouse(); CORO_INVOKE_0(_ctx->dc.Hide); - mpalQueryDialogSelectionU32(_ctx->nChoice, _ctx->sl[_ctx->sel]); + mpalQueryDialogSelection(_ctx->nChoice, _ctx->sl[_ctx->sel]); // Chiude la scelta _ctx->dc.Close(); @@ -2501,10 +2501,18 @@ DECLARE_CUSTOM_FUNCTION(PlayItemSfx)(CORO_PARAM, uint32 nItem, uint32 nSFX, uint } -void RestoreMusic(void) { - PlaySonoriz(nullContext, lastMusic, 0, 0, 0); +void RestoreMusic(CORO_PARAM) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + CORO_INVOKE_4(PlaySonoriz, lastMusic, 0, 0, 0); + if (lastTappeto != 0) CustPlayMusic(4, tappetiFile[lastTappeto], 0, true); + + CORO_END_CODE; } void SaveMusic(Common::OutSaveFile *f) { diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index d04e1f0a13..5dbbd3f71f 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -2236,7 +2236,7 @@ void RMTextDialogScrolling::ClipOnScreen(RMGfxPrimitive *prim) { /****************************************************************************\ -* Metodi di RMTextItemName +* RMTextItemName Methods \****************************************************************************/ RMTextItemName::RMTextItemName() : RMText() { @@ -2259,14 +2259,14 @@ void RMTextItemName::DoFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation & _ctx->lastItem = m_item; - // Si aggiunge alla lista se c'e' bisogno + // Adds to the list if there is need if (!m_nInList) bigBuf.AddPrim(new RMGfxPrimitive(this)); - // Aggiorna le coordinate di scrolling + // Update the scrolling co-ordinates m_curscroll = loc.ScrollPosition(); - // Controlla se siamo sopra l'inventario + // Check if we are on the inventory if (inv.ItemInFocus(m_mpos)) m_item = inv.WhichItemIsIn(m_mpos); else @@ -2274,19 +2274,19 @@ void RMTextItemName::DoFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation & _ctx->itemName = ""; - // Si fa dare il nuovo nome + // If there an item, get it's name if (m_item != NULL) m_item->GetName(_ctx->itemName); - // Se lo scrive + // Write it WriteText(_ctx->itemName, 1); - // Se e' diverso dal precedente, e' il caso di aggiornare anche il puntatore con la WhichPointer + // Handle the change If the selected item is different from the previous one if (_ctx->lastItem != m_item) { if (m_item == NULL) ptr.SetSpecialPointer(RMPointer::PTR_NONE); else { - _ctx->hThread = mpalQueryDoActionU32(20, m_item->MpalCode(), 0); + _ctx->hThread = mpalQueryDoAction(20, m_item->MpalCode(), 0); if (_ctx->hThread == INVALID_PID_VALUE) ptr.SetSpecialPointer(RMPointer::PTR_NONE); else diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 59196ec18a..377ec73673 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -92,11 +92,11 @@ bool bPatIrqFreeze; /* Funzioni globali per la DLL Custom */ /****************************************/ -HANDLE MainLoadLocation(int nLoc, RMPoint pt, RMPoint start) { +uint32 MainLoadLocation(int nLoc, RMPoint pt, RMPoint start) { return _vm->GetEngine()->LoadLocation(nLoc, pt,start); } -void MainUnloadLocation(CORO_PARAM, bool bDoOnExit, HANDLE *result) { +void MainUnloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result) { _vm->GetEngine()->UnloadLocation(coroParam, bDoOnExit, result); } @@ -934,110 +934,110 @@ void RMOptionScreen::ChangeState(STATE newState) { InitState(); } -void RMOptionScreen::DoFrame(RMInput *input) { - bool bLeftClick, bRightClick; - RMPoint mousePos; - bool bRefresh; - int i; +void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { + CORO_BEGIN_CONTEXT; + bool bLeftClick, bRightClick; + RMPoint mousePos; + bool bRefresh; + int i; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + // Se non completamente aperto, non fare nulla if (m_FadeStep != 6) return; // Legge l'input - mousePos = input->MousePos(); - bLeftClick = input->MouseLeftClicked(); - bRightClick = input->MouseRightClicked(); + _ctx->mousePos = input->MousePos(); + _ctx->bLeftClick = input->MouseLeftClicked(); + _ctx->bRightClick = input->MouseRightClicked(); - bRefresh = false; + _ctx->bRefresh = false; if (m_bQuitConfirm) { - bRefresh |= m_ButtonQuitYes->DoFrame(mousePos, bLeftClick, bRightClick); - bRefresh |= m_ButtonQuitNo->DoFrame(mousePos, bLeftClick, bRightClick); + _ctx->bRefresh |= m_ButtonQuitYes->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= m_ButtonQuitNo->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); } else { - bRefresh |= m_ButtonExit->DoFrame(mousePos, bLeftClick, bRightClick); + _ctx->bRefresh |= m_ButtonExit->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); // Controlla se ha clickato sull'uscita if (m_nState == MENUGAME || m_nState == MENUGFX || m_nState == MENUSOUND) { // bottoni senza grafica... - m_ButtonGameMenu->DoFrame(mousePos, bLeftClick, bRightClick); - m_ButtonGfxMenu->DoFrame(mousePos, bLeftClick, bRightClick); - m_ButtonSoundMenu->DoFrame(mousePos, bLeftClick, bRightClick); + m_ButtonGameMenu->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + m_ButtonGfxMenu->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + m_ButtonSoundMenu->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); // bottoni con grafica if (!m_bNoLoadSave) { if (!_vm->getIsDemo()) { - bRefresh |= m_ButtonLoad->DoFrame(mousePos, bLeftClick, bRightClick); - bRefresh |= m_ButtonSave->DoFrame(mousePos, bLeftClick, bRightClick); + _ctx->bRefresh |= m_ButtonLoad->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= m_ButtonSave->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); } - bRefresh |= m_ButtonQuit->DoFrame(mousePos, bLeftClick, bRightClick); + _ctx->bRefresh |= m_ButtonQuit->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); } } - switch (m_nState) { - case MENUGAME: - bRefresh |= m_ButtonGame_Lock->DoFrame(mousePos, bLeftClick, bRightClick); - bRefresh |= m_ButtonGame_TimerizedText->DoFrame(mousePos, bLeftClick, bRightClick); - bRefresh |= m_ButtonGame_Scrolling->DoFrame(mousePos, bLeftClick, bRightClick); - bRefresh |= m_ButtonGame_InterUp->DoFrame(mousePos, bLeftClick, bRightClick); - bRefresh |= m_SlideTextSpeed->DoFrame(mousePos, bLeftClick, bRightClick); - bRefresh |= m_SlideTonySpeed->DoFrame(mousePos, bLeftClick, bRightClick); - break; - - case MENUGFX: - bRefresh |= m_ButtonGfx_Anni30->DoFrame(mousePos, bLeftClick, bRightClick); - bRefresh |= m_ButtonGfx_AntiAlias->DoFrame(mousePos, bLeftClick, bRightClick); - bRefresh |= m_ButtonGfx_Sottotitoli->DoFrame(mousePos, bLeftClick, bRightClick); - bRefresh |= m_ButtonGfx_Tips->DoFrame(mousePos, bLeftClick, bRightClick); - bRefresh |= m_ButtonGfx_Trans->DoFrame(mousePos, bLeftClick, bRightClick); - break; - - case MENUSOUND: - bRefresh |= m_SliderSound_Dubbing->DoFrame(mousePos, bLeftClick, bRightClick); - bRefresh |= m_SliderSound_Music->DoFrame(mousePos, bLeftClick, bRightClick); - bRefresh |= m_SliderSound_SFX->DoFrame(mousePos, bLeftClick, bRightClick); - bRefresh |= m_ButtonSound_DubbingOn->DoFrame(mousePos, bLeftClick, bRightClick); - bRefresh |= m_ButtonSound_MusicOn->DoFrame(mousePos, bLeftClick, bRightClick); - bRefresh |= m_ButtonSound_SFXOn->DoFrame(mousePos, bLeftClick, bRightClick); - break; - - case MENULOAD: - case MENUSAVE: - for (i=0;i<6;i++) - m_ButtonSave_States[i]->DoFrame(mousePos, bLeftClick, bRightClick); + if (m_nState == MENUGAME) { + _ctx->bRefresh |= m_ButtonGame_Lock->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= m_ButtonGame_TimerizedText->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= m_ButtonGame_Scrolling->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= m_ButtonGame_InterUp->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= m_SlideTextSpeed->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= m_SlideTonySpeed->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + + } else if (m_nState == MENUGFX) { + _ctx->bRefresh |= m_ButtonGfx_Anni30->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= m_ButtonGfx_AntiAlias->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= m_ButtonGfx_Sottotitoli->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= m_ButtonGfx_Tips->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= m_ButtonGfx_Trans->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + + } else if (m_nState == MENUSOUND) { + _ctx->bRefresh |= m_SliderSound_Dubbing->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= m_SliderSound_Music->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= m_SliderSound_SFX->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= m_ButtonSound_DubbingOn->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= m_ButtonSound_MusicOn->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= m_ButtonSound_SFXOn->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + + } else if (m_nState == MENULOAD || m_nState == MENUSAVE) { + for (_ctx->i=0;_ctx->i<6;_ctx->i++) + m_ButtonSave_States[_ctx->i]->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); if (m_statePos > 0) - bRefresh |= m_ButtonSave_ArrowLeft->DoFrame(mousePos, bLeftClick, bRightClick); + _ctx->bRefresh |= m_ButtonSave_ArrowLeft->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); if (m_statePos < 90) - bRefresh |= m_ButtonSave_ArrowRight->DoFrame(mousePos, bLeftClick, bRightClick); - break; + _ctx->bRefresh |= m_ButtonSave_ArrowRight->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + } } #define KEYPRESS(c) ((GetAsyncKeyState(c)&0x8001)==0x8001) #define PROCESS_CHAR(cod,c) if (KEYPRESS(cod)) { \ - m_EditName[strlen(m_EditName) +1 ] = '\0'; m_EditName[strlen(m_EditName)] = c; bRefresh = true; } + m_EditName[strlen(m_EditName) +1 ] = '\0'; m_EditName[strlen(m_EditName)] = c; _ctx->bRefresh = true; } /**************** STATO BOTTONI **************/ if (m_bEditSaveName) { if (KEYPRESS(Common::KEYCODE_BACKSPACE)) { if (m_EditName[0] != '\0') { m_EditName[strlen(m_EditName) - 1] = '\0'; - bRefresh = true; + _ctx->bRefresh = true; } } - for (i=0;i<26 && strlen(m_EditName)<12;i++) + for (_ctx->i=0;_ctx->i<26 && strlen(m_EditName)<12;_ctx->i++) if ((GetAsyncKeyState(Common::KEYCODE_LSHIFT) & 0x8000) || (GetAsyncKeyState(Common::KEYCODE_RSHIFT) & 0x8000)) { - PROCESS_CHAR((Common::KeyCode)((int)'a' + i), i + 'A'); + PROCESS_CHAR((Common::KeyCode)((int)'a' + _ctx->i), _ctx->i + 'A'); } else { - PROCESS_CHAR((Common::KeyCode)((int)'a' + i), i + 'a'); + PROCESS_CHAR((Common::KeyCode)((int)'a' + _ctx->i), _ctx->i + 'a'); } - for (i = 0; i < 10 && strlen(m_EditName) < 12; i++) - PROCESS_CHAR((Common::KeyCode)((int)'0' + i), i + '0'); + for (_ctx->i = 0; _ctx->i < 10 && strlen(m_EditName) < 12; _ctx->i++) + PROCESS_CHAR((Common::KeyCode)((int)'0' + _ctx->i), _ctx->i + '0'); if (strlen(m_EditName) < 12) PROCESS_CHAR(Common::KEYCODE_SPACE,' '); @@ -1056,7 +1056,7 @@ void RMOptionScreen::DoFrame(RMInput *input) { // ANNULLA if (KEYPRESS(Common::KEYCODE_ESCAPE)) { m_bEditSaveName = false; - bRefresh = true; + _ctx->bRefresh = true; } // OK @@ -1066,7 +1066,7 @@ void RMOptionScreen::DoFrame(RMInput *input) { Close(); } - } else if (bLeftClick) { + } else if (_ctx->bLeftClick) { if (m_nState == MENULOAD || m_nState == MENUSAVE) { if (m_ButtonExit->IsActive()) { if (m_bLoadMenuOnly) { @@ -1074,14 +1074,14 @@ void RMOptionScreen::DoFrame(RMInput *input) { Close(); } else { ChangeState(m_nLastState); - bRefresh = true; + _ctx->bRefresh = true; } } else if (m_ButtonSave_ArrowLeft->IsActive()) { if (m_statePos > 0) { m_statePos -= 6; if (m_statePos < 0) m_statePos = 0; m_ButtonSave_ArrowLeft->SetActiveState(false); - bRefresh = true; + _ctx->bRefresh = true; RefreshThumbnails(); } } else if (m_ButtonSave_ArrowRight->IsActive()) { @@ -1089,25 +1089,25 @@ void RMOptionScreen::DoFrame(RMInput *input) { m_statePos += 6; if (m_statePos > 90) m_statePos = 90; m_ButtonSave_ArrowRight->SetActiveState(false); - bRefresh = true; + _ctx->bRefresh = true; RefreshThumbnails(); } } else { - for (i = 0; i < 6; i++) - if (m_ButtonSave_States[i]->IsActive()) { + for (_ctx->i = 0; _ctx->i < 6; _ctx->i++) + if (m_ButtonSave_States[_ctx->i]->IsActive()) { // C' da effettuare il salvataggio o il caricamento!!!! - if (m_nState == MENULOAD && m_curThumb[i] != NULL) { + if (m_nState == MENULOAD && m_curThumb[_ctx->i] != NULL) { // Caricamento - _vm->LoadState(m_statePos+i); + CORO_INVOKE_1(_vm->LoadState, m_statePos+_ctx->i); Close(); - } else if (m_nState == MENUSAVE && (m_statePos != 0 || i != 0)) { + } else if (m_nState == MENUSAVE && (m_statePos != 0 || _ctx->i != 0)) { // Attiva la modalit di editing m_bEditSaveName = true; - m_nEditPos = i; - strcpy(m_EditName, m_curThumbName[i]); - bRefresh = true; + m_nEditPos = _ctx->i; + strcpy(m_EditName, m_curThumbName[_ctx->i]); + _ctx->bRefresh = true; - //_vm->SaveState(m_statePos+i,"No name"); + //_vm->SaveState(m_statePos+_ctx->i,"No name"); //Close(); } @@ -1120,10 +1120,10 @@ void RMOptionScreen::DoFrame(RMInput *input) { if (m_bQuitConfirm) { if (m_ButtonQuitNo->IsActive()) { m_bQuitConfirm = false; - bRefresh = true; + _ctx->bRefresh = true; } else if (m_ButtonQuitYes->IsActive()) { m_bQuitConfirm = false; - bRefresh = true; + _ctx->bRefresh = true; _vm->Quit(); } @@ -1132,24 +1132,24 @@ void RMOptionScreen::DoFrame(RMInput *input) { m_bQuitConfirm = true; m_ButtonQuitNo->SetActiveState(false); m_ButtonQuitYes->SetActiveState(false); - bRefresh = true; + _ctx->bRefresh = true; } else if (m_ButtonExit->IsActive()) Close(); else if (m_ButtonLoad->IsActive()) { ChangeState(MENULOAD); - bRefresh = true; + _ctx->bRefresh = true; } else if (m_ButtonSave->IsActive()) { ChangeState(MENUSAVE); - bRefresh = true; + _ctx->bRefresh = true; } else if (m_ButtonGameMenu->IsActive() && m_nState != MENUGAME) { ChangeState(MENUGAME); - bRefresh = true; + _ctx->bRefresh = true; } else if (m_ButtonGfxMenu->IsActive() && m_nState != MENUGFX) { ChangeState(MENUGFX); - bRefresh = true; + _ctx->bRefresh = true; } else if (m_ButtonSoundMenu->IsActive() && m_nState != MENUSOUND) { ChangeState(MENUSOUND); - bRefresh = true; + _ctx->bRefresh = true; } if (m_nState == MENUGFX) { @@ -1177,8 +1177,10 @@ void RMOptionScreen::DoFrame(RMInput *input) { if (!m_bQuitConfirm && KEYPRESS(Common::KEYCODE_ESCAPE)) Close(); - if (bRefresh) + if (_ctx->bRefresh) RefreshAll(); + + CORO_END_CODE; } diff --git a/engines/tony/game.h b/engines/tony/game.h index 593203e443..55fed71380 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -300,7 +300,7 @@ public: bool RemoveThis(); // Polling per l'option screen - void DoFrame(RMInput *m_input); + void DoFrame(CORO_PARAM, RMInput *m_input); protected: diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 12de3573eb..3952d0c227 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -165,7 +165,7 @@ void RMGfxEngine::DoFrame(CORO_PARAM, bool bDrawLocation) { } if (m_bOption) { - m_opt.DoFrame(&m_input); + CORO_INVOKE_1(m_opt.DoFrame, &m_input); m_bOption = !m_opt.IsClosing(); if (!m_bOption) { DisableMouse(); @@ -220,15 +220,15 @@ void RMGfxEngine::DoFrame(CORO_PARAM, bool bDrawLocation) { if (m_bGUIOption) { if (!m_tony.InAction() && m_bInput) { if ((m_input.MouseLeftClicked() && m_input.MousePos().x < 3 && m_input.MousePos().y < 3)) { - OpenOptionScreen(nullContext, 0); + CORO_INVOKE_1(OpenOptionScreen, 0); goto SKIPCLICKSINISTRO; } else if ((GetAsyncKeyState(Common::KEYCODE_ESCAPE)&0x8001) == 0x8001) - OpenOptionScreen(nullContext, 0); + CORO_INVOKE_1(OpenOptionScreen, 0); else if (_vm->getIsDemo()) { if ((GetAsyncKeyState(Common::KEYCODE_F3) & 0x8001) == 0x8001) - OpenOptionScreen(nullContext, 3); + CORO_INVOKE_1(OpenOptionScreen, 3); else if ((GetAsyncKeyState(Common::KEYCODE_F2) & 0x8001) == 0x8001) - OpenOptionScreen(nullContext, 4); + CORO_INVOKE_1(OpenOptionScreen, 4); } } } @@ -494,7 +494,7 @@ void RMGfxEngine::InitForNewLocation(int nLoc, RMPoint ptTonyStart, RMPoint star mpalStartIdlePoll(m_nCurLoc); } -HANDLE RMGfxEngine::LoadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { +uint32 RMGfxEngine::LoadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { bool bLoaded; int i; @@ -529,10 +529,10 @@ HANDLE RMGfxEngine::LoadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { m_bLocationLoaded = true; // On Enter per la locazion - return INVALID_HANDLE_VALUE; //mpalQueryDoAction(0,m_nCurLoc,0); + return INVALID_PID_VALUE; //mpalQueryDoAction(0,m_nCurLoc,0); } -void RMGfxEngine::UnloadLocation(CORO_PARAM, bool bDoOnExit, HANDLE *result) { +void RMGfxEngine::UnloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result) { CORO_BEGIN_CONTEXT; uint32 h; CORO_END_CONTEXT(_ctx); @@ -544,7 +544,7 @@ void RMGfxEngine::UnloadLocation(CORO_PARAM, bool bDoOnExit, HANDLE *result) { // On Exit? if (bDoOnExit) { - _ctx->h = mpalQueryDoActionU32(1, m_nCurLoc, 0); + _ctx->h = mpalQueryDoAction(1, m_nCurLoc, 0); if (_ctx->h != INVALID_PID_VALUE) CORO_INVOKE_2(g_scheduler->waitForSingleObject, _ctx->h, INFINITE); } @@ -557,7 +557,7 @@ void RMGfxEngine::UnloadLocation(CORO_PARAM, bool bDoOnExit, HANDLE *result) { m_loc.Unload(); if (result != NULL) - *result = INVALID_HANDLE_VALUE; + *result = INVALID_PID_VALUE; CORO_END_CODE; } @@ -707,7 +707,7 @@ void SaveChangedHotspot(Common::OutSaveFile *f); void LoadChangedHotspot(Common::InSaveFile *f); void ReapplyChangedHotspot(void); -void RestoreMusic(void); +void RestoreMusic(CORO_PARAM); void SaveMusic(Common::OutSaveFile *f); void LoadMusic(Common::InSaveFile *f); @@ -827,153 +827,159 @@ void RMGfxEngine::SaveState(const char *fn, byte *curThumb, const char *name, bo delete f; } -void RMGfxEngine::LoadState(const char *fn) { +void RMGfxEngine::LoadState(CORO_PARAM, const char *fn) { // PROBLEMA: Bisognerebbe caricare la locazione in un thread a parte per fare la OnEnter ... - Common::InSaveFile *f; - byte *state, *statecmp; - uint size, sizecmp; - char buf[4]; - RMPoint tp; - int loc; - int ver; - int i; + CORO_BEGIN_CONTEXT; + Common::InSaveFile *f; + byte *state, *statecmp; + uint size, sizecmp; + char buf[4]; + RMPoint tp; + int loc; + int ver; + int i; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); - f = g_system->getSavefileManager()->openForLoading(fn); - if (f == NULL) return; - f->read(buf, 4); - if (buf[0] != 'R' || buf[1] != 'M' || buf[2] != 'S') { - delete f; + _ctx->f = g_system->getSavefileManager()->openForLoading(fn); + if (_ctx->f == NULL) return; + _ctx->f->read(_ctx->buf, 4); + if (_ctx->buf[0] != 'R' || _ctx->buf[1] != 'M' || _ctx->buf[2] != 'S') { + delete _ctx->f; return; } - ver = buf[3]; + _ctx->ver = _ctx->buf[3]; - if (ver != 0x1 && ver != 0x2 && ver != 0x3 && ver != 0x4 && ver != 0x5 && ver != 0x6 && ver != 0x7) { - delete f; + if (_ctx->ver != 0x1 && _ctx->ver != 0x2 && _ctx->ver != 0x3 && _ctx->ver != 0x4 && _ctx->ver != 0x5 && _ctx->ver != 0x6 && _ctx->ver != 0x7) { + delete _ctx->f; return; } - if (ver >= 0x3) { - // C' il thumbnail. Se ver >= 5, compresso - if (ver >= 0x5) { - i = 0; - i = f->readUint32LE(); - f->seek(i); + if (_ctx->ver >= 0x3) { + // C' il thumbnail. Se _ctx->ver >= 5, compresso + if (_ctx->ver >= 0x5) { + _ctx->i = 0; + _ctx->i = _ctx->f->readUint32LE(); + _ctx->f->seek(_ctx->i); } else - f->seek(160 * 120 * 2, SEEK_CUR); + _ctx->f->seek(160 * 120 * 2, SEEK_CUR); } - if (ver >= 0x5) { + if (_ctx->ver >= 0x5) { // Skip del livello di difficolt - f->seek(1, SEEK_CUR); + _ctx->f->seek(1, SEEK_CUR); } - if (ver >= 0x4) { // Skippa il nome, che non serve a nessuno - i = f->readByte(); - f->seek(i, SEEK_CUR); + if (_ctx->ver >= 0x4) { // Skippa il nome, che non serve a nessuno + _ctx->i = _ctx->f->readByte(); + _ctx->f->seek(_ctx->i, SEEK_CUR); } - loc = f->readUint32LE(); - loc = f->readUint32LE(); - tp.x = f->readUint32LE(); - tp.y = f->readUint32LE(); - size = f->readUint32LE(); + _ctx->loc = _ctx->f->readUint32LE(); + _ctx->loc = _ctx->f->readUint32LE(); + _ctx->tp.x = _ctx->f->readUint32LE(); + _ctx->tp.y = _ctx->f->readUint32LE(); + _ctx->size = _ctx->f->readUint32LE(); - if (ver >= 0x5) { + if (_ctx->ver >= 0x5) { // Stato MPAL compresso! - sizecmp = f->readUint32LE(); - state = new byte[size]; - statecmp = new byte[sizecmp]; - f->read(statecmp, sizecmp); - lzo1x_decompress(statecmp,sizecmp,state,&size); - delete[] statecmp; + _ctx->sizecmp = _ctx->f->readUint32LE(); + _ctx->state = new byte[_ctx->size]; + _ctx->statecmp = new byte[_ctx->sizecmp]; + _ctx->f->read(_ctx->statecmp, _ctx->sizecmp); + lzo1x_decompress(_ctx->statecmp,_ctx->sizecmp,_ctx->state,&_ctx->size); + delete[] _ctx->statecmp; } else { - state = new byte[size]; - f->read(state, size); + _ctx->state = new byte[_ctx->size]; + _ctx->f->read(_ctx->state, _ctx->size); } - mpalLoadState(state); - delete[] state; + mpalLoadState(_ctx->state); + delete[] _ctx->state; // inventario - size = f->readUint32LE(); - state = new byte[size]; - f->read(state, size); - m_inv.LoadState(state); - delete[] state; - - if (ver >= 0x2) { // Versione 2: box please - size = f->readUint32LE(); - state = new byte[size]; - f->read(state, size); - _vm->_theBoxes.LoadState(state); - delete[] state; + _ctx->size = _ctx->f->readUint32LE(); + _ctx->state = new byte[_ctx->size]; + _ctx->f->read(_ctx->state, _ctx->size); + m_inv.LoadState(_ctx->state); + delete[] _ctx->state; + + if (_ctx->ver >= 0x2) { // Versione 2: box please + _ctx->size = _ctx->f->readUint32LE(); + _ctx->state = new byte[_ctx->size]; + _ctx->f->read(_ctx->state, _ctx->size); + _vm->_theBoxes.LoadState(_ctx->state); + delete[] _ctx->state; } - if (ver >= 5) { + if (_ctx->ver >= 5) { // Versione 5: bool bStat = false; - bStat = f->readByte(); + bStat = _ctx->f->readByte(); m_tony.SetPastorella(bStat); - bStat = f->readByte(); + bStat = _ctx->f->readByte(); m_inter.SetPalesati(bStat); - CharsLoadAll(f); + CharsLoadAll(_ctx->f); } - if (ver >= 6) { + if (_ctx->ver >= 6) { // Carica le opzioni - bCfgInvLocked = f->readByte(); - bCfgInvNoScroll = f->readByte(); - bCfgTimerizedText = f->readByte(); - bCfgInvUp = f->readByte(); - bCfgAnni30 = f->readByte(); - bCfgAntiAlias = f->readByte(); - bCfgSottotitoli = f->readByte(); - bCfgTransparence = f->readByte(); - bCfgInterTips = f->readByte(); - bCfgDubbing = f->readByte(); - bCfgMusic = f->readByte(); - bCfgSFX = f->readByte(); - nCfgTonySpeed = f->readByte(); - nCfgTextSpeed = f->readByte(); - nCfgDubbingVolume = f->readByte(); - nCfgMusicVolume = f->readByte(); - nCfgSFXVolume = f->readByte(); + bCfgInvLocked = _ctx->f->readByte(); + bCfgInvNoScroll = _ctx->f->readByte(); + bCfgTimerizedText = _ctx->f->readByte(); + bCfgInvUp = _ctx->f->readByte(); + bCfgAnni30 = _ctx->f->readByte(); + bCfgAntiAlias = _ctx->f->readByte(); + bCfgSottotitoli = _ctx->f->readByte(); + bCfgTransparence = _ctx->f->readByte(); + bCfgInterTips = _ctx->f->readByte(); + bCfgDubbing = _ctx->f->readByte(); + bCfgMusic = _ctx->f->readByte(); + bCfgSFX = _ctx->f->readByte(); + nCfgTonySpeed = _ctx->f->readByte(); + nCfgTextSpeed = _ctx->f->readByte(); + nCfgDubbingVolume = _ctx->f->readByte(); + nCfgMusicVolume = _ctx->f->readByte(); + nCfgSFXVolume = _ctx->f->readByte(); // Carica gli hotspot - LoadChangedHotspot(f); + LoadChangedHotspot(_ctx->f); } - if (ver >= 7) { - LoadMusic(f); + if (_ctx->ver >= 7) { + LoadMusic(_ctx->f); } - delete f; + delete _ctx->f; - UnloadLocation(nullContext, false, NULL); - LoadLocation(loc,tp,RMPoint(-1, -1)); + CORO_INVOKE_2(UnloadLocation, false, NULL); + LoadLocation(_ctx->loc,_ctx->tp,RMPoint(-1, -1)); m_tony.SetPattern(RMTony::PAT_STANDRIGHT); MainUnfreeze(); // Le versioni vecchie necessitano di On enter - if (ver < 5) - mpalQueryDoActionU32(0, loc, 0); + if (_ctx->ver < 5) + mpalQueryDoAction(0, _ctx->loc, 0); else { // In quelle nuove, ci basta resettare gli mcode MCharResetCodes(); } - if (ver >= 6) + if (_ctx->ver >= 6) ReapplyChangedHotspot(); - RestoreMusic(); + CORO_INVOKE_0(RestoreMusic); m_bGUIInterface = true; m_bGUIInventory = true; m_bGUIOption = true; + + CORO_END_CODE; } void RMGfxEngine::PauseSound(bool bPause) { diff --git a/engines/tony/gfxengine.h b/engines/tony/gfxengine.h index 11d591b408..d119bb07a6 100644 --- a/engines/tony/gfxengine.h +++ b/engines/tony/gfxengine.h @@ -137,8 +137,8 @@ public: void LinkGraphicTask(RMGfxTask *task) { m_bigBuf.AddPrim(new RMGfxPrimitive(task)); }; // Manage a location - HANDLE LoadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start); - void UnloadLocation(CORO_PARAM, bool bDoOnExit, HANDLE *result); + uint32 LoadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start); + void UnloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result); // Freeze and unfreeze void Freeze(void); @@ -146,7 +146,7 @@ public: // State management void SaveState(const char *fn, byte *curThumb, const char *name, bool bFastCompress = false); - void LoadState(const char *fn); + void LoadState(CORO_PARAM, const char *fn); // Selects a location void SelectLocation(RMPoint ptTonyStart=RMPoint(-1,-1), RMPoint start=RMPoint(-1,-1)); diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index a412f9cfd2..bba1ad2f23 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -1376,7 +1376,7 @@ void RMCharacter::NewBoxEntered(int nBox) { bool bOldReverse; // Richiama la On ExitBox - mpalQueryDoActionU32(3, curLocation, curbox); + mpalQueryDoAction(3, curLocation, curbox); cur = theBoxes->GetBoxes(curLocation); bOldReverse = cur->boxes[curbox].bReversed; @@ -1410,7 +1410,7 @@ void RMCharacter::NewBoxEntered(int nBox) { } // Richiama la On EnterBox - mpalQueryDoActionU32(2, curLocation, curbox); + mpalQueryDoAction(2, curLocation, curbox); } void RMCharacter::DoFrame(RMGfxTargetBuffer* bigBuf, int loc) { diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index d6230d7768..c21d84cd9b 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -1570,7 +1570,7 @@ void DoChoice(CORO_PARAM, uint32 nChoice) { * uint32 dwParam Eventuale parametro per l'azione * * Return: Handle del thread che sta eseguendo l'azione, oppure -* INVALID_HANDLE_VALUE se l'azione non e' definita, o l'item +* INVALID_PID_VALUE se l'azione non e' definita, o l'item * e' disattivato. * * Note: Si puo' ottenere l'indice dell'item a partire dal suo numero @@ -1580,7 +1580,7 @@ void DoChoice(CORO_PARAM, uint32 nChoice) { * \****************************************************************************/ -static HANDLE DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { +static uint32 DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { LPMPALITEM item = lpmiItems; int i; LPMPALITEM newitem; @@ -1589,7 +1589,7 @@ static HANDLE DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { item+=ordItem; Common::String buf = Common::String::format("Status.%u", item->nObj); if (varGetValue(buf.c_str()) <= 0) - return INVALID_HANDLE_VALUE; + return INVALID_PID_VALUE; for (i = 0; i < item->nActions; i++) { if (item->Action[i].num != nAction) @@ -1607,7 +1607,7 @@ static HANDLE DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { // Duplichiamo l'item corrente e copiamo la azione #i nella #0 newitem = (LPMPALITEM)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MPALITEM)); if (newitem == NULL) - return INVALID_HANDLE_VALUE; + return INVALID_PID_VALUE; // Nella nuova versione scriviamo il numero dell'azione in dwRes Common::copy((byte *)item, (byte *)item + sizeof(MPALITEM), (byte *)newitem); @@ -1621,26 +1621,18 @@ static HANDLE DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { // !!! New thread management if ((h = g_scheduler->createProcess(ActionThread, &newitem, sizeof(LPMPALITEM))) == NULL) - return INVALID_HANDLE_VALUE; + return INVALID_PID_VALUE; - if ((h = g_scheduler->createProcess(ShutUpActionThread, &h, sizeof(uint32))) == NULL) - return INVALID_HANDLE_VALUE; + if (g_scheduler->createProcess(ShutUpActionThread, &h, sizeof(uint32)) == NULL) + return INVALID_PID_VALUE; -/* - if ((h=(void*)_beginthread(ActionThread, 10240,(void *)newitem))==(void*)-1) - return INVALID_HANDLE_VALUE; - - if ((h=(void*)_beginthread(ShutUpActionThread, 10240,(void *)h))==(void*)-1) - return INVALID_HANDLE_VALUE; - -*/ nExecutingAction = item->nObj; bExecutingAction = true; - return (HANDLE)h; + return h; } - return INVALID_HANDLE_VALUE; + return INVALID_PID_VALUE; } /** @@ -1649,7 +1641,7 @@ static HANDLE DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { * @param nDlgOrd The index of the dialog in the dialog list * @param nGroup Number of the group to perform * @returns The process Id of the process running the dialog - * or INVALID_HANDLE_VALUE on error + * or INVALID_PID_VALUE on error * @remarks The dialogue runs in a thread created on purpose, * so that must inform through an event and when 'necessary to you make a choice. * The data on the choices may be obtained through various queries. @@ -1669,14 +1661,14 @@ static uint32 DoDialog(uint32 nDlgOrd, uint32 nGroup) { // Create a thread that performs the dialogue group // Create the process - if ((h = g_scheduler->createProcess(GroupThread, &nGroup, sizeof(uint32))) == 0) - return 0; + if ((h = g_scheduler->createProcess(GroupThread, &nGroup, sizeof(uint32))) == INVALID_PID_VALUE) + return INVALID_PID_VALUE; // Create a thread that waits until the end of the dialog process, and will restore the global variables - if (g_scheduler->createProcess(ShutUpDialogThread, &h, sizeof(uint32)) == 0) { + if (g_scheduler->createProcess(ShutUpDialogThread, &h, sizeof(uint32)) == INVALID_PID_VALUE) { // Something went wrong, so kill the previously started dialog process g_scheduler->killMatchingProcess(h); - return 0; + return INVALID_PID_VALUE; } return h; @@ -1912,16 +1904,23 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, * \****************************************************************************/ -#define GETARG(type) va_arg(v,type) +#define GETARG(type) va_arg(v, type) -void mpalQueryInner(CORO_PARAM, uint16 wQueryType, uint32 *dwRet, va_list v) { - CORO_BEGIN_CONTEXT; - int x, y, z; - char *n; - Common::String buf; - CORO_END_CONTEXT(_ctx); +/** + * MPAL Query variation #1 - dword return + * This variation handles mpal query types that need to return a dword result. + * + * @param wQueryType Query type + * @param v Variable length argument list + */ +uint32 mpalQueryDWORD(uint16 wQueryType, ...) { + int x, y, z; + Common::String buf; + uint32 dwRet = 0; + char *n; - CORO_BEGIN_CODE(_ctx); + va_list v; + va_start(v, wQueryType); mpalError = OK; @@ -1929,31 +1928,30 @@ void mpalQueryInner(CORO_PARAM, uint16 wQueryType, uint32 *dwRet, va_list v) { /* * uint32 mpalQuery(MPQ_VERSION); */ - *dwRet = HEX_VERSION; + dwRet = HEX_VERSION; } else if (wQueryType == MPQ_GLOBAL_VAR) { /* * uint32 mpalQuery(MPQ_GLOBAL_VAR, char * lpszVarName); */ LockVar(); - *dwRet = (uint32)varGetValue(GETARG(char *)); + dwRet = (uint32)varGetValue(GETARG(char *)); UnlockVar(); } else if (wQueryType == MPQ_MESSAGE) { /* * char * mpalQuery(MPQ_MESSAGE, uint32 nMsg); */ - LockMsg(); - *dwRet = (uint32)DuplicateMessage(msgGetOrderFromNum(GETARG(uint32))); - UnlockMsg(); + error("mpalQuery(MPQ_MESSAGE, uint32 nMsg) used incorrect method variant"); + } else if (wQueryType == MPQ_ITEM_PATTERN) { /* * uint32 mpalQuery(MPQ_ITEM_PATTERN, uint32 nItem); */ LockVar(); - _ctx->buf = Common::String::format("Pattern.%u", GETARG(uint32)); - *dwRet = (uint32)varGetValue(_ctx->buf.c_str()); + buf = Common::String::format("Pattern.%u", GETARG(uint32)); + dwRet = (uint32)varGetValue(buf.c_str()); UnlockVar(); } else if (wQueryType == MPQ_LOCATION_SIZE) { @@ -1961,61 +1959,56 @@ void mpalQueryInner(CORO_PARAM, uint16 wQueryType, uint32 *dwRet, va_list v) { * uint32 mpalQuery(MPQ_LOCATION_SIZE, uint32 nLoc, uint32 dwCoord); */ LockLocations(); - _ctx->x = locGetOrderFromNum(GETARG(uint32)); - _ctx->y = GETARG(uint32); - if (_ctx->x != -1) { - if (_ctx->y == MPQ_X) - *dwRet = lpmlLocations[_ctx->x].dwXlen; - else if (_ctx->y == MPQ_Y) - *dwRet = lpmlLocations[_ctx->x].dwYlen; + x = locGetOrderFromNum(GETARG(uint32)); + y = GETARG(uint32); + if (x != -1) { + if (y == MPQ_X) + dwRet = lpmlLocations[x].dwXlen; + else if (y == MPQ_Y) + dwRet = lpmlLocations[x].dwYlen; else mpalError = 1; } else mpalError = 1; + UnlockLocations(); } else if (wQueryType == MPQ_LOCATION_IMAGE) { /* * HGLOBAL mpalQuery(MPQ_LOCATION_IMAGE, uint32 nLoc); */ - LockLocations(); - _ctx->x = locGetOrderFromNum(GETARG(uint32)); - *dwRet = (uint32)resLoad(lpmlLocations[_ctx->x].dwPicRes); - UnlockLocations(); + error("mpalQuery(MPQ_LOCATION_IMAGE, uint32 nLoc) used incorrect variant"); } else if (wQueryType == MPQ_RESOURCE) { /* * HGLOBAL mpalQuery(MPQ_RESOURCE, uint32 dwRes); */ - *dwRet = (uint32)resLoad(GETARG(uint32)); + error("mpalQuery(MPQ_RESOURCE, uint32 dwRes) used incorrect variant"); } else if (wQueryType == MPQ_ITEM_LIST) { /* * uint32 mpalQuery(MPQ_ITEM_LIST, uint32 nLoc); */ - LockVar(); - *dwRet = (uint32)GetItemList(GETARG(uint32)); - LockVar(); + error("mpalQuery(MPQ_ITEM_LIST, uint32 nLoc) used incorrect variant"); } else if (wQueryType == MPQ_ITEM_DATA) { /* * LPITEM mpalQuery(MPQ_ITEM_DATA, uint32 nItem); */ - LockItems(); - *dwRet = (uint32)GetItemData(itemGetOrderFromNum(GETARG(uint32))); - UnlockItems(); + error("mpalQuery(MPQ_ITEM_DATA, uint32 nItem) used incorrect variant"); } else if (wQueryType == MPQ_ITEM_IS_ACTIVE) { /* * bool mpalQuery(MPQ_ITEM_IS_ACTIVE, uint32 nItem); */ LockVar(); - _ctx->x = GETARG(uint32); - _ctx->buf = Common::String::format("Status.%u", _ctx->x); - if (varGetValue(_ctx->buf.c_str()) <= 0) - *dwRet = (uint32)false; + x = GETARG(uint32); + buf = Common::String::format("Status.%u", x); + if (varGetValue(buf.c_str()) <= 0) + dwRet = (uint32)false; else - *dwRet = (uint32)true; + dwRet = (uint32)true; + UnlockVar(); } else if (wQueryType == MPQ_ITEM_NAME) { @@ -2023,15 +2016,15 @@ void mpalQueryInner(CORO_PARAM, uint16 wQueryType, uint32 *dwRet, va_list v) { * uint32 mpalQuery(MPQ_ITEM_NAME, uint32 nItem, char * lpszName); */ LockVar(); - _ctx->x = GETARG(uint32); - _ctx->n = GETARG(char *); - _ctx->buf = Common::String::format("Status.%u", _ctx->x); - if (varGetValue(_ctx->buf.c_str()) <= 0) - _ctx->n[0]='\0'; + x = GETARG(uint32); + n = GETARG(char *); + buf = Common::String::format("Status.%u", x); + if (varGetValue(buf.c_str()) <= 0) + n[0]='\0'; else { LockItems(); - _ctx->y = itemGetOrderFromNum(_ctx->x); - CopyMemory(_ctx->n, (char *)(lpmiItems+_ctx->y)->lpszDescribe, MAX_DESCRIBE_SIZE); + y = itemGetOrderFromNum(x); + CopyMemory(n, (char *)(lpmiItems + y)->lpszDescribe, MAX_DESCRIBE_SIZE); UnlockItems(); } @@ -2039,43 +2032,31 @@ void mpalQueryInner(CORO_PARAM, uint16 wQueryType, uint32 *dwRet, va_list v) { } else if (wQueryType == MPQ_DIALOG_PERIOD) { /* - * char * mpalQuery(MPQ_DIALOG_PERIOD, uint32 nDialog, uint32 nPeriod); + * char *mpalQuery(MPQ_DIALOG_PERIOD, uint32 nDialog, uint32 nPeriod); */ - LockDialogs(); - _ctx->y = GETARG(uint32); - *dwRet = (uint32)DuplicateDialogPeriod(_ctx->y); - UnlockDialogs(); + error("mpalQuery(MPQ_DIALOG_PERIOD, uint32 nDialog, uint32 nPeriod) used incorrect variant"); } else if (wQueryType == MPQ_DIALOG_WAITFORCHOICE) { /* * void mpalQuery(MPQ_DIALOG_WAITFORCHOICE); */ - CORO_INVOKE_2(g_scheduler->waitForSingleObject, hAskChoice, INFINITE); - - g_scheduler->resetEvent(hAskChoice); - - if (bExecutingDialog) - *dwRet = (uint32)nExecutingChoice; - else - *dwRet = (uint32)((int)-1); + error("mpalQuery(MPQ_DIALOG_WAITFORCHOICE) used incorrect variant"); } else if (wQueryType == MPQ_DIALOG_SELECTLIST) { /* * uint32 *mpalQuery(MPQ_DIALOG_SELECTLIST, uint32 nChoice); */ - LockDialogs(); - *dwRet = (uint32)GetSelectList(GETARG(uint32)); - UnlockDialogs(); - break; + error("mpalQuery(MPQ_DIALOG_SELECTLIST, uint32 nChoice) used incorrect variant"); } else if (wQueryType == MPQ_DIALOG_SELECTION) { /* * bool mpalQuery(MPQ_DIALOG_SELECTION, uint32 nChoice, uint32 dwData); */ LockDialogs(); - _ctx->x = GETARG(uint32); - _ctx->y = GETARG(uint32); - *dwRet = (uint32)DoSelection(_ctx->x,_ctx->y); + x = GETARG(uint32); + y = GETARG(uint32); + dwRet = (uint32)DoSelection(x, y); + UnlockDialogs(); } else if (wQueryType == MPQ_DO_ACTION) { @@ -2084,15 +2065,16 @@ void mpalQueryInner(CORO_PARAM, uint16 wQueryType, uint32 *dwRet, va_list v) { */ LockItems(); LockVar(); - _ctx->x = GETARG(uint32); - _ctx->z = GETARG(uint32); - _ctx->y = itemGetOrderFromNum(_ctx->z); - if (_ctx->y!=-1) { - *dwRet = (uint32)DoAction(_ctx->x, _ctx->y, GETARG(uint32)); + x = GETARG(uint32); + z = GETARG(uint32); + y = itemGetOrderFromNum(z); + if (y != -1) { + dwRet = DoAction(x, y, GETARG(uint32)); } else { - *dwRet = (uint32)INVALID_HANDLE_VALUE; + dwRet = INVALID_PID_VALUE; mpalError = 1; } + UnlockVar(); UnlockItems(); @@ -2103,9 +2085,9 @@ void mpalQueryInner(CORO_PARAM, uint16 wQueryType, uint32 *dwRet, va_list v) { if (!bExecutingDialog) { LockDialogs(); - _ctx->x = dialogGetOrderFromNum(GETARG(uint32)); - _ctx->y = GETARG(uint32); - *dwRet = DoDialog(_ctx->x, _ctx->y); + x = dialogGetOrderFromNum(GETARG(uint32)); + y = GETARG(uint32); + dwRet = DoDialog(x, y); UnlockDialogs(); } } else { @@ -2115,26 +2097,201 @@ void mpalQueryInner(CORO_PARAM, uint16 wQueryType, uint32 *dwRet, va_list v) { mpalError = 1; } - CORO_END_CODE; + va_end(v); + return dwRet; } -uint32 mpalQuery(uint16 wQueryType, ...) { - uint32 dwRet; +/** + * MPAL Query variation #1 - dword return + * This variation handles mpal query types that need to return a pointer/handle result + * + * @param wQueryType Query type + * @param v Variable length argument list + */ +HANDLE mpalQueryHANDLE(uint16 wQueryType, ...) { + int x, y; + char *n; + Common::String buf; va_list v; va_start(v, wQueryType); + void *hRet = NULL; + + mpalError = OK; - mpalQueryInner(nullContext, wQueryType, &dwRet, v); + if (wQueryType == MPQ_VERSION) { + /* + * uint32 mpalQuery(MPQ_VERSION); + */ + error("mpalQuery(MPQ_VERSION) used incorrect variant"); - va_end(v); + } else if (wQueryType == MPQ_GLOBAL_VAR) { + /* + * uint32 mpalQuery(MPQ_GLOBAL_VAR, char * lpszVarName); + */ + error("mpalQuery(MPQ_GLOBAL_VAR, char * lpszVarName) used incorrect variant"); - return dwRet; + } else if (wQueryType == MPQ_MESSAGE) { + /* + * char * mpalQuery(MPQ_MESSAGE, uint32 nMsg); + */ + LockMsg(); + hRet = DuplicateMessage(msgGetOrderFromNum(GETARG(uint32))); + UnlockMsg(); + + } else if (wQueryType == MPQ_ITEM_PATTERN) { + /* + * uint32 mpalQuery(MPQ_ITEM_PATTERN, uint32 nItem); + */ + error("mpalQuery(MPQ_ITEM_PATTERN, uint32 nItem) used incorrect variant"); + + } else if (wQueryType == MPQ_LOCATION_SIZE) { + /* + * uint32 mpalQuery(MPQ_LOCATION_SIZE, uint32 nLoc, uint32 dwCoord); + */ + error("mpalQuery(MPQ_LOCATION_SIZE, uint32 nLoc, uint32 dwCoord) used incorrect variant"); + + } else if (wQueryType == MPQ_LOCATION_IMAGE) { + /* + * HGLOBAL mpalQuery(MPQ_LOCATION_IMAGE, uint32 nLoc); + */ + LockLocations(); + x = locGetOrderFromNum(GETARG(uint32)); + hRet = resLoad(lpmlLocations[x].dwPicRes); + UnlockLocations(); + + } else if (wQueryType == MPQ_RESOURCE) { + /* + * HGLOBAL mpalQuery(MPQ_RESOURCE, uint32 dwRes); + */ + hRet = resLoad(GETARG(uint32)); + + } else if (wQueryType == MPQ_ITEM_LIST) { + /* + * uint32 mpalQuery(MPQ_ITEM_LIST, uint32 nLoc); + */ + LockVar(); + hRet = GetItemList(GETARG(uint32)); + LockVar(); + + } else if (wQueryType == MPQ_ITEM_DATA) { + /* + * LPITEM mpalQuery(MPQ_ITEM_DATA, uint32 nItem); + */ + LockItems(); + hRet = GetItemData(itemGetOrderFromNum(GETARG(uint32))); + UnlockItems(); + + } else if (wQueryType == MPQ_ITEM_IS_ACTIVE) { + /* + * bool mpalQuery(MPQ_ITEM_IS_ACTIVE, uint32 nItem); + */ + error("mpalQuery(MPQ_ITEM_IS_ACTIVE, uint32 nItem) used incorrect variant"); + + } else if (wQueryType == MPQ_ITEM_NAME) { + /* + * uint32 mpalQuery(MPQ_ITEM_NAME, uint32 nItem, char *lpszName); + */ + LockVar(); + x = GETARG(uint32); + n = GETARG(char *); + buf = Common::String::format("Status.%u", x); + if (varGetValue(buf.c_str()) <= 0) + n[0]='\0'; + else { + LockItems(); + y = itemGetOrderFromNum(x); + CopyMemory(n, (char *)(lpmiItems + y)->lpszDescribe, MAX_DESCRIBE_SIZE); + UnlockItems(); + } + + UnlockVar(); + + } else if (wQueryType == MPQ_DIALOG_PERIOD) { + /* + * char * mpalQuery(MPQ_DIALOG_PERIOD, uint32 nDialog, uint32 nPeriod); + */ + LockDialogs(); + y = GETARG(uint32); + hRet = DuplicateDialogPeriod(y); + UnlockDialogs(); + + } else if (wQueryType == MPQ_DIALOG_WAITFORCHOICE) { + /* + * void mpalQuery(MPQ_DIALOG_WAITFORCHOICE); + */ + error("mpalQuery(MPQ_DIALOG_WAITFORCHOICE) used incorrect variant"); + + } else if (wQueryType == MPQ_DIALOG_SELECTLIST) { + /* + * uint32 *mpalQuery(MPQ_DIALOG_SELECTLIST, uint32 nChoice); + */ + LockDialogs(); + hRet = GetSelectList(GETARG(uint32)); + UnlockDialogs(); + + } else if (wQueryType == MPQ_DIALOG_SELECTION) { + /* + * bool mpalQuery(MPQ_DIALOG_SELECTION, uint32 nChoice, uint32 dwData); + */ + error("mpalQuery(MPQ_DIALOG_SELECTION, uint32 nChoice, uint32 dwData) used incorrect variant"); + + } else if (wQueryType == MPQ_DO_ACTION) { + /* + * int mpalQuery(MPQ_DO_ACTION, uint32 nAction, uint32 nItem, uint32 dwParam); + */ + error("mpalQuery(MPQ_DO_ACTION, uint32 nAction, uint32 nItem, uint32 dwParam) used incorrect variant"); + + } else if (wQueryType == MPQ_DO_DIALOG) { + /* + * int mpalQuery(MPQ_DO_DIALOG, uint32 nDialog, uint32 nGroup); + */ + error("mpalQuery(MPQ_DO_DIALOG, uint32 nDialog, uint32 nGroup) used incorrect variant"); + } else { + /* + * DEFAULT -> ERROR + */ + mpalError = 1; + } + + va_end(v); + return hRet; } -void mpalQueryCoro(CORO_PARAM, uint32 *dwRet, uint16 wQueryType, ...) { +/** + * MPAL Query variation #1 - dword return + * This variation handles mpal query types that need to return a pointer/handle result + * + * @param wQueryType Query type + * @param dwRet DWORD return value (when coroutine method completes) + * @param v Variable length argument list + */ +void mpalQueryCORO(CORO_PARAM, uint16 wQueryType, uint32 *dwRet, ...) { + CORO_BEGIN_CONTEXT; + uint32 dwRet; + CORO_END_CONTEXT(_ctx); + va_list v; - va_start(v, wQueryType); + va_start(v, dwRet); + + CORO_BEGIN_CODE(_ctx); + + if (wQueryType == MPQ_DIALOG_WAITFORCHOICE) { + /* + * void mpalQuery(MPQ_DIALOG_WAITFORCHOICE); + */ + CORO_INVOKE_2(g_scheduler->waitForSingleObject, hAskChoice, INFINITE); + + g_scheduler->resetEvent(hAskChoice); - mpalQueryInner(coroParam, wQueryType, dwRet, v); + if (bExecutingDialog) + *dwRet = (uint32)nExecutingChoice; + else + *dwRet = (uint32)((int)-1); + } else { + error("mpalQueryCORO called with unsupported query type"); + } + + CORO_END_CODE; va_end(v); } @@ -2171,7 +2328,6 @@ uint32 mpalGetError(void) { bool EXPORT mpalExecuteScript(int nScript) { int n; LPMPALSCRIPT s; - uint32 dwId; LockScripts(); n = scriptGetOrderFromNum(nScript); diff --git a/engines/tony/mpal/mpal.h b/engines/tony/mpal/mpal.h index 5517a6518c..9a85f2df17 100644 --- a/engines/tony/mpal/mpal.h +++ b/engines/tony/mpal/mpal.h @@ -156,7 +156,7 @@ enum QueryCoordinates { /****************************************************************************\ * enum QueryTypes * --------------- -* Description: Query can be used with mpalQuery (). In practice corresponds +* Description: Query can be used with mpalQuery methods. In practice corresponds * all claims that can do at the library \****************************************************************************/ @@ -252,7 +252,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; \****************************************************************************/ #define mpalQueryVersion() \ - (uint16)mpalQuery(MPQ_VERSION) + (uint16)mpalQueryDWORD(MPQ_VERSION) @@ -273,7 +273,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; \****************************************************************************/ #define mpalQueryGlobalVar(lpszVarName) \ - (uint32)mpalQuery(MPQ_GLOBAL_VAR,(const char *)(lpszVarName)) + mpalQueryDWORD(MPQ_GLOBAL_VAR, (const char *)(lpszVarName)) @@ -291,7 +291,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; \****************************************************************************/ #define mpalQueryResource(dwResId) \ - (HGLOBAL)mpalQuery(MPQ_RESOURCE,(uint32)(dwResId)) + mpalQueryHANDLE(MPQ_RESOURCE, (uint32)(dwResId)) @@ -311,7 +311,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; \****************************************************************************/ #define mpalQueryMessage(nMsg) \ - (LPSTR)mpalQuery(MPQ_MESSAGE,(uint32)(nMsg)) + (LPSTR)mpalQueryHANDLE(MPQ_MESSAGE, (uint32)(nMsg)) @@ -328,7 +328,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; \****************************************************************************/ #define mpalQueryLocationImage(nLoc) \ - (HGLOBAL)mpalQuery(MPQ_LOCATION_IMAGE,(uint32)(nLoc)) + mpalQueryHANDLE(MPQ_LOCATION_IMAGE, (uint32)(nLoc)) @@ -346,7 +346,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; \****************************************************************************/ #define mpalQueryLocationSize(nLoc,dwCoord) \ - (uint32)mpalQuery(MPQ_LOCATION_SIZE,(uint32)(nLoc),(uint32)(dwCoord)) + mpalQueryDWORD(MPQ_LOCATION_SIZE,(uint32)(nLoc),(uint32)(dwCoord)) @@ -361,9 +361,9 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * Return: List of objects (accessible by Item [0], Item [1], etc.) * \****************************************************************************/ - +// TODO: Check if the results of this are endian safe #define mpalQueryItemList(nLoc) \ - (uint32 *)mpalQuery(MPQ_ITEM_LIST,(uint32)(nLoc)) + (uint32 *)mpalQueryHANDLE(MPQ_ITEM_LIST,(uint32)(nLoc)) @@ -380,7 +380,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; \****************************************************************************/ #define mpalQueryItemData(nItem) \ - (LPITEM)mpalQuery(MPQ_ITEM_DATA,(uint32)(nItem)) + (LPITEM)mpalQueryHANDLE(MPQ_ITEM_DATA,(uint32)(nItem)) @@ -400,7 +400,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; \****************************************************************************/ #define mpalQueryItemPattern(nItem) \ - (uint32)mpalQuery(MPQ_ITEM_PATTERN,(uint32)(nItem)) + mpalQueryDWORD(MPQ_ITEM_PATTERN,(uint32)(nItem)) @@ -417,7 +417,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; \****************************************************************************/ #define mpalQueryItemIsActive(nItem) \ - (bool)mpalQuery(MPQ_ITEM_IS_ACTIVE,(uint32)(nItem)) + (bool)mpalQueryDWORD(MPQ_ITEM_IS_ACTIVE,(uint32)(nItem)) /****************************************************************************\ @@ -435,8 +435,8 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * \****************************************************************************/ -#define mpalQueryItemName(nItem,lpszName) \ - (uint32)mpalQuery(MPQ_ITEM_NAME,(uint32)(nItem),(LPSTR)(lpszName)) +#define mpalQueryItemName(nItem, lpszName) \ + mpalQueryHANDLE(MPQ_ITEM_NAME,(uint32)(nItem), (LPSTR)(lpszName)) @@ -459,7 +459,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; \****************************************************************************/ #define mpalQueryDialogPeriod(nPeriod) \ - (LPSTR)mpalQuery(MPQ_DIALOG_PERIOD,(uint32)(nPeriod)) + (LPSTR)mpalQueryHANDLE(MPQ_DIALOG_PERIOD, (uint32)(nPeriod)) @@ -475,7 +475,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; \****************************************************************************/ #define mpalQueryDialogWaitForChoice(dwRet) \ - CORO_INVOKE_2(mpalQueryCoro, dwRet, MPQ_DIALOG_WAITFORCHOICE) + CORO_INVOKE_2(mpalQueryCORO, MPQ_DIALOG_WAITFORCHOICE, dwRet) /****************************************************************************\ * @@ -496,7 +496,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; \****************************************************************************/ #define mpalQueryDialogSelectList(nChoice) \ - (uint32 *)mpalQuery(MPQ_DIALOG_SELECTLIST,(uint32)(nChoice)) + (uint32 *)mpalQueryHANDLE(MPQ_DIALOG_SELECTLIST,(uint32)(nChoice)) @@ -521,10 +521,8 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; \****************************************************************************/ #define mpalQueryDialogSelection(nChoice,dwData) \ - (bool)mpalQuery(MPQ_DIALOG_SELECTION,(uint32)(nChoice),(uint32)(dwData)) + (bool)mpalQueryDWORD(MPQ_DIALOG_SELECTION,(uint32)(nChoice),(uint32)(dwData)) -#define mpalQueryDialogSelectionU32(nChoice, dwData) \ - mpalQuery(MPQ_DIALOG_SELECTION,(uint32)(nChoice),(uint32)(dwData)) /****************************************************************************\ * @@ -539,7 +537,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * uint32 dwParam Action parameter * * Return: Handle to the thread that is performing the action, or -* INVALID_HANDLE_VALUE if the action is not 'defined for +* INVALID_PID_VALUE if the action is not 'defined for * the item, or the item and 'off. * * Note: The parameter is used primarily to implement actions @@ -549,10 +547,8 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; \****************************************************************************/ #define mpalQueryDoAction(nAction, nItem, dwParam) \ - (HANDLE)mpalQuery(MPQ_DO_ACTION, (uint32)(nAction), (uint32)(nItem), (uint32)(dwParam)) + mpalQueryDWORD(MPQ_DO_ACTION, (uint32)(nAction), (uint32)(nItem), (uint32)(dwParam)) -#define mpalQueryDoActionU32(nAction, nItem, dwParam) \ - mpalQuery(MPQ_DO_ACTION, (uint32)(nAction), (uint32)(nItem), (uint32)(dwParam)) /****************************************************************************\ @@ -565,15 +561,12 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * uint32 nGroup Group number to use * * Return: Handle to the thread that is running the box, or -* INVALID_HANDLE_VALUE if the dialogue does not exist. +* INVALID_PID_VALUE if the dialogue does not exist. * \****************************************************************************/ #define mpalQueryDoDialog(nDialog,nGroup) \ - (HANDLE)mpalQuery(MPQ_DO_DIALOG,(uint32)(nDialog),(uint32)(nGroup)) - -#define mpalQueryDoDialogU32(nDialog, nGroup) \ - mpalQuery(MPQ_DO_DIALOG,(uint32)(nDialog),(uint32)(nGroup)) + mpalQueryHANDLE(MPQ_DO_DIALOG, (uint32)(nDialog),(uint32)(nGroup)) /****************************************************************************\ @@ -623,9 +616,13 @@ bool EXPORT mpalInit(const char *lpszFileName, const char *lpszMprFileName, * \****************************************************************************/ -uint32 EXPORT mpalQuery(uint16 wQueryType, ...); +typedef void *HANDLE; + +uint32 mpalQueryDWORD(uint16 wQueryType, ...); + +HANDLE mpalQueryHANDLE(uint16 wQueryType, ...); -void mpalQueryCoro(CORO_PARAM, uint32 *dwRet, uint16 wQueryType, ...); +void mpalQueryCORO(CORO_PARAM, uint16 wQueryType, uint32 *dwRet, ...); /****************************************************************************\ * diff --git a/engines/tony/mpal/stubs.h b/engines/tony/mpal/stubs.h index 082974898c..ae25f7127e 100644 --- a/engines/tony/mpal/stubs.h +++ b/engines/tony/mpal/stubs.h @@ -71,9 +71,6 @@ Out CopyMemory(Out dst, In first, int size) { * Methods \****************************************************************************/ -// Horrendously bad cast -#define INVALID_HANDLE_VALUE (void *)-1 - extern uint16 GetAsyncKeyState(Common::KeyCode kc); } // end of namespace MPAL diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index b376d14149..a2b3d7c8ce 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -1021,7 +1021,7 @@ FPSFX::FPSFX(LPDIRECTSOUND lpds, HWND hWnd, bool bSoundOn) { lpDSNotify = NULL; lpDS = lpds; lastVolume = 63; - hEndOfBuffer = INVALID_HANDLE_VALUE; + hEndOfBuffer = INVALID_PID_VALUE; bIsVoice = false; if (bSoundSupported == false) @@ -1053,7 +1053,7 @@ FPSFX::~FPSFX() { RELEASE(lpDSNotify); - if (hEndOfBuffer != INVALID_HANDLE_VALUE) + if (hEndOfBuffer != INVALID_PID_VALUE) CloseHandle(hEndOfBuffer); RELEASE(lpDSBuffer); @@ -1415,7 +1415,7 @@ bool FPSFX::LoadFile(const char *lpszFileName, uint32 dwCodec) { bool FPSFX::Play() { #ifdef REFACTOR_ME if (bFileLoaded) { - if (hEndOfBuffer != INVALID_HANDLE_VALUE) + if (hEndOfBuffer != INVALID_PID_VALUE) ResetEvent(hEndOfBuffer); lpDSBuffer->SetCurrentPosition(0); diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index ef27f509b9..d8ea05d06a 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -322,11 +322,17 @@ void TonyEngine::SaveState(int n, const char *name) { } -void TonyEngine::LoadState(int n) { - char buf[256]; +void TonyEngine::LoadState(CORO_PARAM, int n) { + CORO_BEGIN_CONTEXT; + char buf[256]; + CORO_END_CONTEXT(_ctx); - GetSaveStateFileName(n, buf); - _theEngine.LoadState(buf); + CORO_BEGIN_CODE(_ctx); + + GetSaveStateFileName(n, _ctx->buf); + CORO_INVOKE_1(_theEngine.LoadState, _ctx->buf); + + CORO_END_CODE; } bool TonyEngine::OpenVoiceDatabase() { @@ -393,35 +399,66 @@ void TonyEngine::Abort(void) { m_bQuitNow = true; } -void TonyEngine::Play(void) { - // Main game loop - while (!shouldQuit() && !m_bQuitNow) { - // Se siamo in pausa, entra nel loop appropriato - if (m_bPaused) - PauseLoop(); +/** + * Main process for playing the game. + * + * @remarks This needs to be in a separate process, since there are some things that can briefly + * block the execution of process. For now, all ScummVm event handling is dispatched to within the context of this + * process. If it ever proves a problem, we may have to look into whether it's feasible to have it still remain + * in the outer 'main' process. + */ +void TonyEngine::PlayProcess(CORO_PARAM, const void *param) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); - g_system->delayMillis(50); + CORO_BEGIN_CODE(_ctx); - // Call any scheduled processes - _scheduler.schedule(); + // Infinite loop. We rely on the outer main process to detect if a shutdown is required, + // and kill the scheudler and all the processes, including this one + for (;;) { + // Se siamo in pausa, entra nel loop appropriato + if (_vm->m_bPaused) + _vm->PauseLoop(); + + // Wait for the next frame + CORO_INVOKE_1(g_scheduler->sleep, 50); // Call the engine to handle the next frame // FIXME: This needs to be moved into it's own process - _theEngine.DoFrame(nullContext, m_bDrawLocation); + CORO_INVOKE_1(_vm->_theEngine.DoFrame, _vm->m_bDrawLocation); // Warns that a frame is finished - g_scheduler->pulseEvent(m_hEndOfFrame); + g_scheduler->pulseEvent(_vm->m_hEndOfFrame); // Handle drawing the frame - if (!m_bPaused) { - if (!_theEngine.m_bWiping) - _window.GetNewFrame(_theEngine, NULL); + if (!_vm->m_bPaused) { + if (!_vm->_theEngine.m_bWiping) + _vm->_window.GetNewFrame(_vm->_theEngine, NULL); else - _window.GetNewFrame(_theEngine, &_theEngine.m_rcWipeEllipse); + _vm->_window.GetNewFrame(_vm->_theEngine, &_vm->_theEngine.m_rcWipeEllipse); } // Paint the frame onto the screen - _window.Repaint(); + _vm->_window.Repaint(); + } + + CORO_END_CODE; +} + +/** + * Play the game + */ +void TonyEngine::Play(void) { + // Create the game player process + g_scheduler->createProcess(PlayProcess, NULL); + + // Loop through calling the scheduler until it's time for the game to quit + while (!shouldQuit() && !m_bQuitNow) { + // Delay for a brief amount + g_system->delayMillis(10); + + // Call any scheduled processes + _scheduler.schedule(); } } diff --git a/engines/tony/tony.h b/engines/tony/tony.h index fdb92e3795..935f805912 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -82,6 +82,7 @@ private: bool OpenVoiceDatabase(); void CloseVoiceDatabase(); void InitCustomFunctionMap(); + static void PlayProcess(CORO_PARAM, const void *param); protected: // Engine APIs virtual Common::Error run(); @@ -193,7 +194,7 @@ public: // Salvataggio void AutoSave(CORO_PARAM); void SaveState(int n, const char *name); - void LoadState(int n); + void LoadState(CORO_PARAM, int n); void GetSaveStateFileName(int n, char *buf); // Prende il thumbnail diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index ea233233d2..06adcd15b8 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -213,53 +213,48 @@ void RMTony::MoveAndDoAction(RMPoint dst, RMItem *item, int nAction, int nAction void RMTony::ExecuteAction(int nAction, int nActionItem, int nParm) { // fixme: See if hThread can be converted to uint32 - HANDLE hThread; uint32 pid; if (nAction == TA_COMBINE) { - hThread = mpalQueryDoAction(TA_COMBINE, nParm, nActionItem); + pid = mpalQueryDoAction(TA_COMBINE, nParm, nActionItem); // Se fallito il combine, proviamo con il ReceiveCombine - if (hThread == INVALID_HANDLE_VALUE) { - hThread = mpalQueryDoAction(TA_RECEIVECOMBINE, nActionItem, nParm); + if (pid == INVALID_PID_VALUE) { + pid = mpalQueryDoAction(TA_RECEIVECOMBINE, nActionItem, nParm); // Se fallito il receive, andiamo con quelli generici // @@@ CombineGive! - if (hThread == INVALID_HANDLE_VALUE) { - hThread = mpalQueryDoAction(TA_COMBINE, nParm, 0); + if (pid == INVALID_PID_VALUE) { + pid = mpalQueryDoAction(TA_COMBINE, nParm, 0); - if (hThread == INVALID_HANDLE_VALUE){ - hThread = mpalQueryDoAction(TA_RECEIVECOMBINE, nActionItem, 0); + if (pid == INVALID_PID_VALUE){ + pid = mpalQueryDoAction(TA_RECEIVECOMBINE, nActionItem, 0); } } } } else { // Perform the action - hThread = mpalQueryDoAction(nAction, nActionItem, 0); + pid = mpalQueryDoAction(nAction, nActionItem, 0); } - if (hThread != INVALID_HANDLE_VALUE) { + if (pid != INVALID_PID_VALUE) { m_bAction = true; - pid = (uint32)hThread; g_scheduler->createProcess(WaitEndOfAction, &pid, sizeof(uint32)); hActionThread = pid; } else if (nAction != TA_GOTO) { if (nAction == TA_TALK) { - hThread = mpalQueryDoAction(6, 1, 0); + pid = mpalQueryDoAction(6, 1, 0); m_bAction = true; - pid = (uint32)hThread; g_scheduler->createProcess(WaitEndOfAction, &pid, sizeof(uint32)); hActionThread = pid; } else if (nAction == TA_PALESATI) { - hThread = mpalQueryDoAction(7, 1, 0); + pid = mpalQueryDoAction(7, 1, 0); m_bAction = true; - pid = (uint32)hThread; g_scheduler->createProcess(WaitEndOfAction, &pid, sizeof(uint32)); hActionThread = pid; } else { - hThread = mpalQueryDoAction(5, 1, 0); + pid = mpalQueryDoAction(5, 1, 0); m_bAction = true; - pid = (uint32)hThread; g_scheduler->createProcess(WaitEndOfAction, &pid, sizeof(uint32)); hActionThread = pid; } @@ -285,21 +280,21 @@ void RMTony::StopNoAction(CORO_PARAM) { void RMTony::Stop(CORO_PARAM) { CORO_BEGIN_CONTEXT; - uint32 hThread; + uint32 pid; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); if (m_ActionItem != NULL) { // Richiama l'MPAL per scegliere la direzione - _ctx->hThread = mpalQueryDoActionU32(21, m_ActionItem->MpalCode(), 0); + _ctx->pid = mpalQueryDoAction(21, m_ActionItem->MpalCode(), 0); - if (_ctx->hThread == INVALID_PID_VALUE) + if (_ctx->pid == INVALID_PID_VALUE) RMCharacter::Stop(); else { bNeedToStop = false; // Se facciamo la OnWhichDirection, almeno dopo non dobbiamo fare la Stop() bMoving = false; - CORO_INVOKE_2(g_scheduler->waitForSingleObject, _ctx->hThread, INFINITE); // @@@ Mettere un assert dopo 10 secondi + CORO_INVOKE_2(g_scheduler->waitForSingleObject, _ctx->pid, INFINITE); // @@@ Mettere un assert dopo 10 secondi } } else { RMCharacter::Stop(); diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index 8ac36a5693..f68c612911 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -149,7 +149,7 @@ byte RMSnapshot::rgb[RM_SX * RM_SY * 3]; bool RMSnapshot::GetFreeSnapName(char *fn) { #ifdef REFACTOR_ME int i, j, k; - HANDLE h; + uint32 h; theGame.GetDataDirectory(RMGame::DD_SHOTS, fn); _splitpath(fn, bufDrive, bufDir, NULL, NULL); @@ -158,7 +158,7 @@ bool RMSnapshot::GetFreeSnapName(char *fn) { wsprintf(bufName,"rm%d00",i); _makepath(fn,bufDrive,bufDir,bufName,".bmp"); h = CreateFile(fn,GENERIC_READ,FILE_SHARE_READ, NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL, NULL); - if (h == INVALID_HANDLE_VALUE) + if (h == INVALID_PID_VALUE) break; CloseHandle(h); } @@ -169,7 +169,7 @@ bool RMSnapshot::GetFreeSnapName(char *fn) { wsprintf(bufName,"rm%d%d0",i,j); _makepath(fn,bufDrive,bufDir,bufName,".bmp"); h=CreateFile(fn,GENERIC_READ,FILE_SHARE_READ, NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL, NULL); - if (h==INVALID_HANDLE_VALUE) + if (h==INVALID_PID_VALUE) break; CloseHandle(h); } @@ -180,7 +180,7 @@ bool RMSnapshot::GetFreeSnapName(char *fn) { wsprintf(bufName,"rm%d%d%d",i,j,k); _makepath(fn,bufDrive,bufDir,bufName,".bmp"); h = CreateFile(fn,GENERIC_READ,FILE_SHARE_READ, NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL, NULL); - if (h==INVALID_HANDLE_VALUE) + if (h==INVALID_PID_VALUE) break; CloseHandle(h); } -- cgit v1.2.3 From 9a7393e0c397c2f5e3a6a9be06197d847ab0d28b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 10 May 2012 22:18:33 +1000 Subject: TONY: Fix operation of MPAL ActionThread method --- engines/tony/mpal/mpal.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'engines') diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index c21d84cd9b..da736a138f 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -996,7 +996,6 @@ void ActionThread(CORO_PARAM, const void *param) { LockVar(); varSetValue(item->Command[_ctx->k].lpszVarName, EvaluateExpression(item->Command[_ctx->k].expr)); UnlockVar(); - break; } else { mpalError = 1; -- cgit v1.2.3 From 82361a3ea3efb9b6454eb4805e777cd4bfc3a0e3 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 11 May 2012 00:09:34 +1000 Subject: TONY: Fixed some missed methods to coroutines --- engines/tony/custom.cpp | 4 +- engines/tony/gfxengine.cpp | 10 ++--- engines/tony/loc.cpp | 107 ++++++++++++++++++++++++++++++--------------- engines/tony/loc.h | 8 ++-- engines/tony/tonychar.cpp | 33 ++++++++++---- engines/tony/tonychar.h | 4 +- 6 files changed, 109 insertions(+), 57 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 150e199fc8..c82d0fcd2b 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -1337,7 +1337,7 @@ DECLARE_CUSTOM_FUNCTION(MoveTonyAndWait)(CORO_PARAM, uint32 nX, uint32 nY, uint3 CORO_BEGIN_CODE(_ctx); - Tony->Move(RMPoint(nX, nY)); + CORO_INVOKE_1(Tony->Move, RMPoint(nX, nY)); if (!bSkipIdle) CORO_INVOKE_0(Tony->WaitForEndMovement); @@ -1346,7 +1346,7 @@ DECLARE_CUSTOM_FUNCTION(MoveTonyAndWait)(CORO_PARAM, uint32 nX, uint32 nY, uint3 } DECLARE_CUSTOM_FUNCTION(MoveTony)(CORO_PARAM, uint32 nX, uint32 nY, uint32, uint32) { - Tony->Move(RMPoint(nX, nY)); + Tony->Move(coroParam, RMPoint(nX, nY)); } DECLARE_CUSTOM_FUNCTION(ScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, uint32 sX, uint32 sY) { diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 3952d0c227..5a9c0555e0 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -208,7 +208,7 @@ void RMGfxEngine::DoFrame(CORO_PARAM, bool bDrawLocation) { // *************** if (m_input.MouseRightReleased()) { if (m_inv.RightRelease(m_input.MousePos(), m_curAction)) { - m_tony.MoveAndDoAction(m_itemName.GetHotspot(),m_itemName.GetSelectedItem(),m_curAction); + CORO_INVOKE_3(m_tony.MoveAndDoAction, m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), m_curAction); m_curAction = TA_GOTO; m_point.SetAction(m_curAction); @@ -240,9 +240,9 @@ void RMGfxEngine::DoFrame(CORO_PARAM, bool bDrawLocation) { //if (m_itemName.IsItemSelected()) { if (m_curAction != TA_COMBINE) - m_tony.MoveAndDoAction(m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), m_point.CurAction()); + CORO_INVOKE_3(m_tony.MoveAndDoAction, m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), m_point.CurAction()); else if (m_itemName.GetSelectedItem() != NULL) - m_tony.MoveAndDoAction(m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), TA_COMBINE, m_curActionObj); + CORO_INVOKE_3(m_tony.MoveAndDoAction, m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), TA_COMBINE, m_curActionObj); } if (m_curAction == TA_COMBINE) { @@ -283,7 +283,7 @@ SKIPCLICKSINISTRO: if (m_bGUIInterface) { if (m_inter.Released(m_input.MousePos(),m_curAction)) { m_point.SetAction(m_curAction); - m_tony.MoveAndDoAction(m_itemName.GetHotspot(),m_itemName.GetSelectedItem(), m_curAction); + CORO_INVOKE_3(m_tony.MoveAndDoAction, m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), m_curAction); m_curAction = TA_GOTO; m_point.SetAction(m_curAction); @@ -304,7 +304,7 @@ SKIPCLICKSINISTRO: } // Anima Tony - m_tony.DoFrame(&m_bigBuf, m_nCurLoc); + CORO_INVOKE_2(m_tony.DoFrame, &m_bigBuf, m_nCurLoc); // Aggiorna lo scrolling per tenere Tony dentro lo schermo if (m_tony.MustUpdateScrolling() && m_bLocationLoaded) { diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index bba1ad2f23..080e06da87 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -1087,10 +1087,15 @@ short RMCharacter::FindPath(short source, short destination) { } -void RMCharacter::GoTo(RMPoint destcoord, bool bReversed) { +void RMCharacter::GoTo(CORO_PARAM, RMPoint destcoord, bool bReversed) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + if (m_pos == destcoord) { if (minpath == 0) { - Stop(); + CORO_INVOKE_0(Stop); g_scheduler->pulseEvent(hEndOfPath); return; } @@ -1149,6 +1154,7 @@ void RMCharacter::GoTo(RMPoint destcoord, bool bReversed) { olddy = dy; // ResetEvent(hTonyEndMovement); @@@ + CORO_END_CODE; } @@ -1413,10 +1419,15 @@ void RMCharacter::NewBoxEntered(int nBox) { mpalQueryDoAction(2, curLocation, curbox); } -void RMCharacter::DoFrame(RMGfxTargetBuffer* bigBuf, int loc) { - bool bEndNow; +void RMCharacter::DoFrame(CORO_PARAM, RMGfxTargetBuffer* bigBuf, int loc) { + CORO_BEGIN_CONTEXT; + bool bEndNow; + RMBoxLoc *cur; + CORO_END_CONTEXT(_ctx); - bEndNow = false; + CORO_BEGIN_CODE(_ctx); + + _ctx->bEndNow = false; bEndOfPath = false; bDrawNow = (curLocation == loc); @@ -1435,7 +1446,7 @@ void RMCharacter::DoFrame(RMGfxTargetBuffer* bigBuf, int loc) { if (((walkspeed > 0) && (m_pos.x > lineend.x)) || ((walkspeed < 0) && (m_pos.x < lineend.x))) { m_pos = lineend; status = STAND; - bEndNow = true; + _ctx->bEndNow = true; } } @@ -1450,7 +1461,7 @@ void RMCharacter::DoFrame(RMGfxTargetBuffer* bigBuf, int loc) { if (((walkspeed > 0) && (m_pos.y > lineend.y)) || ((walkspeed < 0) && (m_pos.y < lineend.y))) { m_pos = lineend; status = STAND; - bEndNow = true; + _ctx->bEndNow = true; } } @@ -1463,9 +1474,9 @@ void RMCharacter::DoFrame(RMGfxTargetBuffer* bigBuf, int loc) { // Se siamo appena arrivati alla destinazione temporanea ed finito il percorso minimo, // ci fermiamo definitivamente - if (bEndNow && minpath == 0) { + if (_ctx->bEndNow && minpath == 0) { if (!bEndOfPath) - Stop(); + CORO_INVOKE_0(Stop); bEndOfPath = true; g_scheduler->pulseEvent(hEndOfPath); } @@ -1487,15 +1498,15 @@ void RMCharacter::DoFrame(RMGfxTargetBuffer* bigBuf, int loc) { if (status == STAND) { // Controlliamo se c' ancora percorso minimo da calcolare if (minpath == 1) { - RMBoxLoc *cur = theBoxes->GetBoxes(curLocation); + _ctx->cur = theBoxes->GetBoxes(curLocation); // Se dobbiamo ancora attraversare un box if (pathcount < pathlenght) { // Controlliamo che il box su cui stiamo entrando sia attivo - if (cur->boxes[path[pathcount-1]].attivo) { + if (_ctx->cur->boxes[path[pathcount-1]].attivo) { // Muoviti in linea retta verso l'hotspot pi vicino, tenendo conto del reversing please // NEWBOX = path[pathcount-1] - GoTo(NearestHotSpot(path[pathcount-1], path[pathcount]), cur->boxes[path[pathcount-1]].bReversed); + CORO_INVOKE_2(GoTo, NearestHotSpot(path[pathcount-1], path[pathcount]), _ctx->cur->boxes[path[pathcount-1]].bReversed); pathcount++; } else { // Se il box disattivato, possiamo solo bloccare tutto @@ -1503,7 +1514,7 @@ void RMCharacter::DoFrame(RMGfxTargetBuffer* bigBuf, int loc) { // la ricerca del percorso minimo minpath = 0; if (!bEndOfPath) - Stop(); + CORO_INVOKE_0(Stop); bEndOfPath = true; g_scheduler->pulseEvent(hEndOfPath); } @@ -1512,7 +1523,7 @@ void RMCharacter::DoFrame(RMGfxTargetBuffer* bigBuf, int loc) { // punto di arrivo // NEWBOX = InWhichBox(pathend) minpath = 0; - GoTo(pathend, cur->boxes[InWhichBox(pathend)].bReversed); + CORO_INVOKE_2(GoTo, pathend, _ctx->cur->boxes[InWhichBox(pathend)].bReversed); } } } @@ -1521,9 +1532,16 @@ void RMCharacter::DoFrame(RMGfxTargetBuffer* bigBuf, int loc) { // Richiama il DoFrame dell'item RMItem::DoFrame(bigBuf); + + CORO_END_CODE; } -void RMCharacter::Stop(void) { +void RMCharacter::Stop(CORO_PARAM) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + bMoving = false; // Non si sa mai... @@ -1558,6 +1576,8 @@ void RMCharacter::Stop(void) { SetPattern(PAT_STANDDOWN); break; } + + CORO_END_CODE; } inline int RMCharacter::InWhichBox(RMPoint pt) { @@ -1565,9 +1585,14 @@ inline int RMCharacter::InWhichBox(RMPoint pt) { } -bool RMCharacter::Move(RMPoint pt) { - RMPoint dest; - int numbox; +void RMCharacter::Move(CORO_PARAM, RMPoint pt, bool *result) { + CORO_BEGIN_CONTEXT; + RMPoint dest; + int numbox; + RMBoxLoc *cur; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); bMoving = true; @@ -1575,31 +1600,33 @@ bool RMCharacter::Move(RMPoint pt) { if (pt.x == 0 && pt.y == 0) { minpath = 0; status = STAND; - Stop(); - return true; + CORO_INVOKE_0(Stop); + if (result) + *result = true; + return; } // Se clicko fuori dai box - numbox = InWhichBox(pt); - if (numbox == -1) { + _ctx->numbox = InWhichBox(pt); + if (_ctx->numbox == -1) { // Trova il punto pi vicino dentro i box - dest = NearestPoint(pt); + _ctx->dest = NearestPoint(pt); // ???!?? - if (dest == pt) - dest = InvScanLine(pt); + if (_ctx->dest == pt) + _ctx->dest = InvScanLine(pt); - pt = dest; - numbox = InWhichBox(pt); + pt = _ctx->dest; + _ctx->numbox = InWhichBox(pt); } - RMBoxLoc *cur = theBoxes->GetBoxes(curLocation); + _ctx->cur = theBoxes->GetBoxes(curLocation); minpath = 0; status = STAND; bMovingWithoutMinpath = true; if (ScanLine(pt)) - GoTo(pt, cur->boxes[numbox].bReversed); + CORO_INVOKE_2(GoTo, pt, _ctx->cur->boxes[_ctx->numbox].bReversed); else if (FindPath(InWhichBox(m_pos), InWhichBox(pt))) { bMovingWithoutMinpath = false; minpath = 1; @@ -1609,22 +1636,30 @@ bool RMCharacter::Move(RMPoint pt) { // @@@ Questo caso se un hotspot dentro un box // ma non c' un path per arrivarci. Usiamo quindi // la invscanline per cercare un punto intorno - dest = InvScanLine(pt); - pt = dest; + _ctx->dest = InvScanLine(pt); + pt = _ctx->dest; if (ScanLine(pt)) - GoTo(pt,cur->boxes[numbox].bReversed); + CORO_INVOKE_2(GoTo, pt, _ctx->cur->boxes[_ctx->numbox].bReversed); else if (FindPath(InWhichBox(m_pos), InWhichBox(pt))) { bMovingWithoutMinpath = false; minpath = 1; pathcount = 1; pathend = pt; - return true; - } else - return false; + if (result) + *result = true; + } else { + if (result) + *result = false; + } + + return; } - return true; + if (result) + *result = true; + + CORO_END_CODE; } void RMCharacter::SetPosition(RMPoint pt, int newloc) { diff --git a/engines/tony/loc.h b/engines/tony/loc.h index 744dab3c25..f5826022e0 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -439,7 +439,7 @@ private: RMPoint Searching(char UP, char DOWN, char RIGHT, char LEFT, RMPoint punto); RMPoint NearestPoint(RMPoint punto); - void GoTo(RMPoint destcoord, bool bReversed=false); + void GoTo(CORO_PARAM, RMPoint destcoord, bool bReversed=false); short ScanLine(RMPoint punto); RMPoint InvScanLine(RMPoint punto); RMPoint NearestHotSpot(int sourcebox, int destbox); @@ -461,7 +461,7 @@ public: virtual bool RemoveThis(void); // Aggiorna la posizione del personaggio - void DoFrame(RMGfxTargetBuffer* bigBuf, int loc); + void DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc); // Overloading del Draw void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); @@ -470,13 +470,13 @@ public: bool EndOfPath() { return bEndOfPath; } // Cambia il pattern del personaggio per fermarlo - virtual void Stop(void); + virtual void Stop(CORO_PARAM); // Controlla se il personaggio si sta muovendo bool IsMoving() { return bMoving; } // Muove il personaggio a una certa posizione - bool Move(RMPoint pt); + void Move(CORO_PARAM, RMPoint pt, bool *result = NULL); // Posiziona il personaggio a una certa posizione SENZA farlo muovere void SetPosition(RMPoint pt, int newloc=-1); diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index 06adcd15b8..c3deae497b 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -125,20 +125,26 @@ void RMTony::Close(void) { m_ombra.Destroy(); } -void RMTony::DoFrame(RMGfxTargetBuffer *bigBuf, int curLoc) { +void RMTony::DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int curLoc) { + CORO_BEGIN_CONTEXT; + int time; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + if (!m_nInList && m_bShow) bigBuf->AddPrim(new RMGfxPrimitive(this)); SetSpeed(nCfgTonySpeed); // Esegue il movimento normale del personaggio - int time = _vm->GetTime(); + _ctx->time = _vm->GetTime(); do { m_nTimeLastStep += (1000 / 40); - RMCharacter::DoFrame(bigBuf, curLoc); + CORO_INVOKE_2(RMCharacter::DoFrame, bigBuf, curLoc); - } while (time > m_nTimeLastStep + (1000 / 40)); + } while (_ctx->time > m_nTimeLastStep + (1000 / 40)); // Controlla se siamo alla fine del percorso if (EndOfPath() && m_bActionPending) { @@ -148,6 +154,8 @@ void RMTony::DoFrame(RMGfxTargetBuffer *bigBuf, int curLoc) { if (m_bIsTalking || m_bIsStaticTalk) m_body.DoFrame(bigBuf, false); + + CORO_END_CODE; } void RMTony::Show(void) { @@ -192,7 +200,13 @@ void RMTony::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { } } -void RMTony::MoveAndDoAction(RMPoint dst, RMItem *item, int nAction, int nActionParm) { +void RMTony::MoveAndDoAction(CORO_PARAM, RMPoint dst, RMItem *item, int nAction, int nActionParm) { + CORO_BEGIN_CONTEXT; + bool result; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + // Fa il movimento normale, ma si ricorda se deve poi eseguire un azione if (item == NULL) { m_bActionPending = false; @@ -204,10 +218,13 @@ void RMTony::MoveAndDoAction(RMPoint dst, RMItem *item, int nAction, int nAction m_bActionPending = true; } - if (!RMCharacter::Move(dst)) { + CORO_INVOKE_2(RMCharacter::Move, dst, &_ctx->result); + if (!_ctx->result) { m_bActionPending = false; m_ActionItem = NULL; } + + CORO_END_CODE; } @@ -290,14 +307,14 @@ void RMTony::Stop(CORO_PARAM) { _ctx->pid = mpalQueryDoAction(21, m_ActionItem->MpalCode(), 0); if (_ctx->pid == INVALID_PID_VALUE) - RMCharacter::Stop(); + CORO_INVOKE_0(RMCharacter::Stop); else { bNeedToStop = false; // Se facciamo la OnWhichDirection, almeno dopo non dobbiamo fare la Stop() bMoving = false; CORO_INVOKE_2(g_scheduler->waitForSingleObject, _ctx->pid, INFINITE); // @@@ Mettere un assert dopo 10 secondi } } else { - RMCharacter::Stop(); + CORO_INVOKE_0(RMCharacter::Stop); } if (!m_bActionPending) diff --git a/engines/tony/tonychar.h b/engines/tony/tonychar.h index 98f247f688..050b39c0ca 100644 --- a/engines/tony/tonychar.h +++ b/engines/tony/tonychar.h @@ -385,7 +385,7 @@ public: void Close(void); // Fa un frame di Tony, aggiornando il movimento, etc - void DoFrame(RMGfxTargetBuffer *bigBuf, int curLoc); + void DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int curLoc); // Metodi di Draw, che controlla la variabile di show void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); @@ -395,7 +395,7 @@ public: void Hide(bool bShowOmbra = false); // Si muove e fa un azione, se necessario - void MoveAndDoAction(RMPoint dst, RMItem *item, int nAction, int nActionParm = 0); + void MoveAndDoAction(CORO_PARAM, RMPoint dst, RMItem *item, int nAction, int nActionParm = 0); // Ferma Tony (dalla parte giusta rispetto a un eventuale oggetto) virtual void Stop(CORO_PARAM); -- cgit v1.2.3 From 724deb6b84b8a5f5a3aa96adc2a512c962f7081a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 11 May 2012 08:44:50 +1000 Subject: TONY: Bugfixes for showing the credits screen. --- engines/tony/custom.cpp | 4 ++-- engines/tony/mpal/mpal.cpp | 4 ++-- engines/tony/mpal/mpal.h | 2 +- engines/tony/window.cpp | 28 ++++++++++++++++++++++++---- engines/tony/window.h | 1 + 5 files changed, 30 insertions(+), 9 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index c82d0fcd2b..5089914d88 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -2615,10 +2615,10 @@ DECLARE_CUSTOM_FUNCTION(DoCredits)(CORO_PARAM, uint32 nMsg, uint32 dwTime, uint3 for (_ctx->i = 0; _ctx->i < _ctx->msg->NumPeriods(); _ctx->i++) { _ctx->text[_ctx->i].SetInput(Input); - // Allineamento + // Alignment if ((*_ctx->msg)[_ctx->i][0] == '@') { _ctx->text[_ctx->i].SetAlignType(RMText::HCENTER, RMText::VTOP); - _ctx->text[_ctx->i].WriteText(_ctx->msg[_ctx->i][1], 3); + _ctx->text[_ctx->i].WriteText(&(*_ctx->msg)[_ctx->i][1], 3); _ctx->text[_ctx->i].SetPosition(RMPoint(414, 70 + _ctx->i * 26)); // 70 } else { _ctx->text[_ctx->i].SetAlignType(RMText::HLEFT,RMText::VTOP); diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index da736a138f..e82df11328 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -422,7 +422,7 @@ static int locGetOrderFromNum(uint32 nLoc) { static int msgGetOrderFromNum(uint32 nMsg) { int i; - LPMPALMSG msg=lpmmMsgs; + LPMPALMSG msg = lpmmMsgs; for (i = 0; i < nMsgs; i++, msg++) if (msg->wNum == nMsg) @@ -542,7 +542,7 @@ static char *DuplicateMessage(uint32 nMsgOrd) { origmsg = (const char *)GlobalLock(lpmmMsgs[nMsgOrd].hText); j = 0; - while (origmsg[j] != '\0' || origmsg[j+1] != '\0') + while (origmsg[j] != '\0' || origmsg[j + 1] != '\0') j++; j += 2; diff --git a/engines/tony/mpal/mpal.h b/engines/tony/mpal/mpal.h index 9a85f2df17..cd46219b57 100644 --- a/engines/tony/mpal/mpal.h +++ b/engines/tony/mpal/mpal.h @@ -566,7 +566,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; \****************************************************************************/ #define mpalQueryDoDialog(nDialog,nGroup) \ - mpalQueryHANDLE(MPQ_DO_DIALOG, (uint32)(nDialog),(uint32)(nGroup)) + mpalQueryDWORD(MPQ_DO_DIALOG, (uint32)(nDialog),(uint32)(nGroup)) /****************************************************************************\ diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index f68c612911..18dcfb7cb6 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -128,12 +128,32 @@ void RMWindow::WipeEffect(Common::Rect &rcBoundEllipse) { } void RMWindow::GetNewFrame(byte *lpBuf, Common::Rect *rcBoundEllipse) { - Common::Rect bounds = (rcBoundEllipse) ? *rcBoundEllipse : Common::Rect(0, 0, RM_SX, RM_SY); - - // Update a screen section - g_system->copyRectToScreen(lpBuf, RM_SX * 2, bounds.left, bounds.top, bounds.width(), bounds.height()); + if (rcBoundEllipse != NULL) { + // Circular wipe effect + GetNewFrameWipe(lpBuf, *rcBoundEllipse); + } else { + // Standard screen copy + g_system->copyRectToScreen(lpBuf, RM_SX * 2, 0, 0, RM_SX, RM_SY); + } } +/** + * Copies a section of the game frame in a circle bounded by the specified rectangle + */ +void RMWindow::GetNewFrameWipe(byte *lpBuf, Common::Rect &rcBoundEllipse) { + // Clear the screen + g_system->fillScreen(0); + + if (!rcBoundEllipse.isValidRect()) + return; + + // TODO: Do a proper circular wipe + for (int yp = rcBoundEllipse.top; yp < rcBoundEllipse.bottom; ++yp) { + const byte *pSrc = lpBuf + (yp * RM_SX * 2) + rcBoundEllipse.left * 2; + + g_system->copyRectToScreen(pSrc, RM_SX * 2, rcBoundEllipse.left, yp, rcBoundEllipse.width(), 1); + } +} /****************************************************************************\ * RMSnapshot Methods diff --git a/engines/tony/window.h b/engines/tony/window.h index 5190fc4d16..06f684a15b 100644 --- a/engines/tony/window.h +++ b/engines/tony/window.h @@ -97,6 +97,7 @@ protected: void CreateBWPrecalcTable(void); void WipeEffect(Common::Rect &rcBoundEllipse); + void GetNewFrameWipe(byte *lpBuf, Common::Rect &rcBoundEllipse); public: RMWindow(); -- cgit v1.2.3 From 50153aba8832d8707031df2219512515797d93ce Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 11 May 2012 23:08:27 +1000 Subject: COMMON: Merged the Tinsel & Tony Coroutine schedulers into Common --- engines/tinsel/coroutine.h | 282 --------------------------------------------- 1 file changed, 282 deletions(-) delete mode 100644 engines/tinsel/coroutine.h (limited to 'engines') diff --git a/engines/tinsel/coroutine.h b/engines/tinsel/coroutine.h deleted file mode 100644 index 5bcf1149d9..0000000000 --- a/engines/tinsel/coroutine.h +++ /dev/null @@ -1,282 +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. - * - */ - -#ifndef TINSEL_COROUTINE_H -#define TINSEL_COROUTINE_H - -#include "common/scummsys.h" -#include "common/util.h" // for SCUMMVM_CURRENT_FUNCTION - -namespace Tinsel { - -/** - * @defgroup TinselCoroutines Coroutine support for Tinsel - * - * The following is loosely based on an article by Simon Tatham: - * . - * However, many improvements and tweaks have been made, in particular - * by taking advantage of C++ features not available in C. - * - * Why is this code here? Well, the Tinsel engine apparently used - * setjmp/longjmp based coroutines as a core tool from the start, and - * so they are deeply ingrained into the whole code base. When we - * started to get Tinsel ready for ScummVM, we had to deal with that. - * It soon got clear that we could not simply rewrite the code to work - * without some form of coroutines. While possible in principle, it - * would have meant a major restructuring of the entire code base, a - * rather daunting task. Also, it would have very likely introduced - * tons of regressons. - * - * So instead of getting rid of the coroutines, we chose to implement - * them in an alternate way, using Simon Tatham's trick as described - * above. While the trick is dirty, the result seems to be clear enough, - * we hope; plus, it allowed us to stay relatively close to the - * original structure of the code, which made it easier to avoid - * regressions, and will be helpful in the future when comparing things - * against the original code base. - */ -//@{ - - -// Enable this macro to enable some debugging support in the coroutine code. -//#define COROUTINE_DEBUG 1 - -/** - * The core of any coroutine context which captures the 'state' of a coroutine. - * Private use only. - */ -struct CoroBaseContext { - int _line; - int _sleep; - CoroBaseContext *_subctx; -#if COROUTINE_DEBUG - const char *_funcName; -#endif - CoroBaseContext(const char *func); - ~CoroBaseContext(); -}; - -typedef CoroBaseContext *CoroContext; - - -// FIXME: Document this! -extern CoroContext nullContext; - -/** - * Wrapper class which holds a pointer to a pointer to a CoroBaseContext. - * The interesting part is the destructor, which kills the context being held, - * but ONLY if the _sleep val of that context is zero. This way, a coroutine - * can just 'return' w/o having to worry about freeing the allocated context - * (in Simon Tatham's original code, one had to use a special macro to - * return from a coroutine). - */ -class CoroContextHolder { - CoroContext &_ctx; -public: - CoroContextHolder(CoroContext &ctx) : _ctx(ctx) { - assert(ctx); - assert(ctx->_sleep >= 0); - ctx->_sleep = 0; - } - ~CoroContextHolder() { - if (_ctx && _ctx->_sleep == 0) { - delete _ctx; - _ctx = 0; - } - } -}; - - -#define CORO_PARAM CoroContext &coroParam - - -/** - * Begin the declaration of a coroutine context. - * This allows declaring variables which are 'persistent' during the - * lifetime of the coroutine. An example use would be: - * - * CORO_BEGIN_CONTEXT; - * int var; - * char *foo; - * CORO_END_CONTEXT(_ctx); - * - * It is not possible to initialize variables here, due to the way this - * macro is implemented. Furthermore, to use the variables declared in - * the coroutine context, you have to access them via the context variable - * name that was specified as parameter to CORO_END_CONTEXT, e.g. - * _ctx->var = 0; - * - * @see CORO_END_CONTEXT - * - * @note We declare a variable 'DUMMY' to allow the user to specify an 'empty' - * context, and so compilers won't complain about ";" following the macro. - */ -#define CORO_BEGIN_CONTEXT \ - struct CoroContextTag : CoroBaseContext { \ - CoroContextTag() : CoroBaseContext(SCUMMVM_CURRENT_FUNCTION) {} \ - int DUMMY - -/** - * End the declaration of a coroutine context. - * @param x name of the coroutine context - * @see CORO_BEGIN_CONTEXT - */ -#define CORO_END_CONTEXT(x) } *x = (CoroContextTag *)coroParam - -/** - * Begin the code section of a coroutine. - * @param x name of the coroutine context - * @see CORO_BEGIN_CODE - */ -#define CORO_BEGIN_CODE(x) \ - if (&coroParam == &nullContext) assert(!nullContext);\ - if (!x) {coroParam = x = new CoroContextTag();}\ - CoroContextHolder tmpHolder(coroParam);\ - switch (coroParam->_line) { case 0:; - -/** - * End the code section of a coroutine. - * @see CORO_END_CODE - */ -#define CORO_END_CODE \ - if (&coroParam == &nullContext) { \ - delete nullContext; \ - nullContext = NULL; \ - } \ - } - -/** - * Sleep for the specified number of scheduler cycles. - */ -#define CORO_SLEEP(delay) do {\ - coroParam->_line = __LINE__;\ - coroParam->_sleep = delay;\ - assert(&coroParam != &nullContext);\ - return; case __LINE__:;\ - } while (0) - -#define CORO_GIVE_WAY do { g_scheduler->giveWay(); CORO_SLEEP(1); } while (0) -#define CORO_RESCHEDULE do { g_scheduler->reschedule(); CORO_SLEEP(1); } while (0) - -/** - * Stop the currently running coroutine and all calling coroutines. - * - * This sets _sleep to -1 rather than 0 so that the context doesn't get - * deleted by CoroContextHolder, since we want CORO_INVOKE_ARGS to - * propogate the _sleep value and return immediately (the scheduler will - * then delete the entire coroutine's state, including all subcontexts). - */ -#define CORO_KILL_SELF() \ - do { if (&coroParam != &nullContext) { coroParam->_sleep = -1; } return; } while (0) - - -/** - * This macro is to be used in conjunction with CORO_INVOKE_ARGS and - * similar macros for calling coroutines-enabled subroutines. - */ -#define CORO_SUBCTX coroParam->_subctx - -/** - * Invoke another coroutine. - * - * If the subcontext still exists after the coroutine is invoked, it has - * either yielded/slept or killed itself, and so we copy the _sleep value - * to our own context and return (execution will continue at the case - * statement below, where we loop and call the coroutine again). - * If the subcontext is null, the coroutine ended normally, and we can - * simply break out of the loop and continue execution. - * - * @param subCoro name of the coroutine-enabled function to invoke - * @param ARGS list of arguments to pass to subCoro - * - * @note ARGS must be surrounded by parentheses, and the first argument - * in this list must always be CORO_SUBCTX. For example, the - * regular function call - * myFunc(a, b); - * becomes the following: - * CORO_INVOKE_ARGS(myFunc, (CORO_SUBCTX, a, b)); - */ -#define CORO_INVOKE_ARGS(subCoro, ARGS) \ - do {\ - coroParam->_line = __LINE__;\ - coroParam->_subctx = 0;\ - do {\ - subCoro ARGS;\ - if (!coroParam->_subctx) break;\ - coroParam->_sleep = coroParam->_subctx->_sleep;\ - assert(&coroParam != &nullContext);\ - return; case __LINE__:;\ - } while (1);\ - } while (0) - -/** - * Invoke another coroutine. Similar to CORO_INVOKE_ARGS, - * but allows specifying a return value which is returned - * if invoked coroutine yields (thus causing the current - * coroutine to yield, too). - */ -#define CORO_INVOKE_ARGS_V(subCoro, RESULT, ARGS) \ - do {\ - coroParam->_line = __LINE__;\ - coroParam->_subctx = 0;\ - do {\ - subCoro ARGS;\ - if (!coroParam->_subctx) break;\ - coroParam->_sleep = coroParam->_subctx->_sleep;\ - assert(&coroParam != &nullContext);\ - return RESULT; case __LINE__:;\ - } while (1);\ - } while (0) - -/** - * Convenience wrapper for CORO_INVOKE_ARGS for invoking a coroutine - * with no parameters. - */ -#define CORO_INVOKE_0(subCoroutine) \ - CORO_INVOKE_ARGS(subCoroutine,(CORO_SUBCTX)) - -/** - * Convenience wrapper for CORO_INVOKE_ARGS for invoking a coroutine - * with one parameter. - */ -#define CORO_INVOKE_1(subCoroutine, a0) \ - CORO_INVOKE_ARGS(subCoroutine,(CORO_SUBCTX,a0)) - -/** - * Convenience wrapper for CORO_INVOKE_ARGS for invoking a coroutine - * with two parameters. - */ -#define CORO_INVOKE_2(subCoroutine, a0,a1) \ - CORO_INVOKE_ARGS(subCoroutine,(CORO_SUBCTX,a0,a1)) - -/** - * Convenience wrapper for CORO_INVOKE_ARGS for invoking a coroutine - * with three parameters. - */ -#define CORO_INVOKE_3(subCoroutine, a0,a1,a2) \ - CORO_INVOKE_ARGS(subCoroutine,(CORO_SUBCTX,a0,a1,a2)) - -//@} - -} // End of namespace Tinsel - -#endif // TINSEL_COROUTINE_H -- cgit v1.2.3 From 64669234b2fdb2375d23157232d6104e6d8967d2 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 11 May 2012 23:10:12 +1000 Subject: TINSEL: Refactored Tinsel engine to use the Common coroutine scheduler --- engines/tinsel/actors.cpp | 12 +- engines/tinsel/background.h | 2 +- engines/tinsel/bg.cpp | 6 +- engines/tinsel/bmv.cpp | 4 +- engines/tinsel/bmv.h | 2 +- engines/tinsel/coroutine.cpp | 82 -------- engines/tinsel/dialogs.cpp | 20 +- engines/tinsel/drives.cpp | 6 +- engines/tinsel/drives.h | 2 +- engines/tinsel/effect.cpp | 2 +- engines/tinsel/events.cpp | 18 +- engines/tinsel/events.h | 4 +- engines/tinsel/faders.cpp | 4 +- engines/tinsel/handle.cpp | 2 +- engines/tinsel/module.mk | 1 - engines/tinsel/move.cpp | 4 +- engines/tinsel/pcode.cpp | 20 +- engines/tinsel/pcode.h | 12 +- engines/tinsel/pdisplay.cpp | 6 +- engines/tinsel/play.cpp | 16 +- engines/tinsel/play.h | 2 +- engines/tinsel/polygons.cpp | 4 +- engines/tinsel/rince.cpp | 8 +- engines/tinsel/rince.h | 4 +- engines/tinsel/savescn.cpp | 10 +- engines/tinsel/scene.cpp | 20 +- engines/tinsel/sched.cpp | 487 +------------------------------------------ engines/tinsel/sched.h | 93 +-------- engines/tinsel/text.h | 2 +- engines/tinsel/tinlib.cpp | 12 +- engines/tinsel/tinsel.cpp | 33 ++- engines/tinsel/token.cpp | 14 +- 32 files changed, 137 insertions(+), 777 deletions(-) delete mode 100644 engines/tinsel/coroutine.cpp (limited to 'engines') diff --git a/engines/tinsel/actors.cpp b/engines/tinsel/actors.cpp index acacd89667..a784ff5788 100644 --- a/engines/tinsel/actors.cpp +++ b/engines/tinsel/actors.cpp @@ -340,7 +340,7 @@ void RestoreActorProcess(int id, INT_CONTEXT *pic, bool savegameFlag) { if (savegameFlag) pic->resumeState = RES_SAVEGAME; - g_scheduler->createProcess(PID_TCODE, ActorRestoredProcess, &r, sizeof(r)); + CoroScheduler.createProcess(PID_TCODE, ActorRestoredProcess, &r, sizeof(r)); } /** @@ -358,7 +358,7 @@ void ActorEvent(int ano, TINSEL_EVENT event, PLR_EVENT be) { atp.event = event; atp.bev = be; atp.pic = NULL; - g_scheduler->createProcess(PID_TCODE, ActorTinselProcess, &atp, sizeof(atp)); + CoroScheduler.createProcess(PID_TCODE, ActorTinselProcess, &atp, sizeof(atp)); } } @@ -369,7 +369,7 @@ void ActorEvent(CORO_PARAM, int ano, TINSEL_EVENT tEvent, bool bWait, int myEsca ATP_INIT atp; int index; CORO_BEGIN_CONTEXT; - PPROCESS pProc; + Common::PPROCESS pProc; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -389,7 +389,7 @@ void ActorEvent(CORO_PARAM, int ano, TINSEL_EVENT tEvent, bool bWait, int myEsca myEscape); if (atp.pic != NULL) { - _ctx->pProc = g_scheduler->createProcess(PID_TCODE, ActorTinselProcess, &atp, sizeof(atp)); + _ctx->pProc = CoroScheduler.createProcess(PID_TCODE, ActorTinselProcess, &atp, sizeof(atp)); AttachInterpret(atp.pic, _ctx->pProc); if (bWait) @@ -474,8 +474,8 @@ void StartTaggedActors(SCNHANDLE ah, int numActors, bool bRunScript) { // Run actor's script for this scene if (bRunScript) { // Send in reverse order - they get swapped round in the scheduler - ActorEvent(nullContext, taggedActors[i].id, SHOWEVENT, false, 0); - ActorEvent(nullContext, taggedActors[i].id, STARTUP, false, 0); + ActorEvent(Common::nullContext, taggedActors[i].id, SHOWEVENT, false, 0); + ActorEvent(Common::nullContext, taggedActors[i].id, STARTUP, false, 0); } } } diff --git a/engines/tinsel/background.h b/engines/tinsel/background.h index 34f1bd6dd2..cfa3998eda 100644 --- a/engines/tinsel/background.h +++ b/engines/tinsel/background.h @@ -24,9 +24,9 @@ #ifndef TINSEL_BACKGND_H // prevent multiple includes #define TINSEL_BACKGND_H +#include "common/coroutines.h" #include "common/frac.h" #include "common/rect.h" -#include "tinsel/coroutine.h" #include "tinsel/dw.h" // for SCNHANDLE #include "tinsel/palette.h" // palette definitions diff --git a/engines/tinsel/bg.cpp b/engines/tinsel/bg.cpp index 72ba05f0b9..a3e21a8227 100644 --- a/engines/tinsel/bg.cpp +++ b/engines/tinsel/bg.cpp @@ -255,17 +255,17 @@ void StartupBackground(CORO_PARAM, SCNHANDLE hFilm) { g_BGspeed = ONE_SECOND / FROM_LE_32(pfilm->frate); // Start display process for each reel in the film - g_scheduler->createProcess(PID_REEL, BGmainProcess, &pfilm->reels[0], sizeof(FREEL)); + CoroScheduler.createProcess(PID_REEL, BGmainProcess, &pfilm->reels[0], sizeof(FREEL)); if (TinselV0) { for (uint i = 1; i < FROM_LE_32(pfilm->numreels); ++i) - g_scheduler->createProcess(PID_REEL, BGotherProcess, &pfilm->reels[i], sizeof(FREEL)); + CoroScheduler.createProcess(PID_REEL, BGotherProcess, &pfilm->reels[i], sizeof(FREEL)); } if (g_pBG[0] == NULL) ControlStartOff(); - if (TinselV2 && (coroParam != nullContext)) + if (TinselV2 && (coroParam != Common::nullContext)) CORO_GIVE_WAY; CORO_END_CODE; diff --git a/engines/tinsel/bmv.cpp b/engines/tinsel/bmv.cpp index 24d47b920f..438fd52a81 100644 --- a/engines/tinsel/bmv.cpp +++ b/engines/tinsel/bmv.cpp @@ -529,7 +529,7 @@ int BMVPlayer::MovieCommand(char cmd, int commandOffset) { if (cmd & CD_PRINT) { PRINT_CMD *pCmd = (PRINT_CMD *)(bigBuffer + commandOffset); - MovieText(nullContext, (int16)READ_LE_UINT16(&pCmd->stringId), + MovieText(Common::nullContext, (int16)READ_LE_UINT16(&pCmd->stringId), (int16)READ_LE_UINT16(&pCmd->x), (int16)READ_LE_UINT16(&pCmd->y), pCmd->fontId, @@ -542,7 +542,7 @@ int BMVPlayer::MovieCommand(char cmd, int commandOffset) { TALK_CMD *pCmd = (TALK_CMD *)(bigBuffer + commandOffset); talkColor = TINSEL_RGB(pCmd->r, pCmd->g, pCmd->b); - MovieText(nullContext, (int16)READ_LE_UINT16(&pCmd->stringId), + MovieText(Common::nullContext, (int16)READ_LE_UINT16(&pCmd->stringId), (int16)READ_LE_UINT16(&pCmd->x), (int16)READ_LE_UINT16(&pCmd->y), 0, diff --git a/engines/tinsel/bmv.h b/engines/tinsel/bmv.h index eadf65c3aa..fa254ed26d 100644 --- a/engines/tinsel/bmv.h +++ b/engines/tinsel/bmv.h @@ -24,12 +24,12 @@ #ifndef TINSEL_BMV_H #define TINSEL_BMV_H +#include "common/coroutines.h" #include "common/file.h" #include "audio/audiostream.h" #include "audio/mixer.h" -#include "tinsel/coroutine.h" #include "tinsel/object.h" #include "tinsel/palette.h" diff --git a/engines/tinsel/coroutine.cpp b/engines/tinsel/coroutine.cpp deleted file mode 100644 index ef0097f043..0000000000 --- a/engines/tinsel/coroutine.cpp +++ /dev/null @@ -1,82 +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. - */ - -#include "tinsel/coroutine.h" -#include "common/hashmap.h" -#include "common/hash-str.h" - -namespace Tinsel { - - -CoroContext nullContext = NULL; // FIXME: Avoid non-const global vars - - -#if COROUTINE_DEBUG -namespace { -static int s_coroCount = 0; - -typedef Common::HashMap CoroHashMap; -static CoroHashMap *s_coroFuncs = 0; - -static void changeCoroStats(const char *func, int change) { - if (!s_coroFuncs) - s_coroFuncs = new CoroHashMap(); - - (*s_coroFuncs)[func] += change; -} - -static void displayCoroStats() { - debug("%d active coros", s_coroCount); - - // Loop over s_coroFuncs and print info about active coros - if (!s_coroFuncs) - return; - for (CoroHashMap::const_iterator it = s_coroFuncs->begin(); - it != s_coroFuncs->end(); ++it) { - if (it->_value != 0) - debug(" %3d x %s", it->_value, it->_key.c_str()); - } -} - -} -#endif - -CoroBaseContext::CoroBaseContext(const char *func) - : _line(0), _sleep(0), _subctx(0) { -#if COROUTINE_DEBUG - _funcName = func; - changeCoroStats(_funcName, +1); - s_coroCount++; -#endif -} - -CoroBaseContext::~CoroBaseContext() { -#if COROUTINE_DEBUG - s_coroCount--; - changeCoroStats(_funcName, -1); - debug("Deleting coro in %s at %p (subctx %p)", - _funcName, (void *)this, (void *)_subctx); - displayCoroStats(); -#endif - delete _subctx; -} - -} // End of namespace Tinsel diff --git a/engines/tinsel/dialogs.cpp b/engines/tinsel/dialogs.cpp index 5396e47566..fbe9e8d1f6 100644 --- a/engines/tinsel/dialogs.cpp +++ b/engines/tinsel/dialogs.cpp @@ -1075,7 +1075,7 @@ static void PrimeSceneHopper() { uint32 vSize; // Open the file (it's on the CD) - CdCD(nullContext); + CdCD(Common::nullContext); if (!f.open(HOPPER_FILENAME)) error(CANNOT_FIND_FILE, HOPPER_FILENAME); @@ -1191,13 +1191,13 @@ static void HopAction() { debugC(DEBUG_BASIC, kTinselDebugAnimations, "Scene hopper chose scene %xh,%d\n", hScene, eNumber); if (FROM_LE_32(pEntry->flags) & fCall) { - SaveScene(nullContext); - NewScene(nullContext, g_pChosenScene->hScene, pEntry->eNumber, TRANS_FADE); + SaveScene(Common::nullContext); + NewScene(Common::nullContext, g_pChosenScene->hScene, pEntry->eNumber, TRANS_FADE); } else if (FROM_LE_32(pEntry->flags) & fHook) HookScene(hScene, eNumber, TRANS_FADE); else - NewScene(nullContext, hScene, eNumber, TRANS_CUT); + NewScene(Common::nullContext, hScene, eNumber, TRANS_CUT); } /**************************************************************************/ @@ -1406,13 +1406,13 @@ static void InvTinselEvent(INV_OBJECT *pinvo, TINSEL_EVENT event, PLR_EVENT be, return; g_GlitterIndex = index; - g_scheduler->createProcess(PID_TCODE, ObjectProcess, &to, sizeof(to)); + CoroScheduler.createProcess(PID_TCODE, ObjectProcess, &to, sizeof(to)); } extern void ObjectEvent(CORO_PARAM, int objId, TINSEL_EVENT event, bool bWait, int myEscape, bool *result) { // COROUTINE CORO_BEGIN_CONTEXT; - PROCESS *pProc; + Common::PROCESS *pProc; INV_OBJECT *pInvo; OP_INIT op; CORO_END_CONTEXT(_ctx); @@ -1428,7 +1428,7 @@ extern void ObjectEvent(CORO_PARAM, int objId, TINSEL_EVENT event, bool bWait, i _ctx->op.event = event; _ctx->op.myEscape = myEscape; - g_scheduler->createProcess(PID_TCODE, ObjectProcess, &_ctx->op, sizeof(_ctx->op)); + CoroScheduler.createProcess(PID_TCODE, ObjectProcess, &_ctx->op, sizeof(_ctx->op)); if (bWait) CORO_INVOKE_2(WaitInterpret, _ctx->pProc, result); @@ -3540,9 +3540,9 @@ extern void ConvAction(int index) { } if (g_thisConvPoly != NOPOLY) - PolygonEvent(nullContext, g_thisConvPoly, CONVERSE, 0, false, 0); + PolygonEvent(Common::nullContext, g_thisConvPoly, CONVERSE, 0, false, 0); else - ActorEvent(nullContext, g_thisConvActor, CONVERSE, false, 0); + ActorEvent(Common::nullContext, g_thisConvActor, CONVERSE, false, 0); } } @@ -5128,7 +5128,7 @@ static void InvPickup(int index) { if (TinselV2) InvPutDown(index); else - g_scheduler->createProcess(PID_TCODE, InvPdProcess, &index, sizeof(index)); + CoroScheduler.createProcess(PID_TCODE, InvPdProcess, &index, sizeof(index)); } } } diff --git a/engines/tinsel/drives.cpp b/engines/tinsel/drives.cpp index d815fd165d..5c4b939e4e 100644 --- a/engines/tinsel/drives.cpp +++ b/engines/tinsel/drives.cpp @@ -48,13 +48,13 @@ void CdCD(CORO_PARAM) { CORO_BEGIN_CODE(_ctx); while (g_bChangingCD) { - if (g_scheduler->getCurrentProcess()) { - // FIXME: CdCD gets passed a nullContext in RegisterGlobals() and + if (CoroScheduler.getCurrentProcess()) { + // FIXME: CdCD gets passed a Common::nullContext in RegisterGlobals() and // PrimeSceneHopper(), because I didn't know how to get a proper // context without converting the whole calling stack to CORO'd // functions. If these functions really get called while a CD // change is requested, this needs to be resolved. - if (coroParam == nullContext) + if (coroParam == Common::nullContext) error("CdCD needs context"); CORO_SLEEP(1); } else diff --git a/engines/tinsel/drives.h b/engines/tinsel/drives.h index 907071d2f8..9e97b92fa5 100644 --- a/engines/tinsel/drives.h +++ b/engines/tinsel/drives.h @@ -24,9 +24,9 @@ #ifndef TINSEL_DRIVES_H #define TINSEL_DRIVES_H +#include "common/coroutines.h" #include "common/stream.h" #include "tinsel/dw.h" -#include "tinsel/coroutine.h" namespace Tinsel { diff --git a/engines/tinsel/effect.cpp b/engines/tinsel/effect.cpp index 22027b0f02..f5adb63c2b 100644 --- a/engines/tinsel/effect.cpp +++ b/engines/tinsel/effect.cpp @@ -108,7 +108,7 @@ static void FettleEffectPolys(int x, int y, int index, PMOVER pActor) { epi.hEpoly = hPoly; epi.pMover = pActor; epi.index = index; - g_scheduler->createProcess(PID_TCODE, EffectProcess, &epi, sizeof(epi)); + CoroScheduler.createProcess(PID_TCODE, EffectProcess, &epi, sizeof(epi)); } } } diff --git a/engines/tinsel/events.cpp b/engines/tinsel/events.cpp index 74454c5f2a..1aa4d34227 100644 --- a/engines/tinsel/events.cpp +++ b/engines/tinsel/events.cpp @@ -22,10 +22,10 @@ * Also provides a couple of utility functions. */ +#include "common/coroutines.h" #include "tinsel/actors.h" #include "tinsel/background.h" #include "tinsel/config.h" -#include "tinsel/coroutine.h" #include "tinsel/cursor.h" #include "tinsel/dw.h" #include "tinsel/events.h" @@ -276,7 +276,7 @@ static void WalkProcess(CORO_PARAM, const void *param) { void WalkTo(int x, int y) { WP_INIT to = { x, y }; - g_scheduler->createProcess(PID_TCODE, WalkProcess, &to, sizeof(to)); + CoroScheduler.createProcess(PID_TCODE, WalkProcess, &to, sizeof(to)); } /** @@ -295,7 +295,7 @@ static void ProcessUserEvent(TINSEL_EVENT uEvent, const Common::Point &coOrds, P if ((actor = GetTaggedActor()) != 0) { // Event for a tagged actor if (TinselV2) - ActorEvent(nullContext, actor, uEvent, false, 0); + ActorEvent(Common::nullContext, actor, uEvent, false, 0); else ActorEvent(actor, uEvent, be); } else if ((hPoly = GetTaggedPoly()) != NOPOLY) { @@ -303,7 +303,7 @@ static void ProcessUserEvent(TINSEL_EVENT uEvent, const Common::Point &coOrds, P if (!TinselV2) RunPolyTinselCode(hPoly, uEvent, be, false); else if (uEvent != PROV_WALKTO) - PolygonEvent(nullContext, hPoly, uEvent, 0, false, 0); + PolygonEvent(Common::nullContext, hPoly, uEvent, 0, false, 0); } else { GetCursorXY(&aniX, &aniY, true); @@ -312,7 +312,7 @@ static void ProcessUserEvent(TINSEL_EVENT uEvent, const Common::Point &coOrds, P if ((hPoly = InPolygon(aniX, aniY, TAG)) != NOPOLY || (!TinselV2 && ((hPoly = InPolygon(aniX, aniY, EXIT)) != NOPOLY))) { if (TinselV2 && (uEvent != PROV_WALKTO)) - PolygonEvent(nullContext, hPoly, uEvent, 0, false, 0); + PolygonEvent(Common::nullContext, hPoly, uEvent, 0, false, 0); else if (!TinselV2) RunPolyTinselCode(hPoly, uEvent, be, false); } else if ((uEvent == PROV_WALKTO) || (uEvent == WALKTO)) { @@ -604,7 +604,7 @@ void PolyTinselProcess(CORO_PARAM, const void *param) { void PolygonEvent(CORO_PARAM, HPOLYGON hPoly, TINSEL_EVENT tEvent, int actor, bool bWait, int myEscape, bool *result) { CORO_BEGIN_CONTEXT; - PPROCESS pProc; + Common::PPROCESS pProc; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -623,7 +623,7 @@ void PolygonEvent(CORO_PARAM, HPOLYGON hPoly, TINSEL_EVENT tEvent, int actor, bo NULL, // No Object myEscape); if (to.pic != NULL) { - _ctx->pProc = g_scheduler->createProcess(PID_TCODE, PolyTinselProcess, &to, sizeof(to)); + _ctx->pProc = CoroScheduler.createProcess(PID_TCODE, PolyTinselProcess, &to, sizeof(to)); AttachInterpret(to.pic, _ctx->pProc); if (bWait) @@ -640,14 +640,14 @@ void RunPolyTinselCode(HPOLYGON hPoly, TINSEL_EVENT event, PLR_EVENT be, bool tc PTP_INIT to = { hPoly, event, be, tc, 0, NULL }; assert(!TinselV2); - g_scheduler->createProcess(PID_TCODE, PolyTinselProcess, &to, sizeof(to)); + CoroScheduler.createProcess(PID_TCODE, PolyTinselProcess, &to, sizeof(to)); } void effRunPolyTinselCode(HPOLYGON hPoly, TINSEL_EVENT event, int actor) { PTP_INIT to = { hPoly, event, PLR_NOEVENT, false, actor, NULL }; assert(!TinselV2); - g_scheduler->createProcess(PID_TCODE, PolyTinselProcess, &to, sizeof(to)); + CoroScheduler.createProcess(PID_TCODE, PolyTinselProcess, &to, sizeof(to)); } /** diff --git a/engines/tinsel/events.h b/engines/tinsel/events.h index f2b4d7f663..cdf5ae2ae4 100644 --- a/engines/tinsel/events.h +++ b/engines/tinsel/events.h @@ -24,9 +24,9 @@ #ifndef TINSEL_EVENTS_H #define TINSEL_EVENTS_H -#include "tinsel/dw.h" -#include "tinsel/coroutine.h" +#include "common/coroutines.h" #include "common/rect.h" +#include "tinsel/dw.h" namespace Tinsel { diff --git a/engines/tinsel/faders.cpp b/engines/tinsel/faders.cpp index 86d117af81..c1574ff963 100644 --- a/engines/tinsel/faders.cpp +++ b/engines/tinsel/faders.cpp @@ -145,7 +145,7 @@ static void Fader(const long multTable[], SCNHANDLE noFadeTable[]) { if (TinselV2) { // The is only ever one cuncurrent fade // But this could be a fade out and the fade in is still going! - g_scheduler->killMatchingProcess(PID_FADER); + CoroScheduler.killMatchingProcess(PID_FADER); NoFadingPalettes(); } @@ -176,7 +176,7 @@ static void Fader(const long multTable[], SCNHANDLE noFadeTable[]) { fade.pPalQ = pPal; // create a fader process for this palette - g_scheduler->createProcess(PID_FADER, FadeProcess, (void *)&fade, sizeof(FADE)); + CoroScheduler.createProcess(PID_FADER, FadeProcess, (void *)&fade, sizeof(FADE)); } } } diff --git a/engines/tinsel/handle.cpp b/engines/tinsel/handle.cpp index e31b2141f5..c3089db990 100644 --- a/engines/tinsel/handle.cpp +++ b/engines/tinsel/handle.cpp @@ -361,7 +361,7 @@ byte *LockMem(SCNHANDLE offset) { if (TinselV2) { SetCD(pH->flags2 & fAllCds); - CdCD(nullContext); + CdCD(Common::nullContext); } LoadFile(pH); } diff --git a/engines/tinsel/module.mk b/engines/tinsel/module.mk index 2ab94b830a..3485bac74b 100644 --- a/engines/tinsel/module.mk +++ b/engines/tinsel/module.mk @@ -9,7 +9,6 @@ MODULE_OBJS := \ bmv.o \ cliprect.o \ config.o \ - coroutine.o \ cursor.o \ debugger.o \ detection.o \ diff --git a/engines/tinsel/move.cpp b/engines/tinsel/move.cpp index bb49e59fe7..275b6006f5 100644 --- a/engines/tinsel/move.cpp +++ b/engines/tinsel/move.cpp @@ -1299,14 +1299,14 @@ static void SetOffWithinNodePath(PMOVER pMover, HPOLYGON StartPath, HPOLYGON Des */ void SSetActorDest(PMOVER pActor) { if (pActor->UtargetX != -1 && pActor->UtargetY != -1) { - Stand(nullContext, pActor->actorID, pActor->objX, pActor->objY, 0); + Stand(Common::nullContext, pActor->actorID, pActor->objX, pActor->objY, 0); if (pActor->UtargetX != -1 && pActor->UtargetY != -1) { SetActorDest(pActor, pActor->UtargetX, pActor->UtargetY, pActor->bIgPath, 0); } } else { - Stand(nullContext, pActor->actorID, pActor->objX, pActor->objY, 0); + Stand(Common::nullContext, pActor->actorID, pActor->objX, pActor->objY, 0); } } diff --git a/engines/tinsel/pcode.cpp b/engines/tinsel/pcode.cpp index 145a6a8e5d..60f04b47fd 100644 --- a/engines/tinsel/pcode.cpp +++ b/engines/tinsel/pcode.cpp @@ -243,13 +243,13 @@ static INT_CONTEXT *AllocateInterpretContext(GSORT gsort) { for (i = 0, pic = g_icList; i < NUM_INTERPRET; i++, pic++) { if (pic->GSort == GS_NONE) { - pic->pProc = g_scheduler->getCurrentProcess(); + pic->pProc = CoroScheduler.getCurrentProcess(); pic->GSort = gsort; return pic; } #ifdef DEBUG else { - if (pic->pProc == g_scheduler->getCurrentProcess()) + if (pic->pProc == CoroScheduler.getCurrentProcess()) error("Found unreleased interpret context"); } #endif @@ -277,7 +277,7 @@ static void FreeWaitCheck(PINT_CONTEXT pic, bool bVoluntary) { if ((g_icList + i)->waitNumber1 == pic->waitNumber2) { (g_icList + i)->waitNumber1 = 0; (g_icList + i)->resumeCode = bVoluntary ? RES_FINISHED : RES_CUTSHORT; - g_scheduler->reschedule((g_icList + i)->pProc); + CoroScheduler.reschedule((g_icList + i)->pProc); break; } } @@ -301,7 +301,7 @@ static void FreeInterpretContextPi(INT_CONTEXT *pic) { * Ensures that interpret contexts don't get lost when an Interpret() * call doesn't complete. */ -void FreeInterpretContextPr(PROCESS *pProc) { +void FreeInterpretContextPr(Common::PROCESS *pProc) { INT_CONTEXT *pic; int i; @@ -393,7 +393,7 @@ INT_CONTEXT *RestoreInterpretContext(INT_CONTEXT *ric) { ic = AllocateInterpretContext(GS_NONE); // Sort will soon be overridden memcpy(ic, ric, sizeof(INT_CONTEXT)); - ic->pProc = g_scheduler->getCurrentProcess(); + ic->pProc = CoroScheduler.getCurrentProcess(); ic->resumeState = RES_1; LockCode(ic); @@ -422,7 +422,7 @@ void RegisterGlobals(int num) { if (g_icList == NULL) { error("Cannot allocate memory for interpret contexts"); } - g_scheduler->setResourceCallback(FreeInterpretContextPr); + CoroScheduler.setResourceCallback(FreeInterpretContextPr); } else { // Check size is still the same assert(g_numGlobals == num); @@ -433,7 +433,7 @@ void RegisterGlobals(int num) { if (TinselV2) { // read initial values - CdCD(nullContext); + CdCD(Common::nullContext); Common::File f; if (!f.open(GLOBALS_FILENAME)) @@ -839,7 +839,7 @@ void Interpret(CORO_PARAM, INT_CONTEXT *ic) { * Associates an interpret context with the * process that will run it. */ -void AttachInterpret(INT_CONTEXT *pic, PROCESS *pProc) { +void AttachInterpret(INT_CONTEXT *pic, Common::PROCESS *pProc) { // Attach the process which is using this context pic->pProc = pProc; } @@ -869,9 +869,9 @@ static uint32 UniqueWaitNumber() { /** * WaitInterpret */ -void WaitInterpret(CORO_PARAM, PPROCESS pWaitProc, bool *result) { +void WaitInterpret(CORO_PARAM, Common::PPROCESS pWaitProc, bool *result) { int i; - PPROCESS currentProcess = g_scheduler->getCurrentProcess(); + Common::PPROCESS currentProcess = CoroScheduler.getCurrentProcess(); assert(currentProcess); assert(currentProcess != pWaitProc); if (result) *result = false; diff --git a/engines/tinsel/pcode.h b/engines/tinsel/pcode.h index 5d16dae432..4980fc6ed9 100644 --- a/engines/tinsel/pcode.h +++ b/engines/tinsel/pcode.h @@ -25,7 +25,7 @@ #define TINSEL_PCODE_H #include "tinsel/events.h" // for TINSEL_EVENT -#include "tinsel/sched.h" // for PROCESS +#include "tinsel/sched.h" // for Common::PROCESS namespace Common { class Serializer; @@ -56,7 +56,7 @@ struct WorkaroundEntry; struct INT_CONTEXT { // Elements for interpret context management - PROCESS *pProc; ///< processes owning this context + Common::PROCESS *pProc; ///< processes owning this context GSORT GSort; ///< sort of this context // Previously parameters to Interpret() @@ -114,12 +114,12 @@ void SaveInterpretContexts(INT_CONTEXT *sICInfo); void RegisterGlobals(int num); void FreeGlobals(); -void AttachInterpret(INT_CONTEXT *pic, PROCESS *pProc); +void AttachInterpret(INT_CONTEXT *pic, Common::PROCESS *pProc); -void WaitInterpret(CORO_PARAM, PPROCESS pWaitProc, bool *result); +void WaitInterpret(CORO_PARAM, Common::PPROCESS pWaitProc, bool *result); -#define NUM_INTERPRET (NUM_PROCESS - 20) -#define MAX_INTERPRET (MAX_PROCESSES - 20) +#define NUM_INTERPRET (CORO_NUM_PROCESS - 20) +#define MAX_INTERPRET (CORO_MAX_PROCESSES - 20) /*----------------------------------------------------------------------*\ |* Library Procedure and Function codes parameter enums *| diff --git a/engines/tinsel/pdisplay.cpp b/engines/tinsel/pdisplay.cpp index 9a9e6ab00f..b821c5dee2 100644 --- a/engines/tinsel/pdisplay.cpp +++ b/engines/tinsel/pdisplay.cpp @@ -23,9 +23,9 @@ * PointProcess() */ +#include "common/coroutines.h" #include "tinsel/actors.h" #include "tinsel/background.h" -#include "tinsel/coroutine.h" #include "tinsel/cursor.h" #include "tinsel/dw.h" #include "tinsel/events.h" @@ -265,7 +265,7 @@ void DisablePointing() { if (hPoly != NOPOLY && PolyType(hPoly) == TAG && PolyIsPointedTo(hPoly)) { SetPolyPointedTo(hPoly, false); SetPolyTagWanted(hPoly, false, false, 0); - PolygonEvent(nullContext, hPoly, UNPOINT, 0, false, 0); + PolygonEvent(Common::nullContext, hPoly, UNPOINT, 0, false, 0); } } @@ -275,7 +275,7 @@ void DisablePointing() { SetActorPointedTo(i, false); SetActorTagWanted(i, false, false, 0); - ActorEvent(nullContext, i, UNPOINT, false, 0); + ActorEvent(Common::nullContext, i, UNPOINT, false, 0); } } } diff --git a/engines/tinsel/play.cpp b/engines/tinsel/play.cpp index 40729d9f3a..9e0baa749e 100644 --- a/engines/tinsel/play.cpp +++ b/engines/tinsel/play.cpp @@ -21,9 +21,9 @@ * Plays films within a scene, takes into account the actor in each 'column'. | */ +#include "common/coroutines.h" #include "tinsel/actors.h" #include "tinsel/background.h" -#include "tinsel/coroutine.h" #include "tinsel/dw.h" #include "tinsel/film.h" #include "tinsel/handle.h" @@ -395,7 +395,7 @@ static void SoundReelWaitCheck() { if (--g_soundReelWait == 0) { for (int i = 0; i < MAX_SOUNDREELS; i++) { if (g_soundReels[i].hFilm) { - g_scheduler->createProcess(PID_REEL, ResSoundReel, &i, sizeof(i)); + CoroScheduler.createProcess(PID_REEL, ResSoundReel, &i, sizeof(i)); } } } @@ -1001,7 +1001,7 @@ void PlayFilm(CORO_PARAM, SCNHANDLE hFilm, int x, int y, int actorid, bool splay NewestFilm(hFilm, &pFilm->reels[i]); ppi.column = i; - g_scheduler->createProcess(PID_REEL, PlayProcess, &ppi, sizeof(PPINIT)); + CoroScheduler.createProcess(PID_REEL, PlayProcess, &ppi, sizeof(PPINIT)); } if (TinselV2) { @@ -1011,7 +1011,7 @@ void PlayFilm(CORO_PARAM, SCNHANDLE hFilm, int x, int y, int actorid, bool splay CORO_GIVE_WAY; if (myescEvent && myescEvent != GetEscEvents()) - g_scheduler->rescheduleAll(); + CoroScheduler.rescheduleAll(); } CORO_END_CODE; @@ -1063,7 +1063,7 @@ void PlayFilmc(CORO_PARAM, SCNHANDLE hFilm, int x, int y, int actorid, bool spla NewestFilm(hFilm, &pFilm->reels[i]); _ctx->ppi.column = i; - g_scheduler->createProcess(PID_REEL, PlayProcess, &_ctx->ppi, sizeof(PPINIT)); + CoroScheduler.createProcess(PID_REEL, PlayProcess, &_ctx->ppi, sizeof(PPINIT)); } if (TinselV2) { @@ -1078,7 +1078,7 @@ void PlayFilmc(CORO_PARAM, SCNHANDLE hFilm, int x, int y, int actorid, bool spla // Wait until film changes or loop count increases while (GetActorPresFilm(_ctx->i) == hFilm && GetLoopCount(_ctx->i) == _ctx->loopCount) { if (myescEvent && myescEvent != GetEscEvents()) { - g_scheduler->rescheduleAll(); + CoroScheduler.rescheduleAll(); break; } @@ -1126,7 +1126,7 @@ void RestoreActorReels(SCNHANDLE hFilm, short reelnum, short z, int x, int y) { NewestFilm(hFilm, &pfilm->reels[reelnum]); // Start display process for the reel - g_scheduler->createProcess(PID_REEL, PlayProcess, &ppi, sizeof(ppi)); + CoroScheduler.createProcess(PID_REEL, PlayProcess, &ppi, sizeof(ppi)); } /** @@ -1160,7 +1160,7 @@ void RestoreActorReels(SCNHANDLE hFilm, int actor, int x, int y) { NewestFilm(hFilm, &pFilm->reels[i]); // Start display process for the reel - g_scheduler->createProcess(PID_REEL, PlayProcess, &ppi, sizeof(ppi)); + CoroScheduler.createProcess(PID_REEL, PlayProcess, &ppi, sizeof(ppi)); g_soundReelWait++; } diff --git a/engines/tinsel/play.h b/engines/tinsel/play.h index 041b7096a8..fffa8a9329 100644 --- a/engines/tinsel/play.h +++ b/engines/tinsel/play.h @@ -24,7 +24,7 @@ #ifndef TINSEL_PLAY_H // prevent multiple includes #define TINSEL_PLAY_H -#include "tinsel/coroutine.h" +#include "common/coroutines.h" #include "tinsel/dw.h" #include "tinsel/multiobj.h" diff --git a/engines/tinsel/polygons.cpp b/engines/tinsel/polygons.cpp index 6fc1c65ec5..d8c1cef0b6 100644 --- a/engines/tinsel/polygons.cpp +++ b/engines/tinsel/polygons.cpp @@ -1469,7 +1469,7 @@ static void SetExTags(SCNHANDLE ph) { pts = &TagStates[SceneTags[i].offset]; for (j = 0; j < SceneTags[i].nooftags; j++, pts++) { if (!pts->enabled) - DisableTag(nullContext, pts->tid); + DisableTag(Common::nullContext, pts->tid); } return; } @@ -1873,7 +1873,7 @@ void InitPolygons(SCNHANDLE ph, int numPoly, bool bRestart) { } else { for (int i = numPoly - 1; i >= 0; i--) { if (Polys[i]->polyType == TAG) { - PolygonEvent(nullContext, i, STARTUP, 0, false, 0); + PolygonEvent(Common::nullContext, i, STARTUP, 0, false, 0); } } } diff --git a/engines/tinsel/rince.cpp b/engines/tinsel/rince.cpp index bb0aeabd2f..ba8f47f9cf 100644 --- a/engines/tinsel/rince.cpp +++ b/engines/tinsel/rince.cpp @@ -202,8 +202,8 @@ void KillMover(PMOVER pMover) { pMover->bActive = false; MultiDeleteObject(GetPlayfieldList(FIELD_WORLD), pMover->actorObj); pMover->actorObj = NULL; - assert(g_scheduler->getCurrentProcess() != pMover->pProc); - g_scheduler->killProcess(pMover->pProc); + assert(CoroScheduler.getCurrentProcess() != pMover->pProc); + CoroScheduler.killProcess(pMover->pProc); } } @@ -856,10 +856,10 @@ void MoverProcessCreate(int X, int Y, int id, PMOVER pMover) { iStruct.Y = Y; iStruct.pMover = pMover; - g_scheduler->createProcess(PID_MOVER, T2MoverProcess, &iStruct, sizeof(MAINIT)); + CoroScheduler.createProcess(PID_MOVER, T2MoverProcess, &iStruct, sizeof(MAINIT)); } else { MoverProcessHelper(X, Y, id, pMover); - pMover->pProc = g_scheduler->createProcess(PID_MOVER, T1MoverProcess, &pMover, sizeof(PMOVER)); + pMover->pProc = CoroScheduler.createProcess(PID_MOVER, T1MoverProcess, &pMover, sizeof(PMOVER)); } } diff --git a/engines/tinsel/rince.h b/engines/tinsel/rince.h index 93fd191172..b34c3f20de 100644 --- a/engines/tinsel/rince.h +++ b/engines/tinsel/rince.h @@ -31,7 +31,7 @@ namespace Tinsel { struct OBJECT; -struct PROCESS; +struct Common::PROCESS; enum NPS {NOT_IN, GOING_UP, GOING_DOWN, LEAVING, ENTERING}; @@ -110,7 +110,7 @@ struct MOVER { /* NOTE: If effect polys can overlap, this needs improving */ bool bInEffect; - PROCESS *pProc; + Common::PROCESS *pProc; // Discworld 2 specific fields int32 zOverride; diff --git a/engines/tinsel/savescn.cpp b/engines/tinsel/savescn.cpp index 1b06e3929c..0c0cc5c81e 100644 --- a/engines/tinsel/savescn.cpp +++ b/engines/tinsel/savescn.cpp @@ -190,7 +190,7 @@ void sortActors(SAVED_DATA *sd) { RestoreAuxScales(sd->SavedMoverInfo); for (int i = 0; i < MAX_MOVERS; i++) { if (sd->SavedMoverInfo[i].bActive) - Stand(nullContext, sd->SavedMoverInfo[i].actorID, sd->SavedMoverInfo[i].objX, + Stand(Common::nullContext, sd->SavedMoverInfo[i].actorID, sd->SavedMoverInfo[i].objX, sd->SavedMoverInfo[i].objY, sd->SavedMoverInfo[i].hLastfilm); } } @@ -245,7 +245,7 @@ static void SortMAProcess(CORO_PARAM, const void *) { void ResumeInterprets() { // Master script only affected on restore game, not restore scene if (!TinselV2 && (g_rsd == &g_sgData)) { - g_scheduler->killMatchingProcess(PID_MASTER_SCR, -1); + CoroScheduler.killMatchingProcess(PID_MASTER_SCR, -1); FreeMasterInterpretContext(); } @@ -314,7 +314,7 @@ static int DoRestoreSceneFrame(SAVED_DATA *sd, int n) { // Master script only affected on restore game, not restore scene if (sd == &g_sgData) { - g_scheduler->killMatchingProcess(PID_MASTER_SCR); + CoroScheduler.killMatchingProcess(PID_MASTER_SCR); KillGlobalProcesses(); FreeMasterInterpretContext(); } @@ -340,7 +340,7 @@ static int DoRestoreSceneFrame(SAVED_DATA *sd, int n) { SetDoFadeIn(!g_bNoFade); g_bNoFade = false; - StartupBackground(nullContext, sd->SavedBgroundHandle); + StartupBackground(Common::nullContext, sd->SavedBgroundHandle); if (TinselV2) { Offset(EX_USEXY, sd->SavedLoffset, sd->SavedToffset); @@ -354,7 +354,7 @@ static int DoRestoreSceneFrame(SAVED_DATA *sd, int n) { if (TinselV2) { // create process to sort out the moving actors - g_scheduler->createProcess(PID_MOVER, SortMAProcess, NULL, 0); + CoroScheduler.createProcess(PID_MOVER, SortMAProcess, NULL, 0); g_bNotDoneYet = true; RestoreActorZ(sd->savedActorZ); diff --git a/engines/tinsel/scene.cpp b/engines/tinsel/scene.cpp index f635ce13a3..79bb30f7a3 100644 --- a/engines/tinsel/scene.cpp +++ b/engines/tinsel/scene.cpp @@ -193,7 +193,7 @@ void SendSceneTinselProcess(TINSEL_EVENT event) { init.event = event; init.hTinselCode = ss->hSceneScript; - g_scheduler->createProcess(PID_TCODE, SceneTinselProcess, &init, sizeof(init)); + CoroScheduler.createProcess(PID_TCODE, SceneTinselProcess, &init, sizeof(init)); } } } @@ -271,7 +271,7 @@ static void LoadScene(SCNHANDLE scene, int entry) { init.event = STARTUP; init.hTinselCode = es->hScript; - g_scheduler->createProcess(PID_TCODE, SceneTinselProcess, &init, sizeof(init)); + CoroScheduler.createProcess(PID_TCODE, SceneTinselProcess, &init, sizeof(init)); } break; } @@ -291,7 +291,7 @@ static void LoadScene(SCNHANDLE scene, int entry) { init.event = STARTUP; init.hTinselCode = ss->hSceneScript; - g_scheduler->createProcess(PID_TCODE, SceneTinselProcess, &init, sizeof(init)); + CoroScheduler.createProcess(PID_TCODE, SceneTinselProcess, &init, sizeof(init)); } } @@ -344,7 +344,7 @@ void EndScene() { KillAllObjects(); // kill all destructable process - g_scheduler->killMatchingProcess(PID_DESTROY, PID_DESTROY); + CoroScheduler.killMatchingProcess(PID_DESTROY, PID_DESTROY); } /** @@ -405,16 +405,16 @@ void PrimeScene() { if (!TinselV2) EnableTags(); // Next scene with tags enabled - g_scheduler->createProcess(PID_SCROLL, ScrollProcess, NULL, 0); - g_scheduler->createProcess(PID_SCROLL, EffectPolyProcess, NULL, 0); + CoroScheduler.createProcess(PID_SCROLL, ScrollProcess, NULL, 0); + CoroScheduler.createProcess(PID_SCROLL, EffectPolyProcess, NULL, 0); #ifdef DEBUG if (g_ShowPosition) - g_scheduler->createProcess(PID_POSITION, CursorPositionProcess, NULL, 0); + CoroScheduler.createProcess(PID_POSITION, CursorPositionProcess, NULL, 0); #endif - g_scheduler->createProcess(PID_TAG, TagProcess, NULL, 0); - g_scheduler->createProcess(PID_TAG, PointProcess, NULL, 0); + CoroScheduler.createProcess(PID_TAG, TagProcess, NULL, 0); + CoroScheduler.createProcess(PID_TAG, PointProcess, NULL, 0); // init the current background PrimeBackground(); @@ -471,7 +471,7 @@ void DoHailScene(SCNHANDLE scene) { init.event = NOEVENT; init.hTinselCode = ss->hSceneScript; - g_scheduler->createProcess(PID_TCODE, SceneTinselProcess, &init, sizeof(init)); + CoroScheduler.createProcess(PID_TCODE, SceneTinselProcess, &init, sizeof(init)); } } diff --git a/engines/tinsel/sched.cpp b/engines/tinsel/sched.cpp index 343758d924..4bf356ba36 100644 --- a/engines/tinsel/sched.cpp +++ b/engines/tinsel/sched.cpp @@ -32,8 +32,6 @@ namespace Tinsel { -Scheduler *g_scheduler = 0; - #include "common/pack-start.h" // START STRUCT PACKING struct PROCESS_STRUC { @@ -53,471 +51,6 @@ static SCNHANDLE g_hSceneProcess; static uint32 g_numGlobalProcess; static PROCESS_STRUC *g_pGlobalProcess; -//--------------------- FUNCTIONS ------------------------ - -Scheduler::Scheduler() { - processList = 0; - pFreeProcesses = 0; - pCurrent = 0; - -#ifdef DEBUG - // diagnostic process counters - numProcs = 0; - maxProcs = 0; -#endif - - pRCfunction = 0; - - active = new PROCESS; - active->pPrevious = NULL; - active->pNext = NULL; - - g_scheduler = this; // FIXME HACK -} - -Scheduler::~Scheduler() { - // Kill all running processes (i.e. free memory allocated for their state). - PROCESS *pProc = active->pNext; - while (pProc != NULL) { - delete pProc->state; - pProc->state = 0; - pProc = pProc->pNext; - } - - free(processList); - processList = NULL; - - delete active; - active = 0; -} - -/** - * Kills all processes and places them on the free list. - */ -void Scheduler::reset() { - -#ifdef DEBUG - // clear number of process in use - numProcs = 0; -#endif - - if (processList == NULL) { - // first time - allocate memory for process list - processList = (PROCESS *)calloc(MAX_PROCESSES, sizeof(PROCESS)); - - // make sure memory allocated - if (processList == NULL) { - error("Cannot allocate memory for process data"); - } - - // fill with garbage - memset(processList, 'S', MAX_PROCESSES * sizeof(PROCESS)); - } - - // Kill all running processes (i.e. free memory allocated for their state). - PROCESS *pProc = active->pNext; - while (pProc != NULL) { - delete pProc->state; - pProc->state = 0; - pProc = pProc->pNext; - } - - // no active processes - pCurrent = active->pNext = NULL; - - // place first process on free list - pFreeProcesses = processList; - - // link all other processes after first - for (int i = 1; i <= NUM_PROCESS; i++) { - processList[i - 1].pNext = (i == NUM_PROCESS) ? NULL : processList + i; - processList[i - 1].pPrevious = (i == 1) ? active : processList + (i - 2); - } -} - - -#ifdef DEBUG -/** - * Shows the maximum number of process used at once. - */ -void Scheduler::printStats() { - debug("%i process of %i used", maxProcs, NUM_PROCESS); -} -#endif - -#ifdef DEBUG -/** - * Checks both the active and free process list to insure all the links are valid, - * and that no processes have been lost - */ -void Scheduler::CheckStack() { - Common::List pList; - - // Check both the active and free process lists - for (int i = 0; i < 2; ++i) { - PROCESS *p = (i == 0) ? active : pFreeProcesses; - - if (p != NULL) { - // Make sure the linkages are correct - while (p->pNext != NULL) { - assert(p->pNext->pPrevious == p); - pList.push_back(p); - p = p->pNext; - } - pList.push_back(p); - } - } - - // Make sure all processes are accounted for - for (int idx = 0; idx < NUM_PROCESS; idx++) { - bool found = false; - for (Common::List::iterator i = pList.begin(); i != pList.end(); ++i) { - PROCESS *pTemp = *i; - if (*i == &processList[idx]) { - found = true; - break; - } - } - - assert(found); - } -} -#endif - -/** - * Give all active processes a chance to run - */ -void Scheduler::schedule() { - // start dispatching active process list - PROCESS *pNext; - PROCESS *pProc = active->pNext; - while (pProc != NULL) { - pNext = pProc->pNext; - - if (--pProc->sleepTime <= 0) { - // process is ready for dispatch, activate it - pCurrent = pProc; - pProc->coroAddr(pProc->state, pProc->param); - - if (!pProc->state || pProc->state->_sleep <= 0) { - // Coroutine finished - pCurrent = pCurrent->pPrevious; - killProcess(pProc); - } else { - pProc->sleepTime = pProc->state->_sleep; - } - - // pCurrent may have been changed - pNext = pCurrent->pNext; - pCurrent = NULL; - } - - pProc = pNext; - } -} - -/** - * Reschedules all the processes to run again this query - */ -void Scheduler::rescheduleAll() { - assert(pCurrent); - - // Unlink current process - pCurrent->pPrevious->pNext = pCurrent->pNext; - if (pCurrent->pNext) - pCurrent->pNext->pPrevious = pCurrent->pPrevious; - - // Add process to the start of the active list - pCurrent->pNext = active->pNext; - active->pNext->pPrevious = pCurrent; - active->pNext = pCurrent; - pCurrent->pPrevious = active; -} - -/** - * If the specified process has already run on this tick, make it run - * again on the current tick. - */ -void Scheduler::reschedule(PPROCESS pReSchedProc) { - // If not currently processing the schedule list, then no action is needed - if (!pCurrent) - return; - - if (!pReSchedProc) - pReSchedProc = pCurrent; - - PPROCESS pEnd; - - // Find the last process in the list. - // But if the target process is down the list from here, do nothing - for (pEnd = pCurrent; pEnd->pNext != NULL; pEnd = pEnd->pNext) { - if (pEnd->pNext == pReSchedProc) - return; - } - - assert(pEnd->pNext == NULL); - - // Could be in the middle of a KillProc()! - // Dying process was last and this process was penultimate - if (pReSchedProc->pNext == NULL) - return; - - // If we're moving the current process, move it back by one, so that the next - // schedule() iteration moves to the now next one - if (pCurrent == pReSchedProc) - pCurrent = pCurrent->pPrevious; - - // Unlink the process, and add it at the end - pReSchedProc->pPrevious->pNext = pReSchedProc->pNext; - pReSchedProc->pNext->pPrevious = pReSchedProc->pPrevious; - pEnd->pNext = pReSchedProc; - pReSchedProc->pPrevious = pEnd; - pReSchedProc->pNext = NULL; -} - -/** - * Moves the specified process to the end of the dispatch queue - * allowing it to run again within the current game cycle. - * @param pGiveProc Which process - */ -void Scheduler::giveWay(PPROCESS pReSchedProc) { - // If not currently processing the schedule list, then no action is needed - if (!pCurrent) - return; - - if (!pReSchedProc) - pReSchedProc = pCurrent; - - // If the process is already at the end of the queue, nothing has to be done - if (!pReSchedProc->pNext) - return; - - PPROCESS pEnd; - - // Find the last process in the list. - for (pEnd = pCurrent; pEnd->pNext != NULL; pEnd = pEnd->pNext) - ; - assert(pEnd->pNext == NULL); - - - // If we're moving the current process, move it back by one, so that the next - // schedule() iteration moves to the now next one - if (pCurrent == pReSchedProc) - pCurrent = pCurrent->pPrevious; - - // Unlink the process, and add it at the end - pReSchedProc->pPrevious->pNext = pReSchedProc->pNext; - pReSchedProc->pNext->pPrevious = pReSchedProc->pPrevious; - pEnd->pNext = pReSchedProc; - pReSchedProc->pPrevious = pEnd; - pReSchedProc->pNext = NULL; -} - -/** - * Creates a new process. - * - * @param pid process identifier - * @param CORO_ADDR coroutine start address - * @param pParam process specific info - * @param sizeParam size of process specific info - */ -PROCESS *Scheduler::createProcess(int pid, CORO_ADDR coroAddr, const void *pParam, int sizeParam) { - PROCESS *pProc; - - // get a free process - pProc = pFreeProcesses; - - // trap no free process - assert(pProc != NULL); // Out of processes - -#ifdef DEBUG - // one more process in use - if (++numProcs > maxProcs) - maxProcs = numProcs; -#endif - - // get link to next free process - pFreeProcesses = pProc->pNext; - if (pFreeProcesses) - pFreeProcesses->pPrevious = NULL; - - if (pCurrent != NULL) { - // place new process before the next active process - pProc->pNext = pCurrent->pNext; - if (pProc->pNext) - pProc->pNext->pPrevious = pProc; - - // make this new process the next active process - pCurrent->pNext = pProc; - pProc->pPrevious = pCurrent; - - } else { // no active processes, place process at head of list - pProc->pNext = active->pNext; - pProc->pPrevious = active; - - if (pProc->pNext) - pProc->pNext->pPrevious = pProc; - active->pNext = pProc; - - } - - // set coroutine entry point - pProc->coroAddr = coroAddr; - - // clear coroutine state - pProc->state = 0; - - // wake process up as soon as possible - pProc->sleepTime = 1; - - // set new process id - pProc->pid = pid; - - // set new process specific info - if (sizeParam) { - assert(sizeParam > 0 && sizeParam <= PARAM_SIZE); - - // set new process specific info - memcpy(pProc->param, pParam, sizeParam); - } - - // return created process - return pProc; -} - -/** - * Kills the specified process. - * - * @param pKillProc which process to kill - */ -void Scheduler::killProcess(PROCESS *pKillProc) { - // make sure a valid process pointer - assert(pKillProc >= processList && pKillProc <= processList + NUM_PROCESS - 1); - - // can not kill the current process using killProcess ! - assert(pCurrent != pKillProc); - -#ifdef DEBUG - // one less process in use - --numProcs; - assert(numProcs >= 0); -#endif - - // Free process' resources - if (pRCfunction != NULL) - (pRCfunction)(pKillProc); - - delete pKillProc->state; - pKillProc->state = 0; - - // Take the process out of the active chain list - pKillProc->pPrevious->pNext = pKillProc->pNext; - if (pKillProc->pNext) - pKillProc->pNext->pPrevious = pKillProc->pPrevious; - - // link first free process after pProc - pKillProc->pNext = pFreeProcesses; - if (pFreeProcesses) - pKillProc->pNext->pPrevious = pKillProc; - pKillProc->pPrevious = NULL; - - // make pKillProc the first free process - pFreeProcesses = pKillProc; -} - - - -/** - * Returns a pointer to the currently running process. - */ -PROCESS *Scheduler::getCurrentProcess() { - return pCurrent; -} - -/** - * Returns the process identifier of the specified process. - * - * @param pProc which process - */ -int Scheduler::getCurrentPID() const { - PROCESS *pProc = pCurrent; - - // make sure a valid process pointer - assert(pProc >= processList && pProc <= processList + NUM_PROCESS - 1); - - // return processes PID - return pProc->pid; -} - -/** - * Kills any process matching the specified PID. The current - * process cannot be killed. - * - * @param pidKill process identifier of process to kill - * @param pidMask mask to apply to process identifiers before comparison - * @return The number of processes killed is returned. - */ -int Scheduler::killMatchingProcess(int pidKill, int pidMask) { - int numKilled = 0; - PROCESS *pProc, *pPrev; // process list pointers - - for (pProc = active->pNext, pPrev = active; pProc != NULL; pPrev = pProc, pProc = pProc->pNext) { - if ((pProc->pid & pidMask) == pidKill) { - // found a matching process - - // dont kill the current process - if (pProc != pCurrent) { - // kill this process - numKilled++; - - // Free the process' resources - if (pRCfunction != NULL) - (pRCfunction)(pProc); - - delete pProc->state; - pProc->state = 0; - - // make prev point to next to unlink pProc - pPrev->pNext = pProc->pNext; - if (pProc->pNext) - pPrev->pNext->pPrevious = pPrev; - - // link first free process after pProc - pProc->pNext = pFreeProcesses; - pProc->pPrevious = NULL; - pFreeProcesses->pPrevious = pProc; - - // make pProc the first free process - pFreeProcesses = pProc; - - // set to a process on the active list - pProc = pPrev; - } - } - } - -#ifdef DEBUG - // adjust process in use - numProcs -= numKilled; - assert(numProcs >= 0); -#endif - - // return number of processes killed - return numKilled; -} - -/** - * Set pointer to a function to be called by killProcess(). - * - * May be called by a resource allocator, the function supplied is - * called by killProcess() to allow the resource allocator to free - * resources allocated to the dying process. - * - * @param pFunc Function to be called by killProcess() - */ -void Scheduler::setResourceCallback(VFPTRPP pFunc) { - pRCfunction = pFunc; -} /**************************************************************************\ |*********** Stuff to do with scene and global processes ************| @@ -537,7 +70,7 @@ static void RestoredProcessProcess(CORO_PARAM, const void *param) { _ctx->pic = *(const PINT_CONTEXT *)param; _ctx->pic = RestoreInterpretContext(_ctx->pic); - AttachInterpret(_ctx->pic, g_scheduler->getCurrentProcess()); + AttachInterpret(_ctx->pic, CoroScheduler.getCurrentProcess()); CORO_INVOKE_1(Interpret, _ctx->pic); @@ -577,7 +110,7 @@ void RestoreSceneProcess(INT_CONTEXT *pic) { pStruc = (PROCESS_STRUC *)LockMem(g_hSceneProcess); for (i = 0; i < g_numSceneProcess; i++) { if (FROM_LE_32(pStruc[i].hProcessCode) == pic->hCode) { - g_scheduler->createProcess(PID_PROCESS + i, RestoredProcessProcess, + CoroScheduler.createProcess(PID_PROCESS + i, RestoredProcessProcess, &pic, sizeof(pic)); break; } @@ -596,7 +129,7 @@ void SceneProcessEvent(CORO_PARAM, uint32 procID, TINSEL_EVENT event, bool bWait CORO_BEGIN_CONTEXT; PROCESS_STRUC *pStruc; - PPROCESS pProc; + Common::PPROCESS pProc; PINT_CONTEXT pic; CORO_END_CONTEXT(_ctx); @@ -617,7 +150,7 @@ void SceneProcessEvent(CORO_PARAM, uint32 procID, TINSEL_EVENT event, bool bWait if (_ctx->pic == NULL) return; - _ctx->pProc = g_scheduler->createProcess(PID_PROCESS + i, ProcessTinselProcess, + _ctx->pProc = CoroScheduler.createProcess(PID_PROCESS + i, ProcessTinselProcess, &_ctx->pic, sizeof(_ctx->pic)); AttachInterpret(_ctx->pic, _ctx->pProc); break; @@ -644,7 +177,7 @@ void KillSceneProcess(uint32 procID) { pStruc = (PROCESS_STRUC *) LockMem(g_hSceneProcess); for (i = 0; i < g_numSceneProcess; i++) { if (FROM_LE_32(pStruc[i].processId) == procID) { - g_scheduler->killMatchingProcess(PID_PROCESS + i, -1); + CoroScheduler.killMatchingProcess(PID_PROCESS + i, -1); break; } } @@ -671,7 +204,7 @@ void RestoreGlobalProcess(INT_CONTEXT *pic) { for (i = 0; i < g_numGlobalProcess; i++) { if (g_pGlobalProcess[i].hProcessCode == pic->hCode) { - g_scheduler->createProcess(PID_GPROCESS + i, RestoredProcessProcess, + CoroScheduler.createProcess(PID_GPROCESS + i, RestoredProcessProcess, &pic, sizeof(pic)); break; } @@ -686,7 +219,7 @@ void RestoreGlobalProcess(INT_CONTEXT *pic) { void KillGlobalProcesses() { for (uint32 i = 0; i < g_numGlobalProcess; ++i) { - g_scheduler->killMatchingProcess(PID_GPROCESS + i, -1); + CoroScheduler.killMatchingProcess(PID_GPROCESS + i, -1); } } @@ -696,7 +229,7 @@ void KillGlobalProcesses() { bool GlobalProcessEvent(CORO_PARAM, uint32 procID, TINSEL_EVENT event, bool bWait, int myEscape) { CORO_BEGIN_CONTEXT; PINT_CONTEXT pic; - PPROCESS pProc; + Common::PPROCESS pProc; CORO_END_CONTEXT(_ctx); bool result = false; @@ -720,7 +253,7 @@ bool GlobalProcessEvent(CORO_PARAM, uint32 procID, TINSEL_EVENT event, bool bWai if (_ctx->pic != NULL) { - _ctx->pProc = g_scheduler->createProcess(PID_GPROCESS + i, ProcessTinselProcess, + _ctx->pProc = CoroScheduler.createProcess(PID_GPROCESS + i, ProcessTinselProcess, &_ctx->pic, sizeof(_ctx->pic)); AttachInterpret(_ctx->pic, _ctx->pProc); } @@ -745,7 +278,7 @@ void xKillGlobalProcess(uint32 procID) { for (i = 0; i < g_numGlobalProcess; ++i) { if (g_pGlobalProcess[i].processId == procID) { - g_scheduler->killMatchingProcess(PID_GPROCESS + i, -1); + CoroScheduler.killMatchingProcess(PID_GPROCESS + i, -1); break; } } diff --git a/engines/tinsel/sched.h b/engines/tinsel/sched.h index a1eafcdc47..3e791cecd8 100644 --- a/engines/tinsel/sched.h +++ b/engines/tinsel/sched.h @@ -24,105 +24,16 @@ #ifndef TINSEL_SCHED_H // prevent multiple includes #define TINSEL_SCHED_H +#include "common/coroutines.h" #include "tinsel/dw.h" // new data types -#include "tinsel/coroutine.h" #include "tinsel/events.h" +#include "tinsel/pcode.h" #include "tinsel/tinsel.h" namespace Tinsel { -// the size of process specific info -#define PARAM_SIZE 32 - -// the maximum number of processes -#define NUM_PROCESS (TinselV2 ? 70 : 64) -#define MAX_PROCESSES 70 - -typedef void (*CORO_ADDR)(CoroContext &, const void *); - -/** process structure */ -struct PROCESS { - PROCESS *pNext; ///< pointer to next process in active or free list - PROCESS *pPrevious; ///< pointer to previous process in active or free list - - CoroContext state; ///< the state of the coroutine - CORO_ADDR coroAddr; ///< the entry point of the coroutine - - int sleepTime; ///< number of scheduler cycles to sleep - int pid; ///< process ID - char param[PARAM_SIZE]; ///< process specific info -}; -typedef PROCESS *PPROCESS; - struct INT_CONTEXT; -/** - * Create and manage "processes" (really coroutines). - */ -class Scheduler { -public: - /** Pointer to a function of the form "void function(PPROCESS)" */ - typedef void (*VFPTRPP)(PROCESS *); - -private: - - /** list of all processes */ - PROCESS *processList; - - /** active process list - also saves scheduler state */ - PROCESS *active; - - /** pointer to free process list */ - PROCESS *pFreeProcesses; - - /** the currently active process */ - PROCESS *pCurrent; - -#ifdef DEBUG - // diagnostic process counters - int numProcs; - int maxProcs; - - void CheckStack(); -#endif - - /** - * Called from killProcess() to enable other resources - * a process may be allocated to be released. - */ - VFPTRPP pRCfunction; - - -public: - - Scheduler(); - ~Scheduler(); - - void reset(); - - #ifdef DEBUG - void printStats(); - #endif - - void schedule(); - void rescheduleAll(); - void reschedule(PPROCESS pReSchedProc = NULL); - void giveWay(PPROCESS pReSchedProc = NULL); - - PROCESS *createProcess(int pid, CORO_ADDR coroAddr, const void *pParam, int sizeParam); - void killProcess(PROCESS *pKillProc); - - PROCESS *getCurrentProcess(); - int getCurrentPID() const; - int killMatchingProcess(int pidKill, int pidMask = -1); - - - void setResourceCallback(VFPTRPP pFunc); - -}; - -extern Scheduler *g_scheduler; // FIXME: Temporary global var, to be used until everything has been OOifyied - //----------------- FUNCTION PROTOTYPES -------------------- void SceneProcesses(uint32 numProcess, SCNHANDLE hProcess); diff --git a/engines/tinsel/text.h b/engines/tinsel/text.h index 4c80300c46..97e82c7a93 100644 --- a/engines/tinsel/text.h +++ b/engines/tinsel/text.h @@ -24,7 +24,7 @@ #ifndef TINSEL_TEXT_H // prevent multiple includes #define TINSEL_TEXT_H -#include "tinsel/coroutine.h" +#include "common/coroutines.h" #include "tinsel/object.h" // object manager defines namespace Tinsel { diff --git a/engines/tinsel/tinlib.cpp b/engines/tinsel/tinlib.cpp index c652abca25..dfa44c505a 100644 --- a/engines/tinsel/tinlib.cpp +++ b/engines/tinsel/tinlib.cpp @@ -28,11 +28,11 @@ #define BODGE +#include "common/coroutines.h" #include "tinsel/actors.h" #include "tinsel/background.h" #include "tinsel/bmv.h" #include "tinsel/config.h" -#include "tinsel/coroutine.h" #include "tinsel/cursor.h" #include "tinsel/drives.h" #include "tinsel/dw.h" @@ -1468,7 +1468,7 @@ void NewScene(CORO_PARAM, SCNHANDLE scene, int entrance, int transition) { ++g_sceneCtr; // Prevent code subsequent to this call running before scene changes - if (g_scheduler->getCurrentPID() != PID_MASTER_SCR) + if (CoroScheduler.getCurrentPID() != PID_MASTER_SCR) CORO_KILL_SELF(); CORO_END_CODE; } @@ -2594,7 +2594,7 @@ static void Scroll(CORO_PARAM, EXTREME extreme, int xp, int yp, int xIter, int y sm.y = _ctx->y; sm.thisScroll = g_scrollNumber; sm.myEscape = myEscape; - g_scheduler->createProcess(PID_TCODE, ScrollMonitorProcess, &sm, sizeof(sm)); + CoroScheduler.createProcess(PID_TCODE, ScrollMonitorProcess, &sm, sizeof(sm)); } } CORO_END_CODE; @@ -2975,12 +2975,12 @@ static void StandTag(int actor, HPOLYGON hp) { && hFilm != TF_LEFT && hFilm != TF_RIGHT) hFilm = 0; - Stand(nullContext, actor, pnodex, pnodey, hFilm); + Stand(Common::nullContext, actor, pnodex, pnodey, hFilm); } else if (hFilm && (actor == LEAD_ACTOR || actor == GetLeadId())) - Stand(nullContext, actor, pnodex, pnodey, hFilm); + Stand(Common::nullContext, actor, pnodex, pnodey, hFilm); else - Stand(nullContext, actor, pnodex, pnodey, 0); + Stand(Common::nullContext, actor, pnodex, pnodey, 0); } diff --git a/engines/tinsel/tinsel.cpp b/engines/tinsel/tinsel.cpp index 65900cc7f3..e09e2c1dcf 100644 --- a/engines/tinsel/tinsel.cpp +++ b/engines/tinsel/tinsel.cpp @@ -109,8 +109,8 @@ static Scene g_NextScene = { 0, 0, 0 }; static Scene g_HookScene = { 0, 0, 0 }; static Scene g_DelayedScene = { 0, 0, 0 }; -static PROCESS *g_pMouseProcess = 0; -static PROCESS *g_pKeyboardProcess = 0; +static Common::PROCESS *g_pMouseProcess = 0; +static Common::PROCESS *g_pKeyboardProcess = 0; static SCNHANDLE g_hCdChangeScene; @@ -324,7 +324,7 @@ static void MouseProcess(CORO_PARAM, const void *) { if (TinselV2) { // Kill off the button process and fire off the action command - g_scheduler->killMatchingProcess(PID_BTN_CLICK, -1); + CoroScheduler.killMatchingProcess(PID_BTN_CLICK, -1); PlayerEvent(PLR_ACTION, _ctx->clickPos); } else { // signal left drag start @@ -368,7 +368,7 @@ static void MouseProcess(CORO_PARAM, const void *) { // will activate a single button click if (TinselV2 && ControlIsOn()) { _ctx->clickPos = mousePos; - g_scheduler->createProcess(PID_BTN_CLICK, SingleLeftProcess, &_ctx->clickPos, sizeof(Common::Point)); + CoroScheduler.createProcess(PID_BTN_CLICK, SingleLeftProcess, &_ctx->clickPos, sizeof(Common::Point)); } } else _ctx->lastLeftClick -= _vm->_config->_dclickSpeed; @@ -616,11 +616,11 @@ static void RestoredProcess(CORO_PARAM, const void *param) { } void RestoreProcess(INT_CONTEXT *pic) { - g_scheduler->createProcess(PID_TCODE, RestoredProcess, &pic, sizeof(pic)); + CoroScheduler.createProcess(PID_TCODE, RestoredProcess, &pic, sizeof(pic)); } void RestoreMasterProcess(INT_CONTEXT *pic) { - g_scheduler->createProcess(PID_MASTER_SCR, RestoredProcess, &pic, sizeof(pic)); + CoroScheduler.createProcess(PID_MASTER_SCR, RestoredProcess, &pic, sizeof(pic)); } // FIXME: CountOut is used by ChangeScene @@ -878,7 +878,6 @@ TinselEngine::~TinselEngine() { FreeObjectList(); FreeGlobalProcesses(); FreeGlobals(); - delete _scheduler; delete _config; @@ -905,7 +904,7 @@ Common::Error TinselEngine::run() { _console = new Console(); - _scheduler = new Scheduler(); + CoroScheduler.reset(); InitSysVars(); @@ -1022,7 +1021,7 @@ void TinselEngine::NextGameCycle() { ResetEcount(); // schedule process - _scheduler->schedule(); + CoroScheduler.schedule(); if (_bmv->MoviePlaying()) _bmv->CopyMovieToScreen(); @@ -1078,11 +1077,11 @@ bool TinselEngine::pollEvent() { */ void TinselEngine::CreateConstProcesses() { // Process to run the master script - _scheduler->createProcess(PID_MASTER_SCR, MasterScriptProcess, NULL, 0); + CoroScheduler.createProcess(PID_MASTER_SCR, MasterScriptProcess, NULL, 0); // Processes to run the cursor and inventory, - _scheduler->createProcess(PID_CURSOR, CursorProcess, NULL, 0); - _scheduler->createProcess(PID_INVENTORY, InventoryProcess, NULL, 0); + CoroScheduler.createProcess(PID_CURSOR, CursorProcess, NULL, 0); + CoroScheduler.createProcess(PID_INVENTORY, InventoryProcess, NULL, 0); } /** @@ -1132,11 +1131,11 @@ void TinselEngine::RestartDrivers() { KillAllObjects(); // init the process scheduler - _scheduler->reset(); + CoroScheduler.reset(); // init the event handlers - g_pMouseProcess = _scheduler->createProcess(PID_MOUSE, MouseProcess, NULL, 0); - g_pKeyboardProcess = _scheduler->createProcess(PID_KEYBOARD, KeyboardProcess, NULL, 0); + g_pMouseProcess = CoroScheduler.createProcess(PID_MOUSE, MouseProcess, NULL, 0); + g_pKeyboardProcess = CoroScheduler.createProcess(PID_KEYBOARD, KeyboardProcess, NULL, 0); // open MIDI files OpenMidiFiles(); @@ -1164,8 +1163,8 @@ void TinselEngine::ChopDrivers() { DeleteMidiBuffer(); // remove event drivers - _scheduler->killProcess(g_pMouseProcess); - _scheduler->killProcess(g_pKeyboardProcess); + CoroScheduler.killProcess(g_pMouseProcess); + CoroScheduler.killProcess(g_pKeyboardProcess); } /** diff --git a/engines/tinsel/token.cpp b/engines/tinsel/token.cpp index c26fa40466..080c005c3c 100644 --- a/engines/tinsel/token.cpp +++ b/engines/tinsel/token.cpp @@ -31,7 +31,7 @@ namespace Tinsel { //----------------- LOCAL GLOBAL DATA -------------------- struct Token { - PROCESS *proc; + Common::PROCESS *proc; }; static Token g_tokens[NUMTOKENS]; // FIXME: Avoid non-const global vars @@ -40,7 +40,7 @@ static Token g_tokens[NUMTOKENS]; // FIXME: Avoid non-const global vars /** * Release all tokens held by this process, and kill the process. */ -static void TerminateProcess(PROCESS *tProc) { +static void TerminateProcess(Common::PROCESS *tProc) { // Release tokens held by the process for (int i = 0; i < NUMTOKENS; i++) { @@ -50,7 +50,7 @@ static void TerminateProcess(PROCESS *tProc) { } // Kill the process - g_scheduler->killProcess(tProc); + CoroScheduler.killProcess(tProc); } /** @@ -60,7 +60,7 @@ void GetControlToken() { const int which = TOKEN_CONTROL; if (g_tokens[which].proc == NULL) { - g_tokens[which].proc = g_scheduler->getCurrentProcess(); + g_tokens[which].proc = CoroScheduler.getCurrentProcess(); } } @@ -85,11 +85,11 @@ void GetToken(int which) { assert(TOKEN_LEAD <= which && which < NUMTOKENS); if (g_tokens[which].proc != NULL) { - assert(g_tokens[which].proc != g_scheduler->getCurrentProcess()); + assert(g_tokens[which].proc != CoroScheduler.getCurrentProcess()); TerminateProcess(g_tokens[which].proc); } - g_tokens[which].proc = g_scheduler->getCurrentProcess(); + g_tokens[which].proc = CoroScheduler.getCurrentProcess(); } /** @@ -99,7 +99,7 @@ void GetToken(int which) { void FreeToken(int which) { assert(TOKEN_LEAD <= which && which < NUMTOKENS); - assert(g_tokens[which].proc == g_scheduler->getCurrentProcess()); // we'd have been killed if some other proc had taken this token + assert(g_tokens[which].proc == CoroScheduler.getCurrentProcess()); // we'd have been killed if some other proc had taken this token g_tokens[which].proc = NULL; } -- cgit v1.2.3 From 68c1b0b0e46b0575a4670d1ffda2fa3c8ae94ed8 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 11 May 2012 23:15:59 +1000 Subject: TONY: Refactored Tony to use the Common coroutine scheduler --- engines/tony/adv.h | 2 +- engines/tony/coroutine.h | 6 +-- engines/tony/custom.cpp | 50 +++++++++--------- engines/tony/font.cpp | 36 ++++++------- engines/tony/font.h | 1 + engines/tony/game.cpp | 2 +- engines/tony/gfxengine.cpp | 20 +++---- engines/tony/loc.cpp | 42 +++++++-------- engines/tony/loc.h | 2 +- engines/tony/module.mk | 2 - engines/tony/mpal/mpal.cpp | 92 ++++++++++++++++---------------- engines/tony/mpal/mpal.h | 6 +-- engines/tony/sched.h | 129 --------------------------------------------- engines/tony/sound.cpp | 12 ++--- engines/tony/tony.cpp | 21 ++++---- engines/tony/tony.h | 2 +- engines/tony/tonychar.cpp | 24 ++++----- engines/tony/tonychar.h | 4 +- engines/tony/window.cpp | 6 +-- 19 files changed, 166 insertions(+), 293 deletions(-) (limited to 'engines') diff --git a/engines/tony/adv.h b/engines/tony/adv.h index a1b21c1e08..6a1b6ce246 100644 --- a/engines/tony/adv.h +++ b/engines/tony/adv.h @@ -48,8 +48,8 @@ #ifndef TONY_ADV_H #define TONY_ADV_H +#include "common/coroutines.h" #include "tony/mpal/memory.h" -#include "tony/coroutine.h" #include "tony/gfxcore.h" diff --git a/engines/tony/coroutine.h b/engines/tony/coroutine.h index 24742a22f9..b4eb105f58 100644 --- a/engines/tony/coroutine.h +++ b/engines/tony/coroutine.h @@ -113,7 +113,7 @@ public: * context, and so compilers won't complain about ";" following the macro. */ #define CORO_BEGIN_CONTEXT \ - struct CoroContextTag : CoroBaseContext { \ + struct CoroContextTag : Common::CoroBaseContext { \ CoroContextTag() : CoroBaseContext(SCUMMVM_CURRENT_FUNCTION) {} \ int DUMMY @@ -156,8 +156,8 @@ public: return; case __LINE__:;\ } while (0) -#define CORO_GIVE_WAY do { g_scheduler->giveWay(); CORO_SLEEP(1); } while (0) -#define CORO_RESCHEDULE do { g_scheduler->reschedule(); CORO_SLEEP(1); } while (0) +#define CORO_GIVE_WAY do { CoroScheduler.giveWay(); CORO_SLEEP(1); } while (0) +#define CORO_RESCHEDULE do { CoroScheduler.reschedule(); CORO_SLEEP(1); } while (0) /** * Stop the currently running coroutine and all calling coroutines. diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 5089914d88..234dd0a4f9 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -327,7 +327,7 @@ DECLARE_CUSTOM_FUNCTION(MySleep)(CORO_PARAM, uint32 dwTime, uint32, uint32, uint CORO_BEGIN_CODE(_ctx); if (!bSkipIdle) - CORO_INVOKE_1(g_scheduler->sleep, dwTime); + CORO_INVOKE_1(CoroScheduler.sleep, dwTime); CORO_END_CODE; } @@ -524,8 +524,8 @@ DECLARE_CUSTOM_FUNCTION(CustLoadLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, ui _ctx->h = mpalQueryDoAction(0, nLoc, 0); // On Enter? - if (_ctx->h != INVALID_PID_VALUE) - CORO_INVOKE_2(g_scheduler->waitForSingleObject, _ctx->h, INFINITE); + if (_ctx->h != CORO_INVALID_PID_VALUE) + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->h, CORO_INFINITE); CORO_END_CODE; } @@ -708,8 +708,8 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint bNoOcchioDiBue = false; // On Enter? - if (_ctx->h != INVALID_PID_VALUE) - CORO_INVOKE_2(g_scheduler->waitForSingleObject, _ctx->h, INFINITE); + if (_ctx->h != CORO_INVALID_PID_VALUE) + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->h, CORO_INFINITE); CORO_END_CODE; } @@ -1843,8 +1843,8 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes // Cerca di eseguire la funzione custom per inizializzare la parlata if (MCharacter[nChar].item) { _ctx->h = mpalQueryDoAction(30, MCharacter[nChar].item->MpalCode(), _ctx->parm); - if (_ctx->h != INVALID_PID_VALUE) { - CORO_INVOKE_2(g_scheduler->waitForSingleObject, _ctx->h, INFINITE); + if (_ctx->h != CORO_INVALID_PID_VALUE) { + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->h, CORO_INFINITE); } } @@ -1924,8 +1924,8 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes // Cerca di eseguire la funzione custom per chiudere la parlata if (MCharacter[nChar].item) { _ctx->h = mpalQueryDoAction(31, MCharacter[nChar].item->MpalCode(), _ctx->parm); - if (_ctx->h != INVALID_PID_VALUE) - CORO_INVOKE_2(g_scheduler->waitForSingleObject, _ctx->h, INFINITE); + if (_ctx->h != CORO_INVALID_PID_VALUE) + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->h, CORO_INFINITE); } CORO_END_CODE; @@ -2035,8 +2035,8 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg } else { // Cerca di eseguire la funzione custom per inizializzare la parlata _ctx->h = mpalQueryDoAction(30, MCharacter[nPers].item->MpalCode(), _ctx->parm); - if (_ctx->h != INVALID_PID_VALUE) - CORO_INVOKE_2(g_scheduler->waitForSingleObject, _ctx->h, INFINITE); + if (_ctx->h != CORO_INVALID_PID_VALUE) + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->h, CORO_INFINITE); MCharacter[nPers].curTalk = _ctx->parm; @@ -2099,8 +2099,8 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg // Cerca di eseguire la funzione custom per chiudere la parlata MCharacter[nPers].curTalk = (MCharacter[nPers].curTalk%10) + MCharacter[nPers].curgroup*10; _ctx->h = mpalQueryDoAction(31,MCharacter[nPers].item->MpalCode(),MCharacter[nPers].curTalk); - if (_ctx->h != INVALID_PID_VALUE) - CORO_INVOKE_2(g_scheduler->waitForSingleObject, _ctx->h, INFINITE); + if (_ctx->h != CORO_INVALID_PID_VALUE) + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->h, CORO_INFINITE); MCharacter[nPers].bInTexts = false; MCharacter[nPers].numtexts = 0; @@ -2214,7 +2214,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr DECLARE_CUSTOM_FUNCTION(TakeOwnership)(CORO_PARAM, uint32 num, uint32, uint32, uint32) { // EnterCriticalSection(&cs[num]); -// WaitForSingleObject(mut[num],INFINITE); +// WaitForSingleObject(mut[num],CORO_INFINITE); warning("TODO"); } @@ -2264,7 +2264,7 @@ void ThreadFadeInMusic(CORO_PARAM, const void *nMusic) { for (_ctx->i = 0; _ctx->i < 16; _ctx->i++) { _vm->SetMusicVolume(nChannel, _ctx->i * 4); - CORO_INVOKE_1(g_scheduler->sleep, 100); + CORO_INVOKE_1(CoroScheduler.sleep, 100); } _vm->SetMusicVolume(nChannel, 64); @@ -2293,7 +2293,7 @@ void ThreadFadeOutMusic(CORO_PARAM, const void *nMusic) { if (_ctx->i * 4 < _ctx->startVolume) _vm->SetMusicVolume(nChannel, _ctx->i * 4); - CORO_INVOKE_1(g_scheduler->sleep, 100); + CORO_INVOKE_1(CoroScheduler.sleep, 100); } if (!bFadeOutStop) @@ -2311,23 +2311,23 @@ void ThreadFadeOutMusic(CORO_PARAM, const void *nMusic) { } DECLARE_CUSTOM_FUNCTION(FadeInSonoriz)(CORO_PARAM, uint32, uint32, uint32, uint32) { - g_scheduler->createProcess(ThreadFadeInMusic, &curSonoriz, sizeof(int)); + CoroScheduler.createProcess(ThreadFadeInMusic, &curSonoriz, sizeof(int)); } DECLARE_CUSTOM_FUNCTION(FadeOutSonoriz)(CORO_PARAM, uint32, uint32, uint32, uint32) { bFadeOutStop = false; - g_scheduler->createProcess(ThreadFadeOutMusic, &curSonoriz, sizeof(int)); + CoroScheduler.createProcess(ThreadFadeOutMusic, &curSonoriz, sizeof(int)); } DECLARE_CUSTOM_FUNCTION(FadeOutStacchetto)(CORO_PARAM, uint32, uint32, uint32, uint32) { bFadeOutStop = false; int channel = 2; - g_scheduler->createProcess(ThreadFadeOutMusic, &channel, sizeof(int)); + CoroScheduler.createProcess(ThreadFadeOutMusic, &channel, sizeof(int)); } DECLARE_CUSTOM_FUNCTION(FadeInStacchetto)(CORO_PARAM, uint32, uint32, uint32, uint32) { int channel = 2; - g_scheduler->createProcess(ThreadFadeInMusic, &channel, sizeof(int)); + CoroScheduler.createProcess(ThreadFadeInMusic, &channel, sizeof(int)); } DECLARE_CUSTOM_FUNCTION(StopSonoriz)(CORO_PARAM, uint32, uint32, uint32, uint32) { @@ -2557,12 +2557,12 @@ DECLARE_CUSTOM_FUNCTION(StacchettoFadeEnd)(CORO_PARAM, uint32 nStacc, uint32 bLo DECLARE_CUSTOM_FUNCTION(MustSkipIdleStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { bSkipIdle = true; - g_scheduler->setEvent(hSkipIdle); + CoroScheduler.setEvent(hSkipIdle); } DECLARE_CUSTOM_FUNCTION(MustSkipIdleEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { bSkipIdle = false; - g_scheduler->resetEvent(hSkipIdle); + CoroScheduler.resetEvent(hSkipIdle); } DECLARE_CUSTOM_FUNCTION(PatIrqFreeze)(CORO_PARAM, uint32 bStatus, uint32, uint32, uint32) { @@ -2608,7 +2608,7 @@ DECLARE_CUSTOM_FUNCTION(DoCredits)(CORO_PARAM, uint32 nMsg, uint32 dwTime, uint3 CORO_BEGIN_CODE(_ctx); _ctx->msg = new RMMessage(nMsg); - _ctx->hDisable = g_scheduler->createEvent(true, false); + _ctx->hDisable = CoroScheduler.createEvent(true, false); _ctx->text = new RMTextDialog[_ctx->msg->NumPeriods()]; @@ -2649,7 +2649,7 @@ DECLARE_CUSTOM_FUNCTION(DoCredits)(CORO_PARAM, uint32 nMsg, uint32 dwTime, uint3 break; } - g_scheduler->setEvent(_ctx->hDisable); + CoroScheduler.setEvent(_ctx->hDisable); CORO_INVOKE_0(WaitFrame); CORO_INVOKE_0(WaitFrame); @@ -2882,7 +2882,7 @@ void SetupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation // Crea l'evento per skippare le idle - hSkipIdle = g_scheduler->createEvent(true, false); + hSkipIdle = CoroScheduler.createEvent(true, false); } } // end of namespace Tony diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 5dbbd3f71f..8cc60a917b 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -2048,16 +2048,16 @@ RMTextDialog::RMTextDialog() : RMText() { m_bForceNoTime = false; m_bAlwaysDisplay = false; m_bNoTab = false; - hCustomSkip = INVALID_PID_VALUE; - hCustomSkip2 = INVALID_PID_VALUE; + hCustomSkip = CORO_INVALID_PID_VALUE; + hCustomSkip2 = CORO_INVALID_PID_VALUE; m_input = NULL; // Crea l'evento di fine displaying - hEndDisplay = g_scheduler->createEvent(false, false); + hEndDisplay = CoroScheduler.createEvent(false, false); } RMTextDialog::~RMTextDialog() { - g_scheduler->closeEvent(hEndDisplay); + CoroScheduler.closeEvent(hEndDisplay); } void RMTextDialog::Show(void) { @@ -2119,7 +2119,7 @@ void RMTextDialog::RemoveThis(CORO_PARAM, bool &result) { // Frase NON di background if (m_bSkipStatus) { - if (!(bCfgDubbing && hCustomSkip2 != INVALID_PID_VALUE)) + if (!(bCfgDubbing && hCustomSkip2 != CORO_INVALID_PID_VALUE)) if (bCfgTimerizedText) { if (!m_bForceNoTime) if (_vm->GetTime() > (uint32)m_time + m_startTime) @@ -2137,7 +2137,7 @@ void RMTextDialog::RemoveThis(CORO_PARAM, bool &result) { } // Frase di background else { - if (!(bCfgDubbing && hCustomSkip2 != INVALID_PID_VALUE)) + if (!(bCfgDubbing && hCustomSkip2 != CORO_INVALID_PID_VALUE)) if (!m_bForceNoTime) if (_vm->GetTime() > (uint32)m_time + m_startTime) return; @@ -2148,15 +2148,15 @@ void RMTextDialog::RemoveThis(CORO_PARAM, bool &result) { if (_vm->GetTime() > (uint32)m_time + m_startTime) return; - if (hCustomSkip != INVALID_PID_VALUE) { - CORO_INVOKE_3(g_scheduler->waitForSingleObject, hCustomSkip, 0, &_ctx->expired); + if (hCustomSkip != CORO_INVALID_PID_VALUE) { + CORO_INVOKE_3(CoroScheduler.waitForSingleObject, hCustomSkip, 0, &_ctx->expired); // == WAIT_OBJECT_0 if (!_ctx->expired) return; } - if (bCfgDubbing && hCustomSkip2 != INVALID_PID_VALUE) { - CORO_INVOKE_3(g_scheduler->waitForSingleObject, hCustomSkip2, 0, &_ctx->expired); + if (bCfgDubbing && hCustomSkip2 != CORO_INVALID_PID_VALUE) { + CORO_INVOKE_3(CoroScheduler.waitForSingleObject, hCustomSkip2, 0, &_ctx->expired); // == WAIT_OBJECT_0 if (!_ctx->expired) return; @@ -2170,7 +2170,7 @@ void RMTextDialog::RemoveThis(CORO_PARAM, bool &result) { void RMTextDialog::Unregister(void) { RMGfxTask::Unregister(); assert(m_nInList == 0); - g_scheduler->setEvent(hEndDisplay); + CoroScheduler.setEvent(hEndDisplay); } void RMTextDialog::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { @@ -2194,7 +2194,7 @@ void RMTextDialog::SetCustomSkipHandle2(uint32 hCustom) { } void RMTextDialog::WaitForEndDisplay(CORO_PARAM) { - g_scheduler->waitForSingleObject(coroParam, hEndDisplay, INFINITE); + CoroScheduler.waitForSingleObject(coroParam, hEndDisplay, CORO_INFINITE); } void RMTextDialog::SetInput(RMInput *input) { @@ -2287,10 +2287,10 @@ void RMTextItemName::DoFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation & ptr.SetSpecialPointer(RMPointer::PTR_NONE); else { _ctx->hThread = mpalQueryDoAction(20, m_item->MpalCode(), 0); - if (_ctx->hThread == INVALID_PID_VALUE) + if (_ctx->hThread == CORO_INVALID_PID_VALUE) ptr.SetSpecialPointer(RMPointer::PTR_NONE); else - CORO_INVOKE_2(g_scheduler->waitForSingleObject, _ctx->hThread, INFINITE); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->hThread, CORO_INFINITE); } } @@ -2344,18 +2344,18 @@ RMDialogChoice::RMDialogChoice() { DlgText.LoadPaletteWA(dlgpal); DlgTextLine.LoadPaletteWA(dlgpal); - hUnreg = g_scheduler->createEvent(false, false); + hUnreg = CoroScheduler.createEvent(false, false); bRemoveFromOT = false; } RMDialogChoice::~RMDialogChoice() { - g_scheduler->closeEvent(hUnreg); + CoroScheduler.closeEvent(hUnreg); } void RMDialogChoice::Unregister(void) { RMGfxWoodyBuffer::Unregister(); assert(!m_nInList); - g_scheduler->pulseEvent(hUnreg); + CoroScheduler.pulseEvent(hUnreg); bRemoveFromOT = false; } @@ -2547,7 +2547,7 @@ void RMDialogChoice::Hide(CORO_PARAM) { m_bShow = false; bRemoveFromOT = true; - CORO_INVOKE_2(g_scheduler->waitForSingleObject, hUnreg, INFINITE); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, hUnreg, CORO_INFINITE); CORO_END_CODE; } diff --git a/engines/tony/font.h b/engines/tony/font.h index 0306c6c673..7447f31515 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -49,6 +49,7 @@ #define TONY_FONT_H #include "common/system.h" +#include "common/coroutines.h" #include "tony/gfxcore.h" #include "tony/resid.h" #include "tony/sched.h" diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 377ec73673..820641e48f 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -113,7 +113,7 @@ void MainUnfreeze(void) { } void MainWaitFrame(CORO_PARAM) { - g_scheduler->waitForSingleObject(coroParam, _vm->m_hEndOfFrame, INFINITE); + CoroScheduler.waitForSingleObject(coroParam, _vm->m_hEndOfFrame, CORO_INFINITE); } void MainShowMouse(void) { diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 5a9c0555e0..88aac99ebe 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -140,7 +140,7 @@ void RMGfxEngine::OpenOptionScreen(CORO_PARAM, int type) { bIdleExited = false; - g_scheduler->createProcess(ExitAllIdles, &m_nCurLoc, sizeof(int)); + CoroScheduler.createProcess(ExitAllIdles, &m_nCurLoc, sizeof(int)); } } @@ -242,7 +242,7 @@ void RMGfxEngine::DoFrame(CORO_PARAM, bool bDrawLocation) { if (m_curAction != TA_COMBINE) CORO_INVOKE_3(m_tony.MoveAndDoAction, m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), m_point.CurAction()); else if (m_itemName.GetSelectedItem() != NULL) - CORO_INVOKE_3(m_tony.MoveAndDoAction, m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), TA_COMBINE, m_curActionObj); + CORO_INVOKE_4(m_tony.MoveAndDoAction, m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), TA_COMBINE, m_curActionObj); } if (m_curAction == TA_COMBINE) { @@ -333,7 +333,7 @@ SKIPCLICKSINISTRO: switch (m_nWipeType) { case 1: if (!(m_rcWipeEllipse.bottom - m_rcWipeEllipse.top >= FSTEP * 2)) { - g_scheduler->setEvent(m_hWipeEvent); + CoroScheduler.setEvent(m_hWipeEvent); m_nWipeType = 3; break; } @@ -346,7 +346,7 @@ SKIPCLICKSINISTRO: case 2: if (!(m_rcWipeEllipse.bottom - m_rcWipeEllipse.top < 480 - FSTEP)) { - g_scheduler->setEvent(m_hWipeEvent); + CoroScheduler.setEvent(m_hWipeEvent); m_nWipeType = 3; break; } @@ -529,7 +529,7 @@ uint32 RMGfxEngine::LoadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { m_bLocationLoaded = true; // On Enter per la locazion - return INVALID_PID_VALUE; //mpalQueryDoAction(0,m_nCurLoc,0); + return CORO_INVALID_PID_VALUE; //mpalQueryDoAction(0,m_nCurLoc,0); } void RMGfxEngine::UnloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result) { @@ -545,8 +545,8 @@ void RMGfxEngine::UnloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result) { // On Exit? if (bDoOnExit) { _ctx->h = mpalQueryDoAction(1, m_nCurLoc, 0); - if (_ctx->h != INVALID_PID_VALUE) - CORO_INVOKE_2(g_scheduler->waitForSingleObject, _ctx->h, INFINITE); + if (_ctx->h != CORO_INVALID_PID_VALUE) + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->h, CORO_INFINITE); } MainFreeze(); @@ -557,7 +557,7 @@ void RMGfxEngine::UnloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result) { m_loc.Unload(); if (result != NULL) - *result = INVALID_PID_VALUE; + *result = CORO_INVALID_PID_VALUE; CORO_END_CODE; } @@ -598,7 +598,7 @@ void RMGfxEngine::Init(/*HINSTANCE hInst*/) { bIdleExited = false; m_bOption = false; m_bWiping = false; - m_hWipeEvent = g_scheduler->createEvent(false, false); + m_hWipeEvent = CoroScheduler.createEvent(false, false); // Crea l'evento di freeze csMainLoop = g_system->createMutex(); @@ -1003,7 +1003,7 @@ void RMGfxEngine::CloseWipe(void) { } void RMGfxEngine::WaitWipeEnd(CORO_PARAM) { - g_scheduler->waitForSingleObject(coroParam, m_hWipeEvent, INFINITE); + CoroScheduler.waitForSingleObject(coroParam, m_hWipeEvent, CORO_INFINITE); } } // End of namespace Tony diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 080e06da87..e4a60cb52a 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -253,7 +253,7 @@ int RMPattern::Update(uint32 hEndPattern, byte &bFlag, RMSfx *sfx) { // Se la speed e' 0, il pattern non avanza mai if (m_speed == 0) { - g_scheduler->pulseEvent(hEndPattern); + CoroScheduler.pulseEvent(hEndPattern); bFlag=m_slots[m_nCurSlot].m_flag; return m_nCurSprite; } @@ -267,7 +267,7 @@ int RMPattern::Update(uint32 hEndPattern, byte &bFlag, RMSfx *sfx) { m_nCurSlot = 0; bFlag = m_slots[m_nCurSlot].m_flag; - g_scheduler->pulseEvent(hEndPattern); + CoroScheduler.pulseEvent(hEndPattern); // @@@ Se non c'e' loop avverte che il pattern e' finito // Se non c'e' loop rimane sull'ultimo frame @@ -835,12 +835,12 @@ RMItem::RMItem() { m_bPal = 0; m_nCurSprite = 0; - m_hEndPattern = g_scheduler->createEvent(false, false); + m_hEndPattern = CoroScheduler.createEvent(false, false); } RMItem::~RMItem() { Unload(); - g_scheduler->closeEvent(m_hEndPattern); + CoroScheduler.closeEvent(m_hEndPattern); } //FIXME: Pass uint32 directly for hCustomSkip @@ -852,12 +852,12 @@ void RMItem::WaitForEndPattern(CORO_PARAM, uint32 hCustomSkip) { CORO_BEGIN_CODE(_ctx); if (m_nCurPattern != 0) { - if (hCustomSkip == INVALID_PID_VALUE) - CORO_INVOKE_2(g_scheduler->waitForSingleObject, m_hEndPattern, INFINITE); + if (hCustomSkip == CORO_INVALID_PID_VALUE) + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, m_hEndPattern, CORO_INFINITE); else { _ctx->h[0] = hCustomSkip; _ctx->h[1] = m_hEndPattern; - CORO_INVOKE_4(g_scheduler->waitForMultipleObjects, 2, &_ctx->h[0], false, INFINITE); + CORO_INVOKE_4(CoroScheduler.waitForMultipleObjects, 2, &_ctx->h[0], false, CORO_INFINITE); } } @@ -888,13 +888,13 @@ void RMItem::PauseSound(bool bPause) { RMWipe::RMWipe() { - m_hUnregistered = g_scheduler->createEvent(false, false); - m_hEndOfFade = g_scheduler->createEvent(false, false); + m_hUnregistered = CoroScheduler.createEvent(false, false); + m_hEndOfFade = CoroScheduler.createEvent(false, false); } RMWipe::~RMWipe() { - g_scheduler->closeEvent(m_hUnregistered); - g_scheduler->closeEvent(m_hEndOfFade); + CoroScheduler.closeEvent(m_hUnregistered); + CoroScheduler.closeEvent(m_hEndOfFade); } int RMWipe::Priority(void) { @@ -904,7 +904,7 @@ int RMWipe::Priority(void) { void RMWipe::Unregister(void) { RMGfxTask::Unregister(); assert(m_nInList == 0); - g_scheduler->setEvent(m_hUnregistered); + CoroScheduler.setEvent(m_hUnregistered); } bool RMWipe::RemoveThis(void) { @@ -917,7 +917,7 @@ void RMWipe::WaitForFadeEnd(CORO_PARAM) { CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_2(g_scheduler->waitForSingleObject, m_hEndOfFade, INFINITE); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, m_hEndOfFade, CORO_INFINITE); m_bEndFade = true; m_bFading = false; @@ -930,7 +930,7 @@ void RMWipe::WaitForFadeEnd(CORO_PARAM) { void RMWipe::CloseFade(void) { // m_bUnregister=true; -// WaitForSingleObject(m_hUnregistered,INFINITE); +// WaitForSingleObject(m_hUnregistered,CORO_INFINITE); m_wip0r.Unload(); } @@ -967,7 +967,7 @@ void RMWipe::DoFrame(RMGfxTargetBuffer &bigBuf) { m_nFadeStep++; if (m_nFadeStep == 10) { - g_scheduler->setEvent(m_hEndOfFade); + CoroScheduler.setEvent(m_hEndOfFade); } } } @@ -1096,7 +1096,7 @@ void RMCharacter::GoTo(CORO_PARAM, RMPoint destcoord, bool bReversed) { if (m_pos == destcoord) { if (minpath == 0) { CORO_INVOKE_0(Stop); - g_scheduler->pulseEvent(hEndOfPath); + CoroScheduler.pulseEvent(hEndOfPath); return; } } @@ -1478,7 +1478,7 @@ void RMCharacter::DoFrame(CORO_PARAM, RMGfxTargetBuffer* bigBuf, int loc) { if (!bEndOfPath) CORO_INVOKE_0(Stop); bEndOfPath = true; - g_scheduler->pulseEvent(hEndOfPath); + CoroScheduler.pulseEvent(hEndOfPath); } walkcount++; @@ -1516,7 +1516,7 @@ void RMCharacter::DoFrame(CORO_PARAM, RMGfxTargetBuffer* bigBuf, int loc) { if (!bEndOfPath) CORO_INVOKE_0(Stop); bEndOfPath = true; - g_scheduler->pulseEvent(hEndOfPath); + CoroScheduler.pulseEvent(hEndOfPath); } } else { // Se siamo gi entrati nell'ultimo box, dobbiamo solo muoverci in linea retta verso il @@ -1687,7 +1687,7 @@ void RMCharacter::WaitForEndMovement(CORO_PARAM) { CORO_BEGIN_CODE(_ctx); if (bMoving) - CORO_INVOKE_2(g_scheduler->waitForSingleObject, hEndOfPath, INFINITE); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, hEndOfPath, CORO_INFINITE); CORO_END_CODE; } @@ -1701,7 +1701,7 @@ bool RMCharacter::RemoveThis(void) { RMCharacter::RMCharacter() { csMove = g_system->createMutex(); - hEndOfPath = g_scheduler->createEvent(false, false); + hEndOfPath = CoroScheduler.createEvent(false, false); minpath = 0; curSpeed = 3; bRemoveFromOT = false; @@ -1722,7 +1722,7 @@ RMCharacter::RMCharacter() { RMCharacter::~RMCharacter() { g_system->deleteMutex(csMove); - g_scheduler->closeEvent(hEndOfPath); + CoroScheduler.closeEvent(hEndOfPath); } void RMCharacter::LinkToBoxes(RMGameBoxes *boxes) { diff --git a/engines/tony/loc.h b/engines/tony/loc.h index f5826022e0..4b8946da54 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -292,7 +292,7 @@ public: void Unload(void); // Aspetta la fine del pattern in play - void WaitForEndPattern(CORO_PARAM, uint32 hCustomSkip = INVALID_PID_VALUE); + void WaitForEndPattern(CORO_PARAM, uint32 hCustomSkip = CORO_INVALID_PID_VALUE); // Setta un nuovo hotspot per l'oggetto void ChangeHotspot(RMPoint pt); diff --git a/engines/tony/module.mk b/engines/tony/module.mk index 24e7f70557..af0b3acd2c 100644 --- a/engines/tony/module.mk +++ b/engines/tony/module.mk @@ -1,7 +1,6 @@ MODULE := engines/tony MODULE_OBJS := \ - coroutine.o \ custom.o \ detection.o \ font.o \ @@ -11,7 +10,6 @@ MODULE_OBJS := \ input.o \ inventory.o \ loc.o \ - sched.o \ sound.o \ tony.o \ tonychar.o \ diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index e82df11328..42c790a1c7 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -883,13 +883,13 @@ void ScriptThread(CORO_PARAM, const void *param) { for (_ctx->i = 0; _ctx->i < s->nMoments; _ctx->i++) { // Dorme il tempo necessario per arrivare al momento successivo if (s->Moment[_ctx->i].dwTime == -1) { - CORO_INVOKE_4(g_scheduler->waitForMultipleObjects, _ctx->numHandles, cfHandles, true, INFINITE); + CORO_INVOKE_4(CoroScheduler.waitForMultipleObjects, _ctx->numHandles, cfHandles, true, CORO_INFINITE); _ctx->dwStartTime = _vm->GetTime(); } else { _ctx->dwCurTime = _vm->GetTime(); if (_ctx->dwCurTime < _ctx->dwStartTime + (s->Moment[_ctx->i].dwTime * 100)) { // warning("PlayScript(): Sleeping %lums\n",_ctx->dwStartTime+(s->Moment[_ctx->i].dwTime*100)-_ctx->dwCurTime); - CORO_INVOKE_1(g_scheduler->sleep, _ctx->dwStartTime+(s->Moment[_ctx->i].dwTime * 100) - _ctx->dwCurTime); + CORO_INVOKE_1(CoroScheduler.sleep, _ctx->dwStartTime+(s->Moment[_ctx->i].dwTime * 100) - _ctx->dwCurTime); } } @@ -913,7 +913,7 @@ void ScriptThread(CORO_PARAM, const void *param) { _ctx->p->arg4=s->Command[_ctx->k].arg4; // !!! Nuova gestione dei thread - if ((cfHandles[_ctx->numHandles++] = g_scheduler->createProcess(CustomThread, &_ctx->p, sizeof(LPCFCALL))) == 0) { + if ((cfHandles[_ctx->numHandles++] = CoroScheduler.createProcess(CustomThread, &_ctx->p, sizeof(LPCFCALL))) == 0) { mpalError = 1; CORO_KILL_SELF(); @@ -976,7 +976,7 @@ void ActionThread(CORO_PARAM, const void *param) { if (item->Command[_ctx->k].type == 1) { // Custom function debugC(DEBUG_DETAILED, kTonyDebugActions, "Action Process %d Call=%s params=%d,%d,%d,%d", - g_scheduler->getCurrentPID(), lplpFunctionStrings[item->Command[_ctx->k].nCf].c_str(), + CoroScheduler.getCurrentPID(), lplpFunctionStrings[item->Command[_ctx->k].nCf].c_str(), item->Command[_ctx->k].arg1, item->Command[_ctx->k].arg2, item->Command[_ctx->k].arg3, item->Command[_ctx->k].arg4 ); @@ -991,7 +991,7 @@ void ActionThread(CORO_PARAM, const void *param) { } else if (item->Command[_ctx->k].type == 2) { // Variable assign debugC(DEBUG_DETAILED, kTonyDebugActions, "Action Process %d Variable=%s", - g_scheduler->getCurrentPID(), item->Command[_ctx->k].lpszVarName); + CoroScheduler.getCurrentPID(), item->Command[_ctx->k].lpszVarName); LockVar(); varSetValue(item->Command[_ctx->k].lpszVarName, EvaluateExpression(item->Command[_ctx->k].expr)); @@ -1005,7 +1005,7 @@ void ActionThread(CORO_PARAM, const void *param) { GlobalFree(item); - debugC(DEBUG_DETAILED, kTonyDebugActions, "Action Process %d ended", g_scheduler->getCurrentPID()); + debugC(DEBUG_DETAILED, kTonyDebugActions, "Action Process %d ended", CoroScheduler.getCurrentPID()); CORO_KILL_SELF(); @@ -1026,7 +1026,7 @@ void ShutUpActionThread(CORO_PARAM, const void *param) { CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_2(g_scheduler->waitForSingleObject, pid, INFINITE); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, pid, CORO_INFINITE); bExecutingAction = false; @@ -1200,7 +1200,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { /* Ci addormentiamo, ma controllando sempre l'evento che viene settato quando viene richiesta la nostra chiusura */ - CORO_INVOKE_3(g_scheduler->waitForSingleObject, hEndPollingLocations[id], _ctx->dwSleepTime, &_ctx->expired); + CORO_INVOKE_3(CoroScheduler.waitForSingleObject, hEndPollingLocations[id], _ctx->dwSleepTime, &_ctx->expired); //if (_ctx->k == WAIT_OBJECT_0) if (!_ctx->expired) @@ -1208,7 +1208,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) if (_ctx->MyThreads[_ctx->i].nItem != 0) { - CORO_INVOKE_3(g_scheduler->waitForSingleObject, _ctx->MyThreads[_ctx->i].hThread, 0, &_ctx->delayExpired); + CORO_INVOKE_3(CoroScheduler.waitForSingleObject, _ctx->MyThreads[_ctx->i].hThread, 0, &_ctx->delayExpired); // if result ) == WAIT_OBJECT_0) if (!_ctx->delayExpired) @@ -1279,7 +1279,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { _ctx->MyThreads[_ctx->i].nItem = _ctx->MyActions[_ctx->k].nItem; // !!! Nuova gestione dei thread - if ((_ctx->MyThreads[_ctx->i].hThread = g_scheduler->createProcess(ActionThread, &_ctx->newItem, sizeof(LPMPALITEM))) == 0) { + if ((_ctx->MyThreads[_ctx->i].hThread = CoroScheduler.createProcess(ActionThread, &_ctx->newItem, sizeof(LPMPALITEM))) == 0) { //if ((_ctx->MyThreads[_ctx->i].hThread=(void*)_beginthread(ActionThread, 10240,(void *)_ctx->newItem))==(void*)-1) GlobalFree(_ctx->newItem); GlobalFree(_ctx->MyThreads); @@ -1309,18 +1309,18 @@ void LocationPollThread(CORO_PARAM, const void *param) { // Set idle skip on // FIXME: Convert to co-routine - lplpFunctions[200](nullContext, 0, 0, 0, 0); + CORO_INVOKE_4(lplpFunctions[200], 0, 0, 0, 0); for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) if (_ctx->MyThreads[_ctx->i].nItem != 0) { - CORO_INVOKE_3(g_scheduler->waitForSingleObject, _ctx->MyThreads[_ctx->i].hThread, 5000, &_ctx->delayExpired); + CORO_INVOKE_3(CoroScheduler.waitForSingleObject, _ctx->MyThreads[_ctx->i].hThread, 5000, &_ctx->delayExpired); /* //if (result != WAIT_OBJECT_0) if (_ctx->delayExpired) TerminateThread(_ctx->MyThreads[_ctx->i].hThread, 0); */ - g_scheduler->killMatchingProcess(_ctx->MyThreads[_ctx->i].hThread); + CoroScheduler.killMatchingProcess(_ctx->MyThreads[_ctx->i].hThread); } // Set idle skip off @@ -1361,13 +1361,13 @@ void ShutUpDialogThread(CORO_PARAM, const void *param) { CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_2(g_scheduler->waitForSingleObject, pid, INFINITE); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, pid, CORO_INFINITE); bExecutingDialog = false; nExecutingDialog = 0; nExecutingChoice = 0; - g_scheduler->setEvent(hAskChoice); + CoroScheduler.setEvent(hAskChoice); CORO_KILL_SELF(); @@ -1519,9 +1519,9 @@ void DoChoice(CORO_PARAM, uint32 nChoice) { /* Avvertiamo il gioco che c'e' una scelta da far fare all'utente, e restiamo in attesa della risposta */ - g_scheduler->resetEvent(hDoneChoice); - g_scheduler->setEvent(hAskChoice); - CORO_INVOKE_2(g_scheduler->waitForSingleObject, hDoneChoice, INFINITE); + CoroScheduler.resetEvent(hDoneChoice); + CoroScheduler.setEvent(hAskChoice); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, hDoneChoice, CORO_INFINITE); /* Ora che la scelta e' stata effettuata, possiamo eseguire _ctx->i gruppi associati con la scelta */ @@ -1569,7 +1569,7 @@ void DoChoice(CORO_PARAM, uint32 nChoice) { * uint32 dwParam Eventuale parametro per l'azione * * Return: Handle del thread che sta eseguendo l'azione, oppure -* INVALID_PID_VALUE se l'azione non e' definita, o l'item +* CORO_INVALID_PID_VALUE se l'azione non e' definita, o l'item * e' disattivato. * * Note: Si puo' ottenere l'indice dell'item a partire dal suo numero @@ -1588,7 +1588,7 @@ static uint32 DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { item+=ordItem; Common::String buf = Common::String::format("Status.%u", item->nObj); if (varGetValue(buf.c_str()) <= 0) - return INVALID_PID_VALUE; + return CORO_INVALID_PID_VALUE; for (i = 0; i < item->nActions; i++) { if (item->Action[i].num != nAction) @@ -1606,7 +1606,7 @@ static uint32 DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { // Duplichiamo l'item corrente e copiamo la azione #i nella #0 newitem = (LPMPALITEM)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MPALITEM)); if (newitem == NULL) - return INVALID_PID_VALUE; + return CORO_INVALID_PID_VALUE; // Nella nuova versione scriviamo il numero dell'azione in dwRes Common::copy((byte *)item, (byte *)item + sizeof(MPALITEM), (byte *)newitem); @@ -1619,11 +1619,11 @@ static uint32 DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { // 0 dell'item, e poi liberera' la memoria con la GlobalFree() // !!! New thread management - if ((h = g_scheduler->createProcess(ActionThread, &newitem, sizeof(LPMPALITEM))) == NULL) - return INVALID_PID_VALUE; + if ((h = CoroScheduler.createProcess(ActionThread, &newitem, sizeof(LPMPALITEM))) == NULL) + return CORO_INVALID_PID_VALUE; - if (g_scheduler->createProcess(ShutUpActionThread, &h, sizeof(uint32)) == NULL) - return INVALID_PID_VALUE; + if (CoroScheduler.createProcess(ShutUpActionThread, &h, sizeof(uint32)) == NULL) + return CORO_INVALID_PID_VALUE; nExecutingAction = item->nObj; bExecutingAction = true; @@ -1631,7 +1631,7 @@ static uint32 DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { return h; } - return INVALID_PID_VALUE; + return CORO_INVALID_PID_VALUE; } /** @@ -1640,7 +1640,7 @@ static uint32 DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { * @param nDlgOrd The index of the dialog in the dialog list * @param nGroup Number of the group to perform * @returns The process Id of the process running the dialog - * or INVALID_PID_VALUE on error + * or CORO_INVALID_PID_VALUE on error * @remarks The dialogue runs in a thread created on purpose, * so that must inform through an event and when 'necessary to you make a choice. * The data on the choices may be obtained through various queries. @@ -1654,20 +1654,20 @@ static uint32 DoDialog(uint32 nDlgOrd, uint32 nGroup) { // Enables the flag to indicate that there is' a running dialogue bExecutingDialog = true; - g_scheduler->resetEvent(hAskChoice); - g_scheduler->resetEvent(hDoneChoice); + CoroScheduler.resetEvent(hAskChoice); + CoroScheduler.resetEvent(hDoneChoice); // Create a thread that performs the dialogue group // Create the process - if ((h = g_scheduler->createProcess(GroupThread, &nGroup, sizeof(uint32))) == INVALID_PID_VALUE) - return INVALID_PID_VALUE; + if ((h = CoroScheduler.createProcess(GroupThread, &nGroup, sizeof(uint32))) == CORO_INVALID_PID_VALUE) + return CORO_INVALID_PID_VALUE; // Create a thread that waits until the end of the dialog process, and will restore the global variables - if (g_scheduler->createProcess(ShutUpDialogThread, &h, sizeof(uint32)) == INVALID_PID_VALUE) { + if (CoroScheduler.createProcess(ShutUpDialogThread, &h, sizeof(uint32)) == CORO_INVALID_PID_VALUE) { // Something went wrong, so kill the previously started dialog process - g_scheduler->killMatchingProcess(h); - return INVALID_PID_VALUE; + CoroScheduler.killMatchingProcess(h); + return CORO_INVALID_PID_VALUE; } return h; @@ -1700,7 +1700,7 @@ bool DoSelection(uint32 i, uint32 dwData) { return false; nSelectedChoice = j; - g_scheduler->setEvent(hDoneChoice); + CoroScheduler.setEvent(hDoneChoice); return true; } @@ -1877,8 +1877,8 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, /* Crea l'evento che verra' utilizzato per avvertire il gioco che c'e' da effettuare una scelta */ - hAskChoice = g_scheduler->createEvent(true, false); - hDoneChoice = g_scheduler->createEvent(true, false); + hAskChoice = CoroScheduler.createEvent(true, false); + hDoneChoice = CoroScheduler.createEvent(true, false); return true; } @@ -2070,7 +2070,7 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { if (y != -1) { dwRet = DoAction(x, y, GETARG(uint32)); } else { - dwRet = INVALID_PID_VALUE; + dwRet = CORO_INVALID_PID_VALUE; mpalError = 1; } @@ -2278,9 +2278,9 @@ void mpalQueryCORO(CORO_PARAM, uint16 wQueryType, uint32 *dwRet, ...) { /* * void mpalQuery(MPQ_DIALOG_WAITFORCHOICE); */ - CORO_INVOKE_2(g_scheduler->waitForSingleObject, hAskChoice, INFINITE); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, hAskChoice, CORO_INFINITE); - g_scheduler->resetEvent(hAskChoice); + CoroScheduler.resetEvent(hAskChoice); if (bExecutingDialog) *dwRet = (uint32)nExecutingChoice; @@ -2338,7 +2338,7 @@ bool EXPORT mpalExecuteScript(int nScript) { UnlockScripts(); // !!! Nuova gestione dei thread - if (g_scheduler->createProcess(ScriptThread, &s, sizeof(LPMPALSCRIPT)) == INVALID_PID_VALUE) + if (CoroScheduler.createProcess(ScriptThread, &s, sizeof(LPMPALSCRIPT)) == CORO_INVALID_PID_VALUE) return false; return true; @@ -2388,9 +2388,9 @@ bool mpalStartIdlePoll(int nLoc) { if (nPollingLocations[i] == 0) { nPollingLocations[i] = nLoc; - hEndPollingLocations[i] = g_scheduler->createEvent(true, false); + hEndPollingLocations[i] = CoroScheduler.createEvent(true, false); // !!! Nuova gestione dei thread - if ((PollingThreads[i] = g_scheduler->createProcess(LocationPollThread, &i, sizeof(uint32))) == 0) + if ((PollingThreads[i] = CoroScheduler.createProcess(LocationPollThread, &i, sizeof(uint32))) == 0) // if ((hEndPollingLocations[i]=(void*)_beginthread(LocationPollThread, 10240,(void *)i))==(void*)-1) return false; @@ -2425,11 +2425,11 @@ void mpalEndIdlePoll(CORO_PARAM, int nLoc, bool *result) { for (_ctx->i = 0; _ctx->i < MAXPOLLINGLOCATIONS; _ctx->i++) { if (nPollingLocations[_ctx->i] == (uint32)nLoc) { - g_scheduler->setEvent(hEndPollingLocations[_ctx->i]); + CoroScheduler.setEvent(hEndPollingLocations[_ctx->i]); - CORO_INVOKE_2(g_scheduler->waitForSingleObject, PollingThreads[_ctx->i], INFINITE); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, PollingThreads[_ctx->i], CORO_INFINITE); - g_scheduler->closeEvent(hEndPollingLocations[_ctx->i]); + CoroScheduler.closeEvent(hEndPollingLocations[_ctx->i]); nPollingLocations[_ctx->i] = 0; if (result) diff --git a/engines/tony/mpal/mpal.h b/engines/tony/mpal/mpal.h index cd46219b57..49601bc1e9 100644 --- a/engines/tony/mpal/mpal.h +++ b/engines/tony/mpal/mpal.h @@ -118,9 +118,9 @@ #define TONY_MPAL_H #include "common/scummsys.h" +#include "common/coroutines.h" #include "common/rect.h" #include "common/str.h" -#include "tony/coroutine.h" namespace Tony { @@ -537,7 +537,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * uint32 dwParam Action parameter * * Return: Handle to the thread that is performing the action, or -* INVALID_PID_VALUE if the action is not 'defined for +* CORO_INVALID_PID_VALUE if the action is not 'defined for * the item, or the item and 'off. * * Note: The parameter is used primarily to implement actions @@ -561,7 +561,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * uint32 nGroup Group number to use * * Return: Handle to the thread that is running the box, or -* INVALID_PID_VALUE if the dialogue does not exist. +* CORO_INVALID_PID_VALUE if the dialogue does not exist. * \****************************************************************************/ diff --git a/engines/tony/sched.h b/engines/tony/sched.h index a9868edad0..f7dabd47ae 100644 --- a/engines/tony/sched.h +++ b/engines/tony/sched.h @@ -24,133 +24,4 @@ #ifndef TONY_SCHED_H #define TONY_SCHED_H -#include "common/list.h" -#include "tony/coroutine.h" - -namespace Tony { - -// the size of process specific info -#define PARAM_SIZE 32 - -// the maximum number of processes -#define NUM_PROCESS 100 -#define MAX_PROCESSES 100 - -#define INFINITE 0xffffffff -#define INVALID_PID_VALUE 0 - -typedef void (*CORO_ADDR)(CoroContext &, const void *); - -/** process structure */ -struct PROCESS { - PROCESS *pNext; ///< pointer to next process in active or free list - PROCESS *pPrevious; ///< pointer to previous process in active or free list - - CoroContext state; ///< the state of the coroutine - CORO_ADDR coroAddr; ///< the entry point of the coroutine - - int sleepTime; ///< number of scheduler cycles to sleep - uint32 pid; ///< process ID - bool waiting; ///< process is currently in a waiting state - char param[PARAM_SIZE]; ///< process specific info -}; -typedef PROCESS *PPROCESS; - -struct INT_CONTEXT; - -/** Event structure */ -struct EVENT { - uint32 pid; - bool manualReset; - bool signalled; -}; - -/** - * Create and manage "processes" (really coroutines). - */ -class Scheduler { -public: - /** Pointer to a function of the form "void function(PPROCESS)" */ - typedef void (*VFPTRPP)(PROCESS *); - -private: - - /** list of all processes */ - PROCESS *processList; - - /** active process list - also saves scheduler state */ - PROCESS *active; - - /** pointer to free process list */ - PROCESS *pFreeProcesses; - - /** the currently active process */ - PROCESS *pCurrent; - - /** Auto-incrementing process Id */ - int pidCounter; - - /** Event list */ - Common::List _events; - -#ifdef DEBUG - // diagnostic process counters - int numProcs; - int maxProcs; - - void CheckStack(); -#endif - - /** - * Called from killProcess() to enable other resources - * a process may be allocated to be released. - */ - VFPTRPP pRCfunction; - - PROCESS *getProcess(uint32 pid); - EVENT *getEvent(uint32 pid); -public: - - Scheduler(); - ~Scheduler(); - - void reset(); - - #ifdef DEBUG - void printStats(); - #endif - - void schedule(); - void rescheduleAll(); - void reschedule(PPROCESS pReSchedProc = NULL); - void giveWay(PPROCESS pReSchedProc = NULL); - void waitForSingleObject(CORO_PARAM, int pid, uint32 duration, bool *expired = NULL); - void waitForMultipleObjects(CORO_PARAM, int nCount, uint32 *pidList, bool bWaitAll, - uint32 duration, bool *expired = NULL); - void Scheduler::sleep(CORO_PARAM, uint32 duration); - - uint32 createProcess(CORO_ADDR coroAddr, const void *pParam, int sizeParam); - uint32 createProcess(CORO_ADDR coroAddr, const void *pParam) { - return createProcess(coroAddr, &pParam, sizeof(void *)); - } - void killProcess(PROCESS *pKillProc); - - PROCESS *getCurrentProcess(); - int getCurrentPID() const; - int killMatchingProcess(uint32 pidKill, int pidMask = -1); - - void setResourceCallback(VFPTRPP pFunc); - - /* Event methods */ - uint32 createEvent(bool bManualReset, bool bInitialState); - void closeEvent(uint32 pidEvent); - void setEvent(uint32 pidEvent); - void resetEvent(uint32 pidEvent); - void pulseEvent(uint32 pidEvent); -}; - -extern Scheduler *g_scheduler; // FIXME: Temporary global var, to be used until everything has been OOifyied - -} // End of namespace Tony - #endif // TONY_SCHED_H diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index a2b3d7c8ce..c8caf5043d 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -1021,7 +1021,7 @@ FPSFX::FPSFX(LPDIRECTSOUND lpds, HWND hWnd, bool bSoundOn) { lpDSNotify = NULL; lpDS = lpds; lastVolume = 63; - hEndOfBuffer = INVALID_PID_VALUE; + hEndOfBuffer = CORO_INVALID_PID_VALUE; bIsVoice = false; if (bSoundSupported == false) @@ -1053,7 +1053,7 @@ FPSFX::~FPSFX() { RELEASE(lpDSNotify); - if (hEndOfBuffer != INVALID_PID_VALUE) + if (hEndOfBuffer != CORO_INVALID_PID_VALUE) CloseHandle(hEndOfBuffer); RELEASE(lpDSBuffer); @@ -1415,7 +1415,7 @@ bool FPSFX::LoadFile(const char *lpszFileName, uint32 dwCodec) { bool FPSFX::Play() { #ifdef REFACTOR_ME if (bFileLoaded) { - if (hEndOfBuffer != INVALID_PID_VALUE) + if (hEndOfBuffer != CORO_INVALID_PID_VALUE) ResetEvent(hEndOfBuffer); lpDSBuffer->SetCurrentPosition(0); @@ -2012,7 +2012,7 @@ bool FPSTREAM::Stop(bool bSync) { /* Avverte il thread che deve uscire e aspetta che si chiuda */ SetEvent(hThreadEnd); - WaitForSingleObject(hPlayThread, INFINITE); + WaitForSingleObject(hPlayThread, CORO_INFINITE); /* Chiude l'handle del thread e disalloca la memoria temporanea */ CloseHandle(hPlayThread); @@ -2048,7 +2048,7 @@ void FPSTREAM::WaitForSync(FPSTREAM *toplay) { this->lpDSBuffer, &this->SyncToPlay, SyncToPlay, &bSyncExit, bSyncExit, GetCurrentThreadId()); warning(buf); - WaitForSingleObject(hPlayThread, INFINITE); + WaitForSingleObject(hPlayThread, CORO_INFINITE); /* Chiude l'handle del thread e disalloca la memoria temporanea */ CloseHandle(hPlayThread); @@ -2109,7 +2109,7 @@ void PASCAL FPSTREAM::PlayThread(FPSTREAM *This) { // sprintf(buf, "WFMO: %x (buf status: %x) MyThread: 0x%x\n", This->lpDSBuffer, dwBufStatus, GetCurrentThreadId()); // warning(buf); - dwResult = WaitForMultipleObjects(5, hList, false, INFINITE); + dwResult = WaitForMultipleObjects(5, hList, false, CORO_INFINITE); /* uint32 dwPlay, dwWrite; This->lpDSBuffer->GetCurrentPosition(&dwPlay, &dwWrite); diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index d8ea05d06a..ece1904810 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -36,7 +36,7 @@ namespace Tony { TonyEngine *_vm; TonyEngine::TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc) : Engine(syst), - _gameDescription(gameDesc), _randomSource("tony"), _scheduler() { + _gameDescription(gameDesc), _randomSource("tony") { _vm = this; DebugMan.addDebugChannel(kTonyDebugAnimations, "animations", "Animations debugging"); @@ -48,6 +48,9 @@ TonyEngine::TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc) : Eng TonyEngine::~TonyEngine() { // Close the voice database CloseVoiceDatabase(); + + // Reset the coroutine scheduler + CoroScheduler.reset(); } /** @@ -68,14 +71,14 @@ Common::Error TonyEngine::run() { * Initialise the game */ Common::ErrorCode TonyEngine::Init() { - m_hEndOfFrame = g_scheduler->createEvent(false, false); + m_hEndOfFrame = CoroScheduler.createEvent(false, false); m_bPaused = false; m_bDrawLocation = true; m_startTime = g_system->getMillis(); // Reset the scheduler - _scheduler.reset(); + CoroScheduler.reset(); // Initialise the graphics window _window.Init(); @@ -413,7 +416,7 @@ void TonyEngine::PlayProcess(CORO_PARAM, const void *param) { CORO_BEGIN_CODE(_ctx); - // Infinite loop. We rely on the outer main process to detect if a shutdown is required, + // CORO_INFINITE loop. We rely on the outer main process to detect if a shutdown is required, // and kill the scheudler and all the processes, including this one for (;;) { // Se siamo in pausa, entra nel loop appropriato @@ -421,14 +424,14 @@ void TonyEngine::PlayProcess(CORO_PARAM, const void *param) { _vm->PauseLoop(); // Wait for the next frame - CORO_INVOKE_1(g_scheduler->sleep, 50); + CORO_INVOKE_1(CoroScheduler.sleep, 50); // Call the engine to handle the next frame // FIXME: This needs to be moved into it's own process CORO_INVOKE_1(_vm->_theEngine.DoFrame, _vm->m_bDrawLocation); // Warns that a frame is finished - g_scheduler->pulseEvent(_vm->m_hEndOfFrame); + CoroScheduler.pulseEvent(_vm->m_hEndOfFrame); // Handle drawing the frame if (!_vm->m_bPaused) { @@ -450,7 +453,7 @@ void TonyEngine::PlayProcess(CORO_PARAM, const void *param) { */ void TonyEngine::Play(void) { // Create the game player process - g_scheduler->createProcess(PlayProcess, NULL); + CoroScheduler.createProcess(PlayProcess, NULL); // Loop through calling the scheduler until it's time for the game to quit while (!shouldQuit() && !m_bQuitNow) { @@ -458,7 +461,7 @@ void TonyEngine::Play(void) { g_system->delayMillis(10); // Call any scheduled processes - _scheduler.schedule(); + CoroScheduler.schedule(); } } @@ -466,7 +469,7 @@ void TonyEngine::Play(void) { void TonyEngine::Close(void) { CloseMusic(); - g_scheduler->closeEvent(m_hEndOfFrame); + CoroScheduler.closeEvent(m_hEndOfFrame); _theBoxes.Close(); _theEngine.Close(); _window.Close(); diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 935f805912..d8104e641b 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -26,6 +26,7 @@ #include "common/scummsys.h" #include "common/system.h" #include "common/array.h" +#include "common/coroutines.h" #include "common/error.h" #include "common/random.h" #include "common/util.h" @@ -97,7 +98,6 @@ public: Common::File _vdbFP; Common::Array _voices; FPSOUND _theSound; - Scheduler _scheduler; enum DATADIR { DD_BASE = 1, diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index c3deae497b..6a5d80f51e 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -67,7 +67,7 @@ void RMTony::WaitEndOfAction(CORO_PARAM, const void *param) { CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_2(g_scheduler->waitForSingleObject, pid, INFINITE); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, pid, CORO_INFINITE); m_bAction = false; @@ -236,15 +236,15 @@ void RMTony::ExecuteAction(int nAction, int nActionItem, int nParm) { pid = mpalQueryDoAction(TA_COMBINE, nParm, nActionItem); // Se fallito il combine, proviamo con il ReceiveCombine - if (pid == INVALID_PID_VALUE) { + if (pid == CORO_INVALID_PID_VALUE) { pid = mpalQueryDoAction(TA_RECEIVECOMBINE, nActionItem, nParm); // Se fallito il receive, andiamo con quelli generici // @@@ CombineGive! - if (pid == INVALID_PID_VALUE) { + if (pid == CORO_INVALID_PID_VALUE) { pid = mpalQueryDoAction(TA_COMBINE, nParm, 0); - if (pid == INVALID_PID_VALUE){ + if (pid == CORO_INVALID_PID_VALUE){ pid = mpalQueryDoAction(TA_RECEIVECOMBINE, nActionItem, 0); } } @@ -254,25 +254,25 @@ void RMTony::ExecuteAction(int nAction, int nActionItem, int nParm) { pid = mpalQueryDoAction(nAction, nActionItem, 0); } - if (pid != INVALID_PID_VALUE) { + if (pid != CORO_INVALID_PID_VALUE) { m_bAction = true; - g_scheduler->createProcess(WaitEndOfAction, &pid, sizeof(uint32)); + CoroScheduler.createProcess(WaitEndOfAction, &pid, sizeof(uint32)); hActionThread = pid; } else if (nAction != TA_GOTO) { if (nAction == TA_TALK) { pid = mpalQueryDoAction(6, 1, 0); m_bAction = true; - g_scheduler->createProcess(WaitEndOfAction, &pid, sizeof(uint32)); + CoroScheduler.createProcess(WaitEndOfAction, &pid, sizeof(uint32)); hActionThread = pid; } else if (nAction == TA_PALESATI) { pid = mpalQueryDoAction(7, 1, 0); m_bAction = true; - g_scheduler->createProcess(WaitEndOfAction, &pid, sizeof(uint32)); + CoroScheduler.createProcess(WaitEndOfAction, &pid, sizeof(uint32)); hActionThread = pid; } else { pid = mpalQueryDoAction(5, 1, 0); m_bAction = true; - g_scheduler->createProcess(WaitEndOfAction, &pid, sizeof(uint32)); + CoroScheduler.createProcess(WaitEndOfAction, &pid, sizeof(uint32)); hActionThread = pid; } } @@ -286,7 +286,7 @@ void RMTony::StopNoAction(CORO_PARAM) { CORO_BEGIN_CODE(_ctx); if (m_bAction) - CORO_INVOKE_2(g_scheduler->waitForSingleObject, hActionThread, INFINITE); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, hActionThread, CORO_INFINITE); m_bActionPending = false; m_ActionItem = NULL; @@ -306,12 +306,12 @@ void RMTony::Stop(CORO_PARAM) { // Richiama l'MPAL per scegliere la direzione _ctx->pid = mpalQueryDoAction(21, m_ActionItem->MpalCode(), 0); - if (_ctx->pid == INVALID_PID_VALUE) + if (_ctx->pid == CORO_INVALID_PID_VALUE) CORO_INVOKE_0(RMCharacter::Stop); else { bNeedToStop = false; // Se facciamo la OnWhichDirection, almeno dopo non dobbiamo fare la Stop() bMoving = false; - CORO_INVOKE_2(g_scheduler->waitForSingleObject, _ctx->pid, INFINITE); // @@@ Mettere un assert dopo 10 secondi + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->pid, CORO_INFINITE); // @@@ Mettere un assert dopo 10 secondi } } else { CORO_INVOKE_0(RMCharacter::Stop); diff --git a/engines/tony/tonychar.h b/engines/tony/tonychar.h index 050b39c0ca..cf67db4df5 100644 --- a/engines/tony/tonychar.h +++ b/engines/tony/tonychar.h @@ -48,8 +48,8 @@ #ifndef TONY_TONYCHAR_H #define TONY_TONYCHAR_H +#include "common/coroutines.h" #include "tony/mpal/stubs.h" -#include "tony/coroutine.h" #include "tony/loc.h" namespace Tony { @@ -408,7 +408,7 @@ public: int GetCurPattern(); // Attende la fine di un pattern - void WaitForEndPattern(CORO_PARAM, uint32 hCustomSkip = INVALID_PID_VALUE) { + void WaitForEndPattern(CORO_PARAM, uint32 hCustomSkip = CORO_INVALID_PID_VALUE) { RMCharacter::WaitForEndPattern(coroParam, hCustomSkip); } diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index 18dcfb7cb6..3185e5aa4d 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -178,7 +178,7 @@ bool RMSnapshot::GetFreeSnapName(char *fn) { wsprintf(bufName,"rm%d00",i); _makepath(fn,bufDrive,bufDir,bufName,".bmp"); h = CreateFile(fn,GENERIC_READ,FILE_SHARE_READ, NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL, NULL); - if (h == INVALID_PID_VALUE) + if (h == CORO_INVALID_PID_VALUE) break; CloseHandle(h); } @@ -189,7 +189,7 @@ bool RMSnapshot::GetFreeSnapName(char *fn) { wsprintf(bufName,"rm%d%d0",i,j); _makepath(fn,bufDrive,bufDir,bufName,".bmp"); h=CreateFile(fn,GENERIC_READ,FILE_SHARE_READ, NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL, NULL); - if (h==INVALID_PID_VALUE) + if (h==CORO_INVALID_PID_VALUE) break; CloseHandle(h); } @@ -200,7 +200,7 @@ bool RMSnapshot::GetFreeSnapName(char *fn) { wsprintf(bufName,"rm%d%d%d",i,j,k); _makepath(fn,bufDrive,bufDir,bufName,".bmp"); h = CreateFile(fn,GENERIC_READ,FILE_SHARE_READ, NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL, NULL); - if (h==INVALID_PID_VALUE) + if (h==CORO_INVALID_PID_VALUE) break; CloseHandle(h); } -- cgit v1.2.3 From beef5fdb264850079208b5513cf72626ff7edd86 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 11 May 2012 23:23:05 +1000 Subject: TONY: Removal of now redundant includes, and deprecated scheduler/coroutine files --- engines/tony/coroutine.cpp | 82 ----- engines/tony/coroutine.h | 271 --------------- engines/tony/custom.cpp | 1 - engines/tony/font.h | 1 - engines/tony/loc.h | 1 - engines/tony/mpal/mpal.cpp | 1 - engines/tony/sched.cpp | 801 --------------------------------------------- engines/tony/sched.h | 27 -- engines/tony/tony.cpp | 109 +++++- engines/tony/tony.h | 1 - 10 files changed, 104 insertions(+), 1191 deletions(-) delete mode 100644 engines/tony/coroutine.cpp delete mode 100644 engines/tony/coroutine.h delete mode 100644 engines/tony/sched.cpp delete mode 100644 engines/tony/sched.h (limited to 'engines') diff --git a/engines/tony/coroutine.cpp b/engines/tony/coroutine.cpp deleted file mode 100644 index 504dc2a3fd..0000000000 --- a/engines/tony/coroutine.cpp +++ /dev/null @@ -1,82 +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. - */ - -#include "tony/coroutine.h" -#include "common/hashmap.h" -#include "common/hash-str.h" - -namespace Tony { - - -CoroContext nullContext = NULL; // FIXME: Avoid non-const global vars - - -#if COROUTINE_DEBUG -namespace { -static int s_coroCount = 0; - -typedef Common::HashMap CoroHashMap; -static CoroHashMap *s_coroFuncs = 0; - -static void changeCoroStats(const char *func, int change) { - if (!s_coroFuncs) - s_coroFuncs = new CoroHashMap(); - - (*s_coroFuncs)[func] += change; -} - -static void displayCoroStats() { - debug("%d active coros", s_coroCount); - - // Loop over s_coroFuncs and print info about active coros - if (!s_coroFuncs) - return; - for (CoroHashMap::const_iterator it = s_coroFuncs->begin(); - it != s_coroFuncs->end(); ++it) { - if (it->_value != 0) - debug(" %3d x %s", it->_value, it->_key.c_str()); - } -} - -} -#endif - -CoroBaseContext::CoroBaseContext(const char *func) - : _line(0), _sleep(0), _subctx(0) { -#if COROUTINE_DEBUG - _funcName = func; - changeCoroStats(_funcName, +1); - s_coroCount++; -#endif -} - -CoroBaseContext::~CoroBaseContext() { -#if COROUTINE_DEBUG - s_coroCount--; - changeCoroStats(_funcName, -1); - debug("Deleting coro in %s at %p (subctx %p)", - _funcName, (void *)this, (void *)_subctx); - displayCoroStats(); -#endif - delete _subctx; -} - -} // End of namespace Tony diff --git a/engines/tony/coroutine.h b/engines/tony/coroutine.h deleted file mode 100644 index b4eb105f58..0000000000 --- a/engines/tony/coroutine.h +++ /dev/null @@ -1,271 +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. - * - */ - -#ifndef TONY_COROUTINE_H -#define TONY_COROUTINE_H - -#include "common/scummsys.h" -#include "common/util.h" // for SCUMMVM_CURRENT_FUNCTION - -namespace Tony { - -/** - * @defgroup TonyCoroutines Coroutine support for Tony engine - * - * The following is loosely based on an article by Simon Tatham: - * . - * However, many improvements and tweaks have been made, in particular - * by taking advantage of C++ features not available in C. - */ -//@{ - - -// Enable this macro to enable some debugging support in the coroutine code. -//#define COROUTINE_DEBUG 1 - -/** - * The core of any coroutine context which captures the 'state' of a coroutine. - * Private use only. - */ -struct CoroBaseContext { - int _line; - int _sleep; - CoroBaseContext *_subctx; -#if COROUTINE_DEBUG - const char *_funcName; -#endif - CoroBaseContext(const char *func); - ~CoroBaseContext(); -}; - -typedef CoroBaseContext *CoroContext; - - -// FIXME: Document this! -extern CoroContext nullContext; - -/** - * Wrapper class which holds a pointer to a pointer to a CoroBaseContext. - * The interesting part is the destructor, which kills the context being held, - * but ONLY if the _sleep val of that context is zero. This way, a coroutine - * can just 'return' w/o having to worry about freeing the allocated context - * (in Simon Tatham's original code, one had to use a special macro to - * return from a coroutine). - */ -class CoroContextHolder { - CoroContext &_ctx; -public: - CoroContextHolder(CoroContext &ctx) : _ctx(ctx) { - assert(ctx); - assert(ctx->_sleep >= 0); - ctx->_sleep = 0; - } - ~CoroContextHolder() { - if (_ctx && _ctx->_sleep == 0) { - delete _ctx; - _ctx = 0; - } - } -}; - - -#define CORO_PARAM CoroContext &coroParam - - -/** - * Begin the declaration of a coroutine context. - * This allows declaring variables which are 'persistent' during the - * lifetime of the coroutine. An example use would be: - * - * CORO_BEGIN_CONTEXT; - * int var; - * char *foo; - * CORO_END_CONTEXT(_ctx); - * - * It is not possible to initialize variables here, due to the way this - * macro is implemented. Furthermore, to use the variables declared in - * the coroutine context, you have to access them via the context variable - * name that was specified as parameter to CORO_END_CONTEXT, e.g. - * _ctx->var = 0; - * - * @see CORO_END_CONTEXT - * - * @note We declare a variable 'DUMMY' to allow the user to specify an 'empty' - * context, and so compilers won't complain about ";" following the macro. - */ -#define CORO_BEGIN_CONTEXT \ - struct CoroContextTag : Common::CoroBaseContext { \ - CoroContextTag() : CoroBaseContext(SCUMMVM_CURRENT_FUNCTION) {} \ - int DUMMY - -/** - * End the declaration of a coroutine context. - * @param x name of the coroutine context - * @see CORO_BEGIN_CONTEXT - */ -#define CORO_END_CONTEXT(x) } *x = (CoroContextTag *)coroParam - -/** - * Begin the code section of a coroutine. - * @param x name of the coroutine context - * @see CORO_BEGIN_CODE - */ -#define CORO_BEGIN_CODE(x) \ - if (&coroParam == &nullContext) assert(!nullContext);\ - if (!x) {coroParam = x = new CoroContextTag();}\ - CoroContextHolder tmpHolder(coroParam);\ - switch (coroParam->_line) { case 0:; - -/** - * End the code section of a coroutine. - * @see CORO_END_CODE - */ -#define CORO_END_CODE \ - if (&coroParam == &nullContext) { \ - delete nullContext; \ - nullContext = NULL; \ - } \ - } - -/** - * Sleep for the specified number of scheduler cycles. - */ -#define CORO_SLEEP(delay) do {\ - coroParam->_line = __LINE__;\ - coroParam->_sleep = delay;\ - assert(&coroParam != &nullContext);\ - return; case __LINE__:;\ - } while (0) - -#define CORO_GIVE_WAY do { CoroScheduler.giveWay(); CORO_SLEEP(1); } while (0) -#define CORO_RESCHEDULE do { CoroScheduler.reschedule(); CORO_SLEEP(1); } while (0) - -/** - * Stop the currently running coroutine and all calling coroutines. - * - * This sets _sleep to -1 rather than 0 so that the context doesn't get - * deleted by CoroContextHolder, since we want CORO_INVOKE_ARGS to - * propogate the _sleep value and return immediately (the scheduler will - * then delete the entire coroutine's state, including all subcontexts). - */ -#define CORO_KILL_SELF() \ - do { if (&coroParam != &nullContext) { coroParam->_sleep = -1; } return; } while (0) - - -/** - * This macro is to be used in conjunction with CORO_INVOKE_ARGS and - * similar macros for calling coroutines-enabled subroutines. - */ -#define CORO_SUBCTX coroParam->_subctx - -/** - * Invoke another coroutine. - * - * If the subcontext still exists after the coroutine is invoked, it has - * either yielded/slept or killed itself, and so we copy the _sleep value - * to our own context and return (execution will continue at the case - * statement below, where we loop and call the coroutine again). - * If the subcontext is null, the coroutine ended normally, and we can - * simply break out of the loop and continue execution. - * - * @param subCoro name of the coroutine-enabled function to invoke - * @param ARGS list of arguments to pass to subCoro - * - * @note ARGS must be surrounded by parentheses, and the first argument - * in this list must always be CORO_SUBCTX. For example, the - * regular function call - * myFunc(a, b); - * becomes the following: - * CORO_INVOKE_ARGS(myFunc, (CORO_SUBCTX, a, b)); - */ -#define CORO_INVOKE_ARGS(subCoro, ARGS) \ - do {\ - coroParam->_line = __LINE__;\ - coroParam->_subctx = 0;\ - do {\ - subCoro ARGS;\ - if (!coroParam->_subctx) break;\ - coroParam->_sleep = coroParam->_subctx->_sleep;\ - assert(&coroParam != &nullContext);\ - return; case __LINE__:;\ - } while (1);\ - } while (0) - -/** - * Invoke another coroutine. Similar to CORO_INVOKE_ARGS, - * but allows specifying a return value which is returned - * if invoked coroutine yields (thus causing the current - * coroutine to yield, too). - */ -#define CORO_INVOKE_ARGS_V(subCoro, RESULT, ARGS) \ - do {\ - coroParam->_line = __LINE__;\ - coroParam->_subctx = 0;\ - do {\ - subCoro ARGS;\ - if (!coroParam->_subctx) break;\ - coroParam->_sleep = coroParam->_subctx->_sleep;\ - assert(&coroParam != &nullContext);\ - return RESULT; case __LINE__:;\ - } while (1);\ - } while (0) - -/** - * Convenience wrapper for CORO_INVOKE_ARGS for invoking a coroutine - * with no parameters. - */ -#define CORO_INVOKE_0(subCoroutine) \ - CORO_INVOKE_ARGS(subCoroutine,(CORO_SUBCTX)) - -/** - * Convenience wrapper for CORO_INVOKE_ARGS for invoking a coroutine - * with one parameter. - */ -#define CORO_INVOKE_1(subCoroutine, a0) \ - CORO_INVOKE_ARGS(subCoroutine,(CORO_SUBCTX,a0)) - -/** - * Convenience wrapper for CORO_INVOKE_ARGS for invoking a coroutine - * with two parameters. - */ -#define CORO_INVOKE_2(subCoroutine, a0,a1) \ - CORO_INVOKE_ARGS(subCoroutine,(CORO_SUBCTX,a0,a1)) - -/** - * Convenience wrapper for CORO_INVOKE_ARGS for invoking a coroutine - * with three parameters. - */ -#define CORO_INVOKE_3(subCoroutine, a0,a1,a2) \ - CORO_INVOKE_ARGS(subCoroutine,(CORO_SUBCTX,a0,a1,a2)) - -/** - * Convenience wrapper for CORO_INVOKE_ARGS for invoking a coroutine - * with four parameters. - */ -#define CORO_INVOKE_4(subCoroutine, a0,a1,a2,a3) \ - CORO_INVOKE_ARGS(subCoroutine,(CORO_SUBCTX,a0,a1,a2,a3)) - -//@} - -} // End of namespace Tony - -#endif // TONY_COROUTINE_H diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 234dd0a4f9..89d3123b60 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -56,7 +56,6 @@ #include "tony/font.h" #include "tony/game.h" #include "tony/gfxcore.h" -#include "tony/sched.h" #include "tony/tony.h" #include "tony/tonychar.h" #include "tony/utils.h" diff --git a/engines/tony/font.h b/engines/tony/font.h index 7447f31515..d883733db6 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -52,7 +52,6 @@ #include "common/coroutines.h" #include "tony/gfxcore.h" #include "tony/resid.h" -#include "tony/sched.h" namespace Tony { diff --git a/engines/tony/loc.h b/engines/tony/loc.h index 4b8946da54..218aca02e7 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -52,7 +52,6 @@ #include "common/system.h" #include "common/file.h" #include "tony/mpal/stubs.h" -#include "tony/sched.h" #include "tony/sound.h" #include "tony/utils.h" diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 42c790a1c7..a665fbacc5 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -51,7 +51,6 @@ #include "common/file.h" #include "common/savefile.h" #include "common/system.h" -#include "tony/sched.h" #include "tony/tony.h" #include "tony/mpal/lzo.h" #include "tony/mpal/mpal.h" diff --git a/engines/tony/sched.cpp b/engines/tony/sched.cpp deleted file mode 100644 index c447afa094..0000000000 --- a/engines/tony/sched.cpp +++ /dev/null @@ -1,801 +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. - * - * Process scheduler. - */ - -#include "common/system.h" -#include "common/textconsole.h" -#include "common/util.h" -#include "tony/sched.h" - -namespace Tony { - -Scheduler *g_scheduler = 0; - -//--------------------- FUNCTIONS ------------------------ - -Scheduler::Scheduler() { - processList = NULL; - pFreeProcesses = NULL; - pCurrent = NULL; - -#ifdef DEBUG - // diagnostic process counters - numProcs = 0; - maxProcs = 0; -#endif - - pRCfunction = NULL; - pidCounter = 0; - - active = new PROCESS; - active->pPrevious = NULL; - active->pNext = NULL; - - g_scheduler = this; // FIXME HACK - - reset(); -} - -Scheduler::~Scheduler() { - // Kill all running processes (i.e. free memory allocated for their state). - PROCESS *pProc = active->pNext; - while (pProc != NULL) { - delete pProc->state; - pProc->state = 0; - pProc = pProc->pNext; - } - - free(processList); - processList = NULL; - - delete active; - active = 0; - - // Clear the event list - Common::List::iterator i; - for (i = _events.begin(); i != _events.end(); ++i) - delete (*i); -} - -/** - * Kills all processes and places them on the free list. - */ -void Scheduler::reset() { - -#ifdef DEBUG - // clear number of process in use - numProcs = 0; -#endif - - if (processList == NULL) { - // first time - allocate memory for process list - processList = (PROCESS *)calloc(MAX_PROCESSES, sizeof(PROCESS)); - - // make sure memory allocated - if (processList == NULL) { - error("Cannot allocate memory for process data"); - } - - // fill with garbage - memset(processList, 'S', MAX_PROCESSES * sizeof(PROCESS)); - } - - // Kill all running processes (i.e. free memory allocated for their state). - PROCESS *pProc = active->pNext; - while (pProc != NULL) { - delete pProc->state; - pProc->state = 0; - pProc->waiting = false; - pProc = pProc->pNext; - } - - // no active processes - pCurrent = active->pNext = NULL; - - // place first process on free list - pFreeProcesses = processList; - - // link all other processes after first - for (int i = 1; i <= NUM_PROCESS; i++) { - processList[i - 1].pNext = (i == NUM_PROCESS) ? NULL : processList + i; - processList[i - 1].pPrevious = (i == 1) ? active : processList + (i - 2); - } -} - - -#ifdef DEBUG -/** - * Shows the maximum number of process used at once. - */ -void Scheduler::printStats() { - debug("%i process of %i used", maxProcs, NUM_PROCESS); -} -#endif - -#ifdef DEBUG -/** - * Checks both the active and free process list to insure all the links are valid, - * and that no processes have been lost - */ -void Scheduler::CheckStack() { - Common::List pList; - - // Check both the active and free process lists - for (int i = 0; i < 2; ++i) { - PROCESS *p = (i == 0) ? active : pFreeProcesses; - - if (p != NULL) { - // Make sure the linkages are correct - while (p->pNext != NULL) { - assert(p->pNext->pPrevious == p); - pList.push_back(p); - p = p->pNext; - } - pList.push_back(p); - } - } - - // Make sure all processes are accounted for - for (int idx = 0; idx < NUM_PROCESS; idx++) { - bool found = false; - for (Common::List::iterator i = pList.begin(); i != pList.end(); ++i) { - PROCESS *pTemp = *i; - if (*i == &processList[idx]) { - found = true; - break; - } - } - - assert(found); - } -} -#endif - -/** - * Give all active processes a chance to run - */ -void Scheduler::schedule() { - // start dispatching active process list - PROCESS *pNext; - PROCESS *pProc = active->pNext; - while (pProc != NULL) { - pNext = pProc->pNext; - - if (--pProc->sleepTime <= 0) { - // process is ready for dispatch, activate it - pCurrent = pProc; - pProc->coroAddr(pProc->state, pProc->param); - - if (!pProc->state || pProc->state->_sleep <= 0) { - // Coroutine finished - pCurrent = pCurrent->pPrevious; - killProcess(pProc); - } else { - pProc->sleepTime = pProc->state->_sleep; - } - - // pCurrent may have been changed - pNext = pCurrent->pNext; - pCurrent = NULL; - } - - pProc = pNext; - } -} - -/** - * Reschedules all the processes to run again this query - */ -void Scheduler::rescheduleAll() { - assert(pCurrent); - - // Unlink current process - pCurrent->pPrevious->pNext = pCurrent->pNext; - if (pCurrent->pNext) - pCurrent->pNext->pPrevious = pCurrent->pPrevious; - - // Add process to the start of the active list - pCurrent->pNext = active->pNext; - active->pNext->pPrevious = pCurrent; - active->pNext = pCurrent; - pCurrent->pPrevious = active; -} - -/** - * If the specified process has already run on this tick, make it run - * again on the current tick. - */ -void Scheduler::reschedule(PPROCESS pReSchedProc) { - // If not currently processing the schedule list, then no action is needed - if (!pCurrent) - return; - - if (!pReSchedProc) - pReSchedProc = pCurrent; - - PPROCESS pEnd; - - // Find the last process in the list. - // But if the target process is down the list from here, do nothing - for (pEnd = pCurrent; pEnd->pNext != NULL; pEnd = pEnd->pNext) { - if (pEnd->pNext == pReSchedProc) - return; - } - - assert(pEnd->pNext == NULL); - - // Could be in the middle of a KillProc()! - // Dying process was last and this process was penultimate - if (pReSchedProc->pNext == NULL) - return; - - // If we're moving the current process, move it back by one, so that the next - // schedule() iteration moves to the now next one - if (pCurrent == pReSchedProc) - pCurrent = pCurrent->pPrevious; - - // Unlink the process, and add it at the end - pReSchedProc->pPrevious->pNext = pReSchedProc->pNext; - pReSchedProc->pNext->pPrevious = pReSchedProc->pPrevious; - pEnd->pNext = pReSchedProc; - pReSchedProc->pPrevious = pEnd; - pReSchedProc->pNext = NULL; -} - -/** - * Moves the specified process to the end of the dispatch queue - * allowing it to run again within the current game cycle. - * @param pGiveProc Which process - */ -void Scheduler::giveWay(PPROCESS pReSchedProc) { - // If not currently processing the schedule list, then no action is needed - if (!pCurrent) - return; - - if (!pReSchedProc) - pReSchedProc = pCurrent; - - // If the process is already at the end of the queue, nothing has to be done - if (!pReSchedProc->pNext) - return; - - PPROCESS pEnd; - - // Find the last process in the list. - for (pEnd = pCurrent; pEnd->pNext != NULL; pEnd = pEnd->pNext) - ; - assert(pEnd->pNext == NULL); - - - // If we're moving the current process, move it back by one, so that the next - // schedule() iteration moves to the now next one - if (pCurrent == pReSchedProc) - pCurrent = pCurrent->pPrevious; - - // Unlink the process, and add it at the end - pReSchedProc->pPrevious->pNext = pReSchedProc->pNext; - pReSchedProc->pNext->pPrevious = pReSchedProc->pPrevious; - pEnd->pNext = pReSchedProc; - pReSchedProc->pPrevious = pEnd; - pReSchedProc->pNext = NULL; -} - -/** - * Continously makes a given process wait for another process to finish or event to signal. - * - * @param pid Process/Event identifier - * @param duration Duration in milliseconds - * @param expired If specified, set to true if delay period expired - */ -void Scheduler::waitForSingleObject(CORO_PARAM, int pid, uint32 duration, bool *expired) { - if (!pCurrent) - error("Called Scheduler::waitForSingleObject from the main process"); - - CORO_BEGIN_CONTEXT; - uint32 endTime; - PROCESS *pProcess; - EVENT *pEvent; - CORO_END_CONTEXT(_ctx); - - CORO_BEGIN_CODE(_ctx); - - // Signal as waiting - pCurrent->waiting = true; - - _ctx->endTime = (duration == INFINITE) ? INFINITE : g_system->getMillis() + duration; - if (expired) - // Presume it will expire - *expired = true; - - // Outer loop for doing checks until expiry - while (g_system->getMillis() < _ctx->endTime) { - // Check to see if a process or event with the given Id exists - _ctx->pProcess = getProcess(pid); - _ctx->pEvent = !_ctx->pProcess ? getEvent(pid) : NULL; - - // If there's no active process or event, presume it's a process that's finished, - // so the waiting can immediately exit - if ((_ctx->pProcess == NULL) && (_ctx->pEvent == NULL)) { - if (expired) - *expired = false; - break; - } - - // If a process was found, don't go into the if statement, and keep waiting. - // Likewise if it's an event that's not yet signalled - if ((_ctx->pEvent != NULL) && _ctx->pEvent->signalled) { - // Unless the event is flagged for manual reset, reset it now - if (!_ctx->pEvent->manualReset) - _ctx->pEvent->signalled = false; - - if (expired) - *expired = false; - break; - } - - // Sleep until the next cycle - CORO_SLEEP(1); - } - - // Signal waiting is done - pCurrent->waiting = false; - - CORO_END_CODE; -} - -/** - * Continously makes a given process wait for given prcesses to finished or events to be set - * - * @param nCount Number of Id's being passed - * @param evtList List of pids to wait for - * @param bWaitAll Specifies whether all or any of the processes/events - * @param duration Duration in milliseconds - * @param expired Set to true if delay period expired - */ -void Scheduler::waitForMultipleObjects(CORO_PARAM, int nCount, uint32 *pidList, bool bWaitAll, - uint32 duration, bool *expired) { - if (!pCurrent) - error("Called Scheduler::waitForMultipleEvents from the main process"); - - CORO_BEGIN_CONTEXT; - uint32 endTime; - bool signalled; - bool pidSignalled; - int i; - PROCESS *pProcess; - EVENT *pEvent; - CORO_END_CONTEXT(_ctx); - - CORO_BEGIN_CODE(_ctx); - - // Signal as waiting - pCurrent->waiting = true; - - _ctx->endTime = (duration == INFINITE) ? INFINITE : g_system->getMillis() + duration; - if (expired) - // Presume that delay will expire - *expired = true; - - // Outer loop for doing checks until expiry - while (g_system->getMillis() < _ctx->endTime) { - _ctx->signalled = bWaitAll; - - for (_ctx->i = 0; _ctx->i < nCount; ++_ctx->i) { - _ctx->pProcess = getProcess(pidList[_ctx->i]); - _ctx->pEvent = !_ctx->pProcess ? getEvent(pidList[_ctx->i]) : NULL; - - // Determine the signalled state - _ctx->pidSignalled = (_ctx->pProcess) || !_ctx->pEvent ? false : _ctx->pEvent->signalled; - - if (bWaitAll && _ctx->pidSignalled) - _ctx->signalled = false; - else if (!bWaitAll & _ctx->pidSignalled) - _ctx->signalled = true; - } - - // At this point, if the signalled variable is set, waiting is finished - if (_ctx->signalled) { - // Automatically reset any events not flagged for manual reset - for (_ctx->i = 0; _ctx->i < nCount; ++_ctx->i) { - _ctx->pEvent = getEvent(pidList[_ctx->i]); - - if (_ctx->pEvent->manualReset) - _ctx->pEvent->signalled = false; - } - - if (expired) - *expired = false; - break; - } - - // Sleep until the next cycle - CORO_SLEEP(1); - } - - // Signal waiting is done - pCurrent->waiting = false; - - CORO_END_CODE; -} - -/** - * Make the active process sleep for the given duration in milliseconds - * @param duration Duration in milliseconds - * @remarks This duration won't be precise, since it relies on the frequency the - * scheduler is called. - */ -void Scheduler::sleep(CORO_PARAM, uint32 duration) { - if (!pCurrent) - error("Called Scheduler::waitForSingleObject from the main process"); - - CORO_BEGIN_CONTEXT; - uint32 endTime; - PROCESS *pProcess; - EVENT *pEvent; - CORO_END_CONTEXT(_ctx); - - CORO_BEGIN_CODE(_ctx); - - // Signal as waiting - pCurrent->waiting = true; - - _ctx->endTime = g_system->getMillis() + duration; - - // Outer loop for doing checks until expiry - while (g_system->getMillis() < _ctx->endTime) { - // Sleep until the next cycle - CORO_SLEEP(1); - } - - // Signal waiting is done - pCurrent->waiting = false; - - CORO_END_CODE; -} - -/** - * Creates a new process. - * - * @param pid process identifier - * @param CORO_ADDR coroutine start address - * @param pParam process specific info - * @param sizeParam size of process specific info - */ -uint32 Scheduler::createProcess(CORO_ADDR coroAddr, const void *pParam, int sizeParam) { - PROCESS *pProc; - - // get a free process - pProc = pFreeProcesses; - - // trap no free process - assert(pProc != NULL); // Out of processes - -#ifdef DEBUG - // one more process in use - if (++numProcs > maxProcs) - maxProcs = numProcs; -#endif - - // get link to next free process - pFreeProcesses = pProc->pNext; - if (pFreeProcesses) - pFreeProcesses->pPrevious = NULL; - - if (pCurrent != NULL) { - // place new process before the next active process - pProc->pNext = pCurrent->pNext; - if (pProc->pNext) - pProc->pNext->pPrevious = pProc; - - // make this new process the next active process - pCurrent->pNext = pProc; - pProc->pPrevious = pCurrent; - - } else { // no active processes, place process at head of list - pProc->pNext = active->pNext; - pProc->pPrevious = active; - - if (pProc->pNext) - pProc->pNext->pPrevious = pProc; - active->pNext = pProc; - - } - - // set coroutine entry point - pProc->coroAddr = coroAddr; - - // clear coroutine state - pProc->state = 0; - - // wake process up as soon as possible - pProc->sleepTime = 1; - - // set new process id - pProc->pid = ++pidCounter; - - // set new process specific info - if (sizeParam) { - assert(sizeParam > 0 && sizeParam <= PARAM_SIZE); - - // set new process specific info - memcpy(pProc->param, pParam, sizeParam); - } - - // return created process - return pProc->pid; -} - -/** - * Kills the specified process. - * - * @param pKillProc which process to kill - */ -void Scheduler::killProcess(PROCESS *pKillProc) { - // make sure a valid process pointer - assert(pKillProc >= processList && pKillProc <= processList + NUM_PROCESS - 1); - - // can not kill the current process using killProcess ! - assert(pCurrent != pKillProc); - -#ifdef DEBUG - // one less process in use - --numProcs; - assert(numProcs >= 0); -#endif - - // Free process' resources - if (pRCfunction != NULL) - (pRCfunction)(pKillProc); - - delete pKillProc->state; - pKillProc->state = 0; - - // Take the process out of the active chain list - pKillProc->pPrevious->pNext = pKillProc->pNext; - if (pKillProc->pNext) - pKillProc->pNext->pPrevious = pKillProc->pPrevious; - - // link first free process after pProc - pKillProc->pNext = pFreeProcesses; - if (pFreeProcesses) - pKillProc->pNext->pPrevious = pKillProc; - pKillProc->pPrevious = NULL; - - // make pKillProc the first free process - pFreeProcesses = pKillProc; -} - - - -/** - * Returns a pointer to the currently running process. - */ -PROCESS *Scheduler::getCurrentProcess() { - return pCurrent; -} - -/** - * Returns the process identifier of the specified process. - * - * @param pProc which process - */ -int Scheduler::getCurrentPID() const { - PROCESS *pProc = pCurrent; - - // make sure a valid process pointer - assert(pProc >= processList && pProc <= processList + NUM_PROCESS - 1); - - // return processes PID - return pProc->pid; -} - -/** - * Kills any process matching the specified PID. The current - * process cannot be killed. - * - * @param pidKill process identifier of process to kill - * @param pidMask mask to apply to process identifiers before comparison - * @return The number of processes killed is returned. - */ -int Scheduler::killMatchingProcess(uint32 pidKill, int pidMask) { - int numKilled = 0; - PROCESS *pProc, *pPrev; // process list pointers - - for (pProc = active->pNext, pPrev = active; pProc != NULL; pPrev = pProc, pProc = pProc->pNext) { - if ((pProc->pid & (uint32)pidMask) == pidKill) { - // found a matching process - - // dont kill the current process - if (pProc != pCurrent) { - // kill this process - numKilled++; - - // Free the process' resources - if (pRCfunction != NULL) - (pRCfunction)(pProc); - - delete pProc->state; - pProc->state = 0; - - // make prev point to next to unlink pProc - pPrev->pNext = pProc->pNext; - if (pProc->pNext) - pPrev->pNext->pPrevious = pPrev; - - // link first free process after pProc - pProc->pNext = pFreeProcesses; - pProc->pPrevious = NULL; - pFreeProcesses->pPrevious = pProc; - - // make pProc the first free process - pFreeProcesses = pProc; - - // set to a process on the active list - pProc = pPrev; - } - } - } - -#ifdef DEBUG - // adjust process in use - numProcs -= numKilled; - assert(numProcs >= 0); -#endif - - // return number of processes killed - return numKilled; -} - -/** - * Set pointer to a function to be called by killProcess(). - * - * May be called by a resource allocator, the function supplied is - * called by killProcess() to allow the resource allocator to free - * resources allocated to the dying process. - * - * @param pFunc Function to be called by killProcess() - */ -void Scheduler::setResourceCallback(VFPTRPP pFunc) { - pRCfunction = pFunc; -} - -PROCESS *Scheduler::getProcess(uint32 pid) { - PROCESS *pProc = active->pNext; - while ((pProc != NULL) && (pProc->pid != pid)) - pProc = pProc->pNext; - - return pProc; -} - -EVENT *Scheduler::getEvent(uint32 pid) { - Common::List::iterator i; - for (i = _events.begin(); i != _events.end(); ++i) { - EVENT *evt = *i; - if (evt->pid == pid) - return evt; - } - - return NULL; -} - - -/** - * Creates a new event object - * @param bManualReset Events needs to be manually reset. Otherwise, events - * will be automatically reset after a process waits on the event finishes - * @param bInitialState Specifies whether the event is signalled or not initially - */ -uint32 Scheduler::createEvent(bool bManualReset, bool bInitialState) { - EVENT *evt = new EVENT(); - evt->pid = ++pidCounter; - evt->manualReset = bManualReset; - evt->signalled = bInitialState; - - _events.push_back(evt); - return evt->pid; -} - -/** - * Destroys the given event - * @param pidEvent Event PID - */ -void Scheduler::closeEvent(uint32 pidEvent) { - EVENT *evt = getEvent(pidEvent); - if (evt) { - _events.remove(evt); - delete evt; - } -} - -/** - * Sets the event - * @param pidEvent Event PID - */ -void Scheduler::setEvent(uint32 pidEvent) { - EVENT *evt = getEvent(pidEvent); - if (evt) - evt->signalled = true; -} - -/** - * Resets the event - * @param pidEvent Event PID - */ -void Scheduler::resetEvent(uint32 pidEvent) { - EVENT *evt = getEvent(pidEvent); - if (evt) - evt->signalled = false; -} - -/** - * Temporarily sets a given event to true, and then runs all waiting processes, allowing any - * processes waiting on the event to be fired. It then immediately resets the event again. - * @param pidEvent Event PID - * - * @remarks Should not be run inside of another process - */ -void Scheduler::pulseEvent(uint32 pidEvent) { - EVENT *evt = getEvent(pidEvent); - if (!evt) - return; - - // Set the event as true - evt->signalled = true; - - // start dispatching active process list for any processes that are currently waiting - PROCESS *pOriginal = pCurrent; - PROCESS *pNext; - PROCESS *pProc = active->pNext; - while (pProc != NULL) { - pNext = pProc->pNext; - - // Only call processes that are currently waiting (either in waitForSingleObject or - // waitForMultipleObjects). If one is found, execute it immediately - if (pProc->waiting) { - // Dispatch the process - pCurrent = pProc; - pProc->coroAddr(pProc->state, pProc->param); - - if (!pProc->state || pProc->state->_sleep <= 0) { - // Coroutine finished - pCurrent = pCurrent->pPrevious; - killProcess(pProc); - } else { - pProc->sleepTime = pProc->state->_sleep; - } - - // pCurrent may have been changed - pNext = pCurrent->pNext; - pCurrent = NULL; - } - - pProc = pNext; - } - - // Restore the original current process (if one was active) - pCurrent = pOriginal; - - // Reset the event back to non-signalled - evt->signalled = false; -} - -} // End of namespace Tony diff --git a/engines/tony/sched.h b/engines/tony/sched.h deleted file mode 100644 index f7dabd47ae..0000000000 --- a/engines/tony/sched.h +++ /dev/null @@ -1,27 +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. - * - * Data structures used by the process scheduler - */ - -#ifndef TONY_SCHED_H -#define TONY_SCHED_H - -#endif // TONY_SCHED_H diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index ece1904810..76f6cfcecb 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -162,7 +162,85 @@ OSystem::MutexRef csMusic; void TonyEngine::PlayMusic(int nChannel, const char *fn, int nFX, bool bLoop, int nSync) { - warning("TonyEngine::PlayMusic"); + warning("TODO: TonyEngine::PlayMusic"); + g_system->lockMutex(csMusic); + + if (nChannel < 4) + if (flipflop) + nChannel = nChannel + 1; + + switch (nFX) { + case 0: + case 1: + case 2: + m_stream[nChannel]->Stop(); + m_stream[nChannel]->UnloadFile(); + break; + + case 22: + break; + } + +#ifdef REFACTOR_ME + // Mette il path giusto + if (nChannel < 4) + GetDataDirectory(DD_MUSIC, path_buffer); + else + GetDataDirectory(DD_LAYER, path_buffer); + _splitpath(path_buffer,drive,dir,NULL,NULL); + _splitpath(fn,NULL,NULL,fname,ext); + _makepath(path_buffer,drive,dir,fname,ext); + + _makepath(path_buffer,drive,dir,fname,ext); + + if (nFX==22) // Sync a tempo + { + curChannel=nChannel; + strcpy(nextMusic, path_buffer); + nextLoop=bLoop; + nextSync=nSync; + if (flipflop) + nextChannel=nChannel-1; + else + nextChannel=nChannel+1; + DWORD id; + HANDLE hThread=CreateThread(NULL,10240,(LPTHREAD_START_ROUTINE)DoNextMusic,m_stream,0,&id); + SetThreadPriority(hThread,THREAD_PRIORITY_HIGHEST); + } + else if (nFX==44) // Cambia canale e lascia finire il primo + { + if (flipflop) + nextChannel=nChannel-1; + else + nextChannel=nChannel+1; + + m_stream[nextChannel]->Stop(); + m_stream[nextChannel]->UnloadFile(); +#ifndef DEMO + if (!m_stream[nextChannel]->LoadFile(path_buffer,FPCODEC_ADPCM,nSync)) + theGame.Abort(); +#else + m_stream[nextChannel]->LoadFile(path_buffer,FPCODEC_ADPCM,nSync); +#endif + m_stream[nextChannel]->SetLoop(bLoop); + m_stream[nextChannel]->Play(); + + flipflop = 1-flipflop; + } + else + { +#ifndef DEMO + if (!m_stream[nChannel]->LoadFile(path_buffer,FPCODEC_ADPCM,nSync)) + theGame.Abort(); +#else + m_stream[nChannel]->LoadFile(path_buffer,FPCODEC_ADPCM,nSync); +#endif + m_stream[nChannel]->SetLoop(bLoop); + m_stream[nChannel]->Play(); + } +#endif + + g_system->unlockMutex(csMusic); } void TonyEngine::PlaySFX(int nChannel, int nFX) { @@ -183,19 +261,40 @@ void TonyEngine::PlaySFX(int nChannel, int nFX) { } void TonyEngine::StopMusic(int nChannel) { - warning("TODO TonyEngine::StopMusic"); + g_system->lockMutex(csMusic); + + if (nChannel < 4) + m_stream[nChannel+flipflop]->Stop(); + else + m_stream[nChannel]->Stop(); + + g_system->unlockMutex(csMusic); } void TonyEngine::StopSFX(int nChannel) { - warning("TODO TonyEngine::StopSFX"); + m_sfx[nChannel]->Stop(); } void TonyEngine::PlayUtilSFX(int nChannel, int nFX) { - warning("TODO TonyEngine::PlayUtilSFX"); + if (m_utilSfx[nChannel]==NULL) + return; + + switch (nFX) { + case 0: + m_utilSfx[nChannel]->SetLoop(false); + break; + + case 1: + m_utilSfx[nChannel]->SetLoop(true); + break; + } + + m_utilSfx[nChannel]->SetVolume(52); + m_utilSfx[nChannel]->Play(); } void TonyEngine::StopUtilSFX(int nChannel) { - warning("TODO TonyEngine::StopUtilSFX"); + m_utilSfx[nChannel]->Stop(); } void TonyEngine::PreloadSFX(int nChannel, const char *fn) { diff --git a/engines/tony/tony.h b/engines/tony/tony.h index d8104e641b..69b54e8edb 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -36,7 +36,6 @@ #include "tony/mpal/memory.h" #include "tony/gfxengine.h" #include "tony/loc.h" -#include "tony/sched.h" #include "tony/utils.h" #include "tony/window.h" -- cgit v1.2.3 From 67c47e9045cab111ff9daadf9968553106f14bfe Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 11 May 2012 23:36:13 +1000 Subject: TONY: First attempt at simulating the circular fade in/out effect engine uses The engine uses DirectX drawing functionality to do drawing of partial frames within an ellipsis, so we need to replicate that manually in code. --- engines/tony/window.cpp | 57 ++++++++++++++++++++++++++++++++++++++++++++----- engines/tony/window.h | 2 ++ 2 files changed, 54 insertions(+), 5 deletions(-) (limited to 'engines') diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index 3185e5aa4d..da49b91109 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -147,11 +147,58 @@ void RMWindow::GetNewFrameWipe(byte *lpBuf, Common::Rect &rcBoundEllipse) { if (!rcBoundEllipse.isValidRect()) return; - // TODO: Do a proper circular wipe - for (int yp = rcBoundEllipse.top; yp < rcBoundEllipse.bottom; ++yp) { - const byte *pSrc = lpBuf + (yp * RM_SX * 2) + rcBoundEllipse.left * 2; - - g_system->copyRectToScreen(pSrc, RM_SX * 2, rcBoundEllipse.left, yp, rcBoundEllipse.width(), 1); + Common::Point center(rcBoundEllipse.left + rcBoundEllipse.width() / 2, + rcBoundEllipse.top + rcBoundEllipse.height() / 2); + int radius = rcBoundEllipse.width() / 2; + + int error = -radius; + int x = radius; + int y = 0; + + while (x >= y) { + plotSplices(lpBuf, center, x, y); + + error += y; + ++y; + error += y; + + if (error >= 0) { + error -= x; + --x; + error -= x; + } + } +} + +/** + * Handles drawing the line splices for the circle of viewable area + */ +void RMWindow::plotSplices(const byte *lpBuf, const Common::Point ¢er, int x, int y) { + plotLines(lpBuf, center, x, y); + if (x != y) + plotLines(lpBuf, center, y, x); +} + +/** + * Handles drawing the line splices for the circle of viewable area + */ +void RMWindow::plotLines(const byte *lpBuf, const Common::Point ¢er, int x, int y) { + // Skips lines that have no width (i.e. at the top of the circle) + if ((x == 0) || (y > center.y)) + return; + + const byte *pSrc; + + if ((center.y - y) >= 0) { + // Draw line in top half of circle + pSrc = lpBuf + ((center.y - y) * RM_SX * 2) + (center.x - x) * 2; + g_system->copyRectToScreen(pSrc, RM_SX * 2, center.x - x, center.y - y, x * 2, 1); + } + + if ((center.y + y) < RM_SY) { + // Draw line in bottom half of circle + pSrc = lpBuf + ((center.y + y) * RM_SX * 2) + (center.x - x) * 2; + g_system->copyRectToScreen(pSrc, RM_SX * 2, center.x - x, center.y + y, x * 2, 1); } } diff --git a/engines/tony/window.h b/engines/tony/window.h index 06f684a15b..56f48d7698 100644 --- a/engines/tony/window.h +++ b/engines/tony/window.h @@ -80,6 +80,8 @@ class RMWindow { private: bool Lock(); void Unlock(); + void plotSplices(const byte *lpBuf, const Common::Point ¢er, int x, int y); + void plotLines(const byte *lpBuf, const Common::Point ¢er, int x, int y); protected: void * /*LPDIRECTDRAWCLIPPER*/ m_MainClipper; -- cgit v1.2.3 From 3a61568b6f0c5d74ced621a5f4161efbcb33f6a9 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 11 May 2012 23:39:32 +1000 Subject: TONY: Removed carriage returns from debug line strings --- engines/tony/custom.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 89d3123b60..a9e8e5bc62 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -2258,7 +2258,7 @@ void ThreadFadeInMusic(CORO_PARAM, const void *nMusic) { CORO_BEGIN_CODE(_ctx); - debug("Start FadeIn Music\n"); + debug("Start FadeIn Music"); for (_ctx->i = 0; _ctx->i < 16; _ctx->i++) { _vm->SetMusicVolume(nChannel, _ctx->i * 4); @@ -2267,7 +2267,7 @@ void ThreadFadeInMusic(CORO_PARAM, const void *nMusic) { } _vm->SetMusicVolume(nChannel, 64); - debug("End FadeIn Music\n"); + debug("End FadeIn Music"); CORO_KILL_SELF(); @@ -2286,7 +2286,7 @@ void ThreadFadeOutMusic(CORO_PARAM, const void *nMusic) { _ctx->startVolume = _vm->GetMusicVolume(nChannel); - debug("Start FadeOut Music\n"); + debug("Start FadeOut Music"); for (_ctx->i = 16; _ctx->i > 0 && !bFadeOutStop; _ctx->i--) { if (_ctx->i * 4 < _ctx->startVolume) @@ -2302,7 +2302,7 @@ void ThreadFadeOutMusic(CORO_PARAM, const void *nMusic) { if (nChannel == 2) _vm->StopMusic(2); - debug("End FadeOut Music\n"); + debug("End FadeOut Music"); CORO_KILL_SELF(); @@ -2470,14 +2470,14 @@ const char *staccFileNames[] = { void CustPlayMusic(uint32 nChannel, const char *mFN, uint32 nFX, bool bLoop, int nSync = 0) { if (nSync == 0) nSync = 2000; - debug("Start CustPlayMusic\n"); + debug("Start CustPlayMusic"); PlayMusic(nChannel, mFN, nFX, bLoop, nSync); - debug("End CustPlayMusic\n"); + debug("End CustPlayMusic"); } DECLARE_CUSTOM_FUNCTION(PlaySonoriz)(CORO_PARAM, uint32 nMusic, uint32 nFX, uint32 bNoLoop, uint32) { if (nFX == 0 || nFX == 1 || nFX==2) { - debug("PlaySonoriz stop fadeout\n"); + debug("PlaySonoriz stop fadeout"); bFadeOutStop = true; } -- cgit v1.2.3 From 166980fa4f7aa29ef604307662ed04d21b26a211 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 12 May 2012 00:08:09 +1000 Subject: TONY: Fix for properly signaling right button release. --- engines/tony/input.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp index b6793695f3..3574980176 100644 --- a/engines/tony/input.cpp +++ b/engines/tony/input.cpp @@ -86,7 +86,7 @@ void RMInput::Poll(void) { } else if (_event.type == Common::EVENT_RBUTTONDOWN) { _rightButton = true; _rightClickMouse = true; - } else if (_event.type == Common::EVENT_RBUTTONDOWN) { + } else if (_event.type == Common::EVENT_RBUTTONUP) { _rightButton = false; _rightReleaseMouse = true; } else -- cgit v1.2.3 From a153f9a2e633c788edd00b1c71c75377a3319e66 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 12 May 2012 10:34:52 +1000 Subject: TONY: Explicitly initialise fields of various objects in their constructors This fixes a crash when the pop-up inventory was displayed. --- engines/tony/gfxcore.cpp | 1 + engines/tony/inventory.cpp | 13 +++++++++++++ engines/tony/tonychar.cpp | 18 ++++++++++++++++++ engines/tony/tonychar.h | 4 +++- 4 files changed, 35 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index de78b51a4e..344542b801 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -287,6 +287,7 @@ RMGfxClearTask RMGfxTargetBuffer::taskClear; RMGfxTargetBuffer::RMGfxTargetBuffer() { otlist = NULL; + m_otSize = 0; csModifyingOT = g_system->createMutex(); } diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index 50e4dd9411..9d673459c5 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -64,6 +64,18 @@ RMInventory::RMInventory() { m_bCombining = false; m_csModifyInterface = g_system->createMutex(); m_nItems = 0; + + Common::fill(m_inv, m_inv + 256, 0); + m_nInv = 0; + m_curPutY = 0; + m_curPutTime = 0; + m_curPos = 0; + m_bHasFocus = false; + m_nSelectObj = 0; + m_nCombine = 0; + m_bBlinkingRight = false; + m_bBlinkingLeft = false; + miniAction = 0; } RMInventory::~RMInventory() { @@ -932,6 +944,7 @@ void RMInterface::Init(void) { */ m_bActive = false; m_bPalesati = false; + m_lastHotZone = 0; } void RMInterface::Close(void) { diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index 6a5d80f51e..982949870c 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -59,6 +59,24 @@ namespace Tony { bool RMTony::m_bAction = false; +RMTony::RMTony() { + m_bShow = false; + m_bShowOmbra = false; + m_bCorpoDavanti = false; + m_bActionPending = false; + m_ActionItem = NULL; + m_Action = 0; + m_ActionParm = 0; + m_bPastorella = false; + m_bIsStaticTalk = false; + m_bIsTalking = false; + m_nPatB4Talking = 0; + m_nTalkType = TALK_NORMAL; + m_TalkDirection = UP; + m_nTimeLastStep = 0; + hActionThread = CORO_INVALID_PID_VALUE; +} + void RMTony::WaitEndOfAction(CORO_PARAM, const void *param) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); diff --git a/engines/tony/tonychar.h b/engines/tony/tonychar.h index cf67db4df5..bbb1667c9b 100644 --- a/engines/tony/tonychar.h +++ b/engines/tony/tonychar.h @@ -127,7 +127,7 @@ private: protected: // Overload dell'allocazione degli sprites per cambiare il tipo - virtual RMGfxSourceBuffer* NewItemSpriteBuffer(int dimx, int dimy, bool bPreRLE); + virtual RMGfxSourceBuffer *NewItemSpriteBuffer(int dimx, int dimy, bool bPreRLE); // Thread which waits for the end of an action static void WaitEndOfAction(CORO_PARAM, const void *param); @@ -378,6 +378,8 @@ public: // per farlo rialzare, altrimenti private }; public: + RMTony(); + // Inizializza Tony void Init(void); -- cgit v1.2.3 From 435971f256f33f9944bc37f7c23c90eb70c77948 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 12 May 2012 10:55:18 +1000 Subject: TONY: Fixed the CopyMemory stub to copy the correct number of bytes. Tony can now leave his office without the game crashing. --- engines/tony/mpal/stubs.cpp | 4 ++++ engines/tony/mpal/stubs.h | 16 ++-------------- 2 files changed, 6 insertions(+), 14 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/stubs.cpp b/engines/tony/mpal/stubs.cpp index 23bc18b0ea..89740fdd52 100644 --- a/engines/tony/mpal/stubs.cpp +++ b/engines/tony/mpal/stubs.cpp @@ -40,6 +40,10 @@ uint16 GetAsyncKeyState(Common::KeyCode kc) { return 0; } +void CopyMemory(void *dst, const void *first, int size) { + Common::copy((const byte *)first, (const byte *)first + size, (byte *)dst); +} + } // end of namespace MPAL } // end of namespace Tony diff --git a/engines/tony/mpal/stubs.h b/engines/tony/mpal/stubs.h index ae25f7127e..ea88c1c76c 100644 --- a/engines/tony/mpal/stubs.h +++ b/engines/tony/mpal/stubs.h @@ -53,24 +53,12 @@ typedef void (*LPTHREAD_ROUTINE)(void *lpThreadParameter); #define PASCAL -/****************************************************************************\ -* Templates -\****************************************************************************/ - -/** - * Copies data from the range [first, last) to [dst, dst + (last - first)). - * It requires the range [dst, dst + (last - first)) to be valid. - * It also requires dst not to be in the range [first, last). - */ -template -Out CopyMemory(Out dst, In first, int size) { - return Common::copy(first, first + size, dst); -} - /****************************************************************************\ * Methods \****************************************************************************/ +extern void CopyMemory(void *dst, const void *first, int size); + extern uint16 GetAsyncKeyState(Common::KeyCode kc); } // end of namespace MPAL -- cgit v1.2.3 From 65ec900cebbfdbf453cdcdb8ec24f86bd797fdcd Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 12 May 2012 11:01:20 +1000 Subject: TONY: Removed old extern, PASCAL, and EXPORT function modifiers --- engines/tony/mpal/mpal.cpp | 12 ++++++------ engines/tony/mpal/mpal.h | 25 +++++++++---------------- engines/tony/mpal/stubs.h | 2 -- engines/tony/sound.cpp | 2 +- 4 files changed, 16 insertions(+), 25 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index a665fbacc5..d28fd8e8e2 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -816,7 +816,7 @@ static LPITEM GetItemData(uint32 nOrdItem) { /****************************************************************************\ * -* Function: void PASCAL CustomThread(LPCFCALL p); +* Function: void CustomThread(LPCFCALL p); * * Description: Thread che richiama una funzione custom. Viene usato negli * script, in modo che ciascuna funzione venga eseguita senza @@ -848,7 +848,7 @@ void CustomThread(CORO_PARAM, const void *param) { /****************************************************************************\ * -* Function: void PASCAL ScriptThread(LPMPALSCRIPT s); +* Function: void ScriptThread(LPMPALSCRIPT s); * * Description: Esegue uno script. Questa funzione e' pensata come starting * point per un thread @@ -946,7 +946,7 @@ void ScriptThread(CORO_PARAM, const void *param) { /****************************************************************************\ * -* Function: void PASCAL ActionThread(LPMPALITEM item); +* Function: void ActionThread(LPMPALITEM item); * * Description: Thread che esegue una azione su un item. Il thread * esegue sempre l'azione 0, per cui e' necessario creare @@ -1036,7 +1036,7 @@ void ShutUpActionThread(CORO_PARAM, const void *param) { /****************************************************************************\ * -* Function: void PASCAL LocationPollThread(uint32 id); +* Function: void LocationPollThread(uint32 id); * * Description: Esegue il polling di una locazione (starting point di un * thread). @@ -2323,7 +2323,7 @@ uint32 mpalGetError(void) { * \****************************************************************************/ -bool EXPORT mpalExecuteScript(int nScript) { +bool mpalExecuteScript(int nScript) { int n; LPMPALSCRIPT s; @@ -2355,7 +2355,7 @@ bool EXPORT mpalExecuteScript(int nScript) { * \****************************************************************************/ -void EXPORT mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCus) { +void mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCus) { lpiifCustom = lpiifCus; } diff --git a/engines/tony/mpal/mpal.h b/engines/tony/mpal/mpal.h index 49601bc1e9..1d298b4f26 100644 --- a/engines/tony/mpal/mpal.h +++ b/engines/tony/mpal/mpal.h @@ -138,7 +138,6 @@ namespace MPAL { #define MAXPOLLINGLOCATIONS 64 -#define EXPORT #define LPSTR char * /****************************************************************************\ @@ -570,12 +569,9 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; /****************************************************************************\ -* Functions exported DLL +* Functions exported to the main game \****************************************************************************/ -#ifdef __cplusplus -extern "C" { -#endif /****************************************************************************\ * @@ -593,7 +589,7 @@ extern "C" { * \****************************************************************************/ -bool EXPORT mpalInit(const char *lpszFileName, const char *lpszMprFileName, +bool mpalInit(const char *lpszFileName, const char *lpszMprFileName, LPLPCUSTOMFUNCTION lplpcfArray, Common::String *lpcfStrings); @@ -636,7 +632,7 @@ void mpalQueryCORO(CORO_PARAM, uint16 wQueryType, uint32 *dwRet, ...); * \****************************************************************************/ -bool EXPORT mpalExecuteScript(int nScript); +bool mpalExecuteScript(int nScript); @@ -650,7 +646,7 @@ bool EXPORT mpalExecuteScript(int nScript); * \****************************************************************************/ -uint32 EXPORT mpalGetError(void); +uint32 mpalGetError(void); @@ -665,7 +661,7 @@ uint32 EXPORT mpalGetError(void); * \****************************************************************************/ -void EXPORT mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCustom); +void mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCustom); /****************************************************************************\ @@ -684,7 +680,7 @@ void EXPORT mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCustom); * \****************************************************************************/ -bool EXPORT mpalStartIdlePoll(int nLoc); +bool mpalStartIdlePoll(int nLoc); /****************************************************************************\ @@ -715,7 +711,7 @@ void mpalEndIdlePoll(CORO_PARAM, int nLoc, bool *result); * \****************************************************************************/ -int EXPORT mpalLoadState(byte *buf); +int mpalLoadState(byte *buf); @@ -730,7 +726,7 @@ int EXPORT mpalLoadState(byte *buf); * \****************************************************************************/ -void EXPORT mpalSaveState(byte *buf); +void mpalSaveState(byte *buf); @@ -744,11 +740,8 @@ void EXPORT mpalSaveState(byte *buf); * \****************************************************************************/ -int EXPORT mpalGetSaveStateSize(void); +int mpalGetSaveStateSize(void); -#ifdef __cplusplus -} -#endif /****************************************************************************\ * diff --git a/engines/tony/mpal/stubs.h b/engines/tony/mpal/stubs.h index ea88c1c76c..66f83997ae 100644 --- a/engines/tony/mpal/stubs.h +++ b/engines/tony/mpal/stubs.h @@ -51,8 +51,6 @@ typedef void (*LPTHREAD_ROUTINE)(void *lpThreadParameter); #define MB_OK 1 -#define PASCAL - /****************************************************************************\ * Methods \****************************************************************************/ diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index c8caf5043d..0658c99f48 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -2069,7 +2069,7 @@ void FPSTREAM::WaitForSync(FPSTREAM *toplay) { * \****************************************************************************/ -void PASCAL FPSTREAM::PlayThread(FPSTREAM *This) { +void FPSTREAM::PlayThread(FPSTREAM *This) { #ifdef REFACTOR_ME byte *lpLockBuf; uint32 dwResult; -- cgit v1.2.3 From 109e5f8226c1db18926e307d4ecb9c3c83fdd7bc Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 12 May 2012 20:49:36 +1000 Subject: TONY: Conversion of more methods to coroutines --- engines/tony/custom.cpp | 9 +- engines/tony/detection_tables.h | 4 + engines/tony/font.cpp | 185 +++++++++++------ engines/tony/font.h | 24 +-- engines/tony/game.cpp | 431 +++++++++++++++++++++++++--------------- engines/tony/game.h | 28 +-- engines/tony/gfxcore.cpp | 124 ++++++++---- engines/tony/gfxcore.h | 33 +-- engines/tony/gfxengine.cpp | 24 ++- engines/tony/gfxengine.h | 1 + engines/tony/input.cpp | 12 ++ engines/tony/input.h | 11 +- engines/tony/inventory.cpp | 91 +++++---- engines/tony/inventory.h | 6 +- engines/tony/loc.cpp | 69 +++++-- engines/tony/loc.h | 16 +- engines/tony/tony.cpp | 27 +-- engines/tony/tonychar.cpp | 15 +- engines/tony/tonychar.h | 2 +- 19 files changed, 698 insertions(+), 414 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index a9e8e5bc62..a3a57dfce9 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -2155,6 +2155,9 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr if (_ctx->num == 1) { mpalQueryDialogSelection(_ctx->nChoice, _ctx->sl[0]); GlobalFree(_ctx->sl); + + // Wait for the next choice to be made + mpalQueryDialogWaitForChoice(&_ctx->nChoice); continue; } @@ -2181,7 +2184,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr while (!(Input->MouseLeftClicked() && ((_ctx->sel = _ctx->dc.GetSelection()) != -1))) { CORO_INVOKE_0(WaitFrame); Freeze(); - _ctx->dc.DoFrame(Input->MousePos()); + CORO_INVOKE_1(_ctx->dc.DoFrame, Input->MousePos()); Unfreeze(); } @@ -2214,7 +2217,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr DECLARE_CUSTOM_FUNCTION(TakeOwnership)(CORO_PARAM, uint32 num, uint32, uint32, uint32) { // EnterCriticalSection(&cs[num]); // WaitForSingleObject(mut[num],CORO_INFINITE); - warning("TODO"); + warning("TODO: TakeOwnership"); } DECLARE_CUSTOM_FUNCTION(ReleaseOwnership)(CORO_PARAM, uint32 num, uint32, uint32, uint32) { @@ -2644,7 +2647,7 @@ DECLARE_CUSTOM_FUNCTION(DoCredits)(CORO_PARAM, uint32 nMsg, uint32 dwTime, uint3 CORO_INVOKE_0(WaitFrame); if (Input->MouseLeftClicked() || Input->MouseRightClicked()) break; - if ((GetAsyncKeyState(Common::KEYCODE_TAB) & 0x8001) == 0x8001) + if (_vm->GetEngine()->GetInput().GetAsyncKeyState(Common::KEYCODE_TAB)) break; } diff --git a/engines/tony/detection_tables.h b/engines/tony/detection_tables.h index bb660dd862..afcf787ca1 100644 --- a/engines/tony/detection_tables.h +++ b/engines/tony/detection_tables.h @@ -32,7 +32,11 @@ static const TonyGameDescription gameDescriptions[] = { AD_ENTRY1s("roasted.mpr", "06203dbbc85fdd1e6dc8fc211c1a6207", 14972409), Common::EN_ANY, Common::kPlatformPC, +#ifdef TEMPORARY_DISABLED ADGF_DEMO, +#else + ADGF_NO_FLAGS, +#endif GUIO1(GUIO_NONE) }, }, diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 8cc60a917b..5712014bf2 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -152,12 +152,19 @@ RMGfxPrimitive *RMFont::MakeLetterPrimitive(byte bChar, int &nLength) { return prim; } -void RMFont::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim2) { - RMFontPrimitive *prim = (RMFontPrimitive *)prim2; +void RMFont::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim2) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + RMFontPrimitive *prim = (RMFontPrimitive *)prim2; + + CORO_BEGIN_CODE(_ctx); + + // Richiama la Draw della lettera assegnata alla primitiva + if (prim->m_nChar != -1) + CORO_INVOKE_2(m_letter[prim->m_nChar].Draw, bigBuf, prim); - // Richiama la Draw della lettera assegnata alla primitiva - if (prim->m_nChar != -1) - m_letter[prim->m_nChar].Draw(bigBuf,prim); + CORO_END_CODE; } void RMFont::Close(void) { @@ -1845,10 +1852,10 @@ void RMText::SetMaxLineLength(int max) { maxLineLength = max; } -bool RMText::RemoveThis() { +void RMText::RemoveThis(CORO_PARAM, bool &result) { // Qui possiamo fare i controlli sul numero di frame, sul tempo trascorso // etc. - return true; + result = true; } @@ -2007,7 +2014,11 @@ void RMText::ClipOnScreen(RMGfxPrimitive *prim) { if (prim->Dst().y1+m_dimy > 475) prim->Dst().y1 = 475 - m_dimy; } -void RMText::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMText::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); // Allinea orizzontalmente if (aHorType == HCENTER) prim->Dst().TopLeft() -= RMPoint(m_dimx / 2, 0); @@ -2016,22 +2027,20 @@ void RMText::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { // Alinea verticalemente - switch (aVerType) { - case VTOP: - break; + if (aVerType == VTOP) { - case VCENTER: - prim->Dst().y1-=m_dimy/2; - break; + } else if (aVerType == VCENTER) { + prim->Dst().y1 -= m_dimy / 2; - case VBOTTOM: - prim->Dst().y1-=m_dimy; - break; + } else if (aVerType == VBOTTOM) { + prim->Dst().y1 -= m_dimy; } ClipOnScreen(prim); - RMGfxWoodyBuffer::Draw(bigBuf,prim); + CORO_INVOKE_2(RMGfxWoodyBuffer::Draw, bigBuf, prim); + + CORO_END_CODE; } /****************************************************************************\ @@ -2127,7 +2136,7 @@ void RMTextDialog::RemoveThis(CORO_PARAM, bool &result) { } if (!m_bNoTab) - if ((GetAsyncKeyState(Common::KEYCODE_TAB) & 0x8001) == 0x8001) + if (_vm->GetEngine()->GetInput().GetAsyncKeyState(Common::KEYCODE_TAB)) return; if (!m_bNoTab) @@ -2173,16 +2182,23 @@ void RMTextDialog::Unregister(void) { CoroScheduler.setEvent(hEndDisplay); } -void RMTextDialog::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMTextDialog::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + if (m_startTime == 0) m_startTime = _vm->GetTime(); if (m_bShowed) { if (bCfgSottotitoli || m_bAlwaysDisplay) { prim->Dst().TopLeft() = dst; - RMText::Draw(bigBuf, prim); + CORO_INVOKE_2(RMText::Draw, bigBuf, prim); } } + + CORO_END_CODE; } void RMTextDialog::SetCustomSkipHandle(uint32 hCustom) { @@ -2217,17 +2233,23 @@ RMTextDialogScrolling::RMTextDialogScrolling(RMLocation *loc) { RMTextDialogScrolling::~RMTextDialogScrolling() { } -void RMTextDialogScrolling::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { - RMPoint curDst; +void RMTextDialogScrolling::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + CORO_BEGIN_CONTEXT; + RMPoint curDst; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); - curDst = dst; + _ctx->curDst = dst; if (curLoc != NULL) dst -= curLoc->ScrollPosition() - startScroll; - RMTextDialog::Draw(bigBuf, prim); + CORO_INVOKE_2(RMTextDialog::Draw, bigBuf, prim); + + dst = _ctx->curDst; - dst = curDst; + CORO_END_CODE; } void RMTextDialogScrolling::ClipOnScreen(RMGfxPrimitive *prim) { @@ -2298,7 +2320,12 @@ void RMTextItemName::DoFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation & } -void RMTextItemName::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMTextItemName::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + // Se non c'e' testo, e' inutile continuare if (m_buf == NULL) return; @@ -2306,7 +2333,9 @@ void RMTextItemName::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { // Setta come coordinate destinazione quelle del mouse prim->Dst().TopLeft() = m_mpos-RMPoint(0, 30); - RMText::Draw(bigBuf,prim); + CORO_INVOKE_2(RMText::Draw, bigBuf, prim); + + CORO_END_CODE; } RMPoint RMTextItemName::GetHotspot() { @@ -2411,9 +2440,13 @@ void RMDialogChoice::AddChoice(RMString string) { m_drawedStrings[m_curAdded++].WriteText(string,0); } -void RMDialogChoice::Prepare(void) { - int i; - RMPoint ptPos; +void RMDialogChoice::Prepare(CORO_PARAM) { + CORO_BEGIN_CONTEXT; + int i; + RMPoint ptPos; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); AddPrim(new RMGfxPrimitive(&DlgText,RMPoint(0,0))); AddPrim(new RMGfxPrimitive(&DlgTextLine,RMPoint(0,155))); @@ -2421,53 +2454,60 @@ void RMDialogChoice::Prepare(void) { AddPrim(new RMGfxPrimitive(&DlgTextLine,RMPoint(0,155+83+83))); AddPrim(new RMGfxPrimitive(&DlgTextLine,RMPoint(0,155+83+83+83))); - ptPos.Set(20,90); + _ctx->ptPos.Set(20,90); - for (i = 0; i < m_numChoices; i++) { - AddPrim(new RMGfxPrimitive(&m_drawedStrings[i], ptPos)); - m_ptDrawStrings[i] = ptPos; - ptPos.Offset(0,m_drawedStrings[i].Dimy() + 15); + for (_ctx->i = 0; _ctx->i < m_numChoices; _ctx->i++) { + AddPrim(new RMGfxPrimitive(&m_drawedStrings[_ctx->i], _ctx->ptPos)); + m_ptDrawStrings[_ctx->i] = _ctx->ptPos; + _ctx->ptPos.Offset(0,m_drawedStrings[_ctx->i].Dimy() + 15); } - DrawOT(); + CORO_INVOKE_0(DrawOT); ClearOT(); - m_ptDrawPos.Set(0,480-ptPos.y); + m_ptDrawPos.Set(0,480-_ctx->ptPos.y); + + CORO_END_CODE; } -void RMDialogChoice::SetSelected(int pos) { - //uint16 * buf = (uint16 *)m_buf; - RMGfxBox box; - RMRect rc; +void RMDialogChoice::SetSelected(CORO_PARAM, int pos) { + CORO_BEGIN_CONTEXT; + RMGfxBox box; + RMRect rc; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); if (pos == m_curSelection) return; - box.SetPriority(5); + _ctx->box.SetPriority(5); if (m_curSelection != -1) { - box.SetColor(0xCC, 0xCC, 0xFF); - rc.TopLeft()=RMPoint(18, m_ptDrawStrings[m_curSelection].y); - rc.BottomRight() = rc.TopLeft() + RMPoint(597, m_drawedStrings[m_curSelection].Dimy()); - AddPrim(new RMGfxPrimitive(&box, rc)); + _ctx->box.SetColor(0xCC, 0xCC, 0xFF); + _ctx->rc.TopLeft()=RMPoint(18, m_ptDrawStrings[m_curSelection].y); + _ctx->rc.BottomRight() = _ctx->rc.TopLeft() + RMPoint(597, m_drawedStrings[m_curSelection].Dimy()); + AddPrim(new RMGfxPrimitive(&_ctx->box, _ctx->rc)); AddPrim(new RMGfxPrimitive(&m_drawedStrings[m_curSelection], m_ptDrawStrings[m_curSelection])); - DrawOT(); + CORO_INVOKE_0(DrawOT); ClearOT(); } if (pos != -1) { - box.SetColor(100, 100, 100); - rc.TopLeft()=RMPoint(18, m_ptDrawStrings[pos].y); - rc.BottomRight() = rc.TopLeft()+RMPoint(597, m_drawedStrings[pos].Dimy()); - AddPrim(new RMGfxPrimitive(&box, rc)); + _ctx->box.SetColor(100, 100, 100); + _ctx->rc.TopLeft()=RMPoint(18, m_ptDrawStrings[pos].y); + _ctx->rc.BottomRight() = _ctx->rc.TopLeft()+RMPoint(597, m_drawedStrings[pos].Dimy()); + AddPrim(new RMGfxPrimitive(&_ctx->box, _ctx->rc)); AddPrim(new RMGfxPrimitive(&m_drawedStrings[pos], m_ptDrawStrings[pos])); } - DrawOT(); + CORO_INVOKE_0(DrawOT); ClearOT(); m_curSelection = pos; + + CORO_END_CODE; } void RMDialogChoice::Show(CORO_PARAM, RMGfxTargetBuffer *bigBuf) { @@ -2480,7 +2520,7 @@ void RMDialogChoice::Show(CORO_PARAM, RMGfxTargetBuffer *bigBuf) { CORO_BEGIN_CODE(_ctx); - Prepare(); + CORO_INVOKE_0(Prepare); m_bShow = false; if (!m_nInList && bigBuf != NULL) @@ -2513,12 +2553,19 @@ void RMDialogChoice::Show(CORO_PARAM, RMGfxTargetBuffer *bigBuf) { CORO_END_CODE; } -void RMDialogChoice::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMDialogChoice::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + if (m_bShow == false) return; prim->SetDst(m_ptDrawPos); - RMGfxSourceBuffer16::Draw(bigBuf, prim); + CORO_INVOKE_2(RMGfxSourceBuffer16::Draw, bigBuf, prim); + + CORO_END_CODE; } @@ -2553,24 +2600,30 @@ void RMDialogChoice::Hide(CORO_PARAM) { } -bool RMDialogChoice::RemoveThis(void) { - return bRemoveFromOT; +void RMDialogChoice::RemoveThis(CORO_PARAM, bool &result) { + result = bRemoveFromOT; } -void RMDialogChoice::DoFrame(RMPoint ptMousePos) { - int i; - +void RMDialogChoice::DoFrame(CORO_PARAM, RMPoint ptMousePos) { + CORO_BEGIN_CONTEXT; + int i; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + if (ptMousePos.y > m_ptDrawPos.y) { - for (i = 0; i < m_numChoices; i++) { - if ((ptMousePos.y >= m_ptDrawPos.y+m_ptDrawStrings[i].y) && (ptMousePos.y < m_ptDrawPos.y+m_ptDrawStrings[i].y+m_drawedStrings[i].Dimy())) { - SetSelected(i); + for (_ctx->i = 0; _ctx->i < m_numChoices; _ctx->i++) { + if ((ptMousePos.y >= m_ptDrawPos.y+m_ptDrawStrings[_ctx->i].y) && (ptMousePos.y < m_ptDrawPos.y+m_ptDrawStrings[_ctx->i].y+m_drawedStrings[_ctx->i].Dimy())) { + CORO_INVOKE_1(SetSelected, _ctx->i); break; } } - if (i == m_numChoices) - SetSelected(-1); + if (_ctx->i == m_numChoices) + CORO_INVOKE_1(SetSelected, -1); } + + CORO_END_CODE; } int RMDialogChoice::GetSelection(void) { diff --git a/engines/tony/font.h b/engines/tony/font.h index d883733db6..7c766e5d01 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -112,7 +112,7 @@ public: virtual void Close(void); // Funzione del task da overloadare - void Draw(RMGfxTargetBuffer &bigBug, RMGfxPrimitive *prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBug, RMGfxPrimitive *prim); // Crea una primitiva per una lettera RMGfxPrimitive *MakeLetterPrimitive(byte bChar, int& nLength); @@ -230,10 +230,10 @@ public: // Overloading della funzione ereditata da RMGfxTask per decidere // quando eliminare un oggetto dalla OTLIST - virtual bool RemoveThis(void); + virtual void RemoveThis(CORO_PARAM, bool &result); // Overloading del Draw per centrare la scritta, se necessario - virtual void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Setta il colore di base void SetColor(byte r, byte g, byte b) { m_r=r; m_g=g; m_b=b; } @@ -275,7 +275,7 @@ class RMTextDialog : public RMText { virtual void Unregister(void); // Overloading del Draw per centrare la scritta, se necessario - virtual void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Setta la posizione void SetPosition(RMPoint pt) { dst=pt; } @@ -310,7 +310,7 @@ public: RMTextDialogScrolling(RMLocation* loc); virtual ~RMTextDialogScrolling(); - virtual void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); }; @@ -334,14 +334,14 @@ public: void SetMouseCoord(RMPoint m) { m_mpos=m; } void DoFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation &loc, RMPointer &ptr, RMInventory &inv); - virtual void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); RMPoint GetHotspot(); RMItem *GetSelectedItem(); bool IsItemSelected(); bool IsNormalItemSelected(); - virtual bool RemoveThis() { return true; } + virtual void RemoveThis(CORO_PARAM, bool &result) { result = true; } }; @@ -363,12 +363,12 @@ private: bool bRemoveFromOT; protected: - void Prepare(void); - void SetSelected(int pos); + void Prepare(CORO_PARAM); + void SetSelected(CORO_PARAM, int pos); public: - bool RemoveThis(void); - void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); + virtual void RemoveThis(CORO_PARAM, bool &result); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); void Unregister(void); public: @@ -394,7 +394,7 @@ public: void Hide(CORO_PARAM); // Polling di aggiornamento - void DoFrame(RMPoint ptMousePos); + void DoFrame(CORO_PARAM, RMPoint ptMousePos); // Ritorna la voce attualmente selezionata, o -1 se nessuna selezionata int GetSelection(void); diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 820641e48f..e5e08f57e7 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -217,12 +217,19 @@ bool RMOptionButton::DoFrame(RMPoint mousePos, bool bLeftClick, bool bRightClick -void RMOptionButton::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMOptionButton::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + if (!m_bActive) return; if (m_bHasGfx) - m_buf->Draw(bigBuf,prim); + CORO_INVOKE_2(m_buf->Draw, bigBuf, prim); + + CORO_END_CODE; } void RMOptionButton::AddToList(RMGfxTargetBuffer &bigBuf) { @@ -310,37 +317,43 @@ bool RMOptionSlide::DoFrame(RMPoint mousePos, bool bLeftClick, bool bRightClick) return bRefresh; } -void RMOptionSlide::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { - int i; - int val; +void RMOptionSlide::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + CORO_BEGIN_CONTEXT; + int i; + int val; + RMPoint pos; + CORO_END_CONTEXT(_ctx); - RMPoint pos; - pos = m_pos; - pos.x += 4; - pos.y += 4; + CORO_BEGIN_CODE(_ctx); + + _ctx->pos = m_pos; + _ctx->pos.x += 4; + _ctx->pos.y += 4; - val = m_nValue * m_nStep; - if (val < 1) val = 1; - else if (val > 100) val = 100; + _ctx->val = m_nValue * m_nStep; + if (_ctx->val < 1) _ctx->val = 1; + else if (_ctx->val > 100) _ctx->val = 100; - if (val == 1) { - prim->SetDst(pos); - m_SliderSingle->Draw(bigBuf, prim); + if (_ctx->val == 1) { + prim->SetDst(_ctx->pos); + CORO_INVOKE_2(m_SliderSingle->Draw, bigBuf, prim); } else { - prim->SetDst(pos); - m_SliderLeft->Draw(bigBuf, prim); - pos.x += 3; - - for (i = 1; i < val - 1; i++) { - prim->SetDst(pos); - m_SliderCenter->Draw(bigBuf, prim); - pos.x += 3; + prim->SetDst(_ctx->pos); + CORO_INVOKE_2(m_SliderLeft->Draw, bigBuf, prim); + _ctx->pos.x += 3; + + for (_ctx->i = 1; _ctx->i < _ctx->val - 1; _ctx->i++) { + prim->SetDst(_ctx->pos); + CORO_INVOKE_2(m_SliderCenter->Draw, bigBuf, prim); + _ctx->pos.x += 3; } - prim->SetDst(pos); - m_SliderRight->Draw(bigBuf, prim); - pos.x += 3; + prim->SetDst(_ctx->pos); + CORO_INVOKE_2(m_SliderRight->Draw, bigBuf, prim); + _ctx->pos.x += 3; } + + CORO_END_CODE; } void RMOptionSlide::AddToList(RMGfxTargetBuffer &bigBuf) { @@ -379,12 +392,49 @@ RMOptionScreen::RMOptionScreen(void) { } m_statePos = 0; + m_ButtonQuitYes = NULL; + m_ButtonQuitNo = NULL; + m_ButtonQuit = NULL; + m_SaveEasy = NULL; + m_SaveHard = NULL; + m_ButtonGfx_Tips = NULL; + m_ButtonSound_DubbingOn = NULL; + m_ButtonSound_MusicOn = NULL; + m_ButtonSound_SFXOn = NULL; + m_SlideTonySpeed = NULL; + m_SlideTextSpeed = NULL; + m_ButtonGame_Lock = NULL; + m_ButtonGfx_Anni30 = NULL; + m_SliderSound_Music = NULL; + m_ButtonGame_TimerizedText = NULL; + m_ButtonGfx_AntiAlias = NULL; + m_SliderSound_SFX = NULL; + m_ButtonGame_Scrolling = NULL; + m_ButtonGfx_Sottotitoli = NULL; + m_SliderSound_Dubbing = NULL; + m_ButtonGame_InterUp = NULL; + m_ButtonGfx_Trans = NULL; + + m_FadeStep = 0; + m_FadeY = 0; + m_FadeTime = 0; + m_nEditPos = 0; + m_nLastState = MENUGAME; } + RMOptionScreen::~RMOptionScreen(void) { } -void RMOptionScreen::RefreshAll(void) { +void RMOptionScreen::RefreshAll(CORO_PARAM) { + CORO_BEGIN_CONTEXT; + RMGfxSourceBuffer16 *thumb; + RMText* title; + RMText *num[6]; + int i; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); ClearOT(); AddPrim(new RMGfxPrimitive(m_menu)); @@ -428,22 +478,21 @@ void RMOptionScreen::RefreshAll(void) { m_ButtonSound_SFXOn->AddToList(*this); } - RMGfxSourceBuffer16 *thumb = NULL; - RMText* title = NULL; - RMText* num[6] = { NULL, NULL, NULL, NULL, NULL, NULL }; - int i; + _ctx->thumb = NULL; + _ctx->title = NULL; + Common::fill(&_ctx->num[0], &_ctx->num[6], (RMText *)NULL); if (m_nState == MENULOAD || m_nState == MENUSAVE) { - title = new RMText; + _ctx->title = new RMText; if (m_nState == MENULOAD) { RMMessage msg(10); - title->WriteText(msg[0], 1); + _ctx->title->WriteText(msg[0], 1); } else { RMMessage msg(11); - title->WriteText(msg[0], 1); + _ctx->title->WriteText(msg[0], 1); } - AddPrim(new RMGfxPrimitive(title, RMPoint(320, 10))); + AddPrim(new RMGfxPrimitive(_ctx->title, RMPoint(320, 10))); if (m_curThumbDiff[0] == 0) AddPrim(new RMGfxPrimitive(m_SaveHard, RMPoint(48, 57))); else if (m_curThumbDiff[0] == 1) AddPrim(new RMGfxPrimitive(m_SaveEasy, RMPoint(48, 57))); @@ -466,56 +515,62 @@ void RMOptionScreen::RefreshAll(void) { if (m_curThumb[5] && !(m_bEditSaveName && m_nEditPos == 5)) AddPrim(new RMGfxPrimitive(m_curThumb[5], RMPoint(432, 239))); if (m_bEditSaveName) { - thumb = new RMGfxSourceBuffer16; - thumb->Init((byte *)_vm->GetThumbnail(), 640 / 4, 480 / 4); - - switch (m_nEditPos) { - case 0: AddPrim(new RMGfxPrimitive(thumb,RMPoint(48, 57))); break; - case 1: AddPrim(new RMGfxPrimitive(thumb,RMPoint(240, 57))); break; - case 2: AddPrim(new RMGfxPrimitive(thumb,RMPoint(432, 57))); break; - case 3: AddPrim(new RMGfxPrimitive(thumb,RMPoint(48, 239))); break; - case 4: AddPrim(new RMGfxPrimitive(thumb,RMPoint(240, 239))); break; - case 5: AddPrim(new RMGfxPrimitive(thumb,RMPoint(432, 239))); break; - } + _ctx->thumb = new RMGfxSourceBuffer16; + _ctx->thumb->Init((byte *)_vm->GetThumbnail(), 640 / 4, 480 / 4); + + if (m_nEditPos == 0) + AddPrim(new RMGfxPrimitive(_ctx->thumb,RMPoint(48, 57))); + else if (m_nEditPos == 1) + AddPrim(new RMGfxPrimitive(_ctx->thumb,RMPoint(240, 57))); + else if (m_nEditPos == 2) + AddPrim(new RMGfxPrimitive(_ctx->thumb,RMPoint(432, 57))); + else if (m_nEditPos == 3) + AddPrim(new RMGfxPrimitive(_ctx->thumb,RMPoint(48, 239))); + else if (m_nEditPos == 4) + AddPrim(new RMGfxPrimitive(_ctx->thumb,RMPoint(240, 239))); + else if (m_nEditPos == 5) + AddPrim(new RMGfxPrimitive(_ctx->thumb,RMPoint(432, 239))); } - for (i = 0; i < 6; i++) { + for (_ctx->i = 0; _ctx->i < 6; _ctx->i++) { RMString s; - if (m_bEditSaveName && m_nEditPos == i) - s.Format("%02d)%s*", m_statePos + i, m_EditName); + if (m_bEditSaveName && m_nEditPos == _ctx->i) + s.Format("%02d)%s*", m_statePos + _ctx->i, m_EditName); else { - if (m_statePos == 0 && i == 0) + if (m_statePos == 0 && _ctx->i == 0) s.Format("Autosave"); else - s.Format("%02d)%s", m_statePos + i, (const char *)m_curThumbName[i]); + s.Format("%02d)%s", m_statePos + _ctx->i, (const char *)m_curThumbName[_ctx->i]); } - num[i] = new RMText; - num[i]->SetAlignType(RMText::HLEFT, RMText::VTOP); - num[i]->WriteText(s, 2); + _ctx->num[_ctx->i] = new RMText; + _ctx->num[_ctx->i]->SetAlignType(RMText::HLEFT, RMText::VTOP); + _ctx->num[_ctx->i]->WriteText(s, 2); } - AddPrim(new RMGfxPrimitive(num[0], RMPoint(55 - 3, 180 + 14))); - AddPrim(new RMGfxPrimitive(num[1], RMPoint(247 - 3, 180 + 14))); - AddPrim(new RMGfxPrimitive(num[2],RMPoint(439 - 3, 180 + 14))); - AddPrim(new RMGfxPrimitive(num[3],RMPoint(55 - 3, 362 + 14))); - AddPrim(new RMGfxPrimitive(num[4],RMPoint(247 - 3, 362 + 14))); - AddPrim(new RMGfxPrimitive(num[5],RMPoint(439 - 3, 362 + 14))); + AddPrim(new RMGfxPrimitive(_ctx->num[0], RMPoint(55 - 3, 180 + 14))); + AddPrim(new RMGfxPrimitive(_ctx->num[1], RMPoint(247 - 3, 180 + 14))); + AddPrim(new RMGfxPrimitive(_ctx->num[2],RMPoint(439 - 3, 180 + 14))); + AddPrim(new RMGfxPrimitive(_ctx->num[3],RMPoint(55 - 3, 362 + 14))); + AddPrim(new RMGfxPrimitive(_ctx->num[4],RMPoint(247 - 3, 362 + 14))); + AddPrim(new RMGfxPrimitive(_ctx->num[5],RMPoint(439 - 3, 362 + 14))); m_ButtonSave_ArrowLeft->AddToList(*this); m_ButtonSave_ArrowRight->AddToList(*this); } - DrawOT(); + CORO_INVOKE_0(DrawOT); if (m_nState == MENULOAD || m_nState == MENUSAVE) { - if (thumb) delete thumb; - if (title) delete title; + if (_ctx->thumb) delete _ctx->thumb; + if (_ctx->title) delete _ctx->title; - for (i = 0; i < 6; i++) - if (num[i]) delete num[i]; + for (_ctx->i = 0; _ctx->i < 6; _ctx->i++) + if (_ctx->num[_ctx->i]) delete _ctx->num[_ctx->i]; } + + CORO_END_CODE; } void RMOptionScreen::RefreshThumbnails(void) { @@ -537,25 +592,29 @@ void RMOptionScreen::RefreshThumbnails(void) { } -void RMOptionScreen::InitState(void) { - RMResRaw *raw; +void RMOptionScreen::InitState(CORO_PARAM) { + CORO_BEGIN_CONTEXT; + RMResRaw *raw; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); if (m_nState == MENUGAME || m_nState == MENUGFX || m_nState == MENUSOUND) - raw = new RMResRaw(20000 + m_nState); + _ctx->raw = new RMResRaw(20000 + m_nState); else if (m_nState == MENULOAD || m_nState == MENUSAVE) { if (m_bAlterGfx) - raw = new RMResRaw(20024); + _ctx->raw = new RMResRaw(20024); else - raw = new RMResRaw(20003); + _ctx->raw = new RMResRaw(20003); } else { error("Invalid state"); } - assert(raw->IsValid()); + assert(_ctx->raw->IsValid()); assert(m_menu == NULL); m_menu = new RMGfxSourceBuffer16(false); - m_menu->Init(*raw, raw->Width(), raw->Height()); - delete raw; + m_menu->Init(*_ctx->raw, _ctx->raw->Width(), _ctx->raw->Height()); + delete _ctx->raw; if (m_nState == MENULOAD || m_nState == MENUSAVE) { if (m_bAlterGfx) { @@ -566,8 +625,8 @@ void RMOptionScreen::InitState(void) { m_ButtonExit = new RMOptionButton(20012, RMPoint(560, 404)); } - INIT_GFX8_FROMRAW(20036, m_SaveEasy); - INIT_GFX8_FROMRAW(20037, m_SaveHard); + INIT_GFX8_FROMRAW(_ctx->raw, 20036, m_SaveEasy); + INIT_GFX8_FROMRAW(_ctx->raw, 20037, m_SaveHard); RefreshThumbnails(); @@ -612,12 +671,12 @@ void RMOptionScreen::InitState(void) { assert(m_ButtonSoundMenu == NULL); m_ButtonSoundMenu = new RMOptionButton(RMRect(212, 32, 306, 64)); - raw = new RMResRaw(20021); - assert(raw->IsValid()); + _ctx->raw = new RMResRaw(20021); + assert(_ctx->raw->IsValid()); assert(m_QuitConfirm == NULL); m_QuitConfirm = new RMGfxSourceBuffer16(false); - m_QuitConfirm->Init(*raw, raw->Width(), raw->Height()); - delete raw; + m_QuitConfirm->Init(*_ctx->raw, _ctx->raw->Width(), _ctx->raw->Height()); + delete _ctx->raw; assert(m_ButtonQuitYes == NULL); m_ButtonQuitYes = new RMOptionButton(20022, RMPoint(281, 265)); @@ -627,12 +686,12 @@ void RMOptionScreen::InitState(void) { m_ButtonQuitNo->SetPriority(30); if (m_bNoLoadSave) { - raw = new RMResRaw(20028); - assert(raw->IsValid()); + _ctx->raw = new RMResRaw(20028); + assert(_ctx->raw->IsValid()); assert(m_HideLoadSave == NULL); m_HideLoadSave = new RMGfxSourceBuffer16(false); - m_HideLoadSave->Init(*raw, raw->Width(), raw->Height()); - delete raw; + m_HideLoadSave->Init(*_ctx->raw, _ctx->raw->Width(), _ctx->raw->Height()); + delete _ctx->raw; } // Menu GAME @@ -693,7 +752,9 @@ void RMOptionScreen::InitState(void) { } } - RefreshAll(); + CORO_INVOKE_0(RefreshAll); + + CORO_END_CODE; } void RMOptionScreen::CloseState(void) { @@ -828,9 +889,16 @@ void RMOptionScreen::ReInit(RMGfxTargetBuffer &bigBuf) { bigBuf.AddPrim(new RMGfxPrimitive(this)); } -bool RMOptionScreen::Init(RMGfxTargetBuffer &bigBuf) { - if (m_FadeStep != 0) - return false; +void RMOptionScreen::Init(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool &result) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + if (m_FadeStep != 0) { + result = false; + return; + } m_FadeStep = 1; m_FadeY = -20; @@ -844,14 +912,24 @@ bool RMOptionScreen::Init(RMGfxTargetBuffer &bigBuf) { if (m_nState == MENULOAD || m_nState == MENUSAVE) m_nState = MENUGAME; - InitState(); + + CORO_INVOKE_0(InitState); - return true; + result = true; + + CORO_END_CODE; } -bool RMOptionScreen::InitLoadMenuOnly(RMGfxTargetBuffer &bigBuf, bool bAlternateGfx) { - if (m_FadeStep != 0) - return false; +void RMOptionScreen::InitLoadMenuOnly(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool bAlternateGfx, bool &result) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + if (m_FadeStep != 0) { + result = false; + return; + } m_FadeStep = 1; m_FadeY = -20; @@ -864,14 +942,23 @@ bool RMOptionScreen::InitLoadMenuOnly(RMGfxTargetBuffer &bigBuf, bool bAlternate bigBuf.AddPrim(new RMGfxPrimitive(this)); m_nState = MENULOAD; - InitState(); + CORO_INVOKE_0(InitState); - return true; + result = true; + + CORO_END_CODE; } -bool RMOptionScreen::InitSaveMenuOnly(RMGfxTargetBuffer &bigBuf, bool bAlternateGfx) { - if (m_FadeStep != 0) - return false; +void RMOptionScreen::InitSaveMenuOnly(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool bAlternateGfx, bool &result) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + if (m_FadeStep != 0) { + result = false; + return; + } m_FadeStep = 1; m_FadeY = -20; @@ -884,14 +971,23 @@ bool RMOptionScreen::InitSaveMenuOnly(RMGfxTargetBuffer &bigBuf, bool bAlternate bigBuf.AddPrim(new RMGfxPrimitive(this)); m_nState = MENUSAVE; - InitState(); + CORO_INVOKE_0(InitState); - return true; + result = true; + + CORO_END_CODE; } -bool RMOptionScreen::InitNoLoadSave(RMGfxTargetBuffer &bigBuf) { - if (m_FadeStep != 0) - return false; +void RMOptionScreen::InitNoLoadSave(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool &result) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + if (m_FadeStep != 0) { + result = false; + return; + } m_FadeStep = 1; m_FadeY = -20; @@ -903,9 +999,11 @@ bool RMOptionScreen::InitNoLoadSave(RMGfxTargetBuffer &bigBuf) { bigBuf.AddPrim(new RMGfxPrimitive(this)); m_nState = MENUGAME; - InitState(); + CORO_INVOKE_0(InitState); - return true; + result = true; + + CORO_END_CODE; } bool RMOptionScreen::Close(void) { @@ -927,11 +1025,18 @@ int RMOptionScreen::Priority() { return 190; } -void RMOptionScreen::ChangeState(STATE newState) { +void RMOptionScreen::ChangeState(CORO_PARAM, STATE newState) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + CloseState(); m_nLastState = m_nState; m_nState = newState; - InitState(); + CORO_INVOKE_0(InitState); + + CORO_END_CODE; } void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { @@ -1015,7 +1120,7 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { } } -#define KEYPRESS(c) ((GetAsyncKeyState(c)&0x8001)==0x8001) +#define KEYPRESS(c) (_vm->GetEngine()->GetInput().GetAsyncKeyState(c)) #define PROCESS_CHAR(cod,c) if (KEYPRESS(cod)) { \ m_EditName[strlen(m_EditName) +1 ] = '\0'; m_EditName[strlen(m_EditName)] = c; _ctx->bRefresh = true; } @@ -1029,8 +1134,8 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { } for (_ctx->i=0;_ctx->i<26 && strlen(m_EditName)<12;_ctx->i++) - if ((GetAsyncKeyState(Common::KEYCODE_LSHIFT) & 0x8000) || - (GetAsyncKeyState(Common::KEYCODE_RSHIFT) & 0x8000)) { + if (KEYPRESS(Common::KEYCODE_LSHIFT) || + KEYPRESS(Common::KEYCODE_RSHIFT)) { PROCESS_CHAR((Common::KeyCode)((int)'a' + _ctx->i), _ctx->i + 'A'); } else { PROCESS_CHAR((Common::KeyCode)((int)'a' + _ctx->i), _ctx->i + 'a'); @@ -1073,7 +1178,7 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { // Se solo il menu di loading, chiudiamo Close(); } else { - ChangeState(m_nLastState); + CORO_INVOKE_1(ChangeState, m_nLastState); _ctx->bRefresh = true; } } else if (m_ButtonSave_ArrowLeft->IsActive()) { @@ -1136,19 +1241,19 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { } else if (m_ButtonExit->IsActive()) Close(); else if (m_ButtonLoad->IsActive()) { - ChangeState(MENULOAD); + CORO_INVOKE_1(ChangeState, MENULOAD); _ctx->bRefresh = true; } else if (m_ButtonSave->IsActive()) { - ChangeState(MENUSAVE); + CORO_INVOKE_1(ChangeState, MENUSAVE); _ctx->bRefresh = true; } else if (m_ButtonGameMenu->IsActive() && m_nState != MENUGAME) { - ChangeState(MENUGAME); + CORO_INVOKE_1(ChangeState, MENUGAME); _ctx->bRefresh = true; } else if (m_ButtonGfxMenu->IsActive() && m_nState != MENUGFX) { - ChangeState(MENUGFX); + CORO_INVOKE_1(ChangeState, MENUGFX); _ctx->bRefresh = true; } else if (m_ButtonSoundMenu->IsActive() && m_nState != MENUSOUND) { - ChangeState(MENUSOUND); + CORO_INVOKE_1(ChangeState, MENUSOUND); _ctx->bRefresh = true; } @@ -1178,24 +1283,29 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { Close(); if (_ctx->bRefresh) - RefreshAll(); + CORO_INVOKE_0(RefreshAll); CORO_END_CODE; } -void RMOptionScreen::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { - int curTime = _vm->GetTime(); +void RMOptionScreen::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + CORO_BEGIN_CONTEXT; + int curTime; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + _ctx->curTime = _vm->GetTime(); #define FADE_SPEED 20 -#define SYNC (curTime-m_FadeTime) / 25 +#define SYNC (_ctx->curTime-m_FadeTime) / 25 if (m_bExit) return; - switch (m_FadeStep) { + if (m_FadeStep == 1) { // Discesa veloce - case 1: if (m_FadeTime == -1) m_FadeY += FADE_SPEED; else @@ -1207,10 +1317,9 @@ void RMOptionScreen::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { // Setta la parte da disegnare per lo scrolling prim->SetSrc(RMRect(0, 480 - m_FadeY, 640, 480)); - break; - - // Rimbalzo 1 - case 2: + + } else if (m_FadeStep == 2) { + // Rimbalzo 1 m_FadeY -= FADE_SPEED / 2 * SYNC; if (m_FadeY < 400) { m_FadeY = 400; @@ -1218,9 +1327,8 @@ void RMOptionScreen::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { } prim->SetSrc(RMRect(0, 480 - m_FadeY, 640, 480)); - break; - case 3: + } else if (m_FadeStep == 3) { m_FadeY -= FADE_SPEED / 4 * SYNC; if (m_FadeY < 380) { m_FadeY = 380; @@ -1228,10 +1336,9 @@ void RMOptionScreen::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { } prim->SetSrc(RMRect(0, 480 - m_FadeY, 640, 480)); - break; - // Rimbalzo 1 - 2 - case 4: + } else if (m_FadeStep == 4) { + // Rimbalzo 1 - 2 m_FadeY += FADE_SPEED / 3 * SYNC; if (m_FadeY > 420) { m_FadeY = 420; @@ -1239,9 +1346,8 @@ void RMOptionScreen::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { } prim->SetSrc(RMRect(0, 480 - m_FadeY, 640, 480)); - break; - case 5: + } else if (m_FadeStep == 5) { m_FadeY += FADE_SPEED / 2 * SYNC; if (m_FadeY > 480) { m_FadeY = 480; @@ -1250,29 +1356,25 @@ void RMOptionScreen::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { } prim->SetSrc(RMRect(0, 480 - m_FadeY, 640, 480)); - break; - // Menu ON - case 6: - break; + } else if (m_FadeStep == 6) { + // Menu ON - // Menu OFF - case 7: + } else if (m_FadeStep == 7) { + // Menu OFF _vm->ShowLocation(); m_FadeStep++; - break; - case 8: + } else if (m_FadeStep == 8) { m_FadeY -= FADE_SPEED * SYNC; if (m_FadeY < 0) { m_FadeY = 0; m_FadeStep++; } prim->SetSrc(RMRect(0, 480 - m_FadeY, 640, 480)); - break; - // Ciao ciao! - case 9: + } else if (m_FadeStep == 9) { + // Ciao ciao! m_bExit = true; m_FadeStep = 0; @@ -1280,21 +1382,22 @@ void RMOptionScreen::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CloseState(); return; - default: + } else { m_FadeStep = 0; - break; } - m_FadeTime = curTime; + m_FadeTime = _ctx->curTime; + + CORO_INVOKE_2(RMGfxWoodyBuffer::Draw, bigBuf, prim); - RMGfxWoodyBuffer::Draw(bigBuf,prim); + CORO_END_CODE; } -bool RMOptionScreen::RemoveThis() { +void RMOptionScreen::RemoveThis(CORO_PARAM, bool &result) { if (m_bExit) - return true; - - return false; + result = true; + else + result = false; } @@ -1434,30 +1537,36 @@ int RMPointer::Priority() { return 200; } -void RMPointer::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { - int n; +void RMPointer::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + CORO_BEGIN_CONTEXT; + int n; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); // Controlla il pointer - n = m_nCurPointer; - if (n == TA_COMBINE) n = TA_USE; + _ctx->n = m_nCurPointer; + if (_ctx->n == TA_COMBINE) _ctx->n = TA_USE; // Copia le coordinate di destinazione nella primitiva prim->SetDst(m_pos); if (m_pos.x >= 0 && m_pos.y >= 0 && m_pos.x < RM_SX && m_pos.y < RM_SY) { // Richiama il draw del puntatore - prim->Dst()-=m_hotspot[n]; + prim->Dst()-=m_hotspot[_ctx->n]; if (m_nCurSpecialPointer == 0) { - m_pointer[n]->Draw(bigBuf,prim); + CORO_INVOKE_2(m_pointer[_ctx->n]->Draw, bigBuf, prim); } else { if (m_nCurSpecialPointer == PTR_CUSTOM) - m_nCurCustomPointer->Draw(bigBuf, prim); + CORO_INVOKE_2(m_nCurCustomPointer->Draw, bigBuf, prim); else // Richiama il draw sul puntatore speciale - m_specialPointer[m_nCurSpecialPointer-1]->Draw(bigBuf, prim); + CORO_INVOKE_2(m_specialPointer[m_nCurSpecialPointer-1]->Draw, bigBuf, prim); } } + + CORO_END_CODE; } void RMPointer::DoFrame(RMGfxTargetBuffer *bigBuf) { @@ -1469,9 +1578,9 @@ void RMPointer::DoFrame(RMGfxTargetBuffer *bigBuf) { m_specialPointer[m_nCurSpecialPointer-1]->DoFrame(bigBuf,false); } -bool RMPointer::RemoveThis() { +void RMPointer::RemoveThis(CORO_PARAM, bool &result) { // Si leva sempre dalla lista di OT, per supportare la DisableInput - return true; + result = true; } int RMPointer::CurAction(void) { diff --git a/engines/tony/game.h b/engines/tony/game.h index 55fed71380..554279c13f 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -64,7 +64,7 @@ namespace Tony { (buf16)->Init(*raw,raw->Width(),raw->Height()); \ delete raw; -#define INIT_GFX8_FROMRAW(dwRes, buf8) \ +#define INIT_GFX8_FROMRAW(raw, dwRes, buf8) \ raw = new RMResRaw(dwRes); \ assert(raw->IsValid()); \ assert((buf8) == NULL); \ @@ -135,13 +135,13 @@ public: int Priority(); // Overloading draw method - void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Sets the current co-ordinates void SetCoord(RMPoint pt) { m_pos = pt; } // Overloading of the method to see if rising from the list - bool RemoveThis(); + virtual void RemoveThis(CORO_PARAM, bool &result); // Sets a new action as current void SetAction(RMTonyAction action) { m_nCurPointer = action; } @@ -174,7 +174,7 @@ public: virtual ~RMOptionButton(); bool DoFrame(RMPoint mousePos, bool bLeftClick, bool bRightClick); - void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); void AddToList(RMGfxTargetBuffer &bigBuf); bool IsActive() { return m_bActive; } void SetActiveState(bool bState) { m_bActive=bState; } @@ -199,7 +199,7 @@ public: virtual ~RMOptionSlide(); bool DoFrame(RMPoint mousePos, bool bLeftClick, bool bRightClick); - void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); void AddToList(RMGfxTargetBuffer& bigBuf); int GetValue() { return m_nValue; } @@ -286,18 +286,18 @@ public: RMOptionScreen(); virtual ~RMOptionScreen(); - bool Init(RMGfxTargetBuffer& bigBuf); - bool InitLoadMenuOnly(RMGfxTargetBuffer &bigBuf, bool bAlternateGfx = false); - bool InitSaveMenuOnly(RMGfxTargetBuffer &bigBuf, bool bAlternateGfx = false); - bool InitNoLoadSave(RMGfxTargetBuffer &bigBuf); + void Init(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool &result); + void InitLoadMenuOnly(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool bAlternateGfx, bool &result); + void InitSaveMenuOnly(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool bAlternateGfx, bool &result); + void InitNoLoadSave(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool &result); void ReInit(RMGfxTargetBuffer &bigBuf); bool Close(); bool IsClosing(); // Metodi in overloading da RMGfxTask int Priority(); - void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - bool RemoveThis(); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void RemoveThis(CORO_PARAM, bool &result); // Polling per l'option screen void DoFrame(CORO_PARAM, RMInput *m_input); @@ -305,12 +305,12 @@ public: protected: // Inizializza tutto per il nuovo stato - void InitState(void); + void InitState(CORO_PARAM); void CloseState(void); - void ChangeState(STATE newState); + void ChangeState(CORO_PARAM, STATE newState); // Ridisegna tutto il menu delle opzioni - void RefreshAll(void); + void RefreshAll(CORO_PARAM); void RefreshThumbnails(void); // Carica lo screenshot per il salvataggio diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 344542b801..6f24941545 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -63,8 +63,8 @@ int RMGfxTask::Priority() { return m_nPrior; } -bool RMGfxTask::RemoveThis() { - return true; +void RMGfxTask::RemoveThis(CORO_PARAM, bool &result) { + result = true; } @@ -261,12 +261,19 @@ RMGfxWoodyBuffer::~RMGfxWoodyBuffer() { } -void RMGfxWoodyBuffer::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMGfxWoodyBuffer::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + // Prima si fa disegnare tramite la propria OT list - DrawOT(); + CORO_INVOKE_0(DrawOT); // Poi disegna se stesso nel target buffer - RMGfxSourceBuffer16::Draw(bigBuf, prim); + CORO_INVOKE_2(RMGfxSourceBuffer16::Draw, bigBuf, prim); + + CORO_END_CODE; } RMGfxWoodyBuffer::RMGfxWoodyBuffer() { @@ -316,47 +323,53 @@ void RMGfxTargetBuffer::ClearOT(void) { g_system->unlockMutex(csModifyingOT); } -void RMGfxTargetBuffer::DrawOT(void) { - OTList *cur; - OTList *prev; - OTList *next; - RMGfxPrimitive *myprim; +void RMGfxTargetBuffer::DrawOT(CORO_PARAM) { + CORO_BEGIN_CONTEXT; + OTList *cur; + OTList *prev; + OTList *next; + RMGfxPrimitive *myprim; + bool result; + CORO_END_CONTEXT(_ctx); - prev = NULL; - cur = otlist; + CORO_BEGIN_CODE(_ctx); + + _ctx->prev = NULL; + _ctx->cur = otlist; // Lock del buffer per accederci Lock(); g_system->lockMutex(csModifyingOT); - while (cur != NULL) { + while (_ctx->cur != NULL) { // Richiama la draw sul task, passandogli una copia della primitiva - myprim=cur->prim->Duplicate(); - cur->prim->m_task->Draw(*this, myprim); - delete myprim; + _ctx->myprim=_ctx->cur->prim->Duplicate(); + CORO_INVOKE_2(_ctx->cur->prim->m_task->Draw, *this, _ctx->myprim); + delete _ctx->myprim; // Controlla se e' arrivato il momento di rimuovere il task dalla OTlist - if (cur->prim->m_task->RemoveThis()) { + CORO_INVOKE_1(_ctx->cur->prim->m_task->RemoveThis, _ctx->result); + if (_ctx->result) { // Deregistra il task - cur->prim->m_task->Unregister(); + _ctx->cur->prim->m_task->Unregister(); // Cancella il task liberando la memoria - delete cur->prim; - next=cur->next; - delete cur; + delete _ctx->cur->prim; + _ctx->next = _ctx->cur->next; + delete _ctx->cur; // Se era il primo elemento, aggiorna la testa della lista - if (prev == NULL) - otlist = next; + if (_ctx->prev == NULL) + otlist = _ctx->next; // Altrimenti aggiorna il puntatore al successivo dell'elemento precedente else - prev->next = next; + _ctx->prev->next = _ctx->next; - cur = next; + _ctx->cur = _ctx->next; } else { // Aggiorna il puntatore al precedente e scorre la lista - prev = cur; - cur = cur->next; + _ctx->prev = _ctx->cur; + _ctx->cur = _ctx->cur->next; } } @@ -364,6 +377,8 @@ void RMGfxTargetBuffer::DrawOT(void) { // Unlock dopo la scrittura Unlock(); + + CORO_END_CODE; } void RMGfxTargetBuffer::AddPrim(RMGfxPrimitive *prim) { @@ -490,7 +505,7 @@ int RMGfxSourceBufferPal::LoadPaletteWA(uint32 resID, bool bSwapped) { * Metodi di RMGfxSourceBuffer4 \****************************************************************************/ -void RMGfxSourceBuffer4::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMGfxSourceBuffer4::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { } RMGfxSourceBuffer4::RMGfxSourceBuffer4(int dimx, int dimy, bool bUseDDraw) @@ -524,7 +539,7 @@ RMGfxSourceBuffer8::~RMGfxSourceBuffer8() { } -void RMGfxSourceBuffer8::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMGfxSourceBuffer8::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { int x, y, width, height, u, v; int bufx = bigBuf.Dimx(); uint16 *buf = bigBuf; @@ -637,7 +652,7 @@ int RMGfxSourceBuffer8AB::CalcTrasp(int fore, int back) } -void RMGfxSourceBuffer8AB::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMGfxSourceBuffer8AB::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { int x, y, width, height, u, v; int bufx=bigBuf.Dimx(); uint16 *buf = bigBuf; @@ -838,7 +853,7 @@ void RMGfxSourceBuffer8RLE::CompressRLE(void) { Common::copy(MegaRLEBuf, MegaRLEBuf + x, m_buf); } -void RMGfxSourceBuffer8RLE::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMGfxSourceBuffer8RLE::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { int y; byte *src; uint16 *buf = bigBuf; @@ -1750,9 +1765,16 @@ void RMGfxSourceBuffer8AA::DrawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri -void RMGfxSourceBuffer8AA::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { - RMGfxSourceBuffer8::Draw(bigBuf, prim); +void RMGfxSourceBuffer8AA::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + CORO_INVOKE_2(RMGfxSourceBuffer8::Draw, bigBuf, prim); DrawAA(bigBuf, prim); + + CORO_END_CODE; } @@ -1770,10 +1792,17 @@ void RMGfxSourceBuffer8RLEByteAA::PrepareImage(void) { CompressRLE(); } -void RMGfxSourceBuffer8RLEByteAA::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { - RMGfxSourceBuffer8RLE::Draw(bigBuf,prim); +void RMGfxSourceBuffer8RLEByteAA::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + CORO_INVOKE_2(RMGfxSourceBuffer8RLE::Draw, bigBuf, prim); if (bCfgAntiAlias) DrawAA(bigBuf,prim); + + CORO_END_CODE; } int RMGfxSourceBuffer8RLEByteAA::Init(const byte *buf, int dimx, int dimy, bool bLoadPalette) { @@ -1801,10 +1830,17 @@ void RMGfxSourceBuffer8RLEWordAA::PrepareImage(void) { CompressRLE(); } -void RMGfxSourceBuffer8RLEWordAA::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { - RMGfxSourceBuffer8RLE::Draw(bigBuf,prim); +void RMGfxSourceBuffer8RLEWordAA::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + CORO_INVOKE_2(RMGfxSourceBuffer8RLE::Draw, bigBuf, prim); if (bCfgAntiAlias) DrawAA(bigBuf,prim); + + CORO_END_CODE; } int RMGfxSourceBuffer8RLEWordAA::Init(byte *buf, int dimx, int dimy, bool bLoadPalette) { @@ -1833,7 +1869,7 @@ RMGfxSourceBuffer16::RMGfxSourceBuffer16(bool bTrasp0) { RMGfxSourceBuffer16::~RMGfxSourceBuffer16() { } -void RMGfxSourceBuffer16::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMGfxSourceBuffer16::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { int x, y; uint16 *buf = bigBuf; uint16 *raw = (uint16*)m_buf; @@ -1927,8 +1963,8 @@ void RMGfxSourceBuffer16::Create(int dimx, int dimy, bool bUseDDraw) { * Metodi di RMGfxBox \****************************************************************************/ -bool RMGfxBox::RemoveThis(void) { - return true; +void RMGfxBox::RemoveThis(CORO_PARAM, bool &result) { + result = true; } void RMGfxBox::SetColor(byte r, byte g, byte b) { @@ -1938,7 +1974,7 @@ void RMGfxBox::SetColor(byte r, byte g, byte b) { wFillColor = (r << 10) | (g << 5) | b; } -void RMGfxBox::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMGfxBox::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { int i, j; uint16 *buf = bigBuf; RMRect rcDst; @@ -1966,14 +2002,14 @@ int RMGfxClearTask::Priority() { return 1; } -void RMGfxClearTask::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *) { +void RMGfxClearTask::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *) { // Pulisce tutto il target buffer Common::fill((byte *)bigBuf, (byte *)bigBuf + (bigBuf.Dimx() * bigBuf.Dimy() * 2), 0x0); } -bool RMGfxClearTask::RemoveThis() { +void RMGfxClearTask::RemoveThis(CORO_PARAM, bool &result) { // Il task di clear si disattiva sempre - return true; + result = true; } } // End of namespace Tony diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index 88f2d6ed22..289c3e9564 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -49,6 +49,7 @@ #define TONY_GFXCORE_H #include "common/system.h" +#include "common/coroutines.h" #include "tony/utils.h" namespace Tony { @@ -190,8 +191,8 @@ public: virtual ~RMGfxTask() { } virtual int Priority(); - virtual void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) = 0; - virtual bool RemoveThis(); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) = 0; + virtual void RemoveThis(CORO_PARAM, bool &result); // Registration virtual void Register(void) { m_nInList++; } @@ -217,8 +218,8 @@ public: virtual ~RMGfxClearTask() { } int Priority(); - void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); - bool RemoveThis(); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void RemoveThis(CORO_PARAM, bool &result); }; @@ -233,8 +234,8 @@ public: virtual ~RMGfxBox() { } void SetColor(byte r, byte g, byte b); - void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - bool RemoveThis(); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void RemoveThis(CORO_PARAM, bool &result); }; @@ -277,7 +278,7 @@ public: void Create(int dimx, int dimy, bool bUseDDraw = false); int Bpp(); - virtual void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); }; @@ -322,7 +323,7 @@ public: void Create(int dimx, int dimy, bool bUseDDraw = false); int Bpp(); - virtual void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive *prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer& bigBuf, RMGfxPrimitive *prim); }; @@ -335,7 +336,7 @@ protected: public: virtual ~RMGfxSourceBuffer8AB(); - virtual void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); }; @@ -376,7 +377,7 @@ public: virtual int Init(const byte *buf, int dimx, int dimy, bool bLoadPalette = false); // Draw image with RLE decompression - void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Sets the color that will be alpha blended void SetAlphaBlendColor(int color); @@ -443,7 +444,7 @@ public: virtual ~RMGfxSourceBuffer8AA(); // Draw con antialiasing - void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); }; @@ -452,7 +453,7 @@ protected: void PrepareImage(void); public: - void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Overloaded initialisation methods virtual void Init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette = false); @@ -466,7 +467,7 @@ protected: void PrepareImage(void); public: - void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Overloaded initialisation method virtual void Init(RMDataStream& ds, int dimx, int dimy, bool bLoadPalette = false); @@ -488,7 +489,7 @@ public: void Create(int dimx, int dimy, bool bUseDDraw = false); int Bpp(); - virtual void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); }; @@ -520,7 +521,7 @@ public: // management of the OT list void ClearOT(void); - void DrawOT(void); + void DrawOT(CORO_PARAM); void AddPrim(RMGfxPrimitive *prim); // The pointer must be delted // Adds a task to clear the screen @@ -547,7 +548,7 @@ public: RMGfxWoodyBuffer(int dimx, int dimy, bool bUseDDraw = false); virtual ~RMGfxWoodyBuffer(); - virtual void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); }; } // End of namespace Tony diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 88aac99ebe..b5278b3b05 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -108,15 +108,15 @@ void RMGfxEngine::OpenOptionScreen(CORO_PARAM, int type) { _ctx->bRes = false; if (type == 0) - _ctx->bRes = m_opt.Init(m_bigBuf); + CORO_INVOKE_2(m_opt.Init, m_bigBuf, _ctx->bRes); else if (type == 1) - _ctx->bRes = m_opt.InitLoadMenuOnly(m_bigBuf, true); + CORO_INVOKE_3(m_opt.InitLoadMenuOnly, m_bigBuf, true, _ctx->bRes); else if (type == 2) - _ctx->bRes = m_opt.InitNoLoadSave(m_bigBuf); + CORO_INVOKE_2(m_opt.InitNoLoadSave, m_bigBuf, _ctx->bRes); else if (type == 3) - _ctx->bRes = m_opt.InitLoadMenuOnly(m_bigBuf, false); + CORO_INVOKE_3(m_opt.InitLoadMenuOnly, m_bigBuf, false, _ctx->bRes); else if (type == 4) - _ctx->bRes = m_opt.InitSaveMenuOnly(m_bigBuf, false); + CORO_INVOKE_3(m_opt.InitSaveMenuOnly, m_bigBuf, false, _ctx->bRes); if (_ctx->bRes) { _vm->PauseSound(true); @@ -222,12 +222,14 @@ void RMGfxEngine::DoFrame(CORO_PARAM, bool bDrawLocation) { if ((m_input.MouseLeftClicked() && m_input.MousePos().x < 3 && m_input.MousePos().y < 3)) { CORO_INVOKE_1(OpenOptionScreen, 0); goto SKIPCLICKSINISTRO; - } else if ((GetAsyncKeyState(Common::KEYCODE_ESCAPE)&0x8001) == 0x8001) + } else if (m_input.GetAsyncKeyState(Common::KEYCODE_ESCAPE)) CORO_INVOKE_1(OpenOptionScreen, 0); - else if (_vm->getIsDemo()) { - if ((GetAsyncKeyState(Common::KEYCODE_F3) & 0x8001) == 0x8001) + else if (!_vm->getIsDemo()) { + if (m_input.GetAsyncKeyState(Common::KEYCODE_F3) || m_input.GetAsyncKeyState(Common::KEYCODE_F5)) + // Save game screen CORO_INVOKE_1(OpenOptionScreen, 3); - else if ((GetAsyncKeyState(Common::KEYCODE_F2) & 0x8001) == 0x8001) + else if (m_input.GetAsyncKeyState(Common::KEYCODE_F2) || m_input.GetAsyncKeyState(Common::KEYCODE_F7)) + // Load game screen CORO_INVOKE_1(OpenOptionScreen, 4); } } @@ -324,7 +326,7 @@ SKIPCLICKSINISTRO: // ********************** // Disegna la lista di OT // ********************** - m_bigBuf.DrawOT(); + m_bigBuf.DrawOT(Common::nullContext); #define FSTEP (480/32) @@ -579,7 +581,7 @@ void RMGfxEngine::Init(/*HINSTANCE hInst*/) { RMGfxSourceBuffer16 *load = NULL; INIT_GFX16_FROMRAW(20038, load); m_bigBuf.AddPrim(new RMGfxPrimitive(load)); - m_bigBuf.DrawOT(); + m_bigBuf.DrawOT(Common::nullContext); m_bigBuf.ClearOT(); delete load; _vm->_window.GetNewFrame(*this, NULL); diff --git a/engines/tony/gfxengine.h b/engines/tony/gfxengine.h index d119bb07a6..41255229b8 100644 --- a/engines/tony/gfxengine.h +++ b/engines/tony/gfxengine.h @@ -129,6 +129,7 @@ public: void DisableMouse(void); operator byte *() { return (byte *)m_bigBuf; } + RMInput &GetInput() { return m_input; } // Link to the custom function list void InitCustomDll(void); diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp index 3574980176..bd90ec641d 100644 --- a/engines/tony/input.cpp +++ b/engines/tony/input.cpp @@ -52,12 +52,16 @@ namespace Tony { #define DIRELEASE(x) if (x) { (x)->Release(); (x)=NULL; } RMInput::RMInput() { + // Setup mouse fields _clampMouse = false; _mousePos.Set(0, 0); _leftButton = _rightButton = false;; _leftClickMouse = _leftReleaseMouse = false; _rightClickMouse = _rightReleaseMouse = false; + + // Setup keyboard fields + Common::fill(&_keyDown[0], &_keyDown[350], 0); } RMInput::~RMInput() { @@ -95,6 +99,14 @@ void RMInput::Poll(void) { // Since a mouse button has changed, don't do any further event processing this frame return; + case Common::EVENT_KEYDOWN: + _keyDown[(int)_event.kbd.keycode] = true; + return; + + case Common::EVENT_KEYUP: + _keyDown[(int)_event.kbd.keycode] = false; + return; + default: break; } diff --git a/engines/tony/input.h b/engines/tony/input.h index dce35141c5..acb7fbd677 100644 --- a/engines/tony/input.h +++ b/engines/tony/input.h @@ -56,14 +56,15 @@ namespace Tony { class RMInput { private: Common::Event _event; - RMPoint _mousePos; -// DIMOUSESTATE m_mState; + // Mouse related fields + RMPoint _mousePos; bool _clampMouse; bool _leftButton, _rightButton; - bool _leftClickMouse, _leftReleaseMouse, _rightClickMouse, _rightReleaseMouse; + // Keyboard related fields + bool _keyDown[350]; private: // Deinizializza DirectInput void DIClose(void); @@ -96,8 +97,8 @@ public: bool MouseRightReleased() { return _rightReleaseMouse; } bool MouseBothReleased() { return _leftReleaseMouse && _rightReleaseMouse; } - // Warns when we are in the GDI loop - void GDIControl(bool bCon); + // Returns true if the given key is pressed + bool GetAsyncKeyState(Common::KeyCode kc) { return _keyDown[(int)kc]; } }; } // End of namespace Tony diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index 9d673459c5..b5c28506a9 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -181,7 +181,7 @@ void RMInventory::Init(void) { // Prepara il primo inventario Prepare(); - DrawOT(); + DrawOT(Common::nullContext); ClearOT(); } @@ -205,50 +205,62 @@ void RMInventory::Reset(void) { EndCombine(); } -void RMInventory::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMInventory::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + CORO_BEGIN_CONTEXT; + RMPoint pos; + RMPoint pos2; + RMGfxPrimitive *p; + RMGfxPrimitive *p2; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + if (m_state == OPENING || m_state == CLOSING) prim->SetDst(RMPoint(0, m_curPutY)); else prim->SetDst(RMPoint(0, m_curPutY)); g_system->lockMutex(m_csModifyInterface); - RMGfxWoodyBuffer::Draw(bigBuf, prim); + CORO_INVOKE_2(RMGfxWoodyBuffer::Draw, bigBuf, prim); g_system->unlockMutex(m_csModifyInterface); if (m_state == SELECTING) { - RMPoint pos; - RMPoint pos2; if (!bCfgInvUp) { - pos.Set((m_nSelectObj+1)*64 - 20,RM_SY - 113); - pos2.Set((m_nSelectObj+1)*64 + 34,RM_SY - 150); + _ctx->pos.Set((m_nSelectObj+1)*64 - 20,RM_SY - 113); + _ctx->pos2.Set((m_nSelectObj+1)*64 + 34,RM_SY - 150); } else { - pos.Set((m_nSelectObj+1)*64 - 20, 72 - 4); // la parte marrone sta in alto :( - pos2.Set((m_nSelectObj+1)*64 + 34, 119 - 4); + _ctx->pos.Set((m_nSelectObj+1)*64 - 20, 72 - 4); // la parte marrone sta in alto :( + _ctx->pos2.Set((m_nSelectObj+1)*64 + 34, 119 - 4); } - RMGfxPrimitive p(prim->m_task, pos); - RMGfxPrimitive p2(prim->m_task, pos2); + _ctx->p = new RMGfxPrimitive(prim->m_task, _ctx->pos); + _ctx->p2 = new RMGfxPrimitive(prim->m_task, _ctx->pos2); // Disegna l'interfaccina stupida - miniInterface.Draw(bigBuf,&p); + CORO_INVOKE_2(miniInterface.Draw, bigBuf, _ctx->p); if (bCfgInterTips) { if (miniAction == 1) // Esamina - m_hints[0].Draw(bigBuf, &p2); + CORO_INVOKE_2(m_hints[0].Draw, bigBuf, _ctx->p2); else if (miniAction == 2) // Parla - m_hints[1].Draw(bigBuf, &p2); + CORO_INVOKE_2(m_hints[1].Draw, bigBuf, _ctx->p2); else if (miniAction == 3) // Usa - m_hints[2].Draw(bigBuf, &p2); + CORO_INVOKE_2(m_hints[2].Draw, bigBuf, _ctx->p2); } + + delete _ctx->p; + delete _ctx->p2; } + + CORO_END_CODE; } -bool RMInventory::RemoveThis(void) { +void RMInventory::RemoveThis(CORO_PARAM, bool &result) { if (m_state == CLOSED) - return true; - - return false; + result = true; + else + result = false; } void RMInventory::RemoveItem(int code) { @@ -263,7 +275,7 @@ void RMInventory::RemoveItem(int code) { m_nInv--; Prepare(); - DrawOT(); + DrawOT(Common::nullContext); ClearOT(); g_system->unlockMutex(m_csModifyInterface); return; @@ -287,7 +299,7 @@ void RMInventory::AddItem(int code) { m_inv[m_nInv++]=code-10000; Prepare(); - DrawOT(); + DrawOT(Common::nullContext); ClearOT(); g_system->unlockMutex(m_csModifyInterface); } @@ -302,7 +314,7 @@ void RMInventory::ChangeItemStatus(uint32 code, uint32 dwStatus) { m_items[code - 10000].status = dwStatus; Prepare(); - DrawOT(); + DrawOT(Common::nullContext); ClearOT(); g_system->unlockMutex(m_csModifyInterface); } @@ -384,7 +396,7 @@ bool RMInventory::LeftClick(RMPoint mpos, int& nCombineObj) { } Prepare(); - DrawOT(); + DrawOT(Common::nullContext); ClearOT(); g_system->unlockMutex(m_csModifyInterface); } @@ -405,7 +417,7 @@ bool RMInventory::LeftClick(RMPoint mpos, int& nCombineObj) { } Prepare(); - DrawOT(); + DrawOT(Common::nullContext); ClearOT(); g_system->unlockMutex(m_csModifyInterface); } @@ -450,7 +462,7 @@ void RMInventory::RightClick(RMPoint mpos) { } Prepare(); - DrawOT(); + DrawOT(Common::nullContext); ClearOT(); g_system->unlockMutex(m_csModifyInterface); } else if ((m_state == OPENED) && m_bBlinkingLeft) { @@ -470,7 +482,7 @@ void RMInventory::RightClick(RMPoint mpos) { } Prepare(); - DrawOT(); + DrawOT(Common::nullContext); ClearOT(); g_system->unlockMutex(m_csModifyInterface); } @@ -550,7 +562,7 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo g_system->unlockMutex(m_csModifyInterface); } - if ((GetAsyncKeyState(Common::KEYCODE_i) & 0x8001) == 0x8001) { + if (_vm->GetEngine()->GetInput().GetAsyncKeyState(Common::KEYCODE_i)) { bCfgInvLocked = !bCfgInvLocked; } @@ -759,7 +771,7 @@ int RMInventory::LoadState(byte *state) { m_items[28].icon.SetPattern(1); Prepare(); - DrawOT(); + DrawOT(Common::nullContext); ClearOT(); return GetSaveStateSize(); @@ -795,30 +807,35 @@ int RMInterface::OnWhichBox(RMPoint pt) { return -1; } -void RMInterface::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { - int h; +void RMInterface::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + CORO_BEGIN_CONTEXT; + int h; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); prim->Dst().TopLeft() = m_openStart; - RMGfxSourceBuffer8RLEByte::Draw(bigBuf, prim); + CORO_INVOKE_2(RMGfxSourceBuffer8RLEByte::Draw, bigBuf, prim); // Controlla se c'e' da disegnare una zona calda - h = OnWhichBox(m_mpos); - if (h != -1) { + _ctx->h = OnWhichBox(m_mpos); + if (_ctx->h != -1) { prim->Dst().TopLeft() = m_openStart; - m_hotzone[h].Draw(bigBuf, prim); + CORO_INVOKE_2(m_hotzone[_ctx->h].Draw, bigBuf, prim); - if (m_lastHotZone != h) { - m_lastHotZone = h; + if (m_lastHotZone != _ctx->h) { + m_lastHotZone = _ctx->h; _vm->PlayUtilSFX(1); } if (bCfgInterTips) { prim->Dst().TopLeft() = m_openStart + RMPoint(70, 177); - m_hints[h].Draw(bigBuf,prim); + CORO_INVOKE_2(m_hints[_ctx->h].Draw, bigBuf, prim); } } else m_lastHotZone = -1; + CORO_END_CODE; } diff --git a/engines/tony/inventory.h b/engines/tony/inventory.h index 3d8650773f..e2143bb24b 100644 --- a/engines/tony/inventory.h +++ b/engines/tony/inventory.h @@ -119,10 +119,10 @@ public: void Reset(void); // Overload per la rimozione da otlist - bool RemoveThis(void); + virtual void RemoveThis(CORO_PARAM, bool &result); // Overload per il disegno (per la posizione x&y e l'interfaccina) - void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Metodo per determinare se l'inventario sta comandando gli input bool HaveFocus(RMPoint mpos); @@ -205,7 +205,7 @@ public: bool GetPalesati(void); // Overloading del Draw per il posizionamente - virtual void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); }; } // End of namespace Tony diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index e4a60cb52a..37fe29f359 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -398,8 +398,8 @@ void RMSprite::ReadFromStream(RMDataStream &ds, bool bLOX) { m_buf->Init(ds, dimx,dimy); } -void RMSprite::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { - m_buf->Draw(bigBuf, prim); +void RMSprite::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + m_buf->Draw(coroParam, bigBuf, prim); } void RMSprite::SetPalette(byte *buf) { @@ -727,7 +727,12 @@ RMPoint RMItem::CalculatePos(void) { return m_pos + m_patterns[m_nCurPattern].Pos(); } -void RMItem::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMItem::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + // Se CurSprite == -1, allora e' finito il pattern if (m_nCurSprite == -1) return; @@ -746,13 +751,15 @@ void RMItem::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { prim->SetStrecth(false); // Ora la passiamo alla routine di drawing generica per surface - m_sprites[m_nCurSprite].Draw(bigBuf, prim); + CORO_INVOKE_2(m_sprites[m_nCurSprite].Draw, bigBuf, prim); + + CORO_END_CODE; } -bool RMItem::RemoveThis() { +void RMItem::RemoveThis(CORO_PARAM, bool &result) { // Rimuove dalla OT list se il frame corrente e' -1 (pattern finito) - return (m_nCurSprite == -1); + result = (m_nCurSprite == -1); } @@ -907,8 +914,8 @@ void RMWipe::Unregister(void) { CoroScheduler.setEvent(m_hUnregistered); } -bool RMWipe::RemoveThis(void) { - return m_bUnregister; +void RMWipe::RemoveThis(CORO_PARAM, bool &result) { + result = m_bUnregister; } void RMWipe::WaitForFadeEnd(CORO_PARAM) { @@ -972,13 +979,20 @@ void RMWipe::DoFrame(RMGfxTargetBuffer &bigBuf) { } } -void RMWipe::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMWipe::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + if (m_bFading) { - m_wip0r.Draw(bigBuf, prim); + CORO_INVOKE_2(m_wip0r.Draw, bigBuf, prim); } if (m_bEndFade) Common::fill((byte *)bigBuf, (byte *)bigBuf + bigBuf.Dimx() * bigBuf.Dimy() * 2, 0x0); + + CORO_END_CODE; } @@ -1369,12 +1383,19 @@ RMPoint RMCharacter::NearestHotSpot(int sourcebox, int destbox) { return puntocaldo; } -void RMCharacter::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMCharacter::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + if (bDrawNow) { prim->Dst() += m_fixedScroll; - RMItem::Draw(bigBuf, prim); + CORO_INVOKE_2(RMItem::Draw, bigBuf, prim); } + + CORO_END_CODE; } void RMCharacter::NewBoxEntered(int nBox) { @@ -1692,11 +1713,18 @@ void RMCharacter::WaitForEndMovement(CORO_PARAM) { CORO_END_CODE; } -bool RMCharacter::RemoveThis(void) { +void RMCharacter::RemoveThis(CORO_PARAM, bool &result) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + if (bRemoveFromOT) - return true; + result = true; + else + CORO_INVOKE_1(RMItem::RemoveThis, result); - return RMItem::RemoveThis(); + CORO_END_CODE; } RMCharacter::RMCharacter() { @@ -2214,7 +2242,12 @@ bool RMLocation::LoadLOX(RMDataStream &ds) { * \****************************************************************************/ -void RMLocation::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMLocation::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + // Setta la posizione sorgente dello scrolling if (m_buf->Dimy()>RM_SY || m_buf->Dimx()>RM_SX) { prim->SetSrc(RMRect(m_curScroll,m_curScroll+RMPoint(640,480))); @@ -2224,7 +2257,9 @@ void RMLocation::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { // Richiama il metodo di drawing della classe dell'immagine, che disegner il background // della locazione - m_buf->Draw(bigBuf, prim); + CORO_INVOKE_2(m_buf->Draw, bigBuf, prim); + + CORO_END_CODE; } diff --git a/engines/tony/loc.h b/engines/tony/loc.h index 218aca02e7..bbe37778c0 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -202,7 +202,7 @@ public: void Init(RMGfxSourceBuffer* buf); friend RMDataStream& operator>>(RMDataStream& ds, RMSprite& sprite); - void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); void SetPalette(byte *lpBuf); void GetSizeFromStream(RMDataStream& ds, int* dimx, int* dimy); void LOXGetSizeFromStream(RMDataStream& ds, int* dimx, int* dimy); @@ -265,10 +265,10 @@ public: void SetScrollPosition(RMPoint scroll); // Overloading della funzione per la rimozione da ot list - virtual bool RemoveThis(); + virtual void RemoveThis(CORO_PARAM, bool &result); // Overloading del draw - virtual void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Overloading della priorit: la Z virtual int Priority() { return m_z; } @@ -457,13 +457,13 @@ public: void LinkToBoxes(RMGameBoxes* theBoxes); - virtual bool RemoveThis(void); + virtual void RemoveThis(CORO_PARAM, bool &result); // Aggiorna la posizione del personaggio void DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc); // Overloading del Draw - void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // TRUE se si appena fermato bool EndOfPath() { return bEndOfPath; } @@ -505,14 +505,14 @@ public: virtual ~RMWipe(); void DoFrame(RMGfxTargetBuffer& bigBuf); - void Draw(RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); void InitFade(int type); void CloseFade(void); void WaitForFadeEnd(CORO_PARAM); virtual void Unregister(void); - virtual bool RemoveThis(void); + virtual void RemoveThis(CORO_PARAM, bool &result); virtual int Priority(void); }; @@ -557,7 +557,7 @@ public: void Unload(void); // Overloading del Draw - void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Prepara un frame disegnando la locazione e tutti i suoi item void DoFrame(RMGfxTargetBuffer *bigBuf); diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 76f6cfcecb..f86576d5c2 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -216,12 +216,14 @@ void TonyEngine::PlayMusic(int nChannel, const char *fn, int nFX, bool bLoop, in m_stream[nextChannel]->Stop(); m_stream[nextChannel]->UnloadFile(); -#ifndef DEMO - if (!m_stream[nextChannel]->LoadFile(path_buffer,FPCODEC_ADPCM,nSync)) - theGame.Abort(); -#else - m_stream[nextChannel]->LoadFile(path_buffer,FPCODEC_ADPCM,nSync); -#endif + + if (!getIsDemo()) { + if (!m_stream[nextChannel]->LoadFile(path_buffer,FPCODEC_ADPCM,nSync)) + theGame.Abort(); + } else { + m_stream[nextChannel]->LoadFile(path_buffer,FPCODEC_ADPCM,nSync); + } + m_stream[nextChannel]->SetLoop(bLoop); m_stream[nextChannel]->Play(); @@ -229,12 +231,13 @@ void TonyEngine::PlayMusic(int nChannel, const char *fn, int nFX, bool bLoop, in } else { -#ifndef DEMO - if (!m_stream[nChannel]->LoadFile(path_buffer,FPCODEC_ADPCM,nSync)) - theGame.Abort(); -#else - m_stream[nChannel]->LoadFile(path_buffer,FPCODEC_ADPCM,nSync); -#endif + if (!getIsDemo()) { + if (!m_stream[nChannel]->LoadFile(path_buffer,FPCODEC_ADPCM,nSync)) + theGame.Abort(); + } else { + m_stream[nChannel]->LoadFile(path_buffer,FPCODEC_ADPCM,nSync); + } + m_stream[nChannel]->SetLoop(bLoop); m_stream[nChannel]->Play(); } diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index 982949870c..0e59779229 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -187,7 +187,12 @@ void RMTony::Hide(bool bShowOmbra) { } -void RMTony::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMTony::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + // Richiama il Draw() della classe madre se tony visibile if (m_bShow && bDrawNow) { if (m_bCorpoDavanti) { @@ -195,7 +200,7 @@ void RMTony::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { prim->Dst().Offset(-44, -134); if (m_bPastorella) prim->Dst().Offset(1, 4); - RMCharacter::Draw(bigBuf, prim); + CORO_INVOKE_2(RMCharacter::Draw, bigBuf, prim); } if (m_bIsTalking || m_bIsStaticTalk) { @@ -205,7 +210,7 @@ void RMTony::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { prim->Dst().Offset(m_pos); prim->Dst().Offset(-44, -134); prim->Dst() += m_nBodyOffset; - m_body.Draw(bigBuf, prim); + CORO_INVOKE_2(m_body.Draw, bigBuf, prim); } if (!m_bCorpoDavanti) { @@ -213,9 +218,11 @@ void RMTony::Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { prim->Dst().Offset(-44, -134); if (m_bPastorella) prim->Dst().Offset(0, 3); - RMCharacter::Draw(bigBuf, prim); + CORO_INVOKE_2(RMCharacter::Draw, bigBuf, prim); } } + + CORO_END_CODE; } void RMTony::MoveAndDoAction(CORO_PARAM, RMPoint dst, RMItem *item, int nAction, int nActionParm) { diff --git a/engines/tony/tonychar.h b/engines/tony/tonychar.h index bbb1667c9b..17b5be23dc 100644 --- a/engines/tony/tonychar.h +++ b/engines/tony/tonychar.h @@ -390,7 +390,7 @@ public: void DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int curLoc); // Metodi di Draw, che controlla la variabile di show - void Draw(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Mostra o nascondi void Show(void); -- cgit v1.2.3 From 073e46503cd09130c3d7e2372ae50e47402569d2 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 12 May 2012 21:54:37 +1000 Subject: TONY: Properly implement game saving and loading. Saving isn't enabled in the demo, so for testing purposes I'm currently dissbling the ADGF_DEMO flag in the detection tables so saving is enabled. --- engines/tony/game.cpp | 62 +++++++++++++++++------------- engines/tony/gfxengine.cpp | 95 ++++++++++++++++++++++------------------------ engines/tony/input.cpp | 10 +++++ engines/tony/input.h | 2 +- engines/tony/tony.cpp | 32 ++++++---------- engines/tony/tony.h | 2 +- engines/tony/window.cpp | 65 ++++++++----------------------- 7 files changed, 120 insertions(+), 148 deletions(-) (limited to 'engines') diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index e5e08f57e7..7378826a71 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -371,6 +371,7 @@ RMOptionScreen::RMOptionScreen(void) { m_menu = NULL; m_HideLoadSave = NULL; m_QuitConfirm = NULL; + m_bQuitConfirm = false; Create(RM_SX, RM_SY); @@ -1401,10 +1402,11 @@ void RMOptionScreen::RemoveThis(CORO_PARAM, bool &result) { } -bool RMOptionScreen::LoadThumbnailFromSaveState(int nState, byte *lpDestBuf, RMString& name, byte &diff) { - char buf[256]; - char namebuf[256]; int i; - Common::File f; +bool RMOptionScreen::LoadThumbnailFromSaveState(int nState, byte *lpDestBuf, RMString &name, byte &diff) { + Common::String buf; + char namebuf[256]; + int i; + Common::InSaveFile *f; char id[4]; // Pulisce la destinazione @@ -1412,60 +1414,68 @@ bool RMOptionScreen::LoadThumbnailFromSaveState(int nState, byte *lpDestBuf, RMS name = "No name"; diff = 10; - // Si fa dare il nome del salvataggio - _vm->GetSaveStateFileName(nState, buf); + // Get the savegame filename for the given slot + buf = _vm->GetSaveStateFileName(nState); - // Guarda se esiste - if (f.open(buf)) + // Try and open the savegame + f = g_system->getSavefileManager()->openForLoading(buf); + if (f == NULL) return false; - // Controlla se giusto l'header - f.read(id, 4); + // Check to see if the file has a valid header + f->read(id, 4); if (id[0] != 'R' || id[1] != 'M' || id[2] != 'S') { - f.close(); + delete f; return false; } if (id[3] < 0x3) { - // Versione vecchia, niente screenshot - f.close(); + // Very old version that doesn't have screenshots + delete f; return true; } - // legge lo screenshot - if (id[3] >= 0x5) { + // Load the screenshot + if ((id[3] >= 0x5) && (id[3] < 0x8)) { + // Read it as an LZO compressed data block byte *cmpbuf; uint32 cmpsize, size; cmpbuf = new byte[160 * 120 * 4]; // Se la versione >= 5, compresso! - cmpsize = f.readUint32LE(); - f.read(cmpbuf, cmpsize); + cmpsize = f->readUint32LE(); + f->read(cmpbuf, cmpsize); lzo1x_decompress(cmpbuf,cmpsize,lpDestBuf,&size); delete[] cmpbuf; - } else - f.read(lpDestBuf, 160 * 120 * 2); + } else { + // Read in the screenshot as an uncompressed data block + if (id[3] >= 8) + // Recent versions use hardcoded 160x120 uncomrpessed data, so size can be skipped + f->skip(4); + + f->read(lpDestBuf, 160 * 120 * 2); + } if (id[3] >= 0x5) { - // Legge il livello di difficolt - diff = f.readByte(); + // Read in the difficulty level + diff = f->readByte(); } if (id[3] < 0x4) { - // Versione vecchia, niente nome - f.close(); + // Savegame version doesn't have a stored name + delete f; return true; } - i = f.readByte(); - f.read(namebuf, i); + i = f->readByte(); + f->read(namebuf, i); namebuf[i] = '\0'; name = namebuf; - f.close(); + delete f; return true; } diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index b5278b3b05..579983ad75 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -713,66 +713,55 @@ void RestoreMusic(CORO_PARAM); void SaveMusic(Common::OutSaveFile *f); void LoadMusic(Common::InSaveFile *f); -unsigned char wrkmem[LZO1X_999_MEM_COMPRESS]; +#define TONY_SAVEGAME_VERSION 8 void RMGfxEngine::SaveState(const char *fn, byte *curThumb, const char *name, bool bFastCompress) { Common::OutSaveFile *f; - byte *state, *statecmp; - byte *thumbcmp; - uint thumbsizecmp, thumbsize; - uint size, sizecmp; + byte *state; + uint thumbsize; + uint size; int i; char buf[4]; RMPoint tp = m_tony.Position(); - // Salvataggio: variabili mpal + locazione corrente + posizione di tony + inventario + // Saving: mpal variables, current location, + tony inventory position - // Per ora salviamo solo lo stato MPAL - size=mpalGetSaveStateSize(); + // For now, we only save the MPAL state + size = mpalGetSaveStateSize(); state = new byte[size]; - statecmp = new byte[size*2]; mpalSaveState(state); - thumbcmp = new byte[160 * 120 * 4]; thumbsize = 160 * 120 * 2; - if (bFastCompress) { - lzo1x_1_compress(state,size,statecmp,&sizecmp,wrkmem); - lzo1x_1_compress(curThumb,thumbsize,thumbcmp,&thumbsizecmp,wrkmem); - } else { - lzo1x_999_compress(state,size,statecmp,&sizecmp,wrkmem); - lzo1x_999_compress(curThumb,thumbsize,thumbcmp,&thumbsizecmp,wrkmem); - } - buf[0] = 'R'; buf[1] = 'M'; buf[2] = 'S'; - buf[3] = 0x7; + buf[3] = TONY_SAVEGAME_VERSION; f = g_system->getSavefileManager()->openForSaving(fn); - if (f==NULL) return; + if (f == NULL) + return; + f->write(buf, 4); - f->writeUint32LE(thumbsizecmp); - f->write(thumbcmp, thumbsizecmp); + f->writeUint32LE(thumbsize); + f->write(curThumb, thumbsize); - // Livello di difficolt + // Difficulty level i = mpalQueryGlobalVar("VERSIONEFACILE"); f->writeByte(i); - i=strlen(name); + i = strlen(name); f->writeByte(i); f->write(name, i); f->writeUint32LE(m_nCurLoc); f->writeUint32LE(tp.x); f->writeUint32LE(tp.y); + f->writeUint32LE(size); - f->writeUint32LE(sizecmp); - f->write(statecmp, sizecmp); + f->write(state, size); delete[] state; - delete[] statecmp; - delete[] thumbcmp; - // inventario + // Inventory size = m_inv.GetSaveStateSize(); state = new byte[size]; m_inv.SaveState(state); @@ -791,16 +780,16 @@ void RMGfxEngine::SaveState(const char *fn, byte *curThumb, const char *name, bo // New Ver5 bool bStat; - // Salva lo stato della pastorella e del palesati + // Saves the state of the shepherdess and show yourself bStat = m_tony.GetPastorella(); f->writeByte(bStat); bStat = m_inter.GetPalesati(); f->writeByte(bStat); - // Salva gli mchar + // Save the chars CharsSaveAll(f); - // Salva le opzioni + // Save the options f->writeByte(bCfgInvLocked); f->writeByte(bCfgInvNoScroll); f->writeByte(bCfgTimerizedText); @@ -819,10 +808,10 @@ void RMGfxEngine::SaveState(const char *fn, byte *curThumb, const char *name, bo f->writeByte(nCfgMusicVolume); f->writeByte(nCfgSFXVolume); - // Salva gli hotspot + // Save the hotspots SaveChangedHotspot(f); - // Salva la musica + // Save the music SaveMusic(f); f->finalize(); @@ -845,8 +834,10 @@ void RMGfxEngine::LoadState(CORO_PARAM, const char *fn) { CORO_BEGIN_CODE(_ctx); _ctx->f = g_system->getSavefileManager()->openForLoading(fn); - if (_ctx->f == NULL) return; + if (_ctx->f == NULL) + return; _ctx->f->read(_ctx->buf, 4); + if (_ctx->buf[0] != 'R' || _ctx->buf[1] != 'M' || _ctx->buf[2] != 'S') { delete _ctx->f; return; @@ -854,39 +845,43 @@ void RMGfxEngine::LoadState(CORO_PARAM, const char *fn) { _ctx->ver = _ctx->buf[3]; - if (_ctx->ver != 0x1 && _ctx->ver != 0x2 && _ctx->ver != 0x3 && _ctx->ver != 0x4 && _ctx->ver != 0x5 && _ctx->ver != 0x6 && _ctx->ver != 0x7) { + if (_ctx->ver == 0 || _ctx->ver > TONY_SAVEGAME_VERSION) { delete _ctx->f; return; } if (_ctx->ver >= 0x3) { - // C' il thumbnail. Se _ctx->ver >= 5, compresso - if (_ctx->ver >= 0x5) { + // There is a thumbnail. If the version is between 5 and 7, it's compressed + if ((_ctx->ver >= 0x5) && (_ctx->ver <= 0x7)) { _ctx->i = 0; _ctx->i = _ctx->f->readUint32LE(); _ctx->f->seek(_ctx->i); - } else + } else { + if (_ctx->ver >= 8) + // Skip thumbnail size + _ctx->f->skip(4); + _ctx->f->seek(160 * 120 * 2, SEEK_CUR); + } } if (_ctx->ver >= 0x5) { - // Skip del livello di difficolt + // Skip the difficulty level _ctx->f->seek(1, SEEK_CUR); } - if (_ctx->ver >= 0x4) { // Skippa il nome, che non serve a nessuno + if (_ctx->ver >= 0x4) { // Skip the savegame name, which serves no purpose _ctx->i = _ctx->f->readByte(); _ctx->f->seek(_ctx->i, SEEK_CUR); } - _ctx->loc = _ctx->f->readUint32LE(); _ctx->loc = _ctx->f->readUint32LE(); _ctx->tp.x = _ctx->f->readUint32LE(); _ctx->tp.y = _ctx->f->readUint32LE(); _ctx->size = _ctx->f->readUint32LE(); - if (_ctx->ver >= 0x5) { - // Stato MPAL compresso! + if ((_ctx->ver >= 0x5) && (_ctx->ver <= 7)) { + // MPAL was packed! _ctx->sizecmp = _ctx->f->readUint32LE(); _ctx->state = new byte[_ctx->size]; _ctx->statecmp = new byte[_ctx->sizecmp]; @@ -894,6 +889,7 @@ void RMGfxEngine::LoadState(CORO_PARAM, const char *fn) { lzo1x_decompress(_ctx->statecmp,_ctx->sizecmp,_ctx->state,&_ctx->size); delete[] _ctx->statecmp; } else { + // Read uncompressed MPAL data _ctx->state = new byte[_ctx->size]; _ctx->f->read(_ctx->state, _ctx->size); } @@ -901,8 +897,7 @@ void RMGfxEngine::LoadState(CORO_PARAM, const char *fn) { mpalLoadState(_ctx->state); delete[] _ctx->state; - - // inventario + // Inventory _ctx->size = _ctx->f->readUint32LE(); _ctx->state = new byte[_ctx->size]; _ctx->f->read(_ctx->state, _ctx->size); @@ -930,7 +925,7 @@ void RMGfxEngine::LoadState(CORO_PARAM, const char *fn) { } if (_ctx->ver >= 6) { - // Carica le opzioni + // Load options bCfgInvLocked = _ctx->f->readByte(); bCfgInvNoScroll = _ctx->f->readByte(); bCfgTimerizedText = _ctx->f->readByte(); @@ -949,7 +944,7 @@ void RMGfxEngine::LoadState(CORO_PARAM, const char *fn) { nCfgMusicVolume = _ctx->f->readByte(); nCfgSFXVolume = _ctx->f->readByte(); - // Carica gli hotspot + // Load hotspots LoadChangedHotspot(_ctx->f); } @@ -964,11 +959,11 @@ void RMGfxEngine::LoadState(CORO_PARAM, const char *fn) { m_tony.SetPattern(RMTony::PAT_STANDRIGHT); MainUnfreeze(); - // Le versioni vecchie necessitano di On enter + // On older versions, need to an enter action if (_ctx->ver < 5) mpalQueryDoAction(0, _ctx->loc, 0); else { - // In quelle nuove, ci basta resettare gli mcode + // In the new ones, we just reset the mcode MCharResetCodes(); } diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp index bd90ec641d..fcd56b5989 100644 --- a/engines/tony/input.cpp +++ b/engines/tony/input.cpp @@ -127,4 +127,14 @@ bool RMInput::MouseRight() { return _rightButton; } +/** + * Return true if a key has been pressed */ +bool RMInput::GetAsyncKeyState(Common::KeyCode kc) { + // The act of testing for a particular key automatically clears the state, to prevent + // the same key being registered in multiple different frames + bool result = _keyDown[(int)kc]; + _keyDown[(int)kc] = false; + return result; +} + } // End of namespace Tony diff --git a/engines/tony/input.h b/engines/tony/input.h index acb7fbd677..79a11db678 100644 --- a/engines/tony/input.h +++ b/engines/tony/input.h @@ -98,7 +98,7 @@ public: bool MouseBothReleased() { return _leftReleaseMouse && _rightReleaseMouse; } // Returns true if the given key is pressed - bool GetAsyncKeyState(Common::KeyCode kc) { return _keyDown[(int)kc]; } + bool GetAsyncKeyState(Common::KeyCode kc); }; } // End of namespace Tony diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index f86576d5c2..56b68419fd 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -389,20 +389,13 @@ int TonyEngine::GetMusicVolume(int nChannel) { } -void TonyEngine::GetSaveStateFileName(int n, char *buf) { - RMString name; - - if (n > 0) - name.Format("%02d", n); - else - name.Format("autosave"); - - name += ".sav"; +Common::String TonyEngine::GetSaveStateFileName(int n) { + return Common::String::format("tony.%03d", n); } void TonyEngine::AutoSave(CORO_PARAM) { CORO_BEGIN_CONTEXT; - char buf[256]; + Common::String buf; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -411,8 +404,8 @@ void TonyEngine::AutoSave(CORO_PARAM) { CORO_INVOKE_0(MainWaitFrame); CORO_INVOKE_0(MainWaitFrame); MainFreeze(); - GetSaveStateFileName(0, _ctx->buf); - _theEngine.SaveState(_ctx->buf, (byte *)m_curThumbnail, "Autosave", true); + _ctx->buf = GetSaveStateFileName(0); + _theEngine.SaveState(_ctx->buf.c_str(), (byte *)m_curThumbnail, "Autosave", true); MainUnfreeze(); CORO_END_CODE; @@ -420,22 +413,20 @@ void TonyEngine::AutoSave(CORO_PARAM) { void TonyEngine::SaveState(int n, const char *name) { - char buf[256]; - - GetSaveStateFileName(n, buf); - _theEngine.SaveState(buf,(byte *)m_curThumbnail, name); + Common::String buf = GetSaveStateFileName(n); + _theEngine.SaveState(buf.c_str(), (byte *)m_curThumbnail, name); } void TonyEngine::LoadState(CORO_PARAM, int n) { CORO_BEGIN_CONTEXT; - char buf[256]; + Common::String buf; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - GetSaveStateFileName(n, _ctx->buf); - CORO_INVOKE_1(_theEngine.LoadState, _ctx->buf); + _ctx->buf = GetSaveStateFileName(n); + CORO_INVOKE_1(_theEngine.LoadState, _ctx->buf.c_str()); CORO_END_CODE; } @@ -485,8 +476,7 @@ void TonyEngine::CloseVoiceDatabase() { } void TonyEngine::GrabThumbnail(void) { - //_window.GrabThumbnail(m_curThumbnail); - warning("TODO: TonyEngine::GrabThumbnail"); + _window.GrabThumbnail(m_curThumbnail); } void TonyEngine::OptionScreen(void) { diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 69b54e8edb..4a80970bb9 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -194,7 +194,7 @@ public: void AutoSave(CORO_PARAM); void SaveState(int n, const char *name); void LoadState(CORO_PARAM, int n); - void GetSaveStateFileName(int n, char *buf); + Common::String GetSaveStateFileName(int n); // Prende il thumbnail void GrabThumbnail(void); diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index da49b91109..2518250bc7 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -90,7 +90,8 @@ void RMWindow::Close(void) { } void RMWindow::GrabThumbnail(uint16 *thumbmem) { - warning("TODO: RMWindow::GrabThumbnail"); + m_bGrabThumbnail = true; + m_wThumbBuf = thumbmem; } /** @@ -135,6 +136,14 @@ void RMWindow::GetNewFrame(byte *lpBuf, Common::Rect *rcBoundEllipse) { // Standard screen copy g_system->copyRectToScreen(lpBuf, RM_SX * 2, 0, 0, RM_SX, RM_SY); } + + if (m_bGrabThumbnail) { + // Need to generate a thumbnail + RMSnapshot s; + + s.GrabScreenshot(lpBuf, 4, m_wThumbBuf); + m_bGrabThumbnail = false; + } } /** @@ -270,7 +279,6 @@ bool RMSnapshot::GetFreeSnapName(char *fn) { } void RMSnapshot::GrabScreenshot(byte *lpBuf, int dezoom, uint16 *lpDestBuf) { -#ifdef REFACTOR_ME uint16 *src = (uint16 *)lpBuf; int dimx = RM_SX / dezoom; @@ -278,15 +286,15 @@ void RMSnapshot::GrabScreenshot(byte *lpBuf, int dezoom, uint16 *lpDestBuf) { int u, v, curv; - uint16 appo; - uint32 k = 0; + uint16 appo; + uint32 k = 0; int sommar, sommab, sommag; uint16 *cursrc; if (lpDestBuf == NULL) src += (RM_SY - 1) * RM_BBX; - if (dezoom == 1 && 0) { // @@@ NON E' TESTATA MOLTO BENE!!! + if (dezoom == 1 && 0) { byte *curOut = rgb; for (int y = 0; y < dimy; y++) { @@ -329,9 +337,10 @@ void RMSnapshot::GrabScreenshot(byte *lpBuf, int dezoom, uint16 *lpDestBuf) { rgb[k + 2] = (byte) (sommar * 8 / (dezoom * dezoom)); if (lpDestBuf!=NULL) - lpDestBuf[k/3] = ((int)rgb[k+0]>>3) | (((int)rgb[k+1]>>3)<<5) | (((int)rgb[k+2]>>3)<<10); + lpDestBuf[k / 3] = ((int)rgb[k + 0] >> 3) | (((int)rgb[k + 1] >> 3) << 5) | + (((int)rgb[k + 2] >> 3) << 10); - k+=3; + k += 3; } if (lpDestBuf == NULL) @@ -340,48 +349,6 @@ void RMSnapshot::GrabScreenshot(byte *lpBuf, int dezoom, uint16 *lpDestBuf) { src += RM_BBX * dezoom; } } - - - if (lpDestBuf == NULL) { - if (!GetFreeSnapName(filename)) - return; - - HANDLE hFile = CreateFile(filename, - GENERIC_WRITE, - 0, - NULL, - CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, - NULL); - - BITMAPFILEHEADER bmfHeader; - bmfHeader.bfType = ((uint16) ('M' << 8) | 'B'); - bmfHeader.bfSize = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + dimx * dimy * 3; - bmfHeader.bfReserved1 = 0; - bmfHeader.bfReserved2 = 0; - bmfHeader.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER); - - BITMAPINFOHEADER bmiHeader; - bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - bmiHeader.biWidth = dimx; - bmiHeader.biHeight = dimy; - bmiHeader.biPlanes = 1; - bmiHeader.biBitCount = 24; - bmiHeader.biCompression = BI_RGB; - bmiHeader.biSizeImage = dimx * dimy * 3; - bmiHeader.biXPelsPerMeter = 0xB12; - bmiHeader.biYPelsPerMeter = 0xB12; - bmiHeader.biClrUsed = 0; - bmiHeader.biClrImportant = 0; - - uint32 dwWritten; - WriteFile(hFile, &bmfHeader, sizeof(BITMAPFILEHEADER), &dwWritten, NULL); - WriteFile(hFile, &bmiHeader, sizeof(BITMAPINFOHEADER), &dwWritten, NULL); - - WriteFile(hFile, rgb, dimx * dimy * 3, &dwWritten, NULL); - CloseHandle(hFile); - } -#endif } } // End of namespace Tony -- cgit v1.2.3 From d615f0054058a8888a8dfa366adaae75c72c5ac9 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 13 May 2012 00:24:53 +1000 Subject: TONY: Workaround for correctly hiding items when they are disabled. I've traced through the code, and the order seems to specifically put the object into the 'destroy me' state by calling another process/thread, but then immediately replaces the values when it returns to the calling method. This workaround at least detects when an item is supposed to be destroyed, and ensures it remains in the 'destroy me' state. --- engines/tony/loc.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 37fe29f359..7a51386a1c 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -321,6 +321,13 @@ int RMPattern::Update(uint32 hEndPattern, byte &bFlag, RMSfx *sfx) { RMPattern::RMPattern() { m_slots = NULL; + m_speed = 0; + m_bLoop = 0; + m_nSlots = 0; + m_nCurSlot = 0; + m_nCurSprite = 0; + m_nStartTime = 0; + m_slots = NULL; } RMPattern::~RMPattern() { @@ -706,9 +713,18 @@ bool RMItem::DoFrame(RMGfxTargetBuffer *bigBuf, bool bAddToList) { return false; // Facciamo un update del pattern, che ci ritorna anche il frame corrente - if (m_nCurPattern != 0) + if (m_nCurPattern != 0) { m_nCurSprite = m_patterns[m_nCurPattern].Update(m_hEndPattern, m_bCurFlag, m_sfx); + // WORKAROUND: Currently, m_nCurSprite = -1 is used to flag that an item should be removed. + // However, this seems to be done inside a process waiting on an event pulsed inside the pattern + // Update method. So the value of m_nCurSprite = -1 is being destroyed with the return value + // replacing it. It may be that the current coroutine PulseEvent implementation is wrong somehow. + // In any case, a special check here is done for items that have ended + if (m_nCurPattern == 0) + m_nCurSprite = -1; + } + // Se la funzione ha ritornato -1, vuol dire che il pattern e' finito if (m_nCurSprite == -1) { // Mettiamo il pattern 0, e usciamo. La classe si auto-deregistrera' della OT list @@ -764,7 +780,7 @@ void RMItem::RemoveThis(CORO_PARAM, bool &result) { void RMItem::SetStatus(int nStatus) { - m_bIsActive = (nStatus>0); + m_bIsActive = (nStatus > 0); } void RMItem::SetPattern(int nPattern, bool bPlayP0) { -- cgit v1.2.3 From 09afc8a1fa354bc25a118a181d261e54c81f97c9 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 13 May 2012 00:25:32 +1000 Subject: TONY: Added FIXME for unsafe pointer conversion --- engines/tony/gfxengine.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines') diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 579983ad75..bbb6eb8f3e 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -371,6 +371,7 @@ void RMGfxEngine::InitCustomDll(void) { SetupGlobalVars(&m_tony, &m_point, &_vm->_theBoxes, &m_loc, &m_inv, &m_input); } +// FIXME: Casting nPattern from int to RMGfxEngine * void RMGfxEngine::ItemIrq(uint32 dwItem, int nPattern, int nStatus) { static RMGfxEngine *This = NULL; RMItem *item; -- cgit v1.2.3 From 8a88ad861d68bd4c5a1a932d9da2518569ecc4ff Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 13 May 2012 00:43:02 +1000 Subject: TONY: Converted object passing to use const reference where appropriate. This should cut down on the number of redunndant creations of temporary objects. --- engines/tony/font.cpp | 14 +++++++------- engines/tony/font.h | 18 +++++++++--------- engines/tony/game.cpp | 10 +++++----- engines/tony/game.h | 10 +++++----- engines/tony/gfxengine.cpp | 2 +- engines/tony/gfxengine.h | 2 +- engines/tony/inventory.cpp | 18 +++++++++--------- engines/tony/inventory.h | 18 +++++++++--------- engines/tony/loc.cpp | 28 ++++++++++++++-------------- engines/tony/loc.h | 30 +++++++++++++++--------------- engines/tony/tonychar.h | 2 +- engines/tony/utils.cpp | 10 +++++----- engines/tony/utils.h | 12 ++++++------ engines/tony/window.cpp | 1 - 14 files changed, 87 insertions(+), 88 deletions(-) (limited to 'engines') diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 5712014bf2..2f8c0c5065 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -171,7 +171,7 @@ void RMFont::Close(void) { Unload(); } -int RMFont::StringLen(RMString text) { +int RMFont::StringLen(const RMString &text) { int len, i; len = 0; @@ -1859,7 +1859,7 @@ void RMText::RemoveThis(CORO_PARAM, bool &result) { } -void RMText::WriteText(RMString text, int nFont, int *time) { +void RMText::WriteText(const RMString &text, int nFont, int *time) { // Inizializza i font (una volta sola) if (m_fonts[0] == NULL) { m_fonts[0] = new RMFontParla; m_fonts[0]->Init(); @@ -1876,7 +1876,7 @@ void RMText::WriteText(RMString text, int nFont, int *time) { } -void RMText::WriteText(RMString text, RMFontColor *font, int *time) { +void RMText::WriteText(const RMString &text, RMFontColor *font, int *time) { RMGfxPrimitive *prim; char *p, *old_p; int i, j, x, y; @@ -2077,14 +2077,14 @@ void RMTextDialog::Hide(CORO_PARAM) { m_bShowed = false; } -void RMTextDialog::WriteText(RMString text, int font, int *time) { +void RMTextDialog::WriteText(const RMString &text, int font, int *time) { RMText::WriteText(text,font,&m_time); if (time != NULL) *time = m_time; } -void RMTextDialog::WriteText(RMString text, RMFontColor *font, int *time) { +void RMTextDialog::WriteText(const RMString &text, RMFontColor *font, int *time) { RMText::WriteText(text,font,&m_time); if (time != NULL) @@ -2434,10 +2434,10 @@ void RMDialogChoice::SetNumChoices(int num) { } } -void RMDialogChoice::AddChoice(RMString string) { +void RMDialogChoice::AddChoice(const RMString &string) { // Si disegna la stringa assert(m_curAdded < m_numChoices); - m_drawedStrings[m_curAdded++].WriteText(string,0); + m_drawedStrings[m_curAdded++].WriteText(string, 0); } void RMDialogChoice::Prepare(CORO_PARAM) { diff --git a/engines/tony/font.h b/engines/tony/font.h index 7c766e5d01..a63c90638d 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -118,8 +118,8 @@ public: RMGfxPrimitive *MakeLetterPrimitive(byte bChar, int& nLength); // Lunghezza in pixel di una stringa con il font corrente - int StringLen(RMString text); - int StringLen(char bChar, char bNext=0); + int StringLen(const RMString &text); + int StringLen(char bChar, char bNext = 0); }; @@ -225,8 +225,8 @@ public: void SetMaxLineLength(int max); // Scrive un testo - void WriteText(RMString text, int font, int *time = NULL); - void WriteText(RMString text, RMFontColor* font, int *time = NULL); + void WriteText(const RMString &text, int font, int *time = NULL); + void WriteText(const RMString &text, RMFontColor *font, int *time = NULL); // Overloading della funzione ereditata da RMGfxTask per decidere // quando eliminare un oggetto dalla OTLIST @@ -263,8 +263,8 @@ class RMTextDialog : public RMText { virtual ~RMTextDialog(); // Scrive un testo - void WriteText(RMString text, int font, int *time=NULL); - void WriteText(RMString text, RMFontColor* font, int *time=NULL); + void WriteText(const RMString &text, int font, int *time = NULL); + void WriteText(const RMString &text, RMFontColor *font, int *time = NULL); // Overloading della funzione ereditata da RMGfxTask per decidere // quando eliminare un oggetto dalla OTLIST @@ -278,7 +278,7 @@ class RMTextDialog : public RMText { virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Setta la posizione - void SetPosition(RMPoint pt) { dst=pt; } + void SetPosition(const RMPoint &pt) { dst = pt; } // Aspetta che venga finita la visualizzazione void WaitForEndDisplay(CORO_PARAM); @@ -331,7 +331,7 @@ public: RMTextItemName(); virtual ~RMTextItemName(); - void SetMouseCoord(RMPoint m) { m_mpos=m; } + void SetMouseCoord(const RMPoint &m) { m_mpos = m; } void DoFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation &loc, RMPointer &ptr, RMInventory &inv); virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); @@ -385,7 +385,7 @@ public: void SetNumChoices(int num); // Aggiunge una stringa con la scelta - void AddChoice(RMString string); + void AddChoice(const RMString &string); // Mostra e nasconde la scelta, con eventuali animazioni // NOTA: Se non viene passato parametro alla Show(), obbligo del diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 7378826a71..d579ac34a3 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -180,7 +180,7 @@ RMOptionButton::RMOptionButton(uint32 dwRes, RMPoint pt, bool bDoubleState) { m_bDoubleState = bDoubleState; } -RMOptionButton::RMOptionButton(RMRect pt) { +RMOptionButton::RMOptionButton(const RMRect &pt) { m_rect = pt; m_bActive = false; m_bHasGfx = false; @@ -192,7 +192,7 @@ RMOptionButton::~RMOptionButton() { delete m_buf; } -bool RMOptionButton::DoFrame(RMPoint mousePos, bool bLeftClick, bool bRightClick) { +bool RMOptionButton::DoFrame(const RMPoint &mousePos, bool bLeftClick, bool bRightClick) { if (!m_bDoubleState) { if (m_rect.PtInRect(mousePos)) { if (!m_bActive) { @@ -201,7 +201,7 @@ bool RMOptionButton::DoFrame(RMPoint mousePos, bool bLeftClick, bool bRightClick } } else { if (m_bActive) { - m_bActive=false; + m_bActive = false; return true; } } @@ -241,7 +241,7 @@ void RMOptionButton::AddToList(RMGfxTargetBuffer &bigBuf) { * Metodi di RMOptionSlide \****************************************************************************/ -RMOptionSlide::RMOptionSlide(RMPoint pt, int nRange, int nStartValue, int slideSize) { +RMOptionSlide::RMOptionSlide(const RMPoint &pt, int nRange, int nStartValue, int slideSize) { RMResRaw *raw; m_pos = pt; @@ -283,7 +283,7 @@ RMOptionSlide::~RMOptionSlide() { m_PushRight = NULL; } -bool RMOptionSlide::DoFrame(RMPoint mousePos, bool bLeftClick, bool bRightClick) { +bool RMOptionSlide::DoFrame(const RMPoint &mousePos, bool bLeftClick, bool bRightClick) { bool bRefresh = false; // Doframe dei bottoni diff --git a/engines/tony/game.h b/engines/tony/game.h index 554279c13f..8cd64ec7d2 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -138,7 +138,7 @@ public: virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Sets the current co-ordinates - void SetCoord(RMPoint pt) { m_pos = pt; } + void SetCoord(const RMPoint &pt) { m_pos = pt; } // Overloading of the method to see if rising from the list virtual void RemoveThis(CORO_PARAM, bool &result); @@ -170,10 +170,10 @@ public: public: RMOptionButton(uint32 dwRes, RMPoint pt, bool bDoubleState = false); - RMOptionButton(RMRect pt); + RMOptionButton(const RMRect &pt); virtual ~RMOptionButton(); - bool DoFrame(RMPoint mousePos, bool bLeftClick, bool bRightClick); + bool DoFrame(const RMPoint &mousePos, bool bLeftClick, bool bRightClick); virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); void AddToList(RMGfxTargetBuffer &bigBuf); bool IsActive() { return m_bActive; } @@ -195,10 +195,10 @@ private: int m_nStep; public: - RMOptionSlide(RMPoint pt, int m_nRange=100, int m_nStartValue=0, int slideSize=300); + RMOptionSlide(const RMPoint &pt, int m_nRange = 100, int m_nStartValue = 0, int slideSize = 300); virtual ~RMOptionSlide(); - bool DoFrame(RMPoint mousePos, bool bLeftClick, bool bRightClick); + bool DoFrame(const RMPoint &mousePos, bool bLeftClick, bool bRightClick); virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); void AddToList(RMGfxTargetBuffer& bigBuf); diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index bbb6eb8f3e..1b09e00956 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -437,7 +437,7 @@ void RMGfxEngine::ItemIrq(uint32 dwItem, int nPattern, int nStatus) { */ -void RMGfxEngine::SelectLocation(RMPoint ptTonyStart, RMPoint start) { +void RMGfxEngine::SelectLocation(const RMPoint &ptTonyStart, const RMPoint &start) { #if 0 OPENFILENAME ofn; char lpszFileName[512]; diff --git a/engines/tony/gfxengine.h b/engines/tony/gfxengine.h index 41255229b8..3f90d41ad7 100644 --- a/engines/tony/gfxengine.h +++ b/engines/tony/gfxengine.h @@ -150,7 +150,7 @@ public: void LoadState(CORO_PARAM, const char *fn); // Selects a location - void SelectLocation(RMPoint ptTonyStart=RMPoint(-1,-1), RMPoint start=RMPoint(-1,-1)); + void SelectLocation(const RMPoint &ptTonyStart = RMPoint(-1, -1), const RMPoint &start = RMPoint(-1,-1)); // Pauses sound void PauseSound(bool bPause); diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index b5c28506a9..b4eef0ac0d 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -83,7 +83,7 @@ RMInventory::~RMInventory() { g_system->deleteMutex(m_csModifyInterface); } -bool RMInventory::CheckPointInside(RMPoint &pt) { +bool RMInventory::CheckPointInside(const RMPoint &pt) { if (!bCfgInvUp) return pt.y > RM_SY - 70; else @@ -343,7 +343,7 @@ bool RMInventory::MiniActive(void) { return m_state == SELECTING; } -bool RMInventory::HaveFocus(RMPoint mpos) { +bool RMInventory::HaveFocus(const RMPoint &mpos) { // In fase di combine abbiamo il focus solo se siamo su una freccia (per poter scrollare) if (m_state == OPENED && m_bCombining && CheckPointInside(mpos) && (mpos.x < 64 || mpos.x > RM_SX - 64)) return true; @@ -363,7 +363,7 @@ void RMInventory::EndCombine(void) { m_bCombining = false; } -bool RMInventory::LeftClick(RMPoint mpos, int& nCombineObj) { +bool RMInventory::LeftClick(const RMPoint &mpos, int& nCombineObj) { int n; // Il click sinistro prende in mano un oggetto dell'inventario per utilizzarlo con lo sfondo @@ -427,7 +427,7 @@ bool RMInventory::LeftClick(RMPoint mpos, int& nCombineObj) { } -void RMInventory::RightClick(RMPoint mpos) { +void RMInventory::RightClick(const RMPoint &mpos) { int n; assert(CheckPointInside(mpos)); @@ -488,7 +488,7 @@ void RMInventory::RightClick(RMPoint mpos) { } } -bool RMInventory::RightRelease(RMPoint mpos, RMTonyAction& curAction) { +bool RMInventory::RightRelease(const RMPoint &mpos, RMTonyAction& curAction) { if (m_state == SELECTING) { m_state = OPENED; @@ -701,14 +701,14 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo } -bool RMInventory::ItemInFocus(RMPoint mpt) { +bool RMInventory::ItemInFocus(const RMPoint &mpt) { if ((m_state == OPENED || m_state == OPENING) && CheckPointInside(mpt)) return true; else return false; } -RMItem *RMInventory::WhichItemIsIn(RMPoint mpt) { +RMItem *RMInventory::WhichItemIsIn(const RMPoint &mpt) { int n; if (m_state == OPENED) { @@ -847,7 +847,7 @@ void RMInterface::DoFrame(RMGfxTargetBuffer &bigBuf, RMPoint mousepos) { m_mpos = mousepos; } -void RMInterface::Clicked(RMPoint mousepos) { +void RMInterface::Clicked(const RMPoint &mousepos) { m_bActive = true; m_openPos = mousepos; @@ -865,7 +865,7 @@ void RMInterface::Clicked(RMPoint mousepos) { _vm->PlayUtilSFX(0); } -bool RMInterface::Released(RMPoint mousepos, RMTonyAction &action) { +bool RMInterface::Released(const RMPoint &mousepos, RMTonyAction &action) { if (!m_bActive) return false; diff --git a/engines/tony/inventory.h b/engines/tony/inventory.h index e2143bb24b..86eaa6801e 100644 --- a/engines/tony/inventory.h +++ b/engines/tony/inventory.h @@ -104,7 +104,7 @@ protected: // Controlla se la posizione Y del mouse corretta, anche in base // alla posizione dell'inventario su schermo - bool CheckPointInside(RMPoint &pt); + bool CheckPointInside(const RMPoint &pt); public: RMInventory(); @@ -125,17 +125,17 @@ public: virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Metodo per determinare se l'inventario sta comandando gli input - bool HaveFocus(RMPoint mpos); + bool HaveFocus(const RMPoint &mpos); // Metodo per determinare se la mini interfaccia attiva bool MiniActive(void); // Gestisce il click sinistro del mouse (solo quando c'ha focus) - bool LeftClick(RMPoint mpos, int &nCombineObj); + bool LeftClick(const RMPoint &mpos, int &nCombineObj); // Gestisce il tasto destro del mouse (solo quando c'ha focus) - void RightClick(RMPoint mpos); - bool RightRelease(RMPoint mpos, RMTonyAction &curAction); + void RightClick(const RMPoint &mpos); + bool RightRelease(const RMPoint &mpos, RMTonyAction &curAction); // Avverte che finito il combine void EndCombine(void); @@ -151,8 +151,8 @@ public: void RemoveItem(int code); // Siamo sopra un oggetto? - RMItem* WhichItemIsIn(RMPoint mpt); - bool ItemInFocus(RMPoint mpt); + RMItem *WhichItemIsIn(const RMPoint &mpt); + bool ItemInFocus(const RMPoint &mpt); // Cambia l'icona di un oggetto void ChangeItemStatus(uint32 dwCode, uint32 dwStatus); @@ -197,8 +197,8 @@ public: void Reset(void); // Avverte dei click e rilasci del mouse - void Clicked(RMPoint mousepos); - bool Released(RMPoint mousepos, RMTonyAction &action); + void Clicked(const RMPoint &mousepos); + bool Released(const RMPoint &mousepos, RMTonyAction &action); // Attiva o disattiva il quinto verbo void SetPalesati(bool bOn); diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 7a51386a1c..d805e9ee82 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -576,7 +576,7 @@ RMGfxSourceBuffer *RMItem::NewItemSpriteBuffer(int dimx, int dimy, bool bPreRLE) return new RMGfxSourceBuffer16; } -bool RMItem::IsIn(RMPoint pt, int *size) { +bool RMItem::IsIn(const RMPoint &pt, int *size) { RMRect rc; if (!m_bIsActive) @@ -701,7 +701,7 @@ RMGfxPrimitive *RMItem::NewItemPrimitive() { return new RMGfxPrimitive(this); } -void RMItem::SetScrollPosition(RMPoint scroll) { +void RMItem::SetScrollPosition(const RMPoint &scroll) { m_curScroll = scroll; } @@ -810,7 +810,7 @@ void RMItem::SetPattern(int nPattern, bool bPlayP0) { } -bool RMItem::GetName(RMString& name) +bool RMItem::GetName(RMString &name) { char buf[256]; @@ -887,7 +887,7 @@ void RMItem::WaitForEndPattern(CORO_PARAM, uint32 hCustomSkip) { CORO_END_CODE; } -void RMItem::ChangeHotspot(RMPoint pt) { +void RMItem::ChangeHotspot(const RMPoint &pt) { m_hot = pt; } @@ -1246,7 +1246,7 @@ RMPoint RMCharacter::Searching(char UP, char DOWN, char RIGHT, char LEFT, RMPoin } -RMPoint RMCharacter::NearestPoint(RMPoint punto) { +RMPoint RMCharacter::NearestPoint(const RMPoint &punto) { /* RMPoint tofind; signed short difx,dify; @@ -1273,7 +1273,7 @@ RMPoint RMCharacter::NearestPoint(RMPoint punto) { } -short RMCharacter::ScanLine(RMPoint punto) { +short RMCharacter::ScanLine(const RMPoint &punto) { int Ldx, Ldy, Lcount; float Lfx, Lfy, Lslope; RMPoint Lstart, Lend, Lscan; @@ -1321,7 +1321,7 @@ short RMCharacter::ScanLine(RMPoint punto) { } // Calcola intersezioni tra la traiettoria rettilinea ed il pi vicino BBOX -RMPoint RMCharacter::InvScanLine(RMPoint punto) { +RMPoint RMCharacter::InvScanLine(const RMPoint &punto) { int Ldx, Ldy, Lcount; float Lfx, Lfy, Lslope; RMPoint Lstart, Lend, Lscan; @@ -1617,8 +1617,8 @@ void RMCharacter::Stop(CORO_PARAM) { CORO_END_CODE; } -inline int RMCharacter::InWhichBox(RMPoint pt) { - return theBoxes->WhichBox(curLocation,pt); +inline int RMCharacter::InWhichBox(const RMPoint &pt) { + return theBoxes->WhichBox(curLocation, pt); } @@ -1699,7 +1699,7 @@ void RMCharacter::Move(CORO_PARAM, RMPoint pt, bool *result) { CORO_END_CODE; } -void RMCharacter::SetPosition(RMPoint pt, int newloc) { +void RMCharacter::SetPosition(const RMPoint &pt, int newloc) { RMBoxLoc *box; minpath = 0; @@ -1912,7 +1912,7 @@ RMBoxLoc *RMGameBoxes::GetBoxes(int nLoc) { return m_allBoxes[nLoc]; } -bool RMGameBoxes::IsInBox(int nLoc, int nBox, RMPoint pt) { +bool RMGameBoxes::IsInBox(int nLoc, int nBox, const RMPoint &pt) { RMBoxLoc *cur = GetBoxes(nLoc); if ((pt.x >= cur->boxes[nBox].left) && (pt.x <= cur->boxes[nBox].right) && @@ -1922,7 +1922,7 @@ bool RMGameBoxes::IsInBox(int nLoc, int nBox, RMPoint pt) { return false; } -int RMGameBoxes::WhichBox(int nLoc, RMPoint punto) { +int RMGameBoxes::WhichBox(int nLoc, const RMPoint &punto) { int i; RMBoxLoc *cur = GetBoxes(nLoc); @@ -2311,7 +2311,7 @@ RMItem *RMLocation::GetItemFromCode(uint32 dwCode) { return NULL; } -RMItem *RMLocation::WhichItemIsIn(RMPoint pt) { +RMItem *RMLocation::WhichItemIsIn(const RMPoint &pt) { int found = -1; int foundSize = 0; int size; @@ -2351,7 +2351,7 @@ void RMLocation::Unload(void) { } } -void RMLocation::UpdateScrolling(RMPoint ptShowThis) { +void RMLocation::UpdateScrolling(const RMPoint &ptShowThis) { RMPoint oldScroll = m_curScroll; if (m_curScroll.x + 250 > ptShowThis.x) { diff --git a/engines/tony/loc.h b/engines/tony/loc.h index bbe37778c0..d81ecb45d5 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -262,7 +262,7 @@ public: bool DoFrame(RMGfxTargetBuffer *bigBuf, bool bAddToList = true); // Setta la posizione corrente di scrolling - void SetScrollPosition(RMPoint scroll); + void SetScrollPosition(const RMPoint &scroll); // Overloading della funzione per la rimozione da ot list virtual void RemoveThis(CORO_PARAM, bool &result); @@ -282,9 +282,9 @@ public: // Setta un nuovo status. void SetStatus(int nStatus); - bool IsIn(RMPoint pt, int* size=NULL); + bool IsIn(const RMPoint &pt, int *size = NULL); RMPoint Hotspot() { return m_hot; } - bool GetName(RMString& name); + bool GetName(RMString &name); int MpalCode() { return m_mpalCode; } // Scarica l'item @@ -294,7 +294,7 @@ public: void WaitForEndPattern(CORO_PARAM, uint32 hCustomSkip = CORO_INVALID_PID_VALUE); // Setta un nuovo hotspot per l'oggetto - void ChangeHotspot(RMPoint pt); + void ChangeHotspot(const RMPoint &pt); void SetInitCurPattern(bool status) { m_bInitCurPattern=status; } @@ -375,10 +375,10 @@ public: RMBoxLoc *GetBoxes(int nLoc); // Calcola in quale box si trova il punto - int WhichBox(int nLoc, RMPoint pt); + int WhichBox(int nLoc, const RMPoint &pt); // Controlla che il punto sia dentro un certo box - bool IsInBox(int nLoc, int nBox, RMPoint pt); + bool IsInBox(int nLoc, int nBox, const RMPoint &pt); // Cambia lo stato di un box void ChangeBoxStatus(int nLoc, int nBox, int status); @@ -432,15 +432,15 @@ private: RMPoint m_fixedScroll; private: - int InWhichBox(RMPoint pt); + int InWhichBox(const RMPoint &pt); short FindPath(short source, short destination); RMPoint Searching(char UP, char DOWN, char RIGHT, char LEFT, RMPoint punto); - RMPoint NearestPoint(RMPoint punto); + RMPoint NearestPoint(const RMPoint &punto); void GoTo(CORO_PARAM, RMPoint destcoord, bool bReversed=false); - short ScanLine(RMPoint punto); - RMPoint InvScanLine(RMPoint punto); + short ScanLine(const RMPoint &punto); + RMPoint InvScanLine(const RMPoint &punto); RMPoint NearestHotSpot(int sourcebox, int destbox); void NewBoxEntered(int nBox); @@ -478,13 +478,13 @@ public: void Move(CORO_PARAM, RMPoint pt, bool *result = NULL); // Posiziona il personaggio a una certa posizione SENZA farlo muovere - void SetPosition(RMPoint pt, int newloc=-1); + void SetPosition(const RMPoint &pt, int newloc = -1); // Aspetta la fine del movimento void WaitForEndMovement(CORO_PARAM); - void SetFixedScroll(RMPoint fix) { m_fixedScroll = fix; } - void SetSpeed(int speed) { curSpeed=speed; } + void SetFixedScroll(const RMPoint &fix) { m_fixedScroll = fix; } + void SetSpeed(int speed) { curSpeed = speed; } }; @@ -563,7 +563,7 @@ public: void DoFrame(RMGfxTargetBuffer *bigBuf); // Si fa dare il numero dell'item - RMItem* WhichItemIsIn(RMPoint pt); + RMItem *WhichItemIsIn(const RMPoint &pt); // Si fa dare un elemento dal suo codice MPAL RMItem* GetItemFromCode(uint32 dwCode); @@ -575,7 +575,7 @@ public: void SetFixedScroll(const RMPoint &scroll); // Aggiorna le coordinate di scrolling in modo da visualizzare sempre il punto fornito - void UpdateScrolling(RMPoint ptShowThis); + void UpdateScrolling(const RMPoint &ptShowThis); // Legge la posizione di scrolling corrente RMPoint ScrollPosition() { return m_curScroll; } diff --git a/engines/tony/tonychar.h b/engines/tony/tonychar.h index 17b5be23dc..ee6d518f4b 100644 --- a/engines/tony/tonychar.h +++ b/engines/tony/tonychar.h @@ -424,7 +424,7 @@ public: RMPoint Position() { return m_pos; } // Setta la posizione di scrolling - void SetScrollPosition(RMPoint pt) { RMCharacter::SetScrollPosition(pt); } + void SetScrollPosition(const RMPoint &pt) { RMCharacter::SetScrollPosition(pt); } // Setta l'animazione di Take void Take(int nWhere, int nPart); diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index 7a750c2975..a3998a01ab 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -109,7 +109,7 @@ RMString::RMString(const int ch) { * Returns the length of the string * @returns Length */ -int RMString::Length() { +int RMString::Length() const { return m_length; } @@ -785,7 +785,7 @@ RMPoint &RMPoint::operator=(RMPoint p) { /** * Offsets the point by another point */ -void RMPoint::Offset(RMPoint p) { +void RMPoint::Offset(const RMPoint &p) { x += p.x; y += p.y; } @@ -878,7 +878,7 @@ void RMRect::SetEmpty(void) { x1 = y1 = x2 = y2 = 0; } -RMRect::RMRect(RMPoint p1, RMPoint p2) { +RMRect::RMRect(const RMPoint &p1, const RMPoint &p2) { SetRect(p1, p2); } @@ -890,7 +890,7 @@ RMRect::RMRect(const RMRect &rc) { CopyRect(rc); } -void RMRect::SetRect(RMPoint p1, RMPoint p2) { +void RMRect::SetRect(const RMPoint &p1, const RMPoint &p2) { x1 = p1.x; y1 = p1.y; x2 = p2.x; @@ -957,7 +957,7 @@ void RMRect::Offset(int xOff, int yOff) { y2 += yOff; } -void RMRect::Offset(RMPoint p) { +void RMRect::Offset(const RMPoint &p) { x1 += p.x; y1 += p.y; x2 += p.x; diff --git a/engines/tony/utils.h b/engines/tony/utils.h index c8ffe062ea..4137823587 100644 --- a/engines/tony/utils.h +++ b/engines/tony/utils.h @@ -185,7 +185,7 @@ public: RMString(const int ch); // Metodi generici - int Length(); + int Length() const; void Compact(); // Access characters within string @@ -247,7 +247,7 @@ public: // Offset void Offset(int xOff, int yOff); - void Offset(RMPoint p); + void Offset(const RMPoint &p); friend RMPoint operator+(RMPoint p1, RMPoint p2); friend RMPoint operator-(RMPoint p1, RMPoint p2); RMPoint &operator+=(RMPoint p); @@ -273,7 +273,7 @@ public: public: RMRect(); RMRect(int x1, int y1, int x2, int y2); - RMRect(RMPoint p1, RMPoint p2); + RMRect(const RMPoint &p1, const RMPoint &p2); RMRect(const RMRect &rc); // Attributes @@ -287,7 +287,7 @@ public: // Set void SetRect(int x1, int y1, int x2, int y2); - void SetRect(RMPoint p1, RMPoint p2); + void SetRect(const RMPoint &p1, const RMPoint &p2); void SetEmpty(void); // Copiers @@ -297,7 +297,7 @@ public: // Offset void Offset(int xOff, int yOff); - void Offset(RMPoint p); + void Offset(const RMPoint &p); friend RMRect operator+(const RMRect &rc, RMPoint p); friend RMRect operator-(const RMRect &rc, RMPoint p); friend RMRect operator+(RMPoint p, const RMRect &rc); @@ -313,7 +313,7 @@ public: void NormalizeRect(); // Point in rect - bool PtInRect(RMPoint pt) { return (pt.x>=x1 && pt.x<=x2 && pt.y>=y1 && pt.y<=y2); } + bool PtInRect(const RMPoint &pt) { return (pt.x >= x1 && pt.x <= x2 && pt.y >= y1 && pt.y <= y2); } // Extract from data stream friend RMDataStream &operator>>(RMDataStream& ds, RMRect &rc); diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index 2518250bc7..f997b8c53d 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -286,7 +286,6 @@ void RMSnapshot::GrabScreenshot(byte *lpBuf, int dezoom, uint16 *lpDestBuf) { int u, v, curv; - uint16 appo; uint32 k = 0; int sommar, sommab, sommag; uint16 *cursrc; -- cgit v1.2.3 From ef4846c1218b0709a71ffb5feafebebd26988a4d Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 13 May 2012 00:47:28 +1000 Subject: TINSEL: Fix compiler warning --- engines/tinsel/rince.h | 1 - 1 file changed, 1 deletion(-) (limited to 'engines') diff --git a/engines/tinsel/rince.h b/engines/tinsel/rince.h index b34c3f20de..623f3ee137 100644 --- a/engines/tinsel/rince.h +++ b/engines/tinsel/rince.h @@ -31,7 +31,6 @@ namespace Tinsel { struct OBJECT; -struct Common::PROCESS; enum NPS {NOT_IN, GOING_UP, GOING_DOWN, LEAVING, ENTERING}; -- cgit v1.2.3 From 63e3b47857fe5a507858b4256b1f3f4d7fe50c22 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 13 May 2012 00:53:09 +1000 Subject: TONY: Fix compiler warnings --- engines/tony/custom.cpp | 6 +++--- engines/tony/mpal/mpal.cpp | 4 ++-- engines/tony/mpal/mpal.h | 3 +++ 3 files changed, 8 insertions(+), 5 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index a3a57dfce9..3e8f0b95e6 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -2130,7 +2130,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr CORO_BEGIN_CONTEXT; uint32 nChoice; uint32 *sl; - int i, num; + uint32 i, num; char *string; RMDialogChoice dc; int sel; @@ -2153,7 +2153,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr // Se c'e' una sola opzione, la fa automaticamente, e aspetta la prossima scelta if (_ctx->num == 1) { - mpalQueryDialogSelection(_ctx->nChoice, _ctx->sl[0]); + mpalQueryDialogSelectionDWORD(_ctx->nChoice, _ctx->sl[0]); GlobalFree(_ctx->sl); // Wait for the next choice to be made @@ -2192,7 +2192,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr MainHideMouse(); CORO_INVOKE_0(_ctx->dc.Hide); - mpalQueryDialogSelection(_ctx->nChoice, _ctx->sl[_ctx->sel]); + mpalQueryDialogSelectionDWORD(_ctx->nChoice, _ctx->sl[_ctx->sel]); // Chiude la scelta _ctx->dc.Close(); diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index d28fd8e8e2..bfde7fe2a6 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -1618,10 +1618,10 @@ static uint32 DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { // 0 dell'item, e poi liberera' la memoria con la GlobalFree() // !!! New thread management - if ((h = CoroScheduler.createProcess(ActionThread, &newitem, sizeof(LPMPALITEM))) == NULL) + if ((h = CoroScheduler.createProcess(ActionThread, &newitem, sizeof(LPMPALITEM))) == CORO_INVALID_PID_VALUE) return CORO_INVALID_PID_VALUE; - if (CoroScheduler.createProcess(ShutUpActionThread, &h, sizeof(uint32)) == NULL) + if (CoroScheduler.createProcess(ShutUpActionThread, &h, sizeof(uint32)) == CORO_INVALID_PID_VALUE) return CORO_INVALID_PID_VALUE; nExecutingAction = item->nObj; diff --git a/engines/tony/mpal/mpal.h b/engines/tony/mpal/mpal.h index 1d298b4f26..319f71c6a8 100644 --- a/engines/tony/mpal/mpal.h +++ b/engines/tony/mpal/mpal.h @@ -522,6 +522,9 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; #define mpalQueryDialogSelection(nChoice,dwData) \ (bool)mpalQueryDWORD(MPQ_DIALOG_SELECTION,(uint32)(nChoice),(uint32)(dwData)) +#define mpalQueryDialogSelectionDWORD(nChoice,dwData) \ + mpalQueryDWORD(MPQ_DIALOG_SELECTION,(uint32)(nChoice),(uint32)(dwData)) + /****************************************************************************\ * -- cgit v1.2.3 From 28c58a7f56ada6e4c72fcddc92fc4d5a1b181224 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 13 May 2012 00:58:59 +1000 Subject: TONY: Fix unsigned comparison warning --- engines/tony/custom.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 3e8f0b95e6..b1b660c423 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -2145,7 +2145,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr // Wait until a choice is selected mpalQueryDialogWaitForChoice(&_ctx->nChoice); - while (_ctx->nChoice != -1) { + while (_ctx->nChoice != (uint32)-1) { // Si fa dare la lista di opzioni e le conta _ctx->sl = mpalQueryDialogSelectList(_ctx->nChoice); for (_ctx->num = 0; _ctx->sl[_ctx->num] != 0; _ctx->num++) -- cgit v1.2.3 From 0a835de46805a3f8db4c68b3081fdf376e03a567 Mon Sep 17 00:00:00 2001 From: Torbj旦rn Andersson Date: Sat, 12 May 2012 19:40:33 +0200 Subject: TONY: Fix compiler warning --- engines/tony/game.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index d579ac34a3..758170c848 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -763,7 +763,7 @@ void RMOptionScreen::CloseState(void) { m_menu = NULL; delete m_ButtonExit; - m_ButtonExit = false; + m_ButtonExit = NULL; if (m_nState == MENULOAD || m_nState == MENUSAVE) { int i; -- cgit v1.2.3 From c35b5397168299176eab69622044a98c8995a369 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 13 May 2012 09:42:09 +1000 Subject: TONY: Some further initialisation of object fields --- engines/tony/gfxengine.cpp | 11 +++++++++++ engines/tony/sound.cpp | 15 +++++++++++++++ 2 files changed, 26 insertions(+) (limited to 'engines') diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 1b09e00956..f6d047d267 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -90,6 +90,17 @@ RMGfxEngine::RMGfxEngine() { m_bigBuf.OffsetY(RM_SKIPY); csMainLoop = NULL; + m_nCurLoc = 0; + m_curAction = TA_GOTO; + m_curActionObj = 0; + m_nWipeType = 0; + m_hWipeEvent = 0; + m_nWipeStep = 0; + m_bMustEnterMenu = false; + m_bWiping = false; + m_bGUIOption = false; + m_bGUIInterface = false; + m_bGUIInventory = false; } RMGfxEngine::~RMGfxEngine() { diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index 0658c99f48..01968ea579 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -775,6 +775,8 @@ uint32 CODECADPCMSTEREO::Decompress(Common::File &fp, void *buf, uint32 dwSize) FPSOUND::FPSOUND() { lpDS = NULL; lpDSBPrimary = NULL; + hwnd = 0; + bSoundSupported = false; } @@ -1028,6 +1030,19 @@ FPSFX::FPSFX(LPDIRECTSOUND lpds, HWND hWnd, bool bSoundOn) { return; /* Poich non abbiamo ancora nessun dato sull'effetto sonoro, non possiamo fare nulla */ +#else + bIsVoice = false; + lastVolume = 0; + dwFreq = 0; + hEndOfBuffer = CORO_INVALID_PID_VALUE; + bFileLoaded = false; + bSoundSupported = false; + bLoop = false; + bPaused = false; + bStereo = false; + b16bit = false; + bIsPlaying = false; + bIsVoice = false; #endif } -- cgit v1.2.3 From 60deca7f54f395974c58683c9e8ce0a079a90ebf Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 13 May 2012 09:58:07 +1000 Subject: TONY: Fix some more uninitialised field values --- engines/tony/gfxengine.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'engines') diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index f6d047d267..2c8543326f 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -101,6 +101,10 @@ RMGfxEngine::RMGfxEngine() { m_bGUIOption = false; m_bGUIInterface = false; m_bGUIInventory = false; + m_bAlwaysDrawMouse = false; + m_bOption = false; + m_bLocationLoaded = false; + m_bInput = false; } RMGfxEngine::~RMGfxEngine() { -- cgit v1.2.3 From 7978eb007c5b03b8eb3148883245cba395e3efd3 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 13 May 2012 10:11:01 +1000 Subject: TONY: Fixed initialisation of missed RMCharacter fields --- engines/tony/loc.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'engines') diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index d805e9ee82..4f61582578 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -1760,6 +1760,11 @@ RMCharacter::RMCharacter() { pathlenght = pathcount = 0; status = STAND; theBoxes = NULL; + walkcount = 0; + bEndOfPath = false; + bMovingWithoutMinpath = false; + bDrawNow = false; + bNeedToStop = false; m_pos.Set(0, 0); } -- cgit v1.2.3 From 81e5a19d58274c2845587500db25c94502eb99a3 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 13 May 2012 10:42:03 +1000 Subject: TONY: Fix memory leak in displaying hotspot texts --- engines/tony/font.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'engines') diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 2f8c0c5065..f7f3fb3f8c 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -2272,11 +2272,12 @@ RMTextItemName::~RMTextItemName() { void RMTextItemName::DoFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation &loc, RMPointer &ptr, RMInventory &inv) { CORO_BEGIN_CONTEXT; - RMString itemName; RMItem *lastItem; uint32 hThread; CORO_END_CONTEXT(_ctx); + RMString itemName; + CORO_BEGIN_CODE(_ctx); _ctx->lastItem = m_item; @@ -2294,14 +2295,14 @@ void RMTextItemName::DoFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation & else m_item = loc.WhichItemIsIn(m_mpos); - _ctx->itemName = ""; + itemName = ""; // If there an item, get it's name if (m_item != NULL) - m_item->GetName(_ctx->itemName); + m_item->GetName(itemName); // Write it - WriteText(_ctx->itemName, 1); + WriteText(itemName, 1); // Handle the change If the selected item is different from the previous one if (_ctx->lastItem != m_item) { -- cgit v1.2.3 From 089d7048b60b8ac880b47a0835b5c2890d8d4423 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 13 May 2012 15:50:15 +1000 Subject: TONY: Bugfix for crash when removing item from inventory --- engines/tony/gfxengine.cpp | 2 +- engines/tony/inventory.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 2c8543326f..8f7d27dafc 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -341,7 +341,7 @@ SKIPCLICKSINISTRO: // ********************** // Disegna la lista di OT // ********************** - m_bigBuf.DrawOT(Common::nullContext); + CORO_INVOKE_0(m_bigBuf.DrawOT); #define FSTEP (480/32) diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index b4eef0ac0d..468ec225a5 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -266,11 +266,11 @@ void RMInventory::RemoveThis(CORO_PARAM, bool &result) { void RMInventory::RemoveItem(int code) { int i; - for (i=0;ilockMutex(m_csModifyInterface); - Common::copy_backward(&m_inv[i + 1], &m_inv[i + 1] + (m_nInv - i), &m_inv[i]); + Common::copy(&m_inv[i + 1], &m_inv[i + 1] + (m_nInv - i), &m_inv[i]); // m_inv[m_nInv-1]=0; m_nInv--; -- cgit v1.2.3 From 8466314735761e3b71adfcc34471db539c14bad2 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 13 May 2012 19:02:47 +1000 Subject: TONY: Disabled target buffer mutex which isn't needed anymore --- engines/tony/gfxcore.cpp | 16 ++++++++-------- engines/tony/gfxcore.h | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'engines') diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 6f24941545..49dd36cfe7 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -295,18 +295,18 @@ RMGfxClearTask RMGfxTargetBuffer::taskClear; RMGfxTargetBuffer::RMGfxTargetBuffer() { otlist = NULL; m_otSize = 0; - csModifyingOT = g_system->createMutex(); +// csModifyingOT = g_system->createMutex(); } RMGfxTargetBuffer::~RMGfxTargetBuffer() { ClearOT(); - g_system->deleteMutex(csModifyingOT); +// g_system->deleteMutex(csModifyingOT); } void RMGfxTargetBuffer::ClearOT(void) { OTList *cur, *n; - g_system->lockMutex(csModifyingOT); +// g_system->lockMutex(csModifyingOT); cur = otlist; @@ -320,7 +320,7 @@ void RMGfxTargetBuffer::ClearOT(void) { otlist = NULL; - g_system->unlockMutex(csModifyingOT); +// g_system->unlockMutex(csModifyingOT); } void RMGfxTargetBuffer::DrawOT(CORO_PARAM) { @@ -339,7 +339,7 @@ void RMGfxTargetBuffer::DrawOT(CORO_PARAM) { // Lock del buffer per accederci Lock(); - g_system->lockMutex(csModifyingOT); +// g_system->lockMutex(csModifyingOT); while (_ctx->cur != NULL) { // Richiama la draw sul task, passandogli una copia della primitiva @@ -373,7 +373,7 @@ void RMGfxTargetBuffer::DrawOT(CORO_PARAM) { } } - g_system->unlockMutex(csModifyingOT); +// g_system->unlockMutex(csModifyingOT); // Unlock dopo la scrittura Unlock(); @@ -385,7 +385,7 @@ void RMGfxTargetBuffer::AddPrim(RMGfxPrimitive *prim) { int nPrior; OTList *cur, *n; - g_system->lockMutex(csModifyingOT); +// g_system->lockMutex(csModifyingOT); // Avverte che e' in lista di OT prim->m_task->Register(); @@ -412,7 +412,7 @@ void RMGfxTargetBuffer::AddPrim(RMGfxPrimitive *prim) { cur->next = n; } - g_system->unlockMutex(csModifyingOT); +// g_system->unlockMutex(csModifyingOT); } void RMGfxTargetBuffer::AddClearTask(void) { diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index 289c3e9564..23f1a9809a 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -509,7 +509,7 @@ static RMGfxClearTask taskClear; }; private: - OSystem::MutexRef csModifyingOT; +// OSystem::MutexRef csModifyingOT; protected: OTList *otlist; -- cgit v1.2.3 From 35143eae094b713524ef677412befdc4c766df04 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 13 May 2012 19:06:08 +1000 Subject: TONY: Converted SendTonyMessage msg field from a pointer back to an object instance --- engines/tony/custom.cpp | 19 +++++++------------ engines/tony/loc.cpp | 18 +++++++++++++----- engines/tony/loc.h | 2 ++ 3 files changed, 22 insertions(+), 17 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index b1b660c423..bda65fcf67 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -379,7 +379,7 @@ VoiceHeader *SearchVoiceHeader(uint32 codehi, uint32 codelo) { DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX, uint32 nY, uint32) { CORO_BEGIN_CONTEXT; - RMMessage *msg; + RMMessage msg; int i; int curOffset; VoiceHeader *curVoc; @@ -393,9 +393,8 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX if (bSkipIdle) return; - _ctx->msg = new RMMessage(dwMessage); - if (!_ctx->msg->IsValid()) { - delete _ctx->msg; + _ctx->msg.Load(dwMessage); + if (!_ctx->msg.IsValid()) { return; } @@ -424,7 +423,7 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX if (!bStaticTalk) nTonyNextTalkType = Tony->TALK_NORMAL; } else { - if (_ctx->msg->NumPeriods() > 1) + if (_ctx->msg.NumPeriods() > 1) CORO_INVOKE_1(Tony->StartTalk, Tony->TALK_FIANCHI); else CORO_INVOKE_1(Tony->StartTalk, Tony->TALK_NORMAL); @@ -435,17 +434,17 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX bTonyIsSpeaking = true; - for (_ctx->i = 0; _ctx->i < _ctx->msg->NumPeriods() && !bSkipIdle; _ctx->i++) { + for (_ctx->i = 0; _ctx->i < _ctx->msg.NumPeriods() && !bSkipIdle; _ctx->i++) { _ctx->text.SetInput(Input); // Allineamento - _ctx->text.SetAlignType(RMText::HCENTER,RMText::VBOTTOM); + _ctx->text.SetAlignType(RMText::HCENTER, RMText::VBOTTOM); // Colore _ctx->text.SetColor(0,255,0); // Scrive il testo - _ctx->text.WriteText((*_ctx->msg)[_ctx->i],0); + _ctx->text.WriteText(_ctx->msg[_ctx->i], 0); // Setta la posizione if (nX == 0 && nY == 0) @@ -494,7 +493,6 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX curBackText->Show(); CORO_INVOKE_0(Tony->EndTalk); - delete _ctx->msg; CORO_END_CODE; } @@ -2207,9 +2205,6 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr } - - - /* * Sync tra idle e mpal */ diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 4f61582578..32754bbb51 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -2425,11 +2425,11 @@ void RMLocation::PauseSound(bool bPause) { \****************************************************************************/ RMMessage::RMMessage(uint32 dwId) { - lpMessage=mpalQueryMessage(dwId); - assert(lpMessage != NULL); - - if (lpMessage) - ParseMessage(); + Load(dwId); +} + +RMMessage::RMMessage() { + lpMessage = NULL; } RMMessage::~RMMessage() { @@ -2437,6 +2437,14 @@ RMMessage::~RMMessage() { GlobalFree(lpMessage); } +void RMMessage::Load(uint32 dwId) { + lpMessage = mpalQueryMessage(dwId); + assert(lpMessage != NULL); + + if (lpMessage) + ParseMessage(); +} + void RMMessage::ParseMessage(void) { char *p; diff --git a/engines/tony/loc.h b/engines/tony/loc.h index d81ecb45d5..bbb98bd9db 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -598,9 +598,11 @@ private: void ParseMessage(void); public: + RMMessage(); RMMessage(uint32 dwId); virtual ~RMMessage(); + void Load(uint32 dwId); bool IsValid() { return lpMessage != NULL; } int NumPeriods() { return nPeriods; } char *Period(int num) { return lpPeriods[num]; } -- cgit v1.2.3 From 546f47ddcee07b5bd7ecad5f25f4bb022944e234 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 13 May 2012 22:34:40 +1000 Subject: TONY: Beginnings of refactoring Globals into their own class --- engines/tony/custom.cpp | 1476 ++++++++++++++++++++------------------------ engines/tony/font.cpp | 12 +- engines/tony/game.cpp | 106 ++-- engines/tony/game.h | 20 - engines/tony/gfxcore.cpp | 7 +- engines/tony/gfxengine.cpp | 98 ++- engines/tony/globals.cpp | 93 +++ engines/tony/globals.h | 232 +++++++ engines/tony/inventory.cpp | 30 +- engines/tony/loc.cpp | 4 +- engines/tony/module.mk | 1 + engines/tony/sound.cpp | 19 +- engines/tony/tony.cpp | 61 +- engines/tony/tony.h | 6 + engines/tony/tonychar.cpp | 2 +- 15 files changed, 1130 insertions(+), 1037 deletions(-) create mode 100644 engines/tony/globals.cpp create mode 100644 engines/tony/globals.h (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index bda65fcf67..168c2d38cd 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -62,54 +62,6 @@ namespace Tony { -extern bool bPatIrqFreeze; - -RMTony *Tony; -RMPointer *Pointer; -RMGameBoxes *Boxes; -RMLocation *Loc; -RMInventory *Inventory; -RMInput *Input; - -uint32 (*LoadLocation)(int, RMPoint, RMPoint start); -void (*UnloadLocation)(CORO_PARAM, bool bDoOnExit, uint32 *result); -void (*LinkGraphicTask)(RMGfxTask *task); -void (*Freeze)(void); -void (*Unfreeze)(void); -void (*WaitFrame)(CORO_PARAM); -void (*PlayMusic)(int nChannel, const char *fileName, int nFX, bool bLoop, int nSync); -void (*WaitWipeEnd)(CORO_PARAM); -void (*CloseWipe)(void); -void (*InitWipe)(int type); -void (*EnableGUI)(void); -void (*DisableGUI)(void); -void (*SetPalesati)(bool bpal); - -uint32 dwTonyNumTexts = 0; -bool bTonyInTexts = false; -bool bStaticTalk = false; -RMTony::TALKTYPE nTonyNextTalkType; - -RMPoint StartLocPos[256]; -OSystem::MutexRef cs[10]; -OSystem::MutexRef vdb; -HANDLE mut[10]; - -bool bSkipIdle = false; -uint32 hSkipIdle; - -int lastMusic = 0, lastTappeto = 0; - -int tappeti[200]; - -#define T_GRILLI 1 -#define T_GRILLIOV 2 -#define T_GRILLIVENTO 3 -#define T_GRILLIVENTO1 4 -#define T_VENTO 5 -#define T_MARE 6 -#define T_MAREMETA 7 - const char *tappetiFile[] = { "None", "1.ADP", // Grilli.WAV @@ -121,140 +73,139 @@ const char *tappetiFile[] = { "6.ADP" // Mare1.WAV met volume }; -struct CharacterStruct { - uint32 code; - RMItem *item; - byte r, g, b; - int talkpattern; - int standpattern; - int starttalkpattern, endtalkpattern; - int numtexts; - - void Save(Common::OutSaveFile *f) { - f->writeUint32LE(code); - f->writeUint32LE(0); - f->writeByte(r); - f->writeByte(g); - f->writeByte(b); - f->writeUint32LE(talkpattern); - f->writeUint32LE(standpattern); - f->writeUint32LE(starttalkpattern); - f->writeUint32LE(endtalkpattern); - f->writeUint32LE(numtexts); - } - void Load(Common::InSaveFile *f) { - code = f->readUint32LE(); - f->readUint32LE(); - item = NULL; - r = f->readByte(); - g = f->readByte(); - b = f->readByte(); - talkpattern = f->readUint32LE(); - standpattern = f->readUint32LE(); - starttalkpattern = f->readUint32LE(); - endtalkpattern = f->readUint32LE(); - numtexts = f->readUint32LE(); - } -}; -CharacterStruct Character[16]; - -struct MCharacterStruct { - uint32 code; - RMItem *item; - byte r, g, b; - int x, y; - int numtalks[10]; - int curgroup; - int numtexts; - bool bInTexts; - int curTalk; - bool bAlwaysBack; - - void Save(Common::OutSaveFile *f) { - f->writeUint32LE(code); - f->writeUint32LE(0); - f->writeByte(r); - f->writeByte(g); - f->writeByte(b); - f->writeUint32LE(x); - f->writeUint32LE(y); - for (int i = 0; i < 10; ++i) - f->writeUint32LE(numtalks[i]); - f->writeUint32LE(curgroup); - f->writeUint32LE(numtexts); - f->writeByte(bInTexts); - f->writeUint32LE(curTalk); - f->writeByte(bAlwaysBack); - } - void Load(Common::InSaveFile *f) { - code = f->readUint32LE(); - f->readUint32LE(); - item = NULL; - r = f->readByte(); - g = f->readByte(); - b = f->readByte(); - x = f->readUint32LE(); - y = f->readUint32LE(); - for (int i = 0; i < 10; ++i) - numtalks[i] = f->readUint32LE(); - curgroup = f->readUint32LE(); - numtexts = f->readUint32LE(); - bInTexts = f->readByte(); - curTalk = f->readUint32LE(); - bAlwaysBack = f->readByte(); - } +struct MusicFileEntry { + const char *name; + int sync; }; -MCharacterStruct MCharacter[10]; +const MusicFileEntry musicFiles[] = { +/* + { "PREGAME1.ADP", 0 }, { "SONO1.ADP", 0 }, + { "SONO2.ADP", 0 }, { "SONO3.ADP", 0 }, + { "CADUTA.ADP",0 }, { "RISVEGLIO.ADP", 0 }, + { "BACKGROUND.ADP", 0 }, { "PREGAME3.ADP", 0 }, + { "BARBUTA1.ADP", 2450 }, { "BARBUTA2.ADP", 0 }, +*/ + { "00.ADP", 0 }, { "01.ADP", 0 }, + { "02.ADP", 0 }, { "03.ADP", 0 }, + { "04.ADP",0 }, { "05.ADP", 0 }, + { "06.ADP", 0 }, { "07.ADP", 0 }, + { "08.ADP", 2450 }, { "09.ADP", 0 }, -bool IsMChar[16]; +/* + { "BARBUTA3.ADP", 0 }, { "15-RUFUS.ADP", 0 }, + { "20-MAMMA.ADP", 0 }, { "32-MAMMARADIO.ADP", 0 }, + { "24-TUNNELOV-MIDI.ADP", 0 }, { "34-RAZZO.ADP", 0 }, + { "27-ZUCC1.ADP", 0 }, { "BEAST.ADP", 0 }, + { "22-MORTIMER.ADP", 0 }, { "25-PUB-OVATTATO.ADP", 0 }, +*/ + { "10.ADP", 0 }, { "11.ADP", 0 }, + { "12.ADP", 0 }, { "13.ADP", 0 }, + { "14.ADP", 0 }, { "15.ADP", 0 }, + { "16.ADP", 0 }, { "17.ADP", 0 }, + { "18.ADP", 0 }, { "19.ADP", 0 }, +/* + { "25-PUB.ADP", 0 }, { "ALBERGO.ADP", 0 }, + { "37.ADP", 0 }, { "26-PIRAT.ADP", 0 }, + { "LORENZBACK.ADP", 0 }, { "LORENZ3.ADP", 0 }, + { "CASTLE.ADP", 0 }, { "53-BACKR.ADP", 0 }, + { "16-SMIL1.ADP", 1670 }, { "16-SMIL2.ADP", 0 }, +*/ + { "20.ADP", 0 }, { "21.ADP", 0 }, + { "22.ADP", 0 }, { "23.ADP", 0 }, + { "24.ADP", 0 }, { "25.ADP", 0 }, + { "26.ADP", 0 }, { "27.ADP", 0 }, + { "28.ADP", 1670 }, { "29.ADP", 0 }, +/* + { "16-SMILE.ADP", 0 }, { "16-DIALOG2.ADP", 0 }, + { "07-SHAKE1.ADP", 2900 }, { "07-SHAKE2.ADP", 0 }, + { "07-SHAKE3.ADP", 0 }, { "46-BEEE.ADP", 0 }, + { "434748.ADP", 0 }, { "TORRE.ADP", 0 }, + { "50-DRAGO.ADP", 0 }, { "56-OPERA.ADP", 0 }, +*/ + { "30.ADP", 0 }, { "31.ADP", 0 }, + { "32.ADP", 2900 }, { "33.ADP", 0 }, + { "34.ADP", 0 }, { "35.ADP", 0 }, + { "36.ADP", 0 }, { "37.ADP", 0 }, + { "38.ADP", 0 }, { "39.ADP", 0 }, +/* + { "FLAUTARP.ADP", 0 }, { "01-2001.ADP", 1920 }, + { "02-INTROPANORAMICA.ADP", 1560 }, { "03-PANORAMICA.ADP", 1920 }, + { "04-INTERNI.ADP", 1920 }, { "05-CADEPIUMA.ADP", 1920 }, + { "06-SCENDESCALE.ADP", 1920 }, { "07-THRILL.ADP", 1920 }, + { "08-CADUTAZUCCA.ADP", 1920 }, { "09-PIUMAALEGGIA.ADP", 1920 }, +*/ + { "40.ADP", 0 }, { "41.ADP", 1920 }, + { "42.ADP", 1560 }, { "43.ADP", 1920 }, + { "44.ADP", 1920 }, { "45.ADP", 1920 }, + { "46.ADP", 1920 }, { "47.ADP", 1920 }, + { "48.ADP", 1920 }, { "49.ADP", 1920 }, -bool bAlwaysDisplay; +/* + { "10-JACKZUCCONA.ADP", 1920 }, { "11-JACKIMPRECAALLAGRANDELUNA.ADP", 1920 }, + { "12-GRANDELUNALOGO.ADP", 1920 }, { "60-BACKGROUND.ADP", 0 }, + { "TONYSTAR.ADP", 0 }, { "FUNNY.ADP", 0 }, + { "60-INIZIODIALOGO.ADP", 0 }, { "60-DIALOGO.ADP", 0 }, + { "60-JACKFELICE.ADP", 0 }, { "24-TONYVIOLENTATO.ADP", 0 } +*/ -RMPoint saveTonyPos; -int saveTonyLoc; + { "50.ADP", 1920 }, { "51.ADP", 1920 }, + { "52.ADP", 1920 }, { "53.ADP", 0 }, + { "54.ADP", 0 }, { "55.ADP", 0 }, + { "56.ADP", 0 }, { "57.ADP", 0 }, + { "58.ADP", 0 }, { "59.ADP", 0 } -RMTextDialog *curBackText = NULL; -bool bTonyIsSpeaking = false; +}; -int curChangedHotspot = 0; -struct ChangedHotspotStruct { - uint32 dwCode; - uint32 nX, nY; +const char *staccFileNames[] = { +/* + "05-MUCCA.ADP", "06-HALOW.ADP", + "LETTERAINIZIO.ADP", "LETTERAPAURA.ADP", + "LETTERAFINE.ADP", "PREGAME2.ADP", + "07-TIMOT.ADP", "15-SHOTRUFUS.ADP", + "15-SHOTTONY.ADP", "27-ZUCC2.ADP", +*/ + "S00.ADP", "S01.ADP", + "S02.ADP", "S03.ADP", + "S04.ADP", "S05.ADP", + "S06.ADP", "S07.ADP", + "S08.ADP", "S09.ADP", - void Save(Common::OutSaveFile *f) { - f->writeUint32LE(dwCode); - f->writeUint32LE(nX); - f->writeUint32LE(nY); - } - void Load(Common::InSaveFile *f) { - dwCode = f->readUint32LE(); - nX = f->readUint32LE(); - nY = f->readUint32LE(); - } +/* + "53-DLOGO.ADP", "16-DIALOG1.ADP", + "TORRE1.ADP", "GARG1.ADP", + "LORENZ1.ADP", "24-FIGHT.ADP", + "08-MACBETH-PREPARA.ADP", "08-MACBETH-RECITA.ADP", + "GATTO1.ADP" +*/ + "S10.ADP", "S11.ADP", + "S12.ADP", "S13.ADP", + "S14.ADP", "S15.ADP", + "S16.ADP", "S17.ADP", + "S18.ADP" }; -ChangedHotspotStruct ChangedHotspot[256]; + void ReapplyChangedHotspot(void) { int i; - for (i = 0; iGetItemFromCode(ChangedHotspot[i].dwCode)->ChangeHotspot(RMPoint(ChangedHotspot[i].nX, ChangedHotspot[i].nY)); + for (i = 0; i < GLOBALS.curChangedHotspot; i++) + GLOBALS.Loc->GetItemFromCode(GLOBALS.ChangedHotspot[i].dwCode)->ChangeHotspot(RMPoint(GLOBALS.ChangedHotspot[i].nX, GLOBALS.ChangedHotspot[i].nY)); } void SaveChangedHotspot(Common::OutSaveFile *f) { - f->writeByte(curChangedHotspot); - if (curChangedHotspot > 0) { - for (int i = 0; i < curChangedHotspot; ++i) - ChangedHotspot[i].Save(f); + f->writeByte(GLOBALS.curChangedHotspot); + if (GLOBALS.curChangedHotspot > 0) { + for (int i = 0; i < GLOBALS.curChangedHotspot; ++i) + GLOBALS.ChangedHotspot[i].Save(f); } } void LoadChangedHotspot(Common::InSaveFile *f) { - curChangedHotspot = f->readByte(); + GLOBALS.curChangedHotspot = f->readByte(); - if (curChangedHotspot > 0) { - for (int i = 0; i < curChangedHotspot; ++i) - ChangedHotspot[i].Load(f); + if (GLOBALS.curChangedHotspot > 0) { + for (int i = 0; i < GLOBALS.curChangedHotspot; ++i) + GLOBALS.ChangedHotspot[i].Load(f); } } @@ -271,51 +222,51 @@ void LoadChangedHotspot(Common::InSaveFile *f) { void MCharResetCodes(void) { for (int i = 0; i < 10; i++) - MCharacter[i].item = Loc->GetItemFromCode(MCharacter[i].code); + GLOBALS.MCharacter[i].item = GLOBALS.Loc->GetItemFromCode(GLOBALS.MCharacter[i].code); for (int i = 0; i < 10; i++) - Character[i].item = Loc->GetItemFromCode(Character[i].code); + GLOBALS.Character[i].item = GLOBALS.Loc->GetItemFromCode(GLOBALS.Character[i].code); } void CharsSaveAll(Common::OutSaveFile *f) { for (int i = 0; i < 10; i++) { - f->writeByte(IsMChar[i]); - if (IsMChar[i]) { - MCharacter[i].Save(f); + f->writeByte(GLOBALS.IsMChar[i]); + if (GLOBALS.IsMChar[i]) { + GLOBALS.MCharacter[i].Save(f); } else { - Character[i].Save(f); + GLOBALS.Character[i].Save(f); } } } void CharsLoadAll(Common::InSaveFile *f) { for (int i = 0; i < 10; i++) { - IsMChar[i] = f->readByte(); - if (IsMChar[i]) - MCharacter[i].Load(f); + GLOBALS.IsMChar[i] = f->readByte(); + if (GLOBALS.IsMChar[i]) + GLOBALS.MCharacter[i].Load(f); else - Character[i].Load(f); + GLOBALS.Character[i].Load(f); } } DECLARE_CUSTOM_FUNCTION(FaceToMe)(CORO_PARAM, uint32, uint32, uint32, uint32) { - Tony->SetPattern(Tony->PAT_STANDDOWN); + GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_STANDDOWN); } DECLARE_CUSTOM_FUNCTION(BackToMe)(CORO_PARAM, uint32, uint32, uint32, uint32) { - Tony->SetPattern(Tony->PAT_STANDUP); + GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_STANDUP); } DECLARE_CUSTOM_FUNCTION(LeftToMe)(CORO_PARAM, uint32, uint32, uint32, uint32) { - Tony->SetPattern(Tony->PAT_STANDLEFT); + GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_STANDLEFT); } DECLARE_CUSTOM_FUNCTION(RightToMe)(CORO_PARAM, uint32, uint32, uint32, uint32) { - Tony->SetPattern(Tony->PAT_STANDRIGHT); + GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_STANDRIGHT); } DECLARE_CUSTOM_FUNCTION(TonySetPalesati)(CORO_PARAM, uint32 bStatus, uint32, uint32, uint32) { - SetPalesati(bStatus); + GLOBALS.SetPalesati(bStatus); } DECLARE_CUSTOM_FUNCTION(MySleep)(CORO_PARAM, uint32 dwTime, uint32, uint32, uint32) { @@ -325,37 +276,37 @@ DECLARE_CUSTOM_FUNCTION(MySleep)(CORO_PARAM, uint32 dwTime, uint32, uint32, uint CORO_BEGIN_CODE(_ctx); - if (!bSkipIdle) + if (!GLOBALS.bSkipIdle) CORO_INVOKE_1(CoroScheduler.sleep, dwTime); CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(SetAlwaysDisplay)(CORO_PARAM, uint32 val, uint32, uint32, uint32) { - bAlwaysDisplay = (val != 0); + GLOBALS.bAlwaysDisplay = (val != 0); } DECLARE_CUSTOM_FUNCTION(SetPointer)(CORO_PARAM, uint32 dwPointer, uint32, uint32, uint32) { switch (dwPointer) { case 1: - Pointer->SetSpecialPointer(Pointer->PTR_FRECCIASU); + GLOBALS.Pointer->SetSpecialPointer(GLOBALS.Pointer->PTR_FRECCIASU); break; case 2: - Pointer->SetSpecialPointer(Pointer->PTR_FRECCIAGIU); + GLOBALS.Pointer->SetSpecialPointer(GLOBALS.Pointer->PTR_FRECCIAGIU); break; case 3: - Pointer->SetSpecialPointer(Pointer->PTR_FRECCIASINISTRA); + GLOBALS.Pointer->SetSpecialPointer(GLOBALS.Pointer->PTR_FRECCIASINISTRA); break; case 4: - Pointer->SetSpecialPointer(Pointer->PTR_FRECCIADESTRA); + GLOBALS.Pointer->SetSpecialPointer(GLOBALS.Pointer->PTR_FRECCIADESTRA); break; case 5: - Pointer->SetSpecialPointer(Pointer->PTR_FRECCIAMAPPA); + GLOBALS.Pointer->SetSpecialPointer(GLOBALS.Pointer->PTR_FRECCIAMAPPA); break; default: - Pointer->SetSpecialPointer(Pointer->PTR_NONE); + GLOBALS.Pointer->SetSpecialPointer(GLOBALS.Pointer->PTR_NONE); break; } } @@ -391,7 +342,7 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX _ctx->curOffset = 0; - if (bSkipIdle) return; + if (GLOBALS.bSkipIdle) return; _ctx->msg.Load(dwMessage); if (!_ctx->msg.IsValid()) { @@ -405,7 +356,7 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX _ctx->curOffset = _ctx->curVoc->offset; // PRIMA VOLTA PREALLOCA - g_system->lockMutex(vdb); + g_system->lockMutex(GLOBALS.vdb); //fseek(_vm->m_vdbFP, _ctx->curOffset, SEEK_SET); _vm->_vdbFP.seek(_ctx->curOffset); _vm->_theSound.CreateSfx(&_ctx->voice); @@ -414,28 +365,28 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX _ctx->curOffset = _vm->_vdbFP.pos(); _ctx->voice->SetLoop(false); - g_system->unlockMutex(vdb); + g_system->unlockMutex(GLOBALS.vdb); } - if (nTonyNextTalkType != Tony->TALK_NORMAL) { - CORO_INVOKE_1(Tony->StartTalk, nTonyNextTalkType); + if (GLOBALS.nTonyNextTalkType != GLOBALS.Tony->TALK_NORMAL) { + CORO_INVOKE_1(GLOBALS.Tony->StartTalk, GLOBALS.nTonyNextTalkType); - if (!bStaticTalk) - nTonyNextTalkType = Tony->TALK_NORMAL; + if (!GLOBALS.bStaticTalk) + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; } else { if (_ctx->msg.NumPeriods() > 1) - CORO_INVOKE_1(Tony->StartTalk, Tony->TALK_FIANCHI); + CORO_INVOKE_1(GLOBALS.Tony->StartTalk, GLOBALS.Tony->TALK_FIANCHI); else - CORO_INVOKE_1(Tony->StartTalk, Tony->TALK_NORMAL); + CORO_INVOKE_1(GLOBALS.Tony->StartTalk, GLOBALS.Tony->TALK_NORMAL); } - if (curBackText) - CORO_INVOKE_0(curBackText->Hide); + if (GLOBALS.curBackText) + CORO_INVOKE_0(GLOBALS.curBackText->Hide); - bTonyIsSpeaking = true; + GLOBALS.bTonyIsSpeaking = true; - for (_ctx->i = 0; _ctx->i < _ctx->msg.NumPeriods() && !bSkipIdle; _ctx->i++) { - _ctx->text.SetInput(Input); + for (_ctx->i = 0; _ctx->i < _ctx->msg.NumPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { + _ctx->text.SetInput(GLOBALS.Input); // Allineamento _ctx->text.SetAlignType(RMText::HCENTER, RMText::VBOTTOM); @@ -448,22 +399,22 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX // Setta la posizione if (nX == 0 && nY == 0) - _ctx->text.SetPosition(Tony->Position() - RMPoint(0, 130) - Loc->ScrollPosition()); + _ctx->text.SetPosition(GLOBALS.Tony->Position() - RMPoint(0, 130) - GLOBALS.Loc->ScrollPosition()); else - _ctx->text.SetPosition(RMPoint(nX, nY) - Loc->ScrollPosition()); + _ctx->text.SetPosition(RMPoint(nX, nY) - GLOBALS.Loc->ScrollPosition()); // Setta l'always display - if (bAlwaysDisplay) { _ctx->text.SetAlwaysDisplay(); _ctx->text.ForceTime(); } + if (GLOBALS.bAlwaysDisplay) { _ctx->text.SetAlwaysDisplay(); _ctx->text.ForceTime(); } // Registra il testo - LinkGraphicTask(&_ctx->text); + GLOBALS.LinkGraphicTask(&_ctx->text); if (_ctx->curVoc) { if (_ctx->i == 0) { _ctx->voice->Play(); _ctx->text.SetCustomSkipHandle2(_ctx->voice->hEndOfBuffer); } else { - g_system->lockMutex(vdb); + g_system->lockMutex(GLOBALS.vdb); // fseek(_vm->m_vdbFP, _ctx->curOffset, SEEK_SET); _vm->_vdbFP.seek(_ctx->curOffset); _vm->_theSound.CreateSfx(&_ctx->voice); @@ -473,12 +424,12 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX _ctx->voice->SetLoop(false); _ctx->voice->Play(); _ctx->text.SetCustomSkipHandle2(_ctx->voice->hEndOfBuffer); - g_system->unlockMutex(vdb); + g_system->unlockMutex(GLOBALS.vdb); } } // Aspetta la fine della visualizzazione - _ctx->text.SetCustomSkipHandle(hSkipIdle); + _ctx->text.SetCustomSkipHandle(GLOBALS.hSkipIdle); CORO_INVOKE_0(_ctx->text.WaitForEndDisplay); if (_ctx->curVoc) { @@ -488,17 +439,17 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX } } - bTonyIsSpeaking = false; - if (curBackText) - curBackText->Show(); + GLOBALS.bTonyIsSpeaking = false; + if (GLOBALS.curBackText) + GLOBALS.curBackText->Show(); - CORO_INVOKE_0(Tony->EndTalk); + CORO_INVOKE_0(GLOBALS.Tony->EndTalk); CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(ChangeBoxStatus)(CORO_PARAM, uint32 nLoc, uint32 nBox, uint32 nStatus, uint32) { - Boxes->ChangeBoxStatus(nLoc,nBox,nStatus); + GLOBALS.Boxes->ChangeBoxStatus(nLoc, nBox, nStatus); } @@ -509,15 +460,15 @@ DECLARE_CUSTOM_FUNCTION(CustLoadLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, ui CORO_BEGIN_CODE(_ctx); - Freeze(); + GLOBALS.Freeze(); - curChangedHotspot = 0; + GLOBALS.curChangedHotspot = 0; if (bUseStartPos != 0) - LoadLocation(nLoc, RMPoint(tX, tY), StartLocPos[nLoc]); + GLOBALS.LoadLocation(nLoc, RMPoint(tX, tY), GLOBALS.StartLocPos[nLoc]); else - LoadLocation(nLoc, RMPoint(tX, tY), RMPoint(-1, -1)); + GLOBALS.LoadLocation(nLoc, RMPoint(tX, tY), RMPoint(-1, -1)); - Unfreeze(); + GLOBALS.Unfreeze(); _ctx->h = mpalQueryDoAction(0, nLoc, 0); // On Enter? @@ -528,9 +479,6 @@ DECLARE_CUSTOM_FUNCTION(CustLoadLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, ui } -RMPoint SFM_pt; -int SFM_nLoc; - DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgStart)(CORO_PARAM, uint32 nMsg, uint32 nFont, uint32, uint32) { CORO_BEGIN_CONTEXT; RMMessage *msg; @@ -543,18 +491,18 @@ DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgStart)(CORO_PARAM, uint32 nMsg, uint32 _ctx->msg = new RMMessage(nMsg); - SFM_nLoc = Loc->TEMPGetNumLoc(); - SFM_pt = Tony->Position(); + GLOBALS.SFM_nLoc = GLOBALS.Loc->TEMPGetNumLoc(); + GLOBALS.SFM_pt = GLOBALS.Tony->Position(); - if (bSkipIdle) + if (GLOBALS.bSkipIdle) return; - CORO_INVOKE_2(UnloadLocation, false, NULL); - Tony->Hide(); - Unfreeze(); + CORO_INVOKE_2(GLOBALS.UnloadLocation, false, NULL); + GLOBALS.Tony->Hide(); + GLOBALS.Unfreeze(); - for (_ctx->i = 0; _ctx->i < _ctx->msg->NumPeriods() && !bSkipIdle; _ctx->i++) { - _ctx->text.SetInput(Input); + for (_ctx->i = 0; _ctx->i < _ctx->msg->NumPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { + _ctx->text.SetInput(GLOBALS.Input); // Allineamento _ctx->text.SetAlignType(RMText::HCENTER,RMText::VCENTER); @@ -578,11 +526,11 @@ DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgStart)(CORO_PARAM, uint32 nMsg, uint32 _ctx->text.ForceTime(); // Registra il testo - LinkGraphicTask(&_ctx->clear); - LinkGraphicTask(&_ctx->text); + GLOBALS.LinkGraphicTask(&_ctx->clear); + GLOBALS.LinkGraphicTask(&_ctx->text); // Aspetta la fine della visualizzazione - _ctx->text.SetCustomSkipHandle(hSkipIdle); + _ctx->text.SetCustomSkipHandle(GLOBALS.hSkipIdle); CORO_INVOKE_0(_ctx->text.WaitForEndDisplay); } @@ -599,19 +547,19 @@ DECLARE_CUSTOM_FUNCTION(ClearScreen)(CORO_PARAM, uint32, uint32, uint32, uint32) CORO_BEGIN_CODE(_ctx); - LinkGraphicTask(&_ctx->clear); + GLOBALS.LinkGraphicTask(&_ctx->clear); - CORO_INVOKE_0(WaitFrame); + CORO_INVOKE_0(GLOBALS.WaitFrame); CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgEnd)(CORO_PARAM, uint32 bNotEnableTony, uint32, uint32, uint32) { - Freeze(); - LoadLocation(SFM_nLoc,RMPoint(SFM_pt.x,SFM_pt.y),RMPoint(-1,-1)); + GLOBALS.Freeze(); + GLOBALS.LoadLocation(GLOBALS.SFM_nLoc,RMPoint(GLOBALS.SFM_pt.x,GLOBALS.SFM_pt.y),RMPoint(-1,-1)); if (!bNotEnableTony) - Tony->Show(); - Unfreeze(); + GLOBALS.Tony->Show(); + GLOBALS.Unfreeze(); MCharResetCodes(); ReapplyChangedHotspot(); @@ -630,10 +578,8 @@ DECLARE_CUSTOM_FUNCTION(SendFullscreenMessage)(CORO_PARAM, uint32 nMsg, uint32 n CORO_END_CODE; } -bool bNoOcchioDiBue = false; - DECLARE_CUSTOM_FUNCTION(NoOcchioDiBue)(CORO_PARAM, uint32, uint32, uint32, uint32) { - bNoOcchioDiBue = true; + GLOBALS.bNoOcchioDiBue = true; } DECLARE_CUSTOM_FUNCTION(CloseLocation)(CORO_PARAM, uint32, uint32, uint32, uint32) { @@ -642,16 +588,16 @@ DECLARE_CUSTOM_FUNCTION(CloseLocation)(CORO_PARAM, uint32, uint32, uint32, uint3 CORO_BEGIN_CODE(_ctx); - if (!bNoOcchioDiBue) { - InitWipe(1); - CORO_INVOKE_0(WaitWipeEnd); + if (!GLOBALS.bNoOcchioDiBue) { + GLOBALS.InitWipe(1); + CORO_INVOKE_0(GLOBALS.WaitWipeEnd); } _vm->StopMusic(4); // On Exit e lascia freezzato - CORO_INVOKE_2(UnloadLocation, true, NULL); - Unfreeze(); + CORO_INVOKE_2(GLOBALS.UnloadLocation, true, NULL); + GLOBALS.Unfreeze(); CORO_END_CODE; } @@ -664,45 +610,45 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint CORO_BEGIN_CODE(_ctx); - if (!bNoOcchioDiBue) { - InitWipe(1); - CORO_INVOKE_0(WaitWipeEnd); + if (!GLOBALS.bNoOcchioDiBue) { + GLOBALS.InitWipe(1); + CORO_INVOKE_0(GLOBALS.WaitWipeEnd); } - if (lastTappeto != tappeti[nLoc]) { + if (GLOBALS.lastTappeto != GLOBALS.tappeti[nLoc]) { _vm->StopMusic(4); } // On Exit e lascia freezzato - CORO_INVOKE_2(UnloadLocation, true, NULL); + CORO_INVOKE_2(GLOBALS.UnloadLocation, true, NULL); - curChangedHotspot = 0; + GLOBALS.curChangedHotspot = 0; if (bUseStartPos != 0) - LoadLocation(nLoc, RMPoint(tX, tY), StartLocPos[nLoc]); + GLOBALS.LoadLocation(nLoc, RMPoint(tX, tY), GLOBALS.StartLocPos[nLoc]); else - LoadLocation(nLoc, RMPoint(tX, tY), RMPoint(-1, -1)); + GLOBALS.LoadLocation(nLoc, RMPoint(tX, tY), RMPoint(-1, -1)); - if (lastTappeto != tappeti[nLoc]) { - lastTappeto = tappeti[nLoc]; - if (lastTappeto != 0) - _vm->PlayMusic(4, tappetiFile[lastTappeto], 0, true, 2000); + if (GLOBALS.lastTappeto != GLOBALS.tappeti[nLoc]) { + GLOBALS.lastTappeto = GLOBALS.tappeti[nLoc]; + if (GLOBALS.lastTappeto != 0) + _vm->PlayMusic(4, tappetiFile[GLOBALS.lastTappeto], 0, true, 2000); } - if (!bNoOcchioDiBue) { - InitWipe(2); + if (!GLOBALS.bNoOcchioDiBue) { + GLOBALS.InitWipe(2); } - Unfreeze(); + GLOBALS.Unfreeze(); _ctx->h = mpalQueryDoAction(0, nLoc, 0); - if (!bNoOcchioDiBue) { - CORO_INVOKE_0(WaitWipeEnd); - CloseWipe(); + if (!GLOBALS.bNoOcchioDiBue) { + CORO_INVOKE_0(GLOBALS.WaitWipeEnd); + GLOBALS.CloseWipe(); } - bNoOcchioDiBue = false; + GLOBALS.bNoOcchioDiBue = false; // On Enter? if (_ctx->h != CORO_INVALID_PID_VALUE) @@ -712,12 +658,12 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint } DECLARE_CUSTOM_FUNCTION(SetLocStartPosition)(CORO_PARAM, uint32 nLoc, uint32 lX, uint32 lY, uint32) { - StartLocPos[nLoc].Set(lX,lY); + GLOBALS.StartLocPos[nLoc].Set(lX,lY); } DECLARE_CUSTOM_FUNCTION(SaveTonyPosition)(CORO_PARAM, uint32, uint32, uint32, uint32) { - saveTonyPos = Tony->Position(); - saveTonyLoc = Loc->TEMPGetNumLoc(); + GLOBALS.saveTonyPos = GLOBALS.Tony->Position(); + GLOBALS.saveTonyLoc = GLOBALS.Loc->TEMPGetNumLoc(); } DECLARE_CUSTOM_FUNCTION(RestoreTonyPosition)(CORO_PARAM, uint32, uint32, uint32, uint32) { @@ -726,7 +672,7 @@ DECLARE_CUSTOM_FUNCTION(RestoreTonyPosition)(CORO_PARAM, uint32, uint32, uint32, CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_4(ChangeLocation, saveTonyLoc, saveTonyPos.x, saveTonyPos.y, 0); + CORO_INVOKE_4(ChangeLocation, GLOBALS.saveTonyLoc, GLOBALS.saveTonyPos.x, GLOBALS.saveTonyPos.y, 0); MCharResetCodes(); @@ -744,16 +690,16 @@ DECLARE_CUSTOM_FUNCTION(EnableInput)(CORO_PARAM, uint32, uint32, uint32, uint32) } DECLARE_CUSTOM_FUNCTION(StopTony)(CORO_PARAM, uint32, uint32, uint32, uint32) { - Tony->StopNoAction(coroParam); + GLOBALS.Tony->StopNoAction(coroParam); } DECLARE_CUSTOM_FUNCTION(CustEnableGUI)(CORO_PARAM, uint32, uint32, uint32, uint32) { - EnableGUI(); + GLOBALS.EnableGUI(); } DECLARE_CUSTOM_FUNCTION(CustDisableGUI)(CORO_PARAM, uint32, uint32, uint32, uint32) { - DisableGUI(); + GLOBALS.DisableGUI(); } @@ -764,12 +710,12 @@ void TonyGenericTake1(CORO_PARAM, uint32 nDirection) { CORO_BEGIN_CODE(_ctx); - Freeze(); - Tony->Take(nDirection, 0); - Unfreeze(); + GLOBALS.Freeze(); + GLOBALS.Tony->Take(nDirection, 0); + GLOBALS.Unfreeze(); - if (!bSkipIdle) - CORO_INVOKE_0(Tony->WaitForEndPattern); + if (!GLOBALS.bSkipIdle) + CORO_INVOKE_0(GLOBALS.Tony->WaitForEndPattern); CORO_END_CODE; } @@ -780,16 +726,16 @@ void TonyGenericTake2(CORO_PARAM, uint32 nDirection) { CORO_BEGIN_CODE(_ctx); - Freeze(); - Tony->Take(nDirection, 1); - Unfreeze(); + GLOBALS.Freeze(); + GLOBALS.Tony->Take(nDirection, 1); + GLOBALS.Unfreeze(); - if (!bSkipIdle) - CORO_INVOKE_0(Tony->WaitForEndPattern); + if (!GLOBALS.bSkipIdle) + CORO_INVOKE_0(GLOBALS.Tony->WaitForEndPattern); - Freeze(); - Tony->Take(nDirection,2); - Unfreeze(); + GLOBALS.Freeze(); + GLOBALS.Tony->Take(nDirection,2); + GLOBALS.Unfreeze(); CORO_END_CODE; } @@ -800,12 +746,12 @@ void TonyGenericPut1(CORO_PARAM, uint32 nDirection) { CORO_BEGIN_CODE(_ctx); - Freeze(); - Tony->Put(nDirection, 0); - Unfreeze(); + GLOBALS.Freeze(); + GLOBALS.Tony->Put(nDirection, 0); + GLOBALS.Unfreeze(); - if (!bSkipIdle) - CORO_INVOKE_0(Tony->WaitForEndPattern); + if (!GLOBALS.bSkipIdle) + CORO_INVOKE_0(GLOBALS.Tony->WaitForEndPattern); CORO_END_CODE; } @@ -816,16 +762,16 @@ void TonyGenericPut2(CORO_PARAM, uint32 nDirection) { CORO_BEGIN_CODE(_ctx); - Freeze(); - Tony->Put(nDirection,1); - Unfreeze(); + GLOBALS.Freeze(); + GLOBALS.Tony->Put(nDirection,1); + GLOBALS.Unfreeze(); - if (!bSkipIdle) - CORO_INVOKE_0(Tony->WaitForEndPattern); + if (!GLOBALS.bSkipIdle) + CORO_INVOKE_0(GLOBALS.Tony->WaitForEndPattern); - Freeze(); - Tony->Put(nDirection,2); - Unfreeze(); + GLOBALS.Freeze(); + GLOBALS.Tony->Put(nDirection,2); + GLOBALS.Unfreeze(); CORO_END_CODE; } @@ -890,9 +836,9 @@ DECLARE_CUSTOM_FUNCTION(TonyPutDown2)(CORO_PARAM, uint32, uint32, uint32, uint32 DECLARE_CUSTOM_FUNCTION(TonyPerTerra)(CORO_PARAM, uint32 dwParte, uint32, uint32, uint32) { if (dwParte == 0) - Tony->SetPattern(Tony->PAT_PERTERRALEFT); + GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_PERTERRALEFT); else - Tony->SetPattern(Tony->PAT_PERTERRARIGHT); + GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_PERTERRARIGHT); } DECLARE_CUSTOM_FUNCTION(TonySiRialza)(CORO_PARAM, uint32 dwParte, uint32, uint32, uint32) { @@ -902,18 +848,18 @@ DECLARE_CUSTOM_FUNCTION(TonySiRialza)(CORO_PARAM, uint32 dwParte, uint32, uint32 CORO_BEGIN_CODE(_ctx); if (dwParte == 0) - Tony->SetPattern(Tony->PAT_SIRIALZALEFT); + GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_SIRIALZALEFT); else - Tony->SetPattern(Tony->PAT_SIRIALZARIGHT); + GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_SIRIALZARIGHT); - if (!bSkipIdle) - CORO_INVOKE_0(Tony->WaitForEndPattern); + if (!GLOBALS.bSkipIdle) + CORO_INVOKE_0(GLOBALS.Tony->WaitForEndPattern); CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(TonyPastorella)(CORO_PARAM, uint32 bIsPast, uint32, uint32, uint32) { - Tony->SetPastorella(bIsPast); + GLOBALS.Tony->SetPastorella(bIsPast); } DECLARE_CUSTOM_FUNCTION(TonyFischietto)(CORO_PARAM, uint32, uint32, uint32, uint32) { @@ -922,104 +868,104 @@ DECLARE_CUSTOM_FUNCTION(TonyFischietto)(CORO_PARAM, uint32, uint32, uint32, uint CORO_BEGIN_CODE(_ctx); - Tony->SetPattern(Tony->PAT_FISCHIETTORIGHT); - if (!bSkipIdle) - CORO_INVOKE_0(Tony->WaitForEndPattern); + GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_FISCHIETTORIGHT); + if (!GLOBALS.bSkipIdle) + CORO_INVOKE_0(GLOBALS.Tony->WaitForEndPattern); - Tony->SetPattern(Tony->PAT_STANDRIGHT); + GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_STANDRIGHT); CORO_END_CODE; } void TonySetNumTexts(uint32 dwText) { - dwTonyNumTexts=dwText; - bTonyInTexts = false; + GLOBALS.dwTonyNumTexts = dwText; + GLOBALS.bTonyInTexts = false; } DECLARE_CUSTOM_FUNCTION(TonyRide)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - nTonyNextTalkType = Tony->TALK_RIDE; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_RIDE; } DECLARE_CUSTOM_FUNCTION(TonyRidacchia)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - nTonyNextTalkType = Tony->TALK_RIDE2; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_RIDE2; } DECLARE_CUSTOM_FUNCTION(TonyFianchi)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - nTonyNextTalkType = Tony->TALK_FIANCHI; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_FIANCHI; } DECLARE_CUSTOM_FUNCTION(TonyCanta)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - nTonyNextTalkType = Tony->TALK_CANTA; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CANTA; } DECLARE_CUSTOM_FUNCTION(TonySiIndica)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - nTonyNextTalkType = Tony->TALK_SIINDICA; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_SIINDICA; } DECLARE_CUSTOM_FUNCTION(TonySpaventatoConMani)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - nTonyNextTalkType = Tony->TALK_SPAVENTATO; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_SPAVENTATO; } DECLARE_CUSTOM_FUNCTION(TonySpaventatoSenzaMani)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - nTonyNextTalkType = Tony->TALK_SPAVENTATO2; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_SPAVENTATO2; } DECLARE_CUSTOM_FUNCTION(TonyConMartello)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - nTonyNextTalkType = Tony->TALK_CONMARTELLO; - Tony->SetPattern(Tony->PAT_CONMARTELLO); + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONMARTELLO; + GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_CONMARTELLO); } DECLARE_CUSTOM_FUNCTION(TonyConBicchiere)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - nTonyNextTalkType = Tony->TALK_CONBICCHIERE; - Tony->SetPattern(Tony->PAT_CONBICCHIERE); + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONBICCHIERE; + GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_CONBICCHIERE); } DECLARE_CUSTOM_FUNCTION(TonyConVerme)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - nTonyNextTalkType = Tony->TALK_CONVERME; - Tony->SetPattern(Tony->PAT_CONVERME); + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONVERME; + GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_CONVERME); } DECLARE_CUSTOM_FUNCTION(TonyConCorda)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - nTonyNextTalkType = Tony->TALK_CONCORDA; - Tony->SetPattern(Tony->PAT_CONCORDA); + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONCORDA; + GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_CONCORDA); } DECLARE_CUSTOM_FUNCTION(TonyConSegretaria)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - nTonyNextTalkType = Tony->TALK_CONSEGRETARIA; - Tony->SetPattern(Tony->PAT_CONSEGRETARIA); + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONSEGRETARIA; + GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_CONSEGRETARIA); } DECLARE_CUSTOM_FUNCTION(TonyConConiglioANIM)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - nTonyNextTalkType = Tony->TALK_CONCONIGLIO; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONCONIGLIO; } DECLARE_CUSTOM_FUNCTION(TonyConRicettaANIM)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - nTonyNextTalkType = Tony->TALK_CONRICETTA; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONRICETTA; } DECLARE_CUSTOM_FUNCTION(TonyConCarteANIM)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - nTonyNextTalkType = Tony->TALK_CONCARTE; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONCARTE; } DECLARE_CUSTOM_FUNCTION(TonyConPupazzoANIM)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - nTonyNextTalkType = Tony->TALK_CONPUPAZZO; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONPUPAZZO; } DECLARE_CUSTOM_FUNCTION(TonyConPupazzoStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { @@ -1028,9 +974,9 @@ DECLARE_CUSTOM_FUNCTION(TonyConPupazzoStart)(CORO_PARAM, uint32, uint32, uint32, CORO_BEGIN_CODE(_ctx); - nTonyNextTalkType = Tony->TALK_CONPUPAZZOSTATIC; - bStaticTalk = true; - CORO_INVOKE_1(Tony->StartStatic, Tony->TALK_CONPUPAZZOSTATIC); + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONPUPAZZOSTATIC; + GLOBALS.bStaticTalk = true; + CORO_INVOKE_1(GLOBALS.Tony->StartStatic, GLOBALS.Tony->TALK_CONPUPAZZOSTATIC); CORO_END_CODE; } @@ -1041,9 +987,9 @@ DECLARE_CUSTOM_FUNCTION(TonyConPupazzoEnd)(CORO_PARAM, uint32, uint32, uint32, u CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(Tony->EndStatic, Tony->TALK_CONPUPAZZOSTATIC); - bStaticTalk = false; - nTonyNextTalkType = Tony->TALK_NORMAL; + CORO_INVOKE_1(GLOBALS.Tony->EndStatic, GLOBALS.Tony->TALK_CONPUPAZZOSTATIC); + GLOBALS.bStaticTalk = false; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; CORO_END_CODE; } @@ -1054,9 +1000,9 @@ DECLARE_CUSTOM_FUNCTION(TonyConConiglioStart)(CORO_PARAM, uint32, uint32, uint32 CORO_BEGIN_CODE(_ctx); - nTonyNextTalkType = Tony->TALK_CONCONIGLIOSTATIC; - bStaticTalk = true; - CORO_INVOKE_1(Tony->StartStatic, Tony->TALK_CONCONIGLIOSTATIC); + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONCONIGLIOSTATIC; + GLOBALS.bStaticTalk = true; + CORO_INVOKE_1(GLOBALS.Tony->StartStatic, GLOBALS.Tony->TALK_CONCONIGLIOSTATIC); CORO_END_CODE; } @@ -1067,9 +1013,9 @@ DECLARE_CUSTOM_FUNCTION(TonyConConiglioEnd)(CORO_PARAM, uint32, uint32, uint32, CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(Tony->EndStatic, Tony->TALK_CONCONIGLIOSTATIC); - bStaticTalk = false; - nTonyNextTalkType = Tony->TALK_NORMAL; + CORO_INVOKE_1(GLOBALS.Tony->EndStatic, GLOBALS.Tony->TALK_CONCONIGLIOSTATIC); + GLOBALS.bStaticTalk = false; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; CORO_END_CODE; } @@ -1080,9 +1026,9 @@ DECLARE_CUSTOM_FUNCTION(TonyConRicettaStart)(CORO_PARAM, uint32, uint32, uint32, CORO_BEGIN_CODE(_ctx); - nTonyNextTalkType = Tony->TALK_CONRICETTASTATIC; - bStaticTalk = true; - CORO_INVOKE_1(Tony->StartStatic, Tony->TALK_CONRICETTASTATIC); + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONRICETTASTATIC; + GLOBALS.bStaticTalk = true; + CORO_INVOKE_1(GLOBALS.Tony->StartStatic, GLOBALS.Tony->TALK_CONRICETTASTATIC); CORO_END_CODE; } @@ -1093,9 +1039,9 @@ DECLARE_CUSTOM_FUNCTION(TonyConRicettaEnd)(CORO_PARAM, uint32, uint32, uint32, u CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(Tony->EndStatic, Tony->TALK_CONRICETTASTATIC); - bStaticTalk = false; - nTonyNextTalkType = Tony->TALK_NORMAL; + CORO_INVOKE_1(GLOBALS.Tony->EndStatic, GLOBALS.Tony->TALK_CONRICETTASTATIC); + GLOBALS.bStaticTalk = false; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; CORO_END_CODE; } @@ -1106,9 +1052,9 @@ DECLARE_CUSTOM_FUNCTION(TonyConCarteStart)(CORO_PARAM, uint32, uint32, uint32, u CORO_BEGIN_CODE(_ctx); - nTonyNextTalkType = Tony->TALK_CONCARTESTATIC; - bStaticTalk = true; - CORO_INVOKE_1(Tony->StartStatic, Tony->TALK_CONCARTESTATIC); + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONCARTESTATIC; + GLOBALS.bStaticTalk = true; + CORO_INVOKE_1(GLOBALS.Tony->StartStatic, GLOBALS.Tony->TALK_CONCARTESTATIC); CORO_END_CODE; } @@ -1119,9 +1065,9 @@ DECLARE_CUSTOM_FUNCTION(TonyConCarteEnd)(CORO_PARAM, uint32, uint32, uint32, uin CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(Tony->EndStatic, Tony->TALK_CONCARTESTATIC); - bStaticTalk = false; - nTonyNextTalkType = Tony->TALK_NORMAL; + CORO_INVOKE_1(GLOBALS.Tony->EndStatic, GLOBALS.Tony->TALK_CONCARTESTATIC); + GLOBALS.bStaticTalk = false; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; CORO_END_CODE; } @@ -1132,9 +1078,9 @@ DECLARE_CUSTOM_FUNCTION(TonyConTaccuinoStart)(CORO_PARAM, uint32, uint32, uint32 CORO_BEGIN_CODE(_ctx); - nTonyNextTalkType = Tony->TALK_CONTACCUINOSTATIC; - bStaticTalk = true; - CORO_INVOKE_1(Tony->StartStatic, Tony->TALK_CONTACCUINOSTATIC); + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONTACCUINOSTATIC; + GLOBALS.bStaticTalk = true; + CORO_INVOKE_1(GLOBALS.Tony->StartStatic, GLOBALS.Tony->TALK_CONTACCUINOSTATIC); CORO_END_CODE; } @@ -1145,9 +1091,9 @@ DECLARE_CUSTOM_FUNCTION(TonyConTaccuinoEnd)(CORO_PARAM, uint32, uint32, uint32, CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(Tony->EndStatic, Tony->TALK_CONTACCUINOSTATIC); - bStaticTalk = false; - nTonyNextTalkType = Tony->TALK_NORMAL; + CORO_INVOKE_1(GLOBALS.Tony->EndStatic, GLOBALS.Tony->TALK_CONTACCUINOSTATIC); + GLOBALS.bStaticTalk = false; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; CORO_END_CODE; } @@ -1158,9 +1104,9 @@ DECLARE_CUSTOM_FUNCTION(TonyConMegafonoStart)(CORO_PARAM, uint32, uint32, uint32 CORO_BEGIN_CODE(_ctx); - nTonyNextTalkType = Tony->TALK_CONMEGAFONOSTATIC; - bStaticTalk = true; - CORO_INVOKE_1(Tony->StartStatic, Tony->TALK_CONMEGAFONOSTATIC); + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONMEGAFONOSTATIC; + GLOBALS.bStaticTalk = true; + CORO_INVOKE_1(GLOBALS.Tony->StartStatic, GLOBALS.Tony->TALK_CONMEGAFONOSTATIC); CORO_END_CODE; } @@ -1171,9 +1117,9 @@ DECLARE_CUSTOM_FUNCTION(TonyConMegafonoEnd)(CORO_PARAM, uint32, uint32, uint32, CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(Tony->EndStatic, Tony->TALK_CONMEGAFONOSTATIC); - bStaticTalk = false; - nTonyNextTalkType = Tony->TALK_NORMAL; + CORO_INVOKE_1(GLOBALS.Tony->EndStatic, GLOBALS.Tony->TALK_CONMEGAFONOSTATIC); + GLOBALS.bStaticTalk = false; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; CORO_END_CODE; } @@ -1184,9 +1130,9 @@ DECLARE_CUSTOM_FUNCTION(TonyConBarbaStart)(CORO_PARAM, uint32, uint32, uint32, u CORO_BEGIN_CODE(_ctx); - nTonyNextTalkType = Tony->TALK_CONBARBASTATIC; - bStaticTalk = true; - CORO_INVOKE_1(Tony->StartStatic, Tony->TALK_CONBARBASTATIC); + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONBARBASTATIC; + GLOBALS.bStaticTalk = true; + CORO_INVOKE_1(GLOBALS.Tony->StartStatic, GLOBALS.Tony->TALK_CONBARBASTATIC); CORO_END_CODE; } @@ -1197,9 +1143,9 @@ DECLARE_CUSTOM_FUNCTION(TonyConBarbaEnd)(CORO_PARAM, uint32, uint32, uint32, uin CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(Tony->EndStatic, Tony->TALK_CONBARBASTATIC); - bStaticTalk = false; - nTonyNextTalkType = Tony->TALK_NORMAL; + CORO_INVOKE_1(GLOBALS.Tony->EndStatic, GLOBALS.Tony->TALK_CONBARBASTATIC); + GLOBALS.bStaticTalk = false; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; CORO_END_CODE; } @@ -1210,9 +1156,9 @@ DECLARE_CUSTOM_FUNCTION(TonySpaventatoStart)(CORO_PARAM, uint32, uint32, uint32, CORO_BEGIN_CODE(_ctx); - nTonyNextTalkType = Tony->TALK_SPAVENTATOSTATIC; - bStaticTalk = true; - CORO_INVOKE_1(Tony->StartStatic, Tony->TALK_SPAVENTATOSTATIC); + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_SPAVENTATOSTATIC; + GLOBALS.bStaticTalk = true; + CORO_INVOKE_1(GLOBALS.Tony->StartStatic, GLOBALS.Tony->TALK_SPAVENTATOSTATIC); CORO_END_CODE; } @@ -1223,9 +1169,9 @@ DECLARE_CUSTOM_FUNCTION(TonySpaventatoEnd)(CORO_PARAM, uint32, uint32, uint32, u CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(Tony->EndStatic, Tony->TALK_SPAVENTATOSTATIC); - bStaticTalk = false; - nTonyNextTalkType = Tony->TALK_NORMAL; + CORO_INVOKE_1(GLOBALS.Tony->EndStatic, GLOBALS.Tony->TALK_SPAVENTATOSTATIC); + GLOBALS.bStaticTalk = false; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; CORO_END_CODE; } @@ -1233,7 +1179,7 @@ DECLARE_CUSTOM_FUNCTION(TonySpaventatoEnd)(CORO_PARAM, uint32, uint32, uint32, u DECLARE_CUSTOM_FUNCTION(TonySchifato)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - nTonyNextTalkType = Tony->TALK_SCHIFATO; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_SCHIFATO; } DECLARE_CUSTOM_FUNCTION(TonySniffaLeft)(CORO_PARAM, uint32, uint32, uint32, uint32) { @@ -1242,8 +1188,8 @@ DECLARE_CUSTOM_FUNCTION(TonySniffaLeft)(CORO_PARAM, uint32, uint32, uint32, uint CORO_BEGIN_CODE(_ctx); - Tony->SetPattern(Tony->PAT_SNIFFA_LEFT); - CORO_INVOKE_0(Tony->WaitForEndPattern); + GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_SNIFFA_LEFT); + CORO_INVOKE_0(GLOBALS.Tony->WaitForEndPattern); CORO_INVOKE_4(LeftToMe, 0, 0, 0, 0); CORO_END_CODE; @@ -1255,8 +1201,8 @@ DECLARE_CUSTOM_FUNCTION(TonySniffaRight)(CORO_PARAM, uint32, uint32, uint32, uin CORO_BEGIN_CODE(_ctx); - Tony->SetPattern(Tony->PAT_SNIFFA_RIGHT); - CORO_INVOKE_0(Tony->WaitForEndPattern); + GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_SNIFFA_RIGHT); + CORO_INVOKE_0(GLOBALS.Tony->WaitForEndPattern); CORO_INVOKE_4(RightToMe, 0, 0, 0, 0); CORO_END_CODE; @@ -1264,48 +1210,48 @@ DECLARE_CUSTOM_FUNCTION(TonySniffaRight)(CORO_PARAM, uint32, uint32, uint32, uin DECLARE_CUSTOM_FUNCTION(TonyNaah)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - nTonyNextTalkType = Tony->TALK_NAAH; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NAAH; } DECLARE_CUSTOM_FUNCTION(TonyMacbeth)(CORO_PARAM, uint32 nPos, uint32, uint32, uint32) { switch (nPos) { case 1: - nTonyNextTalkType = Tony->TALK_MACBETH1; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_MACBETH1; break; case 2: - nTonyNextTalkType = Tony->TALK_MACBETH2; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_MACBETH2; break; case 3: - nTonyNextTalkType = Tony->TALK_MACBETH3; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_MACBETH3; break; case 4: - nTonyNextTalkType = Tony->TALK_MACBETH4; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_MACBETH4; break; case 5: - nTonyNextTalkType = Tony->TALK_MACBETH5; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_MACBETH5; break; case 6: - nTonyNextTalkType = Tony->TALK_MACBETH6; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_MACBETH6; break; case 7: - nTonyNextTalkType = Tony->TALK_MACBETH7; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_MACBETH7; break; case 8: - nTonyNextTalkType = Tony->TALK_MACBETH8; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_MACBETH8; break; case 9: - nTonyNextTalkType = Tony->TALK_MACBETH9; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_MACBETH9; break; } } DECLARE_CUSTOM_FUNCTION(EnableTony)(CORO_PARAM, uint32, uint32, uint32, uint32) { - Tony->Show(); + GLOBALS.Tony->Show(); } DECLARE_CUSTOM_FUNCTION(DisableTony)(CORO_PARAM, uint32 bShowOmbra, uint32, uint32, uint32) { - Tony->Hide(bShowOmbra); + GLOBALS.Tony->Hide(bShowOmbra); } DECLARE_CUSTOM_FUNCTION(WaitForPatternEnd)(CORO_PARAM, uint32 nItem, uint32, uint32, uint32) { @@ -1315,17 +1261,17 @@ DECLARE_CUSTOM_FUNCTION(WaitForPatternEnd)(CORO_PARAM, uint32 nItem, uint32, uin CORO_BEGIN_CODE(_ctx); - _ctx->item = Loc->GetItemFromCode(nItem); + _ctx->item = GLOBALS.Loc->GetItemFromCode(nItem); - if (!bSkipIdle && _ctx->item != NULL) - CORO_INVOKE_1(_ctx->item->WaitForEndPattern, hSkipIdle); + if (!GLOBALS.bSkipIdle && _ctx->item != NULL) + CORO_INVOKE_1(_ctx->item->WaitForEndPattern, GLOBALS.hSkipIdle); CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(SetTonyPosition)(CORO_PARAM, uint32 nX, uint32 nY, uint32 nLoc, uint32) { - Tony->SetPosition(RMPoint(nX, nY), nLoc); + GLOBALS.Tony->SetPosition(RMPoint(nX, nY), nLoc); } DECLARE_CUSTOM_FUNCTION(MoveTonyAndWait)(CORO_PARAM, uint32 nX, uint32 nY, uint32, uint32) { @@ -1334,16 +1280,16 @@ DECLARE_CUSTOM_FUNCTION(MoveTonyAndWait)(CORO_PARAM, uint32 nX, uint32 nY, uint3 CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(Tony->Move, RMPoint(nX, nY)); + CORO_INVOKE_1(GLOBALS.Tony->Move, RMPoint(nX, nY)); - if (!bSkipIdle) - CORO_INVOKE_0(Tony->WaitForEndMovement); + if (!GLOBALS.bSkipIdle) + CORO_INVOKE_0(GLOBALS.Tony->WaitForEndMovement); CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(MoveTony)(CORO_PARAM, uint32 nX, uint32 nY, uint32, uint32) { - Tony->Move(coroParam, RMPoint(nX, nY)); + GLOBALS.Tony->Move(coroParam, RMPoint(nX, nY)); } DECLARE_CUSTOM_FUNCTION(ScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, uint32 sX, uint32 sY) { @@ -1358,9 +1304,9 @@ DECLARE_CUSTOM_FUNCTION(ScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, uint32 _ctx->lx = (int32)nX; _ctx->ly = (int32)nY; - _ctx->pt = Loc->ScrollPosition(); + _ctx->pt = GLOBALS.Loc->ScrollPosition(); - while ((_ctx->lx != 0 || _ctx->ly != 0) && !bSkipIdle) { + while ((_ctx->lx != 0 || _ctx->ly != 0) && !GLOBALS.bSkipIdle) { if (_ctx->lx > 0) { _ctx->lx -= (int32)sX; if (_ctx->lx < 0) _ctx->lx = 0; _ctx->pt.Offset((int32)sX, 0); @@ -1377,12 +1323,12 @@ DECLARE_CUSTOM_FUNCTION(ScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, uint32 _ctx->pt.Offset(0, -(int32)sY); } - CORO_INVOKE_0(WaitFrame); + CORO_INVOKE_0(GLOBALS.WaitFrame); - Freeze(); - Loc->SetScrollPosition(_ctx->pt); - Tony->SetScrollPosition(_ctx->pt); - Unfreeze(); + GLOBALS.Freeze(); + GLOBALS.Loc->SetScrollPosition(_ctx->pt); + GLOBALS.Tony->SetScrollPosition(_ctx->pt); + GLOBALS.Unfreeze(); } CORO_END_CODE; @@ -1410,7 +1356,7 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui _ctx->stepX = sX; _ctx->stepY = sY; - _ctx->startpt = Loc->ScrollPosition(); + _ctx->startpt = GLOBALS.Loc->ScrollPosition(); _ctx->dwStartTime = _vm->GetTime(); @@ -1419,7 +1365,7 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui else _ctx->dwTotalTime = _ctx->dimy * (1000 / 35) / sY; - while ((_ctx->lx != 0 || _ctx->ly != 0) && !bSkipIdle) { + while ((_ctx->lx != 0 || _ctx->ly != 0) && !GLOBALS.bSkipIdle) { _ctx->dwCurTime = _vm->GetTime() - _ctx->dwStartTime; if (_ctx->dwCurTime > _ctx->dwTotalTime) break; @@ -1459,12 +1405,12 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui _ctx->pt.Offset(0,-sY); } */ - CORO_INVOKE_0(WaitFrame); + CORO_INVOKE_0(GLOBALS.WaitFrame); - Freeze(); - Loc->SetScrollPosition(_ctx->pt); - Tony->SetScrollPosition(_ctx->pt); - Unfreeze(); + GLOBALS.Freeze(); + GLOBALS.Loc->SetScrollPosition(_ctx->pt); + GLOBALS.Tony->SetScrollPosition(_ctx->pt); + GLOBALS.Unfreeze(); } @@ -1482,10 +1428,10 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui _ctx->pt.y = _ctx->startpt.y - _ctx->dimy; } - Freeze(); - Loc->SetScrollPosition(_ctx->pt); - Tony->SetScrollPosition(_ctx->pt); - Unfreeze(); + GLOBALS.Freeze(); + GLOBALS.Loc->SetScrollPosition(_ctx->pt); + GLOBALS.Tony->SetScrollPosition(_ctx->pt); + GLOBALS.Unfreeze(); CORO_END_CODE; } @@ -1494,21 +1440,21 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui DECLARE_CUSTOM_FUNCTION(ChangeHotspot)(CORO_PARAM, uint32 dwCode, uint32 nX, uint32 nY, uint32) { int i; - for (i = 0; i < curChangedHotspot; i++) - if (ChangedHotspot[i].dwCode == dwCode) { - ChangedHotspot[i].nX=nX; - ChangedHotspot[i].nY=nY; + for (i = 0; i < GLOBALS.curChangedHotspot; i++) + if (GLOBALS.ChangedHotspot[i].dwCode == dwCode) { + GLOBALS.ChangedHotspot[i].nX=nX; + GLOBALS.ChangedHotspot[i].nY=nY; break; } - if (i == curChangedHotspot) { - ChangedHotspot[i].dwCode=dwCode; - ChangedHotspot[i].nX=nX; - ChangedHotspot[i].nY=nY; - curChangedHotspot++; + if (i == GLOBALS.curChangedHotspot) { + GLOBALS.ChangedHotspot[i].dwCode=dwCode; + GLOBALS.ChangedHotspot[i].nX=nX; + GLOBALS.ChangedHotspot[i].nY=nY; + GLOBALS.curChangedHotspot++; } - Loc->GetItemFromCode(dwCode)->ChangeHotspot(RMPoint(nX, nY)); + GLOBALS.Loc->GetItemFromCode(dwCode)->ChangeHotspot(RMPoint(nX, nY)); } @@ -1535,12 +1481,12 @@ DECLARE_CUSTOM_FUNCTION(TremaSchermo)(CORO_PARAM, uint32 nScosse, uint32, uint32 _ctx->diry = 1; while (_vm->GetTime() < _ctx->curTime + nScosse) { - CORO_INVOKE_0(WaitFrame); + CORO_INVOKE_0(GLOBALS.WaitFrame); - Freeze(); - Loc->SetFixedScroll(RMPoint(1 * _ctx->dirx, 1 * _ctx->diry)); - Tony->SetFixedScroll(RMPoint(1 * _ctx->dirx, 1 * _ctx->diry)); - Unfreeze(); + GLOBALS.Freeze(); + GLOBALS.Loc->SetFixedScroll(RMPoint(1 * _ctx->dirx, 1 * _ctx->diry)); + GLOBALS.Tony->SetFixedScroll(RMPoint(1 * _ctx->dirx, 1 * _ctx->diry)); + GLOBALS.Unfreeze(); _ctx->i = _vm->_randomSource.getRandomNumber(2); @@ -1550,10 +1496,10 @@ DECLARE_CUSTOM_FUNCTION(TremaSchermo)(CORO_PARAM, uint32 nScosse, uint32, uint32 _ctx->diry = -_ctx->diry; } - Freeze(); - Loc->SetFixedScroll(RMPoint(0, 0)); - Tony->SetFixedScroll(RMPoint(0, 0)); - Unfreeze(); + GLOBALS.Freeze(); + GLOBALS.Loc->SetFixedScroll(RMPoint(0, 0)); + GLOBALS.Tony->SetFixedScroll(RMPoint(0, 0)); + GLOBALS.Unfreeze(); CORO_END_CODE; } @@ -1566,36 +1512,36 @@ DECLARE_CUSTOM_FUNCTION(TremaSchermo)(CORO_PARAM, uint32 nScosse, uint32, uint32 DECLARE_CUSTOM_FUNCTION(CharSetCode)(CORO_PARAM, uint32 nChar, uint32 nCode, uint32, uint32) { assert(nChar < 16); - Character[nChar].code = nCode; - Character[nChar].item = Loc->GetItemFromCode(nCode); - Character[nChar].r = 255; - Character[nChar].g = 255; - Character[nChar].b = 255; - Character[nChar].talkpattern = 0; - Character[nChar].starttalkpattern = 0; - Character[nChar].endtalkpattern = 0; - Character[nChar].standpattern = 0; + GLOBALS.Character[nChar].code = nCode; + GLOBALS.Character[nChar].item = GLOBALS.Loc->GetItemFromCode(nCode); + GLOBALS.Character[nChar].r = 255; + GLOBALS.Character[nChar].g = 255; + GLOBALS.Character[nChar].b = 255; + GLOBALS.Character[nChar].talkpattern = 0; + GLOBALS.Character[nChar].starttalkpattern = 0; + GLOBALS.Character[nChar].endtalkpattern = 0; + GLOBALS.Character[nChar].standpattern = 0; - IsMChar[nChar] = false; + GLOBALS.IsMChar[nChar] = false; } DECLARE_CUSTOM_FUNCTION(CharSetColor)(CORO_PARAM, uint32 nChar, uint32 r, uint32 g, uint32 b) { assert(nChar<16); - Character[nChar].r = r; - Character[nChar].g = g; - Character[nChar].b = b; + GLOBALS.Character[nChar].r = r; + GLOBALS.Character[nChar].g = g; + GLOBALS.Character[nChar].b = b; } DECLARE_CUSTOM_FUNCTION(CharSetTalkPattern)(CORO_PARAM, uint32 nChar, uint32 tp, uint32 sp, uint32) { assert(nChar<16); - Character[nChar].talkpattern = tp; - Character[nChar].standpattern = sp; + GLOBALS.Character[nChar].talkpattern = tp; + GLOBALS.Character[nChar].standpattern = sp; } DECLARE_CUSTOM_FUNCTION(CharSetStartEndTalkPattern)(CORO_PARAM, uint32 nChar, uint32 sp, uint32 ep, uint32) { assert(nChar<16); - Character[nChar].starttalkpattern=sp; - Character[nChar].endtalkpattern=ep; + GLOBALS.Character[nChar].starttalkpattern=sp; + GLOBALS.Character[nChar].endtalkpattern=ep; } DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMessage, uint32 bIsBack, uint32) { @@ -1615,40 +1561,40 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess _ctx->curOffset = 0; assert(nChar < 16); - _ctx->pt = Character[nChar].item->CalculatePos() - RMPoint(-60, 20) - Loc->ScrollPosition(); + _ctx->pt = GLOBALS.Character[nChar].item->CalculatePos() - RMPoint(-60, 20) - GLOBALS.Loc->ScrollPosition(); - if (Character[nChar].starttalkpattern != 0) { - Freeze(); - Character[nChar].item->SetPattern(Character[nChar].starttalkpattern); - Unfreeze(); + if (GLOBALS.Character[nChar].starttalkpattern != 0) { + GLOBALS.Freeze(); + GLOBALS.Character[nChar].item->SetPattern(GLOBALS.Character[nChar].starttalkpattern); + GLOBALS.Unfreeze(); - CORO_INVOKE_0(Character[nChar].item->WaitForEndPattern); + CORO_INVOKE_0(GLOBALS.Character[nChar].item->WaitForEndPattern); } - Freeze(); - Character[nChar].item->SetPattern(Character[nChar].talkpattern); - Unfreeze(); + GLOBALS.Freeze(); + GLOBALS.Character[nChar].item->SetPattern(GLOBALS.Character[nChar].talkpattern); + GLOBALS.Unfreeze(); _ctx->curVoc = SearchVoiceHeader(0, dwMessage); _ctx->voice = NULL; if (_ctx->curVoc) { // Si posiziona all'interno del database delle voci all'inizio della prima // fseek(_vm->m_vdbFP, _ctx->curVoc->offset, SEEK_SET); - g_system->lockMutex(vdb); + g_system->lockMutex(GLOBALS.vdb); _vm->_vdbFP.seek(_ctx->curVoc->offset); _ctx->curOffset = _ctx->curVoc->offset; - g_system->unlockMutex(vdb); + g_system->unlockMutex(GLOBALS.vdb); } - for (_ctx->i = 0; _ctx->i<_ctx->msg->NumPeriods() && !bSkipIdle; _ctx->i++) { + for (_ctx->i = 0; _ctx->i<_ctx->msg->NumPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { if (bIsBack) { - curBackText = _ctx->text = new RMTextDialogScrolling(Loc); - if (bTonyIsSpeaking) - CORO_INVOKE_0(curBackText->Hide); + GLOBALS.curBackText = _ctx->text = new RMTextDialogScrolling(GLOBALS.Loc); + if (GLOBALS.bTonyIsSpeaking) + CORO_INVOKE_0(GLOBALS.curBackText->Hide); } else _ctx->text = new RMTextDialog; - _ctx->text->SetInput(Input); + _ctx->text->SetInput(GLOBALS.Input); // Skipping _ctx->text->SetSkipStatus(!bIsBack); @@ -1657,7 +1603,7 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess _ctx->text->SetAlignType(RMText::HCENTER,RMText::VBOTTOM); // Colore - _ctx->text->SetColor(Character[nChar].r,Character[nChar].g,Character[nChar].b); + _ctx->text->SetColor(GLOBALS.Character[nChar].r,GLOBALS.Character[nChar].g,GLOBALS.Character[nChar].b); // Scrive il testo _ctx->text->WriteText((*_ctx->msg)[_ctx->i],0); @@ -1666,13 +1612,13 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess _ctx->text->SetPosition(_ctx->pt); // Setta l'always display - if (bAlwaysDisplay) { _ctx->text->SetAlwaysDisplay(); _ctx->text->ForceTime(); } + if (GLOBALS.bAlwaysDisplay) { _ctx->text->SetAlwaysDisplay(); _ctx->text->ForceTime(); } // Registra il testo - LinkGraphicTask(_ctx->text); + GLOBALS.LinkGraphicTask(_ctx->text); if (_ctx->curVoc) { - g_system->lockMutex(vdb); + g_system->lockMutex(GLOBALS.vdb); _vm->_theSound.CreateSfx(&_ctx->voice); _vm->_vdbFP.seek(_ctx->curOffset); _ctx->voice->LoadVoiceFromVDB(_vm->_vdbFP); @@ -1681,11 +1627,11 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess _ctx->voice->Play(); _ctx->text->SetCustomSkipHandle2(_ctx->voice->hEndOfBuffer); _ctx->curOffset = _vm->_vdbFP.pos(); - g_system->unlockMutex(vdb); + g_system->unlockMutex(GLOBALS.vdb); } // Aspetta la fine della visualizzazione - _ctx->text->SetCustomSkipHandle(hSkipIdle); + _ctx->text->SetCustomSkipHandle(GLOBALS.hSkipIdle); CORO_INVOKE_0(_ctx->text->WaitForEndDisplay); if (_ctx->curVoc) { @@ -1695,83 +1641,81 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess } - curBackText=NULL; + GLOBALS.curBackText = NULL; delete _ctx->text; } - if (Character[nChar].endtalkpattern != 0) { - Freeze(); - Character[nChar].item->SetPattern(Character[nChar].endtalkpattern); - Unfreeze(); - CORO_INVOKE_0(Character[nChar].item->WaitForEndPattern); + if (GLOBALS.Character[nChar].endtalkpattern != 0) { + GLOBALS.Freeze(); + GLOBALS.Character[nChar].item->SetPattern(GLOBALS.Character[nChar].endtalkpattern); + GLOBALS.Unfreeze(); + CORO_INVOKE_0(GLOBALS.Character[nChar].item->WaitForEndPattern); } - Freeze(); - Character[nChar].item->SetPattern(Character[nChar].standpattern); - Unfreeze(); + GLOBALS.Freeze(); + GLOBALS.Character[nChar].item->SetPattern(GLOBALS.Character[nChar].standpattern); + GLOBALS.Unfreeze(); delete _ctx->msg; CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(AddInventory)(CORO_PARAM, uint32 dwCode, uint32, uint32, uint32) { - Inventory->AddItem(dwCode); + GLOBALS.Inventory->AddItem(dwCode); } DECLARE_CUSTOM_FUNCTION(RemoveInventory)(CORO_PARAM, uint32 dwCode, uint32, uint32, uint32) { - Inventory->RemoveItem(dwCode); + GLOBALS.Inventory->RemoveItem(dwCode); } DECLARE_CUSTOM_FUNCTION(ChangeInventoryStatus)(CORO_PARAM, uint32 dwCode, uint32 dwStatus, uint32, uint32) { - Inventory->ChangeItemStatus(dwCode,dwStatus); + GLOBALS.Inventory->ChangeItemStatus(dwCode,dwStatus); } - - /* * Mastri Personaggi */ DECLARE_CUSTOM_FUNCTION(MCharSetCode)(CORO_PARAM, uint32 nChar, uint32 nCode, uint32, uint32) { assert(nChar < 10); - MCharacter[nChar].code=nCode; + GLOBALS.MCharacter[nChar].code=nCode; if (nCode== 0) - MCharacter[nChar].item=NULL; + GLOBALS.MCharacter[nChar].item=NULL; else - MCharacter[nChar].item=Loc->GetItemFromCode(nCode); - MCharacter[nChar].r=255; - MCharacter[nChar].g=255; - MCharacter[nChar].b=255; - MCharacter[nChar].x=-1; - MCharacter[nChar].y=-1; - MCharacter[nChar].bAlwaysBack = 0; + GLOBALS.MCharacter[nChar].item=GLOBALS.Loc->GetItemFromCode(nCode); + GLOBALS.MCharacter[nChar].r=255; + GLOBALS.MCharacter[nChar].g=255; + GLOBALS.MCharacter[nChar].b=255; + GLOBALS.MCharacter[nChar].x=-1; + GLOBALS.MCharacter[nChar].y=-1; + GLOBALS.MCharacter[nChar].bAlwaysBack = 0; for (int i = 0; i < 10; i++) - MCharacter[nChar].numtalks[i] = 1; + GLOBALS.MCharacter[nChar].numtalks[i] = 1; - MCharacter[nChar].curgroup = 0; + GLOBALS.MCharacter[nChar].curgroup = 0; - IsMChar[nChar] = true; + GLOBALS.IsMChar[nChar] = true; } DECLARE_CUSTOM_FUNCTION(MCharResetCode)(CORO_PARAM, uint32 nChar, uint32, uint32, uint32) { - MCharacter[nChar].item=Loc->GetItemFromCode(MCharacter[nChar].code); + GLOBALS.MCharacter[nChar].item=GLOBALS.Loc->GetItemFromCode(GLOBALS.MCharacter[nChar].code); } DECLARE_CUSTOM_FUNCTION(MCharSetPosition)(CORO_PARAM, uint32 nChar, uint32 nX, uint32 nY, uint32) { assert(nChar < 10); - MCharacter[nChar].x=nX; - MCharacter[nChar].y=nY; + GLOBALS.MCharacter[nChar].x=nX; + GLOBALS.MCharacter[nChar].y=nY; } DECLARE_CUSTOM_FUNCTION(MCharSetColor)(CORO_PARAM, uint32 nChar, uint32 r, uint32 g, uint32 b) { assert(nChar < 10); - MCharacter[nChar].r=r; - MCharacter[nChar].g=g; - MCharacter[nChar].b=b; + GLOBALS.MCharacter[nChar].r=r; + GLOBALS.MCharacter[nChar].g=g; + GLOBALS.MCharacter[nChar].b=b; } @@ -1779,7 +1723,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSetNumTalksInGroup)(CORO_PARAM, uint32 nChar, uint3 assert(nChar < 10); assert(nGroup < 10); - MCharacter[nChar].numtalks[nGroup]=nTalks; + GLOBALS.MCharacter[nChar].numtalks[nGroup]=nTalks; } @@ -1788,20 +1732,20 @@ DECLARE_CUSTOM_FUNCTION(MCharSetCurrentGroup)(CORO_PARAM, uint32 nChar, uint32 n assert(nChar < 10); assert(nGroup < 10); - MCharacter[nChar].curgroup = nGroup; + GLOBALS.MCharacter[nChar].curgroup = nGroup; } DECLARE_CUSTOM_FUNCTION(MCharSetNumTexts)(CORO_PARAM, uint32 nChar, uint32 nTexts, uint32, uint32) { assert(nChar < 10); - MCharacter[nChar].numtexts=nTexts-1; - MCharacter[nChar].bInTexts = false; + GLOBALS.MCharacter[nChar].numtexts=nTexts-1; + GLOBALS.MCharacter[nChar].bInTexts = false; } DECLARE_CUSTOM_FUNCTION(MCharSetAlwaysBack)(CORO_PARAM, uint32 nChar, uint32 bAlwaysBack, uint32, uint32) { assert(nChar < 10); - MCharacter[nChar].bAlwaysBack=bAlwaysBack; + GLOBALS.MCharacter[nChar].bAlwaysBack=bAlwaysBack; } @@ -1825,21 +1769,21 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes assert(nChar < 10); - bIsBack |= MCharacter[nChar].bAlwaysBack ? 1 : 0; + bIsBack |= GLOBALS.MCharacter[nChar].bAlwaysBack ? 1 : 0; // Calcola la posizione del testo in base al frame corrente - if (MCharacter[nChar].x==-1) - _ctx->pt=MCharacter[nChar].item->CalculatePos()-RMPoint(-60,20)-Loc->ScrollPosition(); + if (GLOBALS.MCharacter[nChar].x==-1) + _ctx->pt=GLOBALS.MCharacter[nChar].item->CalculatePos()-RMPoint(-60,20)-GLOBALS.Loc->ScrollPosition(); else - _ctx->pt=RMPoint(MCharacter[nChar].x,MCharacter[nChar].y); + _ctx->pt=RMPoint(GLOBALS.MCharacter[nChar].x,GLOBALS.MCharacter[nChar].y); // Parametro per le azioni speciali: random tra le parlate - _ctx->parm = (MCharacter[nChar].curgroup * 10) + _vm->_randomSource.getRandomNumber( - MCharacter[nChar].numtalks[MCharacter[nChar].curgroup] - 1) + 1; + _ctx->parm = (GLOBALS.MCharacter[nChar].curgroup * 10) + _vm->_randomSource.getRandomNumber( + GLOBALS.MCharacter[nChar].numtalks[GLOBALS.MCharacter[nChar].curgroup] - 1) + 1; // Cerca di eseguire la funzione custom per inizializzare la parlata - if (MCharacter[nChar].item) { - _ctx->h = mpalQueryDoAction(30, MCharacter[nChar].item->MpalCode(), _ctx->parm); + if (GLOBALS.MCharacter[nChar].item) { + _ctx->h = mpalQueryDoAction(30, GLOBALS.MCharacter[nChar].item->MpalCode(), _ctx->parm); if (_ctx->h != CORO_INVALID_PID_VALUE) { CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->h, CORO_INFINITE); } @@ -1849,24 +1793,24 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes _ctx->voice = NULL; if (_ctx->curVoc) { // Si posiziona all'interno del database delle voci all'inizio della prima - g_system->lockMutex(vdb); + g_system->lockMutex(GLOBALS.vdb); // fseek(_vm->m_vdbFP, curVoc->offset, SEEK_SET); _vm->_vdbFP.seek(_ctx->curVoc->offset); _ctx->curOffset = _ctx->curVoc->offset; - g_system->unlockMutex(vdb); + g_system->unlockMutex(GLOBALS.vdb); } - for (_ctx->i = 0; _ctx->i < _ctx->msg->NumPeriods() && !bSkipIdle; _ctx->i++) { + for (_ctx->i = 0; _ctx->i < _ctx->msg->NumPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { // Crea l'oggetto diverso se back o no if (bIsBack) { - curBackText=_ctx->text = new RMTextDialogScrolling(Loc); - if (bTonyIsSpeaking) - CORO_INVOKE_0(curBackText->Hide); + GLOBALS.curBackText = _ctx->text = new RMTextDialogScrolling(GLOBALS.Loc); + if (GLOBALS.bTonyIsSpeaking) + CORO_INVOKE_0(GLOBALS.curBackText->Hide); } else _ctx->text = new RMTextDialog; - _ctx->text->SetInput(Input); + _ctx->text->SetInput(GLOBALS.Input); // Skipping _ctx->text->SetSkipStatus(!bIsBack); @@ -1875,7 +1819,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes _ctx->text->SetAlignType(RMText::HCENTER,RMText::VBOTTOM); // Colore - _ctx->text->SetColor(MCharacter[nChar].r,MCharacter[nChar].g,MCharacter[nChar].b); + _ctx->text->SetColor(GLOBALS.MCharacter[nChar].r,GLOBALS.MCharacter[nChar].g,GLOBALS.MCharacter[nChar].b); // Scrive il testo _ctx->text->WriteText((*_ctx->msg)[_ctx->i], nFont); @@ -1884,13 +1828,13 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes _ctx->text->SetPosition(_ctx->pt); // Setta l'always display - if (bAlwaysDisplay) { _ctx->text->SetAlwaysDisplay(); _ctx->text->ForceTime(); } + if (GLOBALS.bAlwaysDisplay) { _ctx->text->SetAlwaysDisplay(); _ctx->text->ForceTime(); } // Registra il testo - LinkGraphicTask(_ctx->text); + GLOBALS.LinkGraphicTask(_ctx->text); if (_ctx->curVoc) { - g_system->lockMutex(vdb); + g_system->lockMutex(GLOBALS.vdb); _vm->_theSound.CreateSfx(&_ctx->voice); _vm->_vdbFP.seek(_ctx->curOffset); _ctx->voice->LoadVoiceFromVDB(_vm->_vdbFP); @@ -1899,11 +1843,11 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes _ctx->voice->Play(); _ctx->text->SetCustomSkipHandle2(_ctx->voice->hEndOfBuffer); _ctx->curOffset = _vm->_vdbFP.pos(); - g_system->unlockMutex(vdb); + g_system->unlockMutex(GLOBALS.vdb); } // Aspetta la fine della visualizzazione - _ctx->text->SetCustomSkipHandle(hSkipIdle); + _ctx->text->SetCustomSkipHandle(GLOBALS.hSkipIdle); CORO_INVOKE_0(_ctx->text->WaitForEndDisplay); if (_ctx->curVoc) { @@ -1912,15 +1856,15 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes _ctx->voice = NULL; } - curBackText = NULL; + GLOBALS.curBackText = NULL; delete _ctx->text; delete _ctx->msg; } // Cerca di eseguire la funzione custom per chiudere la parlata - if (MCharacter[nChar].item) { - _ctx->h = mpalQueryDoAction(31, MCharacter[nChar].item->MpalCode(), _ctx->parm); + if (GLOBALS.MCharacter[nChar].item) { + _ctx->h = mpalQueryDoAction(31, GLOBALS.MCharacter[nChar].item->MpalCode(), _ctx->parm); if (_ctx->h != CORO_INVALID_PID_VALUE) CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->h, CORO_INFINITE); } @@ -1957,7 +1901,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg // La SendDialogMessage pu andare in background se un personaggio in MCHAR settato // con la SetAlwaysBack - if (nPers != 0 && IsMChar[nPers] && MCharacter[nPers].bAlwaysBack) + if (nPers != 0 && GLOBALS.IsMChar[nPers] && GLOBALS.MCharacter[nPers].bAlwaysBack) _ctx->bIsBack = true; _ctx->curVoc = SearchVoiceHeader(curDialog, nMsg); @@ -1965,14 +1909,14 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg if (_ctx->curVoc) { // Si posiziona all'interno del database delle voci all'inizio della prima - g_system->lockMutex(vdb); + g_system->lockMutex(GLOBALS.vdb); // fseek(_vm->m_vdbFP, _ctx->curVoc->offset, SEEK_SET); _vm->_vdbFP.seek(_ctx->curVoc->offset); _vm->_theSound.CreateSfx(&_ctx->voice); _ctx->voice->LoadVoiceFromVDB(_vm->_vdbFP); _ctx->voice->SetLoop(false); if (_ctx->bIsBack) _ctx->voice->SetVolume(55); - g_system->unlockMutex(vdb); + g_system->unlockMutex(GLOBALS.vdb); } _ctx->string = mpalQueryDialogPeriod(nMsg); @@ -1980,89 +1924,89 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg if (nPers == 0) { _ctx->text = new RMTextDialog; _ctx->text->SetColor(0,255,0); - _ctx->text->SetPosition(Tony->Position()-RMPoint(0,130)-Loc->ScrollPosition()); + _ctx->text->SetPosition(GLOBALS.Tony->Position()-RMPoint(0,130)-GLOBALS.Loc->ScrollPosition()); _ctx->text->WriteText(_ctx->string,0); - if (dwTonyNumTexts > 0) { - if (!bTonyInTexts) { - if (nTonyNextTalkType != Tony->TALK_NORMAL) { - CORO_INVOKE_1(Tony->StartTalk, nTonyNextTalkType); - if (!bStaticTalk) - nTonyNextTalkType = Tony->TALK_NORMAL; + if (GLOBALS.dwTonyNumTexts > 0) { + if (!GLOBALS.bTonyInTexts) { + if (GLOBALS.nTonyNextTalkType != GLOBALS.Tony->TALK_NORMAL) { + CORO_INVOKE_1(GLOBALS.Tony->StartTalk, GLOBALS.nTonyNextTalkType); + if (!GLOBALS.bStaticTalk) + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; } else - CORO_INVOKE_1(Tony->StartTalk, Tony->TALK_NORMAL); + CORO_INVOKE_1(GLOBALS.Tony->StartTalk, GLOBALS.Tony->TALK_NORMAL); - bTonyInTexts = true; + GLOBALS.bTonyInTexts = true; } - dwTonyNumTexts--; + GLOBALS.dwTonyNumTexts--; } else { - CORO_INVOKE_1(Tony->StartTalk, nTonyNextTalkType); - if (!bStaticTalk) - nTonyNextTalkType = Tony->TALK_NORMAL; + CORO_INVOKE_1(GLOBALS.Tony->StartTalk, GLOBALS.nTonyNextTalkType); + if (!GLOBALS.bStaticTalk) + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; } - } else if (!IsMChar[nPers]) { + } else if (!GLOBALS.IsMChar[nPers]) { _ctx->text = new RMTextDialog; - _ctx->pt = Character[nPers].item->CalculatePos() - RMPoint(-60, 20) - Loc->ScrollPosition(); + _ctx->pt = GLOBALS.Character[nPers].item->CalculatePos() - RMPoint(-60, 20) - GLOBALS.Loc->ScrollPosition(); - if (Character[nPers].starttalkpattern != 0) { - Freeze(); - Character[nPers].item->SetPattern(Character[nPers].starttalkpattern); - Unfreeze(); - CORO_INVOKE_0(Character[nPers].item->WaitForEndPattern); + if (GLOBALS.Character[nPers].starttalkpattern != 0) { + GLOBALS.Freeze(); + GLOBALS.Character[nPers].item->SetPattern(GLOBALS.Character[nPers].starttalkpattern); + GLOBALS.Unfreeze(); + CORO_INVOKE_0(GLOBALS.Character[nPers].item->WaitForEndPattern); } - Character[nPers].item->SetPattern(Character[nPers].talkpattern); + GLOBALS.Character[nPers].item->SetPattern(GLOBALS.Character[nPers].talkpattern); - _ctx->text->SetColor(Character[nPers].r, Character[nPers].g,Character[nPers].b); + _ctx->text->SetColor(GLOBALS.Character[nPers].r, GLOBALS.Character[nPers].g,GLOBALS.Character[nPers].b); _ctx->text->WriteText(_ctx->string, 0); _ctx->text->SetPosition(_ctx->pt); } else { - if (MCharacter[nPers].x == -1) - _ctx->pt = MCharacter[nPers].item->CalculatePos() - RMPoint(-60, 20) - Loc->ScrollPosition(); + if (GLOBALS.MCharacter[nPers].x == -1) + _ctx->pt = GLOBALS.MCharacter[nPers].item->CalculatePos() - RMPoint(-60, 20) - GLOBALS.Loc->ScrollPosition(); else - _ctx->pt = RMPoint(MCharacter[nPers].x, MCharacter[nPers].y); + _ctx->pt = RMPoint(GLOBALS.MCharacter[nPers].x, GLOBALS.MCharacter[nPers].y); // Parametro per le azioni speciali: random tra le parlate - _ctx->parm = (MCharacter[nPers].curgroup * 10) + _vm->_randomSource.getRandomNumber( - MCharacter[nPers].numtalks[MCharacter[nPers].curgroup] - 1) + 1; + _ctx->parm = (GLOBALS.MCharacter[nPers].curgroup * 10) + _vm->_randomSource.getRandomNumber( + GLOBALS.MCharacter[nPers].numtalks[GLOBALS.MCharacter[nPers].curgroup] - 1) + 1; - if (MCharacter[nPers].numtexts != 0 && MCharacter[nPers].bInTexts) { - MCharacter[nPers].numtexts--; + if (GLOBALS.MCharacter[nPers].numtexts != 0 && GLOBALS.MCharacter[nPers].bInTexts) { + GLOBALS.MCharacter[nPers].numtexts--; } else { // Cerca di eseguire la funzione custom per inizializzare la parlata - _ctx->h = mpalQueryDoAction(30, MCharacter[nPers].item->MpalCode(), _ctx->parm); + _ctx->h = mpalQueryDoAction(30, GLOBALS.MCharacter[nPers].item->MpalCode(), _ctx->parm); if (_ctx->h != CORO_INVALID_PID_VALUE) CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->h, CORO_INFINITE); - MCharacter[nPers].curTalk = _ctx->parm; + GLOBALS.MCharacter[nPers].curTalk = _ctx->parm; - if (MCharacter[nPers].numtexts != 0) { - MCharacter[nPers].bInTexts = true; - MCharacter[nPers].numtexts--; + if (GLOBALS.MCharacter[nPers].numtexts != 0) { + GLOBALS.MCharacter[nPers].bInTexts = true; + GLOBALS.MCharacter[nPers].numtexts--; } } - if (MCharacter[nPers].bAlwaysBack) { - _ctx->text = curBackText = new RMTextDialogScrolling(Loc); - if (bTonyIsSpeaking) - CORO_INVOKE_0(curBackText->Hide); + if (GLOBALS.MCharacter[nPers].bAlwaysBack) { + _ctx->text = GLOBALS.curBackText = new RMTextDialogScrolling(GLOBALS.Loc); + if (GLOBALS.bTonyIsSpeaking) + CORO_INVOKE_0(GLOBALS.curBackText->Hide); _ctx->bIsBack = true; } else _ctx->text = new RMTextDialog; - _ctx->text->SetSkipStatus(!MCharacter[nPers].bAlwaysBack); - _ctx->text->SetColor(MCharacter[nPers].r,MCharacter[nPers].g,MCharacter[nPers].b); + _ctx->text->SetSkipStatus(!GLOBALS.MCharacter[nPers].bAlwaysBack); + _ctx->text->SetColor(GLOBALS.MCharacter[nPers].r,GLOBALS.MCharacter[nPers].g,GLOBALS.MCharacter[nPers].b); _ctx->text->WriteText(_ctx->string,0); _ctx->text->SetPosition(_ctx->pt); } - if (!bSkipIdle) { - _ctx->text->SetInput(Input); - if (bAlwaysDisplay) { _ctx->text->SetAlwaysDisplay(); _ctx->text->ForceTime(); } + if (!GLOBALS.bSkipIdle) { + _ctx->text->SetInput(GLOBALS.Input); + if (GLOBALS.bAlwaysDisplay) { _ctx->text->SetAlwaysDisplay(); _ctx->text->ForceTime(); } _ctx->text->SetAlignType(RMText::HCENTER,RMText::VBOTTOM); - LinkGraphicTask(_ctx->text); + GLOBALS.LinkGraphicTask(_ctx->text); if (_ctx->curVoc) { _ctx->voice->Play(); @@ -2070,7 +2014,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg } // Aspetta la fine della visualizzazione - _ctx->text->SetCustomSkipHandle(hSkipIdle); + _ctx->text->SetCustomSkipHandle(GLOBALS.hSkipIdle); CORO_INVOKE_0(_ctx->text->WaitForEndDisplay); } @@ -2081,36 +2025,36 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg } if (nPers != 0) { - if (!IsMChar[nPers]) { - if (Character[nPers].endtalkpattern != 0) { - Freeze(); - Character[nPers].item->SetPattern(Character[nPers].endtalkpattern); - Unfreeze(); - CORO_INVOKE_0(Character[nPers].item->WaitForEndPattern); + if (!GLOBALS.IsMChar[nPers]) { + if (GLOBALS.Character[nPers].endtalkpattern != 0) { + GLOBALS.Freeze(); + GLOBALS.Character[nPers].item->SetPattern(GLOBALS.Character[nPers].endtalkpattern); + GLOBALS.Unfreeze(); + CORO_INVOKE_0(GLOBALS.Character[nPers].item->WaitForEndPattern); } - Character[nPers].item->SetPattern(Character[nPers].standpattern); + GLOBALS.Character[nPers].item->SetPattern(GLOBALS.Character[nPers].standpattern); delete _ctx->text; } else { - if ((MCharacter[nPers].bInTexts && MCharacter[nPers].numtexts== 0) || !MCharacter[nPers].bInTexts) { + if ((GLOBALS.MCharacter[nPers].bInTexts && GLOBALS.MCharacter[nPers].numtexts== 0) || !GLOBALS.MCharacter[nPers].bInTexts) { // Cerca di eseguire la funzione custom per chiudere la parlata - MCharacter[nPers].curTalk = (MCharacter[nPers].curTalk%10) + MCharacter[nPers].curgroup*10; - _ctx->h = mpalQueryDoAction(31,MCharacter[nPers].item->MpalCode(),MCharacter[nPers].curTalk); + GLOBALS.MCharacter[nPers].curTalk = (GLOBALS.MCharacter[nPers].curTalk%10) + GLOBALS.MCharacter[nPers].curgroup*10; + _ctx->h = mpalQueryDoAction(31,GLOBALS.MCharacter[nPers].item->MpalCode(),GLOBALS.MCharacter[nPers].curTalk); if (_ctx->h != CORO_INVALID_PID_VALUE) CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->h, CORO_INFINITE); - MCharacter[nPers].bInTexts = false; - MCharacter[nPers].numtexts = 0; + GLOBALS.MCharacter[nPers].bInTexts = false; + GLOBALS.MCharacter[nPers].numtexts = 0; } - curBackText = NULL; + GLOBALS.curBackText = NULL; delete _ctx->text; } } else { - if ((dwTonyNumTexts== 0 && bTonyInTexts) || !bTonyInTexts) { - CORO_INVOKE_0(Tony->EndTalk); - dwTonyNumTexts = 0; - bTonyInTexts = false; + if ((GLOBALS.dwTonyNumTexts== 0 && GLOBALS.bTonyInTexts) || !GLOBALS.bTonyInTexts) { + CORO_INVOKE_0(GLOBALS.Tony->EndTalk); + GLOBALS.dwTonyNumTexts = 0; + GLOBALS.bTonyInTexts = false; } delete _ctx->text; @@ -2172,18 +2116,18 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr } // Attiva l'oggetto - LinkGraphicTask(&_ctx->dc); + GLOBALS.LinkGraphicTask(&_ctx->dc); CORO_INVOKE_0(_ctx->dc.Show); // Disegna il puntatore - Pointer->SetSpecialPointer(Pointer->PTR_NONE); + GLOBALS.Pointer->SetSpecialPointer(GLOBALS.Pointer->PTR_NONE); MainShowMouse(); - while (!(Input->MouseLeftClicked() && ((_ctx->sel = _ctx->dc.GetSelection()) != -1))) { - CORO_INVOKE_0(WaitFrame); - Freeze(); - CORO_INVOKE_1(_ctx->dc.DoFrame, Input->MousePos()); - Unfreeze(); + while (!(GLOBALS.Input->MouseLeftClicked() && ((_ctx->sel = _ctx->dc.GetSelection()) != -1))) { + CORO_INVOKE_0(GLOBALS.WaitFrame); + GLOBALS.Freeze(); + CORO_INVOKE_1(_ctx->dc.DoFrame, GLOBALS.Input->MousePos()); + GLOBALS.Unfreeze(); } // Nascondi il puntatore @@ -2243,10 +2187,6 @@ DECLARE_CUSTOM_FUNCTION(ReleaseOwnership)(CORO_PARAM, uint32 num, uint32, uint32 * */ -int curSonoriz = 0; - -bool bFadeOutStop; - void ThreadFadeInMusic(CORO_PARAM, const void *nMusic) { CORO_BEGIN_CONTEXT; int i; @@ -2286,14 +2226,14 @@ void ThreadFadeOutMusic(CORO_PARAM, const void *nMusic) { debug("Start FadeOut Music"); - for (_ctx->i = 16; _ctx->i > 0 && !bFadeOutStop; _ctx->i--) { + for (_ctx->i = 16; _ctx->i > 0 && !GLOBALS.bFadeOutStop; _ctx->i--) { if (_ctx->i * 4 < _ctx->startVolume) _vm->SetMusicVolume(nChannel, _ctx->i * 4); CORO_INVOKE_1(CoroScheduler.sleep, 100); } - if (!bFadeOutStop) + if (!GLOBALS.bFadeOutStop) _vm->SetMusicVolume(nChannel, 0); // Se uno stacchetto ferma tutto @@ -2308,16 +2248,16 @@ void ThreadFadeOutMusic(CORO_PARAM, const void *nMusic) { } DECLARE_CUSTOM_FUNCTION(FadeInSonoriz)(CORO_PARAM, uint32, uint32, uint32, uint32) { - CoroScheduler.createProcess(ThreadFadeInMusic, &curSonoriz, sizeof(int)); + CoroScheduler.createProcess(ThreadFadeInMusic, &GLOBALS.curSonoriz, sizeof(int)); } DECLARE_CUSTOM_FUNCTION(FadeOutSonoriz)(CORO_PARAM, uint32, uint32, uint32, uint32) { - bFadeOutStop = false; - CoroScheduler.createProcess(ThreadFadeOutMusic, &curSonoriz, sizeof(int)); + GLOBALS.bFadeOutStop = false; + CoroScheduler.createProcess(ThreadFadeOutMusic, &GLOBALS.curSonoriz, sizeof(int)); } DECLARE_CUSTOM_FUNCTION(FadeOutStacchetto)(CORO_PARAM, uint32, uint32, uint32, uint32) { - bFadeOutStop = false; + GLOBALS.bFadeOutStop = false; int channel = 2; CoroScheduler.createProcess(ThreadFadeOutMusic, &channel, sizeof(int)); } @@ -2328,7 +2268,7 @@ DECLARE_CUSTOM_FUNCTION(FadeInStacchetto)(CORO_PARAM, uint32, uint32, uint32, ui } DECLARE_CUSTOM_FUNCTION(StopSonoriz)(CORO_PARAM, uint32, uint32, uint32, uint32) { - _vm->StopMusic(curSonoriz); + _vm->StopMusic(GLOBALS.curSonoriz); } DECLARE_CUSTOM_FUNCTION(StopStacchetto)(CORO_PARAM, uint32, uint32, uint32, uint32) { @@ -2336,12 +2276,12 @@ DECLARE_CUSTOM_FUNCTION(StopStacchetto)(CORO_PARAM, uint32, uint32, uint32, uint } DECLARE_CUSTOM_FUNCTION(MuteSonoriz)(CORO_PARAM, uint32, uint32, uint32, uint32) { - _vm->SetMusicVolume(curSonoriz, 0); + _vm->SetMusicVolume(GLOBALS.curSonoriz, 0); } DECLARE_CUSTOM_FUNCTION(DemuteSonoriz)(CORO_PARAM, uint32, uint32, uint32, uint32) { - bFadeOutStop = true; - _vm->SetMusicVolume(curSonoriz, 64); + GLOBALS.bFadeOutStop = true; + _vm->SetMusicVolume(GLOBALS.curSonoriz, 64); } DECLARE_CUSTOM_FUNCTION(MuteStacchetto)(CORO_PARAM, uint32, uint32, uint32, uint32) { @@ -2352,135 +2292,26 @@ DECLARE_CUSTOM_FUNCTION(DemuteStacchetto)(CORO_PARAM, uint32, uint32, uint32, ui _vm->SetMusicVolume(2, 64); } -struct MusicFileEntry { - const char *name; - int sync; -}; -const MusicFileEntry musicFiles[] = { -/* - { "PREGAME1.ADP", 0 }, { "SONO1.ADP", 0 }, - { "SONO2.ADP", 0 }, { "SONO3.ADP", 0 }, - { "CADUTA.ADP",0 }, { "RISVEGLIO.ADP", 0 }, - { "BACKGROUND.ADP", 0 }, { "PREGAME3.ADP", 0 }, - { "BARBUTA1.ADP", 2450 }, { "BARBUTA2.ADP", 0 }, -*/ - { "00.ADP", 0 }, { "01.ADP", 0 }, - { "02.ADP", 0 }, { "03.ADP", 0 }, - { "04.ADP",0 }, { "05.ADP", 0 }, - { "06.ADP", 0 }, { "07.ADP", 0 }, - { "08.ADP", 2450 }, { "09.ADP", 0 }, - -/* - { "BARBUTA3.ADP", 0 }, { "15-RUFUS.ADP", 0 }, - { "20-MAMMA.ADP", 0 }, { "32-MAMMARADIO.ADP", 0 }, - { "24-TUNNELOV-MIDI.ADP", 0 }, { "34-RAZZO.ADP", 0 }, - { "27-ZUCC1.ADP", 0 }, { "BEAST.ADP", 0 }, - { "22-MORTIMER.ADP", 0 }, { "25-PUB-OVATTATO.ADP", 0 }, -*/ - { "10.ADP", 0 }, { "11.ADP", 0 }, - { "12.ADP", 0 }, { "13.ADP", 0 }, - { "14.ADP", 0 }, { "15.ADP", 0 }, - { "16.ADP", 0 }, { "17.ADP", 0 }, - { "18.ADP", 0 }, { "19.ADP", 0 }, -/* - { "25-PUB.ADP", 0 }, { "ALBERGO.ADP", 0 }, - { "37.ADP", 0 }, { "26-PIRAT.ADP", 0 }, - { "LORENZBACK.ADP", 0 }, { "LORENZ3.ADP", 0 }, - { "CASTLE.ADP", 0 }, { "53-BACKR.ADP", 0 }, - { "16-SMIL1.ADP", 1670 }, { "16-SMIL2.ADP", 0 }, -*/ - { "20.ADP", 0 }, { "21.ADP", 0 }, - { "22.ADP", 0 }, { "23.ADP", 0 }, - { "24.ADP", 0 }, { "25.ADP", 0 }, - { "26.ADP", 0 }, { "27.ADP", 0 }, - { "28.ADP", 1670 }, { "29.ADP", 0 }, -/* - { "16-SMILE.ADP", 0 }, { "16-DIALOG2.ADP", 0 }, - { "07-SHAKE1.ADP", 2900 }, { "07-SHAKE2.ADP", 0 }, - { "07-SHAKE3.ADP", 0 }, { "46-BEEE.ADP", 0 }, - { "434748.ADP", 0 }, { "TORRE.ADP", 0 }, - { "50-DRAGO.ADP", 0 }, { "56-OPERA.ADP", 0 }, -*/ - { "30.ADP", 0 }, { "31.ADP", 0 }, - { "32.ADP", 2900 }, { "33.ADP", 0 }, - { "34.ADP", 0 }, { "35.ADP", 0 }, - { "36.ADP", 0 }, { "37.ADP", 0 }, - { "38.ADP", 0 }, { "39.ADP", 0 }, -/* - { "FLAUTARP.ADP", 0 }, { "01-2001.ADP", 1920 }, - { "02-INTROPANORAMICA.ADP", 1560 }, { "03-PANORAMICA.ADP", 1920 }, - { "04-INTERNI.ADP", 1920 }, { "05-CADEPIUMA.ADP", 1920 }, - { "06-SCENDESCALE.ADP", 1920 }, { "07-THRILL.ADP", 1920 }, - { "08-CADUTAZUCCA.ADP", 1920 }, { "09-PIUMAALEGGIA.ADP", 1920 }, -*/ - { "40.ADP", 0 }, { "41.ADP", 1920 }, - { "42.ADP", 1560 }, { "43.ADP", 1920 }, - { "44.ADP", 1920 }, { "45.ADP", 1920 }, - { "46.ADP", 1920 }, { "47.ADP", 1920 }, - { "48.ADP", 1920 }, { "49.ADP", 1920 }, - -/* - { "10-JACKZUCCONA.ADP", 1920 }, { "11-JACKIMPRECAALLAGRANDELUNA.ADP", 1920 }, - { "12-GRANDELUNALOGO.ADP", 1920 }, { "60-BACKGROUND.ADP", 0 }, - { "TONYSTAR.ADP", 0 }, { "FUNNY.ADP", 0 }, - { "60-INIZIODIALOGO.ADP", 0 }, { "60-DIALOGO.ADP", 0 }, - { "60-JACKFELICE.ADP", 0 }, { "24-TONYVIOLENTATO.ADP", 0 } -*/ - { "50.ADP", 1920 }, { "51.ADP", 1920 }, - { "52.ADP", 1920 }, { "53.ADP", 0 }, - { "54.ADP", 0 }, { "55.ADP", 0 }, - { "56.ADP", 0 }, { "57.ADP", 0 }, - { "58.ADP", 0 }, { "59.ADP", 0 } -}; - - -const char *staccFileNames[] = { -/* - "05-MUCCA.ADP", "06-HALOW.ADP", - "LETTERAINIZIO.ADP", "LETTERAPAURA.ADP", - "LETTERAFINE.ADP", "PREGAME2.ADP", - "07-TIMOT.ADP", "15-SHOTRUFUS.ADP", - "15-SHOTTONY.ADP", "27-ZUCC2.ADP", -*/ - "S00.ADP", "S01.ADP", - "S02.ADP", "S03.ADP", - "S04.ADP", "S05.ADP", - "S06.ADP", "S07.ADP", - "S08.ADP", "S09.ADP", - -/* - "53-DLOGO.ADP", "16-DIALOG1.ADP", - "TORRE1.ADP", "GARG1.ADP", - "LORENZ1.ADP", "24-FIGHT.ADP", - "08-MACBETH-PREPARA.ADP", "08-MACBETH-RECITA.ADP", - "GATTO1.ADP" -*/ - "S10.ADP", "S11.ADP", - "S12.ADP", "S13.ADP", - "S14.ADP", "S15.ADP", - "S16.ADP", "S17.ADP", - "S18.ADP" -}; void CustPlayMusic(uint32 nChannel, const char *mFN, uint32 nFX, bool bLoop, int nSync = 0) { if (nSync == 0) nSync = 2000; debug("Start CustPlayMusic"); - PlayMusic(nChannel, mFN, nFX, bLoop, nSync); + GLOBALS.PlayMusic(nChannel, mFN, nFX, bLoop, nSync); debug("End CustPlayMusic"); } DECLARE_CUSTOM_FUNCTION(PlaySonoriz)(CORO_PARAM, uint32 nMusic, uint32 nFX, uint32 bNoLoop, uint32) { if (nFX == 0 || nFX == 1 || nFX==2) { debug("PlaySonoriz stop fadeout"); - bFadeOutStop = true; + GLOBALS.bFadeOutStop = true; } - lastMusic = nMusic; - CustPlayMusic(curSonoriz, musicFiles[nMusic].name, nFX, bNoLoop ? false : true, musicFiles[nMusic].sync); + GLOBALS.lastMusic = nMusic; + CustPlayMusic(GLOBALS.curSonoriz, musicFiles[nMusic].name, nFX, bNoLoop ? false : true, musicFiles[nMusic].sync); } DECLARE_CUSTOM_FUNCTION(PlayStacchetto)(CORO_PARAM, uint32 nMusic, uint32 nFX, uint32 bLoop, uint32) { @@ -2489,9 +2320,9 @@ DECLARE_CUSTOM_FUNCTION(PlayStacchetto)(CORO_PARAM, uint32 nMusic, uint32 nFX, u DECLARE_CUSTOM_FUNCTION(PlayItemSfx)(CORO_PARAM, uint32 nItem, uint32 nSFX, uint32, uint32) { if (nItem== 0) { - Tony->PlaySfx(nSFX); + GLOBALS.Tony->PlaySfx(nSFX); } else { - RMItem *item = Loc->GetItemFromCode(nItem); + RMItem *item = GLOBALS.Loc->GetItemFromCode(nItem); if (item) item->PlaySfx(nSFX); } @@ -2504,22 +2335,22 @@ void RestoreMusic(CORO_PARAM) { CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_4(PlaySonoriz, lastMusic, 0, 0, 0); + CORO_INVOKE_4(PlaySonoriz, GLOBALS.lastMusic, 0, 0, 0); - if (lastTappeto != 0) - CustPlayMusic(4, tappetiFile[lastTappeto], 0, true); + if (GLOBALS.lastTappeto != 0) + CustPlayMusic(4, tappetiFile[GLOBALS.lastTappeto], 0, true); CORO_END_CODE; } void SaveMusic(Common::OutSaveFile *f) { - f->writeByte(lastMusic); - f->writeByte(lastTappeto); + f->writeByte(GLOBALS.lastMusic); + f->writeByte(GLOBALS.lastTappeto); } void LoadMusic(Common::InSaveFile *f) { - lastMusic = f->readByte(); - lastTappeto = f->readByte(); + GLOBALS.lastMusic = f->readByte(); + GLOBALS.lastTappeto = f->readByte(); } @@ -2553,17 +2384,17 @@ DECLARE_CUSTOM_FUNCTION(StacchettoFadeEnd)(CORO_PARAM, uint32 nStacc, uint32 bLo DECLARE_CUSTOM_FUNCTION(MustSkipIdleStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { - bSkipIdle = true; - CoroScheduler.setEvent(hSkipIdle); + GLOBALS.bSkipIdle = true; + CoroScheduler.setEvent(GLOBALS.hSkipIdle); } DECLARE_CUSTOM_FUNCTION(MustSkipIdleEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { - bSkipIdle = false; - CoroScheduler.resetEvent(hSkipIdle); + GLOBALS.bSkipIdle = false; + CoroScheduler.resetEvent(GLOBALS.hSkipIdle); } DECLARE_CUSTOM_FUNCTION(PatIrqFreeze)(CORO_PARAM, uint32 bStatus, uint32, uint32, uint32) { - bPatIrqFreeze = bStatus; + GLOBALS.bPatIrqFreeze = bStatus; } DECLARE_CUSTOM_FUNCTION(OpenInitLoadMenu)(CORO_PARAM, uint32, uint32, uint32, uint32) { @@ -2572,9 +2403,9 @@ DECLARE_CUSTOM_FUNCTION(OpenInitLoadMenu)(CORO_PARAM, uint32, uint32, uint32, ui CORO_BEGIN_CODE(_ctx); - Freeze(); + GLOBALS.Freeze(); CORO_INVOKE_0(_vm->OpenInitLoadMenu); - Unfreeze(); + GLOBALS.Unfreeze(); CORO_END_CODE; } @@ -2585,9 +2416,9 @@ DECLARE_CUSTOM_FUNCTION(OpenInitOptions)(CORO_PARAM, uint32, uint32, uint32, uin CORO_BEGIN_CODE(_ctx); - Freeze(); + GLOBALS.Freeze(); CORO_INVOKE_0(_vm->OpenInitOptions); - Unfreeze(); + GLOBALS.Unfreeze(); CORO_END_CODE; } @@ -2610,7 +2441,7 @@ DECLARE_CUSTOM_FUNCTION(DoCredits)(CORO_PARAM, uint32 nMsg, uint32 dwTime, uint3 _ctx->text = new RMTextDialog[_ctx->msg->NumPeriods()]; for (_ctx->i = 0; _ctx->i < _ctx->msg->NumPeriods(); _ctx->i++) { - _ctx->text[_ctx->i].SetInput(Input); + _ctx->text[_ctx->i].SetInput(GLOBALS.Input); // Alignment if ((*_ctx->msg)[_ctx->i][0] == '@') { @@ -2633,14 +2464,14 @@ DECLARE_CUSTOM_FUNCTION(DoCredits)(CORO_PARAM, uint32 nMsg, uint32 dwTime, uint3 _ctx->text[_ctx->i].SetCustomSkipHandle(_ctx->hDisable); // Registra il testo - LinkGraphicTask(&_ctx->text[_ctx->i]); + GLOBALS.LinkGraphicTask(&_ctx->text[_ctx->i]); } _ctx->startTime = _vm->GetTime(); while (_ctx->startTime + dwTime * 1000 > _vm->GetTime()) { - CORO_INVOKE_0(WaitFrame); - if (Input->MouseLeftClicked() || Input->MouseRightClicked()) + CORO_INVOKE_0(GLOBALS.WaitFrame); + if (GLOBALS.Input->MouseLeftClicked() || GLOBALS.Input->MouseRightClicked()) break; if (_vm->GetEngine()->GetInput().GetAsyncKeyState(Common::KEYCODE_TAB)) break; @@ -2648,8 +2479,8 @@ DECLARE_CUSTOM_FUNCTION(DoCredits)(CORO_PARAM, uint32 nMsg, uint32 dwTime, uint3 CoroScheduler.setEvent(_ctx->hDisable); - CORO_INVOKE_0(WaitFrame); - CORO_INVOKE_0(WaitFrame); + CORO_INVOKE_0(GLOBALS.WaitFrame); + CORO_INVOKE_0(GLOBALS.WaitFrame); delete[] _ctx->text; delete _ctx->msg; @@ -2809,77 +2640,76 @@ BEGIN_CUSTOM_FUNCTION_MAP() END_CUSTOM_FUNCTION_MAP() void SetupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation *loc, RMInventory *inv, RMInput *input) { - Tony = tony; - Pointer = ptr; - Boxes = box; - Loc = loc; - Inventory = inv; - Input = input; - - LoadLocation = MainLoadLocation; - UnloadLocation = MainUnloadLocation; - LinkGraphicTask = MainLinkGraphicTask; - Freeze = MainFreeze; - Unfreeze = MainUnfreeze; - WaitFrame = MainWaitFrame; - PlayMusic = MainPlayMusic; - InitWipe = MainInitWipe; - CloseWipe = MainCloseWipe; - WaitWipeEnd = MainWaitWipeEnd; - DisableGUI = MainDisableGUI; - EnableGUI = MainEnableGUI; - SetPalesati = MainSetPalesati; - - vdb = g_system->createMutex(); - - bAlwaysDisplay = false; + GLOBALS.Tony = tony; + GLOBALS.Pointer = ptr; + GLOBALS.Boxes = box; + GLOBALS.Loc = loc; + GLOBALS.Inventory = inv; + GLOBALS.Input = input; + + GLOBALS.LoadLocation = MainLoadLocation; + GLOBALS.UnloadLocation = MainUnloadLocation; + GLOBALS.LinkGraphicTask = MainLinkGraphicTask; + GLOBALS.Freeze = MainFreeze; + GLOBALS.Unfreeze = MainUnfreeze; + GLOBALS.WaitFrame = MainWaitFrame; + GLOBALS.PlayMusic = MainPlayMusic; + GLOBALS.InitWipe = MainInitWipe; + GLOBALS.CloseWipe = MainCloseWipe; + GLOBALS.WaitWipeEnd = MainWaitWipeEnd; + GLOBALS.DisableGUI = MainDisableGUI; + GLOBALS.EnableGUI = MainEnableGUI; + GLOBALS.SetPalesati = MainSetPalesati; + + GLOBALS.vdb = g_system->createMutex(); + + GLOBALS.bAlwaysDisplay = false; int i; - for (i = 0;i < 10; i++) +/* for (i = 0;i < 10; i++) cs[i] = g_system->createMutex(); -/* for (i = 0;i < 10; i++) mut[i] = CreateMutex(NULL, false, NULL); */ for (i = 0; i < 200; i++) - tappeti[i] = 0; - - tappeti[6] = T_GRILLI; - tappeti[7] = T_GRILLI; - tappeti[8] = T_GRILLIOV; - tappeti[10] = T_GRILLI; - tappeti[12] = T_GRILLI; - tappeti[13] = T_GRILLIOV; - tappeti[15] = T_GRILLI; - tappeti[16] = T_GRILLIVENTO; - tappeti[18] = T_GRILLI; - tappeti[19] = T_GRILLIVENTO; - tappeti[20] = T_GRILLI; - tappeti[23] = T_GRILLI; - tappeti[26] = T_MAREMETA; - tappeti[27] = T_GRILLI; - tappeti[28] = T_GRILLIVENTO; - tappeti[31] = T_GRILLI; - tappeti[33] = T_MARE; - tappeti[35] = T_MARE; - tappeti[36] = T_GRILLI; - tappeti[37] = T_GRILLI; - tappeti[40] = T_GRILLI; - tappeti[41] = T_GRILLI; - tappeti[42] = T_GRILLI; - tappeti[45] = T_GRILLI; - tappeti[51] = T_GRILLI; - tappeti[52] = T_GRILLIVENTO1; - tappeti[53] = T_GRILLI; - tappeti[54] = T_GRILLI; - tappeti[57] = T_VENTO; - tappeti[58] = T_VENTO; - tappeti[60] = T_VENTO; + GLOBALS.tappeti[i] = 0; + + GLOBALS.tappeti[6] = T_GRILLI; + GLOBALS.tappeti[7] = T_GRILLI; + GLOBALS.tappeti[8] = T_GRILLIOV; + GLOBALS.tappeti[10] = T_GRILLI; + GLOBALS.tappeti[12] = T_GRILLI; + GLOBALS.tappeti[13] = T_GRILLIOV; + GLOBALS.tappeti[15] = T_GRILLI; + GLOBALS.tappeti[16] = T_GRILLIVENTO; + GLOBALS.tappeti[18] = T_GRILLI; + GLOBALS.tappeti[19] = T_GRILLIVENTO; + GLOBALS.tappeti[20] = T_GRILLI; + GLOBALS.tappeti[23] = T_GRILLI; + GLOBALS.tappeti[26] = T_MAREMETA; + GLOBALS.tappeti[27] = T_GRILLI; + GLOBALS.tappeti[28] = T_GRILLIVENTO; + GLOBALS.tappeti[31] = T_GRILLI; + GLOBALS.tappeti[33] = T_MARE; + GLOBALS.tappeti[35] = T_MARE; + GLOBALS.tappeti[36] = T_GRILLI; + GLOBALS.tappeti[37] = T_GRILLI; + GLOBALS.tappeti[40] = T_GRILLI; + GLOBALS.tappeti[41] = T_GRILLI; + GLOBALS.tappeti[42] = T_GRILLI; + GLOBALS.tappeti[45] = T_GRILLI; + GLOBALS.tappeti[51] = T_GRILLI; + GLOBALS.tappeti[52] = T_GRILLIVENTO1; + GLOBALS.tappeti[53] = T_GRILLI; + GLOBALS.tappeti[54] = T_GRILLI; + GLOBALS.tappeti[57] = T_VENTO; + GLOBALS.tappeti[58] = T_VENTO; + GLOBALS.tappeti[60] = T_VENTO; // Crea l'evento per skippare le idle - hSkipIdle = CoroScheduler.createEvent(true, false); + GLOBALS.hSkipIdle = CoroScheduler.createEvent(true, false); } } // end of namespace Tony diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index f7f3fb3f8c..dee3c3228a 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -2003,7 +2003,7 @@ void RMText::WriteText(const RMString &text, RMFontColor *font, int *time) { } if (time != NULL) - *time = 1000 + numchar * (11 - nCfgTextSpeed) * 14; + *time = 1000 + numchar * (11 - GLOBALS.nCfgTextSpeed) * 14; } void RMText::ClipOnScreen(RMGfxPrimitive *prim) { @@ -2128,8 +2128,8 @@ void RMTextDialog::RemoveThis(CORO_PARAM, bool &result) { // Frase NON di background if (m_bSkipStatus) { - if (!(bCfgDubbing && hCustomSkip2 != CORO_INVALID_PID_VALUE)) - if (bCfgTimerizedText) { + if (!(GLOBALS.bCfgDubbing && hCustomSkip2 != CORO_INVALID_PID_VALUE)) + if (GLOBALS.bCfgTimerizedText) { if (!m_bForceNoTime) if (_vm->GetTime() > (uint32)m_time + m_startTime) return; @@ -2146,7 +2146,7 @@ void RMTextDialog::RemoveThis(CORO_PARAM, bool &result) { } // Frase di background else { - if (!(bCfgDubbing && hCustomSkip2 != CORO_INVALID_PID_VALUE)) + if (!(GLOBALS.bCfgDubbing && hCustomSkip2 != CORO_INVALID_PID_VALUE)) if (!m_bForceNoTime) if (_vm->GetTime() > (uint32)m_time + m_startTime) return; @@ -2164,7 +2164,7 @@ void RMTextDialog::RemoveThis(CORO_PARAM, bool &result) { return; } - if (bCfgDubbing && hCustomSkip2 != CORO_INVALID_PID_VALUE) { + if (GLOBALS.bCfgDubbing && hCustomSkip2 != CORO_INVALID_PID_VALUE) { CORO_INVOKE_3(CoroScheduler.waitForSingleObject, hCustomSkip2, 0, &_ctx->expired); // == WAIT_OBJECT_0 if (!_ctx->expired) @@ -2192,7 +2192,7 @@ void RMTextDialog::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *p m_startTime = _vm->GetTime(); if (m_bShowed) { - if (bCfgSottotitoli || m_bAlwaysDisplay) { + if (GLOBALS.bCfgSottotitoli || m_bAlwaysDisplay) { prim->Dst().TopLeft() = dst; CORO_INVOKE_2(RMText::Draw, bigBuf, prim); } diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 758170c848..b21498a5e8 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -62,32 +62,6 @@ namespace Tony { using namespace MPAL; -/****************************************/ -/* Variabili globali di configurazione */ -/****************************************/ - -// FIXME: Move into a class instance -bool bCfgInvLocked; -bool bCfgInvNoScroll; -bool bCfgTimerizedText; -bool bCfgInvUp; -bool bCfgAnni30; -bool bCfgAntiAlias; -bool bCfgSottotitoli; -bool bCfgTransparence; -bool bCfgInterTips; -bool bCfgDubbing; -bool bCfgMusic; -bool bCfgSFX; -int nCfgTonySpeed; -int nCfgTextSpeed; -int nCfgDubbingVolume; -int nCfgMusicVolume; -int nCfgSFXVolume; -bool bSkipSfxNoLoop; - -bool bPatIrqFreeze; - /****************************************/ /* Funzioni globali per la DLL Custom */ /****************************************/ @@ -699,57 +673,57 @@ void RMOptionScreen::InitState(CORO_PARAM) { if (m_nState == MENUGAME) { assert(m_ButtonGame_Lock == NULL); m_ButtonGame_Lock = new RMOptionButton(20008,RMPoint(176, 262), true); - m_ButtonGame_Lock->SetActiveState(bCfgInvLocked); + m_ButtonGame_Lock->SetActiveState(GLOBALS.bCfgInvLocked); assert(m_ButtonGame_TimerizedText == NULL); m_ButtonGame_TimerizedText = new RMOptionButton(20009,RMPoint(463, 273), true); - m_ButtonGame_TimerizedText->SetActiveState(!bCfgTimerizedText); + m_ButtonGame_TimerizedText->SetActiveState(!GLOBALS.bCfgTimerizedText); assert(m_ButtonGame_Scrolling == NULL); m_ButtonGame_Scrolling = new RMOptionButton(20010, RMPoint(315, 263), true); - m_ButtonGame_Scrolling->SetActiveState(bCfgInvNoScroll); + m_ButtonGame_Scrolling->SetActiveState(GLOBALS.bCfgInvNoScroll); assert(m_ButtonGame_InterUp == NULL); m_ButtonGame_InterUp = new RMOptionButton(20011,RMPoint(36, 258), true); - m_ButtonGame_InterUp->SetActiveState(bCfgInvUp); + m_ButtonGame_InterUp->SetActiveState(GLOBALS.bCfgInvUp); assert(m_SlideTextSpeed == NULL); - m_SlideTextSpeed = new RMOptionSlide(RMPoint(165, 122), 10, nCfgTextSpeed); + m_SlideTextSpeed = new RMOptionSlide(RMPoint(165, 122), 10, GLOBALS.nCfgTextSpeed); assert(m_SlideTonySpeed == NULL); - m_SlideTonySpeed = new RMOptionSlide(RMPoint(165, 226), 5, nCfgTonySpeed); + m_SlideTonySpeed = new RMOptionSlide(RMPoint(165, 226), 5, GLOBALS.nCfgTonySpeed); } // Menu Graphics else if (m_nState == MENUGFX) { assert(m_ButtonGfx_Anni30 == NULL); m_ButtonGfx_Anni30 = new RMOptionButton(20015,RMPoint(247, 178), true); - m_ButtonGfx_Anni30->SetActiveState(bCfgAnni30); + m_ButtonGfx_Anni30->SetActiveState(GLOBALS.bCfgAnni30); assert(m_ButtonGfx_AntiAlias == NULL); m_ButtonGfx_AntiAlias = new RMOptionButton(20016, RMPoint(430, 83), true); - m_ButtonGfx_AntiAlias->SetActiveState(!bCfgAntiAlias); + m_ButtonGfx_AntiAlias->SetActiveState(!GLOBALS.bCfgAntiAlias); assert(m_ButtonGfx_Sottotitoli == NULL); m_ButtonGfx_Sottotitoli = new RMOptionButton(20017,RMPoint(98, 82), true); - m_ButtonGfx_Sottotitoli->SetActiveState(!bCfgSottotitoli); + m_ButtonGfx_Sottotitoli->SetActiveState(!GLOBALS.bCfgSottotitoli); assert(m_ButtonGfx_Tips == NULL); m_ButtonGfx_Tips = new RMOptionButton(20018,RMPoint(431, 246), true); - m_ButtonGfx_Tips->SetActiveState(bCfgInterTips); + m_ButtonGfx_Tips->SetActiveState(GLOBALS.bCfgInterTips); assert(m_ButtonGfx_Trans == NULL); m_ButtonGfx_Trans = new RMOptionButton(20019,RMPoint(126, 271), true); - m_ButtonGfx_Trans->SetActiveState(!bCfgTransparence); + m_ButtonGfx_Trans->SetActiveState(!GLOBALS.bCfgTransparence); } else if (m_nState == MENUSOUND) { assert(m_SliderSound_Dubbing == NULL); - m_SliderSound_Dubbing = new RMOptionSlide(RMPoint(165, 122), 10, nCfgDubbingVolume); + m_SliderSound_Dubbing = new RMOptionSlide(RMPoint(165, 122), 10, GLOBALS.nCfgDubbingVolume); assert(m_SliderSound_Music == NULL); - m_SliderSound_Music = new RMOptionSlide(RMPoint(165, 226), 10, nCfgMusicVolume); + m_SliderSound_Music = new RMOptionSlide(RMPoint(165, 226), 10, GLOBALS.nCfgMusicVolume); assert(m_SliderSound_SFX == NULL); - m_SliderSound_SFX = new RMOptionSlide(RMPoint(165, 330), 10, nCfgSFXVolume); + m_SliderSound_SFX = new RMOptionSlide(RMPoint(165, 330), 10, GLOBALS.nCfgSFXVolume); assert(m_ButtonSound_DubbingOn == NULL); m_ButtonSound_DubbingOn = new RMOptionButton(20033, RMPoint(339, 75), true); - m_ButtonSound_DubbingOn->SetActiveState(bCfgDubbing); + m_ButtonSound_DubbingOn->SetActiveState(GLOBALS.bCfgDubbing); assert(m_ButtonSound_MusicOn == NULL); m_ButtonSound_MusicOn = new RMOptionButton(20034,RMPoint(338, 179), true); - m_ButtonSound_MusicOn->SetActiveState(bCfgMusic); + m_ButtonSound_MusicOn->SetActiveState(GLOBALS.bCfgMusic); assert(m_ButtonSound_SFXOn == NULL); m_ButtonSound_SFXOn = new RMOptionButton(20035,RMPoint(338, 283), true); - m_ButtonSound_SFXOn->SetActiveState(bCfgSFX); + m_ButtonSound_SFXOn->SetActiveState(GLOBALS.bCfgSFX); } } @@ -815,71 +789,71 @@ void RMOptionScreen::CloseState(void) { } if (m_nState == MENUGAME) { - bCfgInvLocked = m_ButtonGame_Lock->IsActive(); + GLOBALS.bCfgInvLocked = m_ButtonGame_Lock->IsActive(); delete m_ButtonGame_Lock; m_ButtonGame_Lock = NULL; - bCfgTimerizedText = !m_ButtonGame_TimerizedText->IsActive(); + GLOBALS.bCfgTimerizedText = !m_ButtonGame_TimerizedText->IsActive(); delete m_ButtonGame_TimerizedText; m_ButtonGame_TimerizedText = NULL; - bCfgInvNoScroll = m_ButtonGame_Scrolling->IsActive(); + GLOBALS.bCfgInvNoScroll = m_ButtonGame_Scrolling->IsActive(); delete m_ButtonGame_Scrolling; m_ButtonGame_Scrolling = NULL; - bCfgInvUp = m_ButtonGame_InterUp->IsActive(); + GLOBALS.bCfgInvUp = m_ButtonGame_InterUp->IsActive(); delete m_ButtonGame_InterUp; m_ButtonGame_InterUp = NULL; - nCfgTextSpeed = m_SlideTextSpeed->GetValue(); + GLOBALS.nCfgTextSpeed = m_SlideTextSpeed->GetValue(); delete m_SlideTextSpeed; m_SlideTextSpeed = NULL; - nCfgTonySpeed = m_SlideTonySpeed->GetValue(); + GLOBALS.nCfgTonySpeed = m_SlideTonySpeed->GetValue(); delete m_SlideTonySpeed; m_SlideTonySpeed = NULL; } else if (m_nState == MENUGFX) { - bCfgAnni30 = m_ButtonGfx_Anni30->IsActive(); + GLOBALS.bCfgAnni30 = m_ButtonGfx_Anni30->IsActive(); delete m_ButtonGfx_Anni30; m_ButtonGfx_Anni30 = NULL; - bCfgAntiAlias = !m_ButtonGfx_AntiAlias->IsActive(); + GLOBALS.bCfgAntiAlias = !m_ButtonGfx_AntiAlias->IsActive(); delete m_ButtonGfx_AntiAlias; m_ButtonGfx_AntiAlias = NULL; - bCfgSottotitoli = !m_ButtonGfx_Sottotitoli->IsActive(); + GLOBALS.bCfgSottotitoli = !m_ButtonGfx_Sottotitoli->IsActive(); delete m_ButtonGfx_Sottotitoli; m_ButtonGfx_Sottotitoli = NULL; - bCfgInterTips = m_ButtonGfx_Tips->IsActive(); + GLOBALS.bCfgInterTips = m_ButtonGfx_Tips->IsActive(); delete m_ButtonGfx_Tips; m_ButtonGfx_Tips = NULL; - bCfgTransparence = !m_ButtonGfx_Trans->IsActive(); + GLOBALS.bCfgTransparence = !m_ButtonGfx_Trans->IsActive(); delete m_ButtonGfx_Trans; m_ButtonGfx_Trans = NULL; } else if (m_nState == MENUSOUND) { - nCfgDubbingVolume = m_SliderSound_Dubbing->GetValue(); + GLOBALS.nCfgDubbingVolume = m_SliderSound_Dubbing->GetValue(); delete m_SliderSound_Dubbing; m_SliderSound_Dubbing = NULL; - nCfgMusicVolume = m_SliderSound_Music->GetValue(); + GLOBALS.nCfgMusicVolume = m_SliderSound_Music->GetValue(); delete m_SliderSound_Music; m_SliderSound_Music = NULL; - nCfgSFXVolume = m_SliderSound_SFX->GetValue(); + GLOBALS.nCfgSFXVolume = m_SliderSound_SFX->GetValue(); delete m_SliderSound_SFX; m_SliderSound_SFX = NULL; - bCfgDubbing = m_ButtonSound_DubbingOn->IsActive(); + GLOBALS.bCfgDubbing = m_ButtonSound_DubbingOn->IsActive(); delete m_ButtonSound_DubbingOn; m_ButtonSound_DubbingOn = NULL; - bCfgMusic = m_ButtonSound_MusicOn->IsActive(); + GLOBALS.bCfgMusic = m_ButtonSound_MusicOn->IsActive(); delete m_ButtonSound_MusicOn; m_ButtonSound_MusicOn = NULL; - bCfgSFX = m_ButtonSound_SFXOn->IsActive(); + GLOBALS.bCfgSFX = m_ButtonSound_SFXOn->IsActive(); delete m_ButtonSound_SFXOn; m_ButtonSound_SFXOn = NULL; } @@ -1261,19 +1235,19 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { if (m_nState == MENUGFX) { // Queste opzioni hanno effetto immediato if (m_ButtonGfx_Anni30->IsActive()) - bCfgAnni30 = true; + GLOBALS.bCfgAnni30 = true; else - bCfgAnni30 = false; + GLOBALS.bCfgAnni30 = false; if (m_ButtonGfx_AntiAlias->IsActive()) - bCfgAntiAlias = false; + GLOBALS.bCfgAntiAlias = false; else - bCfgAntiAlias = true; + GLOBALS.bCfgAntiAlias = true; if (m_ButtonGfx_Trans->IsActive()) - bCfgTransparence = false; + GLOBALS.bCfgTransparence = false; else - bCfgTransparence = true; + GLOBALS.bCfgTransparence = true; } } } diff --git a/engines/tony/game.h b/engines/tony/game.h index 8cd64ec7d2..80482f39da 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -72,26 +72,6 @@ namespace Tony { (buf8)->Init(*raw, raw->Width(), raw->Height(), true); \ delete raw; -extern bool bCfgInvLocked; -extern bool bCfgInvNoScroll; -extern bool bCfgTimerizedText; -extern bool bCfgInvUp; -extern bool bCfgAnni30; -extern bool bCfgAntiAlias; -extern bool bCfgSottotitoli; -extern bool bCfgTransparence; -extern bool bCfgInterTips; -extern bool bCfgDubbing; -extern bool bCfgMusic; -extern bool bCfgSFX; -extern int nCfgTonySpeed; -extern int nCfgTextSpeed; -extern int nCfgDubbingVolume; -extern int nCfgMusicVolume; -extern int nCfgSFXVolume; -extern bool bSkipSfxNoLoop; - -extern bool bPatIrqFreeze; class RMPointer : public RMGfxTask { private: diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 49dd36cfe7..0c5ffa8096 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -47,6 +47,7 @@ #include "tony/gfxengine.h" #include "tony/mpal/mpalutils.h" +#include "tony/tony.h" namespace Tony { @@ -1437,7 +1438,7 @@ void RMGfxSourceBuffer8RLEWordAB::RLEDecompressLine(uint16 *dst, byte *src, int int i, n; int r, g, b, r2, g2, b2; - if (!bCfgTransparence) { + if (!GLOBALS.bCfgTransparence) { RMGfxSourceBuffer8RLEWord::RLEDecompressLine(dst, src, nStartSkip, nLength); return; } @@ -1799,7 +1800,7 @@ void RMGfxSourceBuffer8RLEByteAA::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RM CORO_BEGIN_CODE(_ctx); CORO_INVOKE_2(RMGfxSourceBuffer8RLE::Draw, bigBuf, prim); - if (bCfgAntiAlias) + if (GLOBALS.bCfgAntiAlias) DrawAA(bigBuf,prim); CORO_END_CODE; @@ -1837,7 +1838,7 @@ void RMGfxSourceBuffer8RLEWordAA::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RM CORO_BEGIN_CODE(_ctx); CORO_INVOKE_2(RMGfxSourceBuffer8RLE::Draw, bigBuf, prim); - if (bCfgAntiAlias) + if (GLOBALS.bCfgAntiAlias) DrawAA(bigBuf,prim); CORO_END_CODE; diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 8f7d27dafc..bf1a08f245 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -54,17 +54,11 @@ namespace Tony { -extern bool bIdleExited; -extern bool bPatIrqFreeze; -extern bool bSkipSfxNoLoop; - /****************************************************************************\ * Metodi di RMGfxEngine \****************************************************************************/ -bool bIdleExited; - void ExitAllIdles(CORO_PARAM, const void *param) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); @@ -74,12 +68,12 @@ void ExitAllIdles(CORO_PARAM, const void *param) { CORO_BEGIN_CODE(_ctx); // Chiude le idle - bSkipSfxNoLoop = true; + GLOBALS.bSkipSfxNoLoop = true; CORO_INVOKE_2(mpalEndIdlePoll, nCurLoc, NULL); - bIdleExited = true; - bSkipSfxNoLoop = false; + GLOBALS.bIdleExited = true; + GLOBALS.bSkipSfxNoLoop = false; CORO_END_CODE; } @@ -149,11 +143,11 @@ void RMGfxEngine::OpenOptionScreen(CORO_PARAM, int type) { // Esce la IDLE onde evitare la morte prematura in caricamento m_bMustEnterMenu = true; if (type == 1 || type == 2) { - bIdleExited = true; + GLOBALS.bIdleExited = true; } else { CORO_INVOKE_0(m_tony.StopNoAction); - bIdleExited = false; + GLOBALS.bIdleExited = false; CoroScheduler.createProcess(ExitAllIdles, &m_nCurLoc, sizeof(int)); } @@ -173,10 +167,10 @@ void RMGfxEngine::DoFrame(CORO_PARAM, bool bDrawLocation) { // Poll dei dispositivi di input m_input.Poll(); - if (m_bMustEnterMenu && bIdleExited) { + if (m_bMustEnterMenu && GLOBALS.bIdleExited) { m_bOption = true; m_bMustEnterMenu = false; - bIdleExited = false; + GLOBALS.bIdleExited = false; } if (m_bOption) { @@ -401,10 +395,10 @@ void RMGfxEngine::ItemIrq(uint32 dwItem, int nPattern, int nStatus) { item=This->m_loc.GetItemFromCode(dwItem); if (item != NULL) { if (nPattern!=-1) { - if (bPatIrqFreeze) + if (GLOBALS.bPatIrqFreeze) MainFreeze(); item->SetPattern(nPattern,true); - if (bPatIrqFreeze) + if (GLOBALS.bPatIrqFreeze) MainUnfreeze(); } if (nStatus!=-1) @@ -604,16 +598,16 @@ void RMGfxEngine::Init(/*HINSTANCE hInst*/) { - bPatIrqFreeze = true; + GLOBALS.bPatIrqFreeze = true; // GUI attivabile m_bGUIOption = true; m_bGUIInterface = true; m_bGUIInventory = true; - bSkipSfxNoLoop = false; + GLOBALS.bSkipSfxNoLoop = false; m_bMustEnterMenu = false; - bIdleExited = false; + GLOBALS.bIdleExited = false; m_bOption = false; m_bWiping = false; m_hWipeEvent = CoroScheduler.createEvent(false, false); @@ -806,23 +800,23 @@ void RMGfxEngine::SaveState(const char *fn, byte *curThumb, const char *name, bo CharsSaveAll(f); // Save the options - f->writeByte(bCfgInvLocked); - f->writeByte(bCfgInvNoScroll); - f->writeByte(bCfgTimerizedText); - f->writeByte(bCfgInvUp); - f->writeByte(bCfgAnni30); - f->writeByte(bCfgAntiAlias); - f->writeByte(bCfgSottotitoli); - f->writeByte(bCfgTransparence); - f->writeByte(bCfgInterTips); - f->writeByte(bCfgDubbing); - f->writeByte(bCfgMusic); - f->writeByte(bCfgSFX); - f->writeByte(nCfgTonySpeed); - f->writeByte(nCfgTextSpeed); - f->writeByte(nCfgDubbingVolume); - f->writeByte(nCfgMusicVolume); - f->writeByte(nCfgSFXVolume); + f->writeByte(GLOBALS.bCfgInvLocked); + f->writeByte(GLOBALS.bCfgInvNoScroll); + f->writeByte(GLOBALS.bCfgTimerizedText); + f->writeByte(GLOBALS.bCfgInvUp); + f->writeByte(GLOBALS.bCfgAnni30); + f->writeByte(GLOBALS.bCfgAntiAlias); + f->writeByte(GLOBALS.bCfgSottotitoli); + f->writeByte(GLOBALS.bCfgTransparence); + f->writeByte(GLOBALS.bCfgInterTips); + f->writeByte(GLOBALS.bCfgDubbing); + f->writeByte(GLOBALS.bCfgMusic); + f->writeByte(GLOBALS.bCfgSFX); + f->writeByte(GLOBALS.nCfgTonySpeed); + f->writeByte(GLOBALS.nCfgTextSpeed); + f->writeByte(GLOBALS.nCfgDubbingVolume); + f->writeByte(GLOBALS.nCfgMusicVolume); + f->writeByte(GLOBALS.nCfgSFXVolume); // Save the hotspots SaveChangedHotspot(f); @@ -942,23 +936,23 @@ void RMGfxEngine::LoadState(CORO_PARAM, const char *fn) { if (_ctx->ver >= 6) { // Load options - bCfgInvLocked = _ctx->f->readByte(); - bCfgInvNoScroll = _ctx->f->readByte(); - bCfgTimerizedText = _ctx->f->readByte(); - bCfgInvUp = _ctx->f->readByte(); - bCfgAnni30 = _ctx->f->readByte(); - bCfgAntiAlias = _ctx->f->readByte(); - bCfgSottotitoli = _ctx->f->readByte(); - bCfgTransparence = _ctx->f->readByte(); - bCfgInterTips = _ctx->f->readByte(); - bCfgDubbing = _ctx->f->readByte(); - bCfgMusic = _ctx->f->readByte(); - bCfgSFX = _ctx->f->readByte(); - nCfgTonySpeed = _ctx->f->readByte(); - nCfgTextSpeed = _ctx->f->readByte(); - nCfgDubbingVolume = _ctx->f->readByte(); - nCfgMusicVolume = _ctx->f->readByte(); - nCfgSFXVolume = _ctx->f->readByte(); + GLOBALS.bCfgInvLocked = _ctx->f->readByte(); + GLOBALS.bCfgInvNoScroll = _ctx->f->readByte(); + GLOBALS.bCfgTimerizedText = _ctx->f->readByte(); + GLOBALS.bCfgInvUp = _ctx->f->readByte(); + GLOBALS.bCfgAnni30 = _ctx->f->readByte(); + GLOBALS.bCfgAntiAlias = _ctx->f->readByte(); + GLOBALS.bCfgSottotitoli = _ctx->f->readByte(); + GLOBALS.bCfgTransparence = _ctx->f->readByte(); + GLOBALS.bCfgInterTips = _ctx->f->readByte(); + GLOBALS.bCfgDubbing = _ctx->f->readByte(); + GLOBALS.bCfgMusic = _ctx->f->readByte(); + GLOBALS.bCfgSFX = _ctx->f->readByte(); + GLOBALS.nCfgTonySpeed = _ctx->f->readByte(); + GLOBALS.nCfgTextSpeed = _ctx->f->readByte(); + GLOBALS.nCfgDubbingVolume = _ctx->f->readByte(); + GLOBALS.nCfgMusicVolume = _ctx->f->readByte(); + GLOBALS.nCfgSFXVolume = _ctx->f->readByte(); // Load hotspots LoadChangedHotspot(_ctx->f); diff --git a/engines/tony/globals.cpp b/engines/tony/globals.cpp new file mode 100644 index 0000000000..c39ba215b4 --- /dev/null +++ b/engines/tony/globals.cpp @@ -0,0 +1,93 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "tony/globals.h" + +namespace Tony { + +Globals::Globals() { + nextLoop = false; + nextChannel = 0; + nextSync = 0; + curChannel = 0; + flipflop = 0; + curBackText = NULL; + Tony = NULL; + Pointer = NULL; + Boxes = NULL; + Loc = NULL; + Inventory = NULL; + Input = NULL; + LoadLocation = NULL; + UnloadLocation = NULL; + LinkGraphicTask = NULL; + Freeze = NULL; + Unfreeze = NULL; + WaitFrame = NULL; + PlayMusic = NULL; + WaitWipeEnd = NULL; + CloseWipe = NULL; + InitWipe = NULL; + EnableGUI = NULL; + DisableGUI = NULL; + SetPalesati = NULL; + + dwTonyNumTexts = 0; + bTonyInTexts = false; + bStaticTalk = false; + bPatIrqFreeze = false; + bCfgInvLocked = false; + bCfgInvNoScroll = false; + bCfgTimerizedText = false; + bCfgInvUp = false; + bCfgAnni30 = false; + bCfgAntiAlias = false; + bCfgSottotitoli = false; + bCfgTransparence = false; + bCfgInterTips = false; + bCfgDubbing = false; + bCfgMusic = false; + bCfgSFX = false; + nCfgTonySpeed = 0; + nCfgTextSpeed = 0; + nCfgDubbingVolume = 0; + nCfgMusicVolume = 0; + nCfgSFXVolume = 0; + bIdleExited = false; + bSkipSfxNoLoop = false; + bNoOcchioDiBue = false; + curDialog = 0; + curSonoriz = 0; + bFadeOutStop = false; + +// OSystem::MutexRef cs[10]; +// OSystem::MutexRef vdb; + Common::fill(&mut[0], &mut[10], (HANDLE)NULL); + bSkipIdle = false; + hSkipIdle = 0; + lastMusic = 0; + lastTappeto = 0; + Common::fill(&tappeti[0], &tappeti[200], 0); + SFM_nLoc = 0; +} + +} // End of namespace Tony diff --git a/engines/tony/globals.h b/engines/tony/globals.h new file mode 100644 index 0000000000..7f6f8ed880 --- /dev/null +++ b/engines/tony/globals.h @@ -0,0 +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. + * + */ + +#ifndef TONY_GLOBALS +#define TONY_GLOBALS + +#include "common/savefile.h" +#include "tony/adv.h" +#include "tony/input.h" +#include "tony/inventory.h" +#include "tony/loc.h" +#include "tony/tonychar.h" + +namespace Tony { + +#define T_GRILLI 1 +#define T_GRILLIOV 2 +#define T_GRILLIVENTO 3 +#define T_GRILLIVENTO1 4 +#define T_VENTO 5 +#define T_MARE 6 +#define T_MAREMETA 7 + + +struct CharacterStruct { + uint32 code; + RMItem *item; + byte r, g, b; + int talkpattern; + int standpattern; + int starttalkpattern, endtalkpattern; + int numtexts; + + void Save(Common::OutSaveFile *f) { + f->writeUint32LE(code); + f->writeUint32LE(0); + f->writeByte(r); + f->writeByte(g); + f->writeByte(b); + f->writeUint32LE(talkpattern); + f->writeUint32LE(standpattern); + f->writeUint32LE(starttalkpattern); + f->writeUint32LE(endtalkpattern); + f->writeUint32LE(numtexts); + } + void Load(Common::InSaveFile *f) { + code = f->readUint32LE(); + f->readUint32LE(); + item = NULL; + r = f->readByte(); + g = f->readByte(); + b = f->readByte(); + talkpattern = f->readUint32LE(); + standpattern = f->readUint32LE(); + starttalkpattern = f->readUint32LE(); + endtalkpattern = f->readUint32LE(); + numtexts = f->readUint32LE(); + } +}; + +struct MCharacterStruct { + uint32 code; + RMItem *item; + byte r, g, b; + int x, y; + int numtalks[10]; + int curgroup; + int numtexts; + bool bInTexts; + int curTalk; + bool bAlwaysBack; + + void Save(Common::OutSaveFile *f) { + f->writeUint32LE(code); + f->writeUint32LE(0); + f->writeByte(r); + f->writeByte(g); + f->writeByte(b); + f->writeUint32LE(x); + f->writeUint32LE(y); + for (int i = 0; i < 10; ++i) + f->writeUint32LE(numtalks[i]); + f->writeUint32LE(curgroup); + f->writeUint32LE(numtexts); + f->writeByte(bInTexts); + f->writeUint32LE(curTalk); + f->writeByte(bAlwaysBack); + } + void Load(Common::InSaveFile *f) { + code = f->readUint32LE(); + f->readUint32LE(); + item = NULL; + r = f->readByte(); + g = f->readByte(); + b = f->readByte(); + x = f->readUint32LE(); + y = f->readUint32LE(); + for (int i = 0; i < 10; ++i) + numtalks[i] = f->readUint32LE(); + curgroup = f->readUint32LE(); + numtexts = f->readUint32LE(); + bInTexts = f->readByte(); + curTalk = f->readUint32LE(); + bAlwaysBack = f->readByte(); + } +}; + +struct ChangedHotspotStruct { + uint32 dwCode; + uint32 nX, nY; + + void Save(Common::OutSaveFile *f) { + f->writeUint32LE(dwCode); + f->writeUint32LE(nX); + f->writeUint32LE(nY); + } + void Load(Common::InSaveFile *f) { + dwCode = f->readUint32LE(); + nX = f->readUint32LE(); + nY = f->readUint32LE(); + } +}; + +class Globals { +public: + Globals(); + + char nextMusic[MAX_PATH]; + bool nextLoop; + int nextChannel; + int nextSync; + int curChannel; + int flipflop; + // OSystem::MutexRef csMusic; + CharacterStruct Character[16]; + MCharacterStruct MCharacter[10]; + ChangedHotspotStruct ChangedHotspot[256]; + bool IsMChar[16]; + bool bAlwaysDisplay; + RMPoint saveTonyPos; + int saveTonyLoc; + RMTextDialog *curBackText; + bool bTonyIsSpeaking; + int curChangedHotspot; + bool bPatIrqFreeze; + bool bCfgInvLocked; + bool bCfgInvNoScroll; + bool bCfgTimerizedText; + bool bCfgInvUp; + bool bCfgAnni30; + bool bCfgAntiAlias; + bool bCfgSottotitoli; + bool bCfgTransparence; + bool bCfgInterTips; + bool bCfgDubbing; + bool bCfgMusic; + bool bCfgSFX; + int nCfgTonySpeed; + int nCfgTextSpeed; + int nCfgDubbingVolume; + int nCfgMusicVolume; + int nCfgSFXVolume; + bool bSkipSfxNoLoop; + bool bIdleExited; + bool bNoOcchioDiBue; + int curDialog; + int curSonoriz; + bool bFadeOutStop; + + RMTony *Tony; + RMPointer *Pointer; + RMGameBoxes *Boxes; + RMLocation *Loc; + RMInventory *Inventory; + RMInput *Input; + + uint32 (*LoadLocation)(int, RMPoint, RMPoint start); + void (*UnloadLocation)(CORO_PARAM, bool bDoOnExit, uint32 *result); + void (*LinkGraphicTask)(RMGfxTask *task); + void (*Freeze)(void); + void (*Unfreeze)(void); + void (*WaitFrame)(CORO_PARAM); + void (*PlayMusic)(int nChannel, const char *fileName, int nFX, bool bLoop, int nSync); + void (*WaitWipeEnd)(CORO_PARAM); + void (*CloseWipe)(void); + void (*InitWipe)(int type); + void (*EnableGUI)(void); + void (*DisableGUI)(void); + void (*SetPalesati)(bool bpal); + + uint32 dwTonyNumTexts; + bool bTonyInTexts; + bool bStaticTalk; + RMTony::TALKTYPE nTonyNextTalkType; + + RMPoint StartLocPos[256]; + OSystem::MutexRef cs[10]; + OSystem::MutexRef vdb; + HANDLE mut[10]; + + bool bSkipIdle; + uint32 hSkipIdle; + + int lastMusic, lastTappeto; + + int tappeti[200]; + RMPoint SFM_pt; + int SFM_nLoc; +}; + +} // End of namespace Tony + +#endif // TONY_GLOBALS diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index 468ec225a5..fbc0918e10 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -84,7 +84,7 @@ RMInventory::~RMInventory() { } bool RMInventory::CheckPointInside(const RMPoint &pt) { - if (!bCfgInvUp) + if (!GLOBALS.bCfgInvUp) return pt.y > RM_SY - 70; else return pt.y < 70; @@ -226,7 +226,7 @@ void RMInventory::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr if (m_state == SELECTING) { - if (!bCfgInvUp) { + if (!GLOBALS.bCfgInvUp) { _ctx->pos.Set((m_nSelectObj+1)*64 - 20,RM_SY - 113); _ctx->pos2.Set((m_nSelectObj+1)*64 + 34,RM_SY - 150); } else { @@ -240,7 +240,7 @@ void RMInventory::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr // Disegna l'interfaccina stupida CORO_INVOKE_2(miniInterface.Draw, bigBuf, _ctx->p); - if (bCfgInterTips) { + if (GLOBALS.bCfgInterTips) { if (miniAction == 1) // Esamina CORO_INVOKE_2(m_hints[0].Draw, bigBuf, _ctx->p2); else if (miniAction == 2) // Parla @@ -563,7 +563,7 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo } if (_vm->GetEngine()->GetInput().GetAsyncKeyState(Common::KEYCODE_i)) { - bCfgInvLocked = !bCfgInvLocked; + GLOBALS.bCfgInvLocked = !GLOBALS.bCfgInvLocked; } if (m_bCombining) {//m_state == COMBINING) @@ -571,9 +571,9 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo ptr.SetSpecialPointer(RMPointer::PTR_CUSTOM); } - if (!bCfgInvUp) { - if ((m_state == CLOSED) && (mpos.y > RM_SY - 10 || bCfgInvLocked) && bCanOpen) { - if (!bCfgInvNoScroll) { + if (!GLOBALS.bCfgInvUp) { + if ((m_state == CLOSED) && (mpos.y > RM_SY - 10 || GLOBALS.bCfgInvLocked) && bCanOpen) { + if (!GLOBALS.bCfgInvNoScroll) { m_state = OPENING; m_curPutY = RM_SY - 1; m_curPutTime=_vm->GetTime(); @@ -582,8 +582,8 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo m_curPutY = RM_SY - 68; } } else if (m_state == OPENED) { - if ((mpos.y < RM_SY - 70 && !bCfgInvLocked) || !bCanOpen) { - if (!bCfgInvNoScroll) { + if ((mpos.y < RM_SY - 70 && !GLOBALS.bCfgInvLocked) || !bCanOpen) { + if (!GLOBALS.bCfgInvNoScroll) { m_state = CLOSING; m_curPutY = RM_SY - 68; m_curPutTime = _vm->GetTime(); @@ -612,8 +612,8 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo m_state = CLOSED; } } else { - if ((m_state == CLOSED) && (mpos.y<10 || bCfgInvLocked) && bCanOpen) { - if (!bCfgInvNoScroll) { + if ((m_state == CLOSED) && (mpos.y<10 || GLOBALS.bCfgInvLocked) && bCanOpen) { + if (!GLOBALS.bCfgInvNoScroll) { m_state = OPENING; m_curPutY =- 68; m_curPutTime = _vm->GetTime(); @@ -623,8 +623,8 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo } } else if (m_state == OPENED) { - if ((mpos.y>70 && !bCfgInvLocked) || !bCanOpen) { - if (!bCfgInvNoScroll) { + if ((mpos.y>70 && !GLOBALS.bCfgInvLocked) || !bCanOpen) { + if (!GLOBALS.bCfgInvNoScroll) { m_state = CLOSING; m_curPutY = -2; m_curPutTime = _vm->GetTime(); @@ -657,7 +657,7 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo int startx = (m_nSelectObj + 1) * 64 - 20; int starty; - if (!bCfgInvUp) + if (!GLOBALS.bCfgInvUp) starty=RM_SY-109; else starty=70; @@ -828,7 +828,7 @@ void RMInterface::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr _vm->PlayUtilSFX(1); } - if (bCfgInterTips) { + if (GLOBALS.bCfgInterTips) { prim->Dst().TopLeft() = m_openStart + RMPoint(70, 177); CORO_INVOKE_2(m_hints[_ctx->h].Draw, bigBuf, prim); } diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 32754bbb51..306322f2ad 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -55,8 +55,6 @@ namespace Tony { using namespace ::Tony::MPAL; -extern bool bSkipSfxNoLoop; - /****************************************************************************\ * Metodi di RMPalette @@ -186,7 +184,7 @@ void RMPattern::StopSfx(RMSfx *sfx) { if (m_slots[i].m_type == SOUND) { if (sfx[m_slots[i].m_data].m_name[0] == '_') sfx[m_slots[i].m_data].Stop(); - else if (bSkipSfxNoLoop) + else if (GLOBALS.bSkipSfxNoLoop) sfx[m_slots[i].m_data].Stop(); } } diff --git a/engines/tony/module.mk b/engines/tony/module.mk index af0b3acd2c..6512391d04 100644 --- a/engines/tony/module.mk +++ b/engines/tony/module.mk @@ -7,6 +7,7 @@ MODULE_OBJS := \ game.o \ gfxcore.o \ gfxengine.o \ + globals.o \ input.o \ inventory.o \ loc.o \ diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index 01968ea579..53d3b962d2 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -51,13 +51,6 @@ namespace Tony { -extern bool bCfgMusic; -extern bool bCfgSFX; -extern bool bCfgDubbing; -extern int nCfgSFXVolume; -extern int nCfgMusicVolume; -extern int nCfgDubbingVolume; - /****************************************************************************\ * Defines @@ -1527,15 +1520,15 @@ void FPSFX::SetVolume(int dwVolume) { lastVolume = dwVolume; if (bIsVoice) { - if (!bCfgDubbing) dwVolume = 0; + if (!GLOBALS.bCfgDubbing) dwVolume = 0; else { - dwVolume -= (10 - nCfgDubbingVolume) * 2; + dwVolume -= (10 - GLOBALS.nCfgDubbingVolume) * 2; if (dwVolume<0) dwVolume = 0; } } else { - if (!bCfgSFX) dwVolume = 0; + if (!GLOBALS.bCfgSFX) dwVolume = 0; else { - dwVolume -= (10 - nCfgSFXVolume) * 2; + dwVolume -= (10 - GLOBALS.nCfgSFXVolume) * 2; if (dwVolume < 0) dwVolume = 0; } } @@ -2273,9 +2266,9 @@ void FPSTREAM::SetVolume(int dwVolume) { lastVolume = dwVolume; - if (!bCfgMusic) dwVolume = 0; + if (!GLOBALS.bCfgMusic) dwVolume = 0; else { - dwVolume -= (10 - nCfgMusicVolume) * 2; + dwVolume -= (10 - GLOBALS.nCfgMusicVolume) * 2; if (dwVolume<0) dwVolume = 0; } diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 56b68419fd..1b4a11df0c 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -119,23 +119,23 @@ Common::ErrorCode TonyEngine::Init() { m_curThumbnail = new uint16[160 * 120]; // Configurazione di default - bCfgInvLocked = false; - bCfgInvNoScroll = false; - bCfgTimerizedText = true; - bCfgInvUp = false; - bCfgAnni30 = false; - bCfgAntiAlias = false; - bCfgTransparence = true; - bCfgInterTips = true; - bCfgSottotitoli = true; - nCfgTonySpeed = 3; - nCfgTextSpeed = 5; - bCfgDubbing = true; - bCfgMusic = true; - bCfgSFX = true; - nCfgDubbingVolume = 10; - nCfgMusicVolume = 7; - nCfgSFXVolume = 10; + GLOBALS.bCfgInvLocked = false; + GLOBALS.bCfgInvNoScroll = false; + GLOBALS.bCfgTimerizedText = true; + GLOBALS.bCfgInvUp = false; + GLOBALS.bCfgAnni30 = false; + GLOBALS.bCfgAntiAlias = false; + GLOBALS.bCfgTransparence = true; + GLOBALS.bCfgInterTips = true; + GLOBALS.bCfgSottotitoli = true; + GLOBALS.nCfgTonySpeed = 3; + GLOBALS.nCfgTextSpeed = 5; + GLOBALS.bCfgDubbing = true; + GLOBALS.bCfgMusic = true; + GLOBALS.bCfgSFX = true; + GLOBALS.nCfgDubbingVolume = 10; + GLOBALS.nCfgMusicVolume = 7; + GLOBALS.nCfgSFXVolume = 10; m_bQuitNow = false; return Common::kNoError; @@ -152,21 +152,12 @@ void TonyEngine::GUIError(const Common::String &msg) { GUIErrorMessage(msg); } -char nextMusic[MAX_PATH]; -bool nextLoop; -int nextChannel; -int nextSync; -int curChannel; -int flipflop=0; -OSystem::MutexRef csMusic; - - void TonyEngine::PlayMusic(int nChannel, const char *fn, int nFX, bool bLoop, int nSync) { warning("TODO: TonyEngine::PlayMusic"); - g_system->lockMutex(csMusic); +// g_system->lockMutex(csMusic); if (nChannel < 4) - if (flipflop) + if (GLOBALS.flipflop) nChannel = nChannel + 1; switch (nFX) { @@ -243,7 +234,7 @@ void TonyEngine::PlayMusic(int nChannel, const char *fn, int nFX, bool bLoop, in } #endif - g_system->unlockMutex(csMusic); +// g_system->unlockMutex(csMusic); } void TonyEngine::PlaySFX(int nChannel, int nFX) { @@ -264,14 +255,14 @@ void TonyEngine::PlaySFX(int nChannel, int nFX) { } void TonyEngine::StopMusic(int nChannel) { - g_system->lockMutex(csMusic); +// g_system->lockMutex(csMusic); if (nChannel < 4) - m_stream[nChannel+flipflop]->Stop(); + m_stream[nChannel + GLOBALS.flipflop]->Stop(); else m_stream[nChannel]->Stop(); - g_system->unlockMutex(csMusic); +// g_system->unlockMutex(csMusic); } void TonyEngine::StopSFX(int nChannel) { @@ -279,7 +270,7 @@ void TonyEngine::StopSFX(int nChannel) { } void TonyEngine::PlayUtilSFX(int nChannel, int nFX) { - if (m_utilSfx[nChannel]==NULL) + if (m_utilSfx[nChannel] == NULL) return; switch (nFX) { @@ -355,7 +346,7 @@ void TonyEngine::InitMusic() { } // Crea la critical section per la musica - csMusic = g_system->createMutex(); +// csMusic = g_system->createMutex(); // Carica effetti sonori // PreloadUtilSFX(0,"AccendiOpzione.ADP"); @@ -372,7 +363,7 @@ void TonyEngine::CloseMusic() { m_stream[i]->Release(); } - g_system->deleteMutex(csMusic); +// g_system->deleteMutex(csMusic); UnloadAllSFX(); UnloadAllUtilSFX(); diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 4a80970bb9..c1ad6756c2 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -38,6 +38,7 @@ #include "tony/loc.h" #include "tony/utils.h" #include "tony/window.h" +#include "tony/globals.h" /** * This is the namespace of the Tony engine. @@ -51,6 +52,8 @@ namespace Tony { using namespace MPAL; +class Globals; + enum { kTonyDebugAnimations = 1 << 0, kTonyDebugActions = 1 << 1, @@ -97,6 +100,7 @@ public: Common::File _vdbFP; Common::Array _voices; FPSOUND _theSound; + Globals _globals; enum DATADIR { DD_BASE = 1, @@ -209,6 +213,8 @@ public: // Global reference to the TonyEngine object extern TonyEngine *_vm; +#define GLOBALS _vm->_globals + } // End of namespace Tony #endif /* TONY_H */ diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index 0e59779229..072e822c36 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -153,7 +153,7 @@ void RMTony::DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int curLoc) { if (!m_nInList && m_bShow) bigBuf->AddPrim(new RMGfxPrimitive(this)); - SetSpeed(nCfgTonySpeed); + SetSpeed(GLOBALS.nCfgTonySpeed); // Esegue il movimento normale del personaggio _ctx->time = _vm->GetTime(); -- cgit v1.2.3 From b01482bddb6d8f0b0be4dd46ee7c9e4141908673 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 13 May 2012 23:05:41 +1000 Subject: TONY: Further globals added to Globals class --- engines/tony/font.cpp | 13 +++++-------- engines/tony/font.h | 2 +- engines/tony/globals.cpp | 1 + engines/tony/input.cpp | 5 ++--- engines/tony/loc.cpp | 2 +- engines/tony/sound.cpp | 8 ++++---- engines/tony/tony.cpp | 4 ++++ engines/tony/tonychar.cpp | 4 ++++ engines/tony/tonychar.h | 1 + engines/tony/window.cpp | 1 - 10 files changed, 23 insertions(+), 18 deletions(-) (limited to 'engines') diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index dee3c3228a..8957c09a87 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -1816,9 +1816,12 @@ void RMFontObj::Init(void) { \****************************************************************************/ RMFontColor *RMText::m_fonts[4] = { NULL, NULL, NULL, NULL }; -OSystem::MutexRef RMText::m_cs; RMGfxClearTask RMText::m_clear; +void RMText::InitStatics() { + Common::fill(&m_fonts[0], &m_fonts[4], (RMFontColor *)NULL); +} + RMText::RMText() { // Colore di default: bianco m_r = m_g = m_b = 255; @@ -1843,8 +1846,6 @@ void RMText::Unload() { delete m_fonts[2]; delete m_fonts[3]; m_fonts[0] = m_fonts[1] = m_fonts[2] = m_fonts[3] = 0; - - g_system->unlockMutex(m_cs); } } @@ -1866,13 +1867,9 @@ void RMText::WriteText(const RMString &text, int nFont, int *time) { m_fonts[1] = new RMFontObj; m_fonts[1]->Init(); m_fonts[2] = new RMFontMacc; m_fonts[2]->Init(); m_fonts[3] = new RMFontCredits; m_fonts[3]->Init(); - - m_cs = g_system->createMutex(); } - g_system->lockMutex(m_cs); - WriteText(text,m_fonts[nFont],time); - g_system->unlockMutex(m_cs); + WriteText(text, m_fonts[nFont], time); } diff --git a/engines/tony/font.h b/engines/tony/font.h index a63c90638d..36fdc9baed 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -188,7 +188,6 @@ class RMText : public RMGfxWoodyBuffer { private: static RMFontColor *m_fonts[4]; static RMGfxClearTask m_clear; - static OSystem::MutexRef m_cs; int maxLineLength; public: @@ -216,6 +215,7 @@ protected: public: RMText(); virtual ~RMText(); + static void InitStatics(); static void Unload(); // Setta il tipo di allineamento diff --git a/engines/tony/globals.cpp b/engines/tony/globals.cpp index c39ba215b4..9bc9ea5d7c 100644 --- a/engines/tony/globals.cpp +++ b/engines/tony/globals.cpp @@ -88,6 +88,7 @@ Globals::Globals() { lastTappeto = 0; Common::fill(&tappeti[0], &tappeti[200], 0); SFM_nLoc = 0; + vdb = NULL; } } // End of namespace Tony diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp index fcd56b5989..f29d4ddc8e 100644 --- a/engines/tony/input.cpp +++ b/engines/tony/input.cpp @@ -49,8 +49,6 @@ namespace Tony { -#define DIRELEASE(x) if (x) { (x)->Release(); (x)=NULL; } - RMInput::RMInput() { // Setup mouse fields _clampMouse = false; @@ -128,7 +126,8 @@ bool RMInput::MouseRight() { } /** - * Return true if a key has been pressed */ + * Return true if a key has been pressed + */ bool RMInput::GetAsyncKeyState(Common::KeyCode kc) { // The act of testing for a particular key automatically clears the state, to prevent // the same key being registered in multiple different frames diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 306322f2ad..70e800a5d4 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -864,7 +864,7 @@ RMItem::~RMItem() { CoroScheduler.closeEvent(m_hEndPattern); } -//FIXME: Pass uint32 directly for hCustomSkip + void RMItem::WaitForEndPattern(CORO_PARAM, uint32 hCustomSkip) { CORO_BEGIN_CONTEXT; uint32 h[2]; diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index 53d3b962d2..61d225b88b 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -113,8 +113,8 @@ public: class CODECADPCM : public CODECRAW { protected: byte *lpTemp; - static int indexTable[16]; - static int stepSizeTable[89]; + static const int indexTable[16]; + static const int stepSizeTable[89]; public: CODECADPCM(bool bLoop = true, byte *lpTempBuffer = NULL); @@ -298,12 +298,12 @@ uint32 CODECRAW::Decompress(Common::File &fp, void *buf, uint32 dwSize) { * Metodi per CODECADPCM \****************************************************************************/ -int CODECADPCM::indexTable[16] = { +const int CODECADPCM::indexTable[16] = { -1, -1, -1, -1, 2, 4, 6, 8, -1, -1, -1, -1, 2, 4, 6, 8, }; -int CODECADPCM::stepSizeTable[89] = { +const int CODECADPCM::stepSizeTable[89] = { 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 19, 21, 23, 25, 28, 31, 34, 37, 41, 45, 50, 55, 60, 66, 73, 80, 88, 97, 107, 118, diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 1b4a11df0c..aa110ce008 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -77,6 +77,10 @@ Common::ErrorCode TonyEngine::Init() { m_bDrawLocation = true; m_startTime = g_system->getMillis(); + // Init static class fields + RMText::InitStatics(); + RMTony::InitStatics(); + // Reset the scheduler CoroScheduler.reset(); diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index 072e822c36..7430ca89ae 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -59,6 +59,10 @@ namespace Tony { bool RMTony::m_bAction = false; +void RMTony::InitStatics() { + m_bAction = false; +} + RMTony::RMTony() { m_bShow = false; m_bShowOmbra = false; diff --git a/engines/tony/tonychar.h b/engines/tony/tonychar.h index ee6d518f4b..27d62d9d57 100644 --- a/engines/tony/tonychar.h +++ b/engines/tony/tonychar.h @@ -378,6 +378,7 @@ public: // per farlo rialzare, altrimenti private }; public: + static void InitStatics(); RMTony(); // Inizializza Tony diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index f997b8c53d..18e6901547 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -53,7 +53,6 @@ namespace Tony { -#define DDRELEASE(x) if (x) { (x)->Release(); (x)=NULL; } /****************************************************************************\ * RMWindow Methods -- cgit v1.2.3 From 94f5a989873151d435f144de59bf06146a48a4b6 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 13 May 2012 23:44:08 +1000 Subject: TONY: Moved remaining globals to Globals class --- engines/tony/globals.cpp | 41 ++++ engines/tony/globals.h | 66 +++++++ engines/tony/mpal/expr.cpp | 2 +- engines/tony/mpal/loadmpc.cpp | 124 ++++++------ engines/tony/mpal/mpal.cpp | 438 +++++++++++++++++------------------------- engines/tony/mpal/mpaldll.h | 44 +---- 6 files changed, 354 insertions(+), 361 deletions(-) (limited to 'engines') diff --git a/engines/tony/globals.cpp b/engines/tony/globals.cpp index 9bc9ea5d7c..0ce99f88e7 100644 --- a/engines/tony/globals.cpp +++ b/engines/tony/globals.cpp @@ -20,6 +20,7 @@ * */ +#include "common/algorithm.h" #include "tony/globals.h" namespace Tony { @@ -31,6 +32,8 @@ Globals::Globals() { curChannel = 0; flipflop = 0; curBackText = NULL; + bTonyIsSpeaking = false; + curChangedHotspot = 0; Tony = NULL; Pointer = NULL; Boxes = NULL; @@ -89,6 +92,44 @@ Globals::Globals() { Common::fill(&tappeti[0], &tappeti[200], 0); SFM_nLoc = 0; vdb = NULL; + + // MPAL global variables + mpalError = 0; + lpiifCustom = NULL; + lplpFunctions = NULL; + lplpFunctionStrings = NULL; + nObjs = 0; + nVars = 0; + hVars = NULL; + lpmvVars = NULL; + nMsgs = 0; + hMsgs = NULL; + lpmmMsgs = NULL; + nDialogs = 0; + hDialogs = NULL; + lpmdDialogs = NULL; + nItems = 0; + hItems = NULL; + lpmiItems = NULL; + nLocations = 0; + hLocations = NULL; + lpmlLocations = NULL; + nScripts = 0; + hScripts = NULL; + lpmsScripts = NULL; + nResources = 0; + lpResources = NULL; + bExecutingAction = false; + bExecutingDialog = false; + Common::fill(&nPollingLocations[0], &nPollingLocations[MAXPOLLINGLOCATIONS], 0); + Common::fill(&hEndPollingLocations[0], &hEndPollingLocations[MAXPOLLINGLOCATIONS], 0); + Common::fill(&PollingThreads[0], &PollingThreads[MAXPOLLINGLOCATIONS], 0); + hAskChoice = 0; + hDoneChoice = 0; + nExecutingAction = 0; + nExecutingDialog = 0; + nExecutingChoice = 0; + nSelectedChoice = 0; } } // End of namespace Tony diff --git a/engines/tony/globals.h b/engines/tony/globals.h index 7f6f8ed880..1a11a871d0 100644 --- a/engines/tony/globals.h +++ b/engines/tony/globals.h @@ -29,6 +29,8 @@ #include "tony/inventory.h" #include "tony/loc.h" #include "tony/tonychar.h" +#include "tony/mpal/mpal.h" +#include "tony/mpal/mpaldll.h" namespace Tony { @@ -140,6 +142,28 @@ struct ChangedHotspotStruct { } }; +/****************************************************************************\ +* typedef CFCALL +* -------------- +* Description: Descrizione di una chiamata a una custom function +\****************************************************************************/ + +typedef struct { + int nCf; + + int arg1, arg2, arg3, arg4; +} CFCALL; +typedef CFCALL* LPCFCALL; +typedef LPCFCALL* LPLPCFCALL; + + +/****************************************************************************\ +* Global variables +\****************************************************************************/ + +/** + * Globals class + */ class Globals { public: Globals(); @@ -225,6 +249,48 @@ public: int tappeti[200]; RMPoint SFM_pt; int SFM_nLoc; + + /** + * @defgroup MPAL variables + * + */ + uint32 mpalError; + LPITEMIRQFUNCTION lpiifCustom; + LPLPCUSTOMFUNCTION lplpFunctions; + Common::String * lplpFunctionStrings; + uint16 nObjs; + uint16 nVars; + HGLOBAL hVars; + LPMPALVAR lpmvVars; + uint16 nMsgs; + HGLOBAL hMsgs; + LPMPALMSG lpmmMsgs; + uint16 nDialogs; + HGLOBAL hDialogs; + LPMPALDIALOG lpmdDialogs; + uint16 nItems; + HGLOBAL hItems; + LPMPALITEM lpmiItems; + uint16 nLocations; + HGLOBAL hLocations; + LPMPALLOCATION lpmlLocations; + uint16 nScripts; + HGLOBAL hScripts; + LPMPALSCRIPT lpmsScripts; + Common::File hMpr; + uint16 nResources; + uint32 * lpResources; + bool bExecutingAction; + bool bExecutingDialog; + uint32 nPollingLocations[MAXPOLLINGLOCATIONS]; + uint32 hEndPollingLocations[MAXPOLLINGLOCATIONS]; + uint32 PollingThreads[MAXPOLLINGLOCATIONS]; + uint32 hAskChoice; + uint32 hDoneChoice; + uint32 nExecutingAction; + uint32 nExecutingDialog; + uint32 nExecutingChoice; + uint32 nSelectedChoice; }; } // End of namespace Tony diff --git a/engines/tony/mpal/expr.cpp b/engines/tony/mpal/expr.cpp index 0ca02d2931..19170ce60c 100644 --- a/engines/tony/mpal/expr.cpp +++ b/engines/tony/mpal/expr.cpp @@ -209,7 +209,7 @@ static int Compute(int a, int b, byte symbol) { case OP_OR: return a||b; default: - mpalError=1; + GLOBALS.mpalError = 1; break; } diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index 9d6ef19e55..937374517f 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -517,58 +517,58 @@ bool ParseMpc(const byte *lpBuf) { return false; lpBuf += 4; - nVars = READ_LE_UINT16(lpBuf); + GLOBALS.nVars = READ_LE_UINT16(lpBuf); lpBuf += 2; - hVars = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof(MPALVAR) * (uint32)nVars); - if (hVars == NULL) + GLOBALS.hVars = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof(MPALVAR) * (uint32)GLOBALS.nVars); + if (GLOBALS.hVars == NULL) return false; - lpmvVars = (LPMPALVAR)GlobalLock(hVars); + GLOBALS.lpmvVars = (LPMPALVAR)GlobalLock(GLOBALS.hVars); - for (i = 0; i < nVars; i++) { + for (i = 0; i < GLOBALS.nVars; i++) { wLen = *(const byte *)lpBuf; lpBuf++; - CopyMemory(lpmvVars->lpszVarName, lpBuf, MIN(wLen, (uint16)32)); + CopyMemory(GLOBALS.lpmvVars->lpszVarName, lpBuf, MIN(wLen, (uint16)32)); lpBuf += wLen; - lpmvVars->dwVal = READ_LE_UINT32(lpBuf); + GLOBALS.lpmvVars->dwVal = READ_LE_UINT32(lpBuf); lpBuf += 4; lpBuf++; // Salta 'ext' - lpmvVars++; + GLOBALS.lpmvVars++; } - GlobalUnlock(hVars); + GlobalUnlock(GLOBALS.hVars); /* 2. Messaggi */ if (lpBuf[0] != 'M' || lpBuf[1] != 'S' || lpBuf[2] != 'G' || lpBuf[3] != 'S') return false; lpBuf += 4; - nMsgs = READ_LE_UINT16(lpBuf); + GLOBALS.nMsgs = READ_LE_UINT16(lpBuf); lpBuf += 2; #ifdef NEED_LOCK_MSGS - hMsgs = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof(MPALMSG) * (uint32)nMsgs); - if (hMsgs == NULL) + GLOBALS.hMsgs = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof(MPALMSG) * (uint32)GLOBALS.nMsgs); + if (GLOBALS.hMsgs == NULL) return false; - lpmmMsgs = (LPMPALMSG)GlobalLock(hMsgs); + GLOBALS.lpmmMsgs = (LPMPALMSG)GlobalLock(GLOBALS.hMsgs); #else - lpmmMsgs=(LPMPALMSG)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,sizeof(MPALMSG)*(uint32)nMsgs); - if (lpmmMsgs==NULL) + GLOBALS.lpmmMsgs=(LPMPALMSG)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,sizeof(MPALMSG)*(uint32)GLOBALS.nMsgs); + if (GLOBALS.lpmmMsgs==NULL) return false; #endif - for (i = 0; i < nMsgs; i++) { - lpmmMsgs->wNum = READ_LE_UINT16(lpBuf); + for (i = 0; i < GLOBALS.nMsgs; i++) { + GLOBALS.lpmmMsgs->wNum = READ_LE_UINT16(lpBuf); lpBuf += 2; for (j = 0; lpBuf[j] != 0;) j += lpBuf[j] + 1; - lpmmMsgs->hText = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, j + 1); - lpTemp2 = lpTemp = (byte *)GlobalLock(lpmmMsgs->hText); + GLOBALS.lpmmMsgs->hText = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, j + 1); + lpTemp2 = lpTemp = (byte *)GlobalLock(GLOBALS.lpmmMsgs->hText); for (j = 0; lpBuf[j] != 0;) { CopyMemory(lpTemp, &lpBuf[j + 1], lpBuf[j]); @@ -580,12 +580,12 @@ bool ParseMpc(const byte *lpBuf) { lpBuf += j + 1; *lpTemp = '\0'; - GlobalUnlock(lpmmMsgs->hText); - lpmmMsgs++; + GlobalUnlock(GLOBALS.lpmmMsgs->hText); + GLOBALS.lpmmMsgs++; } #ifdef NEED_LOCK_MSGS - GlobalUnlock(hMsgs); + GlobalUnlock(GLOBALS.hMsgs); #endif /* 3. Oggetti */ @@ -593,96 +593,96 @@ bool ParseMpc(const byte *lpBuf) { return false; lpBuf += 4; - nObjs = READ_LE_UINT16(lpBuf); + GLOBALS.nObjs = READ_LE_UINT16(lpBuf); lpBuf += 2; // Controlla i dialoghi - nDialogs = 0; - hDialogs = lpmdDialogs = NULL; + GLOBALS.nDialogs = 0; + GLOBALS.hDialogs = GLOBALS.lpmdDialogs = NULL; if (*((const byte *)lpBuf + 2) == 6 && strncmp((const char *)lpBuf + 3, "Dialog", 6) == 0) { - nDialogs = READ_LE_UINT16(lpBuf); lpBuf += 2; + GLOBALS.nDialogs = READ_LE_UINT16(lpBuf); lpBuf += 2; - hDialogs = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)nDialogs * sizeof(MPALDIALOG)); - if (hDialogs == NULL) + GLOBALS.hDialogs = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nDialogs * sizeof(MPALDIALOG)); + if (GLOBALS.hDialogs == NULL) return false; - lpmdDialogs = (LPMPALDIALOG)GlobalLock(hDialogs); + GLOBALS.lpmdDialogs = (LPMPALDIALOG)GlobalLock(GLOBALS.hDialogs); - for (i = 0;i < nDialogs; i++) - if ((lpBuf = ParseDialog(lpBuf + 7, &lpmdDialogs[i])) == NULL) + for (i = 0;i < GLOBALS.nDialogs; i++) + if ((lpBuf = ParseDialog(lpBuf + 7, &GLOBALS.lpmdDialogs[i])) == NULL) return false; - GlobalUnlock(hDialogs); + GlobalUnlock(GLOBALS.hDialogs); } // Controlla gli item - nItems = 0; - hItems = lpmiItems = NULL; + GLOBALS.nItems = 0; + GLOBALS.hItems = GLOBALS.lpmiItems = NULL; if (*(lpBuf + 2) == 4 && strncmp((const char *)lpBuf + 3, "Item", 4)==0) { - nItems = READ_LE_UINT16(lpBuf); lpBuf += 2; + GLOBALS.nItems = READ_LE_UINT16(lpBuf); lpBuf += 2; // Alloca la memoria e li legge - hItems=GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)nItems * sizeof(MPALITEM)); - if (hItems == NULL) + GLOBALS.hItems = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nItems * sizeof(MPALITEM)); + if (GLOBALS.hItems == NULL) return false; - lpmiItems=(LPMPALITEM)GlobalLock(hItems); + GLOBALS.lpmiItems=(LPMPALITEM)GlobalLock(GLOBALS.hItems); - for (i = 0; i < nItems; i++) - if ((lpBuf = ParseItem(lpBuf + 5, &lpmiItems[i])) == NULL) + for (i = 0; i < GLOBALS.nItems; i++) + if ((lpBuf = ParseItem(lpBuf + 5, &GLOBALS.lpmiItems[i])) == NULL) return false; - GlobalUnlock(hItems); + GlobalUnlock(GLOBALS.hItems); } // Controlla le locazioni - nLocations = 0; - hLocations = lpmlLocations = NULL; + GLOBALS.nLocations = 0; + GLOBALS.hLocations = GLOBALS.lpmlLocations = NULL; if (*(lpBuf + 2) == 8 && strncmp((const char *)lpBuf + 3, "Location", 8)==0) { - nLocations = READ_LE_UINT16(lpBuf); lpBuf += 2; + GLOBALS.nLocations = READ_LE_UINT16(lpBuf); lpBuf += 2; // Alloca la memoria e li legge - hLocations=GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)nLocations*sizeof(MPALLOCATION)); - if (hLocations == NULL) + GLOBALS.hLocations=GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nLocations*sizeof(MPALLOCATION)); + if (GLOBALS.hLocations == NULL) return false; - lpmlLocations = (LPMPALLOCATION)GlobalLock(hLocations); + GLOBALS.lpmlLocations = (LPMPALLOCATION)GlobalLock(GLOBALS.hLocations); - for (i = 0; i < nLocations; i++) - if ((lpBuf = ParseLocation(lpBuf + 9, &lpmlLocations[i])) == NULL) + for (i = 0; i < GLOBALS.nLocations; i++) + if ((lpBuf = ParseLocation(lpBuf + 9, &GLOBALS.lpmlLocations[i])) == NULL) return false; - GlobalUnlock(hLocations); + GlobalUnlock(GLOBALS.hLocations); } // Controlla gli script - nScripts = 0; - hScripts = lpmsScripts = NULL; + GLOBALS.nScripts = 0; + GLOBALS.hScripts = GLOBALS.lpmsScripts = NULL; if (*(lpBuf + 2) == 6 && strncmp((const char *)lpBuf + 3, "Script", 6) == 0) { - nScripts = READ_LE_UINT16(lpBuf); lpBuf += 2; + GLOBALS.nScripts = READ_LE_UINT16(lpBuf); lpBuf += 2; // Alloca la memoria - hScripts = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)nScripts * sizeof(MPALSCRIPT)); - if (hScripts == NULL) + GLOBALS.hScripts = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nScripts * sizeof(MPALSCRIPT)); + if (GLOBALS.hScripts == NULL) return false; - lpmsScripts = (LPMPALSCRIPT)GlobalLock(hScripts); + GLOBALS.lpmsScripts = (LPMPALSCRIPT)GlobalLock(GLOBALS.hScripts); - for (i = 0; i < nScripts; i++) { - if ((lpBuf = ParseScript(lpBuf + 7, &lpmsScripts[i])) == NULL) + for (i = 0; i < GLOBALS.nScripts; i++) { + if ((lpBuf = ParseScript(lpBuf + 7, &GLOBALS.lpmsScripts[i])) == NULL) return false; // Ordina i vari moments dello script //qsort( - //lpmsScripts[i].Moment, - //lpmsScripts[i].nMoments, - //sizeof(lpmsScripts[i].Moment[0]), + //GLOBALS.lpmsScripts[i].Moment, + //GLOBALS.lpmsScripts[i].nMoments, + //sizeof(GLOBALS.lpmsScripts[i].Moment[0]), //(int (*)(const void *, const void *))CompareMoments //); } - GlobalUnlock(hScripts); + GlobalUnlock(GLOBALS.hScripts); } if (lpBuf[0] != 'E' || lpBuf[1] != 'N' || lpBuf[2] != 'D' || lpBuf[3] != '0') diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index bfde7fe2a6..66d467f301 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -72,84 +72,6 @@ const char *mpalCopyright = "\n" "\n"; -/****************************************************************************\ -* Structures -\****************************************************************************/ - -/****************************************************************************\ -* typedef CFCALL -* -------------- -* Description: Descrizione di una chiamata a una custom function -\****************************************************************************/ - -typedef struct { - int nCf; - - int arg1, arg2, arg3, arg4; -} CFCALL; -typedef CFCALL* LPCFCALL; -typedef LPCFCALL* LPLPCFCALL; - - -/****************************************************************************\ -* Global variables -\****************************************************************************/ - -uint32 mpalError; - -static byte * lpMpcImage; - -LPITEMIRQFUNCTION lpiifCustom=NULL; - -LPLPCUSTOMFUNCTION lplpFunctions = NULL; -Common::String * lplpFunctionStrings = NULL; -uint16 nObjs; - -uint16 nVars; -HGLOBAL hVars; -LPMPALVAR lpmvVars; - -uint16 nMsgs; -HGLOBAL hMsgs; -LPMPALMSG lpmmMsgs; - -uint16 nDialogs; -HGLOBAL hDialogs; -LPMPALDIALOG lpmdDialogs; - -uint16 nItems; -HGLOBAL hItems; -LPMPALITEM lpmiItems; - -uint16 nLocations; -HGLOBAL hLocations; -LPMPALLOCATION lpmlLocations; - -uint16 nScripts; -HGLOBAL hScripts; -LPMPALSCRIPT lpmsScripts; - -Common::File hMpr; -uint16 nResources; -uint32 * lpResources; - -bool bExecutingAction; -bool bExecutingDialog; - -uint32 nPollingLocations[MAXPOLLINGLOCATIONS]; -uint32 hEndPollingLocations[MAXPOLLINGLOCATIONS]; -uint32 PollingThreads[MAXPOLLINGLOCATIONS]; - -uint32 hAskChoice; -uint32 hDoneChoice; - -uint32 nExecutingAction; - -uint32 nExecutingDialog; -uint32 nExecutingChoice; -uint32 nSelectedChoice; - - /****************************************************************************\ * Internal functions \****************************************************************************/ @@ -163,7 +85,7 @@ uint32 nSelectedChoice; \****************************************************************************/ void LockVar(void) { - lpmvVars=(LPMPALVAR)GlobalLock(hVars); + GLOBALS.lpmvVars = (LPMPALVAR)GlobalLock(GLOBALS.hVars); } /****************************************************************************\ @@ -175,7 +97,7 @@ void LockVar(void) { \****************************************************************************/ void UnlockVar(void) { - GlobalUnlock(hVars); + GlobalUnlock(GLOBALS.hVars); } @@ -189,7 +111,7 @@ void UnlockVar(void) { static void LockMsg(void) { #ifdef NEED_LOCK_MSGS - lpmmMsgs=(LPMPALMSG)GlobalLock(hMsgs); + GLOBALS.lpmmMsgs = (LPMPALMSG)GlobalLock(GLOBALS.hMsgs); #endif } @@ -204,7 +126,7 @@ static void LockMsg(void) { static void UnlockMsg(void) { #ifdef NEED_LOCK_MSGS - GlobalUnlock(hMsgs); + GlobalUnlock(GLOBALS.hMsgs); #endif } @@ -218,7 +140,7 @@ static void UnlockMsg(void) { \****************************************************************************/ static void LockDialogs(void) { - lpmdDialogs=(LPMPALDIALOG)GlobalLock(hDialogs); + GLOBALS.lpmdDialogs = (LPMPALDIALOG)GlobalLock(GLOBALS.hDialogs); } @@ -231,7 +153,7 @@ static void LockDialogs(void) { \****************************************************************************/ static void UnlockDialogs(void) { - GlobalUnlock(hDialogs); + GlobalUnlock(GLOBALS.hDialogs); } @@ -244,7 +166,7 @@ static void UnlockDialogs(void) { \****************************************************************************/ static void LockLocations(void) { - lpmlLocations=(LPMPALLOCATION)GlobalLock(hLocations); + GLOBALS.lpmlLocations = (LPMPALLOCATION)GlobalLock(GLOBALS.hLocations); } @@ -257,7 +179,7 @@ static void LockLocations(void) { \****************************************************************************/ static void UnlockLocations(void) { - GlobalUnlock(hLocations); + GlobalUnlock(GLOBALS.hLocations); } @@ -270,7 +192,7 @@ static void UnlockLocations(void) { \****************************************************************************/ static void LockItems(void) { - lpmiItems=(LPMPALITEM)GlobalLock(hItems); + GLOBALS.lpmiItems = (LPMPALITEM)GlobalLock(GLOBALS.hItems); } @@ -283,7 +205,7 @@ static void LockItems(void) { \****************************************************************************/ static void UnlockItems(void) { - GlobalUnlock(hItems); + GlobalUnlock(GLOBALS.hItems); } /****************************************************************************\ @@ -295,7 +217,7 @@ static void UnlockItems(void) { \****************************************************************************/ static void LockScripts(void) { - lpmsScripts=(LPMPALSCRIPT)GlobalLock(hScripts); + GLOBALS.lpmsScripts = (LPMPALSCRIPT)GlobalLock(GLOBALS.hScripts); } @@ -308,7 +230,7 @@ static void LockScripts(void) { \****************************************************************************/ static void UnlockScripts(void) { - GlobalUnlock(hScripts); + GlobalUnlock(GLOBALS.hScripts); } @@ -330,13 +252,13 @@ static void UnlockScripts(void) { int32 varGetValue(const char *lpszVarName) { int i; - LPMPALVAR v=lpmvVars; + LPMPALVAR v=GLOBALS.lpmvVars; - for (i = 0; i < nVars; v++, i++) + for (i = 0; i < GLOBALS.nVars; v++, i++) if (strcmp(lpszVarName, v->lpszVarName) == 0) return v->dwVal; - mpalError = 1; + GLOBALS.mpalError = 1; return 0; } @@ -354,24 +276,24 @@ int32 varGetValue(const char *lpszVarName) { void varSetValue(const char *lpszVarName, int32 val) { uint i; - LPMPALVAR v = lpmvVars; + LPMPALVAR v = GLOBALS.lpmvVars; - for (i = 0; i < nVars; v++, i++) + for (i = 0; i < GLOBALS.nVars; v++, i++) if (strcmp(lpszVarName, v->lpszVarName) == 0) { v->dwVal = val; - if (lpiifCustom != NULL && strncmp(v->lpszVarName, "Pattern.", 8) == 0) { + if (GLOBALS.lpiifCustom != NULL && strncmp(v->lpszVarName, "Pattern.", 8) == 0) { i = 0; sscanf(v->lpszVarName, "Pattern.%u", &i); - lpiifCustom(i, val, -1); - } else if (lpiifCustom != NULL && strncmp(v->lpszVarName, "Status.", 7) == 0) { + GLOBALS.lpiifCustom(i, val, -1); + } else if (GLOBALS.lpiifCustom != NULL && strncmp(v->lpszVarName, "Status.", 7) == 0) { i = 0; sscanf(v->lpszVarName,"Status.%u", &i); - lpiifCustom(i, -1, val); + GLOBALS.lpiifCustom(i, -1, val); } return; } - mpalError = 1; + GLOBALS.mpalError = 1; return; } @@ -394,9 +316,9 @@ void varSetValue(const char *lpszVarName, int32 val) { static int locGetOrderFromNum(uint32 nLoc) { int i; - LPMPALLOCATION loc = lpmlLocations; + LPMPALLOCATION loc = GLOBALS.lpmlLocations; - for (i = 0; i < nLocations; i++,loc++) + for (i = 0; i < GLOBALS.nLocations; i++, loc++) if (loc->nObj == nLoc) return i; @@ -421,9 +343,9 @@ static int locGetOrderFromNum(uint32 nLoc) { static int msgGetOrderFromNum(uint32 nMsg) { int i; - LPMPALMSG msg = lpmmMsgs; + LPMPALMSG msg = GLOBALS.lpmmMsgs; - for (i = 0; i < nMsgs; i++, msg++) + for (i = 0; i < GLOBALS.nMsgs; i++, msg++) if (msg->wNum == nMsg) return i; @@ -449,9 +371,9 @@ static int msgGetOrderFromNum(uint32 nMsg) { static int itemGetOrderFromNum(uint32 nItem) { int i; - LPMPALITEM item=lpmiItems; + LPMPALITEM item = GLOBALS.lpmiItems; - for (i = 0; i < nItems; i++, item++) + for (i = 0; i < GLOBALS.nItems; i++, item++) if (item->nObj == nItem) return i; @@ -477,9 +399,9 @@ static int itemGetOrderFromNum(uint32 nItem) { static int scriptGetOrderFromNum(uint32 nScript) { int i; - LPMPALSCRIPT script = lpmsScripts; + LPMPALSCRIPT script = GLOBALS.lpmsScripts; - for (i = 0; i < nScripts; i++,script++) + for (i = 0; i < GLOBALS.nScripts; i++, script++) if (script->nObj == nScript) return i; @@ -505,9 +427,9 @@ static int scriptGetOrderFromNum(uint32 nScript) { static int dialogGetOrderFromNum(uint32 nDialog) { int i; - LPMPALDIALOG dialog=lpmdDialogs; + LPMPALDIALOG dialog = GLOBALS.lpmdDialogs; - for (i = 0; i < nDialogs; i++, dialog++) + for (i = 0; i < GLOBALS.nDialogs; i++, dialog++) if (dialog->nObj == nDialog) return i; @@ -538,7 +460,7 @@ static char *DuplicateMessage(uint32 nMsgOrd) { if (nMsgOrd == (uint32)-1) return NULL; - origmsg = (const char *)GlobalLock(lpmmMsgs[nMsgOrd].hText); + origmsg = (const char *)GlobalLock(GLOBALS.lpmmMsgs[nMsgOrd].hText); j = 0; while (origmsg[j] != '\0' || origmsg[j + 1] != '\0') @@ -550,7 +472,7 @@ static char *DuplicateMessage(uint32 nMsgOrd) { return NULL; CopyMemory(clonemsg, origmsg, j); - GlobalUnlock(lpmmMsgs[nMsgOrd].hText); + GlobalUnlock(GLOBALS.lpmmMsgs[nMsgOrd].hText); return clonemsg; } @@ -575,7 +497,7 @@ static char *DuplicateMessage(uint32 nMsgOrd) { static char *DuplicateDialogPeriod(uint32 nPeriod) { const char *origmsg; char *clonemsg; - LPMPALDIALOG dialog=lpmdDialogs+nExecutingDialog; + LPMPALDIALOG dialog = GLOBALS.lpmdDialogs + GLOBALS.nExecutingDialog; int i,j; for (j = 0; dialog->Periods[j] != NULL; j++) @@ -623,28 +545,28 @@ HGLOBAL resLoad(uint32 dwId) { uint32 nSizeComp, nSizeDecomp; byte *temp, *buf; - for (i = 0; i < nResources; i++) - if (lpResources[i * 2] == dwId) { - hMpr.seek(lpResources[i * 2 + 1]); - nBytesRead = hMpr.read(head, 4); + for (i = 0; i < GLOBALS.nResources; i++) + if (GLOBALS.lpResources[i * 2] == dwId) { + GLOBALS.hMpr.seek(GLOBALS.lpResources[i * 2 + 1]); + nBytesRead = GLOBALS.hMpr.read(head, 4); if (nBytesRead != 4) return NULL; if (head[0] != 'R' || head[1] != 'E' || head[2] != 'S' || head[3] != 'D') return NULL; - nSizeDecomp = hMpr.readUint32LE(); - if (hMpr.err()) + nSizeDecomp = GLOBALS.hMpr.readUint32LE(); + if (GLOBALS.hMpr.err()) return NULL; - nSizeComp = hMpr.readUint32LE(); - if (hMpr.err()) + nSizeComp = GLOBALS.hMpr.readUint32LE(); + if (GLOBALS.hMpr.err()) return NULL; h = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, nSizeDecomp + (nSizeDecomp / 1024) * 16); buf = (byte *)GlobalLock(h); temp = (byte *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT,nSizeComp); - nBytesRead = hMpr.read(temp, nSizeComp); + nBytesRead = GLOBALS.hMpr.read(temp, nSizeComp); if (nBytesRead != nSizeComp) return NULL; @@ -663,7 +585,7 @@ HGLOBAL resLoad(uint32 dwId) { static uint32 *GetSelectList(uint32 i) { uint32 *sl; int j,k,num; - LPMPALDIALOG dialog=lpmdDialogs+nExecutingDialog; + LPMPALDIALOG dialog=GLOBALS.lpmdDialogs+GLOBALS.nExecutingDialog; /* Conta quanti select attivi ci sono */ num = 0; @@ -692,10 +614,10 @@ static uint32 *GetSelectList(uint32 i) { static uint32 *GetItemList(uint32 nLoc) { uint32 *il; uint32 num,i,j; - LPMPALVAR v = lpmvVars; + LPMPALVAR v = GLOBALS.lpmvVars; num = 0; - for (i = 0; i < nVars; i++,v++) { + for (i = 0; i < GLOBALS.nVars; i++,v++) { if (strncmp(v->lpszVarName,"Location",8) == 0 && v->dwVal == nLoc) num++; } @@ -704,9 +626,9 @@ static uint32 *GetItemList(uint32 nLoc) { if (il == NULL) return NULL; - v = lpmvVars; + v = GLOBALS.lpmvVars; j = 0; - for (i = 0; i < nVars; i++,v++) { + for (i = 0; i < GLOBALS.nVars; i++,v++) { if (strncmp(v->lpszVarName,"Location",8) == 0 && v->dwVal == nLoc) { sscanf(v->lpszVarName, "Location.%u", &il[j]); j++; @@ -718,7 +640,7 @@ static uint32 *GetItemList(uint32 nLoc) { } static LPITEM GetItemData(uint32 nOrdItem) { - LPMPALITEM curitem = lpmiItems+nOrdItem; + LPMPALITEM curitem = GLOBALS.lpmiItems+nOrdItem; LPITEM ret; HGLOBAL hDat; char *dat; @@ -838,7 +760,7 @@ void CustomThread(CORO_PARAM, const void *param) { _ctx->p = *(LPCFCALL *)param; - CORO_INVOKE_4(lplpFunctions[_ctx->p->nCf], _ctx->p->arg1, _ctx->p->arg2, _ctx->p->arg3, _ctx->p->arg4); + CORO_INVOKE_4(GLOBALS.lplpFunctions[_ctx->p->nCf], _ctx->p->arg1, _ctx->p->arg2, _ctx->p->arg3, _ctx->p->arg4); GlobalFree(_ctx->p); @@ -899,7 +821,7 @@ void ScriptThread(CORO_PARAM, const void *param) { if (s->Command[_ctx->k].type == 1) { _ctx->p=(LPCFCALL)GlobalAlloc(GMEM_FIXED, sizeof(CFCALL)); if (_ctx->p == NULL) { - mpalError = 1; + GLOBALS.mpalError = 1; CORO_KILL_SELF(); return; @@ -913,7 +835,7 @@ void ScriptThread(CORO_PARAM, const void *param) { // !!! Nuova gestione dei thread if ((cfHandles[_ctx->numHandles++] = CoroScheduler.createProcess(CustomThread, &_ctx->p, sizeof(LPCFCALL))) == 0) { - mpalError = 1; + GLOBALS.mpalError = 1; CORO_KILL_SELF(); return; @@ -927,7 +849,7 @@ void ScriptThread(CORO_PARAM, const void *param) { UnlockVar(); } else { - mpalError = 1; + GLOBALS.mpalError = 1; GlobalFree(s); CORO_KILL_SELF(); @@ -968,19 +890,19 @@ void ActionThread(CORO_PARAM, const void *param) { CORO_BEGIN_CODE(_ctx); - mpalError = 0; + GLOBALS.mpalError = 0; for (_ctx->j = 0; _ctx->j < item->Action[item->dwRes].nCmds; _ctx->j++) { _ctx->k = item->Action[item->dwRes].CmdNum[_ctx->j]; if (item->Command[_ctx->k].type == 1) { // Custom function debugC(DEBUG_DETAILED, kTonyDebugActions, "Action Process %d Call=%s params=%d,%d,%d,%d", - CoroScheduler.getCurrentPID(), lplpFunctionStrings[item->Command[_ctx->k].nCf].c_str(), + CoroScheduler.getCurrentPID(), GLOBALS.lplpFunctionStrings[item->Command[_ctx->k].nCf].c_str(), item->Command[_ctx->k].arg1, item->Command[_ctx->k].arg2, item->Command[_ctx->k].arg3, item->Command[_ctx->k].arg4 ); - CORO_INVOKE_4(lplpFunctions[item->Command[_ctx->k].nCf], + CORO_INVOKE_4(GLOBALS.lplpFunctions[item->Command[_ctx->k].nCf], item->Command[_ctx->k].arg1, item->Command[_ctx->k].arg2, item->Command[_ctx->k].arg3, @@ -997,7 +919,7 @@ void ActionThread(CORO_PARAM, const void *param) { UnlockVar(); } else { - mpalError = 1; + GLOBALS.mpalError = 1; break; } } @@ -1027,7 +949,7 @@ void ShutUpActionThread(CORO_PARAM, const void *param) { CORO_INVOKE_2(CoroScheduler.waitForSingleObject, pid, CORO_INFINITE); - bExecutingAction = false; + GLOBALS.bExecutingAction = false; CORO_KILL_SELF(); @@ -1088,7 +1010,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { /* Tanto per cominciare, e' necessario richiedere la lista degli item presenti nella locazione. */ - _ctx->il = mpalQueryItemList(nPollingLocations[id]); + _ctx->il = mpalQueryItemList(GLOBALS.nPollingLocations[id]); /* Contiamo gli items */ for (_ctx->numitems = 0; _ctx->il[_ctx->numitems] != 0; _ctx->numitems++) @@ -1104,7 +1026,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { if (_ctx->ord == -1) continue; - _ctx->curItem = lpmiItems + _ctx->ord; + _ctx->curItem = GLOBALS.lpmiItems + _ctx->ord; _ctx->k = 0; for (_ctx->j = 0; _ctx->j < _ctx->curItem->nActions; _ctx->j++) @@ -1157,7 +1079,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { if (_ctx->il[_ctx->i] == 0) continue; - _ctx->curItem = lpmiItems + itemGetOrderFromNum(_ctx->il[_ctx->i]); + _ctx->curItem = GLOBALS.lpmiItems + itemGetOrderFromNum(_ctx->il[_ctx->i]); for (_ctx->j = 0; _ctx->j < _ctx->curItem->nActions; _ctx->j++) if (_ctx->curItem->Action[_ctx->j].num == 0xFF) { @@ -1199,7 +1121,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { /* Ci addormentiamo, ma controllando sempre l'evento che viene settato quando viene richiesta la nostra chiusura */ - CORO_INVOKE_3(CoroScheduler.waitForSingleObject, hEndPollingLocations[id], _ctx->dwSleepTime, &_ctx->expired); + CORO_INVOKE_3(CoroScheduler.waitForSingleObject, GLOBALS.hEndPollingLocations[id], _ctx->dwSleepTime, &_ctx->expired); //if (_ctx->k == WAIT_OBJECT_0) if (!_ctx->expired) @@ -1226,7 +1148,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { byte randomVal = (byte)_vm->_randomSource.getRandomNumber(99); if (randomVal < _ctx->MyActions[_ctx->k].perc) { /* Controlliamo se c'e' una action in esecuzione sull'item */ - if ((bExecutingAction) && (nExecutingAction == _ctx->MyActions[_ctx->k].nItem)) + if ((GLOBALS.bExecutingAction) && (GLOBALS.nExecutingAction == _ctx->MyActions[_ctx->k].nItem)) continue; /* Controlliamo se c'e' gia' un'altra idle function in esecuzione @@ -1240,7 +1162,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { /* Ok, siamo gli unici :) */ LockItems(); - _ctx->curItem=lpmiItems+itemGetOrderFromNum(_ctx->MyActions[_ctx->k].nItem); + _ctx->curItem=GLOBALS.lpmiItems+itemGetOrderFromNum(_ctx->MyActions[_ctx->k].nItem); /* Controlliamo se c'e' un esperessione WhenExecute */ _ctx->j=_ctx->MyActions[_ctx->k].nAction; @@ -1308,7 +1230,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { // Set idle skip on // FIXME: Convert to co-routine - CORO_INVOKE_4(lplpFunctions[200], 0, 0, 0, 0); + CORO_INVOKE_4(GLOBALS.lplpFunctions[200], 0, 0, 0, 0); for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) if (_ctx->MyThreads[_ctx->i].nItem != 0) { @@ -1323,7 +1245,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { } // Set idle skip off - CORO_INVOKE_4(lplpFunctions[201], 0, 0, 0, 0); + CORO_INVOKE_4(GLOBALS.lplpFunctions[201], 0, 0, 0, 0); /* Abbiamo finito */ GlobalFree(_ctx->MyThreads); @@ -1362,11 +1284,11 @@ void ShutUpDialogThread(CORO_PARAM, const void *param) { CORO_INVOKE_2(CoroScheduler.waitForSingleObject, pid, CORO_INFINITE); - bExecutingDialog = false; - nExecutingDialog = 0; - nExecutingChoice = 0; + GLOBALS.bExecutingDialog = false; + GLOBALS.nExecutingDialog = 0; + GLOBALS.nExecutingChoice = 0; - CoroScheduler.setEvent(hAskChoice); + CoroScheduler.setEvent(GLOBALS.hAskChoice); CORO_KILL_SELF(); @@ -1394,7 +1316,7 @@ void GroupThread(CORO_PARAM, const void *param) { LockDialogs(); // Find the pointer to the current _ctx->dialog - _ctx->dialog = lpmdDialogs + nExecutingDialog; + _ctx->dialog = GLOBALS.lpmdDialogs + GLOBALS.nExecutingDialog; // Search inside the group requesting the _ctx->dialog for (_ctx->i = 0; _ctx->dialog->Group[_ctx->i].num != 0; _ctx->i++) { @@ -1406,7 +1328,7 @@ void GroupThread(CORO_PARAM, const void *param) { _ctx->type = _ctx->dialog->Command[_ctx->k].type; if (_ctx->type == 1) { // Call custom function - CORO_INVOKE_4(lplpFunctions[_ctx->dialog->Command[_ctx->k].nCf], + CORO_INVOKE_4(GLOBALS.lplpFunctions[_ctx->dialog->Command[_ctx->k].nCf], _ctx->dialog->Command[_ctx->k].arg1, _ctx->dialog->Command[_ctx->k].arg2, _ctx->dialog->Command[_ctx->k].arg3, @@ -1424,7 +1346,7 @@ void GroupThread(CORO_PARAM, const void *param) { CORO_INVOKE_1(DoChoice, (uint32)_ctx->dialog->Command[_ctx->k].nChoice); } else { - mpalError = 1; + GLOBALS.mpalError = 1; UnlockDialogs(); CORO_KILL_SELF(); @@ -1441,7 +1363,7 @@ void GroupThread(CORO_PARAM, const void *param) { } /* Se siamo qui, vuol dire che non abbiamo trovato il gruppo richiesto */ - mpalError = 1; + GLOBALS.mpalError = 1; UnlockDialogs(); CORO_KILL_SELF(); @@ -1473,7 +1395,7 @@ void DoChoice(CORO_PARAM, uint32 nChoice) { LockDialogs(); /* Trova il puntatore al dialogo corrente */ - _ctx->dialog=lpmdDialogs+nExecutingDialog; + _ctx->dialog=GLOBALS.lpmdDialogs+GLOBALS.nExecutingDialog; /* Cerca la scelta richiesta tra quelle nel dialogo */ for (_ctx->i = 0; _ctx->dialog->Choice[_ctx->i].nChoice != 0; _ctx->i++) @@ -1483,7 +1405,7 @@ void DoChoice(CORO_PARAM, uint32 nChoice) { /* Se non l'ha trovata, esce con errore */ if (_ctx->dialog->Choice[_ctx->i].nChoice == 0) { /* Se siamo qui, non abbiamo trovato la choice richiesta */ - mpalError = 1; + GLOBALS.mpalError = 1; UnlockDialogs(); CORO_KILL_SELF(); @@ -1492,10 +1414,10 @@ void DoChoice(CORO_PARAM, uint32 nChoice) { /* Abbiamo trova la choice richiesta. Ricordiamoci qual e' nella variabile globale */ - nExecutingChoice = _ctx->i; + GLOBALS.nExecutingChoice = _ctx->i; while (1) { - nExecutingChoice = _ctx->i; + GLOBALS.nExecutingChoice = _ctx->i; _ctx->k = 0; /* Calcoliamo le when expression di ciascun select, per vedere se sono @@ -1518,13 +1440,13 @@ void DoChoice(CORO_PARAM, uint32 nChoice) { /* Avvertiamo il gioco che c'e' una scelta da far fare all'utente, e restiamo in attesa della risposta */ - CoroScheduler.resetEvent(hDoneChoice); - CoroScheduler.setEvent(hAskChoice); - CORO_INVOKE_2(CoroScheduler.waitForSingleObject, hDoneChoice, CORO_INFINITE); + CoroScheduler.resetEvent(GLOBALS.hDoneChoice); + CoroScheduler.setEvent(GLOBALS.hAskChoice); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, GLOBALS.hDoneChoice, CORO_INFINITE); /* Ora che la scelta e' stata effettuata, possiamo eseguire _ctx->i gruppi associati con la scelta */ - _ctx->j = nSelectedChoice; + _ctx->j = GLOBALS.nSelectedChoice; for (_ctx->k = 0; _ctx->dialog->Choice[_ctx->i].Select[_ctx->j].wPlayGroup[_ctx->k] != 0; _ctx->k++) { _ctx->nGroup = _ctx->dialog->Choice[_ctx->i].Select[_ctx->j].wPlayGroup[_ctx->k]; CORO_INVOKE_1(GroupThread, &_ctx->nGroup); @@ -1579,7 +1501,7 @@ void DoChoice(CORO_PARAM, uint32 nChoice) { \****************************************************************************/ static uint32 DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { - LPMPALITEM item = lpmiItems; + LPMPALITEM item = GLOBALS.lpmiItems; int i; LPMPALITEM newitem; uint32 h; @@ -1624,8 +1546,8 @@ static uint32 DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { if (CoroScheduler.createProcess(ShutUpActionThread, &h, sizeof(uint32)) == CORO_INVALID_PID_VALUE) return CORO_INVALID_PID_VALUE; - nExecutingAction = item->nObj; - bExecutingAction = true; + GLOBALS.nExecutingAction = item->nObj; + GLOBALS.bExecutingAction = true; return h; } @@ -1648,13 +1570,13 @@ static uint32 DoDialog(uint32 nDlgOrd, uint32 nGroup) { uint32 h; // Store the running dialog in a global variable - nExecutingDialog = nDlgOrd; + GLOBALS.nExecutingDialog = nDlgOrd; // Enables the flag to indicate that there is' a running dialogue - bExecutingDialog = true; + GLOBALS.bExecutingDialog = true; - CoroScheduler.resetEvent(hAskChoice); - CoroScheduler.resetEvent(hDoneChoice); + CoroScheduler.resetEvent(GLOBALS.hAskChoice); + CoroScheduler.resetEvent(GLOBALS.hDoneChoice); // Create a thread that performs the dialogue group @@ -1688,7 +1610,7 @@ static uint32 DoDialog(uint32 nDlgOrd, uint32 nGroup) { \****************************************************************************/ bool DoSelection(uint32 i, uint32 dwData) { - LPMPALDIALOG dialog=lpmdDialogs+nExecutingDialog; + LPMPALDIALOG dialog=GLOBALS.lpmdDialogs+GLOBALS.nExecutingDialog; int j; for (j = 0; dialog->Choice[i].Select[j].dwData != 0; j++) @@ -1698,8 +1620,8 @@ bool DoSelection(uint32 i, uint32 dwData) { if (dialog->Choice[i].Select[j].dwData == 0) return false; - nSelectedChoice = j; - CoroScheduler.setEvent(hDoneChoice); + GLOBALS.nSelectedChoice = j; + CoroScheduler.setEvent(GLOBALS.hDoneChoice); return true; } @@ -1742,8 +1664,8 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, //printf("Dialog: %lu\n", sizeof(MPALDIALOG)); /* Si salva l'array delle funzioni custom */ - lplpFunctions = lplpcfArray; - lplpFunctionStrings = lpcfStrings; + GLOBALS.lplpFunctions = lplpcfArray; + GLOBALS.lplpFunctionStrings = lpcfStrings; /* Apre il file MPC in lettura */ if (!hMpc.open(lpszMpcFileName)) @@ -1764,7 +1686,7 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, if (hMpc.err()) return false; - lpMpcImage = (byte *)GlobalAlloc(GMEM_FIXED,dwSizeDecomp+16); + byte *lpMpcImage = (byte *)GlobalAlloc(GMEM_FIXED,dwSizeDecomp+16); if (lpMpcImage == NULL) return false; @@ -1811,73 +1733,73 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, { char errbuf[256]; wsprintf(errbuf,"Utilizzo in RAM: VAR %lu, MSG %lu, DLG %lu, ITM %lu, LOC %lu, SCR %lu", - nVars*sizeof(MPALVAR), - nMsgs*sizeof(MPALMSG), - nDialogs*sizeof(MPALDIALOG), - nItems*sizeof(MPALITEM), - nLocations*sizeof(MPALLOCATION), - nScripts*sizeof(MPALSCRIPT)); + GLOBALS.nVars*sizeof(MPALVAR), + GLOBALS.nMsgs*sizeof(MPALMSG), + GLOBALS.nDialogs*sizeof(MPALDIALOG), + GLOBALS.nItems*sizeof(MPALITEM), + GLOBALS.nLocations*sizeof(MPALLOCATION), + GLOBALS.nScripts*sizeof(MPALSCRIPT)); MessageBox(NULL,errbuf,"Dump",MB_OK); } */ /* Apre il file MPR in lettura */ - if (!hMpr.open(lpszMprFileName)) + if (!GLOBALS.hMpr.open(lpszMprFileName)) return false; /* Si posiziona a 8 byte dalla fine del file */ - hMpr.seek(-12, SEEK_END); + GLOBALS.hMpr.seek(-12, SEEK_END); - dwSizeComp = hMpr.readUint32LE(); - if (hMpr.err()) + dwSizeComp = GLOBALS.hMpr.readUint32LE(); + if (GLOBALS.hMpr.err()) return false; - nResources = hMpr.readUint32LE(); - if (hMpr.err()) + GLOBALS.nResources = GLOBALS.hMpr.readUint32LE(); + if (GLOBALS.hMpr.err()) return false; - nBytesRead = hMpr.read(buf, 4); - if (hMpr.err()) + nBytesRead = GLOBALS.hMpr.read(buf, 4); + if (GLOBALS.hMpr.err()) return false; if (buf[0] !='E' || buf[1] != 'N' || buf[2] != 'D' || buf[3] != '0') return false; /* Si posiziona all'inizio dell'header delle risorse */ - hMpr.seek(-(12 + (int)dwSizeComp), SEEK_END); + GLOBALS.hMpr.seek(-(12 + (int)dwSizeComp), SEEK_END); - lpResources = (uint32 *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, nResources * 8); - if (lpResources == NULL) + GLOBALS.lpResources = (uint32 *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, GLOBALS.nResources * 8); + if (GLOBALS.lpResources == NULL) return false; cmpbuf = (byte *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, dwSizeComp); if (cmpbuf == NULL) return false; - nBytesRead = hMpr.read(cmpbuf, dwSizeComp); + nBytesRead = GLOBALS.hMpr.read(cmpbuf, dwSizeComp); if (nBytesRead != dwSizeComp) return false; - lzo1x_decompress((const byte *)cmpbuf, dwSizeComp, (byte *)lpResources, (uint32 *)&nBytesRead); - if (nBytesRead != (uint32)nResources*8) + lzo1x_decompress((const byte *)cmpbuf, dwSizeComp, (byte *)GLOBALS.lpResources, (uint32 *)&nBytesRead); + if (nBytesRead != (uint32)GLOBALS.nResources*8) return false; GlobalFree(cmpbuf); /* Si riposiziona all'inizio lasciando il file di risorse aperto */ - hMpr.seek(0, SEEK_SET); + GLOBALS.hMpr.seek(0, SEEK_SET); /* Non c'e' nessuna azione ne' dialogo in esecuzione */ - bExecutingAction = false; - bExecutingDialog = false; + GLOBALS.bExecutingAction = false; + GLOBALS.bExecutingDialog = false; /* Non c'e' nessuna locazione in polling */ - Common::fill(nPollingLocations, nPollingLocations + MAXPOLLINGLOCATIONS, 0); + Common::fill(GLOBALS.nPollingLocations, GLOBALS.nPollingLocations + MAXPOLLINGLOCATIONS, 0); /* Crea l'evento che verra' utilizzato per avvertire il gioco che c'e' da effettuare una scelta */ - hAskChoice = CoroScheduler.createEvent(true, false); - hDoneChoice = CoroScheduler.createEvent(true, false); + GLOBALS.hAskChoice = CoroScheduler.createEvent(true, false); + GLOBALS.hDoneChoice = CoroScheduler.createEvent(true, false); return true; } @@ -1920,7 +1842,7 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { va_list v; va_start(v, wQueryType); - mpalError = OK; + GLOBALS.mpalError = OK; if (wQueryType == MPQ_VERSION) { /* @@ -1961,13 +1883,13 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { y = GETARG(uint32); if (x != -1) { if (y == MPQ_X) - dwRet = lpmlLocations[x].dwXlen; + dwRet = GLOBALS.lpmlLocations[x].dwXlen; else if (y == MPQ_Y) - dwRet = lpmlLocations[x].dwYlen; + dwRet = GLOBALS.lpmlLocations[x].dwYlen; else - mpalError = 1; + GLOBALS.mpalError = 1; } else - mpalError = 1; + GLOBALS.mpalError = 1; UnlockLocations(); @@ -2022,7 +1944,7 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { else { LockItems(); y = itemGetOrderFromNum(x); - CopyMemory(n, (char *)(lpmiItems + y)->lpszDescribe, MAX_DESCRIBE_SIZE); + CopyMemory(n, (char *)(GLOBALS.lpmiItems + y)->lpszDescribe, MAX_DESCRIBE_SIZE); UnlockItems(); } @@ -2070,7 +1992,7 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { dwRet = DoAction(x, y, GETARG(uint32)); } else { dwRet = CORO_INVALID_PID_VALUE; - mpalError = 1; + GLOBALS.mpalError = 1; } UnlockVar(); @@ -2080,7 +2002,7 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { /* * int mpalQuery(MPQ_DO_DIALOG, uint32 nDialog, uint32 nGroup); */ - if (!bExecutingDialog) { + if (!GLOBALS.bExecutingDialog) { LockDialogs(); x = dialogGetOrderFromNum(GETARG(uint32)); @@ -2092,7 +2014,7 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { /* * DEFAULT -> ERROR */ - mpalError = 1; + GLOBALS.mpalError = 1; } va_end(v); @@ -2114,7 +2036,7 @@ HANDLE mpalQueryHANDLE(uint16 wQueryType, ...) { va_start(v, wQueryType); void *hRet = NULL; - mpalError = OK; + GLOBALS.mpalError = OK; if (wQueryType == MPQ_VERSION) { /* @@ -2154,7 +2076,7 @@ HANDLE mpalQueryHANDLE(uint16 wQueryType, ...) { */ LockLocations(); x = locGetOrderFromNum(GETARG(uint32)); - hRet = resLoad(lpmlLocations[x].dwPicRes); + hRet = resLoad(GLOBALS.lpmlLocations[x].dwPicRes); UnlockLocations(); } else if (wQueryType == MPQ_RESOURCE) { @@ -2198,7 +2120,7 @@ HANDLE mpalQueryHANDLE(uint16 wQueryType, ...) { else { LockItems(); y = itemGetOrderFromNum(x); - CopyMemory(n, (char *)(lpmiItems + y)->lpszDescribe, MAX_DESCRIBE_SIZE); + CopyMemory(n, (char *)(GLOBALS.lpmiItems + y)->lpszDescribe, MAX_DESCRIBE_SIZE); UnlockItems(); } @@ -2248,7 +2170,7 @@ HANDLE mpalQueryHANDLE(uint16 wQueryType, ...) { /* * DEFAULT -> ERROR */ - mpalError = 1; + GLOBALS.mpalError = 1; } va_end(v); @@ -2277,12 +2199,12 @@ void mpalQueryCORO(CORO_PARAM, uint16 wQueryType, uint32 *dwRet, ...) { /* * void mpalQuery(MPQ_DIALOG_WAITFORCHOICE); */ - CORO_INVOKE_2(CoroScheduler.waitForSingleObject, hAskChoice, CORO_INFINITE); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, GLOBALS.hAskChoice, CORO_INFINITE); - CoroScheduler.resetEvent(hAskChoice); + CoroScheduler.resetEvent(GLOBALS.hAskChoice); - if (bExecutingDialog) - *dwRet = (uint32)nExecutingChoice; + if (GLOBALS.bExecutingDialog) + *dwRet = (uint32)GLOBALS.nExecutingChoice; else *dwRet = (uint32)((int)-1); } else { @@ -2306,7 +2228,7 @@ void mpalQueryCORO(CORO_PARAM, uint16 wQueryType, uint32 *dwRet, ...) { \****************************************************************************/ uint32 mpalGetError(void) { - return mpalError; + return GLOBALS.mpalError; } @@ -2333,7 +2255,7 @@ bool mpalExecuteScript(int nScript) { if (s == NULL) return false; - CopyMemory(s, lpmsScripts+n, sizeof(MPALSCRIPT)); + CopyMemory(s, GLOBALS.lpmsScripts + n, sizeof(MPALSCRIPT)); UnlockScripts(); // !!! Nuova gestione dei thread @@ -2346,17 +2268,17 @@ bool mpalExecuteScript(int nScript) { /****************************************************************************\ * -* Function: void mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCustom); +* Function: void mpalInstallItemIrq(LPITEMIRQFUNCTION GLOBALS.lpiifCustom); * * Description: Install a custom routine that will be called by MPAL every * time the pattern of an item has been changed. * -* Input: LPITEMIRQFUNCTION lpiifCustom Custom function to install +* Input: LPITEMIRQFUNCTION GLOBALS.lpiifCustom Custom function to install * \****************************************************************************/ void mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCus) { - lpiifCustom = lpiifCus; + GLOBALS.lpiifCustom = lpiifCus; } @@ -2380,17 +2302,17 @@ bool mpalStartIdlePoll(int nLoc) { uint32 i; for (i = 0; i < MAXPOLLINGLOCATIONS; i++) - if (nPollingLocations[i] == (uint32)nLoc) + if (GLOBALS.nPollingLocations[i] == (uint32)nLoc) return false; for (i = 0; i < MAXPOLLINGLOCATIONS; i++) { - if (nPollingLocations[i] == 0) { - nPollingLocations[i] = nLoc; + if (GLOBALS.nPollingLocations[i] == 0) { + GLOBALS.nPollingLocations[i] = nLoc; - hEndPollingLocations[i] = CoroScheduler.createEvent(true, false); + GLOBALS.hEndPollingLocations[i] = CoroScheduler.createEvent(true, false); // !!! Nuova gestione dei thread - if ((PollingThreads[i] = CoroScheduler.createProcess(LocationPollThread, &i, sizeof(uint32))) == 0) -// if ((hEndPollingLocations[i]=(void*)_beginthread(LocationPollThread, 10240,(void *)i))==(void*)-1) + if ((GLOBALS.PollingThreads[i] = CoroScheduler.createProcess(LocationPollThread, &i, sizeof(uint32))) == CORO_INVALID_PID_VALUE) +// if ((GLOBALS.hEndPollingLocations[i]=(void*)_beginthread(LocationPollThread, 10240,(void *)i))==(void*)-1) return false; return true; @@ -2423,13 +2345,13 @@ void mpalEndIdlePoll(CORO_PARAM, int nLoc, bool *result) { CORO_BEGIN_CODE(_ctx); for (_ctx->i = 0; _ctx->i < MAXPOLLINGLOCATIONS; _ctx->i++) { - if (nPollingLocations[_ctx->i] == (uint32)nLoc) { - CoroScheduler.setEvent(hEndPollingLocations[_ctx->i]); + if (GLOBALS.nPollingLocations[_ctx->i] == (uint32)nLoc) { + CoroScheduler.setEvent(GLOBALS.hEndPollingLocations[_ctx->i]); - CORO_INVOKE_2(CoroScheduler.waitForSingleObject, PollingThreads[_ctx->i], CORO_INFINITE); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, GLOBALS.PollingThreads[_ctx->i], CORO_INFINITE); - CoroScheduler.closeEvent(hEndPollingLocations[_ctx->i]); - nPollingLocations[_ctx->i] = 0; + CoroScheduler.closeEvent(GLOBALS.hEndPollingLocations[_ctx->i]); + GLOBALS.nPollingLocations[_ctx->i] = 0; if (result) *result = true; @@ -2456,7 +2378,7 @@ void mpalEndIdlePoll(CORO_PARAM, int nLoc, bool *result) { \****************************************************************************/ int mpalGetSaveStateSize(void) { - return nVars * sizeof(MPALVAR) + 4; + return GLOBALS.nVars * sizeof(MPALVAR) + 4; } @@ -2473,8 +2395,8 @@ int mpalGetSaveStateSize(void) { void mpalSaveState(byte *buf) { LockVar(); - WRITE_LE_UINT32(buf, nVars); - CopyMemory(buf + 4, (byte *)lpmvVars, nVars * sizeof(MPALVAR)); + WRITE_LE_UINT32(buf, GLOBALS.nVars); + CopyMemory(buf + 4, (byte *)GLOBALS.lpmvVars, GLOBALS.nVars * sizeof(MPALVAR)); UnlockVar(); } @@ -2492,16 +2414,16 @@ void mpalSaveState(byte *buf) { int mpalLoadState(byte *buf) { // Dobbiamo distruggere tutte le variabili e ricrearle - GlobalFree(hVars); + GlobalFree(GLOBALS.hVars); - nVars = READ_LE_UINT32(buf); + GLOBALS.nVars = READ_LE_UINT32(buf); - hVars = GlobalAlloc(GMEM_ZEROINIT | GMEM_MOVEABLE, nVars * sizeof(MPALVAR)); + GLOBALS.hVars = GlobalAlloc(GMEM_ZEROINIT | GMEM_MOVEABLE, GLOBALS.nVars * sizeof(MPALVAR)); LockVar(); - CopyMemory((byte *)lpmvVars, buf + 4, nVars * sizeof(MPALVAR)); + CopyMemory((byte *)GLOBALS.lpmvVars, buf + 4, GLOBALS.nVars * sizeof(MPALVAR)); UnlockVar(); - return nVars*sizeof(MPALVAR)+4; + return GLOBALS.nVars*sizeof(MPALVAR)+4; } bool bDontOutput; @@ -2652,18 +2574,18 @@ void mpalDumpMessages(void) { f = g_system->getSavefileManager()->openForSaving("Messages.htm"); f->writeString("\n\n
%s %s %s %s
\n"); - for (i = 0; i < nMsgs; i++) { - lpMessage = (char*)GlobalLock(lpmmMsgs[i].hText); + for (i = 0; i < GLOBALS.nMsgs; i++) { + lpMessage = (char*)GlobalLock(GLOBALS.lpmmMsgs[i].hText); if (*lpMessage != '\0') { // bernie: debug - /*if (lpmmMsgs[i].wNum == 1950) { + /*if (GLOBALS.lpmmMsgs[i].wNum == 1950) { int a = 1; }*/ nPeriods = 1; p=lpPeriods[0] = lpMessage; - OutputStartMsgComment(lpmmMsgs[i].wNum, f); + OutputStartMsgComment(GLOBALS.lpmmMsgs[i].wNum, f); while (1) { // Trova la fine del periodo corrente @@ -2682,9 +2604,9 @@ void mpalDumpMessages(void) { // Ora fa un ciclo su tutti i periodi for (j = 0;jwriteString("\n\n"); - for (i = 0; i < nMsgs; i++) { - lpMessage = (char*)GlobalLock(lpmmMsgs[i].hText); + for (i = 0; i < GLOBALS.nMsgs; i++) { + lpMessage = (char*)GlobalLock(GLOBALS.lpmmMsgs[i].hText); if (*lpMessage != '\0') { nPeriods = 1; p=lpPeriods[0] = lpMessage; - if (OutputStartOther(lpmmMsgs[i].wNum, f)) { + if (OutputStartOther(GLOBALS.lpmmMsgs[i].wNum, f)) { while (1) { // Trova la fine del periodo corrente while (*p!='\0') @@ -2768,9 +2690,9 @@ void mpalDumpOthers(void) { // Ora fa un ciclo su tutti i periodi for (j = 0; j < nPeriods; j++) { if (nPeriods == 1) - sprintf(fname, "000-%05d.WAV", lpmmMsgs[i].wNum); + sprintf(fname, "000-%05d.WAV", GLOBALS.lpmmMsgs[i].wNum); else - sprintf(fname, "000-%05d-%02d.WAV", lpmmMsgs[i].wNum,j); + sprintf(fname, "000-%05d-%02d.WAV", GLOBALS.lpmmMsgs[i].wNum,j); strcpy(frase,lpPeriods[j]); @@ -2792,9 +2714,9 @@ void mpalDumpOthers(void) { } } - OutputEndOther(lpmmMsgs[i].wNum, f); + OutputEndOther(GLOBALS.lpmmMsgs[i].wNum, f); - GlobalUnlock(lpmmMsgs[i].hText); + GlobalUnlock(GLOBALS.lpmmMsgs[i].hText); } } @@ -3284,8 +3206,8 @@ void mpalDumpDialogs(void) { LockDialogs(); - for (i = 0; i < nDialogs; i++) - mpalDumpDialog(&lpmdDialogs[i]); + for (i = 0; i < GLOBALS.nDialogs; i++) + mpalDumpDialog(&GLOBALS.lpmdDialogs[i]); UnlockDialogs(); } diff --git a/engines/tony/mpal/mpaldll.h b/engines/tony/mpal/mpaldll.h index ee3820531a..a7b6dfc5aa 100644 --- a/engines/tony/mpal/mpaldll.h +++ b/engines/tony/mpal/mpaldll.h @@ -51,8 +51,10 @@ #define __MPALDLL_H #include "common/file.h" -#include "memory.h" -#include "stubs.h" +#include "tony/mpal/memory.h" +#include "tony/mpal/stubs.h" +#include "tony/mpal/loadmpc.h" +#include "tony/mpal/expr.h" namespace Tony { @@ -332,41 +334,6 @@ typedef LPMPALSCRIPT* LPLPMPALSCRIPT; #include "common/pack-end.h" -/****************************************************************************\ -* Variabili globali -\****************************************************************************/ - -extern uint32 mpalError; -extern LPLPCUSTOMFUNCTION lplpFunctions; -extern uint16 nObjs; - -extern uint16 nVars; -extern HGLOBAL hVars; -extern LPMPALVAR lpmvVars; - -extern uint16 nMsgs; -extern HGLOBAL hMsgs; -extern LPMPALMSG lpmmMsgs; - -extern uint16 nDialogs; -extern HGLOBAL hDialogs; -extern LPMPALDIALOG lpmdDialogs; - -extern uint16 nItems; -extern HGLOBAL hItems; -extern LPMPALITEM lpmiItems; - -extern uint16 nLocations; -extern HGLOBAL hLocations; -extern LPMPALLOCATION lpmlLocations; - -extern uint16 nScripts; -extern HGLOBAL hScripts; -extern LPMPALSCRIPT lpmsScripts; - -extern Common::File hMpr; -extern uint16 nResources; -extern uint32 * lpResources; /****************************************************************************\ * Prototipi di funzione @@ -412,8 +379,5 @@ void varSetValue(const char *lpszVarName, int32 val); } // end of namespace Tony -#include "loadmpc.h" -#include "expr.h" - #endif -- cgit v1.2.3 From cf3d2cd3562a6d30690f6e8acb8fb4f17739fa35 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 14 May 2012 08:53:09 +1000 Subject: TONY: Removed some no longer needed FIXME's --- engines/tony/loc.cpp | 1 - engines/tony/mpal/mpal.cpp | 1 - engines/tony/tony.cpp | 1 - 3 files changed, 3 deletions(-) (limited to 'engines') diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 70e800a5d4..cee657791d 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -1021,7 +1021,6 @@ void RMWipe::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { /***************************************************************************/ short RMCharacter::FindPath(short source, short destination) { - // FIXME: Refactor static RMBox BOX[MAXBOXES]; // Matrice di Adjacenza static short COSTO[MAXBOXES]; // Costi per Nodo static short VALIDO[MAXBOXES]; // 0:non valido 1:valido 2:saturo diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 66d467f301..f049ecf3ea 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -1229,7 +1229,6 @@ void LocationPollThread(CORO_PARAM, const void *param) { */ // Set idle skip on - // FIXME: Convert to co-routine CORO_INVOKE_4(GLOBALS.lplpFunctions[200], 0, 0, 0, 0); for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index aa110ce008..d476f60859 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -514,7 +514,6 @@ void TonyEngine::PlayProcess(CORO_PARAM, const void *param) { CORO_INVOKE_1(CoroScheduler.sleep, 50); // Call the engine to handle the next frame - // FIXME: This needs to be moved into it's own process CORO_INVOKE_1(_vm->_theEngine.DoFrame, _vm->m_bDrawLocation); // Warns that a frame is finished -- cgit v1.2.3 From 099fe1e9e62ada666a312e08d7dca5cd2083de0b Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 14 May 2012 07:43:50 +0200 Subject: TONY: Remove original header --- engines/tony/adv.h | 35 ++++++++--------------------------- engines/tony/custom.cpp | 30 +++++------------------------- engines/tony/custom.h | 31 ++++++------------------------- engines/tony/font.cpp | 31 ++++++------------------------- engines/tony/font.h | 30 +++++------------------------- engines/tony/game.cpp | 31 ++++++------------------------- engines/tony/game.h | 31 ++++++------------------------- engines/tony/gfxcore.cpp | 31 ++++++------------------------- engines/tony/gfxcore.h | 31 ++++++------------------------- engines/tony/gfxengine.cpp | 31 ++++++------------------------- engines/tony/gfxengine.h | 31 ++++++------------------------- engines/tony/input.cpp | 31 ++++++------------------------- engines/tony/input.h | 31 ++++++------------------------- engines/tony/inventory.cpp | 31 ++++++------------------------- engines/tony/inventory.h | 31 ++++++------------------------- engines/tony/loc.cpp | 31 ++++++------------------------- engines/tony/loc.h | 31 ++++++------------------------- engines/tony/resid.h | 9 +++------ engines/tony/sound.cpp | 31 ++++++------------------------- engines/tony/sound.h | 31 ++++++------------------------- engines/tony/tonychar.cpp | 31 ++++++------------------------- engines/tony/tonychar.h | 31 ++++++------------------------- engines/tony/utils.cpp | 31 ++++++------------------------- engines/tony/utils.h | 31 ++++++------------------------- engines/tony/window.cpp | 31 ++++++------------------------- engines/tony/window.h | 39 ++++++++++----------------------------- 26 files changed, 157 insertions(+), 637 deletions(-) (limited to 'engines') diff --git a/engines/tony/adv.h b/engines/tony/adv.h index 6a1b6ce246..314672fe39 100644 --- a/engines/tony/adv.h +++ b/engines/tony/adv.h @@ -19,31 +19,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * Nayma Software srl * - * e -= We create much MORE than ALL =- * - * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * - * .d" d$$$$$b "b. * - * .z$* d$$$$$$$L ^*$c. * - * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * - * ^*$b 4$$$$$$$$$F .d$*" * - * ^$$. 4$$$$$$$$$F .$P" Module: ADV.CPP.............. * - * *$. '$$$$$$$$$ 4$P 4 * - * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * - * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c * - * z$$beu .ue=" $ "=e.. .zed$$c * - * "#$e z$*" . `. ^*Nc e$"" * - * "$$". .r" ^4. .^$$" * - * ^.@*"6L=\ebu^+C$"*b." * - * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * - * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * - * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * - * * - * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * - * * - **************************************************************************/ + +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ #ifndef TONY_ADV_H #define TONY_ADV_H @@ -59,7 +40,7 @@ namespace Tony { #define RM_SX 640 #define RM_SY 480 -// Dimensioni X&Y del bigbuf +// X&Y dimensions of bigbuf #define RM_BBX (RM_SX) #define RM_BBY (RM_SY) @@ -90,7 +71,7 @@ enum RMTonyAction { TA_RECEIVECOMBINEGIVE }; -// Funzioni globali +// Global Functions uint32 MainLoadLocation(int nLoc, RMPoint pt, RMPoint start); void MainUnloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result); void MainLinkGraphicTask(RMGfxTask *task); diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 168c2d38cd..c84aa63edb 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -20,31 +20,11 @@ * * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * Nayma Software srl * - * e -= We create much MORE than ALL =- * - * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * - * .d" d$$$$$b "b. * - * .z$* d$$$$$$$L ^*$c. * - * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * - * ^*$b 4$$$$$$$$$F .d$*" * - * ^$$. 4$$$$$$$$$F .$P" Module: Custom.CPP........... * - * *$. '$$$$$$$$$ 4$P 4 * - * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * - * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c Desc: Custom functions..... * - * z$$beu .ue=" $ "=e.. .zed$$c ..................... * - * "#$e z$*" . `. ^*Nc e$"" ..................... * - * "$$". .r" ^4. .^$$" ..................... * - * ^.@*"6L=\ebu^+C$"*b." * - * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * - * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * - * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * - * * - * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * - * * - ************************************************************************** + +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software */ #include "common/system.h" diff --git a/engines/tony/custom.h b/engines/tony/custom.h index 4b9701cec4..875710f974 100644 --- a/engines/tony/custom.h +++ b/engines/tony/custom.h @@ -20,31 +20,12 @@ * * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * Nayma Software srl * - * e -= We create much MORE than ALL =- * - * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * - * .d" d$$$$$b "b. * - * .z$* d$$$$$$$L ^*$c. * - * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * - * ^*$b 4$$$$$$$$$F .d$*" * - * ^$$. 4$$$$$$$$$F .$P" Module: Custom.CPP........... * - * *$. '$$$$$$$$$ 4$P 4 * - * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * - * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c Desc: Custom functions..... * - * z$$beu .ue=" $ "=e.. .zed$$c ..................... * - * "#$e z$*" . `. ^*Nc e$"" ..................... * - * "$$". .r" ^4. .^$$" ..................... * - * ^.@*"6L=\ebu^+C$"*b." * - * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * - * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * - * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * - * * - * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * - * * - **************************************************************************/ + +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ #ifndef TONY_CUSTOM_H #define TONY_CUSTOM_H diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 8957c09a87..c2af10c74a 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -19,31 +19,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * Nayma Software srl * - * e -= We create much MORE than ALL =- * - * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * - * .d" d$$$$$b "b. * - * .z$* d$$$$$$$L ^*$c. * - * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * - * ^*$b 4$$$$$$$$$F .d$*" * - * ^$$. 4$$$$$$$$$F .$P" Module: Font.CPP............. * - * *$. '$$$$$$$$$ 4$P 4 * - * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * - * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c * - * z$$beu .ue=" $ "=e.. .zed$$c * - * "#$e z$*" . `. ^*Nc e$"" * - * "$$". .r" ^4. .^$$" * - * ^.@*"6L=\ebu^+C$"*b." * - * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * - * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * - * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * - * * - * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * - * * - **************************************************************************/ + +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ #include "common/textconsole.h" #include "tony/mpal/mpalutils.h" diff --git a/engines/tony/font.h b/engines/tony/font.h index 36fdc9baed..9715e95043 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -19,31 +19,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * Nayma Software srl * - * e -= We create much MORE than ALL =- * - * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * - * .d" d$$$$$b "b. * - * .z$* d$$$$$$$L ^*$c. * - * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * - * ^*$b 4$$$$$$$$$F .d$*" * - * ^$$. 4$$$$$$$$$F .$P" Module: Font.CPP............. * - * *$. '$$$$$$$$$ 4$P 4 * - * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * - * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c * - * z$$beu .ue=" $ "=e.. .zed$$c * - * "#$e z$*" . `. ^*Nc e$"" * - * "$$". .r" ^4. .^$$" * - * ^.@*"6L=\ebu^+C$"*b." * - * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * - * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * - * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * - * * - * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * - * * - **************************************************************************/ +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ #ifndef TONY_FONT_H #define TONY_FONT_H diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index b21498a5e8..8844374821 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -19,31 +19,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * Nayma Software srl * - * e -= We create much MORE than ALL =- * - * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * - * .d" d$$$$$b "b. * - * .z$* d$$$$$$$L ^*$c. * - * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * - * ^*$b 4$$$$$$$$$F .d$*" * - * ^$$. 4$$$$$$$$$F .$P" Module: Loc.CPP.............. * - * *$. '$$$$$$$$$ 4$P 4 * - * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * - * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c * - * z$$beu .ue=" $ "=e.. .zed$$c * - * "#$e z$*" . `. ^*Nc e$"" * - * "$$". .r" ^4. .^$$" * - * ^.@*"6L=\ebu^+C$"*b." * - * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * - * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * - * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * - * * - * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * - * * - **************************************************************************/ + +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ #include "common/file.h" #include "common/savefile.h" diff --git a/engines/tony/game.h b/engines/tony/game.h index 80482f39da..83972e0f17 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -19,31 +19,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * Nayma Software srl * - * e -= We create much MORE than ALL =- * - * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * - * .d" d$$$$$b "b. * - * .z$* d$$$$$$$L ^*$c. * - * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * - * ^*$b 4$$$$$$$$$F .d$*" * - * ^$$. 4$$$$$$$$$F .$P" Module: Game.CPP............. * - * *$. '$$$$$$$$$ 4$P 4 * - * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * - * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c * - * z$$beu .ue=" $ "=e.. .zed$$c * - * "#$e z$*" . `. ^*Nc e$"" * - * "$$". .r" ^4. .^$$" * - * ^.@*"6L=\ebu^+C$"*b." * - * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * - * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * - * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * - * * - * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * - * * - **************************************************************************/ + +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ #ifndef TONY_GAME_H #define TONY_GAME_H diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 0c5ffa8096..826159a8d7 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -19,31 +19,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * Nayma Software srl * - * e -= We create much MORE than ALL =- * - * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * - * .d" d$$$$$b "b. * - * .z$* d$$$$$$$L ^*$c. * - * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * - * ^*$b 4$$$$$$$$$F .d$*" * - * ^$$. 4$$$$$$$$$F .$P" Module: GfxCore.CPP.......... * - * *$. '$$$$$$$$$ 4$P 4 * - * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * - * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c * - * z$$beu .ue=" $ "=e.. .zed$$c * - * "#$e z$*" . `. ^*Nc e$"" * - * "$$". .r" ^4. .^$$" * - * ^.@*"6L=\ebu^+C$"*b." * - * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * - * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * - * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * - * * - * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * - * * - **************************************************************************/ + +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ #include "tony/gfxengine.h" #include "tony/mpal/mpalutils.h" diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index 23f1a9809a..dacb66d68c 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -19,31 +19,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * Nayma Software srl * - * e -= We create much MORE than ALL =- * - * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * - * .d" d$$$$$b "b. * - * .z$* d$$$$$$$L ^*$c. * - * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * - * ^*$b 4$$$$$$$$$F .d$*" * - * ^$$. 4$$$$$$$$$F .$P" Module: GfxCore.CPP.......... * - * *$. '$$$$$$$$$ 4$P 4 * - * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * - * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c * - * z$$beu .ue=" $ "=e.. .zed$$c * - * "#$e z$*" . `. ^*Nc e$"" * - * "$$". .r" ^4. .^$$" * - * ^.@*"6L=\ebu^+C$"*b." * - * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * - * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * - * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * - * * - * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * - * * - **************************************************************************/ + +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ #ifndef TONY_GFXCORE_H #define TONY_GFXCORE_H diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index bf1a08f245..4a0fdc0795 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -19,31 +19,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * Nayma Software srl * - * e -= We create much MORE than ALL =- * - * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * - * .d" d$$$$$b "b. * - * .z$* d$$$$$$$L ^*$c. * - * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * - * ^*$b 4$$$$$$$$$F .d$*" * - * ^$$. 4$$$$$$$$$F .$P" Module: GfxEngine.CPP........ * - * *$. '$$$$$$$$$ 4$P 4 * - * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * - * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c * - * z$$beu .ue=" $ "=e.. .zed$$c * - * "#$e z$*" . `. ^*Nc e$"" * - * "$$". .r" ^4. .^$$" * - * ^.@*"6L=\ebu^+C$"*b." * - * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * - * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * - * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * - * * - * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * - * * - **************************************************************************/ + +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ #include "common/savefile.h" #include "tony/mpal/lzo.h" diff --git a/engines/tony/gfxengine.h b/engines/tony/gfxengine.h index 3f90d41ad7..2aae0b6ea6 100644 --- a/engines/tony/gfxengine.h +++ b/engines/tony/gfxengine.h @@ -19,31 +19,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * Nayma Software srl * - * e -= We create much MORE than ALL =- * - * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * - * .d" d$$$$$b "b. * - * .z$* d$$$$$$$L ^*$c. * - * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * - * ^*$b 4$$$$$$$$$F .d$*" * - * ^$$. 4$$$$$$$$$F .$P" Module: GfxEngine.CPP........ * - * *$. '$$$$$$$$$ 4$P 4 * - * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * - * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c * - * z$$beu .ue=" $ "=e.. .zed$$c * - * "#$e z$*" . `. ^*Nc e$"" * - * "$$". .r" ^4. .^$$" * - * ^.@*"6L=\ebu^+C$"*b." * - * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * - * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * - * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * - * * - * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * - * * - **************************************************************************/ + +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ #ifndef TONY_GFXENGINE_H #define TONY_GFXENGINE_H diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp index f29d4ddc8e..97425e49c9 100644 --- a/engines/tony/input.cpp +++ b/engines/tony/input.cpp @@ -19,31 +19,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * Nayma Software srl * - * e -= We create much MORE than ALL =- * - * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * - * .d" d$$$$$b "b. * - * .z$* d$$$$$$$L ^*$c. * - * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * - * ^*$b 4$$$$$$$$$F .d$*" * - * ^$$. 4$$$$$$$$$F .$P" Module: Input.CPP............ * - * *$. '$$$$$$$$$ 4$P 4 * - * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * - * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c * - * z$$beu .ue=" $ "=e.. .zed$$c * - * "#$e z$*" . `. ^*Nc e$"" * - * "$$". .r" ^4. .^$$" * - * ^.@*"6L=\ebu^+C$"*b." * - * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * - * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * - * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * - * * - * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * - * * - **************************************************************************/ + +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ #include "tony/gfxengine.h" diff --git a/engines/tony/input.h b/engines/tony/input.h index 79a11db678..544424581f 100644 --- a/engines/tony/input.h +++ b/engines/tony/input.h @@ -19,31 +19,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * Nayma Software srl * - * e -= We create much MORE than ALL =- * - * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * - * .d" d$$$$$b "b. * - * .z$* d$$$$$$$L ^*$c. * - * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * - * ^*$b 4$$$$$$$$$F .d$*" * - * ^$$. 4$$$$$$$$$F .$P" Module: Input.CPP............ * - * *$. '$$$$$$$$$ 4$P 4 * - * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * - * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c * - * z$$beu .ue=" $ "=e.. .zed$$c * - * "#$e z$*" . `. ^*Nc e$"" * - * "$$". .r" ^4. .^$$" * - * ^.@*"6L=\ebu^+C$"*b." * - * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * - * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * - * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * - * * - * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * - * * - **************************************************************************/ + +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ #ifndef TONY_INPUT_H #define TONY_INPUT_H diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index fbc0918e10..7b53e75cdd 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -19,31 +19,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * Nayma Software srl * - * e -= We create much MORE than ALL =- * - * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * - * .d" d$$$$$b "b. * - * .z$* d$$$$$$$L ^*$c. * - * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * - * ^*$b 4$$$$$$$$$F .d$*" * - * ^$$. 4$$$$$$$$$F .$P" Module: Inventory.CPP........ * - * *$. '$$$$$$$$$ 4$P 4 * - * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * - * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c * - * z$$beu .ue=" $ "=e.. .zed$$c * - * "#$e z$*" . `. ^*Nc e$"" * - * "$$". .r" ^4. .^$$" * - * ^.@*"6L=\ebu^+C$"*b." * - * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * - * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * - * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * - * * - * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * - * * - **************************************************************************/ + +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ #include "common/textconsole.h" #include "tony/mpal/mpalutils.h" diff --git a/engines/tony/inventory.h b/engines/tony/inventory.h index 86eaa6801e..309674ff0a 100644 --- a/engines/tony/inventory.h +++ b/engines/tony/inventory.h @@ -19,31 +19,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * Nayma Software srl * - * e -= We create much MORE than ALL =- * - * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * - * .d" d$$$$$b "b. * - * .z$* d$$$$$$$L ^*$c. * - * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * - * ^*$b 4$$$$$$$$$F .d$*" * - * ^$$. 4$$$$$$$$$F .$P" Module: Inventory.CPP........ * - * *$. '$$$$$$$$$ 4$P 4 * - * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * - * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c * - * z$$beu .ue=" $ "=e.. .zed$$c * - * "#$e z$*" . `. ^*Nc e$"" * - * "$$". .r" ^4. .^$$" * - * ^.@*"6L=\ebu^+C$"*b." * - * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * - * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * - * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * - * * - * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * - * * - **************************************************************************/ + +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ #ifndef TONY_INVENTORY_H #define TONY_INVENTORY_H diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index cee657791d..b88fc68fc5 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -19,31 +19,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * Nayma Software srl * - * e -= We create much MORE than ALL =- * - * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * - * .d" d$$$$$b "b. * - * .z$* d$$$$$$$L ^*$c. * - * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * - * ^*$b 4$$$$$$$$$F .d$*" * - * ^$$. 4$$$$$$$$$F .$P" Module: Loc.CPP.............. * - * *$. '$$$$$$$$$ 4$P 4 * - * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * - * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c * - * z$$beu .ue=" $ "=e.. .zed$$c * - * "#$e z$*" . `. ^*Nc e$"" * - * "$$". .r" ^4. .^$$" * - * ^.@*"6L=\ebu^+C$"*b." * - * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * - * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * - * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * - * * - * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * - * * - **************************************************************************/ + +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ #include "common/scummsys.h" #include "tony/mpal/mpalutils.h" diff --git a/engines/tony/loc.h b/engines/tony/loc.h index bbb98bd9db..aee4936490 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -19,31 +19,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * Nayma Software srl * - * e -= We create much MORE than ALL =- * - * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * - * .d" d$$$$$b "b. * - * .z$* d$$$$$$$L ^*$c. * - * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * - * ^*$b 4$$$$$$$$$F .d$*" * - * ^$$. 4$$$$$$$$$F .$P" Module: Loc.CPP.............. * - * *$. '$$$$$$$$$ 4$P 4 * - * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * - * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c * - * z$$beu .ue=" $ "=e.. .zed$$c * - * "#$e z$*" . `. ^*Nc e$"" * - * "$$". .r" ^4. .^$$" * - * ^.@*"6L=\ebu^+C$"*b." * - * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * - * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * - * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * - * * - * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * - * * - **************************************************************************/ + +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ #ifndef TONY_LOC_H #define TONY_LOC_H diff --git a/engines/tony/resid.h b/engines/tony/resid.h index 01ed9b9bd2..aec4d4c38c 100644 --- a/engines/tony/resid.h +++ b/engines/tony/resid.h @@ -19,14 +19,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ + /* - * ResID.H - Include per le risorse MPAL - * - * Coded by Giovanni Bajo - Nayma/Prograph - * - * (C) 1997-98, Nayma Software - * (C) 1998, Prograph Research srl + * This code is based on original Tony Tough source code * + * Copyright (c) 1997-2003 Nayma Software */ /* diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index 61d225b88b..4f7a28b2b3 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -19,31 +19,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * Nayma Software srl * - * e -= We create much MORE than ALL =- * - * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * - * .d" d$$$$$b "b. * - * .z$* d$$$$$$$L ^*$c. * - * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * - * ^*$b 4$$$$$$$$$F .d$*" * - * ^$$. 4$$$$$$$$$F .$P" Module: Sound.CPP............ * - * *$. '$$$$$$$$$ 4$P 4 * - * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * - * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c * - * z$$beu .ue=" $ "=e.. .zed$$c * - * "#$e z$*" . `. ^*Nc e$"" * - * "$$". .r" ^4. .^$$" * - * ^.@*"6L=\ebu^+C$"*b." * - * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * - * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * - * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * - * * - * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * - * * - **************************************************************************/ + +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ #include "common/textconsole.h" #include "tony/game.h" diff --git a/engines/tony/sound.h b/engines/tony/sound.h index e263c7ee51..bfa48f4d78 100644 --- a/engines/tony/sound.h +++ b/engines/tony/sound.h @@ -19,31 +19,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * Nayma Software srl * - * e -= We create much MORE than ALL =- * - * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * - * .d" d$$$$$b "b. * - * .z$* d$$$$$$$L ^*$c. * - * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * - * ^*$b 4$$$$$$$$$F .d$*" * - * ^$$. 4$$$$$$$$$F .$P" Module: Sound.CPP............ * - * *$. '$$$$$$$$$ 4$P 4 * - * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * - * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c * - * z$$beu .ue=" $ "=e.. .zed$$c * - * "#$e z$*" . `. ^*Nc e$"" * - * "$$". .r" ^4. .^$$" * - * ^.@*"6L=\ebu^+C$"*b." * - * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * - * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * - * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * - * * - * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * - * * - **************************************************************************/ + +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ #ifndef TONY_SOUND_H #define TONY_SOUND_H diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index 7430ca89ae..df92cafebd 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -19,31 +19,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * Nayma Software srl * - * e -= We create much MORE than ALL =- * - * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * - * .d" d$$$$$b "b. * - * .z$* d$$$$$$$L ^*$c. * - * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * - * ^*$b 4$$$$$$$$$F .d$*" * - * ^$$. 4$$$$$$$$$F .$P" Module: TonyChar.CPP......... * - * *$. '$$$$$$$$$ 4$P 4 * - * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * - * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c * - * z$$beu .ue=" $ "=e.. .zed$$c * - * "#$e z$*" . `. ^*Nc e$"" * - * "$$". .r" ^4. .^$$" * - * ^.@*"6L=\ebu^+C$"*b." * - * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * - * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * - * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * - * * - * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * - * * - **************************************************************************/ + +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ #include "tony/mpal/memory.h" #include "tony/mpal/mpalutils.h" diff --git a/engines/tony/tonychar.h b/engines/tony/tonychar.h index 27d62d9d57..9cea3a4b2d 100644 --- a/engines/tony/tonychar.h +++ b/engines/tony/tonychar.h @@ -19,31 +19,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * Nayma Software srl * - * e -= We create much MORE than ALL =- * - * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * - * .d" d$$$$$b "b. * - * .z$* d$$$$$$$L ^*$c. * - * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * - * ^*$b 4$$$$$$$$$F .d$*" * - * ^$$. 4$$$$$$$$$F .$P" Module: TonyChar.CPP......... * - * *$. '$$$$$$$$$ 4$P 4 * - * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * - * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c * - * z$$beu .ue=" $ "=e.. .zed$$c * - * "#$e z$*" . `. ^*Nc e$"" * - * "$$". .r" ^4. .^$$" * - * ^.@*"6L=\ebu^+C$"*b." * - * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * - * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * - * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * - * * - * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * - * * - **************************************************************************/ + +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ #ifndef TONY_TONYCHAR_H #define TONY_TONYCHAR_H diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index a3998a01ab..d57640fee8 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -19,31 +19,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * Nayma Software srl * - * e -= We create much MORE than ALL =- * - * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * - * .d" d$$$$$b "b. * - * .z$* d$$$$$$$L ^*$c. * - * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * - * ^*$b 4$$$$$$$$$F .d$*" * - * ^$$. 4$$$$$$$$$F .$P" Module: Utils.CPP............ * - * *$. '$$$$$$$$$ 4$P 4 * - * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * - * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c * - * z$$beu .ue=" $ "=e.. .zed$$c * - * "#$e z$*" . `. ^*Nc e$"" * - * "$$". .r" ^4. .^$$" * - * ^.@*"6L=\ebu^+C$"*b." * - * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * - * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * - * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * - * * - * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * - * * - **************************************************************************/ + +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ #include "tony/utils.h" #include "tony/tony.h" diff --git a/engines/tony/utils.h b/engines/tony/utils.h index 4137823587..1e3841c185 100644 --- a/engines/tony/utils.h +++ b/engines/tony/utils.h @@ -19,31 +19,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * Nayma Software srl * - * e -= We create much MORE than ALL =- * - * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * - * .d" d$$$$$b "b. * - * .z$* d$$$$$$$L ^*$c. * - * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * - * ^*$b 4$$$$$$$$$F .d$*" * - * ^$$. 4$$$$$$$$$F .$P" Module: Utils.CPP............ * - * *$. '$$$$$$$$$ 4$P 4 * - * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * - * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c * - * z$$beu .ue=" $ "=e.. .zed$$c * - * "#$e z$*" . `. ^*Nc e$"" * - * "$$". .r" ^4. .^$$" * - * ^.@*"6L=\ebu^+C$"*b." * - * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * - * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * - * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * - * * - * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * - * * - **************************************************************************/ + +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ #ifndef TONY_UTILS_H #define TONY_UTILS_H diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index 18e6901547..92f6dea032 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -19,31 +19,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * Nayma Software srl * - * e -= We create much MORE than ALL =- * - * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * - * .d" d$$$$$b "b. * - * .z$* d$$$$$$$L ^*$c. * - * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * - * ^*$b 4$$$$$$$$$F .d$*" * - * ^$$. 4$$$$$$$$$F .$P" Module: Window.HPP........... * - * *$. '$$$$$$$$$ 4$P 4 * - * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * - * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c Desc: Classi per la gestione * - * z$$beu .ue=" $ "=e.. .zed$$c di una finestra Direct - * "#$e z$*" . `. ^*Nc e$"" Draw................. * - * "$$". .r" ^4. .^$$" ..................... * - * ^.@*"6L=\ebu^+C$"*b." * - * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * - * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * - * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * - * * - * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * - * * - **************************************************************************/ + +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ #include "common/scummsys.h" #include "util.h" diff --git a/engines/tony/window.h b/engines/tony/window.h index 56f48d7698..ea26df3920 100644 --- a/engines/tony/window.h +++ b/engines/tony/window.h @@ -19,31 +19,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * Nayma Software srl * - * e -= We create much MORE than ALL =- * - * u- z$$$c '. 様様様様様様様様様様様様様様様様様 * - * .d" d$$$$$b "b. * - * .z$* d$$$$$$$L ^*$c. * - * #$$$. $$$$$$$$$ .$$$" Project: Roasted Moths........ * - * ^*$b 4$$$$$$$$$F .d$*" * - * ^$$. 4$$$$$$$$$F .$P" Module: Window.HPP........... * - * *$. '$$$$$$$$$ 4$P 4 * - * J *$ "$$$$$$$" $P r Author: Giovanni Bajo........ * - * z$ '$$$P*4c.*$$$*.z@*R$$$ $. * - * z$" "" #$F^ "" '$c Desc: Classi per la gestione * - * z$$beu .ue=" $ "=e.. .zed$$c di una finestra Direct - * "#$e z$*" . `. ^*Nc e$"" Draw................. * - * "$$". .r" ^4. .^$$" ..................... * - * ^.@*"6L=\ebu^+C$"*b." * - * "**$. "c 4$$$ J" J$P*" OS: [ ] DOS [X] WIN95 [ ] PORT * - * ^"--.^ 9$" .--"" COMP: [ ] WATCOM [X] VISUAL C++ * - * " [ ] EIFFEL [ ] GCC/GXX/DJGPP * - * * - * This source code is Copyright (C) Nayma Software. ALL RIGHTS RESERVED * - * * - **************************************************************************/ + +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ #ifndef TONY_WINDOW_H #define TONY_WINDOW_H @@ -60,18 +41,18 @@ struct DDSURFACEDESC { class RMSnapshot { private: - // Buffer per la creazione dei path + // Buffer used to create a path static char bufDrive[MAX_DRIVE], bufDir[MAX_DIR], bufName[MAX_FNAME], bufExt[MAX_EXT]; static char filename[512]; - // Buffer per la conversione a RGB + // Buffer used to convert a RGB static byte rgb[RM_SX * RM_SY * 3]; private: bool GetFreeSnapName(char *fn); public: - // Prende uno screenshot + // Take a screenshot void GrabScreenshot(byte *lpBuf, int dezoom = 1, uint16 *lpDestBuf = NULL); }; @@ -105,7 +86,7 @@ public: RMWindow(); ~RMWindow(); - // Inizializzazione + // Initialization void Init(/*HINSTANCE hInst*/); void InitDirectDraw(void); void Close(void); -- cgit v1.2.3 From 4bf61b2f02bc933f66588332de37e1fdb996468b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 14 May 2012 20:20:02 +1000 Subject: TONY: Fixed nasty cast in ItemIrq initialisation --- engines/tony/gfxengine.cpp | 19 ++++++------------- engines/tony/globals.cpp | 1 + engines/tony/globals.h | 2 ++ 3 files changed, 9 insertions(+), 13 deletions(-) (limited to 'engines') diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 4a0fdc0795..a2b58f660e 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -361,28 +361,21 @@ void RMGfxEngine::InitCustomDll(void) { SetupGlobalVars(&m_tony, &m_point, &_vm->_theBoxes, &m_loc, &m_inv, &m_input); } -// FIXME: Casting nPattern from int to RMGfxEngine * void RMGfxEngine::ItemIrq(uint32 dwItem, int nPattern, int nStatus) { - static RMGfxEngine *This = NULL; RMItem *item; + assert(GLOBALS.GfxEngine); - // Inizializzazione! - if ((int)dwItem == -1) { - This = (RMGfxEngine*)nPattern; - return; - } - - if (This->m_bLocationLoaded) { - item=This->m_loc.GetItemFromCode(dwItem); + if (GLOBALS.GfxEngine->m_bLocationLoaded) { + item = GLOBALS.GfxEngine->m_loc.GetItemFromCode(dwItem); if (item != NULL) { - if (nPattern!=-1) { + if (nPattern != -1) { if (GLOBALS.bPatIrqFreeze) MainFreeze(); item->SetPattern(nPattern,true); if (GLOBALS.bPatIrqFreeze) MainUnfreeze(); } - if (nStatus!=-1) + if (nStatus != -1) item->SetStatus(nStatus); } } @@ -597,7 +590,7 @@ void RMGfxEngine::Init(/*HINSTANCE hInst*/) { csMainLoop = g_system->createMutex(); // Inizializza la funzione di IRQ di Item per l'MPAL - ItemIrq((uint32)-1, (uint32)this, 0); + GLOBALS.GfxEngine = this; mpalInstallItemIrq(ItemIrq); // Inizializza DirectInput diff --git a/engines/tony/globals.cpp b/engines/tony/globals.cpp index 0ce99f88e7..867d48e0fa 100644 --- a/engines/tony/globals.cpp +++ b/engines/tony/globals.cpp @@ -40,6 +40,7 @@ Globals::Globals() { Loc = NULL; Inventory = NULL; Input = NULL; + GfxEngine = NULL; LoadLocation = NULL; UnloadLocation = NULL; LinkGraphicTask = NULL; diff --git a/engines/tony/globals.h b/engines/tony/globals.h index 1a11a871d0..72faa6a6c5 100644 --- a/engines/tony/globals.h +++ b/engines/tony/globals.h @@ -25,6 +25,7 @@ #include "common/savefile.h" #include "tony/adv.h" +#include "tony/gfxengine.h" #include "tony/input.h" #include "tony/inventory.h" #include "tony/loc.h" @@ -216,6 +217,7 @@ public: RMLocation *Loc; RMInventory *Inventory; RMInput *Input; + RMGfxEngine *GfxEngine; uint32 (*LoadLocation)(int, RMPoint, RMPoint start); void (*UnloadLocation)(CORO_PARAM, bool bDoOnExit, uint32 *result); -- cgit v1.2.3 From 8f4694a80c92b20d76a69c46dc43d1a990ec82c6 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 14 May 2012 20:20:58 +1000 Subject: TONY: Fixed suspicious casting --- engines/tony/custom.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index c84aa63edb..0392fc409d 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -1326,8 +1326,8 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui CORO_BEGIN_CODE(_ctx); // Prende le coordinate di quanto scrollare - _ctx->lx=*((int*)&nX); - _ctx->ly=*((int*)&nY); + _ctx->lx = (int32)nX; + _ctx->ly = (int32)nY; _ctx->dimx = _ctx->lx; _ctx->dimy = _ctx->ly; if (_ctx->lx < 0) _ctx->dimx = -_ctx->lx; -- cgit v1.2.3 From 9eb66a2324120a6c4e22a980a9114bce437fcd8b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 14 May 2012 20:21:54 +1000 Subject: TONY: Added endian fixes for reading data --- engines/tony/mpal/loadmpc.cpp | 62 +++++++++++++++++++++---------------------- engines/tony/sound.cpp | 2 +- 2 files changed, 32 insertions(+), 32 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index 937374517f..6430325503 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -96,27 +96,27 @@ static const byte *ParseScript(const byte *lpBuf, LPMPALSCRIPT lpmsScript) { int curCmd,j,len; uint i; - lpmsScript->nObj=*(int *)lpBuf; - lpBuf+=4; + lpmsScript->nObj = (int32)READ_LE_UINT32(lpBuf); + lpBuf += 4; - lpmsScript->nMoments=*(uint16 *)lpBuf; - lpBuf+=2; + lpmsScript->nMoments = READ_LE_UINT16(lpBuf); + lpBuf += 2; curCmd=0; for (i=0;inMoments;i++) { - lpmsScript->Moment[i].dwTime=*(int *)lpBuf; lpBuf+=4; + lpmsScript->Moment[i].dwTime = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; lpmsScript->Moment[i].nCmds=*lpBuf; lpBuf++; for (j=0;jMoment[i].nCmds;j++) { lpmsScript->Command[curCmd].type=*lpBuf; lpBuf++; switch (lpmsScript->Command[curCmd].type) { case 1: - lpmsScript->Command[curCmd].nCf =*(uint16 *)(lpBuf); lpBuf+=2; - lpmsScript->Command[curCmd].arg1=*(int *)(lpBuf); lpBuf+=4; - lpmsScript->Command[curCmd].arg2=*(int *)(lpBuf); lpBuf+=4; - lpmsScript->Command[curCmd].arg3=*(int *)(lpBuf); lpBuf+=4; - lpmsScript->Command[curCmd].arg4=*(int *)(lpBuf); lpBuf+=4; + lpmsScript->Command[curCmd].nCf = READ_LE_UINT16(lpBuf); lpBuf += 2; + lpmsScript->Command[curCmd].arg1 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; + lpmsScript->Command[curCmd].arg2 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; + lpmsScript->Command[curCmd].arg3 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; + lpmsScript->Command[curCmd].arg4 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; break; case 2: // Variable assign @@ -260,7 +260,7 @@ static const byte *ParseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { error("Too much commands in dialog #%d",lpmdDialog->nObj); /* Choices */ - num=*(uint16 *)lpBuf; lpBuf += 2; + num = READ_LE_UINT16(lpBuf); lpBuf += 2; if (num >= MAX_CHOICES_PER_DIALOG) error("Too much choices in dialog #%d",lpmdDialog->nObj); @@ -343,8 +343,8 @@ static const byte *ParseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { uint32 i,j,kk; uint32 curCmd; - lpmiItem->nObj=*(int *)lpBuf; - lpBuf+=4; + lpmiItem->nObj = (int32)READ_LE_UINT32(lpBuf); + lpBuf += 4; len=*lpBuf; lpBuf++; @@ -367,12 +367,12 @@ static const byte *ParseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { lpmiItem->Action[i].num=*lpBuf; lpBuf++; - lpmiItem->Action[i].wParm=*(uint16 *)lpBuf; - lpBuf+=2; + lpmiItem->Action[i].wParm = READ_LE_UINT16(lpBuf); + lpBuf += 2; if (lpmiItem->Action[i].num==0xFF) { - lpmiItem->Action[i].wTime=*(uint16 *)lpBuf; - lpBuf+=2; + lpmiItem->Action[i].wTime = READ_LE_UINT16(lpBuf); + lpBuf += 2; lpmiItem->Action[i].perc=*lpBuf; lpBuf++; @@ -400,11 +400,11 @@ static const byte *ParseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { lpBuf++; switch (lpmiItem->Command[curCmd].type) { case 1: // Call custom function - lpmiItem->Command[curCmd].nCf =*(uint16 *)(lpBuf); lpBuf+=2; - lpmiItem->Command[curCmd].arg1=*(int *)(lpBuf); lpBuf+=4; - lpmiItem->Command[curCmd].arg2=*(int *)(lpBuf); lpBuf+=4; - lpmiItem->Command[curCmd].arg3=*(int *)(lpBuf); lpBuf+=4; - lpmiItem->Command[curCmd].arg4=*(int *)(lpBuf); lpBuf+=4; + lpmiItem->Command[curCmd].nCf = READ_LE_UINT16(lpBuf); lpBuf += 2; + lpmiItem->Command[curCmd].arg1 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; + lpmiItem->Command[curCmd].arg2 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; + lpmiItem->Command[curCmd].arg3 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; + lpmiItem->Command[curCmd].arg4 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; break; case 2: // Variable assign @@ -444,7 +444,7 @@ static const byte *ParseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { } } - lpmiItem->dwRes=*(uint32 *)lpBuf; lpBuf+=4; + lpmiItem->dwRes = READ_LE_UINT32(lpBuf); lpBuf += 4; return lpBuf; } @@ -468,14 +468,14 @@ static const byte *ParseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { \****************************************************************************/ static const byte *ParseLocation(const byte *lpBuf, LPMPALLOCATION lpmlLocation) { - lpmlLocation->nObj=*(int *)lpBuf; - lpBuf+=4; - lpmlLocation->dwXlen=*(uint16 *)lpBuf; - lpBuf+=2; - lpmlLocation->dwYlen=*(uint16 *)lpBuf; - lpBuf+=2; - lpmlLocation->dwPicRes=*(uint32 *)lpBuf; - lpBuf+=4; + lpmlLocation->nObj = (int32)READ_LE_UINT32(lpBuf); + lpBuf += 4; + lpmlLocation->dwXlen = READ_LE_UINT16(lpBuf); + lpBuf += 2; + lpmlLocation->dwYlen = READ_LE_UINT16(lpBuf); + lpBuf += 2; + lpmlLocation->dwPicRes = READ_LE_UINT32(lpBuf); + lpBuf += 4; return lpBuf; } diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index 4f7a28b2b3..33dd6e1497 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -1122,7 +1122,7 @@ bool FPSFX::LoadFile(byte *lpBuf, uint32 dwCodec) { return false; lpBuf += 4; - dwSize = *(uint32*)lpBuf; + dwSize = READ_LE_UINT32(lpBuf); lpBuf += 4; b16bit = (WAVHeader->nBitsPerSample == 16); -- cgit v1.2.3 From 47ddb2ff339ed21d5cc518b8851961b097169652 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 14 May 2012 21:06:03 +1000 Subject: TONY: Replace stubs for TakeOwnership/ReleaseOwnership with actual implementation --- engines/tony/custom.cpp | 15 +++++---------- engines/tony/globals.cpp | 3 +-- engines/tony/globals.h | 2 +- 3 files changed, 7 insertions(+), 13 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 0392fc409d..d6e7fdd2ee 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -2134,15 +2134,12 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr */ DECLARE_CUSTOM_FUNCTION(TakeOwnership)(CORO_PARAM, uint32 num, uint32, uint32, uint32) { -// EnterCriticalSection(&cs[num]); -// WaitForSingleObject(mut[num],CORO_INFINITE); - warning("TODO: TakeOwnership"); + CoroScheduler.waitForSingleObject(coroParam, GLOBALS.mut[num], CORO_INFINITE); } DECLARE_CUSTOM_FUNCTION(ReleaseOwnership)(CORO_PARAM, uint32 num, uint32, uint32, uint32) { -// LeaveCriticalSection(&cs[num]); -// g_system->unlockMutex(mut[num]); - warning("TODO: ReleaseOwnership"); + CoroScheduler.pulseEvent(GLOBALS.mut[num]); + warning("TODO: Validate that the use of events in TakeOwnership/ReleaseOwnership match original"); } @@ -2646,11 +2643,9 @@ void SetupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation GLOBALS.bAlwaysDisplay = false; int i; -/* for (i = 0;i < 10; i++) - cs[i] = g_system->createMutex(); for (i = 0;i < 10; i++) - mut[i] = CreateMutex(NULL, false, NULL); -*/ + GLOBALS.mut[i] = CoroScheduler.createEvent(false, false); + for (i = 0; i < 200; i++) GLOBALS.tappeti[i] = 0; diff --git a/engines/tony/globals.cpp b/engines/tony/globals.cpp index 867d48e0fa..7c801a787d 100644 --- a/engines/tony/globals.cpp +++ b/engines/tony/globals.cpp @@ -83,9 +83,8 @@ Globals::Globals() { curSonoriz = 0; bFadeOutStop = false; -// OSystem::MutexRef cs[10]; // OSystem::MutexRef vdb; - Common::fill(&mut[0], &mut[10], (HANDLE)NULL); + Common::fill(&mut[0], &mut[10], 0); bSkipIdle = false; hSkipIdle = 0; lastMusic = 0; diff --git a/engines/tony/globals.h b/engines/tony/globals.h index 72faa6a6c5..d82e0fcaf2 100644 --- a/engines/tony/globals.h +++ b/engines/tony/globals.h @@ -241,7 +241,7 @@ public: RMPoint StartLocPos[256]; OSystem::MutexRef cs[10]; OSystem::MutexRef vdb; - HANDLE mut[10]; + uint32 mut[10]; bool bSkipIdle; uint32 hSkipIdle; -- cgit v1.2.3 From d5b80688e773427e0a96fe9270b0177efd953b14 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 14 May 2012 22:39:24 +1000 Subject: TONY: Implemented list-saves and delete save functionality --- engines/tony/detection.cpp | 46 +++++++++++++++++++++++++++++++++++++++++++++- engines/tony/game.h | 5 +++-- engines/tony/tony.h | 2 +- 3 files changed, 49 insertions(+), 4 deletions(-) (limited to 'engines') diff --git a/engines/tony/detection.cpp b/engines/tony/detection.cpp index 6be0ca302c..7a943223a4 100644 --- a/engines/tony/detection.cpp +++ b/engines/tony/detection.cpp @@ -27,6 +27,7 @@ #include "common/system.h" #include "tony/tony.h" +#include "tony/game.h" namespace Tony { @@ -71,10 +72,16 @@ public: virtual bool hasFeature(MetaEngineFeature f) const; virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const; + virtual SaveStateList listSaves(const char *target) const; + virtual int getMaximumSaveSlot() const; + virtual void removeSaveState(const char *target, int slot) const; }; bool TonyMetaEngine::hasFeature(MetaEngineFeature f) const { - return false; + return + (f == kSupportsListSaves) || +// (f == kSupportsLoadingDuringStartup) || + (f == kSupportsDeleteSave); } bool Tony::TonyEngine::hasFeature(EngineFeature f) const { @@ -90,6 +97,43 @@ bool TonyMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGame return gd != 0; } +SaveStateList TonyMetaEngine::listSaves(const char *target) const { + Common::SaveFileManager *saveFileMan = g_system->getSavefileManager(); + Common::StringArray filenames; + Common::String saveDesc; + Common::String pattern = "tony.0??"; + + filenames = saveFileMan->listSavefiles(pattern); + sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..) + + SaveStateList saveList; + for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) { + // Obtain the last 3 digits of the filename, since they correspond to the save slot + int slotNum = atoi(file->c_str() + file->size() - 3); + + if (slotNum >= 0 && slotNum <= 999) { + byte thumbnailData[160 * 120 * 2]; + Tony::RMString saveName; + byte difficulty; + + if (Tony::RMOptionScreen::LoadThumbnailFromSaveState(slotNum, thumbnailData, saveName, difficulty)) { + // Add the save name to the savegame list + saveList.push_back(SaveStateDescriptor(slotNum, (const char *)saveName)); + } + } + } + + return saveList; +} + +int TonyMetaEngine::getMaximumSaveSlot() const { return 99; } + +void TonyMetaEngine::removeSaveState(const char *target, int slot) const { + Common::String filename = Tony::TonyEngine::GetSaveStateFileName(slot); + + g_system->getSavefileManager()->removeSavefile(filename); +} + #if PLUGIN_ENABLED_DYNAMIC(TONY) REGISTER_PLUGIN_DYNAMIC(TONY, PLUGIN_TYPE_ENGINE, TonyMetaEngine); #else diff --git a/engines/tony/game.h b/engines/tony/game.h index 83972e0f17..22df40c6d8 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -263,6 +263,9 @@ public: // Polling per l'option screen void DoFrame(CORO_PARAM, RMInput *m_input); + // Retrieves a savegame's thumbnail, description, and difficulty level + static bool LoadThumbnailFromSaveState(int numState, byte *lpDestBuf, RMString &name, byte &diff); + protected: // Inizializza tutto per il nuovo stato @@ -274,8 +277,6 @@ protected: void RefreshAll(CORO_PARAM); void RefreshThumbnails(void); - // Carica lo screenshot per il salvataggio - bool LoadThumbnailFromSaveState(int numState, byte *lpDestBuf, RMString &name, byte &diff); }; } // End of namespace Tony diff --git a/engines/tony/tony.h b/engines/tony/tony.h index c1ad6756c2..c106a0856b 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -198,7 +198,7 @@ public: void AutoSave(CORO_PARAM); void SaveState(int n, const char *name); void LoadState(CORO_PARAM, int n); - Common::String GetSaveStateFileName(int n); + static Common::String GetSaveStateFileName(int n); // Prende il thumbnail void GrabThumbnail(void); -- cgit v1.2.3 From 88762667b52e4b904c56ecc94bf304c1a91e9feb Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 14 May 2012 21:29:27 +0200 Subject: TONY: Fix some formatting --- engines/tony/adv.h | 24 +- engines/tony/custom.cpp | 1008 +++++++++++++++++++++----------------------- engines/tony/custom.h | 30 +- engines/tony/detection.cpp | 20 +- engines/tony/font.cpp | 472 ++++++++++----------- engines/tony/font.h | 407 +++++++++--------- engines/tony/game.cpp | 272 ++++++------ engines/tony/game.h | 89 ++-- engines/tony/gfxcore.cpp | 528 +++++++++++------------ engines/tony/gfxcore.h | 277 +++++++----- engines/tony/gfxengine.cpp | 357 ++++++++-------- engines/tony/gfxengine.h | 26 +- engines/tony/globals.h | 46 +- engines/tony/input.cpp | 10 +- engines/tony/input.h | 30 +- engines/tony/inventory.cpp | 199 ++++----- engines/tony/tonychar.cpp | 31 +- engines/tony/window.cpp | 44 +- 18 files changed, 2000 insertions(+), 1870 deletions(-) (limited to 'engines') diff --git a/engines/tony/adv.h b/engines/tony/adv.h index 314672fe39..90a9c245b5 100644 --- a/engines/tony/adv.h +++ b/engines/tony/adv.h @@ -37,24 +37,24 @@ namespace Tony { // X & Y dimensions of the adventure -#define RM_SX 640 -#define RM_SY 480 +#define RM_SX 640 +#define RM_SY 480 // X&Y dimensions of bigbuf -#define RM_BBX (RM_SX) -#define RM_BBY (RM_SY) +#define RM_BBX (RM_SX) +#define RM_BBY (RM_SY) -// Skipping X&Y -#define RM_SKIPY ((RM_BBY - RM_SY) / 2) -#define RM_SKIPX 0 +// Skipping X&Y +#define RM_SKIPY ((RM_BBY - RM_SY) / 2) +#define RM_SKIPX 0 // Name lengths // FIXME: Some of these can likely be removed when refactoring is completed -#define MAX_DRIVE 10 -#define MAX_DIR 255 -#define MAX_PATH 255 -#define MAX_FNAME 100 -#define MAX_EXT 10 +#define MAX_DRIVE 10 +#define MAX_DIR 255 +#define MAX_PATH 255 +#define MAX_FNAME 100 +#define MAX_EXT 10 // Tony's actions enum RMTonyAction { diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index d6e7fdd2ee..d38f840011 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -44,120 +44,60 @@ namespace Tony { const char *tappetiFile[] = { "None", - "1.ADP", // Grilli.WAV - "2.ADP", // Grilli-Ovattati.WAV - "3.ADP", // Grilli-Vento.WAV - "3.ADP", // Grilli-Vento1.WAV - "5.ADP", // Vento1.WAV - "4.ADP", // Mare1.WAV - "6.ADP" // Mare1.WAV met volume + "1.ADP", // Grilli.WAV + "2.ADP", // Grilli-Ovattati.WAV + "3.ADP", // Grilli-Vento.WAV + "3.ADP", // Grilli-Vento1.WAV + "5.ADP", // Vento1.WAV + "4.ADP", // Mare1.WAV + "6.ADP" // Mare1.WAV met volume }; struct MusicFileEntry { const char *name; int sync; }; -const MusicFileEntry musicFiles[] = { -/* - { "PREGAME1.ADP", 0 }, { "SONO1.ADP", 0 }, - { "SONO2.ADP", 0 }, { "SONO3.ADP", 0 }, - { "CADUTA.ADP",0 }, { "RISVEGLIO.ADP", 0 }, - { "BACKGROUND.ADP", 0 }, { "PREGAME3.ADP", 0 }, - { "BARBUTA1.ADP", 2450 }, { "BARBUTA2.ADP", 0 }, -*/ - { "00.ADP", 0 }, { "01.ADP", 0 }, - { "02.ADP", 0 }, { "03.ADP", 0 }, - { "04.ADP",0 }, { "05.ADP", 0 }, - { "06.ADP", 0 }, { "07.ADP", 0 }, - { "08.ADP", 2450 }, { "09.ADP", 0 }, - -/* - { "BARBUTA3.ADP", 0 }, { "15-RUFUS.ADP", 0 }, - { "20-MAMMA.ADP", 0 }, { "32-MAMMARADIO.ADP", 0 }, - { "24-TUNNELOV-MIDI.ADP", 0 }, { "34-RAZZO.ADP", 0 }, - { "27-ZUCC1.ADP", 0 }, { "BEAST.ADP", 0 }, - { "22-MORTIMER.ADP", 0 }, { "25-PUB-OVATTATO.ADP", 0 }, -*/ - { "10.ADP", 0 }, { "11.ADP", 0 }, - { "12.ADP", 0 }, { "13.ADP", 0 }, - { "14.ADP", 0 }, { "15.ADP", 0 }, - { "16.ADP", 0 }, { "17.ADP", 0 }, - { "18.ADP", 0 }, { "19.ADP", 0 }, -/* - { "25-PUB.ADP", 0 }, { "ALBERGO.ADP", 0 }, - { "37.ADP", 0 }, { "26-PIRAT.ADP", 0 }, - { "LORENZBACK.ADP", 0 }, { "LORENZ3.ADP", 0 }, - { "CASTLE.ADP", 0 }, { "53-BACKR.ADP", 0 }, - { "16-SMIL1.ADP", 1670 }, { "16-SMIL2.ADP", 0 }, -*/ - { "20.ADP", 0 }, { "21.ADP", 0 }, - { "22.ADP", 0 }, { "23.ADP", 0 }, - { "24.ADP", 0 }, { "25.ADP", 0 }, - { "26.ADP", 0 }, { "27.ADP", 0 }, - { "28.ADP", 1670 }, { "29.ADP", 0 }, -/* - { "16-SMILE.ADP", 0 }, { "16-DIALOG2.ADP", 0 }, - { "07-SHAKE1.ADP", 2900 }, { "07-SHAKE2.ADP", 0 }, - { "07-SHAKE3.ADP", 0 }, { "46-BEEE.ADP", 0 }, - { "434748.ADP", 0 }, { "TORRE.ADP", 0 }, - { "50-DRAGO.ADP", 0 }, { "56-OPERA.ADP", 0 }, -*/ - { "30.ADP", 0 }, { "31.ADP", 0 }, - { "32.ADP", 2900 }, { "33.ADP", 0 }, - { "34.ADP", 0 }, { "35.ADP", 0 }, - { "36.ADP", 0 }, { "37.ADP", 0 }, - { "38.ADP", 0 }, { "39.ADP", 0 }, -/* - { "FLAUTARP.ADP", 0 }, { "01-2001.ADP", 1920 }, - { "02-INTROPANORAMICA.ADP", 1560 }, { "03-PANORAMICA.ADP", 1920 }, - { "04-INTERNI.ADP", 1920 }, { "05-CADEPIUMA.ADP", 1920 }, - { "06-SCENDESCALE.ADP", 1920 }, { "07-THRILL.ADP", 1920 }, - { "08-CADUTAZUCCA.ADP", 1920 }, { "09-PIUMAALEGGIA.ADP", 1920 }, -*/ - { "40.ADP", 0 }, { "41.ADP", 1920 }, - { "42.ADP", 1560 }, { "43.ADP", 1920 }, - { "44.ADP", 1920 }, { "45.ADP", 1920 }, - { "46.ADP", 1920 }, { "47.ADP", 1920 }, - { "48.ADP", 1920 }, { "49.ADP", 1920 }, - -/* - { "10-JACKZUCCONA.ADP", 1920 }, { "11-JACKIMPRECAALLAGRANDELUNA.ADP", 1920 }, - { "12-GRANDELUNALOGO.ADP", 1920 }, { "60-BACKGROUND.ADP", 0 }, - { "TONYSTAR.ADP", 0 }, { "FUNNY.ADP", 0 }, - { "60-INIZIODIALOGO.ADP", 0 }, { "60-DIALOGO.ADP", 0 }, - { "60-JACKFELICE.ADP", 0 }, { "24-TONYVIOLENTATO.ADP", 0 } -*/ - - { "50.ADP", 1920 }, { "51.ADP", 1920 }, - { "52.ADP", 1920 }, { "53.ADP", 0 }, - { "54.ADP", 0 }, { "55.ADP", 0 }, - { "56.ADP", 0 }, { "57.ADP", 0 }, - { "58.ADP", 0 }, { "59.ADP", 0 } +const MusicFileEntry musicFiles[] = { + {"00.ADP", 0}, {"01.ADP", 0}, + {"02.ADP", 0}, {"03.ADP", 0}, + {"04.ADP", 0}, {"05.ADP", 0}, + {"06.ADP", 0}, {"07.ADP", 0}, + {"08.ADP", 2450}, {"09.ADP", 0}, + {"10.ADP", 0}, {"11.ADP", 0}, + {"12.ADP", 0}, {"13.ADP", 0}, + {"14.ADP", 0}, {"15.ADP", 0}, + {"16.ADP", 0}, {"17.ADP", 0}, + {"18.ADP", 0}, {"19.ADP", 0}, + {"20.ADP", 0}, {"21.ADP", 0}, + {"22.ADP", 0}, {"23.ADP", 0}, + {"24.ADP", 0}, {"25.ADP", 0}, + {"26.ADP", 0}, {"27.ADP", 0}, + {"28.ADP", 1670}, {"29.ADP", 0}, + {"30.ADP", 0}, {"31.ADP", 0}, + {"32.ADP", 2900}, {"33.ADP", 0}, + {"34.ADP", 0}, {"35.ADP", 0}, + {"36.ADP", 0}, {"37.ADP", 0}, + {"38.ADP", 0}, {"39.ADP", 0}, + {"40.ADP", 0}, {"41.ADP", 1920}, + {"42.ADP", 1560}, {"43.ADP", 1920}, + {"44.ADP", 1920}, {"45.ADP", 1920}, + {"46.ADP", 1920}, {"47.ADP", 1920}, + {"48.ADP", 1920}, {"49.ADP", 1920}, + {"50.ADP", 1920}, {"51.ADP", 1920}, + {"52.ADP", 1920}, {"53.ADP", 0}, + {"54.ADP", 0}, {"55.ADP", 0}, + {"56.ADP", 0}, {"57.ADP", 0}, + {"58.ADP", 0}, {"59.ADP", 0} }; -const char *staccFileNames[] = { -/* - "05-MUCCA.ADP", "06-HALOW.ADP", - "LETTERAINIZIO.ADP", "LETTERAPAURA.ADP", - "LETTERAFINE.ADP", "PREGAME2.ADP", - "07-TIMOT.ADP", "15-SHOTRUFUS.ADP", - "15-SHOTTONY.ADP", "27-ZUCC2.ADP", -*/ - "S00.ADP", "S01.ADP", - "S02.ADP", "S03.ADP", +const char *staccFileNames[] = { + "S00.ADP", "S01.ADP", + "S02.ADP", "S03.ADP", "S04.ADP", "S05.ADP", "S06.ADP", "S07.ADP", "S08.ADP", "S09.ADP", - -/* - "53-DLOGO.ADP", "16-DIALOG1.ADP", - "TORRE1.ADP", "GARG1.ADP", - "LORENZ1.ADP", "24-FIGHT.ADP", - "08-MACBETH-PREPARA.ADP", "08-MACBETH-RECITA.ADP", - "GATTO1.ADP" -*/ "S10.ADP", "S11.ADP", "S12.ADP", "S13.ADP", "S14.ADP", "S15.ADP", @@ -169,7 +109,7 @@ const char *staccFileNames[] = { void ReapplyChangedHotspot(void) { int i; for (i = 0; i < GLOBALS.curChangedHotspot; i++) - GLOBALS.Loc->GetItemFromCode(GLOBALS.ChangedHotspot[i].dwCode)->ChangeHotspot(RMPoint(GLOBALS.ChangedHotspot[i].nX, GLOBALS.ChangedHotspot[i].nY)); + GLOBALS.Loc->GetItemFromCode(GLOBALS.ChangedHotspot[i].dwCode)->ChangeHotspot(RMPoint(GLOBALS.ChangedHotspot[i].nX, GLOBALS.ChangedHotspot[i].nY)); } void SaveChangedHotspot(Common::OutSaveFile *f) { @@ -182,7 +122,7 @@ void SaveChangedHotspot(Common::OutSaveFile *f) { void LoadChangedHotspot(Common::InSaveFile *f) { GLOBALS.curChangedHotspot = f->readByte(); - + if (GLOBALS.curChangedHotspot > 0) { for (int i = 0; i < GLOBALS.curChangedHotspot; ++i) GLOBALS.ChangedHotspot[i].Load(f); @@ -191,13 +131,13 @@ void LoadChangedHotspot(Common::InSaveFile *f) { /* - Classi richieste per le funzioni custom! + Classi richieste per le funzioni custom! - Tony (per muoverlo) -> si puo' fare tramite MPAL l'animazione? Penso proprio di s + Tony (per muoverlo) -> si puo' fare tramite MPAL l'animazione? Penso proprio di s - SendMessage -> Direi che basta theEngine.SendMessage() - ChangeLocation -> theEngine.ChangeLocation() - AddInventory -> theEngine.AddInventory() + SendMessage -> Direi che basta theEngine.SendMessage() + ChangeLocation -> theEngine.ChangeLocation() + AddInventory -> theEngine.AddInventory() */ void MCharResetCodes(void) { @@ -246,12 +186,12 @@ DECLARE_CUSTOM_FUNCTION(RightToMe)(CORO_PARAM, uint32, uint32, uint32, uint32) { DECLARE_CUSTOM_FUNCTION(TonySetPalesati)(CORO_PARAM, uint32 bStatus, uint32, uint32, uint32) { - GLOBALS.SetPalesati(bStatus); + GLOBALS.SetPalesati(bStatus); } DECLARE_CUSTOM_FUNCTION(MySleep)(CORO_PARAM, uint32 dwTime, uint32, uint32, uint32) { CORO_BEGIN_CONTEXT; - int i; + int i; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -269,25 +209,25 @@ DECLARE_CUSTOM_FUNCTION(SetAlwaysDisplay)(CORO_PARAM, uint32 val, uint32, uint32 DECLARE_CUSTOM_FUNCTION(SetPointer)(CORO_PARAM, uint32 dwPointer, uint32, uint32, uint32) { switch (dwPointer) { - case 1: - GLOBALS.Pointer->SetSpecialPointer(GLOBALS.Pointer->PTR_FRECCIASU); - break; - case 2: - GLOBALS.Pointer->SetSpecialPointer(GLOBALS.Pointer->PTR_FRECCIAGIU); - break; - case 3: - GLOBALS.Pointer->SetSpecialPointer(GLOBALS.Pointer->PTR_FRECCIASINISTRA); - break; - case 4: - GLOBALS.Pointer->SetSpecialPointer(GLOBALS.Pointer->PTR_FRECCIADESTRA); - break; - case 5: - GLOBALS.Pointer->SetSpecialPointer(GLOBALS.Pointer->PTR_FRECCIAMAPPA); - break; + case 1: + GLOBALS.Pointer->SetSpecialPointer(GLOBALS.Pointer->PTR_FRECCIASU); + break; + case 2: + GLOBALS.Pointer->SetSpecialPointer(GLOBALS.Pointer->PTR_FRECCIAGIU); + break; + case 3: + GLOBALS.Pointer->SetSpecialPointer(GLOBALS.Pointer->PTR_FRECCIASINISTRA); + break; + case 4: + GLOBALS.Pointer->SetSpecialPointer(GLOBALS.Pointer->PTR_FRECCIADESTRA); + break; + case 5: + GLOBALS.Pointer->SetSpecialPointer(GLOBALS.Pointer->PTR_FRECCIAMAPPA); + break; - default: - GLOBALS.Pointer->SetSpecialPointer(GLOBALS.Pointer->PTR_NONE); - break; + default: + GLOBALS.Pointer->SetSpecialPointer(GLOBALS.Pointer->PTR_NONE); + break; } } @@ -296,7 +236,7 @@ VoiceHeader *SearchVoiceHeader(uint32 codehi, uint32 codelo) { int code; code = (codehi << 16) | codelo; - + if (_vm->_voices.size() == 0) return NULL; @@ -310,12 +250,12 @@ VoiceHeader *SearchVoiceHeader(uint32 codehi, uint32 codelo) { DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX, uint32 nY, uint32) { CORO_BEGIN_CONTEXT; - RMMessage msg; - int i; - int curOffset; - VoiceHeader *curVoc; - FPSFX *voice; - RMTextDialog text; + RMMessage msg; + int i; + int curOffset; + VoiceHeader *curVoc; + FPSFX *voice; + RMTextDialog text; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -337,11 +277,11 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX // PRIMA VOLTA PREALLOCA g_system->lockMutex(GLOBALS.vdb); - //fseek(_vm->m_vdbFP, _ctx->curOffset, SEEK_SET); + // fseek(_vm->m_vdbFP, _ctx->curOffset, SEEK_SET); _vm->_vdbFP.seek(_ctx->curOffset); _vm->_theSound.CreateSfx(&_ctx->voice); _ctx->voice->LoadVoiceFromVDB(_vm->_vdbFP); -// _ctx->curOffset = ftell(_vm->m_vdbFP); + // _ctx->curOffset = ftell(_vm->m_vdbFP); _ctx->curOffset = _vm->_vdbFP.pos(); _ctx->voice->SetLoop(false); @@ -367,12 +307,12 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX for (_ctx->i = 0; _ctx->i < _ctx->msg.NumPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { _ctx->text.SetInput(GLOBALS.Input); - + // Allineamento _ctx->text.SetAlignType(RMText::HCENTER, RMText::VBOTTOM); - + // Colore - _ctx->text.SetColor(0,255,0); + _ctx->text.SetColor(0, 255, 0); // Scrive il testo _ctx->text.WriteText(_ctx->msg[_ctx->i], 0); @@ -384,7 +324,10 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX _ctx->text.SetPosition(RMPoint(nX, nY) - GLOBALS.Loc->ScrollPosition()); // Setta l'always display - if (GLOBALS.bAlwaysDisplay) { _ctx->text.SetAlwaysDisplay(); _ctx->text.ForceTime(); } + if (GLOBALS.bAlwaysDisplay) { + _ctx->text.SetAlwaysDisplay(); + _ctx->text.ForceTime(); + } // Registra il testo GLOBALS.LinkGraphicTask(&_ctx->text); @@ -395,11 +338,11 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX _ctx->text.SetCustomSkipHandle2(_ctx->voice->hEndOfBuffer); } else { g_system->lockMutex(GLOBALS.vdb); - // fseek(_vm->m_vdbFP, _ctx->curOffset, SEEK_SET); + // fseek(_vm->m_vdbFP, _ctx->curOffset, SEEK_SET); _vm->_vdbFP.seek(_ctx->curOffset); _vm->_theSound.CreateSfx(&_ctx->voice); _ctx->voice->LoadVoiceFromVDB(_vm->_vdbFP); - // _ctx->curOffset = ftell(_vm->m_vdbFP); + // _ctx->curOffset = ftell(_vm->m_vdbFP); _ctx->curOffset = _vm->_vdbFP.pos(); _ctx->voice->SetLoop(false); _ctx->voice->Play(); @@ -408,14 +351,14 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX } } - // Aspetta la fine della visualizzazione + // Aspetta la fine della visualizzazione _ctx->text.SetCustomSkipHandle(GLOBALS.hSkipIdle); CORO_INVOKE_0(_ctx->text.WaitForEndDisplay); if (_ctx->curVoc) { _ctx->voice->Stop(); _ctx->voice->Release(); - _ctx->voice=NULL; + _ctx->voice = NULL; } } @@ -435,7 +378,7 @@ DECLARE_CUSTOM_FUNCTION(ChangeBoxStatus)(CORO_PARAM, uint32 nLoc, uint32 nBox, u DECLARE_CUSTOM_FUNCTION(CustLoadLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint32 tY, uint32 bUseStartPos) { CORO_BEGIN_CONTEXT; - uint32 h; + uint32 h; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -461,20 +404,20 @@ DECLARE_CUSTOM_FUNCTION(CustLoadLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, ui DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgStart)(CORO_PARAM, uint32 nMsg, uint32 nFont, uint32, uint32) { CORO_BEGIN_CONTEXT; - RMMessage *msg; - RMGfxClearTask clear; - int i; - RMTextDialog text; + RMMessage *msg; + RMGfxClearTask clear; + int i; + RMTextDialog text; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); _ctx->msg = new RMMessage(nMsg); - + GLOBALS.SFM_nLoc = GLOBALS.Loc->TEMPGetNumLoc(); GLOBALS.SFM_pt = GLOBALS.Tony->Position(); - - if (GLOBALS.bSkipIdle) + + if (GLOBALS.bSkipIdle) return; CORO_INVOKE_2(GLOBALS.UnloadLocation, false, NULL); @@ -485,13 +428,13 @@ DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgStart)(CORO_PARAM, uint32 nMsg, uint32 _ctx->text.SetInput(GLOBALS.Input); // Allineamento - _ctx->text.SetAlignType(RMText::HCENTER,RMText::VCENTER); - - // Forza il testo a scomparire a tempo + _ctx->text.SetAlignType(RMText::HCENTER, RMText::VCENTER); + + // Forza il testo a scomparire a tempo _ctx->text.ForceTime(); // Colore - _ctx->text.SetColor(255,255,255); + _ctx->text.SetColor(255, 255, 255); // Scrive il testo if (nFont == 0) @@ -509,7 +452,7 @@ DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgStart)(CORO_PARAM, uint32 nMsg, uint32 GLOBALS.LinkGraphicTask(&_ctx->clear); GLOBALS.LinkGraphicTask(&_ctx->text); - // Aspetta la fine della visualizzazione + // Aspetta la fine della visualizzazione _ctx->text.SetCustomSkipHandle(GLOBALS.hSkipIdle); CORO_INVOKE_0(_ctx->text.WaitForEndDisplay); } @@ -521,14 +464,14 @@ DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgStart)(CORO_PARAM, uint32 nMsg, uint32 DECLARE_CUSTOM_FUNCTION(ClearScreen)(CORO_PARAM, uint32, uint32, uint32, uint32) { CORO_BEGIN_CONTEXT; - char buf[256]; - RMGfxClearTask clear; + char buf[256]; + RMGfxClearTask clear; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); GLOBALS.LinkGraphicTask(&_ctx->clear); - + CORO_INVOKE_0(GLOBALS.WaitFrame); CORO_END_CODE; @@ -536,7 +479,7 @@ DECLARE_CUSTOM_FUNCTION(ClearScreen)(CORO_PARAM, uint32, uint32, uint32, uint32) DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgEnd)(CORO_PARAM, uint32 bNotEnableTony, uint32, uint32, uint32) { GLOBALS.Freeze(); - GLOBALS.LoadLocation(GLOBALS.SFM_nLoc,RMPoint(GLOBALS.SFM_pt.x,GLOBALS.SFM_pt.y),RMPoint(-1,-1)); + GLOBALS.LoadLocation(GLOBALS.SFM_nLoc, RMPoint(GLOBALS.SFM_pt.x, GLOBALS.SFM_pt.y), RMPoint(-1, -1)); if (!bNotEnableTony) GLOBALS.Tony->Show(); GLOBALS.Unfreeze(); @@ -569,8 +512,8 @@ DECLARE_CUSTOM_FUNCTION(CloseLocation)(CORO_PARAM, uint32, uint32, uint32, uint3 CORO_BEGIN_CODE(_ctx); if (!GLOBALS.bNoOcchioDiBue) { - GLOBALS.InitWipe(1); - CORO_INVOKE_0(GLOBALS.WaitWipeEnd); + GLOBALS.InitWipe(1); + CORO_INVOKE_0(GLOBALS.WaitWipeEnd); } _vm->StopMusic(4); @@ -585,7 +528,7 @@ DECLARE_CUSTOM_FUNCTION(CloseLocation)(CORO_PARAM, uint32, uint32, uint32, uint3 DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint32 tY, uint32 bUseStartPos) { CORO_BEGIN_CONTEXT; - uint32 h; + uint32 h; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -598,7 +541,7 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint if (GLOBALS.lastTappeto != GLOBALS.tappeti[nLoc]) { _vm->StopMusic(4); } - + // On Exit e lascia freezzato CORO_INVOKE_2(GLOBALS.UnloadLocation, true, NULL); @@ -615,16 +558,16 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint } if (!GLOBALS.bNoOcchioDiBue) { - GLOBALS.InitWipe(2); + GLOBALS.InitWipe(2); } - + GLOBALS.Unfreeze(); _ctx->h = mpalQueryDoAction(0, nLoc, 0); if (!GLOBALS.bNoOcchioDiBue) { - CORO_INVOKE_0(GLOBALS.WaitWipeEnd); + CORO_INVOKE_0(GLOBALS.WaitWipeEnd); GLOBALS.CloseWipe(); } @@ -638,7 +581,7 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint } DECLARE_CUSTOM_FUNCTION(SetLocStartPosition)(CORO_PARAM, uint32 nLoc, uint32 lX, uint32 lY, uint32) { - GLOBALS.StartLocPos[nLoc].Set(lX,lY); + GLOBALS.StartLocPos[nLoc].Set(lX, lY); } DECLARE_CUSTOM_FUNCTION(SaveTonyPosition)(CORO_PARAM, uint32, uint32, uint32, uint32) { @@ -653,7 +596,7 @@ DECLARE_CUSTOM_FUNCTION(RestoreTonyPosition)(CORO_PARAM, uint32, uint32, uint32, CORO_BEGIN_CODE(_ctx); CORO_INVOKE_4(ChangeLocation, GLOBALS.saveTonyLoc, GLOBALS.saveTonyPos.x, GLOBALS.saveTonyPos.y, 0); - + MCharResetCodes(); CORO_END_CODE; @@ -675,7 +618,7 @@ DECLARE_CUSTOM_FUNCTION(StopTony)(CORO_PARAM, uint32, uint32, uint32, uint32) { DECLARE_CUSTOM_FUNCTION(CustEnableGUI)(CORO_PARAM, uint32, uint32, uint32, uint32) { - GLOBALS.EnableGUI(); + GLOBALS.EnableGUI(); } DECLARE_CUSTOM_FUNCTION(CustDisableGUI)(CORO_PARAM, uint32, uint32, uint32, uint32) { @@ -693,7 +636,7 @@ void TonyGenericTake1(CORO_PARAM, uint32 nDirection) { GLOBALS.Freeze(); GLOBALS.Tony->Take(nDirection, 0); GLOBALS.Unfreeze(); - + if (!GLOBALS.bSkipIdle) CORO_INVOKE_0(GLOBALS.Tony->WaitForEndPattern); @@ -714,7 +657,7 @@ void TonyGenericTake2(CORO_PARAM, uint32 nDirection) { CORO_INVOKE_0(GLOBALS.Tony->WaitForEndPattern); GLOBALS.Freeze(); - GLOBALS.Tony->Take(nDirection,2); + GLOBALS.Tony->Take(nDirection, 2); GLOBALS.Unfreeze(); CORO_END_CODE; @@ -729,7 +672,7 @@ void TonyGenericPut1(CORO_PARAM, uint32 nDirection) { GLOBALS.Freeze(); GLOBALS.Tony->Put(nDirection, 0); GLOBALS.Unfreeze(); - + if (!GLOBALS.bSkipIdle) CORO_INVOKE_0(GLOBALS.Tony->WaitForEndPattern); @@ -743,14 +686,14 @@ void TonyGenericPut2(CORO_PARAM, uint32 nDirection) { CORO_BEGIN_CODE(_ctx); GLOBALS.Freeze(); - GLOBALS.Tony->Put(nDirection,1); + GLOBALS.Tony->Put(nDirection, 1); GLOBALS.Unfreeze(); if (!GLOBALS.bSkipIdle) CORO_INVOKE_0(GLOBALS.Tony->WaitForEndPattern); GLOBALS.Freeze(); - GLOBALS.Tony->Put(nDirection,2); + GLOBALS.Tony->Put(nDirection, 2); GLOBALS.Unfreeze(); CORO_END_CODE; @@ -831,7 +774,7 @@ DECLARE_CUSTOM_FUNCTION(TonySiRialza)(CORO_PARAM, uint32 dwParte, uint32, uint32 GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_SIRIALZALEFT); else GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_SIRIALZARIGHT); - + if (!GLOBALS.bSkipIdle) CORO_INVOKE_0(GLOBALS.Tony->WaitForEndPattern); @@ -839,7 +782,7 @@ DECLARE_CUSTOM_FUNCTION(TonySiRialza)(CORO_PARAM, uint32 dwParte, uint32, uint32 } DECLARE_CUSTOM_FUNCTION(TonyPastorella)(CORO_PARAM, uint32 bIsPast, uint32, uint32, uint32) { - GLOBALS.Tony->SetPastorella(bIsPast); + GLOBALS.Tony->SetPastorella(bIsPast); } DECLARE_CUSTOM_FUNCTION(TonyFischietto)(CORO_PARAM, uint32, uint32, uint32, uint32) { @@ -1189,7 +1132,7 @@ DECLARE_CUSTOM_FUNCTION(TonySniffaRight)(CORO_PARAM, uint32, uint32, uint32, uin } DECLARE_CUSTOM_FUNCTION(TonyNaah)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { - TonySetNumTexts(dwText); + TonySetNumTexts(dwText); GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NAAH; } @@ -1236,15 +1179,15 @@ DECLARE_CUSTOM_FUNCTION(DisableTony)(CORO_PARAM, uint32 bShowOmbra, uint32, uint DECLARE_CUSTOM_FUNCTION(WaitForPatternEnd)(CORO_PARAM, uint32 nItem, uint32, uint32, uint32) { CORO_BEGIN_CONTEXT; - RMItem *item; + RMItem *item; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); _ctx->item = GLOBALS.Loc->GetItemFromCode(nItem); - + if (!GLOBALS.bSkipIdle && _ctx->item != NULL) - CORO_INVOKE_1(_ctx->item->WaitForEndPattern, GLOBALS.hSkipIdle); + CORO_INVOKE_1(_ctx->item->WaitForEndPattern, GLOBALS.hSkipIdle); CORO_END_CODE; } @@ -1261,7 +1204,7 @@ DECLARE_CUSTOM_FUNCTION(MoveTonyAndWait)(CORO_PARAM, uint32 nX, uint32 nY, uint3 CORO_BEGIN_CODE(_ctx); CORO_INVOKE_1(GLOBALS.Tony->Move, RMPoint(nX, nY)); - + if (!GLOBALS.bSkipIdle) CORO_INVOKE_0(GLOBALS.Tony->WaitForEndMovement); @@ -1274,8 +1217,8 @@ DECLARE_CUSTOM_FUNCTION(MoveTony)(CORO_PARAM, uint32 nX, uint32 nY, uint32, uint DECLARE_CUSTOM_FUNCTION(ScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, uint32 sX, uint32 sY) { CORO_BEGIN_CONTEXT; - int lx, ly; - RMPoint pt; + int lx, ly; + RMPoint pt; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -1285,21 +1228,25 @@ DECLARE_CUSTOM_FUNCTION(ScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, uint32 _ctx->ly = (int32)nY; _ctx->pt = GLOBALS.Loc->ScrollPosition(); - + while ((_ctx->lx != 0 || _ctx->ly != 0) && !GLOBALS.bSkipIdle) { if (_ctx->lx > 0) { - _ctx->lx -= (int32)sX; if (_ctx->lx < 0) _ctx->lx = 0; + _ctx->lx -= (int32)sX; + if (_ctx->lx < 0) _ctx->lx = 0; _ctx->pt.Offset((int32)sX, 0); } else if (_ctx->lx < 0) { - _ctx->lx += (int32)sX; if (_ctx->lx > 0) _ctx->lx = 0; + _ctx->lx += (int32)sX; + if (_ctx->lx > 0) _ctx->lx = 0; _ctx->pt.Offset(-(int32)sX, 0); } if (_ctx->ly > 0) { - _ctx->ly -= sY; if (_ctx->ly < 0) _ctx->ly = 0; + _ctx->ly -= sY; + if (_ctx->ly < 0) _ctx->ly = 0; _ctx->pt.Offset(0, sY); } else if (_ctx->ly < 0) { - _ctx->ly += sY; if (_ctx->ly > 0) _ctx->ly = 0; + _ctx->ly += sY; + if (_ctx->ly > 0) _ctx->ly = 0; _ctx->pt.Offset(0, -(int32)sY); } @@ -1316,11 +1263,11 @@ DECLARE_CUSTOM_FUNCTION(ScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, uint32 DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, uint32 sX, uint32 sY) { CORO_BEGIN_CONTEXT; - int lx, ly; - RMPoint pt, startpt; - uint32 dwStartTime, dwCurTime, dwTotalTime; - uint32 stepX, stepY; - int dimx, dimy; + int lx, ly; + RMPoint pt, startpt; + uint32 dwStartTime, dwCurTime, dwTotalTime; + uint32 stepX, stepY; + int dimx, dimy; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -1330,16 +1277,19 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui _ctx->ly = (int32)nY; _ctx->dimx = _ctx->lx; _ctx->dimy = _ctx->ly; - if (_ctx->lx < 0) _ctx->dimx = -_ctx->lx; - if (_ctx->ly < 0) _ctx->dimy = -_ctx->ly; + if (_ctx->lx < 0) + _ctx->dimx = -_ctx->lx; + + if (_ctx->ly < 0) + _ctx->dimy = -_ctx->ly; _ctx->stepX = sX; _ctx->stepY = sY; _ctx->startpt = GLOBALS.Loc->ScrollPosition(); - + _ctx->dwStartTime = _vm->GetTime(); - + if (sX) _ctx->dwTotalTime = _ctx->dimx * (1000 / 35) / sX; else @@ -1351,7 +1301,7 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui break; _ctx->pt = _ctx->startpt; - + if (sX) { if (_ctx->lx > 0) _ctx->pt.x += (_ctx->dimx * _ctx->dwCurTime) / _ctx->dwTotalTime; @@ -1359,30 +1309,41 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui _ctx->pt.x -= (_ctx->dimx * _ctx->dwCurTime) / _ctx->dwTotalTime; } else { if (_ctx->ly > 0) - _ctx->pt.y += (_ctx->dimy*_ctx->dwCurTime) / _ctx->dwTotalTime; + _ctx->pt.y += (_ctx->dimy * _ctx->dwCurTime) / _ctx->dwTotalTime; else - _ctx->pt.y -= (_ctx->dimy*_ctx->dwCurTime) / _ctx->dwTotalTime; + _ctx->pt.y -= (_ctx->dimy * _ctx->dwCurTime) / _ctx->dwTotalTime; } -/* +/* sX = _ctx->stepX * (_ctx->dwCurTime-dwLastTime) / (1000 / 35); sY = _ctx->stepY * (_ctx->dwCurTime-dwLastTime) / (1000 / 35); if (_ctx->lx > 0) { - _ctx->lx-=sX; if (_ctx->lx < 0) _ctx->lx = 0; - _ctx->pt.Offset(sX,0); + _ctx->lx -= sX; + if (_ctx->lx < 0) + _ctx->lx = 0; + _ctx->pt.Offset(sX, 0); } else if (_ctx->lx < 0) { - _ctx->lx+=sX; if (_ctx->lx > 0) _ctx->lx = 0; - _ctx->pt.Offset(-sX,0); + _ctx->lx += sX; + + if (_ctx->lx > 0) + _ctx->lx = 0; + + _ctx->pt.Offset(-sX, 0); } if (_ctx->ly > 0) { - _ctx->ly-=sY; if (_ctx->ly<0) _ctx->ly = 0; - _ctx->pt.Offset(0,sY); - } else if (_ctx->ly<0) { - _ctx->ly+=sY; if (_ctx->ly > 0) _ctx->ly = 0; - _ctx->pt.Offset(0,-sY); + _ctx->ly -= sY; + if (_ctx->ly < 0) + _ctx->ly = 0; + _ctx->pt.Offset(0, sY); + } else if (_ctx->ly < 0) { + _ctx->ly += sY; + if (_ctx->ly > 0) + _ctx->ly = 0; + + _ctx->pt.Offset(0, -sY); } */ CORO_INVOKE_0(GLOBALS.WaitFrame); @@ -1422,15 +1383,15 @@ DECLARE_CUSTOM_FUNCTION(ChangeHotspot)(CORO_PARAM, uint32 dwCode, uint32 nX, uin for (i = 0; i < GLOBALS.curChangedHotspot; i++) if (GLOBALS.ChangedHotspot[i].dwCode == dwCode) { - GLOBALS.ChangedHotspot[i].nX=nX; - GLOBALS.ChangedHotspot[i].nY=nY; + GLOBALS.ChangedHotspot[i].nX = nX; + GLOBALS.ChangedHotspot[i].nY = nY; break; } if (i == GLOBALS.curChangedHotspot) { - GLOBALS.ChangedHotspot[i].dwCode=dwCode; - GLOBALS.ChangedHotspot[i].nX=nX; - GLOBALS.ChangedHotspot[i].nY=nY; + GLOBALS.ChangedHotspot[i].dwCode = dwCode; + GLOBALS.ChangedHotspot[i].nX = nX; + GLOBALS.ChangedHotspot[i].nY = nY; GLOBALS.curChangedHotspot++; } @@ -1448,15 +1409,15 @@ DECLARE_CUSTOM_FUNCTION(Abort)(CORO_PARAM, uint32, uint32, uint32, uint32) { DECLARE_CUSTOM_FUNCTION(TremaSchermo)(CORO_PARAM, uint32 nScosse, uint32, uint32, uint32) { CORO_BEGIN_CONTEXT; - uint32 i; - uint32 curTime; - int dirx,diry; + uint32 i; + uint32 curTime; + int dirx, diry; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); _ctx->curTime = _vm->GetTime(); - + _ctx->dirx = 1; _ctx->diry = 1; @@ -1480,14 +1441,14 @@ DECLARE_CUSTOM_FUNCTION(TremaSchermo)(CORO_PARAM, uint32 nScosse, uint32, uint32 GLOBALS.Loc->SetFixedScroll(RMPoint(0, 0)); GLOBALS.Tony->SetFixedScroll(RMPoint(0, 0)); GLOBALS.Unfreeze(); - + CORO_END_CODE; } /* - * Personaggi + * Personaggi */ DECLARE_CUSTOM_FUNCTION(CharSetCode)(CORO_PARAM, uint32 nChar, uint32 nCode, uint32, uint32) { @@ -1496,7 +1457,7 @@ DECLARE_CUSTOM_FUNCTION(CharSetCode)(CORO_PARAM, uint32 nChar, uint32 nCode, uin GLOBALS.Character[nChar].item = GLOBALS.Loc->GetItemFromCode(nCode); GLOBALS.Character[nChar].r = 255; GLOBALS.Character[nChar].g = 255; - GLOBALS.Character[nChar].b = 255; + GLOBALS.Character[nChar].b = 255; GLOBALS.Character[nChar].talkpattern = 0; GLOBALS.Character[nChar].starttalkpattern = 0; GLOBALS.Character[nChar].endtalkpattern = 0; @@ -1506,33 +1467,33 @@ DECLARE_CUSTOM_FUNCTION(CharSetCode)(CORO_PARAM, uint32 nChar, uint32 nCode, uin } DECLARE_CUSTOM_FUNCTION(CharSetColor)(CORO_PARAM, uint32 nChar, uint32 r, uint32 g, uint32 b) { - assert(nChar<16); + assert(nChar < 16); GLOBALS.Character[nChar].r = r; GLOBALS.Character[nChar].g = g; GLOBALS.Character[nChar].b = b; } DECLARE_CUSTOM_FUNCTION(CharSetTalkPattern)(CORO_PARAM, uint32 nChar, uint32 tp, uint32 sp, uint32) { - assert(nChar<16); + assert(nChar < 16); GLOBALS.Character[nChar].talkpattern = tp; GLOBALS.Character[nChar].standpattern = sp; } DECLARE_CUSTOM_FUNCTION(CharSetStartEndTalkPattern)(CORO_PARAM, uint32 nChar, uint32 sp, uint32 ep, uint32) { - assert(nChar<16); - GLOBALS.Character[nChar].starttalkpattern=sp; - GLOBALS.Character[nChar].endtalkpattern=ep; + assert(nChar < 16); + GLOBALS.Character[nChar].starttalkpattern = sp; + GLOBALS.Character[nChar].endtalkpattern = ep; } DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMessage, uint32 bIsBack, uint32) { CORO_BEGIN_CONTEXT; - RMMessage *msg; - int i; - RMPoint pt; - RMTextDialog *text; - int curOffset; - VoiceHeader *curVoc; - FPSFX *voice; + RMMessage *msg; + int i; + RMPoint pt; + RMTextDialog *text; + int curOffset; + VoiceHeader *curVoc; + FPSFX *voice; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -1542,16 +1503,16 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess assert(nChar < 16); _ctx->pt = GLOBALS.Character[nChar].item->CalculatePos() - RMPoint(-60, 20) - GLOBALS.Loc->ScrollPosition(); - + if (GLOBALS.Character[nChar].starttalkpattern != 0) { GLOBALS.Freeze(); GLOBALS.Character[nChar].item->SetPattern(GLOBALS.Character[nChar].starttalkpattern); GLOBALS.Unfreeze(); - + CORO_INVOKE_0(GLOBALS.Character[nChar].item->WaitForEndPattern); } - GLOBALS.Freeze(); + GLOBALS.Freeze(); GLOBALS.Character[nChar].item->SetPattern(GLOBALS.Character[nChar].talkpattern); GLOBALS.Unfreeze(); @@ -1559,14 +1520,14 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess _ctx->voice = NULL; if (_ctx->curVoc) { // Si posiziona all'interno del database delle voci all'inizio della prima -// fseek(_vm->m_vdbFP, _ctx->curVoc->offset, SEEK_SET); + // fseek(_vm->m_vdbFP, _ctx->curVoc->offset, SEEK_SET); g_system->lockMutex(GLOBALS.vdb); _vm->_vdbFP.seek(_ctx->curVoc->offset); _ctx->curOffset = _ctx->curVoc->offset; g_system->unlockMutex(GLOBALS.vdb); } - for (_ctx->i = 0; _ctx->i<_ctx->msg->NumPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { + for (_ctx->i = 0; _ctx->i < _ctx->msg->NumPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { if (bIsBack) { GLOBALS.curBackText = _ctx->text = new RMTextDialogScrolling(GLOBALS.Loc); if (GLOBALS.bTonyIsSpeaking) @@ -1578,21 +1539,24 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess // Skipping _ctx->text->SetSkipStatus(!bIsBack); - + // Allineamento - _ctx->text->SetAlignType(RMText::HCENTER,RMText::VBOTTOM); - + _ctx->text->SetAlignType(RMText::HCENTER, RMText::VBOTTOM); + // Colore - _ctx->text->SetColor(GLOBALS.Character[nChar].r,GLOBALS.Character[nChar].g,GLOBALS.Character[nChar].b); + _ctx->text->SetColor(GLOBALS.Character[nChar].r, GLOBALS.Character[nChar].g, GLOBALS.Character[nChar].b); // Scrive il testo - _ctx->text->WriteText((*_ctx->msg)[_ctx->i],0); + _ctx->text->WriteText((*_ctx->msg)[_ctx->i], 0); // Setta la posizione _ctx->text->SetPosition(_ctx->pt); // Setta l'always display - if (GLOBALS.bAlwaysDisplay) { _ctx->text->SetAlwaysDisplay(); _ctx->text->ForceTime(); } + if (GLOBALS.bAlwaysDisplay) { + _ctx->text->SetAlwaysDisplay(); + _ctx->text->ForceTime(); + } // Registra il testo GLOBALS.LinkGraphicTask(_ctx->text); @@ -1610,14 +1574,14 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess g_system->unlockMutex(GLOBALS.vdb); } - // Aspetta la fine della visualizzazione + // Aspetta la fine della visualizzazione _ctx->text->SetCustomSkipHandle(GLOBALS.hSkipIdle); CORO_INVOKE_0(_ctx->text->WaitForEndDisplay); if (_ctx->curVoc) { _ctx->voice->Stop(); _ctx->voice->Release(); - _ctx->voice=NULL; + _ctx->voice = NULL; } @@ -1630,7 +1594,7 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess GLOBALS.Character[nChar].item->SetPattern(GLOBALS.Character[nChar].endtalkpattern); GLOBALS.Unfreeze(); CORO_INVOKE_0(GLOBALS.Character[nChar].item->WaitForEndPattern); - } + } GLOBALS.Freeze(); GLOBALS.Character[nChar].item->SetPattern(GLOBALS.Character[nChar].standpattern); @@ -1641,7 +1605,7 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess } DECLARE_CUSTOM_FUNCTION(AddInventory)(CORO_PARAM, uint32 dwCode, uint32, uint32, uint32) { - GLOBALS.Inventory->AddItem(dwCode); + GLOBALS.Inventory->AddItem(dwCode); } DECLARE_CUSTOM_FUNCTION(RemoveInventory)(CORO_PARAM, uint32 dwCode, uint32, uint32, uint32) { @@ -1649,67 +1613,66 @@ DECLARE_CUSTOM_FUNCTION(RemoveInventory)(CORO_PARAM, uint32 dwCode, uint32, uint } DECLARE_CUSTOM_FUNCTION(ChangeInventoryStatus)(CORO_PARAM, uint32 dwCode, uint32 dwStatus, uint32, uint32) { - GLOBALS.Inventory->ChangeItemStatus(dwCode,dwStatus); + GLOBALS.Inventory->ChangeItemStatus(dwCode, dwStatus); } /* - * Mastri Personaggi + * Mastri Personaggi */ DECLARE_CUSTOM_FUNCTION(MCharSetCode)(CORO_PARAM, uint32 nChar, uint32 nCode, uint32, uint32) { assert(nChar < 10); - GLOBALS.MCharacter[nChar].code=nCode; - if (nCode== 0) - GLOBALS.MCharacter[nChar].item=NULL; + GLOBALS.MCharacter[nChar].code = nCode; + if (nCode == 0) + GLOBALS.MCharacter[nChar].item = NULL; else - GLOBALS.MCharacter[nChar].item=GLOBALS.Loc->GetItemFromCode(nCode); - GLOBALS.MCharacter[nChar].r=255; - GLOBALS.MCharacter[nChar].g=255; - GLOBALS.MCharacter[nChar].b=255; - GLOBALS.MCharacter[nChar].x=-1; - GLOBALS.MCharacter[nChar].y=-1; + GLOBALS.MCharacter[nChar].item = GLOBALS.Loc->GetItemFromCode(nCode); + GLOBALS.MCharacter[nChar].r = 255; + GLOBALS.MCharacter[nChar].g = 255; + GLOBALS.MCharacter[nChar].b = 255; + GLOBALS.MCharacter[nChar].x = -1; + GLOBALS.MCharacter[nChar].y = -1; GLOBALS.MCharacter[nChar].bAlwaysBack = 0; for (int i = 0; i < 10; i++) GLOBALS.MCharacter[nChar].numtalks[i] = 1; GLOBALS.MCharacter[nChar].curgroup = 0; - + GLOBALS.IsMChar[nChar] = true; } DECLARE_CUSTOM_FUNCTION(MCharResetCode)(CORO_PARAM, uint32 nChar, uint32, uint32, uint32) { - GLOBALS.MCharacter[nChar].item=GLOBALS.Loc->GetItemFromCode(GLOBALS.MCharacter[nChar].code); + GLOBALS.MCharacter[nChar].item = GLOBALS.Loc->GetItemFromCode(GLOBALS.MCharacter[nChar].code); } DECLARE_CUSTOM_FUNCTION(MCharSetPosition)(CORO_PARAM, uint32 nChar, uint32 nX, uint32 nY, uint32) { assert(nChar < 10); - GLOBALS.MCharacter[nChar].x=nX; - GLOBALS.MCharacter[nChar].y=nY; + GLOBALS.MCharacter[nChar].x = nX; + GLOBALS.MCharacter[nChar].y = nY; } DECLARE_CUSTOM_FUNCTION(MCharSetColor)(CORO_PARAM, uint32 nChar, uint32 r, uint32 g, uint32 b) { assert(nChar < 10); - GLOBALS.MCharacter[nChar].r=r; - GLOBALS.MCharacter[nChar].g=g; - GLOBALS.MCharacter[nChar].b=b; + GLOBALS.MCharacter[nChar].r = r; + GLOBALS.MCharacter[nChar].g = g; + GLOBALS.MCharacter[nChar].b = b; } DECLARE_CUSTOM_FUNCTION(MCharSetNumTalksInGroup)(CORO_PARAM, uint32 nChar, uint32 nGroup, uint32 nTalks, uint32) { - assert(nChar < 10); + assert(nChar < 10); assert(nGroup < 10); - GLOBALS.MCharacter[nChar].numtalks[nGroup]=nTalks; + GLOBALS.MCharacter[nChar].numtalks[nGroup] = nTalks; } -DECLARE_CUSTOM_FUNCTION(MCharSetCurrentGroup)(CORO_PARAM, uint32 nChar, uint32 nGroup, uint32, uint32) -{ - assert(nChar < 10); +DECLARE_CUSTOM_FUNCTION(MCharSetCurrentGroup)(CORO_PARAM, uint32 nChar, uint32 nGroup, uint32, uint32) { + assert(nChar < 10); assert(nGroup < 10); GLOBALS.MCharacter[nChar].curgroup = nGroup; @@ -1718,28 +1681,28 @@ DECLARE_CUSTOM_FUNCTION(MCharSetCurrentGroup)(CORO_PARAM, uint32 nChar, uint32 n DECLARE_CUSTOM_FUNCTION(MCharSetNumTexts)(CORO_PARAM, uint32 nChar, uint32 nTexts, uint32, uint32) { assert(nChar < 10); - GLOBALS.MCharacter[nChar].numtexts=nTexts-1; + GLOBALS.MCharacter[nChar].numtexts = nTexts - 1; GLOBALS.MCharacter[nChar].bInTexts = false; } DECLARE_CUSTOM_FUNCTION(MCharSetAlwaysBack)(CORO_PARAM, uint32 nChar, uint32 bAlwaysBack, uint32, uint32) { assert(nChar < 10); - GLOBALS.MCharacter[nChar].bAlwaysBack=bAlwaysBack; + GLOBALS.MCharacter[nChar].bAlwaysBack = bAlwaysBack; } DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMessage, uint32 bIsBack, uint32 nFont) { CORO_BEGIN_CONTEXT; - RMMessage *msg; - int i; - int parm; - RMPoint pt; - uint32 h; - RMTextDialog *text; - int curOffset; - VoiceHeader *curVoc; - FPSFX *voice; + RMMessage *msg; + int i; + int parm; + RMPoint pt; + uint32 h; + RMTextDialog *text; + int curOffset; + VoiceHeader *curVoc; + FPSFX *voice; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -1752,14 +1715,14 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes bIsBack |= GLOBALS.MCharacter[nChar].bAlwaysBack ? 1 : 0; // Calcola la posizione del testo in base al frame corrente - if (GLOBALS.MCharacter[nChar].x==-1) - _ctx->pt=GLOBALS.MCharacter[nChar].item->CalculatePos()-RMPoint(-60,20)-GLOBALS.Loc->ScrollPosition(); + if (GLOBALS.MCharacter[nChar].x == -1) + _ctx->pt = GLOBALS.MCharacter[nChar].item->CalculatePos() - RMPoint(-60, 20) - GLOBALS.Loc->ScrollPosition(); else - _ctx->pt=RMPoint(GLOBALS.MCharacter[nChar].x,GLOBALS.MCharacter[nChar].y); - + _ctx->pt = RMPoint(GLOBALS.MCharacter[nChar].x, GLOBALS.MCharacter[nChar].y); + // Parametro per le azioni speciali: random tra le parlate _ctx->parm = (GLOBALS.MCharacter[nChar].curgroup * 10) + _vm->_randomSource.getRandomNumber( - GLOBALS.MCharacter[nChar].numtalks[GLOBALS.MCharacter[nChar].curgroup] - 1) + 1; + GLOBALS.MCharacter[nChar].numtalks[GLOBALS.MCharacter[nChar].curgroup] - 1) + 1; // Cerca di eseguire la funzione custom per inizializzare la parlata if (GLOBALS.MCharacter[nChar].item) { @@ -1774,7 +1737,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes if (_ctx->curVoc) { // Si posiziona all'interno del database delle voci all'inizio della prima g_system->lockMutex(GLOBALS.vdb); - // fseek(_vm->m_vdbFP, curVoc->offset, SEEK_SET); + // fseek(_vm->m_vdbFP, curVoc->offset, SEEK_SET); _vm->_vdbFP.seek(_ctx->curVoc->offset); _ctx->curOffset = _ctx->curVoc->offset; g_system->unlockMutex(GLOBALS.vdb); @@ -1786,20 +1749,19 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes GLOBALS.curBackText = _ctx->text = new RMTextDialogScrolling(GLOBALS.Loc); if (GLOBALS.bTonyIsSpeaking) CORO_INVOKE_0(GLOBALS.curBackText->Hide); - } - else + } else _ctx->text = new RMTextDialog; _ctx->text->SetInput(GLOBALS.Input); // Skipping _ctx->text->SetSkipStatus(!bIsBack); - + // Allineamento - _ctx->text->SetAlignType(RMText::HCENTER,RMText::VBOTTOM); - + _ctx->text->SetAlignType(RMText::HCENTER, RMText::VBOTTOM); + // Colore - _ctx->text->SetColor(GLOBALS.MCharacter[nChar].r,GLOBALS.MCharacter[nChar].g,GLOBALS.MCharacter[nChar].b); + _ctx->text->SetColor(GLOBALS.MCharacter[nChar].r, GLOBALS.MCharacter[nChar].g, GLOBALS.MCharacter[nChar].b); // Scrive il testo _ctx->text->WriteText((*_ctx->msg)[_ctx->i], nFont); @@ -1808,7 +1770,10 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes _ctx->text->SetPosition(_ctx->pt); // Setta l'always display - if (GLOBALS.bAlwaysDisplay) { _ctx->text->SetAlwaysDisplay(); _ctx->text->ForceTime(); } + if (GLOBALS.bAlwaysDisplay) { + _ctx->text->SetAlwaysDisplay(); + _ctx->text->ForceTime(); + } // Registra il testo GLOBALS.LinkGraphicTask(_ctx->text); @@ -1826,7 +1791,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes g_system->unlockMutex(GLOBALS.vdb); } - // Aspetta la fine della visualizzazione + // Aspetta la fine della visualizzazione _ctx->text->SetCustomSkipHandle(GLOBALS.hSkipIdle); CORO_INVOKE_0(_ctx->text->WaitForEndDisplay); @@ -1836,7 +1801,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes _ctx->voice = NULL; } - GLOBALS.curBackText = NULL; + GLOBALS.curBackText = NULL; delete _ctx->text; delete _ctx->msg; } @@ -1858,21 +1823,21 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes /* - * Dialoghi + * Dialoghi */ int curDialog; DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg, uint32, uint32) { CORO_BEGIN_CONTEXT; - LPSTR string; - RMTextDialog *text; - int parm; - uint32 h; - bool bIsBack; - VoiceHeader *curVoc; - FPSFX *voice; - RMPoint pt; + LPSTR string; + RMTextDialog *text; + int parm; + uint32 h; + bool bIsBack; + VoiceHeader *curVoc; + FPSFX *voice; + RMPoint pt; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -1881,7 +1846,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg // La SendDialogMessage pu andare in background se un personaggio in MCHAR settato // con la SetAlwaysBack - if (nPers != 0 && GLOBALS.IsMChar[nPers] && GLOBALS.MCharacter[nPers].bAlwaysBack) + if (nPers != 0 && GLOBALS.IsMChar[nPers] && GLOBALS.MCharacter[nPers].bAlwaysBack) _ctx->bIsBack = true; _ctx->curVoc = SearchVoiceHeader(curDialog, nMsg); @@ -1890,7 +1855,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg if (_ctx->curVoc) { // Si posiziona all'interno del database delle voci all'inizio della prima g_system->lockMutex(GLOBALS.vdb); -// fseek(_vm->m_vdbFP, _ctx->curVoc->offset, SEEK_SET); + // fseek(_vm->m_vdbFP, _ctx->curVoc->offset, SEEK_SET); _vm->_vdbFP.seek(_ctx->curVoc->offset); _vm->_theSound.CreateSfx(&_ctx->voice); _ctx->voice->LoadVoiceFromVDB(_vm->_vdbFP); @@ -1903,12 +1868,12 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg if (nPers == 0) { _ctx->text = new RMTextDialog; - _ctx->text->SetColor(0,255,0); - _ctx->text->SetPosition(GLOBALS.Tony->Position()-RMPoint(0,130)-GLOBALS.Loc->ScrollPosition()); - _ctx->text->WriteText(_ctx->string,0); + _ctx->text->SetColor(0, 255, 0); + _ctx->text->SetPosition(GLOBALS.Tony->Position() - RMPoint(0, 130) - GLOBALS.Loc->ScrollPosition()); + _ctx->text->WriteText(_ctx->string, 0); if (GLOBALS.dwTonyNumTexts > 0) { - if (!GLOBALS.bTonyInTexts) { + if (!GLOBALS.bTonyInTexts) { if (GLOBALS.nTonyNextTalkType != GLOBALS.Tony->TALK_NORMAL) { CORO_INVOKE_1(GLOBALS.Tony->StartTalk, GLOBALS.nTonyNextTalkType); if (!GLOBALS.bStaticTalk) @@ -1930,15 +1895,15 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg _ctx->pt = GLOBALS.Character[nPers].item->CalculatePos() - RMPoint(-60, 20) - GLOBALS.Loc->ScrollPosition(); if (GLOBALS.Character[nPers].starttalkpattern != 0) { - GLOBALS.Freeze(); - GLOBALS.Character[nPers].item->SetPattern(GLOBALS.Character[nPers].starttalkpattern); - GLOBALS.Unfreeze(); + GLOBALS.Freeze(); + GLOBALS.Character[nPers].item->SetPattern(GLOBALS.Character[nPers].starttalkpattern); + GLOBALS.Unfreeze(); CORO_INVOKE_0(GLOBALS.Character[nPers].item->WaitForEndPattern); - } + } GLOBALS.Character[nPers].item->SetPattern(GLOBALS.Character[nPers].talkpattern); - _ctx->text->SetColor(GLOBALS.Character[nPers].r, GLOBALS.Character[nPers].g,GLOBALS.Character[nPers].b); + _ctx->text->SetColor(GLOBALS.Character[nPers].r, GLOBALS.Character[nPers].g, GLOBALS.Character[nPers].b); _ctx->text->WriteText(_ctx->string, 0); _ctx->text->SetPosition(_ctx->pt); } else { @@ -1949,7 +1914,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg // Parametro per le azioni speciali: random tra le parlate _ctx->parm = (GLOBALS.MCharacter[nPers].curgroup * 10) + _vm->_randomSource.getRandomNumber( - GLOBALS.MCharacter[nPers].numtalks[GLOBALS.MCharacter[nPers].curgroup] - 1) + 1; + GLOBALS.MCharacter[nPers].numtalks[GLOBALS.MCharacter[nPers].curgroup] - 1) + 1; if (GLOBALS.MCharacter[nPers].numtexts != 0 && GLOBALS.MCharacter[nPers].bInTexts) { GLOBALS.MCharacter[nPers].numtexts--; @@ -1960,7 +1925,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->h, CORO_INFINITE); GLOBALS.MCharacter[nPers].curTalk = _ctx->parm; - + if (GLOBALS.MCharacter[nPers].numtexts != 0) { GLOBALS.MCharacter[nPers].bInTexts = true; GLOBALS.MCharacter[nPers].numtexts--; @@ -1977,15 +1942,18 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg _ctx->text = new RMTextDialog; _ctx->text->SetSkipStatus(!GLOBALS.MCharacter[nPers].bAlwaysBack); - _ctx->text->SetColor(GLOBALS.MCharacter[nPers].r,GLOBALS.MCharacter[nPers].g,GLOBALS.MCharacter[nPers].b); - _ctx->text->WriteText(_ctx->string,0); + _ctx->text->SetColor(GLOBALS.MCharacter[nPers].r, GLOBALS.MCharacter[nPers].g, GLOBALS.MCharacter[nPers].b); + _ctx->text->WriteText(_ctx->string, 0); _ctx->text->SetPosition(_ctx->pt); } if (!GLOBALS.bSkipIdle) { _ctx->text->SetInput(GLOBALS.Input); - if (GLOBALS.bAlwaysDisplay) { _ctx->text->SetAlwaysDisplay(); _ctx->text->ForceTime(); } - _ctx->text->SetAlignType(RMText::HCENTER,RMText::VBOTTOM); + if (GLOBALS.bAlwaysDisplay) { + _ctx->text->SetAlwaysDisplay(); + _ctx->text->ForceTime(); + } + _ctx->text->SetAlignType(RMText::HCENTER, RMText::VBOTTOM); GLOBALS.LinkGraphicTask(_ctx->text); if (_ctx->curVoc) { @@ -1993,7 +1961,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg _ctx->text->SetCustomSkipHandle2(_ctx->voice->hEndOfBuffer); } - // Aspetta la fine della visualizzazione + // Aspetta la fine della visualizzazione _ctx->text->SetCustomSkipHandle(GLOBALS.hSkipIdle); CORO_INVOKE_0(_ctx->text->WaitForEndDisplay); } @@ -2001,25 +1969,25 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg if (_ctx->curVoc) { _ctx->voice->Stop(); _ctx->voice->Release(); - _ctx->voice=NULL; + _ctx->voice = NULL; } if (nPers != 0) { if (!GLOBALS.IsMChar[nPers]) { - if (GLOBALS.Character[nPers].endtalkpattern != 0) { + if (GLOBALS.Character[nPers].endtalkpattern != 0) { GLOBALS.Freeze(); GLOBALS.Character[nPers].item->SetPattern(GLOBALS.Character[nPers].endtalkpattern); GLOBALS.Unfreeze(); CORO_INVOKE_0(GLOBALS.Character[nPers].item->WaitForEndPattern); - } - + } + GLOBALS.Character[nPers].item->SetPattern(GLOBALS.Character[nPers].standpattern); delete _ctx->text; } else { - if ((GLOBALS.MCharacter[nPers].bInTexts && GLOBALS.MCharacter[nPers].numtexts== 0) || !GLOBALS.MCharacter[nPers].bInTexts) { + if ((GLOBALS.MCharacter[nPers].bInTexts && GLOBALS.MCharacter[nPers].numtexts == 0) || !GLOBALS.MCharacter[nPers].bInTexts) { // Cerca di eseguire la funzione custom per chiudere la parlata - GLOBALS.MCharacter[nPers].curTalk = (GLOBALS.MCharacter[nPers].curTalk%10) + GLOBALS.MCharacter[nPers].curgroup*10; - _ctx->h = mpalQueryDoAction(31,GLOBALS.MCharacter[nPers].item->MpalCode(),GLOBALS.MCharacter[nPers].curTalk); + GLOBALS.MCharacter[nPers].curTalk = (GLOBALS.MCharacter[nPers].curTalk % 10) + GLOBALS.MCharacter[nPers].curgroup * 10; + _ctx->h = mpalQueryDoAction(31, GLOBALS.MCharacter[nPers].item->MpalCode(), GLOBALS.MCharacter[nPers].curTalk); if (_ctx->h != CORO_INVALID_PID_VALUE) CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->h, CORO_INFINITE); @@ -2031,7 +1999,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg delete _ctx->text; } } else { - if ((GLOBALS.dwTonyNumTexts== 0 && GLOBALS.bTonyInTexts) || !GLOBALS.bTonyInTexts) { + if ((GLOBALS.dwTonyNumTexts == 0 && GLOBALS.bTonyInTexts) || !GLOBALS.bTonyInTexts) { CORO_INVOKE_0(GLOBALS.Tony->EndTalk); GLOBALS.dwTonyNumTexts = 0; GLOBALS.bTonyInTexts = false; @@ -2050,24 +2018,24 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGroup, uint32, uint32) { CORO_BEGIN_CONTEXT; - uint32 nChoice; - uint32 *sl; - uint32 i, num; - char *string; - RMDialogChoice dc; - int sel; + uint32 nChoice; + uint32 *sl; + uint32 i, num; + char *string; + RMDialogChoice dc; + int sel; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); curDialog = nDialog; - + // Call MPAL to start the dialog mpalQueryDoDialog(nDialog, nStartGroup); // Wait until a choice is selected mpalQueryDialogWaitForChoice(&_ctx->nChoice); - while (_ctx->nChoice != (uint32)-1) { + while (_ctx->nChoice != (uint32) - 1) { // Si fa dare la lista di opzioni e le conta _ctx->sl = mpalQueryDialogSelectList(_ctx->nChoice); for (_ctx->num = 0; _ctx->sl[_ctx->num] != 0; _ctx->num++) @@ -2082,7 +2050,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr mpalQueryDialogWaitForChoice(&_ctx->nChoice); continue; } - + // Crea una scelta per il dialogo _ctx->dc.Init(); _ctx->dc.SetNumChoices(_ctx->num); @@ -2102,17 +2070,17 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr // Disegna il puntatore GLOBALS.Pointer->SetSpecialPointer(GLOBALS.Pointer->PTR_NONE); MainShowMouse(); - + while (!(GLOBALS.Input->MouseLeftClicked() && ((_ctx->sel = _ctx->dc.GetSelection()) != -1))) { CORO_INVOKE_0(GLOBALS.WaitFrame); GLOBALS.Freeze(); CORO_INVOKE_1(_ctx->dc.DoFrame, GLOBALS.Input->MousePos()); GLOBALS.Unfreeze(); - } + } // Nascondi il puntatore MainHideMouse(); - + CORO_INVOKE_0(_ctx->dc.Hide); mpalQueryDialogSelectionDWORD(_ctx->nChoice, _ctx->sl[_ctx->sel]); @@ -2130,7 +2098,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr /* - * Sync tra idle e mpal + * Sync tra idle e mpal */ DECLARE_CUSTOM_FUNCTION(TakeOwnership)(CORO_PARAM, uint32 num, uint32, uint32, uint32) { @@ -2138,7 +2106,7 @@ DECLARE_CUSTOM_FUNCTION(TakeOwnership)(CORO_PARAM, uint32 num, uint32, uint32, u } DECLARE_CUSTOM_FUNCTION(ReleaseOwnership)(CORO_PARAM, uint32 num, uint32, uint32, uint32) { - CoroScheduler.pulseEvent(GLOBALS.mut[num]); + CoroScheduler.pulseEvent(GLOBALS.mut[num]); warning("TODO: Validate that the use of events in TakeOwnership/ReleaseOwnership match original"); } @@ -2153,20 +2121,20 @@ DECLARE_CUSTOM_FUNCTION(ReleaseOwnership)(CORO_PARAM, uint32 num, uint32, uint32 /* - * Musica + * Musica * ------ * * Effetti di fade supportati: * * nFX = 0 - La nuova musica si sostituisce a quella vecchia * nFX=1 - La nuova musica si interfade con quella vecchia - * nFX=2 - La nuova musica subentra a tempo con quella vecchia + * nFX=2 - La nuova musica subentra a tempo con quella vecchia * */ void ThreadFadeInMusic(CORO_PARAM, const void *nMusic) { CORO_BEGIN_CONTEXT; - int i; + int i; CORO_END_CONTEXT(_ctx); int nChannel = *(const int *)nMusic; @@ -2183,7 +2151,7 @@ void ThreadFadeInMusic(CORO_PARAM, const void *nMusic) { _vm->SetMusicVolume(nChannel, 64); debug("End FadeIn Music"); - + CORO_KILL_SELF(); CORO_END_CODE; @@ -2191,8 +2159,8 @@ void ThreadFadeInMusic(CORO_PARAM, const void *nMusic) { void ThreadFadeOutMusic(CORO_PARAM, const void *nMusic) { CORO_BEGIN_CONTEXT; - int i; - int startVolume; + int i; + int startVolume; CORO_END_CONTEXT(_ctx); int nChannel = *(const int *)nMusic; @@ -2209,7 +2177,7 @@ void ThreadFadeOutMusic(CORO_PARAM, const void *nMusic) { CORO_INVOKE_1(CoroScheduler.sleep, 100); } - + if (!GLOBALS.bFadeOutStop) _vm->SetMusicVolume(nChannel, 0); @@ -2282,21 +2250,21 @@ void CustPlayMusic(uint32 nChannel, const char *mFN, uint32 nFX, bool bLoop, int } DECLARE_CUSTOM_FUNCTION(PlaySonoriz)(CORO_PARAM, uint32 nMusic, uint32 nFX, uint32 bNoLoop, uint32) { - if (nFX == 0 || nFX == 1 || nFX==2) { + if (nFX == 0 || nFX == 1 || nFX == 2) { debug("PlaySonoriz stop fadeout"); GLOBALS.bFadeOutStop = true; } - + GLOBALS.lastMusic = nMusic; CustPlayMusic(GLOBALS.curSonoriz, musicFiles[nMusic].name, nFX, bNoLoop ? false : true, musicFiles[nMusic].sync); } DECLARE_CUSTOM_FUNCTION(PlayStacchetto)(CORO_PARAM, uint32 nMusic, uint32 nFX, uint32 bLoop, uint32) { - CustPlayMusic(2,staccFileNames[nMusic],nFX,bLoop); + CustPlayMusic(2, staccFileNames[nMusic], nFX, bLoop); } DECLARE_CUSTOM_FUNCTION(PlayItemSfx)(CORO_PARAM, uint32 nItem, uint32 nSFX, uint32, uint32) { - if (nItem== 0) { + if (nItem == 0) { GLOBALS.Tony->PlaySfx(nSFX); } else { RMItem *item = GLOBALS.Loc->GetItemFromCode(nItem); @@ -2340,7 +2308,7 @@ DECLARE_CUSTOM_FUNCTION(StacchettoFadeStart)(CORO_PARAM, uint32 nStacc, uint32 b CORO_INVOKE_4(FadeOutSonoriz, 0, 0, 0, 0); CORO_INVOKE_4(MuteStacchetto, 0, 0, 0, 0); CORO_INVOKE_4(PlayStacchetto, nStacc, 0, bLoop, 0); - CORO_INVOKE_4(FadeInStacchetto, 0, 0, 0, 0); + CORO_INVOKE_4(FadeInStacchetto, 0, 0, 0, 0); CORO_END_CODE; } @@ -2403,21 +2371,21 @@ DECLARE_CUSTOM_FUNCTION(OpenInitOptions)(CORO_PARAM, uint32, uint32, uint32, uin DECLARE_CUSTOM_FUNCTION(DoCredits)(CORO_PARAM, uint32 nMsg, uint32 dwTime, uint32, uint32) { CORO_BEGIN_CONTEXT; - RMMessage *msg; - RMTextDialog *text; - uint32 hDisable; - int i; - uint32 startTime; + RMMessage *msg; + RMTextDialog *text; + uint32 hDisable; + int i; + uint32 startTime; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); _ctx->msg = new RMMessage(nMsg); _ctx->hDisable = CoroScheduler.createEvent(true, false); - + _ctx->text = new RMTextDialog[_ctx->msg->NumPeriods()]; - for (_ctx->i = 0; _ctx->i < _ctx->msg->NumPeriods(); _ctx->i++) { + for (_ctx->i = 0; _ctx->i < _ctx->msg->NumPeriods(); _ctx->i++) { _ctx->text[_ctx->i].SetInput(GLOBALS.Input); // Alignment @@ -2426,24 +2394,24 @@ DECLARE_CUSTOM_FUNCTION(DoCredits)(CORO_PARAM, uint32 nMsg, uint32 dwTime, uint3 _ctx->text[_ctx->i].WriteText(&(*_ctx->msg)[_ctx->i][1], 3); _ctx->text[_ctx->i].SetPosition(RMPoint(414, 70 + _ctx->i * 26)); // 70 } else { - _ctx->text[_ctx->i].SetAlignType(RMText::HLEFT,RMText::VTOP); + _ctx->text[_ctx->i].SetAlignType(RMText::HLEFT, RMText::VTOP); _ctx->text[_ctx->i].WriteText((*_ctx->msg)[_ctx->i], 3); _ctx->text[_ctx->i].SetPosition(RMPoint(260, 70 + _ctx->i * 26)); } - - + + // Setta la posizione _ctx->text[_ctx->i].SetAlwaysDisplay(); _ctx->text[_ctx->i].SetForcedTime(dwTime * 1000); _ctx->text[_ctx->i].SetNoTab(); - // Aspetta la fine della visualizzazione + // Aspetta la fine della visualizzazione _ctx->text[_ctx->i].SetCustomSkipHandle(_ctx->hDisable); // Registra il testo GLOBALS.LinkGraphicTask(&_ctx->text[_ctx->i]); } - + _ctx->startTime = _vm->GetTime(); while (_ctx->startTime + dwTime * 1000 > _vm->GetTime()) { @@ -2469,155 +2437,155 @@ DECLARE_CUSTOM_FUNCTION(DoCredits)(CORO_PARAM, uint32 nMsg, uint32 dwTime, uint3 BEGIN_CUSTOM_FUNCTION_MAP() - ASSIGN( 1, CustLoadLocation) - ASSIGN( 2, MySleep) - ASSIGN( 3, SetPointer) - ASSIGN( 5, MoveTony) - ASSIGN( 6, FaceToMe) - ASSIGN( 7, BackToMe) - ASSIGN( 8, LeftToMe) - ASSIGN( 9, RightToMe) - ASSIGN( 10, SendTonyMessage) - ASSIGN( 11, ChangeBoxStatus) - ASSIGN( 12, ChangeLocation) - ASSIGN( 13, DisableTony) - ASSIGN( 14, EnableTony) - ASSIGN( 15, WaitForPatternEnd) - ASSIGN( 16, SetLocStartPosition) - ASSIGN( 17, ScrollLocation) - ASSIGN( 18, MoveTonyAndWait) - ASSIGN( 19, ChangeHotspot) - ASSIGN( 20, AddInventory) - ASSIGN( 21, RemoveInventory) - ASSIGN( 22, ChangeInventoryStatus) - ASSIGN( 23, SetTonyPosition) - ASSIGN( 24, SendFullscreenMessage) - ASSIGN( 25, SaveTonyPosition) - ASSIGN( 26, RestoreTonyPosition) - ASSIGN( 27, DisableInput) - ASSIGN( 28, EnableInput) - ASSIGN( 29, StopTony) - - ASSIGN( 30, TonyTakeUp1) - ASSIGN( 31, TonyTakeMid1) - ASSIGN( 32, TonyTakeDown1) - ASSIGN( 33, TonyTakeUp2) - ASSIGN( 34, TonyTakeMid2) - ASSIGN( 35, TonyTakeDown2) - - ASSIGN( 72, TonyPutUp1) - ASSIGN( 73, TonyPutMid1) - ASSIGN( 74, TonyPutDown1) - ASSIGN( 75, TonyPutUp2) - ASSIGN( 76, TonyPutMid2) - ASSIGN( 77, TonyPutDown2) - - ASSIGN( 36, TonyPerTerra) - ASSIGN( 37, TonySiRialza) - ASSIGN( 38, TonyPastorella) - ASSIGN( 39, TonyFischietto) - - ASSIGN( 40, TonyRide) - ASSIGN( 41, TonyFianchi) - ASSIGN( 42, TonyCanta) - ASSIGN( 43, TonySiIndica) - ASSIGN( 44, TonySpaventatoConMani) - ASSIGN( 49, TonySpaventatoSenzaMani) - ASSIGN( 45, TonyConBicchiere) - ASSIGN( 46, TonyConVerme) - ASSIGN( 47, TonyConMartello) - ASSIGN( 48, TonyConCorda) - ASSIGN( 90, TonyConConiglioANIM) - ASSIGN( 91, TonyConRicettaANIM) - ASSIGN( 92, TonyConCarteANIM) - ASSIGN( 93, TonyConPupazzoANIM) - ASSIGN( 94, TonyConPupazzoStart) - ASSIGN( 95, TonyConPupazzoEnd) - ASSIGN( 96, TonyConConiglioStart) - ASSIGN( 97, TonyConConiglioEnd) - ASSIGN( 98, TonyConRicettaStart) - ASSIGN( 99, TonyConRicettaEnd) - ASSIGN(100, TonyConCarteStart) - ASSIGN(101, TonyConCarteEnd) - ASSIGN(102, TonyConTaccuinoStart) - ASSIGN(103, TonyConTaccuinoEnd) - ASSIGN(104, TonyConMegafonoStart) - ASSIGN(105, TonyConMegafonoEnd) - ASSIGN(106, TonyConBarbaStart) - ASSIGN(107, TonyConBarbaEnd) - ASSIGN(108, TonyRidacchia) - ASSIGN(109, TonySchifato) - ASSIGN(110, TonyNaah) - ASSIGN(111, TonyMacbeth) - ASSIGN(112, TonySniffaLeft) - ASSIGN(113, TonySniffaRight) - ASSIGN(114, TonySpaventatoStart) - ASSIGN(115, TonySpaventatoEnd) - ASSIGN(116, TonyConSegretaria) - - ASSIGN( 50, CharSetCode) - ASSIGN( 51, CharSetColor) - ASSIGN( 52, CharSetTalkPattern) - ASSIGN( 53, CharSendMessage) - ASSIGN( 54, CharSetStartEndTalkPattern) - - ASSIGN( 60, MCharSetCode) - ASSIGN( 61, MCharSetColor) - ASSIGN( 62, MCharSetCurrentGroup) - ASSIGN( 63, MCharSetNumTalksInGroup) - ASSIGN( 64, MCharSetNumTexts) - ASSIGN( 65, MCharSendMessage) - ASSIGN( 66, MCharSetPosition) - ASSIGN( 67, MCharSetAlwaysBack) - ASSIGN( 68, MCharResetCode) - - ASSIGN( 70, StartDialog) - ASSIGN( 71, SendDialogMessage) - - ASSIGN( 80, TakeOwnership) - ASSIGN( 81, ReleaseOwnership) - - ASSIGN( 86, PlaySonoriz) - ASSIGN( 87, PlayStacchetto) - ASSIGN( 88, FadeInSonoriz) - ASSIGN( 89, FadeOutSonoriz) - ASSIGN(123, FadeInStacchetto) - ASSIGN(124, FadeOutStacchetto) - ASSIGN(125, MuteSonoriz) - ASSIGN(126, DemuteSonoriz) - ASSIGN(127, MuteStacchetto) - ASSIGN(128, DemuteStacchetto) - ASSIGN( 84, StopSonoriz) - ASSIGN( 85, StopStacchetto) - ASSIGN( 83, PlayItemSfx) - ASSIGN(129, StacchettoFadeStart) - ASSIGN(130, StacchettoFadeEnd) - - ASSIGN(120, TremaSchermo) - ASSIGN(121, AutoSave) - ASSIGN(122, Abort) - ASSIGN(131, NoOcchioDiBue) - ASSIGN(132, SendFullscreenMsgStart) - ASSIGN(133, SendFullscreenMsgEnd) - ASSIGN(134, CustEnableGUI) - ASSIGN(135, CustDisableGUI) - ASSIGN(136, ClearScreen) - ASSIGN(137, PatIrqFreeze) - ASSIGN(138, TonySetPalesati) - ASSIGN(139, OpenInitLoadMenu) - ASSIGN(140, OpenInitOptions) - ASSIGN(141, SyncScrollLocation) - ASSIGN(142, CloseLocation) - ASSIGN(143, SetAlwaysDisplay) - ASSIGN(144, DoCredits) - - ASSIGN( 200, MustSkipIdleStart); - ASSIGN( 201, MustSkipIdleEnd); +ASSIGN(1, CustLoadLocation) +ASSIGN(2, MySleep) +ASSIGN(3, SetPointer) +ASSIGN(5, MoveTony) +ASSIGN(6, FaceToMe) +ASSIGN(7, BackToMe) +ASSIGN(8, LeftToMe) +ASSIGN(9, RightToMe) +ASSIGN(10, SendTonyMessage) +ASSIGN(11, ChangeBoxStatus) +ASSIGN(12, ChangeLocation) +ASSIGN(13, DisableTony) +ASSIGN(14, EnableTony) +ASSIGN(15, WaitForPatternEnd) +ASSIGN(16, SetLocStartPosition) +ASSIGN(17, ScrollLocation) +ASSIGN(18, MoveTonyAndWait) +ASSIGN(19, ChangeHotspot) +ASSIGN(20, AddInventory) +ASSIGN(21, RemoveInventory) +ASSIGN(22, ChangeInventoryStatus) +ASSIGN(23, SetTonyPosition) +ASSIGN(24, SendFullscreenMessage) +ASSIGN(25, SaveTonyPosition) +ASSIGN(26, RestoreTonyPosition) +ASSIGN(27, DisableInput) +ASSIGN(28, EnableInput) +ASSIGN(29, StopTony) + +ASSIGN(30, TonyTakeUp1) +ASSIGN(31, TonyTakeMid1) +ASSIGN(32, TonyTakeDown1) +ASSIGN(33, TonyTakeUp2) +ASSIGN(34, TonyTakeMid2) +ASSIGN(35, TonyTakeDown2) + +ASSIGN(72, TonyPutUp1) +ASSIGN(73, TonyPutMid1) +ASSIGN(74, TonyPutDown1) +ASSIGN(75, TonyPutUp2) +ASSIGN(76, TonyPutMid2) +ASSIGN(77, TonyPutDown2) + +ASSIGN(36, TonyPerTerra) +ASSIGN(37, TonySiRialza) +ASSIGN(38, TonyPastorella) +ASSIGN(39, TonyFischietto) + +ASSIGN(40, TonyRide) +ASSIGN(41, TonyFianchi) +ASSIGN(42, TonyCanta) +ASSIGN(43, TonySiIndica) +ASSIGN(44, TonySpaventatoConMani) +ASSIGN(49, TonySpaventatoSenzaMani) +ASSIGN(45, TonyConBicchiere) +ASSIGN(46, TonyConVerme) +ASSIGN(47, TonyConMartello) +ASSIGN(48, TonyConCorda) +ASSIGN(90, TonyConConiglioANIM) +ASSIGN(91, TonyConRicettaANIM) +ASSIGN(92, TonyConCarteANIM) +ASSIGN(93, TonyConPupazzoANIM) +ASSIGN(94, TonyConPupazzoStart) +ASSIGN(95, TonyConPupazzoEnd) +ASSIGN(96, TonyConConiglioStart) +ASSIGN(97, TonyConConiglioEnd) +ASSIGN(98, TonyConRicettaStart) +ASSIGN(99, TonyConRicettaEnd) +ASSIGN(100, TonyConCarteStart) +ASSIGN(101, TonyConCarteEnd) +ASSIGN(102, TonyConTaccuinoStart) +ASSIGN(103, TonyConTaccuinoEnd) +ASSIGN(104, TonyConMegafonoStart) +ASSIGN(105, TonyConMegafonoEnd) +ASSIGN(106, TonyConBarbaStart) +ASSIGN(107, TonyConBarbaEnd) +ASSIGN(108, TonyRidacchia) +ASSIGN(109, TonySchifato) +ASSIGN(110, TonyNaah) +ASSIGN(111, TonyMacbeth) +ASSIGN(112, TonySniffaLeft) +ASSIGN(113, TonySniffaRight) +ASSIGN(114, TonySpaventatoStart) +ASSIGN(115, TonySpaventatoEnd) +ASSIGN(116, TonyConSegretaria) + +ASSIGN(50, CharSetCode) +ASSIGN(51, CharSetColor) +ASSIGN(52, CharSetTalkPattern) +ASSIGN(53, CharSendMessage) +ASSIGN(54, CharSetStartEndTalkPattern) + +ASSIGN(60, MCharSetCode) +ASSIGN(61, MCharSetColor) +ASSIGN(62, MCharSetCurrentGroup) +ASSIGN(63, MCharSetNumTalksInGroup) +ASSIGN(64, MCharSetNumTexts) +ASSIGN(65, MCharSendMessage) +ASSIGN(66, MCharSetPosition) +ASSIGN(67, MCharSetAlwaysBack) +ASSIGN(68, MCharResetCode) + +ASSIGN(70, StartDialog) +ASSIGN(71, SendDialogMessage) + +ASSIGN(80, TakeOwnership) +ASSIGN(81, ReleaseOwnership) + +ASSIGN(86, PlaySonoriz) +ASSIGN(87, PlayStacchetto) +ASSIGN(88, FadeInSonoriz) +ASSIGN(89, FadeOutSonoriz) +ASSIGN(123, FadeInStacchetto) +ASSIGN(124, FadeOutStacchetto) +ASSIGN(125, MuteSonoriz) +ASSIGN(126, DemuteSonoriz) +ASSIGN(127, MuteStacchetto) +ASSIGN(128, DemuteStacchetto) +ASSIGN(84, StopSonoriz) +ASSIGN(85, StopStacchetto) +ASSIGN(83, PlayItemSfx) +ASSIGN(129, StacchettoFadeStart) +ASSIGN(130, StacchettoFadeEnd) + +ASSIGN(120, TremaSchermo) +ASSIGN(121, AutoSave) +ASSIGN(122, Abort) +ASSIGN(131, NoOcchioDiBue) +ASSIGN(132, SendFullscreenMsgStart) +ASSIGN(133, SendFullscreenMsgEnd) +ASSIGN(134, CustEnableGUI) +ASSIGN(135, CustDisableGUI) +ASSIGN(136, ClearScreen) +ASSIGN(137, PatIrqFreeze) +ASSIGN(138, TonySetPalesati) +ASSIGN(139, OpenInitLoadMenu) +ASSIGN(140, OpenInitOptions) +ASSIGN(141, SyncScrollLocation) +ASSIGN(142, CloseLocation) +ASSIGN(143, SetAlwaysDisplay) +ASSIGN(144, DoCredits) + +ASSIGN(200, MustSkipIdleStart); +ASSIGN(201, MustSkipIdleEnd); END_CUSTOM_FUNCTION_MAP() void SetupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation *loc, RMInventory *inv, RMInput *input) { - GLOBALS.Tony = tony; + GLOBALS.Tony = tony; GLOBALS.Pointer = ptr; GLOBALS.Boxes = box; GLOBALS.Loc = loc; @@ -2643,7 +2611,7 @@ void SetupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation GLOBALS.bAlwaysDisplay = false; int i; - for (i = 0;i < 10; i++) + for (i = 0; i < 10; i++) GLOBALS.mut[i] = CoroScheduler.createEvent(false, false); for (i = 0; i < 200; i++) diff --git a/engines/tony/custom.h b/engines/tony/custom.h index 875710f974..9b53dc32d7 100644 --- a/engines/tony/custom.h +++ b/engines/tony/custom.h @@ -38,32 +38,30 @@ namespace Tony { using namespace MPAL; /* - * Defines + * Defines */ typedef uint32 HWND; -#define INIT_CUSTOM_FUNCTION MapCustomFunctions -#define INIT_CUSTOM_FUNCTION_STRING "MapCustomFunctions" +#define INIT_CUSTOM_FUNCTION MapCustomFunctions +#define INIT_CUSTOM_FUNCTION_STRING "MapCustomFunctions" -#define DECLARE_CUSTOM_FUNCTION(x) void x +#define DECLARE_CUSTOM_FUNCTION(x) void x -#define BEGIN_CUSTOM_FUNCTION_MAP() \ - static void AssignError(int num) { \ - error("Custom function %u has been already assigned!", num); \ - } \ +#define BEGIN_CUSTOM_FUNCTION_MAP() \ + static void AssignError(int num) { \ + error("Custom function %u has been already assigned!", num); \ + } \ void INIT_CUSTOM_FUNCTION(LPCUSTOMFUNCTION *lpMap, Common::String *lpStrMap) \ - { + { - -#define END_CUSTOM_FUNCTION_MAP() \ +#define END_CUSTOM_FUNCTION_MAP() \ } - -#define ASSIGN(num, func) \ - if (lpMap[num] != NULL) \ - AssignError(num); \ - lpMap[num] = func; \ +#define ASSIGN(num, func) \ + if (lpMap[num] != NULL) \ + AssignError(num); \ + lpMap[num] = func; \ lpStrMap[num] = #func; class RMTony; diff --git a/engines/tony/detection.cpp b/engines/tony/detection.cpp index 7a943223a4..944f717f26 100644 --- a/engines/tony/detection.cpp +++ b/engines/tony/detection.cpp @@ -44,8 +44,8 @@ Common::Language TonyEngine::getLanguage() const { return _gameDescription->desc.language; } -bool TonyEngine::getIsDemo() const { - return _gameDescription->desc.flags & ADGF_DEMO; +bool TonyEngine::getIsDemo() const { + return _gameDescription->desc.flags & ADGF_DEMO; } } @@ -79,14 +79,14 @@ public: bool TonyMetaEngine::hasFeature(MetaEngineFeature f) const { return - (f == kSupportsListSaves) || + (f == kSupportsListSaves) || // (f == kSupportsLoadingDuringStartup) || - (f == kSupportsDeleteSave); + (f == kSupportsDeleteSave); } bool Tony::TonyEngine::hasFeature(EngineFeature f) const { return - (f == kSupportsRTL); + (f == kSupportsRTL); } bool TonyMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const { @@ -104,7 +104,7 @@ SaveStateList TonyMetaEngine::listSaves(const char *target) const { Common::String pattern = "tony.0??"; filenames = saveFileMan->listSavefiles(pattern); - sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..) + sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..) SaveStateList saveList; for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) { @@ -126,7 +126,9 @@ SaveStateList TonyMetaEngine::listSaves(const char *target) const { return saveList; } -int TonyMetaEngine::getMaximumSaveSlot() const { return 99; } +int TonyMetaEngine::getMaximumSaveSlot() const { + return 99; +} void TonyMetaEngine::removeSaveState(const char *target, int slot) const { Common::String filename = Tony::TonyEngine::GetSaveStateFileName(slot); @@ -135,7 +137,7 @@ void TonyMetaEngine::removeSaveState(const char *target, int slot) const { } #if PLUGIN_ENABLED_DYNAMIC(TONY) - REGISTER_PLUGIN_DYNAMIC(TONY, PLUGIN_TYPE_ENGINE, TonyMetaEngine); +REGISTER_PLUGIN_DYNAMIC(TONY, PLUGIN_TYPE_ENGINE, TonyMetaEngine); #else - REGISTER_PLUGIN_STATIC(TONY, PLUGIN_TYPE_ENGINE, TonyMetaEngine); +REGISTER_PLUGIN_STATIC(TONY, PLUGIN_TYPE_ENGINE, TonyMetaEngine); #endif diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index c2af10c74a..5396b73796 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -73,8 +73,7 @@ void RMFont::Load(const byte *buf, int nChars, int dimx, int dimy, uint32 palRes if (nChars == 112 && palResID == RES_F_PAL) { // Font parla DumpFontBMP("font_parla.bmp", buf, nChars, dimx, dimy, RMRes(palResID)); - } - else if (nChars == 102 && palResID == RES_F_PAL) { + } else if (nChars == 102 && palResID == RES_F_PAL) { // Font macc DumpFontBMP("font_macc.bmp", buf, nChars, dimx, dimy, RMRes(palResID)); } else if (nChars == 85 && palResID == RES_F_PAL) { @@ -82,7 +81,7 @@ void RMFont::Load(const byte *buf, int nChars, int dimx, int dimy, uint32 palRes DumpFontBMP("font_obj.bmp", buf, nChars, dimx, dimy, RMRes(palResID)); } else if (nChars == 112 && palResID == RES_F_CPAL) { // Font credits - DumpFontBMP("font_credits.bmp", buf, nChars, dimx, dimy, RMRes(palResID)); + DumpFontBMP("font_credits.bmp", buf, nChars, dimx, dimy, RMRes(palResID)); } #endif @@ -96,7 +95,7 @@ void RMFont::Load(const byte *buf, int nChars, int dimx, int dimy, uint32 palRes m_fontDimx = dimx; m_fontDimy = dimy; - nLetters=nChars; + nLetters = nChars; } void RMFont::Load(uint32 resID, int nChars, int dimx, int dimy, uint32 palResID) { @@ -172,7 +171,7 @@ int RMFont::StringLen(char bChar, char bNext) { \****************************************************************************/ RMFontColor::RMFontColor() : RMFont() { - m_r = m_g = m_b = 255; + m_r = m_g = m_b = 255; } RMFontColor::~RMFontColor() { @@ -189,7 +188,7 @@ void RMFontColor::SetBaseColor(byte r1, byte g1, byte b1) { int bstep = b / 14; int i; - byte pal[768*3]; + byte pal[768 * 3]; // Controlla se siamo gia' sul colore giusto if (m_r == r1 && m_g == g1 && m_b == b1) @@ -201,18 +200,18 @@ void RMFontColor::SetBaseColor(byte r1, byte g1, byte b1) { // Costruisce la nuova palette per il font for (i = 1; i < 16; i++) { - pal[i * 3 + 0] = r >> 16; - pal[i * 3 + 1] = g >> 16; - pal[i * 3 + 2] = b >> 16; + pal[i * 3 + 0] = r >> 16; + pal[i * 3 + 1] = g >> 16; + pal[i * 3 + 2] = b >> 16; r -= rstep; g -= gstep; b -= bstep; } - pal[15*3 + 0] += 8; - pal[15*3 + 1] += 8; - pal[15*3 + 2] += 8; + pal[15 * 3 + 0] += 8; + pal[15 * 3 + 1] += 8; + pal[15 * 3 + 2] += 8; // La mette in tutte le lettere for (i = 0; i < nLetters; i++) @@ -229,12 +228,12 @@ void RMFontParla::Init(void) { // bernie: numero di caratteri nel font int nchars = - 112 // base - + 18 // polish - + 66 // russian - + 30 // czech - + 8 // french - + 5; // deutsch + 112 // base + + 18 // polish + + 66 // russian + + 30 // czech + + 8 // french + + 5; // deutsch Load(RES_F_PARL, nchars, 20, 20); @@ -306,8 +305,8 @@ void RMFontParla::Init(void) { cTable[(byte)''] = 107; cTable[(byte)''] = 108; cTable[(byte)''] = 109; - //cTable[''] = 110; integrale - cTable['\''] = 111; + //cTable[''] = 110; integrale + cTable['\''] = 111; // Un po' di lunghezze lTable[' '] = 9; @@ -346,7 +345,7 @@ void RMFontParla::Init(void) { // Polish characters //AaCcEeLlNnOoSsZzZz //ス謎戊3剔囀 - + cTable[(byte)''] = 112; cTable[(byte)''] = 113; cTable[(byte)''] = 114; @@ -487,7 +486,7 @@ void RMFontParla::Init(void) { lTable[(byte)''] = 17; lTable[(byte)''] = 18; lTable[(byte)''] = 16; - lTable[(byte)''] = 18; + lTable[(byte)''] = 18; lTable[(byte)''] = 19; lTable[(byte)''] = 11; lTable[(byte)''] = 16; @@ -640,12 +639,12 @@ void RMFontMacc::Init(void) { // bernie: numero di caratteri nel font int nchars = - 102 // base - + 18 // polish - + 66 // russian - + 30 // czech - + 8 // francais - + 5; // deutsch + 102 // base + + 18 // polish + + 66 // russian + + 30 // czech + + 8 // francais + + 5; // deutsch Load(RES_F_MACC, nchars, 11, 16); @@ -654,41 +653,41 @@ void RMFontMacc::Init(void) { lDefault = 10; hDefault = 17; Common::fill(&l2Table[0][0], &l2Table[0][0] + (256 * 256), '\0'); - + for (i = 0; i < 256; i++) { cTable[i] = -1; lTable[i] = lDefault; } for (i = 0; i < 26; i++) - cTable['A'+i] = i + 0; + cTable['A' + i] = i + 0; for (i = 0; i < 26; i++) - cTable['a'+i] = i + 26; + cTable['a' + i] = i + 26; for (i = 0; i < 10; i++) - cTable['0'+i] = i + 52; + cTable['0' + i] = i + 52; cTable['!'] = 62; - //cTable['!'] = 63; // ! rovescia - cTable['\"'] = 64; - cTable['$'] = 65; - cTable['%'] = 66; - cTable['&'] = 67; - cTable['/'] = 68; - cTable['('] = 69; - cTable[')'] = 70; - cTable['='] = 71; - cTable['?'] = 72; - //cTable['?'] = 73; // ? rovescia - cTable['*'] = 74; - cTable['+'] = 75; - cTable[(byte)''] = 76; - cTable[';'] = 77; - cTable[','] = 78; + //cTable['!'] = 63; // ! rovescia + cTable['\"'] = 64; + cTable['$'] = 65; + cTable['%'] = 66; + cTable['&'] = 67; + cTable['/'] = 68; + cTable['('] = 69; + cTable[')'] = 70; + cTable['='] = 71; + cTable['?'] = 72; + //cTable['?'] = 73; // ? rovescia + cTable['*'] = 74; + cTable['+'] = 75; + cTable[(byte)''] = 76; + cTable[';'] = 77; + cTable[','] = 78; cTable['.'] = 79; - cTable[':'] = 80; - cTable['-'] = 81; + cTable[':'] = 80; + cTable['-'] = 81; cTable['<'] = 82; cTable['>'] = 83; cTable['/'] = 84; @@ -698,22 +697,22 @@ void RMFontMacc::Init(void) { cTable[(byte)''] = 88; cTable[(byte)''] = 89; cTable[(byte)''] = 90; - //cTable[(byte)''] = 91; // e col pallino - cTable[(byte)''] = 92; - cTable[(byte)''] = 93; - //cTable[(byte)''] = 94; // i col pallino - cTable[(byte)''] = 95; - cTable[(byte)''] = 96; - //cTable[(byte)''] = 97; // o col pallino - cTable[(byte)''] = 98; - cTable[(byte)''] = 99; - //cTable[(byte)''] = 100; // u col pallino - cTable[(byte)''] = 101; + //cTable[(byte)''] = 91; // e col pallino + cTable[(byte)''] = 92; + cTable[(byte)''] = 93; + //cTable[(byte)''] = 94; // i col pallino + cTable[(byte)''] = 95; + cTable[(byte)''] = 96; + //cTable[(byte)''] = 97; // o col pallino + cTable[(byte)''] = 98; + cTable[(byte)''] = 99; + //cTable[(byte)''] = 100; // u col pallino + cTable[(byte)''] = 101; // Polish characters //AaCcEeLlNnOoSsZzZz //ス謎戊3剔囀 - + cTable[(byte)''] = 102; cTable[(byte)''] = 103; cTable[(byte)''] = 104; @@ -732,7 +731,7 @@ void RMFontMacc::Init(void) { cTable[(byte)''] = 117; cTable[(byte)''] = 118; cTable[(byte)''] = 119; - + lTable[(byte)''] = 14; lTable[(byte)''] = 16; lTable[(byte)''] = 12; @@ -898,7 +897,7 @@ void RMFontMacc::Init(void) { #endif // FONT_RUSSIAN #ifdef FONT_CZECH - + cTable[(byte)''] = 186; cTable[(byte)''] = 187; cTable[(byte)''] = 188; @@ -1007,21 +1006,21 @@ void RMFontCredits::Init(void) { // bernie: numero di caratteri nel font int nchars = - 112 // base - + 18 // polish - + 66 // russian - + 30 // czech - + 8 // french - + 2; // deutsch + 112 // base + + 18 // polish + + 66 // russian + + 30 // czech + + 8 // french + + 2; // deutsch Load(RES_F_CREDITS, nchars, 27, 28, RES_F_CPAL); // Default - lDefault=10; - hDefault=28; + lDefault = 10; + hDefault = 28; Common::fill(&l2Table[0][0], &l2Table[0][0] + (256 * 256), '\0'); - + for (i = 0; i < 256; i++) { cTable[i] = -1; lTable[i] = lDefault; @@ -1040,7 +1039,7 @@ void RMFontCredits::Init(void) { // cTable[''] = 54; // a ^ // cTable[''] = 55; // a pallini cTable[(byte)''] = 56; - cTable[(byte)''] = 57; + cTable[(byte)''] = 57; // cTable[''] = 58; // e ^ // cTable[''] = 59; // e pallini cTable[(byte)''] = 60; @@ -1057,14 +1056,14 @@ void RMFontCredits::Init(void) { // cTable[''] = 71; // u pallini // cTable[''] = 72; // y pallini cTable[(byte)''] = 73; - cTable[(byte)''] = 74; + cTable[(byte)''] = 74; // cTable[''] = 75; // o barrato // cTable[''] = 76; // ac cTable[(byte)''] = 77; // cTable[''] = 78; // ? rovesciato - cTable['?'] = 79; + cTable['?'] = 79; // cTable[''] = 80; // ! rovesciato - cTable['!'] = 81; + cTable['!'] = 81; // cTable[''] = 82; // 1/2 // cTable[''] = 83; // 1/4 cTable['('] = 84; @@ -1081,13 +1080,13 @@ void RMFontCredits::Init(void) { cTable[','] = 95; cTable['^'] = 96; cTable['='] = 97; - cTable['_'] = 98; - cTable['*'] = 99; - cTable['.'] = 100; + cTable['_'] = 98; + cTable['*'] = 99; + cTable['.'] = 100; for (i = 0; i < 10; i++) - cTable['0'+i] = i+101; - cTable['\''] = 111; + cTable['0' + i] = i + 101; + cTable['\''] = 111; lTable[' '] = 11; lTable[(byte)''] = lTable['A'] = 19; @@ -1168,7 +1167,7 @@ void RMFontCredits::Init(void) { // Polish characters //AaCcEeLlNnOoSsZzZz //ス謎戊3剔囀 - + cTable[(byte)''] = 112; cTable[(byte)''] = 113; cTable[(byte)''] = 114; @@ -1187,7 +1186,7 @@ void RMFontCredits::Init(void) { cTable[(byte)''] = 127; cTable[(byte)''] = 128; cTable[(byte)''] = 129; - + lTable[(byte)''] = 20; lTable[(byte)''] = 12; lTable[(byte)''] = 15; @@ -1310,7 +1309,7 @@ void RMFontCredits::Init(void) { lTable[(byte)''] = 23; lTable[(byte)''] = 23; lTable[(byte)''] = 10; - lTable[(byte)''] = 12; + lTable[(byte)''] = 12; lTable[(byte)''] = 16; lTable[(byte)''] = 12; lTable[(byte)''] = 20; @@ -1462,8 +1461,8 @@ void RMFontCredits::Init(void) { * Metodi di RMFontObj \****************************************************************************/ -#define TOUPPER(a) ((a) >='a'&&(a)<='z'?(a)+'A'-'a':(a)) -#define TOLOWER(a) ((a) >='A'&&(a)<='Z'?(a)+'a'-'A':(a)) +#define TOUPPER(a) ((a) >='a'&&(a)<='z'?(a)+'A'-'a':(a)) +#define TOLOWER(a) ((a) >='A'&&(a)<='Z'?(a)+'a'-'A':(a)) void RMFontObj::SetBothCase(int nChar, int nNext, signed char spiazz) { l2Table[TOUPPER(nChar)][TOUPPER(nNext)] = spiazz; @@ -1478,12 +1477,12 @@ void RMFontObj::Init(void) { //bernie: numero di caratteri nel font (solo maiuscolo) int nchars = - 85 // base - + 9 // polish - + 33 // russian - + 15 // czech - + 0 // francais (no uppercase chars) - + 1; // deutsch + 85 // base + + 9 // polish + + 33 // russian + + 15 // czech + + 0 // francais (no uppercase chars) + + 1; // deutsch Load(RES_F_OBJ, nchars, 25, 30); @@ -1499,8 +1498,8 @@ void RMFontObj::Init(void) { } for (i = 0; i < 26; i++) { - cTable['A' + i] = i+0; - cTable['a' + i] = i+0; + cTable['A' + i] = i + 0; + cTable['a' + i] = i + 0; } for (i = 0; i < 10; i++) @@ -1547,13 +1546,13 @@ void RMFontObj::Init(void) { //cTable[(byte)' '] = 74; e cerchietto cTable[(byte)''] = 75; cTable[(byte)''] = 76; - //cTable[(byte)' '] = 77; i cerchietto + //cTable[(byte)' '] = 77; i cerchietto cTable[(byte)''] = 78; cTable[(byte)''] = cTable[(byte)''] = 79; - //cTable[(byte)' '] = 80; o cerchietto + //cTable[(byte)' '] = 80; o cerchietto cTable[(byte)''] = 81; cTable[(byte)''] = cTable[(byte)''] = 82; - //cTable[' '] = 83; u cerchietto + //cTable[' '] = 83; u cerchietto //cTable[' '] = 84; y dieresi /* Un po' di lunghezze */ @@ -1572,7 +1571,7 @@ void RMFontObj::Init(void) { lTable['8'] = 20; lTable['9'] = 20; - + lTable['a'] = lTable['A'] = lTable[''] = lTable[''] = 17; lTable['b'] = lTable['B'] = 17; lTable['c'] = lTable['C'] = 19; @@ -1601,17 +1600,17 @@ void RMFontObj::Init(void) { lTable[(byte)''] = 17; /* Casi particolari */ - SetBothCase('C','C',2); - SetBothCase('A','T',-2); - SetBothCase('R','S',2); - SetBothCase('H','I',-2); - SetBothCase('T','S',2); - SetBothCase('O','R',2); - SetBothCase('O','L',2); - SetBothCase('O','G',2); - SetBothCase('Z','A',-1); - SetBothCase('R','R',1); - SetBothCase('R','U',3); + SetBothCase('C', 'C', 2); + SetBothCase('A', 'T', -2); + SetBothCase('R', 'S', 2); + SetBothCase('H', 'I', -2); + SetBothCase('T', 'S', 2); + SetBothCase('O', 'R', 2); + SetBothCase('O', 'L', 2); + SetBothCase('O', 'G', 2); + SetBothCase('Z', 'A', -1); + SetBothCase('R', 'R', 1); + SetBothCase('R', 'U', 3); // Polish characters @@ -1622,10 +1621,10 @@ void RMFontObj::Init(void) { cTable[(byte)''] = cTable[(byte)''] = 86; lTable[(byte)''] = lTable[(byte)''] = 22; - + cTable[(byte)''] = cTable[(byte)''] = 87; lTable[(byte)''] = lTable[(byte)''] = 17; - + cTable[(byte)''] = cTable[(byte)''] = 88; lTable[(byte)''] = lTable[(byte)''] = 19; @@ -1654,39 +1653,39 @@ void RMFontObj::Init(void) { cTable[(byte)''] = cTable[(byte)''] = 85; lTable[(byte)''] = lTable[(byte)''] = 20; - cTable[(byte)''] = cTable[(byte)''] =94; - cTable[(byte)''] = cTable[(byte)''] =95; - cTable[(byte)''] = cTable[(byte)''] =96; - cTable[(byte)''] = cTable[(byte)''] =97; - cTable[(byte)''] = cTable[(byte)''] =98; - cTable[(byte)''] = cTable[(byte)''] =99; - cTable[(byte)''] = cTable[(byte)''] =100; - cTable[(byte)''] = cTable[(byte)''] =101; - cTable[(byte)''] = cTable[(byte)''] =102; - cTable[(byte)''] = cTable[(byte)''] =103; - cTable[(byte)''] = cTable[(byte)''] =104; - cTable[(byte)''] = cTable[(byte)''] =105; - cTable[(byte)''] = cTable[(byte)''] =106; - cTable[(byte)''] = cTable[(byte)''] =107; - cTable[(byte)''] = cTable[(byte)''] =108; - cTable[(byte)''] = cTable[(byte)''] =109; - cTable[(byte)''] = cTable[(byte)''] =110; - cTable[(byte)''] = cTable[(byte)''] =111; - cTable[(byte)''] = cTable[(byte)''] =112; - cTable[(byte)''] = cTable[(byte)''] =113; - cTable[(byte)''] = cTable[(byte)''] =114; - cTable[(byte)''] = cTable[(byte)''] =115; - cTable[(byte)''] = cTable[(byte)''] =116; - cTable[(byte)''] = cTable[(byte)''] =117; - cTable[(byte)''] = cTable[(byte)''] =118; - cTable[(byte)''] = cTable[(byte)''] =119; - cTable[(byte)''] = cTable[(byte)''] =120; - cTable[(byte)''] = cTable[(byte)''] =121; - cTable[(byte)''] = cTable[(byte)''] =122; - cTable[(byte)''] = cTable[(byte)''] =123; - cTable[(byte)''] = cTable[(byte)''] =124; - cTable[(byte)''] = cTable[(byte)''] =125; - cTable[(byte)''] = cTable[(byte)''] =126; + cTable[(byte)''] = cTable[(byte)''] = 94; + cTable[(byte)''] = cTable[(byte)''] = 95; + cTable[(byte)''] = cTable[(byte)''] = 96; + cTable[(byte)''] = cTable[(byte)''] = 97; + cTable[(byte)''] = cTable[(byte)''] = 98; + cTable[(byte)''] = cTable[(byte)''] = 99; + cTable[(byte)''] = cTable[(byte)''] = 100; + cTable[(byte)''] = cTable[(byte)''] = 101; + cTable[(byte)''] = cTable[(byte)''] = 102; + cTable[(byte)''] = cTable[(byte)''] = 103; + cTable[(byte)''] = cTable[(byte)''] = 104; + cTable[(byte)''] = cTable[(byte)''] = 105; + cTable[(byte)''] = cTable[(byte)''] = 106; + cTable[(byte)''] = cTable[(byte)''] = 107; + cTable[(byte)''] = cTable[(byte)''] = 108; + cTable[(byte)''] = cTable[(byte)''] = 109; + cTable[(byte)''] = cTable[(byte)''] = 110; + cTable[(byte)''] = cTable[(byte)''] = 111; + cTable[(byte)''] = cTable[(byte)''] = 112; + cTable[(byte)''] = cTable[(byte)''] = 113; + cTable[(byte)''] = cTable[(byte)''] = 114; + cTable[(byte)''] = cTable[(byte)''] = 115; + cTable[(byte)''] = cTable[(byte)''] = 116; + cTable[(byte)''] = cTable[(byte)''] = 117; + cTable[(byte)''] = cTable[(byte)''] = 118; + cTable[(byte)''] = cTable[(byte)''] = 119; + cTable[(byte)''] = cTable[(byte)''] = 120; + cTable[(byte)''] = cTable[(byte)''] = 121; + cTable[(byte)''] = cTable[(byte)''] = 122; + cTable[(byte)''] = cTable[(byte)''] = 123; + cTable[(byte)''] = cTable[(byte)''] = 124; + cTable[(byte)''] = cTable[(byte)''] = 125; + cTable[(byte)''] = cTable[(byte)''] = 126; lTable[(byte)''] = lTable[(byte)''] = 18; @@ -1717,7 +1716,7 @@ void RMFontObj::Init(void) { lTable[(byte)''] = lTable[(byte)''] = 19; lTable[(byte)''] = lTable[(byte)''] = 22; lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 19; + lTable[(byte)''] = lTable[(byte)''] = 19; lTable[(byte)''] = lTable[(byte)''] = 19; lTable[(byte)''] = lTable[(byte)''] = 15; lTable[(byte)''] = lTable[(byte)''] = 18; @@ -1726,7 +1725,7 @@ void RMFontObj::Init(void) { #endif // FONT_RUSSIAN #ifdef FONT_CZECH - // rep. ceca characters + // rep. ceca characters cTable[(byte)''] = cTable[(byte)''] = 127; cTable[(byte)''] = cTable[(byte)''] = 128; @@ -1744,21 +1743,21 @@ void RMFontObj::Init(void) { cTable[(byte)''] = cTable[(byte)''] = 140; cTable[(byte)''] = cTable[(byte)''] = 141; - lTable[(byte)''] = lTable[(byte)''] =17; - lTable[(byte)''] = lTable[(byte)''] =15; - lTable[(byte)''] = lTable[(byte)''] =22; - lTable[(byte)''] = lTable[(byte)''] =18; - lTable[(byte)''] = lTable[(byte)''] =21; - lTable[(byte)''] = lTable[(byte)''] =16; - lTable[(byte)''] = lTable[(byte)''] =18; - lTable[(byte)''] = lTable[(byte)''] =19; - lTable[(byte)''] = lTable[(byte)''] =17; - lTable[(byte)''] = lTable[(byte)''] =23; - lTable[(byte)''] = lTable[(byte)''] =24; - lTable[(byte)''] = lTable[(byte)''] =17; - lTable[(byte)''] = lTable[(byte)''] =22; - lTable[(byte)''] = lTable[(byte)''] =16; - lTable[(byte)''] = lTable[(byte)''] =16; + lTable[(byte)''] = lTable[(byte)''] = 17; + lTable[(byte)''] = lTable[(byte)''] = 15; + lTable[(byte)''] = lTable[(byte)''] = 22; + lTable[(byte)''] = lTable[(byte)''] = 18; + lTable[(byte)''] = lTable[(byte)''] = 21; + lTable[(byte)''] = lTable[(byte)''] = 16; + lTable[(byte)''] = lTable[(byte)''] = 18; + lTable[(byte)''] = lTable[(byte)''] = 19; + lTable[(byte)''] = lTable[(byte)''] = 17; + lTable[(byte)''] = lTable[(byte)''] = 23; + lTable[(byte)''] = lTable[(byte)''] = 24; + lTable[(byte)''] = lTable[(byte)''] = 17; + lTable[(byte)''] = lTable[(byte)''] = 22; + lTable[(byte)''] = lTable[(byte)''] = 16; + lTable[(byte)''] = lTable[(byte)''] = 16; #endif // FONT_CZECH @@ -1817,7 +1816,7 @@ RMText::RMText() { } RMText::~RMText() { - + } void RMText::Unload() { @@ -1835,19 +1834,23 @@ void RMText::SetMaxLineLength(int max) { } void RMText::RemoveThis(CORO_PARAM, bool &result) { - // Qui possiamo fare i controlli sul numero di frame, sul tempo trascorso - // etc. +// Qui possiamo fare i controlli sul numero di frame, sul tempo trascorso +// etc. result = true; } void RMText::WriteText(const RMString &text, int nFont, int *time) { - // Inizializza i font (una volta sola) + // Inizializza i font (una volta sola) if (m_fonts[0] == NULL) { - m_fonts[0] = new RMFontParla; m_fonts[0]->Init(); - m_fonts[1] = new RMFontObj; m_fonts[1]->Init(); - m_fonts[2] = new RMFontMacc; m_fonts[2]->Init(); - m_fonts[3] = new RMFontCredits; m_fonts[3]->Init(); + m_fonts[0] = new RMFontParla; + m_fonts[0]->Init(); + m_fonts[1] = new RMFontObj; + m_fonts[1]->Init(); + m_fonts[2] = new RMFontMacc; + m_fonts[2]->Init(); + m_fonts[3] = new RMFontCredits; + m_fonts[3]->Init(); } WriteText(text, m_fonts[nFont], time); @@ -1870,13 +1873,13 @@ void RMText::WriteText(const RMString &text, RMFontColor *font, int *time) { // Si autodistrugge il buffer prima di iniziare Destroy(); - // Se la stringa vuota, non fare nulla + // Se la stringa vuota, non fare nulla if (text == NULL || text[0] == '\0') return; - + // Divide la frase in linee. In questo ciclo, X contiene la lunghezza massima raggiunta da una linea // e I il numero delle linee - string=p = text; + string = p = text; i = j = x = 0; while (*p != '\0') { j += font->StringLen(*p); @@ -1912,7 +1915,7 @@ void RMText::WriteText(const RMString &text, RMFontColor *font, int *time) { } if (j > x) x = j; - + i++; numlines = i; @@ -1945,7 +1948,7 @@ void RMText::WriteText(const RMString &text, RMFontColor *font, int *time) { case HLEFTPAR: if (i == numlines) - x=0; + x = 0; else x = 25; break; @@ -1988,8 +1991,8 @@ void RMText::ClipOnScreen(RMGfxPrimitive *prim) { // Cerca di non farlo uscire dallo schermo if (prim->Dst().x1 < 5) prim->Dst().x1 = 5; if (prim->Dst().y1 < 5) prim->Dst().y1 = 5; - if (prim->Dst().x1+m_dimx > 635) prim->Dst().x1 = 635 - m_dimx; - if (prim->Dst().y1+m_dimy > 475) prim->Dst().y1 = 475 - m_dimy; + if (prim->Dst().x1 + m_dimx > 635) prim->Dst().x1 = 635 - m_dimx; + if (prim->Dst().y1 + m_dimy > 475) prim->Dst().y1 = 475 - m_dimy; } void RMText::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { @@ -2027,7 +2030,7 @@ void RMText::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { RMTextDialog::RMTextDialog() : RMText() { m_startTime = 0; - dst = RMPoint(0,0); + dst = RMPoint(0, 0); m_bSkipStatus = true; m_bShowed = true; @@ -2056,14 +2059,14 @@ void RMTextDialog::Hide(CORO_PARAM) { } void RMTextDialog::WriteText(const RMString &text, int font, int *time) { - RMText::WriteText(text,font,&m_time); + RMText::WriteText(text, font, &m_time); if (time != NULL) *time = m_time; } void RMTextDialog::WriteText(const RMString &text, RMFontColor *font, int *time) { - RMText::WriteText(text,font,&m_time); + RMText::WriteText(text, font, &m_time); if (time != NULL) *time = m_time; @@ -2087,7 +2090,7 @@ void RMTextDialog::SetNoTab(void) { } void RMTextDialog::SetForcedTime(uint32 dwTime) { - m_time = dwTime; + m_time = dwTime; } void RMTextDialog::SetAlwaysDisplay(void) { @@ -2096,7 +2099,7 @@ void RMTextDialog::SetAlwaysDisplay(void) { void RMTextDialog::RemoveThis(CORO_PARAM, bool &result) { CORO_BEGIN_CONTEXT; - bool expired; + bool expired; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -2168,7 +2171,7 @@ void RMTextDialog::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *p if (m_startTime == 0) m_startTime = _vm->GetTime(); - + if (m_bShowed) { if (GLOBALS.bCfgSottotitoli || m_bAlwaysDisplay) { prim->Dst().TopLeft() = dst; @@ -2213,7 +2216,7 @@ RMTextDialogScrolling::~RMTextDialogScrolling() { void RMTextDialogScrolling::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CONTEXT; - RMPoint curDst; + RMPoint curDst; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -2250,8 +2253,8 @@ RMTextItemName::~RMTextItemName() { void RMTextItemName::DoFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation &loc, RMPointer &ptr, RMInventory &inv) { CORO_BEGIN_CONTEXT; - RMItem *lastItem; - uint32 hThread; + RMItem *lastItem; + uint32 hThread; CORO_END_CONTEXT(_ctx); RMString itemName; @@ -2263,7 +2266,7 @@ void RMTextItemName::DoFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation & // Adds to the list if there is need if (!m_nInList) bigBuf.AddPrim(new RMGfxPrimitive(this)); - + // Update the scrolling co-ordinates m_curscroll = loc.ScrollPosition(); @@ -2272,7 +2275,7 @@ void RMTextItemName::DoFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation & m_item = inv.WhichItemIsIn(m_mpos); else m_item = loc.WhichItemIsIn(m_mpos); - + itemName = ""; // If there an item, get it's name @@ -2287,7 +2290,7 @@ void RMTextItemName::DoFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation & if (m_item == NULL) ptr.SetSpecialPointer(RMPointer::PTR_NONE); else { - _ctx->hThread = mpalQueryDoAction(20, m_item->MpalCode(), 0); + _ctx->hThread = mpalQueryDoAction(20, m_item->MpalCode(), 0); if (_ctx->hThread == CORO_INVALID_PID_VALUE) ptr.SetSpecialPointer(RMPointer::PTR_NONE); else @@ -2310,30 +2313,30 @@ void RMTextItemName::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive return; // Setta come coordinate destinazione quelle del mouse - prim->Dst().TopLeft() = m_mpos-RMPoint(0, 30); + prim->Dst().TopLeft() = m_mpos - RMPoint(0, 30); CORO_INVOKE_2(RMText::Draw, bigBuf, prim); CORO_END_CODE; } -RMPoint RMTextItemName::GetHotspot() { - if (m_item == NULL) - return m_mpos + m_curscroll; - else - return m_item->Hotspot(); +RMPoint RMTextItemName::GetHotspot() { + if (m_item == NULL) + return m_mpos + m_curscroll; + else + return m_item->Hotspot(); } -RMItem *RMTextItemName::GetSelectedItem() { - return m_item; +RMItem *RMTextItemName::GetSelectedItem() { + return m_item; } -bool RMTextItemName::IsItemSelected() { - return m_item != NULL; +bool RMTextItemName::IsItemSelected() { + return m_item != NULL; } -bool RMTextItemName::IsNormalItemSelected() { - return m_item != NULL && m_itemName.Length() > 0; +bool RMTextItemName::IsNormalItemSelected() { + return m_item != NULL && m_itemName.Length() > 0; } @@ -2345,13 +2348,13 @@ RMDialogChoice::RMDialogChoice() { RMResRaw dlg1(RES_I_DLGTEXT); RMResRaw dlg2(RES_I_DLGTEXTLINE); RMRes dlgpal(RES_I_DLGTEXTPAL); - + DlgText.Init(dlg1, dlg1.Width(), dlg1.Height()); DlgTextLine.Init(dlg2, dlg2.Width(), dlg2.Height()); DlgText.LoadPaletteWA(dlgpal); DlgTextLine.LoadPaletteWA(dlgpal); - + hUnreg = CoroScheduler.createEvent(false, false); bRemoveFromOT = false; } @@ -2368,8 +2371,7 @@ void RMDialogChoice::Unregister(void) { bRemoveFromOT = false; } -void RMDialogChoice::Init(void) -{ +void RMDialogChoice::Init(void) { m_numChoices = 0; m_drawedStrings = NULL; m_ptDrawStrings = NULL; @@ -2399,7 +2401,7 @@ void RMDialogChoice::SetNumChoices(int num) { m_numChoices = num; m_curAdded = 0; - + // Alloca lo spazio per le stringhe disegnate m_drawedStrings = new RMText[num]; m_ptDrawStrings = new RMPoint[num]; @@ -2416,43 +2418,43 @@ void RMDialogChoice::SetNumChoices(int num) { void RMDialogChoice::AddChoice(const RMString &string) { // Si disegna la stringa assert(m_curAdded < m_numChoices); - m_drawedStrings[m_curAdded++].WriteText(string, 0); + m_drawedStrings[m_curAdded++].WriteText(string, 0); } void RMDialogChoice::Prepare(CORO_PARAM) { CORO_BEGIN_CONTEXT; - int i; - RMPoint ptPos; + int i; + RMPoint ptPos; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - AddPrim(new RMGfxPrimitive(&DlgText,RMPoint(0,0))); - AddPrim(new RMGfxPrimitive(&DlgTextLine,RMPoint(0,155))); - AddPrim(new RMGfxPrimitive(&DlgTextLine,RMPoint(0,155+83))); - AddPrim(new RMGfxPrimitive(&DlgTextLine,RMPoint(0,155+83+83))); - AddPrim(new RMGfxPrimitive(&DlgTextLine,RMPoint(0,155+83+83+83))); + AddPrim(new RMGfxPrimitive(&DlgText, RMPoint(0, 0))); + AddPrim(new RMGfxPrimitive(&DlgTextLine, RMPoint(0, 155))); + AddPrim(new RMGfxPrimitive(&DlgTextLine, RMPoint(0, 155 + 83))); + AddPrim(new RMGfxPrimitive(&DlgTextLine, RMPoint(0, 155 + 83 + 83))); + AddPrim(new RMGfxPrimitive(&DlgTextLine, RMPoint(0, 155 + 83 + 83 + 83))); - _ctx->ptPos.Set(20,90); + _ctx->ptPos.Set(20, 90); for (_ctx->i = 0; _ctx->i < m_numChoices; _ctx->i++) { AddPrim(new RMGfxPrimitive(&m_drawedStrings[_ctx->i], _ctx->ptPos)); m_ptDrawStrings[_ctx->i] = _ctx->ptPos; - _ctx->ptPos.Offset(0,m_drawedStrings[_ctx->i].Dimy() + 15); + _ctx->ptPos.Offset(0, m_drawedStrings[_ctx->i].Dimy() + 15); } CORO_INVOKE_0(DrawOT); ClearOT(); - m_ptDrawPos.Set(0,480-_ctx->ptPos.y); + m_ptDrawPos.Set(0, 480 - _ctx->ptPos.y); CORO_END_CODE; } void RMDialogChoice::SetSelected(CORO_PARAM, int pos) { CORO_BEGIN_CONTEXT; - RMGfxBox box; - RMRect rc; + RMGfxBox box; + RMRect rc; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -2464,7 +2466,7 @@ void RMDialogChoice::SetSelected(CORO_PARAM, int pos) { if (m_curSelection != -1) { _ctx->box.SetColor(0xCC, 0xCC, 0xFF); - _ctx->rc.TopLeft()=RMPoint(18, m_ptDrawStrings[m_curSelection].y); + _ctx->rc.TopLeft() = RMPoint(18, m_ptDrawStrings[m_curSelection].y); _ctx->rc.BottomRight() = _ctx->rc.TopLeft() + RMPoint(597, m_drawedStrings[m_curSelection].Dimy()); AddPrim(new RMGfxPrimitive(&_ctx->box, _ctx->rc)); @@ -2475,8 +2477,8 @@ void RMDialogChoice::SetSelected(CORO_PARAM, int pos) { if (pos != -1) { _ctx->box.SetColor(100, 100, 100); - _ctx->rc.TopLeft()=RMPoint(18, m_ptDrawStrings[pos].y); - _ctx->rc.BottomRight() = _ctx->rc.TopLeft()+RMPoint(597, m_drawedStrings[pos].Dimy()); + _ctx->rc.TopLeft() = RMPoint(18, m_ptDrawStrings[pos].y); + _ctx->rc.BottomRight() = _ctx->rc.TopLeft() + RMPoint(597, m_drawedStrings[pos].Dimy()); AddPrim(new RMGfxPrimitive(&_ctx->box, _ctx->rc)); AddPrim(new RMGfxPrimitive(&m_drawedStrings[pos], m_ptDrawStrings[pos])); } @@ -2491,10 +2493,10 @@ void RMDialogChoice::SetSelected(CORO_PARAM, int pos) { void RMDialogChoice::Show(CORO_PARAM, RMGfxTargetBuffer *bigBuf) { CORO_BEGIN_CONTEXT; - RMPoint destpt; - int deltay; - int starttime; - int elaps; + RMPoint destpt; + int deltay; + int starttime; + int elaps; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -2513,8 +2515,8 @@ void RMDialogChoice::Show(CORO_PARAM, RMGfxTargetBuffer *bigBuf) { _ctx->destpt = m_ptDrawPos; m_ptDrawPos.Set(0, 480); - if (!m_nInList && bigBuf != NULL) - bigBuf->AddPrim(new RMGfxPrimitive(this)); + if (!m_nInList && bigBuf != NULL) + bigBuf->AddPrim(new RMGfxPrimitive(this)); m_bShow = true; _ctx->elaps = 0; @@ -2550,9 +2552,9 @@ void RMDialogChoice::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive void RMDialogChoice::Hide(CORO_PARAM) { CORO_BEGIN_CONTEXT; - int deltay; - int starttime; - int elaps; + int deltay; + int starttime; + int elaps; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -2565,7 +2567,7 @@ void RMDialogChoice::Hide(CORO_PARAM) { while (_ctx->elaps < 700) { CORO_INVOKE_0(MainWaitFrame); MainFreeze(); - _ctx->elaps = _vm->GetTime()-_ctx->starttime; + _ctx->elaps = _vm->GetTime() - _ctx->starttime; m_ptDrawPos.y = 480 - ((_ctx->deltay * 100) / 700 * (700 - _ctx->elaps)) / 100; MainUnfreeze(); } @@ -2585,14 +2587,14 @@ void RMDialogChoice::RemoveThis(CORO_PARAM, bool &result) { void RMDialogChoice::DoFrame(CORO_PARAM, RMPoint ptMousePos) { CORO_BEGIN_CONTEXT; - int i; + int i; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - if (ptMousePos.y > m_ptDrawPos.y) { + if (ptMousePos.y > m_ptDrawPos.y) { for (_ctx->i = 0; _ctx->i < m_numChoices; _ctx->i++) { - if ((ptMousePos.y >= m_ptDrawPos.y+m_ptDrawStrings[_ctx->i].y) && (ptMousePos.y < m_ptDrawPos.y+m_ptDrawStrings[_ctx->i].y+m_drawedStrings[_ctx->i].Dimy())) { + if ((ptMousePos.y >= m_ptDrawPos.y + m_ptDrawStrings[_ctx->i].y) && (ptMousePos.y < m_ptDrawPos.y + m_ptDrawStrings[_ctx->i].y + m_drawedStrings[_ctx->i].Dimy())) { CORO_INVOKE_1(SetSelected, _ctx->i); break; } diff --git a/engines/tony/font.h b/engines/tony/font.h index 9715e95043..3ada4d76c0 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -47,118 +47,126 @@ class RMPointer; */ class RMFont : public RMGfxTaskSetPrior { protected: - int nLetters; - RMGfxSourceBuffer8RLEByte *m_letter; + int nLetters; + RMGfxSourceBuffer8RLEByte *m_letter; public: - int m_fontDimx,m_fontDimy; + int m_fontDimx, m_fontDimy; private: - int m_dimx,m_dimy; + int m_dimx, m_dimy; - class RMFontPrimitive : public RMGfxPrimitive { - public: - RMFontPrimitive() : RMGfxPrimitive() {} - RMFontPrimitive(RMGfxTask *task) : RMGfxPrimitive(task) {} + class RMFontPrimitive : public RMGfxPrimitive { + public: + RMFontPrimitive() : RMGfxPrimitive() {} + RMFontPrimitive(RMGfxTask *task) : RMGfxPrimitive(task) {} virtual ~RMFontPrimitive() { } - virtual RMGfxPrimitive *Duplicate() { return new RMFontPrimitive(*this); } + virtual RMGfxPrimitive *Duplicate() { + return new RMFontPrimitive(*this); + } - int m_nChar; - }; + int m_nChar; + }; protected: - // Caricamento del font - void Load(uint32 resID, int nChars, int dimx, int dimy, uint32 palResID = RES_F_PAL); - void Load(const byte *buf, int nChars, int dimx, int dimy, uint32 palResID = RES_F_PAL); + // Caricamento del font + void Load(uint32 resID, int nChars, int dimx, int dimy, uint32 palResID = RES_F_PAL); + void Load(const byte *buf, int nChars, int dimx, int dimy, uint32 palResID = RES_F_PAL); - // Scaricamente del font (anche da distruttore) - void Unload(void); + // Scaricamente del font (anche da distruttore) + void Unload(void); protected: - // Conversione (da overloadare) - virtual int ConvertToLetter(int nChar) = 0; + // Conversione (da overloadare) + virtual int ConvertToLetter(int nChar) = 0; - // Lunghezza dei caratteri (da overloadare) - virtual int LetterLength(int nChar, int nNext=0) = 0; + // Lunghezza dei caratteri (da overloadare) + virtual int LetterLength(int nChar, int nNext = 0) = 0; public: - virtual int LetterHeight(void) = 0; + virtual int LetterHeight(void) = 0; public: - RMFont(); - virtual ~RMFont(); + RMFont(); + virtual ~RMFont(); - // Inizializzazione e chiusura - virtual void Init(void) = 0; - virtual void Close(void); + // Inizializzazione e chiusura + virtual void Init(void) = 0; + virtual void Close(void); - // Funzione del task da overloadare - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBug, RMGfxPrimitive *prim); + // Funzione del task da overloadare + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBug, RMGfxPrimitive *prim); - // Crea una primitiva per una lettera - RMGfxPrimitive *MakeLetterPrimitive(byte bChar, int& nLength); + // Crea una primitiva per una lettera + RMGfxPrimitive *MakeLetterPrimitive(byte bChar, int &nLength); - // Lunghezza in pixel di una stringa con il font corrente - int StringLen(const RMString &text); - int StringLen(char bChar, char bNext = 0); + // Lunghezza in pixel di una stringa con il font corrente + int StringLen(const RMString &text); + int StringLen(char bChar, char bNext = 0); }; class RMFontColor : public virtual RMFont { private: - byte m_r,m_g,m_b; + byte m_r, m_g, m_b; public: - RMFontColor(); + RMFontColor(); virtual ~RMFontColor(); - virtual void SetBaseColor(byte r, byte g, byte b); + virtual void SetBaseColor(byte r, byte g, byte b); }; class RMFontWithTables : public virtual RMFont { protected: - int cTable[256]; - int lTable[256]; - int lDefault; - int hDefault; - signed char l2Table[256][256]; + int cTable[256]; + int lTable[256]; + int lDefault; + int hDefault; + signed char l2Table[256][256]; protected: - // Overload dei metodi - int ConvertToLetter(int nChar) { return cTable[nChar]; } - int LetterLength(int nChar, int nNext=0) { return (nChar!=-1 ? lTable[nChar]+l2Table[nChar][nNext] : lDefault); } - + // Overload dei metodi + int ConvertToLetter(int nChar) { + return cTable[nChar]; + } + int LetterLength(int nChar, int nNext = 0) { + return (nChar != -1 ? lTable[nChar] + l2Table[nChar][nNext] : lDefault); + } + public: - int LetterHeight() { return hDefault; } + int LetterHeight() { + return hDefault; + } virtual ~RMFontWithTables() {} }; class RMFontParla : public RMFontColor, public RMFontWithTables { public: - void Init(void); + void Init(void); virtual ~RMFontParla() {} }; class RMFontObj : public RMFontColor, public RMFontWithTables { private: - void SetBothCase(int nChar, int nNext, signed char spiazz); + void SetBothCase(int nChar, int nNext, signed char spiazz); public: - void Init(void); + void Init(void); virtual ~RMFontObj() {} }; class RMFontMacc : public RMFontColor, public RMFontWithTables { public: - void Init(void); + void Init(void); virtual ~RMFontMacc() {} }; class RMFontCredits : public RMFontColor, public RMFontWithTables { public: - void Init(void); + void Init(void); virtual ~RMFontCredits() {} - virtual void SetBaseColor(byte r, byte g, byte b) {} + virtual void SetBaseColor(byte r, byte g, byte b) {} }; /** @@ -166,131 +174,140 @@ public: */ class RMText : public RMGfxWoodyBuffer { private: - static RMFontColor *m_fonts[4]; - static RMGfxClearTask m_clear; - int maxLineLength; + static RMFontColor *m_fonts[4]; + static RMGfxClearTask m_clear; + int maxLineLength; public: - enum HORALIGN { - HLEFT, - HLEFTPAR, - HCENTER, - HRIGHT - }; - - enum VERALIGN { - VTOP, - VCENTER, - VBOTTOM - }; + enum HORALIGN { + HLEFT, + HLEFTPAR, + HCENTER, + HRIGHT + }; + + enum VERALIGN { + VTOP, + VCENTER, + VBOTTOM + }; private: HORALIGN aHorType; - VERALIGN aVerType; - byte m_r,m_g,m_b; + VERALIGN aVerType; + byte m_r, m_g, m_b; protected: - virtual void ClipOnScreen(RMGfxPrimitive* prim); + virtual void ClipOnScreen(RMGfxPrimitive *prim); public: - RMText(); - virtual ~RMText(); + RMText(); + virtual ~RMText(); static void InitStatics(); static void Unload(); - // Setta il tipo di allineamento - void SetAlignType(HORALIGN aHor, VERALIGN aVer) { aHorType=aHor; aVerType=aVer; } - - // Setta la lunghezza massima di una linea in pixel (utilizzato per formattare il testo) - void SetMaxLineLength(int max); + // Setta il tipo di allineamento + void SetAlignType(HORALIGN aHor, VERALIGN aVer) { + aHorType = aHor; + aVerType = aVer; + } + + // Setta la lunghezza massima di una linea in pixel (utilizzato per formattare il testo) + void SetMaxLineLength(int max); - // Scrive un testo - void WriteText(const RMString &text, int font, int *time = NULL); - void WriteText(const RMString &text, RMFontColor *font, int *time = NULL); + // Scrive un testo + void WriteText(const RMString &text, int font, int *time = NULL); + void WriteText(const RMString &text, RMFontColor *font, int *time = NULL); - // Overloading della funzione ereditata da RMGfxTask per decidere - // quando eliminare un oggetto dalla OTLIST - virtual void RemoveThis(CORO_PARAM, bool &result); + // Overloading della funzione ereditata da RMGfxTask per decidere + // quando eliminare un oggetto dalla OTLIST + virtual void RemoveThis(CORO_PARAM, bool &result); - // Overloading del Draw per centrare la scritta, se necessario - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + // Overloading del Draw per centrare la scritta, se necessario + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - // Setta il colore di base - void SetColor(byte r, byte g, byte b) { m_r=r; m_g=g; m_b=b; } + // Setta il colore di base + void SetColor(byte r, byte g, byte b) { + m_r = r; + m_g = g; + m_b = b; + } }; /** - * Gestisce il testo di un dialogo + * Gestisce il testo di un dialogo */ class RMTextDialog : public RMText { - protected: - int m_startTime; - int m_time; - bool m_bSkipStatus; - RMPoint dst; - uint32 hEndDisplay; - bool m_bShowed; +protected: + int m_startTime; + int m_time; + bool m_bSkipStatus; + RMPoint dst; + uint32 hEndDisplay; + bool m_bShowed; bool m_bForceTime; - bool m_bForceNoTime; + bool m_bForceNoTime; uint32 hCustomSkip; - uint32 hCustomSkip2; - RMInput *m_input; + uint32 hCustomSkip2; + RMInput *m_input; bool m_bAlwaysDisplay; bool m_bNoTab; - public: - RMTextDialog(); - virtual ~RMTextDialog(); - - // Scrive un testo - void WriteText(const RMString &text, int font, int *time = NULL); - void WriteText(const RMString &text, RMFontColor *font, int *time = NULL); - - // Overloading della funzione ereditata da RMGfxTask per decidere - // quando eliminare un oggetto dalla OTLIST - virtual void RemoveThis(CORO_PARAM, bool &result); - - // Overloading della funzione di deregistrazione, utilizzata per capire - // quando ci leviamo di torno - virtual void Unregister(void); - - // Overloading del Draw per centrare la scritta, se necessario - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - - // Setta la posizione - void SetPosition(const RMPoint &pt) { dst = pt; } - - // Aspetta che venga finita la visualizzazione - void WaitForEndDisplay(CORO_PARAM); - void SetCustomSkipHandle(uint32 hCustomSkip); - void SetCustomSkipHandle2(uint32 hCustomSkip); - void SetSkipStatus(bool bEnabled); +public: + RMTextDialog(); + virtual ~RMTextDialog(); + + // Scrive un testo + void WriteText(const RMString &text, int font, int *time = NULL); + void WriteText(const RMString &text, RMFontColor *font, int *time = NULL); + + // Overloading della funzione ereditata da RMGfxTask per decidere + // quando eliminare un oggetto dalla OTLIST + virtual void RemoveThis(CORO_PARAM, bool &result); + + // Overloading della funzione di deregistrazione, utilizzata per capire + // quando ci leviamo di torno + virtual void Unregister(void); + + // Overloading del Draw per centrare la scritta, se necessario + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + + // Setta la posizione + void SetPosition(const RMPoint &pt) { + dst = pt; + } + + // Aspetta che venga finita la visualizzazione + void WaitForEndDisplay(CORO_PARAM); + void SetCustomSkipHandle(uint32 hCustomSkip); + void SetCustomSkipHandle2(uint32 hCustomSkip); + void SetSkipStatus(bool bEnabled); void SetForcedTime(uint32 dwTime); void SetNoTab(void); void ForceTime(void); void ForceNoTime(void); void SetAlwaysDisplay(void); - - // Setta il dispositivo di input, per permettere skip da mouse - void SetInput(RMInput* input); - void Show(void); - void Hide(CORO_PARAM); + // Setta il dispositivo di input, per permettere skip da mouse + void SetInput(RMInput *input); + + void Show(void); + void Hide(CORO_PARAM); }; class RMTextDialogScrolling : public RMTextDialog { protected: - RMLocation *curLoc; - RMPoint startScroll; + RMLocation *curLoc; + RMPoint startScroll; - virtual void ClipOnScreen(RMGfxPrimitive* prim); + virtual void ClipOnScreen(RMGfxPrimitive *prim); public: - RMTextDialogScrolling(); - RMTextDialogScrolling(RMLocation* loc); + RMTextDialogScrolling(); + RMTextDialogScrolling(RMLocation *loc); virtual ~RMTextDialogScrolling(); - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); }; @@ -302,26 +319,30 @@ public: class RMTextItemName : protected RMText { protected: - RMPoint m_mpos; - RMPoint m_curscroll; - RMItem *m_item; - RMString m_itemName; + RMPoint m_mpos; + RMPoint m_curscroll; + RMItem *m_item; + RMString m_itemName; public: - RMTextItemName(); + RMTextItemName(); virtual ~RMTextItemName(); - - void SetMouseCoord(const RMPoint &m) { m_mpos = m; } - void DoFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation &loc, RMPointer &ptr, RMInventory &inv); - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + void SetMouseCoord(const RMPoint &m) { + m_mpos = m; + } + + void DoFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation &loc, RMPointer &ptr, RMInventory &inv); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - RMPoint GetHotspot(); - RMItem *GetSelectedItem(); - bool IsItemSelected(); - bool IsNormalItemSelected(); + RMPoint GetHotspot(); + RMItem *GetSelectedItem(); + bool IsItemSelected(); + bool IsNormalItemSelected(); - virtual void RemoveThis(CORO_PARAM, bool &result) { result = true; } + virtual void RemoveThis(CORO_PARAM, bool &result) { + result = true; + } }; @@ -330,54 +351,54 @@ public: */ class RMDialogChoice : public RMGfxWoodyBuffer { private: - int m_curSelection; - int m_numChoices; - RMText* m_drawedStrings; - RMPoint *m_ptDrawStrings; - int m_curAdded; - bool m_bShow; - RMGfxSourceBuffer8 DlgText; - RMGfxSourceBuffer8 DlgTextLine; - RMPoint m_ptDrawPos; - uint32 hUnreg; - bool bRemoveFromOT; + int m_curSelection; + int m_numChoices; + RMText *m_drawedStrings; + RMPoint *m_ptDrawStrings; + int m_curAdded; + bool m_bShow; + RMGfxSourceBuffer8 DlgText; + RMGfxSourceBuffer8 DlgTextLine; + RMPoint m_ptDrawPos; + uint32 hUnreg; + bool bRemoveFromOT; protected: - void Prepare(CORO_PARAM); - void SetSelected(CORO_PARAM, int pos); - + void Prepare(CORO_PARAM); + void SetSelected(CORO_PARAM, int pos); + public: - virtual void RemoveThis(CORO_PARAM, bool &result); - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer& bigBuf, RMGfxPrimitive* prim); - void Unregister(void); + virtual void RemoveThis(CORO_PARAM, bool &result); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + void Unregister(void); public: - // Inizializzazione - RMDialogChoice(); - virtual ~RMDialogChoice(); - - // Inizializzazione e chiusura - void Init(void); - void Close(void); - - // Setta il numero delle frasi possibili, che dovranno essere poi aggiunte - // con AddChoice() - void SetNumChoices(int num); - - // Aggiunge una stringa con la scelta - void AddChoice(const RMString &string); - - // Mostra e nasconde la scelta, con eventuali animazioni - // NOTA: Se non viene passato parametro alla Show(), obbligo del - // chiamante assicurarsi che la classe venga inserita alla OTlist - void Show(CORO_PARAM, RMGfxTargetBuffer* bigBuf = NULL); - void Hide(CORO_PARAM); - - // Polling di aggiornamento - void DoFrame(CORO_PARAM, RMPoint ptMousePos); - - // Ritorna la voce attualmente selezionata, o -1 se nessuna selezionata - int GetSelection(void); + // Inizializzazione + RMDialogChoice(); + virtual ~RMDialogChoice(); + + // Inizializzazione e chiusura + void Init(void); + void Close(void); + + // Setta il numero delle frasi possibili, che dovranno essere poi aggiunte + // con AddChoice() + void SetNumChoices(int num); + + // Aggiunge una stringa con la scelta + void AddChoice(const RMString &string); + + // Mostra e nasconde la scelta, con eventuali animazioni + // NOTA: Se non viene passato parametro alla Show(), obbligo del + // chiamante assicurarsi che la classe venga inserita alla OTlist + void Show(CORO_PARAM, RMGfxTargetBuffer *bigBuf = NULL); + void Hide(CORO_PARAM); + + // Polling di aggiornamento + void DoFrame(CORO_PARAM, RMPoint ptMousePos); + + // Ritorna la voce attualmente selezionata, o -1 se nessuna selezionata + int GetSelection(void); }; } // End of namespace Tony diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 8844374821..64c91008a5 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -44,11 +44,11 @@ namespace Tony { using namespace MPAL; /****************************************/ -/* Funzioni globali per la DLL Custom */ +/* Funzioni globali per la DLL Custom */ /****************************************/ uint32 MainLoadLocation(int nLoc, RMPoint pt, RMPoint start) { - return _vm->GetEngine()->LoadLocation(nLoc, pt,start); + return _vm->GetEngine()->LoadLocation(nLoc, pt, start); } void MainUnloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result) { @@ -72,11 +72,11 @@ void MainWaitFrame(CORO_PARAM) { } void MainShowMouse(void) { - _vm->GetEngine()->EnableMouse(); + _vm->GetEngine()->EnableMouse(); } void MainHideMouse(void) { - _vm->GetEngine()->DisableMouse(); + _vm->GetEngine()->DisableMouse(); } void MainPlayMusic(int nChannel, const char *filename, int nFX, bool bLoop, int nSync) { @@ -161,7 +161,7 @@ bool RMOptionButton::DoFrame(const RMPoint &mousePos, bool bLeftClick, bool bRig } } } else { - if (bLeftClick && m_rect.PtInRect(mousePos)) { + if (bLeftClick && m_rect.PtInRect(mousePos)) { m_bActive = !m_bActive; return true; } @@ -176,7 +176,7 @@ void RMOptionButton::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); - CORO_BEGIN_CODE(_ctx); + CORO_BEGIN_CODE(_ctx); if (!m_bActive) return; @@ -274,9 +274,9 @@ bool RMOptionSlide::DoFrame(const RMPoint &mousePos, bool bLeftClick, bool bRigh void RMOptionSlide::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CONTEXT; - int i; - int val; - RMPoint pos; + int i; + int val; + RMPoint pos; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -384,22 +384,22 @@ RMOptionScreen::~RMOptionScreen(void) { void RMOptionScreen::RefreshAll(CORO_PARAM) { CORO_BEGIN_CONTEXT; - RMGfxSourceBuffer16 *thumb; - RMText* title; - RMText *num[6]; - int i; + RMGfxSourceBuffer16 *thumb; + RMText *title; + RMText *num[6]; + int i; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); ClearOT(); AddPrim(new RMGfxPrimitive(m_menu)); - + if (m_bNoLoadSave) - AddPrim(new RMGfxPrimitive(m_HideLoadSave,RMPoint(0, 401))); + AddPrim(new RMGfxPrimitive(m_HideLoadSave, RMPoint(0, 401))); if (m_bQuitConfirm) { - AddPrim(new RMGfxPrimitive(m_QuitConfirm,RMPoint(270, 200))); + AddPrim(new RMGfxPrimitive(m_QuitConfirm, RMPoint(270, 200))); m_ButtonQuitYes->AddToList(*this); m_ButtonQuitNo->AddToList(*this); } @@ -450,47 +450,65 @@ void RMOptionScreen::RefreshAll(CORO_PARAM) { AddPrim(new RMGfxPrimitive(_ctx->title, RMPoint(320, 10))); - if (m_curThumbDiff[0] == 0) AddPrim(new RMGfxPrimitive(m_SaveHard, RMPoint(48, 57))); - else if (m_curThumbDiff[0] == 1) AddPrim(new RMGfxPrimitive(m_SaveEasy, RMPoint(48, 57))); - if (m_curThumbDiff[1] == 0) AddPrim(new RMGfxPrimitive(m_SaveHard, RMPoint(240, 57))); - else if (m_curThumbDiff[1] == 1) AddPrim(new RMGfxPrimitive(m_SaveEasy,RMPoint(240, 57))); - if (m_curThumbDiff[2] == 0) AddPrim(new RMGfxPrimitive(m_SaveHard,RMPoint(432, 57))); - else if (m_curThumbDiff[2] == 1) AddPrim(new RMGfxPrimitive(m_SaveEasy,RMPoint(432, 57))); - if (m_curThumbDiff[3] == 0) AddPrim(new RMGfxPrimitive(m_SaveHard,RMPoint(48, 239))); - else if (m_curThumbDiff[3] == 1) AddPrim(new RMGfxPrimitive(m_SaveEasy,RMPoint(48, 239))); - if (m_curThumbDiff[4] == 0) AddPrim(new RMGfxPrimitive(m_SaveHard,RMPoint(240, 239))); - else if (m_curThumbDiff[4] == 1) AddPrim(new RMGfxPrimitive(m_SaveEasy,RMPoint(240, 239))); - if (m_curThumbDiff[5] == 0) AddPrim(new RMGfxPrimitive(m_SaveHard,RMPoint(432, 239))); - else if (m_curThumbDiff[5] == 1) AddPrim(new RMGfxPrimitive(m_SaveEasy,RMPoint(432, 239))); - - if (m_curThumb[0] && !(m_bEditSaveName && m_nEditPos == 0)) AddPrim(new RMGfxPrimitive(m_curThumb[0], RMPoint(48, 57))); - if (m_curThumb[1] && !(m_bEditSaveName && m_nEditPos == 1)) AddPrim(new RMGfxPrimitive(m_curThumb[1], RMPoint(240, 57))); - if (m_curThumb[2] && !(m_bEditSaveName && m_nEditPos == 2)) AddPrim(new RMGfxPrimitive(m_curThumb[2], RMPoint(432, 57))); - if (m_curThumb[3] && !(m_bEditSaveName && m_nEditPos == 3)) AddPrim(new RMGfxPrimitive(m_curThumb[3], RMPoint(48, 239))); - if (m_curThumb[4] && !(m_bEditSaveName && m_nEditPos == 4)) AddPrim(new RMGfxPrimitive(m_curThumb[4], RMPoint(240, 239))); - if (m_curThumb[5] && !(m_bEditSaveName && m_nEditPos == 5)) AddPrim(new RMGfxPrimitive(m_curThumb[5], RMPoint(432, 239))); + if (m_curThumbDiff[0] == 0) + AddPrim(new RMGfxPrimitive(m_SaveHard, RMPoint(48, 57))); + else if (m_curThumbDiff[0] == 1) + AddPrim(new RMGfxPrimitive(m_SaveEasy, RMPoint(48, 57))); + if (m_curThumbDiff[1] == 0) + AddPrim(new RMGfxPrimitive(m_SaveHard, RMPoint(240, 57))); + else if (m_curThumbDiff[1] == 1) + AddPrim(new RMGfxPrimitive(m_SaveEasy, RMPoint(240, 57))); + if (m_curThumbDiff[2] == 0) + AddPrim(new RMGfxPrimitive(m_SaveHard, RMPoint(432, 57))); + else if (m_curThumbDiff[2] == 1) + AddPrim(new RMGfxPrimitive(m_SaveEasy, RMPoint(432, 57))); + if (m_curThumbDiff[3] == 0) + AddPrim(new RMGfxPrimitive(m_SaveHard, RMPoint(48, 239))); + else if (m_curThumbDiff[3] == 1) + AddPrim(new RMGfxPrimitive(m_SaveEasy, RMPoint(48, 239))); + if (m_curThumbDiff[4] == 0) + AddPrim(new RMGfxPrimitive(m_SaveHard, RMPoint(240, 239))); + else if (m_curThumbDiff[4] == 1) + AddPrim(new RMGfxPrimitive(m_SaveEasy, RMPoint(240, 239))); + if (m_curThumbDiff[5] == 0) + AddPrim(new RMGfxPrimitive(m_SaveHard, RMPoint(432, 239))); + else if (m_curThumbDiff[5] == 1) + AddPrim(new RMGfxPrimitive(m_SaveEasy, RMPoint(432, 239))); + + if (m_curThumb[0] && !(m_bEditSaveName && m_nEditPos == 0)) + AddPrim(new RMGfxPrimitive(m_curThumb[0], RMPoint(48, 57))); + if (m_curThumb[1] && !(m_bEditSaveName && m_nEditPos == 1)) + AddPrim(new RMGfxPrimitive(m_curThumb[1], RMPoint(240, 57))); + if (m_curThumb[2] && !(m_bEditSaveName && m_nEditPos == 2)) + AddPrim(new RMGfxPrimitive(m_curThumb[2], RMPoint(432, 57))); + if (m_curThumb[3] && !(m_bEditSaveName && m_nEditPos == 3)) + AddPrim(new RMGfxPrimitive(m_curThumb[3], RMPoint(48, 239))); + if (m_curThumb[4] && !(m_bEditSaveName && m_nEditPos == 4)) + AddPrim(new RMGfxPrimitive(m_curThumb[4], RMPoint(240, 239))); + if (m_curThumb[5] && !(m_bEditSaveName && m_nEditPos == 5)) + AddPrim(new RMGfxPrimitive(m_curThumb[5], RMPoint(432, 239))); if (m_bEditSaveName) { _ctx->thumb = new RMGfxSourceBuffer16; _ctx->thumb->Init((byte *)_vm->GetThumbnail(), 640 / 4, 480 / 4); if (m_nEditPos == 0) - AddPrim(new RMGfxPrimitive(_ctx->thumb,RMPoint(48, 57))); + AddPrim(new RMGfxPrimitive(_ctx->thumb, RMPoint(48, 57))); else if (m_nEditPos == 1) - AddPrim(new RMGfxPrimitive(_ctx->thumb,RMPoint(240, 57))); + AddPrim(new RMGfxPrimitive(_ctx->thumb, RMPoint(240, 57))); else if (m_nEditPos == 2) - AddPrim(new RMGfxPrimitive(_ctx->thumb,RMPoint(432, 57))); + AddPrim(new RMGfxPrimitive(_ctx->thumb, RMPoint(432, 57))); else if (m_nEditPos == 3) - AddPrim(new RMGfxPrimitive(_ctx->thumb,RMPoint(48, 239))); + AddPrim(new RMGfxPrimitive(_ctx->thumb, RMPoint(48, 239))); else if (m_nEditPos == 4) - AddPrim(new RMGfxPrimitive(_ctx->thumb,RMPoint(240, 239))); + AddPrim(new RMGfxPrimitive(_ctx->thumb, RMPoint(240, 239))); else if (m_nEditPos == 5) - AddPrim(new RMGfxPrimitive(_ctx->thumb,RMPoint(432, 239))); + AddPrim(new RMGfxPrimitive(_ctx->thumb, RMPoint(432, 239))); } for (_ctx->i = 0; _ctx->i < 6; _ctx->i++) { RMString s; - + if (m_bEditSaveName && m_nEditPos == _ctx->i) s.Format("%02d)%s*", m_statePos + _ctx->i, m_EditName); else { @@ -499,23 +517,23 @@ void RMOptionScreen::RefreshAll(CORO_PARAM) { else s.Format("%02d)%s", m_statePos + _ctx->i, (const char *)m_curThumbName[_ctx->i]); } - + _ctx->num[_ctx->i] = new RMText; _ctx->num[_ctx->i]->SetAlignType(RMText::HLEFT, RMText::VTOP); _ctx->num[_ctx->i]->WriteText(s, 2); } - + AddPrim(new RMGfxPrimitive(_ctx->num[0], RMPoint(55 - 3, 180 + 14))); AddPrim(new RMGfxPrimitive(_ctx->num[1], RMPoint(247 - 3, 180 + 14))); - AddPrim(new RMGfxPrimitive(_ctx->num[2],RMPoint(439 - 3, 180 + 14))); - AddPrim(new RMGfxPrimitive(_ctx->num[3],RMPoint(55 - 3, 362 + 14))); - AddPrim(new RMGfxPrimitive(_ctx->num[4],RMPoint(247 - 3, 362 + 14))); - AddPrim(new RMGfxPrimitive(_ctx->num[5],RMPoint(439 - 3, 362 + 14))); - + AddPrim(new RMGfxPrimitive(_ctx->num[2], RMPoint(439 - 3, 180 + 14))); + AddPrim(new RMGfxPrimitive(_ctx->num[3], RMPoint(55 - 3, 362 + 14))); + AddPrim(new RMGfxPrimitive(_ctx->num[4], RMPoint(247 - 3, 362 + 14))); + AddPrim(new RMGfxPrimitive(_ctx->num[5], RMPoint(439 - 3, 362 + 14))); + m_ButtonSave_ArrowLeft->AddToList(*this); m_ButtonSave_ArrowRight->AddToList(*this); } - + CORO_INVOKE_0(DrawOT); if (m_nState == MENULOAD || m_nState == MENUSAVE) { @@ -535,7 +553,7 @@ void RMOptionScreen::RefreshThumbnails(void) { for (i = 0; i < 6; i++) { if (m_curThumb[i]) delete m_curThumb[i]; - + m_curThumb[i] = new RMGfxSourceBuffer16; m_curThumb[i]->Create(640 / 4, 480 / 4); if (!LoadThumbnailFromSaveState(m_statePos + i, *m_curThumb[i], m_curThumbName[i], m_curThumbDiff[i])) { @@ -550,11 +568,11 @@ void RMOptionScreen::RefreshThumbnails(void) { void RMOptionScreen::InitState(CORO_PARAM) { CORO_BEGIN_CONTEXT; - RMResRaw *raw; + RMResRaw *raw; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - + if (m_nState == MENUGAME || m_nState == MENUGFX || m_nState == MENUSOUND) _ctx->raw = new RMResRaw(20000 + m_nState); else if (m_nState == MENULOAD || m_nState == MENUSAVE) { @@ -601,14 +619,14 @@ void RMOptionScreen::InitState(CORO_PARAM) { if (m_bAlterGfx) { assert(m_ButtonSave_ArrowLeft == NULL); - m_ButtonSave_ArrowLeft = new RMOptionButton(20026,RMPoint(3,196)); + m_ButtonSave_ArrowLeft = new RMOptionButton(20026, RMPoint(3, 196)); assert(m_ButtonSave_ArrowRight == NULL); m_ButtonSave_ArrowRight = new RMOptionButton(20027, RMPoint(601, 197)); } else { assert(m_ButtonSave_ArrowLeft == NULL); m_ButtonSave_ArrowLeft = new RMOptionButton(20013, RMPoint(0, 197)); assert(m_ButtonSave_ArrowRight == NULL); - m_ButtonSave_ArrowRight = new RMOptionButton(20014,RMPoint(601, 197)); + m_ButtonSave_ArrowRight = new RMOptionButton(20014, RMPoint(601, 197)); } } else if (m_nState == MENUGAME || m_nState == MENUGFX || m_nState == MENUSOUND) { assert(m_ButtonExit == NULL); @@ -638,7 +656,7 @@ void RMOptionScreen::InitState(CORO_PARAM) { m_ButtonQuitYes = new RMOptionButton(20022, RMPoint(281, 265)); m_ButtonQuitYes->SetPriority(30); assert(m_ButtonQuitNo == NULL); - m_ButtonQuitNo = new RMOptionButton(20023,RMPoint(337, 264)); + m_ButtonQuitNo = new RMOptionButton(20023, RMPoint(337, 264)); m_ButtonQuitNo->SetPriority(30); if (m_bNoLoadSave) { @@ -653,16 +671,16 @@ void RMOptionScreen::InitState(CORO_PARAM) { // Menu GAME if (m_nState == MENUGAME) { assert(m_ButtonGame_Lock == NULL); - m_ButtonGame_Lock = new RMOptionButton(20008,RMPoint(176, 262), true); + m_ButtonGame_Lock = new RMOptionButton(20008, RMPoint(176, 262), true); m_ButtonGame_Lock->SetActiveState(GLOBALS.bCfgInvLocked); assert(m_ButtonGame_TimerizedText == NULL); - m_ButtonGame_TimerizedText = new RMOptionButton(20009,RMPoint(463, 273), true); + m_ButtonGame_TimerizedText = new RMOptionButton(20009, RMPoint(463, 273), true); m_ButtonGame_TimerizedText->SetActiveState(!GLOBALS.bCfgTimerizedText); assert(m_ButtonGame_Scrolling == NULL); m_ButtonGame_Scrolling = new RMOptionButton(20010, RMPoint(315, 263), true); m_ButtonGame_Scrolling->SetActiveState(GLOBALS.bCfgInvNoScroll); assert(m_ButtonGame_InterUp == NULL); - m_ButtonGame_InterUp = new RMOptionButton(20011,RMPoint(36, 258), true); + m_ButtonGame_InterUp = new RMOptionButton(20011, RMPoint(36, 258), true); m_ButtonGame_InterUp->SetActiveState(GLOBALS.bCfgInvUp); assert(m_SlideTextSpeed == NULL); @@ -673,19 +691,19 @@ void RMOptionScreen::InitState(CORO_PARAM) { // Menu Graphics else if (m_nState == MENUGFX) { assert(m_ButtonGfx_Anni30 == NULL); - m_ButtonGfx_Anni30 = new RMOptionButton(20015,RMPoint(247, 178), true); + m_ButtonGfx_Anni30 = new RMOptionButton(20015, RMPoint(247, 178), true); m_ButtonGfx_Anni30->SetActiveState(GLOBALS.bCfgAnni30); assert(m_ButtonGfx_AntiAlias == NULL); m_ButtonGfx_AntiAlias = new RMOptionButton(20016, RMPoint(430, 83), true); m_ButtonGfx_AntiAlias->SetActiveState(!GLOBALS.bCfgAntiAlias); assert(m_ButtonGfx_Sottotitoli == NULL); - m_ButtonGfx_Sottotitoli = new RMOptionButton(20017,RMPoint(98, 82), true); + m_ButtonGfx_Sottotitoli = new RMOptionButton(20017, RMPoint(98, 82), true); m_ButtonGfx_Sottotitoli->SetActiveState(!GLOBALS.bCfgSottotitoli); assert(m_ButtonGfx_Tips == NULL); - m_ButtonGfx_Tips = new RMOptionButton(20018,RMPoint(431, 246), true); + m_ButtonGfx_Tips = new RMOptionButton(20018, RMPoint(431, 246), true); m_ButtonGfx_Tips->SetActiveState(GLOBALS.bCfgInterTips); assert(m_ButtonGfx_Trans == NULL); - m_ButtonGfx_Trans = new RMOptionButton(20019,RMPoint(126, 271), true); + m_ButtonGfx_Trans = new RMOptionButton(20019, RMPoint(126, 271), true); m_ButtonGfx_Trans->SetActiveState(!GLOBALS.bCfgTransparence); } else if (m_nState == MENUSOUND) { @@ -700,10 +718,10 @@ void RMOptionScreen::InitState(CORO_PARAM) { m_ButtonSound_DubbingOn = new RMOptionButton(20033, RMPoint(339, 75), true); m_ButtonSound_DubbingOn->SetActiveState(GLOBALS.bCfgDubbing); assert(m_ButtonSound_MusicOn == NULL); - m_ButtonSound_MusicOn = new RMOptionButton(20034,RMPoint(338, 179), true); + m_ButtonSound_MusicOn = new RMOptionButton(20034, RMPoint(338, 179), true); m_ButtonSound_MusicOn->SetActiveState(GLOBALS.bCfgMusic); assert(m_ButtonSound_SFXOn == NULL); - m_ButtonSound_SFXOn = new RMOptionButton(20035,RMPoint(338, 283), true); + m_ButtonSound_SFXOn = new RMOptionButton(20035, RMPoint(338, 283), true); m_ButtonSound_SFXOn->SetActiveState(GLOBALS.bCfgSFX); } } @@ -728,7 +746,7 @@ void RMOptionScreen::CloseState(void) { delete m_curThumb[i]; m_curThumb[i] = NULL; } - + delete m_ButtonSave_States[i]; m_ButtonSave_States[i] = NULL; } @@ -817,11 +835,11 @@ void RMOptionScreen::CloseState(void) { GLOBALS.nCfgDubbingVolume = m_SliderSound_Dubbing->GetValue(); delete m_SliderSound_Dubbing; m_SliderSound_Dubbing = NULL; - + GLOBALS.nCfgMusicVolume = m_SliderSound_Music->GetValue(); delete m_SliderSound_Music; m_SliderSound_Music = NULL; - + GLOBALS.nCfgSFXVolume = m_SliderSound_SFX->GetValue(); delete m_SliderSound_SFX; m_SliderSound_SFX = NULL; @@ -870,7 +888,7 @@ void RMOptionScreen::Init(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool &result) { m_nState = MENUGAME; CORO_INVOKE_0(InitState); - + result = true; CORO_END_CODE; @@ -899,7 +917,7 @@ void RMOptionScreen::InitLoadMenuOnly(CORO_PARAM, RMGfxTargetBuffer &bigBuf, boo m_nState = MENULOAD; CORO_INVOKE_0(InitState); - + result = true; CORO_END_CODE; @@ -910,7 +928,7 @@ void RMOptionScreen::InitSaveMenuOnly(CORO_PARAM, RMGfxTargetBuffer &bigBuf, boo CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - + if (m_FadeStep != 0) { result = false; return; @@ -928,7 +946,7 @@ void RMOptionScreen::InitSaveMenuOnly(CORO_PARAM, RMGfxTargetBuffer &bigBuf, boo m_nState = MENUSAVE; CORO_INVOKE_0(InitState); - + result = true; CORO_END_CODE; @@ -956,7 +974,7 @@ void RMOptionScreen::InitNoLoadSave(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool m_nState = MENUGAME; CORO_INVOKE_0(InitState); - + result = true; CORO_END_CODE; @@ -995,12 +1013,12 @@ void RMOptionScreen::ChangeState(CORO_PARAM, STATE newState) { CORO_END_CODE; } -void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { +void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { CORO_BEGIN_CONTEXT; - bool bLeftClick, bRightClick; - RMPoint mousePos; - bool bRefresh; - int i; + bool bLeftClick, bRightClick; + RMPoint mousePos; + bool bRefresh; + int i; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -1063,11 +1081,11 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { _ctx->bRefresh |= m_ButtonSound_DubbingOn->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); _ctx->bRefresh |= m_ButtonSound_MusicOn->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); _ctx->bRefresh |= m_ButtonSound_SFXOn->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - + } else if (m_nState == MENULOAD || m_nState == MENUSAVE) { - for (_ctx->i=0;_ctx->i<6;_ctx->i++) + for (_ctx->i = 0; _ctx->i < 6; _ctx->i++) m_ButtonSave_States[_ctx->i]->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - + if (m_statePos > 0) _ctx->bRefresh |= m_ButtonSave_ArrowLeft->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); if (m_statePos < 90) @@ -1075,10 +1093,10 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { } } - -#define KEYPRESS(c) (_vm->GetEngine()->GetInput().GetAsyncKeyState(c)) + +#define KEYPRESS(c) (_vm->GetEngine()->GetInput().GetAsyncKeyState(c)) #define PROCESS_CHAR(cod,c) if (KEYPRESS(cod)) { \ - m_EditName[strlen(m_EditName) +1 ] = '\0'; m_EditName[strlen(m_EditName)] = c; _ctx->bRefresh = true; } + m_EditName[strlen(m_EditName) +1 ] = '\0'; m_EditName[strlen(m_EditName)] = c; _ctx->bRefresh = true; } /**************** STATO BOTTONI **************/ if (m_bEditSaveName) { @@ -1089,9 +1107,9 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { } } - for (_ctx->i=0;_ctx->i<26 && strlen(m_EditName)<12;_ctx->i++) + for (_ctx->i = 0; _ctx->i < 26 && strlen(m_EditName) < 12; _ctx->i++) if (KEYPRESS(Common::KEYCODE_LSHIFT) || - KEYPRESS(Common::KEYCODE_RSHIFT)) { + KEYPRESS(Common::KEYCODE_RSHIFT)) { PROCESS_CHAR((Common::KeyCode)((int)'a' + _ctx->i), _ctx->i + 'A'); } else { PROCESS_CHAR((Common::KeyCode)((int)'a' + _ctx->i), _ctx->i + 'a'); @@ -1099,23 +1117,33 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { for (_ctx->i = 0; _ctx->i < 10 && strlen(m_EditName) < 12; _ctx->i++) PROCESS_CHAR((Common::KeyCode)((int)'0' + _ctx->i), _ctx->i + '0'); - + + if (strlen(m_EditName) < 12) + PROCESS_CHAR(Common::KEYCODE_SPACE, ' '); + + if (strlen(m_EditName) < 12) + PROCESS_CHAR(Common::KEYCODE_KP0, '0'); + if (strlen(m_EditName) < 12) + PROCESS_CHAR(Common::KEYCODE_KP1, '1'); + if (strlen(m_EditName) < 12) + PROCESS_CHAR(Common::KEYCODE_KP2, '2'); + if (strlen(m_EditName) < 12) + PROCESS_CHAR(Common::KEYCODE_KP3, '3'); if (strlen(m_EditName) < 12) - PROCESS_CHAR(Common::KEYCODE_SPACE,' '); - - if (strlen(m_EditName)<12) PROCESS_CHAR(Common::KEYCODE_KP0, '0'); - if (strlen(m_EditName)<12) PROCESS_CHAR(Common::KEYCODE_KP1, '1'); - if (strlen(m_EditName)<12) PROCESS_CHAR(Common::KEYCODE_KP2, '2'); - if (strlen(m_EditName)<12) PROCESS_CHAR(Common::KEYCODE_KP3, '3'); - if (strlen(m_EditName)<12) PROCESS_CHAR(Common::KEYCODE_KP4, '4'); - if (strlen(m_EditName)<12) PROCESS_CHAR(Common::KEYCODE_KP5, '5'); - if (strlen(m_EditName)<12) PROCESS_CHAR(Common::KEYCODE_KP6, '6'); - if (strlen(m_EditName)<12) PROCESS_CHAR(Common::KEYCODE_KP7, '7'); - if (strlen(m_EditName)<12) PROCESS_CHAR(Common::KEYCODE_KP8, '8'); - if (strlen(m_EditName)<12) PROCESS_CHAR(Common::KEYCODE_KP9, '9'); + PROCESS_CHAR(Common::KEYCODE_KP4, '4'); + if (strlen(m_EditName) < 12) + PROCESS_CHAR(Common::KEYCODE_KP5, '5'); + if (strlen(m_EditName) < 12) + PROCESS_CHAR(Common::KEYCODE_KP6, '6'); + if (strlen(m_EditName) < 12) + PROCESS_CHAR(Common::KEYCODE_KP7, '7'); + if (strlen(m_EditName) < 12) + PROCESS_CHAR(Common::KEYCODE_KP8, '8'); + if (strlen(m_EditName) < 12) + PROCESS_CHAR(Common::KEYCODE_KP9, '9'); // ANNULLA - if (KEYPRESS(Common::KEYCODE_ESCAPE)) { + if (KEYPRESS(Common::KEYCODE_ESCAPE)) { m_bEditSaveName = false; _ctx->bRefresh = true; } @@ -1155,11 +1183,11 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { } } else { for (_ctx->i = 0; _ctx->i < 6; _ctx->i++) - if (m_ButtonSave_States[_ctx->i]->IsActive()) { + if (m_ButtonSave_States[_ctx->i]->IsActive()) { // C' da effettuare il salvataggio o il caricamento!!!! if (m_nState == MENULOAD && m_curThumb[_ctx->i] != NULL) { // Caricamento - CORO_INVOKE_1(_vm->LoadState, m_statePos+_ctx->i); + CORO_INVOKE_1(_vm->LoadState, m_statePos + _ctx->i); Close(); } else if (m_nState == MENUSAVE && (m_statePos != 0 || _ctx->i != 0)) { // Attiva la modalit di editing @@ -1247,7 +1275,7 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { void RMOptionScreen::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CONTEXT; - int curTime; + int curTime; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -1255,17 +1283,17 @@ void RMOptionScreen::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive _ctx->curTime = _vm->GetTime(); #define FADE_SPEED 20 -#define SYNC (_ctx->curTime-m_FadeTime) / 25 - +#define SYNC (_ctx->curTime-m_FadeTime) / 25 + if (m_bExit) return; if (m_FadeStep == 1) { - // Discesa veloce + // Discesa veloce if (m_FadeTime == -1) m_FadeY += FADE_SPEED; else - m_FadeY += FADE_SPEED*SYNC; + m_FadeY += FADE_SPEED * SYNC; if (m_FadeY > 480) { m_FadeY = 480; m_FadeStep++; @@ -1334,7 +1362,7 @@ void RMOptionScreen::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive m_bExit = true; m_FadeStep = 0; - // Libera la memoria + // Libera la memoria CloseState(); return; @@ -1357,13 +1385,13 @@ void RMOptionScreen::RemoveThis(CORO_PARAM, bool &result) { } -bool RMOptionScreen::LoadThumbnailFromSaveState(int nState, byte *lpDestBuf, RMString &name, byte &diff) { +bool RMOptionScreen::LoadThumbnailFromSaveState(int nState, byte *lpDestBuf, RMString &name, byte &diff) { Common::String buf; - char namebuf[256]; + char namebuf[256]; int i; Common::InSaveFile *f; char id[4]; - + // Pulisce la destinazione Common::fill(lpDestBuf, lpDestBuf + 160 * 120 * 2, 0); name = "No name"; @@ -1371,7 +1399,7 @@ bool RMOptionScreen::LoadThumbnailFromSaveState(int nState, byte *lpDestBuf, RMS // Get the savegame filename for the given slot buf = _vm->GetSaveStateFileName(nState); - + // Try and open the savegame f = g_system->getSavefileManager()->openForLoading(buf); if (f == NULL) @@ -1397,19 +1425,19 @@ bool RMOptionScreen::LoadThumbnailFromSaveState(int nState, byte *lpDestBuf, RMS uint32 cmpsize, size; cmpbuf = new byte[160 * 120 * 4]; - + // Se la versione >= 5, compresso! cmpsize = f->readUint32LE(); f->read(cmpbuf, cmpsize); - lzo1x_decompress(cmpbuf,cmpsize,lpDestBuf,&size); + lzo1x_decompress(cmpbuf, cmpsize, lpDestBuf, &size); delete[] cmpbuf; } else { // Read in the screenshot as an uncompressed data block if (id[3] >= 8) // Recent versions use hardcoded 160x120 uncomrpessed data, so size can be skipped - f->skip(4); + f->skip(4); f->read(lpDestBuf, 160 * 120 * 2); } @@ -1467,7 +1495,7 @@ void RMPointer::Init(void) { m_specialPointer[i] = new RMItem; ds >> *m_specialPointer[i]; } - + //m_hotspot[0].Set(19,5); m_hotspot[0].Set(5, 1); m_hotspot[1].Set(32, 28); @@ -1504,10 +1532,10 @@ int RMPointer::Priority() { void RMPointer::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CONTEXT; - int n; + int n; CORO_END_CONTEXT(_ctx); - CORO_BEGIN_CODE(_ctx); + CORO_BEGIN_CODE(_ctx); // Controlla il pointer _ctx->n = m_nCurPointer; @@ -1518,7 +1546,7 @@ void RMPointer::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim if (m_pos.x >= 0 && m_pos.y >= 0 && m_pos.x < RM_SX && m_pos.y < RM_SY) { // Richiama il draw del puntatore - prim->Dst()-=m_hotspot[_ctx->n]; + prim->Dst() -= m_hotspot[_ctx->n]; if (m_nCurSpecialPointer == 0) { CORO_INVOKE_2(m_pointer[_ctx->n]->Draw, bigBuf, prim); @@ -1527,7 +1555,7 @@ void RMPointer::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim CORO_INVOKE_2(m_nCurCustomPointer->Draw, bigBuf, prim); else // Richiama il draw sul puntatore speciale - CORO_INVOKE_2(m_specialPointer[m_nCurSpecialPointer-1]->Draw, bigBuf, prim); + CORO_INVOKE_2(m_specialPointer[m_nCurSpecialPointer - 1]->Draw, bigBuf, prim); } } @@ -1539,8 +1567,8 @@ void RMPointer::DoFrame(RMGfxTargetBuffer *bigBuf) { bigBuf->AddPrim(new RMGfxPrimitive(this)); // Se c'e' un puntatore speciale, fa la DoFrame - if (m_nCurSpecialPointer!=0 && m_nCurSpecialPointer!=PTR_CUSTOM) - m_specialPointer[m_nCurSpecialPointer-1]->DoFrame(bigBuf,false); + if (m_nCurSpecialPointer != 0 && m_nCurSpecialPointer != PTR_CUSTOM) + m_specialPointer[m_nCurSpecialPointer - 1]->DoFrame(bigBuf, false); } void RMPointer::RemoveThis(CORO_PARAM, bool &result) { diff --git a/engines/tony/game.h b/engines/tony/game.h index 22df40c6d8..160637d9c2 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -37,19 +37,19 @@ namespace Tony { -#define INIT_GFX16_FROMRAW(dwRes, buf16) \ - raw = new RMResRaw(dwRes); \ - assert(raw->IsValid()); \ - assert((buf16) == NULL); \ - (buf16) = new RMGfxSourceBuffer16(false); \ - (buf16)->Init(*raw,raw->Width(),raw->Height()); \ +#define INIT_GFX16_FROMRAW(dwRes, buf16) \ + raw = new RMResRaw(dwRes); \ + assert(raw->IsValid()); \ + assert((buf16) == NULL); \ + (buf16) = new RMGfxSourceBuffer16(false); \ + (buf16)->Init(*raw,raw->Width(),raw->Height()); \ delete raw; -#define INIT_GFX8_FROMRAW(raw, dwRes, buf8) \ - raw = new RMResRaw(dwRes); \ - assert(raw->IsValid()); \ - assert((buf8) == NULL); \ - (buf8) = new RMGfxSourceBuffer8RLEByte(); \ +#define INIT_GFX8_FROMRAW(raw, dwRes, buf8) \ + raw = new RMResRaw(dwRes); \ + assert(raw->IsValid()); \ + assert((buf8) == NULL); \ + (buf8) = new RMGfxSourceBuffer8RLEByte(); \ (buf8)->Init(*raw, raw->Width(), raw->Height(), true); \ delete raw; @@ -80,7 +80,7 @@ public: public: // Constructor & destructor - RMPointer(); + RMPointer(); virtual ~RMPointer(); // Initialisation @@ -97,25 +97,34 @@ public: // Overloading draw method virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - + // Sets the current co-ordinates - void SetCoord(const RMPoint &pt) { m_pos = pt; } + void SetCoord(const RMPoint &pt) { + m_pos = pt; + } // Overloading of the method to see if rising from the list virtual void RemoveThis(CORO_PARAM, bool &result); // Sets a new action as current - void SetAction(RMTonyAction action) { m_nCurPointer = action; } + void SetAction(RMTonyAction action) { + m_nCurPointer = action; + } // Sets a new pointer - void SetSpecialPointer(POINTER ptr) { - m_nCurSpecialPointer=ptr; - if (m_nCurSpecialPointer && m_nCurSpecialPointer != PTR_CUSTOM) m_specialPointer[ptr-1]->SetPattern(1); + void SetSpecialPointer(POINTER ptr) { + m_nCurSpecialPointer = ptr; + if (m_nCurSpecialPointer && m_nCurSpecialPointer != PTR_CUSTOM) + m_specialPointer[ptr - 1]->SetPattern(1); + } + POINTER GetSpecialPointer(void) { + return (POINTER)m_nCurSpecialPointer; } - POINTER GetSpecialPointer(void) { return (POINTER)m_nCurSpecialPointer; } // Set the new custom pointer - void SetCustomPointer(RMGfxSourceBuffer8 *ptr) { m_nCurCustomPointer = ptr; } + void SetCustomPointer(RMGfxSourceBuffer8 *ptr) { + m_nCurCustomPointer = ptr; + } // Return the current action to be applied according to the pointer int CurAction(void); @@ -137,18 +146,22 @@ public: bool DoFrame(const RMPoint &mousePos, bool bLeftClick, bool bRightClick); virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); void AddToList(RMGfxTargetBuffer &bigBuf); - bool IsActive() { return m_bActive; } - void SetActiveState(bool bState) { m_bActive=bState; } + bool IsActive() { + return m_bActive; + } + void SetActiveState(bool bState) { + m_bActive = bState; + } }; class RMOptionSlide : public RMGfxTaskSetPrior { private: - RMOptionButton* m_PushLeft; - RMOptionButton* m_PushRight; - RMGfxSourceBuffer16* m_SliderCenter; - RMGfxSourceBuffer16* m_SliderLeft; - RMGfxSourceBuffer16* m_SliderRight; - RMGfxSourceBuffer16* m_SliderSingle; + RMOptionButton *m_PushLeft; + RMOptionButton *m_PushRight; + RMGfxSourceBuffer16 *m_SliderCenter; + RMGfxSourceBuffer16 *m_SliderLeft; + RMGfxSourceBuffer16 *m_SliderRight; + RMGfxSourceBuffer16 *m_SliderSingle; int m_nSlideSize; RMPoint m_pos; int m_nValue; @@ -161,9 +174,11 @@ public: bool DoFrame(const RMPoint &mousePos, bool bLeftClick, bool bRightClick); virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - void AddToList(RMGfxTargetBuffer& bigBuf); + void AddToList(RMGfxTargetBuffer &bigBuf); - int GetValue() { return m_nValue; } + int GetValue() { + return m_nValue; + } }; class RMOptionScreen : public RMGfxWoodyBuffer { @@ -202,7 +217,7 @@ private: bool m_bEditSaveName; int m_nEditPos; char m_EditName[256]; - + union { RMOptionButton *m_ButtonGame_Lock; RMOptionButton *m_ButtonGfx_Anni30; @@ -233,11 +248,11 @@ private: bool m_bAlterGfx; enum STATE { - MENUGAME, - MENUGFX, - MENUSOUND, - MENULOAD, - MENUSAVE + MENUGAME, + MENUGFX, + MENUSOUND, + MENULOAD, + MENUSAVE }; STATE m_nState; @@ -276,7 +291,7 @@ protected: // Ridisegna tutto il menu delle opzioni void RefreshAll(CORO_PARAM); void RefreshThumbnails(void); - + }; } // End of namespace Tony diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 826159a8d7..ae68860e79 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -64,9 +64,9 @@ void RMGfxTaskSetPrior::SetPriority(int nPrior) { \****************************************************************************/ RMGfxBuffer::RMGfxBuffer() { - m_dimx = m_dimy = 0; - m_bUseDDraw = false; - m_origBuf = m_buf = NULL; + m_dimx = m_dimy = 0; + m_bUseDDraw = false; + m_origBuf = m_buf = NULL; } RMGfxBuffer::~RMGfxBuffer() { @@ -102,7 +102,7 @@ void RMGfxBuffer::Destroy(void) { void RMGfxBuffer::Lock(void) { if (m_bUseDDraw) { - // Gestisce l'accelerazione + // Gestisce l'accelerazione } } @@ -113,7 +113,7 @@ void RMGfxBuffer::Unlock(void) { } void RMGfxBuffer::OffsetY(int nLines, int nBpp) { - m_buf += nLines* Dimx() * nBpp / 8; + m_buf += nLines * Dimx() * nBpp / 8; } @@ -148,7 +148,7 @@ RMGfxBuffer::RMGfxBuffer(int dimx, int dimy, int nBpp, bool bUseDDraw) { int RMGfxSourceBuffer::Init(const byte *buf, int dimx, int dimy, bool bLoadPalette) { Create(dimx, dimy, Bpp()); CopyMemory(m_buf, buf, dimx * dimy * Bpp() / 8); - + // Richiama la funzione di preparazione della surface (ereditata) PrepareImage(); @@ -156,10 +156,10 @@ int RMGfxSourceBuffer::Init(const byte *buf, int dimx, int dimy, bool bLoadPalet } -void RMGfxSourceBuffer::Init(RMDataStream& ds, int dimx, int dimy, bool bLoadPalette) { - Create(dimx, dimy,Bpp()); - ds.Read(m_buf, dimx * dimy*Bpp() / 8); - +void RMGfxSourceBuffer::Init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette) { + Create(dimx, dimy, Bpp()); + ds.Read(m_buf, dimx * dimy * Bpp() / 8); + // Richiama la funzione di preparazione della surface (ereditata) PrepareImage(); } @@ -171,11 +171,11 @@ void RMGfxSourceBuffer::PrepareImage(void) { // Non fa nulla: puo' essere overloadata se necessaria } -bool RMGfxSourceBuffer::Clip2D(int &x1, int &y1, int &u, int &v, int &width, int &height, bool bUseSrc, RMGfxTargetBuffer* buf) { +bool RMGfxSourceBuffer::Clip2D(int &x1, int &y1, int &u, int &v, int &width, int &height, bool bUseSrc, RMGfxTargetBuffer *buf) { int destw, desth; /* - OBSOLETE CODE: + OBSOLETE CODE: if (buf == NULL) { destw=RM_SX; @@ -185,6 +185,7 @@ bool RMGfxSourceBuffer::Clip2D(int &x1, int &y1, int &u, int &v, int &width, int desth = buf->Dimy(); } */ + destw = buf->Dimx(); desth = buf->Dimy(); @@ -193,20 +194,25 @@ bool RMGfxSourceBuffer::Clip2D(int &x1, int &y1, int &u, int &v, int &width, int width = m_dimx; height = m_dimy; } - - if (x1 > destw - 1) return false; - if (y1 > desth - 1) return false; - if (x1 < 0) { + if (x1 > destw - 1) + return false; + + if (y1 > desth - 1) + return false; + + if (x1 < 0) { width += x1; - if (width < 0) return false; + if (width < 0) + return false; u -= x1; - x1 = 0; + x1 = 0; } - if (y1 < 0) { + if (y1 < 0) { height += y1; - if (height < 0) return false; + if (height < 0) + return false; v -= y1; y1 = 0; } @@ -227,7 +233,7 @@ bool RMGfxSourceBuffer::Clip2D(int &x1, int &y1, int &u, int &v, int &width, int * Description: Carica una surface partendo dall'ID della risorsa * * Input: uint32 resID ID della risorsa -* int dimx, dimy Dimensione del buffer +* int dimx, dimy Dimensione del buffer * \****************************************************************************/ @@ -263,7 +269,7 @@ RMGfxWoodyBuffer::RMGfxWoodyBuffer() { } RMGfxWoodyBuffer::RMGfxWoodyBuffer(int dimx, int dimy, bool bUseDDraw) - : RMGfxBuffer(dimx,dimy,16,bUseDDraw) { + : RMGfxBuffer(dimx, dimy, 16, bUseDDraw) { } @@ -307,11 +313,11 @@ void RMGfxTargetBuffer::ClearOT(void) { void RMGfxTargetBuffer::DrawOT(CORO_PARAM) { CORO_BEGIN_CONTEXT; - OTList *cur; - OTList *prev; - OTList *next; - RMGfxPrimitive *myprim; - bool result; + OTList *cur; + OTList *prev; + OTList *next; + RMGfxPrimitive *myprim; + bool result; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -323,9 +329,9 @@ void RMGfxTargetBuffer::DrawOT(CORO_PARAM) { Lock(); // g_system->lockMutex(csModifyingOT); - while (_ctx->cur != NULL) { + while (_ctx->cur != NULL) { // Richiama la draw sul task, passandogli una copia della primitiva - _ctx->myprim=_ctx->cur->prim->Duplicate(); + _ctx->myprim = _ctx->cur->prim->Duplicate(); CORO_INVOKE_2(_ctx->cur->prim->m_task->Draw, *this, _ctx->myprim); delete _ctx->myprim; @@ -335,7 +341,7 @@ void RMGfxTargetBuffer::DrawOT(CORO_PARAM) { // Deregistra il task _ctx->cur->prim->m_task->Unregister(); - // Cancella il task liberando la memoria + // Cancella il task liberando la memoria delete _ctx->cur->prim; _ctx->next = _ctx->cur->next; delete _ctx->cur; @@ -388,7 +394,7 @@ void RMGfxTargetBuffer::AddPrim(RMGfxPrimitive *prim) { } else { cur = otlist; while (cur->next != NULL && nPrior > cur->next->prim->m_task->Priority()) - cur=cur->next; + cur = cur->next; n->next = cur->next; cur->next = n; @@ -403,7 +409,7 @@ void RMGfxTargetBuffer::AddClearTask(void) { /****************************************************************************\ -* Metodi di RMGfxSourceBufferPal +* Metodi di RMGfxSourceBufferPal \****************************************************************************/ RMGfxSourceBufferPal::~RMGfxSourceBufferPal() { @@ -420,11 +426,11 @@ int RMGfxSourceBufferPal::LoadPaletteWA(const byte *buf, bool bSwapped) { m_pal[i * 3 + 2] = buf[i * 3 + 0]; } else - CopyMemory(m_pal,buf,(1<> 3) << 10) | - (((int)m_pal[i * 3 + 1] >> 3) << 5) | - (((int)m_pal[i * 3 + 2] >> 3) << 0); + (((int)m_pal[i * 3 + 1] >> 3) << 5) | + (((int)m_pal[i * 3 + 2] >> 3) << 0); } } int RMGfxSourceBufferPal::Init(const byte *buf, int dimx, int dimy, bool bLoadPalette) { int read; - + // Carica l'immagine RAW read = RMGfxSourceBuffer::Init(buf, dimx, dimy); - + // Carica la palette se necessario if (bLoadPalette) read += LoadPaletteWA(&buf[read]); @@ -465,7 +471,7 @@ int RMGfxSourceBufferPal::Init(const byte *buf, int dimx, int dimy, bool bLoadPa void RMGfxSourceBufferPal::Init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette) { // Carica l'immagine RAW RMGfxSourceBuffer::Init(ds, dimx, dimy); - + // Carica la palette se necessario if (bLoadPalette) { byte *suxpal = new byte[256 * 3]; @@ -484,14 +490,14 @@ int RMGfxSourceBufferPal::LoadPaletteWA(uint32 resID, bool bSwapped) { } /****************************************************************************\ -* Metodi di RMGfxSourceBuffer4 +* Metodi di RMGfxSourceBuffer4 \****************************************************************************/ void RMGfxSourceBuffer4::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { } RMGfxSourceBuffer4::RMGfxSourceBuffer4(int dimx, int dimy, bool bUseDDraw) - : RMGfxBuffer(dimx,dimy,4,bUseDDraw) { + : RMGfxBuffer(dimx, dimy, 4, bUseDDraw) { SetPriority(0); } @@ -510,11 +516,11 @@ int RMGfxSourceBuffer4::Bpp() { } void RMGfxSourceBuffer4::Create(int dimx, int dimy, bool bUseDDraw) { - RMGfxBuffer::Create(dimx,dimy,4,bUseDDraw); + RMGfxBuffer::Create(dimx, dimy, 4, bUseDDraw); } /****************************************************************************\ -* Metodi di RMGfxSourceBuffer8 +* Metodi di RMGfxSourceBuffer8 \****************************************************************************/ RMGfxSourceBuffer8::~RMGfxSourceBuffer8() { @@ -530,13 +536,13 @@ void RMGfxSourceBuffer8::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimit // Destination nel buffer RMRect dst; if (prim->HaveDst()) - dst=prim->Dst(); - + dst = prim->Dst(); + // Esegue il clip if (prim->HaveSrc()) { u = prim->Src().x1; v = prim->Src().y1; - + width = prim->Src().Width(); height = prim->Src().Height(); } @@ -567,7 +573,7 @@ void RMGfxSourceBuffer8::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimit for (x = 0; x < width; x += 2) { buf[0] = m_palFinal[raw[0]]; buf[1] = m_palFinal[raw[1]]; - + buf += 2; raw += 2; } @@ -578,7 +584,7 @@ void RMGfxSourceBuffer8::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimit } RMGfxSourceBuffer8::RMGfxSourceBuffer8(int dimx, int dimy, bool bUseDDraw) - : RMGfxBuffer(dimx,dimy,8,bUseDDraw) { + : RMGfxBuffer(dimx, dimy, 8, bUseDDraw) { SetPriority(0); } @@ -601,26 +607,25 @@ int RMGfxSourceBuffer8::Bpp() { return 8; } -void RMGfxSourceBuffer8::Create(int dimx, int dimy, bool bUseDDraw) { +void RMGfxSourceBuffer8::Create(int dimx, int dimy, bool bUseDDraw) { RMGfxBuffer::Create(dimx, dimy, 8, bUseDDraw); } -#define GETRED(x) (((x) >> 10) & 0x1F) +#define GETRED(x) (((x) >> 10) & 0x1F) #define GETGREEN(x) (((x) >> 5) & 0x1F) #define GETBLUE(x) ((x) & 0x1F) /****************************************************************************\ -* Metodi di RMGfxSourceBuffer8AB +* Metodi di RMGfxSourceBuffer8AB \****************************************************************************/ RMGfxSourceBuffer8AB::~RMGfxSourceBuffer8AB() { } -int RMGfxSourceBuffer8AB::CalcTrasp(int fore, int back) -{ - int r,g,b; +int RMGfxSourceBuffer8AB::CalcTrasp(int fore, int back) { + int r, g, b; r = (GETRED(fore) >> 2) + (GETRED(back) >> 1); g = (GETGREEN(fore) >> 2) + (GETGREEN(back) >> 1); @@ -630,13 +635,13 @@ int RMGfxSourceBuffer8AB::CalcTrasp(int fore, int back) if (g > 0x1F) g = 0x1F; if (b > 0x1F) b = 0x1F; - return (r<<10)|(g<<5)|b; + return (r << 10) | (g << 5) | b; } void RMGfxSourceBuffer8AB::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { int x, y, width, height, u, v; - int bufx=bigBuf.Dimx(); + int bufx = bigBuf.Dimx(); uint16 *buf = bigBuf; byte *raw = m_buf; @@ -644,12 +649,12 @@ void RMGfxSourceBuffer8AB::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrim RMRect dst; if (prim->HaveDst()) dst = prim->Dst(); - + // Esegue il clip if (prim->HaveSrc()) { - u=prim->Src().x1; - v=prim->Src().y1; - + u = prim->Src().x1; + v = prim->Src().y1; + width = prim->Src().Width(); height = prim->Src().Height(); } @@ -675,12 +680,12 @@ void RMGfxSourceBuffer8AB::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrim } } else { for (y = 0; y < height; y++) { - raw = m_buf + (y+v) * m_dimx + u; + raw = m_buf + (y + v) * m_dimx + u; for (x = 0; x < width; x += 2) { buf[0] = CalcTrasp(m_palFinal[raw[0]], buf[0]); buf[1] = CalcTrasp(m_palFinal[raw[1]], buf[1]); - + buf += 2; raw += 2; } @@ -695,7 +700,7 @@ void RMGfxSourceBuffer8AB::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrim /****************************************************************************\ -* Metodi di RMGfxSourceBuffer8RLE +* Metodi di RMGfxSourceBuffer8RLE \****************************************************************************/ byte RMGfxSourceBuffer8RLE::MegaRLEBuf[512 * 1024]; @@ -724,7 +729,7 @@ int RMGfxSourceBuffer8RLE::Init(const byte *buf, int dimx, int dimy, bool bLoadP void RMGfxSourceBuffer8RLE::Init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette) { if (bNeedRLECompress) { - RMGfxSourceBufferPal::Init(ds, dimx, dimy,bLoadPalette); + RMGfxSourceBufferPal::Init(ds, dimx, dimy, bLoadPalette); } else { int size; @@ -745,7 +750,7 @@ void RMGfxSourceBuffer8RLE::PreparePalette(void) { if (alphaBlendColor != -1) { alphaR = (m_palFinal[alphaBlendColor] >> 10) & 0x1F; alphaG = (m_palFinal[alphaBlendColor] >> 5) & 0x1F; - alphaB = (m_palFinal[alphaBlendColor]) & 0x1F; + alphaB = (m_palFinal[alphaBlendColor]) & 0x1F; } } @@ -770,14 +775,14 @@ void RMGfxSourceBuffer8RLE::CompressRLE(void) { byte *src; byte *startsrc; int rep; - + // Esegue la compressione RLE, per linee cur = MegaRLEBuf; src = m_buf; - for (y = 0;y < m_dimy; y++) { + for (y = 0; y < m_dimy; y++) { // Si salva l'inizio della linea startline = cur; - + // Lascia lo spazio per la lunghezza della linea cur += 2; @@ -787,7 +792,7 @@ void RMGfxSourceBuffer8RLE::CompressRLE(void) { startsrc = src; for (x = 0; x < m_dimx;) { if ((curdata == 0 && *src == 0) || (curdata == 1 && *src == alphaBlendColor) - || (curdata == 2 && (*src != alphaBlendColor && *src != 0))) { + || (curdata == 2 && (*src != alphaBlendColor && *src != 0))) { src++; rep++; x++; @@ -795,8 +800,7 @@ void RMGfxSourceBuffer8RLE::CompressRLE(void) { if (curdata == 0) { RLEWriteTrasp(cur, rep); curdata++; - } - else if (curdata == 1) { + } else if (curdata == 1) { RLEWriteAlphaBlend(cur, rep); curdata++; } else { @@ -807,14 +811,14 @@ void RMGfxSourceBuffer8RLE::CompressRLE(void) { rep = 0; startsrc = src; } - } - + } + // Dati in sospeso? if (curdata == 1) { RLEWriteAlphaBlend(cur, rep); RLEWriteData(cur, 0, NULL); } - + if (curdata == 2) { RLEWriteData(cur, rep, startsrc); } @@ -825,9 +829,9 @@ void RMGfxSourceBuffer8RLE::CompressRLE(void) { // Scrive la lunghezza della linea WRITE_LE_UINT16(startline, (uint16)(cur - startline)); } - + // Cancella l'immagine originale - delete[] m_buf; + delete[] m_buf; // Ci copia l'immagine compressa x = cur - MegaRLEBuf; @@ -840,20 +844,20 @@ void RMGfxSourceBuffer8RLE::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPri byte *src; uint16 *buf = bigBuf; int x1, y1, u, v, width, height; - + // Clippiamo lo sprite - x1=prim->Dst().x1; - y1=prim->Dst().y1; - if (!Clip2D(x1,y1,u,v,width,height,false,&bigBuf)) + x1 = prim->Dst().x1; + y1 = prim->Dst().y1; + if (!Clip2D(x1, y1, u, v, width, height, false, &bigBuf)) return; // Andiamo avanti di V linee nell'immagine RLE src = m_buf; - for (y = 0;yIsFlipped()) { @@ -861,8 +865,8 @@ void RMGfxSourceBuffer8RLE::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPri // width = m_dimx; // x1=prim->Dst().x1; - // Flippiamo il clipping - u = m_dimx - (width+u); + // Flippiamo il clipping + u = m_dimx - (width + u); x1 = (prim->Dst().x1 + m_dimx - 1) - u; for (y = 0; y < height; y++) { @@ -873,7 +877,7 @@ void RMGfxSourceBuffer8RLE::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPri src += READ_LE_UINT16(src); // Skippa alla linea successiva - buf += bigBuf.Dimx(); + buf += bigBuf.Dimx(); } } else { for (y = 0; y < height; y++) { @@ -884,14 +888,14 @@ void RMGfxSourceBuffer8RLE::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPri src += READ_LE_UINT16(src); // Skippa alla linea successiva - buf += bigBuf.Dimx(); + buf += bigBuf.Dimx(); } } } /****************************************************************************\ -* Metodi di RMGfxSourceBuffer8RLEByte +* Metodi di RMGfxSourceBuffer8RLEByte \****************************************************************************/ RMGfxSourceBuffer8RLEByte::~RMGfxSourceBuffer8RLEByte() { @@ -900,18 +904,18 @@ RMGfxSourceBuffer8RLEByte::~RMGfxSourceBuffer8RLEByte() { void RMGfxSourceBuffer8RLEByte::RLEWriteTrasp(byte *&cur, int rep) { assert(rep < 255); - *cur ++= rep; + *cur ++ = rep; } void RMGfxSourceBuffer8RLEByte::RLEWriteAlphaBlend(byte *&cur, int rep) { assert(rep < 255); - *cur ++= rep; + *cur ++ = rep; } void RMGfxSourceBuffer8RLEByte::RLEWriteData(byte *&cur, int rep, byte *src) { assert(rep < 256); - - *cur ++= rep; + + *cur ++ = rep; if (rep > 0) { CopyMemory(cur, src, rep); cur += rep; @@ -922,15 +926,15 @@ void RMGfxSourceBuffer8RLEByte::RLEWriteData(byte *&cur, int rep, byte *src) { } void RMGfxSourceBuffer8RLEByte::RLEWriteEOL(byte *&cur) { - *cur ++= 0xFF; + *cur ++ = 0xFF; } void RMGfxSourceBuffer8RLEByte::RLEDecompressLine(uint16 *dst, byte *src, int nStartSkip, int nLength) { int i, n; int r, g, b; - if (nStartSkip == 0) - goto RLEByteDoTrasp; + if (nStartSkip == 0) + goto RLEByteDoTrasp; while (1) { assert(nStartSkip > 0); @@ -939,7 +943,7 @@ void RMGfxSourceBuffer8RLEByte::RLEDecompressLine(uint16 *dst, byte *src, int nS n = *src++; if (n == 0xFF) return; - + if (n >= nStartSkip) { dst += n - nStartSkip; nLength -= n - nStartSkip; @@ -952,7 +956,7 @@ void RMGfxSourceBuffer8RLEByte::RLEDecompressLine(uint16 *dst, byte *src, int nS assert(nStartSkip > 0); - + // ALPHA n = *src++; if (n >= nStartSkip) { @@ -979,11 +983,11 @@ void RMGfxSourceBuffer8RLEByte::RLEDecompressLine(uint16 *dst, byte *src, int nS RLEByteDoTrasp: // Via il trasp di merda n = *src++; - + // EOL? if (n == 0xFF) - return; - + return; + dst += n; nLength -= n; if (nLength <= 0) @@ -997,15 +1001,15 @@ RLEByteDoAlpha2: if (n > nLength) n = nLength; for (i = 0; i < n; i++) { - r=(*dst >> 10) & 0x1F; - g=(*dst >> 5) & 0x1F; - b=*dst & 0x1F; + r = (*dst >> 10) & 0x1F; + g = (*dst >> 5) & 0x1F; + b = *dst & 0x1F; - r=(r >> 2) + (alphaR >> 1); - g=(g >> 2) + (alphaG >> 1); - b=(b >> 2) + (alphaB >> 1); + r = (r >> 2) + (alphaR >> 1); + g = (g >> 2) + (alphaG >> 1); + b = (b >> 2) + (alphaB >> 1); - *dst ++= (r << 10) | (g << 5) | b; + *dst ++ = (r << 10) | (g << 5) | b; } nLength -= n; @@ -1020,9 +1024,9 @@ RLEByteDoAlpha2: RLEByteDoCopy2: if (n > nLength) n = nLength; - - for (i = 0; i < n; i++) - *dst ++= m_palFinal[*src++]; + + for (i = 0; i < n; i++) + *dst ++ = m_palFinal[*src++]; nLength -= n; if (!nLength) @@ -1035,8 +1039,8 @@ void RMGfxSourceBuffer8RLEByte::RLEDecompressLineFlipped(uint16 *dst, byte *src, int i, n; int r, g, b; - if (nStartSkip == 0) - goto RLEByteFlippedDoTrasp; + if (nStartSkip == 0) + goto RLEByteFlippedDoTrasp; while (1) { assert(nStartSkip > 0); @@ -1045,7 +1049,7 @@ void RMGfxSourceBuffer8RLEByte::RLEDecompressLineFlipped(uint16 *dst, byte *src, n = *src++; if (n == 0xFF) return; - + if (n >= nStartSkip) { dst -= n - nStartSkip; nLength -= n - nStartSkip; @@ -1058,7 +1062,7 @@ void RMGfxSourceBuffer8RLEByte::RLEDecompressLineFlipped(uint16 *dst, byte *src, assert(nStartSkip > 0); - + // ALPHA n = *src++; if (n >= nStartSkip) { @@ -1071,7 +1075,7 @@ void RMGfxSourceBuffer8RLEByte::RLEDecompressLineFlipped(uint16 *dst, byte *src, // DATA n = *src++; - if (n >= nStartSkip){ + if (n >= nStartSkip) { src += nStartSkip; n -= nStartSkip; goto RLEByteFlippedDoCopy2; @@ -1085,11 +1089,11 @@ void RMGfxSourceBuffer8RLEByte::RLEDecompressLineFlipped(uint16 *dst, byte *src, RLEByteFlippedDoTrasp: // Via il trasp di merda n = *src++; - + // EOL? if (n == 0xFF) - return; - + return; + dst -= n; nLength -= n; if (nLength <= 0) @@ -1103,15 +1107,15 @@ RLEByteFlippedDoAlpha2: if (n > nLength) n = nLength; for (i = 0; i < n; i++) { - r=(*dst >> 10) & 0x1F; - g=(*dst >> 5) & 0x1F; - b=*dst & 0x1F; + r = (*dst >> 10) & 0x1F; + g = (*dst >> 5) & 0x1F; + b = *dst & 0x1F; - r=(r >> 2) + (alphaR >> 1); - g=(g >> 2) + (alphaG >> 1); - b=(b >> 2) + (alphaB >> 1); + r = (r >> 2) + (alphaR >> 1); + g = (g >> 2) + (alphaG >> 1); + b = (b >> 2) + (alphaB >> 1); - *dst--=(r << 10) | (g << 5) | b; + *dst-- = (r << 10) | (g << 5) | b; } nLength -= n; @@ -1126,9 +1130,9 @@ RLEByteFlippedDoAlpha2: RLEByteFlippedDoCopy2: if (n > nLength) n = nLength; - - for (i = 0; i < n; i++) - *dst --= m_palFinal[*src++]; + + for (i = 0; i < n; i++) + *dst -- = m_palFinal[*src++]; nLength -= n; if (!nLength) @@ -1139,10 +1143,10 @@ RLEByteFlippedDoCopy2: /****************************************************************************\ -* Metodi di RMGfxSourceBuffer8RLEWord +* Metodi di RMGfxSourceBuffer8RLEWord \****************************************************************************/ -RMGfxSourceBuffer8RLEWord::~RMGfxSourceBuffer8RLEWord(){ +RMGfxSourceBuffer8RLEWord::~RMGfxSourceBuffer8RLEWord() { } @@ -1161,23 +1165,23 @@ void RMGfxSourceBuffer8RLEWord::RLEWriteData(byte *&cur, int rep, byte *src) { cur += 2; if (rep > 0) { - CopyMemory(cur, src,rep); + CopyMemory(cur, src, rep); cur += rep; - src +=rep; + src += rep; } } void RMGfxSourceBuffer8RLEWord::RLEWriteEOL(byte *&cur) { - *cur ++= 0xFF; - *cur ++= 0xFF; + *cur ++ = 0xFF; + *cur ++ = 0xFF; } void RMGfxSourceBuffer8RLEWord::RLEDecompressLine(uint16 *dst, byte *src, int nStartSkip, int nLength) { int i, n; int r, g, b; - if (nStartSkip == 0) - goto RLEWordDoTrasp; + if (nStartSkip == 0) + goto RLEWordDoTrasp; while (1) { assert(nStartSkip > 0); @@ -1188,11 +1192,11 @@ void RMGfxSourceBuffer8RLEWord::RLEDecompressLine(uint16 *dst, byte *src, int nS if (n == 0xFFFF) return; - + if (n >= nStartSkip) { dst += n - nStartSkip; nLength -= n - nStartSkip; - + if (nLength > 0) goto RLEWordDoAlpha; else @@ -1215,7 +1219,7 @@ void RMGfxSourceBuffer8RLEWord::RLEDecompressLine(uint16 *dst, byte *src, int nS // DATA n = READ_LE_UINT16(src); src += 2; - + if (n >= nStartSkip) { src += nStartSkip; n -= nStartSkip; @@ -1231,11 +1235,11 @@ RLEWordDoTrasp: // Via il trasp di merda n = READ_LE_UINT16(src); src += 2; - + // EOL? if (n == 0xFFFF) - return; - + return; + dst += n; nLength -= n; @@ -1252,15 +1256,15 @@ RLEWordDoAlpha2: n = nLength; for (i = 0; i < n; i++) { - r=(*dst >> 10) & 0x1F; - g=(*dst >> 5) & 0x1F; - b=*dst & 0x1F; + r = (*dst >> 10) & 0x1F; + g = (*dst >> 5) & 0x1F; + b = *dst & 0x1F; - r=(r >> 2) + (alphaR >> 1); - g=(g >> 2) + (alphaG >> 1); - b=(b >> 2) + (alphaB >> 1); + r = (r >> 2) + (alphaR >> 1); + g = (g >> 2) + (alphaG >> 1); + b = (b >> 2) + (alphaB >> 1); - *dst++=(r<<10)|(g<<5)|b; + *dst++ = (r << 10) | (g << 5) | b; } nLength -= n; @@ -1273,29 +1277,29 @@ RLEWordDoAlpha2: // Copia la roba n = READ_LE_UINT16(src); src += 2; - + RLEWordDoCopy2: if (n > nLength) n = nLength; - for (i = 0; i < n; i++) - *dst ++= m_palFinal[*src++]; + for (i = 0; i < n; i++) + *dst ++ = m_palFinal[*src++]; nLength -= n; if (!nLength) return; - + assert(nLength > 0); } } void RMGfxSourceBuffer8RLEWord::RLEDecompressLineFlipped(uint16 *dst, byte *src, int nStartSkip, int nLength) { - int i,n; - int r,g,b; + int i, n; + int r, g, b; - if (nStartSkip == 0) - goto RLEWordFlippedDoTrasp; + if (nStartSkip == 0) + goto RLEWordFlippedDoTrasp; while (1) { assert(nStartSkip > 0); @@ -1306,11 +1310,11 @@ void RMGfxSourceBuffer8RLEWord::RLEDecompressLineFlipped(uint16 *dst, byte *src, if (n == 0xFFFF) return; - + if (n >= nStartSkip) { dst -= n - nStartSkip; nLength -= n - nStartSkip; - + if (nLength > 0) goto RLEWordFlippedDoAlpha; else @@ -1333,7 +1337,7 @@ void RMGfxSourceBuffer8RLEWord::RLEDecompressLineFlipped(uint16 *dst, byte *src, // DATA n = READ_LE_UINT16(src); src += 2; - + if (n >= nStartSkip) { src += nStartSkip; n -= nStartSkip; @@ -1349,11 +1353,11 @@ RLEWordFlippedDoTrasp: // Via il trasp di merda n = READ_LE_UINT16(src); src += 2; - + // EOL? if (n == 0xFFFF) - return; - + return; + dst -= n; nLength -= n; @@ -1370,15 +1374,15 @@ RLEWordFlippedDoAlpha2: n = nLength; for (i = 0; i < n; i++) { - r=(*dst >> 10) & 0x1F; - g=(*dst >> 5) & 0x1F; - b=*dst & 0x1F; + r = (*dst >> 10) & 0x1F; + g = (*dst >> 5) & 0x1F; + b = *dst & 0x1F; - r=(r >> 2) + (alphaR >> 1); - g=(g >> 2) + (alphaG >> 1); - b=(b >> 2) + (alphaB >> 1); + r = (r >> 2) + (alphaR >> 1); + g = (g >> 2) + (alphaG >> 1); + b = (b >> 2) + (alphaB >> 1); - *dst--=(r << 10) | (g << 5) | b; + *dst-- = (r << 10) | (g << 5) | b; } nLength -= n; @@ -1391,24 +1395,24 @@ RLEWordFlippedDoAlpha2: // Copia la roba n = READ_LE_UINT16(src); src += 2; - + RLEWordFlippedDoCopy2: if (n > nLength) n = nLength; - for (i = 0;i 0); } } /****************************************************************************\ -* Metodi di RMGfxSourceBuffer8RLEWord +* Metodi di RMGfxSourceBuffer8RLEWord \****************************************************************************/ RMGfxSourceBuffer8RLEWordAB::~RMGfxSourceBuffer8RLEWordAB() { @@ -1424,8 +1428,8 @@ void RMGfxSourceBuffer8RLEWordAB::RLEDecompressLine(uint16 *dst, byte *src, int return; } - if (nStartSkip == 0) - goto RLEWordDoTrasp; + if (nStartSkip == 0) + goto RLEWordDoTrasp; while (1) { assert(nStartSkip > 0); @@ -1436,11 +1440,11 @@ void RMGfxSourceBuffer8RLEWordAB::RLEDecompressLine(uint16 *dst, byte *src, int if (n == 0xFFFF) return; - + if (n >= nStartSkip) { dst += n - nStartSkip; nLength -= n - nStartSkip; - + if (nLength > 0) goto RLEWordDoAlpha; else @@ -1463,7 +1467,7 @@ void RMGfxSourceBuffer8RLEWordAB::RLEDecompressLine(uint16 *dst, byte *src, int // DATA n = READ_LE_UINT16(src); src += 2; - + if (n >= nStartSkip) { src += nStartSkip; n -= nStartSkip; @@ -1479,11 +1483,11 @@ RLEWordDoTrasp: // Via il trasp di merda n = READ_LE_UINT16(src); src += 2; - + // EOL? if (n == 0xFFFF) - return; - + return; + dst += n; nLength -= n; @@ -1499,17 +1503,17 @@ RLEWordDoAlpha2: if (n > nLength) n = nLength; - // @@@ NON DOVREBBE ESSERCI!!!!! + // @@@ NON DOVREBBE ESSERCI!!!!! for (i = 0; i < n; i++) { - r=(*dst >> 10) & 0x1F; - g=(*dst >> 5) & 0x1F; - b=*dst & 0x1F; + r = (*dst >> 10) & 0x1F; + g = (*dst >> 5) & 0x1F; + b = *dst & 0x1F; - r=(r >> 2) + (alphaR >> 1); - g=(g >> 2) + (alphaG >> 1); - b=(b >> 2) + (alphaB >> 1); + r = (r >> 2) + (alphaR >> 1); + g = (g >> 2) + (alphaG >> 1); + b = (b >> 2) + (alphaB >> 1); - *dst++=(r<<10)|(g<<5)|b; + *dst++ = (r << 10) | (g << 5) | b; } nLength -= n; @@ -1522,7 +1526,7 @@ RLEWordDoAlpha2: // Copia la roba n = READ_LE_UINT16(src); src += 2; - + RLEWordDoCopy2: if (n > nLength) n = nLength; @@ -1540,14 +1544,14 @@ RLEWordDoCopy2: g = (g >> 1) + (g2 >> 1); b = (b >> 1) + (b2 >> 1); - *dst ++= (r << 10) | (g << 5) | b; + *dst ++ = (r << 10) | (g << 5) | b; src++; } nLength -= n; if (!nLength) return; - + assert(nLength > 0); } @@ -1555,16 +1559,16 @@ RLEWordDoCopy2: /****************************************************************************\ -* Metodi di RMGfxSourceBuffer8AA +* Metodi di RMGfxSourceBuffer8AA \****************************************************************************/ -byte RMGfxSourceBuffer8AA::MegaAABuf[256*1024]; -byte RMGfxSourceBuffer8AA::MegaAABuf2[64*1024]; +byte RMGfxSourceBuffer8AA::MegaAABuf[256 * 1024]; +byte RMGfxSourceBuffer8AA::MegaAABuf2[64 * 1024]; void RMGfxSourceBuffer8AA::PrepareImage(void) { // Richiama il metodo padre RMGfxSourceBuffer::PrepareImage(); - + // Prepara il buffer di antialiasing CalculateAA(); } @@ -1574,44 +1578,44 @@ void RMGfxSourceBuffer8AA::CalculateAA(void) { // Io suxo tu suxi egli suxa noi suxiamo voi suxate essi suxano ---> ANTI ALIASING SUX! // ************************************************************ - int x,y; + int x, y; byte *src, *srcaa; /* Prima passata: cerchiamo i bordi */ Common::fill(MegaAABuf, MegaAABuf + m_dimx * m_dimy, 0); - + src = m_buf; - srcaa=MegaAABuf; - for (y = 0;y < m_dimy; y++) { + srcaa = MegaAABuf; + for (y = 0; y < m_dimy; y++) { for (x = 0; x < m_dimx; x++) { if (*src == 0) { if ((y > 0 && src[-m_dimx] != 0) || - (y 0 && src[-1] != 0) || - (x 0 && src[-1] != 0) || + (x < m_dimx - 1 && src[1] != 0)) *srcaa = 1; } src++; srcaa++; - } + } } src = m_buf; - srcaa=MegaAABuf; + srcaa = MegaAABuf; for (y = 0; y < m_dimy; y++) { for (x = 0; x < m_dimx; x++) { if (*src != 0) { - if ((y > 0 && srcaa[-m_dimx]==1) || - (y 0 && srcaa[-1]==1) || - (x 0 && srcaa[-m_dimx] == 1) || + (y < m_dimy - 1 && srcaa[m_dimx] == 1) || + (x > 0 && srcaa[-1] == 1) || + (x < m_dimx - 1 && srcaa[1] == 1)) *srcaa = 2; } src++; srcaa++; - } + } } if (m_aabuf != NULL) @@ -1631,14 +1635,14 @@ RMGfxSourceBuffer8AA::~RMGfxSourceBuffer8AA() { } void RMGfxSourceBuffer8AA::DrawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { - int x,y; + int x, y; byte *src; uint16 *mybuf; uint16 *buf; int x1, y1, u, v, width, height; int r, g, b; int step; - + // Clippiamo lo sprite x1 = prim->Dst().x1; y1 = prim->Dst().y1; @@ -1652,7 +1656,7 @@ void RMGfxSourceBuffer8AA::DrawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri // Annulliamo il clipping orizzontale - // Flippiamo il clipping + // Flippiamo il clipping if (prim->IsFlipped()) { u = m_dimx - (width + u); x1 = (prim->Dst().x1 + m_dimx - 1) - u; @@ -1660,7 +1664,7 @@ void RMGfxSourceBuffer8AA::DrawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri // width = m_dimx; // x1=prim->Dst().x1; - + // Posizionamoci nel buffer di destinazione buf = bigBuf; buf += y1 * bigBuf.Dimx(); @@ -1673,12 +1677,12 @@ void RMGfxSourceBuffer8AA::DrawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri // Looppone buf += bigBuf.Dimx(); // skippa la prima linea for (y = 1; y < height - 1; y++) { -/* - if (prim->IsFlipped()) - mybuf=&buf[x1+m_dimx-1]; - else -*/ - mybuf=&buf[x1]; + /* + if (prim->IsFlipped()) + mybuf=&buf[x1+m_dimx-1]; + else + */ + mybuf = &buf[x1]; for (x = 0; x < width; x++, mybuf += step) if (m_aabuf[(y + v) * m_dimx + x + u] == 2 && x != 0 && x != width - 1) { @@ -1689,7 +1693,7 @@ void RMGfxSourceBuffer8AA::DrawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri r += GETRED(mybuf[0]); g += GETGREEN(mybuf[0]); b += GETBLUE(mybuf[0]); - + r /= 5; g /= 5; b /= 5; @@ -1698,28 +1702,28 @@ void RMGfxSourceBuffer8AA::DrawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri if (g > 31) g = 31; if (b > 31) b = 31; - mybuf[0]=(r<<10)|(g<<5)|b; + mybuf[0] = (r << 10) | (g << 5) | b; } - + // Skippa alla linea successiva - buf += bigBuf.Dimx(); + buf += bigBuf.Dimx(); } // Posizionamoci nel buffer di destinazione buf = bigBuf; - buf += y1*bigBuf.Dimx(); + buf += y1 * bigBuf.Dimx(); // Looppone - buf+=bigBuf.Dimx(); + buf += bigBuf.Dimx(); for (y = 1; y < height - 1; y++) { -/* - if (prim->IsFlipped()) - mybuf=&buf[x1+m_dimx-1]; - else -*/ - mybuf=&buf[x1]; + /* + if (prim->IsFlipped()) + mybuf=&buf[x1+m_dimx-1]; + else + */ + mybuf = &buf[x1]; - for (x = 0;x < width; x++, mybuf += step) + for (x = 0; x < width; x++, mybuf += step) if (m_aabuf[(y + v) * m_dimx + x + u] == 1 && x != 0 && x != width - 1) { r = GETRED(mybuf[1]) + GETRED(mybuf[-1]) + GETRED(mybuf[-bigBuf.Dimx()]) + GETRED(mybuf[bigBuf.Dimx()]); g = GETGREEN(mybuf[1]) + GETGREEN(mybuf[-1]) + GETGREEN(mybuf[-bigBuf.Dimx()]) + GETGREEN(mybuf[bigBuf.Dimx()]); @@ -1728,7 +1732,7 @@ void RMGfxSourceBuffer8AA::DrawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri r += GETRED(mybuf[0]) * 2; g += GETGREEN(mybuf[0]) * 2; b += GETBLUE(mybuf[0]) * 2; - + r /= 6; g /= 6; b /= 6; @@ -1737,11 +1741,11 @@ void RMGfxSourceBuffer8AA::DrawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri if (g > 31) g = 31; if (b > 31) b = 31; - mybuf[0]=(r<<10)|(g<<5)|b; + mybuf[0] = (r << 10) | (g << 5) | b; } - + // Skippa alla linea successiva - buf += bigBuf.Dimx(); + buf += bigBuf.Dimx(); } } @@ -1761,7 +1765,7 @@ void RMGfxSourceBuffer8AA::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrim /****************************************************************************\ -* Metodi di RMGfxSourceBuffer8RLEAA +* Metodi di RMGfxSourceBuffer8RLEAA \****************************************************************************/ RMGfxSourceBuffer8RLEByteAA::~RMGfxSourceBuffer8RLEByteAA() { @@ -1782,7 +1786,7 @@ void RMGfxSourceBuffer8RLEByteAA::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RM CORO_INVOKE_2(RMGfxSourceBuffer8RLE::Draw, bigBuf, prim); if (GLOBALS.bCfgAntiAlias) - DrawAA(bigBuf,prim); + DrawAA(bigBuf, prim); CORO_END_CODE; } @@ -1791,8 +1795,8 @@ int RMGfxSourceBuffer8RLEByteAA::Init(const byte *buf, int dimx, int dimy, bool return RMGfxSourceBuffer8RLE::Init(buf, dimx, dimy, bLoadPalette); } -void RMGfxSourceBuffer8RLEByteAA::Init(RMDataStream& ds, int dimx, int dimy, bool bLoadPalette) { - RMGfxSourceBuffer8RLE::Init(ds, dimx, dimy,bLoadPalette); +void RMGfxSourceBuffer8RLEByteAA::Init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette) { + RMGfxSourceBuffer8RLE::Init(ds, dimx, dimy, bLoadPalette); if (!bNeedRLECompress) { // Carica la maschera di antialiasing @@ -1820,17 +1824,17 @@ void RMGfxSourceBuffer8RLEWordAA::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RM CORO_INVOKE_2(RMGfxSourceBuffer8RLE::Draw, bigBuf, prim); if (GLOBALS.bCfgAntiAlias) - DrawAA(bigBuf,prim); + DrawAA(bigBuf, prim); CORO_END_CODE; } int RMGfxSourceBuffer8RLEWordAA::Init(byte *buf, int dimx, int dimy, bool bLoadPalette) { - return RMGfxSourceBuffer8RLE::Init(buf, dimx, dimy,bLoadPalette); + return RMGfxSourceBuffer8RLE::Init(buf, dimx, dimy, bLoadPalette); } -void RMGfxSourceBuffer8RLEWordAA::Init(RMDataStream& ds, int dimx, int dimy, bool bLoadPalette) { - RMGfxSourceBuffer8RLE::Init(ds, dimx, dimy,bLoadPalette); +void RMGfxSourceBuffer8RLEWordAA::Init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette) { + RMGfxSourceBuffer8RLE::Init(ds, dimx, dimy, bLoadPalette); if (!bNeedRLECompress) { // Carica la maschera di antialiasing @@ -1841,11 +1845,11 @@ void RMGfxSourceBuffer8RLEWordAA::Init(RMDataStream& ds, int dimx, int dimy, boo /****************************************************************************\ -* Metodi di RMGfxSourceBuffer16 +* Metodi di RMGfxSourceBuffer16 \****************************************************************************/ RMGfxSourceBuffer16::RMGfxSourceBuffer16(bool bTrasp0) { - m_bTrasp0=bTrasp0; + m_bTrasp0 = bTrasp0; } RMGfxSourceBuffer16::~RMGfxSourceBuffer16() { @@ -1854,10 +1858,10 @@ RMGfxSourceBuffer16::~RMGfxSourceBuffer16() { void RMGfxSourceBuffer16::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { int x, y; uint16 *buf = bigBuf; - uint16 *raw = (uint16*)m_buf; + uint16 *raw = (uint16 *)m_buf; int dimx, dimy; - int u,v; - int x1,y1; + int u, v; + int x1, y1; dimx = m_dimx; dimy = m_dimy; @@ -1881,16 +1885,16 @@ void RMGfxSourceBuffer16::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimi if (!Clip2D(x1, y1, u, v, dimx, dimy, true, &bigBuf)) return; - raw += v * m_dimx+u; + raw += v * m_dimx + u; buf += y1 * bigBuf.Dimx() + x1; if (m_bTrasp0) { for (y = 0; y < dimy; y++) { for (x = 0; x < dimx;) { - while (xDst(); - buf += rcDst.y1*bigBuf.Dimx() + rcDst.x1; + buf += rcDst.y1 * bigBuf.Dimx() + rcDst.x1; // Fa il suo bravo loop di put for (j = 0; j < rcDst.Height(); j++) { for (i = 0; i < rcDst.Width(); i++) - *buf ++= wFillColor; + *buf ++ = wFillColor; buf += bigBuf.Dimx() - rcDst.Width(); } diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index dacb66d68c..3fa29e20f6 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -58,103 +58,157 @@ class RMGfxClearTask; // Task */ class RMGfxBuffer { protected: - int m_dimx, m_dimy; - byte *m_buf; + int m_dimx, m_dimy; + byte *m_buf; byte *m_origBuf; - bool m_bUseDDraw; + bool m_bUseDDraw; public: - RMGfxBuffer(); - RMGfxBuffer(int dimx, int dimy, int nBpp, bool bUseDDraw = false); - virtual ~RMGfxBuffer(); + RMGfxBuffer(); + RMGfxBuffer(int dimx, int dimy, int nBpp, bool bUseDDraw = false); + virtual ~RMGfxBuffer(); - // Attributes - int Dimx() { return m_dimx; } - int Dimy() { return m_dimy; } + // Attributes + int Dimx() { + return m_dimx; + } + int Dimy() { + return m_dimy; + } - // Creation - virtual void Create(int dimx, int dimy, int nBpp, bool bUseDDraw = false); - virtual void Destroy(void); + // Creation + virtual void Create(int dimx, int dimy, int nBpp, bool bUseDDraw = false); + virtual void Destroy(void); - // Buffer access - void Lock(void); - void Unlock(void); + // Buffer access + void Lock(void); + void Unlock(void); - // These are valid only if the buffer is locked - operator byte *(); - operator void *(); + // These are valid only if the buffer is locked + operator byte *(); + operator void *(); // Getting the offset for a given Y position void OffsetY(int nLines, int nBpp); }; /** - * Graphics primitive + * Graphics primitive */ class RMGfxPrimitive { public: - RMGfxTask *m_task; + RMGfxTask *m_task; protected: - RMRect m_src; - RMRect m_dst; + RMRect m_src; + RMRect m_dst; -bool m_bStretch; + bool m_bStretch; byte m_bFlag; public: - RMGfxPrimitive() { m_bFlag = 0; m_task = NULL; m_src.SetEmpty(); m_dst.SetEmpty(); } + RMGfxPrimitive() { + m_bFlag = 0; + m_task = NULL; + m_src.SetEmpty(); + m_dst.SetEmpty(); + } - RMGfxPrimitive(RMGfxTask *task) { - m_task = task; m_bFlag = 0; - } + RMGfxPrimitive(RMGfxTask *task) { + m_task = task; + m_bFlag = 0; + } RMGfxPrimitive(RMGfxTask *task, const RMRect &src, RMRect &dst) { - m_task = task; m_src = src; m_dst = dst; m_bFlag = 0; + m_task = task; + m_src = src; + m_dst = dst; + m_bFlag = 0; m_bStretch = (src.Width() != dst.Width() || src.Height() != dst.Height()); - } + } - RMGfxPrimitive(RMGfxTask *task, const RMPoint &src, RMRect &dst) { - m_task = task; m_src.TopLeft() = src; m_dst = dst; m_bFlag = 0; - } + RMGfxPrimitive(RMGfxTask *task, const RMPoint &src, RMRect &dst) { + m_task = task; + m_src.TopLeft() = src; + m_dst = dst; + m_bFlag = 0; + } - RMGfxPrimitive(RMGfxTask *task, const RMPoint &src, RMPoint &dst) { - m_task = task; m_src.TopLeft() = src; m_dst.TopLeft() = dst; m_bFlag = 0; - } + RMGfxPrimitive(RMGfxTask *task, const RMPoint &src, RMPoint &dst) { + m_task = task; + m_src.TopLeft() = src; + m_dst.TopLeft() = dst; + m_bFlag = 0; + } - RMGfxPrimitive(RMGfxTask *task, const RMRect &src, RMPoint &dst) { - m_task = task; m_src = src; m_dst.TopLeft() = dst; m_bFlag = 0; - } + RMGfxPrimitive(RMGfxTask *task, const RMRect &src, RMPoint &dst) { + m_task = task; + m_src = src; + m_dst.TopLeft() = dst; + m_bFlag = 0; + } - RMGfxPrimitive(RMGfxTask *task, const RMRect &dst) { - m_task = task; m_dst = dst; m_src.SetEmpty(); m_bFlag = 0; - } + RMGfxPrimitive(RMGfxTask *task, const RMRect &dst) { + m_task = task; + m_dst = dst; + m_src.SetEmpty(); + m_bFlag = 0; + } - RMGfxPrimitive(RMGfxTask *task, const RMPoint &dst) { - m_task = task; m_dst.TopLeft() = dst; m_src.SetEmpty(); m_bFlag = 0; - } + RMGfxPrimitive(RMGfxTask *task, const RMPoint &dst) { + m_task = task; + m_dst.TopLeft() = dst; + m_src.SetEmpty(); + m_bFlag = 0; + } virtual ~RMGfxPrimitive() { } - void SetFlag(byte bFlag) { m_bFlag=bFlag; } - void SetTask(RMGfxTask *task) { m_task = task; } - void SetSrc(const RMRect &src) { m_src = src; } - void SetSrc(const RMPoint &src) { m_src.TopLeft() = src; } - void SetDst(const RMRect &dst) { m_dst = dst; } - void SetDst(const RMPoint &dst) { m_dst.TopLeft() = dst; } - void SetStrecth(bool bStretch) { m_bStretch = bStretch; } + void SetFlag(byte bFlag) { + m_bFlag = bFlag; + } + void SetTask(RMGfxTask *task) { + m_task = task; + } + void SetSrc(const RMRect &src) { + m_src = src; + } + void SetSrc(const RMPoint &src) { + m_src.TopLeft() = src; + } + void SetDst(const RMRect &dst) { + m_dst = dst; + } + void SetDst(const RMPoint &dst) { + m_dst.TopLeft() = dst; + } + void SetStrecth(bool bStretch) { + m_bStretch = bStretch; + } - bool HaveDst() { return !m_dst.IsEmpty(); } - RMRect &Dst() { return m_dst; } + bool HaveDst() { + return !m_dst.IsEmpty(); + } + RMRect &Dst() { + return m_dst; + } - bool HaveSrc() { return !m_src.IsEmpty(); } - RMRect &Src() { return m_src; } + bool HaveSrc() { + return !m_src.IsEmpty(); + } + RMRect &Src() { + return m_src; + } // Flags - bool IsFlipped() { return m_bFlag&1; } + bool IsFlipped() { + return m_bFlag & 1; + } // Duplicate - virtual RMGfxPrimitive* Duplicate() { return new RMGfxPrimitive(*this); } + virtual RMGfxPrimitive *Duplicate() { + return new RMGfxPrimitive(*this); + } }; @@ -168,16 +222,21 @@ protected: public: // Costruttore standard - RMGfxTask(); + RMGfxTask(); virtual ~RMGfxTask() { } virtual int Priority(); - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) = 0; - virtual void RemoveThis(CORO_PARAM, bool &result); - + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) = 0; + virtual void RemoveThis(CORO_PARAM, bool &result); + // Registration - virtual void Register(void) { m_nInList++; } - virtual void Unregister(void) { m_nInList--; assert(m_nInList >= 0); } + virtual void Register(void) { + m_nInList++; + } + virtual void Unregister(void) { + m_nInList--; + assert(m_nInList >= 0); + } }; @@ -187,7 +246,7 @@ public: class RMGfxTaskSetPrior : public RMGfxTask { public: virtual ~RMGfxTaskSetPrior() { } - void SetPriority(int nPrior); + void SetPriority(int nPrior); }; @@ -199,7 +258,7 @@ public: virtual ~RMGfxClearTask() { } int Priority(); - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); virtual void RemoveThis(CORO_PARAM, bool &result); }; @@ -207,7 +266,7 @@ public: /** * Task that draws a coloured box */ -class RMGfxBox : public RMGfxTaskSetPrior { +class RMGfxBox : public RMGfxTaskSetPrior { protected: uint16 wFillColor; @@ -225,20 +284,22 @@ public: */ class RMGfxSourceBuffer : public virtual RMGfxBuffer, public RMGfxTaskSetPrior { public: - // Carica i dati della surface a basso livello - virtual int Init(uint32 resID, int dimx, int dimy, bool bLoadPalette = false); - virtual int Init(const byte *buf, int dimx, int dimy, bool bLoadPalette = false); + // Carica i dati della surface a basso livello + virtual int Init(uint32 resID, int dimx, int dimy, bool bLoadPalette = false); + virtual int Init(const byte *buf, int dimx, int dimy, bool bLoadPalette = false); virtual void Init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette = false); - + virtual ~RMGfxSourceBuffer(); protected: virtual void PrepareImage(void); bool Clip2D(int &x1, int &y1, int &u, int &v, int &width, int &height, bool bUseSrc, RMGfxTargetBuffer *buf); - void OffsetY(int nLines) { RMGfxBuffer::OffsetY(nLines,Bpp()); } + void OffsetY(int nLines) { + RMGfxBuffer::OffsetY(nLines, Bpp()); + } public: - virtual int Bpp() = 0; + virtual int Bpp() = 0; }; @@ -249,17 +310,17 @@ class RMGfxSourceBuffer16 : public RMGfxSourceBuffer { protected: virtual void PrepareImage(void); bool m_bTrasp0; - + public: - RMGfxSourceBuffer16(bool bUseTrasp = false); - RMGfxSourceBuffer16(int dimx, int dimy, bool bUseDDraw = false); + RMGfxSourceBuffer16(bool bUseTrasp = false); + RMGfxSourceBuffer16(int dimx, int dimy, bool bUseDDraw = false); virtual ~RMGfxSourceBuffer16(); // Inizializzazione void Create(int dimx, int dimy, bool bUseDDraw = false); - int Bpp(); - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + int Bpp(); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); }; @@ -279,8 +340,8 @@ public: virtual ~RMGfxSourceBufferPal(); virtual int Init(const byte *buf, int dimx, int dimy, bool bLoadPalette = false); - virtual void Init(RMDataStream& ds, int dimx, int dimy, bool bLoadPalette = false); - + virtual void Init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette = false); + int LoadPaletteWA(uint32 resID, bool bSwapped = false); int LoadPaletteWA(const byte *buf, bool bSwapped = false); int LoadPalette(uint32 resID); @@ -294,7 +355,7 @@ public: class RMGfxSourceBuffer8 : public RMGfxSourceBufferPal { protected: bool m_bTrasp0; - + public: RMGfxSourceBuffer8(bool bTrasp0 = true); RMGfxSourceBuffer8(int dimx, int dimy, bool bUseDDraw = false); @@ -304,7 +365,7 @@ public: void Create(int dimx, int dimy, bool bUseDDraw = false); int Bpp(); - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer& bigBuf, RMGfxPrimitive *prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); }; @@ -333,7 +394,7 @@ protected: protected: static byte MegaRLEBuf[]; - + virtual void RLEWriteTrasp(byte *&cur, int rep) = 0; virtual void RLEWriteData(byte *&cur, int rep, byte *src) = 0; virtual void RLEWriteEOL(byte *&cur) = 0; @@ -343,18 +404,18 @@ protected: // Perform image compression in RLE void CompressRLE(void); - + protected: // Overriding initialization methods virtual void PrepareImage(void); - virtual void PreparePalette(void); + virtual void PreparePalette(void); public: RMGfxSourceBuffer8RLE(); virtual ~RMGfxSourceBuffer8RLE(); // Overload of the initialization method - virtual void Init(RMDataStream& ds, int dimx, int dimy, bool bLoadPalette = false); + virtual void Init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette = false); virtual int Init(const byte *buf, int dimx, int dimy, bool bLoadPalette = false); // Draw image with RLE decompression @@ -438,7 +499,7 @@ public: // Overloaded initialisation methods virtual void Init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette = false); - virtual int Init(const byte *buf, int dimx, int dimy, bool bLoadPalette = false); + virtual int Init(const byte *buf, int dimx, int dimy, bool bLoadPalette = false); virtual ~RMGfxSourceBuffer8RLEByteAA(); }; @@ -451,8 +512,8 @@ public: virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Overloaded initialisation method - virtual void Init(RMDataStream& ds, int dimx, int dimy, bool bLoadPalette = false); - virtual int Init(byte *buf, int dimx, int dimy, bool bLoadPalette = false); + virtual void Init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette = false); + virtual int Init(byte *buf, int dimx, int dimy, bool bLoadPalette = false); virtual ~RMGfxSourceBuffer8RLEWordAA(); }; @@ -463,14 +524,14 @@ public: */ class RMGfxSourceBuffer4 : public RMGfxSourceBufferPal { public: - RMGfxSourceBuffer4(); - RMGfxSourceBuffer4(int dimx, int dimy, bool bUseDDraw = false); + RMGfxSourceBuffer4(); + RMGfxSourceBuffer4(int dimx, int dimy, bool bUseDDraw = false); // Initialisation void Create(int dimx, int dimy, bool bUseDDraw = false); - int Bpp(); - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + int Bpp(); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); }; @@ -479,14 +540,16 @@ public: */ class RMGfxTargetBuffer : public virtual RMGfxBuffer { private: -static RMGfxClearTask taskClear; + static RMGfxClearTask taskClear; struct OTList { - RMGfxPrimitive* prim; - OTList* next; + RMGfxPrimitive *prim; + OTList *next; OTList(); - OTList(RMGfxPrimitive* pr) { prim=pr; } + OTList(RMGfxPrimitive *pr) { + prim = pr; + } }; private: @@ -508,15 +571,21 @@ public: // Adds a task to clear the screen void AddClearTask(void); - operator byte *() { return m_buf; } - operator void *() { return (void *)m_buf; } - operator uint16 *() { + operator byte *() { + return m_buf; + } + operator void *() { + return (void *)m_buf; + } + operator uint16 *() { // FIXME: This may not be endian safe - return (uint16 *)m_buf; + return (uint16 *)m_buf; } // Offseting buffer - void OffsetY(int nLines) { RMGfxBuffer::OffsetY(nLines, 16); } + void OffsetY(int nLines) { + RMGfxBuffer::OffsetY(nLines, 16); + } }; @@ -525,11 +594,11 @@ public: */ class RMGfxWoodyBuffer: public RMGfxSourceBuffer16, public RMGfxTargetBuffer { public: - RMGfxWoodyBuffer(); - RMGfxWoodyBuffer(int dimx, int dimy, bool bUseDDraw = false); + RMGfxWoodyBuffer(); + RMGfxWoodyBuffer(int dimx, int dimy, bool bUseDDraw = false); virtual ~RMGfxWoodyBuffer(); - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); }; } // End of namespace Tony diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index a2b58f660e..384e80f209 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -68,9 +68,9 @@ RMGfxEngine::RMGfxEngine() { m_nCurLoc = 0; m_curAction = TA_GOTO; m_curActionObj = 0; - m_nWipeType = 0; + m_nWipeType = 0; m_hWipeEvent = 0; - m_nWipeStep = 0; + m_nWipeStep = 0; m_bMustEnterMenu = false; m_bWiping = false; m_bGUIOption = false; @@ -90,7 +90,7 @@ RMGfxEngine::~RMGfxEngine() { void RMGfxEngine::OpenOptionScreen(CORO_PARAM, int type) { CORO_BEGIN_CONTEXT; - bool bRes; + bool bRes; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -120,9 +120,9 @@ void RMGfxEngine::OpenOptionScreen(CORO_PARAM, int type) { m_point.SetCustomPointer(NULL); EnableMouse(); _vm->GrabThumbnail(); - + // Esce la IDLE onde evitare la morte prematura in caricamento - m_bMustEnterMenu = true; + m_bMustEnterMenu = true; if (type == 1 || type == 2) { GLOBALS.bIdleExited = true; } else { @@ -144,7 +144,7 @@ void RMGfxEngine::DoFrame(CORO_PARAM, bool bDrawLocation) { CORO_BEGIN_CODE(_ctx); g_system->lockMutex(csMainLoop); - + // Poll dei dispositivi di input m_input.Poll(); @@ -153,8 +153,8 @@ void RMGfxEngine::DoFrame(CORO_PARAM, bool bDrawLocation) { m_bMustEnterMenu = false; GLOBALS.bIdleExited = false; } - - if (m_bOption) { + + if (m_bOption) { CORO_INVOKE_1(m_opt.DoFrame, &m_input); m_bOption = !m_opt.IsClosing(); if (!m_bOption) { @@ -177,33 +177,32 @@ void RMGfxEngine::DoFrame(CORO_PARAM, bool bDrawLocation) { // ************** if (m_input.MouseLeftClicked()/* && m_itemName.IsItemSelected()*/) { // Left click attiva il combine, se siamo su un oggetto - if (m_inv.LeftClick(m_input.MousePos(),m_curActionObj)) { + if (m_inv.LeftClick(m_input.MousePos(), m_curActionObj)) { m_curAction = TA_COMBINE; m_point.SetAction(m_curAction); } - } - else + } else - // CLICK DESTRO - // ************ - if (m_input.MouseRightClicked()) { - if(m_itemName.IsItemSelected()) { - m_curActionObj=0; - m_inv.RightClick(m_input.MousePos()); + // CLICK DESTRO + // ************ + if (m_input.MouseRightClicked()) { + if (m_itemName.IsItemSelected()) { + m_curActionObj = 0; + m_inv.RightClick(m_input.MousePos()); + } else + m_inv.RightClick(m_input.MousePos()); } else - m_inv.RightClick(m_input.MousePos()); - } else - // RILASCIO DESTRO - // *************** - if (m_input.MouseRightReleased()) { - if (m_inv.RightRelease(m_input.MousePos(), m_curAction)) { - CORO_INVOKE_3(m_tony.MoveAndDoAction, m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), m_curAction); + // RILASCIO DESTRO + // *************** + if (m_input.MouseRightReleased()) { + if (m_inv.RightRelease(m_input.MousePos(), m_curAction)) { + CORO_INVOKE_3(m_tony.MoveAndDoAction, m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), m_curAction); - m_curAction = TA_GOTO; - m_point.SetAction(m_curAction); - } - } + m_curAction = TA_GOTO; + m_point.SetAction(m_curAction); + } + } } else { // Menu Opzioni // ************ @@ -236,7 +235,7 @@ void RMGfxEngine::DoFrame(CORO_PARAM, bool bDrawLocation) { else if (m_itemName.GetSelectedItem() != NULL) CORO_INVOKE_4(m_tony.MoveAndDoAction, m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), TA_COMBINE, m_curActionObj); } - + if (m_curAction == TA_COMBINE) { m_inv.EndCombine(); m_point.SetSpecialPointer(RMPointer::PTR_NONE); @@ -267,13 +266,13 @@ SKIPCLICKSINISTRO: m_inter.Clicked(m_input.MousePos()); } } - + // RILASCIO DESTRO // *************** if (m_input.MouseRightReleased()) { if (m_bGUIInterface) { - if (m_inter.Released(m_input.MousePos(),m_curAction)) { + if (m_inter.Released(m_input.MousePos(), m_curAction)) { m_point.SetAction(m_curAction); CORO_INVOKE_3(m_tony.MoveAndDoAction, m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), m_curAction); @@ -287,7 +286,7 @@ SKIPCLICKSINISTRO: // Aggiorna il nome sotto il puntatore del mouse m_itemName.SetMouseCoord(m_input.MousePos()); if (!m_inter.Active() && !m_inv.MiniActive()) - CORO_INVOKE_4(m_itemName.DoFrame, m_bigBuf, m_loc, m_point, m_inv); + CORO_INVOKE_4(m_itemName.DoFrame, m_bigBuf, m_loc, m_point, m_inv); } // Inventario & interfaccia @@ -297,7 +296,7 @@ SKIPCLICKSINISTRO: // Anima Tony CORO_INVOKE_2(m_tony.DoFrame, &m_bigBuf, m_nCurLoc); - + // Aggiorna lo scrolling per tenere Tony dentro lo schermo if (m_tony.MustUpdateScrolling() && m_bLocationLoaded) { RMPoint showThis = m_tony.Position(); @@ -323,31 +322,31 @@ SKIPCLICKSINISTRO: // Wipe if (m_bWiping) { switch (m_nWipeType) { - case 1: - if (!(m_rcWipeEllipse.bottom - m_rcWipeEllipse.top >= FSTEP * 2)) { - CoroScheduler.setEvent(m_hWipeEvent); - m_nWipeType = 3; - break; - } - - m_rcWipeEllipse.top += FSTEP; - m_rcWipeEllipse.left += FSTEP; - m_rcWipeEllipse.right -= FSTEP; - m_rcWipeEllipse.bottom -= FSTEP; + case 1: + if (!(m_rcWipeEllipse.bottom - m_rcWipeEllipse.top >= FSTEP * 2)) { + CoroScheduler.setEvent(m_hWipeEvent); + m_nWipeType = 3; break; + } - case 2: - if (!(m_rcWipeEllipse.bottom - m_rcWipeEllipse.top < 480 - FSTEP)) { - CoroScheduler.setEvent(m_hWipeEvent); - m_nWipeType = 3; - break; - } + m_rcWipeEllipse.top += FSTEP; + m_rcWipeEllipse.left += FSTEP; + m_rcWipeEllipse.right -= FSTEP; + m_rcWipeEllipse.bottom -= FSTEP; + break; - m_rcWipeEllipse.top -= FSTEP; - m_rcWipeEllipse.left -= FSTEP; - m_rcWipeEllipse.right += FSTEP; - m_rcWipeEllipse.bottom += FSTEP; + case 2: + if (!(m_rcWipeEllipse.bottom - m_rcWipeEllipse.top < 480 - FSTEP)) { + CoroScheduler.setEvent(m_hWipeEvent); + m_nWipeType = 3; break; + } + + m_rcWipeEllipse.top -= FSTEP; + m_rcWipeEllipse.left -= FSTEP; + m_rcWipeEllipse.right += FSTEP; + m_rcWipeEllipse.bottom += FSTEP; + break; } } @@ -371,7 +370,7 @@ void RMGfxEngine::ItemIrq(uint32 dwItem, int nPattern, int nStatus) { if (nPattern != -1) { if (GLOBALS.bPatIrqFreeze) MainFreeze(); - item->SetPattern(nPattern,true); + item->SetPattern(nPattern, true); if (GLOBALS.bPatIrqFreeze) MainUnfreeze(); } @@ -382,41 +381,41 @@ void RMGfxEngine::ItemIrq(uint32 dwItem, int nPattern, int nStatus) { } /* - // WINBUG: This is a special case for the file open/save dialog, - // which sometimes pumps while it is coming up but before it has - // disabled the main window. - HWND hWndFocus = ::GetFocus(); - bool bEnableParent = false; - m_ofn.hwndOwner = PreModal(); - AfxUnhookWindowCreate(); - if (m_ofn.hwndOwner != NULL && ::IsWindowEnabled(m_ofn.hwndOwner)) { - bEnableParent = true; - ::EnableWindow(m_ofn.hwndOwner, false); - } - - _AFX_THREAD_STATE* pThreadState = AfxGetThreadState(); - ASSERT(pThreadState->m_pAlternateWndInit == NULL); - - if (m_ofn.Flags & OFN_EXPLORER) - pThreadState->m_pAlternateWndInit = this; - else - AfxHookWindowCreate(this); - - int nResult; - if (m_bOpenFileDialog) - nResult = ::GetOpenFileName(&m_ofn); - else - nResult = ::GetSaveFileName(&m_ofn); - - if (nResult) - ASSERT(pThreadState->m_pAlternateWndInit == NULL); - pThreadState->m_pAlternateWndInit = NULL; - - // WINBUG: Second part of special case for file open/save dialog. - if (bEnableParent) - ::EnableWindow(m_ofn.hwndOwner, true); - if (::IsWindow(hWndFocus)) - ::SetFocus(hWndFocus); + // WINBUG: This is a special case for the file open/save dialog, + // which sometimes pumps while it is coming up but before it has + // disabled the main window. + HWND hWndFocus = ::GetFocus(); + bool bEnableParent = false; + m_ofn.hwndOwner = PreModal(); + AfxUnhookWindowCreate(); + if (m_ofn.hwndOwner != NULL && ::IsWindowEnabled(m_ofn.hwndOwner)) { + bEnableParent = true; + ::EnableWindow(m_ofn.hwndOwner, false); + } + + _AFX_THREAD_STATE* pThreadState = AfxGetThreadState(); + ASSERT(pThreadState->m_pAlternateWndInit == NULL); + + if (m_ofn.Flags & OFN_EXPLORER) + pThreadState->m_pAlternateWndInit = this; + else + AfxHookWindowCreate(this); + + int nResult; + if (m_bOpenFileDialog) + nResult = ::GetOpenFileName(&m_ofn); + else + nResult = ::GetSaveFileName(&m_ofn); + + if (nResult) + ASSERT(pThreadState->m_pAlternateWndInit == NULL); + pThreadState->m_pAlternateWndInit = NULL; + + // WINBUG: Second part of special case for file open/save dialog. + if (bEnableParent) + ::EnableWindow(m_ofn.hwndOwner, true); + if (::IsWindow(hWndFocus)) + ::SetFocus(hWndFocus); */ @@ -427,46 +426,46 @@ void RMGfxEngine::SelectLocation(const RMPoint &ptTonyStart, const RMPoint &star // @@@ Con TonyStart=-1,-1 allora usa la posizione scritta nella locazione - // Sceglie la locazione - ZeroMemory(lpszFileName,512); - ZeroMemory(&ofn,sizeof(ofn)); - ofn.lStructSize=sizeof(ofn); - ofn.hwndOwner=NULL; - ofn.lpstrFilter="Locazione (*.LOC)\0*.LOC\0Locazione ottimizzata (*.LOX)\0*.LOX\0Tutti i files (*.*)\0*.*\0"; - ofn.lpstrCustomFilter=NULL; - ofn.nFilterIndex=1; - ofn.lpstrFile=lpszFileName; - ofn.nMaxFile=512; - ofn.lpstrInitialDir=NULL; - ofn.lpstrTitle="Load Location"; - ofn.Flags=OFN_FILEMUSTEXIST|OFN_HIDEREADONLY|OFN_PATHMUSTEXIST; - - if (!GetOpenFileName(&ofn)) + // Sceglie la locazione + ZeroMemory(lpszFileName, 512); + ZeroMemory(&ofn, sizeof(ofn)); + ofn.lStructSize = sizeof(ofn); + ofn.hwndOwner = NULL; + ofn.lpstrFilter = "Locazione (*.LOC)\0*.LOC\0Locazione ottimizzata (*.LOX)\0*.LOX\0Tutti i files (*.*)\0*.*\0"; + ofn.lpstrCustomFilter = NULL; + ofn.nFilterIndex = 1; + ofn.lpstrFile = lpszFileName; + ofn.nMaxFile = 512; + ofn.lpstrInitialDir = NULL; + ofn.lpstrTitle = "Load Location"; + ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST; + + if (!GetOpenFileName(&ofn)) ASSERT(0); // Carica la locazione m_loc.Load(lpszFileName); m_bLocationLoaded = true; - m_nCurLoc=m_loc.TEMPGetNumLoc(); - - if (ptTonyStart.x==-1 && ptTonyStart.y==-1) - InitForNewLocation(m_loc.TEMPGetNumLoc(),m_loc.TEMPGetTonyStart(),RMPoint(-1,-1)); + m_nCurLoc = m_loc.TEMPGetNumLoc(); + + if (ptTonyStart.x == -1 && ptTonyStart.y == -1) + InitForNewLocation(m_loc.TEMPGetNumLoc(), m_loc.TEMPGetTonyStart(), RMPoint(-1, -1)); else - InitForNewLocation(m_loc.TEMPGetNumLoc(),ptTonyStart,start); + InitForNewLocation(m_loc.TEMPGetNumLoc(), ptTonyStart, start); #endif } void RMGfxEngine::InitForNewLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { if (start.x == -1 || start.y == -1) { - start.x = ptTonyStart.x-RM_SX / 2; - start.y = ptTonyStart.y-RM_SY / 2; + start.x = ptTonyStart.x - RM_SX / 2; + start.y = ptTonyStart.y - RM_SY / 2; } m_loc.SetScrollPosition(start); - - if (ptTonyStart.x==0 && ptTonyStart.y == 0) { + + if (ptTonyStart.x == 0 && ptTonyStart.y == 0) { } else { - m_tony.SetPosition(ptTonyStart,nLoc); + m_tony.SetPosition(ptTonyStart, nLoc); m_tony.SetScrollPosition(start); } @@ -484,10 +483,10 @@ uint32 RMGfxEngine::LoadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { bool bLoaded; int i; - m_nCurLoc=nLoc; + m_nCurLoc = nLoc; bLoaded = false; - for (i=0; i < 5; i++) { + for (i = 0; i < 5; i++) { // Retry sul loading della locazione RMRes res(m_nCurLoc); if (!res.IsValid()) @@ -501,13 +500,13 @@ uint32 RMGfxEngine::LoadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { } #endif m_loc.Load(res); - InitForNewLocation(nLoc,ptTonyStart,start); + InitForNewLocation(nLoc, ptTonyStart, start); bLoaded = true; break; } - + if (!bLoaded) - SelectLocation(ptTonyStart,start); + SelectLocation(ptTonyStart, start); if (m_bOption) m_opt.ReInit(m_bigBuf); @@ -520,11 +519,11 @@ uint32 RMGfxEngine::LoadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { void RMGfxEngine::UnloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result) { CORO_BEGIN_CONTEXT; - uint32 h; + uint32 h; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - + // Scarica tutta la memoria della locazione CORO_INVOKE_2(mpalEndIdlePoll, m_nCurLoc, NULL); @@ -538,7 +537,7 @@ void RMGfxEngine::UnloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result) { MainFreeze(); m_bLocationLoaded = false; - + m_bigBuf.ClearOT(); m_loc.Unload(); @@ -549,19 +548,19 @@ void RMGfxEngine::UnloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result) { } void RMGfxEngine::Init(/*HINSTANCE hInst*/) { -/* - //RECUPERARE UNA LOCAZIONE: - - RMRes res(5); - ASSERT(res.IsValid()); - FILE *f; - f=fopen("c:\\code\\rm\\new\\pippo.loc","wb"); - fwrite(res,1,5356900,f); - fclose(f); -*/ + /* + //RECUPERARE UNA LOCAZIONE: + + RMRes res(5); + ASSERT(res.IsValid()); + FILE *f; + f=fopen("c:\\code\\rm\\new\\pippo.loc","wb"); + fwrite(res,1,5356900,f); + fclose(f); + */ // Schermata di loading - RMResRaw *raw; + RMResRaw *raw; RMGfxSourceBuffer16 *load = NULL; INIT_GFX16_FROMRAW(20038, load); m_bigBuf.AddPrim(new RMGfxPrimitive(load)); @@ -592,8 +591,8 @@ void RMGfxEngine::Init(/*HINSTANCE hInst*/) { // Inizializza la funzione di IRQ di Item per l'MPAL GLOBALS.GfxEngine = this; mpalInstallItemIrq(ItemIrq); - - // Inizializza DirectInput + + // Inizializza DirectInput m_input.Init(/*hInst*/); // Inizializza il puntatore del mouse @@ -607,25 +606,25 @@ void RMGfxEngine::Init(/*HINSTANCE hInst*/) { m_inv.Init(); m_inter.Init(); - // Carica la locazione e setta le priorit @@@@@ + // Carica la locazione e setta le priorit @@@@@ m_bLocationLoaded = false; -/* - m_nCurLoc=1; - RMRes res(m_nCurLoc); - m_loc.Load(res); - m_loc.SetPriority(1); - m_tony.SetPosition(RMPoint(201,316),1); - //m_tony.SetPosition(RMPoint(522,305),2); - //m_tony.SetPosition(RMPoint(158,398),4); - m_tony.SetPattern(m_tony.PAT_STANDDOWN); - m_curAction=TA_GOTO; -*/ + /* + m_nCurLoc=1; + RMRes res(m_nCurLoc); + m_loc.Load(res); + m_loc.SetPriority(1); + m_tony.SetPosition(RMPoint(201,316),1); + //m_tony.SetPosition(RMPoint(522,305),2); + //m_tony.SetPosition(RMPoint(158,398),4); + m_tony.SetPattern(m_tony.PAT_STANDDOWN); + m_curAction=TA_GOTO; + */ EnableInput(); // Inizio del gioco //m_tony.ExecuteAction(4,1,0); //PREGAME - - m_tony.ExecuteAction(20,1,0); + + m_tony.ExecuteAction(20, 1, 0); // theLog << "Seleziona la locazione\n"; //LoadLocation(1,RMPoint(201,316),RMPoint(-1,-1)); @@ -639,9 +638,9 @@ void RMGfxEngine::Init(/*HINSTANCE hInst*/) { //LoadLocation(25,RMPoint(221,415),RMPoint(-1,-1)); //LoadLocation(16,RMPoint(111,438),RMPoint(-1,-1)); //LoadLocation(60,RMPoint(18,302),RMPoint(-1,-1)); - + // CASTELLO - + //LoadLocation(40,RMPoint(233,441),RMPoint(-1,-1)); } @@ -716,14 +715,14 @@ void RMGfxEngine::SaveState(const char *fn, byte *curThumb, const char *name, bo mpalSaveState(state); thumbsize = 160 * 120 * 2; - + buf[0] = 'R'; buf[1] = 'M'; buf[2] = 'S'; buf[3] = TONY_SAVEGAME_VERSION; f = g_system->getSavefileManager()->openForSaving(fn); - if (f == NULL) + if (f == NULL) return; f->write(buf, 4); @@ -763,13 +762,13 @@ void RMGfxEngine::SaveState(const char *fn, byte *curThumb, const char *name, bo // New Ver5 bool bStat; - + // Saves the state of the shepherdess and show yourself bStat = m_tony.GetPastorella(); f->writeByte(bStat); bStat = m_inter.GetPalesati(); f->writeByte(bStat); - + // Save the chars CharsSaveAll(f); @@ -805,20 +804,20 @@ void RMGfxEngine::SaveState(const char *fn, byte *curThumb, const char *name, bo void RMGfxEngine::LoadState(CORO_PARAM, const char *fn) { // PROBLEMA: Bisognerebbe caricare la locazione in un thread a parte per fare la OnEnter ... CORO_BEGIN_CONTEXT; - Common::InSaveFile *f; - byte *state, *statecmp; - uint size, sizecmp; - char buf[4]; - RMPoint tp; - int loc; - int ver; - int i; + Common::InSaveFile *f; + byte *state, *statecmp; + uint size, sizecmp; + char buf[4]; + RMPoint tp; + int loc; + int ver; + int i; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); _ctx->f = g_system->getSavefileManager()->openForLoading(fn); - if (_ctx->f == NULL) + if (_ctx->f == NULL) return; _ctx->f->read(_ctx->buf, 4); @@ -826,14 +825,14 @@ void RMGfxEngine::LoadState(CORO_PARAM, const char *fn) { delete _ctx->f; return; } - + _ctx->ver = _ctx->buf[3]; - + if (_ctx->ver == 0 || _ctx->ver > TONY_SAVEGAME_VERSION) { delete _ctx->f; return; } - + if (_ctx->ver >= 0x3) { // There is a thumbnail. If the version is between 5 and 7, it's compressed if ((_ctx->ver >= 0x5) && (_ctx->ver <= 0x7)) { @@ -854,7 +853,7 @@ void RMGfxEngine::LoadState(CORO_PARAM, const char *fn) { _ctx->f->seek(1, SEEK_CUR); } - if (_ctx->ver >= 0x4) { // Skip the savegame name, which serves no purpose + if (_ctx->ver >= 0x4) { // Skip the savegame name, which serves no purpose _ctx->i = _ctx->f->readByte(); _ctx->f->seek(_ctx->i, SEEK_CUR); } @@ -870,7 +869,7 @@ void RMGfxEngine::LoadState(CORO_PARAM, const char *fn) { _ctx->state = new byte[_ctx->size]; _ctx->statecmp = new byte[_ctx->sizecmp]; _ctx->f->read(_ctx->statecmp, _ctx->sizecmp); - lzo1x_decompress(_ctx->statecmp,_ctx->sizecmp,_ctx->state,&_ctx->size); + lzo1x_decompress(_ctx->statecmp, _ctx->sizecmp, _ctx->state, &_ctx->size); delete[] _ctx->statecmp; } else { // Read uncompressed MPAL data @@ -888,7 +887,7 @@ void RMGfxEngine::LoadState(CORO_PARAM, const char *fn) { m_inv.LoadState(_ctx->state); delete[] _ctx->state; - if (_ctx->ver >= 0x2) { // Versione 2: box please + if (_ctx->ver >= 0x2) { // Versione 2: box please _ctx->size = _ctx->f->readUint32LE(); _ctx->state = new byte[_ctx->size]; _ctx->f->read(_ctx->state, _ctx->size); @@ -897,13 +896,13 @@ void RMGfxEngine::LoadState(CORO_PARAM, const char *fn) { } if (_ctx->ver >= 5) { - // Versione 5: + // Versione 5: bool bStat = false; - + bStat = _ctx->f->readByte(); - m_tony.SetPastorella(bStat); + m_tony.SetPastorella(bStat); bStat = _ctx->f->readByte(); - m_inter.SetPalesati(bStat); + m_inter.SetPalesati(bStat); CharsLoadAll(_ctx->f); } @@ -939,10 +938,10 @@ void RMGfxEngine::LoadState(CORO_PARAM, const char *fn) { delete _ctx->f; CORO_INVOKE_2(UnloadLocation, false, NULL); - LoadLocation(_ctx->loc,_ctx->tp,RMPoint(-1, -1)); + LoadLocation(_ctx->loc, _ctx->tp, RMPoint(-1, -1)); m_tony.SetPattern(RMTony::PAT_STANDRIGHT); MainUnfreeze(); - + // On older versions, need to an enter action if (_ctx->ver < 5) mpalQueryDoAction(0, _ctx->loc, 0); @@ -970,8 +969,8 @@ void RMGfxEngine::PauseSound(bool bPause) { void RMGfxEngine::InitWipe(int type) { m_bWiping = true; - m_nWipeType=type; - m_nWipeStep=0; + m_nWipeType = type; + m_nWipeStep = 0; if (m_nWipeType == 1) m_rcWipeEllipse = Common::Rect(80, 0, 640 - 80, 480); diff --git a/engines/tony/gfxengine.h b/engines/tony/gfxengine.h index 2aae0b6ea6..24deb47ec4 100644 --- a/engines/tony/gfxengine.h +++ b/engines/tony/gfxengine.h @@ -44,7 +44,7 @@ namespace Tony { class RMGfxEngine { private: - RMGfxTargetBuffer m_bigBuf; + RMGfxTargetBuffer m_bigBuf; RMInput m_input; RMPointer m_point; RMLocation m_loc; @@ -62,7 +62,7 @@ private: int m_nCurLoc; RMTonyAction m_curAction; - int m_curActionObj; + int m_curActionObj; OSystem::MutexRef csMainLoop; int m_nWipeType; @@ -80,8 +80,8 @@ public: bool m_bGUIInterface; bool m_bGUIInventory; public: - RMGfxEngine(); - virtual ~RMGfxEngine(); + RMGfxEngine(); + virtual ~RMGfxEngine(); // Draw the next frame void DoFrame(CORO_PARAM, bool bDrawLocation); @@ -109,14 +109,20 @@ public: void EnableMouse(void); void DisableMouse(void); - operator byte *() { return (byte *)m_bigBuf; } - RMInput &GetInput() { return m_input; } + operator byte *() { + return (byte *)m_bigBuf; + } + RMInput &GetInput() { + return m_input; + } // Link to the custom function list void InitCustomDll(void); // Link to graphic task - void LinkGraphicTask(RMGfxTask *task) { m_bigBuf.AddPrim(new RMGfxPrimitive(task)); }; + void LinkGraphicTask(RMGfxTask *task) { + m_bigBuf.AddPrim(new RMGfxPrimitive(task)); + }; // Manage a location uint32 LoadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start); @@ -131,7 +137,7 @@ public: void LoadState(CORO_PARAM, const char *fn); // Selects a location - void SelectLocation(const RMPoint &ptTonyStart = RMPoint(-1, -1), const RMPoint &start = RMPoint(-1,-1)); + void SelectLocation(const RMPoint &ptTonyStart = RMPoint(-1, -1), const RMPoint &start = RMPoint(-1, -1)); // Pauses sound void PauseSound(bool bPause); @@ -141,7 +147,9 @@ public: void CloseWipe(void); void WaitWipeEnd(CORO_PARAM); - void SetPalesati(bool bpal) { m_inter.SetPalesati(bpal); } + void SetPalesati(bool bpal) { + m_inter.SetPalesati(bpal); + } }; } // End of namespace Tony diff --git a/engines/tony/globals.h b/engines/tony/globals.h index d82e0fcaf2..1c2835cf40 100644 --- a/engines/tony/globals.h +++ b/engines/tony/globals.h @@ -150,12 +150,12 @@ struct ChangedHotspotStruct { \****************************************************************************/ typedef struct { - int nCf; + int nCf; - int arg1, arg2, arg3, arg4; + int arg1, arg2, arg3, arg4; } CFCALL; -typedef CFCALL* LPCFCALL; -typedef LPCFCALL* LPLPCFCALL; +typedef CFCALL *LPCFCALL; +typedef LPCFCALL *LPLPCFCALL; /****************************************************************************\ @@ -201,9 +201,9 @@ public: bool bCfgSFX; int nCfgTonySpeed; int nCfgTextSpeed; - int nCfgDubbingVolume; - int nCfgMusicVolume; - int nCfgSFXVolume; + int nCfgDubbingVolume; + int nCfgMusicVolume; + int nCfgSFXVolume; bool bSkipSfxNoLoop; bool bIdleExited; bool bNoOcchioDiBue; @@ -219,18 +219,18 @@ public: RMInput *Input; RMGfxEngine *GfxEngine; - uint32 (*LoadLocation)(int, RMPoint, RMPoint start); + uint32(*LoadLocation)(int, RMPoint, RMPoint start); void (*UnloadLocation)(CORO_PARAM, bool bDoOnExit, uint32 *result); void (*LinkGraphicTask)(RMGfxTask *task); - void (*Freeze)(void); - void (*Unfreeze)(void); - void (*WaitFrame)(CORO_PARAM); + void (*Freeze)(void); + void (*Unfreeze)(void); + void (*WaitFrame)(CORO_PARAM); void (*PlayMusic)(int nChannel, const char *fileName, int nFX, bool bLoop, int nSync); - void (*WaitWipeEnd)(CORO_PARAM); - void (*CloseWipe)(void); - void (*InitWipe)(int type); - void (*EnableGUI)(void); - void (*DisableGUI)(void); + void (*WaitWipeEnd)(CORO_PARAM); + void (*CloseWipe)(void); + void (*InitWipe)(int type); + void (*EnableGUI)(void); + void (*DisableGUI)(void); void (*SetPalesati)(bool bpal); uint32 dwTonyNumTexts; @@ -259,7 +259,7 @@ public: uint32 mpalError; LPITEMIRQFUNCTION lpiifCustom; LPLPCUSTOMFUNCTION lplpFunctions; - Common::String * lplpFunctionStrings; + Common::String *lplpFunctionStrings; uint16 nObjs; uint16 nVars; HGLOBAL hVars; @@ -281,14 +281,14 @@ public: LPMPALSCRIPT lpmsScripts; Common::File hMpr; uint16 nResources; - uint32 * lpResources; + uint32 *lpResources; bool bExecutingAction; bool bExecutingDialog; - uint32 nPollingLocations[MAXPOLLINGLOCATIONS]; - uint32 hEndPollingLocations[MAXPOLLINGLOCATIONS]; - uint32 PollingThreads[MAXPOLLINGLOCATIONS]; - uint32 hAskChoice; - uint32 hDoneChoice; + uint32 nPollingLocations[MAXPOLLINGLOCATIONS]; + uint32 hEndPollingLocations[MAXPOLLINGLOCATIONS]; + uint32 PollingThreads[MAXPOLLINGLOCATIONS]; + uint32 hAskChoice; + uint32 hDoneChoice; uint32 nExecutingAction; uint32 nExecutingDialog; uint32 nExecutingChoice; diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp index 97425e49c9..7663774ee4 100644 --- a/engines/tony/input.cpp +++ b/engines/tony/input.cpp @@ -32,7 +32,7 @@ namespace Tony { RMInput::RMInput() { // Setup mouse fields - _clampMouse = false; + _clampMouse = false; _mousePos.Set(0, 0); _leftButton = _rightButton = false;; @@ -89,7 +89,7 @@ void RMInput::Poll(void) { default: break; } - } + } } void RMInput::Init() { @@ -107,12 +107,12 @@ bool RMInput::MouseRight() { } /** - * Return true if a key has been pressed + * Return true if a key has been pressed */ -bool RMInput::GetAsyncKeyState(Common::KeyCode kc) { +bool RMInput::GetAsyncKeyState(Common::KeyCode kc) { // The act of testing for a particular key automatically clears the state, to prevent // the same key being registered in multiple different frames - bool result = _keyDown[(int)kc]; + bool result = _keyDown[(int)kc]; _keyDown[(int)kc] = false; return result; } diff --git a/engines/tony/input.h b/engines/tony/input.h index 544424581f..524f604ec2 100644 --- a/engines/tony/input.h +++ b/engines/tony/input.h @@ -49,7 +49,7 @@ private: private: // Deinizializza DirectInput void DIClose(void); - + public: RMInput(); ~RMInput(); @@ -64,19 +64,33 @@ public: void Poll(void); // Reading of the mouse - RMPoint MousePos() { return _mousePos; } + RMPoint MousePos() { + return _mousePos; + } // Current status of the mouse buttons bool MouseLeft(); bool MouseRight(); // Events of mouse clicks - bool MouseLeftClicked() { return _leftClickMouse; } - bool MouseRightClicked() { return _rightClickMouse; } - bool MouseBothClicked() { return _leftClickMouse && _rightClickMouse; } - bool MouseLeftReleased() { return _leftReleaseMouse; } - bool MouseRightReleased() { return _rightReleaseMouse; } - bool MouseBothReleased() { return _leftReleaseMouse && _rightReleaseMouse; } + bool MouseLeftClicked() { + return _leftClickMouse; + } + bool MouseRightClicked() { + return _rightClickMouse; + } + bool MouseBothClicked() { + return _leftClickMouse && _rightClickMouse; + } + bool MouseLeftReleased() { + return _leftReleaseMouse; + } + bool MouseRightReleased() { + return _rightReleaseMouse; + } + bool MouseBothReleased() { + return _leftReleaseMouse && _rightReleaseMouse; + } // Returns true if the given key is pressed bool GetAsyncKeyState(Common::KeyCode kc); diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index 7b53e75cdd..e10fe228d3 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -36,7 +36,7 @@ namespace Tony { /****************************************************************************\ -* RMInventory Methods +* RMInventory Methods \****************************************************************************/ RMInventory::RMInventory() { @@ -74,7 +74,7 @@ bool RMInventory::CheckPointInside(const RMPoint &pt) { void RMInventory::Init(void) { - int i,j; + int i, j; int curres; // Crea il buffer principale @@ -87,7 +87,7 @@ void RMInventory::Init(void) { m_bCombining = false; // Nuovi oggetti - m_nItems = 78; // @@@ Numero di oggetti prendibili + m_nItems = 78; // @@@ Numero di oggetti prendibili m_items = new RMInventoryItem[m_nItems + 1]; curres = 10500; @@ -115,14 +115,14 @@ void RMInventory::Init(void) { curres++; if (i == 0 || i == 28 || i == 29) continue; - + m_items[i].pointer = new RMGfxSourceBuffer8RLEByteAA[m_items[i].icon.NumPattern()]; for (j = 0; j < m_items[i].icon.NumPattern(); j++) { RMResRaw raw(curres); assert(raw.IsValid()); - + m_items[i].pointer[j].Init((const byte *)raw, raw.Width(), raw.Height(), true); curres++; } @@ -141,24 +141,24 @@ void RMInventory::Init(void) { ds.Close(); // Crea il testo per gli hints sulla mini interfaccia - m_hints[0].SetAlignType(RMText::HCENTER,RMText::VTOP); - m_hints[1].SetAlignType(RMText::HCENTER,RMText::VTOP); - m_hints[2].SetAlignType(RMText::HCENTER,RMText::VTOP); + m_hints[0].SetAlignType(RMText::HCENTER, RMText::VTOP); + m_hints[1].SetAlignType(RMText::HCENTER, RMText::VTOP); + m_hints[2].SetAlignType(RMText::HCENTER, RMText::VTOP); // Il testo viene preso da MPAL per la traduzione RMMessage msg1(15); RMMessage msg2(13); RMMessage msg3(14); - m_hints[0].WriteText(msg1[0],1); - m_hints[1].WriteText(msg2[0],1); - m_hints[2].WriteText(msg3[0],1); + m_hints[0].WriteText(msg1[0], 1); + m_hints[1].WriteText(msg2[0], 1); + m_hints[2].WriteText(msg3[0], 1); -/* - m_hints[0].WriteText("Examine",1); - m_hints[1].WriteText("Talk",1); - m_hints[2].WriteText("Use",1); -*/ + /* + m_hints[0].WriteText("Examine",1); + m_hints[1].WriteText("Talk",1); + m_hints[2].WriteText("Use",1); + */ // Prepara il primo inventario Prepare(); @@ -167,7 +167,7 @@ void RMInventory::Init(void) { } void RMInventory::Close(void) { - // Ciao memoria + // Ciao memoria if (m_items != NULL) { // Delete the item pointers for (int i = 0; i <= m_nItems; i++) @@ -188,10 +188,10 @@ void RMInventory::Reset(void) { void RMInventory::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CONTEXT; - RMPoint pos; - RMPoint pos2; - RMGfxPrimitive *p; - RMGfxPrimitive *p2; + RMPoint pos; + RMPoint pos2; + RMGfxPrimitive *p; + RMGfxPrimitive *p2; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -208,13 +208,13 @@ void RMInventory::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr if (m_state == SELECTING) { if (!GLOBALS.bCfgInvUp) { - _ctx->pos.Set((m_nSelectObj+1)*64 - 20,RM_SY - 113); - _ctx->pos2.Set((m_nSelectObj+1)*64 + 34,RM_SY - 150); + _ctx->pos.Set((m_nSelectObj + 1) * 64 - 20, RM_SY - 113); + _ctx->pos2.Set((m_nSelectObj + 1) * 64 + 34, RM_SY - 150); } else { - _ctx->pos.Set((m_nSelectObj+1)*64 - 20, 72 - 4); // la parte marrone sta in alto :( - _ctx->pos2.Set((m_nSelectObj+1)*64 + 34, 119 - 4); + _ctx->pos.Set((m_nSelectObj + 1) * 64 - 20, 72 - 4); // la parte marrone sta in alto :( + _ctx->pos2.Set((m_nSelectObj + 1) * 64 + 34, 119 - 4); } - + _ctx->p = new RMGfxPrimitive(prim->m_task, _ctx->pos); _ctx->p2 = new RMGfxPrimitive(prim->m_task, _ctx->pos2); @@ -254,7 +254,7 @@ void RMInventory::RemoveItem(int code) { Common::copy(&m_inv[i + 1], &m_inv[i + 1] + (m_nInv - i), &m_inv[i]); // m_inv[m_nInv-1]=0; m_nInv--; - + Prepare(); DrawOT(Common::nullContext); ClearOT(); @@ -272,12 +272,12 @@ void RMInventory::AddItem(int code) { warning("Cannot find a valid icon for this item, and then it will not be added to the inventory"); } else { g_system->lockMutex(m_csModifyInterface); - if (m_curPos + 8 == m_nInv) { + if (m_curPos + 8 == m_nInv) { // Sfondiamo l'inventario! Attivo il pattern di lampeggio m_items[28].icon.SetPattern(2); } - m_inv[m_nInv++]=code-10000; + m_inv[m_nInv++] = code - 10000; Prepare(); DrawOT(Common::nullContext); @@ -302,8 +302,7 @@ void RMInventory::ChangeItemStatus(uint32 code, uint32 dwStatus) { } -void RMInventory::Prepare(void) -{ +void RMInventory::Prepare(void) { int i; for (i = 1; i < RM_SX / 64 - 1; i++) { @@ -332,7 +331,7 @@ bool RMInventory::HaveFocus(const RMPoint &mpos) { // Se l'inventario aperto, abbiamo il focus quando ci andiamo sopra if (m_state == OPENED && !m_bCombining && CheckPointInside(mpos)) return true; - + // Se stiamo selezionando un verbo (quindi tasto destro premuto), abbiamo il focus alltime if (m_state == SELECTING) return true; @@ -344,11 +343,11 @@ void RMInventory::EndCombine(void) { m_bCombining = false; } -bool RMInventory::LeftClick(const RMPoint &mpos, int& nCombineObj) { +bool RMInventory::LeftClick(const RMPoint &mpos, int &nCombineObj) { int n; // Il click sinistro prende in mano un oggetto dell'inventario per utilizzarlo con lo sfondo - n=mpos.x / 64; + n = mpos.x / 64; if (m_state == OPENED) { if (n > 0 && n < RM_SX / 64 - 1 && m_inv[n - 1 + m_curPos] != 0) { @@ -360,13 +359,13 @@ bool RMInventory::LeftClick(const RMPoint &mpos, int& nCombineObj) { return true; } } - + // Click sulla freccia destra if ((m_state == OPENED) && m_bBlinkingRight) { g_system->lockMutex(m_csModifyInterface); m_curPos++; - if (m_curPos+8 >= m_nInv) { + if (m_curPos + 8 >= m_nInv) { m_bBlinkingRight = false; m_items[28].icon.SetPattern(1); } @@ -383,7 +382,7 @@ bool RMInventory::LeftClick(const RMPoint &mpos, int& nCombineObj) { } // Click sulla freccia sinistra else if ((m_state == OPENED) && m_bBlinkingLeft) { - assert(m_curPos>0); + assert(m_curPos > 0); g_system->lockMutex(m_csModifyInterface); m_curPos--; @@ -417,7 +416,7 @@ void RMInventory::RightClick(const RMPoint &mpos) { // Apre l'interfaccina contestuale n = mpos.x / 64; - if (n > 0 && n < RM_SX / 64 - 1 && m_inv[n - 1 + m_curPos] != 0) { + if (n > 0 && n < RM_SX / 64 - 1 && m_inv[n - 1 + m_curPos] != 0) { m_state = SELECTING; miniAction = 0; m_nSelectObj = n - 1; @@ -437,7 +436,7 @@ void RMInventory::RightClick(const RMPoint &mpos) { m_items[28].icon.SetPattern(1); } - if (m_curPos>0) { + if (m_curPos > 0) { m_bBlinkingLeft = true; m_items[29].icon.SetPattern(2); } @@ -469,7 +468,7 @@ void RMInventory::RightClick(const RMPoint &mpos) { } } -bool RMInventory::RightRelease(const RMPoint &mpos, RMTonyAction& curAction) { +bool RMInventory::RightRelease(const RMPoint &mpos, RMTonyAction &curAction) { if (m_state == SELECTING) { m_state = OPENED; @@ -488,7 +487,7 @@ bool RMInventory::RightRelease(const RMPoint &mpos, RMTonyAction& curAction) { return false; } -#define INVSPEED 20 +#define INVSPEED 20 void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpos, bool bCanOpen) { int i; @@ -523,7 +522,7 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo m_items[29].icon.SetPattern(3); m_bBlinkingLeft = true; bNeedRedraw = true; - } + } } else if (m_bBlinkingLeft) { m_items[29].icon.SetPattern(2); m_bBlinkingLeft = false; @@ -542,12 +541,12 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo g_system->unlockMutex(m_csModifyInterface); } - + if (_vm->GetEngine()->GetInput().GetAsyncKeyState(Common::KEYCODE_i)) { GLOBALS.bCfgInvLocked = !GLOBALS.bCfgInvLocked; } - if (m_bCombining) {//m_state == COMBINING) + if (m_bCombining) {//m_state == COMBINING) ptr.SetCustomPointer(&m_items[m_nCombine].pointer[m_items[m_nCombine].status - 1]); ptr.SetSpecialPointer(RMPointer::PTR_CUSTOM); } @@ -557,12 +556,12 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo if (!GLOBALS.bCfgInvNoScroll) { m_state = OPENING; m_curPutY = RM_SY - 1; - m_curPutTime=_vm->GetTime(); + m_curPutTime = _vm->GetTime(); } else { m_state = OPENED; m_curPutY = RM_SY - 68; } - } else if (m_state == OPENED) { + } else if (m_state == OPENED) { if ((mpos.y < RM_SY - 70 && !GLOBALS.bCfgInvLocked) || !bCanOpen) { if (!GLOBALS.bCfgInvNoScroll) { m_state = CLOSING; @@ -593,18 +592,17 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo m_state = CLOSED; } } else { - if ((m_state == CLOSED) && (mpos.y<10 || GLOBALS.bCfgInvLocked) && bCanOpen) { + if ((m_state == CLOSED) && (mpos.y < 10 || GLOBALS.bCfgInvLocked) && bCanOpen) { if (!GLOBALS.bCfgInvNoScroll) { m_state = OPENING; - m_curPutY =- 68; + m_curPutY = - 68; m_curPutTime = _vm->GetTime(); } else { m_state = OPENED; m_curPutY = 0; } - } - else if (m_state == OPENED) { - if ((mpos.y>70 && !GLOBALS.bCfgInvLocked) || !bCanOpen) { + } else if (m_state == OPENED) { + if ((mpos.y > 70 && !GLOBALS.bCfgInvLocked) || !bCanOpen) { if (!GLOBALS.bCfgInvNoScroll) { m_state = CLOSING; m_curPutY = -2; @@ -637,31 +635,31 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo if (m_state == SELECTING) { int startx = (m_nSelectObj + 1) * 64 - 20; int starty; - + if (!GLOBALS.bCfgInvUp) - starty=RM_SY-109; + starty = RM_SY - 109; else - starty=70; - + starty = 70; + // Controlla se si trova su uno dei verbi if (mpos.y > starty && mpos.y < starty + 45) { - if (mpos.x > startx && mpos.x < startx + 40) { - if (miniAction !=1 ) { + if (mpos.x > startx && mpos.x < startx + 40) { + if (miniAction != 1) { miniInterface.SetPattern(2); miniAction = 1; - _vm->PlayUtilSFX(1); + _vm->PlayUtilSFX(1); } } else if (mpos.x >= startx + 40 && mpos.x < startx + 80) { if (miniAction != 2) { miniInterface.SetPattern(3); miniAction = 2; _vm->PlayUtilSFX(1); - } + } } else if (mpos.x >= startx + 80 && mpos.x < startx + 108) { if (miniAction != 3) { miniInterface.SetPattern(4); miniAction = 3; - _vm->PlayUtilSFX(1); + _vm->PlayUtilSFX(1); } } else { miniInterface.SetPattern(1); @@ -671,12 +669,12 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo miniInterface.SetPattern(1); miniAction = 0; } - + // Aggiorna la miniinterface miniInterface.DoFrame(&bigBuf, false); } - if ((m_state!= CLOSED) && !m_nInList) { + if ((m_state != CLOSED) && !m_nInList) { bigBuf.AddPrim(new RMGfxPrimitive(this)); } } @@ -694,10 +692,10 @@ RMItem *RMInventory::WhichItemIsIn(const RMPoint &mpt) { if (m_state == OPENED) { if (CheckPointInside(mpt)) { - n=mpt.x / 64; - if (n>0 && n < RM_SX / 64 - 1 && m_inv[n - 1 + m_curPos] != 0 && (!m_bCombining || m_inv[n - 1 + m_curPos] != m_nCombine)) + n = mpt.x / 64; + if (n > 0 && n < RM_SX / 64 - 1 && m_inv[n - 1 + m_curPos] != 0 && (!m_bCombining || m_inv[n - 1 + m_curPos] != m_nCombine)) return &m_items[m_inv[n - 1 + m_curPos]].icon; - } + } } return NULL; @@ -707,14 +705,16 @@ RMItem *RMInventory::WhichItemIsIn(const RMPoint &mpt) { int RMInventory::GetSaveStateSize(void) { // m_inv pattern m_nInv - return 256*4 + 256*4 + 4 ; + return 256 * 4 + 256 * 4 + 4 ; } void RMInventory::SaveState(byte *state) { int i, x; - WRITE_LE_UINT32(state, m_nInv); state += 4; - Common::copy(m_inv, m_inv + 256, (uint32 *)state); state += 256 * 4; + WRITE_LE_UINT32(state, m_nInv); + state += 4; + Common::copy(m_inv, m_inv + 256, (uint32 *)state); + state += 256 * 4; for (i = 0; i < 256; i++) { if (i < m_nItems) @@ -722,19 +722,23 @@ void RMInventory::SaveState(byte *state) { else x = 0; - WRITE_LE_UINT32(state, x); state += 4; + WRITE_LE_UINT32(state, x); + state += 4; } } int RMInventory::LoadState(byte *state) { int i, x; - m_nInv = READ_LE_UINT32(state); state += 4; - Common::copy((uint32 *)state, (uint32 *)state + 256, m_inv); state += 256 * 4; + m_nInv = READ_LE_UINT32(state); + state += 4; + Common::copy((uint32 *)state, (uint32 *)state + 256, m_inv); + state += 256 * 4; for (i = 0; i < 256; i++) { - x = READ_LE_UINT32(state); state += 4; - + x = READ_LE_UINT32(state); + state += 4; + if (i < m_nItems) { m_items[i].status = x; m_items[i].icon.SetPattern(x); @@ -745,7 +749,7 @@ int RMInventory::LoadState(byte *state) { m_bCombining = false; m_items[29].icon.SetPattern(1); - + if (m_nInv > 8) m_items[28].icon.SetPattern(2); else @@ -760,7 +764,7 @@ int RMInventory::LoadState(byte *state) { /****************************************************************************\ -* RMInterface methods +* RMInterface methods \****************************************************************************/ RMInterface::~RMInterface() { @@ -777,8 +781,9 @@ int RMInterface::OnWhichBox(RMPoint pt) { pt -= m_openStart; // Controlla quanti verbi bisogna considerare - max = 4; if (m_bPalesati) max = 5; - + max = 4; + if (m_bPalesati) max = 5; + // Cerca il verbo for (i = 0; i < max; i++) if (m_hotbbox[i].PtInRect(pt)) @@ -790,7 +795,7 @@ int RMInterface::OnWhichBox(RMPoint pt) { void RMInterface::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CONTEXT; - int h; + int h; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -803,7 +808,7 @@ void RMInterface::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr if (_ctx->h != -1) { prim->Dst().TopLeft() = m_openStart; CORO_INVOKE_2(m_hotzone[_ctx->h].Draw, bigBuf, prim); - + if (m_lastHotZone != _ctx->h) { m_lastHotZone = _ctx->h; _vm->PlayUtilSFX(1); @@ -839,8 +844,8 @@ void RMInterface::Clicked(const RMPoint &mousepos) { // La tiene dentro lo schermo if (m_openStart.x < 0) m_openStart.x = 0; if (m_openStart.y < 0) m_openStart.y = 0; - if (m_openStart.x+m_dimx > RM_SX) m_openStart.x = RM_SX - m_dimx; - if (m_openStart.y+m_dimy > RM_SY) m_openStart.y = RM_SY - m_dimy; + if (m_openStart.x + m_dimx > RM_SX) m_openStart.x = RM_SX - m_dimx; + if (m_openStart.y + m_dimy > RM_SY) m_openStart.y = RM_SY - m_dimy; // Play dell'effetto sonoro _vm->PlayUtilSFX(0); @@ -868,16 +873,16 @@ bool RMInterface::Released(const RMPoint &mousepos, RMTonyAction &action) { case 3: action = TA_EXAMINE; break; - + case 4: action = TA_PALESATI; break; - default: // Nessun verbo + default: // Nessun verbo return false; - } - - return true; + } + + return true; } void RMInterface::Reset(void) { @@ -885,7 +890,7 @@ void RMInterface::Reset(void) { } void RMInterface::SetPalesati(bool bOn) { - m_bPalesati=bOn; + m_bPalesati = bOn; } bool RMInterface::GetPalesati(void) { @@ -894,7 +899,7 @@ bool RMInterface::GetPalesati(void) { void RMInterface::Init(void) { int i; - RMResRaw inter(RES_I_INTERFACE); + RMResRaw inter(RES_I_INTERFACE); RMRes pal(RES_I_INTERPPAL); SetPriority(191); @@ -909,8 +914,8 @@ void RMInterface::Init(void) { m_hotzone[i].LoadPaletteWA(pal); } - m_hotbbox[0].SetRect(126, 123, 159, 208); // prendi - m_hotbbox[1].SetRect(90, 130, 125, 186); // parla + m_hotbbox[0].SetRect(126, 123, 159, 208); // prendi + m_hotbbox[1].SetRect(90, 130, 125, 186); // parla m_hotbbox[2].SetRect(110, 60, 152, 125); m_hotbbox[3].SetRect(56, 51, 93, 99); m_hotbbox[4].SetRect(51, 105, 82, 172); @@ -933,13 +938,13 @@ void RMInterface::Init(void) { m_hints[2].WriteText(msg2[0], 1); m_hints[3].WriteText(msg3[0], 1); m_hints[4].WriteText(msg4[0], 1); -/* - m_hints[0].WriteText("Take",1); - m_hints[1].WriteText("Talk",1); - m_hints[2].WriteText("Use",1); - m_hints[3].WriteText("Examine",1); - m_hints[4].WriteText("Palesati",1); -*/ + /* + m_hints[0].WriteText("Take",1); + m_hints[1].WriteText("Talk",1); + m_hints[2].WriteText("Use",1); + m_hints[3].WriteText("Examine",1); + m_hints[4].WriteText("Palesati",1); + */ m_bActive = false; m_bPalesati = false; m_lastHotZone = 0; diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index df92cafebd..c612ebbf77 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -334,14 +334,14 @@ void RMTony::Stop(CORO_PARAM) { ExecuteAction(m_Action, m_ActionItem->MpalCode(), m_ActionParm); - m_ActionItem=NULL; + m_ActionItem = NULL; CORO_END_CODE; } int RMTony::GetCurPattern(void) { - int nPatt=RMCharacter::GetCurPattern(); + int nPatt = RMCharacter::GetCurPattern(); if (!m_bPastorella) return nPatt; @@ -355,7 +355,6 @@ int RMTony::GetCurPattern(void) { return PAT_STANDLEFT; case PAT_PAST_STANDRIGHT: return PAT_STANDRIGHT; - case PAT_PAST_WALKUP: return PAT_WALKUP; case PAT_PAST_WALKDOWN: @@ -438,7 +437,6 @@ void RMTony::Take(int nWhere, int nPart) { } break; - case PAT_STANDLEFT: switch (nWhere) { case 0: @@ -454,7 +452,7 @@ void RMTony::Take(int nWhere, int nPart) { break; } } else if (nPart == 1) { - SetPattern(GetCurPattern()+1); + SetPattern(GetCurPattern() + 1); } else if (nPart == 2) { switch (GetCurPattern()) { case PAT_TAKEUP_UP2: @@ -514,7 +512,6 @@ void RMTony::Put(int nWhere, int nPart) { } break; - case PAT_STANDLEFT: switch (nWhere) { case 0: @@ -530,7 +527,7 @@ void RMTony::Put(int nWhere, int nPart) { break; } } else if (nPart == 1) { - SetPattern(GetCurPattern()+1); + SetPattern(GetCurPattern() + 1); } else if (nPart == 2) { switch (GetCurPattern()) { case PAT_PUTUP_UP2: @@ -567,7 +564,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body if (!m_bIsStaticTalk) { switch (m_nPatB4Talking) { case PAT_STANDDOWN: - m_TalkDirection=DOWN; + m_TalkDirection = DOWN; break; case PAT_TAKELEFT_UP2: @@ -575,7 +572,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case PAT_TAKELEFT_DOWN2: case PAT_SIRIALZALEFT: case PAT_STANDLEFT: - m_TalkDirection=LEFT; + m_TalkDirection = LEFT; break; case PAT_TAKERIGHT_UP2: @@ -583,14 +580,14 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case PAT_TAKERIGHT_DOWN2: case PAT_SIRIALZARIGHT: case PAT_STANDRIGHT: - m_TalkDirection=RIGHT; + m_TalkDirection = RIGHT; break; case PAT_TAKEUP_UP2: case PAT_TAKEUP_MID2: case PAT_TAKEUP_DOWN2: case PAT_STANDUP: - m_TalkDirection=UP; + m_TalkDirection = UP; break; } @@ -1220,9 +1217,9 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa case TALK_RIDE: case TALK_RIDE2: - if (m_TalkDirection==LEFT) + if (m_TalkDirection == LEFT) headEndPat = PAT_RIDELEFT_END; - else if (m_TalkDirection==RIGHT) + else if (m_TalkDirection == RIGHT) headEndPat = PAT_RIDERIGHT_END; bodyEndPat = 0; @@ -1532,7 +1529,7 @@ void RMTony::StartStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat switch (nPat) { case PAT_STANDDOWN: - m_TalkDirection=DOWN; + m_TalkDirection = DOWN; headPat = PAT_TESTA_RIGHT; break; @@ -1541,7 +1538,7 @@ void RMTony::StartStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat case PAT_TAKELEFT_DOWN2: case PAT_SIRIALZALEFT: case PAT_STANDLEFT: - m_TalkDirection=LEFT; + m_TalkDirection = LEFT; headPat = PAT_TESTA_LEFT; break; @@ -1550,7 +1547,7 @@ void RMTony::StartStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat case PAT_TAKERIGHT_DOWN2: case PAT_SIRIALZARIGHT: case PAT_STANDRIGHT: - m_TalkDirection=RIGHT; + m_TalkDirection = RIGHT; headPat = PAT_TESTA_RIGHT; break; @@ -1558,7 +1555,7 @@ void RMTony::StartStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat case PAT_TAKEUP_MID2: case PAT_TAKEUP_DOWN2: case PAT_STANDUP: - m_TalkDirection=UP; + m_TalkDirection = UP; headPat = PAT_TESTA_LEFT; break; } diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index 92f6dea032..58d0bba2ba 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -211,9 +211,9 @@ bool RMSnapshot::GetFreeSnapName(char *fn) { _splitpath(fn, bufDrive, bufDir, NULL, NULL); for (i = 1; i < 10; i++) { - wsprintf(bufName,"rm%d00",i); - _makepath(fn,bufDrive,bufDir,bufName,".bmp"); - h = CreateFile(fn,GENERIC_READ,FILE_SHARE_READ, NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL, NULL); + wsprintf(bufName, "rm%d00", i); + _makepath(fn, bufDrive, bufDir, bufName, ".bmp"); + h = CreateFile(fn, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (h == CORO_INVALID_PID_VALUE) break; CloseHandle(h); @@ -222,10 +222,10 @@ bool RMSnapshot::GetFreeSnapName(char *fn) { i--; for (j = 1; j < 10; j++) { - wsprintf(bufName,"rm%d%d0",i,j); - _makepath(fn,bufDrive,bufDir,bufName,".bmp"); - h=CreateFile(fn,GENERIC_READ,FILE_SHARE_READ, NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL, NULL); - if (h==CORO_INVALID_PID_VALUE) + wsprintf(bufName, "rm%d%d0", i, j); + _makepath(fn, bufDrive, bufDir, bufName, ".bmp"); + h = CreateFile(fn, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + if (h == CORO_INVALID_PID_VALUE) break; CloseHandle(h); } @@ -233,10 +233,10 @@ bool RMSnapshot::GetFreeSnapName(char *fn) { j--; for (k = 0; k < 10; k++) { - wsprintf(bufName,"rm%d%d%d",i,j,k); - _makepath(fn,bufDrive,bufDir,bufName,".bmp"); - h = CreateFile(fn,GENERIC_READ,FILE_SHARE_READ, NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL, NULL); - if (h==CORO_INVALID_PID_VALUE) + wsprintf(bufName, "rm%d%d%d", i, j, k); + _makepath(fn, bufDrive, bufDir, bufName, ".bmp"); + h = CreateFile(fn, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + if (h == CORO_INVALID_PID_VALUE) break; CloseHandle(h); } @@ -251,8 +251,8 @@ bool RMSnapshot::GetFreeSnapName(char *fn) { return false; } - wsprintf(bufName,"rm%d%d%d",i,j,k); - _makepath(fn,bufDrive,bufDir,bufName,".bmp"); + wsprintf(bufName, "rm%d%d%d", i, j, k); + _makepath(fn, bufDrive, bufDir, bufName, ".bmp"); } #endif return true; @@ -299,7 +299,7 @@ void RMSnapshot::GrabScreenshot(byte *lpBuf, int dezoom, uint16 *lpDestBuf) { cursrc = &src[RM_SKIPX + x * dezoom]; sommar = sommab = sommag = 0; - for (v = 0; v < dezoom; v++) + for (v = 0; v < dezoom; v++) { for (u = 0; u < dezoom; u++) { if (lpDestBuf == NULL) curv = -v; @@ -310,16 +310,16 @@ void RMSnapshot::GrabScreenshot(byte *lpBuf, int dezoom, uint16 *lpDestBuf) { sommag += (cursrc[curv*RM_BBX + u] >> 5) & 0x1F; sommar += (cursrc[curv*RM_BBX + u] >> 10) & 0x1F; } + } + rgb[k + 0] = (byte) (sommab * 8 / (dezoom * dezoom)); + rgb[k + 1] = (byte) (sommag * 8 / (dezoom * dezoom)); + rgb[k + 2] = (byte) (sommar * 8 / (dezoom * dezoom)); - rgb[k + 0] = (byte) (sommab * 8 / (dezoom * dezoom)); - rgb[k + 1] = (byte) (sommag * 8 / (dezoom * dezoom)); - rgb[k + 2] = (byte) (sommar * 8 / (dezoom * dezoom)); - - if (lpDestBuf!=NULL) - lpDestBuf[k / 3] = ((int)rgb[k + 0] >> 3) | (((int)rgb[k + 1] >> 3) << 5) | - (((int)rgb[k + 2] >> 3) << 10); + if (lpDestBuf!=NULL) + lpDestBuf[k / 3] = ((int)rgb[k + 0] >> 3) | (((int)rgb[k + 1] >> 3) << 5) | + (((int)rgb[k + 2] >> 3) << 10); - k += 3; + k += 3; } if (lpDestBuf == NULL) -- cgit v1.2.3 From 59942d9a41cf7d43b95e9775aca66c241884b516 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 16 May 2012 00:05:48 +1000 Subject: TONY: Work on enabling GMM saving and loading --- engines/tony/detection.cpp | 36 +++++++++++++++++++++++++++++++++--- engines/tony/gfxengine.cpp | 12 ++++++++---- engines/tony/gfxengine.h | 5 +++-- engines/tony/tony.cpp | 44 ++++++++++++++++++++++++++++++++++++++++++-- engines/tony/tony.h | 8 +++++++- 5 files changed, 93 insertions(+), 12 deletions(-) (limited to 'engines') diff --git a/engines/tony/detection.cpp b/engines/tony/detection.cpp index 944f717f26..5b1092d2c0 100644 --- a/engines/tony/detection.cpp +++ b/engines/tony/detection.cpp @@ -25,6 +25,7 @@ #include "engines/advancedDetector.h" #include "common/system.h" +#include "graphics/surface.h" #include "tony/tony.h" #include "tony/game.h" @@ -75,18 +76,23 @@ public: virtual SaveStateList listSaves(const char *target) const; virtual int getMaximumSaveSlot() const; virtual void removeSaveState(const char *target, int slot) const; + SaveStateDescriptor TonyMetaEngine::querySaveMetaInfos(const char *target, int slot) const; }; bool TonyMetaEngine::hasFeature(MetaEngineFeature f) const { return (f == kSupportsListSaves) || -// (f == kSupportsLoadingDuringStartup) || - (f == kSupportsDeleteSave); + (f == kSupportsLoadingDuringStartup) || + (f == kSupportsDeleteSave) || + (f == kSavesSupportMetaInfo) || + (f == kSavesSupportThumbnail); } bool Tony::TonyEngine::hasFeature(EngineFeature f) const { return - (f == kSupportsRTL); + (f == kSupportsRTL) || + (f == kSupportsLoadingDuringRuntime) || + (f == kSupportsSavingDuringRuntime); } bool TonyMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const { @@ -136,6 +142,30 @@ void TonyMetaEngine::removeSaveState(const char *target, int slot) const { g_system->getSavefileManager()->removeSavefile(filename); } +SaveStateDescriptor TonyMetaEngine::querySaveMetaInfos(const char *target, int slot) const { + Tony::RMString saveName; + byte difficulty; + + Graphics::PixelFormat pixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0); + Graphics::Surface *thumbnail = new Graphics::Surface(); + thumbnail->create(160, 120, pixelFormat); + + if (Tony::RMOptionScreen::LoadThumbnailFromSaveState(slot, (byte *)thumbnail->pixels, saveName, difficulty)) { + // Create the return descriptor + SaveStateDescriptor desc(slot, (const char *)saveName); + desc.setDeletableFlag(true); + desc.setWriteProtectedFlag(false); + desc.setThumbnail(thumbnail); + + return desc; + } + + thumbnail->free(); + delete thumbnail; + return SaveStateDescriptor(); +} + + #if PLUGIN_ENABLED_DYNAMIC(TONY) REGISTER_PLUGIN_DYNAMIC(TONY, PLUGIN_TYPE_ENGINE, TonyMetaEngine); #else diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 384e80f209..7cfeaecb6f 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -698,7 +698,7 @@ void LoadMusic(Common::InSaveFile *f); #define TONY_SAVEGAME_VERSION 8 -void RMGfxEngine::SaveState(const char *fn, byte *curThumb, const char *name, bool bFastCompress) { +void RMGfxEngine::SaveState(const Common::String &fn, byte *curThumb, const Common::String &name) { Common::OutSaveFile *f; byte *state; uint thumbsize; @@ -733,9 +733,9 @@ void RMGfxEngine::SaveState(const char *fn, byte *curThumb, const char *name, bo i = mpalQueryGlobalVar("VERSIONEFACILE"); f->writeByte(i); - i = strlen(name); + i = strlen(name.c_str()); f->writeByte(i); - f->write(name, i); + f->write(name.c_str(), i); f->writeUint32LE(m_nCurLoc); f->writeUint32LE(tp.x); f->writeUint32LE(tp.y); @@ -801,7 +801,7 @@ void RMGfxEngine::SaveState(const char *fn, byte *curThumb, const char *name, bo delete f; } -void RMGfxEngine::LoadState(CORO_PARAM, const char *fn) { +void RMGfxEngine::LoadState(CORO_PARAM, const Common::String &fn) { // PROBLEMA: Bisognerebbe caricare la locazione in un thread a parte per fare la OnEnter ... CORO_BEGIN_CONTEXT; Common::InSaveFile *f; @@ -986,4 +986,8 @@ void RMGfxEngine::WaitWipeEnd(CORO_PARAM) { CoroScheduler.waitForSingleObject(coroParam, m_hWipeEvent, CORO_INFINITE); } +bool RMGfxEngine::CanLoadSave() { + return m_bInput && !m_tony.InAction(); +} + } // End of namespace Tony diff --git a/engines/tony/gfxengine.h b/engines/tony/gfxengine.h index 24deb47ec4..06eb3cc4ba 100644 --- a/engines/tony/gfxengine.h +++ b/engines/tony/gfxengine.h @@ -133,8 +133,8 @@ public: void Unfreeze(void); // State management - void SaveState(const char *fn, byte *curThumb, const char *name, bool bFastCompress = false); - void LoadState(CORO_PARAM, const char *fn); + void SaveState(const Common::String &fn, byte *curThumb, const Common::String &name); + void LoadState(CORO_PARAM, const Common::String &fn); // Selects a location void SelectLocation(const RMPoint &ptTonyStart = RMPoint(-1, -1), const RMPoint &start = RMPoint(-1, -1)); @@ -150,6 +150,7 @@ public: void SetPalesati(bool bpal) { m_inter.SetPalesati(bpal); } + bool CanLoadSave(); }; } // End of namespace Tony diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index d476f60859..c7056cb88d 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -43,6 +43,14 @@ TonyEngine::TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc) : Eng DebugMan.addDebugChannel(kTonyDebugActions, "actions", "Actions debugging"); DebugMan.addDebugChannel(kTonyDebugSound, "sound", "Sound debugging"); DebugMan.addDebugChannel(kTonyDebugMusic, "music", "Music debugging"); + + // Set up load slot number + _loadSlotNumber = -1; + if (ConfMan.hasKey("save_slot")) { + int slotNumber = ConfMan.getInt("save_slot"); + if (slotNumber >= 0 && slotNumber <= 99) + _loadSlotNumber = slotNumber; + } } TonyEngine::~TonyEngine() { @@ -400,7 +408,7 @@ void TonyEngine::AutoSave(CORO_PARAM) { CORO_INVOKE_0(MainWaitFrame); MainFreeze(); _ctx->buf = GetSaveStateFileName(0); - _theEngine.SaveState(_ctx->buf.c_str(), (byte *)m_curThumbnail, "Autosave", true); + _theEngine.SaveState(_ctx->buf, (byte *)m_curThumbnail, "Autosave"); MainUnfreeze(); CORO_END_CODE; @@ -499,17 +507,26 @@ void TonyEngine::Abort(void) { */ void TonyEngine::PlayProcess(CORO_PARAM, const void *param) { CORO_BEGIN_CONTEXT; + Common::String fn; CORO_END_CONTEXT(_ctx); + CORO_BEGIN_CODE(_ctx); - // CORO_INFINITE loop. We rely on the outer main process to detect if a shutdown is required, + // Game loop. We rely on the outer main process to detect if a shutdown is required, // and kill the scheudler and all the processes, including this one for (;;) { // Se siamo in pausa, entra nel loop appropriato if (_vm->m_bPaused) _vm->PauseLoop(); + // If a savegame needs to be loaded, then do so + if (_vm->_loadSlotNumber != -1 && GLOBALS.GfxEngine != NULL) { + _ctx->fn = GetSaveStateFileName(_vm->_loadSlotNumber); + CORO_INVOKE_1(GLOBALS.GfxEngine->LoadState, _ctx->fn); + _vm->_loadSlotNumber = -1; + } + // Wait for the next frame CORO_INVOKE_1(CoroScheduler.sleep, 50); @@ -627,4 +644,27 @@ uint32 TonyEngine::GetTime() { return g_system->getMillis(); } +bool TonyEngine::canLoadGameStateCurrently() { + return GLOBALS.GfxEngine != NULL && GLOBALS.GfxEngine->CanLoadSave(); +} +bool TonyEngine::canSaveGameStateCurrently() { + return GLOBALS.GfxEngine != NULL && GLOBALS.GfxEngine->CanLoadSave(); +} + +Common::Error TonyEngine::loadGameState(int slot) { + _loadSlotNumber = slot; + return Common::kNoError; +} + +Common::Error TonyEngine::saveGameState(int slot, const Common::String &desc) { + if (!GLOBALS.GfxEngine) + return Common::kUnknownError; + + RMSnapshot s; + s.GrabScreenshot(*GLOBALS.GfxEngine, 4, m_curThumbnail); + + GLOBALS.GfxEngine->SaveState(GetSaveStateFileName(slot), (byte *)m_curThumbnail, desc); + return Common::kNoError; +} + } // End of namespace Tony diff --git a/engines/tony/tony.h b/engines/tony/tony.h index c106a0856b..574861487a 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -78,8 +78,9 @@ struct VoiceHeader { class TonyEngine : public Engine { private: - Common::ErrorCode Init(); + int _loadSlotNumber; + Common::ErrorCode Init(); void InitMusic(); void CloseMusic(); bool OpenVoiceDatabase(); @@ -142,6 +143,11 @@ public: RMGfxEngine *GetEngine() { return &_theEngine; } void GUIError(const Common::String &msg); + virtual bool canLoadGameStateCurrently(); + virtual bool canSaveGameStateCurrently(); + Common::Error TonyEngine::loadGameState(int slot); + Common::Error TonyEngine::saveGameState(int slot, const Common::String &desc); + // Avverte che siamo guidati dal GDI void GDIControl(bool bCon); -- cgit v1.2.3 From 40926933c35cbded1ff2aa8078eaa3c76b2149b3 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 17 May 2012 19:30:30 +1000 Subject: TONY: Handle translating savegame thumbnail for display in ScummVM GMM --- engines/tony/detection.cpp | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'engines') diff --git a/engines/tony/detection.cpp b/engines/tony/detection.cpp index 5b1092d2c0..578c5c796c 100644 --- a/engines/tony/detection.cpp +++ b/engines/tony/detection.cpp @@ -23,8 +23,10 @@ #include "base/plugins.h" +#include "common/memstream.h" #include "engines/advancedDetector.h" #include "common/system.h" +#include "graphics/colormasks.h" #include "graphics/surface.h" #include "tony/tony.h" @@ -145,23 +147,35 @@ void TonyMetaEngine::removeSaveState(const char *target, int slot) const { SaveStateDescriptor TonyMetaEngine::querySaveMetaInfos(const char *target, int slot) const { Tony::RMString saveName; byte difficulty; + byte thumbData[160 * 120 * 2]; + + if (Tony::RMOptionScreen::LoadThumbnailFromSaveState(slot, thumbData, saveName, difficulty)) { + // Convert the 565 thumbnail data to the needed overlay format + Common::MemoryReadStream thumbStream(thumbData, 160 * 120 * 2); + Graphics::PixelFormat destFormat = g_system->getOverlayFormat(); + Graphics::Surface *to = new Graphics::Surface(); + to->create(160, 120, destFormat); + + OverlayColor *pixels = (OverlayColor *)to->pixels; + for (int y = 0; y < to->h; ++y) { + for (int x = 0; x < to->w; ++x) { + uint8 r, g, b; + Graphics::colorToRGB >(thumbStream.readUint16LE(), r, g, b); + + // converting to current OSystem Color + *pixels++ = destFormat.RGBToColor(r, g, b); + } + } - Graphics::PixelFormat pixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0); - Graphics::Surface *thumbnail = new Graphics::Surface(); - thumbnail->create(160, 120, pixelFormat); - - if (Tony::RMOptionScreen::LoadThumbnailFromSaveState(slot, (byte *)thumbnail->pixels, saveName, difficulty)) { // Create the return descriptor SaveStateDescriptor desc(slot, (const char *)saveName); desc.setDeletableFlag(true); desc.setWriteProtectedFlag(false); - desc.setThumbnail(thumbnail); + desc.setThumbnail(to); return desc; } - thumbnail->free(); - delete thumbnail; return SaveStateDescriptor(); } -- cgit v1.2.3 From 7a40750671915d517e8938fdca889f870b554c8c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 17 May 2012 19:41:53 +1000 Subject: TONY: Add a check to prevent GMM saving in the demo --- engines/tony/gfxengine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 7cfeaecb6f..5d81c47333 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -987,7 +987,7 @@ void RMGfxEngine::WaitWipeEnd(CORO_PARAM) { } bool RMGfxEngine::CanLoadSave() { - return m_bInput && !m_tony.InAction(); + return m_bInput && !m_tony.InAction() && !_vm->getIsDemo(); } } // End of namespace Tony -- cgit v1.2.3 From a5a3977c905d55dd3c8e9ff6e1acbac07b1fb305 Mon Sep 17 00:00:00 2001 From: Torbj旦rn Andersson Date: Thu, 17 May 2012 14:20:04 +0200 Subject: TONY: Fix compiling with GCC --- engines/tony/detection.cpp | 2 +- engines/tony/tony.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/tony/detection.cpp b/engines/tony/detection.cpp index 578c5c796c..63bb02a5f2 100644 --- a/engines/tony/detection.cpp +++ b/engines/tony/detection.cpp @@ -78,7 +78,7 @@ public: virtual SaveStateList listSaves(const char *target) const; virtual int getMaximumSaveSlot() const; virtual void removeSaveState(const char *target, int slot) const; - SaveStateDescriptor TonyMetaEngine::querySaveMetaInfos(const char *target, int slot) const; + SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const; }; bool TonyMetaEngine::hasFeature(MetaEngineFeature f) const { diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 574861487a..f40eb1325d 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -145,8 +145,8 @@ public: virtual bool canLoadGameStateCurrently(); virtual bool canSaveGameStateCurrently(); - Common::Error TonyEngine::loadGameState(int slot); - Common::Error TonyEngine::saveGameState(int slot, const Common::String &desc); + Common::Error loadGameState(int slot); + Common::Error saveGameState(int slot, const Common::String &desc); // Avverte che siamo guidati dal GDI void GDIControl(bool bCon); -- cgit v1.2.3 From d67a5162addcc143c870ed35000212bdd7d7ab2c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 18 May 2012 21:48:03 +1000 Subject: TONY: Converting method comments to DOXYGEN format --- engines/tony/mpal/mpal.cpp | 770 +++++++++++++++------------------------------ engines/tony/mpal/mpal.h | 705 +++++++++++++++-------------------------- 2 files changed, 503 insertions(+), 972 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index f049ecf3ea..a173b707f2 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -61,6 +61,8 @@ namespace Tony { namespace MPAL { +#define GETARG(type) va_arg(v, type) + /****************************************************************************\ * Copyright \****************************************************************************/ @@ -76,39 +78,25 @@ const char *mpalCopyright = * Internal functions \****************************************************************************/ -/****************************************************************************\ -* -* Function: void LockVar(void); -* -* Description: Locka le variabili per accederci -* -\****************************************************************************/ - +/** + * Locks the variables for access + */ void LockVar(void) { GLOBALS.lpmvVars = (LPMPALVAR)GlobalLock(GLOBALS.hVars); } -/****************************************************************************\ -* -* Function: void UnlockVar(void); -* -* Description: Unlocka le variabili dopo l'uso -* -\****************************************************************************/ +/** + * Unlocks variables after use + */ void UnlockVar(void) { GlobalUnlock(GLOBALS.hVars); } -/****************************************************************************\ -* -* Function: void LockMsg(void); -* -* Description: Locka i messaggi per accederci -* -\****************************************************************************/ - +/** + * Locks the messages for access + */ static void LockMsg(void) { #ifdef NEED_LOCK_MSGS GLOBALS.lpmmMsgs = (LPMPALMSG)GlobalLock(GLOBALS.hMsgs); @@ -116,14 +104,9 @@ static void LockMsg(void) { } -/****************************************************************************\ -* -* Function: void UnlockMsg(void); -* -* Description: Unlocka i messaggi dopo l'uso -* -\****************************************************************************/ - +/** + * Unlocks the messages after use + */ static void UnlockMsg(void) { #ifdef NEED_LOCK_MSGS GlobalUnlock(GLOBALS.hMsgs); @@ -131,125 +114,79 @@ static void UnlockMsg(void) { } -/****************************************************************************\ -* -* Function: void LockDialogs(void); -* -* Description: Locka i dialoghi per accederci -* -\****************************************************************************/ - +/** + * Locks the dialogs for access + */ static void LockDialogs(void) { GLOBALS.lpmdDialogs = (LPMPALDIALOG)GlobalLock(GLOBALS.hDialogs); } -/****************************************************************************\ -* -* Function: void UnlockDialogs(void); -* -* Description: Unlocka i dialoghi dopo l'uso -* -\****************************************************************************/ - +/** + * Unlocks the dialogs after use + */ static void UnlockDialogs(void) { GlobalUnlock(GLOBALS.hDialogs); } -/****************************************************************************\ -* -* Function: void LockLocations(void); -* -* Description: Locka le strutture di dati sulle locazioni -* -\****************************************************************************/ - +/** + * Locks the location data structures for access + */ static void LockLocations(void) { GLOBALS.lpmlLocations = (LPMPALLOCATION)GlobalLock(GLOBALS.hLocations); } -/****************************************************************************\ -* -* Function: void UnlockLocations(void); -* -* Description: Unlocka le strutture di dati sulle locazioni -* -\****************************************************************************/ - +/** + * Unlocks the location structures after use + */ static void UnlockLocations(void) { GlobalUnlock(GLOBALS.hLocations); } -/****************************************************************************\ -* -* Function: void LockItems(void); -* -* Description: Locka le strutture di dati sugli item -* -\****************************************************************************/ - +/** + * Locks the items structures for use + */ static void LockItems(void) { GLOBALS.lpmiItems = (LPMPALITEM)GlobalLock(GLOBALS.hItems); } -/****************************************************************************\ -* -* Function: void UnlockItems(void); -* -* Description: Unlocka le strutture di dati sugli item -* -\****************************************************************************/ - +/** + * Unlocks the items structures after use + */ static void UnlockItems(void) { GlobalUnlock(GLOBALS.hItems); } -/****************************************************************************\ -* -* Function: void LockScripts(void); -* -* Description: Locka le strutture di dati sugli script -* -\****************************************************************************/ +/** + * Locks the script data structures for use + */ static void LockScripts(void) { GLOBALS.lpmsScripts = (LPMPALSCRIPT)GlobalLock(GLOBALS.hScripts); } -/****************************************************************************\ -* -* Function: void UnlockScripts(void); -* -* Description: Unlocka le strutture di dati sugli script -* -\****************************************************************************/ - +/** + * Unlocks the script data structures after use + */ static void UnlockScripts(void) { GlobalUnlock(GLOBALS.hScripts); } -/****************************************************************************\ -* -* Function: int varGetValue(char * lpszVarName); -* -* Description: Restituisce il valore corrente di una variabile globale -* -* Input: char * lpszVarName Nome della variabile -* -* Return: Valore corrente -* -* Note: Prima di questa funzione, bisogna richiamare LockVar() che -* locka le variabili globali per l'utilizzo. Dopo inoltre bi- -* sogna ricordarsi di chiamare UnlockVar() -* -\****************************************************************************/ - +/** + * Returns the current value of a global variable + * + * @param lpszVarName Name of the variable + * @returns Current value + * @remarks Before using this method, you must call LockVar() to + * lock the global variablves for use. Then afterwards, you will + * need to remember to call UnlockVar() + */ int32 varGetValue(const char *lpszVarName) { int i; LPMPALVAR v=GLOBALS.lpmvVars; @@ -263,17 +200,11 @@ int32 varGetValue(const char *lpszVarName) { } -/****************************************************************************\ -* -* Function: void varSetValue(char * lpszVarName, int val); -* -* Description: Setta un nuovo valore per una variabile globale di MPAL -* -* Input: char * lpszVarName Nome della variabile -* int val Valore da settare -* -\****************************************************************************/ - +/** + * Sets the value of a MPAL global variable + * @param lpszVarName Name of the variable + * @param val Value to set + */ void varSetValue(const char *lpszVarName, int32 val) { uint i; LPMPALVAR v = GLOBALS.lpmvVars; @@ -298,22 +229,14 @@ void varSetValue(const char *lpszVarName, int32 val) { } -/****************************************************************************\ -* -* Function: int locGetOrderFromNum(uint32 nLoc); -* -* Description: Trova l'indice della locazione #nLoc all'interno dell'array -* delle strutture delle locazioni -* -* Input: uint32 nLoc Numero della locazione da cercare -* -* Return: Indice, o -1 se la locazione non e' presente -* -* Note: Per funzionare, la funzione necessita che le locazioni siano -* state lockate con LockLoc() -* -\****************************************************************************/ - +/** + * Find the index of a location within the location array. Remember to call LockLoc() beforehand. + * + * @param nLoc Location number to search for + * @returns Index, or -1 if the location is not present + * @remarks This function requires the location list to have + * first been locked with a call to LockLoc(). + */ static int locGetOrderFromNum(uint32 nLoc) { int i; LPMPALLOCATION loc = GLOBALS.lpmlLocations; @@ -325,22 +248,14 @@ static int locGetOrderFromNum(uint32 nLoc) { return -1; } -/****************************************************************************\ -* -* Function: int msgGetOrderFromNum(uint32 nMsg); -* -* Description: Trova l'indice del messaggio #nMsg all'interno dell'array -* delle strutture dei messaggi -* -* Input: uint32 nMsg Numero del messaggio da cercare -* -* Return: Indice, o -1 se il messaggio non e' presente -* -* Note: Per funzionare, la funzione necessita che i messaggi siano -* stati lockati con LockMsg() -* -\****************************************************************************/ +/** + * Find the index of a message within the messages array + * @param nMsg Message number to search for + * @returns Index, or -1 if the message is not present + * @remarks This function requires the message list to have + * first been locked with a call to LockMsg() + */ static int msgGetOrderFromNum(uint32 nMsg) { int i; LPMPALMSG msg = GLOBALS.lpmmMsgs; @@ -352,23 +267,13 @@ static int msgGetOrderFromNum(uint32 nMsg) { return -1; } - -/****************************************************************************\ -* -* Function: int itemGetOrderFromNum(uint32 nItem); -* -* Description: Trova l'indice dell'item #nItem all'interno dell'array delle -* strutture degli item -* -* Input: uint32 nItem Numero dell'item da cercare -* -* Return: Indice, o -1 se l'item non e' presente -* -* Note: Per funzionare, questa funzione necessita che gli item siano -* stati lockati tramite LockItem() -* -\****************************************************************************/ - +/** + * Find the index of an item within the items array + * @param nItem Item number to search for + * @returns Index, or -1 if the item is not present + * @remarks This function requires the item list to have + * first been locked with a call to LockItems() + */ static int itemGetOrderFromNum(uint32 nItem) { int i; LPMPALITEM item = GLOBALS.lpmiItems; @@ -381,22 +286,13 @@ static int itemGetOrderFromNum(uint32 nItem) { } -/****************************************************************************\ -* -* Function: int scriptGetOrderFromNum(uint32 nScript); -* -* Description: Trova l'indice dello script #nScript all'interno dell'array -* delle strutture degli script -* -* Input: uint32 nScript Numero dello script da cercare -* -* Return: Indice, o -1 se lo script non e' presente -* -* Note: Per funzionare, questa funzione necessita che gli script siano -* stati lockati tramite LockScript() -* -\****************************************************************************/ - +/** + * Find the index of a script within the scripts array + * @param nScript Script number to search for + * @returns Index, or -1 if the script is not present + * @remarks This function requires the script list to have + * first been locked with a call to LockScripts() + */ static int scriptGetOrderFromNum(uint32 nScript) { int i; LPMPALSCRIPT script = GLOBALS.lpmsScripts; @@ -409,22 +305,13 @@ static int scriptGetOrderFromNum(uint32 nScript) { } -/****************************************************************************\ -* -* Function: int dialogGetOrderFromNum(uint32 nDialog); -* -* Description: Trova l'indice del dialog #nDialog all'interno dell'array -* delle strutture dei dialog -* -* Input: uint32 nDialog Numero del dialog da cercare -* -* Return: Indice, o -1 se il dialog non e' presente -* -* Note: Per funzionare, questa funzione necessita che i dialog siano -* stati lockati tramite LockDialogs() -* -\****************************************************************************/ - +/** + * Find the index of a dialog within the dialogs array + * @param nDialog Dialog number to search for + * @returns Index, or -1 if the dialog is not present + * @remarks This function requires the dialog list to have + * first been locked with a call to LockDialogs() + */ static int dialogGetOrderFromNum(uint32 nDialog) { int i; LPMPALDIALOG dialog = GLOBALS.lpmdDialogs; @@ -437,21 +324,12 @@ static int dialogGetOrderFromNum(uint32 nDialog) { } - -/****************************************************************************\ -* -* Function: char * DuplicateMessage(uint32 nMsgOrd); -* -* Description: Duplica un messaggio -* -* Input: uint32 nMsgOrd Indice del messaggio dentro l'array -* di strutture dei messaggi -* -* Return: Pointer al messaggio duplicato (che puo' essere liberato -* con GlobalFree()). -* -\****************************************************************************/ - +/** + * Duplicates a message + * @param nMsgOrd Index of the message inside the messages array + * @returns Pointer to the duplicated message. + * @remarks Remember to free the duplicated message when done with it. + */ static char *DuplicateMessage(uint32 nMsgOrd) { const char *origmsg; char *clonemsg; @@ -478,22 +356,13 @@ static char *DuplicateMessage(uint32 nMsgOrd) { } -/****************************************************************************\ -* -* Function: char * DuplicateDialogPeriod(uint32 nDlgOrd, uint32 nPeriod); -* -* Description: Duplica una frase di un dialog -* -* Input: uint32 nDlgOrd Indice del dialogo dentro l'array di -* strutture dei dialoghi -* -* uint32 nPeriod Numero della frase da duplicare -* -* Return: Pointer alla frase duplicata (che puo' essere liberata con -* GlobalFree()). -* -\****************************************************************************/ - +/** + * Duplicate a sentence of a dialog + * @param nDlgOrd Index of the dialog in the dialogs array + * @param nPeriod Sentence number to be duplicated. + * @returns Pointer to the duplicated phrase. Remember to free it + * when done with it. + */ static char *DuplicateDialogPeriod(uint32 nPeriod) { const char *origmsg; char *clonemsg; @@ -524,19 +393,12 @@ static char *DuplicateDialogPeriod(uint32 nPeriod) { } - -/****************************************************************************\ -* -* Function: HGLOBAL resLoad(uint32 dwId); -* -* Description: Carica una risorsa dal file MPR -* -* Input: uint32 dwId ID della risorsa da caricare -* -* Return: Handle alla memoria in cui si trova la risorsa -* -\****************************************************************************/ - +/** + * Load a resource from the MPR file + * + * @param dwId ID of the resource to load + * @returns Handle to the loaded resource + */ HGLOBAL resLoad(uint32 dwId) { int i; HGLOBAL h; @@ -736,21 +598,13 @@ static LPITEM GetItemData(uint32 nOrdItem) { } -/****************************************************************************\ -* -* Function: void CustomThread(LPCFCALL p); -* -* Description: Thread che richiama una funzione custom. Viene usato negli -* script, in modo che ciascuna funzione venga eseguita senza -* ritardare le altre -* -* Input: LPCFCALL p Struttura che definisce la chiamata -* -* Note: La struttura passata come parametro viene freeata con -* GlobalFree() alla fine dell'esecuzione. -* -\****************************************************************************/ - +/** + * Thread that calls a custom function. It is used in scripts, so that each script + * function is executed without delaying the others. + * + * @param param pointer to a pointer to the structure that defines the call. + * @remarks The passed structure is freed when the process finishes. + */ void CustomThread(CORO_PARAM, const void *param) { CORO_BEGIN_CONTEXT; LPCFCALL p; @@ -768,20 +622,12 @@ void CustomThread(CORO_PARAM, const void *param) { } -/****************************************************************************\ -* -* Function: void ScriptThread(LPMPALSCRIPT s); -* -* Description: Esegue uno script. Questa funzione e' pensata come starting -* point per un thread -* -* Input: LPMPALSCRIPT s Script da eseguire -* -* Note: Lo script passato come parametro viene, alla fine dell'ese- -* cuzione, freeato con una GlobalFree() -* -\****************************************************************************/ - +/** + * Main process for running a script. + * + * @param param Pointer to a pointer to a structure containing the script data. + * @remarks The passed structure is freed when the process finishes. + */ void ScriptThread(CORO_PARAM, const void *param) { CORO_BEGIN_CONTEXT; uint i, j, k; @@ -866,20 +712,13 @@ void ScriptThread(CORO_PARAM, const void *param) { } -/****************************************************************************\ -* -* Function: void ActionThread(LPMPALITEM item); -* -* Description: Thread che esegue una azione su un item. Il thread -* esegue sempre l'azione 0, per cui e' necessario creare -* un item nuovo in cui l'azione 0 sia quella richiesta. -* Inoltre non viene controllata l'espressione when, ma viene -* sempre eseguita l'azione. -* -* Input: LPMPALITEM item Item che contiene l'azione -* -\****************************************************************************/ - +/** + * Thread that performs an action on an item. the thread always executes the action, + * so it should create a new item in which the action is the one required. + * Furthermore, the expression is not checked, but it is always performed the action. + * + * @param param Pointer to a pointer to a structure containing the action. + */ void ActionThread(CORO_PARAM, const void *param) { // COROUTINE CORO_BEGIN_CONTEXT; @@ -935,8 +774,8 @@ void ActionThread(CORO_PARAM, const void *param) { /** * This thread monitors a created action to detect when it ends. - * @remarks Since actions can spawn sub-actions, this needs to be a - * separate thread to determine when the outer action is done + * @remarks Since actions can spawn sub-actions, this needs to be a + * separate thread to determine when the outer action is done */ void ShutUpActionThread(CORO_PARAM, const void *param) { // COROUTINE @@ -956,18 +795,12 @@ void ShutUpActionThread(CORO_PARAM, const void *param) { CORO_END_CODE; } -/****************************************************************************\ -* -* Function: void LocationPollThread(uint32 id); -* -* Description: Esegue il polling di una locazione (starting point di un -* thread). -* -* Input: uint32 id Indice per gli array relativi ai -* polling degli item delle locazioni -* -\****************************************************************************/ +/** + * Polls one location (starting point of a process) + * + * @param param Pointer to an index in the array of polling locations. + */ void LocationPollThread(CORO_PARAM, const void *param) { typedef struct { uint32 nItem, nAction; @@ -1257,22 +1090,17 @@ void LocationPollThread(CORO_PARAM, const void *param) { -/****************************************************************************\ -* -* Function: void ShutUpDialogThread(HANDLE hThread); -* -* Description: Aspetta la fine dell'esecuzione del dialog thread e ripri- -* stina le variabili globali indicando che il dialogo e' finito. -* -* Input: HANDLE hThread Handle del dialog thread -* -* Note: Si ricorre a questo thread aggiuntivo, al posto di azzerare -* le variabili all'interno del dialog thread stesso, poiche', -* a causa della natura ricorsiva di un dialogo, non e' sempre -* possibile sapere quando esattamente finisce un dialogo. -* -\****************************************************************************/ + +/** + * Wait for the end of the dialog execution thread, and then restore global + * variables indicating that the dialogue has finished. + * + * @param param Pointer to a handle to the dialog + * @remarks This additional process is used, instead of clearing variables + * within the same dialog thread, because due to the recursive nature of a dialog, + * it would be difficult to know within it when the dialog is actually ending. + */ void ShutUpDialogThread(CORO_PARAM, const void *param) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); @@ -1296,9 +1124,10 @@ void ShutUpDialogThread(CORO_PARAM, const void *param) { void DoChoice(CORO_PARAM, uint32 nChoice); + /** * Executes a group of the current dialog. Can 'be the Starting point of a process. - * @parm nGroup Number of the group to perform + * @parm nGroup Number of the group to perform */ void GroupThread(CORO_PARAM, const void *param) { CORO_BEGIN_CONTEXT; @@ -1371,16 +1200,11 @@ void GroupThread(CORO_PARAM, const void *param) { } -/****************************************************************************\ -* -* Function: void DoChoice(uint32 nChoice); -* -* Description: Esegue una scelta nel dialogo corrente -* -* Input: uint32 nChoice Numero della scelta da eseguire -* -\****************************************************************************/ - +/** + * Make a choice in the current dialog. + * + * @param nChoice Number of choice to perform + */ void DoChoice(CORO_PARAM, uint32 nChoice) { CORO_BEGIN_CONTEXT; LPMPALDIALOG dialog; @@ -1476,29 +1300,18 @@ void DoChoice(CORO_PARAM, uint32 nChoice) { } - -/****************************************************************************\ -* -* Function: HANDLE DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam); -* -* Description: Esegue una azione su un certo item -* -* Input: uint32 nAction Numero dell'azione -* uint32 ordItem Indice dell'item nelle strutture -* degli item -* uint32 dwParam Eventuale parametro per l'azione -* -* Return: Handle del thread che sta eseguendo l'azione, oppure -* CORO_INVALID_PID_VALUE se l'azione non e' definita, o l'item -* e' disattivato. -* -* Note: Si puo' ottenere l'indice dell'item a partire dal suo numero -* tramite la funzione itemGetOrderFromNum(). -* Gli item devono essere lockati, perche' questa funzione -* funzioni, tramite LockItem(); -* -\****************************************************************************/ - +/** + * Perform an action on a certain item. + * + * @param nAction Action number + * @param ordItem Index of the item in the items list + * @param dwParam Any parameter for the action. + * @returns Id of the process that was launched to perform the action, or + * CORO_INVALID_PID_VALUE if the action was not defined, or the item was inactive. + * @remarks You can get the index of an item from it's number by using + * the itemGetOrderFromNum() function. The items list must first be locked + * by calling LockItem(). + */ static uint32 DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { LPMPALITEM item = GLOBALS.lpmiItems; int i; @@ -1594,20 +1407,14 @@ static uint32 DoDialog(uint32 nDlgOrd, uint32 nGroup) { } -/****************************************************************************\ -* -* Function: bool DoSelection(uint32 nChoice, uint32 dwData); -* -* Description: Prende nota del select scelto dall'utente, e avverte il -* thread che stava eseguendo il dialogo che puo' continuare. -* -* Input: uint32 nChoice Numero della scelta che era in corso -* uint32 dwData Dato abbinato al select selezionato -* -* Return: true se tutto OK, false in caso di errore -* -\****************************************************************************/ - +/** + * Takes note of the selection chosen by the user, and warns the process that was running + * the box that it can continue. + * + * @param nChoice Number of choice that was in progress + * @param dwData Since combined with select selection + * @returns True if everything is OK, false on failure + */ bool DoSelection(uint32 i, uint32 dwData) { LPMPALDIALOG dialog=GLOBALS.lpmdDialogs+GLOBALS.nExecutingDialog; int j; @@ -1625,30 +1432,18 @@ bool DoSelection(uint32 i, uint32 dwData) { } +/** + * @defgroup Exported functions + */ -/****************************************************************************\ -* Exported functions -\****************************************************************************/ - -/****************************************************************************\ -* -* Function: bool mpalInit(LPSTR lpszMpcFileName, LPSTR lpszMprFileName, -* LPLPCUSTOMFUNCTION lplpcfArray); -* -* Description: Inizializza la libreria MPAL, e apre un file .MPC, che -* verra' utilizzato per tutte le query -* -* Input: char * lpszMpcFileName Nome del file .MPC, comprensivo di -* estensione -* char * lpszMprFileName Nome del file .MPR, comprensivo di -* estensione -* LPLPCUSTOMFUNCTION -* lplpcfArray Array di pointer a funzioni custom -* -* Return: true se tutto OK, false in caso di errore -* -\****************************************************************************/ - +/** + * Initialises the MPAL library and opens the .MPC file, which will be used for all queries. + * + * @param lpszMpcFileName Name of the MPC file + * @param lpszMprFileName Name of the MPR file + * @param lplpcfArray Array of pointers to custom functions. + * @returns True if everything is OK, false on failure + */ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, LPLPCUSTOMFUNCTION lplpcfArray, Common::String *lpcfStrings) { Common::File hMpc; @@ -1803,34 +1598,15 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, return true; } -/****************************************************************************\ -* -* Function: uint32 mpalQuery(uint16 wQueryType, ...); -* -* Description: Questa e' la funzione generale per comunicare con la libreria, -* per richiedere informazioni riguardo a quanto si trova nel -* file .MPC -* -* Input: uint16 wQueryType Tipo di query. La lista e' in -* enum QueryTypes -* -* Return: 4 bytes che dipendono dal tipo di query -* -* Note: E' _FORTEMENTE_ consigliato utilizzare le macro -* definite sopra per utilizzare le query, dato che -* permettono di evitare spiacevoli bug dovuti a dimenticanze -* di parametri. -* -\****************************************************************************/ - -#define GETARG(type) va_arg(v, type) /** - * MPAL Query variation #1 - dword return - * This variation handles mpal query types that need to return a dword result. + * This is a general function to communicate with the library, to request information + * about what is in the .MPC file * - * @param wQueryType Query type - * @param v Variable length argument list + * @param wQueryType Type of query. The list is in the QueryTypes enum. + * @returns 4 bytes depending on the type of query + * @remarks This is the specialised version of the original single mpalQuery + * method that returns numeric results. */ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { int x, y, z; @@ -1844,6 +1620,7 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { GLOBALS.mpalError = OK; if (wQueryType == MPQ_VERSION) { + /* * uint32 mpalQuery(MPQ_VERSION); */ @@ -2021,11 +1798,13 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { } /** - * MPAL Query variation #1 - dword return - * This variation handles mpal query types that need to return a pointer/handle result + * This is a general function to communicate with the library, to request information + * about what is in the .MPC file * - * @param wQueryType Query type - * @param v Variable length argument list + * @param wQueryType Type of query. The list is in the QueryTypes enum. + * @returns 4 bytes depending on the type of query + * @remarks This is the specialised version of the original single mpalQuery + * method that returns a pointer or handle. */ HANDLE mpalQueryHANDLE(uint16 wQueryType, ...) { int x, y; @@ -2176,13 +1955,15 @@ HANDLE mpalQueryHANDLE(uint16 wQueryType, ...) { return hRet; } + /** - * MPAL Query variation #1 - dword return - * This variation handles mpal query types that need to return a pointer/handle result + * This is a general function to communicate with the library, to request information + * about what is in the .MPC file * - * @param wQueryType Query type - * @param dwRet DWORD return value (when coroutine method completes) - * @param v Variable length argument list + * @param wQueryType Type of query. The list is in the QueryTypes enum. + * @returns 4 bytes depending on the type of query + * @remarks This is the specialised version of the original single mpalQuery + * method that needs to run within a co-routine context. */ void mpalQueryCORO(CORO_PARAM, uint16 wQueryType, uint32 *dwRet, ...) { CORO_BEGIN_CONTEXT; @@ -2216,34 +1997,22 @@ void mpalQueryCORO(CORO_PARAM, uint16 wQueryType, uint32 *dwRet, ...) { } -/****************************************************************************\ -* -* Function: uint32 mpalGetError(void); -* -* Description: Ritorna il codice di errore corrente di MPAL -* -* Return: Codice di errore -* -\****************************************************************************/ - +/** + * Returns the current MPAL error code + * + * @returns Error code + */ uint32 mpalGetError(void) { return GLOBALS.mpalError; } -/****************************************************************************\ -* -* Function: void mpalExecuteScript(int nScript); -* -* Description: Esegue uno script. Lo script viene eseguito in multitasking -* tramite un thread. -* -* Input: int nScript Numero dello script da eseguire -* -* Return: true se lo script e' stato avviato, false in caso di errore -* -\****************************************************************************/ - +/** + * Execute a script. The script runs on multitasking by a thread. + * + * @param nScript Script number to run + * @returns TRUE if the script 'was launched, FALSE on failure + */ bool mpalExecuteScript(int nScript) { int n; LPMPALSCRIPT s; @@ -2265,38 +2034,26 @@ bool mpalExecuteScript(int nScript) { } -/****************************************************************************\ -* -* Function: void mpalInstallItemIrq(LPITEMIRQFUNCTION GLOBALS.lpiifCustom); -* -* Description: Install a custom routine that will be called by MPAL every -* time the pattern of an item has been changed. -* -* Input: LPITEMIRQFUNCTION GLOBALS.lpiifCustom Custom function to install -* -\****************************************************************************/ - +/** + * Install a custom routine That will be called by MPAL every time the pattern + * of an item has been changed. + * + * @param lpiifCustom Custom function to install + */ void mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCus) { GLOBALS.lpiifCustom = lpiifCus; } -/****************************************************************************\ -* -* Function: bool mpalStartIdlePoll(int nLoc); -* -* Description: Process the idle actions of the items on one location. -* -* Input: int nLoc Number of the location whose items -* must be processed for idle actions. -* -* Return: true se tutto OK, false se si e' superato il limite massimo. -* -* Note: Il numero massimo delle locazione che e' possibile pollare -* contemporaneamente e' contenuto nel define MAXPOLLINGFUNCIONS -* -\****************************************************************************/ - +/** + * Process the idle actions of the items on one location. + * + * @param nLoc Number of the location whose items must be processed + * for idle actions. + * @returns TRUE if all OK, and FALSE if it exceeded the maximum limit. + * @remarks The maximum number of locations that can be polled + * simultaneously is defined defined by MAXPOLLINGFUNCIONS + */ bool mpalStartIdlePoll(int nLoc) { uint32 i; @@ -2322,20 +2079,13 @@ bool mpalStartIdlePoll(int nLoc) { } - -/****************************************************************************\ -* -* Function: bool mpalEndIdlePoll(int nLoc); -* -* Description: Stop processing the idle actions of the items on one location. -* -* Input: int nLoc Number of the location -* -* Return: true se tutto OK, false se la locazione specificata non era -* in fase di polling -* -\****************************************************************************/ - +/** + * Stop processing the idle actions of the items on one location. + * + * @param nLo Number of the location + * @returns TRUE if all OK, FALSE if the specified location was not + * in the process of polling + */ void mpalEndIdlePoll(CORO_PARAM, int nLoc, bool *result) { CORO_BEGIN_CONTEXT; int i; @@ -2365,33 +2115,22 @@ void mpalEndIdlePoll(CORO_PARAM, int nLoc, bool *result) { } - -/****************************************************************************\ -* -* Function: int mpalGetSaveStateSize(void); -* -* Description: Acquire the length of a save state -* -* Return: Length in bytes -* -\****************************************************************************/ - +/** + * Retrieve the length of a save state + * + * @returns Length in bytes + */ int mpalGetSaveStateSize(void) { return GLOBALS.nVars * sizeof(MPALVAR) + 4; } -/****************************************************************************\ -* -* Function: void mpalSaveState(byte *buf); -* -* Description: Store the save state into a buffer. The buffer must be -* length at least the size specified with mpalGetSaveStateSize -* -* Input: byte *buf Buffer where to store the state -* -\****************************************************************************/ - +/** + * Store the save state into a buffer. The buffer must be + * length at least the size specified with mpalGetSaveStateSize + * + * @param buf Buffer where to store the state + */ void mpalSaveState(byte *buf) { LockVar(); WRITE_LE_UINT32(buf, GLOBALS.nVars); @@ -2399,18 +2138,13 @@ void mpalSaveState(byte *buf) { UnlockVar(); } -/****************************************************************************\ -* -* Function: int mpalLoadState(byte *buf); -* -* Description: Load a save state from a buffer. -* -* Input: byte *buf Buffer where to store the state -* -* Return: Length of the state in bytes -* -\****************************************************************************/ +/** + * Load a save state from a buffer. + * + * @param buf Buffer where to store the state + * @returns Length of the state buffer in bytes + */ int mpalLoadState(byte *buf) { // Dobbiamo distruggere tutte le variabili e ricrearle GlobalFree(GLOBALS.hVars); diff --git a/engines/tony/mpal/mpal.h b/engines/tony/mpal/mpal.h index 319f71c6a8..a14bfd1895 100644 --- a/engines/tony/mpal/mpal.h +++ b/engines/tony/mpal/mpal.h @@ -126,6 +126,12 @@ namespace Tony { namespace MPAL { +/****************************************************************************\ +* Type definitions +\****************************************************************************/ + +typedef void *HANDLE; + /****************************************************************************\ * Macro definitions and structures \****************************************************************************/ @@ -140,25 +146,19 @@ namespace MPAL { #define LPSTR char * -/****************************************************************************\ -* enum QueryCoordinates -* --------------------- -* Description: Macro for use with queries that may refer to X and Y co-ordinates -\****************************************************************************/ - +/** + * Macro for use with queries that may refer to X and Y co-ordinates + */ enum QueryCoordinates { MPQ_X, MPQ_Y }; -/****************************************************************************\ -* enum QueryTypes -* --------------- -* Description: Query can be used with mpalQuery methods. In practice corresponds -* all claims that can do at the library -\****************************************************************************/ - +/** + * Query can be used with mpalQuery methods. In practice corresponds all claims + * that can do at the library + */ enum QueryTypes { /* General Query */ MPQ_VERSION=10, @@ -189,13 +189,9 @@ enum QueryTypes { MPQ_DO_DIALOG }; - -/****************************************************************************\ -* typedef ITEM -* ------------ -* Description: Framework to manage the animation of an item -\****************************************************************************/ - +/** + * Framework to manage the animation of an item + */ typedef struct { char *frames[MAXFRAMES]; Common::Rect frameslocations[MAXFRAMES]; @@ -214,311 +210,188 @@ typedef struct { typedef ITEM *LPITEM; -/****************************************************************************\ -* typedef LPCUSTOMFUNCTION -* ------------------------ -* Description: Define a custom function, to use the language MPAL -* to perform various controls as a result of an action -\****************************************************************************/ - +/** + * Define a custom function, to use the language MPAL to perform various controls as a result of an action + */ typedef void (*LPCUSTOMFUNCTION)(CORO_PARAM, uint32, uint32, uint32, uint32); typedef LPCUSTOMFUNCTION *LPLPCUSTOMFUNCTION; - -/****************************************************************************\ -* typedef LPITEMIRQFUNCTION -* ------------------------- -* Description: Define an IRQ of an item that is called when the -* pattern changes or the status of an item -\****************************************************************************/ - +/** + * + * Define an IRQ of an item that is called when the pattern changes or the status of an item + */ typedef void (*LPITEMIRQFUNCTION)(uint32, int, int); typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; +/** + * @defgroup Macrofunctions query + * + * The following are defines used for simplifying calling the mpalQuery variants + */ -/****************************************************************************\ -* Macrofunctions query -\****************************************************************************/ - -/****************************************************************************\ -* -* Function: uint32 mpalQueryVersion(void); -* -* Description: Gets the current version of MPAL -* -* Return: Version number (0x1232 = 1.2.3b) -* -\****************************************************************************/ - +/** + * Gets the current version of MPAL + * + * @returns Version number (0x1232 = 1.2.3b) + */ #define mpalQueryVersion() \ (uint16)mpalQueryDWORD(MPQ_VERSION) - - -/****************************************************************************\ -* -* Function: uint32 mpalQueryGlobalVar(LPSTR lpszVarName); -* -* Description: Gets the numerical value of a global variable -* -* Input: LPSTR lpszVarName Nome della variabile (ASCIIZ) -* -* Return: Valore della variabile -* -* Note: This query was implemented for debugging. The program, -* if well designed, should not need to access variables from -* within the library. -* -\****************************************************************************/ - +/** + * Gets the numerical value of a global variable + * + * @param lpszVarName Nome della variabile (ASCIIZ) + * @returns Global variable value + * @remarks This query was implemented for debugging. The program, + * if well designed, should not need to access variables from + * within the library. + */ #define mpalQueryGlobalVar(lpszVarName) \ mpalQueryDWORD(MPQ_GLOBAL_VAR, (const char *)(lpszVarName)) - -/****************************************************************************\ -* -* Function: HGLOBAL mpalQueryResource(uint32 dwResId); -* -* Description: Provides access to a resource inside the .MPC file -* -* Input: uint32 dwResId ID della risorsa -* -* Return: Handle to a memory area containing the resource, -* ready for use. -* -\****************************************************************************/ - +/** + * Provides access to a resource inside the .MPC file + * + * @param dwResId Resource Id + * @returns Handle to a memory area containing the resource, ready for use. + */ #define mpalQueryResource(dwResId) \ mpalQueryHANDLE(MPQ_RESOURCE, (uint32)(dwResId)) - -/****************************************************************************\ -* -* Function: LPSTR mpalQueryMessage(uint32 nMsg); -* -* Description: Returns a message. -* -* Input: uint32 nMsg Message number -* -* Return: ASCIIZ message -* -* Note: The returned pointer must be freed with GlobalFree() +/** + * Returns a message. + * + * @param nMsg Message number + * @returns ASCIIZ message + * @remarks The returned pointer must be freed via the memory manager * after use. The message will be in ASCIIZ format. -* -\****************************************************************************/ - +*/ #define mpalQueryMessage(nMsg) \ (LPSTR)mpalQueryHANDLE(MPQ_MESSAGE, (uint32)(nMsg)) - -/****************************************************************************\ -* -* Function: HGLOBAL mpalQueryLocationImage(uint32 nLoc); -* -* Description: Provides a image image -* -* Input: uint32 nLoc Locazion number -* -* Return: Returns a picture handle -* -\****************************************************************************/ - +/** + * Provides a location image + * @return Returns a picture handle + */ #define mpalQueryLocationImage(nLoc) \ mpalQueryHANDLE(MPQ_LOCATION_IMAGE, (uint32)(nLoc)) - -/****************************************************************************\ -* -* Function: uint32 mpalQueryLocationSize(uint32 nLoc, uint32 dwCoord); -* -* Description: Request the x or y size of a location in pixels -* -* Input: uint32 nLoc Location number -* uint32 dwCoord MPQ_Xr o MPQ_Y -* -* Return: Size -* -\****************************************************************************/ - +/** + * Request the x or y size of a location in pixels + * + * @param nLoc Location number + * @param dwCoord MPQ_X or MPQ_Y coordinate to retrieve + * @returns Size + */ #define mpalQueryLocationSize(nLoc,dwCoord) \ mpalQueryDWORD(MPQ_LOCATION_SIZE,(uint32)(nLoc),(uint32)(dwCoord)) - -/****************************************************************************\ -* -* Function: uint32 * mpalQueryItemList(uint32 nLoc); -* -* Description: Provides the list of objects in the lease. -* -* Input: uint32 nLoc Location number -* -* Return: List of objects (accessible by Item [0], Item [1], etc.) -* -\****************************************************************************/ -// TODO: Check if the results of this are endian safe +/** + * Provides the list of objects in a location. + * + * @param nLoc Location number + * @returns List of objects (accessible by Item [0], Item [1], etc.) + */ +// TODO: Determine if this is endian safe #define mpalQueryItemList(nLoc) \ (uint32 *)mpalQueryHANDLE(MPQ_ITEM_LIST,(uint32)(nLoc)) - -/****************************************************************************\ -* -* Function: LPBKGANIM mpalQueryItemData(uint32 nItem); -* -* Description: Provides information on an item -*e -* Input: uint32 nItem Item number -* -* Return: structure filled with requested information -* -\****************************************************************************/ - +/** + * Provides information on an item + * + * @param nItem Item number + * @returns Structure filled with requested information + */ #define mpalQueryItemData(nItem) \ (LPITEM)mpalQueryHANDLE(MPQ_ITEM_DATA,(uint32)(nItem)) - -/****************************************************************************\ -* -* Function: uint32 mpalQueryItemPattern(uint32 nItem); -* -* Description: Provides the current pattern of an item -* -* Input: uint32 nItem Item number -* -* Return: Number of animation patterns to be executed. -* -* Note: By default, the pattern of 0 indicates that we should -* do nothing. -* -\****************************************************************************/ - +/** + * Provides the current pattern of an item + * + * @param nItem Item number + * @returns Number of animation patterns to be executed. + * @remarks By default, the pattern of 0 indicates that we should do nothing. + */ #define mpalQueryItemPattern(nItem) \ mpalQueryDWORD(MPQ_ITEM_PATTERN,(uint32)(nItem)) - -/****************************************************************************\ -* -* Function: bool mpalQueryItemIsActive(uint32 nItem); -* -* Description: Returns true if an item is active -* -* Input: uint32 nItem Item number -* -* Return: TRUE if the item is active, FALSE otherwise -* -\****************************************************************************/ - +/** + * Returns true if an item is active + * + * @param nItem Item number + * @returns TRUE if the item is active, FALSE otherwise + */ #define mpalQueryItemIsActive(nItem) \ (bool)mpalQueryDWORD(MPQ_ITEM_IS_ACTIVE,(uint32)(nItem)) -/****************************************************************************\ -* -* Function: void mpalQueryItemName(uint32 nItem, LPSTR lpszName); -* -* Description: Returns the name of an item -* -* Input: uint32 nItem Item number -* LPSTR lpszName Pointer to a buffer of at least 33 bytes -* that will be filled with the name -* -* Note: If the item is not active (ie. if its status or number -* is less than or equal to 0), the string will be empty. -* -\****************************************************************************/ - +/** + * Returns the name of an item + * + * @param nItem Item number + * @param lpszName Pointer to a buffer of at least 33 bytes + * that will be filled with the name + * @remarks If the item is not active (ie. if its status or number + * is less than or equal to 0), the string will be empty. + */ #define mpalQueryItemName(nItem, lpszName) \ mpalQueryHANDLE(MPQ_ITEM_NAME,(uint32)(nItem), (LPSTR)(lpszName)) - -/****************************************************************************\ -* -* Function: LPSTR mpalQueryDialogPeriod(uint32 nDialog, uint32 nPeriod); -* -* Description: Returns a sentence of dialog. -* -* Input: uint32 nDialog Dialog number -* uint32 nPeriod Number of words -* -* Return: A pointer to the string of words, or NULL on failure. -* -* Note: The string must be freed after use by GlobalFree (). -* -* Unlike normal messages, the sentences of dialogue -* are formed by a single string terminated with 0. -* -\****************************************************************************/ - +/** + * Returns a sentence of dialog. + * + * @param nDialog Dialog number + * @param nPeriod Number of words + * @returns A pointer to the string of words, or NULL on failure. + * @remarks The string must be freed after use using the memory manager. + * Unlike normal messages, the sentences of dialogue are formed by a single + * string terminated with 0. + */ #define mpalQueryDialogPeriod(nPeriod) \ (LPSTR)mpalQueryHANDLE(MPQ_DIALOG_PERIOD, (uint32)(nPeriod)) - -/****************************************************************************\ -* -* Function: int mpalQueryDialogWaitForChoice(void); -* -* Description: Wait until the moment in which the need is signaled -* to make a choice by the user. -* -* Return: Number of choice to be made, or -1 if the dialogue is finished. -* -\****************************************************************************/ - +/** + * Wait until the moment in which the need is signaled to make a choice by the user. + * @returns Number of choice to be made, or -1 if the dialogue is finished. + */ #define mpalQueryDialogWaitForChoice(dwRet) \ CORO_INVOKE_2(mpalQueryCORO, MPQ_DIALOG_WAITFORCHOICE, dwRet) -/****************************************************************************\ -* -* Function: uint32 * mpalQueryDialogSelectList(uint32 nChoice); -* -* Description: Requires a list of various options for some choice within -* the current dialog. - -* Input: uint32 nChoice Choice number -* -* Return: A pointer to an array containing the data matched to each option. -* -* Note: The figure 'a uint32 specified in the source to which MPAL -* You can 'assign meaning that the more' suits. -* -* The pointer msut be freed after use by GlobalFree(). -* -\****************************************************************************/ +/** + * Requires a list of various options for some choice within the current dialog. + * + * @param nChoice Choice number + * @returns A pointer to an array containing the data matched to each option. + * @remarks The figure 'a uint32 specified in the source to which MPAL + * You can assign meaning that the more' suits. + * The pointer msut be freed after use using the memory memory. + */ #define mpalQueryDialogSelectList(nChoice) \ (uint32 *)mpalQueryHANDLE(MPQ_DIALOG_SELECTLIST,(uint32)(nChoice)) - -/****************************************************************************\ -* -* Function: bool mpalQueryDialogSelection(uint32 nChoice, uint32 dwData); -* -* Description: Warns the library that the user has selected, in a certain -* choice of the current dialog, corresponding option -* at a certain given. -* -* Input: uint32 nChoice Choice number of the choice that -* was in progress -* uint32 dwData Option that was selected by the user. -* -* Return: TRUE if all OK, FALSE on failure. -* -* Note: After execution of this query, MPAL continue -* Groups according to the execution of the dialogue. And necessary so the game -* remains on hold again for another Chosen by mpalQueryDialogWaitForChoice (). -* -\****************************************************************************/ - +/** + * Warns the library that the user has selected, in a certain choice of the current dialog, + * corresponding option at a certain given. + * + * @param nChoice Choice number of the choice that was in progress + * @param dwData Option that was selected by the user. + * @returns TRUE if all OK, FALSE on failure. + * @remarks After execution of this query, MPAL continue + * Groups according to the execution of the dialogue. And necessary so the game + * remains on hold again for another chosen by mpalQueryDialogWaitForChoice (). + */ #define mpalQueryDialogSelection(nChoice,dwData) \ (bool)mpalQueryDWORD(MPQ_DIALOG_SELECTION,(uint32)(nChoice),(uint32)(dwData)) @@ -526,245 +399,169 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; mpalQueryDWORD(MPQ_DIALOG_SELECTION,(uint32)(nChoice),(uint32)(dwData)) -/****************************************************************************\ -* -* Function: HANDLE mpalQueryDoAction(uint32 nAction, uint32 nItem, -* uint32 dwParam); -* -* Description: Warns the library an action was performed on a Object. -* The library will call 'custom functions, if necessary. -* -* Input: uint32 nAction Action number -* uint32 nItem Item number -* uint32 dwParam Action parameter -* -* Return: Handle to the thread that is performing the action, or -* CORO_INVALID_PID_VALUE if the action is not 'defined for -* the item, or the item and 'off. -* -* Note: The parameter is used primarily to implement actions -* as "U.S." involving two objects together. The action will be executed only -* if the item is active, ie if its status is a positive number greater than 0. -* -\****************************************************************************/ - +/** + * Warns the library an action was performed on a Object. + * The library will call custom functions, if necessary. + * + * @param nAction Action number + * @param nItem Item number + * @param dwParam Action parameter + * @returns Handle to the thread that is performing the action, or CORO_INVALID_PID_VALUE + * if the action is not defined for the item, or the item is inactive. + * @remarks The parameter is used primarily to implement actions + * as "U.S." involving two objects together. The action will be executed only + * if the item is active, ie if its status is a positive number greater than 0. + */ #define mpalQueryDoAction(nAction, nItem, dwParam) \ mpalQueryDWORD(MPQ_DO_ACTION, (uint32)(nAction), (uint32)(nItem), (uint32)(dwParam)) - -/****************************************************************************\ -* -* Function: HANDLE mpalQueryDoDialog(uint32 nDialog, uint32 nGroup); -* -* Description: Warns the library a dialogue was required. -* -* Input: uint32 nDialog Dialog number -* uint32 nGroup Group number to use -* -* Return: Handle to the thread that is running the box, or -* CORO_INVALID_PID_VALUE if the dialogue does not exist. -* -\****************************************************************************/ - +/** + * Warns the library a dialogue was required. + * + * @param nDialog Dialog number + * @param nGroup Group number to use + * @returns Handle to the thread that is running the box, or + * CORO_INVALID_PID_VALUE if the dialogue does not exist. + */ #define mpalQueryDoDialog(nDialog,nGroup) \ mpalQueryDWORD(MPQ_DO_DIALOG, (uint32)(nDialog),(uint32)(nGroup)) -/****************************************************************************\ -* Functions exported to the main game -\****************************************************************************/ - +/** + * @defgroup Functions exported to the main game + */ -/****************************************************************************\ -* -* Function: bool mpalInit(LPSTR lpszMpcFileName, LPSTR lpszMprFileName, -* LPLPCUSTOMFUNCTION lplpcfArray); -* -* Description: Initializes the MPAL library, and opens an .MPC file, which -* will be 'used for all queries -* -* Input: LPSTR lpszMpcFileName Name of the .MPC file, including extension -* LPSTR lpszMprFileName Name of the .MPR file, including extension -* LPLPCUSTOMFUNCTION Array of pointers to custom functions -* -* Return: TRUE if all OK, FALSE on failure -* -\****************************************************************************/ +/** + * Initializes the MPAL library, and opens an .MPC file, which will be 'used for all queries + * @param lpszMpcFileName Name of the .MPC file, including extension + * @param lpszMprFileName Name of the .MPR file, including extension + * @param lplpcfArray Array of pointers to custom functions + * @returns TRUE if all OK, FALSE on failure + */ bool mpalInit(const char *lpszFileName, const char *lpszMprFileName, LPLPCUSTOMFUNCTION lplpcfArray, Common::String *lpcfStrings); - -/****************************************************************************\ -* -* Function: uint32 mpalQuery(uint16 wQueryType, ...); -* -* Description: This is the general function to communicate with the library, -* To request information about what is in the .MPC file -* -* Input: uint16 wQueryType Type of query. The list is in -* the QueryTypes enum. -* -* Return: 4 bytes depending on the type of query -* -* Note: I _strongly_ recommended to use macros defined above to use -* the query, since it helps avoid any unpleasant bugs due to -* forgeting parameters. -* -\****************************************************************************/ - -typedef void *HANDLE; - +/** + * This is a general function to communicate with the library, to request information + * about what is in the .MPC file + * + * @param wQueryType Type of query. The list is in the QueryTypes enum. + * @returns 4 bytes depending on the type of query + * @remarks This is the specialised version of the original single mpalQuery + * method that returns numeric results. + */ uint32 mpalQueryDWORD(uint16 wQueryType, ...); +/** + * This is a general function to communicate with the library, to request information + * about what is in the .MPC file + * + * @param wQueryType Type of query. The list is in the QueryTypes enum. + * @returns 4 bytes depending on the type of query + * @remarks This is the specialised version of the original single mpalQuery + * method that returns a pointer or handle. + */ HANDLE mpalQueryHANDLE(uint16 wQueryType, ...); +/** + * This is a general function to communicate with the library, to request information + * about what is in the .MPC file + * + * @param wQueryType Type of query. The list is in the QueryTypes enum. + * @returns 4 bytes depending on the type of query + * @remarks This is the specialised version of the original single mpalQuery + * method that needs to run within a co-routine context. + */ void mpalQueryCORO(CORO_PARAM, uint16 wQueryType, uint32 *dwRet, ...); -/****************************************************************************\ -* -* Function: bool mpalExecuteScript(int nScript); -* -* Description: Execute a script. The script runs on multitasking by a thread. -* -* Input: int nScript Script number to run -* -* Return: TRUE if the script 'was launched, FALSE on failure -* -\****************************************************************************/ +/** + * Execute a script. The script runs on multitasking by a thread. + * + * @param nScript Script number to run + * @returns TRUE if the script 'was launched, FALSE on failure + */ bool mpalExecuteScript(int nScript); - -/****************************************************************************\ -* -* Function: uint32 mpalGetError(void); -* -* Description: Returns the current MPAL error code -* -* Return: Error code -* -\****************************************************************************/ - +/** + * Returns the current MPAL error code + * + * @returns Error code + */ uint32 mpalGetError(void); - -/****************************************************************************\ -* -* Function: void mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCustom); -* -* Description: Install a custom routine That will be called by MPAL -* every time the pattern of an item has-been changed. -* -* Input: LPITEMIRQFUNCTION lpiifCustom Custom function to install -* -\****************************************************************************/ - +/** + * Install a custom routine That will be called by MPAL every time the pattern + * of an item has been changed. + * + * @param lpiifCustom Custom function to install + */ void mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCustom); -/****************************************************************************\ -* -* Function: bool mpalStartIdlePoll(int nLoc); -* -* Description: Process the idle actions of the items on one location. -* -* Input: int nLoc Number of the location whose items -* must be processed for idle actions. -* -* Return: TRUE if all OK, and FALSE if it exceeded the maximum limit. -* -* Note: The maximum number of locations that can be polled -* simultaneously is defined defined by MAXPOLLINGFUNCIONS -* -\****************************************************************************/ - +/** + * Process the idle actions of the items on one location. + * + * @param nLoc Number of the location whose items must be processed + * for idle actions. + * @returns TRUE if all OK, and FALSE if it exceeded the maximum limit. + * @remarks The maximum number of locations that can be polled + * simultaneously is defined defined by MAXPOLLINGFUNCIONS + */ bool mpalStartIdlePoll(int nLoc); -/****************************************************************************\ -* -* Function: bool mpalEndIdlePoll(int nLoc); -* -* Description: Stop processing the idle actions of the items on one location. -* -* Input: int nLoc Number of the location -* -* Return: TRUE if all OK, FALSE if the specified location was not -* in the process of polling -* -\****************************************************************************/ - +/** + * Stop processing the idle actions of the items on one location. + * + * @param nLo Number of the location + * @returns TRUE if all OK, FALSE if the specified location was not + * in the process of polling + */ void mpalEndIdlePoll(CORO_PARAM, int nLoc, bool *result); -/****************************************************************************\ -* -* Function: int mpalLoadState(LPBYTE buf); -* -* Description: Load a save state from a buffer. -* -* Input: LPBYTE buf Buffer where to store the state -* -* Return: Length of the state in bytes -* -\****************************************************************************/ - +/** + * Load a save state from a buffer. + * + * @param buf Buffer where to store the state + * @returns Length of the state buffer in bytes + */ int mpalLoadState(byte *buf); - -/****************************************************************************\ -* -* Function: void mpalSaveState(LPBYTE buf); -* -* Description: Store the save state into a buffer. The buffer must be -* length at least the size specified with mpalGetSaveStateSize -* -* Input: LPBYTE buf Buffer where to store the state -* -\****************************************************************************/ - +/** + * Store the save state into a buffer. The buffer must be + * length at least the size specified with mpalGetSaveStateSize + * + * @param buf Buffer where to store the state + */ void mpalSaveState(byte *buf); - -/****************************************************************************\ -* -* Function: int mpalGetSaveStateSize(void); -* -* Description: Acquire the length of a save state -* -* Return: Length in bytes -* -\****************************************************************************/ - +/** + * Retrieve the length of a save state + * + * @returns Length in bytes + */ int mpalGetSaveStateSize(void); -/****************************************************************************\ -* -* Function: void LockVar(void); -* -* Description: Locka le variabili per accederci -* -\****************************************************************************/ - -extern void LockVar(void); +/** + * Locks the variables for access + */ +void LockVar(void); -/****************************************************************************\ -* -* Function: void UnlockVar(void); -* -* Description: Unlocka le variabili dopo l'uso -* -\****************************************************************************/ -extern void UnlockVar(void); +/** + * Unlocks variables after use + */ +void UnlockVar(void); } // end of namespace MPAL -- cgit v1.2.3 From bcaeacf1246b652f1564fc7696719ca9429b5acf Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 18 May 2012 22:57:25 +1000 Subject: TONY: Implemented support for loading savegames directly from the launcher. It's not perfect.. the startup screen briefly flashes, and Tony briefly disappears when you do a first action afterwards. --- engines/tony/mpal/mpal.cpp | 11 ++++++++--- engines/tony/tony.cpp | 5 +++-- engines/tony/tony.h | 4 ++-- 3 files changed, 13 insertions(+), 7 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index a173b707f2..854372cdda 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -767,8 +767,6 @@ void ActionThread(CORO_PARAM, const void *param) { debugC(DEBUG_DETAILED, kTonyDebugActions, "Action Process %d ended", CoroScheduler.getCurrentPID()); - CORO_KILL_SELF(); - CORO_END_CODE; } @@ -780,6 +778,7 @@ void ActionThread(CORO_PARAM, const void *param) { void ShutUpActionThread(CORO_PARAM, const void *param) { // COROUTINE CORO_BEGIN_CONTEXT; + int slotNumber; CORO_END_CONTEXT(_ctx); uint32 pid = *(const uint32 *)param; @@ -790,7 +789,13 @@ void ShutUpActionThread(CORO_PARAM, const void *param) { GLOBALS.bExecutingAction = false; - CORO_KILL_SELF(); + if (_vm->_initialLoadSlotNumber != -1) { + _ctx->slotNumber = _vm->_initialLoadSlotNumber; + _vm->_initialLoadSlotNumber = -1; + + CORO_INVOKE_1(_vm->LoadState, _ctx->slotNumber); + } + CORO_END_CODE; } diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index c7056cb88d..2dbe102424 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -38,6 +38,7 @@ TonyEngine *_vm; TonyEngine::TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc), _randomSource("tony") { _vm = this; + _loadSlotNumber = -1; DebugMan.addDebugChannel(kTonyDebugAnimations, "animations", "Animations debugging"); DebugMan.addDebugChannel(kTonyDebugActions, "actions", "Actions debugging"); @@ -45,11 +46,11 @@ TonyEngine::TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc) : Eng DebugMan.addDebugChannel(kTonyDebugMusic, "music", "Music debugging"); // Set up load slot number - _loadSlotNumber = -1; + _initialLoadSlotNumber = -1; if (ConfMan.hasKey("save_slot")) { int slotNumber = ConfMan.getInt("save_slot"); if (slotNumber >= 0 && slotNumber <= 99) - _loadSlotNumber = slotNumber; + _initialLoadSlotNumber = slotNumber; } } diff --git a/engines/tony/tony.h b/engines/tony/tony.h index f40eb1325d..18d4a37067 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -78,8 +78,6 @@ struct VoiceHeader { class TonyEngine : public Engine { private: - int _loadSlotNumber; - Common::ErrorCode Init(); void InitMusic(); void CloseMusic(); @@ -122,6 +120,8 @@ public: bool m_bDrawLocation; int m_startTime; uint16 *m_curThumbnail; + int _initialLoadSlotNumber; + int _loadSlotNumber; // Bounding box list manager RMGameBoxes _theBoxes; -- cgit v1.2.3 From 5d18a71045bd933fc2efc7ed6e60ef7763745cb7 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 19 May 2012 12:33:14 +1000 Subject: TONY: Converting comments to English and formatting --- engines/tony/mpal/expr.cpp | 293 ++++++++++++++++++------------------------ engines/tony/mpal/expr.h | 65 +++------- engines/tony/mpal/loadmpc.cpp | 235 ++++++++++++++------------------- engines/tony/mpal/loadmpc.h | 21 +-- 4 files changed, 247 insertions(+), 367 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/expr.cpp b/engines/tony/mpal/expr.cpp index 19170ce60c..5e09e5dec6 100644 --- a/engines/tony/mpal/expr.cpp +++ b/engines/tony/mpal/expr.cpp @@ -61,9 +61,9 @@ namespace Tony { namespace MPAL { -/****************************************************************************\ -* Operazioni matematiche gestite -\****************************************************************************/ +/** + * @defgroup Mathamatical operations + */ #define OP_MUL ((1<<4)|0) #define OP_DIV ((1<<4)|1) @@ -85,32 +85,24 @@ namespace MPAL { #define OP_OR ((10<<4)|0) -/****************************************************************************\ -* enum ExprListTypes -* ------------------ -* Description: Tipi di oggetto che possono essere contenuti in una struttura -* EXPRESSION. -\****************************************************************************/ - -enum ExprListTypes -{ - ELT_NUMBER=1, - ELT_VAR=2, - ELT_PARENTH=3, - ELT_PARENTH2=4 +/** + * Object types that can be contained in an EXPRESSION structure + */ +enum ExprListTypes { + ELT_NUMBER = 1, + ELT_VAR = 2, + ELT_PARENTH = 3, + ELT_PARENTH2 = 4 }; -/****************************************************************************\ -* Structures -\****************************************************************************/ - -/****************************************************************************\ -* typedef EXPRESSION -* ------------------ -* Description: Struttura per gestire le operazioni matematiche -\****************************************************************************/ +/** + * @defgroup Structures + */ +/** + * Mathamatical framework to manage operations + */ typedef struct { byte type; // Tipo di oggetto (vedi enum ExprListTypes) byte unary; // Unary operatore (NON SUPPORTATO) @@ -128,38 +120,31 @@ typedef struct { typedef EXPRESSION* LPEXPRESSION; -/****************************************************************************\ -* -* Function: LPEXPRESSION DuplicateExpression(HGLOBAL h); -* -* Description: Duplica un'espressione matematica. L'espressione duplicata -* sara' formata da memoria non swappabile. -* -* Input: HGLOBAL h Handle dell'espressione originale -* -* Return: Pointer all'espressione clone della prima -* -\****************************************************************************/ - +/** + * Duplicate a mathematical expression. + * + * @param h Handle to the original expression + * @retruns Pointer to the cloned expression + */ static byte *DuplicateExpression(HGLOBAL h) { int i, num; byte *orig, *clone; LPEXPRESSION one, two; - orig=(byte *)GlobalLock(h); + orig = (byte *)GlobalLock(h); - num=*(byte *)orig; - one=(LPEXPRESSION)(orig+1); + num = *(byte *)orig; + one = (LPEXPRESSION)(orig+1); - clone = (byte *)GlobalAlloc(GMEM_FIXED, sizeof(EXPRESSION)*num+1); - two=(LPEXPRESSION)(clone+1); + clone = (byte *)GlobalAlloc(GMEM_FIXED, sizeof(EXPRESSION) * num + 1); + two = (LPEXPRESSION)(clone + 1); - CopyMemory(clone,orig,sizeof(EXPRESSION)*num+1); + CopyMemory(clone, orig, sizeof(EXPRESSION) * num + 1); - for (i=0;itype==ELT_PARENTH) { - two->type=ELT_PARENTH2; - two->val.pson=DuplicateExpression(two->val.son); + for (i = 0; i < num; i++) { + if (one->type == ELT_PARENTH) { + two->type = ELT_PARENTH2; + two->val.pson = DuplicateExpression(two->val.son); } one++; @@ -173,41 +158,41 @@ static byte *DuplicateExpression(HGLOBAL h) { static int Compute(int a, int b, byte symbol) { switch (symbol) { case OP_MUL: - return a*b; + return a * b; case OP_DIV: - return a/b; + return a / b; case OP_MODULE: - return a%b; + return a % b; case OP_ADD: - return a+b; + return a + b; case OP_SUB: - return a-b; + return a - b; case OP_SHL: - return a<>b; + return a >> b; case OP_MINOR: - return ab; + return a > b; case OP_MINEQ: - return a<=b; + return a <= b; case OP_MAJEQ: - return a>=b; + return a >= b; case OP_EQUAL: - return a==b; + return a == b; case OP_NOEQUAL: - return a!=b; + return a != b; case OP_BITAND: - return a&b; + return a & b; case OP_BITXOR: - return a^b; + return a ^ b; case OP_BITOR: - return a|b; + return a | b; case OP_AND: - return a&&b; + return a && b; case OP_OR: - return a||b; + return a || b; default: GLOBALS.mpalError = 1; break; @@ -220,52 +205,45 @@ static void Solve(LPEXPRESSION one, int num) { LPEXPRESSION two, three; int j; - while (num>1) { - two=one+1; - if ((two->symbol==0) || (one->symbol&0xF0) <= (two->symbol&0xF0)) { - two->val.num=Compute(one->val.num,two->val.num,one->symbol); - CopyMemory(one,two,(num-1)*sizeof(EXPRESSION)); + while (num > 1) { + two=one + 1; + if ((two->symbol == 0) || (one->symbol & 0xF0) <= (two->symbol & 0xF0)) { + two->val.num=Compute(one->val.num, two->val.num,one->symbol); + CopyMemory(one, two, (num - 1) * sizeof(EXPRESSION)); num--; } else { - j=1; - three=two+1; - while ((three->symbol!=0) && (two->symbol&0xF0)>(three->symbol&0xF0)) { + j = 1; + three = two + 1; + while ((three->symbol != 0) && (two->symbol & 0xF0)>(three->symbol & 0xF0)) { two++; three++; j++; } - three->val.num=Compute(two->val.num,three->val.num,two->symbol); - CopyMemory(two,three,(num-j-1)*sizeof(EXPRESSION)); + three->val.num = Compute(two->val.num, three->val.num, two->symbol); + CopyMemory(two, three, (num - j - 1) * sizeof(EXPRESSION)); num--; } } } -/****************************************************************************\ -* -* Function: int EvaluateAndFreeExpression(byte *expr); -* -* Description: Calcola il risultato di una espressione matematica, sosti- -* tuendo ad eventuali variabili il valore corrente. -* -* Input: byte *expr Pointer all'espressione duplicata -* tramite DuplicateExpression -* -* Return: Valore dell'espressione -* -\****************************************************************************/ - +/** + * Calculates the result of a mathematical expression, replacing the current + * value of any variable. + * + * @param expr Pointer to an expression duplicated by DuplicateExpression + * @returns Value + */ static int EvaluateAndFreeExpression(byte *expr) { int i,num,val; LPEXPRESSION one,cur; - num=*expr; - one=(LPEXPRESSION)(expr+1); + num = *expr; + one = (LPEXPRESSION)(expr + 1); // 1) Sostituzioni delle variabili - for (i=0,cur=one;itype==ELT_VAR) { cur->type=ELT_NUMBER; cur->val.num=varGetValue(cur->val.name); @@ -273,39 +251,30 @@ static int EvaluateAndFreeExpression(byte *expr) { } // 2) Sostituzioni delle parentesi (tramite ricorsione) - for (i=0,cur=one;itype==ELT_PARENTH2) { - cur->type=ELT_NUMBER; - cur->val.num=EvaluateAndFreeExpression(cur->val.pson); + for (i = 0, cur = one; i < num; i++, cur++) { + if (cur->type == ELT_PARENTH2) { + cur->type = ELT_NUMBER; + cur->val.num = EvaluateAndFreeExpression(cur->val.pson); } } // 3) Risoluzione algebrica - Solve(one,num); - val=one->val.num; + Solve(one, num); + val = one->val.num; GlobalFree(expr); return val; } -/****************************************************************************\ -* -* Function: byte *ParseExpression(byte *buf, HGLOBAL *h); -* -* Description: Esegue il parsing da file .MPC di un'espressione matematica. -* -* Input: byte *buf Buffer contenente l'espressione -* compilata. -* HGLOBAL *h Pointer a un handle che, alla fine -* dell'esecuzione, puntera' alla -* zona di memoria contenete l'espres- -* sione parsata -* -* Return: Puntatore al buffer subito dopo l'espressione, o NULL in caso -* di errore. -* -\****************************************************************************/ +/** + * Parses a mathematical expression from the MPC file + * + * @param buf Buffer containing the expression to evaluate + * @param h Pointer to a handle that, at the end of execution, + * will point to the area of memory containing the parsed expression + * @returns Pointer to the buffer immediately after the expression, or NULL if error. + */ const byte *ParseExpression(const byte *lpBuf, HGLOBAL *h) { LPEXPRESSION cur; byte *start; @@ -317,36 +286,36 @@ const byte *ParseExpression(const byte *lpBuf, HGLOBAL *h) { if (num == 0) return NULL; - *h = GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT, num * sizeof(EXPRESSION) + 1); + *h = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, num * sizeof(EXPRESSION) + 1); if (*h==NULL) return NULL; - start=(byte *)GlobalLock(*h); - *start=(byte)num; + start = (byte *)GlobalLock(*h); + *start = (byte)num; - cur=(LPEXPRESSION)(start+1); + cur = (LPEXPRESSION)(start + 1); - for (i=0;itype=*(lpBuf); - cur->unary=*(lpBuf+1); - lpBuf+=2; + for (i = 0;i < num; i++) { + cur->type = *(lpBuf); + cur->unary = *(lpBuf + 1); + lpBuf += 2; switch (cur->type) { case ELT_NUMBER: - cur->val.num=*(int *)lpBuf; - lpBuf+=4; + cur->val.num = *(int *)lpBuf; + lpBuf += 4; break; case ELT_VAR: - cur->val.name=(char *)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,(*lpBuf)+1); - if (cur->val.name==NULL) + cur->val.name = (char *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, (*lpBuf) + 1); + if (cur->val.name == NULL) return NULL; - CopyMemory(cur->val.name,lpBuf+1,*lpBuf); - lpBuf+=*lpBuf+1; + CopyMemory(cur->val.name, lpBuf + 1, *lpBuf); + lpBuf += *lpBuf + 1; break; case ELT_PARENTH: - lpBuf=ParseExpression(lpBuf,&cur->val.son); - if (lpBuf==NULL) + lpBuf=ParseExpression(lpBuf, &cur->val.son); + if (lpBuf == NULL) return NULL; break; @@ -354,13 +323,13 @@ const byte *ParseExpression(const byte *lpBuf, HGLOBAL *h) { return NULL; } - cur->symbol=*lpBuf; + cur->symbol = *lpBuf; lpBuf++; cur++; } - if (*lpBuf!=0) + if (*lpBuf != 0) return NULL; lpBuf++; @@ -369,18 +338,12 @@ const byte *ParseExpression(const byte *lpBuf, HGLOBAL *h) { } -/****************************************************************************\ -* -* Function: int EvaluateExpression(HGLOBAL h); -* -* Description: Calcola il valore di un'espressione matematica -* -* Input: HGLOBAL h Handle all'espressione -* -* Return: Valore numerico -* -\****************************************************************************/ - +/** + * Calculate the value of a mathamatical expression + * + * @param h Handle to the expression + * @returns Numeric value + */ int EvaluateExpression(HGLOBAL h) { int ret; @@ -392,28 +355,22 @@ int EvaluateExpression(HGLOBAL h) { } -/****************************************************************************\ -* -* Function: bool CompareExpressions(HGLOBAL h1, HGLOBAL h2); -* -* Description: Confronta due espressioni matematiche tra loro -* -* Input: HGLOBAL h1,h2 Espressioni da confrontare -* -* Return: true se sono uguali, false se sono diverse -* -\****************************************************************************/ - +/** + * Compare two mathematical expressions together + * + * @param h1 Expression to be compared + * @param h2 Expression to be compared + */ bool CompareExpressions(HGLOBAL h1, HGLOBAL h2) { - int i,num1,num2; + int i, num1, num2; byte *e1, *e2; LPEXPRESSION one, two; - e1=(byte *)GlobalLock(h1); - e2=(byte *)GlobalLock(h2); + e1 = (byte *)GlobalLock(h1); + e2 = (byte *)GlobalLock(h2); - num1=*(byte *)e1; - num2=*(byte *)e2; + num1 = *(byte *)e1; + num2 = *(byte *)e2; if (num1 != num2) { GlobalUnlock(h1); @@ -421,11 +378,11 @@ bool CompareExpressions(HGLOBAL h1, HGLOBAL h2) { return false; } - one=(LPEXPRESSION)(e1+1); - two=(LPEXPRESSION)(e2+1); + one = (LPEXPRESSION)(e1+1); + two = (LPEXPRESSION)(e2+1); - for (i=0;itype!=two->type || (i!=num1-1 && one->symbol!=two->symbol)) { + for (i = 0; i < num1; i++) { + if (one->type != two->type || (i != num1 - 1 && one->symbol != two->symbol)) { GlobalUnlock(h1); GlobalUnlock(h2); return false; @@ -449,7 +406,7 @@ bool CompareExpressions(HGLOBAL h1, HGLOBAL h2) { break; case ELT_PARENTH: - if (!CompareExpressions(one->val.son,two->val.son)) { + if (!CompareExpressions(one->val.son, two->val.son)) { GlobalUnlock(h1); GlobalUnlock(h2); return false; diff --git a/engines/tony/mpal/expr.h b/engines/tony/mpal/expr.h index 582f6d381d..3a9f0f3208 100644 --- a/engines/tony/mpal/expr.h +++ b/engines/tony/mpal/expr.h @@ -55,60 +55,37 @@ namespace Tony { namespace MPAL { /****************************************************************************\ -* Prototipi di funzione -\****************************************************************************/ - -/****************************************************************************\ -* -* Function: byte *ParseExpression(byte *buf, HGLOBAL *h); -* -* Description: Esegue il parsing da file .MPC di un'espressione matematica. -* -* Input: byte *buf Buffer contenente l'espressione -* compilata. -* HGLOBAL *h Pointer a un handle che, alla fine -* dell'esecuzione, puntera' alla -* zona di memoria contenete l'espres- -* sione parsata -* -* Return: Puntatore al buffer subito dopo l'espressione, o NULL in caso -* di errore. -* +* Function Prototypes \****************************************************************************/ +/** + * Parses a mathematical expression from the MPC file + * + * @param buf Buffer containing the expression to evaluate + * @param h Pointer to a handle that, at the end of execution, + * will point to the area of memory containing the parsed expression + * @returns Pointer to the buffer immediately after the expression, or NULL if error. + */ const byte *ParseExpression(const byte *lpBuf, HGLOBAL *h); -/****************************************************************************\ -* -* Function: int EvaluateExpression(HGLOBAL h); -* -* Description: Calcola il valore di un'espressione matematica -* -* Input: HGLOBAL h Handle all'espressione -* -* Return: Valore numerico -* -\****************************************************************************/ - +/** + * Calculate the value of a mathamatical expression + * + * @param h Handle to the expression + * @returns Numeric value + */ int EvaluateExpression(HGLOBAL h); -/****************************************************************************\ -* -* Function: bool CompareExpressions(HGLOBAL h1, HGLOBAL h2); -* -* Description: Confronta due espressioni matematiche tra loro -* -* Input: HGLOBAL h1,h2 Espressioni da confrontare -* -* Return: TRUE se sono uguali, FALSE se sono diverse -* -\****************************************************************************/ - +/** + * Compare two mathematical expressions together + * + * @param h1 Expression to be compared + * @param h2 Expression to be compared + */ bool CompareExpressions(HGLOBAL h1, HGLOBAL h2); - } // end of namespace MPAL } // end of namespace Tony diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index 6430325503..6a1213bc19 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -76,22 +76,14 @@ static bool CompareCommands(struct command *cmd1, struct command *cmd2) { } -/****************************************************************************\ -* -* Function: LPBTYE ParseScript(byte *lpBuf, LPMPALSCRIPT lpmsScript); -* -* Description: Esegue il parsing da file .MPC di uno script e inserisce il -* tutto dentro una struttura -* -* Input: byte *lpBuf Buffer contenente lo script compilato -* LPMPALSCRIPT lpmsScript Puntatore a una struttura che verra' -* riempita con i dati dello script -* lato -* -* Return: Puntatore al buffer dopo l'item, o NULL in caso di errore -* -\****************************************************************************/ - +/** + * Parses a script from the MPC file, and inserts it's data into a structure + * + * @param lpBuf Buffer containing the compiled script. + * @param lpmsScript Pointer to a structure that will be filled with the + * data of the script. + * @returns Pointer to the buffer after the item, or NULL on failure. + */ static const byte *ParseScript(const byte *lpBuf, LPMPALSCRIPT lpmsScript) { int curCmd,j,len; uint i; @@ -102,14 +94,14 @@ static const byte *ParseScript(const byte *lpBuf, LPMPALSCRIPT lpmsScript) { lpmsScript->nMoments = READ_LE_UINT16(lpBuf); lpBuf += 2; - curCmd=0; + curCmd = 0; - for (i=0;inMoments;i++) { + for (i = 0; i < lpmsScript->nMoments; i++) { lpmsScript->Moment[i].dwTime = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmsScript->Moment[i].nCmds=*lpBuf; lpBuf++; + lpmsScript->Moment[i].nCmds = *lpBuf; lpBuf++; - for (j=0;jMoment[i].nCmds;j++) { - lpmsScript->Command[curCmd].type=*lpBuf; lpBuf++; + for (j = 0; j < lpmsScript->Moment[i].nCmds; j++) { + lpmsScript->Command[curCmd].type = *lpBuf; lpBuf++; switch (lpmsScript->Command[curCmd].type) { case 1: lpmsScript->Command[curCmd].nCf = READ_LE_UINT16(lpBuf); lpBuf += 2; @@ -121,14 +113,14 @@ static const byte *ParseScript(const byte *lpBuf, LPMPALSCRIPT lpmsScript) { case 2: // Variable assign len=*lpBuf; lpBuf++; - lpmsScript->Command[curCmd].lpszVarName=(char *)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,len+1); - if (lpmsScript->Command[curCmd].lpszVarName==NULL) + lpmsScript->Command[curCmd].lpszVarName = (char *)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,len+1); + if (lpmsScript->Command[curCmd].lpszVarName == NULL) return NULL; CopyMemory(lpmsScript->Command[curCmd].lpszVarName, lpBuf, len); lpBuf+=len; lpBuf = ParseExpression(lpBuf, &lpmsScript->Command[curCmd].expr); - if (lpBuf==NULL) + if (lpBuf == NULL) return NULL; break; @@ -136,7 +128,7 @@ static const byte *ParseScript(const byte *lpBuf, LPMPALSCRIPT lpmsScript) { return NULL; } - lpmsScript->Moment[i].CmdNum[j]=curCmd; + lpmsScript->Moment[i].CmdNum[j] = curCmd; curCmd++; } } @@ -145,26 +137,17 @@ static const byte *ParseScript(const byte *lpBuf, LPMPALSCRIPT lpmsScript) { } -/****************************************************************************\ -* -* Function: byte *ParseDialog(byte *lpBuf, LPMPALDIALOG lpmdDialog); -* -* Description: Esegue il parsing da file .MPC di un dialog, e inserisce il -* tutto dentro una struttura -* -* Input: byte *lpBuf Buffer contenente il dialogo compi- -* lato -* LPMPALDIALOG lpmdDialog Puntatore a una struttura che verra' -* riempita con i dati del dialogo -* compilato -* -* Return: Puntatore al buffer dopo il dialogo, o NULL in caso di errore -* -\****************************************************************************/ - +/** + * Parses a dialog from the MPC file, and inserts it's data into a structure + * + * @param lpBuf Buffer containing the compiled dialog. + * @param lpmdDialog Pointer to a structure that will be filled with the + * data of the dialog. + * @returns Pointer to the buffer after the item, or NULL on failure. + */ static const byte *ParseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { - uint32 i,j,z,kk; - uint32 num,num2,num3; + uint32 i, j, z, kk; + uint32 num, num2, num3; byte *lpLock; uint32 curCmd; uint32 len; @@ -309,7 +292,7 @@ static const byte *ParseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { lpmdDialog->Choice[i].Select[j].wPlayGroup[num3] = 0; } - // Segna l'ultimo select + // Mark the last selection lpmdDialog->Choice[i].Select[num2].dwData = 0; } @@ -318,70 +301,61 @@ static const byte *ParseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { return lpBuf; } -/****************************************************************************\ -* -* Function: byte *ParseItem(byte *lpBuf, LPMPALITEM lpmiItem); -* -* Description: Esegue il parsing da file .MPC di un item, e inserisce il -* tutto dentro una struttura -* -* Input: byte *lpBuf Buffer contenete l'item compilato -* LPMPALITEM lpmiItem Puntatore a una struttura che verra' -* riempita con i dati dell'item -* compilato -* -* Return: Puntatore al buffer dopo l'item, o NULL in caso di errore -* -* Note: E' necessario che la struttura passata come parametro sia -* stata completamente inizializzata a 0 (con una ZeroMemory, -* ad esempio). -* -\****************************************************************************/ +/** + * Parses an item from the MPC file, and inserts it's data into a structure + * + * @param lpBuf Buffer containing the compiled dialog. + * @param lpmiItem Pointer to a structure that will be filled with the + * data of the item. + * @returns Pointer to the buffer after the item, or NULL on failure. + * @remarks It's necessary that the structure that is passed has been + * completely initialised to 0 beforehand. + */ static const byte *ParseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { byte len; - uint32 i,j,kk; + uint32 i, j, kk; uint32 curCmd; lpmiItem->nObj = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; - len=*lpBuf; + len = *lpBuf; lpBuf++; - CopyMemory(lpmiItem->lpszDescribe,lpBuf, MIN((byte)127, len)); - lpBuf+=len; + CopyMemory(lpmiItem->lpszDescribe, lpBuf, MIN((byte)127, len)); + lpBuf += len; if (len >= MAX_DESCRIBE_SIZE) - error("Describe too long in item #%d",lpmiItem->nObj); + error("Describe too long in item #%d", lpmiItem->nObj); lpmiItem->nActions=*lpBuf; lpBuf++; /* Alloca le azioni */ - if (lpmiItem->nActions>0) - lpmiItem->Action = (ItemAction *)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,sizeof(struct ItemAction)*(int)lpmiItem->nActions); + if (lpmiItem->nActions > 0) + lpmiItem->Action = (ItemAction *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(struct ItemAction) * (int)lpmiItem->nActions); - curCmd=0; + curCmd = 0; - for (i=0;inActions;i++) { - lpmiItem->Action[i].num=*lpBuf; + for (i = 0; i < lpmiItem->nActions; i++) { + lpmiItem->Action[i].num = *lpBuf; lpBuf++; lpmiItem->Action[i].wParm = READ_LE_UINT16(lpBuf); lpBuf += 2; - if (lpmiItem->Action[i].num==0xFF) { + if (lpmiItem->Action[i].num == 0xFF) { lpmiItem->Action[i].wTime = READ_LE_UINT16(lpBuf); lpBuf += 2; - lpmiItem->Action[i].perc=*lpBuf; + lpmiItem->Action[i].perc = *lpBuf; lpBuf++; } - if (*lpBuf==0) { + if (*lpBuf == 0) { lpBuf++; - lpmiItem->Action[i].when=NULL; + lpmiItem->Action[i].when = NULL; } else { lpBuf++; lpBuf = ParseExpression(lpBuf,&lpmiItem->Action[i].when); @@ -395,8 +369,8 @@ static const byte *ParseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { if (lpmiItem->Action[i].nCmds >= MAX_COMMANDS_PER_ACTION) error("Too much commands in action #%d in item #%d",lpmiItem->Action[i].num,lpmiItem->nObj); - for (j=0;jAction[i].nCmds;j++) { - lpmiItem->Command[curCmd].type=*lpBuf; + for (j = 0; j < lpmiItem->Action[i].nCmds; j++) { + lpmiItem->Command[curCmd].type = *lpBuf; lpBuf++; switch (lpmiItem->Command[curCmd].type) { case 1: // Call custom function @@ -408,16 +382,16 @@ static const byte *ParseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { break; case 2: // Variable assign - len=*lpBuf; + len = *lpBuf; lpBuf++; - lpmiItem->Command[curCmd].lpszVarName=(char *)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,len+1); - if (lpmiItem->Command[curCmd].lpszVarName==NULL) + lpmiItem->Command[curCmd].lpszVarName = (char *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, len + 1); + if (lpmiItem->Command[curCmd].lpszVarName == NULL) return NULL; - CopyMemory(lpmiItem->Command[curCmd].lpszVarName,lpBuf,len); - lpBuf+=len; + CopyMemory(lpmiItem->Command[curCmd].lpszVarName, lpBuf, len); + lpBuf += len; - lpBuf=ParseExpression(lpBuf,&lpmiItem->Command[curCmd].expr); - if (lpBuf==NULL) + lpBuf=ParseExpression(lpBuf, &lpmiItem->Command[curCmd].expr); + if (lpBuf == NULL) return NULL; break; @@ -425,15 +399,15 @@ static const byte *ParseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { return NULL; } - for (kk=0;kkCommand[kk],&lpmiItem->Command[curCmd])) { - lpmiItem->Action[i].CmdNum[j]=kk; + lpmiItem->Action[i].CmdNum[j] = kk; break; } } if (kk==curCmd) { - lpmiItem->Action[i].CmdNum[j]=curCmd; + lpmiItem->Action[i].CmdNum[j] = curCmd; curCmd++; if (curCmd >= MAX_COMMANDS_PER_ITEM) { @@ -450,23 +424,14 @@ static const byte *ParseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { } -/****************************************************************************\ -* -* Function: byte *ParseLocation(byte *buf, LPMPALLOCATIONN lpmlLocation) -* -* Description: Esegue il parsing da file .MPC di una locazione, riempendo -* una struttura -* -* Input: byte *buf Buffer contenente la locazione -* compilata -* LPMPALLOCATION -* lpmlLocation Pointer alla struttura che verra' -* riempita con i dati sulla locazione -* -* Return: Puntatore al buffer dopo l'item, o NULL in caso di errore -* -\****************************************************************************/ - +/** + * Parses a location from the MPC file, and inserts it's data into a structure + * + * @param lpBuf Buffer containing the compiled location. + * @param lpmiLocation Pointer to a structure that will be filled with the + * data of the location. + * @returns Pointer to the buffer after the location, or NULL on failure. + */ static const byte *ParseLocation(const byte *lpBuf, LPMPALLOCATION lpmlLocation) { lpmlLocation->nObj = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; @@ -480,39 +445,27 @@ static const byte *ParseLocation(const byte *lpBuf, LPMPALLOCATION lpmlLocation) return lpBuf; } -/*static int CompareMoments(int * a, int * b) { - if (*a<*b) - return -1; - else if (*a>*b) - return 1; - else - return 0; -}*/ - -/****************************************************************************\ -* Funzioni globali -\****************************************************************************/ /****************************************************************************\ -* -* Function: bool ParseMpc(byte *lpBuf); -* -* Description: Legge e interpreta un file MPC, e crea le strutture per le -* varie direttive nelle variabili globali -* -* Input: byte *lpBuf Immagine in memoria del file MPC, -* escluso l'header -* -* Return: true se tutto OK, false in caso di errore. -* +* Exported functions \****************************************************************************/ +/** + * @defgroup Exported functions + */ +/** + * Reads and interprets the MPC file, and create structures for various directives + * in the global variables + * + * @param lpBuf Buffer containing the MPC file data, excluding the header. + * @returns True if succeeded OK, false if failure. + */ bool ParseMpc(const byte *lpBuf) { uint16 i, j; uint16 wLen; byte *lpTemp, *lpTemp2; - /* 1. Variabili */ + /* 1. Variables */ if (lpBuf[0] != 'V' || lpBuf[1] != 'A' || lpBuf[2] != 'R' || lpBuf[3] != 'S') return false; @@ -540,7 +493,7 @@ bool ParseMpc(const byte *lpBuf) { GlobalUnlock(GLOBALS.hVars); - /* 2. Messaggi */ + /* 2. Messages */ if (lpBuf[0] != 'M' || lpBuf[1] != 'S' || lpBuf[2] != 'G' || lpBuf[3] != 'S') return false; @@ -588,7 +541,7 @@ bool ParseMpc(const byte *lpBuf) { GlobalUnlock(GLOBALS.hMsgs); #endif - /* 3. Oggetti */ + /* 3. Objects */ if (lpBuf[0] != 'O' || lpBuf[1] != 'B' || lpBuf[2] != 'J' || lpBuf[3] != 'S') return false; @@ -596,7 +549,7 @@ bool ParseMpc(const byte *lpBuf) { GLOBALS.nObjs = READ_LE_UINT16(lpBuf); lpBuf += 2; - // Controlla i dialoghi + // Check out the dialogs GLOBALS.nDialogs = 0; GLOBALS.hDialogs = GLOBALS.lpmdDialogs = NULL; if (*((const byte *)lpBuf + 2) == 6 && strncmp((const char *)lpBuf + 3, "Dialog", 6) == 0) { @@ -615,13 +568,13 @@ bool ParseMpc(const byte *lpBuf) { GlobalUnlock(GLOBALS.hDialogs); } - // Controlla gli item + // Check the items GLOBALS.nItems = 0; GLOBALS.hItems = GLOBALS.lpmiItems = NULL; if (*(lpBuf + 2) == 4 && strncmp((const char *)lpBuf + 3, "Item", 4)==0) { GLOBALS.nItems = READ_LE_UINT16(lpBuf); lpBuf += 2; - // Alloca la memoria e li legge + // Allocate memory and read them in GLOBALS.hItems = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nItems * sizeof(MPALITEM)); if (GLOBALS.hItems == NULL) return false; @@ -635,13 +588,13 @@ bool ParseMpc(const byte *lpBuf) { GlobalUnlock(GLOBALS.hItems); } - // Controlla le locazioni + // Check the locations GLOBALS.nLocations = 0; GLOBALS.hLocations = GLOBALS.lpmlLocations = NULL; if (*(lpBuf + 2) == 8 && strncmp((const char *)lpBuf + 3, "Location", 8)==0) { GLOBALS.nLocations = READ_LE_UINT16(lpBuf); lpBuf += 2; - // Alloca la memoria e li legge + // Allocate memory and read them in GLOBALS.hLocations=GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nLocations*sizeof(MPALLOCATION)); if (GLOBALS.hLocations == NULL) return false; @@ -655,13 +608,13 @@ bool ParseMpc(const byte *lpBuf) { GlobalUnlock(GLOBALS.hLocations); } - // Controlla gli script + // Check the scripts GLOBALS.nScripts = 0; GLOBALS.hScripts = GLOBALS.lpmsScripts = NULL; if (*(lpBuf + 2) == 6 && strncmp((const char *)lpBuf + 3, "Script", 6) == 0) { GLOBALS.nScripts = READ_LE_UINT16(lpBuf); lpBuf += 2; - // Alloca la memoria + // Allocate memory GLOBALS.hScripts = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nScripts * sizeof(MPALSCRIPT)); if (GLOBALS.hScripts == NULL) return false; @@ -672,7 +625,7 @@ bool ParseMpc(const byte *lpBuf) { if ((lpBuf = ParseScript(lpBuf + 7, &GLOBALS.lpmsScripts[i])) == NULL) return false; - // Ordina i vari moments dello script + // Sort the various moments of the script //qsort( //GLOBALS.lpmsScripts[i].Moment, //GLOBALS.lpmsScripts[i].nMoments, diff --git a/engines/tony/mpal/loadmpc.h b/engines/tony/mpal/loadmpc.h index 8763fbf95b..6aea3de16b 100644 --- a/engines/tony/mpal/loadmpc.h +++ b/engines/tony/mpal/loadmpc.h @@ -58,20 +58,13 @@ namespace MPAL { * Prototipi di funzione \****************************************************************************/ -/****************************************************************************\ -* -* Function: BOOL ParseMpc(LPBYTE lpBuf); -* -* Description: Legge e interpreta un file MPC, e crea le strutture per le -* varie direttive nelle variabili globali -* -* Input: LPBYTE lpBuf Immagine in memoria del file MPC, -* escluso l'header -* -* Return: TRUE se tutto OK, FALSE in caso di errore. -* -\****************************************************************************/ - +/** + * Reads and interprets the MPC file, and create structures for various directives + * in the global variables + * + * @param lpBuf Buffer containing the MPC file data, excluding the header. + * @returns True if succeeded OK, false if failure. + */ bool ParseMpc(const byte *lpBuf); -- cgit v1.2.3 From bd064fe044beb4c38b48a1c111d922fdfcf73516 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 19 May 2012 13:18:47 +1000 Subject: TONY: Endian fix in expression parser --- engines/tony/mpal/expr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/tony/mpal/expr.cpp b/engines/tony/mpal/expr.cpp index 5e09e5dec6..7643c8bde3 100644 --- a/engines/tony/mpal/expr.cpp +++ b/engines/tony/mpal/expr.cpp @@ -301,7 +301,7 @@ const byte *ParseExpression(const byte *lpBuf, HGLOBAL *h) { lpBuf += 2; switch (cur->type) { case ELT_NUMBER: - cur->val.num = *(int *)lpBuf; + cur->val.num = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; break; -- cgit v1.2.3 From 8457c1c7682e3c0d0c382c01b042158ec506e300 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 19 May 2012 16:57:17 +1000 Subject: TONY: Removed deprecated MPAL stubs file --- engines/tony/font.cpp | 1 - engines/tony/game.cpp | 1 - engines/tony/loc.h | 1 - engines/tony/module.mk | 3 +- engines/tony/mpal/expr.cpp | 7 ++--- engines/tony/mpal/memory.cpp | 9 ++++++ engines/tony/mpal/memory.h | 3 ++ engines/tony/mpal/mpal.cpp | 1 - engines/tony/mpal/mpaldll.h | 1 - engines/tony/mpal/mpalutils.h | 3 +- engines/tony/mpal/stubs.cpp | 49 -------------------------------- engines/tony/mpal/stubs.h | 66 ------------------------------------------- engines/tony/tonychar.h | 1 - 13 files changed, 17 insertions(+), 129 deletions(-) delete mode 100644 engines/tony/mpal/stubs.cpp delete mode 100644 engines/tony/mpal/stubs.h (limited to 'engines') diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 5396b73796..8fc011bb35 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -28,7 +28,6 @@ #include "common/textconsole.h" #include "tony/mpal/mpalutils.h" -#include "tony/mpal/stubs.h" #include "tony/font.h" #include "tony/input.h" #include "tony/inventory.h" diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 64c91008a5..3551f55c83 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -33,7 +33,6 @@ #include "tony/mpal/memory.h" #include "tony/mpal/mpal.h" #include "tony/mpal/mpalutils.h" -#include "tony/mpal/stubs.h" #include "tony/custom.h" #include "tony/game.h" #include "tony/gfxengine.h" diff --git a/engines/tony/loc.h b/engines/tony/loc.h index aee4936490..e25bdb500c 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -32,7 +32,6 @@ #include "common/scummsys.h" #include "common/system.h" #include "common/file.h" -#include "tony/mpal/stubs.h" #include "tony/sound.h" #include "tony/utils.h" diff --git a/engines/tony/module.mk b/engines/tony/module.mk index 6512391d04..719a598ee4 100644 --- a/engines/tony/module.mk +++ b/engines/tony/module.mk @@ -21,8 +21,7 @@ MODULE_OBJS := \ mpal/memory.o \ mpal/mpal.o \ mpal/mpalutils.o \ - mpal/lzo.o \ - mpal/stubs.o + mpal/lzo.o # This module can be built as a plugin ifeq ($(ENABLE_TONY), DYNAMIC_PLUGIN) diff --git a/engines/tony/mpal/expr.cpp b/engines/tony/mpal/expr.cpp index 7643c8bde3..cf688341be 100644 --- a/engines/tony/mpal/expr.cpp +++ b/engines/tony/mpal/expr.cpp @@ -47,10 +47,9 @@ * * **************************************************************************/ -#include "mpal.h" -#include "memory.h" -#include "mpaldll.h" -#include "stubs.h" +#include "tony/mpal/mpal.h" +#include "tony/mpal/memory.h" +#include "tony/mpal/mpaldll.h" #include "tony/tony.h" /* diff --git a/engines/tony/mpal/memory.cpp b/engines/tony/mpal/memory.cpp index 166e3598f8..4410e8016c 100644 --- a/engines/tony/mpal/memory.cpp +++ b/engines/tony/mpal/memory.cpp @@ -146,6 +146,15 @@ void MemoryManager::erase(HGLOBAL handle) { erase(&item); } +/****************************************************************************\ +* Stand-alone methods +\****************************************************************************/ + +void CopyMemory(void *dst, const void *first, int size) { + Common::copy((const byte *)first, (const byte *)first + size, (byte *)dst); +} + + } // end of namespace MPAL } // end of namespace Tony diff --git a/engines/tony/mpal/memory.h b/engines/tony/mpal/memory.h index 6fd55e7ce5..8d8411c6a1 100644 --- a/engines/tony/mpal/memory.h +++ b/engines/tony/mpal/memory.h @@ -79,6 +79,9 @@ public: #define GMEM_MOVEABLE 2 #define GMEM_ZEROINIT 4 +// Stand-alone methods +extern void CopyMemory(void *dst, const void *first, int size); + } // end of namespace MPAL } // end of namespace Tony diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 854372cdda..6ec92e74c1 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -55,7 +55,6 @@ #include "tony/mpal/lzo.h" #include "tony/mpal/mpal.h" #include "tony/mpal/mpaldll.h" -#include "tony/mpal/stubs.h" namespace Tony { diff --git a/engines/tony/mpal/mpaldll.h b/engines/tony/mpal/mpaldll.h index a7b6dfc5aa..69e58720a4 100644 --- a/engines/tony/mpal/mpaldll.h +++ b/engines/tony/mpal/mpaldll.h @@ -52,7 +52,6 @@ #include "common/file.h" #include "tony/mpal/memory.h" -#include "tony/mpal/stubs.h" #include "tony/mpal/loadmpc.h" #include "tony/mpal/expr.h" diff --git a/engines/tony/mpal/mpalutils.h b/engines/tony/mpal/mpalutils.h index cb8d4ec97d..a9f8403fcd 100644 --- a/engines/tony/mpal/mpalutils.h +++ b/engines/tony/mpal/mpalutils.h @@ -25,8 +25,7 @@ #define TONY_MPAL_MPALUTILS #include "common/scummsys.h" -#include "memory.h" -#include "stubs.h" +#include "tony/mpal/memory.h" namespace Tony { diff --git a/engines/tony/mpal/stubs.cpp b/engines/tony/mpal/stubs.cpp deleted file mode 100644 index 89740fdd52..0000000000 --- a/engines/tony/mpal/stubs.cpp +++ /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 contains stubs and mappings for things used by the MPAL -* library that are handled differently under ScummVM -\****************************************************************************/ - -#include "common/algorithm.h" -#include "common/system.h" -#include "engines/engine.h" -#include "tony/tony.h" -#include "stubs.h" - -namespace Tony { - -namespace MPAL { - -uint16 GetAsyncKeyState(Common::KeyCode kc) { - return 0; -} - -void CopyMemory(void *dst, const void *first, int size) { - Common::copy((const byte *)first, (const byte *)first + size, (byte *)dst); -} - -} // end of namespace MPAL - -} // end of namespace Tony diff --git a/engines/tony/mpal/stubs.h b/engines/tony/mpal/stubs.h deleted file mode 100644 index 66f83997ae..0000000000 --- a/engines/tony/mpal/stubs.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 contains stubs and mappings for things used by the MPAL -* library that are handled differently under ScummVM -\****************************************************************************/ - -#ifndef MPAL_STUBS -#define MPAL_STUBS - -#include "common/scummsys.h" -#include "common/algorithm.h" -#include "common/keyboard.h" -#include "tony/mpal/memory.h" - -namespace Tony { - -namespace MPAL { - -/****************************************************************************\ -* Types -\****************************************************************************/ - -typedef uint32 (*LPTHREAD_START_ROUTINE)(void *lpThreadParameter); -typedef void (*LPTHREAD_ROUTINE)(void *lpThreadParameter); - -/****************************************************************************\ -* Defines -\****************************************************************************/ - -#define MB_OK 1 - -/****************************************************************************\ -* Methods -\****************************************************************************/ - -extern void CopyMemory(void *dst, const void *first, int size); - -extern uint16 GetAsyncKeyState(Common::KeyCode kc); - -} // end of namespace MPAL - -} // end of namespace Tony - -#endif diff --git a/engines/tony/tonychar.h b/engines/tony/tonychar.h index 9cea3a4b2d..201803dc5f 100644 --- a/engines/tony/tonychar.h +++ b/engines/tony/tonychar.h @@ -30,7 +30,6 @@ #define TONY_TONYCHAR_H #include "common/coroutines.h" -#include "tony/mpal/stubs.h" #include "tony/loc.h" namespace Tony { -- cgit v1.2.3 From 827454a87ee73b079a96fbd4bd0df3b43224eb06 Mon Sep 17 00:00:00 2001 From: Torbj旦rn Andersson Date: Sat, 19 May 2012 11:05:57 +0200 Subject: TONY: Change "it's" to "its" in comments where appropriate. (I think.) --- engines/tony/font.cpp | 2 +- engines/tony/gfxcore.h | 2 +- engines/tony/mpal/loadmpc.cpp | 8 ++++---- engines/tony/mpal/memory.cpp | 4 ++-- engines/tony/mpal/mpal.cpp | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) (limited to 'engines') diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 8fc011bb35..db51dc3b79 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -2277,7 +2277,7 @@ void RMTextItemName::DoFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation & itemName = ""; - // If there an item, get it's name + // If there an item, get its name if (m_item != NULL) m_item->GetName(itemName); diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index 3fa29e20f6..1af13d9a66 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -536,7 +536,7 @@ public: /** - * Destination buffer which manages it's own internal list of tasks + * Destination buffer which manages its own internal list of tasks */ class RMGfxTargetBuffer : public virtual RMGfxBuffer { private: diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index 6a1213bc19..6329a2090a 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -77,7 +77,7 @@ static bool CompareCommands(struct command *cmd1, struct command *cmd2) { /** - * Parses a script from the MPC file, and inserts it's data into a structure + * Parses a script from the MPC file, and inserts its data into a structure * * @param lpBuf Buffer containing the compiled script. * @param lpmsScript Pointer to a structure that will be filled with the @@ -138,7 +138,7 @@ static const byte *ParseScript(const byte *lpBuf, LPMPALSCRIPT lpmsScript) { /** - * Parses a dialog from the MPC file, and inserts it's data into a structure + * Parses a dialog from the MPC file, and inserts its data into a structure * * @param lpBuf Buffer containing the compiled dialog. * @param lpmdDialog Pointer to a structure that will be filled with the @@ -303,7 +303,7 @@ static const byte *ParseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { /** - * Parses an item from the MPC file, and inserts it's data into a structure + * Parses an item from the MPC file, and inserts its data into a structure * * @param lpBuf Buffer containing the compiled dialog. * @param lpmiItem Pointer to a structure that will be filled with the @@ -425,7 +425,7 @@ static const byte *ParseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { /** - * Parses a location from the MPC file, and inserts it's data into a structure + * Parses a location from the MPC file, and inserts its data into a structure * * @param lpBuf Buffer containing the compiled location. * @param lpmiLocation Pointer to a structure that will be filled with the diff --git a/engines/tony/mpal/memory.cpp b/engines/tony/mpal/memory.cpp index 4410e8016c..04cb906431 100644 --- a/engines/tony/mpal/memory.cpp +++ b/engines/tony/mpal/memory.cpp @@ -91,7 +91,7 @@ MemoryItem &MemoryManager::allocate(uint32 size, uint flags) { } /** - * Allocates a new memory block and returns it's data pointer + * Allocates a new memory block and returns its data pointer * @returns Data pointer to allocated block */ HGLOBAL MemoryManager::alloc(uint32 size, uint flags) { @@ -123,7 +123,7 @@ MemoryItem &MemoryManager::operator[](HGLOBAL handle) { } /** - * Returns a size of a memory block given it's pointer + * Returns a size of a memory block given its pointer */ uint32 MemoryManager::getSize(HGLOBAL handle) { MemoryItem &item = getItem(handle); diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 6ec92e74c1..aea441138b 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -1312,7 +1312,7 @@ void DoChoice(CORO_PARAM, uint32 nChoice) { * @param dwParam Any parameter for the action. * @returns Id of the process that was launched to perform the action, or * CORO_INVALID_PID_VALUE if the action was not defined, or the item was inactive. - * @remarks You can get the index of an item from it's number by using + * @remarks You can get the index of an item from its number by using * the itemGetOrderFromNum() function. The items list must first be locked * by calling LockItem(). */ -- cgit v1.2.3 From a4a02e15b594e768b73a781823c38234f9f9cf7d Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 19 May 2012 19:43:30 +1000 Subject: TONY: Converting Italian comments to English --- engines/tony/mpal/mpal.cpp | 212 +++++++++++++++++----------------------- engines/tony/mpal/mpaldll.h | 232 ++++++++++++++++++-------------------------- 2 files changed, 188 insertions(+), 256 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index aea441138b..358b4e3505 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -370,10 +370,10 @@ static char *DuplicateDialogPeriod(uint32 nPeriod) { for (j = 0; dialog->Periods[j] != NULL; j++) if (dialog->PeriodNums[j] == nPeriod) { - /* Trovata la frase, va duplicata */ + /* Found the phrase, it should be duplicated */ origmsg = (const char *)GlobalLock(dialog->Periods[j]); - /* Calcola la lunghezza e alloca la memoria */ + /* Calculate the length and allocate memory */ i = 0; while (origmsg[i] != '\0') i++; @@ -448,13 +448,13 @@ static uint32 *GetSelectList(uint32 i) { int j,k,num; LPMPALDIALOG dialog=GLOBALS.lpmdDialogs+GLOBALS.nExecutingDialog; - /* Conta quanti select attivi ci sono */ + /* Count how many are active selects */ num = 0; for (j = 0; dialog->Choice[i].Select[j].dwData != 0; j++) if (dialog->Choice[i].Select[j].curActive) num++; - /* Se sono 0, e' un errore */ + /* If there are 0, it's a mistake */ if (num == 0) return NULL; @@ -462,7 +462,7 @@ static uint32 *GetSelectList(uint32 i) { if (sl == NULL) return NULL; - /* Copia il dato di ogni select attivo dentro la lista */ + /* Copy all the data inside the active select list */ k = 0; for (j = 0; dialog->Choice[i].Select[j].dwData != 0; j++) if (dialog->Choice[i].Select[j].curActive) @@ -509,7 +509,7 @@ static LPITEM GetItemData(uint32 nOrdItem) { char *patlength; uint32 dim; - // Lo zeroinit e' obbligatorio!!!! + // Zeroing out the allocated memory is required!!! ret = (LPITEM)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(ITEM)); if (ret == NULL) return NULL; @@ -519,16 +519,16 @@ static LPITEM GetItemData(uint32 nOrdItem) { dat = (char *)GlobalLock(hDat); if (dat[0] == 'D' && dat[1] == 'A' && dat[2] == 'T') { - i = dat[3]; // Versione!! Per ora 1.0 + i = dat[3]; // For version 1.0!! dat += 4; - if (i >= 0x10) { // Dalla 1.0 c'e' il punto di destinazione per ogni oggetto + if (i >= 0x10) { // From 1.0, there's a destination point for each object ret->destX = (int16)READ_LE_UINT16(dat); ret->destY = (int16)READ_LE_UINT16(dat + 2); dat+=4; } - if (i >= 0x11) {// Dalla 1.1 c'e' la velocita' di animazione + if (i >= 0x11) { // From 1.1, there's animation speed ret->speed = READ_LE_UINT16(dat); dat += 2; } else @@ -539,21 +539,21 @@ static LPITEM GetItemData(uint32 nOrdItem) { ret->numpattern=*dat++; ret->Zvalue=*dat++; - // Carica le coordinate left&top di ogni frame + // Upload the left & top co-ordinates of each frame for (i = 0; i < ret->numframe; i++) { ret->frameslocations[i].left = (int16)READ_LE_UINT16(dat); ret->frameslocations[i].top = (int16)READ_LE_UINT16(dat + 2); dat += 4; } - // Carica le dimensioni di ogni frame e calcola right&bottom + // Upload the size of each frame and calculate the right & bottom for (i = 0; i < ret->numframe; i++) { ret->frameslocations[i].right = (int16)READ_LE_UINT16(dat) + ret->frameslocations[i].left; ret->frameslocations[i].bottom = (int16)READ_LE_UINT16(dat + 2) + ret->frameslocations[i].top; dat+=4; } - // Carica i bounding box di ogni frame + // Upload the bounding boxes of each frame for (i = 0; i < ret->numframe; i++) { ret->bbox[i].left = (int16)READ_LE_UINT16(dat); ret->bbox[i].top = (int16)READ_LE_UINT16(dat + 2); @@ -562,7 +562,7 @@ static LPITEM GetItemData(uint32 nOrdItem) { dat+=8; } - // Carica i pattern di animazione + // Load the animation pattern patlength = dat; dat+=ret->numpattern; @@ -573,7 +573,7 @@ static LPITEM GetItemData(uint32 nOrdItem) { dat += patlength[i]; } - // Carica i singoli frame di animazione + // Upload the individual frames of animations for (i = 1; i < ret->numframe; i++) { dim=(uint32)(ret->frameslocations[i].right-ret->frameslocations[i].left) * (uint32)(ret->frameslocations[i].bottom-ret->frameslocations[i].top); @@ -585,7 +585,7 @@ static LPITEM GetItemData(uint32 nOrdItem) { dat += dim; } - // Controlla se siamo arrivati fino alla fine del file + // Check if we've got to the end of the file i = READ_LE_UINT16(dat); if (i != 0xABCD) return NULL; @@ -678,7 +678,7 @@ void ScriptThread(CORO_PARAM, const void *param) { _ctx->p->arg3=s->Command[_ctx->k].arg3; _ctx->p->arg4=s->Command[_ctx->k].arg4; - // !!! Nuova gestione dei thread + // !!! New process management if ((cfHandles[_ctx->numHandles++] = CoroScheduler.createProcess(CustomThread, &_ctx->p, sizeof(LPCFCALL))) == 0) { GLOBALS.mpalError = 1; @@ -845,16 +845,14 @@ void LocationPollThread(CORO_PARAM, const void *param) { CORO_BEGIN_CODE(_ctx); - /* Tanto per cominciare, e' necessario richiedere la lista degli item - presenti nella locazione. */ + /* To begin with, we need to request the item list from the location */ _ctx->il = mpalQueryItemList(GLOBALS.nPollingLocations[id]); - /* Contiamo gli items */ + /* Count the items */ for (_ctx->numitems = 0; _ctx->il[_ctx->numitems] != 0; _ctx->numitems++) ; - /* Cerchiamo gli items della locazione senza idle actions e li eliminiamo - dalla lista */ + /* We look for items without idle actions, and eliminate them from the list */ LockItems(); _ctx->nIdleActions = 0; _ctx->nRealItems = 0; @@ -873,7 +871,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { _ctx->nIdleActions += _ctx->k; if (_ctx->k == 0) - /* Possiamo eliminare questo item dalla lista */ + /* We can remove this item from the list */ _ctx->il[_ctx->i] = (uint32)NULL; else _ctx->nRealItems++; @@ -894,13 +892,9 @@ void LocationPollThread(CORO_PARAM, const void *param) { return; } - /* Inizializziamo le routine random */ - //curTime = _vm->GetTime(); - //srand(curTime); - - /* Abbiamo appurato che esiste almeno un item che contiene idle actions. - Ora creaiamo le copie speculari delle idle actions */ + /* We have established that there is at least one item that contains idle actions. + Now we created the mirrored copies of the idle actions. */ _ctx->MyActions = (MYACTION *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, _ctx->nIdleActions * sizeof(MYACTION)); if (_ctx->MyActions == NULL) { GlobalFree(_ctx->MyThreads); @@ -937,11 +931,11 @@ void LocationPollThread(CORO_PARAM, const void *param) { UnlockItems(); - /* La item list non ci serve piu' */ + /* We don't need the item list anymore */ GlobalFree(_ctx->il); - /* Eccoci al ciclo principale. */ + /* Here's the main loop */ while (1) { /* Cerchiamo tra tutte le idle actions quella a cui manca meno tempo per l'esecuzione */ @@ -955,9 +949,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { } else _ctx->dwSleepTime = MIN(_ctx->dwSleepTime, _ctx->MyActions[_ctx->k].dwLastTime + _ctx->MyActions[_ctx->k].wTime - _ctx->curTime); - /* Ci addormentiamo, ma controllando sempre l'evento che viene settato - quando viene richiesta la nostra chiusura */ - + /* We fall alseep, but always checking that the event is set when prompted for closure */ CORO_INVOKE_3(CoroScheduler.waitForSingleObject, GLOBALS.hEndPollingLocations[id], _ctx->dwSleepTime, &_ctx->expired); //if (_ctx->k == WAIT_OBJECT_0) @@ -968,28 +960,26 @@ void LocationPollThread(CORO_PARAM, const void *param) { if (_ctx->MyThreads[_ctx->i].nItem != 0) { CORO_INVOKE_3(CoroScheduler.waitForSingleObject, _ctx->MyThreads[_ctx->i].hThread, 0, &_ctx->delayExpired); - // if result ) == WAIT_OBJECT_0) + // if result == WAIT_OBJECT_0) if (!_ctx->delayExpired) _ctx->MyThreads[_ctx->i].nItem = 0; } _ctx->curTime = _vm->GetTime(); - /* Cerchiamo all'interno delle idle actions quale e' necessario eseguire */ + /* Loop through all the necessary idle actions */ for (_ctx->k = 0; _ctx->k < _ctx->nIdleActions; _ctx->k++) if (_ctx->curTime >= _ctx->MyActions[_ctx->k].dwLastTime + _ctx->MyActions[_ctx->k].wTime) { _ctx->MyActions[_ctx->k].dwLastTime += _ctx->MyActions[_ctx->k].wTime; - /* E' _ctx->il momento di tirare _ctx->il nostro dado virtuale, e controllare - se la sorte e' dalla parte della idle action */ + /* It's time to check to see if fortune is on the side of the idle action */ byte randomVal = (byte)_vm->_randomSource.getRandomNumber(99); if (randomVal < _ctx->MyActions[_ctx->k].perc) { - /* Controlliamo se c'e' una action in esecuzione sull'item */ + /* Check if there is an action running on the item */ if ((GLOBALS.bExecutingAction) && (GLOBALS.nExecutingAction == _ctx->MyActions[_ctx->k].nItem)) continue; - /* Controlliamo se c'e' gia' un'altra idle function in esecuzione - sullo stesso item */ + /* Check to see if there already another idle funning running on the item */ for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) if (_ctx->MyThreads[_ctx->i].nItem == _ctx->MyActions[_ctx->k].nItem) break; @@ -997,11 +987,11 @@ void LocationPollThread(CORO_PARAM, const void *param) { if (_ctx->i < _ctx->nRealItems) continue; - /* Ok, siamo gli unici :) */ + /* Ok, we are the only ones :) */ LockItems(); _ctx->curItem=GLOBALS.lpmiItems+itemGetOrderFromNum(_ctx->MyActions[_ctx->k].nItem); - /* Controlliamo se c'e' un esperessione WhenExecute */ + /* Check if there is a WhenExecute expression */ _ctx->j=_ctx->MyActions[_ctx->k].nAction; if (_ctx->curItem->Action[_ctx->j].when != NULL) if (!EvaluateExpression(_ctx->curItem->Action[_ctx->j].when)) { @@ -1009,8 +999,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { continue; } - /* Ok, possiamo eseguire la azione. Per comodita' lo facciamo in - un nuovo thread */ + /* Ok, we can perform the action. For convenience, we do it in a new process */ _ctx->newItem = (LPMPALITEM)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MPALITEM)); if (_ctx->newItem == false) { GlobalFree(_ctx->MyThreads); @@ -1023,21 +1012,20 @@ void LocationPollThread(CORO_PARAM, const void *param) { CopyMemory(_ctx->newItem,_ctx->curItem, sizeof(MPALITEM)); UnlockItems(); - /* Copiamo l'azione nella #0 */ + /* We copy the action in #0 */ // _ctx->newItem->Action[0].nCmds = _ctx->curItem->Action[_ctx->j].nCmds; // CopyMemory(_ctx->newItem->Action[0].CmdNum,_ctx->curItem->Action[_ctx->j].CmdNum,_ctx->newItem->Action[0].nCmds*sizeof(_ctx->newItem->Action[0].CmdNum[0])); _ctx->newItem->dwRes=_ctx->j; - /* Creaiamo l'action thread. Provvedera' lui a liberare la memoria - allocata per _ctx->il nuovo item */ + /* We will create an action, and will provide the necessary details */ for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) if (_ctx->MyThreads[_ctx->i].nItem == 0) break; _ctx->MyThreads[_ctx->i].nItem = _ctx->MyActions[_ctx->k].nItem; - // !!! Nuova gestione dei thread - if ((_ctx->MyThreads[_ctx->i].hThread = CoroScheduler.createProcess(ActionThread, &_ctx->newItem, sizeof(LPMPALITEM))) == 0) { + // Create the process + if ((_ctx->MyThreads[_ctx->i].hThread = CoroScheduler.createProcess(ActionThread, &_ctx->newItem, sizeof(LPMPALITEM))) == CORO_INVALID_PID_VALUE) { //if ((_ctx->MyThreads[_ctx->i].hThread=(void*)_beginthread(ActionThread, 10240,(void *)_ctx->newItem))==(void*)-1) GlobalFree(_ctx->newItem); GlobalFree(_ctx->MyThreads); @@ -1047,23 +1035,11 @@ void LocationPollThread(CORO_PARAM, const void *param) { return; } - /* Skippa tutte le idle action dello stesso item */ + /* Skip all idle actions of the same item */ } } } - /* Chiude tutti _ctx->i thread interni */ - - /* - - CODICE OBSOLETO: ANDIAMO DI SKIP CHE RULLA - - for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) - if (_ctx->MyThreads[_ctx->i].nItem != 0) { - TerminateThread(_ctx->MyThreads[_ctx->i].hThread, 0); - CloseHandle(_ctx->MyThreads[_ctx->i].hThread); - } -*/ // Set idle skip on CORO_INVOKE_4(GLOBALS.lplpFunctions[200], 0, 0, 0, 0); @@ -1083,7 +1059,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { // Set idle skip off CORO_INVOKE_4(GLOBALS.lplpFunctions[201], 0, 0, 0, 0); - /* Abbiamo finito */ + /* We're finished */ GlobalFree(_ctx->MyThreads); GlobalFree(_ctx->MyActions); @@ -1218,20 +1194,20 @@ void DoChoice(CORO_PARAM, uint32 nChoice) { CORO_BEGIN_CODE(_ctx); - /* Locka _ctx->i dialoghi */ + /* Lock the dialogs */ LockDialogs(); - /* Trova il puntatore al dialogo corrente */ - _ctx->dialog=GLOBALS.lpmdDialogs+GLOBALS.nExecutingDialog; + /* Get a pointer to the current dialog */ + _ctx->dialog = GLOBALS.lpmdDialogs + GLOBALS.nExecutingDialog; - /* Cerca la scelta richiesta tra quelle nel dialogo */ + /* Search the choice between those required in the dialog */ for (_ctx->i = 0; _ctx->dialog->Choice[_ctx->i].nChoice != 0; _ctx->i++) if (_ctx->dialog->Choice[_ctx->i].nChoice == nChoice) break; - /* Se non l'ha trovata, esce con errore */ + /* If nothing has been found, exit with an error */ if (_ctx->dialog->Choice[_ctx->i].nChoice == 0) { - /* Se siamo qui, non abbiamo trovato la choice richiesta */ + /* If we're here, we did not find the required choice */ GLOBALS.mpalError = 1; UnlockDialogs(); @@ -1239,16 +1215,14 @@ void DoChoice(CORO_PARAM, uint32 nChoice) { return; } - /* Abbiamo trova la choice richiesta. Ricordiamoci qual e' nella - variabile globale */ + /* We've found the requested choice. Remember what in global variables */ GLOBALS.nExecutingChoice = _ctx->i; while (1) { GLOBALS.nExecutingChoice = _ctx->i; _ctx->k = 0; - /* Calcoliamo le when expression di ciascun select, per vedere se sono - attivi o disattivi */ + /* Calculate the expression of each selection, to see if they're active or inactive */ for (_ctx->j = 0; _ctx->dialog->Choice[_ctx->i].Select[_ctx->j].dwData != 0; _ctx->j++) if (_ctx->dialog->Choice[_ctx->i].Select[_ctx->j].when == NULL) { _ctx->dialog->Choice[_ctx->i].Select[_ctx->j].curActive = 1; @@ -1259,42 +1233,41 @@ void DoChoice(CORO_PARAM, uint32 nChoice) { } else _ctx->dialog->Choice[_ctx->i].Select[_ctx->j].curActive = 0; - /* Se non ci sono scelte attivate, la scelta e' finita */ + /* If there are no choices activated, then the dialog is finished. */ if (_ctx->k == 0) { UnlockDialogs(); break; } - /* Avvertiamo il gioco che c'e' una scelta da far fare all'utente, - e restiamo in attesa della risposta */ + /* There are choices available to the user, so wait for them to make one */ CoroScheduler.resetEvent(GLOBALS.hDoneChoice); CoroScheduler.setEvent(GLOBALS.hAskChoice); CORO_INVOKE_2(CoroScheduler.waitForSingleObject, GLOBALS.hDoneChoice, CORO_INFINITE); - /* Ora che la scelta e' stata effettuata, possiamo eseguire _ctx->i gruppi - associati con la scelta */ + /* Now that the choice has been made, we can run the groups associated with the choice tbontbtitq + */ _ctx->j = GLOBALS.nSelectedChoice; for (_ctx->k = 0; _ctx->dialog->Choice[_ctx->i].Select[_ctx->j].wPlayGroup[_ctx->k] != 0; _ctx->k++) { _ctx->nGroup = _ctx->dialog->Choice[_ctx->i].Select[_ctx->j].wPlayGroup[_ctx->k]; CORO_INVOKE_1(GroupThread, &_ctx->nGroup); } - /* Controllo sugli attributi */ + /* Control attribute */ if (_ctx->dialog->Choice[_ctx->i].Select[_ctx->j].attr & (1 << 0)) { - /* Bit 0 settato: fine della scelta */ + /* Bit 0 set: the end of the choice */ UnlockDialogs(); break; } if (_ctx->dialog->Choice[_ctx->i].Select[_ctx->j].attr & (1 << 1)) { - /* Bit 1 settato: fine del dialogo */ + /* Bit 1 set: the end of the dialog */ UnlockDialogs(); CORO_KILL_SELF(); return; } - /* Fine della scelta senza attributi: bisogna rifarla */ + /* End of choic ewithout attributes. We must do it again */ } // If we're here, we found an end choice. Return to the caller group @@ -1339,23 +1312,23 @@ static uint32 DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { continue; } - // Ora abbiamo trova l'azione giusta che deve essere eseguita. - // Duplichiamo l'item corrente e copiamo la azione #i nella #0 + // Now we find the right action to be performed + // Duplicate the item and copy the current action in #i into #0 newitem = (LPMPALITEM)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MPALITEM)); if (newitem == NULL) return CORO_INVALID_PID_VALUE; - // Nella nuova versione scriviamo il numero dell'azione in dwRes + // In the new version number of the action in writing dwRes Common::copy((byte *)item, (byte *)item + sizeof(MPALITEM), (byte *)newitem); /* newitem->Action[0].nCmds=item->Action[i].nCmds; CopyMemory(newitem->Action[0].CmdNum,item->Action[i].CmdNum,newitem->Action[0].nCmds*sizeof(newitem->Action[0].CmdNum[0])); */ newitem->dwRes = i; - // E finalmente possiamo richiamare il thread, che eseguira' l'azione - // 0 dell'item, e poi liberera' la memoria con la GlobalFree() + // And finally we can laucnh the process that will execute the action, + // and a second process to free up the memory when the action is finished. - // !!! New thread management + // !!! New process management if ((h = CoroScheduler.createProcess(ActionThread, &newitem, sizeof(LPMPALITEM))) == CORO_INVALID_PID_VALUE) return CORO_INVALID_PID_VALUE; @@ -1420,7 +1393,7 @@ static uint32 DoDialog(uint32 nDlgOrd, uint32 nGroup) { * @returns True if everything is OK, false on failure */ bool DoSelection(uint32 i, uint32 dwData) { - LPMPALDIALOG dialog=GLOBALS.lpmdDialogs+GLOBALS.nExecutingDialog; + LPMPALDIALOG dialog = GLOBALS.lpmdDialogs+GLOBALS.nExecutingDialog; int j; for (j = 0; dialog->Choice[i].Select[j].dwData != 0; j++) @@ -1461,15 +1434,15 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, //printf("Script: %lu\n", sizeof(MPALSCRIPT)); //printf("Dialog: %lu\n", sizeof(MPALDIALOG)); - /* Si salva l'array delle funzioni custom */ + /* Save the array of custom functions */ GLOBALS.lplpFunctions = lplpcfArray; GLOBALS.lplpFunctionStrings = lpcfStrings; - /* Apre il file MPC in lettura */ + /* OPen the MPC file for reading */ if (!hMpc.open(lpszMpcFileName)) return false; - /* Legge e controlla l'header */ + /* Read and check the header */ nBytesRead = hMpc.read(buf, 5); if (nBytesRead != 5) return false; @@ -1479,7 +1452,7 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, bCompress = buf[4]; - /* Legge la dimensione del file decompresso, e alloca la memoria */ + /* Reads the size of the uncompressed file, and allocate memory */ dwSizeDecomp = hMpc.readUint32LE(); if (hMpc.err()) return false; @@ -1489,8 +1462,7 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, return false; if (bCompress) { - /* Se il file e' compresso, guarda quanto e' grande e alloca la - memoria temporanea per la decompressione */ + /* Get the compressed size and read the data in */ dwSizeComp = hMpc.readUint32LE(); if (hMpc.err()) return false; @@ -1503,30 +1475,29 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, if (nBytesRead != dwSizeComp) return false; - /* Decomprime l'immagine */ + /* Decompress the data */ lzo1x_decompress(cmpbuf, dwSizeComp, lpMpcImage, &nBytesRead); if (nBytesRead != dwSizeDecomp) return false; GlobalFree(cmpbuf); } else { - /* Se il file non e' compresso, lo legge all'interno della memoria gia' - allocata */ + /* If the file is not compressed, we directly read in the data */ nBytesRead = hMpc.read(lpMpcImage, dwSizeDecomp); if (nBytesRead != dwSizeDecomp) return false; } - /* Chiude il file */ + /* Close the file */ hMpc.close(); - /* Parsa l'immagine */ + /* Process the data */ if (ParseMpc(lpMpcImage) == false) return false; GlobalFree(lpMpcImage); - /* Calcola utilizzo di memoria */ + /* Calculate memory usage */ /* { char errbuf[256]; @@ -1541,11 +1512,11 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, } */ - /* Apre il file MPR in lettura */ + /* Open the MPR file */ if (!GLOBALS.hMpr.open(lpszMprFileName)) return false; - /* Si posiziona a 8 byte dalla fine del file */ + /* Seek to the end of the file to read overall information */ GLOBALS.hMpr.seek(-12, SEEK_END); dwSizeComp = GLOBALS.hMpr.readUint32LE(); @@ -1563,7 +1534,7 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, if (buf[0] !='E' || buf[1] != 'N' || buf[2] != 'D' || buf[3] != '0') return false; - /* Si posiziona all'inizio dell'header delle risorse */ + /* Move to the start of the resources header */ GLOBALS.hMpr.seek(-(12 + (int)dwSizeComp), SEEK_END); GLOBALS.lpResources = (uint32 *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, GLOBALS.nResources * 8); @@ -1584,18 +1555,17 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, GlobalFree(cmpbuf); - /* Si riposiziona all'inizio lasciando il file di risorse aperto */ + /* Reset back to the start of the file, leaving it open */ GLOBALS.hMpr.seek(0, SEEK_SET); - /* Non c'e' nessuna azione ne' dialogo in esecuzione */ + /* There is no action or dialog running by default */ GLOBALS.bExecutingAction = false; GLOBALS.bExecutingDialog = false; - /* Non c'e' nessuna locazione in polling */ + /* There's no polling location */ Common::fill(GLOBALS.nPollingLocations, GLOBALS.nPollingLocations + MAXPOLLINGLOCATIONS, 0); - /* Crea l'evento che verra' utilizzato per avvertire il gioco che c'e' - da effettuare una scelta */ + /* Create the event that will be used to co-ordinate making choices and choices finishing */ GLOBALS.hAskChoice = CoroScheduler.createEvent(true, false); GLOBALS.hDoneChoice = CoroScheduler.createEvent(true, false); @@ -2030,7 +2000,7 @@ bool mpalExecuteScript(int nScript) { CopyMemory(s, GLOBALS.lpmsScripts + n, sizeof(MPALSCRIPT)); UnlockScripts(); - // !!! Nuova gestione dei thread + // !!! New process management if (CoroScheduler.createProcess(ScriptThread, &s, sizeof(LPMPALSCRIPT)) == CORO_INVALID_PID_VALUE) return false; @@ -2070,7 +2040,7 @@ bool mpalStartIdlePoll(int nLoc) { GLOBALS.nPollingLocations[i] = nLoc; GLOBALS.hEndPollingLocations[i] = CoroScheduler.createEvent(true, false); -// !!! Nuova gestione dei thread +// !!! New process management if ((GLOBALS.PollingThreads[i] = CoroScheduler.createProcess(LocationPollThread, &i, sizeof(uint32))) == CORO_INVALID_PID_VALUE) // if ((GLOBALS.hEndPollingLocations[i]=(void*)_beginthread(LocationPollThread, 10240,(void *)i))==(void*)-1) return false; @@ -2150,7 +2120,7 @@ void mpalSaveState(byte *buf) { * @returns Length of the state buffer in bytes */ int mpalLoadState(byte *buf) { - // Dobbiamo distruggere tutte le variabili e ricrearle + // We must destroy and recreate all the variables GlobalFree(GLOBALS.hVars); GLOBALS.nVars = READ_LE_UINT32(buf); @@ -2325,20 +2295,20 @@ void mpalDumpMessages(void) { OutputStartMsgComment(GLOBALS.lpmmMsgs[i].wNum, f); while (1) { - // Trova la fine del periodo corrente + // Find the end of the current period while (*p != '\0') p++; - // Se c'e' un altro '\0' siamo alla fine del messaggio + // If there is another '\0' at the end of the message, then finish p++; if (*p == '\0') break; - // Altrimenti c'e' un altro periodo, e ci ricordiamo il suo inizio + // Otherwise there is another line, so remember the next one's start lpPeriods[nPeriods++] = p; } - // Ora fa un ciclo su tutti i periodi + // Now make a loop over all the periods for (j = 0;jGroup[g].nCmds; c++) { curCmd = &dlg->Command[dlg->Group[g].CmdNum[c]]; - // Se una funzione custom, e richiama la SendDialogMessage(nPers, nMsg) + // If it's a custom function, call SendDialogMessage(nPers, nMsg) if (curCmd->type == 1 && curCmd->nCf == 71) { sprintf(fname, "%03d-%05d.WAV", dlg->nObj, curCmd->arg2); diff --git a/engines/tony/mpal/mpaldll.h b/engines/tony/mpal/mpaldll.h index 69e58720a4..dc42b597bc 100644 --- a/engines/tony/mpal/mpaldll.h +++ b/engines/tony/mpal/mpaldll.h @@ -66,7 +66,7 @@ namespace MPAL { #define HEX_VERSION 0x0170 /* - SICURA + Safe #define MAX_ACTIONS_PER_ITEM 40 #define MAX_COMMANDS_PER_ITEM 256 @@ -90,7 +90,7 @@ namespace MPAL { /* - Versione sicura! + Secure version! #define MAX_GROUPS_PER_DIALOG 128 #define MAX_COMMANDS_PER_DIALOG 640 @@ -111,7 +111,7 @@ namespace MPAL { #define MAX_PERIODS_PER_DIALOG 400 /* - Prima di Rufus: + Before Rufus: #define MAX_GROUPS_PER_DIALOG 128 #define MAX_COMMANDS_PER_DIALOG 512 @@ -131,90 +131,75 @@ namespace MPAL { #include "common/pack-start.h" -/****************************************************************************\ -* typedef MPALVAR -* --------------- -* Description: Variabile globale di MPAL -\****************************************************************************/ - +/** + * MPAL global variables + */ struct MPALVAR { - uint32 dwVal; // Valore della variabile - char lpszVarName[33]; // Nome della variabile + uint32 dwVal; // Variable value + char lpszVarName[33]; // Variable name } PACKED_STRUCT; -typedef MPALVAR* LPMPALVAR; -typedef LPMPALVAR* LPLPMPALVAR; - +typedef MPALVAR *LPMPALVAR; +typedef LPMPALVAR *LPLPMPALVAR; -/****************************************************************************\ -* typedef MPALMSG -* --------------- -* Description: Messaggio di MPAL -\****************************************************************************/ +/** + * MPAL Messages + */ struct MPALMSG { - HGLOBAL hText; // Handle al testo del messaggio - uint16 wNum; // Numero del messaggio + HGLOBAL hText; // Handle to the message text + uint16 wNum; // Message number } PACKED_STRUCT; -typedef MPALMSG* LPMPALMSG; -typedef LPMPALMSG* LPLPMPALMSG; +typedef MPALMSG *LPMPALMSG; +typedef LPMPALMSG *LPLPMPALMSG; -/****************************************************************************\ -* typedef MPALLOCATION -* -------------------- -* Description: Locazione di MPAL -\****************************************************************************/ - +/** + * MPAL Locations + */ struct MPALLOCATION { - uint32 nObj; // Numero della locazione - uint32 dwXlen, dwYlen; // Dimensione - uint32 dwPicRes; // Risorsa che contiene l'immagine + uint32 nObj; // Location number + uint32 dwXlen, dwYlen; // Dimensions + uint32 dwPicRes; // Resource that contains the image } PACKED_STRUCT; -typedef MPALLOCATION* LPMPALLOCATION; -typedef LPMPALLOCATION* LPLPMPALLOCATION; - +typedef MPALLOCATION *LPMPALLOCATION; +typedef LPMPALLOCATION *LPLPMPALLOCATION; -/****************************************************************************\ -* struct command -* -------------- -* Description: Gestisce un comando, cioe' le tag utilizzate dalle OnAction -* negli item, dalle Time negli script e dai Group nei Dialog -\****************************************************************************/ +/** + * All the data for a command, ie. tags used by OnAction in the item, the time + * in the script, and in the group dialog. + */ struct command { /* - * Tipi di comandi riconosciuti: + * Types of commands that are recognised * - * #1 -> Chiamata a funzione custom (ITEM, SCRIPT, DIALOG) - * #2 -> Assegnazione di variabile (ITEM, SCRIPT, DIALOG) - * #3 -> Esecuzione di una scelta (DIALOG) + * #1 -> Custom function call (ITEM, SCRIPT, DIALOG) + * #2 -> Variable assignment (ITEM, SCRIPT, DIALOG) + * #3 -> Making a choice (DIALOG) * */ - byte type; // Tipo di comando + byte type; // Type of control union { - int32 nCf; // Numero funzione custom [#1] - char *lpszVarName; // Nome variabile [#2] - int32 nChoice; // Numero di scelta da fare [#3] + int32 nCf; // Custom function call [#1] + char *lpszVarName; // Variable name [#2] + int32 nChoice; // Number of choice you make [#3] }; union { - int32 arg1; // Argomento 1 funzione custom [#1] - HGLOBAL expr; // Espressione da assegnare alla - // variabile [#2] + int32 arg1; // Argument for custom function [#1] + HGLOBAL expr; // Expression to assign to a variable [#2] }; - int32 arg2,arg3,arg4; // Argomenti per funzione custom [#1] + int32 arg2, arg3, arg4; // Arguments for custom function [#1] } PACKED_STRUCT; -/****************************************************************************\ -* typedef MPALDIALOG -* ------------------ -* Description: Dialog di MPAL -\****************************************************************************/ +/** + * MPAL dialog + */ struct MPALDIALOG { - uint32 nObj; // Numero dialog + uint32 nObj; // Dialog number struct command Command[MAX_COMMANDS_PER_DIALOG]; @@ -227,11 +212,10 @@ struct MPALDIALOG { } Group[MAX_GROUPS_PER_DIALOG]; struct { - // L'ultima choice ha nChoice==0 + // The last choice has nChoice == 0 uint16 nChoice; - // Non c'e' il numero di Select (siamo abbastanza avari di RAM). L'ultimo - // select ha dwData==0 + // The select number (we're pretty stingy with RAM). The last select has dwData == 0 struct { HGLOBAL when; uint32 dwData; @@ -240,8 +224,8 @@ struct MPALDIALOG { // Bit 0=endchoice Bit 1=enddialog byte attr; - // Modificata a run-time: 0 se il select e' correntemente disabilitato, - // 1 se e' correntemente attivato + // Modified at run-time: 0 if the select is currently disabled, + // and 1 if currently active byte curActive; } Select[MAX_SELECTS_PER_CHOICE]; @@ -251,50 +235,48 @@ struct MPALDIALOG { HGLOBAL Periods[MAX_PERIODS_PER_DIALOG]; } PACKED_STRUCT; -typedef MPALDIALOG* LPMPALDIALOG; -typedef LPMPALDIALOG* LPLPMPALDIALOG; +typedef MPALDIALOG *LPMPALDIALOG; +typedef LPMPALDIALOG *LPLPMPALDIALOG; -/****************************************************************************\ -* typedef MPALITEM -* ---------------- -* Description: Item di MPAL -\****************************************************************************/ +/** + * MPAL Item + */ struct ItemAction { - byte num; // Numero dell'azione - uint16 wTime; // In caso di idle, il tempo che deve passare - byte perc; // Percentuale di eseguire l'idle - HGLOBAL when; // Espressione da calcolare: se !=0, allora - // l'azione puo' essere eseguita - uint16 wParm; // Parametro per l'azione - - byte nCmds; // Numero comandi da eseguire - uint32 CmdNum[MAX_COMMANDS_PER_ACTION]; // Comando da eseguire + byte num; // Action number + uint16 wTime; // If idle, the time which must pass + byte perc; // Percentage of the idle run + HGLOBAL when; // Expression to compute. If != 0, then + // action can be done + uint16 wParm; // Parameter for action + + byte nCmds; // Number of commands to be executed + uint32 CmdNum[MAX_COMMANDS_PER_ACTION]; // Commands to execute } PACKED_STRUCT; struct MPALITEM { - uint32 nObj; // Numero item + uint32 nObj; // Item number - byte lpszDescribe[MAX_DESCRIBE_SIZE]; // Nome - byte nActions; // Numero delle azioni gestite - uint32 dwRes; // Risorsa che contiene frame e pattern + byte lpszDescribe[MAX_DESCRIBE_SIZE]; // Name + byte nActions; // Number of managed actions + uint32 dwRes; // Resource that contains frames and patterns struct command Command[MAX_COMMANDS_PER_ITEM]; - // Array di strutture contenenti le varie azioni gestite. In pratica, di - // ogni azione sappiamo quali comandi eseguire, tra quelli definiti nella - // struttura qui sopra + // Array of structures containing various managed activities. In practice, of + // every action we know what commands to run, including those defined in + // structures above /* struct { - byte num; // Numero dell'azione - uint16 wTime; // In caso di idle, il tempo che deve passare - byte perc; // Percentuale di eseguire l'idle - HGLOBAL when; // Espressione da calcolare: se !=0, allora - // l'azione puo' essere eseguita - uint16 wParm; // Parametro per l'azione - - byte nCmds; // Numero comandi da eseguire + byte num; // Numero dell'azione + uint16 wTime; // In caso di idle, il tempo che deve passare + byte perc; // Percentuale di eseguire l'idle + HGLOBAL when; // Espressione da calcolare: se !=0, allora + // l'azione puo' essere eseguita + uint16 wParm; // Parametro per l'azione + + byte nCmds; // Numero comandi da eseguire uint32 CmdNum[MAX_COMMANDS_PER_ACTION]; // Comando da eseguire } Action[MAX_ACTIONS_PER_ITEM]; @@ -306,12 +288,9 @@ typedef MPALITEM* LPMPALITEM; typedef LPMPALITEM* LPLPMPALITEM; -/****************************************************************************\ -* typedef MPALSCRIPT -* ------------------ -* Description: Script di MPAL -\****************************************************************************/ - +/** + * MPAL Script + */ struct MPALSCRIPT { uint32 nObj; @@ -335,44 +314,27 @@ typedef LPMPALSCRIPT* LPLPMPALSCRIPT; /****************************************************************************\ -* Prototipi di funzione -\****************************************************************************/ - -/****************************************************************************\ -* -* Function: int32 varGetValue(const char *lpszVarName); -* -* Description: Restituisce il valore corrente di una variabile globale -* -* Input: const char *lpszVarName Nome della variabile -* -* Return: Valore corrente -* -* Note: Prima di questa funzione, bisogna richiamare LockVar() che -* locka le variabili globali per l'utilizzo. Dopo inoltre bi- -* sogna ricordarsi di chiamare UnlockVar() -* +* Function prototypes \****************************************************************************/ -int32 varGetValue(const char *lpszVarName); - - -/****************************************************************************\ -* -* Function: void varSetValue(const char *lpszVarName, int32 val); -* -* Description: Setta un nuovo valore per una variabile globale di MPAL -* -* Input: const char *lpszVarName Nome della variabile -* int32 val Valore da settare -* -\****************************************************************************/ +/** + * Returns the current value of a global variable + * + * @param lpszVarName Name of the variable + * @returns Current value + * @remarks Before using this method, you must call LockVar() to + * lock the global variablves for use. Then afterwards, you will + * need to remember to call UnlockVar() + */ +extern int32 varGetValue(const char *lpszVarName); -void varSetValue(const char *lpszVarName, int32 val); -/****************************************************************************\ -* Includes the various modules -\****************************************************************************/ +/** + * Sets the value of a MPAL global variable + * @param lpszVarName Name of the variable + * @param val Value to set + */ +extern void varSetValue(const char *lpszVarName, int32 val); } // end of namespace MPAL -- cgit v1.2.3 From f3398ee0104622a7ab0598507894c9d74a7a30e2 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 19 May 2012 19:54:04 +1000 Subject: TONY: Formatting fixes --- engines/tony/mpal/mpal.cpp | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 358b4e3505..d74248911e 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -67,11 +67,11 @@ namespace MPAL { \****************************************************************************/ const char *mpalCopyright = - "\n\nMPAL - MultiPurpose Adventure Language for Windows 95\n" - "Copyright 1997-98 Giovanni Bajo and Luca Giusti\n" - "ALL RIGHTS RESERVED\n" - "\n" - "\n"; + "\n\nMPAL - MultiPurpose Adventure Language for Windows 95\n" + "Copyright 1997-98 Giovanni Bajo and Luca Giusti\n" + "ALL RIGHTS RESERVED\n" + "\n" + "\n"; /****************************************************************************\ * Internal functions @@ -344,7 +344,7 @@ static char *DuplicateMessage(uint32 nMsgOrd) { j++; j += 2; - clonemsg=(char *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, j); + clonemsg = (char *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, j); if (clonemsg == NULL) return NULL; @@ -483,7 +483,7 @@ static uint32 *GetItemList(uint32 nLoc) { num++; } - il=(uint32 *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(uint32) * (num + 1)); + il = (uint32 *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(uint32) * (num + 1)); if (il == NULL) return NULL; @@ -569,15 +569,15 @@ static LPITEM GetItemData(uint32 nOrdItem) { for (i = 1; i < ret->numpattern; i++) { for (j = 0; j < patlength[i]; j++) ret->pattern[i][j] = dat[j]; - ret->pattern[i][(int)patlength[i]] = 255; // Termina i pattern + ret->pattern[i][(int)patlength[i]] = 255; // Terminate pattern dat += patlength[i]; } // Upload the individual frames of animations for (i = 1; i < ret->numframe; i++) { - dim=(uint32)(ret->frameslocations[i].right-ret->frameslocations[i].left) * + dim = (uint32)(ret->frameslocations[i].right-ret->frameslocations[i].left) * (uint32)(ret->frameslocations[i].bottom-ret->frameslocations[i].top); - ret->frames[i]=(char *)GlobalAlloc(GMEM_FIXED,dim); + ret->frames[i] = (char *)GlobalAlloc(GMEM_FIXED,dim); if (ret->frames[i] == NULL) return NULL; @@ -664,7 +664,7 @@ void ScriptThread(CORO_PARAM, const void *param) { _ctx->k = s->Moment[_ctx->i].CmdNum[_ctx->j]; if (s->Command[_ctx->k].type == 1) { - _ctx->p=(LPCFCALL)GlobalAlloc(GMEM_FIXED, sizeof(CFCALL)); + _ctx->p = (LPCFCALL)GlobalAlloc(GMEM_FIXED, sizeof(CFCALL)); if (_ctx->p == NULL) { GLOBALS.mpalError = 1; @@ -1026,7 +1026,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { // Create the process if ((_ctx->MyThreads[_ctx->i].hThread = CoroScheduler.createProcess(ActionThread, &_ctx->newItem, sizeof(LPMPALITEM))) == CORO_INVALID_PID_VALUE) { - //if ((_ctx->MyThreads[_ctx->i].hThread=(void*)_beginthread(ActionThread, 10240,(void *)_ctx->newItem))==(void*)-1) + //if ((_ctx->MyThreads[_ctx->i].hThread = (void*)_beginthread(ActionThread, 10240,(void *)_ctx->newItem))= = (void*)-1) GlobalFree(_ctx->newItem); GlobalFree(_ctx->MyThreads); GlobalFree(_ctx->MyActions); @@ -1457,7 +1457,7 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, if (hMpc.err()) return false; - byte *lpMpcImage = (byte *)GlobalAlloc(GMEM_FIXED,dwSizeDecomp+16); + byte *lpMpcImage = (byte *)GlobalAlloc(GMEM_FIXED, dwSizeDecomp + 16); if (lpMpcImage == NULL) return false; @@ -1467,7 +1467,7 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, if (hMpc.err()) return false; - cmpbuf = (byte *)GlobalAlloc(GMEM_FIXED,dwSizeComp); + cmpbuf = (byte *)GlobalAlloc(GMEM_FIXED, dwSizeComp); if (cmpbuf == NULL) return false; @@ -1550,7 +1550,7 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, return false; lzo1x_decompress((const byte *)cmpbuf, dwSizeComp, (byte *)GLOBALS.lpResources, (uint32 *)&nBytesRead); - if (nBytesRead != (uint32)GLOBALS.nResources*8) + if (nBytesRead != (uint32)GLOBALS.nResources * 8) return false; GlobalFree(cmpbuf); @@ -2042,7 +2042,7 @@ bool mpalStartIdlePoll(int nLoc) { GLOBALS.hEndPollingLocations[i] = CoroScheduler.createEvent(true, false); // !!! New process management if ((GLOBALS.PollingThreads[i] = CoroScheduler.createProcess(LocationPollThread, &i, sizeof(uint32))) == CORO_INVALID_PID_VALUE) -// if ((GLOBALS.hEndPollingLocations[i]=(void*)_beginthread(LocationPollThread, 10240,(void *)i))==(void*)-1) +// if ((GLOBALS.hEndPollingLocations[i] = (void*)_beginthread(LocationPollThread, 10240,(void *)i))= = (void*)-1) return false; return true; @@ -2130,7 +2130,7 @@ int mpalLoadState(byte *buf) { CopyMemory((byte *)GLOBALS.lpmvVars, buf + 4, GLOBALS.nVars * sizeof(MPALVAR)); UnlockVar(); - return GLOBALS.nVars*sizeof(MPALVAR)+4; + return GLOBALS.nVars * sizeof(MPALVAR) + 4; } bool bDontOutput; -- cgit v1.2.3 From c402426117e83fa833fdadcc6ad81f418d195c7e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 19 May 2012 20:29:53 +1000 Subject: TONY: Converted some warning calls to debugC --- engines/tony/mpal/mpal.cpp | 12 ++++++------ engines/tony/tony.h | 3 ++- 2 files changed, 8 insertions(+), 7 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index d74248911e..5cb6546343 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -645,7 +645,7 @@ void ScriptThread(CORO_PARAM, const void *param) { _ctx->dwStartTime = _vm->GetTime(); _ctx->numHandles = 0; -// warning("PlayScript(): Moments: %u\n",s->nMoments); +// debugC(DEBUG_BASIC, kTonyDebugMPAL, "PlayScript(): Moments: %u\n",s->nMoments); for (_ctx->i = 0; _ctx->i < s->nMoments; _ctx->i++) { // Dorme il tempo necessario per arrivare al momento successivo if (s->Moment[_ctx->i].dwTime == -1) { @@ -654,7 +654,7 @@ void ScriptThread(CORO_PARAM, const void *param) { } else { _ctx->dwCurTime = _vm->GetTime(); if (_ctx->dwCurTime < _ctx->dwStartTime + (s->Moment[_ctx->i].dwTime * 100)) { - // warning("PlayScript(): Sleeping %lums\n",_ctx->dwStartTime+(s->Moment[_ctx->i].dwTime*100)-_ctx->dwCurTime); + // debugC(DEBUG_BASIC, kTonyDebugMPAL, "PlayScript(): Sleeping %lums\n",_ctx->dwStartTime+(s->Moment[_ctx->i].dwTime*100)-_ctx->dwCurTime); CORO_INVOKE_1(CoroScheduler.sleep, _ctx->dwStartTime+(s->Moment[_ctx->i].dwTime * 100) - _ctx->dwCurTime); } } @@ -2199,7 +2199,7 @@ void OutputStartMsgComment(uint16 wNum, Common::OutSaveFile *f) { for (i = 0; MsgComments[i].wStart != 0; i++) if (MsgComments[i].wStart == wNum) { - warning("Start: %d\n", wNum); + debugC(DEBUG_BASIC, kTonyDebugMPAL, "Start: %d\n", wNum); f->writeString("
\n

\n

\n"); @@ -2217,7 +2217,7 @@ void OutputEndMsgComment(uint16 wNum, Common::OutSaveFile *f) { for (i = 0; MsgComments[i].wEnd != 0; i++) if (MsgComments[i].wEnd == wNum) { -warning("End: %d\n", wNum); + debugC(DEBUG_BASIC, kTonyDebugMPAL, "End: %d\n", wNum); if (strcmp(MsgComments[i].pComment, "###") != 0 && strncmp(MsgComments[i].pComment, "@@@", 3) != 0) { f->writeString("\n

\n"); @@ -2276,7 +2276,7 @@ void mpalDumpMessages(void) { bDontOutput = false; - warning("Dumping MESSAGES.HTM...\n"); + debugC(DEBUG_BASIC, kTonyDebugMPAL, "Dumping MESSAGES.HTM...\n"); f = g_system->getSavefileManager()->openForSaving("Messages.htm"); f->writeString("\n\n\n"); @@ -2369,7 +2369,7 @@ void mpalDumpOthers(void) { bDontOutput = false; - warning("Dumping OTHERS.HTM...\n"); + debugC(DEBUG_BASIC, kTonyDebugMPAL, "Dumping OTHERS.HTM...\n"); f->writeString("\n\n"); diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 18d4a37067..32332a871d 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -58,7 +58,8 @@ enum { kTonyDebugAnimations = 1 << 0, kTonyDebugActions = 1 << 1, kTonyDebugSound = 1 << 2, - kTonyDebugMusic = 2 << 3 + kTonyDebugMusic = 1 << 3, + kTonyDebugMPAL = 1 << 4 }; #define DEBUG_BASIC 1 -- cgit v1.2.3 From e76a55588af1deb9a14bb8d89d4d818ea8120d96 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 20 May 2012 09:23:12 +1000 Subject: TONY: Added assert for character indexes outside provided font --- engines/tony/font.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines') diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index db51dc3b79..b0e42407cf 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -120,6 +120,7 @@ RMGfxPrimitive *RMFont::MakeLetterPrimitive(byte bChar, int &nLength) { // Converte da carattere a lettera nLett = ConvertToLetter(bChar); + assert(nLett < nLetters); // Crea la primitiva per il font prim = new RMFontPrimitive(this); -- cgit v1.2.3 From 0136bf4a863073a9a47dc379e2eeb2fa74af2ec6 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 20 May 2012 09:57:24 +1000 Subject: TONY: Fix issues with font loading and display of accented characters --- engines/tony/font.cpp | 578 +++++++++++++++++++++++++------------------------- engines/tony/font.h | 8 +- 2 files changed, 291 insertions(+), 295 deletions(-) (limited to 'engines') diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index b0e42407cf..706aca8467 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -1162,297 +1162,293 @@ void RMFontCredits::Init(void) { lTable[':'] = 5; lTable['\''] = 5; - - - // Polish characters - //AaCcEeLlNnOoSsZzZz - //ス謎戊3剔囀 - - cTable[(byte)''] = 112; - cTable[(byte)''] = 113; - cTable[(byte)''] = 114; - cTable[(byte)''] = 115; - cTable[(byte)''] = 116; - cTable[(byte)''] = 117; - cTable[(byte)''] = 118; - cTable[(byte)''] = 119; - cTable[(byte)''] = 120; - cTable[(byte)''] = 121; - cTable[(byte)''] = 122; - cTable[(byte)''] = 123; - cTable[(byte)''] = 124; - cTable[(byte)''] = 125; - cTable[(byte)''] = 126; - cTable[(byte)''] = 127; - cTable[(byte)''] = 128; - cTable[(byte)''] = 129; - - lTable[(byte)''] = 20; - lTable[(byte)''] = 12; - lTable[(byte)''] = 15; - lTable[(byte)''] = 10; - lTable[(byte)''] = 15; - lTable[(byte)''] = 10; - lTable[(byte)''] = 14; - lTable[(byte)''] = 11; - lTable[(byte)''] = 16; - lTable[(byte)''] = 10; - lTable[(byte)''] = 15; - lTable[(byte)''] = 11; - lTable[(byte)''] = 15; - lTable[(byte)''] = 10; - lTable[(byte)''] = 15; - lTable[(byte)''] = 10; - lTable[(byte)''] = 15; - lTable[(byte)''] = 10; - - -#ifdef FONT_RUSSIAN - // Russian Characters - // WARNING: Il russo usa molti dei caratteri ISO-Latin-1 che servono - // per le altre traduzioni. Per compilare Tony in altre lingue, - // commentare via queste definizioni. - - cTable[(byte)''] = 130; - cTable[(byte)''] = 131; - cTable[(byte)''] = 132; - cTable[(byte)''] = 133; - cTable[(byte)''] = 134; - cTable[(byte)''] = 135; - cTable[(byte)''] = 136; - cTable[(byte)''] = 137; - cTable[(byte)''] = 138; - cTable[(byte)''] = 139; - cTable[(byte)''] = 140; - cTable[(byte)''] = 141; - cTable[(byte)''] = 142; - cTable[(byte)''] = 143; - cTable[(byte)''] = 144; - cTable[(byte)''] = 145; - cTable[(byte)''] = 146; - cTable[(byte)''] = 147; - cTable[(byte)''] = 148; - cTable[(byte)''] = 149; - cTable[(byte)''] = 150; - cTable[(byte)''] = 151; - cTable[(byte)''] = 152; - cTable[(byte)''] = 153; - cTable[(byte)''] = 154; - cTable[(byte)''] = 155; - cTable[(byte)''] = 156; - cTable[(byte)''] = 157; - cTable[(byte)''] = 158; - cTable[(byte)''] = 159; - cTable[(byte)''] = 160; - cTable[(byte)''] = 161; - cTable[(byte)''] = 162; - - cTable[(byte)''] = 163; - cTable[(byte)''] = 164; - cTable[(byte)''] = 165; - cTable[(byte)''] = 166; - cTable[(byte)''] = 167; - cTable[(byte)''] = 168; - cTable[(byte)''] = 169; - cTable[(byte)''] = 170; - cTable[(byte)''] = 171; - cTable[(byte)''] = 172; - cTable[(byte)''] = 173; - cTable[(byte)''] = 174; - cTable[(byte)''] = 175; - cTable[(byte)''] = 176; - cTable[(byte)''] = 177; - cTable[(byte)''] = 178; - cTable[(byte)''] = 179; - cTable[(byte)''] = 180; - cTable[(byte)''] = 181; - cTable[(byte)''] = 182; - cTable[(byte)''] = 183; - cTable[(byte)''] = 184; - cTable[(byte)''] = 185; - cTable[(byte)''] = 186; - cTable[(byte)''] = 187; - cTable[(byte)''] = 188; - cTable[(byte)''] = 189; - cTable[(byte)''] = 190; - cTable[(byte)''] = 191; - cTable[(byte)''] = 192; - cTable[(byte)''] = 193; - cTable[(byte)''] = 194; - cTable[(byte)''] = 195; - - lTable[(byte)''] = 20; - lTable[(byte)''] = 16; - lTable[(byte)''] = 16; - lTable[(byte)''] = 14; - lTable[(byte)''] = 22; - lTable[(byte)''] = 15; - lTable[(byte)''] = 15; - lTable[(byte)''] = 20; - lTable[(byte)''] = 12; - lTable[(byte)''] = 16; - lTable[(byte)''] = 16; - lTable[(byte)''] = 16; - lTable[(byte)''] = 22; - lTable[(byte)''] = 18; - lTable[(byte)''] = 16; - lTable[(byte)''] = 15; - lTable[(byte)''] = 14; - lTable[(byte)''] = 13; - lTable[(byte)''] = 15; - lTable[(byte)''] = 12; - lTable[(byte)''] = 14; - lTable[(byte)''] = 15; - lTable[(byte)''] = 13; - lTable[(byte)''] = 16; - lTable[(byte)''] = 14; - lTable[(byte)''] = 23; - lTable[(byte)''] = 23; - lTable[(byte)''] = 10; - lTable[(byte)''] = 12; - lTable[(byte)''] = 16; - lTable[(byte)''] = 12; - lTable[(byte)''] = 20; - lTable[(byte)''] = 15; - - lTable[(byte)''] = 12; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 16; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 13; - lTable[(byte)''] = 12; - lTable[(byte)''] = 13; - lTable[(byte)''] = 13; - lTable[(byte)''] = 12; - lTable[(byte)''] = 13; - lTable[(byte)''] = 14; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 12; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 15; - lTable[(byte)''] = 15; - lTable[(byte)''] = 10; - lTable[(byte)''] = 12; - lTable[(byte)''] = 16; - lTable[(byte)''] = 11; - lTable[(byte)''] = 13; - lTable[(byte)''] = 11; - -#endif // FONT_RUSSIAN - -#ifdef FONT_CZECH - - cTable[(byte)''] = 196; - cTable[(byte)''] = 197; - cTable[(byte)''] = 198; - cTable[(byte)''] = 199; - cTable[(byte)''] = 200; - cTable[(byte)''] = 201; - cTable[(byte)''] = 202; - cTable[(byte)''] = 203; - cTable[(byte)''] = 204; - cTable[(byte)''] = 205; - cTable[(byte)''] = 206; - cTable[(byte)''] = 207; - cTable[(byte)''] = 208; - cTable[(byte)''] = 209; - cTable[(byte)''] = 210; - - cTable[(byte)''] = 211; - cTable[(byte)''] = 212; - cTable[(byte)''] = 213; - cTable[(byte)''] = 214; - cTable[(byte)''] = 215; - cTable[(byte)''] = 216; - cTable[(byte)''] = 217; - cTable[(byte)''] = 218; - cTable[(byte)''] = 219; - cTable[(byte)''] = 220; - cTable[(byte)''] = 221; - cTable[(byte)''] = 222; - cTable[(byte)''] = 223; - cTable[(byte)''] = 224; - cTable[(byte)''] = 225; - - lTable[(byte)''] = 15; - lTable[(byte)''] = 15; - lTable[(byte)''] = 15; - lTable[(byte)''] = 15; - lTable[(byte)''] = 15; - lTable[(byte)''] = 14; - lTable[(byte)''] = 20; - lTable[(byte)''] = 7; - lTable[(byte)''] = 15; - lTable[(byte)''] = 20; - lTable[(byte)''] = 19; - lTable[(byte)''] = 16; - lTable[(byte)''] = 15; - lTable[(byte)''] = 13; - lTable[(byte)''] = 13; - - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 12; - lTable[(byte)''] = 6; - lTable[(byte)''] = 10; - lTable[(byte)''] = 15; - lTable[(byte)''] = 12; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - -#endif // FONT_CZECH - -#ifdef FONT_FRENCH - - cTable[(byte)''] = 226; - cTable[(byte)''] = 227; - cTable[(byte)''] = 228; - cTable[(byte)''] = 229; - cTable[(byte)''] = 230; - cTable[(byte)''] = 231; - cTable[(byte)''] = 232; - cTable[(byte)''] = 233; - - lTable[(byte)''] = 12; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 6; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - -#endif // FONT_FRENCH - -#ifdef FONT_GERMAN - cTable[(byte)''] = 234; - // 'SS' = 235 - - // old chars overrides - cTable[(byte)''] = cTable[(byte)''] = 55; - cTable[(byte)''] = cTable[(byte)''] = 67; - cTable[(byte)''] = cTable[(byte)''] = 71; - - lTable[(byte)''] = 11; - -#endif // FONT_GERMAN + if (_vm->getLanguage() == Common::PL_POL) { + // Polish characters + //AaCcEeLlNnOoSsZzZz + //ス謎戊3剔囀 + + cTable[(byte)''] = 112; + cTable[(byte)''] = 113; + cTable[(byte)''] = 114; + cTable[(byte)''] = 115; + cTable[(byte)''] = 116; + cTable[(byte)''] = 117; + cTable[(byte)''] = 118; + cTable[(byte)''] = 119; + cTable[(byte)''] = 120; + cTable[(byte)''] = 121; + cTable[(byte)''] = 122; + cTable[(byte)''] = 123; + cTable[(byte)''] = 124; + cTable[(byte)''] = 125; + cTable[(byte)''] = 126; + cTable[(byte)''] = 127; + cTable[(byte)''] = 128; + cTable[(byte)''] = 129; + + lTable[(byte)''] = 20; + lTable[(byte)''] = 12; + lTable[(byte)''] = 15; + lTable[(byte)''] = 10; + lTable[(byte)''] = 15; + lTable[(byte)''] = 10; + lTable[(byte)''] = 14; + lTable[(byte)''] = 11; + lTable[(byte)''] = 16; + lTable[(byte)''] = 10; + lTable[(byte)''] = 15; + lTable[(byte)''] = 11; + lTable[(byte)''] = 15; + lTable[(byte)''] = 10; + lTable[(byte)''] = 15; + lTable[(byte)''] = 10; + lTable[(byte)''] = 15; + lTable[(byte)''] = 10; + + } else if (_vm->getLanguage() == Common::RU_RUS) { + + // Russian Characters + // WARNING: Il russo usa molti dei caratteri ISO-Latin-1 che servono + // per le altre traduzioni. Per compilare Tony in altre lingue, + // commentare via queste definizioni. + + cTable[(byte)''] = 130; + cTable[(byte)''] = 131; + cTable[(byte)''] = 132; + cTable[(byte)''] = 133; + cTable[(byte)''] = 134; + cTable[(byte)''] = 135; + cTable[(byte)''] = 136; + cTable[(byte)''] = 137; + cTable[(byte)''] = 138; + cTable[(byte)''] = 139; + cTable[(byte)''] = 140; + cTable[(byte)''] = 141; + cTable[(byte)''] = 142; + cTable[(byte)''] = 143; + cTable[(byte)''] = 144; + cTable[(byte)''] = 145; + cTable[(byte)''] = 146; + cTable[(byte)''] = 147; + cTable[(byte)''] = 148; + cTable[(byte)''] = 149; + cTable[(byte)''] = 150; + cTable[(byte)''] = 151; + cTable[(byte)''] = 152; + cTable[(byte)''] = 153; + cTable[(byte)''] = 154; + cTable[(byte)''] = 155; + cTable[(byte)''] = 156; + cTable[(byte)''] = 157; + cTable[(byte)''] = 158; + cTable[(byte)''] = 159; + cTable[(byte)''] = 160; + cTable[(byte)''] = 161; + cTable[(byte)''] = 162; + + cTable[(byte)''] = 163; + cTable[(byte)''] = 164; + cTable[(byte)''] = 165; + cTable[(byte)''] = 166; + cTable[(byte)''] = 167; + cTable[(byte)''] = 168; + cTable[(byte)''] = 169; + cTable[(byte)''] = 170; + cTable[(byte)''] = 171; + cTable[(byte)''] = 172; + cTable[(byte)''] = 173; + cTable[(byte)''] = 174; + cTable[(byte)''] = 175; + cTable[(byte)''] = 176; + cTable[(byte)''] = 177; + cTable[(byte)''] = 178; + cTable[(byte)''] = 179; + cTable[(byte)''] = 180; + cTable[(byte)''] = 181; + cTable[(byte)''] = 182; + cTable[(byte)''] = 183; + cTable[(byte)''] = 184; + cTable[(byte)''] = 185; + cTable[(byte)''] = 186; + cTable[(byte)''] = 187; + cTable[(byte)''] = 188; + cTable[(byte)''] = 189; + cTable[(byte)''] = 190; + cTable[(byte)''] = 191; + cTable[(byte)''] = 192; + cTable[(byte)''] = 193; + cTable[(byte)''] = 194; + cTable[(byte)''] = 195; + + lTable[(byte)''] = 20; + lTable[(byte)''] = 16; + lTable[(byte)''] = 16; + lTable[(byte)''] = 14; + lTable[(byte)''] = 22; + lTable[(byte)''] = 15; + lTable[(byte)''] = 15; + lTable[(byte)''] = 20; + lTable[(byte)''] = 12; + lTable[(byte)''] = 16; + lTable[(byte)''] = 16; + lTable[(byte)''] = 16; + lTable[(byte)''] = 22; + lTable[(byte)''] = 18; + lTable[(byte)''] = 16; + lTable[(byte)''] = 15; + lTable[(byte)''] = 14; + lTable[(byte)''] = 13; + lTable[(byte)''] = 15; + lTable[(byte)''] = 12; + lTable[(byte)''] = 14; + lTable[(byte)''] = 15; + lTable[(byte)''] = 13; + lTable[(byte)''] = 16; + lTable[(byte)''] = 14; + lTable[(byte)''] = 23; + lTable[(byte)''] = 23; + lTable[(byte)''] = 10; + lTable[(byte)''] = 12; + lTable[(byte)''] = 16; + lTable[(byte)''] = 12; + lTable[(byte)''] = 20; + lTable[(byte)''] = 15; + + lTable[(byte)''] = 12; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 16; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 13; + lTable[(byte)''] = 12; + lTable[(byte)''] = 13; + lTable[(byte)''] = 13; + lTable[(byte)''] = 12; + lTable[(byte)''] = 13; + lTable[(byte)''] = 14; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 12; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 15; + lTable[(byte)''] = 15; + lTable[(byte)''] = 10; + lTable[(byte)''] = 12; + lTable[(byte)''] = 16; + lTable[(byte)''] = 11; + lTable[(byte)''] = 13; + lTable[(byte)''] = 11; + + } else if (_vm->getLanguage() == Common::CZ_CZE) { + // CZECH Language + + cTable[(byte)''] = 196; + cTable[(byte)''] = 197; + cTable[(byte)''] = 198; + cTable[(byte)''] = 199; + cTable[(byte)''] = 200; + cTable[(byte)''] = 201; + cTable[(byte)''] = 202; + cTable[(byte)''] = 203; + cTable[(byte)''] = 204; + cTable[(byte)''] = 205; + cTable[(byte)''] = 206; + cTable[(byte)''] = 207; + cTable[(byte)''] = 208; + cTable[(byte)''] = 209; + cTable[(byte)''] = 210; + + cTable[(byte)''] = 211; + cTable[(byte)''] = 212; + cTable[(byte)''] = 213; + cTable[(byte)''] = 214; + cTable[(byte)''] = 215; + cTable[(byte)''] = 216; + cTable[(byte)''] = 217; + cTable[(byte)''] = 218; + cTable[(byte)''] = 219; + cTable[(byte)''] = 220; + cTable[(byte)''] = 221; + cTable[(byte)''] = 222; + cTable[(byte)''] = 223; + cTable[(byte)''] = 224; + cTable[(byte)''] = 225; + + lTable[(byte)''] = 15; + lTable[(byte)''] = 15; + lTable[(byte)''] = 15; + lTable[(byte)''] = 15; + lTable[(byte)''] = 15; + lTable[(byte)''] = 14; + lTable[(byte)''] = 20; + lTable[(byte)''] = 7; + lTable[(byte)''] = 15; + lTable[(byte)''] = 20; + lTable[(byte)''] = 19; + lTable[(byte)''] = 16; + lTable[(byte)''] = 15; + lTable[(byte)''] = 13; + lTable[(byte)''] = 13; + + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 12; + lTable[(byte)''] = 6; + lTable[(byte)''] = 10; + lTable[(byte)''] = 15; + lTable[(byte)''] = 12; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + + } else if (_vm->getLanguage() == Common::FR_FRA) { + // French + + cTable[(byte)''] = 226; + cTable[(byte)''] = 227; + cTable[(byte)''] = 228; + cTable[(byte)''] = 229; + cTable[(byte)''] = 230; + cTable[(byte)''] = 231; + cTable[(byte)''] = 232; + cTable[(byte)''] = 233; + + lTable[(byte)''] = 12; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 6; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + + } else if (_vm->getLanguage() == Common::DE_DEU) { + // German + + cTable[(byte)''] = 234; + // 'SS' = 235 + + // old chars overrides + cTable[(byte)''] = cTable[(byte)''] = 55; + cTable[(byte)''] = cTable[(byte)''] = 67; + cTable[(byte)''] = cTable[(byte)''] = 71; + + lTable[(byte)''] = 11; + } } diff --git a/engines/tony/font.h b/engines/tony/font.h index 3ada4d76c0..dab07b79b3 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -77,10 +77,10 @@ protected: protected: // Conversione (da overloadare) - virtual int ConvertToLetter(int nChar) = 0; + virtual int ConvertToLetter(byte nChar) = 0; // Lunghezza dei caratteri (da overloadare) - virtual int LetterLength(int nChar, int nNext = 0) = 0; + virtual int LetterLength(byte nChar, byte nNext = 0) = 0; public: virtual int LetterHeight(void) = 0; @@ -126,10 +126,10 @@ protected: protected: // Overload dei metodi - int ConvertToLetter(int nChar) { + int ConvertToLetter(byte nChar) { return cTable[nChar]; } - int LetterLength(int nChar, int nNext = 0) { + int LetterLength(byte nChar, byte nNext = 0) { return (nChar != -1 ? lTable[nChar] + l2Table[nChar][nNext] : lDefault); } -- cgit v1.2.3 From 10b0451776249c4ffe27e319da4e8898a9ddb488 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 20 May 2012 10:52:08 +1000 Subject: TONY: Converted #ifdefs for different language fonts setup It now uses the ScummVM language from the game's detection entry, so foreign language versions like French and German should now load correctly. --- engines/tony/font.cpp | 1482 ++++++++++++++++++++++++------------------------- 1 file changed, 736 insertions(+), 746 deletions(-) (limited to 'engines') diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 706aca8467..91d6708a20 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -341,292 +341,288 @@ void RMFontParla::Init(void) { lTable['E'] = 10; lTable['F'] = 11; + if (_vm->getLanguage() == Common::PL_POL) { + // Polish characters + //AaCcEeLlNnOoSsZzZz + //ス謎戊3剔囀 + + cTable[(byte)''] = 112; + cTable[(byte)''] = 113; + cTable[(byte)''] = 114; + cTable[(byte)''] = 115; + cTable[(byte)''] = 116; + cTable[(byte)''] = 117; + cTable[(byte)''] = 118; + cTable[(byte)''] = 119; + cTable[(byte)''] = 120; + cTable[(byte)''] = 121; + cTable[(byte)''] = 122; + cTable[(byte)''] = 123; + cTable[(byte)''] = 124; + cTable[(byte)''] = 125; + cTable[(byte)''] = 126; + cTable[(byte)''] = 127; + cTable[(byte)''] = 128; + cTable[(byte)''] = 129; + + lTable[(byte)''] = 14; + lTable[(byte)''] = 16; + lTable[(byte)''] = 12; + lTable[(byte)''] = 12; + lTable[(byte)''] = 11; + lTable[(byte)''] = 12; + lTable[(byte)''] = 14; + lTable[(byte)''] = 9; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 13; + lTable[(byte)''] = 11; + lTable[(byte)''] = 12; + lTable[(byte)''] = 12; + lTable[(byte)''] = 13; + lTable[(byte)''] = 13; + lTable[(byte)''] = 14; + lTable[(byte)''] = 13; + + } else if (_vm->getLanguage() == Common::RU_RUS) { + + // Russian Characters + // WARNING: Il russo usa molti dei caratteri ISO-Latin-1 che servono + // per le altre traduzioni. Per compilare Tony in altre lingue, + // commentare via queste definizioni. + + cTable[(byte)''] = 130; + cTable[(byte)''] = 131; + cTable[(byte)''] = 132; + cTable[(byte)''] = 133; + cTable[(byte)''] = 134; + cTable[(byte)''] = 135; + cTable[(byte)''] = 136; + cTable[(byte)''] = 137; + cTable[(byte)''] = 138; + cTable[(byte)''] = 139; + cTable[(byte)''] = 140; + cTable[(byte)''] = 141; + cTable[(byte)''] = 142; + cTable[(byte)''] = 143; + cTable[(byte)''] = 144; + cTable[(byte)''] = 145; + cTable[(byte)''] = 146; + cTable[(byte)''] = 147; + cTable[(byte)''] = 148; + cTable[(byte)''] = 149; + cTable[(byte)''] = 150; + cTable[(byte)''] = 151; + cTable[(byte)''] = 152; + cTable[(byte)''] = 153; + cTable[(byte)''] = 154; + cTable[(byte)''] = 155; + cTable[(byte)''] = 156; + cTable[(byte)''] = 157; + cTable[(byte)''] = 158; + cTable[(byte)''] = 159; + cTable[(byte)''] = 160; + cTable[(byte)''] = 161; + cTable[(byte)''] = 162; + + cTable[(byte)''] = 163; + cTable[(byte)''] = 164; + cTable[(byte)''] = 165; + cTable[(byte)''] = 166; + cTable[(byte)''] = 167; + cTable[(byte)''] = 168; + cTable[(byte)''] = 169; + cTable[(byte)''] = 170; + cTable[(byte)''] = 171; + cTable[(byte)''] = 172; + cTable[(byte)''] = 173; + cTable[(byte)''] = 174; + cTable[(byte)''] = 175; + cTable[(byte)''] = 176; + cTable[(byte)''] = 177; + cTable[(byte)''] = 178; + cTable[(byte)''] = 179; + cTable[(byte)''] = 180; + cTable[(byte)''] = 181; + cTable[(byte)''] = 182; + cTable[(byte)''] = 183; + cTable[(byte)''] = 184; + cTable[(byte)''] = 185; + cTable[(byte)''] = 186; + cTable[(byte)''] = 187; + cTable[(byte)''] = 188; + cTable[(byte)''] = 189; + cTable[(byte)''] = 190; + cTable[(byte)''] = 191; + cTable[(byte)''] = 192; + cTable[(byte)''] = 193; + cTable[(byte)''] = 194; + cTable[(byte)''] = 195; + + lTable[(byte)''] = 13; + lTable[(byte)''] = 15; + lTable[(byte)''] = 15; + lTable[(byte)''] = 11; + lTable[(byte)''] = 15; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 15; + lTable[(byte)''] = 10; + lTable[(byte)''] = 13; + lTable[(byte)''] = 13; + lTable[(byte)''] = 12; + lTable[(byte)''] = 13; + lTable[(byte)''] = 14; + lTable[(byte)''] = 14; + lTable[(byte)''] = 13; + lTable[(byte)''] = 11; + lTable[(byte)''] = 12; + lTable[(byte)''] = 12; + lTable[(byte)''] = 18; + lTable[(byte)''] = 11; + lTable[(byte)''] = 13; + lTable[(byte)''] = 12; + lTable[(byte)''] = 13; + lTable[(byte)''] = 12; + lTable[(byte)''] = 17; + lTable[(byte)''] = 18; + lTable[(byte)''] = 16; + lTable[(byte)''] = 18; + lTable[(byte)''] = 19; + lTable[(byte)''] = 11; + lTable[(byte)''] = 16; + lTable[(byte)''] = 14; + + lTable[(byte)''] = 14; + lTable[(byte)''] = 15; + lTable[(byte)''] = 10; + lTable[(byte)''] = 12; + lTable[(byte)''] = 13; + lTable[(byte)''] = 12; + lTable[(byte)''] = 12; + lTable[(byte)''] = 12; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 12; + lTable[(byte)''] = 12; + lTable[(byte)''] = 12; + lTable[(byte)''] = 12; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 14; + lTable[(byte)''] = 8; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 12; + lTable[(byte)''] = 10; + lTable[(byte)''] = 15; + lTable[(byte)''] = 16; + lTable[(byte)''] = 14; + lTable[(byte)''] = 16; + lTable[(byte)''] = 16; + lTable[(byte)''] = 9; + lTable[(byte)''] = 15; + lTable[(byte)''] = 14; + + } else if (_vm->getLanguage() == Common::CZ_CZE) { + // Czech + cTable[(byte)''] = 196; + cTable[(byte)''] = 197; + cTable[(byte)''] = 198; + cTable[(byte)''] = 199; + cTable[(byte)''] = 200; + cTable[(byte)''] = 201; + cTable[(byte)''] = 202; + cTable[(byte)''] = 203; + cTable[(byte)''] = 204; + cTable[(byte)''] = 205; + cTable[(byte)''] = 206; + cTable[(byte)''] = 207; + cTable[(byte)''] = 208; + cTable[(byte)''] = 209; + cTable[(byte)''] = 210; + + cTable[(byte)''] = 211; + cTable[(byte)''] = 212; + cTable[(byte)''] = 213; + cTable[(byte)''] = 214; + cTable[(byte)''] = 215; + cTable[(byte)''] = 216; + cTable[(byte)''] = 217; + cTable[(byte)''] = 218; + cTable[(byte)''] = 219; + cTable[(byte)''] = 220; + cTable[(byte)''] = 221; + cTable[(byte)''] = 222; + cTable[(byte)''] = 223; + cTable[(byte)''] = 224; + cTable[(byte)''] = 225; + + lTable[(byte)''] = 11; + lTable[(byte)''] = 12; + lTable[(byte)''] = 12; + lTable[(byte)''] = 14; + lTable[(byte)''] = 13; + lTable[(byte)''] = 11; + lTable[(byte)''] = 13; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 15; + lTable[(byte)''] = 19; + lTable[(byte)''] = 10; + lTable[(byte)''] = 13; + lTable[(byte)''] = 13; + lTable[(byte)''] = 13; + + lTable[(byte)''] = 12; + lTable[(byte)''] = 12; + lTable[(byte)''] = 12; + lTable[(byte)''] = 12; + lTable[(byte)''] = 13; + lTable[(byte)''] = 11; + lTable[(byte)''] = 15; + lTable[(byte)''] = 7; + lTable[(byte)''] = 12; + lTable[(byte)''] = 17; + lTable[(byte)''] = 16; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 13; + lTable[(byte)''] = 13; + + } else if (_vm->getLanguage() == Common::FR_FRA) { + // French - // Polish characters - //AaCcEeLlNnOoSsZzZz - //ス謎戊3剔囀 - - cTable[(byte)''] = 112; - cTable[(byte)''] = 113; - cTable[(byte)''] = 114; - cTable[(byte)''] = 115; - cTable[(byte)''] = 116; - cTable[(byte)''] = 117; - cTable[(byte)''] = 118; - cTable[(byte)''] = 119; - cTable[(byte)''] = 120; - cTable[(byte)''] = 121; - cTable[(byte)''] = 122; - cTable[(byte)''] = 123; - cTable[(byte)''] = 124; - cTable[(byte)''] = 125; - cTable[(byte)''] = 126; - cTable[(byte)''] = 127; - cTable[(byte)''] = 128; - cTable[(byte)''] = 129; - - lTable[(byte)''] = 14; - lTable[(byte)''] = 16; - lTable[(byte)''] = 12; - lTable[(byte)''] = 12; - lTable[(byte)''] = 11; - lTable[(byte)''] = 12; - lTable[(byte)''] = 14; - lTable[(byte)''] = 9; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 13; - lTable[(byte)''] = 11; - lTable[(byte)''] = 12; - lTable[(byte)''] = 12; - lTable[(byte)''] = 13; - lTable[(byte)''] = 13; - lTable[(byte)''] = 14; - lTable[(byte)''] = 13; - -#ifdef FONT_RUSSIAN - // Russian Characters - // WARNING: Il russo usa molti dei caratteri ISO-Latin-1 che servono - // per le altre traduzioni. Per compilare Tony in altre lingue, - // commentare via queste definizioni. - - cTable[(byte)''] = 130; - cTable[(byte)''] = 131; - cTable[(byte)''] = 132; - cTable[(byte)''] = 133; - cTable[(byte)''] = 134; - cTable[(byte)''] = 135; - cTable[(byte)''] = 136; - cTable[(byte)''] = 137; - cTable[(byte)''] = 138; - cTable[(byte)''] = 139; - cTable[(byte)''] = 140; - cTable[(byte)''] = 141; - cTable[(byte)''] = 142; - cTable[(byte)''] = 143; - cTable[(byte)''] = 144; - cTable[(byte)''] = 145; - cTable[(byte)''] = 146; - cTable[(byte)''] = 147; - cTable[(byte)''] = 148; - cTable[(byte)''] = 149; - cTable[(byte)''] = 150; - cTable[(byte)''] = 151; - cTable[(byte)''] = 152; - cTable[(byte)''] = 153; - cTable[(byte)''] = 154; - cTable[(byte)''] = 155; - cTable[(byte)''] = 156; - cTable[(byte)''] = 157; - cTable[(byte)''] = 158; - cTable[(byte)''] = 159; - cTable[(byte)''] = 160; - cTable[(byte)''] = 161; - cTable[(byte)''] = 162; - - cTable[(byte)''] = 163; - cTable[(byte)''] = 164; - cTable[(byte)''] = 165; - cTable[(byte)''] = 166; - cTable[(byte)''] = 167; - cTable[(byte)''] = 168; - cTable[(byte)''] = 169; - cTable[(byte)''] = 170; - cTable[(byte)''] = 171; - cTable[(byte)''] = 172; - cTable[(byte)''] = 173; - cTable[(byte)''] = 174; - cTable[(byte)''] = 175; - cTable[(byte)''] = 176; - cTable[(byte)''] = 177; - cTable[(byte)''] = 178; - cTable[(byte)''] = 179; - cTable[(byte)''] = 180; - cTable[(byte)''] = 181; - cTable[(byte)''] = 182; - cTable[(byte)''] = 183; - cTable[(byte)''] = 184; - cTable[(byte)''] = 185; - cTable[(byte)''] = 186; - cTable[(byte)''] = 187; - cTable[(byte)''] = 188; - cTable[(byte)''] = 189; - cTable[(byte)''] = 190; - cTable[(byte)''] = 191; - cTable[(byte)''] = 192; - cTable[(byte)''] = 193; - cTable[(byte)''] = 194; - cTable[(byte)''] = 195; - - lTable[(byte)''] = 13; - lTable[(byte)''] = 15; - lTable[(byte)''] = 15; - lTable[(byte)''] = 11; - lTable[(byte)''] = 15; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 15; - lTable[(byte)''] = 10; - lTable[(byte)''] = 13; - lTable[(byte)''] = 13; - lTable[(byte)''] = 12; - lTable[(byte)''] = 13; - lTable[(byte)''] = 14; - lTable[(byte)''] = 14; - lTable[(byte)''] = 13; - lTable[(byte)''] = 11; - lTable[(byte)''] = 12; - lTable[(byte)''] = 12; - lTable[(byte)''] = 18; - lTable[(byte)''] = 11; - lTable[(byte)''] = 13; - lTable[(byte)''] = 12; - lTable[(byte)''] = 13; - lTable[(byte)''] = 12; - lTable[(byte)''] = 17; - lTable[(byte)''] = 18; - lTable[(byte)''] = 16; - lTable[(byte)''] = 18; - lTable[(byte)''] = 19; - lTable[(byte)''] = 11; - lTable[(byte)''] = 16; - lTable[(byte)''] = 14; - - lTable[(byte)''] = 14; - lTable[(byte)''] = 15; - lTable[(byte)''] = 10; - lTable[(byte)''] = 12; - lTable[(byte)''] = 13; - lTable[(byte)''] = 12; - lTable[(byte)''] = 12; - lTable[(byte)''] = 12; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 12; - lTable[(byte)''] = 12; - lTable[(byte)''] = 12; - lTable[(byte)''] = 12; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 14; - lTable[(byte)''] = 8; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 12; - lTable[(byte)''] = 10; - lTable[(byte)''] = 15; - lTable[(byte)''] = 16; - lTable[(byte)''] = 14; - lTable[(byte)''] = 16; - lTable[(byte)''] = 16; - lTable[(byte)''] = 9; - lTable[(byte)''] = 15; - lTable[(byte)''] = 14; - -#endif // FONT_RUSSIAN - -#ifdef FONT_CZECH - - cTable[(byte)''] = 196; - cTable[(byte)''] = 197; - cTable[(byte)''] = 198; - cTable[(byte)''] = 199; - cTable[(byte)''] = 200; - cTable[(byte)''] = 201; - cTable[(byte)''] = 202; - cTable[(byte)''] = 203; - cTable[(byte)''] = 204; - cTable[(byte)''] = 205; - cTable[(byte)''] = 206; - cTable[(byte)''] = 207; - cTable[(byte)''] = 208; - cTable[(byte)''] = 209; - cTable[(byte)''] = 210; - - cTable[(byte)''] = 211; - cTable[(byte)''] = 212; - cTable[(byte)''] = 213; - cTable[(byte)''] = 214; - cTable[(byte)''] = 215; - cTable[(byte)''] = 216; - cTable[(byte)''] = 217; - cTable[(byte)''] = 218; - cTable[(byte)''] = 219; - cTable[(byte)''] = 220; - cTable[(byte)''] = 221; - cTable[(byte)''] = 222; - cTable[(byte)''] = 223; - cTable[(byte)''] = 224; - cTable[(byte)''] = 225; - - lTable[(byte)''] = 11; - lTable[(byte)''] = 12; - lTable[(byte)''] = 12; - lTable[(byte)''] = 14; - lTable[(byte)''] = 13; - lTable[(byte)''] = 11; - lTable[(byte)''] = 13; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 15; - lTable[(byte)''] = 19; - lTable[(byte)''] = 10; - lTable[(byte)''] = 13; - lTable[(byte)''] = 13; - lTable[(byte)''] = 13; - - lTable[(byte)''] = 12; - lTable[(byte)''] = 12; - lTable[(byte)''] = 12; - lTable[(byte)''] = 12; - lTable[(byte)''] = 13; - lTable[(byte)''] = 11; - lTable[(byte)''] = 15; - lTable[(byte)''] = 7; - lTable[(byte)''] = 12; - lTable[(byte)''] = 17; - lTable[(byte)''] = 16; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 13; - lTable[(byte)''] = 13; - -#endif // FONT_CZECH - -#ifdef FONT_FRENCH - cTable[(byte)''] = 226; - cTable[(byte)''] = 227; - cTable[(byte)''] = 228; - cTable[(byte)''] = 229; - cTable[(byte)''] = 230; - cTable[(byte)''] = 231; - cTable[(byte)''] = 232; - cTable[(byte)''] = 233; - - lTable[(byte)''] = 15; - lTable[(byte)''] = 12; - lTable[(byte)''] = 12; - lTable[(byte)''] = 9; - lTable[(byte)''] = 13; - lTable[(byte)''] = 13; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - -#endif // FONT_FRENCH - -#ifdef FONT_GERMAN - cTable[(byte)''] = 234; - // 'SS' = 235 - cTable[(byte)''] = 236; - cTable[(byte)''] = 237; - cTable[(byte)''] = 238; - - lTable[(byte)''] = 15; - -#endif // FONT_GERMAN + cTable[(byte)''] = 226; + cTable[(byte)''] = 227; + cTable[(byte)''] = 228; + cTable[(byte)''] = 229; + cTable[(byte)''] = 230; + cTable[(byte)''] = 231; + cTable[(byte)''] = 232; + cTable[(byte)''] = 233; + + lTable[(byte)''] = 15; + lTable[(byte)''] = 12; + lTable[(byte)''] = 12; + lTable[(byte)''] = 9; + lTable[(byte)''] = 13; + lTable[(byte)''] = 13; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + + } else if (_vm->getLanguage() == Common::DE_DEU) { + cTable[(byte)''] = 234; + // 'SS' = 235 + cTable[(byte)''] = 236; + cTable[(byte)''] = 237; + cTable[(byte)''] = 238; + + lTable[(byte)''] = 15; + } } @@ -709,292 +705,290 @@ void RMFontMacc::Init(void) { //cTable[(byte)''] = 100; // u col pallino cTable[(byte)''] = 101; - // Polish characters - //AaCcEeLlNnOoSsZzZz - //ス謎戊3剔囀 - - cTable[(byte)''] = 102; - cTable[(byte)''] = 103; - cTable[(byte)''] = 104; - cTable[(byte)''] = 105; - cTable[(byte)''] = 106; - cTable[(byte)''] = 107; - cTable[(byte)''] = 108; - cTable[(byte)''] = 109; - cTable[(byte)''] = 110; - cTable[(byte)''] = 111; - cTable[(byte)''] = 112; - cTable[(byte)''] = 113; - cTable[(byte)''] = 114; - cTable[(byte)''] = 115; - cTable[(byte)''] = 116; - cTable[(byte)''] = 117; - cTable[(byte)''] = 118; - cTable[(byte)''] = 119; - - lTable[(byte)''] = 14; - lTable[(byte)''] = 16; - lTable[(byte)''] = 12; - lTable[(byte)''] = 12; - lTable[(byte)''] = 11; - lTable[(byte)''] = 12; - lTable[(byte)''] = 14; - lTable[(byte)''] = 9; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 13; - lTable[(byte)''] = 11; - lTable[(byte)''] = 12; - lTable[(byte)''] = 12; - lTable[(byte)''] = 13; - lTable[(byte)''] = 13; - lTable[(byte)''] = 14; - lTable[(byte)''] = 13; - - -#ifdef FONT_RUSSIAN - // Russian Characters - // WARNING: Il russo usa molti dei caratteri ISO-Latin-1 che servono - // per le altre traduzioni. Per compilare Tony in altre lingue, - // commentare via queste definizioni. - - cTable[(byte)''] = 120; - cTable[(byte)''] = 121; - cTable[(byte)''] = 122; - cTable[(byte)''] = 123; - cTable[(byte)''] = 124; - cTable[(byte)''] = 125; - cTable[(byte)''] = 126; - cTable[(byte)''] = 127; - cTable[(byte)''] = 128; - cTable[(byte)''] = 129; - cTable[(byte)''] = 130; - cTable[(byte)''] = 131; - cTable[(byte)''] = 132; - cTable[(byte)''] = 133; - cTable[(byte)''] = 134; - cTable[(byte)''] = 135; - cTable[(byte)''] = 136; - cTable[(byte)''] = 137; - cTable[(byte)''] = 138; - cTable[(byte)''] = 139; - cTable[(byte)''] = 140; - cTable[(byte)''] = 141; - cTable[(byte)''] = 142; - cTable[(byte)''] = 143; - cTable[(byte)''] = 144; - cTable[(byte)''] = 145; - cTable[(byte)''] = 146; - cTable[(byte)''] = 147; - cTable[(byte)''] = 148; - cTable[(byte)''] = 149; - cTable[(byte)''] = 150; - cTable[(byte)''] = 151; - cTable[(byte)''] = 152; - - cTable[(byte)''] = 153; - cTable[(byte)''] = 154; - cTable[(byte)''] = 155; - cTable[(byte)''] = 156; - cTable[(byte)''] = 157; - cTable[(byte)''] = 158; - cTable[(byte)''] = 159; - cTable[(byte)''] = 160; - cTable[(byte)''] = 161; - cTable[(byte)''] = 162; - cTable[(byte)''] = 163; - cTable[(byte)''] = 164; - cTable[(byte)''] = 165; - cTable[(byte)''] = 166; - cTable[(byte)''] = 167; - cTable[(byte)''] = 168; - cTable[(byte)''] = 169; - cTable[(byte)''] = 170; - cTable[(byte)''] = 171; - cTable[(byte)''] = 172; - cTable[(byte)''] = 173; - cTable[(byte)''] = 174; - cTable[(byte)''] = 175; - cTable[(byte)''] = 176; - cTable[(byte)''] = 177; - cTable[(byte)''] = 178; - cTable[(byte)''] = 179; - cTable[(byte)''] = 180; - cTable[(byte)''] = 181; - cTable[(byte)''] = 182; - cTable[(byte)''] = 183; - cTable[(byte)''] = 184; - cTable[(byte)''] = 185; - - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 9; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 9; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 8; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 9; - lTable[(byte)''] = 10; - lTable[(byte)''] = 9; - lTable[(byte)''] = 10; - lTable[(byte)''] = 9; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 9; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 9; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 9; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - -#endif // FONT_RUSSIAN - -#ifdef FONT_CZECH - - cTable[(byte)''] = 186; - cTable[(byte)''] = 187; - cTable[(byte)''] = 188; - cTable[(byte)''] = 189; - cTable[(byte)''] = 190; - cTable[(byte)''] = 191; - cTable[(byte)''] = 192; - cTable[(byte)''] = 193; - cTable[(byte)''] = 194; - cTable[(byte)''] = 195; - cTable[(byte)''] = 196; - cTable[(byte)''] = 197; - cTable[(byte)''] = 198; - cTable[(byte)''] = 199; - cTable[(byte)''] = 200; - - cTable[(byte)''] = 201; - cTable[(byte)''] = 202; - cTable[(byte)''] = 203; - cTable[(byte)''] = 204; - cTable[(byte)''] = 205; - cTable[(byte)''] = 206; - cTable[(byte)''] = 207; - cTable[(byte)''] = 208; - cTable[(byte)''] = 209; - cTable[(byte)''] = 210; - cTable[(byte)''] = 211; - cTable[(byte)''] = 212; - cTable[(byte)''] = 213; - cTable[(byte)''] = 214; - cTable[(byte)''] = 215; - - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 9; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 9; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - - lTable[(byte)''] = 10; - lTable[(byte)''] = 9; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 9; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 9; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - -#endif // FONT_CZECH - -#ifdef FONT_FRENCH - - cTable[(byte)''] = 226; - cTable[(byte)''] = 227; - cTable[(byte)''] = 228; - cTable[(byte)''] = 229; - cTable[(byte)''] = 230; - cTable[(byte)''] = 231; - cTable[(byte)''] = 232; - cTable[(byte)''] = 233; - - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 8; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - -#endif // FONT_FRENCH - -#ifdef FONT_GERMAN - cTable[(byte)''] = 234; - // 'SS' = 235 - cTable[(byte)''] = 236; - cTable[(byte)''] = 237; - cTable[(byte)''] = 238; - - lTable[(byte)''] = 11; -#endif // FONT_GERMAN + if (_vm->getLanguage() == Common::PL_POL) { + // Polish characters + //AaCcEeLlNnOoSsZzZz + //ス謎戊3剔囀 + + cTable[(byte)''] = 102; + cTable[(byte)''] = 103; + cTable[(byte)''] = 104; + cTable[(byte)''] = 105; + cTable[(byte)''] = 106; + cTable[(byte)''] = 107; + cTable[(byte)''] = 108; + cTable[(byte)''] = 109; + cTable[(byte)''] = 110; + cTable[(byte)''] = 111; + cTable[(byte)''] = 112; + cTable[(byte)''] = 113; + cTable[(byte)''] = 114; + cTable[(byte)''] = 115; + cTable[(byte)''] = 116; + cTable[(byte)''] = 117; + cTable[(byte)''] = 118; + cTable[(byte)''] = 119; + + lTable[(byte)''] = 14; + lTable[(byte)''] = 16; + lTable[(byte)''] = 12; + lTable[(byte)''] = 12; + lTable[(byte)''] = 11; + lTable[(byte)''] = 12; + lTable[(byte)''] = 14; + lTable[(byte)''] = 9; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 13; + lTable[(byte)''] = 11; + lTable[(byte)''] = 12; + lTable[(byte)''] = 12; + lTable[(byte)''] = 13; + lTable[(byte)''] = 13; + lTable[(byte)''] = 14; + lTable[(byte)''] = 13; + + } else if (_vm->getLanguage() == Common::RU_RUS) { + // Russian Characters + // WARNING: Il russo usa molti dei caratteri ISO-Latin-1 che servono + // per le altre traduzioni. Per compilare Tony in altre lingue, + // commentare via queste definizioni. + + cTable[(byte)''] = 120; + cTable[(byte)''] = 121; + cTable[(byte)''] = 122; + cTable[(byte)''] = 123; + cTable[(byte)''] = 124; + cTable[(byte)''] = 125; + cTable[(byte)''] = 126; + cTable[(byte)''] = 127; + cTable[(byte)''] = 128; + cTable[(byte)''] = 129; + cTable[(byte)''] = 130; + cTable[(byte)''] = 131; + cTable[(byte)''] = 132; + cTable[(byte)''] = 133; + cTable[(byte)''] = 134; + cTable[(byte)''] = 135; + cTable[(byte)''] = 136; + cTable[(byte)''] = 137; + cTable[(byte)''] = 138; + cTable[(byte)''] = 139; + cTable[(byte)''] = 140; + cTable[(byte)''] = 141; + cTable[(byte)''] = 142; + cTable[(byte)''] = 143; + cTable[(byte)''] = 144; + cTable[(byte)''] = 145; + cTable[(byte)''] = 146; + cTable[(byte)''] = 147; + cTable[(byte)''] = 148; + cTable[(byte)''] = 149; + cTable[(byte)''] = 150; + cTable[(byte)''] = 151; + cTable[(byte)''] = 152; + + cTable[(byte)''] = 153; + cTable[(byte)''] = 154; + cTable[(byte)''] = 155; + cTable[(byte)''] = 156; + cTable[(byte)''] = 157; + cTable[(byte)''] = 158; + cTable[(byte)''] = 159; + cTable[(byte)''] = 160; + cTable[(byte)''] = 161; + cTable[(byte)''] = 162; + cTable[(byte)''] = 163; + cTable[(byte)''] = 164; + cTable[(byte)''] = 165; + cTable[(byte)''] = 166; + cTable[(byte)''] = 167; + cTable[(byte)''] = 168; + cTable[(byte)''] = 169; + cTable[(byte)''] = 170; + cTable[(byte)''] = 171; + cTable[(byte)''] = 172; + cTable[(byte)''] = 173; + cTable[(byte)''] = 174; + cTable[(byte)''] = 175; + cTable[(byte)''] = 176; + cTable[(byte)''] = 177; + cTable[(byte)''] = 178; + cTable[(byte)''] = 179; + cTable[(byte)''] = 180; + cTable[(byte)''] = 181; + cTable[(byte)''] = 182; + cTable[(byte)''] = 183; + cTable[(byte)''] = 184; + cTable[(byte)''] = 185; + + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 9; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 9; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 8; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 9; + lTable[(byte)''] = 10; + lTable[(byte)''] = 9; + lTable[(byte)''] = 10; + lTable[(byte)''] = 9; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 9; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 9; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 9; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + + } else if (_vm->getLanguage() == Common::CZ_CZE) { + // Czech + + cTable[(byte)''] = 186; + cTable[(byte)''] = 187; + cTable[(byte)''] = 188; + cTable[(byte)''] = 189; + cTable[(byte)''] = 190; + cTable[(byte)''] = 191; + cTable[(byte)''] = 192; + cTable[(byte)''] = 193; + cTable[(byte)''] = 194; + cTable[(byte)''] = 195; + cTable[(byte)''] = 196; + cTable[(byte)''] = 197; + cTable[(byte)''] = 198; + cTable[(byte)''] = 199; + cTable[(byte)''] = 200; + + cTable[(byte)''] = 201; + cTable[(byte)''] = 202; + cTable[(byte)''] = 203; + cTable[(byte)''] = 204; + cTable[(byte)''] = 205; + cTable[(byte)''] = 206; + cTable[(byte)''] = 207; + cTable[(byte)''] = 208; + cTable[(byte)''] = 209; + cTable[(byte)''] = 210; + cTable[(byte)''] = 211; + cTable[(byte)''] = 212; + cTable[(byte)''] = 213; + cTable[(byte)''] = 214; + cTable[(byte)''] = 215; + + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 9; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 9; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + + lTable[(byte)''] = 10; + lTable[(byte)''] = 9; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 9; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 9; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + + } else if (_vm->getLanguage() == Common::FR_FRA) { + // French + + cTable[(byte)''] = 226; + cTable[(byte)''] = 227; + cTable[(byte)''] = 228; + cTable[(byte)''] = 229; + cTable[(byte)''] = 230; + cTable[(byte)''] = 231; + cTable[(byte)''] = 232; + cTable[(byte)''] = 233; + + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + lTable[(byte)''] = 8; + lTable[(byte)''] = 11; + lTable[(byte)''] = 11; + lTable[(byte)''] = 10; + lTable[(byte)''] = 10; + + } else if (_vm->getLanguage() == Common::DE_DEU) { + // German + + cTable[(byte)''] = 234; + // 'SS' = 235 + cTable[(byte)''] = 236; + cTable[(byte)''] = 237; + cTable[(byte)''] = 238; + + lTable[(byte)''] = 11; + } } /***************************************************************************\ @@ -1608,182 +1602,178 @@ void RMFontObj::Init(void) { SetBothCase('R', 'R', 1); SetBothCase('R', 'U', 3); + if (_vm->getLanguage() == Common::PL_POL) { + // Polish characters + //ス謎戊3剔囀 + //AaCcEeLlNnOoSsZzZz + cTable[(byte)''] = cTable[(byte)''] = 85; + lTable[(byte)''] = lTable[(byte)''] = 20; + + cTable[(byte)''] = cTable[(byte)''] = 86; + lTable[(byte)''] = lTable[(byte)''] = 22; + + cTable[(byte)''] = cTable[(byte)''] = 87; + lTable[(byte)''] = lTable[(byte)''] = 17; + + cTable[(byte)''] = cTable[(byte)''] = 88; + lTable[(byte)''] = lTable[(byte)''] = 19; + + cTable[(byte)''] = cTable[(byte)''] = 89; + lTable[(byte)''] = lTable[(byte)''] = 17; + + cTable[(byte)''] = cTable[(byte)''] = 90; + lTable[(byte)''] = lTable[(byte)''] = 22; - // Polish characters - //ス謎戊3剔囀 - //AaCcEeLlNnOoSsZzZz - cTable[(byte)''] = cTable[(byte)''] = 85; - lTable[(byte)''] = lTable[(byte)''] = 20; - - cTable[(byte)''] = cTable[(byte)''] = 86; - lTable[(byte)''] = lTable[(byte)''] = 22; - - cTable[(byte)''] = cTable[(byte)''] = 87; - lTable[(byte)''] = lTable[(byte)''] = 17; - - cTable[(byte)''] = cTable[(byte)''] = 88; - lTable[(byte)''] = lTable[(byte)''] = 19; - - cTable[(byte)''] = cTable[(byte)''] = 89; - lTable[(byte)''] = lTable[(byte)''] = 17; - - cTable[(byte)''] = cTable[(byte)''] = 90; - lTable[(byte)''] = lTable[(byte)''] = 22; - - cTable[(byte)''] = cTable[(byte)''] = 91; - lTable[(byte)''] = lTable[(byte)''] = 15; - - cTable[(byte)''] = cTable[(byte)''] = 92; - lTable[(byte)''] = lTable[(byte)''] = 21; - - cTable[(byte)''] = cTable[(byte)''] = 93; - lTable[(byte)''] = lTable[(byte)''] = 21; - - -#ifdef FONT_RUSSIAN - // Russian Characters - // WARNING: Il russo usa molti dei caratteri ISO-Latin-1 che servono - // per le altre traduzioni. Per compilare Tony in altre lingue, - // commentare via queste definizioni. - - cTable[(byte)''] = cTable[(byte)''] = 85; - lTable[(byte)''] = lTable[(byte)''] = 20; - - cTable[(byte)''] = cTable[(byte)''] = 94; - cTable[(byte)''] = cTable[(byte)''] = 95; - cTable[(byte)''] = cTable[(byte)''] = 96; - cTable[(byte)''] = cTable[(byte)''] = 97; - cTable[(byte)''] = cTable[(byte)''] = 98; - cTable[(byte)''] = cTable[(byte)''] = 99; - cTable[(byte)''] = cTable[(byte)''] = 100; - cTable[(byte)''] = cTable[(byte)''] = 101; - cTable[(byte)''] = cTable[(byte)''] = 102; - cTable[(byte)''] = cTable[(byte)''] = 103; - cTable[(byte)''] = cTable[(byte)''] = 104; - cTable[(byte)''] = cTable[(byte)''] = 105; - cTable[(byte)''] = cTable[(byte)''] = 106; - cTable[(byte)''] = cTable[(byte)''] = 107; - cTable[(byte)''] = cTable[(byte)''] = 108; - cTable[(byte)''] = cTable[(byte)''] = 109; - cTable[(byte)''] = cTable[(byte)''] = 110; - cTable[(byte)''] = cTable[(byte)''] = 111; - cTable[(byte)''] = cTable[(byte)''] = 112; - cTable[(byte)''] = cTable[(byte)''] = 113; - cTable[(byte)''] = cTable[(byte)''] = 114; - cTable[(byte)''] = cTable[(byte)''] = 115; - cTable[(byte)''] = cTable[(byte)''] = 116; - cTable[(byte)''] = cTable[(byte)''] = 117; - cTable[(byte)''] = cTable[(byte)''] = 118; - cTable[(byte)''] = cTable[(byte)''] = 119; - cTable[(byte)''] = cTable[(byte)''] = 120; - cTable[(byte)''] = cTable[(byte)''] = 121; - cTable[(byte)''] = cTable[(byte)''] = 122; - cTable[(byte)''] = cTable[(byte)''] = 123; - cTable[(byte)''] = cTable[(byte)''] = 124; - cTable[(byte)''] = cTable[(byte)''] = 125; - cTable[(byte)''] = cTable[(byte)''] = 126; - - - lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 17; - lTable[(byte)''] = lTable[(byte)''] = 16; - lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 20; - lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 16; - lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 15; - lTable[(byte)''] = lTable[(byte)''] = 22; - lTable[(byte)''] = lTable[(byte)''] = 15; - lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 22; - lTable[(byte)''] = lTable[(byte)''] = 19; - lTable[(byte)''] = lTable[(byte)''] = 16; - lTable[(byte)''] = lTable[(byte)''] = 21; - lTable[(byte)''] = lTable[(byte)''] = 20; - lTable[(byte)''] = lTable[(byte)''] = 16; - lTable[(byte)''] = lTable[(byte)''] = 16; - lTable[(byte)''] = lTable[(byte)''] = 19; - lTable[(byte)''] = lTable[(byte)''] = 22; - lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 19; - lTable[(byte)''] = lTable[(byte)''] = 19; - lTable[(byte)''] = lTable[(byte)''] = 15; - lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 18; - -#endif // FONT_RUSSIAN - -#ifdef FONT_CZECH - // rep. ceca characters - - cTable[(byte)''] = cTable[(byte)''] = 127; - cTable[(byte)''] = cTable[(byte)''] = 128; - cTable[(byte)''] = cTable[(byte)''] = 129; - cTable[(byte)''] = cTable[(byte)''] = 130; - cTable[(byte)''] = cTable[(byte)''] = 131; - cTable[(byte)''] = cTable[(byte)''] = 132; - cTable[(byte)''] = cTable[(byte)''] = 133; - cTable[(byte)''] = cTable[(byte)''] = 134; - cTable[(byte)''] = cTable[(byte)''] = 135; - cTable[(byte)''] = cTable[(byte)''] = 136; - cTable[(byte)''] = cTable[(byte)''] = 137; - cTable[(byte)''] = cTable[(byte)''] = 138; - cTable[(byte)''] = cTable[(byte)''] = 139; - cTable[(byte)''] = cTable[(byte)''] = 140; - cTable[(byte)''] = cTable[(byte)''] = 141; - - lTable[(byte)''] = lTable[(byte)''] = 17; - lTable[(byte)''] = lTable[(byte)''] = 15; - lTable[(byte)''] = lTable[(byte)''] = 22; - lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 21; - lTable[(byte)''] = lTable[(byte)''] = 16; - lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 19; - lTable[(byte)''] = lTable[(byte)''] = 17; - lTable[(byte)''] = lTable[(byte)''] = 23; - lTable[(byte)''] = lTable[(byte)''] = 24; - lTable[(byte)''] = lTable[(byte)''] = 17; - lTable[(byte)''] = lTable[(byte)''] = 22; - lTable[(byte)''] = lTable[(byte)''] = 16; - lTable[(byte)''] = lTable[(byte)''] = 16; - -#endif // FONT_CZECH - -#ifdef FONT_FRENCH - - // traduci le lettere accentate in lettere normali - - cTable[(byte)''] = cTable[(byte)''] = cTable[(byte)''] = 0; // a - lTable[(byte)''] = lTable[(byte)''] = lTable[(byte)''] = 17; - - cTable[(byte)''] = cTable[(byte)''] = 4; // e - lTable[(byte)''] = lTable[(byte)''] = 15; - - cTable[(byte)''] = cTable[(byte)''] = cTable[(byte)''] = 8; // i - lTable[(byte)''] = lTable[(byte)''] = lTable[(byte)''] = 16; - - cTable[(byte)''] = cTable[(byte)''] = cTable[(byte)''] = cTable[(byte)''] = 14; // o - lTable[(byte)''] = lTable[(byte)''] = lTable[(byte)''] = lTable[(byte)''] = 19; - - cTable[(byte)''] = cTable[(byte)''] = 20; // u - lTable[(byte)''] = lTable[(byte)''] = 15; - -#endif // FONT_FRENCH - -#ifdef FONT_GERMAN - cTable[''] = 142; - // SS = 143 - - lTable[''] = 24; -#endif // FONT_GERMAN + cTable[(byte)''] = cTable[(byte)''] = 91; + lTable[(byte)''] = lTable[(byte)''] = 15; + + cTable[(byte)''] = cTable[(byte)''] = 92; + lTable[(byte)''] = lTable[(byte)''] = 21; + + cTable[(byte)''] = cTable[(byte)''] = 93; + lTable[(byte)''] = lTable[(byte)''] = 21; + + } else if (_vm->getLanguage() == Common::RU_RUS) { + // Russian Characters + // WARNING: Il russo usa molti dei caratteri ISO-Latin-1 che servono + // per le altre traduzioni. Per compilare Tony in altre lingue, + // commentare via queste definizioni. + + cTable[(byte)''] = cTable[(byte)''] = 85; + lTable[(byte)''] = lTable[(byte)''] = 20; + + cTable[(byte)''] = cTable[(byte)''] = 94; + cTable[(byte)''] = cTable[(byte)''] = 95; + cTable[(byte)''] = cTable[(byte)''] = 96; + cTable[(byte)''] = cTable[(byte)''] = 97; + cTable[(byte)''] = cTable[(byte)''] = 98; + cTable[(byte)''] = cTable[(byte)''] = 99; + cTable[(byte)''] = cTable[(byte)''] = 100; + cTable[(byte)''] = cTable[(byte)''] = 101; + cTable[(byte)''] = cTable[(byte)''] = 102; + cTable[(byte)''] = cTable[(byte)''] = 103; + cTable[(byte)''] = cTable[(byte)''] = 104; + cTable[(byte)''] = cTable[(byte)''] = 105; + cTable[(byte)''] = cTable[(byte)''] = 106; + cTable[(byte)''] = cTable[(byte)''] = 107; + cTable[(byte)''] = cTable[(byte)''] = 108; + cTable[(byte)''] = cTable[(byte)''] = 109; + cTable[(byte)''] = cTable[(byte)''] = 110; + cTable[(byte)''] = cTable[(byte)''] = 111; + cTable[(byte)''] = cTable[(byte)''] = 112; + cTable[(byte)''] = cTable[(byte)''] = 113; + cTable[(byte)''] = cTable[(byte)''] = 114; + cTable[(byte)''] = cTable[(byte)''] = 115; + cTable[(byte)''] = cTable[(byte)''] = 116; + cTable[(byte)''] = cTable[(byte)''] = 117; + cTable[(byte)''] = cTable[(byte)''] = 118; + cTable[(byte)''] = cTable[(byte)''] = 119; + cTable[(byte)''] = cTable[(byte)''] = 120; + cTable[(byte)''] = cTable[(byte)''] = 121; + cTable[(byte)''] = cTable[(byte)''] = 122; + cTable[(byte)''] = cTable[(byte)''] = 123; + cTable[(byte)''] = cTable[(byte)''] = 124; + cTable[(byte)''] = cTable[(byte)''] = 125; + cTable[(byte)''] = cTable[(byte)''] = 126; + + + lTable[(byte)''] = lTable[(byte)''] = 18; + lTable[(byte)''] = lTable[(byte)''] = 18; + lTable[(byte)''] = lTable[(byte)''] = 18; + lTable[(byte)''] = lTable[(byte)''] = 17; + lTable[(byte)''] = lTable[(byte)''] = 16; + lTable[(byte)''] = lTable[(byte)''] = 18; + lTable[(byte)''] = lTable[(byte)''] = 18; + lTable[(byte)''] = lTable[(byte)''] = 20; + lTable[(byte)''] = lTable[(byte)''] = 18; + lTable[(byte)''] = lTable[(byte)''] = 18; + lTable[(byte)''] = lTable[(byte)''] = 18; + lTable[(byte)''] = lTable[(byte)''] = 18; + lTable[(byte)''] = lTable[(byte)''] = 16; + lTable[(byte)''] = lTable[(byte)''] = 18; + lTable[(byte)''] = lTable[(byte)''] = 15; + lTable[(byte)''] = lTable[(byte)''] = 22; + lTable[(byte)''] = lTable[(byte)''] = 15; + lTable[(byte)''] = lTable[(byte)''] = 18; + lTable[(byte)''] = lTable[(byte)''] = 22; + lTable[(byte)''] = lTable[(byte)''] = 19; + lTable[(byte)''] = lTable[(byte)''] = 16; + lTable[(byte)''] = lTable[(byte)''] = 21; + lTable[(byte)''] = lTable[(byte)''] = 20; + lTable[(byte)''] = lTable[(byte)''] = 16; + lTable[(byte)''] = lTable[(byte)''] = 16; + lTable[(byte)''] = lTable[(byte)''] = 19; + lTable[(byte)''] = lTable[(byte)''] = 22; + lTable[(byte)''] = lTable[(byte)''] = 18; + lTable[(byte)''] = lTable[(byte)''] = 19; + lTable[(byte)''] = lTable[(byte)''] = 19; + lTable[(byte)''] = lTable[(byte)''] = 15; + lTable[(byte)''] = lTable[(byte)''] = 18; + lTable[(byte)''] = lTable[(byte)''] = 18; + + } else if (_vm->getLanguage() == Common::CZ_CZE) { + // Czech + + cTable[(byte)''] = cTable[(byte)''] = 127; + cTable[(byte)''] = cTable[(byte)''] = 128; + cTable[(byte)''] = cTable[(byte)''] = 129; + cTable[(byte)''] = cTable[(byte)''] = 130; + cTable[(byte)''] = cTable[(byte)''] = 131; + cTable[(byte)''] = cTable[(byte)''] = 132; + cTable[(byte)''] = cTable[(byte)''] = 133; + cTable[(byte)''] = cTable[(byte)''] = 134; + cTable[(byte)''] = cTable[(byte)''] = 135; + cTable[(byte)''] = cTable[(byte)''] = 136; + cTable[(byte)''] = cTable[(byte)''] = 137; + cTable[(byte)''] = cTable[(byte)''] = 138; + cTable[(byte)''] = cTable[(byte)''] = 139; + cTable[(byte)''] = cTable[(byte)''] = 140; + cTable[(byte)''] = cTable[(byte)''] = 141; + + lTable[(byte)''] = lTable[(byte)''] = 17; + lTable[(byte)''] = lTable[(byte)''] = 15; + lTable[(byte)''] = lTable[(byte)''] = 22; + lTable[(byte)''] = lTable[(byte)''] = 18; + lTable[(byte)''] = lTable[(byte)''] = 21; + lTable[(byte)''] = lTable[(byte)''] = 16; + lTable[(byte)''] = lTable[(byte)''] = 18; + lTable[(byte)''] = lTable[(byte)''] = 19; + lTable[(byte)''] = lTable[(byte)''] = 17; + lTable[(byte)''] = lTable[(byte)''] = 23; + lTable[(byte)''] = lTable[(byte)''] = 24; + lTable[(byte)''] = lTable[(byte)''] = 17; + lTable[(byte)''] = lTable[(byte)''] = 22; + lTable[(byte)''] = lTable[(byte)''] = 16; + lTable[(byte)''] = lTable[(byte)''] = 16; + + } else if (_vm->getLanguage() == Common::FR_FRA) { + // French + + // traduci le lettere accentate in lettere normali + + cTable[(byte)''] = cTable[(byte)''] = cTable[(byte)''] = 0; // a + lTable[(byte)''] = lTable[(byte)''] = lTable[(byte)''] = 17; + + cTable[(byte)''] = cTable[(byte)''] = 4; // e + lTable[(byte)''] = lTable[(byte)''] = 15; + + cTable[(byte)''] = cTable[(byte)''] = cTable[(byte)''] = 8; // i + lTable[(byte)''] = lTable[(byte)''] = lTable[(byte)''] = 16; + + cTable[(byte)''] = cTable[(byte)''] = cTable[(byte)''] = cTable[(byte)''] = 14; // o + lTable[(byte)''] = lTable[(byte)''] = lTable[(byte)''] = lTable[(byte)''] = 19; + + cTable[(byte)''] = cTable[(byte)''] = 20; // u + lTable[(byte)''] = lTable[(byte)''] = 15; + + } else if (_vm->getLanguage() == Common::DE_DEU) { + // German + + cTable[''] = 142; + // SS = 143 + + lTable[''] = 24; + } } -- cgit v1.2.3 From 333c30b8c7f6781605f517f2a7150f78a77556fc Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 20 May 2012 11:37:33 +1000 Subject: TONY: Removed unused drive & folder defines and code --- engines/tony/adv.h | 8 ------- engines/tony/globals.h | 3 +++ engines/tony/window.cpp | 61 ------------------------------------------------- engines/tony/window.h | 10 +------- 4 files changed, 4 insertions(+), 78 deletions(-) (limited to 'engines') diff --git a/engines/tony/adv.h b/engines/tony/adv.h index 90a9c245b5..93359688f6 100644 --- a/engines/tony/adv.h +++ b/engines/tony/adv.h @@ -48,14 +48,6 @@ namespace Tony { #define RM_SKIPY ((RM_BBY - RM_SY) / 2) #define RM_SKIPX 0 -// Name lengths -// FIXME: Some of these can likely be removed when refactoring is completed -#define MAX_DRIVE 10 -#define MAX_DIR 255 -#define MAX_PATH 255 -#define MAX_FNAME 100 -#define MAX_EXT 10 - // Tony's actions enum RMTonyAction { TA_GOTO = 0, diff --git a/engines/tony/globals.h b/engines/tony/globals.h index 1c2835cf40..9115b22ccc 100644 --- a/engines/tony/globals.h +++ b/engines/tony/globals.h @@ -44,6 +44,9 @@ namespace Tony { #define T_MAREMETA 7 +#define MAX_PATH 255 + + struct CharacterStruct { uint32 code; RMItem *item; diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index 58d0bba2ba..26dbaf88fc 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -195,69 +195,8 @@ void RMWindow::plotLines(const byte *lpBuf, const Common::Point ¢er, int x, * RMSnapshot Methods \****************************************************************************/ -char RMSnapshot::bufDrive[MAX_DRIVE]; -char RMSnapshot::bufDir[MAX_DIR]; -char RMSnapshot::bufName[MAX_FNAME]; -char RMSnapshot::bufExt[MAX_EXT]; -char RMSnapshot::filename[512]; byte RMSnapshot::rgb[RM_SX * RM_SY * 3]; -bool RMSnapshot::GetFreeSnapName(char *fn) { -#ifdef REFACTOR_ME - int i, j, k; - uint32 h; - - theGame.GetDataDirectory(RMGame::DD_SHOTS, fn); - _splitpath(fn, bufDrive, bufDir, NULL, NULL); - - for (i = 1; i < 10; i++) { - wsprintf(bufName, "rm%d00", i); - _makepath(fn, bufDrive, bufDir, bufName, ".bmp"); - h = CreateFile(fn, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if (h == CORO_INVALID_PID_VALUE) - break; - CloseHandle(h); - } - - i--; - - for (j = 1; j < 10; j++) { - wsprintf(bufName, "rm%d%d0", i, j); - _makepath(fn, bufDrive, bufDir, bufName, ".bmp"); - h = CreateFile(fn, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if (h == CORO_INVALID_PID_VALUE) - break; - CloseHandle(h); - } - - j--; - - for (k = 0; k < 10; k++) { - wsprintf(bufName, "rm%d%d%d", i, j, k); - _makepath(fn, bufDrive, bufDir, bufName, ".bmp"); - h = CreateFile(fn, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if (h == CORO_INVALID_PID_VALUE) - break; - CloseHandle(h); - } - - if (k == 10) { - k = 0; - j++; - if (j == 10) { - j = 0; - i++; - if (i == 10) - return false; - } - - wsprintf(bufName, "rm%d%d%d", i, j, k); - _makepath(fn, bufDrive, bufDir, bufName, ".bmp"); - } -#endif - return true; -} - void RMSnapshot::GrabScreenshot(byte *lpBuf, int dezoom, uint16 *lpDestBuf) { uint16 *src = (uint16 *)lpBuf; diff --git a/engines/tony/window.h b/engines/tony/window.h index ea26df3920..9483f693ab 100644 --- a/engines/tony/window.h +++ b/engines/tony/window.h @@ -41,16 +41,8 @@ struct DDSURFACEDESC { class RMSnapshot { private: - // Buffer used to create a path - static char bufDrive[MAX_DRIVE], bufDir[MAX_DIR], bufName[MAX_FNAME], bufExt[MAX_EXT]; - static char filename[512]; - - // Buffer used to convert a RGB + // Buffer used to convert to RGB static byte rgb[RM_SX * RM_SY * 3]; - -private: - bool GetFreeSnapName(char *fn); - public: // Take a screenshot void GrabScreenshot(byte *lpBuf, int dezoom = 1, uint16 *lpDestBuf = NULL); -- cgit v1.2.3 From 0450275c44c8c001d56cf37c78db6951ecaa4314 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 20 May 2012 13:54:59 +1000 Subject: TONY: Converting Italian comments to English and formatting --- engines/tony/loc.cpp | 612 ++++++++++++++++++++-------------------------- engines/tony/loc.h | 119 +++++---- engines/tony/tony.cpp | 12 +- engines/tony/tony.h | 12 +- engines/tony/tonychar.cpp | 56 ++--- engines/tony/tonychar.h | 69 +++--- engines/tony/utils.cpp | 36 +-- engines/tony/utils.h | 20 +- engines/tony/window.cpp | 6 +- engines/tony/window.h | 10 +- 10 files changed, 433 insertions(+), 519 deletions(-) (limited to 'engines') diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index b88fc68fc5..722116c47c 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -38,47 +38,34 @@ using namespace ::Tony::MPAL; /****************************************************************************\ -* Metodi di RMPalette -\****************************************************************************/ - -/****************************************************************************\ -* -* Function: friend RMDataStream &operator>>(RMDataStream &ds, -* RMPalette& pal); -* -* Description: Operatore di estrazione di palette da data stream -* -* Input: RMDataStream &ds Data stream -* RMPalette& pal Palette di destinazione -* -* Return: Reference allo stream -* +* RMPalette Methods \****************************************************************************/ +/** + * Operator for reading palette information from a data stream. + * + * @param ds Data stream + * @param pal Destination palette + * + * @returns Reference to the data stream + */ RMDataStream &operator>>(RMDataStream &ds, RMPalette &pal) { ds.Read(pal.m_data,1024); return ds; } /****************************************************************************\ -* Metodi di RMSlot -\****************************************************************************/ - -/****************************************************************************\ -* -* Function: friend RMDataStream &operator>>(RMDataStream &ds, -* RMSlot& slot) -* -* Description: Operatore per estrarre uno slot di un pattern da un data -* stream -* -* Input: RMDataStream &ds Data stream -* RMSlot& slot Slot di destinazione -* -* Return: Reference allo stream -* +* RMSlot Methods \****************************************************************************/ +/** + * Operator for reading slot information from a data stream. + * + * @param ds Data stream + * @param slot Destination slot + * + * @returns Reference to the data stream + */ RMDataStream &operator>>(RMDataStream &ds, RMPattern::RMSlot &slot) { slot.ReadFromStream(ds); return ds; @@ -107,20 +94,14 @@ void RMPattern::RMSlot::ReadFromStream(RMDataStream &ds, bool bLOX) { * Metodi di RMPattern \****************************************************************************/ -/****************************************************************************\ -* -* Function: friend RMDataStream &operator>>(RMDataStream &ds, -* RMPattern& pat) -* -* Description: Operatore per estrarre un pattern da un data stream -* -* Input: RMDataStream &ds Data stream -* RMPattern& pat Pattern di destinazione -* -* Return: Reference allo stream -* -\****************************************************************************/ - +/** + * Operator for reading pattern information from a data stream + * + * @param ds Data stream + * @param pat Destination pattern + * + * @returns Reference to the data stream + */ RMDataStream &operator>>(RMDataStream &ds, RMPattern &pat) { pat.ReadFromStream(ds); return ds; @@ -129,23 +110,23 @@ RMDataStream &operator>>(RMDataStream &ds, RMPattern &pat) { void RMPattern::ReadFromStream(RMDataStream &ds, bool bLOX) { int i; - // Nome del pattern + // Pattern name if (!bLOX) ds >> m_name; - // Velocita' + // Velocity ds >> m_speed; - // Posizione + // Position ds >> m_pos; - // Flag di loop del pattern + // Flag for pattern looping ds >> m_bLoop; - // Numero di slot + // Number of slots ds >> m_nSlots; - // Creazione e lettura degli slot + // Create and read the slots m_slots = new RMSlot[m_nSlots]; for (i = 0; i < m_nSlots && !ds.IsError(); i++) { @@ -174,11 +155,11 @@ void RMPattern::StopSfx(RMSfx *sfx) { int RMPattern::Init(RMSfx *sfx, bool bPlayP0, byte *bFlag) { int i; - // Prendiamo il tempo corrente + // Read the current time m_nStartTime = _vm->GetTime(); m_nCurSlot = 0; - // Cerca il primo frame nel pattern + // Find the first frame of the pattern i = 0; while (m_slots[i].m_type != SPRITE) { assert(i + 1 < m_nSlots); @@ -190,13 +171,13 @@ int RMPattern::Init(RMSfx *sfx, bool bPlayP0, byte *bFlag) { if (bFlag) *bFlag = m_slots[i].m_flag; - // Calcola le coordinate correnti + // Calculate the current coordinates UpdateCoord(); - // Controlla per il sonoro: - // Se sta alla slot 0, lo playa - // Se speed = 0, deve suonare solo se va in loop '_', oppure se specificato dal parametro - // Se speed! = 0, suona solo quelli in loop + // Check for sound: + // If the slot is 0, play + // If speed = 0, must playing unless it goes into loop '_', or if specified by the parameter + // If speed != 0, play only the loop for (i = 0;i < m_nSlots; i++) { if (m_slots[i].m_type == SOUND) { if (i == 0) { @@ -230,14 +211,14 @@ int RMPattern::Init(RMSfx *sfx, bool bPlayP0, byte *bFlag) { int RMPattern::Update(uint32 hEndPattern, byte &bFlag, RMSfx *sfx) { int CurTime = _vm->GetTime(); - // Se la speed e' 0, il pattern non avanza mai + // If the speed is 0, then the pattern never advances if (m_speed == 0) { CoroScheduler.pulseEvent(hEndPattern); bFlag=m_slots[m_nCurSlot].m_flag; return m_nCurSprite; } - // E' arrivato il momento di cambiare slot? + // Is it time to change the slots? while (m_nStartTime + m_speed <= (uint32)CurTime) { m_nStartTime += m_speed; if (m_slots[m_nCurSlot].m_type == SPRITE) @@ -248,8 +229,8 @@ int RMPattern::Update(uint32 hEndPattern, byte &bFlag, RMSfx *sfx) { CoroScheduler.pulseEvent(hEndPattern); - // @@@ Se non c'e' loop avverte che il pattern e' finito - // Se non c'e' loop rimane sull'ultimo frame + // @@@ If there is no loop pattern, and there's a warning that it's the final + // frame, then remain on the last frame if (!m_bLoop) { m_nCurSlot = m_nSlots - 1; bFlag = m_slots[m_nCurSlot].m_flag; @@ -260,10 +241,10 @@ int RMPattern::Update(uint32 hEndPattern, byte &bFlag, RMSfx *sfx) { for (;;) { switch (m_slots[m_nCurSlot].m_type) { case SPRITE: - // Legge il prossimo sprite + // Read the next sprite m_nCurSprite = m_slots[m_nCurSlot].m_data; - // Aggiorna le coordinate babbo+figlio + // Update the parent & child coordinates UpdateCoord(); break; @@ -293,7 +274,7 @@ int RMPattern::Update(uint32 hEndPattern, byte &bFlag, RMSfx *sfx) { } } - // Ritorna lo sprite corrente + // Return the current sprite bFlag=m_slots[m_nCurSlot].m_flag; return m_nCurSprite; } @@ -320,23 +301,17 @@ RMPattern::~RMPattern() { /****************************************************************************\ -* Metodi di RMSprite -\****************************************************************************/ - -/****************************************************************************\ -* -* Function: friend RMDataStream &operator>>(RMDataStream &ds, -* RMSprite& sprite) -* -* Description: Operatore per estrarre uno sprite da un data stream -* -* Input: RMDataStream &ds Data stream -* RMItem &item Sprite di destinazione -* -* Return: Reference allo stream -* +* RMSprite Methods \****************************************************************************/ +/** + * Operator for reading sprite information from a data stream. + * + * @param ds Data stream + * @param sprite Destination slot + * + * @returns Reference to the data stream + */ RMDataStream &operator>>(RMDataStream &ds, RMSprite &sprite) { sprite.ReadFromStream(ds); return ds; @@ -366,22 +341,22 @@ void RMSprite::GetSizeFromStream(RMDataStream &ds, int *dimx, int *dimy) { void RMSprite::ReadFromStream(RMDataStream &ds, bool bLOX) { int dimx,dimy; - // Nome dello sprite + // Sprite name if (!bLOX) ds >> m_name; - // Dimensioni + // Dimensions ds >> dimx >> dimy; - // Bouding box + // Bounding box ds >> m_rcBox; - // Spazio inutilizzato + // Unused space if (!bLOX) - ds+=32; + ds += 32; - // Crezione del buffer e lettura - m_buf->Init(ds, dimx,dimy); + // Create buffer and read + m_buf->Init(ds, dimx, dimy); } void RMSprite::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { @@ -405,23 +380,17 @@ RMSprite::~RMSprite() { /****************************************************************************\ -* Metodi di RMSfx -\****************************************************************************/ - -/****************************************************************************\ -* -* Function: friend RMDataStream &operator>>(RMDataStream &ds, -* RMSfx &sfx) -* -* Description: Operatore per estrarre uno sfx da un data stream -* -* Input: RMDataStream &ds Data stream -* RMSfx &sfx Sfx di destinazione -* -* Return: Reference allo stream -* +* RMSfx Methods \****************************************************************************/ +/** + * Operator for reading SFX information from a data stream. + * + * @param ds Data stream + * @param sfx Destination SFX + * + * @returns Reference to the data stream + */ RMDataStream &operator>>(RMDataStream &ds, RMSfx &sfx) { sfx.ReadFromStream(ds); return ds; @@ -432,29 +401,29 @@ void RMSfx::ReadFromStream(RMDataStream &ds, bool bLOX) { int size; byte *raw; - // Nome dello sfx + // sfx name ds >> m_name; ds >> size; - // Carica l'effetto sonoro dal buffer - ds.Read(id,4); + // Upload the sound effect identifier from the buffer + ds.Read(id, 4); - // Controlla che sia un riff + // Ensure it's a RIFF assert(id[0] == 'R' && id[1] == 'I' && id[2] == 'F' && id[3] == 'F'); - // Legge la dimensione + // Read the size ds >> size; - // Carica il wav + // Read the raw WAV data raw = new byte[size]; ds.Read(raw, size); - // Crea l'effetto sonoro + // Create the sound effect m_fx = _vm->CreateSFX(raw); m_fx->SetLoop(false); - // Cancella il buffer che non serve pi a nessuno + // Close the read buffer which is no longer needed delete[] raw; } @@ -476,7 +445,7 @@ void RMSfx::Play(bool bLoop) { m_fx->Play(); if (bLoop) - m_bPlayingLoop=true; + m_bPlayingLoop = true; } } @@ -502,23 +471,17 @@ void RMSfx::Stop(void) { /****************************************************************************\ -* Metodi di RMItem -\****************************************************************************/ - -/****************************************************************************\ -* -* Function: friend RMDataStream &operator>>(RMDataStream &ds, -* RMItem &item) -* -* Description: Operatore per estrarre un item da un data stream -* -* Input: RMDataStream &ds Data stream -* RMItem &item Item di destinazione -* -* Return: Reference allo stream -* +* RMItem Methods \****************************************************************************/ +/** + * Operator for reading item information from a data stream. + * + * @param ds Data stream + * @param tem Destination item + * + * @returns Reference to the data stream + */ RMDataStream &operator>>(RMDataStream &ds, RMItem &item) { item.ReadFromStream(ds); return ds; @@ -561,13 +524,12 @@ bool RMItem::IsIn(const RMPoint &pt, int *size) { if (!m_bIsActive) return false; - // Cerca il rettangolo giusto da usare, che quello dello sprite se ce l'ha, altrimenti - // quello generico dell'oggeto + // Search for the right bounding box to use - use the sprite's if it has one, otherwise use the generic one if (m_nCurPattern != 0 && !m_sprites[m_nCurSprite].m_rcBox.IsEmpty()) rc=m_sprites[m_nCurSprite].m_rcBox + CalculatePos(); else if (!m_rcBox.IsEmpty()) rc = m_rcBox; - // Se non ha box, esce subito + // If no box, return immediately else return false; @@ -582,16 +544,16 @@ void RMItem::ReadFromStream(RMDataStream &ds, bool bLOX) { int i, dimx, dimy; byte cm; - // Codice mpal + // MPAL code ds >> m_mpalCode; - // Nome dell'oggetto + // Object name ds >> m_name; // Z (signed) ds >> m_z; - // Posizione nonno + // Parent position ds >> m_pos; // Hotspot @@ -600,22 +562,22 @@ void RMItem::ReadFromStream(RMDataStream &ds, bool bLOX) { // Bounding box ds >> m_rcBox; - // Numero sprite, effetti sonori e pattern + // Number of sprites, sound effects, and patterns ds >> m_nSprites >> m_nSfx >> m_nPatterns; // Color mode ds >> cm; m_cm=(RMColorMode)cm; - // Flag di presenza della palette differnziata + // Flag for the presence of custom palette differences ds >> m_bPal; if (m_cm == CM_256) { - // Se c'e' la palette, leggiamola + // If there is a palette, read it in if (m_bPal) ds >> m_pal; } - // Dati MPAL + // MPAL data if (!bLOX) ds += 20; @@ -625,17 +587,17 @@ void RMItem::ReadFromStream(RMDataStream &ds, bool bLOX) { if (!bLOX) ds += 106; - // Creazione delle classi + // Create sub-classes if (m_nSprites > 0) m_sprites = new RMSprite[m_nSprites]; if (m_nSfx > 0) m_sfx = new RMSfx[m_nSfx]; m_patterns = new RMPattern[m_nPatterns+1]; - // Lettura delle classi + // Read in class data if (!ds.IsError()) for (i = 0; i < m_nSprites && !ds.IsError(); i++) { - // Carica lo sprite + // Download the sprites if (bLOX) { m_sprites[i].LOXGetSizeFromStream(ds, &dimx, &dimy); m_sprites[i].Init(NewItemSpriteBuffer(dimx, dimy, true)); @@ -658,7 +620,7 @@ void RMItem::ReadFromStream(RMDataStream &ds, bool bLOX) { m_sfx[i].ReadFromStream(ds, false); } - // Leggiamo i pattern a partire dal pattern 1 + // Read the pattern from pattern 1 if (!ds.IsError()) for (i = 1;i <= m_nPatterns && !ds.IsError(); i++) { if (bLOX) @@ -667,12 +629,12 @@ void RMItem::ReadFromStream(RMDataStream &ds, bool bLOX) { m_patterns[i].ReadFromStream(ds, false); } - // Inizializza il curpattern + // Initialise the current pattern if (m_bInitCurPattern) SetPattern(mpalQueryItemPattern(m_mpalCode)); - // Inizializza lo stato di attivazione - m_bIsActive=mpalQueryItemIsActive(m_mpalCode); + // Initailise the current activation state + m_bIsActive = mpalQueryItemIsActive(m_mpalCode); } @@ -687,11 +649,11 @@ void RMItem::SetScrollPosition(const RMPoint &scroll) { bool RMItem::DoFrame(RMGfxTargetBuffer *bigBuf, bool bAddToList) { int oldSprite = m_nCurSprite; - // Pattern 0 = Non disegnare nulla! + // Pattern 0 = Do not draw anything! if (m_nCurPattern == 0) return false; - // Facciamo un update del pattern, che ci ritorna anche il frame corrente + // We do an update of the pattern, which also returns the current frame if (m_nCurPattern != 0) { m_nCurSprite = m_patterns[m_nCurPattern].Update(m_hEndPattern, m_bCurFlag, m_sfx); @@ -704,14 +666,14 @@ bool RMItem::DoFrame(RMGfxTargetBuffer *bigBuf, bool bAddToList) { m_nCurSprite = -1; } - // Se la funzione ha ritornato -1, vuol dire che il pattern e' finito + // If the function returned -1, it means that the pattern has finished if (m_nCurSprite == -1) { - // Mettiamo il pattern 0, e usciamo. La classe si auto-deregistrera' della OT list + // We have pattern 0, so leave. The class will self de-register from the OT list m_nCurPattern = 0; return false; } - // Se non siamo in OT list, mettiamoci + // If we are not in the OT list, add ourselves if (!m_nInList && bAddToList) bigBuf->AddPrim(NewItemPrimitive()); @@ -728,24 +690,24 @@ void RMItem::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CODE(_ctx); - // Se CurSprite == -1, allora e' finito il pattern + // If CurSprite == -1, then the pattern is finished if (m_nCurSprite == -1) return; - // Settiamo la flag + // Set the flag prim->SetFlag(m_bCurFlag); - // Offset inverso per lo scrolling + // Offset direction for scrolling prim->Dst().Offset(-m_curScroll); - // Dobbiamo sparaflashare le coordinate dell'item dentro la primitiva. - // Si calcola nonno+(babbo+figlio) + // We must offset the cordinates of the item inside the primitive + // It is estimated as nonno + (babbo + figlio) prim->Dst().Offset(CalculatePos()); // No stretching, please prim->SetStrecth(false); - // Ora la passiamo alla routine di drawing generica per surface + // Now we turn to the generic surface drawing routines CORO_INVOKE_2(m_sprites[m_nCurSprite].Draw, bigBuf, prim); CORO_END_CODE; @@ -753,7 +715,7 @@ void RMItem::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { void RMItem::RemoveThis(CORO_PARAM, bool &result) { - // Rimuove dalla OT list se il frame corrente e' -1 (pattern finito) + // Remove from the OT list if the current frame is -1 (pattern over) result = (m_nCurSprite == -1); } @@ -771,16 +733,16 @@ void RMItem::SetPattern(int nPattern, bool bPlayP0) { if (m_nCurPattern>0) m_patterns[m_nCurPattern].StopSfx(m_sfx); - // Si ricorda il pattern corrente + // Remember the current pattern m_nCurPattern = nPattern; - // Inizia il pattern per cominciare l'animazione + // Start the pattern to start the animation if (m_nCurPattern != 0) m_nCurSprite = m_patterns[m_nCurPattern].Init(m_sfx, bPlayP0, &m_bCurFlag); else { m_nCurSprite = -1; - // Cerca l'effetto sonoro per il pattern 0 + // Look for the sound effect for pattern 0 if (bPlayP0) for (i = 0;i < m_nSfx; i++) if (strcmp(m_sfx[i].m_name, "p0") == 0) @@ -789,8 +751,7 @@ void RMItem::SetPattern(int nPattern, bool bPlayP0) { } -bool RMItem::GetName(RMString &name) -{ +bool RMItem::GetName(RMString &name) { char buf[256]; mpalQueryItemName(m_mpalCode, buf); @@ -885,7 +846,7 @@ void RMItem::PauseSound(bool bPause) { /****************************************************************************\ -* Metodi di RMWipe +* RMWipe Methods \****************************************************************************/ @@ -931,13 +892,13 @@ void RMWipe::WaitForFadeEnd(CORO_PARAM) { } void RMWipe::CloseFade(void) { -// m_bUnregister=true; +// m_bUnregister = true; // WaitForSingleObject(m_hUnregistered,CORO_INFINITE); m_wip0r.Unload(); } void RMWipe::InitFade(int type) { - // Attiva il fade + // Activate the fade m_bUnregister = false; m_bEndFade = false; @@ -993,19 +954,19 @@ void RMWipe::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { /****************************************************************************\ -* Metodi di RMCharacter +* RMCharacter Methods \****************************************************************************/ -/***************************************************************************/ -/* Cerca il percorso minimo tra due nodi del grafo di connessione dei BOX */ -/* Restituisce il percorso lungo pathlenght nel vettore path[] */ -/***************************************************************************/ +/****************************************************************************/ +/* Find the shortest path between two nodes of the graph connecting the BOX */ +/* Returns path along the vector path path[] */ +/****************************************************************************/ short RMCharacter::FindPath(short source, short destination) { - static RMBox BOX[MAXBOXES]; // Matrice di Adjacenza - static short COSTO[MAXBOXES]; // Costi per Nodo - static short VALIDO[MAXBOXES]; // 0:non valido 1:valido 2:saturo - static short NEXT[MAXBOXES]; // Prossimo Nodo + static RMBox BOX[MAXBOXES]; // Matrix of adjacent boxes + static short COSTO[MAXBOXES]; // Cost per node + static short VALIDO[MAXBOXES]; // 0:Invalid 1:Valid 2:Saturated + static short NEXT[MAXBOXES]; // Prossimo Nodo short i, j, k, costominimo, fine, errore = 0; RMBoxLoc *cur; @@ -1016,37 +977,37 @@ short RMCharacter::FindPath(short source, short destination) { return 0; } - // Si fa dare i box + // Get the boxes cur = theBoxes->GetBoxes(curLocation); - // Effettua una copia di riserva per lavorarci + // Make a backup copy to work on for (i = 0; i < cur->numbbox; i++) memcpy(&BOX[i], &cur->boxes[i], sizeof(RMBox)); - // Invalida tutti i Nodi + // Invalidate all nodes for (i = 0; i < cur->numbbox; i++) VALIDO[i] = 0; - // Prepara sorgente e variabili globali alla procedura + // Prepare source and variables for the procedure COSTO[source] = 0; VALIDO[source] = 1; fine = 0; - // Ricerca del percorso minimo + // Find the shortest path while(!fine) { - costominimo = 32000; // risetta il costo minimo - errore = 1; // errore possibile + costominimo = 32000; // Reset the minimum cost + errore = 1; // Possible error - // 1 ciclo : ricerca di possibili nuovi nodi + // 1st cycle: explore possible new nodes for (i = 0; i < cur->numbbox; i++) if (VALIDO[i] == 1) { - errore = 0; // errore sfatato + errore = 0; // Failure de-bunked j = 0; while (((BOX[i].adj[j]) != 1) && (j < cur->numbbox)) j++; if (j >= cur->numbbox) - VALIDO[i] = 2; // nodo saturo? + VALIDO[i] = 2; // nodo saturated? else { NEXT[i] = j; if (COSTO[i] + 1 < costominimo) @@ -1055,9 +1016,9 @@ short RMCharacter::FindPath(short source, short destination) { } if (errore) - fine = 1; // tutti i nodi saturi + fine = 1; // All nodes saturated - // 2 ciclo : aggiunta nuovi nodi trovati , saturazione nodi vecchi + // 2nd cycle: adding new nodes that were found, saturate old nodes for (i = 0; i < cur->numbbox; i++) if ((VALIDO[i] == 1) && ((COSTO[i] + 1) == costominimo)) { BOX[i].adj[NEXT[i]] = 2; @@ -1072,7 +1033,7 @@ short RMCharacter::FindPath(short source, short destination) { } } - // Estrazione del percorso dalla matrice di adiacenza modificata + // Remove the path from the adjacent modified matrixes if (!errore) { pathlenght = COSTO[destination]; k = pathlenght; @@ -1133,7 +1094,7 @@ void RMCharacter::GoTo(CORO_PARAM, RMPoint destcoord, bool bReversed) { walkspeed = -walkspeed; walkstatus = 1; - // Cambia il proprio pattern per la nuova direzione + // Change the pattern for the new direction bNeedToStop = true; if ((walkspeed < 0 && !bReversed) || (walkspeed >= 0 && bReversed)) { if (nPatt != PAT_WALKLEFT) @@ -1148,7 +1109,7 @@ void RMCharacter::GoTo(CORO_PARAM, RMPoint destcoord, bool bReversed) { walkspeed = -walkspeed; walkstatus = 0; - bNeedToStop=true; + bNeedToStop = true; if ((walkspeed < 0 && !bReversed) || (walkspeed >= 0 && bReversed)) { if (nPatt != PAT_WALKUP) SetPattern(PAT_WALKUP); @@ -1237,7 +1198,7 @@ RMPoint RMCharacter::NearestPoint(const RMPoint &punto) { if ((difx<0) && (dify>0)) tofind=Searching(0,1,0,1,punto); if ((difx<0) && (dify<0)) tofind=Searching(1,0,0,1,punto); - // potrebbero essere tolti? Pensaci @@@@ + // Could be removed? Think @@@@ if ((difx= = 0) && (dify>0)) tofind=Searching(0,1,1,1,punto); if ((difx= = 0) && (dify<0)) tofind=Searching(1,0,1,1,punto); if ((dify= = 0) && (difx>0)) tofind=Searching(1,1,1,0,punto); @@ -1259,8 +1220,8 @@ short RMCharacter::ScanLine(const RMPoint &punto) { Lstart = m_pos; Lend = punto; - Ldx = Lstart.x-Lend.x; - Ldy = Lstart.y-Lend.y; + Ldx = Lstart.x - Lend.x; + Ldy = Lstart.y - Lend.y; Lfx = Ldx; Lfy = Ldy; Ldx = ABS(Ldx); @@ -1278,7 +1239,7 @@ short RMCharacter::ScanLine(const RMPoint &punto) { Lstatus = 0; } - Lscan = Lstart; // Inizio scansione + Lscan = Lstart; // Start scanning while (InWhichBox(Lscan) != -1) { Lcount++; if (Lstatus) { @@ -1298,7 +1259,9 @@ short RMCharacter::ScanLine(const RMPoint &punto) { return 0; } -// Calcola intersezioni tra la traiettoria rettilinea ed il pi vicino BBOX +/** + * Calculates intersections between the straight line and the closest BBOX + */ RMPoint RMCharacter::InvScanLine(const RMPoint &punto) { int Ldx, Ldy, Lcount; float Lfx, Lfy, Lslope; @@ -1351,9 +1314,9 @@ RMPoint RMCharacter::InvScanLine(const RMPoint &punto) { } -/***************************************************************************/ -/* Ritorna la coordinata dell'HotSpot di uscita pi vicino al giocatore */ -/***************************************************************************/ +/** + * Returns the HotSpot coordinate closest to the player + */ RMPoint RMCharacter::NearestHotSpot(int sourcebox, int destbox) { RMPoint puntocaldo; @@ -1396,21 +1359,21 @@ void RMCharacter::NewBoxEntered(int nBox) { RMBoxLoc *cur; bool bOldReverse; - // Richiama la On ExitBox + // Recall on ExitBox mpalQueryDoAction(3, curLocation, curbox); cur = theBoxes->GetBoxes(curLocation); bOldReverse = cur->boxes[curbox].bReversed; curbox = nBox; - // Se cambiata la Z, dobbiamo rimuoverlo dalla OT + // If Z is changed, we must remove it from the OT if (cur->boxes[curbox].Zvalue != m_z) { bRemoveFromOT = true; m_z = cur->boxes[curbox].Zvalue; } - // Gestisce l'inversione del movimento SOLO se non siamo nel percorso minimo: se siamo in percorso - // minimo direttamente la DoFrame a farlo + // Movement management is reversed, only if we are not in the shortest path. If we are in the shortest + // path, directly do the DoFrame if (bMovingWithoutMinpath) { if ((cur->boxes[curbox].bReversed && !bOldReverse) || (!cur->boxes[curbox].bReversed && bOldReverse)) { switch (GetCurPattern()) { @@ -1430,7 +1393,7 @@ void RMCharacter::NewBoxEntered(int nBox) { } } - // Richiama la On EnterBox + // Recall On EnterBox mpalQueryDoAction(2, curLocation, curbox); } @@ -1448,16 +1411,16 @@ void RMCharacter::DoFrame(CORO_PARAM, RMGfxTargetBuffer* bigBuf, int loc) { g_system->lockMutex(csMove); - // Se stiamo camminando... + // If we're walking.. if (status != STAND) { - // Se stiamo andando in orizzontale + // If we are going horizontally if (walkstatus == 1) { dx = walkspeed * walkcount; dy = slope * dx; m_pos.x = linestart.x + dx; m_pos.y = linestart.y + dy; - // Destra + // Right if (((walkspeed > 0) && (m_pos.x > lineend.x)) || ((walkspeed < 0) && (m_pos.x < lineend.x))) { m_pos = lineend; status = STAND; @@ -1465,14 +1428,14 @@ void RMCharacter::DoFrame(CORO_PARAM, RMGfxTargetBuffer* bigBuf, int loc) { } } - // Se stiamo andando in verticale + // If we are going vertical if (walkstatus == 0) { dy = walkspeed * walkcount; dx = slope * dy; m_pos.x = linestart.x + dx; m_pos.y = linestart.y + dy; - // Basso + // Down if (((walkspeed > 0) && (m_pos.y > lineend.y)) || ((walkspeed < 0) && (m_pos.y < lineend.y))) { m_pos = lineend; status = STAND; @@ -1480,15 +1443,13 @@ void RMCharacter::DoFrame(CORO_PARAM, RMGfxTargetBuffer* bigBuf, int loc) { } } - // Controlla se il personaggio uscito dai BOX per errore, nel qual caso - // lo fa rientrare subito + // Check if the character came out of the BOX in error, in which case he returns immediately if (InWhichBox(m_pos) == -1) { m_pos.x = linestart.x + olddx; m_pos.y = linestart.y + olddy; } - // Se siamo appena arrivati alla destinazione temporanea ed finito il percorso minimo, - // ci fermiamo definitivamente + // If we have just moved to a temporary location, and is over the shortest path, we stop permanently if (_ctx->bEndNow && minpath == 0) { if (!bEndOfPath) CORO_INVOKE_0(Stop); @@ -1498,35 +1459,35 @@ void RMCharacter::DoFrame(CORO_PARAM, RMGfxTargetBuffer* bigBuf, int loc) { walkcount++; - // Aggiorna la Z del personaggio @@@ bisognerebbe rimuoverlo solo se cambiata la Z + // Update the character Z. @@@ Should remove only if the Z was changed - // Controlla se abbiamo cambiato box + // Check if the box was changed if (!theBoxes->IsInBox(curLocation, curbox, m_pos)) NewBoxEntered(InWhichBox(m_pos)); - // Aggiorna le vecchie coordinate + // Update the old coordinates olddx = dx; olddy = dy; } - // Se siamo fermi + // If we stop if (status == STAND) { - // Controlliamo se c' ancora percorso minimo da calcolare + // Check if there is still the shortest path to calculate if (minpath == 1) { _ctx->cur = theBoxes->GetBoxes(curLocation); - // Se dobbiamo ancora attraversare un box + // If we still have to go through a box if (pathcount < pathlenght) { - // Controlliamo che il box su cui stiamo entrando sia attivo + // Check if the box we're going into is active if (_ctx->cur->boxes[path[pathcount-1]].attivo) { - // Muoviti in linea retta verso l'hotspot pi vicino, tenendo conto del reversing please + // Move in a straight line towards the nearest hotspot, taking into account the reversing // NEWBOX = path[pathcount-1] CORO_INVOKE_2(GoTo, NearestHotSpot(path[pathcount-1], path[pathcount]), _ctx->cur->boxes[path[pathcount-1]].bReversed); pathcount++; } else { - // Se il box disattivato, possiamo solo bloccare tutto - // @@@ Questo non dovrebbe pi avvenire, dato che abbiamo migliorato - // la ricerca del percorso minimo + // If the box is off, we can only block all + // @@@ Whilst this should not happen, because have improved + // the search for the minimum path minpath = 0; if (!bEndOfPath) CORO_INVOKE_0(Stop); @@ -1534,8 +1495,8 @@ void RMCharacter::DoFrame(CORO_PARAM, RMGfxTargetBuffer* bigBuf, int loc) { CoroScheduler.pulseEvent(hEndOfPath); } } else { - // Se siamo gi entrati nell'ultimo box, dobbiamo solo muoverci in linea retta verso il - // punto di arrivo + // If we have already entered the last box, we just have to move in a straight line towards the + // point of arrival // NEWBOX = InWhichBox(pathend) minpath = 0; CORO_INVOKE_2(GoTo, pathend, _ctx->cur->boxes[InWhichBox(pathend)].bReversed); @@ -1545,7 +1506,7 @@ void RMCharacter::DoFrame(CORO_PARAM, RMGfxTargetBuffer* bigBuf, int loc) { g_system->unlockMutex(csMove); - // Richiama il DoFrame dell'item + // Invoke the DoFrame of the item RMItem::DoFrame(bigBuf); CORO_END_CODE; @@ -1611,7 +1572,7 @@ void RMCharacter::Move(CORO_PARAM, RMPoint pt, bool *result) { bMoving = true; - // Se 0,0, non fare nulla, anzi fermati + // 0, 0 does not do anything, just stops the character if (pt.x == 0 && pt.y == 0) { minpath = 0; status = STAND; @@ -1621,10 +1582,10 @@ void RMCharacter::Move(CORO_PARAM, RMPoint pt, bool *result) { return; } - // Se clicko fuori dai box + // If clicked outside the box _ctx->numbox = InWhichBox(pt); if (_ctx->numbox == -1) { - // Trova il punto pi vicino dentro i box + // Find neareste point inside the box _ctx->dest = NearestPoint(pt); // ???!?? @@ -1687,7 +1648,7 @@ void RMCharacter::SetPosition(const RMPoint &pt, int newloc) { if (newloc != -1) curLocation = newloc; - // Aggiorna la Z del personaggio + // Update the character's Z value box = theBoxes->GetBoxes(curLocation); curbox = InWhichBox(m_pos); assert(curbox != -1); @@ -1771,7 +1732,7 @@ void RMBox::ReadFromStream(RMDataStream &ds) { ds >> right; ds >> bottom; - // Adiacenza + // Adjacency for (i = 0; i < MAXBOXES; i++) { ds >> adj[i]; } @@ -1784,8 +1745,8 @@ void RMBox::ReadFromStream(RMDataStream &ds) { ds >> b; bReversed = b; - // Spazio di espansione - ds+=30; + // Reversed expansion space + ds += 30; // Hotspots for (i = 0; i < numhotspot; i++) { @@ -1818,18 +1779,18 @@ void RMBoxLoc::ReadFromStream(RMDataStream &ds) { char buf[2]; byte ver; - // ID and versione + // ID and version ds >> buf[0] >> buf[1] >> ver; assert(buf[0] == 'B' && buf[1] == 'X'); assert(ver == 3); - // Numero dei box + // Number of boxes ds >> numbbox; - // Alloca la memoria per i box + // Allocate memory for the boxes boxes = new RMBox[numbbox]; - // Li legge da disco + // Read in boxes for (i = 0; i < numbbox; i++) ds >> boxes[i]; } @@ -1950,7 +1911,7 @@ void RMGameBoxes::SaveState(byte *state) { // For each location, write out the number of boxes and their status for (i=1; i <= m_nLocBoxes; i++) { WRITE_LE_UINT32(state, m_allBoxes[i]->numbbox); - state+=4; + state += 4; for (j = 0; j < m_allBoxes[i]->numbbox; j++) *state++ = m_allBoxes[i]->boxes[j].attivo; @@ -1958,17 +1919,16 @@ void RMGameBoxes::SaveState(byte *state) { } void RMGameBoxes::LoadState(byte *state) { - int i,j; - int nloc,nbox; + int i, j; + int nloc, nbox; - // Load number of locations with box + // Load number of items nloc = *(int*)state; - state+=4; + state += 4; - // Controlla che siano meno di quelli correnti assert(nloc <= m_nLocBoxes); - // Per ogni locazione, salva il numero di box e il loro stato + // For each location, read the number of boxes and their status for (i = 1; i <= nloc; i++) { nbox = READ_LE_UINT32(state); state += 4; @@ -1985,17 +1945,12 @@ void RMGameBoxes::LoadState(byte *state) { } /****************************************************************************\ -* Metodi di RMLocation -\****************************************************************************/ - -/****************************************************************************\ -* -* Function: RMLocation::RMLocation(); -* -* Description: Costruttore standard -* +* RMLocation Methods \****************************************************************************/ +/** + * Standard constructor + */ RMLocation::RMLocation() { m_nItems = 0; m_items = NULL; @@ -2003,49 +1958,36 @@ RMLocation::RMLocation() { } -/****************************************************************************\ -* -* Function: bool RMLocation::Load(char *lpszFileName); -* -* Description: Carica una locazione (.LOC) da un file di cui viene fornito -* il pathname. -* -* Input: char *lpszFileName Nome del file di dati -* -* Return: true se tutto OK, false in caso di errore -* -\****************************************************************************/ - +/** + * Load a location (.LOC) from a file that is provided. + * + * @param lpszFileName Name of the file + */ bool RMLocation::Load(const char *lpszFileName) { Common::File f; bool bRet; - // Apre il file in lettura + // Open the file for reading if (!f.open(lpszFileName)) return false; - // Lo passa alla routine di loading da file aperto + // Passes to the method variation for loading from the opened file bRet = Load(f); - // Chiude il file + // Close the file f.close(); return bRet; } -/****************************************************************************\ -* -* Function: bool RMLocation::Load(HANDLE hFile); -* -* Description: Carica una locazione (.LOC) da un handle di file aperto -* -* Input: HANDLE hFile Handle del file -* -* Return: true se tutto OK, false in caso di errore -* -\****************************************************************************/ - +/** + * Load a location (.LOC) from a given open file + * + * @param hFile File reference + * + * @returns True if succeeded OK, false in case of error. + */ bool RMLocation::Load(Common::File &file) { int size; // byte *buf; @@ -2091,20 +2033,12 @@ bool RMLocation::Load(const byte *buf) { } - -/****************************************************************************\ -* -* Function: bool RMLocation::Load(byte *buf); -* -* Description: Carica una locazione (.LOC) parsando il file gia' caricato -* in memoria. -* -* Input: byte *buf Buffer con il file caricato -* -* Return: true se ok, false in caso di errore -* -\****************************************************************************/ - +/** + * Load a location (.LOC) from a given data stream + * + * @param ds Data stream + * @returns True if succeeded OK, false in case of error. + */ bool RMLocation::Load(RMDataStream &ds) { char id[3]; int dimx, dimy; @@ -2112,40 +2046,40 @@ bool RMLocation::Load(RMDataStream &ds) { byte cm; int i; - // Controlla l'ID + // Check the ID ds >> id[0] >> id[1] >> id[2]; - // Controlla se siamo in un LOX + // Check if we are in a LOX if (id[0] == 'L' && id[1] == 'O' && id[2] == 'X') return LoadLOX(ds); - // Altrimenti, controlla che sia un LOC normale + // Otherwise, check that it is a normal LOC if (id[0] != 'L' || id[1] != 'O' || id[2] != 'C') return false; - // Versione + // Version ds >> ver; assert(ver == 6); - // Nome della locazione + // Location name ds >> m_name; - // Skippa i salvataggi MPAL (64 bytes) + // Skip the MPAL bailouts (64 bytes) ds >> TEMPNumLoc; ds >> TEMPTonyStart.x >> TEMPTonyStart.y; ds += 64 - 4 * 3; - // Skippa il flag di background associato (?!) + // Skip flag associated with the background (?) ds += 1; - // Dimensioni della locazione + // Location dimensions ds >> dimx >> dimy; m_curScroll.Set(0, 0); - // Legge il color mode + // Read the colour mode ds >> cm; m_cmode = (RMColorMode)cm; - // Inizializza il source buffer e leggi la locazione dentro + // Initialise the source buffer and read the location switch (m_cmode) { case CM_256: m_buf = new RMGfxSourceBuffer8; @@ -2160,16 +2094,16 @@ bool RMLocation::Load(RMDataStream &ds) { break; }; - // Inizializza la surface, caricando anche la palette se necessario + // Initialise the surface, loading the palette if necessary m_buf->Init(ds, dimx, dimy, true); - // Controlla le dimensioni della locazione + // Check the size of the location // assert(dimy!=512); - // Numero oggetti + // Number of objects ds >> m_nItems; - // Creazione e lettura degli oggetti + // Create and read in the objects if (m_nItems > 0) m_items = new RMItem[m_nItems]; @@ -2179,7 +2113,7 @@ bool RMLocation::Load(RMDataStream &ds) { ds >> m_items[i]; _vm->UnfreezeTime(); - // Setta i pattern iniziali @@@ doppione!! + // Sets the initial pattern @@@ duplication! //for (i = 0;i> ver; assert(ver == 1); - // Nome locazione + // Location name ds >> m_name; - // Numero loc + // Location number ds >> TEMPNumLoc; ds >> TEMPTonyStart.x >> TEMPTonyStart.y; - // Dimensioni + // Dimensions ds >> dimx >> dimy; m_curScroll.Set(0, 0); - // Color mode sempre 65K + // It's always 65K (16-bit) mode m_cmode = CM_65K; m_buf = new RMGfxSourceBuffer16; - // Inizializza la surface, caricando anche la palette se necessario + // Initialise the surface, loading in the palette if necessary m_buf->Init(ds, dimx, dimy, true); - // Controlla le dimensioni della locazione + // Check the size of the location // assert(dimy!=512); - // Numero oggetti + // Number of items ds >> m_nItems; - // Creazione e lettura degli oggetti + // Create and read objects if (m_nItems > 0) m_items = new RMItem[m_nItems]; @@ -2231,54 +2165,40 @@ bool RMLocation::LoadLOX(RMDataStream &ds) { } - -/****************************************************************************\ -* -* Function: void RMLocation::Draw(RMGfxTargetBuffer* bigBuf, -* RMGfxPrimitive* prim); -* -* Description: Metodo di drawing in overloading da RMGfxSourceBuffer8 -* -\****************************************************************************/ - +/** + * Draw method overloaded from RMGfxSourceBUffer8 + */ void RMLocation::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - // Setta la posizione sorgente dello scrolling + // Set the position of the source scrolling if (m_buf->Dimy()>RM_SY || m_buf->Dimx()>RM_SX) { prim->SetSrc(RMRect(m_curScroll,m_curScroll+RMPoint(640,480))); } prim->SetDst(m_fixedScroll); - // Richiama il metodo di drawing della classe dell'immagine, che disegner il background - // della locazione + // Invoke the drawing method fo the image class, which will draw the location background CORO_INVOKE_2(m_buf->Draw, bigBuf, prim); CORO_END_CODE; } -/****************************************************************************\ -* -* Function: void RMLocation::DoFrame(void); -* -* Description: Prepara un frame, aggiungendo alla OTList la locazione stessa -* e tutti gli item che hanno cambiato frame di animazione -* -\****************************************************************************/ - +/** + * Prepare a frame, adding the location to the OT list, and all the items that have changed animation frame. + */ void RMLocation::DoFrame(RMGfxTargetBuffer *bigBuf) { int i; - // Se la locazione non e' in OT list, la aggiunge + // If the location is not in the OT list, add it in if (!m_nInList) bigBuf->AddPrim(new RMGfxPrimitive(this)); - // Processa tutti gli item della locazione + // Process all the location items for (i = 0;i < m_nItems; i++) m_items[i].DoFrame(bigBuf); } @@ -2321,13 +2241,13 @@ RMLocation::~RMLocation() { } void RMLocation::Unload(void) { - // Cancella la memoria + // Clear memory if (m_items) { delete[] m_items; m_items = NULL; } - // Cancella il buffer + // Destroy the buffer if (m_buf) { delete m_buf; m_buf = NULL; @@ -2399,7 +2319,7 @@ void RMLocation::PauseSound(bool bPause) { /****************************************************************************\ -* Metodi di RMMessage +* RMMessage Methods \****************************************************************************/ RMMessage::RMMessage(uint32 dwId) { @@ -2432,16 +2352,16 @@ void RMMessage::ParseMessage(void) { p = lpPeriods[0] = lpMessage; for (;;) { - // Trova la fine del periodo corrente + // Find the end of the current period while (*p != '\0') p++; - // Se c'e' un altro '\0' siamo alla fine del messaggio + // If there is another '0' at the end of the string, the end has been found p++; if (*p == '\0') break; - // Altrimenti c'e' un altro periodo, e ci ricordiamo il suo inizio + // Otherwise there is another line, and remember it's start lpPeriods[nPeriods++] = p; } } diff --git a/engines/tony/loc.h b/engines/tony/loc.h index e25bdb500c..4b9a18f406 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -128,8 +128,8 @@ public: private: int m_speed; - RMPoint m_pos; // Coordinate babbo - RMPoint m_curPos; // Coordinate babbo+figlio + RMPoint m_pos; // Parent coordinates + RMPoint m_curPos; // Parent + child coordinates int m_bLoop; int m_nSlots; int m_nCurSlot; @@ -237,29 +237,29 @@ public: friend RMDataStream& operator>>(RMDataStream &ds, RMItem &item); - // Processa l'oggetto per fare andare avanti eventuale animazioni. Ritorna TRUE se dovr - // essere ridisegnato il prossimo frame + // Process to make the object move on any animations. + // Returns TRUE if it should be redrawn on the next frame bool DoFrame(RMGfxTargetBuffer *bigBuf, bool bAddToList = true); - // Setta la posizione corrente di scrolling + // Sets the current scrolling position void SetScrollPosition(const RMPoint &scroll); - // Overloading della funzione per la rimozione da ot list + // Overloading of check whether to remove from active list virtual void RemoveThis(CORO_PARAM, bool &result); - // Overloading del draw + // Overloaded Draw virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - // Overloading della priorit: la Z + // Overloaded priority: it's based on Z ordering virtual int Priority() { return m_z; } - // Numero di pattern + // Pattern number int NumPattern() { return m_nPatterns; } - // Setta un nuovo pattern di animazione, cambiando bruscamente da quello corrente + // Set anew animation pattern, changing abruptly from the current virtual void SetPattern(int nPattern, bool bPlayP0 = false); - // Setta un nuovo status. + // Set a new status void SetStatus(int nStatus); bool IsIn(const RMPoint &pt, int *size = NULL); @@ -267,13 +267,13 @@ public: bool GetName(RMString &name); int MpalCode() { return m_mpalCode; } - // Scarica l'item + // Unload void Unload(void); - // Aspetta la fine del pattern in play + // Wait for the end of the current pattern void WaitForEndPattern(CORO_PARAM, uint32 hCustomSkip = CORO_INVALID_PID_VALUE); - // Setta un nuovo hotspot per l'oggetto + // Sets a new hotspot fro the object void ChangeHotspot(const RMPoint &pt); void SetInitCurPattern(bool status) { m_bInitCurPattern=status; } @@ -285,30 +285,30 @@ void ReadFromStream(RMDataStream& ds, bool bLOX=false); void PauseSound(bool bPause); protected: - // Crea una primitiva che ha come task l'item stesso + // Create a primitive that has as it's task this item virtual RMGfxPrimitive *NewItemPrimitive(); - // Alloca la memoria per gli sprites - virtual RMGfxSourceBuffer* NewItemSpriteBuffer(int dimx, int dimy, bool bPreRLE); + // Allocate memory for the sprites + virtual RMGfxSourceBuffer *NewItemSpriteBuffer(int dimx, int dimy, bool bPreRLE); }; -#define MAXBOXES 50 // Non si puo' cambiare, comanda cosi' il boxed -#define MAXHOTSPOT 20 // Idem +#define MAXBOXES 50 // Maximum number of allowed boxes +#define MAXHOTSPOT 20 // Maximum nimber of allowed hotspots class RMBox { public: struct T_HOTSPOT { - int hotx, hoty; // coordinate HotSpot - int destination; // destinazione HotSpot + int hotx, hoty; // Hotspot coordinates + int destination; // Hotspot destination }; public: - int left,top,right,bottom; // Vertici BoundingBox - int adj[MAXBOXES]; // Lista di adjacenza - int numhotspot; // Numero HotSpot - uint8 Zvalue; // Zvalue per quel BoundingBox - T_HOTSPOT hotspot[MAXHOTSPOT]; // Lista degli HotSpot + int left, top, right, bottom; // Vertici bounding boxes + int adj[MAXBOXES]; // List of adjacent bounding boxes + int numhotspot; // Hotspot number + uint8 Zvalue; // Z value for the bounding box + T_HOTSPOT hotspot[MAXHOTSPOT]; // List of hotspots bool attivo; bool bReversed; @@ -351,19 +351,19 @@ public: void Init(void); void Close(void); - // Prende i box di una locazione + // Get binding boxes for a given location RMBoxLoc *GetBoxes(int nLoc); - // Calcola in quale box si trova il punto + // Return the box which contains a given point int WhichBox(int nLoc, const RMPoint &pt); - // Controlla che il punto sia dentro un certo box + // Check whether a point is inside a given box bool IsInBox(int nLoc, int nBox, const RMPoint &pt); - // Cambia lo stato di un box + // Change the status of a box void ChangeBoxStatus(int nLoc, int nBox, int status); - // Salvataggi + // Save state handling int GetSaveStateSize(void); void SaveState(byte *buf); void LoadState(byte *buf); @@ -429,38 +429,38 @@ protected: bool bMoving; bool bDrawNow; bool bNeedToStop; -// virtual RMGfxPrimitive* NewItemPrimitive(); +// virtual RMGfxPrimitive *NewItemPrimitive(); public: RMCharacter(); virtual ~RMCharacter(); - void LinkToBoxes(RMGameBoxes* theBoxes); + void LinkToBoxes(RMGameBoxes *theBoxes); virtual void RemoveThis(CORO_PARAM, bool &result); - // Aggiorna la posizione del personaggio + // Update the position of a character void DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc); - // Overloading del Draw + // Overloaded draw virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - // TRUE se si appena fermato + // TRUE if you just stopped bool EndOfPath() { return bEndOfPath; } - // Cambia il pattern del personaggio per fermarlo + // Change the pattern of a character to STOP virtual void Stop(CORO_PARAM); - // Controlla se il personaggio si sta muovendo + // Check if the character is moving bool IsMoving() { return bMoving; } - // Muove il personaggio a una certa posizione + // Move the character to a certain position void Move(CORO_PARAM, RMPoint pt, bool *result = NULL); - // Posiziona il personaggio a una certa posizione SENZA farlo muovere + // Place the character in a certain position WITHOUT moving void SetPosition(const RMPoint &pt, int newloc = -1); - // Aspetta la fine del movimento + // Wait for the end of movement void WaitForEndMovement(CORO_PARAM); void SetFixedScroll(const RMPoint &fix) { m_fixedScroll = fix; } @@ -502,16 +502,16 @@ public: */ class RMLocation : public RMGfxTaskSetPrior { public: - RMString m_name; // Nome + RMString m_name; // Name private: - RMColorMode m_cmode; // Color mode - RMGfxSourceBuffer* m_buf; // Immagine della locazione + RMColorMode m_cmode; // Color mode + RMGfxSourceBuffer *m_buf; // Location picture - int m_nItems; // Numero oggetti -RMItem* m_items; // Oggetti + int m_nItems; // Number of objects + RMItem *m_items; // Objects - RMPoint m_curScroll; // Posizione corrente di scroll + RMPoint m_curScroll; // Current scroll position RMPoint m_fixedScroll; public: @@ -526,41 +526,41 @@ public: RMLocation(); virtual ~RMLocation(); - // Caricamento da disco + // Load variations bool Load(const char *lpszFileName); bool Load(Common::File &file); bool Load(const byte *buf); bool Load(RMDataStream &ds); bool LoadLOX(RMDataStream &ds); - // Scaricamento + // Unload void Unload(void); - // Overloading del Draw + // Overloaded draw virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - // Prepara un frame disegnando la locazione e tutti i suoi item + // Prepare a frame by drawing the location and all it's items void DoFrame(RMGfxTargetBuffer *bigBuf); - // Si fa dare il numero dell'item + // Return the item at a given point RMItem *WhichItemIsIn(const RMPoint &pt); - // Si fa dare un elemento dal suo codice MPAL - RMItem* GetItemFromCode(uint32 dwCode); + // Return the item based on it's MPAL code + RMItem *GetItemFromCode(uint32 dwCode); - // Setta la posizione corrente di scrolling + // Set the current scroll position void SetScrollPosition(const RMPoint &scroll); - // Setta un offset aggiuntivo di scrolling da aggiungere sempre + // Sets an additinal offset for scrolling void SetFixedScroll(const RMPoint &scroll); - // Aggiorna le coordinate di scrolling in modo da visualizzare sempre il punto fornito + // Update the scrolling coordinates to display the specified point void UpdateScrolling(const RMPoint &ptShowThis); - // Legge la posizione di scrolling corrente + // Read the current scroll position RMPoint ScrollPosition() { return m_curScroll; } - // Pausa sonoro + // Pause sound void PauseSound(bool bPause); }; @@ -589,7 +589,6 @@ public: char *operator[](int num) { return lpPeriods[num]; } }; - } // End of namespace Tony #endif /* TONY_H */ diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 2dbe102424..c9abea04e0 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -124,14 +124,12 @@ Common::ErrorCode TonyEngine::Init() { // Link to the custom graphics engine _theEngine.InitCustomDll(); - - // Inizializza il gfxEngine _theEngine.Init(); - // Memoria per il thumbnail + // Allocate space for thumbnails when saving the game m_curThumbnail = new uint16[160 * 120]; - // Configurazione di default + // Set up global defaults GLOBALS.bCfgInvLocked = false; GLOBALS.bCfgInvNoScroll = false; GLOBALS.bCfgTimerizedText = true; @@ -358,14 +356,14 @@ void TonyEngine::InitMusic() { m_sfx[i] = m_utilSfx[i] = NULL; } - // Crea la critical section per la musica + // Create the mutex for controlling music access // csMusic = g_system->createMutex(); - // Carica effetti sonori + // Preload sound effects // PreloadUtilSFX(0,"AccendiOpzione.ADP"); // PreloadUtilSFX(1,"ApriInterfaccia.ADP"); - PreloadUtilSFX(0, "U01.ADP"); // invertiti!! + PreloadUtilSFX(0, "U01.ADP"); // Reversed!! PreloadUtilSFX(1, "U02.ADP"); } diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 32332a871d..8d4e357079 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -149,10 +149,10 @@ public: Common::Error loadGameState(int slot); Common::Error saveGameState(int slot, const Common::String &desc); - // Avverte che siamo guidati dal GDI + // Warn when are being controlled by the GDI void GDIControl(bool bCon); - // Loop che gestisce i messaggi quando siamo in pausa + // Loop that handles messages when the game is paused void PauseLoop(void); void Play(); @@ -167,7 +167,7 @@ public: void ShowLocation(void) { m_bDrawLocation = true; } void HideLocation(void) { m_bDrawLocation = false; } - // Mette o leva la pausa + // Handle pause mode void Pause(bool bPause); bool IsPaused() { return m_bPaused; } @@ -195,19 +195,19 @@ public: void PreloadUtilSFX(int nSfx, const char *fn); void UnloadAllUtilSFX(void); - // Ferma tutta la parte audio + // Stop all the audio void PauseSound(bool bPause); void SetMusicVolume(int nChannel, int volume); int GetMusicVolume(int nChannel); - // Salvataggio + // Handle saving void AutoSave(CORO_PARAM); void SaveState(int n, const char *name); void LoadState(CORO_PARAM, int n); static Common::String GetSaveStateFileName(int n); - // Prende il thumbnail + // Get a thumbnail void GrabThumbnail(void); uint16 *GetThumbnail(void) { return m_curThumbnail; } diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index c612ebbf77..04b6193cd2 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -93,10 +93,10 @@ void RMTony::Init(void) { RMRes body(9999); RMDataStream ds; - // Mostra Tony di default - m_bShow=m_bShowOmbra = true; + // Tony is shown by default + m_bShow = m_bShowOmbra = true; - // Nessuna azione in attesa + // No action pending m_bActionPending = false; m_bAction = false; @@ -104,18 +104,18 @@ void RMTony::Init(void) { m_bIsTalking = false; m_bIsStaticTalk = false; - // Apre il buffer + // Opens the buffer ds.OpenBuffer(tony); - // Legge dallo stream l'oggetto corrente (cio Tony) - ReadFromStream(ds, true); // da OGX + // Reads his details from the stream + ReadFromStream(ds, true); - // Chiude il buffer + // Closes the buffer ds.Close(); - // Legge il corpo di Tony + // Reads Tony's body ds.OpenBuffer(body); - m_body.ReadFromStream(ds, true); // da OGX + m_body.ReadFromStream(ds, true); ds.Close(); m_body.SetPattern(0); @@ -124,7 +124,7 @@ void RMTony::Init(void) { void RMTony::Close(void) { - // Disalloca @@@ Manca la disallocazione di un item + // Disalloca @@@ Deallocation of missing item m_ombra.Destroy(); } @@ -140,7 +140,7 @@ void RMTony::DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int curLoc) { SetSpeed(GLOBALS.nCfgTonySpeed); - // Esegue il movimento normale del personaggio + // Runs the normal character movement _ctx->time = _vm->GetTime(); do { @@ -149,9 +149,9 @@ void RMTony::DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int curLoc) { } while (_ctx->time > m_nTimeLastStep + (1000 / 40)); - // Controlla se siamo alla fine del percorso + // Check if we are at the end of a path if (EndOfPath() && m_bActionPending) { - // Bisogna eseguire l'azione sulla quale abbiamo clickato + // Must perform the action on which we clicked m_bActionPending = false; } @@ -239,17 +239,16 @@ void RMTony::MoveAndDoAction(CORO_PARAM, RMPoint dst, RMItem *item, int nAction, void RMTony::ExecuteAction(int nAction, int nActionItem, int nParm) { - // fixme: See if hThread can be converted to uint32 uint32 pid; if (nAction == TA_COMBINE) { pid = mpalQueryDoAction(TA_COMBINE, nParm, nActionItem); - // Se fallito il combine, proviamo con il ReceiveCombine + // If you failed the combine, we have RECEIVECOMBINE as a fallback if (pid == CORO_INVALID_PID_VALUE) { pid = mpalQueryDoAction(TA_RECEIVECOMBINE, nActionItem, nParm); - // Se fallito il receive, andiamo con quelli generici + // If you failed with that, go with the generic // @@@ CombineGive! if (pid == CORO_INVALID_PID_VALUE) { pid = mpalQueryDoAction(TA_COMBINE, nParm, 0); @@ -313,15 +312,15 @@ void RMTony::Stop(CORO_PARAM) { CORO_BEGIN_CODE(_ctx); if (m_ActionItem != NULL) { - // Richiama l'MPAL per scegliere la direzione + // Call MPAL to choose the direction _ctx->pid = mpalQueryDoAction(21, m_ActionItem->MpalCode(), 0); if (_ctx->pid == CORO_INVALID_PID_VALUE) CORO_INVOKE_0(RMCharacter::Stop); else { - bNeedToStop = false; // Se facciamo la OnWhichDirection, almeno dopo non dobbiamo fare la Stop() + bNeedToStop = false; // If we make the OnWhichDirection, we don't need at least after the Stop(). bMoving = false; - CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->pid, CORO_INFINITE); // @@@ Mettere un assert dopo 10 secondi + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->pid, CORO_INFINITE); // @@@ Put an assert after 10 seconds } } else { CORO_INVOKE_0(RMCharacter::Stop); @@ -406,7 +405,7 @@ void RMTony::Take(int nWhere, int nPart) { if (nPart == 0) { switch (GetCurPattern()) { case PAT_STANDDOWN: - assert(0); // Non esiste il prende mentre sei in StandDown + assert(0); // Not while you're doing a StandDown break; case PAT_STANDUP: @@ -481,7 +480,7 @@ void RMTony::Put(int nWhere, int nPart) { if (nPart == 0) { switch (GetCurPattern()) { case PAT_STANDDOWN: - //assert(0); // Non esiste il prende mentre sei in StandDown + //assert(0); break; case PAT_STANDUP: @@ -560,7 +559,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body m_nPatB4Talking = GetCurPattern(); m_nTalkType = nTalkType; - // Setta la direzione di parlata SOLO se non siamo in una static animation (perch l'ha gi fatto) + // Set the direction of speech ONLY if we are not in a static animation (since it would have already been done) if (!m_bIsStaticTalk) { switch (m_nPatB4Talking) { case PAT_STANDDOWN: @@ -591,12 +590,12 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; } - // Mette davanti il corpo di default + // Puts the body in front by default m_bCorpoDavanti = true; } if (m_bPastorella) { - // Da pastorella, c' un solo parlato + // Talking whilst a shepherdess MainFreeze(); switch (m_TalkDirection) { case UP: @@ -967,8 +966,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body } break; - // La barba l'unico caso in cui la testa animata a parte - // mentre il corpo quello standard + // The beard is the only case in which the head is animated separately while the body is the standard case TALK_CONBARBASTATIC: switch (m_TalkDirection) { case LEFT: @@ -1127,7 +1125,7 @@ void RMTony::StartTalk(CORO_PARAM, TALKTYPE nTalkType) { _ctx->headLoopPat, _ctx->bodyLoopPat)) return; - // Esegue il set dei pattern vero e proprio + // Perform the set pattern if (_ctx->headStartPat != 0 || _ctx->bodyStartPat != 0) { MainFreeze(); SetPattern(_ctx->headStartPat); @@ -1446,7 +1444,7 @@ void RMTony::EndTalk(CORO_PARAM) { if (!EndTalkCalculate(_ctx->headStandPat, _ctx->headEndPat, _ctx->bodyEndPat, _ctx->finalPat, _ctx->bStatic)) return; - // Gestisce la fine di una animazione static lasciando tutto invariato + // Handles the end of an animated and static, leaving everything unchanged if (m_bIsStaticTalk) { if (m_nTalkType == TALK_CONBARBASTATIC) { MainFreeze(); @@ -1471,7 +1469,7 @@ void RMTony::EndTalk(CORO_PARAM) { return; } - // Set dei pattern + // Set the pattern if (_ctx->headEndPat != 0 && _ctx->bodyEndPat != 0) { MainFreeze(); SetPattern(_ctx->headEndPat); diff --git a/engines/tony/tonychar.h b/engines/tony/tonychar.h index 201803dc5f..a7109256f5 100644 --- a/engines/tony/tonychar.h +++ b/engines/tony/tonychar.h @@ -106,13 +106,13 @@ private: uint32 hActionThread; protected: - // Overload dell'allocazione degli sprites per cambiare il tipo + // Overload of the allocation allocation of sprites virtual RMGfxSourceBuffer *NewItemSpriteBuffer(int dimx, int dimy, bool bPreRLE); - // Thread which waits for the end of an action + // Watch thread which waits for the end of an action static void WaitEndOfAction(CORO_PARAM, const void *param); -public: // per farlo rialzare, altrimenti private +public: enum PATTERNS { PAT_TAKEUP_UP1 = 9, PAT_TAKEUP_UP2, @@ -140,7 +140,7 @@ public: // per farlo rialzare, altrimenti private PAT_SIRIALZARIGHT, PAT_PERTERRARIGHT, - // Pastorella! + // Sheperdess! PAT_PAST_WALKUP, PAT_PAST_WALKDOWN, PAT_PAST_WALKLEFT, @@ -151,19 +151,19 @@ public: // per farlo rialzare, altrimenti private PAT_PAST_STANDLEFT, PAT_PAST_STANDRIGHT, - // Parlata + // Speech PAT_TALK_UP, PAT_TALK_DOWN, PAT_TALK_LEFT, PAT_TALK_RIGHT, - // Testa statica + // Static head PAT_TESTA_UP, PAT_TESTA_DOWN, PAT_TESTA_LEFT, PAT_TESTA_RIGHT, - // Risata + // Laugh PAT_RIDELEFT_START, PAT_RIDELEFT_LOOP, PAT_RIDELEFT_END, @@ -171,13 +171,13 @@ public: // per farlo rialzare, altrimenti private PAT_RIDERIGHT_LOOP, PAT_RIDERIGHT_END, - // Parlata da pastorella + // Speaking as a shepherdess PAT_PAST_TALKUP, PAT_PAST_TALKDOWN, PAT_PAST_TALKLEFT, PAT_PAST_TALKRIGHT, - // Spavento + // Fear PAT_SPAVENTOLEFT_START, PAT_SPAVENTOLEFT_LOOP, PAT_SPAVENTOLEFT_END, @@ -188,16 +188,16 @@ public: // per farlo rialzare, altrimenti private PAT_SPAVENTODOWN_LOOP, PAT_SPAVENTODOWN_END, - // Con oggetti: corpo completo + // With objects: full body PAT_CONBICCHIERE, PAT_CONCORDA, PAT_CONVERME, PAT_CONMARTELLO, - // Suona il fischietto + // Sound the whistle PAT_FISCHIETTORIGHT, - // Testa con barba + // Head with beard PAT_TALKBARBA_LEFT, PAT_TALKBARBA_RIGHT, @@ -205,7 +205,7 @@ public: // per farlo rialzare, altrimenti private PAT_SNIFFA_LEFT, PAT_SNIFFA_RIGHT, - // Schifato + // Disgusted PAT_SCHIFATOLEFT_START, PAT_SCHIFATOLEFT_LOOP, PAT_SCHIFATOLEFT_END, @@ -219,7 +219,7 @@ public: // per farlo rialzare, altrimenti private PAT_NAAHRIGHT_LOOP, PAT_NAAHRIGHT_END, - // Stand spaventato + // Stand scared PAT_SPAVENTOLEFT_STAND, PAT_SPAVENTORIGHT_STAND, PAT_SPAVENTODOWN_STAND, @@ -361,81 +361,80 @@ public: static void InitStatics(); RMTony(); - // Inizializza Tony + // Initialise Tony void Init(void); - // Libera tutta la memoria + // Free all memory void Close(void); - // Fa un frame di Tony, aggiornando il movimento, etc + // Tony makes a frame, updating the movement, etc. void DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int curLoc); - // Metodi di Draw, che controlla la variabile di show + // Draw method, which controls chararacter display virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - // Mostra o nascondi + // Show or hide void Show(void); void Hide(bool bShowOmbra = false); - // Si muove e fa un azione, se necessario + // Move and make an action, if necessary void MoveAndDoAction(CORO_PARAM, RMPoint dst, RMItem *item, int nAction, int nActionParm = 0); - // Ferma Tony (dalla parte giusta rispetto a un eventuale oggetto) + // Tony stops (on the right side with respect to any subject) virtual void Stop(CORO_PARAM); void StopNoAction(CORO_PARAM); - // Setta un pattern + // Set a pattern void SetPattern(int npatt, bool bPlayP0 = false); - // Legge il pattern corrente + // Reads the current pattern int GetCurPattern(); - // Attende la fine di un pattern + // Waits until the end of a pattern void WaitForEndPattern(CORO_PARAM, uint32 hCustomSkip = CORO_INVALID_PID_VALUE) { RMCharacter::WaitForEndPattern(coroParam, hCustomSkip); } - // Controlla se si trova in azione - bool InAction() { return (m_bActionPending&&m_Action != 0) | m_bAction; } + // Check if currently in an action + bool InAction() { return (m_bActionPending && m_Action != 0) | m_bAction; } - // Controlla se c' da aggiornare il movimento di scrolling + // Check if there needs to be an update for scrolling movement bool MustUpdateScrolling() { return ((!InAction()) || (IsMoving())); } - // Prende la posizione di Tony + // Returns Tony's position RMPoint Position() { return m_pos; } - // Setta la posizione di scrolling + // Set the scrolling position void SetScrollPosition(const RMPoint &pt) { RMCharacter::SetScrollPosition(pt); } - // Setta l'animazione di Take + // Set the take animation void Take(int nWhere, int nPart); void Put(int nWhere, int nPart); - // Start e End Talk + // Start or End Talk bool StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &bodyStartPat, int &headLoopPat, int &bodyLoopPat); void StartTalk(CORO_PARAM, TALKTYPE nTalkType); bool EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPat, int &finalPat, bool &bStatic); void EndTalk(CORO_PARAM); - // Start e End Static + // Start or End Static void StartStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat, int &bodyStartPat, int &bodyLoopPat); void StartStatic(CORO_PARAM, TALKTYPE nTalkType); void EndStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, int &headEndPat); void EndStatic(CORO_PARAM, TALKTYPE nTalkType); - // Tony si traveste! + // Tony disguises himself! void SetPastorella(bool bIsPast) { m_bPastorella=bIsPast; } int GetPastorella(void) { return m_bPastorella; } - // Esegue una azione + // Perform an action void ExecuteAction(int nAction, int nActionItem, int nParm); void PlaySfx(int nSfx) { RMItem::PlaySfx(nSfx); } }; - } // End of namespace Tony #endif diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index d57640fee8..9aaffefceb 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -40,9 +40,9 @@ namespace Tony { * Constructor */ RMString::RMString() { - m_string=NULL; - m_length=0; - m_realLength=0; + m_string = NULL; + m_length = 0; + m_realLength = 0; } /** @@ -188,8 +188,8 @@ const RMString& RMString::operator=(const int ch) { // Destroy the current string if (m_realLength > 0) { delete [] m_string; - m_string=NULL; - m_length=m_realLength=0; + m_string = NULL; + m_length = m_realLength = 0; } } else { // Resize if necessary @@ -213,7 +213,7 @@ void RMString::Connect(const char *str, int size) { if (size > 0) { // Calculate the new lenght - nlen=m_length+size; + nlen = m_length+size; // Resize Resize(nlen + 1, true); @@ -242,7 +242,7 @@ const RMString &RMString::operator+=(RMString &str) { * @returns Refrence to our string */ const RMString &RMString::operator+=(const char *str) { - Connect(str,strlen(str)); + Connect(str, strlen(str)); return *this; } @@ -385,7 +385,7 @@ void RMString::Format(const char *str, ...) { } /****************************************************************************\ -* Metodi di RMFileStreamSlow +* RMFileStreamSlow Methods \****************************************************************************/ RMFileStreamSlow::RMFileStreamSlow() : RMDataStream() { @@ -410,7 +410,7 @@ bool RMFileStreamSlow::OpenFile(Common::File &file) { bool RMFileStreamSlow::OpenFile(const char *lpFN) { - // Apre il file in lettura + // Open file for reading Common::File f; if (!f.open(lpFN)) return false; @@ -679,13 +679,13 @@ int RMDataStream::Seek(int nBytes, RMDSPos origin) { break; case START: - m_pos=0; + m_pos = 0; break; case END: if (m_length == SIZENOTKNOWN) return m_pos; - m_pos=m_length; + m_pos = m_length; break; } @@ -741,8 +741,8 @@ RMPoint::RMPoint() { * Copy constructor */ RMPoint::RMPoint(const RMPoint &p) { - x=p.x; - y=p.y; + x = p.x; + y = p.y; } /** @@ -969,13 +969,13 @@ RMRect operator-(const RMRect& rc, RMPoint p) { RMRect operator+(RMPoint p, const RMRect& rc) { RMRect r(rc); - return (r+=p); + return (r += p); } RMRect operator-(RMPoint p, const RMRect& rc) { RMRect r(rc); - return (r+=p); + return (r += p); } bool RMRect::operator==(const RMRect& rc) { @@ -987,7 +987,7 @@ bool RMRect::operator!=(const RMRect& rc) { } void RMRect::NormalizeRect(void) { - SetRect(MIN(x1,x2), MIN(y1,y2), MAX(x1,x2), MAX(y1,y2)); + SetRect(MIN(x1, x2), MIN(y1, y2), MAX(x1, x2), MAX(y1, y2)); } RMDataStream &operator>>(RMDataStream &ds, RMRect &rc) { @@ -1029,7 +1029,7 @@ void RMResUpdate::Init(const Common::String &fileName) { _infos = new ResUpdInfo[_numUpd]; // Load the index of the resources in the file - for (i=0; i<_numUpd; ++i) { + for (i = 0; i < _numUpd; ++i) { ResUpdInfo &info = _infos[i]; info.dwRes = _hFile.readUint32LE(); @@ -1045,7 +1045,7 @@ HGLOBAL RMResUpdate::QueryResource(uint32 dwRes) { return NULL; uint32 i; - for (i=0; i < _numUpd; ++i) + for (i = 0; i < _numUpd; ++i) if (_infos[i].dwRes == dwRes) // Found the index break; diff --git a/engines/tony/utils.h b/engines/tony/utils.h index 1e3841c185..c823421c62 100644 --- a/engines/tony/utils.h +++ b/engines/tony/utils.h @@ -71,7 +71,7 @@ public: void OpenBuffer(const byte *buf, int size = SIZENOTKNOWN); void Close(void); - // Attributi + // Attributei int Length(); virtual int Pos(); @@ -86,14 +86,14 @@ public: friend RMDataStream &operator>>(RMDataStream &df, int &var); friend RMDataStream &operator>>(RMDataStream &df, uint32 &var); - // Lettura generica + // General read virtual bool Read(void *buf, int size); // Skipping & Seeking virtual RMDataStream &operator+=(int nBytes); virtual int Seek(int nBytes, RMDSPos origin = CUR); - // Gestione errori + // Error handling void SetError(int ecode); int GetError(); bool IsError(); @@ -111,7 +111,7 @@ public: RMFileStream(); virtual ~RMFileStream(); - // Apre lo stream da file + // Methods for opening file bool OpenFile(const char *lpFN); bool OpenFile(Common::File &file); @@ -165,7 +165,7 @@ public: RMString(const char *str); RMString(const int ch); - // Metodi generici + // General methods int Length() const; void Compact(); @@ -196,10 +196,10 @@ public: friend RMString operator+(RMString &str, const char *s); friend RMString operator+(const char *s, RMString &str); - // Estrazione da data stream + // Extraction from data streams friend RMDataStream& operator>>(RMDataStream& df, RMString &var); - // Formattazione di stringa + // String formatting void Format(const char *str, ...); private: @@ -220,11 +220,11 @@ public: RMPoint(const RMPoint &p); RMPoint(int x1, int y1); - // Copia + // Copy RMPoint& operator=(RMPoint p); // Set - void Set(int x1, int y1) { x=x1; y=y1; } + void Set(int x1, int y1) { x = x1; y = y1; } // Offset void Offset(int xOff, int yOff); @@ -235,7 +235,7 @@ public: RMPoint &operator-=(RMPoint p); RMPoint operator-(); - // Confronti + // Comparison bool operator==(RMPoint p); bool operator!=(RMPoint p); diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index 26dbaf88fc..481393c5ed 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -245,9 +245,9 @@ void RMSnapshot::GrabScreenshot(byte *lpBuf, int dezoom, uint16 *lpDestBuf) { else curv = v; - sommab += cursrc[curv*RM_BBX + u] & 0x1F; - sommag += (cursrc[curv*RM_BBX + u] >> 5) & 0x1F; - sommar += (cursrc[curv*RM_BBX + u] >> 10) & 0x1F; + sommab += cursrc[curv * RM_BBX + u] & 0x1F; + sommag += (cursrc[curv * RM_BBX + u] >> 5) & 0x1F; + sommar += (cursrc[curv * RM_BBX + u] >> 10) & 0x1F; } } rgb[k + 0] = (byte) (sommab * 8 / (dezoom * dezoom)); diff --git a/engines/tony/window.h b/engines/tony/window.h index 9483f693ab..73cc6d2005 100644 --- a/engines/tony/window.h +++ b/engines/tony/window.h @@ -78,21 +78,21 @@ public: RMWindow(); ~RMWindow(); - // Initialization + // Initialisation void Init(/*HINSTANCE hInst*/); void InitDirectDraw(void); void Close(void); - // Repaint grafico tramite DirectDraw + // Drawing void Repaint(void); - // Switch tra windowed e fullscreen + // Switch between windowed and fullscreen void SwitchFullscreen(bool bFull) {} - // Legge il prossimo frame + // Reads the next frame void GetNewFrame(byte *lpBuf, Common::Rect *rcBoundEllipse); - // Avverte di grabbare un thumbnail per il salvataggio + // Request a thumbnail be grabbed during the next frame void GrabThumbnail(uint16 *buf); int getFps() const { return fps; } -- cgit v1.2.3 From 6f6486e5896d8af782aaba408b1fe5ae53021c7f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 20 May 2012 13:56:33 +1000 Subject: TONY: Endian fix --- engines/tony/loc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 722116c47c..ef59b3f916 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -1923,7 +1923,7 @@ void RMGameBoxes::LoadState(byte *state) { int nloc, nbox; // Load number of items - nloc = *(int*)state; + nloc = READ_LE_UINT32(state); state += 4; assert(nloc <= m_nLocBoxes); -- cgit v1.2.3 From 8b9831a50250ccc6b605058a702bb5f617a83978 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 20 May 2012 15:28:48 +1000 Subject: TONY: Converting Italian comments to English and formatting --- engines/tony/font.cpp | 191 ++++++++++++++---------------- engines/tony/font.h | 81 ++++++------- engines/tony/game.cpp | 68 +++++------ engines/tony/game.h | 9 +- engines/tony/gfxcore.cpp | 285 ++++++++++++++++++++------------------------- engines/tony/gfxcore.h | 32 ++--- engines/tony/gfxengine.cpp | 86 +++++++------- engines/tony/globals.h | 8 +- engines/tony/inventory.cpp | 92 +++++++-------- engines/tony/inventory.h | 50 ++++---- 10 files changed, 424 insertions(+), 478 deletions(-) (limited to 'engines') diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 91d6708a20..972bd081bf 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -37,7 +37,7 @@ namespace Tony { /****************************************************************************\ -* Metodi di RMFont +* RMFont Methods \****************************************************************************/ RMFont::RMFont() { @@ -48,15 +48,13 @@ RMFont::~RMFont() { Unload(); } -/****************************************************************************\ -* -* Function: void RMFont::Load(byte *buf, int nChars, int dimx, int dimy); -* -* Description: Carica un font da buffer -* -* Input: byte *buf Buffer contenente il font -* int nChars Numero di caratteri (max 256) -* int dimx,dimy Dimensione in pixel di un carattere + +/** + * Dumps a font to a buffer + * @param buf Buffer contenente il font + * @param nChars Numero di caratteri (max 256) + * @param dimx X dimension in pixels + * @param dimy Y dimension in pixels * \****************************************************************************/ @@ -84,9 +82,9 @@ void RMFont::Load(const byte *buf, int nChars, int dimx, int dimy, uint32 palRes } #endif - // Carichiamoce 'sto font + // Initialisation the fonts for (int i = 0; i < nChars; i++) { - // Inizializza il buffer con le lettere + // Initialise the buffer with the letters m_letter[i].Init(buf + i * (dimx * dimy + 8) + 8, dimx, dimy); m_letter[i].LoadPaletteWA(palResID); } @@ -118,15 +116,15 @@ RMGfxPrimitive *RMFont::MakeLetterPrimitive(byte bChar, int &nLength) { RMFontPrimitive *prim; int nLett; - // Converte da carattere a lettera + // Convert from character to glyph index nLett = ConvertToLetter(bChar); assert(nLett < nLetters); - // Crea la primitiva per il font + // Create primitive font prim = new RMFontPrimitive(this); prim->m_nChar = nLett; - // Si fa' dare la lunghezza della lettera in pixel + // Get the length of the character in pixels nLength = LetterLength(bChar); return prim; @@ -140,7 +138,7 @@ void RMFont::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim2) CORO_BEGIN_CODE(_ctx); - // Richiama la Draw della lettera assegnata alla primitiva + // Call the draw method of the letter assigned to the primitive if (prim->m_nChar != -1) CORO_INVOKE_2(m_letter[prim->m_nChar].Draw, bigBuf, prim); @@ -190,7 +188,7 @@ void RMFontColor::SetBaseColor(byte r1, byte g1, byte b1) { int i; byte pal[768 * 3]; - // Controlla se siamo gia' sul colore giusto + // Check if we are already on the right colour if (m_r == r1 && m_g == g1 && m_b == b1) return; @@ -198,7 +196,7 @@ void RMFontColor::SetBaseColor(byte r1, byte g1, byte b1) { m_g = g1; m_b = b1; - // Costruisce la nuova palette per il font + // Constructs a new paletter for the font for (i = 1; i < 16; i++) { pal[i * 3 + 0] = r >> 16; pal[i * 3 + 1] = g >> 16; @@ -213,20 +211,20 @@ void RMFontColor::SetBaseColor(byte r1, byte g1, byte b1) { pal[15 * 3 + 1] += 8; pal[15 * 3 + 2] += 8; - // La mette in tutte le lettere + // Puts in all the letters for (i = 0; i < nLetters; i++) m_letter[i].LoadPaletteWA(pal); } /***************************************************************************\ -* Metodi di RMFontParla +* RMFontParla Methods \****************************************************************************/ void RMFontParla::Init(void) { int i; - // bernie: numero di caratteri nel font + // bernie: Number of characters in the font int nchars = 112 // base + 18 // polish @@ -237,7 +235,7 @@ void RMFontParla::Init(void) { Load(RES_F_PARL, nchars, 20, 20); - // Inizializziamo le tabelline del cazzo + // Initialise the f**king table lDefault = 13; hDefault = 18; Common::fill(&l2Table[0][0], &l2Table[0][0] + (256 * 256), '\0'); @@ -265,9 +263,9 @@ void RMFontParla::Init(void) { cTable['<'] = 69; cTable['>'] = 70; cTable['!'] = 71; - //cTable['!'] = 72; Esclamativo alla rovescia + //cTable['!'] = 72; Exclamation countdown cTable['?'] = 73; - //cTable['?'] = 74; Interrogativo alla rovescia + //cTable['?'] = 74; Question down cTable['('] = 75; cTable[')'] = 76; cTable['\"'] = 77; @@ -295,20 +293,20 @@ void RMFontParla::Init(void) { cTable[(byte)''] = 97; cTable[(byte)''] = 98; cTable[(byte)''] = 99; - //cTable[' '] = 100; e cerchietto - //cTable[' '] = 101; i cerchietto - //cTable[' '] = 102; o cerchietto - //cTable[' '] = 103; u cerchietto + //cTable[' '] = 100; e circlet + //cTable[' '] = 101; i circlet + //cTable[' '] = 102; o circlet + //cTable[' '] = 103; u circlet cTable[(byte)''] = 104; cTable[(byte)''] = 105; cTable[(byte)''] = 106; cTable[(byte)''] = 107; cTable[(byte)''] = 108; cTable[(byte)''] = 109; - //cTable[''] = 110; integrale + //cTable[''] = 110; integral cTable['\''] = 111; - // Un po' di lunghezze + // Little lengths lTable[' '] = 9; lTable['\''] = 5; lTable['.'] = 5; @@ -387,9 +385,9 @@ void RMFontParla::Init(void) { } else if (_vm->getLanguage() == Common::RU_RUS) { // Russian Characters - // WARNING: Il russo usa molti dei caratteri ISO-Latin-1 che servono - // per le altre traduzioni. Per compilare Tony in altre lingue, - // commentare via queste definizioni. + // WARNING: The Russian font uses many of the ISO-Latin-1 font, + // allowing for further translations. To support Tonyin other langauges, + // these mappings could be used as a basis cTable[(byte)''] = 130; cTable[(byte)''] = 131; @@ -627,13 +625,13 @@ void RMFontParla::Init(void) { /***************************************************************************\ -* Metodi di RMFontMacc +* RMFontMacc Methods \****************************************************************************/ void RMFontMacc::Init(void) { int i; - // bernie: numero di caratteri nel font + // bernie: Number of characters in the font int nchars = 102 // base + 18 // polish @@ -693,16 +691,16 @@ void RMFontMacc::Init(void) { cTable[(byte)''] = 88; cTable[(byte)''] = 89; cTable[(byte)''] = 90; - //cTable[(byte)''] = 91; // e col pallino + //cTable[(byte)''] = 91; // e with ball cTable[(byte)''] = 92; cTable[(byte)''] = 93; - //cTable[(byte)''] = 94; // i col pallino + //cTable[(byte)''] = 94; // i with ball cTable[(byte)''] = 95; cTable[(byte)''] = 96; - //cTable[(byte)''] = 97; // o col pallino + //cTable[(byte)''] = 97; // o with ball cTable[(byte)''] = 98; cTable[(byte)''] = 99; - //cTable[(byte)''] = 100; // u col pallino + //cTable[(byte)''] = 100; // u with ball cTable[(byte)''] = 101; if (_vm->getLanguage() == Common::PL_POL) { @@ -750,10 +748,9 @@ void RMFontMacc::Init(void) { } else if (_vm->getLanguage() == Common::RU_RUS) { // Russian Characters - // WARNING: Il russo usa molti dei caratteri ISO-Latin-1 che servono - // per le altre traduzioni. Per compilare Tony in altre lingue, - // commentare via queste definizioni. - + // WARNING: The Russian font uses many of the ISO-Latin-1 font, + // allowing for further translations. To support Tonyin other langauges, + // these mappings could be used as a basis cTable[(byte)''] = 120; cTable[(byte)''] = 121; cTable[(byte)''] = 122; @@ -992,13 +989,13 @@ void RMFontMacc::Init(void) { } /***************************************************************************\ -* Metodi di RMFontCredits +* RMFontCredits Methods \****************************************************************************/ void RMFontCredits::Init(void) { int i; - // bernie: numero di caratteri nel font + // bernie: Number of characters in the font int nchars = 112 // base + 18 // polish @@ -1200,12 +1197,10 @@ void RMFontCredits::Init(void) { lTable[(byte)''] = 10; } else if (_vm->getLanguage() == Common::RU_RUS) { - // Russian Characters - // WARNING: Il russo usa molti dei caratteri ISO-Latin-1 che servono - // per le altre traduzioni. Per compilare Tony in altre lingue, - // commentare via queste definizioni. - + // WARNING: The Russian font uses many of the ISO-Latin-1 font, + // allowing for further translations. To support Tonyin other langauges, + // these mappings could be used as a basis cTable[(byte)''] = 130; cTable[(byte)''] = 131; cTable[(byte)''] = 132; @@ -1465,7 +1460,7 @@ void RMFontObj::SetBothCase(int nChar, int nNext, signed char spiazz) { void RMFontObj::Init(void) { int i; - //bernie: numero di caratteri nel font (solo maiuscolo) + //bernie: Number of characters in the font (solo maiuscolo) int nchars = 85 // base + 9 // polish @@ -1477,7 +1472,7 @@ void RMFontObj::Init(void) { Load(RES_F_OBJ, nchars, 25, 30); - // Inizializziamo le tabelline del cazzo + // Initialise the f**king table lDefault = 26; hDefault = 30; Common::fill(&l2Table[0][0], &l2Table[0][0] + (256 * 256), '\0'); @@ -1502,7 +1497,7 @@ void RMFontObj::Init(void) { cTable['-'] = 40; cTable['+'] = 41; cTable['!'] = 42; - // cTable['!'] = 43; Esclamativo alla rovescia + // cTable['!'] = 43; Exclamation countdown cTable['?'] = 44; //cTable['?'] = 45; Interrogativo alla rovescia cTable['/'] = 46; @@ -1523,7 +1518,7 @@ void RMFontObj::Init(void) { cTable[(byte)''] = 61; cTable[(byte)''] = 62; cTable[(byte)''] = 63; - //cTable[(byte)''] = 64; integrale + //cTable[(byte)''] = 64; integral cTable[(byte)''] = 65; cTable[(byte)''] = 66; cTable[(byte)''] = 67; @@ -1533,19 +1528,19 @@ void RMFontObj::Init(void) { cTable[(byte)''] = 71; cTable[(byte)''] = 72; cTable[(byte)''] = 73; - //cTable[(byte)' '] = 74; e cerchietto + //cTable[(byte)' '] = 74; e circlet cTable[(byte)''] = 75; cTable[(byte)''] = 76; - //cTable[(byte)' '] = 77; i cerchietto + //cTable[(byte)' '] = 77; i circlet cTable[(byte)''] = 78; cTable[(byte)''] = cTable[(byte)''] = 79; - //cTable[(byte)' '] = 80; o cerchietto + //cTable[(byte)' '] = 80; o circlet cTable[(byte)''] = 81; cTable[(byte)''] = cTable[(byte)''] = 82; - //cTable[' '] = 83; u cerchietto + //cTable[' '] = 83; u circlet //cTable[' '] = 84; y dieresi - /* Un po' di lunghezze */ + /* Little lengths */ lTable[' '] = 11; lTable['.'] = 8; lTable['-'] = 12; @@ -1635,9 +1630,9 @@ void RMFontObj::Init(void) { } else if (_vm->getLanguage() == Common::RU_RUS) { // Russian Characters - // WARNING: Il russo usa molti dei caratteri ISO-Latin-1 che servono - // per le altre traduzioni. Per compilare Tony in altre lingue, - // commentare via queste definizioni. + // WARNING: The Russian font uses many of the ISO-Latin-1 font, + // allowing for further translations. To support Tonyin other langauges, + // these mappings could be used as a basis cTable[(byte)''] = cTable[(byte)''] = 85; lTable[(byte)''] = lTable[(byte)''] = 20; @@ -1749,7 +1744,7 @@ void RMFontObj::Init(void) { } else if (_vm->getLanguage() == Common::FR_FRA) { // French - // traduci le lettere accentate in lettere normali + // Translate accented characters as normal letters cTable[(byte)''] = cTable[(byte)''] = cTable[(byte)''] = 0; // a lTable[(byte)''] = lTable[(byte)''] = lTable[(byte)''] = 17; @@ -1778,7 +1773,7 @@ void RMFontObj::Init(void) { /****************************************************************************\ -* Metodi di RMText +* RMText Methods \****************************************************************************/ RMFontColor *RMText::m_fonts[4] = { NULL, NULL, NULL, NULL }; @@ -1789,10 +1784,10 @@ void RMText::InitStatics() { } RMText::RMText() { - // Colore di default: bianco + // Default colour: white m_r = m_g = m_b = 255; - // Lunghezza di default + // Default length maxLineLength = 350; m_bTrasp0 = true; @@ -1820,14 +1815,13 @@ void RMText::SetMaxLineLength(int max) { } void RMText::RemoveThis(CORO_PARAM, bool &result) { -// Qui possiamo fare i controlli sul numero di frame, sul tempo trascorso -// etc. + // Here we can do checks on the number of frames, time spent, etc. result = true; } void RMText::WriteText(const RMString &text, int nFont, int *time) { - // Inizializza i font (una volta sola) + // Initialises the font (only once) if (m_fonts[0] == NULL) { m_fonts[0] = new RMFontParla; m_fonts[0]->Init(); @@ -1853,18 +1847,18 @@ void RMText::WriteText(const RMString &text, RMFontColor *font, int *time) { char *string; int numlines; - // Setta il colore di base + // Set the base colour font->SetBaseColor(m_r, m_g, m_b); - // Si autodistrugge il buffer prima di iniziare + // Destroy the buffer before starting Destroy(); - // Se la stringa vuota, non fare nulla + // If the string is empty, do nothing if (text == NULL || text[0] == '\0') return; - // Divide la frase in linee. In questo ciclo, X contiene la lunghezza massima raggiunta da una linea - // e I il numero delle linee + // Divide the words into lines. In this cycle, X contains the maximum length reached by a line, + // and the number of lines string = p = text; i = j = x = 0; while (*p != '\0') { @@ -1873,14 +1867,11 @@ void RMText::WriteText(const RMString &text, RMFontColor *font, int *time) { j -= font->StringLen(*p, p[1]); if (j > x) x = j; - // Torna indietro al primo spazio utile + // Back to the first usable space // - // BERNIE: nella versione originale le frasi contenenti - // parole che superano la larghezza di una riga causavano - // l'interruzione dell'intera frase. - // Questo workaround e' parziale: la parola troppo lunga - // viene spezzata bruscamente e si perde una lettera. - // Oltre allo spazio e' ammesso il wrap sul carattere '-'. + // BERNIE: In the original, sentences containing words that exceed the + // width of a line caused discontinuation of the whole sentence. + // This workaround has the partial word broken up so it will still display // old_p = p; while (*p != ' ' && *p != '-' && p > string) p--; @@ -1888,7 +1879,7 @@ void RMText::WriteText(const RMString &text, RMFontColor *font, int *time) { if (p == string) p = old_p; - // Controlla se sono tutti spazi fino alla fine + // Check if there are any blanks to end while (*p == ' ' && *p != '\0') p++; if (*p == '\0') break; @@ -1905,15 +1896,13 @@ void RMText::WriteText(const RMString &text, RMFontColor *font, int *time) { i++; numlines = i; - // X=Lunghezza della linea piu' lunga. Controlla se puo' essere puttata a X1 - //x+=font->StringLen(-1)+1; // Meglio esagerare per sicurezza x += 8; - // Posizione di partenza per la surface: X1,Y + // Starting position for the surface: X1, Y width = x; height = (numlines - 1) * font->LetterHeight() + font->m_fontDimy; - // Crea la surface + // Create the surface Create(width, height); //AddPrim(new RMGfxPrimitive(&m_clear)); Common::fill(m_buf, m_buf + width * height * 2, 0); @@ -1923,7 +1912,7 @@ void RMText::WriteText(const RMString &text, RMFontColor *font, int *time) { y = 0; numchar = 0; for (; i > 0; i--) { - // Misura la lunghezza della linea + // Measure the length of the line x = 0; j = font->StringLen(RMString(p)); @@ -1974,7 +1963,7 @@ void RMText::WriteText(const RMString &text, RMFontColor *font, int *time) { } void RMText::ClipOnScreen(RMGfxPrimitive *prim) { - // Cerca di non farlo uscire dallo schermo + // Don't let it go outside the screen if (prim->Dst().x1 < 5) prim->Dst().x1 = 5; if (prim->Dst().y1 < 5) prim->Dst().y1 = 5; if (prim->Dst().x1 + m_dimx > 635) prim->Dst().x1 = 635 - m_dimx; @@ -1986,14 +1975,14 @@ void RMText::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - // Allinea orizzontalmente + // Horizontally if (aHorType == HCENTER) prim->Dst().TopLeft() -= RMPoint(m_dimx / 2, 0); else if (aHorType == HRIGHT) prim->Dst().TopLeft() -= RMPoint(m_dimx, 0); - // Alinea verticalemente + // Vertically if (aVerType == VTOP) { } else if (aVerType == VCENTER) { @@ -2011,7 +2000,7 @@ void RMText::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { } /****************************************************************************\ -* Metodi di RMTextDialog +* RMTextDialog Methods \****************************************************************************/ RMTextDialog::RMTextDialog() : RMText() { @@ -2028,7 +2017,7 @@ RMTextDialog::RMTextDialog() : RMText() { hCustomSkip2 = CORO_INVALID_PID_VALUE; m_input = NULL; - // Crea l'evento di fine displaying + // Create the event for displaying the end hEndDisplay = CoroScheduler.createEvent(false, false); } @@ -2093,7 +2082,7 @@ void RMTextDialog::RemoveThis(CORO_PARAM, bool &result) { // Presume successful result result = true; - // Frase NON di background + // Don't erase the background if (m_bSkipStatus) { if (!(GLOBALS.bCfgDubbing && hCustomSkip2 != CORO_INVALID_PID_VALUE)) if (GLOBALS.bCfgTimerizedText) { @@ -2111,7 +2100,7 @@ void RMTextDialog::RemoveThis(CORO_PARAM, bool &result) { if (m_input->MouseLeftClicked() || m_input->MouseRightClicked()) return; } - // Frase di background + // Erase the background else { if (!(GLOBALS.bCfgDubbing && hCustomSkip2 != CORO_INVALID_PID_VALUE)) if (!m_bForceNoTime) @@ -2119,7 +2108,7 @@ void RMTextDialog::RemoveThis(CORO_PARAM, bool &result) { return; } - // Se il tempo forzato + // If time is forced if (m_bForceTime) if (_vm->GetTime() > (uint32)m_time + m_startTime) return; @@ -2185,7 +2174,7 @@ void RMTextDialog::SetInput(RMInput *input) { } /****************************************************************************\ -* Metodi di RMTextDialogScrolling +* RMTextDialogScrolling Methods \****************************************************************************/ RMTextDialogScrolling::RMTextDialogScrolling() { @@ -2298,7 +2287,7 @@ void RMTextItemName::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive if (m_buf == NULL) return; - // Setta come coordinate destinazione quelle del mouse + // Set the destination coordinates of the mouse prim->Dst().TopLeft() = m_mpos - RMPoint(0, 30); CORO_INVOKE_2(RMText::Draw, bigBuf, prim); @@ -2327,7 +2316,7 @@ bool RMTextItemName::IsNormalItemSelected() { /****************************************************************************\ -* Metodi di RMDialogChoice +* RMDialogChoice Methods \****************************************************************************/ RMDialogChoice::RMDialogChoice() { @@ -2388,11 +2377,11 @@ void RMDialogChoice::SetNumChoices(int num) { m_numChoices = num; m_curAdded = 0; - // Alloca lo spazio per le stringhe disegnate + // Allocate space for drawn strings m_drawedStrings = new RMText[num]; m_ptDrawStrings = new RMPoint[num]; - // Le inizializza + // Initialisation for (i = 0; i < m_numChoices; i++) { m_drawedStrings[i].SetColor(0, 255, 0); m_drawedStrings[i].SetAlignType(RMText::HLEFTPAR, RMText::VTOP); @@ -2402,7 +2391,7 @@ void RMDialogChoice::SetNumChoices(int num) { } void RMDialogChoice::AddChoice(const RMString &string) { - // Si disegna la stringa + // Draw the string assert(m_curAdded < m_numChoices); m_drawedStrings[m_curAdded++].WriteText(string, 0); } diff --git a/engines/tony/font.h b/engines/tony/font.h index dab07b79b3..b7488399a4 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -43,7 +43,7 @@ class RMLocation; class RMPointer; /** - * Gestisce un font, in cui ha varie surface per ogni lettera + * Manages a font, in which there is a different surface for each letter */ class RMFont : public RMGfxTaskSetPrior { protected: @@ -68,18 +68,18 @@ private: }; protected: - // Caricamento del font + // Loads the font void Load(uint32 resID, int nChars, int dimx, int dimy, uint32 palResID = RES_F_PAL); void Load(const byte *buf, int nChars, int dimx, int dimy, uint32 palResID = RES_F_PAL); - // Scaricamente del font (anche da distruttore) + // Remove the font void Unload(void); protected: - // Conversione (da overloadare) + // Conversion form character to font index virtual int ConvertToLetter(byte nChar) = 0; - // Lunghezza dei caratteri (da overloadare) + // Character width virtual int LetterLength(byte nChar, byte nNext = 0) = 0; public: @@ -89,17 +89,17 @@ public: RMFont(); virtual ~RMFont(); - // Inizializzazione e chiusura + // Initialisation and closing virtual void Init(void) = 0; virtual void Close(void); - // Funzione del task da overloadare + // Drawing virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBug, RMGfxPrimitive *prim); - // Crea una primitiva per una lettera + // Create a primitive for a letter RMGfxPrimitive *MakeLetterPrimitive(byte bChar, int &nLength); - // Lunghezza in pixel di una stringa con il font corrente + // Length in pixels of a string with the current font int StringLen(const RMString &text); int StringLen(char bChar, char bNext = 0); }; @@ -125,7 +125,7 @@ protected: signed char l2Table[256][256]; protected: - // Overload dei metodi + // Overloaded methods int ConvertToLetter(byte nChar) { return cTable[nChar]; } @@ -170,7 +170,7 @@ public: }; /** - * Gestisce una scritta su schermo, con tutte le possibilita' di formattazione disponibile + * Manages writing text onto9 the screen */ class RMText : public RMGfxWoodyBuffer { private: @@ -206,27 +206,26 @@ public: static void InitStatics(); static void Unload(); - // Setta il tipo di allineamento + // Set the alignment type void SetAlignType(HORALIGN aHor, VERALIGN aVer) { aHorType = aHor; aVerType = aVer; } - // Setta la lunghezza massima di una linea in pixel (utilizzato per formattare il testo) + // Sets the maximum length of a line in pixels (used to format the text) void SetMaxLineLength(int max); - // Scrive un testo + // Write the text void WriteText(const RMString &text, int font, int *time = NULL); void WriteText(const RMString &text, RMFontColor *font, int *time = NULL); - // Overloading della funzione ereditata da RMGfxTask per decidere - // quando eliminare un oggetto dalla OTLIST + // Overloaded function to decide when you delete the object from the OT list virtual void RemoveThis(CORO_PARAM, bool &result); - // Overloading del Draw per centrare la scritta, se necessario + // Overloading of the Draw to center the text, if necessary virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - // Setta il colore di base + // Set the base colour void SetColor(byte r, byte g, byte b) { m_r = r; m_g = g; @@ -235,7 +234,7 @@ public: }; /** - * Gestisce il testo di un dialogo + * Manages text in a dialog */ class RMTextDialog : public RMText { protected: @@ -257,27 +256,25 @@ public: RMTextDialog(); virtual ~RMTextDialog(); - // Scrive un testo + // Write the text void WriteText(const RMString &text, int font, int *time = NULL); void WriteText(const RMString &text, RMFontColor *font, int *time = NULL); - // Overloading della funzione ereditata da RMGfxTask per decidere - // quando eliminare un oggetto dalla OTLIST + // Overloaded function to decide when you delete the object from the OT list virtual void RemoveThis(CORO_PARAM, bool &result); - // Overloading della funzione di deregistrazione, utilizzata per capire - // quando ci leviamo di torno + // Overloaded de-registration virtual void Unregister(void); - // Overloading del Draw per centrare la scritta, se necessario + // Overloading of the Draw to center the text, if necessary virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - // Setta la posizione + // Set the position void SetPosition(const RMPoint &pt) { dst = pt; } - // Aspetta che venga finita la visualizzazione + // Waiting void WaitForEndDisplay(CORO_PARAM); void SetCustomSkipHandle(uint32 hCustomSkip); void SetCustomSkipHandle2(uint32 hCustomSkip); @@ -288,7 +285,7 @@ public: void ForceNoTime(void); void SetAlwaysDisplay(void); - // Setta il dispositivo di input, per permettere skip da mouse + // Set the input device, to allow skip from mouse void SetInput(RMInput *input); void Show(void); @@ -311,12 +308,9 @@ public: }; -/****************************************************************************\ -* class RMTextItemName -* -------------------- -* Description: Gestisce il nome dell'oggetto selezionato su schermo -\****************************************************************************/ - +/** + * Manages the name of a selected item on the screen + */ class RMTextItemName : protected RMText { protected: RMPoint m_mpos; @@ -373,31 +367,30 @@ public: void Unregister(void); public: - // Inizializzazione + // Initialisation RMDialogChoice(); virtual ~RMDialogChoice(); - // Inizializzazione e chiusura + // Initialisation and closure void Init(void); void Close(void); - // Setta il numero delle frasi possibili, che dovranno essere poi aggiunte - // con AddChoice() + // Sets the number of possible sentences, which then be added with AddChoice() void SetNumChoices(int num); - // Aggiunge una stringa con la scelta + // Adds a string with the choice void AddChoice(const RMString &string); - // Mostra e nasconde la scelta, con eventuali animazioni - // NOTA: Se non viene passato parametro alla Show(), obbligo del - // chiamante assicurarsi che la classe venga inserita alla OTlist + // Show and hide the selection, with possible animations. + // NOTE: If no parameter is passed to Show(), it is the obligation of + // caller to ensure that the class is inserted into OT list void Show(CORO_PARAM, RMGfxTargetBuffer *bigBuf = NULL); void Hide(CORO_PARAM); - // Polling di aggiornamento + // Polling Update void DoFrame(CORO_PARAM, RMPoint ptMousePos); - // Ritorna la voce attualmente selezionata, o -1 se nessuna selezionata + // Returns the currently selected item, or -1 if none is selected int GetSelection(void); }; diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 3551f55c83..4fe1ea374e 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -43,7 +43,7 @@ namespace Tony { using namespace MPAL; /****************************************/ -/* Funzioni globali per la DLL Custom */ +/* Global functions */ /****************************************/ uint32 MainLoadLocation(int nLoc, RMPoint pt, RMPoint start) { @@ -119,7 +119,7 @@ void MainSetPalesati(bool bPalesati) { } /****************************************************************************\ -* Metodi di RMOptionButton +* RMOptionButton Methods \****************************************************************************/ RMOptionButton::RMOptionButton(uint32 dwRes, RMPoint pt, bool bDoubleState) { @@ -192,7 +192,7 @@ void RMOptionButton::AddToList(RMGfxTargetBuffer &bigBuf) { } /****************************************************************************\ -* Metodi di RMOptionSlide +* RMOptionSlide Methods \****************************************************************************/ RMOptionSlide::RMOptionSlide(const RMPoint &pt, int nRange, int nStartValue, int slideSize) { @@ -240,7 +240,7 @@ RMOptionSlide::~RMOptionSlide() { bool RMOptionSlide::DoFrame(const RMPoint &mousePos, bool bLeftClick, bool bRightClick) { bool bRefresh = false; - // Doframe dei bottoni + // Do the button DoFrame's m_PushLeft->DoFrame(mousePos, bLeftClick, bRightClick); m_PushRight->DoFrame(mousePos, bLeftClick, bRightClick); @@ -317,7 +317,7 @@ void RMOptionSlide::AddToList(RMGfxTargetBuffer &bigBuf) { /****************************************************************************\ -* Metodi di RMOptionScreen +* RMOptionScreen Methods \****************************************************************************/ RMOptionScreen::RMOptionScreen(void) { @@ -983,7 +983,7 @@ bool RMOptionScreen::Close(void) { if (m_FadeStep != 6) return false; - // Inizia il fade out + // Start fade out m_FadeStep++; m_FadeTime = _vm->GetTime(); return true; @@ -994,7 +994,7 @@ bool RMOptionScreen::IsClosing(void) { } int RMOptionScreen::Priority() { - // Appena sotto il mouse + // Just below the mouse return 190; } @@ -1023,11 +1023,11 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { CORO_BEGIN_CODE(_ctx); - // Se non completamente aperto, non fare nulla + // If it is fully open, do nothing if (m_FadeStep != 6) return; - // Legge l'input + // Reads input _ctx->mousePos = input->MousePos(); _ctx->bLeftClick = input->MouseLeftClicked(); _ctx->bRightClick = input->MouseRightClicked(); @@ -1040,14 +1040,14 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { } else { _ctx->bRefresh |= m_ButtonExit->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - // Controlla se ha clickato sull'uscita + // Check if you have clicked on the output if (m_nState == MENUGAME || m_nState == MENUGFX || m_nState == MENUSOUND) { - // bottoni senza grafica... + // Buttons without graphics... m_ButtonGameMenu->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); m_ButtonGfxMenu->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); m_ButtonSoundMenu->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - // bottoni con grafica + // Buttons with graphics if (!m_bNoLoadSave) { if (!_vm->getIsDemo()) { _ctx->bRefresh |= m_ButtonLoad->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); @@ -1097,7 +1097,7 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { #define PROCESS_CHAR(cod,c) if (KEYPRESS(cod)) { \ m_EditName[strlen(m_EditName) +1 ] = '\0'; m_EditName[strlen(m_EditName)] = c; _ctx->bRefresh = true; } - /**************** STATO BOTTONI **************/ + /**************** State Buttons **************/ if (m_bEditSaveName) { if (KEYPRESS(Common::KEYCODE_BACKSPACE)) { if (m_EditName[0] != '\0') { @@ -1141,7 +1141,7 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { if (strlen(m_EditName) < 12) PROCESS_CHAR(Common::KEYCODE_KP9, '9'); - // ANNULLA + // Cancel if (KEYPRESS(Common::KEYCODE_ESCAPE)) { m_bEditSaveName = false; _ctx->bRefresh = true; @@ -1158,7 +1158,7 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { if (m_nState == MENULOAD || m_nState == MENUSAVE) { if (m_ButtonExit->IsActive()) { if (m_bLoadMenuOnly) { - // Se solo il menu di loading, chiudiamo + // If only the loading menu, close Close(); } else { CORO_INVOKE_1(ChangeState, m_nLastState); @@ -1183,13 +1183,13 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { } else { for (_ctx->i = 0; _ctx->i < 6; _ctx->i++) if (m_ButtonSave_States[_ctx->i]->IsActive()) { - // C' da effettuare il salvataggio o il caricamento!!!! + // There by saving or loading!!! if (m_nState == MENULOAD && m_curThumb[_ctx->i] != NULL) { // Caricamento CORO_INVOKE_1(_vm->LoadState, m_statePos + _ctx->i); Close(); } else if (m_nState == MENUSAVE && (m_statePos != 0 || _ctx->i != 0)) { - // Attiva la modalit di editing + // Turn on edit mode m_bEditSaveName = true; m_nEditPos = _ctx->i; strcpy(m_EditName, m_curThumbName[_ctx->i]); @@ -1241,7 +1241,7 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { } if (m_nState == MENUGFX) { - // Queste opzioni hanno effetto immediato + // These options take effect immediately if (m_ButtonGfx_Anni30->IsActive()) GLOBALS.bCfgAnni30 = true; else @@ -1288,7 +1288,7 @@ void RMOptionScreen::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive return; if (m_FadeStep == 1) { - // Discesa veloce + // Downhill fast if (m_FadeTime == -1) m_FadeY += FADE_SPEED; else @@ -1298,11 +1298,11 @@ void RMOptionScreen::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive m_FadeStep++; } - // Setta la parte da disegnare per lo scrolling + // Set the part to draw the scrolling prim->SetSrc(RMRect(0, 480 - m_FadeY, 640, 480)); } else if (m_FadeStep == 2) { - // Rimbalzo 1 + // Bounce 1 m_FadeY -= FADE_SPEED / 2 * SYNC; if (m_FadeY < 400) { m_FadeY = 400; @@ -1321,7 +1321,7 @@ void RMOptionScreen::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive prim->SetSrc(RMRect(0, 480 - m_FadeY, 640, 480)); } else if (m_FadeStep == 4) { - // Rimbalzo 1 - 2 + // Bounce 1 - 2 m_FadeY += FADE_SPEED / 3 * SYNC; if (m_FadeY > 420) { m_FadeY = 420; @@ -1357,11 +1357,11 @@ void RMOptionScreen::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive prim->SetSrc(RMRect(0, 480 - m_FadeY, 640, 480)); } else if (m_FadeStep == 9) { - // Ciao ciao! + // Hello hello! m_bExit = true; m_FadeStep = 0; - // Libera la memoria + // Free memory CloseState(); return; @@ -1391,7 +1391,7 @@ bool RMOptionScreen::LoadThumbnailFromSaveState(int nState, byte *lpDestBuf, RMS Common::InSaveFile *f; char id[4]; - // Pulisce la destinazione + // Cleans the destination Common::fill(lpDestBuf, lpDestBuf + 160 * 120 * 2, 0); name = "No name"; diff = 10; @@ -1463,7 +1463,7 @@ bool RMOptionScreen::LoadThumbnailFromSaveState(int nState, byte *lpDestBuf, RMS /****************************************************************************\ -* Metodi di RMPointer +* RMPointer Methods \****************************************************************************/ RMPointer::RMPointer() { @@ -1525,7 +1525,7 @@ void RMPointer::Close(void) { int RMPointer::Priority() { - // Priorita' minima: davanti a tutto + // Pointer has minimum priority so it will be drawn last return 200; } @@ -1536,15 +1536,15 @@ void RMPointer::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim CORO_BEGIN_CODE(_ctx); - // Controlla il pointer + // Check the pointer _ctx->n = m_nCurPointer; if (_ctx->n == TA_COMBINE) _ctx->n = TA_USE; - // Copia le coordinate di destinazione nella primitiva + // Copy the destination coordinates in the primitive prim->SetDst(m_pos); if (m_pos.x >= 0 && m_pos.y >= 0 && m_pos.x < RM_SX && m_pos.y < RM_SY) { - // Richiama il draw del puntatore + // Call the Draw method of the poitner prim->Dst() -= m_hotspot[_ctx->n]; if (m_nCurSpecialPointer == 0) { @@ -1553,7 +1553,7 @@ void RMPointer::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim if (m_nCurSpecialPointer == PTR_CUSTOM) CORO_INVOKE_2(m_nCurCustomPointer->Draw, bigBuf, prim); else - // Richiama il draw sul puntatore speciale + // Call the draw on the special pointer CORO_INVOKE_2(m_specialPointer[m_nCurSpecialPointer - 1]->Draw, bigBuf, prim); } } @@ -1562,16 +1562,16 @@ void RMPointer::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim } void RMPointer::DoFrame(RMGfxTargetBuffer *bigBuf) { - // Si aggiunge alla lista delle primitive + // Add it to the list of primitives bigBuf->AddPrim(new RMGfxPrimitive(this)); - // Se c'e' un puntatore speciale, fa la DoFrame + // If there is a special pointer, does DoFrame if (m_nCurSpecialPointer != 0 && m_nCurSpecialPointer != PTR_CUSTOM) m_specialPointer[m_nCurSpecialPointer - 1]->DoFrame(bigBuf, false); } void RMPointer::RemoveThis(CORO_PARAM, bool &result) { - // Si leva sempre dalla lista di OT, per supportare la DisableInput + // Always remove from the OT list, to support disabling the pointer result = true; } diff --git a/engines/tony/game.h b/engines/tony/game.h index 160637d9c2..532a457b8f 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -270,12 +270,12 @@ public: bool Close(); bool IsClosing(); - // Metodi in overloading da RMGfxTask - int Priority(); + // Overloaded methods + virtual int Priority(); virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); virtual void RemoveThis(CORO_PARAM, bool &result); - // Polling per l'option screen + // Polling for the option screen void DoFrame(CORO_PARAM, RMInput *m_input); // Retrieves a savegame's thumbnail, description, and difficulty level @@ -288,10 +288,9 @@ protected: void CloseState(void); void ChangeState(CORO_PARAM, STATE newState); - // Ridisegna tutto il menu delle opzioni + // Repaaint the options menu void RefreshAll(CORO_PARAM); void RefreshThumbnails(void); - }; } // End of namespace Tony diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index ae68860e79..8c992eb150 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -33,7 +33,7 @@ namespace Tony { /****************************************************************************\ -* Metodi di RMGfxTask +* RMGfxTask Methods \****************************************************************************/ RMGfxTask::RMGfxTask() { @@ -51,7 +51,7 @@ void RMGfxTask::RemoveThis(CORO_PARAM, bool &result) { /****************************************************************************\ -* Metodi di RMGfxTaskSetPrior +* RMGfxTaskSetPrior Methods \****************************************************************************/ void RMGfxTaskSetPrior::SetPriority(int nPrior) { @@ -60,7 +60,7 @@ void RMGfxTaskSetPrior::SetPriority(int nPrior) { /****************************************************************************\ -* Metodi di RMGfxBuffer +* RMGfxBuffer Methods \****************************************************************************/ RMGfxBuffer::RMGfxBuffer() { @@ -74,17 +74,17 @@ RMGfxBuffer::~RMGfxBuffer() { } void RMGfxBuffer::Create(int dimx, int dimy, int nBpp, bool bUseDDraw) { - // Distruggi il buffer se esiste di gia' + // Destroy the buffer it is already exists if (m_buf != NULL) Destroy(); - // Copia i parametri nei membri privati + // Copy the parameters in the private members m_dimx = dimx; m_dimy = dimy; m_bUseDDraw = bUseDDraw; if (!m_bUseDDraw) { - // Alloca il buffer + // Allocate a buffer m_origBuf = m_buf = new byte[m_dimx * m_dimy * nBpp / 8]; assert(m_buf != NULL); Common::fill(m_origBuf, m_origBuf + m_dimx * m_dimy * nBpp / 8, 0); @@ -102,13 +102,13 @@ void RMGfxBuffer::Destroy(void) { void RMGfxBuffer::Lock(void) { if (m_bUseDDraw) { - // Gestisce l'accelerazione + // Manages acceleration } } void RMGfxBuffer::Unlock(void) { if (m_bUseDDraw) { - // Gestisce l'accelerazione + // Manages acceleration } } @@ -130,26 +130,14 @@ RMGfxBuffer::RMGfxBuffer(int dimx, int dimy, int nBpp, bool bUseDDraw) { } /****************************************************************************\ -* Metodi di RMGfxSourceBuffer -\****************************************************************************/ - -/****************************************************************************\ -* -* Function: -* -* Description: -* -* Input: -* -* Return: -* +* RMGfxSourceBuffer Methods \****************************************************************************/ int RMGfxSourceBuffer::Init(const byte *buf, int dimx, int dimy, bool bLoadPalette) { Create(dimx, dimy, Bpp()); CopyMemory(m_buf, buf, dimx * dimy * Bpp() / 8); - // Richiama la funzione di preparazione della surface (ereditata) + // Invokes the method for preparing the surface (inherited) PrepareImage(); return dimx * dimy * Bpp() / 8; @@ -160,7 +148,7 @@ void RMGfxSourceBuffer::Init(RMDataStream &ds, int dimx, int dimy, bool bLoadPal Create(dimx, dimy, Bpp()); ds.Read(m_buf, dimx * dimy * Bpp() / 8); - // Richiama la funzione di preparazione della surface (ereditata) + // Invokes the method for preparing the surface (inherited) PrepareImage(); } @@ -168,7 +156,7 @@ RMGfxSourceBuffer::~RMGfxSourceBuffer() { } void RMGfxSourceBuffer::PrepareImage(void) { - // Non fa nulla: puo' essere overloadata se necessaria + // Do nothing. Can be overloaded if necessary } bool RMGfxSourceBuffer::Clip2D(int &x1, int &y1, int &u, int &v, int &width, int &height, bool bUseSrc, RMGfxTargetBuffer *buf) { @@ -226,23 +214,20 @@ bool RMGfxSourceBuffer::Clip2D(int &x1, int &y1, int &u, int &v, int &width, int return true; } -/****************************************************************************\ -* -* Function: void RMGfxSourceBuffer::Init(uint32 resID, int dimx, int dimy); -* -* Description: Carica una surface partendo dall'ID della risorsa -* -* Input: uint32 resID ID della risorsa -* int dimx, dimy Dimensione del buffer -* -\****************************************************************************/ -int RMGfxSourceBuffer::Init(uint32 resID, int dimx, int dimy, bool bLoadPalette) { +/** + * Initialises a surface by resource Id + * + * @param resID Resource ID + * @param dimx Buffer X dimension + * @param dimy Buffer Y dimension + */ + int RMGfxSourceBuffer::Init(uint32 resID, int dimx, int dimy, bool bLoadPalette) { return Init(RMRes(resID), dimx, dimy, bLoadPalette); } /****************************************************************************\ -* Metodi di RMGfxWoodyBuffer +* RMGfxWoodyBuffer Methods \****************************************************************************/ RMGfxWoodyBuffer::~RMGfxWoodyBuffer() { @@ -255,10 +240,10 @@ void RMGfxWoodyBuffer::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitiv CORO_BEGIN_CODE(_ctx); - // Prima si fa disegnare tramite la propria OT list + // Draw the OT list CORO_INVOKE_0(DrawOT); - // Poi disegna se stesso nel target buffer + // Draw itself into the target buffer CORO_INVOKE_2(RMGfxSourceBuffer16::Draw, bigBuf, prim); CORO_END_CODE; @@ -275,7 +260,7 @@ RMGfxWoodyBuffer::RMGfxWoodyBuffer(int dimx, int dimy, bool bUseDDraw) /****************************************************************************\ -* Metodi di RMGfxTargetBuffer +* RMGfxTargetBuffer Methods \****************************************************************************/ RMGfxClearTask RMGfxTargetBuffer::taskClear; @@ -325,37 +310,37 @@ void RMGfxTargetBuffer::DrawOT(CORO_PARAM) { _ctx->prev = NULL; _ctx->cur = otlist; - // Lock del buffer per accederci + // Lock the buffer to access it Lock(); // g_system->lockMutex(csModifyingOT); while (_ctx->cur != NULL) { - // Richiama la draw sul task, passandogli una copia della primitiva + // Call the task Draw method, passing it a copy of the original _ctx->myprim = _ctx->cur->prim->Duplicate(); CORO_INVOKE_2(_ctx->cur->prim->m_task->Draw, *this, _ctx->myprim); delete _ctx->myprim; - // Controlla se e' arrivato il momento di rimuovere il task dalla OTlist + // Check if it's time to remove the task from the OT list CORO_INVOKE_1(_ctx->cur->prim->m_task->RemoveThis, _ctx->result); if (_ctx->result) { - // Deregistra il task + // De-register the task _ctx->cur->prim->m_task->Unregister(); - // Cancella il task liberando la memoria + // Delete task, freeing the memory delete _ctx->cur->prim; _ctx->next = _ctx->cur->next; delete _ctx->cur; - // Se era il primo elemento, aggiorna la testa della lista + // If it was the first item, update the list head if (_ctx->prev == NULL) otlist = _ctx->next; - // Altrimenti aggiorna il puntatore al successivo dell'elemento precedente + // Otherwise update the next pinter of the previous item else _ctx->prev->next = _ctx->next; _ctx->cur = _ctx->next; } else { - // Aggiorna il puntatore al precedente e scorre la lista + // Update the pointer to the previous item, and the current to the next _ctx->prev = _ctx->cur; _ctx->cur = _ctx->cur->next; } @@ -363,7 +348,7 @@ void RMGfxTargetBuffer::DrawOT(CORO_PARAM) { // g_system->unlockMutex(csModifyingOT); - // Unlock dopo la scrittura + //Unlock after writing Unlock(); CORO_END_CODE; @@ -375,19 +360,19 @@ void RMGfxTargetBuffer::AddPrim(RMGfxPrimitive *prim) { // g_system->lockMutex(csModifyingOT); - // Avverte che e' in lista di OT + // Warn of the OT listing prim->m_task->Register(); - // Controlla la sua priorita' + // Check the priority nPrior = prim->m_task->Priority(); n = new OTList(prim); - // Lista vuota + // Empty list if (otlist == NULL) { otlist = n; otlist->next = NULL; } - // Inserimento in testa + // Inclusion in the head else if (nPrior < otlist->prim->m_task->Priority()) { n->next = otlist; otlist = n; @@ -409,7 +394,7 @@ void RMGfxTargetBuffer::AddClearTask(void) { /****************************************************************************\ -* Metodi di RMGfxSourceBufferPal +* RMGfxSourceBufferPal Methods \****************************************************************************/ RMGfxSourceBufferPal::~RMGfxSourceBufferPal() { @@ -458,10 +443,10 @@ void RMGfxSourceBufferPal::PreparePalette(void) { int RMGfxSourceBufferPal::Init(const byte *buf, int dimx, int dimy, bool bLoadPalette) { int read; - // Carica l'immagine RAW + // Load the RAW image read = RMGfxSourceBuffer::Init(buf, dimx, dimy); - // Carica la palette se necessario + // Load the palette if necessary if (bLoadPalette) read += LoadPaletteWA(&buf[read]); @@ -469,10 +454,10 @@ int RMGfxSourceBufferPal::Init(const byte *buf, int dimx, int dimy, bool bLoadPa } void RMGfxSourceBufferPal::Init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette) { - // Carica l'immagine RAW + // Load the RAW image RMGfxSourceBuffer::Init(ds, dimx, dimy); - // Carica la palette se necessario + // Load the palette if necessary if (bLoadPalette) { byte *suxpal = new byte[256 * 3]; ds.Read(suxpal, 256 * 3); @@ -490,7 +475,7 @@ int RMGfxSourceBufferPal::LoadPaletteWA(uint32 resID, bool bSwapped) { } /****************************************************************************\ -* Metodi di RMGfxSourceBuffer4 +* RMGfxSourceBuffer4 Methods \****************************************************************************/ void RMGfxSourceBuffer4::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { @@ -501,16 +486,12 @@ RMGfxSourceBuffer4::RMGfxSourceBuffer4(int dimx, int dimy, bool bUseDDraw) SetPriority(0); } -/****************************************************************************\ -* -* Function: int RMGfxSourceBuffer4::Bpp(); -* -* Description: Ritorna il numero di bit per pixel della surface -* -* Return: Bit per pixel -* -\****************************************************************************/ +/** + * Returns the number of bits per pixel of the surface + * + * @returns Bit per pixel + */ int RMGfxSourceBuffer4::Bpp() { return 4; } @@ -520,7 +501,7 @@ void RMGfxSourceBuffer4::Create(int dimx, int dimy, bool bUseDDraw) { } /****************************************************************************\ -* Metodi di RMGfxSourceBuffer8 +* RMGfxSourceBuffer8 Methods \****************************************************************************/ RMGfxSourceBuffer8::~RMGfxSourceBuffer8() { @@ -533,12 +514,12 @@ void RMGfxSourceBuffer8::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimit uint16 *buf = bigBuf; byte *raw = m_buf; - // Destination nel buffer + // Destination buffer RMRect dst; if (prim->HaveDst()) dst = prim->Dst(); - // Esegue il clip + // Clipping if (prim->HaveSrc()) { u = prim->Src().x1; v = prim->Src().y1; @@ -550,10 +531,10 @@ void RMGfxSourceBuffer8::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimit if (!Clip2D(dst.x1, dst.y1, u, v, width, height, prim->HaveSrc(), &bigBuf)) return; - // Offset iniziale nel buffer + // Starting offset into the buffer buf += dst.y1 * bufx + dst.x1; - // Passaggio normale + // Normal step if (m_bTrasp0) { for (y = 0; y < height; y++) { raw = m_buf + (y + v) * m_dimx + u; @@ -593,16 +574,11 @@ RMGfxSourceBuffer8::RMGfxSourceBuffer8(bool bTrasp0) { } -/****************************************************************************\ -* -* Function: int RMGfxSourceBuffer8::Bpp(); -* -* Description: Ritorna il numero di bit per pixel della surface -* -* Return: Bit per pixel -* -\****************************************************************************/ - +/** + * Returns the number of bits per pixel of the surface + * + * @returns Bit per pixel + */ int RMGfxSourceBuffer8::Bpp() { return 8; } @@ -617,7 +593,7 @@ void RMGfxSourceBuffer8::Create(int dimx, int dimy, bool bUseDDraw) { /****************************************************************************\ -* Metodi di RMGfxSourceBuffer8AB +* RMGfxSourceBuffer8AB Methods \****************************************************************************/ RMGfxSourceBuffer8AB::~RMGfxSourceBuffer8AB() { @@ -645,12 +621,12 @@ void RMGfxSourceBuffer8AB::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrim uint16 *buf = bigBuf; byte *raw = m_buf; - // Destination nel buffer + // Destination buffer RMRect dst; if (prim->HaveDst()) dst = prim->Dst(); - // Esegue il clip + // Clipping if (prim->HaveSrc()) { u = prim->Src().x1; v = prim->Src().y1; @@ -662,7 +638,7 @@ void RMGfxSourceBuffer8AB::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrim if (!Clip2D(dst.x1, dst.y1, u, v, width, height, prim->HaveSrc(), &bigBuf)) return; - // Offset iniziale nel buffer + // Starting offset into the buffer buf += dst.y1 * bufx + dst.x1; // Passaggio normale @@ -700,7 +676,7 @@ void RMGfxSourceBuffer8AB::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrim /****************************************************************************\ -* Metodi di RMGfxSourceBuffer8RLE +* RMGfxSourceBuffer8RLE Methods \****************************************************************************/ byte RMGfxSourceBuffer8RLE::MegaRLEBuf[512 * 1024]; @@ -743,10 +719,10 @@ void RMGfxSourceBuffer8RLE::Init(RMDataStream &ds, int dimx, int dimy, bool bLoa } void RMGfxSourceBuffer8RLE::PreparePalette(void) { - // Richiama il metodo padre + // Invoke the parent method RMGfxSourceBuffer8::PreparePalette(); - // Si salva gli RGB di alpha blending + // Handle RGB alpha blending if (alphaBlendColor != -1) { alphaR = (m_palFinal[alphaBlendColor] >> 10) & 0x1F; alphaG = (m_palFinal[alphaBlendColor] >> 5) & 0x1F; @@ -755,10 +731,10 @@ void RMGfxSourceBuffer8RLE::PreparePalette(void) { } void RMGfxSourceBuffer8RLE::PrepareImage(void) { - // Richiama il metodo padre + // Invoke the parent method RMGfxSourceBuffer::PrepareImage(); - // Comprime + // Compress CompressRLE(); } @@ -776,17 +752,17 @@ void RMGfxSourceBuffer8RLE::CompressRLE(void) { byte *startsrc; int rep; - // Esegue la compressione RLE, per linee + // Perform RLE compression for lines cur = MegaRLEBuf; src = m_buf; for (y = 0; y < m_dimy; y++) { - // Si salva l'inizio della linea + // Save the beginning of the line startline = cur; - // Lascia lo spazio per la lunghezza della linea + // Leave space for the length of the line cur += 2; - // Si parte dallo spazio vuoto + // It starts from the empty space curdata = 0; rep = 0; startsrc = src; @@ -813,7 +789,7 @@ void RMGfxSourceBuffer8RLE::CompressRLE(void) { } } - // Dati in sospeso? + // Pending data? if (curdata == 1) { RLEWriteAlphaBlend(cur, rep); RLEWriteData(cur, 0, NULL); @@ -823,17 +799,17 @@ void RMGfxSourceBuffer8RLE::CompressRLE(void) { RLEWriteData(cur, rep, startsrc); } - // Fine linea + // End of line RLEWriteEOL(cur); - // Scrive la lunghezza della linea + // Write the length of the line WRITE_LE_UINT16(startline, (uint16)(cur - startline)); } - // Cancella l'immagine originale + // Delete the original image delete[] m_buf; - // Ci copia l'immagine compressa + // Copy the compressed image x = cur - MegaRLEBuf; m_buf = new byte[x]; Common::copy(MegaRLEBuf, MegaRLEBuf + x, m_buf); @@ -845,27 +821,27 @@ void RMGfxSourceBuffer8RLE::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPri uint16 *buf = bigBuf; int x1, y1, u, v, width, height; - // Clippiamo lo sprite + // Clipping x1 = prim->Dst().x1; y1 = prim->Dst().y1; if (!Clip2D(x1, y1, u, v, width, height, false, &bigBuf)) return; - // Andiamo avanti di V linee nell'immagine RLE + // Go forward through the RLE lines src = m_buf; for (y = 0; y < v; y++) src += READ_LE_UINT16(src); - // Posizionamoci nel buffer di destinazione + // Calculate the position in the destination buffer buf += y1 * bigBuf.Dimx(); - // Looppone + // Loop if (prim->IsFlipped()) { -// Annulliamo il clipping orizzontale +// Eliminate horizontal clipping // width = m_dimx; // x1=prim->Dst().x1; - // Flippiamo il clipping + // Clipping u = m_dimx - (width + u); x1 = (prim->Dst().x1 + m_dimx - 1) - u; @@ -873,21 +849,21 @@ void RMGfxSourceBuffer8RLE::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPri // Decompressione RLEDecompressLineFlipped(buf + x1, src + 2, u, width); - // Prossima linea + // Next line src += READ_LE_UINT16(src); - // Skippa alla linea successiva + // Skip to the next line buf += bigBuf.Dimx(); } } else { for (y = 0; y < height; y++) { - // Decompressione + // Decompression RLEDecompressLine(buf + x1, src + 2, u, width); - // Prossima linea + // Next line src += READ_LE_UINT16(src); - // Skippa alla linea successiva + // Skip to the next line buf += bigBuf.Dimx(); } } @@ -895,7 +871,7 @@ void RMGfxSourceBuffer8RLE::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPri /****************************************************************************\ -* Metodi di RMGfxSourceBuffer8RLEByte +* RMGfxSourceBuffer8RLEByte Methods \****************************************************************************/ RMGfxSourceBuffer8RLEByte::~RMGfxSourceBuffer8RLEByte() { @@ -981,7 +957,7 @@ void RMGfxSourceBuffer8RLEByte::RLEDecompressLine(uint16 *dst, byte *src, int nS while (1) { RLEByteDoTrasp: - // Via il trasp di merda + // Get the trasp of s**t n = *src++; // EOL? @@ -1018,7 +994,7 @@ RLEByteDoAlpha2: assert(nLength > 0); //RLEByteDoCopy: - // Copia la roba + // Copy the stuff n = *src++; RLEByteDoCopy2: @@ -1087,7 +1063,7 @@ void RMGfxSourceBuffer8RLEByte::RLEDecompressLineFlipped(uint16 *dst, byte *src, while (1) { RLEByteFlippedDoTrasp: - // Via il trasp di merda + // Get the trasp of s**t n = *src++; // EOL? @@ -1124,7 +1100,7 @@ RLEByteFlippedDoAlpha2: assert(nLength > 0); //RLEByteFlippedDoCopy: - // Copia la roba + // Copy the data n = *src++; RLEByteFlippedDoCopy2: @@ -1143,7 +1119,7 @@ RLEByteFlippedDoCopy2: /****************************************************************************\ -* Metodi di RMGfxSourceBuffer8RLEWord +* RMGfxSourceBuffer8RLEWord Methods \****************************************************************************/ RMGfxSourceBuffer8RLEWord::~RMGfxSourceBuffer8RLEWord() { @@ -1232,7 +1208,7 @@ void RMGfxSourceBuffer8RLEWord::RLEDecompressLine(uint16 *dst, byte *src, int nS while (1) { RLEWordDoTrasp: - // Via il trasp di merda + // Get the trasp of s**t n = READ_LE_UINT16(src); src += 2; @@ -1274,7 +1250,7 @@ RLEWordDoAlpha2: assert(nLength > 0); //RLEWordDoCopy: - // Copia la roba + // Copy the data n = READ_LE_UINT16(src); src += 2; @@ -1350,7 +1326,7 @@ void RMGfxSourceBuffer8RLEWord::RLEDecompressLineFlipped(uint16 *dst, byte *src, while (1) { RLEWordFlippedDoTrasp: - // Via il trasp di merda + // Get the trasp of s**t n = READ_LE_UINT16(src); src += 2; @@ -1392,7 +1368,7 @@ RLEWordFlippedDoAlpha2: assert(nLength > 0); //RLEWordFlippedDoCopy: - // Copia la roba + // Copy the data n = READ_LE_UINT16(src); src += 2; @@ -1480,7 +1456,7 @@ void RMGfxSourceBuffer8RLEWordAB::RLEDecompressLine(uint16 *dst, byte *src, int while (1) { RLEWordDoTrasp: - // Via il trasp di merda + // Get the trasp of s**t n = READ_LE_UINT16(src); src += 2; @@ -1503,7 +1479,7 @@ RLEWordDoAlpha2: if (n > nLength) n = nLength; - // @@@ NON DOVREBBE ESSERCI!!!!! + // @@@ SHOULD NOT BE THERE !!!!! for (i = 0; i < n; i++) { r = (*dst >> 10) & 0x1F; g = (*dst >> 5) & 0x1F; @@ -1523,7 +1499,7 @@ RLEWordDoAlpha2: assert(nLength > 0); //RLEWordDoCopy: - // Copia la roba + // Copy the data n = READ_LE_UINT16(src); src += 2; @@ -1566,22 +1542,22 @@ byte RMGfxSourceBuffer8AA::MegaAABuf[256 * 1024]; byte RMGfxSourceBuffer8AA::MegaAABuf2[64 * 1024]; void RMGfxSourceBuffer8AA::PrepareImage(void) { - // Richiama il metodo padre + // Invoke the parent method RMGfxSourceBuffer::PrepareImage(); - // Prepara il buffer di antialiasing + // Prepare the buffer for anti-aliasing CalculateAA(); } void RMGfxSourceBuffer8AA::CalculateAA(void) { - // Io suxo tu suxi egli suxa noi suxiamo voi suxate essi suxano ---> ANTI ALIASING SUX! + // I suck, you suck, he sucks, we suck, they all suck ---> ANTI ALIASING SUX! // ************************************************************ int x, y; byte *src, *srcaa; - /* Prima passata: cerchiamo i bordi */ + /* First pass: fill the edges */ Common::fill(MegaAABuf, MegaAABuf + m_dimx * m_dimy, 0); src = m_buf; @@ -1643,20 +1619,19 @@ void RMGfxSourceBuffer8AA::DrawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri int r, g, b; int step; - // Clippiamo lo sprite + // Clip the sprite x1 = prim->Dst().x1; y1 = prim->Dst().y1; if (!Clip2D(x1, y1, u, v, width, height, false, &bigBuf)) return; - // Andiamo avanti di V linee nell'immagine RLE + // Go forward through the RLE lines src = m_buf; for (y = 0; y < v; y++) src += READ_LE_UINT16(src); - // Annulliamo il clipping orizzontale + // Eliminate horizontal clipping - // Flippiamo il clipping if (prim->IsFlipped()) { u = m_dimx - (width + u); x1 = (prim->Dst().x1 + m_dimx - 1) - u; @@ -1665,7 +1640,7 @@ void RMGfxSourceBuffer8AA::DrawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri // x1=prim->Dst().x1; - // Posizionamoci nel buffer di destinazione + // Poisition into the destination buffer buf = bigBuf; buf += y1 * bigBuf.Dimx(); @@ -1674,8 +1649,8 @@ void RMGfxSourceBuffer8AA::DrawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri else step = 1; - // Looppone - buf += bigBuf.Dimx(); // skippa la prima linea + // Loop + buf += bigBuf.Dimx(); // Skip the first line for (y = 1; y < height - 1; y++) { /* if (prim->IsFlipped()) @@ -1705,11 +1680,11 @@ void RMGfxSourceBuffer8AA::DrawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri mybuf[0] = (r << 10) | (g << 5) | b; } - // Skippa alla linea successiva + // Skip to the next line buf += bigBuf.Dimx(); } -// Posizionamoci nel buffer di destinazione +// Position into the destination buffer buf = bigBuf; buf += y1 * bigBuf.Dimx(); @@ -1765,7 +1740,7 @@ void RMGfxSourceBuffer8AA::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrim /****************************************************************************\ -* Metodi di RMGfxSourceBuffer8RLEAA +* RMGfxSourceBuffer8RLEAA Methods \****************************************************************************/ RMGfxSourceBuffer8RLEByteAA::~RMGfxSourceBuffer8RLEByteAA() { @@ -1799,7 +1774,7 @@ void RMGfxSourceBuffer8RLEByteAA::Init(RMDataStream &ds, int dimx, int dimy, boo RMGfxSourceBuffer8RLE::Init(ds, dimx, dimy, bLoadPalette); if (!bNeedRLECompress) { - // Carica la maschera di antialiasing + // Load the anti-aliasing mask m_aabuf = new byte[dimx * dimy]; ds.Read(m_aabuf, dimx * dimy); } @@ -1845,7 +1820,7 @@ void RMGfxSourceBuffer8RLEWordAA::Init(RMDataStream &ds, int dimx, int dimy, boo /****************************************************************************\ -* Metodi di RMGfxSourceBuffer16 +* RMGfxSourceBuffer16 Methods \****************************************************************************/ RMGfxSourceBuffer16::RMGfxSourceBuffer16(bool bTrasp0) { @@ -1913,7 +1888,7 @@ void RMGfxSourceBuffer16::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimi } void RMGfxSourceBuffer16::PrepareImage(void) { - // Color space conversion se necessario! + // Colour space conversion if necessary! int i; uint16 *buf = (uint16 *)m_buf; @@ -1927,16 +1902,12 @@ RMGfxSourceBuffer16::RMGfxSourceBuffer16(int dimx, int dimy, bool bUseDDraw) SetPriority(0); } -/****************************************************************************\ -* -* Function: int RMGfxSourceBuffer16::Bpp(); -* -* Description: Ritorna il numero di bit per pixel della surface -* -* Return: Bit per pixel -* -\****************************************************************************/ +/** + * Returns the number of bits per pixel of the surface + * + * @returns Bit per pixel + */ int RMGfxSourceBuffer16::Bpp() { return 16; } @@ -1946,7 +1917,7 @@ void RMGfxSourceBuffer16::Create(int dimx, int dimy, bool bUseDDraw) { } /****************************************************************************\ -* Metodi di RMGfxBox +* RMGfxBox Methods \****************************************************************************/ void RMGfxBox::RemoveThis(CORO_PARAM, bool &result) { @@ -1965,11 +1936,11 @@ void RMGfxBox::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) uint16 *buf = bigBuf; RMRect rcDst; - // Prende il rettangolo di destinazione + // It takes the destination rectangle rcDst = prim->Dst(); buf += rcDst.y1 * bigBuf.Dimx() + rcDst.x1; - // Fa il suo bravo loop di put + // Loop through the pixels for (j = 0; j < rcDst.Height(); j++) { for (i = 0; i < rcDst.Width(); i++) *buf ++ = wFillColor; @@ -1980,21 +1951,21 @@ void RMGfxBox::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) /****************************************************************************\ -* Metodi di RMGfxClearTask +* RMGfxClearTask Methods \****************************************************************************/ int RMGfxClearTask::Priority() { - // Priorita' massima (deve essere fatto per primo) + // Maximum priority (must be done first) return 1; } void RMGfxClearTask::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *) { - // Pulisce tutto il target buffer + // Clean the target buffer Common::fill((byte *)bigBuf, (byte *)bigBuf + (bigBuf.Dimx() * bigBuf.Dimy() * 2), 0x0); } void RMGfxClearTask::RemoveThis(CORO_PARAM, bool &result) { - // Il task di clear si disattiva sempre + // The task is fine to be removed result = true; } diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index 1af13d9a66..f7ea40fa9b 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -39,13 +39,13 @@ namespace Tony { * Prototipi di classi \****************************************************************************/ -// Nome della classe Albero genealogico Astratto? -class RMGfxTask; // Si -class RMGfxTaskSetPrior; // Task Si +// Class Name Family Treee Abstract? +class RMGfxTask; // Yes +class RMGfxTaskSetPrior; // Task Yes class RMGfxBuffer; // -class RMGfxSourceBuffer; // TaskP+[Buffer] Si +class RMGfxSourceBuffer; // TaskP+[Buffer] Yes class RMGfxTargetBuffer; // [Buffer] -class RMGfxSourceBufferPal; // Source Si +class RMGfxSourceBufferPal; // Source Yes class RMGfxSourceBuffer4; // SourcePal class RMGfxSourceBuffer8; // SourcePal class RMGfxSourceBuffer16; // Source @@ -221,7 +221,7 @@ protected: int m_nInList; public: - // Costruttore standard + // Standard constructor RMGfxTask(); virtual ~RMGfxTask() { } @@ -284,7 +284,7 @@ public: */ class RMGfxSourceBuffer : public virtual RMGfxBuffer, public RMGfxTaskSetPrior { public: - // Carica i dati della surface a basso livello + // Load the data for the surface virtual int Init(uint32 resID, int dimx, int dimy, bool bLoadPalette = false); virtual int Init(const byte *buf, int dimx, int dimy, bool bLoadPalette = false); virtual void Init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette = false); @@ -316,7 +316,7 @@ public: RMGfxSourceBuffer16(int dimx, int dimy, bool bUseDDraw = false); virtual ~RMGfxSourceBuffer16(); - // Inizializzazione + // Initialisation void Create(int dimx, int dimy, bool bUseDDraw = false); int Bpp(); @@ -329,7 +329,7 @@ public: */ class RMGfxSourceBufferPal : public RMGfxSourceBuffer { protected: - // The size of the palette is (1<deleteMutex(csMainLoop); } @@ -121,7 +121,7 @@ void RMGfxEngine::OpenOptionScreen(CORO_PARAM, int type) { EnableMouse(); _vm->GrabThumbnail(); - // Esce la IDLE onde evitare la morte prematura in caricamento + // Exists the IDLE to avoid premature death in loading m_bMustEnterMenu = true; if (type == 1 || type == 2) { GLOBALS.bIdleExited = true; @@ -145,7 +145,7 @@ void RMGfxEngine::DoFrame(CORO_PARAM, bool bDrawLocation) { g_system->lockMutex(csMainLoop); - // Poll dei dispositivi di input + // Poll of input devices m_input.Poll(); if (m_bMustEnterMenu && GLOBALS.bIdleExited) { @@ -166,25 +166,25 @@ void RMGfxEngine::DoFrame(CORO_PARAM, bool bDrawLocation) { } if (bDrawLocation && m_bLocationLoaded) { - // Locazione e oggetti + // Location and objects m_loc.DoFrame(&m_bigBuf); - // Controlla gli input del mouse + // Check the mouse input if (m_bInput && !m_tony.InAction()) { - // Se siamo sull'inventario, lui che controlla tutti gli input + // If we are on the inventory, it is it who controls all input if (m_inv.HaveFocus(m_input.MousePos()) && !m_inter.Active()) { - // CLICK SINISTRO - // ************** + // Left Click + // ********** if (m_input.MouseLeftClicked()/* && m_itemName.IsItemSelected()*/) { - // Left click attiva il combine, se siamo su un oggetto + // Left click activates the combine, if we are on an object if (m_inv.LeftClick(m_input.MousePos(), m_curActionObj)) { m_curAction = TA_COMBINE; m_point.SetAction(m_curAction); } } else - // CLICK DESTRO - // ************ + // Right Click + // *********** if (m_input.MouseRightClicked()) { if (m_itemName.IsItemSelected()) { m_curActionObj = 0; @@ -193,8 +193,8 @@ void RMGfxEngine::DoFrame(CORO_PARAM, bool bDrawLocation) { m_inv.RightClick(m_input.MousePos()); } else - // RILASCIO DESTRO - // *************** + // Right Release + // ************* if (m_input.MouseRightReleased()) { if (m_inv.RightRelease(m_input.MousePos(), m_curAction)) { CORO_INVOKE_3(m_tony.MoveAndDoAction, m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), m_curAction); @@ -204,7 +204,7 @@ void RMGfxEngine::DoFrame(CORO_PARAM, bool bDrawLocation) { } } } else { - // Menu Opzioni + // Options Menu // ************ if (m_bGUIOption) { if (!m_tony.InAction() && m_bInput) { @@ -224,10 +224,10 @@ void RMGfxEngine::DoFrame(CORO_PARAM, bool bDrawLocation) { } } - // CLICK SINISTRO + // Left Click // ************** if (m_input.MouseLeftClicked() && !m_inter.Active()) { - // Se clicko dentro un oggetto, esegui l'azione + // If click inside an item, perform action //if (m_itemName.IsItemSelected()) { if (m_curAction != TA_COMBINE) @@ -246,10 +246,10 @@ void RMGfxEngine::DoFrame(CORO_PARAM, bool bDrawLocation) { } SKIPCLICKSINISTRO: - // CLICK DESTRO + // Right Click // ************ if (m_curAction == TA_COMBINE) { - // Durante il combine, lo annulla. + // During a combine, it cancels it if (m_input.MouseRightClicked()) { m_inv.EndCombine(); m_curActionObj = 0; @@ -259,7 +259,7 @@ SKIPCLICKSINISTRO: } } else if (m_input.MouseRightClicked() && m_itemName.IsItemSelected() && m_point.GetSpecialPointer() == RMPointer::PTR_NONE) { if (m_bGUIInterface) { - // Prima di aprire l'interfaccia, rimette GOTO + // Before opening the interface, replaces GOTO m_curAction = TA_GOTO; m_curActionObj = 0; m_point.SetAction(m_curAction); @@ -268,8 +268,8 @@ SKIPCLICKSINISTRO: } - // RILASCIO DESTRO - // *************** + // Right Release + // ************* if (m_input.MouseRightReleased()) { if (m_bGUIInterface) { if (m_inter.Released(m_input.MousePos(), m_curAction)) { @@ -283,21 +283,21 @@ SKIPCLICKSINISTRO: } } - // Aggiorna il nome sotto il puntatore del mouse + // Update the name under the mouse pointer m_itemName.SetMouseCoord(m_input.MousePos()); if (!m_inter.Active() && !m_inv.MiniActive()) CORO_INVOKE_4(m_itemName.DoFrame, m_bigBuf, m_loc, m_point, m_inv); } - // Inventario & interfaccia + // Interface & Inventory m_inter.DoFrame(m_bigBuf, m_input.MousePos()); m_inv.DoFrame(m_bigBuf, m_point, m_input.MousePos(), (!m_tony.InAction() && !m_inter.Active() && m_bGUIInventory)); } - // Anima Tony + // Animate Tony CORO_INVOKE_2(m_tony.DoFrame, &m_bigBuf, m_nCurLoc); - // Aggiorna lo scrolling per tenere Tony dentro lo schermo + // Update screen scrolling to keep Tony in focus if (m_tony.MustUpdateScrolling() && m_bLocationLoaded) { RMPoint showThis = m_tony.Position(); showThis.y -= 60; @@ -313,7 +313,7 @@ SKIPCLICKSINISTRO: } // ********************** - // Disegna la lista di OT + // Draw the list in the OT // ********************** CORO_INVOKE_0(m_bigBuf.DrawOT); @@ -487,7 +487,7 @@ uint32 RMGfxEngine::LoadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { bLoaded = false; for (i = 0; i < 5; i++) { - // Retry sul loading della locazione + // Retry the loading of the location RMRes res(m_nCurLoc); if (!res.IsValid()) continue; @@ -513,7 +513,7 @@ uint32 RMGfxEngine::LoadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { m_bLocationLoaded = true; - // On Enter per la locazion + // On entering the location return CORO_INVALID_PID_VALUE; //mpalQueryDoAction(0,m_nCurLoc,0); } @@ -524,7 +524,7 @@ void RMGfxEngine::UnloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result) { CORO_BEGIN_CODE(_ctx); - // Scarica tutta la memoria della locazione + // Release the location CORO_INVOKE_2(mpalEndIdlePoll, m_nCurLoc, NULL); // On Exit? @@ -585,28 +585,28 @@ void RMGfxEngine::Init(/*HINSTANCE hInst*/) { m_bWiping = false; m_hWipeEvent = CoroScheduler.createEvent(false, false); - // Crea l'evento di freeze + // Create the freeze event csMainLoop = g_system->createMutex(); - // Inizializza la funzione di IRQ di Item per l'MPAL + // Initialise the IRQ function for items for MPAL GLOBALS.GfxEngine = this; mpalInstallItemIrq(ItemIrq); - // Inizializza DirectInput + // Initialise the input m_input.Init(/*hInst*/); - // Inizializza il puntatore del mouse + // Initialise the mouse pointer m_point.Init(); - // Inizializza Tony + // Initialise Tony m_tony.Init(); m_tony.LinkToBoxes(&_vm->_theBoxes); - // Inizializza l'inventario e l'interfaccia + // Initialise the inventory and the interface m_inv.Init(); m_inter.Init(); - // Carica la locazione e setta le priorit @@@@@ + // Download the location and set priorities @@@@@ m_bLocationLoaded = false; /* m_nCurLoc=1; @@ -621,7 +621,7 @@ void RMGfxEngine::Init(/*HINSTANCE hInst*/) { */ EnableInput(); - // Inizio del gioco + // Starting the game //m_tony.ExecuteAction(4,1,0); //PREGAME m_tony.ExecuteAction(20, 1, 0); @@ -707,7 +707,7 @@ void RMGfxEngine::SaveState(const Common::String &fn, byte *curThumb, const Comm char buf[4]; RMPoint tp = m_tony.Position(); - // Saving: mpal variables, current location, + tony inventory position + // Saving: MPAL variables, current location, and Tony inventory position // For now, we only save the MPAL state size = mpalGetSaveStateSize(); @@ -802,7 +802,7 @@ void RMGfxEngine::SaveState(const Common::String &fn, byte *curThumb, const Comm } void RMGfxEngine::LoadState(CORO_PARAM, const Common::String &fn) { - // PROBLEMA: Bisognerebbe caricare la locazione in un thread a parte per fare la OnEnter ... + // PROBLEM: You should change the location in a separate process to do the OnEnter CORO_BEGIN_CONTEXT; Common::InSaveFile *f; byte *state, *statecmp; @@ -896,7 +896,7 @@ void RMGfxEngine::LoadState(CORO_PARAM, const Common::String &fn) { } if (_ctx->ver >= 5) { - // Versione 5: + // Versione 5 bool bStat = false; bStat = _ctx->f->readByte(); diff --git a/engines/tony/globals.h b/engines/tony/globals.h index 9115b22ccc..d2d47d392a 100644 --- a/engines/tony/globals.h +++ b/engines/tony/globals.h @@ -146,12 +146,10 @@ struct ChangedHotspotStruct { } }; -/****************************************************************************\ -* typedef CFCALL -* -------------- -* Description: Descrizione di una chiamata a una custom function -\****************************************************************************/ +/** + * Description of a call to a custom function. + */ typedef struct { int nCf; diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index e10fe228d3..a2a4923093 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -77,37 +77,36 @@ void RMInventory::Init(void) { int i, j; int curres; - // Crea il buffer principale + // Create the main buffer Create(RM_SX, 68); SetPriority(185); - // Pulisce l'inventario + // Setup the inventory m_nInv = 0; m_curPos = 0; m_bCombining = false; - // Nuovi oggetti - m_nItems = 78; // @@@ Numero di oggetti prendibili + // New items + m_nItems = 78; // @@@ Number of takeable items m_items = new RMInventoryItem[m_nItems + 1]; curres = 10500; - // Loop sugli oggetti + // Loop through the items for (i = 0; i <= m_nItems; i++) { - // Carica l'oggetto da risorsa + // Load the items from the resource RMRes res(curres); RMDataStream ds; assert(res.IsValid()); - // Non deve inizializzare il cur pattern dell'oggetto dell'inventario leggendolo da MPAL! - // Glelo mettiamo noi a MANO, e non c'entra nulla con l'oggetto in MPAL + // Initialise the MPAL inventory item by reading it in. m_items[i].icon.SetInitCurPattern(false); ds.OpenBuffer(res); ds >> m_items[i].icon; ds.Close(); - // Mette di default a pattern 1 + // Puts in the default pattern 1 m_items[i].pointer = NULL; m_items[i].status = 1; m_items[i].icon.SetPattern(1); @@ -131,7 +130,7 @@ void RMInventory::Init(void) { m_items[28].icon.SetPattern(1); m_items[29].icon.SetPattern(1); - // Carica l'interfaccina + // Download interface RMDataStream ds; RMRes res(RES_I_MINIINTER); assert(res.IsValid()); @@ -140,12 +139,12 @@ void RMInventory::Init(void) { miniInterface.SetPattern(1); ds.Close(); - // Crea il testo per gli hints sulla mini interfaccia + // Create the text for hints on the mini interface m_hints[0].SetAlignType(RMText::HCENTER, RMText::VTOP); m_hints[1].SetAlignType(RMText::HCENTER, RMText::VTOP); m_hints[2].SetAlignType(RMText::HCENTER, RMText::VTOP); - // Il testo viene preso da MPAL per la traduzione + // The text is taken from MPAL for translation RMMessage msg1(15); RMMessage msg2(13); RMMessage msg3(14); @@ -160,14 +159,14 @@ void RMInventory::Init(void) { m_hints[2].WriteText("Use",1); */ - // Prepara il primo inventario + // Prepare initial inventory Prepare(); DrawOT(Common::nullContext); ClearOT(); } void RMInventory::Close(void) { - // Ciao memoria + // Has memory if (m_items != NULL) { // Delete the item pointers for (int i = 0; i <= m_nItems; i++) @@ -211,22 +210,22 @@ void RMInventory::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr _ctx->pos.Set((m_nSelectObj + 1) * 64 - 20, RM_SY - 113); _ctx->pos2.Set((m_nSelectObj + 1) * 64 + 34, RM_SY - 150); } else { - _ctx->pos.Set((m_nSelectObj + 1) * 64 - 20, 72 - 4); // la parte marrone sta in alto :( + _ctx->pos.Set((m_nSelectObj + 1) * 64 - 20, 72 - 4); // The brown part is at the top :( _ctx->pos2.Set((m_nSelectObj + 1) * 64 + 34, 119 - 4); } _ctx->p = new RMGfxPrimitive(prim->m_task, _ctx->pos); _ctx->p2 = new RMGfxPrimitive(prim->m_task, _ctx->pos2); - // Disegna l'interfaccina stupida + // Draw the mini interface CORO_INVOKE_2(miniInterface.Draw, bigBuf, _ctx->p); if (GLOBALS.bCfgInterTips) { - if (miniAction == 1) // Esamina + if (miniAction == 1) // Examine CORO_INVOKE_2(m_hints[0].Draw, bigBuf, _ctx->p2); - else if (miniAction == 2) // Parla + else if (miniAction == 2) // Talk CORO_INVOKE_2(m_hints[1].Draw, bigBuf, _ctx->p2); - else if (miniAction == 3) // Usa + else if (miniAction == 3) // Use CORO_INVOKE_2(m_hints[2].Draw, bigBuf, _ctx->p2); } @@ -267,13 +266,12 @@ void RMInventory::RemoveItem(int code) { void RMInventory::AddItem(int code) { if (code <= 10000 && code >= 10101) { - // Se siamo qui, vuol dire che stiamo aggiungendo un oggetto che non dovrebbe essere - // nell'inventario + // If we are here, it means that we are adding an item that should not be in the inventory warning("Cannot find a valid icon for this item, and then it will not be added to the inventory"); } else { g_system->lockMutex(m_csModifyInterface); if (m_curPos + 8 == m_nInv) { - // Sfondiamo l'inventario! Attivo il pattern di lampeggio + // Break through the inventory! On the flashing pattern m_items[28].icon.SetPattern(2); } @@ -324,15 +322,15 @@ bool RMInventory::MiniActive(void) { } bool RMInventory::HaveFocus(const RMPoint &mpos) { - // In fase di combine abbiamo il focus solo se siamo su una freccia (per poter scrollare) + // When we combine, have the focus only if we are on an arrow (to scroll) if (m_state == OPENED && m_bCombining && CheckPointInside(mpos) && (mpos.x < 64 || mpos.x > RM_SX - 64)) return true; - // Se l'inventario aperto, abbiamo il focus quando ci andiamo sopra + // If the inventory is open, focus we we go over it if (m_state == OPENED && !m_bCombining && CheckPointInside(mpos)) return true; - // Se stiamo selezionando un verbo (quindi tasto destro premuto), abbiamo il focus alltime + // If we are selecting a verb (and then right down), we always focus if (m_state == SELECTING) return true; @@ -346,12 +344,12 @@ void RMInventory::EndCombine(void) { bool RMInventory::LeftClick(const RMPoint &mpos, int &nCombineObj) { int n; - // Il click sinistro prende in mano un oggetto dell'inventario per utilizzarlo con lo sfondo + // The left click picks an item from your inventory to use it with the background n = mpos.x / 64; if (m_state == OPENED) { if (n > 0 && n < RM_SX / 64 - 1 && m_inv[n - 1 + m_curPos] != 0) { - m_bCombining = true; //m_state=COMBINING; + m_bCombining = true; //m_state = COMBINING; m_nCombine = m_inv[n - 1 + m_curPos]; nCombineObj = m_nCombine + 10000; @@ -360,7 +358,7 @@ bool RMInventory::LeftClick(const RMPoint &mpos, int &nCombineObj) { } } - // Click sulla freccia destra + // Click the right arrow if ((m_state == OPENED) && m_bBlinkingRight) { g_system->lockMutex(m_csModifyInterface); m_curPos++; @@ -380,7 +378,7 @@ bool RMInventory::LeftClick(const RMPoint &mpos, int &nCombineObj) { ClearOT(); g_system->unlockMutex(m_csModifyInterface); } - // Click sulla freccia sinistra + // Click the left arrow else if ((m_state == OPENED) && m_bBlinkingLeft) { assert(m_curPos > 0); g_system->lockMutex(m_csModifyInterface); @@ -413,7 +411,7 @@ void RMInventory::RightClick(const RMPoint &mpos) { assert(CheckPointInside(mpos)); if (m_state == OPENED && !m_bCombining) { - // Apre l'interfaccina contestuale + // Open the context interface n = mpos.x / 64; if (n > 0 && n < RM_SX / 64 - 1 && m_inv[n - 1 + m_curPos] != 0) { @@ -494,12 +492,12 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo bool bNeedRedraw = false; if (m_state != CLOSED) { - // Pulisce l'OTList + // Clean up the OT list g_system->lockMutex(m_csModifyInterface); ClearOT(); - // Fa il DoFrame di tutti gli oggetti contenuti attualmente nell'inventario - // @@@ forse bisognerebbe farlo di tutti gli oggetti takeable? Probabilmente non serve a nulla + // DoFrame makes all the objects currently in the inventory be displayed + // @@@ Maybe we should do all takeable objects? Please does not help for (i = 0; i < m_nInv; i++) if (m_items[m_inv[i]].icon.DoFrame(this, false) && (i >= m_curPos && i <= m_curPos + 7)) bNeedRedraw = true; @@ -641,7 +639,7 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo else starty = 70; - // Controlla se si trova su uno dei verbi + // Make sure it is on one of the verbs if (mpos.y > starty && mpos.y < starty + 45) { if (mpos.x > startx && mpos.x < startx + 40) { if (miniAction != 1) { @@ -670,7 +668,7 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo miniAction = 0; } - // Aggiorna la miniinterface + // Update the mini-interface miniInterface.DoFrame(&bigBuf, false); } @@ -780,16 +778,16 @@ int RMInterface::OnWhichBox(RMPoint pt) { pt -= m_openStart; - // Controlla quanti verbi bisogna considerare + // Check how many verbs you have to consider max = 4; if (m_bPalesati) max = 5; - // Cerca il verbo + // Find the verb for (i = 0; i < max; i++) if (m_hotbbox[i].PtInRect(pt)) return i; - // Nessun verbo trovato + // Found no verb return -1; } @@ -803,7 +801,7 @@ void RMInterface::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr prim->Dst().TopLeft() = m_openStart; CORO_INVOKE_2(RMGfxSourceBuffer8RLEByte::Draw, bigBuf, prim); - // Controlla se c'e' da disegnare una zona calda + // Check if there is a draw hot zone _ctx->h = OnWhichBox(m_mpos); if (_ctx->h != -1) { prim->Dst().TopLeft() = m_openStart; @@ -826,7 +824,7 @@ void RMInterface::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr void RMInterface::DoFrame(RMGfxTargetBuffer &bigBuf, RMPoint mousepos) { - // Se c' bisogna, schedula nella OT list + // If needed, add to the OT schedule list if (!m_nInList && m_bActive) bigBuf.AddPrim(new RMGfxPrimitive(this)); @@ -837,17 +835,17 @@ void RMInterface::Clicked(const RMPoint &mousepos) { m_bActive = true; m_openPos = mousepos; - // Calcola l'angolo in alto a sinistra dell'interfaccia + // Calculate the top left corner of the interface m_openStart = m_openPos - RMPoint(m_dimx / 2, m_dimy / 2); m_lastHotZone = -1; - // La tiene dentro lo schermo + // Keep it inside the screen if (m_openStart.x < 0) m_openStart.x = 0; if (m_openStart.y < 0) m_openStart.y = 0; if (m_openStart.x + m_dimx > RM_SX) m_openStart.x = RM_SX - m_dimx; if (m_openStart.y + m_dimy > RM_SY) m_openStart.y = RM_SY - m_dimy; - // Play dell'effetto sonoro + // Play the sound effect _vm->PlayUtilSFX(0); } @@ -878,7 +876,7 @@ bool RMInterface::Released(const RMPoint &mousepos, RMTonyAction &action) { action = TA_PALESATI; break; - default: // Nessun verbo + default: // No verb return false; } @@ -914,8 +912,8 @@ void RMInterface::Init(void) { m_hotzone[i].LoadPaletteWA(pal); } - m_hotbbox[0].SetRect(126, 123, 159, 208); // prendi - m_hotbbox[1].SetRect(90, 130, 125, 186); // parla + m_hotbbox[0].SetRect(126, 123, 159, 208); // Take + m_hotbbox[1].SetRect(90, 130, 125, 186); // About m_hotbbox[2].SetRect(110, 60, 152, 125); m_hotbbox[3].SetRect(56, 51, 93, 99); m_hotbbox[4].SetRect(51, 105, 82, 172); @@ -926,7 +924,7 @@ void RMInterface::Init(void) { m_hints[3].SetAlignType(RMText::HRIGHT, RMText::VTOP); m_hints[4].SetAlignType(RMText::HRIGHT, RMText::VTOP); - // Il testo viene preso da MPAL per la traduzione + // The text is taken from MPAL for translation RMMessage msg0(12); RMMessage msg1(13); RMMessage msg2(14); diff --git a/engines/tony/inventory.h b/engines/tony/inventory.h index 309674ff0a..678caa1c78 100644 --- a/engines/tony/inventory.h +++ b/engines/tony/inventory.h @@ -79,66 +79,64 @@ protected: OSystem::MutexRef m_csModifyInterface; protected: - // Prepara l'immagine dell'inventario. Va richiamato ogni volta - // che l'inventario cambia + // Prepare the image inventory. It should be recalled whenever the inventory changes void Prepare(void); - // Controlla se la posizione Y del mouse corretta, anche in base - // alla posizione dell'inventario su schermo + // Check if the mouse Y position is conrrect, even under the inventory portion of the screen bool CheckPointInside(const RMPoint &pt); public: RMInventory(); virtual ~RMInventory(); - // Prepara un frame + // Prepare a frame void DoFrame(RMGfxTargetBuffer& bigBuf, RMPointer &ptr, RMPoint mpos, bool bCanOpen); - // Inizializzazione e chiusura + // Initialisation and closing void Init(void); void Close(void); void Reset(void); - // Overload per la rimozione da otlist + // Overload test for removal from OT list virtual void RemoveThis(CORO_PARAM, bool &result); - // Overload per il disegno (per la posizione x&y e l'interfaccina) + // Overload the drawing of the inventory virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - // Metodo per determinare se l'inventario sta comandando gli input + // Method for determining whether the inventory currently has the focus bool HaveFocus(const RMPoint &mpos); - // Metodo per determinare se la mini interfaccia attiva + // Method for determining if the mini interface is active bool MiniActive(void); - // Gestisce il click sinistro del mouse (solo quando c'ha focus) + // Handle the left mouse click (only when the inventory has the focus) bool LeftClick(const RMPoint &mpos, int &nCombineObj); - // Gestisce il tasto destro del mouse (solo quando c'ha focus) + // Handle the right mouse button (only when the inventory has the focus) void RightClick(const RMPoint &mpos); bool RightRelease(const RMPoint &mpos, RMTonyAction &curAction); - // Avverte che finito il combine + // Warn that an item combine is over void EndCombine(void); public: - // Aggiunta di un oggetto all'inventario + // Add an item to the inventory void AddItem(int code); RMInventory& operator+=(RMItem *item) { AddItem(item->MpalCode()); return *this; } RMInventory& operator+=(RMItem &item) { AddItem(item.MpalCode()); return *this; } RMInventory& operator+=(int code) { AddItem(code); return *this; } - // Rimozione di oggetto + // Removes an item void RemoveItem(int code); - // Siamo sopra un oggetto? + // We are on an object? RMItem *WhichItemIsIn(const RMPoint &mpt); bool ItemInFocus(const RMPoint &mpt); - // Cambia l'icona di un oggetto + // Change the icon of an item void ChangeItemStatus(uint32 dwCode, uint32 dwStatus); - // Salvataggio + // Save methods int GetSaveStateSize(void); void SaveState(byte *state); int LoadState(byte *state); @@ -158,34 +156,34 @@ private: int m_lastHotZone; protected: - // Dice su quale zona calda si trova il punto + // Return which box a given point is in int OnWhichBox(RMPoint pt); public: virtual ~RMInterface(); - // Il solito DoFrame (polling del motore grafico) + // The usual DoFrame (poll the graphics engine) void DoFrame(RMGfxTargetBuffer& bigBuf, RMPoint mousepos); - // TRUE se attiva (non si pu selezionare oggetti) + // TRUE if it is active (you can select items) bool Active(); - // Inizializzazione + // Initialisation void Init(void); void Close(void); - // Resetta l'interfaccia + // Reset the interface void Reset(void); - // Avverte dei click e rilasci del mouse + // Warns of mouse clicks and releases void Clicked(const RMPoint &mousepos); bool Released(const RMPoint &mousepos, RMTonyAction &action); - // Attiva o disattiva il quinto verbo + // Enalbes or disables the fifth verb void SetPalesati(bool bOn); bool GetPalesati(void); - // Overloading del Draw per il posizionamente + // Overloaded Draw virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); }; -- cgit v1.2.3 From 316ca0021bbf9629ae5cd592f28f8b30b24a2b00 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 20 May 2012 15:45:18 +1000 Subject: TONY: Converting Italian comments to English and formatting --- engines/tony/adv.h | 4 +- engines/tony/custom.cpp | 147 ++++++++++++++++++++++++------------------------ 2 files changed, 75 insertions(+), 76 deletions(-) (limited to 'engines') diff --git a/engines/tony/adv.h b/engines/tony/adv.h index 93359688f6..a31c1a28bc 100644 --- a/engines/tony/adv.h +++ b/engines/tony/adv.h @@ -40,11 +40,11 @@ namespace Tony { #define RM_SX 640 #define RM_SY 480 -// X&Y dimensions of bigbuf +// X & Y dimensions of bigbuf #define RM_BBX (RM_SX) #define RM_BBY (RM_SY) -// Skipping X&Y +// Skipping X & Y #define RM_SKIPY ((RM_BBY - RM_SY) / 2) #define RM_SKIPX 0 diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index d38f840011..4b3c533a92 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -130,14 +130,14 @@ void LoadChangedHotspot(Common::InSaveFile *f) { } -/* - Classi richieste per le funzioni custom! - - Tony (per muoverlo) -> si puo' fare tramite MPAL l'animazione? Penso proprio di s - - SendMessage -> Direi che basta theEngine.SendMessage() - ChangeLocation -> theEngine.ChangeLocation() - AddInventory -> theEngine.AddInventory() +/** + * @defgroup Classes required for custom functions + * + * Tony (To Move him) -> You can do MPAL through the animation? I really think so + * + * SendMessage -> I'd say just theEngine.SendMessage() + * ChangeLocation -> theEngine.ChangeLocation() + * AddInventory -> theEngine.AddInventory() */ void MCharResetCodes(void) { @@ -272,10 +272,10 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX _ctx->curVoc = SearchVoiceHeader(0, dwMessage); _ctx->voice = NULL; if (_ctx->curVoc) { - // Si posiziona all'interno del database delle voci all'inizio della prima + // Is positioned within the database of entries beginning at the first _ctx->curOffset = _ctx->curVoc->offset; - // PRIMA VOLTA PREALLOCA + // First time allocation g_system->lockMutex(GLOBALS.vdb); // fseek(_vm->m_vdbFP, _ctx->curOffset, SEEK_SET); _vm->_vdbFP.seek(_ctx->curOffset); @@ -308,28 +308,28 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX for (_ctx->i = 0; _ctx->i < _ctx->msg.NumPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { _ctx->text.SetInput(GLOBALS.Input); - // Allineamento + // Alignment _ctx->text.SetAlignType(RMText::HCENTER, RMText::VBOTTOM); - // Colore + // Colour _ctx->text.SetColor(0, 255, 0); - // Scrive il testo + // Writes the text _ctx->text.WriteText(_ctx->msg[_ctx->i], 0); - // Setta la posizione + // Set the position if (nX == 0 && nY == 0) _ctx->text.SetPosition(GLOBALS.Tony->Position() - RMPoint(0, 130) - GLOBALS.Loc->ScrollPosition()); else _ctx->text.SetPosition(RMPoint(nX, nY) - GLOBALS.Loc->ScrollPosition()); - // Setta l'always display + // Handling for always display if (GLOBALS.bAlwaysDisplay) { _ctx->text.SetAlwaysDisplay(); _ctx->text.ForceTime(); } - // Registra il testo + // Record the text GLOBALS.LinkGraphicTask(&_ctx->text); if (_ctx->curVoc) { @@ -351,7 +351,7 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX } } - // Aspetta la fine della visualizzazione + // Wait for the end of the display _ctx->text.SetCustomSkipHandle(GLOBALS.hSkipIdle); CORO_INVOKE_0(_ctx->text.WaitForEndDisplay); @@ -427,32 +427,32 @@ DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgStart)(CORO_PARAM, uint32 nMsg, uint32 for (_ctx->i = 0; _ctx->i < _ctx->msg->NumPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { _ctx->text.SetInput(GLOBALS.Input); - // Allineamento + // Alignment _ctx->text.SetAlignType(RMText::HCENTER, RMText::VCENTER); - // Forza il testo a scomparire a tempo + // Forces the text to disappear in time _ctx->text.ForceTime(); - // Colore + // Colour _ctx->text.SetColor(255, 255, 255); - // Scrive il testo + // Write the text if (nFont == 0) _ctx->text.WriteText((*_ctx->msg)[_ctx->i], 1); else if (nFont == 1) _ctx->text.WriteText((*_ctx->msg)[_ctx->i], 0); - // Setta la posizione + // Set the position _ctx->text.SetPosition(RMPoint(320, 240)); _ctx->text.SetAlwaysDisplay(); _ctx->text.ForceTime(); - // Registra il testo + // Record the text GLOBALS.LinkGraphicTask(&_ctx->clear); GLOBALS.LinkGraphicTask(&_ctx->text); - // Aspetta la fine della visualizzazione + // Wait for the end of display _ctx->text.SetCustomSkipHandle(GLOBALS.hSkipIdle); CORO_INVOKE_0(_ctx->text.WaitForEndDisplay); } @@ -1223,7 +1223,7 @@ DECLARE_CUSTOM_FUNCTION(ScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, uint32 CORO_BEGIN_CODE(_ctx); - // Prende le coordinate di quanto scrollare + // Take the scroll coordinates _ctx->lx = (int32)nX; _ctx->ly = (int32)nY; @@ -1272,7 +1272,7 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui CORO_BEGIN_CODE(_ctx); - // Prende le coordinate di quanto scrollare + // Take the scroll coordinates _ctx->lx = (int32)nX; _ctx->ly = (int32)nY; _ctx->dimx = _ctx->lx; @@ -1356,7 +1356,7 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui } - // Setta la posizione finale + // Set the position finale if (sX) { if (_ctx->lx > 0) _ctx->pt.x = _ctx->startpt.x + _ctx->dimx; @@ -1519,7 +1519,7 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess _ctx->curVoc = SearchVoiceHeader(0, dwMessage); _ctx->voice = NULL; if (_ctx->curVoc) { - // Si posiziona all'interno del database delle voci all'inizio della prima + // Position within the database of entries, beginning at the first // fseek(_vm->m_vdbFP, _ctx->curVoc->offset, SEEK_SET); g_system->lockMutex(GLOBALS.vdb); _vm->_vdbFP.seek(_ctx->curVoc->offset); @@ -1540,25 +1540,25 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess // Skipping _ctx->text->SetSkipStatus(!bIsBack); - // Allineamento + // Alignment _ctx->text->SetAlignType(RMText::HCENTER, RMText::VBOTTOM); - // Colore + // Colour _ctx->text->SetColor(GLOBALS.Character[nChar].r, GLOBALS.Character[nChar].g, GLOBALS.Character[nChar].b); - // Scrive il testo + // Write the text _ctx->text->WriteText((*_ctx->msg)[_ctx->i], 0); - // Setta la posizione + // Set the position _ctx->text->SetPosition(_ctx->pt); - // Setta l'always display + // Set the always display if (GLOBALS.bAlwaysDisplay) { _ctx->text->SetAlwaysDisplay(); _ctx->text->ForceTime(); } - // Registra il testo + // Record the text GLOBALS.LinkGraphicTask(_ctx->text); if (_ctx->curVoc) { @@ -1574,7 +1574,7 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess g_system->unlockMutex(GLOBALS.vdb); } - // Aspetta la fine della visualizzazione + // Wait for the end of display _ctx->text->SetCustomSkipHandle(GLOBALS.hSkipIdle); CORO_INVOKE_0(_ctx->text->WaitForEndDisplay); @@ -1618,7 +1618,7 @@ DECLARE_CUSTOM_FUNCTION(ChangeInventoryStatus)(CORO_PARAM, uint32 dwCode, uint32 /* - * Mastri Personaggi + * Master Characters */ DECLARE_CUSTOM_FUNCTION(MCharSetCode)(CORO_PARAM, uint32 nChar, uint32 nCode, uint32, uint32) { @@ -1714,17 +1714,17 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes bIsBack |= GLOBALS.MCharacter[nChar].bAlwaysBack ? 1 : 0; - // Calcola la posizione del testo in base al frame corrente + // Calculates the position of the text according to the current frame if (GLOBALS.MCharacter[nChar].x == -1) _ctx->pt = GLOBALS.MCharacter[nChar].item->CalculatePos() - RMPoint(-60, 20) - GLOBALS.Loc->ScrollPosition(); else _ctx->pt = RMPoint(GLOBALS.MCharacter[nChar].x, GLOBALS.MCharacter[nChar].y); - // Parametro per le azioni speciali: random tra le parlate + // Parameter for special actions: random between the spoken _ctx->parm = (GLOBALS.MCharacter[nChar].curgroup * 10) + _vm->_randomSource.getRandomNumber( GLOBALS.MCharacter[nChar].numtalks[GLOBALS.MCharacter[nChar].curgroup] - 1) + 1; - // Cerca di eseguire la funzione custom per inizializzare la parlata + // Try to run the custom function to initialise the speech if (GLOBALS.MCharacter[nChar].item) { _ctx->h = mpalQueryDoAction(30, GLOBALS.MCharacter[nChar].item->MpalCode(), _ctx->parm); if (_ctx->h != CORO_INVALID_PID_VALUE) { @@ -1735,7 +1735,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes _ctx->curVoc = SearchVoiceHeader(0, dwMessage); _ctx->voice = NULL; if (_ctx->curVoc) { - // Si posiziona all'interno del database delle voci all'inizio della prima + // Position within the database of entries, beginning at the first g_system->lockMutex(GLOBALS.vdb); // fseek(_vm->m_vdbFP, curVoc->offset, SEEK_SET); _vm->_vdbFP.seek(_ctx->curVoc->offset); @@ -1744,7 +1744,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes } for (_ctx->i = 0; _ctx->i < _ctx->msg->NumPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { - // Crea l'oggetto diverso se back o no + // Create a different object depending on whether it's background or not if (bIsBack) { GLOBALS.curBackText = _ctx->text = new RMTextDialogScrolling(GLOBALS.Loc); if (GLOBALS.bTonyIsSpeaking) @@ -1757,25 +1757,25 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes // Skipping _ctx->text->SetSkipStatus(!bIsBack); - // Allineamento + // Alignment _ctx->text->SetAlignType(RMText::HCENTER, RMText::VBOTTOM); - // Colore + // Colour _ctx->text->SetColor(GLOBALS.MCharacter[nChar].r, GLOBALS.MCharacter[nChar].g, GLOBALS.MCharacter[nChar].b); - // Scrive il testo + // Write the text _ctx->text->WriteText((*_ctx->msg)[_ctx->i], nFont); - // Setta la posizione + // Set the position _ctx->text->SetPosition(_ctx->pt); - // Setta l'always display + // Set the always display if (GLOBALS.bAlwaysDisplay) { _ctx->text->SetAlwaysDisplay(); _ctx->text->ForceTime(); } - // Registra il testo + // Record the text GLOBALS.LinkGraphicTask(_ctx->text); if (_ctx->curVoc) { @@ -1791,7 +1791,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes g_system->unlockMutex(GLOBALS.vdb); } - // Aspetta la fine della visualizzazione + // Wait for the end of display _ctx->text->SetCustomSkipHandle(GLOBALS.hSkipIdle); CORO_INVOKE_0(_ctx->text->WaitForEndDisplay); @@ -1807,7 +1807,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes } - // Cerca di eseguire la funzione custom per chiudere la parlata + // Try to run the custom function to close the speech if (GLOBALS.MCharacter[nChar].item) { _ctx->h = mpalQueryDoAction(31, GLOBALS.MCharacter[nChar].item->MpalCode(), _ctx->parm); if (_ctx->h != CORO_INVALID_PID_VALUE) @@ -1844,8 +1844,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg _ctx->bIsBack = false; - // La SendDialogMessage pu andare in background se un personaggio in MCHAR settato - // con la SetAlwaysBack + // The SendDialogMessage can go in the background if it is a character if (nPers != 0 && GLOBALS.IsMChar[nPers] && GLOBALS.MCharacter[nPers].bAlwaysBack) _ctx->bIsBack = true; @@ -1853,7 +1852,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg _ctx->voice = NULL; if (_ctx->curVoc) { - // Si posiziona all'interno del database delle voci all'inizio della prima + // Position within the database of entries, beginning at the first g_system->lockMutex(GLOBALS.vdb); // fseek(_vm->m_vdbFP, _ctx->curVoc->offset, SEEK_SET); _vm->_vdbFP.seek(_ctx->curVoc->offset); @@ -1912,14 +1911,14 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg else _ctx->pt = RMPoint(GLOBALS.MCharacter[nPers].x, GLOBALS.MCharacter[nPers].y); - // Parametro per le azioni speciali: random tra le parlate + // Parameter for special actions. Random between the spoken. _ctx->parm = (GLOBALS.MCharacter[nPers].curgroup * 10) + _vm->_randomSource.getRandomNumber( GLOBALS.MCharacter[nPers].numtalks[GLOBALS.MCharacter[nPers].curgroup] - 1) + 1; if (GLOBALS.MCharacter[nPers].numtexts != 0 && GLOBALS.MCharacter[nPers].bInTexts) { GLOBALS.MCharacter[nPers].numtexts--; } else { - // Cerca di eseguire la funzione custom per inizializzare la parlata + // Try to run the custom function to initialise the speech _ctx->h = mpalQueryDoAction(30, GLOBALS.MCharacter[nPers].item->MpalCode(), _ctx->parm); if (_ctx->h != CORO_INVALID_PID_VALUE) CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->h, CORO_INFINITE); @@ -1961,7 +1960,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg _ctx->text->SetCustomSkipHandle2(_ctx->voice->hEndOfBuffer); } - // Aspetta la fine della visualizzazione + // Wait for the end of display _ctx->text->SetCustomSkipHandle(GLOBALS.hSkipIdle); CORO_INVOKE_0(_ctx->text->WaitForEndDisplay); } @@ -1985,7 +1984,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg delete _ctx->text; } else { if ((GLOBALS.MCharacter[nPers].bInTexts && GLOBALS.MCharacter[nPers].numtexts == 0) || !GLOBALS.MCharacter[nPers].bInTexts) { - // Cerca di eseguire la funzione custom per chiudere la parlata + // Try to run the custom function to close the speech GLOBALS.MCharacter[nPers].curTalk = (GLOBALS.MCharacter[nPers].curTalk % 10) + GLOBALS.MCharacter[nPers].curgroup * 10; _ctx->h = mpalQueryDoAction(31, GLOBALS.MCharacter[nPers].item->MpalCode(), GLOBALS.MCharacter[nPers].curTalk); if (_ctx->h != CORO_INVALID_PID_VALUE) @@ -2036,12 +2035,12 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr // Wait until a choice is selected mpalQueryDialogWaitForChoice(&_ctx->nChoice); while (_ctx->nChoice != (uint32) - 1) { - // Si fa dare la lista di opzioni e le conta + // Get the list of options _ctx->sl = mpalQueryDialogSelectList(_ctx->nChoice); for (_ctx->num = 0; _ctx->sl[_ctx->num] != 0; _ctx->num++) ; - // Se c'e' una sola opzione, la fa automaticamente, e aspetta la prossima scelta + // If there is only one option, do it automatically, and wait for the next choice if (_ctx->num == 1) { mpalQueryDialogSelectionDWORD(_ctx->nChoice, _ctx->sl[0]); GlobalFree(_ctx->sl); @@ -2051,11 +2050,11 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr continue; } - // Crea una scelta per il dialogo + // Making a choice for dialog _ctx->dc.Init(); _ctx->dc.SetNumChoices(_ctx->num); - // Scrive tutte le possibili opzioni + // Writeall the possible options for (_ctx->i = 0; _ctx->i < _ctx->num; _ctx->i++) { _ctx->string = mpalQueryDialogPeriod(_ctx->sl[_ctx->i]); assert(_ctx->string != NULL); @@ -2063,11 +2062,11 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr GlobalFree(_ctx->string); } - // Attiva l'oggetto + // Activate the object GLOBALS.LinkGraphicTask(&_ctx->dc); CORO_INVOKE_0(_ctx->dc.Show); - // Disegna il puntatore + // Draw the pointer GLOBALS.Pointer->SetSpecialPointer(GLOBALS.Pointer->PTR_NONE); MainShowMouse(); @@ -2078,13 +2077,13 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr GLOBALS.Unfreeze(); } - // Nascondi il puntatore + // Hide the pointer MainHideMouse(); CORO_INVOKE_0(_ctx->dc.Hide); mpalQueryDialogSelectionDWORD(_ctx->nChoice, _ctx->sl[_ctx->sel]); - // Chiude la scelta + // Closes the choice _ctx->dc.Close(); GlobalFree(_ctx->sl); @@ -2098,7 +2097,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr /* - * Sync tra idle e mpal + * Sync between idle and mpal */ DECLARE_CUSTOM_FUNCTION(TakeOwnership)(CORO_PARAM, uint32 num, uint32, uint32, uint32) { @@ -2124,11 +2123,11 @@ DECLARE_CUSTOM_FUNCTION(ReleaseOwnership)(CORO_PARAM, uint32 num, uint32, uint32 * Musica * ------ * - * Effetti di fade supportati: + * Fadeout effects supposed: * - * nFX = 0 - La nuova musica si sostituisce a quella vecchia - * nFX=1 - La nuova musica si interfade con quella vecchia - * nFX=2 - La nuova musica subentra a tempo con quella vecchia + * nFX = 0 - The new music replaces the old one + * nFX=1 - The new music interfades with the old one + * nFX=2 - The new music takes over in time from the old * */ @@ -2181,7 +2180,7 @@ void ThreadFadeOutMusic(CORO_PARAM, const void *nMusic) { if (!GLOBALS.bFadeOutStop) _vm->SetMusicVolume(nChannel, 0); - // Se uno stacchetto ferma tutto + // If there is a stacchetto, stop all if (nChannel == 2) _vm->StopMusic(2); @@ -2400,15 +2399,15 @@ DECLARE_CUSTOM_FUNCTION(DoCredits)(CORO_PARAM, uint32 nMsg, uint32 dwTime, uint3 } - // Setta la posizione + // Set the position _ctx->text[_ctx->i].SetAlwaysDisplay(); _ctx->text[_ctx->i].SetForcedTime(dwTime * 1000); _ctx->text[_ctx->i].SetNoTab(); - // Aspetta la fine della visualizzazione + // Wait for the end of display _ctx->text[_ctx->i].SetCustomSkipHandle(_ctx->hDisable); - // Registra il testo + // Record the text GLOBALS.LinkGraphicTask(&_ctx->text[_ctx->i]); } @@ -2651,7 +2650,7 @@ void SetupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation - // Crea l'evento per skippare le idle + // Create an event for the idle skipping GLOBALS.hSkipIdle = CoroScheduler.createEvent(true, false); } -- cgit v1.2.3 From 8322da03c04d7994601973364599081447a7ccde Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 20 May 2012 16:03:09 +1000 Subject: TONY: Converting Italian comments to English --- engines/tony/custom.cpp | 1 - engines/tony/font.cpp | 8 ++++---- engines/tony/game.h | 4 ++-- engines/tony/loc.cpp | 7 +++---- engines/tony/mpal/mpal.cpp | 12 ++++++------ engines/tony/tony.cpp | 2 +- engines/tony/tonychar.cpp | 6 +++--- 7 files changed, 19 insertions(+), 21 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 4b3c533a92..254fab91da 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -139,7 +139,6 @@ void LoadChangedHotspot(Common::InSaveFile *f) { * ChangeLocation -> theEngine.ChangeLocation() * AddInventory -> theEngine.AddInventory() */ - void MCharResetCodes(void) { for (int i = 0; i < 10; i++) GLOBALS.MCharacter[i].item = GLOBALS.Loc->GetItemFromCode(GLOBALS.MCharacter[i].code); diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 972bd081bf..efca78301c 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -51,8 +51,8 @@ RMFont::~RMFont() { /** * Dumps a font to a buffer - * @param buf Buffer contenente il font - * @param nChars Numero di caratteri (max 256) + * @param buf Buffer for font contents + * @param nChars Number of characters (max 256) * @param dimx X dimension in pixels * @param dimy Y dimension in pixels * @@ -2209,7 +2209,7 @@ void RMTextDialogScrolling::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPri } void RMTextDialogScrolling::ClipOnScreen(RMGfxPrimitive *prim) { - // Non dobbiamo fare nulla! + // We must not do anything! } @@ -2283,7 +2283,7 @@ void RMTextItemName::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive CORO_BEGIN_CODE(_ctx); - // Se non c'e' testo, e' inutile continuare + // If there is no text, it's pointless to continue if (m_buf == NULL) return; diff --git a/engines/tony/game.h b/engines/tony/game.h index 532a457b8f..20b5f347bc 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -283,12 +283,12 @@ public: protected: - // Inizializza tutto per il nuovo stato + // Initialisation and state change void InitState(CORO_PARAM); void CloseState(void); void ChangeState(CORO_PARAM, STATE newState); - // Repaaint the options menu + // Repaint the options menu void RefreshAll(CORO_PARAM); void RefreshThumbnails(void); }; diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index ef59b3f916..43e673b046 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -1520,7 +1520,7 @@ void RMCharacter::Stop(CORO_PARAM) { bMoving = false; - // Non si sa mai... + // You never know.. status = STAND; minpath = 0; @@ -1609,9 +1609,8 @@ void RMCharacter::Move(CORO_PARAM, RMPoint pt, bool *result) { pathcount = 1; pathend = pt; } else { - // @@@ Questo caso se un hotspot dentro un box - // ma non c' un path per arrivarci. Usiamo quindi - // la invscanline per cercare un punto intorno + // @@@ This case is whether a hotspot is inside a box, but there is + // a path to get there. We use the InvScanLine to search around a point _ctx->dest = InvScanLine(pt); pt = _ctx->dest; diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 5cb6546343..0b56317f6f 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -647,7 +647,7 @@ void ScriptThread(CORO_PARAM, const void *param) { // debugC(DEBUG_BASIC, kTonyDebugMPAL, "PlayScript(): Moments: %u\n",s->nMoments); for (_ctx->i = 0; _ctx->i < s->nMoments; _ctx->i++) { - // Dorme il tempo necessario per arrivare al momento successivo + // Sleep for the required time if (s->Moment[_ctx->i].dwTime == -1) { CORO_INVOKE_4(CoroScheduler.waitForMultipleObjects, _ctx->numHandles, cfHandles, true, CORO_INFINITE); _ctx->dwStartTime = _vm->GetTime(); @@ -878,7 +878,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { } UnlockItems(); - /* Se non e' rimasto nessuno possiamo uscire */ + /* If there is nothing left, we can exit */ if (_ctx->nRealItems == 0) { GlobalFree(_ctx->il); CORO_KILL_SELF(); @@ -1170,7 +1170,7 @@ void GroupThread(CORO_PARAM, const void *param) { } } - /* Se siamo qui, vuol dire che non abbiamo trovato il gruppo richiesto */ + /* If we are here, it means that we have not found the requested group */ GLOBALS.mpalError = 1; UnlockDialogs(); @@ -2750,7 +2750,7 @@ const char *DLG600[] = { "Tony", "Jack", "Jack", NULL, "Jack", NULL, NULL, NULL, case num: \ if (nPers >= (int)(sizeof(DLG##num) / sizeof(const char *)) || DLG##num[nPers] == NULL) \ { \ - warning("ERROR: Il personaggio #%d non esiste nel dialogo %d!\n", nPers, nDlg); \ + warning("ERROR: The character #%d does not exist in dialog %d!\n", nPers, nDlg); \ return "ERROR"; \ } \ else \ @@ -2819,7 +2819,7 @@ const char *GetPersonName(uint16 nDlg, int nPers) { HANDLE_DIALOG(600); default: - warning("ERROR: Il dialogo %d non esiste!\n", (int)nDlg); + warning("ERROR: Dialog %d does not exist!", (int)nDlg); return "ERROR"; } } @@ -2872,7 +2872,7 @@ void mpalDumpDialog(LPMPALDIALOG dlg) { break; if (dlg->Periods[j] == NULL) - warning("ERROR: Dialogo %d, Periodo %d non trovato!\n", (int)dlg->nObj, (int)curCmd->arg2); + warning("ERROR: Dialog %d, Period %d not found!", (int)dlg->nObj, (int)curCmd->arg2); else { frase = (char *)GlobalLock(dlg->Periods[j]); strcpy(copia, frase); diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index c9abea04e0..e539fa1a39 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -609,7 +609,7 @@ void TonyEngine::PauseLoop(void) { } void TonyEngine::Pause(bool bPause) { - // Se non e' cambiato lo stato di pausing, non fare nulla + // If the new status already matches the current one, do nothing if (m_bPaused == bPause) return; diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index 04b6193cd2..593a05d863 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -178,7 +178,7 @@ void RMTony::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CODE(_ctx); - // Richiama il Draw() della classe madre se tony visibile + // Call the Draw() of the parent class if Tony is visible if (m_bShow && bDrawNow) { if (m_bCorpoDavanti) { prim->Dst().SetEmpty(); @@ -189,7 +189,7 @@ void RMTony::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { } if (m_bIsTalking || m_bIsStaticTalk) { - // Offset inverso per lo scrolling + // Offest direction from scrolling prim->Dst().SetEmpty(); prim->Dst().Offset(-m_curScroll); prim->Dst().Offset(m_pos); @@ -217,7 +217,7 @@ void RMTony::MoveAndDoAction(CORO_PARAM, RMPoint dst, RMItem *item, int nAction, CORO_BEGIN_CODE(_ctx); - // Fa il movimento normale, ma si ricorda se deve poi eseguire un azione + // Makes normal movement, but remember if you must then perform an action if (item == NULL) { m_bActionPending = false; m_ActionItem = NULL; -- cgit v1.2.3 From c38bbce20cf69748012863dcd08c575ba6b56c9d Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 20 May 2012 16:11:25 +1000 Subject: TONY: Remove original header --- engines/tony/mpal/expr.cpp | 31 +++++-------------------------- engines/tony/mpal/expr.h | 31 +++++-------------------------- engines/tony/mpal/loadmpc.cpp | 31 +++++-------------------------- engines/tony/mpal/loadmpc.h | 31 +++++-------------------------- engines/tony/mpal/mpal.cpp | 31 +++++-------------------------- engines/tony/mpal/mpal.h | 40 ++-------------------------------------- engines/tony/mpal/mpaldll.h | 31 +++++-------------------------- 7 files changed, 32 insertions(+), 194 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/expr.cpp b/engines/tony/mpal/expr.cpp index cf688341be..aaec74fb4c 100644 --- a/engines/tony/mpal/expr.cpp +++ b/engines/tony/mpal/expr.cpp @@ -20,32 +20,11 @@ * * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * ... Spyral Software snc * - * . x#""*$Nu -= We create much MORE than ALL =- * - * d*#R$. R ^#$o 様様様様様様様様様様様様様様様様様 * - * .F ^$k $ "$b * - * ." $b u "$ #$L * - * P $c :*$L"$L '$k Project: MPAL................... * - * d @$N. $. d ^$b^$k $c * - * F 4 "$c '$ $ #$u#$u '$ Module: Expression gestor...... * - * 4 4k *N #b .> '$N'*$u * * - * M $L #$ $ 8 "$c'#$b.. .@ Author: Giovanni Bajo.......... * - * M '$u "$u :" *$. "#*#" * - * M '$N. " F ^$k Desc: Gestisce le espressioni * - * 4> ^R$oue# d matematiche............ * - * '$ "" @ ....................... * - * #b u# * - * $b .@" OS: [ ] DOS [X] WIN95 [ ] OS/2 * - * #$u .d" * - * '*$e. .zR".@ 様様様様様様様様様様様様様様様様様 * - * "*$$beooee$*" @"M This source code is * - * """ '$.? Copyright (C) Spyral Software * - * '$d> ALL RIGHTS RESERVED * - * '$> 様様様様様様様様様様様様様様様様様 * - * * - **************************************************************************/ +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ #include "tony/mpal/mpal.h" #include "tony/mpal/memory.h" diff --git a/engines/tony/mpal/expr.h b/engines/tony/mpal/expr.h index 3a9f0f3208..7d7ca09c41 100644 --- a/engines/tony/mpal/expr.h +++ b/engines/tony/mpal/expr.h @@ -20,32 +20,11 @@ * * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * ... Spyral Software snc * - * . x#""*$Nu -= We create much MORE than ALL =- * - * d*#R$. R ^#$o 様様様様様様様様様様様様様様様様様 * - * .F ^$k $ "$b * - * ." $b u "$ #$L * - * P $c :*$L"$L '$k Project: MPAL................... * - * d @$N. $. d ^$b^$k $c * - * F 4 "$c '$ $ #$u#$u '$ Module: Expression gestor heade * - * 4 4k *N #b .> '$N'*$u * * - * M $L #$ $ 8 "$c'#$b.. .@ Author: Giovanni Bajo.......... * - * M '$u "$u :" *$. "#*#" * - * M '$N. " F ^$k Desc: Gestisce le espressioni * - * 4> ^R$oue# d matematiche............ * - * '$ "" @ ....................... * - * #b u# * - * $b .@" OS: [ ] DOS [X] WIN95 [ ] OS/2 * - * #$u .d" * - * '*$e. .zR".@ 様様様様様様様様様様様様様様様様様 * - * "*$$beooee$*" @"M This source code is * - * """ '$.? Copyright (C) Spyral Software * - * '$d> ALL RIGHTS RESERVED * - * '$> 様様様様様様様様様様様様様様様様様 * - * * - **************************************************************************/ +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ #ifndef MPAL_EXPR_H #define MPAL_EXPR_H diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index 6329a2090a..a60c9f5f16 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -20,32 +20,11 @@ * * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * ... Spyral Software snc * - * . x#""*$Nu -= We create much MORE than ALL =- * - * d*#R$. R ^#$o 様様様様様様様様様様様様様様様様様 * - * .F ^$k $ "$b * - * ." $b u "$ #$L * - * P $c :*$L"$L '$k Project: MPAL................... * - * d @$N. $. d ^$b^$k $c * - * F 4 "$c '$ $ #$u#$u '$ Module: MPC Loader............. * - * 4 4k *N #b .> '$N'*$u * * - * M $L #$ $ 8 "$c'#$b.. .@ Author: Giovanni Bajo.......... * - * M '$u "$u :" *$. "#*#" * - * M '$N. " F ^$k Desc: Legge un file compilato * - * 4> ^R$oue# d di MPAL................ * - * '$ "" @ ....................... * - * #b u# * - * $b .@" OS: [ ] DOS [X] WIN95 [ ] OS/2 * - * #$u .d" * - * '*$e. .zR".@ 様様様様様様様様様様様様様様様様様 * - * "*$$beooee$*" @"M This source code is * - * """ '$.? Copyright (C) Spyral Software * - * '$d> ALL RIGHTS RESERVED * - * '$> 様様様様様様様様様様様様様様様様様 * - * * - **************************************************************************/ +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ /* #include "lzo1x.h" diff --git a/engines/tony/mpal/loadmpc.h b/engines/tony/mpal/loadmpc.h index 6aea3de16b..2f8a1121ec 100644 --- a/engines/tony/mpal/loadmpc.h +++ b/engines/tony/mpal/loadmpc.h @@ -20,32 +20,11 @@ * * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * ... Spyral Software snc * - * . x#""*$Nu -= We create much MORE than ALL =- * - * d*#R$. R ^#$o 様様様様様様様様様様様様様様様様様 * - * .F ^$k $ "$b * - * ." $b u "$ #$L * - * P $c :*$L"$L '$k Project: MPAL................... * - * d @$N. $. d ^$b^$k $c * - * F 4 "$c '$ $ #$u#$u '$ Module: MPC Loader Header...... * - * 4 4k *N #b .> '$N'*$u * * - * M $L #$ $ 8 "$c'#$b.. .@ Author: Giovanni Bajo.......... * - * M '$u "$u :" *$. "#*#" * - * M '$N. " F ^$k Desc: Legge un file compilato * - * 4> ^R$oue# d MPC.................... * - * '$ "" @ ....................... * - * #b u# * - * $b .@" OS: [ ] DOS [X] WIN95 [ ] OS/2 * - * #$u .d" * - * '*$e. .zR".@ 様様様様様様様様様様様様様様様様様 * - * "*$$beooee$*" @"M This source code is * - * """ '$.? Copyright (C) Spyral Software * - * '$d> ALL RIGHTS RESERVED * - * '$> 様様様様様様様様様様様様様様様様様 * - * * - **************************************************************************/ +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ #ifndef __LOADMPC_H #define __LOADMPC_H diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 0b56317f6f..a5b7593e68 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -20,32 +20,11 @@ * * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * ... Spyral Software snc * - * . x#""*$Nu -= We create much MORE than ALL =- * - * d*#R$. R ^#$o 様様様様様様様様様様様様様様様様様 * - * .F ^$k $ "$b * - * ." $b u "$ #$L * - * P $c :*$L"$L '$k Project: MPAL................... * - * d @$N. $. d ^$b^$k $c * - * F 4 "$c '$ $ #$u#$u '$ Module: Mpal Query Library..... * - * 4 4k *N #b .> '$N'*$u * * - * M $L #$ $ 8 "$c'#$b.. .@ Author: Giovanni Bajo.......... * - * M '$u "$u :" *$. "#*#" * - * M '$N. " F ^$k Desc: Libreria principale di * - * 4> ^R$oue# d MPAL, contenente il * - * '$ "" @ codice per le query.... * - * #b u# * - * $b .@" OS: [ ] DOS [X] WIN95 [ ] OS/2 * - * #$u .d" * - * '*$e. .zR".@ 様様様様様様様様様様様様様様様様様 * - * "*$$beooee$*" @"M This source code is * - * """ '$.? Copyright (C) Spyral Software * - * '$d> ALL RIGHTS RESERVED * - * '$> 様様様様様様様様様様様様様様様様様 * - * * - **************************************************************************/ +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ #include "common/scummsys.h" #include "common/file.h" diff --git a/engines/tony/mpal/mpal.h b/engines/tony/mpal/mpal.h index a14bfd1895..1bf19ef1bb 100644 --- a/engines/tony/mpal/mpal.h +++ b/engines/tony/mpal/mpal.h @@ -20,46 +20,10 @@ * * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * ... Spyral Software snc * - * . x#""*$Nu -= We create much MORE than ALL =- * - * d*#R$. R ^#$o 様様様様様様様様様様様様様様様様様 * - * .F ^$k $ "$b * - * ." $b u "$ #$L * - * P $c :*$L"$L '$k Project: MPAL................... * - * d @$N. $. d ^$b^$k $c * - * F 4 "$c '$ $ #$u#$u '$ Module: MPAL Main Include file. * - * 4 4k *N #b .> '$N'*$u * * - * M $L #$ $ 8 "$c'#$b.. .@ Author: Giovanni Bajo.......... * - * M '$u "$u :" *$. "#*#" * - * M '$N. " F ^$k Desc: Main Include file for * - * 4> ^R$oue# d using MPAL.DLL......... * - * '$ "" @ ....................... * - * #b u# * - * $b .@" OS: [ ] DOS [X] WIN95 [ ] OS/2 * - * #$u .d" * - * '*$e. .zR".@ 様様様様様様様様様様様様様様様様様 * - * "*$$beooee$*" @"M This source code is * - * """ '$.? Copyright (C) Spyral Software * - * '$d> ALL RIGHTS RESERVED * - * '$> 様様様様様様様様様様様様様様様様様 * - * * - **************************************************************************/ - - -/****************************************************************************\ -* Copyright Notice -\****************************************************************************/ - /* - * A Spyral Software Production: - * - * MPAL - MultiPurpose Adventure Language - * (C) 1997 Giovanni Bajo and Luca Giusti - * ALL RIGHTS RESERVED - * + * This code is based on original Tony Tough source code * + * Copyright (c) 1997-2003 Nayma Software */ diff --git a/engines/tony/mpal/mpaldll.h b/engines/tony/mpal/mpaldll.h index dc42b597bc..8216e7b166 100644 --- a/engines/tony/mpal/mpaldll.h +++ b/engines/tony/mpal/mpaldll.h @@ -20,32 +20,11 @@ * * */ -/************************************************************************** - * 様様様様様様様様様様様様様様様様様 * - * ... Spyral Software snc * - * . x#""*$Nu -= We create much MORE than ALL =- * - * d*#R$. R ^#$o 様様様様様様様様様様様様様様様様様 * - * .F ^$k $ "$b * - * ." $b u "$ #$L * - * P $c :*$L"$L '$k Project: MPAL................... * - * d @$N. $. d ^$b^$k $c * - * F 4 "$c '$ $ #$u#$u '$ Module: MPAL DLL Header........ * - * 4 4k *N #b .> '$N'*$u * * - * M $L #$ $ 8 "$c'#$b.. .@ Author: Giovanni Bajo.......... * - * M '$u "$u :" *$. "#*#" * - * M '$N. " F ^$k Desc: Header per i moduli per * - * 4> ^R$oue# d la DLL di query di MPAL * - * '$ "" @ ....................... * - * #b u# * - * $b .@" OS: [ ] DOS [X] WIN95 [ ] OS/2 * - * #$u .d" * - * '*$e. .zR".@ 様様様様様様様様様様様様様様様様様 * - * "*$$beooee$*" @"M This source code is * - * """ '$.? Copyright (C) Spyral Software * - * '$d> ALL RIGHTS RESERVED * - * '$> 様様様様様様様様様様様様様様様様様 * - * * - **************************************************************************/ +/* + * This code is based on original Tony Tough source code + * + * Copyright (c) 1997-2003 Nayma Software + */ #ifndef __MPALDLL_H #define __MPALDLL_H -- cgit v1.2.3 From 7da213cd32b702ad8f4d0a10020eae10666a64ff Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 20 May 2012 16:34:38 +1000 Subject: TONY: Removal of code that was commented out in the original source --- engines/tony/custom.cpp | 47 ++------------ engines/tony/font.cpp | 18 +----- engines/tony/game.cpp | 3 - engines/tony/gfxcore.cpp | 12 ---- engines/tony/gfxengine.cpp | 150 ++++----------------------------------------- engines/tony/gfxengine.h | 3 - engines/tony/inventory.cpp | 34 +++------- engines/tony/loc.cpp | 50 --------------- engines/tony/tony.cpp | 12 ---- 9 files changed, 29 insertions(+), 300 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 254fab91da..0127494007 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -276,11 +276,10 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX // First time allocation g_system->lockMutex(GLOBALS.vdb); - // fseek(_vm->m_vdbFP, _ctx->curOffset, SEEK_SET); _vm->_vdbFP.seek(_ctx->curOffset); _vm->_theSound.CreateSfx(&_ctx->voice); + _ctx->voice->LoadVoiceFromVDB(_vm->_vdbFP); - // _ctx->curOffset = ftell(_vm->m_vdbFP); _ctx->curOffset = _vm->_vdbFP.pos(); _ctx->voice->SetLoop(false); @@ -337,11 +336,10 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX _ctx->text.SetCustomSkipHandle2(_ctx->voice->hEndOfBuffer); } else { g_system->lockMutex(GLOBALS.vdb); - // fseek(_vm->m_vdbFP, _ctx->curOffset, SEEK_SET); _vm->_vdbFP.seek(_ctx->curOffset); _vm->_theSound.CreateSfx(&_ctx->voice); _ctx->voice->LoadVoiceFromVDB(_vm->_vdbFP); - // _ctx->curOffset = ftell(_vm->m_vdbFP); + _ctx->curOffset = _vm->_vdbFP.pos(); _ctx->voice->SetLoop(false); _ctx->voice->Play(); @@ -517,7 +515,7 @@ DECLARE_CUSTOM_FUNCTION(CloseLocation)(CORO_PARAM, uint32, uint32, uint32, uint3 _vm->StopMusic(4); - // On Exit e lascia freezzato + // On exit, unload and unfreeze CORO_INVOKE_2(GLOBALS.UnloadLocation, true, NULL); GLOBALS.Unfreeze(); @@ -541,7 +539,7 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint _vm->StopMusic(4); } - // On Exit e lascia freezzato + // On exit, unfreeze CORO_INVOKE_2(GLOBALS.UnloadLocation, true, NULL); GLOBALS.curChangedHotspot = 0; @@ -1314,37 +1312,6 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui } -/* - sX = _ctx->stepX * (_ctx->dwCurTime-dwLastTime) / (1000 / 35); - sY = _ctx->stepY * (_ctx->dwCurTime-dwLastTime) / (1000 / 35); - - if (_ctx->lx > 0) { - _ctx->lx -= sX; - if (_ctx->lx < 0) - _ctx->lx = 0; - _ctx->pt.Offset(sX, 0); - } else if (_ctx->lx < 0) { - _ctx->lx += sX; - - if (_ctx->lx > 0) - _ctx->lx = 0; - - _ctx->pt.Offset(-sX, 0); - } - - if (_ctx->ly > 0) { - _ctx->ly -= sY; - if (_ctx->ly < 0) - _ctx->ly = 0; - _ctx->pt.Offset(0, sY); - } else if (_ctx->ly < 0) { - _ctx->ly += sY; - if (_ctx->ly > 0) - _ctx->ly = 0; - - _ctx->pt.Offset(0, -sY); - } -*/ CORO_INVOKE_0(GLOBALS.WaitFrame); GLOBALS.Freeze(); @@ -1519,7 +1486,6 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess _ctx->voice = NULL; if (_ctx->curVoc) { // Position within the database of entries, beginning at the first - // fseek(_vm->m_vdbFP, _ctx->curVoc->offset, SEEK_SET); g_system->lockMutex(GLOBALS.vdb); _vm->_vdbFP.seek(_ctx->curVoc->offset); _ctx->curOffset = _ctx->curVoc->offset; @@ -1853,7 +1819,6 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg if (_ctx->curVoc) { // Position within the database of entries, beginning at the first g_system->lockMutex(GLOBALS.vdb); - // fseek(_vm->m_vdbFP, _ctx->curVoc->offset, SEEK_SET); _vm->_vdbFP.seek(_ctx->curVoc->offset); _vm->_theSound.CreateSfx(&_ctx->voice); _ctx->voice->LoadVoiceFromVDB(_vm->_vdbFP); @@ -2119,8 +2084,8 @@ DECLARE_CUSTOM_FUNCTION(ReleaseOwnership)(CORO_PARAM, uint32 num, uint32, uint32 /* - * Musica - * ------ + * Music + * ----- * * Fadeout effects supposed: * diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index efca78301c..a15a79b16c 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -66,23 +66,7 @@ void DumpFontBMP(const char *filename, const byte *buf, int nChars, int charX, i void RMFont::Load(const byte *buf, int nChars, int dimx, int dimy, uint32 palResID) { m_letter = new RMGfxSourceBuffer8RLEByte[nChars]; -#if 0 - if (nChars == 112 && palResID == RES_F_PAL) { - // Font parla - DumpFontBMP("font_parla.bmp", buf, nChars, dimx, dimy, RMRes(palResID)); - } else if (nChars == 102 && palResID == RES_F_PAL) { - // Font macc - DumpFontBMP("font_macc.bmp", buf, nChars, dimx, dimy, RMRes(palResID)); - } else if (nChars == 85 && palResID == RES_F_PAL) { - // Font obj - DumpFontBMP("font_obj.bmp", buf, nChars, dimx, dimy, RMRes(palResID)); - } else if (nChars == 112 && palResID == RES_F_CPAL) { - // Font credits - DumpFontBMP("font_credits.bmp", buf, nChars, dimx, dimy, RMRes(palResID)); - } -#endif - - // Initialisation the fonts + // Initialise the fonts for (int i = 0; i < nChars; i++) { // Initialise the buffer with the letters m_letter[i].Init(buf + i * (dimx * dimy + 8) + 8, dimx, dimy); diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 4fe1ea374e..02eb996562 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -1194,9 +1194,6 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { m_nEditPos = _ctx->i; strcpy(m_EditName, m_curThumbName[_ctx->i]); _ctx->bRefresh = true; - - //_vm->SaveState(m_statePos+_ctx->i,"No name"); - //Close(); } break; diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 8c992eb150..170870a89b 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -162,18 +162,6 @@ void RMGfxSourceBuffer::PrepareImage(void) { bool RMGfxSourceBuffer::Clip2D(int &x1, int &y1, int &u, int &v, int &width, int &height, bool bUseSrc, RMGfxTargetBuffer *buf) { int destw, desth; -/* - OBSOLETE CODE: - - if (buf == NULL) { - destw=RM_SX; - desth=RM_SY; - } else { - destw = buf->Dimx(); - desth = buf->Dimy(); - } -*/ - destw = buf->Dimx(); desth = buf->Dimy(); diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index e4f4cfb22d..3fa33d78ff 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -227,14 +227,11 @@ void RMGfxEngine::DoFrame(CORO_PARAM, bool bDrawLocation) { // Left Click // ************** if (m_input.MouseLeftClicked() && !m_inter.Active()) { - // If click inside an item, perform action - //if (m_itemName.IsItemSelected()) - { - if (m_curAction != TA_COMBINE) - CORO_INVOKE_3(m_tony.MoveAndDoAction, m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), m_point.CurAction()); - else if (m_itemName.GetSelectedItem() != NULL) - CORO_INVOKE_4(m_tony.MoveAndDoAction, m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), TA_COMBINE, m_curActionObj); - } + + if (m_curAction != TA_COMBINE) + CORO_INVOKE_3(m_tony.MoveAndDoAction, m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), m_point.CurAction()); + else if (m_itemName.GetSelectedItem() != NULL) + CORO_INVOKE_4(m_tony.MoveAndDoAction, m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), TA_COMBINE, m_curActionObj); if (m_curAction == TA_COMBINE) { m_inv.EndCombine(); @@ -380,80 +377,6 @@ void RMGfxEngine::ItemIrq(uint32 dwItem, int nPattern, int nStatus) { } } -/* - // WINBUG: This is a special case for the file open/save dialog, - // which sometimes pumps while it is coming up but before it has - // disabled the main window. - HWND hWndFocus = ::GetFocus(); - bool bEnableParent = false; - m_ofn.hwndOwner = PreModal(); - AfxUnhookWindowCreate(); - if (m_ofn.hwndOwner != NULL && ::IsWindowEnabled(m_ofn.hwndOwner)) { - bEnableParent = true; - ::EnableWindow(m_ofn.hwndOwner, false); - } - - _AFX_THREAD_STATE* pThreadState = AfxGetThreadState(); - ASSERT(pThreadState->m_pAlternateWndInit == NULL); - - if (m_ofn.Flags & OFN_EXPLORER) - pThreadState->m_pAlternateWndInit = this; - else - AfxHookWindowCreate(this); - - int nResult; - if (m_bOpenFileDialog) - nResult = ::GetOpenFileName(&m_ofn); - else - nResult = ::GetSaveFileName(&m_ofn); - - if (nResult) - ASSERT(pThreadState->m_pAlternateWndInit == NULL); - pThreadState->m_pAlternateWndInit = NULL; - - // WINBUG: Second part of special case for file open/save dialog. - if (bEnableParent) - ::EnableWindow(m_ofn.hwndOwner, true); - if (::IsWindow(hWndFocus)) - ::SetFocus(hWndFocus); -*/ - - -void RMGfxEngine::SelectLocation(const RMPoint &ptTonyStart, const RMPoint &start) { -#if 0 - OPENFILENAME ofn; - char lpszFileName[512]; - - // @@@ Con TonyStart=-1,-1 allora usa la posizione scritta nella locazione - - // Sceglie la locazione - ZeroMemory(lpszFileName, 512); - ZeroMemory(&ofn, sizeof(ofn)); - ofn.lStructSize = sizeof(ofn); - ofn.hwndOwner = NULL; - ofn.lpstrFilter = "Locazione (*.LOC)\0*.LOC\0Locazione ottimizzata (*.LOX)\0*.LOX\0Tutti i files (*.*)\0*.*\0"; - ofn.lpstrCustomFilter = NULL; - ofn.nFilterIndex = 1; - ofn.lpstrFile = lpszFileName; - ofn.nMaxFile = 512; - ofn.lpstrInitialDir = NULL; - ofn.lpstrTitle = "Load Location"; - ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST; - - if (!GetOpenFileName(&ofn)) - ASSERT(0); - - // Carica la locazione - m_loc.Load(lpszFileName); - m_bLocationLoaded = true; - m_nCurLoc = m_loc.TEMPGetNumLoc(); - - if (ptTonyStart.x == -1 && ptTonyStart.y == -1) - InitForNewLocation(m_loc.TEMPGetNumLoc(), m_loc.TEMPGetTonyStart(), RMPoint(-1, -1)); - else - InitForNewLocation(m_loc.TEMPGetNumLoc(), ptTonyStart, start); -#endif -} void RMGfxEngine::InitForNewLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { if (start.x == -1 || start.y == -1) { @@ -487,18 +410,11 @@ uint32 RMGfxEngine::LoadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { bLoaded = false; for (i = 0; i < 5; i++) { - // Retry the loading of the location + // Try the loading of the location RMRes res(m_nCurLoc); if (!res.IsValid()) continue; -#if 0 - // codice per dumpare una locazione in caso serva una modifica - if (nLoc == 106) { - FILE *f = fopen("loc106.lox", "wb"); - fwrite(res.DataPointer(), res.Size(), 1, f); - fclose(f); - } -#endif + m_loc.Load(res); InitForNewLocation(nLoc, ptTonyStart, start); bLoaded = true; @@ -506,7 +422,7 @@ uint32 RMGfxEngine::LoadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { } if (!bLoaded) - SelectLocation(ptTonyStart, start); + error("Location was not loaded"); if (m_bOption) m_opt.ReInit(m_bigBuf); @@ -547,19 +463,8 @@ void RMGfxEngine::UnloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result) { CORO_END_CODE; } -void RMGfxEngine::Init(/*HINSTANCE hInst*/) { - /* - //RECUPERARE UNA LOCAZIONE: - - RMRes res(5); - ASSERT(res.IsValid()); - FILE *f; - f=fopen("c:\\code\\rm\\new\\pippo.loc","wb"); - fwrite(res,1,5356900,f); - fclose(f); - */ - - // Schermata di loading +void RMGfxEngine::Init() { + // Screen loading RMResRaw *raw; RMGfxSourceBuffer16 *load = NULL; INIT_GFX16_FROMRAW(20038, load); @@ -573,7 +478,7 @@ void RMGfxEngine::Init(/*HINSTANCE hInst*/) { GLOBALS.bPatIrqFreeze = true; - // GUI attivabile + // Activate GUI m_bGUIOption = true; m_bGUIInterface = true; m_bGUIInventory = true; @@ -593,7 +498,7 @@ void RMGfxEngine::Init(/*HINSTANCE hInst*/) { mpalInstallItemIrq(ItemIrq); // Initialise the input - m_input.Init(/*hInst*/); + m_input.Init(); // Initialise the mouse pointer m_point.Init(); @@ -608,40 +513,11 @@ void RMGfxEngine::Init(/*HINSTANCE hInst*/) { // Download the location and set priorities @@@@@ m_bLocationLoaded = false; - /* - m_nCurLoc=1; - RMRes res(m_nCurLoc); - m_loc.Load(res); - m_loc.SetPriority(1); - m_tony.SetPosition(RMPoint(201,316),1); - //m_tony.SetPosition(RMPoint(522,305),2); - //m_tony.SetPosition(RMPoint(158,398),4); - m_tony.SetPattern(m_tony.PAT_STANDDOWN); - m_curAction=TA_GOTO; - */ + EnableInput(); // Starting the game - //m_tony.ExecuteAction(4,1,0); //PREGAME - m_tony.ExecuteAction(20, 1, 0); - -// theLog << "Seleziona la locazione\n"; - //LoadLocation(1,RMPoint(201,316),RMPoint(-1,-1)); - //SelectLocation(); - //LoadLocation(5,RMPoint(685,338),RMPoint(-1,-1)); - //LoadLocation(7,RMPoint(153,424),RMPoint(-1,-1)); - //LoadLocation(70,RMPoint(10,10),RMPoint(-1,-1)); - //LoadLocation(20,RMPoint(112,348),RMPoint(-1,-1)); - //LoadLocation(26,RMPoint(95,456),RMPoint(-1,-1)); - //LoadLocation(12,RMPoint(221,415),RMPoint(-1,-1)); - //LoadLocation(25,RMPoint(221,415),RMPoint(-1,-1)); - //LoadLocation(16,RMPoint(111,438),RMPoint(-1,-1)); - //LoadLocation(60,RMPoint(18,302),RMPoint(-1,-1)); - - // CASTELLO - - //LoadLocation(40,RMPoint(233,441),RMPoint(-1,-1)); } void RMGfxEngine::Close(void) { diff --git a/engines/tony/gfxengine.h b/engines/tony/gfxengine.h index 06eb3cc4ba..b9ab411d2b 100644 --- a/engines/tony/gfxengine.h +++ b/engines/tony/gfxengine.h @@ -136,9 +136,6 @@ public: void SaveState(const Common::String &fn, byte *curThumb, const Common::String &name); void LoadState(CORO_PARAM, const Common::String &fn); - // Selects a location - void SelectLocation(const RMPoint &ptTonyStart = RMPoint(-1, -1), const RMPoint &start = RMPoint(-1, -1)); - // Pauses sound void PauseSound(bool bPause); diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index a2a4923093..e090faacdc 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -149,15 +149,10 @@ void RMInventory::Init(void) { RMMessage msg2(13); RMMessage msg3(14); - m_hints[0].WriteText(msg1[0], 1); - m_hints[1].WriteText(msg2[0], 1); - m_hints[2].WriteText(msg3[0], 1); + m_hints[0].WriteText(msg1[0], 1); // Examine + m_hints[1].WriteText(msg2[0], 1); // Take + m_hints[2].WriteText(msg3[0], 1); // Use - /* - m_hints[0].WriteText("Examine",1); - m_hints[1].WriteText("Talk",1); - m_hints[2].WriteText("Use",1); - */ // Prepare initial inventory Prepare(); @@ -251,7 +246,6 @@ void RMInventory::RemoveItem(int code) { g_system->lockMutex(m_csModifyInterface); Common::copy(&m_inv[i + 1], &m_inv[i + 1] + (m_nInv - i), &m_inv[i]); -// m_inv[m_nInv-1]=0; m_nInv--; Prepare(); @@ -260,8 +254,6 @@ void RMInventory::RemoveItem(int code) { g_system->unlockMutex(m_csModifyInterface); return; } - - //MessageBox(NULL,"Specified object is not in the inventory","INTERNAL ERROR",MB_OK|MB_ICONEXCLAMATION); } void RMInventory::AddItem(int code) { @@ -313,8 +305,6 @@ void RMInventory::Prepare(void) { // Frecce AddPrim(new RMGfxPrimitive(&m_items[29].icon, RMPoint(0, 0))); AddPrim(new RMGfxPrimitive(&m_items[28].icon, RMPoint(640 - 64, 0))); - - //AddPrim(new RMGfxPrimitive(&m_items[0].icon,RMPoint(0,0))); } bool RMInventory::MiniActive(void) { @@ -931,18 +921,12 @@ void RMInterface::Init(void) { RMMessage msg3(15); RMMessage msg4(16); - m_hints[0].WriteText(msg0[0], 1); - m_hints[1].WriteText(msg1[0], 1); - m_hints[2].WriteText(msg2[0], 1); - m_hints[3].WriteText(msg3[0], 1); - m_hints[4].WriteText(msg4[0], 1); - /* - m_hints[0].WriteText("Take",1); - m_hints[1].WriteText("Talk",1); - m_hints[2].WriteText("Use",1); - m_hints[3].WriteText("Examine",1); - m_hints[4].WriteText("Palesati",1); - */ + m_hints[0].WriteText(msg0[0], 1); // Take + m_hints[1].WriteText(msg1[0], 1); // Talk + m_hints[2].WriteText(msg2[0], 1); // Use + m_hints[3].WriteText(msg3[0], 1); // Examine + m_hints[4].WriteText(msg4[0], 1); // Show Yourself + m_bActive = false; m_bPalesati = false; m_lastHotZone = 0; diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 43e673b046..a90b1ecdb5 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -892,8 +892,6 @@ void RMWipe::WaitForFadeEnd(CORO_PARAM) { } void RMWipe::CloseFade(void) { -// m_bUnregister = true; -// WaitForSingleObject(m_hUnregistered,CORO_INFINITE); m_wip0r.Unload(); } @@ -1122,7 +1120,6 @@ void RMCharacter::GoTo(CORO_PARAM, RMPoint destcoord, bool bReversed) { olddx = dx; olddy = dy; - // ResetEvent(hTonyEndMovement); @@@ CORO_END_CODE; } @@ -1186,28 +1183,6 @@ RMPoint RMCharacter::Searching(char UP, char DOWN, char RIGHT, char LEFT, RMPoin RMPoint RMCharacter::NearestPoint(const RMPoint &punto) { -/* - RMPoint tofind; - signed short difx,dify; - - difx = m_pos.x-punto.x; - dify = m_pos.y-punto.y; - - if ((difx>0) && (dify>0)) tofind=Searching(0,1,1,0,punto); - if ((difx>0) && (dify<0)) tofind=Searching(1,0,1,0,punto); - if ((difx<0) && (dify>0)) tofind=Searching(0,1,0,1,punto); - if ((difx<0) && (dify<0)) tofind=Searching(1,0,0,1,punto); - - // Could be removed? Think @@@@ - if ((difx= = 0) && (dify>0)) tofind=Searching(0,1,1,1,punto); - if ((difx= = 0) && (dify<0)) tofind=Searching(1,0,1,1,punto); - if ((dify= = 0) && (difx>0)) tofind=Searching(1,1,1,0,punto); - if ((dify= = 0) && (difx<0)) tofind=Searching(1,1,0,1,punto); - - if ((dify= = 0) && (difx= = 0)) tofind=punto; - - return tofind; -*/ return Searching(1, 1, 1, 1, punto); } @@ -1547,8 +1522,6 @@ void RMCharacter::Stop(CORO_PARAM) { break; default: -// assert(0); -// MessageBox(NULL,"E' lo stesso errore di prima, ma non crasha","Ehi!",MB_OK); SetPattern(PAT_STANDDOWN); break; } @@ -1989,28 +1962,12 @@ bool RMLocation::Load(const char *lpszFileName) { */ bool RMLocation::Load(Common::File &file) { int size; -// byte *buf; -// uint32 dwReadBytes; bool bRet; // Calcola la lunghezza del file size = file.size(); file.seek(0); -/* - // Alloca la memoria per caricare il file in memoria - buf=(LPBYTE)GlobalAlloc(GMEM_FIXED,size); - - // Legge il file in memoria - ReadFile(hFile,buf,size,&dwReadBytes,0); - - // Parsing del file, utilizzando la funzione di load da memorira - bRet=Load(buf); - - // Free della memoria - GlobalFree(buf); -*/ - RMFileStreamSlow fs; fs.OpenFile(file); @@ -2112,10 +2069,6 @@ bool RMLocation::Load(RMDataStream &ds) { ds >> m_items[i]; _vm->UnfreezeTime(); - // Sets the initial pattern @@@ duplication! - //for (i = 0;iInit(ds, dimx, dimy, true); - // Check the size of the location -// assert(dimy!=512); - // Number of items ds >> m_nItems; diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index e539fa1a39..04e81d3a31 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -311,15 +311,6 @@ void TonyEngine::PreloadSFX(int nChannel, const char *fn) { _theSound.CreateSfx(&m_sfx[nChannel]); -/* - // Mette il path giusto - GetDataDirectory(DD_UTILSFX, path_buffer); - _splitpath(path_buffer,drive,dir,NULL,NULL); - _splitpath(fn,NULL,NULL,fname,ext); - _makepath(path_buffer,drive,dir,fname,ext); - - m_sfx[nChannel]->LoadFile(path_buffer, FPCODEC_ADPCM); -*/ m_sfx[nChannel]->LoadFile(fn, FPCODEC_ADPCM); } @@ -360,9 +351,6 @@ void TonyEngine::InitMusic() { // csMusic = g_system->createMutex(); // Preload sound effects -// PreloadUtilSFX(0,"AccendiOpzione.ADP"); -// PreloadUtilSFX(1,"ApriInterfaccia.ADP"); - PreloadUtilSFX(0, "U01.ADP"); // Reversed!! PreloadUtilSFX(1, "U02.ADP"); } -- cgit v1.2.3 From 29cbb3f824a7dc197c396e44de4efc702f04c89a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 20 May 2012 17:01:20 +1000 Subject: TONY: Miscellaneous comment translations and comment cleanup --- engines/tony/font.h | 2 +- engines/tony/game.cpp | 2 +- engines/tony/gfxcore.cpp | 2 +- engines/tony/loc.cpp | 2 +- engines/tony/mpal/mpaldll.h | 62 ++++----------------------------------------- 5 files changed, 9 insertions(+), 61 deletions(-) (limited to 'engines') diff --git a/engines/tony/font.h b/engines/tony/font.h index b7488399a4..6acfea7295 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -341,7 +341,7 @@ public: /** - * Gestisce la schermata di scelta delle voci di un dialogo + * Manages the selection of screen items in a box */ class RMDialogChoice : public RMGfxWoodyBuffer { private: diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 02eb996562..8fe05abb3b 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -1422,7 +1422,7 @@ bool RMOptionScreen::LoadThumbnailFromSaveState(int nState, byte *lpDestBuf, RMS cmpbuf = new byte[160 * 120 * 4]; - // Se la versione >= 5, compresso! + // Read in the compressed data cmpsize = f->readUint32LE(); f->read(cmpbuf, cmpsize); diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 170870a89b..6ec10b3aaa 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -1800,7 +1800,7 @@ void RMGfxSourceBuffer8RLEWordAA::Init(RMDataStream &ds, int dimx, int dimy, boo RMGfxSourceBuffer8RLE::Init(ds, dimx, dimy, bLoadPalette); if (!bNeedRLECompress) { - // Carica la maschera di antialiasing + // Load the anti-aliasing mask m_aabuf = new byte[dimx * dimy]; ds.Read(m_aabuf, dimx * dimy); } diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index a90b1ecdb5..d14b6972c8 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -1964,7 +1964,7 @@ bool RMLocation::Load(Common::File &file) { int size; bool bRet; - // Calcola la lunghezza del file + // Get the file size size = file.size(); file.seek(0); diff --git a/engines/tony/mpal/mpaldll.h b/engines/tony/mpal/mpaldll.h index 8216e7b166..90fa31ef1d 100644 --- a/engines/tony/mpal/mpaldll.h +++ b/engines/tony/mpal/mpaldll.h @@ -44,20 +44,11 @@ namespace MPAL { #define HEX_VERSION 0x0170 -/* - Safe - -#define MAX_ACTIONS_PER_ITEM 40 -#define MAX_COMMANDS_PER_ITEM 256 -#define MAX_COMMANDS_PER_ACTION 64 -#define MAX_DESCRIBE_SIZE 128 -*/ #define MAX_ACTIONS_PER_ITEM 40 #define MAX_COMMANDS_PER_ITEM 128 #define MAX_COMMANDS_PER_ACTION 128 -#define MAX_DESCRIBE_SIZE 64 - +#define MAX_DESCRIBE_SIZE 64 #define MAX_MOMENTS_PER_SCRIPT 256 @@ -65,22 +56,6 @@ namespace MPAL { #define MAX_COMMANDS_PER_MOMENT 32 - - - -/* - Secure version! - -#define MAX_GROUPS_PER_DIALOG 128 -#define MAX_COMMANDS_PER_DIALOG 640 -#define MAX_COMMANDS_PER_GROUP 64 -#define MAX_CHOICES_PER_DIALOG 64 -#define MAX_SELECTS_PER_CHOICE 33 -#define MAX_PLAYGROUPS_PER_SELECT 9 -#define MAX_PERIODS_PER_DIALOG 640 - -*/ - #define MAX_GROUPS_PER_DIALOG 128 #define MAX_COMMANDS_PER_DIALOG 480 #define MAX_COMMANDS_PER_GROUP 64 @@ -89,17 +64,6 @@ namespace MPAL { #define MAX_PLAYGROUPS_PER_SELECT 9 #define MAX_PERIODS_PER_DIALOG 400 -/* - Before Rufus: - -#define MAX_GROUPS_PER_DIALOG 128 -#define MAX_COMMANDS_PER_DIALOG 512 -#define MAX_COMMANDS_PER_GROUP 32 -#define MAX_CHOICES_PER_DIALOG 64 -#define MAX_SELECTS_PER_CHOICE 32 -#define MAX_PLAYGROUPS_PER_SELECT 4 -#define MAX_PERIODS_PER_DIALOG 512 -*/ #define NEED_LOCK_MSGS @@ -242,29 +206,13 @@ struct MPALITEM { struct command Command[MAX_COMMANDS_PER_ITEM]; - // Array of structures containing various managed activities. In practice, of - // every action we know what commands to run, including those defined in - // structures above -/* - struct - { - byte num; // Numero dell'azione - uint16 wTime; // In caso di idle, il tempo che deve passare - byte perc; // Percentuale di eseguire l'idle - HGLOBAL when; // Espressione da calcolare: se !=0, allora - // l'azione puo' essere eseguita - uint16 wParm; // Parametro per l'azione - - byte nCmds; // Numero comandi da eseguire - uint32 CmdNum[MAX_COMMANDS_PER_ACTION]; // Comando da eseguire - - } Action[MAX_ACTIONS_PER_ITEM]; - */ + // Pointer to array of structures containing various managed activities. In practice, of + // every action we know what commands to run, including those defined in structures above struct ItemAction *Action; } PACKED_STRUCT; -typedef MPALITEM* LPMPALITEM; -typedef LPMPALITEM* LPLPMPALITEM; +typedef MPALITEM *LPMPALITEM; +typedef LPMPALITEM *LPLPMPALITEM; /** -- cgit v1.2.3 From 7303849490881f75c990edba895118ec03152320 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 21 May 2012 00:11:14 +1000 Subject: TONY: Removed redundant pause code. The original paused the game whilst dragging the window, and ScummVM takes care of that automatically. --- engines/tony/tony.cpp | 42 ------------------------------------------ engines/tony/tony.h | 7 ------- 2 files changed, 49 deletions(-) (limited to 'engines') diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 04e81d3a31..b60a196ed1 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -503,10 +503,6 @@ void TonyEngine::PlayProcess(CORO_PARAM, const void *param) { // Game loop. We rely on the outer main process to detect if a shutdown is required, // and kill the scheudler and all the processes, including this one for (;;) { - // Se siamo in pausa, entra nel loop appropriato - if (_vm->m_bPaused) - _vm->PauseLoop(); - // If a savegame needs to be loaded, then do so if (_vm->_loadSlotNumber != -1 && GLOBALS.GfxEngine != NULL) { _ctx->fn = GetSaveStateFileName(_vm->_loadSlotNumber); @@ -576,44 +572,6 @@ void TonyEngine::GDIControl(bool bCon) { } -void TonyEngine::PauseLoop(void) { - warning("TODO: TonyEngine::PauseLoop"); - -#if 0 - MSG msg; - int st,et; - - st = GetTime(); - - while (m_bPaused && GetMessage(&msg,_window,0,0)) { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - - et = GetTime(); - - m_startTime += et - st; -#endif -} - -void TonyEngine::Pause(bool bPause) { - // If the new status already matches the current one, do nothing - if (m_bPaused == bPause) - return; - -warning("TODO: TonyEninge::Pause"); -/* - m_bPaused = bPause; - theEngine.GDIControl(m_bPaused); - - if (m_bPaused) { - SetWindowText(_window, "Tony Tough and the night of Roasted Moths - PAUSED"); - } else { - SetWindowText(_window, "Tony Tough and the night of Roasted Moths"); - } -*/ -} - void TonyEngine::FreezeTime(void) { m_bTimeFreezed = true; m_nTimeFreezed = GetTime() - m_startTime; diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 8d4e357079..23c235d058 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -152,9 +152,6 @@ public: // Warn when are being controlled by the GDI void GDIControl(bool bCon); - // Loop that handles messages when the game is paused - void PauseLoop(void); - void Play(); void Close(); void Abort(); @@ -167,10 +164,6 @@ public: void ShowLocation(void) { m_bDrawLocation = true; } void HideLocation(void) { m_bDrawLocation = false; } - // Handle pause mode - void Pause(bool bPause); - bool IsPaused() { return m_bPaused; } - // Reads the time uint32 GetTime(void); void FreezeTime(void); -- cgit v1.2.3 From 3f00f51ef3239b02e01fed80c9205835b2d654e9 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 21 May 2012 23:11:59 +1000 Subject: TONY: Improve the screen wipe logic. The circular area now properly reaches to the edge of the screen when changing scenes. --- engines/tony/window.cpp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'engines') diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index 481393c5ed..0f36c72f97 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -138,8 +138,17 @@ void RMWindow::GetNewFrameWipe(byte *lpBuf, Common::Rect &rcBoundEllipse) { Common::Point center(rcBoundEllipse.left + rcBoundEllipse.width() / 2, rcBoundEllipse.top + rcBoundEllipse.height() / 2); - int radius = rcBoundEllipse.width() / 2; + // The rectangle technically defines the area inside the ellipse, with the corners touching + // the ellipse boundary. Since we're currently simulating the ellipse using a plain circle, + // we need to calculate a necessary width using the hypotenuse of X/2 & Y/2 + int x2y2 = (rcBoundEllipse.width() / 2) * (rcBoundEllipse.width() / 2) + + (rcBoundEllipse.height() / 2) * (rcBoundEllipse.height() / 2); + int radius = 0; + while ((radius * radius) < x2y2) + ++radius; + + // Proceed copying a circular area of the frame with the calculated radius onto the screen int error = -radius; int x = radius; int y = 0; @@ -177,17 +186,19 @@ void RMWindow::plotLines(const byte *lpBuf, const Common::Point ¢er, int x, return; const byte *pSrc; + int xs = MAX(center.x - x, 0); + int width = MIN(RM_SX - xs, x * 2); if ((center.y - y) >= 0) { // Draw line in top half of circle - pSrc = lpBuf + ((center.y - y) * RM_SX * 2) + (center.x - x) * 2; - g_system->copyRectToScreen(pSrc, RM_SX * 2, center.x - x, center.y - y, x * 2, 1); + pSrc = lpBuf + ((center.y - y) * RM_SX * 2) + xs * 2; + g_system->copyRectToScreen(pSrc, RM_SX * 2, xs, center.y - y, width, 1); } if ((center.y + y) < RM_SY) { // Draw line in bottom half of circle - pSrc = lpBuf + ((center.y + y) * RM_SX * 2) + (center.x - x) * 2; - g_system->copyRectToScreen(pSrc, RM_SX * 2, center.x - x, center.y + y, x * 2, 1); + pSrc = lpBuf + ((center.y + y) * RM_SX * 2) + xs * 2; + g_system->copyRectToScreen(pSrc, RM_SX * 2, xs, center.y + y, width, 1); } } -- cgit v1.2.3 From 6856fa2447195e8a65f6d5c7efa73543668d85b0 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 22 May 2012 00:29:27 +1000 Subject: TONY: Implemented ScummVM debugger, with an initial 'scene' command --- engines/tony/debugger.cpp | 116 ++++++++++++++++++++++++++++++++++++++++++++++ engines/tony/debugger.h | 42 +++++++++++++++++ engines/tony/input.cpp | 11 ++++- engines/tony/loc.h | 1 + engines/tony/module.mk | 1 + engines/tony/tony.cpp | 7 +++ engines/tony/tony.h | 2 + 7 files changed, 179 insertions(+), 1 deletion(-) create mode 100644 engines/tony/debugger.cpp create mode 100644 engines/tony/debugger.h (limited to 'engines') diff --git a/engines/tony/debugger.cpp b/engines/tony/debugger.cpp new file mode 100644 index 0000000000..f358d51223 --- /dev/null +++ b/engines/tony/debugger.cpp @@ -0,0 +1,116 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/coroutines.h" +#include "tony/debugger.h" +#include "tony/globals.h" +#include "tony/tony.h" + +namespace Tony { + +Debugger::Debugger() : GUI::Debugger() { + DCmd_Register("continue", WRAP_METHOD(Debugger, Cmd_Exit)); + DCmd_Register("scene", WRAP_METHOD(Debugger, Cmd_Scene)); +} + +static int strToInt(const char *s) { + if (!*s) + // No string at all + return 0; + else if (toupper(s[strlen(s) - 1]) != 'H') + // Standard decimal string + return atoi(s); + + // Hexadecimal string + uint tmp = 0; + int read = sscanf(s, "%xh", &tmp); + if (read < 1) + error("strToInt failed on string \"%s\"", s); + return (int)tmp; +} + +/** + * Support process for changing the scene + */ +struct ChangeSceneDetails { + int sceneNumber; + int x; + int y; +}; + +void DebugChangeScene(CORO_PARAM, const void *param) { + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + uint32 result; + const ChangeSceneDetails *details = (const ChangeSceneDetails *)param; + RMPoint scenePos(details->x, details->y); + + CORO_BEGIN_CODE(_ctx); + + CORO_INVOKE_2(GLOBALS.UnloadLocation, false, &result); + + GLOBALS.LoadLocation(details->sceneNumber, scenePos, RMPoint(-1, -1)); + + MainEnableGUI(); + + CORO_END_CODE; +} + + +/** + * This command loads up the specified new scene number + */ +bool Debugger::Cmd_Scene(int argc, const char **argv) { + if (argc < 2) { + DebugPrintf("Usage: %s [ ]\n", argv[0]); + return true; + } + + int sceneNumber = strToInt(argv[1]); + if (sceneNumber >= _vm->_theBoxes.GetLocBoxesCount()) { + DebugPrintf("Invalid scene\n"); + return true; + } + + RMPoint scenePos; + if (argc >= 4) { + scenePos.x = strToInt(argv[2]); + scenePos.y = strToInt(argv[3]); + } else { + // Get the box areas for the scene, and choose one so as to have a default + // position for Tony that will be in the walkable areas + RMBoxLoc *box = _vm->_theBoxes.GetBoxes(sceneNumber); + scenePos.Set(box->boxes[0].hotspot[0].hotx, box->boxes[0].hotspot[0].hoty); + } + + // Set up a process to change the scene + ChangeSceneDetails details; + details.sceneNumber = sceneNumber; + details.x = scenePos.x; + details.y = scenePos.y; + CoroScheduler.createProcess(DebugChangeScene, &details, sizeof(ChangeSceneDetails)); + + return false; +} + +} // End of namespace Tony diff --git a/engines/tony/debugger.h b/engines/tony/debugger.h new file mode 100644 index 0000000000..c5ed5e417e --- /dev/null +++ b/engines/tony/debugger.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. + * + */ + +#ifndef TONY_DEBUGGER_H +#define TONY_DEBUGGER_H + +#include "common/scummsys.h" +#include "gui/debugger.h" + +namespace Tony { + +class Debugger : public GUI::Debugger { +public: + Debugger(); + virtual ~Debugger() {} + +protected: + bool Cmd_Scene(int argc, const char **argv); +}; + +} // End of namespace Tony + +#endif diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp index 7663774ee4..c1104204b5 100644 --- a/engines/tony/input.cpp +++ b/engines/tony/input.cpp @@ -27,6 +27,7 @@ */ #include "tony/gfxengine.h" +#include "tony/tony.h" namespace Tony { @@ -79,7 +80,15 @@ void RMInput::Poll(void) { return; case Common::EVENT_KEYDOWN: - _keyDown[(int)_event.kbd.keycode] = true; + // Check for debugger + if ((_event.kbd.keycode == Common::KEYCODE_d) && (_event.kbd.flags & Common::KBD_CTRL)) { + // Attach to the debugger + _vm->_debugger->attach(); + _vm->_debugger->onFrame(); + } else { + // Flag the given key as being down + _keyDown[(int)_event.kbd.keycode] = true; + } return; case Common::EVENT_KEYUP: diff --git a/engines/tony/loc.h b/engines/tony/loc.h index 4b9a18f406..7085c81dcb 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -353,6 +353,7 @@ public: // Get binding boxes for a given location RMBoxLoc *GetBoxes(int nLoc); + int GetLocBoxesCount() const { return m_nLocBoxes; } // Return the box which contains a given point int WhichBox(int nLoc, const RMPoint &pt); diff --git a/engines/tony/module.mk b/engines/tony/module.mk index 719a598ee4..d66cf6f065 100644 --- a/engines/tony/module.mk +++ b/engines/tony/module.mk @@ -2,6 +2,7 @@ MODULE := engines/tony MODULE_OBJS := \ custom.o \ + debugger.o \ detection.o \ font.o \ game.o \ diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index b60a196ed1..e5988e7c9b 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -28,6 +28,7 @@ #include "common/file.h" #include "tony/tony.h" #include "tony/custom.h" +#include "tony/debugger.h" #include "tony/game.h" #include "tony/mpal/mpal.h" @@ -40,6 +41,7 @@ TonyEngine::TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc) : Eng _vm = this; _loadSlotNumber = -1; + _debugger = new Debugger(); DebugMan.addDebugChannel(kTonyDebugAnimations, "animations", "Animations debugging"); DebugMan.addDebugChannel(kTonyDebugActions, "actions", "Actions debugging"); DebugMan.addDebugChannel(kTonyDebugSound, "sound", "Sound debugging"); @@ -60,6 +62,8 @@ TonyEngine::~TonyEngine() { // Reset the coroutine scheduler CoroScheduler.reset(); + + delete _debugger; } /** @@ -529,6 +533,9 @@ void TonyEngine::PlayProcess(CORO_PARAM, const void *param) { // Paint the frame onto the screen _vm->_window.Repaint(); + + // Signal the ScummVM debugger + _vm->_debugger->onFrame(); } CORO_END_CODE; diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 23c235d058..bdaffee7c9 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -34,6 +34,7 @@ #include "tony/mpal/mpal.h" #include "tony/mpal/memory.h" +#include "tony/debugger.h" #include "tony/gfxengine.h" #include "tony/loc.h" #include "tony/utils.h" @@ -101,6 +102,7 @@ public: Common::Array _voices; FPSOUND _theSound; Globals _globals; + Debugger *_debugger; enum DATADIR { DD_BASE = 1, -- cgit v1.2.3 From 94d3c8ebb29699a6c7a76c08986b984523761d63 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 21 May 2012 23:53:13 +0200 Subject: TONY: Some more code formatting --- engines/tony/detection.cpp | 2 +- engines/tony/font.cpp | 30 +- engines/tony/game.cpp | 2 +- engines/tony/gfxcore.cpp | 16 +- engines/tony/gfxcore.h | 2 +- engines/tony/inventory.cpp | 18 +- engines/tony/inventory.h | 35 ++- engines/tony/loc.cpp | 463 +++++++++++++++--------------- engines/tony/loc.h | 218 +++++++++------ engines/tony/resid.h | 20 +- engines/tony/sound.cpp | 669 ++++++++++++++++++++++---------------------- engines/tony/sound.h | 680 ++++++++++++++++++++++----------------------- engines/tony/tony.cpp | 75 +++-- engines/tony/tony.h | 26 +- engines/tony/tonychar.cpp | 167 +++++------ engines/tony/tonychar.h | 42 ++- engines/tony/utils.cpp | 188 ++++++------- engines/tony/utils.h | 305 ++++++++++---------- engines/tony/window.cpp | 44 +-- engines/tony/window.h | 6 +- 20 files changed, 1544 insertions(+), 1464 deletions(-) (limited to 'engines') diff --git a/engines/tony/detection.cpp b/engines/tony/detection.cpp index 63bb02a5f2..a87dd9bd07 100644 --- a/engines/tony/detection.cpp +++ b/engines/tony/detection.cpp @@ -147,7 +147,7 @@ void TonyMetaEngine::removeSaveState(const char *target, int slot) const { SaveStateDescriptor TonyMetaEngine::querySaveMetaInfos(const char *target, int slot) const { Tony::RMString saveName; byte difficulty; - byte thumbData[160 * 120 * 2]; + byte thumbData[160 * 120 * 2]; if (Tony::RMOptionScreen::LoadThumbnailFromSaveState(slot, thumbData, saveName, difficulty)) { // Convert the 565 thumbnail data to the needed overlay format diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index a15a79b16c..66f1ccdcd9 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -51,10 +51,10 @@ RMFont::~RMFont() { /** * Dumps a font to a buffer - * @param buf Buffer for font contents - * @param nChars Number of characters (max 256) - * @param dimx X dimension in pixels - * @param dimy Y dimension in pixels + * @param buf Buffer for font contents + * @param nChars Number of characters (max 256) + * @param dimx X dimension in pixels + * @param dimy Y dimension in pixels * \****************************************************************************/ @@ -323,7 +323,7 @@ void RMFontParla::Init(void) { lTable['E'] = 10; lTable['F'] = 11; - if (_vm->getLanguage() == Common::PL_POL) { + if (_vm->getLanguage() == Common::PL_POL) { // Polish characters //AaCcEeLlNnOoSsZzZz //ス謎戊3剔囀 @@ -370,7 +370,7 @@ void RMFontParla::Init(void) { // Russian Characters // WARNING: The Russian font uses many of the ISO-Latin-1 font, - // allowing for further translations. To support Tonyin other langauges, + // allowing for further translations. To support Tonyin other langauges, // these mappings could be used as a basis cTable[(byte)''] = 130; @@ -575,7 +575,7 @@ void RMFontParla::Init(void) { lTable[(byte)''] = 13; lTable[(byte)''] = 13; - } else if (_vm->getLanguage() == Common::FR_FRA) { + } else if (_vm->getLanguage() == Common::FR_FRA) { // French cTable[(byte)''] = 226; @@ -687,7 +687,7 @@ void RMFontMacc::Init(void) { //cTable[(byte)''] = 100; // u with ball cTable[(byte)''] = 101; - if (_vm->getLanguage() == Common::PL_POL) { + if (_vm->getLanguage() == Common::PL_POL) { // Polish characters //AaCcEeLlNnOoSsZzZz //ス謎戊3剔囀 @@ -733,7 +733,7 @@ void RMFontMacc::Init(void) { } else if (_vm->getLanguage() == Common::RU_RUS) { // Russian Characters // WARNING: The Russian font uses many of the ISO-Latin-1 font, - // allowing for further translations. To support Tonyin other langauges, + // allowing for further translations. To support Tonyin other langauges, // these mappings could be used as a basis cTable[(byte)''] = 120; cTable[(byte)''] = 121; @@ -1183,7 +1183,7 @@ void RMFontCredits::Init(void) { } else if (_vm->getLanguage() == Common::RU_RUS) { // Russian Characters // WARNING: The Russian font uses many of the ISO-Latin-1 font, - // allowing for further translations. To support Tonyin other langauges, + // allowing for further translations. To support Tonyin other langauges, // these mappings could be used as a basis cTable[(byte)''] = 130; cTable[(byte)''] = 131; @@ -1581,7 +1581,7 @@ void RMFontObj::Init(void) { SetBothCase('R', 'R', 1); SetBothCase('R', 'U', 3); - if (_vm->getLanguage() == Common::PL_POL) { + if (_vm->getLanguage() == Common::PL_POL) { // Polish characters //ス謎戊3剔囀 //AaCcEeLlNnOoSsZzZz @@ -1614,8 +1614,8 @@ void RMFontObj::Init(void) { } else if (_vm->getLanguage() == Common::RU_RUS) { // Russian Characters - // WARNING: The Russian font uses many of the ISO-Latin-1 font, - // allowing for further translations. To support Tonyin other langauges, + // WARNING: The Russian font uses many of the ISO-Latin-1 font, + // allowing for further translations. To support Tonyin other langauges, // these mappings could be used as a basis cTable[(byte)''] = cTable[(byte)''] = 85; @@ -1725,7 +1725,7 @@ void RMFontObj::Init(void) { lTable[(byte)''] = lTable[(byte)''] = 16; lTable[(byte)''] = lTable[(byte)''] = 16; - } else if (_vm->getLanguage() == Common::FR_FRA) { + } else if (_vm->getLanguage() == Common::FR_FRA) { // French // Translate accented characters as normal letters @@ -1854,7 +1854,7 @@ void RMText::WriteText(const RMString &text, RMFontColor *font, int *time) { // Back to the first usable space // // BERNIE: In the original, sentences containing words that exceed the - // width of a line caused discontinuation of the whole sentence. + // width of a line caused discontinuation of the whole sentence. // This workaround has the partial word broken up so it will still display // old_p = p; diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 8fe05abb3b..dc5e412f00 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -43,7 +43,7 @@ namespace Tony { using namespace MPAL; /****************************************/ -/* Global functions */ +/* Global functions */ /****************************************/ uint32 MainLoadLocation(int nLoc, RMPoint pt, RMPoint start) { diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 6ec10b3aaa..be59a2d9a5 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -173,7 +173,7 @@ bool RMGfxSourceBuffer::Clip2D(int &x1, int &y1, int &u, int &v, int &width, int if (x1 > destw - 1) return false; - + if (y1 > desth - 1) return false; @@ -206,11 +206,11 @@ bool RMGfxSourceBuffer::Clip2D(int &x1, int &y1, int &u, int &v, int &width, int /** * Initialises a surface by resource Id * - * @param resID Resource ID - * @param dimx Buffer X dimension - * @param dimy Buffer Y dimension + * @param resID Resource ID + * @param dimx Buffer X dimension + * @param dimy Buffer Y dimension */ - int RMGfxSourceBuffer::Init(uint32 resID, int dimx, int dimy, bool bLoadPalette) { +int RMGfxSourceBuffer::Init(uint32 resID, int dimx, int dimy, bool bLoadPalette) { return Init(RMRes(resID), dimx, dimy, bLoadPalette); } @@ -478,7 +478,7 @@ RMGfxSourceBuffer4::RMGfxSourceBuffer4(int dimx, int dimy, bool bUseDDraw) /** * Returns the number of bits per pixel of the surface * - * @returns Bit per pixel + * @returns Bit per pixel */ int RMGfxSourceBuffer4::Bpp() { return 4; @@ -565,7 +565,7 @@ RMGfxSourceBuffer8::RMGfxSourceBuffer8(bool bTrasp0) { /** * Returns the number of bits per pixel of the surface * - * @returns Bit per pixel + * @returns Bit per pixel */ int RMGfxSourceBuffer8::Bpp() { return 8; @@ -1894,7 +1894,7 @@ RMGfxSourceBuffer16::RMGfxSourceBuffer16(int dimx, int dimy, bool bUseDDraw) /** * Returns the number of bits per pixel of the surface * - * @returns Bit per pixel + * @returns Bit per pixel */ int RMGfxSourceBuffer16::Bpp() { return 16; diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index f7ea40fa9b..ffeb7724b2 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -39,7 +39,7 @@ namespace Tony { * Prototipi di classi \****************************************************************************/ -// Class Name Family Treee Abstract? +// Class Name Family Treee Abstract? class RMGfxTask; // Yes class RMGfxTaskSetPrior; // Task Yes class RMGfxBuffer; // diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index e090faacdc..539dd4e81b 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -100,7 +100,7 @@ void RMInventory::Init(void) { assert(res.IsValid()); - // Initialise the MPAL inventory item by reading it in. + // Initialise the MPAL inventory item by reading it in. m_items[i].icon.SetInitCurPattern(false); ds.OpenBuffer(res); ds >> m_items[i].icon; @@ -149,9 +149,9 @@ void RMInventory::Init(void) { RMMessage msg2(13); RMMessage msg3(14); - m_hints[0].WriteText(msg1[0], 1); // Examine - m_hints[1].WriteText(msg2[0], 1); // Take - m_hints[2].WriteText(msg3[0], 1); // Use + m_hints[0].WriteText(msg1[0], 1); // Examine + m_hints[1].WriteText(msg2[0], 1); // Take + m_hints[2].WriteText(msg3[0], 1); // Use // Prepare initial inventory @@ -921,11 +921,11 @@ void RMInterface::Init(void) { RMMessage msg3(15); RMMessage msg4(16); - m_hints[0].WriteText(msg0[0], 1); // Take - m_hints[1].WriteText(msg1[0], 1); // Talk - m_hints[2].WriteText(msg2[0], 1); // Use - m_hints[3].WriteText(msg3[0], 1); // Examine - m_hints[4].WriteText(msg4[0], 1); // Show Yourself + m_hints[0].WriteText(msg0[0], 1); // Take + m_hints[1].WriteText(msg1[0], 1); // Talk + m_hints[2].WriteText(msg2[0], 1); // Use + m_hints[3].WriteText(msg3[0], 1); // Examine + m_hints[4].WriteText(msg4[0], 1); // Show Yourself m_bActive = false; m_bPalesati = false; diff --git a/engines/tony/inventory.h b/engines/tony/inventory.h index 678caa1c78..a5f02603e7 100644 --- a/engines/tony/inventory.h +++ b/engines/tony/inventory.h @@ -40,7 +40,7 @@ namespace Tony { struct RMInventoryItem { RMItem icon; - RMGfxSourceBuffer8RLEByteAA *pointer; + RMGfxSourceBuffer8RLEByteAA *pointer; int status; }; @@ -57,7 +57,7 @@ private: protected: int m_nItems; RMInventoryItem *m_items; - + int m_inv[256]; int m_nInv; int m_curPutY; @@ -69,13 +69,13 @@ protected: int m_nSelectObj; int m_nCombine; bool m_bCombining; - + bool m_bBlinkingRight, m_bBlinkingLeft; int miniAction; RMItem miniInterface; RMText m_hints[3]; - + OSystem::MutexRef m_csModifyInterface; protected: @@ -90,7 +90,7 @@ public: virtual ~RMInventory(); // Prepare a frame - void DoFrame(RMGfxTargetBuffer& bigBuf, RMPointer &ptr, RMPoint mpos, bool bCanOpen); + void DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpos, bool bCanOpen); // Initialisation and closing void Init(void); @@ -111,20 +111,29 @@ public: // Handle the left mouse click (only when the inventory has the focus) bool LeftClick(const RMPoint &mpos, int &nCombineObj); - + // Handle the right mouse button (only when the inventory has the focus) void RightClick(const RMPoint &mpos); bool RightRelease(const RMPoint &mpos, RMTonyAction &curAction); // Warn that an item combine is over void EndCombine(void); - -public: + +public: // Add an item to the inventory void AddItem(int code); - RMInventory& operator+=(RMItem *item) { AddItem(item->MpalCode()); return *this; } - RMInventory& operator+=(RMItem &item) { AddItem(item.MpalCode()); return *this; } - RMInventory& operator+=(int code) { AddItem(code); return *this; } + RMInventory &operator+=(RMItem *item) { + AddItem(item->MpalCode()); + return *this; + } + RMInventory &operator+=(RMItem &item) { + AddItem(item.MpalCode()); + return *this; + } + RMInventory &operator+=(int code) { + AddItem(code); + return *this; + } // Removes an item void RemoveItem(int code); @@ -163,10 +172,10 @@ public: virtual ~RMInterface(); // The usual DoFrame (poll the graphics engine) - void DoFrame(RMGfxTargetBuffer& bigBuf, RMPoint mousepos); + void DoFrame(RMGfxTargetBuffer &bigBuf, RMPoint mousepos); // TRUE if it is active (you can select items) - bool Active(); + bool Active(); // Initialisation void Init(void); diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index d14b6972c8..f0dd30b1a9 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -44,13 +44,13 @@ using namespace ::Tony::MPAL; /** * Operator for reading palette information from a data stream. * - * @param ds Data stream - * @param pal Destination palette + * @param ds Data stream + * @param pal Destination palette * - * @returns Reference to the data stream + * @returns Reference to the data stream */ RMDataStream &operator>>(RMDataStream &ds, RMPalette &pal) { - ds.Read(pal.m_data,1024); + ds.Read(pal.m_data, 1024); return ds; } @@ -61,10 +61,10 @@ RMDataStream &operator>>(RMDataStream &ds, RMPalette &pal) { /** * Operator for reading slot information from a data stream. * - * @param ds Data stream - * @param slot Destination slot + * @param ds Data stream + * @param slot Destination slot * - * @returns Reference to the data stream + * @returns Reference to the data stream */ RMDataStream &operator>>(RMDataStream &ds, RMPattern::RMSlot &slot) { slot.ReadFromStream(ds); @@ -78,7 +78,7 @@ void RMPattern::RMSlot::ReadFromStream(RMDataStream &ds, bool bLOX) { // Type ds >> type; m_type = (RMPattern::RMSlotType)type; - + // Dati ds >> m_data; @@ -97,10 +97,10 @@ void RMPattern::RMSlot::ReadFromStream(RMDataStream &ds, bool bLOX) { /** * Operator for reading pattern information from a data stream * - * @param ds Data stream - * @param pat Destination pattern + * @param ds Data stream + * @param pat Destination pattern * - * @returns Reference to the data stream + * @returns Reference to the data stream */ RMDataStream &operator>>(RMDataStream &ds, RMPattern &pat) { pat.ReadFromStream(ds); @@ -170,35 +170,35 @@ int RMPattern::Init(RMSfx *sfx, bool bPlayP0, byte *bFlag) { m_nCurSprite = m_slots[i].m_data; if (bFlag) *bFlag = m_slots[i].m_flag; - + // Calculate the current coordinates UpdateCoord(); - + // Check for sound: // If the slot is 0, play // If speed = 0, must playing unless it goes into loop '_', or if specified by the parameter // If speed != 0, play only the loop - for (i = 0;i < m_nSlots; i++) { + for (i = 0; i < m_nSlots; i++) { if (m_slots[i].m_type == SOUND) { if (i == 0) { if (sfx[m_slots[i].m_data].m_name[0] == '_') { - sfx[m_slots[i].m_data].SetVolume(m_slots[i].Pos().x); + sfx[m_slots[i].m_data].SetVolume(m_slots[i].Pos().x); sfx[m_slots[i].m_data].Play(true); } else { - sfx[m_slots[i].m_data].SetVolume(m_slots[i].Pos().x); + sfx[m_slots[i].m_data].SetVolume(m_slots[i].Pos().x); sfx[m_slots[i].m_data].Play(); } } else if (m_speed == 0) { if (bPlayP0) { - sfx[m_slots[i].m_data].SetVolume(m_slots[i].Pos().x); + sfx[m_slots[i].m_data].SetVolume(m_slots[i].Pos().x); sfx[m_slots[i].m_data].Play(); } else if (sfx[m_slots[i].m_data].m_name[0] == '_') { - sfx[m_slots[i].m_data].SetVolume(m_slots[i].Pos().x); + sfx[m_slots[i].m_data].SetVolume(m_slots[i].Pos().x); sfx[m_slots[i].m_data].Play(true); } } else { if (m_bLoop && sfx[m_slots[i].m_data].m_name[0] == '_') { - sfx[m_slots[i].m_data].SetVolume(m_slots[i].Pos().x); + sfx[m_slots[i].m_data].SetVolume(m_slots[i].Pos().x); sfx[m_slots[i].m_data].Play(true); } } @@ -214,13 +214,13 @@ int RMPattern::Update(uint32 hEndPattern, byte &bFlag, RMSfx *sfx) { // If the speed is 0, then the pattern never advances if (m_speed == 0) { CoroScheduler.pulseEvent(hEndPattern); - bFlag=m_slots[m_nCurSlot].m_flag; + bFlag = m_slots[m_nCurSlot].m_flag; return m_nCurSprite; } // Is it time to change the slots? while (m_nStartTime + m_speed <= (uint32)CurTime) { - m_nStartTime += m_speed; + m_nStartTime += m_speed; if (m_slots[m_nCurSlot].m_type == SPRITE) m_nCurSlot++; if (m_nCurSlot == m_nSlots) { @@ -234,7 +234,7 @@ int RMPattern::Update(uint32 hEndPattern, byte &bFlag, RMSfx *sfx) { if (!m_bLoop) { m_nCurSlot = m_nSlots - 1; bFlag = m_slots[m_nCurSlot].m_flag; - return m_nCurSprite; + return m_nCurSprite; } } @@ -243,7 +243,7 @@ int RMPattern::Update(uint32 hEndPattern, byte &bFlag, RMSfx *sfx) { case SPRITE: // Read the next sprite m_nCurSprite = m_slots[m_nCurSlot].m_data; - + // Update the parent & child coordinates UpdateCoord(); break; @@ -262,7 +262,7 @@ int RMPattern::Update(uint32 hEndPattern, byte &bFlag, RMSfx *sfx) { case COMMAND: assert(0); break; - + default: assert(0); break; @@ -271,11 +271,11 @@ int RMPattern::Update(uint32 hEndPattern, byte &bFlag, RMSfx *sfx) { if (m_slots[m_nCurSlot].m_type == SPRITE) break; m_nCurSlot++; - } + } } // Return the current sprite - bFlag=m_slots[m_nCurSlot].m_flag; + bFlag = m_slots[m_nCurSlot].m_flag; return m_nCurSprite; } @@ -283,11 +283,11 @@ RMPattern::RMPattern() { m_slots = NULL; m_speed = 0; m_bLoop = 0; - m_nSlots = 0; + m_nSlots = 0; m_nCurSlot = 0; m_nCurSprite = 0; m_nStartTime = 0; - m_slots = NULL; + m_slots = NULL; } RMPattern::~RMPattern() { @@ -307,10 +307,10 @@ RMPattern::~RMPattern() { /** * Operator for reading sprite information from a data stream. * - * @param ds Data stream - * @param sprite Destination slot + * @param ds Data stream + * @param sprite Destination slot * - * @returns Reference to the data stream + * @returns Reference to the data stream */ RMDataStream &operator>>(RMDataStream &ds, RMSprite &sprite) { sprite.ReadFromStream(ds); @@ -339,8 +339,8 @@ void RMSprite::GetSizeFromStream(RMDataStream &ds, int *dimx, int *dimy) { } void RMSprite::ReadFromStream(RMDataStream &ds, bool bLOX) { - int dimx,dimy; - + int dimx, dimy; + // Sprite name if (!bLOX) ds >> m_name; @@ -364,11 +364,11 @@ void RMSprite::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) } void RMSprite::SetPalette(byte *buf) { - ((RMGfxSourceBufferPal*)m_buf)->LoadPalette(buf); + ((RMGfxSourceBufferPal *)m_buf)->LoadPalette(buf); } RMSprite::RMSprite() { - m_buf= NULL; + m_buf = NULL; } RMSprite::~RMSprite() { @@ -386,10 +386,10 @@ RMSprite::~RMSprite() { /** * Operator for reading SFX information from a data stream. * - * @param ds Data stream - * @param sfx Destination SFX + * @param ds Data stream + * @param sfx Destination SFX * - * @returns Reference to the data stream + * @returns Reference to the data stream */ RMDataStream &operator>>(RMDataStream &ds, RMSfx &sfx) { sfx.ReadFromStream(ds); @@ -400,10 +400,10 @@ void RMSfx::ReadFromStream(RMDataStream &ds, bool bLOX) { char id[4]; int size; byte *raw; - + // sfx name ds >> m_name; - + ds >> size; // Upload the sound effect identifier from the buffer @@ -416,7 +416,7 @@ void RMSfx::ReadFromStream(RMDataStream &ds, bool bLOX) { ds >> size; // Read the raw WAV data - raw = new byte[size]; + raw = new byte[size]; ds.Read(raw, size); // Create the sound effect @@ -477,10 +477,10 @@ void RMSfx::Stop(void) { /** * Operator for reading item information from a data stream. * - * @param ds Data stream - * @param tem Destination item + * @param ds Data stream + * @param tem Destination item * - * @returns Reference to the data stream + * @returns Reference to the data stream */ RMDataStream &operator>>(RMDataStream &ds, RMItem &item) { item.ReadFromStream(ds); @@ -491,15 +491,15 @@ RMDataStream &operator>>(RMDataStream &ds, RMItem &item) { RMGfxSourceBuffer *RMItem::NewItemSpriteBuffer(int dimx, int dimy, bool bPreRLE) { if (m_cm == CM_256) { RMGfxSourceBuffer8RLE *spr; - - if (m_FX == 2) { // AB + + if (m_FX == 2) { // AB spr = new RMGfxSourceBuffer8RLEWordAB; - } else if (m_FX == 1) { // OMBRA+AA + } else if (m_FX == 1) { // OMBRA+AA if (dimx == -1 || dimx > 255) spr = new RMGfxSourceBuffer8RLEWordAA; else spr = new RMGfxSourceBuffer8RLEByteAA; - + spr->SetAlphaBlendColor(m_FXparm); if (bPreRLE) spr->SetAlreadyCompressed(); @@ -518,25 +518,25 @@ RMGfxSourceBuffer *RMItem::NewItemSpriteBuffer(int dimx, int dimy, bool bPreRLE) return new RMGfxSourceBuffer16; } -bool RMItem::IsIn(const RMPoint &pt, int *size) { +bool RMItem::IsIn(const RMPoint &pt, int *size) { RMRect rc; - - if (!m_bIsActive) - return false; - + + if (!m_bIsActive) + return false; + // Search for the right bounding box to use - use the sprite's if it has one, otherwise use the generic one if (m_nCurPattern != 0 && !m_sprites[m_nCurSprite].m_rcBox.IsEmpty()) - rc=m_sprites[m_nCurSprite].m_rcBox + CalculatePos(); + rc = m_sprites[m_nCurSprite].m_rcBox + CalculatePos(); else if (!m_rcBox.IsEmpty()) rc = m_rcBox; // If no box, return immediately else return false; - - if (size != NULL) - *size = rc.Size(); - - return rc.PtInRect(pt + m_curScroll); + + if (size != NULL) + *size = rc.Size(); + + return rc.PtInRect(pt + m_curScroll); } @@ -566,7 +566,8 @@ void RMItem::ReadFromStream(RMDataStream &ds, bool bLOX) { ds >> m_nSprites >> m_nSfx >> m_nPatterns; // Color mode - ds >> cm; m_cm=(RMColorMode)cm; + ds >> cm; + m_cm = (RMColorMode)cm; // Flag for the presence of custom palette differences ds >> m_bPal; @@ -580,40 +581,40 @@ void RMItem::ReadFromStream(RMDataStream &ds, bool bLOX) { // MPAL data if (!bLOX) ds += 20; - + ds >> m_FX; ds >> m_FXparm; if (!bLOX) - ds += 106; - + ds += 106; + // Create sub-classes if (m_nSprites > 0) - m_sprites = new RMSprite[m_nSprites]; + m_sprites = new RMSprite[m_nSprites]; if (m_nSfx > 0) m_sfx = new RMSfx[m_nSfx]; - m_patterns = new RMPattern[m_nPatterns+1]; + m_patterns = new RMPattern[m_nPatterns + 1]; // Read in class data if (!ds.IsError()) for (i = 0; i < m_nSprites && !ds.IsError(); i++) { - // Download the sprites - if (bLOX) { - m_sprites[i].LOXGetSizeFromStream(ds, &dimx, &dimy); - m_sprites[i].Init(NewItemSpriteBuffer(dimx, dimy, true)); - m_sprites[i].ReadFromStream(ds, true); - } else { - m_sprites[i].GetSizeFromStream(ds, &dimx, &dimy); - m_sprites[i].Init(NewItemSpriteBuffer(dimx, dimy, false)); - m_sprites[i].ReadFromStream(ds, false); - } - - if (m_cm == CM_256 && m_bPal) + // Download the sprites + if (bLOX) { + m_sprites[i].LOXGetSizeFromStream(ds, &dimx, &dimy); + m_sprites[i].Init(NewItemSpriteBuffer(dimx, dimy, true)); + m_sprites[i].ReadFromStream(ds, true); + } else { + m_sprites[i].GetSizeFromStream(ds, &dimx, &dimy); + m_sprites[i].Init(NewItemSpriteBuffer(dimx, dimy, false)); + m_sprites[i].ReadFromStream(ds, false); + } + + if (m_cm == CM_256 && m_bPal) m_sprites[i].SetPalette(m_pal.m_data); - } + } if (!ds.IsError()) - for (i = 0;i < m_nSfx && !ds.IsError(); i++) { + for (i = 0; i < m_nSfx && !ds.IsError(); i++) { if (bLOX) m_sfx[i].ReadFromStream(ds, true); else @@ -622,7 +623,7 @@ void RMItem::ReadFromStream(RMDataStream &ds, bool bLOX) { // Read the pattern from pattern 1 if (!ds.IsError()) - for (i = 1;i <= m_nPatterns && !ds.IsError(); i++) { + for (i = 1; i <= m_nPatterns && !ds.IsError(); i++) { if (bLOX) m_patterns[i].ReadFromStream(ds, true); else @@ -692,8 +693,8 @@ void RMItem::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { // If CurSprite == -1, then the pattern is finished if (m_nCurSprite == -1) - return; - + return; + // Set the flag prim->SetFlag(m_bCurFlag); @@ -730,9 +731,9 @@ void RMItem::SetPattern(int nPattern, bool bPlayP0) { assert(nPattern >= 0 && nPattern <= m_nPatterns); if (m_sfx) - if (m_nCurPattern>0) + if (m_nCurPattern > 0) m_patterns[m_nCurPattern].StopSfx(m_sfx); - + // Remember the current pattern m_nCurPattern = nPattern; @@ -741,10 +742,10 @@ void RMItem::SetPattern(int nPattern, bool bPlayP0) { m_nCurSprite = m_patterns[m_nCurPattern].Init(m_sfx, bPlayP0, &m_bCurFlag); else { m_nCurSprite = -1; - + // Look for the sound effect for pattern 0 if (bPlayP0) - for (i = 0;i < m_nSfx; i++) + for (i = 0; i < m_nSfx; i++) if (strcmp(m_sfx[i].m_name, "p0") == 0) m_sfx[i].Play(); } @@ -758,7 +759,7 @@ bool RMItem::GetName(RMString &name) { name = buf; if (buf[0] == '\0') return false; - return true; + return true; } @@ -767,12 +768,12 @@ void RMItem::Unload(void) { delete[] m_patterns; m_patterns = NULL; } - + if (m_sprites != NULL) { delete[] m_sprites; m_sprites = NULL; } - + if (m_sfx != NULL) { delete[] m_sfx; m_sfx = NULL; @@ -809,7 +810,7 @@ RMItem::~RMItem() { void RMItem::WaitForEndPattern(CORO_PARAM, uint32 hCustomSkip) { CORO_BEGIN_CONTEXT; - uint32 h[2]; + uint32 h[2]; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -880,7 +881,7 @@ void RMWipe::WaitForFadeEnd(CORO_PARAM) { CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_2(CoroScheduler.waitForSingleObject, m_hEndOfFade, CORO_INFINITE); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, m_hEndOfFade, CORO_INFINITE); m_bEndFade = true; m_bFading = false; @@ -910,7 +911,7 @@ void RMWipe::InitFade(int type) { ds.OpenBuffer(res); ds >> m_wip0r; ds.Close(); - + m_wip0r.SetPattern(1); m_bFading = true; @@ -921,12 +922,12 @@ void RMWipe::DoFrame(RMGfxTargetBuffer &bigBuf) { bigBuf.AddPrim(new RMGfxPrimitive(this)); m_bMustRegister = false; } - + if (m_bFading) { m_wip0r.DoFrame(&bigBuf, false); m_nFadeStep++; - + if (m_nFadeStep == 10) { CoroScheduler.setEvent(m_hEndOfFade); } @@ -961,17 +962,17 @@ void RMWipe::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { /****************************************************************************/ short RMCharacter::FindPath(short source, short destination) { - static RMBox BOX[MAXBOXES]; // Matrix of adjacent boxes + static RMBox BOX[MAXBOXES]; // Matrix of adjacent boxes static short COSTO[MAXBOXES]; // Cost per node static short VALIDO[MAXBOXES]; // 0:Invalid 1:Valid 2:Saturated static short NEXT[MAXBOXES]; // Prossimo Nodo short i, j, k, costominimo, fine, errore = 0; RMBoxLoc *cur; - g_system->lockMutex(csMove); + g_system->lockMutex(csMove); if (source == -1 || destination == -1) { - g_system->unlockMutex(csMove); + g_system->unlockMutex(csMove); return 0; } @@ -983,37 +984,37 @@ short RMCharacter::FindPath(short source, short destination) { memcpy(&BOX[i], &cur->boxes[i], sizeof(RMBox)); // Invalidate all nodes - for (i = 0; i < cur->numbbox; i++) + for (i = 0; i < cur->numbbox; i++) VALIDO[i] = 0; - + // Prepare source and variables for the procedure COSTO[source] = 0; VALIDO[source] = 1; fine = 0; - - // Find the shortest path - while(!fine) { - costominimo = 32000; // Reset the minimum cost - errore = 1; // Possible error + + // Find the shortest path + while (!fine) { + costominimo = 32000; // Reset the minimum cost + errore = 1; // Possible error // 1st cycle: explore possible new nodes for (i = 0; i < cur->numbbox; i++) if (VALIDO[i] == 1) { - errore = 0; // Failure de-bunked + errore = 0; // Failure de-bunked j = 0; - while (((BOX[i].adj[j]) != 1) && (j < cur->numbbox)) + while (((BOX[i].adj[j]) != 1) && (j < cur->numbbox)) j++; - - if (j >= cur->numbbox) + + if (j >= cur->numbbox) VALIDO[i] = 2; // nodo saturated? else { NEXT[i] = j; - if (COSTO[i] + 1 < costominimo) + if (COSTO[i] + 1 < costominimo) costominimo = COSTO[i] + 1; } } - if (errore) + if (errore) fine = 1; // All nodes saturated // 2nd cycle: adding new nodes that were found, saturate old nodes @@ -1023,10 +1024,10 @@ short RMCharacter::FindPath(short source, short destination) { COSTO[NEXT[i]] = costominimo; VALIDO[NEXT[i]] = 1; for (j = 0; j < cur->numbbox; j++) - if (BOX[j].adj[NEXT[i]] == 1) + if (BOX[j].adj[NEXT[i]] == 1) BOX[j].adj[NEXT[i]] = 0; - - if (NEXT[i] == destination) + + if (NEXT[i] == destination) fine = 1; } } @@ -1036,7 +1037,7 @@ short RMCharacter::FindPath(short source, short destination) { pathlenght = COSTO[destination]; k = pathlenght; path[k] = destination; - + while (path[k] != source) { i = 0; while (BOX[i].adj[path[k]] != 2) @@ -1044,7 +1045,7 @@ short RMCharacter::FindPath(short source, short destination) { k--; path[k] = i; } - + pathlenght++; } @@ -1081,38 +1082,38 @@ void RMCharacter::GoTo(CORO_PARAM, RMPoint destcoord, bool bReversed) { walkcount = 0; if (bReversed) { - while (0) ; + while (0) ; } int nPatt = GetCurPattern(); if (dx > dy) { slope = fy / fx; - if (lineend.x < linestart.x) + if (lineend.x < linestart.x) walkspeed = -walkspeed; walkstatus = 1; - + // Change the pattern for the new direction bNeedToStop = true; if ((walkspeed < 0 && !bReversed) || (walkspeed >= 0 && bReversed)) { - if (nPatt != PAT_WALKLEFT) - SetPattern(PAT_WALKLEFT); + if (nPatt != PAT_WALKLEFT) + SetPattern(PAT_WALKLEFT); } else { - if (nPatt != PAT_WALKRIGHT) + if (nPatt != PAT_WALKRIGHT) SetPattern(PAT_WALKRIGHT); } } else { slope = fx / fy; - if (lineend.y < linestart.y) + if (lineend.y < linestart.y) walkspeed = -walkspeed; walkstatus = 0; - + bNeedToStop = true; if ((walkspeed < 0 && !bReversed) || (walkspeed >= 0 && bReversed)) { - if (nPatt != PAT_WALKUP) - SetPattern(PAT_WALKUP); + if (nPatt != PAT_WALKUP) + SetPattern(PAT_WALKUP); } else { - if (nPatt != PAT_WALKDOWN) + if (nPatt != PAT_WALKDOWN) SetPattern(PAT_WALKDOWN); } } @@ -1132,9 +1133,12 @@ RMPoint RMCharacter::Searching(char UP, char DOWN, char RIGHT, char LEFT, RMPoin if (UP) { nuovo = punto; passi = 0; - while((InWhichBox(nuovo) == -1) && (nuovo.y >= 0)) { nuovo.y--; passi++; } - if ((InWhichBox(nuovo) != -1) && (passi < minimo)&& - FindPath(InWhichBox(m_pos), InWhichBox(nuovo))) { + while ((InWhichBox(nuovo) == -1) && (nuovo.y >= 0)) { + nuovo.y--; + passi++; + } + if ((InWhichBox(nuovo) != -1) && (passi < minimo) && + FindPath(InWhichBox(m_pos), InWhichBox(nuovo))) { minimo = passi; nuovo.y--; // to avoid error? trovato = nuovo; @@ -1144,9 +1148,12 @@ RMPoint RMCharacter::Searching(char UP, char DOWN, char RIGHT, char LEFT, RMPoin if (DOWN) { nuovo = punto; passi = 0; - while ((InWhichBox(nuovo) == -1) && (nuovo.y < 480)) { nuovo.y++; passi++; } + while ((InWhichBox(nuovo) == -1) && (nuovo.y < 480)) { + nuovo.y++; + passi++; + } if ((InWhichBox(nuovo) != -1) && (passi < minimo) && - FindPath(InWhichBox(m_pos), InWhichBox(nuovo))) { + FindPath(InWhichBox(m_pos), InWhichBox(nuovo))) { minimo = passi; nuovo.y++; // to avoid error? trovato = nuovo; @@ -1156,9 +1163,12 @@ RMPoint RMCharacter::Searching(char UP, char DOWN, char RIGHT, char LEFT, RMPoin if (RIGHT) { nuovo = punto; passi = 0; - while ((InWhichBox(nuovo) == -1) && (nuovo.x < 640)) { nuovo.x++; passi++; } + while ((InWhichBox(nuovo) == -1) && (nuovo.x < 640)) { + nuovo.x++; + passi++; + } if ((InWhichBox(nuovo) != -1) && (passi < minimo) && - FindPath(InWhichBox(m_pos), InWhichBox(nuovo))) { + FindPath(InWhichBox(m_pos), InWhichBox(nuovo))) { minimo = passi; nuovo.x++; // to avoid error? trovato = nuovo; @@ -1168,9 +1178,12 @@ RMPoint RMCharacter::Searching(char UP, char DOWN, char RIGHT, char LEFT, RMPoin if (LEFT) { nuovo = punto; passi = 0; - while ((InWhichBox(nuovo) == -1) && (nuovo.x >= 0)) { nuovo.x--; passi++; } + while ((InWhichBox(nuovo) == -1) && (nuovo.x >= 0)) { + nuovo.x--; + passi++; + } if ((InWhichBox(nuovo) != -1) && (passi < minimo) && - FindPath(InWhichBox(m_pos), InWhichBox(nuovo))) { + FindPath(InWhichBox(m_pos), InWhichBox(nuovo))) { minimo = passi; nuovo.x--; // to avoid error? trovato = nuovo; @@ -1210,7 +1223,7 @@ short RMCharacter::ScanLine(const RMPoint &punto) { Lstatus = 1; } else { Lslope = Lfx / Lfy; - if (Lend.y < Lstart.y) Lspeed =- Lspeed; + if (Lend.y < Lstart.y) Lspeed = - Lspeed; Lstatus = 0; } @@ -1227,7 +1240,7 @@ short RMCharacter::ScanLine(const RMPoint &punto) { Lscan.x = Lstart.x + Ldx; Lscan.y = Lstart.y + Ldy; - + if ((ABS(Lscan.x - Lend.x) <= 1) && (ABS(Lscan.y - Lend.y) <= 1)) return 1; } @@ -1253,11 +1266,11 @@ RMPoint RMCharacter::InvScanLine(const RMPoint &punto) { Ldy = ABS(Ldy); Lspeed = 1; Lcount = 0; - + if (Ldx > Ldy) { Lslope = Lfy / Lfx; if (Lend.x < Lstart.x) Lspeed = -Lspeed; - Lstatus=1; + Lstatus = 1; } else { Lslope = Lfx / Lfy; if (Lend.y < Lstart.y) Lspeed = -Lspeed; @@ -1268,9 +1281,9 @@ RMPoint RMCharacter::InvScanLine(const RMPoint &punto) { for (;;) { if (InWhichBox(Lscan) != -1) { if (InWhichBox(Lscan) != Lbox) { - if (InWhichBox(m_pos) == InWhichBox(Lscan) || FindPath(InWhichBox(m_pos),InWhichBox(Lscan))) + if (InWhichBox(m_pos) == InWhichBox(Lscan) || FindPath(InWhichBox(m_pos), InWhichBox(Lscan))) return Lscan; - else + else Lbox = InWhichBox(Lscan); } } @@ -1279,10 +1292,10 @@ RMPoint RMCharacter::InvScanLine(const RMPoint &punto) { if (Lstatus) { Ldx = Lspeed * Lcount; Ldy = Lslope * Ldx; - } else { + } else { Ldy = Lspeed * Lcount; Ldx = Lslope * Ldy; - } + } Lscan.x = Lstart.x + Ldx; Lscan.y = Lstart.y + Ldy; } @@ -1299,19 +1312,19 @@ RMPoint RMCharacter::NearestHotSpot(int sourcebox, int destbox) { int x, y, distanzaminima; distanzaminima = 10000000; RMBoxLoc *cur = theBoxes->GetBoxes(curLocation); - + for (cc = 0; cc < cur->boxes[sourcebox].numhotspot; cc++) if ((cur->boxes[sourcebox].hotspot[cc].destination) == destbox) { x = ABS(cur->boxes[sourcebox].hotspot[cc].hotx - m_pos.x); y = ABS(cur->boxes[sourcebox].hotspot[cc].hoty - m_pos.y); - + if ((x * x + y * y) < distanzaminima) { distanzaminima = x * x + y * y; puntocaldo.x = cur->boxes[sourcebox].hotspot[cc].hotx; puntocaldo.y = cur->boxes[sourcebox].hotspot[cc].hoty; } } - + return puntocaldo; } @@ -1333,7 +1346,7 @@ void RMCharacter::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr void RMCharacter::NewBoxEntered(int nBox) { RMBoxLoc *cur; bool bOldReverse; - + // Recall on ExitBox mpalQueryDoAction(3, curLocation, curbox); @@ -1371,11 +1384,11 @@ void RMCharacter::NewBoxEntered(int nBox) { // Recall On EnterBox mpalQueryDoAction(2, curLocation, curbox); } - -void RMCharacter::DoFrame(CORO_PARAM, RMGfxTargetBuffer* bigBuf, int loc) { + +void RMCharacter::DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc) { CORO_BEGIN_CONTEXT; - bool bEndNow; - RMBoxLoc *cur; + bool bEndNow; + RMBoxLoc *cur; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -1402,7 +1415,7 @@ void RMCharacter::DoFrame(CORO_PARAM, RMGfxTargetBuffer* bigBuf, int loc) { _ctx->bEndNow = true; } } - + // If we are going vertical if (walkstatus == 0) { dy = walkspeed * walkcount; @@ -1431,11 +1444,11 @@ void RMCharacter::DoFrame(CORO_PARAM, RMGfxTargetBuffer* bigBuf, int loc) { bEndOfPath = true; CoroScheduler.pulseEvent(hEndOfPath); } - + walkcount++; // Update the character Z. @@@ Should remove only if the Z was changed - + // Check if the box was changed if (!theBoxes->IsInBox(curLocation, curbox, m_pos)) NewBoxEntered(InWhichBox(m_pos)); @@ -1454,10 +1467,10 @@ void RMCharacter::DoFrame(CORO_PARAM, RMGfxTargetBuffer* bigBuf, int loc) { // If we still have to go through a box if (pathcount < pathlenght) { // Check if the box we're going into is active - if (_ctx->cur->boxes[path[pathcount-1]].attivo) { + if (_ctx->cur->boxes[path[pathcount - 1]].attivo) { // Move in a straight line towards the nearest hotspot, taking into account the reversing // NEWBOX = path[pathcount-1] - CORO_INVOKE_2(GoTo, NearestHotSpot(path[pathcount-1], path[pathcount]), _ctx->cur->boxes[path[pathcount-1]].bReversed); + CORO_INVOKE_2(GoTo, NearestHotSpot(path[pathcount - 1], path[pathcount]), _ctx->cur->boxes[path[pathcount - 1]].bReversed); pathcount++; } else { // If the box is off, we can only block all @@ -1470,7 +1483,7 @@ void RMCharacter::DoFrame(CORO_PARAM, RMGfxTargetBuffer* bigBuf, int loc) { CoroScheduler.pulseEvent(hEndOfPath); } } else { - // If we have already entered the last box, we just have to move in a straight line towards the + // If we have already entered the last box, we just have to move in a straight line towards the // point of arrival // NEWBOX = InWhichBox(pathend) minpath = 0; @@ -1520,7 +1533,7 @@ void RMCharacter::Stop(CORO_PARAM) { case PAT_WALKRIGHT: SetPattern(PAT_STANDRIGHT); break; - + default: SetPattern(PAT_STANDDOWN); break; @@ -1529,22 +1542,22 @@ void RMCharacter::Stop(CORO_PARAM) { CORO_END_CODE; } -inline int RMCharacter::InWhichBox(const RMPoint &pt) { - return theBoxes->WhichBox(curLocation, pt); +inline int RMCharacter::InWhichBox(const RMPoint &pt) { + return theBoxes->WhichBox(curLocation, pt); } void RMCharacter::Move(CORO_PARAM, RMPoint pt, bool *result) { CORO_BEGIN_CONTEXT; - RMPoint dest; - int numbox; - RMBoxLoc *cur; + RMPoint dest; + int numbox; + RMBoxLoc *cur; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); bMoving = true; - + // 0, 0 does not do anything, just stops the character if (pt.x == 0 && pt.y == 0) { minpath = 0; @@ -1556,7 +1569,7 @@ void RMCharacter::Move(CORO_PARAM, RMPoint pt, bool *result) { } // If clicked outside the box - _ctx->numbox = InWhichBox(pt); + _ctx->numbox = InWhichBox(pt); if (_ctx->numbox == -1) { // Find neareste point inside the box _ctx->dest = NearestPoint(pt); @@ -1574,7 +1587,7 @@ void RMCharacter::Move(CORO_PARAM, RMPoint pt, bool *result) { minpath = 0; status = STAND; bMovingWithoutMinpath = true; - if (ScanLine(pt)) + if (ScanLine(pt)) CORO_INVOKE_2(GoTo, pt, _ctx->cur->boxes[_ctx->numbox].bReversed); else if (FindPath(InWhichBox(m_pos), InWhichBox(pt))) { bMovingWithoutMinpath = false; @@ -1586,8 +1599,8 @@ void RMCharacter::Move(CORO_PARAM, RMPoint pt, bool *result) { // a path to get there. We use the InvScanLine to search around a point _ctx->dest = InvScanLine(pt); pt = _ctx->dest; - - if (ScanLine(pt)) + + if (ScanLine(pt)) CORO_INVOKE_2(GoTo, pt, _ctx->cur->boxes[_ctx->numbox].bReversed); else if (FindPath(InWhichBox(m_pos), InWhichBox(pt))) { bMovingWithoutMinpath = false; @@ -1612,11 +1625,11 @@ void RMCharacter::Move(CORO_PARAM, RMPoint pt, bool *result) { void RMCharacter::SetPosition(const RMPoint &pt, int newloc) { RMBoxLoc *box; - + minpath = 0; status = STAND; m_pos = pt; - + if (newloc != -1) curLocation = newloc; @@ -1628,14 +1641,14 @@ void RMCharacter::SetPosition(const RMPoint &pt, int newloc) { bRemoveFromOT = true; } -void RMCharacter::WaitForEndMovement(CORO_PARAM) { +void RMCharacter::WaitForEndMovement(CORO_PARAM) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - if (bMoving) - CORO_INVOKE_2(CoroScheduler.waitForSingleObject, hEndOfPath, CORO_INFINITE); + if (bMoving) + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, hEndOfPath, CORO_INFINITE); CORO_END_CODE; } @@ -1722,9 +1735,12 @@ void RMBox::ReadFromStream(RMDataStream &ds) { // Hotspots for (i = 0; i < numhotspot; i++) { - ds >> w; hotspot[i].hotx = w; - ds >> w; hotspot[i].hoty = w; - ds >> w; hotspot[i].destination = w; + ds >> w; + hotspot[i].hotx = w; + ds >> w; + hotspot[i].hoty = w; + ds >> w; + hotspot[i].destination = w; } } @@ -1811,7 +1827,7 @@ void RMGameBoxes::Init(void) { RMRes res(10000 + i); ds.OpenBuffer(res); - + m_allBoxes[i] = new RMBoxLoc(); ds >> *m_allBoxes[i]; @@ -1832,7 +1848,7 @@ bool RMGameBoxes::IsInBox(int nLoc, int nBox, const RMPoint &pt) { RMBoxLoc *cur = GetBoxes(nLoc); if ((pt.x >= cur->boxes[nBox].left) && (pt.x <= cur->boxes[nBox].right) && - (pt.y >= cur->boxes[nBox].top) && (pt.y <= cur->boxes[nBox].bottom)) + (pt.y >= cur->boxes[nBox].top) && (pt.y <= cur->boxes[nBox].bottom)) return true; else return false; @@ -1841,20 +1857,20 @@ bool RMGameBoxes::IsInBox(int nLoc, int nBox, const RMPoint &pt) { int RMGameBoxes::WhichBox(int nLoc, const RMPoint &punto) { int i; RMBoxLoc *cur = GetBoxes(nLoc); - + if (!cur) return -1; - for (i = 0; inumbbox; i++) + for (i = 0; i < cur->numbbox; i++) if (cur->boxes[i].attivo) - if ((punto.x >= cur->boxes[i].left) && (punto.x <= cur->boxes[i].right) && - (punto.y >= cur->boxes[i].top) && (punto.y <= cur->boxes[i].bottom)) + if ((punto.x >= cur->boxes[i].left) && (punto.x <= cur->boxes[i].right) && + (punto.y >= cur->boxes[i].top) && (punto.y <= cur->boxes[i].bottom)) return i; return -1; } void RMGameBoxes::ChangeBoxStatus(int nLoc, int nBox, int status) { - m_allBoxes[nLoc]->boxes[nBox].attivo=status; + m_allBoxes[nLoc]->boxes[nBox].attivo = status; m_allBoxes[nLoc]->RecalcAllAdj(); } @@ -1863,9 +1879,9 @@ int RMGameBoxes::GetSaveStateSize(void) { int size; int i; - size=4; + size = 4; - for (i=1; i <= m_nLocBoxes; i++) { + for (i = 1; i <= m_nLocBoxes; i++) { size += 4; size += m_allBoxes[i]->numbbox; } @@ -1874,17 +1890,17 @@ int RMGameBoxes::GetSaveStateSize(void) { } void RMGameBoxes::SaveState(byte *state) { - int i,j; - + int i, j; + // Save the number of locations with boxes WRITE_LE_UINT32(state, m_nLocBoxes); state += 4; // For each location, write out the number of boxes and their status - for (i=1; i <= m_nLocBoxes; i++) { + for (i = 1; i <= m_nLocBoxes; i++) { WRITE_LE_UINT32(state, m_allBoxes[i]->numbbox); state += 4; - + for (j = 0; j < m_allBoxes[i]->numbbox; j++) *state++ = m_allBoxes[i]->boxes[j].attivo; } @@ -1905,8 +1921,8 @@ void RMGameBoxes::LoadState(byte *state) { nbox = READ_LE_UINT32(state); state += 4; - for (j = 0; jnumbbox) + for (j = 0; j < nbox ; j++) { + if (j < m_allBoxes[i]->numbbox) m_allBoxes[i]->boxes[j].attivo = *state; state++; @@ -1933,7 +1949,7 @@ RMLocation::RMLocation() { /** * Load a location (.LOC) from a file that is provided. * - * @param lpszFileName Name of the file + * @param lpszFileName Name of the file */ bool RMLocation::Load(const char *lpszFileName) { Common::File f; @@ -1956,9 +1972,9 @@ bool RMLocation::Load(const char *lpszFileName) { /** * Load a location (.LOC) from a given open file * - * @param hFile File reference + * @param hFile File reference * - * @returns True if succeeded OK, false in case of error. + * @returns True if succeeded OK, false in case of error. */ bool RMLocation::Load(Common::File &file) { int size; @@ -1973,7 +1989,7 @@ bool RMLocation::Load(Common::File &file) { fs.OpenFile(file); bRet = Load(fs); fs.Close(); - + return bRet; } @@ -1992,8 +2008,8 @@ bool RMLocation::Load(const byte *buf) { /** * Load a location (.LOC) from a given data stream * - * @param ds Data stream - * @returns True if succeeded OK, false in case of error. + * @param ds Data stream + * @returns True if succeeded OK, false in case of error. */ bool RMLocation::Load(RMDataStream &ds) { char id[3]; @@ -2004,14 +2020,14 @@ bool RMLocation::Load(RMDataStream &ds) { // Check the ID ds >> id[0] >> id[1] >> id[2]; - + // Check if we are in a LOX if (id[0] == 'L' && id[1] == 'O' && id[2] == 'X') return LoadLOX(ds); - + // Otherwise, check that it is a normal LOC if (id[0] != 'L' || id[1] != 'O' || id[2] != 'C') - return false; + return false; // Version ds >> ver; @@ -2033,10 +2049,11 @@ bool RMLocation::Load(RMDataStream &ds) { m_curScroll.Set(0, 0); // Read the colour mode - ds >> cm; m_cmode = (RMColorMode)cm; + ds >> cm; + m_cmode = (RMColorMode)cm; // Initialise the source buffer and read the location - switch (m_cmode) { + switch (m_cmode) { case CM_256: m_buf = new RMGfxSourceBuffer8; break; @@ -2044,7 +2061,7 @@ bool RMLocation::Load(RMDataStream &ds) { case CM_65K: m_buf = new RMGfxSourceBuffer16; break; - + default: assert(0); break; @@ -2052,7 +2069,7 @@ bool RMLocation::Load(RMDataStream &ds) { // Initialise the surface, loading the palette if necessary m_buf->Init(ds, dimx, dimy, true); - + // Check the size of the location // assert(dimy!=512); @@ -2065,7 +2082,7 @@ bool RMLocation::Load(RMDataStream &ds) { _vm->FreezeTime(); - for (i = 0;i < m_nItems && !ds.IsError(); i++) + for (i = 0; i < m_nItems && !ds.IsError(); i++) ds >> m_items[i]; _vm->UnfreezeTime(); @@ -2099,14 +2116,14 @@ bool RMLocation::LoadLOX(RMDataStream &ds) { // Initialise the surface, loading in the palette if necessary m_buf->Init(ds, dimx, dimy, true); - + // Number of items ds >> m_nItems; // Create and read objects if (m_nItems > 0) m_items = new RMItem[m_nItems]; - + for (i = 0; i < m_nItems && !ds.IsError(); i++) m_items[i].ReadFromStream(ds, true); @@ -2124,12 +2141,12 @@ void RMLocation::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri CORO_BEGIN_CODE(_ctx); // Set the position of the source scrolling - if (m_buf->Dimy()>RM_SY || m_buf->Dimx()>RM_SX) { - prim->SetSrc(RMRect(m_curScroll,m_curScroll+RMPoint(640,480))); + if (m_buf->Dimy() > RM_SY || m_buf->Dimx() > RM_SX) { + prim->SetSrc(RMRect(m_curScroll, m_curScroll + RMPoint(640, 480))); } prim->SetDst(m_fixedScroll); - + // Invoke the drawing method fo the image class, which will draw the location background CORO_INVOKE_2(m_buf->Draw, bigBuf, prim); @@ -2148,33 +2165,33 @@ void RMLocation::DoFrame(RMGfxTargetBuffer *bigBuf) { bigBuf->AddPrim(new RMGfxPrimitive(this)); // Process all the location items - for (i = 0;i < m_nItems; i++) + for (i = 0; i < m_nItems; i++) m_items[i].DoFrame(bigBuf); } RMItem *RMLocation::GetItemFromCode(uint32 dwCode) { int i; - + for (i = 0; i < m_nItems; i++) if (m_items[i].MpalCode() == (int)dwCode) return &m_items[i]; - - return NULL; + + return NULL; } RMItem *RMLocation::WhichItemIsIn(const RMPoint &pt) { int found = -1; int foundSize = 0; int size; - + for (int i = 0; i < m_nItems; i++) { size = 0; if (m_items[i].IsIn(pt, &size)) { if (found == -1 || size < foundSize) { foundSize = size; found = i; - } + } } } @@ -2249,8 +2266,8 @@ void RMLocation::SetScrollPosition(const RMPoint &scroll) { RMPoint pt = scroll; if (pt.x < 0) pt.x = 0; if (pt.y < 0) pt.y = 0; - if (pt.x + RM_SX>m_buf->Dimx()) pt.x = m_buf->Dimx() - RM_SX; - if (pt.y + RM_SY>m_buf->Dimy()) pt.y = m_buf->Dimy() - RM_SY; + if (pt.x + RM_SX > m_buf->Dimx()) pt.x = m_buf->Dimx() - RM_SX; + if (pt.y + RM_SY > m_buf->Dimy()) pt.y = m_buf->Dimy() - RM_SY; m_curScroll = pt; @@ -2271,7 +2288,7 @@ void RMLocation::PauseSound(bool bPause) { * RMMessage Methods \****************************************************************************/ -RMMessage::RMMessage(uint32 dwId) { +RMMessage::RMMessage(uint32 dwId) { Load(dwId); } @@ -2287,19 +2304,19 @@ RMMessage::~RMMessage() { void RMMessage::Load(uint32 dwId) { lpMessage = mpalQueryMessage(dwId); assert(lpMessage != NULL); - + if (lpMessage) ParseMessage(); } void RMMessage::ParseMessage(void) { char *p; - + assert(lpMessage != NULL); - + nPeriods = 1; p = lpPeriods[0] = lpMessage; - + for (;;) { // Find the end of the current period while (*p != '\0') diff --git a/engines/tony/loc.h b/engines/tony/loc.h index 7085c81dcb..612e7b5d3e 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -62,7 +62,7 @@ public: byte m_data[1024]; public: - friend RMDataStream &operator>>(RMDataStream &ds, RMPalette &pal); + friend RMDataStream &operator>>(RMDataStream &ds, RMPalette &pal); }; @@ -79,14 +79,14 @@ public: RMSfx(); virtual ~RMSfx(); - friend RMDataStream& operator>>(RMDataStream &ds, RMSfx &sfx); + friend RMDataStream &operator>>(RMDataStream &ds, RMSfx &sfx); void Play(bool bLoop = false); void SetVolume(int vol); void Pause(bool bPause); void Stop(void); - void ReadFromStream(RMDataStream& ds, bool bLOX = false); + void ReadFromStream(RMDataStream &ds, bool bLOX = false); }; @@ -111,44 +111,46 @@ public: RMPoint m_pos; // Child co-ordinates public: - RMSlotType m_type; + RMSlotType m_type; int m_data; byte m_flag; public: - friend RMDataStream& operator>>(RMDataStream& ds, RMSlot& slot); + friend RMDataStream &operator>>(RMDataStream &ds, RMSlot &slot); - RMPoint Pos() { return m_pos; } + RMPoint Pos() { + return m_pos; + } - void ReadFromStream(RMDataStream& ds, bool bLOX = false); + void ReadFromStream(RMDataStream &ds, bool bLOX = false); }; public: - RMString m_name; + RMString m_name; private: - int m_speed; - RMPoint m_pos; // Parent coordinates - RMPoint m_curPos; // Parent + child coordinates - int m_bLoop; - int m_nSlots; + int m_speed; + RMPoint m_pos; // Parent coordinates + RMPoint m_curPos; // Parent + child coordinates + int m_bLoop; + int m_nSlots; int m_nCurSlot; int m_nCurSprite; - RMSlot *m_slots; + RMSlot *m_slots; uint32 m_nStartTime; public: RMPattern(); virtual ~RMPattern(); - - friend RMDataStream& operator>>(RMDataStream& ds, RMPattern& pat); + + friend RMDataStream &operator>>(RMDataStream &ds, RMPattern &pat); // A warning that the pattern now and the current - int Init(RMSfx* sfx, bool bPlayP0=false, byte* bFlag=NULL); + int Init(RMSfx *sfx, bool bPlayP0 = false, byte *bFlag = NULL); - // Update the pattern, checking to see if it's time to change slot and executing + // Update the pattern, checking to see if it's time to change slot and executing // any associated commands int Update(uint32 hEndPattern, byte &bFlag, RMSfx *sfx); @@ -156,9 +158,11 @@ public: void StopSfx(RMSfx *sfx); // Reads the position of the pattern - RMPoint Pos() { return m_curPos; } + RMPoint Pos() { + return m_curPos; + } - void ReadFromStream(RMDataStream& ds, bool bLOX = false); + void ReadFromStream(RMDataStream &ds, bool bLOX = false); private: void UpdateCoord(void); @@ -170,24 +174,24 @@ private: */ class RMSprite : public RMGfxTask { public: - RMString m_name; - RMRect m_rcBox; + RMString m_name; + RMRect m_rcBox; protected: - RMGfxSourceBuffer* m_buf; + RMGfxSourceBuffer *m_buf; public: RMSprite(); virtual ~RMSprite(); - void Init(RMGfxSourceBuffer* buf); - friend RMDataStream& operator>>(RMDataStream& ds, RMSprite& sprite); + void Init(RMGfxSourceBuffer *buf); + friend RMDataStream &operator>>(RMDataStream &ds, RMSprite &sprite); virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); void SetPalette(byte *lpBuf); - void GetSizeFromStream(RMDataStream& ds, int* dimx, int* dimy); - void LOXGetSizeFromStream(RMDataStream& ds, int* dimx, int* dimy); + void GetSizeFromStream(RMDataStream &ds, int *dimx, int *dimy); + void LOXGetSizeFromStream(RMDataStream &ds, int *dimx, int *dimy); - void ReadFromStream(RMDataStream& ds, bool bLOX = false); + void ReadFromStream(RMDataStream &ds, bool bLOX = false); }; @@ -196,31 +200,33 @@ public: */ class RMItem : public RMGfxTask { public: - RMString m_name; + RMString m_name; protected: - int m_z; - RMPoint m_pos; // Coordinate nonno + int m_z; + RMPoint m_pos; // Coordinate nonno RMColorMode m_cm; RMPoint m_curScroll; byte m_FX; byte m_FXparm; - virtual int GetCurPattern() { return m_nCurPattern; } + virtual int GetCurPattern() { + return m_nCurPattern; + } private: int m_nCurPattern; int m_mpalCode; - RMPoint m_hot; + RMPoint m_hot; RMRect m_rcBox; - int m_nSprites,m_nSfx,m_nPatterns; - byte m_bPal; - RMPalette m_pal; + int m_nSprites, m_nSfx, m_nPatterns; + byte m_bPal; + RMPalette m_pal; - RMSprite *m_sprites; - RMSfx *m_sfx; - RMPattern *m_patterns; + RMSprite *m_sprites; + RMSfx *m_sfx; + RMPattern *m_patterns; byte m_bCurFlag; int m_nCurSprite; @@ -235,7 +241,7 @@ public: RMItem(); virtual ~RMItem(); - friend RMDataStream& operator>>(RMDataStream &ds, RMItem &item); + friend RMDataStream &operator>>(RMDataStream &ds, RMItem &item); // Process to make the object move on any animations. // Returns TRUE if it should be redrawn on the next frame @@ -246,15 +252,19 @@ public: // Overloading of check whether to remove from active list virtual void RemoveThis(CORO_PARAM, bool &result); - + // Overloaded Draw virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Overloaded priority: it's based on Z ordering - virtual int Priority() { return m_z; } + virtual int Priority() { + return m_z; + } // Pattern number - int NumPattern() { return m_nPatterns; } + int NumPattern() { + return m_nPatterns; + } // Set anew animation pattern, changing abruptly from the current virtual void SetPattern(int nPattern, bool bPlayP0 = false); @@ -263,9 +273,13 @@ public: void SetStatus(int nStatus); bool IsIn(const RMPoint &pt, int *size = NULL); - RMPoint Hotspot() { return m_hot; } + RMPoint Hotspot() { + return m_hot; + } bool GetName(RMString &name); - int MpalCode() { return m_mpalCode; } + int MpalCode() { + return m_mpalCode; + } // Unload void Unload(void); @@ -276,11 +290,13 @@ public: // Sets a new hotspot fro the object void ChangeHotspot(const RMPoint &pt); - void SetInitCurPattern(bool status) { m_bInitCurPattern=status; } + void SetInitCurPattern(bool status) { + m_bInitCurPattern = status; + } void PlaySfx(int nSfx); -void ReadFromStream(RMDataStream& ds, bool bLOX=false); + void ReadFromStream(RMDataStream &ds, bool bLOX = false); void PauseSound(bool bPause); @@ -293,8 +309,8 @@ protected: }; -#define MAXBOXES 50 // Maximum number of allowed boxes -#define MAXHOTSPOT 20 // Maximum nimber of allowed hotspots +#define MAXBOXES 50 // Maximum number of allowed boxes +#define MAXHOTSPOT 20 // Maximum nimber of allowed hotspots class RMBox { public: @@ -304,11 +320,11 @@ public: }; public: - int left, top, right, bottom; // Vertici bounding boxes - int adj[MAXBOXES]; // List of adjacent bounding boxes - int numhotspot; // Hotspot number - uint8 Zvalue; // Z value for the bounding box - T_HOTSPOT hotspot[MAXHOTSPOT]; // List of hotspots + int left, top, right, bottom; // Vertici bounding boxes + int adj[MAXBOXES]; // List of adjacent bounding boxes + int numhotspot; // Hotspot number + uint8 Zvalue; // Z value for the bounding box + T_HOTSPOT hotspot[MAXHOTSPOT]; // List of hotspots bool attivo; bool bReversed; @@ -327,19 +343,19 @@ public: RMBox *boxes; private: - void ReadFromStream(RMDataStream& ds); + void ReadFromStream(RMDataStream &ds); public: RMBoxLoc(); virtual ~RMBoxLoc(); - friend RMDataStream& operator >>(RMDataStream &ds, RMBoxLoc &bl); + friend RMDataStream &operator >>(RMDataStream &ds, RMBoxLoc &bl); void RecalcAllAdj(void); }; #define GAME_BOXES_SIZE 200 -class RMGameBoxes { +class RMGameBoxes { protected: RMBoxLoc *m_allBoxes[GAME_BOXES_SIZE]; int m_nLocBoxes; @@ -348,19 +364,19 @@ public: RMGameBoxes(); ~RMGameBoxes(); - void Init(void); + void Init(void); void Close(void); // Get binding boxes for a given location RMBoxLoc *GetBoxes(int nLoc); int GetLocBoxesCount() const { return m_nLocBoxes; } - + // Return the box which contains a given point int WhichBox(int nLoc, const RMPoint &pt); // Check whether a point is inside a given box bool IsInBox(int nLoc, int nBox, const RMPoint &pt); - + // Change the status of a box void ChangeBoxStatus(int nLoc, int nBox, int status); @@ -380,7 +396,7 @@ public: PAT_WALKUP, PAT_WALKDOWN, PAT_WALKLEFT, - PAT_WALKRIGHT + PAT_WALKRIGHT }; private: @@ -399,7 +415,7 @@ private: short path[MAXBOXES]; short pathlenght, pathcount; int curbox; - + STATUS status; int curSpeed; bool bEndOfPath; @@ -409,17 +425,17 @@ private: bool bRemoveFromOT; bool bMovingWithoutMinpath; RMGameBoxes *theBoxes; - + RMPoint m_fixedScroll; - + private: - int InWhichBox(const RMPoint &pt); - + int InWhichBox(const RMPoint &pt); + short FindPath(short source, short destination); RMPoint Searching(char UP, char DOWN, char RIGHT, char LEFT, RMPoint punto); RMPoint NearestPoint(const RMPoint &punto); - - void GoTo(CORO_PARAM, RMPoint destcoord, bool bReversed=false); + + void GoTo(CORO_PARAM, RMPoint destcoord, bool bReversed = false); short ScanLine(const RMPoint &punto); RMPoint InvScanLine(const RMPoint &punto); RMPoint NearestHotSpot(int sourcebox, int destbox); @@ -439,21 +455,25 @@ public: void LinkToBoxes(RMGameBoxes *theBoxes); virtual void RemoveThis(CORO_PARAM, bool &result); - + // Update the position of a character - void DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc); + void DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc); // Overloaded draw virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // TRUE if you just stopped - bool EndOfPath() { return bEndOfPath; } + bool EndOfPath() { + return bEndOfPath; + } // Change the pattern of a character to STOP virtual void Stop(CORO_PARAM); // Check if the character is moving - bool IsMoving() { return bMoving; } + bool IsMoving() { + return bMoving; + } // Move the character to a certain position void Move(CORO_PARAM, RMPoint pt, bool *result = NULL); @@ -464,8 +484,12 @@ public: // Wait for the end of movement void WaitForEndMovement(CORO_PARAM); - void SetFixedScroll(const RMPoint &fix) { m_fixedScroll = fix; } - void SetSpeed(int speed) { curSpeed = speed; } + void SetFixedScroll(const RMPoint &fix) { + m_fixedScroll = fix; + } + void SetSpeed(int speed) { + curSpeed = speed; + } }; @@ -485,9 +509,9 @@ public: RMWipe(); virtual ~RMWipe(); - void DoFrame(RMGfxTargetBuffer& bigBuf); + void DoFrame(RMGfxTargetBuffer &bigBuf); virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - + void InitFade(int type); void CloseFade(void); void WaitForFadeEnd(CORO_PARAM); @@ -503,25 +527,29 @@ public: */ class RMLocation : public RMGfxTaskSetPrior { public: - RMString m_name; // Name + RMString m_name; // Name - private: - RMColorMode m_cmode; // Color mode - RMGfxSourceBuffer *m_buf; // Location picture +private: + RMColorMode m_cmode; // Color mode + RMGfxSourceBuffer *m_buf; // Location picture - int m_nItems; // Number of objects - RMItem *m_items; // Objects + int m_nItems; // Number of objects + RMItem *m_items; // Objects - RMPoint m_curScroll; // Current scroll position + RMPoint m_curScroll; // Current scroll position RMPoint m_fixedScroll; public: // @@@@@@@@@@@@@@@@@@@@@@@ RMPoint TEMPTonyStart; - RMPoint TEMPGetTonyStart() { return TEMPTonyStart; } + RMPoint TEMPGetTonyStart() { + return TEMPTonyStart; + } int TEMPNumLoc; - int TEMPGetNumLoc() { return TEMPNumLoc; } + int TEMPGetNumLoc() { + return TEMPNumLoc; + } public: RMLocation(); @@ -559,7 +587,9 @@ public: void UpdateScrolling(const RMPoint &ptShowThis); // Read the current scroll position - RMPoint ScrollPosition() { return m_curScroll; } + RMPoint ScrollPosition() { + return m_curScroll; + } // Pause sound void PauseSound(bool bPause); @@ -584,10 +614,18 @@ public: virtual ~RMMessage(); void Load(uint32 dwId); - bool IsValid() { return lpMessage != NULL; } - int NumPeriods() { return nPeriods; } - char *Period(int num) { return lpPeriods[num]; } - char *operator[](int num) { return lpPeriods[num]; } + bool IsValid() { + return lpMessage != NULL; + } + int NumPeriods() { + return nPeriods; + } + char *Period(int num) { + return lpPeriods[num]; + } + char *operator[](int num) { + return lpPeriods[num]; + } }; } // End of namespace Tony diff --git a/engines/tony/resid.h b/engines/tony/resid.h index aec4d4c38c..5215801d5d 100644 --- a/engines/tony/resid.h +++ b/engines/tony/resid.h @@ -27,7 +27,7 @@ */ /* - Da 10500 in poi ci sono gli .OGG per l'inventario e i ritagli + Da 10500 in poi ci sono gli .OGG per l'inventario e i ritagli */ #ifndef TONY_RESID_H #define TONY_RESID_H @@ -42,18 +42,18 @@ #define RES_I_INTERP4 10306 #define RES_I_INTERP5 10307 -#define RES_I_DLGTEXT 10350 +#define RES_I_DLGTEXT 10350 #define RES_I_DLGTEXTLINE 10351 -#define RES_I_DLGTEXTPAL 10352 +#define RES_I_DLGTEXTPAL 10352 -#define RES_I_MINIINTER 10360 +#define RES_I_MINIINTER 10360 -#define RES_P_PAL 10410 -#define RES_P_GO 10400 -#define RES_P_TAKE 10401 -#define RES_P_USE 10402 -#define RES_P_EXAM 10403 -#define RES_P_TALK 10404 +#define RES_P_PAL 10410 +#define RES_P_GO 10400 +#define RES_P_TAKE 10401 +#define RES_P_USE 10402 +#define RES_P_EXAM 10403 +#define RES_P_TALK 10404 #define RES_P_PAP1 10420 #define RES_P_PAP2 10421 diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index 33dd6e1497..2f55bfad42 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -151,8 +151,7 @@ CODEC::CODEC(bool loop) { bEndReached = false; } -CODEC::~CODEC() -{ +CODEC::~CODEC() { } @@ -228,24 +227,21 @@ uint32 CODECRAW::Decompress(HANDLE hStream, void *buf, uint32 dwSize) { bEndReached = false; dwEOF = 0; - ReadFile(hStream,lpBuf,dwSize, &dwRead, NULL); - - if (dwRead>4)&0xF; - } - else - delta=cache&0xF; - - /* Trova il nuovo indice */ - index+=indexTable[delta]; - if (index<0) index = 0; - if (index>88) index=88; - - /* Legge il segno e lo separa dall'ampliamento */ - sign=delta&8; - delta=delta&7; - - /* Trova la differenza dal valore precedente */ - vpdiff=step>>3; - if (delta&4) vpdiff+=step; - if (delta&2) vpdiff+=step>>1; - if (delta&1) vpdiff+=step>>2; - - if (sign) - valpred-=vpdiff; - else - valpred+=vpdiff; - - /* Controlla i limiti del valore trovato */ - if (valpred > 32767) - valpred = 32767; - else if (valpred<-32768) - valpred=-32768; - - /* Aggiorna lo step */ - step=stepSizeTable[index]; - - /* Scrive il valore trovato */ - *lpBuf++ = (signed short)valpred; - - bufferstep=!bufferstep; - } - - return eof/2; + uint16 *lpBuf = (uint16 *)buf; + byte *inp; + int bufferstep; + int cache; + int delta; + int sign; + int vpdiff; + uint32 eof, i; + int step; + uint32 dwRead; + + bufferstep = 1; + step = stepSizeTable[index]; + + /* Richiama il CODEC RAW per leggere da disco lo stream con loop. La + chiamata e' possibile perche' abbiamo ereditato CODECADPCM da CODECRAW, + e non semplicemente da CODEC. */ + eof = CODECRAW::Decompress(hFile, lpTemp, dwSize / 4); + inp = lpTemp; + + eof *= 2; + /* Se bisogna loopare subito lo fa */ + if (EndOfStream() && eof == 0) { + LoopReset(); + bufferstep = 1; + step = stepSizeTable[index]; + } else if (!EndOfStream()) + eof = 0; + + dwSize /= 2; + for (i = 0; i < dwSize; i++) { + /* Controlla se siamo alla fine del file, e bisogna loopare */ + if (eof != 0 && i == eof) { + LoopReset(); + bufferstep = 1; + step = stepSizeTable[index]; + } + + /* Legge il delta (4 bit) */ + if (bufferstep) { + cache = *inp++; + delta = (cache >> 4) & 0xF; + } else + delta = cache & 0xF; + + /* Trova il nuovo indice */ + index += indexTable[delta]; + if (index < 0) index = 0; + if (index > 88) index = 88; + + /* Legge il segno e lo separa dall'ampliamento */ + sign = delta & 8; + delta = delta & 7; + + /* Trova la differenza dal valore precedente */ + vpdiff = step >> 3; + if (delta & 4) vpdiff += step; + if (delta & 2) vpdiff += step >> 1; + if (delta & 1) vpdiff += step >> 2; + + if (sign) + valpred -= vpdiff; + else + valpred += vpdiff; + + /* Controlla i limiti del valore trovato */ + if (valpred > 32767) + valpred = 32767; + else if (valpred < -32768) + valpred = -32768; + + /* Aggiorna lo step */ + step = stepSizeTable[index]; + + /* Scrive il valore trovato */ + *lpBuf++ = (signed short)valpred; + + bufferstep = !bufferstep; + } + + return eof / 2; #endif - return 0; + return 0; } uint32 CODECADPCMMONO::Decompress(Common::File &fp, void *buf, uint32 dwSize) { @@ -489,9 +479,9 @@ uint32 CODECADPCMMONO::Decompress(Common::File &fp, void *buf, uint32 dwSize) { bufferstep = 1; step = stepSizeTable[index]; - /* Richiama il CODEC RAW per leggere da disco lo stream con loop. La - chiamata e' possibile perche' abbiamo ereditato CODECADPCM da CODECRAW, - e non semplicemente da CODEC. */ + /* Richiama il CODEC RAW per leggere da disco lo stream con loop. La + chiamata e' possibile perche' abbiamo ereditato CODECADPCM da CODECRAW, + e non semplicemente da CODEC. */ eof = CODECRAW::Decompress(fp, lpTemp, dwSize / 4); inp = lpTemp; @@ -506,18 +496,18 @@ uint32 CODECADPCMMONO::Decompress(Common::File &fp, void *buf, uint32 dwSize) { eof = 0; dwSize /= 2; - for (i = 0;i < dwSize; i++) { + for (i = 0; i < dwSize; i++) { /* Controlla se siamo alla fine del file, e bisogna loopare */ if (eof != 0 && i == eof) { LoopReset(); - bufferstep=1; + bufferstep = 1; step = stepSizeTable[index]; } /* Legge il delta (4 bit) */ if (bufferstep) { cache = *inp++; - delta = (cache>>4)&0xF; + delta = (cache >> 4) & 0xF; } else delta = cache & 0xF; @@ -527,14 +517,14 @@ uint32 CODECADPCMMONO::Decompress(Common::File &fp, void *buf, uint32 dwSize) { if (index > 88) index = 88; /* Legge il segno e lo separa dall'ampliamento */ - sign = delta&8; - delta = delta&7; + sign = delta & 8; + delta = delta & 7; /* Trova la differenza dal valore precedente */ vpdiff = step >> 3; - if (delta&4) vpdiff += step; - if (delta&2) vpdiff += step >> 1; - if (delta&1) vpdiff += step >> 2; + if (delta & 4) vpdiff += step; + if (delta & 2) vpdiff += step >> 1; + if (delta & 1) vpdiff += step >> 2; if (sign) valpred -= vpdiff; @@ -545,13 +535,13 @@ uint32 CODECADPCMMONO::Decompress(Common::File &fp, void *buf, uint32 dwSize) { if (valpred > 32767) valpred = 32767; else if (valpred < -32768) - valpred =- 32768; + valpred = - 32768; /* Aggiorna lo step */ step = stepSizeTable[index]; /* Scrive il valore trovato */ - *lpBuf ++= (signed short)valpred; + *lpBuf ++ = (signed short)valpred; bufferstep = !bufferstep; } @@ -596,7 +586,7 @@ uint32 CODECADPCMSTEREO::Decompress(HANDLE hFile, void *buf, uint32 dwSize) { /* Controlla se siamo alla fine del file, e bisogna loopare */ if (eof != 0 && i == eof) { LoopReset(); - bufferstep=1; + bufferstep = 1; step[0] = stepSizeTable[index[0]]; step[1] = stepSizeTable[index[1]]; } @@ -609,7 +599,7 @@ uint32 CODECADPCMSTEREO::Decompress(HANDLE hFile, void *buf, uint32 dwSize) { delta = (cache >> 4) & 0xF; /* Trova il nuovo indice */ - index[bufferstep]+=indexTable[delta]; + index[bufferstep] += indexTable[delta]; if (index[bufferstep] < 0) index[bufferstep] = 0; if (index[bufferstep] > 88) index[bufferstep] = 88; @@ -620,13 +610,13 @@ uint32 CODECADPCMSTEREO::Decompress(HANDLE hFile, void *buf, uint32 dwSize) { /* Trova la differenza dal valore precedente */ vpdiff = step[bufferstep] >> 3; if (delta & 4) vpdiff += step[bufferstep]; - if (delta & 2) vpdiff += step[bufferstep]>>1; - if (delta & 1) vpdiff += step[bufferstep]>>2; + if (delta & 2) vpdiff += step[bufferstep] >> 1; + if (delta & 1) vpdiff += step[bufferstep] >> 2; if (sign) - valpred[bufferstep]-=vpdiff; + valpred[bufferstep] -= vpdiff; else - valpred[bufferstep]+=vpdiff; + valpred[bufferstep] += vpdiff; /* Controlla i limiti del valore trovato */ if (valpred[bufferstep] > 32767) @@ -638,9 +628,9 @@ uint32 CODECADPCMSTEREO::Decompress(HANDLE hFile, void *buf, uint32 dwSize) { step[bufferstep] = stepSizeTable[index[bufferstep]]; /* Scrive il valore trovato */ - *lpBuf ++= (signed short)valpred[bufferstep]; + *lpBuf ++ = (signed short)valpred[bufferstep]; - bufferstep=!bufferstep; + bufferstep = !bufferstep; } return eof / 2; @@ -655,7 +645,7 @@ uint32 CODECADPCMSTEREO::Decompress(Common::File &fp, void *buf, uint32 dwSize) int delta; int sign; int vpdiff; - uint32 eof,i; + uint32 eof, i; int step[2]; bufferstep = 1; @@ -663,8 +653,8 @@ uint32 CODECADPCMSTEREO::Decompress(Common::File &fp, void *buf, uint32 dwSize) step[1] = stepSizeTable[index[1]]; /* Richiama il CODEC RAW per leggere da disco lo stream con loop. La - chiamata e' possibile perche' abbiamo ereditato CODECADPCM da CODECRAW, - e non semplicemente da CODEC. */ + chiamata e' possibile perche' abbiamo ereditato CODECADPCM da CODECRAW, + e non semplicemente da CODEC. */ eof = CODECRAW::Decompress(fp, lpTemp, dwSize / 4); inp = lpTemp; @@ -681,9 +671,9 @@ uint32 CODECADPCMSTEREO::Decompress(Common::File &fp, void *buf, uint32 dwSize) dwSize /= 2; for (i = 0; i < dwSize; i++) { /* Controlla se siamo alla fine del file, e bisogna loopare */ - if (eof != 0 && i==eof) { + if (eof != 0 && i == eof) { LoopReset(); - bufferstep=1; + bufferstep = 1; step[0] = stepSizeTable[index[0]]; step[1] = stepSizeTable[index[1]]; } @@ -705,15 +695,15 @@ uint32 CODECADPCMSTEREO::Decompress(Common::File &fp, void *buf, uint32 dwSize) delta = delta & 7; /* Trova la differenza dal valore precedente */ - vpdiff = step[bufferstep]>>3; + vpdiff = step[bufferstep] >> 3; if (delta & 4) vpdiff += step[bufferstep]; if (delta & 2) vpdiff += step[bufferstep] >> 1; if (delta & 1) vpdiff += step[bufferstep] >> 2; if (sign) - valpred[bufferstep]-=vpdiff; + valpred[bufferstep] -= vpdiff; else - valpred[bufferstep]+=vpdiff; + valpred[bufferstep] += vpdiff; /* Controlla i limiti del valore trovato */ if (valpred[bufferstep] > 32767) @@ -725,7 +715,7 @@ uint32 CODECADPCMSTEREO::Decompress(Common::File &fp, void *buf, uint32 dwSize) step[bufferstep] = stepSizeTable[index[bufferstep]]; /* Scrive il valore trovato */ - *lpBuf ++= (signed short)valpred[bufferstep]; + *lpBuf ++ = (signed short)valpred[bufferstep]; bufferstep = !bufferstep; } @@ -775,17 +765,17 @@ bool FPSOUND::Init(/*HWND hWnd*/) { static char errbuf[128]; /* Salva l'handle della finestra nella variabile globale. DirectSound ha - bisogno dell'handle per effetuare il multitasking sonoro. */ + bisogno dell'handle per effetuare il multitasking sonoro. */ hwnd = hWnd; /* Di default, disabilita il sonoro. Se non troveremo problemi, lo - riabiliteremo alla fine della routine */ + riabiliteremo alla fine della routine */ bSoundSupported = false; /* Crea un oggetto DirectSound. Usiamo il driver sonoro settato di default. - In realta' sarebbe possibile richiedere una lista delle schede sonore - presenti, e lasciare scegliere all'utente quale utilizzare, ma mi sembra - una perdita di tempo. */ + In realta' sarebbe possibile richiedere una lista delle schede sonore + presenti, e lasciare scegliere all'utente quale utilizzare, ma mi sembra + una perdita di tempo. */ if ((err = DirectSoundCreate(NULL, &lpDS, NULL)) != DS_OK) { return false; } @@ -799,50 +789,50 @@ bool FPSOUND::Init(/*HWND hWnd*/) { error("The current sound driver is not directly supported by DirectSound. This will slow down sound performance of the game."); /* Setta il livello di cooperazione a esclusivo. In questo modo il gioco - sara' il solo ad accedere alla scheda sonora mentre e' in escuzione, ed - eventuali player in background saranno automaticamente stoppati. - Inoltre in questo modo e' possibile settare il formato di output sonoro - del primary buffer */ + sara' il solo ad accedere alla scheda sonora mentre e' in escuzione, ed + eventuali player in background saranno automaticamente stoppati. + Inoltre in questo modo e' possibile settare il formato di output sonoro + del primary buffer */ if ((err = lpDS->SetCooperativeLevel(hWnd, DSSCL_PRIORITY)) != DS_OK) { - MessageBox(hwnd,"Cannot set exclusive mode!","soundInit()", MB_OK); + MessageBox(hwnd, "Cannot set exclusive mode!", "soundInit()", MB_OK); return false; } /* Crea il primary buffer. In realta' DirectSound la farebbe automaticamente, - ma noi vogliamo il pointer al primary perche' dobbiamo settare il - formato di output */ - ZeroMemory(&dsbdesc,sizeof(dsbdesc)); - dsbdesc.dwSize=sizeof(dsbdesc); - dsbdesc.dwFlags=DSBCAPS_CTRLVOLUME|DSBCAPS_PRIMARYBUFFER; + ma noi vogliamo il pointer al primary perche' dobbiamo settare il + formato di output */ + ZeroMemory(&dsbdesc, sizeof(dsbdesc)); + dsbdesc.dwSize = sizeof(dsbdesc); + dsbdesc.dwFlags = DSBCAPS_CTRLVOLUME | DSBCAPS_PRIMARYBUFFER; if (lpDS->CreateSoundBuffer(&dsbdesc, &lpDSBPrimary, NULL) != DS_OK) { - MessageBox(hwnd,"Cannot create primary buffer!","soundInit()", MB_OK); + MessageBox(hwnd, "Cannot create primary buffer!", "soundInit()", MB_OK); return false; } /* Settiamo il formato del buffer primario. L'ideale sarebbe 16bit 44khz - stereo, ma dobbiamo anche controllare che cio' sia permesso dalla scheda - sonora, guardando nelle caratteristiche che abbiamo richiesto sopra. - Inoltre in seguito sara' possibile lasciare scegliere all'utente il - formato da utilizzare */ - pcmwf.wBitsPerSample = ((dscaps.dwFlags&DSCAPS_PRIMARY16BIT) != 0 ? 16 : 8); + stereo, ma dobbiamo anche controllare che cio' sia permesso dalla scheda + sonora, guardando nelle caratteristiche che abbiamo richiesto sopra. + Inoltre in seguito sara' possibile lasciare scegliere all'utente il + formato da utilizzare */ + pcmwf.wBitsPerSample = ((dscaps.dwFlags & DSCAPS_PRIMARY16BIT) != 0 ? 16 : 8); pcmwf.wf.wFormatTag = WAVE_FORMAT_PCM; - pcmwf.wf.nChannels = ((dscaps.dwFlags&DSCAPS_PRIMARYSTEREO) != 0 ? 2 : 1); + pcmwf.wf.nChannels = ((dscaps.dwFlags & DSCAPS_PRIMARYSTEREO) != 0 ? 2 : 1); pcmwf.wf.nSamplesPerSec = 44100; pcmwf.wf.nBlockAlign = (pcmwf.wBitsPerSample / 8) * pcmwf.wf.nChannels; pcmwf.wf.nAvgBytesPerSec = (uint32)pcmwf.wf.nBlockAlign * (uint32)pcmwf.wf.nSamplesPerSec; if ((err = lpDSBPrimary->SetFormat((LPWAVEFORMATEX) & pcmwf)) != DS_OK) { - wsprintf(errbuf,"Error setting the output format (%lx)",err); - MessageBox(hwnd,errbuf,"soundInit()", MB_OK); + wsprintf(errbuf, "Error setting the output format (%lx)", err); + MessageBox(hwnd, errbuf, "soundInit()", MB_OK); return false; } /* Controlla che il driver DirectSound supporti buffer secondari con - play di stream 16bit, 44khz stereo */ + play di stream 16bit, 44khz stereo */ if (dscaps.dwMaxSecondarySampleRate != 0 && dscaps.dwMaxSecondarySampleRate < 44100) { - wsprintf(errbuf,"Driver does not support 16bit 44khz stereo mixing! (%lu)",dscaps.dwMaxSecondarySampleRate); - MessageBox(hwnd,errbuf,"soundInit()", MB_OK); + wsprintf(errbuf, "Driver does not support 16bit 44khz stereo mixing! (%lu)", dscaps.dwMaxSecondarySampleRate); + MessageBox(hwnd, errbuf, "soundInit()", MB_OK); return false; } @@ -911,7 +901,7 @@ bool FPSOUND::CreateStream(FPSTREAM **lplpStream) { * * Return: true se tutto OK, false in caso di errore * -* Note: Vedi le note di CreateStream() +* Note: Vedi le note di CreateStream() * \****************************************************************************/ @@ -940,7 +930,7 @@ void FPSOUND::SetMasterVolume(int dwVolume) { return; if (dwVolume > 63) dwVolume = 63; - if (dwVolume < 0) dwVolume = 0; + if (dwVolume < 0) dwVolume = 0; lpDSBPrimary->SetVolume(dwVolume * (DSBVOLUME_MAX - DSBVOLUME_MIN) / 64 + DSBVOLUME_MIN); #endif @@ -961,7 +951,7 @@ void FPSOUND::GetMasterVolume(int *lpdwVolume) { #ifdef REFACTOR_ME if (!bSoundSupported) return; - + lpDSBPrimary->GetVolume((uint32 *)lpdwVolume); *lpdwVolume -= (DSBVOLUME_MIN); *lpdwVolume *= 64; @@ -1026,8 +1016,8 @@ FPSFX::FPSFX(LPDIRECTSOUND lpds, HWND hWnd, bool bSoundOn) { * Function: ~FPSFX(); * * Description: Distruttore di default. Si preoccupa anche di fermare il sound -* effect eventualmente in esecuzione, e disallocare la memoria -* da esso occupata. +* effect eventualmente in esecuzione, e disallocare la memoria +* da esso occupata. * \****************************************************************************/ @@ -1076,7 +1066,7 @@ void FPSFX::Release() { * * Description: Apre un file di effetto sonoro e lo carica. * -* Input: byte *lpBuf Buffer dove si trova l'sfx +* Input: byte *lpBuf Buffer dove si trova l'sfx * uint32 dwCoded CODEC da utilizzare per decomprimere * i campioni sonori * @@ -1115,7 +1105,7 @@ bool FPSFX::LoadFile(byte *lpBuf, uint32 dwCodec) { if (lpBuf[4] != 'f' || lpBuf[5] != 'm' || lpBuf[6] != 't' || lpBuf[7] != ' ') return false; - WAVHeader = (WAVH*)(lpBuf+8); + WAVHeader = (WAVH *)(lpBuf + 8); lpBuf += 8 + sizeof(WAVH); if (lpBuf[0] != 'd' || lpBuf[1] != 'a' || lpBuf[2] != 't' || lpBuf[3] != 'a') @@ -1130,11 +1120,11 @@ bool FPSFX::LoadFile(byte *lpBuf, uint32 dwCodec) { dwFreq = WAVHeader->nSamplesPerSec; /* Setta le strutture necessarie per la creazione di un secondary buffer - Attiviamo inoltre il controllo del volume, in modo da poter abbassare - e alzare il volume della musica indipendentemente da quello generale. + Attiviamo inoltre il controllo del volume, in modo da poter abbassare + e alzare il volume della musica indipendentemente da quello generale. Proviamo a buttarlo in sound ram. */ pcmwf.wBitsPerSample = (b16bit ? 16 : 8); - pcmwf.wf.wFormatTag=WAVE_FORMAT_PCM; + pcmwf.wf.wFormatTag = WAVE_FORMAT_PCM; pcmwf.wf.nChannels = (bStereo ? 2 : 1); pcmwf.wf.nSamplesPerSec = dwFreq; pcmwf.wf.nBlockAlign = (pcmwf.wBitsPerSample / 8) * pcmwf.wf.nChannels; @@ -1146,14 +1136,14 @@ bool FPSFX::LoadFile(byte *lpBuf, uint32 dwCodec) { dsbdesc.lpwfxFormat = (LPWAVEFORMATEX)&pcmwf; if ((err = lpDS->CreateSoundBuffer(&dsbdesc, &lpDSBuffer, NULL)) != DS_OK) { - wsprintf(errbuf,"Error creating the secondary buffer (%lx)",err); - MessageBox(hwnd,errbuf,"FPSFX::FPSFX()", MB_OK); + wsprintf(errbuf, "Error creating the secondary buffer (%lx)", err); + MessageBox(hwnd, errbuf, "FPSFX::FPSFX()", MB_OK); return false; } // Riempie il buffer - if ((err = lpDSBuffer->Lock(0,dwSize, &lpLock,(uint32 *)&dwHi, NULL, NULL, 0)) != DS_OK) { - MessageBox(hwnd,"Cannot lock sfx buffer!","FPSFX::LoadFile()", MB_OK); + if ((err = lpDSBuffer->Lock(0, dwSize, &lpLock, (uint32 *)&dwHi, NULL, NULL, 0)) != DS_OK) { + MessageBox(hwnd, "Cannot lock sfx buffer!", "FPSFX::LoadFile()", MB_OK); return false; } @@ -1203,20 +1193,20 @@ bool FPSFX::LoadVoiceFromVDB(Common::File &vdbFP) { b16bit = true; bStereo = false; bIsVoice = true; - + // fread(&dwSize,1,4,vdbFP); // fread(&dwFreq,1,4,vdbFP); - ReadFile(vdbFP, &dwSize,4, &dwHi, NULL); - ReadFile(vdbFP, &dwFreq,4, &dwHi, NULL); + ReadFile(vdbFP, &dwSize, 4, &dwHi, NULL); + ReadFile(vdbFP, &dwFreq, 4, &dwHi, NULL); dwSize *= 4; /* Setta le strutture necessarie per la creazione di un secondary buffer - Attiviamo inoltre il controllo del volume, in modo da poter abbassare - e alzare il volume della musica indipendentemente da quello generale. + Attiviamo inoltre il controllo del volume, in modo da poter abbassare + e alzare il volume della musica indipendentemente da quello generale. Proviamo a buttarlo in sound ram. */ pcmwf.wBitsPerSample = (b16bit ? 16 : 8); - pcmwf.wf.wFormatTag=WAVE_FORMAT_PCM; + pcmwf.wf.wFormatTag = WAVE_FORMAT_PCM; pcmwf.wf.nChannels = (bStereo ? 2 : 1); pcmwf.wf.nSamplesPerSec = dwFreq; pcmwf.wf.nBlockAlign = (pcmwf.wBitsPerSample / 8) * pcmwf.wf.nChannels; @@ -1228,8 +1218,8 @@ bool FPSFX::LoadVoiceFromVDB(Common::File &vdbFP) { dsbdesc.lpwfxFormat = (LPWAVEFORMATEX)&pcmwf; if ((err = lpDS->CreateSoundBuffer(&dsbdesc, &lpDSBuffer, NULL)) != DS_OK) { - wsprintf(errbuf,"Error creating the secondary buffer (%lx)",err); - MessageBox(hwnd,errbuf,"FPSFX::FPSFX()", MB_OK); + wsprintf(errbuf, "Error creating the secondary buffer (%lx)", err); + MessageBox(hwnd, errbuf, "FPSFX::FPSFX()", MB_OK); return false; } @@ -1239,10 +1229,10 @@ bool FPSFX::LoadVoiceFromVDB(Common::File &vdbFP) { return false; lpCodec = new CODECADPCMMONO(bLoop, lpTempBuffer); - + /* Riempie il buffer */ - if ((err = lpDSBuffer->Lock(0,dwSize, &lpBuf,(uint32 *)&dwHi, NULL, NULL, 0)) != DS_OK) { - MessageBox(hwnd,"Cannot lock sfx buffer!","FPSFX::LoadFile()", MB_OK); + if ((err = lpDSBuffer->Lock(0, dwSize, &lpBuf, (uint32 *)&dwHi, NULL, NULL, 0)) != DS_OK) { + MessageBox(hwnd, "Cannot lock sfx buffer!", "FPSFX::LoadFile()", MB_OK); return false; } @@ -1255,10 +1245,10 @@ bool FPSFX::LoadVoiceFromVDB(Common::File &vdbFP) { delete lpCodec; /* Crea il notify per avvertire quando raggiungiamo la fine della voce */ - err = lpDSBuffer->QueryInterface(IID_IDirectSoundNotify,(void **)&lpDSNotify); + err = lpDSBuffer->QueryInterface(IID_IDirectSoundNotify, (void **)&lpDSNotify); if (FAILED(err)) { - wsprintf(errbuf,"Error creating notify object! (%lx)",err); - MessageBox(hwnd,errbuf,"FPSFX::LoadVoiceFromVDB()", MB_OK); + wsprintf(errbuf, "Error creating notify object! (%lx)", err); + MessageBox(hwnd, errbuf, "FPSFX::LoadVoiceFromVDB()", MB_OK); return false; } @@ -1268,7 +1258,7 @@ bool FPSFX::LoadVoiceFromVDB(Common::File &vdbFP) { dspnHot[0].hEventNotify = hEndOfBuffer; lpDSNotify->SetNotificationPositions(1, dspnHot); - + /* Tutto a posto, possiamo uscire */ bFileLoaded = true; SetVolume(62); @@ -1327,8 +1317,8 @@ bool FPSFX::LoadFile(const char *lpszFileName, uint32 dwCodec) { dwSize *= 4; /* Setta le strutture necessarie per la creazione di un secondary buffer - Attiviamo inoltre il controllo del volume, in modo da poter abbassare - e alzare il volume della musica indipendentemente da quello generale. + Attiviamo inoltre il controllo del volume, in modo da poter abbassare + e alzare il volume della musica indipendentemente da quello generale. Proviamo a buttarlo in sound ram. */ pcmwf.wBitsPerSample = (b16bit ? 16 : 8); pcmwf.wf.wFormatTag = WAVE_FORMAT_PCM; @@ -1337,14 +1327,14 @@ bool FPSFX::LoadFile(const char *lpszFileName, uint32 dwCodec) { pcmwf.wf.nBlockAlign = (pcmwf.wBitsPerSample / 8) * pcmwf.wf.nChannels; pcmwf.wf.nAvgBytesPerSec = (uint32)pcmwf.wf.nBlockAlign * (uint32)pcmwf.wf.nSamplesPerSec; - dsbdesc.dwSize=sizeof(dsbdesc); + dsbdesc.dwSize = sizeof(dsbdesc); dsbdesc.dwFlags = DSBCAPS_CTRLVOLUME | DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLPOSITIONNOTIFY; dsbdesc.dwBufferBytes = dwSize; dsbdesc.lpwfxFormat = (LPWAVEFORMATEX) & pcmwf; if ((err = lpDS->CreateSoundBuffer(&dsbdesc, &lpDSBuffer, NULL)) != DS_OK) { - wsprintf(errbuf,"Error creating the secondary buffer (%lx)",err); - MessageBox(hwnd,errbuf,"FPSFX::FPSFX()", MB_OK); + wsprintf(errbuf, "Error creating the secondary buffer (%lx)", err); + MessageBox(hwnd, errbuf, "FPSFX::FPSFX()", MB_OK); return false; } @@ -1360,18 +1350,19 @@ bool FPSFX::LoadFile(const char *lpszFileName, uint32 dwCodec) { case FPCODEC_ADPCM: if (bStereo) - lpCodec = new CODECADPCMSTEREO(bLoop,lpTempBuffer); - else - lpCodec = new CODECADPCMMONO(bLoop,lpTempBuffer); - break; + lpCodec = new CODECADPCMSTEREO(bLoop, lpTempBuffer); + else + lpCodec = new CODECADPCMMONO(bLoop, lpTempBuffer); + break; default: - return false;G + return false; + G } /* Riempie il buffer */ if ((err = lpDSBuffer->Lock(0, dwSize, &lpBuf, (uint32 *)&dwHi, NULL, NULL, 0)) != DS_OK) { - MessageBox(hwnd,"Cannot lock sfx buffer!","FPSFX::LoadFile()", MB_OK); + MessageBox(hwnd, "Cannot lock sfx buffer!", "FPSFX::LoadFile()", MB_OK); return false; } @@ -1504,7 +1495,7 @@ void FPSFX::SetVolume(int dwVolume) { if (!GLOBALS.bCfgDubbing) dwVolume = 0; else { dwVolume -= (10 - GLOBALS.nCfgDubbingVolume) * 2; - if (dwVolume<0) dwVolume = 0; + if (dwVolume < 0) dwVolume = 0; } } else { if (!GLOBALS.bCfgSFX) dwVolume = 0; @@ -1515,7 +1506,7 @@ void FPSFX::SetVolume(int dwVolume) { } #ifdef REFACTOR_ME if (bFileLoaded) - lpDSBuffer->SetVolume(dwVolume * (DSBVOLUME_MAX-DSBVOLUME_MIN) / 64 + DSBVOLUME_MIN); + lpDSBuffer->SetVolume(dwVolume * (DSBVOLUME_MAX - DSBVOLUME_MIN) / 64 + DSBVOLUME_MIN); #endif } @@ -1560,7 +1551,7 @@ void FPSFX::GetVolume(int *lpdwVolume) { FPSTREAM::FPSTREAM(LPDIRECTSOUND LPDS, HWND hWnd, bool bSoundOn) { #ifdef REFACTOR_ME //hwnd=hWnd; - lpDS=LPDS; + lpDS = LPDS; bSoundSupported = bSoundOn; bFileLoaded = false; bIsPlaying = false; @@ -1583,12 +1574,12 @@ bool FPSTREAM::CreateBuffer(int nBufSize) { return true; /* Setta le strutture necessarie per la creazione di un secondary buffer - per lo stream lungo esattamente 1 secondo di musica. Attiviamo inoltre - il controllo del volume, in modo da poter abbassare e alzare il volume - della musica indipendentemente da quello generale. Ovviamente si tratta - di un buffer in RAM */ + per lo stream lungo esattamente 1 secondo di musica. Attiviamo inoltre + il controllo del volume, in modo da poter abbassare e alzare il volume + della musica indipendentemente da quello generale. Ovviamente si tratta + di un buffer in RAM */ pcmwf.wBitsPerSample = 16; - pcmwf.wf.wFormatTag=WAVE_FORMAT_PCM; + pcmwf.wf.wFormatTag = WAVE_FORMAT_PCM; pcmwf.wf.nChannels = 2; pcmwf.wf.nSamplesPerSec = 44100; pcmwf.wf.nBlockAlign = (pcmwf.wBitsPerSample / 8) * pcmwf.wf.nChannels; @@ -1596,12 +1587,12 @@ bool FPSTREAM::CreateBuffer(int nBufSize) { dsbdesc.dwSize = sizeof(dsbdesc); dsbdesc.dwFlags = DSBCAPS_CTRLVOLUME | DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLPOSITIONNOTIFY; - dwBufferSize=dsbdesc.dwBufferBytes = (((uint32)(pcmwf.wf.nAvgBytesPerSec * nBufSize) / 1000 + 31) / 32) * 32; + dwBufferSize = dsbdesc.dwBufferBytes = (((uint32)(pcmwf.wf.nAvgBytesPerSec * nBufSize) / 1000 + 31) / 32) * 32; dsbdesc.lpwfxFormat = (LPWAVEFORMATEX) & pcmwf; if ((err = lpDS->CreateSoundBuffer(&dsbdesc, &lpDSBuffer, NULL)) != DS_OK) { - wsprintf(errbuf,"Error creating the secondary buffer (%lx)",err); - MessageBox(hwnd,errbuf,"FPSTREAM::FPSTREAM()", MB_OK); + wsprintf(errbuf, "Error creating the secondary buffer (%lx)", err); + MessageBox(hwnd, errbuf, "FPSTREAM::FPSTREAM()", MB_OK); bSoundSupported = false; return false; } @@ -1609,20 +1600,20 @@ bool FPSTREAM::CreateBuffer(int nBufSize) { /* Crea il notify per avvertire quando vengono raggiunte le posizioni chiave - all'interno dello stream. Le posizioni chiave si trovano rispettivamente - subito dopo l'inizio e subito dopo la meta' del buffer */ - err = lpDSBuffer->QueryInterface(IID_IDirectSoundNotify,(void **)&lpDSNotify); + all'interno dello stream. Le posizioni chiave si trovano rispettivamente + subito dopo l'inizio e subito dopo la meta' del buffer */ + err = lpDSBuffer->QueryInterface(IID_IDirectSoundNotify, (void **)&lpDSNotify); if (FAILED(err)) { - wsprintf(errbuf,"Error creating notify object! (%lx)",err); - MessageBox(hwnd,errbuf,"FPSTREAM::FPSTREAM()", MB_OK); + wsprintf(errbuf, "Error creating notify object! (%lx)", err); + MessageBox(hwnd, errbuf, "FPSTREAM::FPSTREAM()", MB_OK); bSoundSupported = false; return false; } - hHot1=CreateEvent(NULL, false, false, NULL); - hHot2=CreateEvent(NULL, false, false, NULL); - hHot3=CreateEvent(NULL, false, false, NULL); + hHot1 = CreateEvent(NULL, false, false, NULL); + hHot2 = CreateEvent(NULL, false, false, NULL); + hHot3 = CreateEvent(NULL, false, false, NULL); hPlayThread_PlayFast = CreateEvent(NULL, false, false, NULL); dspnHot[0].dwOffset = 32; @@ -1634,7 +1625,7 @@ bool FPSTREAM::CreateBuffer(int nBufSize) { dspnHot[2].dwOffset = dwBufferSize - 32; //DSBPN_OFFSETSTOP; dspnHot[2].hEventNotify = hHot3; - lpDSNotify->SetNotificationPositions(3,dspnHot); + lpDSNotify->SetNotificationPositions(3, dspnHot); #endif return true; } @@ -1681,7 +1672,7 @@ FPSTREAM::~FPSTREAM() { CloseHandle(hPlayThread_PlayNormal); hPlayThread_PlayNormal = NULL; } - + SyncToPlay = NULL; RELEASE(lpDSNotify); @@ -1743,18 +1734,18 @@ bool FPSTREAM::LoadFile(const char *lpszFileName, uint32 dwCodType, int nBufSize if (!_file.open(lpszFileName)) //MessageBox(hwnd,"Cannot open stream file!","FPSTREAM::LoadFile()", MB_OK); return false; - } +} - /* Si salva la lunghezza dello stream */ - dwSize = _file.size(); - _file.seek(0); +/* Si salva la lunghezza dello stream */ +dwSize = _file.size(); +_file.seek(0); - /* Tutto a posto, possiamo uscire */ - bFileLoaded = true; - bIsPlaying = false; - bPaused = false; +/* Tutto a posto, possiamo uscire */ +bFileLoaded = true; +bIsPlaying = false; +bPaused = false; #endif - return true; +return true; } @@ -1832,36 +1823,36 @@ void FPSTREAM::Prefetch(void) { /* Riempie il buffer per avere i dati gia' pronti */ if ((err = lpDSBuffer->Lock(0, dwBufferSize / 2, &lpBuf, (uint32 *)&dwHi, NULL, NULL, 0)) != DS_OK) { - MessageBox(hwnd,"Cannot lock stream buffer!","soundLoadStream()", MB_OK); + MessageBox(hwnd, "Cannot lock stream buffer!", "soundLoadStream()", MB_OK); return; } - + /* Decomprime i dati dello stream direttamente dentro il buffer lockato */ lpCodec->Decompress(hFile, lpBuf, dwBufferSize / 2); - + /* Unlocka il buffer */ lpDSBuffer->Unlock(lpBuf, dwBufferSize / 2, NULL, NULL); - + /* Crea il thread che fa il play dello stream */ hThreadEnd = CreateEvent(NULL, false, false, NULL); hPlayThread = CreateThread(NULL, 10240, (LPTHREAD_START_ROUTINE)PlayThread, (void *)this, 0, &dwId); SetThreadPriority(hPlayThread, THREAD_PRIORITY_HIGHEST); - + /* Start il play del buffer DirectSound */ lpDSBuffer->SetCurrentPosition(0); bIsPlaying = true; dspnHot[0].dwOffset = 32; dspnHot[0].hEventNotify = hHot1; - + dspnHot[1].dwOffset = dwBufferSize / 2 + 32; dspnHot[1].hEventNotify = hHot2; - + dspnHot[2].dwOffset = dwBufferSize - 32; //DSBPN_OFFSETSTOP; dspnHot[2].hEventNotify = hHot3; - - if (FAILED(lpDSNotify->SetNotificationPositions(3,dspnHot))) { - int a=1; + + if (FAILED(lpDSNotify->SetNotificationPositions(3, dspnHot))) { + int a = 1; } #endif } @@ -1870,16 +1861,16 @@ void FPSTREAM::PlayFast(void) { #ifdef REFACTOR_ME dspnHot[0].dwOffset = 32; dspnHot[0].hEventNotify = hHot1; - + dspnHot[1].dwOffset = dwBufferSize / 2 + 32; dspnHot[1].hEventNotify = hHot2; - - dspnHot[2].dwOffset = dwBufferSize-32; //DSBPN_OFFSETSTOP; + + dspnHot[2].dwOffset = dwBufferSize - 32; //DSBPN_OFFSETSTOP; dspnHot[2].hEventNotify = hHot3; - + lpDSBuffer->Stop(); - if (FAILED(lpDSNotify->SetNotificationPositions(3,dspnHot))) { + if (FAILED(lpDSNotify->SetNotificationPositions(3, dspnHot))) { warning("PlayFast SNP failed!"); } @@ -1908,58 +1899,57 @@ bool FPSTREAM::Play() { case FPCODEC_RAW: lpCodec = new CODECRAW(bLoop); break; - + case FPCODEC_ADPCM: lpCodec = new CODECADPCMSTEREO(bLoop); break; - + default: return false; } - + /* Posiziona lo stream file all'inizio */ _file.seek(0); lpDSBuffer->Stop(); lpDSBuffer->SetCurrentPosition(0); - + /* Riempie il buffer per avere i dati gia' pronti */ - if ((err = lpDSBuffer->Lock(0,dwBufferSize/2, &lpBuf,(uint32 *)&dwHi, NULL, NULL, 0)) != DS_OK) { - error("Cannot lock stream buffer!","soundLoadStream()"); + if ((err = lpDSBuffer->Lock(0, dwBufferSize / 2, &lpBuf, (uint32 *)&dwHi, NULL, NULL, 0)) != DS_OK) { + error("Cannot lock stream buffer!", "soundLoadStream()"); } - + /* Decomprime i dati dello stream direttamente dentro il buffer lockato */ lpCodec->Decompress(hFile, lpBuf, dwBufferSize / 2); - + /* Unlocka il buffer */ lpDSBuffer->Unlock(lpBuf, dwBufferSize / 2, NULL, NULL); - + /* Crea il thread che fa il play dello stream */ hThreadEnd = CreateEvent(NULL, false, false, NULL); hPlayThread = CreateThread(NULL, 10240, (LPTHREAD_START_ROUTINE)PlayThread, (void *)this, 0, &dwId); SetThreadPriority(hPlayThread, THREAD_PRIORITY_HIGHEST); SetEvent(hPlayThread_PlayFast); - + #if 0 - /* Start il play del buffer DirectSound */ - lpDSBuffer->SetCurrentPosition(0); - - dspnHot[0].dwOffset = 32; - dspnHot[0].hEventNotify = hHot1; - - dspnHot[1].dwOffset = dwBufferSize/2+32; - dspnHot[1].hEventNotify = hHot2; - - dspnHot[2].dwOffset = dwBufferSize-32; //DSBPN_OFFSETSTOP; - dspnHot[2].hEventNotify = hHot3; - - if (FAILED(lpDSNotify->SetNotificationPositions(3,dspnHot))) - { - int a=1; - } - - - lpDSBuffer->Play(0, 0,DSBPLAY_LOOPING); + /* Start il play del buffer DirectSound */ + lpDSBuffer->SetCurrentPosition(0); + + dspnHot[0].dwOffset = 32; + dspnHot[0].hEventNotify = hHot1; + + dspnHot[1].dwOffset = dwBufferSize / 2 + 32; + dspnHot[1].hEventNotify = hHot2; + + dspnHot[2].dwOffset = dwBufferSize - 32; //DSBPN_OFFSETSTOP; + dspnHot[2].hEventNotify = hHot3; + + if (FAILED(lpDSNotify->SetNotificationPositions(3, dspnHot))) { + int a = 1; + } + + + lpDSBuffer->Play(0, 0, DSBPLAY_LOOPING); #endif bIsPlaying = true; @@ -1996,9 +1986,9 @@ bool FPSTREAM::Stop(bool bSync) { // lpDSBuffer->Play(0, 0, 0); return true; } else { - /* Ferma il buffer DirectSound */ + /* Ferma il buffer DirectSound */ lpDSBuffer->Stop(); - + /* Avverte il thread che deve uscire e aspetta che si chiuda */ SetEvent(hThreadEnd); WaitForSingleObject(hPlayThread, CORO_INFINITE); @@ -2033,8 +2023,8 @@ void FPSTREAM::WaitForSync(FPSTREAM *toplay) { bSyncExit = true; char buf[1024]; - sprintf(buf, "Wait for sync: %x (SyncToPlay: [%x]=%x, SyncExit: [%x]=%d) MyThread: 0x%x\n", - this->lpDSBuffer, &this->SyncToPlay, SyncToPlay, &bSyncExit, bSyncExit, GetCurrentThreadId()); + sprintf(buf, "Wait for sync: %x (SyncToPlay: [%x]=%x, SyncExit: [%x]=%d) MyThread: 0x%x\n", + this->lpDSBuffer, &this->SyncToPlay, SyncToPlay, &bSyncExit, bSyncExit, GetCurrentThreadId()); warning(buf); WaitForSingleObject(hPlayThread, CORO_INFINITE); @@ -2043,7 +2033,7 @@ void FPSTREAM::WaitForSync(FPSTREAM *toplay) { CloseHandle(hPlayThread); CloseHandle(hThreadEnd); GlobalFree(lpTempBuffer); - + /* Disalloca e chiude il CODEC */ delete lpCodec; #endif @@ -2068,7 +2058,7 @@ void FPSTREAM::PlayThread(FPSTREAM *This) { uint32 countEnd; bool bPrecache; char buf[1024]; - + /* Eventi che segnalano quando bisogna eseguire qualcosa */ HANDLE hList[5] = { This->hThreadEnd, This->hHot1, This->hHot2, This->hHot3, This->hPlayThread_PlayFast }; @@ -2077,7 +2067,7 @@ void FPSTREAM::PlayThread(FPSTREAM *This) { while (cicla) { if (This->lpCodec->EndOfStream() && This->lpCodec->bLoop == false) { countEnd++; - if (countEnd==3) + if (countEnd == 3) break; } @@ -2086,7 +2076,7 @@ void FPSTREAM::PlayThread(FPSTREAM *This) { ZeroMemory(This->lpTempBuffer, This->dwBufferSize / 2); else if (bPrecache) This->lpCodec->Decompress(This->_file, This->lpTempBuffer, This->dwBufferSize / 2); - + bPrecache = false; /* Attende il set di un evento. Dato che sono tutti in automatic reset, @@ -2100,12 +2090,12 @@ void FPSTREAM::PlayThread(FPSTREAM *This) { // warning(buf); dwResult = WaitForMultipleObjects(5, hList, false, CORO_INFINITE); -/* uint32 dwPlay, dwWrite; - This->lpDSBuffer->GetCurrentPosition(&dwPlay, &dwWrite); - sprintf(buf, "CP Play: %u, Write: %u\n", dwPlay, dwWrite); - warning(buf); */ + /* uint32 dwPlay, dwWrite; + This->lpDSBuffer->GetCurrentPosition(&dwPlay, &dwWrite); + sprintf(buf, "CP Play: %u, Write: %u\n", dwPlay, dwWrite); + warning(buf); */ - /* Fa uno switch per stabilire quale evento e' stato settato */ + /* Fa uno switch per stabilire quale evento e' stato settato */ switch (dwResult - WAIT_OBJECT_0) { case 0: /* Bisogna uscire dal thread */ @@ -2113,16 +2103,16 @@ void FPSTREAM::PlayThread(FPSTREAM *This) { break; case 1: - /* Bisogna riempire la seconda meta' del buffer */ + /* Bisogna riempire la seconda meta' del buffer */ // if (dwPlay >= This->dspnHot[0].dwOffset && dwPlay <= This->dspnHot[0].dwOffset+1024 ) { // sprintf(buf, "Prima met buffer: %x\n", This->lpDSBuffer); // warning(buf); - This->lpDSBuffer->Lock(This->dwBufferSize/2,This->dwBufferSize/2,(void **)&lpLockBuf, &dwResult,(void **)&lpLockBuf2, &dwResult2, 0); - // sprintf(buf, "LockedBuf: dwResult=%x, dwBufferSize/2=%x, lpLockBuf2=%x, dwResult2=%x\n", dwResult, This->dwBufferSize/2, lpLockBuf2, dwResult2); - // warning(buf); - CopyMemory(lpLockBuf,This->lpTempBuffer,This->dwBufferSize/2); - This->lpDSBuffer->Unlock(lpLockBuf,This->dwBufferSize/2,lpLockBuf2, 0); + This->lpDSBuffer->Lock(This->dwBufferSize / 2, This->dwBufferSize / 2, (void **)&lpLockBuf, &dwResult, (void **)&lpLockBuf2, &dwResult2, 0); + // sprintf(buf, "LockedBuf: dwResult=%x, dwBufferSize/2=%x, lpLockBuf2=%x, dwResult2=%x\n", dwResult, This->dwBufferSize/2, lpLockBuf2, dwResult2); + // warning(buf); + CopyMemory(lpLockBuf, This->lpTempBuffer, This->dwBufferSize / 2); + This->lpDSBuffer->Unlock(lpLockBuf, This->dwBufferSize / 2, lpLockBuf2, 0); bPrecache = true; } break; @@ -2130,33 +2120,32 @@ void FPSTREAM::PlayThread(FPSTREAM *This) { case 2: /* Bisogna riempire la prima meta' del buffer */ // if (dwPlay >= This->dspnHot[1].dwOffset && dwPlay <= This->dspnHot[1].dwOffset+1024 ) - { + { // sprintf(buf, "Seconda met buffer: %x\n", This->lpDSBuffer); // warning(buf); - This->lpDSBuffer->Lock(0,This->dwBufferSize/2,(void **)&lpLockBuf, &dwResult, NULL, NULL, 0); - CopyMemory(lpLockBuf,This->lpTempBuffer,This->dwBufferSize/2); - This->lpDSBuffer->Unlock(lpLockBuf,This->dwBufferSize/2, NULL, NULL); - bPrecache = true; - } - break; + This->lpDSBuffer->Lock(0, This->dwBufferSize / 2, (void **)&lpLockBuf, &dwResult, NULL, NULL, 0); + CopyMemory(lpLockBuf, This->lpTempBuffer, This->dwBufferSize / 2); + This->lpDSBuffer->Unlock(lpLockBuf, This->dwBufferSize / 2, NULL, NULL); + bPrecache = true; + } + break; - case 3: - { + case 3: { // sprintf(buf, "End of buffer %x (SyncToPlay [%x]=%x, SyncExit: [%x]=%d)\n", This->lpDSBuffer, &This->SyncToPlay, This->SyncToPlay, &This->bSyncExit, This->bSyncExit); // warning(buf); - if (This->bSyncExit) { + if (This->bSyncExit) { // sprintf(buf, "Go with sync (Buffer: %x) MyThread: %x!\n", This->SyncToPlay->lpDSBuffer, GetCurrentThreadId()); // warning(buf); - //This->SyncToPlay->PlayFast(); - SetEvent(This->SyncToPlay->hPlayThread_PlayFast); - // Transfer immediatly control to the other threads - Sleep(0); - This->bSyncExit = false; - cicla = false; - break; - } + //This->SyncToPlay->PlayFast(); + SetEvent(This->SyncToPlay->hPlayThread_PlayFast); + // Transfer immediatly control to the other threads + Sleep(0); + This->bSyncExit = false; + cicla = false; + break; } - break; + } + break; case 4: This->PlayFast(); @@ -2164,7 +2153,7 @@ void FPSTREAM::PlayThread(FPSTREAM *This) { } } - /* Ferma il buffer DirectSound */ + /* Ferma il buffer DirectSound */ // sprintf(buf, "Exiting thread. Buffer = %x, MyThread = 0x%x\n", This->lpDSBuffer, GetCurrentThreadId()); // warning(buf); This->lpDSBuffer->Stop(); @@ -2206,17 +2195,17 @@ void FPSTREAM::Pause(bool bPause) { } else if (!bPause && bPaused) { dspnHot[0].dwOffset = 32; dspnHot[0].hEventNotify = hHot1; - + dspnHot[1].dwOffset = dwBufferSize / 2 + 32; dspnHot[1].hEventNotify = hHot2; - - dspnHot[2].dwOffset = dwBufferSize-32; //DSBPN_OFFSETSTOP; + + dspnHot[2].dwOffset = dwBufferSize - 32; //DSBPN_OFFSETSTOP; dspnHot[2].hEventNotify = hHot3; - - if (FAILED(lpDSNotify->SetNotificationPositions(3,dspnHot))) { + + if (FAILED(lpDSNotify->SetNotificationPositions(3, dspnHot))) { int a = 1; } - + lpDSBuffer->Play(0, 0, bLoop); bIsPlaying = true; bPaused = false; @@ -2244,13 +2233,13 @@ void FPSTREAM::SetVolume(int dwVolume) { #ifdef REFACTOR_ME if (dwVolume > 63) dwVolume = 63; if (dwVolume < 0) dwVolume = 0; - + lastVolume = dwVolume; if (!GLOBALS.bCfgMusic) dwVolume = 0; else { dwVolume -= (10 - GLOBALS.nCfgMusicVolume) * 2; - if (dwVolume<0) dwVolume = 0; + if (dwVolume < 0) dwVolume = 0; } if (lpDSBuffer) diff --git a/engines/tony/sound.h b/engines/tony/sound.h index bfa48f4d78..7defeb1149 100644 --- a/engines/tony/sound.h +++ b/engines/tony/sound.h @@ -73,144 +73,144 @@ private: DSCAPS dscaps; HWND hwnd; -/****************************************************************************\ -* Metodi -\****************************************************************************/ + /****************************************************************************\ + * Metodi + \****************************************************************************/ public: -/****************************************************************************\ -* -* Function: FPSOUND::FPSOUND(); -* -* Description: Costruttore di default. Inizializza gli attributi. -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: FPSOUND::FPSOUND(); + * + * Description: Costruttore di default. Inizializza gli attributi. + * + \****************************************************************************/ FPSOUND(); -/****************************************************************************\ -* -* Function: FPSOUND::~FPSOUND(); -* -* Description: Deinizializza l'oggetto, disallocando la memoria. -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: FPSOUND::~FPSOUND(); + * + * Description: Deinizializza l'oggetto, disallocando la memoria. + * + \****************************************************************************/ ~FPSOUND(); -/****************************************************************************\ -* -* Function: bool FPSOUND::Init(HWND hWnd); -* -* Description: Inizializza l'oggetto, e prepara tutto il necessario per -* creare stream e effetti sonori. -* -* Input: HWND hWnd Handle della finestra principale -* -* Return: True se tutto OK, FALSE in caso di errore. -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: bool FPSOUND::Init(HWND hWnd); + * + * Description: Inizializza l'oggetto, e prepara tutto il necessario per + * creare stream e effetti sonori. + * + * Input: HWND hWnd Handle della finestra principale + * + * Return: True se tutto OK, FALSE in caso di errore. + * + \****************************************************************************/ bool Init(/*HWND hWnd*/); -/****************************************************************************\ -* -* Function: bool CreateStream(FPSTREAM** lplpStream); -* -* Description: Alloca un oggetti di tipo FPSTREAM, e ritorna il suo -* puntatore dopo averlo inizializzato. -* -* Input: FPSTREAM** lplpStream Conterra' il pointer all'oggetto -* appena creato. -* -* Return: TRUE se tutto OK, FALSE in caso di errore -* -* Note: L'utilizzo di funzioni del tipo CreateStream(), CreateSfx(), -* sono dovute al fatto che i costruttori delle classi FPSTREAM -* e FPSFX richiedono che DirectSound sia gia' stato -* inzializzato. In questo modo quindi si evitano dei bugs -* che si verrebbero a creare se venisse dichiarata un oggetto -* di tipo FPSTREAM o FPSFX globale (o cmq prima della -* inizializzazione di DirectSound). -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: bool CreateStream(FPSTREAM** lplpStream); + * + * Description: Alloca un oggetti di tipo FPSTREAM, e ritorna il suo + * puntatore dopo averlo inizializzato. + * + * Input: FPSTREAM** lplpStream Conterra' il pointer all'oggetto + * appena creato. + * + * Return: TRUE se tutto OK, FALSE in caso di errore + * + * Note: L'utilizzo di funzioni del tipo CreateStream(), CreateSfx(), + * sono dovute al fatto che i costruttori delle classi FPSTREAM + * e FPSFX richiedono che DirectSound sia gia' stato + * inzializzato. In questo modo quindi si evitano dei bugs + * che si verrebbero a creare se venisse dichiarata un oggetto + * di tipo FPSTREAM o FPSFX globale (o cmq prima della + * inizializzazione di DirectSound). + * + \****************************************************************************/ bool CreateStream(FPSTREAM **lplpStream); -/****************************************************************************\ -* -* Function: bool CreateSfx(FPSFX** lplpSfx); -* -* Description: Alloca un oggetti di tipo FPSFX e ritorna il suo -* puntatore dopo averlo inizializzato. -* -* Input: FPSFX** lplpSfx Conterra' il pointer all'oggetto -* appena creato. -* -* Return: TRUE se tutto OK, FALSE in caso di errore -* -* Note: Vedi le note di CreateStream() -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: bool CreateSfx(FPSFX** lplpSfx); + * + * Description: Alloca un oggetti di tipo FPSFX e ritorna il suo + * puntatore dopo averlo inizializzato. + * + * Input: FPSFX** lplpSfx Conterra' il pointer all'oggetto + * appena creato. + * + * Return: TRUE se tutto OK, FALSE in caso di errore + * + * Note: Vedi le note di CreateStream() + * + \****************************************************************************/ bool CreateSfx(FPSFX **lplpSfx); -/****************************************************************************\ -* -* Function: void SetMasterVolume(int dwVolume); -* -* Description: Setta il volume generale -* -* Input: int dwVolume Volume da settare (0-63) -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: void SetMasterVolume(int dwVolume); + * + * Description: Setta il volume generale + * + * Input: int dwVolume Volume da settare (0-63) + * + \****************************************************************************/ void SetMasterVolume(int dwVolume); -/****************************************************************************\ -* -* Function: void GetMasterVolume(LPINT lpdwVolume); -* -* Description: Richiede il volume generale -* -* Input: LPINT lpdwVolume Variabile che conterra' il volume (0-63) -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: void GetMasterVolume(LPINT lpdwVolume); + * + * Description: Richiede il volume generale + * + * Input: LPINT lpdwVolume Variabile che conterra' il volume (0-63) + * + \****************************************************************************/ void GetMasterVolume(int *lpdwVolume); }; class FPSFX { -/****************************************************************************\ -* Attributi -\****************************************************************************/ + /****************************************************************************\ + * Attributi + \****************************************************************************/ private: -/* - HWND hwnd; - LPDIRECTSOUND lpDS; - LPDIRECTSOUNDBUFFER lpDSBuffer; // Buffer DirectSound -*/ + /* + HWND hwnd; + LPDIRECTSOUND lpDS; + LPDIRECTSOUNDBUFFER lpDSBuffer; // Buffer DirectSound + */ bool bSoundSupported; // TRUE se il suono e' attivo bool bFileLoaded; // TRUE se e' stato aperto un file bool bLoop; // TRUE se bisogna loopare l'effetto sonoro bool bPaused; int lastVolume; - bool bStereo; // TRUE se stereo - bool b16bit; // TRUE se 16 bit - uint32 dwFreq; // Frequenza originale di campionamento + bool bStereo; // TRUE se stereo + bool b16bit; // TRUE se 16 bit + uint32 dwFreq; // Frequenza originale di campionamento // CODEC* lpCodec; // CODEC da utilizzare. bool bIsPlaying; // TRUE se si sta playando l'effetto sonoro @@ -219,178 +219,178 @@ private: // LPDIRECTSOUNDNOTIFY lpDSNotify; // Notify degli hotspot nel buffer // DSBPOSITIONNOTIFY dspnHot[2]; - + public: uint32 hEndOfBuffer; private: -/****************************************************************************\ -* Metodi -\****************************************************************************/ + /****************************************************************************\ + * Metodi + \****************************************************************************/ public: -/****************************************************************************\ -* -* Function: FPSFX(LPDIRECTSOUND lpDS, bool bSoundOn); -* -* Description: Costruttore di default. *NON* bisogna dichiarare direttamente -* un oggetto, ma crearlo piuttosto tramite FPSOUND::CreateSfx() -* -\****************************************************************************/ - - FPSFX(void * /*LPDIRECTSOUND */lpDS, uint32 /*HWND*/ hwnd, bool bSoundOn); - - -/****************************************************************************\ -* -* Function: ~FPSFX(); -* -* Description: Distruttore di default. Si preoccupa anche di fermare il sound -* effect eventualmente in esecuzione, e disallocare la memoria -* da esso occupata. -* -\****************************************************************************/ - - ~FPSFX(); - + /****************************************************************************\ + * + * Function: FPSFX(LPDIRECTSOUND lpDS, bool bSoundOn); + * + * Description: Costruttore di default. *NON* bisogna dichiarare direttamente + * un oggetto, ma crearlo piuttosto tramite FPSOUND::CreateSfx() + * + \****************************************************************************/ + + FPSFX(void * /*LPDIRECTSOUND */lpDS, uint32 /*HWND*/ hwnd, bool bSoundOn); + + + /****************************************************************************\ + * + * Function: ~FPSFX(); + * + * Description: Distruttore di default. Si preoccupa anche di fermare il sound + * effect eventualmente in esecuzione, e disallocare la memoria + * da esso occupata. + * + \****************************************************************************/ + + ~FPSFX(); + + + /****************************************************************************\ + * + * Function: Release(); + * + * Description: Rilascia la memoria dell'oggetto. Deve essere richiamata quando + * l'oggetto non serve piu' e **SOLO SE** l'oggetto e' stato + * creato con la FPSOUND::CreateStream(). + * + * Note: Eventuali puntatori all'oggetto non sono piu' validi dopo + * questa chiamata. + * + \****************************************************************************/ -/****************************************************************************\ -* -* Function: Release(); -* -* Description: Rilascia la memoria dell'oggetto. Deve essere richiamata quando -* l'oggetto non serve piu' e **SOLO SE** l'oggetto e' stato -* creato con la FPSOUND::CreateStream(). -* -* Note: Eventuali puntatori all'oggetto non sono piu' validi dopo -* questa chiamata. -* -\****************************************************************************/ - - void Release(); + void Release(); -/****************************************************************************\ -* -* Function: bool LoadFile(char *lpszFileName, uint32 dwCodec=FPCODEC_RAW); -* -* Description: Apre un file di effetto sonoro e lo carica. -* -* Input: char *lpszFile Nome del file di sfx da aprire -* uint32 dwCodec CODEC da utilizzare per decomprimere -* i campioni sonori -* -* Return: TRUE se tutto OK, FALSE in caso di errore -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: bool LoadFile(char *lpszFileName, uint32 dwCodec=FPCODEC_RAW); + * + * Description: Apre un file di effetto sonoro e lo carica. + * + * Input: char *lpszFile Nome del file di sfx da aprire + * uint32 dwCodec CODEC da utilizzare per decomprimere + * i campioni sonori + * + * Return: TRUE se tutto OK, FALSE in caso di errore + * + \****************************************************************************/ bool LoadFile(const char *lpszFileName, uint32 dwCodec = FPCODEC_RAW); bool LoadFile(byte *lpBuf, uint32 dwCodec); bool LoadVoiceFromVDB(Common::File &vdbFP); -/****************************************************************************\ -* -* Function: bool Play(); -* -* Description: Suona lo sfx caricato. -* -* Return: TRUE se tutto OK, FALSE in caso di errore. -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: bool Play(); + * + * Description: Suona lo sfx caricato. + * + * Return: TRUE se tutto OK, FALSE in caso di errore. + * + \****************************************************************************/ - bool Play(); + bool Play(); -/****************************************************************************\ -* -* Function: bool Stop(); -* -* Description: Ferma il play dello sfx. -* -* Return: TRUE se tutto OK, FALSE in caso di errore. -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: bool Stop(); + * + * Description: Ferma il play dello sfx. + * + * Return: TRUE se tutto OK, FALSE in caso di errore. + * + \****************************************************************************/ - bool Stop(); + bool Stop(); -/****************************************************************************\ -* -* Function: void Pause(bool bPause); -* -* Description: Pause dell'effetto sonoro -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: void Pause(bool bPause); + * + * Description: Pause dell'effetto sonoro + * + \****************************************************************************/ - void Pause(bool bPause); + void Pause(bool bPause); -/****************************************************************************\ -* -* Function: bool SetLoop(bool bLoop); -* -* Description: Attiva o disattiva il loop dello sfx. -* -* Input: bool bLoop TRUE per attivare il loop, FALSE per -* disattivarlo -* -* Note: Il loop deve essere attivato PRIMA di eseguire il play -* dello sfx. Qualsiasi modifica effettuata durante il play -* non avra' effetto fino a che lo sfx non viene fermato, -* e poi rimesso in play. -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: bool SetLoop(bool bLoop); + * + * Description: Attiva o disattiva il loop dello sfx. + * + * Input: bool bLoop TRUE per attivare il loop, FALSE per + * disattivarlo + * + * Note: Il loop deve essere attivato PRIMA di eseguire il play + * dello sfx. Qualsiasi modifica effettuata durante il play + * non avra' effetto fino a che lo sfx non viene fermato, + * e poi rimesso in play. + * + \****************************************************************************/ - void SetLoop(bool bLoop); + void SetLoop(bool bLoop); -/****************************************************************************\ -* -* Function: void SetVolume(int dwVolume); -* -* Description: Cambia il volume dello sfx -* -* Input: int dwVolume Volume da settare (0-63) -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: void SetVolume(int dwVolume); + * + * Description: Cambia il volume dello sfx + * + * Input: int dwVolume Volume da settare (0-63) + * + \****************************************************************************/ - void SetVolume(int dwVolume); + void SetVolume(int dwVolume); -/****************************************************************************\ -* -* Function: void GetVolume(int * lpdwVolume); -* -* Description: Chiede il volume dello sfx -* -* Input: int * lpdwVolume Variabile in cui verra' inserito -* il volume corrente -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: void GetVolume(int * lpdwVolume); + * + * Description: Chiede il volume dello sfx + * + * Input: int * lpdwVolume Variabile in cui verra' inserito + * il volume corrente + * + \****************************************************************************/ - void GetVolume(int * lpdwVolume); + void GetVolume(int *lpdwVolume); }; class FPSTREAM { -/****************************************************************************\ -* Attributi -\****************************************************************************/ + /****************************************************************************\ + * Attributi + \****************************************************************************/ private: -/* - HWND hwnd; - LPDIRECTSOUND lpDS; - LPDIRECTSOUNDBUFFER lpDSBuffer; // Buffer DirectSound circolare - LPDIRECTSOUNDNOTIFY lpDSNotify; // Notify degli hotspot nel buffer -*/ + /* + HWND hwnd; + LPDIRECTSOUND lpDS; + LPDIRECTSOUNDBUFFER lpDSBuffer; // Buffer DirectSound circolare + LPDIRECTSOUNDNOTIFY lpDSNotify; // Notify degli hotspot nel buffer + */ byte *lpTempBuffer; // Buffer temporaneo per decompressione uint32 dwBufferSize; // Dimensione del buffer in bytes @@ -424,171 +424,171 @@ private: static void PlayThread(FPSTREAM *This); -/****************************************************************************\ -* Metodi -\****************************************************************************/ + /****************************************************************************\ + * Metodi + \****************************************************************************/ public: -/****************************************************************************\ -* -* Function: FPSTREAM(LPDIRECTSOUND lpDS, bool bSoundOn); -* -* Description: Costruttore di default. *NON* bisogna dichiarare direttamente -* un oggetto, ma crearlo piuttosto tramite FPSOUND::CreateStream() -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: FPSTREAM(LPDIRECTSOUND lpDS, bool bSoundOn); + * + * Description: Costruttore di default. *NON* bisogna dichiarare direttamente + * un oggetto, ma crearlo piuttosto tramite FPSOUND::CreateStream() + * + \****************************************************************************/ FPSTREAM(void * /*LPDIRECTSOUND*/ lpDS, uint32 /*HWND hWnd */, bool bSoundOn); -/****************************************************************************\ -* -* Function: ~FPSTREAM(); -* -* Description: Distruttore di default. Si preoccupa anche di fermare stream -* eventualmente in esecuzione, e disallocare la memoria da -* essi occupata. -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: ~FPSTREAM(); + * + * Description: Distruttore di default. Si preoccupa anche di fermare stream + * eventualmente in esecuzione, e disallocare la memoria da + * essi occupata. + * + \****************************************************************************/ ~FPSTREAM(); -/****************************************************************************\ -* -* Function: Release(); -* -* Description: Rilascia la memoria dell'oggetto. Deve essere richiamata quando -* l'oggetto non serve piu' e **SOLO SE** l'oggetto e' stato -* creato con la FPSOUND::CreateStream(). -* -* Note: Eventuali puntatori all'oggetto non sono piu' validi dopo -* questa chiamata. -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: Release(); + * + * Description: Rilascia la memoria dell'oggetto. Deve essere richiamata quando + * l'oggetto non serve piu' e **SOLO SE** l'oggetto e' stato + * creato con la FPSOUND::CreateStream(). + * + * Note: Eventuali puntatori all'oggetto non sono piu' validi dopo + * questa chiamata. + * + \****************************************************************************/ void Release(); -/****************************************************************************\ -* -* Function: bool LoadFile(char *lpszFileName, uint32 dwCodec=FPCODEC_RAW); -* -* Description: Apre un file di stream. -* -* Input: char *lpszFile Nome del file di stream da aprire -* uint32 dwCodec CODEC da utilizzare per decomprimere -* i campioni sonori -* -* Return: TRUE se tutto OK, FALSE in caso di errore -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: bool LoadFile(char *lpszFileName, uint32 dwCodec=FPCODEC_RAW); + * + * Description: Apre un file di stream. + * + * Input: char *lpszFile Nome del file di stream da aprire + * uint32 dwCodec CODEC da utilizzare per decomprimere + * i campioni sonori + * + * Return: TRUE se tutto OK, FALSE in caso di errore + * + \****************************************************************************/ bool LoadFile(const char *lpszFileName, uint32 dwCodec = FPCODEC_RAW, int nSync = 2000); -/****************************************************************************\ -* -* Function: UnloadFile(); -* -* Description: Chiude un file di stream eventualmente aperto. E' necessario -* richiamare questa funzione per disallocare la memoria -* occupata dallo stream. -* -* Return: Il distruttore della classe per sicurezza richiama la -* UnloadFile() se non e' stata richiamata esplicitamente. -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: UnloadFile(); + * + * Description: Chiude un file di stream eventualmente aperto. E' necessario + * richiamare questa funzione per disallocare la memoria + * occupata dallo stream. + * + * Return: Il distruttore della classe per sicurezza richiama la + * UnloadFile() se non e' stata richiamata esplicitamente. + * + \****************************************************************************/ bool UnloadFile(); -/****************************************************************************\ -* -* Function: bool Play(); -* -* Description: Suona lo stream caricato. -* -* Return: TRUE se tutto OK, FALSE in caso di errore. -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: bool Play(); + * + * Description: Suona lo stream caricato. + * + * Return: TRUE se tutto OK, FALSE in caso di errore. + * + \****************************************************************************/ bool Play(); void PlayFast(void); void Prefetch(void); -/****************************************************************************\ -* -* Function: bool Stop(); -* -* Description: Ferma il play dello stream. -* -* Return: TRUE se tutto OK, FALSE in caso di errore. -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: bool Stop(); + * + * Description: Ferma il play dello stream. + * + * Return: TRUE se tutto OK, FALSE in caso di errore. + * + \****************************************************************************/ bool Stop(bool bSync = false); - void WaitForSync(FPSTREAM* toplay); + void WaitForSync(FPSTREAM *toplay); -/****************************************************************************\ -* -* Function: void Pause(bool bPause); -* -* Description: Pause dell'effetto sonoro -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: void Pause(bool bPause); + * + * Description: Pause dell'effetto sonoro + * + \****************************************************************************/ void Pause(bool bPause); -/****************************************************************************\ -* -* Function: bool SetLoop(bool bLoop); -* -* Description: Attiva o disattiva il loop dello stream. -* -* Input: bool bLoop TRUE per attivare il loop, FALSE per -* disattivarlo -* -* Note: Il loop deve essere attivato PRIMA di eseguire il play -* dello stream. Qualsiasi modifica effettuata durante il play -* non avra' effetto fino a che lo stream non viene fermato, -* e poi rimesso in play. -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: bool SetLoop(bool bLoop); + * + * Description: Attiva o disattiva il loop dello stream. + * + * Input: bool bLoop TRUE per attivare il loop, FALSE per + * disattivarlo + * + * Note: Il loop deve essere attivato PRIMA di eseguire il play + * dello stream. Qualsiasi modifica effettuata durante il play + * non avra' effetto fino a che lo stream non viene fermato, + * e poi rimesso in play. + * + \****************************************************************************/ void SetLoop(bool bLoop); -/****************************************************************************\ -* -* Function: void SetVolume(int dwVolume); -* -* Description: Cambia il volume dello stream -* -* Input: int dwVolume Volume da settare (0-63) -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: void SetVolume(int dwVolume); + * + * Description: Cambia il volume dello stream + * + * Input: int dwVolume Volume da settare (0-63) + * + \****************************************************************************/ void SetVolume(int dwVolume); -/****************************************************************************\ -* -* Function: void GetVolume(LPINT lpdwVolume); -* -* Description: Chiede il volume dello stream -* -* Input: LPINT lpdwVolume Variabile in cui verra' inserito -* il volume corrente -* -\****************************************************************************/ + /****************************************************************************\ + * + * Function: void GetVolume(LPINT lpdwVolume); + * + * Description: Chiede il volume dello stream + * + * Input: LPINT lpdwVolume Variabile in cui verra' inserito + * il volume corrente + * + \****************************************************************************/ void GetVolume(int *lpdwVolume); }; diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index e5988e7c9b..e5c30ffcec 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -36,8 +36,8 @@ namespace Tony { TonyEngine *_vm; -TonyEngine::TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc) : Engine(syst), - _gameDescription(gameDesc), _randomSource("tony") { +TonyEngine::TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc) : Engine(syst), + _gameDescription(gameDesc), _randomSource("tony") { _vm = this; _loadSlotNumber = -1; @@ -90,7 +90,7 @@ Common::ErrorCode TonyEngine::Init() { m_bDrawLocation = true; m_startTime = g_system->getMillis(); - // Init static class fields + // Init static class fields RMText::InitStatics(); RMTony::InitStatics(); @@ -174,7 +174,7 @@ void TonyEngine::PlayMusic(int nChannel, const char *fn, int nFX, bool bLoop, in if (nChannel < 4) if (GLOBALS.flipflop) nChannel = nChannel + 1; - + switch (nFX) { case 0: case 1: @@ -186,62 +186,57 @@ void TonyEngine::PlayMusic(int nChannel, const char *fn, int nFX, bool bLoop, in case 22: break; } - -#ifdef REFACTOR_ME + +#ifdef REFACTOR_ME // Mette il path giusto if (nChannel < 4) GetDataDirectory(DD_MUSIC, path_buffer); else GetDataDirectory(DD_LAYER, path_buffer); - _splitpath(path_buffer,drive,dir,NULL,NULL); - _splitpath(fn,NULL,NULL,fname,ext); - _makepath(path_buffer,drive,dir,fname,ext); + _splitpath(path_buffer, drive, dir, NULL, NULL); + _splitpath(fn, NULL, NULL, fname, ext); + _makepath(path_buffer, drive, dir, fname, ext); - _makepath(path_buffer,drive,dir,fname,ext); + _makepath(path_buffer, drive, dir, fname, ext); - if (nFX==22) // Sync a tempo - { - curChannel=nChannel; + if (nFX == 22) { // Sync a tempo + curChannel = nChannel; strcpy(nextMusic, path_buffer); - nextLoop=bLoop; - nextSync=nSync; + nextLoop = bLoop; + nextSync = nSync; if (flipflop) - nextChannel=nChannel-1; + nextChannel = nChannel - 1; else - nextChannel=nChannel+1; + nextChannel = nChannel + 1; DWORD id; - HANDLE hThread=CreateThread(NULL,10240,(LPTHREAD_START_ROUTINE)DoNextMusic,m_stream,0,&id); - SetThreadPriority(hThread,THREAD_PRIORITY_HIGHEST); - } - else if (nFX==44) // Cambia canale e lascia finire il primo - { + HANDLE hThread = CreateThread(NULL, 10240, (LPTHREAD_START_ROUTINE)DoNextMusic, m_stream, 0, &id); + SetThreadPriority(hThread, THREAD_PRIORITY_HIGHEST); + } else if (nFX == 44) { // Cambia canale e lascia finire il primo if (flipflop) - nextChannel=nChannel-1; + nextChannel = nChannel - 1; else - nextChannel=nChannel+1; + nextChannel = nChannel + 1; m_stream[nextChannel]->Stop(); m_stream[nextChannel]->UnloadFile(); if (!getIsDemo()) { - if (!m_stream[nextChannel]->LoadFile(path_buffer,FPCODEC_ADPCM,nSync)) + if (!m_stream[nextChannel]->LoadFile(path_buffer, FPCODEC_ADPCM, nSync)) theGame.Abort(); } else { - m_stream[nextChannel]->LoadFile(path_buffer,FPCODEC_ADPCM,nSync); + m_stream[nextChannel]->LoadFile(path_buffer, FPCODEC_ADPCM, nSync); } m_stream[nextChannel]->SetLoop(bLoop); m_stream[nextChannel]->Play(); - flipflop = 1-flipflop; - } - else - { + flipflop = 1 - flipflop; + } else { if (!getIsDemo()) { - if (!m_stream[nChannel]->LoadFile(path_buffer,FPCODEC_ADPCM,nSync)) + if (!m_stream[nChannel]->LoadFile(path_buffer, FPCODEC_ADPCM, nSync)) theGame.Abort(); } else { - m_stream[nChannel]->LoadFile(path_buffer,FPCODEC_ADPCM,nSync); + m_stream[nChannel]->LoadFile(path_buffer, FPCODEC_ADPCM, nSync); } m_stream[nChannel]->SetLoop(bLoop); @@ -320,9 +315,9 @@ void TonyEngine::PreloadSFX(int nChannel, const char *fn) { FPSFX *TonyEngine::CreateSFX(byte *buf) { FPSFX *sfx; - + _theSound.CreateSfx(&sfx); - sfx->LoadFile(buf,FPCODEC_WAV); + sfx->LoadFile(buf, FPCODEC_WAV); return sfx; } @@ -343,7 +338,7 @@ void TonyEngine::InitMusic() { _theSound.Init(/*_window*/); _theSound.SetMasterVolume(63); - + for (i = 0; i < 6; i++) _theSound.CreateStream(&m_stream[i]); @@ -389,7 +384,7 @@ Common::String TonyEngine::GetSaveStateFileName(int n) { void TonyEngine::AutoSave(CORO_PARAM) { CORO_BEGIN_CONTEXT; - Common::String buf; + Common::String buf; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -414,7 +409,7 @@ void TonyEngine::SaveState(int n, const char *name) { void TonyEngine::LoadState(CORO_PARAM, int n) { CORO_BEGIN_CONTEXT; - Common::String buf; + Common::String buf; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -491,14 +486,14 @@ void TonyEngine::Abort(void) { /** * Main process for playing the game. * - * @remarks This needs to be in a separate process, since there are some things that can briefly + * @remarks This needs to be in a separate process, since there are some things that can briefly * block the execution of process. For now, all ScummVm event handling is dispatched to within the context of this * process. If it ever proves a problem, we may have to look into whether it's feasible to have it still remain * in the outer 'main' process. */ void TonyEngine::PlayProcess(CORO_PARAM, const void *param) { CORO_BEGIN_CONTEXT; - Common::String fn; + Common::String fn; CORO_END_CONTEXT(_ctx); @@ -517,7 +512,7 @@ void TonyEngine::PlayProcess(CORO_PARAM, const void *param) { // Wait for the next frame CORO_INVOKE_1(CoroScheduler.sleep, 50); - // Call the engine to handle the next frame + // Call the engine to handle the next frame CORO_INVOKE_1(_vm->_theEngine.DoFrame, _vm->m_bDrawLocation); // Warns that a frame is finished diff --git a/engines/tony/tony.h b/engines/tony/tony.h index bdaffee7c9..f4d9d83674 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -69,7 +69,7 @@ enum { struct TonyGameDescription; -#define MAX_SFX_CHANNELS 32 +#define MAX_SFX_CHANNELS 32 struct VoiceHeader { int offset; @@ -100,7 +100,7 @@ public: uint32 m_hEndOfFrame; Common::File _vdbFP; Common::Array _voices; - FPSOUND _theSound; + FPSOUND _theSound; Globals _globals; Debugger *_debugger; @@ -143,7 +143,9 @@ public: Common::Language getLanguage() const; uint16 getVersion() const; bool getIsDemo() const; - RMGfxEngine *GetEngine() { return &_theEngine; } + RMGfxEngine *GetEngine() { + return &_theEngine; + } void GUIError(const Common::String &msg); virtual bool canLoadGameStateCurrently(); @@ -163,8 +165,12 @@ public: void SwitchFullscreen(bool bFull); void OptionScreen(void); - void ShowLocation(void) { m_bDrawLocation = true; } - void HideLocation(void) { m_bDrawLocation = false; } + void ShowLocation(void) { + m_bDrawLocation = true; + } + void HideLocation(void) { + m_bDrawLocation = false; + } // Reads the time uint32 GetTime(void); @@ -186,7 +192,7 @@ public: void PreloadSFX(int nSfx, const char *fn); void UnloadAllSFX(void); - + void PreloadUtilSFX(int nSfx, const char *fn); void UnloadAllUtilSFX(void); @@ -204,9 +210,13 @@ public: // Get a thumbnail void GrabThumbnail(void); - uint16 *GetThumbnail(void) { return m_curThumbnail; } + uint16 *GetThumbnail(void) { + return m_curThumbnail; + } - void Quit(void) { m_bQuitNow = true; } + void Quit(void) { + m_bQuitNow = true; + } void OpenInitLoadMenu(CORO_PARAM); void OpenInitOptions(CORO_PARAM); diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index 593a05d863..71f95f8133 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -79,7 +79,7 @@ void RMTony::WaitEndOfAction(CORO_PARAM, const void *param) { RMGfxSourceBuffer *RMTony::NewItemSpriteBuffer(int dimx, int dimy, bool bPreRLE) { RMGfxSourceBuffer8RLE *spr; - + assert(m_cm == CM_256); spr = new RMGfxSourceBuffer8RLEByteAA; spr->SetAlphaBlendColor(1); @@ -109,7 +109,7 @@ void RMTony::Init(void) { // Reads his details from the stream ReadFromStream(ds, true); - + // Closes the buffer ds.Close(); @@ -130,15 +130,15 @@ void RMTony::Close(void) { void RMTony::DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int curLoc) { CORO_BEGIN_CONTEXT; - int time; + int time; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); if (!m_nInList && m_bShow) bigBuf->AddPrim(new RMGfxPrimitive(this)); - - SetSpeed(GLOBALS.nCfgTonySpeed); + + SetSpeed(GLOBALS.nCfgTonySpeed); // Runs the normal character movement _ctx->time = _vm->GetTime(); @@ -152,7 +152,7 @@ void RMTony::DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int curLoc) { // Check if we are at the end of a path if (EndOfPath() && m_bActionPending) { // Must perform the action on which we clicked - m_bActionPending = false; + m_bActionPending = false; } if (m_bIsTalking || m_bIsStaticTalk) @@ -192,9 +192,9 @@ void RMTony::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { // Offest direction from scrolling prim->Dst().SetEmpty(); prim->Dst().Offset(-m_curScroll); - prim->Dst().Offset(m_pos); + prim->Dst().Offset(m_pos); prim->Dst().Offset(-44, -134); - prim->Dst() += m_nBodyOffset; + prim->Dst() += m_nBodyOffset; CORO_INVOKE_2(m_body.Draw, bigBuf, prim); } @@ -212,7 +212,7 @@ void RMTony::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { void RMTony::MoveAndDoAction(CORO_PARAM, RMPoint dst, RMItem *item, int nAction, int nActionParm) { CORO_BEGIN_CONTEXT; - bool result; + bool result; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -240,46 +240,46 @@ void RMTony::MoveAndDoAction(CORO_PARAM, RMPoint dst, RMItem *item, int nAction, void RMTony::ExecuteAction(int nAction, int nActionItem, int nParm) { uint32 pid; - + if (nAction == TA_COMBINE) { pid = mpalQueryDoAction(TA_COMBINE, nParm, nActionItem); - + // If you failed the combine, we have RECEIVECOMBINE as a fallback if (pid == CORO_INVALID_PID_VALUE) { - pid = mpalQueryDoAction(TA_RECEIVECOMBINE, nActionItem, nParm); - + pid = mpalQueryDoAction(TA_RECEIVECOMBINE, nActionItem, nParm); + // If you failed with that, go with the generic // @@@ CombineGive! if (pid == CORO_INVALID_PID_VALUE) { pid = mpalQueryDoAction(TA_COMBINE, nParm, 0); - - if (pid == CORO_INVALID_PID_VALUE){ + + if (pid == CORO_INVALID_PID_VALUE) { pid = mpalQueryDoAction(TA_RECEIVECOMBINE, nActionItem, 0); } } } } else { // Perform the action - pid = mpalQueryDoAction(nAction, nActionItem, 0); + pid = mpalQueryDoAction(nAction, nActionItem, 0); } - + if (pid != CORO_INVALID_PID_VALUE) { m_bAction = true; CoroScheduler.createProcess(WaitEndOfAction, &pid, sizeof(uint32)); hActionThread = pid; } else if (nAction != TA_GOTO) { if (nAction == TA_TALK) { - pid = mpalQueryDoAction(6, 1, 0); + pid = mpalQueryDoAction(6, 1, 0); m_bAction = true; CoroScheduler.createProcess(WaitEndOfAction, &pid, sizeof(uint32)); - hActionThread = pid; + hActionThread = pid; } else if (nAction == TA_PALESATI) { pid = mpalQueryDoAction(7, 1, 0); - m_bAction = true; + m_bAction = true; CoroScheduler.createProcess(WaitEndOfAction, &pid, sizeof(uint32)); - hActionThread = pid; + hActionThread = pid; } else { - pid = mpalQueryDoAction(5, 1, 0); + pid = mpalQueryDoAction(5, 1, 0); m_bAction = true; CoroScheduler.createProcess(WaitEndOfAction, &pid, sizeof(uint32)); hActionThread = pid; @@ -306,7 +306,7 @@ void RMTony::StopNoAction(CORO_PARAM) { void RMTony::Stop(CORO_PARAM) { CORO_BEGIN_CONTEXT; - uint32 pid; + uint32 pid; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -318,7 +318,7 @@ void RMTony::Stop(CORO_PARAM) { if (_ctx->pid == CORO_INVALID_PID_VALUE) CORO_INVOKE_0(RMCharacter::Stop); else { - bNeedToStop = false; // If we make the OnWhichDirection, we don't need at least after the Stop(). + bNeedToStop = false; // If we make the OnWhichDirection, we don't need at least after the Stop(). bMoving = false; CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->pid, CORO_INFINITE); // @@@ Put an assert after 10 seconds } @@ -332,7 +332,7 @@ void RMTony::Stop(CORO_PARAM) { m_bActionPending = false; ExecuteAction(m_Action, m_ActionItem->MpalCode(), m_ActionParm); - + m_ActionItem = NULL; CORO_END_CODE; @@ -344,7 +344,7 @@ int RMTony::GetCurPattern(void) { if (!m_bPastorella) return nPatt; - + switch (nPatt) { case PAT_PAST_STANDUP: return PAT_STANDUP; @@ -371,28 +371,28 @@ void RMTony::SetPattern(int nPatt, bool bPlayP0) { if (m_bPastorella) { switch (nPatt) { case PAT_STANDUP: - nPatt=PAT_PAST_STANDUP; + nPatt = PAT_PAST_STANDUP; break; case PAT_STANDDOWN: - nPatt=PAT_PAST_STANDDOWN; + nPatt = PAT_PAST_STANDDOWN; break; case PAT_STANDLEFT: - nPatt=PAT_PAST_STANDLEFT; + nPatt = PAT_PAST_STANDLEFT; break; case PAT_STANDRIGHT: - nPatt=PAT_PAST_STANDRIGHT; + nPatt = PAT_PAST_STANDRIGHT; break; case PAT_WALKUP: - nPatt=PAT_PAST_WALKUP; + nPatt = PAT_PAST_WALKUP; break; case PAT_WALKDOWN: - nPatt=PAT_PAST_WALKDOWN; + nPatt = PAT_PAST_WALKDOWN; break; case PAT_WALKLEFT: - nPatt=PAT_PAST_WALKLEFT; + nPatt = PAT_PAST_WALKLEFT; break; case PAT_WALKRIGHT: - nPatt=PAT_PAST_WALKRIGHT; + nPatt = PAT_PAST_WALKRIGHT; break; } } @@ -405,7 +405,7 @@ void RMTony::Take(int nWhere, int nPart) { if (nPart == 0) { switch (GetCurPattern()) { case PAT_STANDDOWN: - assert(0); // Not while you're doing a StandDown + assert(0); // Not while you're doing a StandDown break; case PAT_STANDUP: @@ -552,7 +552,7 @@ void RMTony::Put(int nWhere, int nPart) { bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &bodyStartPat, - int &headLoopPat, int &bodyLoopPat) { + int &headLoopPat, int &bodyLoopPat) { assert(!m_bIsTalking); m_bIsTalking = true; @@ -573,7 +573,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case PAT_STANDLEFT: m_TalkDirection = LEFT; break; - + case PAT_TAKERIGHT_UP2: case PAT_TAKERIGHT_MID2: case PAT_TAKERIGHT_DOWN2: @@ -605,7 +605,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case DOWN: SetPattern(PAT_PAST_TALKDOWN); break; - + case LEFT: SetPattern(PAT_PAST_TALKLEFT); break; @@ -622,7 +622,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body bodyLoopPat = 0; switch (nTalkType) { - case TALK_NORMAL: + case TALK_NORMAL: m_bCorpoDavanti = false; headStartPat = 0; bodyStartPat = 0; @@ -654,7 +654,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body } break; - case TALK_FIANCHI: + case TALK_FIANCHI: m_bCorpoDavanti = false; switch (m_TalkDirection) { case UP: @@ -760,7 +760,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body m_nBodyOffset.Set(5, 40); headLoopPat = PAT_TALK_RIGHT; bodyLoopPat = BPAT_SIINDICARIGHT; - break; + break; } break; @@ -966,7 +966,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body } break; - // The beard is the only case in which the head is animated separately while the body is the standard + // The beard is the only case in which the head is animated separately while the body is the standard case TALK_CONBARBASTATIC: switch (m_TalkDirection) { case LEFT: @@ -984,7 +984,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; } break; - + case TALK_SCHIFATO: switch (m_TalkDirection) { case LEFT: @@ -1112,8 +1112,8 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body void RMTony::StartTalk(CORO_PARAM, TALKTYPE nTalkType) { CORO_BEGIN_CONTEXT; - int headStartPat, bodyStartPat; - int headLoopPat, bodyLoopPat; + int headStartPat, bodyStartPat; + int headLoopPat, bodyLoopPat; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -1122,7 +1122,7 @@ void RMTony::StartTalk(CORO_PARAM, TALKTYPE nTalkType) { _ctx->headLoopPat = _ctx->bodyLoopPat = 0; if (!StartTalkCalculate(nTalkType, _ctx->headStartPat, _ctx->bodyStartPat, - _ctx->headLoopPat, _ctx->bodyLoopPat)) + _ctx->headLoopPat, _ctx->bodyLoopPat)) return; // Perform the set pattern @@ -1131,13 +1131,13 @@ void RMTony::StartTalk(CORO_PARAM, TALKTYPE nTalkType) { SetPattern(_ctx->headStartPat); m_body.SetPattern(_ctx->bodyStartPat); MainUnfreeze(); - + if (_ctx->bodyStartPat != 0) CORO_INVOKE_0(m_body.WaitForEndPattern); if (_ctx->headStartPat != 0) CORO_INVOKE_0(WaitForEndPattern); } - + MainFreeze(); SetPattern(_ctx->headLoopPat); if (_ctx->bodyLoopPat) @@ -1151,7 +1151,7 @@ void RMTony::StartTalk(CORO_PARAM, TALKTYPE nTalkType) { bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPat, int &finalPat, bool &bStatic) { bodyEndPat = 0; headEndPat = 0; - + switch (m_TalkDirection) { case UP: finalPat = PAT_STANDUP; @@ -1178,7 +1178,7 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa MainFreeze(); SetPattern(finalPat); MainUnfreeze(); - m_bIsTalking = false; + m_bIsTalking = false; return false; } @@ -1203,7 +1203,7 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa bodyEndPat = BPAT_FIANCHILEFT_END; break; - case RIGHT: + case RIGHT: bodyEndPat = BPAT_FIANCHIRIGHT_END; break; } @@ -1219,12 +1219,12 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa headEndPat = PAT_RIDELEFT_END; else if (m_TalkDirection == RIGHT) headEndPat = PAT_RIDERIGHT_END; - + bodyEndPat = 0; break; case TALK_SCHIFATO: - switch (m_TalkDirection) { + switch (m_TalkDirection) { case UP: case LEFT: headEndPat = PAT_SCHIFATOLEFT_END; @@ -1235,12 +1235,12 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa headEndPat = PAT_SCHIFATORIGHT_END; break; } - + bodyEndPat = 0; break; case TALK_NAAH: - switch (m_TalkDirection) { + switch (m_TalkDirection) { case UP: case LEFT: headEndPat = PAT_NAAHLEFT_END; @@ -1251,7 +1251,7 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa headEndPat = PAT_NAAHRIGHT_END; break; } - + bodyEndPat = 0; break; @@ -1259,7 +1259,7 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa break; case TALK_SPAVENTATO: - switch (m_TalkDirection) { + switch (m_TalkDirection) { case UP: bodyEndPat = BPAT_SPAVENTOUP_END; break; @@ -1282,7 +1282,7 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa break; case TALK_SPAVENTATO2: - switch (m_TalkDirection) { + switch (m_TalkDirection) { case UP: bodyEndPat = 0; break; @@ -1305,7 +1305,7 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa break; case TALK_CONCONIGLIO: - switch (m_TalkDirection) { + switch (m_TalkDirection) { case UP: case LEFT: finalPat = PAT_STANDLEFT; @@ -1321,7 +1321,7 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa break; case TALK_CONRICETTA: - switch (m_TalkDirection) { + switch (m_TalkDirection) { case UP: case LEFT: finalPat = PAT_STANDLEFT; @@ -1337,7 +1337,7 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa break; case TALK_CONCARTE: - switch (m_TalkDirection) { + switch (m_TalkDirection) { case UP: case LEFT: finalPat = PAT_STANDLEFT; @@ -1353,7 +1353,7 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa break; case TALK_CONPUPAZZO: - switch (m_TalkDirection) { + switch (m_TalkDirection) { case UP: case LEFT: finalPat = PAT_STANDLEFT; @@ -1396,7 +1396,7 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa break; case TALK_SPAVENTATOSTATIC: - switch (m_TalkDirection) { + switch (m_TalkDirection) { case DOWN: headStandPat = PAT_SPAVENTODOWN_STAND; bodyEndPat = 0; @@ -1427,9 +1427,9 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa void RMTony::EndTalk(CORO_PARAM) { CORO_BEGIN_CONTEXT; - int headStandPat, headEndPat; - int bodyEndPat, finalPat; - bool bStatic; + int headStandPat, headEndPat; + int bodyEndPat, finalPat; + bool bStatic; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -1465,7 +1465,7 @@ void RMTony::EndTalk(CORO_PARAM) { CORO_INVOKE_0(m_body.WaitForEndPattern); } - m_bIsTalking = false; + m_bIsTalking = false; return; } @@ -1480,7 +1480,7 @@ void RMTony::EndTalk(CORO_PARAM) { MainFreeze(); m_body.SetPattern(_ctx->bodyEndPat); MainUnfreeze(); - + CORO_INVOKE_0(WaitForEndPattern); CORO_INVOKE_0(m_body.WaitForEndPattern); } else if (_ctx->bodyEndPat != 0) { @@ -1493,7 +1493,7 @@ void RMTony::EndTalk(CORO_PARAM) { MainFreeze(); m_body.SetPattern(_ctx->bodyEndPat); MainUnfreeze(); - + CORO_INVOKE_0(m_body.WaitForEndPattern); } else if (_ctx->headEndPat != 0) { CORO_INVOKE_0(m_body.WaitForEndPattern); @@ -1514,13 +1514,13 @@ void RMTony::EndTalk(CORO_PARAM) { MainUnfreeze(); } - m_bIsTalking = false; + m_bIsTalking = false; CORO_END_CODE; } void RMTony::StartStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat, - int &bodyStartPat, int &bodyLoopPat) { + int &bodyStartPat, int &bodyLoopPat) { int nPat = GetCurPattern(); headLoopPat = -1; @@ -1539,7 +1539,7 @@ void RMTony::StartStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat m_TalkDirection = LEFT; headPat = PAT_TESTA_LEFT; break; - + case PAT_TAKERIGHT_UP2: case PAT_TAKERIGHT_MID2: case PAT_TAKERIGHT_DOWN2: @@ -1728,8 +1728,8 @@ void RMTony::StartStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat void RMTony::StartStatic(CORO_PARAM, TALKTYPE nTalk) { CORO_BEGIN_CONTEXT; - int headPat, headLoopPat; - int bodyStartPat, bodyLoopPat; + int headPat, headLoopPat; + int bodyStartPat, bodyLoopPat; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -1745,7 +1745,7 @@ void RMTony::StartStatic(CORO_PARAM, TALKTYPE nTalk) { m_body.SetPattern(_ctx->bodyStartPat); MainUnfreeze(); - CORO_INVOKE_0(m_body.WaitForEndPattern); + CORO_INVOKE_0(m_body.WaitForEndPattern); CORO_INVOKE_0(WaitForEndPattern); MainFreeze(); @@ -1774,7 +1774,8 @@ void RMTony::EndStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, switch (nTalk) { case TALK_CONPUPAZZOSTATIC: switch (m_TalkDirection) { - case UP: case LEFT: + case UP: + case LEFT: bodyEndPat = BPAT_CONPUPAZZOLEFT_END; break; @@ -1812,7 +1813,7 @@ void RMTony::EndStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, break; } break; - + case TALK_CONCARTESTATIC: switch (m_TalkDirection) { case UP: @@ -1895,9 +1896,9 @@ void RMTony::EndStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, void RMTony::EndStatic(CORO_PARAM, TALKTYPE nTalk) { CORO_BEGIN_CONTEXT; - int bodyEndPat; - int finalPat; - int headEndPat; + int bodyEndPat; + int finalPat; + int headEndPat; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -1913,21 +1914,21 @@ void RMTony::EndStatic(CORO_PARAM, TALKTYPE nTalk) { SetPattern(_ctx->headEndPat); MainUnfreeze(); - CORO_INVOKE_0(WaitForEndPattern); + CORO_INVOKE_0(WaitForEndPattern); } else { // Play please MainFreeze(); m_body.SetPattern(_ctx->bodyEndPat); MainUnfreeze(); - CORO_INVOKE_0(m_body.WaitForEndPattern); + CORO_INVOKE_0(m_body.WaitForEndPattern); } MainFreeze(); SetPattern(_ctx->finalPat); m_body.SetPattern(0); MainUnfreeze(); - + m_bIsStaticTalk = false; CORO_END_CODE; diff --git a/engines/tony/tonychar.h b/engines/tony/tonychar.h index a7109256f5..a1c7fc152b 100644 --- a/engines/tony/tonychar.h +++ b/engines/tony/tonychar.h @@ -112,7 +112,7 @@ protected: // Watch thread which waits for the end of an action static void WaitEndOfAction(CORO_PARAM, const void *param); -public: +public: enum PATTERNS { PAT_TAKEUP_UP1 = 9, PAT_TAKEUP_UP2, @@ -120,7 +120,7 @@ public: PAT_TAKEUP_MID2, PAT_TAKEUP_DOWN1, PAT_TAKEUP_DOWN2, - + PAT_TAKELEFT_UP1, PAT_TAKELEFT_UP2, PAT_TAKELEFT_MID1, @@ -242,7 +242,7 @@ public: PAT_PUTUP_MID2, PAT_PUTUP_DOWN1, PAT_PUTUP_DOWN2, - + PAT_CONSEGRETARIA }; @@ -363,7 +363,7 @@ public: // Initialise Tony void Init(void); - + // Free all memory void Close(void); @@ -391,21 +391,29 @@ public: int GetCurPattern(); // Waits until the end of a pattern - void WaitForEndPattern(CORO_PARAM, uint32 hCustomSkip = CORO_INVALID_PID_VALUE) { + void WaitForEndPattern(CORO_PARAM, uint32 hCustomSkip = CORO_INVALID_PID_VALUE) { RMCharacter::WaitForEndPattern(coroParam, hCustomSkip); } // Check if currently in an action - bool InAction() { return (m_bActionPending && m_Action != 0) | m_bAction; } + bool InAction() { + return (m_bActionPending && m_Action != 0) | m_bAction; + } // Check if there needs to be an update for scrolling movement - bool MustUpdateScrolling() { return ((!InAction()) || (IsMoving())); } + bool MustUpdateScrolling() { + return ((!InAction()) || (IsMoving())); + } // Returns Tony's position - RMPoint Position() { return m_pos; } + RMPoint Position() { + return m_pos; + } // Set the scrolling position - void SetScrollPosition(const RMPoint &pt) { RMCharacter::SetScrollPosition(pt); } + void SetScrollPosition(const RMPoint &pt) { + RMCharacter::SetScrollPosition(pt); + } // Set the take animation void Take(int nWhere, int nPart); @@ -413,26 +421,32 @@ public: // Start or End Talk bool StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &bodyStartPat, - int &headLoopPat, int &bodyLoopPat); + int &headLoopPat, int &bodyLoopPat); void StartTalk(CORO_PARAM, TALKTYPE nTalkType); bool EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPat, int &finalPat, bool &bStatic); void EndTalk(CORO_PARAM); // Start or End Static void StartStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat, - int &bodyStartPat, int &bodyLoopPat); + int &bodyStartPat, int &bodyLoopPat); void StartStatic(CORO_PARAM, TALKTYPE nTalkType); void EndStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, int &headEndPat); void EndStatic(CORO_PARAM, TALKTYPE nTalkType); // Tony disguises himself! - void SetPastorella(bool bIsPast) { m_bPastorella=bIsPast; } - int GetPastorella(void) { return m_bPastorella; } + void SetPastorella(bool bIsPast) { + m_bPastorella = bIsPast; + } + int GetPastorella(void) { + return m_bPastorella; + } // Perform an action void ExecuteAction(int nAction, int nActionItem, int nParm); - void PlaySfx(int nSfx) { RMItem::PlaySfx(nSfx); } + void PlaySfx(int nSfx) { + RMItem::PlaySfx(nSfx); + } }; } // End of namespace Tony diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index 9aaffefceb..92b896b180 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -67,7 +67,7 @@ RMString::RMString(const RMString &str) { /** * Constructor from a char * */ -RMString::RMString(const char* str) { +RMString::RMString(const char *str) { // Use the overloaded '=' when copying m_string = NULL; m_length = 0; @@ -88,16 +88,16 @@ RMString::RMString(const int ch) { /** * Returns the length of the string - * @returns Length + * @returns Length */ int RMString::Length() const { - return m_length; + return m_length; } /** * Gets the character at the given index - * @param nIndex Position of the character to return - * @returns Character + * @param nIndex Position of the character to return + * @returns Character */ char RMString::GetAt(int nIndex) { assert(nIndex < m_length); @@ -106,8 +106,8 @@ char RMString::GetAt(int nIndex) { /** * Sets the character at the given index - * @param nIndex Position of the character to change - * @param c Character + * @param nIndex Position of the character to change + * @param c Character */ void RMString::SetAt(int nIndex, char c) { assert(nIndex < m_length); @@ -116,8 +116,8 @@ void RMString::SetAt(int nIndex, char c) { /** * Overloaded square brackets operator for accessing characters within the string - * @param nIndex Position of the charactre to reference - * @params Reference to the character + * @param nIndex Position of the charactre to reference + * @params Reference to the character */ char &RMString::operator[](int nIndex) { assert(nIndex < m_length); @@ -126,8 +126,8 @@ char &RMString::operator[](int nIndex) { /** * Copies a string - * @param str String to copy - * @returns Refrence to our string + * @param str String to copy + * @returns Refrence to our string */ const RMString &RMString::operator=(const RMString &str) { // Set the new length @@ -147,16 +147,16 @@ const RMString &RMString::operator=(const RMString &str) { // Copy the string Common::copy(str.m_string, str.m_string + m_length + 1, m_string); } - + return *this; } /** * Copies a char * string - * @param str String to copy - * @returns Refrence to our string + * @param str String to copy + * @returns Refrence to our string */ -const RMString& RMString::operator=(const char* str) { +const RMString &RMString::operator=(const char *str) { // If the source is empty, then destroy the current string buffer if (str == NULL) { if (m_realLength > 0) { @@ -180,11 +180,11 @@ const RMString& RMString::operator=(const char* str) { /** * Forms a string from a passed character - * @param ch Character to copy - * @returns Refrence to our string + * @param ch Character to copy + * @returns Refrence to our string */ -const RMString& RMString::operator=(const int ch) { - if (ch=='\0') { +const RMString &RMString::operator=(const int ch) { + if (ch == '\0') { // Destroy the current string if (m_realLength > 0) { delete [] m_string; @@ -203,17 +203,17 @@ const RMString& RMString::operator=(const int ch) { return *this; } -/** +/** * Concatenate a string into the current one - * @param str String to concatenate - * @param size Length of the string + * @param str String to concatenate + * @param size Length of the string */ void RMString::Connect(const char *str, int size) { int nlen; if (size > 0) { // Calculate the new lenght - nlen = m_length+size; + nlen = m_length + size; // Resize Resize(nlen + 1, true); @@ -228,18 +228,18 @@ void RMString::Connect(const char *str, int size) { /** * Concatenate a string - * @param str String to concatenate - * @returns Refrence to our string + * @param str String to concatenate + * @returns Refrence to our string */ const RMString &RMString::operator+=(RMString &str) { - Connect(str,str.Length()); + Connect(str, str.Length()); return *this; } /** * Concatenate a string - * @param str String to concatenate - * @returns Refrence to our string + * @param str String to concatenate + * @returns Refrence to our string */ const RMString &RMString::operator+=(const char *str) { Connect(str, strlen(str)); @@ -248,8 +248,8 @@ const RMString &RMString::operator+=(const char *str) { /** * Concatenate a character - * @param ch Character to concatenate - * @returns Refrence to our string + * @param ch Character to concatenate + * @returns Refrence to our string */ const RMString &RMString::operator+=(const int ch) { char str[2]; @@ -264,17 +264,17 @@ const RMString &RMString::operator+=(const int ch) { /** * Casts a string as char * - * @returns char * reference to string + * @returns char * reference to string */ -RMString::operator char*() const { +RMString::operator char *() const { return m_string; } /** * Resize a string as necessary - * @param size New size necessary (in bytes) - * @param bMaintain If true we must keep the original string, - if false we can destroy. + * @param size New size necessary (in bytes) + * @param bMaintain If true we must keep the original string, + if false we can destroy. */ void RMString::Resize(int size, bool bMantain) { if (m_realLength == 0) { @@ -282,7 +282,7 @@ void RMString::Resize(int size, bool bMantain) { m_realLength = size; } else if (size > m_realLength) { if (bMantain) { - char* app; + char *app; app = new char[size]; Common::copy(m_string, m_string + m_length + 1, app); @@ -346,13 +346,13 @@ RMString operator+(RMString &str, const char *s) { RMString operator+(const char *s, RMString &str) { RMString ret(s); - return (ret+=str); + return (ret += str); } /** * Extracts a string from a data stream - * @param df data stream - * @param var String + * @param df data stream + * @param var String */ RMDataStream &operator>>(RMDataStream &df, RMString &var) { uint8 len; @@ -360,14 +360,14 @@ RMDataStream &operator>>(RMDataStream &df, RMString &var) { df >> len; var.Resize(len + 1); - var.m_length=len+1; - + var.m_length = len + 1; + for (i = 0; i < len; i++) df >> var[i]; - var[i] = '\0'; + var[i] = '\0'; var.m_length = len; - + return df; } @@ -422,7 +422,7 @@ bool RMFileStreamSlow::OpenFile(const char *lpFN) { } -RMDataStream& RMFileStreamSlow::operator+=(int nBytes) { +RMDataStream &RMFileStreamSlow::operator+=(int nBytes) { Seek(nBytes); return *this; } @@ -440,7 +440,7 @@ int RMFileStreamSlow::Seek(int nBytes, RMDSPos where) { switch (where) { case START: return _stream->seek(nBytes); - + case END: return _stream->seek(nBytes, SEEK_END); @@ -467,7 +467,7 @@ RMFileStreamSlow &operator>>(RMFileStreamSlow &df, char &var) { } RMFileStreamSlow &operator>>(RMFileStreamSlow &df, byte &var) { - df.Read(&var,1); + df.Read(&var, 1); return df; } @@ -487,7 +487,7 @@ RMFileStreamSlow &operator>>(RMFileStreamSlow &df, int16 &var) { RMFileStreamSlow &operator>>(RMFileStreamSlow &df, int &var) { int v; - df.Read(&v,4); + df.Read(&v, 4); var = FROM_LE_32(v); return df; } @@ -530,10 +530,10 @@ void RMDataStream::Close(void) { /** * Takes the address of the buffer from which will be read the data. - * @param lpBuf Data buffer - * @param size Size of the buffer - * @remarks If the length of the buffer is not known, and cannot be - * specified, then EOF() and Seek() to end won't work. + * @param lpBuf Data buffer + * @param size Size of the buffer + * @remarks If the length of the buffer is not known, and cannot be + * specified, then EOF() and Seek() to end won't work. */ void RMDataStream::OpenBuffer(const byte *lpBuf, int size) { m_length = size; @@ -544,7 +544,7 @@ void RMDataStream::OpenBuffer(const byte *lpBuf, int size) { /** * Returns the length of the stream - * @returns Stream length + * @returns Stream length */ int RMDataStream::Length() { return m_length; @@ -552,7 +552,7 @@ int RMDataStream::Length() { /** * Determines if the end of the stream has been reached - * @returns true if end of stream reached, false if not + * @returns true if end of stream reached, false if not */ bool RMDataStream::IsEOF() { return (m_pos >= m_length); @@ -560,9 +560,9 @@ bool RMDataStream::IsEOF() { /** * Extracts data from the stream - * @param df Stream - * @param var Variable of a supported type - * @returns Value read from the stream + * @param df Stream + * @param var Variable of a supported type + * @returns Value read from the stream */ RMDataStream &operator>>(RMDataStream &df, char &var) { df.Read(&var, 1); @@ -571,9 +571,9 @@ RMDataStream &operator>>(RMDataStream &df, char &var) { /** * Extracts data from the stream - * @param df Stream - * @param var Variable of a supported type - * @returns Value read from the stream + * @param df Stream + * @param var Variable of a supported type + * @returns Value read from the stream */ RMDataStream &operator>>(RMDataStream &df, uint8 &var) { df.Read(&var, 1); @@ -582,9 +582,9 @@ RMDataStream &operator>>(RMDataStream &df, uint8 &var) { /** * Extracts data from the stream - * @param df Stream - * @param var Variable of a supported type - * @returns Value read from the stream + * @param df Stream + * @param var Variable of a supported type + * @returns Value read from the stream */ RMDataStream &operator>>(RMDataStream &df, uint16 &var) { uint16 v; @@ -596,9 +596,9 @@ RMDataStream &operator>>(RMDataStream &df, uint16 &var) { /** * Extracts data from the stream - * @param df Stream - * @param var Variable of a supported type - * @returns Value read from the stream + * @param df Stream + * @param var Variable of a supported type + * @returns Value read from the stream */ RMDataStream &operator>>(RMDataStream &df, int16 &var) { uint16 v; @@ -610,9 +610,9 @@ RMDataStream &operator>>(RMDataStream &df, int16 &var) { /** * Extracts data from the stream - * @param df Stream - * @param var Variable of a supported type - * @returns Value read from the stream + * @param df Stream + * @param var Variable of a supported type + * @returns Value read from the stream */ RMDataStream &operator>>(RMDataStream &df, int &var) { uint32 v; @@ -624,9 +624,9 @@ RMDataStream &operator>>(RMDataStream &df, int &var) { /** * Extracts data from the stream - * @param df Stream - * @param var Variable of a supported type - * @returns Value read from the stream + * @param df Stream + * @param var Variable of a supported type + * @returns Value read from the stream */ RMDataStream &operator>>(RMDataStream &df, uint32 &var) { uint32 v; @@ -638,9 +638,9 @@ RMDataStream &operator>>(RMDataStream &df, uint32 &var) { /** * Reads a series of data from the stream in a buffer - * @param lpBuf Data buffer - * @param size Size of the buffer - * @returns true if we have reached the end, false if not + * @param lpBuf Data buffer + * @param size Size of the buffer + * @returns true if we have reached the end, false if not */ bool RMDataStream::Read(void *lpBuf, int size) { byte *dest = (byte *)lpBuf; @@ -659,19 +659,19 @@ bool RMDataStream::Read(void *lpBuf, int size) { /** * Skips a number of bytes in the stream - * @param nBytres Number of bytes to skip - * @returns The stream + * @param nBytres Number of bytes to skip + * @returns The stream */ RMDataStream &RMDataStream::operator+=(int nBytes) { - m_pos+=nBytes; + m_pos += nBytes; return *this; } /** * Seeks to a position within the stream - * @param nBytes Number of bytes from specified origin - * @param origin Origin to do offset from - * @returns The absolute current position in bytes + * @param nBytes Number of bytes from specified origin + * @param origin Origin to do offset from + * @returns The absolute current position in bytes */ int RMDataStream::Seek(int nBytes, RMDSPos origin) { switch (origin) { @@ -689,13 +689,13 @@ int RMDataStream::Seek(int nBytes, RMDSPos origin) { break; } - m_pos+=nBytes; + m_pos += nBytes; return m_pos; } /** * Returns the current position of the stream - * @returns The current position + * @returns The current position */ int RMDataStream::Pos() { return m_pos; @@ -703,7 +703,7 @@ int RMDataStream::Pos() { /** * Check if an error occurred during reading the stream - * @returns true if there was an error, false otherwise + * @returns true if there was an error, false otherwise */ bool RMDataStream::IsError() { return m_bError; @@ -711,7 +711,7 @@ bool RMDataStream::IsError() { /** * Sets an error code for the stream - * @param code Error code + * @param code Error code */ void RMDataStream::SetError(int code) { m_bError = true; @@ -720,7 +720,7 @@ void RMDataStream::SetError(int code) { /** * Returns the error code for the stream - * @returns Error code + * @returns Error code */ int RMDataStream::GetError() { return m_ecode; @@ -903,11 +903,11 @@ RMPoint &RMRect::TopLeft() { RMPoint &RMRect::BottomRight() { // FIXME: This seems very bad - return *((RMPoint*)this + 1); + return *((RMPoint *)this + 1); } RMPoint RMRect::Center() { - return RMPoint((x2 - x1) / 2,(y2 - y1) / 2); + return RMPoint((x2 - x1) / 2, (y2 - y1) / 2); } int RMRect::Width() const { @@ -926,7 +926,7 @@ bool RMRect::IsEmpty() const { return (x1 == 0 && y1 == 0 && x2 == 0 && y2 == 0); } -const RMRect& RMRect::operator=(const RMRect &rc) { +const RMRect &RMRect::operator=(const RMRect &rc) { CopyRect(rc); return *this; } @@ -960,29 +960,29 @@ RMRect operator+(const RMRect &rc, RMPoint p) { return (r += p); } -RMRect operator-(const RMRect& rc, RMPoint p) { +RMRect operator-(const RMRect &rc, RMPoint p) { RMRect r(rc); return (r -= p); } -RMRect operator+(RMPoint p, const RMRect& rc) { +RMRect operator+(RMPoint p, const RMRect &rc) { RMRect r(rc); return (r += p); } -RMRect operator-(RMPoint p, const RMRect& rc) { +RMRect operator-(RMPoint p, const RMRect &rc) { RMRect r(rc); return (r += p); } -bool RMRect::operator==(const RMRect& rc) { +bool RMRect::operator==(const RMRect &rc) { return ((x1 == rc.x1) && (y1 == rc.y1) && (x2 == rc.x2) && (y2 == rc.y2)); } -bool RMRect::operator!=(const RMRect& rc) { +bool RMRect::operator!=(const RMRect &rc) { return ((x1 != rc.x1) || (y1 != rc.y1) || (x2 != rc.x2) || (y2 != rc.y2)); } @@ -1050,7 +1050,7 @@ HGLOBAL RMResUpdate::QueryResource(uint32 dwRes) { // Found the index break; - if (i==_numUpd) + if (i == _numUpd) // Couldn't find a matching resource, so return NULL return NULL; diff --git a/engines/tony/utils.h b/engines/tony/utils.h index c823421c62..2eb6c5c2da 100644 --- a/engines/tony/utils.h +++ b/engines/tony/utils.h @@ -45,58 +45,58 @@ using namespace ::Tony::MPAL; class RMDataStream { protected: const byte *m_buf; - int m_length; - int m_pos; - bool m_bError; - int m_ecode; + int m_length; + int m_pos; + bool m_bError; + int m_ecode; public: - enum RMDSPos { - CUR, - START, - END - }; + enum RMDSPos { + CUR, + START, + END + }; private: - enum { - SIZENOTKNOWN = 0x7FFFFFFF - }; + enum { + SIZENOTKNOWN = 0x7FFFFFFF + }; public: - // Constructor and destructor - RMDataStream(); - virtual ~RMDataStream(); + // Constructor and destructor + RMDataStream(); + virtual ~RMDataStream(); - // Loading buffer - void OpenBuffer(const byte *buf, int size = SIZENOTKNOWN); + // Loading buffer + void OpenBuffer(const byte *buf, int size = SIZENOTKNOWN); void Close(void); - // Attributei - int Length(); - virtual int Pos(); - - // EOF - virtual bool IsEOF(); + // Attributei + int Length(); + virtual int Pos(); - // Read methods - friend RMDataStream &operator>>(RMDataStream &df, char &var); - friend RMDataStream &operator>>(RMDataStream &df, byte &var); - friend RMDataStream &operator>>(RMDataStream &df, uint16 &var); - friend RMDataStream &operator>>(RMDataStream &df, int16 &var); - friend RMDataStream &operator>>(RMDataStream &df, int &var); - friend RMDataStream &operator>>(RMDataStream &df, uint32 &var); - - // General read - virtual bool Read(void *buf, int size); - - // Skipping & Seeking - virtual RMDataStream &operator+=(int nBytes); - virtual int Seek(int nBytes, RMDSPos origin = CUR); + // EOF + virtual bool IsEOF(); - // Error handling - void SetError(int ecode); - int GetError(); - bool IsError(); + // Read methods + friend RMDataStream &operator>>(RMDataStream &df, char &var); + friend RMDataStream &operator>>(RMDataStream &df, byte &var); + friend RMDataStream &operator>>(RMDataStream &df, uint16 &var); + friend RMDataStream &operator>>(RMDataStream &df, int16 &var); + friend RMDataStream &operator>>(RMDataStream &df, int &var); + friend RMDataStream &operator>>(RMDataStream &df, uint32 &var); + + // General read + virtual bool Read(void *buf, int size); + + // Skipping & Seeking + virtual RMDataStream &operator+=(int nBytes); + virtual int Seek(int nBytes, RMDSPos origin = CUR); + + // Error handling + void SetError(int ecode); + int GetError(); + bool IsError(); }; @@ -131,20 +131,20 @@ public: void Close(void); - RMDataStream& operator+=(int nBytes); - int Seek(int nBytes, RMDSPos where = CUR); + RMDataStream &operator+=(int nBytes); + int Seek(int nBytes, RMDSPos where = CUR); int Pos(); virtual bool IsEOF(); bool Read(void *buf, int size); - friend RMFileStreamSlow& operator>>(RMFileStreamSlow &df, char &var); - friend RMFileStreamSlow& operator>>(RMFileStreamSlow &df, byte &var); - friend RMFileStreamSlow& operator>>(RMFileStreamSlow &df, uint16 &var); - friend RMFileStreamSlow& operator>>(RMFileStreamSlow &df, int16 &var); - friend RMFileStreamSlow& operator>>(RMFileStreamSlow &df, int &var); - friend RMFileStreamSlow& operator>>(RMFileStreamSlow &df, uint32 &var); + friend RMFileStreamSlow &operator>>(RMFileStreamSlow &df, char &var); + friend RMFileStreamSlow &operator>>(RMFileStreamSlow &df, byte &var); + friend RMFileStreamSlow &operator>>(RMFileStreamSlow &df, uint16 &var); + friend RMFileStreamSlow &operator>>(RMFileStreamSlow &df, int16 &var); + friend RMFileStreamSlow &operator>>(RMFileStreamSlow &df, int &var); + friend RMFileStreamSlow &operator>>(RMFileStreamSlow &df, uint32 &var); }; /** @@ -154,57 +154,57 @@ class RMString { private: char *m_string; int m_length; - int m_realLength; + int m_realLength; public: - RMString(); - ~RMString(); + RMString(); + ~RMString(); - // Assignment constructors - RMString(const RMString &str); - RMString(const char *str); - RMString(const int ch); + // Assignment constructors + RMString(const RMString &str); + RMString(const char *str); + RMString(const int ch); - // General methods - int Length() const; - void Compact(); + // General methods + int Length() const; + void Compact(); - // Access characters within string - char GetAt(int nIndex); - void SetAt(int nIndex, char c); - char& operator[](int nIndex); + // Access characters within string + char GetAt(int nIndex); + void SetAt(int nIndex, char c); + char &operator[](int nIndex); - // String cast - operator char*() const; + // String cast + operator char *() const; - // String assignments - const RMString &operator=(const RMString &str); - const RMString &operator=(const char *str); - const RMString &operator=(const int ch); + // String assignments + const RMString &operator=(const RMString &str); + const RMString &operator=(const char *str); + const RMString &operator=(const int ch); - // String concatenation - const RMString &operator+=(RMString &str); - const RMString &operator+=(const char *str); - const RMString &operator+=(const int ch); + // String concatenation + const RMString &operator+=(RMString &str); + const RMString &operator+=(const char *str); + const RMString &operator+=(const int ch); - // Concatentation of string or character - friend RMString operator+(const RMString &str1, const RMString &str2); + // Concatentation of string or character + friend RMString operator+(const RMString &str1, const RMString &str2); - friend RMString operator+(RMString& str, const int ch); - friend RMString operator+(const int ch, RMString &str); + friend RMString operator+(RMString &str, const int ch); + friend RMString operator+(const int ch, RMString &str); - friend RMString operator+(RMString &str, const char *s); - friend RMString operator+(const char *s, RMString &str); + friend RMString operator+(RMString &str, const char *s); + friend RMString operator+(const char *s, RMString &str); - // Extraction from data streams - friend RMDataStream& operator>>(RMDataStream& df, RMString &var); + // Extraction from data streams + friend RMDataStream &operator>>(RMDataStream &df, RMString &var); // String formatting void Format(const char *str, ...); private: - void Resize(int size, bool bMantain = false); - void Connect(const char* str, int size); + void Resize(int size, bool bMantain = false); + void Connect(const char *str, int size); }; /** @@ -215,89 +215,94 @@ public: int x, y; public: - // Constructor - RMPoint(); - RMPoint(const RMPoint &p); - RMPoint(int x1, int y1); + // Constructor + RMPoint(); + RMPoint(const RMPoint &p); + RMPoint(int x1, int y1); - // Copy - RMPoint& operator=(RMPoint p); + // Copy + RMPoint &operator=(RMPoint p); // Set - void Set(int x1, int y1) { x = x1; y = y1; } - - // Offset - void Offset(int xOff, int yOff); - void Offset(const RMPoint &p); - friend RMPoint operator+(RMPoint p1, RMPoint p2); - friend RMPoint operator-(RMPoint p1, RMPoint p2); - RMPoint &operator+=(RMPoint p); - RMPoint &operator-=(RMPoint p); - RMPoint operator-(); - - // Comparison - bool operator==(RMPoint p); - bool operator!=(RMPoint p); - - // Casting a POINT + void Set(int x1, int y1) { + x = x1; + y = y1; + } + + // Offset + void Offset(int xOff, int yOff); + void Offset(const RMPoint &p); + friend RMPoint operator+(RMPoint p1, RMPoint p2); + friend RMPoint operator-(RMPoint p1, RMPoint p2); + RMPoint &operator+=(RMPoint p); + RMPoint &operator-=(RMPoint p); + RMPoint operator-(); + + // Comparison + bool operator==(RMPoint p); + bool operator!=(RMPoint p); + + // Casting a POINT operator Common::Point() const; - // Extraction from data streams - friend RMDataStream& operator>>(RMDataStream &ds, RMPoint &p); + // Extraction from data streams + friend RMDataStream &operator>>(RMDataStream &ds, RMPoint &p); }; class RMRect { public: - int x1,y1; - int x2,y2; + int x1, y1; + int x2, y2; public: - RMRect(); - RMRect(int x1, int y1, int x2, int y2); - RMRect(const RMPoint &p1, const RMPoint &p2); - RMRect(const RMRect &rc); - - // Attributes - RMPoint &TopLeft(); - RMPoint &BottomRight(); - RMPoint Center(); - int Width() const; - int Height() const; - bool IsEmpty() const; + RMRect(); + RMRect(int x1, int y1, int x2, int y2); + RMRect(const RMPoint &p1, const RMPoint &p2); + RMRect(const RMRect &rc); + + // Attributes + RMPoint &TopLeft(); + RMPoint &BottomRight(); + RMPoint Center(); + int Width() const; + int Height() const; + bool IsEmpty() const; int Size() const; - // Set - void SetRect(int x1, int y1, int x2, int y2); - void SetRect(const RMPoint &p1, const RMPoint &p2); - void SetEmpty(void); - - // Copiers - void SetRect(const RMRect &rc); - void CopyRect(const RMRect &rc); - const RMRect &operator=(const RMRect &rc); - - // Offset - void Offset(int xOff, int yOff); - void Offset(const RMPoint &p); - friend RMRect operator+(const RMRect &rc, RMPoint p); - friend RMRect operator-(const RMRect &rc, RMPoint p); - friend RMRect operator+(RMPoint p, const RMRect &rc); - friend RMRect operator-(RMPoint p, const RMRect &rc); - const RMRect &operator+=(RMPoint p); - const RMRect &operator-=(RMPoint p); - - // Comparison - bool operator==(const RMRect &rc); - bool operator!=(const RMRect &rc); - - // Normalise - void NormalizeRect(); + // Set + void SetRect(int x1, int y1, int x2, int y2); + void SetRect(const RMPoint &p1, const RMPoint &p2); + void SetEmpty(void); + + // Copiers + void SetRect(const RMRect &rc); + void CopyRect(const RMRect &rc); + const RMRect &operator=(const RMRect &rc); + + // Offset + void Offset(int xOff, int yOff); + void Offset(const RMPoint &p); + friend RMRect operator+(const RMRect &rc, RMPoint p); + friend RMRect operator-(const RMRect &rc, RMPoint p); + friend RMRect operator+(RMPoint p, const RMRect &rc); + friend RMRect operator-(RMPoint p, const RMRect &rc); + const RMRect &operator+=(RMPoint p); + const RMRect &operator-=(RMPoint p); + + // Comparison + bool operator==(const RMRect &rc); + bool operator!=(const RMRect &rc); + + // Normalise + void NormalizeRect(); // Point in rect - bool PtInRect(const RMPoint &pt) { return (pt.x >= x1 && pt.x <= x2 && pt.y >= y1 && pt.y <= y2); } + bool PtInRect(const RMPoint &pt) { + return (pt.x >= x1 && pt.x <= x2 && pt.y >= y1 && pt.y <= y2); + } - // Extract from data stream - friend RMDataStream &operator>>(RMDataStream& ds, RMRect &rc); + // Extract from data stream + friend RMDataStream &operator>>(RMDataStream &ds, RMRect &rc); }; /** diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index 0f36c72f97..6b61d25ea2 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -39,7 +39,7 @@ namespace Tony { * RMWindow Methods \****************************************************************************/ -RMWindow::RMWindow() { +RMWindow::RMWindow() { } @@ -93,7 +93,7 @@ void RMWindow::Unlock() { */ void RMWindow::WipeEffect(Common::Rect &rcBoundEllipse) { if ((rcBoundEllipse.left == 0) && (rcBoundEllipse.top == 0) && - (rcBoundEllipse.right == RM_SX) && (rcBoundEllipse.bottom == RM_SY)) { + (rcBoundEllipse.right == RM_SX) && (rcBoundEllipse.bottom == RM_SY)) { // Full screen clear wanted, so use shortcut method g_system->fillScreen(0); } else { @@ -136,14 +136,14 @@ void RMWindow::GetNewFrameWipe(byte *lpBuf, Common::Rect &rcBoundEllipse) { if (!rcBoundEllipse.isValidRect()) return; - Common::Point center(rcBoundEllipse.left + rcBoundEllipse.width() / 2, - rcBoundEllipse.top + rcBoundEllipse.height() / 2); + Common::Point center(rcBoundEllipse.left + rcBoundEllipse.width() / 2, + rcBoundEllipse.top + rcBoundEllipse.height() / 2); // The rectangle technically defines the area inside the ellipse, with the corners touching // the ellipse boundary. Since we're currently simulating the ellipse using a plain circle, // we need to calculate a necessary width using the hypotenuse of X/2 & Y/2 int x2y2 = (rcBoundEllipse.width() / 2) * (rcBoundEllipse.width() / 2) + - (rcBoundEllipse.height() / 2) * (rcBoundEllipse.height() / 2); + (rcBoundEllipse.height() / 2) * (rcBoundEllipse.height() / 2); int radius = 0; while ((radius * radius) < x2y2) ++radius; @@ -155,11 +155,11 @@ void RMWindow::GetNewFrameWipe(byte *lpBuf, Common::Rect &rcBoundEllipse) { while (x >= y) { plotSplices(lpBuf, center, x, y); - + error += y; ++y; error += y; - + if (error >= 0) { error -= x; --x; @@ -173,7 +173,7 @@ void RMWindow::GetNewFrameWipe(byte *lpBuf, Common::Rect &rcBoundEllipse) { */ void RMWindow::plotSplices(const byte *lpBuf, const Common::Point ¢er, int x, int y) { plotLines(lpBuf, center, x, y); - if (x != y) + if (x != y) plotLines(lpBuf, center, y, x); } @@ -206,11 +206,11 @@ void RMWindow::plotLines(const byte *lpBuf, const Common::Point ¢er, int x, * RMSnapshot Methods \****************************************************************************/ -byte RMSnapshot::rgb[RM_SX * RM_SY * 3]; +byte RMSnapshot::rgb[RM_SX *RM_SY * 3]; void RMSnapshot::GrabScreenshot(byte *lpBuf, int dezoom, uint16 *lpDestBuf) { uint16 *src = (uint16 *)lpBuf; - + int dimx = RM_SX / dezoom; int dimy = RM_SY / dezoom; @@ -219,13 +219,13 @@ void RMSnapshot::GrabScreenshot(byte *lpBuf, int dezoom, uint16 *lpDestBuf) { uint32 k = 0; int sommar, sommab, sommag; uint16 *cursrc; - + if (lpDestBuf == NULL) src += (RM_SY - 1) * RM_BBX; if (dezoom == 1 && 0) { byte *curOut = rgb; - + for (int y = 0; y < dimy; y++) { for (int x = 0; x < dimx; x++) { cursrc = &src[RM_SKIPX + x]; @@ -242,32 +242,32 @@ void RMSnapshot::GrabScreenshot(byte *lpBuf, int dezoom, uint16 *lpDestBuf) { src -= RM_BBX; else src += RM_BBX; - } + } } else { for (int y = 0; y < dimy; y++) { - for(int x = 0; x < dimx; x++) { + for (int x = 0; x < dimx; x++) { cursrc = &src[RM_SKIPX + x * dezoom]; sommar = sommab = sommag = 0; - + for (v = 0; v < dezoom; v++) { for (u = 0; u < dezoom; u++) { if (lpDestBuf == NULL) curv = -v; else curv = v; - + sommab += cursrc[curv * RM_BBX + u] & 0x1F; sommag += (cursrc[curv * RM_BBX + u] >> 5) & 0x1F; sommar += (cursrc[curv * RM_BBX + u] >> 10) & 0x1F; } } - rgb[k + 0] = (byte) (sommab * 8 / (dezoom * dezoom)); - rgb[k + 1] = (byte) (sommag * 8 / (dezoom * dezoom)); - rgb[k + 2] = (byte) (sommar * 8 / (dezoom * dezoom)); + rgb[k + 0] = (byte)(sommab * 8 / (dezoom * dezoom)); + rgb[k + 1] = (byte)(sommag * 8 / (dezoom * dezoom)); + rgb[k + 2] = (byte)(sommar * 8 / (dezoom * dezoom)); - if (lpDestBuf!=NULL) - lpDestBuf[k / 3] = ((int)rgb[k + 0] >> 3) | (((int)rgb[k + 1] >> 3) << 5) | - (((int)rgb[k + 2] >> 3) << 10); + if (lpDestBuf != NULL) + lpDestBuf[k / 3] = ((int)rgb[k + 0] >> 3) | (((int)rgb[k + 1] >> 3) << 5) | + (((int)rgb[k + 2] >> 3) << 10); k += 3; } diff --git a/engines/tony/window.h b/engines/tony/window.h index 73cc6d2005..0f614fca97 100644 --- a/engines/tony/window.h +++ b/engines/tony/window.h @@ -42,7 +42,7 @@ struct DDSURFACEDESC { class RMSnapshot { private: // Buffer used to convert to RGB - static byte rgb[RM_SX * RM_SY * 3]; + static byte rgb[RM_SX *RM_SY * 3]; public: // Take a screenshot void GrabScreenshot(byte *lpBuf, int dezoom = 1, uint16 *lpDestBuf = NULL); @@ -95,7 +95,9 @@ public: // Request a thumbnail be grabbed during the next frame void GrabThumbnail(uint16 *buf); - int getFps() const { return fps; } + int getFps() const { + return fps; + } }; } // End of namespace Tony -- cgit v1.2.3 From 75a0b0c6296af6600ce1a4e585fb7c5b9a0ea203 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 23 May 2012 00:19:46 +0200 Subject: TONY: Some more code formatting --- engines/tony/custom.cpp | 10 ---- engines/tony/font.cpp | 56 ++++++++++++------- engines/tony/mpal/expr.cpp | 64 +++++++++++----------- engines/tony/mpal/expr.h | 2 - engines/tony/mpal/loadmpc.cpp | 124 ++++++++++++++++++++++++++---------------- engines/tony/mpal/mpal.cpp | 44 +++++++-------- engines/tony/mpal/mpaldll.h | 4 +- 7 files changed, 166 insertions(+), 138 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 0127494007..a6381e0937 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -2073,16 +2073,6 @@ DECLARE_CUSTOM_FUNCTION(ReleaseOwnership)(CORO_PARAM, uint32 num, uint32, uint32 warning("TODO: Validate that the use of events in TakeOwnership/ReleaseOwnership match original"); } - - - - - - - - - - /* * Music * ----- diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 66f1ccdcd9..6b6778044d 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -1430,8 +1430,8 @@ void RMFontCredits::Init(void) { * Metodi di RMFontObj \****************************************************************************/ -#define TOUPPER(a) ((a) >='a'&&(a)<='z'?(a)+'A'-'a':(a)) -#define TOLOWER(a) ((a) >='A'&&(a)<='Z'?(a)+'a'-'A':(a)) +#define TOUPPER(a) ((a) >= 'a' && (a) <= 'z' ? (a) + 'A' - 'a' : (a)) +#define TOLOWER(a) ((a) >= 'A' && (a) <= 'Z' ? (a) + 'a' - 'A' : (a)) void RMFontObj::SetBothCase(int nChar, int nNext, signed char spiazz) { l2Table[TOUPPER(nChar)][TOUPPER(nNext)] = spiazz; @@ -1849,7 +1849,8 @@ void RMText::WriteText(const RMString &text, RMFontColor *font, int *time) { j += font->StringLen(*p); if (j > (((aHorType == HLEFTPAR) && (i > 0)) ? maxLineLength - 25 : maxLineLength)) { j -= font->StringLen(*p, p[1]); - if (j > x) x = j; + if (j > x) + x = j; // Back to the first usable space // @@ -1858,13 +1859,15 @@ void RMText::WriteText(const RMString &text, RMFontColor *font, int *time) { // This workaround has the partial word broken up so it will still display // old_p = p; - while (*p != ' ' && *p != '-' && p > string) p--; + while (*p != ' ' && *p != '-' && p > string) + p--; if (p == string) p = old_p; // Check if there are any blanks to end - while (*p == ' ' && *p != '\0') p++; + while (*p == ' ' && *p != '\0') + p++; if (*p == '\0') break; p--; @@ -1875,7 +1878,8 @@ void RMText::WriteText(const RMString &text, RMFontColor *font, int *time) { p++; } - if (j > x) x = j; + if (j > x) + x = j; i++; numlines = i; @@ -1948,10 +1952,14 @@ void RMText::WriteText(const RMString &text, RMFontColor *font, int *time) { void RMText::ClipOnScreen(RMGfxPrimitive *prim) { // Don't let it go outside the screen - if (prim->Dst().x1 < 5) prim->Dst().x1 = 5; - if (prim->Dst().y1 < 5) prim->Dst().y1 = 5; - if (prim->Dst().x1 + m_dimx > 635) prim->Dst().x1 = 635 - m_dimx; - if (prim->Dst().y1 + m_dimy > 475) prim->Dst().y1 = 475 - m_dimy; + if (prim->Dst().x1 < 5) + prim->Dst().x1 = 5; + if (prim->Dst().y1 < 5) + prim->Dst().y1 = 5; + if (prim->Dst().x1 + m_dimx > 635) + prim->Dst().x1 = 635 - m_dimx; + if (prim->Dst().y1 + m_dimy > 475) + prim->Dst().y1 = 475 - m_dimy; } void RMText::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { @@ -2068,34 +2076,40 @@ void RMTextDialog::RemoveThis(CORO_PARAM, bool &result) { // Don't erase the background if (m_bSkipStatus) { - if (!(GLOBALS.bCfgDubbing && hCustomSkip2 != CORO_INVALID_PID_VALUE)) + if (!(GLOBALS.bCfgDubbing && hCustomSkip2 != CORO_INVALID_PID_VALUE)) { if (GLOBALS.bCfgTimerizedText) { - if (!m_bForceNoTime) + if (!m_bForceNoTime) { if (_vm->GetTime() > (uint32)m_time + m_startTime) return; + } } + } - if (!m_bNoTab) + if (!m_bNoTab) { if (_vm->GetEngine()->GetInput().GetAsyncKeyState(Common::KEYCODE_TAB)) return; + } - if (!m_bNoTab) - if (m_input) + if (!m_bNoTab) { + if (m_input) { if (m_input->MouseLeftClicked() || m_input->MouseRightClicked()) return; + } + } } // Erase the background - else { - if (!(GLOBALS.bCfgDubbing && hCustomSkip2 != CORO_INVALID_PID_VALUE)) - if (!m_bForceNoTime) - if (_vm->GetTime() > (uint32)m_time + m_startTime) - return; + else if (!(GLOBALS.bCfgDubbing && hCustomSkip2 != CORO_INVALID_PID_VALUE)) { + if (!m_bForceNoTime) { + if (_vm->GetTime() > (uint32)m_time + m_startTime) + return; + } } // If time is forced - if (m_bForceTime) + if (m_bForceTime) { if (_vm->GetTime() > (uint32)m_time + m_startTime) return; + } if (hCustomSkip != CORO_INVALID_PID_VALUE) { CORO_INVOKE_3(CoroScheduler.waitForSingleObject, hCustomSkip, 0, &_ctx->expired); diff --git a/engines/tony/mpal/expr.cpp b/engines/tony/mpal/expr.cpp index aaec74fb4c..ae6dfac482 100644 --- a/engines/tony/mpal/expr.cpp +++ b/engines/tony/mpal/expr.cpp @@ -43,37 +43,36 @@ namespace MPAL { * @defgroup Mathamatical operations */ -#define OP_MUL ((1<<4)|0) -#define OP_DIV ((1<<4)|1) -#define OP_MODULE ((1<<4)|2) -#define OP_ADD ((2<<4)|0) -#define OP_SUB ((2<<4)|1) -#define OP_SHL ((3<<4)|0) -#define OP_SHR ((3<<4)|1) -#define OP_MINOR ((4<<4)|0) -#define OP_MAJOR ((4<<4)|1) -#define OP_MINEQ ((4<<4)|2) -#define OP_MAJEQ ((4<<4)|3) -#define OP_EQUAL ((5<<4)|0) -#define OP_NOEQUAL ((5<<4)|1) -#define OP_BITAND ((6<<4)|0) -#define OP_BITXOR ((7<<4)|0) -#define OP_BITOR ((8<<4)|0) -#define OP_AND ((9<<4)|0) -#define OP_OR ((10<<4)|0) +#define OP_MUL ((1 << 4) | 0) +#define OP_DIV ((1 << 4) | 1) +#define OP_MODULE ((1 << 4) | 2) +#define OP_ADD ((2 << 4) | 0) +#define OP_SUB ((2 << 4) | 1) +#define OP_SHL ((3 << 4) | 0) +#define OP_SHR ((3 << 4) | 1) +#define OP_MINOR ((4 << 4) | 0) +#define OP_MAJOR ((4 << 4) | 1) +#define OP_MINEQ ((4 << 4) | 2) +#define OP_MAJEQ ((4 << 4) | 3) +#define OP_EQUAL ((5 << 4) | 0) +#define OP_NOEQUAL ((5 << 4) | 1) +#define OP_BITAND ((6 << 4) | 0) +#define OP_BITXOR ((7 << 4) | 0) +#define OP_BITOR ((8 << 4) | 0) +#define OP_AND ((9 << 4) | 0) +#define OP_OR ((10 << 4) | 0) /** * Object types that can be contained in an EXPRESSION structure */ enum ExprListTypes { - ELT_NUMBER = 1, - ELT_VAR = 2, - ELT_PARENTH = 3, + ELT_NUMBER = 1, + ELT_VAR = 2, + ELT_PARENTH = 3, ELT_PARENTH2 = 4 }; - /** * @defgroup Structures */ @@ -95,7 +94,7 @@ typedef struct { byte symbol; // Simbolo matematico (vedi #define OP_*) } EXPRESSION; -typedef EXPRESSION* LPEXPRESSION; +typedef EXPRESSION *LPEXPRESSION; /** @@ -186,13 +185,13 @@ static void Solve(LPEXPRESSION one, int num) { while (num > 1) { two=one + 1; if ((two->symbol == 0) || (one->symbol & 0xF0) <= (two->symbol & 0xF0)) { - two->val.num=Compute(one->val.num, two->val.num,one->symbol); + two->val.num = Compute(one->val.num, two->val.num,one->symbol); CopyMemory(one, two, (num - 1) * sizeof(EXPRESSION)); num--; } else { j = 1; three = two + 1; - while ((three->symbol != 0) && (two->symbol & 0xF0)>(three->symbol & 0xF0)) { + while ((three->symbol != 0) && (two->symbol & 0xF0) > (three->symbol & 0xF0)) { two++; three++; j++; @@ -221,10 +220,10 @@ static int EvaluateAndFreeExpression(byte *expr) { one = (LPEXPRESSION)(expr + 1); // 1) Sostituzioni delle variabili - for (i=0, cur=one; i < num; i++, cur++) { - if (cur->type==ELT_VAR) { - cur->type=ELT_NUMBER; - cur->val.num=varGetValue(cur->val.name); + for (i = 0, cur = one; i < num; i++, cur++) { + if (cur->type == ELT_VAR) { + cur->type = ELT_NUMBER; + cur->val.num = varGetValue(cur->val.name); } } @@ -265,7 +264,7 @@ const byte *ParseExpression(const byte *lpBuf, HGLOBAL *h) { return NULL; *h = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, num * sizeof(EXPRESSION) + 1); - if (*h==NULL) + if (*h == NULL) return NULL; start = (byte *)GlobalLock(*h); @@ -332,7 +331,6 @@ int EvaluateExpression(HGLOBAL h) { return ret; } - /** * Compare two mathematical expressions together * @@ -356,8 +354,8 @@ bool CompareExpressions(HGLOBAL h1, HGLOBAL h2) { return false; } - one = (LPEXPRESSION)(e1+1); - two = (LPEXPRESSION)(e2+1); + one = (LPEXPRESSION)(e1 + 1); + two = (LPEXPRESSION)(e2 + 1); for (i = 0; i < num1; i++) { if (one->type != two->type || (i != num1 - 1 && one->symbol != two->symbol)) { diff --git a/engines/tony/mpal/expr.h b/engines/tony/mpal/expr.h index 7d7ca09c41..17e9c1264b 100644 --- a/engines/tony/mpal/expr.h +++ b/engines/tony/mpal/expr.h @@ -47,7 +47,6 @@ namespace MPAL { */ const byte *ParseExpression(const byte *lpBuf, HGLOBAL *h); - /** * Calculate the value of a mathamatical expression * @@ -56,7 +55,6 @@ const byte *ParseExpression(const byte *lpBuf, HGLOBAL *h); */ int EvaluateExpression(HGLOBAL h); - /** * Compare two mathematical expressions together * diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index a60c9f5f16..a80c85eb75 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -38,7 +38,6 @@ namespace Tony { namespace MPAL { - /****************************************************************************\ * Funzioni statiche \****************************************************************************/ @@ -54,7 +53,6 @@ static bool CompareCommands(struct command *cmd1, struct command *cmd2) { return (memcmp(cmd1, cmd2, sizeof(struct command)) == 0); } - /** * Parses a script from the MPC file, and inserts its data into a structure * @@ -64,7 +62,7 @@ static bool CompareCommands(struct command *cmd1, struct command *cmd2) { * @returns Pointer to the buffer after the item, or NULL on failure. */ static const byte *ParseScript(const byte *lpBuf, LPMPALSCRIPT lpmsScript) { - int curCmd,j,len; + int curCmd, j, len; uint i; lpmsScript->nObj = (int32)READ_LE_UINT32(lpBuf); @@ -76,31 +74,40 @@ static const byte *ParseScript(const byte *lpBuf, LPMPALSCRIPT lpmsScript) { curCmd = 0; for (i = 0; i < lpmsScript->nMoments; i++) { - lpmsScript->Moment[i].dwTime = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmsScript->Moment[i].nCmds = *lpBuf; lpBuf++; + lpmsScript->Moment[i].dwTime = (int32)READ_LE_UINT32(lpBuf); + lpBuf += 4; + lpmsScript->Moment[i].nCmds = *lpBuf; + lpBuf++; for (j = 0; j < lpmsScript->Moment[i].nCmds; j++) { - lpmsScript->Command[curCmd].type = *lpBuf; lpBuf++; + lpmsScript->Command[curCmd].type = *lpBuf; + lpBuf++; switch (lpmsScript->Command[curCmd].type) { case 1: - lpmsScript->Command[curCmd].nCf = READ_LE_UINT16(lpBuf); lpBuf += 2; - lpmsScript->Command[curCmd].arg1 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmsScript->Command[curCmd].arg2 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmsScript->Command[curCmd].arg3 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmsScript->Command[curCmd].arg4 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; + lpmsScript->Command[curCmd].nCf = READ_LE_UINT16(lpBuf); + lpBuf += 2; + lpmsScript->Command[curCmd].arg1 = (int32)READ_LE_UINT32(lpBuf); + lpBuf += 4; + lpmsScript->Command[curCmd].arg2 = (int32)READ_LE_UINT32(lpBuf); + lpBuf += 4; + lpmsScript->Command[curCmd].arg3 = (int32)READ_LE_UINT32(lpBuf); + lpBuf += 4; + lpmsScript->Command[curCmd].arg4 = (int32)READ_LE_UINT32(lpBuf); + lpBuf += 4; break; case 2: // Variable assign - len=*lpBuf; lpBuf++; - lpmsScript->Command[curCmd].lpszVarName = (char *)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,len+1); + len = *lpBuf; + lpBuf++; + lpmsScript->Command[curCmd].lpszVarName = (char *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, len + 1); if (lpmsScript->Command[curCmd].lpszVarName == NULL) return NULL; CopyMemory(lpmsScript->Command[curCmd].lpszVarName, lpBuf, len); - lpBuf+=len; + lpBuf += len; lpBuf = ParseExpression(lpBuf, &lpmsScript->Command[curCmd].expr); if (lpBuf == NULL) - return NULL; + return NULL; break; default: @@ -111,11 +118,9 @@ static const byte *ParseScript(const byte *lpBuf, LPMPALSCRIPT lpmsScript) { curCmd++; } } - return lpBuf; } - /** * Parses a dialog from the MPC file, and inserts its data into a structure * @@ -131,16 +136,19 @@ static const byte *ParseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { uint32 curCmd; uint32 len; - lpmdDialog->nObj = READ_LE_UINT32(lpBuf); lpBuf += 4; + lpmdDialog->nObj = READ_LE_UINT32(lpBuf); + lpBuf += 4; /* Periodi */ - num = READ_LE_UINT16(lpBuf); lpBuf += 2; + num = READ_LE_UINT16(lpBuf); + lpBuf += 2; if (num >= MAX_PERIODS_PER_DIALOG - 1) error("Too much periods in dialog #%d", lpmdDialog->nObj); for (i = 0; i < num; i++) { - lpmdDialog->PeriodNums[i] = READ_LE_UINT16(lpBuf); lpBuf += 2; + lpmdDialog->PeriodNums[i] = READ_LE_UINT16(lpBuf); + lpBuf += 2; lpmdDialog->Periods[i] = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, *lpBuf + 1); lpLock = (byte *)GlobalLock(lpmdDialog->Periods[i]); Common::copy(lpBuf + 1, lpBuf + 1 + *lpBuf, lpLock); @@ -152,14 +160,16 @@ static const byte *ParseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { lpmdDialog->Periods[i] = NULL; /* Gruppi */ - num = READ_LE_UINT16(lpBuf); lpBuf += 2; + num = READ_LE_UINT16(lpBuf); + lpBuf += 2; curCmd = 0; if (num >= MAX_GROUPS_PER_DIALOG) error("Too much groups in dialog #%d", lpmdDialog->nObj); for (i = 0; i < num; i++) { - lpmdDialog->Group[i].num = READ_LE_UINT16(lpBuf); lpBuf += 2; + lpmdDialog->Group[i].num = READ_LE_UINT16(lpBuf); + lpBuf += 2; lpmdDialog->Group[i].nCmds = *lpBuf; lpBuf++; if (lpmdDialog->Group[i].nCmds >= MAX_COMMANDS_PER_GROUP) @@ -172,11 +182,16 @@ static const byte *ParseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { switch (lpmdDialog->Command[curCmd].type) { // Call custom function case 1: - lpmdDialog->Command[curCmd].nCf = READ_LE_UINT16(lpBuf); lpBuf += 2; - lpmdDialog->Command[curCmd].arg1 = READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmdDialog->Command[curCmd].arg2 = READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmdDialog->Command[curCmd].arg3 = READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmdDialog->Command[curCmd].arg4 = READ_LE_UINT32(lpBuf); lpBuf += 4; + lpmdDialog->Command[curCmd].nCf = READ_LE_UINT16(lpBuf); + lpBuf += 2; + lpmdDialog->Command[curCmd].arg1 = READ_LE_UINT32(lpBuf); + lpBuf += 4; + lpmdDialog->Command[curCmd].arg2 = READ_LE_UINT32(lpBuf); + lpBuf += 4; + lpmdDialog->Command[curCmd].arg3 = READ_LE_UINT32(lpBuf); + lpBuf += 4; + lpmdDialog->Command[curCmd].arg4 = READ_LE_UINT32(lpBuf); + lpBuf += 4; break; // Variable assign @@ -197,7 +212,8 @@ static const byte *ParseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { // Do Choice case 3: - lpmdDialog->Command[curCmd].nChoice = READ_LE_UINT16(lpBuf); lpBuf += 2; + lpmdDialog->Command[curCmd].nChoice = READ_LE_UINT16(lpBuf); + lpBuf += 2; break; default: @@ -222,13 +238,15 @@ static const byte *ParseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { error("Too much commands in dialog #%d",lpmdDialog->nObj); /* Choices */ - num = READ_LE_UINT16(lpBuf); lpBuf += 2; + num = READ_LE_UINT16(lpBuf); + lpBuf += 2; if (num >= MAX_CHOICES_PER_DIALOG) error("Too much choices in dialog #%d",lpmdDialog->nObj); for (i = 0; i < num; i++) { - lpmdDialog->Choice[i].nChoice = READ_LE_UINT16(lpBuf); lpBuf += 2; + lpmdDialog->Choice[i].nChoice = READ_LE_UINT16(lpBuf); + lpBuf += 2; num2 = *lpBuf++; @@ -256,16 +274,19 @@ static const byte *ParseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { lpmdDialog->Choice[i].Select[j].attr = *lpBuf++; // Data - lpmdDialog->Choice[i].Select[j].dwData = READ_LE_UINT32(lpBuf); lpBuf += 4; + lpmdDialog->Choice[i].Select[j].dwData = READ_LE_UINT32(lpBuf); + lpBuf += 4; // PlayGroup - num3 = *lpBuf; *lpBuf++; + num3 = *lpBuf; + *lpBuf++; if (num3 >= MAX_PLAYGROUPS_PER_SELECT) error("Too much playgroups in select #%d in choice #%d in dialog #%d", j, lpmdDialog->Choice[i].nChoice, lpmdDialog->nObj); for (z = 0; z < num3; z++) { - lpmdDialog->Choice[i].Select[j].wPlayGroup[z] = READ_LE_UINT16(lpBuf); lpBuf += 2; + lpmdDialog->Choice[i].Select[j].wPlayGroup[z] = READ_LE_UINT16(lpBuf); + lpBuf += 2; } lpmdDialog->Choice[i].Select[j].wPlayGroup[num3] = 0; @@ -353,11 +374,16 @@ static const byte *ParseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { lpBuf++; switch (lpmiItem->Command[curCmd].type) { case 1: // Call custom function - lpmiItem->Command[curCmd].nCf = READ_LE_UINT16(lpBuf); lpBuf += 2; - lpmiItem->Command[curCmd].arg1 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmiItem->Command[curCmd].arg2 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmiItem->Command[curCmd].arg3 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmiItem->Command[curCmd].arg4 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; + lpmiItem->Command[curCmd].nCf = READ_LE_UINT16(lpBuf); + lpBuf += 2; + lpmiItem->Command[curCmd].arg1 = (int32)READ_LE_UINT32(lpBuf); + lpBuf += 4; + lpmiItem->Command[curCmd].arg2 = (int32)READ_LE_UINT32(lpBuf); + lpBuf += 4; + lpmiItem->Command[curCmd].arg3 = (int32)READ_LE_UINT32(lpBuf); + lpBuf += 4; + lpmiItem->Command[curCmd].arg4 = (int32)READ_LE_UINT32(lpBuf); + lpBuf += 4; break; case 2: // Variable assign @@ -385,7 +411,7 @@ static const byte *ParseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { } } - if (kk==curCmd) { + if (kk == curCmd) { lpmiItem->Action[i].CmdNum[j] = curCmd; curCmd++; @@ -397,7 +423,8 @@ static const byte *ParseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { } } - lpmiItem->dwRes = READ_LE_UINT32(lpBuf); lpBuf += 4; + lpmiItem->dwRes = READ_LE_UINT32(lpBuf); + lpBuf += 4; return lpBuf; } @@ -418,7 +445,7 @@ static const byte *ParseLocation(const byte *lpBuf, LPMPALLOCATION lpmlLocation) lpBuf += 2; lpmlLocation->dwYlen = READ_LE_UINT16(lpBuf); lpBuf += 2; - lpmlLocation->dwPicRes = READ_LE_UINT32(lpBuf); + lpmlLocation->dwPicRes = READ_LE_UINT32(lpBuf); lpBuf += 4; return lpBuf; @@ -551,14 +578,15 @@ bool ParseMpc(const byte *lpBuf) { GLOBALS.nItems = 0; GLOBALS.hItems = GLOBALS.lpmiItems = NULL; if (*(lpBuf + 2) == 4 && strncmp((const char *)lpBuf + 3, "Item", 4)==0) { - GLOBALS.nItems = READ_LE_UINT16(lpBuf); lpBuf += 2; + GLOBALS.nItems = READ_LE_UINT16(lpBuf); + lpBuf += 2; // Allocate memory and read them in GLOBALS.hItems = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nItems * sizeof(MPALITEM)); if (GLOBALS.hItems == NULL) return false; - GLOBALS.lpmiItems=(LPMPALITEM)GlobalLock(GLOBALS.hItems); + GLOBALS.lpmiItems = (LPMPALITEM)GlobalLock(GLOBALS.hItems); for (i = 0; i < GLOBALS.nItems; i++) if ((lpBuf = ParseItem(lpBuf + 5, &GLOBALS.lpmiItems[i])) == NULL) @@ -570,8 +598,9 @@ bool ParseMpc(const byte *lpBuf) { // Check the locations GLOBALS.nLocations = 0; GLOBALS.hLocations = GLOBALS.lpmlLocations = NULL; - if (*(lpBuf + 2) == 8 && strncmp((const char *)lpBuf + 3, "Location", 8)==0) { - GLOBALS.nLocations = READ_LE_UINT16(lpBuf); lpBuf += 2; + if (*(lpBuf + 2) == 8 && strncmp((const char *)lpBuf + 3, "Location", 8) == 0) { + GLOBALS.nLocations = READ_LE_UINT16(lpBuf); + lpBuf += 2; // Allocate memory and read them in GLOBALS.hLocations=GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nLocations*sizeof(MPALLOCATION)); @@ -591,7 +620,8 @@ bool ParseMpc(const byte *lpBuf) { GLOBALS.nScripts = 0; GLOBALS.hScripts = GLOBALS.lpmsScripts = NULL; if (*(lpBuf + 2) == 6 && strncmp((const char *)lpBuf + 3, "Script", 6) == 0) { - GLOBALS.nScripts = READ_LE_UINT16(lpBuf); lpBuf += 2; + GLOBALS.nScripts = READ_LE_UINT16(lpBuf); + lpBuf += 2; // Allocate memory GLOBALS.hScripts = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nScripts * sizeof(MPALSCRIPT)); @@ -611,7 +641,6 @@ bool ParseMpc(const byte *lpBuf) { //sizeof(GLOBALS.lpmsScripts[i].Moment[0]), //(int (*)(const void *, const void *))CompareMoments //); - } GlobalUnlock(GLOBALS.hScripts); @@ -623,7 +652,6 @@ bool ParseMpc(const byte *lpBuf) { return true; } - } // end of namespace MPAL } // end of namespace Tony diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index a5b7593e68..12fc78c60c 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -345,7 +345,7 @@ static char *DuplicateDialogPeriod(uint32 nPeriod) { const char *origmsg; char *clonemsg; LPMPALDIALOG dialog = GLOBALS.lpmdDialogs + GLOBALS.nExecutingDialog; - int i,j; + int i, j; for (j = 0; dialog->Periods[j] != NULL; j++) if (dialog->PeriodNums[j] == nPeriod) { @@ -457,7 +457,7 @@ static uint32 *GetItemList(uint32 nLoc) { LPMPALVAR v = GLOBALS.lpmvVars; num = 0; - for (i = 0; i < GLOBALS.nVars; i++,v++) { + for (i = 0; i < GLOBALS.nVars; i++, v++) { if (strncmp(v->lpszVarName,"Location",8) == 0 && v->dwVal == nLoc) num++; } @@ -468,8 +468,8 @@ static uint32 *GetItemList(uint32 nLoc) { v = GLOBALS.lpmvVars; j = 0; - for (i = 0; i < GLOBALS.nVars; i++,v++) { - if (strncmp(v->lpszVarName,"Location",8) == 0 && v->dwVal == nLoc) { + for (i = 0; i < GLOBALS.nVars; i++, v++) { + if (strncmp(v->lpszVarName, "Location", 8) == 0 && v->dwVal == nLoc) { sscanf(v->lpszVarName, "Location.%u", &il[j]); j++; } @@ -504,7 +504,7 @@ static LPITEM GetItemData(uint32 nOrdItem) { if (i >= 0x10) { // From 1.0, there's a destination point for each object ret->destX = (int16)READ_LE_UINT16(dat); ret->destY = (int16)READ_LE_UINT16(dat + 2); - dat+=4; + dat += 4; } if (i >= 0x11) { // From 1.1, there's animation speed @@ -514,9 +514,9 @@ static LPITEM GetItemData(uint32 nOrdItem) { ret->speed = 150; } - ret->numframe=*dat++; - ret->numpattern=*dat++; - ret->Zvalue=*dat++; + ret->numframe = *dat++; + ret->numpattern = *dat++; + ret->Zvalue = *dat++; // Upload the left & top co-ordinates of each frame for (i = 0; i < ret->numframe; i++) { @@ -529,7 +529,7 @@ static LPITEM GetItemData(uint32 nOrdItem) { for (i = 0; i < ret->numframe; i++) { ret->frameslocations[i].right = (int16)READ_LE_UINT16(dat) + ret->frameslocations[i].left; ret->frameslocations[i].bottom = (int16)READ_LE_UINT16(dat + 2) + ret->frameslocations[i].top; - dat+=4; + dat += 4; } // Upload the bounding boxes of each frame @@ -538,12 +538,12 @@ static LPITEM GetItemData(uint32 nOrdItem) { ret->bbox[i].top = (int16)READ_LE_UINT16(dat + 2); ret->bbox[i].right = (int16)READ_LE_UINT16(dat + 4); ret->bbox[i].bottom = (int16)READ_LE_UINT16(dat + 6); - dat+=8; + dat += 8; } // Load the animation pattern patlength = dat; - dat+=ret->numpattern; + dat += ret->numpattern; for (i = 1; i < ret->numpattern; i++) { for (j = 0; j < patlength[i]; j++) @@ -639,7 +639,7 @@ void ScriptThread(CORO_PARAM, const void *param) { } _ctx->numHandles = 0; - for (_ctx->j = 0; _ctx->jMoment[_ctx->i].nCmds; _ctx->j++) { + for (_ctx->j = 0; _ctx->j < s->Moment[_ctx->i].nCmds; _ctx->j++) { _ctx->k = s->Moment[_ctx->i].CmdNum[_ctx->j]; if (s->Command[_ctx->k].type == 1) { @@ -1048,9 +1048,6 @@ void LocationPollThread(CORO_PARAM, const void *param) { } - - - /** * Wait for the end of the dialog execution thread, and then restore global * variables indicating that the dialogue has finished. @@ -1847,7 +1844,7 @@ HANDLE mpalQueryHANDLE(uint16 wQueryType, ...) { n = GETARG(char *); buf = Common::String::format("Status.%u", x); if (varGetValue(buf.c_str()) <= 0) - n[0]='\0'; + n[0] = '\0'; else { LockItems(); y = itemGetOrderFromNum(x); @@ -2288,7 +2285,7 @@ void mpalDumpMessages(void) { } // Now make a loop over all the periods - for (j = 0;j -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to do -// so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -#include "agos/installshield_cab.h" - -#include "common/debug.h" -#include "common/file.h" -#include "common/memstream.h" -#include "common/zlib.h" - -namespace AGOS { - -class InstallShieldCabinet : public Common::Archive { - Common::String _installShieldFilename; - -public: - InstallShieldCabinet(const Common::String &filename); - ~InstallShieldCabinet(); - - // Common::Archive API implementation - bool hasFile(const Common::String &name) const; - int listMembers(Common::ArchiveMemberList &list) const; - const Common::ArchiveMemberPtr getMember(const Common::String &name) const; - Common::SeekableReadStream *createReadStreamForMember(const Common::String &name) const; - -private: - struct FileEntry { - uint32 uncompressedSize; - uint32 compressedSize; - uint32 offset; - uint16 flags; - }; - - typedef Common::HashMap FileMap; - FileMap _map; -}; - -InstallShieldCabinet::~InstallShieldCabinet() { - _map.clear(); -} - -InstallShieldCabinet::InstallShieldCabinet(const Common::String &filename) : _installShieldFilename(filename) { - Common::File installShieldFile; - - if (!installShieldFile.open(_installShieldFilename)) { - warning("InstallShieldCabinet::InstallShieldCabinet(): Could not find the archive file %s", _installShieldFilename.c_str()); - return; - } - - // Note that we only support a limited subset of cabinet files - // Only single cabinet files and ones without data shared between - // cabinets. - - // Check for the magic uint32 - if (installShieldFile.readUint32LE() != 0x28635349) { - warning("InstallShieldCabinet::InstallShieldCabinet(): Magic ID doesn't match"); - return; - } - - uint32 version = installShieldFile.readUint32LE(); - - if (version != 0x01000004) { - warning("Unsupported CAB version %08x", version); - return; - } - - /* uint32 volumeInfo = */ installShieldFile.readUint32LE(); - uint32 cabDescriptorOffset = installShieldFile.readUint32LE(); - /* uint32 cabDescriptorSize = */ installShieldFile.readUint32LE(); - - installShieldFile.seek(cabDescriptorOffset); - - installShieldFile.skip(12); - uint32 fileTableOffset = installShieldFile.readUint32LE(); - installShieldFile.skip(4); - uint32 fileTableSize = installShieldFile.readUint32LE(); - uint32 fileTableSize2 = installShieldFile.readUint32LE(); - uint32 directoryCount = installShieldFile.readUint32LE(); - installShieldFile.skip(8); - uint32 fileCount = installShieldFile.readUint32LE(); - - if (fileTableSize != fileTableSize2) - warning("file table sizes do not match"); - - // We're ignoring file groups and components since we - // should not need them. Moving on to the files... - - installShieldFile.seek(cabDescriptorOffset + fileTableOffset); - uint32 fileTableCount = directoryCount + fileCount; - uint32 *fileTableOffsets = new uint32[fileTableCount]; - for (uint32 i = 0; i < fileTableCount; i++) - fileTableOffsets[i] = installShieldFile.readUint32LE(); - - for (uint32 i = directoryCount; i < fileCount + directoryCount; i++) { - installShieldFile.seek(cabDescriptorOffset + fileTableOffset + fileTableOffsets[i]); - uint32 nameOffset = installShieldFile.readUint32LE(); - /* uint32 directoryIndex = */ installShieldFile.readUint32LE(); - - // First read in data needed by us to get at the file data - FileEntry entry; - entry.flags = installShieldFile.readUint16LE(); - entry.uncompressedSize = installShieldFile.readUint32LE(); - entry.compressedSize = installShieldFile.readUint32LE(); - installShieldFile.skip(20); - entry.offset = installShieldFile.readUint32LE(); - - // Then let's get the string - installShieldFile.seek(cabDescriptorOffset + fileTableOffset + nameOffset); - Common::String fileName; - - char c = installShieldFile.readByte(); - while (c) { - fileName += c; - c = installShieldFile.readByte(); - } - _map[fileName] = entry; - } - - delete[] fileTableOffsets; -} - -bool InstallShieldCabinet::hasFile(const Common::String &name) const { - return _map.contains(name); -} - -int InstallShieldCabinet::listMembers(Common::ArchiveMemberList &list) const { - for (FileMap::const_iterator it = _map.begin(); it != _map.end(); it++) - list.push_back(getMember(it->_key)); - - return _map.size(); -} - -const Common::ArchiveMemberPtr InstallShieldCabinet::getMember(const Common::String &name) const { - return Common::ArchiveMemberPtr(new Common::GenericArchiveMember(name, this)); -} - -Common::SeekableReadStream *InstallShieldCabinet::createReadStreamForMember(const Common::String &name) const { - if (!_map.contains(name)) - return 0; - - const FileEntry &entry = _map[name]; - - Common::File archiveFile; - archiveFile.open(_installShieldFilename); - archiveFile.seek(entry.offset); - - if (!(entry.flags & 0x04)) { - // Not compressed - return archiveFile.readStream(entry.uncompressedSize); - } - -#ifdef USE_ZLIB - byte *src = (byte *)malloc(entry.compressedSize); - byte *dst = (byte *)malloc(entry.uncompressedSize); - - archiveFile.read(src, entry.compressedSize); - - bool result = Common::inflateZlibHeaderless(dst, entry.uncompressedSize, src, entry.compressedSize); - free(src); - - if (!result) { - warning("failed to inflate CAB file '%s'", name.c_str()); - free(dst); - return 0; - } - - return new Common::MemoryReadStream(dst, entry.uncompressedSize, DisposeAfterUse::YES); -#else - warning("zlib required to extract compressed CAB file '%s'", name.c_str()); - return 0; -#endif -} - -Common::Archive *makeInstallShieldArchive(const Common::String &name) { - return new InstallShieldCabinet(name); -} - -} // End of namespace AGOS diff --git a/engines/agos/installshield_cab.h b/engines/agos/installshield_cab.h deleted file mode 100644 index f7e8bed277..0000000000 --- a/engines/agos/installshield_cab.h +++ /dev/null @@ -1,41 +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. - * - */ - -#include "common/archive.h" -#include "common/str.h" - -#ifndef AGOS_INSTALLSHIELD_CAB_H -#define AGOS_INSTALLSHIELD_CAB_H - -namespace AGOS { - -/** - * This factory method creates an Archive instance corresponding to the content - * of the InstallShield compressed file with the given name. - * - * May return 0 in case of a failure. - */ -Common::Archive *makeInstallShieldArchive(const Common::String &name); - -} // End of namespace AGOS - -#endif diff --git a/engines/agos/module.mk b/engines/agos/module.mk index 7ae5e17bf2..7069d8005b 100644 --- a/engines/agos/module.mk +++ b/engines/agos/module.mk @@ -51,7 +51,6 @@ ifdef ENABLE_AGOS2 MODULE_OBJS += \ animation.o \ feeble.o \ - installshield_cab.o \ oracle.o \ script_dp.o \ script_ff.o \ diff --git a/engines/agos/res.cpp b/engines/agos/res.cpp index 0305879390..2e44a6575c 100644 --- a/engines/agos/res.cpp +++ b/engines/agos/res.cpp @@ -23,6 +23,8 @@ // Resource file routines for Simon1/Simon2 +#include "common/archive.h" +#include "common/installshield_cab.h" #include "common/file.h" #include "common/memstream.h" #include "common/textconsole.h" @@ -31,7 +33,6 @@ #include "agos/agos.h" #include "agos/intern.h" #include "agos/sound.h" -#include "agos/installshield_cab.h" #include "common/zlib.h" @@ -43,7 +44,10 @@ ArchiveMan::ArchiveMan() { #ifdef ENABLE_AGOS2 void ArchiveMan::registerArchive(const Common::String &filename, int priority) { - add(filename, makeInstallShieldArchive(filename), priority); + Common::SeekableReadStream *stream = SearchMan.createReadStreamForMember(filename); + + if (stream) + add(filename, makeInstallShieldArchive(stream, DisposeAfterUse::YES), priority); } #endif -- cgit v1.2.3 From 6e104f0883eaf060e66dadc07cf546b5f1dee1b7 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Mon, 28 May 2012 16:56:31 -0400 Subject: TONY: Add support for using the compressed version of the demo --- engines/tony/detection.cpp | 9 ++++++++- engines/tony/detection_tables.h | 17 +++++++++++++++++ engines/tony/tony.cpp | 13 +++++++++++++ engines/tony/tony.h | 1 + 4 files changed, 39 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/tony/detection.cpp b/engines/tony/detection.cpp index a87dd9bd07..1de1b70968 100644 --- a/engines/tony/detection.cpp +++ b/engines/tony/detection.cpp @@ -32,9 +32,12 @@ #include "tony/tony.h" #include "tony/game.h" - namespace Tony { +enum { + GF_COMPRESSED = (1 << 0) +}; + struct TonyGameDescription { ADGameDescription desc; }; @@ -51,8 +54,12 @@ bool TonyEngine::getIsDemo() const { return _gameDescription->desc.flags & ADGF_DEMO; } +bool TonyEngine::isCompressed() const { + return _gameDescription->desc.flags & GF_COMPRESSED; } +} // End of namespace Tony + static const PlainGameDescriptor tonyGames[] = { {"tony", "Tony Tough and the Night of Roasted Moths"}, {0, 0} diff --git a/engines/tony/detection_tables.h b/engines/tony/detection_tables.h index afcf787ca1..3510178474 100644 --- a/engines/tony/detection_tables.h +++ b/engines/tony/detection_tables.h @@ -41,6 +41,23 @@ static const TonyGameDescription gameDescriptions[] = { }, }, + { + // Tony Tough English Demo (Compressed) + { + "tony", + "Demo", + AD_ENTRY1s("data1.cab", "7d8b6d308f96aee3968ad7910fb11e6d", 58660608), + Common::EN_ANY, + Common::kPlatformPC, +#ifdef TEMPORARY_DISABLED + ADGF_DEMO | GF_COMPRESSED, +#else + ADGF_NO_FLAGS | GF_COMPRESSED, +#endif + GUIO1(GUIO_NONE) + }, + }, + { AD_TABLE_END_MARKER } }; diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index e5c30ffcec..da63c23bab 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -26,6 +26,7 @@ #include "common/debug-channels.h" #include "common/events.h" #include "common/file.h" +#include "common/installshield_cab.h" #include "tony/tony.h" #include "tony/custom.h" #include "tony/debugger.h" @@ -84,6 +85,18 @@ Common::Error TonyEngine::run() { * Initialise the game */ Common::ErrorCode TonyEngine::Init() { + if (isCompressed()) { + Common::SeekableReadStream *stream = SearchMan.createReadStreamForMember("data1.cab"); + if (!stream) + error("Failed to open data1.cab"); + + Common::Archive *cabinet = Common::makeInstallShieldArchive(stream); + if (!cabinet) + error("Failed to parse data1.cab"); + + SearchMan.add("data1.cab", cabinet); + } + m_hEndOfFrame = CoroScheduler.createEvent(false, false); m_bPaused = false; diff --git a/engines/tony/tony.h b/engines/tony/tony.h index f4d9d83674..78e9abd476 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -143,6 +143,7 @@ public: Common::Language getLanguage() const; uint16 getVersion() const; bool getIsDemo() const; + bool isCompressed() const; RMGfxEngine *GetEngine() { return &_theEngine; } -- cgit v1.2.3 From 01df8ae0e81a25c14b0f17e82af9d0ce407846e0 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 2 Jun 2012 10:39:00 +1000 Subject: TONY: Fix compiler warning of not using a deferenced pointer --- engines/tony/mpal/loadmpc.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index a80c85eb75..02571bd30f 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -278,10 +278,9 @@ static const byte *ParseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { lpBuf += 4; // PlayGroup - num3 = *lpBuf; - *lpBuf++; + num3 = *lpBuf++; - if (num3 >= MAX_PLAYGROUPS_PER_SELECT) + if (num3 >= MAX_PLAYGROUPS_PER_SELECT) error("Too much playgroups in select #%d in choice #%d in dialog #%d", j, lpmdDialog->Choice[i].nChoice, lpmdDialog->nObj); for (z = 0; z < num3; z++) { -- cgit v1.2.3 From be320760bd2b3f8f7ada1f27eb4e9997bbb25f4a Mon Sep 17 00:00:00 2001 From: D G Turner Date: Sat, 2 Jun 2012 01:44:34 +0100 Subject: TONY: Remove TEMPORARY_DISABLED define from detection tables. --- engines/tony/detection_tables.h | 8 -------- 1 file changed, 8 deletions(-) (limited to 'engines') diff --git a/engines/tony/detection_tables.h b/engines/tony/detection_tables.h index 3510178474..498dcb4eb5 100644 --- a/engines/tony/detection_tables.h +++ b/engines/tony/detection_tables.h @@ -32,11 +32,7 @@ static const TonyGameDescription gameDescriptions[] = { AD_ENTRY1s("roasted.mpr", "06203dbbc85fdd1e6dc8fc211c1a6207", 14972409), Common::EN_ANY, Common::kPlatformPC, -#ifdef TEMPORARY_DISABLED ADGF_DEMO, -#else - ADGF_NO_FLAGS, -#endif GUIO1(GUIO_NONE) }, }, @@ -49,11 +45,7 @@ static const TonyGameDescription gameDescriptions[] = { AD_ENTRY1s("data1.cab", "7d8b6d308f96aee3968ad7910fb11e6d", 58660608), Common::EN_ANY, Common::kPlatformPC, -#ifdef TEMPORARY_DISABLED ADGF_DEMO | GF_COMPRESSED, -#else - ADGF_NO_FLAGS | GF_COMPRESSED, -#endif GUIO1(GUIO_NONE) }, }, -- cgit v1.2.3 From 22b432643743bda52665e7f733e149633cab96bf Mon Sep 17 00:00:00 2001 From: D G Turner Date: Sat, 2 Jun 2012 01:47:33 +0100 Subject: TONY: Add detection entries for full english game release. Also, now versions using uncompressed game data will be marked with "Extracted" in the launcher detection description. This should help in detecting any performance issues in future bug reports from user using compressed vs. extracted game data. --- engines/tony/detection_tables.h | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/tony/detection_tables.h b/engines/tony/detection_tables.h index 498dcb4eb5..23defb57c0 100644 --- a/engines/tony/detection_tables.h +++ b/engines/tony/detection_tables.h @@ -23,12 +23,37 @@ namespace Tony { static const TonyGameDescription gameDescriptions[] = { + { + // Tony Tough English + { + "tony", + "Extracted", + AD_ENTRY1s("roasted.mpr", "06203dbbc85fdd1e6dc8fc211c1a6207", 135911071), + Common::EN_ANY, + Common::kPlatformPC, + ADGF_NO_FLAGS, + GUIO1(GUIO_NONE) + }, + }, + + { + // Tony Tough English (Compressed) + { + "tony", + "", + AD_ENTRY1s("data1.cab", "ce82907242166bfb594d97bdb68f96d2", 4350), + Common::EN_ANY, + Common::kPlatformPC, + ADGF_NO_FLAGS | GF_COMPRESSED, + GUIO1(GUIO_NONE) + }, + }, { // Tony Tough English Demo { "tony", - "Demo", + "Extracted Demo", AD_ENTRY1s("roasted.mpr", "06203dbbc85fdd1e6dc8fc211c1a6207", 14972409), Common::EN_ANY, Common::kPlatformPC, -- cgit v1.2.3 From 6ecd71270da3e3ddaadf181e37a17419c74cdef2 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 2 Jun 2012 11:07:56 +1000 Subject: TONY: Removed redundant vdb mutex --- engines/tony/custom.cpp | 16 ---------------- engines/tony/globals.cpp | 1 - engines/tony/globals.h | 1 - 3 files changed, 18 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index a6381e0937..03c6405d2e 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -275,7 +275,6 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX _ctx->curOffset = _ctx->curVoc->offset; // First time allocation - g_system->lockMutex(GLOBALS.vdb); _vm->_vdbFP.seek(_ctx->curOffset); _vm->_theSound.CreateSfx(&_ctx->voice); @@ -283,7 +282,6 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX _ctx->curOffset = _vm->_vdbFP.pos(); _ctx->voice->SetLoop(false); - g_system->unlockMutex(GLOBALS.vdb); } if (GLOBALS.nTonyNextTalkType != GLOBALS.Tony->TALK_NORMAL) { @@ -335,7 +333,6 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX _ctx->voice->Play(); _ctx->text.SetCustomSkipHandle2(_ctx->voice->hEndOfBuffer); } else { - g_system->lockMutex(GLOBALS.vdb); _vm->_vdbFP.seek(_ctx->curOffset); _vm->_theSound.CreateSfx(&_ctx->voice); _ctx->voice->LoadVoiceFromVDB(_vm->_vdbFP); @@ -344,7 +341,6 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX _ctx->voice->SetLoop(false); _ctx->voice->Play(); _ctx->text.SetCustomSkipHandle2(_ctx->voice->hEndOfBuffer); - g_system->unlockMutex(GLOBALS.vdb); } } @@ -1486,10 +1482,8 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess _ctx->voice = NULL; if (_ctx->curVoc) { // Position within the database of entries, beginning at the first - g_system->lockMutex(GLOBALS.vdb); _vm->_vdbFP.seek(_ctx->curVoc->offset); _ctx->curOffset = _ctx->curVoc->offset; - g_system->unlockMutex(GLOBALS.vdb); } for (_ctx->i = 0; _ctx->i < _ctx->msg->NumPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { @@ -1527,7 +1521,6 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess GLOBALS.LinkGraphicTask(_ctx->text); if (_ctx->curVoc) { - g_system->lockMutex(GLOBALS.vdb); _vm->_theSound.CreateSfx(&_ctx->voice); _vm->_vdbFP.seek(_ctx->curOffset); _ctx->voice->LoadVoiceFromVDB(_vm->_vdbFP); @@ -1536,7 +1529,6 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess _ctx->voice->Play(); _ctx->text->SetCustomSkipHandle2(_ctx->voice->hEndOfBuffer); _ctx->curOffset = _vm->_vdbFP.pos(); - g_system->unlockMutex(GLOBALS.vdb); } // Wait for the end of display @@ -1701,11 +1693,9 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes _ctx->voice = NULL; if (_ctx->curVoc) { // Position within the database of entries, beginning at the first - g_system->lockMutex(GLOBALS.vdb); // fseek(_vm->m_vdbFP, curVoc->offset, SEEK_SET); _vm->_vdbFP.seek(_ctx->curVoc->offset); _ctx->curOffset = _ctx->curVoc->offset; - g_system->unlockMutex(GLOBALS.vdb); } for (_ctx->i = 0; _ctx->i < _ctx->msg->NumPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { @@ -1744,7 +1734,6 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes GLOBALS.LinkGraphicTask(_ctx->text); if (_ctx->curVoc) { - g_system->lockMutex(GLOBALS.vdb); _vm->_theSound.CreateSfx(&_ctx->voice); _vm->_vdbFP.seek(_ctx->curOffset); _ctx->voice->LoadVoiceFromVDB(_vm->_vdbFP); @@ -1753,7 +1742,6 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes _ctx->voice->Play(); _ctx->text->SetCustomSkipHandle2(_ctx->voice->hEndOfBuffer); _ctx->curOffset = _vm->_vdbFP.pos(); - g_system->unlockMutex(GLOBALS.vdb); } // Wait for the end of display @@ -1818,13 +1806,11 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg if (_ctx->curVoc) { // Position within the database of entries, beginning at the first - g_system->lockMutex(GLOBALS.vdb); _vm->_vdbFP.seek(_ctx->curVoc->offset); _vm->_theSound.CreateSfx(&_ctx->voice); _ctx->voice->LoadVoiceFromVDB(_vm->_vdbFP); _ctx->voice->SetLoop(false); if (_ctx->bIsBack) _ctx->voice->SetVolume(55); - g_system->unlockMutex(GLOBALS.vdb); } _ctx->string = mpalQueryDialogPeriod(nMsg); @@ -2559,8 +2545,6 @@ void SetupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation GLOBALS.EnableGUI = MainEnableGUI; GLOBALS.SetPalesati = MainSetPalesati; - GLOBALS.vdb = g_system->createMutex(); - GLOBALS.bAlwaysDisplay = false; int i; diff --git a/engines/tony/globals.cpp b/engines/tony/globals.cpp index 7c801a787d..1a4467ef28 100644 --- a/engines/tony/globals.cpp +++ b/engines/tony/globals.cpp @@ -91,7 +91,6 @@ Globals::Globals() { lastTappeto = 0; Common::fill(&tappeti[0], &tappeti[200], 0); SFM_nLoc = 0; - vdb = NULL; // MPAL global variables mpalError = 0; diff --git a/engines/tony/globals.h b/engines/tony/globals.h index d2d47d392a..76a54e07c8 100644 --- a/engines/tony/globals.h +++ b/engines/tony/globals.h @@ -241,7 +241,6 @@ public: RMPoint StartLocPos[256]; OSystem::MutexRef cs[10]; - OSystem::MutexRef vdb; uint32 mut[10]; bool bSkipIdle; -- cgit v1.2.3 From 3367679ae80e89dcdbc424af477ee743007050ac Mon Sep 17 00:00:00 2001 From: D G Turner Date: Sat, 2 Jun 2012 03:10:33 +0100 Subject: TONY: Correcting full english version detection entries. Though the CD contains installshield cabinets, these don't contain the required datafiles. These are instead already found on the CD in the directories named "Music", "Voices" and "Roasted". The last of these contains the main datafiles and executables. It appears the installshield cabinet format here is using a rare "external" link format pointing to the files and folders on the CD. Since the files are on the CD anyway, the "compressed" entry is not required. However, the detection entry is likely to need some more changes to support detection of these in the original CD folder structure.. --- engines/tony/detection_tables.h | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) (limited to 'engines') diff --git a/engines/tony/detection_tables.h b/engines/tony/detection_tables.h index 23defb57c0..63a6d044ae 100644 --- a/engines/tony/detection_tables.h +++ b/engines/tony/detection_tables.h @@ -27,7 +27,7 @@ static const TonyGameDescription gameDescriptions[] = { // Tony Tough English { "tony", - "Extracted", + "", AD_ENTRY1s("roasted.mpr", "06203dbbc85fdd1e6dc8fc211c1a6207", 135911071), Common::EN_ANY, Common::kPlatformPC, @@ -36,19 +36,6 @@ static const TonyGameDescription gameDescriptions[] = { }, }, - { - // Tony Tough English (Compressed) - { - "tony", - "", - AD_ENTRY1s("data1.cab", "ce82907242166bfb594d97bdb68f96d2", 4350), - Common::EN_ANY, - Common::kPlatformPC, - ADGF_NO_FLAGS | GF_COMPRESSED, - GUIO1(GUIO_NONE) - }, - }, - { // Tony Tough English Demo { -- cgit v1.2.3 From c1e6913fedf05d18edf6ef64c5a7c1c2cabedd4e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 2 Jun 2012 16:59:58 +1000 Subject: TONY: Fixed memory leaks with the Options screen --- engines/tony/game.cpp | 6 +++++- engines/tony/game.h | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index dc5e412f00..a1954b95b2 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -139,6 +139,7 @@ RMOptionButton::RMOptionButton(const RMRect &pt) { m_bActive = false; m_bHasGfx = false; m_bDoubleState = false; + m_buf = NULL; } RMOptionButton::~RMOptionButton() { @@ -321,7 +322,7 @@ void RMOptionSlide::AddToList(RMGfxTargetBuffer &bigBuf) { \****************************************************************************/ RMOptionScreen::RMOptionScreen(void) { - m_nState = MENUGAME; + m_nState = MENUNONE; m_menu = NULL; m_HideLoadSave = NULL; m_QuitConfirm = NULL; @@ -379,6 +380,7 @@ RMOptionScreen::RMOptionScreen(void) { RMOptionScreen::~RMOptionScreen(void) { + CloseState(); } void RMOptionScreen::RefreshAll(CORO_PARAM) { @@ -856,6 +858,8 @@ void RMOptionScreen::CloseState(void) { m_ButtonSound_SFXOn = NULL; } } + + m_nState = MENUNONE; } void RMOptionScreen::ReInit(RMGfxTargetBuffer &bigBuf) { diff --git a/engines/tony/game.h b/engines/tony/game.h index 20b5f347bc..c920b88ee5 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -252,7 +252,8 @@ private: MENUGFX, MENUSOUND, MENULOAD, - MENUSAVE + MENUSAVE, + MENUNONE }; STATE m_nState; -- cgit v1.2.3 From ea8c4960c7139440df9416366a78094f4753aa12 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 2 Jun 2012 17:15:24 +1000 Subject: TONY: Fix Valgrind warnings of checks on uninitialised variables --- engines/tony/input.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp index c1104204b5..fc98544e14 100644 --- a/engines/tony/input.cpp +++ b/engines/tony/input.cpp @@ -35,11 +35,12 @@ RMInput::RMInput() { // Setup mouse fields _clampMouse = false; _mousePos.Set(0, 0); - _leftButton = _rightButton = false;; - + _leftButton = _rightButton = false; _leftClickMouse = _leftReleaseMouse = false; _rightClickMouse = _rightReleaseMouse = false; + Common::fill((byte *)&_event, (byte *)&_event + sizeof(Common::Event), 0); + // Setup keyboard fields Common::fill(&_keyDown[0], &_keyDown[350], 0); } -- cgit v1.2.3 From a850eabf07bd5c620a7329529f464deb4930a127 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 2 Jun 2012 17:40:01 +1000 Subject: TONY: Fix memory leak when game exited whilst credits are active --- engines/tony/custom.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 03c6405d2e..96b78d0e83 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -2315,6 +2315,12 @@ DECLARE_CUSTOM_FUNCTION(DoCredits)(CORO_PARAM, uint32 nMsg, uint32 dwTime, uint3 uint32 hDisable; int i; uint32 startTime; + + ~CoroContextTag() { + delete msg; + delete[] text; + } + CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -2368,6 +2374,8 @@ DECLARE_CUSTOM_FUNCTION(DoCredits)(CORO_PARAM, uint32 nMsg, uint32 dwTime, uint3 delete[] _ctx->text; delete _ctx->msg; + _ctx->text = NULL; + _ctx->msg = NULL; CORO_END_CODE; } -- cgit v1.2.3 From 3927d9020613682a7e38e5c387835e27e170fb66 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 2 Jun 2012 18:37:41 +1000 Subject: TONY: Extra initialisation of globals --- engines/tony/globals.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'engines') diff --git a/engines/tony/globals.cpp b/engines/tony/globals.cpp index 1a4467ef28..742d4376d5 100644 --- a/engines/tony/globals.cpp +++ b/engines/tony/globals.cpp @@ -26,6 +26,7 @@ namespace Tony { Globals::Globals() { + Common::fill(nextMusic, nextMusic + MAX_PATH, 0); nextLoop = false; nextChannel = 0; nextSync = 0; @@ -71,6 +72,7 @@ Globals::Globals() { bCfgDubbing = false; bCfgMusic = false; bCfgSFX = false; + bAlwaysDisplay = false; nCfgTonySpeed = 0; nCfgTextSpeed = 0; nCfgDubbingVolume = 0; @@ -129,6 +131,15 @@ Globals::Globals() { nExecutingDialog = 0; nExecutingChoice = 0; nSelectedChoice = 0; + nTonyNextTalkType = RMTony::TALK_NORMAL; + saveTonyLoc = 0; + + for (int i = 0; i < 16; ++i) + Common::fill((byte *)&Character[i], (byte *)&Character[i] + sizeof(CharacterStruct), 0); + for (int i = 0; i < 10; ++i) + Common::fill((byte *)&MCharacter[i], (byte *)&MCharacter[i] + sizeof(MCharacterStruct), 0); + for (int i = 0; i < 256; ++i) + Common::fill((byte *)&ChangedHotspot[i], (byte *)&ChangedHotspot[i] + sizeof(ChangedHotspotStruct), 0); } } // End of namespace Tony -- cgit v1.2.3 From b566583e3231b70512b7954a7b00cc0f02f9f24c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 3 Jun 2012 21:16:25 +1000 Subject: TONY: Workaround for hang on title screen if you click with a y = 0 --- engines/tony/loc.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'engines') diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index f0dd30b1a9..512c28605e 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -1298,6 +1298,10 @@ RMPoint RMCharacter::InvScanLine(const RMPoint &punto) { } Lscan.x = Lstart.x + Ldx; Lscan.y = Lstart.y + Ldy; + + // WORKAROUND: Handles cases where the points never fall inside a bounding box + if (Lscan.x < -100 || Lscan.y < -100 || Lscan.x >= 1000 || Lscan.y >= 1000) + return punto; } } -- cgit v1.2.3 From c17af63aacda4b18ca6e756fb710cecb3b25fc88 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 4 Jun 2012 22:18:50 +0200 Subject: TONY: Modify detection in order to use roasted.mpc too. Add French, German, Italian and Polish versions. This also breaks the English game detection. To be fixed! --- engines/tony/detection_tables.h | 85 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 80 insertions(+), 5 deletions(-) (limited to 'engines') diff --git a/engines/tony/detection_tables.h b/engines/tony/detection_tables.h index 63a6d044ae..36548c4e3c 100644 --- a/engines/tony/detection_tables.h +++ b/engines/tony/detection_tables.h @@ -27,8 +27,13 @@ static const TonyGameDescription gameDescriptions[] = { // Tony Tough English { "tony", - "", - AD_ENTRY1s("roasted.mpr", "06203dbbc85fdd1e6dc8fc211c1a6207", 135911071), + 0, + { + {"roasted.mpr", 0, "06203dbbc85fdd1e6dc8fc211c1a6207", 135911071}, + // Fake md5 : to be fixed! + {"roasted.mpc", 0, "bad97eae03a4db3e99565e39b0b3c06a", 16384}, + AD_LISTEND + }, Common::EN_ANY, Common::kPlatformPC, ADGF_NO_FLAGS, @@ -41,7 +46,11 @@ static const TonyGameDescription gameDescriptions[] = { { "tony", "Extracted Demo", - AD_ENTRY1s("roasted.mpr", "06203dbbc85fdd1e6dc8fc211c1a6207", 14972409), + { + {"roasted.mpr", 0, "06203dbbc85fdd1e6dc8fc211c1a6207", 14972409}, + {"roasted.mpc", 0, "1e247922ec869712bfd96625bc4d3c7c", 39211}, + AD_LISTEND + }, Common::EN_ANY, Common::kPlatformPC, ADGF_DEMO, @@ -54,14 +63,80 @@ static const TonyGameDescription gameDescriptions[] = { { "tony", "Demo", - AD_ENTRY1s("data1.cab", "7d8b6d308f96aee3968ad7910fb11e6d", 58660608), + { + {"data1.cab", 0, "7d8b6d308f96aee3968ad7910fb11e6d", 58660608}, + AD_LISTEND + }, Common::EN_ANY, Common::kPlatformPC, ADGF_DEMO | GF_COMPRESSED, GUIO1(GUIO_NONE) }, }, - + { + // Tony Tough French "Collection Aventure" provided by Strangerke + { + "tony", + 0, + { + {"roasted.mpr", 0, "06203dbbc85fdd1e6dc8fc211c1a6207", 135911071}, + {"roasted.mpc", 0, "e890c6a41238827bdfa9874a65618b69", 374135}, + AD_LISTEND + }, + Common::FR_FRA, + Common::kPlatformPC, + ADGF_NO_FLAGS, + GUIO1(GUIO_NONE) + }, + }, + { + // Tony Tough German "Shoe Box" provided by Strangerke + { + "tony", + 0, + { + {"roasted.mpr", 0, "06203dbbc85fdd1e6dc8fc211c1a6207", 135911071}, + {"roasted.mpc", 0, "ccf7ab939a34de1b13df538596431684", 389554}, + AD_LISTEND + }, + Common::DE_DEU, + Common::kPlatformPC, + ADGF_NO_FLAGS, + GUIO1(GUIO_NONE) + }, + }, + { + // Tony Tough Italian provided by Fabio Barzagli + { + "tony", + 0, + { + {"roasted.mpr", 0, "06203dbbc85fdd1e6dc8fc211c1a6207", 135911071}, + {"roasted.mpc", 0, "1dc896cdb945170d7408598f803411c1", 380001}, + AD_LISTEND + }, + Common::IT_ITA, + Common::kPlatformPC, + ADGF_NO_FLAGS, + GUIO1(GUIO_NONE) + }, + }, + { + // Tony Tough Polish provided by Fabio Barzagli + { + "tony", + 0, + { + {"roasted.mpr", 0, "06203dbbc85fdd1e6dc8fc211c1a6207", 135911071}, + {"roasted.mpc", 0, "89733ea710669acc8e7900b115f4afef", 389625}, + AD_LISTEND + }, + Common::PL_POL, + Common::kPlatformPC, + ADGF_NO_FLAGS, + GUIO1(GUIO_NONE) + }, + }, { AD_TABLE_END_MARKER } }; -- cgit v1.2.3 From a1f6f8ceb19d65619dfd8e2477bffad773ba49ba Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 4 Jun 2012 23:45:36 +0200 Subject: TONY: Rename variables and functions in tony.h --- engines/tony/custom.cpp | 70 ++++++------- engines/tony/detection.cpp | 2 +- engines/tony/font.cpp | 18 ++-- engines/tony/game.cpp | 62 ++++++------ engines/tony/gfxengine.cpp | 6 +- engines/tony/inventory.cpp | 32 +++--- engines/tony/loc.cpp | 10 +- engines/tony/mpal/mpal.cpp | 14 +-- engines/tony/tony.cpp | 248 ++++++++++++++++++++++----------------------- engines/tony/tony.h | 126 +++++++++++------------ engines/tony/tonychar.cpp | 4 +- 11 files changed, 294 insertions(+), 298 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 96b78d0e83..47089f3214 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -240,7 +240,7 @@ VoiceHeader *SearchVoiceHeader(uint32 codehi, uint32 codelo) { return NULL; for (i = 0; i < _vm->_voices.size(); i++) - if (_vm->_voices[i].code == code) + if (_vm->_voices[i]._code == code) return &_vm->_voices[i]; return NULL; @@ -272,7 +272,7 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX _ctx->voice = NULL; if (_ctx->curVoc) { // Is positioned within the database of entries beginning at the first - _ctx->curOffset = _ctx->curVoc->offset; + _ctx->curOffset = _ctx->curVoc->_offset; // First time allocation _vm->_vdbFP.seek(_ctx->curOffset); @@ -509,7 +509,7 @@ DECLARE_CUSTOM_FUNCTION(CloseLocation)(CORO_PARAM, uint32, uint32, uint32, uint3 CORO_INVOKE_0(GLOBALS.WaitWipeEnd); } - _vm->StopMusic(4); + _vm->stopMusic(4); // On exit, unload and unfreeze CORO_INVOKE_2(GLOBALS.UnloadLocation, true, NULL); @@ -532,7 +532,7 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint } if (GLOBALS.lastTappeto != GLOBALS.tappeti[nLoc]) { - _vm->StopMusic(4); + _vm->stopMusic(4); } // On exit, unfreeze @@ -547,7 +547,7 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint if (GLOBALS.lastTappeto != GLOBALS.tappeti[nLoc]) { GLOBALS.lastTappeto = GLOBALS.tappeti[nLoc]; if (GLOBALS.lastTappeto != 0) - _vm->PlayMusic(4, tappetiFile[GLOBALS.lastTappeto], 0, true, 2000); + _vm->playMusic(4, tappetiFile[GLOBALS.lastTappeto], 0, true, 2000); } if (!GLOBALS.bNoOcchioDiBue) { @@ -1281,7 +1281,7 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui _ctx->startpt = GLOBALS.Loc->ScrollPosition(); - _ctx->dwStartTime = _vm->GetTime(); + _ctx->dwStartTime = _vm->getTime(); if (sX) _ctx->dwTotalTime = _ctx->dimx * (1000 / 35) / sX; @@ -1289,7 +1289,7 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui _ctx->dwTotalTime = _ctx->dimy * (1000 / 35) / sY; while ((_ctx->lx != 0 || _ctx->ly != 0) && !GLOBALS.bSkipIdle) { - _ctx->dwCurTime = _vm->GetTime() - _ctx->dwStartTime; + _ctx->dwCurTime = _vm->getTime() - _ctx->dwStartTime; if (_ctx->dwCurTime > _ctx->dwTotalTime) break; @@ -1362,11 +1362,11 @@ DECLARE_CUSTOM_FUNCTION(ChangeHotspot)(CORO_PARAM, uint32 dwCode, uint32 nX, uin DECLARE_CUSTOM_FUNCTION(AutoSave)(CORO_PARAM, uint32, uint32, uint32, uint32) { - _vm->AutoSave(coroParam); + _vm->autoSave(coroParam); } -DECLARE_CUSTOM_FUNCTION(Abort)(CORO_PARAM, uint32, uint32, uint32, uint32) { - _vm->Abort(); +DECLARE_CUSTOM_FUNCTION(AbortGame)(CORO_PARAM, uint32, uint32, uint32, uint32) { + _vm->abortGame(); } DECLARE_CUSTOM_FUNCTION(TremaSchermo)(CORO_PARAM, uint32 nScosse, uint32, uint32, uint32) { @@ -1378,12 +1378,12 @@ DECLARE_CUSTOM_FUNCTION(TremaSchermo)(CORO_PARAM, uint32 nScosse, uint32, uint32 CORO_BEGIN_CODE(_ctx); - _ctx->curTime = _vm->GetTime(); + _ctx->curTime = _vm->getTime(); _ctx->dirx = 1; _ctx->diry = 1; - while (_vm->GetTime() < _ctx->curTime + nScosse) { + while (_vm->getTime() < _ctx->curTime + nScosse) { CORO_INVOKE_0(GLOBALS.WaitFrame); GLOBALS.Freeze(); @@ -1482,8 +1482,8 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess _ctx->voice = NULL; if (_ctx->curVoc) { // Position within the database of entries, beginning at the first - _vm->_vdbFP.seek(_ctx->curVoc->offset); - _ctx->curOffset = _ctx->curVoc->offset; + _vm->_vdbFP.seek(_ctx->curVoc->_offset); + _ctx->curOffset = _ctx->curVoc->_offset; } for (_ctx->i = 0; _ctx->i < _ctx->msg->NumPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { @@ -1694,8 +1694,8 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes if (_ctx->curVoc) { // Position within the database of entries, beginning at the first // fseek(_vm->m_vdbFP, curVoc->offset, SEEK_SET); - _vm->_vdbFP.seek(_ctx->curVoc->offset); - _ctx->curOffset = _ctx->curVoc->offset; + _vm->_vdbFP.seek(_ctx->curVoc->_offset); + _ctx->curOffset = _ctx->curVoc->_offset; } for (_ctx->i = 0; _ctx->i < _ctx->msg->NumPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { @@ -1806,7 +1806,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg if (_ctx->curVoc) { // Position within the database of entries, beginning at the first - _vm->_vdbFP.seek(_ctx->curVoc->offset); + _vm->_vdbFP.seek(_ctx->curVoc->_offset); _vm->_theSound.CreateSfx(&_ctx->voice); _ctx->voice->LoadVoiceFromVDB(_vm->_vdbFP); _ctx->voice->SetLoop(false); @@ -2083,11 +2083,11 @@ void ThreadFadeInMusic(CORO_PARAM, const void *nMusic) { debug("Start FadeIn Music"); for (_ctx->i = 0; _ctx->i < 16; _ctx->i++) { - _vm->SetMusicVolume(nChannel, _ctx->i * 4); + _vm->setMusicVolume(nChannel, _ctx->i * 4); CORO_INVOKE_1(CoroScheduler.sleep, 100); } - _vm->SetMusicVolume(nChannel, 64); + _vm->setMusicVolume(nChannel, 64); debug("End FadeIn Music"); @@ -2106,23 +2106,23 @@ void ThreadFadeOutMusic(CORO_PARAM, const void *nMusic) { CORO_BEGIN_CODE(_ctx); - _ctx->startVolume = _vm->GetMusicVolume(nChannel); + _ctx->startVolume = _vm->getMusicVolume(nChannel); debug("Start FadeOut Music"); for (_ctx->i = 16; _ctx->i > 0 && !GLOBALS.bFadeOutStop; _ctx->i--) { if (_ctx->i * 4 < _ctx->startVolume) - _vm->SetMusicVolume(nChannel, _ctx->i * 4); + _vm->setMusicVolume(nChannel, _ctx->i * 4); CORO_INVOKE_1(CoroScheduler.sleep, 100); } if (!GLOBALS.bFadeOutStop) - _vm->SetMusicVolume(nChannel, 0); + _vm->setMusicVolume(nChannel, 0); // If there is a stacchetto, stop all if (nChannel == 2) - _vm->StopMusic(2); + _vm->stopMusic(2); debug("End FadeOut Music"); @@ -2152,28 +2152,28 @@ DECLARE_CUSTOM_FUNCTION(FadeInStacchetto)(CORO_PARAM, uint32, uint32, uint32, ui } DECLARE_CUSTOM_FUNCTION(StopSonoriz)(CORO_PARAM, uint32, uint32, uint32, uint32) { - _vm->StopMusic(GLOBALS.curSonoriz); + _vm->stopMusic(GLOBALS.curSonoriz); } DECLARE_CUSTOM_FUNCTION(StopStacchetto)(CORO_PARAM, uint32, uint32, uint32, uint32) { - _vm->StopMusic(2); + _vm->stopMusic(2); } DECLARE_CUSTOM_FUNCTION(MuteSonoriz)(CORO_PARAM, uint32, uint32, uint32, uint32) { - _vm->SetMusicVolume(GLOBALS.curSonoriz, 0); + _vm->setMusicVolume(GLOBALS.curSonoriz, 0); } DECLARE_CUSTOM_FUNCTION(DemuteSonoriz)(CORO_PARAM, uint32, uint32, uint32, uint32) { GLOBALS.bFadeOutStop = true; - _vm->SetMusicVolume(GLOBALS.curSonoriz, 64); + _vm->setMusicVolume(GLOBALS.curSonoriz, 64); } DECLARE_CUSTOM_FUNCTION(MuteStacchetto)(CORO_PARAM, uint32, uint32, uint32, uint32) { - _vm->SetMusicVolume(2, 0); + _vm->setMusicVolume(2, 0); } DECLARE_CUSTOM_FUNCTION(DemuteStacchetto)(CORO_PARAM, uint32, uint32, uint32, uint32) { - _vm->SetMusicVolume(2, 64); + _vm->setMusicVolume(2, 64); } @@ -2288,7 +2288,7 @@ DECLARE_CUSTOM_FUNCTION(OpenInitLoadMenu)(CORO_PARAM, uint32, uint32, uint32, ui CORO_BEGIN_CODE(_ctx); GLOBALS.Freeze(); - CORO_INVOKE_0(_vm->OpenInitLoadMenu); + CORO_INVOKE_0(_vm->openInitLoadMenu); GLOBALS.Unfreeze(); CORO_END_CODE; @@ -2301,7 +2301,7 @@ DECLARE_CUSTOM_FUNCTION(OpenInitOptions)(CORO_PARAM, uint32, uint32, uint32, uin CORO_BEGIN_CODE(_ctx); GLOBALS.Freeze(); - CORO_INVOKE_0(_vm->OpenInitOptions); + CORO_INVOKE_0(_vm->openInitOptions); GLOBALS.Unfreeze(); CORO_END_CODE; @@ -2357,13 +2357,13 @@ DECLARE_CUSTOM_FUNCTION(DoCredits)(CORO_PARAM, uint32 nMsg, uint32 dwTime, uint3 GLOBALS.LinkGraphicTask(&_ctx->text[_ctx->i]); } - _ctx->startTime = _vm->GetTime(); + _ctx->startTime = _vm->getTime(); - while (_ctx->startTime + dwTime * 1000 > _vm->GetTime()) { + while (_ctx->startTime + dwTime * 1000 > _vm->getTime()) { CORO_INVOKE_0(GLOBALS.WaitFrame); if (GLOBALS.Input->MouseLeftClicked() || GLOBALS.Input->MouseRightClicked()) break; - if (_vm->GetEngine()->GetInput().GetAsyncKeyState(Common::KEYCODE_TAB)) + if (_vm->getEngine()->GetInput().GetAsyncKeyState(Common::KEYCODE_TAB)) break; } @@ -2510,7 +2510,7 @@ ASSIGN(130, StacchettoFadeEnd) ASSIGN(120, TremaSchermo) ASSIGN(121, AutoSave) -ASSIGN(122, Abort) +ASSIGN(122, AbortGame) ASSIGN(131, NoOcchioDiBue) ASSIGN(132, SendFullscreenMsgStart) ASSIGN(133, SendFullscreenMsgEnd) diff --git a/engines/tony/detection.cpp b/engines/tony/detection.cpp index 1de1b70968..be45aba19f 100644 --- a/engines/tony/detection.cpp +++ b/engines/tony/detection.cpp @@ -146,7 +146,7 @@ int TonyMetaEngine::getMaximumSaveSlot() const { } void TonyMetaEngine::removeSaveState(const char *target, int slot) const { - Common::String filename = Tony::TonyEngine::GetSaveStateFileName(slot); + Common::String filename = Tony::TonyEngine::getSaveStateFileName(slot); g_system->getSavefileManager()->removeSavefile(filename); } diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 6b6778044d..567da3041c 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -2079,14 +2079,14 @@ void RMTextDialog::RemoveThis(CORO_PARAM, bool &result) { if (!(GLOBALS.bCfgDubbing && hCustomSkip2 != CORO_INVALID_PID_VALUE)) { if (GLOBALS.bCfgTimerizedText) { if (!m_bForceNoTime) { - if (_vm->GetTime() > (uint32)m_time + m_startTime) + if (_vm->getTime() > (uint32)m_time + m_startTime) return; } } } if (!m_bNoTab) { - if (_vm->GetEngine()->GetInput().GetAsyncKeyState(Common::KEYCODE_TAB)) + if (_vm->getEngine()->GetInput().GetAsyncKeyState(Common::KEYCODE_TAB)) return; } @@ -2100,14 +2100,14 @@ void RMTextDialog::RemoveThis(CORO_PARAM, bool &result) { // Erase the background else if (!(GLOBALS.bCfgDubbing && hCustomSkip2 != CORO_INVALID_PID_VALUE)) { if (!m_bForceNoTime) { - if (_vm->GetTime() > (uint32)m_time + m_startTime) + if (_vm->getTime() > (uint32)m_time + m_startTime) return; } } // If time is forced if (m_bForceTime) { - if (_vm->GetTime() > (uint32)m_time + m_startTime) + if (_vm->getTime() > (uint32)m_time + m_startTime) return; } @@ -2143,7 +2143,7 @@ void RMTextDialog::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *p CORO_BEGIN_CODE(_ctx); if (m_startTime == 0) - m_startTime = _vm->GetTime(); + m_startTime = _vm->getTime(); if (m_bShowed) { if (GLOBALS.bCfgSottotitoli || m_bAlwaysDisplay) { @@ -2483,7 +2483,7 @@ void RMDialogChoice::Show(CORO_PARAM, RMGfxTargetBuffer *bigBuf) { if (0) { m_bShow = true; } else { - _ctx->starttime = _vm->GetTime(); + _ctx->starttime = _vm->getTime(); _ctx->deltay = 480 - m_ptDrawPos.y; _ctx->destpt = m_ptDrawPos; m_ptDrawPos.Set(0, 480); @@ -2496,7 +2496,7 @@ void RMDialogChoice::Show(CORO_PARAM, RMGfxTargetBuffer *bigBuf) { while (_ctx->elaps < 700) { CORO_INVOKE_0(MainWaitFrame); MainFreeze(); - _ctx->elaps = _vm->GetTime() - _ctx->starttime; + _ctx->elaps = _vm->getTime() - _ctx->starttime; m_ptDrawPos.y = 480 - ((_ctx->deltay * 100) / 700 * _ctx->elaps) / 100; MainUnfreeze(); } @@ -2533,14 +2533,14 @@ void RMDialogChoice::Hide(CORO_PARAM) { CORO_BEGIN_CODE(_ctx); if (1) { - _ctx->starttime = _vm->GetTime(); + _ctx->starttime = _vm->getTime(); _ctx->deltay = 480 - m_ptDrawPos.y; _ctx->elaps = 0; while (_ctx->elaps < 700) { CORO_INVOKE_0(MainWaitFrame); MainFreeze(); - _ctx->elaps = _vm->GetTime() - _ctx->starttime; + _ctx->elaps = _vm->getTime() - _ctx->starttime; m_ptDrawPos.y = 480 - ((_ctx->deltay * 100) / 700 * (700 - _ctx->elaps)) / 100; MainUnfreeze(); } diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index a1954b95b2..42c33f2259 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -47,75 +47,75 @@ using namespace MPAL; /****************************************/ uint32 MainLoadLocation(int nLoc, RMPoint pt, RMPoint start) { - return _vm->GetEngine()->LoadLocation(nLoc, pt, start); + return _vm->getEngine()->LoadLocation(nLoc, pt, start); } void MainUnloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result) { - _vm->GetEngine()->UnloadLocation(coroParam, bDoOnExit, result); + _vm->getEngine()->UnloadLocation(coroParam, bDoOnExit, result); } void MainLinkGraphicTask(RMGfxTask *task) { - _vm->GetEngine()->LinkGraphicTask(task); + _vm->getEngine()->LinkGraphicTask(task); } void MainFreeze(void) { - _vm->GetEngine()->Freeze(); + _vm->getEngine()->Freeze(); } void MainUnfreeze(void) { - _vm->GetEngine()->Unfreeze(); + _vm->getEngine()->Unfreeze(); } void MainWaitFrame(CORO_PARAM) { - CoroScheduler.waitForSingleObject(coroParam, _vm->m_hEndOfFrame, CORO_INFINITE); + CoroScheduler.waitForSingleObject(coroParam, _vm->_hEndOfFrame, CORO_INFINITE); } void MainShowMouse(void) { - _vm->GetEngine()->EnableMouse(); + _vm->getEngine()->EnableMouse(); } void MainHideMouse(void) { - _vm->GetEngine()->DisableMouse(); + _vm->getEngine()->DisableMouse(); } void MainPlayMusic(int nChannel, const char *filename, int nFX, bool bLoop, int nSync) { - _vm->PlayMusic(nChannel, filename, nFX, bLoop, nSync); + _vm->playMusic(nChannel, filename, nFX, bLoop, nSync); } void MainDisableInput(void) { - _vm->GetEngine()->DisableInput(); + _vm->getEngine()->DisableInput(); } void MainEnableInput(void) { - _vm->GetEngine()->EnableInput(); + _vm->getEngine()->EnableInput(); } void MainInitWipe(int type) { - _vm->GetEngine()->InitWipe(type); + _vm->getEngine()->InitWipe(type); } void MainCloseWipe(void) { - _vm->GetEngine()->CloseWipe(); + _vm->getEngine()->CloseWipe(); } void MainWaitWipeEnd(CORO_PARAM) { - _vm->GetEngine()->WaitWipeEnd(coroParam); + _vm->getEngine()->WaitWipeEnd(coroParam); } void MainEnableGUI(void) { - _vm->GetEngine()->m_bGUIInterface = true; - _vm->GetEngine()->m_bGUIInventory = true; - _vm->GetEngine()->m_bGUIOption = true; + _vm->getEngine()->m_bGUIInterface = true; + _vm->getEngine()->m_bGUIInventory = true; + _vm->getEngine()->m_bGUIOption = true; } void MainDisableGUI(void) { - _vm->GetEngine()->m_bGUIInterface = false; - _vm->GetEngine()->m_bGUIInventory = false; - _vm->GetEngine()->m_bGUIOption = false; + _vm->getEngine()->m_bGUIInterface = false; + _vm->getEngine()->m_bGUIInventory = false; + _vm->getEngine()->m_bGUIOption = false; } void MainSetPalesati(bool bPalesati) { - _vm->GetEngine()->SetPalesati(bPalesati); + _vm->getEngine()->SetPalesati(bPalesati); } /****************************************************************************\ @@ -491,7 +491,7 @@ void RMOptionScreen::RefreshAll(CORO_PARAM) { if (m_bEditSaveName) { _ctx->thumb = new RMGfxSourceBuffer16; - _ctx->thumb->Init((byte *)_vm->GetThumbnail(), 640 / 4, 480 / 4); + _ctx->thumb->Init((byte *)_vm->getThumbnail(), 640 / 4, 480 / 4); if (m_nEditPos == 0) AddPrim(new RMGfxPrimitive(_ctx->thumb, RMPoint(48, 57))); @@ -989,7 +989,7 @@ bool RMOptionScreen::Close(void) { // Start fade out m_FadeStep++; - m_FadeTime = _vm->GetTime(); + m_FadeTime = _vm->getTime(); return true; } @@ -1097,7 +1097,7 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { } } -#define KEYPRESS(c) (_vm->GetEngine()->GetInput().GetAsyncKeyState(c)) +#define KEYPRESS(c) (_vm->getEngine()->GetInput().GetAsyncKeyState(c)) #define PROCESS_CHAR(cod,c) if (KEYPRESS(cod)) { \ m_EditName[strlen(m_EditName) +1 ] = '\0'; m_EditName[strlen(m_EditName)] = c; _ctx->bRefresh = true; } @@ -1154,7 +1154,7 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { // OK if (KEYPRESS(Common::KEYCODE_RETURN)) { m_bEditSaveName = false; - _vm->SaveState(m_statePos + m_nEditPos, m_EditName); + _vm->saveState(m_statePos + m_nEditPos, m_EditName); Close(); } @@ -1190,7 +1190,7 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { // There by saving or loading!!! if (m_nState == MENULOAD && m_curThumb[_ctx->i] != NULL) { // Caricamento - CORO_INVOKE_1(_vm->LoadState, m_statePos + _ctx->i); + CORO_INVOKE_1(_vm->loadState, m_statePos + _ctx->i); Close(); } else if (m_nState == MENUSAVE && (m_statePos != 0 || _ctx->i != 0)) { // Turn on edit mode @@ -1214,7 +1214,7 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { m_bQuitConfirm = false; _ctx->bRefresh = true; - _vm->Quit(); + _vm->quitGame(); } } else { if (m_ButtonQuit->IsActive()) { @@ -1280,7 +1280,7 @@ void RMOptionScreen::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive CORO_BEGIN_CODE(_ctx); - _ctx->curTime = _vm->GetTime(); + _ctx->curTime = _vm->getTime(); #define FADE_SPEED 20 #define SYNC (_ctx->curTime-m_FadeTime) / 25 @@ -1336,7 +1336,7 @@ void RMOptionScreen::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive if (m_FadeY > 480) { m_FadeY = 480; m_FadeStep++; - _vm->HideLocation(); + _vm->hideLocation(); } prim->SetSrc(RMRect(0, 480 - m_FadeY, 640, 480)); @@ -1346,7 +1346,7 @@ void RMOptionScreen::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive } else if (m_FadeStep == 7) { // Menu OFF - _vm->ShowLocation(); + _vm->showLocation(); m_FadeStep++; } else if (m_FadeStep == 8) { @@ -1398,7 +1398,7 @@ bool RMOptionScreen::LoadThumbnailFromSaveState(int nState, byte *lpDestBuf, RMS diff = 10; // Get the savegame filename for the given slot - buf = _vm->GetSaveStateFileName(nState); + buf = _vm->getSaveStateFileName(nState); // Try and open the savegame f = g_system->getSavefileManager()->openForLoading(buf); diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 3fa33d78ff..4642ee0ab7 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -109,7 +109,7 @@ void RMGfxEngine::OpenOptionScreen(CORO_PARAM, int type) { CORO_INVOKE_3(m_opt.InitSaveMenuOnly, m_bigBuf, false, _ctx->bRes); if (_ctx->bRes) { - _vm->PauseSound(true); + _vm->pauseSound(true); DisableInput(); m_inv.EndCombine(); @@ -119,7 +119,7 @@ void RMGfxEngine::OpenOptionScreen(CORO_PARAM, int type) { m_point.SetSpecialPointer(RMPointer::PTR_NONE); m_point.SetCustomPointer(NULL); EnableMouse(); - _vm->GrabThumbnail(); + _vm->grabThumbnail(); // Exists the IDLE to avoid premature death in loading m_bMustEnterMenu = true; @@ -161,7 +161,7 @@ void RMGfxEngine::DoFrame(CORO_PARAM, bool bDrawLocation) { DisableMouse(); EnableInput(); mpalStartIdlePoll(m_nCurLoc); - _vm->PauseSound(false); + _vm->pauseSound(false); } } diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index 539dd4e81b..1a245d9aba 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -343,7 +343,7 @@ bool RMInventory::LeftClick(const RMPoint &mpos, int &nCombineObj) { m_nCombine = m_inv[n - 1 + m_curPos]; nCombineObj = m_nCombine + 10000; - _vm->PlayUtilSFX(1); + _vm->playUtilSFX(1); return true; } } @@ -409,7 +409,7 @@ void RMInventory::RightClick(const RMPoint &mpos) { miniAction = 0; m_nSelectObj = n - 1; - _vm->PlayUtilSFX(0); + _vm->playUtilSFX(0); } } @@ -530,7 +530,7 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo g_system->unlockMutex(m_csModifyInterface); } - if (_vm->GetEngine()->GetInput().GetAsyncKeyState(Common::KEYCODE_i)) { + if (_vm->getEngine()->GetInput().GetAsyncKeyState(Common::KEYCODE_i)) { GLOBALS.bCfgInvLocked = !GLOBALS.bCfgInvLocked; } @@ -544,7 +544,7 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo if (!GLOBALS.bCfgInvNoScroll) { m_state = OPENING; m_curPutY = RM_SY - 1; - m_curPutTime = _vm->GetTime(); + m_curPutTime = _vm->getTime(); } else { m_state = OPENED; m_curPutY = RM_SY - 68; @@ -554,13 +554,13 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo if (!GLOBALS.bCfgInvNoScroll) { m_state = CLOSING; m_curPutY = RM_SY - 68; - m_curPutTime = _vm->GetTime(); + m_curPutTime = _vm->getTime(); } else { m_state = CLOSED; } } } else if (m_state == OPENING) { - while (m_curPutTime + INVSPEED < _vm->GetTime()) { + while (m_curPutTime + INVSPEED < _vm->getTime()) { m_curPutY -= 3; m_curPutTime += INVSPEED; } @@ -571,7 +571,7 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo } } else if (m_state == CLOSING) { - while (m_curPutTime + INVSPEED < _vm->GetTime()) { + while (m_curPutTime + INVSPEED < _vm->getTime()) { m_curPutY += 3; m_curPutTime += INVSPEED; } @@ -584,7 +584,7 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo if (!GLOBALS.bCfgInvNoScroll) { m_state = OPENING; m_curPutY = - 68; - m_curPutTime = _vm->GetTime(); + m_curPutTime = _vm->getTime(); } else { m_state = OPENED; m_curPutY = 0; @@ -594,13 +594,13 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo if (!GLOBALS.bCfgInvNoScroll) { m_state = CLOSING; m_curPutY = -2; - m_curPutTime = _vm->GetTime(); + m_curPutTime = _vm->getTime(); } else { m_state = CLOSED; } } } else if (m_state == OPENING) { - while (m_curPutTime + INVSPEED < _vm->GetTime()) { + while (m_curPutTime + INVSPEED < _vm->getTime()) { m_curPutY += 3; m_curPutTime += INVSPEED; } @@ -610,7 +610,7 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo m_curPutY = 0; } } else if (m_state == CLOSING) { - while (m_curPutTime + INVSPEED < _vm->GetTime()) { + while (m_curPutTime + INVSPEED < _vm->getTime()) { m_curPutY -= 3; m_curPutTime += INVSPEED; } @@ -635,19 +635,19 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo if (miniAction != 1) { miniInterface.SetPattern(2); miniAction = 1; - _vm->PlayUtilSFX(1); + _vm->playUtilSFX(1); } } else if (mpos.x >= startx + 40 && mpos.x < startx + 80) { if (miniAction != 2) { miniInterface.SetPattern(3); miniAction = 2; - _vm->PlayUtilSFX(1); + _vm->playUtilSFX(1); } } else if (mpos.x >= startx + 80 && mpos.x < startx + 108) { if (miniAction != 3) { miniInterface.SetPattern(4); miniAction = 3; - _vm->PlayUtilSFX(1); + _vm->playUtilSFX(1); } } else { miniInterface.SetPattern(1); @@ -799,7 +799,7 @@ void RMInterface::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr if (m_lastHotZone != _ctx->h) { m_lastHotZone = _ctx->h; - _vm->PlayUtilSFX(1); + _vm->playUtilSFX(1); } if (GLOBALS.bCfgInterTips) { @@ -836,7 +836,7 @@ void RMInterface::Clicked(const RMPoint &mousepos) { if (m_openStart.y + m_dimy > RM_SY) m_openStart.y = RM_SY - m_dimy; // Play the sound effect - _vm->PlayUtilSFX(0); + _vm->playUtilSFX(0); } bool RMInterface::Released(const RMPoint &mousepos, RMTonyAction &action) { diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 512c28605e..b3768ca330 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -156,7 +156,7 @@ int RMPattern::Init(RMSfx *sfx, bool bPlayP0, byte *bFlag) { int i; // Read the current time - m_nStartTime = _vm->GetTime(); + m_nStartTime = _vm->getTime(); m_nCurSlot = 0; // Find the first frame of the pattern @@ -209,7 +209,7 @@ int RMPattern::Init(RMSfx *sfx, bool bPlayP0, byte *bFlag) { } int RMPattern::Update(uint32 hEndPattern, byte &bFlag, RMSfx *sfx) { - int CurTime = _vm->GetTime(); + int CurTime = _vm->getTime(); // If the speed is 0, then the pattern never advances if (m_speed == 0) { @@ -420,7 +420,7 @@ void RMSfx::ReadFromStream(RMDataStream &ds, bool bLOX) { ds.Read(raw, size); // Create the sound effect - m_fx = _vm->CreateSFX(raw); + m_fx = _vm->createSFX(raw); m_fx->SetLoop(false); // Close the read buffer which is no longer needed @@ -2085,10 +2085,10 @@ bool RMLocation::Load(RMDataStream &ds) { m_items = new RMItem[m_nItems]; - _vm->FreezeTime(); + _vm->freezeTime(); for (i = 0; i < m_nItems && !ds.IsError(); i++) ds >> m_items[i]; - _vm->UnfreezeTime(); + _vm->unfreezeTime(); return ds.IsError(); } diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 12fc78c60c..16c530206c 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -621,7 +621,7 @@ void ScriptThread(CORO_PARAM, const void *param) { CORO_BEGIN_CODE(_ctx); - _ctx->dwStartTime = _vm->GetTime(); + _ctx->dwStartTime = _vm->getTime(); _ctx->numHandles = 0; // debugC(DEBUG_BASIC, kTonyDebugMPAL, "PlayScript(): Moments: %u\n",s->nMoments); @@ -629,9 +629,9 @@ void ScriptThread(CORO_PARAM, const void *param) { // Sleep for the required time if (s->Moment[_ctx->i].dwTime == -1) { CORO_INVOKE_4(CoroScheduler.waitForMultipleObjects, _ctx->numHandles, cfHandles, true, CORO_INFINITE); - _ctx->dwStartTime = _vm->GetTime(); + _ctx->dwStartTime = _vm->getTime(); } else { - _ctx->dwCurTime = _vm->GetTime(); + _ctx->dwCurTime = _vm->getTime(); if (_ctx->dwCurTime < _ctx->dwStartTime + (s->Moment[_ctx->i].dwTime * 100)) { // debugC(DEBUG_BASIC, kTonyDebugMPAL, "PlayScript(): Sleeping %lums\n",_ctx->dwStartTime+(s->Moment[_ctx->i].dwTime*100)-_ctx->dwCurTime); CORO_INVOKE_1(CoroScheduler.sleep, _ctx->dwStartTime+(s->Moment[_ctx->i].dwTime * 100) - _ctx->dwCurTime); @@ -771,7 +771,7 @@ void ShutUpActionThread(CORO_PARAM, const void *param) { _ctx->slotNumber = _vm->_initialLoadSlotNumber; _vm->_initialLoadSlotNumber = -1; - CORO_INVOKE_1(_vm->LoadState, _ctx->slotNumber); + CORO_INVOKE_1(_vm->loadState, _ctx->slotNumber); } @@ -903,7 +903,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { CopyMemory(_ctx->MyActions[_ctx->k].CmdNum, _ctx->curItem->Action[_ctx->j].CmdNum, MAX_COMMANDS_PER_ACTION * sizeof(uint16)); - _ctx->MyActions[_ctx->k].dwLastTime = _vm->GetTime(); + _ctx->MyActions[_ctx->k].dwLastTime = _vm->getTime(); _ctx->k++; } } @@ -918,7 +918,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { while (1) { /* Cerchiamo tra tutte le idle actions quella a cui manca meno tempo per l'esecuzione */ - _ctx->curTime = _vm->GetTime(); + _ctx->curTime = _vm->getTime(); _ctx->dwSleepTime = (uint32)-1L; for (_ctx->k = 0;_ctx->k<_ctx->nIdleActions;_ctx->k++) @@ -944,7 +944,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { _ctx->MyThreads[_ctx->i].nItem = 0; } - _ctx->curTime = _vm->GetTime(); + _ctx->curTime = _vm->getTime(); /* Loop through all the necessary idle actions */ for (_ctx->k = 0; _ctx->k < _ctx->nIdleActions; _ctx->k++) diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index da63c23bab..c2350d14e4 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -59,7 +59,7 @@ TonyEngine::TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc) : Eng TonyEngine::~TonyEngine() { // Close the voice database - CloseVoiceDatabase(); + closeVoiceDatabase(); // Reset the coroutine scheduler CoroScheduler.reset(); @@ -71,12 +71,12 @@ TonyEngine::~TonyEngine() { * Run the game */ Common::Error TonyEngine::run() { - Common::ErrorCode result = Init(); + Common::ErrorCode result = init(); if (result != Common::kNoError) return result; - Play(); - Close(); + play(); + close(); return Common::kNoError; } @@ -84,7 +84,7 @@ Common::Error TonyEngine::run() { /** * Initialise the game */ -Common::ErrorCode TonyEngine::Init() { +Common::ErrorCode TonyEngine::init() { if (isCompressed()) { Common::SeekableReadStream *stream = SearchMan.createReadStreamForMember("data1.cab"); if (!stream) @@ -97,11 +97,11 @@ Common::ErrorCode TonyEngine::Init() { SearchMan.add("data1.cab", cabinet); } - m_hEndOfFrame = CoroScheduler.createEvent(false, false); + _hEndOfFrame = CoroScheduler.createEvent(false, false); - m_bPaused = false; - m_bDrawLocation = true; - m_startTime = g_system->getMillis(); + _bPaused = false; + _bDrawLocation = true; + _startTime = g_system->getMillis(); // Init static class fields RMText::InitStatics(); @@ -114,8 +114,8 @@ Common::ErrorCode TonyEngine::Init() { _window.Init(); // Initialise the function list - Common::fill(FuncList, FuncList + 300, (LPCUSTOMFUNCTION)NULL); - InitCustomFunctionMap(); + Common::fill(_funcList, _funcList + 300, (LPCUSTOMFUNCTION)NULL); + initCustomFunctionMap(); // Initializes MPAL system, passing the custom functions list Common::File f; @@ -123,17 +123,17 @@ Common::ErrorCode TonyEngine::Init() { return Common::kReadingFailed; f.close(); - if (!mpalInit("ROASTED.MPC", "ROASTED.MPR", FuncList, FuncListStrings)) + if (!mpalInit("ROASTED.MPC", "ROASTED.MPR", _funcList, _funcListStrings)) return Common::kUnknownError; // Initialise the update resources _resUpdate.Init("ROASTED.MPU"); // Initialise the music - InitMusic(); + initMusic(); // Initialise the voices database - if (!OpenVoiceDatabase()) + if (!openVoiceDatabase()) return Common::kReadingFailed; // Initialise the boxes @@ -144,7 +144,7 @@ Common::ErrorCode TonyEngine::Init() { _theEngine.Init(); // Allocate space for thumbnails when saving the game - m_curThumbnail = new uint16[160 * 120]; + _curThumbnail = new uint16[160 * 120]; // Set up global defaults GLOBALS.bCfgInvLocked = false; @@ -164,13 +164,13 @@ Common::ErrorCode TonyEngine::Init() { GLOBALS.nCfgDubbingVolume = 10; GLOBALS.nCfgMusicVolume = 7; GLOBALS.nCfgSFXVolume = 10; - m_bQuitNow = false; + _bQuitNow = false; return Common::kNoError; } -void TonyEngine::InitCustomFunctionMap() { - INIT_CUSTOM_FUNCTION(FuncList, FuncListStrings); +void TonyEngine::initCustomFunctionMap() { + INIT_CUSTOM_FUNCTION(_funcList, _funcListStrings); } /** @@ -180,8 +180,8 @@ void TonyEngine::GUIError(const Common::String &msg) { GUIErrorMessage(msg); } -void TonyEngine::PlayMusic(int nChannel, const char *fn, int nFX, bool bLoop, int nSync) { - warning("TODO: TonyEngine::PlayMusic"); +void TonyEngine::playMusic(int nChannel, const char *fn, int nFX, bool bLoop, int nSync) { + warning("TODO: TonyEngine::playMusic"); // g_system->lockMutex(csMusic); if (nChannel < 4) @@ -192,8 +192,8 @@ void TonyEngine::PlayMusic(int nChannel, const char *fn, int nFX, bool bLoop, in case 0: case 1: case 2: - m_stream[nChannel]->Stop(); - m_stream[nChannel]->UnloadFile(); + _stream[nChannel]->Stop(); + _stream[nChannel]->UnloadFile(); break; case 22: @@ -222,7 +222,7 @@ void TonyEngine::PlayMusic(int nChannel, const char *fn, int nFX, bool bLoop, in else nextChannel = nChannel + 1; DWORD id; - HANDLE hThread = CreateThread(NULL, 10240, (LPTHREAD_START_ROUTINE)DoNextMusic, m_stream, 0, &id); + HANDLE hThread = CreateThread(NULL, 10240, (LPTHREAD_START_ROUTINE)DoNextMusic, _stream, 0, &id); SetThreadPriority(hThread, THREAD_PRIORITY_HIGHEST); } else if (nFX == 44) { // Cambia canale e lascia finire il primo if (flipflop) @@ -230,103 +230,103 @@ void TonyEngine::PlayMusic(int nChannel, const char *fn, int nFX, bool bLoop, in else nextChannel = nChannel + 1; - m_stream[nextChannel]->Stop(); - m_stream[nextChannel]->UnloadFile(); + _stream[nextChannel]->Stop(); + _stream[nextChannel]->UnloadFile(); if (!getIsDemo()) { - if (!m_stream[nextChannel]->LoadFile(path_buffer, FPCODEC_ADPCM, nSync)) + if (!_stream[nextChannel]->LoadFile(path_buffer, FPCODEC_ADPCM, nSync)) theGame.Abort(); } else { - m_stream[nextChannel]->LoadFile(path_buffer, FPCODEC_ADPCM, nSync); + _stream[nextChannel]->LoadFile(path_buffer, FPCODEC_ADPCM, nSync); } - m_stream[nextChannel]->SetLoop(bLoop); - m_stream[nextChannel]->Play(); + _stream[nextChannel]->SetLoop(bLoop); + _stream[nextChannel]->Play(); flipflop = 1 - flipflop; } else { if (!getIsDemo()) { - if (!m_stream[nChannel]->LoadFile(path_buffer, FPCODEC_ADPCM, nSync)) + if (!_stream[nChannel]->LoadFile(path_buffer, FPCODEC_ADPCM, nSync)) theGame.Abort(); } else { - m_stream[nChannel]->LoadFile(path_buffer, FPCODEC_ADPCM, nSync); + _stream[nChannel]->LoadFile(path_buffer, FPCODEC_ADPCM, nSync); } - m_stream[nChannel]->SetLoop(bLoop); - m_stream[nChannel]->Play(); + _stream[nChannel]->SetLoop(bLoop); + _stream[nChannel]->Play(); } #endif // g_system->unlockMutex(csMusic); } -void TonyEngine::PlaySFX(int nChannel, int nFX) { - if (m_sfx[nChannel] == NULL) +void TonyEngine::playSFX(int nChannel, int nFX) { + if (_sfx[nChannel] == NULL) return; switch (nFX) { case 0: - m_sfx[nChannel]->SetLoop(false); + _sfx[nChannel]->SetLoop(false); break; case 1: - m_sfx[nChannel]->SetLoop(true); + _sfx[nChannel]->SetLoop(true); break; } - m_sfx[nChannel]->Play(); + _sfx[nChannel]->Play(); } -void TonyEngine::StopMusic(int nChannel) { +void TonyEngine::stopMusic(int nChannel) { // g_system->lockMutex(csMusic); if (nChannel < 4) - m_stream[nChannel + GLOBALS.flipflop]->Stop(); + _stream[nChannel + GLOBALS.flipflop]->Stop(); else - m_stream[nChannel]->Stop(); + _stream[nChannel]->Stop(); // g_system->unlockMutex(csMusic); } -void TonyEngine::StopSFX(int nChannel) { - m_sfx[nChannel]->Stop(); +void TonyEngine::stopSFX(int nChannel) { + _sfx[nChannel]->Stop(); } -void TonyEngine::PlayUtilSFX(int nChannel, int nFX) { - if (m_utilSfx[nChannel] == NULL) +void TonyEngine::playUtilSFX(int nChannel, int nFX) { + if (_utilSfx[nChannel] == NULL) return; switch (nFX) { case 0: - m_utilSfx[nChannel]->SetLoop(false); + _utilSfx[nChannel]->SetLoop(false); break; case 1: - m_utilSfx[nChannel]->SetLoop(true); + _utilSfx[nChannel]->SetLoop(true); break; } - m_utilSfx[nChannel]->SetVolume(52); - m_utilSfx[nChannel]->Play(); + _utilSfx[nChannel]->SetVolume(52); + _utilSfx[nChannel]->Play(); } -void TonyEngine::StopUtilSFX(int nChannel) { - m_utilSfx[nChannel]->Stop(); +void TonyEngine::stopUtilSFX(int nChannel) { + _utilSfx[nChannel]->Stop(); } -void TonyEngine::PreloadSFX(int nChannel, const char *fn) { - if (m_sfx[nChannel] != NULL) { - m_sfx[nChannel]->Stop(); - m_sfx[nChannel]->Release(); - m_sfx[nChannel] = NULL; +void TonyEngine::preloadSFX(int nChannel, const char *fn) { + if (_sfx[nChannel] != NULL) { + _sfx[nChannel]->Stop(); + _sfx[nChannel]->Release(); + _sfx[nChannel] = NULL; } - _theSound.CreateSfx(&m_sfx[nChannel]); + _theSound.CreateSfx(&_sfx[nChannel]); - m_sfx[nChannel]->LoadFile(fn, FPCODEC_ADPCM); + _sfx[nChannel]->LoadFile(fn, FPCODEC_ADPCM); } -FPSFX *TonyEngine::CreateSFX(byte *buf) { +FPSFX *TonyEngine::createSFX(byte *buf) { FPSFX *sfx; _theSound.CreateSfx(&sfx); @@ -334,106 +334,105 @@ FPSFX *TonyEngine::CreateSFX(byte *buf) { return sfx; } -void TonyEngine::PreloadUtilSFX(int nChannel, const char *fn) { - warning("TonyEngine::PreloadUtilSFX"); +void TonyEngine::preloadUtilSFX(int nChannel, const char *fn) { + warning("TonyEngine::preloadUtilSFX"); } -void TonyEngine::UnloadAllSFX(void) { - warning("TonyEngine::UnloadAllSFX"); +void TonyEngine::unloadAllSFX(void) { + warning("TonyEngine::unloadAllSFX"); } -void TonyEngine::UnloadAllUtilSFX(void) { - warning("TonyEngine::UnloadAllUtilSFX"); +void TonyEngine::unloadAllUtilSFX(void) { + warning("TonyEngine::unloadAllUtilSFX"); } -void TonyEngine::InitMusic() { +void TonyEngine::initMusic() { int i; _theSound.Init(/*_window*/); _theSound.SetMasterVolume(63); for (i = 0; i < 6; i++) - _theSound.CreateStream(&m_stream[i]); + _theSound.CreateStream(&_stream[i]); for (i = 0; i < MAX_SFX_CHANNELS; i++) { - m_sfx[i] = m_utilSfx[i] = NULL; + _sfx[i] = _utilSfx[i] = NULL; } // Create the mutex for controlling music access // csMusic = g_system->createMutex(); // Preload sound effects - PreloadUtilSFX(0, "U01.ADP"); // Reversed!! - PreloadUtilSFX(1, "U02.ADP"); + preloadUtilSFX(0, "U01.ADP"); // Reversed!! + preloadUtilSFX(1, "U02.ADP"); } -void TonyEngine::CloseMusic() { +void TonyEngine::closeMusic() { for (int i = 0; i < 6; i++) { - m_stream[i]->Stop(); - m_stream[i]->UnloadFile(); - m_stream[i]->Release(); + _stream[i]->Stop(); + _stream[i]->UnloadFile(); + _stream[i]->Release(); } // g_system->deleteMutex(csMusic); - UnloadAllSFX(); - UnloadAllUtilSFX(); + unloadAllSFX(); + unloadAllUtilSFX(); } -void TonyEngine::PauseSound(bool bPause) { +void TonyEngine::pauseSound(bool bPause) { } -void TonyEngine::SetMusicVolume(int nChannel, int volume) { +void TonyEngine::setMusicVolume(int nChannel, int volume) { } -int TonyEngine::GetMusicVolume(int nChannel) { +int TonyEngine::getMusicVolume(int nChannel) { return 255; } - -Common::String TonyEngine::GetSaveStateFileName(int n) { +Common::String TonyEngine::getSaveStateFileName(int n) { return Common::String::format("tony.%03d", n); } -void TonyEngine::AutoSave(CORO_PARAM) { +void TonyEngine::autoSave(CORO_PARAM) { CORO_BEGIN_CONTEXT; Common::String buf; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - GrabThumbnail(); + grabThumbnail(); CORO_INVOKE_0(MainWaitFrame); CORO_INVOKE_0(MainWaitFrame); MainFreeze(); - _ctx->buf = GetSaveStateFileName(0); - _theEngine.SaveState(_ctx->buf, (byte *)m_curThumbnail, "Autosave"); + _ctx->buf = getSaveStateFileName(0); + _theEngine.SaveState(_ctx->buf, (byte *)_curThumbnail, "Autosave"); MainUnfreeze(); CORO_END_CODE; } -void TonyEngine::SaveState(int n, const char *name) { - Common::String buf = GetSaveStateFileName(n); - _theEngine.SaveState(buf.c_str(), (byte *)m_curThumbnail, name); +void TonyEngine::saveState(int n, const char *name) { + Common::String buf = getSaveStateFileName(n); + _theEngine.SaveState(buf.c_str(), (byte *)_curThumbnail, name); } -void TonyEngine::LoadState(CORO_PARAM, int n) { +void TonyEngine::loadState(CORO_PARAM, int n) { CORO_BEGIN_CONTEXT; Common::String buf; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - _ctx->buf = GetSaveStateFileName(n); + _ctx->buf = getSaveStateFileName(n); CORO_INVOKE_1(_theEngine.LoadState, _ctx->buf.c_str()); CORO_END_CODE; } -bool TonyEngine::OpenVoiceDatabase() { +bool TonyEngine::openVoiceDatabase() { char id[4]; uint32 numfiles; @@ -459,9 +458,9 @@ bool TonyEngine::OpenVoiceDatabase() { for (uint32 i = 0; i < numfiles; ++i) { VoiceHeader vh; - vh.offset = _vdbFP.readUint32LE(); - vh.code = _vdbFP.readUint32LE(); - vh.parts = _vdbFP.readUint32LE(); + vh._offset = _vdbFP.readUint32LE(); + vh._code = _vdbFP.readUint32LE(); + vh._parts = _vdbFP.readUint32LE(); _voices.push_back(vh); } @@ -469,7 +468,7 @@ bool TonyEngine::OpenVoiceDatabase() { return true; } -void TonyEngine::CloseVoiceDatabase() { +void TonyEngine::closeVoiceDatabase() { if (_vdbFP.isOpen()) _vdbFP.close(); @@ -477,23 +476,23 @@ void TonyEngine::CloseVoiceDatabase() { _voices.clear(); } -void TonyEngine::GrabThumbnail(void) { - _window.GrabThumbnail(m_curThumbnail); +void TonyEngine::grabThumbnail(void) { + _window.GrabThumbnail(_curThumbnail); } -void TonyEngine::OptionScreen(void) { +void TonyEngine::optionScreen(void) { } -void TonyEngine::OpenInitLoadMenu(CORO_PARAM) { +void TonyEngine::openInitLoadMenu(CORO_PARAM) { _theEngine.OpenOptionScreen(coroParam, 1); } -void TonyEngine::OpenInitOptions(CORO_PARAM) { +void TonyEngine::openInitOptions(CORO_PARAM) { _theEngine.OpenOptionScreen(coroParam, 2); } -void TonyEngine::Abort(void) { - m_bQuitNow = true; +void TonyEngine::abortGame(void) { + _bQuitNow = true; } /** @@ -504,7 +503,7 @@ void TonyEngine::Abort(void) { * process. If it ever proves a problem, we may have to look into whether it's feasible to have it still remain * in the outer 'main' process. */ -void TonyEngine::PlayProcess(CORO_PARAM, const void *param) { +void TonyEngine::playProcess(CORO_PARAM, const void *param) { CORO_BEGIN_CONTEXT; Common::String fn; CORO_END_CONTEXT(_ctx); @@ -517,7 +516,7 @@ void TonyEngine::PlayProcess(CORO_PARAM, const void *param) { for (;;) { // If a savegame needs to be loaded, then do so if (_vm->_loadSlotNumber != -1 && GLOBALS.GfxEngine != NULL) { - _ctx->fn = GetSaveStateFileName(_vm->_loadSlotNumber); + _ctx->fn = getSaveStateFileName(_vm->_loadSlotNumber); CORO_INVOKE_1(GLOBALS.GfxEngine->LoadState, _ctx->fn); _vm->_loadSlotNumber = -1; } @@ -526,13 +525,13 @@ void TonyEngine::PlayProcess(CORO_PARAM, const void *param) { CORO_INVOKE_1(CoroScheduler.sleep, 50); // Call the engine to handle the next frame - CORO_INVOKE_1(_vm->_theEngine.DoFrame, _vm->m_bDrawLocation); + CORO_INVOKE_1(_vm->_theEngine.DoFrame, _vm->_bDrawLocation); // Warns that a frame is finished - CoroScheduler.pulseEvent(_vm->m_hEndOfFrame); + CoroScheduler.pulseEvent(_vm->_hEndOfFrame); // Handle drawing the frame - if (!_vm->m_bPaused) { + if (!_vm->_bPaused) { if (!_vm->_theEngine.m_bWiping) _vm->_window.GetNewFrame(_vm->_theEngine, NULL); else @@ -552,12 +551,12 @@ void TonyEngine::PlayProcess(CORO_PARAM, const void *param) { /** * Play the game */ -void TonyEngine::Play(void) { +void TonyEngine::play(void) { // Create the game player process - CoroScheduler.createProcess(PlayProcess, NULL); + CoroScheduler.createProcess(playProcess, NULL); // Loop through calling the scheduler until it's time for the game to quit - while (!shouldQuit() && !m_bQuitNow) { + while (!shouldQuit() && !_bQuitNow) { // Delay for a brief amount g_system->delayMillis(10); @@ -566,18 +565,16 @@ void TonyEngine::Play(void) { } } - - -void TonyEngine::Close(void) { - CloseMusic(); - CoroScheduler.closeEvent(m_hEndOfFrame); +void TonyEngine::close(void) { + closeMusic(); + CoroScheduler.closeEvent(_hEndOfFrame); _theBoxes.Close(); _theEngine.Close(); _window.Close(); - delete[] m_curThumbnail; + delete[] _curThumbnail; } -void TonyEngine::SwitchFullscreen(bool bFull) { +void TonyEngine::switchFullscreen(bool bFull) { _window.SwitchFullscreen(bFull); _theEngine.SwitchFullscreen(bFull); } @@ -586,21 +583,20 @@ void TonyEngine::GDIControl(bool bCon) { _theEngine.GDIControl(bCon); } - -void TonyEngine::FreezeTime(void) { - m_bTimeFreezed = true; - m_nTimeFreezed = GetTime() - m_startTime; +void TonyEngine::freezeTime(void) { + _bTimeFreezed = true; + _nTimeFreezed = getTime() - _startTime; } -void TonyEngine::UnfreezeTime(void) { - m_bTimeFreezed = false; +void TonyEngine::unfreezeTime(void) { + _bTimeFreezed = false; } /** * Returns the millisecond timer */ -uint32 TonyEngine::GetTime() { +uint32 TonyEngine::getTime() { return g_system->getMillis(); } @@ -621,9 +617,9 @@ Common::Error TonyEngine::saveGameState(int slot, const Common::String &desc) { return Common::kUnknownError; RMSnapshot s; - s.GrabScreenshot(*GLOBALS.GfxEngine, 4, m_curThumbnail); + s.GrabScreenshot(*GLOBALS.GfxEngine, 4, _curThumbnail); - GLOBALS.GfxEngine->SaveState(GetSaveStateFileName(slot), (byte *)m_curThumbnail, desc); + GLOBALS.GfxEngine->SaveState(getSaveStateFileName(slot), (byte *)_curThumbnail, desc); return Common::kNoError; } diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 78e9abd476..83543f8022 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -72,32 +72,32 @@ struct TonyGameDescription; #define MAX_SFX_CHANNELS 32 struct VoiceHeader { - int offset; - int code; - int parts; + int _offset; + int _code; + int _parts; }; #define VOICE_HEADER_SIZE 12 class TonyEngine : public Engine { private: - Common::ErrorCode Init(); - void InitMusic(); - void CloseMusic(); - bool OpenVoiceDatabase(); - void CloseVoiceDatabase(); - void InitCustomFunctionMap(); - static void PlayProcess(CORO_PARAM, const void *param); + Common::ErrorCode init(); + void initMusic(); + void closeMusic(); + bool openVoiceDatabase(); + void closeVoiceDatabase(); + void initCustomFunctionMap(); + static void playProcess(CORO_PARAM, const void *param); protected: // Engine APIs virtual Common::Error run(); virtual bool hasFeature(EngineFeature f) const; public: - LPCUSTOMFUNCTION FuncList[300]; - Common::String FuncListStrings[300]; + LPCUSTOMFUNCTION _funcList[300]; + Common::String _funcListStrings[300]; Common::RandomSource _randomSource; MPAL::MemoryManager _memoryManager; RMResUpdate _resUpdate; - uint32 m_hEndOfFrame; + uint32 _hEndOfFrame; Common::File _vdbFP; Common::Array _voices; FPSOUND _theSound; @@ -115,14 +115,14 @@ public: DD_BASE2 }; - FPSTREAM *m_stream[6]; - FPSFX *m_sfx[MAX_SFX_CHANNELS]; - FPSFX *m_utilSfx[MAX_SFX_CHANNELS]; - RMFont *fonts[2]; - bool m_bPaused; - bool m_bDrawLocation; - int m_startTime; - uint16 *m_curThumbnail; + FPSTREAM *_stream[6]; + FPSFX *_sfx[MAX_SFX_CHANNELS]; + FPSFX *_utilSfx[MAX_SFX_CHANNELS]; +// RMFont *_fonts[2]; + bool _bPaused; + bool _bDrawLocation; + int _startTime; + uint16 *_curThumbnail; int _initialLoadSlotNumber; int _loadSlotNumber; @@ -131,9 +131,9 @@ public: RMWindow _window; RMGfxEngine _theEngine; - bool m_bQuitNow; - bool m_bTimeFreezed; - int m_nTimeFreezed; + bool _bQuitNow; + bool _bTimeFreezed; + int _nTimeFreezed; public: TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc); virtual ~TonyEngine(); @@ -144,7 +144,7 @@ public: uint16 getVersion() const; bool getIsDemo() const; bool isCompressed() const; - RMGfxEngine *GetEngine() { + RMGfxEngine *getEngine() { return &_theEngine; } void GUIError(const Common::String &msg); @@ -157,70 +157,70 @@ public: // Warn when are being controlled by the GDI void GDIControl(bool bCon); - void Play(); - void Close(); - void Abort(); + void play(); + void close(); + void abortGame(); - void GetDataDirectory(DATADIR dir, char *path); + void getDataDirectory(DATADIR dir, char *path); - void SwitchFullscreen(bool bFull); - void OptionScreen(void); + void switchFullscreen(bool bFull); + void optionScreen(void); - void ShowLocation(void) { - m_bDrawLocation = true; + void showLocation(void) { + _bDrawLocation = true; } - void HideLocation(void) { - m_bDrawLocation = false; + void hideLocation(void) { + _bDrawLocation = false; } // Reads the time - uint32 GetTime(void); - void FreezeTime(void); - void UnfreezeTime(void); + uint32 getTime(void); + void freezeTime(void); + void unfreezeTime(void); // Music // ****** - void PlayMusic(int nChannel, const char *fn, int nFX, bool bLoop, int nSync); - void StopMusic(int nChannel); + void playMusic(int nChannel, const char *fn, int nFX, bool bLoop, int nSync); + void stopMusic(int nChannel); - void PlaySFX(int nSfx, int nFX = 0); - void StopSFX(int nSfx); + void playSFX(int nSfx, int nFX = 0); + void stopSFX(int nSfx); - void PlayUtilSFX(int nSfx, int nFX = 0); - void StopUtilSFX(int nSfx); + void playUtilSFX(int nSfx, int nFX = 0); + void stopUtilSFX(int nSfx); - FPSFX *CreateSFX(byte *buf); + FPSFX *createSFX(byte *buf); - void PreloadSFX(int nSfx, const char *fn); - void UnloadAllSFX(void); + void preloadSFX(int nSfx, const char *fn); + void unloadAllSFX(void); - void PreloadUtilSFX(int nSfx, const char *fn); - void UnloadAllUtilSFX(void); + void preloadUtilSFX(int nSfx, const char *fn); + void unloadAllUtilSFX(void); // Stop all the audio - void PauseSound(bool bPause); + void pauseSound(bool bPause); - void SetMusicVolume(int nChannel, int volume); - int GetMusicVolume(int nChannel); + void setMusicVolume(int nChannel, int volume); + int getMusicVolume(int nChannel); // Handle saving - void AutoSave(CORO_PARAM); - void SaveState(int n, const char *name); - void LoadState(CORO_PARAM, int n); - static Common::String GetSaveStateFileName(int n); + void autoSave(CORO_PARAM); + void saveState(int n, const char *name); + void loadState(CORO_PARAM, int n); + static Common::String getSaveStateFileName(int n); // Get a thumbnail - void GrabThumbnail(void); - uint16 *GetThumbnail(void) { - return m_curThumbnail; + void grabThumbnail(void); + uint16 *getThumbnail(void) { + return _curThumbnail; } - void Quit(void) { - m_bQuitNow = true; + void quitGame(void) { + _bQuitNow = true; } - void OpenInitLoadMenu(CORO_PARAM); - void OpenInitOptions(CORO_PARAM); + void openInitLoadMenu(CORO_PARAM); + void openInitOptions(CORO_PARAM); }; // Global reference to the TonyEngine object diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index 71f95f8133..212899cde3 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -119,7 +119,7 @@ void RMTony::Init(void) { ds.Close(); m_body.SetPattern(0); - m_nTimeLastStep = _vm->GetTime(); + m_nTimeLastStep = _vm->getTime(); } @@ -141,7 +141,7 @@ void RMTony::DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int curLoc) { SetSpeed(GLOBALS.nCfgTonySpeed); // Runs the normal character movement - _ctx->time = _vm->GetTime(); + _ctx->time = _vm->getTime(); do { m_nTimeLastStep += (1000 / 40); -- cgit v1.2.3 From 7b547a78cc08627dfedd6a08a3e1afb58d8193fd Mon Sep 17 00:00:00 2001 From: D G Turner Date: Mon, 4 Jun 2012 22:54:53 +0100 Subject: TONY: Fix english CD detection entry. --- engines/tony/detection_tables.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/tony/detection_tables.h b/engines/tony/detection_tables.h index 36548c4e3c..97bcc30f4b 100644 --- a/engines/tony/detection_tables.h +++ b/engines/tony/detection_tables.h @@ -30,8 +30,7 @@ static const TonyGameDescription gameDescriptions[] = { 0, { {"roasted.mpr", 0, "06203dbbc85fdd1e6dc8fc211c1a6207", 135911071}, - // Fake md5 : to be fixed! - {"roasted.mpc", 0, "bad97eae03a4db3e99565e39b0b3c06a", 16384}, + {"roasted.mpc", 0, "57c4a3860cf899443c357e0078ea6f49", 366773}, AD_LISTEND }, Common::EN_ANY, -- cgit v1.2.3 From 014330a538244b0e33bcf230cc5e84c28977f096 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 5 Jun 2012 00:02:15 +0200 Subject: TONY: Rename variables and functions in input.h --- engines/tony/custom.cpp | 8 ++++---- engines/tony/font.cpp | 4 ++-- engines/tony/game.cpp | 8 ++++---- engines/tony/gfxengine.cpp | 50 +++++++++++++++++++++++----------------------- engines/tony/input.cpp | 12 +++++------ engines/tony/input.h | 26 ++++++++++++------------ engines/tony/inventory.cpp | 2 +- 7 files changed, 55 insertions(+), 55 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 47089f3214..1ed7c8b5a6 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -2020,10 +2020,10 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr GLOBALS.Pointer->SetSpecialPointer(GLOBALS.Pointer->PTR_NONE); MainShowMouse(); - while (!(GLOBALS.Input->MouseLeftClicked() && ((_ctx->sel = _ctx->dc.GetSelection()) != -1))) { + while (!(GLOBALS.Input->mouseLeftClicked() && ((_ctx->sel = _ctx->dc.GetSelection()) != -1))) { CORO_INVOKE_0(GLOBALS.WaitFrame); GLOBALS.Freeze(); - CORO_INVOKE_1(_ctx->dc.DoFrame, GLOBALS.Input->MousePos()); + CORO_INVOKE_1(_ctx->dc.DoFrame, GLOBALS.Input->mousePos()); GLOBALS.Unfreeze(); } @@ -2361,9 +2361,9 @@ DECLARE_CUSTOM_FUNCTION(DoCredits)(CORO_PARAM, uint32 nMsg, uint32 dwTime, uint3 while (_ctx->startTime + dwTime * 1000 > _vm->getTime()) { CORO_INVOKE_0(GLOBALS.WaitFrame); - if (GLOBALS.Input->MouseLeftClicked() || GLOBALS.Input->MouseRightClicked()) + if (GLOBALS.Input->mouseLeftClicked() || GLOBALS.Input->mouseRightClicked()) break; - if (_vm->getEngine()->GetInput().GetAsyncKeyState(Common::KEYCODE_TAB)) + if (_vm->getEngine()->GetInput().getAsyncKeyState(Common::KEYCODE_TAB)) break; } diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 567da3041c..a9f7759156 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -2086,13 +2086,13 @@ void RMTextDialog::RemoveThis(CORO_PARAM, bool &result) { } if (!m_bNoTab) { - if (_vm->getEngine()->GetInput().GetAsyncKeyState(Common::KEYCODE_TAB)) + if (_vm->getEngine()->GetInput().getAsyncKeyState(Common::KEYCODE_TAB)) return; } if (!m_bNoTab) { if (m_input) { - if (m_input->MouseLeftClicked() || m_input->MouseRightClicked()) + if (m_input->mouseLeftClicked() || m_input->mouseRightClicked()) return; } } diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 42c33f2259..28d7cd5e8c 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -1032,9 +1032,9 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { return; // Reads input - _ctx->mousePos = input->MousePos(); - _ctx->bLeftClick = input->MouseLeftClicked(); - _ctx->bRightClick = input->MouseRightClicked(); + _ctx->mousePos = input->mousePos(); + _ctx->bLeftClick = input->mouseLeftClicked(); + _ctx->bRightClick = input->mouseRightClicked(); _ctx->bRefresh = false; @@ -1097,7 +1097,7 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { } } -#define KEYPRESS(c) (_vm->getEngine()->GetInput().GetAsyncKeyState(c)) +#define KEYPRESS(c) (_vm->getEngine()->GetInput().getAsyncKeyState(c)) #define PROCESS_CHAR(cod,c) if (KEYPRESS(cod)) { \ m_EditName[strlen(m_EditName) +1 ] = '\0'; m_EditName[strlen(m_EditName)] = c; _ctx->bRefresh = true; } diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 4642ee0ab7..2ff57bf804 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -146,7 +146,7 @@ void RMGfxEngine::DoFrame(CORO_PARAM, bool bDrawLocation) { g_system->lockMutex(csMainLoop); // Poll of input devices - m_input.Poll(); + m_input.poll(); if (m_bMustEnterMenu && GLOBALS.bIdleExited) { m_bOption = true; @@ -172,12 +172,12 @@ void RMGfxEngine::DoFrame(CORO_PARAM, bool bDrawLocation) { // Check the mouse input if (m_bInput && !m_tony.InAction()) { // If we are on the inventory, it is it who controls all input - if (m_inv.HaveFocus(m_input.MousePos()) && !m_inter.Active()) { + if (m_inv.HaveFocus(m_input.mousePos()) && !m_inter.Active()) { // Left Click // ********** - if (m_input.MouseLeftClicked()/* && m_itemName.IsItemSelected()*/) { + if (m_input.mouseLeftClicked()/* && m_itemName.IsItemSelected()*/) { // Left click activates the combine, if we are on an object - if (m_inv.LeftClick(m_input.MousePos(), m_curActionObj)) { + if (m_inv.LeftClick(m_input.mousePos(), m_curActionObj)) { m_curAction = TA_COMBINE; m_point.SetAction(m_curAction); } @@ -185,18 +185,18 @@ void RMGfxEngine::DoFrame(CORO_PARAM, bool bDrawLocation) { // Right Click // *********** - if (m_input.MouseRightClicked()) { + if (m_input.mouseRightClicked()) { if (m_itemName.IsItemSelected()) { m_curActionObj = 0; - m_inv.RightClick(m_input.MousePos()); + m_inv.RightClick(m_input.mousePos()); } else - m_inv.RightClick(m_input.MousePos()); + m_inv.RightClick(m_input.mousePos()); } else // Right Release // ************* - if (m_input.MouseRightReleased()) { - if (m_inv.RightRelease(m_input.MousePos(), m_curAction)) { + if (m_input.mouseRightReleased()) { + if (m_inv.RightRelease(m_input.mousePos(), m_curAction)) { CORO_INVOKE_3(m_tony.MoveAndDoAction, m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), m_curAction); m_curAction = TA_GOTO; @@ -208,16 +208,16 @@ void RMGfxEngine::DoFrame(CORO_PARAM, bool bDrawLocation) { // ************ if (m_bGUIOption) { if (!m_tony.InAction() && m_bInput) { - if ((m_input.MouseLeftClicked() && m_input.MousePos().x < 3 && m_input.MousePos().y < 3)) { + if ((m_input.mouseLeftClicked() && m_input.mousePos().x < 3 && m_input.mousePos().y < 3)) { CORO_INVOKE_1(OpenOptionScreen, 0); goto SKIPCLICKSINISTRO; - } else if (m_input.GetAsyncKeyState(Common::KEYCODE_ESCAPE)) + } else if (m_input.getAsyncKeyState(Common::KEYCODE_ESCAPE)) CORO_INVOKE_1(OpenOptionScreen, 0); else if (!_vm->getIsDemo()) { - if (m_input.GetAsyncKeyState(Common::KEYCODE_F3) || m_input.GetAsyncKeyState(Common::KEYCODE_F5)) + if (m_input.getAsyncKeyState(Common::KEYCODE_F3) || m_input.getAsyncKeyState(Common::KEYCODE_F5)) // Save game screen CORO_INVOKE_1(OpenOptionScreen, 3); - else if (m_input.GetAsyncKeyState(Common::KEYCODE_F2) || m_input.GetAsyncKeyState(Common::KEYCODE_F7)) + else if (m_input.getAsyncKeyState(Common::KEYCODE_F2) || m_input.getAsyncKeyState(Common::KEYCODE_F7)) // Load game screen CORO_INVOKE_1(OpenOptionScreen, 4); } @@ -226,7 +226,7 @@ void RMGfxEngine::DoFrame(CORO_PARAM, bool bDrawLocation) { // Left Click // ************** - if (m_input.MouseLeftClicked() && !m_inter.Active()) { + if (m_input.mouseLeftClicked() && !m_inter.Active()) { if (m_curAction != TA_COMBINE) CORO_INVOKE_3(m_tony.MoveAndDoAction, m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), m_point.CurAction()); @@ -247,29 +247,29 @@ SKIPCLICKSINISTRO: // ************ if (m_curAction == TA_COMBINE) { // During a combine, it cancels it - if (m_input.MouseRightClicked()) { + if (m_input.mouseRightClicked()) { m_inv.EndCombine(); m_curActionObj = 0; m_curAction = TA_GOTO; m_point.SetAction(m_curAction); m_point.SetSpecialPointer(RMPointer::PTR_NONE); } - } else if (m_input.MouseRightClicked() && m_itemName.IsItemSelected() && m_point.GetSpecialPointer() == RMPointer::PTR_NONE) { + } else if (m_input.mouseRightClicked() && m_itemName.IsItemSelected() && m_point.GetSpecialPointer() == RMPointer::PTR_NONE) { if (m_bGUIInterface) { // Before opening the interface, replaces GOTO m_curAction = TA_GOTO; m_curActionObj = 0; m_point.SetAction(m_curAction); - m_inter.Clicked(m_input.MousePos()); + m_inter.Clicked(m_input.mousePos()); } } // Right Release // ************* - if (m_input.MouseRightReleased()) { + if (m_input.mouseRightReleased()) { if (m_bGUIInterface) { - if (m_inter.Released(m_input.MousePos(), m_curAction)) { + if (m_inter.Released(m_input.mousePos(), m_curAction)) { m_point.SetAction(m_curAction); CORO_INVOKE_3(m_tony.MoveAndDoAction, m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), m_curAction); @@ -281,14 +281,14 @@ SKIPCLICKSINISTRO: } // Update the name under the mouse pointer - m_itemName.SetMouseCoord(m_input.MousePos()); + m_itemName.SetMouseCoord(m_input.mousePos()); if (!m_inter.Active() && !m_inv.MiniActive()) CORO_INVOKE_4(m_itemName.DoFrame, m_bigBuf, m_loc, m_point, m_inv); } // Interface & Inventory - m_inter.DoFrame(m_bigBuf, m_input.MousePos()); - m_inv.DoFrame(m_bigBuf, m_point, m_input.MousePos(), (!m_tony.InAction() && !m_inter.Active() && m_bGUIInventory)); + m_inter.DoFrame(m_bigBuf, m_input.mousePos()); + m_inv.DoFrame(m_bigBuf, m_point, m_input.mousePos(), (!m_tony.InAction() && !m_inter.Active() && m_bGUIInventory)); } // Animate Tony @@ -305,7 +305,7 @@ SKIPCLICKSINISTRO: m_tony.SetScrollPosition(m_loc.ScrollPosition()); if ((!m_tony.InAction() && m_bInput) || m_bAlwaysDrawMouse) { - m_point.SetCoord(m_input.MousePos()); + m_point.SetCoord(m_input.mousePos()); m_point.DoFrame(&m_bigBuf); } @@ -498,7 +498,7 @@ void RMGfxEngine::Init() { mpalInstallItemIrq(ItemIrq); // Initialise the input - m_input.Init(); + m_input.init(); // Initialise the mouse pointer m_point.Init(); @@ -527,7 +527,7 @@ void RMGfxEngine::Close(void) { m_inv.Close(); m_tony.Close(); m_point.Close(); - m_input.Close(); + m_input.close(); } void RMGfxEngine::SwitchFullscreen(bool bFull) { diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp index fc98544e14..4990b379b9 100644 --- a/engines/tony/input.cpp +++ b/engines/tony/input.cpp @@ -49,7 +49,7 @@ RMInput::~RMInput() { } -void RMInput::Poll(void) { +void RMInput::poll(void) { _leftClickMouse = _leftReleaseMouse = _rightClickMouse = _rightReleaseMouse = false; // Get pending events @@ -102,24 +102,24 @@ void RMInput::Poll(void) { } } -void RMInput::Init() { +void RMInput::init() { } -void RMInput::Close(void) { +void RMInput::close(void) { } -bool RMInput::MouseLeft() { +bool RMInput::mouseLeft() { return _leftButton; } -bool RMInput::MouseRight() { +bool RMInput::mouseRight() { return _rightButton; } /** * Return true if a key has been pressed */ -bool RMInput::GetAsyncKeyState(Common::KeyCode kc) { +bool RMInput::getAsyncKeyState(Common::KeyCode kc) { // The act of testing for a particular key automatically clears the state, to prevent // the same key being registered in multiple different frames bool result = _keyDown[(int)kc]; diff --git a/engines/tony/input.h b/engines/tony/input.h index 524f604ec2..e7e200e1b7 100644 --- a/engines/tony/input.h +++ b/engines/tony/input.h @@ -55,45 +55,45 @@ public: ~RMInput(); // Class initialisation - void Init(/*uint32 hInst*/); + void init(/*uint32 hInst*/); // Closes the class - void Close(void); + void close(void); // Polling (must be performed once per frame) - void Poll(void); + void poll(void); // Reading of the mouse - RMPoint MousePos() { + RMPoint mousePos() { return _mousePos; } // Current status of the mouse buttons - bool MouseLeft(); - bool MouseRight(); + bool mouseLeft(); + bool mouseRight(); // Events of mouse clicks - bool MouseLeftClicked() { + bool mouseLeftClicked() { return _leftClickMouse; } - bool MouseRightClicked() { + bool mouseRightClicked() { return _rightClickMouse; } - bool MouseBothClicked() { + bool mouseBothClicked() { return _leftClickMouse && _rightClickMouse; } - bool MouseLeftReleased() { + bool mouseLeftReleased() { return _leftReleaseMouse; } - bool MouseRightReleased() { + bool mouseRightReleased() { return _rightReleaseMouse; } - bool MouseBothReleased() { + bool mouseBothReleased() { return _leftReleaseMouse && _rightReleaseMouse; } // Returns true if the given key is pressed - bool GetAsyncKeyState(Common::KeyCode kc); + bool getAsyncKeyState(Common::KeyCode kc); }; } // End of namespace Tony diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index 1a245d9aba..aec1e1a57b 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -530,7 +530,7 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo g_system->unlockMutex(m_csModifyInterface); } - if (_vm->getEngine()->GetInput().GetAsyncKeyState(Common::KEYCODE_i)) { + if (_vm->getEngine()->GetInput().getAsyncKeyState(Common::KEYCODE_i)) { GLOBALS.bCfgInvLocked = !GLOBALS.bCfgInvLocked; } -- cgit v1.2.3 From a5cb751f7ab82a089207025810e3aaa0f0748dbd Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 5 Jun 2012 01:04:53 +0200 Subject: TONY: Rename variables and functions in gfxengine.h --- engines/tony/custom.cpp | 4 +- engines/tony/custom.h | 2 +- engines/tony/font.cpp | 2 +- engines/tony/game.cpp | 42 ++-- engines/tony/gfxengine.cpp | 500 ++++++++++++++++++++++----------------------- engines/tony/gfxengine.h | 122 +++++------ engines/tony/inventory.cpp | 2 +- engines/tony/tony.cpp | 32 +-- 8 files changed, 352 insertions(+), 354 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 1ed7c8b5a6..59de6909dc 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -2363,7 +2363,7 @@ DECLARE_CUSTOM_FUNCTION(DoCredits)(CORO_PARAM, uint32 nMsg, uint32 dwTime, uint3 CORO_INVOKE_0(GLOBALS.WaitFrame); if (GLOBALS.Input->mouseLeftClicked() || GLOBALS.Input->mouseRightClicked()) break; - if (_vm->getEngine()->GetInput().getAsyncKeyState(Common::KEYCODE_TAB)) + if (_vm->getEngine()->getInput().getAsyncKeyState(Common::KEYCODE_TAB)) break; } @@ -2531,7 +2531,7 @@ ASSIGN(201, MustSkipIdleEnd); END_CUSTOM_FUNCTION_MAP() -void SetupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation *loc, RMInventory *inv, RMInput *input) { +void setupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation *loc, RMInventory *inv, RMInput *input) { GLOBALS.Tony = tony; GLOBALS.Pointer = ptr; GLOBALS.Boxes = box; diff --git a/engines/tony/custom.h b/engines/tony/custom.h index 9b53dc32d7..514af1223c 100644 --- a/engines/tony/custom.h +++ b/engines/tony/custom.h @@ -72,7 +72,7 @@ class RMInventory; class RMInput; void INIT_CUSTOM_FUNCTION(LPCUSTOMFUNCTION *lpMap, Common::String *lpStrMap); -void SetupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation *loc, RMInventory *inv, RMInput *input); +void setupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation *loc, RMInventory *inv, RMInput *input); #endif diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index a9f7759156..71cffab26b 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -2086,7 +2086,7 @@ void RMTextDialog::RemoveThis(CORO_PARAM, bool &result) { } if (!m_bNoTab) { - if (_vm->getEngine()->GetInput().getAsyncKeyState(Common::KEYCODE_TAB)) + if (_vm->getEngine()->getInput().getAsyncKeyState(Common::KEYCODE_TAB)) return; } diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 28d7cd5e8c..71dbb68c73 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -47,23 +47,23 @@ using namespace MPAL; /****************************************/ uint32 MainLoadLocation(int nLoc, RMPoint pt, RMPoint start) { - return _vm->getEngine()->LoadLocation(nLoc, pt, start); + return _vm->getEngine()->loadLocation(nLoc, pt, start); } void MainUnloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result) { - _vm->getEngine()->UnloadLocation(coroParam, bDoOnExit, result); + _vm->getEngine()->unloadLocation(coroParam, bDoOnExit, result); } void MainLinkGraphicTask(RMGfxTask *task) { - _vm->getEngine()->LinkGraphicTask(task); + _vm->getEngine()->linkGraphicTask(task); } void MainFreeze(void) { - _vm->getEngine()->Freeze(); + _vm->getEngine()->freeze(); } void MainUnfreeze(void) { - _vm->getEngine()->Unfreeze(); + _vm->getEngine()->unfreeze(); } void MainWaitFrame(CORO_PARAM) { @@ -71,11 +71,11 @@ void MainWaitFrame(CORO_PARAM) { } void MainShowMouse(void) { - _vm->getEngine()->EnableMouse(); + _vm->getEngine()->enableMouse(); } void MainHideMouse(void) { - _vm->getEngine()->DisableMouse(); + _vm->getEngine()->disableMouse(); } void MainPlayMusic(int nChannel, const char *filename, int nFX, bool bLoop, int nSync) { @@ -83,39 +83,39 @@ void MainPlayMusic(int nChannel, const char *filename, int nFX, bool bLoop, int } void MainDisableInput(void) { - _vm->getEngine()->DisableInput(); + _vm->getEngine()->disableInput(); } void MainEnableInput(void) { - _vm->getEngine()->EnableInput(); + _vm->getEngine()->enableInput(); } void MainInitWipe(int type) { - _vm->getEngine()->InitWipe(type); + _vm->getEngine()->initWipe(type); } void MainCloseWipe(void) { - _vm->getEngine()->CloseWipe(); + _vm->getEngine()->closeWipe(); } void MainWaitWipeEnd(CORO_PARAM) { - _vm->getEngine()->WaitWipeEnd(coroParam); + _vm->getEngine()->waitWipeEnd(coroParam); } void MainEnableGUI(void) { - _vm->getEngine()->m_bGUIInterface = true; - _vm->getEngine()->m_bGUIInventory = true; - _vm->getEngine()->m_bGUIOption = true; + _vm->getEngine()->_bGUIInterface = true; + _vm->getEngine()->_bGUIInventory = true; + _vm->getEngine()->_bGUIOption = true; } void MainDisableGUI(void) { - _vm->getEngine()->m_bGUIInterface = false; - _vm->getEngine()->m_bGUIInventory = false; - _vm->getEngine()->m_bGUIOption = false; + _vm->getEngine()->_bGUIInterface = false; + _vm->getEngine()->_bGUIInventory = false; + _vm->getEngine()->_bGUIOption = false; } void MainSetPalesati(bool bPalesati) { - _vm->getEngine()->SetPalesati(bPalesati); + _vm->getEngine()->setPalesati(bPalesati); } /****************************************************************************\ @@ -1097,9 +1097,9 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { } } -#define KEYPRESS(c) (_vm->getEngine()->GetInput().getAsyncKeyState(c)) +#define KEYPRESS(c) (_vm->getEngine()->getInput().getAsyncKeyState(c)) #define PROCESS_CHAR(cod,c) if (KEYPRESS(cod)) { \ - m_EditName[strlen(m_EditName) +1 ] = '\0'; m_EditName[strlen(m_EditName)] = c; _ctx->bRefresh = true; } + m_EditName[strlen(m_EditName) + 1] = '\0'; m_EditName[strlen(m_EditName)] = c; _ctx->bRefresh = true; } /**************** State Buttons **************/ if (m_bEditSaveName) { diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 2ff57bf804..75eb6de883 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -61,34 +61,34 @@ void ExitAllIdles(CORO_PARAM, const void *param) { RMGfxEngine::RMGfxEngine() { // Create big buffer where the frame will be rendered - m_bigBuf.Create(RM_BBX, RM_BBY, 16); - m_bigBuf.OffsetY(RM_SKIPY); - - csMainLoop = NULL; - m_nCurLoc = 0; - m_curAction = TA_GOTO; - m_curActionObj = 0; - m_nWipeType = 0; - m_hWipeEvent = 0; - m_nWipeStep = 0; - m_bMustEnterMenu = false; - m_bWiping = false; - m_bGUIOption = false; - m_bGUIInterface = false; - m_bGUIInventory = false; - m_bAlwaysDrawMouse = false; - m_bOption = false; - m_bLocationLoaded = false; - m_bInput = false; + _bigBuf.Create(RM_BBX, RM_BBY, 16); + _bigBuf.OffsetY(RM_SKIPY); + + _csMainLoop = NULL; + _nCurLoc = 0; + _curAction = TA_GOTO; + _curActionObj = 0; + _nWipeType = 0; + _hWipeEvent = 0; + _nWipeStep = 0; + _bMustEnterMenu = false; + _bWiping = false; + _bGUIOption = false; + _bGUIInterface = false; + _bGUIInventory = false; + _bAlwaysDrawMouse = false; + _bOption = false; + _bLocationLoaded = false; + _bInput = false; } RMGfxEngine::~RMGfxEngine() { // Close the buffer - m_bigBuf.Destroy(); - g_system->deleteMutex(csMainLoop); + _bigBuf.Destroy(); + g_system->deleteMutex(_csMainLoop); } -void RMGfxEngine::OpenOptionScreen(CORO_PARAM, int type) { +void RMGfxEngine::openOptionScreen(CORO_PARAM, int type) { CORO_BEGIN_CONTEXT; bool bRes; CORO_END_CONTEXT(_ctx); @@ -98,271 +98,271 @@ void RMGfxEngine::OpenOptionScreen(CORO_PARAM, int type) { _ctx->bRes = false; if (type == 0) - CORO_INVOKE_2(m_opt.Init, m_bigBuf, _ctx->bRes); + CORO_INVOKE_2(_opt.Init, _bigBuf, _ctx->bRes); else if (type == 1) - CORO_INVOKE_3(m_opt.InitLoadMenuOnly, m_bigBuf, true, _ctx->bRes); + CORO_INVOKE_3(_opt.InitLoadMenuOnly, _bigBuf, true, _ctx->bRes); else if (type == 2) - CORO_INVOKE_2(m_opt.InitNoLoadSave, m_bigBuf, _ctx->bRes); + CORO_INVOKE_2(_opt.InitNoLoadSave, _bigBuf, _ctx->bRes); else if (type == 3) - CORO_INVOKE_3(m_opt.InitLoadMenuOnly, m_bigBuf, false, _ctx->bRes); + CORO_INVOKE_3(_opt.InitLoadMenuOnly, _bigBuf, false, _ctx->bRes); else if (type == 4) - CORO_INVOKE_3(m_opt.InitSaveMenuOnly, m_bigBuf, false, _ctx->bRes); + CORO_INVOKE_3(_opt.InitSaveMenuOnly, _bigBuf, false, _ctx->bRes); if (_ctx->bRes) { _vm->pauseSound(true); - DisableInput(); - m_inv.EndCombine(); - m_curActionObj = 0; - m_curAction = TA_GOTO; - m_point.SetAction(m_curAction); - m_point.SetSpecialPointer(RMPointer::PTR_NONE); - m_point.SetCustomPointer(NULL); - EnableMouse(); + disableInput(); + _inv.EndCombine(); + _curActionObj = 0; + _curAction = TA_GOTO; + _point.SetAction(_curAction); + _point.SetSpecialPointer(RMPointer::PTR_NONE); + _point.SetCustomPointer(NULL); + enableMouse(); _vm->grabThumbnail(); // Exists the IDLE to avoid premature death in loading - m_bMustEnterMenu = true; + _bMustEnterMenu = true; if (type == 1 || type == 2) { GLOBALS.bIdleExited = true; } else { - CORO_INVOKE_0(m_tony.StopNoAction); + CORO_INVOKE_0(_tony.StopNoAction); GLOBALS.bIdleExited = false; - CoroScheduler.createProcess(ExitAllIdles, &m_nCurLoc, sizeof(int)); + CoroScheduler.createProcess(ExitAllIdles, &_nCurLoc, sizeof(int)); } } CORO_END_CODE; } -void RMGfxEngine::DoFrame(CORO_PARAM, bool bDrawLocation) { +void RMGfxEngine::doFrame(CORO_PARAM, bool bDrawLocation) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - g_system->lockMutex(csMainLoop); + g_system->lockMutex(_csMainLoop); // Poll of input devices - m_input.poll(); + _input.poll(); - if (m_bMustEnterMenu && GLOBALS.bIdleExited) { - m_bOption = true; - m_bMustEnterMenu = false; + if (_bMustEnterMenu && GLOBALS.bIdleExited) { + _bOption = true; + _bMustEnterMenu = false; GLOBALS.bIdleExited = false; } - if (m_bOption) { - CORO_INVOKE_1(m_opt.DoFrame, &m_input); - m_bOption = !m_opt.IsClosing(); - if (!m_bOption) { - DisableMouse(); - EnableInput(); - mpalStartIdlePoll(m_nCurLoc); + if (_bOption) { + CORO_INVOKE_1(_opt.DoFrame, &_input); + _bOption = !_opt.IsClosing(); + if (!_bOption) { + disableMouse(); + enableInput(); + mpalStartIdlePoll(_nCurLoc); _vm->pauseSound(false); } } - if (bDrawLocation && m_bLocationLoaded) { + if (bDrawLocation && _bLocationLoaded) { // Location and objects - m_loc.DoFrame(&m_bigBuf); + _loc.DoFrame(&_bigBuf); // Check the mouse input - if (m_bInput && !m_tony.InAction()) { + if (_bInput && !_tony.InAction()) { // If we are on the inventory, it is it who controls all input - if (m_inv.HaveFocus(m_input.mousePos()) && !m_inter.Active()) { + if (_inv.HaveFocus(_input.mousePos()) && !_inter.Active()) { // Left Click // ********** - if (m_input.mouseLeftClicked()/* && m_itemName.IsItemSelected()*/) { + if (_input.mouseLeftClicked()/* && m_itemName.IsItemSelected()*/) { // Left click activates the combine, if we are on an object - if (m_inv.LeftClick(m_input.mousePos(), m_curActionObj)) { - m_curAction = TA_COMBINE; - m_point.SetAction(m_curAction); + if (_inv.LeftClick(_input.mousePos(), _curActionObj)) { + _curAction = TA_COMBINE; + _point.SetAction(_curAction); } } else // Right Click // *********** - if (m_input.mouseRightClicked()) { - if (m_itemName.IsItemSelected()) { - m_curActionObj = 0; - m_inv.RightClick(m_input.mousePos()); + if (_input.mouseRightClicked()) { + if (_itemName.IsItemSelected()) { + _curActionObj = 0; + _inv.RightClick(_input.mousePos()); } else - m_inv.RightClick(m_input.mousePos()); + _inv.RightClick(_input.mousePos()); } else // Right Release // ************* - if (m_input.mouseRightReleased()) { - if (m_inv.RightRelease(m_input.mousePos(), m_curAction)) { - CORO_INVOKE_3(m_tony.MoveAndDoAction, m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), m_curAction); + if (_input.mouseRightReleased()) { + if (_inv.RightRelease(_input.mousePos(), _curAction)) { + CORO_INVOKE_3(_tony.MoveAndDoAction, _itemName.GetHotspot(), _itemName.GetSelectedItem(), _curAction); - m_curAction = TA_GOTO; - m_point.SetAction(m_curAction); + _curAction = TA_GOTO; + _point.SetAction(_curAction); } } } else { // Options Menu // ************ - if (m_bGUIOption) { - if (!m_tony.InAction() && m_bInput) { - if ((m_input.mouseLeftClicked() && m_input.mousePos().x < 3 && m_input.mousePos().y < 3)) { - CORO_INVOKE_1(OpenOptionScreen, 0); + if (_bGUIOption) { + if (!_tony.InAction() && _bInput) { + if ((_input.mouseLeftClicked() && _input.mousePos().x < 3 && _input.mousePos().y < 3)) { + CORO_INVOKE_1(openOptionScreen, 0); goto SKIPCLICKSINISTRO; - } else if (m_input.getAsyncKeyState(Common::KEYCODE_ESCAPE)) - CORO_INVOKE_1(OpenOptionScreen, 0); + } else if (_input.getAsyncKeyState(Common::KEYCODE_ESCAPE)) + CORO_INVOKE_1(openOptionScreen, 0); else if (!_vm->getIsDemo()) { - if (m_input.getAsyncKeyState(Common::KEYCODE_F3) || m_input.getAsyncKeyState(Common::KEYCODE_F5)) + if (_input.getAsyncKeyState(Common::KEYCODE_F3) || _input.getAsyncKeyState(Common::KEYCODE_F5)) // Save game screen - CORO_INVOKE_1(OpenOptionScreen, 3); - else if (m_input.getAsyncKeyState(Common::KEYCODE_F2) || m_input.getAsyncKeyState(Common::KEYCODE_F7)) + CORO_INVOKE_1(openOptionScreen, 3); + else if (_input.getAsyncKeyState(Common::KEYCODE_F2) || _input.getAsyncKeyState(Common::KEYCODE_F7)) // Load game screen - CORO_INVOKE_1(OpenOptionScreen, 4); + CORO_INVOKE_1(openOptionScreen, 4); } } } // Left Click // ************** - if (m_input.mouseLeftClicked() && !m_inter.Active()) { + if (_input.mouseLeftClicked() && !_inter.Active()) { - if (m_curAction != TA_COMBINE) - CORO_INVOKE_3(m_tony.MoveAndDoAction, m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), m_point.CurAction()); - else if (m_itemName.GetSelectedItem() != NULL) - CORO_INVOKE_4(m_tony.MoveAndDoAction, m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), TA_COMBINE, m_curActionObj); + if (_curAction != TA_COMBINE) + CORO_INVOKE_3(_tony.MoveAndDoAction, _itemName.GetHotspot(), _itemName.GetSelectedItem(), _point.CurAction()); + else if (_itemName.GetSelectedItem() != NULL) + CORO_INVOKE_4(_tony.MoveAndDoAction, _itemName.GetHotspot(), _itemName.GetSelectedItem(), TA_COMBINE, _curActionObj); - if (m_curAction == TA_COMBINE) { - m_inv.EndCombine(); - m_point.SetSpecialPointer(RMPointer::PTR_NONE); + if (_curAction == TA_COMBINE) { + _inv.EndCombine(); + _point.SetSpecialPointer(RMPointer::PTR_NONE); } - m_curAction = TA_GOTO; - m_point.SetAction(m_curAction); + _curAction = TA_GOTO; + _point.SetAction(_curAction); } SKIPCLICKSINISTRO: // Right Click // ************ - if (m_curAction == TA_COMBINE) { + if (_curAction == TA_COMBINE) { // During a combine, it cancels it - if (m_input.mouseRightClicked()) { - m_inv.EndCombine(); - m_curActionObj = 0; - m_curAction = TA_GOTO; - m_point.SetAction(m_curAction); - m_point.SetSpecialPointer(RMPointer::PTR_NONE); + if (_input.mouseRightClicked()) { + _inv.EndCombine(); + _curActionObj = 0; + _curAction = TA_GOTO; + _point.SetAction(_curAction); + _point.SetSpecialPointer(RMPointer::PTR_NONE); } - } else if (m_input.mouseRightClicked() && m_itemName.IsItemSelected() && m_point.GetSpecialPointer() == RMPointer::PTR_NONE) { - if (m_bGUIInterface) { + } else if (_input.mouseRightClicked() && _itemName.IsItemSelected() && _point.GetSpecialPointer() == RMPointer::PTR_NONE) { + if (_bGUIInterface) { // Before opening the interface, replaces GOTO - m_curAction = TA_GOTO; - m_curActionObj = 0; - m_point.SetAction(m_curAction); - m_inter.Clicked(m_input.mousePos()); + _curAction = TA_GOTO; + _curActionObj = 0; + _point.SetAction(_curAction); + _inter.Clicked(_input.mousePos()); } } // Right Release // ************* - if (m_input.mouseRightReleased()) { - if (m_bGUIInterface) { - if (m_inter.Released(m_input.mousePos(), m_curAction)) { - m_point.SetAction(m_curAction); - CORO_INVOKE_3(m_tony.MoveAndDoAction, m_itemName.GetHotspot(), m_itemName.GetSelectedItem(), m_curAction); - - m_curAction = TA_GOTO; - m_point.SetAction(m_curAction); + if (_input.mouseRightReleased()) { + if (_bGUIInterface) { + if (_inter.Released(_input.mousePos(), _curAction)) { + _point.SetAction(_curAction); + CORO_INVOKE_3(_tony.MoveAndDoAction, _itemName.GetHotspot(), _itemName.GetSelectedItem(), _curAction); + + _curAction = TA_GOTO; + _point.SetAction(_curAction); } } } } // Update the name under the mouse pointer - m_itemName.SetMouseCoord(m_input.mousePos()); - if (!m_inter.Active() && !m_inv.MiniActive()) - CORO_INVOKE_4(m_itemName.DoFrame, m_bigBuf, m_loc, m_point, m_inv); + _itemName.SetMouseCoord(_input.mousePos()); + if (!_inter.Active() && !_inv.MiniActive()) + CORO_INVOKE_4(_itemName.DoFrame, _bigBuf, _loc, _point, _inv); } // Interface & Inventory - m_inter.DoFrame(m_bigBuf, m_input.mousePos()); - m_inv.DoFrame(m_bigBuf, m_point, m_input.mousePos(), (!m_tony.InAction() && !m_inter.Active() && m_bGUIInventory)); + _inter.DoFrame(_bigBuf, _input.mousePos()); + _inv.DoFrame(_bigBuf, _point, _input.mousePos(), (!_tony.InAction() && !_inter.Active() && _bGUIInventory)); } // Animate Tony - CORO_INVOKE_2(m_tony.DoFrame, &m_bigBuf, m_nCurLoc); + CORO_INVOKE_2(_tony.DoFrame, &_bigBuf, _nCurLoc); // Update screen scrolling to keep Tony in focus - if (m_tony.MustUpdateScrolling() && m_bLocationLoaded) { - RMPoint showThis = m_tony.Position(); + if (_tony.MustUpdateScrolling() && _bLocationLoaded) { + RMPoint showThis = _tony.Position(); showThis.y -= 60; - m_loc.UpdateScrolling(showThis); + _loc.UpdateScrolling(showThis); } - if (m_bLocationLoaded) - m_tony.SetScrollPosition(m_loc.ScrollPosition()); + if (_bLocationLoaded) + _tony.SetScrollPosition(_loc.ScrollPosition()); - if ((!m_tony.InAction() && m_bInput) || m_bAlwaysDrawMouse) { - m_point.SetCoord(m_input.mousePos()); - m_point.DoFrame(&m_bigBuf); + if ((!_tony.InAction() && _bInput) || _bAlwaysDrawMouse) { + _point.SetCoord(_input.mousePos()); + _point.DoFrame(&_bigBuf); } // ********************** // Draw the list in the OT // ********************** - CORO_INVOKE_0(m_bigBuf.DrawOT); + CORO_INVOKE_0(_bigBuf.DrawOT); #define FSTEP (480/32) // Wipe - if (m_bWiping) { - switch (m_nWipeType) { + if (_bWiping) { + switch (_nWipeType) { case 1: - if (!(m_rcWipeEllipse.bottom - m_rcWipeEllipse.top >= FSTEP * 2)) { - CoroScheduler.setEvent(m_hWipeEvent); - m_nWipeType = 3; + if (!(_rcWipeEllipse.bottom - _rcWipeEllipse.top >= FSTEP * 2)) { + CoroScheduler.setEvent(_hWipeEvent); + _nWipeType = 3; break; } - m_rcWipeEllipse.top += FSTEP; - m_rcWipeEllipse.left += FSTEP; - m_rcWipeEllipse.right -= FSTEP; - m_rcWipeEllipse.bottom -= FSTEP; + _rcWipeEllipse.top += FSTEP; + _rcWipeEllipse.left += FSTEP; + _rcWipeEllipse.right -= FSTEP; + _rcWipeEllipse.bottom -= FSTEP; break; case 2: - if (!(m_rcWipeEllipse.bottom - m_rcWipeEllipse.top < 480 - FSTEP)) { - CoroScheduler.setEvent(m_hWipeEvent); - m_nWipeType = 3; + if (!(_rcWipeEllipse.bottom - _rcWipeEllipse.top < 480 - FSTEP)) { + CoroScheduler.setEvent(_hWipeEvent); + _nWipeType = 3; break; } - m_rcWipeEllipse.top -= FSTEP; - m_rcWipeEllipse.left -= FSTEP; - m_rcWipeEllipse.right += FSTEP; - m_rcWipeEllipse.bottom += FSTEP; + _rcWipeEllipse.top -= FSTEP; + _rcWipeEllipse.left -= FSTEP; + _rcWipeEllipse.right += FSTEP; + _rcWipeEllipse.bottom += FSTEP; break; } } - g_system->unlockMutex(csMainLoop); + g_system->unlockMutex(_csMainLoop); CORO_END_CODE; } -void RMGfxEngine::InitCustomDll(void) { - SetupGlobalVars(&m_tony, &m_point, &_vm->_theBoxes, &m_loc, &m_inv, &m_input); +void RMGfxEngine::initCustomDll(void) { + setupGlobalVars(&_tony, &_point, &_vm->_theBoxes, &_loc, &_inv, &_input); } -void RMGfxEngine::ItemIrq(uint32 dwItem, int nPattern, int nStatus) { +void RMGfxEngine::itemIrq(uint32 dwItem, int nPattern, int nStatus) { RMItem *item; assert(GLOBALS.GfxEngine); - if (GLOBALS.GfxEngine->m_bLocationLoaded) { - item = GLOBALS.GfxEngine->m_loc.GetItemFromCode(dwItem); + if (GLOBALS.GfxEngine->_bLocationLoaded) { + item = GLOBALS.GfxEngine->_loc.GetItemFromCode(dwItem); if (item != NULL) { if (nPattern != -1) { if (GLOBALS.bPatIrqFreeze) @@ -378,45 +378,45 @@ void RMGfxEngine::ItemIrq(uint32 dwItem, int nPattern, int nStatus) { } -void RMGfxEngine::InitForNewLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { +void RMGfxEngine::initForNewLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { if (start.x == -1 || start.y == -1) { start.x = ptTonyStart.x - RM_SX / 2; start.y = ptTonyStart.y - RM_SY / 2; } - m_loc.SetScrollPosition(start); + _loc.SetScrollPosition(start); if (ptTonyStart.x == 0 && ptTonyStart.y == 0) { } else { - m_tony.SetPosition(ptTonyStart, nLoc); - m_tony.SetScrollPosition(start); + _tony.SetPosition(ptTonyStart, nLoc); + _tony.SetScrollPosition(start); } - m_curAction = TA_GOTO; - m_point.SetCustomPointer(NULL); - m_point.SetSpecialPointer(RMPointer::PTR_NONE); - m_point.SetAction(m_curAction); - m_inter.Reset(); - m_inv.Reset(); + _curAction = TA_GOTO; + _point.SetCustomPointer(NULL); + _point.SetSpecialPointer(RMPointer::PTR_NONE); + _point.SetAction(_curAction); + _inter.Reset(); + _inv.Reset(); - mpalStartIdlePoll(m_nCurLoc); + mpalStartIdlePoll(_nCurLoc); } -uint32 RMGfxEngine::LoadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { +uint32 RMGfxEngine::loadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { bool bLoaded; int i; - m_nCurLoc = nLoc; + _nCurLoc = nLoc; bLoaded = false; for (i = 0; i < 5; i++) { // Try the loading of the location - RMRes res(m_nCurLoc); + RMRes res(_nCurLoc); if (!res.IsValid()) continue; - m_loc.Load(res); - InitForNewLocation(nLoc, ptTonyStart, start); + _loc.Load(res); + initForNewLocation(nLoc, ptTonyStart, start); bLoaded = true; break; } @@ -424,16 +424,16 @@ uint32 RMGfxEngine::LoadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { if (!bLoaded) error("Location was not loaded"); - if (m_bOption) - m_opt.ReInit(m_bigBuf); + if (_bOption) + _opt.ReInit(_bigBuf); - m_bLocationLoaded = true; + _bLocationLoaded = true; // On entering the location return CORO_INVALID_PID_VALUE; //mpalQueryDoAction(0,m_nCurLoc,0); } -void RMGfxEngine::UnloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result) { +void RMGfxEngine::unloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result) { CORO_BEGIN_CONTEXT; uint32 h; CORO_END_CONTEXT(_ctx); @@ -441,21 +441,21 @@ void RMGfxEngine::UnloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result) { CORO_BEGIN_CODE(_ctx); // Release the location - CORO_INVOKE_2(mpalEndIdlePoll, m_nCurLoc, NULL); + CORO_INVOKE_2(mpalEndIdlePoll, _nCurLoc, NULL); // On Exit? if (bDoOnExit) { - _ctx->h = mpalQueryDoAction(1, m_nCurLoc, 0); + _ctx->h = mpalQueryDoAction(1, _nCurLoc, 0); if (_ctx->h != CORO_INVALID_PID_VALUE) CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->h, CORO_INFINITE); } MainFreeze(); - m_bLocationLoaded = false; + _bLocationLoaded = false; - m_bigBuf.ClearOT(); - m_loc.Unload(); + _bigBuf.ClearOT(); + _loc.Unload(); if (result != NULL) *result = CORO_INVALID_PID_VALUE; @@ -463,102 +463,100 @@ void RMGfxEngine::UnloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result) { CORO_END_CODE; } -void RMGfxEngine::Init() { +void RMGfxEngine::init() { // Screen loading RMResRaw *raw; RMGfxSourceBuffer16 *load = NULL; INIT_GFX16_FROMRAW(20038, load); - m_bigBuf.AddPrim(new RMGfxPrimitive(load)); - m_bigBuf.DrawOT(Common::nullContext); - m_bigBuf.ClearOT(); + _bigBuf.AddPrim(new RMGfxPrimitive(load)); + _bigBuf.DrawOT(Common::nullContext); + _bigBuf.ClearOT(); delete load; _vm->_window.GetNewFrame(*this, NULL); - - GLOBALS.bPatIrqFreeze = true; // Activate GUI - m_bGUIOption = true; - m_bGUIInterface = true; - m_bGUIInventory = true; + _bGUIOption = true; + _bGUIInterface = true; + _bGUIInventory = true; GLOBALS.bSkipSfxNoLoop = false; - m_bMustEnterMenu = false; + _bMustEnterMenu = false; GLOBALS.bIdleExited = false; - m_bOption = false; - m_bWiping = false; - m_hWipeEvent = CoroScheduler.createEvent(false, false); + _bOption = false; + _bWiping = false; + _hWipeEvent = CoroScheduler.createEvent(false, false); // Create the freeze event - csMainLoop = g_system->createMutex(); + _csMainLoop = g_system->createMutex(); // Initialise the IRQ function for items for MPAL GLOBALS.GfxEngine = this; - mpalInstallItemIrq(ItemIrq); + mpalInstallItemIrq(itemIrq); // Initialise the input - m_input.init(); + _input.init(); // Initialise the mouse pointer - m_point.Init(); + _point.Init(); // Initialise Tony - m_tony.Init(); - m_tony.LinkToBoxes(&_vm->_theBoxes); + _tony.Init(); + _tony.LinkToBoxes(&_vm->_theBoxes); // Initialise the inventory and the interface - m_inv.Init(); - m_inter.Init(); + _inv.Init(); + _inter.Init(); // Download the location and set priorities @@@@@ - m_bLocationLoaded = false; + _bLocationLoaded = false; - EnableInput(); + enableInput(); // Starting the game - m_tony.ExecuteAction(20, 1, 0); + _tony.ExecuteAction(20, 1, 0); } -void RMGfxEngine::Close(void) { - m_bigBuf.ClearOT(); +void RMGfxEngine::close(void) { + _bigBuf.ClearOT(); - m_inter.Close(); - m_inv.Close(); - m_tony.Close(); - m_point.Close(); - m_input.close(); + _inter.Close(); + _inv.Close(); + _tony.Close(); + _point.Close(); + _input.close(); } -void RMGfxEngine::SwitchFullscreen(bool bFull) { +void RMGfxEngine::switchFullscreen(bool bFull) { } void RMGfxEngine::GDIControl(bool bCon) { } -void RMGfxEngine::EnableInput(void) { - m_bInput = true; +void RMGfxEngine::enableInput(void) { + _bInput = true; } -void RMGfxEngine::DisableInput(void) { - m_bInput = false; - m_inter.Reset(); +void RMGfxEngine::disableInput(void) { + _bInput = false; + _inter.Reset(); } -void RMGfxEngine::EnableMouse(void) { - m_bAlwaysDrawMouse = true; +void RMGfxEngine::enableMouse(void) { + _bAlwaysDrawMouse = true; } -void RMGfxEngine::DisableMouse(void) { - m_bAlwaysDrawMouse = false; +void RMGfxEngine::disableMouse(void) { + _bAlwaysDrawMouse = false; } -void RMGfxEngine::Freeze(void) { - g_system->lockMutex(csMainLoop); +void RMGfxEngine::freeze(void) { + g_system->lockMutex(_csMainLoop); } -void RMGfxEngine::Unfreeze(void) { - g_system->unlockMutex(csMainLoop); +void RMGfxEngine::unfreeze(void) { + g_system->unlockMutex(_csMainLoop); } void CharsSaveAll(Common::OutSaveFile *f); @@ -574,14 +572,14 @@ void LoadMusic(Common::InSaveFile *f); #define TONY_SAVEGAME_VERSION 8 -void RMGfxEngine::SaveState(const Common::String &fn, byte *curThumb, const Common::String &name) { +void RMGfxEngine::saveState(const Common::String &fn, byte *curThumb, const Common::String &name) { Common::OutSaveFile *f; byte *state; uint thumbsize; uint size; int i; char buf[4]; - RMPoint tp = m_tony.Position(); + RMPoint tp = _tony.Position(); // Saving: MPAL variables, current location, and Tony inventory position @@ -612,7 +610,7 @@ void RMGfxEngine::SaveState(const Common::String &fn, byte *curThumb, const Comm i = strlen(name.c_str()); f->writeByte(i); f->write(name.c_str(), i); - f->writeUint32LE(m_nCurLoc); + f->writeUint32LE(_nCurLoc); f->writeUint32LE(tp.x); f->writeUint32LE(tp.y); @@ -621,9 +619,9 @@ void RMGfxEngine::SaveState(const Common::String &fn, byte *curThumb, const Comm delete[] state; // Inventory - size = m_inv.GetSaveStateSize(); + size = _inv.GetSaveStateSize(); state = new byte[size]; - m_inv.SaveState(state); + _inv.SaveState(state); f->writeUint32LE(size); f->write(state, size); delete[] state; @@ -640,9 +638,9 @@ void RMGfxEngine::SaveState(const Common::String &fn, byte *curThumb, const Comm bool bStat; // Saves the state of the shepherdess and show yourself - bStat = m_tony.GetPastorella(); + bStat = _tony.GetPastorella(); f->writeByte(bStat); - bStat = m_inter.GetPalesati(); + bStat = _inter.GetPalesati(); f->writeByte(bStat); // Save the chars @@ -677,7 +675,7 @@ void RMGfxEngine::SaveState(const Common::String &fn, byte *curThumb, const Comm delete f; } -void RMGfxEngine::LoadState(CORO_PARAM, const Common::String &fn) { +void RMGfxEngine::loadState(CORO_PARAM, const Common::String &fn) { // PROBLEM: You should change the location in a separate process to do the OnEnter CORO_BEGIN_CONTEXT; Common::InSaveFile *f; @@ -760,7 +758,7 @@ void RMGfxEngine::LoadState(CORO_PARAM, const Common::String &fn) { _ctx->size = _ctx->f->readUint32LE(); _ctx->state = new byte[_ctx->size]; _ctx->f->read(_ctx->state, _ctx->size); - m_inv.LoadState(_ctx->state); + _inv.LoadState(_ctx->state); delete[] _ctx->state; if (_ctx->ver >= 0x2) { // Versione 2: box please @@ -776,9 +774,9 @@ void RMGfxEngine::LoadState(CORO_PARAM, const Common::String &fn) { bool bStat = false; bStat = _ctx->f->readByte(); - m_tony.SetPastorella(bStat); + _tony.SetPastorella(bStat); bStat = _ctx->f->readByte(); - m_inter.SetPalesati(bStat); + _inter.SetPalesati(bStat); CharsLoadAll(_ctx->f); } @@ -813,9 +811,9 @@ void RMGfxEngine::LoadState(CORO_PARAM, const Common::String &fn) { delete _ctx->f; - CORO_INVOKE_2(UnloadLocation, false, NULL); - LoadLocation(_ctx->loc, _ctx->tp, RMPoint(-1, -1)); - m_tony.SetPattern(RMTony::PAT_STANDRIGHT); + CORO_INVOKE_2(unloadLocation, false, NULL); + loadLocation(_ctx->loc, _ctx->tp, RMPoint(-1, -1)); + _tony.SetPattern(RMTony::PAT_STANDRIGHT); MainUnfreeze(); // On older versions, need to an enter action @@ -831,39 +829,39 @@ void RMGfxEngine::LoadState(CORO_PARAM, const Common::String &fn) { CORO_INVOKE_0(RestoreMusic); - m_bGUIInterface = true; - m_bGUIInventory = true; - m_bGUIOption = true; + _bGUIInterface = true; + _bGUIInventory = true; + _bGUIOption = true; CORO_END_CODE; } -void RMGfxEngine::PauseSound(bool bPause) { - if (m_bLocationLoaded) - m_loc.PauseSound(bPause); +void RMGfxEngine::pauseSound(bool bPause) { + if (_bLocationLoaded) + _loc.PauseSound(bPause); } -void RMGfxEngine::InitWipe(int type) { - m_bWiping = true; - m_nWipeType = type; - m_nWipeStep = 0; +void RMGfxEngine::initWipe(int type) { + _bWiping = true; + _nWipeType = type; + _nWipeStep = 0; - if (m_nWipeType == 1) - m_rcWipeEllipse = Common::Rect(80, 0, 640 - 80, 480); - else if (m_nWipeType == 2) - m_rcWipeEllipse = Common::Rect(320 - FSTEP, 240 - FSTEP, 320 + FSTEP, 240 + FSTEP); + if (_nWipeType == 1) + _rcWipeEllipse = Common::Rect(80, 0, 640 - 80, 480); + else if (_nWipeType == 2) + _rcWipeEllipse = Common::Rect(320 - FSTEP, 240 - FSTEP, 320 + FSTEP, 240 + FSTEP); } -void RMGfxEngine::CloseWipe(void) { - m_bWiping = false; +void RMGfxEngine::closeWipe(void) { + _bWiping = false; } -void RMGfxEngine::WaitWipeEnd(CORO_PARAM) { - CoroScheduler.waitForSingleObject(coroParam, m_hWipeEvent, CORO_INFINITE); +void RMGfxEngine::waitWipeEnd(CORO_PARAM) { + CoroScheduler.waitForSingleObject(coroParam, _hWipeEvent, CORO_INFINITE); } -bool RMGfxEngine::CanLoadSave() { - return m_bInput && !m_tony.InAction() && !_vm->getIsDemo(); +bool RMGfxEngine::canLoadSave() { + return _bInput && !_tony.InAction() && !_vm->getIsDemo(); } } // End of namespace Tony diff --git a/engines/tony/gfxengine.h b/engines/tony/gfxengine.h index b9ab411d2b..695c5af58f 100644 --- a/engines/tony/gfxengine.h +++ b/engines/tony/gfxengine.h @@ -44,110 +44,110 @@ namespace Tony { class RMGfxEngine { private: - RMGfxTargetBuffer m_bigBuf; - RMInput m_input; - RMPointer m_point; - RMLocation m_loc; - RMOptionScreen m_opt; - RMTony m_tony; - RMInventory m_inv; - RMInterface m_inter; - RMTextItemName m_itemName; - - bool m_bOption; - bool m_bLocationLoaded; - - bool m_bInput; - bool m_bAlwaysDrawMouse; - - int m_nCurLoc; - RMTonyAction m_curAction; - int m_curActionObj; - OSystem::MutexRef csMainLoop; - - int m_nWipeType; - uint32 m_hWipeEvent; - int m_nWipeStep; - - bool m_bMustEnterMenu; + RMGfxTargetBuffer _bigBuf; + RMInput _input; + RMPointer _point; + RMLocation _loc; + RMOptionScreen _opt; + RMTony _tony; + RMInventory _inv; + RMInterface _inter; + RMTextItemName _itemName; + + bool _bOption; + bool _bLocationLoaded; + + bool _bInput; + bool _bAlwaysDrawMouse; + + int _nCurLoc; + RMTonyAction _curAction; + int _curActionObj; + OSystem::MutexRef _csMainLoop; + + int _nWipeType; + uint32 _hWipeEvent; + int _nWipeStep; + + bool _bMustEnterMenu; protected: - static void ItemIrq(uint32 dwItem, int nPattern, int nStatus); - void InitForNewLocation(int nLoc, RMPoint ptTonyStart, RMPoint start); + static void itemIrq(uint32 dwItem, int nPattern, int nStatus); + void initForNewLocation(int nLoc, RMPoint ptTonyStart, RMPoint start); public: - bool m_bWiping; - Common::Rect m_rcWipeEllipse; - bool m_bGUIOption; - bool m_bGUIInterface; - bool m_bGUIInventory; + bool _bWiping; + Common::Rect _rcWipeEllipse; + bool _bGUIOption; + bool _bGUIInterface; + bool _bGUIInventory; public: RMGfxEngine(); virtual ~RMGfxEngine(); // Draw the next frame - void DoFrame(CORO_PARAM, bool bDrawLocation); + void doFrame(CORO_PARAM, bool bDrawLocation); // Initialises the graphics engine - void Init(); + void init(); // Closes the graphics engine - void Close(void); + void close(void); // Warns when changing - void SwitchFullscreen(bool bFull); + void switchFullscreen(bool bFull); // Warn that we are guided by the GDI void GDIControl(bool bCon); // Warns when entering or exits the options menu - void OpenOptionScreen(CORO_PARAM, int type); + void openOptionScreen(CORO_PARAM, int type); // Enables or disables mouse input - void EnableInput(void); - void DisableInput(void); + void enableInput(void); + void disableInput(void); // Enables and disables mouse draw - void EnableMouse(void); - void DisableMouse(void); + void enableMouse(void); + void disableMouse(void); operator byte *() { - return (byte *)m_bigBuf; + return (byte *)_bigBuf; } - RMInput &GetInput() { - return m_input; + RMInput &getInput() { + return _input; } // Link to the custom function list - void InitCustomDll(void); + void initCustomDll(void); // Link to graphic task - void LinkGraphicTask(RMGfxTask *task) { - m_bigBuf.AddPrim(new RMGfxPrimitive(task)); + void linkGraphicTask(RMGfxTask *task) { + _bigBuf.AddPrim(new RMGfxPrimitive(task)); }; // Manage a location - uint32 LoadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start); - void UnloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result); + uint32 loadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start); + void unloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result); // Freeze and unfreeze - void Freeze(void); - void Unfreeze(void); + void freeze(void); + void unfreeze(void); // State management - void SaveState(const Common::String &fn, byte *curThumb, const Common::String &name); - void LoadState(CORO_PARAM, const Common::String &fn); + void saveState(const Common::String &fn, byte *curThumb, const Common::String &name); + void loadState(CORO_PARAM, const Common::String &fn); // Pauses sound - void PauseSound(bool bPause); + void pauseSound(bool bPause); // Wipe - void InitWipe(int type); - void CloseWipe(void); - void WaitWipeEnd(CORO_PARAM); + void initWipe(int type); + void closeWipe(void); + void waitWipeEnd(CORO_PARAM); - void SetPalesati(bool bpal) { - m_inter.SetPalesati(bpal); + void setPalesati(bool bpal) { + _inter.SetPalesati(bpal); } - bool CanLoadSave(); + bool canLoadSave(); }; } // End of namespace Tony diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index aec1e1a57b..5fb375da81 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -530,7 +530,7 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo g_system->unlockMutex(m_csModifyInterface); } - if (_vm->getEngine()->GetInput().getAsyncKeyState(Common::KEYCODE_i)) { + if (_vm->getEngine()->getInput().getAsyncKeyState(Common::KEYCODE_i)) { GLOBALS.bCfgInvLocked = !GLOBALS.bCfgInvLocked; } diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index c2350d14e4..ab8eb53969 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -140,8 +140,8 @@ Common::ErrorCode TonyEngine::init() { _theBoxes.Init(); // Link to the custom graphics engine - _theEngine.InitCustomDll(); - _theEngine.Init(); + _theEngine.initCustomDll(); + _theEngine.init(); // Allocate space for thumbnails when saving the game _curThumbnail = new uint16[160 * 120]; @@ -406,7 +406,7 @@ void TonyEngine::autoSave(CORO_PARAM) { CORO_INVOKE_0(MainWaitFrame); MainFreeze(); _ctx->buf = getSaveStateFileName(0); - _theEngine.SaveState(_ctx->buf, (byte *)_curThumbnail, "Autosave"); + _theEngine.saveState(_ctx->buf, (byte *)_curThumbnail, "Autosave"); MainUnfreeze(); CORO_END_CODE; @@ -415,7 +415,7 @@ void TonyEngine::autoSave(CORO_PARAM) { void TonyEngine::saveState(int n, const char *name) { Common::String buf = getSaveStateFileName(n); - _theEngine.SaveState(buf.c_str(), (byte *)_curThumbnail, name); + _theEngine.saveState(buf.c_str(), (byte *)_curThumbnail, name); } @@ -427,7 +427,7 @@ void TonyEngine::loadState(CORO_PARAM, int n) { CORO_BEGIN_CODE(_ctx); _ctx->buf = getSaveStateFileName(n); - CORO_INVOKE_1(_theEngine.LoadState, _ctx->buf.c_str()); + CORO_INVOKE_1(_theEngine.loadState, _ctx->buf.c_str()); CORO_END_CODE; } @@ -484,11 +484,11 @@ void TonyEngine::optionScreen(void) { } void TonyEngine::openInitLoadMenu(CORO_PARAM) { - _theEngine.OpenOptionScreen(coroParam, 1); + _theEngine.openOptionScreen(coroParam, 1); } void TonyEngine::openInitOptions(CORO_PARAM) { - _theEngine.OpenOptionScreen(coroParam, 2); + _theEngine.openOptionScreen(coroParam, 2); } void TonyEngine::abortGame(void) { @@ -517,7 +517,7 @@ void TonyEngine::playProcess(CORO_PARAM, const void *param) { // If a savegame needs to be loaded, then do so if (_vm->_loadSlotNumber != -1 && GLOBALS.GfxEngine != NULL) { _ctx->fn = getSaveStateFileName(_vm->_loadSlotNumber); - CORO_INVOKE_1(GLOBALS.GfxEngine->LoadState, _ctx->fn); + CORO_INVOKE_1(GLOBALS.GfxEngine->loadState, _ctx->fn); _vm->_loadSlotNumber = -1; } @@ -525,17 +525,17 @@ void TonyEngine::playProcess(CORO_PARAM, const void *param) { CORO_INVOKE_1(CoroScheduler.sleep, 50); // Call the engine to handle the next frame - CORO_INVOKE_1(_vm->_theEngine.DoFrame, _vm->_bDrawLocation); + CORO_INVOKE_1(_vm->_theEngine.doFrame, _vm->_bDrawLocation); // Warns that a frame is finished CoroScheduler.pulseEvent(_vm->_hEndOfFrame); // Handle drawing the frame if (!_vm->_bPaused) { - if (!_vm->_theEngine.m_bWiping) + if (!_vm->_theEngine._bWiping) _vm->_window.GetNewFrame(_vm->_theEngine, NULL); else - _vm->_window.GetNewFrame(_vm->_theEngine, &_vm->_theEngine.m_rcWipeEllipse); + _vm->_window.GetNewFrame(_vm->_theEngine, &_vm->_theEngine._rcWipeEllipse); } // Paint the frame onto the screen @@ -569,14 +569,14 @@ void TonyEngine::close(void) { closeMusic(); CoroScheduler.closeEvent(_hEndOfFrame); _theBoxes.Close(); - _theEngine.Close(); + _theEngine.close(); _window.Close(); delete[] _curThumbnail; } void TonyEngine::switchFullscreen(bool bFull) { _window.SwitchFullscreen(bFull); - _theEngine.SwitchFullscreen(bFull); + _theEngine.switchFullscreen(bFull); } void TonyEngine::GDIControl(bool bCon) { @@ -601,10 +601,10 @@ uint32 TonyEngine::getTime() { } bool TonyEngine::canLoadGameStateCurrently() { - return GLOBALS.GfxEngine != NULL && GLOBALS.GfxEngine->CanLoadSave(); + return GLOBALS.GfxEngine != NULL && GLOBALS.GfxEngine->canLoadSave(); } bool TonyEngine::canSaveGameStateCurrently() { - return GLOBALS.GfxEngine != NULL && GLOBALS.GfxEngine->CanLoadSave(); + return GLOBALS.GfxEngine != NULL && GLOBALS.GfxEngine->canLoadSave(); } Common::Error TonyEngine::loadGameState(int slot) { @@ -619,7 +619,7 @@ Common::Error TonyEngine::saveGameState(int slot, const Common::String &desc) { RMSnapshot s; s.GrabScreenshot(*GLOBALS.GfxEngine, 4, _curThumbnail); - GLOBALS.GfxEngine->SaveState(getSaveStateFileName(slot), (byte *)_curThumbnail, desc); + GLOBALS.GfxEngine->saveState(getSaveStateFileName(slot), (byte *)_curThumbnail, desc); return Common::kNoError; } -- cgit v1.2.3 From 93cba6d88049d73b965143130a1f7751e3dc79db Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 5 Jun 2012 01:15:25 +0200 Subject: TONY: Rename variables and functions in adv.h --- engines/tony/adv.h | 34 +++++++++++------------ engines/tony/custom.cpp | 37 ++++++++++++------------- engines/tony/debugger.cpp | 2 +- engines/tony/font.cpp | 12 ++++---- engines/tony/game.cpp | 34 +++++++++++------------ engines/tony/gfxengine.cpp | 8 +++--- engines/tony/loc.cpp | 4 +-- engines/tony/tony.cpp | 8 +++--- engines/tony/tonychar.cpp | 68 +++++++++++++++++++++++----------------------- 9 files changed, 102 insertions(+), 105 deletions(-) (limited to 'engines') diff --git a/engines/tony/adv.h b/engines/tony/adv.h index a31c1a28bc..0bdef25ea8 100644 --- a/engines/tony/adv.h +++ b/engines/tony/adv.h @@ -64,23 +64,23 @@ enum RMTonyAction { }; // Global Functions -uint32 MainLoadLocation(int nLoc, RMPoint pt, RMPoint start); -void MainUnloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result); -void MainLinkGraphicTask(RMGfxTask *task); -void MainFreeze(void); -void MainUnfreeze(void); -void MainWaitFrame(CORO_PARAM); -void MainShowMouse(void); -void MainHideMouse(void); -void MainEnableInput(void); -void MainDisableInput(void); -void MainPlayMusic(int nChannel, const char *filename, int nFX, bool bLoop, int nSync); -void MainInitWipe(int type); -void MainCloseWipe(void); -void MainWaitWipeEnd(CORO_PARAM); -void MainEnableGUI(void); -void MainDisableGUI(void); -void MainSetPalesati(bool bPalesati); +uint32 mainLoadLocation(int nLoc, RMPoint pt, RMPoint start); +void mainUnloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result); +void mainLinkGraphicTask(RMGfxTask *task); +void mainFreeze(void); +void mainUnfreeze(void); +void mainWaitFrame(CORO_PARAM); +void mainShowMouse(void); +void mainHideMouse(void); +void mainEnableInput(void); +void mainDisableInput(void); +void mainPlayMusic(int nChannel, const char *filename, int nFX, bool bLoop, int nSync); +void mainInitWipe(int type); +void mainCloseWipe(void); +void mainWaitWipeEnd(CORO_PARAM); +void mainEnableGUI(void); +void mainDisableGUI(void); +void mainSetPalesati(bool bPalesati); } // End of namespace Tony diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 59de6909dc..579532d9bc 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -595,21 +595,18 @@ DECLARE_CUSTOM_FUNCTION(RestoreTonyPosition)(CORO_PARAM, uint32, uint32, uint32, CORO_END_CODE; } - DECLARE_CUSTOM_FUNCTION(DisableInput)(CORO_PARAM, uint32, uint32, uint32, uint32) { - MainDisableInput(); + mainDisableInput(); } - DECLARE_CUSTOM_FUNCTION(EnableInput)(CORO_PARAM, uint32, uint32, uint32, uint32) { - MainEnableInput(); + mainEnableInput(); } DECLARE_CUSTOM_FUNCTION(StopTony)(CORO_PARAM, uint32, uint32, uint32, uint32) { GLOBALS.Tony->StopNoAction(coroParam); } - DECLARE_CUSTOM_FUNCTION(CustEnableGUI)(CORO_PARAM, uint32, uint32, uint32, uint32) { GLOBALS.EnableGUI(); } @@ -2018,7 +2015,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr // Draw the pointer GLOBALS.Pointer->SetSpecialPointer(GLOBALS.Pointer->PTR_NONE); - MainShowMouse(); + mainShowMouse(); while (!(GLOBALS.Input->mouseLeftClicked() && ((_ctx->sel = _ctx->dc.GetSelection()) != -1))) { CORO_INVOKE_0(GLOBALS.WaitFrame); @@ -2028,7 +2025,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr } // Hide the pointer - MainHideMouse(); + mainHideMouse(); CORO_INVOKE_0(_ctx->dc.Hide); mpalQueryDialogSelectionDWORD(_ctx->nChoice, _ctx->sl[_ctx->sel]); @@ -2539,19 +2536,19 @@ void setupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation GLOBALS.Inventory = inv; GLOBALS.Input = input; - GLOBALS.LoadLocation = MainLoadLocation; - GLOBALS.UnloadLocation = MainUnloadLocation; - GLOBALS.LinkGraphicTask = MainLinkGraphicTask; - GLOBALS.Freeze = MainFreeze; - GLOBALS.Unfreeze = MainUnfreeze; - GLOBALS.WaitFrame = MainWaitFrame; - GLOBALS.PlayMusic = MainPlayMusic; - GLOBALS.InitWipe = MainInitWipe; - GLOBALS.CloseWipe = MainCloseWipe; - GLOBALS.WaitWipeEnd = MainWaitWipeEnd; - GLOBALS.DisableGUI = MainDisableGUI; - GLOBALS.EnableGUI = MainEnableGUI; - GLOBALS.SetPalesati = MainSetPalesati; + GLOBALS.LoadLocation = mainLoadLocation; + GLOBALS.UnloadLocation = mainUnloadLocation; + GLOBALS.LinkGraphicTask = mainLinkGraphicTask; + GLOBALS.Freeze = mainFreeze; + GLOBALS.Unfreeze = mainUnfreeze; + GLOBALS.WaitFrame = mainWaitFrame; + GLOBALS.PlayMusic = mainPlayMusic; + GLOBALS.InitWipe = mainInitWipe; + GLOBALS.CloseWipe = mainCloseWipe; + GLOBALS.WaitWipeEnd = mainWaitWipeEnd; + GLOBALS.DisableGUI = mainDisableGUI; + GLOBALS.EnableGUI = mainEnableGUI; + GLOBALS.SetPalesati = mainSetPalesati; GLOBALS.bAlwaysDisplay = false; int i; diff --git a/engines/tony/debugger.cpp b/engines/tony/debugger.cpp index f358d51223..7dc32d9f61 100644 --- a/engines/tony/debugger.cpp +++ b/engines/tony/debugger.cpp @@ -71,7 +71,7 @@ void DebugChangeScene(CORO_PARAM, const void *param) { GLOBALS.LoadLocation(details->sceneNumber, scenePos, RMPoint(-1, -1)); - MainEnableGUI(); + mainEnableGUI(); CORO_END_CODE; } diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 71cffab26b..80837be34d 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -2494,11 +2494,11 @@ void RMDialogChoice::Show(CORO_PARAM, RMGfxTargetBuffer *bigBuf) { _ctx->elaps = 0; while (_ctx->elaps < 700) { - CORO_INVOKE_0(MainWaitFrame); - MainFreeze(); + CORO_INVOKE_0(mainWaitFrame); + mainFreeze(); _ctx->elaps = _vm->getTime() - _ctx->starttime; m_ptDrawPos.y = 480 - ((_ctx->deltay * 100) / 700 * _ctx->elaps) / 100; - MainUnfreeze(); + mainUnfreeze(); } m_ptDrawPos.y = _ctx->destpt.y; @@ -2538,11 +2538,11 @@ void RMDialogChoice::Hide(CORO_PARAM) { _ctx->deltay = 480 - m_ptDrawPos.y; _ctx->elaps = 0; while (_ctx->elaps < 700) { - CORO_INVOKE_0(MainWaitFrame); - MainFreeze(); + CORO_INVOKE_0(mainWaitFrame); + mainFreeze(); _ctx->elaps = _vm->getTime() - _ctx->starttime; m_ptDrawPos.y = 480 - ((_ctx->deltay * 100) / 700 * (700 - _ctx->elaps)) / 100; - MainUnfreeze(); + mainUnfreeze(); } } diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 71dbb68c73..220f41a558 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -46,75 +46,75 @@ using namespace MPAL; /* Global functions */ /****************************************/ -uint32 MainLoadLocation(int nLoc, RMPoint pt, RMPoint start) { +uint32 mainLoadLocation(int nLoc, RMPoint pt, RMPoint start) { return _vm->getEngine()->loadLocation(nLoc, pt, start); } -void MainUnloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result) { +void mainUnloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result) { _vm->getEngine()->unloadLocation(coroParam, bDoOnExit, result); } -void MainLinkGraphicTask(RMGfxTask *task) { +void mainLinkGraphicTask(RMGfxTask *task) { _vm->getEngine()->linkGraphicTask(task); } -void MainFreeze(void) { +void mainFreeze(void) { _vm->getEngine()->freeze(); } -void MainUnfreeze(void) { +void mainUnfreeze(void) { _vm->getEngine()->unfreeze(); } -void MainWaitFrame(CORO_PARAM) { +void mainWaitFrame(CORO_PARAM) { CoroScheduler.waitForSingleObject(coroParam, _vm->_hEndOfFrame, CORO_INFINITE); } -void MainShowMouse(void) { +void mainShowMouse(void) { _vm->getEngine()->enableMouse(); } -void MainHideMouse(void) { +void mainHideMouse(void) { _vm->getEngine()->disableMouse(); } -void MainPlayMusic(int nChannel, const char *filename, int nFX, bool bLoop, int nSync) { +void mainPlayMusic(int nChannel, const char *filename, int nFX, bool bLoop, int nSync) { _vm->playMusic(nChannel, filename, nFX, bLoop, nSync); } -void MainDisableInput(void) { +void mainDisableInput(void) { _vm->getEngine()->disableInput(); } -void MainEnableInput(void) { +void mainEnableInput(void) { _vm->getEngine()->enableInput(); } -void MainInitWipe(int type) { +void mainInitWipe(int type) { _vm->getEngine()->initWipe(type); } -void MainCloseWipe(void) { +void mainCloseWipe(void) { _vm->getEngine()->closeWipe(); } -void MainWaitWipeEnd(CORO_PARAM) { +void mainWaitWipeEnd(CORO_PARAM) { _vm->getEngine()->waitWipeEnd(coroParam); } -void MainEnableGUI(void) { +void mainEnableGUI(void) { _vm->getEngine()->_bGUIInterface = true; _vm->getEngine()->_bGUIInventory = true; _vm->getEngine()->_bGUIOption = true; } -void MainDisableGUI(void) { +void mainDisableGUI(void) { _vm->getEngine()->_bGUIInterface = false; _vm->getEngine()->_bGUIInventory = false; _vm->getEngine()->_bGUIOption = false; } -void MainSetPalesati(bool bPalesati) { +void mainSetPalesati(bool bPalesati) { _vm->getEngine()->setPalesati(bPalesati); } diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 75eb6de883..dd448fdc93 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -366,10 +366,10 @@ void RMGfxEngine::itemIrq(uint32 dwItem, int nPattern, int nStatus) { if (item != NULL) { if (nPattern != -1) { if (GLOBALS.bPatIrqFreeze) - MainFreeze(); + mainFreeze(); item->SetPattern(nPattern, true); if (GLOBALS.bPatIrqFreeze) - MainUnfreeze(); + mainUnfreeze(); } if (nStatus != -1) item->SetStatus(nStatus); @@ -450,7 +450,7 @@ void RMGfxEngine::unloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result) { CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->h, CORO_INFINITE); } - MainFreeze(); + mainFreeze(); _bLocationLoaded = false; @@ -814,7 +814,7 @@ void RMGfxEngine::loadState(CORO_PARAM, const Common::String &fn) { CORO_INVOKE_2(unloadLocation, false, NULL); loadLocation(_ctx->loc, _ctx->tp, RMPoint(-1, -1)); _tony.SetPattern(RMTony::PAT_STANDRIGHT); - MainUnfreeze(); + mainUnfreeze(); // On older versions, need to an enter action if (_ctx->ver < 5) diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index b3768ca330..601ae3f09b 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -886,8 +886,8 @@ void RMWipe::WaitForFadeEnd(CORO_PARAM) { m_bEndFade = true; m_bFading = false; - CORO_INVOKE_0(MainWaitFrame); - CORO_INVOKE_0(MainWaitFrame); + CORO_INVOKE_0(mainWaitFrame); + CORO_INVOKE_0(mainWaitFrame); CORO_END_CODE; } diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index ab8eb53969..98171b2544 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -402,12 +402,12 @@ void TonyEngine::autoSave(CORO_PARAM) { CORO_BEGIN_CODE(_ctx); grabThumbnail(); - CORO_INVOKE_0(MainWaitFrame); - CORO_INVOKE_0(MainWaitFrame); - MainFreeze(); + CORO_INVOKE_0(mainWaitFrame); + CORO_INVOKE_0(mainWaitFrame); + mainFreeze(); _ctx->buf = getSaveStateFileName(0); _theEngine.saveState(_ctx->buf, (byte *)_curThumbnail, "Autosave"); - MainUnfreeze(); + mainUnfreeze(); CORO_END_CODE; } diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index 212899cde3..419f5a251f 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -596,7 +596,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body if (m_bPastorella) { // Talking whilst a shepherdess - MainFreeze(); + mainFreeze(); switch (m_TalkDirection) { case UP: SetPattern(PAT_PAST_TALKUP); @@ -614,7 +614,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body SetPattern(PAT_PAST_TALKRIGHT); break; } - MainUnfreeze(); + mainUnfreeze(); return false; } @@ -1127,10 +1127,10 @@ void RMTony::StartTalk(CORO_PARAM, TALKTYPE nTalkType) { // Perform the set pattern if (_ctx->headStartPat != 0 || _ctx->bodyStartPat != 0) { - MainFreeze(); + mainFreeze(); SetPattern(_ctx->headStartPat); m_body.SetPattern(_ctx->bodyStartPat); - MainUnfreeze(); + mainUnfreeze(); if (_ctx->bodyStartPat != 0) CORO_INVOKE_0(m_body.WaitForEndPattern); @@ -1138,11 +1138,11 @@ void RMTony::StartTalk(CORO_PARAM, TALKTYPE nTalkType) { CORO_INVOKE_0(WaitForEndPattern); } - MainFreeze(); + mainFreeze(); SetPattern(_ctx->headLoopPat); if (_ctx->bodyLoopPat) m_body.SetPattern(_ctx->bodyLoopPat); - MainUnfreeze(); + mainUnfreeze(); CORO_END_CODE; } @@ -1175,9 +1175,9 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa } if (m_bPastorella) { - MainFreeze(); + mainFreeze(); SetPattern(finalPat); - MainUnfreeze(); + mainUnfreeze(); m_bIsTalking = false; return false; } @@ -1447,7 +1447,7 @@ void RMTony::EndTalk(CORO_PARAM) { // Handles the end of an animated and static, leaving everything unchanged if (m_bIsStaticTalk) { if (m_nTalkType == TALK_CONBARBASTATIC) { - MainFreeze(); + mainFreeze(); SetPattern(0); if (m_TalkDirection == UP || m_TalkDirection == LEFT) { m_body.SetPattern(BPAT_CONBARBALEFT_STATIC); @@ -1456,11 +1456,11 @@ void RMTony::EndTalk(CORO_PARAM) { m_body.SetPattern(BPAT_CONBARBARIGHT_STATIC); m_nBodyOffset.Set(-26, -14); } - MainUnfreeze(); + mainUnfreeze(); } else { - MainFreeze(); + mainFreeze(); SetPattern(_ctx->headStandPat); - MainUnfreeze(); + mainUnfreeze(); CORO_INVOKE_0(m_body.WaitForEndPattern); } @@ -1471,36 +1471,36 @@ void RMTony::EndTalk(CORO_PARAM) { // Set the pattern if (_ctx->headEndPat != 0 && _ctx->bodyEndPat != 0) { - MainFreeze(); + mainFreeze(); SetPattern(_ctx->headEndPat); - MainUnfreeze(); + mainUnfreeze(); CORO_INVOKE_0(m_body.WaitForEndPattern); - MainFreeze(); + mainFreeze(); m_body.SetPattern(_ctx->bodyEndPat); - MainUnfreeze(); + mainUnfreeze(); CORO_INVOKE_0(WaitForEndPattern); CORO_INVOKE_0(m_body.WaitForEndPattern); } else if (_ctx->bodyEndPat != 0) { - MainFreeze(); + mainFreeze(); SetPattern(_ctx->headStandPat); - MainUnfreeze(); + mainUnfreeze(); CORO_INVOKE_0(m_body.WaitForEndPattern); - MainFreeze(); + mainFreeze(); m_body.SetPattern(_ctx->bodyEndPat); - MainUnfreeze(); + mainUnfreeze(); CORO_INVOKE_0(m_body.WaitForEndPattern); } else if (_ctx->headEndPat != 0) { CORO_INVOKE_0(m_body.WaitForEndPattern); - MainFreeze(); + mainFreeze(); SetPattern(_ctx->headEndPat); - MainUnfreeze(); + mainUnfreeze(); CORO_INVOKE_0(WaitForEndPattern); } else { @@ -1508,10 +1508,10 @@ void RMTony::EndTalk(CORO_PARAM) { } if (_ctx->finalPat != 0) { - MainFreeze(); + mainFreeze(); m_body.SetPattern(0); SetPattern(_ctx->finalPat); - MainUnfreeze(); + mainUnfreeze(); } m_bIsTalking = false; @@ -1740,19 +1740,19 @@ void RMTony::StartStatic(CORO_PARAM, TALKTYPE nTalk) { // e vai con i pattern m_bIsStaticTalk = true; - MainFreeze(); + mainFreeze(); SetPattern(_ctx->headPat); m_body.SetPattern(_ctx->bodyStartPat); - MainUnfreeze(); + mainUnfreeze(); CORO_INVOKE_0(m_body.WaitForEndPattern); CORO_INVOKE_0(WaitForEndPattern); - MainFreeze(); + mainFreeze(); if (_ctx->headLoopPat != -1) SetPattern(_ctx->headLoopPat); m_body.SetPattern(_ctx->bodyLoopPat); - MainUnfreeze(); + mainUnfreeze(); CORO_END_CODE; } @@ -1910,24 +1910,24 @@ void RMTony::EndStatic(CORO_PARAM, TALKTYPE nTalk) { EndStaticCalculate(nTalk, _ctx->bodyEndPat, _ctx->finalPat, _ctx->headEndPat); if (_ctx->headEndPat != 0) { - MainFreeze(); + mainFreeze(); SetPattern(_ctx->headEndPat); - MainUnfreeze(); + mainUnfreeze(); CORO_INVOKE_0(WaitForEndPattern); } else { // Play please - MainFreeze(); + mainFreeze(); m_body.SetPattern(_ctx->bodyEndPat); - MainUnfreeze(); + mainUnfreeze(); CORO_INVOKE_0(m_body.WaitForEndPattern); } - MainFreeze(); + mainFreeze(); SetPattern(_ctx->finalPat); m_body.SetPattern(0); - MainUnfreeze(); + mainUnfreeze(); m_bIsStaticTalk = false; -- cgit v1.2.3 From 23c95d7014ee9875bb1b55c696d0245d7f114ba8 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 5 Jun 2012 08:39:55 +0200 Subject: TONY: Some more renaming --- engines/tony/custom.cpp | 2 +- engines/tony/font.cpp | 154 ++++++------- engines/tony/font.h | 26 +-- engines/tony/game.cpp | 156 +++++++------ engines/tony/game.h | 12 +- engines/tony/gfxcore.cpp | 551 +++++++++++++++++++++++---------------------- engines/tony/gfxcore.h | 282 +++++++++++------------ engines/tony/gfxengine.cpp | 20 +- engines/tony/gfxengine.h | 2 +- engines/tony/inventory.cpp | 108 ++++----- engines/tony/inventory.h | 4 +- engines/tony/loc.cpp | 86 +++---- engines/tony/loc.h | 10 +- engines/tony/tony.cpp | 6 +- engines/tony/tonychar.cpp | 22 +- engines/tony/tonychar.h | 6 +- engines/tony/window.cpp | 2 +- engines/tony/window.h | 4 +- 18 files changed, 731 insertions(+), 722 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 579532d9bc..8092109ef5 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -1998,7 +1998,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr } // Making a choice for dialog - _ctx->dc.Init(); + _ctx->dc.init(); _ctx->dc.SetNumChoices(_ctx->num); // Writeall the possible options diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 80837be34d..16cf4497fc 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -69,8 +69,8 @@ void RMFont::Load(const byte *buf, int nChars, int dimx, int dimy, uint32 palRes // Initialise the fonts for (int i = 0; i < nChars; i++) { // Initialise the buffer with the letters - m_letter[i].Init(buf + i * (dimx * dimy + 8) + 8, dimx, dimy); - m_letter[i].LoadPaletteWA(palResID); + m_letter[i].init(buf + i * (dimx * dimy + 8) + 8, dimx, dimy); + m_letter[i].loadPaletteWA(palResID); } m_fontDimx = dimx; @@ -114,7 +114,7 @@ RMGfxPrimitive *RMFont::MakeLetterPrimitive(byte bChar, int &nLength) { return prim; } -void RMFont::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim2) { +void RMFont::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim2) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); @@ -124,7 +124,7 @@ void RMFont::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim2) // Call the draw method of the letter assigned to the primitive if (prim->m_nChar != -1) - CORO_INVOKE_2(m_letter[prim->m_nChar].Draw, bigBuf, prim); + CORO_INVOKE_2(m_letter[prim->m_nChar].draw, bigBuf, prim); CORO_END_CODE; } @@ -197,7 +197,7 @@ void RMFontColor::SetBaseColor(byte r1, byte g1, byte b1) { // Puts in all the letters for (i = 0; i < nLetters; i++) - m_letter[i].LoadPaletteWA(pal); + m_letter[i].loadPaletteWA(pal); } @@ -205,7 +205,7 @@ void RMFontColor::SetBaseColor(byte r1, byte g1, byte b1) { * RMFontParla Methods \****************************************************************************/ -void RMFontParla::Init(void) { +void RMFontParla::init(void) { int i; // bernie: Number of characters in the font @@ -612,7 +612,7 @@ void RMFontParla::Init(void) { * RMFontMacc Methods \****************************************************************************/ -void RMFontMacc::Init(void) { +void RMFontMacc::init(void) { int i; // bernie: Number of characters in the font @@ -976,7 +976,7 @@ void RMFontMacc::Init(void) { * RMFontCredits Methods \****************************************************************************/ -void RMFontCredits::Init(void) { +void RMFontCredits::init(void) { int i; // bernie: Number of characters in the font @@ -1441,7 +1441,7 @@ void RMFontObj::SetBothCase(int nChar, int nNext, signed char spiazz) { } -void RMFontObj::Init(void) { +void RMFontObj::init(void) { int i; //bernie: Number of characters in the font (solo maiuscolo) @@ -1763,7 +1763,7 @@ void RMFontObj::Init(void) { RMFontColor *RMText::m_fonts[4] = { NULL, NULL, NULL, NULL }; RMGfxClearTask RMText::m_clear; -void RMText::InitStatics() { +void RMText::initStatics() { Common::fill(&m_fonts[0], &m_fonts[4], (RMFontColor *)NULL); } @@ -1774,10 +1774,10 @@ RMText::RMText() { // Default length maxLineLength = 350; - m_bTrasp0 = true; + _bTrasp0 = true; aHorType = HCENTER; aVerType = VTOP; - SetPriority(150); + setPriority(150); } RMText::~RMText() { @@ -1808,13 +1808,13 @@ void RMText::WriteText(const RMString &text, int nFont, int *time) { // Initialises the font (only once) if (m_fonts[0] == NULL) { m_fonts[0] = new RMFontParla; - m_fonts[0]->Init(); + m_fonts[0]->init(); m_fonts[1] = new RMFontObj; - m_fonts[1]->Init(); + m_fonts[1]->init(); m_fonts[2] = new RMFontMacc; - m_fonts[2]->Init(); + m_fonts[2]->init(); m_fonts[3] = new RMFontCredits; - m_fonts[3]->Init(); + m_fonts[3]->init(); } WriteText(text, m_fonts[nFont], time); @@ -1835,7 +1835,7 @@ void RMText::WriteText(const RMString &text, RMFontColor *font, int *time) { font->SetBaseColor(m_r, m_g, m_b); // Destroy the buffer before starting - Destroy(); + destroy(); // If the string is empty, do nothing if (text == NULL || text[0] == '\0') @@ -1893,7 +1893,7 @@ void RMText::WriteText(const RMString &text, RMFontColor *font, int *time) { // Create the surface Create(width, height); //AddPrim(new RMGfxPrimitive(&m_clear)); - Common::fill(m_buf, m_buf + width * height * 2, 0); + Common::fill(_buf, _buf + width * height * 2, 0); p = string; @@ -1935,7 +1935,7 @@ void RMText::WriteText(const RMString &text, RMFontColor *font, int *time) { prim = font->MakeLetterPrimitive(*p, len); prim->Dst().x1 = x; prim->Dst().y1 = y; - AddPrim(prim); + addPrim(prim); numchar++; @@ -1956,37 +1956,37 @@ void RMText::ClipOnScreen(RMGfxPrimitive *prim) { prim->Dst().x1 = 5; if (prim->Dst().y1 < 5) prim->Dst().y1 = 5; - if (prim->Dst().x1 + m_dimx > 635) - prim->Dst().x1 = 635 - m_dimx; - if (prim->Dst().y1 + m_dimy > 475) - prim->Dst().y1 = 475 - m_dimy; + if (prim->Dst().x1 + _dimx > 635) + prim->Dst().x1 = 635 - _dimx; + if (prim->Dst().y1 + _dimy > 475) + prim->Dst().y1 = 475 - _dimy; } -void RMText::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMText::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); // Horizontally if (aHorType == HCENTER) - prim->Dst().TopLeft() -= RMPoint(m_dimx / 2, 0); + prim->Dst().TopLeft() -= RMPoint(_dimx / 2, 0); else if (aHorType == HRIGHT) - prim->Dst().TopLeft() -= RMPoint(m_dimx, 0); + prim->Dst().TopLeft() -= RMPoint(_dimx, 0); // Vertically if (aVerType == VTOP) { } else if (aVerType == VCENTER) { - prim->Dst().y1 -= m_dimy / 2; + prim->Dst().y1 -= _dimy / 2; } else if (aVerType == VBOTTOM) { - prim->Dst().y1 -= m_dimy; + prim->Dst().y1 -= _dimy; } ClipOnScreen(prim); - CORO_INVOKE_2(RMGfxWoodyBuffer::Draw, bigBuf, prim); + CORO_INVOKE_2(RMGfxWoodyBuffer::draw, bigBuf, prim); CORO_END_CODE; } @@ -2132,11 +2132,11 @@ void RMTextDialog::RemoveThis(CORO_PARAM, bool &result) { void RMTextDialog::Unregister(void) { RMGfxTask::Unregister(); - assert(m_nInList == 0); + assert(_nInList == 0); CoroScheduler.setEvent(hEndDisplay); } -void RMTextDialog::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMTextDialog::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); @@ -2148,7 +2148,7 @@ void RMTextDialog::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *p if (m_bShowed) { if (GLOBALS.bCfgSottotitoli || m_bAlwaysDisplay) { prim->Dst().TopLeft() = dst; - CORO_INVOKE_2(RMText::Draw, bigBuf, prim); + CORO_INVOKE_2(RMText::draw, bigBuf, prim); } } @@ -2187,7 +2187,7 @@ RMTextDialogScrolling::RMTextDialogScrolling(RMLocation *loc) { RMTextDialogScrolling::~RMTextDialogScrolling() { } -void RMTextDialogScrolling::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMTextDialogScrolling::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CONTEXT; RMPoint curDst; CORO_END_CONTEXT(_ctx); @@ -2199,7 +2199,7 @@ void RMTextDialogScrolling::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPri if (curLoc != NULL) dst -= curLoc->ScrollPosition() - startScroll; - CORO_INVOKE_2(RMTextDialog::Draw, bigBuf, prim); + CORO_INVOKE_2(RMTextDialog::draw, bigBuf, prim); dst = _ctx->curDst; @@ -2217,7 +2217,7 @@ void RMTextDialogScrolling::ClipOnScreen(RMGfxPrimitive *prim) { RMTextItemName::RMTextItemName() : RMText() { m_item = NULL; - SetPriority(220); + setPriority(220); } RMTextItemName::~RMTextItemName() { @@ -2237,8 +2237,8 @@ void RMTextItemName::DoFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation & _ctx->lastItem = m_item; // Adds to the list if there is need - if (!m_nInList) - bigBuf.AddPrim(new RMGfxPrimitive(this)); + if (!_nInList) + bigBuf.addPrim(new RMGfxPrimitive(this)); // Update the scrolling co-ordinates m_curscroll = loc.ScrollPosition(); @@ -2275,20 +2275,20 @@ void RMTextItemName::DoFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation & } -void RMTextItemName::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMTextItemName::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); // If there is no text, it's pointless to continue - if (m_buf == NULL) + if (_buf == NULL) return; // Set the destination coordinates of the mouse prim->Dst().TopLeft() = m_mpos - RMPoint(0, 30); - CORO_INVOKE_2(RMText::Draw, bigBuf, prim); + CORO_INVOKE_2(RMText::draw, bigBuf, prim); CORO_END_CODE; } @@ -2322,11 +2322,11 @@ RMDialogChoice::RMDialogChoice() { RMResRaw dlg2(RES_I_DLGTEXTLINE); RMRes dlgpal(RES_I_DLGTEXTPAL); - DlgText.Init(dlg1, dlg1.Width(), dlg1.Height()); - DlgTextLine.Init(dlg2, dlg2.Width(), dlg2.Height()); + DlgText.init(dlg1, dlg1.Width(), dlg1.Height()); + DlgTextLine.init(dlg2, dlg2.Width(), dlg2.Height()); - DlgText.LoadPaletteWA(dlgpal); - DlgTextLine.LoadPaletteWA(dlgpal); + DlgText.loadPaletteWA(dlgpal); + DlgTextLine.loadPaletteWA(dlgpal); hUnreg = CoroScheduler.createEvent(false, false); bRemoveFromOT = false; @@ -2338,20 +2338,20 @@ RMDialogChoice::~RMDialogChoice() { void RMDialogChoice::Unregister(void) { RMGfxWoodyBuffer::Unregister(); - assert(!m_nInList); + assert(!_nInList); CoroScheduler.pulseEvent(hUnreg); bRemoveFromOT = false; } -void RMDialogChoice::Init(void) { +void RMDialogChoice::init(void) { m_numChoices = 0; m_drawedStrings = NULL; m_ptDrawStrings = NULL; m_curSelection = -1; Create(640, 477); - SetPriority(140); + setPriority(140); } @@ -2366,7 +2366,7 @@ void RMDialogChoice::Close(void) { m_ptDrawStrings = NULL; } - Destroy(); + destroy(); } void RMDialogChoice::SetNumChoices(int num) { @@ -2384,7 +2384,7 @@ void RMDialogChoice::SetNumChoices(int num) { m_drawedStrings[i].SetColor(0, 255, 0); m_drawedStrings[i].SetAlignType(RMText::HLEFTPAR, RMText::VTOP); m_drawedStrings[i].SetMaxLineLength(600); - m_drawedStrings[i].SetPriority(10); + m_drawedStrings[i].setPriority(10); } } @@ -2402,22 +2402,22 @@ void RMDialogChoice::Prepare(CORO_PARAM) { CORO_BEGIN_CODE(_ctx); - AddPrim(new RMGfxPrimitive(&DlgText, RMPoint(0, 0))); - AddPrim(new RMGfxPrimitive(&DlgTextLine, RMPoint(0, 155))); - AddPrim(new RMGfxPrimitive(&DlgTextLine, RMPoint(0, 155 + 83))); - AddPrim(new RMGfxPrimitive(&DlgTextLine, RMPoint(0, 155 + 83 + 83))); - AddPrim(new RMGfxPrimitive(&DlgTextLine, RMPoint(0, 155 + 83 + 83 + 83))); + addPrim(new RMGfxPrimitive(&DlgText, RMPoint(0, 0))); + addPrim(new RMGfxPrimitive(&DlgTextLine, RMPoint(0, 155))); + addPrim(new RMGfxPrimitive(&DlgTextLine, RMPoint(0, 155 + 83))); + addPrim(new RMGfxPrimitive(&DlgTextLine, RMPoint(0, 155 + 83 + 83))); + addPrim(new RMGfxPrimitive(&DlgTextLine, RMPoint(0, 155 + 83 + 83 + 83))); _ctx->ptPos.Set(20, 90); for (_ctx->i = 0; _ctx->i < m_numChoices; _ctx->i++) { - AddPrim(new RMGfxPrimitive(&m_drawedStrings[_ctx->i], _ctx->ptPos)); + addPrim(new RMGfxPrimitive(&m_drawedStrings[_ctx->i], _ctx->ptPos)); m_ptDrawStrings[_ctx->i] = _ctx->ptPos; - _ctx->ptPos.Offset(0, m_drawedStrings[_ctx->i].Dimy() + 15); + _ctx->ptPos.Offset(0, m_drawedStrings[_ctx->i].getDimy() + 15); } - CORO_INVOKE_0(DrawOT); - ClearOT(); + CORO_INVOKE_0(drawOT); + clearOT(); m_ptDrawPos.Set(0, 480 - _ctx->ptPos.y); @@ -2435,29 +2435,29 @@ void RMDialogChoice::SetSelected(CORO_PARAM, int pos) { if (pos == m_curSelection) return; - _ctx->box.SetPriority(5); + _ctx->box.setPriority(5); if (m_curSelection != -1) { _ctx->box.SetColor(0xCC, 0xCC, 0xFF); _ctx->rc.TopLeft() = RMPoint(18, m_ptDrawStrings[m_curSelection].y); - _ctx->rc.BottomRight() = _ctx->rc.TopLeft() + RMPoint(597, m_drawedStrings[m_curSelection].Dimy()); - AddPrim(new RMGfxPrimitive(&_ctx->box, _ctx->rc)); + _ctx->rc.BottomRight() = _ctx->rc.TopLeft() + RMPoint(597, m_drawedStrings[m_curSelection].getDimy()); + addPrim(new RMGfxPrimitive(&_ctx->box, _ctx->rc)); - AddPrim(new RMGfxPrimitive(&m_drawedStrings[m_curSelection], m_ptDrawStrings[m_curSelection])); - CORO_INVOKE_0(DrawOT); - ClearOT(); + addPrim(new RMGfxPrimitive(&m_drawedStrings[m_curSelection], m_ptDrawStrings[m_curSelection])); + CORO_INVOKE_0(drawOT); + clearOT(); } if (pos != -1) { _ctx->box.SetColor(100, 100, 100); _ctx->rc.TopLeft() = RMPoint(18, m_ptDrawStrings[pos].y); - _ctx->rc.BottomRight() = _ctx->rc.TopLeft() + RMPoint(597, m_drawedStrings[pos].Dimy()); - AddPrim(new RMGfxPrimitive(&_ctx->box, _ctx->rc)); - AddPrim(new RMGfxPrimitive(&m_drawedStrings[pos], m_ptDrawStrings[pos])); + _ctx->rc.BottomRight() = _ctx->rc.TopLeft() + RMPoint(597, m_drawedStrings[pos].getDimy()); + addPrim(new RMGfxPrimitive(&_ctx->box, _ctx->rc)); + addPrim(new RMGfxPrimitive(&m_drawedStrings[pos], m_ptDrawStrings[pos])); } - CORO_INVOKE_0(DrawOT); - ClearOT(); + CORO_INVOKE_0(drawOT); + clearOT(); m_curSelection = pos; @@ -2477,8 +2477,8 @@ void RMDialogChoice::Show(CORO_PARAM, RMGfxTargetBuffer *bigBuf) { CORO_INVOKE_0(Prepare); m_bShow = false; - if (!m_nInList && bigBuf != NULL) - bigBuf->AddPrim(new RMGfxPrimitive(this)); + if (!_nInList && bigBuf != NULL) + bigBuf->addPrim(new RMGfxPrimitive(this)); if (0) { m_bShow = true; @@ -2488,8 +2488,8 @@ void RMDialogChoice::Show(CORO_PARAM, RMGfxTargetBuffer *bigBuf) { _ctx->destpt = m_ptDrawPos; m_ptDrawPos.Set(0, 480); - if (!m_nInList && bigBuf != NULL) - bigBuf->AddPrim(new RMGfxPrimitive(this)); + if (!_nInList && bigBuf != NULL) + bigBuf->addPrim(new RMGfxPrimitive(this)); m_bShow = true; _ctx->elaps = 0; @@ -2507,7 +2507,7 @@ void RMDialogChoice::Show(CORO_PARAM, RMGfxTargetBuffer *bigBuf) { CORO_END_CODE; } -void RMDialogChoice::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMDialogChoice::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); @@ -2516,8 +2516,8 @@ void RMDialogChoice::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive if (m_bShow == false) return; - prim->SetDst(m_ptDrawPos); - CORO_INVOKE_2(RMGfxSourceBuffer16::Draw, bigBuf, prim); + prim->setDst(m_ptDrawPos); + CORO_INVOKE_2(RMGfxSourceBuffer16::draw, bigBuf, prim); CORO_END_CODE; } @@ -2567,7 +2567,7 @@ void RMDialogChoice::DoFrame(CORO_PARAM, RMPoint ptMousePos) { if (ptMousePos.y > m_ptDrawPos.y) { for (_ctx->i = 0; _ctx->i < m_numChoices; _ctx->i++) { - if ((ptMousePos.y >= m_ptDrawPos.y + m_ptDrawStrings[_ctx->i].y) && (ptMousePos.y < m_ptDrawPos.y + m_ptDrawStrings[_ctx->i].y + m_drawedStrings[_ctx->i].Dimy())) { + if ((ptMousePos.y >= m_ptDrawPos.y + m_ptDrawStrings[_ctx->i].y) && (ptMousePos.y < m_ptDrawPos.y + m_ptDrawStrings[_ctx->i].y + m_drawedStrings[_ctx->i].getDimy())) { CORO_INVOKE_1(SetSelected, _ctx->i); break; } diff --git a/engines/tony/font.h b/engines/tony/font.h index 82ce686ec0..0faaec89d4 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -90,11 +90,11 @@ public: virtual ~RMFont(); // Initialisation and closing - virtual void Init(void) = 0; + virtual void init(void) = 0; virtual void Close(void); // Drawing - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBug, RMGfxPrimitive *prim); + virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBug, RMGfxPrimitive *prim); // Create a primitive for a letter RMGfxPrimitive *MakeLetterPrimitive(byte bChar, int &nLength); @@ -143,7 +143,7 @@ public: class RMFontParla : public RMFontColor, public RMFontWithTables { public: - void Init(void); + void init(void); virtual ~RMFontParla() {} }; @@ -152,19 +152,19 @@ private: void SetBothCase(int nChar, int nNext, signed char spiazz); public: - void Init(void); + void init(void); virtual ~RMFontObj() {} }; class RMFontMacc : public RMFontColor, public RMFontWithTables { public: - void Init(void); + void init(void); virtual ~RMFontMacc() {} }; class RMFontCredits : public RMFontColor, public RMFontWithTables { public: - void Init(void); + void init(void); virtual ~RMFontCredits() {} virtual void SetBaseColor(byte r, byte g, byte b) {} }; @@ -203,7 +203,7 @@ protected: public: RMText(); virtual ~RMText(); - static void InitStatics(); + static void initStatics(); static void Unload(); // Set the alignment type @@ -223,7 +223,7 @@ public: virtual void RemoveThis(CORO_PARAM, bool &result); // Overloading of the Draw to center the text, if necessary - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Set the base colour void SetColor(byte r, byte g, byte b) { @@ -267,7 +267,7 @@ public: virtual void Unregister(void); // Overloading of the Draw to center the text, if necessary - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Set the position void SetPosition(const RMPoint &pt) { @@ -304,7 +304,7 @@ public: RMTextDialogScrolling(RMLocation *loc); virtual ~RMTextDialogScrolling(); - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); }; @@ -327,7 +327,7 @@ public: } void DoFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation &loc, RMPointer &ptr, RMInventory &inv); - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); RMPoint GetHotspot(); RMItem *GetSelectedItem(); @@ -363,7 +363,7 @@ protected: public: virtual void RemoveThis(CORO_PARAM, bool &result); - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); void Unregister(void); public: @@ -372,7 +372,7 @@ public: virtual ~RMDialogChoice(); // Initialisation and closure - void Init(void); + void init(void); void Close(void); // Sets the number of possible sentences, which then be added with AddChoice() diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 220f41a558..c22706cc6d 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -126,7 +126,7 @@ RMOptionButton::RMOptionButton(uint32 dwRes, RMPoint pt, bool bDoubleState) { RMResRaw raw(dwRes); assert(raw.IsValid()); m_buf = new RMGfxSourceBuffer16(false); - m_buf->Init(raw, raw.Width(), raw.Height()); + m_buf->init(raw, raw.Width(), raw.Height()); m_rect.SetRect(pt.x, pt.y, pt.x + raw.Width() - 1, pt.y + raw.Height() - 1); m_bActive = false; @@ -170,9 +170,7 @@ bool RMOptionButton::DoFrame(const RMPoint &mousePos, bool bLeftClick, bool bRig return false; } - - -void RMOptionButton::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMOptionButton::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); @@ -182,14 +180,14 @@ void RMOptionButton::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive return; if (m_bHasGfx) - CORO_INVOKE_2(m_buf->Draw, bigBuf, prim); + CORO_INVOKE_2(m_buf->draw, bigBuf, prim); CORO_END_CODE; } void RMOptionButton::AddToList(RMGfxTargetBuffer &bigBuf) { if (m_bHasGfx) - bigBuf.AddPrim(new RMGfxPrimitive(this, m_rect)); + bigBuf.addPrim(new RMGfxPrimitive(this, m_rect)); } /****************************************************************************\ @@ -272,7 +270,7 @@ bool RMOptionSlide::DoFrame(const RMPoint &mousePos, bool bLeftClick, bool bRigh return bRefresh; } -void RMOptionSlide::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMOptionSlide::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CONTEXT; int i; int val; @@ -290,21 +288,21 @@ void RMOptionSlide::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive * else if (_ctx->val > 100) _ctx->val = 100; if (_ctx->val == 1) { - prim->SetDst(_ctx->pos); - CORO_INVOKE_2(m_SliderSingle->Draw, bigBuf, prim); + prim->setDst(_ctx->pos); + CORO_INVOKE_2(m_SliderSingle->draw, bigBuf, prim); } else { - prim->SetDst(_ctx->pos); - CORO_INVOKE_2(m_SliderLeft->Draw, bigBuf, prim); + prim->setDst(_ctx->pos); + CORO_INVOKE_2(m_SliderLeft->draw, bigBuf, prim); _ctx->pos.x += 3; for (_ctx->i = 1; _ctx->i < _ctx->val - 1; _ctx->i++) { - prim->SetDst(_ctx->pos); - CORO_INVOKE_2(m_SliderCenter->Draw, bigBuf, prim); + prim->setDst(_ctx->pos); + CORO_INVOKE_2(m_SliderCenter->draw, bigBuf, prim); _ctx->pos.x += 3; } - prim->SetDst(_ctx->pos); - CORO_INVOKE_2(m_SliderRight->Draw, bigBuf, prim); + prim->setDst(_ctx->pos); + CORO_INVOKE_2(m_SliderRight->draw, bigBuf, prim); _ctx->pos.x += 3; } @@ -312,7 +310,7 @@ void RMOptionSlide::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive * } void RMOptionSlide::AddToList(RMGfxTargetBuffer &bigBuf) { - bigBuf.AddPrim(new RMGfxPrimitive(this)); + bigBuf.addPrim(new RMGfxPrimitive(this)); } @@ -392,15 +390,15 @@ void RMOptionScreen::RefreshAll(CORO_PARAM) { CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - ClearOT(); + clearOT(); - AddPrim(new RMGfxPrimitive(m_menu)); + addPrim(new RMGfxPrimitive(m_menu)); if (m_bNoLoadSave) - AddPrim(new RMGfxPrimitive(m_HideLoadSave, RMPoint(0, 401))); + addPrim(new RMGfxPrimitive(m_HideLoadSave, RMPoint(0, 401))); if (m_bQuitConfirm) { - AddPrim(new RMGfxPrimitive(m_QuitConfirm, RMPoint(270, 200))); + addPrim(new RMGfxPrimitive(m_QuitConfirm, RMPoint(270, 200))); m_ButtonQuitYes->AddToList(*this); m_ButtonQuitNo->AddToList(*this); } @@ -449,62 +447,62 @@ void RMOptionScreen::RefreshAll(CORO_PARAM) { _ctx->title->WriteText(msg[0], 1); } - AddPrim(new RMGfxPrimitive(_ctx->title, RMPoint(320, 10))); + addPrim(new RMGfxPrimitive(_ctx->title, RMPoint(320, 10))); if (m_curThumbDiff[0] == 0) - AddPrim(new RMGfxPrimitive(m_SaveHard, RMPoint(48, 57))); + addPrim(new RMGfxPrimitive(m_SaveHard, RMPoint(48, 57))); else if (m_curThumbDiff[0] == 1) - AddPrim(new RMGfxPrimitive(m_SaveEasy, RMPoint(48, 57))); + addPrim(new RMGfxPrimitive(m_SaveEasy, RMPoint(48, 57))); if (m_curThumbDiff[1] == 0) - AddPrim(new RMGfxPrimitive(m_SaveHard, RMPoint(240, 57))); + addPrim(new RMGfxPrimitive(m_SaveHard, RMPoint(240, 57))); else if (m_curThumbDiff[1] == 1) - AddPrim(new RMGfxPrimitive(m_SaveEasy, RMPoint(240, 57))); + addPrim(new RMGfxPrimitive(m_SaveEasy, RMPoint(240, 57))); if (m_curThumbDiff[2] == 0) - AddPrim(new RMGfxPrimitive(m_SaveHard, RMPoint(432, 57))); + addPrim(new RMGfxPrimitive(m_SaveHard, RMPoint(432, 57))); else if (m_curThumbDiff[2] == 1) - AddPrim(new RMGfxPrimitive(m_SaveEasy, RMPoint(432, 57))); + addPrim(new RMGfxPrimitive(m_SaveEasy, RMPoint(432, 57))); if (m_curThumbDiff[3] == 0) - AddPrim(new RMGfxPrimitive(m_SaveHard, RMPoint(48, 239))); + addPrim(new RMGfxPrimitive(m_SaveHard, RMPoint(48, 239))); else if (m_curThumbDiff[3] == 1) - AddPrim(new RMGfxPrimitive(m_SaveEasy, RMPoint(48, 239))); + addPrim(new RMGfxPrimitive(m_SaveEasy, RMPoint(48, 239))); if (m_curThumbDiff[4] == 0) - AddPrim(new RMGfxPrimitive(m_SaveHard, RMPoint(240, 239))); + addPrim(new RMGfxPrimitive(m_SaveHard, RMPoint(240, 239))); else if (m_curThumbDiff[4] == 1) - AddPrim(new RMGfxPrimitive(m_SaveEasy, RMPoint(240, 239))); + addPrim(new RMGfxPrimitive(m_SaveEasy, RMPoint(240, 239))); if (m_curThumbDiff[5] == 0) - AddPrim(new RMGfxPrimitive(m_SaveHard, RMPoint(432, 239))); + addPrim(new RMGfxPrimitive(m_SaveHard, RMPoint(432, 239))); else if (m_curThumbDiff[5] == 1) - AddPrim(new RMGfxPrimitive(m_SaveEasy, RMPoint(432, 239))); + addPrim(new RMGfxPrimitive(m_SaveEasy, RMPoint(432, 239))); if (m_curThumb[0] && !(m_bEditSaveName && m_nEditPos == 0)) - AddPrim(new RMGfxPrimitive(m_curThumb[0], RMPoint(48, 57))); + addPrim(new RMGfxPrimitive(m_curThumb[0], RMPoint(48, 57))); if (m_curThumb[1] && !(m_bEditSaveName && m_nEditPos == 1)) - AddPrim(new RMGfxPrimitive(m_curThumb[1], RMPoint(240, 57))); + addPrim(new RMGfxPrimitive(m_curThumb[1], RMPoint(240, 57))); if (m_curThumb[2] && !(m_bEditSaveName && m_nEditPos == 2)) - AddPrim(new RMGfxPrimitive(m_curThumb[2], RMPoint(432, 57))); + addPrim(new RMGfxPrimitive(m_curThumb[2], RMPoint(432, 57))); if (m_curThumb[3] && !(m_bEditSaveName && m_nEditPos == 3)) - AddPrim(new RMGfxPrimitive(m_curThumb[3], RMPoint(48, 239))); + addPrim(new RMGfxPrimitive(m_curThumb[3], RMPoint(48, 239))); if (m_curThumb[4] && !(m_bEditSaveName && m_nEditPos == 4)) - AddPrim(new RMGfxPrimitive(m_curThumb[4], RMPoint(240, 239))); + addPrim(new RMGfxPrimitive(m_curThumb[4], RMPoint(240, 239))); if (m_curThumb[5] && !(m_bEditSaveName && m_nEditPos == 5)) - AddPrim(new RMGfxPrimitive(m_curThumb[5], RMPoint(432, 239))); + addPrim(new RMGfxPrimitive(m_curThumb[5], RMPoint(432, 239))); if (m_bEditSaveName) { _ctx->thumb = new RMGfxSourceBuffer16; - _ctx->thumb->Init((byte *)_vm->getThumbnail(), 640 / 4, 480 / 4); + _ctx->thumb->init((byte *)_vm->getThumbnail(), 640 / 4, 480 / 4); if (m_nEditPos == 0) - AddPrim(new RMGfxPrimitive(_ctx->thumb, RMPoint(48, 57))); + addPrim(new RMGfxPrimitive(_ctx->thumb, RMPoint(48, 57))); else if (m_nEditPos == 1) - AddPrim(new RMGfxPrimitive(_ctx->thumb, RMPoint(240, 57))); + addPrim(new RMGfxPrimitive(_ctx->thumb, RMPoint(240, 57))); else if (m_nEditPos == 2) - AddPrim(new RMGfxPrimitive(_ctx->thumb, RMPoint(432, 57))); + addPrim(new RMGfxPrimitive(_ctx->thumb, RMPoint(432, 57))); else if (m_nEditPos == 3) - AddPrim(new RMGfxPrimitive(_ctx->thumb, RMPoint(48, 239))); + addPrim(new RMGfxPrimitive(_ctx->thumb, RMPoint(48, 239))); else if (m_nEditPos == 4) - AddPrim(new RMGfxPrimitive(_ctx->thumb, RMPoint(240, 239))); + addPrim(new RMGfxPrimitive(_ctx->thumb, RMPoint(240, 239))); else if (m_nEditPos == 5) - AddPrim(new RMGfxPrimitive(_ctx->thumb, RMPoint(432, 239))); + addPrim(new RMGfxPrimitive(_ctx->thumb, RMPoint(432, 239))); } for (_ctx->i = 0; _ctx->i < 6; _ctx->i++) { @@ -524,18 +522,18 @@ void RMOptionScreen::RefreshAll(CORO_PARAM) { _ctx->num[_ctx->i]->WriteText(s, 2); } - AddPrim(new RMGfxPrimitive(_ctx->num[0], RMPoint(55 - 3, 180 + 14))); - AddPrim(new RMGfxPrimitive(_ctx->num[1], RMPoint(247 - 3, 180 + 14))); - AddPrim(new RMGfxPrimitive(_ctx->num[2], RMPoint(439 - 3, 180 + 14))); - AddPrim(new RMGfxPrimitive(_ctx->num[3], RMPoint(55 - 3, 362 + 14))); - AddPrim(new RMGfxPrimitive(_ctx->num[4], RMPoint(247 - 3, 362 + 14))); - AddPrim(new RMGfxPrimitive(_ctx->num[5], RMPoint(439 - 3, 362 + 14))); + addPrim(new RMGfxPrimitive(_ctx->num[0], RMPoint(55 - 3, 180 + 14))); + addPrim(new RMGfxPrimitive(_ctx->num[1], RMPoint(247 - 3, 180 + 14))); + addPrim(new RMGfxPrimitive(_ctx->num[2], RMPoint(439 - 3, 180 + 14))); + addPrim(new RMGfxPrimitive(_ctx->num[3], RMPoint(55 - 3, 362 + 14))); + addPrim(new RMGfxPrimitive(_ctx->num[4], RMPoint(247 - 3, 362 + 14))); + addPrim(new RMGfxPrimitive(_ctx->num[5], RMPoint(439 - 3, 362 + 14))); m_ButtonSave_ArrowLeft->AddToList(*this); m_ButtonSave_ArrowRight->AddToList(*this); } - CORO_INVOKE_0(DrawOT); + CORO_INVOKE_0(drawOT); if (m_nState == MENULOAD || m_nState == MENUSAVE) { if (_ctx->thumb) delete _ctx->thumb; @@ -588,7 +586,7 @@ void RMOptionScreen::InitState(CORO_PARAM) { assert(_ctx->raw->IsValid()); assert(m_menu == NULL); m_menu = new RMGfxSourceBuffer16(false); - m_menu->Init(*_ctx->raw, _ctx->raw->Width(), _ctx->raw->Height()); + m_menu->init(*_ctx->raw, _ctx->raw->Width(), _ctx->raw->Height()); delete _ctx->raw; if (m_nState == MENULOAD || m_nState == MENUSAVE) { @@ -650,22 +648,22 @@ void RMOptionScreen::InitState(CORO_PARAM) { assert(_ctx->raw->IsValid()); assert(m_QuitConfirm == NULL); m_QuitConfirm = new RMGfxSourceBuffer16(false); - m_QuitConfirm->Init(*_ctx->raw, _ctx->raw->Width(), _ctx->raw->Height()); + m_QuitConfirm->init(*_ctx->raw, _ctx->raw->Width(), _ctx->raw->Height()); delete _ctx->raw; assert(m_ButtonQuitYes == NULL); m_ButtonQuitYes = new RMOptionButton(20022, RMPoint(281, 265)); - m_ButtonQuitYes->SetPriority(30); + m_ButtonQuitYes->setPriority(30); assert(m_ButtonQuitNo == NULL); m_ButtonQuitNo = new RMOptionButton(20023, RMPoint(337, 264)); - m_ButtonQuitNo->SetPriority(30); + m_ButtonQuitNo->setPriority(30); if (m_bNoLoadSave) { _ctx->raw = new RMResRaw(20028); assert(_ctx->raw->IsValid()); assert(m_HideLoadSave == NULL); m_HideLoadSave = new RMGfxSourceBuffer16(false); - m_HideLoadSave->Init(*_ctx->raw, _ctx->raw->Width(), _ctx->raw->Height()); + m_HideLoadSave->init(*_ctx->raw, _ctx->raw->Width(), _ctx->raw->Height()); delete _ctx->raw; } @@ -863,7 +861,7 @@ void RMOptionScreen::CloseState(void) { } void RMOptionScreen::ReInit(RMGfxTargetBuffer &bigBuf) { - bigBuf.AddPrim(new RMGfxPrimitive(this)); + bigBuf.addPrim(new RMGfxPrimitive(this)); } void RMOptionScreen::Init(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool &result) { @@ -885,7 +883,7 @@ void RMOptionScreen::Init(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool &result) { m_bNoLoadSave = false; m_bAlterGfx = false; - bigBuf.AddPrim(new RMGfxPrimitive(this)); + bigBuf.addPrim(new RMGfxPrimitive(this)); if (m_nState == MENULOAD || m_nState == MENUSAVE) m_nState = MENUGAME; @@ -916,7 +914,7 @@ void RMOptionScreen::InitLoadMenuOnly(CORO_PARAM, RMGfxTargetBuffer &bigBuf, boo m_bNoLoadSave = false; m_bAlterGfx = bAlternateGfx; - bigBuf.AddPrim(new RMGfxPrimitive(this)); + bigBuf.addPrim(new RMGfxPrimitive(this)); m_nState = MENULOAD; CORO_INVOKE_0(InitState); @@ -945,7 +943,7 @@ void RMOptionScreen::InitSaveMenuOnly(CORO_PARAM, RMGfxTargetBuffer &bigBuf, boo m_bNoLoadSave = false; m_bAlterGfx = bAlternateGfx; - bigBuf.AddPrim(new RMGfxPrimitive(this)); + bigBuf.addPrim(new RMGfxPrimitive(this)); m_nState = MENUSAVE; CORO_INVOKE_0(InitState); @@ -973,7 +971,7 @@ void RMOptionScreen::InitNoLoadSave(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool m_bLoadMenuOnly = false; m_bNoLoadSave = true; - bigBuf.AddPrim(new RMGfxPrimitive(this)); + bigBuf.addPrim(new RMGfxPrimitive(this)); m_nState = MENUGAME; CORO_INVOKE_0(InitState); @@ -1273,7 +1271,7 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { } -void RMOptionScreen::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMOptionScreen::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CONTEXT; int curTime; CORO_END_CONTEXT(_ctx); @@ -1300,7 +1298,7 @@ void RMOptionScreen::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive } // Set the part to draw the scrolling - prim->SetSrc(RMRect(0, 480 - m_FadeY, 640, 480)); + prim->setSrc(RMRect(0, 480 - m_FadeY, 640, 480)); } else if (m_FadeStep == 2) { // Bounce 1 @@ -1310,7 +1308,7 @@ void RMOptionScreen::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive m_FadeStep++; } - prim->SetSrc(RMRect(0, 480 - m_FadeY, 640, 480)); + prim->setSrc(RMRect(0, 480 - m_FadeY, 640, 480)); } else if (m_FadeStep == 3) { m_FadeY -= FADE_SPEED / 4 * SYNC; @@ -1319,7 +1317,7 @@ void RMOptionScreen::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive m_FadeStep++; } - prim->SetSrc(RMRect(0, 480 - m_FadeY, 640, 480)); + prim->setSrc(RMRect(0, 480 - m_FadeY, 640, 480)); } else if (m_FadeStep == 4) { // Bounce 1 - 2 @@ -1329,7 +1327,7 @@ void RMOptionScreen::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive m_FadeStep++; } - prim->SetSrc(RMRect(0, 480 - m_FadeY, 640, 480)); + prim->setSrc(RMRect(0, 480 - m_FadeY, 640, 480)); } else if (m_FadeStep == 5) { m_FadeY += FADE_SPEED / 2 * SYNC; @@ -1339,7 +1337,7 @@ void RMOptionScreen::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive _vm->hideLocation(); } - prim->SetSrc(RMRect(0, 480 - m_FadeY, 640, 480)); + prim->setSrc(RMRect(0, 480 - m_FadeY, 640, 480)); } else if (m_FadeStep == 6) { // Menu ON @@ -1355,7 +1353,7 @@ void RMOptionScreen::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive m_FadeY = 0; m_FadeStep++; } - prim->SetSrc(RMRect(0, 480 - m_FadeY, 640, 480)); + prim->setSrc(RMRect(0, 480 - m_FadeY, 640, 480)); } else if (m_FadeStep == 9) { // Hello hello! @@ -1372,7 +1370,7 @@ void RMOptionScreen::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive m_FadeTime = _ctx->curTime; - CORO_INVOKE_2(RMGfxWoodyBuffer::Draw, bigBuf, prim); + CORO_INVOKE_2(RMGfxWoodyBuffer::draw, bigBuf, prim); CORO_END_CODE; } @@ -1483,8 +1481,8 @@ void RMPointer::Init(void) { RMResRaw res(RES_P_GO + i); m_pointer[i] = new RMGfxSourceBuffer8RLEByteAA; - m_pointer[i]->Init(res, res.Width(), res.Height(), false); - m_pointer[i]->LoadPaletteWA(RES_P_PAL); + m_pointer[i]->init(res, res.Width(), res.Height(), false); + m_pointer[i]->loadPaletteWA(RES_P_PAL); } for (i = 0; i < 5; i++) { @@ -1530,7 +1528,7 @@ int RMPointer::Priority() { return 200; } -void RMPointer::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMPointer::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CONTEXT; int n; CORO_END_CONTEXT(_ctx); @@ -1542,20 +1540,20 @@ void RMPointer::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim if (_ctx->n == TA_COMBINE) _ctx->n = TA_USE; // Copy the destination coordinates in the primitive - prim->SetDst(m_pos); + prim->setDst(m_pos); if (m_pos.x >= 0 && m_pos.y >= 0 && m_pos.x < RM_SX && m_pos.y < RM_SY) { // Call the Draw method of the poitner prim->Dst() -= m_hotspot[_ctx->n]; if (m_nCurSpecialPointer == 0) { - CORO_INVOKE_2(m_pointer[_ctx->n]->Draw, bigBuf, prim); + CORO_INVOKE_2(m_pointer[_ctx->n]->draw, bigBuf, prim); } else { if (m_nCurSpecialPointer == PTR_CUSTOM) - CORO_INVOKE_2(m_nCurCustomPointer->Draw, bigBuf, prim); + CORO_INVOKE_2(m_nCurCustomPointer->draw, bigBuf, prim); else // Call the draw on the special pointer - CORO_INVOKE_2(m_specialPointer[m_nCurSpecialPointer - 1]->Draw, bigBuf, prim); + CORO_INVOKE_2(m_specialPointer[m_nCurSpecialPointer - 1]->draw, bigBuf, prim); } } @@ -1564,7 +1562,7 @@ void RMPointer::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim void RMPointer::DoFrame(RMGfxTargetBuffer *bigBuf) { // Add it to the list of primitives - bigBuf->AddPrim(new RMGfxPrimitive(this)); + bigBuf->addPrim(new RMGfxPrimitive(this)); // If there is a special pointer, does DoFrame if (m_nCurSpecialPointer != 0 && m_nCurSpecialPointer != PTR_CUSTOM) diff --git a/engines/tony/game.h b/engines/tony/game.h index c920b88ee5..d42a3805c8 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -42,7 +42,7 @@ namespace Tony { assert(raw->IsValid()); \ assert((buf16) == NULL); \ (buf16) = new RMGfxSourceBuffer16(false); \ - (buf16)->Init(*raw,raw->Width(),raw->Height()); \ + (buf16)->init(*raw,raw->Width(),raw->Height()); \ delete raw; #define INIT_GFX8_FROMRAW(raw, dwRes, buf8) \ @@ -50,7 +50,7 @@ namespace Tony { assert(raw->IsValid()); \ assert((buf8) == NULL); \ (buf8) = new RMGfxSourceBuffer8RLEByte(); \ - (buf8)->Init(*raw, raw->Width(), raw->Height(), true); \ + (buf8)->init(*raw, raw->Width(), raw->Height(), true); \ delete raw; @@ -96,7 +96,7 @@ public: int Priority(); // Overloading draw method - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Sets the current co-ordinates void SetCoord(const RMPoint &pt) { @@ -144,7 +144,7 @@ public: virtual ~RMOptionButton(); bool DoFrame(const RMPoint &mousePos, bool bLeftClick, bool bRightClick); - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); void AddToList(RMGfxTargetBuffer &bigBuf); bool IsActive() { return m_bActive; @@ -173,7 +173,7 @@ public: virtual ~RMOptionSlide(); bool DoFrame(const RMPoint &mousePos, bool bLeftClick, bool bRightClick); - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); void AddToList(RMGfxTargetBuffer &bigBuf); int GetValue() { @@ -273,7 +273,7 @@ public: // Overloaded methods virtual int Priority(); - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); virtual void RemoveThis(CORO_PARAM, bool &result); // Polling for the option screen diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index be59a2d9a5..2076e2af47 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -37,15 +37,15 @@ namespace Tony { \****************************************************************************/ RMGfxTask::RMGfxTask() { - m_nPrior = 0; - m_nInList = 0; + _nPrior = 0; + _nInList = 0; } -int RMGfxTask::Priority() { - return m_nPrior; +int RMGfxTask::priority() { + return _nPrior; } -void RMGfxTask::RemoveThis(CORO_PARAM, bool &result) { +void RMGfxTask::removeThis(CORO_PARAM, bool &result) { result = true; } @@ -54,8 +54,8 @@ void RMGfxTask::RemoveThis(CORO_PARAM, bool &result) { * RMGfxTaskSetPrior Methods \****************************************************************************/ -void RMGfxTaskSetPrior::SetPriority(int nPrior) { - m_nPrior = nPrior; +void RMGfxTaskSetPrior::setPriority(int nPrior) { + _nPrior = nPrior; } @@ -64,111 +64,111 @@ void RMGfxTaskSetPrior::SetPriority(int nPrior) { \****************************************************************************/ RMGfxBuffer::RMGfxBuffer() { - m_dimx = m_dimy = 0; - m_bUseDDraw = false; - m_origBuf = m_buf = NULL; + _dimx = _dimy = 0; + _bUseDDraw = false; + _origBuf = _buf = NULL; } RMGfxBuffer::~RMGfxBuffer() { - Destroy(); + destroy(); } -void RMGfxBuffer::Create(int dimx, int dimy, int nBpp, bool bUseDDraw) { +void RMGfxBuffer::create(int dimx, int dimy, int nBpp, bool bUseDDraw) { // Destroy the buffer it is already exists - if (m_buf != NULL) - Destroy(); + if (_buf != NULL) + destroy(); // Copy the parameters in the private members - m_dimx = dimx; - m_dimy = dimy; - m_bUseDDraw = bUseDDraw; + _dimx = dimx; + _dimy = dimy; + _bUseDDraw = bUseDDraw; - if (!m_bUseDDraw) { + if (!_bUseDDraw) { // Allocate a buffer - m_origBuf = m_buf = new byte[m_dimx * m_dimy * nBpp / 8]; - assert(m_buf != NULL); - Common::fill(m_origBuf, m_origBuf + m_dimx * m_dimy * nBpp / 8, 0); + _origBuf = _buf = new byte[_dimx * _dimy * nBpp / 8]; + assert(_buf != NULL); + Common::fill(_origBuf, _origBuf + _dimx * _dimy * nBpp / 8, 0); } } -void RMGfxBuffer::Destroy(void) { - if (!m_bUseDDraw) { - if (m_origBuf != NULL && m_origBuf == m_buf) { - delete[] m_origBuf; - m_origBuf = m_buf = NULL; +void RMGfxBuffer::destroy(void) { + if (!_bUseDDraw) { + if (_origBuf != NULL && _origBuf == _buf) { + delete[] _origBuf; + _origBuf = _buf = NULL; } } } -void RMGfxBuffer::Lock(void) { - if (m_bUseDDraw) { +void RMGfxBuffer::lock(void) { + if (_bUseDDraw) { // Manages acceleration } } -void RMGfxBuffer::Unlock(void) { - if (m_bUseDDraw) { +void RMGfxBuffer::unlock(void) { + if (_bUseDDraw) { // Manages acceleration } } -void RMGfxBuffer::OffsetY(int nLines, int nBpp) { - m_buf += nLines * Dimx() * nBpp / 8; +void RMGfxBuffer::offsetY(int nLines, int nBpp) { + _buf += nLines * getDimx() * nBpp / 8; } RMGfxBuffer::operator byte *() { - return m_buf; + return _buf; } RMGfxBuffer::operator void *() { - return (void *)m_buf; + return (void *)_buf; } RMGfxBuffer::RMGfxBuffer(int dimx, int dimy, int nBpp, bool bUseDDraw) { - Create(dimx, dimy, nBpp, bUseDDraw); + create(dimx, dimy, nBpp, bUseDDraw); } /****************************************************************************\ * RMGfxSourceBuffer Methods \****************************************************************************/ -int RMGfxSourceBuffer::Init(const byte *buf, int dimx, int dimy, bool bLoadPalette) { - Create(dimx, dimy, Bpp()); - CopyMemory(m_buf, buf, dimx * dimy * Bpp() / 8); +int RMGfxSourceBuffer::init(const byte *buf, int dimx, int dimy, bool bLoadPalette) { + create(dimx, dimy, Bpp()); + CopyMemory(_buf, buf, dimx * dimy * Bpp() / 8); // Invokes the method for preparing the surface (inherited) - PrepareImage(); + prepareImage(); return dimx * dimy * Bpp() / 8; } -void RMGfxSourceBuffer::Init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette) { - Create(dimx, dimy, Bpp()); - ds.Read(m_buf, dimx * dimy * Bpp() / 8); +void RMGfxSourceBuffer::init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette) { + create(dimx, dimy, Bpp()); + ds.Read(_buf, dimx * dimy * Bpp() / 8); // Invokes the method for preparing the surface (inherited) - PrepareImage(); + prepareImage(); } RMGfxSourceBuffer::~RMGfxSourceBuffer() { } -void RMGfxSourceBuffer::PrepareImage(void) { +void RMGfxSourceBuffer::prepareImage(void) { // Do nothing. Can be overloaded if necessary } -bool RMGfxSourceBuffer::Clip2D(int &x1, int &y1, int &u, int &v, int &width, int &height, bool bUseSrc, RMGfxTargetBuffer *buf) { +bool RMGfxSourceBuffer::clip2D(int &x1, int &y1, int &u, int &v, int &width, int &height, bool bUseSrc, RMGfxTargetBuffer *buf) { int destw, desth; - destw = buf->Dimx(); - desth = buf->Dimy(); + destw = buf->getDimx(); + desth = buf->getDimy(); if (!bUseSrc) { u = v = 0; - width = m_dimx; - height = m_dimy; + width = _dimx; + height = _dimy; } if (x1 > destw - 1) @@ -210,8 +210,8 @@ bool RMGfxSourceBuffer::Clip2D(int &x1, int &y1, int &u, int &v, int &width, int * @param dimx Buffer X dimension * @param dimy Buffer Y dimension */ -int RMGfxSourceBuffer::Init(uint32 resID, int dimx, int dimy, bool bLoadPalette) { - return Init(RMRes(resID), dimx, dimy, bLoadPalette); +int RMGfxSourceBuffer::init(uint32 resID, int dimx, int dimy, bool bLoadPalette) { + return init(RMRes(resID), dimx, dimy, bLoadPalette); } /****************************************************************************\ @@ -222,17 +222,17 @@ RMGfxWoodyBuffer::~RMGfxWoodyBuffer() { } -void RMGfxWoodyBuffer::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMGfxWoodyBuffer::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); // Draw the OT list - CORO_INVOKE_0(DrawOT); + CORO_INVOKE_0(drawOT); // Draw itself into the target buffer - CORO_INVOKE_2(RMGfxSourceBuffer16::Draw, bigBuf, prim); + CORO_INVOKE_2(RMGfxSourceBuffer16::draw, bigBuf, prim); CORO_END_CODE; } @@ -255,16 +255,16 @@ RMGfxClearTask RMGfxTargetBuffer::taskClear; RMGfxTargetBuffer::RMGfxTargetBuffer() { otlist = NULL; - m_otSize = 0; + _otSize = 0; // csModifyingOT = g_system->createMutex(); } RMGfxTargetBuffer::~RMGfxTargetBuffer() { - ClearOT(); + clearOT(); // g_system->deleteMutex(csModifyingOT); } -void RMGfxTargetBuffer::ClearOT(void) { +void RMGfxTargetBuffer::clearOT(void) { OTList *cur, *n; // g_system->lockMutex(csModifyingOT); @@ -272,7 +272,7 @@ void RMGfxTargetBuffer::ClearOT(void) { cur = otlist; while (cur != NULL) { - cur->prim->m_task->Unregister(); + cur->prim->_task->Unregister(); delete cur->prim; n = cur->next; delete cur; @@ -284,7 +284,7 @@ void RMGfxTargetBuffer::ClearOT(void) { // g_system->unlockMutex(csModifyingOT); } -void RMGfxTargetBuffer::DrawOT(CORO_PARAM) { +void RMGfxTargetBuffer::drawOT(CORO_PARAM) { CORO_BEGIN_CONTEXT; OTList *cur; OTList *prev; @@ -299,20 +299,20 @@ void RMGfxTargetBuffer::DrawOT(CORO_PARAM) { _ctx->cur = otlist; // Lock the buffer to access it - Lock(); + lock(); // g_system->lockMutex(csModifyingOT); while (_ctx->cur != NULL) { // Call the task Draw method, passing it a copy of the original - _ctx->myprim = _ctx->cur->prim->Duplicate(); - CORO_INVOKE_2(_ctx->cur->prim->m_task->Draw, *this, _ctx->myprim); + _ctx->myprim = _ctx->cur->prim->duplicate(); + CORO_INVOKE_2(_ctx->cur->prim->_task->draw, *this, _ctx->myprim); delete _ctx->myprim; // Check if it's time to remove the task from the OT list - CORO_INVOKE_1(_ctx->cur->prim->m_task->RemoveThis, _ctx->result); + CORO_INVOKE_1(_ctx->cur->prim->_task->removeThis, _ctx->result); if (_ctx->result) { // De-register the task - _ctx->cur->prim->m_task->Unregister(); + _ctx->cur->prim->_task->Unregister(); // Delete task, freeing the memory delete _ctx->cur->prim; @@ -337,22 +337,22 @@ void RMGfxTargetBuffer::DrawOT(CORO_PARAM) { // g_system->unlockMutex(csModifyingOT); //Unlock after writing - Unlock(); + unlock(); CORO_END_CODE; } -void RMGfxTargetBuffer::AddPrim(RMGfxPrimitive *prim) { +void RMGfxTargetBuffer::addPrim(RMGfxPrimitive *prim) { int nPrior; OTList *cur, *n; // g_system->lockMutex(csModifyingOT); // Warn of the OT listing - prim->m_task->Register(); + prim->_task->Register(); // Check the priority - nPrior = prim->m_task->Priority(); + nPrior = prim->_task->priority(); n = new OTList(prim); // Empty list @@ -361,12 +361,12 @@ void RMGfxTargetBuffer::AddPrim(RMGfxPrimitive *prim) { otlist->next = NULL; } // Inclusion in the head - else if (nPrior < otlist->prim->m_task->Priority()) { + else if (nPrior < otlist->prim->_task->priority()) { n->next = otlist; otlist = n; } else { cur = otlist; - while (cur->next != NULL && nPrior > cur->next->prim->m_task->Priority()) + while (cur->next != NULL && nPrior > cur->next->prim->_task->priority()) cur = cur->next; n->next = cur->next; @@ -376,8 +376,8 @@ void RMGfxTargetBuffer::AddPrim(RMGfxPrimitive *prim) { // g_system->unlockMutex(csModifyingOT); } -void RMGfxTargetBuffer::AddClearTask(void) { - AddPrim(new RMGfxPrimitive(&taskClear)); +void RMGfxTargetBuffer::addClearTask(void) { + addPrim(new RMGfxPrimitive(&taskClear)); } @@ -389,89 +389,89 @@ RMGfxSourceBufferPal::~RMGfxSourceBufferPal() { } -int RMGfxSourceBufferPal::LoadPaletteWA(const byte *buf, bool bSwapped) { +int RMGfxSourceBufferPal::loadPaletteWA(const byte *buf, bool bSwapped) { int i; if (bSwapped) for (i = 0; i < (1 << Bpp()); i++) { - m_pal[i * 3 + 0] = buf[i * 3 + 2]; - m_pal[i * 3 + 1] = buf[i * 3 + 1]; - m_pal[i * 3 + 2] = buf[i * 3 + 0]; + _pal[i * 3 + 0] = buf[i * 3 + 2]; + _pal[i * 3 + 1] = buf[i * 3 + 1]; + _pal[i * 3 + 2] = buf[i * 3 + 0]; } else - CopyMemory(m_pal, buf, (1 << Bpp()) * 3); + CopyMemory(_pal, buf, (1 << Bpp()) * 3); - PreparePalette(); + preparePalette(); return (1 << Bpp()) * 3; } -int RMGfxSourceBufferPal::LoadPalette(const byte *buf) { +int RMGfxSourceBufferPal::loadPalette(const byte *buf) { int i; for (i = 0; i < 256; i++) - CopyMemory(m_pal + i * 3, buf + i * 4, 3); + CopyMemory(_pal + i * 3, buf + i * 4, 3); - PreparePalette(); + preparePalette(); return (1 << Bpp()) * 4; } -void RMGfxSourceBufferPal::PreparePalette(void) { +void RMGfxSourceBufferPal::preparePalette(void) { int i; for (i = 0; i < 256; i++) { - m_palFinal[i] = (((int)m_pal[i * 3 + 0] >> 3) << 10) | - (((int)m_pal[i * 3 + 1] >> 3) << 5) | - (((int)m_pal[i * 3 + 2] >> 3) << 0); + _palFinal[i] = (((int)_pal[i * 3 + 0] >> 3) << 10) | + (((int)_pal[i * 3 + 1] >> 3) << 5) | + (((int)_pal[i * 3 + 2] >> 3) << 0); } } -int RMGfxSourceBufferPal::Init(const byte *buf, int dimx, int dimy, bool bLoadPalette) { +int RMGfxSourceBufferPal::init(const byte *buf, int dimx, int dimy, bool bLoadPalette) { int read; // Load the RAW image - read = RMGfxSourceBuffer::Init(buf, dimx, dimy); + read = RMGfxSourceBuffer::init(buf, dimx, dimy); // Load the palette if necessary if (bLoadPalette) - read += LoadPaletteWA(&buf[read]); + read += loadPaletteWA(&buf[read]); return read; } -void RMGfxSourceBufferPal::Init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette) { +void RMGfxSourceBufferPal::init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette) { // Load the RAW image - RMGfxSourceBuffer::Init(ds, dimx, dimy); + RMGfxSourceBuffer::init(ds, dimx, dimy); // Load the palette if necessary if (bLoadPalette) { byte *suxpal = new byte[256 * 3]; ds.Read(suxpal, 256 * 3); - LoadPaletteWA(suxpal); + loadPaletteWA(suxpal); delete[] suxpal; } } -int RMGfxSourceBufferPal::LoadPalette(uint32 resID) { - return LoadPalette(RMRes(resID)); +int RMGfxSourceBufferPal::loadPalette(uint32 resID) { + return loadPalette(RMRes(resID)); } -int RMGfxSourceBufferPal::LoadPaletteWA(uint32 resID, bool bSwapped) { - return LoadPaletteWA(RMRes(resID), bSwapped); +int RMGfxSourceBufferPal::loadPaletteWA(uint32 resID, bool bSwapped) { + return loadPaletteWA(RMRes(resID), bSwapped); } /****************************************************************************\ * RMGfxSourceBuffer4 Methods \****************************************************************************/ -void RMGfxSourceBuffer4::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMGfxSourceBuffer4::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { } RMGfxSourceBuffer4::RMGfxSourceBuffer4(int dimx, int dimy, bool bUseDDraw) : RMGfxBuffer(dimx, dimy, 4, bUseDDraw) { - SetPriority(0); + setPriority(0); } @@ -485,7 +485,7 @@ int RMGfxSourceBuffer4::Bpp() { } void RMGfxSourceBuffer4::Create(int dimx, int dimy, bool bUseDDraw) { - RMGfxBuffer::Create(dimx, dimy, 4, bUseDDraw); + RMGfxBuffer::create(dimx, dimy, 4, bUseDDraw); } /****************************************************************************\ @@ -496,19 +496,19 @@ RMGfxSourceBuffer8::~RMGfxSourceBuffer8() { } -void RMGfxSourceBuffer8::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMGfxSourceBuffer8::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { int x, y, width, height, u, v; - int bufx = bigBuf.Dimx(); + int bufx = bigBuf.getDimx(); uint16 *buf = bigBuf; - byte *raw = m_buf; + byte *raw = _buf; // Destination buffer RMRect dst; - if (prim->HaveDst()) + if (prim->haveDst()) dst = prim->Dst(); // Clipping - if (prim->HaveSrc()) { + if (prim->haveSrc()) { u = prim->Src().x1; v = prim->Src().y1; @@ -516,19 +516,20 @@ void RMGfxSourceBuffer8::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimit height = prim->Src().Height(); } - if (!Clip2D(dst.x1, dst.y1, u, v, width, height, prim->HaveSrc(), &bigBuf)) + if (!clip2D(dst.x1, dst.y1, u, v, width, height, prim->haveSrc(), &bigBuf)) return; // Starting offset into the buffer buf += dst.y1 * bufx + dst.x1; // Normal step - if (m_bTrasp0) { + if (_bTrasp0) { for (y = 0; y < height; y++) { - raw = m_buf + (y + v) * m_dimx + u; + raw = _buf + (y + v) * _dimx + u; for (x = 0; x < width; x++) { - if (*raw) *buf = m_palFinal[*raw]; + if (*raw) + *buf = _palFinal[*raw]; buf++; raw++; } @@ -537,11 +538,11 @@ void RMGfxSourceBuffer8::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimit } } else { for (y = 0; y < height; y++) { - raw = m_buf + (y + v) * m_dimx + u; + raw = _buf + (y + v) * _dimx + u; for (x = 0; x < width; x += 2) { - buf[0] = m_palFinal[raw[0]]; - buf[1] = m_palFinal[raw[1]]; + buf[0] = _palFinal[raw[0]]; + buf[1] = _palFinal[raw[1]]; buf += 2; raw += 2; @@ -554,11 +555,11 @@ void RMGfxSourceBuffer8::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimit RMGfxSourceBuffer8::RMGfxSourceBuffer8(int dimx, int dimy, bool bUseDDraw) : RMGfxBuffer(dimx, dimy, 8, bUseDDraw) { - SetPriority(0); + setPriority(0); } RMGfxSourceBuffer8::RMGfxSourceBuffer8(bool bTrasp0) { - m_bTrasp0 = bTrasp0; + _bTrasp0 = bTrasp0; } @@ -571,8 +572,8 @@ int RMGfxSourceBuffer8::Bpp() { return 8; } -void RMGfxSourceBuffer8::Create(int dimx, int dimy, bool bUseDDraw) { - RMGfxBuffer::Create(dimx, dimy, 8, bUseDDraw); +void RMGfxSourceBuffer8::create(int dimx, int dimy, bool bUseDDraw) { + RMGfxBuffer::create(dimx, dimy, 8, bUseDDraw); } #define GETRED(x) (((x) >> 10) & 0x1F) @@ -588,7 +589,7 @@ RMGfxSourceBuffer8AB::~RMGfxSourceBuffer8AB() { } -int RMGfxSourceBuffer8AB::CalcTrasp(int fore, int back) { +int RMGfxSourceBuffer8AB::calcTrasp(int fore, int back) { int r, g, b; r = (GETRED(fore) >> 2) + (GETRED(back) >> 1); @@ -603,19 +604,19 @@ int RMGfxSourceBuffer8AB::CalcTrasp(int fore, int back) { } -void RMGfxSourceBuffer8AB::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMGfxSourceBuffer8AB::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { int x, y, width, height, u, v; - int bufx = bigBuf.Dimx(); + int bufx = bigBuf.getDimx(); uint16 *buf = bigBuf; - byte *raw = m_buf; + byte *raw = _buf; // Destination buffer RMRect dst; - if (prim->HaveDst()) + if (prim->haveDst()) dst = prim->Dst(); // Clipping - if (prim->HaveSrc()) { + if (prim->haveSrc()) { u = prim->Src().x1; v = prim->Src().y1; @@ -623,19 +624,21 @@ void RMGfxSourceBuffer8AB::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrim height = prim->Src().Height(); } - if (!Clip2D(dst.x1, dst.y1, u, v, width, height, prim->HaveSrc(), &bigBuf)) + if (!clip2D(dst.x1, dst.y1, u, v, width, height, prim->haveSrc(), &bigBuf)) return; // Starting offset into the buffer buf += dst.y1 * bufx + dst.x1; // Passaggio normale - if (m_bTrasp0) { + if (_bTrasp0) { for (y = 0; y < height; y++) { - raw = m_buf + (y + v) * m_dimx + u; + raw = _buf + (y + v) * _dimx + u; for (x = 0; x < width; x++) { - if (*raw) *buf = CalcTrasp(m_palFinal[*raw], *buf); + if (*raw) + *buf = calcTrasp(_palFinal[*raw], *buf); + buf++; raw++; } @@ -644,11 +647,11 @@ void RMGfxSourceBuffer8AB::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrim } } else { for (y = 0; y < height; y++) { - raw = m_buf + (y + v) * m_dimx + u; + raw = _buf + (y + v) * _dimx + u; for (x = 0; x < width; x += 2) { - buf[0] = CalcTrasp(m_palFinal[raw[0]], buf[0]); - buf[1] = CalcTrasp(m_palFinal[raw[1]], buf[1]); + buf[0] = calcTrasp(_palFinal[raw[0]], buf[0]); + buf[1] = calcTrasp(_palFinal[raw[1]], buf[1]); buf += 2; raw += 2; @@ -669,69 +672,69 @@ void RMGfxSourceBuffer8AB::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrim byte RMGfxSourceBuffer8RLE::MegaRLEBuf[512 * 1024]; -void RMGfxSourceBuffer8RLE::SetAlphaBlendColor(int color) { +void RMGfxSourceBuffer8RLE::setAlphaBlendColor(int color) { alphaBlendColor = color; } RMGfxSourceBuffer8RLE::RMGfxSourceBuffer8RLE() { alphaBlendColor = -1; bNeedRLECompress = true; - m_buf = NULL; + _buf = NULL; } RMGfxSourceBuffer8RLE::~RMGfxSourceBuffer8RLE() { - if (m_buf != NULL) { - delete[] m_buf; - m_buf = NULL; + if (_buf != NULL) { + delete[] _buf; + _buf = NULL; } } -int RMGfxSourceBuffer8RLE::Init(const byte *buf, int dimx, int dimy, bool bLoadPalette) { - return RMGfxSourceBufferPal::Init(buf, dimx, dimy, bLoadPalette); +int RMGfxSourceBuffer8RLE::init(const byte *buf, int dimx, int dimy, bool bLoadPalette) { + return RMGfxSourceBufferPal::init(buf, dimx, dimy, bLoadPalette); } -void RMGfxSourceBuffer8RLE::Init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette) { +void RMGfxSourceBuffer8RLE::init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette) { if (bNeedRLECompress) { - RMGfxSourceBufferPal::Init(ds, dimx, dimy, bLoadPalette); + RMGfxSourceBufferPal::init(ds, dimx, dimy, bLoadPalette); } else { int size; ds >> size; - m_buf = new byte[size]; - ds.Read(m_buf, size); + _buf = new byte[size]; + ds.Read(_buf, size); - m_dimx = dimx; - m_dimy = dimy; + _dimx = dimx; + _dimy = dimy; } } -void RMGfxSourceBuffer8RLE::PreparePalette(void) { +void RMGfxSourceBuffer8RLE::preparePalette(void) { // Invoke the parent method - RMGfxSourceBuffer8::PreparePalette(); + RMGfxSourceBuffer8::preparePalette(); // Handle RGB alpha blending if (alphaBlendColor != -1) { - alphaR = (m_palFinal[alphaBlendColor] >> 10) & 0x1F; - alphaG = (m_palFinal[alphaBlendColor] >> 5) & 0x1F; - alphaB = (m_palFinal[alphaBlendColor]) & 0x1F; + alphaR = (_palFinal[alphaBlendColor] >> 10) & 0x1F; + alphaG = (_palFinal[alphaBlendColor] >> 5) & 0x1F; + alphaB = (_palFinal[alphaBlendColor]) & 0x1F; } } -void RMGfxSourceBuffer8RLE::PrepareImage(void) { +void RMGfxSourceBuffer8RLE::prepareImage(void) { // Invoke the parent method - RMGfxSourceBuffer::PrepareImage(); + RMGfxSourceBuffer::prepareImage(); // Compress - CompressRLE(); + compressRLE(); } -void RMGfxSourceBuffer8RLE::SetAlreadyCompressed(void) { +void RMGfxSourceBuffer8RLE::setAlreadyCompressed(void) { bNeedRLECompress = false; } -void RMGfxSourceBuffer8RLE::CompressRLE(void) { +void RMGfxSourceBuffer8RLE::compressRLE(void) { int x, y; byte *startline; byte *cur; @@ -742,8 +745,8 @@ void RMGfxSourceBuffer8RLE::CompressRLE(void) { // Perform RLE compression for lines cur = MegaRLEBuf; - src = m_buf; - for (y = 0; y < m_dimy; y++) { + src = _buf; + for (y = 0; y < _dimy; y++) { // Save the beginning of the line startline = cur; @@ -754,7 +757,7 @@ void RMGfxSourceBuffer8RLE::CompressRLE(void) { curdata = 0; rep = 0; startsrc = src; - for (x = 0; x < m_dimx;) { + for (x = 0; x < _dimx;) { if ((curdata == 0 && *src == 0) || (curdata == 1 && *src == alphaBlendColor) || (curdata == 2 && (*src != alphaBlendColor && *src != 0))) { src++; @@ -795,15 +798,15 @@ void RMGfxSourceBuffer8RLE::CompressRLE(void) { } // Delete the original image - delete[] m_buf; + delete[] _buf; // Copy the compressed image x = cur - MegaRLEBuf; - m_buf = new byte[x]; - Common::copy(MegaRLEBuf, MegaRLEBuf + x, m_buf); + _buf = new byte[x]; + Common::copy(MegaRLEBuf, MegaRLEBuf + x, _buf); } -void RMGfxSourceBuffer8RLE::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMGfxSourceBuffer8RLE::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { int y; byte *src; uint16 *buf = bigBuf; @@ -812,26 +815,26 @@ void RMGfxSourceBuffer8RLE::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPri // Clipping x1 = prim->Dst().x1; y1 = prim->Dst().y1; - if (!Clip2D(x1, y1, u, v, width, height, false, &bigBuf)) + if (!clip2D(x1, y1, u, v, width, height, false, &bigBuf)) return; // Go forward through the RLE lines - src = m_buf; + src = _buf; for (y = 0; y < v; y++) src += READ_LE_UINT16(src); // Calculate the position in the destination buffer - buf += y1 * bigBuf.Dimx(); + buf += y1 * bigBuf.getDimx(); // Loop - if (prim->IsFlipped()) { + if (prim->isFlipped()) { // Eliminate horizontal clipping // width = m_dimx; // x1=prim->Dst().x1; // Clipping - u = m_dimx - (width + u); - x1 = (prim->Dst().x1 + m_dimx - 1) - u; + u = _dimx - (width + u); + x1 = (prim->Dst().x1 + _dimx - 1) - u; for (y = 0; y < height; y++) { // Decompressione @@ -841,7 +844,7 @@ void RMGfxSourceBuffer8RLE::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPri src += READ_LE_UINT16(src); // Skip to the next line - buf += bigBuf.Dimx(); + buf += bigBuf.getDimx(); } } else { for (y = 0; y < height; y++) { @@ -852,7 +855,7 @@ void RMGfxSourceBuffer8RLE::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPri src += READ_LE_UINT16(src); // Skip to the next line - buf += bigBuf.Dimx(); + buf += bigBuf.getDimx(); } } } @@ -990,7 +993,7 @@ RLEByteDoCopy2: n = nLength; for (i = 0; i < n; i++) - *dst ++ = m_palFinal[*src++]; + *dst ++ = _palFinal[*src++]; nLength -= n; if (!nLength) @@ -1096,7 +1099,7 @@ RLEByteFlippedDoCopy2: n = nLength; for (i = 0; i < n; i++) - *dst -- = m_palFinal[*src++]; + *dst-- = _palFinal[*src++]; nLength -= n; if (!nLength) @@ -1247,7 +1250,7 @@ RLEWordDoCopy2: n = nLength; for (i = 0; i < n; i++) - *dst ++ = m_palFinal[*src++]; + *dst++ = _palFinal[*src++]; nLength -= n; if (!nLength) @@ -1365,7 +1368,7 @@ RLEWordFlippedDoCopy2: n = nLength; for (i = 0; i < n; i++) - *dst -- = m_palFinal[*src++]; + *dst-- = _palFinal[*src++]; nLength -= n; if (!nLength) @@ -1500,9 +1503,9 @@ RLEWordDoCopy2: g = (*dst >> 5) & 0x1F; b = *dst & 0x1F; - r2 = (m_palFinal[*src] >> 10) & 0x1F; - g2 = (m_palFinal[*src] >> 5) & 0x1F; - b2 = m_palFinal[*src] & 0x1F; + r2 = (_palFinal[*src] >> 10) & 0x1F; + g2 = (_palFinal[*src] >> 5) & 0x1F; + b2 = _palFinal[*src] & 0x1F; r = (r >> 1) + (r2 >> 1); g = (g >> 1) + (g2 >> 1); @@ -1529,16 +1532,16 @@ RLEWordDoCopy2: byte RMGfxSourceBuffer8AA::MegaAABuf[256 * 1024]; byte RMGfxSourceBuffer8AA::MegaAABuf2[64 * 1024]; -void RMGfxSourceBuffer8AA::PrepareImage(void) { +void RMGfxSourceBuffer8AA::prepareImage(void) { // Invoke the parent method - RMGfxSourceBuffer::PrepareImage(); + RMGfxSourceBuffer::prepareImage(); // Prepare the buffer for anti-aliasing - CalculateAA(); + calculateAA(); } -void RMGfxSourceBuffer8AA::CalculateAA(void) { +void RMGfxSourceBuffer8AA::calculateAA(void) { // I suck, you suck, he sucks, we suck, they all suck ---> ANTI ALIASING SUX! // ************************************************************ @@ -1546,17 +1549,17 @@ void RMGfxSourceBuffer8AA::CalculateAA(void) { byte *src, *srcaa; /* First pass: fill the edges */ - Common::fill(MegaAABuf, MegaAABuf + m_dimx * m_dimy, 0); + Common::fill(MegaAABuf, MegaAABuf + _dimx * _dimy, 0); - src = m_buf; + src = _buf; srcaa = MegaAABuf; - for (y = 0; y < m_dimy; y++) { - for (x = 0; x < m_dimx; x++) { + for (y = 0; y < _dimy; y++) { + for (x = 0; x < _dimx; x++) { if (*src == 0) { - if ((y > 0 && src[-m_dimx] != 0) || - (y < m_dimy - 1 && src[m_dimx] != 0) || + if ((y > 0 && src[-_dimx] != 0) || + (y < _dimy - 1 && src[_dimx] != 0) || (x > 0 && src[-1] != 0) || - (x < m_dimx - 1 && src[1] != 0)) + (x < _dimx - 1 && src[1] != 0)) *srcaa = 1; } @@ -1565,15 +1568,15 @@ void RMGfxSourceBuffer8AA::CalculateAA(void) { } } - src = m_buf; + src = _buf; srcaa = MegaAABuf; - for (y = 0; y < m_dimy; y++) { - for (x = 0; x < m_dimx; x++) { + for (y = 0; y < _dimy; y++) { + for (x = 0; x < _dimx; x++) { if (*src != 0) { - if ((y > 0 && srcaa[-m_dimx] == 1) || - (y < m_dimy - 1 && srcaa[m_dimx] == 1) || + if ((y > 0 && srcaa[-_dimx] == 1) || + (y < _dimy - 1 && srcaa[_dimx] == 1) || (x > 0 && srcaa[-1] == 1) || - (x < m_dimx - 1 && srcaa[1] == 1)) + (x < _dimx - 1 && srcaa[1] == 1)) *srcaa = 2; } @@ -1582,23 +1585,23 @@ void RMGfxSourceBuffer8AA::CalculateAA(void) { } } - if (m_aabuf != NULL) - delete[] m_aabuf; + if (_aabuf != NULL) + delete[] _aabuf; - m_aabuf = new byte[m_dimx * m_dimy]; - CopyMemory(m_aabuf, MegaAABuf, m_dimx * m_dimy); + _aabuf = new byte[_dimx * _dimy]; + CopyMemory(_aabuf, MegaAABuf, _dimx * _dimy); } RMGfxSourceBuffer8AA::RMGfxSourceBuffer8AA() : RMGfxSourceBuffer8() { - m_aabuf = NULL; + _aabuf = NULL; } RMGfxSourceBuffer8AA::~RMGfxSourceBuffer8AA() { - if (m_aabuf != NULL) - delete[] m_aabuf; + if (_aabuf != NULL) + delete[] _aabuf; } -void RMGfxSourceBuffer8AA::DrawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMGfxSourceBuffer8AA::drawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { int x, y; byte *src; uint16 *mybuf; @@ -1610,35 +1613,35 @@ void RMGfxSourceBuffer8AA::DrawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri // Clip the sprite x1 = prim->Dst().x1; y1 = prim->Dst().y1; - if (!Clip2D(x1, y1, u, v, width, height, false, &bigBuf)) + if (!clip2D(x1, y1, u, v, width, height, false, &bigBuf)) return; // Go forward through the RLE lines - src = m_buf; + src = _buf; for (y = 0; y < v; y++) src += READ_LE_UINT16(src); // Eliminate horizontal clipping - if (prim->IsFlipped()) { - u = m_dimx - (width + u); - x1 = (prim->Dst().x1 + m_dimx - 1) - u; + if (prim->isFlipped()) { + u = _dimx - (width + u); + x1 = (prim->Dst().x1 + _dimx - 1) - u; } -// width = m_dimx; -// x1=prim->Dst().x1; +// width = _dimx; +// x1 = prim->Dst().x1; // Poisition into the destination buffer buf = bigBuf; - buf += y1 * bigBuf.Dimx(); + buf += y1 * bigBuf.getDimx(); - if (prim->IsFlipped()) + if (prim->isFlipped()) step = -1; else step = 1; // Loop - buf += bigBuf.Dimx(); // Skip the first line + buf += bigBuf.getDimx(); // Skip the first line for (y = 1; y < height - 1; y++) { /* if (prim->IsFlipped()) @@ -1648,10 +1651,10 @@ void RMGfxSourceBuffer8AA::DrawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri mybuf = &buf[x1]; for (x = 0; x < width; x++, mybuf += step) - if (m_aabuf[(y + v) * m_dimx + x + u] == 2 && x != 0 && x != width - 1) { - r = GETRED(mybuf[1]) + GETRED(mybuf[-1]) + GETRED(mybuf[-bigBuf.Dimx()]) + GETRED(mybuf[bigBuf.Dimx()]); - g = GETGREEN(mybuf[1]) + GETGREEN(mybuf[-1]) + GETGREEN(mybuf[-bigBuf.Dimx()]) + GETGREEN(mybuf[bigBuf.Dimx()]); - b = GETBLUE(mybuf[1]) + GETBLUE(mybuf[-1]) + GETBLUE(mybuf[-bigBuf.Dimx()]) + GETBLUE(mybuf[bigBuf.Dimx()]); + if (_aabuf[(y + v) * _dimx + x + u] == 2 && x != 0 && x != width - 1) { + r = GETRED(mybuf[1]) + GETRED(mybuf[-1]) + GETRED(mybuf[-bigBuf.getDimx()]) + GETRED(mybuf[bigBuf.getDimx()]); + g = GETGREEN(mybuf[1]) + GETGREEN(mybuf[-1]) + GETGREEN(mybuf[-bigBuf.getDimx()]) + GETGREEN(mybuf[bigBuf.getDimx()]); + b = GETBLUE(mybuf[1]) + GETBLUE(mybuf[-1]) + GETBLUE(mybuf[-bigBuf.getDimx()]) + GETBLUE(mybuf[bigBuf.getDimx()]); r += GETRED(mybuf[0]); g += GETGREEN(mybuf[0]); @@ -1669,15 +1672,15 @@ void RMGfxSourceBuffer8AA::DrawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri } // Skip to the next line - buf += bigBuf.Dimx(); + buf += bigBuf.getDimx(); } // Position into the destination buffer buf = bigBuf; - buf += y1 * bigBuf.Dimx(); + buf += y1 * bigBuf.getDimx(); // Looppone - buf += bigBuf.Dimx(); + buf += bigBuf.getDimx(); for (y = 1; y < height - 1; y++) { /* if (prim->IsFlipped()) @@ -1687,10 +1690,10 @@ void RMGfxSourceBuffer8AA::DrawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri mybuf = &buf[x1]; for (x = 0; x < width; x++, mybuf += step) - if (m_aabuf[(y + v) * m_dimx + x + u] == 1 && x != 0 && x != width - 1) { - r = GETRED(mybuf[1]) + GETRED(mybuf[-1]) + GETRED(mybuf[-bigBuf.Dimx()]) + GETRED(mybuf[bigBuf.Dimx()]); - g = GETGREEN(mybuf[1]) + GETGREEN(mybuf[-1]) + GETGREEN(mybuf[-bigBuf.Dimx()]) + GETGREEN(mybuf[bigBuf.Dimx()]); - b = GETBLUE(mybuf[1]) + GETBLUE(mybuf[-1]) + GETBLUE(mybuf[-bigBuf.Dimx()]) + GETBLUE(mybuf[bigBuf.Dimx()]); + if (_aabuf[(y + v) * _dimx + x + u] == 1 && x != 0 && x != width - 1) { + r = GETRED(mybuf[1]) + GETRED(mybuf[-1]) + GETRED(mybuf[-bigBuf.getDimx()]) + GETRED(mybuf[bigBuf.getDimx()]); + g = GETGREEN(mybuf[1]) + GETGREEN(mybuf[-1]) + GETGREEN(mybuf[-bigBuf.getDimx()]) + GETGREEN(mybuf[bigBuf.getDimx()]); + b = GETBLUE(mybuf[1]) + GETBLUE(mybuf[-1]) + GETBLUE(mybuf[-bigBuf.getDimx()]) + GETBLUE(mybuf[bigBuf.getDimx()]); r += GETRED(mybuf[0]) * 2; g += GETGREEN(mybuf[0]) * 2; @@ -1708,20 +1711,20 @@ void RMGfxSourceBuffer8AA::DrawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri } // Skippa alla linea successiva - buf += bigBuf.Dimx(); + buf += bigBuf.getDimx(); } } -void RMGfxSourceBuffer8AA::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMGfxSourceBuffer8AA::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_2(RMGfxSourceBuffer8::Draw, bigBuf, prim); - DrawAA(bigBuf, prim); + CORO_INVOKE_2(RMGfxSourceBuffer8::draw, bigBuf, prim); + drawAA(bigBuf, prim); CORO_END_CODE; } @@ -1735,36 +1738,36 @@ RMGfxSourceBuffer8RLEByteAA::~RMGfxSourceBuffer8RLEByteAA() { } -void RMGfxSourceBuffer8RLEByteAA::PrepareImage(void) { - RMGfxSourceBuffer::PrepareImage(); - CalculateAA(); - CompressRLE(); +void RMGfxSourceBuffer8RLEByteAA::prepareImage(void) { + RMGfxSourceBuffer::prepareImage(); + calculateAA(); + compressRLE(); } -void RMGfxSourceBuffer8RLEByteAA::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMGfxSourceBuffer8RLEByteAA::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_2(RMGfxSourceBuffer8RLE::Draw, bigBuf, prim); + CORO_INVOKE_2(RMGfxSourceBuffer8RLE::draw, bigBuf, prim); if (GLOBALS.bCfgAntiAlias) - DrawAA(bigBuf, prim); + drawAA(bigBuf, prim); CORO_END_CODE; } -int RMGfxSourceBuffer8RLEByteAA::Init(const byte *buf, int dimx, int dimy, bool bLoadPalette) { - return RMGfxSourceBuffer8RLE::Init(buf, dimx, dimy, bLoadPalette); +int RMGfxSourceBuffer8RLEByteAA::init(const byte *buf, int dimx, int dimy, bool bLoadPalette) { + return RMGfxSourceBuffer8RLE::init(buf, dimx, dimy, bLoadPalette); } -void RMGfxSourceBuffer8RLEByteAA::Init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette) { - RMGfxSourceBuffer8RLE::Init(ds, dimx, dimy, bLoadPalette); +void RMGfxSourceBuffer8RLEByteAA::init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette) { + RMGfxSourceBuffer8RLE::init(ds, dimx, dimy, bLoadPalette); if (!bNeedRLECompress) { // Load the anti-aliasing mask - m_aabuf = new byte[dimx * dimy]; - ds.Read(m_aabuf, dimx * dimy); + _aabuf = new byte[dimx * dimy]; + ds.Read(_aabuf, dimx * dimy); } } @@ -1773,36 +1776,36 @@ RMGfxSourceBuffer8RLEWordAA::~RMGfxSourceBuffer8RLEWordAA() { } -void RMGfxSourceBuffer8RLEWordAA::PrepareImage(void) { - RMGfxSourceBuffer::PrepareImage(); - CalculateAA(); - CompressRLE(); +void RMGfxSourceBuffer8RLEWordAA::prepareImage(void) { + RMGfxSourceBuffer::prepareImage(); + calculateAA(); + compressRLE(); } -void RMGfxSourceBuffer8RLEWordAA::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMGfxSourceBuffer8RLEWordAA::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_2(RMGfxSourceBuffer8RLE::Draw, bigBuf, prim); + CORO_INVOKE_2(RMGfxSourceBuffer8RLE::draw, bigBuf, prim); if (GLOBALS.bCfgAntiAlias) - DrawAA(bigBuf, prim); + drawAA(bigBuf, prim); CORO_END_CODE; } -int RMGfxSourceBuffer8RLEWordAA::Init(byte *buf, int dimx, int dimy, bool bLoadPalette) { - return RMGfxSourceBuffer8RLE::Init(buf, dimx, dimy, bLoadPalette); +int RMGfxSourceBuffer8RLEWordAA::init(byte *buf, int dimx, int dimy, bool bLoadPalette) { + return RMGfxSourceBuffer8RLE::init(buf, dimx, dimy, bLoadPalette); } -void RMGfxSourceBuffer8RLEWordAA::Init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette) { - RMGfxSourceBuffer8RLE::Init(ds, dimx, dimy, bLoadPalette); +void RMGfxSourceBuffer8RLEWordAA::init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette) { + RMGfxSourceBuffer8RLE::init(ds, dimx, dimy, bLoadPalette); if (!bNeedRLECompress) { // Load the anti-aliasing mask - m_aabuf = new byte[dimx * dimy]; - ds.Read(m_aabuf, dimx * dimy); + _aabuf = new byte[dimx * dimy]; + ds.Read(_aabuf, dimx * dimy); } } @@ -1812,46 +1815,46 @@ void RMGfxSourceBuffer8RLEWordAA::Init(RMDataStream &ds, int dimx, int dimy, boo \****************************************************************************/ RMGfxSourceBuffer16::RMGfxSourceBuffer16(bool bTrasp0) { - m_bTrasp0 = bTrasp0; + _bTrasp0 = bTrasp0; } RMGfxSourceBuffer16::~RMGfxSourceBuffer16() { } -void RMGfxSourceBuffer16::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMGfxSourceBuffer16::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { int x, y; uint16 *buf = bigBuf; - uint16 *raw = (uint16 *)m_buf; + uint16 *raw = (uint16 *)_buf; int dimx, dimy; int u, v; int x1, y1; - dimx = m_dimx; - dimy = m_dimy; + dimx = _dimx; + dimy = _dimy; u = 0; v = 0; x1 = 0; y1 = 0; - if (prim->HaveSrc()) { + if (prim->haveSrc()) { u = prim->Src().x1; v = prim->Src().y1; dimx = prim->Src().Width(); dimy = prim->Src().Height(); } - if (prim->HaveDst()) { + if (prim->haveDst()) { x1 = prim->Dst().x1; y1 = prim->Dst().y1; } - if (!Clip2D(x1, y1, u, v, dimx, dimy, true, &bigBuf)) + if (!clip2D(x1, y1, u, v, dimx, dimy, true, &bigBuf)) return; - raw += v * m_dimx + u; - buf += y1 * bigBuf.Dimx() + x1; + raw += v * _dimx + u; + buf += y1 * bigBuf.getDimx() + x1; - if (m_bTrasp0) { + if (_bTrasp0) { for (y = 0; y < dimy; y++) { for (x = 0; x < dimx;) { while (x < dimx && raw[x] == 0) @@ -1863,14 +1866,14 @@ void RMGfxSourceBuffer16::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimi } } - raw += m_dimx; - buf += bigBuf.Dimx(); + raw += _dimx; + buf += bigBuf.getDimx(); } } else { for (y = 0; y < dimy; y++) { Common::copy(raw, raw + dimx, buf); - buf += bigBuf.Dimx(); - raw += m_dimx; + buf += bigBuf.getDimx(); + raw += _dimx; } } } @@ -1878,16 +1881,16 @@ void RMGfxSourceBuffer16::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimi void RMGfxSourceBuffer16::PrepareImage(void) { // Colour space conversion if necessary! int i; - uint16 *buf = (uint16 *)m_buf; + uint16 *buf = (uint16 *)_buf; - for (i = 0; i < m_dimx * m_dimy; i++) + for (i = 0; i < _dimx * _dimy; i++) WRITE_LE_UINT16(&buf[i], FROM_LE_16(buf[i]) & 0x7FFF); } RMGfxSourceBuffer16::RMGfxSourceBuffer16(int dimx, int dimy, bool bUseDDraw) : RMGfxBuffer(dimx, dimy, 16, bUseDDraw) { - SetPriority(0); + setPriority(0); } @@ -1901,14 +1904,14 @@ int RMGfxSourceBuffer16::Bpp() { } void RMGfxSourceBuffer16::Create(int dimx, int dimy, bool bUseDDraw) { - RMGfxBuffer::Create(dimx, dimy, 16, bUseDDraw); + RMGfxBuffer::create(dimx, dimy, 16, bUseDDraw); } /****************************************************************************\ * RMGfxBox Methods \****************************************************************************/ -void RMGfxBox::RemoveThis(CORO_PARAM, bool &result) { +void RMGfxBox::removeThis(CORO_PARAM, bool &result) { result = true; } @@ -1919,21 +1922,21 @@ void RMGfxBox::SetColor(byte r, byte g, byte b) { wFillColor = (r << 10) | (g << 5) | b; } -void RMGfxBox::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMGfxBox::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { int i, j; uint16 *buf = bigBuf; RMRect rcDst; // It takes the destination rectangle rcDst = prim->Dst(); - buf += rcDst.y1 * bigBuf.Dimx() + rcDst.x1; + buf += rcDst.y1 * bigBuf.getDimx() + rcDst.x1; // Loop through the pixels for (j = 0; j < rcDst.Height(); j++) { for (i = 0; i < rcDst.Width(); i++) *buf ++ = wFillColor; - buf += bigBuf.Dimx() - rcDst.Width(); + buf += bigBuf.getDimx() - rcDst.Width(); } } @@ -1947,12 +1950,12 @@ int RMGfxClearTask::Priority() { return 1; } -void RMGfxClearTask::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *) { +void RMGfxClearTask::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *) { // Clean the target buffer - Common::fill((byte *)bigBuf, (byte *)bigBuf + (bigBuf.Dimx() * bigBuf.Dimy() * 2), 0x0); + Common::fill((byte *)bigBuf, (byte *)bigBuf + (bigBuf.getDimx() * bigBuf.getDimy() * 2), 0x0); } -void RMGfxClearTask::RemoveThis(CORO_PARAM, bool &result) { +void RMGfxClearTask::removeThis(CORO_PARAM, bool &result) { // The task is fine to be removed result = true; } diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index ffeb7724b2..51d27b7311 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -58,10 +58,10 @@ class RMGfxClearTask; // Task */ class RMGfxBuffer { protected: - int m_dimx, m_dimy; - byte *m_buf; - byte *m_origBuf; - bool m_bUseDDraw; + int _dimx, _dimy; + byte *_buf; + byte *_origBuf; + bool _bUseDDraw; public: RMGfxBuffer(); @@ -69,27 +69,27 @@ public: virtual ~RMGfxBuffer(); // Attributes - int Dimx() { - return m_dimx; + int getDimx() { + return _dimx; } - int Dimy() { - return m_dimy; + int getDimy() { + return _dimy; } // Creation - virtual void Create(int dimx, int dimy, int nBpp, bool bUseDDraw = false); - virtual void Destroy(void); + virtual void create(int dimx, int dimy, int nBpp, bool bUseDDraw = false); + virtual void destroy(void); // Buffer access - void Lock(void); - void Unlock(void); + void lock(void); + void unlock(void); // These are valid only if the buffer is locked operator byte *(); operator void *(); // Getting the offset for a given Y position - void OffsetY(int nLines, int nBpp); + void offsetY(int nLines, int nBpp); }; /** @@ -97,116 +97,116 @@ public: */ class RMGfxPrimitive { public: - RMGfxTask *m_task; + RMGfxTask *_task; protected: - RMRect m_src; - RMRect m_dst; + RMRect _src; + RMRect _dst; - bool m_bStretch; - byte m_bFlag; + bool _bStretch; + byte _bFlag; public: RMGfxPrimitive() { - m_bFlag = 0; - m_task = NULL; - m_src.SetEmpty(); - m_dst.SetEmpty(); + _bFlag = 0; + _task = NULL; + _src.SetEmpty(); + _dst.SetEmpty(); } RMGfxPrimitive(RMGfxTask *task) { - m_task = task; - m_bFlag = 0; + _task = task; + _bFlag = 0; } RMGfxPrimitive(RMGfxTask *task, const RMRect &src, RMRect &dst) { - m_task = task; - m_src = src; - m_dst = dst; - m_bFlag = 0; - m_bStretch = (src.Width() != dst.Width() || src.Height() != dst.Height()); + _task = task; + _src = src; + _dst = dst; + _bFlag = 0; + _bStretch = (src.Width() != dst.Width() || src.Height() != dst.Height()); } RMGfxPrimitive(RMGfxTask *task, const RMPoint &src, RMRect &dst) { - m_task = task; - m_src.TopLeft() = src; - m_dst = dst; - m_bFlag = 0; + _task = task; + _src.TopLeft() = src; + _dst = dst; + _bFlag = 0; } RMGfxPrimitive(RMGfxTask *task, const RMPoint &src, RMPoint &dst) { - m_task = task; - m_src.TopLeft() = src; - m_dst.TopLeft() = dst; - m_bFlag = 0; + _task = task; + _src.TopLeft() = src; + _dst.TopLeft() = dst; + _bFlag = 0; } RMGfxPrimitive(RMGfxTask *task, const RMRect &src, RMPoint &dst) { - m_task = task; - m_src = src; - m_dst.TopLeft() = dst; - m_bFlag = 0; + _task = task; + _src = src; + _dst.TopLeft() = dst; + _bFlag = 0; } RMGfxPrimitive(RMGfxTask *task, const RMRect &dst) { - m_task = task; - m_dst = dst; - m_src.SetEmpty(); - m_bFlag = 0; + _task = task; + _dst = dst; + _src.SetEmpty(); + _bFlag = 0; } RMGfxPrimitive(RMGfxTask *task, const RMPoint &dst) { - m_task = task; - m_dst.TopLeft() = dst; - m_src.SetEmpty(); - m_bFlag = 0; + _task = task; + _dst.TopLeft() = dst; + _src.SetEmpty(); + _bFlag = 0; } virtual ~RMGfxPrimitive() { } - void SetFlag(byte bFlag) { - m_bFlag = bFlag; + void setFlag(byte bFlag) { + _bFlag = bFlag; } - void SetTask(RMGfxTask *task) { - m_task = task; + void setTask(RMGfxTask *task) { + _task = task; } - void SetSrc(const RMRect &src) { - m_src = src; + void setSrc(const RMRect &src) { + _src = src; } - void SetSrc(const RMPoint &src) { - m_src.TopLeft() = src; + void setSrc(const RMPoint &src) { + _src.TopLeft() = src; } - void SetDst(const RMRect &dst) { - m_dst = dst; + void setDst(const RMRect &dst) { + _dst = dst; } - void SetDst(const RMPoint &dst) { - m_dst.TopLeft() = dst; + void setDst(const RMPoint &dst) { + _dst.TopLeft() = dst; } - void SetStrecth(bool bStretch) { - m_bStretch = bStretch; + void setStrecth(bool bStretch) { + _bStretch = bStretch; } - bool HaveDst() { - return !m_dst.IsEmpty(); + bool haveDst() { + return !_dst.IsEmpty(); } RMRect &Dst() { - return m_dst; + return _dst; } - bool HaveSrc() { - return !m_src.IsEmpty(); + bool haveSrc() { + return !_src.IsEmpty(); } RMRect &Src() { - return m_src; + return _src; } // Flags - bool IsFlipped() { - return m_bFlag & 1; + bool isFlipped() { + return _bFlag & 1; } // Duplicate - virtual RMGfxPrimitive *Duplicate() { + virtual RMGfxPrimitive *duplicate() { return new RMGfxPrimitive(*this); } }; @@ -217,25 +217,25 @@ public: */ class RMGfxTask { protected: - int m_nPrior; - int m_nInList; + int _nPrior; + int _nInList; public: // Standard constructor RMGfxTask(); virtual ~RMGfxTask() { } - virtual int Priority(); - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) = 0; - virtual void RemoveThis(CORO_PARAM, bool &result); + virtual int priority(); + virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) = 0; + virtual void removeThis(CORO_PARAM, bool &result); // Registration virtual void Register(void) { - m_nInList++; + _nInList++; } virtual void Unregister(void) { - m_nInList--; - assert(m_nInList >= 0); + _nInList--; + assert(_nInList >= 0); } }; @@ -246,7 +246,7 @@ public: class RMGfxTaskSetPrior : public RMGfxTask { public: virtual ~RMGfxTaskSetPrior() { } - void SetPriority(int nPrior); + void setPriority(int nPrior); }; @@ -258,8 +258,8 @@ public: virtual ~RMGfxClearTask() { } int Priority(); - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - virtual void RemoveThis(CORO_PARAM, bool &result); + virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void removeThis(CORO_PARAM, bool &result); }; @@ -274,8 +274,8 @@ public: virtual ~RMGfxBox() { } void SetColor(byte r, byte g, byte b); - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - virtual void RemoveThis(CORO_PARAM, bool &result); + virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void removeThis(CORO_PARAM, bool &result); }; @@ -285,17 +285,17 @@ public: class RMGfxSourceBuffer : public virtual RMGfxBuffer, public RMGfxTaskSetPrior { public: // Load the data for the surface - virtual int Init(uint32 resID, int dimx, int dimy, bool bLoadPalette = false); - virtual int Init(const byte *buf, int dimx, int dimy, bool bLoadPalette = false); - virtual void Init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette = false); + virtual int init(uint32 resID, int dimx, int dimy, bool bLoadPalette = false); + virtual int init(const byte *buf, int dimx, int dimy, bool bLoadPalette = false); + virtual void init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette = false); virtual ~RMGfxSourceBuffer(); protected: - virtual void PrepareImage(void); - bool Clip2D(int &x1, int &y1, int &u, int &v, int &width, int &height, bool bUseSrc, RMGfxTargetBuffer *buf); - void OffsetY(int nLines) { - RMGfxBuffer::OffsetY(nLines, Bpp()); + virtual void prepareImage(void); + bool clip2D(int &x1, int &y1, int &u, int &v, int &width, int &height, bool bUseSrc, RMGfxTargetBuffer *buf); + void offsetY(int nLines) { + RMGfxBuffer::offsetY(nLines, Bpp()); } public: @@ -309,7 +309,7 @@ public: class RMGfxSourceBuffer16 : public RMGfxSourceBuffer { protected: virtual void PrepareImage(void); - bool m_bTrasp0; + bool _bTrasp0; public: RMGfxSourceBuffer16(bool bUseTrasp = false); @@ -320,7 +320,7 @@ public: void Create(int dimx, int dimy, bool bUseDDraw = false); int Bpp(); - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); }; @@ -330,22 +330,22 @@ public: class RMGfxSourceBufferPal : public RMGfxSourceBuffer { protected: // The size of the palette is (1 << Bpp()) * 4 - byte m_pal[256 * 3]; - uint16 m_palFinal[256]; + byte _pal[256 * 3]; + uint16 _palFinal[256]; // Post process to prepare the palette for drawing - virtual void PreparePalette(void); + virtual void preparePalette(void); public: virtual ~RMGfxSourceBufferPal(); - virtual int Init(const byte *buf, int dimx, int dimy, bool bLoadPalette = false); - virtual void Init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette = false); + virtual int init(const byte *buf, int dimx, int dimy, bool bLoadPalette = false); + virtual void init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette = false); - int LoadPaletteWA(uint32 resID, bool bSwapped = false); - int LoadPaletteWA(const byte *buf, bool bSwapped = false); - int LoadPalette(uint32 resID); - int LoadPalette(const byte *buf); + int loadPaletteWA(uint32 resID, bool bSwapped = false); + int loadPaletteWA(const byte *buf, bool bSwapped = false); + int loadPalette(uint32 resID); + int loadPalette(const byte *buf); }; @@ -354,7 +354,7 @@ public: */ class RMGfxSourceBuffer8 : public RMGfxSourceBufferPal { protected: - bool m_bTrasp0; + bool _bTrasp0; public: RMGfxSourceBuffer8(bool bTrasp0 = true); @@ -362,10 +362,10 @@ public: virtual ~RMGfxSourceBuffer8(); // Initialisation - void Create(int dimx, int dimy, bool bUseDDraw = false); + void create(int dimx, int dimy, bool bUseDDraw = false); int Bpp(); - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); }; @@ -374,11 +374,11 @@ public: */ class RMGfxSourceBuffer8AB : public RMGfxSourceBuffer8 { protected: - int CalcTrasp(int f, int b); + int calcTrasp(int f, int b); public: virtual ~RMGfxSourceBuffer8AB(); - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); }; @@ -403,29 +403,29 @@ protected: virtual void RLEDecompressLineFlipped(uint16 *dst, byte *src, int nStartSkip, int nLength) = 0; // Perform image compression in RLE - void CompressRLE(void); + void compressRLE(void); protected: // Overriding initialisation methods - virtual void PrepareImage(void); - virtual void PreparePalette(void); + virtual void prepareImage(void); + virtual void preparePalette(void); public: RMGfxSourceBuffer8RLE(); virtual ~RMGfxSourceBuffer8RLE(); // Overload of the initialisation method - virtual void Init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette = false); - virtual int Init(const byte *buf, int dimx, int dimy, bool bLoadPalette = false); + virtual void init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette = false); + virtual int init(const byte *buf, int dimx, int dimy, bool bLoadPalette = false); // Draw image with RLE decompression - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Sets the color that will be alpha blended - void SetAlphaBlendColor(int color); + void setAlphaBlendColor(int color); // Warn if the data is already compressed - void SetAlreadyCompressed(void); + void setAlreadyCompressed(void); }; class RMGfxSourceBuffer8RLEByte : public RMGfxSourceBuffer8RLE { @@ -470,50 +470,50 @@ class RMGfxSourceBuffer8AA : public virtual RMGfxSourceBuffer8 { protected: static byte MegaAABuf[]; static byte MegaAABuf2[]; - byte *m_aabuf; + byte *_aabuf; // Calculate the buffer for the anti-aliasing - void CalculateAA(void); + void calculateAA(void); // Draw the AA - void DrawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + void drawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); protected: - void PrepareImage(void); + void prepareImage(void); public: RMGfxSourceBuffer8AA(); virtual ~RMGfxSourceBuffer8AA(); // Draw with anti-aliasing - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); }; class RMGfxSourceBuffer8RLEByteAA : public RMGfxSourceBuffer8RLEByte, public RMGfxSourceBuffer8AA { protected: - void PrepareImage(void); + void prepareImage(void); public: - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Overloaded initialisation methods - virtual void Init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette = false); - virtual int Init(const byte *buf, int dimx, int dimy, bool bLoadPalette = false); + virtual void init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette = false); + virtual int init(const byte *buf, int dimx, int dimy, bool bLoadPalette = false); virtual ~RMGfxSourceBuffer8RLEByteAA(); }; class RMGfxSourceBuffer8RLEWordAA : public RMGfxSourceBuffer8RLEWord, public RMGfxSourceBuffer8AA { protected: - void PrepareImage(void); + void prepareImage(void); public: - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Overloaded initialisation methods - virtual void Init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette = false); - virtual int Init(byte *buf, int dimx, int dimy, bool bLoadPalette = false); + virtual void init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette = false); + virtual int init(byte *buf, int dimx, int dimy, bool bLoadPalette = false); virtual ~RMGfxSourceBuffer8RLEWordAA(); }; @@ -531,7 +531,7 @@ public: void Create(int dimx, int dimy, bool bUseDDraw = false); int Bpp(); - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); }; @@ -557,34 +557,34 @@ private: protected: OTList *otlist; - int m_otSize; + int _otSize; public: RMGfxTargetBuffer(); virtual ~RMGfxTargetBuffer(); // management of the OT list - void ClearOT(void); - void DrawOT(CORO_PARAM); - void AddPrim(RMGfxPrimitive *prim); // The pointer must be delted + void clearOT(void); + void drawOT(CORO_PARAM); + void addPrim(RMGfxPrimitive *prim); // The pointer must be delted // Adds a task to clear the screen - void AddClearTask(void); + void addClearTask(void); operator byte *() { - return m_buf; + return _buf; } operator void *() { - return (void *)m_buf; + return (void *)_buf; } operator uint16 *() { // FIXME: This may not be endian safe - return (uint16 *)m_buf; + return (uint16 *)_buf; } // Offseting buffer - void OffsetY(int nLines) { - RMGfxBuffer::OffsetY(nLines, 16); + void offsetY(int nLines) { + RMGfxBuffer::offsetY(nLines, 16); } }; @@ -598,7 +598,7 @@ public: RMGfxWoodyBuffer(int dimx, int dimy, bool bUseDDraw = false); virtual ~RMGfxWoodyBuffer(); - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); }; } // End of namespace Tony diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index dd448fdc93..2d1c0663a6 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -61,8 +61,8 @@ void ExitAllIdles(CORO_PARAM, const void *param) { RMGfxEngine::RMGfxEngine() { // Create big buffer where the frame will be rendered - _bigBuf.Create(RM_BBX, RM_BBY, 16); - _bigBuf.OffsetY(RM_SKIPY); + _bigBuf.create(RM_BBX, RM_BBY, 16); + _bigBuf.offsetY(RM_SKIPY); _csMainLoop = NULL; _nCurLoc = 0; @@ -84,7 +84,7 @@ RMGfxEngine::RMGfxEngine() { RMGfxEngine::~RMGfxEngine() { // Close the buffer - _bigBuf.Destroy(); + _bigBuf.destroy(); g_system->deleteMutex(_csMainLoop); } @@ -312,7 +312,7 @@ SKIPCLICKSINISTRO: // ********************** // Draw the list in the OT // ********************** - CORO_INVOKE_0(_bigBuf.DrawOT); + CORO_INVOKE_0(_bigBuf.drawOT); #define FSTEP (480/32) @@ -454,7 +454,7 @@ void RMGfxEngine::unloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result) { _bLocationLoaded = false; - _bigBuf.ClearOT(); + _bigBuf.clearOT(); _loc.Unload(); if (result != NULL) @@ -468,9 +468,9 @@ void RMGfxEngine::init() { RMResRaw *raw; RMGfxSourceBuffer16 *load = NULL; INIT_GFX16_FROMRAW(20038, load); - _bigBuf.AddPrim(new RMGfxPrimitive(load)); - _bigBuf.DrawOT(Common::nullContext); - _bigBuf.ClearOT(); + _bigBuf.addPrim(new RMGfxPrimitive(load)); + _bigBuf.drawOT(Common::nullContext); + _bigBuf.clearOT(); delete load; _vm->_window.GetNewFrame(*this, NULL); @@ -502,7 +502,7 @@ void RMGfxEngine::init() { _point.Init(); // Initialise Tony - _tony.Init(); + _tony.init(); _tony.LinkToBoxes(&_vm->_theBoxes); // Initialise the inventory and the interface @@ -519,7 +519,7 @@ void RMGfxEngine::init() { } void RMGfxEngine::close(void) { - _bigBuf.ClearOT(); + _bigBuf.clearOT(); _inter.Close(); _inv.Close(); diff --git a/engines/tony/gfxengine.h b/engines/tony/gfxengine.h index 695c5af58f..69d36cbbc0 100644 --- a/engines/tony/gfxengine.h +++ b/engines/tony/gfxengine.h @@ -121,7 +121,7 @@ public: // Link to graphic task void linkGraphicTask(RMGfxTask *task) { - _bigBuf.AddPrim(new RMGfxPrimitive(task)); + _bigBuf.addPrim(new RMGfxPrimitive(task)); }; // Manage a location diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index 5fb375da81..9b8f346aaf 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -79,7 +79,7 @@ void RMInventory::Init(void) { // Create the main buffer Create(RM_SX, 68); - SetPriority(185); + setPriority(185); // Setup the inventory m_nInv = 0; @@ -122,7 +122,7 @@ void RMInventory::Init(void) { assert(raw.IsValid()); - m_items[i].pointer[j].Init((const byte *)raw, raw.Width(), raw.Height(), true); + m_items[i].pointer[j].init((const byte *)raw, raw.Width(), raw.Height(), true); curres++; } } @@ -156,8 +156,8 @@ void RMInventory::Init(void) { // Prepare initial inventory Prepare(); - DrawOT(Common::nullContext); - ClearOT(); + drawOT(Common::nullContext); + clearOT(); } void RMInventory::Close(void) { @@ -172,7 +172,7 @@ void RMInventory::Close(void) { m_items = NULL; } - Destroy(); + destroy(); } void RMInventory::Reset(void) { @@ -180,7 +180,7 @@ void RMInventory::Reset(void) { EndCombine(); } -void RMInventory::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMInventory::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CONTEXT; RMPoint pos; RMPoint pos2; @@ -191,12 +191,12 @@ void RMInventory::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr CORO_BEGIN_CODE(_ctx); if (m_state == OPENING || m_state == CLOSING) - prim->SetDst(RMPoint(0, m_curPutY)); + prim->setDst(RMPoint(0, m_curPutY)); else - prim->SetDst(RMPoint(0, m_curPutY)); + prim->setDst(RMPoint(0, m_curPutY)); g_system->lockMutex(m_csModifyInterface); - CORO_INVOKE_2(RMGfxWoodyBuffer::Draw, bigBuf, prim); + CORO_INVOKE_2(RMGfxWoodyBuffer::draw, bigBuf, prim); g_system->unlockMutex(m_csModifyInterface); if (m_state == SELECTING) { @@ -209,19 +209,19 @@ void RMInventory::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr _ctx->pos2.Set((m_nSelectObj + 1) * 64 + 34, 119 - 4); } - _ctx->p = new RMGfxPrimitive(prim->m_task, _ctx->pos); - _ctx->p2 = new RMGfxPrimitive(prim->m_task, _ctx->pos2); + _ctx->p = new RMGfxPrimitive(prim->_task, _ctx->pos); + _ctx->p2 = new RMGfxPrimitive(prim->_task, _ctx->pos2); // Draw the mini interface - CORO_INVOKE_2(miniInterface.Draw, bigBuf, _ctx->p); + CORO_INVOKE_2(miniInterface.draw, bigBuf, _ctx->p); if (GLOBALS.bCfgInterTips) { if (miniAction == 1) // Examine - CORO_INVOKE_2(m_hints[0].Draw, bigBuf, _ctx->p2); + CORO_INVOKE_2(m_hints[0].draw, bigBuf, _ctx->p2); else if (miniAction == 2) // Talk - CORO_INVOKE_2(m_hints[1].Draw, bigBuf, _ctx->p2); + CORO_INVOKE_2(m_hints[1].draw, bigBuf, _ctx->p2); else if (miniAction == 3) // Use - CORO_INVOKE_2(m_hints[2].Draw, bigBuf, _ctx->p2); + CORO_INVOKE_2(m_hints[2].draw, bigBuf, _ctx->p2); } delete _ctx->p; @@ -249,8 +249,8 @@ void RMInventory::RemoveItem(int code) { m_nInv--; Prepare(); - DrawOT(Common::nullContext); - ClearOT(); + drawOT(Common::nullContext); + clearOT(); g_system->unlockMutex(m_csModifyInterface); return; } @@ -270,8 +270,8 @@ void RMInventory::AddItem(int code) { m_inv[m_nInv++] = code - 10000; Prepare(); - DrawOT(Common::nullContext); - ClearOT(); + drawOT(Common::nullContext); + clearOT(); g_system->unlockMutex(m_csModifyInterface); } } @@ -285,8 +285,8 @@ void RMInventory::ChangeItemStatus(uint32 code, uint32 dwStatus) { m_items[code - 10000].status = dwStatus; Prepare(); - DrawOT(Common::nullContext); - ClearOT(); + drawOT(Common::nullContext); + clearOT(); g_system->unlockMutex(m_csModifyInterface); } } @@ -297,14 +297,14 @@ void RMInventory::Prepare(void) { for (i = 1; i < RM_SX / 64 - 1; i++) { if (i - 1 + m_curPos < m_nInv) - AddPrim(new RMGfxPrimitive(&m_items[m_inv[i - 1 + m_curPos]].icon, RMPoint(i * 64, 0))); + addPrim(new RMGfxPrimitive(&m_items[m_inv[i - 1 + m_curPos]].icon, RMPoint(i * 64, 0))); else - AddPrim(new RMGfxPrimitive(&m_items[0].icon, RMPoint(i * 64, 0))); + addPrim(new RMGfxPrimitive(&m_items[0].icon, RMPoint(i * 64, 0))); } // Frecce - AddPrim(new RMGfxPrimitive(&m_items[29].icon, RMPoint(0, 0))); - AddPrim(new RMGfxPrimitive(&m_items[28].icon, RMPoint(640 - 64, 0))); + addPrim(new RMGfxPrimitive(&m_items[29].icon, RMPoint(0, 0))); + addPrim(new RMGfxPrimitive(&m_items[28].icon, RMPoint(640 - 64, 0))); } bool RMInventory::MiniActive(void) { @@ -364,8 +364,8 @@ bool RMInventory::LeftClick(const RMPoint &mpos, int &nCombineObj) { } Prepare(); - DrawOT(Common::nullContext); - ClearOT(); + drawOT(Common::nullContext); + clearOT(); g_system->unlockMutex(m_csModifyInterface); } // Click the left arrow @@ -385,8 +385,8 @@ bool RMInventory::LeftClick(const RMPoint &mpos, int &nCombineObj) { } Prepare(); - DrawOT(Common::nullContext); - ClearOT(); + drawOT(Common::nullContext); + clearOT(); g_system->unlockMutex(m_csModifyInterface); } @@ -430,8 +430,8 @@ void RMInventory::RightClick(const RMPoint &mpos) { } Prepare(); - DrawOT(Common::nullContext); - ClearOT(); + drawOT(Common::nullContext); + clearOT(); g_system->unlockMutex(m_csModifyInterface); } else if ((m_state == OPENED) && m_bBlinkingLeft) { assert(m_curPos > 0); @@ -450,8 +450,8 @@ void RMInventory::RightClick(const RMPoint &mpos) { } Prepare(); - DrawOT(Common::nullContext); - ClearOT(); + drawOT(Common::nullContext); + clearOT(); g_system->unlockMutex(m_csModifyInterface); } } @@ -484,7 +484,7 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo if (m_state != CLOSED) { // Clean up the OT list g_system->lockMutex(m_csModifyInterface); - ClearOT(); + clearOT(); // DoFrame makes all the objects currently in the inventory be displayed // @@@ Maybe we should do all takeable objects? Please does not help @@ -662,8 +662,8 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo miniInterface.DoFrame(&bigBuf, false); } - if ((m_state != CLOSED) && !m_nInList) { - bigBuf.AddPrim(new RMGfxPrimitive(this)); + if ((m_state != CLOSED) && !_nInList) { + bigBuf.addPrim(new RMGfxPrimitive(this)); } } @@ -744,8 +744,8 @@ int RMInventory::LoadState(byte *state) { m_items[28].icon.SetPattern(1); Prepare(); - DrawOT(Common::nullContext); - ClearOT(); + drawOT(Common::nullContext); + clearOT(); return GetSaveStateSize(); } @@ -781,7 +781,7 @@ int RMInterface::OnWhichBox(RMPoint pt) { return -1; } -void RMInterface::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMInterface::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CONTEXT; int h; CORO_END_CONTEXT(_ctx); @@ -789,13 +789,13 @@ void RMInterface::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr CORO_BEGIN_CODE(_ctx); prim->Dst().TopLeft() = m_openStart; - CORO_INVOKE_2(RMGfxSourceBuffer8RLEByte::Draw, bigBuf, prim); + CORO_INVOKE_2(RMGfxSourceBuffer8RLEByte::draw, bigBuf, prim); // Check if there is a draw hot zone _ctx->h = OnWhichBox(m_mpos); if (_ctx->h != -1) { prim->Dst().TopLeft() = m_openStart; - CORO_INVOKE_2(m_hotzone[_ctx->h].Draw, bigBuf, prim); + CORO_INVOKE_2(m_hotzone[_ctx->h].draw, bigBuf, prim); if (m_lastHotZone != _ctx->h) { m_lastHotZone = _ctx->h; @@ -804,7 +804,7 @@ void RMInterface::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr if (GLOBALS.bCfgInterTips) { prim->Dst().TopLeft() = m_openStart + RMPoint(70, 177); - CORO_INVOKE_2(m_hints[_ctx->h].Draw, bigBuf, prim); + CORO_INVOKE_2(m_hints[_ctx->h].draw, bigBuf, prim); } } else m_lastHotZone = -1; @@ -815,8 +815,8 @@ void RMInterface::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr void RMInterface::DoFrame(RMGfxTargetBuffer &bigBuf, RMPoint mousepos) { // If needed, add to the OT schedule list - if (!m_nInList && m_bActive) - bigBuf.AddPrim(new RMGfxPrimitive(this)); + if (!_nInList && m_bActive) + bigBuf.addPrim(new RMGfxPrimitive(this)); m_mpos = mousepos; } @@ -826,14 +826,14 @@ void RMInterface::Clicked(const RMPoint &mousepos) { m_openPos = mousepos; // Calculate the top left corner of the interface - m_openStart = m_openPos - RMPoint(m_dimx / 2, m_dimy / 2); + m_openStart = m_openPos - RMPoint(_dimx / 2, _dimy / 2); m_lastHotZone = -1; // Keep it inside the screen if (m_openStart.x < 0) m_openStart.x = 0; if (m_openStart.y < 0) m_openStart.y = 0; - if (m_openStart.x + m_dimx > RM_SX) m_openStart.x = RM_SX - m_dimx; - if (m_openStart.y + m_dimy > RM_SY) m_openStart.y = RM_SY - m_dimy; + if (m_openStart.x + _dimx > RM_SX) m_openStart.x = RM_SX - _dimx; + if (m_openStart.y + _dimy > RM_SY) m_openStart.y = RM_SY - _dimy; // Play the sound effect _vm->playUtilSFX(0); @@ -890,16 +890,16 @@ void RMInterface::Init(void) { RMResRaw inter(RES_I_INTERFACE); RMRes pal(RES_I_INTERPPAL); - SetPriority(191); + setPriority(191); - RMGfxSourceBuffer::Init(inter, inter.Width(), inter.Height()); - LoadPaletteWA(RES_I_INTERPAL); + RMGfxSourceBuffer::init(inter, inter.Width(), inter.Height()); + loadPaletteWA(RES_I_INTERPAL); for (i = 0; i < 5; i++) { RMResRaw part(RES_I_INTERP1 + i); - m_hotzone[i].Init(part, part.Width(), part.Height()); - m_hotzone[i].LoadPaletteWA(pal); + m_hotzone[i].init(part, part.Width(), part.Height()); + m_hotzone[i].loadPaletteWA(pal); } m_hotbbox[0].SetRect(126, 123, 159, 208); // Take @@ -935,10 +935,10 @@ void RMInterface::Init(void) { void RMInterface::Close(void) { int i; - Destroy(); + destroy(); for (i = 0; i < 5; i++) - m_hotzone[i].Destroy(); + m_hotzone[i].destroy(); } } // End of namespace Tony diff --git a/engines/tony/inventory.h b/engines/tony/inventory.h index a5f02603e7..87ccaa33b4 100644 --- a/engines/tony/inventory.h +++ b/engines/tony/inventory.h @@ -101,7 +101,7 @@ public: virtual void RemoveThis(CORO_PARAM, bool &result); // Overload the drawing of the inventory - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Method for determining whether the inventory currently has the focus bool HaveFocus(const RMPoint &mpos); @@ -193,7 +193,7 @@ public: bool GetPalesati(void); // Overloaded Draw - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); }; } // End of namespace Tony diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 601ae3f09b..1a7933a03d 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -356,15 +356,15 @@ void RMSprite::ReadFromStream(RMDataStream &ds, bool bLOX) { ds += 32; // Create buffer and read - m_buf->Init(ds, dimx, dimy); + m_buf->init(ds, dimx, dimy); } -void RMSprite::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { - m_buf->Draw(coroParam, bigBuf, prim); +void RMSprite::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { + m_buf->draw(coroParam, bigBuf, prim); } void RMSprite::SetPalette(byte *buf) { - ((RMGfxSourceBufferPal *)m_buf)->LoadPalette(buf); + ((RMGfxSourceBufferPal *)m_buf)->loadPalette(buf); } RMSprite::RMSprite() { @@ -500,9 +500,9 @@ RMGfxSourceBuffer *RMItem::NewItemSpriteBuffer(int dimx, int dimy, bool bPreRLE) else spr = new RMGfxSourceBuffer8RLEByteAA; - spr->SetAlphaBlendColor(m_FXparm); + spr->setAlphaBlendColor(m_FXparm); if (bPreRLE) - spr->SetAlreadyCompressed(); + spr->setAlreadyCompressed(); } else { if (dimx == -1 || dimx > 255) spr = new RMGfxSourceBuffer8RLEWord; @@ -510,7 +510,7 @@ RMGfxSourceBuffer *RMItem::NewItemSpriteBuffer(int dimx, int dimy, bool bPreRLE) spr = new RMGfxSourceBuffer8RLEByte; if (bPreRLE) - spr->SetAlreadyCompressed(); + spr->setAlreadyCompressed(); } return spr; @@ -675,8 +675,8 @@ bool RMItem::DoFrame(RMGfxTargetBuffer *bigBuf, bool bAddToList) { } // If we are not in the OT list, add ourselves - if (!m_nInList && bAddToList) - bigBuf->AddPrim(NewItemPrimitive()); + if (!_nInList && bAddToList) + bigBuf->addPrim(NewItemPrimitive()); return oldSprite != m_nCurSprite; } @@ -685,7 +685,7 @@ RMPoint RMItem::CalculatePos(void) { return m_pos + m_patterns[m_nCurPattern].Pos(); } -void RMItem::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMItem::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); @@ -696,7 +696,7 @@ void RMItem::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { return; // Set the flag - prim->SetFlag(m_bCurFlag); + prim->setFlag(m_bCurFlag); // Offset direction for scrolling prim->Dst().Offset(-m_curScroll); @@ -706,10 +706,10 @@ void RMItem::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { prim->Dst().Offset(CalculatePos()); // No stretching, please - prim->SetStrecth(false); + prim->setStrecth(false); // Now we turn to the generic surface drawing routines - CORO_INVOKE_2(m_sprites[m_nCurSprite].Draw, bigBuf, prim); + CORO_INVOKE_2(m_sprites[m_nCurSprite].draw, bigBuf, prim); CORO_END_CODE; } @@ -867,7 +867,7 @@ int RMWipe::Priority(void) { void RMWipe::Unregister(void) { RMGfxTask::Unregister(); - assert(m_nInList == 0); + assert(_nInList == 0); CoroScheduler.setEvent(m_hUnregistered); } @@ -919,7 +919,7 @@ void RMWipe::InitFade(int type) { void RMWipe::DoFrame(RMGfxTargetBuffer &bigBuf) { if (m_bMustRegister) { - bigBuf.AddPrim(new RMGfxPrimitive(this)); + bigBuf.addPrim(new RMGfxPrimitive(this)); m_bMustRegister = false; } @@ -934,18 +934,18 @@ void RMWipe::DoFrame(RMGfxTargetBuffer &bigBuf) { } } -void RMWipe::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMWipe::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); if (m_bFading) { - CORO_INVOKE_2(m_wip0r.Draw, bigBuf, prim); + CORO_INVOKE_2(m_wip0r.draw, bigBuf, prim); } if (m_bEndFade) - Common::fill((byte *)bigBuf, (byte *)bigBuf + bigBuf.Dimx() * bigBuf.Dimy() * 2, 0x0); + Common::fill((byte *)bigBuf, (byte *)bigBuf + bigBuf.getDimx() * bigBuf.getDimy() * 2, 0x0); CORO_END_CODE; } @@ -1332,7 +1332,7 @@ RMPoint RMCharacter::NearestHotSpot(int sourcebox, int destbox) { return puntocaldo; } -void RMCharacter::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMCharacter::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); @@ -1341,7 +1341,7 @@ void RMCharacter::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr if (bDrawNow) { prim->Dst() += m_fixedScroll; - CORO_INVOKE_2(RMItem::Draw, bigBuf, prim); + CORO_INVOKE_2(RMItem::draw, bigBuf, prim); } CORO_END_CODE; @@ -2072,7 +2072,7 @@ bool RMLocation::Load(RMDataStream &ds) { }; // Initialise the surface, loading the palette if necessary - m_buf->Init(ds, dimx, dimy, true); + m_buf->init(ds, dimx, dimy, true); // Check the size of the location // assert(dimy!=512); @@ -2119,7 +2119,7 @@ bool RMLocation::LoadLOX(RMDataStream &ds) { m_buf = new RMGfxSourceBuffer16; // Initialise the surface, loading in the palette if necessary - m_buf->Init(ds, dimx, dimy, true); + m_buf->init(ds, dimx, dimy, true); // Number of items ds >> m_nItems; @@ -2138,21 +2138,21 @@ bool RMLocation::LoadLOX(RMDataStream &ds) { /** * Draw method overloaded from RMGfxSourceBUffer8 */ -void RMLocation::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMLocation::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); // Set the position of the source scrolling - if (m_buf->Dimy() > RM_SY || m_buf->Dimx() > RM_SX) { - prim->SetSrc(RMRect(m_curScroll, m_curScroll + RMPoint(640, 480))); + if (m_buf->getDimy() > RM_SY || m_buf->getDimx() > RM_SX) { + prim->setSrc(RMRect(m_curScroll, m_curScroll + RMPoint(640, 480))); } - prim->SetDst(m_fixedScroll); + prim->setDst(m_fixedScroll); // Invoke the drawing method fo the image class, which will draw the location background - CORO_INVOKE_2(m_buf->Draw, bigBuf, prim); + CORO_INVOKE_2(m_buf->draw, bigBuf, prim); CORO_END_CODE; } @@ -2165,8 +2165,8 @@ void RMLocation::DoFrame(RMGfxTargetBuffer *bigBuf) { int i; // If the location is not in the OT list, add it in - if (!m_nInList) - bigBuf->AddPrim(new RMGfxPrimitive(this)); + if (!_nInList) + bigBuf->addPrim(new RMGfxPrimitive(this)); // Process all the location items for (i = 0; i < m_nItems; i++) @@ -2231,7 +2231,7 @@ void RMLocation::UpdateScrolling(const RMPoint &ptShowThis) { m_curScroll.x = ptShowThis.x - 250; } else if (m_curScroll.x + RM_SX - 250 < ptShowThis.x) { m_curScroll.x = ptShowThis.x + 250 - RM_SX; - } else if (ABS(m_curScroll.x + RM_SX / 2 - ptShowThis.x) > 32 && m_buf->Dimx() > RM_SX) { + } else if (ABS(m_curScroll.x + RM_SX / 2 - ptShowThis.x) > 32 && m_buf->getDimx() > RM_SX) { if (m_curScroll.x + RM_SX / 2 < ptShowThis.x) m_curScroll.x++; else @@ -2242,17 +2242,21 @@ void RMLocation::UpdateScrolling(const RMPoint &ptShowThis) { m_curScroll.y = ptShowThis.y - 180; } else if (m_curScroll.y + RM_SY - 180 < ptShowThis.y) { m_curScroll.y = ptShowThis.y + 180 - RM_SY; - } else if (ABS(m_curScroll.y + RM_SY / 2 - ptShowThis.y) > 16 && m_buf->Dimy() > RM_SY) { + } else if (ABS(m_curScroll.y + RM_SY / 2 - ptShowThis.y) > 16 && m_buf->getDimy() > RM_SY) { if (m_curScroll.y + RM_SY / 2 < ptShowThis.y) m_curScroll.y++; else m_curScroll.y--; } - if (m_curScroll.x < 0) m_curScroll.x = 0; - if (m_curScroll.y < 0) m_curScroll.y = 0; - if (m_curScroll.x + RM_SX > m_buf->Dimx()) m_curScroll.x = m_buf->Dimx() - RM_SX; - if (m_curScroll.y + RM_SY > m_buf->Dimy()) m_curScroll.y = m_buf->Dimy() - RM_SY; + if (m_curScroll.x < 0) + m_curScroll.x = 0; + if (m_curScroll.y < 0) + m_curScroll.y = 0; + if (m_curScroll.x + RM_SX > m_buf->getDimx()) + m_curScroll.x = m_buf->getDimx() - RM_SX; + if (m_curScroll.y + RM_SY > m_buf->getDimy()) + m_curScroll.y = m_buf->getDimy() - RM_SY; if (oldScroll != m_curScroll) for (int i = 0; i < m_nItems; i++) @@ -2268,10 +2272,14 @@ void RMLocation::SetFixedScroll(const RMPoint &scroll) { void RMLocation::SetScrollPosition(const RMPoint &scroll) { RMPoint pt = scroll; - if (pt.x < 0) pt.x = 0; - if (pt.y < 0) pt.y = 0; - if (pt.x + RM_SX > m_buf->Dimx()) pt.x = m_buf->Dimx() - RM_SX; - if (pt.y + RM_SY > m_buf->Dimy()) pt.y = m_buf->Dimy() - RM_SY; + if (pt.x < 0) + pt.x = 0; + if (pt.y < 0) + pt.y = 0; + if (pt.x + RM_SX > m_buf->getDimx()) + pt.x = m_buf->getDimx() - RM_SX; + if (pt.y + RM_SY > m_buf->getDimy()) + pt.y = m_buf->getDimy() - RM_SY; m_curScroll = pt; diff --git a/engines/tony/loc.h b/engines/tony/loc.h index 612e7b5d3e..c11dac4782 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -186,7 +186,7 @@ public: void Init(RMGfxSourceBuffer *buf); friend RMDataStream &operator>>(RMDataStream &ds, RMSprite &sprite); - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); void SetPalette(byte *lpBuf); void GetSizeFromStream(RMDataStream &ds, int *dimx, int *dimy); void LOXGetSizeFromStream(RMDataStream &ds, int *dimx, int *dimy); @@ -254,7 +254,7 @@ public: virtual void RemoveThis(CORO_PARAM, bool &result); // Overloaded Draw - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Overloaded priority: it's based on Z ordering virtual int Priority() { @@ -460,7 +460,7 @@ public: void DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc); // Overloaded draw - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // TRUE if you just stopped bool EndOfPath() { @@ -510,7 +510,7 @@ public: virtual ~RMWipe(); void DoFrame(RMGfxTargetBuffer &bigBuf); - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); void InitFade(int type); void CloseFade(void); @@ -566,7 +566,7 @@ public: void Unload(void); // Overloaded draw - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Prepare a frame by drawing the location and all it's items void DoFrame(RMGfxTargetBuffer *bigBuf); diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 98171b2544..cc323eb5d2 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -104,14 +104,14 @@ Common::ErrorCode TonyEngine::init() { _startTime = g_system->getMillis(); // Init static class fields - RMText::InitStatics(); - RMTony::InitStatics(); + RMText::initStatics(); + RMTony::initStatics(); // Reset the scheduler CoroScheduler.reset(); // Initialise the graphics window - _window.Init(); + _window.init(); // Initialise the function list Common::fill(_funcList, _funcList + 300, (LPCUSTOMFUNCTION)NULL); diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index 419f5a251f..f135cff7c3 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -40,7 +40,7 @@ namespace Tony { bool RMTony::m_bAction = false; -void RMTony::InitStatics() { +void RMTony::initStatics() { m_bAction = false; } @@ -82,13 +82,13 @@ RMGfxSourceBuffer *RMTony::NewItemSpriteBuffer(int dimx, int dimy, bool bPreRLE) assert(m_cm == CM_256); spr = new RMGfxSourceBuffer8RLEByteAA; - spr->SetAlphaBlendColor(1); + spr->setAlphaBlendColor(1); if (bPreRLE) - spr->SetAlreadyCompressed(); + spr->setAlreadyCompressed(); return spr; } -void RMTony::Init(void) { +void RMTony::init(void) { RMRes tony(0); RMRes body(9999); RMDataStream ds; @@ -125,7 +125,7 @@ void RMTony::Init(void) { void RMTony::Close(void) { // Disalloca @@@ Deallocation of missing item - m_ombra.Destroy(); + m_ombra.destroy(); } void RMTony::DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int curLoc) { @@ -135,8 +135,8 @@ void RMTony::DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int curLoc) { CORO_BEGIN_CODE(_ctx); - if (!m_nInList && m_bShow) - bigBuf->AddPrim(new RMGfxPrimitive(this)); + if (!_nInList && m_bShow) + bigBuf->addPrim(new RMGfxPrimitive(this)); SetSpeed(GLOBALS.nCfgTonySpeed); @@ -172,7 +172,7 @@ void RMTony::Hide(bool bShowOmbra) { } -void RMTony::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { +void RMTony::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); @@ -185,7 +185,7 @@ void RMTony::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { prim->Dst().Offset(-44, -134); if (m_bPastorella) prim->Dst().Offset(1, 4); - CORO_INVOKE_2(RMCharacter::Draw, bigBuf, prim); + CORO_INVOKE_2(RMCharacter::draw, bigBuf, prim); } if (m_bIsTalking || m_bIsStaticTalk) { @@ -195,7 +195,7 @@ void RMTony::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { prim->Dst().Offset(m_pos); prim->Dst().Offset(-44, -134); prim->Dst() += m_nBodyOffset; - CORO_INVOKE_2(m_body.Draw, bigBuf, prim); + CORO_INVOKE_2(m_body.draw, bigBuf, prim); } if (!m_bCorpoDavanti) { @@ -203,7 +203,7 @@ void RMTony::Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { prim->Dst().Offset(-44, -134); if (m_bPastorella) prim->Dst().Offset(0, 3); - CORO_INVOKE_2(RMCharacter::Draw, bigBuf, prim); + CORO_INVOKE_2(RMCharacter::draw, bigBuf, prim); } } diff --git a/engines/tony/tonychar.h b/engines/tony/tonychar.h index a1c7fc152b..e7b4227fc5 100644 --- a/engines/tony/tonychar.h +++ b/engines/tony/tonychar.h @@ -358,11 +358,11 @@ public: }; public: - static void InitStatics(); + static void initStatics(); RMTony(); // Initialise Tony - void Init(void); + void init(void); // Free all memory void Close(void); @@ -371,7 +371,7 @@ public: void DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int curLoc); // Draw method, which controls chararacter display - virtual void Draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); + virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Show or hide void Show(void); diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index 6b61d25ea2..5d73443167 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -51,7 +51,7 @@ RMWindow::~RMWindow() { /** * Initialises the graphics window */ -void RMWindow::Init() { +void RMWindow::init() { Graphics::PixelFormat pixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0); initGraphics(RM_SX, RM_SY, true, &pixelFormat); diff --git a/engines/tony/window.h b/engines/tony/window.h index 0f614fca97..70e74eb54d 100644 --- a/engines/tony/window.h +++ b/engines/tony/window.h @@ -79,8 +79,8 @@ public: ~RMWindow(); // Initialisation - void Init(/*HINSTANCE hInst*/); - void InitDirectDraw(void); + void init(/*HINSTANCE hInst*/); + void initDirectDraw(void); void Close(void); // Drawing -- cgit v1.2.3 From 380c86fd4073415ee485c244383cc15d3b45b703 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 5 Jun 2012 18:51:20 +0200 Subject: TONY: Some renaming --- engines/tony/font.cpp | 6 +++--- engines/tony/font.h | 8 ++++---- engines/tony/game.cpp | 8 ++++---- engines/tony/game.h | 8 ++++---- engines/tony/gfxcore.cpp | 2 +- engines/tony/gfxcore.h | 2 +- engines/tony/inventory.cpp | 2 +- engines/tony/inventory.h | 2 +- engines/tony/loc.cpp | 10 +++++----- engines/tony/loc.h | 10 +++++----- 10 files changed, 29 insertions(+), 29 deletions(-) (limited to 'engines') diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 16cf4497fc..47cdcb56b5 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -1798,7 +1798,7 @@ void RMText::SetMaxLineLength(int max) { maxLineLength = max; } -void RMText::RemoveThis(CORO_PARAM, bool &result) { +void RMText::removeThis(CORO_PARAM, bool &result) { // Here we can do checks on the number of frames, time spent, etc. result = true; } @@ -2064,7 +2064,7 @@ void RMTextDialog::SetAlwaysDisplay(void) { m_bAlwaysDisplay = true; } -void RMTextDialog::RemoveThis(CORO_PARAM, bool &result) { +void RMTextDialog::removeThis(CORO_PARAM, bool &result) { CORO_BEGIN_CONTEXT; bool expired; CORO_END_CONTEXT(_ctx); @@ -2554,7 +2554,7 @@ void RMDialogChoice::Hide(CORO_PARAM) { } -void RMDialogChoice::RemoveThis(CORO_PARAM, bool &result) { +void RMDialogChoice::removeThis(CORO_PARAM, bool &result) { result = bRemoveFromOT; } diff --git a/engines/tony/font.h b/engines/tony/font.h index 0faaec89d4..752f142cf1 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -220,7 +220,7 @@ public: void WriteText(const RMString &text, RMFontColor *font, int *time = NULL); // Overloaded function to decide when you delete the object from the OT list - virtual void RemoveThis(CORO_PARAM, bool &result); + virtual void removeThis(CORO_PARAM, bool &result); // Overloading of the Draw to center the text, if necessary virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); @@ -261,7 +261,7 @@ public: void WriteText(const RMString &text, RMFontColor *font, int *time = NULL); // Overloaded function to decide when you delete the object from the OT list - virtual void RemoveThis(CORO_PARAM, bool &result); + virtual void removeThis(CORO_PARAM, bool &result); // Overloaded de-registration virtual void Unregister(void); @@ -334,7 +334,7 @@ public: bool IsItemSelected(); bool IsNormalItemSelected(); - virtual void RemoveThis(CORO_PARAM, bool &result) { + virtual void removeThis(CORO_PARAM, bool &result) { result = true; } }; @@ -362,7 +362,7 @@ protected: void SetSelected(CORO_PARAM, int pos); public: - virtual void RemoveThis(CORO_PARAM, bool &result); + virtual void removeThis(CORO_PARAM, bool &result); virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); void Unregister(void); diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index c22706cc6d..5f8f238bff 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -995,7 +995,7 @@ bool RMOptionScreen::IsClosing(void) { return m_bExit; } -int RMOptionScreen::Priority() { +int RMOptionScreen::priority() { // Just below the mouse return 190; } @@ -1375,7 +1375,7 @@ void RMOptionScreen::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive CORO_END_CODE; } -void RMOptionScreen::RemoveThis(CORO_PARAM, bool &result) { +void RMOptionScreen::removeThis(CORO_PARAM, bool &result) { if (m_bExit) result = true; else @@ -1523,7 +1523,7 @@ void RMPointer::Close(void) { } -int RMPointer::Priority() { +int RMPointer::priority() { // Pointer has minimum priority so it will be drawn last return 200; } @@ -1569,7 +1569,7 @@ void RMPointer::DoFrame(RMGfxTargetBuffer *bigBuf) { m_specialPointer[m_nCurSpecialPointer - 1]->DoFrame(bigBuf, false); } -void RMPointer::RemoveThis(CORO_PARAM, bool &result) { +void RMPointer::removeThis(CORO_PARAM, bool &result) { // Always remove from the OT list, to support disabling the pointer result = true; } diff --git a/engines/tony/game.h b/engines/tony/game.h index d42a3805c8..5dbd81c079 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -93,7 +93,7 @@ public: void DoFrame(RMGfxTargetBuffer *bigBuf); // Overloading of priorities - int Priority(); + int priority(); // Overloading draw method virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); @@ -104,7 +104,7 @@ public: } // Overloading of the method to see if rising from the list - virtual void RemoveThis(CORO_PARAM, bool &result); + virtual void removeThis(CORO_PARAM, bool &result); // Sets a new action as current void SetAction(RMTonyAction action) { @@ -272,9 +272,9 @@ public: bool IsClosing(); // Overloaded methods - virtual int Priority(); + virtual int priority(); virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - virtual void RemoveThis(CORO_PARAM, bool &result); + virtual void removeThis(CORO_PARAM, bool &result); // Polling for the option screen void DoFrame(CORO_PARAM, RMInput *m_input); diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 2076e2af47..6369d91207 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -1945,7 +1945,7 @@ void RMGfxBox::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) * RMGfxClearTask Methods \****************************************************************************/ -int RMGfxClearTask::Priority() { +int RMGfxClearTask::priority() { // Maximum priority (must be done first) return 1; } diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index 51d27b7311..2daa7edc6d 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -257,7 +257,7 @@ class RMGfxClearTask : public RMGfxTask { public: virtual ~RMGfxClearTask() { } - int Priority(); + int priority(); virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); virtual void removeThis(CORO_PARAM, bool &result); }; diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index 9b8f346aaf..a660ad736e 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -231,7 +231,7 @@ void RMInventory::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr CORO_END_CODE; } -void RMInventory::RemoveThis(CORO_PARAM, bool &result) { +void RMInventory::removeThis(CORO_PARAM, bool &result) { if (m_state == CLOSED) result = true; else diff --git a/engines/tony/inventory.h b/engines/tony/inventory.h index 87ccaa33b4..9ed250592d 100644 --- a/engines/tony/inventory.h +++ b/engines/tony/inventory.h @@ -98,7 +98,7 @@ public: void Reset(void); // Overload test for removal from OT list - virtual void RemoveThis(CORO_PARAM, bool &result); + virtual void removeThis(CORO_PARAM, bool &result); // Overload the drawing of the inventory virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 1a7933a03d..6ede99b57d 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -715,7 +715,7 @@ void RMItem::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { } -void RMItem::RemoveThis(CORO_PARAM, bool &result) { +void RMItem::removeThis(CORO_PARAM, bool &result) { // Remove from the OT list if the current frame is -1 (pattern over) result = (m_nCurSprite == -1); } @@ -861,7 +861,7 @@ RMWipe::~RMWipe() { CoroScheduler.closeEvent(m_hEndOfFade); } -int RMWipe::Priority(void) { +int RMWipe::priority(void) { return 200; } @@ -871,7 +871,7 @@ void RMWipe::Unregister(void) { CoroScheduler.setEvent(m_hUnregistered); } -void RMWipe::RemoveThis(CORO_PARAM, bool &result) { +void RMWipe::removeThis(CORO_PARAM, bool &result) { result = m_bUnregister; } @@ -1657,7 +1657,7 @@ void RMCharacter::WaitForEndMovement(CORO_PARAM) { CORO_END_CODE; } -void RMCharacter::RemoveThis(CORO_PARAM, bool &result) { +void RMCharacter::removeThis(CORO_PARAM, bool &result) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); @@ -1666,7 +1666,7 @@ void RMCharacter::RemoveThis(CORO_PARAM, bool &result) { if (bRemoveFromOT) result = true; else - CORO_INVOKE_1(RMItem::RemoveThis, result); + CORO_INVOKE_1(RMItem::removeThis, result); CORO_END_CODE; } diff --git a/engines/tony/loc.h b/engines/tony/loc.h index c11dac4782..282ea0fa4a 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -251,13 +251,13 @@ public: void SetScrollPosition(const RMPoint &scroll); // Overloading of check whether to remove from active list - virtual void RemoveThis(CORO_PARAM, bool &result); + virtual void removeThis(CORO_PARAM, bool &result); // Overloaded Draw virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Overloaded priority: it's based on Z ordering - virtual int Priority() { + virtual int priority() { return m_z; } @@ -454,7 +454,7 @@ public: void LinkToBoxes(RMGameBoxes *theBoxes); - virtual void RemoveThis(CORO_PARAM, bool &result); + virtual void removeThis(CORO_PARAM, bool &result); // Update the position of a character void DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc); @@ -517,8 +517,8 @@ public: void WaitForFadeEnd(CORO_PARAM); virtual void Unregister(void); - virtual void RemoveThis(CORO_PARAM, bool &result); - virtual int Priority(void); + virtual void removeThis(CORO_PARAM, bool &result); + virtual int priority(void); }; -- cgit v1.2.3 From 334dc91e279d01b264ae7454f39faa557a250428 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 6 Jun 2012 01:37:06 +0200 Subject: TONY: Rename variables and functions in game.h --- engines/tony/custom.cpp | 14 +- engines/tony/detection.cpp | 4 +- engines/tony/font.cpp | 4 +- engines/tony/game.cpp | 1444 ++++++++++++++++++++++---------------------- engines/tony/game.h | 236 ++++---- engines/tony/gfxengine.cpp | 60 +- engines/tony/inventory.cpp | 14 +- engines/tony/loc.cpp | 10 +- engines/tony/loc.h | 4 +- engines/tony/tonychar.cpp | 2 +- 10 files changed, 898 insertions(+), 894 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 8092109ef5..24caaa1e29 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -209,23 +209,23 @@ DECLARE_CUSTOM_FUNCTION(SetAlwaysDisplay)(CORO_PARAM, uint32 val, uint32, uint32 DECLARE_CUSTOM_FUNCTION(SetPointer)(CORO_PARAM, uint32 dwPointer, uint32, uint32, uint32) { switch (dwPointer) { case 1: - GLOBALS.Pointer->SetSpecialPointer(GLOBALS.Pointer->PTR_FRECCIASU); + GLOBALS.Pointer->setSpecialPointer(GLOBALS.Pointer->PTR_FRECCIASU); break; case 2: - GLOBALS.Pointer->SetSpecialPointer(GLOBALS.Pointer->PTR_FRECCIAGIU); + GLOBALS.Pointer->setSpecialPointer(GLOBALS.Pointer->PTR_FRECCIAGIU); break; case 3: - GLOBALS.Pointer->SetSpecialPointer(GLOBALS.Pointer->PTR_FRECCIASINISTRA); + GLOBALS.Pointer->setSpecialPointer(GLOBALS.Pointer->PTR_FRECCIASINISTRA); break; case 4: - GLOBALS.Pointer->SetSpecialPointer(GLOBALS.Pointer->PTR_FRECCIADESTRA); + GLOBALS.Pointer->setSpecialPointer(GLOBALS.Pointer->PTR_FRECCIADESTRA); break; case 5: - GLOBALS.Pointer->SetSpecialPointer(GLOBALS.Pointer->PTR_FRECCIAMAPPA); + GLOBALS.Pointer->setSpecialPointer(GLOBALS.Pointer->PTR_FRECCIAMAPPA); break; default: - GLOBALS.Pointer->SetSpecialPointer(GLOBALS.Pointer->PTR_NONE); + GLOBALS.Pointer->setSpecialPointer(GLOBALS.Pointer->PTR_NONE); break; } } @@ -2014,7 +2014,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr CORO_INVOKE_0(_ctx->dc.Show); // Draw the pointer - GLOBALS.Pointer->SetSpecialPointer(GLOBALS.Pointer->PTR_NONE); + GLOBALS.Pointer->setSpecialPointer(GLOBALS.Pointer->PTR_NONE); mainShowMouse(); while (!(GLOBALS.Input->mouseLeftClicked() && ((_ctx->sel = _ctx->dc.GetSelection()) != -1))) { diff --git a/engines/tony/detection.cpp b/engines/tony/detection.cpp index be45aba19f..c408da3f24 100644 --- a/engines/tony/detection.cpp +++ b/engines/tony/detection.cpp @@ -131,7 +131,7 @@ SaveStateList TonyMetaEngine::listSaves(const char *target) const { Tony::RMString saveName; byte difficulty; - if (Tony::RMOptionScreen::LoadThumbnailFromSaveState(slotNum, thumbnailData, saveName, difficulty)) { + if (Tony::RMOptionScreen::loadThumbnailFromSaveState(slotNum, thumbnailData, saveName, difficulty)) { // Add the save name to the savegame list saveList.push_back(SaveStateDescriptor(slotNum, (const char *)saveName)); } @@ -156,7 +156,7 @@ SaveStateDescriptor TonyMetaEngine::querySaveMetaInfos(const char *target, int s byte difficulty; byte thumbData[160 * 120 * 2]; - if (Tony::RMOptionScreen::LoadThumbnailFromSaveState(slot, thumbData, saveName, difficulty)) { + if (Tony::RMOptionScreen::loadThumbnailFromSaveState(slot, thumbData, saveName, difficulty)) { // Convert the 565 thumbnail data to the needed overlay format Common::MemoryReadStream thumbStream(thumbData, 160 * 120 * 2); Graphics::PixelFormat destFormat = g_system->getOverlayFormat(); diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 47cdcb56b5..e0eca3b4e2 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -2261,11 +2261,11 @@ void RMTextItemName::DoFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation & // Handle the change If the selected item is different from the previous one if (_ctx->lastItem != m_item) { if (m_item == NULL) - ptr.SetSpecialPointer(RMPointer::PTR_NONE); + ptr.setSpecialPointer(RMPointer::PTR_NONE); else { _ctx->hThread = mpalQueryDoAction(20, m_item->MpalCode(), 0); if (_ctx->hThread == CORO_INVALID_PID_VALUE) - ptr.SetSpecialPointer(RMPointer::PTR_NONE); + ptr.setSpecialPointer(RMPointer::PTR_NONE); else CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->hThread, CORO_INFINITE); } diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 5f8f238bff..c729a4e8c0 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -125,44 +125,44 @@ void mainSetPalesati(bool bPalesati) { RMOptionButton::RMOptionButton(uint32 dwRes, RMPoint pt, bool bDoubleState) { RMResRaw raw(dwRes); assert(raw.IsValid()); - m_buf = new RMGfxSourceBuffer16(false); - m_buf->init(raw, raw.Width(), raw.Height()); + _buf = new RMGfxSourceBuffer16(false); + _buf->init(raw, raw.Width(), raw.Height()); - m_rect.SetRect(pt.x, pt.y, pt.x + raw.Width() - 1, pt.y + raw.Height() - 1); - m_bActive = false; - m_bHasGfx = true; - m_bDoubleState = bDoubleState; + _rect.SetRect(pt.x, pt.y, pt.x + raw.Width() - 1, pt.y + raw.Height() - 1); + _bActive = false; + _bHasGfx = true; + _bDoubleState = bDoubleState; } RMOptionButton::RMOptionButton(const RMRect &pt) { - m_rect = pt; - m_bActive = false; - m_bHasGfx = false; - m_bDoubleState = false; - m_buf = NULL; + _rect = pt; + _bActive = false; + _bHasGfx = false; + _bDoubleState = false; + _buf = NULL; } RMOptionButton::~RMOptionButton() { - if (m_bHasGfx) - delete m_buf; + if (_bHasGfx) + delete _buf; } -bool RMOptionButton::DoFrame(const RMPoint &mousePos, bool bLeftClick, bool bRightClick) { - if (!m_bDoubleState) { - if (m_rect.PtInRect(mousePos)) { - if (!m_bActive) { - m_bActive = true; +bool RMOptionButton::doFrame(const RMPoint &mousePos, bool bLeftClick, bool bRightClick) { + if (!_bDoubleState) { + if (_rect.PtInRect(mousePos)) { + if (!_bActive) { + _bActive = true; return true; } } else { - if (m_bActive) { - m_bActive = false; + if (_bActive) { + _bActive = false; return true; } } } else { - if (bLeftClick && m_rect.PtInRect(mousePos)) { - m_bActive = !m_bActive; + if (bLeftClick && _rect.PtInRect(mousePos)) { + _bActive = !_bActive; return true; } } @@ -176,18 +176,18 @@ void RMOptionButton::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive CORO_BEGIN_CODE(_ctx); - if (!m_bActive) + if (!_bActive) return; - if (m_bHasGfx) - CORO_INVOKE_2(m_buf->draw, bigBuf, prim); + if (_bHasGfx) + CORO_INVOKE_2(_buf->draw, bigBuf, prim); CORO_END_CODE; } -void RMOptionButton::AddToList(RMGfxTargetBuffer &bigBuf) { - if (m_bHasGfx) - bigBuf.addPrim(new RMGfxPrimitive(this, m_rect)); +void RMOptionButton::addToList(RMGfxTargetBuffer &bigBuf) { + if (_bHasGfx) + bigBuf.addPrim(new RMGfxPrimitive(this, _rect)); } /****************************************************************************\ @@ -197,74 +197,74 @@ void RMOptionButton::AddToList(RMGfxTargetBuffer &bigBuf) { RMOptionSlide::RMOptionSlide(const RMPoint &pt, int nRange, int nStartValue, int slideSize) { RMResRaw *raw; - m_pos = pt; - m_nSlideSize = slideSize; - m_nMax = nRange; - m_nStep = 100 / m_nMax; - m_nValue = nStartValue; + _pos = pt; + _nSlideSize = slideSize; + _nMax = nRange; + _nStep = 100 / _nMax; + _nValue = nStartValue; - m_SliderCenter = NULL; - m_SliderLeft = NULL; - m_SliderRight = NULL; - m_SliderSingle = NULL; + _SliderCenter = NULL; + _SliderLeft = NULL; + _SliderRight = NULL; + _SliderSingle = NULL; // Sliders - INIT_GFX16_FROMRAW(20029, m_SliderCenter); - INIT_GFX16_FROMRAW(20030, m_SliderLeft); - INIT_GFX16_FROMRAW(20031, m_SliderRight); - INIT_GFX16_FROMRAW(20032, m_SliderSingle); + INIT_GFX16_FROMRAW(20029, _SliderCenter); + INIT_GFX16_FROMRAW(20030, _SliderLeft); + INIT_GFX16_FROMRAW(20031, _SliderRight); + INIT_GFX16_FROMRAW(20032, _SliderSingle); // Buttons - m_PushLeft = new RMOptionButton(RMRect(pt.x - 23, pt.y, pt.x - 23 + 22, pt.y + 26)); - m_PushRight = new RMOptionButton(RMRect(pt.x + m_nSlideSize, pt.y, pt.x + m_nSlideSize + 5 + 22, pt.y + 26)); + _PushLeft = new RMOptionButton(RMRect(pt.x - 23, pt.y, pt.x - 23 + 22, pt.y + 26)); + _PushRight = new RMOptionButton(RMRect(pt.x + _nSlideSize, pt.y, pt.x + _nSlideSize + 5 + 22, pt.y + 26)); } RMOptionSlide::~RMOptionSlide() { - delete m_SliderCenter; - m_SliderCenter = NULL; - delete m_SliderLeft; - m_SliderLeft = NULL; - delete m_SliderRight; - m_SliderRight = NULL; - delete m_SliderSingle; - m_SliderSingle = NULL; - - delete m_PushLeft; - m_PushLeft = NULL; - delete m_PushRight; - m_PushRight = NULL; + delete _SliderCenter; + _SliderCenter = NULL; + delete _SliderLeft; + _SliderLeft = NULL; + delete _SliderRight; + _SliderRight = NULL; + delete _SliderSingle; + _SliderSingle = NULL; + + delete _PushLeft; + _PushLeft = NULL; + delete _PushRight; + _PushRight = NULL; } -bool RMOptionSlide::DoFrame(const RMPoint &mousePos, bool bLeftClick, bool bRightClick) { +bool RMOptionSlide::doFrame(const RMPoint &mousePos, bool bLeftClick, bool bRightClick) { bool bRefresh = false; // Do the button DoFrame's - m_PushLeft->DoFrame(mousePos, bLeftClick, bRightClick); - m_PushRight->DoFrame(mousePos, bLeftClick, bRightClick); + _PushLeft->doFrame(mousePos, bLeftClick, bRightClick); + _PushRight->doFrame(mousePos, bLeftClick, bRightClick); - if (m_PushLeft->IsActive()) { + if (_PushLeft->isActive()) { if (bLeftClick) { bRefresh = true; - m_nValue--; + _nValue--; } else if (bRightClick) { bRefresh = true; - m_nValue -= 3; + _nValue -= 3; } - if (m_nValue < 1) - m_nValue = 1; - } else if (m_PushRight->IsActive()) { + if (_nValue < 1) + _nValue = 1; + } else if (_PushRight->isActive()) { bRefresh = true; if (bLeftClick) { bRefresh = true; - m_nValue++; + _nValue++; } else if (bRightClick) { bRefresh = true; - m_nValue += 3; + _nValue += 3; } - if (m_nValue > m_nMax) - m_nValue = m_nMax; + if (_nValue > _nMax) + _nValue = _nMax; } return bRefresh; @@ -279,37 +279,39 @@ void RMOptionSlide::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive * CORO_BEGIN_CODE(_ctx); - _ctx->pos = m_pos; + _ctx->pos = _pos; _ctx->pos.x += 4; _ctx->pos.y += 4; - _ctx->val = m_nValue * m_nStep; - if (_ctx->val < 1) _ctx->val = 1; - else if (_ctx->val > 100) _ctx->val = 100; + _ctx->val = _nValue * _nStep; + if (_ctx->val < 1) + _ctx->val = 1; + else if (_ctx->val > 100) + _ctx->val = 100; if (_ctx->val == 1) { prim->setDst(_ctx->pos); - CORO_INVOKE_2(m_SliderSingle->draw, bigBuf, prim); + CORO_INVOKE_2(_SliderSingle->draw, bigBuf, prim); } else { prim->setDst(_ctx->pos); - CORO_INVOKE_2(m_SliderLeft->draw, bigBuf, prim); + CORO_INVOKE_2(_SliderLeft->draw, bigBuf, prim); _ctx->pos.x += 3; for (_ctx->i = 1; _ctx->i < _ctx->val - 1; _ctx->i++) { prim->setDst(_ctx->pos); - CORO_INVOKE_2(m_SliderCenter->draw, bigBuf, prim); + CORO_INVOKE_2(_SliderCenter->draw, bigBuf, prim); _ctx->pos.x += 3; } prim->setDst(_ctx->pos); - CORO_INVOKE_2(m_SliderRight->draw, bigBuf, prim); + CORO_INVOKE_2(_SliderRight->draw, bigBuf, prim); _ctx->pos.x += 3; } CORO_END_CODE; } -void RMOptionSlide::AddToList(RMGfxTargetBuffer &bigBuf) { +void RMOptionSlide::addToList(RMGfxTargetBuffer &bigBuf) { bigBuf.addPrim(new RMGfxPrimitive(this)); } @@ -320,68 +322,68 @@ void RMOptionSlide::AddToList(RMGfxTargetBuffer &bigBuf) { \****************************************************************************/ RMOptionScreen::RMOptionScreen(void) { - m_nState = MENUNONE; - m_menu = NULL; - m_HideLoadSave = NULL; - m_QuitConfirm = NULL; - m_bQuitConfirm = false; + _nState = MENUNONE; + _menu = NULL; + _HideLoadSave = NULL; + _QuitConfirm = NULL; + _bQuitConfirm = false; Create(RM_SX, RM_SY); - m_ButtonExit = NULL; - m_ButtonLoad = NULL; - m_ButtonSave = NULL; - m_ButtonGameMenu = NULL; - m_ButtonGfxMenu = NULL; - m_ButtonSoundMenu = NULL; - m_ButtonSave_ArrowLeft = NULL; - m_ButtonSave_ArrowRight = NULL; - m_bEditSaveName = false; + _ButtonExit = NULL; + _ButtonLoad = NULL; + _ButtonSave = NULL; + _ButtonGameMenu = NULL; + _ButtonGfxMenu = NULL; + _ButtonSoundMenu = NULL; + _ButtonSave_ArrowLeft = NULL; + _ButtonSave_ArrowRight = NULL; + _bEditSaveName = false; int i; for (i = 0; i < 6; i++) { - m_curThumb[i] = NULL; - m_ButtonSave_States[i] = NULL; + _curThumb[i] = NULL; + _ButtonSave_States[i] = NULL; } - m_statePos = 0; - m_ButtonQuitYes = NULL; - m_ButtonQuitNo = NULL; - m_ButtonQuit = NULL; - m_SaveEasy = NULL; - m_SaveHard = NULL; - m_ButtonGfx_Tips = NULL; - m_ButtonSound_DubbingOn = NULL; - m_ButtonSound_MusicOn = NULL; - m_ButtonSound_SFXOn = NULL; - m_SlideTonySpeed = NULL; - m_SlideTextSpeed = NULL; - m_ButtonGame_Lock = NULL; - m_ButtonGfx_Anni30 = NULL; - m_SliderSound_Music = NULL; - m_ButtonGame_TimerizedText = NULL; - m_ButtonGfx_AntiAlias = NULL; - m_SliderSound_SFX = NULL; - m_ButtonGame_Scrolling = NULL; - m_ButtonGfx_Sottotitoli = NULL; - m_SliderSound_Dubbing = NULL; - m_ButtonGame_InterUp = NULL; - m_ButtonGfx_Trans = NULL; - - m_FadeStep = 0; - m_FadeY = 0; - m_FadeTime = 0; - m_nEditPos = 0; - m_nLastState = MENUGAME; + _statePos = 0; + _ButtonQuitYes = NULL; + _ButtonQuitNo = NULL; + _ButtonQuit = NULL; + _SaveEasy = NULL; + _SaveHard = NULL; + _ButtonGfx_Tips = NULL; + _ButtonSound_DubbingOn = NULL; + _ButtonSound_MusicOn = NULL; + _ButtonSound_SFXOn = NULL; + _SlideTonySpeed = NULL; + _SlideTextSpeed = NULL; + _ButtonGame_Lock = NULL; + _ButtonGfx_Anni30 = NULL; + _SliderSound_Music = NULL; + _ButtonGame_TimerizedText = NULL; + _ButtonGfx_AntiAlias = NULL; + _SliderSound_SFX = NULL; + _ButtonGame_Scrolling = NULL; + _ButtonGfx_Sottotitoli = NULL; + _SliderSound_Dubbing = NULL; + _ButtonGame_InterUp = NULL; + _ButtonGfx_Trans = NULL; + + _FadeStep = 0; + _FadeY = 0; + _FadeTime = 0; + _nEditPos = 0; + _nLastState = MENUGAME; } RMOptionScreen::~RMOptionScreen(void) { - CloseState(); + closeState(); } -void RMOptionScreen::RefreshAll(CORO_PARAM) { +void RMOptionScreen::refreshAll(CORO_PARAM) { CORO_BEGIN_CONTEXT; RMGfxSourceBuffer16 *thumb; RMText *title; @@ -392,54 +394,54 @@ void RMOptionScreen::RefreshAll(CORO_PARAM) { CORO_BEGIN_CODE(_ctx); clearOT(); - addPrim(new RMGfxPrimitive(m_menu)); + addPrim(new RMGfxPrimitive(_menu)); - if (m_bNoLoadSave) - addPrim(new RMGfxPrimitive(m_HideLoadSave, RMPoint(0, 401))); + if (_bNoLoadSave) + addPrim(new RMGfxPrimitive(_HideLoadSave, RMPoint(0, 401))); - if (m_bQuitConfirm) { - addPrim(new RMGfxPrimitive(m_QuitConfirm, RMPoint(270, 200))); - m_ButtonQuitYes->AddToList(*this); - m_ButtonQuitNo->AddToList(*this); + if (_bQuitConfirm) { + addPrim(new RMGfxPrimitive(_QuitConfirm, RMPoint(270, 200))); + _ButtonQuitYes->addToList(*this); + _ButtonQuitNo->addToList(*this); } - m_ButtonExit->AddToList(*this); + _ButtonExit->addToList(*this); - if (m_nState == MENUGAME || m_nState == MENUGFX || m_nState == MENUSOUND) { - m_ButtonQuit->AddToList(*this); - m_ButtonLoad->AddToList(*this); - m_ButtonSave->AddToList(*this); + if (_nState == MENUGAME || _nState == MENUGFX || _nState == MENUSOUND) { + _ButtonQuit->addToList(*this); + _ButtonLoad->addToList(*this); + _ButtonSave->addToList(*this); } - if (m_nState == MENUGAME) { - m_ButtonGame_Lock->AddToList(*this); - m_ButtonGame_TimerizedText->AddToList(*this); - m_ButtonGame_Scrolling->AddToList(*this); - m_ButtonGame_InterUp->AddToList(*this); - m_SlideTextSpeed->AddToList(*this); - m_SlideTonySpeed->AddToList(*this); - } else if (m_nState == MENUGFX) { - m_ButtonGfx_Anni30->AddToList(*this); - m_ButtonGfx_AntiAlias->AddToList(*this); - m_ButtonGfx_Sottotitoli->AddToList(*this); - m_ButtonGfx_Trans->AddToList(*this); - m_ButtonGfx_Tips->AddToList(*this); - } else if (m_nState == MENUSOUND) { - m_SliderSound_Dubbing->AddToList(*this); - m_SliderSound_Music->AddToList(*this); - m_SliderSound_SFX->AddToList(*this); - m_ButtonSound_DubbingOn->AddToList(*this); - m_ButtonSound_MusicOn->AddToList(*this); - m_ButtonSound_SFXOn->AddToList(*this); + if (_nState == MENUGAME) { + _ButtonGame_Lock->addToList(*this); + _ButtonGame_TimerizedText->addToList(*this); + _ButtonGame_Scrolling->addToList(*this); + _ButtonGame_InterUp->addToList(*this); + _SlideTextSpeed->addToList(*this); + _SlideTonySpeed->addToList(*this); + } else if (_nState == MENUGFX) { + _ButtonGfx_Anni30->addToList(*this); + _ButtonGfx_AntiAlias->addToList(*this); + _ButtonGfx_Sottotitoli->addToList(*this); + _ButtonGfx_Trans->addToList(*this); + _ButtonGfx_Tips->addToList(*this); + } else if (_nState == MENUSOUND) { + _SliderSound_Dubbing->addToList(*this); + _SliderSound_Music->addToList(*this); + _SliderSound_SFX->addToList(*this); + _ButtonSound_DubbingOn->addToList(*this); + _ButtonSound_MusicOn->addToList(*this); + _ButtonSound_SFXOn->addToList(*this); } _ctx->thumb = NULL; _ctx->title = NULL; Common::fill(&_ctx->num[0], &_ctx->num[6], (RMText *)NULL); - if (m_nState == MENULOAD || m_nState == MENUSAVE) { + if (_nState == MENULOAD || _nState == MENUSAVE) { _ctx->title = new RMText; - if (m_nState == MENULOAD) { + if (_nState == MENULOAD) { RMMessage msg(10); _ctx->title->WriteText(msg[0], 1); } else { @@ -449,72 +451,72 @@ void RMOptionScreen::RefreshAll(CORO_PARAM) { addPrim(new RMGfxPrimitive(_ctx->title, RMPoint(320, 10))); - if (m_curThumbDiff[0] == 0) - addPrim(new RMGfxPrimitive(m_SaveHard, RMPoint(48, 57))); - else if (m_curThumbDiff[0] == 1) - addPrim(new RMGfxPrimitive(m_SaveEasy, RMPoint(48, 57))); - if (m_curThumbDiff[1] == 0) - addPrim(new RMGfxPrimitive(m_SaveHard, RMPoint(240, 57))); - else if (m_curThumbDiff[1] == 1) - addPrim(new RMGfxPrimitive(m_SaveEasy, RMPoint(240, 57))); - if (m_curThumbDiff[2] == 0) - addPrim(new RMGfxPrimitive(m_SaveHard, RMPoint(432, 57))); - else if (m_curThumbDiff[2] == 1) - addPrim(new RMGfxPrimitive(m_SaveEasy, RMPoint(432, 57))); - if (m_curThumbDiff[3] == 0) - addPrim(new RMGfxPrimitive(m_SaveHard, RMPoint(48, 239))); - else if (m_curThumbDiff[3] == 1) - addPrim(new RMGfxPrimitive(m_SaveEasy, RMPoint(48, 239))); - if (m_curThumbDiff[4] == 0) - addPrim(new RMGfxPrimitive(m_SaveHard, RMPoint(240, 239))); - else if (m_curThumbDiff[4] == 1) - addPrim(new RMGfxPrimitive(m_SaveEasy, RMPoint(240, 239))); - if (m_curThumbDiff[5] == 0) - addPrim(new RMGfxPrimitive(m_SaveHard, RMPoint(432, 239))); - else if (m_curThumbDiff[5] == 1) - addPrim(new RMGfxPrimitive(m_SaveEasy, RMPoint(432, 239))); - - if (m_curThumb[0] && !(m_bEditSaveName && m_nEditPos == 0)) - addPrim(new RMGfxPrimitive(m_curThumb[0], RMPoint(48, 57))); - if (m_curThumb[1] && !(m_bEditSaveName && m_nEditPos == 1)) - addPrim(new RMGfxPrimitive(m_curThumb[1], RMPoint(240, 57))); - if (m_curThumb[2] && !(m_bEditSaveName && m_nEditPos == 2)) - addPrim(new RMGfxPrimitive(m_curThumb[2], RMPoint(432, 57))); - if (m_curThumb[3] && !(m_bEditSaveName && m_nEditPos == 3)) - addPrim(new RMGfxPrimitive(m_curThumb[3], RMPoint(48, 239))); - if (m_curThumb[4] && !(m_bEditSaveName && m_nEditPos == 4)) - addPrim(new RMGfxPrimitive(m_curThumb[4], RMPoint(240, 239))); - if (m_curThumb[5] && !(m_bEditSaveName && m_nEditPos == 5)) - addPrim(new RMGfxPrimitive(m_curThumb[5], RMPoint(432, 239))); - - if (m_bEditSaveName) { + if (_curThumbDiff[0] == 0) + addPrim(new RMGfxPrimitive(_SaveHard, RMPoint(48, 57))); + else if (_curThumbDiff[0] == 1) + addPrim(new RMGfxPrimitive(_SaveEasy, RMPoint(48, 57))); + if (_curThumbDiff[1] == 0) + addPrim(new RMGfxPrimitive(_SaveHard, RMPoint(240, 57))); + else if (_curThumbDiff[1] == 1) + addPrim(new RMGfxPrimitive(_SaveEasy, RMPoint(240, 57))); + if (_curThumbDiff[2] == 0) + addPrim(new RMGfxPrimitive(_SaveHard, RMPoint(432, 57))); + else if (_curThumbDiff[2] == 1) + addPrim(new RMGfxPrimitive(_SaveEasy, RMPoint(432, 57))); + if (_curThumbDiff[3] == 0) + addPrim(new RMGfxPrimitive(_SaveHard, RMPoint(48, 239))); + else if (_curThumbDiff[3] == 1) + addPrim(new RMGfxPrimitive(_SaveEasy, RMPoint(48, 239))); + if (_curThumbDiff[4] == 0) + addPrim(new RMGfxPrimitive(_SaveHard, RMPoint(240, 239))); + else if (_curThumbDiff[4] == 1) + addPrim(new RMGfxPrimitive(_SaveEasy, RMPoint(240, 239))); + if (_curThumbDiff[5] == 0) + addPrim(new RMGfxPrimitive(_SaveHard, RMPoint(432, 239))); + else if (_curThumbDiff[5] == 1) + addPrim(new RMGfxPrimitive(_SaveEasy, RMPoint(432, 239))); + + if (_curThumb[0] && !(_bEditSaveName && _nEditPos == 0)) + addPrim(new RMGfxPrimitive(_curThumb[0], RMPoint(48, 57))); + if (_curThumb[1] && !(_bEditSaveName && _nEditPos == 1)) + addPrim(new RMGfxPrimitive(_curThumb[1], RMPoint(240, 57))); + if (_curThumb[2] && !(_bEditSaveName && _nEditPos == 2)) + addPrim(new RMGfxPrimitive(_curThumb[2], RMPoint(432, 57))); + if (_curThumb[3] && !(_bEditSaveName && _nEditPos == 3)) + addPrim(new RMGfxPrimitive(_curThumb[3], RMPoint(48, 239))); + if (_curThumb[4] && !(_bEditSaveName && _nEditPos == 4)) + addPrim(new RMGfxPrimitive(_curThumb[4], RMPoint(240, 239))); + if (_curThumb[5] && !(_bEditSaveName && _nEditPos == 5)) + addPrim(new RMGfxPrimitive(_curThumb[5], RMPoint(432, 239))); + + if (_bEditSaveName) { _ctx->thumb = new RMGfxSourceBuffer16; _ctx->thumb->init((byte *)_vm->getThumbnail(), 640 / 4, 480 / 4); - if (m_nEditPos == 0) + if (_nEditPos == 0) addPrim(new RMGfxPrimitive(_ctx->thumb, RMPoint(48, 57))); - else if (m_nEditPos == 1) + else if (_nEditPos == 1) addPrim(new RMGfxPrimitive(_ctx->thumb, RMPoint(240, 57))); - else if (m_nEditPos == 2) + else if (_nEditPos == 2) addPrim(new RMGfxPrimitive(_ctx->thumb, RMPoint(432, 57))); - else if (m_nEditPos == 3) + else if (_nEditPos == 3) addPrim(new RMGfxPrimitive(_ctx->thumb, RMPoint(48, 239))); - else if (m_nEditPos == 4) + else if (_nEditPos == 4) addPrim(new RMGfxPrimitive(_ctx->thumb, RMPoint(240, 239))); - else if (m_nEditPos == 5) + else if (_nEditPos == 5) addPrim(new RMGfxPrimitive(_ctx->thumb, RMPoint(432, 239))); } for (_ctx->i = 0; _ctx->i < 6; _ctx->i++) { RMString s; - if (m_bEditSaveName && m_nEditPos == _ctx->i) - s.Format("%02d)%s*", m_statePos + _ctx->i, m_EditName); + if (_bEditSaveName && _nEditPos == _ctx->i) + s.Format("%02d)%s*", _statePos + _ctx->i, _EditName); else { - if (m_statePos == 0 && _ctx->i == 0) + if (_statePos == 0 && _ctx->i == 0) s.Format("Autosave"); else - s.Format("%02d)%s", m_statePos + _ctx->i, (const char *)m_curThumbName[_ctx->i]); + s.Format("%02d)%s", _statePos + _ctx->i, (const char *)_curThumbName[_ctx->i]); } _ctx->num[_ctx->i] = new RMText; @@ -529,13 +531,13 @@ void RMOptionScreen::RefreshAll(CORO_PARAM) { addPrim(new RMGfxPrimitive(_ctx->num[4], RMPoint(247 - 3, 362 + 14))); addPrim(new RMGfxPrimitive(_ctx->num[5], RMPoint(439 - 3, 362 + 14))); - m_ButtonSave_ArrowLeft->AddToList(*this); - m_ButtonSave_ArrowRight->AddToList(*this); + _ButtonSave_ArrowLeft->addToList(*this); + _ButtonSave_ArrowRight->addToList(*this); } CORO_INVOKE_0(drawOT); - if (m_nState == MENULOAD || m_nState == MENUSAVE) { + if (_nState == MENULOAD || _nState == MENUSAVE) { if (_ctx->thumb) delete _ctx->thumb; if (_ctx->title) delete _ctx->title; @@ -546,36 +548,36 @@ void RMOptionScreen::RefreshAll(CORO_PARAM) { CORO_END_CODE; } -void RMOptionScreen::RefreshThumbnails(void) { +void RMOptionScreen::refreshThumbnails(void) { int i; for (i = 0; i < 6; i++) { - if (m_curThumb[i]) - delete m_curThumb[i]; - - m_curThumb[i] = new RMGfxSourceBuffer16; - m_curThumb[i]->Create(640 / 4, 480 / 4); - if (!LoadThumbnailFromSaveState(m_statePos + i, *m_curThumb[i], m_curThumbName[i], m_curThumbDiff[i])) { - delete m_curThumb[i]; - m_curThumb[i] = NULL; - m_curThumbName[i] = ""; - m_curThumbDiff[i] = 11; + if (_curThumb[i]) + delete _curThumb[i]; + + _curThumb[i] = new RMGfxSourceBuffer16; + _curThumb[i]->Create(640 / 4, 480 / 4); + if (!loadThumbnailFromSaveState(_statePos + i, *_curThumb[i], _curThumbName[i], _curThumbDiff[i])) { + delete _curThumb[i]; + _curThumb[i] = NULL; + _curThumbName[i] = ""; + _curThumbDiff[i] = 11; } } } -void RMOptionScreen::InitState(CORO_PARAM) { +void RMOptionScreen::initState(CORO_PARAM) { CORO_BEGIN_CONTEXT; RMResRaw *raw; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - if (m_nState == MENUGAME || m_nState == MENUGFX || m_nState == MENUSOUND) - _ctx->raw = new RMResRaw(20000 + m_nState); - else if (m_nState == MENULOAD || m_nState == MENUSAVE) { - if (m_bAlterGfx) + if (_nState == MENUGAME || _nState == MENUGFX || _nState == MENUSOUND) + _ctx->raw = new RMResRaw(20000 + _nState); + else if (_nState == MENULOAD || _nState == MENUSAVE) { + if (_bAlterGfx) _ctx->raw = new RMResRaw(20024); else _ctx->raw = new RMResRaw(20003); @@ -584,415 +586,415 @@ void RMOptionScreen::InitState(CORO_PARAM) { } assert(_ctx->raw->IsValid()); - assert(m_menu == NULL); - m_menu = new RMGfxSourceBuffer16(false); - m_menu->init(*_ctx->raw, _ctx->raw->Width(), _ctx->raw->Height()); + assert(_menu == NULL); + _menu = new RMGfxSourceBuffer16(false); + _menu->init(*_ctx->raw, _ctx->raw->Width(), _ctx->raw->Height()); delete _ctx->raw; - if (m_nState == MENULOAD || m_nState == MENUSAVE) { - if (m_bAlterGfx) { - assert(m_ButtonExit == NULL); - m_ButtonExit = new RMOptionButton(20025, RMPoint(561, 406)); + if (_nState == MENULOAD || _nState == MENUSAVE) { + if (_bAlterGfx) { + assert(_ButtonExit == NULL); + _ButtonExit = new RMOptionButton(20025, RMPoint(561, 406)); } else { - assert(m_ButtonExit == NULL); - m_ButtonExit = new RMOptionButton(20012, RMPoint(560, 404)); + assert(_ButtonExit == NULL); + _ButtonExit = new RMOptionButton(20012, RMPoint(560, 404)); } - INIT_GFX8_FROMRAW(_ctx->raw, 20036, m_SaveEasy); - INIT_GFX8_FROMRAW(_ctx->raw, 20037, m_SaveHard); - - RefreshThumbnails(); - - assert(m_ButtonSave_States[0] == NULL); - m_ButtonSave_States[0] = new RMOptionButton(RMRect(48, 57, 48 + 160, 57 + 120)); - assert(m_ButtonSave_States[1] == NULL); - m_ButtonSave_States[1] = new RMOptionButton(RMRect(240, 57, 240 + 160, 57 + 120)); - assert(m_ButtonSave_States[2] == NULL); - m_ButtonSave_States[2] = new RMOptionButton(RMRect(432, 57, 432 + 160, 57 + 120)); - assert(m_ButtonSave_States[3] == NULL); - m_ButtonSave_States[3] = new RMOptionButton(RMRect(48, 239, 48 + 160, 239 + 120)); - assert(m_ButtonSave_States[4] == NULL); - m_ButtonSave_States[4] = new RMOptionButton(RMRect(240, 239, 240 + 160, 239 + 120)); - assert(m_ButtonSave_States[5] == NULL); - m_ButtonSave_States[5] = new RMOptionButton(RMRect(432, 239, 432 + 160, 239 + 120)); - - if (m_bAlterGfx) { - assert(m_ButtonSave_ArrowLeft == NULL); - m_ButtonSave_ArrowLeft = new RMOptionButton(20026, RMPoint(3, 196)); - assert(m_ButtonSave_ArrowRight == NULL); - m_ButtonSave_ArrowRight = new RMOptionButton(20027, RMPoint(601, 197)); + INIT_GFX8_FROMRAW(_ctx->raw, 20036, _SaveEasy); + INIT_GFX8_FROMRAW(_ctx->raw, 20037, _SaveHard); + + refreshThumbnails(); + + assert(_ButtonSave_States[0] == NULL); + _ButtonSave_States[0] = new RMOptionButton(RMRect(48, 57, 48 + 160, 57 + 120)); + assert(_ButtonSave_States[1] == NULL); + _ButtonSave_States[1] = new RMOptionButton(RMRect(240, 57, 240 + 160, 57 + 120)); + assert(_ButtonSave_States[2] == NULL); + _ButtonSave_States[2] = new RMOptionButton(RMRect(432, 57, 432 + 160, 57 + 120)); + assert(_ButtonSave_States[3] == NULL); + _ButtonSave_States[3] = new RMOptionButton(RMRect(48, 239, 48 + 160, 239 + 120)); + assert(_ButtonSave_States[4] == NULL); + _ButtonSave_States[4] = new RMOptionButton(RMRect(240, 239, 240 + 160, 239 + 120)); + assert(_ButtonSave_States[5] == NULL); + _ButtonSave_States[5] = new RMOptionButton(RMRect(432, 239, 432 + 160, 239 + 120)); + + if (_bAlterGfx) { + assert(_ButtonSave_ArrowLeft == NULL); + _ButtonSave_ArrowLeft = new RMOptionButton(20026, RMPoint(3, 196)); + assert(_ButtonSave_ArrowRight == NULL); + _ButtonSave_ArrowRight = new RMOptionButton(20027, RMPoint(601, 197)); } else { - assert(m_ButtonSave_ArrowLeft == NULL); - m_ButtonSave_ArrowLeft = new RMOptionButton(20013, RMPoint(0, 197)); - assert(m_ButtonSave_ArrowRight == NULL); - m_ButtonSave_ArrowRight = new RMOptionButton(20014, RMPoint(601, 197)); + assert(_ButtonSave_ArrowLeft == NULL); + _ButtonSave_ArrowLeft = new RMOptionButton(20013, RMPoint(0, 197)); + assert(_ButtonSave_ArrowRight == NULL); + _ButtonSave_ArrowRight = new RMOptionButton(20014, RMPoint(601, 197)); } - } else if (m_nState == MENUGAME || m_nState == MENUGFX || m_nState == MENUSOUND) { - assert(m_ButtonExit == NULL); - m_ButtonExit = new RMOptionButton(20005, RMPoint(560, 405)); - assert(m_ButtonQuit == NULL); - m_ButtonQuit = new RMOptionButton(20020, RMPoint(7, 408)); - assert(m_ButtonLoad == NULL); - m_ButtonLoad = new RMOptionButton(20006, RMPoint(231, 401)); - assert(m_ButtonSave == NULL); - m_ButtonSave = new RMOptionButton(20007, RMPoint(325, 401)); - - assert(m_ButtonGameMenu == NULL); - m_ButtonGameMenu = new RMOptionButton(RMRect(24, 32, 118, 64)); - assert(m_ButtonGfxMenu == NULL); - m_ButtonGfxMenu = new RMOptionButton(RMRect(118, 32, 212, 64)); - assert(m_ButtonSoundMenu == NULL); - m_ButtonSoundMenu = new RMOptionButton(RMRect(212, 32, 306, 64)); + } else if (_nState == MENUGAME || _nState == MENUGFX || _nState == MENUSOUND) { + assert(_ButtonExit == NULL); + _ButtonExit = new RMOptionButton(20005, RMPoint(560, 405)); + assert(_ButtonQuit == NULL); + _ButtonQuit = new RMOptionButton(20020, RMPoint(7, 408)); + assert(_ButtonLoad == NULL); + _ButtonLoad = new RMOptionButton(20006, RMPoint(231, 401)); + assert(_ButtonSave == NULL); + _ButtonSave = new RMOptionButton(20007, RMPoint(325, 401)); + + assert(_ButtonGameMenu == NULL); + _ButtonGameMenu = new RMOptionButton(RMRect(24, 32, 118, 64)); + assert(_ButtonGfxMenu == NULL); + _ButtonGfxMenu = new RMOptionButton(RMRect(118, 32, 212, 64)); + assert(_ButtonSoundMenu == NULL); + _ButtonSoundMenu = new RMOptionButton(RMRect(212, 32, 306, 64)); _ctx->raw = new RMResRaw(20021); assert(_ctx->raw->IsValid()); - assert(m_QuitConfirm == NULL); - m_QuitConfirm = new RMGfxSourceBuffer16(false); - m_QuitConfirm->init(*_ctx->raw, _ctx->raw->Width(), _ctx->raw->Height()); + assert(_QuitConfirm == NULL); + _QuitConfirm = new RMGfxSourceBuffer16(false); + _QuitConfirm->init(*_ctx->raw, _ctx->raw->Width(), _ctx->raw->Height()); delete _ctx->raw; - assert(m_ButtonQuitYes == NULL); - m_ButtonQuitYes = new RMOptionButton(20022, RMPoint(281, 265)); - m_ButtonQuitYes->setPriority(30); - assert(m_ButtonQuitNo == NULL); - m_ButtonQuitNo = new RMOptionButton(20023, RMPoint(337, 264)); - m_ButtonQuitNo->setPriority(30); + assert(_ButtonQuitYes == NULL); + _ButtonQuitYes = new RMOptionButton(20022, RMPoint(281, 265)); + _ButtonQuitYes->setPriority(30); + assert(_ButtonQuitNo == NULL); + _ButtonQuitNo = new RMOptionButton(20023, RMPoint(337, 264)); + _ButtonQuitNo->setPriority(30); - if (m_bNoLoadSave) { + if (_bNoLoadSave) { _ctx->raw = new RMResRaw(20028); assert(_ctx->raw->IsValid()); - assert(m_HideLoadSave == NULL); - m_HideLoadSave = new RMGfxSourceBuffer16(false); - m_HideLoadSave->init(*_ctx->raw, _ctx->raw->Width(), _ctx->raw->Height()); + assert(_HideLoadSave == NULL); + _HideLoadSave = new RMGfxSourceBuffer16(false); + _HideLoadSave->init(*_ctx->raw, _ctx->raw->Width(), _ctx->raw->Height()); delete _ctx->raw; } // Menu GAME - if (m_nState == MENUGAME) { - assert(m_ButtonGame_Lock == NULL); - m_ButtonGame_Lock = new RMOptionButton(20008, RMPoint(176, 262), true); - m_ButtonGame_Lock->SetActiveState(GLOBALS.bCfgInvLocked); - assert(m_ButtonGame_TimerizedText == NULL); - m_ButtonGame_TimerizedText = new RMOptionButton(20009, RMPoint(463, 273), true); - m_ButtonGame_TimerizedText->SetActiveState(!GLOBALS.bCfgTimerizedText); - assert(m_ButtonGame_Scrolling == NULL); - m_ButtonGame_Scrolling = new RMOptionButton(20010, RMPoint(315, 263), true); - m_ButtonGame_Scrolling->SetActiveState(GLOBALS.bCfgInvNoScroll); - assert(m_ButtonGame_InterUp == NULL); - m_ButtonGame_InterUp = new RMOptionButton(20011, RMPoint(36, 258), true); - m_ButtonGame_InterUp->SetActiveState(GLOBALS.bCfgInvUp); - - assert(m_SlideTextSpeed == NULL); - m_SlideTextSpeed = new RMOptionSlide(RMPoint(165, 122), 10, GLOBALS.nCfgTextSpeed); - assert(m_SlideTonySpeed == NULL); - m_SlideTonySpeed = new RMOptionSlide(RMPoint(165, 226), 5, GLOBALS.nCfgTonySpeed); + if (_nState == MENUGAME) { + assert(_ButtonGame_Lock == NULL); + _ButtonGame_Lock = new RMOptionButton(20008, RMPoint(176, 262), true); + _ButtonGame_Lock->setActiveState(GLOBALS.bCfgInvLocked); + assert(_ButtonGame_TimerizedText == NULL); + _ButtonGame_TimerizedText = new RMOptionButton(20009, RMPoint(463, 273), true); + _ButtonGame_TimerizedText->setActiveState(!GLOBALS.bCfgTimerizedText); + assert(_ButtonGame_Scrolling == NULL); + _ButtonGame_Scrolling = new RMOptionButton(20010, RMPoint(315, 263), true); + _ButtonGame_Scrolling->setActiveState(GLOBALS.bCfgInvNoScroll); + assert(_ButtonGame_InterUp == NULL); + _ButtonGame_InterUp = new RMOptionButton(20011, RMPoint(36, 258), true); + _ButtonGame_InterUp->setActiveState(GLOBALS.bCfgInvUp); + + assert(_SlideTextSpeed == NULL); + _SlideTextSpeed = new RMOptionSlide(RMPoint(165, 122), 10, GLOBALS.nCfgTextSpeed); + assert(_SlideTonySpeed == NULL); + _SlideTonySpeed = new RMOptionSlide(RMPoint(165, 226), 5, GLOBALS.nCfgTonySpeed); } // Menu Graphics - else if (m_nState == MENUGFX) { - assert(m_ButtonGfx_Anni30 == NULL); - m_ButtonGfx_Anni30 = new RMOptionButton(20015, RMPoint(247, 178), true); - m_ButtonGfx_Anni30->SetActiveState(GLOBALS.bCfgAnni30); - assert(m_ButtonGfx_AntiAlias == NULL); - m_ButtonGfx_AntiAlias = new RMOptionButton(20016, RMPoint(430, 83), true); - m_ButtonGfx_AntiAlias->SetActiveState(!GLOBALS.bCfgAntiAlias); - assert(m_ButtonGfx_Sottotitoli == NULL); - m_ButtonGfx_Sottotitoli = new RMOptionButton(20017, RMPoint(98, 82), true); - m_ButtonGfx_Sottotitoli->SetActiveState(!GLOBALS.bCfgSottotitoli); - assert(m_ButtonGfx_Tips == NULL); - m_ButtonGfx_Tips = new RMOptionButton(20018, RMPoint(431, 246), true); - m_ButtonGfx_Tips->SetActiveState(GLOBALS.bCfgInterTips); - assert(m_ButtonGfx_Trans == NULL); - m_ButtonGfx_Trans = new RMOptionButton(20019, RMPoint(126, 271), true); - m_ButtonGfx_Trans->SetActiveState(!GLOBALS.bCfgTransparence); - - } else if (m_nState == MENUSOUND) { - assert(m_SliderSound_Dubbing == NULL); - m_SliderSound_Dubbing = new RMOptionSlide(RMPoint(165, 122), 10, GLOBALS.nCfgDubbingVolume); - assert(m_SliderSound_Music == NULL); - m_SliderSound_Music = new RMOptionSlide(RMPoint(165, 226), 10, GLOBALS.nCfgMusicVolume); - assert(m_SliderSound_SFX == NULL); - m_SliderSound_SFX = new RMOptionSlide(RMPoint(165, 330), 10, GLOBALS.nCfgSFXVolume); - - assert(m_ButtonSound_DubbingOn == NULL); - m_ButtonSound_DubbingOn = new RMOptionButton(20033, RMPoint(339, 75), true); - m_ButtonSound_DubbingOn->SetActiveState(GLOBALS.bCfgDubbing); - assert(m_ButtonSound_MusicOn == NULL); - m_ButtonSound_MusicOn = new RMOptionButton(20034, RMPoint(338, 179), true); - m_ButtonSound_MusicOn->SetActiveState(GLOBALS.bCfgMusic); - assert(m_ButtonSound_SFXOn == NULL); - m_ButtonSound_SFXOn = new RMOptionButton(20035, RMPoint(338, 283), true); - m_ButtonSound_SFXOn->SetActiveState(GLOBALS.bCfgSFX); + else if (_nState == MENUGFX) { + assert(_ButtonGfx_Anni30 == NULL); + _ButtonGfx_Anni30 = new RMOptionButton(20015, RMPoint(247, 178), true); + _ButtonGfx_Anni30->setActiveState(GLOBALS.bCfgAnni30); + assert(_ButtonGfx_AntiAlias == NULL); + _ButtonGfx_AntiAlias = new RMOptionButton(20016, RMPoint(430, 83), true); + _ButtonGfx_AntiAlias->setActiveState(!GLOBALS.bCfgAntiAlias); + assert(_ButtonGfx_Sottotitoli == NULL); + _ButtonGfx_Sottotitoli = new RMOptionButton(20017, RMPoint(98, 82), true); + _ButtonGfx_Sottotitoli->setActiveState(!GLOBALS.bCfgSottotitoli); + assert(_ButtonGfx_Tips == NULL); + _ButtonGfx_Tips = new RMOptionButton(20018, RMPoint(431, 246), true); + _ButtonGfx_Tips->setActiveState(GLOBALS.bCfgInterTips); + assert(_ButtonGfx_Trans == NULL); + _ButtonGfx_Trans = new RMOptionButton(20019, RMPoint(126, 271), true); + _ButtonGfx_Trans->setActiveState(!GLOBALS.bCfgTransparence); + + } else if (_nState == MENUSOUND) { + assert(_SliderSound_Dubbing == NULL); + _SliderSound_Dubbing = new RMOptionSlide(RMPoint(165, 122), 10, GLOBALS.nCfgDubbingVolume); + assert(_SliderSound_Music == NULL); + _SliderSound_Music = new RMOptionSlide(RMPoint(165, 226), 10, GLOBALS.nCfgMusicVolume); + assert(_SliderSound_SFX == NULL); + _SliderSound_SFX = new RMOptionSlide(RMPoint(165, 330), 10, GLOBALS.nCfgSFXVolume); + + assert(_ButtonSound_DubbingOn == NULL); + _ButtonSound_DubbingOn = new RMOptionButton(20033, RMPoint(339, 75), true); + _ButtonSound_DubbingOn->setActiveState(GLOBALS.bCfgDubbing); + assert(_ButtonSound_MusicOn == NULL); + _ButtonSound_MusicOn = new RMOptionButton(20034, RMPoint(338, 179), true); + _ButtonSound_MusicOn->setActiveState(GLOBALS.bCfgMusic); + assert(_ButtonSound_SFXOn == NULL); + _ButtonSound_SFXOn = new RMOptionButton(20035, RMPoint(338, 283), true); + _ButtonSound_SFXOn->setActiveState(GLOBALS.bCfgSFX); } } - CORO_INVOKE_0(RefreshAll); + CORO_INVOKE_0(refreshAll); CORO_END_CODE; } -void RMOptionScreen::CloseState(void) { - delete m_menu; - m_menu = NULL; +void RMOptionScreen::closeState(void) { + delete _menu; + _menu = NULL; - delete m_ButtonExit; - m_ButtonExit = NULL; + delete _ButtonExit; + _ButtonExit = NULL; - if (m_nState == MENULOAD || m_nState == MENUSAVE) { + if (_nState == MENULOAD || _nState == MENUSAVE) { int i; for (i = 0; i < 6; i++) { - if (m_curThumb[i] != NULL) { - delete m_curThumb[i]; - m_curThumb[i] = NULL; + if (_curThumb[i] != NULL) { + delete _curThumb[i]; + _curThumb[i] = NULL; } - delete m_ButtonSave_States[i]; - m_ButtonSave_States[i] = NULL; + delete _ButtonSave_States[i]; + _ButtonSave_States[i] = NULL; } - delete m_ButtonSave_ArrowLeft; - m_ButtonSave_ArrowLeft = NULL; - delete m_ButtonSave_ArrowRight; - m_ButtonSave_ArrowRight = NULL; + delete _ButtonSave_ArrowLeft; + _ButtonSave_ArrowLeft = NULL; + delete _ButtonSave_ArrowRight; + _ButtonSave_ArrowRight = NULL; - delete m_SaveEasy; - m_SaveEasy = NULL; - delete m_SaveHard; - m_SaveHard = NULL; + delete _SaveEasy; + _SaveEasy = NULL; + delete _SaveHard; + _SaveHard = NULL; } - if (m_nState == MENUGAME || m_nState == MENUGFX || m_nState == MENUSOUND) { - delete m_ButtonQuit; - m_ButtonQuit = NULL; - delete m_ButtonLoad; - m_ButtonLoad = NULL; - delete m_ButtonSave; - m_ButtonSave = NULL; - delete m_ButtonGameMenu; - m_ButtonGameMenu = NULL; - delete m_ButtonGfxMenu; - m_ButtonGfxMenu = NULL; - delete m_ButtonSoundMenu; - m_ButtonSoundMenu = NULL; - delete m_QuitConfirm; - m_QuitConfirm = NULL; - delete m_ButtonQuitYes; - m_ButtonQuitYes = NULL; - delete m_ButtonQuitNo; - m_ButtonQuitNo = NULL; - - if (m_bNoLoadSave) { - delete m_HideLoadSave; - m_HideLoadSave = NULL; + if (_nState == MENUGAME || _nState == MENUGFX || _nState == MENUSOUND) { + delete _ButtonQuit; + _ButtonQuit = NULL; + delete _ButtonLoad; + _ButtonLoad = NULL; + delete _ButtonSave; + _ButtonSave = NULL; + delete _ButtonGameMenu; + _ButtonGameMenu = NULL; + delete _ButtonGfxMenu; + _ButtonGfxMenu = NULL; + delete _ButtonSoundMenu; + _ButtonSoundMenu = NULL; + delete _QuitConfirm; + _QuitConfirm = NULL; + delete _ButtonQuitYes; + _ButtonQuitYes = NULL; + delete _ButtonQuitNo; + _ButtonQuitNo = NULL; + + if (_bNoLoadSave) { + delete _HideLoadSave; + _HideLoadSave = NULL; } - if (m_nState == MENUGAME) { - GLOBALS.bCfgInvLocked = m_ButtonGame_Lock->IsActive(); - delete m_ButtonGame_Lock; - m_ButtonGame_Lock = NULL; - - GLOBALS.bCfgTimerizedText = !m_ButtonGame_TimerizedText->IsActive(); - delete m_ButtonGame_TimerizedText; - m_ButtonGame_TimerizedText = NULL; - - GLOBALS.bCfgInvNoScroll = m_ButtonGame_Scrolling->IsActive(); - delete m_ButtonGame_Scrolling; - m_ButtonGame_Scrolling = NULL; - - GLOBALS.bCfgInvUp = m_ButtonGame_InterUp->IsActive(); - delete m_ButtonGame_InterUp; - m_ButtonGame_InterUp = NULL; - - GLOBALS.nCfgTextSpeed = m_SlideTextSpeed->GetValue(); - delete m_SlideTextSpeed; - m_SlideTextSpeed = NULL; - - GLOBALS.nCfgTonySpeed = m_SlideTonySpeed->GetValue(); - delete m_SlideTonySpeed; - m_SlideTonySpeed = NULL; - } else if (m_nState == MENUGFX) { - GLOBALS.bCfgAnni30 = m_ButtonGfx_Anni30->IsActive(); - delete m_ButtonGfx_Anni30; - m_ButtonGfx_Anni30 = NULL; - - GLOBALS.bCfgAntiAlias = !m_ButtonGfx_AntiAlias->IsActive(); - delete m_ButtonGfx_AntiAlias; - m_ButtonGfx_AntiAlias = NULL; - - GLOBALS.bCfgSottotitoli = !m_ButtonGfx_Sottotitoli->IsActive(); - delete m_ButtonGfx_Sottotitoli; - m_ButtonGfx_Sottotitoli = NULL; - - GLOBALS.bCfgInterTips = m_ButtonGfx_Tips->IsActive(); - delete m_ButtonGfx_Tips; - m_ButtonGfx_Tips = NULL; - - GLOBALS.bCfgTransparence = !m_ButtonGfx_Trans->IsActive(); - delete m_ButtonGfx_Trans; - m_ButtonGfx_Trans = NULL; - } else if (m_nState == MENUSOUND) { - GLOBALS.nCfgDubbingVolume = m_SliderSound_Dubbing->GetValue(); - delete m_SliderSound_Dubbing; - m_SliderSound_Dubbing = NULL; - - GLOBALS.nCfgMusicVolume = m_SliderSound_Music->GetValue(); - delete m_SliderSound_Music; - m_SliderSound_Music = NULL; - - GLOBALS.nCfgSFXVolume = m_SliderSound_SFX->GetValue(); - delete m_SliderSound_SFX; - m_SliderSound_SFX = NULL; - - GLOBALS.bCfgDubbing = m_ButtonSound_DubbingOn->IsActive(); - delete m_ButtonSound_DubbingOn; - m_ButtonSound_DubbingOn = NULL; - - GLOBALS.bCfgMusic = m_ButtonSound_MusicOn->IsActive(); - delete m_ButtonSound_MusicOn; - m_ButtonSound_MusicOn = NULL; - - GLOBALS.bCfgSFX = m_ButtonSound_SFXOn->IsActive(); - delete m_ButtonSound_SFXOn; - m_ButtonSound_SFXOn = NULL; + if (_nState == MENUGAME) { + GLOBALS.bCfgInvLocked = _ButtonGame_Lock->isActive(); + delete _ButtonGame_Lock; + _ButtonGame_Lock = NULL; + + GLOBALS.bCfgTimerizedText = !_ButtonGame_TimerizedText->isActive(); + delete _ButtonGame_TimerizedText; + _ButtonGame_TimerizedText = NULL; + + GLOBALS.bCfgInvNoScroll = _ButtonGame_Scrolling->isActive(); + delete _ButtonGame_Scrolling; + _ButtonGame_Scrolling = NULL; + + GLOBALS.bCfgInvUp = _ButtonGame_InterUp->isActive(); + delete _ButtonGame_InterUp; + _ButtonGame_InterUp = NULL; + + GLOBALS.nCfgTextSpeed = _SlideTextSpeed->getValue(); + delete _SlideTextSpeed; + _SlideTextSpeed = NULL; + + GLOBALS.nCfgTonySpeed = _SlideTonySpeed->getValue(); + delete _SlideTonySpeed; + _SlideTonySpeed = NULL; + } else if (_nState == MENUGFX) { + GLOBALS.bCfgAnni30 = _ButtonGfx_Anni30->isActive(); + delete _ButtonGfx_Anni30; + _ButtonGfx_Anni30 = NULL; + + GLOBALS.bCfgAntiAlias = !_ButtonGfx_AntiAlias->isActive(); + delete _ButtonGfx_AntiAlias; + _ButtonGfx_AntiAlias = NULL; + + GLOBALS.bCfgSottotitoli = !_ButtonGfx_Sottotitoli->isActive(); + delete _ButtonGfx_Sottotitoli; + _ButtonGfx_Sottotitoli = NULL; + + GLOBALS.bCfgInterTips = _ButtonGfx_Tips->isActive(); + delete _ButtonGfx_Tips; + _ButtonGfx_Tips = NULL; + + GLOBALS.bCfgTransparence = !_ButtonGfx_Trans->isActive(); + delete _ButtonGfx_Trans; + _ButtonGfx_Trans = NULL; + } else if (_nState == MENUSOUND) { + GLOBALS.nCfgDubbingVolume = _SliderSound_Dubbing->getValue(); + delete _SliderSound_Dubbing; + _SliderSound_Dubbing = NULL; + + GLOBALS.nCfgMusicVolume = _SliderSound_Music->getValue(); + delete _SliderSound_Music; + _SliderSound_Music = NULL; + + GLOBALS.nCfgSFXVolume = _SliderSound_SFX->getValue(); + delete _SliderSound_SFX; + _SliderSound_SFX = NULL; + + GLOBALS.bCfgDubbing = _ButtonSound_DubbingOn->isActive(); + delete _ButtonSound_DubbingOn; + _ButtonSound_DubbingOn = NULL; + + GLOBALS.bCfgMusic = _ButtonSound_MusicOn->isActive(); + delete _ButtonSound_MusicOn; + _ButtonSound_MusicOn = NULL; + + GLOBALS.bCfgSFX = _ButtonSound_SFXOn->isActive(); + delete _ButtonSound_SFXOn; + _ButtonSound_SFXOn = NULL; } } - m_nState = MENUNONE; + _nState = MENUNONE; } -void RMOptionScreen::ReInit(RMGfxTargetBuffer &bigBuf) { +void RMOptionScreen::reInit(RMGfxTargetBuffer &bigBuf) { bigBuf.addPrim(new RMGfxPrimitive(this)); } -void RMOptionScreen::Init(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool &result) { +void RMOptionScreen::init(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool &result) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - if (m_FadeStep != 0) { + if (_FadeStep != 0) { result = false; return; } - m_FadeStep = 1; - m_FadeY = -20; - m_FadeTime = -1; - m_bExit = false; - m_bLoadMenuOnly = false; - m_bNoLoadSave = false; - m_bAlterGfx = false; + _FadeStep = 1; + _FadeY = -20; + _FadeTime = -1; + _bExit = false; + _bLoadMenuOnly = false; + _bNoLoadSave = false; + _bAlterGfx = false; bigBuf.addPrim(new RMGfxPrimitive(this)); - if (m_nState == MENULOAD || m_nState == MENUSAVE) - m_nState = MENUGAME; + if (_nState == MENULOAD || _nState == MENUSAVE) + _nState = MENUGAME; - CORO_INVOKE_0(InitState); + CORO_INVOKE_0(initState); result = true; CORO_END_CODE; } -void RMOptionScreen::InitLoadMenuOnly(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool bAlternateGfx, bool &result) { +void RMOptionScreen::initLoadMenuOnly(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool bAlternateGfx, bool &result) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - if (m_FadeStep != 0) { + if (_FadeStep != 0) { result = false; return; } - m_FadeStep = 1; - m_FadeY = -20; - m_FadeTime = -1; - m_bExit = false; - m_bLoadMenuOnly = true; - m_bNoLoadSave = false; - m_bAlterGfx = bAlternateGfx; + _FadeStep = 1; + _FadeY = -20; + _FadeTime = -1; + _bExit = false; + _bLoadMenuOnly = true; + _bNoLoadSave = false; + _bAlterGfx = bAlternateGfx; bigBuf.addPrim(new RMGfxPrimitive(this)); - m_nState = MENULOAD; - CORO_INVOKE_0(InitState); + _nState = MENULOAD; + CORO_INVOKE_0(initState); result = true; CORO_END_CODE; } -void RMOptionScreen::InitSaveMenuOnly(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool bAlternateGfx, bool &result) { +void RMOptionScreen::initSaveMenuOnly(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool bAlternateGfx, bool &result) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - if (m_FadeStep != 0) { + if (_FadeStep != 0) { result = false; return; } - m_FadeStep = 1; - m_FadeY = -20; - m_FadeTime = -1; - m_bExit = false; - m_bLoadMenuOnly = true; - m_bNoLoadSave = false; - m_bAlterGfx = bAlternateGfx; + _FadeStep = 1; + _FadeY = -20; + _FadeTime = -1; + _bExit = false; + _bLoadMenuOnly = true; + _bNoLoadSave = false; + _bAlterGfx = bAlternateGfx; bigBuf.addPrim(new RMGfxPrimitive(this)); - m_nState = MENUSAVE; - CORO_INVOKE_0(InitState); + _nState = MENUSAVE; + CORO_INVOKE_0(initState); result = true; CORO_END_CODE; } -void RMOptionScreen::InitNoLoadSave(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool &result) { +void RMOptionScreen::initNoLoadSave(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool &result) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - if (m_FadeStep != 0) { + if (_FadeStep != 0) { result = false; return; } - m_FadeStep = 1; - m_FadeY = -20; - m_FadeTime = -1; - m_bExit = false; - m_bLoadMenuOnly = false; - m_bNoLoadSave = true; + _FadeStep = 1; + _FadeY = -20; + _FadeTime = -1; + _bExit = false; + _bLoadMenuOnly = false; + _bNoLoadSave = true; bigBuf.addPrim(new RMGfxPrimitive(this)); - m_nState = MENUGAME; - CORO_INVOKE_0(InitState); + _nState = MENUGAME; + CORO_INVOKE_0(initState); result = true; CORO_END_CODE; } -bool RMOptionScreen::Close(void) { - if (m_FadeStep != 6) +bool RMOptionScreen::close(void) { + if (_FadeStep != 6) return false; // Start fade out - m_FadeStep++; - m_FadeTime = _vm->getTime(); + _FadeStep++; + _FadeTime = _vm->getTime(); return true; } -bool RMOptionScreen::IsClosing(void) { - return m_bExit; +bool RMOptionScreen::isClosing(void) { + return _bExit; } int RMOptionScreen::priority() { @@ -1000,21 +1002,21 @@ int RMOptionScreen::priority() { return 190; } -void RMOptionScreen::ChangeState(CORO_PARAM, STATE newState) { +void RMOptionScreen::changeState(CORO_PARAM, STATE newState) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - CloseState(); - m_nLastState = m_nState; - m_nState = newState; - CORO_INVOKE_0(InitState); + closeState(); + _nLastState = _nState; + _nState = newState; + CORO_INVOKE_0(initState); CORO_END_CODE; } -void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { +void RMOptionScreen::doFrame(CORO_PARAM, RMInput *input) { CORO_BEGIN_CONTEXT; bool bLeftClick, bRightClick; RMPoint mousePos; @@ -1026,7 +1028,7 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { // If it is fully open, do nothing - if (m_FadeStep != 6) + if (_FadeStep != 6) return; // Reads input @@ -1036,79 +1038,79 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { _ctx->bRefresh = false; - if (m_bQuitConfirm) { - _ctx->bRefresh |= m_ButtonQuitYes->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= m_ButtonQuitNo->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + if (_bQuitConfirm) { + _ctx->bRefresh |= _ButtonQuitYes->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _ButtonQuitNo->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); } else { - _ctx->bRefresh |= m_ButtonExit->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _ButtonExit->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); // Check if you have clicked on the output - if (m_nState == MENUGAME || m_nState == MENUGFX || m_nState == MENUSOUND) { + if (_nState == MENUGAME || _nState == MENUGFX || _nState == MENUSOUND) { // Buttons without graphics... - m_ButtonGameMenu->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - m_ButtonGfxMenu->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - m_ButtonSoundMenu->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ButtonGameMenu->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ButtonGfxMenu->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ButtonSoundMenu->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); // Buttons with graphics - if (!m_bNoLoadSave) { + if (!_bNoLoadSave) { if (!_vm->getIsDemo()) { - _ctx->bRefresh |= m_ButtonLoad->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= m_ButtonSave->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _ButtonLoad->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _ButtonSave->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); } - _ctx->bRefresh |= m_ButtonQuit->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _ButtonQuit->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); } } - if (m_nState == MENUGAME) { - _ctx->bRefresh |= m_ButtonGame_Lock->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= m_ButtonGame_TimerizedText->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= m_ButtonGame_Scrolling->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= m_ButtonGame_InterUp->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= m_SlideTextSpeed->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= m_SlideTonySpeed->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - - } else if (m_nState == MENUGFX) { - _ctx->bRefresh |= m_ButtonGfx_Anni30->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= m_ButtonGfx_AntiAlias->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= m_ButtonGfx_Sottotitoli->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= m_ButtonGfx_Tips->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= m_ButtonGfx_Trans->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - - } else if (m_nState == MENUSOUND) { - _ctx->bRefresh |= m_SliderSound_Dubbing->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= m_SliderSound_Music->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= m_SliderSound_SFX->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= m_ButtonSound_DubbingOn->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= m_ButtonSound_MusicOn->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= m_ButtonSound_SFXOn->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - - } else if (m_nState == MENULOAD || m_nState == MENUSAVE) { + if (_nState == MENUGAME) { + _ctx->bRefresh |= _ButtonGame_Lock->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _ButtonGame_TimerizedText->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _ButtonGame_Scrolling->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _ButtonGame_InterUp->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _SlideTextSpeed->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _SlideTonySpeed->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + + } else if (_nState == MENUGFX) { + _ctx->bRefresh |= _ButtonGfx_Anni30->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _ButtonGfx_AntiAlias->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _ButtonGfx_Sottotitoli->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _ButtonGfx_Tips->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _ButtonGfx_Trans->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + + } else if (_nState == MENUSOUND) { + _ctx->bRefresh |= _SliderSound_Dubbing->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _SliderSound_Music->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _SliderSound_SFX->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _ButtonSound_DubbingOn->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _ButtonSound_MusicOn->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _ButtonSound_SFXOn->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + + } else if (_nState == MENULOAD || _nState == MENUSAVE) { for (_ctx->i = 0; _ctx->i < 6; _ctx->i++) - m_ButtonSave_States[_ctx->i]->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ButtonSave_States[_ctx->i]->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - if (m_statePos > 0) - _ctx->bRefresh |= m_ButtonSave_ArrowLeft->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - if (m_statePos < 90) - _ctx->bRefresh |= m_ButtonSave_ArrowRight->DoFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + if (_statePos > 0) + _ctx->bRefresh |= _ButtonSave_ArrowLeft->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + if (_statePos < 90) + _ctx->bRefresh |= _ButtonSave_ArrowRight->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); } } #define KEYPRESS(c) (_vm->getEngine()->getInput().getAsyncKeyState(c)) #define PROCESS_CHAR(cod,c) if (KEYPRESS(cod)) { \ - m_EditName[strlen(m_EditName) + 1] = '\0'; m_EditName[strlen(m_EditName)] = c; _ctx->bRefresh = true; } + _EditName[strlen(_EditName) + 1] = '\0'; _EditName[strlen(_EditName)] = c; _ctx->bRefresh = true; } /**************** State Buttons **************/ - if (m_bEditSaveName) { + if (_bEditSaveName) { if (KEYPRESS(Common::KEYCODE_BACKSPACE)) { - if (m_EditName[0] != '\0') { - m_EditName[strlen(m_EditName) - 1] = '\0'; + if (_EditName[0] != '\0') { + _EditName[strlen(_EditName) - 1] = '\0'; _ctx->bRefresh = true; } } - for (_ctx->i = 0; _ctx->i < 26 && strlen(m_EditName) < 12; _ctx->i++) + for (_ctx->i = 0; _ctx->i < 26 && strlen(_EditName) < 12; _ctx->i++) if (KEYPRESS(Common::KEYCODE_LSHIFT) || KEYPRESS(Common::KEYCODE_RSHIFT)) { PROCESS_CHAR((Common::KeyCode)((int)'a' + _ctx->i), _ctx->i + 'A'); @@ -1116,85 +1118,87 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { PROCESS_CHAR((Common::KeyCode)((int)'a' + _ctx->i), _ctx->i + 'a'); } - for (_ctx->i = 0; _ctx->i < 10 && strlen(m_EditName) < 12; _ctx->i++) + for (_ctx->i = 0; _ctx->i < 10 && strlen(_EditName) < 12; _ctx->i++) PROCESS_CHAR((Common::KeyCode)((int)'0' + _ctx->i), _ctx->i + '0'); - if (strlen(m_EditName) < 12) + if (strlen(_EditName) < 12) PROCESS_CHAR(Common::KEYCODE_SPACE, ' '); - if (strlen(m_EditName) < 12) + if (strlen(_EditName) < 12) PROCESS_CHAR(Common::KEYCODE_KP0, '0'); - if (strlen(m_EditName) < 12) + if (strlen(_EditName) < 12) PROCESS_CHAR(Common::KEYCODE_KP1, '1'); - if (strlen(m_EditName) < 12) + if (strlen(_EditName) < 12) PROCESS_CHAR(Common::KEYCODE_KP2, '2'); - if (strlen(m_EditName) < 12) + if (strlen(_EditName) < 12) PROCESS_CHAR(Common::KEYCODE_KP3, '3'); - if (strlen(m_EditName) < 12) + if (strlen(_EditName) < 12) PROCESS_CHAR(Common::KEYCODE_KP4, '4'); - if (strlen(m_EditName) < 12) + if (strlen(_EditName) < 12) PROCESS_CHAR(Common::KEYCODE_KP5, '5'); - if (strlen(m_EditName) < 12) + if (strlen(_EditName) < 12) PROCESS_CHAR(Common::KEYCODE_KP6, '6'); - if (strlen(m_EditName) < 12) + if (strlen(_EditName) < 12) PROCESS_CHAR(Common::KEYCODE_KP7, '7'); - if (strlen(m_EditName) < 12) + if (strlen(_EditName) < 12) PROCESS_CHAR(Common::KEYCODE_KP8, '8'); - if (strlen(m_EditName) < 12) + if (strlen(_EditName) < 12) PROCESS_CHAR(Common::KEYCODE_KP9, '9'); // Cancel if (KEYPRESS(Common::KEYCODE_ESCAPE)) { - m_bEditSaveName = false; + _bEditSaveName = false; _ctx->bRefresh = true; } // OK if (KEYPRESS(Common::KEYCODE_RETURN)) { - m_bEditSaveName = false; - _vm->saveState(m_statePos + m_nEditPos, m_EditName); - Close(); + _bEditSaveName = false; + _vm->saveState(_statePos + _nEditPos, _EditName); + close(); } } else if (_ctx->bLeftClick) { - if (m_nState == MENULOAD || m_nState == MENUSAVE) { - if (m_ButtonExit->IsActive()) { - if (m_bLoadMenuOnly) { + if (_nState == MENULOAD || _nState == MENUSAVE) { + if (_ButtonExit->isActive()) { + if (_bLoadMenuOnly) { // If only the loading menu, close - Close(); + close(); } else { - CORO_INVOKE_1(ChangeState, m_nLastState); + CORO_INVOKE_1(changeState, _nLastState); _ctx->bRefresh = true; } - } else if (m_ButtonSave_ArrowLeft->IsActive()) { - if (m_statePos > 0) { - m_statePos -= 6; - if (m_statePos < 0) m_statePos = 0; - m_ButtonSave_ArrowLeft->SetActiveState(false); + } else if (_ButtonSave_ArrowLeft->isActive()) { + if (_statePos > 0) { + _statePos -= 6; + if (_statePos < 0) + _statePos = 0; + _ButtonSave_ArrowLeft->setActiveState(false); _ctx->bRefresh = true; - RefreshThumbnails(); + refreshThumbnails(); } - } else if (m_ButtonSave_ArrowRight->IsActive()) { - if (m_statePos < 90) { - m_statePos += 6; - if (m_statePos > 90) m_statePos = 90; - m_ButtonSave_ArrowRight->SetActiveState(false); + } else if (_ButtonSave_ArrowRight->isActive()) { + if (_statePos < 90) { + _statePos += 6; + if (_statePos > 90) + _statePos = 90; + _ButtonSave_ArrowRight->setActiveState(false); _ctx->bRefresh = true; - RefreshThumbnails(); + refreshThumbnails(); } } else { for (_ctx->i = 0; _ctx->i < 6; _ctx->i++) - if (m_ButtonSave_States[_ctx->i]->IsActive()) { + if (_ButtonSave_States[_ctx->i]->isActive()) { // There by saving or loading!!! - if (m_nState == MENULOAD && m_curThumb[_ctx->i] != NULL) { + if (_nState == MENULOAD && _curThumb[_ctx->i] != NULL) { // Caricamento - CORO_INVOKE_1(_vm->loadState, m_statePos + _ctx->i); - Close(); - } else if (m_nState == MENUSAVE && (m_statePos != 0 || _ctx->i != 0)) { + CORO_INVOKE_1(_vm->loadState, _statePos + _ctx->i); + close(); + } else if (_nState == MENUSAVE && (_statePos != 0 || _ctx->i != 0)) { // Turn on edit mode - m_bEditSaveName = true; - m_nEditPos = _ctx->i; - strcpy(m_EditName, m_curThumbName[_ctx->i]); + _bEditSaveName = true; + _nEditPos = _ctx->i; + strcpy(_EditName, _curThumbName[_ctx->i]); _ctx->bRefresh = true; } @@ -1203,55 +1207,55 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { } } - if (m_nState == MENUGAME || m_nState == MENUGFX || m_nState == MENUSOUND) { - if (m_bQuitConfirm) { - if (m_ButtonQuitNo->IsActive()) { - m_bQuitConfirm = false; + if (_nState == MENUGAME || _nState == MENUGFX || _nState == MENUSOUND) { + if (_bQuitConfirm) { + if (_ButtonQuitNo->isActive()) { + _bQuitConfirm = false; _ctx->bRefresh = true; - } else if (m_ButtonQuitYes->IsActive()) { - m_bQuitConfirm = false; + } else if (_ButtonQuitYes->isActive()) { + _bQuitConfirm = false; _ctx->bRefresh = true; _vm->quitGame(); } } else { - if (m_ButtonQuit->IsActive()) { - m_bQuitConfirm = true; - m_ButtonQuitNo->SetActiveState(false); - m_ButtonQuitYes->SetActiveState(false); + if (_ButtonQuit->isActive()) { + _bQuitConfirm = true; + _ButtonQuitNo->setActiveState(false); + _ButtonQuitYes->setActiveState(false); _ctx->bRefresh = true; - } else if (m_ButtonExit->IsActive()) - Close(); - else if (m_ButtonLoad->IsActive()) { - CORO_INVOKE_1(ChangeState, MENULOAD); + } else if (_ButtonExit->isActive()) + close(); + else if (_ButtonLoad->isActive()) { + CORO_INVOKE_1(changeState, MENULOAD); _ctx->bRefresh = true; - } else if (m_ButtonSave->IsActive()) { - CORO_INVOKE_1(ChangeState, MENUSAVE); + } else if (_ButtonSave->isActive()) { + CORO_INVOKE_1(changeState, MENUSAVE); _ctx->bRefresh = true; - } else if (m_ButtonGameMenu->IsActive() && m_nState != MENUGAME) { - CORO_INVOKE_1(ChangeState, MENUGAME); + } else if (_ButtonGameMenu->isActive() && _nState != MENUGAME) { + CORO_INVOKE_1(changeState, MENUGAME); _ctx->bRefresh = true; - } else if (m_ButtonGfxMenu->IsActive() && m_nState != MENUGFX) { - CORO_INVOKE_1(ChangeState, MENUGFX); + } else if (_ButtonGfxMenu->isActive() && _nState != MENUGFX) { + CORO_INVOKE_1(changeState, MENUGFX); _ctx->bRefresh = true; - } else if (m_ButtonSoundMenu->IsActive() && m_nState != MENUSOUND) { - CORO_INVOKE_1(ChangeState, MENUSOUND); + } else if (_ButtonSoundMenu->isActive() && _nState != MENUSOUND) { + CORO_INVOKE_1(changeState, MENUSOUND); _ctx->bRefresh = true; } - if (m_nState == MENUGFX) { + if (_nState == MENUGFX) { // These options take effect immediately - if (m_ButtonGfx_Anni30->IsActive()) + if (_ButtonGfx_Anni30->isActive()) GLOBALS.bCfgAnni30 = true; else GLOBALS.bCfgAnni30 = false; - if (m_ButtonGfx_AntiAlias->IsActive()) + if (_ButtonGfx_AntiAlias->isActive()) GLOBALS.bCfgAntiAlias = false; else GLOBALS.bCfgAntiAlias = true; - if (m_ButtonGfx_Trans->IsActive()) + if (_ButtonGfx_Trans->isActive()) GLOBALS.bCfgTransparence = false; else GLOBALS.bCfgTransparence = true; @@ -1260,12 +1264,12 @@ void RMOptionScreen::DoFrame(CORO_PARAM, RMInput *input) { } } - if (m_nState == MENUGAME || m_nState == MENUGFX || m_nState == MENUSOUND) - if (!m_bQuitConfirm && KEYPRESS(Common::KEYCODE_ESCAPE)) - Close(); + if (_nState == MENUGAME || _nState == MENUGFX || _nState == MENUSOUND) + if (!_bQuitConfirm && KEYPRESS(Common::KEYCODE_ESCAPE)) + close(); if (_ctx->bRefresh) - CORO_INVOKE_0(RefreshAll); + CORO_INVOKE_0(refreshAll); CORO_END_CODE; } @@ -1281,94 +1285,94 @@ void RMOptionScreen::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive _ctx->curTime = _vm->getTime(); #define FADE_SPEED 20 -#define SYNC (_ctx->curTime-m_FadeTime) / 25 +#define SYNC (_ctx->curTime - _FadeTime) / 25 - if (m_bExit) + if (_bExit) return; - if (m_FadeStep == 1) { + if (_FadeStep == 1) { // Downhill fast - if (m_FadeTime == -1) - m_FadeY += FADE_SPEED; + if (_FadeTime == -1) + _FadeY += FADE_SPEED; else - m_FadeY += FADE_SPEED * SYNC; - if (m_FadeY > 480) { - m_FadeY = 480; - m_FadeStep++; + _FadeY += FADE_SPEED * SYNC; + if (_FadeY > 480) { + _FadeY = 480; + _FadeStep++; } // Set the part to draw the scrolling - prim->setSrc(RMRect(0, 480 - m_FadeY, 640, 480)); + prim->setSrc(RMRect(0, 480 - _FadeY, 640, 480)); - } else if (m_FadeStep == 2) { + } else if (_FadeStep == 2) { // Bounce 1 - m_FadeY -= FADE_SPEED / 2 * SYNC; - if (m_FadeY < 400) { - m_FadeY = 400; - m_FadeStep++; + _FadeY -= FADE_SPEED / 2 * SYNC; + if (_FadeY < 400) { + _FadeY = 400; + _FadeStep++; } - prim->setSrc(RMRect(0, 480 - m_FadeY, 640, 480)); + prim->setSrc(RMRect(0, 480 - _FadeY, 640, 480)); - } else if (m_FadeStep == 3) { - m_FadeY -= FADE_SPEED / 4 * SYNC; - if (m_FadeY < 380) { - m_FadeY = 380; - m_FadeStep++; + } else if (_FadeStep == 3) { + _FadeY -= FADE_SPEED / 4 * SYNC; + if (_FadeY < 380) { + _FadeY = 380; + _FadeStep++; } - prim->setSrc(RMRect(0, 480 - m_FadeY, 640, 480)); + prim->setSrc(RMRect(0, 480 - _FadeY, 640, 480)); - } else if (m_FadeStep == 4) { + } else if (_FadeStep == 4) { // Bounce 1 - 2 - m_FadeY += FADE_SPEED / 3 * SYNC; - if (m_FadeY > 420) { - m_FadeY = 420; - m_FadeStep++; + _FadeY += FADE_SPEED / 3 * SYNC; + if (_FadeY > 420) { + _FadeY = 420; + _FadeStep++; } - prim->setSrc(RMRect(0, 480 - m_FadeY, 640, 480)); + prim->setSrc(RMRect(0, 480 - _FadeY, 640, 480)); - } else if (m_FadeStep == 5) { - m_FadeY += FADE_SPEED / 2 * SYNC; - if (m_FadeY > 480) { - m_FadeY = 480; - m_FadeStep++; + } else if (_FadeStep == 5) { + _FadeY += FADE_SPEED / 2 * SYNC; + if (_FadeY > 480) { + _FadeY = 480; + _FadeStep++; _vm->hideLocation(); } - prim->setSrc(RMRect(0, 480 - m_FadeY, 640, 480)); + prim->setSrc(RMRect(0, 480 - _FadeY, 640, 480)); - } else if (m_FadeStep == 6) { + } else if (_FadeStep == 6) { // Menu ON - } else if (m_FadeStep == 7) { + } else if (_FadeStep == 7) { // Menu OFF _vm->showLocation(); - m_FadeStep++; + _FadeStep++; - } else if (m_FadeStep == 8) { - m_FadeY -= FADE_SPEED * SYNC; - if (m_FadeY < 0) { - m_FadeY = 0; - m_FadeStep++; + } else if (_FadeStep == 8) { + _FadeY -= FADE_SPEED * SYNC; + if (_FadeY < 0) { + _FadeY = 0; + _FadeStep++; } - prim->setSrc(RMRect(0, 480 - m_FadeY, 640, 480)); + prim->setSrc(RMRect(0, 480 - _FadeY, 640, 480)); - } else if (m_FadeStep == 9) { + } else if (_FadeStep == 9) { // Hello hello! - m_bExit = true; - m_FadeStep = 0; + _bExit = true; + _FadeStep = 0; // Free memory - CloseState(); + closeState(); return; } else { - m_FadeStep = 0; + _FadeStep = 0; } - m_FadeTime = _ctx->curTime; + _FadeTime = _ctx->curTime; CORO_INVOKE_2(RMGfxWoodyBuffer::draw, bigBuf, prim); @@ -1376,14 +1380,14 @@ void RMOptionScreen::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive } void RMOptionScreen::removeThis(CORO_PARAM, bool &result) { - if (m_bExit) + if (_bExit) result = true; else result = false; } -bool RMOptionScreen::LoadThumbnailFromSaveState(int nState, byte *lpDestBuf, RMString &name, byte &diff) { +bool RMOptionScreen::loadThumbnailFromSaveState(int nState, byte *lpDestBuf, RMString &name, byte &diff) { Common::String buf; char namebuf[256]; int i; @@ -1466,23 +1470,23 @@ bool RMOptionScreen::LoadThumbnailFromSaveState(int nState, byte *lpDestBuf, RMS \****************************************************************************/ RMPointer::RMPointer() { - Common::fill(m_pointer, m_pointer + 16, (RMGfxSourceBuffer8 *)NULL); - Common::fill(m_specialPointer, m_specialPointer + 16, (RMItem *)NULL); + Common::fill(_pointer, _pointer + 16, (RMGfxSourceBuffer8 *)NULL); + Common::fill(_specialPointer, _specialPointer + 16, (RMItem *)NULL); } RMPointer::~RMPointer() { - Close(); + close(); } -void RMPointer::Init(void) { +void RMPointer::init(void) { int i; for (i = 0; i < 5; i++) { RMResRaw res(RES_P_GO + i); - m_pointer[i] = new RMGfxSourceBuffer8RLEByteAA; - m_pointer[i]->init(res, res.Width(), res.Height(), false); - m_pointer[i]->loadPaletteWA(RES_P_PAL); + _pointer[i] = new RMGfxSourceBuffer8RLEByteAA; + _pointer[i]->init(res, res.Width(), res.Height(), false); + _pointer[i]->loadPaletteWA(RES_P_PAL); } for (i = 0; i < 5; i++) { @@ -1490,34 +1494,34 @@ void RMPointer::Init(void) { RMDataStream ds; ds.OpenBuffer(res); - m_specialPointer[i] = new RMItem; - ds >> *m_specialPointer[i]; + _specialPointer[i] = new RMItem; + ds >> *_specialPointer[i]; } //m_hotspot[0].Set(19,5); - m_hotspot[0].Set(5, 1); - m_hotspot[1].Set(32, 28); - m_hotspot[2].Set(45, 23); - m_hotspot[3].Set(35, 25); - m_hotspot[4].Set(32, 28); + _hotspot[0].Set(5, 1); + _hotspot[1].Set(32, 28); + _hotspot[2].Set(45, 23); + _hotspot[3].Set(35, 25); + _hotspot[4].Set(32, 28); // Default=GO - m_nCurPointer = 0; - m_nCurSpecialPointer = 0; + _nCurPointer = 0; + _nCurSpecialPointer = 0; } -void RMPointer::Close(void) { +void RMPointer::close(void) { int i; for (i = 0; i < 5; i++) { - if (m_pointer[i] != NULL) { - delete m_pointer[i]; - m_pointer[i] = NULL; + if (_pointer[i] != NULL) { + delete _pointer[i]; + _pointer[i] = NULL; } - if (m_specialPointer[i] != NULL) { - delete m_specialPointer[i]; - m_specialPointer[i] = NULL; + if (_specialPointer[i] != NULL) { + delete _specialPointer[i]; + _specialPointer[i] = NULL; } } } @@ -1536,37 +1540,37 @@ void RMPointer::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim CORO_BEGIN_CODE(_ctx); // Check the pointer - _ctx->n = m_nCurPointer; + _ctx->n = _nCurPointer; if (_ctx->n == TA_COMBINE) _ctx->n = TA_USE; // Copy the destination coordinates in the primitive - prim->setDst(m_pos); + prim->setDst(_pos); - if (m_pos.x >= 0 && m_pos.y >= 0 && m_pos.x < RM_SX && m_pos.y < RM_SY) { + if (_pos.x >= 0 && _pos.y >= 0 && _pos.x < RM_SX && _pos.y < RM_SY) { // Call the Draw method of the poitner - prim->Dst() -= m_hotspot[_ctx->n]; + prim->Dst() -= _hotspot[_ctx->n]; - if (m_nCurSpecialPointer == 0) { - CORO_INVOKE_2(m_pointer[_ctx->n]->draw, bigBuf, prim); + if (_nCurSpecialPointer == 0) { + CORO_INVOKE_2(_pointer[_ctx->n]->draw, bigBuf, prim); } else { - if (m_nCurSpecialPointer == PTR_CUSTOM) - CORO_INVOKE_2(m_nCurCustomPointer->draw, bigBuf, prim); + if (_nCurSpecialPointer == PTR_CUSTOM) + CORO_INVOKE_2(_nCurCustomPointer->draw, bigBuf, prim); else // Call the draw on the special pointer - CORO_INVOKE_2(m_specialPointer[m_nCurSpecialPointer - 1]->draw, bigBuf, prim); + CORO_INVOKE_2(_specialPointer[_nCurSpecialPointer - 1]->draw, bigBuf, prim); } } CORO_END_CODE; } -void RMPointer::DoFrame(RMGfxTargetBuffer *bigBuf) { +void RMPointer::doFrame(RMGfxTargetBuffer *bigBuf) { // Add it to the list of primitives bigBuf->addPrim(new RMGfxPrimitive(this)); // If there is a special pointer, does DoFrame - if (m_nCurSpecialPointer != 0 && m_nCurSpecialPointer != PTR_CUSTOM) - m_specialPointer[m_nCurSpecialPointer - 1]->DoFrame(bigBuf, false); + if (_nCurSpecialPointer != 0 && _nCurSpecialPointer != PTR_CUSTOM) + _specialPointer[_nCurSpecialPointer - 1]->doFrame(bigBuf, false); } void RMPointer::removeThis(CORO_PARAM, bool &result) { @@ -1574,11 +1578,11 @@ void RMPointer::removeThis(CORO_PARAM, bool &result) { result = true; } -int RMPointer::CurAction(void) { - if (m_nCurSpecialPointer != 0) +int RMPointer::curAction(void) { + if (_nCurSpecialPointer != 0) return 0; - return m_nCurPointer; + return _nCurPointer; } } // End of namespace Tony diff --git a/engines/tony/game.h b/engines/tony/game.h index 5dbd81c079..34e99c369e 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -56,16 +56,16 @@ namespace Tony { class RMPointer : public RMGfxTask { private: - RMGfxSourceBuffer8 *m_pointer[16]; - RMPoint m_hotspot[16]; - RMPoint m_pos; + RMGfxSourceBuffer8 *_pointer[16]; + RMPoint _hotspot[16]; + RMPoint _pos; - RMItem *m_specialPointer[16]; + RMItem *_specialPointer[16]; - int m_nCurPointer; - int m_nCurSpecialPointer; + int _nCurPointer; + int _nCurSpecialPointer; - RMGfxSourceBuffer8 *m_nCurCustomPointer; + RMGfxSourceBuffer8 *_nCurCustomPointer; public: enum POINTER { @@ -84,13 +84,13 @@ public: virtual ~RMPointer(); // Initialisation - void Init(void); + void init(void); // Deinitialisation - void Close(void); + void close(void); // Process a frame - void DoFrame(RMGfxTargetBuffer *bigBuf); + void doFrame(RMGfxTargetBuffer *bigBuf); // Overloading of priorities int priority(); @@ -99,153 +99,153 @@ public: virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Sets the current co-ordinates - void SetCoord(const RMPoint &pt) { - m_pos = pt; + void setCoord(const RMPoint &pt) { + _pos = pt; } // Overloading of the method to see if rising from the list virtual void removeThis(CORO_PARAM, bool &result); // Sets a new action as current - void SetAction(RMTonyAction action) { - m_nCurPointer = action; + void setAction(RMTonyAction action) { + _nCurPointer = action; } // Sets a new pointer - void SetSpecialPointer(POINTER ptr) { - m_nCurSpecialPointer = ptr; - if (m_nCurSpecialPointer && m_nCurSpecialPointer != PTR_CUSTOM) - m_specialPointer[ptr - 1]->SetPattern(1); + void setSpecialPointer(POINTER ptr) { + _nCurSpecialPointer = ptr; + if (_nCurSpecialPointer && _nCurSpecialPointer != PTR_CUSTOM) + _specialPointer[ptr - 1]->SetPattern(1); } - POINTER GetSpecialPointer(void) { - return (POINTER)m_nCurSpecialPointer; + POINTER getSpecialPointer(void) { + return (POINTER)_nCurSpecialPointer; } // Set the new custom pointer - void SetCustomPointer(RMGfxSourceBuffer8 *ptr) { - m_nCurCustomPointer = ptr; + void setCustomPointer(RMGfxSourceBuffer8 *ptr) { + _nCurCustomPointer = ptr; } // Return the current action to be applied according to the pointer - int CurAction(void); + int curAction(void); }; class RMOptionButton: public RMGfxTaskSetPrior { public: - RMRect m_rect; - RMGfxSourceBuffer16 *m_buf; - bool m_bActive; - bool m_bHasGfx; - bool m_bDoubleState; + RMRect _rect; + RMGfxSourceBuffer16 *_buf; + bool _bActive; + bool _bHasGfx; + bool _bDoubleState; public: RMOptionButton(uint32 dwRes, RMPoint pt, bool bDoubleState = false); RMOptionButton(const RMRect &pt); virtual ~RMOptionButton(); - bool DoFrame(const RMPoint &mousePos, bool bLeftClick, bool bRightClick); + bool doFrame(const RMPoint &mousePos, bool bLeftClick, bool bRightClick); virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - void AddToList(RMGfxTargetBuffer &bigBuf); - bool IsActive() { - return m_bActive; + void addToList(RMGfxTargetBuffer &bigBuf); + bool isActive() { + return _bActive; } - void SetActiveState(bool bState) { - m_bActive = bState; + void setActiveState(bool bState) { + _bActive = bState; } }; class RMOptionSlide : public RMGfxTaskSetPrior { private: - RMOptionButton *m_PushLeft; - RMOptionButton *m_PushRight; - RMGfxSourceBuffer16 *m_SliderCenter; - RMGfxSourceBuffer16 *m_SliderLeft; - RMGfxSourceBuffer16 *m_SliderRight; - RMGfxSourceBuffer16 *m_SliderSingle; - int m_nSlideSize; - RMPoint m_pos; - int m_nValue; - int m_nMax; - int m_nStep; + RMOptionButton *_PushLeft; + RMOptionButton *_PushRight; + RMGfxSourceBuffer16 *_SliderCenter; + RMGfxSourceBuffer16 *_SliderLeft; + RMGfxSourceBuffer16 *_SliderRight; + RMGfxSourceBuffer16 *_SliderSingle; + int _nSlideSize; + RMPoint _pos; + int _nValue; + int _nMax; + int _nStep; public: RMOptionSlide(const RMPoint &pt, int m_nRange = 100, int m_nStartValue = 0, int slideSize = 300); virtual ~RMOptionSlide(); - bool DoFrame(const RMPoint &mousePos, bool bLeftClick, bool bRightClick); + bool doFrame(const RMPoint &mousePos, bool bLeftClick, bool bRightClick); virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - void AddToList(RMGfxTargetBuffer &bigBuf); + void addToList(RMGfxTargetBuffer &bigBuf); - int GetValue() { - return m_nValue; + int getValue() { + return _nValue; } }; class RMOptionScreen : public RMGfxWoodyBuffer { private: - RMGfxSourceBuffer16 *m_menu; - RMGfxSourceBuffer16 *m_QuitConfirm; - RMGfxSourceBuffer16 *m_HideLoadSave; - RMOptionButton *m_ButtonQuitYes; - RMOptionButton *m_ButtonQuitNo; - RMOptionButton *m_ButtonExit; - RMOptionButton *m_ButtonQuit; - RMOptionButton *m_ButtonLoad; - RMOptionButton *m_ButtonSave; - RMOptionButton *m_ButtonGameMenu; - RMOptionButton *m_ButtonGfxMenu; - RMOptionButton *m_ButtonSoundMenu; - RMGfxSourceBuffer8 *m_SaveEasy; - RMGfxSourceBuffer8 *m_SaveHard; - RMGfxSourceBuffer16 *m_curThumb[6]; - RMString m_curThumbName[6]; - byte m_curThumbDiff[6]; - RMOptionButton *m_ButtonSave_States[6]; - RMOptionButton *m_ButtonSave_ArrowLeft; - RMOptionButton *m_ButtonSave_ArrowRight; - RMOptionButton *m_ButtonGfx_Tips; - - RMOptionButton *m_ButtonSound_DubbingOn; - RMOptionButton *m_ButtonSound_MusicOn; - RMOptionButton *m_ButtonSound_SFXOn; - - RMOptionSlide *m_SlideTonySpeed; - RMOptionSlide *m_SlideTextSpeed; - - - int m_statePos; - bool m_bEditSaveName; - int m_nEditPos; - char m_EditName[256]; + RMGfxSourceBuffer16 *_menu; + RMGfxSourceBuffer16 *_QuitConfirm; + RMGfxSourceBuffer16 *_HideLoadSave; + RMOptionButton *_ButtonQuitYes; + RMOptionButton *_ButtonQuitNo; + RMOptionButton *_ButtonExit; + RMOptionButton *_ButtonQuit; + RMOptionButton *_ButtonLoad; + RMOptionButton *_ButtonSave; + RMOptionButton *_ButtonGameMenu; + RMOptionButton *_ButtonGfxMenu; + RMOptionButton *_ButtonSoundMenu; + RMGfxSourceBuffer8 *_SaveEasy; + RMGfxSourceBuffer8 *_SaveHard; + RMGfxSourceBuffer16 *_curThumb[6]; + RMString _curThumbName[6]; + byte _curThumbDiff[6]; + RMOptionButton *_ButtonSave_States[6]; + RMOptionButton *_ButtonSave_ArrowLeft; + RMOptionButton *_ButtonSave_ArrowRight; + RMOptionButton *_ButtonGfx_Tips; + + RMOptionButton *_ButtonSound_DubbingOn; + RMOptionButton *_ButtonSound_MusicOn; + RMOptionButton *_ButtonSound_SFXOn; + + RMOptionSlide *_SlideTonySpeed; + RMOptionSlide *_SlideTextSpeed; + + + int _statePos; + bool _bEditSaveName; + int _nEditPos; + char _EditName[256]; union { - RMOptionButton *m_ButtonGame_Lock; - RMOptionButton *m_ButtonGfx_Anni30; - RMOptionSlide *m_SliderSound_Music; + RMOptionButton *_ButtonGame_Lock; + RMOptionButton *_ButtonGfx_Anni30; + RMOptionSlide *_SliderSound_Music; }; union { - RMOptionButton *m_ButtonGame_TimerizedText; - RMOptionButton *m_ButtonGfx_AntiAlias; - RMOptionSlide *m_SliderSound_SFX; + RMOptionButton *_ButtonGame_TimerizedText; + RMOptionButton *_ButtonGfx_AntiAlias; + RMOptionSlide *_SliderSound_SFX; }; union { - RMOptionButton *m_ButtonGame_Scrolling; - RMOptionButton *m_ButtonGfx_Sottotitoli; - RMOptionSlide *m_SliderSound_Dubbing; + RMOptionButton *_ButtonGame_Scrolling; + RMOptionButton *_ButtonGfx_Sottotitoli; + RMOptionSlide *_SliderSound_Dubbing; }; union { - RMOptionButton *m_ButtonGame_InterUp; - RMOptionButton *m_ButtonGfx_Trans; + RMOptionButton *_ButtonGame_InterUp; + RMOptionButton *_ButtonGfx_Trans; }; - int m_FadeStep; - bool m_bExit; - bool m_bQuitConfirm; - int m_FadeY; - int m_FadeTime; - bool m_bLoadMenuOnly; - bool m_bNoLoadSave; - bool m_bAlterGfx; + int _FadeStep; + bool _bExit; + bool _bQuitConfirm; + int _FadeY; + int _FadeTime; + bool _bLoadMenuOnly; + bool _bNoLoadSave; + bool _bAlterGfx; enum STATE { MENUGAME, @@ -256,20 +256,20 @@ private: MENUNONE }; - STATE m_nState; - STATE m_nLastState; + STATE _nState; + STATE _nLastState; public: RMOptionScreen(); virtual ~RMOptionScreen(); - void Init(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool &result); - void InitLoadMenuOnly(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool bAlternateGfx, bool &result); - void InitSaveMenuOnly(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool bAlternateGfx, bool &result); - void InitNoLoadSave(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool &result); - void ReInit(RMGfxTargetBuffer &bigBuf); - bool Close(); - bool IsClosing(); + void init(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool &result); + void initLoadMenuOnly(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool bAlternateGfx, bool &result); + void initSaveMenuOnly(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool bAlternateGfx, bool &result); + void initNoLoadSave(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool &result); + void reInit(RMGfxTargetBuffer &bigBuf); + bool close(); + bool isClosing(); // Overloaded methods virtual int priority(); @@ -277,21 +277,21 @@ public: virtual void removeThis(CORO_PARAM, bool &result); // Polling for the option screen - void DoFrame(CORO_PARAM, RMInput *m_input); + void doFrame(CORO_PARAM, RMInput *m_input); // Retrieves a savegame's thumbnail, description, and difficulty level - static bool LoadThumbnailFromSaveState(int numState, byte *lpDestBuf, RMString &name, byte &diff); + static bool loadThumbnailFromSaveState(int numState, byte *lpDestBuf, RMString &name, byte &diff); protected: // Initialisation and state change - void InitState(CORO_PARAM); - void CloseState(void); - void ChangeState(CORO_PARAM, STATE newState); + void initState(CORO_PARAM); + void closeState(void); + void changeState(CORO_PARAM, STATE newState); // Repaint the options menu - void RefreshAll(CORO_PARAM); - void RefreshThumbnails(void); + void refreshAll(CORO_PARAM); + void refreshThumbnails(void); }; } // End of namespace Tony diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 2d1c0663a6..ca7e645825 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -98,15 +98,15 @@ void RMGfxEngine::openOptionScreen(CORO_PARAM, int type) { _ctx->bRes = false; if (type == 0) - CORO_INVOKE_2(_opt.Init, _bigBuf, _ctx->bRes); + CORO_INVOKE_2(_opt.init, _bigBuf, _ctx->bRes); else if (type == 1) - CORO_INVOKE_3(_opt.InitLoadMenuOnly, _bigBuf, true, _ctx->bRes); + CORO_INVOKE_3(_opt.initLoadMenuOnly, _bigBuf, true, _ctx->bRes); else if (type == 2) - CORO_INVOKE_2(_opt.InitNoLoadSave, _bigBuf, _ctx->bRes); + CORO_INVOKE_2(_opt.initNoLoadSave, _bigBuf, _ctx->bRes); else if (type == 3) - CORO_INVOKE_3(_opt.InitLoadMenuOnly, _bigBuf, false, _ctx->bRes); + CORO_INVOKE_3(_opt.initLoadMenuOnly, _bigBuf, false, _ctx->bRes); else if (type == 4) - CORO_INVOKE_3(_opt.InitSaveMenuOnly, _bigBuf, false, _ctx->bRes); + CORO_INVOKE_3(_opt.initSaveMenuOnly, _bigBuf, false, _ctx->bRes); if (_ctx->bRes) { _vm->pauseSound(true); @@ -115,9 +115,9 @@ void RMGfxEngine::openOptionScreen(CORO_PARAM, int type) { _inv.EndCombine(); _curActionObj = 0; _curAction = TA_GOTO; - _point.SetAction(_curAction); - _point.SetSpecialPointer(RMPointer::PTR_NONE); - _point.SetCustomPointer(NULL); + _point.setAction(_curAction); + _point.setSpecialPointer(RMPointer::PTR_NONE); + _point.setCustomPointer(NULL); enableMouse(); _vm->grabThumbnail(); @@ -155,8 +155,8 @@ void RMGfxEngine::doFrame(CORO_PARAM, bool bDrawLocation) { } if (_bOption) { - CORO_INVOKE_1(_opt.DoFrame, &_input); - _bOption = !_opt.IsClosing(); + CORO_INVOKE_1(_opt.doFrame, &_input); + _bOption = !_opt.isClosing(); if (!_bOption) { disableMouse(); enableInput(); @@ -167,7 +167,7 @@ void RMGfxEngine::doFrame(CORO_PARAM, bool bDrawLocation) { if (bDrawLocation && _bLocationLoaded) { // Location and objects - _loc.DoFrame(&_bigBuf); + _loc.doFrame(&_bigBuf); // Check the mouse input if (_bInput && !_tony.InAction()) { @@ -179,7 +179,7 @@ void RMGfxEngine::doFrame(CORO_PARAM, bool bDrawLocation) { // Left click activates the combine, if we are on an object if (_inv.LeftClick(_input.mousePos(), _curActionObj)) { _curAction = TA_COMBINE; - _point.SetAction(_curAction); + _point.setAction(_curAction); } } else @@ -200,7 +200,7 @@ void RMGfxEngine::doFrame(CORO_PARAM, bool bDrawLocation) { CORO_INVOKE_3(_tony.MoveAndDoAction, _itemName.GetHotspot(), _itemName.GetSelectedItem(), _curAction); _curAction = TA_GOTO; - _point.SetAction(_curAction); + _point.setAction(_curAction); } } } else { @@ -229,17 +229,17 @@ void RMGfxEngine::doFrame(CORO_PARAM, bool bDrawLocation) { if (_input.mouseLeftClicked() && !_inter.Active()) { if (_curAction != TA_COMBINE) - CORO_INVOKE_3(_tony.MoveAndDoAction, _itemName.GetHotspot(), _itemName.GetSelectedItem(), _point.CurAction()); + CORO_INVOKE_3(_tony.MoveAndDoAction, _itemName.GetHotspot(), _itemName.GetSelectedItem(), _point.curAction()); else if (_itemName.GetSelectedItem() != NULL) CORO_INVOKE_4(_tony.MoveAndDoAction, _itemName.GetHotspot(), _itemName.GetSelectedItem(), TA_COMBINE, _curActionObj); if (_curAction == TA_COMBINE) { _inv.EndCombine(); - _point.SetSpecialPointer(RMPointer::PTR_NONE); + _point.setSpecialPointer(RMPointer::PTR_NONE); } _curAction = TA_GOTO; - _point.SetAction(_curAction); + _point.setAction(_curAction); } SKIPCLICKSINISTRO: @@ -251,15 +251,15 @@ SKIPCLICKSINISTRO: _inv.EndCombine(); _curActionObj = 0; _curAction = TA_GOTO; - _point.SetAction(_curAction); - _point.SetSpecialPointer(RMPointer::PTR_NONE); + _point.setAction(_curAction); + _point.setSpecialPointer(RMPointer::PTR_NONE); } - } else if (_input.mouseRightClicked() && _itemName.IsItemSelected() && _point.GetSpecialPointer() == RMPointer::PTR_NONE) { + } else if (_input.mouseRightClicked() && _itemName.IsItemSelected() && _point.getSpecialPointer() == RMPointer::PTR_NONE) { if (_bGUIInterface) { // Before opening the interface, replaces GOTO _curAction = TA_GOTO; _curActionObj = 0; - _point.SetAction(_curAction); + _point.setAction(_curAction); _inter.Clicked(_input.mousePos()); } } @@ -270,11 +270,11 @@ SKIPCLICKSINISTRO: if (_input.mouseRightReleased()) { if (_bGUIInterface) { if (_inter.Released(_input.mousePos(), _curAction)) { - _point.SetAction(_curAction); + _point.setAction(_curAction); CORO_INVOKE_3(_tony.MoveAndDoAction, _itemName.GetHotspot(), _itemName.GetSelectedItem(), _curAction); _curAction = TA_GOTO; - _point.SetAction(_curAction); + _point.setAction(_curAction); } } } @@ -305,8 +305,8 @@ SKIPCLICKSINISTRO: _tony.SetScrollPosition(_loc.ScrollPosition()); if ((!_tony.InAction() && _bInput) || _bAlwaysDrawMouse) { - _point.SetCoord(_input.mousePos()); - _point.DoFrame(&_bigBuf); + _point.setCoord(_input.mousePos()); + _point.doFrame(&_bigBuf); } // ********************** @@ -393,9 +393,9 @@ void RMGfxEngine::initForNewLocation(int nLoc, RMPoint ptTonyStart, RMPoint star } _curAction = TA_GOTO; - _point.SetCustomPointer(NULL); - _point.SetSpecialPointer(RMPointer::PTR_NONE); - _point.SetAction(_curAction); + _point.setCustomPointer(NULL); + _point.setSpecialPointer(RMPointer::PTR_NONE); + _point.setAction(_curAction); _inter.Reset(); _inv.Reset(); @@ -425,7 +425,7 @@ uint32 RMGfxEngine::loadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { error("Location was not loaded"); if (_bOption) - _opt.ReInit(_bigBuf); + _opt.reInit(_bigBuf); _bLocationLoaded = true; @@ -499,7 +499,7 @@ void RMGfxEngine::init() { _input.init(); // Initialise the mouse pointer - _point.Init(); + _point.init(); // Initialise Tony _tony.init(); @@ -524,7 +524,7 @@ void RMGfxEngine::close(void) { _inter.Close(); _inv.Close(); _tony.Close(); - _point.Close(); + _point.close(); _input.close(); } diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index a660ad736e..cd302f8259 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -110,7 +110,7 @@ void RMInventory::Init(void) { m_items[i].pointer = NULL; m_items[i].status = 1; m_items[i].icon.SetPattern(1); - m_items[i].icon.DoFrame(this, false); + m_items[i].icon.doFrame(this, false); curres++; if (i == 0 || i == 28 || i == 29) continue; @@ -489,7 +489,7 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo // DoFrame makes all the objects currently in the inventory be displayed // @@@ Maybe we should do all takeable objects? Please does not help for (i = 0; i < m_nInv; i++) - if (m_items[m_inv[i]].icon.DoFrame(this, false) && (i >= m_curPos && i <= m_curPos + 7)) + if (m_items[m_inv[i]].icon.doFrame(this, false) && (i >= m_curPos && i <= m_curPos + 7)) bNeedRedraw = true; if ((m_state == CLOSING || m_state == OPENING || m_state == OPENED) && CheckPointInside(mpos)) { @@ -518,10 +518,10 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo } } - if (m_items[28].icon.DoFrame(this, false)) + if (m_items[28].icon.doFrame(this, false)) bNeedRedraw = true; - if (m_items[29].icon.DoFrame(this, false)) + if (m_items[29].icon.doFrame(this, false)) bNeedRedraw = true; if (bNeedRedraw) @@ -535,8 +535,8 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo } if (m_bCombining) {//m_state == COMBINING) - ptr.SetCustomPointer(&m_items[m_nCombine].pointer[m_items[m_nCombine].status - 1]); - ptr.SetSpecialPointer(RMPointer::PTR_CUSTOM); + ptr.setCustomPointer(&m_items[m_nCombine].pointer[m_items[m_nCombine].status - 1]); + ptr.setSpecialPointer(RMPointer::PTR_CUSTOM); } if (!GLOBALS.bCfgInvUp) { @@ -659,7 +659,7 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo } // Update the mini-interface - miniInterface.DoFrame(&bigBuf, false); + miniInterface.doFrame(&bigBuf, false); } if ((m_state != CLOSED) && !_nInList) { diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 6ede99b57d..ae34c577aa 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -647,7 +647,7 @@ void RMItem::SetScrollPosition(const RMPoint &scroll) { m_curScroll = scroll; } -bool RMItem::DoFrame(RMGfxTargetBuffer *bigBuf, bool bAddToList) { +bool RMItem::doFrame(RMGfxTargetBuffer *bigBuf, bool bAddToList) { int oldSprite = m_nCurSprite; // Pattern 0 = Do not draw anything! @@ -924,7 +924,7 @@ void RMWipe::DoFrame(RMGfxTargetBuffer &bigBuf) { } if (m_bFading) { - m_wip0r.DoFrame(&bigBuf, false); + m_wip0r.doFrame(&bigBuf, false); m_nFadeStep++; @@ -1499,7 +1499,7 @@ void RMCharacter::DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc) { g_system->unlockMutex(csMove); // Invoke the DoFrame of the item - RMItem::DoFrame(bigBuf); + RMItem::doFrame(bigBuf); CORO_END_CODE; } @@ -2161,7 +2161,7 @@ void RMLocation::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri /** * Prepare a frame, adding the location to the OT list, and all the items that have changed animation frame. */ -void RMLocation::DoFrame(RMGfxTargetBuffer *bigBuf) { +void RMLocation::doFrame(RMGfxTargetBuffer *bigBuf) { int i; // If the location is not in the OT list, add it in @@ -2170,7 +2170,7 @@ void RMLocation::DoFrame(RMGfxTargetBuffer *bigBuf) { // Process all the location items for (i = 0; i < m_nItems; i++) - m_items[i].DoFrame(bigBuf); + m_items[i].doFrame(bigBuf); } diff --git a/engines/tony/loc.h b/engines/tony/loc.h index 282ea0fa4a..abcdcb85a2 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -245,7 +245,7 @@ public: // Process to make the object move on any animations. // Returns TRUE if it should be redrawn on the next frame - bool DoFrame(RMGfxTargetBuffer *bigBuf, bool bAddToList = true); + bool doFrame(RMGfxTargetBuffer *bigBuf, bool bAddToList = true); // Sets the current scrolling position void SetScrollPosition(const RMPoint &scroll); @@ -569,7 +569,7 @@ public: virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Prepare a frame by drawing the location and all it's items - void DoFrame(RMGfxTargetBuffer *bigBuf); + void doFrame(RMGfxTargetBuffer *bigBuf); // Return the item at a given point RMItem *WhichItemIsIn(const RMPoint &pt); diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index f135cff7c3..8bca6fe7f6 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -156,7 +156,7 @@ void RMTony::DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int curLoc) { } if (m_bIsTalking || m_bIsStaticTalk) - m_body.DoFrame(bigBuf, false); + m_body.doFrame(bigBuf, false); CORO_END_CODE; } -- cgit v1.2.3 From f1ac5d5acdbc0349850377619d8056be22871b42 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 6 Jun 2012 08:04:33 +0200 Subject: TONY: More renaming --- engines/tony/custom.cpp | 170 +++++++++--------- engines/tony/font.cpp | 434 ++++++++++++++++++++++----------------------- engines/tony/font.h | 160 ++++++++--------- engines/tony/game.cpp | 8 +- engines/tony/gfxengine.cpp | 28 +-- engines/tony/inventory.cpp | 65 ++++--- engines/tony/inventory.h | 10 +- engines/tony/tony.cpp | 14 +- engines/tony/window.cpp | 40 ++--- engines/tony/window.h | 30 ++-- 10 files changed, 479 insertions(+), 480 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 24caaa1e29..84bafc2cd1 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -297,32 +297,32 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX } if (GLOBALS.curBackText) - CORO_INVOKE_0(GLOBALS.curBackText->Hide); + CORO_INVOKE_0(GLOBALS.curBackText->hide); GLOBALS.bTonyIsSpeaking = true; for (_ctx->i = 0; _ctx->i < _ctx->msg.NumPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { - _ctx->text.SetInput(GLOBALS.Input); + _ctx->text.setInput(GLOBALS.Input); // Alignment - _ctx->text.SetAlignType(RMText::HCENTER, RMText::VBOTTOM); + _ctx->text.setAlignType(RMText::HCENTER, RMText::VBOTTOM); // Colour - _ctx->text.SetColor(0, 255, 0); + _ctx->text.setColor(0, 255, 0); // Writes the text - _ctx->text.WriteText(_ctx->msg[_ctx->i], 0); + _ctx->text.writeText(_ctx->msg[_ctx->i], 0); // Set the position if (nX == 0 && nY == 0) - _ctx->text.SetPosition(GLOBALS.Tony->Position() - RMPoint(0, 130) - GLOBALS.Loc->ScrollPosition()); + _ctx->text.setPosition(GLOBALS.Tony->Position() - RMPoint(0, 130) - GLOBALS.Loc->ScrollPosition()); else - _ctx->text.SetPosition(RMPoint(nX, nY) - GLOBALS.Loc->ScrollPosition()); + _ctx->text.setPosition(RMPoint(nX, nY) - GLOBALS.Loc->ScrollPosition()); // Handling for always display if (GLOBALS.bAlwaysDisplay) { - _ctx->text.SetAlwaysDisplay(); - _ctx->text.ForceTime(); + _ctx->text.setAlwaysDisplay(); + _ctx->text.forceTime(); } // Record the text @@ -331,7 +331,7 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX if (_ctx->curVoc) { if (_ctx->i == 0) { _ctx->voice->Play(); - _ctx->text.SetCustomSkipHandle2(_ctx->voice->hEndOfBuffer); + _ctx->text.setCustomSkipHandle2(_ctx->voice->hEndOfBuffer); } else { _vm->_vdbFP.seek(_ctx->curOffset); _vm->_theSound.CreateSfx(&_ctx->voice); @@ -340,13 +340,13 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX _ctx->curOffset = _vm->_vdbFP.pos(); _ctx->voice->SetLoop(false); _ctx->voice->Play(); - _ctx->text.SetCustomSkipHandle2(_ctx->voice->hEndOfBuffer); + _ctx->text.setCustomSkipHandle2(_ctx->voice->hEndOfBuffer); } } // Wait for the end of the display - _ctx->text.SetCustomSkipHandle(GLOBALS.hSkipIdle); - CORO_INVOKE_0(_ctx->text.WaitForEndDisplay); + _ctx->text.setCustomSkipHandle(GLOBALS.hSkipIdle); + CORO_INVOKE_0(_ctx->text.waitForEndDisplay); if (_ctx->curVoc) { _ctx->voice->Stop(); @@ -357,7 +357,7 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX GLOBALS.bTonyIsSpeaking = false; if (GLOBALS.curBackText) - GLOBALS.curBackText->Show(); + GLOBALS.curBackText->show(); CORO_INVOKE_0(GLOBALS.Tony->EndTalk); @@ -418,36 +418,36 @@ DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgStart)(CORO_PARAM, uint32 nMsg, uint32 GLOBALS.Unfreeze(); for (_ctx->i = 0; _ctx->i < _ctx->msg->NumPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { - _ctx->text.SetInput(GLOBALS.Input); + _ctx->text.setInput(GLOBALS.Input); // Alignment - _ctx->text.SetAlignType(RMText::HCENTER, RMText::VCENTER); + _ctx->text.setAlignType(RMText::HCENTER, RMText::VCENTER); // Forces the text to disappear in time - _ctx->text.ForceTime(); + _ctx->text.forceTime(); // Colour - _ctx->text.SetColor(255, 255, 255); + _ctx->text.setColor(255, 255, 255); // Write the text if (nFont == 0) - _ctx->text.WriteText((*_ctx->msg)[_ctx->i], 1); + _ctx->text.writeText((*_ctx->msg)[_ctx->i], 1); else if (nFont == 1) - _ctx->text.WriteText((*_ctx->msg)[_ctx->i], 0); + _ctx->text.writeText((*_ctx->msg)[_ctx->i], 0); // Set the position - _ctx->text.SetPosition(RMPoint(320, 240)); + _ctx->text.setPosition(RMPoint(320, 240)); - _ctx->text.SetAlwaysDisplay(); - _ctx->text.ForceTime(); + _ctx->text.setAlwaysDisplay(); + _ctx->text.forceTime(); // Record the text GLOBALS.LinkGraphicTask(&_ctx->clear); GLOBALS.LinkGraphicTask(&_ctx->text); // Wait for the end of display - _ctx->text.SetCustomSkipHandle(GLOBALS.hSkipIdle); - CORO_INVOKE_0(_ctx->text.WaitForEndDisplay); + _ctx->text.setCustomSkipHandle(GLOBALS.hSkipIdle); + CORO_INVOKE_0(_ctx->text.waitForEndDisplay); } delete _ctx->msg; @@ -1487,31 +1487,31 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess if (bIsBack) { GLOBALS.curBackText = _ctx->text = new RMTextDialogScrolling(GLOBALS.Loc); if (GLOBALS.bTonyIsSpeaking) - CORO_INVOKE_0(GLOBALS.curBackText->Hide); + CORO_INVOKE_0(GLOBALS.curBackText->hide); } else _ctx->text = new RMTextDialog; - _ctx->text->SetInput(GLOBALS.Input); + _ctx->text->setInput(GLOBALS.Input); // Skipping - _ctx->text->SetSkipStatus(!bIsBack); + _ctx->text->setSkipStatus(!bIsBack); // Alignment - _ctx->text->SetAlignType(RMText::HCENTER, RMText::VBOTTOM); + _ctx->text->setAlignType(RMText::HCENTER, RMText::VBOTTOM); // Colour - _ctx->text->SetColor(GLOBALS.Character[nChar].r, GLOBALS.Character[nChar].g, GLOBALS.Character[nChar].b); + _ctx->text->setColor(GLOBALS.Character[nChar].r, GLOBALS.Character[nChar].g, GLOBALS.Character[nChar].b); // Write the text - _ctx->text->WriteText((*_ctx->msg)[_ctx->i], 0); + _ctx->text->writeText((*_ctx->msg)[_ctx->i], 0); // Set the position - _ctx->text->SetPosition(_ctx->pt); + _ctx->text->setPosition(_ctx->pt); // Set the always display if (GLOBALS.bAlwaysDisplay) { - _ctx->text->SetAlwaysDisplay(); - _ctx->text->ForceTime(); + _ctx->text->setAlwaysDisplay(); + _ctx->text->forceTime(); } // Record the text @@ -1524,13 +1524,13 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess _ctx->voice->SetLoop(false); if (bIsBack) _ctx->voice->SetVolume(55); _ctx->voice->Play(); - _ctx->text->SetCustomSkipHandle2(_ctx->voice->hEndOfBuffer); + _ctx->text->setCustomSkipHandle2(_ctx->voice->hEndOfBuffer); _ctx->curOffset = _vm->_vdbFP.pos(); } // Wait for the end of display - _ctx->text->SetCustomSkipHandle(GLOBALS.hSkipIdle); - CORO_INVOKE_0(_ctx->text->WaitForEndDisplay); + _ctx->text->setCustomSkipHandle(GLOBALS.hSkipIdle); + CORO_INVOKE_0(_ctx->text->waitForEndDisplay); if (_ctx->curVoc) { _ctx->voice->Stop(); @@ -1700,31 +1700,31 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes if (bIsBack) { GLOBALS.curBackText = _ctx->text = new RMTextDialogScrolling(GLOBALS.Loc); if (GLOBALS.bTonyIsSpeaking) - CORO_INVOKE_0(GLOBALS.curBackText->Hide); + CORO_INVOKE_0(GLOBALS.curBackText->hide); } else _ctx->text = new RMTextDialog; - _ctx->text->SetInput(GLOBALS.Input); + _ctx->text->setInput(GLOBALS.Input); // Skipping - _ctx->text->SetSkipStatus(!bIsBack); + _ctx->text->setSkipStatus(!bIsBack); // Alignment - _ctx->text->SetAlignType(RMText::HCENTER, RMText::VBOTTOM); + _ctx->text->setAlignType(RMText::HCENTER, RMText::VBOTTOM); // Colour - _ctx->text->SetColor(GLOBALS.MCharacter[nChar].r, GLOBALS.MCharacter[nChar].g, GLOBALS.MCharacter[nChar].b); + _ctx->text->setColor(GLOBALS.MCharacter[nChar].r, GLOBALS.MCharacter[nChar].g, GLOBALS.MCharacter[nChar].b); // Write the text - _ctx->text->WriteText((*_ctx->msg)[_ctx->i], nFont); + _ctx->text->writeText((*_ctx->msg)[_ctx->i], nFont); // Set the position - _ctx->text->SetPosition(_ctx->pt); + _ctx->text->setPosition(_ctx->pt); // Set the always display if (GLOBALS.bAlwaysDisplay) { - _ctx->text->SetAlwaysDisplay(); - _ctx->text->ForceTime(); + _ctx->text->setAlwaysDisplay(); + _ctx->text->forceTime(); } // Record the text @@ -1737,13 +1737,13 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes _ctx->voice->SetLoop(false); if (bIsBack) _ctx->voice->SetVolume(55); _ctx->voice->Play(); - _ctx->text->SetCustomSkipHandle2(_ctx->voice->hEndOfBuffer); + _ctx->text->setCustomSkipHandle2(_ctx->voice->hEndOfBuffer); _ctx->curOffset = _vm->_vdbFP.pos(); } // Wait for the end of display - _ctx->text->SetCustomSkipHandle(GLOBALS.hSkipIdle); - CORO_INVOKE_0(_ctx->text->WaitForEndDisplay); + _ctx->text->setCustomSkipHandle(GLOBALS.hSkipIdle); + CORO_INVOKE_0(_ctx->text->waitForEndDisplay); if (_ctx->curVoc) { _ctx->voice->Stop(); @@ -1814,9 +1814,9 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg if (nPers == 0) { _ctx->text = new RMTextDialog; - _ctx->text->SetColor(0, 255, 0); - _ctx->text->SetPosition(GLOBALS.Tony->Position() - RMPoint(0, 130) - GLOBALS.Loc->ScrollPosition()); - _ctx->text->WriteText(_ctx->string, 0); + _ctx->text->setColor(0, 255, 0); + _ctx->text->setPosition(GLOBALS.Tony->Position() - RMPoint(0, 130) - GLOBALS.Loc->ScrollPosition()); + _ctx->text->writeText(_ctx->string, 0); if (GLOBALS.dwTonyNumTexts > 0) { if (!GLOBALS.bTonyInTexts) { @@ -1849,9 +1849,9 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg GLOBALS.Character[nPers].item->SetPattern(GLOBALS.Character[nPers].talkpattern); - _ctx->text->SetColor(GLOBALS.Character[nPers].r, GLOBALS.Character[nPers].g, GLOBALS.Character[nPers].b); - _ctx->text->WriteText(_ctx->string, 0); - _ctx->text->SetPosition(_ctx->pt); + _ctx->text->setColor(GLOBALS.Character[nPers].r, GLOBALS.Character[nPers].g, GLOBALS.Character[nPers].b); + _ctx->text->writeText(_ctx->string, 0); + _ctx->text->setPosition(_ctx->pt); } else { if (GLOBALS.MCharacter[nPers].x == -1) _ctx->pt = GLOBALS.MCharacter[nPers].item->CalculatePos() - RMPoint(-60, 20) - GLOBALS.Loc->ScrollPosition(); @@ -1881,35 +1881,35 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg if (GLOBALS.MCharacter[nPers].bAlwaysBack) { _ctx->text = GLOBALS.curBackText = new RMTextDialogScrolling(GLOBALS.Loc); if (GLOBALS.bTonyIsSpeaking) - CORO_INVOKE_0(GLOBALS.curBackText->Hide); + CORO_INVOKE_0(GLOBALS.curBackText->hide); _ctx->bIsBack = true; } else _ctx->text = new RMTextDialog; - _ctx->text->SetSkipStatus(!GLOBALS.MCharacter[nPers].bAlwaysBack); - _ctx->text->SetColor(GLOBALS.MCharacter[nPers].r, GLOBALS.MCharacter[nPers].g, GLOBALS.MCharacter[nPers].b); - _ctx->text->WriteText(_ctx->string, 0); - _ctx->text->SetPosition(_ctx->pt); + _ctx->text->setSkipStatus(!GLOBALS.MCharacter[nPers].bAlwaysBack); + _ctx->text->setColor(GLOBALS.MCharacter[nPers].r, GLOBALS.MCharacter[nPers].g, GLOBALS.MCharacter[nPers].b); + _ctx->text->writeText(_ctx->string, 0); + _ctx->text->setPosition(_ctx->pt); } if (!GLOBALS.bSkipIdle) { - _ctx->text->SetInput(GLOBALS.Input); + _ctx->text->setInput(GLOBALS.Input); if (GLOBALS.bAlwaysDisplay) { - _ctx->text->SetAlwaysDisplay(); - _ctx->text->ForceTime(); + _ctx->text->setAlwaysDisplay(); + _ctx->text->forceTime(); } - _ctx->text->SetAlignType(RMText::HCENTER, RMText::VBOTTOM); + _ctx->text->setAlignType(RMText::HCENTER, RMText::VBOTTOM); GLOBALS.LinkGraphicTask(_ctx->text); if (_ctx->curVoc) { _ctx->voice->Play(); - _ctx->text->SetCustomSkipHandle2(_ctx->voice->hEndOfBuffer); + _ctx->text->setCustomSkipHandle2(_ctx->voice->hEndOfBuffer); } // Wait for the end of display - _ctx->text->SetCustomSkipHandle(GLOBALS.hSkipIdle); - CORO_INVOKE_0(_ctx->text->WaitForEndDisplay); + _ctx->text->setCustomSkipHandle(GLOBALS.hSkipIdle); + CORO_INVOKE_0(_ctx->text->waitForEndDisplay); } if (_ctx->curVoc) { @@ -1999,39 +1999,39 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr // Making a choice for dialog _ctx->dc.init(); - _ctx->dc.SetNumChoices(_ctx->num); + _ctx->dc.setNumChoices(_ctx->num); // Writeall the possible options for (_ctx->i = 0; _ctx->i < _ctx->num; _ctx->i++) { _ctx->string = mpalQueryDialogPeriod(_ctx->sl[_ctx->i]); assert(_ctx->string != NULL); - _ctx->dc.AddChoice(_ctx->string); + _ctx->dc.addChoice(_ctx->string); GlobalFree(_ctx->string); } // Activate the object GLOBALS.LinkGraphicTask(&_ctx->dc); - CORO_INVOKE_0(_ctx->dc.Show); + CORO_INVOKE_0(_ctx->dc.show); // Draw the pointer GLOBALS.Pointer->setSpecialPointer(GLOBALS.Pointer->PTR_NONE); mainShowMouse(); - while (!(GLOBALS.Input->mouseLeftClicked() && ((_ctx->sel = _ctx->dc.GetSelection()) != -1))) { + while (!(GLOBALS.Input->mouseLeftClicked() && ((_ctx->sel = _ctx->dc.getSelection()) != -1))) { CORO_INVOKE_0(GLOBALS.WaitFrame); GLOBALS.Freeze(); - CORO_INVOKE_1(_ctx->dc.DoFrame, GLOBALS.Input->mousePos()); + CORO_INVOKE_1(_ctx->dc.doFrame, GLOBALS.Input->mousePos()); GLOBALS.Unfreeze(); } // Hide the pointer mainHideMouse(); - CORO_INVOKE_0(_ctx->dc.Hide); + CORO_INVOKE_0(_ctx->dc.hide); mpalQueryDialogSelectionDWORD(_ctx->nChoice, _ctx->sl[_ctx->sel]); // Closes the choice - _ctx->dc.Close(); + _ctx->dc.close(); GlobalFree(_ctx->sl); @@ -2328,27 +2328,27 @@ DECLARE_CUSTOM_FUNCTION(DoCredits)(CORO_PARAM, uint32 nMsg, uint32 dwTime, uint3 _ctx->text = new RMTextDialog[_ctx->msg->NumPeriods()]; for (_ctx->i = 0; _ctx->i < _ctx->msg->NumPeriods(); _ctx->i++) { - _ctx->text[_ctx->i].SetInput(GLOBALS.Input); + _ctx->text[_ctx->i].setInput(GLOBALS.Input); // Alignment if ((*_ctx->msg)[_ctx->i][0] == '@') { - _ctx->text[_ctx->i].SetAlignType(RMText::HCENTER, RMText::VTOP); - _ctx->text[_ctx->i].WriteText(&(*_ctx->msg)[_ctx->i][1], 3); - _ctx->text[_ctx->i].SetPosition(RMPoint(414, 70 + _ctx->i * 26)); // 70 + _ctx->text[_ctx->i].setAlignType(RMText::HCENTER, RMText::VTOP); + _ctx->text[_ctx->i].writeText(&(*_ctx->msg)[_ctx->i][1], 3); + _ctx->text[_ctx->i].setPosition(RMPoint(414, 70 + _ctx->i * 26)); // 70 } else { - _ctx->text[_ctx->i].SetAlignType(RMText::HLEFT, RMText::VTOP); - _ctx->text[_ctx->i].WriteText((*_ctx->msg)[_ctx->i], 3); - _ctx->text[_ctx->i].SetPosition(RMPoint(260, 70 + _ctx->i * 26)); + _ctx->text[_ctx->i].setAlignType(RMText::HLEFT, RMText::VTOP); + _ctx->text[_ctx->i].writeText((*_ctx->msg)[_ctx->i], 3); + _ctx->text[_ctx->i].setPosition(RMPoint(260, 70 + _ctx->i * 26)); } // Set the position - _ctx->text[_ctx->i].SetAlwaysDisplay(); - _ctx->text[_ctx->i].SetForcedTime(dwTime * 1000); - _ctx->text[_ctx->i].SetNoTab(); + _ctx->text[_ctx->i].setAlwaysDisplay(); + _ctx->text[_ctx->i].setForcedTime(dwTime * 1000); + _ctx->text[_ctx->i].setNoTab(); // Wait for the end of display - _ctx->text[_ctx->i].SetCustomSkipHandle(_ctx->hDisable); + _ctx->text[_ctx->i].setCustomSkipHandle(_ctx->hDisable); // Record the text GLOBALS.LinkGraphicTask(&_ctx->text[_ctx->i]); diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index e0eca3b4e2..e967f38199 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -41,11 +41,11 @@ namespace Tony { \****************************************************************************/ RMFont::RMFont() { - m_letter = NULL; + _letter = NULL; } RMFont::~RMFont() { - Unload(); + unload(); } @@ -63,53 +63,53 @@ void DumpFontBMP(const char *filename, const byte *buf, int nChars, int charX, i } -void RMFont::Load(const byte *buf, int nChars, int dimx, int dimy, uint32 palResID) { - m_letter = new RMGfxSourceBuffer8RLEByte[nChars]; +void RMFont::load(const byte *buf, int nChars, int dimx, int dimy, uint32 palResID) { + _letter = new RMGfxSourceBuffer8RLEByte[nChars]; // Initialise the fonts for (int i = 0; i < nChars; i++) { // Initialise the buffer with the letters - m_letter[i].init(buf + i * (dimx * dimy + 8) + 8, dimx, dimy); - m_letter[i].loadPaletteWA(palResID); + _letter[i].init(buf + i * (dimx * dimy + 8) + 8, dimx, dimy); + _letter[i].loadPaletteWA(palResID); } - m_fontDimx = dimx; - m_fontDimy = dimy; + _fontDimx = dimx; + _fontDimy = dimy; nLetters = nChars; } -void RMFont::Load(uint32 resID, int nChars, int dimx, int dimy, uint32 palResID) { +void RMFont::load(uint32 resID, int nChars, int dimx, int dimy, uint32 palResID) { RMRes res(resID); if ((int)res.Size() < nChars * (dimy * dimx + 8)) nChars = res.Size() / (dimy * dimx + 8); - Load(res, nChars, dimx, dimy, palResID); + load(res, nChars, dimx, dimy, palResID); } -void RMFont::Unload(void) { - if (m_letter != NULL) { - delete[] m_letter; - m_letter = NULL; +void RMFont::unload(void) { + if (_letter != NULL) { + delete[] _letter; + _letter = NULL; } } -RMGfxPrimitive *RMFont::MakeLetterPrimitive(byte bChar, int &nLength) { +RMGfxPrimitive *RMFont::makeLetterPrimitive(byte bChar, int &nLength) { RMFontPrimitive *prim; int nLett; // Convert from character to glyph index - nLett = ConvertToLetter(bChar); + nLett = convertToLetter(bChar); assert(nLett < nLetters); // Create primitive font prim = new RMFontPrimitive(this); - prim->m_nChar = nLett; + prim->_nChar = nLett; // Get the length of the character in pixels - nLength = LetterLength(bChar); + nLength = letterLength(bChar); return prim; } @@ -123,29 +123,29 @@ void RMFont::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim2) CORO_BEGIN_CODE(_ctx); // Call the draw method of the letter assigned to the primitive - if (prim->m_nChar != -1) - CORO_INVOKE_2(m_letter[prim->m_nChar].draw, bigBuf, prim); + if (prim->_nChar != -1) + CORO_INVOKE_2(_letter[prim->_nChar].draw, bigBuf, prim); CORO_END_CODE; } -void RMFont::Close(void) { - Unload(); +void RMFont::close(void) { + unload(); } -int RMFont::StringLen(const RMString &text) { +int RMFont::stringLen(const RMString &text) { int len, i; len = 0; for (i = 0; i < text.Length() - 1; i++) - len += LetterLength(text[i], text[i + 1]); - len += LetterLength(text[i]); + len += letterLength(text[i], text[i + 1]); + len += letterLength(text[i]); return len; } -int RMFont::StringLen(char bChar, char bNext) { - return LetterLength(bChar, bNext); +int RMFont::stringLen(char bChar, char bNext) { + return letterLength(bChar, bNext); } /****************************************************************************\ @@ -197,7 +197,7 @@ void RMFontColor::SetBaseColor(byte r1, byte g1, byte b1) { // Puts in all the letters for (i = 0; i < nLetters; i++) - m_letter[i].loadPaletteWA(pal); + _letter[i].loadPaletteWA(pal); } @@ -217,7 +217,7 @@ void RMFontParla::init(void) { + 8 // french + 5; // deutsch - Load(RES_F_PARL, nchars, 20, 20); + load(RES_F_PARL, nchars, 20, 20); // Initialise the f**king table lDefault = 13; @@ -625,7 +625,7 @@ void RMFontMacc::init(void) { + 5; // deutsch - Load(RES_F_MACC, nchars, 11, 16); + load(RES_F_MACC, nchars, 11, 16); // Default lDefault = 10; @@ -989,7 +989,7 @@ void RMFontCredits::init(void) { + 2; // deutsch - Load(RES_F_CREDITS, nchars, 27, 28, RES_F_CPAL); + load(RES_F_CREDITS, nchars, 27, 28, RES_F_CPAL); // Default lDefault = 10; @@ -1433,7 +1433,7 @@ void RMFontCredits::init(void) { #define TOUPPER(a) ((a) >= 'a' && (a) <= 'z' ? (a) + 'A' - 'a' : (a)) #define TOLOWER(a) ((a) >= 'A' && (a) <= 'Z' ? (a) + 'a' - 'A' : (a)) -void RMFontObj::SetBothCase(int nChar, int nNext, signed char spiazz) { +void RMFontObj::setBothCase(int nChar, int nNext, signed char spiazz) { l2Table[TOUPPER(nChar)][TOUPPER(nNext)] = spiazz; l2Table[TOUPPER(nChar)][TOLOWER(nNext)] = spiazz; l2Table[TOLOWER(nChar)][TOUPPER(nNext)] = spiazz; @@ -1454,7 +1454,7 @@ void RMFontObj::init(void) { + 1; // deutsch - Load(RES_F_OBJ, nchars, 25, 30); + load(RES_F_OBJ, nchars, 25, 30); // Initialise the f**king table lDefault = 26; @@ -1569,17 +1569,17 @@ void RMFontObj::init(void) { lTable[(byte)''] = 17; /* Casi particolari */ - SetBothCase('C', 'C', 2); - SetBothCase('A', 'T', -2); - SetBothCase('R', 'S', 2); - SetBothCase('H', 'I', -2); - SetBothCase('T', 'S', 2); - SetBothCase('O', 'R', 2); - SetBothCase('O', 'L', 2); - SetBothCase('O', 'G', 2); - SetBothCase('Z', 'A', -1); - SetBothCase('R', 'R', 1); - SetBothCase('R', 'U', 3); + setBothCase('C', 'C', 2); + setBothCase('A', 'T', -2); + setBothCase('R', 'S', 2); + setBothCase('H', 'I', -2); + setBothCase('T', 'S', 2); + setBothCase('O', 'R', 2); + setBothCase('O', 'L', 2); + setBothCase('O', 'G', 2); + setBothCase('Z', 'A', -1); + setBothCase('R', 'R', 1); + setBothCase('R', 'U', 3); if (_vm->getLanguage() == Common::PL_POL) { // Polish characters @@ -1760,11 +1760,11 @@ void RMFontObj::init(void) { * RMText Methods \****************************************************************************/ -RMFontColor *RMText::m_fonts[4] = { NULL, NULL, NULL, NULL }; -RMGfxClearTask RMText::m_clear; +RMFontColor *RMText::_fonts[4] = { NULL, NULL, NULL, NULL }; +RMGfxClearTask RMText::_clear; void RMText::initStatics() { - Common::fill(&m_fonts[0], &m_fonts[4], (RMFontColor *)NULL); + Common::fill(&_fonts[0], &_fonts[4], (RMFontColor *)NULL); } RMText::RMText() { @@ -1784,17 +1784,17 @@ RMText::~RMText() { } -void RMText::Unload() { - if (m_fonts[0] != NULL) { - delete m_fonts[0]; - delete m_fonts[1]; - delete m_fonts[2]; - delete m_fonts[3]; - m_fonts[0] = m_fonts[1] = m_fonts[2] = m_fonts[3] = 0; +void RMText::unload() { + if (_fonts[0] != NULL) { + delete _fonts[0]; + delete _fonts[1]; + delete _fonts[2]; + delete _fonts[3]; + _fonts[0] = _fonts[1] = _fonts[2] = _fonts[3] = 0; } } -void RMText::SetMaxLineLength(int max) { +void RMText::setMaxLineLength(int max) { maxLineLength = max; } @@ -1804,24 +1804,24 @@ void RMText::removeThis(CORO_PARAM, bool &result) { } -void RMText::WriteText(const RMString &text, int nFont, int *time) { +void RMText::writeText(const RMString &text, int nFont, int *time) { // Initialises the font (only once) - if (m_fonts[0] == NULL) { - m_fonts[0] = new RMFontParla; - m_fonts[0]->init(); - m_fonts[1] = new RMFontObj; - m_fonts[1]->init(); - m_fonts[2] = new RMFontMacc; - m_fonts[2]->init(); - m_fonts[3] = new RMFontCredits; - m_fonts[3]->init(); + if (_fonts[0] == NULL) { + _fonts[0] = new RMFontParla; + _fonts[0]->init(); + _fonts[1] = new RMFontObj; + _fonts[1]->init(); + _fonts[2] = new RMFontMacc; + _fonts[2]->init(); + _fonts[3] = new RMFontCredits; + _fonts[3]->init(); } - WriteText(text, m_fonts[nFont], time); + writeText(text, _fonts[nFont], time); } -void RMText::WriteText(const RMString &text, RMFontColor *font, int *time) { +void RMText::writeText(const RMString &text, RMFontColor *font, int *time) { RMGfxPrimitive *prim; char *p, *old_p; int i, j, x, y; @@ -1846,9 +1846,9 @@ void RMText::WriteText(const RMString &text, RMFontColor *font, int *time) { string = p = text; i = j = x = 0; while (*p != '\0') { - j += font->StringLen(*p); + j += font->stringLen(*p); if (j > (((aHorType == HLEFTPAR) && (i > 0)) ? maxLineLength - 25 : maxLineLength)) { - j -= font->StringLen(*p, p[1]); + j -= font->stringLen(*p, p[1]); if (j > x) x = j; @@ -1888,7 +1888,7 @@ void RMText::WriteText(const RMString &text, RMFontColor *font, int *time) { // Starting position for the surface: X1, Y width = x; - height = (numlines - 1) * font->LetterHeight() + font->m_fontDimy; + height = (numlines - 1) * font->letterHeight() + font->_fontDimy; // Create the surface Create(width, height); @@ -1902,7 +1902,7 @@ void RMText::WriteText(const RMString &text, RMFontColor *font, int *time) { for (; i > 0; i--) { // Measure the length of the line x = 0; - j = font->StringLen(RMString(p)); + j = font->stringLen(RMString(p)); switch (aHorType) { case HLEFT: @@ -1927,30 +1927,30 @@ void RMText::WriteText(const RMString &text, RMFontColor *font, int *time) { while (*p != '\0') { if (*p == ' ') { - x += font->StringLen(*p); + x += font->stringLen(*p); p++; continue; } - prim = font->MakeLetterPrimitive(*p, len); + prim = font->makeLetterPrimitive(*p, len); prim->Dst().x1 = x; prim->Dst().y1 = y; addPrim(prim); numchar++; - x += font->StringLen(*p, p[1]); + x += font->stringLen(*p, p[1]); p++; } p++; - y += font->LetterHeight(); + y += font->letterHeight(); } if (time != NULL) *time = 1000 + numchar * (11 - GLOBALS.nCfgTextSpeed) * 14; } -void RMText::ClipOnScreen(RMGfxPrimitive *prim) { +void RMText::clipOnScreen(RMGfxPrimitive *prim) { // Don't let it go outside the screen if (prim->Dst().x1 < 5) prim->Dst().x1 = 5; @@ -1984,7 +1984,7 @@ void RMText::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { prim->Dst().y1 -= _dimy; } - ClipOnScreen(prim); + clipOnScreen(prim); CORO_INVOKE_2(RMGfxWoodyBuffer::draw, bigBuf, prim); @@ -1996,18 +1996,18 @@ void RMText::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { \****************************************************************************/ RMTextDialog::RMTextDialog() : RMText() { - m_startTime = 0; + _startTime = 0; dst = RMPoint(0, 0); - m_bSkipStatus = true; - m_bShowed = true; - m_bForceTime = false; - m_bForceNoTime = false; - m_bAlwaysDisplay = false; - m_bNoTab = false; + _bSkipStatus = true; + _bShowed = true; + _bForceTime = false; + _bForceNoTime = false; + _bAlwaysDisplay = false; + _bNoTab = false; hCustomSkip = CORO_INVALID_PID_VALUE; hCustomSkip2 = CORO_INVALID_PID_VALUE; - m_input = NULL; + _input = NULL; // Create the event for displaying the end hEndDisplay = CoroScheduler.createEvent(false, false); @@ -2017,51 +2017,51 @@ RMTextDialog::~RMTextDialog() { CoroScheduler.closeEvent(hEndDisplay); } -void RMTextDialog::Show(void) { - m_bShowed = true; +void RMTextDialog::show(void) { + _bShowed = true; } -void RMTextDialog::Hide(CORO_PARAM) { - m_bShowed = false; +void RMTextDialog::hide(CORO_PARAM) { + _bShowed = false; } -void RMTextDialog::WriteText(const RMString &text, int font, int *time) { - RMText::WriteText(text, font, &m_time); +void RMTextDialog::writeText(const RMString &text, int font, int *time) { + RMText::writeText(text, font, &_time); if (time != NULL) - *time = m_time; + *time = _time; } -void RMTextDialog::WriteText(const RMString &text, RMFontColor *font, int *time) { - RMText::WriteText(text, font, &m_time); +void RMTextDialog::writeText(const RMString &text, RMFontColor *font, int *time) { + RMText::writeText(text, font, &_time); if (time != NULL) - *time = m_time; + *time = _time; } -void RMTextDialog::SetSkipStatus(bool bEnabled) { - m_bSkipStatus = bEnabled; +void RMTextDialog::setSkipStatus(bool bEnabled) { + _bSkipStatus = bEnabled; } -void RMTextDialog::ForceTime(void) { - m_bForceTime = true; +void RMTextDialog::forceTime(void) { + _bForceTime = true; } -void RMTextDialog::ForceNoTime(void) { - m_bForceNoTime = true; +void RMTextDialog::forceNoTime(void) { + _bForceNoTime = true; } -void RMTextDialog::SetNoTab(void) { - m_bNoTab = true; +void RMTextDialog::setNoTab(void) { + _bNoTab = true; } -void RMTextDialog::SetForcedTime(uint32 dwTime) { - m_time = dwTime; +void RMTextDialog::setForcedTime(uint32 dwTime) { + _time = dwTime; } -void RMTextDialog::SetAlwaysDisplay(void) { - m_bAlwaysDisplay = true; +void RMTextDialog::setAlwaysDisplay(void) { + _bAlwaysDisplay = true; } void RMTextDialog::removeThis(CORO_PARAM, bool &result) { @@ -2075,39 +2075,39 @@ void RMTextDialog::removeThis(CORO_PARAM, bool &result) { result = true; // Don't erase the background - if (m_bSkipStatus) { + if (_bSkipStatus) { if (!(GLOBALS.bCfgDubbing && hCustomSkip2 != CORO_INVALID_PID_VALUE)) { if (GLOBALS.bCfgTimerizedText) { - if (!m_bForceNoTime) { - if (_vm->getTime() > (uint32)m_time + m_startTime) + if (!_bForceNoTime) { + if (_vm->getTime() > (uint32)_time + _startTime) return; } } } - if (!m_bNoTab) { + if (!_bNoTab) { if (_vm->getEngine()->getInput().getAsyncKeyState(Common::KEYCODE_TAB)) return; } - if (!m_bNoTab) { - if (m_input) { - if (m_input->mouseLeftClicked() || m_input->mouseRightClicked()) + if (!_bNoTab) { + if (_input) { + if (_input->mouseLeftClicked() || _input->mouseRightClicked()) return; } } } // Erase the background else if (!(GLOBALS.bCfgDubbing && hCustomSkip2 != CORO_INVALID_PID_VALUE)) { - if (!m_bForceNoTime) { - if (_vm->getTime() > (uint32)m_time + m_startTime) + if (!_bForceNoTime) { + if (_vm->getTime() > (uint32)_time + _startTime) return; } } // If time is forced - if (m_bForceTime) { - if (_vm->getTime() > (uint32)m_time + m_startTime) + if (_bForceTime) { + if (_vm->getTime() > (uint32)_time + _startTime) return; } @@ -2142,11 +2142,11 @@ void RMTextDialog::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *p CORO_BEGIN_CODE(_ctx); - if (m_startTime == 0) - m_startTime = _vm->getTime(); + if (_startTime == 0) + _startTime = _vm->getTime(); - if (m_bShowed) { - if (GLOBALS.bCfgSottotitoli || m_bAlwaysDisplay) { + if (_bShowed) { + if (GLOBALS.bCfgSottotitoli || _bAlwaysDisplay) { prim->Dst().TopLeft() = dst; CORO_INVOKE_2(RMText::draw, bigBuf, prim); } @@ -2155,20 +2155,20 @@ void RMTextDialog::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *p CORO_END_CODE; } -void RMTextDialog::SetCustomSkipHandle(uint32 hCustom) { +void RMTextDialog::setCustomSkipHandle(uint32 hCustom) { hCustomSkip = hCustom; } -void RMTextDialog::SetCustomSkipHandle2(uint32 hCustom) { +void RMTextDialog::setCustomSkipHandle2(uint32 hCustom) { hCustomSkip2 = hCustom; } -void RMTextDialog::WaitForEndDisplay(CORO_PARAM) { +void RMTextDialog::waitForEndDisplay(CORO_PARAM) { CoroScheduler.waitForSingleObject(coroParam, hEndDisplay, CORO_INFINITE); } -void RMTextDialog::SetInput(RMInput *input) { - m_input = input; +void RMTextDialog::setInput(RMInput *input) { + _input = input; } /****************************************************************************\ @@ -2206,7 +2206,7 @@ void RMTextDialogScrolling::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPri CORO_END_CODE; } -void RMTextDialogScrolling::ClipOnScreen(RMGfxPrimitive *prim) { +void RMTextDialogScrolling::clipOnScreen(RMGfxPrimitive *prim) { // We must not do anything! } @@ -2216,7 +2216,7 @@ void RMTextDialogScrolling::ClipOnScreen(RMGfxPrimitive *prim) { \****************************************************************************/ RMTextItemName::RMTextItemName() : RMText() { - m_item = NULL; + _item = NULL; setPriority(220); } @@ -2224,7 +2224,7 @@ RMTextItemName::~RMTextItemName() { } -void RMTextItemName::DoFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation &loc, RMPointer &ptr, RMInventory &inv) { +void RMTextItemName::doFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation &loc, RMPointer &ptr, RMInventory &inv) { CORO_BEGIN_CONTEXT; RMItem *lastItem; uint32 hThread; @@ -2234,36 +2234,36 @@ void RMTextItemName::DoFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation & CORO_BEGIN_CODE(_ctx); - _ctx->lastItem = m_item; + _ctx->lastItem = _item; // Adds to the list if there is need if (!_nInList) bigBuf.addPrim(new RMGfxPrimitive(this)); // Update the scrolling co-ordinates - m_curscroll = loc.ScrollPosition(); + _curscroll = loc.ScrollPosition(); // Check if we are on the inventory - if (inv.ItemInFocus(m_mpos)) - m_item = inv.WhichItemIsIn(m_mpos); + if (inv.ItemInFocus(_mpos)) + _item = inv.WhichItemIsIn(_mpos); else - m_item = loc.WhichItemIsIn(m_mpos); + _item = loc.WhichItemIsIn(_mpos); itemName = ""; // If there an item, get its name - if (m_item != NULL) - m_item->GetName(itemName); + if (_item != NULL) + _item->GetName(itemName); // Write it - WriteText(itemName, 1); + writeText(itemName, 1); // Handle the change If the selected item is different from the previous one - if (_ctx->lastItem != m_item) { - if (m_item == NULL) + if (_ctx->lastItem != _item) { + if (_item == NULL) ptr.setSpecialPointer(RMPointer::PTR_NONE); else { - _ctx->hThread = mpalQueryDoAction(20, m_item->MpalCode(), 0); + _ctx->hThread = mpalQueryDoAction(20, _item->MpalCode(), 0); if (_ctx->hThread == CORO_INVALID_PID_VALUE) ptr.setSpecialPointer(RMPointer::PTR_NONE); else @@ -2286,30 +2286,30 @@ void RMTextItemName::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive return; // Set the destination coordinates of the mouse - prim->Dst().TopLeft() = m_mpos - RMPoint(0, 30); + prim->Dst().TopLeft() = _mpos - RMPoint(0, 30); CORO_INVOKE_2(RMText::draw, bigBuf, prim); CORO_END_CODE; } -RMPoint RMTextItemName::GetHotspot() { - if (m_item == NULL) - return m_mpos + m_curscroll; +RMPoint RMTextItemName::getHotspot() { + if (_item == NULL) + return _mpos + _curscroll; else - return m_item->Hotspot(); + return _item->Hotspot(); } -RMItem *RMTextItemName::GetSelectedItem() { - return m_item; +RMItem *RMTextItemName::getSelectedItem() { + return _item; } -bool RMTextItemName::IsItemSelected() { - return m_item != NULL; +bool RMTextItemName::isItemSelected() { + return _item != NULL; } -bool RMTextItemName::IsNormalItemSelected() { - return m_item != NULL && m_itemName.Length() > 0; +bool RMTextItemName::isNormalItemSelected() { + return _item != NULL && _itemName.Length() > 0; } @@ -2345,56 +2345,56 @@ void RMDialogChoice::Unregister(void) { } void RMDialogChoice::init(void) { - m_numChoices = 0; - m_drawedStrings = NULL; - m_ptDrawStrings = NULL; - m_curSelection = -1; + _numChoices = 0; + _drawedStrings = NULL; + _ptDrawStrings = NULL; + _curSelection = -1; Create(640, 477); setPriority(140); } -void RMDialogChoice::Close(void) { - if (m_drawedStrings != NULL) { - delete[] m_drawedStrings; - m_drawedStrings = NULL; +void RMDialogChoice::close(void) { + if (_drawedStrings != NULL) { + delete[] _drawedStrings; + _drawedStrings = NULL; } - if (m_ptDrawStrings != NULL) { - delete[] m_ptDrawStrings; - m_ptDrawStrings = NULL; + if (_ptDrawStrings != NULL) { + delete[] _ptDrawStrings; + _ptDrawStrings = NULL; } destroy(); } -void RMDialogChoice::SetNumChoices(int num) { +void RMDialogChoice::setNumChoices(int num) { int i; - m_numChoices = num; - m_curAdded = 0; + _numChoices = num; + _curAdded = 0; // Allocate space for drawn strings - m_drawedStrings = new RMText[num]; - m_ptDrawStrings = new RMPoint[num]; + _drawedStrings = new RMText[num]; + _ptDrawStrings = new RMPoint[num]; // Initialisation - for (i = 0; i < m_numChoices; i++) { - m_drawedStrings[i].SetColor(0, 255, 0); - m_drawedStrings[i].SetAlignType(RMText::HLEFTPAR, RMText::VTOP); - m_drawedStrings[i].SetMaxLineLength(600); - m_drawedStrings[i].setPriority(10); + for (i = 0; i < _numChoices; i++) { + _drawedStrings[i].setColor(0, 255, 0); + _drawedStrings[i].setAlignType(RMText::HLEFTPAR, RMText::VTOP); + _drawedStrings[i].setMaxLineLength(600); + _drawedStrings[i].setPriority(10); } } -void RMDialogChoice::AddChoice(const RMString &string) { +void RMDialogChoice::addChoice(const RMString &string) { // Draw the string - assert(m_curAdded < m_numChoices); - m_drawedStrings[m_curAdded++].WriteText(string, 0); + assert(_curAdded < _numChoices); + _drawedStrings[_curAdded++].writeText(string, 0); } -void RMDialogChoice::Prepare(CORO_PARAM) { +void RMDialogChoice::prepare(CORO_PARAM) { CORO_BEGIN_CONTEXT; int i; RMPoint ptPos; @@ -2410,21 +2410,21 @@ void RMDialogChoice::Prepare(CORO_PARAM) { _ctx->ptPos.Set(20, 90); - for (_ctx->i = 0; _ctx->i < m_numChoices; _ctx->i++) { - addPrim(new RMGfxPrimitive(&m_drawedStrings[_ctx->i], _ctx->ptPos)); - m_ptDrawStrings[_ctx->i] = _ctx->ptPos; - _ctx->ptPos.Offset(0, m_drawedStrings[_ctx->i].getDimy() + 15); + for (_ctx->i = 0; _ctx->i < _numChoices; _ctx->i++) { + addPrim(new RMGfxPrimitive(&_drawedStrings[_ctx->i], _ctx->ptPos)); + _ptDrawStrings[_ctx->i] = _ctx->ptPos; + _ctx->ptPos.Offset(0, _drawedStrings[_ctx->i].getDimy() + 15); } CORO_INVOKE_0(drawOT); clearOT(); - m_ptDrawPos.Set(0, 480 - _ctx->ptPos.y); + _ptDrawPos.Set(0, 480 - _ctx->ptPos.y); CORO_END_CODE; } -void RMDialogChoice::SetSelected(CORO_PARAM, int pos) { +void RMDialogChoice::setSelected(CORO_PARAM, int pos) { CORO_BEGIN_CONTEXT; RMGfxBox box; RMRect rc; @@ -2432,39 +2432,39 @@ void RMDialogChoice::SetSelected(CORO_PARAM, int pos) { CORO_BEGIN_CODE(_ctx); - if (pos == m_curSelection) + if (pos == _curSelection) return; _ctx->box.setPriority(5); - if (m_curSelection != -1) { + if (_curSelection != -1) { _ctx->box.SetColor(0xCC, 0xCC, 0xFF); - _ctx->rc.TopLeft() = RMPoint(18, m_ptDrawStrings[m_curSelection].y); - _ctx->rc.BottomRight() = _ctx->rc.TopLeft() + RMPoint(597, m_drawedStrings[m_curSelection].getDimy()); + _ctx->rc.TopLeft() = RMPoint(18, _ptDrawStrings[_curSelection].y); + _ctx->rc.BottomRight() = _ctx->rc.TopLeft() + RMPoint(597, _drawedStrings[_curSelection].getDimy()); addPrim(new RMGfxPrimitive(&_ctx->box, _ctx->rc)); - addPrim(new RMGfxPrimitive(&m_drawedStrings[m_curSelection], m_ptDrawStrings[m_curSelection])); + addPrim(new RMGfxPrimitive(&_drawedStrings[_curSelection], _ptDrawStrings[_curSelection])); CORO_INVOKE_0(drawOT); clearOT(); } if (pos != -1) { _ctx->box.SetColor(100, 100, 100); - _ctx->rc.TopLeft() = RMPoint(18, m_ptDrawStrings[pos].y); - _ctx->rc.BottomRight() = _ctx->rc.TopLeft() + RMPoint(597, m_drawedStrings[pos].getDimy()); + _ctx->rc.TopLeft() = RMPoint(18, _ptDrawStrings[pos].y); + _ctx->rc.BottomRight() = _ctx->rc.TopLeft() + RMPoint(597, _drawedStrings[pos].getDimy()); addPrim(new RMGfxPrimitive(&_ctx->box, _ctx->rc)); - addPrim(new RMGfxPrimitive(&m_drawedStrings[pos], m_ptDrawStrings[pos])); + addPrim(new RMGfxPrimitive(&_drawedStrings[pos], _ptDrawStrings[pos])); } CORO_INVOKE_0(drawOT); clearOT(); - m_curSelection = pos; + _curSelection = pos; CORO_END_CODE; } -void RMDialogChoice::Show(CORO_PARAM, RMGfxTargetBuffer *bigBuf) { +void RMDialogChoice::show(CORO_PARAM, RMGfxTargetBuffer *bigBuf) { CORO_BEGIN_CONTEXT; RMPoint destpt; int deltay; @@ -2474,34 +2474,34 @@ void RMDialogChoice::Show(CORO_PARAM, RMGfxTargetBuffer *bigBuf) { CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_0(Prepare); - m_bShow = false; + CORO_INVOKE_0(prepare); + _bShow = false; if (!_nInList && bigBuf != NULL) bigBuf->addPrim(new RMGfxPrimitive(this)); if (0) { - m_bShow = true; + _bShow = true; } else { _ctx->starttime = _vm->getTime(); - _ctx->deltay = 480 - m_ptDrawPos.y; - _ctx->destpt = m_ptDrawPos; - m_ptDrawPos.Set(0, 480); + _ctx->deltay = 480 - _ptDrawPos.y; + _ctx->destpt = _ptDrawPos; + _ptDrawPos.Set(0, 480); if (!_nInList && bigBuf != NULL) bigBuf->addPrim(new RMGfxPrimitive(this)); - m_bShow = true; + _bShow = true; _ctx->elaps = 0; while (_ctx->elaps < 700) { CORO_INVOKE_0(mainWaitFrame); mainFreeze(); _ctx->elaps = _vm->getTime() - _ctx->starttime; - m_ptDrawPos.y = 480 - ((_ctx->deltay * 100) / 700 * _ctx->elaps) / 100; + _ptDrawPos.y = 480 - ((_ctx->deltay * 100) / 700 * _ctx->elaps) / 100; mainUnfreeze(); } - m_ptDrawPos.y = _ctx->destpt.y; + _ptDrawPos.y = _ctx->destpt.y; } CORO_END_CODE; @@ -2513,17 +2513,17 @@ void RMDialogChoice::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive CORO_BEGIN_CODE(_ctx); - if (m_bShow == false) + if (_bShow == false) return; - prim->setDst(m_ptDrawPos); + prim->setDst(_ptDrawPos); CORO_INVOKE_2(RMGfxSourceBuffer16::draw, bigBuf, prim); CORO_END_CODE; } -void RMDialogChoice::Hide(CORO_PARAM) { +void RMDialogChoice::hide(CORO_PARAM) { CORO_BEGIN_CONTEXT; int deltay; int starttime; @@ -2535,18 +2535,18 @@ void RMDialogChoice::Hide(CORO_PARAM) { if (1) { _ctx->starttime = _vm->getTime(); - _ctx->deltay = 480 - m_ptDrawPos.y; + _ctx->deltay = 480 - _ptDrawPos.y; _ctx->elaps = 0; while (_ctx->elaps < 700) { CORO_INVOKE_0(mainWaitFrame); mainFreeze(); _ctx->elaps = _vm->getTime() - _ctx->starttime; - m_ptDrawPos.y = 480 - ((_ctx->deltay * 100) / 700 * (700 - _ctx->elaps)) / 100; + _ptDrawPos.y = 480 - ((_ctx->deltay * 100) / 700 * (700 - _ctx->elaps)) / 100; mainUnfreeze(); } } - m_bShow = false; + _bShow = false; bRemoveFromOT = true; CORO_INVOKE_2(CoroScheduler.waitForSingleObject, hUnreg, CORO_INFINITE); @@ -2558,30 +2558,30 @@ void RMDialogChoice::removeThis(CORO_PARAM, bool &result) { result = bRemoveFromOT; } -void RMDialogChoice::DoFrame(CORO_PARAM, RMPoint ptMousePos) { +void RMDialogChoice::doFrame(CORO_PARAM, RMPoint ptMousePos) { CORO_BEGIN_CONTEXT; int i; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - if (ptMousePos.y > m_ptDrawPos.y) { - for (_ctx->i = 0; _ctx->i < m_numChoices; _ctx->i++) { - if ((ptMousePos.y >= m_ptDrawPos.y + m_ptDrawStrings[_ctx->i].y) && (ptMousePos.y < m_ptDrawPos.y + m_ptDrawStrings[_ctx->i].y + m_drawedStrings[_ctx->i].getDimy())) { - CORO_INVOKE_1(SetSelected, _ctx->i); + if (ptMousePos.y > _ptDrawPos.y) { + for (_ctx->i = 0; _ctx->i < _numChoices; _ctx->i++) { + if ((ptMousePos.y >= _ptDrawPos.y + _ptDrawStrings[_ctx->i].y) && (ptMousePos.y < _ptDrawPos.y + _ptDrawStrings[_ctx->i].y + _drawedStrings[_ctx->i].getDimy())) { + CORO_INVOKE_1(setSelected, _ctx->i); break; } } - if (_ctx->i == m_numChoices) - CORO_INVOKE_1(SetSelected, -1); + if (_ctx->i == _numChoices) + CORO_INVOKE_1(setSelected, -1); } CORO_END_CODE; } -int RMDialogChoice::GetSelection(void) { - return m_curSelection; +int RMDialogChoice::getSelection(void) { + return _curSelection; } } // End of namespace Tony diff --git a/engines/tony/font.h b/engines/tony/font.h index 752f142cf1..d39b9752a7 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -48,12 +48,12 @@ class RMPointer; class RMFont : public RMGfxTaskSetPrior { protected: int nLetters; - RMGfxSourceBuffer8RLEByte *m_letter; + RMGfxSourceBuffer8RLEByte *_letter; public: - int m_fontDimx, m_fontDimy; + int _fontDimx, _fontDimy; private: - int m_dimx, m_dimy; + int _dimx, _dimy; class RMFontPrimitive : public RMGfxPrimitive { public: @@ -64,26 +64,26 @@ private: return new RMFontPrimitive(*this); } - int m_nChar; + int _nChar; }; protected: // Loads the font - void Load(uint32 resID, int nChars, int dimx, int dimy, uint32 palResID = RES_F_PAL); - void Load(const byte *buf, int nChars, int dimx, int dimy, uint32 palResID = RES_F_PAL); + void load(uint32 resID, int nChars, int dimx, int dimy, uint32 palResID = RES_F_PAL); + void load(const byte *buf, int nChars, int dimx, int dimy, uint32 palResID = RES_F_PAL); // Remove the font - void Unload(void); + void unload(void); protected: // Conversion form character to font index - virtual int ConvertToLetter(byte nChar) = 0; + virtual int convertToLetter(byte nChar) = 0; // Character width - virtual int LetterLength(int nChar, int nNext = 0) = 0; + virtual int letterLength(int nChar, int nNext = 0) = 0; public: - virtual int LetterHeight(void) = 0; + virtual int letterHeight(void) = 0; public: RMFont(); @@ -91,17 +91,17 @@ public: // Initialisation and closing virtual void init(void) = 0; - virtual void Close(void); + virtual void close(void); // Drawing virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBug, RMGfxPrimitive *prim); // Create a primitive for a letter - RMGfxPrimitive *MakeLetterPrimitive(byte bChar, int &nLength); + RMGfxPrimitive *makeLetterPrimitive(byte bChar, int &nLength); // Length in pixels of a string with the current font - int StringLen(const RMString &text); - int StringLen(char bChar, char bNext = 0); + int stringLen(const RMString &text); + int stringLen(char bChar, char bNext = 0); }; @@ -126,15 +126,15 @@ protected: protected: // Overloaded methods - int ConvertToLetter(byte nChar) { + int convertToLetter(byte nChar) { return cTable[nChar]; } - int LetterLength(int nChar, int nNext = 0) { + int letterLength(int nChar, int nNext = 0) { return (nChar != -1 ? lTable[(byte)nChar] + l2Table[(byte)nChar][(byte)nNext] : lDefault); } public: - int LetterHeight() { + int letterHeight() { return hDefault; } virtual ~RMFontWithTables() {} @@ -149,7 +149,7 @@ public: class RMFontObj : public RMFontColor, public RMFontWithTables { private: - void SetBothCase(int nChar, int nNext, signed char spiazz); + void setBothCase(int nChar, int nNext, signed char spiazz); public: void init(void); @@ -166,7 +166,7 @@ class RMFontCredits : public RMFontColor, public RMFontWithTables { public: void init(void); virtual ~RMFontCredits() {} - virtual void SetBaseColor(byte r, byte g, byte b) {} + virtual void setBaseColor(byte r, byte g, byte b) {} }; /** @@ -174,8 +174,8 @@ public: */ class RMText : public RMGfxWoodyBuffer { private: - static RMFontColor *m_fonts[4]; - static RMGfxClearTask m_clear; + static RMFontColor *_fonts[4]; + static RMGfxClearTask _clear; int maxLineLength; public: @@ -198,26 +198,26 @@ private: byte m_r, m_g, m_b; protected: - virtual void ClipOnScreen(RMGfxPrimitive *prim); + virtual void clipOnScreen(RMGfxPrimitive *prim); public: RMText(); virtual ~RMText(); static void initStatics(); - static void Unload(); + static void unload(); // Set the alignment type - void SetAlignType(HORALIGN aHor, VERALIGN aVer) { + void setAlignType(HORALIGN aHor, VERALIGN aVer) { aHorType = aHor; aVerType = aVer; } // Sets the maximum length of a line in pixels (used to format the text) - void SetMaxLineLength(int max); + void setMaxLineLength(int max); // Write the text - void WriteText(const RMString &text, int font, int *time = NULL); - void WriteText(const RMString &text, RMFontColor *font, int *time = NULL); + void writeText(const RMString &text, int font, int *time = NULL); + void writeText(const RMString &text, RMFontColor *font, int *time = NULL); // Overloaded function to decide when you delete the object from the OT list virtual void removeThis(CORO_PARAM, bool &result); @@ -226,7 +226,7 @@ public: virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Set the base colour - void SetColor(byte r, byte g, byte b) { + void setColor(byte r, byte g, byte b) { m_r = r; m_g = g; m_b = b; @@ -238,27 +238,27 @@ public: */ class RMTextDialog : public RMText { protected: - int m_startTime; - int m_time; - bool m_bSkipStatus; + int _startTime; + int _time; + bool _bSkipStatus; RMPoint dst; uint32 hEndDisplay; - bool m_bShowed; - bool m_bForceTime; - bool m_bForceNoTime; + bool _bShowed; + bool _bForceTime; + bool _bForceNoTime; uint32 hCustomSkip; uint32 hCustomSkip2; - RMInput *m_input; - bool m_bAlwaysDisplay; - bool m_bNoTab; + RMInput *_input; + bool _bAlwaysDisplay; + bool _bNoTab; public: RMTextDialog(); virtual ~RMTextDialog(); // Write the text - void WriteText(const RMString &text, int font, int *time = NULL); - void WriteText(const RMString &text, RMFontColor *font, int *time = NULL); + void writeText(const RMString &text, int font, int *time = NULL); + void writeText(const RMString &text, RMFontColor *font, int *time = NULL); // Overloaded function to decide when you delete the object from the OT list virtual void removeThis(CORO_PARAM, bool &result); @@ -270,26 +270,26 @@ public: virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Set the position - void SetPosition(const RMPoint &pt) { + void setPosition(const RMPoint &pt) { dst = pt; } // Waiting - void WaitForEndDisplay(CORO_PARAM); - void SetCustomSkipHandle(uint32 hCustomSkip); - void SetCustomSkipHandle2(uint32 hCustomSkip); - void SetSkipStatus(bool bEnabled); - void SetForcedTime(uint32 dwTime); - void SetNoTab(void); - void ForceTime(void); - void ForceNoTime(void); - void SetAlwaysDisplay(void); + void waitForEndDisplay(CORO_PARAM); + void setCustomSkipHandle(uint32 hCustomSkip); + void setCustomSkipHandle2(uint32 hCustomSkip); + void setSkipStatus(bool bEnabled); + void setForcedTime(uint32 dwTime); + void setNoTab(void); + void forceTime(void); + void forceNoTime(void); + void setAlwaysDisplay(void); // Set the input device, to allow skip from mouse - void SetInput(RMInput *input); + void setInput(RMInput *input); - void Show(void); - void Hide(CORO_PARAM); + void show(void); + void hide(CORO_PARAM); }; class RMTextDialogScrolling : public RMTextDialog { @@ -297,7 +297,7 @@ protected: RMLocation *curLoc; RMPoint startScroll; - virtual void ClipOnScreen(RMGfxPrimitive *prim); + virtual void clipOnScreen(RMGfxPrimitive *prim); public: RMTextDialogScrolling(); @@ -313,26 +313,26 @@ public: */ class RMTextItemName : protected RMText { protected: - RMPoint m_mpos; - RMPoint m_curscroll; - RMItem *m_item; - RMString m_itemName; + RMPoint _mpos; + RMPoint _curscroll; + RMItem *_item; + RMString _itemName; public: RMTextItemName(); virtual ~RMTextItemName(); - void SetMouseCoord(const RMPoint &m) { - m_mpos = m; + void setMouseCoord(const RMPoint &m) { + _mpos = m; } - void DoFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation &loc, RMPointer &ptr, RMInventory &inv); + void doFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation &loc, RMPointer &ptr, RMInventory &inv); virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - RMPoint GetHotspot(); - RMItem *GetSelectedItem(); - bool IsItemSelected(); - bool IsNormalItemSelected(); + RMPoint getHotspot(); + RMItem *getSelectedItem(); + bool isItemSelected(); + bool isNormalItemSelected(); virtual void removeThis(CORO_PARAM, bool &result) { result = true; @@ -345,21 +345,21 @@ public: */ class RMDialogChoice : public RMGfxWoodyBuffer { private: - int m_curSelection; - int m_numChoices; - RMText *m_drawedStrings; - RMPoint *m_ptDrawStrings; - int m_curAdded; - bool m_bShow; + int _curSelection; + int _numChoices; + RMText *_drawedStrings; + RMPoint *_ptDrawStrings; + int _curAdded; + bool _bShow; RMGfxSourceBuffer8 DlgText; RMGfxSourceBuffer8 DlgTextLine; - RMPoint m_ptDrawPos; + RMPoint _ptDrawPos; uint32 hUnreg; bool bRemoveFromOT; protected: - void Prepare(CORO_PARAM); - void SetSelected(CORO_PARAM, int pos); + void prepare(CORO_PARAM); + void setSelected(CORO_PARAM, int pos); public: virtual void removeThis(CORO_PARAM, bool &result); @@ -373,25 +373,25 @@ public: // Initialisation and closure void init(void); - void Close(void); + void close(void); // Sets the number of possible sentences, which then be added with AddChoice() - void SetNumChoices(int num); + void setNumChoices(int num); // Adds a string with the choice - void AddChoice(const RMString &string); + void addChoice(const RMString &string); // Show and hide the selection, with possible animations. // NOTE: If no parameter is passed to Show(), it is the obligation of // caller to ensure that the class is inserted into OT list - void Show(CORO_PARAM, RMGfxTargetBuffer *bigBuf = NULL); - void Hide(CORO_PARAM); + void show(CORO_PARAM, RMGfxTargetBuffer *bigBuf = NULL); + void hide(CORO_PARAM); // Polling Update - void DoFrame(CORO_PARAM, RMPoint ptMousePos); + void doFrame(CORO_PARAM, RMPoint ptMousePos); // Returns the currently selected item, or -1 if none is selected - int GetSelection(void); + int getSelection(void); }; } // End of namespace Tony diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index c729a4e8c0..bf708ec075 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -443,10 +443,10 @@ void RMOptionScreen::refreshAll(CORO_PARAM) { _ctx->title = new RMText; if (_nState == MENULOAD) { RMMessage msg(10); - _ctx->title->WriteText(msg[0], 1); + _ctx->title->writeText(msg[0], 1); } else { RMMessage msg(11); - _ctx->title->WriteText(msg[0], 1); + _ctx->title->writeText(msg[0], 1); } addPrim(new RMGfxPrimitive(_ctx->title, RMPoint(320, 10))); @@ -520,8 +520,8 @@ void RMOptionScreen::refreshAll(CORO_PARAM) { } _ctx->num[_ctx->i] = new RMText; - _ctx->num[_ctx->i]->SetAlignType(RMText::HLEFT, RMText::VTOP); - _ctx->num[_ctx->i]->WriteText(s, 2); + _ctx->num[_ctx->i]->setAlignType(RMText::HLEFT, RMText::VTOP); + _ctx->num[_ctx->i]->writeText(s, 2); } addPrim(new RMGfxPrimitive(_ctx->num[0], RMPoint(55 - 3, 180 + 14))); diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index ca7e645825..08976e6092 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -186,7 +186,7 @@ void RMGfxEngine::doFrame(CORO_PARAM, bool bDrawLocation) { // Right Click // *********** if (_input.mouseRightClicked()) { - if (_itemName.IsItemSelected()) { + if (_itemName.isItemSelected()) { _curActionObj = 0; _inv.RightClick(_input.mousePos()); } else @@ -197,7 +197,7 @@ void RMGfxEngine::doFrame(CORO_PARAM, bool bDrawLocation) { // ************* if (_input.mouseRightReleased()) { if (_inv.RightRelease(_input.mousePos(), _curAction)) { - CORO_INVOKE_3(_tony.MoveAndDoAction, _itemName.GetHotspot(), _itemName.GetSelectedItem(), _curAction); + CORO_INVOKE_3(_tony.MoveAndDoAction, _itemName.getHotspot(), _itemName.getSelectedItem(), _curAction); _curAction = TA_GOTO; _point.setAction(_curAction); @@ -229,9 +229,9 @@ void RMGfxEngine::doFrame(CORO_PARAM, bool bDrawLocation) { if (_input.mouseLeftClicked() && !_inter.Active()) { if (_curAction != TA_COMBINE) - CORO_INVOKE_3(_tony.MoveAndDoAction, _itemName.GetHotspot(), _itemName.GetSelectedItem(), _point.curAction()); - else if (_itemName.GetSelectedItem() != NULL) - CORO_INVOKE_4(_tony.MoveAndDoAction, _itemName.GetHotspot(), _itemName.GetSelectedItem(), TA_COMBINE, _curActionObj); + CORO_INVOKE_3(_tony.MoveAndDoAction, _itemName.getHotspot(), _itemName.getSelectedItem(), _point.curAction()); + else if (_itemName.getSelectedItem() != NULL) + CORO_INVOKE_4(_tony.MoveAndDoAction, _itemName.getHotspot(), _itemName.getSelectedItem(), TA_COMBINE, _curActionObj); if (_curAction == TA_COMBINE) { _inv.EndCombine(); @@ -254,7 +254,7 @@ SKIPCLICKSINISTRO: _point.setAction(_curAction); _point.setSpecialPointer(RMPointer::PTR_NONE); } - } else if (_input.mouseRightClicked() && _itemName.IsItemSelected() && _point.getSpecialPointer() == RMPointer::PTR_NONE) { + } else if (_input.mouseRightClicked() && _itemName.isItemSelected() && _point.getSpecialPointer() == RMPointer::PTR_NONE) { if (_bGUIInterface) { // Before opening the interface, replaces GOTO _curAction = TA_GOTO; @@ -271,7 +271,7 @@ SKIPCLICKSINISTRO: if (_bGUIInterface) { if (_inter.Released(_input.mousePos(), _curAction)) { _point.setAction(_curAction); - CORO_INVOKE_3(_tony.MoveAndDoAction, _itemName.GetHotspot(), _itemName.GetSelectedItem(), _curAction); + CORO_INVOKE_3(_tony.MoveAndDoAction, _itemName.getHotspot(), _itemName.getSelectedItem(), _curAction); _curAction = TA_GOTO; _point.setAction(_curAction); @@ -281,14 +281,14 @@ SKIPCLICKSINISTRO: } // Update the name under the mouse pointer - _itemName.SetMouseCoord(_input.mousePos()); + _itemName.setMouseCoord(_input.mousePos()); if (!_inter.Active() && !_inv.MiniActive()) - CORO_INVOKE_4(_itemName.DoFrame, _bigBuf, _loc, _point, _inv); + CORO_INVOKE_4(_itemName.doFrame, _bigBuf, _loc, _point, _inv); } // Interface & Inventory _inter.DoFrame(_bigBuf, _input.mousePos()); - _inv.DoFrame(_bigBuf, _point, _input.mousePos(), (!_tony.InAction() && !_inter.Active() && _bGUIInventory)); + _inv.doFrame(_bigBuf, _point, _input.mousePos(), (!_tony.InAction() && !_inter.Active() && _bGUIInventory)); } // Animate Tony @@ -397,7 +397,7 @@ void RMGfxEngine::initForNewLocation(int nLoc, RMPoint ptTonyStart, RMPoint star _point.setSpecialPointer(RMPointer::PTR_NONE); _point.setAction(_curAction); _inter.Reset(); - _inv.Reset(); + _inv.reset(); mpalStartIdlePoll(_nCurLoc); } @@ -472,7 +472,7 @@ void RMGfxEngine::init() { _bigBuf.drawOT(Common::nullContext); _bigBuf.clearOT(); delete load; - _vm->_window.GetNewFrame(*this, NULL); + _vm->_window.getNewFrame(*this, NULL); GLOBALS.bPatIrqFreeze = true; @@ -506,7 +506,7 @@ void RMGfxEngine::init() { _tony.LinkToBoxes(&_vm->_theBoxes); // Initialise the inventory and the interface - _inv.Init(); + _inv.init(); _inter.Init(); // Download the location and set priorities @@@@@ @@ -522,7 +522,7 @@ void RMGfxEngine::close(void) { _bigBuf.clearOT(); _inter.Close(); - _inv.Close(); + _inv.close(); _tony.Close(); _point.close(); _input.close(); diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index cd302f8259..360e53803e 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -60,7 +60,7 @@ RMInventory::RMInventory() { } RMInventory::~RMInventory() { - Close(); + close(); g_system->deleteMutex(m_csModifyInterface); } @@ -72,8 +72,7 @@ bool RMInventory::CheckPointInside(const RMPoint &pt) { } - -void RMInventory::Init(void) { +void RMInventory::init(void) { int i, j; int curres; @@ -140,27 +139,27 @@ void RMInventory::Init(void) { ds.Close(); // Create the text for hints on the mini interface - m_hints[0].SetAlignType(RMText::HCENTER, RMText::VTOP); - m_hints[1].SetAlignType(RMText::HCENTER, RMText::VTOP); - m_hints[2].SetAlignType(RMText::HCENTER, RMText::VTOP); + m_hints[0].setAlignType(RMText::HCENTER, RMText::VTOP); + m_hints[1].setAlignType(RMText::HCENTER, RMText::VTOP); + m_hints[2].setAlignType(RMText::HCENTER, RMText::VTOP); // The text is taken from MPAL for translation RMMessage msg1(15); RMMessage msg2(13); RMMessage msg3(14); - m_hints[0].WriteText(msg1[0], 1); // Examine - m_hints[1].WriteText(msg2[0], 1); // Take - m_hints[2].WriteText(msg3[0], 1); // Use + m_hints[0].writeText(msg1[0], 1); // Examine + m_hints[1].writeText(msg2[0], 1); // Take + m_hints[2].writeText(msg3[0], 1); // Use // Prepare initial inventory - Prepare(); + prepare(); drawOT(Common::nullContext); clearOT(); } -void RMInventory::Close(void) { +void RMInventory::close(void) { // Has memory if (m_items != NULL) { // Delete the item pointers @@ -175,7 +174,7 @@ void RMInventory::Close(void) { destroy(); } -void RMInventory::Reset(void) { +void RMInventory::reset(void) { m_state = CLOSED; EndCombine(); } @@ -248,7 +247,7 @@ void RMInventory::RemoveItem(int code) { Common::copy(&m_inv[i + 1], &m_inv[i + 1] + (m_nInv - i), &m_inv[i]); m_nInv--; - Prepare(); + prepare(); drawOT(Common::nullContext); clearOT(); g_system->unlockMutex(m_csModifyInterface); @@ -269,7 +268,7 @@ void RMInventory::AddItem(int code) { m_inv[m_nInv++] = code - 10000; - Prepare(); + prepare(); drawOT(Common::nullContext); clearOT(); g_system->unlockMutex(m_csModifyInterface); @@ -284,7 +283,7 @@ void RMInventory::ChangeItemStatus(uint32 code, uint32 dwStatus) { m_items[code - 10000].icon.SetPattern(dwStatus); m_items[code - 10000].status = dwStatus; - Prepare(); + prepare(); drawOT(Common::nullContext); clearOT(); g_system->unlockMutex(m_csModifyInterface); @@ -292,7 +291,7 @@ void RMInventory::ChangeItemStatus(uint32 code, uint32 dwStatus) { } -void RMInventory::Prepare(void) { +void RMInventory::prepare(void) { int i; for (i = 1; i < RM_SX / 64 - 1; i++) { @@ -363,7 +362,7 @@ bool RMInventory::LeftClick(const RMPoint &mpos, int &nCombineObj) { m_items[29].icon.SetPattern(2); } - Prepare(); + prepare(); drawOT(Common::nullContext); clearOT(); g_system->unlockMutex(m_csModifyInterface); @@ -384,7 +383,7 @@ bool RMInventory::LeftClick(const RMPoint &mpos, int &nCombineObj) { m_items[28].icon.SetPattern(2); } - Prepare(); + prepare(); drawOT(Common::nullContext); clearOT(); g_system->unlockMutex(m_csModifyInterface); @@ -429,7 +428,7 @@ void RMInventory::RightClick(const RMPoint &mpos) { m_items[29].icon.SetPattern(2); } - Prepare(); + prepare(); drawOT(Common::nullContext); clearOT(); g_system->unlockMutex(m_csModifyInterface); @@ -449,7 +448,7 @@ void RMInventory::RightClick(const RMPoint &mpos) { m_items[28].icon.SetPattern(2); } - Prepare(); + prepare(); drawOT(Common::nullContext); clearOT(); g_system->unlockMutex(m_csModifyInterface); @@ -477,7 +476,7 @@ bool RMInventory::RightRelease(const RMPoint &mpos, RMTonyAction &curAction) { #define INVSPEED 20 -void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpos, bool bCanOpen) { +void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpos, bool bCanOpen) { int i; bool bNeedRedraw = false; @@ -525,7 +524,7 @@ void RMInventory::DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo bNeedRedraw = true; if (bNeedRedraw) - Prepare(); + prepare(); g_system->unlockMutex(m_csModifyInterface); } @@ -743,7 +742,7 @@ int RMInventory::LoadState(byte *state) { else m_items[28].icon.SetPattern(1); - Prepare(); + prepare(); drawOT(Common::nullContext); clearOT(); @@ -908,11 +907,11 @@ void RMInterface::Init(void) { m_hotbbox[3].SetRect(56, 51, 93, 99); m_hotbbox[4].SetRect(51, 105, 82, 172); - m_hints[0].SetAlignType(RMText::HRIGHT, RMText::VTOP); - m_hints[1].SetAlignType(RMText::HRIGHT, RMText::VTOP); - m_hints[2].SetAlignType(RMText::HRIGHT, RMText::VTOP); - m_hints[3].SetAlignType(RMText::HRIGHT, RMText::VTOP); - m_hints[4].SetAlignType(RMText::HRIGHT, RMText::VTOP); + m_hints[0].setAlignType(RMText::HRIGHT, RMText::VTOP); + m_hints[1].setAlignType(RMText::HRIGHT, RMText::VTOP); + m_hints[2].setAlignType(RMText::HRIGHT, RMText::VTOP); + m_hints[3].setAlignType(RMText::HRIGHT, RMText::VTOP); + m_hints[4].setAlignType(RMText::HRIGHT, RMText::VTOP); // The text is taken from MPAL for translation RMMessage msg0(12); @@ -921,11 +920,11 @@ void RMInterface::Init(void) { RMMessage msg3(15); RMMessage msg4(16); - m_hints[0].WriteText(msg0[0], 1); // Take - m_hints[1].WriteText(msg1[0], 1); // Talk - m_hints[2].WriteText(msg2[0], 1); // Use - m_hints[3].WriteText(msg3[0], 1); // Examine - m_hints[4].WriteText(msg4[0], 1); // Show Yourself + m_hints[0].writeText(msg0[0], 1); // Take + m_hints[1].writeText(msg1[0], 1); // Talk + m_hints[2].writeText(msg2[0], 1); // Use + m_hints[3].writeText(msg3[0], 1); // Examine + m_hints[4].writeText(msg4[0], 1); // Show Yourself m_bActive = false; m_bPalesati = false; diff --git a/engines/tony/inventory.h b/engines/tony/inventory.h index 9ed250592d..3548317dcc 100644 --- a/engines/tony/inventory.h +++ b/engines/tony/inventory.h @@ -80,7 +80,7 @@ protected: protected: // Prepare the image inventory. It should be recalled whenever the inventory changes - void Prepare(void); + void prepare(void); // Check if the mouse Y position is conrrect, even under the inventory portion of the screen bool CheckPointInside(const RMPoint &pt); @@ -90,12 +90,12 @@ public: virtual ~RMInventory(); // Prepare a frame - void DoFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpos, bool bCanOpen); + void doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpos, bool bCanOpen); // Initialisation and closing - void Init(void); - void Close(void); - void Reset(void); + void init(void); + void close(void); + void reset(void); // Overload test for removal from OT list virtual void removeThis(CORO_PARAM, bool &result); diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index cc323eb5d2..ea378e0fc3 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -477,7 +477,7 @@ void TonyEngine::closeVoiceDatabase() { } void TonyEngine::grabThumbnail(void) { - _window.GrabThumbnail(_curThumbnail); + _window.grabThumbnail(_curThumbnail); } void TonyEngine::optionScreen(void) { @@ -533,13 +533,13 @@ void TonyEngine::playProcess(CORO_PARAM, const void *param) { // Handle drawing the frame if (!_vm->_bPaused) { if (!_vm->_theEngine._bWiping) - _vm->_window.GetNewFrame(_vm->_theEngine, NULL); + _vm->_window.getNewFrame(_vm->_theEngine, NULL); else - _vm->_window.GetNewFrame(_vm->_theEngine, &_vm->_theEngine._rcWipeEllipse); + _vm->_window.getNewFrame(_vm->_theEngine, &_vm->_theEngine._rcWipeEllipse); } // Paint the frame onto the screen - _vm->_window.Repaint(); + _vm->_window.repaint(); // Signal the ScummVM debugger _vm->_debugger->onFrame(); @@ -570,12 +570,12 @@ void TonyEngine::close(void) { CoroScheduler.closeEvent(_hEndOfFrame); _theBoxes.Close(); _theEngine.close(); - _window.Close(); + _window.close(); delete[] _curThumbnail; } void TonyEngine::switchFullscreen(bool bFull) { - _window.SwitchFullscreen(bFull); + _window.switchFullscreen(bFull); _theEngine.switchFullscreen(bFull); } @@ -617,7 +617,7 @@ Common::Error TonyEngine::saveGameState(int slot, const Common::String &desc) { return Common::kUnknownError; RMSnapshot s; - s.GrabScreenshot(*GLOBALS.GfxEngine, 4, _curThumbnail); + s.grabScreenshot(*GLOBALS.GfxEngine, 4, _curThumbnail); GLOBALS.GfxEngine->saveState(getSaveStateFileName(slot), (byte *)_curThumbnail, desc); return Common::kNoError; diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index 5d73443167..cfa9d088e3 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -44,8 +44,8 @@ RMWindow::RMWindow() { } RMWindow::~RMWindow() { - Close(); - RMText::Unload(); + close(); + RMText::unload(); } /** @@ -58,40 +58,40 @@ void RMWindow::init() { // Inizializza i conteggi degli FPS fps = lastfcount = fcount = lastsecond = 0; - m_bGrabScreenshot = false; - m_bGrabThumbnail = false; - m_bGrabMovie = false; + _bGrabScreenshot = false; + _bGrabThumbnail = false; + _bGrabMovie = false; } /** * Close the window */ -void RMWindow::Close(void) { +void RMWindow::close(void) { } -void RMWindow::GrabThumbnail(uint16 *thumbmem) { - m_bGrabThumbnail = true; - m_wThumbBuf = thumbmem; +void RMWindow::grabThumbnail(uint16 *thumbmem) { + _bGrabThumbnail = true; + _wThumbBuf = thumbmem; } /** * Repaint the screen */ -void RMWindow::Repaint(void) { +void RMWindow::repaint(void) { g_system->updateScreen(); } -bool RMWindow::Lock() { +bool RMWindow::lock() { return true; } -void RMWindow::Unlock() { +void RMWindow::unlock() { } /** * Wipes an area of the screen */ -void RMWindow::WipeEffect(Common::Rect &rcBoundEllipse) { +void RMWindow::wipeEffect(Common::Rect &rcBoundEllipse) { if ((rcBoundEllipse.left == 0) && (rcBoundEllipse.top == 0) && (rcBoundEllipse.right == RM_SX) && (rcBoundEllipse.bottom == RM_SY)) { // Full screen clear wanted, so use shortcut method @@ -108,28 +108,28 @@ void RMWindow::WipeEffect(Common::Rect &rcBoundEllipse) { } } -void RMWindow::GetNewFrame(byte *lpBuf, Common::Rect *rcBoundEllipse) { +void RMWindow::getNewFrame(byte *lpBuf, Common::Rect *rcBoundEllipse) { if (rcBoundEllipse != NULL) { // Circular wipe effect - GetNewFrameWipe(lpBuf, *rcBoundEllipse); + getNewFrameWipe(lpBuf, *rcBoundEllipse); } else { // Standard screen copy g_system->copyRectToScreen(lpBuf, RM_SX * 2, 0, 0, RM_SX, RM_SY); } - if (m_bGrabThumbnail) { + if (_bGrabThumbnail) { // Need to generate a thumbnail RMSnapshot s; - s.GrabScreenshot(lpBuf, 4, m_wThumbBuf); - m_bGrabThumbnail = false; + s.grabScreenshot(lpBuf, 4, _wThumbBuf); + _bGrabThumbnail = false; } } /** * Copies a section of the game frame in a circle bounded by the specified rectangle */ -void RMWindow::GetNewFrameWipe(byte *lpBuf, Common::Rect &rcBoundEllipse) { +void RMWindow::getNewFrameWipe(byte *lpBuf, Common::Rect &rcBoundEllipse) { // Clear the screen g_system->fillScreen(0); @@ -208,7 +208,7 @@ void RMWindow::plotLines(const byte *lpBuf, const Common::Point ¢er, int x, byte RMSnapshot::rgb[RM_SX *RM_SY * 3]; -void RMSnapshot::GrabScreenshot(byte *lpBuf, int dezoom, uint16 *lpDestBuf) { +void RMSnapshot::grabScreenshot(byte *lpBuf, int dezoom, uint16 *lpDestBuf) { uint16 *src = (uint16 *)lpBuf; int dimx = RM_SX / dezoom; diff --git a/engines/tony/window.h b/engines/tony/window.h index 70e74eb54d..3d1199482f 100644 --- a/engines/tony/window.h +++ b/engines/tony/window.h @@ -45,14 +45,14 @@ private: static byte rgb[RM_SX *RM_SY * 3]; public: // Take a screenshot - void GrabScreenshot(byte *lpBuf, int dezoom = 1, uint16 *lpDestBuf = NULL); + void grabScreenshot(byte *lpBuf, int dezoom = 1, uint16 *lpDestBuf = NULL); }; class RMWindow { private: - bool Lock(); - void Unlock(); + bool lock(); + void unlock(); void plotSplices(const byte *lpBuf, const Common::Point ¢er, int x, int y); void plotLines(const byte *lpBuf, const Common::Point ¢er, int x, int y); @@ -65,14 +65,14 @@ protected: int mskRed, mskGreen, mskBlue; - bool m_bGrabScreenshot; - bool m_bGrabThumbnail; - bool m_bGrabMovie; - uint16 *m_wThumbBuf; + bool _bGrabScreenshot; + bool _bGrabThumbnail; + bool _bGrabMovie; + uint16 *_wThumbBuf; - void CreateBWPrecalcTable(void); - void WipeEffect(Common::Rect &rcBoundEllipse); - void GetNewFrameWipe(byte *lpBuf, Common::Rect &rcBoundEllipse); + void createBWPrecalcTable(void); + void wipeEffect(Common::Rect &rcBoundEllipse); + void getNewFrameWipe(byte *lpBuf, Common::Rect &rcBoundEllipse); public: RMWindow(); @@ -81,19 +81,19 @@ public: // Initialisation void init(/*HINSTANCE hInst*/); void initDirectDraw(void); - void Close(void); + void close(void); // Drawing - void Repaint(void); + void repaint(void); // Switch between windowed and fullscreen - void SwitchFullscreen(bool bFull) {} + void switchFullscreen(bool bFull) {} // Reads the next frame - void GetNewFrame(byte *lpBuf, Common::Rect *rcBoundEllipse); + void getNewFrame(byte *lpBuf, Common::Rect *rcBoundEllipse); // Request a thumbnail be grabbed during the next frame - void GrabThumbnail(uint16 *buf); + void grabThumbnail(uint16 *buf); int getFps() const { return fps; -- cgit v1.2.3 From 53e38106b73e6ad9e6f725857483bfd35e961326 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 6 Jun 2012 08:31:06 +0200 Subject: TONY: Rename variables and functions in inventory.h That fixes the regression in the credits --- engines/tony/custom.cpp | 6 +- engines/tony/font.cpp | 9 +- engines/tony/font.h | 4 +- engines/tony/gfxengine.cpp | 46 ++-- engines/tony/gfxengine.h | 2 +- engines/tony/inventory.cpp | 639 +++++++++++++++++++++++---------------------- engines/tony/inventory.h | 104 ++++---- 7 files changed, 407 insertions(+), 403 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 84bafc2cd1..2725f2565e 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -1559,15 +1559,15 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess } DECLARE_CUSTOM_FUNCTION(AddInventory)(CORO_PARAM, uint32 dwCode, uint32, uint32, uint32) { - GLOBALS.Inventory->AddItem(dwCode); + GLOBALS.Inventory->addItem(dwCode); } DECLARE_CUSTOM_FUNCTION(RemoveInventory)(CORO_PARAM, uint32 dwCode, uint32, uint32, uint32) { - GLOBALS.Inventory->RemoveItem(dwCode); + GLOBALS.Inventory->removeItem(dwCode); } DECLARE_CUSTOM_FUNCTION(ChangeInventoryStatus)(CORO_PARAM, uint32 dwCode, uint32 dwStatus, uint32, uint32) { - GLOBALS.Inventory->ChangeItemStatus(dwCode, dwStatus); + GLOBALS.Inventory->changeItemStatus(dwCode, dwStatus); } diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index e967f38199..bc32939061 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -157,10 +157,9 @@ RMFontColor::RMFontColor() : RMFont() { } RMFontColor::~RMFontColor() { - } -void RMFontColor::SetBaseColor(byte r1, byte g1, byte b1) { +void RMFontColor::setBaseColor(byte r1, byte g1, byte b1) { int r = (int)r1 << 16; int g = (int)g1 << 16; int b = (int)b1 << 16; @@ -1832,7 +1831,7 @@ void RMText::writeText(const RMString &text, RMFontColor *font, int *time) { int numlines; // Set the base colour - font->SetBaseColor(m_r, m_g, m_b); + font->setBaseColor(m_r, m_g, m_b); // Destroy the buffer before starting destroy(); @@ -2244,8 +2243,8 @@ void RMTextItemName::doFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation & _curscroll = loc.ScrollPosition(); // Check if we are on the inventory - if (inv.ItemInFocus(_mpos)) - _item = inv.WhichItemIsIn(_mpos); + if (inv.itemInFocus(_mpos)) + _item = inv.whichItemIsIn(_mpos); else _item = loc.WhichItemIsIn(_mpos); diff --git a/engines/tony/font.h b/engines/tony/font.h index d39b9752a7..2e2b1724a9 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -60,7 +60,7 @@ private: RMFontPrimitive() : RMGfxPrimitive() {} RMFontPrimitive(RMGfxTask *task) : RMGfxPrimitive(task) {} virtual ~RMFontPrimitive() { } - virtual RMGfxPrimitive *Duplicate() { + virtual RMGfxPrimitive *duplicate() { return new RMFontPrimitive(*this); } @@ -112,7 +112,7 @@ private: public: RMFontColor(); virtual ~RMFontColor(); - virtual void SetBaseColor(byte r, byte g, byte b); + virtual void setBaseColor(byte r, byte g, byte b); }; diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 08976e6092..a80552b1d1 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -112,7 +112,7 @@ void RMGfxEngine::openOptionScreen(CORO_PARAM, int type) { _vm->pauseSound(true); disableInput(); - _inv.EndCombine(); + _inv.endCombine(); _curActionObj = 0; _curAction = TA_GOTO; _point.setAction(_curAction); @@ -172,12 +172,12 @@ void RMGfxEngine::doFrame(CORO_PARAM, bool bDrawLocation) { // Check the mouse input if (_bInput && !_tony.InAction()) { // If we are on the inventory, it is it who controls all input - if (_inv.HaveFocus(_input.mousePos()) && !_inter.Active()) { + if (_inv.haveFocus(_input.mousePos()) && !_inter.active()) { // Left Click // ********** if (_input.mouseLeftClicked()/* && m_itemName.IsItemSelected()*/) { // Left click activates the combine, if we are on an object - if (_inv.LeftClick(_input.mousePos(), _curActionObj)) { + if (_inv.leftClick(_input.mousePos(), _curActionObj)) { _curAction = TA_COMBINE; _point.setAction(_curAction); } @@ -188,15 +188,15 @@ void RMGfxEngine::doFrame(CORO_PARAM, bool bDrawLocation) { if (_input.mouseRightClicked()) { if (_itemName.isItemSelected()) { _curActionObj = 0; - _inv.RightClick(_input.mousePos()); + _inv.rightClick(_input.mousePos()); } else - _inv.RightClick(_input.mousePos()); + _inv.rightClick(_input.mousePos()); } else // Right Release // ************* if (_input.mouseRightReleased()) { - if (_inv.RightRelease(_input.mousePos(), _curAction)) { + if (_inv.rightRelease(_input.mousePos(), _curAction)) { CORO_INVOKE_3(_tony.MoveAndDoAction, _itemName.getHotspot(), _itemName.getSelectedItem(), _curAction); _curAction = TA_GOTO; @@ -226,7 +226,7 @@ void RMGfxEngine::doFrame(CORO_PARAM, bool bDrawLocation) { // Left Click // ************** - if (_input.mouseLeftClicked() && !_inter.Active()) { + if (_input.mouseLeftClicked() && !_inter.active()) { if (_curAction != TA_COMBINE) CORO_INVOKE_3(_tony.MoveAndDoAction, _itemName.getHotspot(), _itemName.getSelectedItem(), _point.curAction()); @@ -234,7 +234,7 @@ void RMGfxEngine::doFrame(CORO_PARAM, bool bDrawLocation) { CORO_INVOKE_4(_tony.MoveAndDoAction, _itemName.getHotspot(), _itemName.getSelectedItem(), TA_COMBINE, _curActionObj); if (_curAction == TA_COMBINE) { - _inv.EndCombine(); + _inv.endCombine(); _point.setSpecialPointer(RMPointer::PTR_NONE); } @@ -248,7 +248,7 @@ SKIPCLICKSINISTRO: if (_curAction == TA_COMBINE) { // During a combine, it cancels it if (_input.mouseRightClicked()) { - _inv.EndCombine(); + _inv.endCombine(); _curActionObj = 0; _curAction = TA_GOTO; _point.setAction(_curAction); @@ -260,7 +260,7 @@ SKIPCLICKSINISTRO: _curAction = TA_GOTO; _curActionObj = 0; _point.setAction(_curAction); - _inter.Clicked(_input.mousePos()); + _inter.clicked(_input.mousePos()); } } @@ -269,7 +269,7 @@ SKIPCLICKSINISTRO: // ************* if (_input.mouseRightReleased()) { if (_bGUIInterface) { - if (_inter.Released(_input.mousePos(), _curAction)) { + if (_inter.released(_input.mousePos(), _curAction)) { _point.setAction(_curAction); CORO_INVOKE_3(_tony.MoveAndDoAction, _itemName.getHotspot(), _itemName.getSelectedItem(), _curAction); @@ -282,13 +282,13 @@ SKIPCLICKSINISTRO: // Update the name under the mouse pointer _itemName.setMouseCoord(_input.mousePos()); - if (!_inter.Active() && !_inv.MiniActive()) + if (!_inter.active() && !_inv.miniActive()) CORO_INVOKE_4(_itemName.doFrame, _bigBuf, _loc, _point, _inv); } // Interface & Inventory - _inter.DoFrame(_bigBuf, _input.mousePos()); - _inv.doFrame(_bigBuf, _point, _input.mousePos(), (!_tony.InAction() && !_inter.Active() && _bGUIInventory)); + _inter.doFrame(_bigBuf, _input.mousePos()); + _inv.doFrame(_bigBuf, _point, _input.mousePos(), (!_tony.InAction() && !_inter.active() && _bGUIInventory)); } // Animate Tony @@ -396,7 +396,7 @@ void RMGfxEngine::initForNewLocation(int nLoc, RMPoint ptTonyStart, RMPoint star _point.setCustomPointer(NULL); _point.setSpecialPointer(RMPointer::PTR_NONE); _point.setAction(_curAction); - _inter.Reset(); + _inter.reset(); _inv.reset(); mpalStartIdlePoll(_nCurLoc); @@ -507,7 +507,7 @@ void RMGfxEngine::init() { // Initialise the inventory and the interface _inv.init(); - _inter.Init(); + _inter.init(); // Download the location and set priorities @@@@@ _bLocationLoaded = false; @@ -521,7 +521,7 @@ void RMGfxEngine::init() { void RMGfxEngine::close(void) { _bigBuf.clearOT(); - _inter.Close(); + _inter.close(); _inv.close(); _tony.Close(); _point.close(); @@ -540,7 +540,7 @@ void RMGfxEngine::enableInput(void) { void RMGfxEngine::disableInput(void) { _bInput = false; - _inter.Reset(); + _inter.reset(); } void RMGfxEngine::enableMouse(void) { @@ -619,9 +619,9 @@ void RMGfxEngine::saveState(const Common::String &fn, byte *curThumb, const Comm delete[] state; // Inventory - size = _inv.GetSaveStateSize(); + size = _inv.getSaveStateSize(); state = new byte[size]; - _inv.SaveState(state); + _inv.saveState(state); f->writeUint32LE(size); f->write(state, size); delete[] state; @@ -640,7 +640,7 @@ void RMGfxEngine::saveState(const Common::String &fn, byte *curThumb, const Comm // Saves the state of the shepherdess and show yourself bStat = _tony.GetPastorella(); f->writeByte(bStat); - bStat = _inter.GetPalesati(); + bStat = _inter.getPalesati(); f->writeByte(bStat); // Save the chars @@ -758,7 +758,7 @@ void RMGfxEngine::loadState(CORO_PARAM, const Common::String &fn) { _ctx->size = _ctx->f->readUint32LE(); _ctx->state = new byte[_ctx->size]; _ctx->f->read(_ctx->state, _ctx->size); - _inv.LoadState(_ctx->state); + _inv.loadState(_ctx->state); delete[] _ctx->state; if (_ctx->ver >= 0x2) { // Versione 2: box please @@ -776,7 +776,7 @@ void RMGfxEngine::loadState(CORO_PARAM, const Common::String &fn) { bStat = _ctx->f->readByte(); _tony.SetPastorella(bStat); bStat = _ctx->f->readByte(); - _inter.SetPalesati(bStat); + _inter.setPalesati(bStat); CharsLoadAll(_ctx->f); } diff --git a/engines/tony/gfxengine.h b/engines/tony/gfxengine.h index 69d36cbbc0..8d9648c454 100644 --- a/engines/tony/gfxengine.h +++ b/engines/tony/gfxengine.h @@ -145,7 +145,7 @@ public: void waitWipeEnd(CORO_PARAM); void setPalesati(bool bpal) { - _inter.SetPalesati(bpal); + _inter.setPalesati(bpal); } bool canLoadSave(); }; diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index 360e53803e..595a1ba0f2 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -40,31 +40,31 @@ namespace Tony { \****************************************************************************/ RMInventory::RMInventory() { - m_items = NULL; - m_state = CLOSED; - m_bCombining = false; - m_csModifyInterface = g_system->createMutex(); - m_nItems = 0; - - Common::fill(m_inv, m_inv + 256, 0); - m_nInv = 0; - m_curPutY = 0; - m_curPutTime = 0; - m_curPos = 0; - m_bHasFocus = false; - m_nSelectObj = 0; - m_nCombine = 0; - m_bBlinkingRight = false; - m_bBlinkingLeft = false; + _items = NULL; + _state = CLOSED; + _bCombining = false; + _csModifyInterface = g_system->createMutex(); + _nItems = 0; + + Common::fill(_inv, _inv + 256, 0); + _nInv = 0; + _curPutY = 0; + _curPutTime = 0; + _curPos = 0; + _bHasFocus = false; + _nSelectObj = 0; + _nCombine = 0; + _bBlinkingRight = false; + _bBlinkingLeft = false; miniAction = 0; } RMInventory::~RMInventory() { close(); - g_system->deleteMutex(m_csModifyInterface); + g_system->deleteMutex(_csModifyInterface); } -bool RMInventory::CheckPointInside(const RMPoint &pt) { +bool RMInventory::checkPointInside(const RMPoint &pt) { if (!GLOBALS.bCfgInvUp) return pt.y > RM_SY - 70; else @@ -81,18 +81,18 @@ void RMInventory::init(void) { setPriority(185); // Setup the inventory - m_nInv = 0; - m_curPos = 0; - m_bCombining = false; + _nInv = 0; + _curPos = 0; + _bCombining = false; // New items - m_nItems = 78; // @@@ Number of takeable items - m_items = new RMInventoryItem[m_nItems + 1]; + _nItems = 78; // @@@ Number of takeable items + _items = new RMInventoryItem[_nItems + 1]; curres = 10500; // Loop through the items - for (i = 0; i <= m_nItems; i++) { + for (i = 0; i <= _nItems; i++) { // Load the items from the resource RMRes res(curres); RMDataStream ds; @@ -100,34 +100,35 @@ void RMInventory::init(void) { assert(res.IsValid()); // Initialise the MPAL inventory item by reading it in. - m_items[i].icon.SetInitCurPattern(false); + _items[i].icon.SetInitCurPattern(false); ds.OpenBuffer(res); - ds >> m_items[i].icon; + ds >> _items[i].icon; ds.Close(); // Puts in the default pattern 1 - m_items[i].pointer = NULL; - m_items[i].status = 1; - m_items[i].icon.SetPattern(1); - m_items[i].icon.doFrame(this, false); + _items[i].pointer = NULL; + _items[i].status = 1; + _items[i].icon.SetPattern(1); + _items[i].icon.doFrame(this, false); curres++; - if (i == 0 || i == 28 || i == 29) continue; + if (i == 0 || i == 28 || i == 29) + continue; - m_items[i].pointer = new RMGfxSourceBuffer8RLEByteAA[m_items[i].icon.NumPattern()]; + _items[i].pointer = new RMGfxSourceBuffer8RLEByteAA[_items[i].icon.NumPattern()]; - for (j = 0; j < m_items[i].icon.NumPattern(); j++) { + for (j = 0; j < _items[i].icon.NumPattern(); j++) { RMResRaw raw(curres); assert(raw.IsValid()); - m_items[i].pointer[j].init((const byte *)raw, raw.Width(), raw.Height(), true); + _items[i].pointer[j].init((const byte *)raw, raw.Width(), raw.Height(), true); curres++; } } - m_items[28].icon.SetPattern(1); - m_items[29].icon.SetPattern(1); + _items[28].icon.SetPattern(1); + _items[29].icon.SetPattern(1); // Download interface RMDataStream ds; @@ -139,18 +140,18 @@ void RMInventory::init(void) { ds.Close(); // Create the text for hints on the mini interface - m_hints[0].setAlignType(RMText::HCENTER, RMText::VTOP); - m_hints[1].setAlignType(RMText::HCENTER, RMText::VTOP); - m_hints[2].setAlignType(RMText::HCENTER, RMText::VTOP); + _hints[0].setAlignType(RMText::HCENTER, RMText::VTOP); + _hints[1].setAlignType(RMText::HCENTER, RMText::VTOP); + _hints[2].setAlignType(RMText::HCENTER, RMText::VTOP); // The text is taken from MPAL for translation RMMessage msg1(15); RMMessage msg2(13); RMMessage msg3(14); - m_hints[0].writeText(msg1[0], 1); // Examine - m_hints[1].writeText(msg2[0], 1); // Take - m_hints[2].writeText(msg3[0], 1); // Use + _hints[0].writeText(msg1[0], 1); // Examine + _hints[1].writeText(msg2[0], 1); // Take + _hints[2].writeText(msg3[0], 1); // Use // Prepare initial inventory @@ -161,22 +162,22 @@ void RMInventory::init(void) { void RMInventory::close(void) { // Has memory - if (m_items != NULL) { + if (_items != NULL) { // Delete the item pointers - for (int i = 0; i <= m_nItems; i++) - delete[] m_items[i].pointer; + for (int i = 0; i <= _nItems; i++) + delete[] _items[i].pointer; // Delete the items array - delete[] m_items; - m_items = NULL; + delete[] _items; + _items = NULL; } destroy(); } void RMInventory::reset(void) { - m_state = CLOSED; - EndCombine(); + _state = CLOSED; + endCombine(); } void RMInventory::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { @@ -189,23 +190,23 @@ void RMInventory::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr CORO_BEGIN_CODE(_ctx); - if (m_state == OPENING || m_state == CLOSING) - prim->setDst(RMPoint(0, m_curPutY)); + if (_state == OPENING || _state == CLOSING) + prim->setDst(RMPoint(0, _curPutY)); else - prim->setDst(RMPoint(0, m_curPutY)); + prim->setDst(RMPoint(0, _curPutY)); - g_system->lockMutex(m_csModifyInterface); + g_system->lockMutex(_csModifyInterface); CORO_INVOKE_2(RMGfxWoodyBuffer::draw, bigBuf, prim); - g_system->unlockMutex(m_csModifyInterface); + g_system->unlockMutex(_csModifyInterface); - if (m_state == SELECTING) { + if (_state == SELECTING) { if (!GLOBALS.bCfgInvUp) { - _ctx->pos.Set((m_nSelectObj + 1) * 64 - 20, RM_SY - 113); - _ctx->pos2.Set((m_nSelectObj + 1) * 64 + 34, RM_SY - 150); + _ctx->pos.Set((_nSelectObj + 1) * 64 - 20, RM_SY - 113); + _ctx->pos2.Set((_nSelectObj + 1) * 64 + 34, RM_SY - 150); } else { - _ctx->pos.Set((m_nSelectObj + 1) * 64 - 20, 72 - 4); // The brown part is at the top :( - _ctx->pos2.Set((m_nSelectObj + 1) * 64 + 34, 119 - 4); + _ctx->pos.Set((_nSelectObj + 1) * 64 - 20, 72 - 4); // The brown part is at the top :( + _ctx->pos2.Set((_nSelectObj + 1) * 64 + 34, 119 - 4); } _ctx->p = new RMGfxPrimitive(prim->_task, _ctx->pos); @@ -216,11 +217,11 @@ void RMInventory::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr if (GLOBALS.bCfgInterTips) { if (miniAction == 1) // Examine - CORO_INVOKE_2(m_hints[0].draw, bigBuf, _ctx->p2); + CORO_INVOKE_2(_hints[0].draw, bigBuf, _ctx->p2); else if (miniAction == 2) // Talk - CORO_INVOKE_2(m_hints[1].draw, bigBuf, _ctx->p2); + CORO_INVOKE_2(_hints[1].draw, bigBuf, _ctx->p2); else if (miniAction == 3) // Use - CORO_INVOKE_2(m_hints[2].draw, bigBuf, _ctx->p2); + CORO_INVOKE_2(_hints[2].draw, bigBuf, _ctx->p2); } delete _ctx->p; @@ -231,62 +232,62 @@ void RMInventory::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr } void RMInventory::removeThis(CORO_PARAM, bool &result) { - if (m_state == CLOSED) + if (_state == CLOSED) result = true; else result = false; } -void RMInventory::RemoveItem(int code) { +void RMInventory::removeItem(int code) { int i; - for (i = 0; i < m_nInv; i++) - if (m_inv[i] == code - 10000) { - g_system->lockMutex(m_csModifyInterface); + for (i = 0; i < _nInv; i++) + if (_inv[i] == code - 10000) { + g_system->lockMutex(_csModifyInterface); - Common::copy(&m_inv[i + 1], &m_inv[i + 1] + (m_nInv - i), &m_inv[i]); - m_nInv--; + Common::copy(&_inv[i + 1], &_inv[i + 1] + (_nInv - i), &_inv[i]); + _nInv--; prepare(); drawOT(Common::nullContext); clearOT(); - g_system->unlockMutex(m_csModifyInterface); + g_system->unlockMutex(_csModifyInterface); return; } } -void RMInventory::AddItem(int code) { +void RMInventory::addItem(int code) { if (code <= 10000 && code >= 10101) { // If we are here, it means that we are adding an item that should not be in the inventory warning("Cannot find a valid icon for this item, and then it will not be added to the inventory"); } else { - g_system->lockMutex(m_csModifyInterface); - if (m_curPos + 8 == m_nInv) { + g_system->lockMutex(_csModifyInterface); + if (_curPos + 8 == _nInv) { // Break through the inventory! On the flashing pattern - m_items[28].icon.SetPattern(2); + _items[28].icon.SetPattern(2); } - m_inv[m_nInv++] = code - 10000; + _inv[_nInv++] = code - 10000; prepare(); drawOT(Common::nullContext); clearOT(); - g_system->unlockMutex(m_csModifyInterface); + g_system->unlockMutex(_csModifyInterface); } } -void RMInventory::ChangeItemStatus(uint32 code, uint32 dwStatus) { +void RMInventory::changeItemStatus(uint32 code, uint32 dwStatus) { if (code <= 10000 && code >= 10101) { error("Specified object code is not valid"); } else { - g_system->lockMutex(m_csModifyInterface); - m_items[code - 10000].icon.SetPattern(dwStatus); - m_items[code - 10000].status = dwStatus; + g_system->lockMutex(_csModifyInterface); + _items[code - 10000].icon.SetPattern(dwStatus); + _items[code - 10000].status = dwStatus; prepare(); drawOT(Common::nullContext); clearOT(); - g_system->unlockMutex(m_csModifyInterface); + g_system->unlockMutex(_csModifyInterface); } } @@ -295,52 +296,52 @@ void RMInventory::prepare(void) { int i; for (i = 1; i < RM_SX / 64 - 1; i++) { - if (i - 1 + m_curPos < m_nInv) - addPrim(new RMGfxPrimitive(&m_items[m_inv[i - 1 + m_curPos]].icon, RMPoint(i * 64, 0))); + if (i - 1 + _curPos < _nInv) + addPrim(new RMGfxPrimitive(&_items[_inv[i - 1 + _curPos]].icon, RMPoint(i * 64, 0))); else - addPrim(new RMGfxPrimitive(&m_items[0].icon, RMPoint(i * 64, 0))); + addPrim(new RMGfxPrimitive(&_items[0].icon, RMPoint(i * 64, 0))); } // Frecce - addPrim(new RMGfxPrimitive(&m_items[29].icon, RMPoint(0, 0))); - addPrim(new RMGfxPrimitive(&m_items[28].icon, RMPoint(640 - 64, 0))); + addPrim(new RMGfxPrimitive(&_items[29].icon, RMPoint(0, 0))); + addPrim(new RMGfxPrimitive(&_items[28].icon, RMPoint(640 - 64, 0))); } -bool RMInventory::MiniActive(void) { - return m_state == SELECTING; +bool RMInventory::miniActive(void) { + return _state == SELECTING; } -bool RMInventory::HaveFocus(const RMPoint &mpos) { +bool RMInventory::haveFocus(const RMPoint &mpos) { // When we combine, have the focus only if we are on an arrow (to scroll) - if (m_state == OPENED && m_bCombining && CheckPointInside(mpos) && (mpos.x < 64 || mpos.x > RM_SX - 64)) + if (_state == OPENED && _bCombining && checkPointInside(mpos) && (mpos.x < 64 || mpos.x > RM_SX - 64)) return true; // If the inventory is open, focus we we go over it - if (m_state == OPENED && !m_bCombining && CheckPointInside(mpos)) + if (_state == OPENED && !_bCombining && checkPointInside(mpos)) return true; // If we are selecting a verb (and then right down), we always focus - if (m_state == SELECTING) + if (_state == SELECTING) return true; return false; } -void RMInventory::EndCombine(void) { - m_bCombining = false; +void RMInventory::endCombine(void) { + _bCombining = false; } -bool RMInventory::LeftClick(const RMPoint &mpos, int &nCombineObj) { +bool RMInventory::leftClick(const RMPoint &mpos, int &nCombineObj) { int n; // The left click picks an item from your inventory to use it with the background n = mpos.x / 64; - if (m_state == OPENED) { - if (n > 0 && n < RM_SX / 64 - 1 && m_inv[n - 1 + m_curPos] != 0) { - m_bCombining = true; //m_state = COMBINING; - m_nCombine = m_inv[n - 1 + m_curPos]; - nCombineObj = m_nCombine + 10000; + if (_state == OPENED) { + if (n > 0 && n < RM_SX / 64 - 1 && _inv[n - 1 + _curPos] != 0) { + _bCombining = true; //m_state = COMBINING; + _nCombine = _inv[n - 1 + _curPos]; + nCombineObj = _nCombine + 10000; _vm->playUtilSFX(1); return true; @@ -348,116 +349,116 @@ bool RMInventory::LeftClick(const RMPoint &mpos, int &nCombineObj) { } // Click the right arrow - if ((m_state == OPENED) && m_bBlinkingRight) { - g_system->lockMutex(m_csModifyInterface); - m_curPos++; + if ((_state == OPENED) && _bBlinkingRight) { + g_system->lockMutex(_csModifyInterface); + _curPos++; - if (m_curPos + 8 >= m_nInv) { - m_bBlinkingRight = false; - m_items[28].icon.SetPattern(1); + if (_curPos + 8 >= _nInv) { + _bBlinkingRight = false; + _items[28].icon.SetPattern(1); } - if (m_curPos > 0) { - m_bBlinkingLeft = true; - m_items[29].icon.SetPattern(2); + if (_curPos > 0) { + _bBlinkingLeft = true; + _items[29].icon.SetPattern(2); } prepare(); drawOT(Common::nullContext); clearOT(); - g_system->unlockMutex(m_csModifyInterface); + g_system->unlockMutex(_csModifyInterface); } // Click the left arrow - else if ((m_state == OPENED) && m_bBlinkingLeft) { - assert(m_curPos > 0); - g_system->lockMutex(m_csModifyInterface); - m_curPos--; - - if (m_curPos == 0) { - m_bBlinkingLeft = false; - m_items[29].icon.SetPattern(1); + else if ((_state == OPENED) && _bBlinkingLeft) { + assert(_curPos > 0); + g_system->lockMutex(_csModifyInterface); + _curPos--; + + if (_curPos == 0) { + _bBlinkingLeft = false; + _items[29].icon.SetPattern(1); } - if (m_curPos + 8 < m_nInv) { - m_bBlinkingRight = true; - m_items[28].icon.SetPattern(2); + if (_curPos + 8 < _nInv) { + _bBlinkingRight = true; + _items[28].icon.SetPattern(2); } prepare(); drawOT(Common::nullContext); clearOT(); - g_system->unlockMutex(m_csModifyInterface); + g_system->unlockMutex(_csModifyInterface); } return false; } - -void RMInventory::RightClick(const RMPoint &mpos) { +void RMInventory::rightClick(const RMPoint &mpos) { int n; - assert(CheckPointInside(mpos)); + assert(checkPointInside(mpos)); - if (m_state == OPENED && !m_bCombining) { + if (_state == OPENED && !_bCombining) { // Open the context interface n = mpos.x / 64; - if (n > 0 && n < RM_SX / 64 - 1 && m_inv[n - 1 + m_curPos] != 0) { - m_state = SELECTING; + if (n > 0 && n < RM_SX / 64 - 1 && _inv[n - 1 + _curPos] != 0) { + _state = SELECTING; miniAction = 0; - m_nSelectObj = n - 1; + _nSelectObj = n - 1; _vm->playUtilSFX(0); } } - if ((m_state == OPENED) && m_bBlinkingRight) { - g_system->lockMutex(m_csModifyInterface); - m_curPos += 7; - if (m_curPos + 8 > m_nInv) - m_curPos = m_nInv - 8; + if ((_state == OPENED) && _bBlinkingRight) { + g_system->lockMutex(_csModifyInterface); + _curPos += 7; + if (_curPos + 8 > _nInv) + _curPos = _nInv - 8; - if (m_curPos + 8 <= m_nInv) { - m_bBlinkingRight = false; - m_items[28].icon.SetPattern(1); + if (_curPos + 8 <= _nInv) { + _bBlinkingRight = false; + _items[28].icon.SetPattern(1); } - if (m_curPos > 0) { - m_bBlinkingLeft = true; - m_items[29].icon.SetPattern(2); + if (_curPos > 0) { + _bBlinkingLeft = true; + _items[29].icon.SetPattern(2); } prepare(); drawOT(Common::nullContext); clearOT(); - g_system->unlockMutex(m_csModifyInterface); - } else if ((m_state == OPENED) && m_bBlinkingLeft) { - assert(m_curPos > 0); - g_system->lockMutex(m_csModifyInterface); - m_curPos -= 7; - if (m_curPos < 0) m_curPos = 0; - - if (m_curPos == 0) { - m_bBlinkingLeft = false; - m_items[29].icon.SetPattern(1); + g_system->unlockMutex(_csModifyInterface); + } else if ((_state == OPENED) && _bBlinkingLeft) { + assert(_curPos > 0); + g_system->lockMutex(_csModifyInterface); + _curPos -= 7; + if (_curPos < 0) + _curPos = 0; + + if (_curPos == 0) { + _bBlinkingLeft = false; + _items[29].icon.SetPattern(1); } - if (m_curPos + 8 < m_nInv) { - m_bBlinkingRight = true; - m_items[28].icon.SetPattern(2); + if (_curPos + 8 < _nInv) { + _bBlinkingRight = true; + _items[28].icon.SetPattern(2); } prepare(); drawOT(Common::nullContext); clearOT(); - g_system->unlockMutex(m_csModifyInterface); + g_system->unlockMutex(_csModifyInterface); } } -bool RMInventory::RightRelease(const RMPoint &mpos, RMTonyAction &curAction) { - if (m_state == SELECTING) { - m_state = OPENED; +bool RMInventory::rightRelease(const RMPoint &mpos, RMTonyAction &curAction) { + if (_state == SELECTING) { + _state = OPENED; if (miniAction == 1) { // Esamina curAction = TA_EXAMINE; @@ -480,147 +481,147 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo int i; bool bNeedRedraw = false; - if (m_state != CLOSED) { + if (_state != CLOSED) { // Clean up the OT list - g_system->lockMutex(m_csModifyInterface); + g_system->lockMutex(_csModifyInterface); clearOT(); // DoFrame makes all the objects currently in the inventory be displayed // @@@ Maybe we should do all takeable objects? Please does not help - for (i = 0; i < m_nInv; i++) - if (m_items[m_inv[i]].icon.doFrame(this, false) && (i >= m_curPos && i <= m_curPos + 7)) + for (i = 0; i < _nInv; i++) + if (_items[_inv[i]].icon.doFrame(this, false) && (i >= _curPos && i <= _curPos + 7)) bNeedRedraw = true; - if ((m_state == CLOSING || m_state == OPENING || m_state == OPENED) && CheckPointInside(mpos)) { + if ((_state == CLOSING || _state == OPENING || _state == OPENED) && checkPointInside(mpos)) { if (mpos.x > RM_SX - 64) { - if (m_curPos + 8 < m_nInv && !m_bBlinkingRight) { - m_items[28].icon.SetPattern(3); - m_bBlinkingRight = true; + if (_curPos + 8 < _nInv && !_bBlinkingRight) { + _items[28].icon.SetPattern(3); + _bBlinkingRight = true; bNeedRedraw = true; } - } else if (m_bBlinkingRight) { - m_items[28].icon.SetPattern(2); - m_bBlinkingRight = false; + } else if (_bBlinkingRight) { + _items[28].icon.SetPattern(2); + _bBlinkingRight = false; bNeedRedraw = true; } if (mpos.x < 64) { - if (m_curPos > 0 && !m_bBlinkingLeft) { - m_items[29].icon.SetPattern(3); - m_bBlinkingLeft = true; + if (_curPos > 0 && !_bBlinkingLeft) { + _items[29].icon.SetPattern(3); + _bBlinkingLeft = true; bNeedRedraw = true; } - } else if (m_bBlinkingLeft) { - m_items[29].icon.SetPattern(2); - m_bBlinkingLeft = false; + } else if (_bBlinkingLeft) { + _items[29].icon.SetPattern(2); + _bBlinkingLeft = false; bNeedRedraw = true; } } - if (m_items[28].icon.doFrame(this, false)) + if (_items[28].icon.doFrame(this, false)) bNeedRedraw = true; - if (m_items[29].icon.doFrame(this, false)) + if (_items[29].icon.doFrame(this, false)) bNeedRedraw = true; if (bNeedRedraw) prepare(); - g_system->unlockMutex(m_csModifyInterface); + g_system->unlockMutex(_csModifyInterface); } if (_vm->getEngine()->getInput().getAsyncKeyState(Common::KEYCODE_i)) { GLOBALS.bCfgInvLocked = !GLOBALS.bCfgInvLocked; } - if (m_bCombining) {//m_state == COMBINING) - ptr.setCustomPointer(&m_items[m_nCombine].pointer[m_items[m_nCombine].status - 1]); + if (_bCombining) {//m_state == COMBINING) + ptr.setCustomPointer(&_items[_nCombine].pointer[_items[_nCombine].status - 1]); ptr.setSpecialPointer(RMPointer::PTR_CUSTOM); } if (!GLOBALS.bCfgInvUp) { - if ((m_state == CLOSED) && (mpos.y > RM_SY - 10 || GLOBALS.bCfgInvLocked) && bCanOpen) { + if ((_state == CLOSED) && (mpos.y > RM_SY - 10 || GLOBALS.bCfgInvLocked) && bCanOpen) { if (!GLOBALS.bCfgInvNoScroll) { - m_state = OPENING; - m_curPutY = RM_SY - 1; - m_curPutTime = _vm->getTime(); + _state = OPENING; + _curPutY = RM_SY - 1; + _curPutTime = _vm->getTime(); } else { - m_state = OPENED; - m_curPutY = RM_SY - 68; + _state = OPENED; + _curPutY = RM_SY - 68; } - } else if (m_state == OPENED) { + } else if (_state == OPENED) { if ((mpos.y < RM_SY - 70 && !GLOBALS.bCfgInvLocked) || !bCanOpen) { if (!GLOBALS.bCfgInvNoScroll) { - m_state = CLOSING; - m_curPutY = RM_SY - 68; - m_curPutTime = _vm->getTime(); + _state = CLOSING; + _curPutY = RM_SY - 68; + _curPutTime = _vm->getTime(); } else { - m_state = CLOSED; + _state = CLOSED; } } - } else if (m_state == OPENING) { - while (m_curPutTime + INVSPEED < _vm->getTime()) { - m_curPutY -= 3; - m_curPutTime += INVSPEED; + } else if (_state == OPENING) { + while (_curPutTime + INVSPEED < _vm->getTime()) { + _curPutY -= 3; + _curPutTime += INVSPEED; } - if (m_curPutY <= RM_SY - 68) { - m_state = OPENED; - m_curPutY = RM_SY - 68; + if (_curPutY <= RM_SY - 68) { + _state = OPENED; + _curPutY = RM_SY - 68; } - } else if (m_state == CLOSING) { - while (m_curPutTime + INVSPEED < _vm->getTime()) { - m_curPutY += 3; - m_curPutTime += INVSPEED; + } else if (_state == CLOSING) { + while (_curPutTime + INVSPEED < _vm->getTime()) { + _curPutY += 3; + _curPutTime += INVSPEED; } - if (m_curPutY > 480) - m_state = CLOSED; + if (_curPutY > 480) + _state = CLOSED; } } else { - if ((m_state == CLOSED) && (mpos.y < 10 || GLOBALS.bCfgInvLocked) && bCanOpen) { + if ((_state == CLOSED) && (mpos.y < 10 || GLOBALS.bCfgInvLocked) && bCanOpen) { if (!GLOBALS.bCfgInvNoScroll) { - m_state = OPENING; - m_curPutY = - 68; - m_curPutTime = _vm->getTime(); + _state = OPENING; + _curPutY = - 68; + _curPutTime = _vm->getTime(); } else { - m_state = OPENED; - m_curPutY = 0; + _state = OPENED; + _curPutY = 0; } - } else if (m_state == OPENED) { + } else if (_state == OPENED) { if ((mpos.y > 70 && !GLOBALS.bCfgInvLocked) || !bCanOpen) { if (!GLOBALS.bCfgInvNoScroll) { - m_state = CLOSING; - m_curPutY = -2; - m_curPutTime = _vm->getTime(); + _state = CLOSING; + _curPutY = -2; + _curPutTime = _vm->getTime(); } else { - m_state = CLOSED; + _state = CLOSED; } } - } else if (m_state == OPENING) { - while (m_curPutTime + INVSPEED < _vm->getTime()) { - m_curPutY += 3; - m_curPutTime += INVSPEED; + } else if (_state == OPENING) { + while (_curPutTime + INVSPEED < _vm->getTime()) { + _curPutY += 3; + _curPutTime += INVSPEED; } - if (m_curPutY >= 0) { - m_state = OPENED; - m_curPutY = 0; + if (_curPutY >= 0) { + _state = OPENED; + _curPutY = 0; } - } else if (m_state == CLOSING) { - while (m_curPutTime + INVSPEED < _vm->getTime()) { - m_curPutY -= 3; - m_curPutTime += INVSPEED; + } else if (_state == CLOSING) { + while (_curPutTime + INVSPEED < _vm->getTime()) { + _curPutY -= 3; + _curPutTime += INVSPEED; } - if (m_curPutY < -68) - m_state = CLOSED; + if (_curPutY < -68) + _state = CLOSED; } } - if (m_state == SELECTING) { - int startx = (m_nSelectObj + 1) * 64 - 20; + if (_state == SELECTING) { + int startx = (_nSelectObj + 1) * 64 - 20; int starty; if (!GLOBALS.bCfgInvUp) @@ -661,27 +662,27 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo miniInterface.doFrame(&bigBuf, false); } - if ((m_state != CLOSED) && !_nInList) { + if ((_state != CLOSED) && !_nInList) { bigBuf.addPrim(new RMGfxPrimitive(this)); } } -bool RMInventory::ItemInFocus(const RMPoint &mpt) { - if ((m_state == OPENED || m_state == OPENING) && CheckPointInside(mpt)) +bool RMInventory::itemInFocus(const RMPoint &mpt) { + if ((_state == OPENED || _state == OPENING) && checkPointInside(mpt)) return true; else return false; } -RMItem *RMInventory::WhichItemIsIn(const RMPoint &mpt) { +RMItem *RMInventory::whichItemIsIn(const RMPoint &mpt) { int n; - if (m_state == OPENED) { - if (CheckPointInside(mpt)) { + if (_state == OPENED) { + if (checkPointInside(mpt)) { n = mpt.x / 64; - if (n > 0 && n < RM_SX / 64 - 1 && m_inv[n - 1 + m_curPos] != 0 && (!m_bCombining || m_inv[n - 1 + m_curPos] != m_nCombine)) - return &m_items[m_inv[n - 1 + m_curPos]].icon; + if (n > 0 && n < RM_SX / 64 - 1 && _inv[n - 1 + _curPos] != 0 && (!_bCombining || _inv[n - 1 + _curPos] != _nCombine)) + return &_items[_inv[n - 1 + _curPos]].icon; } } @@ -690,22 +691,22 @@ RMItem *RMInventory::WhichItemIsIn(const RMPoint &mpt) { -int RMInventory::GetSaveStateSize(void) { +int RMInventory::getSaveStateSize(void) { // m_inv pattern m_nInv return 256 * 4 + 256 * 4 + 4 ; } -void RMInventory::SaveState(byte *state) { +void RMInventory::saveState(byte *state) { int i, x; - WRITE_LE_UINT32(state, m_nInv); + WRITE_LE_UINT32(state, _nInv); state += 4; - Common::copy(m_inv, m_inv + 256, (uint32 *)state); + Common::copy(_inv, _inv + 256, (uint32 *)state); state += 256 * 4; for (i = 0; i < 256; i++) { - if (i < m_nItems) - x = m_items[i].status; + if (i < _nItems) + x = _items[i].status; else x = 0; @@ -714,39 +715,39 @@ void RMInventory::SaveState(byte *state) { } } -int RMInventory::LoadState(byte *state) { +int RMInventory::loadState(byte *state) { int i, x; - m_nInv = READ_LE_UINT32(state); + _nInv = READ_LE_UINT32(state); state += 4; - Common::copy((uint32 *)state, (uint32 *)state + 256, m_inv); + Common::copy((uint32 *)state, (uint32 *)state + 256, _inv); state += 256 * 4; for (i = 0; i < 256; i++) { x = READ_LE_UINT32(state); state += 4; - if (i < m_nItems) { - m_items[i].status = x; - m_items[i].icon.SetPattern(x); + if (i < _nItems) { + _items[i].status = x; + _items[i].icon.SetPattern(x); } } - m_curPos = 0; - m_bCombining = false; - - m_items[29].icon.SetPattern(1); + _curPos = 0; + _bCombining = false; + + _items[29].icon.SetPattern(1); - if (m_nInv > 8) - m_items[28].icon.SetPattern(2); + if (_nInv > 8) + _items[28].icon.SetPattern(2); else - m_items[28].icon.SetPattern(1); + _items[28].icon.SetPattern(1); prepare(); drawOT(Common::nullContext); clearOT(); - return GetSaveStateSize(); + return getSaveStateSize(); } @@ -758,22 +759,22 @@ RMInterface::~RMInterface() { } -bool RMInterface::Active() { - return m_bActive; +bool RMInterface::active() { + return _bActive; } -int RMInterface::OnWhichBox(RMPoint pt) { +int RMInterface::onWhichBox(RMPoint pt) { int max, i; - pt -= m_openStart; + pt -= _openStart; // Check how many verbs you have to consider max = 4; - if (m_bPalesati) max = 5; + if (_bPalesati) max = 5; // Find the verb for (i = 0; i < max; i++) - if (m_hotbbox[i].PtInRect(pt)) + if (_hotbbox[i].PtInRect(pt)) return i; // Found no verb @@ -787,64 +788,68 @@ void RMInterface::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr CORO_BEGIN_CODE(_ctx); - prim->Dst().TopLeft() = m_openStart; + prim->Dst().TopLeft() = _openStart; CORO_INVOKE_2(RMGfxSourceBuffer8RLEByte::draw, bigBuf, prim); // Check if there is a draw hot zone - _ctx->h = OnWhichBox(m_mpos); + _ctx->h = onWhichBox(_mpos); if (_ctx->h != -1) { - prim->Dst().TopLeft() = m_openStart; - CORO_INVOKE_2(m_hotzone[_ctx->h].draw, bigBuf, prim); + prim->Dst().TopLeft() = _openStart; + CORO_INVOKE_2(_hotzone[_ctx->h].draw, bigBuf, prim); - if (m_lastHotZone != _ctx->h) { - m_lastHotZone = _ctx->h; + if (_lastHotZone != _ctx->h) { + _lastHotZone = _ctx->h; _vm->playUtilSFX(1); } if (GLOBALS.bCfgInterTips) { - prim->Dst().TopLeft() = m_openStart + RMPoint(70, 177); - CORO_INVOKE_2(m_hints[_ctx->h].draw, bigBuf, prim); + prim->Dst().TopLeft() = _openStart + RMPoint(70, 177); + CORO_INVOKE_2(_hints[_ctx->h].draw, bigBuf, prim); } } else - m_lastHotZone = -1; + _lastHotZone = -1; CORO_END_CODE; } -void RMInterface::DoFrame(RMGfxTargetBuffer &bigBuf, RMPoint mousepos) { +void RMInterface::doFrame(RMGfxTargetBuffer &bigBuf, RMPoint mousepos) { // If needed, add to the OT schedule list - if (!_nInList && m_bActive) + if (!_nInList && _bActive) bigBuf.addPrim(new RMGfxPrimitive(this)); - m_mpos = mousepos; + _mpos = mousepos; } -void RMInterface::Clicked(const RMPoint &mousepos) { - m_bActive = true; - m_openPos = mousepos; +void RMInterface::clicked(const RMPoint &mousepos) { + _bActive = true; + _openPos = mousepos; // Calculate the top left corner of the interface - m_openStart = m_openPos - RMPoint(_dimx / 2, _dimy / 2); - m_lastHotZone = -1; + _openStart = _openPos - RMPoint(_dimx / 2, _dimy / 2); + _lastHotZone = -1; // Keep it inside the screen - if (m_openStart.x < 0) m_openStart.x = 0; - if (m_openStart.y < 0) m_openStart.y = 0; - if (m_openStart.x + _dimx > RM_SX) m_openStart.x = RM_SX - _dimx; - if (m_openStart.y + _dimy > RM_SY) m_openStart.y = RM_SY - _dimy; + if (_openStart.x < 0) + _openStart.x = 0; + if (_openStart.y < 0) + _openStart.y = 0; + if (_openStart.x + _dimx > RM_SX) + _openStart.x = RM_SX - _dimx; + if (_openStart.y + _dimy > RM_SY) + _openStart.y = RM_SY - _dimy; // Play the sound effect _vm->playUtilSFX(0); } -bool RMInterface::Released(const RMPoint &mousepos, RMTonyAction &action) { - if (!m_bActive) +bool RMInterface::released(const RMPoint &mousepos, RMTonyAction &action) { + if (!_bActive) return false; - m_bActive = false; + _bActive = false; - switch (OnWhichBox(mousepos)) { + switch (onWhichBox(mousepos)) { case 0: action = TA_TAKE; break; @@ -872,19 +877,19 @@ bool RMInterface::Released(const RMPoint &mousepos, RMTonyAction &action) { return true; } -void RMInterface::Reset(void) { - m_bActive = false; +void RMInterface::reset(void) { + _bActive = false; } -void RMInterface::SetPalesati(bool bOn) { - m_bPalesati = bOn; +void RMInterface::setPalesati(bool bOn) { + _bPalesati = bOn; } -bool RMInterface::GetPalesati(void) { - return m_bPalesati; +bool RMInterface::getPalesati(void) { + return _bPalesati; } -void RMInterface::Init(void) { +void RMInterface::init(void) { int i; RMResRaw inter(RES_I_INTERFACE); RMRes pal(RES_I_INTERPPAL); @@ -897,21 +902,21 @@ void RMInterface::Init(void) { for (i = 0; i < 5; i++) { RMResRaw part(RES_I_INTERP1 + i); - m_hotzone[i].init(part, part.Width(), part.Height()); - m_hotzone[i].loadPaletteWA(pal); + _hotzone[i].init(part, part.Width(), part.Height()); + _hotzone[i].loadPaletteWA(pal); } - m_hotbbox[0].SetRect(126, 123, 159, 208); // Take - m_hotbbox[1].SetRect(90, 130, 125, 186); // About - m_hotbbox[2].SetRect(110, 60, 152, 125); - m_hotbbox[3].SetRect(56, 51, 93, 99); - m_hotbbox[4].SetRect(51, 105, 82, 172); + _hotbbox[0].SetRect(126, 123, 159, 208); // Take + _hotbbox[1].SetRect(90, 130, 125, 186); // About + _hotbbox[2].SetRect(110, 60, 152, 125); + _hotbbox[3].SetRect(56, 51, 93, 99); + _hotbbox[4].SetRect(51, 105, 82, 172); - m_hints[0].setAlignType(RMText::HRIGHT, RMText::VTOP); - m_hints[1].setAlignType(RMText::HRIGHT, RMText::VTOP); - m_hints[2].setAlignType(RMText::HRIGHT, RMText::VTOP); - m_hints[3].setAlignType(RMText::HRIGHT, RMText::VTOP); - m_hints[4].setAlignType(RMText::HRIGHT, RMText::VTOP); + _hints[0].setAlignType(RMText::HRIGHT, RMText::VTOP); + _hints[1].setAlignType(RMText::HRIGHT, RMText::VTOP); + _hints[2].setAlignType(RMText::HRIGHT, RMText::VTOP); + _hints[3].setAlignType(RMText::HRIGHT, RMText::VTOP); + _hints[4].setAlignType(RMText::HRIGHT, RMText::VTOP); // The text is taken from MPAL for translation RMMessage msg0(12); @@ -920,24 +925,24 @@ void RMInterface::Init(void) { RMMessage msg3(15); RMMessage msg4(16); - m_hints[0].writeText(msg0[0], 1); // Take - m_hints[1].writeText(msg1[0], 1); // Talk - m_hints[2].writeText(msg2[0], 1); // Use - m_hints[3].writeText(msg3[0], 1); // Examine - m_hints[4].writeText(msg4[0], 1); // Show Yourself + _hints[0].writeText(msg0[0], 1); // Take + _hints[1].writeText(msg1[0], 1); // Talk + _hints[2].writeText(msg2[0], 1); // Use + _hints[3].writeText(msg3[0], 1); // Examine + _hints[4].writeText(msg4[0], 1); // Show Yourself - m_bActive = false; - m_bPalesati = false; - m_lastHotZone = 0; + _bActive = false; + _bPalesati = false; + _lastHotZone = 0; } -void RMInterface::Close(void) { +void RMInterface::close(void) { int i; destroy(); for (i = 0; i < 5; i++) - m_hotzone[i].destroy(); + _hotzone[i].destroy(); } } // End of namespace Tony diff --git a/engines/tony/inventory.h b/engines/tony/inventory.h index 3548317dcc..6ffb33dd21 100644 --- a/engines/tony/inventory.h +++ b/engines/tony/inventory.h @@ -55,35 +55,35 @@ private: }; protected: - int m_nItems; - RMInventoryItem *m_items; + int _nItems; + RMInventoryItem *_items; - int m_inv[256]; - int m_nInv; - int m_curPutY; - uint32 m_curPutTime; + int _inv[256]; + int _nInv; + int _curPutY; + uint32 _curPutTime; - int m_curPos; - STATE m_state; - bool m_bHasFocus; - int m_nSelectObj; - int m_nCombine; - bool m_bCombining; + int _curPos; + STATE _state; + bool _bHasFocus; + int _nSelectObj; + int _nCombine; + bool _bCombining; - bool m_bBlinkingRight, m_bBlinkingLeft; + bool _bBlinkingRight, _bBlinkingLeft; int miniAction; RMItem miniInterface; - RMText m_hints[3]; + RMText _hints[3]; - OSystem::MutexRef m_csModifyInterface; + OSystem::MutexRef _csModifyInterface; protected: // Prepare the image inventory. It should be recalled whenever the inventory changes void prepare(void); // Check if the mouse Y position is conrrect, even under the inventory portion of the screen - bool CheckPointInside(const RMPoint &pt); + bool checkPointInside(const RMPoint &pt); public: RMInventory(); @@ -104,93 +104,93 @@ public: virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Method for determining whether the inventory currently has the focus - bool HaveFocus(const RMPoint &mpos); + bool haveFocus(const RMPoint &mpos); // Method for determining if the mini interface is active - bool MiniActive(void); + bool miniActive(void); // Handle the left mouse click (only when the inventory has the focus) - bool LeftClick(const RMPoint &mpos, int &nCombineObj); + bool leftClick(const RMPoint &mpos, int &nCombineObj); // Handle the right mouse button (only when the inventory has the focus) - void RightClick(const RMPoint &mpos); - bool RightRelease(const RMPoint &mpos, RMTonyAction &curAction); + void rightClick(const RMPoint &mpos); + bool rightRelease(const RMPoint &mpos, RMTonyAction &curAction); // Warn that an item combine is over - void EndCombine(void); + void endCombine(void); public: // Add an item to the inventory - void AddItem(int code); + void addItem(int code); RMInventory &operator+=(RMItem *item) { - AddItem(item->MpalCode()); + addItem(item->MpalCode()); return *this; } RMInventory &operator+=(RMItem &item) { - AddItem(item.MpalCode()); + addItem(item.MpalCode()); return *this; } RMInventory &operator+=(int code) { - AddItem(code); + addItem(code); return *this; } // Removes an item - void RemoveItem(int code); + void removeItem(int code); // We are on an object? - RMItem *WhichItemIsIn(const RMPoint &mpt); - bool ItemInFocus(const RMPoint &mpt); + RMItem *whichItemIsIn(const RMPoint &mpt); + bool itemInFocus(const RMPoint &mpt); // Change the icon of an item - void ChangeItemStatus(uint32 dwCode, uint32 dwStatus); + void changeItemStatus(uint32 dwCode, uint32 dwStatus); // Save methods - int GetSaveStateSize(void); - void SaveState(byte *state); - int LoadState(byte *state); + int getSaveStateSize(void); + void saveState(byte *state); + int loadState(byte *state); }; class RMInterface : public RMGfxSourceBuffer8RLEByte { private: - bool m_bActive; - RMPoint m_mpos; - RMPoint m_openPos; - RMPoint m_openStart; - RMText m_hints[5]; - RMGfxSourceBuffer8RLEByte m_hotzone[5]; - RMRect m_hotbbox[5]; - bool m_bPalesati; - int m_lastHotZone; + bool _bActive; + RMPoint _mpos; + RMPoint _openPos; + RMPoint _openStart; + RMText _hints[5]; + RMGfxSourceBuffer8RLEByte _hotzone[5]; + RMRect _hotbbox[5]; + bool _bPalesati; + int _lastHotZone; protected: // Return which box a given point is in - int OnWhichBox(RMPoint pt); + int onWhichBox(RMPoint pt); public: virtual ~RMInterface(); // The usual DoFrame (poll the graphics engine) - void DoFrame(RMGfxTargetBuffer &bigBuf, RMPoint mousepos); + void doFrame(RMGfxTargetBuffer &bigBuf, RMPoint mousepos); // TRUE if it is active (you can select items) - bool Active(); + bool active(); // Initialisation - void Init(void); - void Close(void); + void init(void); + void close(void); // Reset the interface - void Reset(void); + void reset(void); // Warns of mouse clicks and releases - void Clicked(const RMPoint &mousepos); - bool Released(const RMPoint &mousepos, RMTonyAction &action); + void clicked(const RMPoint &mousepos); + bool released(const RMPoint &mousepos, RMTonyAction &action); // Enalbes or disables the fifth verb - void SetPalesati(bool bOn); - bool GetPalesati(void); + void setPalesati(bool bOn); + bool getPalesati(void); // Overloaded Draw virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); -- cgit v1.2.3 From 3a28323ba26786c89689f8ad637fcc5f4e0cdd9e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 6 Jun 2012 23:18:56 +1000 Subject: TONY: Added sub-folders for full English game and revised detection entry --- engines/tony/detection_tables.h | 7 +++++-- engines/tony/tony.cpp | 10 ++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) (limited to 'engines') diff --git a/engines/tony/detection_tables.h b/engines/tony/detection_tables.h index 97bcc30f4b..bf4af08d2f 100644 --- a/engines/tony/detection_tables.h +++ b/engines/tony/detection_tables.h @@ -29,8 +29,11 @@ static const TonyGameDescription gameDescriptions[] = { "tony", 0, { - {"roasted.mpr", 0, "06203dbbc85fdd1e6dc8fc211c1a6207", 135911071}, - {"roasted.mpc", 0, "57c4a3860cf899443c357e0078ea6f49", 366773}, + // TODO: AdvancedDetector seems to have a problem where it thinks data1.cab is unrecognised. + // Is it perhaps because the Agos engine also has detection entries for data1.cab? + {"data1.cab", 0, "ce82907242166bfb594d97bdb68f96d2", 4350}, + /*{"roasted.mpr", 0, "06203dbbc85fdd1e6dc8fc211c1a6207", 135911071}, + {"roasted.mpc", 0, "57c4a3860cf899443c357e0078ea6f49", 366773},*/ AD_LISTEND }, Common::EN_ANY, diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index ea378e0fc3..3549b54c2c 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -48,6 +48,12 @@ TonyEngine::TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc) : Eng DebugMan.addDebugChannel(kTonyDebugSound, "sound", "Sound debugging"); DebugMan.addDebugChannel(kTonyDebugMusic, "music", "Music debugging"); + // Add folders to the search directory list + const Common::FSNode gameDataDir(ConfMan.get("path")); + SearchMan.addSubDirectoryMatching(gameDataDir, "Voices"); + SearchMan.addSubDirectoryMatching(gameDataDir, "Roasted"); + SearchMan.addSubDirectoryMatching(gameDataDir, "Music"); + // Set up load slot number _initialLoadSlotNumber = -1; if (ConfMan.hasKey("save_slot")) { @@ -436,10 +442,6 @@ bool TonyEngine::openVoiceDatabase() { char id[4]; uint32 numfiles; - // Add the voices folder to the search directory list - const Common::FSNode gameDataDir(ConfMan.get("path")); - SearchMan.addSubDirectoryMatching(gameDataDir, "voices"); - // Open the voices database if (!_vdbFP.open("voices.vdb")) return false; -- cgit v1.2.3 From 53bd99ce870ac5bd7f65d1e45641e13070f652d0 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 7 Jun 2012 07:58:01 +0200 Subject: TONY: Rename variables and functions in loc.h and tonychar.h --- engines/tony/custom.cpp | 253 +++++------ engines/tony/debugger.cpp | 4 +- engines/tony/font.cpp | 14 +- engines/tony/game.h | 2 +- engines/tony/gfxengine.cpp | 68 +-- engines/tony/inventory.cpp | 60 +-- engines/tony/inventory.h | 4 +- engines/tony/loc.cpp | 1077 ++++++++++++++++++++++---------------------- engines/tony/loc.h | 326 +++++++------- engines/tony/tony.cpp | 4 +- engines/tony/tonychar.cpp | 677 ++++++++++++++-------------- engines/tony/tonychar.h | 120 ++--- 12 files changed, 1299 insertions(+), 1310 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 2725f2565e..d42ef94a17 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -109,7 +109,7 @@ const char *staccFileNames[] = { void ReapplyChangedHotspot(void) { int i; for (i = 0; i < GLOBALS.curChangedHotspot; i++) - GLOBALS.Loc->GetItemFromCode(GLOBALS.ChangedHotspot[i].dwCode)->ChangeHotspot(RMPoint(GLOBALS.ChangedHotspot[i].nX, GLOBALS.ChangedHotspot[i].nY)); + GLOBALS.Loc->getItemFromCode(GLOBALS.ChangedHotspot[i].dwCode)->changeHotspot(RMPoint(GLOBALS.ChangedHotspot[i].nX, GLOBALS.ChangedHotspot[i].nY)); } void SaveChangedHotspot(Common::OutSaveFile *f) { @@ -141,9 +141,9 @@ void LoadChangedHotspot(Common::InSaveFile *f) { */ void MCharResetCodes(void) { for (int i = 0; i < 10; i++) - GLOBALS.MCharacter[i].item = GLOBALS.Loc->GetItemFromCode(GLOBALS.MCharacter[i].code); + GLOBALS.MCharacter[i].item = GLOBALS.Loc->getItemFromCode(GLOBALS.MCharacter[i].code); for (int i = 0; i < 10; i++) - GLOBALS.Character[i].item = GLOBALS.Loc->GetItemFromCode(GLOBALS.Character[i].code); + GLOBALS.Character[i].item = GLOBALS.Loc->getItemFromCode(GLOBALS.Character[i].code); } void CharsSaveAll(Common::OutSaveFile *f) { @@ -168,19 +168,19 @@ void CharsLoadAll(Common::InSaveFile *f) { } DECLARE_CUSTOM_FUNCTION(FaceToMe)(CORO_PARAM, uint32, uint32, uint32, uint32) { - GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_STANDDOWN); + GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_STANDDOWN); } DECLARE_CUSTOM_FUNCTION(BackToMe)(CORO_PARAM, uint32, uint32, uint32, uint32) { - GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_STANDUP); + GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_STANDUP); } DECLARE_CUSTOM_FUNCTION(LeftToMe)(CORO_PARAM, uint32, uint32, uint32, uint32) { - GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_STANDLEFT); + GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_STANDLEFT); } DECLARE_CUSTOM_FUNCTION(RightToMe)(CORO_PARAM, uint32, uint32, uint32, uint32) { - GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_STANDRIGHT); + GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_STANDRIGHT); } @@ -263,8 +263,8 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX if (GLOBALS.bSkipIdle) return; - _ctx->msg.Load(dwMessage); - if (!_ctx->msg.IsValid()) { + _ctx->msg.load(dwMessage); + if (!_ctx->msg.isValid()) { return; } @@ -285,15 +285,15 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX } if (GLOBALS.nTonyNextTalkType != GLOBALS.Tony->TALK_NORMAL) { - CORO_INVOKE_1(GLOBALS.Tony->StartTalk, GLOBALS.nTonyNextTalkType); + CORO_INVOKE_1(GLOBALS.Tony->startTalk, GLOBALS.nTonyNextTalkType); if (!GLOBALS.bStaticTalk) GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; } else { - if (_ctx->msg.NumPeriods() > 1) - CORO_INVOKE_1(GLOBALS.Tony->StartTalk, GLOBALS.Tony->TALK_FIANCHI); + if (_ctx->msg.numPeriods() > 1) + CORO_INVOKE_1(GLOBALS.Tony->startTalk, GLOBALS.Tony->TALK_FIANCHI); else - CORO_INVOKE_1(GLOBALS.Tony->StartTalk, GLOBALS.Tony->TALK_NORMAL); + CORO_INVOKE_1(GLOBALS.Tony->startTalk, GLOBALS.Tony->TALK_NORMAL); } if (GLOBALS.curBackText) @@ -301,7 +301,7 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX GLOBALS.bTonyIsSpeaking = true; - for (_ctx->i = 0; _ctx->i < _ctx->msg.NumPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { + for (_ctx->i = 0; _ctx->i < _ctx->msg.numPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { _ctx->text.setInput(GLOBALS.Input); // Alignment @@ -315,9 +315,9 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX // Set the position if (nX == 0 && nY == 0) - _ctx->text.setPosition(GLOBALS.Tony->Position() - RMPoint(0, 130) - GLOBALS.Loc->ScrollPosition()); + _ctx->text.setPosition(GLOBALS.Tony->position() - RMPoint(0, 130) - GLOBALS.Loc->scrollPosition()); else - _ctx->text.setPosition(RMPoint(nX, nY) - GLOBALS.Loc->ScrollPosition()); + _ctx->text.setPosition(RMPoint(nX, nY) - GLOBALS.Loc->scrollPosition()); // Handling for always display if (GLOBALS.bAlwaysDisplay) { @@ -359,13 +359,13 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX if (GLOBALS.curBackText) GLOBALS.curBackText->show(); - CORO_INVOKE_0(GLOBALS.Tony->EndTalk); + CORO_INVOKE_0(GLOBALS.Tony->endTalk); CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(ChangeBoxStatus)(CORO_PARAM, uint32 nLoc, uint32 nBox, uint32 nStatus, uint32) { - GLOBALS.Boxes->ChangeBoxStatus(nLoc, nBox, nStatus); + GLOBALS.Boxes->changeBoxStatus(nLoc, nBox, nStatus); } @@ -408,16 +408,16 @@ DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgStart)(CORO_PARAM, uint32 nMsg, uint32 _ctx->msg = new RMMessage(nMsg); GLOBALS.SFM_nLoc = GLOBALS.Loc->TEMPGetNumLoc(); - GLOBALS.SFM_pt = GLOBALS.Tony->Position(); + GLOBALS.SFM_pt = GLOBALS.Tony->position(); if (GLOBALS.bSkipIdle) return; CORO_INVOKE_2(GLOBALS.UnloadLocation, false, NULL); - GLOBALS.Tony->Hide(); + GLOBALS.Tony->hide(); GLOBALS.Unfreeze(); - for (_ctx->i = 0; _ctx->i < _ctx->msg->NumPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { + for (_ctx->i = 0; _ctx->i < _ctx->msg->numPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { _ctx->text.setInput(GLOBALS.Input); // Alignment @@ -474,7 +474,7 @@ DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgEnd)(CORO_PARAM, uint32 bNotEnableTony, GLOBALS.Freeze(); GLOBALS.LoadLocation(GLOBALS.SFM_nLoc, RMPoint(GLOBALS.SFM_pt.x, GLOBALS.SFM_pt.y), RMPoint(-1, -1)); if (!bNotEnableTony) - GLOBALS.Tony->Show(); + GLOBALS.Tony->show(); GLOBALS.Unfreeze(); MCharResetCodes(); @@ -578,7 +578,7 @@ DECLARE_CUSTOM_FUNCTION(SetLocStartPosition)(CORO_PARAM, uint32 nLoc, uint32 lX, } DECLARE_CUSTOM_FUNCTION(SaveTonyPosition)(CORO_PARAM, uint32, uint32, uint32, uint32) { - GLOBALS.saveTonyPos = GLOBALS.Tony->Position(); + GLOBALS.saveTonyPos = GLOBALS.Tony->position(); GLOBALS.saveTonyLoc = GLOBALS.Loc->TEMPGetNumLoc(); } @@ -604,7 +604,7 @@ DECLARE_CUSTOM_FUNCTION(EnableInput)(CORO_PARAM, uint32, uint32, uint32, uint32) } DECLARE_CUSTOM_FUNCTION(StopTony)(CORO_PARAM, uint32, uint32, uint32, uint32) { - GLOBALS.Tony->StopNoAction(coroParam); + GLOBALS.Tony->stopNoAction(coroParam); } DECLARE_CUSTOM_FUNCTION(CustEnableGUI)(CORO_PARAM, uint32, uint32, uint32, uint32) { @@ -624,11 +624,11 @@ void TonyGenericTake1(CORO_PARAM, uint32 nDirection) { CORO_BEGIN_CODE(_ctx); GLOBALS.Freeze(); - GLOBALS.Tony->Take(nDirection, 0); + GLOBALS.Tony->take(nDirection, 0); GLOBALS.Unfreeze(); if (!GLOBALS.bSkipIdle) - CORO_INVOKE_0(GLOBALS.Tony->WaitForEndPattern); + CORO_INVOKE_0(GLOBALS.Tony->waitForEndPattern); CORO_END_CODE; } @@ -640,14 +640,14 @@ void TonyGenericTake2(CORO_PARAM, uint32 nDirection) { CORO_BEGIN_CODE(_ctx); GLOBALS.Freeze(); - GLOBALS.Tony->Take(nDirection, 1); + GLOBALS.Tony->take(nDirection, 1); GLOBALS.Unfreeze(); if (!GLOBALS.bSkipIdle) - CORO_INVOKE_0(GLOBALS.Tony->WaitForEndPattern); + CORO_INVOKE_0(GLOBALS.Tony->waitForEndPattern); GLOBALS.Freeze(); - GLOBALS.Tony->Take(nDirection, 2); + GLOBALS.Tony->take(nDirection, 2); GLOBALS.Unfreeze(); CORO_END_CODE; @@ -660,11 +660,11 @@ void TonyGenericPut1(CORO_PARAM, uint32 nDirection) { CORO_BEGIN_CODE(_ctx); GLOBALS.Freeze(); - GLOBALS.Tony->Put(nDirection, 0); + GLOBALS.Tony->put(nDirection, 0); GLOBALS.Unfreeze(); if (!GLOBALS.bSkipIdle) - CORO_INVOKE_0(GLOBALS.Tony->WaitForEndPattern); + CORO_INVOKE_0(GLOBALS.Tony->waitForEndPattern); CORO_END_CODE; } @@ -676,14 +676,14 @@ void TonyGenericPut2(CORO_PARAM, uint32 nDirection) { CORO_BEGIN_CODE(_ctx); GLOBALS.Freeze(); - GLOBALS.Tony->Put(nDirection, 1); + GLOBALS.Tony->put(nDirection, 1); GLOBALS.Unfreeze(); if (!GLOBALS.bSkipIdle) - CORO_INVOKE_0(GLOBALS.Tony->WaitForEndPattern); + CORO_INVOKE_0(GLOBALS.Tony->waitForEndPattern); GLOBALS.Freeze(); - GLOBALS.Tony->Put(nDirection, 2); + GLOBALS.Tony->put(nDirection, 2); GLOBALS.Unfreeze(); CORO_END_CODE; @@ -749,9 +749,9 @@ DECLARE_CUSTOM_FUNCTION(TonyPutDown2)(CORO_PARAM, uint32, uint32, uint32, uint32 DECLARE_CUSTOM_FUNCTION(TonyPerTerra)(CORO_PARAM, uint32 dwParte, uint32, uint32, uint32) { if (dwParte == 0) - GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_PERTERRALEFT); + GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_PERTERRALEFT); else - GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_PERTERRARIGHT); + GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_PERTERRARIGHT); } DECLARE_CUSTOM_FUNCTION(TonySiRialza)(CORO_PARAM, uint32 dwParte, uint32, uint32, uint32) { @@ -761,18 +761,18 @@ DECLARE_CUSTOM_FUNCTION(TonySiRialza)(CORO_PARAM, uint32 dwParte, uint32, uint32 CORO_BEGIN_CODE(_ctx); if (dwParte == 0) - GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_SIRIALZALEFT); + GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_SIRIALZALEFT); else - GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_SIRIALZARIGHT); + GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_SIRIALZARIGHT); if (!GLOBALS.bSkipIdle) - CORO_INVOKE_0(GLOBALS.Tony->WaitForEndPattern); + CORO_INVOKE_0(GLOBALS.Tony->waitForEndPattern); CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(TonyPastorella)(CORO_PARAM, uint32 bIsPast, uint32, uint32, uint32) { - GLOBALS.Tony->SetPastorella(bIsPast); + GLOBALS.Tony->setPastorella(bIsPast); } DECLARE_CUSTOM_FUNCTION(TonyFischietto)(CORO_PARAM, uint32, uint32, uint32, uint32) { @@ -781,11 +781,11 @@ DECLARE_CUSTOM_FUNCTION(TonyFischietto)(CORO_PARAM, uint32, uint32, uint32, uint CORO_BEGIN_CODE(_ctx); - GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_FISCHIETTORIGHT); + GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_FISCHIETTORIGHT); if (!GLOBALS.bSkipIdle) - CORO_INVOKE_0(GLOBALS.Tony->WaitForEndPattern); + CORO_INVOKE_0(GLOBALS.Tony->waitForEndPattern); - GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_STANDRIGHT); + GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_STANDRIGHT); CORO_END_CODE; } @@ -834,31 +834,31 @@ DECLARE_CUSTOM_FUNCTION(TonySpaventatoSenzaMani)(CORO_PARAM, uint32 dwText, uint DECLARE_CUSTOM_FUNCTION(TonyConMartello)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONMARTELLO; - GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_CONMARTELLO); + GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_CONMARTELLO); } DECLARE_CUSTOM_FUNCTION(TonyConBicchiere)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONBICCHIERE; - GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_CONBICCHIERE); + GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_CONBICCHIERE); } DECLARE_CUSTOM_FUNCTION(TonyConVerme)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONVERME; - GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_CONVERME); + GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_CONVERME); } DECLARE_CUSTOM_FUNCTION(TonyConCorda)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONCORDA; - GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_CONCORDA); + GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_CONCORDA); } DECLARE_CUSTOM_FUNCTION(TonyConSegretaria)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONSEGRETARIA; - GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_CONSEGRETARIA); + GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_CONSEGRETARIA); } DECLARE_CUSTOM_FUNCTION(TonyConConiglioANIM)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { @@ -889,7 +889,7 @@ DECLARE_CUSTOM_FUNCTION(TonyConPupazzoStart)(CORO_PARAM, uint32, uint32, uint32, GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONPUPAZZOSTATIC; GLOBALS.bStaticTalk = true; - CORO_INVOKE_1(GLOBALS.Tony->StartStatic, GLOBALS.Tony->TALK_CONPUPAZZOSTATIC); + CORO_INVOKE_1(GLOBALS.Tony->startStatic, GLOBALS.Tony->TALK_CONPUPAZZOSTATIC); CORO_END_CODE; } @@ -900,7 +900,7 @@ DECLARE_CUSTOM_FUNCTION(TonyConPupazzoEnd)(CORO_PARAM, uint32, uint32, uint32, u CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(GLOBALS.Tony->EndStatic, GLOBALS.Tony->TALK_CONPUPAZZOSTATIC); + CORO_INVOKE_1(GLOBALS.Tony->endStatic, GLOBALS.Tony->TALK_CONPUPAZZOSTATIC); GLOBALS.bStaticTalk = false; GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; @@ -915,7 +915,7 @@ DECLARE_CUSTOM_FUNCTION(TonyConConiglioStart)(CORO_PARAM, uint32, uint32, uint32 GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONCONIGLIOSTATIC; GLOBALS.bStaticTalk = true; - CORO_INVOKE_1(GLOBALS.Tony->StartStatic, GLOBALS.Tony->TALK_CONCONIGLIOSTATIC); + CORO_INVOKE_1(GLOBALS.Tony->startStatic, GLOBALS.Tony->TALK_CONCONIGLIOSTATIC); CORO_END_CODE; } @@ -926,7 +926,7 @@ DECLARE_CUSTOM_FUNCTION(TonyConConiglioEnd)(CORO_PARAM, uint32, uint32, uint32, CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(GLOBALS.Tony->EndStatic, GLOBALS.Tony->TALK_CONCONIGLIOSTATIC); + CORO_INVOKE_1(GLOBALS.Tony->endStatic, GLOBALS.Tony->TALK_CONCONIGLIOSTATIC); GLOBALS.bStaticTalk = false; GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; @@ -941,7 +941,7 @@ DECLARE_CUSTOM_FUNCTION(TonyConRicettaStart)(CORO_PARAM, uint32, uint32, uint32, GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONRICETTASTATIC; GLOBALS.bStaticTalk = true; - CORO_INVOKE_1(GLOBALS.Tony->StartStatic, GLOBALS.Tony->TALK_CONRICETTASTATIC); + CORO_INVOKE_1(GLOBALS.Tony->startStatic, GLOBALS.Tony->TALK_CONRICETTASTATIC); CORO_END_CODE; } @@ -952,7 +952,7 @@ DECLARE_CUSTOM_FUNCTION(TonyConRicettaEnd)(CORO_PARAM, uint32, uint32, uint32, u CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(GLOBALS.Tony->EndStatic, GLOBALS.Tony->TALK_CONRICETTASTATIC); + CORO_INVOKE_1(GLOBALS.Tony->endStatic, GLOBALS.Tony->TALK_CONRICETTASTATIC); GLOBALS.bStaticTalk = false; GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; @@ -967,7 +967,7 @@ DECLARE_CUSTOM_FUNCTION(TonyConCarteStart)(CORO_PARAM, uint32, uint32, uint32, u GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONCARTESTATIC; GLOBALS.bStaticTalk = true; - CORO_INVOKE_1(GLOBALS.Tony->StartStatic, GLOBALS.Tony->TALK_CONCARTESTATIC); + CORO_INVOKE_1(GLOBALS.Tony->startStatic, GLOBALS.Tony->TALK_CONCARTESTATIC); CORO_END_CODE; } @@ -978,7 +978,7 @@ DECLARE_CUSTOM_FUNCTION(TonyConCarteEnd)(CORO_PARAM, uint32, uint32, uint32, uin CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(GLOBALS.Tony->EndStatic, GLOBALS.Tony->TALK_CONCARTESTATIC); + CORO_INVOKE_1(GLOBALS.Tony->endStatic, GLOBALS.Tony->TALK_CONCARTESTATIC); GLOBALS.bStaticTalk = false; GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; @@ -993,7 +993,7 @@ DECLARE_CUSTOM_FUNCTION(TonyConTaccuinoStart)(CORO_PARAM, uint32, uint32, uint32 GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONTACCUINOSTATIC; GLOBALS.bStaticTalk = true; - CORO_INVOKE_1(GLOBALS.Tony->StartStatic, GLOBALS.Tony->TALK_CONTACCUINOSTATIC); + CORO_INVOKE_1(GLOBALS.Tony->startStatic, GLOBALS.Tony->TALK_CONTACCUINOSTATIC); CORO_END_CODE; } @@ -1004,7 +1004,7 @@ DECLARE_CUSTOM_FUNCTION(TonyConTaccuinoEnd)(CORO_PARAM, uint32, uint32, uint32, CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(GLOBALS.Tony->EndStatic, GLOBALS.Tony->TALK_CONTACCUINOSTATIC); + CORO_INVOKE_1(GLOBALS.Tony->endStatic, GLOBALS.Tony->TALK_CONTACCUINOSTATIC); GLOBALS.bStaticTalk = false; GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; @@ -1019,7 +1019,7 @@ DECLARE_CUSTOM_FUNCTION(TonyConMegafonoStart)(CORO_PARAM, uint32, uint32, uint32 GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONMEGAFONOSTATIC; GLOBALS.bStaticTalk = true; - CORO_INVOKE_1(GLOBALS.Tony->StartStatic, GLOBALS.Tony->TALK_CONMEGAFONOSTATIC); + CORO_INVOKE_1(GLOBALS.Tony->startStatic, GLOBALS.Tony->TALK_CONMEGAFONOSTATIC); CORO_END_CODE; } @@ -1030,7 +1030,7 @@ DECLARE_CUSTOM_FUNCTION(TonyConMegafonoEnd)(CORO_PARAM, uint32, uint32, uint32, CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(GLOBALS.Tony->EndStatic, GLOBALS.Tony->TALK_CONMEGAFONOSTATIC); + CORO_INVOKE_1(GLOBALS.Tony->endStatic, GLOBALS.Tony->TALK_CONMEGAFONOSTATIC); GLOBALS.bStaticTalk = false; GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; @@ -1045,7 +1045,7 @@ DECLARE_CUSTOM_FUNCTION(TonyConBarbaStart)(CORO_PARAM, uint32, uint32, uint32, u GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONBARBASTATIC; GLOBALS.bStaticTalk = true; - CORO_INVOKE_1(GLOBALS.Tony->StartStatic, GLOBALS.Tony->TALK_CONBARBASTATIC); + CORO_INVOKE_1(GLOBALS.Tony->startStatic, GLOBALS.Tony->TALK_CONBARBASTATIC); CORO_END_CODE; } @@ -1056,7 +1056,7 @@ DECLARE_CUSTOM_FUNCTION(TonyConBarbaEnd)(CORO_PARAM, uint32, uint32, uint32, uin CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(GLOBALS.Tony->EndStatic, GLOBALS.Tony->TALK_CONBARBASTATIC); + CORO_INVOKE_1(GLOBALS.Tony->endStatic, GLOBALS.Tony->TALK_CONBARBASTATIC); GLOBALS.bStaticTalk = false; GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; @@ -1071,7 +1071,7 @@ DECLARE_CUSTOM_FUNCTION(TonySpaventatoStart)(CORO_PARAM, uint32, uint32, uint32, GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_SPAVENTATOSTATIC; GLOBALS.bStaticTalk = true; - CORO_INVOKE_1(GLOBALS.Tony->StartStatic, GLOBALS.Tony->TALK_SPAVENTATOSTATIC); + CORO_INVOKE_1(GLOBALS.Tony->startStatic, GLOBALS.Tony->TALK_SPAVENTATOSTATIC); CORO_END_CODE; } @@ -1082,7 +1082,7 @@ DECLARE_CUSTOM_FUNCTION(TonySpaventatoEnd)(CORO_PARAM, uint32, uint32, uint32, u CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(GLOBALS.Tony->EndStatic, GLOBALS.Tony->TALK_SPAVENTATOSTATIC); + CORO_INVOKE_1(GLOBALS.Tony->endStatic, GLOBALS.Tony->TALK_SPAVENTATOSTATIC); GLOBALS.bStaticTalk = false; GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; @@ -1101,8 +1101,8 @@ DECLARE_CUSTOM_FUNCTION(TonySniffaLeft)(CORO_PARAM, uint32, uint32, uint32, uint CORO_BEGIN_CODE(_ctx); - GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_SNIFFA_LEFT); - CORO_INVOKE_0(GLOBALS.Tony->WaitForEndPattern); + GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_SNIFFA_LEFT); + CORO_INVOKE_0(GLOBALS.Tony->waitForEndPattern); CORO_INVOKE_4(LeftToMe, 0, 0, 0, 0); CORO_END_CODE; @@ -1114,8 +1114,8 @@ DECLARE_CUSTOM_FUNCTION(TonySniffaRight)(CORO_PARAM, uint32, uint32, uint32, uin CORO_BEGIN_CODE(_ctx); - GLOBALS.Tony->SetPattern(GLOBALS.Tony->PAT_SNIFFA_RIGHT); - CORO_INVOKE_0(GLOBALS.Tony->WaitForEndPattern); + GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_SNIFFA_RIGHT); + CORO_INVOKE_0(GLOBALS.Tony->waitForEndPattern); CORO_INVOKE_4(RightToMe, 0, 0, 0, 0); CORO_END_CODE; @@ -1160,11 +1160,11 @@ DECLARE_CUSTOM_FUNCTION(TonyMacbeth)(CORO_PARAM, uint32 nPos, uint32, uint32, ui DECLARE_CUSTOM_FUNCTION(EnableTony)(CORO_PARAM, uint32, uint32, uint32, uint32) { - GLOBALS.Tony->Show(); + GLOBALS.Tony->show(); } DECLARE_CUSTOM_FUNCTION(DisableTony)(CORO_PARAM, uint32 bShowOmbra, uint32, uint32, uint32) { - GLOBALS.Tony->Hide(bShowOmbra); + GLOBALS.Tony->hide(bShowOmbra); } DECLARE_CUSTOM_FUNCTION(WaitForPatternEnd)(CORO_PARAM, uint32 nItem, uint32, uint32, uint32) { @@ -1174,17 +1174,17 @@ DECLARE_CUSTOM_FUNCTION(WaitForPatternEnd)(CORO_PARAM, uint32 nItem, uint32, uin CORO_BEGIN_CODE(_ctx); - _ctx->item = GLOBALS.Loc->GetItemFromCode(nItem); + _ctx->item = GLOBALS.Loc->getItemFromCode(nItem); if (!GLOBALS.bSkipIdle && _ctx->item != NULL) - CORO_INVOKE_1(_ctx->item->WaitForEndPattern, GLOBALS.hSkipIdle); + CORO_INVOKE_1(_ctx->item->waitForEndPattern, GLOBALS.hSkipIdle); CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(SetTonyPosition)(CORO_PARAM, uint32 nX, uint32 nY, uint32 nLoc, uint32) { - GLOBALS.Tony->SetPosition(RMPoint(nX, nY), nLoc); + GLOBALS.Tony->setPosition(RMPoint(nX, nY), nLoc); } DECLARE_CUSTOM_FUNCTION(MoveTonyAndWait)(CORO_PARAM, uint32 nX, uint32 nY, uint32, uint32) { @@ -1193,16 +1193,16 @@ DECLARE_CUSTOM_FUNCTION(MoveTonyAndWait)(CORO_PARAM, uint32 nX, uint32 nY, uint3 CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(GLOBALS.Tony->Move, RMPoint(nX, nY)); + CORO_INVOKE_1(GLOBALS.Tony->move, RMPoint(nX, nY)); if (!GLOBALS.bSkipIdle) - CORO_INVOKE_0(GLOBALS.Tony->WaitForEndMovement); + CORO_INVOKE_0(GLOBALS.Tony->waitForEndMovement); CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(MoveTony)(CORO_PARAM, uint32 nX, uint32 nY, uint32, uint32) { - GLOBALS.Tony->Move(coroParam, RMPoint(nX, nY)); + GLOBALS.Tony->move(coroParam, RMPoint(nX, nY)); } DECLARE_CUSTOM_FUNCTION(ScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, uint32 sX, uint32 sY) { @@ -1217,7 +1217,7 @@ DECLARE_CUSTOM_FUNCTION(ScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, uint32 _ctx->lx = (int32)nX; _ctx->ly = (int32)nY; - _ctx->pt = GLOBALS.Loc->ScrollPosition(); + _ctx->pt = GLOBALS.Loc->scrollPosition(); while ((_ctx->lx != 0 || _ctx->ly != 0) && !GLOBALS.bSkipIdle) { if (_ctx->lx > 0) { @@ -1243,8 +1243,8 @@ DECLARE_CUSTOM_FUNCTION(ScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, uint32 CORO_INVOKE_0(GLOBALS.WaitFrame); GLOBALS.Freeze(); - GLOBALS.Loc->SetScrollPosition(_ctx->pt); - GLOBALS.Tony->SetScrollPosition(_ctx->pt); + GLOBALS.Loc->setScrollPosition(_ctx->pt); + GLOBALS.Tony->setScrollPosition(_ctx->pt); GLOBALS.Unfreeze(); } @@ -1276,7 +1276,7 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui _ctx->stepX = sX; _ctx->stepY = sY; - _ctx->startpt = GLOBALS.Loc->ScrollPosition(); + _ctx->startpt = GLOBALS.Loc->scrollPosition(); _ctx->dwStartTime = _vm->getTime(); @@ -1308,8 +1308,8 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui CORO_INVOKE_0(GLOBALS.WaitFrame); GLOBALS.Freeze(); - GLOBALS.Loc->SetScrollPosition(_ctx->pt); - GLOBALS.Tony->SetScrollPosition(_ctx->pt); + GLOBALS.Loc->setScrollPosition(_ctx->pt); + GLOBALS.Tony->setScrollPosition(_ctx->pt); GLOBALS.Unfreeze(); } @@ -1329,8 +1329,8 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui } GLOBALS.Freeze(); - GLOBALS.Loc->SetScrollPosition(_ctx->pt); - GLOBALS.Tony->SetScrollPosition(_ctx->pt); + GLOBALS.Loc->setScrollPosition(_ctx->pt); + GLOBALS.Tony->setScrollPosition(_ctx->pt); GLOBALS.Unfreeze(); CORO_END_CODE; @@ -1354,7 +1354,7 @@ DECLARE_CUSTOM_FUNCTION(ChangeHotspot)(CORO_PARAM, uint32 dwCode, uint32 nX, uin GLOBALS.curChangedHotspot++; } - GLOBALS.Loc->GetItemFromCode(dwCode)->ChangeHotspot(RMPoint(nX, nY)); + GLOBALS.Loc->getItemFromCode(dwCode)->changeHotspot(RMPoint(nX, nY)); } @@ -1384,8 +1384,8 @@ DECLARE_CUSTOM_FUNCTION(TremaSchermo)(CORO_PARAM, uint32 nScosse, uint32, uint32 CORO_INVOKE_0(GLOBALS.WaitFrame); GLOBALS.Freeze(); - GLOBALS.Loc->SetFixedScroll(RMPoint(1 * _ctx->dirx, 1 * _ctx->diry)); - GLOBALS.Tony->SetFixedScroll(RMPoint(1 * _ctx->dirx, 1 * _ctx->diry)); + GLOBALS.Loc->setFixedScroll(RMPoint(1 * _ctx->dirx, 1 * _ctx->diry)); + GLOBALS.Tony->setFixedScroll(RMPoint(1 * _ctx->dirx, 1 * _ctx->diry)); GLOBALS.Unfreeze(); _ctx->i = _vm->_randomSource.getRandomNumber(2); @@ -1397,8 +1397,8 @@ DECLARE_CUSTOM_FUNCTION(TremaSchermo)(CORO_PARAM, uint32 nScosse, uint32, uint32 } GLOBALS.Freeze(); - GLOBALS.Loc->SetFixedScroll(RMPoint(0, 0)); - GLOBALS.Tony->SetFixedScroll(RMPoint(0, 0)); + GLOBALS.Loc->setFixedScroll(RMPoint(0, 0)); + GLOBALS.Tony->setFixedScroll(RMPoint(0, 0)); GLOBALS.Unfreeze(); CORO_END_CODE; @@ -1413,7 +1413,7 @@ DECLARE_CUSTOM_FUNCTION(TremaSchermo)(CORO_PARAM, uint32 nScosse, uint32, uint32 DECLARE_CUSTOM_FUNCTION(CharSetCode)(CORO_PARAM, uint32 nChar, uint32 nCode, uint32, uint32) { assert(nChar < 16); GLOBALS.Character[nChar].code = nCode; - GLOBALS.Character[nChar].item = GLOBALS.Loc->GetItemFromCode(nCode); + GLOBALS.Character[nChar].item = GLOBALS.Loc->getItemFromCode(nCode); GLOBALS.Character[nChar].r = 255; GLOBALS.Character[nChar].g = 255; GLOBALS.Character[nChar].b = 255; @@ -1461,18 +1461,18 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess _ctx->curOffset = 0; assert(nChar < 16); - _ctx->pt = GLOBALS.Character[nChar].item->CalculatePos() - RMPoint(-60, 20) - GLOBALS.Loc->ScrollPosition(); + _ctx->pt = GLOBALS.Character[nChar].item->calculatePos() - RMPoint(-60, 20) - GLOBALS.Loc->scrollPosition(); if (GLOBALS.Character[nChar].starttalkpattern != 0) { GLOBALS.Freeze(); - GLOBALS.Character[nChar].item->SetPattern(GLOBALS.Character[nChar].starttalkpattern); + GLOBALS.Character[nChar].item->setPattern(GLOBALS.Character[nChar].starttalkpattern); GLOBALS.Unfreeze(); - CORO_INVOKE_0(GLOBALS.Character[nChar].item->WaitForEndPattern); + CORO_INVOKE_0(GLOBALS.Character[nChar].item->waitForEndPattern); } GLOBALS.Freeze(); - GLOBALS.Character[nChar].item->SetPattern(GLOBALS.Character[nChar].talkpattern); + GLOBALS.Character[nChar].item->setPattern(GLOBALS.Character[nChar].talkpattern); GLOBALS.Unfreeze(); _ctx->curVoc = SearchVoiceHeader(0, dwMessage); @@ -1483,7 +1483,7 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess _ctx->curOffset = _ctx->curVoc->_offset; } - for (_ctx->i = 0; _ctx->i < _ctx->msg->NumPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { + for (_ctx->i = 0; _ctx->i < _ctx->msg->numPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { if (bIsBack) { GLOBALS.curBackText = _ctx->text = new RMTextDialogScrolling(GLOBALS.Loc); if (GLOBALS.bTonyIsSpeaking) @@ -1545,13 +1545,13 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess if (GLOBALS.Character[nChar].endtalkpattern != 0) { GLOBALS.Freeze(); - GLOBALS.Character[nChar].item->SetPattern(GLOBALS.Character[nChar].endtalkpattern); + GLOBALS.Character[nChar].item->setPattern(GLOBALS.Character[nChar].endtalkpattern); GLOBALS.Unfreeze(); - CORO_INVOKE_0(GLOBALS.Character[nChar].item->WaitForEndPattern); + CORO_INVOKE_0(GLOBALS.Character[nChar].item->waitForEndPattern); } GLOBALS.Freeze(); - GLOBALS.Character[nChar].item->SetPattern(GLOBALS.Character[nChar].standpattern); + GLOBALS.Character[nChar].item->setPattern(GLOBALS.Character[nChar].standpattern); GLOBALS.Unfreeze(); delete _ctx->msg; @@ -1581,7 +1581,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSetCode)(CORO_PARAM, uint32 nChar, uint32 nCode, ui if (nCode == 0) GLOBALS.MCharacter[nChar].item = NULL; else - GLOBALS.MCharacter[nChar].item = GLOBALS.Loc->GetItemFromCode(nCode); + GLOBALS.MCharacter[nChar].item = GLOBALS.Loc->getItemFromCode(nCode); GLOBALS.MCharacter[nChar].r = 255; GLOBALS.MCharacter[nChar].g = 255; GLOBALS.MCharacter[nChar].b = 255; @@ -1598,7 +1598,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSetCode)(CORO_PARAM, uint32 nChar, uint32 nCode, ui } DECLARE_CUSTOM_FUNCTION(MCharResetCode)(CORO_PARAM, uint32 nChar, uint32, uint32, uint32) { - GLOBALS.MCharacter[nChar].item = GLOBALS.Loc->GetItemFromCode(GLOBALS.MCharacter[nChar].code); + GLOBALS.MCharacter[nChar].item = GLOBALS.Loc->getItemFromCode(GLOBALS.MCharacter[nChar].code); } @@ -1670,7 +1670,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes // Calculates the position of the text according to the current frame if (GLOBALS.MCharacter[nChar].x == -1) - _ctx->pt = GLOBALS.MCharacter[nChar].item->CalculatePos() - RMPoint(-60, 20) - GLOBALS.Loc->ScrollPosition(); + _ctx->pt = GLOBALS.MCharacter[nChar].item->calculatePos() - RMPoint(-60, 20) - GLOBALS.Loc->scrollPosition(); else _ctx->pt = RMPoint(GLOBALS.MCharacter[nChar].x, GLOBALS.MCharacter[nChar].y); @@ -1680,7 +1680,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes // Try to run the custom function to initialise the speech if (GLOBALS.MCharacter[nChar].item) { - _ctx->h = mpalQueryDoAction(30, GLOBALS.MCharacter[nChar].item->MpalCode(), _ctx->parm); + _ctx->h = mpalQueryDoAction(30, GLOBALS.MCharacter[nChar].item->mpalCode(), _ctx->parm); if (_ctx->h != CORO_INVALID_PID_VALUE) { CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->h, CORO_INFINITE); } @@ -1695,7 +1695,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes _ctx->curOffset = _ctx->curVoc->_offset; } - for (_ctx->i = 0; _ctx->i < _ctx->msg->NumPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { + for (_ctx->i = 0; _ctx->i < _ctx->msg->numPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { // Create a different object depending on whether it's background or not if (bIsBack) { GLOBALS.curBackText = _ctx->text = new RMTextDialogScrolling(GLOBALS.Loc); @@ -1759,7 +1759,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes // Try to run the custom function to close the speech if (GLOBALS.MCharacter[nChar].item) { - _ctx->h = mpalQueryDoAction(31, GLOBALS.MCharacter[nChar].item->MpalCode(), _ctx->parm); + _ctx->h = mpalQueryDoAction(31, GLOBALS.MCharacter[nChar].item->mpalCode(), _ctx->parm); if (_ctx->h != CORO_INVALID_PID_VALUE) CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->h, CORO_INFINITE); } @@ -1767,11 +1767,6 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes CORO_END_CODE; } - - - - - /* * Dialoghi */ @@ -1815,46 +1810,46 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg if (nPers == 0) { _ctx->text = new RMTextDialog; _ctx->text->setColor(0, 255, 0); - _ctx->text->setPosition(GLOBALS.Tony->Position() - RMPoint(0, 130) - GLOBALS.Loc->ScrollPosition()); + _ctx->text->setPosition(GLOBALS.Tony->position() - RMPoint(0, 130) - GLOBALS.Loc->scrollPosition()); _ctx->text->writeText(_ctx->string, 0); if (GLOBALS.dwTonyNumTexts > 0) { if (!GLOBALS.bTonyInTexts) { if (GLOBALS.nTonyNextTalkType != GLOBALS.Tony->TALK_NORMAL) { - CORO_INVOKE_1(GLOBALS.Tony->StartTalk, GLOBALS.nTonyNextTalkType); + CORO_INVOKE_1(GLOBALS.Tony->startTalk, GLOBALS.nTonyNextTalkType); if (!GLOBALS.bStaticTalk) GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; } else - CORO_INVOKE_1(GLOBALS.Tony->StartTalk, GLOBALS.Tony->TALK_NORMAL); + CORO_INVOKE_1(GLOBALS.Tony->startTalk, GLOBALS.Tony->TALK_NORMAL); GLOBALS.bTonyInTexts = true; } GLOBALS.dwTonyNumTexts--; } else { - CORO_INVOKE_1(GLOBALS.Tony->StartTalk, GLOBALS.nTonyNextTalkType); + CORO_INVOKE_1(GLOBALS.Tony->startTalk, GLOBALS.nTonyNextTalkType); if (!GLOBALS.bStaticTalk) GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; } } else if (!GLOBALS.IsMChar[nPers]) { _ctx->text = new RMTextDialog; - _ctx->pt = GLOBALS.Character[nPers].item->CalculatePos() - RMPoint(-60, 20) - GLOBALS.Loc->ScrollPosition(); + _ctx->pt = GLOBALS.Character[nPers].item->calculatePos() - RMPoint(-60, 20) - GLOBALS.Loc->scrollPosition(); if (GLOBALS.Character[nPers].starttalkpattern != 0) { GLOBALS.Freeze(); - GLOBALS.Character[nPers].item->SetPattern(GLOBALS.Character[nPers].starttalkpattern); + GLOBALS.Character[nPers].item->setPattern(GLOBALS.Character[nPers].starttalkpattern); GLOBALS.Unfreeze(); - CORO_INVOKE_0(GLOBALS.Character[nPers].item->WaitForEndPattern); + CORO_INVOKE_0(GLOBALS.Character[nPers].item->waitForEndPattern); } - GLOBALS.Character[nPers].item->SetPattern(GLOBALS.Character[nPers].talkpattern); + GLOBALS.Character[nPers].item->setPattern(GLOBALS.Character[nPers].talkpattern); _ctx->text->setColor(GLOBALS.Character[nPers].r, GLOBALS.Character[nPers].g, GLOBALS.Character[nPers].b); _ctx->text->writeText(_ctx->string, 0); _ctx->text->setPosition(_ctx->pt); } else { if (GLOBALS.MCharacter[nPers].x == -1) - _ctx->pt = GLOBALS.MCharacter[nPers].item->CalculatePos() - RMPoint(-60, 20) - GLOBALS.Loc->ScrollPosition(); + _ctx->pt = GLOBALS.MCharacter[nPers].item->calculatePos() - RMPoint(-60, 20) - GLOBALS.Loc->scrollPosition(); else _ctx->pt = RMPoint(GLOBALS.MCharacter[nPers].x, GLOBALS.MCharacter[nPers].y); @@ -1866,7 +1861,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg GLOBALS.MCharacter[nPers].numtexts--; } else { // Try to run the custom function to initialise the speech - _ctx->h = mpalQueryDoAction(30, GLOBALS.MCharacter[nPers].item->MpalCode(), _ctx->parm); + _ctx->h = mpalQueryDoAction(30, GLOBALS.MCharacter[nPers].item->mpalCode(), _ctx->parm); if (_ctx->h != CORO_INVALID_PID_VALUE) CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->h, CORO_INFINITE); @@ -1922,18 +1917,18 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg if (!GLOBALS.IsMChar[nPers]) { if (GLOBALS.Character[nPers].endtalkpattern != 0) { GLOBALS.Freeze(); - GLOBALS.Character[nPers].item->SetPattern(GLOBALS.Character[nPers].endtalkpattern); + GLOBALS.Character[nPers].item->setPattern(GLOBALS.Character[nPers].endtalkpattern); GLOBALS.Unfreeze(); - CORO_INVOKE_0(GLOBALS.Character[nPers].item->WaitForEndPattern); + CORO_INVOKE_0(GLOBALS.Character[nPers].item->waitForEndPattern); } - GLOBALS.Character[nPers].item->SetPattern(GLOBALS.Character[nPers].standpattern); + GLOBALS.Character[nPers].item->setPattern(GLOBALS.Character[nPers].standpattern); delete _ctx->text; } else { if ((GLOBALS.MCharacter[nPers].bInTexts && GLOBALS.MCharacter[nPers].numtexts == 0) || !GLOBALS.MCharacter[nPers].bInTexts) { // Try to run the custom function to close the speech GLOBALS.MCharacter[nPers].curTalk = (GLOBALS.MCharacter[nPers].curTalk % 10) + GLOBALS.MCharacter[nPers].curgroup * 10; - _ctx->h = mpalQueryDoAction(31, GLOBALS.MCharacter[nPers].item->MpalCode(), GLOBALS.MCharacter[nPers].curTalk); + _ctx->h = mpalQueryDoAction(31, GLOBALS.MCharacter[nPers].item->mpalCode(), GLOBALS.MCharacter[nPers].curTalk); if (_ctx->h != CORO_INVALID_PID_VALUE) CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->h, CORO_INFINITE); @@ -1946,7 +1941,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg } } else { if ((GLOBALS.dwTonyNumTexts == 0 && GLOBALS.bTonyInTexts) || !GLOBALS.bTonyInTexts) { - CORO_INVOKE_0(GLOBALS.Tony->EndTalk); + CORO_INVOKE_0(GLOBALS.Tony->endTalk); GLOBALS.dwTonyNumTexts = 0; GLOBALS.bTonyInTexts = false; } @@ -2201,11 +2196,11 @@ DECLARE_CUSTOM_FUNCTION(PlayStacchetto)(CORO_PARAM, uint32 nMusic, uint32 nFX, u DECLARE_CUSTOM_FUNCTION(PlayItemSfx)(CORO_PARAM, uint32 nItem, uint32 nSFX, uint32, uint32) { if (nItem == 0) { - GLOBALS.Tony->PlaySfx(nSFX); + GLOBALS.Tony->playSfx(nSFX); } else { - RMItem *item = GLOBALS.Loc->GetItemFromCode(nItem); + RMItem *item = GLOBALS.Loc->getItemFromCode(nItem); if (item) - item->PlaySfx(nSFX); + item->playSfx(nSFX); } } @@ -2325,9 +2320,9 @@ DECLARE_CUSTOM_FUNCTION(DoCredits)(CORO_PARAM, uint32 nMsg, uint32 dwTime, uint3 _ctx->msg = new RMMessage(nMsg); _ctx->hDisable = CoroScheduler.createEvent(true, false); - _ctx->text = new RMTextDialog[_ctx->msg->NumPeriods()]; + _ctx->text = new RMTextDialog[_ctx->msg->numPeriods()]; - for (_ctx->i = 0; _ctx->i < _ctx->msg->NumPeriods(); _ctx->i++) { + for (_ctx->i = 0; _ctx->i < _ctx->msg->numPeriods(); _ctx->i++) { _ctx->text[_ctx->i].setInput(GLOBALS.Input); // Alignment diff --git a/engines/tony/debugger.cpp b/engines/tony/debugger.cpp index 7dc32d9f61..66fddf2834 100644 --- a/engines/tony/debugger.cpp +++ b/engines/tony/debugger.cpp @@ -87,7 +87,7 @@ bool Debugger::Cmd_Scene(int argc, const char **argv) { } int sceneNumber = strToInt(argv[1]); - if (sceneNumber >= _vm->_theBoxes.GetLocBoxesCount()) { + if (sceneNumber >= _vm->_theBoxes.getLocBoxesCount()) { DebugPrintf("Invalid scene\n"); return true; } @@ -99,7 +99,7 @@ bool Debugger::Cmd_Scene(int argc, const char **argv) { } else { // Get the box areas for the scene, and choose one so as to have a default // position for Tony that will be in the walkable areas - RMBoxLoc *box = _vm->_theBoxes.GetBoxes(sceneNumber); + RMBoxLoc *box = _vm->_theBoxes.getBoxes(sceneNumber); scenePos.Set(box->boxes[0].hotspot[0].hotx, box->boxes[0].hotspot[0].hoty); } diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index bc32939061..e056484e54 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -2180,7 +2180,7 @@ RMTextDialogScrolling::RMTextDialogScrolling() { RMTextDialogScrolling::RMTextDialogScrolling(RMLocation *loc) { curLoc = loc; - startScroll = loc->ScrollPosition(); + startScroll = loc->scrollPosition(); } RMTextDialogScrolling::~RMTextDialogScrolling() { @@ -2196,7 +2196,7 @@ void RMTextDialogScrolling::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPri _ctx->curDst = dst; if (curLoc != NULL) - dst -= curLoc->ScrollPosition() - startScroll; + dst -= curLoc->scrollPosition() - startScroll; CORO_INVOKE_2(RMTextDialog::draw, bigBuf, prim); @@ -2240,19 +2240,19 @@ void RMTextItemName::doFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation & bigBuf.addPrim(new RMGfxPrimitive(this)); // Update the scrolling co-ordinates - _curscroll = loc.ScrollPosition(); + _curscroll = loc.scrollPosition(); // Check if we are on the inventory if (inv.itemInFocus(_mpos)) _item = inv.whichItemIsIn(_mpos); else - _item = loc.WhichItemIsIn(_mpos); + _item = loc.whichItemIsIn(_mpos); itemName = ""; // If there an item, get its name if (_item != NULL) - _item->GetName(itemName); + _item->getName(itemName); // Write it writeText(itemName, 1); @@ -2262,7 +2262,7 @@ void RMTextItemName::doFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation & if (_item == NULL) ptr.setSpecialPointer(RMPointer::PTR_NONE); else { - _ctx->hThread = mpalQueryDoAction(20, _item->MpalCode(), 0); + _ctx->hThread = mpalQueryDoAction(20, _item->mpalCode(), 0); if (_ctx->hThread == CORO_INVALID_PID_VALUE) ptr.setSpecialPointer(RMPointer::PTR_NONE); else @@ -2296,7 +2296,7 @@ RMPoint RMTextItemName::getHotspot() { if (_item == NULL) return _mpos + _curscroll; else - return _item->Hotspot(); + return _item->hotspot(); } RMItem *RMTextItemName::getSelectedItem() { diff --git a/engines/tony/game.h b/engines/tony/game.h index 34e99c369e..5f387d558b 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -115,7 +115,7 @@ public: void setSpecialPointer(POINTER ptr) { _nCurSpecialPointer = ptr; if (_nCurSpecialPointer && _nCurSpecialPointer != PTR_CUSTOM) - _specialPointer[ptr - 1]->SetPattern(1); + _specialPointer[ptr - 1]->setPattern(1); } POINTER getSpecialPointer(void) { return (POINTER)_nCurSpecialPointer; diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index a80552b1d1..56ce8a47e1 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -126,7 +126,7 @@ void RMGfxEngine::openOptionScreen(CORO_PARAM, int type) { if (type == 1 || type == 2) { GLOBALS.bIdleExited = true; } else { - CORO_INVOKE_0(_tony.StopNoAction); + CORO_INVOKE_0(_tony.stopNoAction); GLOBALS.bIdleExited = false; @@ -170,7 +170,7 @@ void RMGfxEngine::doFrame(CORO_PARAM, bool bDrawLocation) { _loc.doFrame(&_bigBuf); // Check the mouse input - if (_bInput && !_tony.InAction()) { + if (_bInput && !_tony.inAction()) { // If we are on the inventory, it is it who controls all input if (_inv.haveFocus(_input.mousePos()) && !_inter.active()) { // Left Click @@ -197,7 +197,7 @@ void RMGfxEngine::doFrame(CORO_PARAM, bool bDrawLocation) { // ************* if (_input.mouseRightReleased()) { if (_inv.rightRelease(_input.mousePos(), _curAction)) { - CORO_INVOKE_3(_tony.MoveAndDoAction, _itemName.getHotspot(), _itemName.getSelectedItem(), _curAction); + CORO_INVOKE_3(_tony.moveAndDoAction, _itemName.getHotspot(), _itemName.getSelectedItem(), _curAction); _curAction = TA_GOTO; _point.setAction(_curAction); @@ -207,7 +207,7 @@ void RMGfxEngine::doFrame(CORO_PARAM, bool bDrawLocation) { // Options Menu // ************ if (_bGUIOption) { - if (!_tony.InAction() && _bInput) { + if (!_tony.inAction() && _bInput) { if ((_input.mouseLeftClicked() && _input.mousePos().x < 3 && _input.mousePos().y < 3)) { CORO_INVOKE_1(openOptionScreen, 0); goto SKIPCLICKSINISTRO; @@ -229,9 +229,9 @@ void RMGfxEngine::doFrame(CORO_PARAM, bool bDrawLocation) { if (_input.mouseLeftClicked() && !_inter.active()) { if (_curAction != TA_COMBINE) - CORO_INVOKE_3(_tony.MoveAndDoAction, _itemName.getHotspot(), _itemName.getSelectedItem(), _point.curAction()); + CORO_INVOKE_3(_tony.moveAndDoAction, _itemName.getHotspot(), _itemName.getSelectedItem(), _point.curAction()); else if (_itemName.getSelectedItem() != NULL) - CORO_INVOKE_4(_tony.MoveAndDoAction, _itemName.getHotspot(), _itemName.getSelectedItem(), TA_COMBINE, _curActionObj); + CORO_INVOKE_4(_tony.moveAndDoAction, _itemName.getHotspot(), _itemName.getSelectedItem(), TA_COMBINE, _curActionObj); if (_curAction == TA_COMBINE) { _inv.endCombine(); @@ -271,7 +271,7 @@ SKIPCLICKSINISTRO: if (_bGUIInterface) { if (_inter.released(_input.mousePos(), _curAction)) { _point.setAction(_curAction); - CORO_INVOKE_3(_tony.MoveAndDoAction, _itemName.getHotspot(), _itemName.getSelectedItem(), _curAction); + CORO_INVOKE_3(_tony.moveAndDoAction, _itemName.getHotspot(), _itemName.getSelectedItem(), _curAction); _curAction = TA_GOTO; _point.setAction(_curAction); @@ -288,23 +288,23 @@ SKIPCLICKSINISTRO: // Interface & Inventory _inter.doFrame(_bigBuf, _input.mousePos()); - _inv.doFrame(_bigBuf, _point, _input.mousePos(), (!_tony.InAction() && !_inter.active() && _bGUIInventory)); + _inv.doFrame(_bigBuf, _point, _input.mousePos(), (!_tony.inAction() && !_inter.active() && _bGUIInventory)); } // Animate Tony - CORO_INVOKE_2(_tony.DoFrame, &_bigBuf, _nCurLoc); + CORO_INVOKE_2(_tony.doFrame, &_bigBuf, _nCurLoc); // Update screen scrolling to keep Tony in focus - if (_tony.MustUpdateScrolling() && _bLocationLoaded) { - RMPoint showThis = _tony.Position(); + if (_tony.mustUpdateScrolling() && _bLocationLoaded) { + RMPoint showThis = _tony.position(); showThis.y -= 60; - _loc.UpdateScrolling(showThis); + _loc.updateScrolling(showThis); } if (_bLocationLoaded) - _tony.SetScrollPosition(_loc.ScrollPosition()); + _tony.setScrollPosition(_loc.scrollPosition()); - if ((!_tony.InAction() && _bInput) || _bAlwaysDrawMouse) { + if ((!_tony.inAction() && _bInput) || _bAlwaysDrawMouse) { _point.setCoord(_input.mousePos()); _point.doFrame(&_bigBuf); } @@ -362,17 +362,17 @@ void RMGfxEngine::itemIrq(uint32 dwItem, int nPattern, int nStatus) { assert(GLOBALS.GfxEngine); if (GLOBALS.GfxEngine->_bLocationLoaded) { - item = GLOBALS.GfxEngine->_loc.GetItemFromCode(dwItem); + item = GLOBALS.GfxEngine->_loc.getItemFromCode(dwItem); if (item != NULL) { if (nPattern != -1) { if (GLOBALS.bPatIrqFreeze) mainFreeze(); - item->SetPattern(nPattern, true); + item->setPattern(nPattern, true); if (GLOBALS.bPatIrqFreeze) mainUnfreeze(); } if (nStatus != -1) - item->SetStatus(nStatus); + item->setStatus(nStatus); } } } @@ -384,12 +384,12 @@ void RMGfxEngine::initForNewLocation(int nLoc, RMPoint ptTonyStart, RMPoint star start.y = ptTonyStart.y - RM_SY / 2; } - _loc.SetScrollPosition(start); + _loc.setScrollPosition(start); if (ptTonyStart.x == 0 && ptTonyStart.y == 0) { } else { - _tony.SetPosition(ptTonyStart, nLoc); - _tony.SetScrollPosition(start); + _tony.setPosition(ptTonyStart, nLoc); + _tony.setScrollPosition(start); } _curAction = TA_GOTO; @@ -415,7 +415,7 @@ uint32 RMGfxEngine::loadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { if (!res.IsValid()) continue; - _loc.Load(res); + _loc.load(res); initForNewLocation(nLoc, ptTonyStart, start); bLoaded = true; break; @@ -455,7 +455,7 @@ void RMGfxEngine::unloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result) { _bLocationLoaded = false; _bigBuf.clearOT(); - _loc.Unload(); + _loc.unload(); if (result != NULL) *result = CORO_INVALID_PID_VALUE; @@ -503,7 +503,7 @@ void RMGfxEngine::init() { // Initialise Tony _tony.init(); - _tony.LinkToBoxes(&_vm->_theBoxes); + _tony.linkToBoxes(&_vm->_theBoxes); // Initialise the inventory and the interface _inv.init(); @@ -515,7 +515,7 @@ void RMGfxEngine::init() { enableInput(); // Starting the game - _tony.ExecuteAction(20, 1, 0); + _tony.executeAction(20, 1, 0); } void RMGfxEngine::close(void) { @@ -523,7 +523,7 @@ void RMGfxEngine::close(void) { _inter.close(); _inv.close(); - _tony.Close(); + _tony.close(); _point.close(); _input.close(); } @@ -579,7 +579,7 @@ void RMGfxEngine::saveState(const Common::String &fn, byte *curThumb, const Comm uint size; int i; char buf[4]; - RMPoint tp = _tony.Position(); + RMPoint tp = _tony.position(); // Saving: MPAL variables, current location, and Tony inventory position @@ -627,9 +627,9 @@ void RMGfxEngine::saveState(const Common::String &fn, byte *curThumb, const Comm delete[] state; // boxes - size = _vm->_theBoxes.GetSaveStateSize(); + size = _vm->_theBoxes.getSaveStateSize(); state = new byte[size]; - _vm->_theBoxes.SaveState(state); + _vm->_theBoxes.saveState(state); f->writeUint32LE(size); f->write(state, size); delete[] state; @@ -638,7 +638,7 @@ void RMGfxEngine::saveState(const Common::String &fn, byte *curThumb, const Comm bool bStat; // Saves the state of the shepherdess and show yourself - bStat = _tony.GetPastorella(); + bStat = _tony.getPastorella(); f->writeByte(bStat); bStat = _inter.getPalesati(); f->writeByte(bStat); @@ -765,7 +765,7 @@ void RMGfxEngine::loadState(CORO_PARAM, const Common::String &fn) { _ctx->size = _ctx->f->readUint32LE(); _ctx->state = new byte[_ctx->size]; _ctx->f->read(_ctx->state, _ctx->size); - _vm->_theBoxes.LoadState(_ctx->state); + _vm->_theBoxes.loadState(_ctx->state); delete[] _ctx->state; } @@ -774,7 +774,7 @@ void RMGfxEngine::loadState(CORO_PARAM, const Common::String &fn) { bool bStat = false; bStat = _ctx->f->readByte(); - _tony.SetPastorella(bStat); + _tony.setPastorella(bStat); bStat = _ctx->f->readByte(); _inter.setPalesati(bStat); @@ -813,7 +813,7 @@ void RMGfxEngine::loadState(CORO_PARAM, const Common::String &fn) { CORO_INVOKE_2(unloadLocation, false, NULL); loadLocation(_ctx->loc, _ctx->tp, RMPoint(-1, -1)); - _tony.SetPattern(RMTony::PAT_STANDRIGHT); + _tony.setPattern(RMTony::PAT_STANDRIGHT); mainUnfreeze(); // On older versions, need to an enter action @@ -838,7 +838,7 @@ void RMGfxEngine::loadState(CORO_PARAM, const Common::String &fn) { void RMGfxEngine::pauseSound(bool bPause) { if (_bLocationLoaded) - _loc.PauseSound(bPause); + _loc.pauseSound(bPause); } void RMGfxEngine::initWipe(int type) { @@ -861,7 +861,7 @@ void RMGfxEngine::waitWipeEnd(CORO_PARAM) { } bool RMGfxEngine::canLoadSave() { - return _bInput && !_tony.InAction() && !_vm->getIsDemo(); + return _bInput && !_tony.inAction() && !_vm->getIsDemo(); } } // End of namespace Tony diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index 595a1ba0f2..5ff4f6cd10 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -100,7 +100,7 @@ void RMInventory::init(void) { assert(res.IsValid()); // Initialise the MPAL inventory item by reading it in. - _items[i].icon.SetInitCurPattern(false); + _items[i].icon.setInitCurPattern(false); ds.OpenBuffer(res); ds >> _items[i].icon; ds.Close(); @@ -108,16 +108,16 @@ void RMInventory::init(void) { // Puts in the default pattern 1 _items[i].pointer = NULL; _items[i].status = 1; - _items[i].icon.SetPattern(1); + _items[i].icon.setPattern(1); _items[i].icon.doFrame(this, false); curres++; if (i == 0 || i == 28 || i == 29) continue; - _items[i].pointer = new RMGfxSourceBuffer8RLEByteAA[_items[i].icon.NumPattern()]; + _items[i].pointer = new RMGfxSourceBuffer8RLEByteAA[_items[i].icon.numPattern()]; - for (j = 0; j < _items[i].icon.NumPattern(); j++) { + for (j = 0; j < _items[i].icon.numPattern(); j++) { RMResRaw raw(curres); assert(raw.IsValid()); @@ -127,8 +127,8 @@ void RMInventory::init(void) { } } - _items[28].icon.SetPattern(1); - _items[29].icon.SetPattern(1); + _items[28].icon.setPattern(1); + _items[29].icon.setPattern(1); // Download interface RMDataStream ds; @@ -136,7 +136,7 @@ void RMInventory::init(void) { assert(res.IsValid()); ds.OpenBuffer(res); ds >> miniInterface; - miniInterface.SetPattern(1); + miniInterface.setPattern(1); ds.Close(); // Create the text for hints on the mini interface @@ -264,7 +264,7 @@ void RMInventory::addItem(int code) { g_system->lockMutex(_csModifyInterface); if (_curPos + 8 == _nInv) { // Break through the inventory! On the flashing pattern - _items[28].icon.SetPattern(2); + _items[28].icon.setPattern(2); } _inv[_nInv++] = code - 10000; @@ -281,7 +281,7 @@ void RMInventory::changeItemStatus(uint32 code, uint32 dwStatus) { error("Specified object code is not valid"); } else { g_system->lockMutex(_csModifyInterface); - _items[code - 10000].icon.SetPattern(dwStatus); + _items[code - 10000].icon.setPattern(dwStatus); _items[code - 10000].status = dwStatus; prepare(); @@ -355,12 +355,12 @@ bool RMInventory::leftClick(const RMPoint &mpos, int &nCombineObj) { if (_curPos + 8 >= _nInv) { _bBlinkingRight = false; - _items[28].icon.SetPattern(1); + _items[28].icon.setPattern(1); } if (_curPos > 0) { _bBlinkingLeft = true; - _items[29].icon.SetPattern(2); + _items[29].icon.setPattern(2); } prepare(); @@ -376,12 +376,12 @@ bool RMInventory::leftClick(const RMPoint &mpos, int &nCombineObj) { if (_curPos == 0) { _bBlinkingLeft = false; - _items[29].icon.SetPattern(1); + _items[29].icon.setPattern(1); } if (_curPos + 8 < _nInv) { _bBlinkingRight = true; - _items[28].icon.SetPattern(2); + _items[28].icon.setPattern(2); } prepare(); @@ -420,12 +420,12 @@ void RMInventory::rightClick(const RMPoint &mpos) { if (_curPos + 8 <= _nInv) { _bBlinkingRight = false; - _items[28].icon.SetPattern(1); + _items[28].icon.setPattern(1); } if (_curPos > 0) { _bBlinkingLeft = true; - _items[29].icon.SetPattern(2); + _items[29].icon.setPattern(2); } prepare(); @@ -441,12 +441,12 @@ void RMInventory::rightClick(const RMPoint &mpos) { if (_curPos == 0) { _bBlinkingLeft = false; - _items[29].icon.SetPattern(1); + _items[29].icon.setPattern(1); } if (_curPos + 8 < _nInv) { _bBlinkingRight = true; - _items[28].icon.SetPattern(2); + _items[28].icon.setPattern(2); } prepare(); @@ -495,24 +495,24 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo if ((_state == CLOSING || _state == OPENING || _state == OPENED) && checkPointInside(mpos)) { if (mpos.x > RM_SX - 64) { if (_curPos + 8 < _nInv && !_bBlinkingRight) { - _items[28].icon.SetPattern(3); + _items[28].icon.setPattern(3); _bBlinkingRight = true; bNeedRedraw = true; } } else if (_bBlinkingRight) { - _items[28].icon.SetPattern(2); + _items[28].icon.setPattern(2); _bBlinkingRight = false; bNeedRedraw = true; } if (mpos.x < 64) { if (_curPos > 0 && !_bBlinkingLeft) { - _items[29].icon.SetPattern(3); + _items[29].icon.setPattern(3); _bBlinkingLeft = true; bNeedRedraw = true; } } else if (_bBlinkingLeft) { - _items[29].icon.SetPattern(2); + _items[29].icon.setPattern(2); _bBlinkingLeft = false; bNeedRedraw = true; } @@ -633,28 +633,28 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo if (mpos.y > starty && mpos.y < starty + 45) { if (mpos.x > startx && mpos.x < startx + 40) { if (miniAction != 1) { - miniInterface.SetPattern(2); + miniInterface.setPattern(2); miniAction = 1; _vm->playUtilSFX(1); } } else if (mpos.x >= startx + 40 && mpos.x < startx + 80) { if (miniAction != 2) { - miniInterface.SetPattern(3); + miniInterface.setPattern(3); miniAction = 2; _vm->playUtilSFX(1); } } else if (mpos.x >= startx + 80 && mpos.x < startx + 108) { if (miniAction != 3) { - miniInterface.SetPattern(4); + miniInterface.setPattern(4); miniAction = 3; _vm->playUtilSFX(1); } } else { - miniInterface.SetPattern(1); + miniInterface.setPattern(1); miniAction = 0; } } else { - miniInterface.SetPattern(1); + miniInterface.setPattern(1); miniAction = 0; } @@ -729,19 +729,19 @@ int RMInventory::loadState(byte *state) { if (i < _nItems) { _items[i].status = x; - _items[i].icon.SetPattern(x); + _items[i].icon.setPattern(x); } } _curPos = 0; _bCombining = false; - _items[29].icon.SetPattern(1); + _items[29].icon.setPattern(1); if (_nInv > 8) - _items[28].icon.SetPattern(2); + _items[28].icon.setPattern(2); else - _items[28].icon.SetPattern(1); + _items[28].icon.setPattern(1); prepare(); drawOT(Common::nullContext); diff --git a/engines/tony/inventory.h b/engines/tony/inventory.h index 6ffb33dd21..d8b20827b4 100644 --- a/engines/tony/inventory.h +++ b/engines/tony/inventory.h @@ -123,11 +123,11 @@ public: // Add an item to the inventory void addItem(int code); RMInventory &operator+=(RMItem *item) { - addItem(item->MpalCode()); + addItem(item->mpalCode()); return *this; } RMInventory &operator+=(RMItem &item) { - addItem(item.MpalCode()); + addItem(item.mpalCode()); return *this; } RMInventory &operator+=(int code) { diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index ae34c577aa..d2688140fb 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -50,7 +50,7 @@ using namespace ::Tony::MPAL; * @returns Reference to the data stream */ RMDataStream &operator>>(RMDataStream &ds, RMPalette &pal) { - ds.Read(pal.m_data, 1024); + ds.Read(pal._data, 1024); return ds; } @@ -67,26 +67,26 @@ RMDataStream &operator>>(RMDataStream &ds, RMPalette &pal) { * @returns Reference to the data stream */ RMDataStream &operator>>(RMDataStream &ds, RMPattern::RMSlot &slot) { - slot.ReadFromStream(ds); + slot.readFromStream(ds); return ds; } -void RMPattern::RMSlot::ReadFromStream(RMDataStream &ds, bool bLOX) { +void RMPattern::RMSlot::readFromStream(RMDataStream &ds, bool bLOX) { byte type; // Type ds >> type; - m_type = (RMPattern::RMSlotType)type; + _type = (RMPattern::RMSlotType)type; // Dati - ds >> m_data; + ds >> _data; // Posizione - ds >> m_pos; + ds >> _pos; // Flag generica - ds >> m_flag; + ds >> _flag; } @@ -103,159 +103,159 @@ void RMPattern::RMSlot::ReadFromStream(RMDataStream &ds, bool bLOX) { * @returns Reference to the data stream */ RMDataStream &operator>>(RMDataStream &ds, RMPattern &pat) { - pat.ReadFromStream(ds); + pat.readFromStream(ds); return ds; } -void RMPattern::ReadFromStream(RMDataStream &ds, bool bLOX) { +void RMPattern::readFromStream(RMDataStream &ds, bool bLOX) { int i; // Pattern name if (!bLOX) - ds >> m_name; + ds >> _name; // Velocity - ds >> m_speed; + ds >> _speed; // Position - ds >> m_pos; + ds >> _pos; // Flag for pattern looping - ds >> m_bLoop; + ds >> _bLoop; // Number of slots - ds >> m_nSlots; + ds >> _nSlots; // Create and read the slots - m_slots = new RMSlot[m_nSlots]; + _slots = new RMSlot[_nSlots]; - for (i = 0; i < m_nSlots && !ds.IsError(); i++) { + for (i = 0; i < _nSlots && !ds.IsError(); i++) { if (bLOX) - m_slots[i].ReadFromStream(ds, true); + _slots[i].readFromStream(ds, true); else - m_slots[i].ReadFromStream(ds, false); + _slots[i].readFromStream(ds, false); } } -void RMPattern::UpdateCoord(void) { - m_curPos = m_pos + m_slots[m_nCurSlot].Pos(); +void RMPattern::updateCoord(void) { + _curPos = _pos + _slots[_nCurSlot].pos(); } -void RMPattern::StopSfx(RMSfx *sfx) { - for (int i = 0; i < m_nSlots; i++) { - if (m_slots[i].m_type == SOUND) { - if (sfx[m_slots[i].m_data].m_name[0] == '_') - sfx[m_slots[i].m_data].Stop(); +void RMPattern::stopSfx(RMSfx *sfx) { + for (int i = 0; i < _nSlots; i++) { + if (_slots[i]._type == SOUND) { + if (sfx[_slots[i]._data]._name[0] == '_') + sfx[_slots[i]._data].stop(); else if (GLOBALS.bSkipSfxNoLoop) - sfx[m_slots[i].m_data].Stop(); + sfx[_slots[i]._data].stop(); } } } -int RMPattern::Init(RMSfx *sfx, bool bPlayP0, byte *bFlag) { +int RMPattern::init(RMSfx *sfx, bool bPlayP0, byte *bFlag) { int i; // Read the current time - m_nStartTime = _vm->getTime(); - m_nCurSlot = 0; + _nStartTime = _vm->getTime(); + _nCurSlot = 0; // Find the first frame of the pattern i = 0; - while (m_slots[i].m_type != SPRITE) { - assert(i + 1 < m_nSlots); + while (_slots[i]._type != SPRITE) { + assert(i + 1 < _nSlots); i++; } - m_nCurSlot = i; - m_nCurSprite = m_slots[i].m_data; + _nCurSlot = i; + _nCurSprite = _slots[i]._data; if (bFlag) - *bFlag = m_slots[i].m_flag; + *bFlag = _slots[i]._flag; // Calculate the current coordinates - UpdateCoord(); + updateCoord(); // Check for sound: // If the slot is 0, play // If speed = 0, must playing unless it goes into loop '_', or if specified by the parameter // If speed != 0, play only the loop - for (i = 0; i < m_nSlots; i++) { - if (m_slots[i].m_type == SOUND) { + for (i = 0; i < _nSlots; i++) { + if (_slots[i]._type == SOUND) { if (i == 0) { - if (sfx[m_slots[i].m_data].m_name[0] == '_') { - sfx[m_slots[i].m_data].SetVolume(m_slots[i].Pos().x); - sfx[m_slots[i].m_data].Play(true); + if (sfx[_slots[i]._data]._name[0] == '_') { + sfx[_slots[i]._data].setVolume(_slots[i].pos().x); + sfx[_slots[i]._data].play(true); } else { - sfx[m_slots[i].m_data].SetVolume(m_slots[i].Pos().x); - sfx[m_slots[i].m_data].Play(); + sfx[_slots[i]._data].setVolume(_slots[i].pos().x); + sfx[_slots[i]._data].play(); } - } else if (m_speed == 0) { + } else if (_speed == 0) { if (bPlayP0) { - sfx[m_slots[i].m_data].SetVolume(m_slots[i].Pos().x); - sfx[m_slots[i].m_data].Play(); - } else if (sfx[m_slots[i].m_data].m_name[0] == '_') { - sfx[m_slots[i].m_data].SetVolume(m_slots[i].Pos().x); - sfx[m_slots[i].m_data].Play(true); + sfx[_slots[i]._data].setVolume(_slots[i].pos().x); + sfx[_slots[i]._data].play(); + } else if (sfx[_slots[i]._data]._name[0] == '_') { + sfx[_slots[i]._data].setVolume(_slots[i].pos().x); + sfx[_slots[i]._data].play(true); } } else { - if (m_bLoop && sfx[m_slots[i].m_data].m_name[0] == '_') { - sfx[m_slots[i].m_data].SetVolume(m_slots[i].Pos().x); - sfx[m_slots[i].m_data].Play(true); + if (_bLoop && sfx[_slots[i]._data]._name[0] == '_') { + sfx[_slots[i]._data].setVolume(_slots[i].pos().x); + sfx[_slots[i]._data].play(true); } } } } - return m_nCurSprite; + return _nCurSprite; } -int RMPattern::Update(uint32 hEndPattern, byte &bFlag, RMSfx *sfx) { +int RMPattern::update(uint32 hEndPattern, byte &bFlag, RMSfx *sfx) { int CurTime = _vm->getTime(); // If the speed is 0, then the pattern never advances - if (m_speed == 0) { + if (_speed == 0) { CoroScheduler.pulseEvent(hEndPattern); - bFlag = m_slots[m_nCurSlot].m_flag; - return m_nCurSprite; + bFlag = _slots[_nCurSlot]._flag; + return _nCurSprite; } // Is it time to change the slots? - while (m_nStartTime + m_speed <= (uint32)CurTime) { - m_nStartTime += m_speed; - if (m_slots[m_nCurSlot].m_type == SPRITE) - m_nCurSlot++; - if (m_nCurSlot == m_nSlots) { - m_nCurSlot = 0; - bFlag = m_slots[m_nCurSlot].m_flag; + while (_nStartTime + _speed <= (uint32)CurTime) { + _nStartTime += _speed; + if (_slots[_nCurSlot]._type == SPRITE) + _nCurSlot++; + if (_nCurSlot == _nSlots) { + _nCurSlot = 0; + bFlag = _slots[_nCurSlot]._flag; CoroScheduler.pulseEvent(hEndPattern); // @@@ If there is no loop pattern, and there's a warning that it's the final // frame, then remain on the last frame - if (!m_bLoop) { - m_nCurSlot = m_nSlots - 1; - bFlag = m_slots[m_nCurSlot].m_flag; - return m_nCurSprite; + if (!_bLoop) { + _nCurSlot = _nSlots - 1; + bFlag = _slots[_nCurSlot]._flag; + return _nCurSprite; } } for (;;) { - switch (m_slots[m_nCurSlot].m_type) { + switch (_slots[_nCurSlot]._type) { case SPRITE: // Read the next sprite - m_nCurSprite = m_slots[m_nCurSlot].m_data; + _nCurSprite = _slots[_nCurSlot]._data; // Update the parent & child coordinates - UpdateCoord(); + updateCoord(); break; case SOUND: if (sfx != NULL) { - sfx[m_slots[m_nCurSlot].m_data].SetVolume(m_slots[m_nCurSlot].Pos().x); + sfx[_slots[_nCurSlot]._data].setVolume(_slots[_nCurSlot].pos().x); - if (sfx[m_slots[m_nCurSlot].m_data].m_name[0] != '_') - sfx[m_slots[m_nCurSlot].m_data].Play(false); + if (sfx[_slots[_nCurSlot]._data]._name[0] != '_') + sfx[_slots[_nCurSlot]._data].play(false); else - sfx[m_slots[m_nCurSlot].m_data].Play(true); + sfx[_slots[_nCurSlot]._data].play(true); } break; @@ -268,38 +268,35 @@ int RMPattern::Update(uint32 hEndPattern, byte &bFlag, RMSfx *sfx) { break; } - if (m_slots[m_nCurSlot].m_type == SPRITE) + if (_slots[_nCurSlot]._type == SPRITE) break; - m_nCurSlot++; + _nCurSlot++; } } // Return the current sprite - bFlag = m_slots[m_nCurSlot].m_flag; - return m_nCurSprite; + bFlag = _slots[_nCurSlot]._flag; + return _nCurSprite; } RMPattern::RMPattern() { - m_slots = NULL; - m_speed = 0; - m_bLoop = 0; - m_nSlots = 0; - m_nCurSlot = 0; - m_nCurSprite = 0; - m_nStartTime = 0; - m_slots = NULL; + _slots = NULL; + _speed = 0; + _bLoop = 0; + _nSlots = 0; + _nCurSlot = 0; + _nCurSprite = 0; + _nStartTime = 0; + _slots = NULL; } RMPattern::~RMPattern() { - if (m_slots != NULL) { - delete[] m_slots; - m_slots = NULL; + if (_slots != NULL) { + delete[] _slots; + _slots = NULL; } } - - - /****************************************************************************\ * RMSprite Methods \****************************************************************************/ @@ -313,12 +310,12 @@ RMPattern::~RMPattern() { * @returns Reference to the data stream */ RMDataStream &operator>>(RMDataStream &ds, RMSprite &sprite) { - sprite.ReadFromStream(ds); + sprite.readFromStream(ds); return ds; } -void RMSprite::Init(RMGfxSourceBuffer *buf) { - m_buf = buf; +void RMSprite::init(RMGfxSourceBuffer *buf) { + _buf = buf; } void RMSprite::LOXGetSizeFromStream(RMDataStream &ds, int *dimx, int *dimy) { @@ -329,52 +326,52 @@ void RMSprite::LOXGetSizeFromStream(RMDataStream &ds, int *dimx, int *dimy) { ds.Seek(pos, ds.START); } -void RMSprite::GetSizeFromStream(RMDataStream &ds, int *dimx, int *dimy) { +void RMSprite::getSizeFromStream(RMDataStream &ds, int *dimx, int *dimy) { int pos = ds.Pos(); - ds >> m_name; + ds >> _name; ds >> *dimx >> *dimy; ds.Seek(pos, ds.START); } -void RMSprite::ReadFromStream(RMDataStream &ds, bool bLOX) { +void RMSprite::readFromStream(RMDataStream &ds, bool bLOX) { int dimx, dimy; // Sprite name if (!bLOX) - ds >> m_name; + ds >> _name; // Dimensions ds >> dimx >> dimy; // Bounding box - ds >> m_rcBox; + ds >> _rcBox; // Unused space if (!bLOX) ds += 32; // Create buffer and read - m_buf->init(ds, dimx, dimy); + _buf->init(ds, dimx, dimy); } void RMSprite::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { - m_buf->draw(coroParam, bigBuf, prim); + _buf->draw(coroParam, bigBuf, prim); } -void RMSprite::SetPalette(byte *buf) { - ((RMGfxSourceBufferPal *)m_buf)->loadPalette(buf); +void RMSprite::setPalette(byte *buf) { + ((RMGfxSourceBufferPal *)_buf)->loadPalette(buf); } RMSprite::RMSprite() { - m_buf = NULL; + _buf = NULL; } RMSprite::~RMSprite() { - if (m_buf) { - delete m_buf; - m_buf = NULL; + if (_buf) { + delete _buf; + _buf = NULL; } } @@ -392,17 +389,17 @@ RMSprite::~RMSprite() { * @returns Reference to the data stream */ RMDataStream &operator>>(RMDataStream &ds, RMSfx &sfx) { - sfx.ReadFromStream(ds); + sfx.readFromStream(ds); return ds; } -void RMSfx::ReadFromStream(RMDataStream &ds, bool bLOX) { +void RMSfx::readFromStream(RMDataStream &ds, bool bLOX) { char id[4]; int size; byte *raw; // sfx name - ds >> m_name; + ds >> _name; ds >> size; @@ -420,51 +417,51 @@ void RMSfx::ReadFromStream(RMDataStream &ds, bool bLOX) { ds.Read(raw, size); // Create the sound effect - m_fx = _vm->createSFX(raw); - m_fx->SetLoop(false); + _fx = _vm->createSFX(raw); + _fx->SetLoop(false); // Close the read buffer which is no longer needed delete[] raw; } RMSfx::RMSfx() { - m_fx = NULL; - m_bPlayingLoop = false; + _fx = NULL; + _bPlayingLoop = false; } RMSfx::~RMSfx() { - if (m_fx) { - m_fx->Release(); - m_fx = NULL; + if (_fx) { + _fx->Release(); + _fx = NULL; } } -void RMSfx::Play(bool bLoop) { - if (m_fx && !m_bPlayingLoop) { - m_fx->SetLoop(bLoop); - m_fx->Play(); +void RMSfx::play(bool bLoop) { + if (_fx && !_bPlayingLoop) { + _fx->SetLoop(bLoop); + _fx->Play(); if (bLoop) - m_bPlayingLoop = true; + _bPlayingLoop = true; } } -void RMSfx::SetVolume(int vol) { - if (m_fx) { - m_fx->SetVolume(vol); +void RMSfx::setVolume(int vol) { + if (_fx) { + _fx->SetVolume(vol); } } -void RMSfx::Pause(bool bPause) { - if (m_fx) { - m_fx->Pause(bPause); +void RMSfx::pause(bool bPause) { + if (_fx) { + _fx->Pause(bPause); } } -void RMSfx::Stop(void) { - if (m_fx) { - m_fx->Stop(); - m_bPlayingLoop = false; +void RMSfx::stop(void) { + if (_fx) { + _fx->Stop(); + _bPlayingLoop = false; } } @@ -483,24 +480,24 @@ void RMSfx::Stop(void) { * @returns Reference to the data stream */ RMDataStream &operator>>(RMDataStream &ds, RMItem &item) { - item.ReadFromStream(ds); + item.readFromStream(ds); return ds; } -RMGfxSourceBuffer *RMItem::NewItemSpriteBuffer(int dimx, int dimy, bool bPreRLE) { - if (m_cm == CM_256) { +RMGfxSourceBuffer *RMItem::newItemSpriteBuffer(int dimx, int dimy, bool bPreRLE) { + if (_cm == CM_256) { RMGfxSourceBuffer8RLE *spr; - if (m_FX == 2) { // AB + if (_FX == 2) { // AB spr = new RMGfxSourceBuffer8RLEWordAB; - } else if (m_FX == 1) { // OMBRA+AA + } else if (_FX == 1) { // OMBRA+AA if (dimx == -1 || dimx > 255) spr = new RMGfxSourceBuffer8RLEWordAA; else spr = new RMGfxSourceBuffer8RLEByteAA; - spr->setAlphaBlendColor(m_FXparm); + spr->setAlphaBlendColor(_FXparm); if (bPreRLE) spr->setAlreadyCompressed(); } else { @@ -518,17 +515,17 @@ RMGfxSourceBuffer *RMItem::NewItemSpriteBuffer(int dimx, int dimy, bool bPreRLE) return new RMGfxSourceBuffer16; } -bool RMItem::IsIn(const RMPoint &pt, int *size) { +bool RMItem::isIn(const RMPoint &pt, int *size) { RMRect rc; - if (!m_bIsActive) + if (!_bIsActive) return false; // Search for the right bounding box to use - use the sprite's if it has one, otherwise use the generic one - if (m_nCurPattern != 0 && !m_sprites[m_nCurSprite].m_rcBox.IsEmpty()) - rc = m_sprites[m_nCurSprite].m_rcBox + CalculatePos(); - else if (!m_rcBox.IsEmpty()) - rc = m_rcBox; + if (_nCurPattern != 0 && !_sprites[_nCurSprite]._rcBox.IsEmpty()) + rc = _sprites[_nCurSprite]._rcBox + calculatePos(); + else if (!_rcBox.IsEmpty()) + rc = _rcBox; // If no box, return immediately else return false; @@ -536,153 +533,152 @@ bool RMItem::IsIn(const RMPoint &pt, int *size) { if (size != NULL) *size = rc.Size(); - return rc.PtInRect(pt + m_curScroll); + return rc.PtInRect(pt + _curScroll); } - -void RMItem::ReadFromStream(RMDataStream &ds, bool bLOX) { +void RMItem::readFromStream(RMDataStream &ds, bool bLOX) { int i, dimx, dimy; byte cm; // MPAL code - ds >> m_mpalCode; + ds >> _mpalCode; // Object name - ds >> m_name; + ds >> _name; // Z (signed) - ds >> m_z; + ds >> _z; // Parent position - ds >> m_pos; + ds >> _pos; // Hotspot - ds >> m_hot; + ds >> _hot; // Bounding box - ds >> m_rcBox; + ds >> _rcBox; // Number of sprites, sound effects, and patterns - ds >> m_nSprites >> m_nSfx >> m_nPatterns; + ds >> _nSprites >> _nSfx >> _nPatterns; // Color mode ds >> cm; - m_cm = (RMColorMode)cm; + _cm = (RMColorMode)cm; // Flag for the presence of custom palette differences - ds >> m_bPal; + ds >> _bPal; - if (m_cm == CM_256) { + if (_cm == CM_256) { // If there is a palette, read it in - if (m_bPal) - ds >> m_pal; + if (_bPal) + ds >> _pal; } // MPAL data if (!bLOX) ds += 20; - ds >> m_FX; - ds >> m_FXparm; + ds >> _FX; + ds >> _FXparm; if (!bLOX) ds += 106; // Create sub-classes - if (m_nSprites > 0) - m_sprites = new RMSprite[m_nSprites]; - if (m_nSfx > 0) - m_sfx = new RMSfx[m_nSfx]; - m_patterns = new RMPattern[m_nPatterns + 1]; + if (_nSprites > 0) + _sprites = new RMSprite[_nSprites]; + if (_nSfx > 0) + _sfx = new RMSfx[_nSfx]; + _patterns = new RMPattern[_nPatterns + 1]; // Read in class data if (!ds.IsError()) - for (i = 0; i < m_nSprites && !ds.IsError(); i++) { + for (i = 0; i < _nSprites && !ds.IsError(); i++) { // Download the sprites if (bLOX) { - m_sprites[i].LOXGetSizeFromStream(ds, &dimx, &dimy); - m_sprites[i].Init(NewItemSpriteBuffer(dimx, dimy, true)); - m_sprites[i].ReadFromStream(ds, true); + _sprites[i].LOXGetSizeFromStream(ds, &dimx, &dimy); + _sprites[i].init(newItemSpriteBuffer(dimx, dimy, true)); + _sprites[i].readFromStream(ds, true); } else { - m_sprites[i].GetSizeFromStream(ds, &dimx, &dimy); - m_sprites[i].Init(NewItemSpriteBuffer(dimx, dimy, false)); - m_sprites[i].ReadFromStream(ds, false); + _sprites[i].getSizeFromStream(ds, &dimx, &dimy); + _sprites[i].init(newItemSpriteBuffer(dimx, dimy, false)); + _sprites[i].readFromStream(ds, false); } - if (m_cm == CM_256 && m_bPal) - m_sprites[i].SetPalette(m_pal.m_data); + if (_cm == CM_256 && _bPal) + _sprites[i].setPalette(_pal._data); } if (!ds.IsError()) - for (i = 0; i < m_nSfx && !ds.IsError(); i++) { + for (i = 0; i < _nSfx && !ds.IsError(); i++) { if (bLOX) - m_sfx[i].ReadFromStream(ds, true); + _sfx[i].readFromStream(ds, true); else - m_sfx[i].ReadFromStream(ds, false); + _sfx[i].readFromStream(ds, false); } // Read the pattern from pattern 1 if (!ds.IsError()) - for (i = 1; i <= m_nPatterns && !ds.IsError(); i++) { + for (i = 1; i <= _nPatterns && !ds.IsError(); i++) { if (bLOX) - m_patterns[i].ReadFromStream(ds, true); + _patterns[i].readFromStream(ds, true); else - m_patterns[i].ReadFromStream(ds, false); + _patterns[i].readFromStream(ds, false); } // Initialise the current pattern - if (m_bInitCurPattern) - SetPattern(mpalQueryItemPattern(m_mpalCode)); + if (_bInitCurPattern) + setPattern(mpalQueryItemPattern(_mpalCode)); // Initailise the current activation state - m_bIsActive = mpalQueryItemIsActive(m_mpalCode); + _bIsActive = mpalQueryItemIsActive(_mpalCode); } -RMGfxPrimitive *RMItem::NewItemPrimitive() { +RMGfxPrimitive *RMItem::newItemPrimitive() { return new RMGfxPrimitive(this); } -void RMItem::SetScrollPosition(const RMPoint &scroll) { - m_curScroll = scroll; +void RMItem::setScrollPosition(const RMPoint &scroll) { + _curScroll = scroll; } bool RMItem::doFrame(RMGfxTargetBuffer *bigBuf, bool bAddToList) { - int oldSprite = m_nCurSprite; + int oldSprite = _nCurSprite; // Pattern 0 = Do not draw anything! - if (m_nCurPattern == 0) + if (_nCurPattern == 0) return false; // We do an update of the pattern, which also returns the current frame - if (m_nCurPattern != 0) { - m_nCurSprite = m_patterns[m_nCurPattern].Update(m_hEndPattern, m_bCurFlag, m_sfx); + if (_nCurPattern != 0) { + _nCurSprite = _patterns[_nCurPattern].update(_hEndPattern, _bCurFlag, _sfx); // WORKAROUND: Currently, m_nCurSprite = -1 is used to flag that an item should be removed. // However, this seems to be done inside a process waiting on an event pulsed inside the pattern // Update method. So the value of m_nCurSprite = -1 is being destroyed with the return value // replacing it. It may be that the current coroutine PulseEvent implementation is wrong somehow. // In any case, a special check here is done for items that have ended - if (m_nCurPattern == 0) - m_nCurSprite = -1; + if (_nCurPattern == 0) + _nCurSprite = -1; } // If the function returned -1, it means that the pattern has finished - if (m_nCurSprite == -1) { + if (_nCurSprite == -1) { // We have pattern 0, so leave. The class will self de-register from the OT list - m_nCurPattern = 0; + _nCurPattern = 0; return false; } // If we are not in the OT list, add ourselves if (!_nInList && bAddToList) - bigBuf->addPrim(NewItemPrimitive()); + bigBuf->addPrim(newItemPrimitive()); - return oldSprite != m_nCurSprite; + return oldSprite != _nCurSprite; } -RMPoint RMItem::CalculatePos(void) { - return m_pos + m_patterns[m_nCurPattern].Pos(); +RMPoint RMItem::calculatePos(void) { + return _pos + _patterns[_nCurPattern].pos(); } void RMItem::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { @@ -692,24 +688,24 @@ void RMItem::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CODE(_ctx); // If CurSprite == -1, then the pattern is finished - if (m_nCurSprite == -1) + if (_nCurSprite == -1) return; // Set the flag - prim->setFlag(m_bCurFlag); + prim->setFlag(_bCurFlag); // Offset direction for scrolling - prim->Dst().Offset(-m_curScroll); + prim->Dst().Offset(-_curScroll); // We must offset the cordinates of the item inside the primitive // It is estimated as nonno + (babbo + figlio) - prim->Dst().Offset(CalculatePos()); + prim->Dst().Offset(calculatePos()); // No stretching, please prim->setStrecth(false); // Now we turn to the generic surface drawing routines - CORO_INVOKE_2(m_sprites[m_nCurSprite].draw, bigBuf, prim); + CORO_INVOKE_2(_sprites[_nCurSprite].draw, bigBuf, prim); CORO_END_CODE; } @@ -717,45 +713,45 @@ void RMItem::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { void RMItem::removeThis(CORO_PARAM, bool &result) { // Remove from the OT list if the current frame is -1 (pattern over) - result = (m_nCurSprite == -1); + result = (_nCurSprite == -1); } -void RMItem::SetStatus(int nStatus) { - m_bIsActive = (nStatus > 0); +void RMItem::setStatus(int nStatus) { + _bIsActive = (nStatus > 0); } -void RMItem::SetPattern(int nPattern, bool bPlayP0) { +void RMItem::setPattern(int nPattern, bool bPlayP0) { int i; - assert(nPattern >= 0 && nPattern <= m_nPatterns); + assert(nPattern >= 0 && nPattern <= _nPatterns); - if (m_sfx) - if (m_nCurPattern > 0) - m_patterns[m_nCurPattern].StopSfx(m_sfx); + if (_sfx) + if (_nCurPattern > 0) + _patterns[_nCurPattern].stopSfx(_sfx); // Remember the current pattern - m_nCurPattern = nPattern; + _nCurPattern = nPattern; // Start the pattern to start the animation - if (m_nCurPattern != 0) - m_nCurSprite = m_patterns[m_nCurPattern].Init(m_sfx, bPlayP0, &m_bCurFlag); + if (_nCurPattern != 0) + _nCurSprite = _patterns[_nCurPattern].init(_sfx, bPlayP0, &_bCurFlag); else { - m_nCurSprite = -1; + _nCurSprite = -1; // Look for the sound effect for pattern 0 if (bPlayP0) - for (i = 0; i < m_nSfx; i++) - if (strcmp(m_sfx[i].m_name, "p0") == 0) - m_sfx[i].Play(); + for (i = 0; i < _nSfx; i++) + if (strcmp(_sfx[i]._name, "p0") == 0) + _sfx[i].play(); } } -bool RMItem::GetName(RMString &name) { +bool RMItem::getName(RMString &name) { char buf[256]; - mpalQueryItemName(m_mpalCode, buf); + mpalQueryItemName(_mpalCode, buf); name = buf; if (buf[0] == '\0') return false; @@ -763,64 +759,64 @@ bool RMItem::GetName(RMString &name) { } -void RMItem::Unload(void) { - if (m_patterns != NULL) { - delete[] m_patterns; - m_patterns = NULL; +void RMItem::unload(void) { + if (_patterns != NULL) { + delete[] _patterns; + _patterns = NULL; } - if (m_sprites != NULL) { - delete[] m_sprites; - m_sprites = NULL; + if (_sprites != NULL) { + delete[] _sprites; + _sprites = NULL; } - if (m_sfx != NULL) { - delete[] m_sfx; - m_sfx = NULL; + if (_sfx != NULL) { + delete[] _sfx; + _sfx = NULL; } } RMItem::RMItem() { - m_bCurFlag = 0; - m_patterns = NULL; - m_sprites = NULL; - m_sfx = NULL; - m_curScroll.Set(0, 0); - m_bInitCurPattern = true; - m_nCurPattern = 0; - m_z = 0; - m_cm = CM_256; - m_FX = 0; - m_FXparm = 0; - m_mpalCode = 0; - m_nSprites = 0; - m_nSfx = 0; - m_nPatterns = 0; - m_bPal = 0; - m_nCurSprite = 0; - - m_hEndPattern = CoroScheduler.createEvent(false, false); + _bCurFlag = 0; + _patterns = NULL; + _sprites = NULL; + _sfx = NULL; + _curScroll.Set(0, 0); + _bInitCurPattern = true; + _nCurPattern = 0; + _z = 0; + _cm = CM_256; + _FX = 0; + _FXparm = 0; + _mpalCode = 0; + _nSprites = 0; + _nSfx = 0; + _nPatterns = 0; + _bPal = 0; + _nCurSprite = 0; + + _hEndPattern = CoroScheduler.createEvent(false, false); } RMItem::~RMItem() { - Unload(); - CoroScheduler.closeEvent(m_hEndPattern); + unload(); + CoroScheduler.closeEvent(_hEndPattern); } -void RMItem::WaitForEndPattern(CORO_PARAM, uint32 hCustomSkip) { +void RMItem::waitForEndPattern(CORO_PARAM, uint32 hCustomSkip) { CORO_BEGIN_CONTEXT; uint32 h[2]; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - if (m_nCurPattern != 0) { + if (_nCurPattern != 0) { if (hCustomSkip == CORO_INVALID_PID_VALUE) - CORO_INVOKE_2(CoroScheduler.waitForSingleObject, m_hEndPattern, CORO_INFINITE); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _hEndPattern, CORO_INFINITE); else { _ctx->h[0] = hCustomSkip; - _ctx->h[1] = m_hEndPattern; + _ctx->h[1] = _hEndPattern; CORO_INVOKE_4(CoroScheduler.waitForMultipleObjects, 2, &_ctx->h[0], false, CORO_INFINITE); } } @@ -828,20 +824,20 @@ void RMItem::WaitForEndPattern(CORO_PARAM, uint32 hCustomSkip) { CORO_END_CODE; } -void RMItem::ChangeHotspot(const RMPoint &pt) { - m_hot = pt; +void RMItem::changeHotspot(const RMPoint &pt) { + _hot = pt; } -void RMItem::PlaySfx(int nSfx) { - if (nSfx < m_nSfx) - m_sfx[nSfx].Play(); +void RMItem::playSfx(int nSfx) { + if (nSfx < _nSfx) + _sfx[nSfx].play(); } -void RMItem::PauseSound(bool bPause) { +void RMItem::pauseSound(bool bPause) { int i; - for (i = 0; i < m_nSfx; i++) - m_sfx[i].Pause(bPause); + for (i = 0; i < _nSfx; i++) + _sfx[i].pause(bPause); } @@ -852,13 +848,13 @@ void RMItem::PauseSound(bool bPause) { RMWipe::RMWipe() { - m_hUnregistered = CoroScheduler.createEvent(false, false); - m_hEndOfFade = CoroScheduler.createEvent(false, false); + _hUnregistered = CoroScheduler.createEvent(false, false); + _hEndOfFade = CoroScheduler.createEvent(false, false); } RMWipe::~RMWipe() { - CoroScheduler.closeEvent(m_hUnregistered); - CoroScheduler.closeEvent(m_hEndOfFade); + CoroScheduler.closeEvent(_hUnregistered); + CoroScheduler.closeEvent(_hEndOfFade); } int RMWipe::priority(void) { @@ -868,23 +864,23 @@ int RMWipe::priority(void) { void RMWipe::Unregister(void) { RMGfxTask::Unregister(); assert(_nInList == 0); - CoroScheduler.setEvent(m_hUnregistered); + CoroScheduler.setEvent(_hUnregistered); } void RMWipe::removeThis(CORO_PARAM, bool &result) { - result = m_bUnregister; + result = _bUnregister; } -void RMWipe::WaitForFadeEnd(CORO_PARAM) { +void RMWipe::waitForFadeEnd(CORO_PARAM) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_2(CoroScheduler.waitForSingleObject, m_hEndOfFade, CORO_INFINITE); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _hEndOfFade, CORO_INFINITE); - m_bEndFade = true; - m_bFading = false; + _bEndFade = true; + _bFading = false; CORO_INVOKE_0(mainWaitFrame); CORO_INVOKE_0(mainWaitFrame); @@ -892,44 +888,44 @@ void RMWipe::WaitForFadeEnd(CORO_PARAM) { CORO_END_CODE; } -void RMWipe::CloseFade(void) { - m_wip0r.Unload(); +void RMWipe::closeFade(void) { + _wip0r.unload(); } -void RMWipe::InitFade(int type) { +void RMWipe::initFade(int type) { // Activate the fade - m_bUnregister = false; - m_bEndFade = false; + _bUnregister = false; + _bEndFade = false; - m_nFadeStep = 0; + _nFadeStep = 0; - m_bMustRegister = true; + _bMustRegister = true; RMRes res(RES_W_CERCHIO); RMDataStream ds; ds.OpenBuffer(res); - ds >> m_wip0r; + ds >> _wip0r; ds.Close(); - m_wip0r.SetPattern(1); + _wip0r.setPattern(1); - m_bFading = true; + _bFading = true; } -void RMWipe::DoFrame(RMGfxTargetBuffer &bigBuf) { - if (m_bMustRegister) { +void RMWipe::doFrame(RMGfxTargetBuffer &bigBuf) { + if (_bMustRegister) { bigBuf.addPrim(new RMGfxPrimitive(this)); - m_bMustRegister = false; + _bMustRegister = false; } - if (m_bFading) { - m_wip0r.doFrame(&bigBuf, false); + if (_bFading) { + _wip0r.doFrame(&bigBuf, false); - m_nFadeStep++; + _nFadeStep++; - if (m_nFadeStep == 10) { - CoroScheduler.setEvent(m_hEndOfFade); + if (_nFadeStep == 10) { + CoroScheduler.setEvent(_hEndOfFade); } } } @@ -940,18 +936,16 @@ void RMWipe::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CODE(_ctx); - if (m_bFading) { - CORO_INVOKE_2(m_wip0r.draw, bigBuf, prim); + if (_bFading) { + CORO_INVOKE_2(_wip0r.draw, bigBuf, prim); } - if (m_bEndFade) + if (_bEndFade) Common::fill((byte *)bigBuf, (byte *)bigBuf + bigBuf.getDimx() * bigBuf.getDimy() * 2, 0x0); CORO_END_CODE; } - - /****************************************************************************\ * RMCharacter Methods \****************************************************************************/ @@ -961,7 +955,7 @@ void RMWipe::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { /* Returns path along the vector path path[] */ /****************************************************************************/ -short RMCharacter::FindPath(short source, short destination) { +short RMCharacter::findPath(short source, short destination) { static RMBox BOX[MAXBOXES]; // Matrix of adjacent boxes static short COSTO[MAXBOXES]; // Cost per node static short VALIDO[MAXBOXES]; // 0:Invalid 1:Valid 2:Saturated @@ -977,7 +971,7 @@ short RMCharacter::FindPath(short source, short destination) { } // Get the boxes - cur = theBoxes->GetBoxes(curLocation); + cur = theBoxes->getBoxes(curLocation); // Make a backup copy to work on for (i = 0; i < cur->numbbox; i++) @@ -1055,22 +1049,22 @@ short RMCharacter::FindPath(short source, short destination) { } -void RMCharacter::GoTo(CORO_PARAM, RMPoint destcoord, bool bReversed) { +void RMCharacter::goTo(CORO_PARAM, RMPoint destcoord, bool bReversed) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - if (m_pos == destcoord) { + if (_pos == destcoord) { if (minpath == 0) { - CORO_INVOKE_0(Stop); + CORO_INVOKE_0(stop); CoroScheduler.pulseEvent(hEndOfPath); return; } } status = WALK; - linestart = m_pos; + linestart = _pos; lineend = destcoord; dx = linestart.x - lineend.x; dy = linestart.y - lineend.y; @@ -1085,7 +1079,7 @@ void RMCharacter::GoTo(CORO_PARAM, RMPoint destcoord, bool bReversed) { while (0) ; } - int nPatt = GetCurPattern(); + int nPatt = getCurPattern(); if (dx > dy) { slope = fy / fx; @@ -1097,10 +1091,10 @@ void RMCharacter::GoTo(CORO_PARAM, RMPoint destcoord, bool bReversed) { bNeedToStop = true; if ((walkspeed < 0 && !bReversed) || (walkspeed >= 0 && bReversed)) { if (nPatt != PAT_WALKLEFT) - SetPattern(PAT_WALKLEFT); + setPattern(PAT_WALKLEFT); } else { if (nPatt != PAT_WALKRIGHT) - SetPattern(PAT_WALKRIGHT); + setPattern(PAT_WALKRIGHT); } } else { slope = fx / fy; @@ -1111,10 +1105,10 @@ void RMCharacter::GoTo(CORO_PARAM, RMPoint destcoord, bool bReversed) { bNeedToStop = true; if ((walkspeed < 0 && !bReversed) || (walkspeed >= 0 && bReversed)) { if (nPatt != PAT_WALKUP) - SetPattern(PAT_WALKUP); + setPattern(PAT_WALKUP); } else { if (nPatt != PAT_WALKDOWN) - SetPattern(PAT_WALKDOWN); + setPattern(PAT_WALKDOWN); } } @@ -1125,7 +1119,7 @@ void RMCharacter::GoTo(CORO_PARAM, RMPoint destcoord, bool bReversed) { } -RMPoint RMCharacter::Searching(char UP, char DOWN, char RIGHT, char LEFT, RMPoint punto) { +RMPoint RMCharacter::searching(char UP, char DOWN, char RIGHT, char LEFT, RMPoint punto) { short passi, minimo; RMPoint nuovo, trovato; minimo = 32000; @@ -1133,12 +1127,12 @@ RMPoint RMCharacter::Searching(char UP, char DOWN, char RIGHT, char LEFT, RMPoin if (UP) { nuovo = punto; passi = 0; - while ((InWhichBox(nuovo) == -1) && (nuovo.y >= 0)) { + while ((inWhichBox(nuovo) == -1) && (nuovo.y >= 0)) { nuovo.y--; passi++; } - if ((InWhichBox(nuovo) != -1) && (passi < minimo) && - FindPath(InWhichBox(m_pos), InWhichBox(nuovo))) { + if ((inWhichBox(nuovo) != -1) && (passi < minimo) && + findPath(inWhichBox(_pos), inWhichBox(nuovo))) { minimo = passi; nuovo.y--; // to avoid error? trovato = nuovo; @@ -1148,12 +1142,12 @@ RMPoint RMCharacter::Searching(char UP, char DOWN, char RIGHT, char LEFT, RMPoin if (DOWN) { nuovo = punto; passi = 0; - while ((InWhichBox(nuovo) == -1) && (nuovo.y < 480)) { + while ((inWhichBox(nuovo) == -1) && (nuovo.y < 480)) { nuovo.y++; passi++; } - if ((InWhichBox(nuovo) != -1) && (passi < minimo) && - FindPath(InWhichBox(m_pos), InWhichBox(nuovo))) { + if ((inWhichBox(nuovo) != -1) && (passi < minimo) && + findPath(inWhichBox(_pos), inWhichBox(nuovo))) { minimo = passi; nuovo.y++; // to avoid error? trovato = nuovo; @@ -1163,12 +1157,12 @@ RMPoint RMCharacter::Searching(char UP, char DOWN, char RIGHT, char LEFT, RMPoin if (RIGHT) { nuovo = punto; passi = 0; - while ((InWhichBox(nuovo) == -1) && (nuovo.x < 640)) { + while ((inWhichBox(nuovo) == -1) && (nuovo.x < 640)) { nuovo.x++; passi++; } - if ((InWhichBox(nuovo) != -1) && (passi < minimo) && - FindPath(InWhichBox(m_pos), InWhichBox(nuovo))) { + if ((inWhichBox(nuovo) != -1) && (passi < minimo) && + findPath(inWhichBox(_pos), inWhichBox(nuovo))) { minimo = passi; nuovo.x++; // to avoid error? trovato = nuovo; @@ -1178,12 +1172,12 @@ RMPoint RMCharacter::Searching(char UP, char DOWN, char RIGHT, char LEFT, RMPoin if (LEFT) { nuovo = punto; passi = 0; - while ((InWhichBox(nuovo) == -1) && (nuovo.x >= 0)) { + while ((inWhichBox(nuovo) == -1) && (nuovo.x >= 0)) { nuovo.x--; passi++; } - if ((InWhichBox(nuovo) != -1) && (passi < minimo) && - FindPath(InWhichBox(m_pos), InWhichBox(nuovo))) { + if ((inWhichBox(nuovo) != -1) && (passi < minimo) && + findPath(inWhichBox(_pos), inWhichBox(nuovo))) { minimo = passi; nuovo.x--; // to avoid error? trovato = nuovo; @@ -1195,18 +1189,18 @@ RMPoint RMCharacter::Searching(char UP, char DOWN, char RIGHT, char LEFT, RMPoin } -RMPoint RMCharacter::NearestPoint(const RMPoint &punto) { - return Searching(1, 1, 1, 1, punto); +RMPoint RMCharacter::nearestPoint(const RMPoint &punto) { + return searching(1, 1, 1, 1, punto); } -short RMCharacter::ScanLine(const RMPoint &punto) { +short RMCharacter::scanLine(const RMPoint &punto) { int Ldx, Ldy, Lcount; float Lfx, Lfy, Lslope; RMPoint Lstart, Lend, Lscan; signed char Lspeed, Lstatus; - Lstart = m_pos; + Lstart = _pos; Lend = punto; Ldx = Lstart.x - Lend.x; Ldy = Lstart.y - Lend.y; @@ -1228,7 +1222,7 @@ short RMCharacter::ScanLine(const RMPoint &punto) { } Lscan = Lstart; // Start scanning - while (InWhichBox(Lscan) != -1) { + while (inWhichBox(Lscan) != -1) { Lcount++; if (Lstatus) { Ldx = Lspeed * Lcount; @@ -1250,14 +1244,14 @@ short RMCharacter::ScanLine(const RMPoint &punto) { /** * Calculates intersections between the straight line and the closest BBOX */ -RMPoint RMCharacter::InvScanLine(const RMPoint &punto) { +RMPoint RMCharacter::invScanLine(const RMPoint &punto) { int Ldx, Ldy, Lcount; float Lfx, Lfy, Lslope; RMPoint Lstart, Lend, Lscan; signed char Lspeed, Lstatus, Lbox = -1; Lstart = punto; // Exchange! - Lend = m_pos; // :-) + Lend = _pos; // :-) Ldx = Lstart.x - Lend.x; Ldy = Lstart.y - Lend.y; Lfx = Ldx; @@ -1279,12 +1273,12 @@ RMPoint RMCharacter::InvScanLine(const RMPoint &punto) { Lscan = Lstart; for (;;) { - if (InWhichBox(Lscan) != -1) { - if (InWhichBox(Lscan) != Lbox) { - if (InWhichBox(m_pos) == InWhichBox(Lscan) || FindPath(InWhichBox(m_pos), InWhichBox(Lscan))) + if (inWhichBox(Lscan) != -1) { + if (inWhichBox(Lscan) != Lbox) { + if (inWhichBox(_pos) == inWhichBox(Lscan) || findPath(inWhichBox(_pos), inWhichBox(Lscan))) return Lscan; else - Lbox = InWhichBox(Lscan); + Lbox = inWhichBox(Lscan); } } @@ -1310,17 +1304,17 @@ RMPoint RMCharacter::InvScanLine(const RMPoint &punto) { * Returns the HotSpot coordinate closest to the player */ -RMPoint RMCharacter::NearestHotSpot(int sourcebox, int destbox) { +RMPoint RMCharacter::nearestHotSpot(int sourcebox, int destbox) { RMPoint puntocaldo; short cc; int x, y, distanzaminima; distanzaminima = 10000000; - RMBoxLoc *cur = theBoxes->GetBoxes(curLocation); + RMBoxLoc *cur = theBoxes->getBoxes(curLocation); for (cc = 0; cc < cur->boxes[sourcebox].numhotspot; cc++) if ((cur->boxes[sourcebox].hotspot[cc].destination) == destbox) { - x = ABS(cur->boxes[sourcebox].hotspot[cc].hotx - m_pos.x); - y = ABS(cur->boxes[sourcebox].hotspot[cc].hoty - m_pos.y); + x = ABS(cur->boxes[sourcebox].hotspot[cc].hotx - _pos.x); + y = ABS(cur->boxes[sourcebox].hotspot[cc].hoty - _pos.y); if ((x * x + y * y) < distanzaminima) { distanzaminima = x * x + y * y; @@ -1339,7 +1333,7 @@ void RMCharacter::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr CORO_BEGIN_CODE(_ctx); if (bDrawNow) { - prim->Dst() += m_fixedScroll; + prim->Dst() += _fixedScroll; CORO_INVOKE_2(RMItem::draw, bigBuf, prim); } @@ -1347,39 +1341,39 @@ void RMCharacter::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr CORO_END_CODE; } -void RMCharacter::NewBoxEntered(int nBox) { +void RMCharacter::newBoxEntered(int nBox) { RMBoxLoc *cur; bool bOldReverse; // Recall on ExitBox mpalQueryDoAction(3, curLocation, curbox); - cur = theBoxes->GetBoxes(curLocation); + cur = theBoxes->getBoxes(curLocation); bOldReverse = cur->boxes[curbox].bReversed; curbox = nBox; // If Z is changed, we must remove it from the OT - if (cur->boxes[curbox].Zvalue != m_z) { + if (cur->boxes[curbox].Zvalue != _z) { bRemoveFromOT = true; - m_z = cur->boxes[curbox].Zvalue; + _z = cur->boxes[curbox].Zvalue; } // Movement management is reversed, only if we are not in the shortest path. If we are in the shortest // path, directly do the DoFrame if (bMovingWithoutMinpath) { if ((cur->boxes[curbox].bReversed && !bOldReverse) || (!cur->boxes[curbox].bReversed && bOldReverse)) { - switch (GetCurPattern()) { + switch (getCurPattern()) { case PAT_WALKUP: - SetPattern(PAT_WALKDOWN); + setPattern(PAT_WALKDOWN); break; case PAT_WALKDOWN: - SetPattern(PAT_WALKUP); + setPattern(PAT_WALKUP); break; case PAT_WALKRIGHT: - SetPattern(PAT_WALKLEFT); + setPattern(PAT_WALKLEFT); break; case PAT_WALKLEFT: - SetPattern(PAT_WALKRIGHT); + setPattern(PAT_WALKRIGHT); break; } } @@ -1389,7 +1383,7 @@ void RMCharacter::NewBoxEntered(int nBox) { mpalQueryDoAction(2, curLocation, curbox); } -void RMCharacter::DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc) { +void RMCharacter::doFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc) { CORO_BEGIN_CONTEXT; bool bEndNow; RMBoxLoc *cur; @@ -1409,12 +1403,12 @@ void RMCharacter::DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc) { if (walkstatus == 1) { dx = walkspeed * walkcount; dy = slope * dx; - m_pos.x = linestart.x + dx; - m_pos.y = linestart.y + dy; + _pos.x = linestart.x + dx; + _pos.y = linestart.y + dy; // Right - if (((walkspeed > 0) && (m_pos.x > lineend.x)) || ((walkspeed < 0) && (m_pos.x < lineend.x))) { - m_pos = lineend; + if (((walkspeed > 0) && (_pos.x > lineend.x)) || ((walkspeed < 0) && (_pos.x < lineend.x))) { + _pos = lineend; status = STAND; _ctx->bEndNow = true; } @@ -1424,27 +1418,27 @@ void RMCharacter::DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc) { if (walkstatus == 0) { dy = walkspeed * walkcount; dx = slope * dy; - m_pos.x = linestart.x + dx; - m_pos.y = linestart.y + dy; + _pos.x = linestart.x + dx; + _pos.y = linestart.y + dy; // Down - if (((walkspeed > 0) && (m_pos.y > lineend.y)) || ((walkspeed < 0) && (m_pos.y < lineend.y))) { - m_pos = lineend; + if (((walkspeed > 0) && (_pos.y > lineend.y)) || ((walkspeed < 0) && (_pos.y < lineend.y))) { + _pos = lineend; status = STAND; _ctx->bEndNow = true; } } // Check if the character came out of the BOX in error, in which case he returns immediately - if (InWhichBox(m_pos) == -1) { - m_pos.x = linestart.x + olddx; - m_pos.y = linestart.y + olddy; + if (inWhichBox(_pos) == -1) { + _pos.x = linestart.x + olddx; + _pos.y = linestart.y + olddy; } // If we have just moved to a temporary location, and is over the shortest path, we stop permanently if (_ctx->bEndNow && minpath == 0) { if (!bEndOfPath) - CORO_INVOKE_0(Stop); + CORO_INVOKE_0(stop); bEndOfPath = true; CoroScheduler.pulseEvent(hEndOfPath); } @@ -1454,8 +1448,8 @@ void RMCharacter::DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc) { // Update the character Z. @@@ Should remove only if the Z was changed // Check if the box was changed - if (!theBoxes->IsInBox(curLocation, curbox, m_pos)) - NewBoxEntered(InWhichBox(m_pos)); + if (!theBoxes->isInBox(curLocation, curbox, _pos)) + newBoxEntered(inWhichBox(_pos)); // Update the old coordinates olddx = dx; @@ -1466,7 +1460,7 @@ void RMCharacter::DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc) { if (status == STAND) { // Check if there is still the shortest path to calculate if (minpath == 1) { - _ctx->cur = theBoxes->GetBoxes(curLocation); + _ctx->cur = theBoxes->getBoxes(curLocation); // If we still have to go through a box if (pathcount < pathlenght) { @@ -1474,7 +1468,7 @@ void RMCharacter::DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc) { if (_ctx->cur->boxes[path[pathcount - 1]].attivo) { // Move in a straight line towards the nearest hotspot, taking into account the reversing // NEWBOX = path[pathcount-1] - CORO_INVOKE_2(GoTo, NearestHotSpot(path[pathcount - 1], path[pathcount]), _ctx->cur->boxes[path[pathcount - 1]].bReversed); + CORO_INVOKE_2(goTo, nearestHotSpot(path[pathcount - 1], path[pathcount]), _ctx->cur->boxes[path[pathcount - 1]].bReversed); pathcount++; } else { // If the box is off, we can only block all @@ -1482,7 +1476,7 @@ void RMCharacter::DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc) { // the search for the minimum path minpath = 0; if (!bEndOfPath) - CORO_INVOKE_0(Stop); + CORO_INVOKE_0(stop); bEndOfPath = true; CoroScheduler.pulseEvent(hEndOfPath); } @@ -1491,7 +1485,7 @@ void RMCharacter::DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc) { // point of arrival // NEWBOX = InWhichBox(pathend) minpath = 0; - CORO_INVOKE_2(GoTo, pathend, _ctx->cur->boxes[InWhichBox(pathend)].bReversed); + CORO_INVOKE_2(goTo, pathend, _ctx->cur->boxes[inWhichBox(pathend)].bReversed); } } } @@ -1504,7 +1498,7 @@ void RMCharacter::DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc) { CORO_END_CODE; } -void RMCharacter::Stop(CORO_PARAM) { +void RMCharacter::stop(CORO_PARAM) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); @@ -1521,37 +1515,37 @@ void RMCharacter::Stop(CORO_PARAM) { bNeedToStop = false; - switch (GetCurPattern()) { + switch (getCurPattern()) { case PAT_WALKUP: - SetPattern(PAT_STANDUP); + setPattern(PAT_STANDUP); break; case PAT_WALKDOWN: - SetPattern(PAT_STANDDOWN); + setPattern(PAT_STANDDOWN); break; case PAT_WALKLEFT: - SetPattern(PAT_STANDLEFT); + setPattern(PAT_STANDLEFT); break; case PAT_WALKRIGHT: - SetPattern(PAT_STANDRIGHT); + setPattern(PAT_STANDRIGHT); break; default: - SetPattern(PAT_STANDDOWN); + setPattern(PAT_STANDDOWN); break; } CORO_END_CODE; } -inline int RMCharacter::InWhichBox(const RMPoint &pt) { - return theBoxes->WhichBox(curLocation, pt); +inline int RMCharacter::inWhichBox(const RMPoint &pt) { + return theBoxes->whichBox(curLocation, pt); } -void RMCharacter::Move(CORO_PARAM, RMPoint pt, bool *result) { +void RMCharacter::move(CORO_PARAM, RMPoint pt, bool *result) { CORO_BEGIN_CONTEXT; RMPoint dest; int numbox; @@ -1566,34 +1560,34 @@ void RMCharacter::Move(CORO_PARAM, RMPoint pt, bool *result) { if (pt.x == 0 && pt.y == 0) { minpath = 0; status = STAND; - CORO_INVOKE_0(Stop); + CORO_INVOKE_0(stop); if (result) *result = true; return; } // If clicked outside the box - _ctx->numbox = InWhichBox(pt); + _ctx->numbox = inWhichBox(pt); if (_ctx->numbox == -1) { // Find neareste point inside the box - _ctx->dest = NearestPoint(pt); + _ctx->dest = nearestPoint(pt); // ???!?? if (_ctx->dest == pt) - _ctx->dest = InvScanLine(pt); + _ctx->dest = invScanLine(pt); pt = _ctx->dest; - _ctx->numbox = InWhichBox(pt); + _ctx->numbox = inWhichBox(pt); } - _ctx->cur = theBoxes->GetBoxes(curLocation); + _ctx->cur = theBoxes->getBoxes(curLocation); minpath = 0; status = STAND; bMovingWithoutMinpath = true; - if (ScanLine(pt)) - CORO_INVOKE_2(GoTo, pt, _ctx->cur->boxes[_ctx->numbox].bReversed); - else if (FindPath(InWhichBox(m_pos), InWhichBox(pt))) { + if (scanLine(pt)) + CORO_INVOKE_2(goTo, pt, _ctx->cur->boxes[_ctx->numbox].bReversed); + else if (findPath(inWhichBox(_pos), inWhichBox(pt))) { bMovingWithoutMinpath = false; minpath = 1; pathcount = 1; @@ -1601,12 +1595,12 @@ void RMCharacter::Move(CORO_PARAM, RMPoint pt, bool *result) { } else { // @@@ This case is whether a hotspot is inside a box, but there is // a path to get there. We use the InvScanLine to search around a point - _ctx->dest = InvScanLine(pt); + _ctx->dest = invScanLine(pt); pt = _ctx->dest; - if (ScanLine(pt)) - CORO_INVOKE_2(GoTo, pt, _ctx->cur->boxes[_ctx->numbox].bReversed); - else if (FindPath(InWhichBox(m_pos), InWhichBox(pt))) { + if (scanLine(pt)) + CORO_INVOKE_2(goTo, pt, _ctx->cur->boxes[_ctx->numbox].bReversed); + else if (findPath(inWhichBox(_pos), inWhichBox(pt))) { bMovingWithoutMinpath = false; minpath = 1; pathcount = 1; @@ -1627,25 +1621,25 @@ void RMCharacter::Move(CORO_PARAM, RMPoint pt, bool *result) { CORO_END_CODE; } -void RMCharacter::SetPosition(const RMPoint &pt, int newloc) { +void RMCharacter::setPosition(const RMPoint &pt, int newloc) { RMBoxLoc *box; minpath = 0; status = STAND; - m_pos = pt; + _pos = pt; if (newloc != -1) curLocation = newloc; // Update the character's Z value - box = theBoxes->GetBoxes(curLocation); - curbox = InWhichBox(m_pos); + box = theBoxes->getBoxes(curLocation); + curbox = inWhichBox(_pos); assert(curbox != -1); - m_z = box->boxes[curbox].Zvalue; + _z = box->boxes[curbox].Zvalue; bRemoveFromOT = true; } -void RMCharacter::WaitForEndMovement(CORO_PARAM) { +void RMCharacter::waitForEndMovement(CORO_PARAM) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); @@ -1694,7 +1688,7 @@ RMCharacter::RMCharacter() { bDrawNow = false; bNeedToStop = false; - m_pos.Set(0, 0); + _pos.Set(0, 0); } RMCharacter::~RMCharacter() { @@ -1702,7 +1696,7 @@ RMCharacter::~RMCharacter() { CoroScheduler.closeEvent(hEndOfPath); } -void RMCharacter::LinkToBoxes(RMGameBoxes *boxes) { +void RMCharacter::linkToBoxes(RMGameBoxes *boxes) { theBoxes = boxes; } @@ -1710,7 +1704,7 @@ void RMCharacter::LinkToBoxes(RMGameBoxes *boxes) { * RMBox Methods \****************************************************************************/ -void RMBox::ReadFromStream(RMDataStream &ds) { +void RMBox::readFromStream(RMDataStream &ds) { uint16 w; int i; byte b; @@ -1749,7 +1743,7 @@ void RMBox::ReadFromStream(RMDataStream &ds) { } RMDataStream &operator>>(RMDataStream &ds, RMBox &box) { - box.ReadFromStream(ds); + box.readFromStream(ds); return ds; } @@ -1766,7 +1760,7 @@ RMBoxLoc::~RMBoxLoc() { delete[] boxes; } -void RMBoxLoc::ReadFromStream(RMDataStream &ds) { +void RMBoxLoc::readFromStream(RMDataStream &ds) { int i; char buf[2]; byte ver; @@ -1788,7 +1782,7 @@ void RMBoxLoc::ReadFromStream(RMDataStream &ds) { } -void RMBoxLoc::RecalcAllAdj(void) { +void RMBoxLoc::recalcAllAdj(void) { int i, j; for (i = 0; i < numbbox; i++) { @@ -1801,7 +1795,7 @@ void RMBoxLoc::RecalcAllAdj(void) { } RMDataStream &operator>>(RMDataStream &ds, RMBoxLoc &bl) { - bl.ReadFromStream(ds); + bl.readFromStream(ds); return ds; } @@ -1811,45 +1805,45 @@ RMDataStream &operator>>(RMDataStream &ds, RMBoxLoc &bl) { \****************************************************************************/ RMGameBoxes::RMGameBoxes() { - m_nLocBoxes = 0; - Common::fill(m_allBoxes, m_allBoxes + GAME_BOXES_SIZE, (RMBoxLoc *)NULL); + _nLocBoxes = 0; + Common::fill(_allBoxes, _allBoxes + GAME_BOXES_SIZE, (RMBoxLoc *)NULL); } RMGameBoxes::~RMGameBoxes() { - for (int i = 1; i <= m_nLocBoxes; ++i) - delete m_allBoxes[i]; + for (int i = 1; i <= _nLocBoxes; ++i) + delete _allBoxes[i]; } -void RMGameBoxes::Init(void) { +void RMGameBoxes::init(void) { int i; RMString fn; RMDataStream ds; // Load boxes from disk - m_nLocBoxes = 130; - for (i = 1; i <= m_nLocBoxes; i++) { + _nLocBoxes = 130; + for (i = 1; i <= _nLocBoxes; i++) { RMRes res(10000 + i); ds.OpenBuffer(res); - m_allBoxes[i] = new RMBoxLoc(); - ds >> *m_allBoxes[i]; + _allBoxes[i] = new RMBoxLoc(); + ds >> *_allBoxes[i]; - m_allBoxes[i]->RecalcAllAdj(); + _allBoxes[i]->recalcAllAdj(); ds.Close(); } } -void RMGameBoxes::Close(void) { +void RMGameBoxes::close(void) { } -RMBoxLoc *RMGameBoxes::GetBoxes(int nLoc) { - return m_allBoxes[nLoc]; +RMBoxLoc *RMGameBoxes::getBoxes(int nLoc) { + return _allBoxes[nLoc]; } -bool RMGameBoxes::IsInBox(int nLoc, int nBox, const RMPoint &pt) { - RMBoxLoc *cur = GetBoxes(nLoc); +bool RMGameBoxes::isInBox(int nLoc, int nBox, const RMPoint &pt) { + RMBoxLoc *cur = getBoxes(nLoc); if ((pt.x >= cur->boxes[nBox].left) && (pt.x <= cur->boxes[nBox].right) && (pt.y >= cur->boxes[nBox].top) && (pt.y <= cur->boxes[nBox].bottom)) @@ -1858,11 +1852,12 @@ bool RMGameBoxes::IsInBox(int nLoc, int nBox, const RMPoint &pt) { return false; } -int RMGameBoxes::WhichBox(int nLoc, const RMPoint &punto) { +int RMGameBoxes::whichBox(int nLoc, const RMPoint &punto) { int i; - RMBoxLoc *cur = GetBoxes(nLoc); + RMBoxLoc *cur = getBoxes(nLoc); - if (!cur) return -1; + if (!cur) + return -1; for (i = 0; i < cur->numbbox; i++) if (cur->boxes[i].attivo) @@ -1873,44 +1868,44 @@ int RMGameBoxes::WhichBox(int nLoc, const RMPoint &punto) { return -1; } -void RMGameBoxes::ChangeBoxStatus(int nLoc, int nBox, int status) { - m_allBoxes[nLoc]->boxes[nBox].attivo = status; - m_allBoxes[nLoc]->RecalcAllAdj(); +void RMGameBoxes::changeBoxStatus(int nLoc, int nBox, int status) { + _allBoxes[nLoc]->boxes[nBox].attivo = status; + _allBoxes[nLoc]->recalcAllAdj(); } -int RMGameBoxes::GetSaveStateSize(void) { +int RMGameBoxes::getSaveStateSize(void) { int size; int i; size = 4; - for (i = 1; i <= m_nLocBoxes; i++) { + for (i = 1; i <= _nLocBoxes; i++) { size += 4; - size += m_allBoxes[i]->numbbox; + size += _allBoxes[i]->numbbox; } return size; } -void RMGameBoxes::SaveState(byte *state) { +void RMGameBoxes::saveState(byte *state) { int i, j; // Save the number of locations with boxes - WRITE_LE_UINT32(state, m_nLocBoxes); + WRITE_LE_UINT32(state, _nLocBoxes); state += 4; // For each location, write out the number of boxes and their status - for (i = 1; i <= m_nLocBoxes; i++) { - WRITE_LE_UINT32(state, m_allBoxes[i]->numbbox); + for (i = 1; i <= _nLocBoxes; i++) { + WRITE_LE_UINT32(state, _allBoxes[i]->numbbox); state += 4; - for (j = 0; j < m_allBoxes[i]->numbbox; j++) - *state++ = m_allBoxes[i]->boxes[j].attivo; + for (j = 0; j < _allBoxes[i]->numbbox; j++) + *state++ = _allBoxes[i]->boxes[j].attivo; } } -void RMGameBoxes::LoadState(byte *state) { +void RMGameBoxes::loadState(byte *state) { int i, j; int nloc, nbox; @@ -1918,7 +1913,7 @@ void RMGameBoxes::LoadState(byte *state) { nloc = READ_LE_UINT32(state); state += 4; - assert(nloc <= m_nLocBoxes); + assert(nloc <= _nLocBoxes); // For each location, read the number of boxes and their status for (i = 1; i <= nloc; i++) { @@ -1926,13 +1921,13 @@ void RMGameBoxes::LoadState(byte *state) { state += 4; for (j = 0; j < nbox ; j++) { - if (j < m_allBoxes[i]->numbbox) - m_allBoxes[i]->boxes[j].attivo = *state; + if (j < _allBoxes[i]->numbbox) + _allBoxes[i]->boxes[j].attivo = *state; state++; } - m_allBoxes[i]->RecalcAllAdj(); + _allBoxes[i]->recalcAllAdj(); } } @@ -1944,9 +1939,9 @@ void RMGameBoxes::LoadState(byte *state) { * Standard constructor */ RMLocation::RMLocation() { - m_nItems = 0; - m_items = NULL; - m_buf = NULL; + _nItems = 0; + _items = NULL; + _buf = NULL; } @@ -1955,7 +1950,7 @@ RMLocation::RMLocation() { * * @param lpszFileName Name of the file */ -bool RMLocation::Load(const char *lpszFileName) { +bool RMLocation::load(const char *lpszFileName) { Common::File f; bool bRet; @@ -1964,7 +1959,7 @@ bool RMLocation::Load(const char *lpszFileName) { return false; // Passes to the method variation for loading from the opened file - bRet = Load(f); + bRet = load(f); // Close the file f.close(); @@ -1980,7 +1975,7 @@ bool RMLocation::Load(const char *lpszFileName) { * * @returns True if succeeded OK, false in case of error. */ -bool RMLocation::Load(Common::File &file) { +bool RMLocation::load(Common::File &file) { int size; bool bRet; @@ -1991,19 +1986,19 @@ bool RMLocation::Load(Common::File &file) { RMFileStreamSlow fs; fs.OpenFile(file); - bRet = Load(fs); + bRet = load(fs); fs.Close(); return bRet; } -bool RMLocation::Load(const byte *buf) { +bool RMLocation::load(const byte *buf) { RMDataStream ds; bool bRet; ds.OpenBuffer(buf); - bRet = Load(ds); + bRet = load(ds); ds.Close(); return bRet; } @@ -2015,7 +2010,7 @@ bool RMLocation::Load(const byte *buf) { * @param ds Data stream * @returns True if succeeded OK, false in case of error. */ -bool RMLocation::Load(RMDataStream &ds) { +bool RMLocation::load(RMDataStream &ds) { char id[3]; int dimx, dimy; byte ver; @@ -2027,7 +2022,7 @@ bool RMLocation::Load(RMDataStream &ds) { // Check if we are in a LOX if (id[0] == 'L' && id[1] == 'O' && id[2] == 'X') - return LoadLOX(ds); + return loadLOX(ds); // Otherwise, check that it is a normal LOC if (id[0] != 'L' || id[1] != 'O' || id[2] != 'C') @@ -2038,7 +2033,7 @@ bool RMLocation::Load(RMDataStream &ds) { assert(ver == 6); // Location name - ds >> m_name; + ds >> _name; // Skip the MPAL bailouts (64 bytes) ds >> TEMPNumLoc; @@ -2050,20 +2045,20 @@ bool RMLocation::Load(RMDataStream &ds) { // Location dimensions ds >> dimx >> dimy; - m_curScroll.Set(0, 0); + _curScroll.Set(0, 0); // Read the colour mode ds >> cm; - m_cmode = (RMColorMode)cm; + _cmode = (RMColorMode)cm; // Initialise the source buffer and read the location - switch (m_cmode) { + switch (_cmode) { case CM_256: - m_buf = new RMGfxSourceBuffer8; + _buf = new RMGfxSourceBuffer8; break; case CM_65K: - m_buf = new RMGfxSourceBuffer16; + _buf = new RMGfxSourceBuffer16; break; default: @@ -2072,29 +2067,29 @@ bool RMLocation::Load(RMDataStream &ds) { }; // Initialise the surface, loading the palette if necessary - m_buf->init(ds, dimx, dimy, true); + _buf->init(ds, dimx, dimy, true); // Check the size of the location // assert(dimy!=512); // Number of objects - ds >> m_nItems; + ds >> _nItems; // Create and read in the objects - if (m_nItems > 0) - m_items = new RMItem[m_nItems]; + if (_nItems > 0) + _items = new RMItem[_nItems]; _vm->freezeTime(); - for (i = 0; i < m_nItems && !ds.IsError(); i++) - ds >> m_items[i]; + for (i = 0; i < _nItems && !ds.IsError(); i++) + ds >> _items[i]; _vm->unfreezeTime(); return ds.IsError(); } -bool RMLocation::LoadLOX(RMDataStream &ds) { +bool RMLocation::loadLOX(RMDataStream &ds) { int dimx, dimy; byte ver; int i; @@ -2104,7 +2099,7 @@ bool RMLocation::LoadLOX(RMDataStream &ds) { assert(ver == 1); // Location name - ds >> m_name; + ds >> _name; // Location number ds >> TEMPNumLoc; @@ -2112,24 +2107,24 @@ bool RMLocation::LoadLOX(RMDataStream &ds) { // Dimensions ds >> dimx >> dimy; - m_curScroll.Set(0, 0); + _curScroll.Set(0, 0); // It's always 65K (16-bit) mode - m_cmode = CM_65K; - m_buf = new RMGfxSourceBuffer16; + _cmode = CM_65K; + _buf = new RMGfxSourceBuffer16; // Initialise the surface, loading in the palette if necessary - m_buf->init(ds, dimx, dimy, true); + _buf->init(ds, dimx, dimy, true); // Number of items - ds >> m_nItems; + ds >> _nItems; // Create and read objects - if (m_nItems > 0) - m_items = new RMItem[m_nItems]; + if (_nItems > 0) + _items = new RMItem[_nItems]; - for (i = 0; i < m_nItems && !ds.IsError(); i++) - m_items[i].ReadFromStream(ds, true); + for (i = 0; i < _nItems && !ds.IsError(); i++) + _items[i].readFromStream(ds, true); return ds.IsError(); } @@ -2145,14 +2140,14 @@ void RMLocation::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri CORO_BEGIN_CODE(_ctx); // Set the position of the source scrolling - if (m_buf->getDimy() > RM_SY || m_buf->getDimx() > RM_SX) { - prim->setSrc(RMRect(m_curScroll, m_curScroll + RMPoint(640, 480))); + if (_buf->getDimy() > RM_SY || _buf->getDimx() > RM_SX) { + prim->setSrc(RMRect(_curScroll, _curScroll + RMPoint(640, 480))); } - prim->setDst(m_fixedScroll); + prim->setDst(_fixedScroll); // Invoke the drawing method fo the image class, which will draw the location background - CORO_INVOKE_2(m_buf->draw, bigBuf, prim); + CORO_INVOKE_2(_buf->draw, bigBuf, prim); CORO_END_CODE; } @@ -2169,29 +2164,29 @@ void RMLocation::doFrame(RMGfxTargetBuffer *bigBuf) { bigBuf->addPrim(new RMGfxPrimitive(this)); // Process all the location items - for (i = 0; i < m_nItems; i++) - m_items[i].doFrame(bigBuf); + for (i = 0; i < _nItems; i++) + _items[i].doFrame(bigBuf); } -RMItem *RMLocation::GetItemFromCode(uint32 dwCode) { +RMItem *RMLocation::getItemFromCode(uint32 dwCode) { int i; - for (i = 0; i < m_nItems; i++) - if (m_items[i].MpalCode() == (int)dwCode) - return &m_items[i]; + for (i = 0; i < _nItems; i++) + if (_items[i].mpalCode() == (int)dwCode) + return &_items[i]; return NULL; } -RMItem *RMLocation::WhichItemIsIn(const RMPoint &pt) { +RMItem *RMLocation::whichItemIsIn(const RMPoint &pt) { int found = -1; int foundSize = 0; int size; - for (int i = 0; i < m_nItems; i++) { + for (int i = 0; i < _nItems; i++) { size = 0; - if (m_items[i].IsIn(pt, &size)) { + if (_items[i].isIn(pt, &size)) { if (found == -1 || size < foundSize) { foundSize = size; found = i; @@ -2202,97 +2197,97 @@ RMItem *RMLocation::WhichItemIsIn(const RMPoint &pt) { if (found == -1) return NULL; else - return &m_items[found]; + return &_items[found]; } RMLocation::~RMLocation() { - Unload(); + unload(); } -void RMLocation::Unload(void) { +void RMLocation::unload(void) { // Clear memory - if (m_items) { - delete[] m_items; - m_items = NULL; + if (_items) { + delete[] _items; + _items = NULL; } // Destroy the buffer - if (m_buf) { - delete m_buf; - m_buf = NULL; + if (_buf) { + delete _buf; + _buf = NULL; } } -void RMLocation::UpdateScrolling(const RMPoint &ptShowThis) { - RMPoint oldScroll = m_curScroll; +void RMLocation::updateScrolling(const RMPoint &ptShowThis) { + RMPoint oldScroll = _curScroll; - if (m_curScroll.x + 250 > ptShowThis.x) { - m_curScroll.x = ptShowThis.x - 250; - } else if (m_curScroll.x + RM_SX - 250 < ptShowThis.x) { - m_curScroll.x = ptShowThis.x + 250 - RM_SX; - } else if (ABS(m_curScroll.x + RM_SX / 2 - ptShowThis.x) > 32 && m_buf->getDimx() > RM_SX) { - if (m_curScroll.x + RM_SX / 2 < ptShowThis.x) - m_curScroll.x++; + if (_curScroll.x + 250 > ptShowThis.x) { + _curScroll.x = ptShowThis.x - 250; + } else if (_curScroll.x + RM_SX - 250 < ptShowThis.x) { + _curScroll.x = ptShowThis.x + 250 - RM_SX; + } else if (ABS(_curScroll.x + RM_SX / 2 - ptShowThis.x) > 32 && _buf->getDimx() > RM_SX) { + if (_curScroll.x + RM_SX / 2 < ptShowThis.x) + _curScroll.x++; else - m_curScroll.x--; + _curScroll.x--; } - if (m_curScroll.y + 180 > ptShowThis.y) { - m_curScroll.y = ptShowThis.y - 180; - } else if (m_curScroll.y + RM_SY - 180 < ptShowThis.y) { - m_curScroll.y = ptShowThis.y + 180 - RM_SY; - } else if (ABS(m_curScroll.y + RM_SY / 2 - ptShowThis.y) > 16 && m_buf->getDimy() > RM_SY) { - if (m_curScroll.y + RM_SY / 2 < ptShowThis.y) - m_curScroll.y++; + if (_curScroll.y + 180 > ptShowThis.y) { + _curScroll.y = ptShowThis.y - 180; + } else if (_curScroll.y + RM_SY - 180 < ptShowThis.y) { + _curScroll.y = ptShowThis.y + 180 - RM_SY; + } else if (ABS(_curScroll.y + RM_SY / 2 - ptShowThis.y) > 16 && _buf->getDimy() > RM_SY) { + if (_curScroll.y + RM_SY / 2 < ptShowThis.y) + _curScroll.y++; else - m_curScroll.y--; + _curScroll.y--; } - if (m_curScroll.x < 0) - m_curScroll.x = 0; - if (m_curScroll.y < 0) - m_curScroll.y = 0; - if (m_curScroll.x + RM_SX > m_buf->getDimx()) - m_curScroll.x = m_buf->getDimx() - RM_SX; - if (m_curScroll.y + RM_SY > m_buf->getDimy()) - m_curScroll.y = m_buf->getDimy() - RM_SY; + if (_curScroll.x < 0) + _curScroll.x = 0; + if (_curScroll.y < 0) + _curScroll.y = 0; + if (_curScroll.x + RM_SX > _buf->getDimx()) + _curScroll.x = _buf->getDimx() - RM_SX; + if (_curScroll.y + RM_SY > _buf->getDimy()) + _curScroll.y = _buf->getDimy() - RM_SY; - if (oldScroll != m_curScroll) - for (int i = 0; i < m_nItems; i++) - m_items[i].SetScrollPosition(m_curScroll); + if (oldScroll != _curScroll) + for (int i = 0; i < _nItems; i++) + _items[i].setScrollPosition(_curScroll); } -void RMLocation::SetFixedScroll(const RMPoint &scroll) { - m_fixedScroll = scroll; +void RMLocation::setFixedScroll(const RMPoint &scroll) { + _fixedScroll = scroll; - for (int i = 0; i < m_nItems; i++) - m_items[i].SetScrollPosition(m_curScroll - m_fixedScroll); + for (int i = 0; i < _nItems; i++) + _items[i].setScrollPosition(_curScroll - _fixedScroll); } -void RMLocation::SetScrollPosition(const RMPoint &scroll) { +void RMLocation::setScrollPosition(const RMPoint &scroll) { RMPoint pt = scroll; if (pt.x < 0) pt.x = 0; if (pt.y < 0) pt.y = 0; - if (pt.x + RM_SX > m_buf->getDimx()) - pt.x = m_buf->getDimx() - RM_SX; - if (pt.y + RM_SY > m_buf->getDimy()) - pt.y = m_buf->getDimy() - RM_SY; + if (pt.x + RM_SX > _buf->getDimx()) + pt.x = _buf->getDimx() - RM_SX; + if (pt.y + RM_SY > _buf->getDimy()) + pt.y = _buf->getDimy() - RM_SY; - m_curScroll = pt; + _curScroll = pt; - for (int i = 0; i < m_nItems; i++) - m_items[i].SetScrollPosition(m_curScroll); + for (int i = 0; i < _nItems; i++) + _items[i].setScrollPosition(_curScroll); } -void RMLocation::PauseSound(bool bPause) { +void RMLocation::pauseSound(bool bPause) { int i; - for (i = 0; i < m_nItems; i++) - m_items[i].PauseSound(bPause); + for (i = 0; i < _nItems; i++) + _items[i].pauseSound(bPause); } @@ -2301,7 +2296,7 @@ void RMLocation::PauseSound(bool bPause) { \****************************************************************************/ RMMessage::RMMessage(uint32 dwId) { - Load(dwId); + load(dwId); } RMMessage::RMMessage() { @@ -2313,15 +2308,15 @@ RMMessage::~RMMessage() { GlobalFree(lpMessage); } -void RMMessage::Load(uint32 dwId) { +void RMMessage::load(uint32 dwId) { lpMessage = mpalQueryMessage(dwId); assert(lpMessage != NULL); if (lpMessage) - ParseMessage(); + parseMessage(); } -void RMMessage::ParseMessage(void) { +void RMMessage::parseMessage(void) { char *p; assert(lpMessage != NULL); diff --git a/engines/tony/loc.h b/engines/tony/loc.h index abcdcb85a2..e465b113b2 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -59,7 +59,7 @@ typedef enum { */ class RMPalette { public: - byte m_data[1024]; + byte _data[1024]; public: friend RMDataStream &operator>>(RMDataStream &ds, RMPalette &pal); @@ -71,9 +71,9 @@ public: */ class RMSfx { public: - RMString m_name; - FPSFX *m_fx; - bool m_bPlayingLoop; + RMString _name; + FPSFX *_fx; + bool _bPlayingLoop; public: RMSfx(); @@ -81,12 +81,12 @@ public: friend RMDataStream &operator>>(RMDataStream &ds, RMSfx &sfx); - void Play(bool bLoop = false); - void SetVolume(int vol); - void Pause(bool bPause); - void Stop(void); + void play(bool bLoop = false); + void setVolume(int vol); + void pause(bool bPause); + void stop(void); - void ReadFromStream(RMDataStream &ds, bool bLOX = false); + void readFromStream(RMDataStream &ds, bool bLOX = false); }; @@ -108,38 +108,38 @@ public: // Class slot class RMSlot { private: - RMPoint m_pos; // Child co-ordinates + RMPoint _pos; // Child co-ordinates public: - RMSlotType m_type; - int m_data; - byte m_flag; + RMSlotType _type; + int _data; + byte _flag; public: friend RMDataStream &operator>>(RMDataStream &ds, RMSlot &slot); - RMPoint Pos() { - return m_pos; + RMPoint pos() { + return _pos; } - void ReadFromStream(RMDataStream &ds, bool bLOX = false); + void readFromStream(RMDataStream &ds, bool bLOX = false); }; public: - RMString m_name; + RMString _name; private: - int m_speed; - RMPoint m_pos; // Parent coordinates - RMPoint m_curPos; // Parent + child coordinates - int m_bLoop; - int m_nSlots; - int m_nCurSlot; - int m_nCurSprite; + int _speed; + RMPoint _pos; // Parent coordinates + RMPoint _curPos; // Parent + child coordinates + int _bLoop; + int _nSlots; + int _nCurSlot; + int _nCurSprite; - RMSlot *m_slots; + RMSlot *_slots; - uint32 m_nStartTime; + uint32 _nStartTime; public: RMPattern(); @@ -148,24 +148,24 @@ public: friend RMDataStream &operator>>(RMDataStream &ds, RMPattern &pat); // A warning that the pattern now and the current - int Init(RMSfx *sfx, bool bPlayP0 = false, byte *bFlag = NULL); + int init(RMSfx *sfx, bool bPlayP0 = false, byte *bFlag = NULL); // Update the pattern, checking to see if it's time to change slot and executing // any associated commands - int Update(uint32 hEndPattern, byte &bFlag, RMSfx *sfx); + int update(uint32 hEndPattern, byte &bFlag, RMSfx *sfx); // Stop a sound effect - void StopSfx(RMSfx *sfx); + void stopSfx(RMSfx *sfx); // Reads the position of the pattern - RMPoint Pos() { - return m_curPos; + RMPoint pos() { + return _curPos; } - void ReadFromStream(RMDataStream &ds, bool bLOX = false); + void readFromStream(RMDataStream &ds, bool bLOX = false); private: - void UpdateCoord(void); + void updateCoord(void); }; @@ -174,24 +174,24 @@ private: */ class RMSprite : public RMGfxTask { public: - RMString m_name; - RMRect m_rcBox; + RMString _name; + RMRect _rcBox; protected: - RMGfxSourceBuffer *m_buf; + RMGfxSourceBuffer *_buf; public: RMSprite(); virtual ~RMSprite(); - void Init(RMGfxSourceBuffer *buf); + void init(RMGfxSourceBuffer *buf); friend RMDataStream &operator>>(RMDataStream &ds, RMSprite &sprite); virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - void SetPalette(byte *lpBuf); - void GetSizeFromStream(RMDataStream &ds, int *dimx, int *dimy); + void setPalette(byte *lpBuf); + void getSizeFromStream(RMDataStream &ds, int *dimx, int *dimy); void LOXGetSizeFromStream(RMDataStream &ds, int *dimx, int *dimy); - void ReadFromStream(RMDataStream &ds, bool bLOX = false); + void readFromStream(RMDataStream &ds, bool bLOX = false); }; @@ -200,42 +200,42 @@ public: */ class RMItem : public RMGfxTask { public: - RMString m_name; + RMString _name; protected: - int m_z; - RMPoint m_pos; // Coordinate nonno - RMColorMode m_cm; - RMPoint m_curScroll; + int _z; + RMPoint _pos; // Coordinate nonno + RMColorMode _cm; + RMPoint _curScroll; - byte m_FX; - byte m_FXparm; + byte _FX; + byte _FXparm; - virtual int GetCurPattern() { - return m_nCurPattern; + virtual int getCurPattern() { + return _nCurPattern; } private: - int m_nCurPattern; - int m_mpalCode; - RMPoint m_hot; - RMRect m_rcBox; - int m_nSprites, m_nSfx, m_nPatterns; - byte m_bPal; - RMPalette m_pal; - - RMSprite *m_sprites; - RMSfx *m_sfx; - RMPattern *m_patterns; - - byte m_bCurFlag; - int m_nCurSprite; - bool m_bIsActive; - uint32 m_hEndPattern; - bool m_bInitCurPattern; + int _nCurPattern; + int _mpalCode; + RMPoint _hot; + RMRect _rcBox; + int _nSprites, _nSfx, _nPatterns; + byte _bPal; + RMPalette _pal; + + RMSprite *_sprites; + RMSfx *_sfx; + RMPattern *_patterns; + + byte _bCurFlag; + int _nCurSprite; + bool _bIsActive; + uint32 _hEndPattern; + bool _bInitCurPattern; public: - RMPoint CalculatePos(void); + RMPoint calculatePos(void); public: RMItem(); @@ -248,7 +248,7 @@ public: bool doFrame(RMGfxTargetBuffer *bigBuf, bool bAddToList = true); // Sets the current scrolling position - void SetScrollPosition(const RMPoint &scroll); + void setScrollPosition(const RMPoint &scroll); // Overloading of check whether to remove from active list virtual void removeThis(CORO_PARAM, bool &result); @@ -258,54 +258,54 @@ public: // Overloaded priority: it's based on Z ordering virtual int priority() { - return m_z; + return _z; } // Pattern number - int NumPattern() { - return m_nPatterns; + int numPattern() { + return _nPatterns; } // Set anew animation pattern, changing abruptly from the current - virtual void SetPattern(int nPattern, bool bPlayP0 = false); + virtual void setPattern(int nPattern, bool bPlayP0 = false); // Set a new status - void SetStatus(int nStatus); + void setStatus(int nStatus); - bool IsIn(const RMPoint &pt, int *size = NULL); - RMPoint Hotspot() { - return m_hot; + bool isIn(const RMPoint &pt, int *size = NULL); + RMPoint hotspot() { + return _hot; } - bool GetName(RMString &name); - int MpalCode() { - return m_mpalCode; + bool getName(RMString &name); + int mpalCode() { + return _mpalCode; } // Unload - void Unload(void); + void unload(void); // Wait for the end of the current pattern - void WaitForEndPattern(CORO_PARAM, uint32 hCustomSkip = CORO_INVALID_PID_VALUE); + void waitForEndPattern(CORO_PARAM, uint32 hCustomSkip = CORO_INVALID_PID_VALUE); // Sets a new hotspot fro the object - void ChangeHotspot(const RMPoint &pt); + void changeHotspot(const RMPoint &pt); - void SetInitCurPattern(bool status) { - m_bInitCurPattern = status; + void setInitCurPattern(bool status) { + _bInitCurPattern = status; } - void PlaySfx(int nSfx); + void playSfx(int nSfx); - void ReadFromStream(RMDataStream &ds, bool bLOX = false); + void readFromStream(RMDataStream &ds, bool bLOX = false); - void PauseSound(bool bPause); + void pauseSound(bool bPause); protected: // Create a primitive that has as it's task this item - virtual RMGfxPrimitive *NewItemPrimitive(); + virtual RMGfxPrimitive *newItemPrimitive(); // Allocate memory for the sprites - virtual RMGfxSourceBuffer *NewItemSpriteBuffer(int dimx, int dimy, bool bPreRLE); + virtual RMGfxSourceBuffer *newItemSpriteBuffer(int dimx, int dimy, bool bPreRLE); }; @@ -330,7 +330,7 @@ public: bool bReversed; private: - void ReadFromStream(RMDataStream &ds); + void readFromStream(RMDataStream &ds); public: friend RMDataStream &operator>>(RMDataStream &ds, RMBox &box); @@ -343,47 +343,47 @@ public: RMBox *boxes; private: - void ReadFromStream(RMDataStream &ds); + void readFromStream(RMDataStream &ds); public: RMBoxLoc(); virtual ~RMBoxLoc(); friend RMDataStream &operator >>(RMDataStream &ds, RMBoxLoc &bl); - void RecalcAllAdj(void); + void recalcAllAdj(void); }; #define GAME_BOXES_SIZE 200 class RMGameBoxes { protected: - RMBoxLoc *m_allBoxes[GAME_BOXES_SIZE]; - int m_nLocBoxes; + RMBoxLoc *_allBoxes[GAME_BOXES_SIZE]; + int _nLocBoxes; public: RMGameBoxes(); ~RMGameBoxes(); - void Init(void); - void Close(void); + void init(void); + void close(void); // Get binding boxes for a given location - RMBoxLoc *GetBoxes(int nLoc); - int GetLocBoxesCount() const { return m_nLocBoxes; } + RMBoxLoc *getBoxes(int nLoc); + int getLocBoxesCount() const { return _nLocBoxes; } // Return the box which contains a given point - int WhichBox(int nLoc, const RMPoint &pt); + int whichBox(int nLoc, const RMPoint &pt); // Check whether a point is inside a given box - bool IsInBox(int nLoc, int nBox, const RMPoint &pt); + bool isInBox(int nLoc, int nBox, const RMPoint &pt); // Change the status of a box - void ChangeBoxStatus(int nLoc, int nBox, int status); + void changeBoxStatus(int nLoc, int nBox, int status); // Save state handling - int GetSaveStateSize(void); - void SaveState(byte *buf); - void LoadState(byte *buf); + int getSaveStateSize(void); + void saveState(byte *buf); + void loadState(byte *buf); }; class RMCharacter : protected RMItem { @@ -426,21 +426,21 @@ private: bool bMovingWithoutMinpath; RMGameBoxes *theBoxes; - RMPoint m_fixedScroll; + RMPoint _fixedScroll; private: - int InWhichBox(const RMPoint &pt); + int inWhichBox(const RMPoint &pt); - short FindPath(short source, short destination); - RMPoint Searching(char UP, char DOWN, char RIGHT, char LEFT, RMPoint punto); - RMPoint NearestPoint(const RMPoint &punto); + short findPath(short source, short destination); + RMPoint searching(char UP, char DOWN, char RIGHT, char LEFT, RMPoint punto); + RMPoint nearestPoint(const RMPoint &punto); - void GoTo(CORO_PARAM, RMPoint destcoord, bool bReversed = false); - short ScanLine(const RMPoint &punto); - RMPoint InvScanLine(const RMPoint &punto); - RMPoint NearestHotSpot(int sourcebox, int destbox); + void goTo(CORO_PARAM, RMPoint destcoord, bool bReversed = false); + short scanLine(const RMPoint &punto); + RMPoint invScanLine(const RMPoint &punto); + RMPoint nearestHotSpot(int sourcebox, int destbox); - void NewBoxEntered(int nBox); + void newBoxEntered(int nBox); protected: bool bMoving; @@ -452,42 +452,42 @@ public: RMCharacter(); virtual ~RMCharacter(); - void LinkToBoxes(RMGameBoxes *theBoxes); + void linkToBoxes(RMGameBoxes *theBoxes); virtual void removeThis(CORO_PARAM, bool &result); // Update the position of a character - void DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc); + void doFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc); // Overloaded draw virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // TRUE if you just stopped - bool EndOfPath() { + bool endOfPath() { return bEndOfPath; } // Change the pattern of a character to STOP - virtual void Stop(CORO_PARAM); + virtual void stop(CORO_PARAM); // Check if the character is moving - bool IsMoving() { + bool isMoving() { return bMoving; } // Move the character to a certain position - void Move(CORO_PARAM, RMPoint pt, bool *result = NULL); + void move(CORO_PARAM, RMPoint pt, bool *result = NULL); // Place the character in a certain position WITHOUT moving - void SetPosition(const RMPoint &pt, int newloc = -1); + void setPosition(const RMPoint &pt, int newloc = -1); // Wait for the end of movement - void WaitForEndMovement(CORO_PARAM); + void waitForEndMovement(CORO_PARAM); - void SetFixedScroll(const RMPoint &fix) { - m_fixedScroll = fix; + void setFixedScroll(const RMPoint &fix) { + _fixedScroll = fix; } - void SetSpeed(int speed) { + void setSpeed(int speed) { curSpeed = speed; } }; @@ -495,26 +495,26 @@ public: class RMWipe : public RMGfxTask { private: - bool m_bFading; - bool m_bEndFade; - bool m_bUnregister; - uint32 m_hUnregistered; - int m_nFadeStep; - uint32 m_hEndOfFade; - bool m_bMustRegister; + bool _bFading; + bool _bEndFade; + bool _bUnregister; + uint32 _hUnregistered; + int _nFadeStep; + uint32 _hEndOfFade; + bool _bMustRegister; - RMItem m_wip0r; + RMItem _wip0r; public: RMWipe(); virtual ~RMWipe(); - void DoFrame(RMGfxTargetBuffer &bigBuf); + void doFrame(RMGfxTargetBuffer &bigBuf); virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - void InitFade(int type); - void CloseFade(void); - void WaitForFadeEnd(CORO_PARAM); + void initFade(int type); + void closeFade(void); + void waitForFadeEnd(CORO_PARAM); virtual void Unregister(void); virtual void removeThis(CORO_PARAM, bool &result); @@ -527,17 +527,17 @@ public: */ class RMLocation : public RMGfxTaskSetPrior { public: - RMString m_name; // Name + RMString _name; // Name private: - RMColorMode m_cmode; // Color mode - RMGfxSourceBuffer *m_buf; // Location picture + RMColorMode _cmode; // Color mode + RMGfxSourceBuffer *_buf; // Location picture - int m_nItems; // Number of objects - RMItem *m_items; // Objects + int _nItems; // Number of objects + RMItem *_items; // Objects - RMPoint m_curScroll; // Current scroll position - RMPoint m_fixedScroll; + RMPoint _curScroll; // Current scroll position + RMPoint _fixedScroll; public: // @@@@@@@@@@@@@@@@@@@@@@@ @@ -556,14 +556,14 @@ public: virtual ~RMLocation(); // Load variations - bool Load(const char *lpszFileName); - bool Load(Common::File &file); - bool Load(const byte *buf); - bool Load(RMDataStream &ds); - bool LoadLOX(RMDataStream &ds); + bool load(const char *lpszFileName); + bool load(Common::File &file); + bool load(const byte *buf); + bool load(RMDataStream &ds); + bool loadLOX(RMDataStream &ds); // Unload - void Unload(void); + void unload(void); // Overloaded draw virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); @@ -572,27 +572,27 @@ public: void doFrame(RMGfxTargetBuffer *bigBuf); // Return the item at a given point - RMItem *WhichItemIsIn(const RMPoint &pt); + RMItem *whichItemIsIn(const RMPoint &pt); // Return the item based on it's MPAL code - RMItem *GetItemFromCode(uint32 dwCode); + RMItem *getItemFromCode(uint32 dwCode); // Set the current scroll position - void SetScrollPosition(const RMPoint &scroll); + void setScrollPosition(const RMPoint &scroll); // Sets an additinal offset for scrolling - void SetFixedScroll(const RMPoint &scroll); + void setFixedScroll(const RMPoint &scroll); // Update the scrolling coordinates to display the specified point - void UpdateScrolling(const RMPoint &ptShowThis); + void updateScrolling(const RMPoint &ptShowThis); // Read the current scroll position - RMPoint ScrollPosition() { - return m_curScroll; + RMPoint scrollPosition() { + return _curScroll; } // Pause sound - void PauseSound(bool bPause); + void pauseSound(bool bPause); }; @@ -606,21 +606,21 @@ private: int nPeriods; private: - void ParseMessage(void); + void parseMessage(void); public: RMMessage(); RMMessage(uint32 dwId); virtual ~RMMessage(); - void Load(uint32 dwId); - bool IsValid() { + void load(uint32 dwId); + bool isValid() { return lpMessage != NULL; } - int NumPeriods() { + int numPeriods() { return nPeriods; } - char *Period(int num) { + char *period(int num) { return lpPeriods[num]; } char *operator[](int num) { diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index ea378e0fc3..abc3033993 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -137,7 +137,7 @@ Common::ErrorCode TonyEngine::init() { return Common::kReadingFailed; // Initialise the boxes - _theBoxes.Init(); + _theBoxes.init(); // Link to the custom graphics engine _theEngine.initCustomDll(); @@ -568,7 +568,7 @@ void TonyEngine::play(void) { void TonyEngine::close(void) { closeMusic(); CoroScheduler.closeEvent(_hEndOfFrame); - _theBoxes.Close(); + _theBoxes.close(); _theEngine.close(); _window.close(); delete[] _curThumbnail; diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index 8bca6fe7f6..dc771b08aa 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -38,31 +38,31 @@ namespace Tony { * Metodi di RMTony \****************************************************************************/ -bool RMTony::m_bAction = false; +bool RMTony::_bAction = false; void RMTony::initStatics() { - m_bAction = false; + _bAction = false; } RMTony::RMTony() { - m_bShow = false; - m_bShowOmbra = false; - m_bCorpoDavanti = false; - m_bActionPending = false; - m_ActionItem = NULL; - m_Action = 0; - m_ActionParm = 0; - m_bPastorella = false; - m_bIsStaticTalk = false; - m_bIsTalking = false; - m_nPatB4Talking = 0; - m_nTalkType = TALK_NORMAL; - m_TalkDirection = UP; - m_nTimeLastStep = 0; + _bShow = false; + _bShowOmbra = false; + _bCorpoDavanti = false; + _bActionPending = false; + _ActionItem = NULL; + _Action = 0; + _ActionParm = 0; + _bPastorella = false; + _bIsStaticTalk = false; + _bIsTalking = false; + _nPatB4Talking = 0; + _nTalkType = TALK_NORMAL; + _TalkDirection = UP; + _nTimeLastStep = 0; hActionThread = CORO_INVALID_PID_VALUE; } -void RMTony::WaitEndOfAction(CORO_PARAM, const void *param) { +void RMTony::waitEndOfAction(CORO_PARAM, const void *param) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); @@ -72,15 +72,15 @@ void RMTony::WaitEndOfAction(CORO_PARAM, const void *param) { CORO_INVOKE_2(CoroScheduler.waitForSingleObject, pid, CORO_INFINITE); - m_bAction = false; + _bAction = false; CORO_END_CODE; } -RMGfxSourceBuffer *RMTony::NewItemSpriteBuffer(int dimx, int dimy, bool bPreRLE) { +RMGfxSourceBuffer *RMTony::newItemSpriteBuffer(int dimx, int dimy, bool bPreRLE) { RMGfxSourceBuffer8RLE *spr; - assert(m_cm == CM_256); + assert(_cm == CM_256); spr = new RMGfxSourceBuffer8RLEByteAA; spr->setAlphaBlendColor(1); if (bPreRLE) @@ -94,81 +94,80 @@ void RMTony::init(void) { RMDataStream ds; // Tony is shown by default - m_bShow = m_bShowOmbra = true; + _bShow = _bShowOmbra = true; // No action pending - m_bActionPending = false; - m_bAction = false; + _bActionPending = false; + _bAction = false; - m_bPastorella = false; - m_bIsTalking = false; - m_bIsStaticTalk = false; + _bPastorella = false; + _bIsTalking = false; + _bIsStaticTalk = false; // Opens the buffer ds.OpenBuffer(tony); // Reads his details from the stream - ReadFromStream(ds, true); + readFromStream(ds, true); // Closes the buffer ds.Close(); // Reads Tony's body ds.OpenBuffer(body); - m_body.ReadFromStream(ds, true); + _body.readFromStream(ds, true); ds.Close(); - m_body.SetPattern(0); + _body.setPattern(0); - m_nTimeLastStep = _vm->getTime(); + _nTimeLastStep = _vm->getTime(); } -void RMTony::Close(void) { +void RMTony::close(void) { // Disalloca @@@ Deallocation of missing item - m_ombra.destroy(); + _ombra.destroy(); } -void RMTony::DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int curLoc) { +void RMTony::doFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int curLoc) { CORO_BEGIN_CONTEXT; int time; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - if (!_nInList && m_bShow) + if (!_nInList && _bShow) bigBuf->addPrim(new RMGfxPrimitive(this)); - SetSpeed(GLOBALS.nCfgTonySpeed); + setSpeed(GLOBALS.nCfgTonySpeed); // Runs the normal character movement _ctx->time = _vm->getTime(); do { - m_nTimeLastStep += (1000 / 40); - CORO_INVOKE_2(RMCharacter::DoFrame, bigBuf, curLoc); - - } while (_ctx->time > m_nTimeLastStep + (1000 / 40)); + _nTimeLastStep += (1000 / 40); + CORO_INVOKE_2(RMCharacter::doFrame, bigBuf, curLoc); + } while (_ctx->time > _nTimeLastStep + (1000 / 40)); // Check if we are at the end of a path - if (EndOfPath() && m_bActionPending) { + if (endOfPath() && _bActionPending) { // Must perform the action on which we clicked - m_bActionPending = false; + _bActionPending = false; } - if (m_bIsTalking || m_bIsStaticTalk) - m_body.doFrame(bigBuf, false); + if (_bIsTalking || _bIsStaticTalk) + _body.doFrame(bigBuf, false); CORO_END_CODE; } -void RMTony::Show(void) { - m_bShow = true; - m_bShowOmbra = true; +void RMTony::show(void) { + _bShow = true; + _bShowOmbra = true; } -void RMTony::Hide(bool bShowOmbra) { - m_bShow = false; - m_bShowOmbra = bShowOmbra; +void RMTony::hide(bool bShowOmbra) { + _bShow = false; + _bShowOmbra = bShowOmbra; } @@ -179,29 +178,29 @@ void RMTony::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CODE(_ctx); // Call the Draw() of the parent class if Tony is visible - if (m_bShow && bDrawNow) { - if (m_bCorpoDavanti) { + if (_bShow && bDrawNow) { + if (_bCorpoDavanti) { prim->Dst().SetEmpty(); prim->Dst().Offset(-44, -134); - if (m_bPastorella) + if (_bPastorella) prim->Dst().Offset(1, 4); CORO_INVOKE_2(RMCharacter::draw, bigBuf, prim); } - if (m_bIsTalking || m_bIsStaticTalk) { + if (_bIsTalking || _bIsStaticTalk) { // Offest direction from scrolling prim->Dst().SetEmpty(); - prim->Dst().Offset(-m_curScroll); - prim->Dst().Offset(m_pos); + prim->Dst().Offset(-_curScroll); + prim->Dst().Offset(_pos); prim->Dst().Offset(-44, -134); - prim->Dst() += m_nBodyOffset; - CORO_INVOKE_2(m_body.draw, bigBuf, prim); + prim->Dst() += _nBodyOffset; + CORO_INVOKE_2(_body.draw, bigBuf, prim); } - if (!m_bCorpoDavanti) { + if (!_bCorpoDavanti) { prim->Dst().SetEmpty(); prim->Dst().Offset(-44, -134); - if (m_bPastorella) + if (_bPastorella) prim->Dst().Offset(0, 3); CORO_INVOKE_2(RMCharacter::draw, bigBuf, prim); } @@ -210,7 +209,7 @@ void RMTony::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_END_CODE; } -void RMTony::MoveAndDoAction(CORO_PARAM, RMPoint dst, RMItem *item, int nAction, int nActionParm) { +void RMTony::moveAndDoAction(CORO_PARAM, RMPoint dst, RMItem *item, int nAction, int nActionParm) { CORO_BEGIN_CONTEXT; bool result; CORO_END_CONTEXT(_ctx); @@ -219,26 +218,26 @@ void RMTony::MoveAndDoAction(CORO_PARAM, RMPoint dst, RMItem *item, int nAction, // Makes normal movement, but remember if you must then perform an action if (item == NULL) { - m_bActionPending = false; - m_ActionItem = NULL; + _bActionPending = false; + _ActionItem = NULL; } else { - m_ActionItem = item; - m_Action = nAction; - m_ActionParm = nActionParm; - m_bActionPending = true; + _ActionItem = item; + _Action = nAction; + _ActionParm = nActionParm; + _bActionPending = true; } - CORO_INVOKE_2(RMCharacter::Move, dst, &_ctx->result); + CORO_INVOKE_2(RMCharacter::move, dst, &_ctx->result); if (!_ctx->result) { - m_bActionPending = false; - m_ActionItem = NULL; + _bActionPending = false; + _ActionItem = NULL; } CORO_END_CODE; } -void RMTony::ExecuteAction(int nAction, int nActionItem, int nParm) { +void RMTony::executeAction(int nAction, int nActionItem, int nParm) { uint32 pid; if (nAction == TA_COMBINE) { @@ -264,85 +263,85 @@ void RMTony::ExecuteAction(int nAction, int nActionItem, int nParm) { } if (pid != CORO_INVALID_PID_VALUE) { - m_bAction = true; - CoroScheduler.createProcess(WaitEndOfAction, &pid, sizeof(uint32)); + _bAction = true; + CoroScheduler.createProcess(waitEndOfAction, &pid, sizeof(uint32)); hActionThread = pid; } else if (nAction != TA_GOTO) { if (nAction == TA_TALK) { pid = mpalQueryDoAction(6, 1, 0); - m_bAction = true; - CoroScheduler.createProcess(WaitEndOfAction, &pid, sizeof(uint32)); + _bAction = true; + CoroScheduler.createProcess(waitEndOfAction, &pid, sizeof(uint32)); hActionThread = pid; } else if (nAction == TA_PALESATI) { pid = mpalQueryDoAction(7, 1, 0); - m_bAction = true; - CoroScheduler.createProcess(WaitEndOfAction, &pid, sizeof(uint32)); + _bAction = true; + CoroScheduler.createProcess(waitEndOfAction, &pid, sizeof(uint32)); hActionThread = pid; } else { pid = mpalQueryDoAction(5, 1, 0); - m_bAction = true; - CoroScheduler.createProcess(WaitEndOfAction, &pid, sizeof(uint32)); + _bAction = true; + CoroScheduler.createProcess(waitEndOfAction, &pid, sizeof(uint32)); hActionThread = pid; } } } -void RMTony::StopNoAction(CORO_PARAM) { +void RMTony::stopNoAction(CORO_PARAM) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - if (m_bAction) + if (_bAction) CORO_INVOKE_2(CoroScheduler.waitForSingleObject, hActionThread, CORO_INFINITE); - m_bActionPending = false; - m_ActionItem = NULL; - CORO_INVOKE_0(Stop); + _bActionPending = false; + _ActionItem = NULL; + CORO_INVOKE_0(stop); CORO_END_CODE; } -void RMTony::Stop(CORO_PARAM) { +void RMTony::stop(CORO_PARAM) { CORO_BEGIN_CONTEXT; uint32 pid; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - if (m_ActionItem != NULL) { + if (_ActionItem != NULL) { // Call MPAL to choose the direction - _ctx->pid = mpalQueryDoAction(21, m_ActionItem->MpalCode(), 0); + _ctx->pid = mpalQueryDoAction(21, _ActionItem->mpalCode(), 0); if (_ctx->pid == CORO_INVALID_PID_VALUE) - CORO_INVOKE_0(RMCharacter::Stop); + CORO_INVOKE_0(RMCharacter::stop); else { bNeedToStop = false; // If we make the OnWhichDirection, we don't need at least after the Stop(). bMoving = false; CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->pid, CORO_INFINITE); // @@@ Put an assert after 10 seconds } } else { - CORO_INVOKE_0(RMCharacter::Stop); + CORO_INVOKE_0(RMCharacter::stop); } - if (!m_bActionPending) + if (!_bActionPending) return; - m_bActionPending = false; + _bActionPending = false; - ExecuteAction(m_Action, m_ActionItem->MpalCode(), m_ActionParm); + executeAction(_Action, _ActionItem->mpalCode(), _ActionParm); - m_ActionItem = NULL; + _ActionItem = NULL; CORO_END_CODE; } -int RMTony::GetCurPattern(void) { - int nPatt = RMCharacter::GetCurPattern(); +int RMTony::getCurPattern(void) { + int nPatt = RMCharacter::getCurPattern(); - if (!m_bPastorella) + if (!_bPastorella) return nPatt; switch (nPatt) { @@ -367,8 +366,8 @@ int RMTony::GetCurPattern(void) { return nPatt; } -void RMTony::SetPattern(int nPatt, bool bPlayP0) { - if (m_bPastorella) { +void RMTony::setPattern(int nPatt, bool bPlayP0) { + if (_bPastorella) { switch (nPatt) { case PAT_STANDUP: nPatt = PAT_PAST_STANDUP; @@ -397,13 +396,13 @@ void RMTony::SetPattern(int nPatt, bool bPlayP0) { } } - RMCharacter::SetPattern(nPatt, bPlayP0); + RMCharacter::setPattern(nPatt, bPlayP0); } -void RMTony::Take(int nWhere, int nPart) { +void RMTony::take(int nWhere, int nPart) { if (nPart == 0) { - switch (GetCurPattern()) { + switch (getCurPattern()) { case PAT_STANDDOWN: assert(0); // Not while you're doing a StandDown break; @@ -411,13 +410,13 @@ void RMTony::Take(int nWhere, int nPart) { case PAT_STANDUP: switch (nWhere) { case 0: - SetPattern(PAT_TAKEUP_UP1); + setPattern(PAT_TAKEUP_UP1); break; case 1: - SetPattern(PAT_TAKEUP_MID1); + setPattern(PAT_TAKEUP_MID1); break; case 2: - SetPattern(PAT_TAKEUP_DOWN1); + setPattern(PAT_TAKEUP_DOWN1); break; } break; @@ -425,13 +424,13 @@ void RMTony::Take(int nWhere, int nPart) { case PAT_STANDRIGHT: switch (nWhere) { case 0: - SetPattern(PAT_TAKERIGHT_UP1); + setPattern(PAT_TAKERIGHT_UP1); break; case 1: - SetPattern(PAT_TAKERIGHT_MID1); + setPattern(PAT_TAKERIGHT_MID1); break; case 2: - SetPattern(PAT_TAKERIGHT_DOWN1); + setPattern(PAT_TAKERIGHT_DOWN1); break; } break; @@ -439,46 +438,46 @@ void RMTony::Take(int nWhere, int nPart) { case PAT_STANDLEFT: switch (nWhere) { case 0: - SetPattern(PAT_TAKELEFT_UP1); + setPattern(PAT_TAKELEFT_UP1); break; case 1: - SetPattern(PAT_TAKELEFT_MID1); + setPattern(PAT_TAKELEFT_MID1); break; case 2: - SetPattern(PAT_TAKELEFT_DOWN1); + setPattern(PAT_TAKELEFT_DOWN1); break; } break; } } else if (nPart == 1) { - SetPattern(GetCurPattern() + 1); + setPattern(getCurPattern() + 1); } else if (nPart == 2) { - switch (GetCurPattern()) { + switch (getCurPattern()) { case PAT_TAKEUP_UP2: case PAT_TAKEUP_MID2: case PAT_TAKEUP_DOWN2: - SetPattern(PAT_STANDUP); + setPattern(PAT_STANDUP); break; case PAT_TAKELEFT_UP2: case PAT_TAKELEFT_MID2: case PAT_TAKELEFT_DOWN2: - SetPattern(PAT_STANDLEFT); + setPattern(PAT_STANDLEFT); break; case PAT_TAKERIGHT_UP2: case PAT_TAKERIGHT_MID2: case PAT_TAKERIGHT_DOWN2: - SetPattern(PAT_STANDRIGHT); + setPattern(PAT_STANDRIGHT); break; } } } -void RMTony::Put(int nWhere, int nPart) { +void RMTony::put(int nWhere, int nPart) { if (nPart == 0) { - switch (GetCurPattern()) { + switch (getCurPattern()) { case PAT_STANDDOWN: //assert(0); break; @@ -486,13 +485,13 @@ void RMTony::Put(int nWhere, int nPart) { case PAT_STANDUP: switch (nWhere) { case 0: - SetPattern(PAT_PUTUP_UP1); + setPattern(PAT_PUTUP_UP1); break; case 1: - SetPattern(PAT_PUTUP_MID1); + setPattern(PAT_PUTUP_MID1); break; case 2: - SetPattern(PAT_PUTUP_DOWN1); + setPattern(PAT_PUTUP_DOWN1); break; } break; @@ -500,13 +499,13 @@ void RMTony::Put(int nWhere, int nPart) { case PAT_STANDRIGHT: switch (nWhere) { case 0: - SetPattern(PAT_PUTRIGHT_UP1); + setPattern(PAT_PUTRIGHT_UP1); break; case 1: - SetPattern(PAT_PUTRIGHT_MID1); + setPattern(PAT_PUTRIGHT_MID1); break; case 2: - SetPattern(PAT_PUTRIGHT_DOWN1); + setPattern(PAT_PUTRIGHT_DOWN1); break; } break; @@ -514,56 +513,56 @@ void RMTony::Put(int nWhere, int nPart) { case PAT_STANDLEFT: switch (nWhere) { case 0: - SetPattern(PAT_PUTLEFT_UP1); + setPattern(PAT_PUTLEFT_UP1); break; case 1: - SetPattern(PAT_PUTLEFT_MID1); + setPattern(PAT_PUTLEFT_MID1); break; case 2: - SetPattern(PAT_PUTLEFT_DOWN1); + setPattern(PAT_PUTLEFT_DOWN1); break; } break; } } else if (nPart == 1) { - SetPattern(GetCurPattern() + 1); + setPattern(getCurPattern() + 1); } else if (nPart == 2) { - switch (GetCurPattern()) { + switch (getCurPattern()) { case PAT_PUTUP_UP2: case PAT_PUTUP_MID2: case PAT_PUTUP_DOWN2: - SetPattern(PAT_STANDUP); + setPattern(PAT_STANDUP); break; case PAT_PUTLEFT_UP2: case PAT_PUTLEFT_MID2: case PAT_PUTLEFT_DOWN2: - SetPattern(PAT_STANDLEFT); + setPattern(PAT_STANDLEFT); break; case PAT_PUTRIGHT_UP2: case PAT_PUTRIGHT_MID2: case PAT_PUTRIGHT_DOWN2: - SetPattern(PAT_STANDRIGHT); + setPattern(PAT_STANDRIGHT); break; } } } -bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &bodyStartPat, +bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &bodyStartPat, int &headLoopPat, int &bodyLoopPat) { - assert(!m_bIsTalking); + assert(!_bIsTalking); - m_bIsTalking = true; - m_nPatB4Talking = GetCurPattern(); - m_nTalkType = nTalkType; + _bIsTalking = true; + _nPatB4Talking = getCurPattern(); + _nTalkType = nTalkType; // Set the direction of speech ONLY if we are not in a static animation (since it would have already been done) - if (!m_bIsStaticTalk) { - switch (m_nPatB4Talking) { + if (!_bIsStaticTalk) { + switch (_nPatB4Talking) { case PAT_STANDDOWN: - m_TalkDirection = DOWN; + _TalkDirection = DOWN; break; case PAT_TAKELEFT_UP2: @@ -571,7 +570,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case PAT_TAKELEFT_DOWN2: case PAT_SIRIALZALEFT: case PAT_STANDLEFT: - m_TalkDirection = LEFT; + _TalkDirection = LEFT; break; case PAT_TAKERIGHT_UP2: @@ -579,39 +578,39 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case PAT_TAKERIGHT_DOWN2: case PAT_SIRIALZARIGHT: case PAT_STANDRIGHT: - m_TalkDirection = RIGHT; + _TalkDirection = RIGHT; break; case PAT_TAKEUP_UP2: case PAT_TAKEUP_MID2: case PAT_TAKEUP_DOWN2: case PAT_STANDUP: - m_TalkDirection = UP; + _TalkDirection = UP; break; } // Puts the body in front by default - m_bCorpoDavanti = true; + _bCorpoDavanti = true; } - if (m_bPastorella) { + if (_bPastorella) { // Talking whilst a shepherdess mainFreeze(); - switch (m_TalkDirection) { + switch (_TalkDirection) { case UP: - SetPattern(PAT_PAST_TALKUP); + setPattern(PAT_PAST_TALKUP); break; case DOWN: - SetPattern(PAT_PAST_TALKDOWN); + setPattern(PAT_PAST_TALKDOWN); break; case LEFT: - SetPattern(PAT_PAST_TALKLEFT); + setPattern(PAT_PAST_TALKLEFT); break; case RIGHT: - SetPattern(PAT_PAST_TALKRIGHT); + setPattern(PAT_PAST_TALKRIGHT); break; } mainUnfreeze(); @@ -623,42 +622,42 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body switch (nTalkType) { case TALK_NORMAL: - m_bCorpoDavanti = false; + _bCorpoDavanti = false; headStartPat = 0; bodyStartPat = 0; - switch (m_TalkDirection) { + switch (_TalkDirection) { case DOWN: headLoopPat = PAT_TALK_DOWN; bodyLoopPat = BPAT_STANDDOWN; - m_nBodyOffset.Set(4, 53); + _nBodyOffset.Set(4, 53); break; case LEFT: headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_STANDLEFT; - m_nBodyOffset.Set(6, 56); + _nBodyOffset.Set(6, 56); break; case RIGHT: headLoopPat = PAT_TALK_RIGHT; bodyLoopPat = BPAT_STANDRIGHT; - m_nBodyOffset.Set(6, 56); + _nBodyOffset.Set(6, 56); break; case UP: headLoopPat = PAT_TALK_UP; bodyLoopPat = BPAT_STANDUP; - m_nBodyOffset.Set(6, 53); + _nBodyOffset.Set(6, 53); break; } break; case TALK_FIANCHI: - m_bCorpoDavanti = false; - switch (m_TalkDirection) { + _bCorpoDavanti = false; + switch (_TalkDirection) { case UP: - m_nBodyOffset.Set(2, 42); + _nBodyOffset.Set(2, 42); headStartPat = PAT_TESTA_UP; bodyStartPat = BPAT_FIANCHIUP_START; headLoopPat = PAT_TALK_UP; @@ -666,7 +665,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case DOWN: - m_nBodyOffset.Set(2, 48); + _nBodyOffset.Set(2, 48); headStartPat = PAT_TESTA_DOWN; bodyStartPat = BPAT_FIANCHIDOWN_START; headLoopPat = PAT_TALK_DOWN; @@ -674,7 +673,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case LEFT: - m_nBodyOffset.Set(-3, 53); + _nBodyOffset.Set(-3, 53); headStartPat = PAT_TESTA_LEFT; bodyStartPat = BPAT_FIANCHILEFT_START; headLoopPat = PAT_TALK_LEFT; @@ -682,7 +681,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case RIGHT: - m_nBodyOffset.Set(2, 53); + _nBodyOffset.Set(2, 53); headStartPat = PAT_TESTA_RIGHT; bodyStartPat = BPAT_FIANCHIRIGHT_START; headLoopPat = PAT_TALK_RIGHT; @@ -693,7 +692,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case TALK_CANTA: - m_nBodyOffset.Set(-10, 25); + _nBodyOffset.Set(-10, 25); headStartPat = PAT_TESTA_LEFT; bodyStartPat = BPAT_CANTALEFT_START; headLoopPat = PAT_TALK_LEFT; @@ -701,12 +700,12 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case TALK_RIDE: - m_bCorpoDavanti = false; - switch (m_TalkDirection) { + _bCorpoDavanti = false; + switch (_TalkDirection) { case UP: case DOWN: case LEFT: - m_nBodyOffset.Set(6, 56); + _nBodyOffset.Set(6, 56); headStartPat = PAT_RIDELEFT_START; bodyStartPat = BPAT_STANDLEFT; headLoopPat = PAT_RIDELEFT_LOOP; @@ -714,7 +713,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case RIGHT: - m_nBodyOffset.Set(6, 56); + _nBodyOffset.Set(6, 56); headStartPat = PAT_RIDERIGHT_START; bodyStartPat = BPAT_STANDRIGHT; headLoopPat = PAT_RIDERIGHT_LOOP; @@ -724,19 +723,19 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case TALK_RIDE2: - m_bCorpoDavanti = false; - switch (m_TalkDirection) { + _bCorpoDavanti = false; + switch (_TalkDirection) { case UP: case DOWN: case LEFT: - m_nBodyOffset.Set(6, 56); + _nBodyOffset.Set(6, 56); headStartPat = PAT_RIDELEFT_START; bodyStartPat = BPAT_STANDLEFT; headLoopPat = PAT_RIDELEFT_LOOP; break; case RIGHT: - m_nBodyOffset.Set(6, 56); + _nBodyOffset.Set(6, 56); headStartPat = PAT_RIDERIGHT_START; bodyStartPat = BPAT_STANDRIGHT; headLoopPat = PAT_RIDERIGHT_LOOP; @@ -747,17 +746,17 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case TALK_SIINDICA: - switch (m_TalkDirection) { + switch (_TalkDirection) { case UP: case DOWN: case LEFT: - m_nBodyOffset.Set(-4, 40); + _nBodyOffset.Set(-4, 40); headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_SIINDICALEFT; break; case RIGHT: - m_nBodyOffset.Set(5, 40); + _nBodyOffset.Set(5, 40); headLoopPat = PAT_TALK_RIGHT; bodyLoopPat = BPAT_SIINDICARIGHT; break; @@ -765,9 +764,9 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case TALK_SPAVENTATO: - switch (m_TalkDirection) { + switch (_TalkDirection) { case UP: - m_nBodyOffset.Set(-4, -11); + _nBodyOffset.Set(-4, -11); headStartPat = PAT_TESTA_UP; bodyStartPat = BPAT_SPAVENTOUP_START; headLoopPat = PAT_TALK_UP; @@ -775,7 +774,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case DOWN: - m_nBodyOffset.Set(-5, 45); + _nBodyOffset.Set(-5, 45); headStartPat = PAT_SPAVENTODOWN_START; bodyStartPat = BPAT_SPAVENTODOWN_START; headLoopPat = PAT_SPAVENTODOWN_LOOP; @@ -783,7 +782,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case RIGHT: - m_nBodyOffset.Set(-4, 41); + _nBodyOffset.Set(-4, 41); headStartPat = PAT_SPAVENTORIGHT_START; bodyStartPat = BPAT_SPAVENTORIGHT_START; headLoopPat = PAT_SPAVENTORIGHT_LOOP; @@ -791,7 +790,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case LEFT: - m_nBodyOffset.Set(-10, 41); + _nBodyOffset.Set(-10, 41); headStartPat = PAT_SPAVENTOLEFT_START; bodyStartPat = BPAT_SPAVENTOLEFT_START; headLoopPat = PAT_SPAVENTOLEFT_LOOP; @@ -801,12 +800,12 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case TALK_SPAVENTATO2: - m_bCorpoDavanti = false; - switch (m_TalkDirection) { + _bCorpoDavanti = false; + switch (_TalkDirection) { case UP: bodyStartPat = BPAT_STANDUP; bodyLoopPat = BPAT_STANDUP; - m_nBodyOffset.Set(6, 53); + _nBodyOffset.Set(6, 53); headStartPat = PAT_TESTA_UP; headLoopPat = PAT_TALK_UP; @@ -815,7 +814,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case DOWN: bodyStartPat = BPAT_STANDDOWN; bodyLoopPat = BPAT_STANDDOWN; - m_nBodyOffset.Set(4, 53); + _nBodyOffset.Set(4, 53); headStartPat = PAT_SPAVENTODOWN_START; headLoopPat = PAT_SPAVENTODOWN_LOOP; @@ -824,7 +823,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case RIGHT: bodyStartPat = BPAT_STANDRIGHT; bodyLoopPat = BPAT_STANDRIGHT; - m_nBodyOffset.Set(6, 56); + _nBodyOffset.Set(6, 56); headStartPat = PAT_SPAVENTORIGHT_START; headLoopPat = PAT_SPAVENTORIGHT_LOOP; @@ -833,7 +832,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case LEFT: bodyStartPat = BPAT_STANDLEFT; bodyLoopPat = BPAT_STANDLEFT; - m_nBodyOffset.Set(6, 56); + _nBodyOffset.Set(6, 56); headStartPat = PAT_SPAVENTOLEFT_START; headLoopPat = PAT_SPAVENTOLEFT_LOOP; @@ -842,36 +841,36 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case TALK_CONBICCHIERE: - m_nBodyOffset.Set(4, 53); + _nBodyOffset.Set(4, 53); headLoopPat = PAT_TALK_DOWN; bodyLoopPat = BPAT_BICCHIERE; break; case TALK_CONVERME: - m_nBodyOffset.Set(9, 56); + _nBodyOffset.Set(9, 56); headLoopPat = PAT_TALK_RIGHT; bodyLoopPat = BPAT_VERME; break; case TALK_CONMARTELLO: - m_nBodyOffset.Set(6, 56); + _nBodyOffset.Set(6, 56); headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_MARTELLO; break; case TALK_CONCORDA: - m_nBodyOffset.Set(-3, 38); + _nBodyOffset.Set(-3, 38); headLoopPat = PAT_TALK_RIGHT; bodyLoopPat = BPAT_CORDA; break; case TALK_CONSEGRETARIA: - m_nBodyOffset.Set(-17, 12); + _nBodyOffset.Set(-17, 12); headLoopPat = PAT_TALK_RIGHT; bodyLoopPat = BPAT_CONSEGRETARIA; break; case TALK_CONCONIGLIO: - switch (m_TalkDirection) { + switch (_TalkDirection) { case LEFT: case UP: - m_nBodyOffset.Set(-21, -5); + _nBodyOffset.Set(-21, -5); bodyStartPat = BPAT_CONCONIGLIOLEFT_START; headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_CONCONIGLIOLEFT_LOOP; @@ -879,7 +878,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case DOWN: case RIGHT: - m_nBodyOffset.Set(-4, -5); + _nBodyOffset.Set(-4, -5); bodyStartPat = BPAT_CONCONIGLIORIGHT_START; headLoopPat = PAT_TALK_RIGHT; bodyLoopPat = BPAT_CONCONIGLIORIGHT_LOOP; @@ -888,10 +887,10 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case TALK_CONRICETTA: - switch (m_TalkDirection) { + switch (_TalkDirection) { case LEFT: case UP: - m_nBodyOffset.Set(-61, -7); + _nBodyOffset.Set(-61, -7); bodyStartPat = BPAT_CONRICETTALEFT_START; headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_CONRICETTALEFT_LOOP; @@ -899,7 +898,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case DOWN: case RIGHT: - m_nBodyOffset.Set(-5, -7); + _nBodyOffset.Set(-5, -7); bodyStartPat = BPAT_CONRICETTARIGHT_START; headLoopPat = PAT_TALK_RIGHT; bodyLoopPat = BPAT_CONRICETTARIGHT_LOOP; @@ -908,10 +907,10 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case TALK_CONCARTE: - switch (m_TalkDirection) { + switch (_TalkDirection) { case LEFT: case UP: - m_nBodyOffset.Set(-34, -2); + _nBodyOffset.Set(-34, -2); bodyStartPat = BPAT_CONCARTELEFT_START; headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_CONCARTELEFT_LOOP; @@ -919,7 +918,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case DOWN: case RIGHT: - m_nBodyOffset.Set(-4, -2); + _nBodyOffset.Set(-4, -2); bodyStartPat = BPAT_CONCARTERIGHT_START; headLoopPat = PAT_TALK_RIGHT; bodyLoopPat = BPAT_CONCARTERIGHT_LOOP; @@ -928,10 +927,10 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case TALK_CONPUPAZZO: - switch (m_TalkDirection) { + switch (_TalkDirection) { case LEFT: case UP: - m_nBodyOffset.Set(-35, 2); + _nBodyOffset.Set(-35, 2); bodyStartPat = BPAT_CONPUPAZZOLEFT_START; headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_CONPUPAZZOLEFT_LOOP; @@ -939,7 +938,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case DOWN: case RIGHT: - m_nBodyOffset.Set(-14, 2); + _nBodyOffset.Set(-14, 2); bodyStartPat = BPAT_CONPUPAZZORIGHT_START; headLoopPat = PAT_TALK_RIGHT; bodyLoopPat = BPAT_CONPUPAZZORIGHT_LOOP; @@ -953,7 +952,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case TALK_CONCARTESTATIC: case TALK_CONTACCUINOSTATIC: case TALK_CONMEGAFONOSTATIC: - switch (m_TalkDirection) { + switch (_TalkDirection) { case LEFT: case UP: headLoopPat = PAT_TALK_LEFT; @@ -968,28 +967,28 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body // The beard is the only case in which the head is animated separately while the body is the standard case TALK_CONBARBASTATIC: - switch (m_TalkDirection) { + switch (_TalkDirection) { case LEFT: case UP: headLoopPat = PAT_TALKBARBA_LEFT; bodyLoopPat = BPAT_STANDLEFT; - m_nBodyOffset.Set(6, 56); + _nBodyOffset.Set(6, 56); break; case DOWN: case RIGHT: headLoopPat = PAT_TALKBARBA_RIGHT; bodyLoopPat = BPAT_STANDRIGHT; - m_nBodyOffset.Set(6, 56); + _nBodyOffset.Set(6, 56); break; } break; case TALK_SCHIFATO: - switch (m_TalkDirection) { + switch (_TalkDirection) { case LEFT: case UP: - m_nBodyOffset.Set(6, 56); + _nBodyOffset.Set(6, 56); headStartPat = PAT_SCHIFATOLEFT_START; bodyStartPat = BPAT_STANDLEFT; headLoopPat = PAT_SCHIFATOLEFT_LOOP; @@ -997,7 +996,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case DOWN: case RIGHT: - m_nBodyOffset.Set(6, 56); + _nBodyOffset.Set(6, 56); headStartPat = PAT_SCHIFATORIGHT_START; bodyStartPat = BPAT_STANDRIGHT; headLoopPat = PAT_SCHIFATORIGHT_LOOP; @@ -1006,10 +1005,10 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case TALK_NAAH: - switch (m_TalkDirection) { + switch (_TalkDirection) { case LEFT: case UP: - m_nBodyOffset.Set(6, 56); + _nBodyOffset.Set(6, 56); headStartPat = PAT_NAAHLEFT_START; bodyStartPat = BPAT_STANDLEFT; headLoopPat = PAT_NAAHLEFT_LOOP; @@ -1017,7 +1016,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case DOWN: case RIGHT: - m_nBodyOffset.Set(6, 56); + _nBodyOffset.Set(6, 56); headStartPat = PAT_NAAHRIGHT_START; bodyStartPat = BPAT_STANDRIGHT; headLoopPat = PAT_NAAHRIGHT_LOOP; @@ -1026,58 +1025,58 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case TALK_MACBETH1: - m_nBodyOffset.Set(-33, -1); + _nBodyOffset.Set(-33, -1); headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_MACBETH1; break; case TALK_MACBETH2: - m_nBodyOffset.Set(-33, -1); + _nBodyOffset.Set(-33, -1); headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_MACBETH2; break; case TALK_MACBETH3: - m_nBodyOffset.Set(-33, -1); + _nBodyOffset.Set(-33, -1); headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_MACBETH3; break; case TALK_MACBETH4: - m_nBodyOffset.Set(-33, -1); + _nBodyOffset.Set(-33, -1); headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_MACBETH4; break; case TALK_MACBETH5: - m_nBodyOffset.Set(-33, -1); + _nBodyOffset.Set(-33, -1); headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_MACBETH5; break; case TALK_MACBETH6: - m_nBodyOffset.Set(-33, -1); + _nBodyOffset.Set(-33, -1); headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_MACBETH6; break; case TALK_MACBETH7: - m_nBodyOffset.Set(-33, -1); + _nBodyOffset.Set(-33, -1); headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_MACBETH7; break; case TALK_MACBETH8: - m_nBodyOffset.Set(-33, -1); + _nBodyOffset.Set(-33, -1); headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_MACBETH8; break; case TALK_MACBETH9: - m_nBodyOffset.Set(-33, -1); + _nBodyOffset.Set(-33, -1); headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_MACBETH9; break; case TALK_SPAVENTATOSTATIC: - m_bCorpoDavanti = false; - switch (m_TalkDirection) { + _bCorpoDavanti = false; + switch (_TalkDirection) { case DOWN: bodyStartPat = BPAT_STANDDOWN; bodyLoopPat = BPAT_STANDDOWN; - m_nBodyOffset.Set(4, 53); + _nBodyOffset.Set(4, 53); headStartPat = PAT_SPAVENTODOWN_STAND; headLoopPat = PAT_SPAVENTODOWN_LOOP; @@ -1086,7 +1085,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case RIGHT: bodyStartPat = BPAT_STANDRIGHT; bodyLoopPat = BPAT_STANDRIGHT; - m_nBodyOffset.Set(6, 56); + _nBodyOffset.Set(6, 56); headStartPat = PAT_SPAVENTORIGHT_STAND; headLoopPat = PAT_SPAVENTORIGHT_LOOP; @@ -1095,7 +1094,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case LEFT: bodyStartPat = BPAT_STANDLEFT; bodyLoopPat = BPAT_STANDLEFT; - m_nBodyOffset.Set(6, 56); + _nBodyOffset.Set(6, 56); headStartPat = PAT_SPAVENTOLEFT_STAND; headLoopPat = PAT_SPAVENTOLEFT_LOOP; @@ -1110,7 +1109,7 @@ bool RMTony::StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body return true; } -void RMTony::StartTalk(CORO_PARAM, TALKTYPE nTalkType) { +void RMTony::startTalk(CORO_PARAM, TALKTYPE nTalkType) { CORO_BEGIN_CONTEXT; int headStartPat, bodyStartPat; int headLoopPat, bodyLoopPat; @@ -1121,38 +1120,38 @@ void RMTony::StartTalk(CORO_PARAM, TALKTYPE nTalkType) { _ctx->headStartPat = _ctx->bodyStartPat = 0; _ctx->headLoopPat = _ctx->bodyLoopPat = 0; - if (!StartTalkCalculate(nTalkType, _ctx->headStartPat, _ctx->bodyStartPat, + if (!startTalkCalculate(nTalkType, _ctx->headStartPat, _ctx->bodyStartPat, _ctx->headLoopPat, _ctx->bodyLoopPat)) return; // Perform the set pattern if (_ctx->headStartPat != 0 || _ctx->bodyStartPat != 0) { mainFreeze(); - SetPattern(_ctx->headStartPat); - m_body.SetPattern(_ctx->bodyStartPat); + setPattern(_ctx->headStartPat); + _body.setPattern(_ctx->bodyStartPat); mainUnfreeze(); if (_ctx->bodyStartPat != 0) - CORO_INVOKE_0(m_body.WaitForEndPattern); + CORO_INVOKE_0(_body.waitForEndPattern); if (_ctx->headStartPat != 0) - CORO_INVOKE_0(WaitForEndPattern); + CORO_INVOKE_0(waitForEndPattern); } mainFreeze(); - SetPattern(_ctx->headLoopPat); + setPattern(_ctx->headLoopPat); if (_ctx->bodyLoopPat) - m_body.SetPattern(_ctx->bodyLoopPat); + _body.setPattern(_ctx->bodyLoopPat); mainUnfreeze(); CORO_END_CODE; } -bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPat, int &finalPat, bool &bStatic) { +bool RMTony::endTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPat, int &finalPat, bool &bStatic) { bodyEndPat = 0; headEndPat = 0; - switch (m_TalkDirection) { + switch (_TalkDirection) { case UP: finalPat = PAT_STANDUP; headStandPat = PAT_TESTA_UP; @@ -1174,23 +1173,23 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa break; } - if (m_bPastorella) { + if (_bPastorella) { mainFreeze(); - SetPattern(finalPat); + setPattern(finalPat); mainUnfreeze(); - m_bIsTalking = false; + _bIsTalking = false; return false; } bStatic = false; - switch (m_nTalkType) { + switch (_nTalkType) { case TALK_NORMAL: bodyEndPat = 0; break; case TALK_FIANCHI: - switch (m_TalkDirection) { + switch (_TalkDirection) { case UP: bodyEndPat = BPAT_FIANCHIUP_END; break; @@ -1215,16 +1214,16 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa case TALK_RIDE: case TALK_RIDE2: - if (m_TalkDirection == LEFT) + if (_TalkDirection == LEFT) headEndPat = PAT_RIDELEFT_END; - else if (m_TalkDirection == RIGHT) + else if (_TalkDirection == RIGHT) headEndPat = PAT_RIDERIGHT_END; bodyEndPat = 0; break; case TALK_SCHIFATO: - switch (m_TalkDirection) { + switch (_TalkDirection) { case UP: case LEFT: headEndPat = PAT_SCHIFATOLEFT_END; @@ -1240,7 +1239,7 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa break; case TALK_NAAH: - switch (m_TalkDirection) { + switch (_TalkDirection) { case UP: case LEFT: headEndPat = PAT_NAAHLEFT_END; @@ -1259,7 +1258,7 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa break; case TALK_SPAVENTATO: - switch (m_TalkDirection) { + switch (_TalkDirection) { case UP: bodyEndPat = BPAT_SPAVENTOUP_END; break; @@ -1282,7 +1281,7 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa break; case TALK_SPAVENTATO2: - switch (m_TalkDirection) { + switch (_TalkDirection) { case UP: bodyEndPat = 0; break; @@ -1305,7 +1304,7 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa break; case TALK_CONCONIGLIO: - switch (m_TalkDirection) { + switch (_TalkDirection) { case UP: case LEFT: finalPat = PAT_STANDLEFT; @@ -1321,7 +1320,7 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa break; case TALK_CONRICETTA: - switch (m_TalkDirection) { + switch (_TalkDirection) { case UP: case LEFT: finalPat = PAT_STANDLEFT; @@ -1337,7 +1336,7 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa break; case TALK_CONCARTE: - switch (m_TalkDirection) { + switch (_TalkDirection) { case UP: case LEFT: finalPat = PAT_STANDLEFT; @@ -1353,7 +1352,7 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa break; case TALK_CONPUPAZZO: - switch (m_TalkDirection) { + switch (_TalkDirection) { case UP: case LEFT: finalPat = PAT_STANDLEFT; @@ -1396,7 +1395,7 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa break; case TALK_SPAVENTATOSTATIC: - switch (m_TalkDirection) { + switch (_TalkDirection) { case DOWN: headStandPat = PAT_SPAVENTODOWN_STAND; bodyEndPat = 0; @@ -1425,7 +1424,7 @@ bool RMTony::EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa return true; } -void RMTony::EndTalk(CORO_PARAM) { +void RMTony::endTalk(CORO_PARAM) { CORO_BEGIN_CONTEXT; int headStandPat, headEndPat; int bodyEndPat, finalPat; @@ -1441,93 +1440,93 @@ void RMTony::EndTalk(CORO_PARAM) { _ctx->bodyEndPat = 0; _ctx->headEndPat = 0; - if (!EndTalkCalculate(_ctx->headStandPat, _ctx->headEndPat, _ctx->bodyEndPat, _ctx->finalPat, _ctx->bStatic)) + if (!endTalkCalculate(_ctx->headStandPat, _ctx->headEndPat, _ctx->bodyEndPat, _ctx->finalPat, _ctx->bStatic)) return; // Handles the end of an animated and static, leaving everything unchanged - if (m_bIsStaticTalk) { - if (m_nTalkType == TALK_CONBARBASTATIC) { + if (_bIsStaticTalk) { + if (_nTalkType == TALK_CONBARBASTATIC) { mainFreeze(); - SetPattern(0); - if (m_TalkDirection == UP || m_TalkDirection == LEFT) { - m_body.SetPattern(BPAT_CONBARBALEFT_STATIC); - m_nBodyOffset.Set(-41, -14); - } else if (m_TalkDirection == DOWN || m_TalkDirection == RIGHT) { - m_body.SetPattern(BPAT_CONBARBARIGHT_STATIC); - m_nBodyOffset.Set(-26, -14); + setPattern(0); + if (_TalkDirection == UP || _TalkDirection == LEFT) { + _body.setPattern(BPAT_CONBARBALEFT_STATIC); + _nBodyOffset.Set(-41, -14); + } else if (_TalkDirection == DOWN || _TalkDirection == RIGHT) { + _body.setPattern(BPAT_CONBARBARIGHT_STATIC); + _nBodyOffset.Set(-26, -14); } mainUnfreeze(); } else { mainFreeze(); - SetPattern(_ctx->headStandPat); + setPattern(_ctx->headStandPat); mainUnfreeze(); - CORO_INVOKE_0(m_body.WaitForEndPattern); + CORO_INVOKE_0(_body.waitForEndPattern); } - m_bIsTalking = false; + _bIsTalking = false; return; } // Set the pattern if (_ctx->headEndPat != 0 && _ctx->bodyEndPat != 0) { mainFreeze(); - SetPattern(_ctx->headEndPat); + setPattern(_ctx->headEndPat); mainUnfreeze(); - CORO_INVOKE_0(m_body.WaitForEndPattern); + CORO_INVOKE_0(_body.waitForEndPattern); mainFreeze(); - m_body.SetPattern(_ctx->bodyEndPat); + _body.setPattern(_ctx->bodyEndPat); mainUnfreeze(); - CORO_INVOKE_0(WaitForEndPattern); - CORO_INVOKE_0(m_body.WaitForEndPattern); + CORO_INVOKE_0(waitForEndPattern); + CORO_INVOKE_0(_body.waitForEndPattern); } else if (_ctx->bodyEndPat != 0) { mainFreeze(); - SetPattern(_ctx->headStandPat); + setPattern(_ctx->headStandPat); mainUnfreeze(); - CORO_INVOKE_0(m_body.WaitForEndPattern); + CORO_INVOKE_0(_body.waitForEndPattern); mainFreeze(); - m_body.SetPattern(_ctx->bodyEndPat); + _body.setPattern(_ctx->bodyEndPat); mainUnfreeze(); - CORO_INVOKE_0(m_body.WaitForEndPattern); + CORO_INVOKE_0(_body.waitForEndPattern); } else if (_ctx->headEndPat != 0) { - CORO_INVOKE_0(m_body.WaitForEndPattern); + CORO_INVOKE_0(_body.waitForEndPattern); mainFreeze(); - SetPattern(_ctx->headEndPat); + setPattern(_ctx->headEndPat); mainUnfreeze(); - CORO_INVOKE_0(WaitForEndPattern); + CORO_INVOKE_0(waitForEndPattern); } else { - CORO_INVOKE_0(m_body.WaitForEndPattern); + CORO_INVOKE_0(_body.waitForEndPattern); } if (_ctx->finalPat != 0) { mainFreeze(); - m_body.SetPattern(0); - SetPattern(_ctx->finalPat); + _body.setPattern(0); + setPattern(_ctx->finalPat); mainUnfreeze(); } - m_bIsTalking = false; + _bIsTalking = false; CORO_END_CODE; } -void RMTony::StartStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat, +void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat, int &bodyStartPat, int &bodyLoopPat) { - int nPat = GetCurPattern(); + int nPat = getCurPattern(); headLoopPat = -1; switch (nPat) { case PAT_STANDDOWN: - m_TalkDirection = DOWN; + _TalkDirection = DOWN; headPat = PAT_TESTA_RIGHT; break; @@ -1536,7 +1535,7 @@ void RMTony::StartStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat case PAT_TAKELEFT_DOWN2: case PAT_SIRIALZALEFT: case PAT_STANDLEFT: - m_TalkDirection = LEFT; + _TalkDirection = LEFT; headPat = PAT_TESTA_LEFT; break; @@ -1545,7 +1544,7 @@ void RMTony::StartStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat case PAT_TAKERIGHT_DOWN2: case PAT_SIRIALZARIGHT: case PAT_STANDRIGHT: - m_TalkDirection = RIGHT; + _TalkDirection = RIGHT; headPat = PAT_TESTA_RIGHT; break; @@ -1553,26 +1552,26 @@ void RMTony::StartStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat case PAT_TAKEUP_MID2: case PAT_TAKEUP_DOWN2: case PAT_STANDUP: - m_TalkDirection = UP; + _TalkDirection = UP; headPat = PAT_TESTA_LEFT; break; } - m_bCorpoDavanti = true; + _bCorpoDavanti = true; switch (nTalk) { case TALK_CONCONIGLIOSTATIC: - switch (m_TalkDirection) { + switch (_TalkDirection) { case UP: case LEFT: - m_nBodyOffset.Set(-21, -5); + _nBodyOffset.Set(-21, -5); bodyStartPat = BPAT_CONCONIGLIOLEFT_START; bodyLoopPat = BPAT_CONCONIGLIOLEFT_LOOP; break; case DOWN: case RIGHT: - m_nBodyOffset.Set(-4, -5); + _nBodyOffset.Set(-4, -5); bodyStartPat = BPAT_CONCONIGLIORIGHT_START; bodyLoopPat = BPAT_CONCONIGLIORIGHT_LOOP; break; @@ -1580,17 +1579,17 @@ void RMTony::StartStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat break; case TALK_CONCARTESTATIC: - switch (m_TalkDirection) { + switch (_TalkDirection) { case UP: case LEFT: - m_nBodyOffset.Set(-34, -2); + _nBodyOffset.Set(-34, -2); bodyStartPat = BPAT_CONCARTELEFT_START; bodyLoopPat = BPAT_CONCARTELEFT_LOOP; break; case DOWN: case RIGHT: - m_nBodyOffset.Set(-4, -2); + _nBodyOffset.Set(-4, -2); bodyStartPat = BPAT_CONCARTERIGHT_START; bodyLoopPat = BPAT_CONCARTERIGHT_LOOP; break; @@ -1598,17 +1597,17 @@ void RMTony::StartStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat break; case TALK_CONRICETTASTATIC: - switch (m_TalkDirection) { + switch (_TalkDirection) { case UP: case LEFT: - m_nBodyOffset.Set(-61, -7); + _nBodyOffset.Set(-61, -7); bodyStartPat = BPAT_CONRICETTALEFT_START; bodyLoopPat = BPAT_CONRICETTALEFT_LOOP; break; case DOWN: case RIGHT: - m_nBodyOffset.Set(-5, -7); + _nBodyOffset.Set(-5, -7); bodyStartPat = BPAT_CONRICETTARIGHT_START; bodyLoopPat = BPAT_CONRICETTARIGHT_LOOP; break; @@ -1616,17 +1615,17 @@ void RMTony::StartStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat break; case TALK_CONPUPAZZOSTATIC: - switch (m_TalkDirection) { + switch (_TalkDirection) { case UP: case LEFT: - m_nBodyOffset.Set(-35, 2); + _nBodyOffset.Set(-35, 2); bodyStartPat = BPAT_CONPUPAZZOLEFT_START; bodyLoopPat = BPAT_CONPUPAZZOLEFT_LOOP; break; case DOWN: case RIGHT: - m_nBodyOffset.Set(-14, 2); + _nBodyOffset.Set(-14, 2); bodyStartPat = BPAT_CONPUPAZZORIGHT_START; bodyLoopPat = BPAT_CONPUPAZZORIGHT_LOOP; break; @@ -1634,17 +1633,17 @@ void RMTony::StartStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat break; case TALK_CONTACCUINOSTATIC: - switch (m_TalkDirection) { + switch (_TalkDirection) { case UP: case LEFT: - m_nBodyOffset.Set(-16, -9); + _nBodyOffset.Set(-16, -9); bodyStartPat = BPAT_CONTACCUINOLEFT_START; bodyLoopPat = BPAT_CONTACCUINOLEFT_LOOP; break; case DOWN: case RIGHT: - m_nBodyOffset.Set(-6, -9); + _nBodyOffset.Set(-6, -9); bodyStartPat = BPAT_CONTACCUINORIGHT_START; bodyLoopPat = BPAT_CONTACCUINORIGHT_LOOP; break; @@ -1652,17 +1651,17 @@ void RMTony::StartStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat break; case TALK_CONMEGAFONOSTATIC: - switch (m_TalkDirection) { + switch (_TalkDirection) { case UP: case LEFT: - m_nBodyOffset.Set(-41, -8); + _nBodyOffset.Set(-41, -8); bodyStartPat = BPAT_CONMEGAFONOLEFT_START; bodyLoopPat = BPAT_CONMEGAFONOLEFT_LOOP; break; case DOWN: case RIGHT: - m_nBodyOffset.Set(-14, -8); + _nBodyOffset.Set(-14, -8); bodyStartPat = BPAT_CONMEGAFONORIGHT_START; bodyLoopPat = BPAT_CONMEGAFONORIGHT_LOOP; break; @@ -1670,10 +1669,10 @@ void RMTony::StartStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat break; case TALK_CONBARBASTATIC: - switch (m_TalkDirection) { + switch (_TalkDirection) { case UP: case LEFT: - m_nBodyOffset.Set(-41, -14); + _nBodyOffset.Set(-41, -14); bodyStartPat = BPAT_CONBARBALEFT_START; bodyLoopPat = BPAT_STANDLEFT; headLoopPat = PAT_TALKBARBA_LEFT; @@ -1682,7 +1681,7 @@ void RMTony::StartStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat case DOWN: case RIGHT: - m_nBodyOffset.Set(-26, -14); + _nBodyOffset.Set(-26, -14); bodyStartPat = BPAT_CONBARBARIGHT_START; bodyLoopPat = BPAT_STANDRIGHT; headLoopPat = PAT_TALKBARBA_RIGHT; @@ -1692,13 +1691,13 @@ void RMTony::StartStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat break; case TALK_SPAVENTATOSTATIC: - switch (m_TalkDirection) { + switch (_TalkDirection) { case DOWN: headPat = PAT_SPAVENTODOWN_START; bodyLoopPat = BPAT_STANDDOWN; bodyStartPat = BPAT_STANDDOWN; headLoopPat = PAT_SPAVENTODOWN_STAND; - m_nBodyOffset.Set(4, 53); + _nBodyOffset.Set(4, 53); break; case LEFT: @@ -1706,7 +1705,7 @@ void RMTony::StartStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat bodyLoopPat = BPAT_STANDLEFT; bodyStartPat = BPAT_STANDLEFT; headLoopPat = PAT_SPAVENTOLEFT_STAND; - m_nBodyOffset.Set(6, 56); + _nBodyOffset.Set(6, 56); break; case RIGHT: @@ -1714,7 +1713,7 @@ void RMTony::StartStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat bodyLoopPat = BPAT_STANDRIGHT; bodyStartPat = BPAT_STANDRIGHT; headLoopPat = PAT_SPAVENTORIGHT_STAND; - m_nBodyOffset.Set(6, 56); + _nBodyOffset.Set(6, 56); break; default: @@ -1726,7 +1725,7 @@ void RMTony::StartStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat } } -void RMTony::StartStatic(CORO_PARAM, TALKTYPE nTalk) { +void RMTony::startStatic(CORO_PARAM, TALKTYPE nTalk) { CORO_BEGIN_CONTEXT; int headPat, headLoopPat; int bodyStartPat, bodyLoopPat; @@ -1738,28 +1737,28 @@ void RMTony::StartStatic(CORO_PARAM, TALKTYPE nTalk) { _ctx->bodyStartPat = _ctx->bodyLoopPat = 0; // e vai con i pattern - m_bIsStaticTalk = true; + _bIsStaticTalk = true; mainFreeze(); - SetPattern(_ctx->headPat); - m_body.SetPattern(_ctx->bodyStartPat); + setPattern(_ctx->headPat); + _body.setPattern(_ctx->bodyStartPat); mainUnfreeze(); - CORO_INVOKE_0(m_body.WaitForEndPattern); - CORO_INVOKE_0(WaitForEndPattern); + CORO_INVOKE_0(_body.waitForEndPattern); + CORO_INVOKE_0(waitForEndPattern); mainFreeze(); if (_ctx->headLoopPat != -1) - SetPattern(_ctx->headLoopPat); - m_body.SetPattern(_ctx->bodyLoopPat); + setPattern(_ctx->headLoopPat); + _body.setPattern(_ctx->bodyLoopPat); mainUnfreeze(); CORO_END_CODE; } -void RMTony::EndStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, int &headEndPat) { - switch (m_TalkDirection) { +void RMTony::endStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, int &headEndPat) { + switch (_TalkDirection) { case UP: case LEFT: finalPat = PAT_STANDLEFT; @@ -1773,7 +1772,7 @@ void RMTony::EndStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, switch (nTalk) { case TALK_CONPUPAZZOSTATIC: - switch (m_TalkDirection) { + switch (_TalkDirection) { case UP: case LEFT: bodyEndPat = BPAT_CONPUPAZZOLEFT_END; @@ -1787,7 +1786,7 @@ void RMTony::EndStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, break; case TALK_CONRICETTASTATIC: - switch (m_TalkDirection) { + switch (_TalkDirection) { case UP: case LEFT: bodyEndPat = BPAT_CONRICETTALEFT_END; @@ -1801,7 +1800,7 @@ void RMTony::EndStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, break; case TALK_CONCONIGLIOSTATIC: - switch (m_TalkDirection) { + switch (_TalkDirection) { case UP: case LEFT: bodyEndPat = BPAT_CONCONIGLIOLEFT_END; @@ -1815,7 +1814,7 @@ void RMTony::EndStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, break; case TALK_CONCARTESTATIC: - switch (m_TalkDirection) { + switch (_TalkDirection) { case UP: case LEFT: bodyEndPat = BPAT_CONCARTELEFT_END; @@ -1829,7 +1828,7 @@ void RMTony::EndStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, break; case TALK_CONTACCUINOSTATIC: - switch (m_TalkDirection) { + switch (_TalkDirection) { case UP: case LEFT: bodyEndPat = BPAT_CONTACCUINOLEFT_END; @@ -1843,7 +1842,7 @@ void RMTony::EndStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, break; case TALK_CONMEGAFONOSTATIC: - switch (m_TalkDirection) { + switch (_TalkDirection) { case UP: case LEFT: bodyEndPat = BPAT_CONMEGAFONOLEFT_END; @@ -1857,7 +1856,7 @@ void RMTony::EndStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, break; case TALK_CONBARBASTATIC: - switch (m_TalkDirection) { + switch (_TalkDirection) { case UP: case LEFT: bodyEndPat = BPAT_CONBARBALEFT_END; @@ -1871,7 +1870,7 @@ void RMTony::EndStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, break; case TALK_SPAVENTATOSTATIC: - switch (m_TalkDirection) { + switch (_TalkDirection) { case LEFT: headEndPat = PAT_SPAVENTOLEFT_END; break; @@ -1894,7 +1893,7 @@ void RMTony::EndStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, } } -void RMTony::EndStatic(CORO_PARAM, TALKTYPE nTalk) { +void RMTony::endStatic(CORO_PARAM, TALKTYPE nTalk) { CORO_BEGIN_CONTEXT; int bodyEndPat; int finalPat; @@ -1907,29 +1906,29 @@ void RMTony::EndStatic(CORO_PARAM, TALKTYPE nTalk) { _ctx->finalPat = 0; _ctx->headEndPat = 0; - EndStaticCalculate(nTalk, _ctx->bodyEndPat, _ctx->finalPat, _ctx->headEndPat); + endStaticCalculate(nTalk, _ctx->bodyEndPat, _ctx->finalPat, _ctx->headEndPat); if (_ctx->headEndPat != 0) { mainFreeze(); - SetPattern(_ctx->headEndPat); + setPattern(_ctx->headEndPat); mainUnfreeze(); - CORO_INVOKE_0(WaitForEndPattern); + CORO_INVOKE_0(waitForEndPattern); } else { // Play please mainFreeze(); - m_body.SetPattern(_ctx->bodyEndPat); + _body.setPattern(_ctx->bodyEndPat); mainUnfreeze(); - CORO_INVOKE_0(m_body.WaitForEndPattern); + CORO_INVOKE_0(_body.waitForEndPattern); } mainFreeze(); - SetPattern(_ctx->finalPat); - m_body.SetPattern(0); + setPattern(_ctx->finalPat); + _body.setPattern(0); mainUnfreeze(); - m_bIsStaticTalk = false; + _bIsStaticTalk = false; CORO_END_CODE; } diff --git a/engines/tony/tonychar.h b/engines/tony/tonychar.h index e7b4227fc5..5179230b4c 100644 --- a/engines/tony/tonychar.h +++ b/engines/tony/tonychar.h @@ -81,36 +81,36 @@ public: }; private: - bool m_bShow; - bool m_bShowOmbra; - bool m_bCorpoDavanti; - RMGfxSourceBuffer8AB m_ombra; - bool m_bActionPending; - RMItem *m_ActionItem; - int m_Action; - int m_ActionParm; - static bool m_bAction; - - bool m_bPastorella; - - bool m_bIsStaticTalk; - bool m_bIsTalking; - int m_nPatB4Talking; - TALKTYPE m_nTalkType; - DIRECTION m_TalkDirection; - RMPoint m_nBodyOffset; - - int m_nTimeLastStep; - - RMItem m_body; + bool _bShow; + bool _bShowOmbra; + bool _bCorpoDavanti; + RMGfxSourceBuffer8AB _ombra; + bool _bActionPending; + RMItem *_ActionItem; + int _Action; + int _ActionParm; + static bool _bAction; + + bool _bPastorella; + + bool _bIsStaticTalk; + bool _bIsTalking; + int _nPatB4Talking; + TALKTYPE _nTalkType; + DIRECTION _TalkDirection; + RMPoint _nBodyOffset; + + int _nTimeLastStep; + + RMItem _body; uint32 hActionThread; protected: // Overload of the allocation allocation of sprites - virtual RMGfxSourceBuffer *NewItemSpriteBuffer(int dimx, int dimy, bool bPreRLE); + virtual RMGfxSourceBuffer *newItemSpriteBuffer(int dimx, int dimy, bool bPreRLE); // Watch thread which waits for the end of an action - static void WaitEndOfAction(CORO_PARAM, const void *param); + static void waitEndOfAction(CORO_PARAM, const void *param); public: enum PATTERNS { @@ -365,87 +365,87 @@ public: void init(void); // Free all memory - void Close(void); + void close(void); // Tony makes a frame, updating the movement, etc. - void DoFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int curLoc); + void doFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int curLoc); // Draw method, which controls chararacter display virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Show or hide - void Show(void); - void Hide(bool bShowOmbra = false); + void show(void); + void hide(bool bShowOmbra = false); // Move and make an action, if necessary - void MoveAndDoAction(CORO_PARAM, RMPoint dst, RMItem *item, int nAction, int nActionParm = 0); + void moveAndDoAction(CORO_PARAM, RMPoint dst, RMItem *item, int nAction, int nActionParm = 0); // Tony stops (on the right side with respect to any subject) - virtual void Stop(CORO_PARAM); - void StopNoAction(CORO_PARAM); + virtual void stop(CORO_PARAM); + void stopNoAction(CORO_PARAM); // Set a pattern - void SetPattern(int npatt, bool bPlayP0 = false); + void setPattern(int npatt, bool bPlayP0 = false); // Reads the current pattern - int GetCurPattern(); + int getCurPattern(); // Waits until the end of a pattern - void WaitForEndPattern(CORO_PARAM, uint32 hCustomSkip = CORO_INVALID_PID_VALUE) { - RMCharacter::WaitForEndPattern(coroParam, hCustomSkip); + void waitForEndPattern(CORO_PARAM, uint32 hCustomSkip = CORO_INVALID_PID_VALUE) { + RMCharacter::waitForEndPattern(coroParam, hCustomSkip); } // Check if currently in an action - bool InAction() { - return (m_bActionPending && m_Action != 0) | m_bAction; + bool inAction() { + return (_bActionPending && _Action != 0) | _bAction; } // Check if there needs to be an update for scrolling movement - bool MustUpdateScrolling() { - return ((!InAction()) || (IsMoving())); + bool mustUpdateScrolling() { + return ((!inAction()) || (isMoving())); } // Returns Tony's position - RMPoint Position() { - return m_pos; + RMPoint position() { + return _pos; } // Set the scrolling position - void SetScrollPosition(const RMPoint &pt) { - RMCharacter::SetScrollPosition(pt); + void setScrollPosition(const RMPoint &pt) { + RMCharacter::setScrollPosition(pt); } // Set the take animation - void Take(int nWhere, int nPart); - void Put(int nWhere, int nPart); + void take(int nWhere, int nPart); + void put(int nWhere, int nPart); // Start or End Talk - bool StartTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &bodyStartPat, + bool startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &bodyStartPat, int &headLoopPat, int &bodyLoopPat); - void StartTalk(CORO_PARAM, TALKTYPE nTalkType); - bool EndTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPat, int &finalPat, bool &bStatic); - void EndTalk(CORO_PARAM); + void startTalk(CORO_PARAM, TALKTYPE nTalkType); + bool endTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPat, int &finalPat, bool &bStatic); + void endTalk(CORO_PARAM); // Start or End Static - void StartStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat, + void startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat, int &bodyStartPat, int &bodyLoopPat); - void StartStatic(CORO_PARAM, TALKTYPE nTalkType); - void EndStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, int &headEndPat); - void EndStatic(CORO_PARAM, TALKTYPE nTalkType); + void startStatic(CORO_PARAM, TALKTYPE nTalkType); + void endStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, int &headEndPat); + void endStatic(CORO_PARAM, TALKTYPE nTalkType); // Tony disguises himself! - void SetPastorella(bool bIsPast) { - m_bPastorella = bIsPast; + void setPastorella(bool bIsPast) { + _bPastorella = bIsPast; } - int GetPastorella(void) { - return m_bPastorella; + int getPastorella(void) { + return _bPastorella; } // Perform an action - void ExecuteAction(int nAction, int nActionItem, int nParm); + void executeAction(int nAction, int nActionItem, int nParm); - void PlaySfx(int nSfx) { - RMItem::PlaySfx(nSfx); + void playSfx(int nSfx) { + RMItem::playSfx(nSfx); } }; -- cgit v1.2.3 From f12ab3e521b01ed2b40e7d517753dd14bc6e6f0f Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 7 Jun 2012 08:42:35 +0200 Subject: TONY: Rename variables and functions in utils.h --- engines/tony/custom.cpp | 10 +- engines/tony/debugger.cpp | 2 +- engines/tony/font.cpp | 36 ++--- engines/tony/game.cpp | 44 +++--- engines/tony/game.h | 8 +- engines/tony/gfxcore.cpp | 28 ++-- engines/tony/gfxcore.h | 28 ++-- engines/tony/gfxengine.cpp | 2 +- engines/tony/input.cpp | 4 +- engines/tony/inventory.cpp | 46 +++--- engines/tony/loc.cpp | 72 ++++----- engines/tony/mpal/mpalutils.cpp | 36 ++--- engines/tony/mpal/mpalutils.h | 14 +- engines/tony/tony.cpp | 2 +- engines/tony/tonychar.cpp | 174 ++++++++++----------- engines/tony/utils.cpp | 338 ++++++++++++++++++++-------------------- engines/tony/utils.h | 114 +++++++------- engines/tony/window.h | 4 +- 18 files changed, 481 insertions(+), 481 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index d42ef94a17..eaf125c973 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -574,7 +574,7 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint } DECLARE_CUSTOM_FUNCTION(SetLocStartPosition)(CORO_PARAM, uint32 nLoc, uint32 lX, uint32 lY, uint32) { - GLOBALS.StartLocPos[nLoc].Set(lX, lY); + GLOBALS.StartLocPos[nLoc].set(lX, lY); } DECLARE_CUSTOM_FUNCTION(SaveTonyPosition)(CORO_PARAM, uint32, uint32, uint32, uint32) { @@ -1223,21 +1223,21 @@ DECLARE_CUSTOM_FUNCTION(ScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, uint32 if (_ctx->lx > 0) { _ctx->lx -= (int32)sX; if (_ctx->lx < 0) _ctx->lx = 0; - _ctx->pt.Offset((int32)sX, 0); + _ctx->pt.offset((int32)sX, 0); } else if (_ctx->lx < 0) { _ctx->lx += (int32)sX; if (_ctx->lx > 0) _ctx->lx = 0; - _ctx->pt.Offset(-(int32)sX, 0); + _ctx->pt.offset(-(int32)sX, 0); } if (_ctx->ly > 0) { _ctx->ly -= sY; if (_ctx->ly < 0) _ctx->ly = 0; - _ctx->pt.Offset(0, sY); + _ctx->pt.offset(0, sY); } else if (_ctx->ly < 0) { _ctx->ly += sY; if (_ctx->ly > 0) _ctx->ly = 0; - _ctx->pt.Offset(0, -(int32)sY); + _ctx->pt.offset(0, -(int32)sY); } CORO_INVOKE_0(GLOBALS.WaitFrame); diff --git a/engines/tony/debugger.cpp b/engines/tony/debugger.cpp index 66fddf2834..af2bffc459 100644 --- a/engines/tony/debugger.cpp +++ b/engines/tony/debugger.cpp @@ -100,7 +100,7 @@ bool Debugger::Cmd_Scene(int argc, const char **argv) { // Get the box areas for the scene, and choose one so as to have a default // position for Tony that will be in the walkable areas RMBoxLoc *box = _vm->_theBoxes.getBoxes(sceneNumber); - scenePos.Set(box->boxes[0].hotspot[0].hotx, box->boxes[0].hotspot[0].hoty); + scenePos.set(box->boxes[0].hotspot[0].hotx, box->boxes[0].hotspot[0].hoty); } // Set up a process to change the scene diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index e056484e54..623aab5ab4 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -82,8 +82,8 @@ void RMFont::load(const byte *buf, int nChars, int dimx, int dimy, uint32 palRes void RMFont::load(uint32 resID, int nChars, int dimx, int dimy, uint32 palResID) { RMRes res(resID); - if ((int)res.Size() < nChars * (dimy * dimx + 8)) - nChars = res.Size() / (dimy * dimx + 8); + if ((int)res.size() < nChars * (dimy * dimx + 8)) + nChars = res.size() / (dimy * dimx + 8); load(res, nChars, dimx, dimy, palResID); } @@ -137,7 +137,7 @@ int RMFont::stringLen(const RMString &text) { int len, i; len = 0; - for (i = 0; i < text.Length() - 1; i++) + for (i = 0; i < text.length() - 1; i++) len += letterLength(text[i], text[i + 1]); len += letterLength(text[i]); @@ -1968,9 +1968,9 @@ void RMText::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CODE(_ctx); // Horizontally if (aHorType == HCENTER) - prim->Dst().TopLeft() -= RMPoint(_dimx / 2, 0); + prim->Dst().topLeft() -= RMPoint(_dimx / 2, 0); else if (aHorType == HRIGHT) - prim->Dst().TopLeft() -= RMPoint(_dimx, 0); + prim->Dst().topLeft() -= RMPoint(_dimx, 0); // Vertically @@ -2146,7 +2146,7 @@ void RMTextDialog::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *p if (_bShowed) { if (GLOBALS.bCfgSottotitoli || _bAlwaysDisplay) { - prim->Dst().TopLeft() = dst; + prim->Dst().topLeft() = dst; CORO_INVOKE_2(RMText::draw, bigBuf, prim); } } @@ -2285,7 +2285,7 @@ void RMTextItemName::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive return; // Set the destination coordinates of the mouse - prim->Dst().TopLeft() = _mpos - RMPoint(0, 30); + prim->Dst().topLeft() = _mpos - RMPoint(0, 30); CORO_INVOKE_2(RMText::draw, bigBuf, prim); @@ -2308,7 +2308,7 @@ bool RMTextItemName::isItemSelected() { } bool RMTextItemName::isNormalItemSelected() { - return _item != NULL && _itemName.Length() > 0; + return _item != NULL && _itemName.length() > 0; } @@ -2321,8 +2321,8 @@ RMDialogChoice::RMDialogChoice() { RMResRaw dlg2(RES_I_DLGTEXTLINE); RMRes dlgpal(RES_I_DLGTEXTPAL); - DlgText.init(dlg1, dlg1.Width(), dlg1.Height()); - DlgTextLine.init(dlg2, dlg2.Width(), dlg2.Height()); + DlgText.init(dlg1, dlg1.width(), dlg1.height()); + DlgTextLine.init(dlg2, dlg2.width(), dlg2.height()); DlgText.loadPaletteWA(dlgpal); DlgTextLine.loadPaletteWA(dlgpal); @@ -2407,18 +2407,18 @@ void RMDialogChoice::prepare(CORO_PARAM) { addPrim(new RMGfxPrimitive(&DlgTextLine, RMPoint(0, 155 + 83 + 83))); addPrim(new RMGfxPrimitive(&DlgTextLine, RMPoint(0, 155 + 83 + 83 + 83))); - _ctx->ptPos.Set(20, 90); + _ctx->ptPos.set(20, 90); for (_ctx->i = 0; _ctx->i < _numChoices; _ctx->i++) { addPrim(new RMGfxPrimitive(&_drawedStrings[_ctx->i], _ctx->ptPos)); _ptDrawStrings[_ctx->i] = _ctx->ptPos; - _ctx->ptPos.Offset(0, _drawedStrings[_ctx->i].getDimy() + 15); + _ctx->ptPos.offset(0, _drawedStrings[_ctx->i].getDimy() + 15); } CORO_INVOKE_0(drawOT); clearOT(); - _ptDrawPos.Set(0, 480 - _ctx->ptPos.y); + _ptDrawPos.set(0, 480 - _ctx->ptPos.y); CORO_END_CODE; } @@ -2438,8 +2438,8 @@ void RMDialogChoice::setSelected(CORO_PARAM, int pos) { if (_curSelection != -1) { _ctx->box.SetColor(0xCC, 0xCC, 0xFF); - _ctx->rc.TopLeft() = RMPoint(18, _ptDrawStrings[_curSelection].y); - _ctx->rc.BottomRight() = _ctx->rc.TopLeft() + RMPoint(597, _drawedStrings[_curSelection].getDimy()); + _ctx->rc.topLeft() = RMPoint(18, _ptDrawStrings[_curSelection].y); + _ctx->rc.bottomRight() = _ctx->rc.topLeft() + RMPoint(597, _drawedStrings[_curSelection].getDimy()); addPrim(new RMGfxPrimitive(&_ctx->box, _ctx->rc)); addPrim(new RMGfxPrimitive(&_drawedStrings[_curSelection], _ptDrawStrings[_curSelection])); @@ -2449,8 +2449,8 @@ void RMDialogChoice::setSelected(CORO_PARAM, int pos) { if (pos != -1) { _ctx->box.SetColor(100, 100, 100); - _ctx->rc.TopLeft() = RMPoint(18, _ptDrawStrings[pos].y); - _ctx->rc.BottomRight() = _ctx->rc.TopLeft() + RMPoint(597, _drawedStrings[pos].getDimy()); + _ctx->rc.topLeft() = RMPoint(18, _ptDrawStrings[pos].y); + _ctx->rc.bottomRight() = _ctx->rc.topLeft() + RMPoint(597, _drawedStrings[pos].getDimy()); addPrim(new RMGfxPrimitive(&_ctx->box, _ctx->rc)); addPrim(new RMGfxPrimitive(&_drawedStrings[pos], _ptDrawStrings[pos])); } @@ -2485,7 +2485,7 @@ void RMDialogChoice::show(CORO_PARAM, RMGfxTargetBuffer *bigBuf) { _ctx->starttime = _vm->getTime(); _ctx->deltay = 480 - _ptDrawPos.y; _ctx->destpt = _ptDrawPos; - _ptDrawPos.Set(0, 480); + _ptDrawPos.set(0, 480); if (!_nInList && bigBuf != NULL) bigBuf->addPrim(new RMGfxPrimitive(this)); diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index bf708ec075..c8a70d7b0f 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -124,11 +124,11 @@ void mainSetPalesati(bool bPalesati) { RMOptionButton::RMOptionButton(uint32 dwRes, RMPoint pt, bool bDoubleState) { RMResRaw raw(dwRes); - assert(raw.IsValid()); + assert(raw.isValid()); _buf = new RMGfxSourceBuffer16(false); - _buf->init(raw, raw.Width(), raw.Height()); + _buf->init(raw, raw.width(), raw.height()); - _rect.SetRect(pt.x, pt.y, pt.x + raw.Width() - 1, pt.y + raw.Height() - 1); + _rect.setRect(pt.x, pt.y, pt.x + raw.width() - 1, pt.y + raw.height() - 1); _bActive = false; _bHasGfx = true; _bDoubleState = bDoubleState; @@ -149,7 +149,7 @@ RMOptionButton::~RMOptionButton() { bool RMOptionButton::doFrame(const RMPoint &mousePos, bool bLeftClick, bool bRightClick) { if (!_bDoubleState) { - if (_rect.PtInRect(mousePos)) { + if (_rect.ptInRect(mousePos)) { if (!_bActive) { _bActive = true; return true; @@ -161,7 +161,7 @@ bool RMOptionButton::doFrame(const RMPoint &mousePos, bool bLeftClick, bool bRig } } } else { - if (bLeftClick && _rect.PtInRect(mousePos)) { + if (bLeftClick && _rect.ptInRect(mousePos)) { _bActive = !_bActive; return true; } @@ -511,12 +511,12 @@ void RMOptionScreen::refreshAll(CORO_PARAM) { RMString s; if (_bEditSaveName && _nEditPos == _ctx->i) - s.Format("%02d)%s*", _statePos + _ctx->i, _EditName); + s.format("%02d)%s*", _statePos + _ctx->i, _EditName); else { if (_statePos == 0 && _ctx->i == 0) - s.Format("Autosave"); + s.format("Autosave"); else - s.Format("%02d)%s", _statePos + _ctx->i, (const char *)_curThumbName[_ctx->i]); + s.format("%02d)%s", _statePos + _ctx->i, (const char *)_curThumbName[_ctx->i]); } _ctx->num[_ctx->i] = new RMText; @@ -585,10 +585,10 @@ void RMOptionScreen::initState(CORO_PARAM) { error("Invalid state"); } - assert(_ctx->raw->IsValid()); + assert(_ctx->raw->isValid()); assert(_menu == NULL); _menu = new RMGfxSourceBuffer16(false); - _menu->init(*_ctx->raw, _ctx->raw->Width(), _ctx->raw->Height()); + _menu->init(*_ctx->raw, _ctx->raw->width(), _ctx->raw->height()); delete _ctx->raw; if (_nState == MENULOAD || _nState == MENUSAVE) { @@ -647,10 +647,10 @@ void RMOptionScreen::initState(CORO_PARAM) { _ButtonSoundMenu = new RMOptionButton(RMRect(212, 32, 306, 64)); _ctx->raw = new RMResRaw(20021); - assert(_ctx->raw->IsValid()); + assert(_ctx->raw->isValid()); assert(_QuitConfirm == NULL); _QuitConfirm = new RMGfxSourceBuffer16(false); - _QuitConfirm->init(*_ctx->raw, _ctx->raw->Width(), _ctx->raw->Height()); + _QuitConfirm->init(*_ctx->raw, _ctx->raw->width(), _ctx->raw->height()); delete _ctx->raw; assert(_ButtonQuitYes == NULL); @@ -662,10 +662,10 @@ void RMOptionScreen::initState(CORO_PARAM) { if (_bNoLoadSave) { _ctx->raw = new RMResRaw(20028); - assert(_ctx->raw->IsValid()); + assert(_ctx->raw->isValid()); assert(_HideLoadSave == NULL); _HideLoadSave = new RMGfxSourceBuffer16(false); - _HideLoadSave->init(*_ctx->raw, _ctx->raw->Width(), _ctx->raw->Height()); + _HideLoadSave->init(*_ctx->raw, _ctx->raw->width(), _ctx->raw->height()); delete _ctx->raw; } @@ -1485,7 +1485,7 @@ void RMPointer::init(void) { RMResRaw res(RES_P_GO + i); _pointer[i] = new RMGfxSourceBuffer8RLEByteAA; - _pointer[i]->init(res, res.Width(), res.Height(), false); + _pointer[i]->init(res, res.width(), res.height(), false); _pointer[i]->loadPaletteWA(RES_P_PAL); } @@ -1493,17 +1493,17 @@ void RMPointer::init(void) { RMRes res(RES_P_PAP1 + i); RMDataStream ds; - ds.OpenBuffer(res); + ds.openBuffer(res); _specialPointer[i] = new RMItem; ds >> *_specialPointer[i]; } - //m_hotspot[0].Set(19,5); - _hotspot[0].Set(5, 1); - _hotspot[1].Set(32, 28); - _hotspot[2].Set(45, 23); - _hotspot[3].Set(35, 25); - _hotspot[4].Set(32, 28); + //m_hotspot[0].set(19,5); + _hotspot[0].set(5, 1); + _hotspot[1].set(32, 28); + _hotspot[2].set(45, 23); + _hotspot[3].set(35, 25); + _hotspot[4].set(32, 28); // Default=GO _nCurPointer = 0; diff --git a/engines/tony/game.h b/engines/tony/game.h index 5f387d558b..2d8f73f79b 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -39,18 +39,18 @@ namespace Tony { #define INIT_GFX16_FROMRAW(dwRes, buf16) \ raw = new RMResRaw(dwRes); \ - assert(raw->IsValid()); \ + assert(raw->isValid()); \ assert((buf16) == NULL); \ (buf16) = new RMGfxSourceBuffer16(false); \ - (buf16)->init(*raw,raw->Width(),raw->Height()); \ + (buf16)->init(*raw,raw->width(),raw->height()); \ delete raw; #define INIT_GFX8_FROMRAW(raw, dwRes, buf8) \ raw = new RMResRaw(dwRes); \ - assert(raw->IsValid()); \ + assert(raw->isValid()); \ assert((buf8) == NULL); \ (buf8) = new RMGfxSourceBuffer8RLEByte(); \ - (buf8)->init(*raw, raw->Width(), raw->Height(), true); \ + (buf8)->init(*raw, raw->width(), raw->height(), true); \ delete raw; diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 6369d91207..55a15a5961 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -146,7 +146,7 @@ int RMGfxSourceBuffer::init(const byte *buf, int dimx, int dimy, bool bLoadPalet void RMGfxSourceBuffer::init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette) { create(dimx, dimy, Bpp()); - ds.Read(_buf, dimx * dimy * Bpp() / 8); + ds.read(_buf, dimx * dimy * Bpp() / 8); // Invokes the method for preparing the surface (inherited) prepareImage(); @@ -448,7 +448,7 @@ void RMGfxSourceBufferPal::init(RMDataStream &ds, int dimx, int dimy, bool bLoad // Load the palette if necessary if (bLoadPalette) { byte *suxpal = new byte[256 * 3]; - ds.Read(suxpal, 256 * 3); + ds.read(suxpal, 256 * 3); loadPaletteWA(suxpal); delete[] suxpal; } @@ -512,8 +512,8 @@ void RMGfxSourceBuffer8::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimit u = prim->Src().x1; v = prim->Src().y1; - width = prim->Src().Width(); - height = prim->Src().Height(); + width = prim->Src().width(); + height = prim->Src().height(); } if (!clip2D(dst.x1, dst.y1, u, v, width, height, prim->haveSrc(), &bigBuf)) @@ -620,8 +620,8 @@ void RMGfxSourceBuffer8AB::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrim u = prim->Src().x1; v = prim->Src().y1; - width = prim->Src().Width(); - height = prim->Src().Height(); + width = prim->Src().width(); + height = prim->Src().height(); } if (!clip2D(dst.x1, dst.y1, u, v, width, height, prim->haveSrc(), &bigBuf)) @@ -702,7 +702,7 @@ void RMGfxSourceBuffer8RLE::init(RMDataStream &ds, int dimx, int dimy, bool bLoa ds >> size; _buf = new byte[size]; - ds.Read(_buf, size); + ds.read(_buf, size); _dimx = dimx; _dimy = dimy; @@ -1767,7 +1767,7 @@ void RMGfxSourceBuffer8RLEByteAA::init(RMDataStream &ds, int dimx, int dimy, boo if (!bNeedRLECompress) { // Load the anti-aliasing mask _aabuf = new byte[dimx * dimy]; - ds.Read(_aabuf, dimx * dimy); + ds.read(_aabuf, dimx * dimy); } } @@ -1805,7 +1805,7 @@ void RMGfxSourceBuffer8RLEWordAA::init(RMDataStream &ds, int dimx, int dimy, boo if (!bNeedRLECompress) { // Load the anti-aliasing mask _aabuf = new byte[dimx * dimy]; - ds.Read(_aabuf, dimx * dimy); + ds.read(_aabuf, dimx * dimy); } } @@ -1839,8 +1839,8 @@ void RMGfxSourceBuffer16::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimi if (prim->haveSrc()) { u = prim->Src().x1; v = prim->Src().y1; - dimx = prim->Src().Width(); - dimy = prim->Src().Height(); + dimx = prim->Src().width(); + dimy = prim->Src().height(); } if (prim->haveDst()) { @@ -1932,11 +1932,11 @@ void RMGfxBox::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) buf += rcDst.y1 * bigBuf.getDimx() + rcDst.x1; // Loop through the pixels - for (j = 0; j < rcDst.Height(); j++) { - for (i = 0; i < rcDst.Width(); i++) + for (j = 0; j < rcDst.height(); j++) { + for (i = 0; i < rcDst.width(); i++) *buf ++ = wFillColor; - buf += bigBuf.getDimx() - rcDst.Width(); + buf += bigBuf.getDimx() - rcDst.width(); } } diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index 2daa7edc6d..82f8383131 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -110,8 +110,8 @@ public: RMGfxPrimitive() { _bFlag = 0; _task = NULL; - _src.SetEmpty(); - _dst.SetEmpty(); + _src.setEmpty(); + _dst.setEmpty(); } RMGfxPrimitive(RMGfxTask *task) { @@ -124,41 +124,41 @@ public: _src = src; _dst = dst; _bFlag = 0; - _bStretch = (src.Width() != dst.Width() || src.Height() != dst.Height()); + _bStretch = (src.width() != dst.width() || src.height() != dst.height()); } RMGfxPrimitive(RMGfxTask *task, const RMPoint &src, RMRect &dst) { _task = task; - _src.TopLeft() = src; + _src.topLeft() = src; _dst = dst; _bFlag = 0; } RMGfxPrimitive(RMGfxTask *task, const RMPoint &src, RMPoint &dst) { _task = task; - _src.TopLeft() = src; - _dst.TopLeft() = dst; + _src.topLeft() = src; + _dst.topLeft() = dst; _bFlag = 0; } RMGfxPrimitive(RMGfxTask *task, const RMRect &src, RMPoint &dst) { _task = task; _src = src; - _dst.TopLeft() = dst; + _dst.topLeft() = dst; _bFlag = 0; } RMGfxPrimitive(RMGfxTask *task, const RMRect &dst) { _task = task; _dst = dst; - _src.SetEmpty(); + _src.setEmpty(); _bFlag = 0; } RMGfxPrimitive(RMGfxTask *task, const RMPoint &dst) { _task = task; - _dst.TopLeft() = dst; - _src.SetEmpty(); + _dst.topLeft() = dst; + _src.setEmpty(); _bFlag = 0; } @@ -174,27 +174,27 @@ public: _src = src; } void setSrc(const RMPoint &src) { - _src.TopLeft() = src; + _src.topLeft() = src; } void setDst(const RMRect &dst) { _dst = dst; } void setDst(const RMPoint &dst) { - _dst.TopLeft() = dst; + _dst.topLeft() = dst; } void setStrecth(bool bStretch) { _bStretch = bStretch; } bool haveDst() { - return !_dst.IsEmpty(); + return !_dst.isEmpty(); } RMRect &Dst() { return _dst; } bool haveSrc() { - return !_src.IsEmpty(); + return !_src.isEmpty(); } RMRect &Src() { return _src; diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 56ce8a47e1..b102323dce 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -412,7 +412,7 @@ uint32 RMGfxEngine::loadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { for (i = 0; i < 5; i++) { // Try the loading of the location RMRes res(_nCurLoc); - if (!res.IsValid()) + if (!res.isValid()) continue; _loc.load(res); diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp index 4990b379b9..36cad4c6a1 100644 --- a/engines/tony/input.cpp +++ b/engines/tony/input.cpp @@ -34,7 +34,7 @@ namespace Tony { RMInput::RMInput() { // Setup mouse fields _clampMouse = false; - _mousePos.Set(0, 0); + _mousePos.set(0, 0); _leftButton = _rightButton = false; _leftClickMouse = _leftReleaseMouse = false; _rightClickMouse = _rightReleaseMouse = false; @@ -60,7 +60,7 @@ void RMInput::poll(void) { case Common::EVENT_LBUTTONUP: case Common::EVENT_RBUTTONDOWN: case Common::EVENT_RBUTTONUP: - _mousePos.Set(_event.mouse.x, _event.mouse.y); + _mousePos.set(_event.mouse.x, _event.mouse.y); if (_event.type == Common::EVENT_LBUTTONDOWN) { _leftButton = true; diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index 5ff4f6cd10..c83402e724 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -97,13 +97,13 @@ void RMInventory::init(void) { RMRes res(curres); RMDataStream ds; - assert(res.IsValid()); + assert(res.isValid()); // Initialise the MPAL inventory item by reading it in. _items[i].icon.setInitCurPattern(false); - ds.OpenBuffer(res); + ds.openBuffer(res); ds >> _items[i].icon; - ds.Close(); + ds.close(); // Puts in the default pattern 1 _items[i].pointer = NULL; @@ -120,9 +120,9 @@ void RMInventory::init(void) { for (j = 0; j < _items[i].icon.numPattern(); j++) { RMResRaw raw(curres); - assert(raw.IsValid()); + assert(raw.isValid()); - _items[i].pointer[j].init((const byte *)raw, raw.Width(), raw.Height(), true); + _items[i].pointer[j].init((const byte *)raw, raw.width(), raw.height(), true); curres++; } } @@ -133,11 +133,11 @@ void RMInventory::init(void) { // Download interface RMDataStream ds; RMRes res(RES_I_MINIINTER); - assert(res.IsValid()); - ds.OpenBuffer(res); + assert(res.isValid()); + ds.openBuffer(res); ds >> miniInterface; miniInterface.setPattern(1); - ds.Close(); + ds.close(); // Create the text for hints on the mini interface _hints[0].setAlignType(RMText::HCENTER, RMText::VTOP); @@ -202,11 +202,11 @@ void RMInventory::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr if (_state == SELECTING) { if (!GLOBALS.bCfgInvUp) { - _ctx->pos.Set((_nSelectObj + 1) * 64 - 20, RM_SY - 113); - _ctx->pos2.Set((_nSelectObj + 1) * 64 + 34, RM_SY - 150); + _ctx->pos.set((_nSelectObj + 1) * 64 - 20, RM_SY - 113); + _ctx->pos2.set((_nSelectObj + 1) * 64 + 34, RM_SY - 150); } else { - _ctx->pos.Set((_nSelectObj + 1) * 64 - 20, 72 - 4); // The brown part is at the top :( - _ctx->pos2.Set((_nSelectObj + 1) * 64 + 34, 119 - 4); + _ctx->pos.set((_nSelectObj + 1) * 64 - 20, 72 - 4); // The brown part is at the top :( + _ctx->pos2.set((_nSelectObj + 1) * 64 + 34, 119 - 4); } _ctx->p = new RMGfxPrimitive(prim->_task, _ctx->pos); @@ -774,7 +774,7 @@ int RMInterface::onWhichBox(RMPoint pt) { // Find the verb for (i = 0; i < max; i++) - if (_hotbbox[i].PtInRect(pt)) + if (_hotbbox[i].ptInRect(pt)) return i; // Found no verb @@ -788,13 +788,13 @@ void RMInterface::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr CORO_BEGIN_CODE(_ctx); - prim->Dst().TopLeft() = _openStart; + prim->Dst().topLeft() = _openStart; CORO_INVOKE_2(RMGfxSourceBuffer8RLEByte::draw, bigBuf, prim); // Check if there is a draw hot zone _ctx->h = onWhichBox(_mpos); if (_ctx->h != -1) { - prim->Dst().TopLeft() = _openStart; + prim->Dst().topLeft() = _openStart; CORO_INVOKE_2(_hotzone[_ctx->h].draw, bigBuf, prim); if (_lastHotZone != _ctx->h) { @@ -803,7 +803,7 @@ void RMInterface::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr } if (GLOBALS.bCfgInterTips) { - prim->Dst().TopLeft() = _openStart + RMPoint(70, 177); + prim->Dst().topLeft() = _openStart + RMPoint(70, 177); CORO_INVOKE_2(_hints[_ctx->h].draw, bigBuf, prim); } } else @@ -896,21 +896,21 @@ void RMInterface::init(void) { setPriority(191); - RMGfxSourceBuffer::init(inter, inter.Width(), inter.Height()); + RMGfxSourceBuffer::init(inter, inter.width(), inter.height()); loadPaletteWA(RES_I_INTERPAL); for (i = 0; i < 5; i++) { RMResRaw part(RES_I_INTERP1 + i); - _hotzone[i].init(part, part.Width(), part.Height()); + _hotzone[i].init(part, part.width(), part.height()); _hotzone[i].loadPaletteWA(pal); } - _hotbbox[0].SetRect(126, 123, 159, 208); // Take - _hotbbox[1].SetRect(90, 130, 125, 186); // About - _hotbbox[2].SetRect(110, 60, 152, 125); - _hotbbox[3].SetRect(56, 51, 93, 99); - _hotbbox[4].SetRect(51, 105, 82, 172); + _hotbbox[0].setRect(126, 123, 159, 208); // Take + _hotbbox[1].setRect(90, 130, 125, 186); // About + _hotbbox[2].setRect(110, 60, 152, 125); + _hotbbox[3].setRect(56, 51, 93, 99); + _hotbbox[4].setRect(51, 105, 82, 172); _hints[0].setAlignType(RMText::HRIGHT, RMText::VTOP); _hints[1].setAlignType(RMText::HRIGHT, RMText::VTOP); diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index d2688140fb..48480389bb 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -50,7 +50,7 @@ using namespace ::Tony::MPAL; * @returns Reference to the data stream */ RMDataStream &operator>>(RMDataStream &ds, RMPalette &pal) { - ds.Read(pal._data, 1024); + ds.read(pal._data, 1024); return ds; } @@ -129,7 +129,7 @@ void RMPattern::readFromStream(RMDataStream &ds, bool bLOX) { // Create and read the slots _slots = new RMSlot[_nSlots]; - for (i = 0; i < _nSlots && !ds.IsError(); i++) { + for (i = 0; i < _nSlots && !ds.isError(); i++) { if (bLOX) _slots[i].readFromStream(ds, true); else @@ -319,20 +319,20 @@ void RMSprite::init(RMGfxSourceBuffer *buf) { } void RMSprite::LOXGetSizeFromStream(RMDataStream &ds, int *dimx, int *dimy) { - int pos = ds.Pos(); + int pos = ds.pos(); ds >> *dimx >> *dimy; - ds.Seek(pos, ds.START); + ds.seek(pos, ds.START); } void RMSprite::getSizeFromStream(RMDataStream &ds, int *dimx, int *dimy) { - int pos = ds.Pos(); + int pos = ds.pos(); ds >> _name; ds >> *dimx >> *dimy; - ds.Seek(pos, ds.START); + ds.seek(pos, ds.START); } void RMSprite::readFromStream(RMDataStream &ds, bool bLOX) { @@ -404,7 +404,7 @@ void RMSfx::readFromStream(RMDataStream &ds, bool bLOX) { ds >> size; // Upload the sound effect identifier from the buffer - ds.Read(id, 4); + ds.read(id, 4); // Ensure it's a RIFF assert(id[0] == 'R' && id[1] == 'I' && id[2] == 'F' && id[3] == 'F'); @@ -414,7 +414,7 @@ void RMSfx::readFromStream(RMDataStream &ds, bool bLOX) { // Read the raw WAV data raw = new byte[size]; - ds.Read(raw, size); + ds.read(raw, size); // Create the sound effect _fx = _vm->createSFX(raw); @@ -522,18 +522,18 @@ bool RMItem::isIn(const RMPoint &pt, int *size) { return false; // Search for the right bounding box to use - use the sprite's if it has one, otherwise use the generic one - if (_nCurPattern != 0 && !_sprites[_nCurSprite]._rcBox.IsEmpty()) + if (_nCurPattern != 0 && !_sprites[_nCurSprite]._rcBox.isEmpty()) rc = _sprites[_nCurSprite]._rcBox + calculatePos(); - else if (!_rcBox.IsEmpty()) + else if (!_rcBox.isEmpty()) rc = _rcBox; // If no box, return immediately else return false; if (size != NULL) - *size = rc.Size(); + *size = rc.size(); - return rc.PtInRect(pt + _curScroll); + return rc.ptInRect(pt + _curScroll); } void RMItem::readFromStream(RMDataStream &ds, bool bLOX) { @@ -592,8 +592,8 @@ void RMItem::readFromStream(RMDataStream &ds, bool bLOX) { _patterns = new RMPattern[_nPatterns + 1]; // Read in class data - if (!ds.IsError()) - for (i = 0; i < _nSprites && !ds.IsError(); i++) { + if (!ds.isError()) + for (i = 0; i < _nSprites && !ds.isError(); i++) { // Download the sprites if (bLOX) { _sprites[i].LOXGetSizeFromStream(ds, &dimx, &dimy); @@ -609,8 +609,8 @@ void RMItem::readFromStream(RMDataStream &ds, bool bLOX) { _sprites[i].setPalette(_pal._data); } - if (!ds.IsError()) - for (i = 0; i < _nSfx && !ds.IsError(); i++) { + if (!ds.isError()) + for (i = 0; i < _nSfx && !ds.isError(); i++) { if (bLOX) _sfx[i].readFromStream(ds, true); else @@ -618,8 +618,8 @@ void RMItem::readFromStream(RMDataStream &ds, bool bLOX) { } // Read the pattern from pattern 1 - if (!ds.IsError()) - for (i = 1; i <= _nPatterns && !ds.IsError(); i++) { + if (!ds.isError()) + for (i = 1; i <= _nPatterns && !ds.isError(); i++) { if (bLOX) _patterns[i].readFromStream(ds, true); else @@ -695,11 +695,11 @@ void RMItem::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { prim->setFlag(_bCurFlag); // Offset direction for scrolling - prim->Dst().Offset(-_curScroll); + prim->Dst().offset(-_curScroll); // We must offset the cordinates of the item inside the primitive // It is estimated as nonno + (babbo + figlio) - prim->Dst().Offset(calculatePos()); + prim->Dst().offset(calculatePos()); // No stretching, please prim->setStrecth(false); @@ -781,7 +781,7 @@ RMItem::RMItem() { _patterns = NULL; _sprites = NULL; _sfx = NULL; - _curScroll.Set(0, 0); + _curScroll.set(0, 0); _bInitCurPattern = true; _nCurPattern = 0; _z = 0; @@ -904,9 +904,9 @@ void RMWipe::initFade(int type) { RMRes res(RES_W_CERCHIO); RMDataStream ds; - ds.OpenBuffer(res); + ds.openBuffer(res); ds >> _wip0r; - ds.Close(); + ds.close(); _wip0r.setPattern(1); @@ -1688,7 +1688,7 @@ RMCharacter::RMCharacter() { bDrawNow = false; bNeedToStop = false; - _pos.Set(0, 0); + _pos.set(0, 0); } RMCharacter::~RMCharacter() { @@ -1824,14 +1824,14 @@ void RMGameBoxes::init(void) { for (i = 1; i <= _nLocBoxes; i++) { RMRes res(10000 + i); - ds.OpenBuffer(res); + ds.openBuffer(res); _allBoxes[i] = new RMBoxLoc(); ds >> *_allBoxes[i]; _allBoxes[i]->recalcAllAdj(); - ds.Close(); + ds.close(); } } @@ -1985,9 +1985,9 @@ bool RMLocation::load(Common::File &file) { RMFileStreamSlow fs; - fs.OpenFile(file); + fs.openFile(file); bRet = load(fs); - fs.Close(); + fs.close(); return bRet; } @@ -1997,9 +1997,9 @@ bool RMLocation::load(const byte *buf) { RMDataStream ds; bool bRet; - ds.OpenBuffer(buf); + ds.openBuffer(buf); bRet = load(ds); - ds.Close(); + ds.close(); return bRet; } @@ -2045,7 +2045,7 @@ bool RMLocation::load(RMDataStream &ds) { // Location dimensions ds >> dimx >> dimy; - _curScroll.Set(0, 0); + _curScroll.set(0, 0); // Read the colour mode ds >> cm; @@ -2081,11 +2081,11 @@ bool RMLocation::load(RMDataStream &ds) { _vm->freezeTime(); - for (i = 0; i < _nItems && !ds.IsError(); i++) + for (i = 0; i < _nItems && !ds.isError(); i++) ds >> _items[i]; _vm->unfreezeTime(); - return ds.IsError(); + return ds.isError(); } @@ -2107,7 +2107,7 @@ bool RMLocation::loadLOX(RMDataStream &ds) { // Dimensions ds >> dimx >> dimy; - _curScroll.Set(0, 0); + _curScroll.set(0, 0); // It's always 65K (16-bit) mode _cmode = CM_65K; @@ -2123,10 +2123,10 @@ bool RMLocation::loadLOX(RMDataStream &ds) { if (_nItems > 0) _items = new RMItem[_nItems]; - for (i = 0; i < _nItems && !ds.IsError(); i++) + for (i = 0; i < _nItems && !ds.isError(); i++) _items[i].readFromStream(ds, true); - return ds.IsError(); + return ds.isError(); } diff --git a/engines/tony/mpal/mpalutils.cpp b/engines/tony/mpal/mpalutils.cpp index 2e3bd07383..edc6e65ca1 100644 --- a/engines/tony/mpal/mpalutils.cpp +++ b/engines/tony/mpal/mpalutils.cpp @@ -37,42 +37,42 @@ namespace MPAL { * @param resId MPAL resource to open */ RMRes::RMRes(uint32 resID) { - m_h = _vm->_resUpdate.QueryResource(resID); - if (m_h == NULL) - m_h = mpalQueryResource(resID); - if (m_h != NULL) - m_buf = (byte *)GlobalLock(m_h); + _h = _vm->_resUpdate.queryResource(resID); + if (_h == NULL) + _h = mpalQueryResource(resID); + if (_h != NULL) + _buf = (byte *)GlobalLock(_h); } /** * Destructor */ RMRes::~RMRes() { - if (m_h != NULL) { - GlobalUnlock(m_h); - GlobalFree(m_h); + if (_h != NULL) { + GlobalUnlock(_h); + GlobalFree(_h); } } /** * Returns a pointer to the resource */ -const byte *RMRes::DataPointer() { - return m_buf; +const byte *RMRes::dataPointer() { + return _buf; } /** * Returns a pointer to the resource */ RMRes::operator const byte *() { - return DataPointer(); + return dataPointer(); } /** * Returns the size of the resource */ -unsigned int RMRes::Size() { - return GlobalSize(m_h); +unsigned int RMRes::size() { + return GlobalSize(_h); } /****************************************************************************\ @@ -86,19 +86,19 @@ RMResRaw::~RMResRaw() { } const byte *RMResRaw::DataPointer() { - return m_buf + 8; + return _buf + 8; } RMResRaw::operator const byte *() { return DataPointer(); } -int RMResRaw::Width() { - return READ_LE_UINT16(m_buf + 4); +int RMResRaw::width() { + return READ_LE_UINT16(_buf + 4); } -int RMResRaw::Height() { - return READ_LE_UINT16(m_buf + 6); +int RMResRaw::height() { + return READ_LE_UINT16(_buf + 6); } } // end of namespace MPAL diff --git a/engines/tony/mpal/mpalutils.h b/engines/tony/mpal/mpalutils.h index a9f8403fcd..a428a40a64 100644 --- a/engines/tony/mpal/mpalutils.h +++ b/engines/tony/mpal/mpalutils.h @@ -33,17 +33,17 @@ namespace MPAL { class RMRes { protected: - HGLOBAL m_h; - byte *m_buf; + HGLOBAL _h; + byte *_buf; public: RMRes(uint32 resID); virtual ~RMRes(); // Attributes - unsigned int Size(); - const byte *DataPointer(); - bool IsValid() { return m_h != NULL; } + unsigned int size(); + const byte *dataPointer(); + bool isValid() { return _h != NULL; } // Casting for access to data operator const byte*(); @@ -57,8 +57,8 @@ public: const byte *DataPointer(); operator const byte*(); - int Width(); - int Height(); + int width(); + int height(); }; } // end of namespace MPAL diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index abc3033993..72ea389e59 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -127,7 +127,7 @@ Common::ErrorCode TonyEngine::init() { return Common::kUnknownError; // Initialise the update resources - _resUpdate.Init("ROASTED.MPU"); + _resUpdate.init("ROASTED.MPU"); // Initialise the music initMusic(); diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index dc771b08aa..fb53d68615 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -105,18 +105,18 @@ void RMTony::init(void) { _bIsStaticTalk = false; // Opens the buffer - ds.OpenBuffer(tony); + ds.openBuffer(tony); // Reads his details from the stream readFromStream(ds, true); // Closes the buffer - ds.Close(); + ds.close(); // Reads Tony's body - ds.OpenBuffer(body); + ds.openBuffer(body); _body.readFromStream(ds, true); - ds.Close(); + ds.close(); _body.setPattern(0); _nTimeLastStep = _vm->getTime(); @@ -180,28 +180,28 @@ void RMTony::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { // Call the Draw() of the parent class if Tony is visible if (_bShow && bDrawNow) { if (_bCorpoDavanti) { - prim->Dst().SetEmpty(); - prim->Dst().Offset(-44, -134); + prim->Dst().setEmpty(); + prim->Dst().offset(-44, -134); if (_bPastorella) - prim->Dst().Offset(1, 4); + prim->Dst().offset(1, 4); CORO_INVOKE_2(RMCharacter::draw, bigBuf, prim); } if (_bIsTalking || _bIsStaticTalk) { // Offest direction from scrolling - prim->Dst().SetEmpty(); - prim->Dst().Offset(-_curScroll); - prim->Dst().Offset(_pos); - prim->Dst().Offset(-44, -134); + prim->Dst().setEmpty(); + prim->Dst().offset(-_curScroll); + prim->Dst().offset(_pos); + prim->Dst().offset(-44, -134); prim->Dst() += _nBodyOffset; CORO_INVOKE_2(_body.draw, bigBuf, prim); } if (!_bCorpoDavanti) { - prim->Dst().SetEmpty(); - prim->Dst().Offset(-44, -134); + prim->Dst().setEmpty(); + prim->Dst().offset(-44, -134); if (_bPastorella) - prim->Dst().Offset(0, 3); + prim->Dst().offset(0, 3); CORO_INVOKE_2(RMCharacter::draw, bigBuf, prim); } } @@ -630,25 +630,25 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case DOWN: headLoopPat = PAT_TALK_DOWN; bodyLoopPat = BPAT_STANDDOWN; - _nBodyOffset.Set(4, 53); + _nBodyOffset.set(4, 53); break; case LEFT: headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_STANDLEFT; - _nBodyOffset.Set(6, 56); + _nBodyOffset.set(6, 56); break; case RIGHT: headLoopPat = PAT_TALK_RIGHT; bodyLoopPat = BPAT_STANDRIGHT; - _nBodyOffset.Set(6, 56); + _nBodyOffset.set(6, 56); break; case UP: headLoopPat = PAT_TALK_UP; bodyLoopPat = BPAT_STANDUP; - _nBodyOffset.Set(6, 53); + _nBodyOffset.set(6, 53); break; } break; @@ -657,7 +657,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body _bCorpoDavanti = false; switch (_TalkDirection) { case UP: - _nBodyOffset.Set(2, 42); + _nBodyOffset.set(2, 42); headStartPat = PAT_TESTA_UP; bodyStartPat = BPAT_FIANCHIUP_START; headLoopPat = PAT_TALK_UP; @@ -665,7 +665,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case DOWN: - _nBodyOffset.Set(2, 48); + _nBodyOffset.set(2, 48); headStartPat = PAT_TESTA_DOWN; bodyStartPat = BPAT_FIANCHIDOWN_START; headLoopPat = PAT_TALK_DOWN; @@ -673,7 +673,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case LEFT: - _nBodyOffset.Set(-3, 53); + _nBodyOffset.set(-3, 53); headStartPat = PAT_TESTA_LEFT; bodyStartPat = BPAT_FIANCHILEFT_START; headLoopPat = PAT_TALK_LEFT; @@ -681,7 +681,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case RIGHT: - _nBodyOffset.Set(2, 53); + _nBodyOffset.set(2, 53); headStartPat = PAT_TESTA_RIGHT; bodyStartPat = BPAT_FIANCHIRIGHT_START; headLoopPat = PAT_TALK_RIGHT; @@ -692,7 +692,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case TALK_CANTA: - _nBodyOffset.Set(-10, 25); + _nBodyOffset.set(-10, 25); headStartPat = PAT_TESTA_LEFT; bodyStartPat = BPAT_CANTALEFT_START; headLoopPat = PAT_TALK_LEFT; @@ -705,7 +705,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case UP: case DOWN: case LEFT: - _nBodyOffset.Set(6, 56); + _nBodyOffset.set(6, 56); headStartPat = PAT_RIDELEFT_START; bodyStartPat = BPAT_STANDLEFT; headLoopPat = PAT_RIDELEFT_LOOP; @@ -713,7 +713,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case RIGHT: - _nBodyOffset.Set(6, 56); + _nBodyOffset.set(6, 56); headStartPat = PAT_RIDERIGHT_START; bodyStartPat = BPAT_STANDRIGHT; headLoopPat = PAT_RIDERIGHT_LOOP; @@ -728,14 +728,14 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case UP: case DOWN: case LEFT: - _nBodyOffset.Set(6, 56); + _nBodyOffset.set(6, 56); headStartPat = PAT_RIDELEFT_START; bodyStartPat = BPAT_STANDLEFT; headLoopPat = PAT_RIDELEFT_LOOP; break; case RIGHT: - _nBodyOffset.Set(6, 56); + _nBodyOffset.set(6, 56); headStartPat = PAT_RIDERIGHT_START; bodyStartPat = BPAT_STANDRIGHT; headLoopPat = PAT_RIDERIGHT_LOOP; @@ -750,13 +750,13 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case UP: case DOWN: case LEFT: - _nBodyOffset.Set(-4, 40); + _nBodyOffset.set(-4, 40); headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_SIINDICALEFT; break; case RIGHT: - _nBodyOffset.Set(5, 40); + _nBodyOffset.set(5, 40); headLoopPat = PAT_TALK_RIGHT; bodyLoopPat = BPAT_SIINDICARIGHT; break; @@ -766,7 +766,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case TALK_SPAVENTATO: switch (_TalkDirection) { case UP: - _nBodyOffset.Set(-4, -11); + _nBodyOffset.set(-4, -11); headStartPat = PAT_TESTA_UP; bodyStartPat = BPAT_SPAVENTOUP_START; headLoopPat = PAT_TALK_UP; @@ -774,7 +774,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case DOWN: - _nBodyOffset.Set(-5, 45); + _nBodyOffset.set(-5, 45); headStartPat = PAT_SPAVENTODOWN_START; bodyStartPat = BPAT_SPAVENTODOWN_START; headLoopPat = PAT_SPAVENTODOWN_LOOP; @@ -782,7 +782,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case RIGHT: - _nBodyOffset.Set(-4, 41); + _nBodyOffset.set(-4, 41); headStartPat = PAT_SPAVENTORIGHT_START; bodyStartPat = BPAT_SPAVENTORIGHT_START; headLoopPat = PAT_SPAVENTORIGHT_LOOP; @@ -790,7 +790,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case LEFT: - _nBodyOffset.Set(-10, 41); + _nBodyOffset.set(-10, 41); headStartPat = PAT_SPAVENTOLEFT_START; bodyStartPat = BPAT_SPAVENTOLEFT_START; headLoopPat = PAT_SPAVENTOLEFT_LOOP; @@ -805,7 +805,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case UP: bodyStartPat = BPAT_STANDUP; bodyLoopPat = BPAT_STANDUP; - _nBodyOffset.Set(6, 53); + _nBodyOffset.set(6, 53); headStartPat = PAT_TESTA_UP; headLoopPat = PAT_TALK_UP; @@ -814,7 +814,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case DOWN: bodyStartPat = BPAT_STANDDOWN; bodyLoopPat = BPAT_STANDDOWN; - _nBodyOffset.Set(4, 53); + _nBodyOffset.set(4, 53); headStartPat = PAT_SPAVENTODOWN_START; headLoopPat = PAT_SPAVENTODOWN_LOOP; @@ -823,7 +823,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case RIGHT: bodyStartPat = BPAT_STANDRIGHT; bodyLoopPat = BPAT_STANDRIGHT; - _nBodyOffset.Set(6, 56); + _nBodyOffset.set(6, 56); headStartPat = PAT_SPAVENTORIGHT_START; headLoopPat = PAT_SPAVENTORIGHT_LOOP; @@ -832,7 +832,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case LEFT: bodyStartPat = BPAT_STANDLEFT; bodyLoopPat = BPAT_STANDLEFT; - _nBodyOffset.Set(6, 56); + _nBodyOffset.set(6, 56); headStartPat = PAT_SPAVENTOLEFT_START; headLoopPat = PAT_SPAVENTOLEFT_LOOP; @@ -841,27 +841,27 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case TALK_CONBICCHIERE: - _nBodyOffset.Set(4, 53); + _nBodyOffset.set(4, 53); headLoopPat = PAT_TALK_DOWN; bodyLoopPat = BPAT_BICCHIERE; break; case TALK_CONVERME: - _nBodyOffset.Set(9, 56); + _nBodyOffset.set(9, 56); headLoopPat = PAT_TALK_RIGHT; bodyLoopPat = BPAT_VERME; break; case TALK_CONMARTELLO: - _nBodyOffset.Set(6, 56); + _nBodyOffset.set(6, 56); headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_MARTELLO; break; case TALK_CONCORDA: - _nBodyOffset.Set(-3, 38); + _nBodyOffset.set(-3, 38); headLoopPat = PAT_TALK_RIGHT; bodyLoopPat = BPAT_CORDA; break; case TALK_CONSEGRETARIA: - _nBodyOffset.Set(-17, 12); + _nBodyOffset.set(-17, 12); headLoopPat = PAT_TALK_RIGHT; bodyLoopPat = BPAT_CONSEGRETARIA; break; @@ -870,7 +870,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body switch (_TalkDirection) { case LEFT: case UP: - _nBodyOffset.Set(-21, -5); + _nBodyOffset.set(-21, -5); bodyStartPat = BPAT_CONCONIGLIOLEFT_START; headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_CONCONIGLIOLEFT_LOOP; @@ -878,7 +878,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case DOWN: case RIGHT: - _nBodyOffset.Set(-4, -5); + _nBodyOffset.set(-4, -5); bodyStartPat = BPAT_CONCONIGLIORIGHT_START; headLoopPat = PAT_TALK_RIGHT; bodyLoopPat = BPAT_CONCONIGLIORIGHT_LOOP; @@ -890,7 +890,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body switch (_TalkDirection) { case LEFT: case UP: - _nBodyOffset.Set(-61, -7); + _nBodyOffset.set(-61, -7); bodyStartPat = BPAT_CONRICETTALEFT_START; headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_CONRICETTALEFT_LOOP; @@ -898,7 +898,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case DOWN: case RIGHT: - _nBodyOffset.Set(-5, -7); + _nBodyOffset.set(-5, -7); bodyStartPat = BPAT_CONRICETTARIGHT_START; headLoopPat = PAT_TALK_RIGHT; bodyLoopPat = BPAT_CONRICETTARIGHT_LOOP; @@ -910,7 +910,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body switch (_TalkDirection) { case LEFT: case UP: - _nBodyOffset.Set(-34, -2); + _nBodyOffset.set(-34, -2); bodyStartPat = BPAT_CONCARTELEFT_START; headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_CONCARTELEFT_LOOP; @@ -918,7 +918,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case DOWN: case RIGHT: - _nBodyOffset.Set(-4, -2); + _nBodyOffset.set(-4, -2); bodyStartPat = BPAT_CONCARTERIGHT_START; headLoopPat = PAT_TALK_RIGHT; bodyLoopPat = BPAT_CONCARTERIGHT_LOOP; @@ -930,7 +930,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body switch (_TalkDirection) { case LEFT: case UP: - _nBodyOffset.Set(-35, 2); + _nBodyOffset.set(-35, 2); bodyStartPat = BPAT_CONPUPAZZOLEFT_START; headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_CONPUPAZZOLEFT_LOOP; @@ -938,7 +938,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case DOWN: case RIGHT: - _nBodyOffset.Set(-14, 2); + _nBodyOffset.set(-14, 2); bodyStartPat = BPAT_CONPUPAZZORIGHT_START; headLoopPat = PAT_TALK_RIGHT; bodyLoopPat = BPAT_CONPUPAZZORIGHT_LOOP; @@ -972,14 +972,14 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case UP: headLoopPat = PAT_TALKBARBA_LEFT; bodyLoopPat = BPAT_STANDLEFT; - _nBodyOffset.Set(6, 56); + _nBodyOffset.set(6, 56); break; case DOWN: case RIGHT: headLoopPat = PAT_TALKBARBA_RIGHT; bodyLoopPat = BPAT_STANDRIGHT; - _nBodyOffset.Set(6, 56); + _nBodyOffset.set(6, 56); break; } break; @@ -988,7 +988,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body switch (_TalkDirection) { case LEFT: case UP: - _nBodyOffset.Set(6, 56); + _nBodyOffset.set(6, 56); headStartPat = PAT_SCHIFATOLEFT_START; bodyStartPat = BPAT_STANDLEFT; headLoopPat = PAT_SCHIFATOLEFT_LOOP; @@ -996,7 +996,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case DOWN: case RIGHT: - _nBodyOffset.Set(6, 56); + _nBodyOffset.set(6, 56); headStartPat = PAT_SCHIFATORIGHT_START; bodyStartPat = BPAT_STANDRIGHT; headLoopPat = PAT_SCHIFATORIGHT_LOOP; @@ -1008,7 +1008,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body switch (_TalkDirection) { case LEFT: case UP: - _nBodyOffset.Set(6, 56); + _nBodyOffset.set(6, 56); headStartPat = PAT_NAAHLEFT_START; bodyStartPat = BPAT_STANDLEFT; headLoopPat = PAT_NAAHLEFT_LOOP; @@ -1016,7 +1016,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case DOWN: case RIGHT: - _nBodyOffset.Set(6, 56); + _nBodyOffset.set(6, 56); headStartPat = PAT_NAAHRIGHT_START; bodyStartPat = BPAT_STANDRIGHT; headLoopPat = PAT_NAAHRIGHT_LOOP; @@ -1025,47 +1025,47 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case TALK_MACBETH1: - _nBodyOffset.Set(-33, -1); + _nBodyOffset.set(-33, -1); headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_MACBETH1; break; case TALK_MACBETH2: - _nBodyOffset.Set(-33, -1); + _nBodyOffset.set(-33, -1); headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_MACBETH2; break; case TALK_MACBETH3: - _nBodyOffset.Set(-33, -1); + _nBodyOffset.set(-33, -1); headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_MACBETH3; break; case TALK_MACBETH4: - _nBodyOffset.Set(-33, -1); + _nBodyOffset.set(-33, -1); headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_MACBETH4; break; case TALK_MACBETH5: - _nBodyOffset.Set(-33, -1); + _nBodyOffset.set(-33, -1); headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_MACBETH5; break; case TALK_MACBETH6: - _nBodyOffset.Set(-33, -1); + _nBodyOffset.set(-33, -1); headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_MACBETH6; break; case TALK_MACBETH7: - _nBodyOffset.Set(-33, -1); + _nBodyOffset.set(-33, -1); headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_MACBETH7; break; case TALK_MACBETH8: - _nBodyOffset.Set(-33, -1); + _nBodyOffset.set(-33, -1); headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_MACBETH8; break; case TALK_MACBETH9: - _nBodyOffset.Set(-33, -1); + _nBodyOffset.set(-33, -1); headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_MACBETH9; break; @@ -1076,7 +1076,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case DOWN: bodyStartPat = BPAT_STANDDOWN; bodyLoopPat = BPAT_STANDDOWN; - _nBodyOffset.Set(4, 53); + _nBodyOffset.set(4, 53); headStartPat = PAT_SPAVENTODOWN_STAND; headLoopPat = PAT_SPAVENTODOWN_LOOP; @@ -1085,7 +1085,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case RIGHT: bodyStartPat = BPAT_STANDRIGHT; bodyLoopPat = BPAT_STANDRIGHT; - _nBodyOffset.Set(6, 56); + _nBodyOffset.set(6, 56); headStartPat = PAT_SPAVENTORIGHT_STAND; headLoopPat = PAT_SPAVENTORIGHT_LOOP; @@ -1094,7 +1094,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case LEFT: bodyStartPat = BPAT_STANDLEFT; bodyLoopPat = BPAT_STANDLEFT; - _nBodyOffset.Set(6, 56); + _nBodyOffset.set(6, 56); headStartPat = PAT_SPAVENTOLEFT_STAND; headLoopPat = PAT_SPAVENTOLEFT_LOOP; @@ -1450,10 +1450,10 @@ void RMTony::endTalk(CORO_PARAM) { setPattern(0); if (_TalkDirection == UP || _TalkDirection == LEFT) { _body.setPattern(BPAT_CONBARBALEFT_STATIC); - _nBodyOffset.Set(-41, -14); + _nBodyOffset.set(-41, -14); } else if (_TalkDirection == DOWN || _TalkDirection == RIGHT) { _body.setPattern(BPAT_CONBARBARIGHT_STATIC); - _nBodyOffset.Set(-26, -14); + _nBodyOffset.set(-26, -14); } mainUnfreeze(); } else { @@ -1564,14 +1564,14 @@ void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat switch (_TalkDirection) { case UP: case LEFT: - _nBodyOffset.Set(-21, -5); + _nBodyOffset.set(-21, -5); bodyStartPat = BPAT_CONCONIGLIOLEFT_START; bodyLoopPat = BPAT_CONCONIGLIOLEFT_LOOP; break; case DOWN: case RIGHT: - _nBodyOffset.Set(-4, -5); + _nBodyOffset.set(-4, -5); bodyStartPat = BPAT_CONCONIGLIORIGHT_START; bodyLoopPat = BPAT_CONCONIGLIORIGHT_LOOP; break; @@ -1582,14 +1582,14 @@ void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat switch (_TalkDirection) { case UP: case LEFT: - _nBodyOffset.Set(-34, -2); + _nBodyOffset.set(-34, -2); bodyStartPat = BPAT_CONCARTELEFT_START; bodyLoopPat = BPAT_CONCARTELEFT_LOOP; break; case DOWN: case RIGHT: - _nBodyOffset.Set(-4, -2); + _nBodyOffset.set(-4, -2); bodyStartPat = BPAT_CONCARTERIGHT_START; bodyLoopPat = BPAT_CONCARTERIGHT_LOOP; break; @@ -1600,14 +1600,14 @@ void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat switch (_TalkDirection) { case UP: case LEFT: - _nBodyOffset.Set(-61, -7); + _nBodyOffset.set(-61, -7); bodyStartPat = BPAT_CONRICETTALEFT_START; bodyLoopPat = BPAT_CONRICETTALEFT_LOOP; break; case DOWN: case RIGHT: - _nBodyOffset.Set(-5, -7); + _nBodyOffset.set(-5, -7); bodyStartPat = BPAT_CONRICETTARIGHT_START; bodyLoopPat = BPAT_CONRICETTARIGHT_LOOP; break; @@ -1618,14 +1618,14 @@ void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat switch (_TalkDirection) { case UP: case LEFT: - _nBodyOffset.Set(-35, 2); + _nBodyOffset.set(-35, 2); bodyStartPat = BPAT_CONPUPAZZOLEFT_START; bodyLoopPat = BPAT_CONPUPAZZOLEFT_LOOP; break; case DOWN: case RIGHT: - _nBodyOffset.Set(-14, 2); + _nBodyOffset.set(-14, 2); bodyStartPat = BPAT_CONPUPAZZORIGHT_START; bodyLoopPat = BPAT_CONPUPAZZORIGHT_LOOP; break; @@ -1636,14 +1636,14 @@ void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat switch (_TalkDirection) { case UP: case LEFT: - _nBodyOffset.Set(-16, -9); + _nBodyOffset.set(-16, -9); bodyStartPat = BPAT_CONTACCUINOLEFT_START; bodyLoopPat = BPAT_CONTACCUINOLEFT_LOOP; break; case DOWN: case RIGHT: - _nBodyOffset.Set(-6, -9); + _nBodyOffset.set(-6, -9); bodyStartPat = BPAT_CONTACCUINORIGHT_START; bodyLoopPat = BPAT_CONTACCUINORIGHT_LOOP; break; @@ -1654,14 +1654,14 @@ void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat switch (_TalkDirection) { case UP: case LEFT: - _nBodyOffset.Set(-41, -8); + _nBodyOffset.set(-41, -8); bodyStartPat = BPAT_CONMEGAFONOLEFT_START; bodyLoopPat = BPAT_CONMEGAFONOLEFT_LOOP; break; case DOWN: case RIGHT: - _nBodyOffset.Set(-14, -8); + _nBodyOffset.set(-14, -8); bodyStartPat = BPAT_CONMEGAFONORIGHT_START; bodyLoopPat = BPAT_CONMEGAFONORIGHT_LOOP; break; @@ -1672,7 +1672,7 @@ void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat switch (_TalkDirection) { case UP: case LEFT: - _nBodyOffset.Set(-41, -14); + _nBodyOffset.set(-41, -14); bodyStartPat = BPAT_CONBARBALEFT_START; bodyLoopPat = BPAT_STANDLEFT; headLoopPat = PAT_TALKBARBA_LEFT; @@ -1681,7 +1681,7 @@ void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat case DOWN: case RIGHT: - _nBodyOffset.Set(-26, -14); + _nBodyOffset.set(-26, -14); bodyStartPat = BPAT_CONBARBARIGHT_START; bodyLoopPat = BPAT_STANDRIGHT; headLoopPat = PAT_TALKBARBA_RIGHT; @@ -1697,7 +1697,7 @@ void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat bodyLoopPat = BPAT_STANDDOWN; bodyStartPat = BPAT_STANDDOWN; headLoopPat = PAT_SPAVENTODOWN_STAND; - _nBodyOffset.Set(4, 53); + _nBodyOffset.set(4, 53); break; case LEFT: @@ -1705,7 +1705,7 @@ void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat bodyLoopPat = BPAT_STANDLEFT; bodyStartPat = BPAT_STANDLEFT; headLoopPat = PAT_SPAVENTOLEFT_STAND; - _nBodyOffset.Set(6, 56); + _nBodyOffset.set(6, 56); break; case RIGHT: @@ -1713,7 +1713,7 @@ void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat bodyLoopPat = BPAT_STANDRIGHT; bodyStartPat = BPAT_STANDRIGHT; headLoopPat = PAT_SPAVENTORIGHT_STAND; - _nBodyOffset.Set(6, 56); + _nBodyOffset.set(6, 56); break; default: diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index 92b896b180..f11c9e6a2f 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -40,17 +40,17 @@ namespace Tony { * Constructor */ RMString::RMString() { - m_string = NULL; - m_length = 0; - m_realLength = 0; + _string = NULL; + _length = 0; + _realLength = 0; } /** * Destructor */ RMString::~RMString() { - if (m_string != NULL) - delete[] m_string; + if (_string != NULL) + delete[] _string; } /** @@ -58,9 +58,9 @@ RMString::~RMString() { */ RMString::RMString(const RMString &str) { // Richiama l'overload su '=' per copiare - m_string = NULL; - m_length = 0; - m_realLength = 0; + _string = NULL; + _length = 0; + _realLength = 0; *this = str; } @@ -69,9 +69,9 @@ RMString::RMString(const RMString &str) { */ RMString::RMString(const char *str) { // Use the overloaded '=' when copying - m_string = NULL; - m_length = 0; - m_realLength = 0; + _string = NULL; + _length = 0; + _realLength = 0; *this = str; } @@ -80,9 +80,9 @@ RMString::RMString(const char *str) { */ RMString::RMString(const int ch) { // Use the overloaded '=' when copying - m_string = NULL; - m_length = 0; - m_realLength = 0; + _string = NULL; + _length = 0; + _realLength = 0; *this = ch; } @@ -90,8 +90,8 @@ RMString::RMString(const int ch) { * Returns the length of the string * @returns Length */ -int RMString::Length() const { - return m_length; +int RMString::length() const { + return _length; } /** @@ -99,9 +99,9 @@ int RMString::Length() const { * @param nIndex Position of the character to return * @returns Character */ -char RMString::GetAt(int nIndex) { - assert(nIndex < m_length); - return m_string[nIndex]; +char RMString::getAt(int nIndex) { + assert(nIndex < _length); + return _string[nIndex]; } /** @@ -109,9 +109,9 @@ char RMString::GetAt(int nIndex) { * @param nIndex Position of the character to change * @param c Character */ -void RMString::SetAt(int nIndex, char c) { - assert(nIndex < m_length); - m_string[nIndex] = c; +void RMString::setAt(int nIndex, char c) { + assert(nIndex < _length); + _string[nIndex] = c; } /** @@ -120,8 +120,8 @@ void RMString::SetAt(int nIndex, char c) { * @params Reference to the character */ char &RMString::operator[](int nIndex) { - assert(nIndex < m_length); - return m_string[nIndex]; + assert(nIndex < _length); + return _string[nIndex]; } /** @@ -131,21 +131,21 @@ char &RMString::operator[](int nIndex) { */ const RMString &RMString::operator=(const RMString &str) { // Set the new length - m_length = str.m_length; + _length = str._length; // If the source is empty, then destroy the current string buffer - if (m_length == 0) { - if (m_realLength > 0) { - delete[] m_string; - m_string = NULL; - m_realLength = 0; + if (_length == 0) { + if (_realLength > 0) { + delete[] _string; + _string = NULL; + _realLength = 0; } } else { // Resize if necessary - Resize(m_length + 1); + resize(_length + 1); // Copy the string - Common::copy(str.m_string, str.m_string + m_length + 1, m_string); + Common::copy(str._string, str._string + _length + 1, _string); } return *this; @@ -159,20 +159,20 @@ const RMString &RMString::operator=(const RMString &str) { const RMString &RMString::operator=(const char *str) { // If the source is empty, then destroy the current string buffer if (str == NULL) { - if (m_realLength > 0) { - delete[] m_string; - m_string = NULL; - m_realLength = m_length = 0; + if (_realLength > 0) { + delete[] _string; + _string = NULL; + _realLength = _length = 0; } } else { // Calculate the new length - m_length = strlen(str); + _length = strlen(str); // Resize if necessary - Resize(m_length + 1); + resize(_length + 1); // Copy the string - Common::copy(str, str + m_length + 1, m_string); + Common::copy(str, str + _length + 1, _string); } return *this; @@ -186,18 +186,18 @@ const RMString &RMString::operator=(const char *str) { const RMString &RMString::operator=(const int ch) { if (ch == '\0') { // Destroy the current string - if (m_realLength > 0) { - delete [] m_string; - m_string = NULL; - m_length = m_realLength = 0; + if (_realLength > 0) { + delete [] _string; + _string = NULL; + _length = _realLength = 0; } } else { // Resize if necessary - Resize(2); + resize(2); - m_string[0] = ch; - m_string[1] = '\0'; - m_length = 1; + _string[0] = ch; + _string[1] = '\0'; + _length = 1; } return *this; @@ -208,21 +208,21 @@ const RMString &RMString::operator=(const int ch) { * @param str String to concatenate * @param size Length of the string */ -void RMString::Connect(const char *str, int size) { +void RMString::connect(const char *str, int size) { int nlen; if (size > 0) { // Calculate the new lenght - nlen = m_length + size; + nlen = _length + size; // Resize - Resize(nlen + 1, true); + resize(nlen + 1, true); // Linkage with '\0' - Common::copy(str, str + size + 1, m_string + m_length); + Common::copy(str, str + size + 1, _string + _length); // Save the new length - m_length = nlen; + _length = nlen; } } @@ -232,7 +232,7 @@ void RMString::Connect(const char *str, int size) { * @returns Refrence to our string */ const RMString &RMString::operator+=(RMString &str) { - Connect(str, str.Length()); + connect(str, str.length()); return *this; } @@ -242,7 +242,7 @@ const RMString &RMString::operator+=(RMString &str) { * @returns Refrence to our string */ const RMString &RMString::operator+=(const char *str) { - Connect(str, strlen(str)); + connect(str, strlen(str)); return *this; } @@ -258,7 +258,7 @@ const RMString &RMString::operator+=(const int ch) { str[0] = ch; str[1] = '\0'; - Connect(str, 1); + connect(str, 1); return *this; } @@ -267,7 +267,7 @@ const RMString &RMString::operator+=(const int ch) { * @returns char * reference to string */ RMString::operator char *() const { - return m_string; + return _string; } /** @@ -276,21 +276,21 @@ RMString::operator char *() const { * @param bMaintain If true we must keep the original string, if false we can destroy. */ -void RMString::Resize(int size, bool bMantain) { - if (m_realLength == 0) { - m_string = new char[size]; - m_realLength = size; - } else if (size > m_realLength) { +void RMString::resize(int size, bool bMantain) { + if (_realLength == 0) { + _string = new char[size]; + _realLength = size; + } else if (size > _realLength) { if (bMantain) { char *app; app = new char[size]; - Common::copy(m_string, m_string + m_length + 1, app); - delete[] m_string; - m_string = app; + Common::copy(_string, _string + _length + 1, app); + delete[] _string; + _string = app; } else { - delete[] m_string; - m_string = new char[size]; + delete[] _string; + _string = new char[size]; } } } @@ -298,15 +298,15 @@ void RMString::Resize(int size, bool bMantain) { /** * Compacts the string to occupy less memory if possible. */ -void RMString::Compact(void) { - if (m_realLength + 1 > m_length) { +void RMString::compact(void) { + if (_realLength + 1 > _length) { char *app; - app = new char[m_length + 1]; - Common::copy(m_string, m_string + m_length + 1, app); + app = new char[_length + 1]; + Common::copy(_string, _string + _length + 1, app); - delete[] m_string; - m_string = app; + delete[] _string; + _string = app; } } @@ -359,14 +359,14 @@ RMDataStream &operator>>(RMDataStream &df, RMString &var) { int i; df >> len; - var.Resize(len + 1); - var.m_length = len + 1; + var.resize(len + 1); + var._length = len + 1; for (i = 0; i < len; i++) df >> var[i]; var[i] = '\0'; - var.m_length = len; + var._length = len; return df; } @@ -374,7 +374,7 @@ RMDataStream &operator>>(RMDataStream &df, RMString &var) { /** * Formats a string */ -void RMString::Format(const char *str, ...) { +void RMString::format(const char *str, ...) { static char buf[2048]; va_list argList; @@ -393,29 +393,29 @@ RMFileStreamSlow::RMFileStreamSlow() : RMDataStream() { } RMFileStreamSlow::~RMFileStreamSlow() { - Close(); + close(); } -void RMFileStreamSlow::Close() { +void RMFileStreamSlow::close() { delete _stream; } -bool RMFileStreamSlow::OpenFile(Common::File &file) { +bool RMFileStreamSlow::openFile(Common::File &file) { _stream = file.readStream(file.size()); - m_length = _stream->pos(); + _length = _stream->pos(); return true; } -bool RMFileStreamSlow::OpenFile(const char *lpFN) { +bool RMFileStreamSlow::openFile(const char *lpFN) { // Open file for reading Common::File f; if (!f.open(lpFN)) return false; - m_length = f.size(); + _length = f.size(); _stream = f.readStream(f.size()); return true; @@ -423,20 +423,20 @@ bool RMFileStreamSlow::OpenFile(const char *lpFN) { RMDataStream &RMFileStreamSlow::operator+=(int nBytes) { - Seek(nBytes); + seek(nBytes); return *this; } -int RMFileStreamSlow::Pos() { +int RMFileStreamSlow::pos() { return _stream->pos(); } -bool RMFileStreamSlow::IsEOF() { - return (Pos() >= m_length); +bool RMFileStreamSlow::isEOF() { + return (pos() >= _length); } -int RMFileStreamSlow::Seek(int nBytes, RMDSPos where) { +int RMFileStreamSlow::seek(int nBytes, RMDSPos where) { switch (where) { case START: return _stream->seek(nBytes); @@ -453,7 +453,7 @@ int RMFileStreamSlow::Seek(int nBytes, RMDSPos where) { } -bool RMFileStreamSlow::Read(void *buf, int size) { +bool RMFileStreamSlow::read(void *buf, int size) { uint32 dwRead; dwRead = _stream->read(buf, size); @@ -462,39 +462,39 @@ bool RMFileStreamSlow::Read(void *buf, int size) { RMFileStreamSlow &operator>>(RMFileStreamSlow &df, char &var) { - df.Read(&var, 1); + df.read(&var, 1); return df; } RMFileStreamSlow &operator>>(RMFileStreamSlow &df, byte &var) { - df.Read(&var, 1); + df.read(&var, 1); return df; } RMFileStreamSlow &operator>>(RMFileStreamSlow &df, uint16 &var) { uint16 v; - df.Read(&v, 2); + df.read(&v, 2); v = FROM_LE_16(v); return df; } RMFileStreamSlow &operator>>(RMFileStreamSlow &df, int16 &var) { uint16 v; - df.Read(&v, 2); + df.read(&v, 2); var = (int16)FROM_LE_16(v); return df; } RMFileStreamSlow &operator>>(RMFileStreamSlow &df, int &var) { int v; - df.Read(&v, 4); + df.read(&v, 4); var = FROM_LE_32(v); return df; } RMFileStreamSlow &operator>>(RMFileStreamSlow &df, uint32 &var) { uint32 v; - df.Read(&v, 4); + df.read(&v, 4); var = FROM_LE_32(v); return df; } @@ -508,24 +508,24 @@ RMFileStreamSlow &operator>>(RMFileStreamSlow &df, uint32 &var) { * Constructor */ RMDataStream::RMDataStream() { - m_length = 0; - m_pos = 0; - m_bError = false; + _length = 0; + _pos = 0; + _bError = false; } /** * Destructor */ RMDataStream::~RMDataStream() { - Close(); + close(); } /** * Close a stream */ -void RMDataStream::Close(void) { - m_length = 0; - m_pos = 0; +void RMDataStream::close(void) { + _length = 0; + _pos = 0; } /** @@ -535,27 +535,27 @@ void RMDataStream::Close(void) { * @remarks If the length of the buffer is not known, and cannot be * specified, then EOF() and Seek() to end won't work. */ -void RMDataStream::OpenBuffer(const byte *lpBuf, int size) { - m_length = size; - m_buf = lpBuf; - m_bError = false; - m_pos = 0; +void RMDataStream::openBuffer(const byte *lpBuf, int size) { + _length = size; + _buf = lpBuf; + _bError = false; + _pos = 0; } /** * Returns the length of the stream * @returns Stream length */ -int RMDataStream::Length() { - return m_length; +int RMDataStream::length() { + return _length; } /** * Determines if the end of the stream has been reached * @returns true if end of stream reached, false if not */ -bool RMDataStream::IsEOF() { - return (m_pos >= m_length); +bool RMDataStream::isEOF() { + return (_pos >= _length); } /** @@ -565,7 +565,7 @@ bool RMDataStream::IsEOF() { * @returns Value read from the stream */ RMDataStream &operator>>(RMDataStream &df, char &var) { - df.Read(&var, 1); + df.read(&var, 1); return df; } @@ -576,7 +576,7 @@ RMDataStream &operator>>(RMDataStream &df, char &var) { * @returns Value read from the stream */ RMDataStream &operator>>(RMDataStream &df, uint8 &var) { - df.Read(&var, 1); + df.read(&var, 1); return df; } @@ -588,7 +588,7 @@ RMDataStream &operator>>(RMDataStream &df, uint8 &var) { */ RMDataStream &operator>>(RMDataStream &df, uint16 &var) { uint16 v; - df.Read(&v, 2); + df.read(&v, 2); var = FROM_LE_16(v); return df; @@ -602,7 +602,7 @@ RMDataStream &operator>>(RMDataStream &df, uint16 &var) { */ RMDataStream &operator>>(RMDataStream &df, int16 &var) { uint16 v; - df.Read(&v, 2); + df.read(&v, 2); var = (int16)FROM_LE_16(v); return df; @@ -616,7 +616,7 @@ RMDataStream &operator>>(RMDataStream &df, int16 &var) { */ RMDataStream &operator>>(RMDataStream &df, int &var) { uint32 v; - df.Read(&v, 4); + df.read(&v, 4); var = (int)FROM_LE_32(v); return df; @@ -630,7 +630,7 @@ RMDataStream &operator>>(RMDataStream &df, int &var) { */ RMDataStream &operator>>(RMDataStream &df, uint32 &var) { uint32 v; - df.Read(&v, 4); + df.read(&v, 4); var = FROM_LE_32(v); return df; @@ -642,17 +642,17 @@ RMDataStream &operator>>(RMDataStream &df, uint32 &var) { * @param size Size of the buffer * @returns true if we have reached the end, false if not */ -bool RMDataStream::Read(void *lpBuf, int size) { +bool RMDataStream::read(void *lpBuf, int size) { byte *dest = (byte *)lpBuf; - if ((m_pos + size) > m_length) { - Common::copy(m_buf + m_pos, m_buf + m_pos + (m_length - m_pos), dest); + if ((_pos + size) > _length) { + Common::copy(_buf + _pos, _buf + _pos + (_length - _pos), dest); return true; } else { - Common::copy(m_buf + m_pos, m_buf + m_pos + size, dest); + Common::copy(_buf + _pos, _buf + _pos + size, dest); - m_pos += size; + _pos += size; return false; } } @@ -663,7 +663,7 @@ bool RMDataStream::Read(void *lpBuf, int size) { * @returns The stream */ RMDataStream &RMDataStream::operator+=(int nBytes) { - m_pos += nBytes; + _pos += nBytes; return *this; } @@ -673,57 +673,57 @@ RMDataStream &RMDataStream::operator+=(int nBytes) { * @param origin Origin to do offset from * @returns The absolute current position in bytes */ -int RMDataStream::Seek(int nBytes, RMDSPos origin) { +int RMDataStream::seek(int nBytes, RMDSPos origin) { switch (origin) { case CUR: break; case START: - m_pos = 0; + _pos = 0; break; case END: - if (m_length == SIZENOTKNOWN) - return m_pos; - m_pos = m_length; + if (_length == SIZENOTKNOWN) + return _pos; + _pos = _length; break; } - m_pos += nBytes; - return m_pos; + _pos += nBytes; + return _pos; } /** * Returns the current position of the stream * @returns The current position */ -int RMDataStream::Pos() { - return m_pos; +int RMDataStream::pos() { + return _pos; } /** * Check if an error occurred during reading the stream * @returns true if there was an error, false otherwise */ -bool RMDataStream::IsError() { - return m_bError; +bool RMDataStream::isError() { + return _bError; } /** * Sets an error code for the stream * @param code Error code */ -void RMDataStream::SetError(int code) { - m_bError = true; - m_ecode = code; +void RMDataStream::setError(int code) { + _bError = true; + _ecode = code; } /** * Returns the error code for the stream * @returns Error code */ -int RMDataStream::GetError() { - return m_ecode; +int RMDataStream::getError() { + return _ecode; } /****************************************************************************\ @@ -766,7 +766,7 @@ RMPoint &RMPoint::operator=(RMPoint p) { /** * Offsets the point by another point */ -void RMPoint::Offset(const RMPoint &p) { +void RMPoint::offset(const RMPoint &p) { x += p.x; y += p.y; } @@ -774,7 +774,7 @@ void RMPoint::Offset(const RMPoint &p) { /** * Offsets the point by a specified offset */ -void RMPoint::Offset(int xOff, int yOff) { +void RMPoint::offset(int xOff, int yOff) { x += xOff; y += yOff; } @@ -801,7 +801,7 @@ RMPoint operator-(RMPoint p1, RMPoint p2) { * Sum (offset) of a point */ RMPoint &RMPoint::operator+=(RMPoint p) { - Offset(p); + offset(p); return *this; } @@ -809,7 +809,7 @@ RMPoint &RMPoint::operator+=(RMPoint p) { * Subtract (offset) of a point */ RMPoint &RMPoint::operator-=(RMPoint p) { - Offset(-p); + offset(-p); return *this; } @@ -852,93 +852,93 @@ RMDataStream &operator>>(RMDataStream &ds, RMPoint &p) { \****************************************************************************/ RMRect::RMRect() { - SetEmpty(); + setEmpty(); } -void RMRect::SetEmpty(void) { +void RMRect::setEmpty(void) { x1 = y1 = x2 = y2 = 0; } RMRect::RMRect(const RMPoint &p1, const RMPoint &p2) { - SetRect(p1, p2); + setRect(p1, p2); } RMRect::RMRect(int X1, int Y1, int X2, int Y2) { - SetRect(X1, Y1, X2, Y2); + setRect(X1, Y1, X2, Y2); } RMRect::RMRect(const RMRect &rc) { - CopyRect(rc); + copyRect(rc); } -void RMRect::SetRect(const RMPoint &p1, const RMPoint &p2) { +void RMRect::setRect(const RMPoint &p1, const RMPoint &p2) { x1 = p1.x; y1 = p1.y; x2 = p2.x; y2 = p2.y; } -void RMRect::SetRect(int X1, int Y1, int X2, int Y2) { +void RMRect::setRect(int X1, int Y1, int X2, int Y2) { x1 = X1; y1 = Y1; x2 = X2; y2 = Y2; } -void RMRect::SetRect(const RMRect &rc) { - CopyRect(rc); +void RMRect::setRect(const RMRect &rc) { + copyRect(rc); } -void RMRect::CopyRect(const RMRect &rc) { +void RMRect::copyRect(const RMRect &rc) { x1 = rc.x1; y1 = rc.y1; x2 = rc.x2; y2 = rc.y2; } -RMPoint &RMRect::TopLeft() { +RMPoint &RMRect::topLeft() { // FIXME: This seems very bad return *((RMPoint *)this); } -RMPoint &RMRect::BottomRight() { +RMPoint &RMRect::bottomRight() { // FIXME: This seems very bad return *((RMPoint *)this + 1); } -RMPoint RMRect::Center() { +RMPoint RMRect::center() { return RMPoint((x2 - x1) / 2, (y2 - y1) / 2); } -int RMRect::Width() const { +int RMRect::width() const { return x2 - x1; } -int RMRect::Height() const { +int RMRect::height() const { return y2 - y1; } -int RMRect::Size() const { - return Width() * Height(); +int RMRect::size() const { + return width() * height(); } -bool RMRect::IsEmpty() const { +bool RMRect::isEmpty() const { return (x1 == 0 && y1 == 0 && x2 == 0 && y2 == 0); } const RMRect &RMRect::operator=(const RMRect &rc) { - CopyRect(rc); + copyRect(rc); return *this; } -void RMRect::Offset(int xOff, int yOff) { +void RMRect::offset(int xOff, int yOff) { x1 += xOff; y1 += yOff; x2 += xOff; y2 += yOff; } -void RMRect::Offset(const RMPoint &p) { +void RMRect::offset(const RMPoint &p) { x1 += p.x; y1 += p.y; x2 += p.x; @@ -946,12 +946,12 @@ void RMRect::Offset(const RMPoint &p) { } const RMRect &RMRect::operator+=(RMPoint p) { - Offset(p); + offset(p); return *this; } const RMRect &RMRect::operator-=(RMPoint p) { - Offset(-p); + offset(-p); return *this; } @@ -986,8 +986,8 @@ bool RMRect::operator!=(const RMRect &rc) { return ((x1 != rc.x1) || (y1 != rc.y1) || (x2 != rc.x2) || (y2 != rc.y2)); } -void RMRect::NormalizeRect(void) { - SetRect(MIN(x1, x2), MIN(y1, y2), MAX(x1, x2), MAX(y1, y2)); +void RMRect::normalizeRect(void) { + setRect(MIN(x1, x2), MIN(y1, y2), MAX(x1, x2), MAX(y1, y2)); } RMDataStream &operator>>(RMDataStream &ds, RMRect &rc) { @@ -1014,7 +1014,7 @@ RMResUpdate::~RMResUpdate() { _hFile.close(); } -void RMResUpdate::Init(const Common::String &fileName) { +void RMResUpdate::init(const Common::String &fileName) { // Open the resource update file if (!_hFile.open(fileName)) // It doesn't exist, so exit immediately @@ -1039,7 +1039,7 @@ void RMResUpdate::Init(const Common::String &fileName) { } } -HGLOBAL RMResUpdate::QueryResource(uint32 dwRes) { +HGLOBAL RMResUpdate::queryResource(uint32 dwRes) { // If there isn't an update file, return NULL if (!_hFile.isOpen()) return NULL; diff --git a/engines/tony/utils.h b/engines/tony/utils.h index 2eb6c5c2da..e649000e58 100644 --- a/engines/tony/utils.h +++ b/engines/tony/utils.h @@ -44,11 +44,11 @@ using namespace ::Tony::MPAL; */ class RMDataStream { protected: - const byte *m_buf; - int m_length; - int m_pos; - bool m_bError; - int m_ecode; + const byte *_buf; + int _length; + int _pos; + bool _bError; + int _ecode; public: enum RMDSPos { @@ -68,15 +68,15 @@ public: virtual ~RMDataStream(); // Loading buffer - void OpenBuffer(const byte *buf, int size = SIZENOTKNOWN); - void Close(void); + void openBuffer(const byte *buf, int size = SIZENOTKNOWN); + void close(void); // Attributei - int Length(); - virtual int Pos(); + int length(); + virtual int pos(); // EOF - virtual bool IsEOF(); + virtual bool isEOF(); // Read methods friend RMDataStream &operator>>(RMDataStream &df, char &var); @@ -87,16 +87,16 @@ public: friend RMDataStream &operator>>(RMDataStream &df, uint32 &var); // General read - virtual bool Read(void *buf, int size); + virtual bool read(void *buf, int size); // Skipping & Seeking virtual RMDataStream &operator+=(int nBytes); - virtual int Seek(int nBytes, RMDSPos origin = CUR); + virtual int seek(int nBytes, RMDSPos origin = CUR); // Error handling - void SetError(int ecode); - int GetError(); - bool IsError(); + void setError(int ecode); + int getError(); + bool isError(); }; @@ -105,17 +105,17 @@ public: */ class RMFileStream : public RMDataStream { private: - byte *m_buf; + byte *_buf; public: RMFileStream(); virtual ~RMFileStream(); // Methods for opening file - bool OpenFile(const char *lpFN); - bool OpenFile(Common::File &file); + bool openFile(const char *lpFN); + bool openFile(Common::File &file); - void Close(void); + void close(void); }; @@ -126,18 +126,18 @@ public: RMFileStreamSlow(); virtual ~RMFileStreamSlow(); - bool OpenFile(const char *lpFN); - bool OpenFile(Common::File &file); + bool openFile(const char *lpFN); + bool openFile(Common::File &file); - void Close(void); + void close(void); RMDataStream &operator+=(int nBytes); - int Seek(int nBytes, RMDSPos where = CUR); + int seek(int nBytes, RMDSPos where = CUR); - int Pos(); - virtual bool IsEOF(); + int pos(); + virtual bool isEOF(); - bool Read(void *buf, int size); + bool read(void *buf, int size); friend RMFileStreamSlow &operator>>(RMFileStreamSlow &df, char &var); friend RMFileStreamSlow &operator>>(RMFileStreamSlow &df, byte &var); @@ -152,9 +152,9 @@ public: */ class RMString { private: - char *m_string; - int m_length; - int m_realLength; + char *_string; + int _length; + int _realLength; public: RMString(); @@ -166,12 +166,12 @@ public: RMString(const int ch); // General methods - int Length() const; - void Compact(); + int length() const; + void compact(); // Access characters within string - char GetAt(int nIndex); - void SetAt(int nIndex, char c); + char getAt(int nIndex); + void setAt(int nIndex, char c); char &operator[](int nIndex); // String cast @@ -200,11 +200,11 @@ public: friend RMDataStream &operator>>(RMDataStream &df, RMString &var); // String formatting - void Format(const char *str, ...); + void format(const char *str, ...); private: - void Resize(int size, bool bMantain = false); - void Connect(const char *str, int size); + void resize(int size, bool bMantain = false); + void connect(const char *str, int size); }; /** @@ -224,14 +224,14 @@ public: RMPoint &operator=(RMPoint p); // Set - void Set(int x1, int y1) { + void set(int x1, int y1) { x = x1; y = y1; } // Offset - void Offset(int xOff, int yOff); - void Offset(const RMPoint &p); + void offset(int xOff, int yOff); + void offset(const RMPoint &p); friend RMPoint operator+(RMPoint p1, RMPoint p2); friend RMPoint operator-(RMPoint p1, RMPoint p2); RMPoint &operator+=(RMPoint p); @@ -261,27 +261,27 @@ public: RMRect(const RMRect &rc); // Attributes - RMPoint &TopLeft(); - RMPoint &BottomRight(); - RMPoint Center(); - int Width() const; - int Height() const; - bool IsEmpty() const; - int Size() const; + RMPoint &topLeft(); + RMPoint &bottomRight(); + RMPoint center(); + int width() const; + int height() const; + bool isEmpty() const; + int size() const; // Set - void SetRect(int x1, int y1, int x2, int y2); - void SetRect(const RMPoint &p1, const RMPoint &p2); - void SetEmpty(void); + void setRect(int x1, int y1, int x2, int y2); + void setRect(const RMPoint &p1, const RMPoint &p2); + void setEmpty(void); // Copiers - void SetRect(const RMRect &rc); - void CopyRect(const RMRect &rc); + void setRect(const RMRect &rc); + void copyRect(const RMRect &rc); const RMRect &operator=(const RMRect &rc); // Offset - void Offset(int xOff, int yOff); - void Offset(const RMPoint &p); + void offset(int xOff, int yOff); + void offset(const RMPoint &p); friend RMRect operator+(const RMRect &rc, RMPoint p); friend RMRect operator-(const RMRect &rc, RMPoint p); friend RMRect operator+(RMPoint p, const RMRect &rc); @@ -294,10 +294,10 @@ public: bool operator!=(const RMRect &rc); // Normalise - void NormalizeRect(); + void normalizeRect(); // Point in rect - bool PtInRect(const RMPoint &pt) { + bool ptInRect(const RMPoint &pt) { return (pt.x >= x1 && pt.x <= x2 && pt.y >= y1 && pt.y <= y2); } @@ -324,8 +324,8 @@ public: RMResUpdate(); ~RMResUpdate(); - void Init(const Common::String &fileName); - HGLOBAL QueryResource(uint32 dwRes); + void init(const Common::String &fileName); + HGLOBAL queryResource(uint32 dwRes); }; } // End of namespace Tony diff --git a/engines/tony/window.h b/engines/tony/window.h index 3d1199482f..34f0c1cb51 100644 --- a/engines/tony/window.h +++ b/engines/tony/window.h @@ -57,8 +57,8 @@ private: void plotLines(const byte *lpBuf, const Common::Point ¢er, int x, int y); protected: - void * /*LPDIRECTDRAWCLIPPER*/ m_MainClipper; - void * /*LPDIRECTDRAWCLIPPER*/ m_BackClipper; +// void * /*LPDIRECTDRAWCLIPPER*/ _MainClipper; +// void * /*LPDIRECTDRAWCLIPPER*/ _BackClipper; int fps, fcount; int lastsecond, lastfcount; -- cgit v1.2.3 From a7a619e1b41b771726b6fb611ddb640e38a78185 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 7 Jun 2012 21:19:57 +1000 Subject: TONY: Fix to correctly show the loading screen at the start of the game --- engines/tony/gfxengine.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'engines') diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index b102323dce..e61e6a8b84 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -472,7 +472,12 @@ void RMGfxEngine::init() { _bigBuf.drawOT(Common::nullContext); _bigBuf.clearOT(); delete load; + + // Display 'Loading' screen + // TODO: The loading screen isn't currently optimal, since the game doesn't respond to events + // whilst the mpalInit code is being executed. _vm->_window.getNewFrame(*this, NULL); + _vm->_window.repaint(); GLOBALS.bPatIrqFreeze = true; -- cgit v1.2.3 From cd15e483ed64274049142a2e6838962d794c3ff5 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 7 Jun 2012 21:14:59 +0200 Subject: TONY: Some more renaming --- engines/tony/custom.cpp | 8 +- engines/tony/font.cpp | 40 ++-- engines/tony/game.cpp | 6 +- engines/tony/gfxcore.cpp | 190 ++++++++-------- engines/tony/gfxcore.h | 39 ++-- engines/tony/inventory.cpp | 8 +- engines/tony/loc.cpp | 8 +- engines/tony/mpal/expr.cpp | 78 +++---- engines/tony/mpal/expr.h | 6 +- engines/tony/mpal/loadmpc.cpp | 184 +++++++-------- engines/tony/mpal/memory.cpp | 12 +- engines/tony/mpal/memory.h | 20 +- engines/tony/mpal/mpal.cpp | 482 ++++++++++++++++++++-------------------- engines/tony/mpal/mpal.h | 4 +- engines/tony/mpal/mpaldll.h | 16 +- engines/tony/mpal/mpalutils.cpp | 8 +- engines/tony/sound.cpp | 10 +- engines/tony/tonychar.cpp | 22 +- engines/tony/utils.cpp | 6 +- 19 files changed, 574 insertions(+), 573 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index eaf125c973..a50807822c 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -1949,7 +1949,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg delete _ctx->text; } - GlobalFree(_ctx->string); + globalFree(_ctx->string); CORO_END_CODE; } @@ -1985,7 +1985,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr // If there is only one option, do it automatically, and wait for the next choice if (_ctx->num == 1) { mpalQueryDialogSelectionDWORD(_ctx->nChoice, _ctx->sl[0]); - GlobalFree(_ctx->sl); + globalFree(_ctx->sl); // Wait for the next choice to be made mpalQueryDialogWaitForChoice(&_ctx->nChoice); @@ -2001,7 +2001,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr _ctx->string = mpalQueryDialogPeriod(_ctx->sl[_ctx->i]); assert(_ctx->string != NULL); _ctx->dc.addChoice(_ctx->string); - GlobalFree(_ctx->string); + globalFree(_ctx->string); } // Activate the object @@ -2028,7 +2028,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr // Closes the choice _ctx->dc.close(); - GlobalFree(_ctx->sl); + globalFree(_ctx->sl); // Wait for the next choice to be made mpalQueryDialogWaitForChoice(&_ctx->nChoice); diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 623aab5ab4..398389ebcd 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -1890,7 +1890,7 @@ void RMText::writeText(const RMString &text, RMFontColor *font, int *time) { height = (numlines - 1) * font->letterHeight() + font->_fontDimy; // Create the surface - Create(width, height); + create(width, height); //AddPrim(new RMGfxPrimitive(&m_clear)); Common::fill(_buf, _buf + width * height * 2, 0); @@ -1932,8 +1932,8 @@ void RMText::writeText(const RMString &text, RMFontColor *font, int *time) { } prim = font->makeLetterPrimitive(*p, len); - prim->Dst().x1 = x; - prim->Dst().y1 = y; + prim->getDst().x1 = x; + prim->getDst().y1 = y; addPrim(prim); numchar++; @@ -1951,14 +1951,14 @@ void RMText::writeText(const RMString &text, RMFontColor *font, int *time) { void RMText::clipOnScreen(RMGfxPrimitive *prim) { // Don't let it go outside the screen - if (prim->Dst().x1 < 5) - prim->Dst().x1 = 5; - if (prim->Dst().y1 < 5) - prim->Dst().y1 = 5; - if (prim->Dst().x1 + _dimx > 635) - prim->Dst().x1 = 635 - _dimx; - if (prim->Dst().y1 + _dimy > 475) - prim->Dst().y1 = 475 - _dimy; + if (prim->getDst().x1 < 5) + prim->getDst().x1 = 5; + if (prim->getDst().y1 < 5) + prim->getDst().y1 = 5; + if (prim->getDst().x1 + _dimx > 635) + prim->getDst().x1 = 635 - _dimx; + if (prim->getDst().y1 + _dimy > 475) + prim->getDst().y1 = 475 - _dimy; } void RMText::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { @@ -1968,19 +1968,19 @@ void RMText::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CODE(_ctx); // Horizontally if (aHorType == HCENTER) - prim->Dst().topLeft() -= RMPoint(_dimx / 2, 0); + prim->getDst().topLeft() -= RMPoint(_dimx / 2, 0); else if (aHorType == HRIGHT) - prim->Dst().topLeft() -= RMPoint(_dimx, 0); + prim->getDst().topLeft() -= RMPoint(_dimx, 0); // Vertically if (aVerType == VTOP) { } else if (aVerType == VCENTER) { - prim->Dst().y1 -= _dimy / 2; + prim->getDst().y1 -= _dimy / 2; } else if (aVerType == VBOTTOM) { - prim->Dst().y1 -= _dimy; + prim->getDst().y1 -= _dimy; } clipOnScreen(prim); @@ -2146,7 +2146,7 @@ void RMTextDialog::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *p if (_bShowed) { if (GLOBALS.bCfgSottotitoli || _bAlwaysDisplay) { - prim->Dst().topLeft() = dst; + prim->getDst().topLeft() = dst; CORO_INVOKE_2(RMText::draw, bigBuf, prim); } } @@ -2285,7 +2285,7 @@ void RMTextItemName::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive return; // Set the destination coordinates of the mouse - prim->Dst().topLeft() = _mpos - RMPoint(0, 30); + prim->getDst().topLeft() = _mpos - RMPoint(0, 30); CORO_INVOKE_2(RMText::draw, bigBuf, prim); @@ -2349,7 +2349,7 @@ void RMDialogChoice::init(void) { _ptDrawStrings = NULL; _curSelection = -1; - Create(640, 477); + create(640, 477); setPriority(140); } @@ -2437,7 +2437,7 @@ void RMDialogChoice::setSelected(CORO_PARAM, int pos) { _ctx->box.setPriority(5); if (_curSelection != -1) { - _ctx->box.SetColor(0xCC, 0xCC, 0xFF); + _ctx->box.setColor(0xCC, 0xCC, 0xFF); _ctx->rc.topLeft() = RMPoint(18, _ptDrawStrings[_curSelection].y); _ctx->rc.bottomRight() = _ctx->rc.topLeft() + RMPoint(597, _drawedStrings[_curSelection].getDimy()); addPrim(new RMGfxPrimitive(&_ctx->box, _ctx->rc)); @@ -2448,7 +2448,7 @@ void RMDialogChoice::setSelected(CORO_PARAM, int pos) { } if (pos != -1) { - _ctx->box.SetColor(100, 100, 100); + _ctx->box.setColor(100, 100, 100); _ctx->rc.topLeft() = RMPoint(18, _ptDrawStrings[pos].y); _ctx->rc.bottomRight() = _ctx->rc.topLeft() + RMPoint(597, _drawedStrings[pos].getDimy()); addPrim(new RMGfxPrimitive(&_ctx->box, _ctx->rc)); diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index c8a70d7b0f..886b5f0859 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -328,7 +328,7 @@ RMOptionScreen::RMOptionScreen(void) { _QuitConfirm = NULL; _bQuitConfirm = false; - Create(RM_SX, RM_SY); + create(RM_SX, RM_SY); _ButtonExit = NULL; _ButtonLoad = NULL; @@ -556,7 +556,7 @@ void RMOptionScreen::refreshThumbnails(void) { delete _curThumb[i]; _curThumb[i] = new RMGfxSourceBuffer16; - _curThumb[i]->Create(640 / 4, 480 / 4); + _curThumb[i]->create(640 / 4, 480 / 4); if (!loadThumbnailFromSaveState(_statePos + i, *_curThumb[i], _curThumbName[i], _curThumbDiff[i])) { delete _curThumb[i]; _curThumb[i] = NULL; @@ -1548,7 +1548,7 @@ void RMPointer::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim if (_pos.x >= 0 && _pos.y >= 0 && _pos.x < RM_SX && _pos.y < RM_SY) { // Call the Draw method of the poitner - prim->Dst() -= _hotspot[_ctx->n]; + prim->getDst() -= _hotspot[_ctx->n]; if (_nCurSpecialPointer == 0) { CORO_INVOKE_2(_pointer[_ctx->n]->draw, bigBuf, prim); diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 55a15a5961..09b102db11 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -134,19 +134,19 @@ RMGfxBuffer::RMGfxBuffer(int dimx, int dimy, int nBpp, bool bUseDDraw) { \****************************************************************************/ int RMGfxSourceBuffer::init(const byte *buf, int dimx, int dimy, bool bLoadPalette) { - create(dimx, dimy, Bpp()); - CopyMemory(_buf, buf, dimx * dimy * Bpp() / 8); + create(dimx, dimy, getBpp()); + copyMemory(_buf, buf, dimx * dimy * getBpp() / 8); // Invokes the method for preparing the surface (inherited) prepareImage(); - return dimx * dimy * Bpp() / 8; + return dimx * dimy * getBpp() / 8; } void RMGfxSourceBuffer::init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette) { - create(dimx, dimy, Bpp()); - ds.read(_buf, dimx * dimy * Bpp() / 8); + create(dimx, dimy, getBpp()); + ds.read(_buf, dimx * dimy * getBpp() / 8); // Invokes the method for preparing the surface (inherited) prepareImage(); @@ -254,7 +254,7 @@ RMGfxWoodyBuffer::RMGfxWoodyBuffer(int dimx, int dimy, bool bUseDDraw) RMGfxClearTask RMGfxTargetBuffer::taskClear; RMGfxTargetBuffer::RMGfxTargetBuffer() { - otlist = NULL; + _otlist = NULL; _otSize = 0; // csModifyingOT = g_system->createMutex(); } @@ -269,7 +269,7 @@ void RMGfxTargetBuffer::clearOT(void) { // g_system->lockMutex(csModifyingOT); - cur = otlist; + cur = _otlist; while (cur != NULL) { cur->prim->_task->Unregister(); @@ -279,7 +279,7 @@ void RMGfxTargetBuffer::clearOT(void) { cur = n; } - otlist = NULL; + _otlist = NULL; // g_system->unlockMutex(csModifyingOT); } @@ -296,7 +296,7 @@ void RMGfxTargetBuffer::drawOT(CORO_PARAM) { CORO_BEGIN_CODE(_ctx); _ctx->prev = NULL; - _ctx->cur = otlist; + _ctx->cur = _otlist; // Lock the buffer to access it lock(); @@ -321,7 +321,7 @@ void RMGfxTargetBuffer::drawOT(CORO_PARAM) { // If it was the first item, update the list head if (_ctx->prev == NULL) - otlist = _ctx->next; + _otlist = _ctx->next; // Otherwise update the next pinter of the previous item else _ctx->prev->next = _ctx->next; @@ -356,16 +356,16 @@ void RMGfxTargetBuffer::addPrim(RMGfxPrimitive *prim) { n = new OTList(prim); // Empty list - if (otlist == NULL) { - otlist = n; - otlist->next = NULL; + if (_otlist == NULL) { + _otlist = n; + _otlist->next = NULL; } // Inclusion in the head - else if (nPrior < otlist->prim->_task->priority()) { - n->next = otlist; - otlist = n; + else if (nPrior < _otlist->prim->_task->priority()) { + n->next = _otlist; + _otlist = n; } else { - cur = otlist; + cur = _otlist; while (cur->next != NULL && nPrior > cur->next->prim->_task->priority()) cur = cur->next; @@ -393,28 +393,28 @@ int RMGfxSourceBufferPal::loadPaletteWA(const byte *buf, bool bSwapped) { int i; if (bSwapped) - for (i = 0; i < (1 << Bpp()); i++) { + for (i = 0; i < (1 << getBpp()); i++) { _pal[i * 3 + 0] = buf[i * 3 + 2]; _pal[i * 3 + 1] = buf[i * 3 + 1]; _pal[i * 3 + 2] = buf[i * 3 + 0]; } else - CopyMemory(_pal, buf, (1 << Bpp()) * 3); + copyMemory(_pal, buf, (1 << getBpp()) * 3); preparePalette(); - return (1 << Bpp()) * 3; + return (1 << getBpp()) * 3; } int RMGfxSourceBufferPal::loadPalette(const byte *buf) { int i; for (i = 0; i < 256; i++) - CopyMemory(_pal + i * 3, buf + i * 4, 3); + copyMemory(_pal + i * 3, buf + i * 4, 3); preparePalette(); - return (1 << Bpp()) * 4; + return (1 << getBpp()) * 4; } @@ -480,11 +480,11 @@ RMGfxSourceBuffer4::RMGfxSourceBuffer4(int dimx, int dimy, bool bUseDDraw) * * @returns Bit per pixel */ -int RMGfxSourceBuffer4::Bpp() { +int RMGfxSourceBuffer4::getBpp() { return 4; } -void RMGfxSourceBuffer4::Create(int dimx, int dimy, bool bUseDDraw) { +void RMGfxSourceBuffer4::create(int dimx, int dimy, bool bUseDDraw) { RMGfxBuffer::create(dimx, dimy, 4, bUseDDraw); } @@ -505,15 +505,15 @@ void RMGfxSourceBuffer8::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimit // Destination buffer RMRect dst; if (prim->haveDst()) - dst = prim->Dst(); + dst = prim->getDst(); // Clipping if (prim->haveSrc()) { - u = prim->Src().x1; - v = prim->Src().y1; + u = prim->getSrc().x1; + v = prim->getSrc().y1; - width = prim->Src().width(); - height = prim->Src().height(); + width = prim->getSrc().width(); + height = prim->getSrc().height(); } if (!clip2D(dst.x1, dst.y1, u, v, width, height, prim->haveSrc(), &bigBuf)) @@ -568,7 +568,7 @@ RMGfxSourceBuffer8::RMGfxSourceBuffer8(bool bTrasp0) { * * @returns Bit per pixel */ -int RMGfxSourceBuffer8::Bpp() { +int RMGfxSourceBuffer8::getBpp() { return 8; } @@ -578,7 +578,7 @@ void RMGfxSourceBuffer8::create(int dimx, int dimy, bool bUseDDraw) { #define GETRED(x) (((x) >> 10) & 0x1F) #define GETGREEN(x) (((x) >> 5) & 0x1F) -#define GETBLUE(x) ((x) & 0x1F) +#define GETBLUE(x) ((x) & 0x1F) /****************************************************************************\ @@ -613,15 +613,15 @@ void RMGfxSourceBuffer8AB::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrim // Destination buffer RMRect dst; if (prim->haveDst()) - dst = prim->Dst(); + dst = prim->getDst(); // Clipping if (prim->haveSrc()) { - u = prim->Src().x1; - v = prim->Src().y1; + u = prim->getSrc().x1; + v = prim->getSrc().y1; - width = prim->Src().width(); - height = prim->Src().height(); + width = prim->getSrc().width(); + height = prim->getSrc().height(); } if (!clip2D(dst.x1, dst.y1, u, v, width, height, prim->haveSrc(), &bigBuf)) @@ -670,15 +670,15 @@ void RMGfxSourceBuffer8AB::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrim * RMGfxSourceBuffer8RLE Methods \****************************************************************************/ -byte RMGfxSourceBuffer8RLE::MegaRLEBuf[512 * 1024]; +byte RMGfxSourceBuffer8RLE::_megaRLEBuf[512 * 1024]; void RMGfxSourceBuffer8RLE::setAlphaBlendColor(int color) { - alphaBlendColor = color; + _alphaBlendColor = color; } RMGfxSourceBuffer8RLE::RMGfxSourceBuffer8RLE() { - alphaBlendColor = -1; - bNeedRLECompress = true; + _alphaBlendColor = -1; + _bNeedRLECompress = true; _buf = NULL; } @@ -695,7 +695,7 @@ int RMGfxSourceBuffer8RLE::init(const byte *buf, int dimx, int dimy, bool bLoadP } void RMGfxSourceBuffer8RLE::init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette) { - if (bNeedRLECompress) { + if (_bNeedRLECompress) { RMGfxSourceBufferPal::init(ds, dimx, dimy, bLoadPalette); } else { int size; @@ -714,10 +714,10 @@ void RMGfxSourceBuffer8RLE::preparePalette(void) { RMGfxSourceBuffer8::preparePalette(); // Handle RGB alpha blending - if (alphaBlendColor != -1) { - alphaR = (_palFinal[alphaBlendColor] >> 10) & 0x1F; - alphaG = (_palFinal[alphaBlendColor] >> 5) & 0x1F; - alphaB = (_palFinal[alphaBlendColor]) & 0x1F; + if (_alphaBlendColor != -1) { + _alphaR = (_palFinal[_alphaBlendColor] >> 10) & 0x1F; + _alphaG = (_palFinal[_alphaBlendColor] >> 5) & 0x1F; + _alphaB = (_palFinal[_alphaBlendColor]) & 0x1F; } } @@ -730,7 +730,7 @@ void RMGfxSourceBuffer8RLE::prepareImage(void) { } void RMGfxSourceBuffer8RLE::setAlreadyCompressed(void) { - bNeedRLECompress = false; + _bNeedRLECompress = false; } @@ -744,7 +744,7 @@ void RMGfxSourceBuffer8RLE::compressRLE(void) { int rep; // Perform RLE compression for lines - cur = MegaRLEBuf; + cur = _megaRLEBuf; src = _buf; for (y = 0; y < _dimy; y++) { // Save the beginning of the line @@ -758,8 +758,8 @@ void RMGfxSourceBuffer8RLE::compressRLE(void) { rep = 0; startsrc = src; for (x = 0; x < _dimx;) { - if ((curdata == 0 && *src == 0) || (curdata == 1 && *src == alphaBlendColor) - || (curdata == 2 && (*src != alphaBlendColor && *src != 0))) { + if ((curdata == 0 && *src == 0) || (curdata == 1 && *src == _alphaBlendColor) + || (curdata == 2 && (*src != _alphaBlendColor && *src != 0))) { src++; rep++; x++; @@ -801,9 +801,9 @@ void RMGfxSourceBuffer8RLE::compressRLE(void) { delete[] _buf; // Copy the compressed image - x = cur - MegaRLEBuf; + x = cur - _megaRLEBuf; _buf = new byte[x]; - Common::copy(MegaRLEBuf, MegaRLEBuf + x, _buf); + Common::copy(_megaRLEBuf, _megaRLEBuf + x, _buf); } void RMGfxSourceBuffer8RLE::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { @@ -813,8 +813,8 @@ void RMGfxSourceBuffer8RLE::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPri int x1, y1, u, v, width, height; // Clipping - x1 = prim->Dst().x1; - y1 = prim->Dst().y1; + x1 = prim->getDst().x1; + y1 = prim->getDst().y1; if (!clip2D(x1, y1, u, v, width, height, false, &bigBuf)) return; @@ -834,7 +834,7 @@ void RMGfxSourceBuffer8RLE::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPri // Clipping u = _dimx - (width + u); - x1 = (prim->Dst().x1 + _dimx - 1) - u; + x1 = (prim->getDst().x1 + _dimx - 1) - u; for (y = 0; y < height; y++) { // Decompressione @@ -884,7 +884,7 @@ void RMGfxSourceBuffer8RLEByte::RLEWriteData(byte *&cur, int rep, byte *src) { *cur ++ = rep; if (rep > 0) { - CopyMemory(cur, src, rep); + copyMemory(cur, src, rep); cur += rep; src += rep; } @@ -972,9 +972,9 @@ RLEByteDoAlpha2: g = (*dst >> 5) & 0x1F; b = *dst & 0x1F; - r = (r >> 2) + (alphaR >> 1); - g = (g >> 2) + (alphaG >> 1); - b = (b >> 2) + (alphaB >> 1); + r = (r >> 2) + (_alphaR >> 1); + g = (g >> 2) + (_alphaG >> 1); + b = (b >> 2) + (_alphaB >> 1); *dst ++ = (r << 10) | (g << 5) | b; } @@ -1078,9 +1078,9 @@ RLEByteFlippedDoAlpha2: g = (*dst >> 5) & 0x1F; b = *dst & 0x1F; - r = (r >> 2) + (alphaR >> 1); - g = (g >> 2) + (alphaG >> 1); - b = (b >> 2) + (alphaB >> 1); + r = (r >> 2) + (_alphaR >> 1); + g = (g >> 2) + (_alphaG >> 1); + b = (b >> 2) + (_alphaB >> 1); *dst-- = (r << 10) | (g << 5) | b; } @@ -1132,7 +1132,7 @@ void RMGfxSourceBuffer8RLEWord::RLEWriteData(byte *&cur, int rep, byte *src) { cur += 2; if (rep > 0) { - CopyMemory(cur, src, rep); + copyMemory(cur, src, rep); cur += rep; src += rep; } @@ -1227,9 +1227,9 @@ RLEWordDoAlpha2: g = (*dst >> 5) & 0x1F; b = *dst & 0x1F; - r = (r >> 2) + (alphaR >> 1); - g = (g >> 2) + (alphaG >> 1); - b = (b >> 2) + (alphaB >> 1); + r = (r >> 2) + (_alphaR >> 1); + g = (g >> 2) + (_alphaG >> 1); + b = (b >> 2) + (_alphaB >> 1); *dst++ = (r << 10) | (g << 5) | b; } @@ -1345,9 +1345,9 @@ RLEWordFlippedDoAlpha2: g = (*dst >> 5) & 0x1F; b = *dst & 0x1F; - r = (r >> 2) + (alphaR >> 1); - g = (g >> 2) + (alphaG >> 1); - b = (b >> 2) + (alphaB >> 1); + r = (r >> 2) + (_alphaR >> 1); + g = (g >> 2) + (_alphaG >> 1); + b = (b >> 2) + (_alphaB >> 1); *dst-- = (r << 10) | (g << 5) | b; } @@ -1476,9 +1476,9 @@ RLEWordDoAlpha2: g = (*dst >> 5) & 0x1F; b = *dst & 0x1F; - r = (r >> 2) + (alphaR >> 1); - g = (g >> 2) + (alphaG >> 1); - b = (b >> 2) + (alphaB >> 1); + r = (r >> 2) + (_alphaR >> 1); + g = (g >> 2) + (_alphaG >> 1); + b = (b >> 2) + (_alphaB >> 1); *dst++ = (r << 10) | (g << 5) | b; } @@ -1529,8 +1529,8 @@ RLEWordDoCopy2: * Metodi di RMGfxSourceBuffer8AA \****************************************************************************/ -byte RMGfxSourceBuffer8AA::MegaAABuf[256 * 1024]; -byte RMGfxSourceBuffer8AA::MegaAABuf2[64 * 1024]; +byte RMGfxSourceBuffer8AA::_megaAABuf[256 * 1024]; +byte RMGfxSourceBuffer8AA::_megaAABuf2[64 * 1024]; void RMGfxSourceBuffer8AA::prepareImage(void) { // Invoke the parent method @@ -1549,10 +1549,10 @@ void RMGfxSourceBuffer8AA::calculateAA(void) { byte *src, *srcaa; /* First pass: fill the edges */ - Common::fill(MegaAABuf, MegaAABuf + _dimx * _dimy, 0); + Common::fill(_megaAABuf, _megaAABuf + _dimx * _dimy, 0); src = _buf; - srcaa = MegaAABuf; + srcaa = _megaAABuf; for (y = 0; y < _dimy; y++) { for (x = 0; x < _dimx; x++) { if (*src == 0) { @@ -1569,7 +1569,7 @@ void RMGfxSourceBuffer8AA::calculateAA(void) { } src = _buf; - srcaa = MegaAABuf; + srcaa = _megaAABuf; for (y = 0; y < _dimy; y++) { for (x = 0; x < _dimx; x++) { if (*src != 0) { @@ -1589,7 +1589,7 @@ void RMGfxSourceBuffer8AA::calculateAA(void) { delete[] _aabuf; _aabuf = new byte[_dimx * _dimy]; - CopyMemory(_aabuf, MegaAABuf, _dimx * _dimy); + copyMemory(_aabuf, _megaAABuf, _dimx * _dimy); } RMGfxSourceBuffer8AA::RMGfxSourceBuffer8AA() : RMGfxSourceBuffer8() { @@ -1611,8 +1611,8 @@ void RMGfxSourceBuffer8AA::drawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri int step; // Clip the sprite - x1 = prim->Dst().x1; - y1 = prim->Dst().y1; + x1 = prim->getDst().x1; + y1 = prim->getDst().y1; if (!clip2D(x1, y1, u, v, width, height, false, &bigBuf)) return; @@ -1625,7 +1625,7 @@ void RMGfxSourceBuffer8AA::drawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri if (prim->isFlipped()) { u = _dimx - (width + u); - x1 = (prim->Dst().x1 + _dimx - 1) - u; + x1 = (prim->getDst().x1 + _dimx - 1) - u; } // width = _dimx; // x1 = prim->Dst().x1; @@ -1764,7 +1764,7 @@ int RMGfxSourceBuffer8RLEByteAA::init(const byte *buf, int dimx, int dimy, bool void RMGfxSourceBuffer8RLEByteAA::init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette) { RMGfxSourceBuffer8RLE::init(ds, dimx, dimy, bLoadPalette); - if (!bNeedRLECompress) { + if (!_bNeedRLECompress) { // Load the anti-aliasing mask _aabuf = new byte[dimx * dimy]; ds.read(_aabuf, dimx * dimy); @@ -1802,7 +1802,7 @@ int RMGfxSourceBuffer8RLEWordAA::init(byte *buf, int dimx, int dimy, bool bLoadP void RMGfxSourceBuffer8RLEWordAA::init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette) { RMGfxSourceBuffer8RLE::init(ds, dimx, dimy, bLoadPalette); - if (!bNeedRLECompress) { + if (!_bNeedRLECompress) { // Load the anti-aliasing mask _aabuf = new byte[dimx * dimy]; ds.read(_aabuf, dimx * dimy); @@ -1837,15 +1837,15 @@ void RMGfxSourceBuffer16::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimi y1 = 0; if (prim->haveSrc()) { - u = prim->Src().x1; - v = prim->Src().y1; - dimx = prim->Src().width(); - dimy = prim->Src().height(); + u = prim->getSrc().x1; + v = prim->getSrc().y1; + dimx = prim->getSrc().width(); + dimy = prim->getSrc().height(); } if (prim->haveDst()) { - x1 = prim->Dst().x1; - y1 = prim->Dst().y1; + x1 = prim->getDst().x1; + y1 = prim->getDst().y1; } if (!clip2D(x1, y1, u, v, dimx, dimy, true, &bigBuf)) @@ -1878,7 +1878,7 @@ void RMGfxSourceBuffer16::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimi } } -void RMGfxSourceBuffer16::PrepareImage(void) { +void RMGfxSourceBuffer16::prepareImage(void) { // Colour space conversion if necessary! int i; uint16 *buf = (uint16 *)_buf; @@ -1899,11 +1899,11 @@ RMGfxSourceBuffer16::RMGfxSourceBuffer16(int dimx, int dimy, bool bUseDDraw) * * @returns Bit per pixel */ -int RMGfxSourceBuffer16::Bpp() { +int RMGfxSourceBuffer16::getBpp() { return 16; } -void RMGfxSourceBuffer16::Create(int dimx, int dimy, bool bUseDDraw) { +void RMGfxSourceBuffer16::create(int dimx, int dimy, bool bUseDDraw) { RMGfxBuffer::create(dimx, dimy, 16, bUseDDraw); } @@ -1915,11 +1915,11 @@ void RMGfxBox::removeThis(CORO_PARAM, bool &result) { result = true; } -void RMGfxBox::SetColor(byte r, byte g, byte b) { +void RMGfxBox::setColor(byte r, byte g, byte b) { r >>= 3; g >>= 3; b >>= 3; - wFillColor = (r << 10) | (g << 5) | b; + _wFillColor = (r << 10) | (g << 5) | b; } void RMGfxBox::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { @@ -1928,13 +1928,13 @@ void RMGfxBox::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) RMRect rcDst; // It takes the destination rectangle - rcDst = prim->Dst(); + rcDst = prim->getDst(); buf += rcDst.y1 * bigBuf.getDimx() + rcDst.x1; // Loop through the pixels for (j = 0; j < rcDst.height(); j++) { for (i = 0; i < rcDst.width(); i++) - *buf ++ = wFillColor; + *buf++ = _wFillColor; buf += bigBuf.getDimx() - rcDst.width(); } diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index 82f8383131..a1bf537e3b 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -189,14 +189,15 @@ public: bool haveDst() { return !_dst.isEmpty(); } - RMRect &Dst() { + + RMRect &getDst() { return _dst; } bool haveSrc() { return !_src.isEmpty(); } - RMRect &Src() { + RMRect &getSrc() { return _src; } @@ -268,12 +269,12 @@ public: */ class RMGfxBox : public RMGfxTaskSetPrior { protected: - uint16 wFillColor; + uint16 _wFillColor; public: virtual ~RMGfxBox() { } - void SetColor(byte r, byte g, byte b); + void setColor(byte r, byte g, byte b); virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); virtual void removeThis(CORO_PARAM, bool &result); }; @@ -295,11 +296,11 @@ protected: virtual void prepareImage(void); bool clip2D(int &x1, int &y1, int &u, int &v, int &width, int &height, bool bUseSrc, RMGfxTargetBuffer *buf); void offsetY(int nLines) { - RMGfxBuffer::offsetY(nLines, Bpp()); + RMGfxBuffer::offsetY(nLines, getBpp()); } public: - virtual int Bpp() = 0; + virtual int getBpp() = 0; }; @@ -308,7 +309,7 @@ public: */ class RMGfxSourceBuffer16 : public RMGfxSourceBuffer { protected: - virtual void PrepareImage(void); + virtual void prepareImage(void); bool _bTrasp0; public: @@ -317,9 +318,9 @@ public: virtual ~RMGfxSourceBuffer16(); // Initialisation - void Create(int dimx, int dimy, bool bUseDDraw = false); + void create(int dimx, int dimy, bool bUseDDraw = false); - int Bpp(); + int getBpp(); virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); }; @@ -364,7 +365,7 @@ public: // Initialisation void create(int dimx, int dimy, bool bUseDDraw = false); - int Bpp(); + int getBpp(); virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); }; @@ -388,12 +389,12 @@ public: class RMGfxSourceBuffer8RLE : public virtual RMGfxSourceBuffer8 { protected: - int alphaBlendColor; - int alphaR, alphaB, alphaG; - bool bNeedRLECompress; + int _alphaBlendColor; + int _alphaR, _alphaB, _alphaG; + bool _bNeedRLECompress; protected: - static byte MegaRLEBuf[]; + static byte _megaRLEBuf[]; virtual void RLEWriteTrasp(byte *&cur, int rep) = 0; virtual void RLEWriteData(byte *&cur, int rep, byte *src) = 0; @@ -468,8 +469,8 @@ public: */ class RMGfxSourceBuffer8AA : public virtual RMGfxSourceBuffer8 { protected: - static byte MegaAABuf[]; - static byte MegaAABuf2[]; + static byte _megaAABuf[]; + static byte _megaAABuf2[]; byte *_aabuf; // Calculate the buffer for the anti-aliasing @@ -528,9 +529,9 @@ public: RMGfxSourceBuffer4(int dimx, int dimy, bool bUseDDraw = false); // Initialisation - void Create(int dimx, int dimy, bool bUseDDraw = false); + void create(int dimx, int dimy, bool bUseDDraw = false); - int Bpp(); + int getBpp(); virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); }; @@ -556,7 +557,7 @@ private: // OSystem::MutexRef csModifyingOT; protected: - OTList *otlist; + OTList *_otlist; int _otSize; public: diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index c83402e724..bbc74afa01 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -77,7 +77,7 @@ void RMInventory::init(void) { int curres; // Create the main buffer - Create(RM_SX, 68); + create(RM_SX, 68); setPriority(185); // Setup the inventory @@ -788,13 +788,13 @@ void RMInterface::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr CORO_BEGIN_CODE(_ctx); - prim->Dst().topLeft() = _openStart; + prim->getDst().topLeft() = _openStart; CORO_INVOKE_2(RMGfxSourceBuffer8RLEByte::draw, bigBuf, prim); // Check if there is a draw hot zone _ctx->h = onWhichBox(_mpos); if (_ctx->h != -1) { - prim->Dst().topLeft() = _openStart; + prim->getDst().topLeft() = _openStart; CORO_INVOKE_2(_hotzone[_ctx->h].draw, bigBuf, prim); if (_lastHotZone != _ctx->h) { @@ -803,7 +803,7 @@ void RMInterface::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr } if (GLOBALS.bCfgInterTips) { - prim->Dst().topLeft() = _openStart + RMPoint(70, 177); + prim->getDst().topLeft() = _openStart + RMPoint(70, 177); CORO_INVOKE_2(_hints[_ctx->h].draw, bigBuf, prim); } } else diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 48480389bb..2700a05831 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -695,11 +695,11 @@ void RMItem::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { prim->setFlag(_bCurFlag); // Offset direction for scrolling - prim->Dst().offset(-_curScroll); + prim->getDst().offset(-_curScroll); // We must offset the cordinates of the item inside the primitive // It is estimated as nonno + (babbo + figlio) - prim->Dst().offset(calculatePos()); + prim->getDst().offset(calculatePos()); // No stretching, please prim->setStrecth(false); @@ -1333,7 +1333,7 @@ void RMCharacter::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr CORO_BEGIN_CODE(_ctx); if (bDrawNow) { - prim->Dst() += _fixedScroll; + prim->getDst() += _fixedScroll; CORO_INVOKE_2(RMItem::draw, bigBuf, prim); } @@ -2305,7 +2305,7 @@ RMMessage::RMMessage() { RMMessage::~RMMessage() { if (lpMessage) - GlobalFree(lpMessage); + globalFree(lpMessage); } void RMMessage::load(uint32 dwId) { diff --git a/engines/tony/mpal/expr.cpp b/engines/tony/mpal/expr.cpp index ae6dfac482..0b51724330 100644 --- a/engines/tony/mpal/expr.cpp +++ b/engines/tony/mpal/expr.cpp @@ -103,32 +103,32 @@ typedef EXPRESSION *LPEXPRESSION; * @param h Handle to the original expression * @retruns Pointer to the cloned expression */ -static byte *DuplicateExpression(HGLOBAL h) { +static byte *duplicateExpression(HGLOBAL h) { int i, num; byte *orig, *clone; LPEXPRESSION one, two; - orig = (byte *)GlobalLock(h); + orig = (byte *)globalLock(h); num = *(byte *)orig; one = (LPEXPRESSION)(orig+1); - clone = (byte *)GlobalAlloc(GMEM_FIXED, sizeof(EXPRESSION) * num + 1); + clone = (byte *)globalAlloc(GMEM_FIXED, sizeof(EXPRESSION) * num + 1); two = (LPEXPRESSION)(clone + 1); - CopyMemory(clone, orig, sizeof(EXPRESSION) * num + 1); + copyMemory(clone, orig, sizeof(EXPRESSION) * num + 1); for (i = 0; i < num; i++) { if (one->type == ELT_PARENTH) { two->type = ELT_PARENTH2; - two->val.pson = DuplicateExpression(two->val.son); + two->val.pson = duplicateExpression(two->val.son); } one++; two++; } - GlobalUnlock(h); + globalUnlock(h); return clone; } @@ -178,7 +178,7 @@ static int Compute(int a, int b, byte symbol) { return 0; } -static void Solve(LPEXPRESSION one, int num) { +static void solve(LPEXPRESSION one, int num) { LPEXPRESSION two, three; int j; @@ -186,7 +186,7 @@ static void Solve(LPEXPRESSION one, int num) { two=one + 1; if ((two->symbol == 0) || (one->symbol & 0xF0) <= (two->symbol & 0xF0)) { two->val.num = Compute(one->val.num, two->val.num,one->symbol); - CopyMemory(one, two, (num - 1) * sizeof(EXPRESSION)); + copyMemory(one, two, (num - 1) * sizeof(EXPRESSION)); num--; } else { j = 1; @@ -198,7 +198,7 @@ static void Solve(LPEXPRESSION one, int num) { } three->val.num = Compute(two->val.num, three->val.num, two->symbol); - CopyMemory(two, three, (num - j - 1) * sizeof(EXPRESSION)); + copyMemory(two, three, (num - j - 1) * sizeof(EXPRESSION)); num--; } } @@ -212,7 +212,7 @@ static void Solve(LPEXPRESSION one, int num) { * @param expr Pointer to an expression duplicated by DuplicateExpression * @returns Value */ -static int EvaluateAndFreeExpression(byte *expr) { +static int evaluateAndFreeExpression(byte *expr) { int i,num,val; LPEXPRESSION one,cur; @@ -231,14 +231,14 @@ static int EvaluateAndFreeExpression(byte *expr) { for (i = 0, cur = one; i < num; i++, cur++) { if (cur->type == ELT_PARENTH2) { cur->type = ELT_NUMBER; - cur->val.num = EvaluateAndFreeExpression(cur->val.pson); + cur->val.num = evaluateAndFreeExpression(cur->val.pson); } } // 3) Risoluzione algebrica - Solve(one, num); + solve(one, num); val = one->val.num; - GlobalFree(expr); + globalFree(expr); return val; } @@ -252,7 +252,7 @@ static int EvaluateAndFreeExpression(byte *expr) { * will point to the area of memory containing the parsed expression * @returns Pointer to the buffer immediately after the expression, or NULL if error. */ -const byte *ParseExpression(const byte *lpBuf, HGLOBAL *h) { +const byte *parseExpression(const byte *lpBuf, HGLOBAL *h) { LPEXPRESSION cur; byte *start; uint32 num, i; @@ -263,11 +263,11 @@ const byte *ParseExpression(const byte *lpBuf, HGLOBAL *h) { if (num == 0) return NULL; - *h = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, num * sizeof(EXPRESSION) + 1); + *h = globalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, num * sizeof(EXPRESSION) + 1); if (*h == NULL) return NULL; - start = (byte *)GlobalLock(*h); + start = (byte *)globalLock(*h); *start = (byte)num; cur = (LPEXPRESSION)(start + 1); @@ -283,15 +283,15 @@ const byte *ParseExpression(const byte *lpBuf, HGLOBAL *h) { break; case ELT_VAR: - cur->val.name = (char *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, (*lpBuf) + 1); + cur->val.name = (char *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, (*lpBuf) + 1); if (cur->val.name == NULL) return NULL; - CopyMemory(cur->val.name, lpBuf + 1, *lpBuf); + copyMemory(cur->val.name, lpBuf + 1, *lpBuf); lpBuf += *lpBuf + 1; break; case ELT_PARENTH: - lpBuf=ParseExpression(lpBuf, &cur->val.son); + lpBuf = parseExpression(lpBuf, &cur->val.son); if (lpBuf == NULL) return NULL; break; @@ -321,12 +321,12 @@ const byte *ParseExpression(const byte *lpBuf, HGLOBAL *h) { * @param h Handle to the expression * @returns Numeric value */ -int EvaluateExpression(HGLOBAL h) { +int evaluateExpression(HGLOBAL h) { int ret; - LockVar(); - ret=EvaluateAndFreeExpression(DuplicateExpression(h)); - UnlockVar(); + lockVar(); + ret = evaluateAndFreeExpression(duplicateExpression(h)); + unlockVar(); return ret; } @@ -337,20 +337,20 @@ int EvaluateExpression(HGLOBAL h) { * @param h1 Expression to be compared * @param h2 Expression to be compared */ -bool CompareExpressions(HGLOBAL h1, HGLOBAL h2) { +bool compareExpressions(HGLOBAL h1, HGLOBAL h2) { int i, num1, num2; byte *e1, *e2; LPEXPRESSION one, two; - e1 = (byte *)GlobalLock(h1); - e2 = (byte *)GlobalLock(h2); + e1 = (byte *)globalLock(h1); + e2 = (byte *)globalLock(h2); num1 = *(byte *)e1; num2 = *(byte *)e2; if (num1 != num2) { - GlobalUnlock(h1); - GlobalUnlock(h2); + globalUnlock(h1); + globalUnlock(h2); return false; } @@ -359,32 +359,32 @@ bool CompareExpressions(HGLOBAL h1, HGLOBAL h2) { for (i = 0; i < num1; i++) { if (one->type != two->type || (i != num1 - 1 && one->symbol != two->symbol)) { - GlobalUnlock(h1); - GlobalUnlock(h2); + globalUnlock(h1); + globalUnlock(h2); return false; } switch (one->type) { case ELT_NUMBER: if (one->val.num != two->val.num) { - GlobalUnlock(h1); - GlobalUnlock(h2); + globalUnlock(h1); + globalUnlock(h2); return false; } break; case ELT_VAR: if (strcmp(one->val.name, two->val.name) != 0) { - GlobalUnlock(h1); - GlobalUnlock(h2); + globalUnlock(h1); + globalUnlock(h2); return false; } break; case ELT_PARENTH: - if (!CompareExpressions(one->val.son, two->val.son)) { - GlobalUnlock(h1); - GlobalUnlock(h2); + if (!compareExpressions(one->val.son, two->val.son)) { + globalUnlock(h1); + globalUnlock(h2); return false; } break; @@ -394,8 +394,8 @@ bool CompareExpressions(HGLOBAL h1, HGLOBAL h2) { two++; } - GlobalUnlock(h1); - GlobalUnlock(h2); + globalUnlock(h1); + globalUnlock(h2); return true; } diff --git a/engines/tony/mpal/expr.h b/engines/tony/mpal/expr.h index 17e9c1264b..7d33e5c8ca 100644 --- a/engines/tony/mpal/expr.h +++ b/engines/tony/mpal/expr.h @@ -45,7 +45,7 @@ namespace MPAL { * will point to the area of memory containing the parsed expression * @returns Pointer to the buffer immediately after the expression, or NULL if error. */ -const byte *ParseExpression(const byte *lpBuf, HGLOBAL *h); +const byte *parseExpression(const byte *lpBuf, HGLOBAL *h); /** * Calculate the value of a mathamatical expression @@ -53,7 +53,7 @@ const byte *ParseExpression(const byte *lpBuf, HGLOBAL *h); * @param h Handle to the expression * @returns Numeric value */ -int EvaluateExpression(HGLOBAL h); +int evaluateExpression(HGLOBAL h); /** * Compare two mathematical expressions together @@ -61,7 +61,7 @@ int EvaluateExpression(HGLOBAL h); * @param h1 Expression to be compared * @param h2 Expression to be compared */ -bool CompareExpressions(HGLOBAL h1, HGLOBAL h2); +bool compareExpressions(HGLOBAL h1, HGLOBAL h2); } // end of namespace MPAL diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index 02571bd30f..8f07102aa3 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -42,10 +42,10 @@ namespace MPAL { * Funzioni statiche \****************************************************************************/ -static bool CompareCommands(struct command *cmd1, struct command *cmd2) { +static bool compareCommands(struct command *cmd1, struct command *cmd2) { if (cmd1->type == 2 && cmd2->type == 2) { if (strcmp(cmd1->lpszVarName, cmd2->lpszVarName) == 0 && - CompareExpressions(cmd1->expr, cmd2->expr)) + compareExpressions(cmd1->expr, cmd2->expr)) return true; else return false; @@ -80,32 +80,32 @@ static const byte *ParseScript(const byte *lpBuf, LPMPALSCRIPT lpmsScript) { lpBuf++; for (j = 0; j < lpmsScript->Moment[i].nCmds; j++) { - lpmsScript->Command[curCmd].type = *lpBuf; + lpmsScript->_command[curCmd].type = *lpBuf; lpBuf++; - switch (lpmsScript->Command[curCmd].type) { + switch (lpmsScript->_command[curCmd].type) { case 1: - lpmsScript->Command[curCmd].nCf = READ_LE_UINT16(lpBuf); + lpmsScript->_command[curCmd].nCf = READ_LE_UINT16(lpBuf); lpBuf += 2; - lpmsScript->Command[curCmd].arg1 = (int32)READ_LE_UINT32(lpBuf); + lpmsScript->_command[curCmd].arg1 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmsScript->Command[curCmd].arg2 = (int32)READ_LE_UINT32(lpBuf); + lpmsScript->_command[curCmd].arg2 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmsScript->Command[curCmd].arg3 = (int32)READ_LE_UINT32(lpBuf); + lpmsScript->_command[curCmd].arg3 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmsScript->Command[curCmd].arg4 = (int32)READ_LE_UINT32(lpBuf); + lpmsScript->_command[curCmd].arg4 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; break; case 2: // Variable assign len = *lpBuf; lpBuf++; - lpmsScript->Command[curCmd].lpszVarName = (char *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, len + 1); - if (lpmsScript->Command[curCmd].lpszVarName == NULL) + lpmsScript->_command[curCmd].lpszVarName = (char *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, len + 1); + if (lpmsScript->_command[curCmd].lpszVarName == NULL) return NULL; - CopyMemory(lpmsScript->Command[curCmd].lpszVarName, lpBuf, len); + copyMemory(lpmsScript->_command[curCmd].lpszVarName, lpBuf, len); lpBuf += len; - lpBuf = ParseExpression(lpBuf, &lpmsScript->Command[curCmd].expr); + lpBuf = parseExpression(lpBuf, &lpmsScript->_command[curCmd].expr); if (lpBuf == NULL) return NULL; break; @@ -129,7 +129,7 @@ static const byte *ParseScript(const byte *lpBuf, LPMPALSCRIPT lpmsScript) { * data of the dialog. * @returns Pointer to the buffer after the item, or NULL on failure. */ -static const byte *ParseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { +static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { uint32 i, j, z, kk; uint32 num, num2, num3; byte *lpLock; @@ -147,17 +147,17 @@ static const byte *ParseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { error("Too much periods in dialog #%d", lpmdDialog->nObj); for (i = 0; i < num; i++) { - lpmdDialog->PeriodNums[i] = READ_LE_UINT16(lpBuf); + lpmdDialog->_periodNums[i] = READ_LE_UINT16(lpBuf); lpBuf += 2; - lpmdDialog->Periods[i] = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, *lpBuf + 1); - lpLock = (byte *)GlobalLock(lpmdDialog->Periods[i]); + lpmdDialog->_periods[i] = globalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, *lpBuf + 1); + lpLock = (byte *)globalLock(lpmdDialog->_periods[i]); Common::copy(lpBuf + 1, lpBuf + 1 + *lpBuf, lpLock); - GlobalUnlock(lpmdDialog->Periods[i]); + globalUnlock(lpmdDialog->_periods[i]); lpBuf += (*lpBuf) + 1; } - lpmdDialog->PeriodNums[i] = 0; - lpmdDialog->Periods[i] = NULL; + lpmdDialog->_periodNums[i] = 0; + lpmdDialog->_periods[i] = NULL; /* Gruppi */ num = READ_LE_UINT16(lpBuf); @@ -168,29 +168,29 @@ static const byte *ParseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { error("Too much groups in dialog #%d", lpmdDialog->nObj); for (i = 0; i < num; i++) { - lpmdDialog->Group[i].num = READ_LE_UINT16(lpBuf); + lpmdDialog->_group[i].num = READ_LE_UINT16(lpBuf); lpBuf += 2; - lpmdDialog->Group[i].nCmds = *lpBuf; lpBuf++; + lpmdDialog->_group[i].nCmds = *lpBuf; lpBuf++; - if (lpmdDialog->Group[i].nCmds >= MAX_COMMANDS_PER_GROUP) - error("Too much commands in group #%d in dialog #%d",lpmdDialog->Group[i].num,lpmdDialog->nObj); + if (lpmdDialog->_group[i].nCmds >= MAX_COMMANDS_PER_GROUP) + error("Too much commands in group #%d in dialog #%d",lpmdDialog->_group[i].num,lpmdDialog->nObj); - for (j = 0; j < lpmdDialog->Group[i].nCmds; j++) { - lpmdDialog->Command[curCmd].type = *lpBuf; + for (j = 0; j < lpmdDialog->_group[i].nCmds; j++) { + lpmdDialog->_command[curCmd].type = *lpBuf; lpBuf++; - switch (lpmdDialog->Command[curCmd].type) { + switch (lpmdDialog->_command[curCmd].type) { // Call custom function case 1: - lpmdDialog->Command[curCmd].nCf = READ_LE_UINT16(lpBuf); + lpmdDialog->_command[curCmd].nCf = READ_LE_UINT16(lpBuf); lpBuf += 2; - lpmdDialog->Command[curCmd].arg1 = READ_LE_UINT32(lpBuf); + lpmdDialog->_command[curCmd].arg1 = READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmdDialog->Command[curCmd].arg2 = READ_LE_UINT32(lpBuf); + lpmdDialog->_command[curCmd].arg2 = READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmdDialog->Command[curCmd].arg3 = READ_LE_UINT32(lpBuf); + lpmdDialog->_command[curCmd].arg3 = READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmdDialog->Command[curCmd].arg4 = READ_LE_UINT32(lpBuf); + lpmdDialog->_command[curCmd].arg4 = READ_LE_UINT32(lpBuf); lpBuf += 4; break; @@ -198,21 +198,21 @@ static const byte *ParseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { case 2: len = *lpBuf; lpBuf++; - lpmdDialog->Command[curCmd].lpszVarName = (char *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, len + 1); - if (lpmdDialog->Command[curCmd].lpszVarName == NULL) + lpmdDialog->_command[curCmd].lpszVarName = (char *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, len + 1); + if (lpmdDialog->_command[curCmd].lpszVarName == NULL) return NULL; - Common::copy(lpBuf, lpBuf + len, lpmdDialog->Command[curCmd].lpszVarName); + Common::copy(lpBuf, lpBuf + len, lpmdDialog->_command[curCmd].lpszVarName); lpBuf += len; - lpBuf = ParseExpression(lpBuf, &lpmdDialog->Command[curCmd].expr); + lpBuf = parseExpression(lpBuf, &lpmdDialog->_command[curCmd].expr); if (lpBuf == NULL) return NULL; break; // Do Choice case 3: - lpmdDialog->Command[curCmd].nChoice = READ_LE_UINT16(lpBuf); + lpmdDialog->_command[curCmd].nChoice = READ_LE_UINT16(lpBuf); lpBuf += 2; break; @@ -221,14 +221,14 @@ static const byte *ParseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { } for (kk = 0;kk < curCmd; kk++) { - if (CompareCommands(&lpmdDialog->Command[kk], &lpmdDialog->Command[curCmd])) { - lpmdDialog->Group[i].CmdNum[j] = kk; + if (compareCommands(&lpmdDialog->_command[kk], &lpmdDialog->_command[curCmd])) { + lpmdDialog->_group[i].CmdNum[j] = kk; break; } } if (kk == curCmd) { - lpmdDialog->Group[i].CmdNum[j] = curCmd; + lpmdDialog->_group[i].CmdNum[j] = curCmd; curCmd++; } } @@ -245,23 +245,23 @@ static const byte *ParseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { error("Too much choices in dialog #%d",lpmdDialog->nObj); for (i = 0; i < num; i++) { - lpmdDialog->Choice[i].nChoice = READ_LE_UINT16(lpBuf); + lpmdDialog->_choice[i].nChoice = READ_LE_UINT16(lpBuf); lpBuf += 2; num2 = *lpBuf++; if (num2 >= MAX_SELECTS_PER_CHOICE) - error("Too much selects in choice #%d in dialog #%d",lpmdDialog->Choice[i].nChoice,lpmdDialog->nObj); + error("Too much selects in choice #%d in dialog #%d", lpmdDialog->_choice[i].nChoice, lpmdDialog->nObj); for (j = 0; j < num2; j++) { // When switch (*lpBuf++) { case 0: - lpmdDialog->Choice[i].Select[j].when = NULL; + lpmdDialog->_choice[i]._select[j].when = NULL; break; case 1: - lpBuf = ParseExpression(lpBuf,&lpmdDialog->Choice[i].Select[j].when); + lpBuf = parseExpression(lpBuf, &lpmdDialog->_choice[i]._select[j].when); if (lpBuf == NULL) return NULL; break; @@ -271,31 +271,31 @@ static const byte *ParseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { } // Attrib - lpmdDialog->Choice[i].Select[j].attr = *lpBuf++; + lpmdDialog->_choice[i]._select[j].attr = *lpBuf++; // Data - lpmdDialog->Choice[i].Select[j].dwData = READ_LE_UINT32(lpBuf); + lpmdDialog->_choice[i]._select[j].dwData = READ_LE_UINT32(lpBuf); lpBuf += 4; // PlayGroup num3 = *lpBuf++; if (num3 >= MAX_PLAYGROUPS_PER_SELECT) - error("Too much playgroups in select #%d in choice #%d in dialog #%d", j, lpmdDialog->Choice[i].nChoice, lpmdDialog->nObj); + error("Too much playgroups in select #%d in choice #%d in dialog #%d", j, lpmdDialog->_choice[i].nChoice, lpmdDialog->nObj); for (z = 0; z < num3; z++) { - lpmdDialog->Choice[i].Select[j].wPlayGroup[z] = READ_LE_UINT16(lpBuf); + lpmdDialog->_choice[i]._select[j].wPlayGroup[z] = READ_LE_UINT16(lpBuf); lpBuf += 2; } - lpmdDialog->Choice[i].Select[j].wPlayGroup[num3] = 0; + lpmdDialog->_choice[i]._select[j].wPlayGroup[num3] = 0; } // Mark the last selection - lpmdDialog->Choice[i].Select[num2].dwData = 0; + lpmdDialog->_choice[i]._select[num2].dwData = 0; } - lpmdDialog->Choice[num].nChoice = 0; + lpmdDialog->_choice[num].nChoice = 0; return lpBuf; } @@ -311,7 +311,7 @@ static const byte *ParseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { * @remarks It's necessary that the structure that is passed has been * completely initialised to 0 beforehand. */ -static const byte *ParseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { +static const byte *parseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { byte len; uint32 i, j, kk; uint32 curCmd; @@ -321,7 +321,7 @@ static const byte *ParseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { len = *lpBuf; lpBuf++; - CopyMemory(lpmiItem->lpszDescribe, lpBuf, MIN((byte)127, len)); + copyMemory(lpmiItem->lpszDescribe, lpBuf, MIN((byte)127, len)); lpBuf += len; if (len >= MAX_DESCRIBE_SIZE) @@ -332,7 +332,7 @@ static const byte *ParseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { /* Alloca le azioni */ if (lpmiItem->nActions > 0) - lpmiItem->Action = (ItemAction *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(struct ItemAction) * (int)lpmiItem->nActions); + lpmiItem->Action = (ItemAction *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(struct ItemAction) * (int)lpmiItem->nActions); curCmd = 0; @@ -357,7 +357,7 @@ static const byte *ParseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { lpmiItem->Action[i].when = NULL; } else { lpBuf++; - lpBuf = ParseExpression(lpBuf,&lpmiItem->Action[i].when); + lpBuf = parseExpression(lpBuf,&lpmiItem->Action[i].when); if (lpBuf == NULL) return NULL; } @@ -369,32 +369,32 @@ static const byte *ParseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { error("Too much commands in action #%d in item #%d",lpmiItem->Action[i].num,lpmiItem->nObj); for (j = 0; j < lpmiItem->Action[i].nCmds; j++) { - lpmiItem->Command[curCmd].type = *lpBuf; + lpmiItem->_command[curCmd].type = *lpBuf; lpBuf++; - switch (lpmiItem->Command[curCmd].type) { + switch (lpmiItem->_command[curCmd].type) { case 1: // Call custom function - lpmiItem->Command[curCmd].nCf = READ_LE_UINT16(lpBuf); + lpmiItem->_command[curCmd].nCf = READ_LE_UINT16(lpBuf); lpBuf += 2; - lpmiItem->Command[curCmd].arg1 = (int32)READ_LE_UINT32(lpBuf); + lpmiItem->_command[curCmd].arg1 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmiItem->Command[curCmd].arg2 = (int32)READ_LE_UINT32(lpBuf); + lpmiItem->_command[curCmd].arg2 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmiItem->Command[curCmd].arg3 = (int32)READ_LE_UINT32(lpBuf); + lpmiItem->_command[curCmd].arg3 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmiItem->Command[curCmd].arg4 = (int32)READ_LE_UINT32(lpBuf); + lpmiItem->_command[curCmd].arg4 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; break; case 2: // Variable assign len = *lpBuf; lpBuf++; - lpmiItem->Command[curCmd].lpszVarName = (char *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, len + 1); - if (lpmiItem->Command[curCmd].lpszVarName == NULL) + lpmiItem->_command[curCmd].lpszVarName = (char *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, len + 1); + if (lpmiItem->_command[curCmd].lpszVarName == NULL) return NULL; - CopyMemory(lpmiItem->Command[curCmd].lpszVarName, lpBuf, len); + copyMemory(lpmiItem->_command[curCmd].lpszVarName, lpBuf, len); lpBuf += len; - lpBuf=ParseExpression(lpBuf, &lpmiItem->Command[curCmd].expr); + lpBuf = parseExpression(lpBuf, &lpmiItem->_command[curCmd].expr); if (lpBuf == NULL) return NULL; break; @@ -404,7 +404,7 @@ static const byte *ParseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { } for (kk = 0; kk < curCmd; kk++) { - if (CompareCommands(&lpmiItem->Command[kk],&lpmiItem->Command[curCmd])) { + if (compareCommands(&lpmiItem->_command[kk], &lpmiItem->_command[curCmd])) { lpmiItem->Action[i].CmdNum[j] = kk; break; } @@ -478,16 +478,16 @@ bool ParseMpc(const byte *lpBuf) { GLOBALS.nVars = READ_LE_UINT16(lpBuf); lpBuf += 2; - GLOBALS.hVars = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof(MPALVAR) * (uint32)GLOBALS.nVars); + GLOBALS.hVars = globalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof(MPALVAR) * (uint32)GLOBALS.nVars); if (GLOBALS.hVars == NULL) return false; - GLOBALS.lpmvVars = (LPMPALVAR)GlobalLock(GLOBALS.hVars); + GLOBALS.lpmvVars = (LPMPALVAR)globalLock(GLOBALS.hVars); for (i = 0; i < GLOBALS.nVars; i++) { wLen = *(const byte *)lpBuf; lpBuf++; - CopyMemory(GLOBALS.lpmvVars->lpszVarName, lpBuf, MIN(wLen, (uint16)32)); + copyMemory(GLOBALS.lpmvVars->lpszVarName, lpBuf, MIN(wLen, (uint16)32)); lpBuf += wLen; GLOBALS.lpmvVars->dwVal = READ_LE_UINT32(lpBuf); lpBuf += 4; @@ -496,7 +496,7 @@ bool ParseMpc(const byte *lpBuf) { GLOBALS.lpmvVars++; } - GlobalUnlock(GLOBALS.hVars); + globalUnlock(GLOBALS.hVars); /* 2. Messages */ if (lpBuf[0] != 'M' || lpBuf[1] != 'S' || lpBuf[2] != 'G' || lpBuf[3] != 'S') @@ -507,11 +507,11 @@ bool ParseMpc(const byte *lpBuf) { lpBuf += 2; #ifdef NEED_LOCK_MSGS - GLOBALS.hMsgs = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof(MPALMSG) * (uint32)GLOBALS.nMsgs); + GLOBALS.hMsgs = globalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof(MPALMSG) * (uint32)GLOBALS.nMsgs); if (GLOBALS.hMsgs == NULL) return false; - GLOBALS.lpmmMsgs = (LPMPALMSG)GlobalLock(GLOBALS.hMsgs); + GLOBALS.lpmmMsgs = (LPMPALMSG)globalLock(GLOBALS.hMsgs); #else GLOBALS.lpmmMsgs=(LPMPALMSG)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,sizeof(MPALMSG)*(uint32)GLOBALS.nMsgs); if (GLOBALS.lpmmMsgs==NULL) @@ -525,11 +525,11 @@ bool ParseMpc(const byte *lpBuf) { for (j = 0; lpBuf[j] != 0;) j += lpBuf[j] + 1; - GLOBALS.lpmmMsgs->hText = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, j + 1); - lpTemp2 = lpTemp = (byte *)GlobalLock(GLOBALS.lpmmMsgs->hText); + GLOBALS.lpmmMsgs->hText = globalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, j + 1); + lpTemp2 = lpTemp = (byte *)globalLock(GLOBALS.lpmmMsgs->hText); for (j = 0; lpBuf[j] != 0;) { - CopyMemory(lpTemp, &lpBuf[j + 1], lpBuf[j]); + copyMemory(lpTemp, &lpBuf[j + 1], lpBuf[j]); lpTemp += lpBuf[j]; *lpTemp ++= '\0'; j += lpBuf[j] + 1; @@ -538,12 +538,12 @@ bool ParseMpc(const byte *lpBuf) { lpBuf += j + 1; *lpTemp = '\0'; - GlobalUnlock(GLOBALS.lpmmMsgs->hText); + globalUnlock(GLOBALS.lpmmMsgs->hText); GLOBALS.lpmmMsgs++; } #ifdef NEED_LOCK_MSGS - GlobalUnlock(GLOBALS.hMsgs); + globalUnlock(GLOBALS.hMsgs); #endif /* 3. Objects */ @@ -560,17 +560,17 @@ bool ParseMpc(const byte *lpBuf) { if (*((const byte *)lpBuf + 2) == 6 && strncmp((const char *)lpBuf + 3, "Dialog", 6) == 0) { GLOBALS.nDialogs = READ_LE_UINT16(lpBuf); lpBuf += 2; - GLOBALS.hDialogs = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nDialogs * sizeof(MPALDIALOG)); + GLOBALS.hDialogs = globalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nDialogs * sizeof(MPALDIALOG)); if (GLOBALS.hDialogs == NULL) return false; - GLOBALS.lpmdDialogs = (LPMPALDIALOG)GlobalLock(GLOBALS.hDialogs); + GLOBALS.lpmdDialogs = (LPMPALDIALOG)globalLock(GLOBALS.hDialogs); for (i = 0;i < GLOBALS.nDialogs; i++) - if ((lpBuf = ParseDialog(lpBuf + 7, &GLOBALS.lpmdDialogs[i])) == NULL) + if ((lpBuf = parseDialog(lpBuf + 7, &GLOBALS.lpmdDialogs[i])) == NULL) return false; - GlobalUnlock(GLOBALS.hDialogs); + globalUnlock(GLOBALS.hDialogs); } // Check the items @@ -581,17 +581,17 @@ bool ParseMpc(const byte *lpBuf) { lpBuf += 2; // Allocate memory and read them in - GLOBALS.hItems = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nItems * sizeof(MPALITEM)); + GLOBALS.hItems = globalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nItems * sizeof(MPALITEM)); if (GLOBALS.hItems == NULL) return false; - GLOBALS.lpmiItems = (LPMPALITEM)GlobalLock(GLOBALS.hItems); + GLOBALS.lpmiItems = (LPMPALITEM)globalLock(GLOBALS.hItems); for (i = 0; i < GLOBALS.nItems; i++) - if ((lpBuf = ParseItem(lpBuf + 5, &GLOBALS.lpmiItems[i])) == NULL) + if ((lpBuf = parseItem(lpBuf + 5, &GLOBALS.lpmiItems[i])) == NULL) return false; - GlobalUnlock(GLOBALS.hItems); + globalUnlock(GLOBALS.hItems); } // Check the locations @@ -602,17 +602,17 @@ bool ParseMpc(const byte *lpBuf) { lpBuf += 2; // Allocate memory and read them in - GLOBALS.hLocations=GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nLocations*sizeof(MPALLOCATION)); + GLOBALS.hLocations = globalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nLocations*sizeof(MPALLOCATION)); if (GLOBALS.hLocations == NULL) return false; - GLOBALS.lpmlLocations = (LPMPALLOCATION)GlobalLock(GLOBALS.hLocations); + GLOBALS.lpmlLocations = (LPMPALLOCATION)globalLock(GLOBALS.hLocations); for (i = 0; i < GLOBALS.nLocations; i++) if ((lpBuf = ParseLocation(lpBuf + 9, &GLOBALS.lpmlLocations[i])) == NULL) return false; - GlobalUnlock(GLOBALS.hLocations); + globalUnlock(GLOBALS.hLocations); } // Check the scripts @@ -623,11 +623,11 @@ bool ParseMpc(const byte *lpBuf) { lpBuf += 2; // Allocate memory - GLOBALS.hScripts = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nScripts * sizeof(MPALSCRIPT)); + GLOBALS.hScripts = globalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nScripts * sizeof(MPALSCRIPT)); if (GLOBALS.hScripts == NULL) return false; - GLOBALS.lpmsScripts = (LPMPALSCRIPT)GlobalLock(GLOBALS.hScripts); + GLOBALS.lpmsScripts = (LPMPALSCRIPT)globalLock(GLOBALS.hScripts); for (i = 0; i < GLOBALS.nScripts; i++) { if ((lpBuf = ParseScript(lpBuf + 7, &GLOBALS.lpmsScripts[i])) == NULL) @@ -642,7 +642,7 @@ bool ParseMpc(const byte *lpBuf) { //); } - GlobalUnlock(GLOBALS.hScripts); + globalUnlock(GLOBALS.hScripts); } if (lpBuf[0] != 'E' || lpBuf[1] != 'N' || lpBuf[2] != 'D' || lpBuf[3] != '0') diff --git a/engines/tony/mpal/memory.cpp b/engines/tony/mpal/memory.cpp index 04cb906431..b5bd77f838 100644 --- a/engines/tony/mpal/memory.cpp +++ b/engines/tony/mpal/memory.cpp @@ -53,7 +53,7 @@ MemoryItem::~MemoryItem() { * Returns a pointer to the resource */ MemoryItem::operator void *() { - return DataPointer(); + return dataPointer(); } /****************************************************************************\ @@ -81,7 +81,7 @@ MemoryManager::~MemoryManager() { MemoryItem &MemoryManager::allocate(uint32 size, uint flags) { MemoryItem *newItem = new MemoryItem(size); if ((flags & GMEM_ZEROINIT) != 0) { - byte *dataP = (byte *)newItem->DataPointer(); + byte *dataP = (byte *)newItem->dataPointer(); Common::fill(dataP, dataP + size, 0); } @@ -96,7 +96,7 @@ MemoryItem &MemoryManager::allocate(uint32 size, uint flags) { */ HGLOBAL MemoryManager::alloc(uint32 size, uint flags) { MemoryItem &newItem = allocate(size, flags); - return (HGLOBAL)newItem.DataPointer(); + return (HGLOBAL)newItem.dataPointer(); } /** @@ -107,7 +107,7 @@ MemoryItem &MemoryManager::getItem(HGLOBAL handle) { Common::List::iterator i; for (i = _memoryBlocks.begin(); i != _memoryBlocks.end(); ++i) { MemoryItem *item = *i; - if (item->DataPointer() == handle) + if (item->dataPointer() == handle) return *item; } @@ -127,7 +127,7 @@ MemoryItem &MemoryManager::operator[](HGLOBAL handle) { */ uint32 MemoryManager::getSize(HGLOBAL handle) { MemoryItem &item = getItem(handle); - return item.Size(); + return item.size(); } /** @@ -150,7 +150,7 @@ void MemoryManager::erase(HGLOBAL handle) { * Stand-alone methods \****************************************************************************/ -void CopyMemory(void *dst, const void *first, int size) { +void copyMemory(void *dst, const void *first, int size) { Common::copy((const byte *)first, (const byte *)first + size, (byte *)dst); } diff --git a/engines/tony/mpal/memory.h b/engines/tony/mpal/memory.h index 8d8411c6a1..7f95f8d86f 100644 --- a/engines/tony/mpal/memory.h +++ b/engines/tony/mpal/memory.h @@ -42,9 +42,9 @@ public: MemoryItem(uint32 size); virtual ~MemoryItem(); - uint32 Size() { return _size; } - void *DataPointer() { return (void *)_buffer; } - bool IsValid() { return _buffer != NULL; } + uint32 size() { return _size; } + void *dataPointer() { return (void *)_buffer; } + bool isValid() { return _buffer != NULL; } // Casting for access to data operator void *(); @@ -68,19 +68,19 @@ public: }; // defines -#define GlobalAlloc(flags, size) _vm->_memoryManager.alloc(size, flags) -#define GlobalAllocate(size) _vm->_memoryManager.allocate(size, 0) -#define GlobalFree(handle) _vm->_memoryManager.erase(handle) -#define GlobalLock(handle) (_vm->_memoryManager.getItem(handle).DataPointer()) -#define GlobalUnlock(handle) {} -#define GlobalSize(handle) (_vm->_memoryManager.getItem(handle).Size()) +#define globalAlloc(flags, size) _vm->_memoryManager.alloc(size, flags) +#define globalAllocate(size) _vm->_memoryManager.allocate(size, 0) +#define globalFree(handle) _vm->_memoryManager.erase(handle) +#define globalLock(handle) (_vm->_memoryManager.getItem(handle).dataPointer()) +#define globalUnlock(handle) {} +#define globalSize(handle) (_vm->_memoryManager.getItem(handle).size()) #define GMEM_FIXED 1 #define GMEM_MOVEABLE 2 #define GMEM_ZEROINIT 4 // Stand-alone methods -extern void CopyMemory(void *dst, const void *first, int size); +extern void copyMemory(void *dst, const void *first, int size); } // end of namespace MPAL diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 16c530206c..95c0b067d5 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -59,16 +59,16 @@ const char *mpalCopyright = /** * Locks the variables for access */ -void LockVar(void) { - GLOBALS.lpmvVars = (LPMPALVAR)GlobalLock(GLOBALS.hVars); +void lockVar(void) { + GLOBALS.lpmvVars = (LPMPALVAR)globalLock(GLOBALS.hVars); } /** * Unlocks variables after use */ -void UnlockVar(void) { - GlobalUnlock(GLOBALS.hVars); +void unlockVar(void) { + globalUnlock(GLOBALS.hVars); } @@ -77,7 +77,7 @@ void UnlockVar(void) { */ static void LockMsg(void) { #ifdef NEED_LOCK_MSGS - GLOBALS.lpmmMsgs = (LPMPALMSG)GlobalLock(GLOBALS.hMsgs); + GLOBALS.lpmmMsgs = (LPMPALMSG)globalLock(GLOBALS.hMsgs); #endif } @@ -87,7 +87,7 @@ static void LockMsg(void) { */ static void UnlockMsg(void) { #ifdef NEED_LOCK_MSGS - GlobalUnlock(GLOBALS.hMsgs); + globalUnlock(GLOBALS.hMsgs); #endif } @@ -95,48 +95,48 @@ static void UnlockMsg(void) { /** * Locks the dialogs for access */ -static void LockDialogs(void) { - GLOBALS.lpmdDialogs = (LPMPALDIALOG)GlobalLock(GLOBALS.hDialogs); +static void lockDialogs(void) { + GLOBALS.lpmdDialogs = (LPMPALDIALOG)globalLock(GLOBALS.hDialogs); } /** * Unlocks the dialogs after use */ -static void UnlockDialogs(void) { - GlobalUnlock(GLOBALS.hDialogs); +static void unlockDialogs(void) { + globalUnlock(GLOBALS.hDialogs); } /** * Locks the location data structures for access */ -static void LockLocations(void) { - GLOBALS.lpmlLocations = (LPMPALLOCATION)GlobalLock(GLOBALS.hLocations); +static void lockLocations(void) { + GLOBALS.lpmlLocations = (LPMPALLOCATION)globalLock(GLOBALS.hLocations); } /** * Unlocks the location structures after use */ -static void UnlockLocations(void) { - GlobalUnlock(GLOBALS.hLocations); +static void unlockLocations(void) { + globalUnlock(GLOBALS.hLocations); } /** * Locks the items structures for use */ -static void LockItems(void) { - GLOBALS.lpmiItems = (LPMPALITEM)GlobalLock(GLOBALS.hItems); +static void lockItems(void) { + GLOBALS.lpmiItems = (LPMPALITEM)globalLock(GLOBALS.hItems); } /** * Unlocks the items structures after use */ -static void UnlockItems(void) { - GlobalUnlock(GLOBALS.hItems); +static void unlockItems(void) { + globalUnlock(GLOBALS.hItems); } @@ -144,15 +144,15 @@ static void UnlockItems(void) { * Locks the script data structures for use */ static void LockScripts(void) { - GLOBALS.lpmsScripts = (LPMPALSCRIPT)GlobalLock(GLOBALS.hScripts); + GLOBALS.lpmsScripts = (LPMPALSCRIPT)globalLock(GLOBALS.hScripts); } /** * Unlocks the script data structures after use */ -static void UnlockScripts(void) { - GlobalUnlock(GLOBALS.hScripts); +static void unlockScripts(void) { + globalUnlock(GLOBALS.hScripts); } @@ -161,7 +161,7 @@ static void UnlockScripts(void) { * * @param lpszVarName Name of the variable * @returns Current value - * @remarks Before using this method, you must call LockVar() to + * @remarks Before using this method, you must call lockVar() to * lock the global variablves for use. Then afterwards, you will * need to remember to call UnlockVar() */ @@ -316,19 +316,19 @@ static char *DuplicateMessage(uint32 nMsgOrd) { if (nMsgOrd == (uint32)-1) return NULL; - origmsg = (const char *)GlobalLock(GLOBALS.lpmmMsgs[nMsgOrd].hText); + origmsg = (const char *)globalLock(GLOBALS.lpmmMsgs[nMsgOrd].hText); j = 0; while (origmsg[j] != '\0' || origmsg[j + 1] != '\0') j++; j += 2; - clonemsg = (char *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, j); + clonemsg = (char *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, j); if (clonemsg == NULL) return NULL; - CopyMemory(clonemsg, origmsg, j); - GlobalUnlock(GLOBALS.lpmmMsgs[nMsgOrd].hText); + copyMemory(clonemsg, origmsg, j); + globalUnlock(GLOBALS.lpmmMsgs[nMsgOrd].hText); return clonemsg; } @@ -341,28 +341,28 @@ static char *DuplicateMessage(uint32 nMsgOrd) { * @returns Pointer to the duplicated phrase. Remember to free it * when done with it. */ -static char *DuplicateDialogPeriod(uint32 nPeriod) { +static char *duplicateDialogPeriod(uint32 nPeriod) { const char *origmsg; char *clonemsg; LPMPALDIALOG dialog = GLOBALS.lpmdDialogs + GLOBALS.nExecutingDialog; int i, j; - for (j = 0; dialog->Periods[j] != NULL; j++) - if (dialog->PeriodNums[j] == nPeriod) { + for (j = 0; dialog->_periods[j] != NULL; j++) + if (dialog->_periodNums[j] == nPeriod) { /* Found the phrase, it should be duplicated */ - origmsg = (const char *)GlobalLock(dialog->Periods[j]); + origmsg = (const char *)globalLock(dialog->_periods[j]); /* Calculate the length and allocate memory */ i = 0; while (origmsg[i] != '\0') i++; - clonemsg = (char *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, i + 1); + clonemsg = (char *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, i + 1); if (clonemsg == NULL) return NULL; - CopyMemory(clonemsg, origmsg, i); + copyMemory(clonemsg, origmsg, i); - GlobalUnlock(dialog->Periods[j]); + globalUnlock(dialog->_periods[j]); return clonemsg; } @@ -402,9 +402,9 @@ HGLOBAL resLoad(uint32 dwId) { if (GLOBALS.hMpr.err()) return NULL; - h = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, nSizeDecomp + (nSizeDecomp / 1024) * 16); - buf = (byte *)GlobalLock(h); - temp = (byte *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT,nSizeComp); + h = globalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, nSizeDecomp + (nSizeDecomp / 1024) * 16); + buf = (byte *)globalLock(h); + temp = (byte *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT,nSizeComp); nBytesRead = GLOBALS.hMpr.read(temp, nSizeComp); if (nBytesRead != nSizeComp) @@ -414,38 +414,38 @@ HGLOBAL resLoad(uint32 dwId) { if (nBytesRead != nSizeDecomp) return NULL; - GlobalFree(temp); - GlobalUnlock(h); + globalFree(temp); + globalUnlock(h); return h; } return NULL; } -static uint32 *GetSelectList(uint32 i) { +static uint32 *getSelectList(uint32 i) { uint32 *sl; - int j,k,num; - LPMPALDIALOG dialog=GLOBALS.lpmdDialogs+GLOBALS.nExecutingDialog; + int j, k, num; + LPMPALDIALOG dialog = GLOBALS.lpmdDialogs+GLOBALS.nExecutingDialog; /* Count how many are active selects */ num = 0; - for (j = 0; dialog->Choice[i].Select[j].dwData != 0; j++) - if (dialog->Choice[i].Select[j].curActive) + for (j = 0; dialog->_choice[i]._select[j].dwData != 0; j++) + if (dialog->_choice[i]._select[j].curActive) num++; /* If there are 0, it's a mistake */ if (num == 0) return NULL; - sl= (uint32 *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(uint32) * (num + 1)); + sl= (uint32 *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(uint32) * (num + 1)); if (sl == NULL) return NULL; /* Copy all the data inside the active select list */ k = 0; - for (j = 0; dialog->Choice[i].Select[j].dwData != 0; j++) - if (dialog->Choice[i].Select[j].curActive) - sl[k++] = dialog->Choice[i].Select[j].dwData; + for (j = 0; dialog->_choice[i]._select[j].dwData != 0; j++) + if (dialog->_choice[i]._select[j].curActive) + sl[k++] = dialog->_choice[i]._select[j].dwData; sl[k] = (uint32)NULL; return sl; @@ -462,7 +462,7 @@ static uint32 *GetItemList(uint32 nLoc) { num++; } - il = (uint32 *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(uint32) * (num + 1)); + il = (uint32 *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(uint32) * (num + 1)); if (il == NULL) return NULL; @@ -479,7 +479,7 @@ static uint32 *GetItemList(uint32 nLoc) { return il; } -static LPITEM GetItemData(uint32 nOrdItem) { +static LPITEM getItemData(uint32 nOrdItem) { LPMPALITEM curitem = GLOBALS.lpmiItems+nOrdItem; LPITEM ret; HGLOBAL hDat; @@ -489,13 +489,13 @@ static LPITEM GetItemData(uint32 nOrdItem) { uint32 dim; // Zeroing out the allocated memory is required!!! - ret = (LPITEM)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(ITEM)); + ret = (LPITEM)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(ITEM)); if (ret == NULL) return NULL; ret->speed = 150; hDat = resLoad(curitem->dwRes); - dat = (char *)GlobalLock(hDat); + dat = (char *)globalLock(hDat); if (dat[0] == 'D' && dat[1] == 'A' && dat[2] == 'T') { i = dat[3]; // For version 1.0!! @@ -556,11 +556,11 @@ static LPITEM GetItemData(uint32 nOrdItem) { for (i = 1; i < ret->numframe; i++) { dim = (uint32)(ret->frameslocations[i].right-ret->frameslocations[i].left) * (uint32)(ret->frameslocations[i].bottom-ret->frameslocations[i].top); - ret->frames[i] = (char *)GlobalAlloc(GMEM_FIXED,dim); + ret->frames[i] = (char *)globalAlloc(GMEM_FIXED,dim); if (ret->frames[i] == NULL) return NULL; - CopyMemory(ret->frames[i], dat, dim); + copyMemory(ret->frames[i], dat, dim); dat += dim; } @@ -569,8 +569,8 @@ static LPITEM GetItemData(uint32 nOrdItem) { if (i != 0xABCD) return NULL; - GlobalUnlock(hDat); - GlobalFree(hDat); + globalUnlock(hDat); + globalFree(hDat); return ret; } @@ -594,7 +594,7 @@ void CustomThread(CORO_PARAM, const void *param) { CORO_INVOKE_4(GLOBALS.lplpFunctions[_ctx->p->nCf], _ctx->p->arg1, _ctx->p->arg2, _ctx->p->arg3, _ctx->p->arg4); - GlobalFree(_ctx->p); + globalFree(_ctx->p); CORO_END_CODE; } @@ -642,8 +642,8 @@ void ScriptThread(CORO_PARAM, const void *param) { for (_ctx->j = 0; _ctx->j < s->Moment[_ctx->i].nCmds; _ctx->j++) { _ctx->k = s->Moment[_ctx->i].CmdNum[_ctx->j]; - if (s->Command[_ctx->k].type == 1) { - _ctx->p = (LPCFCALL)GlobalAlloc(GMEM_FIXED, sizeof(CFCALL)); + if (s->_command[_ctx->k].type == 1) { + _ctx->p = (LPCFCALL)globalAlloc(GMEM_FIXED, sizeof(CFCALL)); if (_ctx->p == NULL) { GLOBALS.mpalError = 1; @@ -651,11 +651,11 @@ void ScriptThread(CORO_PARAM, const void *param) { return; } - _ctx->p->nCf=s->Command[_ctx->k].nCf; - _ctx->p->arg1=s->Command[_ctx->k].arg1; - _ctx->p->arg2=s->Command[_ctx->k].arg2; - _ctx->p->arg3=s->Command[_ctx->k].arg3; - _ctx->p->arg4=s->Command[_ctx->k].arg4; + _ctx->p->nCf=s->_command[_ctx->k].nCf; + _ctx->p->arg1=s->_command[_ctx->k].arg1; + _ctx->p->arg2=s->_command[_ctx->k].arg2; + _ctx->p->arg3=s->_command[_ctx->k].arg3; + _ctx->p->arg4=s->_command[_ctx->k].arg4; // !!! New process management if ((cfHandles[_ctx->numHandles++] = CoroScheduler.createProcess(CustomThread, &_ctx->p, sizeof(LPCFCALL))) == 0) { @@ -664,17 +664,17 @@ void ScriptThread(CORO_PARAM, const void *param) { CORO_KILL_SELF(); return; } - } else if (s->Command[_ctx->k].type == 2) { - LockVar(); + } else if (s->_command[_ctx->k].type == 2) { + lockVar(); varSetValue( - s->Command[_ctx->k].lpszVarName, - EvaluateExpression(s->Command[_ctx->k].expr) + s->_command[_ctx->k].lpszVarName, + evaluateExpression(s->_command[_ctx->k].expr) ); - UnlockVar(); + unlockVar(); } else { GLOBALS.mpalError = 1; - GlobalFree(s); + globalFree(s); CORO_KILL_SELF(); return; @@ -682,7 +682,7 @@ void ScriptThread(CORO_PARAM, const void *param) { } } - GlobalFree(s); + globalFree(s); CORO_KILL_SELF(); @@ -711,29 +711,29 @@ void ActionThread(CORO_PARAM, const void *param) { for (_ctx->j = 0; _ctx->j < item->Action[item->dwRes].nCmds; _ctx->j++) { _ctx->k = item->Action[item->dwRes].CmdNum[_ctx->j]; - if (item->Command[_ctx->k].type == 1) { + if (item->_command[_ctx->k].type == 1) { // Custom function debugC(DEBUG_DETAILED, kTonyDebugActions, "Action Process %d Call=%s params=%d,%d,%d,%d", - CoroScheduler.getCurrentPID(), GLOBALS.lplpFunctionStrings[item->Command[_ctx->k].nCf].c_str(), - item->Command[_ctx->k].arg1, item->Command[_ctx->k].arg2, - item->Command[_ctx->k].arg3, item->Command[_ctx->k].arg4 + CoroScheduler.getCurrentPID(), GLOBALS.lplpFunctionStrings[item->_command[_ctx->k].nCf].c_str(), + item->_command[_ctx->k].arg1, item->_command[_ctx->k].arg2, + item->_command[_ctx->k].arg3, item->_command[_ctx->k].arg4 ); - CORO_INVOKE_4(GLOBALS.lplpFunctions[item->Command[_ctx->k].nCf], - item->Command[_ctx->k].arg1, - item->Command[_ctx->k].arg2, - item->Command[_ctx->k].arg3, - item->Command[_ctx->k].arg4 + CORO_INVOKE_4(GLOBALS.lplpFunctions[item->_command[_ctx->k].nCf], + item->_command[_ctx->k].arg1, + item->_command[_ctx->k].arg2, + item->_command[_ctx->k].arg3, + item->_command[_ctx->k].arg4 ); - } else if (item->Command[_ctx->k].type == 2) { + } else if (item->_command[_ctx->k].type == 2) { // Variable assign debugC(DEBUG_DETAILED, kTonyDebugActions, "Action Process %d Variable=%s", - CoroScheduler.getCurrentPID(), item->Command[_ctx->k].lpszVarName); + CoroScheduler.getCurrentPID(), item->_command[_ctx->k].lpszVarName); - LockVar(); - varSetValue(item->Command[_ctx->k].lpszVarName, EvaluateExpression(item->Command[_ctx->k].expr)); - UnlockVar(); + lockVar(); + varSetValue(item->_command[_ctx->k].lpszVarName, evaluateExpression(item->_command[_ctx->k].expr)); + unlockVar(); } else { GLOBALS.mpalError = 1; @@ -741,7 +741,7 @@ void ActionThread(CORO_PARAM, const void *param) { } } - GlobalFree(item); + globalFree(item); debugC(DEBUG_DETAILED, kTonyDebugActions, "Action Process %d ended", CoroScheduler.getCurrentPID()); @@ -832,7 +832,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { ; /* We look for items without idle actions, and eliminate them from the list */ - LockItems(); + lockItems(); _ctx->nIdleActions = 0; _ctx->nRealItems = 0; for (_ctx->i = 0; _ctx->i < _ctx->numitems; _ctx->i++) { @@ -855,18 +855,18 @@ void LocationPollThread(CORO_PARAM, const void *param) { else _ctx->nRealItems++; } - UnlockItems(); + unlockItems(); /* If there is nothing left, we can exit */ if (_ctx->nRealItems == 0) { - GlobalFree(_ctx->il); + globalFree(_ctx->il); CORO_KILL_SELF(); return; } - _ctx->MyThreads = (MYTHREAD *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, _ctx->nRealItems * sizeof(MYTHREAD)); + _ctx->MyThreads = (MYTHREAD *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, _ctx->nRealItems * sizeof(MYTHREAD)); if (_ctx->MyThreads == NULL) { - GlobalFree(_ctx->il); + globalFree(_ctx->il); CORO_KILL_SELF(); return; } @@ -874,15 +874,15 @@ void LocationPollThread(CORO_PARAM, const void *param) { /* We have established that there is at least one item that contains idle actions. Now we created the mirrored copies of the idle actions. */ - _ctx->MyActions = (MYACTION *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, _ctx->nIdleActions * sizeof(MYACTION)); + _ctx->MyActions = (MYACTION *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, _ctx->nIdleActions * sizeof(MYACTION)); if (_ctx->MyActions == NULL) { - GlobalFree(_ctx->MyThreads); - GlobalFree(_ctx->il); + globalFree(_ctx->MyThreads); + globalFree(_ctx->il); CORO_KILL_SELF(); return; } - LockItems(); + lockItems(); _ctx->k = 0; for (_ctx->i = 0; _ctx->i < _ctx->numitems; _ctx->i++) { @@ -900,7 +900,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { _ctx->MyActions[_ctx->k].perc = _ctx->curItem->Action[_ctx->j].perc; _ctx->MyActions[_ctx->k].when = _ctx->curItem->Action[_ctx->j].when; _ctx->MyActions[_ctx->k].nCmds = _ctx->curItem->Action[_ctx->j].nCmds; - CopyMemory(_ctx->MyActions[_ctx->k].CmdNum, _ctx->curItem->Action[_ctx->j].CmdNum, + copyMemory(_ctx->MyActions[_ctx->k].CmdNum, _ctx->curItem->Action[_ctx->j].CmdNum, MAX_COMMANDS_PER_ACTION * sizeof(uint16)); _ctx->MyActions[_ctx->k].dwLastTime = _vm->getTime(); @@ -908,10 +908,10 @@ void LocationPollThread(CORO_PARAM, const void *param) { } } - UnlockItems(); + unlockItems(); /* We don't need the item list anymore */ - GlobalFree(_ctx->il); + globalFree(_ctx->il); /* Here's the main loop */ @@ -967,33 +967,33 @@ void LocationPollThread(CORO_PARAM, const void *param) { continue; /* Ok, we are the only ones :) */ - LockItems(); + lockItems(); _ctx->curItem=GLOBALS.lpmiItems+itemGetOrderFromNum(_ctx->MyActions[_ctx->k].nItem); /* Check if there is a WhenExecute expression */ _ctx->j=_ctx->MyActions[_ctx->k].nAction; if (_ctx->curItem->Action[_ctx->j].when != NULL) - if (!EvaluateExpression(_ctx->curItem->Action[_ctx->j].when)) { - UnlockItems(); + if (!evaluateExpression(_ctx->curItem->Action[_ctx->j].when)) { + unlockItems(); continue; } /* Ok, we can perform the action. For convenience, we do it in a new process */ - _ctx->newItem = (LPMPALITEM)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MPALITEM)); + _ctx->newItem = (LPMPALITEM)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MPALITEM)); if (_ctx->newItem == false) { - GlobalFree(_ctx->MyThreads); - GlobalFree(_ctx->MyActions); + globalFree(_ctx->MyThreads); + globalFree(_ctx->MyActions); CORO_KILL_SELF(); return; } - CopyMemory(_ctx->newItem,_ctx->curItem, sizeof(MPALITEM)); - UnlockItems(); + copyMemory(_ctx->newItem,_ctx->curItem, sizeof(MPALITEM)); + unlockItems(); /* We copy the action in #0 */ // _ctx->newItem->Action[0].nCmds = _ctx->curItem->Action[_ctx->j].nCmds; -// CopyMemory(_ctx->newItem->Action[0].CmdNum,_ctx->curItem->Action[_ctx->j].CmdNum,_ctx->newItem->Action[0].nCmds*sizeof(_ctx->newItem->Action[0].CmdNum[0])); +// copyMemory(_ctx->newItem->Action[0].CmdNum,_ctx->curItem->Action[_ctx->j].CmdNum,_ctx->newItem->Action[0].nCmds*sizeof(_ctx->newItem->Action[0].CmdNum[0])); _ctx->newItem->dwRes=_ctx->j; /* We will create an action, and will provide the necessary details */ @@ -1006,9 +1006,9 @@ void LocationPollThread(CORO_PARAM, const void *param) { // Create the process if ((_ctx->MyThreads[_ctx->i].hThread = CoroScheduler.createProcess(ActionThread, &_ctx->newItem, sizeof(LPMPALITEM))) == CORO_INVALID_PID_VALUE) { //if ((_ctx->MyThreads[_ctx->i].hThread = (void*)_beginthread(ActionThread, 10240,(void *)_ctx->newItem))= = (void*)-1) - GlobalFree(_ctx->newItem); - GlobalFree(_ctx->MyThreads); - GlobalFree(_ctx->MyActions); + globalFree(_ctx->newItem); + globalFree(_ctx->MyThreads); + globalFree(_ctx->MyActions); CORO_KILL_SELF(); return; @@ -1039,8 +1039,8 @@ void LocationPollThread(CORO_PARAM, const void *param) { CORO_INVOKE_4(GLOBALS.lplpFunctions[201], 0, 0, 0, 0); /* We're finished */ - GlobalFree(_ctx->MyThreads); - GlobalFree(_ctx->MyActions); + globalFree(_ctx->MyThreads); + globalFree(_ctx->MyActions); CORO_KILL_SELF(); @@ -1078,7 +1078,7 @@ void ShutUpDialogThread(CORO_PARAM, const void *param) { CORO_END_CODE; } -void DoChoice(CORO_PARAM, uint32 nChoice); +void doChoice(CORO_PARAM, uint32 nChoice); /** @@ -1097,41 +1097,41 @@ void GroupThread(CORO_PARAM, const void *param) { CORO_BEGIN_CODE(_ctx); // Lock the _ctx->dialog - LockDialogs(); + lockDialogs(); // Find the pointer to the current _ctx->dialog _ctx->dialog = GLOBALS.lpmdDialogs + GLOBALS.nExecutingDialog; // Search inside the group requesting the _ctx->dialog - for (_ctx->i = 0; _ctx->dialog->Group[_ctx->i].num != 0; _ctx->i++) { - if (_ctx->dialog->Group[_ctx->i].num == nGroup) { + for (_ctx->i = 0; _ctx->dialog->_group[_ctx->i].num != 0; _ctx->i++) { + if (_ctx->dialog->_group[_ctx->i].num == nGroup) { // Cycle through executing the commands of the group - for (_ctx->j = 0; _ctx->j < _ctx->dialog->Group[_ctx->i].nCmds; _ctx->j++) { - _ctx->k = _ctx->dialog->Group[_ctx->i].CmdNum[_ctx->j]; + for (_ctx->j = 0; _ctx->j < _ctx->dialog->_group[_ctx->i].nCmds; _ctx->j++) { + _ctx->k = _ctx->dialog->_group[_ctx->i].CmdNum[_ctx->j]; - _ctx->type = _ctx->dialog->Command[_ctx->k].type; + _ctx->type = _ctx->dialog->_command[_ctx->k].type; if (_ctx->type == 1) { // Call custom function - CORO_INVOKE_4(GLOBALS.lplpFunctions[_ctx->dialog->Command[_ctx->k].nCf], - _ctx->dialog->Command[_ctx->k].arg1, - _ctx->dialog->Command[_ctx->k].arg2, - _ctx->dialog->Command[_ctx->k].arg3, - _ctx->dialog->Command[_ctx->k].arg4 + CORO_INVOKE_4(GLOBALS.lplpFunctions[_ctx->dialog->_command[_ctx->k].nCf], + _ctx->dialog->_command[_ctx->k].arg1, + _ctx->dialog->_command[_ctx->k].arg2, + _ctx->dialog->_command[_ctx->k].arg3, + _ctx->dialog->_command[_ctx->k].arg4 ); } else if (_ctx->type == 2) { // Set a variable - LockVar(); - varSetValue(_ctx->dialog->Command[_ctx->k].lpszVarName, EvaluateExpression(_ctx->dialog->Command[_ctx->k].expr)); - UnlockVar(); + lockVar(); + varSetValue(_ctx->dialog->_command[_ctx->k].lpszVarName, evaluateExpression(_ctx->dialog->_command[_ctx->k].expr)); + unlockVar(); } else if (_ctx->type == 3) { // DoChoice: call the chosen function - CORO_INVOKE_1(DoChoice, (uint32)_ctx->dialog->Command[_ctx->k].nChoice); + CORO_INVOKE_1(doChoice, (uint32)_ctx->dialog->_command[_ctx->k].nChoice); } else { GLOBALS.mpalError = 1; - UnlockDialogs(); + unlockDialogs(); CORO_KILL_SELF(); return; @@ -1148,7 +1148,7 @@ void GroupThread(CORO_PARAM, const void *param) { /* If we are here, it means that we have not found the requested group */ GLOBALS.mpalError = 1; - UnlockDialogs(); + unlockDialogs(); CORO_KILL_SELF(); @@ -1161,7 +1161,7 @@ void GroupThread(CORO_PARAM, const void *param) { * * @param nChoice Number of choice to perform */ -void DoChoice(CORO_PARAM, uint32 nChoice) { +void doChoice(CORO_PARAM, uint32 nChoice) { CORO_BEGIN_CONTEXT; LPMPALDIALOG dialog; int i, j, k; @@ -1171,21 +1171,21 @@ void DoChoice(CORO_PARAM, uint32 nChoice) { CORO_BEGIN_CODE(_ctx); /* Lock the dialogs */ - LockDialogs(); + lockDialogs(); /* Get a pointer to the current dialog */ _ctx->dialog = GLOBALS.lpmdDialogs + GLOBALS.nExecutingDialog; /* Search the choice between those required in the dialog */ - for (_ctx->i = 0; _ctx->dialog->Choice[_ctx->i].nChoice != 0; _ctx->i++) - if (_ctx->dialog->Choice[_ctx->i].nChoice == nChoice) + for (_ctx->i = 0; _ctx->dialog->_choice[_ctx->i].nChoice != 0; _ctx->i++) + if (_ctx->dialog->_choice[_ctx->i].nChoice == nChoice) break; /* If nothing has been found, exit with an error */ - if (_ctx->dialog->Choice[_ctx->i].nChoice == 0) { + if (_ctx->dialog->_choice[_ctx->i].nChoice == 0) { /* If we're here, we did not find the required choice */ GLOBALS.mpalError = 1; - UnlockDialogs(); + unlockDialogs(); CORO_KILL_SELF(); return; @@ -1199,19 +1199,19 @@ void DoChoice(CORO_PARAM, uint32 nChoice) { _ctx->k = 0; /* Calculate the expression of each selection, to see if they're active or inactive */ - for (_ctx->j = 0; _ctx->dialog->Choice[_ctx->i].Select[_ctx->j].dwData != 0; _ctx->j++) - if (_ctx->dialog->Choice[_ctx->i].Select[_ctx->j].when == NULL) { - _ctx->dialog->Choice[_ctx->i].Select[_ctx->j].curActive = 1; + for (_ctx->j = 0; _ctx->dialog->_choice[_ctx->i]._select[_ctx->j].dwData != 0; _ctx->j++) + if (_ctx->dialog->_choice[_ctx->i]._select[_ctx->j].when == NULL) { + _ctx->dialog->_choice[_ctx->i]._select[_ctx->j].curActive = 1; _ctx->k++; - } else if (EvaluateExpression(_ctx->dialog->Choice[_ctx->i].Select[_ctx->j].when)) { - _ctx->dialog->Choice[_ctx->i].Select[_ctx->j].curActive = 1; + } else if (evaluateExpression(_ctx->dialog->_choice[_ctx->i]._select[_ctx->j].when)) { + _ctx->dialog->_choice[_ctx->i]._select[_ctx->j].curActive = 1; _ctx->k++; } else - _ctx->dialog->Choice[_ctx->i].Select[_ctx->j].curActive = 0; + _ctx->dialog->_choice[_ctx->i]._select[_ctx->j].curActive = 0; /* If there are no choices activated, then the dialog is finished. */ if (_ctx->k == 0) { - UnlockDialogs(); + unlockDialogs(); break; } @@ -1223,21 +1223,21 @@ void DoChoice(CORO_PARAM, uint32 nChoice) { /* Now that the choice has been made, we can run the groups associated with the choice tbontbtitq */ _ctx->j = GLOBALS.nSelectedChoice; - for (_ctx->k = 0; _ctx->dialog->Choice[_ctx->i].Select[_ctx->j].wPlayGroup[_ctx->k] != 0; _ctx->k++) { - _ctx->nGroup = _ctx->dialog->Choice[_ctx->i].Select[_ctx->j].wPlayGroup[_ctx->k]; + for (_ctx->k = 0; _ctx->dialog->_choice[_ctx->i]._select[_ctx->j].wPlayGroup[_ctx->k] != 0; _ctx->k++) { + _ctx->nGroup = _ctx->dialog->_choice[_ctx->i]._select[_ctx->j].wPlayGroup[_ctx->k]; CORO_INVOKE_1(GroupThread, &_ctx->nGroup); } /* Control attribute */ - if (_ctx->dialog->Choice[_ctx->i].Select[_ctx->j].attr & (1 << 0)) { + if (_ctx->dialog->_choice[_ctx->i]._select[_ctx->j].attr & (1 << 0)) { /* Bit 0 set: the end of the choice */ - UnlockDialogs(); + unlockDialogs(); break; } - if (_ctx->dialog->Choice[_ctx->i].Select[_ctx->j].attr & (1 << 1)) { + if (_ctx->dialog->_choice[_ctx->i]._select[_ctx->j].attr & (1 << 1)) { /* Bit 1 set: the end of the dialog */ - UnlockDialogs(); + unlockDialogs(); CORO_KILL_SELF(); return; @@ -1265,7 +1265,7 @@ void DoChoice(CORO_PARAM, uint32 nChoice) { * the itemGetOrderFromNum() function. The items list must first be locked * by calling LockItem(). */ -static uint32 DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { +static uint32 doAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { LPMPALITEM item = GLOBALS.lpmiItems; int i; LPMPALITEM newitem; @@ -1284,20 +1284,20 @@ static uint32 DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { continue; if (item->Action[i].when != NULL) { - if (!EvaluateExpression(item->Action[i].when)) + if (!evaluateExpression(item->Action[i].when)) continue; } // Now we find the right action to be performed // Duplicate the item and copy the current action in #i into #0 - newitem = (LPMPALITEM)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MPALITEM)); + newitem = (LPMPALITEM)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MPALITEM)); if (newitem == NULL) return CORO_INVALID_PID_VALUE; // In the new version number of the action in writing dwRes Common::copy((byte *)item, (byte *)item + sizeof(MPALITEM), (byte *)newitem); /* newitem->Action[0].nCmds=item->Action[i].nCmds; - CopyMemory(newitem->Action[0].CmdNum,item->Action[i].CmdNum,newitem->Action[0].nCmds*sizeof(newitem->Action[0].CmdNum[0])); + copyMemory(newitem->Action[0].CmdNum,item->Action[i].CmdNum,newitem->Action[0].nCmds*sizeof(newitem->Action[0].CmdNum[0])); */ newitem->dwRes = i; @@ -1331,7 +1331,7 @@ static uint32 DoAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { * so that must inform through an event and when 'necessary to you make a choice. * The data on the choices may be obtained through various queries. */ -static uint32 DoDialog(uint32 nDlgOrd, uint32 nGroup) { +static uint32 doDialog(uint32 nDlgOrd, uint32 nGroup) { uint32 h; // Store the running dialog in a global variable @@ -1368,15 +1368,15 @@ static uint32 DoDialog(uint32 nDlgOrd, uint32 nGroup) { * @param dwData Since combined with select selection * @returns True if everything is OK, false on failure */ -bool DoSelection(uint32 i, uint32 dwData) { +bool doSelection(uint32 i, uint32 dwData) { LPMPALDIALOG dialog = GLOBALS.lpmdDialogs+GLOBALS.nExecutingDialog; int j; - for (j = 0; dialog->Choice[i].Select[j].dwData != 0; j++) - if (dialog->Choice[i].Select[j].dwData == dwData && dialog->Choice[i].Select[j].curActive != 0) + for (j = 0; dialog->_choice[i]._select[j].dwData != 0; j++) + if (dialog->_choice[i]._select[j].dwData == dwData && dialog->_choice[i]._select[j].curActive != 0) break; - if (dialog->Choice[i].Select[j].dwData == 0) + if (dialog->_choice[i]._select[j].dwData == 0) return false; GLOBALS.nSelectedChoice = j; @@ -1433,7 +1433,7 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, if (hMpc.err()) return false; - byte *lpMpcImage = (byte *)GlobalAlloc(GMEM_FIXED, dwSizeDecomp + 16); + byte *lpMpcImage = (byte *)globalAlloc(GMEM_FIXED, dwSizeDecomp + 16); if (lpMpcImage == NULL) return false; @@ -1443,7 +1443,7 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, if (hMpc.err()) return false; - cmpbuf = (byte *)GlobalAlloc(GMEM_FIXED, dwSizeComp); + cmpbuf = (byte *)globalAlloc(GMEM_FIXED, dwSizeComp); if (cmpbuf == NULL) return false; @@ -1456,7 +1456,7 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, if (nBytesRead != dwSizeDecomp) return false; - GlobalFree(cmpbuf); + globalFree(cmpbuf); } else { /* If the file is not compressed, we directly read in the data */ nBytesRead = hMpc.read(lpMpcImage, dwSizeDecomp); @@ -1471,7 +1471,7 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, if (ParseMpc(lpMpcImage) == false) return false; - GlobalFree(lpMpcImage); + globalFree(lpMpcImage); /* Calculate memory usage */ /* @@ -1513,11 +1513,11 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, /* Move to the start of the resources header */ GLOBALS.hMpr.seek(-(12 + (int)dwSizeComp), SEEK_END); - GLOBALS.lpResources = (uint32 *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, GLOBALS.nResources * 8); + GLOBALS.lpResources = (uint32 *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, GLOBALS.nResources * 8); if (GLOBALS.lpResources == NULL) return false; - cmpbuf = (byte *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, dwSizeComp); + cmpbuf = (byte *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, dwSizeComp); if (cmpbuf == NULL) return false; @@ -1529,7 +1529,7 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, if (nBytesRead != (uint32)GLOBALS.nResources * 8) return false; - GlobalFree(cmpbuf); + globalFree(cmpbuf); /* Reset back to the start of the file, leaving it open */ GLOBALS.hMpr.seek(0, SEEK_SET); @@ -1580,9 +1580,9 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { /* * uint32 mpalQuery(MPQ_GLOBAL_VAR, char * lpszVarName); */ - LockVar(); + lockVar(); dwRet = (uint32)varGetValue(GETARG(char *)); - UnlockVar(); + unlockVar(); } else if (wQueryType == MPQ_MESSAGE) { /* @@ -1595,16 +1595,16 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { /* * uint32 mpalQuery(MPQ_ITEM_PATTERN, uint32 nItem); */ - LockVar(); + lockVar(); buf = Common::String::format("Pattern.%u", GETARG(uint32)); dwRet = (uint32)varGetValue(buf.c_str()); - UnlockVar(); + unlockVar(); } else if (wQueryType == MPQ_LOCATION_SIZE) { /* * uint32 mpalQuery(MPQ_LOCATION_SIZE, uint32 nLoc, uint32 dwCoord); */ - LockLocations(); + lockLocations(); x = locGetOrderFromNum(GETARG(uint32)); y = GETARG(uint32); if (x != -1) { @@ -1617,7 +1617,7 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { } else GLOBALS.mpalError = 1; - UnlockLocations(); + unlockLocations(); } else if (wQueryType == MPQ_LOCATION_IMAGE) { /* @@ -1647,7 +1647,7 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { /* * bool mpalQuery(MPQ_ITEM_IS_ACTIVE, uint32 nItem); */ - LockVar(); + lockVar(); x = GETARG(uint32); buf = Common::String::format("Status.%u", x); if (varGetValue(buf.c_str()) <= 0) @@ -1655,26 +1655,26 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { else dwRet = (uint32)true; - UnlockVar(); + unlockVar(); } else if (wQueryType == MPQ_ITEM_NAME) { /* * uint32 mpalQuery(MPQ_ITEM_NAME, uint32 nItem, char * lpszName); */ - LockVar(); + lockVar(); x = GETARG(uint32); n = GETARG(char *); buf = Common::String::format("Status.%u", x); if (varGetValue(buf.c_str()) <= 0) n[0]='\0'; else { - LockItems(); + lockItems(); y = itemGetOrderFromNum(x); - CopyMemory(n, (char *)(GLOBALS.lpmiItems + y)->lpszDescribe, MAX_DESCRIBE_SIZE); - UnlockItems(); + copyMemory(n, (char *)(GLOBALS.lpmiItems + y)->lpszDescribe, MAX_DESCRIBE_SIZE); + unlockItems(); } - UnlockVar(); + unlockVar(); } else if (wQueryType == MPQ_DIALOG_PERIOD) { /* @@ -1698,43 +1698,43 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { /* * bool mpalQuery(MPQ_DIALOG_SELECTION, uint32 nChoice, uint32 dwData); */ - LockDialogs(); + lockDialogs(); x = GETARG(uint32); y = GETARG(uint32); - dwRet = (uint32)DoSelection(x, y); + dwRet = (uint32)doSelection(x, y); - UnlockDialogs(); + unlockDialogs(); } else if (wQueryType == MPQ_DO_ACTION) { /* * int mpalQuery(MPQ_DO_ACTION, uint32 nAction, uint32 nItem, uint32 dwParam); */ - LockItems(); - LockVar(); + lockItems(); + lockVar(); x = GETARG(uint32); z = GETARG(uint32); y = itemGetOrderFromNum(z); if (y != -1) { - dwRet = DoAction(x, y, GETARG(uint32)); + dwRet = doAction(x, y, GETARG(uint32)); } else { dwRet = CORO_INVALID_PID_VALUE; GLOBALS.mpalError = 1; } - UnlockVar(); - UnlockItems(); + unlockVar(); + unlockItems(); } else if (wQueryType == MPQ_DO_DIALOG) { /* * int mpalQuery(MPQ_DO_DIALOG, uint32 nDialog, uint32 nGroup); */ if (!GLOBALS.bExecutingDialog) { - LockDialogs(); + lockDialogs(); x = dialogGetOrderFromNum(GETARG(uint32)); y = GETARG(uint32); - dwRet = DoDialog(x, y); - UnlockDialogs(); + dwRet = doDialog(x, y); + unlockDialogs(); } } else { /* @@ -1802,10 +1802,10 @@ HANDLE mpalQueryHANDLE(uint16 wQueryType, ...) { /* * HGLOBAL mpalQuery(MPQ_LOCATION_IMAGE, uint32 nLoc); */ - LockLocations(); + lockLocations(); x = locGetOrderFromNum(GETARG(uint32)); hRet = resLoad(GLOBALS.lpmlLocations[x].dwPicRes); - UnlockLocations(); + unlockLocations(); } else if (wQueryType == MPQ_RESOURCE) { /* @@ -1817,17 +1817,17 @@ HANDLE mpalQueryHANDLE(uint16 wQueryType, ...) { /* * uint32 mpalQuery(MPQ_ITEM_LIST, uint32 nLoc); */ - LockVar(); + lockVar(); hRet = GetItemList(GETARG(uint32)); - LockVar(); + lockVar(); } else if (wQueryType == MPQ_ITEM_DATA) { /* * LPITEM mpalQuery(MPQ_ITEM_DATA, uint32 nItem); */ - LockItems(); - hRet = GetItemData(itemGetOrderFromNum(GETARG(uint32))); - UnlockItems(); + lockItems(); + hRet = getItemData(itemGetOrderFromNum(GETARG(uint32))); + unlockItems(); } else if (wQueryType == MPQ_ITEM_IS_ACTIVE) { /* @@ -1839,29 +1839,29 @@ HANDLE mpalQueryHANDLE(uint16 wQueryType, ...) { /* * uint32 mpalQuery(MPQ_ITEM_NAME, uint32 nItem, char *lpszName); */ - LockVar(); + lockVar(); x = GETARG(uint32); n = GETARG(char *); buf = Common::String::format("Status.%u", x); if (varGetValue(buf.c_str()) <= 0) n[0] = '\0'; else { - LockItems(); + lockItems(); y = itemGetOrderFromNum(x); - CopyMemory(n, (char *)(GLOBALS.lpmiItems + y)->lpszDescribe, MAX_DESCRIBE_SIZE); - UnlockItems(); + copyMemory(n, (char *)(GLOBALS.lpmiItems + y)->lpszDescribe, MAX_DESCRIBE_SIZE); + unlockItems(); } - UnlockVar(); + unlockVar(); } else if (wQueryType == MPQ_DIALOG_PERIOD) { /* * char * mpalQuery(MPQ_DIALOG_PERIOD, uint32 nDialog, uint32 nPeriod); */ - LockDialogs(); + lockDialogs(); y = GETARG(uint32); - hRet = DuplicateDialogPeriod(y); - UnlockDialogs(); + hRet = duplicateDialogPeriod(y); + unlockDialogs(); } else if (wQueryType == MPQ_DIALOG_WAITFORCHOICE) { /* @@ -1873,9 +1873,9 @@ HANDLE mpalQueryHANDLE(uint16 wQueryType, ...) { /* * uint32 *mpalQuery(MPQ_DIALOG_SELECTLIST, uint32 nChoice); */ - LockDialogs(); - hRet = GetSelectList(GETARG(uint32)); - UnlockDialogs(); + lockDialogs(); + hRet = getSelectList(GETARG(uint32)); + unlockDialogs(); } else if (wQueryType == MPQ_DIALOG_SELECTION) { /* @@ -1969,12 +1969,12 @@ bool mpalExecuteScript(int nScript) { LockScripts(); n = scriptGetOrderFromNum(nScript); - s = (LPMPALSCRIPT)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MPALSCRIPT)); + s = (LPMPALSCRIPT)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MPALSCRIPT)); if (s == NULL) return false; - CopyMemory(s, GLOBALS.lpmsScripts + n, sizeof(MPALSCRIPT)); - UnlockScripts(); + copyMemory(s, GLOBALS.lpmsScripts + n, sizeof(MPALSCRIPT)); + unlockScripts(); // !!! New process management if (CoroScheduler.createProcess(ScriptThread, &s, sizeof(LPMPALSCRIPT)) == CORO_INVALID_PID_VALUE) @@ -2082,10 +2082,10 @@ int mpalGetSaveStateSize(void) { * @param buf Buffer where to store the state */ void mpalSaveState(byte *buf) { - LockVar(); + lockVar(); WRITE_LE_UINT32(buf, GLOBALS.nVars); - CopyMemory(buf + 4, (byte *)GLOBALS.lpmvVars, GLOBALS.nVars * sizeof(MPALVAR)); - UnlockVar(); + copyMemory(buf + 4, (byte *)GLOBALS.lpmvVars, GLOBALS.nVars * sizeof(MPALVAR)); + unlockVar(); } @@ -2097,14 +2097,14 @@ void mpalSaveState(byte *buf) { */ int mpalLoadState(byte *buf) { // We must destroy and recreate all the variables - GlobalFree(GLOBALS.hVars); + globalFree(GLOBALS.hVars); GLOBALS.nVars = READ_LE_UINT32(buf); - GLOBALS.hVars = GlobalAlloc(GMEM_ZEROINIT | GMEM_MOVEABLE, GLOBALS.nVars * sizeof(MPALVAR)); - LockVar(); - CopyMemory((byte *)GLOBALS.lpmvVars, buf + 4, GLOBALS.nVars * sizeof(MPALVAR)); - UnlockVar(); + GLOBALS.hVars = globalAlloc(GMEM_ZEROINIT | GMEM_MOVEABLE, GLOBALS.nVars * sizeof(MPALVAR)); + lockVar(); + copyMemory((byte *)GLOBALS.lpmvVars, buf + 4, GLOBALS.nVars * sizeof(MPALVAR)); + unlockVar(); return GLOBALS.nVars * sizeof(MPALVAR) + 4; } @@ -2170,7 +2170,7 @@ const MsgCommentsStruct MsgComments[] = { { 0, 0, NULL } }; -void OutputStartMsgComment(uint16 wNum, Common::OutSaveFile *f) { +void outputStartMsgComment(uint16 wNum, Common::OutSaveFile *f) { int i; for (i = 0; MsgComments[i].wStart != 0; i++) @@ -2225,7 +2225,7 @@ int OutputStartOther(uint16 wNum, Common::OutSaveFile *f) { } -void OutputEndOther(uint16 wNum, Common::OutSaveFile *f) { +void outputEndOther(uint16 wNum, Common::OutSaveFile *f) { int i; for (i = 0; MsgComments[i].wStart != 0; i++) @@ -2258,7 +2258,7 @@ void mpalDumpMessages(void) { f->writeString("\n\n
\n"); for (i = 0; i < GLOBALS.nMsgs; i++) { - lpMessage = (char*)GlobalLock(GLOBALS.lpmmMsgs[i].hText); + lpMessage = (char *)globalLock(GLOBALS.lpmmMsgs[i].hText); if (*lpMessage != '\0') { // bernie: debug /*if (GLOBALS.lpmmMsgs[i].wNum == 1950) { @@ -2266,9 +2266,9 @@ void mpalDumpMessages(void) { }*/ nPeriods = 1; - p=lpPeriods[0] = lpMessage; + p = lpPeriods[0] = lpMessage; - OutputStartMsgComment(GLOBALS.lpmmMsgs[i].wNum, f); + outputStartMsgComment(GLOBALS.lpmmMsgs[i].wNum, f); while (1) { // Find the end of the current period @@ -2313,7 +2313,7 @@ void mpalDumpMessages(void) { OutputEndMsgComment(GLOBALS.lpmmMsgs[i].wNum, f); - GlobalUnlock(GLOBALS.lpmmMsgs[i].hText); + globalUnlock(GLOBALS.lpmmMsgs[i].hText); } } @@ -2351,10 +2351,10 @@ void mpalDumpOthers(void) { f->writeString("\n\n"); for (i = 0; i < GLOBALS.nMsgs; i++) { - lpMessage = (char*)GlobalLock(GLOBALS.lpmmMsgs[i].hText); + lpMessage = (char *)globalLock(GLOBALS.lpmmMsgs[i].hText); if (*lpMessage != '\0') { nPeriods = 1; - p=lpPeriods[0] = lpMessage; + p = lpPeriods[0] = lpMessage; if (OutputStartOther(GLOBALS.lpmmMsgs[i].wNum, f)) { while (1) { @@ -2399,9 +2399,9 @@ void mpalDumpOthers(void) { } } - OutputEndOther(GLOBALS.lpmmMsgs[i].wNum, f); + outputEndOther(GLOBALS.lpmmMsgs[i].wNum, f); - GlobalUnlock(GLOBALS.lpmmMsgs[i].hText); + globalUnlock(GLOBALS.lpmmMsgs[i].hText); } } @@ -2735,7 +2735,7 @@ case num: \ return DLG##num[nPers]; -const char *GetPersonName(uint16 nDlg, int nPers) { +const char *getPersonName(uint16 nDlg, int nPers) { switch (nDlg) { HANDLE_DIALOG(10); HANDLE_DIALOG(51); @@ -2821,11 +2821,11 @@ void mpalDumpDialog(LPMPALDIALOG dlg) { f->writeString("\n\n"); - for (g = 0;dlg->Group[g].num != 0; g++) { + for (g = 0; dlg->_group[g].num != 0; g++) { bAtLeastOne = false; - for (c = 0; cGroup[g].nCmds; c++) { - curCmd = &dlg->Command[dlg->Group[g].CmdNum[c]]; + for (c = 0; c_group[g].nCmds; c++) { + curCmd = &dlg->_command[dlg->_group[g].CmdNum[c]]; if (curCmd->type == 1 && curCmd->nCf == 71) { bAtLeastOne = true; break; @@ -2838,23 +2838,23 @@ void mpalDumpDialog(LPMPALDIALOG dlg) { f->writeString(Common::String::format("

\n

Group %d

\n

\n", g)); f->writeString("

\n"); - for (c = 0;cGroup[g].nCmds; c++) { - curCmd = &dlg->Command[dlg->Group[g].CmdNum[c]]; + for (c = 0; c < dlg->_group[g].nCmds; c++) { + curCmd = &dlg->_command[dlg->_group[g].CmdNum[c]]; // If it's a custom function, call SendDialogMessage(nPers, nMsg) if (curCmd->type == 1 && curCmd->nCf == 71) { sprintf(fname, "%03d-%05d.WAV", dlg->nObj, curCmd->arg2); - for (j = 0; dlg->Periods[j] != NULL; j++) - if (dlg->PeriodNums[j] == curCmd->arg2) + for (j = 0; dlg->_periods[j] != NULL; j++) + if (dlg->_periodNums[j] == curCmd->arg2) break; - if (dlg->Periods[j] == NULL) + if (dlg->_periods[j] == NULL) warning("ERROR: Dialog %d, Period %d not found!", (int)dlg->nObj, (int)curCmd->arg2); else { - frase = (char *)GlobalLock(dlg->Periods[j]); + frase = (char *)globalLock(dlg->_periods[j]); strcpy(copia, frase); - GlobalUnlock(dlg->Periods[j]); + globalUnlock(dlg->_periods[j]); while ((p = strchr(copia,'^')) != NULL) *p = '\"'; @@ -2869,7 +2869,7 @@ void mpalDumpDialog(LPMPALDIALOG dlg) { f->writeString("\t\n"); f->writeString(Common::String::format("\t\t\n", fname)); f->writeString(Common::String::format("\t\t\n", - GetPersonName(dlg->nObj, curCmd->arg1))); + getPersonName(dlg->nObj, curCmd->arg1))); f->writeString(Common::String::format("\t\t\n",copia)); f->writeString("\t\n"); //fprintf(f, "(%s) <%s> %s\n", fname, GetPersonName(dlg->nObj, curCmd->arg1), copia); @@ -2890,12 +2890,12 @@ void mpalDumpDialog(LPMPALDIALOG dlg) { void mpalDumpDialogs(void) { int i; - LockDialogs(); + lockDialogs(); for (i = 0; i < GLOBALS.nDialogs; i++) mpalDumpDialog(&GLOBALS.lpmdDialogs[i]); - UnlockDialogs(); + unlockDialogs(); } } // end of namespace MPAL diff --git a/engines/tony/mpal/mpal.h b/engines/tony/mpal/mpal.h index 1bf19ef1bb..fb3d019051 100644 --- a/engines/tony/mpal/mpal.h +++ b/engines/tony/mpal/mpal.h @@ -519,13 +519,13 @@ int mpalGetSaveStateSize(void); /** * Locks the variables for access */ -void LockVar(void); +void lockVar(void); /** * Unlocks variables after use */ -void UnlockVar(void); +void unlockVar(void); } // end of namespace MPAL diff --git a/engines/tony/mpal/mpaldll.h b/engines/tony/mpal/mpaldll.h index 44d817d748..e331335315 100644 --- a/engines/tony/mpal/mpaldll.h +++ b/engines/tony/mpal/mpaldll.h @@ -144,7 +144,7 @@ struct command { struct MPALDIALOG { uint32 nObj; // Dialog number - struct command Command[MAX_COMMANDS_PER_DIALOG]; + struct command _command[MAX_COMMANDS_PER_DIALOG]; struct { uint16 num; @@ -152,7 +152,7 @@ struct MPALDIALOG { byte nCmds; uint16 CmdNum[MAX_COMMANDS_PER_GROUP]; - } Group[MAX_GROUPS_PER_DIALOG]; + } _group[MAX_GROUPS_PER_DIALOG]; struct { // The last choice has nChoice == 0 @@ -170,12 +170,12 @@ struct MPALDIALOG { // Modified at run-time: 0 if the select is currently disabled, // and 1 if currently active byte curActive; - } Select[MAX_SELECTS_PER_CHOICE]; + } _select[MAX_SELECTS_PER_CHOICE]; - } Choice[MAX_CHOICES_PER_DIALOG]; + } _choice[MAX_CHOICES_PER_DIALOG]; - uint16 PeriodNums[MAX_PERIODS_PER_DIALOG]; - HGLOBAL Periods[MAX_PERIODS_PER_DIALOG]; + uint16 _periodNums[MAX_PERIODS_PER_DIALOG]; + HGLOBAL _periods[MAX_PERIODS_PER_DIALOG]; } PACKED_STRUCT; typedef MPALDIALOG *LPMPALDIALOG; @@ -204,7 +204,7 @@ struct MPALITEM { byte nActions; // Number of managed actions uint32 dwRes; // Resource that contains frames and patterns - struct command Command[MAX_COMMANDS_PER_ITEM]; + struct command _command[MAX_COMMANDS_PER_ITEM]; // Pointer to array of structures containing various managed activities. In practice, of // every action we know what commands to run, including those defined in structures above @@ -223,7 +223,7 @@ struct MPALSCRIPT { uint32 nMoments; - struct command Command[MAX_COMMANDS_PER_SCRIPT]; + struct command _command[MAX_COMMANDS_PER_SCRIPT]; struct { int32 dwTime; diff --git a/engines/tony/mpal/mpalutils.cpp b/engines/tony/mpal/mpalutils.cpp index edc6e65ca1..bce623e43c 100644 --- a/engines/tony/mpal/mpalutils.cpp +++ b/engines/tony/mpal/mpalutils.cpp @@ -41,7 +41,7 @@ RMRes::RMRes(uint32 resID) { if (_h == NULL) _h = mpalQueryResource(resID); if (_h != NULL) - _buf = (byte *)GlobalLock(_h); + _buf = (byte *)globalLock(_h); } /** @@ -49,8 +49,8 @@ RMRes::RMRes(uint32 resID) { */ RMRes::~RMRes() { if (_h != NULL) { - GlobalUnlock(_h); - GlobalFree(_h); + globalUnlock(_h); + globalFree(_h); } } @@ -72,7 +72,7 @@ RMRes::operator const byte *() { * Returns the size of the resource */ unsigned int RMRes::size() { - return GlobalSize(_h); + return globalSize(_h); } /****************************************************************************\ diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index 2f55bfad42..93b5e90706 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -307,7 +307,7 @@ CODECADPCM::CODECADPCM(bool loop, byte *lpTempBuffer) : CODECRAW(loop) { if (lpTempBuffer != NULL) { lpTemp = lpTempBuffer; } else { - lpTemp = (byte *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, MAXDECODESIZE); + lpTemp = (byte *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, MAXDECODESIZE); if (lpTemp == NULL) { error("Insufficient memory!"); @@ -344,7 +344,7 @@ CODECADPCMSTEREO::~CODECADPCMSTEREO() { \****************************************************************************/ CODECADPCM::~CODECADPCM() { - GlobalFree(lpTemp); + globalFree(lpTemp); } @@ -1148,7 +1148,7 @@ bool FPSFX::LoadFile(byte *lpBuf, uint32 dwCodec) { } /* Decomprime i dati dello stream direttamente dentro il buffer lockato */ - CopyMemory(lpLock, lpBuf, dwSize); + copyMemory(lpLock, lpBuf, dwSize); /* Unlocka il buffer */ lpDSBuffer->Unlock(lpLock, dwSize, NULL, NULL); @@ -2111,7 +2111,7 @@ void FPSTREAM::PlayThread(FPSTREAM *This) { This->lpDSBuffer->Lock(This->dwBufferSize / 2, This->dwBufferSize / 2, (void **)&lpLockBuf, &dwResult, (void **)&lpLockBuf2, &dwResult2, 0); // sprintf(buf, "LockedBuf: dwResult=%x, dwBufferSize/2=%x, lpLockBuf2=%x, dwResult2=%x\n", dwResult, This->dwBufferSize/2, lpLockBuf2, dwResult2); // warning(buf); - CopyMemory(lpLockBuf, This->lpTempBuffer, This->dwBufferSize / 2); + copyMemory(lpLockBuf, This->lpTempBuffer, This->dwBufferSize / 2); This->lpDSBuffer->Unlock(lpLockBuf, This->dwBufferSize / 2, lpLockBuf2, 0); bPrecache = true; } @@ -2124,7 +2124,7 @@ void FPSTREAM::PlayThread(FPSTREAM *This) { // sprintf(buf, "Seconda met buffer: %x\n", This->lpDSBuffer); // warning(buf); This->lpDSBuffer->Lock(0, This->dwBufferSize / 2, (void **)&lpLockBuf, &dwResult, NULL, NULL, 0); - CopyMemory(lpLockBuf, This->lpTempBuffer, This->dwBufferSize / 2); + copyMemory(lpLockBuf, This->lpTempBuffer, This->dwBufferSize / 2); This->lpDSBuffer->Unlock(lpLockBuf, This->dwBufferSize / 2, NULL, NULL); bPrecache = true; } diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index fb53d68615..9f34276c41 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -180,28 +180,28 @@ void RMTony::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { // Call the Draw() of the parent class if Tony is visible if (_bShow && bDrawNow) { if (_bCorpoDavanti) { - prim->Dst().setEmpty(); - prim->Dst().offset(-44, -134); + prim->getDst().setEmpty(); + prim->getDst().offset(-44, -134); if (_bPastorella) - prim->Dst().offset(1, 4); + prim->getDst().offset(1, 4); CORO_INVOKE_2(RMCharacter::draw, bigBuf, prim); } if (_bIsTalking || _bIsStaticTalk) { // Offest direction from scrolling - prim->Dst().setEmpty(); - prim->Dst().offset(-_curScroll); - prim->Dst().offset(_pos); - prim->Dst().offset(-44, -134); - prim->Dst() += _nBodyOffset; + prim->getDst().setEmpty(); + prim->getDst().offset(-_curScroll); + prim->getDst().offset(_pos); + prim->getDst().offset(-44, -134); + prim->getDst() += _nBodyOffset; CORO_INVOKE_2(_body.draw, bigBuf, prim); } if (!_bCorpoDavanti) { - prim->Dst().setEmpty(); - prim->Dst().offset(-44, -134); + prim->getDst().setEmpty(); + prim->getDst().offset(-44, -134); if (_bPastorella) - prim->Dst().offset(0, 3); + prim->getDst().offset(0, 3); CORO_INVOKE_2(RMCharacter::draw, bigBuf, prim); } } diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index f11c9e6a2f..98b23001c0 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -1069,8 +1069,8 @@ HGLOBAL RMResUpdate::queryResource(uint32 dwRes) { } // Allocate space for the output resource - HGLOBAL destBuf = GlobalAllocate(info.size); - byte *lpDestBuf = (byte *)GlobalLock(destBuf); + HGLOBAL destBuf = globalAllocate(info.size); + byte *lpDestBuf = (byte *)globalLock(destBuf); uint32 dwSize; // Decompress the data @@ -1080,7 +1080,7 @@ HGLOBAL RMResUpdate::queryResource(uint32 dwRes) { delete [] cmpBuf; // Return the resource - GlobalUnlock(destBuf); + globalUnlock(destBuf); return lpDestBuf; } -- cgit v1.2.3 From 1866cbd0fb0d7df1c1a4059e98b5d0f6d851c2d4 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 8 Jun 2012 08:44:14 +0200 Subject: TONY: start renaming globals --- engines/tony/custom.cpp | 304 ++++++++++++++++++++-------------------- engines/tony/globals.cpp | 28 ++-- engines/tony/globals.h | 186 ++++++++++++------------ engines/tony/mpal/mpalutils.cpp | 4 +- engines/tony/mpal/mpalutils.h | 2 +- engines/tony/tony.cpp | 4 +- 6 files changed, 264 insertions(+), 264 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index a50807822c..810e6a9353 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -108,24 +108,24 @@ const char *staccFileNames[] = { void ReapplyChangedHotspot(void) { int i; - for (i = 0; i < GLOBALS.curChangedHotspot; i++) - GLOBALS.Loc->getItemFromCode(GLOBALS.ChangedHotspot[i].dwCode)->changeHotspot(RMPoint(GLOBALS.ChangedHotspot[i].nX, GLOBALS.ChangedHotspot[i].nY)); + for (i = 0; i < GLOBALS._curChangedHotspot; i++) + GLOBALS.Loc->getItemFromCode(GLOBALS._changedHotspot[i]._dwCode)->changeHotspot(RMPoint(GLOBALS._changedHotspot[i]._nX, GLOBALS._changedHotspot[i]._nY)); } void SaveChangedHotspot(Common::OutSaveFile *f) { - f->writeByte(GLOBALS.curChangedHotspot); - if (GLOBALS.curChangedHotspot > 0) { - for (int i = 0; i < GLOBALS.curChangedHotspot; ++i) - GLOBALS.ChangedHotspot[i].Save(f); + f->writeByte(GLOBALS._curChangedHotspot); + if (GLOBALS._curChangedHotspot > 0) { + for (int i = 0; i < GLOBALS._curChangedHotspot; ++i) + GLOBALS._changedHotspot[i].save(f); } } void LoadChangedHotspot(Common::InSaveFile *f) { - GLOBALS.curChangedHotspot = f->readByte(); + GLOBALS._curChangedHotspot = f->readByte(); - if (GLOBALS.curChangedHotspot > 0) { - for (int i = 0; i < GLOBALS.curChangedHotspot; ++i) - GLOBALS.ChangedHotspot[i].Load(f); + if (GLOBALS._curChangedHotspot > 0) { + for (int i = 0; i < GLOBALS._curChangedHotspot; ++i) + GLOBALS._changedHotspot[i].load(f); } } @@ -141,29 +141,29 @@ void LoadChangedHotspot(Common::InSaveFile *f) { */ void MCharResetCodes(void) { for (int i = 0; i < 10; i++) - GLOBALS.MCharacter[i].item = GLOBALS.Loc->getItemFromCode(GLOBALS.MCharacter[i].code); + GLOBALS._mCharacter[i]._item = GLOBALS.Loc->getItemFromCode(GLOBALS._mCharacter[i]._code); for (int i = 0; i < 10; i++) - GLOBALS.Character[i].item = GLOBALS.Loc->getItemFromCode(GLOBALS.Character[i].code); + GLOBALS._character[i]._item = GLOBALS.Loc->getItemFromCode(GLOBALS._character[i]._code); } void CharsSaveAll(Common::OutSaveFile *f) { for (int i = 0; i < 10; i++) { - f->writeByte(GLOBALS.IsMChar[i]); - if (GLOBALS.IsMChar[i]) { - GLOBALS.MCharacter[i].Save(f); + f->writeByte(GLOBALS._isMChar[i]); + if (GLOBALS._isMChar[i]) { + GLOBALS._mCharacter[i].save(f); } else { - GLOBALS.Character[i].Save(f); + GLOBALS._character[i].save(f); } } } void CharsLoadAll(Common::InSaveFile *f) { for (int i = 0; i < 10; i++) { - GLOBALS.IsMChar[i] = f->readByte(); - if (GLOBALS.IsMChar[i]) - GLOBALS.MCharacter[i].Load(f); + GLOBALS._isMChar[i] = f->readByte(); + if (GLOBALS._isMChar[i]) + GLOBALS._mCharacter[i].load(f); else - GLOBALS.Character[i].Load(f); + GLOBALS._character[i].load(f); } } @@ -202,7 +202,7 @@ DECLARE_CUSTOM_FUNCTION(MySleep)(CORO_PARAM, uint32 dwTime, uint32, uint32, uint } DECLARE_CUSTOM_FUNCTION(SetAlwaysDisplay)(CORO_PARAM, uint32 val, uint32, uint32, uint32) { - GLOBALS.bAlwaysDisplay = (val != 0); + GLOBALS._bAlwaysDisplay = (val != 0); } @@ -296,10 +296,10 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX CORO_INVOKE_1(GLOBALS.Tony->startTalk, GLOBALS.Tony->TALK_NORMAL); } - if (GLOBALS.curBackText) - CORO_INVOKE_0(GLOBALS.curBackText->hide); + if (GLOBALS._curBackText) + CORO_INVOKE_0(GLOBALS._curBackText->hide); - GLOBALS.bTonyIsSpeaking = true; + GLOBALS._bTonyIsSpeaking = true; for (_ctx->i = 0; _ctx->i < _ctx->msg.numPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { _ctx->text.setInput(GLOBALS.Input); @@ -320,7 +320,7 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX _ctx->text.setPosition(RMPoint(nX, nY) - GLOBALS.Loc->scrollPosition()); // Handling for always display - if (GLOBALS.bAlwaysDisplay) { + if (GLOBALS._bAlwaysDisplay) { _ctx->text.setAlwaysDisplay(); _ctx->text.forceTime(); } @@ -355,9 +355,9 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX } } - GLOBALS.bTonyIsSpeaking = false; - if (GLOBALS.curBackText) - GLOBALS.curBackText->show(); + GLOBALS._bTonyIsSpeaking = false; + if (GLOBALS._curBackText) + GLOBALS._curBackText->show(); CORO_INVOKE_0(GLOBALS.Tony->endTalk); @@ -378,7 +378,7 @@ DECLARE_CUSTOM_FUNCTION(CustLoadLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, ui GLOBALS.Freeze(); - GLOBALS.curChangedHotspot = 0; + GLOBALS._curChangedHotspot = 0; if (bUseStartPos != 0) GLOBALS.LoadLocation(nLoc, RMPoint(tX, tY), GLOBALS.StartLocPos[nLoc]); else @@ -538,7 +538,7 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint // On exit, unfreeze CORO_INVOKE_2(GLOBALS.UnloadLocation, true, NULL); - GLOBALS.curChangedHotspot = 0; + GLOBALS._curChangedHotspot = 0; if (bUseStartPos != 0) GLOBALS.LoadLocation(nLoc, RMPoint(tX, tY), GLOBALS.StartLocPos[nLoc]); else @@ -578,8 +578,8 @@ DECLARE_CUSTOM_FUNCTION(SetLocStartPosition)(CORO_PARAM, uint32 nLoc, uint32 lX, } DECLARE_CUSTOM_FUNCTION(SaveTonyPosition)(CORO_PARAM, uint32, uint32, uint32, uint32) { - GLOBALS.saveTonyPos = GLOBALS.Tony->position(); - GLOBALS.saveTonyLoc = GLOBALS.Loc->TEMPGetNumLoc(); + GLOBALS._saveTonyPos = GLOBALS.Tony->position(); + GLOBALS._saveTonyLoc = GLOBALS.Loc->TEMPGetNumLoc(); } DECLARE_CUSTOM_FUNCTION(RestoreTonyPosition)(CORO_PARAM, uint32, uint32, uint32, uint32) { @@ -588,7 +588,7 @@ DECLARE_CUSTOM_FUNCTION(RestoreTonyPosition)(CORO_PARAM, uint32, uint32, uint32, CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_4(ChangeLocation, GLOBALS.saveTonyLoc, GLOBALS.saveTonyPos.x, GLOBALS.saveTonyPos.y, 0); + CORO_INVOKE_4(ChangeLocation, GLOBALS._saveTonyLoc, GLOBALS._saveTonyPos.x, GLOBALS._saveTonyPos.y, 0); MCharResetCodes(); @@ -1340,18 +1340,18 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui DECLARE_CUSTOM_FUNCTION(ChangeHotspot)(CORO_PARAM, uint32 dwCode, uint32 nX, uint32 nY, uint32) { int i; - for (i = 0; i < GLOBALS.curChangedHotspot; i++) - if (GLOBALS.ChangedHotspot[i].dwCode == dwCode) { - GLOBALS.ChangedHotspot[i].nX = nX; - GLOBALS.ChangedHotspot[i].nY = nY; + for (i = 0; i < GLOBALS._curChangedHotspot; i++) + if (GLOBALS._changedHotspot[i]._dwCode == dwCode) { + GLOBALS._changedHotspot[i]._nX = nX; + GLOBALS._changedHotspot[i]._nY = nY; break; } - if (i == GLOBALS.curChangedHotspot) { - GLOBALS.ChangedHotspot[i].dwCode = dwCode; - GLOBALS.ChangedHotspot[i].nX = nX; - GLOBALS.ChangedHotspot[i].nY = nY; - GLOBALS.curChangedHotspot++; + if (i == GLOBALS._curChangedHotspot) { + GLOBALS._changedHotspot[i]._dwCode = dwCode; + GLOBALS._changedHotspot[i]._nX = nX; + GLOBALS._changedHotspot[i]._nY = nY; + GLOBALS._curChangedHotspot++; } GLOBALS.Loc->getItemFromCode(dwCode)->changeHotspot(RMPoint(nX, nY)); @@ -1412,36 +1412,36 @@ DECLARE_CUSTOM_FUNCTION(TremaSchermo)(CORO_PARAM, uint32 nScosse, uint32, uint32 DECLARE_CUSTOM_FUNCTION(CharSetCode)(CORO_PARAM, uint32 nChar, uint32 nCode, uint32, uint32) { assert(nChar < 16); - GLOBALS.Character[nChar].code = nCode; - GLOBALS.Character[nChar].item = GLOBALS.Loc->getItemFromCode(nCode); - GLOBALS.Character[nChar].r = 255; - GLOBALS.Character[nChar].g = 255; - GLOBALS.Character[nChar].b = 255; - GLOBALS.Character[nChar].talkpattern = 0; - GLOBALS.Character[nChar].starttalkpattern = 0; - GLOBALS.Character[nChar].endtalkpattern = 0; - GLOBALS.Character[nChar].standpattern = 0; + GLOBALS._character[nChar]._code = nCode; + GLOBALS._character[nChar]._item = GLOBALS.Loc->getItemFromCode(nCode); + GLOBALS._character[nChar]._r = 255; + GLOBALS._character[nChar]._g = 255; + GLOBALS._character[nChar]._b = 255; + GLOBALS._character[nChar]._talkPattern = 0; + GLOBALS._character[nChar]._startTalkPattern = 0; + GLOBALS._character[nChar]._endTalkPattern = 0; + GLOBALS._character[nChar]._standPattern = 0; - GLOBALS.IsMChar[nChar] = false; + GLOBALS._isMChar[nChar] = false; } DECLARE_CUSTOM_FUNCTION(CharSetColor)(CORO_PARAM, uint32 nChar, uint32 r, uint32 g, uint32 b) { assert(nChar < 16); - GLOBALS.Character[nChar].r = r; - GLOBALS.Character[nChar].g = g; - GLOBALS.Character[nChar].b = b; + GLOBALS._character[nChar]._r = r; + GLOBALS._character[nChar]._g = g; + GLOBALS._character[nChar]._b = b; } DECLARE_CUSTOM_FUNCTION(CharSetTalkPattern)(CORO_PARAM, uint32 nChar, uint32 tp, uint32 sp, uint32) { assert(nChar < 16); - GLOBALS.Character[nChar].talkpattern = tp; - GLOBALS.Character[nChar].standpattern = sp; + GLOBALS._character[nChar]._talkPattern = tp; + GLOBALS._character[nChar]._standPattern = sp; } DECLARE_CUSTOM_FUNCTION(CharSetStartEndTalkPattern)(CORO_PARAM, uint32 nChar, uint32 sp, uint32 ep, uint32) { assert(nChar < 16); - GLOBALS.Character[nChar].starttalkpattern = sp; - GLOBALS.Character[nChar].endtalkpattern = ep; + GLOBALS._character[nChar]._startTalkPattern = sp; + GLOBALS._character[nChar]._endTalkPattern = ep; } DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMessage, uint32 bIsBack, uint32) { @@ -1461,18 +1461,18 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess _ctx->curOffset = 0; assert(nChar < 16); - _ctx->pt = GLOBALS.Character[nChar].item->calculatePos() - RMPoint(-60, 20) - GLOBALS.Loc->scrollPosition(); + _ctx->pt = GLOBALS._character[nChar]._item->calculatePos() - RMPoint(-60, 20) - GLOBALS.Loc->scrollPosition(); - if (GLOBALS.Character[nChar].starttalkpattern != 0) { + if (GLOBALS._character[nChar]._startTalkPattern != 0) { GLOBALS.Freeze(); - GLOBALS.Character[nChar].item->setPattern(GLOBALS.Character[nChar].starttalkpattern); + GLOBALS._character[nChar]._item->setPattern(GLOBALS._character[nChar]._startTalkPattern); GLOBALS.Unfreeze(); - CORO_INVOKE_0(GLOBALS.Character[nChar].item->waitForEndPattern); + CORO_INVOKE_0(GLOBALS._character[nChar]._item->waitForEndPattern); } GLOBALS.Freeze(); - GLOBALS.Character[nChar].item->setPattern(GLOBALS.Character[nChar].talkpattern); + GLOBALS._character[nChar]._item->setPattern(GLOBALS._character[nChar]._talkPattern); GLOBALS.Unfreeze(); _ctx->curVoc = SearchVoiceHeader(0, dwMessage); @@ -1485,9 +1485,9 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess for (_ctx->i = 0; _ctx->i < _ctx->msg->numPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { if (bIsBack) { - GLOBALS.curBackText = _ctx->text = new RMTextDialogScrolling(GLOBALS.Loc); - if (GLOBALS.bTonyIsSpeaking) - CORO_INVOKE_0(GLOBALS.curBackText->hide); + GLOBALS._curBackText = _ctx->text = new RMTextDialogScrolling(GLOBALS.Loc); + if (GLOBALS._bTonyIsSpeaking) + CORO_INVOKE_0(GLOBALS._curBackText->hide); } else _ctx->text = new RMTextDialog; @@ -1500,7 +1500,7 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess _ctx->text->setAlignType(RMText::HCENTER, RMText::VBOTTOM); // Colour - _ctx->text->setColor(GLOBALS.Character[nChar].r, GLOBALS.Character[nChar].g, GLOBALS.Character[nChar].b); + _ctx->text->setColor(GLOBALS._character[nChar]._r, GLOBALS._character[nChar]._g, GLOBALS._character[nChar]._b); // Write the text _ctx->text->writeText((*_ctx->msg)[_ctx->i], 0); @@ -1509,7 +1509,7 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess _ctx->text->setPosition(_ctx->pt); // Set the always display - if (GLOBALS.bAlwaysDisplay) { + if (GLOBALS._bAlwaysDisplay) { _ctx->text->setAlwaysDisplay(); _ctx->text->forceTime(); } @@ -1539,19 +1539,19 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess } - GLOBALS.curBackText = NULL; + GLOBALS._curBackText = NULL; delete _ctx->text; } - if (GLOBALS.Character[nChar].endtalkpattern != 0) { + if (GLOBALS._character[nChar]._endTalkPattern != 0) { GLOBALS.Freeze(); - GLOBALS.Character[nChar].item->setPattern(GLOBALS.Character[nChar].endtalkpattern); + GLOBALS._character[nChar]._item->setPattern(GLOBALS._character[nChar]._endTalkPattern); GLOBALS.Unfreeze(); - CORO_INVOKE_0(GLOBALS.Character[nChar].item->waitForEndPattern); + CORO_INVOKE_0(GLOBALS._character[nChar]._item->waitForEndPattern); } GLOBALS.Freeze(); - GLOBALS.Character[nChar].item->setPattern(GLOBALS.Character[nChar].standpattern); + GLOBALS._character[nChar]._item->setPattern(GLOBALS._character[nChar]._standPattern); GLOBALS.Unfreeze(); delete _ctx->msg; @@ -1577,43 +1577,43 @@ DECLARE_CUSTOM_FUNCTION(ChangeInventoryStatus)(CORO_PARAM, uint32 dwCode, uint32 DECLARE_CUSTOM_FUNCTION(MCharSetCode)(CORO_PARAM, uint32 nChar, uint32 nCode, uint32, uint32) { assert(nChar < 10); - GLOBALS.MCharacter[nChar].code = nCode; + GLOBALS._mCharacter[nChar]._code = nCode; if (nCode == 0) - GLOBALS.MCharacter[nChar].item = NULL; + GLOBALS._mCharacter[nChar]._item = NULL; else - GLOBALS.MCharacter[nChar].item = GLOBALS.Loc->getItemFromCode(nCode); - GLOBALS.MCharacter[nChar].r = 255; - GLOBALS.MCharacter[nChar].g = 255; - GLOBALS.MCharacter[nChar].b = 255; - GLOBALS.MCharacter[nChar].x = -1; - GLOBALS.MCharacter[nChar].y = -1; - GLOBALS.MCharacter[nChar].bAlwaysBack = 0; + GLOBALS._mCharacter[nChar]._item = GLOBALS.Loc->getItemFromCode(nCode); + GLOBALS._mCharacter[nChar]._r = 255; + GLOBALS._mCharacter[nChar]._g = 255; + GLOBALS._mCharacter[nChar]._b = 255; + GLOBALS._mCharacter[nChar]._x = -1; + GLOBALS._mCharacter[nChar]._y = -1; + GLOBALS._mCharacter[nChar]._bAlwaysBack = 0; for (int i = 0; i < 10; i++) - GLOBALS.MCharacter[nChar].numtalks[i] = 1; + GLOBALS._mCharacter[nChar]._numTalks[i] = 1; - GLOBALS.MCharacter[nChar].curgroup = 0; + GLOBALS._mCharacter[nChar]._curGroup = 0; - GLOBALS.IsMChar[nChar] = true; + GLOBALS._isMChar[nChar] = true; } DECLARE_CUSTOM_FUNCTION(MCharResetCode)(CORO_PARAM, uint32 nChar, uint32, uint32, uint32) { - GLOBALS.MCharacter[nChar].item = GLOBALS.Loc->getItemFromCode(GLOBALS.MCharacter[nChar].code); + GLOBALS._mCharacter[nChar]._item = GLOBALS.Loc->getItemFromCode(GLOBALS._mCharacter[nChar]._code); } DECLARE_CUSTOM_FUNCTION(MCharSetPosition)(CORO_PARAM, uint32 nChar, uint32 nX, uint32 nY, uint32) { assert(nChar < 10); - GLOBALS.MCharacter[nChar].x = nX; - GLOBALS.MCharacter[nChar].y = nY; + GLOBALS._mCharacter[nChar]._x = nX; + GLOBALS._mCharacter[nChar]._y = nY; } DECLARE_CUSTOM_FUNCTION(MCharSetColor)(CORO_PARAM, uint32 nChar, uint32 r, uint32 g, uint32 b) { assert(nChar < 10); - GLOBALS.MCharacter[nChar].r = r; - GLOBALS.MCharacter[nChar].g = g; - GLOBALS.MCharacter[nChar].b = b; + GLOBALS._mCharacter[nChar]._r = r; + GLOBALS._mCharacter[nChar]._g = g; + GLOBALS._mCharacter[nChar]._b = b; } @@ -1621,7 +1621,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSetNumTalksInGroup)(CORO_PARAM, uint32 nChar, uint3 assert(nChar < 10); assert(nGroup < 10); - GLOBALS.MCharacter[nChar].numtalks[nGroup] = nTalks; + GLOBALS._mCharacter[nChar]._numTalks[nGroup] = nTalks; } @@ -1629,20 +1629,20 @@ DECLARE_CUSTOM_FUNCTION(MCharSetCurrentGroup)(CORO_PARAM, uint32 nChar, uint32 n assert(nChar < 10); assert(nGroup < 10); - GLOBALS.MCharacter[nChar].curgroup = nGroup; + GLOBALS._mCharacter[nChar]._curGroup = nGroup; } DECLARE_CUSTOM_FUNCTION(MCharSetNumTexts)(CORO_PARAM, uint32 nChar, uint32 nTexts, uint32, uint32) { assert(nChar < 10); - GLOBALS.MCharacter[nChar].numtexts = nTexts - 1; - GLOBALS.MCharacter[nChar].bInTexts = false; + GLOBALS._mCharacter[nChar]._numTexts = nTexts - 1; + GLOBALS._mCharacter[nChar]._bInTexts = false; } DECLARE_CUSTOM_FUNCTION(MCharSetAlwaysBack)(CORO_PARAM, uint32 nChar, uint32 bAlwaysBack, uint32, uint32) { assert(nChar < 10); - GLOBALS.MCharacter[nChar].bAlwaysBack = bAlwaysBack; + GLOBALS._mCharacter[nChar]._bAlwaysBack = bAlwaysBack; } @@ -1666,21 +1666,21 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes assert(nChar < 10); - bIsBack |= GLOBALS.MCharacter[nChar].bAlwaysBack ? 1 : 0; + bIsBack |= GLOBALS._mCharacter[nChar]._bAlwaysBack ? 1 : 0; // Calculates the position of the text according to the current frame - if (GLOBALS.MCharacter[nChar].x == -1) - _ctx->pt = GLOBALS.MCharacter[nChar].item->calculatePos() - RMPoint(-60, 20) - GLOBALS.Loc->scrollPosition(); + if (GLOBALS._mCharacter[nChar]._x == -1) + _ctx->pt = GLOBALS._mCharacter[nChar]._item->calculatePos() - RMPoint(-60, 20) - GLOBALS.Loc->scrollPosition(); else - _ctx->pt = RMPoint(GLOBALS.MCharacter[nChar].x, GLOBALS.MCharacter[nChar].y); + _ctx->pt = RMPoint(GLOBALS._mCharacter[nChar]._x, GLOBALS._mCharacter[nChar]._y); // Parameter for special actions: random between the spoken - _ctx->parm = (GLOBALS.MCharacter[nChar].curgroup * 10) + _vm->_randomSource.getRandomNumber( - GLOBALS.MCharacter[nChar].numtalks[GLOBALS.MCharacter[nChar].curgroup] - 1) + 1; + _ctx->parm = (GLOBALS._mCharacter[nChar]._curGroup * 10) + _vm->_randomSource.getRandomNumber( + GLOBALS._mCharacter[nChar]._numTalks[GLOBALS._mCharacter[nChar]._curGroup] - 1) + 1; // Try to run the custom function to initialise the speech - if (GLOBALS.MCharacter[nChar].item) { - _ctx->h = mpalQueryDoAction(30, GLOBALS.MCharacter[nChar].item->mpalCode(), _ctx->parm); + if (GLOBALS._mCharacter[nChar]._item) { + _ctx->h = mpalQueryDoAction(30, GLOBALS._mCharacter[nChar]._item->mpalCode(), _ctx->parm); if (_ctx->h != CORO_INVALID_PID_VALUE) { CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->h, CORO_INFINITE); } @@ -1698,9 +1698,9 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes for (_ctx->i = 0; _ctx->i < _ctx->msg->numPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { // Create a different object depending on whether it's background or not if (bIsBack) { - GLOBALS.curBackText = _ctx->text = new RMTextDialogScrolling(GLOBALS.Loc); - if (GLOBALS.bTonyIsSpeaking) - CORO_INVOKE_0(GLOBALS.curBackText->hide); + GLOBALS._curBackText = _ctx->text = new RMTextDialogScrolling(GLOBALS.Loc); + if (GLOBALS._bTonyIsSpeaking) + CORO_INVOKE_0(GLOBALS._curBackText->hide); } else _ctx->text = new RMTextDialog; @@ -1713,7 +1713,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes _ctx->text->setAlignType(RMText::HCENTER, RMText::VBOTTOM); // Colour - _ctx->text->setColor(GLOBALS.MCharacter[nChar].r, GLOBALS.MCharacter[nChar].g, GLOBALS.MCharacter[nChar].b); + _ctx->text->setColor(GLOBALS._mCharacter[nChar]._r, GLOBALS._mCharacter[nChar]._g, GLOBALS._mCharacter[nChar]._b); // Write the text _ctx->text->writeText((*_ctx->msg)[_ctx->i], nFont); @@ -1722,7 +1722,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes _ctx->text->setPosition(_ctx->pt); // Set the always display - if (GLOBALS.bAlwaysDisplay) { + if (GLOBALS._bAlwaysDisplay) { _ctx->text->setAlwaysDisplay(); _ctx->text->forceTime(); } @@ -1751,15 +1751,15 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes _ctx->voice = NULL; } - GLOBALS.curBackText = NULL; + GLOBALS._curBackText = NULL; delete _ctx->text; delete _ctx->msg; } // Try to run the custom function to close the speech - if (GLOBALS.MCharacter[nChar].item) { - _ctx->h = mpalQueryDoAction(31, GLOBALS.MCharacter[nChar].item->mpalCode(), _ctx->parm); + if (GLOBALS._mCharacter[nChar]._item) { + _ctx->h = mpalQueryDoAction(31, GLOBALS._mCharacter[nChar]._item->mpalCode(), _ctx->parm); if (_ctx->h != CORO_INVALID_PID_VALUE) CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->h, CORO_INFINITE); } @@ -1790,7 +1790,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg _ctx->bIsBack = false; // The SendDialogMessage can go in the background if it is a character - if (nPers != 0 && GLOBALS.IsMChar[nPers] && GLOBALS.MCharacter[nPers].bAlwaysBack) + if (nPers != 0 && GLOBALS._isMChar[nPers] && GLOBALS._mCharacter[nPers]._bAlwaysBack) _ctx->bIsBack = true; _ctx->curVoc = SearchVoiceHeader(curDialog, nMsg); @@ -1830,67 +1830,67 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg if (!GLOBALS.bStaticTalk) GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; } - } else if (!GLOBALS.IsMChar[nPers]) { + } else if (!GLOBALS._isMChar[nPers]) { _ctx->text = new RMTextDialog; - _ctx->pt = GLOBALS.Character[nPers].item->calculatePos() - RMPoint(-60, 20) - GLOBALS.Loc->scrollPosition(); + _ctx->pt = GLOBALS._character[nPers]._item->calculatePos() - RMPoint(-60, 20) - GLOBALS.Loc->scrollPosition(); - if (GLOBALS.Character[nPers].starttalkpattern != 0) { + if (GLOBALS._character[nPers]._startTalkPattern != 0) { GLOBALS.Freeze(); - GLOBALS.Character[nPers].item->setPattern(GLOBALS.Character[nPers].starttalkpattern); + GLOBALS._character[nPers]._item->setPattern(GLOBALS._character[nPers]._startTalkPattern); GLOBALS.Unfreeze(); - CORO_INVOKE_0(GLOBALS.Character[nPers].item->waitForEndPattern); + CORO_INVOKE_0(GLOBALS._character[nPers]._item->waitForEndPattern); } - GLOBALS.Character[nPers].item->setPattern(GLOBALS.Character[nPers].talkpattern); + GLOBALS._character[nPers]._item->setPattern(GLOBALS._character[nPers]._talkPattern); - _ctx->text->setColor(GLOBALS.Character[nPers].r, GLOBALS.Character[nPers].g, GLOBALS.Character[nPers].b); + _ctx->text->setColor(GLOBALS._character[nPers]._r, GLOBALS._character[nPers]._g, GLOBALS._character[nPers]._b); _ctx->text->writeText(_ctx->string, 0); _ctx->text->setPosition(_ctx->pt); } else { - if (GLOBALS.MCharacter[nPers].x == -1) - _ctx->pt = GLOBALS.MCharacter[nPers].item->calculatePos() - RMPoint(-60, 20) - GLOBALS.Loc->scrollPosition(); + if (GLOBALS._mCharacter[nPers]._x == -1) + _ctx->pt = GLOBALS._mCharacter[nPers]._item->calculatePos() - RMPoint(-60, 20) - GLOBALS.Loc->scrollPosition(); else - _ctx->pt = RMPoint(GLOBALS.MCharacter[nPers].x, GLOBALS.MCharacter[nPers].y); + _ctx->pt = RMPoint(GLOBALS._mCharacter[nPers]._x, GLOBALS._mCharacter[nPers]._y); // Parameter for special actions. Random between the spoken. - _ctx->parm = (GLOBALS.MCharacter[nPers].curgroup * 10) + _vm->_randomSource.getRandomNumber( - GLOBALS.MCharacter[nPers].numtalks[GLOBALS.MCharacter[nPers].curgroup] - 1) + 1; + _ctx->parm = (GLOBALS._mCharacter[nPers]._curGroup * 10) + _vm->_randomSource.getRandomNumber( + GLOBALS._mCharacter[nPers]._numTalks[GLOBALS._mCharacter[nPers]._curGroup] - 1) + 1; - if (GLOBALS.MCharacter[nPers].numtexts != 0 && GLOBALS.MCharacter[nPers].bInTexts) { - GLOBALS.MCharacter[nPers].numtexts--; + if (GLOBALS._mCharacter[nPers]._numTexts != 0 && GLOBALS._mCharacter[nPers]._bInTexts) { + GLOBALS._mCharacter[nPers]._numTexts--; } else { // Try to run the custom function to initialise the speech - _ctx->h = mpalQueryDoAction(30, GLOBALS.MCharacter[nPers].item->mpalCode(), _ctx->parm); + _ctx->h = mpalQueryDoAction(30, GLOBALS._mCharacter[nPers]._item->mpalCode(), _ctx->parm); if (_ctx->h != CORO_INVALID_PID_VALUE) CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->h, CORO_INFINITE); - GLOBALS.MCharacter[nPers].curTalk = _ctx->parm; + GLOBALS._mCharacter[nPers]._curTalk = _ctx->parm; - if (GLOBALS.MCharacter[nPers].numtexts != 0) { - GLOBALS.MCharacter[nPers].bInTexts = true; - GLOBALS.MCharacter[nPers].numtexts--; + if (GLOBALS._mCharacter[nPers]._numTexts != 0) { + GLOBALS._mCharacter[nPers]._bInTexts = true; + GLOBALS._mCharacter[nPers]._numTexts--; } } - if (GLOBALS.MCharacter[nPers].bAlwaysBack) { - _ctx->text = GLOBALS.curBackText = new RMTextDialogScrolling(GLOBALS.Loc); - if (GLOBALS.bTonyIsSpeaking) - CORO_INVOKE_0(GLOBALS.curBackText->hide); + if (GLOBALS._mCharacter[nPers]._bAlwaysBack) { + _ctx->text = GLOBALS._curBackText = new RMTextDialogScrolling(GLOBALS.Loc); + if (GLOBALS._bTonyIsSpeaking) + CORO_INVOKE_0(GLOBALS._curBackText->hide); _ctx->bIsBack = true; } else _ctx->text = new RMTextDialog; - _ctx->text->setSkipStatus(!GLOBALS.MCharacter[nPers].bAlwaysBack); - _ctx->text->setColor(GLOBALS.MCharacter[nPers].r, GLOBALS.MCharacter[nPers].g, GLOBALS.MCharacter[nPers].b); + _ctx->text->setSkipStatus(!GLOBALS._mCharacter[nPers]._bAlwaysBack); + _ctx->text->setColor(GLOBALS._mCharacter[nPers]._r, GLOBALS._mCharacter[nPers]._g, GLOBALS._mCharacter[nPers]._b); _ctx->text->writeText(_ctx->string, 0); _ctx->text->setPosition(_ctx->pt); } if (!GLOBALS.bSkipIdle) { _ctx->text->setInput(GLOBALS.Input); - if (GLOBALS.bAlwaysDisplay) { + if (GLOBALS._bAlwaysDisplay) { _ctx->text->setAlwaysDisplay(); _ctx->text->forceTime(); } @@ -1914,29 +1914,29 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg } if (nPers != 0) { - if (!GLOBALS.IsMChar[nPers]) { - if (GLOBALS.Character[nPers].endtalkpattern != 0) { + if (!GLOBALS._isMChar[nPers]) { + if (GLOBALS._character[nPers]._endTalkPattern != 0) { GLOBALS.Freeze(); - GLOBALS.Character[nPers].item->setPattern(GLOBALS.Character[nPers].endtalkpattern); + GLOBALS._character[nPers]._item->setPattern(GLOBALS._character[nPers]._endTalkPattern); GLOBALS.Unfreeze(); - CORO_INVOKE_0(GLOBALS.Character[nPers].item->waitForEndPattern); + CORO_INVOKE_0(GLOBALS._character[nPers]._item->waitForEndPattern); } - GLOBALS.Character[nPers].item->setPattern(GLOBALS.Character[nPers].standpattern); + GLOBALS._character[nPers]._item->setPattern(GLOBALS._character[nPers]._standPattern); delete _ctx->text; } else { - if ((GLOBALS.MCharacter[nPers].bInTexts && GLOBALS.MCharacter[nPers].numtexts == 0) || !GLOBALS.MCharacter[nPers].bInTexts) { + if ((GLOBALS._mCharacter[nPers]._bInTexts && GLOBALS._mCharacter[nPers]._numTexts == 0) || !GLOBALS._mCharacter[nPers]._bInTexts) { // Try to run the custom function to close the speech - GLOBALS.MCharacter[nPers].curTalk = (GLOBALS.MCharacter[nPers].curTalk % 10) + GLOBALS.MCharacter[nPers].curgroup * 10; - _ctx->h = mpalQueryDoAction(31, GLOBALS.MCharacter[nPers].item->mpalCode(), GLOBALS.MCharacter[nPers].curTalk); + GLOBALS._mCharacter[nPers]._curTalk = (GLOBALS._mCharacter[nPers]._curTalk % 10) + GLOBALS._mCharacter[nPers]._curGroup * 10; + _ctx->h = mpalQueryDoAction(31, GLOBALS._mCharacter[nPers]._item->mpalCode(), GLOBALS._mCharacter[nPers]._curTalk); if (_ctx->h != CORO_INVALID_PID_VALUE) CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->h, CORO_INFINITE); - GLOBALS.MCharacter[nPers].bInTexts = false; - GLOBALS.MCharacter[nPers].numtexts = 0; + GLOBALS._mCharacter[nPers]._bInTexts = false; + GLOBALS._mCharacter[nPers]._numTexts = 0; } - GLOBALS.curBackText = NULL; + GLOBALS._curBackText = NULL; delete _ctx->text; } } else { @@ -2545,7 +2545,7 @@ void setupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation GLOBALS.EnableGUI = mainEnableGUI; GLOBALS.SetPalesati = mainSetPalesati; - GLOBALS.bAlwaysDisplay = false; + GLOBALS._bAlwaysDisplay = false; int i; for (i = 0; i < 10; i++) diff --git a/engines/tony/globals.cpp b/engines/tony/globals.cpp index 742d4376d5..37a5a20454 100644 --- a/engines/tony/globals.cpp +++ b/engines/tony/globals.cpp @@ -26,15 +26,15 @@ namespace Tony { Globals::Globals() { - Common::fill(nextMusic, nextMusic + MAX_PATH, 0); - nextLoop = false; - nextChannel = 0; - nextSync = 0; - curChannel = 0; - flipflop = 0; - curBackText = NULL; - bTonyIsSpeaking = false; - curChangedHotspot = 0; + Common::fill(_nextMusic, _nextMusic + MAX_PATH, 0); + _nextLoop = false; + _nextChannel = 0; + _nextSync = 0; + _curChannel = 0; + _flipflop = 0; + _curBackText = NULL; + _bTonyIsSpeaking = false; + _curChangedHotspot = 0; Tony = NULL; Pointer = NULL; Boxes = NULL; @@ -72,7 +72,7 @@ Globals::Globals() { bCfgDubbing = false; bCfgMusic = false; bCfgSFX = false; - bAlwaysDisplay = false; + _bAlwaysDisplay = false; nCfgTonySpeed = 0; nCfgTextSpeed = 0; nCfgDubbingVolume = 0; @@ -132,14 +132,14 @@ Globals::Globals() { nExecutingChoice = 0; nSelectedChoice = 0; nTonyNextTalkType = RMTony::TALK_NORMAL; - saveTonyLoc = 0; + _saveTonyLoc = 0; for (int i = 0; i < 16; ++i) - Common::fill((byte *)&Character[i], (byte *)&Character[i] + sizeof(CharacterStruct), 0); + Common::fill((byte *)&_character[i], (byte *)&_character[i] + sizeof(CharacterStruct), 0); for (int i = 0; i < 10; ++i) - Common::fill((byte *)&MCharacter[i], (byte *)&MCharacter[i] + sizeof(MCharacterStruct), 0); + Common::fill((byte *)&_mCharacter[i], (byte *)&_mCharacter[i] + sizeof(MCharacterStruct), 0); for (int i = 0; i < 256; ++i) - Common::fill((byte *)&ChangedHotspot[i], (byte *)&ChangedHotspot[i] + sizeof(ChangedHotspotStruct), 0); + Common::fill((byte *)&_changedHotspot[i], (byte *)&_changedHotspot[i] + sizeof(ChangedHotspotStruct), 0); } } // End of namespace Tony diff --git a/engines/tony/globals.h b/engines/tony/globals.h index 76a54e07c8..84c5d7398c 100644 --- a/engines/tony/globals.h +++ b/engines/tony/globals.h @@ -48,101 +48,101 @@ namespace Tony { struct CharacterStruct { - uint32 code; - RMItem *item; - byte r, g, b; - int talkpattern; - int standpattern; - int starttalkpattern, endtalkpattern; - int numtexts; - - void Save(Common::OutSaveFile *f) { - f->writeUint32LE(code); + uint32 _code; + RMItem *_item; + byte _r, _g, _b; + int _talkPattern; + int _standPattern; + int _startTalkPattern, _endTalkPattern; + int _numTexts; + + void save(Common::OutSaveFile *f) { + f->writeUint32LE(_code); f->writeUint32LE(0); - f->writeByte(r); - f->writeByte(g); - f->writeByte(b); - f->writeUint32LE(talkpattern); - f->writeUint32LE(standpattern); - f->writeUint32LE(starttalkpattern); - f->writeUint32LE(endtalkpattern); - f->writeUint32LE(numtexts); + f->writeByte(_r); + f->writeByte(_g); + f->writeByte(_b); + f->writeUint32LE(_talkPattern); + f->writeUint32LE(_standPattern); + f->writeUint32LE(_startTalkPattern); + f->writeUint32LE(_endTalkPattern); + f->writeUint32LE(_numTexts); } - void Load(Common::InSaveFile *f) { - code = f->readUint32LE(); + void load(Common::InSaveFile *f) { + _code = f->readUint32LE(); f->readUint32LE(); - item = NULL; - r = f->readByte(); - g = f->readByte(); - b = f->readByte(); - talkpattern = f->readUint32LE(); - standpattern = f->readUint32LE(); - starttalkpattern = f->readUint32LE(); - endtalkpattern = f->readUint32LE(); - numtexts = f->readUint32LE(); + _item = NULL; + _r = f->readByte(); + _g = f->readByte(); + _b = f->readByte(); + _talkPattern = f->readUint32LE(); + _standPattern = f->readUint32LE(); + _startTalkPattern = f->readUint32LE(); + _endTalkPattern = f->readUint32LE(); + _numTexts = f->readUint32LE(); } }; struct MCharacterStruct { - uint32 code; - RMItem *item; - byte r, g, b; - int x, y; - int numtalks[10]; - int curgroup; - int numtexts; - bool bInTexts; - int curTalk; - bool bAlwaysBack; - - void Save(Common::OutSaveFile *f) { - f->writeUint32LE(code); + uint32 _code; + RMItem *_item; + byte _r, _g, _b; + int _x, _y; + int _numTalks[10]; + int _curGroup; + int _numTexts; + bool _bInTexts; + int _curTalk; + bool _bAlwaysBack; + + void save(Common::OutSaveFile *f) { + f->writeUint32LE(_code); f->writeUint32LE(0); - f->writeByte(r); - f->writeByte(g); - f->writeByte(b); - f->writeUint32LE(x); - f->writeUint32LE(y); + f->writeByte(_r); + f->writeByte(_g); + f->writeByte(_b); + f->writeUint32LE(_x); + f->writeUint32LE(_y); for (int i = 0; i < 10; ++i) - f->writeUint32LE(numtalks[i]); - f->writeUint32LE(curgroup); - f->writeUint32LE(numtexts); - f->writeByte(bInTexts); - f->writeUint32LE(curTalk); - f->writeByte(bAlwaysBack); + f->writeUint32LE(_numTalks[i]); + f->writeUint32LE(_curGroup); + f->writeUint32LE(_numTexts); + f->writeByte(_bInTexts); + f->writeUint32LE(_curTalk); + f->writeByte(_bAlwaysBack); } - void Load(Common::InSaveFile *f) { - code = f->readUint32LE(); + void load(Common::InSaveFile *f) { + _code = f->readUint32LE(); f->readUint32LE(); - item = NULL; - r = f->readByte(); - g = f->readByte(); - b = f->readByte(); - x = f->readUint32LE(); - y = f->readUint32LE(); + _item = NULL; + _r = f->readByte(); + _g = f->readByte(); + _b = f->readByte(); + _x = f->readUint32LE(); + _y = f->readUint32LE(); for (int i = 0; i < 10; ++i) - numtalks[i] = f->readUint32LE(); - curgroup = f->readUint32LE(); - numtexts = f->readUint32LE(); - bInTexts = f->readByte(); - curTalk = f->readUint32LE(); - bAlwaysBack = f->readByte(); + _numTalks[i] = f->readUint32LE(); + _curGroup = f->readUint32LE(); + _numTexts = f->readUint32LE(); + _bInTexts = f->readByte(); + _curTalk = f->readUint32LE(); + _bAlwaysBack = f->readByte(); } }; struct ChangedHotspotStruct { - uint32 dwCode; - uint32 nX, nY; + uint32 _dwCode; + uint32 _nX, _nY; - void Save(Common::OutSaveFile *f) { - f->writeUint32LE(dwCode); - f->writeUint32LE(nX); - f->writeUint32LE(nY); + void save(Common::OutSaveFile *f) { + f->writeUint32LE(_dwCode); + f->writeUint32LE(_nX); + f->writeUint32LE(_nY); } - void Load(Common::InSaveFile *f) { - dwCode = f->readUint32LE(); - nX = f->readUint32LE(); - nY = f->readUint32LE(); + void load(Common::InSaveFile *f) { + _dwCode = f->readUint32LE(); + _nX = f->readUint32LE(); + _nY = f->readUint32LE(); } }; @@ -170,23 +170,23 @@ class Globals { public: Globals(); - char nextMusic[MAX_PATH]; - bool nextLoop; - int nextChannel; - int nextSync; - int curChannel; - int flipflop; + char _nextMusic[MAX_PATH]; + bool _nextLoop; + int _nextChannel; + int _nextSync; + int _curChannel; + int _flipflop; // OSystem::MutexRef csMusic; - CharacterStruct Character[16]; - MCharacterStruct MCharacter[10]; - ChangedHotspotStruct ChangedHotspot[256]; - bool IsMChar[16]; - bool bAlwaysDisplay; - RMPoint saveTonyPos; - int saveTonyLoc; - RMTextDialog *curBackText; - bool bTonyIsSpeaking; - int curChangedHotspot; + CharacterStruct _character[16]; + MCharacterStruct _mCharacter[10]; + ChangedHotspotStruct _changedHotspot[256]; + bool _isMChar[16]; + bool _bAlwaysDisplay; + RMPoint _saveTonyPos; + int _saveTonyLoc; + RMTextDialog *_curBackText; + bool _bTonyIsSpeaking; + int _curChangedHotspot; bool bPatIrqFreeze; bool bCfgInvLocked; bool bCfgInvNoScroll; diff --git a/engines/tony/mpal/mpalutils.cpp b/engines/tony/mpal/mpalutils.cpp index bce623e43c..aba92a86cd 100644 --- a/engines/tony/mpal/mpalutils.cpp +++ b/engines/tony/mpal/mpalutils.cpp @@ -85,12 +85,12 @@ RMResRaw::RMResRaw(uint32 resID) : RMRes(resID) { RMResRaw::~RMResRaw() { } -const byte *RMResRaw::DataPointer() { +const byte *RMResRaw::dataPointer() { return _buf + 8; } RMResRaw::operator const byte *() { - return DataPointer(); + return dataPointer(); } int RMResRaw::width() { diff --git a/engines/tony/mpal/mpalutils.h b/engines/tony/mpal/mpalutils.h index a428a40a64..19810cf3a1 100644 --- a/engines/tony/mpal/mpalutils.h +++ b/engines/tony/mpal/mpalutils.h @@ -54,7 +54,7 @@ public: RMResRaw(uint32 resID); virtual ~RMResRaw(); - const byte *DataPointer(); + const byte *dataPointer(); operator const byte*(); int width(); diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index e763877d97..e53177513a 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -191,7 +191,7 @@ void TonyEngine::playMusic(int nChannel, const char *fn, int nFX, bool bLoop, in // g_system->lockMutex(csMusic); if (nChannel < 4) - if (GLOBALS.flipflop) + if (GLOBALS._flipflop) nChannel = nChannel + 1; switch (nFX) { @@ -287,7 +287,7 @@ void TonyEngine::stopMusic(int nChannel) { // g_system->lockMutex(csMusic); if (nChannel < 4) - _stream[nChannel + GLOBALS.flipflop]->Stop(); + _stream[nChannel + GLOBALS._flipflop]->Stop(); else _stream[nChannel]->Stop(); -- cgit v1.2.3 From d4777379d23b70aa07feec3ef2e90fcf376f4117 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 8 Jun 2012 23:00:48 +1000 Subject: TONY: Refactored the memory manager to increase performance --- engines/tony/loc.cpp | 2 +- engines/tony/mpal/expr.cpp | 4 +- engines/tony/mpal/expr.h | 2 + engines/tony/mpal/loadmpc.cpp | 16 +++--- engines/tony/mpal/memory.cpp | 128 +++++++++++++++++------------------------- engines/tony/mpal/memory.h | 53 ++++++++--------- engines/tony/mpal/mpal.cpp | 15 ++--- engines/tony/mpal/mpal.h | 7 +-- engines/tony/tony.h | 1 - engines/tony/utils.cpp | 4 +- 10 files changed, 99 insertions(+), 133 deletions(-) (limited to 'engines') diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 2700a05831..afde5403b5 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -2305,7 +2305,7 @@ RMMessage::RMMessage() { RMMessage::~RMMessage() { if (lpMessage) - globalFree(lpMessage); + globalDestroy(lpMessage); } void RMMessage::load(uint32 dwId) { diff --git a/engines/tony/mpal/expr.cpp b/engines/tony/mpal/expr.cpp index 0b51724330..5ba2fff442 100644 --- a/engines/tony/mpal/expr.cpp +++ b/engines/tony/mpal/expr.cpp @@ -238,7 +238,7 @@ static int evaluateAndFreeExpression(byte *expr) { // 3) Risoluzione algebrica solve(one, num); val = one->val.num; - globalFree(expr); + globalDestroy(expr); return val; } @@ -263,7 +263,7 @@ const byte *parseExpression(const byte *lpBuf, HGLOBAL *h) { if (num == 0) return NULL; - *h = globalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, num * sizeof(EXPRESSION) + 1); + *h = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, num * sizeof(EXPRESSION) + 1); if (*h == NULL) return NULL; diff --git a/engines/tony/mpal/expr.h b/engines/tony/mpal/expr.h index 7d33e5c8ca..9844add822 100644 --- a/engines/tony/mpal/expr.h +++ b/engines/tony/mpal/expr.h @@ -29,6 +29,8 @@ #ifndef MPAL_EXPR_H #define MPAL_EXPR_H +#include "tony/mpal/memory.h" + namespace Tony { namespace MPAL { diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index 8f07102aa3..5a338b24b0 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -149,7 +149,7 @@ static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { for (i = 0; i < num; i++) { lpmdDialog->_periodNums[i] = READ_LE_UINT16(lpBuf); lpBuf += 2; - lpmdDialog->_periods[i] = globalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, *lpBuf + 1); + lpmdDialog->_periods[i] = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, *lpBuf + 1); lpLock = (byte *)globalLock(lpmdDialog->_periods[i]); Common::copy(lpBuf + 1, lpBuf + 1 + *lpBuf, lpLock); globalUnlock(lpmdDialog->_periods[i]); @@ -478,7 +478,7 @@ bool ParseMpc(const byte *lpBuf) { GLOBALS.nVars = READ_LE_UINT16(lpBuf); lpBuf += 2; - GLOBALS.hVars = globalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof(MPALVAR) * (uint32)GLOBALS.nVars); + GLOBALS.hVars = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof(MPALVAR) * (uint32)GLOBALS.nVars); if (GLOBALS.hVars == NULL) return false; @@ -507,7 +507,7 @@ bool ParseMpc(const byte *lpBuf) { lpBuf += 2; #ifdef NEED_LOCK_MSGS - GLOBALS.hMsgs = globalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof(MPALMSG) * (uint32)GLOBALS.nMsgs); + GLOBALS.hMsgs = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof(MPALMSG) * (uint32)GLOBALS.nMsgs); if (GLOBALS.hMsgs == NULL) return false; @@ -525,7 +525,7 @@ bool ParseMpc(const byte *lpBuf) { for (j = 0; lpBuf[j] != 0;) j += lpBuf[j] + 1; - GLOBALS.lpmmMsgs->hText = globalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, j + 1); + GLOBALS.lpmmMsgs->hText = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, j + 1); lpTemp2 = lpTemp = (byte *)globalLock(GLOBALS.lpmmMsgs->hText); for (j = 0; lpBuf[j] != 0;) { @@ -560,7 +560,7 @@ bool ParseMpc(const byte *lpBuf) { if (*((const byte *)lpBuf + 2) == 6 && strncmp((const char *)lpBuf + 3, "Dialog", 6) == 0) { GLOBALS.nDialogs = READ_LE_UINT16(lpBuf); lpBuf += 2; - GLOBALS.hDialogs = globalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nDialogs * sizeof(MPALDIALOG)); + GLOBALS.hDialogs = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nDialogs * sizeof(MPALDIALOG)); if (GLOBALS.hDialogs == NULL) return false; @@ -581,7 +581,7 @@ bool ParseMpc(const byte *lpBuf) { lpBuf += 2; // Allocate memory and read them in - GLOBALS.hItems = globalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nItems * sizeof(MPALITEM)); + GLOBALS.hItems = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nItems * sizeof(MPALITEM)); if (GLOBALS.hItems == NULL) return false; @@ -602,7 +602,7 @@ bool ParseMpc(const byte *lpBuf) { lpBuf += 2; // Allocate memory and read them in - GLOBALS.hLocations = globalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nLocations*sizeof(MPALLOCATION)); + GLOBALS.hLocations = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nLocations*sizeof(MPALLOCATION)); if (GLOBALS.hLocations == NULL) return false; @@ -623,7 +623,7 @@ bool ParseMpc(const byte *lpBuf) { lpBuf += 2; // Allocate memory - GLOBALS.hScripts = globalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nScripts * sizeof(MPALSCRIPT)); + GLOBALS.hScripts = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nScripts * sizeof(MPALSCRIPT)); if (GLOBALS.hScripts == NULL) return false; diff --git a/engines/tony/mpal/memory.cpp b/engines/tony/mpal/memory.cpp index b5bd77f838..b50f9d7c37 100644 --- a/engines/tony/mpal/memory.cpp +++ b/engines/tony/mpal/memory.cpp @@ -29,123 +29,101 @@ namespace Tony { namespace MPAL { -/****************************************************************************\ -* MemoryItem methods -\****************************************************************************/ - -/** - * Constructor - * @param Data sizee - */ -MemoryItem::MemoryItem(uint32 size) { - _size = size; - _buffer = (size == 0) ? NULL : new byte[size]; -} - -/** - * Destructor - */ -MemoryItem::~MemoryItem() { - delete[] _buffer; -} - -/** - * Returns a pointer to the resource - */ -MemoryItem::operator void *() { - return dataPointer(); -} - /****************************************************************************\ * MemoryManager methods \****************************************************************************/ -MemoryManager::MemoryManager() { -} - -/** - * Destructor - */ -MemoryManager::~MemoryManager() { - Common::List::iterator i; - for (i = _memoryBlocks.begin(); i != _memoryBlocks.end(); ++i) { - MemoryItem *item = *i; - delete item; - } -} +const int BLOCK_ID = 0x12345678; /** * Allocates a new memory block - * @returns Returns a MemoryItem instance for the new block + * @return Returns a MemoryItem instance for the new block */ -MemoryItem &MemoryManager::allocate(uint32 size, uint flags) { - MemoryItem *newItem = new MemoryItem(size); +HANDLE MemoryManager::allocate(uint32 size, uint flags) { + MemoryItem *newItem = (MemoryItem *)malloc(sizeof(MemoryItem) + size); + newItem->_id = BLOCK_ID; + newItem->_size = size; + newItem->_lockCount = 0; + + // If requested, clear the allocated data block if ((flags & GMEM_ZEROINIT) != 0) { - byte *dataP = (byte *)newItem->dataPointer(); + byte *dataP = newItem->_data; Common::fill(dataP, dataP + size, 0); } - _memoryBlocks.push_back(newItem); - - return *newItem; + return (HANDLE)newItem; } /** * Allocates a new memory block and returns its data pointer - * @returns Data pointer to allocated block + * @return Data pointer to allocated block */ -HGLOBAL MemoryManager::alloc(uint32 size, uint flags) { - MemoryItem &newItem = allocate(size, flags); - return (HGLOBAL)newItem.dataPointer(); +void *MemoryManager::alloc(uint32 size, uint flags) { + MemoryItem *item = (MemoryItem *)allocate(size, flags); + ++item->_lockCount; + return &item->_data[0]; } +#define OFFSETOF(type, field) ((unsigned long) &(((type *) 0)->field)) + /** * Returns a reference to the MemoryItem for a gien byte pointer * @param block Byte pointer */ -MemoryItem &MemoryManager::getItem(HGLOBAL handle) { - Common::List::iterator i; - for (i = _memoryBlocks.begin(); i != _memoryBlocks.end(); ++i) { - MemoryItem *item = *i; - if (item->dataPointer() == handle) - return *item; - } - - error("Could not locate a memory block"); +MemoryItem *MemoryManager::getItem(HGLOBAL handle) { + MemoryItem *rec = (MemoryItem *)((byte *)handle - OFFSETOF(MemoryItem, _data)); + assert(rec->_id == BLOCK_ID); + return rec; } /** - * Square bracketes operator - * @param block Byte pointer + * Returns a size of a memory block given its pointer */ -MemoryItem &MemoryManager::operator[](HGLOBAL handle) { - return getItem(handle); +uint32 MemoryManager::getSize(HANDLE handle) { + MemoryItem *item = (MemoryItem *)handle; + assert(item->_id == BLOCK_ID); + return item->_size; } /** - * Returns a size of a memory block given its pointer + * Erases a given item */ -uint32 MemoryManager::getSize(HGLOBAL handle) { - MemoryItem &item = getItem(handle); - return item.size(); +void MemoryManager::freeBlock(HANDLE handle) { + MemoryItem *item = (MemoryItem *)handle; + assert(item->_id == BLOCK_ID); + free(item); } /** * Erases a given item */ -void MemoryManager::erase(MemoryItem *item) { - delete item; - _memoryBlocks.remove(item); +void MemoryManager::destroyItem(HANDLE handle) { + MemoryItem *item = getItem(handle); + assert(item->_id == BLOCK_ID); + free(item); } /** - * Erases a given item + * Locks an item for access */ -void MemoryManager::erase(HGLOBAL handle) { - MemoryItem &item = getItem(handle); - erase(&item); +byte *MemoryManager::lockItem(HANDLE handle) { + MemoryItem *item = (MemoryItem *)handle; + assert(item->_id == BLOCK_ID); + ++item->_lockCount; + return &item->_data[0]; } +/** + * Unlocks a locked item + */ +void MemoryManager::unlockItem(HANDLE handle) { + MemoryItem *item = (MemoryItem *)handle; + assert(item->_id == BLOCK_ID); + assert(item->_lockCount > 0); + --item->_lockCount; +} + + /****************************************************************************\ * Stand-alone methods \****************************************************************************/ diff --git a/engines/tony/mpal/memory.h b/engines/tony/mpal/memory.h index 7f95f8d86f..52d527544a 100644 --- a/engines/tony/mpal/memory.h +++ b/engines/tony/mpal/memory.h @@ -34,46 +34,37 @@ namespace MPAL { typedef void *HANDLE; typedef HANDLE HGLOBAL; -class MemoryItem { -protected: - byte *_buffer; +struct MemoryItem { + uint32 _id; uint32 _size; -public: - MemoryItem(uint32 size); - virtual ~MemoryItem(); - - uint32 size() { return _size; } - void *dataPointer() { return (void *)_buffer; } - bool isValid() { return _buffer != NULL; } - - // Casting for access to data - operator void *(); + int _lockCount; + byte _data[1]; + + // Casting for access to data + operator void *() { return &_data[0]; } }; class MemoryManager { private: - Common::List _memoryBlocks; + static MemoryItem *getItem(HGLOBAL handle); public: - MemoryManager(); - virtual ~MemoryManager(); - - MemoryItem &allocate(uint32 size, uint flags); - HGLOBAL alloc(uint32 size, uint flags); - MemoryItem &getItem(HGLOBAL handle); - MemoryItem &operator[](HGLOBAL handle); - void erase(MemoryItem *item); - void erase(HGLOBAL handle); - - uint32 getSize(HANDLE handle); + static HANDLE allocate(uint32 size, uint flags); + static void *alloc(uint32 size, uint flags); + static void freeBlock(HANDLE handle); + static void destroyItem(HANDLE handle); + static uint32 getSize(HANDLE handle); + static byte *lockItem(HANDLE handle); + static void unlockItem(HANDLE handle); }; // defines -#define globalAlloc(flags, size) _vm->_memoryManager.alloc(size, flags) -#define globalAllocate(size) _vm->_memoryManager.allocate(size, 0) -#define globalFree(handle) _vm->_memoryManager.erase(handle) -#define globalLock(handle) (_vm->_memoryManager.getItem(handle).dataPointer()) -#define globalUnlock(handle) {} -#define globalSize(handle) (_vm->_memoryManager.getItem(handle).size()) +#define globalAlloc(flags, size) MemoryManager::alloc(size, flags) +#define globalAllocate(flags, size) MemoryManager::allocate(size, flags) +#define globalFree(handle) MemoryManager::freeBlock(handle) +#define globalDestroy(handle) MemoryManager::destroyItem(handle) +#define globalLock(handle) MemoryManager::lockItem(handle) +#define globalUnlock(handle) MemoryManager::unlockItem(handle) +#define globalSize(handle) MemoryManager::getSize(handle) #define GMEM_FIXED 1 #define GMEM_MOVEABLE 2 diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 95c0b067d5..425fe187fc 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -402,7 +402,7 @@ HGLOBAL resLoad(uint32 dwId) { if (GLOBALS.hMpr.err()) return NULL; - h = globalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, nSizeDecomp + (nSizeDecomp / 1024) * 16); + h = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, nSizeDecomp + (nSizeDecomp / 1024) * 16); buf = (byte *)globalLock(h); temp = (byte *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT,nSizeComp); @@ -414,7 +414,7 @@ HGLOBAL resLoad(uint32 dwId) { if (nBytesRead != nSizeDecomp) return NULL; - globalFree(temp); + globalDestroy(temp); globalUnlock(h); return h; } @@ -741,7 +741,7 @@ void ActionThread(CORO_PARAM, const void *param) { } } - globalFree(item); + globalDestroy(item); debugC(DEBUG_DETAILED, kTonyDebugActions, "Action Process %d ended", CoroScheduler.getCurrentPID()); @@ -803,6 +803,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { } MYTHREAD; CORO_BEGIN_CONTEXT; + // TODO: Requires endian fix uint32 *il; int i, j, k; int numitems; @@ -859,7 +860,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { /* If there is nothing left, we can exit */ if (_ctx->nRealItems == 0) { - globalFree(_ctx->il); + globalDestroy(_ctx->il); CORO_KILL_SELF(); return; } @@ -1456,7 +1457,7 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, if (nBytesRead != dwSizeDecomp) return false; - globalFree(cmpbuf); + globalDestroy(cmpbuf); } else { /* If the file is not compressed, we directly read in the data */ nBytesRead = hMpc.read(lpMpcImage, dwSizeDecomp); @@ -1471,7 +1472,7 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, if (ParseMpc(lpMpcImage) == false) return false; - globalFree(lpMpcImage); + globalDestroy(lpMpcImage); /* Calculate memory usage */ /* @@ -1529,7 +1530,7 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, if (nBytesRead != (uint32)GLOBALS.nResources * 8) return false; - globalFree(cmpbuf); + globalDestroy(cmpbuf); /* Reset back to the start of the file, leaving it open */ GLOBALS.hMpr.seek(0, SEEK_SET); diff --git a/engines/tony/mpal/mpal.h b/engines/tony/mpal/mpal.h index fb3d019051..f23eaf8e4a 100644 --- a/engines/tony/mpal/mpal.h +++ b/engines/tony/mpal/mpal.h @@ -85,17 +85,12 @@ #include "common/coroutines.h" #include "common/rect.h" #include "common/str.h" +#include "tony/mpal/memory.h" namespace Tony { namespace MPAL { -/****************************************************************************\ -* Type definitions -\****************************************************************************/ - -typedef void *HANDLE; - /****************************************************************************\ * Macro definitions and structures \****************************************************************************/ diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 83543f8022..68730fa91b 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -95,7 +95,6 @@ public: LPCUSTOMFUNCTION _funcList[300]; Common::String _funcListStrings[300]; Common::RandomSource _randomSource; - MPAL::MemoryManager _memoryManager; RMResUpdate _resUpdate; uint32 _hEndOfFrame; Common::File _vdbFP; diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index 98b23001c0..fa100d681e 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -1069,7 +1069,7 @@ HGLOBAL RMResUpdate::queryResource(uint32 dwRes) { } // Allocate space for the output resource - HGLOBAL destBuf = globalAllocate(info.size); + HGLOBAL destBuf = globalAllocate(0, info.size); byte *lpDestBuf = (byte *)globalLock(destBuf); uint32 dwSize; @@ -1081,7 +1081,7 @@ HGLOBAL RMResUpdate::queryResource(uint32 dwRes) { // Return the resource globalUnlock(destBuf); - return lpDestBuf; + return destBuf; } } // End of namespace Tony -- cgit v1.2.3 From 739983f42fae768dfee574122adbac93ac8b15d2 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 8 Jun 2012 23:21:12 +1000 Subject: TONY: Fixed sign of block identifier constant --- engines/tony/mpal/memory.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/tony/mpal/memory.cpp b/engines/tony/mpal/memory.cpp index b50f9d7c37..c5e752d390 100644 --- a/engines/tony/mpal/memory.cpp +++ b/engines/tony/mpal/memory.cpp @@ -33,7 +33,7 @@ namespace MPAL { * MemoryManager methods \****************************************************************************/ -const int BLOCK_ID = 0x12345678; +const uint32 BLOCK_ID = 0x12345678; /** * Allocates a new memory block -- cgit v1.2.3 From 83f1cad02be38e56161350aabc29176f24c901a0 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 9 Jun 2012 01:20:08 +1000 Subject: TONY: Added code to free parsed MPC file data when the game ends --- engines/tony/mpal/expr.cpp | 30 +++++++++++- engines/tony/mpal/expr.h | 7 +++ engines/tony/mpal/loadmpc.cpp | 108 ++++++++++++++++++++++++++++++++++++++++++ engines/tony/mpal/loadmpc.h | 4 ++ engines/tony/mpal/mpal.cpp | 1 - engines/tony/tony.cpp | 1 + 6 files changed, 149 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/expr.cpp b/engines/tony/mpal/expr.cpp index 5ba2fff442..a9d48e2016 100644 --- a/engines/tony/mpal/expr.cpp +++ b/engines/tony/mpal/expr.cpp @@ -84,7 +84,7 @@ typedef struct { byte type; // Tipo di oggetto (vedi enum ExprListTypes) byte unary; // Unary operatore (NON SUPPORTATO) - union { + union { int num; // Numero (se type==ELT_NUMBER) char *name; // Nome variabile (se type==ELT_VAR) HGLOBAL son; // Handle a espressione (type==ELT_PARENTH) @@ -400,6 +400,34 @@ bool compareExpressions(HGLOBAL h1, HGLOBAL h2) { return true; } +/** + * Frees an expression that was previously parsed + * + * @param h Handle for the expression + */ +void freeExpression(HGLOBAL h) { + byte *data = (byte *)globalLock(h); + int num = *data; + LPEXPRESSION cur = (LPEXPRESSION)(data + 1); + + for (int i = 0; i < num; ++i, ++cur) { + switch (cur->type) { + case ELT_VAR: + globalDestroy(cur->val.name); + break; + + case ELT_PARENTH: + freeExpression(cur->val.son); + break; + + default: + break; + } + } + + globalUnlock(h); + globalFree(h); +} } // end of namespace MPAL diff --git a/engines/tony/mpal/expr.h b/engines/tony/mpal/expr.h index 9844add822..3130539000 100644 --- a/engines/tony/mpal/expr.h +++ b/engines/tony/mpal/expr.h @@ -65,6 +65,13 @@ int evaluateExpression(HGLOBAL h); */ bool compareExpressions(HGLOBAL h1, HGLOBAL h2); +/** + * Frees an expression that was previously parsed + * + * @param h Handle for the expression + */ +void freeExpression(HGLOBAL h); + } // end of namespace MPAL } // end of namespace Tony diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index 5a338b24b0..aa048c0b2f 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -121,6 +121,21 @@ static const byte *ParseScript(const byte *lpBuf, LPMPALSCRIPT lpmsScript) { return lpBuf; } +/** + * Frees a script allocated via a previous call to ParseScript + * + * @param lpmsScript Pointer to a script structure + */ +static void FreeScript(LPMPALSCRIPT lpmsScript) { + for (int i = 0; i < MAX_COMMANDS_PER_SCRIPT && (lpmsScript->_command[i].type); ++i, ++lpmsScript) { + if (lpmsScript->_command[i].type == 2) { + // Variable Assign + globalDestroy(lpmsScript->_command[i].lpszVarName); + freeExpression(lpmsScript->_command[i].expr); + } + } +} + /** * Parses a dialog from the MPC file, and inserts its data into a structure * @@ -428,6 +443,25 @@ static const byte *parseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { return lpBuf; } +/** + * Frees an item parsed from a prior call to ParseItem + * + * @param lpmiItem Pointer to an item structure + */ +static void freeItem(LPMPALITEM lpmiItem) { + // Free the actions + if (lpmiItem->Action) + globalDestroy(lpmiItem->Action); + + // Free the commands + for (int i = 0; i < MAX_COMMANDS_PER_ITEM && (lpmiItem->_command[i].type); ++i, ++lpmiItem) { + if (lpmiItem->_command[i].type == 2) { + // Variable Assign + globalDestroy(lpmiItem->_command[i].lpszVarName); + freeExpression(lpmiItem->_command[i].expr); + } + } +} /** * Parses a location from the MPC file, and inserts its data into a structure @@ -651,6 +685,80 @@ bool ParseMpc(const byte *lpBuf) { return true; } +/** + * Free the given dialog + */ +static void freeDialog(LPMPALDIALOG lpmdDialog) { + // Free the periods + int i; + + for (i = 0; i < MAX_PERIODS_PER_DIALOG && (lpmdDialog->_periods[i]); ++i) + globalFree(lpmdDialog->_periods[i]); + + for (i = 0; i < MAX_COMMANDS_PER_GROUP && (lpmdDialog->_command[i].type); i++) { + if (lpmdDialog->_command[i].type == 2) { + // Variable assign + globalDestroy(lpmdDialog->_command[i].lpszVarName); + freeExpression(lpmdDialog->_command[i].expr); + } + } +} + +/** + * Frees any data allocated from the parsing of the MPC file + */ +void FreeMpc() { + int i; + + // Free variables + globalFree(GLOBALS.hVars); + + // Free messages + LPMPALMSG lpmmMsgs = (LPMPALMSG)globalLock(GLOBALS.hMsgs); + for (i = 0; i < GLOBALS.nMsgs; i++, ++lpmmMsgs) + globalFree(lpmmMsgs->hText); + + globalUnlock(GLOBALS.hMsgs); + globalFree(GLOBALS.hMsgs); + + // Free objects + if (GLOBALS.hDialogs) { + LPMPALDIALOG lpmdDialogs = (LPMPALDIALOG)globalLock(GLOBALS.hDialogs); + + for (i = 0; i < GLOBALS.nDialogs; i++, ++lpmdDialogs) + freeDialog(lpmdDialogs); + + globalFree(GLOBALS.hDialogs); + } + + // Free items + if (GLOBALS.hItems) { + LPMPALITEM lpmiItems = (LPMPALITEM)globalLock(GLOBALS.hItems); + + for (i = 0; i < GLOBALS.nItems; ++i, ++lpmiItems) + freeItem(lpmiItems); + + globalUnlock(GLOBALS.hItems); + globalFree(GLOBALS.hItems); + } + + // Free the locations + if (GLOBALS.hLocations) { + globalFree(GLOBALS.hLocations); + } + + // Free the scripts + if (GLOBALS.hScripts) { + LPMPALSCRIPT lpmsScripts = (LPMPALSCRIPT)globalLock(GLOBALS.hScripts); + + for (i = 0; i < GLOBALS.nScripts; ++i, ++lpmsScripts) { + FreeScript(lpmsScripts); + } + + globalUnlock(GLOBALS.hScripts); + } +} + } // end of namespace MPAL } // end of namespace Tony diff --git a/engines/tony/mpal/loadmpc.h b/engines/tony/mpal/loadmpc.h index 2f8a1121ec..83463f0092 100644 --- a/engines/tony/mpal/loadmpc.h +++ b/engines/tony/mpal/loadmpc.h @@ -46,6 +46,10 @@ namespace MPAL { */ bool ParseMpc(const byte *lpBuf); +/** + * Frees any data allocated from the parsing of the MPC file + */ +void FreeMpc(); } // end of namespace MPAL diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 425fe187fc..04d562ffc9 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -803,7 +803,6 @@ void LocationPollThread(CORO_PARAM, const void *param) { } MYTHREAD; CORO_BEGIN_CONTEXT; - // TODO: Requires endian fix uint32 *il; int i, j, k; int numitems; diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index e53177513a..7f7930c5d7 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -573,6 +573,7 @@ void TonyEngine::close(void) { _theBoxes.close(); _theEngine.close(); _window.close(); + FreeMpc(); delete[] _curThumbnail; } -- cgit v1.2.3 From c52aca5ac407c498eb0a287697199a97f7c18bae Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 9 Jun 2012 00:52:38 +0200 Subject: TONY: Rename more globals --- engines/tony/custom.cpp | 38 +++++++++---------- engines/tony/font.cpp | 12 +++--- engines/tony/game.cpp | 80 ++++++++++++++++++++-------------------- engines/tony/gfxcore.cpp | 6 +-- engines/tony/gfxengine.cpp | 92 +++++++++++++++++++++++----------------------- engines/tony/globals.cpp | 48 ++++++++++++------------ engines/tony/globals.h | 48 ++++++++++++------------ engines/tony/inventory.cpp | 30 +++++++-------- engines/tony/loc.cpp | 2 +- engines/tony/sound.cpp | 8 ++-- engines/tony/tony.cpp | 34 ++++++++--------- engines/tony/tonychar.cpp | 2 +- 12 files changed, 200 insertions(+), 200 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 810e6a9353..7482ac0db8 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -495,7 +495,7 @@ DECLARE_CUSTOM_FUNCTION(SendFullscreenMessage)(CORO_PARAM, uint32 nMsg, uint32 n } DECLARE_CUSTOM_FUNCTION(NoOcchioDiBue)(CORO_PARAM, uint32, uint32, uint32, uint32) { - GLOBALS.bNoOcchioDiBue = true; + GLOBALS._bNoOcchioDiBue = true; } DECLARE_CUSTOM_FUNCTION(CloseLocation)(CORO_PARAM, uint32, uint32, uint32, uint32) { @@ -504,7 +504,7 @@ DECLARE_CUSTOM_FUNCTION(CloseLocation)(CORO_PARAM, uint32, uint32, uint32, uint3 CORO_BEGIN_CODE(_ctx); - if (!GLOBALS.bNoOcchioDiBue) { + if (!GLOBALS._bNoOcchioDiBue) { GLOBALS.InitWipe(1); CORO_INVOKE_0(GLOBALS.WaitWipeEnd); } @@ -526,7 +526,7 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint CORO_BEGIN_CODE(_ctx); - if (!GLOBALS.bNoOcchioDiBue) { + if (!GLOBALS._bNoOcchioDiBue) { GLOBALS.InitWipe(1); CORO_INVOKE_0(GLOBALS.WaitWipeEnd); } @@ -550,7 +550,7 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint _vm->playMusic(4, tappetiFile[GLOBALS.lastTappeto], 0, true, 2000); } - if (!GLOBALS.bNoOcchioDiBue) { + if (!GLOBALS._bNoOcchioDiBue) { GLOBALS.InitWipe(2); } @@ -559,12 +559,12 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint _ctx->h = mpalQueryDoAction(0, nLoc, 0); - if (!GLOBALS.bNoOcchioDiBue) { + if (!GLOBALS._bNoOcchioDiBue) { CORO_INVOKE_0(GLOBALS.WaitWipeEnd); GLOBALS.CloseWipe(); } - GLOBALS.bNoOcchioDiBue = false; + GLOBALS._bNoOcchioDiBue = false; // On Enter? if (_ctx->h != CORO_INVALID_PID_VALUE) @@ -2102,14 +2102,14 @@ void ThreadFadeOutMusic(CORO_PARAM, const void *nMusic) { debug("Start FadeOut Music"); - for (_ctx->i = 16; _ctx->i > 0 && !GLOBALS.bFadeOutStop; _ctx->i--) { + for (_ctx->i = 16; _ctx->i > 0 && !GLOBALS._bFadeOutStop; _ctx->i--) { if (_ctx->i * 4 < _ctx->startVolume) _vm->setMusicVolume(nChannel, _ctx->i * 4); CORO_INVOKE_1(CoroScheduler.sleep, 100); } - if (!GLOBALS.bFadeOutStop) + if (!GLOBALS._bFadeOutStop) _vm->setMusicVolume(nChannel, 0); // If there is a stacchetto, stop all @@ -2124,16 +2124,16 @@ void ThreadFadeOutMusic(CORO_PARAM, const void *nMusic) { } DECLARE_CUSTOM_FUNCTION(FadeInSonoriz)(CORO_PARAM, uint32, uint32, uint32, uint32) { - CoroScheduler.createProcess(ThreadFadeInMusic, &GLOBALS.curSonoriz, sizeof(int)); + CoroScheduler.createProcess(ThreadFadeInMusic, &GLOBALS._curSonoriz, sizeof(int)); } DECLARE_CUSTOM_FUNCTION(FadeOutSonoriz)(CORO_PARAM, uint32, uint32, uint32, uint32) { - GLOBALS.bFadeOutStop = false; - CoroScheduler.createProcess(ThreadFadeOutMusic, &GLOBALS.curSonoriz, sizeof(int)); + GLOBALS._bFadeOutStop = false; + CoroScheduler.createProcess(ThreadFadeOutMusic, &GLOBALS._curSonoriz, sizeof(int)); } DECLARE_CUSTOM_FUNCTION(FadeOutStacchetto)(CORO_PARAM, uint32, uint32, uint32, uint32) { - GLOBALS.bFadeOutStop = false; + GLOBALS._bFadeOutStop = false; int channel = 2; CoroScheduler.createProcess(ThreadFadeOutMusic, &channel, sizeof(int)); } @@ -2144,7 +2144,7 @@ DECLARE_CUSTOM_FUNCTION(FadeInStacchetto)(CORO_PARAM, uint32, uint32, uint32, ui } DECLARE_CUSTOM_FUNCTION(StopSonoriz)(CORO_PARAM, uint32, uint32, uint32, uint32) { - _vm->stopMusic(GLOBALS.curSonoriz); + _vm->stopMusic(GLOBALS._curSonoriz); } DECLARE_CUSTOM_FUNCTION(StopStacchetto)(CORO_PARAM, uint32, uint32, uint32, uint32) { @@ -2152,12 +2152,12 @@ DECLARE_CUSTOM_FUNCTION(StopStacchetto)(CORO_PARAM, uint32, uint32, uint32, uint } DECLARE_CUSTOM_FUNCTION(MuteSonoriz)(CORO_PARAM, uint32, uint32, uint32, uint32) { - _vm->setMusicVolume(GLOBALS.curSonoriz, 0); + _vm->setMusicVolume(GLOBALS._curSonoriz, 0); } DECLARE_CUSTOM_FUNCTION(DemuteSonoriz)(CORO_PARAM, uint32, uint32, uint32, uint32) { - GLOBALS.bFadeOutStop = true; - _vm->setMusicVolume(GLOBALS.curSonoriz, 64); + GLOBALS._bFadeOutStop = true; + _vm->setMusicVolume(GLOBALS._curSonoriz, 64); } DECLARE_CUSTOM_FUNCTION(MuteStacchetto)(CORO_PARAM, uint32, uint32, uint32, uint32) { @@ -2183,11 +2183,11 @@ void CustPlayMusic(uint32 nChannel, const char *mFN, uint32 nFX, bool bLoop, int DECLARE_CUSTOM_FUNCTION(PlaySonoriz)(CORO_PARAM, uint32 nMusic, uint32 nFX, uint32 bNoLoop, uint32) { if (nFX == 0 || nFX == 1 || nFX == 2) { debug("PlaySonoriz stop fadeout"); - GLOBALS.bFadeOutStop = true; + GLOBALS._bFadeOutStop = true; } GLOBALS.lastMusic = nMusic; - CustPlayMusic(GLOBALS.curSonoriz, musicFiles[nMusic].name, nFX, bNoLoop ? false : true, musicFiles[nMusic].sync); + CustPlayMusic(GLOBALS._curSonoriz, musicFiles[nMusic].name, nFX, bNoLoop ? false : true, musicFiles[nMusic].sync); } DECLARE_CUSTOM_FUNCTION(PlayStacchetto)(CORO_PARAM, uint32 nMusic, uint32 nFX, uint32 bLoop, uint32) { @@ -2270,7 +2270,7 @@ DECLARE_CUSTOM_FUNCTION(MustSkipIdleEnd)(CORO_PARAM, uint32, uint32, uint32, uin } DECLARE_CUSTOM_FUNCTION(PatIrqFreeze)(CORO_PARAM, uint32 bStatus, uint32, uint32, uint32) { - GLOBALS.bPatIrqFreeze = bStatus; + GLOBALS._bPatIrqFreeze = bStatus; } DECLARE_CUSTOM_FUNCTION(OpenInitLoadMenu)(CORO_PARAM, uint32, uint32, uint32, uint32) { diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 398389ebcd..23a92c5f30 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -1946,7 +1946,7 @@ void RMText::writeText(const RMString &text, RMFontColor *font, int *time) { } if (time != NULL) - *time = 1000 + numchar * (11 - GLOBALS.nCfgTextSpeed) * 14; + *time = 1000 + numchar * (11 - GLOBALS._nCfgTextSpeed) * 14; } void RMText::clipOnScreen(RMGfxPrimitive *prim) { @@ -2075,8 +2075,8 @@ void RMTextDialog::removeThis(CORO_PARAM, bool &result) { // Don't erase the background if (_bSkipStatus) { - if (!(GLOBALS.bCfgDubbing && hCustomSkip2 != CORO_INVALID_PID_VALUE)) { - if (GLOBALS.bCfgTimerizedText) { + if (!(GLOBALS._bCfgDubbing && hCustomSkip2 != CORO_INVALID_PID_VALUE)) { + if (GLOBALS._bCfgTimerizedText) { if (!_bForceNoTime) { if (_vm->getTime() > (uint32)_time + _startTime) return; @@ -2097,7 +2097,7 @@ void RMTextDialog::removeThis(CORO_PARAM, bool &result) { } } // Erase the background - else if (!(GLOBALS.bCfgDubbing && hCustomSkip2 != CORO_INVALID_PID_VALUE)) { + else if (!(GLOBALS._bCfgDubbing && hCustomSkip2 != CORO_INVALID_PID_VALUE)) { if (!_bForceNoTime) { if (_vm->getTime() > (uint32)_time + _startTime) return; @@ -2117,7 +2117,7 @@ void RMTextDialog::removeThis(CORO_PARAM, bool &result) { return; } - if (GLOBALS.bCfgDubbing && hCustomSkip2 != CORO_INVALID_PID_VALUE) { + if (GLOBALS._bCfgDubbing && hCustomSkip2 != CORO_INVALID_PID_VALUE) { CORO_INVOKE_3(CoroScheduler.waitForSingleObject, hCustomSkip2, 0, &_ctx->expired); // == WAIT_OBJECT_0 if (!_ctx->expired) @@ -2145,7 +2145,7 @@ void RMTextDialog::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *p _startTime = _vm->getTime(); if (_bShowed) { - if (GLOBALS.bCfgSottotitoli || _bAlwaysDisplay) { + if (GLOBALS._bCfgSottotitoli || _bAlwaysDisplay) { prim->getDst().topLeft() = dst; CORO_INVOKE_2(RMText::draw, bigBuf, prim); } diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 886b5f0859..f3aee0f183 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -673,57 +673,57 @@ void RMOptionScreen::initState(CORO_PARAM) { if (_nState == MENUGAME) { assert(_ButtonGame_Lock == NULL); _ButtonGame_Lock = new RMOptionButton(20008, RMPoint(176, 262), true); - _ButtonGame_Lock->setActiveState(GLOBALS.bCfgInvLocked); + _ButtonGame_Lock->setActiveState(GLOBALS._bCfgInvLocked); assert(_ButtonGame_TimerizedText == NULL); _ButtonGame_TimerizedText = new RMOptionButton(20009, RMPoint(463, 273), true); - _ButtonGame_TimerizedText->setActiveState(!GLOBALS.bCfgTimerizedText); + _ButtonGame_TimerizedText->setActiveState(!GLOBALS._bCfgTimerizedText); assert(_ButtonGame_Scrolling == NULL); _ButtonGame_Scrolling = new RMOptionButton(20010, RMPoint(315, 263), true); - _ButtonGame_Scrolling->setActiveState(GLOBALS.bCfgInvNoScroll); + _ButtonGame_Scrolling->setActiveState(GLOBALS._bCfgInvNoScroll); assert(_ButtonGame_InterUp == NULL); _ButtonGame_InterUp = new RMOptionButton(20011, RMPoint(36, 258), true); - _ButtonGame_InterUp->setActiveState(GLOBALS.bCfgInvUp); + _ButtonGame_InterUp->setActiveState(GLOBALS._bCfgInvUp); assert(_SlideTextSpeed == NULL); - _SlideTextSpeed = new RMOptionSlide(RMPoint(165, 122), 10, GLOBALS.nCfgTextSpeed); + _SlideTextSpeed = new RMOptionSlide(RMPoint(165, 122), 10, GLOBALS._nCfgTextSpeed); assert(_SlideTonySpeed == NULL); - _SlideTonySpeed = new RMOptionSlide(RMPoint(165, 226), 5, GLOBALS.nCfgTonySpeed); + _SlideTonySpeed = new RMOptionSlide(RMPoint(165, 226), 5, GLOBALS._nCfgTonySpeed); } // Menu Graphics else if (_nState == MENUGFX) { assert(_ButtonGfx_Anni30 == NULL); _ButtonGfx_Anni30 = new RMOptionButton(20015, RMPoint(247, 178), true); - _ButtonGfx_Anni30->setActiveState(GLOBALS.bCfgAnni30); + _ButtonGfx_Anni30->setActiveState(GLOBALS._bCfgAnni30); assert(_ButtonGfx_AntiAlias == NULL); _ButtonGfx_AntiAlias = new RMOptionButton(20016, RMPoint(430, 83), true); - _ButtonGfx_AntiAlias->setActiveState(!GLOBALS.bCfgAntiAlias); + _ButtonGfx_AntiAlias->setActiveState(!GLOBALS._bCfgAntiAlias); assert(_ButtonGfx_Sottotitoli == NULL); _ButtonGfx_Sottotitoli = new RMOptionButton(20017, RMPoint(98, 82), true); - _ButtonGfx_Sottotitoli->setActiveState(!GLOBALS.bCfgSottotitoli); + _ButtonGfx_Sottotitoli->setActiveState(!GLOBALS._bCfgSottotitoli); assert(_ButtonGfx_Tips == NULL); _ButtonGfx_Tips = new RMOptionButton(20018, RMPoint(431, 246), true); - _ButtonGfx_Tips->setActiveState(GLOBALS.bCfgInterTips); + _ButtonGfx_Tips->setActiveState(GLOBALS._bCfgInterTips); assert(_ButtonGfx_Trans == NULL); _ButtonGfx_Trans = new RMOptionButton(20019, RMPoint(126, 271), true); - _ButtonGfx_Trans->setActiveState(!GLOBALS.bCfgTransparence); + _ButtonGfx_Trans->setActiveState(!GLOBALS._bCfgTransparence); } else if (_nState == MENUSOUND) { assert(_SliderSound_Dubbing == NULL); - _SliderSound_Dubbing = new RMOptionSlide(RMPoint(165, 122), 10, GLOBALS.nCfgDubbingVolume); + _SliderSound_Dubbing = new RMOptionSlide(RMPoint(165, 122), 10, GLOBALS._nCfgDubbingVolume); assert(_SliderSound_Music == NULL); - _SliderSound_Music = new RMOptionSlide(RMPoint(165, 226), 10, GLOBALS.nCfgMusicVolume); + _SliderSound_Music = new RMOptionSlide(RMPoint(165, 226), 10, GLOBALS._nCfgMusicVolume); assert(_SliderSound_SFX == NULL); - _SliderSound_SFX = new RMOptionSlide(RMPoint(165, 330), 10, GLOBALS.nCfgSFXVolume); + _SliderSound_SFX = new RMOptionSlide(RMPoint(165, 330), 10, GLOBALS._nCfgSFXVolume); assert(_ButtonSound_DubbingOn == NULL); _ButtonSound_DubbingOn = new RMOptionButton(20033, RMPoint(339, 75), true); - _ButtonSound_DubbingOn->setActiveState(GLOBALS.bCfgDubbing); + _ButtonSound_DubbingOn->setActiveState(GLOBALS._bCfgDubbing); assert(_ButtonSound_MusicOn == NULL); _ButtonSound_MusicOn = new RMOptionButton(20034, RMPoint(338, 179), true); - _ButtonSound_MusicOn->setActiveState(GLOBALS.bCfgMusic); + _ButtonSound_MusicOn->setActiveState(GLOBALS._bCfgMusic); assert(_ButtonSound_SFXOn == NULL); _ButtonSound_SFXOn = new RMOptionButton(20035, RMPoint(338, 283), true); - _ButtonSound_SFXOn->setActiveState(GLOBALS.bCfgSFX); + _ButtonSound_SFXOn->setActiveState(GLOBALS._bCfgSFX); } } @@ -789,71 +789,71 @@ void RMOptionScreen::closeState(void) { } if (_nState == MENUGAME) { - GLOBALS.bCfgInvLocked = _ButtonGame_Lock->isActive(); + GLOBALS._bCfgInvLocked = _ButtonGame_Lock->isActive(); delete _ButtonGame_Lock; _ButtonGame_Lock = NULL; - GLOBALS.bCfgTimerizedText = !_ButtonGame_TimerizedText->isActive(); + GLOBALS._bCfgTimerizedText = !_ButtonGame_TimerizedText->isActive(); delete _ButtonGame_TimerizedText; _ButtonGame_TimerizedText = NULL; - GLOBALS.bCfgInvNoScroll = _ButtonGame_Scrolling->isActive(); + GLOBALS._bCfgInvNoScroll = _ButtonGame_Scrolling->isActive(); delete _ButtonGame_Scrolling; _ButtonGame_Scrolling = NULL; - GLOBALS.bCfgInvUp = _ButtonGame_InterUp->isActive(); + GLOBALS._bCfgInvUp = _ButtonGame_InterUp->isActive(); delete _ButtonGame_InterUp; _ButtonGame_InterUp = NULL; - GLOBALS.nCfgTextSpeed = _SlideTextSpeed->getValue(); + GLOBALS._nCfgTextSpeed = _SlideTextSpeed->getValue(); delete _SlideTextSpeed; _SlideTextSpeed = NULL; - GLOBALS.nCfgTonySpeed = _SlideTonySpeed->getValue(); + GLOBALS._nCfgTonySpeed = _SlideTonySpeed->getValue(); delete _SlideTonySpeed; _SlideTonySpeed = NULL; } else if (_nState == MENUGFX) { - GLOBALS.bCfgAnni30 = _ButtonGfx_Anni30->isActive(); + GLOBALS._bCfgAnni30 = _ButtonGfx_Anni30->isActive(); delete _ButtonGfx_Anni30; _ButtonGfx_Anni30 = NULL; - GLOBALS.bCfgAntiAlias = !_ButtonGfx_AntiAlias->isActive(); + GLOBALS._bCfgAntiAlias = !_ButtonGfx_AntiAlias->isActive(); delete _ButtonGfx_AntiAlias; _ButtonGfx_AntiAlias = NULL; - GLOBALS.bCfgSottotitoli = !_ButtonGfx_Sottotitoli->isActive(); + GLOBALS._bCfgSottotitoli = !_ButtonGfx_Sottotitoli->isActive(); delete _ButtonGfx_Sottotitoli; _ButtonGfx_Sottotitoli = NULL; - GLOBALS.bCfgInterTips = _ButtonGfx_Tips->isActive(); + GLOBALS._bCfgInterTips = _ButtonGfx_Tips->isActive(); delete _ButtonGfx_Tips; _ButtonGfx_Tips = NULL; - GLOBALS.bCfgTransparence = !_ButtonGfx_Trans->isActive(); + GLOBALS._bCfgTransparence = !_ButtonGfx_Trans->isActive(); delete _ButtonGfx_Trans; _ButtonGfx_Trans = NULL; } else if (_nState == MENUSOUND) { - GLOBALS.nCfgDubbingVolume = _SliderSound_Dubbing->getValue(); + GLOBALS._nCfgDubbingVolume = _SliderSound_Dubbing->getValue(); delete _SliderSound_Dubbing; _SliderSound_Dubbing = NULL; - GLOBALS.nCfgMusicVolume = _SliderSound_Music->getValue(); + GLOBALS._nCfgMusicVolume = _SliderSound_Music->getValue(); delete _SliderSound_Music; _SliderSound_Music = NULL; - GLOBALS.nCfgSFXVolume = _SliderSound_SFX->getValue(); + GLOBALS._nCfgSFXVolume = _SliderSound_SFX->getValue(); delete _SliderSound_SFX; _SliderSound_SFX = NULL; - GLOBALS.bCfgDubbing = _ButtonSound_DubbingOn->isActive(); + GLOBALS._bCfgDubbing = _ButtonSound_DubbingOn->isActive(); delete _ButtonSound_DubbingOn; _ButtonSound_DubbingOn = NULL; - GLOBALS.bCfgMusic = _ButtonSound_MusicOn->isActive(); + GLOBALS._bCfgMusic = _ButtonSound_MusicOn->isActive(); delete _ButtonSound_MusicOn; _ButtonSound_MusicOn = NULL; - GLOBALS.bCfgSFX = _ButtonSound_SFXOn->isActive(); + GLOBALS._bCfgSFX = _ButtonSound_SFXOn->isActive(); delete _ButtonSound_SFXOn; _ButtonSound_SFXOn = NULL; } @@ -1246,19 +1246,19 @@ void RMOptionScreen::doFrame(CORO_PARAM, RMInput *input) { if (_nState == MENUGFX) { // These options take effect immediately if (_ButtonGfx_Anni30->isActive()) - GLOBALS.bCfgAnni30 = true; + GLOBALS._bCfgAnni30 = true; else - GLOBALS.bCfgAnni30 = false; + GLOBALS._bCfgAnni30 = false; if (_ButtonGfx_AntiAlias->isActive()) - GLOBALS.bCfgAntiAlias = false; + GLOBALS._bCfgAntiAlias = false; else - GLOBALS.bCfgAntiAlias = true; + GLOBALS._bCfgAntiAlias = true; if (_ButtonGfx_Trans->isActive()) - GLOBALS.bCfgTransparence = false; + GLOBALS._bCfgTransparence = false; else - GLOBALS.bCfgTransparence = true; + GLOBALS._bCfgTransparence = true; } } } diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 09b102db11..fdc435e3e9 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -1390,7 +1390,7 @@ void RMGfxSourceBuffer8RLEWordAB::RLEDecompressLine(uint16 *dst, byte *src, int int i, n; int r, g, b, r2, g2, b2; - if (!GLOBALS.bCfgTransparence) { + if (!GLOBALS._bCfgTransparence) { RMGfxSourceBuffer8RLEWord::RLEDecompressLine(dst, src, nStartSkip, nLength); return; } @@ -1751,7 +1751,7 @@ void RMGfxSourceBuffer8RLEByteAA::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RM CORO_BEGIN_CODE(_ctx); CORO_INVOKE_2(RMGfxSourceBuffer8RLE::draw, bigBuf, prim); - if (GLOBALS.bCfgAntiAlias) + if (GLOBALS._bCfgAntiAlias) drawAA(bigBuf, prim); CORO_END_CODE; @@ -1789,7 +1789,7 @@ void RMGfxSourceBuffer8RLEWordAA::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RM CORO_BEGIN_CODE(_ctx); CORO_INVOKE_2(RMGfxSourceBuffer8RLE::draw, bigBuf, prim); - if (GLOBALS.bCfgAntiAlias) + if (GLOBALS._bCfgAntiAlias) drawAA(bigBuf, prim); CORO_END_CODE; diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index e61e6a8b84..801b4d35fb 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -49,12 +49,12 @@ void ExitAllIdles(CORO_PARAM, const void *param) { CORO_BEGIN_CODE(_ctx); // Closes idle - GLOBALS.bSkipSfxNoLoop = true; + GLOBALS._bSkipSfxNoLoop = true; CORO_INVOKE_2(mpalEndIdlePoll, nCurLoc, NULL); - GLOBALS.bIdleExited = true; - GLOBALS.bSkipSfxNoLoop = false; + GLOBALS._bIdleExited = true; + GLOBALS._bSkipSfxNoLoop = false; CORO_END_CODE; } @@ -124,11 +124,11 @@ void RMGfxEngine::openOptionScreen(CORO_PARAM, int type) { // Exists the IDLE to avoid premature death in loading _bMustEnterMenu = true; if (type == 1 || type == 2) { - GLOBALS.bIdleExited = true; + GLOBALS._bIdleExited = true; } else { CORO_INVOKE_0(_tony.stopNoAction); - GLOBALS.bIdleExited = false; + GLOBALS._bIdleExited = false; CoroScheduler.createProcess(ExitAllIdles, &_nCurLoc, sizeof(int)); } @@ -148,10 +148,10 @@ void RMGfxEngine::doFrame(CORO_PARAM, bool bDrawLocation) { // Poll of input devices _input.poll(); - if (_bMustEnterMenu && GLOBALS.bIdleExited) { + if (_bMustEnterMenu && GLOBALS._bIdleExited) { _bOption = true; _bMustEnterMenu = false; - GLOBALS.bIdleExited = false; + GLOBALS._bIdleExited = false; } if (_bOption) { @@ -365,10 +365,10 @@ void RMGfxEngine::itemIrq(uint32 dwItem, int nPattern, int nStatus) { item = GLOBALS.GfxEngine->_loc.getItemFromCode(dwItem); if (item != NULL) { if (nPattern != -1) { - if (GLOBALS.bPatIrqFreeze) + if (GLOBALS._bPatIrqFreeze) mainFreeze(); item->setPattern(nPattern, true); - if (GLOBALS.bPatIrqFreeze) + if (GLOBALS._bPatIrqFreeze) mainUnfreeze(); } if (nStatus != -1) @@ -479,16 +479,16 @@ void RMGfxEngine::init() { _vm->_window.getNewFrame(*this, NULL); _vm->_window.repaint(); - GLOBALS.bPatIrqFreeze = true; + GLOBALS._bPatIrqFreeze = true; // Activate GUI _bGUIOption = true; _bGUIInterface = true; _bGUIInventory = true; - GLOBALS.bSkipSfxNoLoop = false; + GLOBALS._bSkipSfxNoLoop = false; _bMustEnterMenu = false; - GLOBALS.bIdleExited = false; + GLOBALS._bIdleExited = false; _bOption = false; _bWiping = false; _hWipeEvent = CoroScheduler.createEvent(false, false); @@ -652,23 +652,23 @@ void RMGfxEngine::saveState(const Common::String &fn, byte *curThumb, const Comm CharsSaveAll(f); // Save the options - f->writeByte(GLOBALS.bCfgInvLocked); - f->writeByte(GLOBALS.bCfgInvNoScroll); - f->writeByte(GLOBALS.bCfgTimerizedText); - f->writeByte(GLOBALS.bCfgInvUp); - f->writeByte(GLOBALS.bCfgAnni30); - f->writeByte(GLOBALS.bCfgAntiAlias); - f->writeByte(GLOBALS.bCfgSottotitoli); - f->writeByte(GLOBALS.bCfgTransparence); - f->writeByte(GLOBALS.bCfgInterTips); - f->writeByte(GLOBALS.bCfgDubbing); - f->writeByte(GLOBALS.bCfgMusic); - f->writeByte(GLOBALS.bCfgSFX); - f->writeByte(GLOBALS.nCfgTonySpeed); - f->writeByte(GLOBALS.nCfgTextSpeed); - f->writeByte(GLOBALS.nCfgDubbingVolume); - f->writeByte(GLOBALS.nCfgMusicVolume); - f->writeByte(GLOBALS.nCfgSFXVolume); + f->writeByte(GLOBALS._bCfgInvLocked); + f->writeByte(GLOBALS._bCfgInvNoScroll); + f->writeByte(GLOBALS._bCfgTimerizedText); + f->writeByte(GLOBALS._bCfgInvUp); + f->writeByte(GLOBALS._bCfgAnni30); + f->writeByte(GLOBALS._bCfgAntiAlias); + f->writeByte(GLOBALS._bCfgSottotitoli); + f->writeByte(GLOBALS._bCfgTransparence); + f->writeByte(GLOBALS._bCfgInterTips); + f->writeByte(GLOBALS._bCfgDubbing); + f->writeByte(GLOBALS._bCfgMusic); + f->writeByte(GLOBALS._bCfgSFX); + f->writeByte(GLOBALS._nCfgTonySpeed); + f->writeByte(GLOBALS._nCfgTextSpeed); + f->writeByte(GLOBALS._nCfgDubbingVolume); + f->writeByte(GLOBALS._nCfgMusicVolume); + f->writeByte(GLOBALS._nCfgSFXVolume); // Save the hotspots SaveChangedHotspot(f); @@ -788,23 +788,23 @@ void RMGfxEngine::loadState(CORO_PARAM, const Common::String &fn) { if (_ctx->ver >= 6) { // Load options - GLOBALS.bCfgInvLocked = _ctx->f->readByte(); - GLOBALS.bCfgInvNoScroll = _ctx->f->readByte(); - GLOBALS.bCfgTimerizedText = _ctx->f->readByte(); - GLOBALS.bCfgInvUp = _ctx->f->readByte(); - GLOBALS.bCfgAnni30 = _ctx->f->readByte(); - GLOBALS.bCfgAntiAlias = _ctx->f->readByte(); - GLOBALS.bCfgSottotitoli = _ctx->f->readByte(); - GLOBALS.bCfgTransparence = _ctx->f->readByte(); - GLOBALS.bCfgInterTips = _ctx->f->readByte(); - GLOBALS.bCfgDubbing = _ctx->f->readByte(); - GLOBALS.bCfgMusic = _ctx->f->readByte(); - GLOBALS.bCfgSFX = _ctx->f->readByte(); - GLOBALS.nCfgTonySpeed = _ctx->f->readByte(); - GLOBALS.nCfgTextSpeed = _ctx->f->readByte(); - GLOBALS.nCfgDubbingVolume = _ctx->f->readByte(); - GLOBALS.nCfgMusicVolume = _ctx->f->readByte(); - GLOBALS.nCfgSFXVolume = _ctx->f->readByte(); + GLOBALS._bCfgInvLocked = _ctx->f->readByte(); + GLOBALS._bCfgInvNoScroll = _ctx->f->readByte(); + GLOBALS._bCfgTimerizedText = _ctx->f->readByte(); + GLOBALS._bCfgInvUp = _ctx->f->readByte(); + GLOBALS._bCfgAnni30 = _ctx->f->readByte(); + GLOBALS._bCfgAntiAlias = _ctx->f->readByte(); + GLOBALS._bCfgSottotitoli = _ctx->f->readByte(); + GLOBALS._bCfgTransparence = _ctx->f->readByte(); + GLOBALS._bCfgInterTips = _ctx->f->readByte(); + GLOBALS._bCfgDubbing = _ctx->f->readByte(); + GLOBALS._bCfgMusic = _ctx->f->readByte(); + GLOBALS._bCfgSFX = _ctx->f->readByte(); + GLOBALS._nCfgTonySpeed = _ctx->f->readByte(); + GLOBALS._nCfgTextSpeed = _ctx->f->readByte(); + GLOBALS._nCfgDubbingVolume = _ctx->f->readByte(); + GLOBALS._nCfgMusicVolume = _ctx->f->readByte(); + GLOBALS._nCfgSFXVolume = _ctx->f->readByte(); // Load hotspots LoadChangedHotspot(_ctx->f); diff --git a/engines/tony/globals.cpp b/engines/tony/globals.cpp index 37a5a20454..6f81e81a48 100644 --- a/engines/tony/globals.cpp +++ b/engines/tony/globals.cpp @@ -59,31 +59,31 @@ Globals::Globals() { dwTonyNumTexts = 0; bTonyInTexts = false; bStaticTalk = false; - bPatIrqFreeze = false; - bCfgInvLocked = false; - bCfgInvNoScroll = false; - bCfgTimerizedText = false; - bCfgInvUp = false; - bCfgAnni30 = false; - bCfgAntiAlias = false; - bCfgSottotitoli = false; - bCfgTransparence = false; - bCfgInterTips = false; - bCfgDubbing = false; - bCfgMusic = false; - bCfgSFX = false; + _bPatIrqFreeze = false; + _bCfgInvLocked = false; + _bCfgInvNoScroll = false; + _bCfgTimerizedText = false; + _bCfgInvUp = false; + _bCfgAnni30 = false; + _bCfgAntiAlias = false; + _bCfgSottotitoli = false; + _bCfgTransparence = false; + _bCfgInterTips = false; + _bCfgDubbing = false; + _bCfgMusic = false; + _bCfgSFX = false; _bAlwaysDisplay = false; - nCfgTonySpeed = 0; - nCfgTextSpeed = 0; - nCfgDubbingVolume = 0; - nCfgMusicVolume = 0; - nCfgSFXVolume = 0; - bIdleExited = false; - bSkipSfxNoLoop = false; - bNoOcchioDiBue = false; - curDialog = 0; - curSonoriz = 0; - bFadeOutStop = false; + _nCfgTonySpeed = 0; + _nCfgTextSpeed = 0; + _nCfgDubbingVolume = 0; + _nCfgMusicVolume = 0; + _nCfgSFXVolume = 0; + _bIdleExited = false; + _bSkipSfxNoLoop = false; + _bNoOcchioDiBue = false; + _curDialog = 0; + _curSonoriz = 0; + _bFadeOutStop = false; // OSystem::MutexRef vdb; Common::fill(&mut[0], &mut[10], 0); diff --git a/engines/tony/globals.h b/engines/tony/globals.h index 84c5d7398c..a675066bc1 100644 --- a/engines/tony/globals.h +++ b/engines/tony/globals.h @@ -187,30 +187,30 @@ public: RMTextDialog *_curBackText; bool _bTonyIsSpeaking; int _curChangedHotspot; - bool bPatIrqFreeze; - bool bCfgInvLocked; - bool bCfgInvNoScroll; - bool bCfgTimerizedText; - bool bCfgInvUp; - bool bCfgAnni30; - bool bCfgAntiAlias; - bool bCfgSottotitoli; - bool bCfgTransparence; - bool bCfgInterTips; - bool bCfgDubbing; - bool bCfgMusic; - bool bCfgSFX; - int nCfgTonySpeed; - int nCfgTextSpeed; - int nCfgDubbingVolume; - int nCfgMusicVolume; - int nCfgSFXVolume; - bool bSkipSfxNoLoop; - bool bIdleExited; - bool bNoOcchioDiBue; - int curDialog; - int curSonoriz; - bool bFadeOutStop; + bool _bPatIrqFreeze; + bool _bCfgInvLocked; + bool _bCfgInvNoScroll; + bool _bCfgTimerizedText; + bool _bCfgInvUp; + bool _bCfgAnni30; + bool _bCfgAntiAlias; + bool _bCfgSottotitoli; + bool _bCfgTransparence; + bool _bCfgInterTips; + bool _bCfgDubbing; + bool _bCfgMusic; + bool _bCfgSFX; + int _nCfgTonySpeed; + int _nCfgTextSpeed; + int _nCfgDubbingVolume; + int _nCfgMusicVolume; + int _nCfgSFXVolume; + bool _bSkipSfxNoLoop; + bool _bIdleExited; + bool _bNoOcchioDiBue; + int _curDialog; + int _curSonoriz; + bool _bFadeOutStop; RMTony *Tony; RMPointer *Pointer; diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index bbc74afa01..162443d0bd 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -65,7 +65,7 @@ RMInventory::~RMInventory() { } bool RMInventory::checkPointInside(const RMPoint &pt) { - if (!GLOBALS.bCfgInvUp) + if (!GLOBALS._bCfgInvUp) return pt.y > RM_SY - 70; else return pt.y < 70; @@ -201,7 +201,7 @@ void RMInventory::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr if (_state == SELECTING) { - if (!GLOBALS.bCfgInvUp) { + if (!GLOBALS._bCfgInvUp) { _ctx->pos.set((_nSelectObj + 1) * 64 - 20, RM_SY - 113); _ctx->pos2.set((_nSelectObj + 1) * 64 + 34, RM_SY - 150); } else { @@ -215,7 +215,7 @@ void RMInventory::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr // Draw the mini interface CORO_INVOKE_2(miniInterface.draw, bigBuf, _ctx->p); - if (GLOBALS.bCfgInterTips) { + if (GLOBALS._bCfgInterTips) { if (miniAction == 1) // Examine CORO_INVOKE_2(_hints[0].draw, bigBuf, _ctx->p2); else if (miniAction == 2) // Talk @@ -531,7 +531,7 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo } if (_vm->getEngine()->getInput().getAsyncKeyState(Common::KEYCODE_i)) { - GLOBALS.bCfgInvLocked = !GLOBALS.bCfgInvLocked; + GLOBALS._bCfgInvLocked = !GLOBALS._bCfgInvLocked; } if (_bCombining) {//m_state == COMBINING) @@ -539,9 +539,9 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo ptr.setSpecialPointer(RMPointer::PTR_CUSTOM); } - if (!GLOBALS.bCfgInvUp) { - if ((_state == CLOSED) && (mpos.y > RM_SY - 10 || GLOBALS.bCfgInvLocked) && bCanOpen) { - if (!GLOBALS.bCfgInvNoScroll) { + if (!GLOBALS._bCfgInvUp) { + if ((_state == CLOSED) && (mpos.y > RM_SY - 10 || GLOBALS._bCfgInvLocked) && bCanOpen) { + if (!GLOBALS._bCfgInvNoScroll) { _state = OPENING; _curPutY = RM_SY - 1; _curPutTime = _vm->getTime(); @@ -550,8 +550,8 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo _curPutY = RM_SY - 68; } } else if (_state == OPENED) { - if ((mpos.y < RM_SY - 70 && !GLOBALS.bCfgInvLocked) || !bCanOpen) { - if (!GLOBALS.bCfgInvNoScroll) { + if ((mpos.y < RM_SY - 70 && !GLOBALS._bCfgInvLocked) || !bCanOpen) { + if (!GLOBALS._bCfgInvNoScroll) { _state = CLOSING; _curPutY = RM_SY - 68; _curPutTime = _vm->getTime(); @@ -580,8 +580,8 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo _state = CLOSED; } } else { - if ((_state == CLOSED) && (mpos.y < 10 || GLOBALS.bCfgInvLocked) && bCanOpen) { - if (!GLOBALS.bCfgInvNoScroll) { + if ((_state == CLOSED) && (mpos.y < 10 || GLOBALS._bCfgInvLocked) && bCanOpen) { + if (!GLOBALS._bCfgInvNoScroll) { _state = OPENING; _curPutY = - 68; _curPutTime = _vm->getTime(); @@ -590,8 +590,8 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo _curPutY = 0; } } else if (_state == OPENED) { - if ((mpos.y > 70 && !GLOBALS.bCfgInvLocked) || !bCanOpen) { - if (!GLOBALS.bCfgInvNoScroll) { + if ((mpos.y > 70 && !GLOBALS._bCfgInvLocked) || !bCanOpen) { + if (!GLOBALS._bCfgInvNoScroll) { _state = CLOSING; _curPutY = -2; _curPutTime = _vm->getTime(); @@ -624,7 +624,7 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo int startx = (_nSelectObj + 1) * 64 - 20; int starty; - if (!GLOBALS.bCfgInvUp) + if (!GLOBALS._bCfgInvUp) starty = RM_SY - 109; else starty = 70; @@ -802,7 +802,7 @@ void RMInterface::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr _vm->playUtilSFX(1); } - if (GLOBALS.bCfgInterTips) { + if (GLOBALS._bCfgInterTips) { prim->getDst().topLeft() = _openStart + RMPoint(70, 177); CORO_INVOKE_2(_hints[_ctx->h].draw, bigBuf, prim); } diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index afde5403b5..146ca65533 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -146,7 +146,7 @@ void RMPattern::stopSfx(RMSfx *sfx) { if (_slots[i]._type == SOUND) { if (sfx[_slots[i]._data]._name[0] == '_') sfx[_slots[i]._data].stop(); - else if (GLOBALS.bSkipSfxNoLoop) + else if (GLOBALS._bSkipSfxNoLoop) sfx[_slots[i]._data].stop(); } } diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index 93b5e90706..6d9eaf350b 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -1492,15 +1492,15 @@ void FPSFX::SetVolume(int dwVolume) { lastVolume = dwVolume; if (bIsVoice) { - if (!GLOBALS.bCfgDubbing) dwVolume = 0; + if (!GLOBALS._bCfgDubbing) dwVolume = 0; else { - dwVolume -= (10 - GLOBALS.nCfgDubbingVolume) * 2; + dwVolume -= (10 - GLOBALS._nCfgDubbingVolume) * 2; if (dwVolume < 0) dwVolume = 0; } } else { - if (!GLOBALS.bCfgSFX) dwVolume = 0; + if (!GLOBALS._bCfgSFX) dwVolume = 0; else { - dwVolume -= (10 - GLOBALS.nCfgSFXVolume) * 2; + dwVolume -= (10 - GLOBALS._nCfgSFXVolume) * 2; if (dwVolume < 0) dwVolume = 0; } } diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 7f7930c5d7..eab52c6b4b 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -153,23 +153,23 @@ Common::ErrorCode TonyEngine::init() { _curThumbnail = new uint16[160 * 120]; // Set up global defaults - GLOBALS.bCfgInvLocked = false; - GLOBALS.bCfgInvNoScroll = false; - GLOBALS.bCfgTimerizedText = true; - GLOBALS.bCfgInvUp = false; - GLOBALS.bCfgAnni30 = false; - GLOBALS.bCfgAntiAlias = false; - GLOBALS.bCfgTransparence = true; - GLOBALS.bCfgInterTips = true; - GLOBALS.bCfgSottotitoli = true; - GLOBALS.nCfgTonySpeed = 3; - GLOBALS.nCfgTextSpeed = 5; - GLOBALS.bCfgDubbing = true; - GLOBALS.bCfgMusic = true; - GLOBALS.bCfgSFX = true; - GLOBALS.nCfgDubbingVolume = 10; - GLOBALS.nCfgMusicVolume = 7; - GLOBALS.nCfgSFXVolume = 10; + GLOBALS._bCfgInvLocked = false; + GLOBALS._bCfgInvNoScroll = false; + GLOBALS._bCfgTimerizedText = true; + GLOBALS._bCfgInvUp = false; + GLOBALS._bCfgAnni30 = false; + GLOBALS._bCfgAntiAlias = false; + GLOBALS._bCfgTransparence = true; + GLOBALS._bCfgInterTips = true; + GLOBALS._bCfgSottotitoli = true; + GLOBALS._nCfgTonySpeed = 3; + GLOBALS._nCfgTextSpeed = 5; + GLOBALS._bCfgDubbing = true; + GLOBALS._bCfgMusic = true; + GLOBALS._bCfgSFX = true; + GLOBALS._nCfgDubbingVolume = 10; + GLOBALS._nCfgMusicVolume = 7; + GLOBALS._nCfgSFXVolume = 10; _bQuitNow = false; return Common::kNoError; diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index 9f34276c41..a63d2d69c3 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -138,7 +138,7 @@ void RMTony::doFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int curLoc) { if (!_nInList && _bShow) bigBuf->addPrim(new RMGfxPrimitive(this)); - setSpeed(GLOBALS.nCfgTonySpeed); + setSpeed(GLOBALS._nCfgTonySpeed); // Runs the normal character movement _ctx->time = _vm->getTime(); -- cgit v1.2.3 From dd8b4b519a2a61e010d9aa4d71b5f123dfeffc6b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 9 Jun 2012 10:44:51 +1000 Subject: TONY: Added more freeing of MPC data when the game ends --- engines/tony/mpal/loadmpc.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index aa048c0b2f..e222891170 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -690,7 +690,7 @@ bool ParseMpc(const byte *lpBuf) { */ static void freeDialog(LPMPALDIALOG lpmdDialog) { // Free the periods - int i; + int i, j; for (i = 0; i < MAX_PERIODS_PER_DIALOG && (lpmdDialog->_periods[i]); ++i) globalFree(lpmdDialog->_periods[i]); @@ -702,6 +702,14 @@ static void freeDialog(LPMPALDIALOG lpmdDialog) { freeExpression(lpmdDialog->_command[i].expr); } } + + // Free the choices + for (i = 0; i < MAX_CHOICES_PER_DIALOG; ++i) { + for (j = 0; j < MAX_SELECTS_PER_CHOICE; j++) { + if (lpmdDialog->_choice[i]._select[j].when) + freeExpression(lpmdDialog->_choice[i]._select[j].when); + } + } } /** -- cgit v1.2.3 From 5e062ce86c87c0253fc237c6c26ed9d9293ef571 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 9 Jun 2012 11:57:07 +1000 Subject: TONY: Properly free items during loading when there is duplicates --- engines/tony/mpal/loadmpc.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'engines') diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index e222891170..bb2c999984 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -421,6 +421,16 @@ static const byte *parseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { for (kk = 0; kk < curCmd; kk++) { if (compareCommands(&lpmiItem->_command[kk], &lpmiItem->_command[curCmd])) { lpmiItem->Action[i].CmdNum[j] = kk; + + // Free any data allocated for the duplictaed command + if (lpmiItem->_command[curCmd].type == 2) { + globalDestroy(lpmiItem->_command[curCmd].lpszVarName); + freeExpression(lpmiItem->_command[curCmd].expr); + + lpmiItem->_command[curCmd].lpszVarName = NULL; + lpmiItem->_command[curCmd].expr = 0; + lpmiItem->_command[curCmd].type = 0; + } break; } } -- cgit v1.2.3 From 8d6f50463ee0541e2d4609f80443537adefdd35e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 9 Jun 2012 12:29:34 +1000 Subject: TONY: Properly free dialog commands during loading when there is duplicates --- engines/tony/mpal/loadmpc.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'engines') diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index bb2c999984..d0b6a75f72 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -238,6 +238,16 @@ static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { for (kk = 0;kk < curCmd; kk++) { if (compareCommands(&lpmdDialog->_command[kk], &lpmdDialog->_command[curCmd])) { lpmdDialog->_group[i].CmdNum[j] = kk; + + // Free any data allocated for the duplictaed command + if (lpmdDialog->_command[curCmd].type == 2) { + globalDestroy(lpmdDialog->_command[curCmd].lpszVarName); + freeExpression(lpmdDialog->_command[curCmd].expr); + + lpmdDialog->_command[curCmd].lpszVarName = NULL; + lpmdDialog->_command[curCmd].expr = 0; + lpmdDialog->_command[curCmd].type = 0; + } break; } } -- cgit v1.2.3 From a50b1f32c1de667cd2d73535b07e62b000cf4483 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 9 Jun 2012 13:05:48 +1000 Subject: TONY: Fixes for deallocating MPC and MPAL data --- engines/tony/mpal/loadmpc.cpp | 12 +++++++++--- engines/tony/mpal/mpal.cpp | 7 +++++++ engines/tony/mpal/mpal.h | 4 ++++ engines/tony/tony.cpp | 1 + 4 files changed, 21 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index d0b6a75f72..1f610a8d2c 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -470,11 +470,17 @@ static const byte *parseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { */ static void freeItem(LPMPALITEM lpmiItem) { // Free the actions - if (lpmiItem->Action) + if (lpmiItem->Action) { + for (int i = 0; i < lpmiItem->nActions; ++i) { + if (lpmiItem->Action[i].when != 0) + freeExpression(lpmiItem->Action[i].when); + } + globalDestroy(lpmiItem->Action); + } // Free the commands - for (int i = 0; i < MAX_COMMANDS_PER_ITEM && (lpmiItem->_command[i].type); ++i, ++lpmiItem) { + for (int i = 0; i < MAX_COMMANDS_PER_ITEM && (lpmiItem->_command[i].type); ++i) { if (lpmiItem->_command[i].type == 2) { // Variable Assign globalDestroy(lpmiItem->_command[i].lpszVarName); @@ -715,7 +721,7 @@ static void freeDialog(LPMPALDIALOG lpmdDialog) { for (i = 0; i < MAX_PERIODS_PER_DIALOG && (lpmdDialog->_periods[i]); ++i) globalFree(lpmdDialog->_periods[i]); - for (i = 0; i < MAX_COMMANDS_PER_GROUP && (lpmdDialog->_command[i].type); i++) { + for (i = 0; i < MAX_COMMANDS_PER_DIALOG && (lpmdDialog->_command[i].type); i++) { if (lpmdDialog->_command[i].type == 2) { // Variable assign globalDestroy(lpmdDialog->_command[i].lpszVarName); diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 04d562ffc9..4aac53bb8e 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -1548,6 +1548,13 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, return true; } +/** + * Frees resources allocated by the MPAL subsystem + */ +void mpalFree() { + // Free the resource list + globalDestroy(GLOBALS.lpResources); +} /** * This is a general function to communicate with the library, to request information diff --git a/engines/tony/mpal/mpal.h b/engines/tony/mpal/mpal.h index f23eaf8e4a..198083f851 100644 --- a/engines/tony/mpal/mpal.h +++ b/engines/tony/mpal/mpal.h @@ -402,6 +402,10 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; bool mpalInit(const char *lpszFileName, const char *lpszMprFileName, LPLPCUSTOMFUNCTION lplpcfArray, Common::String *lpcfStrings); +/** + * Frees resources allocated by the MPAL subsystem + */ +void mpalFree(); /** * This is a general function to communicate with the library, to request information diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index eab52c6b4b..a66e7b0684 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -573,6 +573,7 @@ void TonyEngine::close(void) { _theBoxes.close(); _theEngine.close(); _window.close(); + mpalFree(); FreeMpc(); delete[] _curThumbnail; } -- cgit v1.2.3 From 10621fded8eee2da03a2a9f93bfa1546bcb7c748 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 9 Jun 2012 17:51:58 +1000 Subject: TONY: Fix some calls from globalFree to globalDestroy --- engines/tony/custom.cpp | 2 +- engines/tony/mpal/mpal.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 7482ac0db8..858479ca7f 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -1949,7 +1949,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg delete _ctx->text; } - globalFree(_ctx->string); + globalDestroy(_ctx->string); CORO_END_CODE; } diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 4aac53bb8e..9f9a4c203b 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -911,7 +911,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { unlockItems(); /* We don't need the item list anymore */ - globalFree(_ctx->il); + globalDestroy(_ctx->il); /* Here's the main loop */ @@ -2108,7 +2108,7 @@ int mpalLoadState(byte *buf) { GLOBALS.nVars = READ_LE_UINT32(buf); - GLOBALS.hVars = globalAlloc(GMEM_ZEROINIT | GMEM_MOVEABLE, GLOBALS.nVars * sizeof(MPALVAR)); + GLOBALS.hVars = globalAllocate(GMEM_ZEROINIT | GMEM_MOVEABLE, GLOBALS.nVars * sizeof(MPALVAR)); lockVar(); copyMemory((byte *)GLOBALS.lpmvVars, buf + 4, GLOBALS.nVars * sizeof(MPALVAR)); unlockVar(); -- cgit v1.2.3 From da39f4d758f0952e207665244023d2f3f91c6c6e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 9 Jun 2012 17:52:42 +1000 Subject: TONY: Fix the dialogs displayed for the different function keys --- engines/tony/gfxengine.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 801b4d35fb..4bfdc1333f 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -216,10 +216,10 @@ void RMGfxEngine::doFrame(CORO_PARAM, bool bDrawLocation) { else if (!_vm->getIsDemo()) { if (_input.getAsyncKeyState(Common::KEYCODE_F3) || _input.getAsyncKeyState(Common::KEYCODE_F5)) // Save game screen - CORO_INVOKE_1(openOptionScreen, 3); + CORO_INVOKE_1(openOptionScreen, 4); else if (_input.getAsyncKeyState(Common::KEYCODE_F2) || _input.getAsyncKeyState(Common::KEYCODE_F7)) // Load game screen - CORO_INVOKE_1(openOptionScreen, 4); + CORO_INVOKE_1(openOptionScreen, 3); } } } -- cgit v1.2.3 From 7758b1a432fcd31e5e608cb7720225f7a0cc633c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 9 Jun 2012 22:14:38 +1000 Subject: TONY: Fix operation of TakeOwnership/ReleaseOwnership --- engines/tony/custom.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 858479ca7f..6db6d5f858 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -2043,12 +2043,25 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr */ DECLARE_CUSTOM_FUNCTION(TakeOwnership)(CORO_PARAM, uint32 num, uint32, uint32, uint32) { - CoroScheduler.waitForSingleObject(coroParam, GLOBALS.mut[num], CORO_INFINITE); + CORO_BEGIN_CONTEXT; + bool expired; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + // The event is operating as a mutex, so if the event is already set, wait until it's reset + do { + CORO_INVOKE_3(CoroScheduler.waitForSingleObject, GLOBALS.mut[num], 0, &_ctx->expired); + } while (!_ctx->expired); + + // Set the event to flag ownership + CoroScheduler.setEvent(GLOBALS.mut[num]); + + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(ReleaseOwnership)(CORO_PARAM, uint32 num, uint32, uint32, uint32) { - CoroScheduler.pulseEvent(GLOBALS.mut[num]); - warning("TODO: Validate that the use of events in TakeOwnership/ReleaseOwnership match original"); + CoroScheduler.resetEvent(GLOBALS.mut[num]); } /* -- cgit v1.2.3 From 4a3518dc92762cbcd8bda8786c975af021564b37 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 9 Jun 2012 22:20:16 +1000 Subject: TONY: Fix data freeing in LocationPollThread --- engines/tony/mpal/mpal.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 9f9a4c203b..5a4310c15b 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -866,7 +866,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { _ctx->MyThreads = (MYTHREAD *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, _ctx->nRealItems * sizeof(MYTHREAD)); if (_ctx->MyThreads == NULL) { - globalFree(_ctx->il); + globalDestroy(_ctx->il); CORO_KILL_SELF(); return; } @@ -876,8 +876,8 @@ void LocationPollThread(CORO_PARAM, const void *param) { Now we created the mirrored copies of the idle actions. */ _ctx->MyActions = (MYACTION *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, _ctx->nIdleActions * sizeof(MYACTION)); if (_ctx->MyActions == NULL) { - globalFree(_ctx->MyThreads); - globalFree(_ctx->il); + globalDestroy(_ctx->MyThreads); + globalDestroy(_ctx->il); CORO_KILL_SELF(); return; } @@ -981,8 +981,8 @@ void LocationPollThread(CORO_PARAM, const void *param) { /* Ok, we can perform the action. For convenience, we do it in a new process */ _ctx->newItem = (LPMPALITEM)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MPALITEM)); if (_ctx->newItem == false) { - globalFree(_ctx->MyThreads); - globalFree(_ctx->MyActions); + globalDestroy(_ctx->MyThreads); + globalDestroy(_ctx->MyActions); CORO_KILL_SELF(); return; @@ -1006,9 +1006,9 @@ void LocationPollThread(CORO_PARAM, const void *param) { // Create the process if ((_ctx->MyThreads[_ctx->i].hThread = CoroScheduler.createProcess(ActionThread, &_ctx->newItem, sizeof(LPMPALITEM))) == CORO_INVALID_PID_VALUE) { //if ((_ctx->MyThreads[_ctx->i].hThread = (void*)_beginthread(ActionThread, 10240,(void *)_ctx->newItem))= = (void*)-1) - globalFree(_ctx->newItem); - globalFree(_ctx->MyThreads); - globalFree(_ctx->MyActions); + globalDestroy(_ctx->newItem); + globalDestroy(_ctx->MyThreads); + globalDestroy(_ctx->MyActions); CORO_KILL_SELF(); return; @@ -1039,8 +1039,8 @@ void LocationPollThread(CORO_PARAM, const void *param) { CORO_INVOKE_4(GLOBALS.lplpFunctions[201], 0, 0, 0, 0); /* We're finished */ - globalFree(_ctx->MyThreads); - globalFree(_ctx->MyActions); + globalDestroy(_ctx->MyThreads); + globalDestroy(_ctx->MyActions); CORO_KILL_SELF(); -- cgit v1.2.3 From 060449042a532e6cd7319ea36376021d76dde470 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Sat, 9 Jun 2012 17:31:18 -0400 Subject: TONY: Silence some gcc warnings --- engines/tony/loc.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'engines') diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 146ca65533..61271d7f39 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -1226,10 +1226,10 @@ short RMCharacter::scanLine(const RMPoint &punto) { Lcount++; if (Lstatus) { Ldx = Lspeed * Lcount; - Ldy = Lslope * Ldx; + Ldy = (int)(Lslope * Ldx); } else { Ldy = Lspeed * Lcount; - Ldx = Lslope * Ldy; + Ldx = (int)(Lslope * Ldy); } Lscan.x = Lstart.x + Ldx; @@ -1285,10 +1285,10 @@ RMPoint RMCharacter::invScanLine(const RMPoint &punto) { Lcount++; if (Lstatus) { Ldx = Lspeed * Lcount; - Ldy = Lslope * Ldx; + Ldy = (int)(Lslope * Ldx); } else { Ldy = Lspeed * Lcount; - Ldx = Lslope * Ldy; + Ldx = (int)(Lslope * Ldy); } Lscan.x = Lstart.x + Ldx; Lscan.y = Lstart.y + Ldy; @@ -1402,7 +1402,7 @@ void RMCharacter::doFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc) { // If we are going horizontally if (walkstatus == 1) { dx = walkspeed * walkcount; - dy = slope * dx; + dy = (int)(slope * dx); _pos.x = linestart.x + dx; _pos.y = linestart.y + dy; @@ -1417,7 +1417,7 @@ void RMCharacter::doFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc) { // If we are going vertical if (walkstatus == 0) { dy = walkspeed * walkcount; - dx = slope * dy; + dx = (int)(slope * dy); _pos.x = linestart.x + dx; _pos.y = linestart.y + dy; -- cgit v1.2.3 From 9b3df4de21d96324a2b9fcf8a16bf133188afccd Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Sat, 9 Jun 2012 18:09:54 -0400 Subject: TONY: Rework the way wave files are loaded We'll let our own sound code take care of the RIFF header --- engines/tony/loc.cpp | 24 ++++++------------------ engines/tony/sound.cpp | 10 ++++------ engines/tony/sound.h | 5 ++--- engines/tony/tony.cpp | 4 ++-- engines/tony/tony.h | 2 +- 5 files changed, 15 insertions(+), 30 deletions(-) (limited to 'engines') diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 61271d7f39..ac238193e0 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -26,6 +26,7 @@ * Copyright (c) 1997-2003 Nayma Software */ +#include "common/memstream.h" #include "common/scummsys.h" #include "tony/mpal/mpalutils.h" #include "tony/adv.h" @@ -394,34 +395,21 @@ RMDataStream &operator>>(RMDataStream &ds, RMSfx &sfx) { } void RMSfx::readFromStream(RMDataStream &ds, bool bLOX) { - char id[4]; int size; - byte *raw; // sfx name ds >> _name; ds >> size; - // Upload the sound effect identifier from the buffer - ds.read(id, 4); - - // Ensure it's a RIFF - assert(id[0] == 'R' && id[1] == 'I' && id[2] == 'F' && id[3] == 'F'); - - // Read the size - ds >> size; - - // Read the raw WAV data - raw = new byte[size]; - ds.read(raw, size); + // Read the entire buffer into a MemoryReadStream + byte *buffer = (byte *)malloc(size); + ds.read(buffer, size); + Common::SeekableReadStream *stream = new Common::MemoryReadStream(buffer, size, DisposeAfterUse::YES); // Create the sound effect - _fx = _vm->createSFX(raw); + _fx = _vm->createSFX(stream); _fx->SetLoop(false); - - // Close the read buffer which is no longer needed - delete[] raw; } RMSfx::RMSfx() { diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index 6d9eaf350b..df633e3be2 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -1062,7 +1062,7 @@ void FPSFX::Release() { /****************************************************************************\ * -* Function: bool LoadFile(byte *lpBuf); +* Function: bool loadWave(Common::SeekableReadStream *stream); * * Description: Apre un file di effetto sonoro e lo carica. * @@ -1074,7 +1074,7 @@ void FPSFX::Release() { * \****************************************************************************/ -bool FPSFX::LoadFile(byte *lpBuf, uint32 dwCodec) { +bool FPSFX::loadWave(Common::SeekableReadStream *stream) { #ifdef REFACTOR_ME static PCMWAVEFORMAT pcmwf; static DSBUFFERDESC dsbdesc; @@ -1096,10 +1096,6 @@ bool FPSFX::LoadFile(byte *lpBuf, uint32 dwCodec) { if (!bSoundSupported) return true; - /* Nel buffer troviamo un file WAV completo, almeno per ora */ - if (dwCodec != FPCODEC_WAV) - return false; - if (lpBuf[0] != 'W' || lpBuf[1] != 'A' || lpBuf[2] != 'V' || lpBuf[3] != 'E') return false; if (lpBuf[4] != 'f' || lpBuf[5] != 'm' || lpBuf[6] != 't' || lpBuf[7] != ' ') @@ -1158,6 +1154,8 @@ bool FPSFX::LoadFile(byte *lpBuf, uint32 dwCodec) { bFileLoaded = true; #endif + + delete stream; // Just so we don't leak it return true; } diff --git a/engines/tony/sound.h b/engines/tony/sound.h index 7defeb1149..8be1fb42f5 100644 --- a/engines/tony/sound.h +++ b/engines/tony/sound.h @@ -50,8 +50,7 @@ class CODEC; enum CODECS { FPCODEC_RAW, - FPCODEC_ADPCM, - FPCODEC_WAV + FPCODEC_ADPCM }; @@ -288,7 +287,7 @@ public: \****************************************************************************/ bool LoadFile(const char *lpszFileName, uint32 dwCodec = FPCODEC_RAW); - bool LoadFile(byte *lpBuf, uint32 dwCodec); + bool loadWave(Common::SeekableReadStream *stream); bool LoadVoiceFromVDB(Common::File &vdbFP); diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index a66e7b0684..0c0bcf331a 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -332,11 +332,11 @@ void TonyEngine::preloadSFX(int nChannel, const char *fn) { _sfx[nChannel]->LoadFile(fn, FPCODEC_ADPCM); } -FPSFX *TonyEngine::createSFX(byte *buf) { +FPSFX *TonyEngine::createSFX(Common::SeekableReadStream *stream) { FPSFX *sfx; _theSound.CreateSfx(&sfx); - sfx->LoadFile(buf, FPCODEC_WAV); + sfx->loadWave(stream); return sfx; } diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 68730fa91b..cee15d07a4 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -188,7 +188,7 @@ public: void playUtilSFX(int nSfx, int nFX = 0); void stopUtilSFX(int nSfx); - FPSFX *createSFX(byte *buf); + FPSFX *createSFX(Common::SeekableReadStream *stream); void preloadSFX(int nSfx, const char *fn); void unloadAllSFX(void); -- cgit v1.2.3 From 05340fa4ca300794d73436fd2456af9ffd8307f0 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Sat, 9 Jun 2012 18:14:18 -0400 Subject: TONY: Remove custom sound CODEC classes We already have our own raw PCM and IMA ADPCM classes that we will use --- engines/tony/sound.cpp | 685 ------------------------------------------------- 1 file changed, 685 deletions(-) (limited to 'engines') diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index df633e3be2..450384b341 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -37,693 +37,8 @@ namespace Tony { * Defines \****************************************************************************/ -/* Massimo numero di bytes da decodificare in una singola chiamata a CODEC */ -#define MAXDECODESIZE (44100 * 2 * 2) - #define RELEASE(x) {if ((x) != NULL) { (x)->Release(); x = NULL; }} -/****************************************************************************\ -***************************************************************************** -* class CODEC (ABSTRACT) -* ----------- -* Description: classe base per CODEC. -***************************************************************************** -\****************************************************************************/ - -class CODEC { -protected: - bool bEndReached; - -public: - bool bLoop; - CODEC(bool bLoop = true); - virtual ~CODEC(); - virtual uint32 Decompress(HANDLE hStream, void *lpBuf, uint32 dwSize) = 0; - virtual uint32 Decompress(Common::File &fp, void *lpBuf, uint32 dwSize) = 0; - virtual void LoopReset() = 0; - bool EndOfStream(); -}; - - -/****************************************************************************\ -***************************************************************************** -* class CODECRAW -* -------------- -* Description: CODEC di play da disco di campioni puri -***************************************************************************** -\****************************************************************************/ - -class CODECRAW : public CODEC { -public: - CODECRAW(bool bLoop = true); - virtual ~CODECRAW(); - virtual uint32 Decompress(HANDLE hStream, void *lpBuf, uint32 dwSize); - virtual uint32 Decompress(Common::File &fp, void *lpBuf, uint32 dwSize); - virtual void LoopReset(); -}; - - -/****************************************************************************\ -***************************************************************************** -* class CODECADPCM -* ---------------- -* Description: CODEC per play di compressione ADPCM -***************************************************************************** -\****************************************************************************/ - -class CODECADPCM : public CODECRAW { -protected: - byte *lpTemp; - static const int indexTable[16]; - static const int stepSizeTable[89]; - -public: - CODECADPCM(bool bLoop = true, byte *lpTempBuffer = NULL); - virtual ~CODECADPCM(); - virtual uint32 Decompress(HANDLE hStream, void *lpBuf, uint32 dwSize) = 0; - virtual uint32 Decompress(Common::File &fp, void *lpBuf, uint32 dwSize) = 0; - virtual void LoopReset() = 0; -}; - -class CODECADPCMSTEREO : public CODECADPCM { -protected: - int valpred[2], index[2]; - -public: - CODECADPCMSTEREO(bool bLoop = true, byte *lpTempBuffer = NULL); - virtual ~CODECADPCMSTEREO(); - virtual uint32 Decompress(HANDLE hStream, void *lpBuf, uint32 dwSize); - virtual uint32 Decompress(Common::File &fp, void *lpBuf, uint32 dwSize); - virtual void LoopReset(); -}; - -class CODECADPCMMONO : public CODECADPCM { -protected: - int valpred, index; - -public: - CODECADPCMMONO(bool bLoop = true, byte *lpTempBuffer = NULL); - virtual ~CODECADPCMMONO(); - virtual uint32 Decompress(HANDLE hStream, void *lpBuf, uint32 dwSize); - virtual uint32 Decompress(Common::File &fp, void *lpBuf, uint32 dwSize); - virtual void LoopReset(); -}; - -/****************************************************************************\ -* Metodi per CODEC -\****************************************************************************/ - - -/****************************************************************************\ -* -* Function: CODEC::CODEC(bool loop = true); -* -* Description: Costruttore standard. E' possibile specificare se si vuole -* attivare o disattivare il loop (che di default e' attivo). -* -* Input: bool loop true se si vuole attivare il loop, -* false per disattivarlo -* -\****************************************************************************/ - -CODEC::CODEC(bool loop) { - bLoop = loop; - bEndReached = false; -} - -CODEC::~CODEC() { - -} - -/****************************************************************************\ -* -* Function: bool CODEC::EndOfStream() -* -* Description: Informa se abbiamo raggiunto la fine dello stream -* -* Return: true se siamo arrivati alla fine, false altrimenti -* -\****************************************************************************/ - -bool CODEC::EndOfStream() { - return bEndReached; -} - - -/****************************************************************************\ -* Metodi per CODECRAW -\****************************************************************************/ - -/****************************************************************************\ -* -* Function: CODECRAW::CODECRAW(bool loop = true); -* -* Description: Costruttore standard. Richiama solamente il costruttore della -* classe astratta CODEC. -* -* Input: bool loop true se si vuole attivare il loop, -* false per disattivarlo -* -\****************************************************************************/ - -CODECRAW::CODECRAW(bool loop) : CODEC(loop) { -} - -CODECRAW::~CODECRAW() { - -} - -/****************************************************************************\ -* -* Function: CODECRAW::LoopReset(); -* -* Description: Resetta il playing prima di iniziare di nuovo il file. -* Nel caso dei file RAW non fa nulla. -* -\****************************************************************************/ - -void CODECRAW::LoopReset() { -} - -/****************************************************************************\ -* -* Function: uint32 CODECRAW::Decompress(HANDLE hStream, void *lpBuf, -* uint32 dwSize) -* -* Description: Gestisce il formato RAW: semplicemente copia dal file -* stream nel buffer. -* -* Return: Se e' stata raggiunta la fine del file, indica quale byte, -* tra quelli letti, e' l'inizio del nuovo loop. Altrimenti -* il valore non e' determinato. -* -\****************************************************************************/ - -uint32 CODECRAW::Decompress(HANDLE hStream, void *buf, uint32 dwSize) { -#if 0 - byte *lpBuf = (byte *)buf; - uint32 dwRead; - uint32 dwEOF; - - bEndReached = false; - dwEOF = 0; - ReadFile(hStream, lpBuf, dwSize, &dwRead, NULL); - - if (dwRead < dwSize) { - dwEOF = dwRead; - bEndReached = true; - - if (!bLoop) { - ZeroMemory(lpBuf + dwRead, dwSize - dwRead); - } else { - SetFilePointer(hStream, 0, NULL, FILE_BEGIN); - ReadFile(hStream, lpBuf + dwRead, dwSize - dwRead, &dwRead, NULL); - } - } - - return dwEOF; -#endif - return 0; -} - -uint32 CODECRAW::Decompress(Common::File &fp, void *buf, uint32 dwSize) { - byte *lpBuf = (byte *)buf; - uint32 dwRead; - uint32 dwEOF; - - bEndReached = false; - dwEOF = 0; - - dwRead = fp.read(lpBuf, dwSize); - - if (dwRead < dwSize) { - dwEOF = dwRead; - bEndReached = true; - - if (!bLoop) { - Common::fill(lpBuf + dwRead, lpBuf + dwRead + (dwSize - dwRead), 0); - } else { - fp.seek(0); - fp.read(lpBuf + dwRead, dwSize - dwRead); - } - } - - return dwEOF; -} - -/****************************************************************************\ -* Metodi per CODECADPCM -\****************************************************************************/ - -const int CODECADPCM::indexTable[16] = { - -1, -1, -1, -1, 2, 4, 6, 8, - -1, -1, -1, -1, 2, 4, 6, 8, -}; - -const int CODECADPCM::stepSizeTable[89] = { - 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, - 19, 21, 23, 25, 28, 31, 34, 37, 41, 45, - 50, 55, 60, 66, 73, 80, 88, 97, 107, 118, - 130, 143, 157, 173, 190, 209, 230, 253, 279, 307, - 337, 371, 408, 449, 494, 544, 598, 658, 724, 796, - 876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066, - 2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358, - 5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899, - 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767 -}; - - -/****************************************************************************\ -* -* Function: CODECADPCM::CODECADPCM() -* -* Description: Costruttore. Inizializza le tabelle e alloca la memoria -* temporanea. -* -\****************************************************************************/ - -CODECADPCM::CODECADPCM(bool loop, byte *lpTempBuffer) : CODECRAW(loop) { - /* Alloca la memoria temporanea */ - if (lpTempBuffer != NULL) { - lpTemp = lpTempBuffer; - } else { - lpTemp = (byte *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, MAXDECODESIZE); - - if (lpTemp == NULL) { - error("Insufficient memory!"); - return; - } - } -} - - -CODECADPCMMONO::CODECADPCMMONO(bool loop, byte *lpTempBuffer) : CODECADPCM(loop, lpTempBuffer) { - /* Inizializza per il playing */ - LoopReset(); -} - -CODECADPCMMONO::~CODECADPCMMONO() { -} - - -CODECADPCMSTEREO::CODECADPCMSTEREO(bool loop, byte *lpTempBuffer) : CODECADPCM(loop, lpTempBuffer) { - /* Inizializza per il playing */ - LoopReset(); -} - -CODECADPCMSTEREO::~CODECADPCMSTEREO() { - -} - -/****************************************************************************\ -* -* Function: CODECADPCM::~CODECADPCM() -* -* Description: Distruttore. Libera la memoria temporanea. -* -\****************************************************************************/ - -CODECADPCM::~CODECADPCM() { - globalFree(lpTemp); -} - - -/****************************************************************************\ -* -* Function: CODECADPCM::LoopReset() -* -* Description: Resetta il player prima di ogni play o loop. -* -\****************************************************************************/ - -void CODECADPCMSTEREO::LoopReset() { - valpred[0] = 0; - valpred[1] = 0; - index[0] = 0; - index[1] = 0; -} - -void CODECADPCMMONO::LoopReset() { - valpred = 0; - index = 0; -} - -/****************************************************************************\ -* -* Function: CODECADPCM::Decompress(HANDLE hStream, void *lpBuf, -* uint32 dwSize); -* -* Description: Gestisce il formato ADPCM 16:4. La routine dovrebbe essere -* ottimizzata in Assembler per garantire migliori performance. -* -\****************************************************************************/ - -uint32 CODECADPCMMONO::Decompress(HANDLE hFile, void *buf, uint32 dwSize) { -#if 0 - uint16 *lpBuf = (uint16 *)buf; - byte *inp; - int bufferstep; - int cache; - int delta; - int sign; - int vpdiff; - uint32 eof, i; - int step; - uint32 dwRead; - - bufferstep = 1; - step = stepSizeTable[index]; - - /* Richiama il CODEC RAW per leggere da disco lo stream con loop. La - chiamata e' possibile perche' abbiamo ereditato CODECADPCM da CODECRAW, - e non semplicemente da CODEC. */ - eof = CODECRAW::Decompress(hFile, lpTemp, dwSize / 4); - inp = lpTemp; - - eof *= 2; - /* Se bisogna loopare subito lo fa */ - if (EndOfStream() && eof == 0) { - LoopReset(); - bufferstep = 1; - step = stepSizeTable[index]; - } else if (!EndOfStream()) - eof = 0; - - dwSize /= 2; - for (i = 0; i < dwSize; i++) { - /* Controlla se siamo alla fine del file, e bisogna loopare */ - if (eof != 0 && i == eof) { - LoopReset(); - bufferstep = 1; - step = stepSizeTable[index]; - } - - /* Legge il delta (4 bit) */ - if (bufferstep) { - cache = *inp++; - delta = (cache >> 4) & 0xF; - } else - delta = cache & 0xF; - - /* Trova il nuovo indice */ - index += indexTable[delta]; - if (index < 0) index = 0; - if (index > 88) index = 88; - - /* Legge il segno e lo separa dall'ampliamento */ - sign = delta & 8; - delta = delta & 7; - - /* Trova la differenza dal valore precedente */ - vpdiff = step >> 3; - if (delta & 4) vpdiff += step; - if (delta & 2) vpdiff += step >> 1; - if (delta & 1) vpdiff += step >> 2; - - if (sign) - valpred -= vpdiff; - else - valpred += vpdiff; - - /* Controlla i limiti del valore trovato */ - if (valpred > 32767) - valpred = 32767; - else if (valpred < -32768) - valpred = -32768; - - /* Aggiorna lo step */ - step = stepSizeTable[index]; - - /* Scrive il valore trovato */ - *lpBuf++ = (signed short)valpred; - - bufferstep = !bufferstep; - } - - return eof / 2; -#endif - return 0; -} - -uint32 CODECADPCMMONO::Decompress(Common::File &fp, void *buf, uint32 dwSize) { - uint16 *lpBuf = (uint16 *)buf; - byte *inp; - int bufferstep; - int cache = 0; - int delta; - int sign; - int vpdiff; - uint32 eof, i; - int step; - - bufferstep = 1; - step = stepSizeTable[index]; - - /* Richiama il CODEC RAW per leggere da disco lo stream con loop. La - chiamata e' possibile perche' abbiamo ereditato CODECADPCM da CODECRAW, - e non semplicemente da CODEC. */ - eof = CODECRAW::Decompress(fp, lpTemp, dwSize / 4); - inp = lpTemp; - - eof *= 2; - - /* Se bisogna loopare subito lo fa */ - if (EndOfStream() && eof == 0) { - LoopReset(); - bufferstep = 1; - step = stepSizeTable[index]; - } else if (!EndOfStream()) - eof = 0; - - dwSize /= 2; - for (i = 0; i < dwSize; i++) { - /* Controlla se siamo alla fine del file, e bisogna loopare */ - if (eof != 0 && i == eof) { - LoopReset(); - bufferstep = 1; - step = stepSizeTable[index]; - } - - /* Legge il delta (4 bit) */ - if (bufferstep) { - cache = *inp++; - delta = (cache >> 4) & 0xF; - } else - delta = cache & 0xF; - - /* Trova il nuovo indice */ - index += indexTable[delta]; - if (index < 0) index = 0; - if (index > 88) index = 88; - - /* Legge il segno e lo separa dall'ampliamento */ - sign = delta & 8; - delta = delta & 7; - - /* Trova la differenza dal valore precedente */ - vpdiff = step >> 3; - if (delta & 4) vpdiff += step; - if (delta & 2) vpdiff += step >> 1; - if (delta & 1) vpdiff += step >> 2; - - if (sign) - valpred -= vpdiff; - else - valpred += vpdiff; - - /* Controlla i limiti del valore trovato */ - if (valpred > 32767) - valpred = 32767; - else if (valpred < -32768) - valpred = - 32768; - - /* Aggiorna lo step */ - step = stepSizeTable[index]; - - /* Scrive il valore trovato */ - *lpBuf ++ = (signed short)valpred; - - bufferstep = !bufferstep; - } - - return eof / 2; -} - -uint32 CODECADPCMSTEREO::Decompress(HANDLE hFile, void *buf, uint32 dwSize) { - uint16 *lpBuf = (uint16 *)buf; - byte *inp; - int bufferstep; - int cache = 0; - int delta; - int sign; - int vpdiff; - uint32 eof, i; - int step[2]; - - bufferstep = 1; - step[0] = stepSizeTable[index[0]]; - step[1] = stepSizeTable[index[1]]; - - /* Richiama il CODEC RAW per leggere da disco lo stream con loop. La - chiamata e' possibile perche' abbiamo ereditato CODECADPCM da CODECRAW, - e non semplicemente da CODEC. */ - eof = CODECRAW::Decompress(hFile, lpTemp, dwSize / 4); - inp = lpTemp; - - eof *= 2; - - /* Se bisogna loopare subito lo fa */ - if (EndOfStream() && eof == 0) { - LoopReset(); - bufferstep = 1; - step[0] = stepSizeTable[index[0]]; - step[1] = stepSizeTable[index[1]]; - } else if (!EndOfStream()) - eof = 0; - - dwSize /= 2; - for (i = 0; i < dwSize; i++) { - /* Controlla se siamo alla fine del file, e bisogna loopare */ - if (eof != 0 && i == eof) { - LoopReset(); - bufferstep = 1; - step[0] = stepSizeTable[index[0]]; - step[1] = stepSizeTable[index[1]]; - } - - /* Legge il delta (4 bit) */ - if (bufferstep) { - cache = *inp++; - delta = cache & 0xF; - } else - delta = (cache >> 4) & 0xF; - - /* Trova il nuovo indice */ - index[bufferstep] += indexTable[delta]; - if (index[bufferstep] < 0) index[bufferstep] = 0; - if (index[bufferstep] > 88) index[bufferstep] = 88; - - /* Legge il segno e lo separa dall'ampliamento */ - sign = delta & 8; - delta = delta & 7; - - /* Trova la differenza dal valore precedente */ - vpdiff = step[bufferstep] >> 3; - if (delta & 4) vpdiff += step[bufferstep]; - if (delta & 2) vpdiff += step[bufferstep] >> 1; - if (delta & 1) vpdiff += step[bufferstep] >> 2; - - if (sign) - valpred[bufferstep] -= vpdiff; - else - valpred[bufferstep] += vpdiff; - - /* Controlla i limiti del valore trovato */ - if (valpred[bufferstep] > 32767) - valpred[bufferstep] = 32767; - else if (valpred[bufferstep] < -32768) - valpred[bufferstep] = -32768; - - /* Aggiorna lo step */ - step[bufferstep] = stepSizeTable[index[bufferstep]]; - - /* Scrive il valore trovato */ - *lpBuf ++ = (signed short)valpred[bufferstep]; - - bufferstep = !bufferstep; - } - - return eof / 2; -} - - -uint32 CODECADPCMSTEREO::Decompress(Common::File &fp, void *buf, uint32 dwSize) { - uint16 *lpBuf = (uint16 *)buf; - byte *inp; - int bufferstep; - int cache = 0; - int delta; - int sign; - int vpdiff; - uint32 eof, i; - int step[2]; - - bufferstep = 1; - step[0] = stepSizeTable[index[0]]; - step[1] = stepSizeTable[index[1]]; - - /* Richiama il CODEC RAW per leggere da disco lo stream con loop. La - chiamata e' possibile perche' abbiamo ereditato CODECADPCM da CODECRAW, - e non semplicemente da CODEC. */ - eof = CODECRAW::Decompress(fp, lpTemp, dwSize / 4); - inp = lpTemp; - - eof *= 2; - /* Se bisogna loopare subito lo fa */ - if (EndOfStream() && eof == 0) { - LoopReset(); - bufferstep = 1; - step[0] = stepSizeTable[index[0]]; - step[1] = stepSizeTable[index[1]]; - } else if (!EndOfStream()) - eof = 0; - - dwSize /= 2; - for (i = 0; i < dwSize; i++) { - /* Controlla se siamo alla fine del file, e bisogna loopare */ - if (eof != 0 && i == eof) { - LoopReset(); - bufferstep = 1; - step[0] = stepSizeTable[index[0]]; - step[1] = stepSizeTable[index[1]]; - } - - /* Legge il delta (4 bit) */ - if (bufferstep) { - cache = *inp++; - delta = cache & 0xF; - } else - delta = (cache >> 4) & 0xF; - - /* Trova il nuovo indice */ - index[bufferstep] += indexTable[delta]; - if (index[bufferstep] < 0) index[bufferstep] = 0; - if (index[bufferstep] > 88) index[bufferstep] = 88; - - /* Legge il segno e lo separa dall'ampliamento */ - sign = delta & 8; - delta = delta & 7; - - /* Trova la differenza dal valore precedente */ - vpdiff = step[bufferstep] >> 3; - if (delta & 4) vpdiff += step[bufferstep]; - if (delta & 2) vpdiff += step[bufferstep] >> 1; - if (delta & 1) vpdiff += step[bufferstep] >> 2; - - if (sign) - valpred[bufferstep] -= vpdiff; - else - valpred[bufferstep] += vpdiff; - - /* Controlla i limiti del valore trovato */ - if (valpred[bufferstep] > 32767) - valpred[bufferstep] = 32767; - else if (valpred[bufferstep] < -32768) - valpred[bufferstep] = -32768; - - /* Aggiorna lo step */ - step[bufferstep] = stepSizeTable[index[bufferstep]]; - - /* Scrive il valore trovato */ - *lpBuf ++ = (signed short)valpred[bufferstep]; - - bufferstep = !bufferstep; - } - - return eof / 2; -} - - /****************************************************************************\ * Metodi per FPSOUND \****************************************************************************/ -- cgit v1.2.3 From 1668a231926d3ff8b464417bd8023d7a93839d21 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Sat, 9 Jun 2012 18:35:08 -0400 Subject: TONY: Make FPSOUND work in ScummVM --- engines/tony/sound.cpp | 121 +++++-------------------------------------------- engines/tony/sound.h | 29 +++--------- 2 files changed, 17 insertions(+), 133 deletions(-) (limited to 'engines') diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index 450384b341..2d4ff824f0 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -26,6 +26,7 @@ * Copyright (c) 1997-2003 Nayma Software */ +#include "audio/mixer.h" #include "common/textconsole.h" #include "tony/game.h" #include "tony/tony.h" @@ -52,109 +53,24 @@ namespace Tony { \****************************************************************************/ FPSOUND::FPSOUND() { - lpDS = NULL; - lpDSBPrimary = NULL; - hwnd = 0; bSoundSupported = false; } /****************************************************************************\ * -* Function: bool FPSOUND::Init(HWND hWnd); +* Function: bool FPSOUND::Init(); * * Description: Inizializza l'oggetto, e prepara tutto il necessario per * creare stream e effetti sonori. * -* Input: HWND hWnd Handle della finestra principale -* * Return: True se tutto OK, false in caso di errore. * \****************************************************************************/ -bool FPSOUND::Init(/*HWND hWnd*/) { -#ifdef REFACTOR_ME - HRESULT err; - static DSBUFFERDESC dsbdesc; - static PCMWAVEFORMAT pcmwf; - static char errbuf[128]; - - /* Salva l'handle della finestra nella variabile globale. DirectSound ha - bisogno dell'handle per effetuare il multitasking sonoro. */ - hwnd = hWnd; - - /* Di default, disabilita il sonoro. Se non troveremo problemi, lo - riabiliteremo alla fine della routine */ - bSoundSupported = false; - - /* Crea un oggetto DirectSound. Usiamo il driver sonoro settato di default. - In realta' sarebbe possibile richiedere una lista delle schede sonore - presenti, e lasciare scegliere all'utente quale utilizzare, ma mi sembra - una perdita di tempo. */ - if ((err = DirectSoundCreate(NULL, &lpDS, NULL)) != DS_OK) { - return false; - } - - /* Richiede le caratteristiche del driver sonoro */ - dscaps.dwSize = sizeof(dscaps); - lpDS->GetCaps(&dscaps); - - /* Controlla se siamo in emulazione, e in caso affermativo avverte l'utente */ - if ((dscaps.dwFlags & DSCAPS_EMULDRIVER)) - error("The current sound driver is not directly supported by DirectSound. This will slow down sound performance of the game."); - - /* Setta il livello di cooperazione a esclusivo. In questo modo il gioco - sara' il solo ad accedere alla scheda sonora mentre e' in escuzione, ed - eventuali player in background saranno automaticamente stoppati. - Inoltre in questo modo e' possibile settare il formato di output sonoro - del primary buffer */ - if ((err = lpDS->SetCooperativeLevel(hWnd, DSSCL_PRIORITY)) != DS_OK) { - MessageBox(hwnd, "Cannot set exclusive mode!", "soundInit()", MB_OK); - return false; - } - - - /* Crea il primary buffer. In realta' DirectSound la farebbe automaticamente, - ma noi vogliamo il pointer al primary perche' dobbiamo settare il - formato di output */ - ZeroMemory(&dsbdesc, sizeof(dsbdesc)); - dsbdesc.dwSize = sizeof(dsbdesc); - dsbdesc.dwFlags = DSBCAPS_CTRLVOLUME | DSBCAPS_PRIMARYBUFFER; - if (lpDS->CreateSoundBuffer(&dsbdesc, &lpDSBPrimary, NULL) != DS_OK) { - MessageBox(hwnd, "Cannot create primary buffer!", "soundInit()", MB_OK); - return false; - } - - /* Settiamo il formato del buffer primario. L'ideale sarebbe 16bit 44khz - stereo, ma dobbiamo anche controllare che cio' sia permesso dalla scheda - sonora, guardando nelle caratteristiche che abbiamo richiesto sopra. - Inoltre in seguito sara' possibile lasciare scegliere all'utente il - formato da utilizzare */ - pcmwf.wBitsPerSample = ((dscaps.dwFlags & DSCAPS_PRIMARY16BIT) != 0 ? 16 : 8); - pcmwf.wf.wFormatTag = WAVE_FORMAT_PCM; - pcmwf.wf.nChannels = ((dscaps.dwFlags & DSCAPS_PRIMARYSTEREO) != 0 ? 2 : 1); - pcmwf.wf.nSamplesPerSec = 44100; - pcmwf.wf.nBlockAlign = (pcmwf.wBitsPerSample / 8) * pcmwf.wf.nChannels; - pcmwf.wf.nAvgBytesPerSec = (uint32)pcmwf.wf.nBlockAlign * (uint32)pcmwf.wf.nSamplesPerSec; - - if ((err = lpDSBPrimary->SetFormat((LPWAVEFORMATEX) & pcmwf)) != DS_OK) { - wsprintf(errbuf, "Error setting the output format (%lx)", err); - MessageBox(hwnd, errbuf, "soundInit()", MB_OK); - return false; - } - - /* Controlla che il driver DirectSound supporti buffer secondari con - play di stream 16bit, 44khz stereo */ - if (dscaps.dwMaxSecondarySampleRate != 0 && dscaps.dwMaxSecondarySampleRate < 44100) { - wsprintf(errbuf, "Driver does not support 16bit 44khz stereo mixing! (%lu)", dscaps.dwMaxSecondarySampleRate); - MessageBox(hwnd, errbuf, "soundInit()", MB_OK); - return false; - } - - /* Tutto OK. */ - bSoundSupported = true; -#endif - return true; +bool FPSOUND::Init() { + bSoundSupported = g_system->getMixer()->isReady(); + return bSoundSupported; } @@ -167,10 +83,6 @@ bool FPSOUND::Init(/*HWND hWnd*/) { \****************************************************************************/ FPSOUND::~FPSOUND() { -#ifdef REFACTOR_ME - RELEASE(lpDSBPrimary); - RELEASE(lpDS); -#endif } @@ -197,7 +109,7 @@ FPSOUND::~FPSOUND() { \****************************************************************************/ bool FPSOUND::CreateStream(FPSTREAM **lplpStream) { - (*lplpStream) = new FPSTREAM(lpDS, hwnd, bSoundSupported); + (*lplpStream) = new FPSTREAM(bSoundSupported); return (*lplpStream != NULL); } @@ -221,7 +133,7 @@ bool FPSOUND::CreateStream(FPSTREAM **lplpStream) { \****************************************************************************/ bool FPSOUND::CreateSfx(FPSFX **lplpSfx) { - (*lplpSfx) = new FPSFX(lpDS, hwnd, bSoundSupported); + (*lplpSfx) = new FPSFX(bSoundSupported); return (*lplpSfx != NULL); } @@ -239,16 +151,10 @@ bool FPSOUND::CreateSfx(FPSFX **lplpSfx) { \****************************************************************************/ void FPSOUND::SetMasterVolume(int dwVolume) { -#ifdef REFACTOR_ME - if (!bSoundSupported) return; - if (dwVolume > 63) dwVolume = 63; - if (dwVolume < 0) dwVolume = 0; - - lpDSBPrimary->SetVolume(dwVolume * (DSBVOLUME_MAX - DSBVOLUME_MIN) / 64 + DSBVOLUME_MIN); -#endif + g_system->getMixer()->setVolumeForSoundType(Audio::Mixer::kPlainSoundType, CLIP(dwVolume, 0, 63) * Audio::Mixer::kMaxChannelVolume / 63); } @@ -263,15 +169,10 @@ void FPSOUND::SetMasterVolume(int dwVolume) { \****************************************************************************/ void FPSOUND::GetMasterVolume(int *lpdwVolume) { -#ifdef REFACTOR_ME if (!bSoundSupported) return; - lpDSBPrimary->GetVolume((uint32 *)lpdwVolume); - *lpdwVolume -= (DSBVOLUME_MIN); - *lpdwVolume *= 64; - *lpdwVolume /= (DSBVOLUME_MAX - DSBVOLUME_MIN); -#endif + *lpdwVolume = g_system->getMixer()->getVolumeForSoundType(Audio::Mixer::kPlainSoundType) * 63 / Audio::Mixer::kMaxChannelVolume; } @@ -288,7 +189,7 @@ void FPSOUND::GetMasterVolume(int *lpdwVolume) { * \****************************************************************************/ -FPSFX::FPSFX(LPDIRECTSOUND lpds, HWND hWnd, bool bSoundOn) { +FPSFX::FPSFX(bool bSoundOn) { #ifdef REFACTOR_ME static char errbuf[128]; @@ -861,7 +762,7 @@ void FPSFX::GetVolume(int *lpdwVolume) { * \****************************************************************************/ -FPSTREAM::FPSTREAM(LPDIRECTSOUND LPDS, HWND hWnd, bool bSoundOn) { +FPSTREAM::FPSTREAM(bool bSoundOn) { #ifdef REFACTOR_ME //hwnd=hWnd; lpDS = LPDS; diff --git a/engines/tony/sound.h b/engines/tony/sound.h index 8be1fb42f5..be3c2da319 100644 --- a/engines/tony/sound.h +++ b/engines/tony/sound.h @@ -36,17 +36,8 @@ namespace Tony { -// Dummy type declarations -typedef void *LPDIRECTSOUND; -typedef void *LPDIRECTSOUNDBUFFER; -typedef uint32 HWND; -struct DSCAPS { -}; - - class FPSTREAM; class FPSFX; -class CODEC; enum CODECS { FPCODEC_RAW, @@ -67,10 +58,6 @@ class FPSOUND { private: bool bSoundSupported; - LPDIRECTSOUND lpDS; - LPDIRECTSOUNDBUFFER lpDSBPrimary; - DSCAPS dscaps; - HWND hwnd; /****************************************************************************\ * Metodi @@ -102,19 +89,17 @@ public: /****************************************************************************\ * - * Function: bool FPSOUND::Init(HWND hWnd); + * Function: bool FPSOUND::Init(); * * Description: Inizializza l'oggetto, e prepara tutto il necessario per * creare stream e effetti sonori. * - * Input: HWND hWnd Handle della finestra principale - * * Return: True se tutto OK, FALSE in caso di errore. * \****************************************************************************/ - bool Init(/*HWND hWnd*/); + bool Init(); /****************************************************************************\ @@ -211,7 +196,6 @@ private: bool b16bit; // TRUE se 16 bit uint32 dwFreq; // Frequenza originale di campionamento -// CODEC* lpCodec; // CODEC da utilizzare. bool bIsPlaying; // TRUE se si sta playando l'effetto sonoro bool bIsVoice; @@ -233,14 +217,14 @@ public: /****************************************************************************\ * - * Function: FPSFX(LPDIRECTSOUND lpDS, bool bSoundOn); + * Function: FPSFX(bool bSoundOn); * * Description: Costruttore di default. *NON* bisogna dichiarare direttamente * un oggetto, ma crearlo piuttosto tramite FPSOUND::CreateSfx() * \****************************************************************************/ - FPSFX(void * /*LPDIRECTSOUND */lpDS, uint32 /*HWND*/ hwnd, bool bSoundOn); + FPSFX(bool bSoundOn); /****************************************************************************\ @@ -413,7 +397,6 @@ private: FPSTREAM *SyncToPlay; // DSBPOSITIONNOTIFY dspnHot[3]; - CODEC *lpCodec; // CODEC da utilizzare. bool CreateBuffer(int nBufSize); public: @@ -431,14 +414,14 @@ public: /****************************************************************************\ * - * Function: FPSTREAM(LPDIRECTSOUND lpDS, bool bSoundOn); + * Function: FPSTREAM(bool bSoundOn); * * Description: Costruttore di default. *NON* bisogna dichiarare direttamente * un oggetto, ma crearlo piuttosto tramite FPSOUND::CreateStream() * \****************************************************************************/ - FPSTREAM(void * /*LPDIRECTSOUND*/ lpDS, uint32 /*HWND hWnd */, bool bSoundOn); + FPSTREAM(bool bSoundOn); /****************************************************************************\ -- cgit v1.2.3 From e37319a28753f9b885e7c9d0a0e607d8090ae041 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 10 Jun 2012 17:56:52 +1000 Subject: TONY: Fix data freeing in DialogStart --- engines/tony/custom.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 6db6d5f858..e00db701f3 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -1985,7 +1985,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr // If there is only one option, do it automatically, and wait for the next choice if (_ctx->num == 1) { mpalQueryDialogSelectionDWORD(_ctx->nChoice, _ctx->sl[0]); - globalFree(_ctx->sl); + globalDestroy(_ctx->sl); // Wait for the next choice to be made mpalQueryDialogWaitForChoice(&_ctx->nChoice); @@ -2001,7 +2001,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr _ctx->string = mpalQueryDialogPeriod(_ctx->sl[_ctx->i]); assert(_ctx->string != NULL); _ctx->dc.addChoice(_ctx->string); - globalFree(_ctx->string); + globalDestroy(_ctx->string); } // Activate the object @@ -2028,7 +2028,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr // Closes the choice _ctx->dc.close(); - globalFree(_ctx->sl); + globalDestroy(_ctx->sl); // Wait for the next choice to be made mpalQueryDialogWaitForChoice(&_ctx->nChoice); -- cgit v1.2.3 From f64700b27fa8f083697a16459e8237bf6c48f1dc Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 11 Jun 2012 00:24:52 +1000 Subject: TONY: Fixed display of static animations, and some variable renaming --- engines/tony/custom.cpp | 14 +++++++------- engines/tony/tonychar.cpp | 9 ++++++--- engines/tony/tonychar.h | 2 +- 3 files changed, 14 insertions(+), 11 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index e00db701f3..185fc64e94 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -985,26 +985,26 @@ DECLARE_CUSTOM_FUNCTION(TonyConCarteEnd)(CORO_PARAM, uint32, uint32, uint32, uin CORO_END_CODE; } -DECLARE_CUSTOM_FUNCTION(TonyConTaccuinoStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyWithNotebookStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONTACCUINOSTATIC; + GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_WITH_NOTEBOOK; GLOBALS.bStaticTalk = true; - CORO_INVOKE_1(GLOBALS.Tony->startStatic, GLOBALS.Tony->TALK_CONTACCUINOSTATIC); + CORO_INVOKE_1(GLOBALS.Tony->startStatic, GLOBALS.Tony->TALK_WITH_NOTEBOOK); CORO_END_CODE; } -DECLARE_CUSTOM_FUNCTION(TonyConTaccuinoEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyWithNotebookEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(GLOBALS.Tony->endStatic, GLOBALS.Tony->TALK_CONTACCUINOSTATIC); + CORO_INVOKE_1(GLOBALS.Tony->endStatic, GLOBALS.Tony->TALK_WITH_NOTEBOOK); GLOBALS.bStaticTalk = false; GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; @@ -2459,8 +2459,8 @@ ASSIGN(98, TonyConRicettaStart) ASSIGN(99, TonyConRicettaEnd) ASSIGN(100, TonyConCarteStart) ASSIGN(101, TonyConCarteEnd) -ASSIGN(102, TonyConTaccuinoStart) -ASSIGN(103, TonyConTaccuinoEnd) +ASSIGN(102, TonyWithNotebookStart) +ASSIGN(103, TonyWithNotebookEnd) ASSIGN(104, TonyConMegafonoStart) ASSIGN(105, TonyConMegafonoEnd) ASSIGN(106, TonyConBarbaStart) diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index a63d2d69c3..f0357ad15d 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -950,7 +950,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case TALK_CONRICETTASTATIC: case TALK_CONCONIGLIOSTATIC: case TALK_CONCARTESTATIC: - case TALK_CONTACCUINOSTATIC: + case TALK_WITH_NOTEBOOK: case TALK_CONMEGAFONOSTATIC: switch (_TalkDirection) { case LEFT: @@ -1632,7 +1632,7 @@ void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat } break; - case TALK_CONTACCUINOSTATIC: + case TALK_WITH_NOTEBOOK: switch (_TalkDirection) { case UP: case LEFT: @@ -1736,6 +1736,9 @@ void RMTony::startStatic(CORO_PARAM, TALKTYPE nTalk) { _ctx->headPat = _ctx->headLoopPat = 0; _ctx->bodyStartPat = _ctx->bodyLoopPat = 0; + startStaticCalculate(nTalk, _ctx->headPat, _ctx->headLoopPat, + _ctx->bodyStartPat, _ctx->bodyLoopPat); + // e vai con i pattern _bIsStaticTalk = true; @@ -1827,7 +1830,7 @@ void RMTony::endStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, } break; - case TALK_CONTACCUINOSTATIC: + case TALK_WITH_NOTEBOOK: switch (_TalkDirection) { case UP: case LEFT: diff --git a/engines/tony/tonychar.h b/engines/tony/tonychar.h index 5179230b4c..4e0a0f0d93 100644 --- a/engines/tony/tonychar.h +++ b/engines/tony/tonychar.h @@ -61,7 +61,7 @@ public: TALK_CONCONIGLIOSTATIC, TALK_CONRICETTASTATIC, TALK_CONCARTESTATIC, - TALK_CONTACCUINOSTATIC, + TALK_WITH_NOTEBOOK, TALK_CONMEGAFONOSTATIC, TALK_CONBARBASTATIC, TALK_RIDE2, -- cgit v1.2.3 From 2b02a45ce16960644e1d5e297066f8040cd48cbc Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 10 Jun 2012 22:02:31 +0200 Subject: TONY: Rename variables in globals.h --- engines/tony/custom.cpp | 574 +++++++++++++++++++++--------------------- engines/tony/gfxengine.cpp | 8 +- engines/tony/globals.cpp | 106 ++++---- engines/tony/globals.h | 114 ++++----- engines/tony/mpal/expr.cpp | 2 +- engines/tony/mpal/loadmpc.cpp | 195 +++++++------- engines/tony/mpal/mpal.cpp | 389 ++++++++++++++-------------- engines/tony/mpal/mpaldll.h | 10 +- engines/tony/tony.cpp | 14 +- 9 files changed, 707 insertions(+), 705 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 185fc64e94..2e408a01aa 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -109,7 +109,7 @@ const char *staccFileNames[] = { void ReapplyChangedHotspot(void) { int i; for (i = 0; i < GLOBALS._curChangedHotspot; i++) - GLOBALS.Loc->getItemFromCode(GLOBALS._changedHotspot[i]._dwCode)->changeHotspot(RMPoint(GLOBALS._changedHotspot[i]._nX, GLOBALS._changedHotspot[i]._nY)); + GLOBALS._loc->getItemFromCode(GLOBALS._changedHotspot[i]._dwCode)->changeHotspot(RMPoint(GLOBALS._changedHotspot[i]._nX, GLOBALS._changedHotspot[i]._nY)); } void SaveChangedHotspot(Common::OutSaveFile *f) { @@ -141,9 +141,9 @@ void LoadChangedHotspot(Common::InSaveFile *f) { */ void MCharResetCodes(void) { for (int i = 0; i < 10; i++) - GLOBALS._mCharacter[i]._item = GLOBALS.Loc->getItemFromCode(GLOBALS._mCharacter[i]._code); + GLOBALS._mCharacter[i]._item = GLOBALS._loc->getItemFromCode(GLOBALS._mCharacter[i]._code); for (int i = 0; i < 10; i++) - GLOBALS._character[i]._item = GLOBALS.Loc->getItemFromCode(GLOBALS._character[i]._code); + GLOBALS._character[i]._item = GLOBALS._loc->getItemFromCode(GLOBALS._character[i]._code); } void CharsSaveAll(Common::OutSaveFile *f) { @@ -168,19 +168,19 @@ void CharsLoadAll(Common::InSaveFile *f) { } DECLARE_CUSTOM_FUNCTION(FaceToMe)(CORO_PARAM, uint32, uint32, uint32, uint32) { - GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_STANDDOWN); + GLOBALS._tony->setPattern(GLOBALS._tony->PAT_STANDDOWN); } DECLARE_CUSTOM_FUNCTION(BackToMe)(CORO_PARAM, uint32, uint32, uint32, uint32) { - GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_STANDUP); + GLOBALS._tony->setPattern(GLOBALS._tony->PAT_STANDUP); } DECLARE_CUSTOM_FUNCTION(LeftToMe)(CORO_PARAM, uint32, uint32, uint32, uint32) { - GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_STANDLEFT); + GLOBALS._tony->setPattern(GLOBALS._tony->PAT_STANDLEFT); } DECLARE_CUSTOM_FUNCTION(RightToMe)(CORO_PARAM, uint32, uint32, uint32, uint32) { - GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_STANDRIGHT); + GLOBALS._tony->setPattern(GLOBALS._tony->PAT_STANDRIGHT); } @@ -195,7 +195,7 @@ DECLARE_CUSTOM_FUNCTION(MySleep)(CORO_PARAM, uint32 dwTime, uint32, uint32, uint CORO_BEGIN_CODE(_ctx); - if (!GLOBALS.bSkipIdle) + if (!GLOBALS._bSkipIdle) CORO_INVOKE_1(CoroScheduler.sleep, dwTime); CORO_END_CODE; @@ -209,23 +209,23 @@ DECLARE_CUSTOM_FUNCTION(SetAlwaysDisplay)(CORO_PARAM, uint32 val, uint32, uint32 DECLARE_CUSTOM_FUNCTION(SetPointer)(CORO_PARAM, uint32 dwPointer, uint32, uint32, uint32) { switch (dwPointer) { case 1: - GLOBALS.Pointer->setSpecialPointer(GLOBALS.Pointer->PTR_FRECCIASU); + GLOBALS._pointer->setSpecialPointer(GLOBALS._pointer->PTR_FRECCIASU); break; case 2: - GLOBALS.Pointer->setSpecialPointer(GLOBALS.Pointer->PTR_FRECCIAGIU); + GLOBALS._pointer->setSpecialPointer(GLOBALS._pointer->PTR_FRECCIAGIU); break; case 3: - GLOBALS.Pointer->setSpecialPointer(GLOBALS.Pointer->PTR_FRECCIASINISTRA); + GLOBALS._pointer->setSpecialPointer(GLOBALS._pointer->PTR_FRECCIASINISTRA); break; case 4: - GLOBALS.Pointer->setSpecialPointer(GLOBALS.Pointer->PTR_FRECCIADESTRA); + GLOBALS._pointer->setSpecialPointer(GLOBALS._pointer->PTR_FRECCIADESTRA); break; case 5: - GLOBALS.Pointer->setSpecialPointer(GLOBALS.Pointer->PTR_FRECCIAMAPPA); + GLOBALS._pointer->setSpecialPointer(GLOBALS._pointer->PTR_FRECCIAMAPPA); break; default: - GLOBALS.Pointer->setSpecialPointer(GLOBALS.Pointer->PTR_NONE); + GLOBALS._pointer->setSpecialPointer(GLOBALS._pointer->PTR_NONE); break; } } @@ -261,12 +261,12 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX _ctx->curOffset = 0; - if (GLOBALS.bSkipIdle) return; + if (GLOBALS._bSkipIdle) + return; _ctx->msg.load(dwMessage); - if (!_ctx->msg.isValid()) { + if (!_ctx->msg.isValid()) return; - } _ctx->curVoc = SearchVoiceHeader(0, dwMessage); _ctx->voice = NULL; @@ -284,16 +284,16 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX _ctx->voice->SetLoop(false); } - if (GLOBALS.nTonyNextTalkType != GLOBALS.Tony->TALK_NORMAL) { - CORO_INVOKE_1(GLOBALS.Tony->startTalk, GLOBALS.nTonyNextTalkType); + if (GLOBALS._nTonyNextTalkType != GLOBALS._tony->TALK_NORMAL) { + CORO_INVOKE_1(GLOBALS._tony->startTalk, GLOBALS._nTonyNextTalkType); - if (!GLOBALS.bStaticTalk) - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; + if (!GLOBALS._bStaticTalk) + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_NORMAL; } else { if (_ctx->msg.numPeriods() > 1) - CORO_INVOKE_1(GLOBALS.Tony->startTalk, GLOBALS.Tony->TALK_FIANCHI); + CORO_INVOKE_1(GLOBALS._tony->startTalk, GLOBALS._tony->TALK_FIANCHI); else - CORO_INVOKE_1(GLOBALS.Tony->startTalk, GLOBALS.Tony->TALK_NORMAL); + CORO_INVOKE_1(GLOBALS._tony->startTalk, GLOBALS._tony->TALK_NORMAL); } if (GLOBALS._curBackText) @@ -301,8 +301,8 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX GLOBALS._bTonyIsSpeaking = true; - for (_ctx->i = 0; _ctx->i < _ctx->msg.numPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { - _ctx->text.setInput(GLOBALS.Input); + for (_ctx->i = 0; _ctx->i < _ctx->msg.numPeriods() && !GLOBALS._bSkipIdle; _ctx->i++) { + _ctx->text.setInput(GLOBALS._input); // Alignment _ctx->text.setAlignType(RMText::HCENTER, RMText::VBOTTOM); @@ -315,9 +315,9 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX // Set the position if (nX == 0 && nY == 0) - _ctx->text.setPosition(GLOBALS.Tony->position() - RMPoint(0, 130) - GLOBALS.Loc->scrollPosition()); + _ctx->text.setPosition(GLOBALS._tony->position() - RMPoint(0, 130) - GLOBALS._loc->scrollPosition()); else - _ctx->text.setPosition(RMPoint(nX, nY) - GLOBALS.Loc->scrollPosition()); + _ctx->text.setPosition(RMPoint(nX, nY) - GLOBALS._loc->scrollPosition()); // Handling for always display if (GLOBALS._bAlwaysDisplay) { @@ -345,7 +345,7 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX } // Wait for the end of the display - _ctx->text.setCustomSkipHandle(GLOBALS.hSkipIdle); + _ctx->text.setCustomSkipHandle(GLOBALS._hSkipIdle); CORO_INVOKE_0(_ctx->text.waitForEndDisplay); if (_ctx->curVoc) { @@ -359,13 +359,13 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX if (GLOBALS._curBackText) GLOBALS._curBackText->show(); - CORO_INVOKE_0(GLOBALS.Tony->endTalk); + CORO_INVOKE_0(GLOBALS._tony->endTalk); CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(ChangeBoxStatus)(CORO_PARAM, uint32 nLoc, uint32 nBox, uint32 nStatus, uint32) { - GLOBALS.Boxes->changeBoxStatus(nLoc, nBox, nStatus); + GLOBALS._boxes->changeBoxStatus(nLoc, nBox, nStatus); } @@ -380,7 +380,7 @@ DECLARE_CUSTOM_FUNCTION(CustLoadLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, ui GLOBALS._curChangedHotspot = 0; if (bUseStartPos != 0) - GLOBALS.LoadLocation(nLoc, RMPoint(tX, tY), GLOBALS.StartLocPos[nLoc]); + GLOBALS.LoadLocation(nLoc, RMPoint(tX, tY), GLOBALS._startLocPos[nLoc]); else GLOBALS.LoadLocation(nLoc, RMPoint(tX, tY), RMPoint(-1, -1)); @@ -407,18 +407,18 @@ DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgStart)(CORO_PARAM, uint32 nMsg, uint32 _ctx->msg = new RMMessage(nMsg); - GLOBALS.SFM_nLoc = GLOBALS.Loc->TEMPGetNumLoc(); - GLOBALS.SFM_pt = GLOBALS.Tony->position(); + GLOBALS.SFM_nLoc = GLOBALS._loc->TEMPGetNumLoc(); + GLOBALS.SFM_pt = GLOBALS._tony->position(); - if (GLOBALS.bSkipIdle) + if (GLOBALS._bSkipIdle) return; CORO_INVOKE_2(GLOBALS.UnloadLocation, false, NULL); - GLOBALS.Tony->hide(); + GLOBALS._tony->hide(); GLOBALS.Unfreeze(); - for (_ctx->i = 0; _ctx->i < _ctx->msg->numPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { - _ctx->text.setInput(GLOBALS.Input); + for (_ctx->i = 0; _ctx->i < _ctx->msg->numPeriods() && !GLOBALS._bSkipIdle; _ctx->i++) { + _ctx->text.setInput(GLOBALS._input); // Alignment _ctx->text.setAlignType(RMText::HCENTER, RMText::VCENTER); @@ -446,7 +446,7 @@ DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgStart)(CORO_PARAM, uint32 nMsg, uint32 GLOBALS.LinkGraphicTask(&_ctx->text); // Wait for the end of display - _ctx->text.setCustomSkipHandle(GLOBALS.hSkipIdle); + _ctx->text.setCustomSkipHandle(GLOBALS._hSkipIdle); CORO_INVOKE_0(_ctx->text.waitForEndDisplay); } @@ -474,7 +474,7 @@ DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgEnd)(CORO_PARAM, uint32 bNotEnableTony, GLOBALS.Freeze(); GLOBALS.LoadLocation(GLOBALS.SFM_nLoc, RMPoint(GLOBALS.SFM_pt.x, GLOBALS.SFM_pt.y), RMPoint(-1, -1)); if (!bNotEnableTony) - GLOBALS.Tony->show(); + GLOBALS._tony->show(); GLOBALS.Unfreeze(); MCharResetCodes(); @@ -531,7 +531,7 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint CORO_INVOKE_0(GLOBALS.WaitWipeEnd); } - if (GLOBALS.lastTappeto != GLOBALS.tappeti[nLoc]) { + if (GLOBALS._lastTappeto != GLOBALS._tappeti[nLoc]) { _vm->stopMusic(4); } @@ -540,14 +540,14 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint GLOBALS._curChangedHotspot = 0; if (bUseStartPos != 0) - GLOBALS.LoadLocation(nLoc, RMPoint(tX, tY), GLOBALS.StartLocPos[nLoc]); + GLOBALS.LoadLocation(nLoc, RMPoint(tX, tY), GLOBALS._startLocPos[nLoc]); else GLOBALS.LoadLocation(nLoc, RMPoint(tX, tY), RMPoint(-1, -1)); - if (GLOBALS.lastTappeto != GLOBALS.tappeti[nLoc]) { - GLOBALS.lastTappeto = GLOBALS.tappeti[nLoc]; - if (GLOBALS.lastTappeto != 0) - _vm->playMusic(4, tappetiFile[GLOBALS.lastTappeto], 0, true, 2000); + if (GLOBALS._lastTappeto != GLOBALS._tappeti[nLoc]) { + GLOBALS._lastTappeto = GLOBALS._tappeti[nLoc]; + if (GLOBALS._lastTappeto != 0) + _vm->playMusic(4, tappetiFile[GLOBALS._lastTappeto], 0, true, 2000); } if (!GLOBALS._bNoOcchioDiBue) { @@ -574,12 +574,12 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint } DECLARE_CUSTOM_FUNCTION(SetLocStartPosition)(CORO_PARAM, uint32 nLoc, uint32 lX, uint32 lY, uint32) { - GLOBALS.StartLocPos[nLoc].set(lX, lY); + GLOBALS._startLocPos[nLoc].set(lX, lY); } DECLARE_CUSTOM_FUNCTION(SaveTonyPosition)(CORO_PARAM, uint32, uint32, uint32, uint32) { - GLOBALS._saveTonyPos = GLOBALS.Tony->position(); - GLOBALS._saveTonyLoc = GLOBALS.Loc->TEMPGetNumLoc(); + GLOBALS._saveTonyPos = GLOBALS._tony->position(); + GLOBALS._saveTonyLoc = GLOBALS._loc->TEMPGetNumLoc(); } DECLARE_CUSTOM_FUNCTION(RestoreTonyPosition)(CORO_PARAM, uint32, uint32, uint32, uint32) { @@ -604,7 +604,7 @@ DECLARE_CUSTOM_FUNCTION(EnableInput)(CORO_PARAM, uint32, uint32, uint32, uint32) } DECLARE_CUSTOM_FUNCTION(StopTony)(CORO_PARAM, uint32, uint32, uint32, uint32) { - GLOBALS.Tony->stopNoAction(coroParam); + GLOBALS._tony->stopNoAction(coroParam); } DECLARE_CUSTOM_FUNCTION(CustEnableGUI)(CORO_PARAM, uint32, uint32, uint32, uint32) { @@ -624,11 +624,11 @@ void TonyGenericTake1(CORO_PARAM, uint32 nDirection) { CORO_BEGIN_CODE(_ctx); GLOBALS.Freeze(); - GLOBALS.Tony->take(nDirection, 0); + GLOBALS._tony->take(nDirection, 0); GLOBALS.Unfreeze(); - if (!GLOBALS.bSkipIdle) - CORO_INVOKE_0(GLOBALS.Tony->waitForEndPattern); + if (!GLOBALS._bSkipIdle) + CORO_INVOKE_0(GLOBALS._tony->waitForEndPattern); CORO_END_CODE; } @@ -640,14 +640,14 @@ void TonyGenericTake2(CORO_PARAM, uint32 nDirection) { CORO_BEGIN_CODE(_ctx); GLOBALS.Freeze(); - GLOBALS.Tony->take(nDirection, 1); + GLOBALS._tony->take(nDirection, 1); GLOBALS.Unfreeze(); - if (!GLOBALS.bSkipIdle) - CORO_INVOKE_0(GLOBALS.Tony->waitForEndPattern); + if (!GLOBALS._bSkipIdle) + CORO_INVOKE_0(GLOBALS._tony->waitForEndPattern); GLOBALS.Freeze(); - GLOBALS.Tony->take(nDirection, 2); + GLOBALS._tony->take(nDirection, 2); GLOBALS.Unfreeze(); CORO_END_CODE; @@ -660,11 +660,11 @@ void TonyGenericPut1(CORO_PARAM, uint32 nDirection) { CORO_BEGIN_CODE(_ctx); GLOBALS.Freeze(); - GLOBALS.Tony->put(nDirection, 0); + GLOBALS._tony->put(nDirection, 0); GLOBALS.Unfreeze(); - if (!GLOBALS.bSkipIdle) - CORO_INVOKE_0(GLOBALS.Tony->waitForEndPattern); + if (!GLOBALS._bSkipIdle) + CORO_INVOKE_0(GLOBALS._tony->waitForEndPattern); CORO_END_CODE; } @@ -676,14 +676,14 @@ void TonyGenericPut2(CORO_PARAM, uint32 nDirection) { CORO_BEGIN_CODE(_ctx); GLOBALS.Freeze(); - GLOBALS.Tony->put(nDirection, 1); + GLOBALS._tony->put(nDirection, 1); GLOBALS.Unfreeze(); - if (!GLOBALS.bSkipIdle) - CORO_INVOKE_0(GLOBALS.Tony->waitForEndPattern); + if (!GLOBALS._bSkipIdle) + CORO_INVOKE_0(GLOBALS._tony->waitForEndPattern); GLOBALS.Freeze(); - GLOBALS.Tony->put(nDirection, 2); + GLOBALS._tony->put(nDirection, 2); GLOBALS.Unfreeze(); CORO_END_CODE; @@ -749,9 +749,9 @@ DECLARE_CUSTOM_FUNCTION(TonyPutDown2)(CORO_PARAM, uint32, uint32, uint32, uint32 DECLARE_CUSTOM_FUNCTION(TonyPerTerra)(CORO_PARAM, uint32 dwParte, uint32, uint32, uint32) { if (dwParte == 0) - GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_PERTERRALEFT); + GLOBALS._tony->setPattern(GLOBALS._tony->PAT_PERTERRALEFT); else - GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_PERTERRARIGHT); + GLOBALS._tony->setPattern(GLOBALS._tony->PAT_PERTERRARIGHT); } DECLARE_CUSTOM_FUNCTION(TonySiRialza)(CORO_PARAM, uint32 dwParte, uint32, uint32, uint32) { @@ -761,18 +761,18 @@ DECLARE_CUSTOM_FUNCTION(TonySiRialza)(CORO_PARAM, uint32 dwParte, uint32, uint32 CORO_BEGIN_CODE(_ctx); if (dwParte == 0) - GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_SIRIALZALEFT); + GLOBALS._tony->setPattern(GLOBALS._tony->PAT_SIRIALZALEFT); else - GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_SIRIALZARIGHT); + GLOBALS._tony->setPattern(GLOBALS._tony->PAT_SIRIALZARIGHT); - if (!GLOBALS.bSkipIdle) - CORO_INVOKE_0(GLOBALS.Tony->waitForEndPattern); + if (!GLOBALS._bSkipIdle) + CORO_INVOKE_0(GLOBALS._tony->waitForEndPattern); CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(TonyPastorella)(CORO_PARAM, uint32 bIsPast, uint32, uint32, uint32) { - GLOBALS.Tony->setPastorella(bIsPast); + GLOBALS._tony->setPastorella(bIsPast); } DECLARE_CUSTOM_FUNCTION(TonyFischietto)(CORO_PARAM, uint32, uint32, uint32, uint32) { @@ -781,104 +781,104 @@ DECLARE_CUSTOM_FUNCTION(TonyFischietto)(CORO_PARAM, uint32, uint32, uint32, uint CORO_BEGIN_CODE(_ctx); - GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_FISCHIETTORIGHT); - if (!GLOBALS.bSkipIdle) - CORO_INVOKE_0(GLOBALS.Tony->waitForEndPattern); + GLOBALS._tony->setPattern(GLOBALS._tony->PAT_FISCHIETTORIGHT); + if (!GLOBALS._bSkipIdle) + CORO_INVOKE_0(GLOBALS._tony->waitForEndPattern); - GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_STANDRIGHT); + GLOBALS._tony->setPattern(GLOBALS._tony->PAT_STANDRIGHT); CORO_END_CODE; } void TonySetNumTexts(uint32 dwText) { - GLOBALS.dwTonyNumTexts = dwText; - GLOBALS.bTonyInTexts = false; + GLOBALS._dwTonyNumTexts = dwText; + GLOBALS._bTonyInTexts = false; } DECLARE_CUSTOM_FUNCTION(TonyRide)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_RIDE; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_RIDE; } DECLARE_CUSTOM_FUNCTION(TonyRidacchia)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_RIDE2; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_RIDE2; } DECLARE_CUSTOM_FUNCTION(TonyFianchi)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_FIANCHI; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_FIANCHI; } DECLARE_CUSTOM_FUNCTION(TonyCanta)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CANTA; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CANTA; } DECLARE_CUSTOM_FUNCTION(TonySiIndica)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_SIINDICA; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_SIINDICA; } DECLARE_CUSTOM_FUNCTION(TonySpaventatoConMani)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_SPAVENTATO; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_SPAVENTATO; } DECLARE_CUSTOM_FUNCTION(TonySpaventatoSenzaMani)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_SPAVENTATO2; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_SPAVENTATO2; } DECLARE_CUSTOM_FUNCTION(TonyConMartello)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONMARTELLO; - GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_CONMARTELLO); + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CONMARTELLO; + GLOBALS._tony->setPattern(GLOBALS._tony->PAT_CONMARTELLO); } DECLARE_CUSTOM_FUNCTION(TonyConBicchiere)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONBICCHIERE; - GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_CONBICCHIERE); + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CONBICCHIERE; + GLOBALS._tony->setPattern(GLOBALS._tony->PAT_CONBICCHIERE); } DECLARE_CUSTOM_FUNCTION(TonyConVerme)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONVERME; - GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_CONVERME); + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CONVERME; + GLOBALS._tony->setPattern(GLOBALS._tony->PAT_CONVERME); } DECLARE_CUSTOM_FUNCTION(TonyConCorda)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONCORDA; - GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_CONCORDA); + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CONCORDA; + GLOBALS._tony->setPattern(GLOBALS._tony->PAT_CONCORDA); } DECLARE_CUSTOM_FUNCTION(TonyConSegretaria)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONSEGRETARIA; - GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_CONSEGRETARIA); + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CONSEGRETARIA; + GLOBALS._tony->setPattern(GLOBALS._tony->PAT_CONSEGRETARIA); } DECLARE_CUSTOM_FUNCTION(TonyConConiglioANIM)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONCONIGLIO; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CONCONIGLIO; } DECLARE_CUSTOM_FUNCTION(TonyConRicettaANIM)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONRICETTA; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CONRICETTA; } DECLARE_CUSTOM_FUNCTION(TonyConCarteANIM)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONCARTE; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CONCARTE; } DECLARE_CUSTOM_FUNCTION(TonyConPupazzoANIM)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONPUPAZZO; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CONPUPAZZO; } DECLARE_CUSTOM_FUNCTION(TonyConPupazzoStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { @@ -887,9 +887,9 @@ DECLARE_CUSTOM_FUNCTION(TonyConPupazzoStart)(CORO_PARAM, uint32, uint32, uint32, CORO_BEGIN_CODE(_ctx); - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONPUPAZZOSTATIC; - GLOBALS.bStaticTalk = true; - CORO_INVOKE_1(GLOBALS.Tony->startStatic, GLOBALS.Tony->TALK_CONPUPAZZOSTATIC); + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CONPUPAZZOSTATIC; + GLOBALS._bStaticTalk = true; + CORO_INVOKE_1(GLOBALS._tony->startStatic, GLOBALS._tony->TALK_CONPUPAZZOSTATIC); CORO_END_CODE; } @@ -900,9 +900,9 @@ DECLARE_CUSTOM_FUNCTION(TonyConPupazzoEnd)(CORO_PARAM, uint32, uint32, uint32, u CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(GLOBALS.Tony->endStatic, GLOBALS.Tony->TALK_CONPUPAZZOSTATIC); - GLOBALS.bStaticTalk = false; - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; + CORO_INVOKE_1(GLOBALS._tony->endStatic, GLOBALS._tony->TALK_CONPUPAZZOSTATIC); + GLOBALS._bStaticTalk = false; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_NORMAL; CORO_END_CODE; } @@ -913,9 +913,9 @@ DECLARE_CUSTOM_FUNCTION(TonyConConiglioStart)(CORO_PARAM, uint32, uint32, uint32 CORO_BEGIN_CODE(_ctx); - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONCONIGLIOSTATIC; - GLOBALS.bStaticTalk = true; - CORO_INVOKE_1(GLOBALS.Tony->startStatic, GLOBALS.Tony->TALK_CONCONIGLIOSTATIC); + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CONCONIGLIOSTATIC; + GLOBALS._bStaticTalk = true; + CORO_INVOKE_1(GLOBALS._tony->startStatic, GLOBALS._tony->TALK_CONCONIGLIOSTATIC); CORO_END_CODE; } @@ -926,9 +926,9 @@ DECLARE_CUSTOM_FUNCTION(TonyConConiglioEnd)(CORO_PARAM, uint32, uint32, uint32, CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(GLOBALS.Tony->endStatic, GLOBALS.Tony->TALK_CONCONIGLIOSTATIC); - GLOBALS.bStaticTalk = false; - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; + CORO_INVOKE_1(GLOBALS._tony->endStatic, GLOBALS._tony->TALK_CONCONIGLIOSTATIC); + GLOBALS._bStaticTalk = false; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_NORMAL; CORO_END_CODE; } @@ -939,9 +939,9 @@ DECLARE_CUSTOM_FUNCTION(TonyConRicettaStart)(CORO_PARAM, uint32, uint32, uint32, CORO_BEGIN_CODE(_ctx); - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONRICETTASTATIC; - GLOBALS.bStaticTalk = true; - CORO_INVOKE_1(GLOBALS.Tony->startStatic, GLOBALS.Tony->TALK_CONRICETTASTATIC); + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CONRICETTASTATIC; + GLOBALS._bStaticTalk = true; + CORO_INVOKE_1(GLOBALS._tony->startStatic, GLOBALS._tony->TALK_CONRICETTASTATIC); CORO_END_CODE; } @@ -952,9 +952,9 @@ DECLARE_CUSTOM_FUNCTION(TonyConRicettaEnd)(CORO_PARAM, uint32, uint32, uint32, u CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(GLOBALS.Tony->endStatic, GLOBALS.Tony->TALK_CONRICETTASTATIC); - GLOBALS.bStaticTalk = false; - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; + CORO_INVOKE_1(GLOBALS._tony->endStatic, GLOBALS._tony->TALK_CONRICETTASTATIC); + GLOBALS._bStaticTalk = false; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_NORMAL; CORO_END_CODE; } @@ -965,9 +965,9 @@ DECLARE_CUSTOM_FUNCTION(TonyConCarteStart)(CORO_PARAM, uint32, uint32, uint32, u CORO_BEGIN_CODE(_ctx); - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONCARTESTATIC; - GLOBALS.bStaticTalk = true; - CORO_INVOKE_1(GLOBALS.Tony->startStatic, GLOBALS.Tony->TALK_CONCARTESTATIC); + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CONCARTESTATIC; + GLOBALS._bStaticTalk = true; + CORO_INVOKE_1(GLOBALS._tony->startStatic, GLOBALS._tony->TALK_CONCARTESTATIC); CORO_END_CODE; } @@ -978,9 +978,9 @@ DECLARE_CUSTOM_FUNCTION(TonyConCarteEnd)(CORO_PARAM, uint32, uint32, uint32, uin CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(GLOBALS.Tony->endStatic, GLOBALS.Tony->TALK_CONCARTESTATIC); - GLOBALS.bStaticTalk = false; - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; + CORO_INVOKE_1(GLOBALS._tony->endStatic, GLOBALS._tony->TALK_CONCARTESTATIC); + GLOBALS._bStaticTalk = false; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_NORMAL; CORO_END_CODE; } @@ -991,9 +991,9 @@ DECLARE_CUSTOM_FUNCTION(TonyWithNotebookStart)(CORO_PARAM, uint32, uint32, uint3 CORO_BEGIN_CODE(_ctx); - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_WITH_NOTEBOOK; - GLOBALS.bStaticTalk = true; - CORO_INVOKE_1(GLOBALS.Tony->startStatic, GLOBALS.Tony->TALK_WITH_NOTEBOOK); + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_WITH_NOTEBOOK; + GLOBALS._bStaticTalk = true; + CORO_INVOKE_1(GLOBALS._tony->startStatic, GLOBALS._tony->TALK_WITH_NOTEBOOK); CORO_END_CODE; } @@ -1004,9 +1004,9 @@ DECLARE_CUSTOM_FUNCTION(TonyWithNotebookEnd)(CORO_PARAM, uint32, uint32, uint32, CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(GLOBALS.Tony->endStatic, GLOBALS.Tony->TALK_WITH_NOTEBOOK); - GLOBALS.bStaticTalk = false; - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; + CORO_INVOKE_1(GLOBALS._tony->endStatic, GLOBALS._tony->TALK_WITH_NOTEBOOK); + GLOBALS._bStaticTalk = false; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_NORMAL; CORO_END_CODE; } @@ -1017,9 +1017,9 @@ DECLARE_CUSTOM_FUNCTION(TonyConMegafonoStart)(CORO_PARAM, uint32, uint32, uint32 CORO_BEGIN_CODE(_ctx); - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONMEGAFONOSTATIC; - GLOBALS.bStaticTalk = true; - CORO_INVOKE_1(GLOBALS.Tony->startStatic, GLOBALS.Tony->TALK_CONMEGAFONOSTATIC); + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CONMEGAFONOSTATIC; + GLOBALS._bStaticTalk = true; + CORO_INVOKE_1(GLOBALS._tony->startStatic, GLOBALS._tony->TALK_CONMEGAFONOSTATIC); CORO_END_CODE; } @@ -1030,9 +1030,9 @@ DECLARE_CUSTOM_FUNCTION(TonyConMegafonoEnd)(CORO_PARAM, uint32, uint32, uint32, CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(GLOBALS.Tony->endStatic, GLOBALS.Tony->TALK_CONMEGAFONOSTATIC); - GLOBALS.bStaticTalk = false; - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; + CORO_INVOKE_1(GLOBALS._tony->endStatic, GLOBALS._tony->TALK_CONMEGAFONOSTATIC); + GLOBALS._bStaticTalk = false; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_NORMAL; CORO_END_CODE; } @@ -1043,9 +1043,9 @@ DECLARE_CUSTOM_FUNCTION(TonyConBarbaStart)(CORO_PARAM, uint32, uint32, uint32, u CORO_BEGIN_CODE(_ctx); - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_CONBARBASTATIC; - GLOBALS.bStaticTalk = true; - CORO_INVOKE_1(GLOBALS.Tony->startStatic, GLOBALS.Tony->TALK_CONBARBASTATIC); + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CONBARBASTATIC; + GLOBALS._bStaticTalk = true; + CORO_INVOKE_1(GLOBALS._tony->startStatic, GLOBALS._tony->TALK_CONBARBASTATIC); CORO_END_CODE; } @@ -1056,9 +1056,9 @@ DECLARE_CUSTOM_FUNCTION(TonyConBarbaEnd)(CORO_PARAM, uint32, uint32, uint32, uin CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(GLOBALS.Tony->endStatic, GLOBALS.Tony->TALK_CONBARBASTATIC); - GLOBALS.bStaticTalk = false; - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; + CORO_INVOKE_1(GLOBALS._tony->endStatic, GLOBALS._tony->TALK_CONBARBASTATIC); + GLOBALS._bStaticTalk = false; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_NORMAL; CORO_END_CODE; } @@ -1069,9 +1069,9 @@ DECLARE_CUSTOM_FUNCTION(TonySpaventatoStart)(CORO_PARAM, uint32, uint32, uint32, CORO_BEGIN_CODE(_ctx); - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_SPAVENTATOSTATIC; - GLOBALS.bStaticTalk = true; - CORO_INVOKE_1(GLOBALS.Tony->startStatic, GLOBALS.Tony->TALK_SPAVENTATOSTATIC); + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_SPAVENTATOSTATIC; + GLOBALS._bStaticTalk = true; + CORO_INVOKE_1(GLOBALS._tony->startStatic, GLOBALS._tony->TALK_SPAVENTATOSTATIC); CORO_END_CODE; } @@ -1082,9 +1082,9 @@ DECLARE_CUSTOM_FUNCTION(TonySpaventatoEnd)(CORO_PARAM, uint32, uint32, uint32, u CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(GLOBALS.Tony->endStatic, GLOBALS.Tony->TALK_SPAVENTATOSTATIC); - GLOBALS.bStaticTalk = false; - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; + CORO_INVOKE_1(GLOBALS._tony->endStatic, GLOBALS._tony->TALK_SPAVENTATOSTATIC); + GLOBALS._bStaticTalk = false; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_NORMAL; CORO_END_CODE; } @@ -1092,7 +1092,7 @@ DECLARE_CUSTOM_FUNCTION(TonySpaventatoEnd)(CORO_PARAM, uint32, uint32, uint32, u DECLARE_CUSTOM_FUNCTION(TonySchifato)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_SCHIFATO; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_SCHIFATO; } DECLARE_CUSTOM_FUNCTION(TonySniffaLeft)(CORO_PARAM, uint32, uint32, uint32, uint32) { @@ -1101,8 +1101,8 @@ DECLARE_CUSTOM_FUNCTION(TonySniffaLeft)(CORO_PARAM, uint32, uint32, uint32, uint CORO_BEGIN_CODE(_ctx); - GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_SNIFFA_LEFT); - CORO_INVOKE_0(GLOBALS.Tony->waitForEndPattern); + GLOBALS._tony->setPattern(GLOBALS._tony->PAT_SNIFFA_LEFT); + CORO_INVOKE_0(GLOBALS._tony->waitForEndPattern); CORO_INVOKE_4(LeftToMe, 0, 0, 0, 0); CORO_END_CODE; @@ -1114,8 +1114,8 @@ DECLARE_CUSTOM_FUNCTION(TonySniffaRight)(CORO_PARAM, uint32, uint32, uint32, uin CORO_BEGIN_CODE(_ctx); - GLOBALS.Tony->setPattern(GLOBALS.Tony->PAT_SNIFFA_RIGHT); - CORO_INVOKE_0(GLOBALS.Tony->waitForEndPattern); + GLOBALS._tony->setPattern(GLOBALS._tony->PAT_SNIFFA_RIGHT); + CORO_INVOKE_0(GLOBALS._tony->waitForEndPattern); CORO_INVOKE_4(RightToMe, 0, 0, 0, 0); CORO_END_CODE; @@ -1123,48 +1123,48 @@ DECLARE_CUSTOM_FUNCTION(TonySniffaRight)(CORO_PARAM, uint32, uint32, uint32, uin DECLARE_CUSTOM_FUNCTION(TonyNaah)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NAAH; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_NAAH; } DECLARE_CUSTOM_FUNCTION(TonyMacbeth)(CORO_PARAM, uint32 nPos, uint32, uint32, uint32) { switch (nPos) { case 1: - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_MACBETH1; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_MACBETH1; break; case 2: - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_MACBETH2; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_MACBETH2; break; case 3: - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_MACBETH3; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_MACBETH3; break; case 4: - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_MACBETH4; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_MACBETH4; break; case 5: - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_MACBETH5; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_MACBETH5; break; case 6: - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_MACBETH6; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_MACBETH6; break; case 7: - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_MACBETH7; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_MACBETH7; break; case 8: - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_MACBETH8; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_MACBETH8; break; case 9: - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_MACBETH9; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_MACBETH9; break; } } DECLARE_CUSTOM_FUNCTION(EnableTony)(CORO_PARAM, uint32, uint32, uint32, uint32) { - GLOBALS.Tony->show(); + GLOBALS._tony->show(); } DECLARE_CUSTOM_FUNCTION(DisableTony)(CORO_PARAM, uint32 bShowOmbra, uint32, uint32, uint32) { - GLOBALS.Tony->hide(bShowOmbra); + GLOBALS._tony->hide(bShowOmbra); } DECLARE_CUSTOM_FUNCTION(WaitForPatternEnd)(CORO_PARAM, uint32 nItem, uint32, uint32, uint32) { @@ -1174,17 +1174,17 @@ DECLARE_CUSTOM_FUNCTION(WaitForPatternEnd)(CORO_PARAM, uint32 nItem, uint32, uin CORO_BEGIN_CODE(_ctx); - _ctx->item = GLOBALS.Loc->getItemFromCode(nItem); + _ctx->item = GLOBALS._loc->getItemFromCode(nItem); - if (!GLOBALS.bSkipIdle && _ctx->item != NULL) - CORO_INVOKE_1(_ctx->item->waitForEndPattern, GLOBALS.hSkipIdle); + if (!GLOBALS._bSkipIdle && _ctx->item != NULL) + CORO_INVOKE_1(_ctx->item->waitForEndPattern, GLOBALS._hSkipIdle); CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(SetTonyPosition)(CORO_PARAM, uint32 nX, uint32 nY, uint32 nLoc, uint32) { - GLOBALS.Tony->setPosition(RMPoint(nX, nY), nLoc); + GLOBALS._tony->setPosition(RMPoint(nX, nY), nLoc); } DECLARE_CUSTOM_FUNCTION(MoveTonyAndWait)(CORO_PARAM, uint32 nX, uint32 nY, uint32, uint32) { @@ -1193,16 +1193,16 @@ DECLARE_CUSTOM_FUNCTION(MoveTonyAndWait)(CORO_PARAM, uint32 nX, uint32 nY, uint3 CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(GLOBALS.Tony->move, RMPoint(nX, nY)); + CORO_INVOKE_1(GLOBALS._tony->move, RMPoint(nX, nY)); - if (!GLOBALS.bSkipIdle) - CORO_INVOKE_0(GLOBALS.Tony->waitForEndMovement); + if (!GLOBALS._bSkipIdle) + CORO_INVOKE_0(GLOBALS._tony->waitForEndMovement); CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(MoveTony)(CORO_PARAM, uint32 nX, uint32 nY, uint32, uint32) { - GLOBALS.Tony->move(coroParam, RMPoint(nX, nY)); + GLOBALS._tony->move(coroParam, RMPoint(nX, nY)); } DECLARE_CUSTOM_FUNCTION(ScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, uint32 sX, uint32 sY) { @@ -1217,9 +1217,9 @@ DECLARE_CUSTOM_FUNCTION(ScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, uint32 _ctx->lx = (int32)nX; _ctx->ly = (int32)nY; - _ctx->pt = GLOBALS.Loc->scrollPosition(); + _ctx->pt = GLOBALS._loc->scrollPosition(); - while ((_ctx->lx != 0 || _ctx->ly != 0) && !GLOBALS.bSkipIdle) { + while ((_ctx->lx != 0 || _ctx->ly != 0) && !GLOBALS._bSkipIdle) { if (_ctx->lx > 0) { _ctx->lx -= (int32)sX; if (_ctx->lx < 0) _ctx->lx = 0; @@ -1243,8 +1243,8 @@ DECLARE_CUSTOM_FUNCTION(ScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, uint32 CORO_INVOKE_0(GLOBALS.WaitFrame); GLOBALS.Freeze(); - GLOBALS.Loc->setScrollPosition(_ctx->pt); - GLOBALS.Tony->setScrollPosition(_ctx->pt); + GLOBALS._loc->setScrollPosition(_ctx->pt); + GLOBALS._tony->setScrollPosition(_ctx->pt); GLOBALS.Unfreeze(); } @@ -1276,7 +1276,7 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui _ctx->stepX = sX; _ctx->stepY = sY; - _ctx->startpt = GLOBALS.Loc->scrollPosition(); + _ctx->startpt = GLOBALS._loc->scrollPosition(); _ctx->dwStartTime = _vm->getTime(); @@ -1285,7 +1285,7 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui else _ctx->dwTotalTime = _ctx->dimy * (1000 / 35) / sY; - while ((_ctx->lx != 0 || _ctx->ly != 0) && !GLOBALS.bSkipIdle) { + while ((_ctx->lx != 0 || _ctx->ly != 0) && !GLOBALS._bSkipIdle) { _ctx->dwCurTime = _vm->getTime() - _ctx->dwStartTime; if (_ctx->dwCurTime > _ctx->dwTotalTime) break; @@ -1308,8 +1308,8 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui CORO_INVOKE_0(GLOBALS.WaitFrame); GLOBALS.Freeze(); - GLOBALS.Loc->setScrollPosition(_ctx->pt); - GLOBALS.Tony->setScrollPosition(_ctx->pt); + GLOBALS._loc->setScrollPosition(_ctx->pt); + GLOBALS._tony->setScrollPosition(_ctx->pt); GLOBALS.Unfreeze(); } @@ -1329,8 +1329,8 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui } GLOBALS.Freeze(); - GLOBALS.Loc->setScrollPosition(_ctx->pt); - GLOBALS.Tony->setScrollPosition(_ctx->pt); + GLOBALS._loc->setScrollPosition(_ctx->pt); + GLOBALS._tony->setScrollPosition(_ctx->pt); GLOBALS.Unfreeze(); CORO_END_CODE; @@ -1354,7 +1354,7 @@ DECLARE_CUSTOM_FUNCTION(ChangeHotspot)(CORO_PARAM, uint32 dwCode, uint32 nX, uin GLOBALS._curChangedHotspot++; } - GLOBALS.Loc->getItemFromCode(dwCode)->changeHotspot(RMPoint(nX, nY)); + GLOBALS._loc->getItemFromCode(dwCode)->changeHotspot(RMPoint(nX, nY)); } @@ -1384,8 +1384,8 @@ DECLARE_CUSTOM_FUNCTION(TremaSchermo)(CORO_PARAM, uint32 nScosse, uint32, uint32 CORO_INVOKE_0(GLOBALS.WaitFrame); GLOBALS.Freeze(); - GLOBALS.Loc->setFixedScroll(RMPoint(1 * _ctx->dirx, 1 * _ctx->diry)); - GLOBALS.Tony->setFixedScroll(RMPoint(1 * _ctx->dirx, 1 * _ctx->diry)); + GLOBALS._loc->setFixedScroll(RMPoint(1 * _ctx->dirx, 1 * _ctx->diry)); + GLOBALS._tony->setFixedScroll(RMPoint(1 * _ctx->dirx, 1 * _ctx->diry)); GLOBALS.Unfreeze(); _ctx->i = _vm->_randomSource.getRandomNumber(2); @@ -1397,8 +1397,8 @@ DECLARE_CUSTOM_FUNCTION(TremaSchermo)(CORO_PARAM, uint32 nScosse, uint32, uint32 } GLOBALS.Freeze(); - GLOBALS.Loc->setFixedScroll(RMPoint(0, 0)); - GLOBALS.Tony->setFixedScroll(RMPoint(0, 0)); + GLOBALS._loc->setFixedScroll(RMPoint(0, 0)); + GLOBALS._tony->setFixedScroll(RMPoint(0, 0)); GLOBALS.Unfreeze(); CORO_END_CODE; @@ -1413,7 +1413,7 @@ DECLARE_CUSTOM_FUNCTION(TremaSchermo)(CORO_PARAM, uint32 nScosse, uint32, uint32 DECLARE_CUSTOM_FUNCTION(CharSetCode)(CORO_PARAM, uint32 nChar, uint32 nCode, uint32, uint32) { assert(nChar < 16); GLOBALS._character[nChar]._code = nCode; - GLOBALS._character[nChar]._item = GLOBALS.Loc->getItemFromCode(nCode); + GLOBALS._character[nChar]._item = GLOBALS._loc->getItemFromCode(nCode); GLOBALS._character[nChar]._r = 255; GLOBALS._character[nChar]._g = 255; GLOBALS._character[nChar]._b = 255; @@ -1461,7 +1461,7 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess _ctx->curOffset = 0; assert(nChar < 16); - _ctx->pt = GLOBALS._character[nChar]._item->calculatePos() - RMPoint(-60, 20) - GLOBALS.Loc->scrollPosition(); + _ctx->pt = GLOBALS._character[nChar]._item->calculatePos() - RMPoint(-60, 20) - GLOBALS._loc->scrollPosition(); if (GLOBALS._character[nChar]._startTalkPattern != 0) { GLOBALS.Freeze(); @@ -1483,15 +1483,15 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess _ctx->curOffset = _ctx->curVoc->_offset; } - for (_ctx->i = 0; _ctx->i < _ctx->msg->numPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { + for (_ctx->i = 0; _ctx->i < _ctx->msg->numPeriods() && !GLOBALS._bSkipIdle; _ctx->i++) { if (bIsBack) { - GLOBALS._curBackText = _ctx->text = new RMTextDialogScrolling(GLOBALS.Loc); + GLOBALS._curBackText = _ctx->text = new RMTextDialogScrolling(GLOBALS._loc); if (GLOBALS._bTonyIsSpeaking) CORO_INVOKE_0(GLOBALS._curBackText->hide); } else _ctx->text = new RMTextDialog; - _ctx->text->setInput(GLOBALS.Input); + _ctx->text->setInput(GLOBALS._input); // Skipping _ctx->text->setSkipStatus(!bIsBack); @@ -1529,7 +1529,7 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess } // Wait for the end of display - _ctx->text->setCustomSkipHandle(GLOBALS.hSkipIdle); + _ctx->text->setCustomSkipHandle(GLOBALS._hSkipIdle); CORO_INVOKE_0(_ctx->text->waitForEndDisplay); if (_ctx->curVoc) { @@ -1559,15 +1559,15 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess } DECLARE_CUSTOM_FUNCTION(AddInventory)(CORO_PARAM, uint32 dwCode, uint32, uint32, uint32) { - GLOBALS.Inventory->addItem(dwCode); + GLOBALS._inventory->addItem(dwCode); } DECLARE_CUSTOM_FUNCTION(RemoveInventory)(CORO_PARAM, uint32 dwCode, uint32, uint32, uint32) { - GLOBALS.Inventory->removeItem(dwCode); + GLOBALS._inventory->removeItem(dwCode); } DECLARE_CUSTOM_FUNCTION(ChangeInventoryStatus)(CORO_PARAM, uint32 dwCode, uint32 dwStatus, uint32, uint32) { - GLOBALS.Inventory->changeItemStatus(dwCode, dwStatus); + GLOBALS._inventory->changeItemStatus(dwCode, dwStatus); } @@ -1581,7 +1581,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSetCode)(CORO_PARAM, uint32 nChar, uint32 nCode, ui if (nCode == 0) GLOBALS._mCharacter[nChar]._item = NULL; else - GLOBALS._mCharacter[nChar]._item = GLOBALS.Loc->getItemFromCode(nCode); + GLOBALS._mCharacter[nChar]._item = GLOBALS._loc->getItemFromCode(nCode); GLOBALS._mCharacter[nChar]._r = 255; GLOBALS._mCharacter[nChar]._g = 255; GLOBALS._mCharacter[nChar]._b = 255; @@ -1598,7 +1598,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSetCode)(CORO_PARAM, uint32 nChar, uint32 nCode, ui } DECLARE_CUSTOM_FUNCTION(MCharResetCode)(CORO_PARAM, uint32 nChar, uint32, uint32, uint32) { - GLOBALS._mCharacter[nChar]._item = GLOBALS.Loc->getItemFromCode(GLOBALS._mCharacter[nChar]._code); + GLOBALS._mCharacter[nChar]._item = GLOBALS._loc->getItemFromCode(GLOBALS._mCharacter[nChar]._code); } @@ -1670,7 +1670,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes // Calculates the position of the text according to the current frame if (GLOBALS._mCharacter[nChar]._x == -1) - _ctx->pt = GLOBALS._mCharacter[nChar]._item->calculatePos() - RMPoint(-60, 20) - GLOBALS.Loc->scrollPosition(); + _ctx->pt = GLOBALS._mCharacter[nChar]._item->calculatePos() - RMPoint(-60, 20) - GLOBALS._loc->scrollPosition(); else _ctx->pt = RMPoint(GLOBALS._mCharacter[nChar]._x, GLOBALS._mCharacter[nChar]._y); @@ -1695,16 +1695,16 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes _ctx->curOffset = _ctx->curVoc->_offset; } - for (_ctx->i = 0; _ctx->i < _ctx->msg->numPeriods() && !GLOBALS.bSkipIdle; _ctx->i++) { + for (_ctx->i = 0; _ctx->i < _ctx->msg->numPeriods() && !GLOBALS._bSkipIdle; _ctx->i++) { // Create a different object depending on whether it's background or not if (bIsBack) { - GLOBALS._curBackText = _ctx->text = new RMTextDialogScrolling(GLOBALS.Loc); + GLOBALS._curBackText = _ctx->text = new RMTextDialogScrolling(GLOBALS._loc); if (GLOBALS._bTonyIsSpeaking) CORO_INVOKE_0(GLOBALS._curBackText->hide); } else _ctx->text = new RMTextDialog; - _ctx->text->setInput(GLOBALS.Input); + _ctx->text->setInput(GLOBALS._input); // Skipping _ctx->text->setSkipStatus(!bIsBack); @@ -1742,7 +1742,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes } // Wait for the end of display - _ctx->text->setCustomSkipHandle(GLOBALS.hSkipIdle); + _ctx->text->setCustomSkipHandle(GLOBALS._hSkipIdle); CORO_INVOKE_0(_ctx->text->waitForEndDisplay); if (_ctx->curVoc) { @@ -1810,30 +1810,30 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg if (nPers == 0) { _ctx->text = new RMTextDialog; _ctx->text->setColor(0, 255, 0); - _ctx->text->setPosition(GLOBALS.Tony->position() - RMPoint(0, 130) - GLOBALS.Loc->scrollPosition()); + _ctx->text->setPosition(GLOBALS._tony->position() - RMPoint(0, 130) - GLOBALS._loc->scrollPosition()); _ctx->text->writeText(_ctx->string, 0); - if (GLOBALS.dwTonyNumTexts > 0) { - if (!GLOBALS.bTonyInTexts) { - if (GLOBALS.nTonyNextTalkType != GLOBALS.Tony->TALK_NORMAL) { - CORO_INVOKE_1(GLOBALS.Tony->startTalk, GLOBALS.nTonyNextTalkType); - if (!GLOBALS.bStaticTalk) - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; + if (GLOBALS._dwTonyNumTexts > 0) { + if (!GLOBALS._bTonyInTexts) { + if (GLOBALS._nTonyNextTalkType != GLOBALS._tony->TALK_NORMAL) { + CORO_INVOKE_1(GLOBALS._tony->startTalk, GLOBALS._nTonyNextTalkType); + if (!GLOBALS._bStaticTalk) + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_NORMAL; } else - CORO_INVOKE_1(GLOBALS.Tony->startTalk, GLOBALS.Tony->TALK_NORMAL); + CORO_INVOKE_1(GLOBALS._tony->startTalk, GLOBALS._tony->TALK_NORMAL); - GLOBALS.bTonyInTexts = true; + GLOBALS._bTonyInTexts = true; } - GLOBALS.dwTonyNumTexts--; + GLOBALS._dwTonyNumTexts--; } else { - CORO_INVOKE_1(GLOBALS.Tony->startTalk, GLOBALS.nTonyNextTalkType); - if (!GLOBALS.bStaticTalk) - GLOBALS.nTonyNextTalkType = GLOBALS.Tony->TALK_NORMAL; + CORO_INVOKE_1(GLOBALS._tony->startTalk, GLOBALS._nTonyNextTalkType); + if (!GLOBALS._bStaticTalk) + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_NORMAL; } } else if (!GLOBALS._isMChar[nPers]) { _ctx->text = new RMTextDialog; - _ctx->pt = GLOBALS._character[nPers]._item->calculatePos() - RMPoint(-60, 20) - GLOBALS.Loc->scrollPosition(); + _ctx->pt = GLOBALS._character[nPers]._item->calculatePos() - RMPoint(-60, 20) - GLOBALS._loc->scrollPosition(); if (GLOBALS._character[nPers]._startTalkPattern != 0) { GLOBALS.Freeze(); @@ -1849,7 +1849,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg _ctx->text->setPosition(_ctx->pt); } else { if (GLOBALS._mCharacter[nPers]._x == -1) - _ctx->pt = GLOBALS._mCharacter[nPers]._item->calculatePos() - RMPoint(-60, 20) - GLOBALS.Loc->scrollPosition(); + _ctx->pt = GLOBALS._mCharacter[nPers]._item->calculatePos() - RMPoint(-60, 20) - GLOBALS._loc->scrollPosition(); else _ctx->pt = RMPoint(GLOBALS._mCharacter[nPers]._x, GLOBALS._mCharacter[nPers]._y); @@ -1874,7 +1874,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg } if (GLOBALS._mCharacter[nPers]._bAlwaysBack) { - _ctx->text = GLOBALS._curBackText = new RMTextDialogScrolling(GLOBALS.Loc); + _ctx->text = GLOBALS._curBackText = new RMTextDialogScrolling(GLOBALS._loc); if (GLOBALS._bTonyIsSpeaking) CORO_INVOKE_0(GLOBALS._curBackText->hide); @@ -1888,8 +1888,8 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg _ctx->text->setPosition(_ctx->pt); } - if (!GLOBALS.bSkipIdle) { - _ctx->text->setInput(GLOBALS.Input); + if (!GLOBALS._bSkipIdle) { + _ctx->text->setInput(GLOBALS._input); if (GLOBALS._bAlwaysDisplay) { _ctx->text->setAlwaysDisplay(); _ctx->text->forceTime(); @@ -1903,7 +1903,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg } // Wait for the end of display - _ctx->text->setCustomSkipHandle(GLOBALS.hSkipIdle); + _ctx->text->setCustomSkipHandle(GLOBALS._hSkipIdle); CORO_INVOKE_0(_ctx->text->waitForEndDisplay); } @@ -1940,10 +1940,10 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg delete _ctx->text; } } else { - if ((GLOBALS.dwTonyNumTexts == 0 && GLOBALS.bTonyInTexts) || !GLOBALS.bTonyInTexts) { - CORO_INVOKE_0(GLOBALS.Tony->endTalk); - GLOBALS.dwTonyNumTexts = 0; - GLOBALS.bTonyInTexts = false; + if ((GLOBALS._dwTonyNumTexts == 0 && GLOBALS._bTonyInTexts) || !GLOBALS._bTonyInTexts) { + CORO_INVOKE_0(GLOBALS._tony->endTalk); + GLOBALS._dwTonyNumTexts = 0; + GLOBALS._bTonyInTexts = false; } delete _ctx->text; @@ -2009,13 +2009,13 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr CORO_INVOKE_0(_ctx->dc.show); // Draw the pointer - GLOBALS.Pointer->setSpecialPointer(GLOBALS.Pointer->PTR_NONE); + GLOBALS._pointer->setSpecialPointer(GLOBALS._pointer->PTR_NONE); mainShowMouse(); - while (!(GLOBALS.Input->mouseLeftClicked() && ((_ctx->sel = _ctx->dc.getSelection()) != -1))) { + while (!(GLOBALS._input->mouseLeftClicked() && ((_ctx->sel = _ctx->dc.getSelection()) != -1))) { CORO_INVOKE_0(GLOBALS.WaitFrame); GLOBALS.Freeze(); - CORO_INVOKE_1(_ctx->dc.doFrame, GLOBALS.Input->mousePos()); + CORO_INVOKE_1(_ctx->dc.doFrame, GLOBALS._input->mousePos()); GLOBALS.Unfreeze(); } @@ -2051,17 +2051,17 @@ DECLARE_CUSTOM_FUNCTION(TakeOwnership)(CORO_PARAM, uint32 num, uint32, uint32, u // The event is operating as a mutex, so if the event is already set, wait until it's reset do { - CORO_INVOKE_3(CoroScheduler.waitForSingleObject, GLOBALS.mut[num], 0, &_ctx->expired); + CORO_INVOKE_3(CoroScheduler.waitForSingleObject, GLOBALS._mut[num], 0, &_ctx->expired); } while (!_ctx->expired); // Set the event to flag ownership - CoroScheduler.setEvent(GLOBALS.mut[num]); + CoroScheduler.setEvent(GLOBALS._mut[num]); CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(ReleaseOwnership)(CORO_PARAM, uint32 num, uint32, uint32, uint32) { - CoroScheduler.resetEvent(GLOBALS.mut[num]); + CoroScheduler.resetEvent(GLOBALS._mut[num]); } /* @@ -2199,7 +2199,7 @@ DECLARE_CUSTOM_FUNCTION(PlaySonoriz)(CORO_PARAM, uint32 nMusic, uint32 nFX, uint GLOBALS._bFadeOutStop = true; } - GLOBALS.lastMusic = nMusic; + GLOBALS._lastMusic = nMusic; CustPlayMusic(GLOBALS._curSonoriz, musicFiles[nMusic].name, nFX, bNoLoop ? false : true, musicFiles[nMusic].sync); } @@ -2209,9 +2209,9 @@ DECLARE_CUSTOM_FUNCTION(PlayStacchetto)(CORO_PARAM, uint32 nMusic, uint32 nFX, u DECLARE_CUSTOM_FUNCTION(PlayItemSfx)(CORO_PARAM, uint32 nItem, uint32 nSFX, uint32, uint32) { if (nItem == 0) { - GLOBALS.Tony->playSfx(nSFX); + GLOBALS._tony->playSfx(nSFX); } else { - RMItem *item = GLOBALS.Loc->getItemFromCode(nItem); + RMItem *item = GLOBALS._loc->getItemFromCode(nItem); if (item) item->playSfx(nSFX); } @@ -2224,22 +2224,22 @@ void RestoreMusic(CORO_PARAM) { CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_4(PlaySonoriz, GLOBALS.lastMusic, 0, 0, 0); + CORO_INVOKE_4(PlaySonoriz, GLOBALS._lastMusic, 0, 0, 0); - if (GLOBALS.lastTappeto != 0) - CustPlayMusic(4, tappetiFile[GLOBALS.lastTappeto], 0, true); + if (GLOBALS._lastTappeto != 0) + CustPlayMusic(4, tappetiFile[GLOBALS._lastTappeto], 0, true); CORO_END_CODE; } void SaveMusic(Common::OutSaveFile *f) { - f->writeByte(GLOBALS.lastMusic); - f->writeByte(GLOBALS.lastTappeto); + f->writeByte(GLOBALS._lastMusic); + f->writeByte(GLOBALS._lastTappeto); } void LoadMusic(Common::InSaveFile *f) { - GLOBALS.lastMusic = f->readByte(); - GLOBALS.lastTappeto = f->readByte(); + GLOBALS._lastMusic = f->readByte(); + GLOBALS._lastTappeto = f->readByte(); } @@ -2273,13 +2273,13 @@ DECLARE_CUSTOM_FUNCTION(StacchettoFadeEnd)(CORO_PARAM, uint32 nStacc, uint32 bLo DECLARE_CUSTOM_FUNCTION(MustSkipIdleStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { - GLOBALS.bSkipIdle = true; - CoroScheduler.setEvent(GLOBALS.hSkipIdle); + GLOBALS._bSkipIdle = true; + CoroScheduler.setEvent(GLOBALS._hSkipIdle); } DECLARE_CUSTOM_FUNCTION(MustSkipIdleEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { - GLOBALS.bSkipIdle = false; - CoroScheduler.resetEvent(GLOBALS.hSkipIdle); + GLOBALS._bSkipIdle = false; + CoroScheduler.resetEvent(GLOBALS._hSkipIdle); } DECLARE_CUSTOM_FUNCTION(PatIrqFreeze)(CORO_PARAM, uint32 bStatus, uint32, uint32, uint32) { @@ -2336,7 +2336,7 @@ DECLARE_CUSTOM_FUNCTION(DoCredits)(CORO_PARAM, uint32 nMsg, uint32 dwTime, uint3 _ctx->text = new RMTextDialog[_ctx->msg->numPeriods()]; for (_ctx->i = 0; _ctx->i < _ctx->msg->numPeriods(); _ctx->i++) { - _ctx->text[_ctx->i].setInput(GLOBALS.Input); + _ctx->text[_ctx->i].setInput(GLOBALS._input); // Alignment if ((*_ctx->msg)[_ctx->i][0] == '@') { @@ -2366,7 +2366,7 @@ DECLARE_CUSTOM_FUNCTION(DoCredits)(CORO_PARAM, uint32 nMsg, uint32 dwTime, uint3 while (_ctx->startTime + dwTime * 1000 > _vm->getTime()) { CORO_INVOKE_0(GLOBALS.WaitFrame); - if (GLOBALS.Input->mouseLeftClicked() || GLOBALS.Input->mouseRightClicked()) + if (GLOBALS._input->mouseLeftClicked() || GLOBALS._input->mouseRightClicked()) break; if (_vm->getEngine()->getInput().getAsyncKeyState(Common::KEYCODE_TAB)) break; @@ -2537,12 +2537,12 @@ ASSIGN(201, MustSkipIdleEnd); END_CUSTOM_FUNCTION_MAP() void setupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation *loc, RMInventory *inv, RMInput *input) { - GLOBALS.Tony = tony; - GLOBALS.Pointer = ptr; - GLOBALS.Boxes = box; - GLOBALS.Loc = loc; - GLOBALS.Inventory = inv; - GLOBALS.Input = input; + GLOBALS._tony = tony; + GLOBALS._pointer = ptr; + GLOBALS._boxes = box; + GLOBALS._loc = loc; + GLOBALS._inventory = inv; + GLOBALS._input = input; GLOBALS.LoadLocation = mainLoadLocation; GLOBALS.UnloadLocation = mainUnloadLocation; @@ -2562,47 +2562,47 @@ void setupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation int i; for (i = 0; i < 10; i++) - GLOBALS.mut[i] = CoroScheduler.createEvent(false, false); + GLOBALS._mut[i] = CoroScheduler.createEvent(false, false); for (i = 0; i < 200; i++) - GLOBALS.tappeti[i] = 0; - - GLOBALS.tappeti[6] = T_GRILLI; - GLOBALS.tappeti[7] = T_GRILLI; - GLOBALS.tappeti[8] = T_GRILLIOV; - GLOBALS.tappeti[10] = T_GRILLI; - GLOBALS.tappeti[12] = T_GRILLI; - GLOBALS.tappeti[13] = T_GRILLIOV; - GLOBALS.tappeti[15] = T_GRILLI; - GLOBALS.tappeti[16] = T_GRILLIVENTO; - GLOBALS.tappeti[18] = T_GRILLI; - GLOBALS.tappeti[19] = T_GRILLIVENTO; - GLOBALS.tappeti[20] = T_GRILLI; - GLOBALS.tappeti[23] = T_GRILLI; - GLOBALS.tappeti[26] = T_MAREMETA; - GLOBALS.tappeti[27] = T_GRILLI; - GLOBALS.tappeti[28] = T_GRILLIVENTO; - GLOBALS.tappeti[31] = T_GRILLI; - GLOBALS.tappeti[33] = T_MARE; - GLOBALS.tappeti[35] = T_MARE; - GLOBALS.tappeti[36] = T_GRILLI; - GLOBALS.tappeti[37] = T_GRILLI; - GLOBALS.tappeti[40] = T_GRILLI; - GLOBALS.tappeti[41] = T_GRILLI; - GLOBALS.tappeti[42] = T_GRILLI; - GLOBALS.tappeti[45] = T_GRILLI; - GLOBALS.tappeti[51] = T_GRILLI; - GLOBALS.tappeti[52] = T_GRILLIVENTO1; - GLOBALS.tappeti[53] = T_GRILLI; - GLOBALS.tappeti[54] = T_GRILLI; - GLOBALS.tappeti[57] = T_VENTO; - GLOBALS.tappeti[58] = T_VENTO; - GLOBALS.tappeti[60] = T_VENTO; + GLOBALS._tappeti[i] = 0; + + GLOBALS._tappeti[6] = T_GRILLI; + GLOBALS._tappeti[7] = T_GRILLI; + GLOBALS._tappeti[8] = T_GRILLIOV; + GLOBALS._tappeti[10] = T_GRILLI; + GLOBALS._tappeti[12] = T_GRILLI; + GLOBALS._tappeti[13] = T_GRILLIOV; + GLOBALS._tappeti[15] = T_GRILLI; + GLOBALS._tappeti[16] = T_GRILLIVENTO; + GLOBALS._tappeti[18] = T_GRILLI; + GLOBALS._tappeti[19] = T_GRILLIVENTO; + GLOBALS._tappeti[20] = T_GRILLI; + GLOBALS._tappeti[23] = T_GRILLI; + GLOBALS._tappeti[26] = T_MAREMETA; + GLOBALS._tappeti[27] = T_GRILLI; + GLOBALS._tappeti[28] = T_GRILLIVENTO; + GLOBALS._tappeti[31] = T_GRILLI; + GLOBALS._tappeti[33] = T_MARE; + GLOBALS._tappeti[35] = T_MARE; + GLOBALS._tappeti[36] = T_GRILLI; + GLOBALS._tappeti[37] = T_GRILLI; + GLOBALS._tappeti[40] = T_GRILLI; + GLOBALS._tappeti[41] = T_GRILLI; + GLOBALS._tappeti[42] = T_GRILLI; + GLOBALS._tappeti[45] = T_GRILLI; + GLOBALS._tappeti[51] = T_GRILLI; + GLOBALS._tappeti[52] = T_GRILLIVENTO1; + GLOBALS._tappeti[53] = T_GRILLI; + GLOBALS._tappeti[54] = T_GRILLI; + GLOBALS._tappeti[57] = T_VENTO; + GLOBALS._tappeti[58] = T_VENTO; + GLOBALS._tappeti[60] = T_VENTO; // Create an event for the idle skipping - GLOBALS.hSkipIdle = CoroScheduler.createEvent(true, false); + GLOBALS._hSkipIdle = CoroScheduler.createEvent(true, false); } } // end of namespace Tony diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 4bfdc1333f..e8f32edac7 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -359,10 +359,10 @@ void RMGfxEngine::initCustomDll(void) { void RMGfxEngine::itemIrq(uint32 dwItem, int nPattern, int nStatus) { RMItem *item; - assert(GLOBALS.GfxEngine); + assert(GLOBALS._gfxEngine); - if (GLOBALS.GfxEngine->_bLocationLoaded) { - item = GLOBALS.GfxEngine->_loc.getItemFromCode(dwItem); + if (GLOBALS._gfxEngine->_bLocationLoaded) { + item = GLOBALS._gfxEngine->_loc.getItemFromCode(dwItem); if (item != NULL) { if (nPattern != -1) { if (GLOBALS._bPatIrqFreeze) @@ -497,7 +497,7 @@ void RMGfxEngine::init() { _csMainLoop = g_system->createMutex(); // Initialise the IRQ function for items for MPAL - GLOBALS.GfxEngine = this; + GLOBALS._gfxEngine = this; mpalInstallItemIrq(itemIrq); // Initialise the input diff --git a/engines/tony/globals.cpp b/engines/tony/globals.cpp index 6f81e81a48..e676f33174 100644 --- a/engines/tony/globals.cpp +++ b/engines/tony/globals.cpp @@ -35,13 +35,13 @@ Globals::Globals() { _curBackText = NULL; _bTonyIsSpeaking = false; _curChangedHotspot = 0; - Tony = NULL; - Pointer = NULL; - Boxes = NULL; - Loc = NULL; - Inventory = NULL; - Input = NULL; - GfxEngine = NULL; + _tony = NULL; + _pointer = NULL; + _boxes = NULL; + _loc = NULL; + _inventory = NULL; + _input = NULL; + _gfxEngine = NULL; LoadLocation = NULL; UnloadLocation = NULL; LinkGraphicTask = NULL; @@ -56,9 +56,9 @@ Globals::Globals() { DisableGUI = NULL; SetPalesati = NULL; - dwTonyNumTexts = 0; - bTonyInTexts = false; - bStaticTalk = false; + _dwTonyNumTexts = 0; + _bTonyInTexts = false; + _bStaticTalk = false; _bPatIrqFreeze = false; _bCfgInvLocked = false; _bCfgInvNoScroll = false; @@ -86,52 +86,52 @@ Globals::Globals() { _bFadeOutStop = false; // OSystem::MutexRef vdb; - Common::fill(&mut[0], &mut[10], 0); - bSkipIdle = false; - hSkipIdle = 0; - lastMusic = 0; - lastTappeto = 0; - Common::fill(&tappeti[0], &tappeti[200], 0); + Common::fill(&_mut[0], &_mut[10], 0); + _bSkipIdle = false; + _hSkipIdle = 0; + _lastMusic = 0; + _lastTappeto = 0; + Common::fill(&_tappeti[0], &_tappeti[200], 0); SFM_nLoc = 0; // MPAL global variables - mpalError = 0; - lpiifCustom = NULL; - lplpFunctions = NULL; - lplpFunctionStrings = NULL; - nObjs = 0; - nVars = 0; - hVars = NULL; - lpmvVars = NULL; - nMsgs = 0; - hMsgs = NULL; - lpmmMsgs = NULL; - nDialogs = 0; - hDialogs = NULL; - lpmdDialogs = NULL; - nItems = 0; - hItems = NULL; - lpmiItems = NULL; - nLocations = 0; - hLocations = NULL; - lpmlLocations = NULL; - nScripts = 0; - hScripts = NULL; - lpmsScripts = NULL; - nResources = 0; - lpResources = NULL; - bExecutingAction = false; - bExecutingDialog = false; - Common::fill(&nPollingLocations[0], &nPollingLocations[MAXPOLLINGLOCATIONS], 0); - Common::fill(&hEndPollingLocations[0], &hEndPollingLocations[MAXPOLLINGLOCATIONS], 0); - Common::fill(&PollingThreads[0], &PollingThreads[MAXPOLLINGLOCATIONS], 0); - hAskChoice = 0; - hDoneChoice = 0; - nExecutingAction = 0; - nExecutingDialog = 0; - nExecutingChoice = 0; - nSelectedChoice = 0; - nTonyNextTalkType = RMTony::TALK_NORMAL; + _mpalError = 0; + _lpiifCustom = NULL; + _lplpFunctions = NULL; + _lplpFunctionStrings = NULL; + _nObjs = 0; + _nVars = 0; + _hVars = NULL; + _lpmvVars = NULL; + _nMsgs = 0; + _hMsgs = NULL; + _lpmmMsgs = NULL; + _nDialogs = 0; + _hDialogs = NULL; + _lpmdDialogs = NULL; + _nItems = 0; + _hItems = NULL; + _lpmiItems = NULL; + _nLocations = 0; + _hLocations = NULL; + _lpmlLocations = NULL; + _nScripts = 0; + _hScripts = NULL; + _lpmsScripts = NULL; + _nResources = 0; + _lpResources = NULL; + _bExecutingAction = false; + _bExecutingDialog = false; + Common::fill(&_nPollingLocations[0], &_nPollingLocations[MAXPOLLINGLOCATIONS], 0); + Common::fill(&_hEndPollingLocations[0], &_hEndPollingLocations[MAXPOLLINGLOCATIONS], 0); + Common::fill(&_pollingThreads[0], &_pollingThreads[MAXPOLLINGLOCATIONS], 0); + _hAskChoice = 0; + _hDoneChoice = 0; + _nExecutingAction = 0; + _nExecutingDialog = 0; + _nExecutingChoice = 0; + _nSelectedChoice = 0; + _nTonyNextTalkType = RMTony::TALK_NORMAL; _saveTonyLoc = 0; for (int i = 0; i < 16; ++i) diff --git a/engines/tony/globals.h b/engines/tony/globals.h index a675066bc1..e924678df0 100644 --- a/engines/tony/globals.h +++ b/engines/tony/globals.h @@ -151,9 +151,9 @@ struct ChangedHotspotStruct { * Description of a call to a custom function. */ typedef struct { - int nCf; + int _nCf; - int arg1, arg2, arg3, arg4; + int _arg1, _arg2, _arg3, _arg4; } CFCALL; typedef CFCALL *LPCFCALL; typedef LPCFCALL *LPLPCFCALL; @@ -212,13 +212,13 @@ public: int _curSonoriz; bool _bFadeOutStop; - RMTony *Tony; - RMPointer *Pointer; - RMGameBoxes *Boxes; - RMLocation *Loc; - RMInventory *Inventory; - RMInput *Input; - RMGfxEngine *GfxEngine; + RMTony *_tony; + RMPointer *_pointer; + RMGameBoxes *_boxes; + RMLocation *_loc; + RMInventory *_inventory; + RMInput *_input; + RMGfxEngine *_gfxEngine; uint32(*LoadLocation)(int, RMPoint, RMPoint start); void (*UnloadLocation)(CORO_PARAM, bool bDoOnExit, uint32 *result); @@ -234,21 +234,21 @@ public: void (*DisableGUI)(void); void (*SetPalesati)(bool bpal); - uint32 dwTonyNumTexts; - bool bTonyInTexts; - bool bStaticTalk; - RMTony::TALKTYPE nTonyNextTalkType; + uint32 _dwTonyNumTexts; + bool _bTonyInTexts; + bool _bStaticTalk; + RMTony::TALKTYPE _nTonyNextTalkType; - RMPoint StartLocPos[256]; - OSystem::MutexRef cs[10]; - uint32 mut[10]; + RMPoint _startLocPos[256]; + OSystem::MutexRef _cs[10]; + uint32 _mut[10]; - bool bSkipIdle; - uint32 hSkipIdle; + bool _bSkipIdle; + uint32 _hSkipIdle; - int lastMusic, lastTappeto; + int _lastMusic, _lastTappeto; - int tappeti[200]; + int _tappeti[200]; RMPoint SFM_pt; int SFM_nLoc; @@ -256,43 +256,43 @@ public: * @defgroup MPAL variables * */ - uint32 mpalError; - LPITEMIRQFUNCTION lpiifCustom; - LPLPCUSTOMFUNCTION lplpFunctions; - Common::String *lplpFunctionStrings; - uint16 nObjs; - uint16 nVars; - HGLOBAL hVars; - LPMPALVAR lpmvVars; - uint16 nMsgs; - HGLOBAL hMsgs; - LPMPALMSG lpmmMsgs; - uint16 nDialogs; - HGLOBAL hDialogs; - LPMPALDIALOG lpmdDialogs; - uint16 nItems; - HGLOBAL hItems; - LPMPALITEM lpmiItems; - uint16 nLocations; - HGLOBAL hLocations; - LPMPALLOCATION lpmlLocations; - uint16 nScripts; - HGLOBAL hScripts; - LPMPALSCRIPT lpmsScripts; - Common::File hMpr; - uint16 nResources; - uint32 *lpResources; - bool bExecutingAction; - bool bExecutingDialog; - uint32 nPollingLocations[MAXPOLLINGLOCATIONS]; - uint32 hEndPollingLocations[MAXPOLLINGLOCATIONS]; - uint32 PollingThreads[MAXPOLLINGLOCATIONS]; - uint32 hAskChoice; - uint32 hDoneChoice; - uint32 nExecutingAction; - uint32 nExecutingDialog; - uint32 nExecutingChoice; - uint32 nSelectedChoice; + uint32 _mpalError; + LPITEMIRQFUNCTION _lpiifCustom; + LPLPCUSTOMFUNCTION _lplpFunctions; + Common::String *_lplpFunctionStrings; + uint16 _nObjs; + uint16 _nVars; + HGLOBAL _hVars; + LPMPALVAR _lpmvVars; + uint16 _nMsgs; + HGLOBAL _hMsgs; + LPMPALMSG _lpmmMsgs; + uint16 _nDialogs; + HGLOBAL _hDialogs; + LPMPALDIALOG _lpmdDialogs; + uint16 _nItems; + HGLOBAL _hItems; + LPMPALITEM _lpmiItems; + uint16 _nLocations; + HGLOBAL _hLocations; + LPMPALLOCATION _lpmlLocations; + uint16 _nScripts; + HGLOBAL _hScripts; + LPMPALSCRIPT _lpmsScripts; + Common::File _hMpr; + uint16 _nResources; + uint32 *_lpResources; + bool _bExecutingAction; + bool _bExecutingDialog; + uint32 _nPollingLocations[MAXPOLLINGLOCATIONS]; + uint32 _hEndPollingLocations[MAXPOLLINGLOCATIONS]; + uint32 _pollingThreads[MAXPOLLINGLOCATIONS]; + uint32 _hAskChoice; + uint32 _hDoneChoice; + uint32 _nExecutingAction; + uint32 _nExecutingDialog; + uint32 _nExecutingChoice; + uint32 _nSelectedChoice; }; } // End of namespace Tony diff --git a/engines/tony/mpal/expr.cpp b/engines/tony/mpal/expr.cpp index a9d48e2016..516da98bb1 100644 --- a/engines/tony/mpal/expr.cpp +++ b/engines/tony/mpal/expr.cpp @@ -171,7 +171,7 @@ static int Compute(int a, int b, byte symbol) { case OP_OR: return a || b; default: - GLOBALS.mpalError = 1; + GLOBALS._mpalError = 1; break; } diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index 1f610a8d2c..6ed4545d67 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -84,15 +84,15 @@ static const byte *ParseScript(const byte *lpBuf, LPMPALSCRIPT lpmsScript) { lpBuf++; switch (lpmsScript->_command[curCmd].type) { case 1: - lpmsScript->_command[curCmd].nCf = READ_LE_UINT16(lpBuf); + lpmsScript->_command[curCmd]._nCf = READ_LE_UINT16(lpBuf); lpBuf += 2; - lpmsScript->_command[curCmd].arg1 = (int32)READ_LE_UINT32(lpBuf); + lpmsScript->_command[curCmd]._arg1 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmsScript->_command[curCmd].arg2 = (int32)READ_LE_UINT32(lpBuf); + lpmsScript->_command[curCmd]._arg2 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmsScript->_command[curCmd].arg3 = (int32)READ_LE_UINT32(lpBuf); + lpmsScript->_command[curCmd]._arg3 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmsScript->_command[curCmd].arg4 = (int32)READ_LE_UINT32(lpBuf); + lpmsScript->_command[curCmd]._arg4 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; break; @@ -197,15 +197,15 @@ static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { switch (lpmdDialog->_command[curCmd].type) { // Call custom function case 1: - lpmdDialog->_command[curCmd].nCf = READ_LE_UINT16(lpBuf); + lpmdDialog->_command[curCmd]._nCf = READ_LE_UINT16(lpBuf); lpBuf += 2; - lpmdDialog->_command[curCmd].arg1 = READ_LE_UINT32(lpBuf); + lpmdDialog->_command[curCmd]._arg1 = READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmdDialog->_command[curCmd].arg2 = READ_LE_UINT32(lpBuf); + lpmdDialog->_command[curCmd]._arg2 = READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmdDialog->_command[curCmd].arg3 = READ_LE_UINT32(lpBuf); + lpmdDialog->_command[curCmd]._arg3 = READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmdDialog->_command[curCmd].arg4 = READ_LE_UINT32(lpBuf); + lpmdDialog->_command[curCmd]._arg4 = READ_LE_UINT32(lpBuf); lpBuf += 4; break; @@ -398,15 +398,15 @@ static const byte *parseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { lpBuf++; switch (lpmiItem->_command[curCmd].type) { case 1: // Call custom function - lpmiItem->_command[curCmd].nCf = READ_LE_UINT16(lpBuf); + lpmiItem->_command[curCmd]._nCf = READ_LE_UINT16(lpBuf); lpBuf += 2; - lpmiItem->_command[curCmd].arg1 = (int32)READ_LE_UINT32(lpBuf); + lpmiItem->_command[curCmd]._arg1 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmiItem->_command[curCmd].arg2 = (int32)READ_LE_UINT32(lpBuf); + lpmiItem->_command[curCmd]._arg2 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmiItem->_command[curCmd].arg3 = (int32)READ_LE_UINT32(lpBuf); + lpmiItem->_command[curCmd]._arg3 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmiItem->_command[curCmd].arg4 = (int32)READ_LE_UINT32(lpBuf); + lpmiItem->_command[curCmd]._arg4 = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; break; @@ -535,58 +535,58 @@ bool ParseMpc(const byte *lpBuf) { return false; lpBuf += 4; - GLOBALS.nVars = READ_LE_UINT16(lpBuf); + GLOBALS._nVars = READ_LE_UINT16(lpBuf); lpBuf += 2; - GLOBALS.hVars = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof(MPALVAR) * (uint32)GLOBALS.nVars); - if (GLOBALS.hVars == NULL) + GLOBALS._hVars = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof(MPALVAR) * (uint32)GLOBALS._nVars); + if (GLOBALS._hVars == NULL) return false; - GLOBALS.lpmvVars = (LPMPALVAR)globalLock(GLOBALS.hVars); + GLOBALS._lpmvVars = (LPMPALVAR)globalLock(GLOBALS._hVars); - for (i = 0; i < GLOBALS.nVars; i++) { + for (i = 0; i < GLOBALS._nVars; i++) { wLen = *(const byte *)lpBuf; lpBuf++; - copyMemory(GLOBALS.lpmvVars->lpszVarName, lpBuf, MIN(wLen, (uint16)32)); + copyMemory(GLOBALS._lpmvVars->lpszVarName, lpBuf, MIN(wLen, (uint16)32)); lpBuf += wLen; - GLOBALS.lpmvVars->dwVal = READ_LE_UINT32(lpBuf); + GLOBALS._lpmvVars->dwVal = READ_LE_UINT32(lpBuf); lpBuf += 4; lpBuf++; // Salta 'ext' - GLOBALS.lpmvVars++; + GLOBALS._lpmvVars++; } - globalUnlock(GLOBALS.hVars); + globalUnlock(GLOBALS._hVars); /* 2. Messages */ if (lpBuf[0] != 'M' || lpBuf[1] != 'S' || lpBuf[2] != 'G' || lpBuf[3] != 'S') return false; lpBuf += 4; - GLOBALS.nMsgs = READ_LE_UINT16(lpBuf); + GLOBALS._nMsgs = READ_LE_UINT16(lpBuf); lpBuf += 2; #ifdef NEED_LOCK_MSGS - GLOBALS.hMsgs = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof(MPALMSG) * (uint32)GLOBALS.nMsgs); - if (GLOBALS.hMsgs == NULL) + GLOBALS._hMsgs = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof(MPALMSG) * (uint32)GLOBALS._nMsgs); + if (GLOBALS._hMsgs == NULL) return false; - GLOBALS.lpmmMsgs = (LPMPALMSG)globalLock(GLOBALS.hMsgs); + GLOBALS._lpmmMsgs = (LPMPALMSG)globalLock(GLOBALS._hMsgs); #else - GLOBALS.lpmmMsgs=(LPMPALMSG)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT,sizeof(MPALMSG)*(uint32)GLOBALS.nMsgs); - if (GLOBALS.lpmmMsgs==NULL) + GLOBALS._lpmmMsgs=(LPMPALMSG)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MPALMSG) * (uint32)GLOBALS._nMsgs); + if (GLOBALS._lpmmMsgs==NULL) return false; #endif - for (i = 0; i < GLOBALS.nMsgs; i++) { - GLOBALS.lpmmMsgs->wNum = READ_LE_UINT16(lpBuf); + for (i = 0; i < GLOBALS._nMsgs; i++) { + GLOBALS._lpmmMsgs->_wNum = READ_LE_UINT16(lpBuf); lpBuf += 2; for (j = 0; lpBuf[j] != 0;) j += lpBuf[j] + 1; - GLOBALS.lpmmMsgs->hText = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, j + 1); - lpTemp2 = lpTemp = (byte *)globalLock(GLOBALS.lpmmMsgs->hText); + GLOBALS._lpmmMsgs->_hText = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, j + 1); + lpTemp2 = lpTemp = (byte *)globalLock(GLOBALS._lpmmMsgs->_hText); for (j = 0; lpBuf[j] != 0;) { copyMemory(lpTemp, &lpBuf[j + 1], lpBuf[j]); @@ -598,12 +598,12 @@ bool ParseMpc(const byte *lpBuf) { lpBuf += j + 1; *lpTemp = '\0'; - globalUnlock(GLOBALS.lpmmMsgs->hText); - GLOBALS.lpmmMsgs++; + globalUnlock(GLOBALS._lpmmMsgs->_hText); + GLOBALS._lpmmMsgs++; } #ifdef NEED_LOCK_MSGS - globalUnlock(GLOBALS.hMsgs); + globalUnlock(GLOBALS._hMsgs); #endif /* 3. Objects */ @@ -611,86 +611,89 @@ bool ParseMpc(const byte *lpBuf) { return false; lpBuf += 4; - GLOBALS.nObjs = READ_LE_UINT16(lpBuf); + GLOBALS._nObjs = READ_LE_UINT16(lpBuf); lpBuf += 2; // Check out the dialogs - GLOBALS.nDialogs = 0; - GLOBALS.hDialogs = GLOBALS.lpmdDialogs = NULL; + GLOBALS._nDialogs = 0; + GLOBALS._hDialogs = GLOBALS._lpmdDialogs = NULL; if (*((const byte *)lpBuf + 2) == 6 && strncmp((const char *)lpBuf + 3, "Dialog", 6) == 0) { - GLOBALS.nDialogs = READ_LE_UINT16(lpBuf); lpBuf += 2; + GLOBALS._nDialogs = READ_LE_UINT16(lpBuf); + lpBuf += 2; - GLOBALS.hDialogs = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nDialogs * sizeof(MPALDIALOG)); - if (GLOBALS.hDialogs == NULL) + GLOBALS._hDialogs = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS._nDialogs * sizeof(MPALDIALOG)); + if (GLOBALS._hDialogs == NULL) return false; - GLOBALS.lpmdDialogs = (LPMPALDIALOG)globalLock(GLOBALS.hDialogs); + GLOBALS._lpmdDialogs = (LPMPALDIALOG)globalLock(GLOBALS._hDialogs); - for (i = 0;i < GLOBALS.nDialogs; i++) - if ((lpBuf = parseDialog(lpBuf + 7, &GLOBALS.lpmdDialogs[i])) == NULL) + for (i = 0;i < GLOBALS._nDialogs; i++) + if ((lpBuf = parseDialog(lpBuf + 7, &GLOBALS._lpmdDialogs[i])) == NULL) return false; - globalUnlock(GLOBALS.hDialogs); + globalUnlock(GLOBALS._hDialogs); } // Check the items - GLOBALS.nItems = 0; - GLOBALS.hItems = GLOBALS.lpmiItems = NULL; - if (*(lpBuf + 2) == 4 && strncmp((const char *)lpBuf + 3, "Item", 4)==0) { - GLOBALS.nItems = READ_LE_UINT16(lpBuf); + GLOBALS._nItems = 0; + GLOBALS._hItems = GLOBALS._lpmiItems = NULL; + if (*(lpBuf + 2) == 4 && strncmp((const char *)lpBuf + 3, "Item", 4) == 0) { + GLOBALS._nItems = READ_LE_UINT16(lpBuf); lpBuf += 2; // Allocate memory and read them in - GLOBALS.hItems = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nItems * sizeof(MPALITEM)); - if (GLOBALS.hItems == NULL) + GLOBALS._hItems = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS._nItems * sizeof(MPALITEM)); + if (GLOBALS._hItems == NULL) return false; - GLOBALS.lpmiItems = (LPMPALITEM)globalLock(GLOBALS.hItems); + GLOBALS._lpmiItems = (LPMPALITEM)globalLock(GLOBALS._hItems); - for (i = 0; i < GLOBALS.nItems; i++) - if ((lpBuf = parseItem(lpBuf + 5, &GLOBALS.lpmiItems[i])) == NULL) + for (i = 0; i < GLOBALS._nItems; i++) { + if ((lpBuf = parseItem(lpBuf + 5, &GLOBALS._lpmiItems[i])) == NULL) return false; + } - globalUnlock(GLOBALS.hItems); + globalUnlock(GLOBALS._hItems); } // Check the locations - GLOBALS.nLocations = 0; - GLOBALS.hLocations = GLOBALS.lpmlLocations = NULL; + GLOBALS._nLocations = 0; + GLOBALS._hLocations = GLOBALS._lpmlLocations = NULL; if (*(lpBuf + 2) == 8 && strncmp((const char *)lpBuf + 3, "Location", 8) == 0) { - GLOBALS.nLocations = READ_LE_UINT16(lpBuf); + GLOBALS._nLocations = READ_LE_UINT16(lpBuf); lpBuf += 2; // Allocate memory and read them in - GLOBALS.hLocations = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nLocations*sizeof(MPALLOCATION)); - if (GLOBALS.hLocations == NULL) + GLOBALS._hLocations = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS._nLocations * sizeof(MPALLOCATION)); + if (GLOBALS._hLocations == NULL) return false; - GLOBALS.lpmlLocations = (LPMPALLOCATION)globalLock(GLOBALS.hLocations); + GLOBALS._lpmlLocations = (LPMPALLOCATION)globalLock(GLOBALS._hLocations); - for (i = 0; i < GLOBALS.nLocations; i++) - if ((lpBuf = ParseLocation(lpBuf + 9, &GLOBALS.lpmlLocations[i])) == NULL) + for (i = 0; i < GLOBALS._nLocations; i++) { + if ((lpBuf = ParseLocation(lpBuf + 9, &GLOBALS._lpmlLocations[i])) == NULL) return false; + } - globalUnlock(GLOBALS.hLocations); + globalUnlock(GLOBALS._hLocations); } // Check the scripts - GLOBALS.nScripts = 0; - GLOBALS.hScripts = GLOBALS.lpmsScripts = NULL; + GLOBALS._nScripts = 0; + GLOBALS._hScripts = GLOBALS._lpmsScripts = NULL; if (*(lpBuf + 2) == 6 && strncmp((const char *)lpBuf + 3, "Script", 6) == 0) { - GLOBALS.nScripts = READ_LE_UINT16(lpBuf); + GLOBALS._nScripts = READ_LE_UINT16(lpBuf); lpBuf += 2; // Allocate memory - GLOBALS.hScripts = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS.nScripts * sizeof(MPALSCRIPT)); - if (GLOBALS.hScripts == NULL) + GLOBALS._hScripts = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS._nScripts * sizeof(MPALSCRIPT)); + if (GLOBALS._hScripts == NULL) return false; - GLOBALS.lpmsScripts = (LPMPALSCRIPT)globalLock(GLOBALS.hScripts); + GLOBALS._lpmsScripts = (LPMPALSCRIPT)globalLock(GLOBALS._hScripts); - for (i = 0; i < GLOBALS.nScripts; i++) { - if ((lpBuf = ParseScript(lpBuf + 7, &GLOBALS.lpmsScripts[i])) == NULL) + for (i = 0; i < GLOBALS._nScripts; i++) { + if ((lpBuf = ParseScript(lpBuf + 7, &GLOBALS._lpmsScripts[i])) == NULL) return false; // Sort the various moments of the script @@ -702,7 +705,7 @@ bool ParseMpc(const byte *lpBuf) { //); } - globalUnlock(GLOBALS.hScripts); + globalUnlock(GLOBALS._hScripts); } if (lpBuf[0] != 'E' || lpBuf[1] != 'N' || lpBuf[2] != 'D' || lpBuf[3] != '0') @@ -745,51 +748,51 @@ void FreeMpc() { int i; // Free variables - globalFree(GLOBALS.hVars); + globalFree(GLOBALS._hVars); // Free messages - LPMPALMSG lpmmMsgs = (LPMPALMSG)globalLock(GLOBALS.hMsgs); - for (i = 0; i < GLOBALS.nMsgs; i++, ++lpmmMsgs) - globalFree(lpmmMsgs->hText); + LPMPALMSG lpmmMsgs = (LPMPALMSG)globalLock(GLOBALS._hMsgs); + for (i = 0; i < GLOBALS._nMsgs; i++, ++lpmmMsgs) + globalFree(lpmmMsgs->_hText); - globalUnlock(GLOBALS.hMsgs); - globalFree(GLOBALS.hMsgs); + globalUnlock(GLOBALS._hMsgs); + globalFree(GLOBALS._hMsgs); // Free objects - if (GLOBALS.hDialogs) { - LPMPALDIALOG lpmdDialogs = (LPMPALDIALOG)globalLock(GLOBALS.hDialogs); + if (GLOBALS._hDialogs) { + LPMPALDIALOG lpmdDialogs = (LPMPALDIALOG)globalLock(GLOBALS._hDialogs); - for (i = 0; i < GLOBALS.nDialogs; i++, ++lpmdDialogs) + for (i = 0; i < GLOBALS._nDialogs; i++, ++lpmdDialogs) freeDialog(lpmdDialogs); - globalFree(GLOBALS.hDialogs); + globalFree(GLOBALS._hDialogs); } // Free items - if (GLOBALS.hItems) { - LPMPALITEM lpmiItems = (LPMPALITEM)globalLock(GLOBALS.hItems); + if (GLOBALS._hItems) { + LPMPALITEM lpmiItems = (LPMPALITEM)globalLock(GLOBALS._hItems); - for (i = 0; i < GLOBALS.nItems; ++i, ++lpmiItems) + for (i = 0; i < GLOBALS._nItems; ++i, ++lpmiItems) freeItem(lpmiItems); - globalUnlock(GLOBALS.hItems); - globalFree(GLOBALS.hItems); + globalUnlock(GLOBALS._hItems); + globalFree(GLOBALS._hItems); } // Free the locations - if (GLOBALS.hLocations) { - globalFree(GLOBALS.hLocations); + if (GLOBALS._hLocations) { + globalFree(GLOBALS._hLocations); } // Free the scripts - if (GLOBALS.hScripts) { - LPMPALSCRIPT lpmsScripts = (LPMPALSCRIPT)globalLock(GLOBALS.hScripts); + if (GLOBALS._hScripts) { + LPMPALSCRIPT lpmsScripts = (LPMPALSCRIPT)globalLock(GLOBALS._hScripts); - for (i = 0; i < GLOBALS.nScripts; ++i, ++lpmsScripts) { + for (i = 0; i < GLOBALS._nScripts; ++i, ++lpmsScripts) { FreeScript(lpmsScripts); } - globalUnlock(GLOBALS.hScripts); + globalUnlock(GLOBALS._hScripts); } } diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 5a4310c15b..162ba4c776 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -60,24 +60,22 @@ const char *mpalCopyright = * Locks the variables for access */ void lockVar(void) { - GLOBALS.lpmvVars = (LPMPALVAR)globalLock(GLOBALS.hVars); + GLOBALS._lpmvVars = (LPMPALVAR)globalLock(GLOBALS._hVars); } - /** * Unlocks variables after use */ void unlockVar(void) { - globalUnlock(GLOBALS.hVars); + globalUnlock(GLOBALS._hVars); } - /** * Locks the messages for access */ static void LockMsg(void) { #ifdef NEED_LOCK_MSGS - GLOBALS.lpmmMsgs = (LPMPALMSG)globalLock(GLOBALS.hMsgs); + GLOBALS._lpmmMsgs = (LPMPALMSG)globalLock(GLOBALS._hMsgs); #endif } @@ -87,7 +85,7 @@ static void LockMsg(void) { */ static void UnlockMsg(void) { #ifdef NEED_LOCK_MSGS - globalUnlock(GLOBALS.hMsgs); + globalUnlock(GLOBALS._hMsgs); #endif } @@ -96,7 +94,7 @@ static void UnlockMsg(void) { * Locks the dialogs for access */ static void lockDialogs(void) { - GLOBALS.lpmdDialogs = (LPMPALDIALOG)globalLock(GLOBALS.hDialogs); + GLOBALS._lpmdDialogs = (LPMPALDIALOG)globalLock(GLOBALS._hDialogs); } @@ -104,7 +102,7 @@ static void lockDialogs(void) { * Unlocks the dialogs after use */ static void unlockDialogs(void) { - globalUnlock(GLOBALS.hDialogs); + globalUnlock(GLOBALS._hDialogs); } @@ -112,7 +110,7 @@ static void unlockDialogs(void) { * Locks the location data structures for access */ static void lockLocations(void) { - GLOBALS.lpmlLocations = (LPMPALLOCATION)globalLock(GLOBALS.hLocations); + GLOBALS._lpmlLocations = (LPMPALLOCATION)globalLock(GLOBALS._hLocations); } @@ -120,7 +118,7 @@ static void lockLocations(void) { * Unlocks the location structures after use */ static void unlockLocations(void) { - globalUnlock(GLOBALS.hLocations); + globalUnlock(GLOBALS._hLocations); } @@ -128,7 +126,7 @@ static void unlockLocations(void) { * Locks the items structures for use */ static void lockItems(void) { - GLOBALS.lpmiItems = (LPMPALITEM)globalLock(GLOBALS.hItems); + GLOBALS._lpmiItems = (LPMPALITEM)globalLock(GLOBALS._hItems); } @@ -136,7 +134,7 @@ static void lockItems(void) { * Unlocks the items structures after use */ static void unlockItems(void) { - globalUnlock(GLOBALS.hItems); + globalUnlock(GLOBALS._hItems); } @@ -144,7 +142,7 @@ static void unlockItems(void) { * Locks the script data structures for use */ static void LockScripts(void) { - GLOBALS.lpmsScripts = (LPMPALSCRIPT)globalLock(GLOBALS.hScripts); + GLOBALS._lpmsScripts = (LPMPALSCRIPT)globalLock(GLOBALS._hScripts); } @@ -152,7 +150,7 @@ static void LockScripts(void) { * Unlocks the script data structures after use */ static void unlockScripts(void) { - globalUnlock(GLOBALS.hScripts); + globalUnlock(GLOBALS._hScripts); } @@ -167,13 +165,13 @@ static void unlockScripts(void) { */ int32 varGetValue(const char *lpszVarName) { int i; - LPMPALVAR v=GLOBALS.lpmvVars; + LPMPALVAR v = GLOBALS._lpmvVars; - for (i = 0; i < GLOBALS.nVars; v++, i++) + for (i = 0; i < GLOBALS._nVars; v++, i++) if (strcmp(lpszVarName, v->lpszVarName) == 0) return v->dwVal; - GLOBALS.mpalError = 1; + GLOBALS._mpalError = 1; return 0; } @@ -185,24 +183,24 @@ int32 varGetValue(const char *lpszVarName) { */ void varSetValue(const char *lpszVarName, int32 val) { uint i; - LPMPALVAR v = GLOBALS.lpmvVars; + LPMPALVAR v = GLOBALS._lpmvVars; - for (i = 0; i < GLOBALS.nVars; v++, i++) + for (i = 0; i < GLOBALS._nVars; v++, i++) if (strcmp(lpszVarName, v->lpszVarName) == 0) { v->dwVal = val; - if (GLOBALS.lpiifCustom != NULL && strncmp(v->lpszVarName, "Pattern.", 8) == 0) { + if (GLOBALS._lpiifCustom != NULL && strncmp(v->lpszVarName, "Pattern.", 8) == 0) { i = 0; sscanf(v->lpszVarName, "Pattern.%u", &i); - GLOBALS.lpiifCustom(i, val, -1); - } else if (GLOBALS.lpiifCustom != NULL && strncmp(v->lpszVarName, "Status.", 7) == 0) { + GLOBALS._lpiifCustom(i, val, -1); + } else if (GLOBALS._lpiifCustom != NULL && strncmp(v->lpszVarName, "Status.", 7) == 0) { i = 0; sscanf(v->lpszVarName,"Status.%u", &i); - GLOBALS.lpiifCustom(i, -1, val); + GLOBALS._lpiifCustom(i, -1, val); } return; } - GLOBALS.mpalError = 1; + GLOBALS._mpalError = 1; return; } @@ -217,9 +215,9 @@ void varSetValue(const char *lpszVarName, int32 val) { */ static int locGetOrderFromNum(uint32 nLoc) { int i; - LPMPALLOCATION loc = GLOBALS.lpmlLocations; + LPMPALLOCATION loc = GLOBALS._lpmlLocations; - for (i = 0; i < GLOBALS.nLocations; i++, loc++) + for (i = 0; i < GLOBALS._nLocations; i++, loc++) if (loc->nObj == nLoc) return i; @@ -236,10 +234,10 @@ static int locGetOrderFromNum(uint32 nLoc) { */ static int msgGetOrderFromNum(uint32 nMsg) { int i; - LPMPALMSG msg = GLOBALS.lpmmMsgs; + LPMPALMSG msg = GLOBALS._lpmmMsgs; - for (i = 0; i < GLOBALS.nMsgs; i++, msg++) - if (msg->wNum == nMsg) + for (i = 0; i < GLOBALS._nMsgs; i++, msg++) + if (msg->_wNum == nMsg) return i; return -1; @@ -254,9 +252,9 @@ static int msgGetOrderFromNum(uint32 nMsg) { */ static int itemGetOrderFromNum(uint32 nItem) { int i; - LPMPALITEM item = GLOBALS.lpmiItems; + LPMPALITEM item = GLOBALS._lpmiItems; - for (i = 0; i < GLOBALS.nItems; i++, item++) + for (i = 0; i < GLOBALS._nItems; i++, item++) if (item->nObj == nItem) return i; @@ -273,9 +271,9 @@ static int itemGetOrderFromNum(uint32 nItem) { */ static int scriptGetOrderFromNum(uint32 nScript) { int i; - LPMPALSCRIPT script = GLOBALS.lpmsScripts; + LPMPALSCRIPT script = GLOBALS._lpmsScripts; - for (i = 0; i < GLOBALS.nScripts; i++, script++) + for (i = 0; i < GLOBALS._nScripts; i++, script++) if (script->nObj == nScript) return i; @@ -292,9 +290,9 @@ static int scriptGetOrderFromNum(uint32 nScript) { */ static int dialogGetOrderFromNum(uint32 nDialog) { int i; - LPMPALDIALOG dialog = GLOBALS.lpmdDialogs; + LPMPALDIALOG dialog = GLOBALS._lpmdDialogs; - for (i = 0; i < GLOBALS.nDialogs; i++, dialog++) + for (i = 0; i < GLOBALS._nDialogs; i++, dialog++) if (dialog->nObj == nDialog) return i; @@ -316,7 +314,7 @@ static char *DuplicateMessage(uint32 nMsgOrd) { if (nMsgOrd == (uint32)-1) return NULL; - origmsg = (const char *)globalLock(GLOBALS.lpmmMsgs[nMsgOrd].hText); + origmsg = (const char *)globalLock(GLOBALS._lpmmMsgs[nMsgOrd]._hText); j = 0; while (origmsg[j] != '\0' || origmsg[j + 1] != '\0') @@ -328,7 +326,7 @@ static char *DuplicateMessage(uint32 nMsgOrd) { return NULL; copyMemory(clonemsg, origmsg, j); - globalUnlock(GLOBALS.lpmmMsgs[nMsgOrd].hText); + globalUnlock(GLOBALS._lpmmMsgs[nMsgOrd]._hText); return clonemsg; } @@ -344,7 +342,7 @@ static char *DuplicateMessage(uint32 nMsgOrd) { static char *duplicateDialogPeriod(uint32 nPeriod) { const char *origmsg; char *clonemsg; - LPMPALDIALOG dialog = GLOBALS.lpmdDialogs + GLOBALS.nExecutingDialog; + LPMPALDIALOG dialog = GLOBALS._lpmdDialogs + GLOBALS._nExecutingDialog; int i, j; for (j = 0; dialog->_periods[j] != NULL; j++) @@ -385,28 +383,28 @@ HGLOBAL resLoad(uint32 dwId) { uint32 nSizeComp, nSizeDecomp; byte *temp, *buf; - for (i = 0; i < GLOBALS.nResources; i++) - if (GLOBALS.lpResources[i * 2] == dwId) { - GLOBALS.hMpr.seek(GLOBALS.lpResources[i * 2 + 1]); - nBytesRead = GLOBALS.hMpr.read(head, 4); + for (i = 0; i < GLOBALS._nResources; i++) + if (GLOBALS._lpResources[i * 2] == dwId) { + GLOBALS._hMpr.seek(GLOBALS._lpResources[i * 2 + 1]); + nBytesRead = GLOBALS._hMpr.read(head, 4); if (nBytesRead != 4) return NULL; if (head[0] != 'R' || head[1] != 'E' || head[2] != 'S' || head[3] != 'D') return NULL; - nSizeDecomp = GLOBALS.hMpr.readUint32LE(); - if (GLOBALS.hMpr.err()) + nSizeDecomp = GLOBALS._hMpr.readUint32LE(); + if (GLOBALS._hMpr.err()) return NULL; - nSizeComp = GLOBALS.hMpr.readUint32LE(); - if (GLOBALS.hMpr.err()) + nSizeComp = GLOBALS._hMpr.readUint32LE(); + if (GLOBALS._hMpr.err()) return NULL; h = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, nSizeDecomp + (nSizeDecomp / 1024) * 16); buf = (byte *)globalLock(h); temp = (byte *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT,nSizeComp); - nBytesRead = GLOBALS.hMpr.read(temp, nSizeComp); + nBytesRead = GLOBALS._hMpr.read(temp, nSizeComp); if (nBytesRead != nSizeComp) return NULL; @@ -425,7 +423,7 @@ HGLOBAL resLoad(uint32 dwId) { static uint32 *getSelectList(uint32 i) { uint32 *sl; int j, k, num; - LPMPALDIALOG dialog = GLOBALS.lpmdDialogs+GLOBALS.nExecutingDialog; + LPMPALDIALOG dialog = GLOBALS._lpmdDialogs + GLOBALS._nExecutingDialog; /* Count how many are active selects */ num = 0; @@ -454,10 +452,10 @@ static uint32 *getSelectList(uint32 i) { static uint32 *GetItemList(uint32 nLoc) { uint32 *il; uint32 num,i,j; - LPMPALVAR v = GLOBALS.lpmvVars; + LPMPALVAR v = GLOBALS._lpmvVars; num = 0; - for (i = 0; i < GLOBALS.nVars; i++, v++) { + for (i = 0; i < GLOBALS._nVars; i++, v++) { if (strncmp(v->lpszVarName,"Location",8) == 0 && v->dwVal == nLoc) num++; } @@ -466,9 +464,9 @@ static uint32 *GetItemList(uint32 nLoc) { if (il == NULL) return NULL; - v = GLOBALS.lpmvVars; + v = GLOBALS._lpmvVars; j = 0; - for (i = 0; i < GLOBALS.nVars; i++, v++) { + for (i = 0; i < GLOBALS._nVars; i++, v++) { if (strncmp(v->lpszVarName, "Location", 8) == 0 && v->dwVal == nLoc) { sscanf(v->lpszVarName, "Location.%u", &il[j]); j++; @@ -480,7 +478,7 @@ static uint32 *GetItemList(uint32 nLoc) { } static LPITEM getItemData(uint32 nOrdItem) { - LPMPALITEM curitem = GLOBALS.lpmiItems+nOrdItem; + LPMPALITEM curitem = GLOBALS._lpmiItems + nOrdItem; LPITEM ret; HGLOBAL hDat; char *dat; @@ -592,7 +590,7 @@ void CustomThread(CORO_PARAM, const void *param) { _ctx->p = *(LPCFCALL *)param; - CORO_INVOKE_4(GLOBALS.lplpFunctions[_ctx->p->nCf], _ctx->p->arg1, _ctx->p->arg2, _ctx->p->arg3, _ctx->p->arg4); + CORO_INVOKE_4(GLOBALS._lplpFunctions[_ctx->p->_nCf], _ctx->p->_arg1, _ctx->p->_arg2, _ctx->p->_arg3, _ctx->p->_arg4); globalFree(_ctx->p); @@ -645,21 +643,21 @@ void ScriptThread(CORO_PARAM, const void *param) { if (s->_command[_ctx->k].type == 1) { _ctx->p = (LPCFCALL)globalAlloc(GMEM_FIXED, sizeof(CFCALL)); if (_ctx->p == NULL) { - GLOBALS.mpalError = 1; + GLOBALS._mpalError = 1; CORO_KILL_SELF(); return; } - _ctx->p->nCf=s->_command[_ctx->k].nCf; - _ctx->p->arg1=s->_command[_ctx->k].arg1; - _ctx->p->arg2=s->_command[_ctx->k].arg2; - _ctx->p->arg3=s->_command[_ctx->k].arg3; - _ctx->p->arg4=s->_command[_ctx->k].arg4; + _ctx->p->_nCf = s->_command[_ctx->k]._nCf; + _ctx->p->_arg1 = s->_command[_ctx->k]._arg1; + _ctx->p->_arg2 = s->_command[_ctx->k]._arg2; + _ctx->p->_arg3 = s->_command[_ctx->k]._arg3; + _ctx->p->_arg4 = s->_command[_ctx->k]._arg4; // !!! New process management if ((cfHandles[_ctx->numHandles++] = CoroScheduler.createProcess(CustomThread, &_ctx->p, sizeof(LPCFCALL))) == 0) { - GLOBALS.mpalError = 1; + GLOBALS._mpalError = 1; CORO_KILL_SELF(); return; @@ -673,7 +671,7 @@ void ScriptThread(CORO_PARAM, const void *param) { unlockVar(); } else { - GLOBALS.mpalError = 1; + GLOBALS._mpalError = 1; globalFree(s); CORO_KILL_SELF(); @@ -707,23 +705,23 @@ void ActionThread(CORO_PARAM, const void *param) { CORO_BEGIN_CODE(_ctx); - GLOBALS.mpalError = 0; + GLOBALS._mpalError = 0; for (_ctx->j = 0; _ctx->j < item->Action[item->dwRes].nCmds; _ctx->j++) { _ctx->k = item->Action[item->dwRes].CmdNum[_ctx->j]; if (item->_command[_ctx->k].type == 1) { // Custom function debugC(DEBUG_DETAILED, kTonyDebugActions, "Action Process %d Call=%s params=%d,%d,%d,%d", - CoroScheduler.getCurrentPID(), GLOBALS.lplpFunctionStrings[item->_command[_ctx->k].nCf].c_str(), - item->_command[_ctx->k].arg1, item->_command[_ctx->k].arg2, - item->_command[_ctx->k].arg3, item->_command[_ctx->k].arg4 + CoroScheduler.getCurrentPID(), GLOBALS._lplpFunctionStrings[item->_command[_ctx->k]._nCf].c_str(), + item->_command[_ctx->k]._arg1, item->_command[_ctx->k]._arg2, + item->_command[_ctx->k]._arg3, item->_command[_ctx->k]._arg4 ); - CORO_INVOKE_4(GLOBALS.lplpFunctions[item->_command[_ctx->k].nCf], - item->_command[_ctx->k].arg1, - item->_command[_ctx->k].arg2, - item->_command[_ctx->k].arg3, - item->_command[_ctx->k].arg4 + CORO_INVOKE_4(GLOBALS._lplpFunctions[item->_command[_ctx->k]._nCf], + item->_command[_ctx->k]._arg1, + item->_command[_ctx->k]._arg2, + item->_command[_ctx->k]._arg3, + item->_command[_ctx->k]._arg4 ); } else if (item->_command[_ctx->k].type == 2) { @@ -736,7 +734,7 @@ void ActionThread(CORO_PARAM, const void *param) { unlockVar(); } else { - GLOBALS.mpalError = 1; + GLOBALS._mpalError = 1; break; } } @@ -765,7 +763,7 @@ void ShutUpActionThread(CORO_PARAM, const void *param) { CORO_INVOKE_2(CoroScheduler.waitForSingleObject, pid, CORO_INFINITE); - GLOBALS.bExecutingAction = false; + GLOBALS._bExecutingAction = false; if (_vm->_initialLoadSlotNumber != -1) { _ctx->slotNumber = _vm->_initialLoadSlotNumber; @@ -825,7 +823,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { CORO_BEGIN_CODE(_ctx); /* To begin with, we need to request the item list from the location */ - _ctx->il = mpalQueryItemList(GLOBALS.nPollingLocations[id]); + _ctx->il = mpalQueryItemList(GLOBALS._nPollingLocations[id]); /* Count the items */ for (_ctx->numitems = 0; _ctx->il[_ctx->numitems] != 0; _ctx->numitems++) @@ -840,7 +838,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { if (_ctx->ord == -1) continue; - _ctx->curItem = GLOBALS.lpmiItems + _ctx->ord; + _ctx->curItem = GLOBALS._lpmiItems + _ctx->ord; _ctx->k = 0; for (_ctx->j = 0; _ctx->j < _ctx->curItem->nActions; _ctx->j++) @@ -889,9 +887,9 @@ void LocationPollThread(CORO_PARAM, const void *param) { if (_ctx->il[_ctx->i] == 0) continue; - _ctx->curItem = GLOBALS.lpmiItems + itemGetOrderFromNum(_ctx->il[_ctx->i]); + _ctx->curItem = GLOBALS._lpmiItems + itemGetOrderFromNum(_ctx->il[_ctx->i]); - for (_ctx->j = 0; _ctx->j < _ctx->curItem->nActions; _ctx->j++) + for (_ctx->j = 0; _ctx->j < _ctx->curItem->nActions; _ctx->j++) { if (_ctx->curItem->Action[_ctx->j].num == 0xFF) { _ctx->MyActions[_ctx->k].nItem = _ctx->il[_ctx->i]; _ctx->MyActions[_ctx->k].nAction = _ctx->j; @@ -906,6 +904,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { _ctx->MyActions[_ctx->k].dwLastTime = _vm->getTime(); _ctx->k++; } + } } unlockItems(); @@ -929,7 +928,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { _ctx->dwSleepTime = MIN(_ctx->dwSleepTime, _ctx->MyActions[_ctx->k].dwLastTime + _ctx->MyActions[_ctx->k].wTime - _ctx->curTime); /* We fall alseep, but always checking that the event is set when prompted for closure */ - CORO_INVOKE_3(CoroScheduler.waitForSingleObject, GLOBALS.hEndPollingLocations[id], _ctx->dwSleepTime, &_ctx->expired); + CORO_INVOKE_3(CoroScheduler.waitForSingleObject, GLOBALS._hEndPollingLocations[id], _ctx->dwSleepTime, &_ctx->expired); //if (_ctx->k == WAIT_OBJECT_0) if (!_ctx->expired) @@ -955,7 +954,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { byte randomVal = (byte)_vm->_randomSource.getRandomNumber(99); if (randomVal < _ctx->MyActions[_ctx->k].perc) { /* Check if there is an action running on the item */ - if ((GLOBALS.bExecutingAction) && (GLOBALS.nExecutingAction == _ctx->MyActions[_ctx->k].nItem)) + if ((GLOBALS._bExecutingAction) && (GLOBALS._nExecutingAction == _ctx->MyActions[_ctx->k].nItem)) continue; /* Check to see if there already another idle funning running on the item */ @@ -968,7 +967,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { /* Ok, we are the only ones :) */ lockItems(); - _ctx->curItem=GLOBALS.lpmiItems+itemGetOrderFromNum(_ctx->MyActions[_ctx->k].nItem); + _ctx->curItem = GLOBALS._lpmiItems + itemGetOrderFromNum(_ctx->MyActions[_ctx->k].nItem); /* Check if there is a WhenExecute expression */ _ctx->j=_ctx->MyActions[_ctx->k].nAction; @@ -1021,7 +1020,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { // Set idle skip on - CORO_INVOKE_4(GLOBALS.lplpFunctions[200], 0, 0, 0, 0); + CORO_INVOKE_4(GLOBALS._lplpFunctions[200], 0, 0, 0, 0); for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) if (_ctx->MyThreads[_ctx->i].nItem != 0) { @@ -1036,7 +1035,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { } // Set idle skip off - CORO_INVOKE_4(GLOBALS.lplpFunctions[201], 0, 0, 0, 0); + CORO_INVOKE_4(GLOBALS._lplpFunctions[201], 0, 0, 0, 0); /* We're finished */ globalDestroy(_ctx->MyThreads); @@ -1067,11 +1066,11 @@ void ShutUpDialogThread(CORO_PARAM, const void *param) { CORO_INVOKE_2(CoroScheduler.waitForSingleObject, pid, CORO_INFINITE); - GLOBALS.bExecutingDialog = false; - GLOBALS.nExecutingDialog = 0; - GLOBALS.nExecutingChoice = 0; + GLOBALS._bExecutingDialog = false; + GLOBALS._nExecutingDialog = 0; + GLOBALS._nExecutingChoice = 0; - CoroScheduler.setEvent(GLOBALS.hAskChoice); + CoroScheduler.setEvent(GLOBALS._hAskChoice); CORO_KILL_SELF(); @@ -1100,7 +1099,7 @@ void GroupThread(CORO_PARAM, const void *param) { lockDialogs(); // Find the pointer to the current _ctx->dialog - _ctx->dialog = GLOBALS.lpmdDialogs + GLOBALS.nExecutingDialog; + _ctx->dialog = GLOBALS._lpmdDialogs + GLOBALS._nExecutingDialog; // Search inside the group requesting the _ctx->dialog for (_ctx->i = 0; _ctx->dialog->_group[_ctx->i].num != 0; _ctx->i++) { @@ -1112,11 +1111,11 @@ void GroupThread(CORO_PARAM, const void *param) { _ctx->type = _ctx->dialog->_command[_ctx->k].type; if (_ctx->type == 1) { // Call custom function - CORO_INVOKE_4(GLOBALS.lplpFunctions[_ctx->dialog->_command[_ctx->k].nCf], - _ctx->dialog->_command[_ctx->k].arg1, - _ctx->dialog->_command[_ctx->k].arg2, - _ctx->dialog->_command[_ctx->k].arg3, - _ctx->dialog->_command[_ctx->k].arg4 + CORO_INVOKE_4(GLOBALS._lplpFunctions[_ctx->dialog->_command[_ctx->k]._nCf], + _ctx->dialog->_command[_ctx->k]._arg1, + _ctx->dialog->_command[_ctx->k]._arg2, + _ctx->dialog->_command[_ctx->k]._arg3, + _ctx->dialog->_command[_ctx->k]._arg4 ); } else if (_ctx->type == 2) { @@ -1130,7 +1129,7 @@ void GroupThread(CORO_PARAM, const void *param) { CORO_INVOKE_1(doChoice, (uint32)_ctx->dialog->_command[_ctx->k].nChoice); } else { - GLOBALS.mpalError = 1; + GLOBALS._mpalError = 1; unlockDialogs(); CORO_KILL_SELF(); @@ -1147,7 +1146,7 @@ void GroupThread(CORO_PARAM, const void *param) { } /* If we are here, it means that we have not found the requested group */ - GLOBALS.mpalError = 1; + GLOBALS._mpalError = 1; unlockDialogs(); CORO_KILL_SELF(); @@ -1174,7 +1173,7 @@ void doChoice(CORO_PARAM, uint32 nChoice) { lockDialogs(); /* Get a pointer to the current dialog */ - _ctx->dialog = GLOBALS.lpmdDialogs + GLOBALS.nExecutingDialog; + _ctx->dialog = GLOBALS._lpmdDialogs + GLOBALS._nExecutingDialog; /* Search the choice between those required in the dialog */ for (_ctx->i = 0; _ctx->dialog->_choice[_ctx->i].nChoice != 0; _ctx->i++) @@ -1184,7 +1183,7 @@ void doChoice(CORO_PARAM, uint32 nChoice) { /* If nothing has been found, exit with an error */ if (_ctx->dialog->_choice[_ctx->i].nChoice == 0) { /* If we're here, we did not find the required choice */ - GLOBALS.mpalError = 1; + GLOBALS._mpalError = 1; unlockDialogs(); CORO_KILL_SELF(); @@ -1192,10 +1191,10 @@ void doChoice(CORO_PARAM, uint32 nChoice) { } /* We've found the requested choice. Remember what in global variables */ - GLOBALS.nExecutingChoice = _ctx->i; + GLOBALS._nExecutingChoice = _ctx->i; while (1) { - GLOBALS.nExecutingChoice = _ctx->i; + GLOBALS._nExecutingChoice = _ctx->i; _ctx->k = 0; /* Calculate the expression of each selection, to see if they're active or inactive */ @@ -1216,13 +1215,13 @@ void doChoice(CORO_PARAM, uint32 nChoice) { } /* There are choices available to the user, so wait for them to make one */ - CoroScheduler.resetEvent(GLOBALS.hDoneChoice); - CoroScheduler.setEvent(GLOBALS.hAskChoice); - CORO_INVOKE_2(CoroScheduler.waitForSingleObject, GLOBALS.hDoneChoice, CORO_INFINITE); + CoroScheduler.resetEvent(GLOBALS._hDoneChoice); + CoroScheduler.setEvent(GLOBALS._hAskChoice); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, GLOBALS._hDoneChoice, CORO_INFINITE); /* Now that the choice has been made, we can run the groups associated with the choice tbontbtitq */ - _ctx->j = GLOBALS.nSelectedChoice; + _ctx->j = GLOBALS._nSelectedChoice; for (_ctx->k = 0; _ctx->dialog->_choice[_ctx->i]._select[_ctx->j].wPlayGroup[_ctx->k] != 0; _ctx->k++) { _ctx->nGroup = _ctx->dialog->_choice[_ctx->i]._select[_ctx->j].wPlayGroup[_ctx->k]; CORO_INVOKE_1(GroupThread, &_ctx->nGroup); @@ -1266,7 +1265,7 @@ void doChoice(CORO_PARAM, uint32 nChoice) { * by calling LockItem(). */ static uint32 doAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { - LPMPALITEM item = GLOBALS.lpmiItems; + LPMPALITEM item = GLOBALS._lpmiItems; int i; LPMPALITEM newitem; uint32 h; @@ -1311,8 +1310,8 @@ static uint32 doAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { if (CoroScheduler.createProcess(ShutUpActionThread, &h, sizeof(uint32)) == CORO_INVALID_PID_VALUE) return CORO_INVALID_PID_VALUE; - GLOBALS.nExecutingAction = item->nObj; - GLOBALS.bExecutingAction = true; + GLOBALS._nExecutingAction = item->nObj; + GLOBALS._bExecutingAction = true; return h; } @@ -1335,13 +1334,13 @@ static uint32 doDialog(uint32 nDlgOrd, uint32 nGroup) { uint32 h; // Store the running dialog in a global variable - GLOBALS.nExecutingDialog = nDlgOrd; + GLOBALS._nExecutingDialog = nDlgOrd; // Enables the flag to indicate that there is' a running dialogue - GLOBALS.bExecutingDialog = true; + GLOBALS._bExecutingDialog = true; - CoroScheduler.resetEvent(GLOBALS.hAskChoice); - CoroScheduler.resetEvent(GLOBALS.hDoneChoice); + CoroScheduler.resetEvent(GLOBALS._hAskChoice); + CoroScheduler.resetEvent(GLOBALS._hDoneChoice); // Create a thread that performs the dialogue group @@ -1369,7 +1368,7 @@ static uint32 doDialog(uint32 nDlgOrd, uint32 nGroup) { * @returns True if everything is OK, false on failure */ bool doSelection(uint32 i, uint32 dwData) { - LPMPALDIALOG dialog = GLOBALS.lpmdDialogs+GLOBALS.nExecutingDialog; + LPMPALDIALOG dialog = GLOBALS._lpmdDialogs + GLOBALS._nExecutingDialog; int j; for (j = 0; dialog->_choice[i]._select[j].dwData != 0; j++) @@ -1379,8 +1378,8 @@ bool doSelection(uint32 i, uint32 dwData) { if (dialog->_choice[i]._select[j].dwData == 0) return false; - GLOBALS.nSelectedChoice = j; - CoroScheduler.setEvent(GLOBALS.hDoneChoice); + GLOBALS._nSelectedChoice = j; + CoroScheduler.setEvent(GLOBALS._hDoneChoice); return true; } @@ -1411,8 +1410,8 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, //printf("Dialog: %lu\n", sizeof(MPALDIALOG)); /* Save the array of custom functions */ - GLOBALS.lplpFunctions = lplpcfArray; - GLOBALS.lplpFunctionStrings = lpcfStrings; + GLOBALS._lplpFunctions = lplpcfArray; + GLOBALS._lplpFunctionStrings = lpcfStrings; /* OPen the MPC file for reading */ if (!hMpc.open(lpszMpcFileName)) @@ -1489,61 +1488,61 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, */ /* Open the MPR file */ - if (!GLOBALS.hMpr.open(lpszMprFileName)) + if (!GLOBALS._hMpr.open(lpszMprFileName)) return false; /* Seek to the end of the file to read overall information */ - GLOBALS.hMpr.seek(-12, SEEK_END); + GLOBALS._hMpr.seek(-12, SEEK_END); - dwSizeComp = GLOBALS.hMpr.readUint32LE(); - if (GLOBALS.hMpr.err()) + dwSizeComp = GLOBALS._hMpr.readUint32LE(); + if (GLOBALS._hMpr.err()) return false; - GLOBALS.nResources = GLOBALS.hMpr.readUint32LE(); - if (GLOBALS.hMpr.err()) + GLOBALS._nResources = GLOBALS._hMpr.readUint32LE(); + if (GLOBALS._hMpr.err()) return false; - nBytesRead = GLOBALS.hMpr.read(buf, 4); - if (GLOBALS.hMpr.err()) + nBytesRead = GLOBALS._hMpr.read(buf, 4); + if (GLOBALS._hMpr.err()) return false; if (buf[0] !='E' || buf[1] != 'N' || buf[2] != 'D' || buf[3] != '0') return false; /* Move to the start of the resources header */ - GLOBALS.hMpr.seek(-(12 + (int)dwSizeComp), SEEK_END); + GLOBALS._hMpr.seek(-(12 + (int)dwSizeComp), SEEK_END); - GLOBALS.lpResources = (uint32 *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, GLOBALS.nResources * 8); - if (GLOBALS.lpResources == NULL) + GLOBALS._lpResources = (uint32 *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, GLOBALS._nResources * 8); + if (GLOBALS._lpResources == NULL) return false; cmpbuf = (byte *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, dwSizeComp); if (cmpbuf == NULL) return false; - nBytesRead = GLOBALS.hMpr.read(cmpbuf, dwSizeComp); + nBytesRead = GLOBALS._hMpr.read(cmpbuf, dwSizeComp); if (nBytesRead != dwSizeComp) return false; - lzo1x_decompress((const byte *)cmpbuf, dwSizeComp, (byte *)GLOBALS.lpResources, (uint32 *)&nBytesRead); - if (nBytesRead != (uint32)GLOBALS.nResources * 8) + lzo1x_decompress((const byte *)cmpbuf, dwSizeComp, (byte *)GLOBALS._lpResources, (uint32 *)&nBytesRead); + if (nBytesRead != (uint32)GLOBALS._nResources * 8) return false; globalDestroy(cmpbuf); /* Reset back to the start of the file, leaving it open */ - GLOBALS.hMpr.seek(0, SEEK_SET); + GLOBALS._hMpr.seek(0, SEEK_SET); /* There is no action or dialog running by default */ - GLOBALS.bExecutingAction = false; - GLOBALS.bExecutingDialog = false; + GLOBALS._bExecutingAction = false; + GLOBALS._bExecutingDialog = false; /* There's no polling location */ - Common::fill(GLOBALS.nPollingLocations, GLOBALS.nPollingLocations + MAXPOLLINGLOCATIONS, 0); + Common::fill(GLOBALS._nPollingLocations, GLOBALS._nPollingLocations + MAXPOLLINGLOCATIONS, 0); /* Create the event that will be used to co-ordinate making choices and choices finishing */ - GLOBALS.hAskChoice = CoroScheduler.createEvent(true, false); - GLOBALS.hDoneChoice = CoroScheduler.createEvent(true, false); + GLOBALS._hAskChoice = CoroScheduler.createEvent(true, false); + GLOBALS._hDoneChoice = CoroScheduler.createEvent(true, false); return true; } @@ -1553,7 +1552,7 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, */ void mpalFree() { // Free the resource list - globalDestroy(GLOBALS.lpResources); + globalDestroy(GLOBALS._lpResources); } /** @@ -1574,7 +1573,7 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { va_list v; va_start(v, wQueryType); - GLOBALS.mpalError = OK; + GLOBALS._mpalError = OK; if (wQueryType == MPQ_VERSION) { @@ -1616,13 +1615,13 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { y = GETARG(uint32); if (x != -1) { if (y == MPQ_X) - dwRet = GLOBALS.lpmlLocations[x].dwXlen; + dwRet = GLOBALS._lpmlLocations[x].dwXlen; else if (y == MPQ_Y) - dwRet = GLOBALS.lpmlLocations[x].dwYlen; + dwRet = GLOBALS._lpmlLocations[x].dwYlen; else - GLOBALS.mpalError = 1; + GLOBALS._mpalError = 1; } else - GLOBALS.mpalError = 1; + GLOBALS._mpalError = 1; unlockLocations(); @@ -1677,7 +1676,7 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { else { lockItems(); y = itemGetOrderFromNum(x); - copyMemory(n, (char *)(GLOBALS.lpmiItems + y)->lpszDescribe, MAX_DESCRIBE_SIZE); + copyMemory(n, (char *)(GLOBALS._lpmiItems + y)->lpszDescribe, MAX_DESCRIBE_SIZE); unlockItems(); } @@ -1725,7 +1724,7 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { dwRet = doAction(x, y, GETARG(uint32)); } else { dwRet = CORO_INVALID_PID_VALUE; - GLOBALS.mpalError = 1; + GLOBALS._mpalError = 1; } unlockVar(); @@ -1735,7 +1734,7 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { /* * int mpalQuery(MPQ_DO_DIALOG, uint32 nDialog, uint32 nGroup); */ - if (!GLOBALS.bExecutingDialog) { + if (!GLOBALS._bExecutingDialog) { lockDialogs(); x = dialogGetOrderFromNum(GETARG(uint32)); @@ -1747,7 +1746,7 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { /* * DEFAULT -> ERROR */ - GLOBALS.mpalError = 1; + GLOBALS._mpalError = 1; } va_end(v); @@ -1771,7 +1770,7 @@ HANDLE mpalQueryHANDLE(uint16 wQueryType, ...) { va_start(v, wQueryType); void *hRet = NULL; - GLOBALS.mpalError = OK; + GLOBALS._mpalError = OK; if (wQueryType == MPQ_VERSION) { /* @@ -1811,7 +1810,7 @@ HANDLE mpalQueryHANDLE(uint16 wQueryType, ...) { */ lockLocations(); x = locGetOrderFromNum(GETARG(uint32)); - hRet = resLoad(GLOBALS.lpmlLocations[x].dwPicRes); + hRet = resLoad(GLOBALS._lpmlLocations[x].dwPicRes); unlockLocations(); } else if (wQueryType == MPQ_RESOURCE) { @@ -1855,7 +1854,7 @@ HANDLE mpalQueryHANDLE(uint16 wQueryType, ...) { else { lockItems(); y = itemGetOrderFromNum(x); - copyMemory(n, (char *)(GLOBALS.lpmiItems + y)->lpszDescribe, MAX_DESCRIBE_SIZE); + copyMemory(n, (char *)(GLOBALS._lpmiItems + y)->lpszDescribe, MAX_DESCRIBE_SIZE); unlockItems(); } @@ -1905,7 +1904,7 @@ HANDLE mpalQueryHANDLE(uint16 wQueryType, ...) { /* * DEFAULT -> ERROR */ - GLOBALS.mpalError = 1; + GLOBALS._mpalError = 1; } va_end(v); @@ -1936,12 +1935,12 @@ void mpalQueryCORO(CORO_PARAM, uint16 wQueryType, uint32 *dwRet, ...) { /* * void mpalQuery(MPQ_DIALOG_WAITFORCHOICE); */ - CORO_INVOKE_2(CoroScheduler.waitForSingleObject, GLOBALS.hAskChoice, CORO_INFINITE); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, GLOBALS._hAskChoice, CORO_INFINITE); - CoroScheduler.resetEvent(GLOBALS.hAskChoice); + CoroScheduler.resetEvent(GLOBALS._hAskChoice); - if (GLOBALS.bExecutingDialog) - *dwRet = (uint32)GLOBALS.nExecutingChoice; + if (GLOBALS._bExecutingDialog) + *dwRet = (uint32)GLOBALS._nExecutingChoice; else *dwRet = (uint32)((int)-1); } else { @@ -1960,7 +1959,7 @@ void mpalQueryCORO(CORO_PARAM, uint16 wQueryType, uint32 *dwRet, ...) { * @returns Error code */ uint32 mpalGetError(void) { - return GLOBALS.mpalError; + return GLOBALS._mpalError; } @@ -1980,7 +1979,7 @@ bool mpalExecuteScript(int nScript) { if (s == NULL) return false; - copyMemory(s, GLOBALS.lpmsScripts + n, sizeof(MPALSCRIPT)); + copyMemory(s, GLOBALS._lpmsScripts + n, sizeof(MPALSCRIPT)); unlockScripts(); // !!! New process management @@ -1998,7 +1997,7 @@ bool mpalExecuteScript(int nScript) { * @param lpiifCustom Custom function to install */ void mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCus) { - GLOBALS.lpiifCustom = lpiifCus; + GLOBALS._lpiifCustom = lpiifCus; } @@ -2015,16 +2014,16 @@ bool mpalStartIdlePoll(int nLoc) { uint32 i; for (i = 0; i < MAXPOLLINGLOCATIONS; i++) - if (GLOBALS.nPollingLocations[i] == (uint32)nLoc) + if (GLOBALS._nPollingLocations[i] == (uint32)nLoc) return false; for (i = 0; i < MAXPOLLINGLOCATIONS; i++) { - if (GLOBALS.nPollingLocations[i] == 0) { - GLOBALS.nPollingLocations[i] = nLoc; + if (GLOBALS._nPollingLocations[i] == 0) { + GLOBALS._nPollingLocations[i] = nLoc; - GLOBALS.hEndPollingLocations[i] = CoroScheduler.createEvent(true, false); + GLOBALS._hEndPollingLocations[i] = CoroScheduler.createEvent(true, false); // !!! New process management - if ((GLOBALS.PollingThreads[i] = CoroScheduler.createProcess(LocationPollThread, &i, sizeof(uint32))) == CORO_INVALID_PID_VALUE) + if ((GLOBALS._pollingThreads[i] = CoroScheduler.createProcess(LocationPollThread, &i, sizeof(uint32))) == CORO_INVALID_PID_VALUE) // if ((GLOBALS.hEndPollingLocations[i] = (void*)_beginthread(LocationPollThread, 10240,(void *)i))= = (void*)-1) return false; @@ -2051,13 +2050,13 @@ void mpalEndIdlePoll(CORO_PARAM, int nLoc, bool *result) { CORO_BEGIN_CODE(_ctx); for (_ctx->i = 0; _ctx->i < MAXPOLLINGLOCATIONS; _ctx->i++) { - if (GLOBALS.nPollingLocations[_ctx->i] == (uint32)nLoc) { - CoroScheduler.setEvent(GLOBALS.hEndPollingLocations[_ctx->i]); + if (GLOBALS._nPollingLocations[_ctx->i] == (uint32)nLoc) { + CoroScheduler.setEvent(GLOBALS._hEndPollingLocations[_ctx->i]); - CORO_INVOKE_2(CoroScheduler.waitForSingleObject, GLOBALS.PollingThreads[_ctx->i], CORO_INFINITE); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, GLOBALS._pollingThreads[_ctx->i], CORO_INFINITE); - CoroScheduler.closeEvent(GLOBALS.hEndPollingLocations[_ctx->i]); - GLOBALS.nPollingLocations[_ctx->i] = 0; + CoroScheduler.closeEvent(GLOBALS._hEndPollingLocations[_ctx->i]); + GLOBALS._nPollingLocations[_ctx->i] = 0; if (result) *result = true; @@ -2078,7 +2077,7 @@ void mpalEndIdlePoll(CORO_PARAM, int nLoc, bool *result) { * @returns Length in bytes */ int mpalGetSaveStateSize(void) { - return GLOBALS.nVars * sizeof(MPALVAR) + 4; + return GLOBALS._nVars * sizeof(MPALVAR) + 4; } @@ -2090,8 +2089,8 @@ int mpalGetSaveStateSize(void) { */ void mpalSaveState(byte *buf) { lockVar(); - WRITE_LE_UINT32(buf, GLOBALS.nVars); - copyMemory(buf + 4, (byte *)GLOBALS.lpmvVars, GLOBALS.nVars * sizeof(MPALVAR)); + WRITE_LE_UINT32(buf, GLOBALS._nVars); + copyMemory(buf + 4, (byte *)GLOBALS._lpmvVars, GLOBALS._nVars * sizeof(MPALVAR)); unlockVar(); } @@ -2104,16 +2103,16 @@ void mpalSaveState(byte *buf) { */ int mpalLoadState(byte *buf) { // We must destroy and recreate all the variables - globalFree(GLOBALS.hVars); + globalFree(GLOBALS._hVars); - GLOBALS.nVars = READ_LE_UINT32(buf); + GLOBALS._nVars = READ_LE_UINT32(buf); - GLOBALS.hVars = globalAllocate(GMEM_ZEROINIT | GMEM_MOVEABLE, GLOBALS.nVars * sizeof(MPALVAR)); + GLOBALS._hVars = globalAllocate(GMEM_ZEROINIT | GMEM_MOVEABLE, GLOBALS._nVars * sizeof(MPALVAR)); lockVar(); - copyMemory((byte *)GLOBALS.lpmvVars, buf + 4, GLOBALS.nVars * sizeof(MPALVAR)); + copyMemory((byte *)GLOBALS._lpmvVars, buf + 4, GLOBALS._nVars * sizeof(MPALVAR)); unlockVar(); - return GLOBALS.nVars * sizeof(MPALVAR) + 4; + return GLOBALS._nVars * sizeof(MPALVAR) + 4; } bool bDontOutput; @@ -2264,8 +2263,8 @@ void mpalDumpMessages(void) { f = g_system->getSavefileManager()->openForSaving("Messages.htm"); f->writeString("\n\n
%s %s %s
\n"); - for (i = 0; i < GLOBALS.nMsgs; i++) { - lpMessage = (char *)globalLock(GLOBALS.lpmmMsgs[i].hText); + for (i = 0; i < GLOBALS._nMsgs; i++) { + lpMessage = (char *)globalLock(GLOBALS._lpmmMsgs[i]._hText); if (*lpMessage != '\0') { // bernie: debug /*if (GLOBALS.lpmmMsgs[i].wNum == 1950) { @@ -2275,7 +2274,7 @@ void mpalDumpMessages(void) { nPeriods = 1; p = lpPeriods[0] = lpMessage; - outputStartMsgComment(GLOBALS.lpmmMsgs[i].wNum, f); + outputStartMsgComment(GLOBALS._lpmmMsgs[i]._wNum, f); while (1) { // Find the end of the current period @@ -2294,9 +2293,9 @@ void mpalDumpMessages(void) { // Now make a loop over all the periods for (j = 0; j < nPeriods; j++) { if (nPeriods == 1) - sprintf(fname, "000-%05d.WAV", GLOBALS.lpmmMsgs[i].wNum); + sprintf(fname, "000-%05d.WAV", GLOBALS._lpmmMsgs[i]._wNum); else - sprintf(fname, "000-%05d-%02d.WAV", GLOBALS.lpmmMsgs[i].wNum,j); + sprintf(fname, "000-%05d-%02d.WAV", GLOBALS._lpmmMsgs[i]._wNum,j); strcpy(frase, lpPeriods[j]); @@ -2318,9 +2317,9 @@ void mpalDumpMessages(void) { } } - OutputEndMsgComment(GLOBALS.lpmmMsgs[i].wNum, f); + OutputEndMsgComment(GLOBALS._lpmmMsgs[i]._wNum, f); - globalUnlock(GLOBALS.lpmmMsgs[i].hText); + globalUnlock(GLOBALS._lpmmMsgs[i]._hText); } } @@ -2357,13 +2356,13 @@ void mpalDumpOthers(void) { f->writeString("\n\n"); - for (i = 0; i < GLOBALS.nMsgs; i++) { - lpMessage = (char *)globalLock(GLOBALS.lpmmMsgs[i].hText); + for (i = 0; i < GLOBALS._nMsgs; i++) { + lpMessage = (char *)globalLock(GLOBALS._lpmmMsgs[i]._hText); if (*lpMessage != '\0') { nPeriods = 1; p = lpPeriods[0] = lpMessage; - if (OutputStartOther(GLOBALS.lpmmMsgs[i].wNum, f)) { + if (OutputStartOther(GLOBALS._lpmmMsgs[i]._wNum, f)) { while (1) { // Find the end of the current period while (*p != '\0') @@ -2381,9 +2380,9 @@ void mpalDumpOthers(void) { // Now loop over all the periods for (j = 0; j < nPeriods; j++) { if (nPeriods == 1) - sprintf(fname, "000-%05d.WAV", GLOBALS.lpmmMsgs[i].wNum); + sprintf(fname, "000-%05d.WAV", GLOBALS._lpmmMsgs[i]._wNum); else - sprintf(fname, "000-%05d-%02d.WAV", GLOBALS.lpmmMsgs[i].wNum,j); + sprintf(fname, "000-%05d-%02d.WAV", GLOBALS._lpmmMsgs[i]._wNum,j); strcpy(frase,lpPeriods[j]); @@ -2406,9 +2405,9 @@ void mpalDumpOthers(void) { } } - outputEndOther(GLOBALS.lpmmMsgs[i].wNum, f); + outputEndOther(GLOBALS._lpmmMsgs[i]._wNum, f); - globalUnlock(GLOBALS.lpmmMsgs[i].hText); + globalUnlock(GLOBALS._lpmmMsgs[i]._hText); } } @@ -2833,7 +2832,7 @@ void mpalDumpDialog(LPMPALDIALOG dlg) { for (c = 0; c_group[g].nCmds; c++) { curCmd = &dlg->_command[dlg->_group[g].CmdNum[c]]; - if (curCmd->type == 1 && curCmd->nCf == 71) { + if (curCmd->type == 1 && curCmd->_nCf == 71) { bAtLeastOne = true; break; } @@ -2849,15 +2848,15 @@ void mpalDumpDialog(LPMPALDIALOG dlg) { curCmd = &dlg->_command[dlg->_group[g].CmdNum[c]]; // If it's a custom function, call SendDialogMessage(nPers, nMsg) - if (curCmd->type == 1 && curCmd->nCf == 71) { - sprintf(fname, "%03d-%05d.WAV", dlg->nObj, curCmd->arg2); + if (curCmd->type == 1 && curCmd->_nCf == 71) { + sprintf(fname, "%03d-%05d.WAV", dlg->nObj, curCmd->_arg2); for (j = 0; dlg->_periods[j] != NULL; j++) - if (dlg->_periodNums[j] == curCmd->arg2) + if (dlg->_periodNums[j] == curCmd->_arg2) break; if (dlg->_periods[j] == NULL) - warning("ERROR: Dialog %d, Period %d not found!", (int)dlg->nObj, (int)curCmd->arg2); + warning("ERROR: Dialog %d, Period %d not found!", (int)dlg->nObj, (int)curCmd->_arg2); else { frase = (char *)globalLock(dlg->_periods[j]); strcpy(copia, frase); @@ -2876,7 +2875,7 @@ void mpalDumpDialog(LPMPALDIALOG dlg) { f->writeString("\t\n"); f->writeString(Common::String::format("\t\t\n", fname)); f->writeString(Common::String::format("\t\t\n", - getPersonName(dlg->nObj, curCmd->arg1))); + getPersonName(dlg->nObj, curCmd->_arg1))); f->writeString(Common::String::format("\t\t\n",copia)); f->writeString("\t\n"); //fprintf(f, "(%s) <%s> %s\n", fname, GetPersonName(dlg->nObj, curCmd->arg1), copia); @@ -2899,8 +2898,8 @@ void mpalDumpDialogs(void) { lockDialogs(); - for (i = 0; i < GLOBALS.nDialogs; i++) - mpalDumpDialog(&GLOBALS.lpmdDialogs[i]); + for (i = 0; i < GLOBALS._nDialogs; i++) + mpalDumpDialog(&GLOBALS._lpmdDialogs[i]); unlockDialogs(); } diff --git a/engines/tony/mpal/mpaldll.h b/engines/tony/mpal/mpaldll.h index e331335315..952a0957c5 100644 --- a/engines/tony/mpal/mpaldll.h +++ b/engines/tony/mpal/mpaldll.h @@ -89,8 +89,8 @@ typedef LPMPALVAR *LPLPMPALVAR; * MPAL Messages */ struct MPALMSG { - HGLOBAL hText; // Handle to the message text - uint16 wNum; // Message number + HGLOBAL _hText; // Handle to the message text + uint16 _wNum; // Message number } PACKED_STRUCT; typedef MPALMSG *LPMPALMSG; typedef LPMPALMSG *LPLPMPALMSG; @@ -124,17 +124,17 @@ struct command { byte type; // Type of control union { - int32 nCf; // Custom function call [#1] + int32 _nCf; // Custom function call [#1] char *lpszVarName; // Variable name [#2] int32 nChoice; // Number of choice you make [#3] }; union { - int32 arg1; // Argument for custom function [#1] + int32 _arg1; // Argument for custom function [#1] HGLOBAL expr; // Expression to assign to a variable [#2] }; - int32 arg2, arg3, arg4; // Arguments for custom function [#1] + int32 _arg2, _arg3, _arg4; // Arguments for custom function [#1] } PACKED_STRUCT; diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 0c0bcf331a..2b9d8fbc20 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -517,9 +517,9 @@ void TonyEngine::playProcess(CORO_PARAM, const void *param) { // and kill the scheudler and all the processes, including this one for (;;) { // If a savegame needs to be loaded, then do so - if (_vm->_loadSlotNumber != -1 && GLOBALS.GfxEngine != NULL) { + if (_vm->_loadSlotNumber != -1 && GLOBALS._gfxEngine != NULL) { _ctx->fn = getSaveStateFileName(_vm->_loadSlotNumber); - CORO_INVOKE_1(GLOBALS.GfxEngine->loadState, _ctx->fn); + CORO_INVOKE_1(GLOBALS._gfxEngine->loadState, _ctx->fn); _vm->_loadSlotNumber = -1; } @@ -605,10 +605,10 @@ uint32 TonyEngine::getTime() { } bool TonyEngine::canLoadGameStateCurrently() { - return GLOBALS.GfxEngine != NULL && GLOBALS.GfxEngine->canLoadSave(); + return GLOBALS._gfxEngine != NULL && GLOBALS._gfxEngine->canLoadSave(); } bool TonyEngine::canSaveGameStateCurrently() { - return GLOBALS.GfxEngine != NULL && GLOBALS.GfxEngine->canLoadSave(); + return GLOBALS._gfxEngine != NULL && GLOBALS._gfxEngine->canLoadSave(); } Common::Error TonyEngine::loadGameState(int slot) { @@ -617,13 +617,13 @@ Common::Error TonyEngine::loadGameState(int slot) { } Common::Error TonyEngine::saveGameState(int slot, const Common::String &desc) { - if (!GLOBALS.GfxEngine) + if (!GLOBALS._gfxEngine) return Common::kUnknownError; RMSnapshot s; - s.grabScreenshot(*GLOBALS.GfxEngine, 4, _curThumbnail); + s.grabScreenshot(*GLOBALS._gfxEngine, 4, _curThumbnail); - GLOBALS.GfxEngine->saveState(getSaveStateFileName(slot), (byte *)_curThumbnail, desc); + GLOBALS._gfxEngine->saveState(getSaveStateFileName(slot), (byte *)_curThumbnail, desc); return Common::kNoError; } -- cgit v1.2.3 From 44ee26e6c99383dd9cec1392afae958faaf87b12 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 10 Jun 2012 23:56:37 +0200 Subject: TONY: Rename variables in loc.h and mpal.h --- engines/tony/debugger.cpp | 2 +- engines/tony/loc.cpp | 406 ++++++++++++++++++++++----------------------- engines/tony/loc.h | 86 +++++----- engines/tony/mpal/mpal.cpp | 58 +++---- engines/tony/mpal/mpal.h | 48 +++--- engines/tony/tonychar.cpp | 6 +- 6 files changed, 303 insertions(+), 303 deletions(-) (limited to 'engines') diff --git a/engines/tony/debugger.cpp b/engines/tony/debugger.cpp index af2bffc459..1a4dc16b75 100644 --- a/engines/tony/debugger.cpp +++ b/engines/tony/debugger.cpp @@ -100,7 +100,7 @@ bool Debugger::Cmd_Scene(int argc, const char **argv) { // Get the box areas for the scene, and choose one so as to have a default // position for Tony that will be in the walkable areas RMBoxLoc *box = _vm->_theBoxes.getBoxes(sceneNumber); - scenePos.set(box->boxes[0].hotspot[0].hotx, box->boxes[0].hotspot[0].hoty); + scenePos.set(box->_boxes[0]._hotspot[0]._hotx, box->_boxes[0]._hotspot[0]._hoty); } // Set up a process to change the scene diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index ac238193e0..81fb0d307f 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -951,19 +951,19 @@ short RMCharacter::findPath(short source, short destination) { short i, j, k, costominimo, fine, errore = 0; RMBoxLoc *cur; - g_system->lockMutex(csMove); + g_system->lockMutex(_csMove); if (source == -1 || destination == -1) { - g_system->unlockMutex(csMove); + g_system->unlockMutex(_csMove); return 0; } // Get the boxes - cur = theBoxes->getBoxes(curLocation); + cur = _theBoxes->getBoxes(_curLocation); // Make a backup copy to work on for (i = 0; i < cur->numbbox; i++) - memcpy(&BOX[i], &cur->boxes[i], sizeof(RMBox)); + memcpy(&BOX[i], &cur->_boxes[i], sizeof(RMBox)); // Invalidate all nodes for (i = 0; i < cur->numbbox; i++) @@ -984,7 +984,7 @@ short RMCharacter::findPath(short source, short destination) { if (VALIDO[i] == 1) { errore = 0; // Failure de-bunked j = 0; - while (((BOX[i].adj[j]) != 1) && (j < cur->numbbox)) + while (((BOX[i]._adj[j]) != 1) && (j < cur->numbbox)) j++; if (j >= cur->numbbox) @@ -1002,12 +1002,12 @@ short RMCharacter::findPath(short source, short destination) { // 2nd cycle: adding new nodes that were found, saturate old nodes for (i = 0; i < cur->numbbox; i++) if ((VALIDO[i] == 1) && ((COSTO[i] + 1) == costominimo)) { - BOX[i].adj[NEXT[i]] = 2; + BOX[i]._adj[NEXT[i]] = 2; COSTO[NEXT[i]] = costominimo; VALIDO[NEXT[i]] = 1; for (j = 0; j < cur->numbbox; j++) - if (BOX[j].adj[NEXT[i]] == 1) - BOX[j].adj[NEXT[i]] = 0; + if (BOX[j]._adj[NEXT[i]] == 1) + BOX[j]._adj[NEXT[i]] = 0; if (NEXT[i] == destination) fine = 1; @@ -1016,22 +1016,22 @@ short RMCharacter::findPath(short source, short destination) { // Remove the path from the adjacent modified matrixes if (!errore) { - pathlenght = COSTO[destination]; - k = pathlenght; - path[k] = destination; + _pathLength = COSTO[destination]; + k = _pathLength; + _path[k] = destination; - while (path[k] != source) { + while (_path[k] != source) { i = 0; - while (BOX[i].adj[path[k]] != 2) + while (BOX[i]._adj[_path[k]] != 2) i++; k--; - path[k] = i; + _path[k] = i; } - pathlenght++; + _pathLength++; } - g_system->unlockMutex(csMove); + g_system->unlockMutex(_csMove); return !errore; } @@ -1044,24 +1044,24 @@ void RMCharacter::goTo(CORO_PARAM, RMPoint destcoord, bool bReversed) { CORO_BEGIN_CODE(_ctx); if (_pos == destcoord) { - if (minpath == 0) { + if (_minPath == 0) { CORO_INVOKE_0(stop); - CoroScheduler.pulseEvent(hEndOfPath); + CoroScheduler.pulseEvent(_hEndOfPath); return; } } - status = WALK; - linestart = _pos; - lineend = destcoord; - dx = linestart.x - lineend.x; - dy = linestart.y - lineend.y; - fx = dx; - fy = dy; - dx = ABS(dx); - dy = ABS(dy); - walkspeed = curSpeed; - walkcount = 0; + _status = WALK; + _lineStart = _pos; + _lineEnd = destcoord; + _dx = _lineStart.x - _lineEnd.x; + _dy = _lineStart.y - _lineEnd.y; + _fx = _dx; + _fy = _dy; + _dx = ABS(_dx); + _dy = ABS(_dy); + _walkSpeed = _curSpeed; + _walkCount = 0; if (bReversed) { while (0) ; @@ -1069,15 +1069,15 @@ void RMCharacter::goTo(CORO_PARAM, RMPoint destcoord, bool bReversed) { int nPatt = getCurPattern(); - if (dx > dy) { - slope = fy / fx; - if (lineend.x < linestart.x) - walkspeed = -walkspeed; - walkstatus = 1; + if (_dx > _dy) { + _slope = _fy / _fx; + if (_lineEnd.x < _lineStart.x) + _walkSpeed = -_walkSpeed; + _walkStatus = 1; // Change the pattern for the new direction - bNeedToStop = true; - if ((walkspeed < 0 && !bReversed) || (walkspeed >= 0 && bReversed)) { + _bNeedToStop = true; + if ((_walkSpeed < 0 && !bReversed) || (_walkSpeed >= 0 && bReversed)) { if (nPatt != PAT_WALKLEFT) setPattern(PAT_WALKLEFT); } else { @@ -1085,13 +1085,13 @@ void RMCharacter::goTo(CORO_PARAM, RMPoint destcoord, bool bReversed) { setPattern(PAT_WALKRIGHT); } } else { - slope = fx / fy; - if (lineend.y < linestart.y) - walkspeed = -walkspeed; - walkstatus = 0; + _slope = _fx / _fy; + if (_lineEnd.y < _lineStart.y) + _walkSpeed = -_walkSpeed; + _walkStatus = 0; - bNeedToStop = true; - if ((walkspeed < 0 && !bReversed) || (walkspeed >= 0 && bReversed)) { + _bNeedToStop = true; + if ((_walkSpeed < 0 && !bReversed) || (_walkSpeed >= 0 && bReversed)) { if (nPatt != PAT_WALKUP) setPattern(PAT_WALKUP); } else { @@ -1100,8 +1100,8 @@ void RMCharacter::goTo(CORO_PARAM, RMPoint destcoord, bool bReversed) { } } - olddx = dx; - olddy = dy; + _olddx = _dx; + _olddy = _dy; CORO_END_CODE; } @@ -1297,17 +1297,17 @@ RMPoint RMCharacter::nearestHotSpot(int sourcebox, int destbox) { short cc; int x, y, distanzaminima; distanzaminima = 10000000; - RMBoxLoc *cur = theBoxes->getBoxes(curLocation); + RMBoxLoc *cur = _theBoxes->getBoxes(_curLocation); - for (cc = 0; cc < cur->boxes[sourcebox].numhotspot; cc++) - if ((cur->boxes[sourcebox].hotspot[cc].destination) == destbox) { - x = ABS(cur->boxes[sourcebox].hotspot[cc].hotx - _pos.x); - y = ABS(cur->boxes[sourcebox].hotspot[cc].hoty - _pos.y); + for (cc = 0; cc < cur->_boxes[sourcebox]._numHotspot; cc++) + if ((cur->_boxes[sourcebox]._hotspot[cc]._destination) == destbox) { + x = ABS(cur->_boxes[sourcebox]._hotspot[cc]._hotx - _pos.x); + y = ABS(cur->_boxes[sourcebox]._hotspot[cc]._hoty - _pos.y); if ((x * x + y * y) < distanzaminima) { distanzaminima = x * x + y * y; - puntocaldo.x = cur->boxes[sourcebox].hotspot[cc].hotx; - puntocaldo.y = cur->boxes[sourcebox].hotspot[cc].hoty; + puntocaldo.x = cur->_boxes[sourcebox]._hotspot[cc]._hotx; + puntocaldo.y = cur->_boxes[sourcebox]._hotspot[cc]._hoty; } } @@ -1320,7 +1320,7 @@ void RMCharacter::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr CORO_BEGIN_CODE(_ctx); - if (bDrawNow) { + if (_bDrawNow) { prim->getDst() += _fixedScroll; CORO_INVOKE_2(RMItem::draw, bigBuf, prim); @@ -1334,22 +1334,22 @@ void RMCharacter::newBoxEntered(int nBox) { bool bOldReverse; // Recall on ExitBox - mpalQueryDoAction(3, curLocation, curbox); + mpalQueryDoAction(3, _curLocation, _curBox); - cur = theBoxes->getBoxes(curLocation); - bOldReverse = cur->boxes[curbox].bReversed; - curbox = nBox; + cur = _theBoxes->getBoxes(_curLocation); + bOldReverse = cur->_boxes[_curBox]._bReversed; + _curBox = nBox; // If Z is changed, we must remove it from the OT - if (cur->boxes[curbox].Zvalue != _z) { - bRemoveFromOT = true; - _z = cur->boxes[curbox].Zvalue; + if (cur->_boxes[_curBox]._destZ != _z) { + _bRemoveFromOT = true; + _z = cur->_boxes[_curBox]._destZ; } // Movement management is reversed, only if we are not in the shortest path. If we are in the shortest // path, directly do the DoFrame - if (bMovingWithoutMinpath) { - if ((cur->boxes[curbox].bReversed && !bOldReverse) || (!cur->boxes[curbox].bReversed && bOldReverse)) { + if (_bMovingWithoutMinpath) { + if ((cur->_boxes[_curBox]._bReversed && !bOldReverse) || (!cur->_boxes[_curBox]._bReversed && bOldReverse)) { switch (getCurPattern()) { case PAT_WALKUP: setPattern(PAT_WALKDOWN); @@ -1368,7 +1368,7 @@ void RMCharacter::newBoxEntered(int nBox) { } // Recall On EnterBox - mpalQueryDoAction(2, curLocation, curbox); + mpalQueryDoAction(2, _curLocation, _curBox); } void RMCharacter::doFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc) { @@ -1380,105 +1380,105 @@ void RMCharacter::doFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc) { CORO_BEGIN_CODE(_ctx); _ctx->bEndNow = false; - bEndOfPath = false; - bDrawNow = (curLocation == loc); + _bEndOfPath = false; + _bDrawNow = (_curLocation == loc); - g_system->lockMutex(csMove); + g_system->lockMutex(_csMove); // If we're walking.. - if (status != STAND) { + if (_status != STAND) { // If we are going horizontally - if (walkstatus == 1) { - dx = walkspeed * walkcount; - dy = (int)(slope * dx); - _pos.x = linestart.x + dx; - _pos.y = linestart.y + dy; + if (_walkStatus == 1) { + _dx = _walkSpeed * _walkCount; + _dy = (int)(_slope * _dx); + _pos.x = _lineStart.x + _dx; + _pos.y = _lineStart.y + _dy; // Right - if (((walkspeed > 0) && (_pos.x > lineend.x)) || ((walkspeed < 0) && (_pos.x < lineend.x))) { - _pos = lineend; - status = STAND; + if (((_walkSpeed > 0) && (_pos.x > _lineEnd.x)) || ((_walkSpeed < 0) && (_pos.x < _lineEnd.x))) { + _pos = _lineEnd; + _status = STAND; _ctx->bEndNow = true; } } // If we are going vertical - if (walkstatus == 0) { - dy = walkspeed * walkcount; - dx = (int)(slope * dy); - _pos.x = linestart.x + dx; - _pos.y = linestart.y + dy; + if (_walkStatus == 0) { + _dy = _walkSpeed * _walkCount; + _dx = (int)(_slope * _dy); + _pos.x = _lineStart.x + _dx; + _pos.y = _lineStart.y + _dy; // Down - if (((walkspeed > 0) && (_pos.y > lineend.y)) || ((walkspeed < 0) && (_pos.y < lineend.y))) { - _pos = lineend; - status = STAND; + if (((_walkSpeed > 0) && (_pos.y > _lineEnd.y)) || ((_walkSpeed < 0) && (_pos.y < _lineEnd.y))) { + _pos = _lineEnd; + _status = STAND; _ctx->bEndNow = true; } } // Check if the character came out of the BOX in error, in which case he returns immediately if (inWhichBox(_pos) == -1) { - _pos.x = linestart.x + olddx; - _pos.y = linestart.y + olddy; + _pos.x = _lineStart.x + _olddx; + _pos.y = _lineStart.y + _olddy; } // If we have just moved to a temporary location, and is over the shortest path, we stop permanently - if (_ctx->bEndNow && minpath == 0) { - if (!bEndOfPath) + if (_ctx->bEndNow && _minPath == 0) { + if (!_bEndOfPath) CORO_INVOKE_0(stop); - bEndOfPath = true; - CoroScheduler.pulseEvent(hEndOfPath); + _bEndOfPath = true; + CoroScheduler.pulseEvent(_hEndOfPath); } - walkcount++; + _walkCount++; // Update the character Z. @@@ Should remove only if the Z was changed // Check if the box was changed - if (!theBoxes->isInBox(curLocation, curbox, _pos)) + if (!_theBoxes->isInBox(_curLocation, _curBox, _pos)) newBoxEntered(inWhichBox(_pos)); // Update the old coordinates - olddx = dx; - olddy = dy; + _olddx = _dx; + _olddy = _dy; } // If we stop - if (status == STAND) { + if (_status == STAND) { // Check if there is still the shortest path to calculate - if (minpath == 1) { - _ctx->cur = theBoxes->getBoxes(curLocation); + if (_minPath == 1) { + _ctx->cur = _theBoxes->getBoxes(_curLocation); // If we still have to go through a box - if (pathcount < pathlenght) { + if (_pathCount < _pathLength) { // Check if the box we're going into is active - if (_ctx->cur->boxes[path[pathcount - 1]].attivo) { + if (_ctx->cur->_boxes[_path[_pathCount - 1]]._attivo) { // Move in a straight line towards the nearest hotspot, taking into account the reversing // NEWBOX = path[pathcount-1] - CORO_INVOKE_2(goTo, nearestHotSpot(path[pathcount - 1], path[pathcount]), _ctx->cur->boxes[path[pathcount - 1]].bReversed); - pathcount++; + CORO_INVOKE_2(goTo, nearestHotSpot(_path[_pathCount - 1], _path[_pathCount]), _ctx->cur->_boxes[_path[_pathCount - 1]]._bReversed); + _pathCount++; } else { // If the box is off, we can only block all // @@@ Whilst this should not happen, because have improved // the search for the minimum path - minpath = 0; - if (!bEndOfPath) + _minPath = 0; + if (!_bEndOfPath) CORO_INVOKE_0(stop); - bEndOfPath = true; - CoroScheduler.pulseEvent(hEndOfPath); + _bEndOfPath = true; + CoroScheduler.pulseEvent(_hEndOfPath); } } else { // If we have already entered the last box, we just have to move in a straight line towards the // point of arrival // NEWBOX = InWhichBox(pathend) - minpath = 0; - CORO_INVOKE_2(goTo, pathend, _ctx->cur->boxes[inWhichBox(pathend)].bReversed); + _minPath = 0; + CORO_INVOKE_2(goTo, _pathEnd, _ctx->cur->_boxes[inWhichBox(_pathEnd)]._bReversed); } } } - g_system->unlockMutex(csMove); + g_system->unlockMutex(_csMove); // Invoke the DoFrame of the item RMItem::doFrame(bigBuf); @@ -1492,16 +1492,16 @@ void RMCharacter::stop(CORO_PARAM) { CORO_BEGIN_CODE(_ctx); - bMoving = false; + _bMoving = false; // You never know.. - status = STAND; - minpath = 0; + _status = STAND; + _minPath = 0; - if (!bNeedToStop) + if (!_bNeedToStop) return; - bNeedToStop = false; + _bNeedToStop = false; switch (getCurPattern()) { case PAT_WALKUP: @@ -1529,7 +1529,7 @@ void RMCharacter::stop(CORO_PARAM) { } inline int RMCharacter::inWhichBox(const RMPoint &pt) { - return theBoxes->whichBox(curLocation, pt); + return _theBoxes->whichBox(_curLocation, pt); } @@ -1542,12 +1542,12 @@ void RMCharacter::move(CORO_PARAM, RMPoint pt, bool *result) { CORO_BEGIN_CODE(_ctx); - bMoving = true; + _bMoving = true; // 0, 0 does not do anything, just stops the character if (pt.x == 0 && pt.y == 0) { - minpath = 0; - status = STAND; + _minPath = 0; + _status = STAND; CORO_INVOKE_0(stop); if (result) *result = true; @@ -1568,18 +1568,18 @@ void RMCharacter::move(CORO_PARAM, RMPoint pt, bool *result) { _ctx->numbox = inWhichBox(pt); } - _ctx->cur = theBoxes->getBoxes(curLocation); + _ctx->cur = _theBoxes->getBoxes(_curLocation); - minpath = 0; - status = STAND; - bMovingWithoutMinpath = true; + _minPath = 0; + _status = STAND; + _bMovingWithoutMinpath = true; if (scanLine(pt)) - CORO_INVOKE_2(goTo, pt, _ctx->cur->boxes[_ctx->numbox].bReversed); + CORO_INVOKE_2(goTo, pt, _ctx->cur->_boxes[_ctx->numbox]._bReversed); else if (findPath(inWhichBox(_pos), inWhichBox(pt))) { - bMovingWithoutMinpath = false; - minpath = 1; - pathcount = 1; - pathend = pt; + _bMovingWithoutMinpath = false; + _minPath = 1; + _pathCount = 1; + _pathEnd = pt; } else { // @@@ This case is whether a hotspot is inside a box, but there is // a path to get there. We use the InvScanLine to search around a point @@ -1587,12 +1587,12 @@ void RMCharacter::move(CORO_PARAM, RMPoint pt, bool *result) { pt = _ctx->dest; if (scanLine(pt)) - CORO_INVOKE_2(goTo, pt, _ctx->cur->boxes[_ctx->numbox].bReversed); + CORO_INVOKE_2(goTo, pt, _ctx->cur->_boxes[_ctx->numbox]._bReversed); else if (findPath(inWhichBox(_pos), inWhichBox(pt))) { - bMovingWithoutMinpath = false; - minpath = 1; - pathcount = 1; - pathend = pt; + _bMovingWithoutMinpath = false; + _minPath = 1; + _pathCount = 1; + _pathEnd = pt; if (result) *result = true; } else { @@ -1612,19 +1612,19 @@ void RMCharacter::move(CORO_PARAM, RMPoint pt, bool *result) { void RMCharacter::setPosition(const RMPoint &pt, int newloc) { RMBoxLoc *box; - minpath = 0; - status = STAND; + _minPath = 0; + _status = STAND; _pos = pt; if (newloc != -1) - curLocation = newloc; + _curLocation = newloc; // Update the character's Z value - box = theBoxes->getBoxes(curLocation); - curbox = inWhichBox(_pos); - assert(curbox != -1); - _z = box->boxes[curbox].Zvalue; - bRemoveFromOT = true; + box = _theBoxes->getBoxes(_curLocation); + _curBox = inWhichBox(_pos); + assert(_curBox != -1); + _z = box->_boxes[_curBox]._destZ; + _bRemoveFromOT = true; } void RMCharacter::waitForEndMovement(CORO_PARAM) { @@ -1633,8 +1633,8 @@ void RMCharacter::waitForEndMovement(CORO_PARAM) { CORO_BEGIN_CODE(_ctx); - if (bMoving) - CORO_INVOKE_2(CoroScheduler.waitForSingleObject, hEndOfPath, CORO_INFINITE); + if (_bMoving) + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _hEndOfPath, CORO_INFINITE); CORO_END_CODE; } @@ -1645,7 +1645,7 @@ void RMCharacter::removeThis(CORO_PARAM, bool &result) { CORO_BEGIN_CODE(_ctx); - if (bRemoveFromOT) + if (_bRemoveFromOT) result = true; else CORO_INVOKE_1(RMItem::removeThis, result); @@ -1654,38 +1654,38 @@ void RMCharacter::removeThis(CORO_PARAM, bool &result) { } RMCharacter::RMCharacter() { - csMove = g_system->createMutex(); - hEndOfPath = CoroScheduler.createEvent(false, false); - minpath = 0; - curSpeed = 3; - bRemoveFromOT = false; - bMoving = false; - curLocation = 0; - curbox = 0; - dx = dy = 0; - olddx = olddy = 0; - fx = fy = slope = 0; - walkspeed = walkstatus = 0; - nextbox = 0; - pathlenght = pathcount = 0; - status = STAND; - theBoxes = NULL; - walkcount = 0; - bEndOfPath = false; - bMovingWithoutMinpath = false; - bDrawNow = false; - bNeedToStop = false; + _csMove = g_system->createMutex(); + _hEndOfPath = CoroScheduler.createEvent(false, false); + _minPath = 0; + _curSpeed = 3; + _bRemoveFromOT = false; + _bMoving = false; + _curLocation = 0; + _curBox = 0; + _dx = _dy = 0; + _olddx = _olddy = 0; + _fx = _fy = _slope = 0; + _walkSpeed = _walkStatus = 0; + _nextBox = 0; + _pathLength = _pathCount = 0; + _status = STAND; + _theBoxes = NULL; + _walkCount = 0; + _bEndOfPath = false; + _bMovingWithoutMinpath = false; + _bDrawNow = false; + _bNeedToStop = false; _pos.set(0, 0); } RMCharacter::~RMCharacter() { - g_system->deleteMutex(csMove); - CoroScheduler.closeEvent(hEndOfPath); + g_system->deleteMutex(_csMove); + CoroScheduler.closeEvent(_hEndOfPath); } void RMCharacter::linkToBoxes(RMGameBoxes *boxes) { - theBoxes = boxes; + _theBoxes = boxes; } /****************************************************************************\ @@ -1698,35 +1698,35 @@ void RMBox::readFromStream(RMDataStream &ds) { byte b; // Bbox - ds >> left; - ds >> top; - ds >> right; - ds >> bottom; + ds >> _left; + ds >> _top; + ds >> _right; + ds >> _bottom; // Adjacency for (i = 0; i < MAXBOXES; i++) { - ds >> adj[i]; + ds >> _adj[i]; } // Misc - ds >> numhotspot; - ds >> Zvalue; + ds >> _numHotspot; + ds >> _destZ; ds >> b; - attivo = b; + _attivo = b; ds >> b; - bReversed = b; + _bReversed = b; // Reversed expansion space ds += 30; // Hotspots - for (i = 0; i < numhotspot; i++) { + for (i = 0; i < _numHotspot; i++) { ds >> w; - hotspot[i].hotx = w; + _hotspot[i]._hotx = w; ds >> w; - hotspot[i].hoty = w; + _hotspot[i]._hoty = w; ds >> w; - hotspot[i].destination = w; + _hotspot[i]._destination = w; } } @@ -1741,11 +1741,11 @@ RMDataStream &operator>>(RMDataStream &ds, RMBox &box) { \****************************************************************************/ RMBoxLoc::RMBoxLoc() { - boxes = NULL; + _boxes = NULL; } RMBoxLoc::~RMBoxLoc() { - delete[] boxes; + delete[] _boxes; } void RMBoxLoc::readFromStream(RMDataStream &ds) { @@ -1762,11 +1762,11 @@ void RMBoxLoc::readFromStream(RMDataStream &ds) { ds >> numbbox; // Allocate memory for the boxes - boxes = new RMBox[numbbox]; + _boxes = new RMBox[numbbox]; // Read in boxes for (i = 0; i < numbbox; i++) - ds >> boxes[i]; + ds >> _boxes[i]; } @@ -1774,11 +1774,11 @@ void RMBoxLoc::recalcAllAdj(void) { int i, j; for (i = 0; i < numbbox; i++) { - Common::fill(boxes[i].adj, boxes[i].adj + MAXBOXES, 0); + Common::fill(_boxes[i]._adj, _boxes[i]._adj + MAXBOXES, 0); - for (j = 0; j < boxes[i].numhotspot; j++) - if (boxes[boxes[i].hotspot[j].destination].attivo) - boxes[i].adj[boxes[i].hotspot[j].destination] = 1; + for (j = 0; j < _boxes[i]._numHotspot; j++) + if (_boxes[_boxes[i]._hotspot[j]._destination]._attivo) + _boxes[i]._adj[_boxes[i]._hotspot[j]._destination] = 1; } } @@ -1833,8 +1833,8 @@ RMBoxLoc *RMGameBoxes::getBoxes(int nLoc) { bool RMGameBoxes::isInBox(int nLoc, int nBox, const RMPoint &pt) { RMBoxLoc *cur = getBoxes(nLoc); - if ((pt.x >= cur->boxes[nBox].left) && (pt.x <= cur->boxes[nBox].right) && - (pt.y >= cur->boxes[nBox].top) && (pt.y <= cur->boxes[nBox].bottom)) + if ((pt.x >= cur->_boxes[nBox]._left) && (pt.x <= cur->_boxes[nBox]._right) && + (pt.y >= cur->_boxes[nBox]._top) && (pt.y <= cur->_boxes[nBox]._bottom)) return true; else return false; @@ -1848,16 +1848,16 @@ int RMGameBoxes::whichBox(int nLoc, const RMPoint &punto) { return -1; for (i = 0; i < cur->numbbox; i++) - if (cur->boxes[i].attivo) - if ((punto.x >= cur->boxes[i].left) && (punto.x <= cur->boxes[i].right) && - (punto.y >= cur->boxes[i].top) && (punto.y <= cur->boxes[i].bottom)) + if (cur->_boxes[i]._attivo) + if ((punto.x >= cur->_boxes[i]._left) && (punto.x <= cur->_boxes[i]._right) && + (punto.y >= cur->_boxes[i]._top) && (punto.y <= cur->_boxes[i]._bottom)) return i; return -1; } void RMGameBoxes::changeBoxStatus(int nLoc, int nBox, int status) { - _allBoxes[nLoc]->boxes[nBox].attivo = status; + _allBoxes[nLoc]->_boxes[nBox]._attivo = status; _allBoxes[nLoc]->recalcAllAdj(); } @@ -1889,7 +1889,7 @@ void RMGameBoxes::saveState(byte *state) { state += 4; for (j = 0; j < _allBoxes[i]->numbbox; j++) - *state++ = _allBoxes[i]->boxes[j].attivo; + *state++ = _allBoxes[i]->_boxes[j]._attivo; } } @@ -1910,7 +1910,7 @@ void RMGameBoxes::loadState(byte *state) { for (j = 0; j < nbox ; j++) { if (j < _allBoxes[i]->numbbox) - _allBoxes[i]->boxes[j].attivo = *state; + _allBoxes[i]->_boxes[j]._attivo = *state; state++; } @@ -2288,29 +2288,29 @@ RMMessage::RMMessage(uint32 dwId) { } RMMessage::RMMessage() { - lpMessage = NULL; + _lpMessage = NULL; } RMMessage::~RMMessage() { - if (lpMessage) - globalDestroy(lpMessage); + if (_lpMessage) + globalDestroy(_lpMessage); } void RMMessage::load(uint32 dwId) { - lpMessage = mpalQueryMessage(dwId); - assert(lpMessage != NULL); + _lpMessage = mpalQueryMessage(dwId); + assert(_lpMessage != NULL); - if (lpMessage) + if (_lpMessage) parseMessage(); } void RMMessage::parseMessage(void) { char *p; - assert(lpMessage != NULL); + assert(_lpMessage != NULL); - nPeriods = 1; - p = lpPeriods[0] = lpMessage; + _nPeriods = 1; + p = _lpPeriods[0] = _lpMessage; for (;;) { // Find the end of the current period @@ -2323,7 +2323,7 @@ void RMMessage::parseMessage(void) { break; // Otherwise there is another line, and remember it's start - lpPeriods[nPeriods++] = p; + _lpPeriods[_nPeriods++] = p; } } diff --git a/engines/tony/loc.h b/engines/tony/loc.h index e465b113b2..79eb936d9b 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -315,19 +315,19 @@ protected: class RMBox { public: struct T_HOTSPOT { - int hotx, hoty; // Hotspot coordinates - int destination; // Hotspot destination + int _hotx, _hoty; // Hotspot coordinates + int _destination; // Hotspot destination }; public: - int left, top, right, bottom; // Vertici bounding boxes - int adj[MAXBOXES]; // List of adjacent bounding boxes - int numhotspot; // Hotspot number - uint8 Zvalue; // Z value for the bounding box - T_HOTSPOT hotspot[MAXHOTSPOT]; // List of hotspots + int _left, _top, _right, _bottom; // Vertici bounding boxes + int _adj[MAXBOXES]; // List of adjacent bounding boxes + int _numHotspot; // Hotspot number + uint8 _destZ; // Z value for the bounding box + T_HOTSPOT _hotspot[MAXHOTSPOT]; // List of hotspots - bool attivo; - bool bReversed; + bool _attivo; + bool _bReversed; private: void readFromStream(RMDataStream &ds); @@ -340,7 +340,7 @@ public: class RMBoxLoc { public: int numbbox; - RMBox *boxes; + RMBox *_boxes; private: void readFromStream(RMDataStream &ds); @@ -405,26 +405,26 @@ private: WALK }; - signed short walkcount; - int dx, dy, olddx, olddy; - float fx, fy, slope; - RMPoint linestart, lineend, pathend; - signed char walkspeed, walkstatus; - char minpath; - short nextbox; - short path[MAXBOXES]; - short pathlenght, pathcount; - int curbox; - - STATUS status; - int curSpeed; - bool bEndOfPath; - uint32 hEndOfPath; - OSystem::MutexRef csMove; - int curLocation; - bool bRemoveFromOT; - bool bMovingWithoutMinpath; - RMGameBoxes *theBoxes; + signed short _walkCount; + int _dx, _dy, _olddx, _olddy; + float _fx, _fy, _slope; + RMPoint _lineStart, _lineEnd, _pathEnd; + signed char _walkSpeed, _walkStatus; + char _minPath; + short _nextBox; + short _path[MAXBOXES]; + short _pathLength, _pathCount; + int _curBox; + + STATUS _status; + int _curSpeed; + bool _bEndOfPath; + uint32 _hEndOfPath; + OSystem::MutexRef _csMove; + int _curLocation; + bool _bRemoveFromOT; + bool _bMovingWithoutMinpath; + RMGameBoxes *_theBoxes; RMPoint _fixedScroll; @@ -443,9 +443,9 @@ private: void newBoxEntered(int nBox); protected: - bool bMoving; - bool bDrawNow; - bool bNeedToStop; + bool _bMoving; + bool _bDrawNow; + bool _bNeedToStop; // virtual RMGfxPrimitive *NewItemPrimitive(); public: @@ -464,7 +464,7 @@ public: // TRUE if you just stopped bool endOfPath() { - return bEndOfPath; + return _bEndOfPath; } // Change the pattern of a character to STOP @@ -472,7 +472,7 @@ public: // Check if the character is moving bool isMoving() { - return bMoving; + return _bMoving; } // Move the character to a certain position @@ -488,7 +488,7 @@ public: _fixedScroll = fix; } void setSpeed(int speed) { - curSpeed = speed; + _curSpeed = speed; } }; @@ -601,9 +601,9 @@ public: */ class RMMessage { private: - char *lpMessage; - char *lpPeriods[256]; - int nPeriods; + char *_lpMessage; + char *_lpPeriods[256]; + int _nPeriods; private: void parseMessage(void); @@ -615,16 +615,16 @@ public: void load(uint32 dwId); bool isValid() { - return lpMessage != NULL; + return _lpMessage != NULL; } int numPeriods() { - return nPeriods; + return _nPeriods; } char *period(int num) { - return lpPeriods[num]; + return _lpPeriods[num]; } char *operator[](int num) { - return lpPeriods[num]; + return _lpPeriods[num]; } }; diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 162ba4c776..3b798b8071 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -490,7 +490,7 @@ static LPITEM getItemData(uint32 nOrdItem) { ret = (LPITEM)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(ITEM)); if (ret == NULL) return NULL; - ret->speed = 150; + ret->_speed = 150; hDat = resLoad(curitem->dwRes); dat = (char *)globalLock(hDat); @@ -500,65 +500,65 @@ static LPITEM getItemData(uint32 nOrdItem) { dat += 4; if (i >= 0x10) { // From 1.0, there's a destination point for each object - ret->destX = (int16)READ_LE_UINT16(dat); - ret->destY = (int16)READ_LE_UINT16(dat + 2); + ret->_destX = (int16)READ_LE_UINT16(dat); + ret->_destY = (int16)READ_LE_UINT16(dat + 2); dat += 4; } if (i >= 0x11) { // From 1.1, there's animation speed - ret->speed = READ_LE_UINT16(dat); + ret->_speed = READ_LE_UINT16(dat); dat += 2; } else - ret->speed = 150; + ret->_speed = 150; } - ret->numframe = *dat++; - ret->numpattern = *dat++; - ret->Zvalue = *dat++; + ret->_numframe = *dat++; + ret->_numpattern = *dat++; + ret->_destZ = *dat++; // Upload the left & top co-ordinates of each frame - for (i = 0; i < ret->numframe; i++) { - ret->frameslocations[i].left = (int16)READ_LE_UINT16(dat); - ret->frameslocations[i].top = (int16)READ_LE_UINT16(dat + 2); + for (i = 0; i < ret->_numframe; i++) { + ret->_frameslocations[i].left = (int16)READ_LE_UINT16(dat); + ret->_frameslocations[i].top = (int16)READ_LE_UINT16(dat + 2); dat += 4; } // Upload the size of each frame and calculate the right & bottom - for (i = 0; i < ret->numframe; i++) { - ret->frameslocations[i].right = (int16)READ_LE_UINT16(dat) + ret->frameslocations[i].left; - ret->frameslocations[i].bottom = (int16)READ_LE_UINT16(dat + 2) + ret->frameslocations[i].top; + for (i = 0; i < ret->_numframe; i++) { + ret->_frameslocations[i].right = (int16)READ_LE_UINT16(dat) + ret->_frameslocations[i].left; + ret->_frameslocations[i].bottom = (int16)READ_LE_UINT16(dat + 2) + ret->_frameslocations[i].top; dat += 4; } // Upload the bounding boxes of each frame - for (i = 0; i < ret->numframe; i++) { - ret->bbox[i].left = (int16)READ_LE_UINT16(dat); - ret->bbox[i].top = (int16)READ_LE_UINT16(dat + 2); - ret->bbox[i].right = (int16)READ_LE_UINT16(dat + 4); - ret->bbox[i].bottom = (int16)READ_LE_UINT16(dat + 6); + for (i = 0; i < ret->_numframe; i++) { + ret->_bbox[i].left = (int16)READ_LE_UINT16(dat); + ret->_bbox[i].top = (int16)READ_LE_UINT16(dat + 2); + ret->_bbox[i].right = (int16)READ_LE_UINT16(dat + 4); + ret->_bbox[i].bottom = (int16)READ_LE_UINT16(dat + 6); dat += 8; } // Load the animation pattern patlength = dat; - dat += ret->numpattern; + dat += ret->_numpattern; - for (i = 1; i < ret->numpattern; i++) { + for (i = 1; i < ret->_numpattern; i++) { for (j = 0; j < patlength[i]; j++) - ret->pattern[i][j] = dat[j]; - ret->pattern[i][(int)patlength[i]] = 255; // Terminate pattern + ret->_pattern[i][j] = dat[j]; + ret->_pattern[i][(int)patlength[i]] = 255; // Terminate pattern dat += patlength[i]; } // Upload the individual frames of animations - for (i = 1; i < ret->numframe; i++) { - dim = (uint32)(ret->frameslocations[i].right-ret->frameslocations[i].left) * - (uint32)(ret->frameslocations[i].bottom-ret->frameslocations[i].top); - ret->frames[i] = (char *)globalAlloc(GMEM_FIXED,dim); + for (i = 1; i < ret->_numframe; i++) { + dim = (uint32)(ret->_frameslocations[i].right - ret->_frameslocations[i].left) * + (uint32)(ret->_frameslocations[i].bottom - ret->_frameslocations[i].top); + ret->_frames[i] = (char *)globalAlloc(GMEM_FIXED,dim); - if (ret->frames[i] == NULL) + if (ret->_frames[i] == NULL) return NULL; - copyMemory(ret->frames[i], dat, dim); + copyMemory(ret->_frames[i], dat, dim); dat += dim; } diff --git a/engines/tony/mpal/mpal.h b/engines/tony/mpal/mpal.h index 198083f851..9ea0c40bbc 100644 --- a/engines/tony/mpal/mpal.h +++ b/engines/tony/mpal/mpal.h @@ -152,19 +152,19 @@ enum QueryTypes { * Framework to manage the animation of an item */ typedef struct { - char *frames[MAXFRAMES]; - Common::Rect frameslocations[MAXFRAMES]; - Common::Rect bbox[MAXFRAMES]; - short pattern[MAXPATTERN][MAXFRAMES]; - short speed; - char numframe; - char numpattern; - char curframe; - char curpattern; - short destX, destY; - signed char Zvalue; - short objectID; - char TAG; + char *_frames[MAXFRAMES]; + Common::Rect _frameslocations[MAXFRAMES]; + Common::Rect _bbox[MAXFRAMES]; + short _pattern[MAXPATTERN][MAXFRAMES]; + short _speed; + char _numframe; + char _numpattern; + char _curframe; + char _curpattern; + short _destX, _destY; + signed char _destZ; + short _objectID; +// char TAG; } ITEM; typedef ITEM *LPITEM; @@ -247,7 +247,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * @returns Size */ #define mpalQueryLocationSize(nLoc,dwCoord) \ - mpalQueryDWORD(MPQ_LOCATION_SIZE,(uint32)(nLoc),(uint32)(dwCoord)) + mpalQueryDWORD(MPQ_LOCATION_SIZE, (uint32)(nLoc), (uint32)(dwCoord)) /** @@ -258,7 +258,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; */ // TODO: Determine if this is endian safe #define mpalQueryItemList(nLoc) \ - (uint32 *)mpalQueryHANDLE(MPQ_ITEM_LIST,(uint32)(nLoc)) + (uint32 *)mpalQueryHANDLE(MPQ_ITEM_LIST, (uint32)(nLoc)) /** @@ -268,7 +268,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * @returns Structure filled with requested information */ #define mpalQueryItemData(nItem) \ - (LPITEM)mpalQueryHANDLE(MPQ_ITEM_DATA,(uint32)(nItem)) + (LPITEM)mpalQueryHANDLE(MPQ_ITEM_DATA, (uint32)(nItem)) /** @@ -279,7 +279,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * @remarks By default, the pattern of 0 indicates that we should do nothing. */ #define mpalQueryItemPattern(nItem) \ - mpalQueryDWORD(MPQ_ITEM_PATTERN,(uint32)(nItem)) + mpalQueryDWORD(MPQ_ITEM_PATTERN, (uint32)(nItem)) /** @@ -289,7 +289,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * @returns TRUE if the item is active, FALSE otherwise */ #define mpalQueryItemIsActive(nItem) \ - (bool)mpalQueryDWORD(MPQ_ITEM_IS_ACTIVE,(uint32)(nItem)) + (bool)mpalQueryDWORD(MPQ_ITEM_IS_ACTIVE, (uint32)(nItem)) /** @@ -302,7 +302,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * is less than or equal to 0), the string will be empty. */ #define mpalQueryItemName(nItem, lpszName) \ - mpalQueryHANDLE(MPQ_ITEM_NAME,(uint32)(nItem), (LPSTR)(lpszName)) + mpalQueryHANDLE(MPQ_ITEM_NAME, (uint32)(nItem), (LPSTR)(lpszName)) /** @@ -337,7 +337,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * The pointer msut be freed after use using the memory memory. */ #define mpalQueryDialogSelectList(nChoice) \ - (uint32 *)mpalQueryHANDLE(MPQ_DIALOG_SELECTLIST,(uint32)(nChoice)) + (uint32 *)mpalQueryHANDLE(MPQ_DIALOG_SELECTLIST, (uint32)(nChoice)) /** @@ -351,11 +351,11 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * Groups according to the execution of the dialogue. And necessary so the game * remains on hold again for another chosen by mpalQueryDialogWaitForChoice (). */ -#define mpalQueryDialogSelection(nChoice,dwData) \ - (bool)mpalQueryDWORD(MPQ_DIALOG_SELECTION,(uint32)(nChoice),(uint32)(dwData)) +#define mpalQueryDialogSelection(nChoice, dwData) \ + (bool)mpalQueryDWORD(MPQ_DIALOG_SELECTION, (uint32)(nChoice), (uint32)(dwData)) -#define mpalQueryDialogSelectionDWORD(nChoice,dwData) \ - mpalQueryDWORD(MPQ_DIALOG_SELECTION,(uint32)(nChoice),(uint32)(dwData)) +#define mpalQueryDialogSelectionDWORD(nChoice, dwData) \ + mpalQueryDWORD(MPQ_DIALOG_SELECTION, (uint32)(nChoice), (uint32)(dwData)) /** diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index f0357ad15d..6852369c64 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -178,7 +178,7 @@ void RMTony::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CODE(_ctx); // Call the Draw() of the parent class if Tony is visible - if (_bShow && bDrawNow) { + if (_bShow && _bDrawNow) { if (_bCorpoDavanti) { prim->getDst().setEmpty(); prim->getDst().offset(-44, -134); @@ -317,8 +317,8 @@ void RMTony::stop(CORO_PARAM) { if (_ctx->pid == CORO_INVALID_PID_VALUE) CORO_INVOKE_0(RMCharacter::stop); else { - bNeedToStop = false; // If we make the OnWhichDirection, we don't need at least after the Stop(). - bMoving = false; + _bNeedToStop = false; // If we make the OnWhichDirection, we don't need at least after the Stop(). + _bMoving = false; CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->pid, CORO_INFINITE); // @@@ Put an assert after 10 seconds } } else { -- cgit v1.2.3 From 7ace80b0d046126bb2d5f1199fe9f0606c05c11b Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 11 Jun 2012 00:34:45 +0200 Subject: TONY: Rename variables in font.h --- engines/tony/font.cpp | 2688 ++++++++++++++++++++++++------------------------- engines/tony/font.h | 60 +- 2 files changed, 1374 insertions(+), 1374 deletions(-) (limited to 'engines') diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 23a92c5f30..6652e77e13 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -76,7 +76,7 @@ void RMFont::load(const byte *buf, int nChars, int dimx, int dimy, uint32 palRes _fontDimx = dimx; _fontDimy = dimy; - nLetters = nChars; + _nLetters = nChars; } void RMFont::load(uint32 resID, int nChars, int dimx, int dimy, uint32 palResID) { @@ -102,7 +102,7 @@ RMGfxPrimitive *RMFont::makeLetterPrimitive(byte bChar, int &nLength) { // Convert from character to glyph index nLett = convertToLetter(bChar); - assert(nLett < nLetters); + assert(nLett < _nLetters); // Create primitive font prim = new RMFontPrimitive(this); @@ -153,7 +153,7 @@ int RMFont::stringLen(char bChar, char bNext) { \****************************************************************************/ RMFontColor::RMFontColor() : RMFont() { - m_r = m_g = m_b = 255; + _fontR = _fontG = _fontB = 255; } RMFontColor::~RMFontColor() { @@ -172,12 +172,12 @@ void RMFontColor::setBaseColor(byte r1, byte g1, byte b1) { byte pal[768 * 3]; // Check if we are already on the right colour - if (m_r == r1 && m_g == g1 && m_b == b1) + if (_fontR == r1 && _fontG == g1 && _fontB == b1) return; - m_r = r1; - m_g = g1; - m_b = b1; + _fontR = r1; + _fontG = g1; + _fontB = b1; // Constructs a new paletter for the font for (i = 1; i < 16; i++) { @@ -195,7 +195,7 @@ void RMFontColor::setBaseColor(byte r1, byte g1, byte b1) { pal[15 * 3 + 2] += 8; // Puts in all the letters - for (i = 0; i < nLetters; i++) + for (i = 0; i < _nLetters; i++) _letter[i].loadPaletteWA(pal); } @@ -219,151 +219,151 @@ void RMFontParla::init(void) { load(RES_F_PARL, nchars, 20, 20); // Initialise the f**king table - lDefault = 13; - hDefault = 18; - Common::fill(&l2Table[0][0], &l2Table[0][0] + (256 * 256), '\0'); + _lDefault = 13; + _hDefault = 18; + Common::fill(&_l2Table[0][0], &_l2Table[0][0] + (256 * 256), '\0'); for (i = 0; i < 256; i++) { - cTable[i] = -1; - lTable[i] = lDefault; + _cTable[i] = -1; + _lTable[i] = _lDefault; } for (i = 0; i < 26; i++) - cTable['A' + i] = i + 0; + _cTable['A' + i] = i + 0; for (i = 0; i < 26; i++) - cTable['a' + i] = i + 26; + _cTable['a' + i] = i + 26; for (i = 0; i < 10; i++) - cTable['0' + i] = i + 52; - - cTable[';'] = 62; - cTable[','] = 63; - cTable['.'] = 64; - cTable[':'] = 65; - cTable['-'] = 66; - cTable['_'] = 67; - cTable['+'] = 68; - cTable['<'] = 69; - cTable['>'] = 70; - cTable['!'] = 71; - //cTable['!'] = 72; Exclamation countdown - cTable['?'] = 73; - //cTable['?'] = 74; Question down - cTable['('] = 75; - cTable[')'] = 76; - cTable['\"'] = 77; - cTable['^'] = 77; - cTable['/'] = 78; - cTable[(byte)''] = 79; - cTable['$'] = 80; - cTable['%'] = 81; - cTable['&'] = 82; - cTable['='] = 83; - cTable[(byte)''] = 84; - cTable[(byte)''] = 85; - cTable[(byte)''] = 86; - cTable[(byte)''] = 87; - cTable[(byte)''] = 88; - cTable[(byte)''] = 89; - cTable[(byte)''] = 89; - cTable[(byte)''] = 90; - cTable[(byte)''] = 91; - cTable[(byte)''] = 92; - cTable[(byte)''] = 93; - cTable[(byte)''] = 94; - cTable[(byte)''] = 95; - cTable[(byte)''] = 96; - cTable[(byte)''] = 97; - cTable[(byte)''] = 98; - cTable[(byte)''] = 99; - //cTable[' '] = 100; e circlet - //cTable[' '] = 101; i circlet - //cTable[' '] = 102; o circlet - //cTable[' '] = 103; u circlet - cTable[(byte)''] = 104; - cTable[(byte)''] = 105; - cTable[(byte)''] = 106; - cTable[(byte)''] = 107; - cTable[(byte)''] = 108; - cTable[(byte)''] = 109; - //cTable[''] = 110; integral - cTable['\''] = 111; + _cTable['0' + i] = i + 52; + + _cTable[';'] = 62; + _cTable[','] = 63; + _cTable['.'] = 64; + _cTable[':'] = 65; + _cTable['-'] = 66; + _cTable['_'] = 67; + _cTable['+'] = 68; + _cTable['<'] = 69; + _cTable['>'] = 70; + _cTable['!'] = 71; + //_cTable['!'] = 72; Exclamation countdown + _cTable['?'] = 73; + //_cTable['?'] = 74; Question down + _cTable['('] = 75; + _cTable[')'] = 76; + _cTable['\"'] = 77; + _cTable['^'] = 77; + _cTable['/'] = 78; + _cTable[(byte)''] = 79; + _cTable['$'] = 80; + _cTable['%'] = 81; + _cTable['&'] = 82; + _cTable['='] = 83; + _cTable[(byte)''] = 84; + _cTable[(byte)''] = 85; + _cTable[(byte)''] = 86; + _cTable[(byte)''] = 87; + _cTable[(byte)''] = 88; + _cTable[(byte)''] = 89; + _cTable[(byte)''] = 89; + _cTable[(byte)''] = 90; + _cTable[(byte)''] = 91; + _cTable[(byte)''] = 92; + _cTable[(byte)''] = 93; + _cTable[(byte)''] = 94; + _cTable[(byte)''] = 95; + _cTable[(byte)''] = 96; + _cTable[(byte)''] = 97; + _cTable[(byte)''] = 98; + _cTable[(byte)''] = 99; + //_cTable[' '] = 100; e circlet + //_cTable[' '] = 101; i circlet + //_cTable[' '] = 102; o circlet + //_cTable[' '] = 103; u circlet + _cTable[(byte)''] = 104; + _cTable[(byte)''] = 105; + _cTable[(byte)''] = 106; + _cTable[(byte)''] = 107; + _cTable[(byte)''] = 108; + _cTable[(byte)''] = 109; + //_cTable[''] = 110; integral + _cTable['\''] = 111; // Little lengths - lTable[' '] = 9; - lTable['\''] = 5; - lTable['.'] = 5; - lTable[','] = 5; - lTable[':'] = 5; - lTable[';'] = 5; - lTable['!'] = 5; - lTable['?'] = 10; - lTable['\"'] = 5; - lTable['^'] = 5; - lTable['('] = 7; - lTable[')'] = 7; - - lTable['4'] = 10; - - lTable['a'] = 14; - lTable['b'] = 15; - lTable['c'] = 12; - lTable['e'] = 12; - lTable['i'] = 6; - lTable[''] = 6; - lTable['l'] = 5; - lTable['m'] = 16; - lTable['n'] = 12; - lTable['o'] = 11; - lTable['p'] = 11; - lTable['s'] = 12; - lTable['u'] = 12; - - lTable['E'] = 10; - lTable['F'] = 11; + _lTable[' '] = 9; + _lTable['\''] = 5; + _lTable['.'] = 5; + _lTable[','] = 5; + _lTable[':'] = 5; + _lTable[';'] = 5; + _lTable['!'] = 5; + _lTable['?'] = 10; + _lTable['\"'] = 5; + _lTable['^'] = 5; + _lTable['('] = 7; + _lTable[')'] = 7; + + _lTable['4'] = 10; + + _lTable['a'] = 14; + _lTable['b'] = 15; + _lTable['c'] = 12; + _lTable['e'] = 12; + _lTable['i'] = 6; + _lTable[''] = 6; + _lTable['l'] = 5; + _lTable['m'] = 16; + _lTable['n'] = 12; + _lTable['o'] = 11; + _lTable['p'] = 11; + _lTable['s'] = 12; + _lTable['u'] = 12; + + _lTable['E'] = 10; + _lTable['F'] = 11; if (_vm->getLanguage() == Common::PL_POL) { // Polish characters //AaCcEeLlNnOoSsZzZz //ス謎戊3剔囀 - cTable[(byte)''] = 112; - cTable[(byte)''] = 113; - cTable[(byte)''] = 114; - cTable[(byte)''] = 115; - cTable[(byte)''] = 116; - cTable[(byte)''] = 117; - cTable[(byte)''] = 118; - cTable[(byte)''] = 119; - cTable[(byte)''] = 120; - cTable[(byte)''] = 121; - cTable[(byte)''] = 122; - cTable[(byte)''] = 123; - cTable[(byte)''] = 124; - cTable[(byte)''] = 125; - cTable[(byte)''] = 126; - cTable[(byte)''] = 127; - cTable[(byte)''] = 128; - cTable[(byte)''] = 129; - - lTable[(byte)''] = 14; - lTable[(byte)''] = 16; - lTable[(byte)''] = 12; - lTable[(byte)''] = 12; - lTable[(byte)''] = 11; - lTable[(byte)''] = 12; - lTable[(byte)''] = 14; - lTable[(byte)''] = 9; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 13; - lTable[(byte)''] = 11; - lTable[(byte)''] = 12; - lTable[(byte)''] = 12; - lTable[(byte)''] = 13; - lTable[(byte)''] = 13; - lTable[(byte)''] = 14; - lTable[(byte)''] = 13; + _cTable[(byte)''] = 112; + _cTable[(byte)''] = 113; + _cTable[(byte)''] = 114; + _cTable[(byte)''] = 115; + _cTable[(byte)''] = 116; + _cTable[(byte)''] = 117; + _cTable[(byte)''] = 118; + _cTable[(byte)''] = 119; + _cTable[(byte)''] = 120; + _cTable[(byte)''] = 121; + _cTable[(byte)''] = 122; + _cTable[(byte)''] = 123; + _cTable[(byte)''] = 124; + _cTable[(byte)''] = 125; + _cTable[(byte)''] = 126; + _cTable[(byte)''] = 127; + _cTable[(byte)''] = 128; + _cTable[(byte)''] = 129; + + _lTable[(byte)''] = 14; + _lTable[(byte)''] = 16; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 14; + _lTable[(byte)''] = 9; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 13; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 13; + _lTable[(byte)''] = 13; + _lTable[(byte)''] = 14; + _lTable[(byte)''] = 13; } else if (_vm->getLanguage() == Common::RU_RUS) { @@ -372,237 +372,237 @@ void RMFontParla::init(void) { // allowing for further translations. To support Tonyin other langauges, // these mappings could be used as a basis - cTable[(byte)''] = 130; - cTable[(byte)''] = 131; - cTable[(byte)''] = 132; - cTable[(byte)''] = 133; - cTable[(byte)''] = 134; - cTable[(byte)''] = 135; - cTable[(byte)''] = 136; - cTable[(byte)''] = 137; - cTable[(byte)''] = 138; - cTable[(byte)''] = 139; - cTable[(byte)''] = 140; - cTable[(byte)''] = 141; - cTable[(byte)''] = 142; - cTable[(byte)''] = 143; - cTable[(byte)''] = 144; - cTable[(byte)''] = 145; - cTable[(byte)''] = 146; - cTable[(byte)''] = 147; - cTable[(byte)''] = 148; - cTable[(byte)''] = 149; - cTable[(byte)''] = 150; - cTable[(byte)''] = 151; - cTable[(byte)''] = 152; - cTable[(byte)''] = 153; - cTable[(byte)''] = 154; - cTable[(byte)''] = 155; - cTable[(byte)''] = 156; - cTable[(byte)''] = 157; - cTable[(byte)''] = 158; - cTable[(byte)''] = 159; - cTable[(byte)''] = 160; - cTable[(byte)''] = 161; - cTable[(byte)''] = 162; - - cTable[(byte)''] = 163; - cTable[(byte)''] = 164; - cTable[(byte)''] = 165; - cTable[(byte)''] = 166; - cTable[(byte)''] = 167; - cTable[(byte)''] = 168; - cTable[(byte)''] = 169; - cTable[(byte)''] = 170; - cTable[(byte)''] = 171; - cTable[(byte)''] = 172; - cTable[(byte)''] = 173; - cTable[(byte)''] = 174; - cTable[(byte)''] = 175; - cTable[(byte)''] = 176; - cTable[(byte)''] = 177; - cTable[(byte)''] = 178; - cTable[(byte)''] = 179; - cTable[(byte)''] = 180; - cTable[(byte)''] = 181; - cTable[(byte)''] = 182; - cTable[(byte)''] = 183; - cTable[(byte)''] = 184; - cTable[(byte)''] = 185; - cTable[(byte)''] = 186; - cTable[(byte)''] = 187; - cTable[(byte)''] = 188; - cTable[(byte)''] = 189; - cTable[(byte)''] = 190; - cTable[(byte)''] = 191; - cTable[(byte)''] = 192; - cTable[(byte)''] = 193; - cTable[(byte)''] = 194; - cTable[(byte)''] = 195; - - lTable[(byte)''] = 13; - lTable[(byte)''] = 15; - lTable[(byte)''] = 15; - lTable[(byte)''] = 11; - lTable[(byte)''] = 15; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 15; - lTable[(byte)''] = 10; - lTable[(byte)''] = 13; - lTable[(byte)''] = 13; - lTable[(byte)''] = 12; - lTable[(byte)''] = 13; - lTable[(byte)''] = 14; - lTable[(byte)''] = 14; - lTable[(byte)''] = 13; - lTable[(byte)''] = 11; - lTable[(byte)''] = 12; - lTable[(byte)''] = 12; - lTable[(byte)''] = 18; - lTable[(byte)''] = 11; - lTable[(byte)''] = 13; - lTable[(byte)''] = 12; - lTable[(byte)''] = 13; - lTable[(byte)''] = 12; - lTable[(byte)''] = 17; - lTable[(byte)''] = 18; - lTable[(byte)''] = 16; - lTable[(byte)''] = 18; - lTable[(byte)''] = 19; - lTable[(byte)''] = 11; - lTable[(byte)''] = 16; - lTable[(byte)''] = 14; - - lTable[(byte)''] = 14; - lTable[(byte)''] = 15; - lTable[(byte)''] = 10; - lTable[(byte)''] = 12; - lTable[(byte)''] = 13; - lTable[(byte)''] = 12; - lTable[(byte)''] = 12; - lTable[(byte)''] = 12; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 12; - lTable[(byte)''] = 12; - lTable[(byte)''] = 12; - lTable[(byte)''] = 12; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 14; - lTable[(byte)''] = 8; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 12; - lTable[(byte)''] = 10; - lTable[(byte)''] = 15; - lTable[(byte)''] = 16; - lTable[(byte)''] = 14; - lTable[(byte)''] = 16; - lTable[(byte)''] = 16; - lTable[(byte)''] = 9; - lTable[(byte)''] = 15; - lTable[(byte)''] = 14; + _cTable[(byte)''] = 130; + _cTable[(byte)''] = 131; + _cTable[(byte)''] = 132; + _cTable[(byte)''] = 133; + _cTable[(byte)''] = 134; + _cTable[(byte)''] = 135; + _cTable[(byte)''] = 136; + _cTable[(byte)''] = 137; + _cTable[(byte)''] = 138; + _cTable[(byte)''] = 139; + _cTable[(byte)''] = 140; + _cTable[(byte)''] = 141; + _cTable[(byte)''] = 142; + _cTable[(byte)''] = 143; + _cTable[(byte)''] = 144; + _cTable[(byte)''] = 145; + _cTable[(byte)''] = 146; + _cTable[(byte)''] = 147; + _cTable[(byte)''] = 148; + _cTable[(byte)''] = 149; + _cTable[(byte)''] = 150; + _cTable[(byte)''] = 151; + _cTable[(byte)''] = 152; + _cTable[(byte)''] = 153; + _cTable[(byte)''] = 154; + _cTable[(byte)''] = 155; + _cTable[(byte)''] = 156; + _cTable[(byte)''] = 157; + _cTable[(byte)''] = 158; + _cTable[(byte)''] = 159; + _cTable[(byte)''] = 160; + _cTable[(byte)''] = 161; + _cTable[(byte)''] = 162; + + _cTable[(byte)''] = 163; + _cTable[(byte)''] = 164; + _cTable[(byte)''] = 165; + _cTable[(byte)''] = 166; + _cTable[(byte)''] = 167; + _cTable[(byte)''] = 168; + _cTable[(byte)''] = 169; + _cTable[(byte)''] = 170; + _cTable[(byte)''] = 171; + _cTable[(byte)''] = 172; + _cTable[(byte)''] = 173; + _cTable[(byte)''] = 174; + _cTable[(byte)''] = 175; + _cTable[(byte)''] = 176; + _cTable[(byte)''] = 177; + _cTable[(byte)''] = 178; + _cTable[(byte)''] = 179; + _cTable[(byte)''] = 180; + _cTable[(byte)''] = 181; + _cTable[(byte)''] = 182; + _cTable[(byte)''] = 183; + _cTable[(byte)''] = 184; + _cTable[(byte)''] = 185; + _cTable[(byte)''] = 186; + _cTable[(byte)''] = 187; + _cTable[(byte)''] = 188; + _cTable[(byte)''] = 189; + _cTable[(byte)''] = 190; + _cTable[(byte)''] = 191; + _cTable[(byte)''] = 192; + _cTable[(byte)''] = 193; + _cTable[(byte)''] = 194; + _cTable[(byte)''] = 195; + + _lTable[(byte)''] = 13; + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 13; + _lTable[(byte)''] = 13; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 13; + _lTable[(byte)''] = 14; + _lTable[(byte)''] = 14; + _lTable[(byte)''] = 13; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 18; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 13; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 13; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 17; + _lTable[(byte)''] = 18; + _lTable[(byte)''] = 16; + _lTable[(byte)''] = 18; + _lTable[(byte)''] = 19; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 16; + _lTable[(byte)''] = 14; + + _lTable[(byte)''] = 14; + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 13; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 14; + _lTable[(byte)''] = 8; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 16; + _lTable[(byte)''] = 14; + _lTable[(byte)''] = 16; + _lTable[(byte)''] = 16; + _lTable[(byte)''] = 9; + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 14; } else if (_vm->getLanguage() == Common::CZ_CZE) { // Czech - cTable[(byte)''] = 196; - cTable[(byte)''] = 197; - cTable[(byte)''] = 198; - cTable[(byte)''] = 199; - cTable[(byte)''] = 200; - cTable[(byte)''] = 201; - cTable[(byte)''] = 202; - cTable[(byte)''] = 203; - cTable[(byte)''] = 204; - cTable[(byte)''] = 205; - cTable[(byte)''] = 206; - cTable[(byte)''] = 207; - cTable[(byte)''] = 208; - cTable[(byte)''] = 209; - cTable[(byte)''] = 210; - - cTable[(byte)''] = 211; - cTable[(byte)''] = 212; - cTable[(byte)''] = 213; - cTable[(byte)''] = 214; - cTable[(byte)''] = 215; - cTable[(byte)''] = 216; - cTable[(byte)''] = 217; - cTable[(byte)''] = 218; - cTable[(byte)''] = 219; - cTable[(byte)''] = 220; - cTable[(byte)''] = 221; - cTable[(byte)''] = 222; - cTable[(byte)''] = 223; - cTable[(byte)''] = 224; - cTable[(byte)''] = 225; - - lTable[(byte)''] = 11; - lTable[(byte)''] = 12; - lTable[(byte)''] = 12; - lTable[(byte)''] = 14; - lTable[(byte)''] = 13; - lTable[(byte)''] = 11; - lTable[(byte)''] = 13; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 15; - lTable[(byte)''] = 19; - lTable[(byte)''] = 10; - lTable[(byte)''] = 13; - lTable[(byte)''] = 13; - lTable[(byte)''] = 13; - - lTable[(byte)''] = 12; - lTable[(byte)''] = 12; - lTable[(byte)''] = 12; - lTable[(byte)''] = 12; - lTable[(byte)''] = 13; - lTable[(byte)''] = 11; - lTable[(byte)''] = 15; - lTable[(byte)''] = 7; - lTable[(byte)''] = 12; - lTable[(byte)''] = 17; - lTable[(byte)''] = 16; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 13; - lTable[(byte)''] = 13; + _cTable[(byte)''] = 196; + _cTable[(byte)''] = 197; + _cTable[(byte)''] = 198; + _cTable[(byte)''] = 199; + _cTable[(byte)''] = 200; + _cTable[(byte)''] = 201; + _cTable[(byte)''] = 202; + _cTable[(byte)''] = 203; + _cTable[(byte)''] = 204; + _cTable[(byte)''] = 205; + _cTable[(byte)''] = 206; + _cTable[(byte)''] = 207; + _cTable[(byte)''] = 208; + _cTable[(byte)''] = 209; + _cTable[(byte)''] = 210; + + _cTable[(byte)''] = 211; + _cTable[(byte)''] = 212; + _cTable[(byte)''] = 213; + _cTable[(byte)''] = 214; + _cTable[(byte)''] = 215; + _cTable[(byte)''] = 216; + _cTable[(byte)''] = 217; + _cTable[(byte)''] = 218; + _cTable[(byte)''] = 219; + _cTable[(byte)''] = 220; + _cTable[(byte)''] = 221; + _cTable[(byte)''] = 222; + _cTable[(byte)''] = 223; + _cTable[(byte)''] = 224; + _cTable[(byte)''] = 225; + + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 14; + _lTable[(byte)''] = 13; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 13; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 19; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 13; + _lTable[(byte)''] = 13; + _lTable[(byte)''] = 13; + + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 13; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 7; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 17; + _lTable[(byte)''] = 16; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 13; + _lTable[(byte)''] = 13; } else if (_vm->getLanguage() == Common::FR_FRA) { // French - cTable[(byte)''] = 226; - cTable[(byte)''] = 227; - cTable[(byte)''] = 228; - cTable[(byte)''] = 229; - cTable[(byte)''] = 230; - cTable[(byte)''] = 231; - cTable[(byte)''] = 232; - cTable[(byte)''] = 233; - - lTable[(byte)''] = 15; - lTable[(byte)''] = 12; - lTable[(byte)''] = 12; - lTable[(byte)''] = 9; - lTable[(byte)''] = 13; - lTable[(byte)''] = 13; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; + _cTable[(byte)''] = 226; + _cTable[(byte)''] = 227; + _cTable[(byte)''] = 228; + _cTable[(byte)''] = 229; + _cTable[(byte)''] = 230; + _cTable[(byte)''] = 231; + _cTable[(byte)''] = 232; + _cTable[(byte)''] = 233; + + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 9; + _lTable[(byte)''] = 13; + _lTable[(byte)''] = 13; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; } else if (_vm->getLanguage() == Common::DE_DEU) { - cTable[(byte)''] = 234; + _cTable[(byte)''] = 234; // 'SS' = 235 - cTable[(byte)''] = 236; - cTable[(byte)''] = 237; - cTable[(byte)''] = 238; + _cTable[(byte)''] = 236; + _cTable[(byte)''] = 237; + _cTable[(byte)''] = 238; - lTable[(byte)''] = 15; + _lTable[(byte)''] = 15; } } @@ -627,347 +627,347 @@ void RMFontMacc::init(void) { load(RES_F_MACC, nchars, 11, 16); // Default - lDefault = 10; - hDefault = 17; - Common::fill(&l2Table[0][0], &l2Table[0][0] + (256 * 256), '\0'); + _lDefault = 10; + _hDefault = 17; + Common::fill(&_l2Table[0][0], &_l2Table[0][0] + (256 * 256), '\0'); for (i = 0; i < 256; i++) { - cTable[i] = -1; - lTable[i] = lDefault; + _cTable[i] = -1; + _lTable[i] = _lDefault; } for (i = 0; i < 26; i++) - cTable['A' + i] = i + 0; + _cTable['A' + i] = i + 0; for (i = 0; i < 26; i++) - cTable['a' + i] = i + 26; + _cTable['a' + i] = i + 26; for (i = 0; i < 10; i++) - cTable['0' + i] = i + 52; - - cTable['!'] = 62; - //cTable['!'] = 63; // ! rovescia - cTable['\"'] = 64; - cTable['$'] = 65; - cTable['%'] = 66; - cTable['&'] = 67; - cTable['/'] = 68; - cTable['('] = 69; - cTable[')'] = 70; - cTable['='] = 71; - cTable['?'] = 72; - //cTable['?'] = 73; // ? rovescia - cTable['*'] = 74; - cTable['+'] = 75; - cTable[(byte)''] = 76; - cTable[';'] = 77; - cTable[','] = 78; - cTable['.'] = 79; - cTable[':'] = 80; - cTable['-'] = 81; - cTable['<'] = 82; - cTable['>'] = 83; - cTable['/'] = 84; - cTable[(byte)''] = 85; - cTable[(byte)''] = 86; - cTable[(byte)''] = 87; - cTable[(byte)''] = 88; - cTable[(byte)''] = 89; - cTable[(byte)''] = 90; - //cTable[(byte)''] = 91; // e with ball - cTable[(byte)''] = 92; - cTable[(byte)''] = 93; - //cTable[(byte)''] = 94; // i with ball - cTable[(byte)''] = 95; - cTable[(byte)''] = 96; - //cTable[(byte)''] = 97; // o with ball - cTable[(byte)''] = 98; - cTable[(byte)''] = 99; - //cTable[(byte)''] = 100; // u with ball - cTable[(byte)''] = 101; + _cTable['0' + i] = i + 52; + + _cTable['!'] = 62; + //_cTable['!'] = 63; // ! rovescia + _cTable['\"'] = 64; + _cTable['$'] = 65; + _cTable['%'] = 66; + _cTable['&'] = 67; + _cTable['/'] = 68; + _cTable['('] = 69; + _cTable[')'] = 70; + _cTable['='] = 71; + _cTable['?'] = 72; + //_cTable['?'] = 73; // ? rovescia + _cTable['*'] = 74; + _cTable['+'] = 75; + _cTable[(byte)''] = 76; + _cTable[';'] = 77; + _cTable[','] = 78; + _cTable['.'] = 79; + _cTable[':'] = 80; + _cTable['-'] = 81; + _cTable['<'] = 82; + _cTable['>'] = 83; + _cTable['/'] = 84; + _cTable[(byte)''] = 85; + _cTable[(byte)''] = 86; + _cTable[(byte)''] = 87; + _cTable[(byte)''] = 88; + _cTable[(byte)''] = 89; + _cTable[(byte)''] = 90; + //_cTable[(byte)''] = 91; // e with ball + _cTable[(byte)''] = 92; + _cTable[(byte)''] = 93; + //_cTable[(byte)''] = 94; // i with ball + _cTable[(byte)''] = 95; + _cTable[(byte)''] = 96; + //_cTable[(byte)''] = 97; // o with ball + _cTable[(byte)''] = 98; + _cTable[(byte)''] = 99; + //_cTable[(byte)''] = 100; // u with ball + _cTable[(byte)''] = 101; if (_vm->getLanguage() == Common::PL_POL) { // Polish characters //AaCcEeLlNnOoSsZzZz //ス謎戊3剔囀 - cTable[(byte)''] = 102; - cTable[(byte)''] = 103; - cTable[(byte)''] = 104; - cTable[(byte)''] = 105; - cTable[(byte)''] = 106; - cTable[(byte)''] = 107; - cTable[(byte)''] = 108; - cTable[(byte)''] = 109; - cTable[(byte)''] = 110; - cTable[(byte)''] = 111; - cTable[(byte)''] = 112; - cTable[(byte)''] = 113; - cTable[(byte)''] = 114; - cTable[(byte)''] = 115; - cTable[(byte)''] = 116; - cTable[(byte)''] = 117; - cTable[(byte)''] = 118; - cTable[(byte)''] = 119; - - lTable[(byte)''] = 14; - lTable[(byte)''] = 16; - lTable[(byte)''] = 12; - lTable[(byte)''] = 12; - lTable[(byte)''] = 11; - lTable[(byte)''] = 12; - lTable[(byte)''] = 14; - lTable[(byte)''] = 9; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 13; - lTable[(byte)''] = 11; - lTable[(byte)''] = 12; - lTable[(byte)''] = 12; - lTable[(byte)''] = 13; - lTable[(byte)''] = 13; - lTable[(byte)''] = 14; - lTable[(byte)''] = 13; + _cTable[(byte)''] = 102; + _cTable[(byte)''] = 103; + _cTable[(byte)''] = 104; + _cTable[(byte)''] = 105; + _cTable[(byte)''] = 106; + _cTable[(byte)''] = 107; + _cTable[(byte)''] = 108; + _cTable[(byte)''] = 109; + _cTable[(byte)''] = 110; + _cTable[(byte)''] = 111; + _cTable[(byte)''] = 112; + _cTable[(byte)''] = 113; + _cTable[(byte)''] = 114; + _cTable[(byte)''] = 115; + _cTable[(byte)''] = 116; + _cTable[(byte)''] = 117; + _cTable[(byte)''] = 118; + _cTable[(byte)''] = 119; + + _lTable[(byte)''] = 14; + _lTable[(byte)''] = 16; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 14; + _lTable[(byte)''] = 9; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 13; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 13; + _lTable[(byte)''] = 13; + _lTable[(byte)''] = 14; + _lTable[(byte)''] = 13; } else if (_vm->getLanguage() == Common::RU_RUS) { // Russian Characters // WARNING: The Russian font uses many of the ISO-Latin-1 font, // allowing for further translations. To support Tonyin other langauges, // these mappings could be used as a basis - cTable[(byte)''] = 120; - cTable[(byte)''] = 121; - cTable[(byte)''] = 122; - cTable[(byte)''] = 123; - cTable[(byte)''] = 124; - cTable[(byte)''] = 125; - cTable[(byte)''] = 126; - cTable[(byte)''] = 127; - cTable[(byte)''] = 128; - cTable[(byte)''] = 129; - cTable[(byte)''] = 130; - cTable[(byte)''] = 131; - cTable[(byte)''] = 132; - cTable[(byte)''] = 133; - cTable[(byte)''] = 134; - cTable[(byte)''] = 135; - cTable[(byte)''] = 136; - cTable[(byte)''] = 137; - cTable[(byte)''] = 138; - cTable[(byte)''] = 139; - cTable[(byte)''] = 140; - cTable[(byte)''] = 141; - cTable[(byte)''] = 142; - cTable[(byte)''] = 143; - cTable[(byte)''] = 144; - cTable[(byte)''] = 145; - cTable[(byte)''] = 146; - cTable[(byte)''] = 147; - cTable[(byte)''] = 148; - cTable[(byte)''] = 149; - cTable[(byte)''] = 150; - cTable[(byte)''] = 151; - cTable[(byte)''] = 152; - - cTable[(byte)''] = 153; - cTable[(byte)''] = 154; - cTable[(byte)''] = 155; - cTable[(byte)''] = 156; - cTable[(byte)''] = 157; - cTable[(byte)''] = 158; - cTable[(byte)''] = 159; - cTable[(byte)''] = 160; - cTable[(byte)''] = 161; - cTable[(byte)''] = 162; - cTable[(byte)''] = 163; - cTable[(byte)''] = 164; - cTable[(byte)''] = 165; - cTable[(byte)''] = 166; - cTable[(byte)''] = 167; - cTable[(byte)''] = 168; - cTable[(byte)''] = 169; - cTable[(byte)''] = 170; - cTable[(byte)''] = 171; - cTable[(byte)''] = 172; - cTable[(byte)''] = 173; - cTable[(byte)''] = 174; - cTable[(byte)''] = 175; - cTable[(byte)''] = 176; - cTable[(byte)''] = 177; - cTable[(byte)''] = 178; - cTable[(byte)''] = 179; - cTable[(byte)''] = 180; - cTable[(byte)''] = 181; - cTable[(byte)''] = 182; - cTable[(byte)''] = 183; - cTable[(byte)''] = 184; - cTable[(byte)''] = 185; - - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 9; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 9; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 8; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 9; - lTable[(byte)''] = 10; - lTable[(byte)''] = 9; - lTable[(byte)''] = 10; - lTable[(byte)''] = 9; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 9; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 9; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 9; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; + _cTable[(byte)''] = 120; + _cTable[(byte)''] = 121; + _cTable[(byte)''] = 122; + _cTable[(byte)''] = 123; + _cTable[(byte)''] = 124; + _cTable[(byte)''] = 125; + _cTable[(byte)''] = 126; + _cTable[(byte)''] = 127; + _cTable[(byte)''] = 128; + _cTable[(byte)''] = 129; + _cTable[(byte)''] = 130; + _cTable[(byte)''] = 131; + _cTable[(byte)''] = 132; + _cTable[(byte)''] = 133; + _cTable[(byte)''] = 134; + _cTable[(byte)''] = 135; + _cTable[(byte)''] = 136; + _cTable[(byte)''] = 137; + _cTable[(byte)''] = 138; + _cTable[(byte)''] = 139; + _cTable[(byte)''] = 140; + _cTable[(byte)''] = 141; + _cTable[(byte)''] = 142; + _cTable[(byte)''] = 143; + _cTable[(byte)''] = 144; + _cTable[(byte)''] = 145; + _cTable[(byte)''] = 146; + _cTable[(byte)''] = 147; + _cTable[(byte)''] = 148; + _cTable[(byte)''] = 149; + _cTable[(byte)''] = 150; + _cTable[(byte)''] = 151; + _cTable[(byte)''] = 152; + + _cTable[(byte)''] = 153; + _cTable[(byte)''] = 154; + _cTable[(byte)''] = 155; + _cTable[(byte)''] = 156; + _cTable[(byte)''] = 157; + _cTable[(byte)''] = 158; + _cTable[(byte)''] = 159; + _cTable[(byte)''] = 160; + _cTable[(byte)''] = 161; + _cTable[(byte)''] = 162; + _cTable[(byte)''] = 163; + _cTable[(byte)''] = 164; + _cTable[(byte)''] = 165; + _cTable[(byte)''] = 166; + _cTable[(byte)''] = 167; + _cTable[(byte)''] = 168; + _cTable[(byte)''] = 169; + _cTable[(byte)''] = 170; + _cTable[(byte)''] = 171; + _cTable[(byte)''] = 172; + _cTable[(byte)''] = 173; + _cTable[(byte)''] = 174; + _cTable[(byte)''] = 175; + _cTable[(byte)''] = 176; + _cTable[(byte)''] = 177; + _cTable[(byte)''] = 178; + _cTable[(byte)''] = 179; + _cTable[(byte)''] = 180; + _cTable[(byte)''] = 181; + _cTable[(byte)''] = 182; + _cTable[(byte)''] = 183; + _cTable[(byte)''] = 184; + _cTable[(byte)''] = 185; + + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 9; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 9; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 8; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 9; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 9; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 9; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 9; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 9; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 9; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; } else if (_vm->getLanguage() == Common::CZ_CZE) { // Czech - cTable[(byte)''] = 186; - cTable[(byte)''] = 187; - cTable[(byte)''] = 188; - cTable[(byte)''] = 189; - cTable[(byte)''] = 190; - cTable[(byte)''] = 191; - cTable[(byte)''] = 192; - cTable[(byte)''] = 193; - cTable[(byte)''] = 194; - cTable[(byte)''] = 195; - cTable[(byte)''] = 196; - cTable[(byte)''] = 197; - cTable[(byte)''] = 198; - cTable[(byte)''] = 199; - cTable[(byte)''] = 200; - - cTable[(byte)''] = 201; - cTable[(byte)''] = 202; - cTable[(byte)''] = 203; - cTable[(byte)''] = 204; - cTable[(byte)''] = 205; - cTable[(byte)''] = 206; - cTable[(byte)''] = 207; - cTable[(byte)''] = 208; - cTable[(byte)''] = 209; - cTable[(byte)''] = 210; - cTable[(byte)''] = 211; - cTable[(byte)''] = 212; - cTable[(byte)''] = 213; - cTable[(byte)''] = 214; - cTable[(byte)''] = 215; - - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 9; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 9; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - - lTable[(byte)''] = 10; - lTable[(byte)''] = 9; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 9; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 9; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; + _cTable[(byte)''] = 186; + _cTable[(byte)''] = 187; + _cTable[(byte)''] = 188; + _cTable[(byte)''] = 189; + _cTable[(byte)''] = 190; + _cTable[(byte)''] = 191; + _cTable[(byte)''] = 192; + _cTable[(byte)''] = 193; + _cTable[(byte)''] = 194; + _cTable[(byte)''] = 195; + _cTable[(byte)''] = 196; + _cTable[(byte)''] = 197; + _cTable[(byte)''] = 198; + _cTable[(byte)''] = 199; + _cTable[(byte)''] = 200; + + _cTable[(byte)''] = 201; + _cTable[(byte)''] = 202; + _cTable[(byte)''] = 203; + _cTable[(byte)''] = 204; + _cTable[(byte)''] = 205; + _cTable[(byte)''] = 206; + _cTable[(byte)''] = 207; + _cTable[(byte)''] = 208; + _cTable[(byte)''] = 209; + _cTable[(byte)''] = 210; + _cTable[(byte)''] = 211; + _cTable[(byte)''] = 212; + _cTable[(byte)''] = 213; + _cTable[(byte)''] = 214; + _cTable[(byte)''] = 215; + + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 9; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 9; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 9; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 9; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 9; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; } else if (_vm->getLanguage() == Common::FR_FRA) { // French - cTable[(byte)''] = 226; - cTable[(byte)''] = 227; - cTable[(byte)''] = 228; - cTable[(byte)''] = 229; - cTable[(byte)''] = 230; - cTable[(byte)''] = 231; - cTable[(byte)''] = 232; - cTable[(byte)''] = 233; - - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 8; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; + _cTable[(byte)''] = 226; + _cTable[(byte)''] = 227; + _cTable[(byte)''] = 228; + _cTable[(byte)''] = 229; + _cTable[(byte)''] = 230; + _cTable[(byte)''] = 231; + _cTable[(byte)''] = 232; + _cTable[(byte)''] = 233; + + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 8; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 10; } else if (_vm->getLanguage() == Common::DE_DEU) { // German - cTable[(byte)''] = 234; + _cTable[(byte)''] = 234; // 'SS' = 235 - cTable[(byte)''] = 236; - cTable[(byte)''] = 237; - cTable[(byte)''] = 238; + _cTable[(byte)''] = 236; + _cTable[(byte)''] = 237; + _cTable[(byte)''] = 238; - lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; } } @@ -991,435 +991,435 @@ void RMFontCredits::init(void) { load(RES_F_CREDITS, nchars, 27, 28, RES_F_CPAL); // Default - lDefault = 10; - hDefault = 28; - Common::fill(&l2Table[0][0], &l2Table[0][0] + (256 * 256), '\0'); + _lDefault = 10; + _hDefault = 28; + Common::fill(&_l2Table[0][0], &_l2Table[0][0] + (256 * 256), '\0'); for (i = 0; i < 256; i++) { - cTable[i] = -1; - lTable[i] = lDefault; + _cTable[i] = -1; + _lTable[i] = _lDefault; } for (i = 0; i < 26; i++) - cTable['A' + i] = i + 0; + _cTable['A' + i] = i + 0; for (i = 0; i < 26; i++) - cTable['a' + i] = i + 26; - - - - cTable[(byte)''] = 52; - cTable[(byte)''] = 53; -// cTable[''] = 54; // a ^ -// cTable[''] = 55; // a pallini - cTable[(byte)''] = 56; - cTable[(byte)''] = 57; -// cTable[''] = 58; // e ^ -// cTable[''] = 59; // e pallini - cTable[(byte)''] = 60; - cTable[(byte)''] = 61; -// cTable[''] = 62; // i ^ -// cTable[''] = 63; // i pallini - cTable[(byte)''] = 64; - cTable[(byte)''] = 65; -// cTable[''] = 66; // o ^ -// cTable[''] = 67; // o pallini - cTable[(byte)''] = 68; - cTable[(byte)''] = 69; -// cTable[''] = 70; // u ^ -// cTable[''] = 71; // u pallini -// cTable[''] = 72; // y pallini - cTable[(byte)''] = 73; - cTable[(byte)''] = 74; -// cTable[''] = 75; // o barrato -// cTable[''] = 76; // ac - cTable[(byte)''] = 77; -// cTable[''] = 78; // ? rovesciato - cTable['?'] = 79; -// cTable[''] = 80; // ! rovesciato - cTable['!'] = 81; -// cTable[''] = 82; // 1/2 -// cTable[''] = 83; // 1/4 - cTable['('] = 84; - cTable[')'] = 85; - cTable[(byte)''] = 86; - cTable[(byte)''] = 87; -// cTable[''] = 88; // AE - cTable[':'] = 89; - cTable['%'] = 90; - cTable['&'] = 91; - cTable['/'] = 92; - cTable['+'] = 93; - cTable[';'] = 94; - cTable[','] = 95; - cTable['^'] = 96; - cTable['='] = 97; - cTable['_'] = 98; - cTable['*'] = 99; - cTable['.'] = 100; + _cTable['a' + i] = i + 26; + + + + _cTable[(byte)''] = 52; + _cTable[(byte)''] = 53; +// _cTable[''] = 54; // a ^ +// _cTable[''] = 55; // a pallini + _cTable[(byte)''] = 56; + _cTable[(byte)''] = 57; +// _cTable[''] = 58; // e ^ +// _cTable[''] = 59; // e pallini + _cTable[(byte)''] = 60; + _cTable[(byte)''] = 61; +// _cTable[''] = 62; // i ^ +// _cTable[''] = 63; // i pallini + _cTable[(byte)''] = 64; + _cTable[(byte)''] = 65; +// _cTable[''] = 66; // o ^ +// _cTable[''] = 67; // o pallini + _cTable[(byte)''] = 68; + _cTable[(byte)''] = 69; +// _cTable[''] = 70; // u ^ +// _cTable[''] = 71; // u pallini +// _cTable[''] = 72; // y pallini + _cTable[(byte)''] = 73; + _cTable[(byte)''] = 74; +// _cTable[''] = 75; // o barrato +// _cTable[''] = 76; // ac + _cTable[(byte)''] = 77; +// _cTable[''] = 78; // ? rovesciato + _cTable['?'] = 79; +// _cTable[''] = 80; // ! rovesciato + _cTable['!'] = 81; +// _cTable[''] = 82; // 1/2 +// _cTable[''] = 83; // 1/4 + _cTable['('] = 84; + _cTable[')'] = 85; + _cTable[(byte)''] = 86; + _cTable[(byte)''] = 87; +// _cTable[''] = 88; // AE + _cTable[':'] = 89; + _cTable['%'] = 90; + _cTable['&'] = 91; + _cTable['/'] = 92; + _cTable['+'] = 93; + _cTable[';'] = 94; + _cTable[','] = 95; + _cTable['^'] = 96; + _cTable['='] = 97; + _cTable['_'] = 98; + _cTable['*'] = 99; + _cTable['.'] = 100; for (i = 0; i < 10; i++) - cTable['0' + i] = i + 101; - cTable['\''] = 111; - - lTable[' '] = 11; - lTable[(byte)''] = lTable['A'] = 19; - lTable['B'] = 15; - lTable['C'] = 14; - lTable['D'] = 13; - lTable['E'] = 14; - lTable['F'] = 13; - lTable['G'] = 16; - lTable['H'] = 15; - lTable['I'] = 5; - lTable['J'] = 8; - lTable['K'] = 15; - lTable['L'] = 13; - lTable['M'] = 17; - lTable['N'] = 15; - lTable[''] = lTable['O'] = 14; - lTable['P'] = 12; - lTable['Q'] = 14; - lTable['R'] = 14; - lTable['S'] = 15; - lTable['T'] = 11; - lTable[''] = lTable['U'] = 12; - lTable['V'] = 12; - lTable['W'] = 16; - lTable['X'] = 12; - lTable['Y'] = 13; - lTable['Z'] = 14; - - lTable['a'] = 11; - lTable['b'] = 9; - lTable['c'] = 9; - lTable['d'] = 10; - lTable['e'] = 9; - lTable['f'] = 8; - lTable['g'] = 9; - lTable['h'] = 10; - lTable['i'] = 5; - lTable['j'] = 6; - lTable['k'] = 12; - lTable['l'] = 6; - lTable['m'] = 14; - lTable['n'] = 10; - lTable['o'] = 11; - lTable['p'] = 11; - lTable['q'] = 9; - lTable['r'] = 9; - lTable['s'] = 9; - lTable['t'] = 6; - lTable['u'] = 9; - lTable['v'] = 10; - lTable['w'] = 14; - lTable['x'] = 9; - lTable['y'] = 10; - lTable['z'] = 9; - - lTable['0'] = 12; - lTable['1'] = 8; - lTable['2'] = 10; - lTable['3'] = 11; - lTable['4'] = 12; - lTable['5'] = 11; - lTable['6'] = 12; - lTable['7'] = 10; - lTable['8'] = 11; - lTable['9'] = 10; - - lTable['/'] = 10; - lTable['^'] = 9; - lTable[','] = 5; - lTable['.'] = 5; - lTable[';'] = 5; - lTable[':'] = 5; - lTable['\''] = 5; + _cTable['0' + i] = i + 101; + _cTable['\''] = 111; + + _lTable[' '] = 11; + _lTable[(byte)''] = _lTable['A'] = 19; + _lTable['B'] = 15; + _lTable['C'] = 14; + _lTable['D'] = 13; + _lTable['E'] = 14; + _lTable['F'] = 13; + _lTable['G'] = 16; + _lTable['H'] = 15; + _lTable['I'] = 5; + _lTable['J'] = 8; + _lTable['K'] = 15; + _lTable['L'] = 13; + _lTable['M'] = 17; + _lTable['N'] = 15; + _lTable[''] = _lTable['O'] = 14; + _lTable['P'] = 12; + _lTable['Q'] = 14; + _lTable['R'] = 14; + _lTable['S'] = 15; + _lTable['T'] = 11; + _lTable[''] = _lTable['U'] = 12; + _lTable['V'] = 12; + _lTable['W'] = 16; + _lTable['X'] = 12; + _lTable['Y'] = 13; + _lTable['Z'] = 14; + + _lTable['a'] = 11; + _lTable['b'] = 9; + _lTable['c'] = 9; + _lTable['d'] = 10; + _lTable['e'] = 9; + _lTable['f'] = 8; + _lTable['g'] = 9; + _lTable['h'] = 10; + _lTable['i'] = 5; + _lTable['j'] = 6; + _lTable['k'] = 12; + _lTable['l'] = 6; + _lTable['m'] = 14; + _lTable['n'] = 10; + _lTable['o'] = 11; + _lTable['p'] = 11; + _lTable['q'] = 9; + _lTable['r'] = 9; + _lTable['s'] = 9; + _lTable['t'] = 6; + _lTable['u'] = 9; + _lTable['v'] = 10; + _lTable['w'] = 14; + _lTable['x'] = 9; + _lTable['y'] = 10; + _lTable['z'] = 9; + + _lTable['0'] = 12; + _lTable['1'] = 8; + _lTable['2'] = 10; + _lTable['3'] = 11; + _lTable['4'] = 12; + _lTable['5'] = 11; + _lTable['6'] = 12; + _lTable['7'] = 10; + _lTable['8'] = 11; + _lTable['9'] = 10; + + _lTable['/'] = 10; + _lTable['^'] = 9; + _lTable[','] = 5; + _lTable['.'] = 5; + _lTable[';'] = 5; + _lTable[':'] = 5; + _lTable['\''] = 5; if (_vm->getLanguage() == Common::PL_POL) { // Polish characters //AaCcEeLlNnOoSsZzZz //ス謎戊3剔囀 - cTable[(byte)''] = 112; - cTable[(byte)''] = 113; - cTable[(byte)''] = 114; - cTable[(byte)''] = 115; - cTable[(byte)''] = 116; - cTable[(byte)''] = 117; - cTable[(byte)''] = 118; - cTable[(byte)''] = 119; - cTable[(byte)''] = 120; - cTable[(byte)''] = 121; - cTable[(byte)''] = 122; - cTable[(byte)''] = 123; - cTable[(byte)''] = 124; - cTable[(byte)''] = 125; - cTable[(byte)''] = 126; - cTable[(byte)''] = 127; - cTable[(byte)''] = 128; - cTable[(byte)''] = 129; - - lTable[(byte)''] = 20; - lTable[(byte)''] = 12; - lTable[(byte)''] = 15; - lTable[(byte)''] = 10; - lTable[(byte)''] = 15; - lTable[(byte)''] = 10; - lTable[(byte)''] = 14; - lTable[(byte)''] = 11; - lTable[(byte)''] = 16; - lTable[(byte)''] = 10; - lTable[(byte)''] = 15; - lTable[(byte)''] = 11; - lTable[(byte)''] = 15; - lTable[(byte)''] = 10; - lTable[(byte)''] = 15; - lTable[(byte)''] = 10; - lTable[(byte)''] = 15; - lTable[(byte)''] = 10; + _cTable[(byte)''] = 112; + _cTable[(byte)''] = 113; + _cTable[(byte)''] = 114; + _cTable[(byte)''] = 115; + _cTable[(byte)''] = 116; + _cTable[(byte)''] = 117; + _cTable[(byte)''] = 118; + _cTable[(byte)''] = 119; + _cTable[(byte)''] = 120; + _cTable[(byte)''] = 121; + _cTable[(byte)''] = 122; + _cTable[(byte)''] = 123; + _cTable[(byte)''] = 124; + _cTable[(byte)''] = 125; + _cTable[(byte)''] = 126; + _cTable[(byte)''] = 127; + _cTable[(byte)''] = 128; + _cTable[(byte)''] = 129; + + _lTable[(byte)''] = 20; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 14; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 16; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 10; } else if (_vm->getLanguage() == Common::RU_RUS) { // Russian Characters // WARNING: The Russian font uses many of the ISO-Latin-1 font, // allowing for further translations. To support Tonyin other langauges, // these mappings could be used as a basis - cTable[(byte)''] = 130; - cTable[(byte)''] = 131; - cTable[(byte)''] = 132; - cTable[(byte)''] = 133; - cTable[(byte)''] = 134; - cTable[(byte)''] = 135; - cTable[(byte)''] = 136; - cTable[(byte)''] = 137; - cTable[(byte)''] = 138; - cTable[(byte)''] = 139; - cTable[(byte)''] = 140; - cTable[(byte)''] = 141; - cTable[(byte)''] = 142; - cTable[(byte)''] = 143; - cTable[(byte)''] = 144; - cTable[(byte)''] = 145; - cTable[(byte)''] = 146; - cTable[(byte)''] = 147; - cTable[(byte)''] = 148; - cTable[(byte)''] = 149; - cTable[(byte)''] = 150; - cTable[(byte)''] = 151; - cTable[(byte)''] = 152; - cTable[(byte)''] = 153; - cTable[(byte)''] = 154; - cTable[(byte)''] = 155; - cTable[(byte)''] = 156; - cTable[(byte)''] = 157; - cTable[(byte)''] = 158; - cTable[(byte)''] = 159; - cTable[(byte)''] = 160; - cTable[(byte)''] = 161; - cTable[(byte)''] = 162; - - cTable[(byte)''] = 163; - cTable[(byte)''] = 164; - cTable[(byte)''] = 165; - cTable[(byte)''] = 166; - cTable[(byte)''] = 167; - cTable[(byte)''] = 168; - cTable[(byte)''] = 169; - cTable[(byte)''] = 170; - cTable[(byte)''] = 171; - cTable[(byte)''] = 172; - cTable[(byte)''] = 173; - cTable[(byte)''] = 174; - cTable[(byte)''] = 175; - cTable[(byte)''] = 176; - cTable[(byte)''] = 177; - cTable[(byte)''] = 178; - cTable[(byte)''] = 179; - cTable[(byte)''] = 180; - cTable[(byte)''] = 181; - cTable[(byte)''] = 182; - cTable[(byte)''] = 183; - cTable[(byte)''] = 184; - cTable[(byte)''] = 185; - cTable[(byte)''] = 186; - cTable[(byte)''] = 187; - cTable[(byte)''] = 188; - cTable[(byte)''] = 189; - cTable[(byte)''] = 190; - cTable[(byte)''] = 191; - cTable[(byte)''] = 192; - cTable[(byte)''] = 193; - cTable[(byte)''] = 194; - cTable[(byte)''] = 195; - - lTable[(byte)''] = 20; - lTable[(byte)''] = 16; - lTable[(byte)''] = 16; - lTable[(byte)''] = 14; - lTable[(byte)''] = 22; - lTable[(byte)''] = 15; - lTable[(byte)''] = 15; - lTable[(byte)''] = 20; - lTable[(byte)''] = 12; - lTable[(byte)''] = 16; - lTable[(byte)''] = 16; - lTable[(byte)''] = 16; - lTable[(byte)''] = 22; - lTable[(byte)''] = 18; - lTable[(byte)''] = 16; - lTable[(byte)''] = 15; - lTable[(byte)''] = 14; - lTable[(byte)''] = 13; - lTable[(byte)''] = 15; - lTable[(byte)''] = 12; - lTable[(byte)''] = 14; - lTable[(byte)''] = 15; - lTable[(byte)''] = 13; - lTable[(byte)''] = 16; - lTable[(byte)''] = 14; - lTable[(byte)''] = 23; - lTable[(byte)''] = 23; - lTable[(byte)''] = 10; - lTable[(byte)''] = 12; - lTable[(byte)''] = 16; - lTable[(byte)''] = 12; - lTable[(byte)''] = 20; - lTable[(byte)''] = 15; - - lTable[(byte)''] = 12; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 16; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 13; - lTable[(byte)''] = 12; - lTable[(byte)''] = 13; - lTable[(byte)''] = 13; - lTable[(byte)''] = 12; - lTable[(byte)''] = 13; - lTable[(byte)''] = 14; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 12; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 15; - lTable[(byte)''] = 15; - lTable[(byte)''] = 10; - lTable[(byte)''] = 12; - lTable[(byte)''] = 16; - lTable[(byte)''] = 11; - lTable[(byte)''] = 13; - lTable[(byte)''] = 11; + _cTable[(byte)''] = 130; + _cTable[(byte)''] = 131; + _cTable[(byte)''] = 132; + _cTable[(byte)''] = 133; + _cTable[(byte)''] = 134; + _cTable[(byte)''] = 135; + _cTable[(byte)''] = 136; + _cTable[(byte)''] = 137; + _cTable[(byte)''] = 138; + _cTable[(byte)''] = 139; + _cTable[(byte)''] = 140; + _cTable[(byte)''] = 141; + _cTable[(byte)''] = 142; + _cTable[(byte)''] = 143; + _cTable[(byte)''] = 144; + _cTable[(byte)''] = 145; + _cTable[(byte)''] = 146; + _cTable[(byte)''] = 147; + _cTable[(byte)''] = 148; + _cTable[(byte)''] = 149; + _cTable[(byte)''] = 150; + _cTable[(byte)''] = 151; + _cTable[(byte)''] = 152; + _cTable[(byte)''] = 153; + _cTable[(byte)''] = 154; + _cTable[(byte)''] = 155; + _cTable[(byte)''] = 156; + _cTable[(byte)''] = 157; + _cTable[(byte)''] = 158; + _cTable[(byte)''] = 159; + _cTable[(byte)''] = 160; + _cTable[(byte)''] = 161; + _cTable[(byte)''] = 162; + + _cTable[(byte)''] = 163; + _cTable[(byte)''] = 164; + _cTable[(byte)''] = 165; + _cTable[(byte)''] = 166; + _cTable[(byte)''] = 167; + _cTable[(byte)''] = 168; + _cTable[(byte)''] = 169; + _cTable[(byte)''] = 170; + _cTable[(byte)''] = 171; + _cTable[(byte)''] = 172; + _cTable[(byte)''] = 173; + _cTable[(byte)''] = 174; + _cTable[(byte)''] = 175; + _cTable[(byte)''] = 176; + _cTable[(byte)''] = 177; + _cTable[(byte)''] = 178; + _cTable[(byte)''] = 179; + _cTable[(byte)''] = 180; + _cTable[(byte)''] = 181; + _cTable[(byte)''] = 182; + _cTable[(byte)''] = 183; + _cTable[(byte)''] = 184; + _cTable[(byte)''] = 185; + _cTable[(byte)''] = 186; + _cTable[(byte)''] = 187; + _cTable[(byte)''] = 188; + _cTable[(byte)''] = 189; + _cTable[(byte)''] = 190; + _cTable[(byte)''] = 191; + _cTable[(byte)''] = 192; + _cTable[(byte)''] = 193; + _cTable[(byte)''] = 194; + _cTable[(byte)''] = 195; + + _lTable[(byte)''] = 20; + _lTable[(byte)''] = 16; + _lTable[(byte)''] = 16; + _lTable[(byte)''] = 14; + _lTable[(byte)''] = 22; + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 20; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 16; + _lTable[(byte)''] = 16; + _lTable[(byte)''] = 16; + _lTable[(byte)''] = 22; + _lTable[(byte)''] = 18; + _lTable[(byte)''] = 16; + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 14; + _lTable[(byte)''] = 13; + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 14; + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 13; + _lTable[(byte)''] = 16; + _lTable[(byte)''] = 14; + _lTable[(byte)''] = 23; + _lTable[(byte)''] = 23; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 16; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 20; + _lTable[(byte)''] = 15; + + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 16; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 13; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 13; + _lTable[(byte)''] = 13; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 13; + _lTable[(byte)''] = 14; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 16; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 13; + _lTable[(byte)''] = 11; } else if (_vm->getLanguage() == Common::CZ_CZE) { // CZECH Language - cTable[(byte)''] = 196; - cTable[(byte)''] = 197; - cTable[(byte)''] = 198; - cTable[(byte)''] = 199; - cTable[(byte)''] = 200; - cTable[(byte)''] = 201; - cTable[(byte)''] = 202; - cTable[(byte)''] = 203; - cTable[(byte)''] = 204; - cTable[(byte)''] = 205; - cTable[(byte)''] = 206; - cTable[(byte)''] = 207; - cTable[(byte)''] = 208; - cTable[(byte)''] = 209; - cTable[(byte)''] = 210; - - cTable[(byte)''] = 211; - cTable[(byte)''] = 212; - cTable[(byte)''] = 213; - cTable[(byte)''] = 214; - cTable[(byte)''] = 215; - cTable[(byte)''] = 216; - cTable[(byte)''] = 217; - cTable[(byte)''] = 218; - cTable[(byte)''] = 219; - cTable[(byte)''] = 220; - cTable[(byte)''] = 221; - cTable[(byte)''] = 222; - cTable[(byte)''] = 223; - cTable[(byte)''] = 224; - cTable[(byte)''] = 225; - - lTable[(byte)''] = 15; - lTable[(byte)''] = 15; - lTable[(byte)''] = 15; - lTable[(byte)''] = 15; - lTable[(byte)''] = 15; - lTable[(byte)''] = 14; - lTable[(byte)''] = 20; - lTable[(byte)''] = 7; - lTable[(byte)''] = 15; - lTable[(byte)''] = 20; - lTable[(byte)''] = 19; - lTable[(byte)''] = 16; - lTable[(byte)''] = 15; - lTable[(byte)''] = 13; - lTable[(byte)''] = 13; - - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 12; - lTable[(byte)''] = 6; - lTable[(byte)''] = 10; - lTable[(byte)''] = 15; - lTable[(byte)''] = 12; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; + _cTable[(byte)''] = 196; + _cTable[(byte)''] = 197; + _cTable[(byte)''] = 198; + _cTable[(byte)''] = 199; + _cTable[(byte)''] = 200; + _cTable[(byte)''] = 201; + _cTable[(byte)''] = 202; + _cTable[(byte)''] = 203; + _cTable[(byte)''] = 204; + _cTable[(byte)''] = 205; + _cTable[(byte)''] = 206; + _cTable[(byte)''] = 207; + _cTable[(byte)''] = 208; + _cTable[(byte)''] = 209; + _cTable[(byte)''] = 210; + + _cTable[(byte)''] = 211; + _cTable[(byte)''] = 212; + _cTable[(byte)''] = 213; + _cTable[(byte)''] = 214; + _cTable[(byte)''] = 215; + _cTable[(byte)''] = 216; + _cTable[(byte)''] = 217; + _cTable[(byte)''] = 218; + _cTable[(byte)''] = 219; + _cTable[(byte)''] = 220; + _cTable[(byte)''] = 221; + _cTable[(byte)''] = 222; + _cTable[(byte)''] = 223; + _cTable[(byte)''] = 224; + _cTable[(byte)''] = 225; + + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 14; + _lTable[(byte)''] = 20; + _lTable[(byte)''] = 7; + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 20; + _lTable[(byte)''] = 19; + _lTable[(byte)''] = 16; + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 13; + _lTable[(byte)''] = 13; + + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 6; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 15; + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 10; } else if (_vm->getLanguage() == Common::FR_FRA) { // French - cTable[(byte)''] = 226; - cTable[(byte)''] = 227; - cTable[(byte)''] = 228; - cTable[(byte)''] = 229; - cTable[(byte)''] = 230; - cTable[(byte)''] = 231; - cTable[(byte)''] = 232; - cTable[(byte)''] = 233; - - lTable[(byte)''] = 12; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 6; - lTable[(byte)''] = 10; - lTable[(byte)''] = 10; - lTable[(byte)''] = 11; - lTable[(byte)''] = 11; + _cTable[(byte)''] = 226; + _cTable[(byte)''] = 227; + _cTable[(byte)''] = 228; + _cTable[(byte)''] = 229; + _cTable[(byte)''] = 230; + _cTable[(byte)''] = 231; + _cTable[(byte)''] = 232; + _cTable[(byte)''] = 233; + + _lTable[(byte)''] = 12; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 6; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 10; + _lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; } else if (_vm->getLanguage() == Common::DE_DEU) { // German - cTable[(byte)''] = 234; + _cTable[(byte)''] = 234; // 'SS' = 235 // old chars overrides - cTable[(byte)''] = cTable[(byte)''] = 55; - cTable[(byte)''] = cTable[(byte)''] = 67; - cTable[(byte)''] = cTable[(byte)''] = 71; + _cTable[(byte)''] = _cTable[(byte)''] = 55; + _cTable[(byte)''] = _cTable[(byte)''] = 67; + _cTable[(byte)''] = _cTable[(byte)''] = 71; - lTable[(byte)''] = 11; + _lTable[(byte)''] = 11; } } @@ -1433,10 +1433,10 @@ void RMFontCredits::init(void) { #define TOLOWER(a) ((a) >= 'A' && (a) <= 'Z' ? (a) + 'a' - 'A' : (a)) void RMFontObj::setBothCase(int nChar, int nNext, signed char spiazz) { - l2Table[TOUPPER(nChar)][TOUPPER(nNext)] = spiazz; - l2Table[TOUPPER(nChar)][TOLOWER(nNext)] = spiazz; - l2Table[TOLOWER(nChar)][TOUPPER(nNext)] = spiazz; - l2Table[TOLOWER(nChar)][TOLOWER(nNext)] = spiazz; + _l2Table[TOUPPER(nChar)][TOUPPER(nNext)] = spiazz; + _l2Table[TOUPPER(nChar)][TOLOWER(nNext)] = spiazz; + _l2Table[TOLOWER(nChar)][TOUPPER(nNext)] = spiazz; + _l2Table[TOLOWER(nChar)][TOLOWER(nNext)] = spiazz; } @@ -1456,116 +1456,116 @@ void RMFontObj::init(void) { load(RES_F_OBJ, nchars, 25, 30); // Initialise the f**king table - lDefault = 26; - hDefault = 30; - Common::fill(&l2Table[0][0], &l2Table[0][0] + (256 * 256), '\0'); + _lDefault = 26; + _hDefault = 30; + Common::fill(&_l2Table[0][0], &_l2Table[0][0] + (256 * 256), '\0'); for (i = 0; i < 256; i++) { - cTable[i] = -1; - lTable[i] = lDefault; + _cTable[i] = -1; + _lTable[i] = _lDefault; } for (i = 0; i < 26; i++) { - cTable['A' + i] = i + 0; - cTable['a' + i] = i + 0; + _cTable['A' + i] = i + 0; + _cTable['a' + i] = i + 0; } for (i = 0; i < 10; i++) - cTable['0' + i] = i + 26; - - cTable[','] = 36; - cTable[';'] = 37; - cTable['.'] = 38; - cTable[':'] = 39; - cTable['-'] = 40; - cTable['+'] = 41; - cTable['!'] = 42; - // cTable['!'] = 43; Exclamation countdown - cTable['?'] = 44; - //cTable['?'] = 45; Interrogativo alla rovescia - cTable['/'] = 46; - cTable['('] = 47; - cTable[')'] = 48; - cTable['='] = 49; - cTable['\''] = 50; - cTable['\"'] = 51; - cTable[(byte)''] = 52; - cTable[(byte)'$'] = 53; - cTable[(byte)'%'] = 54; - cTable[(byte)'&'] = 55; - cTable[(byte)'^'] = 56; - cTable[(byte)'*'] = 57; - cTable[(byte)'<'] = 58; - cTable[(byte)'>'] = 59; - cTable[(byte)''] = 60; - cTable[(byte)''] = 61; - cTable[(byte)''] = 62; - cTable[(byte)''] = 63; - //cTable[(byte)''] = 64; integral - cTable[(byte)''] = 65; - cTable[(byte)''] = 66; - cTable[(byte)''] = 67; - cTable[(byte)''] = 68; - cTable[(byte)''] = 69; - cTable[(byte)''] = cTable[(byte)''] = 70; - cTable[(byte)''] = 71; - cTable[(byte)''] = 72; - cTable[(byte)''] = 73; - //cTable[(byte)' '] = 74; e circlet - cTable[(byte)''] = 75; - cTable[(byte)''] = 76; - //cTable[(byte)' '] = 77; i circlet - cTable[(byte)''] = 78; - cTable[(byte)''] = cTable[(byte)''] = 79; - //cTable[(byte)' '] = 80; o circlet - cTable[(byte)''] = 81; - cTable[(byte)''] = cTable[(byte)''] = 82; - //cTable[' '] = 83; u circlet - //cTable[' '] = 84; y dieresi + _cTable['0' + i] = i + 26; + + _cTable[','] = 36; + _cTable[';'] = 37; + _cTable['.'] = 38; + _cTable[':'] = 39; + _cTable['-'] = 40; + _cTable['+'] = 41; + _cTable['!'] = 42; + // _cTable['!'] = 43; Exclamation countdown + _cTable['?'] = 44; + // _cTable['?'] = 45; Interrogativo alla rovescia + _cTable['/'] = 46; + _cTable['('] = 47; + _cTable[')'] = 48; + _cTable['='] = 49; + _cTable['\''] = 50; + _cTable['\"'] = 51; + _cTable[(byte)''] = 52; + _cTable[(byte)'$'] = 53; + _cTable[(byte)'%'] = 54; + _cTable[(byte)'&'] = 55; + _cTable[(byte)'^'] = 56; + _cTable[(byte)'*'] = 57; + _cTable[(byte)'<'] = 58; + _cTable[(byte)'>'] = 59; + _cTable[(byte)''] = 60; + _cTable[(byte)''] = 61; + _cTable[(byte)''] = 62; + _cTable[(byte)''] = 63; + //_cTable[(byte)''] = 64; integral + _cTable[(byte)''] = 65; + _cTable[(byte)''] = 66; + _cTable[(byte)''] = 67; + _cTable[(byte)''] = 68; + _cTable[(byte)''] = 69; + _cTable[(byte)''] = _cTable[(byte)''] = 70; + _cTable[(byte)''] = 71; + _cTable[(byte)''] = 72; + _cTable[(byte)''] = 73; + //_cTable[(byte)' '] = 74; e circlet + _cTable[(byte)''] = 75; + _cTable[(byte)''] = 76; + //_cTable[(byte)' '] = 77; i circlet + _cTable[(byte)''] = 78; + _cTable[(byte)''] = _cTable[(byte)''] = 79; + //_cTable[(byte)' '] = 80; o circlet + _cTable[(byte)''] = 81; + _cTable[(byte)''] = _cTable[(byte)''] = 82; + //_cTable[' '] = 83; u circlet + //_cTable[' '] = 84; y dieresi /* Little lengths */ - lTable[' '] = 11; - lTable['.'] = 8; - lTable['-'] = 12; - lTable['\''] = 8; - lTable['0'] = 20; - lTable['1'] = 20; - lTable['2'] = 15; - lTable['3'] = 20; - lTable['4'] = 20; - lTable['5'] = 20; - lTable['6'] = 20; - lTable['7'] = 20; - lTable['8'] = 20; - lTable['9'] = 20; - - - lTable['a'] = lTable['A'] = lTable[''] = lTable[''] = 17; - lTable['b'] = lTable['B'] = 17; - lTable['c'] = lTable['C'] = 19; - lTable['d'] = lTable['D'] = 17; - lTable['e'] = lTable['E'] = 15; - lTable['f'] = lTable['F'] = 17; - lTable['g'] = lTable['G'] = 19; - lTable['i'] = lTable['I'] = 16; - lTable['h'] = lTable['H'] = 17; - lTable['k'] = lTable['K'] = 17; - lTable['l'] = lTable['L'] = 14; - lTable['m'] = lTable['M'] = 19; - lTable['n'] = lTable['N'] = 17; - lTable['o'] = lTable['O'] = lTable[''] = lTable[''] = 19; - lTable['p'] = lTable['P'] = 17; - lTable['q'] = lTable['Q'] = 19; - lTable['r'] = lTable['R'] = 14; - lTable['s'] = lTable['S'] = 13; - lTable['t'] = lTable['T'] = 15; - lTable['u'] = lTable['U'] = lTable[''] = lTable[''] = 15; - lTable['v'] = lTable['V'] = 13; - lTable['x'] = lTable['X'] = 15; - lTable['y'] = lTable['Y'] = 13; - lTable['w'] = lTable['W'] = 19; - lTable['z'] = lTable['Z'] = 20; - lTable[(byte)''] = 17; + _lTable[' '] = 11; + _lTable['.'] = 8; + _lTable['-'] = 12; + _lTable['\''] = 8; + _lTable['0'] = 20; + _lTable['1'] = 20; + _lTable['2'] = 15; + _lTable['3'] = 20; + _lTable['4'] = 20; + _lTable['5'] = 20; + _lTable['6'] = 20; + _lTable['7'] = 20; + _lTable['8'] = 20; + _lTable['9'] = 20; + + + _lTable['a'] = _lTable['A'] = _lTable[''] = _lTable[''] = 17; + _lTable['b'] = _lTable['B'] = 17; + _lTable['c'] = _lTable['C'] = 19; + _lTable['d'] = _lTable['D'] = 17; + _lTable['e'] = _lTable['E'] = 15; + _lTable['f'] = _lTable['F'] = 17; + _lTable['g'] = _lTable['G'] = 19; + _lTable['i'] = _lTable['I'] = 16; + _lTable['h'] = _lTable['H'] = 17; + _lTable['k'] = _lTable['K'] = 17; + _lTable['l'] = _lTable['L'] = 14; + _lTable['m'] = _lTable['M'] = 19; + _lTable['n'] = _lTable['N'] = 17; + _lTable['o'] = _lTable['O'] = _lTable[''] = _lTable[''] = 19; + _lTable['p'] = _lTable['P'] = 17; + _lTable['q'] = _lTable['Q'] = 19; + _lTable['r'] = _lTable['R'] = 14; + _lTable['s'] = _lTable['S'] = 13; + _lTable['t'] = _lTable['T'] = 15; + _lTable['u'] = _lTable['U'] = _lTable[''] = _lTable[''] = 15; + _lTable['v'] = _lTable['V'] = 13; + _lTable['x'] = _lTable['X'] = 15; + _lTable['y'] = _lTable['Y'] = 13; + _lTable['w'] = _lTable['W'] = 19; + _lTable['z'] = _lTable['Z'] = 20; + _lTable[(byte)''] = 17; /* Casi particolari */ setBothCase('C', 'C', 2); @@ -1584,32 +1584,32 @@ void RMFontObj::init(void) { // Polish characters //ス謎戊3剔囀 //AaCcEeLlNnOoSsZzZz - cTable[(byte)''] = cTable[(byte)''] = 85; - lTable[(byte)''] = lTable[(byte)''] = 20; + _cTable[(byte)''] = _cTable[(byte)''] = 85; + _lTable[(byte)''] = _lTable[(byte)''] = 20; - cTable[(byte)''] = cTable[(byte)''] = 86; - lTable[(byte)''] = lTable[(byte)''] = 22; + _cTable[(byte)''] = _cTable[(byte)''] = 86; + _lTable[(byte)''] = _lTable[(byte)''] = 22; - cTable[(byte)''] = cTable[(byte)''] = 87; - lTable[(byte)''] = lTable[(byte)''] = 17; + _cTable[(byte)''] = _cTable[(byte)''] = 87; + _lTable[(byte)''] = _lTable[(byte)''] = 17; - cTable[(byte)''] = cTable[(byte)''] = 88; - lTable[(byte)''] = lTable[(byte)''] = 19; + _cTable[(byte)''] = _cTable[(byte)''] = 88; + _lTable[(byte)''] = _lTable[(byte)''] = 19; - cTable[(byte)''] = cTable[(byte)''] = 89; - lTable[(byte)''] = lTable[(byte)''] = 17; + _cTable[(byte)''] = _cTable[(byte)''] = 89; + _lTable[(byte)''] = _lTable[(byte)''] = 17; - cTable[(byte)''] = cTable[(byte)''] = 90; - lTable[(byte)''] = lTable[(byte)''] = 22; + _cTable[(byte)''] = _cTable[(byte)''] = 90; + _lTable[(byte)''] = _lTable[(byte)''] = 22; - cTable[(byte)''] = cTable[(byte)''] = 91; - lTable[(byte)''] = lTable[(byte)''] = 15; + _cTable[(byte)''] = _cTable[(byte)''] = 91; + _lTable[(byte)''] = _lTable[(byte)''] = 15; - cTable[(byte)''] = cTable[(byte)''] = 92; - lTable[(byte)''] = lTable[(byte)''] = 21; + _cTable[(byte)''] = _cTable[(byte)''] = 92; + _lTable[(byte)''] = _lTable[(byte)''] = 21; - cTable[(byte)''] = cTable[(byte)''] = 93; - lTable[(byte)''] = lTable[(byte)''] = 21; + _cTable[(byte)''] = _cTable[(byte)''] = 93; + _lTable[(byte)''] = _lTable[(byte)''] = 21; } else if (_vm->getLanguage() == Common::RU_RUS) { // Russian Characters @@ -1617,140 +1617,140 @@ void RMFontObj::init(void) { // allowing for further translations. To support Tonyin other langauges, // these mappings could be used as a basis - cTable[(byte)''] = cTable[(byte)''] = 85; - lTable[(byte)''] = lTable[(byte)''] = 20; - - cTable[(byte)''] = cTable[(byte)''] = 94; - cTable[(byte)''] = cTable[(byte)''] = 95; - cTable[(byte)''] = cTable[(byte)''] = 96; - cTable[(byte)''] = cTable[(byte)''] = 97; - cTable[(byte)''] = cTable[(byte)''] = 98; - cTable[(byte)''] = cTable[(byte)''] = 99; - cTable[(byte)''] = cTable[(byte)''] = 100; - cTable[(byte)''] = cTable[(byte)''] = 101; - cTable[(byte)''] = cTable[(byte)''] = 102; - cTable[(byte)''] = cTable[(byte)''] = 103; - cTable[(byte)''] = cTable[(byte)''] = 104; - cTable[(byte)''] = cTable[(byte)''] = 105; - cTable[(byte)''] = cTable[(byte)''] = 106; - cTable[(byte)''] = cTable[(byte)''] = 107; - cTable[(byte)''] = cTable[(byte)''] = 108; - cTable[(byte)''] = cTable[(byte)''] = 109; - cTable[(byte)''] = cTable[(byte)''] = 110; - cTable[(byte)''] = cTable[(byte)''] = 111; - cTable[(byte)''] = cTable[(byte)''] = 112; - cTable[(byte)''] = cTable[(byte)''] = 113; - cTable[(byte)''] = cTable[(byte)''] = 114; - cTable[(byte)''] = cTable[(byte)''] = 115; - cTable[(byte)''] = cTable[(byte)''] = 116; - cTable[(byte)''] = cTable[(byte)''] = 117; - cTable[(byte)''] = cTable[(byte)''] = 118; - cTable[(byte)''] = cTable[(byte)''] = 119; - cTable[(byte)''] = cTable[(byte)''] = 120; - cTable[(byte)''] = cTable[(byte)''] = 121; - cTable[(byte)''] = cTable[(byte)''] = 122; - cTable[(byte)''] = cTable[(byte)''] = 123; - cTable[(byte)''] = cTable[(byte)''] = 124; - cTable[(byte)''] = cTable[(byte)''] = 125; - cTable[(byte)''] = cTable[(byte)''] = 126; - - - lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 17; - lTable[(byte)''] = lTable[(byte)''] = 16; - lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 20; - lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 16; - lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 15; - lTable[(byte)''] = lTable[(byte)''] = 22; - lTable[(byte)''] = lTable[(byte)''] = 15; - lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 22; - lTable[(byte)''] = lTable[(byte)''] = 19; - lTable[(byte)''] = lTable[(byte)''] = 16; - lTable[(byte)''] = lTable[(byte)''] = 21; - lTable[(byte)''] = lTable[(byte)''] = 20; - lTable[(byte)''] = lTable[(byte)''] = 16; - lTable[(byte)''] = lTable[(byte)''] = 16; - lTable[(byte)''] = lTable[(byte)''] = 19; - lTable[(byte)''] = lTable[(byte)''] = 22; - lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 19; - lTable[(byte)''] = lTable[(byte)''] = 19; - lTable[(byte)''] = lTable[(byte)''] = 15; - lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 18; + _cTable[(byte)''] = _cTable[(byte)''] = 85; + _lTable[(byte)''] = _lTable[(byte)''] = 20; + + _cTable[(byte)''] = _cTable[(byte)''] = 94; + _cTable[(byte)''] = _cTable[(byte)''] = 95; + _cTable[(byte)''] = _cTable[(byte)''] = 96; + _cTable[(byte)''] = _cTable[(byte)''] = 97; + _cTable[(byte)''] = _cTable[(byte)''] = 98; + _cTable[(byte)''] = _cTable[(byte)''] = 99; + _cTable[(byte)''] = _cTable[(byte)''] = 100; + _cTable[(byte)''] = _cTable[(byte)''] = 101; + _cTable[(byte)''] = _cTable[(byte)''] = 102; + _cTable[(byte)''] = _cTable[(byte)''] = 103; + _cTable[(byte)''] = _cTable[(byte)''] = 104; + _cTable[(byte)''] = _cTable[(byte)''] = 105; + _cTable[(byte)''] = _cTable[(byte)''] = 106; + _cTable[(byte)''] = _cTable[(byte)''] = 107; + _cTable[(byte)''] = _cTable[(byte)''] = 108; + _cTable[(byte)''] = _cTable[(byte)''] = 109; + _cTable[(byte)''] = _cTable[(byte)''] = 110; + _cTable[(byte)''] = _cTable[(byte)''] = 111; + _cTable[(byte)''] = _cTable[(byte)''] = 112; + _cTable[(byte)''] = _cTable[(byte)''] = 113; + _cTable[(byte)''] = _cTable[(byte)''] = 114; + _cTable[(byte)''] = _cTable[(byte)''] = 115; + _cTable[(byte)''] = _cTable[(byte)''] = 116; + _cTable[(byte)''] = _cTable[(byte)''] = 117; + _cTable[(byte)''] = _cTable[(byte)''] = 118; + _cTable[(byte)''] = _cTable[(byte)''] = 119; + _cTable[(byte)''] = _cTable[(byte)''] = 120; + _cTable[(byte)''] = _cTable[(byte)''] = 121; + _cTable[(byte)''] = _cTable[(byte)''] = 122; + _cTable[(byte)''] = _cTable[(byte)''] = 123; + _cTable[(byte)''] = _cTable[(byte)''] = 124; + _cTable[(byte)''] = _cTable[(byte)''] = 125; + _cTable[(byte)''] = _cTable[(byte)''] = 126; + + + _lTable[(byte)''] = _lTable[(byte)''] = 18; + _lTable[(byte)''] = _lTable[(byte)''] = 18; + _lTable[(byte)''] = _lTable[(byte)''] = 18; + _lTable[(byte)''] = _lTable[(byte)''] = 17; + _lTable[(byte)''] = _lTable[(byte)''] = 16; + _lTable[(byte)''] = _lTable[(byte)''] = 18; + _lTable[(byte)''] = _lTable[(byte)''] = 18; + _lTable[(byte)''] = _lTable[(byte)''] = 20; + _lTable[(byte)''] = _lTable[(byte)''] = 18; + _lTable[(byte)''] = _lTable[(byte)''] = 18; + _lTable[(byte)''] = _lTable[(byte)''] = 18; + _lTable[(byte)''] = _lTable[(byte)''] = 18; + _lTable[(byte)''] = _lTable[(byte)''] = 16; + _lTable[(byte)''] = _lTable[(byte)''] = 18; + _lTable[(byte)''] = _lTable[(byte)''] = 15; + _lTable[(byte)''] = _lTable[(byte)''] = 22; + _lTable[(byte)''] = _lTable[(byte)''] = 15; + _lTable[(byte)''] = _lTable[(byte)''] = 18; + _lTable[(byte)''] = _lTable[(byte)''] = 22; + _lTable[(byte)''] = _lTable[(byte)''] = 19; + _lTable[(byte)''] = _lTable[(byte)''] = 16; + _lTable[(byte)''] = _lTable[(byte)''] = 21; + _lTable[(byte)''] = _lTable[(byte)''] = 20; + _lTable[(byte)''] = _lTable[(byte)''] = 16; + _lTable[(byte)''] = _lTable[(byte)''] = 16; + _lTable[(byte)''] = _lTable[(byte)''] = 19; + _lTable[(byte)''] = _lTable[(byte)''] = 22; + _lTable[(byte)''] = _lTable[(byte)''] = 18; + _lTable[(byte)''] = _lTable[(byte)''] = 19; + _lTable[(byte)''] = _lTable[(byte)''] = 19; + _lTable[(byte)''] = _lTable[(byte)''] = 15; + _lTable[(byte)''] = _lTable[(byte)''] = 18; + _lTable[(byte)''] = _lTable[(byte)''] = 18; } else if (_vm->getLanguage() == Common::CZ_CZE) { // Czech - cTable[(byte)''] = cTable[(byte)''] = 127; - cTable[(byte)''] = cTable[(byte)''] = 128; - cTable[(byte)''] = cTable[(byte)''] = 129; - cTable[(byte)''] = cTable[(byte)''] = 130; - cTable[(byte)''] = cTable[(byte)''] = 131; - cTable[(byte)''] = cTable[(byte)''] = 132; - cTable[(byte)''] = cTable[(byte)''] = 133; - cTable[(byte)''] = cTable[(byte)''] = 134; - cTable[(byte)''] = cTable[(byte)''] = 135; - cTable[(byte)''] = cTable[(byte)''] = 136; - cTable[(byte)''] = cTable[(byte)''] = 137; - cTable[(byte)''] = cTable[(byte)''] = 138; - cTable[(byte)''] = cTable[(byte)''] = 139; - cTable[(byte)''] = cTable[(byte)''] = 140; - cTable[(byte)''] = cTable[(byte)''] = 141; - - lTable[(byte)''] = lTable[(byte)''] = 17; - lTable[(byte)''] = lTable[(byte)''] = 15; - lTable[(byte)''] = lTable[(byte)''] = 22; - lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 21; - lTable[(byte)''] = lTable[(byte)''] = 16; - lTable[(byte)''] = lTable[(byte)''] = 18; - lTable[(byte)''] = lTable[(byte)''] = 19; - lTable[(byte)''] = lTable[(byte)''] = 17; - lTable[(byte)''] = lTable[(byte)''] = 23; - lTable[(byte)''] = lTable[(byte)''] = 24; - lTable[(byte)''] = lTable[(byte)''] = 17; - lTable[(byte)''] = lTable[(byte)''] = 22; - lTable[(byte)''] = lTable[(byte)''] = 16; - lTable[(byte)''] = lTable[(byte)''] = 16; + _cTable[(byte)''] = _cTable[(byte)''] = 127; + _cTable[(byte)''] = _cTable[(byte)''] = 128; + _cTable[(byte)''] = _cTable[(byte)''] = 129; + _cTable[(byte)''] = _cTable[(byte)''] = 130; + _cTable[(byte)''] = _cTable[(byte)''] = 131; + _cTable[(byte)''] = _cTable[(byte)''] = 132; + _cTable[(byte)''] = _cTable[(byte)''] = 133; + _cTable[(byte)''] = _cTable[(byte)''] = 134; + _cTable[(byte)''] = _cTable[(byte)''] = 135; + _cTable[(byte)''] = _cTable[(byte)''] = 136; + _cTable[(byte)''] = _cTable[(byte)''] = 137; + _cTable[(byte)''] = _cTable[(byte)''] = 138; + _cTable[(byte)''] = _cTable[(byte)''] = 139; + _cTable[(byte)''] = _cTable[(byte)''] = 140; + _cTable[(byte)''] = _cTable[(byte)''] = 141; + + _lTable[(byte)''] = _lTable[(byte)''] = 17; + _lTable[(byte)''] = _lTable[(byte)''] = 15; + _lTable[(byte)''] = _lTable[(byte)''] = 22; + _lTable[(byte)''] = _lTable[(byte)''] = 18; + _lTable[(byte)''] = _lTable[(byte)''] = 21; + _lTable[(byte)''] = _lTable[(byte)''] = 16; + _lTable[(byte)''] = _lTable[(byte)''] = 18; + _lTable[(byte)''] = _lTable[(byte)''] = 19; + _lTable[(byte)''] = _lTable[(byte)''] = 17; + _lTable[(byte)''] = _lTable[(byte)''] = 23; + _lTable[(byte)''] = _lTable[(byte)''] = 24; + _lTable[(byte)''] = _lTable[(byte)''] = 17; + _lTable[(byte)''] = _lTable[(byte)''] = 22; + _lTable[(byte)''] = _lTable[(byte)''] = 16; + _lTable[(byte)''] = _lTable[(byte)''] = 16; } else if (_vm->getLanguage() == Common::FR_FRA) { // French // Translate accented characters as normal letters - cTable[(byte)''] = cTable[(byte)''] = cTable[(byte)''] = 0; // a - lTable[(byte)''] = lTable[(byte)''] = lTable[(byte)''] = 17; + _cTable[(byte)''] = _cTable[(byte)''] = _cTable[(byte)''] = 0; // a + _lTable[(byte)''] = _lTable[(byte)''] = _lTable[(byte)''] = 17; - cTable[(byte)''] = cTable[(byte)''] = 4; // e - lTable[(byte)''] = lTable[(byte)''] = 15; + _cTable[(byte)''] = _cTable[(byte)''] = 4; // e + _lTable[(byte)''] = _lTable[(byte)''] = 15; - cTable[(byte)''] = cTable[(byte)''] = cTable[(byte)''] = 8; // i - lTable[(byte)''] = lTable[(byte)''] = lTable[(byte)''] = 16; + _cTable[(byte)''] = _cTable[(byte)''] = _cTable[(byte)''] = 8; // i + _lTable[(byte)''] = _lTable[(byte)''] = _lTable[(byte)''] = 16; - cTable[(byte)''] = cTable[(byte)''] = cTable[(byte)''] = cTable[(byte)''] = 14; // o - lTable[(byte)''] = lTable[(byte)''] = lTable[(byte)''] = lTable[(byte)''] = 19; + _cTable[(byte)''] = _cTable[(byte)''] = _cTable[(byte)''] = _cTable[(byte)''] = 14; // o + _lTable[(byte)''] = _lTable[(byte)''] = _lTable[(byte)''] = _lTable[(byte)''] = 19; - cTable[(byte)''] = cTable[(byte)''] = 20; // u - lTable[(byte)''] = lTable[(byte)''] = 15; + _cTable[(byte)''] = _cTable[(byte)''] = 20; // u + _lTable[(byte)''] = _lTable[(byte)''] = 15; } else if (_vm->getLanguage() == Common::DE_DEU) { // German - cTable[''] = 142; + _cTable[''] = 142; // SS = 143 - lTable[''] = 24; + _lTable[''] = 24; } } @@ -1768,14 +1768,14 @@ void RMText::initStatics() { RMText::RMText() { // Default colour: white - m_r = m_g = m_b = 255; + _textR = _textG = _textB = 255; // Default length - maxLineLength = 350; + _maxLineLength = 350; _bTrasp0 = true; - aHorType = HCENTER; - aVerType = VTOP; + _aHorType = HCENTER; + _aVerType = VTOP; setPriority(150); } @@ -1794,7 +1794,7 @@ void RMText::unload() { } void RMText::setMaxLineLength(int max) { - maxLineLength = max; + _maxLineLength = max; } void RMText::removeThis(CORO_PARAM, bool &result) { @@ -1831,7 +1831,7 @@ void RMText::writeText(const RMString &text, RMFontColor *font, int *time) { int numlines; // Set the base colour - font->setBaseColor(m_r, m_g, m_b); + font->setBaseColor(_textR, _textG, _textB); // Destroy the buffer before starting destroy(); @@ -1846,7 +1846,7 @@ void RMText::writeText(const RMString &text, RMFontColor *font, int *time) { i = j = x = 0; while (*p != '\0') { j += font->stringLen(*p); - if (j > (((aHorType == HLEFTPAR) && (i > 0)) ? maxLineLength - 25 : maxLineLength)) { + if (j > (((_aHorType == HLEFTPAR) && (i > 0)) ? _maxLineLength - 25 : _maxLineLength)) { j -= font->stringLen(*p, p[1]); if (j > x) x = j; @@ -1903,7 +1903,7 @@ void RMText::writeText(const RMString &text, RMFontColor *font, int *time) { x = 0; j = font->stringLen(RMString(p)); - switch (aHorType) { + switch (_aHorType) { case HLEFT: x = 0; break; @@ -1967,19 +1967,19 @@ void RMText::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CODE(_ctx); // Horizontally - if (aHorType == HCENTER) + if (_aHorType == HCENTER) prim->getDst().topLeft() -= RMPoint(_dimx / 2, 0); - else if (aHorType == HRIGHT) + else if (_aHorType == HRIGHT) prim->getDst().topLeft() -= RMPoint(_dimx, 0); // Vertically - if (aVerType == VTOP) { + if (_aVerType == VTOP) { - } else if (aVerType == VCENTER) { + } else if (_aVerType == VCENTER) { prim->getDst().y1 -= _dimy / 2; - } else if (aVerType == VBOTTOM) { + } else if (_aVerType == VBOTTOM) { prim->getDst().y1 -= _dimy; } @@ -1996,7 +1996,7 @@ void RMText::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { RMTextDialog::RMTextDialog() : RMText() { _startTime = 0; - dst = RMPoint(0, 0); + _dst = RMPoint(0, 0); _bSkipStatus = true; _bShowed = true; @@ -2004,16 +2004,16 @@ RMTextDialog::RMTextDialog() : RMText() { _bForceNoTime = false; _bAlwaysDisplay = false; _bNoTab = false; - hCustomSkip = CORO_INVALID_PID_VALUE; - hCustomSkip2 = CORO_INVALID_PID_VALUE; + _hCustomSkip = CORO_INVALID_PID_VALUE; + _hCustomSkip2 = CORO_INVALID_PID_VALUE; _input = NULL; // Create the event for displaying the end - hEndDisplay = CoroScheduler.createEvent(false, false); + _hEndDisplay = CoroScheduler.createEvent(false, false); } RMTextDialog::~RMTextDialog() { - CoroScheduler.closeEvent(hEndDisplay); + CoroScheduler.closeEvent(_hEndDisplay); } void RMTextDialog::show(void) { @@ -2075,7 +2075,7 @@ void RMTextDialog::removeThis(CORO_PARAM, bool &result) { // Don't erase the background if (_bSkipStatus) { - if (!(GLOBALS._bCfgDubbing && hCustomSkip2 != CORO_INVALID_PID_VALUE)) { + if (!(GLOBALS._bCfgDubbing && _hCustomSkip2 != CORO_INVALID_PID_VALUE)) { if (GLOBALS._bCfgTimerizedText) { if (!_bForceNoTime) { if (_vm->getTime() > (uint32)_time + _startTime) @@ -2097,7 +2097,7 @@ void RMTextDialog::removeThis(CORO_PARAM, bool &result) { } } // Erase the background - else if (!(GLOBALS._bCfgDubbing && hCustomSkip2 != CORO_INVALID_PID_VALUE)) { + else if (!(GLOBALS._bCfgDubbing && _hCustomSkip2 != CORO_INVALID_PID_VALUE)) { if (!_bForceNoTime) { if (_vm->getTime() > (uint32)_time + _startTime) return; @@ -2110,15 +2110,15 @@ void RMTextDialog::removeThis(CORO_PARAM, bool &result) { return; } - if (hCustomSkip != CORO_INVALID_PID_VALUE) { - CORO_INVOKE_3(CoroScheduler.waitForSingleObject, hCustomSkip, 0, &_ctx->expired); + if (_hCustomSkip != CORO_INVALID_PID_VALUE) { + CORO_INVOKE_3(CoroScheduler.waitForSingleObject, _hCustomSkip, 0, &_ctx->expired); // == WAIT_OBJECT_0 if (!_ctx->expired) return; } - if (GLOBALS._bCfgDubbing && hCustomSkip2 != CORO_INVALID_PID_VALUE) { - CORO_INVOKE_3(CoroScheduler.waitForSingleObject, hCustomSkip2, 0, &_ctx->expired); + if (GLOBALS._bCfgDubbing && _hCustomSkip2 != CORO_INVALID_PID_VALUE) { + CORO_INVOKE_3(CoroScheduler.waitForSingleObject, _hCustomSkip2, 0, &_ctx->expired); // == WAIT_OBJECT_0 if (!_ctx->expired) return; @@ -2132,7 +2132,7 @@ void RMTextDialog::removeThis(CORO_PARAM, bool &result) { void RMTextDialog::Unregister(void) { RMGfxTask::Unregister(); assert(_nInList == 0); - CoroScheduler.setEvent(hEndDisplay); + CoroScheduler.setEvent(_hEndDisplay); } void RMTextDialog::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { @@ -2146,7 +2146,7 @@ void RMTextDialog::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *p if (_bShowed) { if (GLOBALS._bCfgSottotitoli || _bAlwaysDisplay) { - prim->getDst().topLeft() = dst; + prim->getDst().topLeft() = _dst; CORO_INVOKE_2(RMText::draw, bigBuf, prim); } } @@ -2155,15 +2155,15 @@ void RMTextDialog::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *p } void RMTextDialog::setCustomSkipHandle(uint32 hCustom) { - hCustomSkip = hCustom; + _hCustomSkip = hCustom; } void RMTextDialog::setCustomSkipHandle2(uint32 hCustom) { - hCustomSkip2 = hCustom; + _hCustomSkip2 = hCustom; } void RMTextDialog::waitForEndDisplay(CORO_PARAM) { - CoroScheduler.waitForSingleObject(coroParam, hEndDisplay, CORO_INFINITE); + CoroScheduler.waitForSingleObject(coroParam, _hEndDisplay, CORO_INFINITE); } void RMTextDialog::setInput(RMInput *input) { @@ -2175,12 +2175,12 @@ void RMTextDialog::setInput(RMInput *input) { \****************************************************************************/ RMTextDialogScrolling::RMTextDialogScrolling() { - curLoc = NULL; + _curLoc = NULL; } RMTextDialogScrolling::RMTextDialogScrolling(RMLocation *loc) { - curLoc = loc; - startScroll = loc->scrollPosition(); + _curLoc = loc; + _startScroll = loc->scrollPosition(); } RMTextDialogScrolling::~RMTextDialogScrolling() { @@ -2193,14 +2193,14 @@ void RMTextDialogScrolling::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPri CORO_BEGIN_CODE(_ctx); - _ctx->curDst = dst; + _ctx->curDst = _dst; - if (curLoc != NULL) - dst -= curLoc->scrollPosition() - startScroll; + if (_curLoc != NULL) + _dst -= _curLoc->scrollPosition() - _startScroll; CORO_INVOKE_2(RMTextDialog::draw, bigBuf, prim); - dst = _ctx->curDst; + _dst = _ctx->curDst; CORO_END_CODE; } @@ -2321,26 +2321,26 @@ RMDialogChoice::RMDialogChoice() { RMResRaw dlg2(RES_I_DLGTEXTLINE); RMRes dlgpal(RES_I_DLGTEXTPAL); - DlgText.init(dlg1, dlg1.width(), dlg1.height()); - DlgTextLine.init(dlg2, dlg2.width(), dlg2.height()); + _dlgText.init(dlg1, dlg1.width(), dlg1.height()); + _dlgTextLine.init(dlg2, dlg2.width(), dlg2.height()); - DlgText.loadPaletteWA(dlgpal); - DlgTextLine.loadPaletteWA(dlgpal); + _dlgText.loadPaletteWA(dlgpal); + _dlgTextLine.loadPaletteWA(dlgpal); - hUnreg = CoroScheduler.createEvent(false, false); - bRemoveFromOT = false; + _hUnreg = CoroScheduler.createEvent(false, false); + _bRemoveFromOT = false; } RMDialogChoice::~RMDialogChoice() { - CoroScheduler.closeEvent(hUnreg); + CoroScheduler.closeEvent(_hUnreg); } void RMDialogChoice::Unregister(void) { RMGfxWoodyBuffer::Unregister(); assert(!_nInList); - CoroScheduler.pulseEvent(hUnreg); + CoroScheduler.pulseEvent(_hUnreg); - bRemoveFromOT = false; + _bRemoveFromOT = false; } void RMDialogChoice::init(void) { @@ -2401,11 +2401,11 @@ void RMDialogChoice::prepare(CORO_PARAM) { CORO_BEGIN_CODE(_ctx); - addPrim(new RMGfxPrimitive(&DlgText, RMPoint(0, 0))); - addPrim(new RMGfxPrimitive(&DlgTextLine, RMPoint(0, 155))); - addPrim(new RMGfxPrimitive(&DlgTextLine, RMPoint(0, 155 + 83))); - addPrim(new RMGfxPrimitive(&DlgTextLine, RMPoint(0, 155 + 83 + 83))); - addPrim(new RMGfxPrimitive(&DlgTextLine, RMPoint(0, 155 + 83 + 83 + 83))); + addPrim(new RMGfxPrimitive(&_dlgText, RMPoint(0, 0))); + addPrim(new RMGfxPrimitive(&_dlgTextLine, RMPoint(0, 155))); + addPrim(new RMGfxPrimitive(&_dlgTextLine, RMPoint(0, 155 + 83))); + addPrim(new RMGfxPrimitive(&_dlgTextLine, RMPoint(0, 155 + 83 + 83))); + addPrim(new RMGfxPrimitive(&_dlgTextLine, RMPoint(0, 155 + 83 + 83 + 83))); _ctx->ptPos.set(20, 90); @@ -2546,15 +2546,15 @@ void RMDialogChoice::hide(CORO_PARAM) { } _bShow = false; - bRemoveFromOT = true; - CORO_INVOKE_2(CoroScheduler.waitForSingleObject, hUnreg, CORO_INFINITE); + _bRemoveFromOT = true; + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _hUnreg, CORO_INFINITE); CORO_END_CODE; } void RMDialogChoice::removeThis(CORO_PARAM, bool &result) { - result = bRemoveFromOT; + result = _bRemoveFromOT; } void RMDialogChoice::doFrame(CORO_PARAM, RMPoint ptMousePos) { diff --git a/engines/tony/font.h b/engines/tony/font.h index 2e2b1724a9..d1423c9749 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -47,7 +47,7 @@ class RMPointer; */ class RMFont : public RMGfxTaskSetPrior { protected: - int nLetters; + int _nLetters; RMGfxSourceBuffer8RLEByte *_letter; public: int _fontDimx, _fontDimy; @@ -107,7 +107,7 @@ public: class RMFontColor : public virtual RMFont { private: - byte m_r, m_g, m_b; + byte _fontR, _fontG, _fontB; public: RMFontColor(); @@ -118,24 +118,24 @@ public: class RMFontWithTables : public virtual RMFont { protected: - int cTable[256]; - int lTable[256]; - int lDefault; - int hDefault; - signed char l2Table[256][256]; + int _cTable[256]; + int _lTable[256]; + int _lDefault; + int _hDefault; + signed char _l2Table[256][256]; protected: // Overloaded methods int convertToLetter(byte nChar) { - return cTable[nChar]; + return _cTable[nChar]; } int letterLength(int nChar, int nNext = 0) { - return (nChar != -1 ? lTable[(byte)nChar] + l2Table[(byte)nChar][(byte)nNext] : lDefault); + return (nChar != -1 ? _lTable[(byte)nChar] + _l2Table[(byte)nChar][(byte)nNext] : _lDefault); } public: int letterHeight() { - return hDefault; + return _hDefault; } virtual ~RMFontWithTables() {} }; @@ -176,7 +176,7 @@ class RMText : public RMGfxWoodyBuffer { private: static RMFontColor *_fonts[4]; static RMGfxClearTask _clear; - int maxLineLength; + int _maxLineLength; public: enum HORALIGN { @@ -193,9 +193,9 @@ public: }; private: - HORALIGN aHorType; - VERALIGN aVerType; - byte m_r, m_g, m_b; + HORALIGN _aHorType; + VERALIGN _aVerType; + byte _textR, _textG, _textB; protected: virtual void clipOnScreen(RMGfxPrimitive *prim); @@ -208,8 +208,8 @@ public: // Set the alignment type void setAlignType(HORALIGN aHor, VERALIGN aVer) { - aHorType = aHor; - aVerType = aVer; + _aHorType = aHor; + _aVerType = aVer; } // Sets the maximum length of a line in pixels (used to format the text) @@ -227,9 +227,9 @@ public: // Set the base colour void setColor(byte r, byte g, byte b) { - m_r = r; - m_g = g; - m_b = b; + _textR = r; + _textG = g; + _textB = b; } }; @@ -241,13 +241,13 @@ protected: int _startTime; int _time; bool _bSkipStatus; - RMPoint dst; - uint32 hEndDisplay; + RMPoint _dst; + uint32 _hEndDisplay; bool _bShowed; bool _bForceTime; bool _bForceNoTime; - uint32 hCustomSkip; - uint32 hCustomSkip2; + uint32 _hCustomSkip; + uint32 _hCustomSkip2; RMInput *_input; bool _bAlwaysDisplay; bool _bNoTab; @@ -271,7 +271,7 @@ public: // Set the position void setPosition(const RMPoint &pt) { - dst = pt; + _dst = pt; } // Waiting @@ -294,8 +294,8 @@ public: class RMTextDialogScrolling : public RMTextDialog { protected: - RMLocation *curLoc; - RMPoint startScroll; + RMLocation *_curLoc; + RMPoint _startScroll; virtual void clipOnScreen(RMGfxPrimitive *prim); @@ -351,11 +351,11 @@ private: RMPoint *_ptDrawStrings; int _curAdded; bool _bShow; - RMGfxSourceBuffer8 DlgText; - RMGfxSourceBuffer8 DlgTextLine; + RMGfxSourceBuffer8 _dlgText; + RMGfxSourceBuffer8 _dlgTextLine; RMPoint _ptDrawPos; - uint32 hUnreg; - bool bRemoveFromOT; + uint32 _hUnreg; + bool _bRemoveFromOT; protected: void prepare(CORO_PARAM); -- cgit v1.2.3 From 264721a19405920a57fece9b5bd09d773055531c Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 11 Jun 2012 00:43:59 +0200 Subject: TONY: Rename variables in inventory.h --- engines/tony/inventory.cpp | 134 ++++++++++++++++++++++----------------------- engines/tony/inventory.h | 10 ++-- 2 files changed, 72 insertions(+), 72 deletions(-) (limited to 'engines') diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index 162443d0bd..cfa49181e1 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -56,7 +56,7 @@ RMInventory::RMInventory() { _nCombine = 0; _bBlinkingRight = false; _bBlinkingLeft = false; - miniAction = 0; + _miniAction = 0; } RMInventory::~RMInventory() { @@ -100,43 +100,43 @@ void RMInventory::init(void) { assert(res.isValid()); // Initialise the MPAL inventory item by reading it in. - _items[i].icon.setInitCurPattern(false); + _items[i]._icon.setInitCurPattern(false); ds.openBuffer(res); - ds >> _items[i].icon; + ds >> _items[i]._icon; ds.close(); // Puts in the default pattern 1 - _items[i].pointer = NULL; - _items[i].status = 1; - _items[i].icon.setPattern(1); - _items[i].icon.doFrame(this, false); + _items[i]._pointer = NULL; + _items[i]._status = 1; + _items[i]._icon.setPattern(1); + _items[i]._icon.doFrame(this, false); curres++; if (i == 0 || i == 28 || i == 29) continue; - _items[i].pointer = new RMGfxSourceBuffer8RLEByteAA[_items[i].icon.numPattern()]; + _items[i]._pointer = new RMGfxSourceBuffer8RLEByteAA[_items[i]._icon.numPattern()]; - for (j = 0; j < _items[i].icon.numPattern(); j++) { + for (j = 0; j < _items[i]._icon.numPattern(); j++) { RMResRaw raw(curres); assert(raw.isValid()); - _items[i].pointer[j].init((const byte *)raw, raw.width(), raw.height(), true); + _items[i]._pointer[j].init((const byte *)raw, raw.width(), raw.height(), true); curres++; } } - _items[28].icon.setPattern(1); - _items[29].icon.setPattern(1); + _items[28]._icon.setPattern(1); + _items[29]._icon.setPattern(1); // Download interface RMDataStream ds; RMRes res(RES_I_MINIINTER); assert(res.isValid()); ds.openBuffer(res); - ds >> miniInterface; - miniInterface.setPattern(1); + ds >> _miniInterface; + _miniInterface.setPattern(1); ds.close(); // Create the text for hints on the mini interface @@ -165,7 +165,7 @@ void RMInventory::close(void) { if (_items != NULL) { // Delete the item pointers for (int i = 0; i <= _nItems; i++) - delete[] _items[i].pointer; + delete[] _items[i]._pointer; // Delete the items array delete[] _items; @@ -213,14 +213,14 @@ void RMInventory::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr _ctx->p2 = new RMGfxPrimitive(prim->_task, _ctx->pos2); // Draw the mini interface - CORO_INVOKE_2(miniInterface.draw, bigBuf, _ctx->p); + CORO_INVOKE_2(_miniInterface.draw, bigBuf, _ctx->p); if (GLOBALS._bCfgInterTips) { - if (miniAction == 1) // Examine + if (_miniAction == 1) // Examine CORO_INVOKE_2(_hints[0].draw, bigBuf, _ctx->p2); - else if (miniAction == 2) // Talk + else if (_miniAction == 2) // Talk CORO_INVOKE_2(_hints[1].draw, bigBuf, _ctx->p2); - else if (miniAction == 3) // Use + else if (_miniAction == 3) // Use CORO_INVOKE_2(_hints[2].draw, bigBuf, _ctx->p2); } @@ -264,7 +264,7 @@ void RMInventory::addItem(int code) { g_system->lockMutex(_csModifyInterface); if (_curPos + 8 == _nInv) { // Break through the inventory! On the flashing pattern - _items[28].icon.setPattern(2); + _items[28]._icon.setPattern(2); } _inv[_nInv++] = code - 10000; @@ -281,8 +281,8 @@ void RMInventory::changeItemStatus(uint32 code, uint32 dwStatus) { error("Specified object code is not valid"); } else { g_system->lockMutex(_csModifyInterface); - _items[code - 10000].icon.setPattern(dwStatus); - _items[code - 10000].status = dwStatus; + _items[code - 10000]._icon.setPattern(dwStatus); + _items[code - 10000]._status = dwStatus; prepare(); drawOT(Common::nullContext); @@ -297,14 +297,14 @@ void RMInventory::prepare(void) { for (i = 1; i < RM_SX / 64 - 1; i++) { if (i - 1 + _curPos < _nInv) - addPrim(new RMGfxPrimitive(&_items[_inv[i - 1 + _curPos]].icon, RMPoint(i * 64, 0))); + addPrim(new RMGfxPrimitive(&_items[_inv[i - 1 + _curPos]]._icon, RMPoint(i * 64, 0))); else - addPrim(new RMGfxPrimitive(&_items[0].icon, RMPoint(i * 64, 0))); + addPrim(new RMGfxPrimitive(&_items[0]._icon, RMPoint(i * 64, 0))); } // Frecce - addPrim(new RMGfxPrimitive(&_items[29].icon, RMPoint(0, 0))); - addPrim(new RMGfxPrimitive(&_items[28].icon, RMPoint(640 - 64, 0))); + addPrim(new RMGfxPrimitive(&_items[29]._icon, RMPoint(0, 0))); + addPrim(new RMGfxPrimitive(&_items[28]._icon, RMPoint(640 - 64, 0))); } bool RMInventory::miniActive(void) { @@ -355,12 +355,12 @@ bool RMInventory::leftClick(const RMPoint &mpos, int &nCombineObj) { if (_curPos + 8 >= _nInv) { _bBlinkingRight = false; - _items[28].icon.setPattern(1); + _items[28]._icon.setPattern(1); } if (_curPos > 0) { _bBlinkingLeft = true; - _items[29].icon.setPattern(2); + _items[29]._icon.setPattern(2); } prepare(); @@ -376,12 +376,12 @@ bool RMInventory::leftClick(const RMPoint &mpos, int &nCombineObj) { if (_curPos == 0) { _bBlinkingLeft = false; - _items[29].icon.setPattern(1); + _items[29]._icon.setPattern(1); } if (_curPos + 8 < _nInv) { _bBlinkingRight = true; - _items[28].icon.setPattern(2); + _items[28]._icon.setPattern(2); } prepare(); @@ -405,7 +405,7 @@ void RMInventory::rightClick(const RMPoint &mpos) { if (n > 0 && n < RM_SX / 64 - 1 && _inv[n - 1 + _curPos] != 0) { _state = SELECTING; - miniAction = 0; + _miniAction = 0; _nSelectObj = n - 1; _vm->playUtilSFX(0); @@ -420,12 +420,12 @@ void RMInventory::rightClick(const RMPoint &mpos) { if (_curPos + 8 <= _nInv) { _bBlinkingRight = false; - _items[28].icon.setPattern(1); + _items[28]._icon.setPattern(1); } if (_curPos > 0) { _bBlinkingLeft = true; - _items[29].icon.setPattern(2); + _items[29]._icon.setPattern(2); } prepare(); @@ -441,12 +441,12 @@ void RMInventory::rightClick(const RMPoint &mpos) { if (_curPos == 0) { _bBlinkingLeft = false; - _items[29].icon.setPattern(1); + _items[29]._icon.setPattern(1); } if (_curPos + 8 < _nInv) { _bBlinkingRight = true; - _items[28].icon.setPattern(2); + _items[28]._icon.setPattern(2); } prepare(); @@ -460,13 +460,13 @@ bool RMInventory::rightRelease(const RMPoint &mpos, RMTonyAction &curAction) { if (_state == SELECTING) { _state = OPENED; - if (miniAction == 1) { // Esamina + if (_miniAction == 1) { // Esamina curAction = TA_EXAMINE; return true; - } else if (miniAction == 2) { // Parla + } else if (_miniAction == 2) { // Parla curAction = TA_TALK; return true; - } else if (miniAction == 3) { // Usa + } else if (_miniAction == 3) { // Usa curAction = TA_USE; return true; } @@ -489,39 +489,39 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo // DoFrame makes all the objects currently in the inventory be displayed // @@@ Maybe we should do all takeable objects? Please does not help for (i = 0; i < _nInv; i++) - if (_items[_inv[i]].icon.doFrame(this, false) && (i >= _curPos && i <= _curPos + 7)) + if (_items[_inv[i]]._icon.doFrame(this, false) && (i >= _curPos && i <= _curPos + 7)) bNeedRedraw = true; if ((_state == CLOSING || _state == OPENING || _state == OPENED) && checkPointInside(mpos)) { if (mpos.x > RM_SX - 64) { if (_curPos + 8 < _nInv && !_bBlinkingRight) { - _items[28].icon.setPattern(3); + _items[28]._icon.setPattern(3); _bBlinkingRight = true; bNeedRedraw = true; } } else if (_bBlinkingRight) { - _items[28].icon.setPattern(2); + _items[28]._icon.setPattern(2); _bBlinkingRight = false; bNeedRedraw = true; } if (mpos.x < 64) { if (_curPos > 0 && !_bBlinkingLeft) { - _items[29].icon.setPattern(3); + _items[29]._icon.setPattern(3); _bBlinkingLeft = true; bNeedRedraw = true; } } else if (_bBlinkingLeft) { - _items[29].icon.setPattern(2); + _items[29]._icon.setPattern(2); _bBlinkingLeft = false; bNeedRedraw = true; } } - if (_items[28].icon.doFrame(this, false)) + if (_items[28]._icon.doFrame(this, false)) bNeedRedraw = true; - if (_items[29].icon.doFrame(this, false)) + if (_items[29]._icon.doFrame(this, false)) bNeedRedraw = true; if (bNeedRedraw) @@ -535,7 +535,7 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo } if (_bCombining) {//m_state == COMBINING) - ptr.setCustomPointer(&_items[_nCombine].pointer[_items[_nCombine].status - 1]); + ptr.setCustomPointer(&_items[_nCombine]._pointer[_items[_nCombine]._status - 1]); ptr.setSpecialPointer(RMPointer::PTR_CUSTOM); } @@ -632,34 +632,34 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo // Make sure it is on one of the verbs if (mpos.y > starty && mpos.y < starty + 45) { if (mpos.x > startx && mpos.x < startx + 40) { - if (miniAction != 1) { - miniInterface.setPattern(2); - miniAction = 1; + if (_miniAction != 1) { + _miniInterface.setPattern(2); + _miniAction = 1; _vm->playUtilSFX(1); } } else if (mpos.x >= startx + 40 && mpos.x < startx + 80) { - if (miniAction != 2) { - miniInterface.setPattern(3); - miniAction = 2; + if (_miniAction != 2) { + _miniInterface.setPattern(3); + _miniAction = 2; _vm->playUtilSFX(1); } } else if (mpos.x >= startx + 80 && mpos.x < startx + 108) { - if (miniAction != 3) { - miniInterface.setPattern(4); - miniAction = 3; + if (_miniAction != 3) { + _miniInterface.setPattern(4); + _miniAction = 3; _vm->playUtilSFX(1); } } else { - miniInterface.setPattern(1); - miniAction = 0; + _miniInterface.setPattern(1); + _miniAction = 0; } } else { - miniInterface.setPattern(1); - miniAction = 0; + _miniInterface.setPattern(1); + _miniAction = 0; } // Update the mini-interface - miniInterface.doFrame(&bigBuf, false); + _miniInterface.doFrame(&bigBuf, false); } if ((_state != CLOSED) && !_nInList) { @@ -682,7 +682,7 @@ RMItem *RMInventory::whichItemIsIn(const RMPoint &mpt) { if (checkPointInside(mpt)) { n = mpt.x / 64; if (n > 0 && n < RM_SX / 64 - 1 && _inv[n - 1 + _curPos] != 0 && (!_bCombining || _inv[n - 1 + _curPos] != _nCombine)) - return &_items[_inv[n - 1 + _curPos]].icon; + return &_items[_inv[n - 1 + _curPos]]._icon; } } @@ -706,7 +706,7 @@ void RMInventory::saveState(byte *state) { for (i = 0; i < 256; i++) { if (i < _nItems) - x = _items[i].status; + x = _items[i]._status; else x = 0; @@ -728,20 +728,20 @@ int RMInventory::loadState(byte *state) { state += 4; if (i < _nItems) { - _items[i].status = x; - _items[i].icon.setPattern(x); + _items[i]._status = x; + _items[i]._icon.setPattern(x); } } _curPos = 0; _bCombining = false; - _items[29].icon.setPattern(1); + _items[29]._icon.setPattern(1); if (_nInv > 8) - _items[28].icon.setPattern(2); + _items[28]._icon.setPattern(2); else - _items[28].icon.setPattern(1); + _items[28]._icon.setPattern(1); prepare(); drawOT(Common::nullContext); diff --git a/engines/tony/inventory.h b/engines/tony/inventory.h index d8b20827b4..2b6248f7eb 100644 --- a/engines/tony/inventory.h +++ b/engines/tony/inventory.h @@ -39,9 +39,9 @@ namespace Tony { struct RMInventoryItem { - RMItem icon; - RMGfxSourceBuffer8RLEByteAA *pointer; - int status; + RMItem _icon; + RMGfxSourceBuffer8RLEByteAA *_pointer; + int _status; }; class RMInventory : public RMGfxWoodyBuffer { @@ -72,8 +72,8 @@ protected: bool _bBlinkingRight, _bBlinkingLeft; - int miniAction; - RMItem miniInterface; + int _miniAction; + RMItem _miniInterface; RMText _hints[3]; OSystem::MutexRef _csModifyInterface; -- cgit v1.2.3 From 42f4fe359c16dfe5291e6274464b76168b117135 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Sun, 10 Jun 2012 21:23:28 -0400 Subject: TONY: Convert FPSFX to our mixer code Only thing missing is the hEndOfBuffer code, but this is a good start --- engines/tony/sound.cpp | 387 ++++++++----------------------------------------- engines/tony/sound.h | 22 +-- 2 files changed, 69 insertions(+), 340 deletions(-) (limited to 'engines') diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index 2d4ff824f0..e63245586d 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -26,7 +26,10 @@ * Copyright (c) 1997-2003 Nayma Software */ -#include "audio/mixer.h" +#include "audio/audiostream.h" +#include "audio/decoders/adpcm.h" +#include "audio/decoders/raw.h" +#include "audio/decoders/wave.h" #include "common/textconsole.h" #include "tony/game.h" #include "tony/tony.h" @@ -182,7 +185,7 @@ void FPSOUND::GetMasterVolume(int *lpdwVolume) { /****************************************************************************\ * -* Function: FPSFX(LPDIRECTSOUND lpDS, bool bSoundOn); +* Function: FPSFX(bool bSoundOn); * * Description: Costruttore di default. *NON* bisogna dichiarare direttamente * un oggetto, ma crearlo piuttosto tramite FPSOUND::CreateSfx() @@ -190,40 +193,13 @@ void FPSOUND::GetMasterVolume(int *lpdwVolume) { \****************************************************************************/ FPSFX::FPSFX(bool bSoundOn) { -#ifdef REFACTOR_ME - - static char errbuf[128]; - - //hwnd=hWnd; bSoundSupported = bSoundOn; bFileLoaded = false; - bIsPlaying = false; - bPaused = false; - lpDSBuffer = NULL; - lpDSNotify = NULL; - lpDS = lpds; lastVolume = 63; hEndOfBuffer = CORO_INVALID_PID_VALUE; bIsVoice = false; - - if (bSoundSupported == false) - return; - - /* Poich non abbiamo ancora nessun dato sull'effetto sonoro, non possiamo fare nulla */ -#else - bIsVoice = false; - lastVolume = 0; - dwFreq = 0; - hEndOfBuffer = CORO_INVALID_PID_VALUE; - bFileLoaded = false; - bSoundSupported = false; - bLoop = false; + _stream = 0; bPaused = false; - bStereo = false; - b16bit = false; - bIsPlaying = false; - bIsVoice = false; -#endif } @@ -238,21 +214,16 @@ FPSFX::FPSFX(bool bSoundOn) { \****************************************************************************/ FPSFX::~FPSFX() { -#ifdef REFACTOR_ME - if (!bSoundSupported) return; - if (bIsPlaying) - Stop(); - - RELEASE(lpDSNotify); + g_system->getMixer()->stopHandle(_handle); - if (hEndOfBuffer != CORO_INVALID_PID_VALUE) - CloseHandle(hEndOfBuffer); + delete _stream; - RELEASE(lpDSBuffer); -#endif + // FIXME + //if (hEndOfBuffer != CORO_INVALID_PID_VALUE) + // CloseHandle(hEndOfBuffer); } @@ -271,7 +242,6 @@ FPSFX::~FPSFX() { void FPSFX::Release() { delete this; -// return NULL; } @@ -291,87 +261,16 @@ void FPSFX::Release() { \****************************************************************************/ bool FPSFX::loadWave(Common::SeekableReadStream *stream) { -#ifdef REFACTOR_ME - static PCMWAVEFORMAT pcmwf; - static DSBUFFERDESC dsbdesc; - static HRESULT err; - static char errbuf[128]; - uint32 dwHi; - struct WAVH { - int nChunckSize; - uint16 wFormatTag; - uint16 nChannels; - int nSamplesPerSec; - int nAvgBytesPerSec; - uint16 nBlockAlign; - uint16 nBitsPerSample; - } *WAVHeader; - uint32 dwSize; - void *lpLock; - - if (!bSoundSupported) - return true; - - if (lpBuf[0] != 'W' || lpBuf[1] != 'A' || lpBuf[2] != 'V' || lpBuf[3] != 'E') - return false; - if (lpBuf[4] != 'f' || lpBuf[5] != 'm' || lpBuf[6] != 't' || lpBuf[7] != ' ') + if (!stream) return false; - WAVHeader = (WAVH *)(lpBuf + 8); - lpBuf += 8 + sizeof(WAVH); + _stream = Audio::makeWAVStream(stream, DisposeAfterUse::YES); - if (lpBuf[0] != 'd' || lpBuf[1] != 'a' || lpBuf[2] != 't' || lpBuf[3] != 'a') + if (!_stream) return false; - lpBuf += 4; - - dwSize = READ_LE_UINT32(lpBuf); - lpBuf += 4; - - b16bit = (WAVHeader->nBitsPerSample == 16); - bStereo = (WAVHeader->nChannels == 2); - dwFreq = WAVHeader->nSamplesPerSec; - - /* Setta le strutture necessarie per la creazione di un secondary buffer - Attiviamo inoltre il controllo del volume, in modo da poter abbassare - e alzare il volume della musica indipendentemente da quello generale. - Proviamo a buttarlo in sound ram. */ - pcmwf.wBitsPerSample = (b16bit ? 16 : 8); - pcmwf.wf.wFormatTag = WAVE_FORMAT_PCM; - pcmwf.wf.nChannels = (bStereo ? 2 : 1); - pcmwf.wf.nSamplesPerSec = dwFreq; - pcmwf.wf.nBlockAlign = (pcmwf.wBitsPerSample / 8) * pcmwf.wf.nChannels; - pcmwf.wf.nAvgBytesPerSec = (uint32)pcmwf.wf.nBlockAlign * (uint32)pcmwf.wf.nSamplesPerSec; - - dsbdesc.dwSize = sizeof(dsbdesc); - dsbdesc.dwFlags = DSBCAPS_CTRLVOLUME | DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLPOSITIONNOTIFY; - dsbdesc.dwBufferBytes = dwSize; - dsbdesc.lpwfxFormat = (LPWAVEFORMATEX)&pcmwf; - - if ((err = lpDS->CreateSoundBuffer(&dsbdesc, &lpDSBuffer, NULL)) != DS_OK) { - wsprintf(errbuf, "Error creating the secondary buffer (%lx)", err); - MessageBox(hwnd, errbuf, "FPSFX::FPSFX()", MB_OK); - return false; - } - - // Riempie il buffer - if ((err = lpDSBuffer->Lock(0, dwSize, &lpLock, (uint32 *)&dwHi, NULL, NULL, 0)) != DS_OK) { - MessageBox(hwnd, "Cannot lock sfx buffer!", "FPSFX::LoadFile()", MB_OK); - return false; - } - - /* Decomprime i dati dello stream direttamente dentro il buffer lockato */ - copyMemory(lpLock, lpBuf, dwSize); - - /* Unlocka il buffer */ - lpDSBuffer->Unlock(lpLock, dwSize, NULL, NULL); - - /* Setta volume iniziale */ - SetVolume(lastVolume); bFileLoaded = true; -#endif - - delete stream; // Just so we don't leak it + SetVolume(lastVolume); return true; } @@ -391,207 +290,59 @@ bool FPSFX::loadWave(Common::SeekableReadStream *stream) { \****************************************************************************/ bool FPSFX::LoadVoiceFromVDB(Common::File &vdbFP) { -#ifdef REFACTOR_ME - uint32 dwSize; - static PCMWAVEFORMAT pcmwf; - static DSBUFFERDESC dsbdesc; - byte *lpTempBuffer; - static HRESULT err; - uint32 dwHi; - void *lpBuf; - static char errbuf[128]; - if (!bSoundSupported) return true; - b16bit = true; - bStereo = false; + uint32 size = vdbFP.readUint32LE(); + uint32 rate = vdbFP.readUint32LE(); bIsVoice = true; -// fread(&dwSize,1,4,vdbFP); -// fread(&dwFreq,1,4,vdbFP); - ReadFile(vdbFP, &dwSize, 4, &dwHi, NULL); - ReadFile(vdbFP, &dwFreq, 4, &dwHi, NULL); - - dwSize *= 4; - - /* Setta le strutture necessarie per la creazione di un secondary buffer - Attiviamo inoltre il controllo del volume, in modo da poter abbassare - e alzare il volume della musica indipendentemente da quello generale. - Proviamo a buttarlo in sound ram. */ - pcmwf.wBitsPerSample = (b16bit ? 16 : 8); - pcmwf.wf.wFormatTag = WAVE_FORMAT_PCM; - pcmwf.wf.nChannels = (bStereo ? 2 : 1); - pcmwf.wf.nSamplesPerSec = dwFreq; - pcmwf.wf.nBlockAlign = (pcmwf.wBitsPerSample / 8) * pcmwf.wf.nChannels; - pcmwf.wf.nAvgBytesPerSec = (uint32)pcmwf.wf.nBlockAlign * (uint32)pcmwf.wf.nSamplesPerSec; - - dsbdesc.dwSize = sizeof(dsbdesc); - dsbdesc.dwFlags = DSBCAPS_CTRLVOLUME | DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLPOSITIONNOTIFY; - dsbdesc.dwBufferBytes = dwSize; - dsbdesc.lpwfxFormat = (LPWAVEFORMATEX)&pcmwf; - - if ((err = lpDS->CreateSoundBuffer(&dsbdesc, &lpDSBuffer, NULL)) != DS_OK) { - wsprintf(errbuf, "Error creating the secondary buffer (%lx)", err); - MessageBox(hwnd, errbuf, "FPSFX::FPSFX()", MB_OK); - return false; - } - - /* Alloca un buffer temporaneo */ - lpTempBuffer = (byte *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, dwSize); - if (lpTempBuffer == NULL) - return false; - - lpCodec = new CODECADPCMMONO(bLoop, lpTempBuffer); - - /* Riempie il buffer */ - if ((err = lpDSBuffer->Lock(0, dwSize, &lpBuf, (uint32 *)&dwHi, NULL, NULL, 0)) != DS_OK) { - MessageBox(hwnd, "Cannot lock sfx buffer!", "FPSFX::LoadFile()", MB_OK); - return false; - } - - /* Decomprime i dati dello stream direttamente dentro il buffer lockato */ - lpCodec->Decompress(vdbFP, lpBuf, dwSize); + _stream = Audio::makeADPCMStream(vdbFP.readStream(size), DisposeAfterUse::YES, 0, Audio::kADPCMDVI, rate, 1); - /* Unlocka il buffer */ - lpDSBuffer->Unlock(lpBuf, dwSize, NULL, NULL); - - delete lpCodec; - - /* Crea il notify per avvertire quando raggiungiamo la fine della voce */ - err = lpDSBuffer->QueryInterface(IID_IDirectSoundNotify, (void **)&lpDSNotify); - if (FAILED(err)) { - wsprintf(errbuf, "Error creating notify object! (%lx)", err); - MessageBox(hwnd, errbuf, "FPSFX::LoadVoiceFromVDB()", MB_OK); - return false; - } - - hEndOfBuffer = CreateEvent(NULL, false, false, NULL); - - dspnHot[0].dwOffset = DSBPN_OFFSETSTOP; - dspnHot[0].hEventNotify = hEndOfBuffer; - - lpDSNotify->SetNotificationPositions(1, dspnHot); - - /* Tutto a posto, possiamo uscire */ bFileLoaded = true; SetVolume(62); - -#endif return true; } bool FPSFX::LoadFile(const char *lpszFileName, uint32 dwCodec) { -#ifdef REFACTOR_ME - static PCMWAVEFORMAT pcmwf; - static DSBUFFERDESC dsbdesc; - static HRESULT err; - static char errbuf[128]; - Common::File file; - uint32 dwSize; - byte *lpTempBuffer; - void *lpBuf; - uint32 dwHi; - struct { - char id[4]; - int freq; - int nChan; - } ADPHead; - if (!bSoundSupported) return true; - /* Apre il file di stream in lettura */ + Common::File file; if (!file.open(lpszFileName)) { - warning("FPSFX::LoadFile() : Cannot open sfx file!"); - return false; - } - - /* Leggiamo l'header */ - file.read(ADPHead.id, 4); - ADPHead.freq = file.readUint32LE(); - ADPHead.nChan = file.readUint32LE(); - - if (ADPHead.id[0] != 'A' || ADPHead.id[1] != 'D' || ADPHead.id[2] != 'P' || ADPHead.id[3] != 0x10) { - warning("FPSFX::LoadFile() : Invalid ADP header!"); - file.close(); + warning("FPSFX::LoadFile(): Cannot open sfx file!"); return false; } - b16bit = true; - bStereo = (ADPHead.nChan == 2); - dwFreq = ADPHead.freq; - - /* Si salva la lunghezza dello stream */ - dwSize = file.size() - 12 /*sizeof(ADPHead)*/; - file.seek(0); - - if (dwCodec == FPCODEC_ADPCM) - dwSize *= 4; - - /* Setta le strutture necessarie per la creazione di un secondary buffer - Attiviamo inoltre il controllo del volume, in modo da poter abbassare - e alzare il volume della musica indipendentemente da quello generale. - Proviamo a buttarlo in sound ram. */ - pcmwf.wBitsPerSample = (b16bit ? 16 : 8); - pcmwf.wf.wFormatTag = WAVE_FORMAT_PCM; - pcmwf.wf.nChannels = (bStereo ? 2 : 1); - pcmwf.wf.nSamplesPerSec = dwFreq; - pcmwf.wf.nBlockAlign = (pcmwf.wBitsPerSample / 8) * pcmwf.wf.nChannels; - pcmwf.wf.nAvgBytesPerSec = (uint32)pcmwf.wf.nBlockAlign * (uint32)pcmwf.wf.nSamplesPerSec; - - dsbdesc.dwSize = sizeof(dsbdesc); - dsbdesc.dwFlags = DSBCAPS_CTRLVOLUME | DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLPOSITIONNOTIFY; - dsbdesc.dwBufferBytes = dwSize; - dsbdesc.lpwfxFormat = (LPWAVEFORMATEX) & pcmwf; - - if ((err = lpDS->CreateSoundBuffer(&dsbdesc, &lpDSBuffer, NULL)) != DS_OK) { - wsprintf(errbuf, "Error creating the secondary buffer (%lx)", err); - MessageBox(hwnd, errbuf, "FPSFX::FPSFX()", MB_OK); + if (file.readUint32BE() != MKTAG('A', 'D', 'P', 0x10)) { + warning("FPSFX::LoadFile(): Invalid ADP header!"); return false; } - /* Alloca un buffer temporaneo */ - lpTempBuffer = (byte *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, dwSize); - if (lpTempBuffer == NULL) - return false; + uint32 rate = file.readUint32LE(); + uint32 channels = file.readUint32LE(); - switch (dwCodec) { - case FPCODEC_RAW: - lpCodec = new CODECRAW(bLoop); - break; + Common::SeekableReadStream *buffer = file.readStream(file.size() - file.pos()); + Audio::RewindableAudioStream *stream; - case FPCODEC_ADPCM: - if (bStereo) - lpCodec = new CODECADPCMSTEREO(bLoop, lpTempBuffer); - else - lpCodec = new CODECADPCMMONO(bLoop, lpTempBuffer); - break; + if (dwCodec == FPCODEC_ADPCM) { + stream = Audio::makeADPCMStream(buffer, DisposeAfterUse::YES, 0, Audio::kADPCMDVI, rate, channels); + } else { + byte flags = Audio::FLAG_16BITS | Audio::FLAG_LITTLE_ENDIAN; - default: - return false; - G - } + if (channels == 2) + flags |= Audio::FLAG_STEREO; - /* Riempie il buffer */ - if ((err = lpDSBuffer->Lock(0, dwSize, &lpBuf, (uint32 *)&dwHi, NULL, NULL, 0)) != DS_OK) { - MessageBox(hwnd, "Cannot lock sfx buffer!", "FPSFX::LoadFile()", MB_OK); - return false; + stream = Audio::makeRawStream(buffer, rate, flags, DisposeAfterUse::YES); } - /* Decomprime i dati dello stream direttamente dentro il buffer lockato */ - lpCodec->Decompress(file, lpBuf, dwSize); - - /* Unlocka il buffer */ - lpDSBuffer->Unlock(lpBuf, dwSize, NULL, NULL); + if (bLoop) + _stream = Audio::makeLoopingAudioStream(stream, 0); + else + _stream = stream; - delete lpCodec; - file.close(); - - /* Tutto a posto, possiamo uscire */ bFileLoaded = true; -#endif return true; } @@ -607,19 +358,22 @@ bool FPSFX::LoadFile(const char *lpszFileName, uint32 dwCodec) { \****************************************************************************/ bool FPSFX::Play() { -#ifdef REFACTOR_ME + Stop(); // sanity check + if (bFileLoaded) { - if (hEndOfBuffer != CORO_INVALID_PID_VALUE) - ResetEvent(hEndOfBuffer); + // FIXME + //if (hEndOfBuffer != CORO_INVALID_PID_VALUE) + // ResetEvent(hEndOfBuffer); - lpDSBuffer->SetCurrentPosition(0); - bIsPlaying = true; + g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &_handle, _stream, -1, + Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO); - if (!bPaused) { - lpDSBuffer->Play(0, 0, (bLoop ? DSBPLAY_LOOPING : 0)); - } + SetVolume(lastVolume); + + if (bPaused) + g_system->getMixer()->pauseHandle(_handle, true); } -#endif + return true; } @@ -634,17 +388,12 @@ bool FPSFX::Play() { * \****************************************************************************/ -bool FPSFX::Stop(void) { -#ifdef REFACTOR_ME +bool FPSFX::Stop() { if (bFileLoaded) { - if (bPaused || bIsPlaying) { - lpDSBuffer->Stop(); - } - - bIsPlaying = false; + g_system->getMixer()->stopHandle(_handle); bPaused = false; } -#endif + return true; } @@ -671,21 +420,12 @@ void FPSFX::SetLoop(bool bLop) { } void FPSFX::Pause(bool bPause) { -#ifdef REFACTOR_ME if (bFileLoaded) { - if (bPause && bIsPlaying) { - lpDSBuffer->Stop(); - } else if (!bPause && bPaused) { - if (bIsPlaying && bLoop) - lpDSBuffer->Play(0, 0, (bLoop ? DSBPLAY_LOOPING : 0)); - } + if (g_system->getMixer()->isSoundHandleActive(_handle) && (bPause ^ bPaused)) + g_system->getMixer()->pauseHandle(_handle, bPause); - // Trucchetto per risettare il volume secondo le - // possibili nuove configurazioni sonore - SetVolume(lastVolume); bPaused = bPause; } -#endif } @@ -718,10 +458,9 @@ void FPSFX::SetVolume(int dwVolume) { if (dwVolume < 0) dwVolume = 0; } } -#ifdef REFACTOR_ME - if (bFileLoaded) - lpDSBuffer->SetVolume(dwVolume * (DSBVOLUME_MAX - DSBVOLUME_MIN) / 64 + DSBVOLUME_MIN); -#endif + + if (g_system->getMixer()->isSoundHandleActive(_handle)) + g_system->getMixer()->setChannelVolume(_handle, dwVolume * Audio::Mixer::kMaxChannelVolume / 63); } @@ -738,14 +477,10 @@ void FPSFX::SetVolume(int dwVolume) { \****************************************************************************/ void FPSFX::GetVolume(int *lpdwVolume) { -#ifdef REFACTOR_ME - if (bFileLoaded) - lpDSBuffer->GetVolume((uint32 *)lpdwVolume); - - *lpdwVolume -= (DSBVOLUME_MIN); - *lpdwVolume *= 64; - *lpdwVolume /= (DSBVOLUME_MAX - DSBVOLUME_MIN); -#endif + if (g_system->getMixer()->isSoundHandleActive(_handle)) + *lpdwVolume = g_system->getMixer()->getChannelVolume(_handle) * 63 / Audio::Mixer::kMaxChannelVolume; + else + *lpdwVolume = 0; } diff --git a/engines/tony/sound.h b/engines/tony/sound.h index be3c2da319..6ebf30f22b 100644 --- a/engines/tony/sound.h +++ b/engines/tony/sound.h @@ -29,11 +29,16 @@ #ifndef TONY_SOUND_H #define TONY_SOUND_H +#include "audio/mixer.h" #include "common/file.h" #include "tony/gfxcore.h" #include "tony/loc.h" #include "tony/utils.h" +namespace Audio { +class RewindableAudioStream; +} + namespace Tony { class FPSTREAM; @@ -181,27 +186,16 @@ class FPSFX { \****************************************************************************/ private: - /* - HWND hwnd; - LPDIRECTSOUND lpDS; - LPDIRECTSOUNDBUFFER lpDSBuffer; // Buffer DirectSound - */ bool bSoundSupported; // TRUE se il suono e' attivo bool bFileLoaded; // TRUE se e' stato aperto un file bool bLoop; // TRUE se bisogna loopare l'effetto sonoro - bool bPaused; int lastVolume; - bool bStereo; // TRUE se stereo - bool b16bit; // TRUE se 16 bit - uint32 dwFreq; // Frequenza originale di campionamento - - bool bIsPlaying; // TRUE se si sta playando l'effetto sonoro - bool bIsVoice; + bool bPaused; -// LPDIRECTSOUNDNOTIFY lpDSNotify; // Notify degli hotspot nel buffer -// DSBPOSITIONNOTIFY dspnHot[2]; + Audio::AudioStream *_stream; + Audio::SoundHandle _handle; public: uint32 hEndOfBuffer; -- cgit v1.2.3 From 2da2981682cdc637faf5e2fccc041223d457bdc4 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Sun, 10 Jun 2012 22:03:52 -0400 Subject: TONY: Rewind sounds before playing them Fixes sounds in the menu --- engines/tony/sound.cpp | 21 +++++++++++++-------- engines/tony/sound.h | 1 + 2 files changed, 14 insertions(+), 8 deletions(-) (limited to 'engines') diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index e63245586d..1fb4bbee1f 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -199,6 +199,7 @@ FPSFX::FPSFX(bool bSoundOn) { hEndOfBuffer = CORO_INVALID_PID_VALUE; bIsVoice = false; _stream = 0; + _rewindableStream = 0; bPaused = false; } @@ -220,6 +221,7 @@ FPSFX::~FPSFX() { g_system->getMixer()->stopHandle(_handle); delete _stream; + // _rewindableStream is deleted by deleting _stream // FIXME //if (hEndOfBuffer != CORO_INVALID_PID_VALUE) @@ -264,11 +266,12 @@ bool FPSFX::loadWave(Common::SeekableReadStream *stream) { if (!stream) return false; - _stream = Audio::makeWAVStream(stream, DisposeAfterUse::YES); + _rewindableStream = Audio::makeWAVStream(stream, DisposeAfterUse::YES); - if (!_stream) + if (!_rewindableStream) return false; + _stream = _rewindableStream; bFileLoaded = true; SetVolume(lastVolume); return true; @@ -297,7 +300,8 @@ bool FPSFX::LoadVoiceFromVDB(Common::File &vdbFP) { uint32 rate = vdbFP.readUint32LE(); bIsVoice = true; - _stream = Audio::makeADPCMStream(vdbFP.readStream(size), DisposeAfterUse::YES, 0, Audio::kADPCMDVI, rate, 1); + _rewindableStream = Audio::makeADPCMStream(vdbFP.readStream(size), DisposeAfterUse::YES, 0, Audio::kADPCMDVI, rate, 1); + _stream = _rewindableStream; bFileLoaded = true; SetVolume(62); @@ -324,23 +328,22 @@ bool FPSFX::LoadFile(const char *lpszFileName, uint32 dwCodec) { uint32 channels = file.readUint32LE(); Common::SeekableReadStream *buffer = file.readStream(file.size() - file.pos()); - Audio::RewindableAudioStream *stream; if (dwCodec == FPCODEC_ADPCM) { - stream = Audio::makeADPCMStream(buffer, DisposeAfterUse::YES, 0, Audio::kADPCMDVI, rate, channels); + _rewindableStream = Audio::makeADPCMStream(buffer, DisposeAfterUse::YES, 0, Audio::kADPCMDVI, rate, channels); } else { byte flags = Audio::FLAG_16BITS | Audio::FLAG_LITTLE_ENDIAN; if (channels == 2) flags |= Audio::FLAG_STEREO; - stream = Audio::makeRawStream(buffer, rate, flags, DisposeAfterUse::YES); + _rewindableStream = Audio::makeRawStream(buffer, rate, flags, DisposeAfterUse::YES); } if (bLoop) - _stream = Audio::makeLoopingAudioStream(stream, 0); + _stream = Audio::makeLoopingAudioStream(_rewindableStream, 0); else - _stream = stream; + _stream = _rewindableStream; bFileLoaded = true; return true; @@ -365,6 +368,8 @@ bool FPSFX::Play() { //if (hEndOfBuffer != CORO_INVALID_PID_VALUE) // ResetEvent(hEndOfBuffer); + _rewindableStream->rewind(); + g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &_handle, _stream, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO); diff --git a/engines/tony/sound.h b/engines/tony/sound.h index 6ebf30f22b..c64680a9cf 100644 --- a/engines/tony/sound.h +++ b/engines/tony/sound.h @@ -195,6 +195,7 @@ private: bool bPaused; Audio::AudioStream *_stream; + Audio::RewindableAudioStream *_rewindableStream; Audio::SoundHandle _handle; public: -- cgit v1.2.3 From 5b5a812d3750cc1e8063ccfc8d1d9bf4db6a127b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 11 Jun 2012 12:20:12 +1000 Subject: TONY: Implemented process to properly set hEndOfBuffer when sound effects end --- engines/tony/sound.cpp | 35 +++++++++++++++++++++++++++++++++++ engines/tony/sound.h | 9 +++++++++ engines/tony/tony.cpp | 3 +++ engines/tony/tony.h | 1 + 4 files changed, 48 insertions(+) (limited to 'engines') diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index 1fb4bbee1f..487bf54111 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -201,6 +201,8 @@ FPSFX::FPSFX(bool bSoundOn) { _stream = 0; _rewindableStream = 0; bPaused = false; + + _vm->_activeSfx.push_back(this); } @@ -219,6 +221,7 @@ FPSFX::~FPSFX() { return; g_system->getMixer()->stopHandle(_handle); + _vm->_activeSfx.remove(this); delete _stream; // _rewindableStream is deleted by deleting _stream @@ -488,6 +491,38 @@ void FPSFX::GetVolume(int *lpdwVolume) { *lpdwVolume = 0; } +/** + * Returns true if the underlying sound has ended + */ +bool FPSFX::endOfBuffer() const { + return !g_system->getMixer()->isSoundHandleActive(_handle) && (!_stream || _stream->endOfData()); +} + +/** + * Continually checks to see if active sounds have finished playing + * Sets the event signalling the sound has ended + */ +void FPSFX::soundCheckProcess(CORO_PARAM, const void *param) { + CORO_BEGIN_CONTEXT; + Common::List::iterator i; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + for (;;) { + // Check each active sound + for (_ctx->i = _vm->_activeSfx.begin(); _ctx->i != _vm->_activeSfx.end(); ++_ctx->i) { + FPSFX *sfx = *_ctx->i; + if (sfx->endOfBuffer()) + CoroScheduler.setEvent(sfx->hEndOfBuffer); + } + + // Delay until the next check is done + CORO_INVOKE_1(CoroScheduler.sleep, 50); + } + + CORO_END_CODE; +} /****************************************************************************\ * Metodi di FPSTREAM diff --git a/engines/tony/sound.h b/engines/tony/sound.h index c64680a9cf..6593470d0c 100644 --- a/engines/tony/sound.h +++ b/engines/tony/sound.h @@ -209,6 +209,10 @@ private: \****************************************************************************/ public: + /** + * Check process for whether sounds have finished playing + */ + static void soundCheckProcess(CORO_PARAM, const void *param); /****************************************************************************\ * @@ -353,6 +357,11 @@ public: \****************************************************************************/ void GetVolume(int *lpdwVolume); + + /** + * Returns true if the sound has finished playing + */ + bool endOfBuffer() const; }; class FPSTREAM { diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 2b9d8fbc20..b1e45c8bfa 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -371,6 +371,9 @@ void TonyEngine::initMusic() { // Preload sound effects preloadUtilSFX(0, "U01.ADP"); // Reversed!! preloadUtilSFX(1, "U02.ADP"); + + // Start check processes for sound + CoroScheduler.createProcess(FPSFX::soundCheckProcess, NULL); } void TonyEngine::closeMusic() { diff --git a/engines/tony/tony.h b/engines/tony/tony.h index cee15d07a4..43bc23c636 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -100,6 +100,7 @@ public: Common::File _vdbFP; Common::Array _voices; FPSOUND _theSound; + Common::List _activeSfx; Globals _globals; Debugger *_debugger; -- cgit v1.2.3 From d20fb7480eaccb59b11e3a5ba02b1a2b60619aaf Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 11 Jun 2012 19:22:41 +1000 Subject: TONY: Fix crash in the Tunnel Of Love --- engines/tony/custom.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 2e408a01aa..6627cd6c39 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -467,6 +467,11 @@ DECLARE_CUSTOM_FUNCTION(ClearScreen)(CORO_PARAM, uint32, uint32, uint32, uint32) CORO_INVOKE_0(GLOBALS.WaitFrame); + // WORKAROUND: This fixes a bug in the original source where the linked clear task + // didn't have time to be drawn and removed from the draw list before the method + // ended, thus remaining in the draw list and causing a later crash + CORO_INVOKE_0(GLOBALS.WaitFrame); + CORO_END_CODE; } -- cgit v1.2.3 From 71329df502bb07f105f34ac6c4b871ee0e8e19e0 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 11 Jun 2012 22:38:03 +1000 Subject: TONY: Removed unused variable --- engines/tony/font.cpp | 2 -- engines/tony/font.h | 1 - 2 files changed, 3 deletions(-) (limited to 'engines') diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 6652e77e13..6f70f41d80 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -1760,7 +1760,6 @@ void RMFontObj::init(void) { \****************************************************************************/ RMFontColor *RMText::_fonts[4] = { NULL, NULL, NULL, NULL }; -RMGfxClearTask RMText::_clear; void RMText::initStatics() { Common::fill(&_fonts[0], &_fonts[4], (RMFontColor *)NULL); @@ -1891,7 +1890,6 @@ void RMText::writeText(const RMString &text, RMFontColor *font, int *time) { // Create the surface create(width, height); - //AddPrim(new RMGfxPrimitive(&m_clear)); Common::fill(_buf, _buf + width * height * 2, 0); p = string; diff --git a/engines/tony/font.h b/engines/tony/font.h index d1423c9749..daaac84a59 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -175,7 +175,6 @@ public: class RMText : public RMGfxWoodyBuffer { private: static RMFontColor *_fonts[4]; - static RMGfxClearTask _clear; int _maxLineLength; public: -- cgit v1.2.3 From 02c8ccebcb20aa904dba3151d65a7b4fa67998fe Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 11 Jun 2012 20:24:25 +0200 Subject: TONY: Rename variables in utils.h --- engines/tony/custom.cpp | 23 +++--- engines/tony/debugger.cpp | 8 +- engines/tony/font.cpp | 44 +++++------ engines/tony/game.cpp | 18 ++--- engines/tony/gfxcore.cpp | 38 +++++----- engines/tony/gfxengine.cpp | 20 ++--- engines/tony/inventory.cpp | 48 ++++++------ engines/tony/loc.cpp | 177 +++++++++++++++++++++++---------------------- engines/tony/utils.cpp | 112 ++++++++++++++-------------- engines/tony/utils.h | 20 ++--- 10 files changed, 256 insertions(+), 252 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 6627cd6c39..0cf40e5a14 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -477,7 +477,7 @@ DECLARE_CUSTOM_FUNCTION(ClearScreen)(CORO_PARAM, uint32, uint32, uint32, uint32) DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgEnd)(CORO_PARAM, uint32 bNotEnableTony, uint32, uint32, uint32) { GLOBALS.Freeze(); - GLOBALS.LoadLocation(GLOBALS.SFM_nLoc, RMPoint(GLOBALS.SFM_pt.x, GLOBALS.SFM_pt.y), RMPoint(-1, -1)); + GLOBALS.LoadLocation(GLOBALS.SFM_nLoc, RMPoint(GLOBALS.SFM_pt._x, GLOBALS.SFM_pt._y), RMPoint(-1, -1)); if (!bNotEnableTony) GLOBALS._tony->show(); GLOBALS.Unfreeze(); @@ -593,7 +593,7 @@ DECLARE_CUSTOM_FUNCTION(RestoreTonyPosition)(CORO_PARAM, uint32, uint32, uint32, CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_4(ChangeLocation, GLOBALS._saveTonyLoc, GLOBALS._saveTonyPos.x, GLOBALS._saveTonyPos.y, 0); + CORO_INVOKE_4(ChangeLocation, GLOBALS._saveTonyLoc, GLOBALS._saveTonyPos._x, GLOBALS._saveTonyPos._y, 0); MCharResetCodes(); @@ -1299,14 +1299,14 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui if (sX) { if (_ctx->lx > 0) - _ctx->pt.x += (_ctx->dimx * _ctx->dwCurTime) / _ctx->dwTotalTime; + _ctx->pt._x += (_ctx->dimx * _ctx->dwCurTime) / _ctx->dwTotalTime; else - _ctx->pt.x -= (_ctx->dimx * _ctx->dwCurTime) / _ctx->dwTotalTime; + _ctx->pt._x -= (_ctx->dimx * _ctx->dwCurTime) / _ctx->dwTotalTime; } else { if (_ctx->ly > 0) - _ctx->pt.y += (_ctx->dimy * _ctx->dwCurTime) / _ctx->dwTotalTime; + _ctx->pt._y += (_ctx->dimy * _ctx->dwCurTime) / _ctx->dwTotalTime; else - _ctx->pt.y -= (_ctx->dimy * _ctx->dwCurTime) / _ctx->dwTotalTime; + _ctx->pt._y -= (_ctx->dimy * _ctx->dwCurTime) / _ctx->dwTotalTime; } @@ -1323,14 +1323,14 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui // Set the position finale if (sX) { if (_ctx->lx > 0) - _ctx->pt.x = _ctx->startpt.x + _ctx->dimx; + _ctx->pt._x = _ctx->startpt._x + _ctx->dimx; else - _ctx->pt.x = _ctx->startpt.x - _ctx->dimx; + _ctx->pt._x = _ctx->startpt._x - _ctx->dimx; } else { if (_ctx->ly > 0) - _ctx->pt.y = _ctx->startpt.y + _ctx->dimy; + _ctx->pt._y = _ctx->startpt._y + _ctx->dimy; else - _ctx->pt.y = _ctx->startpt.y - _ctx->dimy; + _ctx->pt._y = _ctx->startpt._y - _ctx->dimy; } GLOBALS.Freeze(); @@ -1345,12 +1345,13 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui DECLARE_CUSTOM_FUNCTION(ChangeHotspot)(CORO_PARAM, uint32 dwCode, uint32 nX, uint32 nY, uint32) { int i; - for (i = 0; i < GLOBALS._curChangedHotspot; i++) + for (i = 0; i < GLOBALS._curChangedHotspot; i++) { if (GLOBALS._changedHotspot[i]._dwCode == dwCode) { GLOBALS._changedHotspot[i]._nX = nX; GLOBALS._changedHotspot[i]._nY = nY; break; } + } if (i == GLOBALS._curChangedHotspot) { GLOBALS._changedHotspot[i]._dwCode = dwCode; diff --git a/engines/tony/debugger.cpp b/engines/tony/debugger.cpp index 1a4dc16b75..8beb7285a4 100644 --- a/engines/tony/debugger.cpp +++ b/engines/tony/debugger.cpp @@ -94,8 +94,8 @@ bool Debugger::Cmd_Scene(int argc, const char **argv) { RMPoint scenePos; if (argc >= 4) { - scenePos.x = strToInt(argv[2]); - scenePos.y = strToInt(argv[3]); + scenePos._x = strToInt(argv[2]); + scenePos._y = strToInt(argv[3]); } else { // Get the box areas for the scene, and choose one so as to have a default // position for Tony that will be in the walkable areas @@ -106,8 +106,8 @@ bool Debugger::Cmd_Scene(int argc, const char **argv) { // Set up a process to change the scene ChangeSceneDetails details; details.sceneNumber = sceneNumber; - details.x = scenePos.x; - details.y = scenePos.y; + details.x = scenePos._x; + details.y = scenePos._y; CoroScheduler.createProcess(DebugChangeScene, &details, sizeof(ChangeSceneDetails)); return false; diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 6f70f41d80..122c529de3 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -1930,8 +1930,8 @@ void RMText::writeText(const RMString &text, RMFontColor *font, int *time) { } prim = font->makeLetterPrimitive(*p, len); - prim->getDst().x1 = x; - prim->getDst().y1 = y; + prim->getDst()._x1 = x; + prim->getDst()._y1 = y; addPrim(prim); numchar++; @@ -1949,14 +1949,14 @@ void RMText::writeText(const RMString &text, RMFontColor *font, int *time) { void RMText::clipOnScreen(RMGfxPrimitive *prim) { // Don't let it go outside the screen - if (prim->getDst().x1 < 5) - prim->getDst().x1 = 5; - if (prim->getDst().y1 < 5) - prim->getDst().y1 = 5; - if (prim->getDst().x1 + _dimx > 635) - prim->getDst().x1 = 635 - _dimx; - if (prim->getDst().y1 + _dimy > 475) - prim->getDst().y1 = 475 - _dimy; + if (prim->getDst()._x1 < 5) + prim->getDst()._x1 = 5; + if (prim->getDst()._y1 < 5) + prim->getDst()._y1 = 5; + if (prim->getDst()._x1 + _dimx > 635) + prim->getDst()._x1 = 635 - _dimx; + if (prim->getDst()._y1 + _dimy > 475) + prim->getDst()._y1 = 475 - _dimy; } void RMText::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { @@ -1975,10 +1975,10 @@ void RMText::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { if (_aVerType == VTOP) { } else if (_aVerType == VCENTER) { - prim->getDst().y1 -= _dimy / 2; + prim->getDst()._y1 -= _dimy / 2; } else if (_aVerType == VBOTTOM) { - prim->getDst().y1 -= _dimy; + prim->getDst()._y1 -= _dimy; } clipOnScreen(prim); @@ -2416,7 +2416,7 @@ void RMDialogChoice::prepare(CORO_PARAM) { CORO_INVOKE_0(drawOT); clearOT(); - _ptDrawPos.set(0, 480 - _ctx->ptPos.y); + _ptDrawPos.set(0, 480 - _ctx->ptPos._y); CORO_END_CODE; } @@ -2436,7 +2436,7 @@ void RMDialogChoice::setSelected(CORO_PARAM, int pos) { if (_curSelection != -1) { _ctx->box.setColor(0xCC, 0xCC, 0xFF); - _ctx->rc.topLeft() = RMPoint(18, _ptDrawStrings[_curSelection].y); + _ctx->rc.topLeft() = RMPoint(18, _ptDrawStrings[_curSelection]._y); _ctx->rc.bottomRight() = _ctx->rc.topLeft() + RMPoint(597, _drawedStrings[_curSelection].getDimy()); addPrim(new RMGfxPrimitive(&_ctx->box, _ctx->rc)); @@ -2447,7 +2447,7 @@ void RMDialogChoice::setSelected(CORO_PARAM, int pos) { if (pos != -1) { _ctx->box.setColor(100, 100, 100); - _ctx->rc.topLeft() = RMPoint(18, _ptDrawStrings[pos].y); + _ctx->rc.topLeft() = RMPoint(18, _ptDrawStrings[pos]._y); _ctx->rc.bottomRight() = _ctx->rc.topLeft() + RMPoint(597, _drawedStrings[pos].getDimy()); addPrim(new RMGfxPrimitive(&_ctx->box, _ctx->rc)); addPrim(new RMGfxPrimitive(&_drawedStrings[pos], _ptDrawStrings[pos])); @@ -2481,7 +2481,7 @@ void RMDialogChoice::show(CORO_PARAM, RMGfxTargetBuffer *bigBuf) { _bShow = true; } else { _ctx->starttime = _vm->getTime(); - _ctx->deltay = 480 - _ptDrawPos.y; + _ctx->deltay = 480 - _ptDrawPos._y; _ctx->destpt = _ptDrawPos; _ptDrawPos.set(0, 480); @@ -2494,11 +2494,11 @@ void RMDialogChoice::show(CORO_PARAM, RMGfxTargetBuffer *bigBuf) { CORO_INVOKE_0(mainWaitFrame); mainFreeze(); _ctx->elaps = _vm->getTime() - _ctx->starttime; - _ptDrawPos.y = 480 - ((_ctx->deltay * 100) / 700 * _ctx->elaps) / 100; + _ptDrawPos._y = 480 - ((_ctx->deltay * 100) / 700 * _ctx->elaps) / 100; mainUnfreeze(); } - _ptDrawPos.y = _ctx->destpt.y; + _ptDrawPos._y = _ctx->destpt._y; } CORO_END_CODE; @@ -2532,13 +2532,13 @@ void RMDialogChoice::hide(CORO_PARAM) { if (1) { _ctx->starttime = _vm->getTime(); - _ctx->deltay = 480 - _ptDrawPos.y; + _ctx->deltay = 480 - _ptDrawPos._y; _ctx->elaps = 0; while (_ctx->elaps < 700) { CORO_INVOKE_0(mainWaitFrame); mainFreeze(); _ctx->elaps = _vm->getTime() - _ctx->starttime; - _ptDrawPos.y = 480 - ((_ctx->deltay * 100) / 700 * (700 - _ctx->elaps)) / 100; + _ptDrawPos._y = 480 - ((_ctx->deltay * 100) / 700 * (700 - _ctx->elaps)) / 100; mainUnfreeze(); } } @@ -2562,9 +2562,9 @@ void RMDialogChoice::doFrame(CORO_PARAM, RMPoint ptMousePos) { CORO_BEGIN_CODE(_ctx); - if (ptMousePos.y > _ptDrawPos.y) { + if (ptMousePos._y > _ptDrawPos._y) { for (_ctx->i = 0; _ctx->i < _numChoices; _ctx->i++) { - if ((ptMousePos.y >= _ptDrawPos.y + _ptDrawStrings[_ctx->i].y) && (ptMousePos.y < _ptDrawPos.y + _ptDrawStrings[_ctx->i].y + _drawedStrings[_ctx->i].getDimy())) { + if ((ptMousePos._y >= _ptDrawPos._y + _ptDrawStrings[_ctx->i]._y) && (ptMousePos._y < _ptDrawPos._y + _ptDrawStrings[_ctx->i]._y + _drawedStrings[_ctx->i].getDimy())) { CORO_INVOKE_1(setSelected, _ctx->i); break; } diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index f3aee0f183..c6107e2cf4 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -128,7 +128,7 @@ RMOptionButton::RMOptionButton(uint32 dwRes, RMPoint pt, bool bDoubleState) { _buf = new RMGfxSourceBuffer16(false); _buf->init(raw, raw.width(), raw.height()); - _rect.setRect(pt.x, pt.y, pt.x + raw.width() - 1, pt.y + raw.height() - 1); + _rect.setRect(pt._x, pt._y, pt._x + raw.width() - 1, pt._y + raw.height() - 1); _bActive = false; _bHasGfx = true; _bDoubleState = bDoubleState; @@ -215,8 +215,8 @@ RMOptionSlide::RMOptionSlide(const RMPoint &pt, int nRange, int nStartValue, int INIT_GFX16_FROMRAW(20032, _SliderSingle); // Buttons - _PushLeft = new RMOptionButton(RMRect(pt.x - 23, pt.y, pt.x - 23 + 22, pt.y + 26)); - _PushRight = new RMOptionButton(RMRect(pt.x + _nSlideSize, pt.y, pt.x + _nSlideSize + 5 + 22, pt.y + 26)); + _PushLeft = new RMOptionButton(RMRect(pt._x - 23, pt._y, pt._x - 23 + 22, pt._y + 26)); + _PushRight = new RMOptionButton(RMRect(pt._x + _nSlideSize, pt._y, pt._x + _nSlideSize + 5 + 22, pt._y + 26)); } @@ -280,8 +280,8 @@ void RMOptionSlide::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive * CORO_BEGIN_CODE(_ctx); _ctx->pos = _pos; - _ctx->pos.x += 4; - _ctx->pos.y += 4; + _ctx->pos._x += 4; + _ctx->pos._y += 4; _ctx->val = _nValue * _nStep; if (_ctx->val < 1) @@ -295,17 +295,17 @@ void RMOptionSlide::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive * } else { prim->setDst(_ctx->pos); CORO_INVOKE_2(_SliderLeft->draw, bigBuf, prim); - _ctx->pos.x += 3; + _ctx->pos._x += 3; for (_ctx->i = 1; _ctx->i < _ctx->val - 1; _ctx->i++) { prim->setDst(_ctx->pos); CORO_INVOKE_2(_SliderCenter->draw, bigBuf, prim); - _ctx->pos.x += 3; + _ctx->pos._x += 3; } prim->setDst(_ctx->pos); CORO_INVOKE_2(_SliderRight->draw, bigBuf, prim); - _ctx->pos.x += 3; + _ctx->pos._x += 3; } CORO_END_CODE; @@ -1546,7 +1546,7 @@ void RMPointer::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim // Copy the destination coordinates in the primitive prim->setDst(_pos); - if (_pos.x >= 0 && _pos.y >= 0 && _pos.x < RM_SX && _pos.y < RM_SY) { + if (_pos._x >= 0 && _pos._y >= 0 && _pos._x < RM_SX && _pos._y < RM_SY) { // Call the Draw method of the poitner prim->getDst() -= _hotspot[_ctx->n]; diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index fdc435e3e9..9d3795c760 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -509,18 +509,18 @@ void RMGfxSourceBuffer8::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimit // Clipping if (prim->haveSrc()) { - u = prim->getSrc().x1; - v = prim->getSrc().y1; + u = prim->getSrc()._x1; + v = prim->getSrc()._y1; width = prim->getSrc().width(); height = prim->getSrc().height(); } - if (!clip2D(dst.x1, dst.y1, u, v, width, height, prim->haveSrc(), &bigBuf)) + if (!clip2D(dst._x1, dst._y1, u, v, width, height, prim->haveSrc(), &bigBuf)) return; // Starting offset into the buffer - buf += dst.y1 * bufx + dst.x1; + buf += dst._y1 * bufx + dst._x1; // Normal step if (_bTrasp0) { @@ -617,18 +617,18 @@ void RMGfxSourceBuffer8AB::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrim // Clipping if (prim->haveSrc()) { - u = prim->getSrc().x1; - v = prim->getSrc().y1; + u = prim->getSrc()._x1; + v = prim->getSrc()._y1; width = prim->getSrc().width(); height = prim->getSrc().height(); } - if (!clip2D(dst.x1, dst.y1, u, v, width, height, prim->haveSrc(), &bigBuf)) + if (!clip2D(dst._x1, dst._y1, u, v, width, height, prim->haveSrc(), &bigBuf)) return; // Starting offset into the buffer - buf += dst.y1 * bufx + dst.x1; + buf += dst._y1 * bufx + dst._x1; // Passaggio normale if (_bTrasp0) { @@ -813,8 +813,8 @@ void RMGfxSourceBuffer8RLE::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPri int x1, y1, u, v, width, height; // Clipping - x1 = prim->getDst().x1; - y1 = prim->getDst().y1; + x1 = prim->getDst()._x1; + y1 = prim->getDst()._y1; if (!clip2D(x1, y1, u, v, width, height, false, &bigBuf)) return; @@ -834,7 +834,7 @@ void RMGfxSourceBuffer8RLE::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPri // Clipping u = _dimx - (width + u); - x1 = (prim->getDst().x1 + _dimx - 1) - u; + x1 = (prim->getDst()._x1 + _dimx - 1) - u; for (y = 0; y < height; y++) { // Decompressione @@ -1611,8 +1611,8 @@ void RMGfxSourceBuffer8AA::drawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri int step; // Clip the sprite - x1 = prim->getDst().x1; - y1 = prim->getDst().y1; + x1 = prim->getDst()._x1; + y1 = prim->getDst()._y1; if (!clip2D(x1, y1, u, v, width, height, false, &bigBuf)) return; @@ -1625,7 +1625,7 @@ void RMGfxSourceBuffer8AA::drawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri if (prim->isFlipped()) { u = _dimx - (width + u); - x1 = (prim->getDst().x1 + _dimx - 1) - u; + x1 = (prim->getDst()._x1 + _dimx - 1) - u; } // width = _dimx; // x1 = prim->Dst().x1; @@ -1837,15 +1837,15 @@ void RMGfxSourceBuffer16::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimi y1 = 0; if (prim->haveSrc()) { - u = prim->getSrc().x1; - v = prim->getSrc().y1; + u = prim->getSrc()._x1; + v = prim->getSrc()._y1; dimx = prim->getSrc().width(); dimy = prim->getSrc().height(); } if (prim->haveDst()) { - x1 = prim->getDst().x1; - y1 = prim->getDst().y1; + x1 = prim->getDst()._x1; + y1 = prim->getDst()._y1; } if (!clip2D(x1, y1, u, v, dimx, dimy, true, &bigBuf)) @@ -1929,7 +1929,7 @@ void RMGfxBox::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) // It takes the destination rectangle rcDst = prim->getDst(); - buf += rcDst.y1 * bigBuf.getDimx() + rcDst.x1; + buf += rcDst._y1 * bigBuf.getDimx() + rcDst._x1; // Loop through the pixels for (j = 0; j < rcDst.height(); j++) { diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index e8f32edac7..8daf49c4a5 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -208,7 +208,7 @@ void RMGfxEngine::doFrame(CORO_PARAM, bool bDrawLocation) { // ************ if (_bGUIOption) { if (!_tony.inAction() && _bInput) { - if ((_input.mouseLeftClicked() && _input.mousePos().x < 3 && _input.mousePos().y < 3)) { + if ((_input.mouseLeftClicked() && _input.mousePos()._x < 3 && _input.mousePos()._y < 3)) { CORO_INVOKE_1(openOptionScreen, 0); goto SKIPCLICKSINISTRO; } else if (_input.getAsyncKeyState(Common::KEYCODE_ESCAPE)) @@ -297,7 +297,7 @@ SKIPCLICKSINISTRO: // Update screen scrolling to keep Tony in focus if (_tony.mustUpdateScrolling() && _bLocationLoaded) { RMPoint showThis = _tony.position(); - showThis.y -= 60; + showThis._y -= 60; _loc.updateScrolling(showThis); } @@ -379,14 +379,14 @@ void RMGfxEngine::itemIrq(uint32 dwItem, int nPattern, int nStatus) { void RMGfxEngine::initForNewLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { - if (start.x == -1 || start.y == -1) { - start.x = ptTonyStart.x - RM_SX / 2; - start.y = ptTonyStart.y - RM_SY / 2; + if (start._x == -1 || start._y == -1) { + start._x = ptTonyStart._x - RM_SX / 2; + start._y = ptTonyStart._y - RM_SY / 2; } _loc.setScrollPosition(start); - if (ptTonyStart.x == 0 && ptTonyStart.y == 0) { + if (ptTonyStart._x == 0 && ptTonyStart._y == 0) { } else { _tony.setPosition(ptTonyStart, nLoc); _tony.setScrollPosition(start); @@ -616,8 +616,8 @@ void RMGfxEngine::saveState(const Common::String &fn, byte *curThumb, const Comm f->writeByte(i); f->write(name.c_str(), i); f->writeUint32LE(_nCurLoc); - f->writeUint32LE(tp.x); - f->writeUint32LE(tp.y); + f->writeUint32LE(tp._x); + f->writeUint32LE(tp._y); f->writeUint32LE(size); f->write(state, size); @@ -738,8 +738,8 @@ void RMGfxEngine::loadState(CORO_PARAM, const Common::String &fn) { } _ctx->loc = _ctx->f->readUint32LE(); - _ctx->tp.x = _ctx->f->readUint32LE(); - _ctx->tp.y = _ctx->f->readUint32LE(); + _ctx->tp._x = _ctx->f->readUint32LE(); + _ctx->tp._y = _ctx->f->readUint32LE(); _ctx->size = _ctx->f->readUint32LE(); if ((_ctx->ver >= 0x5) && (_ctx->ver <= 7)) { diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index cfa49181e1..de8b21748e 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -66,9 +66,9 @@ RMInventory::~RMInventory() { bool RMInventory::checkPointInside(const RMPoint &pt) { if (!GLOBALS._bCfgInvUp) - return pt.y > RM_SY - 70; + return pt._y > RM_SY - 70; else - return pt.y < 70; + return pt._y < 70; } @@ -313,7 +313,7 @@ bool RMInventory::miniActive(void) { bool RMInventory::haveFocus(const RMPoint &mpos) { // When we combine, have the focus only if we are on an arrow (to scroll) - if (_state == OPENED && _bCombining && checkPointInside(mpos) && (mpos.x < 64 || mpos.x > RM_SX - 64)) + if (_state == OPENED && _bCombining && checkPointInside(mpos) && (mpos._x < 64 || mpos._x > RM_SX - 64)) return true; // If the inventory is open, focus we we go over it @@ -335,7 +335,7 @@ bool RMInventory::leftClick(const RMPoint &mpos, int &nCombineObj) { int n; // The left click picks an item from your inventory to use it with the background - n = mpos.x / 64; + n = mpos._x / 64; if (_state == OPENED) { if (n > 0 && n < RM_SX / 64 - 1 && _inv[n - 1 + _curPos] != 0) { @@ -401,7 +401,7 @@ void RMInventory::rightClick(const RMPoint &mpos) { if (_state == OPENED && !_bCombining) { // Open the context interface - n = mpos.x / 64; + n = mpos._x / 64; if (n > 0 && n < RM_SX / 64 - 1 && _inv[n - 1 + _curPos] != 0) { _state = SELECTING; @@ -493,7 +493,7 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo bNeedRedraw = true; if ((_state == CLOSING || _state == OPENING || _state == OPENED) && checkPointInside(mpos)) { - if (mpos.x > RM_SX - 64) { + if (mpos._x > RM_SX - 64) { if (_curPos + 8 < _nInv && !_bBlinkingRight) { _items[28]._icon.setPattern(3); _bBlinkingRight = true; @@ -505,7 +505,7 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo bNeedRedraw = true; } - if (mpos.x < 64) { + if (mpos._x < 64) { if (_curPos > 0 && !_bBlinkingLeft) { _items[29]._icon.setPattern(3); _bBlinkingLeft = true; @@ -540,7 +540,7 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo } if (!GLOBALS._bCfgInvUp) { - if ((_state == CLOSED) && (mpos.y > RM_SY - 10 || GLOBALS._bCfgInvLocked) && bCanOpen) { + if ((_state == CLOSED) && (mpos._y > RM_SY - 10 || GLOBALS._bCfgInvLocked) && bCanOpen) { if (!GLOBALS._bCfgInvNoScroll) { _state = OPENING; _curPutY = RM_SY - 1; @@ -550,7 +550,7 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo _curPutY = RM_SY - 68; } } else if (_state == OPENED) { - if ((mpos.y < RM_SY - 70 && !GLOBALS._bCfgInvLocked) || !bCanOpen) { + if ((mpos._y < RM_SY - 70 && !GLOBALS._bCfgInvLocked) || !bCanOpen) { if (!GLOBALS._bCfgInvNoScroll) { _state = CLOSING; _curPutY = RM_SY - 68; @@ -580,7 +580,7 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo _state = CLOSED; } } else { - if ((_state == CLOSED) && (mpos.y < 10 || GLOBALS._bCfgInvLocked) && bCanOpen) { + if ((_state == CLOSED) && (mpos._y < 10 || GLOBALS._bCfgInvLocked) && bCanOpen) { if (!GLOBALS._bCfgInvNoScroll) { _state = OPENING; _curPutY = - 68; @@ -590,7 +590,7 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo _curPutY = 0; } } else if (_state == OPENED) { - if ((mpos.y > 70 && !GLOBALS._bCfgInvLocked) || !bCanOpen) { + if ((mpos._y > 70 && !GLOBALS._bCfgInvLocked) || !bCanOpen) { if (!GLOBALS._bCfgInvNoScroll) { _state = CLOSING; _curPutY = -2; @@ -630,20 +630,20 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo starty = 70; // Make sure it is on one of the verbs - if (mpos.y > starty && mpos.y < starty + 45) { - if (mpos.x > startx && mpos.x < startx + 40) { + if (mpos._y > starty && mpos._y < starty + 45) { + if (mpos._x > startx && mpos._x < startx + 40) { if (_miniAction != 1) { _miniInterface.setPattern(2); _miniAction = 1; _vm->playUtilSFX(1); } - } else if (mpos.x >= startx + 40 && mpos.x < startx + 80) { + } else if (mpos._x >= startx + 40 && mpos._x < startx + 80) { if (_miniAction != 2) { _miniInterface.setPattern(3); _miniAction = 2; _vm->playUtilSFX(1); } - } else if (mpos.x >= startx + 80 && mpos.x < startx + 108) { + } else if (mpos._x >= startx + 80 && mpos._x < startx + 108) { if (_miniAction != 3) { _miniInterface.setPattern(4); _miniAction = 3; @@ -680,7 +680,7 @@ RMItem *RMInventory::whichItemIsIn(const RMPoint &mpt) { if (_state == OPENED) { if (checkPointInside(mpt)) { - n = mpt.x / 64; + n = mpt._x / 64; if (n > 0 && n < RM_SX / 64 - 1 && _inv[n - 1 + _curPos] != 0 && (!_bCombining || _inv[n - 1 + _curPos] != _nCombine)) return &_items[_inv[n - 1 + _curPos]]._icon; } @@ -830,14 +830,14 @@ void RMInterface::clicked(const RMPoint &mousepos) { _lastHotZone = -1; // Keep it inside the screen - if (_openStart.x < 0) - _openStart.x = 0; - if (_openStart.y < 0) - _openStart.y = 0; - if (_openStart.x + _dimx > RM_SX) - _openStart.x = RM_SX - _dimx; - if (_openStart.y + _dimy > RM_SY) - _openStart.y = RM_SY - _dimy; + if (_openStart._x < 0) + _openStart._x = 0; + if (_openStart._y < 0) + _openStart._y = 0; + if (_openStart._x + _dimx > RM_SX) + _openStart._x = RM_SX - _dimx; + if (_openStart._y + _dimy > RM_SY) + _openStart._y = RM_SY - _dimy; // Play the sound effect _vm->playUtilSFX(0); diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 81fb0d307f..9c032fe6be 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -183,23 +183,23 @@ int RMPattern::init(RMSfx *sfx, bool bPlayP0, byte *bFlag) { if (_slots[i]._type == SOUND) { if (i == 0) { if (sfx[_slots[i]._data]._name[0] == '_') { - sfx[_slots[i]._data].setVolume(_slots[i].pos().x); + sfx[_slots[i]._data].setVolume(_slots[i].pos()._x); sfx[_slots[i]._data].play(true); } else { - sfx[_slots[i]._data].setVolume(_slots[i].pos().x); + sfx[_slots[i]._data].setVolume(_slots[i].pos()._x); sfx[_slots[i]._data].play(); } } else if (_speed == 0) { if (bPlayP0) { - sfx[_slots[i]._data].setVolume(_slots[i].pos().x); + sfx[_slots[i]._data].setVolume(_slots[i].pos()._x); sfx[_slots[i]._data].play(); } else if (sfx[_slots[i]._data]._name[0] == '_') { - sfx[_slots[i]._data].setVolume(_slots[i].pos().x); + sfx[_slots[i]._data].setVolume(_slots[i].pos()._x); sfx[_slots[i]._data].play(true); } } else { if (_bLoop && sfx[_slots[i]._data]._name[0] == '_') { - sfx[_slots[i]._data].setVolume(_slots[i].pos().x); + sfx[_slots[i]._data].setVolume(_slots[i].pos()._x); sfx[_slots[i]._data].play(true); } } @@ -251,7 +251,7 @@ int RMPattern::update(uint32 hEndPattern, byte &bFlag, RMSfx *sfx) { case SOUND: if (sfx != NULL) { - sfx[_slots[_nCurSlot]._data].setVolume(_slots[_nCurSlot].pos().x); + sfx[_slots[_nCurSlot]._data].setVolume(_slots[_nCurSlot].pos()._x); if (sfx[_slots[_nCurSlot]._data]._name[0] != '_') sfx[_slots[_nCurSlot]._data].play(false); @@ -1054,8 +1054,8 @@ void RMCharacter::goTo(CORO_PARAM, RMPoint destcoord, bool bReversed) { _status = WALK; _lineStart = _pos; _lineEnd = destcoord; - _dx = _lineStart.x - _lineEnd.x; - _dy = _lineStart.y - _lineEnd.y; + _dx = _lineStart._x - _lineEnd._x; + _dy = _lineStart._y - _lineEnd._y; _fx = _dx; _fy = _dy; _dx = ABS(_dx); @@ -1071,7 +1071,7 @@ void RMCharacter::goTo(CORO_PARAM, RMPoint destcoord, bool bReversed) { if (_dx > _dy) { _slope = _fy / _fx; - if (_lineEnd.x < _lineStart.x) + if (_lineEnd._x < _lineStart._x) _walkSpeed = -_walkSpeed; _walkStatus = 1; @@ -1086,7 +1086,7 @@ void RMCharacter::goTo(CORO_PARAM, RMPoint destcoord, bool bReversed) { } } else { _slope = _fx / _fy; - if (_lineEnd.y < _lineStart.y) + if (_lineEnd._y < _lineStart._y) _walkSpeed = -_walkSpeed; _walkStatus = 0; @@ -1115,14 +1115,14 @@ RMPoint RMCharacter::searching(char UP, char DOWN, char RIGHT, char LEFT, RMPoin if (UP) { nuovo = punto; passi = 0; - while ((inWhichBox(nuovo) == -1) && (nuovo.y >= 0)) { - nuovo.y--; + while ((inWhichBox(nuovo) == -1) && (nuovo._y >= 0)) { + nuovo._y--; passi++; } if ((inWhichBox(nuovo) != -1) && (passi < minimo) && findPath(inWhichBox(_pos), inWhichBox(nuovo))) { minimo = passi; - nuovo.y--; // to avoid error? + nuovo._y--; // to avoid error? trovato = nuovo; } } @@ -1130,14 +1130,14 @@ RMPoint RMCharacter::searching(char UP, char DOWN, char RIGHT, char LEFT, RMPoin if (DOWN) { nuovo = punto; passi = 0; - while ((inWhichBox(nuovo) == -1) && (nuovo.y < 480)) { - nuovo.y++; + while ((inWhichBox(nuovo) == -1) && (nuovo._y < 480)) { + nuovo._y++; passi++; } if ((inWhichBox(nuovo) != -1) && (passi < minimo) && findPath(inWhichBox(_pos), inWhichBox(nuovo))) { minimo = passi; - nuovo.y++; // to avoid error? + nuovo._y++; // to avoid error? trovato = nuovo; } } @@ -1145,14 +1145,14 @@ RMPoint RMCharacter::searching(char UP, char DOWN, char RIGHT, char LEFT, RMPoin if (RIGHT) { nuovo = punto; passi = 0; - while ((inWhichBox(nuovo) == -1) && (nuovo.x < 640)) { - nuovo.x++; + while ((inWhichBox(nuovo) == -1) && (nuovo._x < 640)) { + nuovo._x++; passi++; } if ((inWhichBox(nuovo) != -1) && (passi < minimo) && findPath(inWhichBox(_pos), inWhichBox(nuovo))) { minimo = passi; - nuovo.x++; // to avoid error? + nuovo._x++; // to avoid error? trovato = nuovo; } } @@ -1160,14 +1160,14 @@ RMPoint RMCharacter::searching(char UP, char DOWN, char RIGHT, char LEFT, RMPoin if (LEFT) { nuovo = punto; passi = 0; - while ((inWhichBox(nuovo) == -1) && (nuovo.x >= 0)) { - nuovo.x--; + while ((inWhichBox(nuovo) == -1) && (nuovo._x >= 0)) { + nuovo._x--; passi++; } if ((inWhichBox(nuovo) != -1) && (passi < minimo) && findPath(inWhichBox(_pos), inWhichBox(nuovo))) { minimo = passi; - nuovo.x--; // to avoid error? + nuovo._x--; // to avoid error? trovato = nuovo; } } @@ -1190,8 +1190,8 @@ short RMCharacter::scanLine(const RMPoint &punto) { Lstart = _pos; Lend = punto; - Ldx = Lstart.x - Lend.x; - Ldy = Lstart.y - Lend.y; + Ldx = Lstart._x - Lend._x; + Ldy = Lstart._y - Lend._y; Lfx = Ldx; Lfy = Ldy; Ldx = ABS(Ldx); @@ -1201,11 +1201,11 @@ short RMCharacter::scanLine(const RMPoint &punto) { if (Ldx > Ldy) { Lslope = Lfy / Lfx; - if (Lend.x < Lstart.x) Lspeed = -Lspeed; + if (Lend._x < Lstart._x) Lspeed = -Lspeed; Lstatus = 1; } else { Lslope = Lfx / Lfy; - if (Lend.y < Lstart.y) Lspeed = - Lspeed; + if (Lend._y < Lstart._y) Lspeed = - Lspeed; Lstatus = 0; } @@ -1220,10 +1220,11 @@ short RMCharacter::scanLine(const RMPoint &punto) { Ldx = (int)(Lslope * Ldy); } - Lscan.x = Lstart.x + Ldx; - Lscan.y = Lstart.y + Ldy; + Lscan._x = Lstart._x + Ldx; + Lscan._y = Lstart._y + Ldy; - if ((ABS(Lscan.x - Lend.x) <= 1) && (ABS(Lscan.y - Lend.y) <= 1)) return 1; + if ((ABS(Lscan._x - Lend._x) <= 1) && (ABS(Lscan._y - Lend._y) <= 1)) + return 1; } return 0; @@ -1240,8 +1241,8 @@ RMPoint RMCharacter::invScanLine(const RMPoint &punto) { Lstart = punto; // Exchange! Lend = _pos; // :-) - Ldx = Lstart.x - Lend.x; - Ldy = Lstart.y - Lend.y; + Ldx = Lstart._x - Lend._x; + Ldy = Lstart._y - Lend._y; Lfx = Ldx; Lfy = Ldy; Ldx = ABS(Ldx); @@ -1251,11 +1252,13 @@ RMPoint RMCharacter::invScanLine(const RMPoint &punto) { if (Ldx > Ldy) { Lslope = Lfy / Lfx; - if (Lend.x < Lstart.x) Lspeed = -Lspeed; + if (Lend._x < Lstart._x) + Lspeed = -Lspeed; Lstatus = 1; } else { Lslope = Lfx / Lfy; - if (Lend.y < Lstart.y) Lspeed = -Lspeed; + if (Lend._y < Lstart._y) + Lspeed = -Lspeed; Lstatus = 0; } Lscan = Lstart; @@ -1278,11 +1281,11 @@ RMPoint RMCharacter::invScanLine(const RMPoint &punto) { Ldy = Lspeed * Lcount; Ldx = (int)(Lslope * Ldy); } - Lscan.x = Lstart.x + Ldx; - Lscan.y = Lstart.y + Ldy; + Lscan._x = Lstart._x + Ldx; + Lscan._y = Lstart._y + Ldy; // WORKAROUND: Handles cases where the points never fall inside a bounding box - if (Lscan.x < -100 || Lscan.y < -100 || Lscan.x >= 1000 || Lscan.y >= 1000) + if (Lscan._x < -100 || Lscan._y < -100 || Lscan._x >= 1000 || Lscan._y >= 1000) return punto; } } @@ -1301,13 +1304,13 @@ RMPoint RMCharacter::nearestHotSpot(int sourcebox, int destbox) { for (cc = 0; cc < cur->_boxes[sourcebox]._numHotspot; cc++) if ((cur->_boxes[sourcebox]._hotspot[cc]._destination) == destbox) { - x = ABS(cur->_boxes[sourcebox]._hotspot[cc]._hotx - _pos.x); - y = ABS(cur->_boxes[sourcebox]._hotspot[cc]._hoty - _pos.y); + x = ABS(cur->_boxes[sourcebox]._hotspot[cc]._hotx - _pos._x); + y = ABS(cur->_boxes[sourcebox]._hotspot[cc]._hoty - _pos._y); if ((x * x + y * y) < distanzaminima) { distanzaminima = x * x + y * y; - puntocaldo.x = cur->_boxes[sourcebox]._hotspot[cc]._hotx; - puntocaldo.y = cur->_boxes[sourcebox]._hotspot[cc]._hoty; + puntocaldo._x = cur->_boxes[sourcebox]._hotspot[cc]._hotx; + puntocaldo._y = cur->_boxes[sourcebox]._hotspot[cc]._hoty; } } @@ -1391,11 +1394,11 @@ void RMCharacter::doFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc) { if (_walkStatus == 1) { _dx = _walkSpeed * _walkCount; _dy = (int)(_slope * _dx); - _pos.x = _lineStart.x + _dx; - _pos.y = _lineStart.y + _dy; + _pos._x = _lineStart._x + _dx; + _pos._y = _lineStart._y + _dy; // Right - if (((_walkSpeed > 0) && (_pos.x > _lineEnd.x)) || ((_walkSpeed < 0) && (_pos.x < _lineEnd.x))) { + if (((_walkSpeed > 0) && (_pos._x > _lineEnd._x)) || ((_walkSpeed < 0) && (_pos._x < _lineEnd._x))) { _pos = _lineEnd; _status = STAND; _ctx->bEndNow = true; @@ -1406,11 +1409,11 @@ void RMCharacter::doFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc) { if (_walkStatus == 0) { _dy = _walkSpeed * _walkCount; _dx = (int)(_slope * _dy); - _pos.x = _lineStart.x + _dx; - _pos.y = _lineStart.y + _dy; + _pos._x = _lineStart._x + _dx; + _pos._y = _lineStart._y + _dy; // Down - if (((_walkSpeed > 0) && (_pos.y > _lineEnd.y)) || ((_walkSpeed < 0) && (_pos.y < _lineEnd.y))) { + if (((_walkSpeed > 0) && (_pos._y > _lineEnd._y)) || ((_walkSpeed < 0) && (_pos._y < _lineEnd._y))) { _pos = _lineEnd; _status = STAND; _ctx->bEndNow = true; @@ -1419,8 +1422,8 @@ void RMCharacter::doFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc) { // Check if the character came out of the BOX in error, in which case he returns immediately if (inWhichBox(_pos) == -1) { - _pos.x = _lineStart.x + _olddx; - _pos.y = _lineStart.y + _olddy; + _pos._x = _lineStart._x + _olddx; + _pos._y = _lineStart._y + _olddy; } // If we have just moved to a temporary location, and is over the shortest path, we stop permanently @@ -1545,7 +1548,7 @@ void RMCharacter::move(CORO_PARAM, RMPoint pt, bool *result) { _bMoving = true; // 0, 0 does not do anything, just stops the character - if (pt.x == 0 && pt.y == 0) { + if (pt._x == 0 && pt._y == 0) { _minPath = 0; _status = STAND; CORO_INVOKE_0(stop); @@ -1833,8 +1836,8 @@ RMBoxLoc *RMGameBoxes::getBoxes(int nLoc) { bool RMGameBoxes::isInBox(int nLoc, int nBox, const RMPoint &pt) { RMBoxLoc *cur = getBoxes(nLoc); - if ((pt.x >= cur->_boxes[nBox]._left) && (pt.x <= cur->_boxes[nBox]._right) && - (pt.y >= cur->_boxes[nBox]._top) && (pt.y <= cur->_boxes[nBox]._bottom)) + if ((pt._x >= cur->_boxes[nBox]._left) && (pt._x <= cur->_boxes[nBox]._right) && + (pt._y >= cur->_boxes[nBox]._top) && (pt._y <= cur->_boxes[nBox]._bottom)) return true; else return false; @@ -1849,8 +1852,8 @@ int RMGameBoxes::whichBox(int nLoc, const RMPoint &punto) { for (i = 0; i < cur->numbbox; i++) if (cur->_boxes[i]._attivo) - if ((punto.x >= cur->_boxes[i]._left) && (punto.x <= cur->_boxes[i]._right) && - (punto.y >= cur->_boxes[i]._top) && (punto.y <= cur->_boxes[i]._bottom)) + if ((punto._x >= cur->_boxes[i]._left) && (punto._x <= cur->_boxes[i]._right) && + (punto._y >= cur->_boxes[i]._top) && (punto._y <= cur->_boxes[i]._bottom)) return i; return -1; @@ -2025,7 +2028,7 @@ bool RMLocation::load(RMDataStream &ds) { // Skip the MPAL bailouts (64 bytes) ds >> TEMPNumLoc; - ds >> TEMPTonyStart.x >> TEMPTonyStart.y; + ds >> TEMPTonyStart._x >> TEMPTonyStart._y; ds += 64 - 4 * 3; // Skip flag associated with the background (?) @@ -2091,7 +2094,7 @@ bool RMLocation::loadLOX(RMDataStream &ds) { // Location number ds >> TEMPNumLoc; - ds >> TEMPTonyStart.x >> TEMPTonyStart.y; + ds >> TEMPTonyStart._x >> TEMPTonyStart._y; // Dimensions ds >> dimx >> dimy; @@ -2210,36 +2213,36 @@ void RMLocation::unload(void) { void RMLocation::updateScrolling(const RMPoint &ptShowThis) { RMPoint oldScroll = _curScroll; - if (_curScroll.x + 250 > ptShowThis.x) { - _curScroll.x = ptShowThis.x - 250; - } else if (_curScroll.x + RM_SX - 250 < ptShowThis.x) { - _curScroll.x = ptShowThis.x + 250 - RM_SX; - } else if (ABS(_curScroll.x + RM_SX / 2 - ptShowThis.x) > 32 && _buf->getDimx() > RM_SX) { - if (_curScroll.x + RM_SX / 2 < ptShowThis.x) - _curScroll.x++; + if (_curScroll._x + 250 > ptShowThis._x) { + _curScroll._x = ptShowThis._x - 250; + } else if (_curScroll._x + RM_SX - 250 < ptShowThis._x) { + _curScroll._x = ptShowThis._x + 250 - RM_SX; + } else if (ABS(_curScroll._x + RM_SX / 2 - ptShowThis._x) > 32 && _buf->getDimx() > RM_SX) { + if (_curScroll._x + RM_SX / 2 < ptShowThis._x) + _curScroll._x++; else - _curScroll.x--; + _curScroll._x--; } - if (_curScroll.y + 180 > ptShowThis.y) { - _curScroll.y = ptShowThis.y - 180; - } else if (_curScroll.y + RM_SY - 180 < ptShowThis.y) { - _curScroll.y = ptShowThis.y + 180 - RM_SY; - } else if (ABS(_curScroll.y + RM_SY / 2 - ptShowThis.y) > 16 && _buf->getDimy() > RM_SY) { - if (_curScroll.y + RM_SY / 2 < ptShowThis.y) - _curScroll.y++; + if (_curScroll._y + 180 > ptShowThis._y) { + _curScroll._y = ptShowThis._y - 180; + } else if (_curScroll._y + RM_SY - 180 < ptShowThis._y) { + _curScroll._y = ptShowThis._y + 180 - RM_SY; + } else if (ABS(_curScroll._y + RM_SY / 2 - ptShowThis._y) > 16 && _buf->getDimy() > RM_SY) { + if (_curScroll._y + RM_SY / 2 < ptShowThis._y) + _curScroll._y++; else - _curScroll.y--; + _curScroll._y--; } - if (_curScroll.x < 0) - _curScroll.x = 0; - if (_curScroll.y < 0) - _curScroll.y = 0; - if (_curScroll.x + RM_SX > _buf->getDimx()) - _curScroll.x = _buf->getDimx() - RM_SX; - if (_curScroll.y + RM_SY > _buf->getDimy()) - _curScroll.y = _buf->getDimy() - RM_SY; + if (_curScroll._x < 0) + _curScroll._x = 0; + if (_curScroll._y < 0) + _curScroll._y = 0; + if (_curScroll._x + RM_SX > _buf->getDimx()) + _curScroll._x = _buf->getDimx() - RM_SX; + if (_curScroll._y + RM_SY > _buf->getDimy()) + _curScroll._y = _buf->getDimy() - RM_SY; if (oldScroll != _curScroll) for (int i = 0; i < _nItems; i++) @@ -2255,14 +2258,14 @@ void RMLocation::setFixedScroll(const RMPoint &scroll) { void RMLocation::setScrollPosition(const RMPoint &scroll) { RMPoint pt = scroll; - if (pt.x < 0) - pt.x = 0; - if (pt.y < 0) - pt.y = 0; - if (pt.x + RM_SX > _buf->getDimx()) - pt.x = _buf->getDimx() - RM_SX; - if (pt.y + RM_SY > _buf->getDimy()) - pt.y = _buf->getDimy() - RM_SY; + if (pt._x < 0) + pt._x = 0; + if (pt._y < 0) + pt._y = 0; + if (pt._x + RM_SX > _buf->getDimx()) + pt._x = _buf->getDimx() - RM_SX; + if (pt._y + RM_SY > _buf->getDimy()) + pt._y = _buf->getDimy() - RM_SY; _curScroll = pt; diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index fa100d681e..6d790c0e68 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -734,31 +734,31 @@ int RMDataStream::getError() { * Constructor */ RMPoint::RMPoint() { - x = y = 0; + _x = _y = 0; } /** * Copy constructor */ RMPoint::RMPoint(const RMPoint &p) { - x = p.x; - y = p.y; + _x = p._x; + _y = p._y; } /** * Constructor with integer parameters */ RMPoint::RMPoint(int x1, int y1) { - x = x1; - y = y1; + _x = x1; + _y = y1; } /** * Copy operator */ RMPoint &RMPoint::operator=(RMPoint p) { - x = p.x; - y = p.y; + _x = p._x; + _y = p._y; return *this; } @@ -767,16 +767,16 @@ RMPoint &RMPoint::operator=(RMPoint p) { * Offsets the point by another point */ void RMPoint::offset(const RMPoint &p) { - x += p.x; - y += p.y; + _x += p._x; + _y += p._y; } /** * Offsets the point by a specified offset */ void RMPoint::offset(int xOff, int yOff) { - x += xOff; - y += yOff; + _x += xOff; + _y += yOff; } /** @@ -819,8 +819,8 @@ RMPoint &RMPoint::operator-=(RMPoint p) { RMPoint RMPoint::operator-() { RMPoint p; - p.x = -x; - p.y = -y; + p._x = -_x; + p._y = -_y; return p; } @@ -829,21 +829,21 @@ RMPoint RMPoint::operator-() { * Equality operator */ bool RMPoint::operator==(RMPoint p) { - return ((x == p.x) && (y == p.y)); + return ((_x == p._x) && (_y == p._y)); } /** * Not equal operator */ bool RMPoint::operator!=(RMPoint p) { - return ((x != p.x) || (y != p.y)); + return ((_x != p._x) || (_y != p._y)); } /** * Reads a point from a stream */ RMDataStream &operator>>(RMDataStream &ds, RMPoint &p) { - ds >> p.x >> p.y; + ds >> p._x >> p._y; return ds; } @@ -856,7 +856,7 @@ RMRect::RMRect() { } void RMRect::setEmpty(void) { - x1 = y1 = x2 = y2 = 0; + _x1 = _y1 = _x2 = _y2 = 0; } RMRect::RMRect(const RMPoint &p1, const RMPoint &p2) { @@ -872,17 +872,17 @@ RMRect::RMRect(const RMRect &rc) { } void RMRect::setRect(const RMPoint &p1, const RMPoint &p2) { - x1 = p1.x; - y1 = p1.y; - x2 = p2.x; - y2 = p2.y; + _x1 = p1._x; + _y1 = p1._y; + _x2 = p2._x; + _y2 = p2._y; } void RMRect::setRect(int X1, int Y1, int X2, int Y2) { - x1 = X1; - y1 = Y1; - x2 = X2; - y2 = Y2; + _x1 = X1; + _y1 = Y1; + _x2 = X2; + _y2 = Y2; } void RMRect::setRect(const RMRect &rc) { @@ -890,10 +890,10 @@ void RMRect::setRect(const RMRect &rc) { } void RMRect::copyRect(const RMRect &rc) { - x1 = rc.x1; - y1 = rc.y1; - x2 = rc.x2; - y2 = rc.y2; + _x1 = rc._x1; + _y1 = rc._y1; + _x2 = rc._x2; + _y2 = rc._y2; } RMPoint &RMRect::topLeft() { @@ -907,15 +907,15 @@ RMPoint &RMRect::bottomRight() { } RMPoint RMRect::center() { - return RMPoint((x2 - x1) / 2, (y2 - y1) / 2); + return RMPoint((_x2 - _x1) / 2, (_y2 - _y1) / 2); } int RMRect::width() const { - return x2 - x1; + return _x2 - _x1; } int RMRect::height() const { - return y2 - y1; + return _y2 - _y1; } int RMRect::size() const { @@ -923,7 +923,7 @@ int RMRect::size() const { } bool RMRect::isEmpty() const { - return (x1 == 0 && y1 == 0 && x2 == 0 && y2 == 0); + return (_x1 == 0 && _y1 == 0 && _x2 == 0 && _y2 == 0); } const RMRect &RMRect::operator=(const RMRect &rc) { @@ -932,17 +932,17 @@ const RMRect &RMRect::operator=(const RMRect &rc) { } void RMRect::offset(int xOff, int yOff) { - x1 += xOff; - y1 += yOff; - x2 += xOff; - y2 += yOff; + _x1 += xOff; + _y1 += yOff; + _x2 += xOff; + _y2 += yOff; } void RMRect::offset(const RMPoint &p) { - x1 += p.x; - y1 += p.y; - x2 += p.x; - y2 += p.y; + _x1 += p._x; + _y1 += p._y; + _x2 += p._x; + _y2 += p._y; } const RMRect &RMRect::operator+=(RMPoint p) { @@ -979,19 +979,19 @@ RMRect operator-(RMPoint p, const RMRect &rc) { } bool RMRect::operator==(const RMRect &rc) { - return ((x1 == rc.x1) && (y1 == rc.y1) && (x2 == rc.x2) && (y2 == rc.y2)); + return ((_x1 == rc._x1) && (_y1 == rc._y1) && (_x2 == rc._x2) && (_y2 == rc._y2)); } bool RMRect::operator!=(const RMRect &rc) { - return ((x1 != rc.x1) || (y1 != rc.y1) || (x2 != rc.x2) || (y2 != rc.y2)); + return ((_x1 != rc._x1) || (_y1 != rc._y1) || (_x2 != rc._x2) || (_y2 != rc._y2)); } void RMRect::normalizeRect(void) { - setRect(MIN(x1, x2), MIN(y1, y2), MAX(x1, x2), MAX(y1, y2)); + setRect(MIN(_x1, _x2), MIN(_y1, _y2), MAX(_x1, _x2), MAX(_y1, _y2)); } RMDataStream &operator>>(RMDataStream &ds, RMRect &rc) { - ds >> rc.x1 >> rc.y1 >> rc.x2 >> rc.y2; + ds >> rc._x1 >> rc._y1 >> rc._x2 >> rc._y2; return ds; } @@ -1032,10 +1032,10 @@ void RMResUpdate::init(const Common::String &fileName) { for (i = 0; i < _numUpd; ++i) { ResUpdInfo &info = _infos[i]; - info.dwRes = _hFile.readUint32LE(); - info.offset = _hFile.readUint32LE(); - info.size = _hFile.readUint32LE(); - info.cmpSize = _hFile.readUint32LE(); + info._dwRes = _hFile.readUint32LE(); + info._offset = _hFile.readUint32LE(); + info._size = _hFile.readUint32LE(); + info._cmpSize = _hFile.readUint32LE(); } } @@ -1046,7 +1046,7 @@ HGLOBAL RMResUpdate::queryResource(uint32 dwRes) { uint32 i; for (i = 0; i < _numUpd; ++i) - if (_infos[i].dwRes == dwRes) + if (_infos[i]._dwRes == dwRes) // Found the index break; @@ -1055,26 +1055,26 @@ HGLOBAL RMResUpdate::queryResource(uint32 dwRes) { return NULL; const ResUpdInfo &info = _infos[i]; - byte *cmpBuf = new byte[info.cmpSize]; + byte *cmpBuf = new byte[info._cmpSize]; uint32 dwRead; // Move to the correct offset and read in the compressed data - _hFile.seek(info.offset); - dwRead = _hFile.read(cmpBuf, info.cmpSize); + _hFile.seek(info._offset); + dwRead = _hFile.read(cmpBuf, info._cmpSize); - if (info.cmpSize > dwRead) { + if (info._cmpSize > dwRead) { // Error occurred reading data, so return NULL delete[] cmpBuf; return NULL; } // Allocate space for the output resource - HGLOBAL destBuf = globalAllocate(0, info.size); + HGLOBAL destBuf = globalAllocate(0, info._size); byte *lpDestBuf = (byte *)globalLock(destBuf); uint32 dwSize; // Decompress the data - lzo1x_decompress(cmpBuf, info.cmpSize, lpDestBuf, &dwSize); + lzo1x_decompress(cmpBuf, info._cmpSize, lpDestBuf, &dwSize); // Delete buffer for compressed data delete [] cmpBuf; diff --git a/engines/tony/utils.h b/engines/tony/utils.h index e649000e58..33e2db7d7e 100644 --- a/engines/tony/utils.h +++ b/engines/tony/utils.h @@ -212,7 +212,7 @@ private: */ class RMPoint { public: - int x, y; + int _x, _y; public: // Constructor @@ -225,8 +225,8 @@ public: // Set void set(int x1, int y1) { - x = x1; - y = y1; + _x = x1; + _y = y1; } // Offset @@ -251,8 +251,8 @@ public: class RMRect { public: - int x1, y1; - int x2, y2; + int _x1, _y1; + int _x2, _y2; public: RMRect(); @@ -298,7 +298,7 @@ public: // Point in rect bool ptInRect(const RMPoint &pt) { - return (pt.x >= x1 && pt.x <= x2 && pt.y >= y1 && pt.y <= y2); + return (pt._x >= _x1 && pt._x <= _x2 && pt._y >= _y1 && pt._y <= _y2); } // Extract from data stream @@ -310,10 +310,10 @@ public: */ class RMResUpdate { struct ResUpdInfo { - uint32 dwRes; - uint32 offset; - uint32 size; - uint32 cmpSize; + uint32 _dwRes; + uint32 _offset; + uint32 _size; + uint32 _cmpSize; }; uint32 _numUpd; -- cgit v1.2.3 From 94df38bfb4f2d9831e1cdc7cfe8a873e3ba13f42 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 11 Jun 2012 21:30:47 +0200 Subject: TONY: Rename variables in game.h and gfxcore.h --- engines/tony/game.cpp | 850 +++++++++++++++++++++++------------------------ engines/tony/game.h | 86 ++--- engines/tony/gfxcore.cpp | 36 +- engines/tony/gfxcore.h | 6 +- 4 files changed, 489 insertions(+), 489 deletions(-) (limited to 'engines') diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index c6107e2cf4..9fc65aa87d 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -203,47 +203,47 @@ RMOptionSlide::RMOptionSlide(const RMPoint &pt, int nRange, int nStartValue, int _nStep = 100 / _nMax; _nValue = nStartValue; - _SliderCenter = NULL; - _SliderLeft = NULL; - _SliderRight = NULL; - _SliderSingle = NULL; + _sliderCenter = NULL; + _sliderLeft = NULL; + _sliderRight = NULL; + _sliderSingle = NULL; // Sliders - INIT_GFX16_FROMRAW(20029, _SliderCenter); - INIT_GFX16_FROMRAW(20030, _SliderLeft); - INIT_GFX16_FROMRAW(20031, _SliderRight); - INIT_GFX16_FROMRAW(20032, _SliderSingle); + INIT_GFX16_FROMRAW(20029, _sliderCenter); + INIT_GFX16_FROMRAW(20030, _sliderLeft); + INIT_GFX16_FROMRAW(20031, _sliderRight); + INIT_GFX16_FROMRAW(20032, _sliderSingle); // Buttons - _PushLeft = new RMOptionButton(RMRect(pt._x - 23, pt._y, pt._x - 23 + 22, pt._y + 26)); - _PushRight = new RMOptionButton(RMRect(pt._x + _nSlideSize, pt._y, pt._x + _nSlideSize + 5 + 22, pt._y + 26)); + _pushLeft = new RMOptionButton(RMRect(pt._x - 23, pt._y, pt._x - 23 + 22, pt._y + 26)); + _pushRight = new RMOptionButton(RMRect(pt._x + _nSlideSize, pt._y, pt._x + _nSlideSize + 5 + 22, pt._y + 26)); } RMOptionSlide::~RMOptionSlide() { - delete _SliderCenter; - _SliderCenter = NULL; - delete _SliderLeft; - _SliderLeft = NULL; - delete _SliderRight; - _SliderRight = NULL; - delete _SliderSingle; - _SliderSingle = NULL; - - delete _PushLeft; - _PushLeft = NULL; - delete _PushRight; - _PushRight = NULL; + delete _sliderCenter; + _sliderCenter = NULL; + delete _sliderLeft; + _sliderLeft = NULL; + delete _sliderRight; + _sliderRight = NULL; + delete _sliderSingle; + _sliderSingle = NULL; + + delete _pushLeft; + _pushLeft = NULL; + delete _pushRight; + _pushRight = NULL; } bool RMOptionSlide::doFrame(const RMPoint &mousePos, bool bLeftClick, bool bRightClick) { bool bRefresh = false; // Do the button DoFrame's - _PushLeft->doFrame(mousePos, bLeftClick, bRightClick); - _PushRight->doFrame(mousePos, bLeftClick, bRightClick); + _pushLeft->doFrame(mousePos, bLeftClick, bRightClick); + _pushRight->doFrame(mousePos, bLeftClick, bRightClick); - if (_PushLeft->isActive()) { + if (_pushLeft->isActive()) { if (bLeftClick) { bRefresh = true; _nValue--; @@ -253,7 +253,7 @@ bool RMOptionSlide::doFrame(const RMPoint &mousePos, bool bLeftClick, bool bRigh } if (_nValue < 1) _nValue = 1; - } else if (_PushRight->isActive()) { + } else if (_pushRight->isActive()) { bRefresh = true; if (bLeftClick) { @@ -291,20 +291,20 @@ void RMOptionSlide::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive * if (_ctx->val == 1) { prim->setDst(_ctx->pos); - CORO_INVOKE_2(_SliderSingle->draw, bigBuf, prim); + CORO_INVOKE_2(_sliderSingle->draw, bigBuf, prim); } else { prim->setDst(_ctx->pos); - CORO_INVOKE_2(_SliderLeft->draw, bigBuf, prim); + CORO_INVOKE_2(_sliderLeft->draw, bigBuf, prim); _ctx->pos._x += 3; for (_ctx->i = 1; _ctx->i < _ctx->val - 1; _ctx->i++) { prim->setDst(_ctx->pos); - CORO_INVOKE_2(_SliderCenter->draw, bigBuf, prim); + CORO_INVOKE_2(_sliderCenter->draw, bigBuf, prim); _ctx->pos._x += 3; } prim->setDst(_ctx->pos); - CORO_INVOKE_2(_SliderRight->draw, bigBuf, prim); + CORO_INVOKE_2(_sliderRight->draw, bigBuf, prim); _ctx->pos._x += 3; } @@ -324,56 +324,56 @@ void RMOptionSlide::addToList(RMGfxTargetBuffer &bigBuf) { RMOptionScreen::RMOptionScreen(void) { _nState = MENUNONE; _menu = NULL; - _HideLoadSave = NULL; - _QuitConfirm = NULL; + _hideLoadSave = NULL; + _quitConfirm = NULL; _bQuitConfirm = false; create(RM_SX, RM_SY); - _ButtonExit = NULL; - _ButtonLoad = NULL; - _ButtonSave = NULL; - _ButtonGameMenu = NULL; - _ButtonGfxMenu = NULL; - _ButtonSoundMenu = NULL; - _ButtonSave_ArrowLeft = NULL; - _ButtonSave_ArrowRight = NULL; + _buttonExit = NULL; + _buttonLoad = NULL; + _buttonSave = NULL; + _buttonGameMenu = NULL; + _buttonGfxMenu = NULL; + _buttonSoundMenu = NULL; + _buttonSave_ArrowLeft = NULL; + _buttonSave_ArrowRight = NULL; _bEditSaveName = false; int i; for (i = 0; i < 6; i++) { _curThumb[i] = NULL; - _ButtonSave_States[i] = NULL; + _buttonSave_States[i] = NULL; } _statePos = 0; - _ButtonQuitYes = NULL; - _ButtonQuitNo = NULL; - _ButtonQuit = NULL; - _SaveEasy = NULL; - _SaveHard = NULL; - _ButtonGfx_Tips = NULL; - _ButtonSound_DubbingOn = NULL; - _ButtonSound_MusicOn = NULL; - _ButtonSound_SFXOn = NULL; - _SlideTonySpeed = NULL; - _SlideTextSpeed = NULL; - _ButtonGame_Lock = NULL; - _ButtonGfx_Anni30 = NULL; - _SliderSound_Music = NULL; - _ButtonGame_TimerizedText = NULL; - _ButtonGfx_AntiAlias = NULL; - _SliderSound_SFX = NULL; - _ButtonGame_Scrolling = NULL; - _ButtonGfx_Sottotitoli = NULL; - _SliderSound_Dubbing = NULL; - _ButtonGame_InterUp = NULL; - _ButtonGfx_Trans = NULL; - - _FadeStep = 0; - _FadeY = 0; - _FadeTime = 0; + _buttonQuitYes = NULL; + _buttonQuitNo = NULL; + _buttonQuit = NULL; + _saveEasy = NULL; + _saveHard = NULL; + _buttonGfx_Tips = NULL; + _buttonSound_DubbingOn = NULL; + _buttonSound_MusicOn = NULL; + _buttonSound_SFXOn = NULL; + _slideTonySpeed = NULL; + _slideTextSpeed = NULL; + _buttonGame_Lock = NULL; + _buttonGfx_Anni30 = NULL; + _sliderSound_Music = NULL; + _buttonGame_TimerizedText = NULL; + _buttonGfx_AntiAlias = NULL; + _sliderSound_SFX = NULL; + _buttonGame_Scrolling = NULL; + _buttonGfx_Sottotitoli = NULL; + _sliderSound_Dubbing = NULL; + _buttonGame_InterUp = NULL; + _buttonGfx_Trans = NULL; + + _fadeStep = 0; + _fadeY = 0; + _fadeTime = 0; _nEditPos = 0; _nLastState = MENUGAME; } @@ -397,42 +397,42 @@ void RMOptionScreen::refreshAll(CORO_PARAM) { addPrim(new RMGfxPrimitive(_menu)); if (_bNoLoadSave) - addPrim(new RMGfxPrimitive(_HideLoadSave, RMPoint(0, 401))); + addPrim(new RMGfxPrimitive(_hideLoadSave, RMPoint(0, 401))); if (_bQuitConfirm) { - addPrim(new RMGfxPrimitive(_QuitConfirm, RMPoint(270, 200))); - _ButtonQuitYes->addToList(*this); - _ButtonQuitNo->addToList(*this); + addPrim(new RMGfxPrimitive(_quitConfirm, RMPoint(270, 200))); + _buttonQuitYes->addToList(*this); + _buttonQuitNo->addToList(*this); } - _ButtonExit->addToList(*this); + _buttonExit->addToList(*this); if (_nState == MENUGAME || _nState == MENUGFX || _nState == MENUSOUND) { - _ButtonQuit->addToList(*this); - _ButtonLoad->addToList(*this); - _ButtonSave->addToList(*this); + _buttonQuit->addToList(*this); + _buttonLoad->addToList(*this); + _buttonSave->addToList(*this); } if (_nState == MENUGAME) { - _ButtonGame_Lock->addToList(*this); - _ButtonGame_TimerizedText->addToList(*this); - _ButtonGame_Scrolling->addToList(*this); - _ButtonGame_InterUp->addToList(*this); - _SlideTextSpeed->addToList(*this); - _SlideTonySpeed->addToList(*this); + _buttonGame_Lock->addToList(*this); + _buttonGame_TimerizedText->addToList(*this); + _buttonGame_Scrolling->addToList(*this); + _buttonGame_InterUp->addToList(*this); + _slideTextSpeed->addToList(*this); + _slideTonySpeed->addToList(*this); } else if (_nState == MENUGFX) { - _ButtonGfx_Anni30->addToList(*this); - _ButtonGfx_AntiAlias->addToList(*this); - _ButtonGfx_Sottotitoli->addToList(*this); - _ButtonGfx_Trans->addToList(*this); - _ButtonGfx_Tips->addToList(*this); + _buttonGfx_Anni30->addToList(*this); + _buttonGfx_AntiAlias->addToList(*this); + _buttonGfx_Sottotitoli->addToList(*this); + _buttonGfx_Trans->addToList(*this); + _buttonGfx_Tips->addToList(*this); } else if (_nState == MENUSOUND) { - _SliderSound_Dubbing->addToList(*this); - _SliderSound_Music->addToList(*this); - _SliderSound_SFX->addToList(*this); - _ButtonSound_DubbingOn->addToList(*this); - _ButtonSound_MusicOn->addToList(*this); - _ButtonSound_SFXOn->addToList(*this); + _sliderSound_Dubbing->addToList(*this); + _sliderSound_Music->addToList(*this); + _sliderSound_SFX->addToList(*this); + _buttonSound_DubbingOn->addToList(*this); + _buttonSound_MusicOn->addToList(*this); + _buttonSound_SFXOn->addToList(*this); } _ctx->thumb = NULL; @@ -452,29 +452,29 @@ void RMOptionScreen::refreshAll(CORO_PARAM) { addPrim(new RMGfxPrimitive(_ctx->title, RMPoint(320, 10))); if (_curThumbDiff[0] == 0) - addPrim(new RMGfxPrimitive(_SaveHard, RMPoint(48, 57))); + addPrim(new RMGfxPrimitive(_saveHard, RMPoint(48, 57))); else if (_curThumbDiff[0] == 1) - addPrim(new RMGfxPrimitive(_SaveEasy, RMPoint(48, 57))); + addPrim(new RMGfxPrimitive(_saveEasy, RMPoint(48, 57))); if (_curThumbDiff[1] == 0) - addPrim(new RMGfxPrimitive(_SaveHard, RMPoint(240, 57))); + addPrim(new RMGfxPrimitive(_saveHard, RMPoint(240, 57))); else if (_curThumbDiff[1] == 1) - addPrim(new RMGfxPrimitive(_SaveEasy, RMPoint(240, 57))); + addPrim(new RMGfxPrimitive(_saveEasy, RMPoint(240, 57))); if (_curThumbDiff[2] == 0) - addPrim(new RMGfxPrimitive(_SaveHard, RMPoint(432, 57))); + addPrim(new RMGfxPrimitive(_saveHard, RMPoint(432, 57))); else if (_curThumbDiff[2] == 1) - addPrim(new RMGfxPrimitive(_SaveEasy, RMPoint(432, 57))); + addPrim(new RMGfxPrimitive(_saveEasy, RMPoint(432, 57))); if (_curThumbDiff[3] == 0) - addPrim(new RMGfxPrimitive(_SaveHard, RMPoint(48, 239))); + addPrim(new RMGfxPrimitive(_saveHard, RMPoint(48, 239))); else if (_curThumbDiff[3] == 1) - addPrim(new RMGfxPrimitive(_SaveEasy, RMPoint(48, 239))); + addPrim(new RMGfxPrimitive(_saveEasy, RMPoint(48, 239))); if (_curThumbDiff[4] == 0) - addPrim(new RMGfxPrimitive(_SaveHard, RMPoint(240, 239))); + addPrim(new RMGfxPrimitive(_saveHard, RMPoint(240, 239))); else if (_curThumbDiff[4] == 1) - addPrim(new RMGfxPrimitive(_SaveEasy, RMPoint(240, 239))); + addPrim(new RMGfxPrimitive(_saveEasy, RMPoint(240, 239))); if (_curThumbDiff[5] == 0) - addPrim(new RMGfxPrimitive(_SaveHard, RMPoint(432, 239))); + addPrim(new RMGfxPrimitive(_saveHard, RMPoint(432, 239))); else if (_curThumbDiff[5] == 1) - addPrim(new RMGfxPrimitive(_SaveEasy, RMPoint(432, 239))); + addPrim(new RMGfxPrimitive(_saveEasy, RMPoint(432, 239))); if (_curThumb[0] && !(_bEditSaveName && _nEditPos == 0)) addPrim(new RMGfxPrimitive(_curThumb[0], RMPoint(48, 57))); @@ -511,7 +511,7 @@ void RMOptionScreen::refreshAll(CORO_PARAM) { RMString s; if (_bEditSaveName && _nEditPos == _ctx->i) - s.format("%02d)%s*", _statePos + _ctx->i, _EditName); + s.format("%02d)%s*", _statePos + _ctx->i, _editName); else { if (_statePos == 0 && _ctx->i == 0) s.format("Autosave"); @@ -531,8 +531,8 @@ void RMOptionScreen::refreshAll(CORO_PARAM) { addPrim(new RMGfxPrimitive(_ctx->num[4], RMPoint(247 - 3, 362 + 14))); addPrim(new RMGfxPrimitive(_ctx->num[5], RMPoint(439 - 3, 362 + 14))); - _ButtonSave_ArrowLeft->addToList(*this); - _ButtonSave_ArrowRight->addToList(*this); + _buttonSave_ArrowLeft->addToList(*this); + _buttonSave_ArrowRight->addToList(*this); } CORO_INVOKE_0(drawOT); @@ -593,137 +593,137 @@ void RMOptionScreen::initState(CORO_PARAM) { if (_nState == MENULOAD || _nState == MENUSAVE) { if (_bAlterGfx) { - assert(_ButtonExit == NULL); - _ButtonExit = new RMOptionButton(20025, RMPoint(561, 406)); + assert(_buttonExit == NULL); + _buttonExit = new RMOptionButton(20025, RMPoint(561, 406)); } else { - assert(_ButtonExit == NULL); - _ButtonExit = new RMOptionButton(20012, RMPoint(560, 404)); + assert(_buttonExit == NULL); + _buttonExit = new RMOptionButton(20012, RMPoint(560, 404)); } - INIT_GFX8_FROMRAW(_ctx->raw, 20036, _SaveEasy); - INIT_GFX8_FROMRAW(_ctx->raw, 20037, _SaveHard); + INIT_GFX8_FROMRAW(_ctx->raw, 20036, _saveEasy); + INIT_GFX8_FROMRAW(_ctx->raw, 20037, _saveHard); refreshThumbnails(); - assert(_ButtonSave_States[0] == NULL); - _ButtonSave_States[0] = new RMOptionButton(RMRect(48, 57, 48 + 160, 57 + 120)); - assert(_ButtonSave_States[1] == NULL); - _ButtonSave_States[1] = new RMOptionButton(RMRect(240, 57, 240 + 160, 57 + 120)); - assert(_ButtonSave_States[2] == NULL); - _ButtonSave_States[2] = new RMOptionButton(RMRect(432, 57, 432 + 160, 57 + 120)); - assert(_ButtonSave_States[3] == NULL); - _ButtonSave_States[3] = new RMOptionButton(RMRect(48, 239, 48 + 160, 239 + 120)); - assert(_ButtonSave_States[4] == NULL); - _ButtonSave_States[4] = new RMOptionButton(RMRect(240, 239, 240 + 160, 239 + 120)); - assert(_ButtonSave_States[5] == NULL); - _ButtonSave_States[5] = new RMOptionButton(RMRect(432, 239, 432 + 160, 239 + 120)); + assert(_buttonSave_States[0] == NULL); + _buttonSave_States[0] = new RMOptionButton(RMRect(48, 57, 48 + 160, 57 + 120)); + assert(_buttonSave_States[1] == NULL); + _buttonSave_States[1] = new RMOptionButton(RMRect(240, 57, 240 + 160, 57 + 120)); + assert(_buttonSave_States[2] == NULL); + _buttonSave_States[2] = new RMOptionButton(RMRect(432, 57, 432 + 160, 57 + 120)); + assert(_buttonSave_States[3] == NULL); + _buttonSave_States[3] = new RMOptionButton(RMRect(48, 239, 48 + 160, 239 + 120)); + assert(_buttonSave_States[4] == NULL); + _buttonSave_States[4] = new RMOptionButton(RMRect(240, 239, 240 + 160, 239 + 120)); + assert(_buttonSave_States[5] == NULL); + _buttonSave_States[5] = new RMOptionButton(RMRect(432, 239, 432 + 160, 239 + 120)); if (_bAlterGfx) { - assert(_ButtonSave_ArrowLeft == NULL); - _ButtonSave_ArrowLeft = new RMOptionButton(20026, RMPoint(3, 196)); - assert(_ButtonSave_ArrowRight == NULL); - _ButtonSave_ArrowRight = new RMOptionButton(20027, RMPoint(601, 197)); + assert(_buttonSave_ArrowLeft == NULL); + _buttonSave_ArrowLeft = new RMOptionButton(20026, RMPoint(3, 196)); + assert(_buttonSave_ArrowRight == NULL); + _buttonSave_ArrowRight = new RMOptionButton(20027, RMPoint(601, 197)); } else { - assert(_ButtonSave_ArrowLeft == NULL); - _ButtonSave_ArrowLeft = new RMOptionButton(20013, RMPoint(0, 197)); - assert(_ButtonSave_ArrowRight == NULL); - _ButtonSave_ArrowRight = new RMOptionButton(20014, RMPoint(601, 197)); + assert(_buttonSave_ArrowLeft == NULL); + _buttonSave_ArrowLeft = new RMOptionButton(20013, RMPoint(0, 197)); + assert(_buttonSave_ArrowRight == NULL); + _buttonSave_ArrowRight = new RMOptionButton(20014, RMPoint(601, 197)); } } else if (_nState == MENUGAME || _nState == MENUGFX || _nState == MENUSOUND) { - assert(_ButtonExit == NULL); - _ButtonExit = new RMOptionButton(20005, RMPoint(560, 405)); - assert(_ButtonQuit == NULL); - _ButtonQuit = new RMOptionButton(20020, RMPoint(7, 408)); - assert(_ButtonLoad == NULL); - _ButtonLoad = new RMOptionButton(20006, RMPoint(231, 401)); - assert(_ButtonSave == NULL); - _ButtonSave = new RMOptionButton(20007, RMPoint(325, 401)); - - assert(_ButtonGameMenu == NULL); - _ButtonGameMenu = new RMOptionButton(RMRect(24, 32, 118, 64)); - assert(_ButtonGfxMenu == NULL); - _ButtonGfxMenu = new RMOptionButton(RMRect(118, 32, 212, 64)); - assert(_ButtonSoundMenu == NULL); - _ButtonSoundMenu = new RMOptionButton(RMRect(212, 32, 306, 64)); + assert(_buttonExit == NULL); + _buttonExit = new RMOptionButton(20005, RMPoint(560, 405)); + assert(_buttonQuit == NULL); + _buttonQuit = new RMOptionButton(20020, RMPoint(7, 408)); + assert(_buttonLoad == NULL); + _buttonLoad = new RMOptionButton(20006, RMPoint(231, 401)); + assert(_buttonSave == NULL); + _buttonSave = new RMOptionButton(20007, RMPoint(325, 401)); + + assert(_buttonGameMenu == NULL); + _buttonGameMenu = new RMOptionButton(RMRect(24, 32, 118, 64)); + assert(_buttonGfxMenu == NULL); + _buttonGfxMenu = new RMOptionButton(RMRect(118, 32, 212, 64)); + assert(_buttonSoundMenu == NULL); + _buttonSoundMenu = new RMOptionButton(RMRect(212, 32, 306, 64)); _ctx->raw = new RMResRaw(20021); assert(_ctx->raw->isValid()); - assert(_QuitConfirm == NULL); - _QuitConfirm = new RMGfxSourceBuffer16(false); - _QuitConfirm->init(*_ctx->raw, _ctx->raw->width(), _ctx->raw->height()); + assert(_quitConfirm == NULL); + _quitConfirm = new RMGfxSourceBuffer16(false); + _quitConfirm->init(*_ctx->raw, _ctx->raw->width(), _ctx->raw->height()); delete _ctx->raw; - assert(_ButtonQuitYes == NULL); - _ButtonQuitYes = new RMOptionButton(20022, RMPoint(281, 265)); - _ButtonQuitYes->setPriority(30); - assert(_ButtonQuitNo == NULL); - _ButtonQuitNo = new RMOptionButton(20023, RMPoint(337, 264)); - _ButtonQuitNo->setPriority(30); + assert(_buttonQuitYes == NULL); + _buttonQuitYes = new RMOptionButton(20022, RMPoint(281, 265)); + _buttonQuitYes->setPriority(30); + assert(_buttonQuitNo == NULL); + _buttonQuitNo = new RMOptionButton(20023, RMPoint(337, 264)); + _buttonQuitNo->setPriority(30); if (_bNoLoadSave) { _ctx->raw = new RMResRaw(20028); assert(_ctx->raw->isValid()); - assert(_HideLoadSave == NULL); - _HideLoadSave = new RMGfxSourceBuffer16(false); - _HideLoadSave->init(*_ctx->raw, _ctx->raw->width(), _ctx->raw->height()); + assert(_hideLoadSave == NULL); + _hideLoadSave = new RMGfxSourceBuffer16(false); + _hideLoadSave->init(*_ctx->raw, _ctx->raw->width(), _ctx->raw->height()); delete _ctx->raw; } // Menu GAME if (_nState == MENUGAME) { - assert(_ButtonGame_Lock == NULL); - _ButtonGame_Lock = new RMOptionButton(20008, RMPoint(176, 262), true); - _ButtonGame_Lock->setActiveState(GLOBALS._bCfgInvLocked); - assert(_ButtonGame_TimerizedText == NULL); - _ButtonGame_TimerizedText = new RMOptionButton(20009, RMPoint(463, 273), true); - _ButtonGame_TimerizedText->setActiveState(!GLOBALS._bCfgTimerizedText); - assert(_ButtonGame_Scrolling == NULL); - _ButtonGame_Scrolling = new RMOptionButton(20010, RMPoint(315, 263), true); - _ButtonGame_Scrolling->setActiveState(GLOBALS._bCfgInvNoScroll); - assert(_ButtonGame_InterUp == NULL); - _ButtonGame_InterUp = new RMOptionButton(20011, RMPoint(36, 258), true); - _ButtonGame_InterUp->setActiveState(GLOBALS._bCfgInvUp); - - assert(_SlideTextSpeed == NULL); - _SlideTextSpeed = new RMOptionSlide(RMPoint(165, 122), 10, GLOBALS._nCfgTextSpeed); - assert(_SlideTonySpeed == NULL); - _SlideTonySpeed = new RMOptionSlide(RMPoint(165, 226), 5, GLOBALS._nCfgTonySpeed); + assert(_buttonGame_Lock == NULL); + _buttonGame_Lock = new RMOptionButton(20008, RMPoint(176, 262), true); + _buttonGame_Lock->setActiveState(GLOBALS._bCfgInvLocked); + assert(_buttonGame_TimerizedText == NULL); + _buttonGame_TimerizedText = new RMOptionButton(20009, RMPoint(463, 273), true); + _buttonGame_TimerizedText->setActiveState(!GLOBALS._bCfgTimerizedText); + assert(_buttonGame_Scrolling == NULL); + _buttonGame_Scrolling = new RMOptionButton(20010, RMPoint(315, 263), true); + _buttonGame_Scrolling->setActiveState(GLOBALS._bCfgInvNoScroll); + assert(_buttonGame_InterUp == NULL); + _buttonGame_InterUp = new RMOptionButton(20011, RMPoint(36, 258), true); + _buttonGame_InterUp->setActiveState(GLOBALS._bCfgInvUp); + + assert(_slideTextSpeed == NULL); + _slideTextSpeed = new RMOptionSlide(RMPoint(165, 122), 10, GLOBALS._nCfgTextSpeed); + assert(_slideTonySpeed == NULL); + _slideTonySpeed = new RMOptionSlide(RMPoint(165, 226), 5, GLOBALS._nCfgTonySpeed); } // Menu Graphics else if (_nState == MENUGFX) { - assert(_ButtonGfx_Anni30 == NULL); - _ButtonGfx_Anni30 = new RMOptionButton(20015, RMPoint(247, 178), true); - _ButtonGfx_Anni30->setActiveState(GLOBALS._bCfgAnni30); - assert(_ButtonGfx_AntiAlias == NULL); - _ButtonGfx_AntiAlias = new RMOptionButton(20016, RMPoint(430, 83), true); - _ButtonGfx_AntiAlias->setActiveState(!GLOBALS._bCfgAntiAlias); - assert(_ButtonGfx_Sottotitoli == NULL); - _ButtonGfx_Sottotitoli = new RMOptionButton(20017, RMPoint(98, 82), true); - _ButtonGfx_Sottotitoli->setActiveState(!GLOBALS._bCfgSottotitoli); - assert(_ButtonGfx_Tips == NULL); - _ButtonGfx_Tips = new RMOptionButton(20018, RMPoint(431, 246), true); - _ButtonGfx_Tips->setActiveState(GLOBALS._bCfgInterTips); - assert(_ButtonGfx_Trans == NULL); - _ButtonGfx_Trans = new RMOptionButton(20019, RMPoint(126, 271), true); - _ButtonGfx_Trans->setActiveState(!GLOBALS._bCfgTransparence); + assert(_buttonGfx_Anni30 == NULL); + _buttonGfx_Anni30 = new RMOptionButton(20015, RMPoint(247, 178), true); + _buttonGfx_Anni30->setActiveState(GLOBALS._bCfgAnni30); + assert(_buttonGfx_AntiAlias == NULL); + _buttonGfx_AntiAlias = new RMOptionButton(20016, RMPoint(430, 83), true); + _buttonGfx_AntiAlias->setActiveState(!GLOBALS._bCfgAntiAlias); + assert(_buttonGfx_Sottotitoli == NULL); + _buttonGfx_Sottotitoli = new RMOptionButton(20017, RMPoint(98, 82), true); + _buttonGfx_Sottotitoli->setActiveState(!GLOBALS._bCfgSottotitoli); + assert(_buttonGfx_Tips == NULL); + _buttonGfx_Tips = new RMOptionButton(20018, RMPoint(431, 246), true); + _buttonGfx_Tips->setActiveState(GLOBALS._bCfgInterTips); + assert(_buttonGfx_Trans == NULL); + _buttonGfx_Trans = new RMOptionButton(20019, RMPoint(126, 271), true); + _buttonGfx_Trans->setActiveState(!GLOBALS._bCfgTransparence); } else if (_nState == MENUSOUND) { - assert(_SliderSound_Dubbing == NULL); - _SliderSound_Dubbing = new RMOptionSlide(RMPoint(165, 122), 10, GLOBALS._nCfgDubbingVolume); - assert(_SliderSound_Music == NULL); - _SliderSound_Music = new RMOptionSlide(RMPoint(165, 226), 10, GLOBALS._nCfgMusicVolume); - assert(_SliderSound_SFX == NULL); - _SliderSound_SFX = new RMOptionSlide(RMPoint(165, 330), 10, GLOBALS._nCfgSFXVolume); - - assert(_ButtonSound_DubbingOn == NULL); - _ButtonSound_DubbingOn = new RMOptionButton(20033, RMPoint(339, 75), true); - _ButtonSound_DubbingOn->setActiveState(GLOBALS._bCfgDubbing); - assert(_ButtonSound_MusicOn == NULL); - _ButtonSound_MusicOn = new RMOptionButton(20034, RMPoint(338, 179), true); - _ButtonSound_MusicOn->setActiveState(GLOBALS._bCfgMusic); - assert(_ButtonSound_SFXOn == NULL); - _ButtonSound_SFXOn = new RMOptionButton(20035, RMPoint(338, 283), true); - _ButtonSound_SFXOn->setActiveState(GLOBALS._bCfgSFX); + assert(_sliderSound_Dubbing == NULL); + _sliderSound_Dubbing = new RMOptionSlide(RMPoint(165, 122), 10, GLOBALS._nCfgDubbingVolume); + assert(_sliderSound_Music == NULL); + _sliderSound_Music = new RMOptionSlide(RMPoint(165, 226), 10, GLOBALS._nCfgMusicVolume); + assert(_sliderSound_SFX == NULL); + _sliderSound_SFX = new RMOptionSlide(RMPoint(165, 330), 10, GLOBALS._nCfgSFXVolume); + + assert(_buttonSound_DubbingOn == NULL); + _buttonSound_DubbingOn = new RMOptionButton(20033, RMPoint(339, 75), true); + _buttonSound_DubbingOn->setActiveState(GLOBALS._bCfgDubbing); + assert(_buttonSound_MusicOn == NULL); + _buttonSound_MusicOn = new RMOptionButton(20034, RMPoint(338, 179), true); + _buttonSound_MusicOn->setActiveState(GLOBALS._bCfgMusic); + assert(_buttonSound_SFXOn == NULL); + _buttonSound_SFXOn = new RMOptionButton(20035, RMPoint(338, 283), true); + _buttonSound_SFXOn->setActiveState(GLOBALS._bCfgSFX); } } @@ -736,8 +736,8 @@ void RMOptionScreen::closeState(void) { delete _menu; _menu = NULL; - delete _ButtonExit; - _ButtonExit = NULL; + delete _buttonExit; + _buttonExit = NULL; if (_nState == MENULOAD || _nState == MENUSAVE) { int i; @@ -748,114 +748,114 @@ void RMOptionScreen::closeState(void) { _curThumb[i] = NULL; } - delete _ButtonSave_States[i]; - _ButtonSave_States[i] = NULL; + delete _buttonSave_States[i]; + _buttonSave_States[i] = NULL; } - delete _ButtonSave_ArrowLeft; - _ButtonSave_ArrowLeft = NULL; - delete _ButtonSave_ArrowRight; - _ButtonSave_ArrowRight = NULL; + delete _buttonSave_ArrowLeft; + _buttonSave_ArrowLeft = NULL; + delete _buttonSave_ArrowRight; + _buttonSave_ArrowRight = NULL; - delete _SaveEasy; - _SaveEasy = NULL; - delete _SaveHard; - _SaveHard = NULL; + delete _saveEasy; + _saveEasy = NULL; + delete _saveHard; + _saveHard = NULL; } if (_nState == MENUGAME || _nState == MENUGFX || _nState == MENUSOUND) { - delete _ButtonQuit; - _ButtonQuit = NULL; - delete _ButtonLoad; - _ButtonLoad = NULL; - delete _ButtonSave; - _ButtonSave = NULL; - delete _ButtonGameMenu; - _ButtonGameMenu = NULL; - delete _ButtonGfxMenu; - _ButtonGfxMenu = NULL; - delete _ButtonSoundMenu; - _ButtonSoundMenu = NULL; - delete _QuitConfirm; - _QuitConfirm = NULL; - delete _ButtonQuitYes; - _ButtonQuitYes = NULL; - delete _ButtonQuitNo; - _ButtonQuitNo = NULL; + delete _buttonQuit; + _buttonQuit = NULL; + delete _buttonLoad; + _buttonLoad = NULL; + delete _buttonSave; + _buttonSave = NULL; + delete _buttonGameMenu; + _buttonGameMenu = NULL; + delete _buttonGfxMenu; + _buttonGfxMenu = NULL; + delete _buttonSoundMenu; + _buttonSoundMenu = NULL; + delete _quitConfirm; + _quitConfirm = NULL; + delete _buttonQuitYes; + _buttonQuitYes = NULL; + delete _buttonQuitNo; + _buttonQuitNo = NULL; if (_bNoLoadSave) { - delete _HideLoadSave; - _HideLoadSave = NULL; + delete _hideLoadSave; + _hideLoadSave = NULL; } if (_nState == MENUGAME) { - GLOBALS._bCfgInvLocked = _ButtonGame_Lock->isActive(); - delete _ButtonGame_Lock; - _ButtonGame_Lock = NULL; + GLOBALS._bCfgInvLocked = _buttonGame_Lock->isActive(); + delete _buttonGame_Lock; + _buttonGame_Lock = NULL; - GLOBALS._bCfgTimerizedText = !_ButtonGame_TimerizedText->isActive(); - delete _ButtonGame_TimerizedText; - _ButtonGame_TimerizedText = NULL; + GLOBALS._bCfgTimerizedText = !_buttonGame_TimerizedText->isActive(); + delete _buttonGame_TimerizedText; + _buttonGame_TimerizedText = NULL; - GLOBALS._bCfgInvNoScroll = _ButtonGame_Scrolling->isActive(); - delete _ButtonGame_Scrolling; - _ButtonGame_Scrolling = NULL; + GLOBALS._bCfgInvNoScroll = _buttonGame_Scrolling->isActive(); + delete _buttonGame_Scrolling; + _buttonGame_Scrolling = NULL; - GLOBALS._bCfgInvUp = _ButtonGame_InterUp->isActive(); - delete _ButtonGame_InterUp; - _ButtonGame_InterUp = NULL; + GLOBALS._bCfgInvUp = _buttonGame_InterUp->isActive(); + delete _buttonGame_InterUp; + _buttonGame_InterUp = NULL; - GLOBALS._nCfgTextSpeed = _SlideTextSpeed->getValue(); - delete _SlideTextSpeed; - _SlideTextSpeed = NULL; + GLOBALS._nCfgTextSpeed = _slideTextSpeed->getValue(); + delete _slideTextSpeed; + _slideTextSpeed = NULL; - GLOBALS._nCfgTonySpeed = _SlideTonySpeed->getValue(); - delete _SlideTonySpeed; - _SlideTonySpeed = NULL; + GLOBALS._nCfgTonySpeed = _slideTonySpeed->getValue(); + delete _slideTonySpeed; + _slideTonySpeed = NULL; } else if (_nState == MENUGFX) { - GLOBALS._bCfgAnni30 = _ButtonGfx_Anni30->isActive(); - delete _ButtonGfx_Anni30; - _ButtonGfx_Anni30 = NULL; + GLOBALS._bCfgAnni30 = _buttonGfx_Anni30->isActive(); + delete _buttonGfx_Anni30; + _buttonGfx_Anni30 = NULL; - GLOBALS._bCfgAntiAlias = !_ButtonGfx_AntiAlias->isActive(); - delete _ButtonGfx_AntiAlias; - _ButtonGfx_AntiAlias = NULL; + GLOBALS._bCfgAntiAlias = !_buttonGfx_AntiAlias->isActive(); + delete _buttonGfx_AntiAlias; + _buttonGfx_AntiAlias = NULL; - GLOBALS._bCfgSottotitoli = !_ButtonGfx_Sottotitoli->isActive(); - delete _ButtonGfx_Sottotitoli; - _ButtonGfx_Sottotitoli = NULL; + GLOBALS._bCfgSottotitoli = !_buttonGfx_Sottotitoli->isActive(); + delete _buttonGfx_Sottotitoli; + _buttonGfx_Sottotitoli = NULL; - GLOBALS._bCfgInterTips = _ButtonGfx_Tips->isActive(); - delete _ButtonGfx_Tips; - _ButtonGfx_Tips = NULL; + GLOBALS._bCfgInterTips = _buttonGfx_Tips->isActive(); + delete _buttonGfx_Tips; + _buttonGfx_Tips = NULL; - GLOBALS._bCfgTransparence = !_ButtonGfx_Trans->isActive(); - delete _ButtonGfx_Trans; - _ButtonGfx_Trans = NULL; + GLOBALS._bCfgTransparence = !_buttonGfx_Trans->isActive(); + delete _buttonGfx_Trans; + _buttonGfx_Trans = NULL; } else if (_nState == MENUSOUND) { - GLOBALS._nCfgDubbingVolume = _SliderSound_Dubbing->getValue(); - delete _SliderSound_Dubbing; - _SliderSound_Dubbing = NULL; + GLOBALS._nCfgDubbingVolume = _sliderSound_Dubbing->getValue(); + delete _sliderSound_Dubbing; + _sliderSound_Dubbing = NULL; - GLOBALS._nCfgMusicVolume = _SliderSound_Music->getValue(); - delete _SliderSound_Music; - _SliderSound_Music = NULL; + GLOBALS._nCfgMusicVolume = _sliderSound_Music->getValue(); + delete _sliderSound_Music; + _sliderSound_Music = NULL; - GLOBALS._nCfgSFXVolume = _SliderSound_SFX->getValue(); - delete _SliderSound_SFX; - _SliderSound_SFX = NULL; + GLOBALS._nCfgSFXVolume = _sliderSound_SFX->getValue(); + delete _sliderSound_SFX; + _sliderSound_SFX = NULL; - GLOBALS._bCfgDubbing = _ButtonSound_DubbingOn->isActive(); - delete _ButtonSound_DubbingOn; - _ButtonSound_DubbingOn = NULL; + GLOBALS._bCfgDubbing = _buttonSound_DubbingOn->isActive(); + delete _buttonSound_DubbingOn; + _buttonSound_DubbingOn = NULL; - GLOBALS._bCfgMusic = _ButtonSound_MusicOn->isActive(); - delete _ButtonSound_MusicOn; - _ButtonSound_MusicOn = NULL; + GLOBALS._bCfgMusic = _buttonSound_MusicOn->isActive(); + delete _buttonSound_MusicOn; + _buttonSound_MusicOn = NULL; - GLOBALS._bCfgSFX = _ButtonSound_SFXOn->isActive(); - delete _ButtonSound_SFXOn; - _ButtonSound_SFXOn = NULL; + GLOBALS._bCfgSFX = _buttonSound_SFXOn->isActive(); + delete _buttonSound_SFXOn; + _buttonSound_SFXOn = NULL; } } @@ -872,14 +872,14 @@ void RMOptionScreen::init(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool &result) { CORO_BEGIN_CODE(_ctx); - if (_FadeStep != 0) { + if (_fadeStep != 0) { result = false; return; } - _FadeStep = 1; - _FadeY = -20; - _FadeTime = -1; + _fadeStep = 1; + _fadeY = -20; + _fadeTime = -1; _bExit = false; _bLoadMenuOnly = false; _bNoLoadSave = false; @@ -903,14 +903,14 @@ void RMOptionScreen::initLoadMenuOnly(CORO_PARAM, RMGfxTargetBuffer &bigBuf, boo CORO_BEGIN_CODE(_ctx); - if (_FadeStep != 0) { + if (_fadeStep != 0) { result = false; return; } - _FadeStep = 1; - _FadeY = -20; - _FadeTime = -1; + _fadeStep = 1; + _fadeY = -20; + _fadeTime = -1; _bExit = false; _bLoadMenuOnly = true; _bNoLoadSave = false; @@ -932,14 +932,14 @@ void RMOptionScreen::initSaveMenuOnly(CORO_PARAM, RMGfxTargetBuffer &bigBuf, boo CORO_BEGIN_CODE(_ctx); - if (_FadeStep != 0) { + if (_fadeStep != 0) { result = false; return; } - _FadeStep = 1; - _FadeY = -20; - _FadeTime = -1; + _fadeStep = 1; + _fadeY = -20; + _fadeTime = -1; _bExit = false; _bLoadMenuOnly = true; _bNoLoadSave = false; @@ -961,14 +961,14 @@ void RMOptionScreen::initNoLoadSave(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool CORO_BEGIN_CODE(_ctx); - if (_FadeStep != 0) { + if (_fadeStep != 0) { result = false; return; } - _FadeStep = 1; - _FadeY = -20; - _FadeTime = -1; + _fadeStep = 1; + _fadeY = -20; + _fadeTime = -1; _bExit = false; _bLoadMenuOnly = false; _bNoLoadSave = true; @@ -984,12 +984,12 @@ void RMOptionScreen::initNoLoadSave(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool } bool RMOptionScreen::close(void) { - if (_FadeStep != 6) + if (_fadeStep != 6) return false; // Start fade out - _FadeStep++; - _FadeTime = _vm->getTime(); + _fadeStep++; + _fadeTime = _vm->getTime(); return true; } @@ -1028,7 +1028,7 @@ void RMOptionScreen::doFrame(CORO_PARAM, RMInput *input) { // If it is fully open, do nothing - if (_FadeStep != 6) + if (_fadeStep != 6) return; // Reads input @@ -1039,78 +1039,78 @@ void RMOptionScreen::doFrame(CORO_PARAM, RMInput *input) { _ctx->bRefresh = false; if (_bQuitConfirm) { - _ctx->bRefresh |= _ButtonQuitYes->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= _ButtonQuitNo->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _buttonQuitYes->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _buttonQuitNo->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); } else { - _ctx->bRefresh |= _ButtonExit->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _buttonExit->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); // Check if you have clicked on the output if (_nState == MENUGAME || _nState == MENUGFX || _nState == MENUSOUND) { // Buttons without graphics... - _ButtonGameMenu->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ButtonGfxMenu->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ButtonSoundMenu->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _buttonGameMenu->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _buttonGfxMenu->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _buttonSoundMenu->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); // Buttons with graphics if (!_bNoLoadSave) { if (!_vm->getIsDemo()) { - _ctx->bRefresh |= _ButtonLoad->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= _ButtonSave->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _buttonLoad->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _buttonSave->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); } - _ctx->bRefresh |= _ButtonQuit->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _buttonQuit->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); } } if (_nState == MENUGAME) { - _ctx->bRefresh |= _ButtonGame_Lock->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= _ButtonGame_TimerizedText->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= _ButtonGame_Scrolling->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= _ButtonGame_InterUp->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= _SlideTextSpeed->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= _SlideTonySpeed->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _buttonGame_Lock->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _buttonGame_TimerizedText->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _buttonGame_Scrolling->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _buttonGame_InterUp->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _slideTextSpeed->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _slideTonySpeed->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); } else if (_nState == MENUGFX) { - _ctx->bRefresh |= _ButtonGfx_Anni30->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= _ButtonGfx_AntiAlias->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= _ButtonGfx_Sottotitoli->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= _ButtonGfx_Tips->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= _ButtonGfx_Trans->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _buttonGfx_Anni30->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _buttonGfx_AntiAlias->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _buttonGfx_Sottotitoli->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _buttonGfx_Tips->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _buttonGfx_Trans->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); } else if (_nState == MENUSOUND) { - _ctx->bRefresh |= _SliderSound_Dubbing->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= _SliderSound_Music->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= _SliderSound_SFX->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= _ButtonSound_DubbingOn->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= _ButtonSound_MusicOn->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - _ctx->bRefresh |= _ButtonSound_SFXOn->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _sliderSound_Dubbing->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _sliderSound_Music->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _sliderSound_SFX->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _buttonSound_DubbingOn->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _buttonSound_MusicOn->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _buttonSound_SFXOn->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); } else if (_nState == MENULOAD || _nState == MENUSAVE) { for (_ctx->i = 0; _ctx->i < 6; _ctx->i++) - _ButtonSave_States[_ctx->i]->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _buttonSave_States[_ctx->i]->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); if (_statePos > 0) - _ctx->bRefresh |= _ButtonSave_ArrowLeft->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _buttonSave_ArrowLeft->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); if (_statePos < 90) - _ctx->bRefresh |= _ButtonSave_ArrowRight->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); + _ctx->bRefresh |= _buttonSave_ArrowRight->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); } } #define KEYPRESS(c) (_vm->getEngine()->getInput().getAsyncKeyState(c)) #define PROCESS_CHAR(cod,c) if (KEYPRESS(cod)) { \ - _EditName[strlen(_EditName) + 1] = '\0'; _EditName[strlen(_EditName)] = c; _ctx->bRefresh = true; } + _editName[strlen(_editName) + 1] = '\0'; _editName[strlen(_editName)] = c; _ctx->bRefresh = true; } /**************** State Buttons **************/ if (_bEditSaveName) { if (KEYPRESS(Common::KEYCODE_BACKSPACE)) { - if (_EditName[0] != '\0') { - _EditName[strlen(_EditName) - 1] = '\0'; + if (_editName[0] != '\0') { + _editName[strlen(_editName) - 1] = '\0'; _ctx->bRefresh = true; } } - for (_ctx->i = 0; _ctx->i < 26 && strlen(_EditName) < 12; _ctx->i++) + for (_ctx->i = 0; _ctx->i < 26 && strlen(_editName) < 12; _ctx->i++) if (KEYPRESS(Common::KEYCODE_LSHIFT) || KEYPRESS(Common::KEYCODE_RSHIFT)) { PROCESS_CHAR((Common::KeyCode)((int)'a' + _ctx->i), _ctx->i + 'A'); @@ -1118,31 +1118,31 @@ void RMOptionScreen::doFrame(CORO_PARAM, RMInput *input) { PROCESS_CHAR((Common::KeyCode)((int)'a' + _ctx->i), _ctx->i + 'a'); } - for (_ctx->i = 0; _ctx->i < 10 && strlen(_EditName) < 12; _ctx->i++) + for (_ctx->i = 0; _ctx->i < 10 && strlen(_editName) < 12; _ctx->i++) PROCESS_CHAR((Common::KeyCode)((int)'0' + _ctx->i), _ctx->i + '0'); - if (strlen(_EditName) < 12) + if (strlen(_editName) < 12) PROCESS_CHAR(Common::KEYCODE_SPACE, ' '); - if (strlen(_EditName) < 12) + if (strlen(_editName) < 12) PROCESS_CHAR(Common::KEYCODE_KP0, '0'); - if (strlen(_EditName) < 12) + if (strlen(_editName) < 12) PROCESS_CHAR(Common::KEYCODE_KP1, '1'); - if (strlen(_EditName) < 12) + if (strlen(_editName) < 12) PROCESS_CHAR(Common::KEYCODE_KP2, '2'); - if (strlen(_EditName) < 12) + if (strlen(_editName) < 12) PROCESS_CHAR(Common::KEYCODE_KP3, '3'); - if (strlen(_EditName) < 12) + if (strlen(_editName) < 12) PROCESS_CHAR(Common::KEYCODE_KP4, '4'); - if (strlen(_EditName) < 12) + if (strlen(_editName) < 12) PROCESS_CHAR(Common::KEYCODE_KP5, '5'); - if (strlen(_EditName) < 12) + if (strlen(_editName) < 12) PROCESS_CHAR(Common::KEYCODE_KP6, '6'); - if (strlen(_EditName) < 12) + if (strlen(_editName) < 12) PROCESS_CHAR(Common::KEYCODE_KP7, '7'); - if (strlen(_EditName) < 12) + if (strlen(_editName) < 12) PROCESS_CHAR(Common::KEYCODE_KP8, '8'); - if (strlen(_EditName) < 12) + if (strlen(_editName) < 12) PROCESS_CHAR(Common::KEYCODE_KP9, '9'); // Cancel @@ -1154,13 +1154,13 @@ void RMOptionScreen::doFrame(CORO_PARAM, RMInput *input) { // OK if (KEYPRESS(Common::KEYCODE_RETURN)) { _bEditSaveName = false; - _vm->saveState(_statePos + _nEditPos, _EditName); + _vm->saveState(_statePos + _nEditPos, _editName); close(); } } else if (_ctx->bLeftClick) { if (_nState == MENULOAD || _nState == MENUSAVE) { - if (_ButtonExit->isActive()) { + if (_buttonExit->isActive()) { if (_bLoadMenuOnly) { // If only the loading menu, close close(); @@ -1168,27 +1168,27 @@ void RMOptionScreen::doFrame(CORO_PARAM, RMInput *input) { CORO_INVOKE_1(changeState, _nLastState); _ctx->bRefresh = true; } - } else if (_ButtonSave_ArrowLeft->isActive()) { + } else if (_buttonSave_ArrowLeft->isActive()) { if (_statePos > 0) { _statePos -= 6; if (_statePos < 0) _statePos = 0; - _ButtonSave_ArrowLeft->setActiveState(false); + _buttonSave_ArrowLeft->setActiveState(false); _ctx->bRefresh = true; refreshThumbnails(); } - } else if (_ButtonSave_ArrowRight->isActive()) { + } else if (_buttonSave_ArrowRight->isActive()) { if (_statePos < 90) { _statePos += 6; if (_statePos > 90) _statePos = 90; - _ButtonSave_ArrowRight->setActiveState(false); + _buttonSave_ArrowRight->setActiveState(false); _ctx->bRefresh = true; refreshThumbnails(); } } else { for (_ctx->i = 0; _ctx->i < 6; _ctx->i++) - if (_ButtonSave_States[_ctx->i]->isActive()) { + if (_buttonSave_States[_ctx->i]->isActive()) { // There by saving or loading!!! if (_nState == MENULOAD && _curThumb[_ctx->i] != NULL) { // Caricamento @@ -1198,7 +1198,7 @@ void RMOptionScreen::doFrame(CORO_PARAM, RMInput *input) { // Turn on edit mode _bEditSaveName = true; _nEditPos = _ctx->i; - strcpy(_EditName, _curThumbName[_ctx->i]); + strcpy(_editName, _curThumbName[_ctx->i]); _ctx->bRefresh = true; } @@ -1209,53 +1209,53 @@ void RMOptionScreen::doFrame(CORO_PARAM, RMInput *input) { if (_nState == MENUGAME || _nState == MENUGFX || _nState == MENUSOUND) { if (_bQuitConfirm) { - if (_ButtonQuitNo->isActive()) { + if (_buttonQuitNo->isActive()) { _bQuitConfirm = false; _ctx->bRefresh = true; - } else if (_ButtonQuitYes->isActive()) { + } else if (_buttonQuitYes->isActive()) { _bQuitConfirm = false; _ctx->bRefresh = true; _vm->quitGame(); } } else { - if (_ButtonQuit->isActive()) { + if (_buttonQuit->isActive()) { _bQuitConfirm = true; - _ButtonQuitNo->setActiveState(false); - _ButtonQuitYes->setActiveState(false); + _buttonQuitNo->setActiveState(false); + _buttonQuitYes->setActiveState(false); _ctx->bRefresh = true; - } else if (_ButtonExit->isActive()) + } else if (_buttonExit->isActive()) close(); - else if (_ButtonLoad->isActive()) { + else if (_buttonLoad->isActive()) { CORO_INVOKE_1(changeState, MENULOAD); _ctx->bRefresh = true; - } else if (_ButtonSave->isActive()) { + } else if (_buttonSave->isActive()) { CORO_INVOKE_1(changeState, MENUSAVE); _ctx->bRefresh = true; - } else if (_ButtonGameMenu->isActive() && _nState != MENUGAME) { + } else if (_buttonGameMenu->isActive() && _nState != MENUGAME) { CORO_INVOKE_1(changeState, MENUGAME); _ctx->bRefresh = true; - } else if (_ButtonGfxMenu->isActive() && _nState != MENUGFX) { + } else if (_buttonGfxMenu->isActive() && _nState != MENUGFX) { CORO_INVOKE_1(changeState, MENUGFX); _ctx->bRefresh = true; - } else if (_ButtonSoundMenu->isActive() && _nState != MENUSOUND) { + } else if (_buttonSoundMenu->isActive() && _nState != MENUSOUND) { CORO_INVOKE_1(changeState, MENUSOUND); _ctx->bRefresh = true; } if (_nState == MENUGFX) { // These options take effect immediately - if (_ButtonGfx_Anni30->isActive()) + if (_buttonGfx_Anni30->isActive()) GLOBALS._bCfgAnni30 = true; else GLOBALS._bCfgAnni30 = false; - if (_ButtonGfx_AntiAlias->isActive()) + if (_buttonGfx_AntiAlias->isActive()) GLOBALS._bCfgAntiAlias = false; else GLOBALS._bCfgAntiAlias = true; - if (_ButtonGfx_Trans->isActive()) + if (_buttonGfx_Trans->isActive()) GLOBALS._bCfgTransparence = false; else GLOBALS._bCfgTransparence = true; @@ -1285,94 +1285,94 @@ void RMOptionScreen::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive _ctx->curTime = _vm->getTime(); #define FADE_SPEED 20 -#define SYNC (_ctx->curTime - _FadeTime) / 25 +#define SYNC (_ctx->curTime - _fadeTime) / 25 if (_bExit) return; - if (_FadeStep == 1) { + if (_fadeStep == 1) { // Downhill fast - if (_FadeTime == -1) - _FadeY += FADE_SPEED; + if (_fadeTime == -1) + _fadeY += FADE_SPEED; else - _FadeY += FADE_SPEED * SYNC; - if (_FadeY > 480) { - _FadeY = 480; - _FadeStep++; + _fadeY += FADE_SPEED * SYNC; + if (_fadeY > 480) { + _fadeY = 480; + _fadeStep++; } // Set the part to draw the scrolling - prim->setSrc(RMRect(0, 480 - _FadeY, 640, 480)); + prim->setSrc(RMRect(0, 480 - _fadeY, 640, 480)); - } else if (_FadeStep == 2) { + } else if (_fadeStep == 2) { // Bounce 1 - _FadeY -= FADE_SPEED / 2 * SYNC; - if (_FadeY < 400) { - _FadeY = 400; - _FadeStep++; + _fadeY -= FADE_SPEED / 2 * SYNC; + if (_fadeY < 400) { + _fadeY = 400; + _fadeStep++; } - prim->setSrc(RMRect(0, 480 - _FadeY, 640, 480)); + prim->setSrc(RMRect(0, 480 - _fadeY, 640, 480)); - } else if (_FadeStep == 3) { - _FadeY -= FADE_SPEED / 4 * SYNC; - if (_FadeY < 380) { - _FadeY = 380; - _FadeStep++; + } else if (_fadeStep == 3) { + _fadeY -= FADE_SPEED / 4 * SYNC; + if (_fadeY < 380) { + _fadeY = 380; + _fadeStep++; } - prim->setSrc(RMRect(0, 480 - _FadeY, 640, 480)); + prim->setSrc(RMRect(0, 480 - _fadeY, 640, 480)); - } else if (_FadeStep == 4) { + } else if (_fadeStep == 4) { // Bounce 1 - 2 - _FadeY += FADE_SPEED / 3 * SYNC; - if (_FadeY > 420) { - _FadeY = 420; - _FadeStep++; + _fadeY += FADE_SPEED / 3 * SYNC; + if (_fadeY > 420) { + _fadeY = 420; + _fadeStep++; } - prim->setSrc(RMRect(0, 480 - _FadeY, 640, 480)); + prim->setSrc(RMRect(0, 480 - _fadeY, 640, 480)); - } else if (_FadeStep == 5) { - _FadeY += FADE_SPEED / 2 * SYNC; - if (_FadeY > 480) { - _FadeY = 480; - _FadeStep++; + } else if (_fadeStep == 5) { + _fadeY += FADE_SPEED / 2 * SYNC; + if (_fadeY > 480) { + _fadeY = 480; + _fadeStep++; _vm->hideLocation(); } - prim->setSrc(RMRect(0, 480 - _FadeY, 640, 480)); + prim->setSrc(RMRect(0, 480 - _fadeY, 640, 480)); - } else if (_FadeStep == 6) { + } else if (_fadeStep == 6) { // Menu ON - } else if (_FadeStep == 7) { + } else if (_fadeStep == 7) { // Menu OFF _vm->showLocation(); - _FadeStep++; + _fadeStep++; - } else if (_FadeStep == 8) { - _FadeY -= FADE_SPEED * SYNC; - if (_FadeY < 0) { - _FadeY = 0; - _FadeStep++; + } else if (_fadeStep == 8) { + _fadeY -= FADE_SPEED * SYNC; + if (_fadeY < 0) { + _fadeY = 0; + _fadeStep++; } - prim->setSrc(RMRect(0, 480 - _FadeY, 640, 480)); + prim->setSrc(RMRect(0, 480 - _fadeY, 640, 480)); - } else if (_FadeStep == 9) { + } else if (_fadeStep == 9) { // Hello hello! _bExit = true; - _FadeStep = 0; + _fadeStep = 0; // Free memory closeState(); return; } else { - _FadeStep = 0; + _fadeStep = 0; } - _FadeTime = _ctx->curTime; + _fadeTime = _ctx->curTime; CORO_INVOKE_2(RMGfxWoodyBuffer::draw, bigBuf, prim); diff --git a/engines/tony/game.h b/engines/tony/game.h index 2d8f73f79b..db182dfa23 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -156,12 +156,12 @@ public: class RMOptionSlide : public RMGfxTaskSetPrior { private: - RMOptionButton *_PushLeft; - RMOptionButton *_PushRight; - RMGfxSourceBuffer16 *_SliderCenter; - RMGfxSourceBuffer16 *_SliderLeft; - RMGfxSourceBuffer16 *_SliderRight; - RMGfxSourceBuffer16 *_SliderSingle; + RMOptionButton *_pushLeft; + RMOptionButton *_pushRight; + RMGfxSourceBuffer16 *_sliderCenter; + RMGfxSourceBuffer16 *_sliderLeft; + RMGfxSourceBuffer16 *_sliderRight; + RMGfxSourceBuffer16 *_sliderSingle; int _nSlideSize; RMPoint _pos; int _nValue; @@ -184,65 +184,65 @@ public: class RMOptionScreen : public RMGfxWoodyBuffer { private: RMGfxSourceBuffer16 *_menu; - RMGfxSourceBuffer16 *_QuitConfirm; - RMGfxSourceBuffer16 *_HideLoadSave; - RMOptionButton *_ButtonQuitYes; - RMOptionButton *_ButtonQuitNo; - RMOptionButton *_ButtonExit; - RMOptionButton *_ButtonQuit; - RMOptionButton *_ButtonLoad; - RMOptionButton *_ButtonSave; - RMOptionButton *_ButtonGameMenu; - RMOptionButton *_ButtonGfxMenu; - RMOptionButton *_ButtonSoundMenu; - RMGfxSourceBuffer8 *_SaveEasy; - RMGfxSourceBuffer8 *_SaveHard; + RMGfxSourceBuffer16 *_quitConfirm; + RMGfxSourceBuffer16 *_hideLoadSave; + RMOptionButton *_buttonQuitYes; + RMOptionButton *_buttonQuitNo; + RMOptionButton *_buttonExit; + RMOptionButton *_buttonQuit; + RMOptionButton *_buttonLoad; + RMOptionButton *_buttonSave; + RMOptionButton *_buttonGameMenu; + RMOptionButton *_buttonGfxMenu; + RMOptionButton *_buttonSoundMenu; + RMGfxSourceBuffer8 *_saveEasy; + RMGfxSourceBuffer8 *_saveHard; RMGfxSourceBuffer16 *_curThumb[6]; RMString _curThumbName[6]; byte _curThumbDiff[6]; - RMOptionButton *_ButtonSave_States[6]; - RMOptionButton *_ButtonSave_ArrowLeft; - RMOptionButton *_ButtonSave_ArrowRight; - RMOptionButton *_ButtonGfx_Tips; + RMOptionButton *_buttonSave_States[6]; + RMOptionButton *_buttonSave_ArrowLeft; + RMOptionButton *_buttonSave_ArrowRight; + RMOptionButton *_buttonGfx_Tips; - RMOptionButton *_ButtonSound_DubbingOn; - RMOptionButton *_ButtonSound_MusicOn; - RMOptionButton *_ButtonSound_SFXOn; + RMOptionButton *_buttonSound_DubbingOn; + RMOptionButton *_buttonSound_MusicOn; + RMOptionButton *_buttonSound_SFXOn; - RMOptionSlide *_SlideTonySpeed; - RMOptionSlide *_SlideTextSpeed; + RMOptionSlide *_slideTonySpeed; + RMOptionSlide *_slideTextSpeed; int _statePos; bool _bEditSaveName; int _nEditPos; - char _EditName[256]; + char _editName[256]; union { - RMOptionButton *_ButtonGame_Lock; - RMOptionButton *_ButtonGfx_Anni30; - RMOptionSlide *_SliderSound_Music; + RMOptionButton *_buttonGame_Lock; + RMOptionButton *_buttonGfx_Anni30; + RMOptionSlide *_sliderSound_Music; }; union { - RMOptionButton *_ButtonGame_TimerizedText; - RMOptionButton *_ButtonGfx_AntiAlias; - RMOptionSlide *_SliderSound_SFX; + RMOptionButton *_buttonGame_TimerizedText; + RMOptionButton *_buttonGfx_AntiAlias; + RMOptionSlide *_sliderSound_SFX; }; union { - RMOptionButton *_ButtonGame_Scrolling; - RMOptionButton *_ButtonGfx_Sottotitoli; - RMOptionSlide *_SliderSound_Dubbing; + RMOptionButton *_buttonGame_Scrolling; + RMOptionButton *_buttonGfx_Sottotitoli; + RMOptionSlide *_sliderSound_Dubbing; }; union { - RMOptionButton *_ButtonGame_InterUp; - RMOptionButton *_ButtonGfx_Trans; + RMOptionButton *_buttonGame_InterUp; + RMOptionButton *_buttonGfx_Trans; }; - int _FadeStep; + int _fadeStep; bool _bExit; bool _bQuitConfirm; - int _FadeY; - int _FadeTime; + int _fadeY; + int _fadeTime; bool _bLoadMenuOnly; bool _bNoLoadSave; bool _bAlterGfx; diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 9d3795c760..8be4cbd5f5 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -272,9 +272,9 @@ void RMGfxTargetBuffer::clearOT(void) { cur = _otlist; while (cur != NULL) { - cur->prim->_task->Unregister(); - delete cur->prim; - n = cur->next; + cur->_prim->_task->Unregister(); + delete cur->_prim; + n = cur->_next; delete cur; cur = n; } @@ -304,19 +304,19 @@ void RMGfxTargetBuffer::drawOT(CORO_PARAM) { while (_ctx->cur != NULL) { // Call the task Draw method, passing it a copy of the original - _ctx->myprim = _ctx->cur->prim->duplicate(); - CORO_INVOKE_2(_ctx->cur->prim->_task->draw, *this, _ctx->myprim); + _ctx->myprim = _ctx->cur->_prim->duplicate(); + CORO_INVOKE_2(_ctx->cur->_prim->_task->draw, *this, _ctx->myprim); delete _ctx->myprim; // Check if it's time to remove the task from the OT list - CORO_INVOKE_1(_ctx->cur->prim->_task->removeThis, _ctx->result); + CORO_INVOKE_1(_ctx->cur->_prim->_task->removeThis, _ctx->result); if (_ctx->result) { // De-register the task - _ctx->cur->prim->_task->Unregister(); + _ctx->cur->_prim->_task->Unregister(); // Delete task, freeing the memory - delete _ctx->cur->prim; - _ctx->next = _ctx->cur->next; + delete _ctx->cur->_prim; + _ctx->next = _ctx->cur->_next; delete _ctx->cur; // If it was the first item, update the list head @@ -324,13 +324,13 @@ void RMGfxTargetBuffer::drawOT(CORO_PARAM) { _otlist = _ctx->next; // Otherwise update the next pinter of the previous item else - _ctx->prev->next = _ctx->next; + _ctx->prev->_next = _ctx->next; _ctx->cur = _ctx->next; } else { // Update the pointer to the previous item, and the current to the next _ctx->prev = _ctx->cur; - _ctx->cur = _ctx->cur->next; + _ctx->cur = _ctx->cur->_next; } } @@ -358,19 +358,19 @@ void RMGfxTargetBuffer::addPrim(RMGfxPrimitive *prim) { // Empty list if (_otlist == NULL) { _otlist = n; - _otlist->next = NULL; + _otlist->_next = NULL; } // Inclusion in the head - else if (nPrior < _otlist->prim->_task->priority()) { - n->next = _otlist; + else if (nPrior < _otlist->_prim->_task->priority()) { + n->_next = _otlist; _otlist = n; } else { cur = _otlist; - while (cur->next != NULL && nPrior > cur->next->prim->_task->priority()) - cur = cur->next; + while (cur->_next != NULL && nPrior > cur->_next->_prim->_task->priority()) + cur = cur->_next; - n->next = cur->next; - cur->next = n; + n->_next = cur->_next; + cur->_next = n; } // g_system->unlockMutex(csModifyingOT); diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index a1bf537e3b..17ad303fbd 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -544,12 +544,12 @@ private: static RMGfxClearTask taskClear; struct OTList { - RMGfxPrimitive *prim; - OTList *next; + RMGfxPrimitive *_prim; + OTList *_next; OTList(); OTList(RMGfxPrimitive *pr) { - prim = pr; + _prim = pr; } }; -- cgit v1.2.3 From 5de8b7aa74ad01daea0d41eebd24ad6f63edccd4 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 11 Jun 2012 21:43:04 +0200 Subject: TONY: Rename variables in tonychar.h --- engines/tony/tonychar.cpp | 154 +++++++++++++++++++++++----------------------- engines/tony/tonychar.h | 12 ++-- 2 files changed, 83 insertions(+), 83 deletions(-) (limited to 'engines') diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index 6852369c64..5d2c4d37bc 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -49,17 +49,17 @@ RMTony::RMTony() { _bShowOmbra = false; _bCorpoDavanti = false; _bActionPending = false; - _ActionItem = NULL; - _Action = 0; - _ActionParm = 0; + _actionItem = NULL; + _action = 0; + _actionParm = 0; _bPastorella = false; _bIsStaticTalk = false; _bIsTalking = false; _nPatB4Talking = 0; _nTalkType = TALK_NORMAL; - _TalkDirection = UP; + _talkDirection = UP; _nTimeLastStep = 0; - hActionThread = CORO_INVALID_PID_VALUE; + _hActionThread = CORO_INVALID_PID_VALUE; } void RMTony::waitEndOfAction(CORO_PARAM, const void *param) { @@ -219,18 +219,18 @@ void RMTony::moveAndDoAction(CORO_PARAM, RMPoint dst, RMItem *item, int nAction, // Makes normal movement, but remember if you must then perform an action if (item == NULL) { _bActionPending = false; - _ActionItem = NULL; + _actionItem = NULL; } else { - _ActionItem = item; - _Action = nAction; - _ActionParm = nActionParm; + _actionItem = item; + _action = nAction; + _actionParm = nActionParm; _bActionPending = true; } CORO_INVOKE_2(RMCharacter::move, dst, &_ctx->result); if (!_ctx->result) { _bActionPending = false; - _ActionItem = NULL; + _actionItem = NULL; } CORO_END_CODE; @@ -265,23 +265,23 @@ void RMTony::executeAction(int nAction, int nActionItem, int nParm) { if (pid != CORO_INVALID_PID_VALUE) { _bAction = true; CoroScheduler.createProcess(waitEndOfAction, &pid, sizeof(uint32)); - hActionThread = pid; + _hActionThread = pid; } else if (nAction != TA_GOTO) { if (nAction == TA_TALK) { pid = mpalQueryDoAction(6, 1, 0); _bAction = true; CoroScheduler.createProcess(waitEndOfAction, &pid, sizeof(uint32)); - hActionThread = pid; + _hActionThread = pid; } else if (nAction == TA_PALESATI) { pid = mpalQueryDoAction(7, 1, 0); _bAction = true; CoroScheduler.createProcess(waitEndOfAction, &pid, sizeof(uint32)); - hActionThread = pid; + _hActionThread = pid; } else { pid = mpalQueryDoAction(5, 1, 0); _bAction = true; CoroScheduler.createProcess(waitEndOfAction, &pid, sizeof(uint32)); - hActionThread = pid; + _hActionThread = pid; } } } @@ -294,10 +294,10 @@ void RMTony::stopNoAction(CORO_PARAM) { CORO_BEGIN_CODE(_ctx); if (_bAction) - CORO_INVOKE_2(CoroScheduler.waitForSingleObject, hActionThread, CORO_INFINITE); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _hActionThread, CORO_INFINITE); _bActionPending = false; - _ActionItem = NULL; + _actionItem = NULL; CORO_INVOKE_0(stop); CORO_END_CODE; @@ -310,9 +310,9 @@ void RMTony::stop(CORO_PARAM) { CORO_BEGIN_CODE(_ctx); - if (_ActionItem != NULL) { + if (_actionItem != NULL) { // Call MPAL to choose the direction - _ctx->pid = mpalQueryDoAction(21, _ActionItem->mpalCode(), 0); + _ctx->pid = mpalQueryDoAction(21, _actionItem->mpalCode(), 0); if (_ctx->pid == CORO_INVALID_PID_VALUE) CORO_INVOKE_0(RMCharacter::stop); @@ -330,9 +330,9 @@ void RMTony::stop(CORO_PARAM) { _bActionPending = false; - executeAction(_Action, _ActionItem->mpalCode(), _ActionParm); + executeAction(_action, _actionItem->mpalCode(), _actionParm); - _ActionItem = NULL; + _actionItem = NULL; CORO_END_CODE; } @@ -562,7 +562,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body if (!_bIsStaticTalk) { switch (_nPatB4Talking) { case PAT_STANDDOWN: - _TalkDirection = DOWN; + _talkDirection = DOWN; break; case PAT_TAKELEFT_UP2: @@ -570,7 +570,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case PAT_TAKELEFT_DOWN2: case PAT_SIRIALZALEFT: case PAT_STANDLEFT: - _TalkDirection = LEFT; + _talkDirection = LEFT; break; case PAT_TAKERIGHT_UP2: @@ -578,14 +578,14 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case PAT_TAKERIGHT_DOWN2: case PAT_SIRIALZARIGHT: case PAT_STANDRIGHT: - _TalkDirection = RIGHT; + _talkDirection = RIGHT; break; case PAT_TAKEUP_UP2: case PAT_TAKEUP_MID2: case PAT_TAKEUP_DOWN2: case PAT_STANDUP: - _TalkDirection = UP; + _talkDirection = UP; break; } @@ -596,7 +596,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body if (_bPastorella) { // Talking whilst a shepherdess mainFreeze(); - switch (_TalkDirection) { + switch (_talkDirection) { case UP: setPattern(PAT_PAST_TALKUP); break; @@ -626,7 +626,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body headStartPat = 0; bodyStartPat = 0; - switch (_TalkDirection) { + switch (_talkDirection) { case DOWN: headLoopPat = PAT_TALK_DOWN; bodyLoopPat = BPAT_STANDDOWN; @@ -655,7 +655,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case TALK_FIANCHI: _bCorpoDavanti = false; - switch (_TalkDirection) { + switch (_talkDirection) { case UP: _nBodyOffset.set(2, 42); headStartPat = PAT_TESTA_UP; @@ -701,7 +701,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case TALK_RIDE: _bCorpoDavanti = false; - switch (_TalkDirection) { + switch (_talkDirection) { case UP: case DOWN: case LEFT: @@ -724,7 +724,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case TALK_RIDE2: _bCorpoDavanti = false; - switch (_TalkDirection) { + switch (_talkDirection) { case UP: case DOWN: case LEFT: @@ -746,7 +746,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case TALK_SIINDICA: - switch (_TalkDirection) { + switch (_talkDirection) { case UP: case DOWN: case LEFT: @@ -764,7 +764,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case TALK_SPAVENTATO: - switch (_TalkDirection) { + switch (_talkDirection) { case UP: _nBodyOffset.set(-4, -11); headStartPat = PAT_TESTA_UP; @@ -801,7 +801,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case TALK_SPAVENTATO2: _bCorpoDavanti = false; - switch (_TalkDirection) { + switch (_talkDirection) { case UP: bodyStartPat = BPAT_STANDUP; bodyLoopPat = BPAT_STANDUP; @@ -867,7 +867,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case TALK_CONCONIGLIO: - switch (_TalkDirection) { + switch (_talkDirection) { case LEFT: case UP: _nBodyOffset.set(-21, -5); @@ -887,7 +887,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case TALK_CONRICETTA: - switch (_TalkDirection) { + switch (_talkDirection) { case LEFT: case UP: _nBodyOffset.set(-61, -7); @@ -907,7 +907,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case TALK_CONCARTE: - switch (_TalkDirection) { + switch (_talkDirection) { case LEFT: case UP: _nBodyOffset.set(-34, -2); @@ -927,7 +927,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case TALK_CONPUPAZZO: - switch (_TalkDirection) { + switch (_talkDirection) { case LEFT: case UP: _nBodyOffset.set(-35, 2); @@ -952,7 +952,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case TALK_CONCARTESTATIC: case TALK_WITH_NOTEBOOK: case TALK_CONMEGAFONOSTATIC: - switch (_TalkDirection) { + switch (_talkDirection) { case LEFT: case UP: headLoopPat = PAT_TALK_LEFT; @@ -967,7 +967,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body // The beard is the only case in which the head is animated separately while the body is the standard case TALK_CONBARBASTATIC: - switch (_TalkDirection) { + switch (_talkDirection) { case LEFT: case UP: headLoopPat = PAT_TALKBARBA_LEFT; @@ -985,7 +985,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case TALK_SCHIFATO: - switch (_TalkDirection) { + switch (_talkDirection) { case LEFT: case UP: _nBodyOffset.set(6, 56); @@ -1005,7 +1005,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case TALK_NAAH: - switch (_TalkDirection) { + switch (_talkDirection) { case LEFT: case UP: _nBodyOffset.set(6, 56); @@ -1072,7 +1072,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case TALK_SPAVENTATOSTATIC: _bCorpoDavanti = false; - switch (_TalkDirection) { + switch (_talkDirection) { case DOWN: bodyStartPat = BPAT_STANDDOWN; bodyLoopPat = BPAT_STANDDOWN; @@ -1151,7 +1151,7 @@ bool RMTony::endTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa bodyEndPat = 0; headEndPat = 0; - switch (_TalkDirection) { + switch (_talkDirection) { case UP: finalPat = PAT_STANDUP; headStandPat = PAT_TESTA_UP; @@ -1189,7 +1189,7 @@ bool RMTony::endTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa break; case TALK_FIANCHI: - switch (_TalkDirection) { + switch (_talkDirection) { case UP: bodyEndPat = BPAT_FIANCHIUP_END; break; @@ -1214,16 +1214,16 @@ bool RMTony::endTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa case TALK_RIDE: case TALK_RIDE2: - if (_TalkDirection == LEFT) + if (_talkDirection == LEFT) headEndPat = PAT_RIDELEFT_END; - else if (_TalkDirection == RIGHT) + else if (_talkDirection == RIGHT) headEndPat = PAT_RIDERIGHT_END; bodyEndPat = 0; break; case TALK_SCHIFATO: - switch (_TalkDirection) { + switch (_talkDirection) { case UP: case LEFT: headEndPat = PAT_SCHIFATOLEFT_END; @@ -1239,7 +1239,7 @@ bool RMTony::endTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa break; case TALK_NAAH: - switch (_TalkDirection) { + switch (_talkDirection) { case UP: case LEFT: headEndPat = PAT_NAAHLEFT_END; @@ -1258,7 +1258,7 @@ bool RMTony::endTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa break; case TALK_SPAVENTATO: - switch (_TalkDirection) { + switch (_talkDirection) { case UP: bodyEndPat = BPAT_SPAVENTOUP_END; break; @@ -1281,7 +1281,7 @@ bool RMTony::endTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa break; case TALK_SPAVENTATO2: - switch (_TalkDirection) { + switch (_talkDirection) { case UP: bodyEndPat = 0; break; @@ -1304,7 +1304,7 @@ bool RMTony::endTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa break; case TALK_CONCONIGLIO: - switch (_TalkDirection) { + switch (_talkDirection) { case UP: case LEFT: finalPat = PAT_STANDLEFT; @@ -1320,7 +1320,7 @@ bool RMTony::endTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa break; case TALK_CONRICETTA: - switch (_TalkDirection) { + switch (_talkDirection) { case UP: case LEFT: finalPat = PAT_STANDLEFT; @@ -1336,7 +1336,7 @@ bool RMTony::endTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa break; case TALK_CONCARTE: - switch (_TalkDirection) { + switch (_talkDirection) { case UP: case LEFT: finalPat = PAT_STANDLEFT; @@ -1352,7 +1352,7 @@ bool RMTony::endTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa break; case TALK_CONPUPAZZO: - switch (_TalkDirection) { + switch (_talkDirection) { case UP: case LEFT: finalPat = PAT_STANDLEFT; @@ -1395,7 +1395,7 @@ bool RMTony::endTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa break; case TALK_SPAVENTATOSTATIC: - switch (_TalkDirection) { + switch (_talkDirection) { case DOWN: headStandPat = PAT_SPAVENTODOWN_STAND; bodyEndPat = 0; @@ -1448,10 +1448,10 @@ void RMTony::endTalk(CORO_PARAM) { if (_nTalkType == TALK_CONBARBASTATIC) { mainFreeze(); setPattern(0); - if (_TalkDirection == UP || _TalkDirection == LEFT) { + if (_talkDirection == UP || _talkDirection == LEFT) { _body.setPattern(BPAT_CONBARBALEFT_STATIC); _nBodyOffset.set(-41, -14); - } else if (_TalkDirection == DOWN || _TalkDirection == RIGHT) { + } else if (_talkDirection == DOWN || _talkDirection == RIGHT) { _body.setPattern(BPAT_CONBARBARIGHT_STATIC); _nBodyOffset.set(-26, -14); } @@ -1526,7 +1526,7 @@ void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat switch (nPat) { case PAT_STANDDOWN: - _TalkDirection = DOWN; + _talkDirection = DOWN; headPat = PAT_TESTA_RIGHT; break; @@ -1535,7 +1535,7 @@ void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat case PAT_TAKELEFT_DOWN2: case PAT_SIRIALZALEFT: case PAT_STANDLEFT: - _TalkDirection = LEFT; + _talkDirection = LEFT; headPat = PAT_TESTA_LEFT; break; @@ -1544,7 +1544,7 @@ void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat case PAT_TAKERIGHT_DOWN2: case PAT_SIRIALZARIGHT: case PAT_STANDRIGHT: - _TalkDirection = RIGHT; + _talkDirection = RIGHT; headPat = PAT_TESTA_RIGHT; break; @@ -1552,7 +1552,7 @@ void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat case PAT_TAKEUP_MID2: case PAT_TAKEUP_DOWN2: case PAT_STANDUP: - _TalkDirection = UP; + _talkDirection = UP; headPat = PAT_TESTA_LEFT; break; } @@ -1561,7 +1561,7 @@ void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat switch (nTalk) { case TALK_CONCONIGLIOSTATIC: - switch (_TalkDirection) { + switch (_talkDirection) { case UP: case LEFT: _nBodyOffset.set(-21, -5); @@ -1579,7 +1579,7 @@ void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat break; case TALK_CONCARTESTATIC: - switch (_TalkDirection) { + switch (_talkDirection) { case UP: case LEFT: _nBodyOffset.set(-34, -2); @@ -1597,7 +1597,7 @@ void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat break; case TALK_CONRICETTASTATIC: - switch (_TalkDirection) { + switch (_talkDirection) { case UP: case LEFT: _nBodyOffset.set(-61, -7); @@ -1615,7 +1615,7 @@ void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat break; case TALK_CONPUPAZZOSTATIC: - switch (_TalkDirection) { + switch (_talkDirection) { case UP: case LEFT: _nBodyOffset.set(-35, 2); @@ -1633,7 +1633,7 @@ void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat break; case TALK_WITH_NOTEBOOK: - switch (_TalkDirection) { + switch (_talkDirection) { case UP: case LEFT: _nBodyOffset.set(-16, -9); @@ -1651,7 +1651,7 @@ void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat break; case TALK_CONMEGAFONOSTATIC: - switch (_TalkDirection) { + switch (_talkDirection) { case UP: case LEFT: _nBodyOffset.set(-41, -8); @@ -1669,7 +1669,7 @@ void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat break; case TALK_CONBARBASTATIC: - switch (_TalkDirection) { + switch (_talkDirection) { case UP: case LEFT: _nBodyOffset.set(-41, -14); @@ -1691,7 +1691,7 @@ void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat break; case TALK_SPAVENTATOSTATIC: - switch (_TalkDirection) { + switch (_talkDirection) { case DOWN: headPat = PAT_SPAVENTODOWN_START; bodyLoopPat = BPAT_STANDDOWN; @@ -1761,7 +1761,7 @@ void RMTony::startStatic(CORO_PARAM, TALKTYPE nTalk) { void RMTony::endStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, int &headEndPat) { - switch (_TalkDirection) { + switch (_talkDirection) { case UP: case LEFT: finalPat = PAT_STANDLEFT; @@ -1775,7 +1775,7 @@ void RMTony::endStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, switch (nTalk) { case TALK_CONPUPAZZOSTATIC: - switch (_TalkDirection) { + switch (_talkDirection) { case UP: case LEFT: bodyEndPat = BPAT_CONPUPAZZOLEFT_END; @@ -1789,7 +1789,7 @@ void RMTony::endStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, break; case TALK_CONRICETTASTATIC: - switch (_TalkDirection) { + switch (_talkDirection) { case UP: case LEFT: bodyEndPat = BPAT_CONRICETTALEFT_END; @@ -1803,7 +1803,7 @@ void RMTony::endStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, break; case TALK_CONCONIGLIOSTATIC: - switch (_TalkDirection) { + switch (_talkDirection) { case UP: case LEFT: bodyEndPat = BPAT_CONCONIGLIOLEFT_END; @@ -1817,7 +1817,7 @@ void RMTony::endStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, break; case TALK_CONCARTESTATIC: - switch (_TalkDirection) { + switch (_talkDirection) { case UP: case LEFT: bodyEndPat = BPAT_CONCARTELEFT_END; @@ -1831,7 +1831,7 @@ void RMTony::endStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, break; case TALK_WITH_NOTEBOOK: - switch (_TalkDirection) { + switch (_talkDirection) { case UP: case LEFT: bodyEndPat = BPAT_CONTACCUINOLEFT_END; @@ -1845,7 +1845,7 @@ void RMTony::endStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, break; case TALK_CONMEGAFONOSTATIC: - switch (_TalkDirection) { + switch (_talkDirection) { case UP: case LEFT: bodyEndPat = BPAT_CONMEGAFONOLEFT_END; @@ -1859,7 +1859,7 @@ void RMTony::endStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, break; case TALK_CONBARBASTATIC: - switch (_TalkDirection) { + switch (_talkDirection) { case UP: case LEFT: bodyEndPat = BPAT_CONBARBALEFT_END; @@ -1873,7 +1873,7 @@ void RMTony::endStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, break; case TALK_SPAVENTATOSTATIC: - switch (_TalkDirection) { + switch (_talkDirection) { case LEFT: headEndPat = PAT_SPAVENTOLEFT_END; break; diff --git a/engines/tony/tonychar.h b/engines/tony/tonychar.h index 4e0a0f0d93..6ba66729a9 100644 --- a/engines/tony/tonychar.h +++ b/engines/tony/tonychar.h @@ -86,9 +86,9 @@ private: bool _bCorpoDavanti; RMGfxSourceBuffer8AB _ombra; bool _bActionPending; - RMItem *_ActionItem; - int _Action; - int _ActionParm; + RMItem *_actionItem; + int _action; + int _actionParm; static bool _bAction; bool _bPastorella; @@ -97,13 +97,13 @@ private: bool _bIsTalking; int _nPatB4Talking; TALKTYPE _nTalkType; - DIRECTION _TalkDirection; + DIRECTION _talkDirection; RMPoint _nBodyOffset; int _nTimeLastStep; RMItem _body; - uint32 hActionThread; + uint32 _hActionThread; protected: // Overload of the allocation allocation of sprites @@ -397,7 +397,7 @@ public: // Check if currently in an action bool inAction() { - return (_bActionPending && _Action != 0) | _bAction; + return (_bActionPending && _action != 0) | _bAction; } // Check if there needs to be an update for scrolling movement -- cgit v1.2.3 From 34a7c7be984e6d47d83ce71af93402281039405d Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 11 Jun 2012 22:22:46 +0200 Subject: TONY: Rename a remaining variable in loc.h --- engines/tony/loc.cpp | 32 ++++++++++++++++---------------- engines/tony/loc.h | 2 +- 2 files changed, 17 insertions(+), 17 deletions(-) (limited to 'engines') diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 9c032fe6be..e70d15695e 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -962,11 +962,11 @@ short RMCharacter::findPath(short source, short destination) { cur = _theBoxes->getBoxes(_curLocation); // Make a backup copy to work on - for (i = 0; i < cur->numbbox; i++) + for (i = 0; i < cur->_numbBox; i++) memcpy(&BOX[i], &cur->_boxes[i], sizeof(RMBox)); // Invalidate all nodes - for (i = 0; i < cur->numbbox; i++) + for (i = 0; i < cur->_numbBox; i++) VALIDO[i] = 0; // Prepare source and variables for the procedure @@ -980,14 +980,14 @@ short RMCharacter::findPath(short source, short destination) { errore = 1; // Possible error // 1st cycle: explore possible new nodes - for (i = 0; i < cur->numbbox; i++) + for (i = 0; i < cur->_numbBox; i++) if (VALIDO[i] == 1) { errore = 0; // Failure de-bunked j = 0; - while (((BOX[i]._adj[j]) != 1) && (j < cur->numbbox)) + while (((BOX[i]._adj[j]) != 1) && (j < cur->_numbBox)) j++; - if (j >= cur->numbbox) + if (j >= cur->_numbBox) VALIDO[i] = 2; // nodo saturated? else { NEXT[i] = j; @@ -1000,12 +1000,12 @@ short RMCharacter::findPath(short source, short destination) { fine = 1; // All nodes saturated // 2nd cycle: adding new nodes that were found, saturate old nodes - for (i = 0; i < cur->numbbox; i++) + for (i = 0; i < cur->_numbBox; i++) if ((VALIDO[i] == 1) && ((COSTO[i] + 1) == costominimo)) { BOX[i]._adj[NEXT[i]] = 2; COSTO[NEXT[i]] = costominimo; VALIDO[NEXT[i]] = 1; - for (j = 0; j < cur->numbbox; j++) + for (j = 0; j < cur->_numbBox; j++) if (BOX[j]._adj[NEXT[i]] == 1) BOX[j]._adj[NEXT[i]] = 0; @@ -1762,13 +1762,13 @@ void RMBoxLoc::readFromStream(RMDataStream &ds) { assert(ver == 3); // Number of boxes - ds >> numbbox; + ds >> _numbBox; // Allocate memory for the boxes - _boxes = new RMBox[numbbox]; + _boxes = new RMBox[_numbBox]; // Read in boxes - for (i = 0; i < numbbox; i++) + for (i = 0; i < _numbBox; i++) ds >> _boxes[i]; } @@ -1776,7 +1776,7 @@ void RMBoxLoc::readFromStream(RMDataStream &ds) { void RMBoxLoc::recalcAllAdj(void) { int i, j; - for (i = 0; i < numbbox; i++) { + for (i = 0; i < _numbBox; i++) { Common::fill(_boxes[i]._adj, _boxes[i]._adj + MAXBOXES, 0); for (j = 0; j < _boxes[i]._numHotspot; j++) @@ -1850,7 +1850,7 @@ int RMGameBoxes::whichBox(int nLoc, const RMPoint &punto) { if (!cur) return -1; - for (i = 0; i < cur->numbbox; i++) + for (i = 0; i < cur->_numbBox; i++) if (cur->_boxes[i]._attivo) if ((punto._x >= cur->_boxes[i]._left) && (punto._x <= cur->_boxes[i]._right) && (punto._y >= cur->_boxes[i]._top) && (punto._y <= cur->_boxes[i]._bottom)) @@ -1873,7 +1873,7 @@ int RMGameBoxes::getSaveStateSize(void) { for (i = 1; i <= _nLocBoxes; i++) { size += 4; - size += _allBoxes[i]->numbbox; + size += _allBoxes[i]->_numbBox; } return size; @@ -1888,10 +1888,10 @@ void RMGameBoxes::saveState(byte *state) { // For each location, write out the number of boxes and their status for (i = 1; i <= _nLocBoxes; i++) { - WRITE_LE_UINT32(state, _allBoxes[i]->numbbox); + WRITE_LE_UINT32(state, _allBoxes[i]->_numbBox); state += 4; - for (j = 0; j < _allBoxes[i]->numbbox; j++) + for (j = 0; j < _allBoxes[i]->_numbBox; j++) *state++ = _allBoxes[i]->_boxes[j]._attivo; } } @@ -1912,7 +1912,7 @@ void RMGameBoxes::loadState(byte *state) { state += 4; for (j = 0; j < nbox ; j++) { - if (j < _allBoxes[i]->numbbox) + if (j < _allBoxes[i]->_numbBox) _allBoxes[i]->_boxes[j]._attivo = *state; state++; diff --git a/engines/tony/loc.h b/engines/tony/loc.h index 79eb936d9b..7fe02a4f54 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -339,7 +339,7 @@ public: class RMBoxLoc { public: - int numbbox; + int _numbBox; RMBox *_boxes; private: -- cgit v1.2.3 From 985602a72d52acdb99599eaddbed7f7b9fce01ce Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 12 Jun 2012 00:07:50 +0200 Subject: TONY: Rename some Italian into English --- engines/tony/adv.h | 4 +- engines/tony/custom.cpp | 8 +-- engines/tony/game.cpp | 4 +- engines/tony/gfxengine.cpp | 4 +- engines/tony/gfxengine.h | 4 +- engines/tony/globals.cpp | 2 +- engines/tony/globals.h | 2 +- engines/tony/input.h | 2 +- engines/tony/inventory.cpp | 15 +++--- engines/tony/inventory.h | 6 +-- engines/tony/loc.cpp | 16 +++--- engines/tony/loc.h | 2 +- engines/tony/resid.h | 2 +- engines/tony/sound.h | 121 +++++++++++++++++++-------------------------- engines/tony/tonychar.cpp | 2 +- engines/tony/window.cpp | 2 +- 16 files changed, 89 insertions(+), 107 deletions(-) (limited to 'engines') diff --git a/engines/tony/adv.h b/engines/tony/adv.h index 0bdef25ea8..b2d61a5da5 100644 --- a/engines/tony/adv.h +++ b/engines/tony/adv.h @@ -55,7 +55,7 @@ enum RMTonyAction { TA_USE, TA_EXAMINE, TA_TALK, - TA_PALESATI, + TA_PERORATE, TA_COMBINE = 10, TA_RECEIVECOMBINE, @@ -80,7 +80,7 @@ void mainCloseWipe(void); void mainWaitWipeEnd(CORO_PARAM); void mainEnableGUI(void); void mainDisableGUI(void); -void mainSetPalesati(bool bPalesati); +void mainSetPerorate(bool bPerorate); } // End of namespace Tony diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 0cf40e5a14..964e506099 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -184,8 +184,8 @@ DECLARE_CUSTOM_FUNCTION(RightToMe)(CORO_PARAM, uint32, uint32, uint32, uint32) { } -DECLARE_CUSTOM_FUNCTION(TonySetPalesati)(CORO_PARAM, uint32 bStatus, uint32, uint32, uint32) { - GLOBALS.SetPalesati(bStatus); +DECLARE_CUSTOM_FUNCTION(TonySetPerorate)(CORO_PARAM, uint32 bStatus, uint32, uint32, uint32) { + GLOBALS.SetPerorate(bStatus); } DECLARE_CUSTOM_FUNCTION(MySleep)(CORO_PARAM, uint32 dwTime, uint32, uint32, uint32) { @@ -2529,7 +2529,7 @@ ASSIGN(134, CustEnableGUI) ASSIGN(135, CustDisableGUI) ASSIGN(136, ClearScreen) ASSIGN(137, PatIrqFreeze) -ASSIGN(138, TonySetPalesati) +ASSIGN(138, TonySetPerorate) ASSIGN(139, OpenInitLoadMenu) ASSIGN(140, OpenInitOptions) ASSIGN(141, SyncScrollLocation) @@ -2562,7 +2562,7 @@ void setupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation GLOBALS.WaitWipeEnd = mainWaitWipeEnd; GLOBALS.DisableGUI = mainDisableGUI; GLOBALS.EnableGUI = mainEnableGUI; - GLOBALS.SetPalesati = mainSetPalesati; + GLOBALS.SetPerorate = mainSetPerorate; GLOBALS._bAlwaysDisplay = false; int i; diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 9fc65aa87d..0ccd2d8dc8 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -114,8 +114,8 @@ void mainDisableGUI(void) { _vm->getEngine()->_bGUIOption = false; } -void mainSetPalesati(bool bPalesati) { - _vm->getEngine()->setPalesati(bPalesati); +void mainSetPerorate(bool bPerorate) { + _vm->getEngine()->setPerorate(bPerorate); } /****************************************************************************\ diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 8daf49c4a5..4c09e16678 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -645,7 +645,7 @@ void RMGfxEngine::saveState(const Common::String &fn, byte *curThumb, const Comm // Saves the state of the shepherdess and show yourself bStat = _tony.getPastorella(); f->writeByte(bStat); - bStat = _inter.getPalesati(); + bStat = _inter.getPerorate(); f->writeByte(bStat); // Save the chars @@ -781,7 +781,7 @@ void RMGfxEngine::loadState(CORO_PARAM, const Common::String &fn) { bStat = _ctx->f->readByte(); _tony.setPastorella(bStat); bStat = _ctx->f->readByte(); - _inter.setPalesati(bStat); + _inter.setPerorate(bStat); CharsLoadAll(_ctx->f); } diff --git a/engines/tony/gfxengine.h b/engines/tony/gfxengine.h index 8d9648c454..18c13d8d3d 100644 --- a/engines/tony/gfxengine.h +++ b/engines/tony/gfxengine.h @@ -144,8 +144,8 @@ public: void closeWipe(void); void waitWipeEnd(CORO_PARAM); - void setPalesati(bool bpal) { - _inter.setPalesati(bpal); + void setPerorate(bool bpal) { + _inter.setPerorate(bpal); } bool canLoadSave(); }; diff --git a/engines/tony/globals.cpp b/engines/tony/globals.cpp index e676f33174..e3d36db11b 100644 --- a/engines/tony/globals.cpp +++ b/engines/tony/globals.cpp @@ -54,7 +54,7 @@ Globals::Globals() { InitWipe = NULL; EnableGUI = NULL; DisableGUI = NULL; - SetPalesati = NULL; + SetPerorate = NULL; _dwTonyNumTexts = 0; _bTonyInTexts = false; diff --git a/engines/tony/globals.h b/engines/tony/globals.h index e924678df0..24825588e1 100644 --- a/engines/tony/globals.h +++ b/engines/tony/globals.h @@ -232,7 +232,7 @@ public: void (*InitWipe)(int type); void (*EnableGUI)(void); void (*DisableGUI)(void); - void (*SetPalesati)(bool bpal); + void (*SetPerorate)(bool bpal); uint32 _dwTonyNumTexts; bool _bTonyInTexts; diff --git a/engines/tony/input.h b/engines/tony/input.h index e7e200e1b7..fd194d0fc5 100644 --- a/engines/tony/input.h +++ b/engines/tony/input.h @@ -47,7 +47,7 @@ private: // Keyboard related fields bool _keyDown[350]; private: - // Deinizializza DirectInput + // Deinitialize DirectInput void DIClose(void); public: diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index de8b21748e..f29713adbd 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -770,7 +770,8 @@ int RMInterface::onWhichBox(RMPoint pt) { // Check how many verbs you have to consider max = 4; - if (_bPalesati) max = 5; + if (_bPerorate) + max = 5; // Find the verb for (i = 0; i < max; i++) @@ -867,7 +868,7 @@ bool RMInterface::released(const RMPoint &mousepos, RMTonyAction &action) { break; case 4: - action = TA_PALESATI; + action = TA_PERORATE; break; default: // No verb @@ -881,12 +882,12 @@ void RMInterface::reset(void) { _bActive = false; } -void RMInterface::setPalesati(bool bOn) { - _bPalesati = bOn; +void RMInterface::setPerorate(bool bOn) { + _bPerorate = bOn; } -bool RMInterface::getPalesati(void) { - return _bPalesati; +bool RMInterface::getPerorate(void) { + return _bPerorate; } void RMInterface::init(void) { @@ -932,7 +933,7 @@ void RMInterface::init(void) { _hints[4].writeText(msg4[0], 1); // Show Yourself _bActive = false; - _bPalesati = false; + _bPerorate = false; _lastHotZone = 0; } diff --git a/engines/tony/inventory.h b/engines/tony/inventory.h index 2b6248f7eb..5bf35e6eb0 100644 --- a/engines/tony/inventory.h +++ b/engines/tony/inventory.h @@ -161,7 +161,7 @@ private: RMText _hints[5]; RMGfxSourceBuffer8RLEByte _hotzone[5]; RMRect _hotbbox[5]; - bool _bPalesati; + bool _bPerorate; int _lastHotZone; protected: @@ -189,8 +189,8 @@ public: bool released(const RMPoint &mousepos, RMTonyAction &action); // Enalbes or disables the fifth verb - void setPalesati(bool bOn); - bool getPalesati(void); + void setPerorate(bool bOn); + bool getPerorate(void); // Overloaded Draw virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index e70d15695e..b2bf3b3565 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -889,7 +889,7 @@ void RMWipe::initFade(int type) { _bMustRegister = true; - RMRes res(RES_W_CERCHIO); + RMRes res(RES_W_CIRCLE); RMDataStream ds; ds.openBuffer(res); @@ -1456,7 +1456,7 @@ void RMCharacter::doFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc) { // If we still have to go through a box if (_pathCount < _pathLength) { // Check if the box we're going into is active - if (_ctx->cur->_boxes[_path[_pathCount - 1]]._attivo) { + if (_ctx->cur->_boxes[_path[_pathCount - 1]]._bActive) { // Move in a straight line towards the nearest hotspot, taking into account the reversing // NEWBOX = path[pathcount-1] CORO_INVOKE_2(goTo, nearestHotSpot(_path[_pathCount - 1], _path[_pathCount]), _ctx->cur->_boxes[_path[_pathCount - 1]]._bReversed); @@ -1715,7 +1715,7 @@ void RMBox::readFromStream(RMDataStream &ds) { ds >> _numHotspot; ds >> _destZ; ds >> b; - _attivo = b; + _bActive = b; ds >> b; _bReversed = b; @@ -1780,7 +1780,7 @@ void RMBoxLoc::recalcAllAdj(void) { Common::fill(_boxes[i]._adj, _boxes[i]._adj + MAXBOXES, 0); for (j = 0; j < _boxes[i]._numHotspot; j++) - if (_boxes[_boxes[i]._hotspot[j]._destination]._attivo) + if (_boxes[_boxes[i]._hotspot[j]._destination]._bActive) _boxes[i]._adj[_boxes[i]._hotspot[j]._destination] = 1; } } @@ -1851,7 +1851,7 @@ int RMGameBoxes::whichBox(int nLoc, const RMPoint &punto) { return -1; for (i = 0; i < cur->_numbBox; i++) - if (cur->_boxes[i]._attivo) + if (cur->_boxes[i]._bActive) if ((punto._x >= cur->_boxes[i]._left) && (punto._x <= cur->_boxes[i]._right) && (punto._y >= cur->_boxes[i]._top) && (punto._y <= cur->_boxes[i]._bottom)) return i; @@ -1860,7 +1860,7 @@ int RMGameBoxes::whichBox(int nLoc, const RMPoint &punto) { } void RMGameBoxes::changeBoxStatus(int nLoc, int nBox, int status) { - _allBoxes[nLoc]->_boxes[nBox]._attivo = status; + _allBoxes[nLoc]->_boxes[nBox]._bActive = status; _allBoxes[nLoc]->recalcAllAdj(); } @@ -1892,7 +1892,7 @@ void RMGameBoxes::saveState(byte *state) { state += 4; for (j = 0; j < _allBoxes[i]->_numbBox; j++) - *state++ = _allBoxes[i]->_boxes[j]._attivo; + *state++ = _allBoxes[i]->_boxes[j]._bActive; } } @@ -1913,7 +1913,7 @@ void RMGameBoxes::loadState(byte *state) { for (j = 0; j < nbox ; j++) { if (j < _allBoxes[i]->_numbBox) - _allBoxes[i]->_boxes[j]._attivo = *state; + _allBoxes[i]->_boxes[j]._bActive = *state; state++; } diff --git a/engines/tony/loc.h b/engines/tony/loc.h index 7fe02a4f54..4231c99eab 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -326,7 +326,7 @@ public: uint8 _destZ; // Z value for the bounding box T_HOTSPOT _hotspot[MAXHOTSPOT]; // List of hotspots - bool _attivo; + bool _bActive; bool _bReversed; private: diff --git a/engines/tony/resid.h b/engines/tony/resid.h index 5215801d5d..7f2dc7bb54 100644 --- a/engines/tony/resid.h +++ b/engines/tony/resid.h @@ -68,6 +68,6 @@ #define RES_F_CREDITS 10704 #define RES_F_CPAL 10705 -#define RES_W_CERCHIO 10800 +#define RES_W_CIRCLE 10800 #endif diff --git a/engines/tony/sound.h b/engines/tony/sound.h index 6593470d0c..4669dff568 100644 --- a/engines/tony/sound.h +++ b/engines/tony/sound.h @@ -65,7 +65,7 @@ private: bool bSoundSupported; /****************************************************************************\ - * Metodi + * Methods \****************************************************************************/ public: @@ -74,105 +74,95 @@ public: * * Function: FPSOUND::FPSOUND(); * - * Description: Costruttore di default. Inizializza gli attributi. + * Description: Default constructor. Initializes the attributes * \****************************************************************************/ FPSOUND(); - /****************************************************************************\ * * Function: FPSOUND::~FPSOUND(); * - * Description: Deinizializza l'oggetto, disallocando la memoria. + * Description: Deinitialize the object, free memory * \****************************************************************************/ ~FPSOUND(); - /****************************************************************************\ * * Function: bool FPSOUND::Init(); * - * Description: Inizializza l'oggetto, e prepara tutto il necessario per - * creare stream e effetti sonori. + * Description: Initializes the objects, and prepare everything required to + * create streams and sound effects. * - * Return: True se tutto OK, FALSE in caso di errore. + * Return: True if everything is OK, False otherwise. * \****************************************************************************/ - bool Init(); - /****************************************************************************\ * * Function: bool CreateStream(FPSTREAM** lplpStream); * - * Description: Alloca un oggetti di tipo FPSTREAM, e ritorna il suo - * puntatore dopo averlo inizializzato. + * Description: Allocates an object of type FPSTREAM, and return its + * pointer after it has been initialized. * - * Input: FPSTREAM** lplpStream Conterra' il pointer all'oggetto - * appena creato. + * Input: FPSTREAM** lplpStream Will contain the pointer of the + * object * - * Return: TRUE se tutto OK, FALSE in caso di errore - * - * Note: L'utilizzo di funzioni del tipo CreateStream(), CreateSfx(), - * sono dovute al fatto che i costruttori delle classi FPSTREAM - * e FPSFX richiedono che DirectSound sia gia' stato - * inzializzato. In questo modo quindi si evitano dei bugs - * che si verrebbero a creare se venisse dichiarata un oggetto - * di tipo FPSTREAM o FPSFX globale (o cmq prima della - * inizializzazione di DirectSound). + * Return: True is everything i OK, False otherwise * + * Note: The use of functions like CreateStream () and CreateSfx () + * are due to the fact that the class constructors and + * FPSTREAM FPSFX require that DirectSound is already initialized. + * In this way, you avoid the bugs that would be created if an + * object type is declared FPSTREAM FPSFX or global + * (or anyway before initializing DirectSound). \****************************************************************************/ bool CreateStream(FPSTREAM **lplpStream); - - /****************************************************************************\ * * Function: bool CreateSfx(FPSFX** lplpSfx); * - * Description: Alloca un oggetti di tipo FPSFX e ritorna il suo - * puntatore dopo averlo inizializzato. + * Description: Allocates an object of type FPSFX and returns a pointer + * pointing to it * - * Input: FPSFX** lplpSfx Conterra' il pointer all'oggetto - * appena creato. + * Input: FPSFX** lplpSfx Will contain the pointer of the + * object * - * Return: TRUE se tutto OK, FALSE in caso di errore + * Return: True is everything i OK, False otherwise * - * Note: Vedi le note di CreateStream() + * Note: See notes about CreateStream() * \****************************************************************************/ bool CreateSfx(FPSFX **lplpSfx); - - /****************************************************************************\ * * Function: void SetMasterVolume(int dwVolume); * - * Description: Setta il volume generale + * Description: Set main volume * - * Input: int dwVolume Volume da settare (0-63) + * Input: int dwVolume Volume to be set (0-63) * \****************************************************************************/ void SetMasterVolume(int dwVolume); - /****************************************************************************\ * * Function: void GetMasterVolume(LPINT lpdwVolume); * - * Description: Richiede il volume generale + * Description: Get main volume * - * Input: LPINT lpdwVolume Variabile che conterra' il volume (0-63) + * Input: LPINT lpdwVolume This variable will contain the + * current volume (0-63) * \****************************************************************************/ @@ -182,13 +172,13 @@ public: class FPSFX { /****************************************************************************\ - * Attributi + * Attributes \****************************************************************************/ private: - bool bSoundSupported; // TRUE se il suono e' attivo - bool bFileLoaded; // TRUE se e' stato aperto un file - bool bLoop; // TRUE se bisogna loopare l'effetto sonoro + bool bSoundSupported; // True if the sound is active + bool bFileLoaded; // True is a file is opened + bool bLoop; // True is sound effect should loop int lastVolume; bool bIsVoice; @@ -205,7 +195,7 @@ private: /****************************************************************************\ - * Metodi + * Methods \****************************************************************************/ public: @@ -218,54 +208,49 @@ public: * * Function: FPSFX(bool bSoundOn); * - * Description: Costruttore di default. *NON* bisogna dichiarare direttamente - * un oggetto, ma crearlo piuttosto tramite FPSOUND::CreateSfx() + * Description: Default constructor. *DO NOT* declare the object directly, + * create it though FPSOUND::CreateSfx() instead * \****************************************************************************/ FPSFX(bool bSoundOn); - /****************************************************************************\ * * Function: ~FPSFX(); * - * Description: Distruttore di default. Si preoccupa anche di fermare il sound - * effect eventualmente in esecuzione, e disallocare la memoria - * da esso occupata. + * Description: Default destructor. It also stops the sound effect that + * may be running, and free the memory used. * \****************************************************************************/ ~FPSFX(); - /****************************************************************************\ * * Function: Release(); * - * Description: Rilascia la memoria dell'oggetto. Deve essere richiamata quando - * l'oggetto non serve piu' e **SOLO SE** l'oggetto e' stato - * creato con la FPSOUND::CreateStream(). + * Description: Releases the memory object. Must be called when the object + * is no longer useful and **ONLY** when the object was created + * with the FPSOUND :: CreateStream (). * - * Note: Eventuali puntatori all'oggetto non sono piu' validi dopo - * questa chiamata. + * Note: Any object pointers are no longer valid after this call. * \****************************************************************************/ void Release(); - /****************************************************************************\ * * Function: bool LoadFile(char *lpszFileName, uint32 dwCodec=FPCODEC_RAW); * - * Description: Apre un file di effetto sonoro e lo carica. + * Description: Opens a file and load sound effect * - * Input: char *lpszFile Nome del file di sfx da aprire - * uint32 dwCodec CODEC da utilizzare per decomprimere - * i campioni sonori + * Input: char *lpszFile SFX filename + * uint32 dwCodec CODEC to be used to decompress + * the sound samples * - * Return: TRUE se tutto OK, FALSE in caso di errore + * Return: True if everything is OK, False otherwise * \****************************************************************************/ @@ -273,44 +258,40 @@ public: bool loadWave(Common::SeekableReadStream *stream); bool LoadVoiceFromVDB(Common::File &vdbFP); - /****************************************************************************\ * * Function: bool Play(); * - * Description: Suona lo sfx caricato. + * Description: Play the loaded FX. * - * Return: TRUE se tutto OK, FALSE in caso di errore. + * Return: True if everything is OK, False otherwise * \****************************************************************************/ bool Play(); - /****************************************************************************\ * * Function: bool Stop(); * - * Description: Ferma il play dello sfx. + * Description: Stop a FX * - * Return: TRUE se tutto OK, FALSE in caso di errore. + * Return: True if everything is OK, False otherwise * \****************************************************************************/ bool Stop(); - /****************************************************************************\ * * Function: void Pause(bool bPause); * - * Description: Pause dell'effetto sonoro + * Description: Pause a FX * \****************************************************************************/ void Pause(bool bPause); - /****************************************************************************\ * * Function: bool SetLoop(bool bLoop); diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index 5d2c4d37bc..e384dfe794 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -272,7 +272,7 @@ void RMTony::executeAction(int nAction, int nActionItem, int nParm) { _bAction = true; CoroScheduler.createProcess(waitEndOfAction, &pid, sizeof(uint32)); _hActionThread = pid; - } else if (nAction == TA_PALESATI) { + } else if (nAction == TA_PERORATE) { pid = mpalQueryDoAction(7, 1, 0); _bAction = true; CoroScheduler.createProcess(waitEndOfAction, &pid, sizeof(uint32)); diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index cfa9d088e3..db21be0ded 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -55,7 +55,7 @@ void RMWindow::init() { Graphics::PixelFormat pixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0); initGraphics(RM_SX, RM_SY, true, &pixelFormat); - // Inizializza i conteggi degli FPS + // Initialize FPS counters fps = lastfcount = fcount = lastsecond = 0; _bGrabScreenshot = false; -- cgit v1.2.3 From b8282316712c1969d9f7e8c1d80a673eeb4b2ced Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 12 Jun 2012 08:03:51 +0200 Subject: TONY: Translate some more comments into English --- engines/tony/gfxcore.cpp | 13 ++--- engines/tony/gfxcore.h | 2 +- engines/tony/sound.h | 138 ++++++++++++++++++++--------------------------- engines/tony/utils.cpp | 2 +- 4 files changed, 64 insertions(+), 91 deletions(-) (limited to 'engines') diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 8be4cbd5f5..83769ee78b 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -837,7 +837,7 @@ void RMGfxSourceBuffer8RLE::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPri x1 = (prim->getDst()._x1 + _dimx - 1) - u; for (y = 0; y < height; y++) { - // Decompressione + // Decompression RLEDecompressLineFlipped(buf + x1, src + 2, u, width); // Next line @@ -1379,7 +1379,7 @@ RLEWordFlippedDoCopy2: } /****************************************************************************\ -* Metodi di RMGfxSourceBuffer8RLEWord +* Methods for RMGfxSourceBuffer8RLEWord \****************************************************************************/ RMGfxSourceBuffer8RLEWordAB::~RMGfxSourceBuffer8RLEWordAB() { @@ -1526,7 +1526,7 @@ RLEWordDoCopy2: /****************************************************************************\ -* Metodi di RMGfxSourceBuffer8AA +* Methods for RMGfxSourceBuffer8AA \****************************************************************************/ byte RMGfxSourceBuffer8AA::_megaAABuf[256 * 1024]; @@ -1542,9 +1542,6 @@ void RMGfxSourceBuffer8AA::prepareImage(void) { void RMGfxSourceBuffer8AA::calculateAA(void) { - // I suck, you suck, he sucks, we suck, they all suck ---> ANTI ALIASING SUX! - // ************************************************************ - int x, y; byte *src, *srcaa; @@ -1631,7 +1628,7 @@ void RMGfxSourceBuffer8AA::drawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri // x1 = prim->Dst().x1; - // Poisition into the destination buffer + // Position into the destination buffer buf = bigBuf; buf += y1 * bigBuf.getDimx(); @@ -1710,7 +1707,7 @@ void RMGfxSourceBuffer8AA::drawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri mybuf[0] = (r << 10) | (g << 5) | b; } - // Skippa alla linea successiva + // Skip to the next line buf += bigBuf.getDimx(); } } diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index 17ad303fbd..9a00ed1646 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -36,7 +36,7 @@ namespace Tony { /****************************************************************************\ -* Prototipi di classi +* Class prototype \****************************************************************************/ // Class Name Family Treee Abstract? diff --git a/engines/tony/sound.h b/engines/tony/sound.h index 4669dff568..8f4a509930 100644 --- a/engines/tony/sound.h +++ b/engines/tony/sound.h @@ -296,44 +296,37 @@ public: * * Function: bool SetLoop(bool bLoop); * - * Description: Attiva o disattiva il loop dello sfx. + * Description: Enables or disables SFX loop * - * Input: bool bLoop TRUE per attivare il loop, FALSE per - * disattivarlo + * Input: bool bLoop True to activate the loop, else False * - * Note: Il loop deve essere attivato PRIMA di eseguire il play - * dello sfx. Qualsiasi modifica effettuata durante il play - * non avra' effetto fino a che lo sfx non viene fermato, - * e poi rimesso in play. + * Note: The loop must be activated before the SFX starts to play, + * else the effect will only be noticable next time the SFX is + * played * \****************************************************************************/ void SetLoop(bool bLoop); - - /****************************************************************************\ * * Function: void SetVolume(int dwVolume); * - * Description: Cambia il volume dello sfx + * Description: Set SFX Volume * - * Input: int dwVolume Volume da settare (0-63) + * Input: int dwVolume Volume to set (0-63) * \****************************************************************************/ void SetVolume(int dwVolume); - - /****************************************************************************\ * * Function: void GetVolume(int * lpdwVolume); * - * Description: Chiede il volume dello sfx + * Description: Get SFX volume * - * Input: int * lpdwVolume Variabile in cui verra' inserito - * il volume corrente + * Input: int * lpdwVolume Will contain the current volume * \****************************************************************************/ @@ -348,7 +341,7 @@ public: class FPSTREAM { /****************************************************************************\ - * Attributi + * Attributes \****************************************************************************/ private: @@ -356,26 +349,26 @@ private: /* HWND hwnd; LPDIRECTSOUND lpDS; - LPDIRECTSOUNDBUFFER lpDSBuffer; // Buffer DirectSound circolare - LPDIRECTSOUNDNOTIFY lpDSNotify; // Notify degli hotspot nel buffer + LPDIRECTSOUNDBUFFER lpDSBuffer; // DirectSound circular buffer + LPDIRECTSOUNDNOTIFY lpDSNotify; // Notify hotspots in the buffer */ - byte *lpTempBuffer; // Buffer temporaneo per decompressione + byte *lpTempBuffer; // Temporary buffer use for decompression - uint32 dwBufferSize; // Dimensione del buffer in bytes - uint32 dwSize; // Dimensione dello stream in bytes - uint32 dwCodec; // CODEC utilizzato + uint32 dwBufferSize; // Buffer size (bytes) + uint32 dwSize; // Stream size (bytes) + uint32 dwCodec; // CODEC used - HANDLE hThreadEnd; // Evento per chiudere il thread - Common::File _file; // Handle del file di stream - HANDLE hPlayThread; // Handle del thread di play - HANDLE hHot1, hHot2, hHot3; // Eventi settati da DirectSoundNotify + HANDLE hThreadEnd; // Event used to close thread + Common::File _file; // File handle used for the stream + HANDLE hPlayThread; // Handle of the Play thread + HANDLE hHot1, hHot2, hHot3; // Events set by DirectSoundNotify HANDLE hPlayThread_PlayFast; HANDLE hPlayThread_PlayNormal; - bool bSoundSupported; // TRUE se il suono e' attivo - bool bFileLoaded; // TRUE se e' stato aperto un file - bool bLoop; // TRUE se bisogna loopare lo stream - bool bDoFadeOut; // TRUE se bisogna fare un fade out + bool bSoundSupported; // True if the sound is active + bool bFileLoaded; // True if the file is open + bool bLoop; // True if the stream should loop + bool bDoFadeOut; // True if fade out is required bool bSyncExit; bool bPaused; int lastVolume; @@ -385,14 +378,14 @@ private: bool CreateBuffer(int nBufSize); public: - bool bIsPlaying; // TRUE se si sta playando lo stream + bool bIsPlaying; // True if the stream is playing private: static void PlayThread(FPSTREAM *This); /****************************************************************************\ - * Metodi + * Methods \****************************************************************************/ public: @@ -401,84 +394,75 @@ public: * * Function: FPSTREAM(bool bSoundOn); * - * Description: Costruttore di default. *NON* bisogna dichiarare direttamente - * un oggetto, ma crearlo piuttosto tramite FPSOUND::CreateStream() + * Description: Default contractor. *DO NOT* declare the object directly: use + * FPSOUND::CreateStream() indtead * \****************************************************************************/ FPSTREAM(bool bSoundOn); - /****************************************************************************\ * * Function: ~FPSTREAM(); * - * Description: Distruttore di default. Si preoccupa anche di fermare stream - * eventualmente in esecuzione, e disallocare la memoria da - * essi occupata. + * Description: Destructor by default. Stops the playing stream (if any) and + * frees the memory used by them * \****************************************************************************/ ~FPSTREAM(); - /****************************************************************************\ * * Function: Release(); * - * Description: Rilascia la memoria dell'oggetto. Deve essere richiamata quando - * l'oggetto non serve piu' e **SOLO SE** l'oggetto e' stato - * creato con la FPSOUND::CreateStream(). + * Description: Releases memory used by object. Must be used when the object + * is no longer used. *ONLY*for objects created by + * FPSOUND::CreateStream(). * - * Note: Eventuali puntatori all'oggetto non sono piu' validi dopo - * questa chiamata. + * Note: Object pointers are no longer valid after this call. * \****************************************************************************/ void Release(); - /****************************************************************************\ * * Function: bool LoadFile(char *lpszFileName, uint32 dwCodec=FPCODEC_RAW); * - * Description: Apre un file di stream. + * Description: Open a file for a stream. * - * Input: char *lpszFile Nome del file di stream da aprire - * uint32 dwCodec CODEC da utilizzare per decomprimere - * i campioni sonori + * Input: char *lpszFile Filename to be opened + * uint32 dwCodec CODEC to be used to decompress + * sound samples * - * Return: TRUE se tutto OK, FALSE in caso di errore + * Return: True if everything is OK, False otherwise * \****************************************************************************/ bool LoadFile(const char *lpszFileName, uint32 dwCodec = FPCODEC_RAW, int nSync = 2000); - - /****************************************************************************\ * * Function: UnloadFile(); * - * Description: Chiude un file di stream eventualmente aperto. E' necessario - * richiamare questa funzione per disallocare la memoria - * occupata dallo stream. + * Description: Close a file stream (if opened). This function must be + * called to free the memory used by the stream * - * Return: Il distruttore della classe per sicurezza richiama la - * UnloadFile() se non e' stata richiamata esplicitamente. + * Return: Just to be sure, the destructor of this class calls + * UnloadFile() if it has not been mentioned explicitly * \****************************************************************************/ bool UnloadFile(); - /****************************************************************************\ * * Function: bool Play(); * - * Description: Suona lo stream caricato. + * Description: Play the loaded stream. * - * Return: TRUE se tutto OK, FALSE in caso di errore. + * Return: True if everything is OK, False otherwise * \****************************************************************************/ @@ -486,59 +470,52 @@ public: void PlayFast(void); void Prefetch(void); - /****************************************************************************\ * * Function: bool Stop(); * - * Description: Ferma il play dello stream. + * Description: Stops the play of the stream. * - * Return: TRUE se tutto OK, FALSE in caso di errore. + * Return: True if everything is OK, False otherwise * \****************************************************************************/ bool Stop(bool bSync = false); void WaitForSync(FPSTREAM *toplay); - /****************************************************************************\ * * Function: void Pause(bool bPause); * - * Description: Pause dell'effetto sonoro + * Description: Pause sound effect * \****************************************************************************/ void Pause(bool bPause); - /****************************************************************************\ * * Function: bool SetLoop(bool bLoop); * - * Description: Attiva o disattiva il loop dello stream. + * Description: Enable of disable stream loop * - * Input: bool bLoop TRUE per attivare il loop, FALSE per - * disattivarlo + * Input: bool bLoop True to enable loop, false otherwise * - * Note: Il loop deve essere attivato PRIMA di eseguire il play - * dello stream. Qualsiasi modifica effettuata durante il play - * non avra' effetto fino a che lo stream non viene fermato, - * e poi rimesso in play. + * Note: The loop must be activated BEFORE you play back the stream. + * Any changes made during play will not have 'effect until + * the stream is not stopped, and then comes back into play. * \****************************************************************************/ void SetLoop(bool bLoop); - - /****************************************************************************\ * * Function: void SetVolume(int dwVolume); * - * Description: Cambia il volume dello stream + * Description: Change stream colume * - * Input: int dwVolume Volume da settare (0-63) + * Input: int dwVolume Volume to be set (0-63) * \****************************************************************************/ @@ -550,10 +527,9 @@ public: * * Function: void GetVolume(LPINT lpdwVolume); * - * Description: Chiede il volume dello stream + * Description: Get stream volume * - * Input: LPINT lpdwVolume Variabile in cui verra' inserito - * il volume corrente + * Input: LPINT lpdwVolume Will contain the current stream volume * \****************************************************************************/ diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index 6d790c0e68..8e751a811a 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -57,7 +57,7 @@ RMString::~RMString() { * Copy constructor */ RMString::RMString(const RMString &str) { - // Richiama l'overload su '=' per copiare + // Use the overloaded '=' when copying _string = NULL; _length = 0; _realLength = 0; -- cgit v1.2.3 From de440e1a714d596feac383dcb256d431d7e81e4b Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Tue, 12 Jun 2012 11:35:27 -0400 Subject: TONY: Fix looping some sounds --- engines/tony/sound.cpp | 28 ++++++++++++++++------------ engines/tony/sound.h | 2 +- 2 files changed, 17 insertions(+), 13 deletions(-) (limited to 'engines') diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index 487bf54111..b3bdd1be9a 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -198,7 +198,7 @@ FPSFX::FPSFX(bool bSoundOn) { lastVolume = 63; hEndOfBuffer = CORO_INVALID_PID_VALUE; bIsVoice = false; - _stream = 0; + _loopStream = 0; _rewindableStream = 0; bPaused = false; @@ -223,8 +223,10 @@ FPSFX::~FPSFX() { g_system->getMixer()->stopHandle(_handle); _vm->_activeSfx.remove(this); - delete _stream; - // _rewindableStream is deleted by deleting _stream + if (_loopStream) + delete _loopStream; // _rewindableStream is deleted by deleting _loopStream + else + delete _rewindableStream; // FIXME //if (hEndOfBuffer != CORO_INVALID_PID_VALUE) @@ -274,7 +276,6 @@ bool FPSFX::loadWave(Common::SeekableReadStream *stream) { if (!_rewindableStream) return false; - _stream = _rewindableStream; bFileLoaded = true; SetVolume(lastVolume); return true; @@ -304,7 +305,6 @@ bool FPSFX::LoadVoiceFromVDB(Common::File &vdbFP) { bIsVoice = true; _rewindableStream = Audio::makeADPCMStream(vdbFP.readStream(size), DisposeAfterUse::YES, 0, Audio::kADPCMDVI, rate, 1); - _stream = _rewindableStream; bFileLoaded = true; SetVolume(62); @@ -343,11 +343,6 @@ bool FPSFX::LoadFile(const char *lpszFileName, uint32 dwCodec) { _rewindableStream = Audio::makeRawStream(buffer, rate, flags, DisposeAfterUse::YES); } - if (bLoop) - _stream = Audio::makeLoopingAudioStream(_rewindableStream, 0); - else - _stream = _rewindableStream; - bFileLoaded = true; return true; } @@ -373,7 +368,16 @@ bool FPSFX::Play() { _rewindableStream->rewind(); - g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &_handle, _stream, -1, + Audio::AudioStream *stream = _rewindableStream; + + if (bLoop) { + if (!_loopStream) + _loopStream = Audio::makeLoopingAudioStream(_rewindableStream, 0); + + stream = _loopStream; + } + + g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &_handle, stream, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO); SetVolume(lastVolume); @@ -495,7 +499,7 @@ void FPSFX::GetVolume(int *lpdwVolume) { * Returns true if the underlying sound has ended */ bool FPSFX::endOfBuffer() const { - return !g_system->getMixer()->isSoundHandleActive(_handle) && (!_stream || _stream->endOfData()); + return !g_system->getMixer()->isSoundHandleActive(_handle) && (!_rewindableStream || _rewindableStream->endOfData()); } /** diff --git a/engines/tony/sound.h b/engines/tony/sound.h index 8f4a509930..24e7f34921 100644 --- a/engines/tony/sound.h +++ b/engines/tony/sound.h @@ -184,7 +184,7 @@ private: bool bIsVoice; bool bPaused; - Audio::AudioStream *_stream; + Audio::AudioStream *_loopStream; Audio::RewindableAudioStream *_rewindableStream; Audio::SoundHandle _handle; -- cgit v1.2.3 From 876d47e17d84912dbcf3e2f29339b2a792d92e95 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 12 Jun 2012 21:42:46 +0200 Subject: TONY: Translate Italian enums --- engines/tony/custom.cpp | 176 +++++++++++------------ engines/tony/tonychar.cpp | 346 +++++++++++++++++++++++----------------------- engines/tony/tonychar.h | 212 ++++++++++++++-------------- 3 files changed, 367 insertions(+), 367 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 964e506099..81fa5c7ad4 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -786,7 +786,7 @@ DECLARE_CUSTOM_FUNCTION(TonyFischietto)(CORO_PARAM, uint32, uint32, uint32, uint CORO_BEGIN_CODE(_ctx); - GLOBALS._tony->setPattern(GLOBALS._tony->PAT_FISCHIETTORIGHT); + GLOBALS._tony->setPattern(GLOBALS._tony->PAT_WHISTLERIGHT); if (!GLOBALS._bSkipIdle) CORO_INVOKE_0(GLOBALS._tony->waitForEndPattern); @@ -826,164 +826,164 @@ DECLARE_CUSTOM_FUNCTION(TonySiIndica)(CORO_PARAM, uint32 dwText, uint32, uint32, GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_SIINDICA; } -DECLARE_CUSTOM_FUNCTION(TonySpaventatoConMani)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyScaredWithHands)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_SPAVENTATO; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_SCARED; } -DECLARE_CUSTOM_FUNCTION(TonySpaventatoSenzaMani)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyScaredWithoutHands)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_SPAVENTATO2; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_SCARED2; } -DECLARE_CUSTOM_FUNCTION(TonyConMartello)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyWithHammer)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CONMARTELLO; - GLOBALS._tony->setPattern(GLOBALS._tony->PAT_CONMARTELLO); + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_WITHHAMMER; + GLOBALS._tony->setPattern(GLOBALS._tony->PAT_WITHHAMMER); } -DECLARE_CUSTOM_FUNCTION(TonyConBicchiere)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyWithGlasses)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CONBICCHIERE; - GLOBALS._tony->setPattern(GLOBALS._tony->PAT_CONBICCHIERE); + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_WITHGLASSES; + GLOBALS._tony->setPattern(GLOBALS._tony->PAT_WITHGLASSES); } -DECLARE_CUSTOM_FUNCTION(TonyConVerme)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyWithWorm)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CONVERME; - GLOBALS._tony->setPattern(GLOBALS._tony->PAT_CONVERME); + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_WITHWORM; + GLOBALS._tony->setPattern(GLOBALS._tony->PAT_WITHWORM); } -DECLARE_CUSTOM_FUNCTION(TonyConCorda)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyWithRope)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CONCORDA; - GLOBALS._tony->setPattern(GLOBALS._tony->PAT_CONCORDA); + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_WITHROPE; + GLOBALS._tony->setPattern(GLOBALS._tony->PAT_WITHROPE); } -DECLARE_CUSTOM_FUNCTION(TonyConSegretaria)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyWithSecretary)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CONSEGRETARIA; - GLOBALS._tony->setPattern(GLOBALS._tony->PAT_CONSEGRETARIA); + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_WITHSECRETARY; + GLOBALS._tony->setPattern(GLOBALS._tony->PAT_WITHSECRETARY); } -DECLARE_CUSTOM_FUNCTION(TonyConConiglioANIM)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyWithRabbitANIM)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CONCONIGLIO; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_WITHRABBIT; } -DECLARE_CUSTOM_FUNCTION(TonyConRicettaANIM)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyWithRecipeANIM)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CONRICETTA; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_WITHRECIPE; } -DECLARE_CUSTOM_FUNCTION(TonyConCarteANIM)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyWithCardsANIM)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CONCARTE; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_WITHCARDS; } -DECLARE_CUSTOM_FUNCTION(TonyConPupazzoANIM)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyWithSnowmanANIM)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CONPUPAZZO; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_WITHSNOWMAN; } -DECLARE_CUSTOM_FUNCTION(TonyConPupazzoStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyWithSnowmanStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CONPUPAZZOSTATIC; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_WITHSNOWMANSTATIC; GLOBALS._bStaticTalk = true; - CORO_INVOKE_1(GLOBALS._tony->startStatic, GLOBALS._tony->TALK_CONPUPAZZOSTATIC); + CORO_INVOKE_1(GLOBALS._tony->startStatic, GLOBALS._tony->TALK_WITHSNOWMANSTATIC); CORO_END_CODE; } -DECLARE_CUSTOM_FUNCTION(TonyConPupazzoEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyWithSnowmanEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(GLOBALS._tony->endStatic, GLOBALS._tony->TALK_CONPUPAZZOSTATIC); + CORO_INVOKE_1(GLOBALS._tony->endStatic, GLOBALS._tony->TALK_WITHSNOWMANSTATIC); GLOBALS._bStaticTalk = false; GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_NORMAL; CORO_END_CODE; } -DECLARE_CUSTOM_FUNCTION(TonyConConiglioStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyWithRabbitStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CONCONIGLIOSTATIC; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_WITHRABBITSTATIC; GLOBALS._bStaticTalk = true; - CORO_INVOKE_1(GLOBALS._tony->startStatic, GLOBALS._tony->TALK_CONCONIGLIOSTATIC); + CORO_INVOKE_1(GLOBALS._tony->startStatic, GLOBALS._tony->TALK_WITHRABBITSTATIC); CORO_END_CODE; } -DECLARE_CUSTOM_FUNCTION(TonyConConiglioEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyWithRabbitEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(GLOBALS._tony->endStatic, GLOBALS._tony->TALK_CONCONIGLIOSTATIC); + CORO_INVOKE_1(GLOBALS._tony->endStatic, GLOBALS._tony->TALK_WITHRABBITSTATIC); GLOBALS._bStaticTalk = false; GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_NORMAL; CORO_END_CODE; } -DECLARE_CUSTOM_FUNCTION(TonyConRicettaStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyWithRecipeStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CONRICETTASTATIC; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_WITHRECIPESTATIC; GLOBALS._bStaticTalk = true; - CORO_INVOKE_1(GLOBALS._tony->startStatic, GLOBALS._tony->TALK_CONRICETTASTATIC); + CORO_INVOKE_1(GLOBALS._tony->startStatic, GLOBALS._tony->TALK_WITHRECIPESTATIC); CORO_END_CODE; } -DECLARE_CUSTOM_FUNCTION(TonyConRicettaEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyWithRecipeEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(GLOBALS._tony->endStatic, GLOBALS._tony->TALK_CONRICETTASTATIC); + CORO_INVOKE_1(GLOBALS._tony->endStatic, GLOBALS._tony->TALK_WITHRECIPESTATIC); GLOBALS._bStaticTalk = false; GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_NORMAL; CORO_END_CODE; } -DECLARE_CUSTOM_FUNCTION(TonyConCarteStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyWithCardsStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CONCARTESTATIC; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_WITHCARDSSTATIC; GLOBALS._bStaticTalk = true; - CORO_INVOKE_1(GLOBALS._tony->startStatic, GLOBALS._tony->TALK_CONCARTESTATIC); + CORO_INVOKE_1(GLOBALS._tony->startStatic, GLOBALS._tony->TALK_WITHCARDSSTATIC); CORO_END_CODE; } -DECLARE_CUSTOM_FUNCTION(TonyConCarteEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyWithCardsEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(GLOBALS._tony->endStatic, GLOBALS._tony->TALK_CONCARTESTATIC); + CORO_INVOKE_1(GLOBALS._tony->endStatic, GLOBALS._tony->TALK_WITHCARDSSTATIC); GLOBALS._bStaticTalk = false; GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_NORMAL; @@ -1016,78 +1016,78 @@ DECLARE_CUSTOM_FUNCTION(TonyWithNotebookEnd)(CORO_PARAM, uint32, uint32, uint32, CORO_END_CODE; } -DECLARE_CUSTOM_FUNCTION(TonyConMegafonoStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyWithMegaphoneStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CONMEGAFONOSTATIC; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_WITHMEGAPHONESTATIC; GLOBALS._bStaticTalk = true; - CORO_INVOKE_1(GLOBALS._tony->startStatic, GLOBALS._tony->TALK_CONMEGAFONOSTATIC); + CORO_INVOKE_1(GLOBALS._tony->startStatic, GLOBALS._tony->TALK_WITHMEGAPHONESTATIC); CORO_END_CODE; } -DECLARE_CUSTOM_FUNCTION(TonyConMegafonoEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyWithMegaphoneEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(GLOBALS._tony->endStatic, GLOBALS._tony->TALK_CONMEGAFONOSTATIC); + CORO_INVOKE_1(GLOBALS._tony->endStatic, GLOBALS._tony->TALK_WITHMEGAPHONESTATIC); GLOBALS._bStaticTalk = false; GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_NORMAL; CORO_END_CODE; } -DECLARE_CUSTOM_FUNCTION(TonyConBarbaStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyWithBeardStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CONBARBASTATIC; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_WITHBEARDSTATIC; GLOBALS._bStaticTalk = true; - CORO_INVOKE_1(GLOBALS._tony->startStatic, GLOBALS._tony->TALK_CONBARBASTATIC); + CORO_INVOKE_1(GLOBALS._tony->startStatic, GLOBALS._tony->TALK_WITHBEARDSTATIC); CORO_END_CODE; } -DECLARE_CUSTOM_FUNCTION(TonyConBarbaEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyWithBeardEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(GLOBALS._tony->endStatic, GLOBALS._tony->TALK_CONBARBASTATIC); + CORO_INVOKE_1(GLOBALS._tony->endStatic, GLOBALS._tony->TALK_WITHBEARDSTATIC); GLOBALS._bStaticTalk = false; GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_NORMAL; CORO_END_CODE; } -DECLARE_CUSTOM_FUNCTION(TonySpaventatoStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyScaredStart)(CORO_PARAM, uint32, uint32, uint32, uint32) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_SPAVENTATOSTATIC; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_SCAREDSTATIC; GLOBALS._bStaticTalk = true; - CORO_INVOKE_1(GLOBALS._tony->startStatic, GLOBALS._tony->TALK_SPAVENTATOSTATIC); + CORO_INVOKE_1(GLOBALS._tony->startStatic, GLOBALS._tony->TALK_SCAREDSTATIC); CORO_END_CODE; } -DECLARE_CUSTOM_FUNCTION(TonySpaventatoEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyScaredEnd)(CORO_PARAM, uint32, uint32, uint32, uint32) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_1(GLOBALS._tony->endStatic, GLOBALS._tony->TALK_SPAVENTATOSTATIC); + CORO_INVOKE_1(GLOBALS._tony->endStatic, GLOBALS._tony->TALK_SCAREDSTATIC); GLOBALS._bStaticTalk = false; GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_NORMAL; @@ -2447,39 +2447,39 @@ ASSIGN(40, TonyRide) ASSIGN(41, TonyFianchi) ASSIGN(42, TonyCanta) ASSIGN(43, TonySiIndica) -ASSIGN(44, TonySpaventatoConMani) -ASSIGN(49, TonySpaventatoSenzaMani) -ASSIGN(45, TonyConBicchiere) -ASSIGN(46, TonyConVerme) -ASSIGN(47, TonyConMartello) -ASSIGN(48, TonyConCorda) -ASSIGN(90, TonyConConiglioANIM) -ASSIGN(91, TonyConRicettaANIM) -ASSIGN(92, TonyConCarteANIM) -ASSIGN(93, TonyConPupazzoANIM) -ASSIGN(94, TonyConPupazzoStart) -ASSIGN(95, TonyConPupazzoEnd) -ASSIGN(96, TonyConConiglioStart) -ASSIGN(97, TonyConConiglioEnd) -ASSIGN(98, TonyConRicettaStart) -ASSIGN(99, TonyConRicettaEnd) -ASSIGN(100, TonyConCarteStart) -ASSIGN(101, TonyConCarteEnd) +ASSIGN(44, TonyScaredWithHands) +ASSIGN(49, TonyScaredWithoutHands) +ASSIGN(45, TonyWithGlasses) +ASSIGN(46, TonyWithWorm) +ASSIGN(47, TonyWithHammer) +ASSIGN(48, TonyWithRope) +ASSIGN(90, TonyWithRabbitANIM) +ASSIGN(91, TonyWithRecipeANIM) +ASSIGN(92, TonyWithCardsANIM) +ASSIGN(93, TonyWithSnowmanANIM) +ASSIGN(94, TonyWithSnowmanStart) +ASSIGN(95, TonyWithSnowmanEnd) +ASSIGN(96, TonyWithRabbitStart) +ASSIGN(97, TonyWithRabbitEnd) +ASSIGN(98, TonyWithRecipeStart) +ASSIGN(99, TonyWithRecipeEnd) +ASSIGN(100, TonyWithCardsStart) +ASSIGN(101, TonyWithCardsEnd) ASSIGN(102, TonyWithNotebookStart) ASSIGN(103, TonyWithNotebookEnd) -ASSIGN(104, TonyConMegafonoStart) -ASSIGN(105, TonyConMegafonoEnd) -ASSIGN(106, TonyConBarbaStart) -ASSIGN(107, TonyConBarbaEnd) +ASSIGN(104, TonyWithMegaphoneStart) +ASSIGN(105, TonyWithMegaphoneEnd) +ASSIGN(106, TonyWithBeardStart) +ASSIGN(107, TonyWithBeardEnd) ASSIGN(108, TonyRidacchia) ASSIGN(109, TonySchifato) ASSIGN(110, TonyNaah) ASSIGN(111, TonyMacbeth) ASSIGN(112, TonySniffaLeft) ASSIGN(113, TonySniffaRight) -ASSIGN(114, TonySpaventatoStart) -ASSIGN(115, TonySpaventatoEnd) -ASSIGN(116, TonyConSegretaria) +ASSIGN(114, TonyScaredStart) +ASSIGN(115, TonyScaredEnd) +ASSIGN(116, TonyWithSecretary) ASSIGN(50, CharSetCode) ASSIGN(51, CharSetColor) diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index e384dfe794..f232f56cb2 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -763,43 +763,43 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body } break; - case TALK_SPAVENTATO: + case TALK_SCARED: switch (_talkDirection) { case UP: _nBodyOffset.set(-4, -11); headStartPat = PAT_TESTA_UP; - bodyStartPat = BPAT_SPAVENTOUP_START; + bodyStartPat = BPAT_SCAREDUP_START; headLoopPat = PAT_TALK_UP; - bodyLoopPat = BPAT_SPAVENTOUP_LOOP; + bodyLoopPat = BPAT_SCAREDUP_LOOP; break; case DOWN: _nBodyOffset.set(-5, 45); - headStartPat = PAT_SPAVENTODOWN_START; - bodyStartPat = BPAT_SPAVENTODOWN_START; - headLoopPat = PAT_SPAVENTODOWN_LOOP; - bodyLoopPat = BPAT_SPAVENTODOWN_LOOP; + headStartPat = PAT_SCAREDDOWN_START; + bodyStartPat = BPAT_SCAREDDOWN_START; + headLoopPat = PAT_SCAREDDOWN_LOOP; + bodyLoopPat = BPAT_SCAREDDOWN_LOOP; break; case RIGHT: _nBodyOffset.set(-4, 41); - headStartPat = PAT_SPAVENTORIGHT_START; - bodyStartPat = BPAT_SPAVENTORIGHT_START; - headLoopPat = PAT_SPAVENTORIGHT_LOOP; - bodyLoopPat = BPAT_SPAVENTORIGHT_LOOP; + headStartPat = PAT_SCAREDRIGHT_START; + bodyStartPat = BPAT_SCAREDRIGHT_START; + headLoopPat = PAT_SCAREDRIGHT_LOOP; + bodyLoopPat = BPAT_SCAREDRIGHT_LOOP; break; case LEFT: _nBodyOffset.set(-10, 41); - headStartPat = PAT_SPAVENTOLEFT_START; - bodyStartPat = BPAT_SPAVENTOLEFT_START; - headLoopPat = PAT_SPAVENTOLEFT_LOOP; - bodyLoopPat = BPAT_SPAVENTOLEFT_LOOP; + headStartPat = PAT_SCAREDLEFT_START; + bodyStartPat = BPAT_SCAREDLEFT_START; + headLoopPat = PAT_SCAREDLEFT_LOOP; + bodyLoopPat = BPAT_SCAREDLEFT_LOOP; break; } break; - case TALK_SPAVENTATO2: + case TALK_SCARED2: _bCorpoDavanti = false; switch (_talkDirection) { case UP: @@ -816,8 +816,8 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body bodyLoopPat = BPAT_STANDDOWN; _nBodyOffset.set(4, 53); - headStartPat = PAT_SPAVENTODOWN_START; - headLoopPat = PAT_SPAVENTODOWN_LOOP; + headStartPat = PAT_SCAREDDOWN_START; + headLoopPat = PAT_SCAREDDOWN_LOOP; break; case RIGHT: @@ -825,8 +825,8 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body bodyLoopPat = BPAT_STANDRIGHT; _nBodyOffset.set(6, 56); - headStartPat = PAT_SPAVENTORIGHT_START; - headLoopPat = PAT_SPAVENTORIGHT_LOOP; + headStartPat = PAT_SCAREDRIGHT_START; + headLoopPat = PAT_SCAREDRIGHT_LOOP; break; case LEFT: @@ -834,124 +834,124 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body bodyLoopPat = BPAT_STANDLEFT; _nBodyOffset.set(6, 56); - headStartPat = PAT_SPAVENTOLEFT_START; - headLoopPat = PAT_SPAVENTOLEFT_LOOP; + headStartPat = PAT_SCAREDLEFT_START; + headLoopPat = PAT_SCAREDLEFT_LOOP; break; } break; - case TALK_CONBICCHIERE: + case TALK_WITHGLASSES: _nBodyOffset.set(4, 53); headLoopPat = PAT_TALK_DOWN; - bodyLoopPat = BPAT_BICCHIERE; + bodyLoopPat = BPAT_GLASS; break; - case TALK_CONVERME: + case TALK_WITHWORM: _nBodyOffset.set(9, 56); headLoopPat = PAT_TALK_RIGHT; - bodyLoopPat = BPAT_VERME; + bodyLoopPat = BPAT_WORM; break; - case TALK_CONMARTELLO: + case TALK_WITHHAMMER: _nBodyOffset.set(6, 56); headLoopPat = PAT_TALK_LEFT; - bodyLoopPat = BPAT_MARTELLO; + bodyLoopPat = BPAT_HAMMER; break; - case TALK_CONCORDA: + case TALK_WITHROPE: _nBodyOffset.set(-3, 38); headLoopPat = PAT_TALK_RIGHT; - bodyLoopPat = BPAT_CORDA; + bodyLoopPat = BPAT_ROPE; break; - case TALK_CONSEGRETARIA: + case TALK_WITHSECRETARY: _nBodyOffset.set(-17, 12); headLoopPat = PAT_TALK_RIGHT; - bodyLoopPat = BPAT_CONSEGRETARIA; + bodyLoopPat = BPAT_WITHSECRETARY; break; - case TALK_CONCONIGLIO: + case TALK_WITHRABBIT: switch (_talkDirection) { case LEFT: case UP: _nBodyOffset.set(-21, -5); - bodyStartPat = BPAT_CONCONIGLIOLEFT_START; + bodyStartPat = BPAT_WITHRABBITLEFT_START; headLoopPat = PAT_TALK_LEFT; - bodyLoopPat = BPAT_CONCONIGLIOLEFT_LOOP; + bodyLoopPat = BPAT_WITHRABBITLEFT_LOOP; break; case DOWN: case RIGHT: _nBodyOffset.set(-4, -5); - bodyStartPat = BPAT_CONCONIGLIORIGHT_START; + bodyStartPat = BPAT_WITHRABBITRIGHT_START; headLoopPat = PAT_TALK_RIGHT; - bodyLoopPat = BPAT_CONCONIGLIORIGHT_LOOP; + bodyLoopPat = BPAT_WITHRABBITRIGHT_LOOP; break; } break; - case TALK_CONRICETTA: + case TALK_WITHRECIPE: switch (_talkDirection) { case LEFT: case UP: _nBodyOffset.set(-61, -7); - bodyStartPat = BPAT_CONRICETTALEFT_START; + bodyStartPat = BPAT_WITHRECIPELEFT_START; headLoopPat = PAT_TALK_LEFT; - bodyLoopPat = BPAT_CONRICETTALEFT_LOOP; + bodyLoopPat = BPAT_WITHRECIPELEFT_LOOP; break; case DOWN: case RIGHT: _nBodyOffset.set(-5, -7); - bodyStartPat = BPAT_CONRICETTARIGHT_START; + bodyStartPat = BPAT_WITHRECIPERIGHT_START; headLoopPat = PAT_TALK_RIGHT; - bodyLoopPat = BPAT_CONRICETTARIGHT_LOOP; + bodyLoopPat = BPAT_WITHRECIPERIGHT_LOOP; break; } break; - case TALK_CONCARTE: + case TALK_WITHCARDS: switch (_talkDirection) { case LEFT: case UP: _nBodyOffset.set(-34, -2); - bodyStartPat = BPAT_CONCARTELEFT_START; + bodyStartPat = BPAT_WITHCARDSLEFT_START; headLoopPat = PAT_TALK_LEFT; - bodyLoopPat = BPAT_CONCARTELEFT_LOOP; + bodyLoopPat = BPAT_WITHCARDSLEFT_LOOP; break; case DOWN: case RIGHT: _nBodyOffset.set(-4, -2); - bodyStartPat = BPAT_CONCARTERIGHT_START; + bodyStartPat = BPAT_WITHCARDSRIGHT_START; headLoopPat = PAT_TALK_RIGHT; - bodyLoopPat = BPAT_CONCARTERIGHT_LOOP; + bodyLoopPat = BPAT_WITHCARDSRIGHT_LOOP; break; } break; - case TALK_CONPUPAZZO: + case TALK_WITHSNOWMAN: switch (_talkDirection) { case LEFT: case UP: _nBodyOffset.set(-35, 2); - bodyStartPat = BPAT_CONPUPAZZOLEFT_START; + bodyStartPat = BPAT_WITHSNOWMANLEFT_START; headLoopPat = PAT_TALK_LEFT; - bodyLoopPat = BPAT_CONPUPAZZOLEFT_LOOP; + bodyLoopPat = BPAT_WITHSNOWMANLEFT_LOOP; break; case DOWN: case RIGHT: _nBodyOffset.set(-14, 2); - bodyStartPat = BPAT_CONPUPAZZORIGHT_START; + bodyStartPat = BPAT_WITHSNOWMANRIGHT_START; headLoopPat = PAT_TALK_RIGHT; - bodyLoopPat = BPAT_CONPUPAZZORIGHT_LOOP; + bodyLoopPat = BPAT_WITHSNOWMANRIGHT_LOOP; break; } break; - case TALK_CONPUPAZZOSTATIC: - case TALK_CONRICETTASTATIC: - case TALK_CONCONIGLIOSTATIC: - case TALK_CONCARTESTATIC: + case TALK_WITHSNOWMANSTATIC: + case TALK_WITHRECIPESTATIC: + case TALK_WITHRABBITSTATIC: + case TALK_WITHCARDSSTATIC: case TALK_WITH_NOTEBOOK: - case TALK_CONMEGAFONOSTATIC: + case TALK_WITHMEGAPHONESTATIC: switch (_talkDirection) { case LEFT: case UP: @@ -966,18 +966,18 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; // The beard is the only case in which the head is animated separately while the body is the standard - case TALK_CONBARBASTATIC: + case TALK_WITHBEARDSTATIC: switch (_talkDirection) { case LEFT: case UP: - headLoopPat = PAT_TALKBARBA_LEFT; + headLoopPat = PAT_TALKBEARD_LEFT; bodyLoopPat = BPAT_STANDLEFT; _nBodyOffset.set(6, 56); break; case DOWN: case RIGHT: - headLoopPat = PAT_TALKBARBA_RIGHT; + headLoopPat = PAT_TALKBEARD_RIGHT; bodyLoopPat = BPAT_STANDRIGHT; _nBodyOffset.set(6, 56); break; @@ -1070,7 +1070,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body bodyLoopPat = BPAT_MACBETH9; break; - case TALK_SPAVENTATOSTATIC: + case TALK_SCAREDSTATIC: _bCorpoDavanti = false; switch (_talkDirection) { case DOWN: @@ -1078,8 +1078,8 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body bodyLoopPat = BPAT_STANDDOWN; _nBodyOffset.set(4, 53); - headStartPat = PAT_SPAVENTODOWN_STAND; - headLoopPat = PAT_SPAVENTODOWN_LOOP; + headStartPat = PAT_SCAREDDOWN_STAND; + headLoopPat = PAT_SCAREDDOWN_LOOP; break; case RIGHT: @@ -1087,8 +1087,8 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body bodyLoopPat = BPAT_STANDRIGHT; _nBodyOffset.set(6, 56); - headStartPat = PAT_SPAVENTORIGHT_STAND; - headLoopPat = PAT_SPAVENTORIGHT_LOOP; + headStartPat = PAT_SCAREDRIGHT_STAND; + headLoopPat = PAT_SCAREDRIGHT_LOOP; break; case LEFT: @@ -1096,8 +1096,8 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body bodyLoopPat = BPAT_STANDLEFT; _nBodyOffset.set(6, 56); - headStartPat = PAT_SPAVENTOLEFT_STAND; - headLoopPat = PAT_SPAVENTOLEFT_LOOP; + headStartPat = PAT_SCAREDLEFT_STAND; + headLoopPat = PAT_SCAREDLEFT_LOOP; break; default: @@ -1257,130 +1257,130 @@ bool RMTony::endTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa case TALK_SIINDICA: break; - case TALK_SPAVENTATO: + case TALK_SCARED: switch (_talkDirection) { case UP: - bodyEndPat = BPAT_SPAVENTOUP_END; + bodyEndPat = BPAT_SCAREDUP_END; break; case DOWN: - headEndPat = PAT_SPAVENTODOWN_END; - bodyEndPat = BPAT_SPAVENTODOWN_END; + headEndPat = PAT_SCAREDDOWN_END; + bodyEndPat = BPAT_SCAREDDOWN_END; break; case RIGHT: - headEndPat = PAT_SPAVENTORIGHT_END; - bodyEndPat = BPAT_SPAVENTORIGHT_END; + headEndPat = PAT_SCAREDRIGHT_END; + bodyEndPat = BPAT_SCAREDRIGHT_END; break; case LEFT: - headEndPat = PAT_SPAVENTOLEFT_END; - bodyEndPat = BPAT_SPAVENTOLEFT_END; + headEndPat = PAT_SCAREDLEFT_END; + bodyEndPat = BPAT_SCAREDLEFT_END; break; } break; - case TALK_SPAVENTATO2: + case TALK_SCARED2: switch (_talkDirection) { case UP: bodyEndPat = 0; break; case DOWN: - headEndPat = PAT_SPAVENTODOWN_END; + headEndPat = PAT_SCAREDDOWN_END; bodyEndPat = 0; break; case RIGHT: - headEndPat = PAT_SPAVENTORIGHT_END; + headEndPat = PAT_SCAREDRIGHT_END; bodyEndPat = 0; break; case LEFT: - headEndPat = PAT_SPAVENTOLEFT_END; + headEndPat = PAT_SCAREDLEFT_END; bodyEndPat = 0; break; } break; - case TALK_CONCONIGLIO: + case TALK_WITHRABBIT: switch (_talkDirection) { case UP: case LEFT: finalPat = PAT_STANDLEFT; - bodyEndPat = BPAT_CONCONIGLIOLEFT_END; + bodyEndPat = BPAT_WITHRABBITLEFT_END; break; case RIGHT: case DOWN: finalPat = PAT_STANDRIGHT; - bodyEndPat = BPAT_CONCONIGLIORIGHT_END; + bodyEndPat = BPAT_WITHRABBITRIGHT_END; break; } break; - case TALK_CONRICETTA: + case TALK_WITHRECIPE: switch (_talkDirection) { case UP: case LEFT: finalPat = PAT_STANDLEFT; - bodyEndPat = BPAT_CONRICETTALEFT_END; + bodyEndPat = BPAT_WITHRECIPELEFT_END; break; case RIGHT: case DOWN: finalPat = PAT_STANDRIGHT; - bodyEndPat = BPAT_CONRICETTARIGHT_END; + bodyEndPat = BPAT_WITHRECIPERIGHT_END; break; } break; - case TALK_CONCARTE: + case TALK_WITHCARDS: switch (_talkDirection) { case UP: case LEFT: finalPat = PAT_STANDLEFT; - bodyEndPat = BPAT_CONCARTELEFT_END; + bodyEndPat = BPAT_WITHCARDSLEFT_END; break; case RIGHT: case DOWN: finalPat = PAT_STANDRIGHT; - bodyEndPat = BPAT_CONCARTERIGHT_END; + bodyEndPat = BPAT_WITHCARDSRIGHT_END; break; } break; - case TALK_CONPUPAZZO: + case TALK_WITHSNOWMAN: switch (_talkDirection) { case UP: case LEFT: finalPat = PAT_STANDLEFT; - bodyEndPat = BPAT_CONPUPAZZOLEFT_END; + bodyEndPat = BPAT_WITHSNOWMANLEFT_END; break; case RIGHT: case DOWN: finalPat = PAT_STANDRIGHT; - bodyEndPat = BPAT_CONPUPAZZORIGHT_END; + bodyEndPat = BPAT_WITHSNOWMANRIGHT_END; break; } break; - case TALK_CONVERME: - finalPat = PAT_CONVERME; + case TALK_WITHWORM: + finalPat = PAT_WITHWORM; break; - case TALK_CONCORDA: - finalPat = PAT_CONCORDA; + case TALK_WITHROPE: + finalPat = PAT_WITHROPE; break; - case TALK_CONSEGRETARIA: - finalPat = PAT_CONSEGRETARIA; + case TALK_WITHSECRETARY: + finalPat = PAT_WITHSECRETARY; break; - case TALK_CONMARTELLO: - finalPat = PAT_CONMARTELLO; + case TALK_WITHHAMMER: + finalPat = PAT_WITHHAMMER; break; - case TALK_CONBICCHIERE: - finalPat = PAT_CONBICCHIERE; + case TALK_WITHGLASSES: + finalPat = PAT_WITHGLASSES; break; case TALK_MACBETH1: @@ -1394,20 +1394,20 @@ bool RMTony::endTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa finalPat = 0; break; - case TALK_SPAVENTATOSTATIC: + case TALK_SCAREDSTATIC: switch (_talkDirection) { case DOWN: - headStandPat = PAT_SPAVENTODOWN_STAND; + headStandPat = PAT_SCAREDDOWN_STAND; bodyEndPat = 0; break; case RIGHT: - headStandPat = PAT_SPAVENTORIGHT_STAND; + headStandPat = PAT_SCAREDRIGHT_STAND; bodyEndPat = 0; break; case LEFT: - headStandPat = PAT_SPAVENTOLEFT_STAND; + headStandPat = PAT_SCAREDLEFT_STAND; bodyEndPat = 0; break; @@ -1445,14 +1445,14 @@ void RMTony::endTalk(CORO_PARAM) { // Handles the end of an animated and static, leaving everything unchanged if (_bIsStaticTalk) { - if (_nTalkType == TALK_CONBARBASTATIC) { + if (_nTalkType == TALK_WITHBEARDSTATIC) { mainFreeze(); setPattern(0); if (_talkDirection == UP || _talkDirection == LEFT) { - _body.setPattern(BPAT_CONBARBALEFT_STATIC); + _body.setPattern(BPAT_WITHBEARDLEFT_STATIC); _nBodyOffset.set(-41, -14); } else if (_talkDirection == DOWN || _talkDirection == RIGHT) { - _body.setPattern(BPAT_CONBARBARIGHT_STATIC); + _body.setPattern(BPAT_WITHBEARDRIGHT_STATIC); _nBodyOffset.set(-26, -14); } mainUnfreeze(); @@ -1560,74 +1560,74 @@ void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat _bCorpoDavanti = true; switch (nTalk) { - case TALK_CONCONIGLIOSTATIC: + case TALK_WITHRABBITSTATIC: switch (_talkDirection) { case UP: case LEFT: _nBodyOffset.set(-21, -5); - bodyStartPat = BPAT_CONCONIGLIOLEFT_START; - bodyLoopPat = BPAT_CONCONIGLIOLEFT_LOOP; + bodyStartPat = BPAT_WITHRABBITLEFT_START; + bodyLoopPat = BPAT_WITHRABBITLEFT_LOOP; break; case DOWN: case RIGHT: _nBodyOffset.set(-4, -5); - bodyStartPat = BPAT_CONCONIGLIORIGHT_START; - bodyLoopPat = BPAT_CONCONIGLIORIGHT_LOOP; + bodyStartPat = BPAT_WITHRABBITRIGHT_START; + bodyLoopPat = BPAT_WITHRABBITRIGHT_LOOP; break; } break; - case TALK_CONCARTESTATIC: + case TALK_WITHCARDSSTATIC: switch (_talkDirection) { case UP: case LEFT: _nBodyOffset.set(-34, -2); - bodyStartPat = BPAT_CONCARTELEFT_START; - bodyLoopPat = BPAT_CONCARTELEFT_LOOP; + bodyStartPat = BPAT_WITHCARDSLEFT_START; + bodyLoopPat = BPAT_WITHCARDSLEFT_LOOP; break; case DOWN: case RIGHT: _nBodyOffset.set(-4, -2); - bodyStartPat = BPAT_CONCARTERIGHT_START; - bodyLoopPat = BPAT_CONCARTERIGHT_LOOP; + bodyStartPat = BPAT_WITHCARDSRIGHT_START; + bodyLoopPat = BPAT_WITHCARDSRIGHT_LOOP; break; } break; - case TALK_CONRICETTASTATIC: + case TALK_WITHRECIPESTATIC: switch (_talkDirection) { case UP: case LEFT: _nBodyOffset.set(-61, -7); - bodyStartPat = BPAT_CONRICETTALEFT_START; - bodyLoopPat = BPAT_CONRICETTALEFT_LOOP; + bodyStartPat = BPAT_WITHRECIPELEFT_START; + bodyLoopPat = BPAT_WITHRECIPELEFT_LOOP; break; case DOWN: case RIGHT: _nBodyOffset.set(-5, -7); - bodyStartPat = BPAT_CONRICETTARIGHT_START; - bodyLoopPat = BPAT_CONRICETTARIGHT_LOOP; + bodyStartPat = BPAT_WITHRECIPERIGHT_START; + bodyLoopPat = BPAT_WITHRECIPERIGHT_LOOP; break; } break; - case TALK_CONPUPAZZOSTATIC: + case TALK_WITHSNOWMANSTATIC: switch (_talkDirection) { case UP: case LEFT: _nBodyOffset.set(-35, 2); - bodyStartPat = BPAT_CONPUPAZZOLEFT_START; - bodyLoopPat = BPAT_CONPUPAZZOLEFT_LOOP; + bodyStartPat = BPAT_WITHSNOWMANLEFT_START; + bodyLoopPat = BPAT_WITHSNOWMANLEFT_LOOP; break; case DOWN: case RIGHT: _nBodyOffset.set(-14, 2); - bodyStartPat = BPAT_CONPUPAZZORIGHT_START; - bodyLoopPat = BPAT_CONPUPAZZORIGHT_LOOP; + bodyStartPat = BPAT_WITHSNOWMANRIGHT_START; + bodyLoopPat = BPAT_WITHSNOWMANRIGHT_LOOP; break; } break; @@ -1637,82 +1637,82 @@ void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat case UP: case LEFT: _nBodyOffset.set(-16, -9); - bodyStartPat = BPAT_CONTACCUINOLEFT_START; - bodyLoopPat = BPAT_CONTACCUINOLEFT_LOOP; + bodyStartPat = BPAT_WITHNOTEBOOKLEFT_START; + bodyLoopPat = BPAT_WITHNOTEBOOKLEFT_LOOP; break; case DOWN: case RIGHT: _nBodyOffset.set(-6, -9); - bodyStartPat = BPAT_CONTACCUINORIGHT_START; - bodyLoopPat = BPAT_CONTACCUINORIGHT_LOOP; + bodyStartPat = BPAT_WITHNOTEBOOKRIGHT_START; + bodyLoopPat = BPAT_WITHNOTEBOOKRIGHT_LOOP; break; } break; - case TALK_CONMEGAFONOSTATIC: + case TALK_WITHMEGAPHONESTATIC: switch (_talkDirection) { case UP: case LEFT: _nBodyOffset.set(-41, -8); - bodyStartPat = BPAT_CONMEGAFONOLEFT_START; - bodyLoopPat = BPAT_CONMEGAFONOLEFT_LOOP; + bodyStartPat = BPAT_WITHMEGAPHONELEFT_START; + bodyLoopPat = BPAT_WITHMEGAPHONELEFT_LOOP; break; case DOWN: case RIGHT: _nBodyOffset.set(-14, -8); - bodyStartPat = BPAT_CONMEGAFONORIGHT_START; - bodyLoopPat = BPAT_CONMEGAFONORIGHT_LOOP; + bodyStartPat = BPAT_WITHMEGAPHONERIGHT_START; + bodyLoopPat = BPAT_WITHMEGAPHONERIGHT_LOOP; break; } break; - case TALK_CONBARBASTATIC: + case TALK_WITHBEARDSTATIC: switch (_talkDirection) { case UP: case LEFT: _nBodyOffset.set(-41, -14); - bodyStartPat = BPAT_CONBARBALEFT_START; + bodyStartPat = BPAT_WITHBEARDLEFT_START; bodyLoopPat = BPAT_STANDLEFT; - headLoopPat = PAT_TALKBARBA_LEFT; + headLoopPat = PAT_TALKBEARD_LEFT; headPat = 0; break; case DOWN: case RIGHT: _nBodyOffset.set(-26, -14); - bodyStartPat = BPAT_CONBARBARIGHT_START; + bodyStartPat = BPAT_WITHBEARDRIGHT_START; bodyLoopPat = BPAT_STANDRIGHT; - headLoopPat = PAT_TALKBARBA_RIGHT; + headLoopPat = PAT_TALKBEARD_RIGHT; headPat = 0; break; } break; - case TALK_SPAVENTATOSTATIC: + case TALK_SCAREDSTATIC: switch (_talkDirection) { case DOWN: - headPat = PAT_SPAVENTODOWN_START; + headPat = PAT_SCAREDDOWN_START; bodyLoopPat = BPAT_STANDDOWN; bodyStartPat = BPAT_STANDDOWN; - headLoopPat = PAT_SPAVENTODOWN_STAND; + headLoopPat = PAT_SCAREDDOWN_STAND; _nBodyOffset.set(4, 53); break; case LEFT: - headPat = PAT_SPAVENTOLEFT_START; + headPat = PAT_SCAREDLEFT_START; bodyLoopPat = BPAT_STANDLEFT; bodyStartPat = BPAT_STANDLEFT; - headLoopPat = PAT_SPAVENTOLEFT_STAND; + headLoopPat = PAT_SCAREDLEFT_STAND; _nBodyOffset.set(6, 56); break; case RIGHT: - headPat = PAT_SPAVENTORIGHT_START; + headPat = PAT_SCAREDRIGHT_START; bodyLoopPat = BPAT_STANDRIGHT; bodyStartPat = BPAT_STANDRIGHT; - headLoopPat = PAT_SPAVENTORIGHT_STAND; + headLoopPat = PAT_SCAREDRIGHT_STAND; _nBodyOffset.set(6, 56); break; @@ -1774,58 +1774,58 @@ void RMTony::endStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, } switch (nTalk) { - case TALK_CONPUPAZZOSTATIC: + case TALK_WITHSNOWMANSTATIC: switch (_talkDirection) { case UP: case LEFT: - bodyEndPat = BPAT_CONPUPAZZOLEFT_END; + bodyEndPat = BPAT_WITHSNOWMANLEFT_END; break; case DOWN: case RIGHT: - bodyEndPat = BPAT_CONPUPAZZORIGHT_END; + bodyEndPat = BPAT_WITHSNOWMANRIGHT_END; break; } break; - case TALK_CONRICETTASTATIC: + case TALK_WITHRECIPESTATIC: switch (_talkDirection) { case UP: case LEFT: - bodyEndPat = BPAT_CONRICETTALEFT_END; + bodyEndPat = BPAT_WITHRECIPELEFT_END; break; case DOWN: case RIGHT: - bodyEndPat = BPAT_CONRICETTARIGHT_END; + bodyEndPat = BPAT_WITHRECIPERIGHT_END; break; } break; - case TALK_CONCONIGLIOSTATIC: + case TALK_WITHRABBITSTATIC: switch (_talkDirection) { case UP: case LEFT: - bodyEndPat = BPAT_CONCONIGLIOLEFT_END; + bodyEndPat = BPAT_WITHRABBITLEFT_END; break; case DOWN: case RIGHT: - bodyEndPat = BPAT_CONCONIGLIORIGHT_END; + bodyEndPat = BPAT_WITHRABBITRIGHT_END; break; } break; - case TALK_CONCARTESTATIC: + case TALK_WITHCARDSSTATIC: switch (_talkDirection) { case UP: case LEFT: - bodyEndPat = BPAT_CONCARTELEFT_END; + bodyEndPat = BPAT_WITHCARDSLEFT_END; break; case DOWN: case RIGHT: - bodyEndPat = BPAT_CONCARTERIGHT_END; + bodyEndPat = BPAT_WITHCARDSRIGHT_END; break; } break; @@ -1834,56 +1834,56 @@ void RMTony::endStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, switch (_talkDirection) { case UP: case LEFT: - bodyEndPat = BPAT_CONTACCUINOLEFT_END; + bodyEndPat = BPAT_WITHNOTEBOOKLEFT_END; break; case DOWN: case RIGHT: - bodyEndPat = BPAT_CONTACCUINORIGHT_END; + bodyEndPat = BPAT_WITHNOTEBOOKRIGHT_END; break; } break; - case TALK_CONMEGAFONOSTATIC: + case TALK_WITHMEGAPHONESTATIC: switch (_talkDirection) { case UP: case LEFT: - bodyEndPat = BPAT_CONMEGAFONOLEFT_END; + bodyEndPat = BPAT_WITHMEGAPHONELEFT_END; break; case DOWN: case RIGHT: - bodyEndPat = BPAT_CONMEGAFONORIGHT_END; + bodyEndPat = BPAT_WITHMEGAPHONERIGHT_END; break; } break; - case TALK_CONBARBASTATIC: + case TALK_WITHBEARDSTATIC: switch (_talkDirection) { case UP: case LEFT: - bodyEndPat = BPAT_CONBARBALEFT_END; + bodyEndPat = BPAT_WITHBEARDLEFT_END; break; case DOWN: case RIGHT: - bodyEndPat = BPAT_CONBARBARIGHT_END; + bodyEndPat = BPAT_WITHBEARDRIGHT_END; break; } break; - case TALK_SPAVENTATOSTATIC: + case TALK_SCAREDSTATIC: switch (_talkDirection) { case LEFT: - headEndPat = PAT_SPAVENTOLEFT_END; + headEndPat = PAT_SCAREDLEFT_END; break; case DOWN: - headEndPat = PAT_SPAVENTODOWN_END; + headEndPat = PAT_SCAREDDOWN_END; break; case RIGHT: - headEndPat = PAT_SPAVENTORIGHT_END; + headEndPat = PAT_SCAREDRIGHT_END; break; default: diff --git a/engines/tony/tonychar.h b/engines/tony/tonychar.h index 6ba66729a9..8c5c0f530d 100644 --- a/engines/tony/tonychar.h +++ b/engines/tony/tonychar.h @@ -47,23 +47,23 @@ public: TALK_CANTA, TALK_RIDE, TALK_SIINDICA, - TALK_SPAVENTATO, - TALK_SPAVENTATO2, - TALK_CONBICCHIERE, - TALK_CONMARTELLO, - TALK_CONVERME, - TALK_CONCORDA, - TALK_CONCONIGLIO, - TALK_CONRICETTA, - TALK_CONCARTE, - TALK_CONPUPAZZO, - TALK_CONPUPAZZOSTATIC, - TALK_CONCONIGLIOSTATIC, - TALK_CONRICETTASTATIC, - TALK_CONCARTESTATIC, + TALK_SCARED, + TALK_SCARED2, + TALK_WITHGLASSES, + TALK_WITHHAMMER, + TALK_WITHWORM, + TALK_WITHROPE, + TALK_WITHRABBIT, + TALK_WITHRECIPE, + TALK_WITHCARDS, + TALK_WITHSNOWMAN, + TALK_WITHSNOWMANSTATIC, + TALK_WITHRABBITSTATIC, + TALK_WITHRECIPESTATIC, + TALK_WITHCARDSSTATIC, TALK_WITH_NOTEBOOK, - TALK_CONMEGAFONOSTATIC, - TALK_CONBARBASTATIC, + TALK_WITHMEGAPHONESTATIC, + TALK_WITHBEARDSTATIC, TALK_RIDE2, TALK_SCHIFATO, TALK_NAAH, @@ -76,8 +76,8 @@ public: TALK_MACBETH7, TALK_MACBETH8, TALK_MACBETH9, - TALK_SPAVENTATOSTATIC, - TALK_CONSEGRETARIA + TALK_SCAREDSTATIC, + TALK_WITHSECRETARY }; private: @@ -178,28 +178,28 @@ public: PAT_PAST_TALKRIGHT, // Fear - PAT_SPAVENTOLEFT_START, - PAT_SPAVENTOLEFT_LOOP, - PAT_SPAVENTOLEFT_END, - PAT_SPAVENTORIGHT_START, - PAT_SPAVENTORIGHT_LOOP, - PAT_SPAVENTORIGHT_END, - PAT_SPAVENTODOWN_START, - PAT_SPAVENTODOWN_LOOP, - PAT_SPAVENTODOWN_END, + PAT_SCAREDLEFT_START, + PAT_SCAREDLEFT_LOOP, + PAT_SCAREDLEFT_END, + PAT_SCAREDRIGHT_START, + PAT_SCAREDRIGHT_LOOP, + PAT_SCAREDRIGHT_END, + PAT_SCAREDDOWN_START, + PAT_SCAREDDOWN_LOOP, + PAT_SCAREDDOWN_END, // With objects: full body - PAT_CONBICCHIERE, - PAT_CONCORDA, - PAT_CONVERME, - PAT_CONMARTELLO, + PAT_WITHGLASSES, + PAT_WITHROPE, + PAT_WITHWORM, + PAT_WITHHAMMER, // Sound the whistle - PAT_FISCHIETTORIGHT, + PAT_WHISTLERIGHT, // Head with beard - PAT_TALKBARBA_LEFT, - PAT_TALKBARBA_RIGHT, + PAT_TALKBEARD_LEFT, + PAT_TALKBEARD_RIGHT, // Sniff PAT_SNIFFA_LEFT, @@ -220,9 +220,9 @@ public: PAT_NAAHRIGHT_END, // Stand scared - PAT_SPAVENTOLEFT_STAND, - PAT_SPAVENTORIGHT_STAND, - PAT_SPAVENTODOWN_STAND, + PAT_SCAREDLEFT_STAND, + PAT_SCAREDRIGHT_STAND, + PAT_SCAREDDOWN_STAND, PAT_PUTLEFT_UP1, PAT_PUTLEFT_UP2, @@ -243,7 +243,7 @@ public: PAT_PUTUP_DOWN1, PAT_PUTUP_DOWN2, - PAT_CONSEGRETARIA + PAT_WITHSECRETARY }; enum BODYPATTERNS { @@ -252,10 +252,10 @@ public: BPAT_STANDLEFT, BPAT_STANDRIGHT, - BPAT_MARTELLO, - BPAT_PUPAZZO, - BPAT_VERME, - BPAT_BICCHIERE, + BPAT_HAMMER, + BPAT_SNOWMAN, + BPAT_WORM, + BPAT_GLASS, BPAT_CANTALEFT_START, BPAT_CANTALEFT_LOOP, @@ -280,69 +280,69 @@ public: BPAT_SIINDICALEFT, BPAT_SIINDICARIGHT, - BPAT_SPAVENTODOWN_START, - BPAT_SPAVENTODOWN_LOOP, - BPAT_SPAVENTODOWN_END, - BPAT_SPAVENTOLEFT_START, - BPAT_SPAVENTOLEFT_LOOP, - BPAT_SPAVENTOLEFT_END, - BPAT_SPAVENTORIGHT_START, - BPAT_SPAVENTORIGHT_LOOP, - BPAT_SPAVENTORIGHT_END, - BPAT_SPAVENTOUP_START, - BPAT_SPAVENTOUP_LOOP, - BPAT_SPAVENTOUP_END, - - BPAT_CORDA, - - BPAT_CONCONIGLIOLEFT_START, - BPAT_CONCONIGLIOLEFT_LOOP, - BPAT_CONCONIGLIOLEFT_END, - BPAT_CONCONIGLIORIGHT_START, - BPAT_CONCONIGLIORIGHT_LOOP, - BPAT_CONCONIGLIORIGHT_END, - - BPAT_CONRICETTALEFT_START, - BPAT_CONRICETTALEFT_LOOP, - BPAT_CONRICETTALEFT_END, - BPAT_CONRICETTARIGHT_START, - BPAT_CONRICETTARIGHT_LOOP, - BPAT_CONRICETTARIGHT_END, - - BPAT_CONCARTELEFT_START, - BPAT_CONCARTELEFT_LOOP, - BPAT_CONCARTELEFT_END, - BPAT_CONCARTERIGHT_START, - BPAT_CONCARTERIGHT_LOOP, - BPAT_CONCARTERIGHT_END, - - BPAT_CONPUPAZZOLEFT_START, - BPAT_CONPUPAZZOLEFT_LOOP, - BPAT_CONPUPAZZOLEFT_END, - BPAT_CONPUPAZZORIGHT_START, - BPAT_CONPUPAZZORIGHT_LOOP, - BPAT_CONPUPAZZORIGHT_END, - - BPAT_CONTACCUINOLEFT_START, - BPAT_CONTACCUINOLEFT_LOOP, - BPAT_CONTACCUINOLEFT_END, - BPAT_CONTACCUINORIGHT_START, - BPAT_CONTACCUINORIGHT_LOOP, - BPAT_CONTACCUINORIGHT_END, - - BPAT_CONMEGAFONOLEFT_START, - BPAT_CONMEGAFONOLEFT_LOOP, - BPAT_CONMEGAFONOLEFT_END, - BPAT_CONMEGAFONORIGHT_START, - BPAT_CONMEGAFONORIGHT_LOOP, - BPAT_CONMEGAFONORIGHT_END, - - BPAT_CONBARBALEFT_START, - BPAT_CONBARBALEFT_END, - BPAT_CONBARBARIGHT_START, - BPAT_CONBARBARIGHT_END, - BPAT_CONBARBALEFT_STATIC, - BPAT_CONBARBARIGHT_STATIC, + BPAT_SCAREDDOWN_START, + BPAT_SCAREDDOWN_LOOP, + BPAT_SCAREDDOWN_END, + BPAT_SCAREDLEFT_START, + BPAT_SCAREDLEFT_LOOP, + BPAT_SCAREDLEFT_END, + BPAT_SCAREDRIGHT_START, + BPAT_SCAREDRIGHT_LOOP, + BPAT_SCAREDRIGHT_END, + BPAT_SCAREDUP_START, + BPAT_SCAREDUP_LOOP, + BPAT_SCAREDUP_END, + + BPAT_ROPE, + + BPAT_WITHRABBITLEFT_START, + BPAT_WITHRABBITLEFT_LOOP, + BPAT_WITHRABBITLEFT_END, + BPAT_WITHRABBITRIGHT_START, + BPAT_WITHRABBITRIGHT_LOOP, + BPAT_WITHRABBITRIGHT_END, + + BPAT_WITHRECIPELEFT_START, + BPAT_WITHRECIPELEFT_LOOP, + BPAT_WITHRECIPELEFT_END, + BPAT_WITHRECIPERIGHT_START, + BPAT_WITHRECIPERIGHT_LOOP, + BPAT_WITHRECIPERIGHT_END, + + BPAT_WITHCARDSLEFT_START, + BPAT_WITHCARDSLEFT_LOOP, + BPAT_WITHCARDSLEFT_END, + BPAT_WITHCARDSRIGHT_START, + BPAT_WITHCARDSRIGHT_LOOP, + BPAT_WITHCARDSRIGHT_END, + + BPAT_WITHSNOWMANLEFT_START, + BPAT_WITHSNOWMANLEFT_LOOP, + BPAT_WITHSNOWMANLEFT_END, + BPAT_WITHSNOWMANRIGHT_START, + BPAT_WITHSNOWMANRIGHT_LOOP, + BPAT_WITHSNOWMANRIGHT_END, + + BPAT_WITHNOTEBOOKLEFT_START, + BPAT_WITHNOTEBOOKLEFT_LOOP, + BPAT_WITHNOTEBOOKLEFT_END, + BPAT_WITHNOTEBOOKRIGHT_START, + BPAT_WITHNOTEBOOKRIGHT_LOOP, + BPAT_WITHNOTEBOOKRIGHT_END, + + BPAT_WITHMEGAPHONELEFT_START, + BPAT_WITHMEGAPHONELEFT_LOOP, + BPAT_WITHMEGAPHONELEFT_END, + BPAT_WITHMEGAPHONERIGHT_START, + BPAT_WITHMEGAPHONERIGHT_LOOP, + BPAT_WITHMEGAPHONERIGHT_END, + + BPAT_WITHBEARDLEFT_START, + BPAT_WITHBEARDLEFT_END, + BPAT_WITHBEARDRIGHT_START, + BPAT_WITHBEARDRIGHT_END, + BPAT_WITHBEARDLEFT_STATIC, + BPAT_WITHBEARDRIGHT_STATIC, BPAT_MACBETH1, BPAT_MACBETH2, @@ -354,7 +354,7 @@ public: BPAT_MACBETH8, BPAT_MACBETH9, - BPAT_CONSEGRETARIA + BPAT_WITHSECRETARY }; public: -- cgit v1.2.3 From 5bafab9ad629595a1d270b60b2a91bd04dc1b7b9 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 13 Jun 2012 08:00:37 +0200 Subject: TONY: Translate some more Italian --- engines/tony/custom.cpp | 136 ++++++++++++++++++++++----------------------- engines/tony/gfxengine.cpp | 4 +- engines/tony/tonychar.cpp | 122 ++++++++++++++++++++-------------------- engines/tony/tonychar.h | 67 +++++++++++----------- 4 files changed, 165 insertions(+), 164 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 81fa5c7ad4..eea134e442 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -752,23 +752,23 @@ DECLARE_CUSTOM_FUNCTION(TonyPutDown2)(CORO_PARAM, uint32, uint32, uint32, uint32 } -DECLARE_CUSTOM_FUNCTION(TonyPerTerra)(CORO_PARAM, uint32 dwParte, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyOnTheFloor)(CORO_PARAM, uint32 dwParte, uint32, uint32, uint32) { if (dwParte == 0) - GLOBALS._tony->setPattern(GLOBALS._tony->PAT_PERTERRALEFT); + GLOBALS._tony->setPattern(GLOBALS._tony->PAT_ONTHEFLOORLEFT); else - GLOBALS._tony->setPattern(GLOBALS._tony->PAT_PERTERRARIGHT); + GLOBALS._tony->setPattern(GLOBALS._tony->PAT_ONTHEFLOORRIGHT); } -DECLARE_CUSTOM_FUNCTION(TonySiRialza)(CORO_PARAM, uint32 dwParte, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyGetUp)(CORO_PARAM, uint32 dwParte, uint32, uint32, uint32) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); if (dwParte == 0) - GLOBALS._tony->setPattern(GLOBALS._tony->PAT_SIRIALZALEFT); + GLOBALS._tony->setPattern(GLOBALS._tony->PAT_GETUPLEFT); else - GLOBALS._tony->setPattern(GLOBALS._tony->PAT_SIRIALZARIGHT); + GLOBALS._tony->setPattern(GLOBALS._tony->PAT_GETUPRIGHT); if (!GLOBALS._bSkipIdle) CORO_INVOKE_0(GLOBALS._tony->waitForEndPattern); @@ -776,11 +776,11 @@ DECLARE_CUSTOM_FUNCTION(TonySiRialza)(CORO_PARAM, uint32 dwParte, uint32, uint32 CORO_END_CODE; } -DECLARE_CUSTOM_FUNCTION(TonyPastorella)(CORO_PARAM, uint32 bIsPast, uint32, uint32, uint32) { - GLOBALS._tony->setPastorella(bIsPast); +DECLARE_CUSTOM_FUNCTION(TonyShepherdess)(CORO_PARAM, uint32 bIsPast, uint32, uint32, uint32) { + GLOBALS._tony->setShepherdess(bIsPast); } -DECLARE_CUSTOM_FUNCTION(TonyFischietto)(CORO_PARAM, uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyWhistle)(CORO_PARAM, uint32, uint32, uint32, uint32) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); @@ -806,7 +806,7 @@ DECLARE_CUSTOM_FUNCTION(TonyRide)(CORO_PARAM, uint32 dwText, uint32, uint32, uin GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_RIDE; } -DECLARE_CUSTOM_FUNCTION(TonyRidacchia)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyGiggle)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_RIDE2; } @@ -816,14 +816,14 @@ DECLARE_CUSTOM_FUNCTION(TonyFianchi)(CORO_PARAM, uint32 dwText, uint32, uint32, GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_FIANCHI; } -DECLARE_CUSTOM_FUNCTION(TonyCanta)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonySing)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_CANTA; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_SING; } -DECLARE_CUSTOM_FUNCTION(TonySiIndica)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyIndicate)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_SIINDICA; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_INDICATE; } DECLARE_CUSTOM_FUNCTION(TonyScaredWithHands)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { @@ -1095,31 +1095,31 @@ DECLARE_CUSTOM_FUNCTION(TonyScaredEnd)(CORO_PARAM, uint32, uint32, uint32, uint3 } -DECLARE_CUSTOM_FUNCTION(TonySchifato)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyDisgusted)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_SCHIFATO; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_DISGUSTED; } -DECLARE_CUSTOM_FUNCTION(TonySniffaLeft)(CORO_PARAM, uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonySniffLeft)(CORO_PARAM, uint32, uint32, uint32, uint32) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - GLOBALS._tony->setPattern(GLOBALS._tony->PAT_SNIFFA_LEFT); + GLOBALS._tony->setPattern(GLOBALS._tony->PAT_SNIFF_LEFT); CORO_INVOKE_0(GLOBALS._tony->waitForEndPattern); CORO_INVOKE_4(LeftToMe, 0, 0, 0, 0); CORO_END_CODE; } -DECLARE_CUSTOM_FUNCTION(TonySniffaRight)(CORO_PARAM, uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonySniffRight)(CORO_PARAM, uint32, uint32, uint32, uint32) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - GLOBALS._tony->setPattern(GLOBALS._tony->PAT_SNIFFA_RIGHT); + GLOBALS._tony->setPattern(GLOBALS._tony->PAT_SNIFF_RIGHT); CORO_INVOKE_0(GLOBALS._tony->waitForEndPattern); CORO_INVOKE_4(RightToMe, 0, 0, 0, 0); @@ -1168,8 +1168,8 @@ DECLARE_CUSTOM_FUNCTION(EnableTony)(CORO_PARAM, uint32, uint32, uint32, uint32) GLOBALS._tony->show(); } -DECLARE_CUSTOM_FUNCTION(DisableTony)(CORO_PARAM, uint32 bShowOmbra, uint32, uint32, uint32) { - GLOBALS._tony->hide(bShowOmbra); +DECLARE_CUSTOM_FUNCTION(DisableTony)(CORO_PARAM, uint32 bShowShadow, uint32, uint32, uint32) { + GLOBALS._tony->hide(bShowShadow); } DECLARE_CUSTOM_FUNCTION(WaitForPatternEnd)(CORO_PARAM, uint32 nItem, uint32, uint32, uint32) { @@ -2438,63 +2438,63 @@ ASSIGN(75, TonyPutUp2) ASSIGN(76, TonyPutMid2) ASSIGN(77, TonyPutDown2) -ASSIGN(36, TonyPerTerra) -ASSIGN(37, TonySiRialza) -ASSIGN(38, TonyPastorella) -ASSIGN(39, TonyFischietto) +ASSIGN(36, TonyOnTheFloor) +ASSIGN(37, TonyGetUp) +ASSIGN(38, TonyShepherdess) +ASSIGN(39, TonyWhistle) ASSIGN(40, TonyRide) ASSIGN(41, TonyFianchi) -ASSIGN(42, TonyCanta) -ASSIGN(43, TonySiIndica) -ASSIGN(44, TonyScaredWithHands) -ASSIGN(49, TonyScaredWithoutHands) -ASSIGN(45, TonyWithGlasses) -ASSIGN(46, TonyWithWorm) -ASSIGN(47, TonyWithHammer) -ASSIGN(48, TonyWithRope) -ASSIGN(90, TonyWithRabbitANIM) -ASSIGN(91, TonyWithRecipeANIM) -ASSIGN(92, TonyWithCardsANIM) -ASSIGN(93, TonyWithSnowmanANIM) -ASSIGN(94, TonyWithSnowmanStart) -ASSIGN(95, TonyWithSnowmanEnd) -ASSIGN(96, TonyWithRabbitStart) -ASSIGN(97, TonyWithRabbitEnd) -ASSIGN(98, TonyWithRecipeStart) -ASSIGN(99, TonyWithRecipeEnd) -ASSIGN(100, TonyWithCardsStart) -ASSIGN(101, TonyWithCardsEnd) -ASSIGN(102, TonyWithNotebookStart) -ASSIGN(103, TonyWithNotebookEnd) -ASSIGN(104, TonyWithMegaphoneStart) -ASSIGN(105, TonyWithMegaphoneEnd) -ASSIGN(106, TonyWithBeardStart) -ASSIGN(107, TonyWithBeardEnd) -ASSIGN(108, TonyRidacchia) -ASSIGN(109, TonySchifato) -ASSIGN(110, TonyNaah) -ASSIGN(111, TonyMacbeth) -ASSIGN(112, TonySniffaLeft) -ASSIGN(113, TonySniffaRight) -ASSIGN(114, TonyScaredStart) -ASSIGN(115, TonyScaredEnd) -ASSIGN(116, TonyWithSecretary) +ASSIGN(42, TonySing) +ASSIGN(43, TonyIndicate) +ASSIGN(44, TonyScaredWithHands) +ASSIGN(49, TonyScaredWithoutHands) +ASSIGN(45, TonyWithGlasses) +ASSIGN(46, TonyWithWorm) +ASSIGN(47, TonyWithHammer) +ASSIGN(48, TonyWithRope) +ASSIGN(90, TonyWithRabbitANIM) +ASSIGN(91, TonyWithRecipeANIM) +ASSIGN(92, TonyWithCardsANIM) +ASSIGN(93, TonyWithSnowmanANIM) +ASSIGN(94, TonyWithSnowmanStart) +ASSIGN(95, TonyWithSnowmanEnd) +ASSIGN(96, TonyWithRabbitStart) +ASSIGN(97, TonyWithRabbitEnd) +ASSIGN(98, TonyWithRecipeStart) +ASSIGN(99, TonyWithRecipeEnd) +ASSIGN(100, TonyWithCardsStart) +ASSIGN(101, TonyWithCardsEnd) +ASSIGN(102, TonyWithNotebookStart) +ASSIGN(103, TonyWithNotebookEnd) +ASSIGN(104, TonyWithMegaphoneStart) +ASSIGN(105, TonyWithMegaphoneEnd) +ASSIGN(106, TonyWithBeardStart) +ASSIGN(107, TonyWithBeardEnd) +ASSIGN(108, TonyGiggle) +ASSIGN(109, TonyDisgusted) +ASSIGN(110, TonyNaah) +ASSIGN(111, TonyMacbeth) +ASSIGN(112, TonySniffLeft) +ASSIGN(113, TonySniffRight) +ASSIGN(114, TonyScaredStart) +ASSIGN(115, TonyScaredEnd) +ASSIGN(116, TonyWithSecretary) ASSIGN(50, CharSetCode) -ASSIGN(51, CharSetColor) +ASSIGN(51, CharSetColor) ASSIGN(52, CharSetTalkPattern) ASSIGN(53, CharSendMessage) ASSIGN(54, CharSetStartEndTalkPattern) ASSIGN(60, MCharSetCode) ASSIGN(61, MCharSetColor) -ASSIGN(62, MCharSetCurrentGroup) -ASSIGN(63, MCharSetNumTalksInGroup) -ASSIGN(64, MCharSetNumTexts) -ASSIGN(65, MCharSendMessage) -ASSIGN(66, MCharSetPosition) -ASSIGN(67, MCharSetAlwaysBack) +ASSIGN(62, MCharSetCurrentGroup) +ASSIGN(63, MCharSetNumTalksInGroup) +ASSIGN(64, MCharSetNumTexts) +ASSIGN(65, MCharSendMessage) +ASSIGN(66, MCharSetPosition) +ASSIGN(67, MCharSetAlwaysBack) ASSIGN(68, MCharResetCode) ASSIGN(70, StartDialog) diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 4c09e16678..b167d0a546 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -643,7 +643,7 @@ void RMGfxEngine::saveState(const Common::String &fn, byte *curThumb, const Comm bool bStat; // Saves the state of the shepherdess and show yourself - bStat = _tony.getPastorella(); + bStat = _tony.getShepherdess(); f->writeByte(bStat); bStat = _inter.getPerorate(); f->writeByte(bStat); @@ -779,7 +779,7 @@ void RMGfxEngine::loadState(CORO_PARAM, const Common::String &fn) { bool bStat = false; bStat = _ctx->f->readByte(); - _tony.setPastorella(bStat); + _tony.setShepherdess(bStat); bStat = _ctx->f->readByte(); _inter.setPerorate(bStat); diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index f232f56cb2..0f16bc45c3 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -46,13 +46,13 @@ void RMTony::initStatics() { RMTony::RMTony() { _bShow = false; - _bShowOmbra = false; - _bCorpoDavanti = false; + _bShowShadow = false; + _bBodyFront = false; _bActionPending = false; _actionItem = NULL; _action = 0; _actionParm = 0; - _bPastorella = false; + _bShepherdess = false; _bIsStaticTalk = false; _bIsTalking = false; _nPatB4Talking = 0; @@ -94,13 +94,13 @@ void RMTony::init(void) { RMDataStream ds; // Tony is shown by default - _bShow = _bShowOmbra = true; + _bShow = _bShowShadow = true; // No action pending _bActionPending = false; _bAction = false; - _bPastorella = false; + _bShepherdess = false; _bIsTalking = false; _bIsStaticTalk = false; @@ -125,7 +125,7 @@ void RMTony::init(void) { void RMTony::close(void) { // Disalloca @@@ Deallocation of missing item - _ombra.destroy(); +// _shadow.destroy(); } void RMTony::doFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int curLoc) { @@ -162,12 +162,12 @@ void RMTony::doFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int curLoc) { void RMTony::show(void) { _bShow = true; - _bShowOmbra = true; + _bShowShadow = true; } -void RMTony::hide(bool bShowOmbra) { +void RMTony::hide(bool bShowShadow) { _bShow = false; - _bShowOmbra = bShowOmbra; + _bShowShadow = bShowShadow; } @@ -179,10 +179,10 @@ void RMTony::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { // Call the Draw() of the parent class if Tony is visible if (_bShow && _bDrawNow) { - if (_bCorpoDavanti) { + if (_bBodyFront) { prim->getDst().setEmpty(); prim->getDst().offset(-44, -134); - if (_bPastorella) + if (_bShepherdess) prim->getDst().offset(1, 4); CORO_INVOKE_2(RMCharacter::draw, bigBuf, prim); } @@ -197,10 +197,10 @@ void RMTony::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_INVOKE_2(_body.draw, bigBuf, prim); } - if (!_bCorpoDavanti) { + if (!_bBodyFront) { prim->getDst().setEmpty(); prim->getDst().offset(-44, -134); - if (_bPastorella) + if (_bShepherdess) prim->getDst().offset(0, 3); CORO_INVOKE_2(RMCharacter::draw, bigBuf, prim); } @@ -341,7 +341,7 @@ void RMTony::stop(CORO_PARAM) { int RMTony::getCurPattern(void) { int nPatt = RMCharacter::getCurPattern(); - if (!_bPastorella) + if (!_bShepherdess) return nPatt; switch (nPatt) { @@ -367,7 +367,7 @@ int RMTony::getCurPattern(void) { } void RMTony::setPattern(int nPatt, bool bPlayP0) { - if (_bPastorella) { + if (_bShepherdess) { switch (nPatt) { case PAT_STANDUP: nPatt = PAT_PAST_STANDUP; @@ -568,7 +568,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case PAT_TAKELEFT_UP2: case PAT_TAKELEFT_MID2: case PAT_TAKELEFT_DOWN2: - case PAT_SIRIALZALEFT: + case PAT_GETUPLEFT: case PAT_STANDLEFT: _talkDirection = LEFT; break; @@ -576,7 +576,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case PAT_TAKERIGHT_UP2: case PAT_TAKERIGHT_MID2: case PAT_TAKERIGHT_DOWN2: - case PAT_SIRIALZARIGHT: + case PAT_GETUPRIGHT: case PAT_STANDRIGHT: _talkDirection = RIGHT; break; @@ -590,10 +590,10 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body } // Puts the body in front by default - _bCorpoDavanti = true; + _bBodyFront = true; } - if (_bPastorella) { + if (_bShepherdess) { // Talking whilst a shepherdess mainFreeze(); switch (_talkDirection) { @@ -622,7 +622,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body switch (nTalkType) { case TALK_NORMAL: - _bCorpoDavanti = false; + _bBodyFront = false; headStartPat = 0; bodyStartPat = 0; @@ -654,11 +654,11 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case TALK_FIANCHI: - _bCorpoDavanti = false; + _bBodyFront = false; switch (_talkDirection) { case UP: _nBodyOffset.set(2, 42); - headStartPat = PAT_TESTA_UP; + headStartPat = PAT_HEAD_UP; bodyStartPat = BPAT_FIANCHIUP_START; headLoopPat = PAT_TALK_UP; bodyLoopPat = BPAT_FIANCHIUP_LOOP; @@ -666,7 +666,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case DOWN: _nBodyOffset.set(2, 48); - headStartPat = PAT_TESTA_DOWN; + headStartPat = PAT_HEAD_DOWN; bodyStartPat = BPAT_FIANCHIDOWN_START; headLoopPat = PAT_TALK_DOWN; bodyLoopPat = BPAT_FIANCHIDOWN_LOOP; @@ -674,7 +674,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case LEFT: _nBodyOffset.set(-3, 53); - headStartPat = PAT_TESTA_LEFT; + headStartPat = PAT_HEAD_LEFT; bodyStartPat = BPAT_FIANCHILEFT_START; headLoopPat = PAT_TALK_LEFT; bodyLoopPat = BPAT_FIANCHILEFT_LOOP; @@ -682,7 +682,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body case RIGHT: _nBodyOffset.set(2, 53); - headStartPat = PAT_TESTA_RIGHT; + headStartPat = PAT_HEAD_RIGHT; bodyStartPat = BPAT_FIANCHIRIGHT_START; headLoopPat = PAT_TALK_RIGHT; bodyLoopPat = BPAT_FIANCHIRIGHT_LOOP; @@ -691,16 +691,16 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; - case TALK_CANTA: + case TALK_SING: _nBodyOffset.set(-10, 25); - headStartPat = PAT_TESTA_LEFT; - bodyStartPat = BPAT_CANTALEFT_START; + headStartPat = PAT_HEAD_LEFT; + bodyStartPat = BPAT_SINGLEFT_START; headLoopPat = PAT_TALK_LEFT; - bodyLoopPat = BPAT_CANTALEFT_LOOP; + bodyLoopPat = BPAT_SINGLEFT_LOOP; break; case TALK_RIDE: - _bCorpoDavanti = false; + _bBodyFront = false; switch (_talkDirection) { case UP: case DOWN: @@ -723,7 +723,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case TALK_RIDE2: - _bCorpoDavanti = false; + _bBodyFront = false; switch (_talkDirection) { case UP: case DOWN: @@ -745,20 +745,20 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; - case TALK_SIINDICA: + case TALK_INDICATE: switch (_talkDirection) { case UP: case DOWN: case LEFT: _nBodyOffset.set(-4, 40); headLoopPat = PAT_TALK_LEFT; - bodyLoopPat = BPAT_SIINDICALEFT; + bodyLoopPat = BPAT_INDICATELEFT; break; case RIGHT: _nBodyOffset.set(5, 40); headLoopPat = PAT_TALK_RIGHT; - bodyLoopPat = BPAT_SIINDICARIGHT; + bodyLoopPat = BPAT_INDICATERIGHT; break; } break; @@ -767,7 +767,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body switch (_talkDirection) { case UP: _nBodyOffset.set(-4, -11); - headStartPat = PAT_TESTA_UP; + headStartPat = PAT_HEAD_UP; bodyStartPat = BPAT_SCAREDUP_START; headLoopPat = PAT_TALK_UP; bodyLoopPat = BPAT_SCAREDUP_LOOP; @@ -800,14 +800,14 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case TALK_SCARED2: - _bCorpoDavanti = false; + _bBodyFront = false; switch (_talkDirection) { case UP: bodyStartPat = BPAT_STANDUP; bodyLoopPat = BPAT_STANDUP; _nBodyOffset.set(6, 53); - headStartPat = PAT_TESTA_UP; + headStartPat = PAT_HEAD_UP; headLoopPat = PAT_TALK_UP; break; @@ -984,22 +984,22 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body } break; - case TALK_SCHIFATO: + case TALK_DISGUSTED: switch (_talkDirection) { case LEFT: case UP: _nBodyOffset.set(6, 56); - headStartPat = PAT_SCHIFATOLEFT_START; + headStartPat = PAT_DISGUSTEDLEFT_START; bodyStartPat = BPAT_STANDLEFT; - headLoopPat = PAT_SCHIFATOLEFT_LOOP; + headLoopPat = PAT_DISGUSTEDLEFT_LOOP; break; case DOWN: case RIGHT: _nBodyOffset.set(6, 56); - headStartPat = PAT_SCHIFATORIGHT_START; + headStartPat = PAT_DISGUSTEDRIGHT_START; bodyStartPat = BPAT_STANDRIGHT; - headLoopPat = PAT_SCHIFATORIGHT_LOOP; + headLoopPat = PAT_DISGUSTEDRIGHT_LOOP; break; } break; @@ -1071,7 +1071,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body break; case TALK_SCAREDSTATIC: - _bCorpoDavanti = false; + _bBodyFront = false; switch (_talkDirection) { case DOWN: bodyStartPat = BPAT_STANDDOWN; @@ -1154,26 +1154,26 @@ bool RMTony::endTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa switch (_talkDirection) { case UP: finalPat = PAT_STANDUP; - headStandPat = PAT_TESTA_UP; + headStandPat = PAT_HEAD_UP; break; case DOWN: finalPat = PAT_STANDDOWN; - headStandPat = PAT_TESTA_DOWN; + headStandPat = PAT_HEAD_DOWN; break; case LEFT: finalPat = PAT_STANDLEFT; - headStandPat = PAT_TESTA_LEFT; + headStandPat = PAT_HEAD_LEFT; break; case RIGHT: finalPat = PAT_STANDRIGHT; - headStandPat = PAT_TESTA_RIGHT; + headStandPat = PAT_HEAD_RIGHT; break; } - if (_bPastorella) { + if (_bShepherdess) { mainFreeze(); setPattern(finalPat); mainUnfreeze(); @@ -1208,8 +1208,8 @@ bool RMTony::endTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa } break; - case TALK_CANTA: - bodyEndPat = BPAT_CANTALEFT_END; + case TALK_SING: + bodyEndPat = BPAT_SINGLEFT_END; break; case TALK_RIDE: @@ -1222,16 +1222,16 @@ bool RMTony::endTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa bodyEndPat = 0; break; - case TALK_SCHIFATO: + case TALK_DISGUSTED: switch (_talkDirection) { case UP: case LEFT: - headEndPat = PAT_SCHIFATOLEFT_END; + headEndPat = PAT_DISGUSTEDLEFT_END; break; case DOWN: case RIGHT: - headEndPat = PAT_SCHIFATORIGHT_END; + headEndPat = PAT_DISGUSTEDRIGHT_END; break; } @@ -1254,7 +1254,7 @@ bool RMTony::endTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa bodyEndPat = 0; break; - case TALK_SIINDICA: + case TALK_INDICATE: break; case TALK_SCARED: @@ -1527,25 +1527,25 @@ void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat switch (nPat) { case PAT_STANDDOWN: _talkDirection = DOWN; - headPat = PAT_TESTA_RIGHT; + headPat = PAT_HEAD_RIGHT; break; case PAT_TAKELEFT_UP2: case PAT_TAKELEFT_MID2: case PAT_TAKELEFT_DOWN2: - case PAT_SIRIALZALEFT: + case PAT_GETUPLEFT: case PAT_STANDLEFT: _talkDirection = LEFT; - headPat = PAT_TESTA_LEFT; + headPat = PAT_HEAD_LEFT; break; case PAT_TAKERIGHT_UP2: case PAT_TAKERIGHT_MID2: case PAT_TAKERIGHT_DOWN2: - case PAT_SIRIALZARIGHT: + case PAT_GETUPRIGHT: case PAT_STANDRIGHT: _talkDirection = RIGHT; - headPat = PAT_TESTA_RIGHT; + headPat = PAT_HEAD_RIGHT; break; case PAT_TAKEUP_UP2: @@ -1553,11 +1553,11 @@ void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat case PAT_TAKEUP_DOWN2: case PAT_STANDUP: _talkDirection = UP; - headPat = PAT_TESTA_LEFT; + headPat = PAT_HEAD_LEFT; break; } - _bCorpoDavanti = true; + _bBodyFront = true; switch (nTalk) { case TALK_WITHRABBITSTATIC: diff --git a/engines/tony/tonychar.h b/engines/tony/tonychar.h index 8c5c0f530d..e5231d89fd 100644 --- a/engines/tony/tonychar.h +++ b/engines/tony/tonychar.h @@ -44,9 +44,9 @@ public: enum TALKTYPE { TALK_NORMAL, TALK_FIANCHI, - TALK_CANTA, + TALK_SING, TALK_RIDE, - TALK_SIINDICA, + TALK_INDICATE, TALK_SCARED, TALK_SCARED2, TALK_WITHGLASSES, @@ -65,7 +65,7 @@ public: TALK_WITHMEGAPHONESTATIC, TALK_WITHBEARDSTATIC, TALK_RIDE2, - TALK_SCHIFATO, + TALK_DISGUSTED, TALK_NAAH, TALK_MACBETH1, TALK_MACBETH2, @@ -82,16 +82,17 @@ public: private: bool _bShow; - bool _bShowOmbra; - bool _bCorpoDavanti; - RMGfxSourceBuffer8AB _ombra; + bool _bShowShadow; + bool _bBodyFront; + // Useless variable? + // RMGfxSourceBuffer8AB _shadow; bool _bActionPending; RMItem *_actionItem; int _action; int _actionParm; static bool _bAction; - bool _bPastorella; + bool _bShepherdess; bool _bIsStaticTalk; bool _bIsTalking; @@ -135,10 +136,10 @@ public: PAT_TAKERIGHT_DOWN1, PAT_TAKERIGHT_DOWN2, - PAT_SIRIALZALEFT, - PAT_PERTERRALEFT, - PAT_SIRIALZARIGHT, - PAT_PERTERRARIGHT, + PAT_GETUPLEFT, + PAT_ONTHEFLOORLEFT, + PAT_GETUPRIGHT, + PAT_ONTHEFLOORRIGHT, // Sheperdess! PAT_PAST_WALKUP, @@ -158,10 +159,10 @@ public: PAT_TALK_RIGHT, // Static head - PAT_TESTA_UP, - PAT_TESTA_DOWN, - PAT_TESTA_LEFT, - PAT_TESTA_RIGHT, + PAT_HEAD_UP, + PAT_HEAD_DOWN, + PAT_HEAD_LEFT, + PAT_HEAD_RIGHT, // Laugh PAT_RIDELEFT_START, @@ -202,16 +203,16 @@ public: PAT_TALKBEARD_RIGHT, // Sniff - PAT_SNIFFA_LEFT, - PAT_SNIFFA_RIGHT, + PAT_SNIFF_LEFT, + PAT_SNIFF_RIGHT, // Disgusted - PAT_SCHIFATOLEFT_START, - PAT_SCHIFATOLEFT_LOOP, - PAT_SCHIFATOLEFT_END, - PAT_SCHIFATORIGHT_START, - PAT_SCHIFATORIGHT_LOOP, - PAT_SCHIFATORIGHT_END, + PAT_DISGUSTEDLEFT_START, + PAT_DISGUSTEDLEFT_LOOP, + PAT_DISGUSTEDLEFT_END, + PAT_DISGUSTEDRIGHT_START, + PAT_DISGUSTEDRIGHT_LOOP, + PAT_DISGUSTEDRIGHT_END, PAT_NAAHLEFT_START, PAT_NAAHLEFT_LOOP, PAT_NAAHLEFT_END, @@ -257,9 +258,9 @@ public: BPAT_WORM, BPAT_GLASS, - BPAT_CANTALEFT_START, - BPAT_CANTALEFT_LOOP, - BPAT_CANTALEFT_END, + BPAT_SINGLEFT_START, + BPAT_SINGLEFT_LOOP, + BPAT_SINGLEFT_END, BPAT_FIANCHILEFT_START, BPAT_FIANCHILEFT_LOOP, @@ -277,8 +278,8 @@ public: BPAT_RIDELEFT, BPAT_RIDERIGHT, - BPAT_SIINDICALEFT, - BPAT_SIINDICARIGHT, + BPAT_INDICATELEFT, + BPAT_INDICATERIGHT, BPAT_SCAREDDOWN_START, BPAT_SCAREDDOWN_LOOP, @@ -375,7 +376,7 @@ public: // Show or hide void show(void); - void hide(bool bShowOmbra = false); + void hide(bool bShowShadow = false); // Move and make an action, if necessary void moveAndDoAction(CORO_PARAM, RMPoint dst, RMItem *item, int nAction, int nActionParm = 0); @@ -434,11 +435,11 @@ public: void endStatic(CORO_PARAM, TALKTYPE nTalkType); // Tony disguises himself! - void setPastorella(bool bIsPast) { - _bPastorella = bIsPast; + void setShepherdess(bool bIsPast) { + _bShepherdess = bIsPast; } - int getPastorella(void) { - return _bPastorella; + int getShepherdess(void) { + return _bShepherdess; } // Perform an action -- cgit v1.2.3 From 746dcf33da340702157dc7aca0f01265648189be Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 13 Jun 2012 21:06:57 +1000 Subject: TONY: Refactor RMPointer class to use the ScummVM CursorMan --- engines/tony/game.cpp | 73 ++++++++++++++++++++++++++++------------------ engines/tony/game.h | 28 ++++++++++-------- engines/tony/gfxengine.cpp | 5 ++-- 3 files changed, 64 insertions(+), 42 deletions(-) (limited to 'engines') diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 0ccd2d8dc8..1b13fa98bf 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -29,6 +29,7 @@ #include "common/file.h" #include "common/savefile.h" #include "common/textconsole.h" +#include "graphics/cursorman.h" #include "tony/mpal/lzo.h" #include "tony/mpal/memory.h" #include "tony/mpal/mpal.h" @@ -1543,46 +1544,62 @@ void RMPointer::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim _ctx->n = _nCurPointer; if (_ctx->n == TA_COMBINE) _ctx->n = TA_USE; - // Copy the destination coordinates in the primitive - prim->setDst(_pos); + _cursorHotspot = _hotspot[_ctx->n]; - if (_pos._x >= 0 && _pos._y >= 0 && _pos._x < RM_SX && _pos._y < RM_SY) { - // Call the Draw method of the poitner - prim->getDst() -= _hotspot[_ctx->n]; - - if (_nCurSpecialPointer == 0) { - CORO_INVOKE_2(_pointer[_ctx->n]->draw, bigBuf, prim); - } else { - if (_nCurSpecialPointer == PTR_CUSTOM) - CORO_INVOKE_2(_nCurCustomPointer->draw, bigBuf, prim); - else - // Call the draw on the special pointer - CORO_INVOKE_2(_specialPointer[_nCurSpecialPointer - 1]->draw, bigBuf, prim); - } + // Call the Draw method of the pointer + if (_nCurSpecialPointer == 0) { + CORO_INVOKE_2(_pointer[_ctx->n]->draw, bigBuf, prim); + } else { + if (_nCurSpecialPointer == PTR_CUSTOM) + CORO_INVOKE_2(_nCurCustomPointer->draw, bigBuf, prim); + else + // Call the draw on the special pointer + CORO_INVOKE_2(_specialPointer[_nCurSpecialPointer - 1]->draw, bigBuf, prim); } CORO_END_CODE; } -void RMPointer::doFrame(RMGfxTargetBuffer *bigBuf) { - // Add it to the list of primitives - bigBuf->addPrim(new RMGfxPrimitive(this)); +int RMPointer::curAction(void) { + if (_nCurSpecialPointer != 0) + return 0; - // If there is a special pointer, does DoFrame - if (_nCurSpecialPointer != 0 && _nCurSpecialPointer != PTR_CUSTOM) - _specialPointer[_nCurSpecialPointer - 1]->doFrame(bigBuf, false); + return _nCurPointer; } -void RMPointer::removeThis(CORO_PARAM, bool &result) { - // Always remove from the OT list, to support disabling the pointer - result = true; +/** + * Show the cursor + */ +void RMPointer::showCursor() { + if (!CursorMan.isVisible()) { + CursorMan.showMouse(true); + + updateCursor(); + } } -int RMPointer::curAction(void) { - if (_nCurSpecialPointer != 0) - return 0; +/** + * Hide the cursor + */ +void RMPointer::hideCursor() { + if (CursorMan.isVisible()) { + CursorMan.showMouse(false); + } +} - return _nCurPointer; + +void RMPointer::updateCursor() { + // Create an intermediate buffer and draw the cursor onto it + RMGfxTargetBuffer buf; + buf.create(64, 64, 16); + RMGfxPrimitive prim; + + draw(Common::nullContext, buf, &prim); + + // Get the raw pixel data and set the cursor to it + const byte *cursorData = buf; + Graphics::PixelFormat pixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0); + CursorMan.replaceCursor(cursorData, 64, 64, _cursorHotspot._x, _cursorHotspot._y, 0, 1, &pixelFormat); } } // End of namespace Tony diff --git a/engines/tony/game.h b/engines/tony/game.h index db182dfa23..9ac8f76bcc 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -54,11 +54,11 @@ namespace Tony { delete raw; -class RMPointer : public RMGfxTask { +class RMPointer { private: RMGfxSourceBuffer8 *_pointer[16]; RMPoint _hotspot[16]; - RMPoint _pos; + RMPoint _cursorHotspot; RMItem *_specialPointer[16]; @@ -67,6 +67,8 @@ private: RMGfxSourceBuffer8 *_nCurCustomPointer; + void updateCursor(); + public: enum POINTER { PTR_NONE = 0, @@ -95,20 +97,13 @@ public: // Overloading of priorities int priority(); - // Overloading draw method - virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - - // Sets the current co-ordinates - void setCoord(const RMPoint &pt) { - _pos = pt; - } - - // Overloading of the method to see if rising from the list - virtual void removeThis(CORO_PARAM, bool &result); + // draw method + void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Sets a new action as current void setAction(RMTonyAction action) { _nCurPointer = action; + updateCursor(); } // Sets a new pointer @@ -116,6 +111,8 @@ public: _nCurSpecialPointer = ptr; if (_nCurSpecialPointer && _nCurSpecialPointer != PTR_CUSTOM) _specialPointer[ptr - 1]->setPattern(1); + + updateCursor(); } POINTER getSpecialPointer(void) { return (POINTER)_nCurSpecialPointer; @@ -124,10 +121,17 @@ public: // Set the new custom pointer void setCustomPointer(RMGfxSourceBuffer8 *ptr) { _nCurCustomPointer = ptr; + updateCursor(); } // Return the current action to be applied according to the pointer int curAction(void); + + /** Show the cursor */ + void showCursor(); + + /** Hide the cursor */ + void hideCursor(); }; class RMOptionButton: public RMGfxTaskSetPrior { diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index b167d0a546..deae0cb641 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -305,8 +305,9 @@ SKIPCLICKSINISTRO: _tony.setScrollPosition(_loc.scrollPosition()); if ((!_tony.inAction() && _bInput) || _bAlwaysDrawMouse) { - _point.setCoord(_input.mousePos()); - _point.doFrame(&_bigBuf); + _point.showCursor(); + } else { + _point.hideCursor(); } // ********************** -- cgit v1.2.3 From 42a322d671a27406a9dd993f82675dda0ee4780b Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 14 Jun 2012 00:11:56 +0200 Subject: TONY: Silent some CppCheck warnings --- engines/tony/font.cpp | 6 +++++- engines/tony/font.h | 4 ++-- engines/tony/game.cpp | 3 +++ engines/tony/gfxcore.cpp | 16 +++++++--------- engines/tony/inventory.cpp | 5 +++++ engines/tony/inventory.h | 1 + 6 files changed, 23 insertions(+), 12 deletions(-) (limited to 'engines') diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 122c529de3..a567fe20cd 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -42,6 +42,7 @@ namespace Tony { RMFont::RMFont() { _letter = NULL; + _nLetters = _fontDimx = _fontDimy = _dimx = _dimy = 0; } RMFont::~RMFont() { @@ -1993,7 +1994,7 @@ void RMText::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { \****************************************************************************/ RMTextDialog::RMTextDialog() : RMText() { - _startTime = 0; + _time = _startTime = 0; _dst = RMPoint(0, 0); _bSkipStatus = true; @@ -2327,6 +2328,9 @@ RMDialogChoice::RMDialogChoice() { _hUnreg = CoroScheduler.createEvent(false, false); _bRemoveFromOT = false; + + _curAdded = 0; + _bShow = false; } RMDialogChoice::~RMDialogChoice() { diff --git a/engines/tony/font.h b/engines/tony/font.h index daaac84a59..328d501e27 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -57,8 +57,8 @@ private: class RMFontPrimitive : public RMGfxPrimitive { public: - RMFontPrimitive() : RMGfxPrimitive() {} - RMFontPrimitive(RMGfxTask *task) : RMGfxPrimitive(task) {} + RMFontPrimitive() : RMGfxPrimitive() { _nChar = 0; } + RMFontPrimitive(RMGfxTask *task) : RMGfxPrimitive(task) { _nChar = 0; } virtual ~RMFontPrimitive() { } virtual RMGfxPrimitive *duplicate() { return new RMFontPrimitive(*this); diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 1b13fa98bf..03479d96a5 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -1473,6 +1473,9 @@ bool RMOptionScreen::loadThumbnailFromSaveState(int nState, byte *lpDestBuf, RMS RMPointer::RMPointer() { Common::fill(_pointer, _pointer + 16, (RMGfxSourceBuffer8 *)NULL); Common::fill(_specialPointer, _specialPointer + 16, (RMItem *)NULL); + + _nCurPointer = _nCurSpecialPointer = 0; + _nCurCustomPointer = NULL; } RMPointer::~RMPointer() { diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 83769ee78b..e168d2b7c9 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -390,16 +390,15 @@ RMGfxSourceBufferPal::~RMGfxSourceBufferPal() { } int RMGfxSourceBufferPal::loadPaletteWA(const byte *buf, bool bSwapped) { - int i; - - if (bSwapped) - for (i = 0; i < (1 << getBpp()); i++) { + if (bSwapped) { + for (int i = 0; i < (1 << getBpp()); i++) { _pal[i * 3 + 0] = buf[i * 3 + 2]; _pal[i * 3 + 1] = buf[i * 3 + 1]; _pal[i * 3 + 2] = buf[i * 3 + 0]; } - else + } else { copyMemory(_pal, buf, (1 << getBpp()) * 3); + } preparePalette(); @@ -1819,7 +1818,6 @@ RMGfxSourceBuffer16::~RMGfxSourceBuffer16() { } void RMGfxSourceBuffer16::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { - int x, y; uint16 *buf = bigBuf; uint16 *raw = (uint16 *)_buf; int dimx, dimy; @@ -1852,8 +1850,8 @@ void RMGfxSourceBuffer16::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimi buf += y1 * bigBuf.getDimx() + x1; if (_bTrasp0) { - for (y = 0; y < dimy; y++) { - for (x = 0; x < dimx;) { + for (int y = 0; y < dimy; y++) { + for (int x = 0; x < dimx;) { while (x < dimx && raw[x] == 0) x++; @@ -1867,7 +1865,7 @@ void RMGfxSourceBuffer16::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimi buf += bigBuf.getDimx(); } } else { - for (y = 0; y < dimy; y++) { + for (int y = 0; y < dimy; y++) { Common::copy(raw, raw + dimx, buf); buf += bigBuf.getDimx(); raw += _dimx; diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index f29713adbd..76d0f0eca9 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -755,6 +755,11 @@ int RMInventory::loadState(byte *state) { * RMInterface methods \****************************************************************************/ +RMInterface::RMInterface() : RMGfxSourceBuffer8RLEByte() { + _bActive = _bPerorate = false; + _lastHotZone = -1; +} + RMInterface::~RMInterface() { } diff --git a/engines/tony/inventory.h b/engines/tony/inventory.h index 5bf35e6eb0..b739e16f72 100644 --- a/engines/tony/inventory.h +++ b/engines/tony/inventory.h @@ -169,6 +169,7 @@ protected: int onWhichBox(RMPoint pt); public: + RMInterface(); virtual ~RMInterface(); // The usual DoFrame (poll the graphics engine) -- cgit v1.2.3 From d4e9aa78aba58ba96d99595410fd46dd351b8aca Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 14 Jun 2012 08:08:13 +0200 Subject: TONY: Silent more CppCheck warnings --- engines/tony/gfxcore.h | 7 +++++++ engines/tony/loc.cpp | 18 +++++++++--------- engines/tony/mpal/expr.cpp | 22 +++++++++++----------- engines/tony/mpal/mpal.cpp | 4 ++-- engines/tony/window.cpp | 8 +++----- 5 files changed, 32 insertions(+), 27 deletions(-) (limited to 'engines') diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index 9a00ed1646..4461f41271 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -112,11 +112,13 @@ public: _task = NULL; _src.setEmpty(); _dst.setEmpty(); + _bStretch = false; } RMGfxPrimitive(RMGfxTask *task) { _task = task; _bFlag = 0; + _bStretch = false; } RMGfxPrimitive(RMGfxTask *task, const RMRect &src, RMRect &dst) { @@ -132,6 +134,7 @@ public: _src.topLeft() = src; _dst = dst; _bFlag = 0; + _bStretch = false; } RMGfxPrimitive(RMGfxTask *task, const RMPoint &src, RMPoint &dst) { @@ -139,6 +142,7 @@ public: _src.topLeft() = src; _dst.topLeft() = dst; _bFlag = 0; + _bStretch = false; } RMGfxPrimitive(RMGfxTask *task, const RMRect &src, RMPoint &dst) { @@ -146,6 +150,7 @@ public: _src = src; _dst.topLeft() = dst; _bFlag = 0; + _bStretch = false; } RMGfxPrimitive(RMGfxTask *task, const RMRect &dst) { @@ -153,6 +158,7 @@ public: _dst = dst; _src.setEmpty(); _bFlag = 0; + _bStretch = false; } RMGfxPrimitive(RMGfxTask *task, const RMPoint &dst) { @@ -160,6 +166,7 @@ public: _dst.topLeft() = dst; _src.setEmpty(); _bFlag = 0; + _bStretch = false; } virtual ~RMGfxPrimitive() { } diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index b2bf3b3565..0b8398c541 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -710,14 +710,13 @@ void RMItem::setStatus(int nStatus) { } void RMItem::setPattern(int nPattern, bool bPlayP0) { - int i; - assert(nPattern >= 0 && nPattern <= _nPatterns); - if (_sfx) + if (_sfx) { if (_nCurPattern > 0) _patterns[_nCurPattern].stopSfx(_sfx); - + } + // Remember the current pattern _nCurPattern = nPattern; @@ -728,10 +727,12 @@ void RMItem::setPattern(int nPattern, bool bPlayP0) { _nCurSprite = -1; // Look for the sound effect for pattern 0 - if (bPlayP0) - for (i = 0; i < _nSfx; i++) + if (bPlayP0) { + for (int i = 0; i < _nSfx; i++) { if (strcmp(_sfx[i]._name, "p0") == 0) _sfx[i].play(); + } + } } } @@ -783,6 +784,8 @@ RMItem::RMItem() { _bPal = 0; _nCurSprite = 0; + _bIsActive = false; + _hEndPattern = CoroScheduler.createEvent(false, false); } @@ -1967,11 +1970,8 @@ bool RMLocation::load(const char *lpszFileName) { * @returns True if succeeded OK, false in case of error. */ bool RMLocation::load(Common::File &file) { - int size; bool bRet; - // Get the file size - size = file.size(); file.seek(0); RMFileStreamSlow fs; diff --git a/engines/tony/mpal/expr.cpp b/engines/tony/mpal/expr.cpp index 516da98bb1..52751120f6 100644 --- a/engines/tony/mpal/expr.cpp +++ b/engines/tony/mpal/expr.cpp @@ -124,8 +124,8 @@ static byte *duplicateExpression(HGLOBAL h) { two->val.pson = duplicateExpression(two->val.son); } - one++; - two++; + ++one; + ++two; } globalUnlock(h); @@ -183,23 +183,23 @@ static void solve(LPEXPRESSION one, int num) { int j; while (num > 1) { - two=one + 1; + two = one + 1; if ((two->symbol == 0) || (one->symbol & 0xF0) <= (two->symbol & 0xF0)) { - two->val.num = Compute(one->val.num, two->val.num,one->symbol); + two->val.num = Compute(one->val.num, two->val.num, one->symbol); copyMemory(one, two, (num - 1) * sizeof(EXPRESSION)); - num--; + --num; } else { j = 1; three = two + 1; while ((three->symbol != 0) && (two->symbol & 0xF0) > (three->symbol & 0xF0)) { - two++; - three++; - j++; + ++two; + ++three; + ++j; } three->val.num = Compute(two->val.num, three->val.num, two->symbol); copyMemory(two, three, (num - j - 1) * sizeof(EXPRESSION)); - num--; + --num; } } } @@ -390,8 +390,8 @@ bool compareExpressions(HGLOBAL h1, HGLOBAL h2) { break; } - one++; - two++; + ++one; + ++two; } globalUnlock(h1); diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 3b798b8071..92ece3b0b4 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -1565,7 +1565,7 @@ void mpalFree() { * method that returns numeric results. */ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { - int x, y, z; + int x, y; Common::String buf; uint32 dwRet = 0; char *n; @@ -1718,7 +1718,7 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { lockItems(); lockVar(); x = GETARG(uint32); - z = GETARG(uint32); + int z = GETARG(uint32); y = itemGetOrderFromNum(z); if (y != -1) { dwRet = doAction(x, y, GETARG(uint32)); diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index db21be0ded..3b60e480f6 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -214,10 +214,7 @@ void RMSnapshot::grabScreenshot(byte *lpBuf, int dezoom, uint16 *lpDestBuf) { int dimx = RM_SX / dezoom; int dimy = RM_SY / dezoom; - int u, v, curv; - uint32 k = 0; - int sommar, sommab, sommag; uint16 *cursrc; if (lpDestBuf == NULL) @@ -247,10 +244,11 @@ void RMSnapshot::grabScreenshot(byte *lpBuf, int dezoom, uint16 *lpDestBuf) { for (int y = 0; y < dimy; y++) { for (int x = 0; x < dimx; x++) { cursrc = &src[RM_SKIPX + x * dezoom]; + int sommar, sommab, sommag, curv; sommar = sommab = sommag = 0; - for (v = 0; v < dezoom; v++) { - for (u = 0; u < dezoom; u++) { + for (int v = 0; v < dezoom; v++) { + for (int u = 0; u < dezoom; u++) { if (lpDestBuf == NULL) curv = -v; else -- cgit v1.2.3 From e55a16271e4a686d6a23bdb479cd5cf8ac89594a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 14 Jun 2012 22:07:36 +1000 Subject: TONY: Removed unused global static object and associated method --- engines/tony/gfxcore.cpp | 7 ------- engines/tony/gfxcore.h | 5 ----- 2 files changed, 12 deletions(-) (limited to 'engines') diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index e168d2b7c9..37fc947912 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -251,8 +251,6 @@ RMGfxWoodyBuffer::RMGfxWoodyBuffer(int dimx, int dimy, bool bUseDDraw) * RMGfxTargetBuffer Methods \****************************************************************************/ -RMGfxClearTask RMGfxTargetBuffer::taskClear; - RMGfxTargetBuffer::RMGfxTargetBuffer() { _otlist = NULL; _otSize = 0; @@ -376,11 +374,6 @@ void RMGfxTargetBuffer::addPrim(RMGfxPrimitive *prim) { // g_system->unlockMutex(csModifyingOT); } -void RMGfxTargetBuffer::addClearTask(void) { - addPrim(new RMGfxPrimitive(&taskClear)); -} - - /****************************************************************************\ * RMGfxSourceBufferPal Methods \****************************************************************************/ diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index 4461f41271..e221753a47 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -548,8 +548,6 @@ public: */ class RMGfxTargetBuffer : public virtual RMGfxBuffer { private: - static RMGfxClearTask taskClear; - struct OTList { RMGfxPrimitive *_prim; OTList *_next; @@ -576,9 +574,6 @@ public: void drawOT(CORO_PARAM); void addPrim(RMGfxPrimitive *prim); // The pointer must be delted - // Adds a task to clear the screen - void addClearTask(void); - operator byte *() { return _buf; } -- cgit v1.2.3 From 7951881d46aedb230870d843a3f7278368556657 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 14 Jun 2012 18:30:56 +0200 Subject: TONY: Fix three warnings reported by CppCheck in inventory (reported by eriktorbjorn) --- engines/tony/inventory.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'engines') diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index 76d0f0eca9..4109e5f371 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -190,11 +190,7 @@ void RMInventory::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr CORO_BEGIN_CODE(_ctx); - if (_state == OPENING || _state == CLOSING) - prim->setDst(RMPoint(0, _curPutY)); - else - prim->setDst(RMPoint(0, _curPutY)); - + prim->setDst(RMPoint(0, _curPutY)); g_system->lockMutex(_csModifyInterface); CORO_INVOKE_2(RMGfxWoodyBuffer::draw, bigBuf, prim); g_system->unlockMutex(_csModifyInterface); @@ -257,9 +253,9 @@ void RMInventory::removeItem(int code) { } void RMInventory::addItem(int code) { - if (code <= 10000 && code >= 10101) { + if (code <= 10000 || code >= 10101) { // If we are here, it means that we are adding an item that should not be in the inventory - warning("Cannot find a valid icon for this item, and then it will not be added to the inventory"); + warning("RMInventory::addItem(%d) - Cannot find a valid icon for this item, and then it will not be added to the inventory", code); } else { g_system->lockMutex(_csModifyInterface); if (_curPos + 8 == _nInv) { @@ -277,8 +273,8 @@ void RMInventory::addItem(int code) { } void RMInventory::changeItemStatus(uint32 code, uint32 dwStatus) { - if (code <= 10000 && code >= 10101) { - error("Specified object code is not valid"); + if (code <= 10000 || code >= 10101) { + error("RMInventory::changeItemStatus(%d) - Specified object code is not valid", code); } else { g_system->lockMutex(_csModifyInterface); _items[code - 10000]._icon.setPattern(dwStatus); -- cgit v1.2.3 From 7c605c5f69e350e87801912babdf5b3cd65024d3 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 15 Jun 2012 08:23:06 +0200 Subject: TONY: Silent more CppCheck warnings, remove an unused global --- engines/tony/gfxcore.cpp | 4 ++++ engines/tony/globals.cpp | 5 ++++- engines/tony/globals.h | 1 - engines/tony/inventory.cpp | 18 +++++++----------- engines/tony/loc.cpp | 16 ++++++++++++++++ 5 files changed, 31 insertions(+), 13 deletions(-) (limited to 'engines') diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 37fc947912..2f38f5d05d 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -548,6 +548,7 @@ void RMGfxSourceBuffer8::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimit RMGfxSourceBuffer8::RMGfxSourceBuffer8(int dimx, int dimy, bool bUseDDraw) : RMGfxBuffer(dimx, dimy, 8, bUseDDraw) { setPriority(0); + _bTrasp0 = false; } RMGfxSourceBuffer8::RMGfxSourceBuffer8(bool bTrasp0) { @@ -672,6 +673,8 @@ RMGfxSourceBuffer8RLE::RMGfxSourceBuffer8RLE() { _alphaBlendColor = -1; _bNeedRLECompress = true; _buf = NULL; + + _alphaR = _alphaG = _alphaB = 0; } RMGfxSourceBuffer8RLE::~RMGfxSourceBuffer8RLE() { @@ -1879,6 +1882,7 @@ void RMGfxSourceBuffer16::prepareImage(void) { RMGfxSourceBuffer16::RMGfxSourceBuffer16(int dimx, int dimy, bool bUseDDraw) : RMGfxBuffer(dimx, dimy, 16, bUseDDraw) { setPriority(0); + _bTrasp0 = false; } diff --git a/engines/tony/globals.cpp b/engines/tony/globals.cpp index e3d36db11b..45ab5f8722 100644 --- a/engines/tony/globals.cpp +++ b/engines/tony/globals.cpp @@ -134,8 +134,11 @@ Globals::Globals() { _nTonyNextTalkType = RMTony::TALK_NORMAL; _saveTonyLoc = 0; - for (int i = 0; i < 16; ++i) + for (int i = 0; i < 16; ++i) { Common::fill((byte *)&_character[i], (byte *)&_character[i] + sizeof(CharacterStruct), 0); + _isMChar[i] = false; + } + for (int i = 0; i < 10; ++i) Common::fill((byte *)&_mCharacter[i], (byte *)&_mCharacter[i] + sizeof(MCharacterStruct), 0); for (int i = 0; i < 256; ++i) diff --git a/engines/tony/globals.h b/engines/tony/globals.h index 24825588e1..2301e621aa 100644 --- a/engines/tony/globals.h +++ b/engines/tony/globals.h @@ -240,7 +240,6 @@ public: RMTony::TALKTYPE _nTonyNextTalkType; RMPoint _startLocPos[256]; - OSystem::MutexRef _cs[10]; uint32 _mut[10]; bool _bSkipIdle; diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index 4109e5f371..4d824bb10a 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -391,13 +391,11 @@ bool RMInventory::leftClick(const RMPoint &mpos, int &nCombineObj) { } void RMInventory::rightClick(const RMPoint &mpos) { - int n; - assert(checkPointInside(mpos)); if (_state == OPENED && !_bCombining) { // Open the context interface - n = mpos._x / 64; + int n = mpos._x / 64; if (n > 0 && n < RM_SX / 64 - 1 && _inv[n - 1 + _curPos] != 0) { _state = SELECTING; @@ -456,13 +454,13 @@ bool RMInventory::rightRelease(const RMPoint &mpos, RMTonyAction &curAction) { if (_state == SELECTING) { _state = OPENED; - if (_miniAction == 1) { // Esamina + if (_miniAction == 1) { // Examine curAction = TA_EXAMINE; return true; - } else if (_miniAction == 2) { // Parla + } else if (_miniAction == 2) { // Talk curAction = TA_TALK; return true; - } else if (_miniAction == 3) { // Usa + } else if (_miniAction == 3) { // Use curAction = TA_USE; return true; } @@ -474,7 +472,6 @@ bool RMInventory::rightRelease(const RMPoint &mpos, RMTonyAction &curAction) { #define INVSPEED 20 void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpos, bool bCanOpen) { - int i; bool bNeedRedraw = false; if (_state != CLOSED) { @@ -484,9 +481,10 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo // DoFrame makes all the objects currently in the inventory be displayed // @@@ Maybe we should do all takeable objects? Please does not help - for (i = 0; i < _nInv; i++) + for (int i = 0; i < _nInv; i++) { if (_items[_inv[i]]._icon.doFrame(this, false) && (i >= _curPos && i <= _curPos + 7)) bNeedRedraw = true; + } if ((_state == CLOSING || _state == OPENING || _state == OPENED) && checkPointInside(mpos)) { if (mpos._x > RM_SX - 64) { @@ -672,11 +670,9 @@ bool RMInventory::itemInFocus(const RMPoint &mpt) { } RMItem *RMInventory::whichItemIsIn(const RMPoint &mpt) { - int n; - if (_state == OPENED) { if (checkPointInside(mpt)) { - n = mpt._x / 64; + int n = mpt._x / 64; if (n > 0 && n < RM_SX / 64 - 1 && _inv[n - 1 + _curPos] != 0 && (!_bCombining || _inv[n - 1 + _curPos] != _nCombine)) return &_items[_inv[n - 1 + _curPos]]._icon; } diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 0b8398c541..42c96076f9 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -785,6 +785,7 @@ RMItem::RMItem() { _nCurSprite = 0; _bIsActive = false; + memset(_pal._data, 0, sizeof(_pal._data)); _hEndPattern = CoroScheduler.createEvent(false, false); } @@ -841,6 +842,13 @@ void RMItem::pauseSound(bool bPause) { RMWipe::RMWipe() { _hUnregistered = CoroScheduler.createEvent(false, false); _hEndOfFade = CoroScheduler.createEvent(false, false); + + _bMustRegister = false; + _bUnregister = false; + _bEndFade = false; + _bFading = false; + _nFadeStep = 0; + } RMWipe::~RMWipe() { @@ -1681,6 +1689,8 @@ RMCharacter::RMCharacter() { _bMovingWithoutMinpath = false; _bDrawNow = false; _bNeedToStop = false; + + memset(_path, 0, sizeof(_path)); _pos.set(0, 0); } @@ -1748,6 +1758,7 @@ RMDataStream &operator>>(RMDataStream &ds, RMBox &box) { RMBoxLoc::RMBoxLoc() { _boxes = NULL; + _numbBox = 0; } RMBoxLoc::~RMBoxLoc() { @@ -1936,6 +1947,8 @@ RMLocation::RMLocation() { _nItems = 0; _items = NULL; _buf = NULL; + TEMPNumLoc = 0; + _cmode = CM_256; } @@ -2292,6 +2305,9 @@ RMMessage::RMMessage(uint32 dwId) { RMMessage::RMMessage() { _lpMessage = NULL; + _nPeriods = 0; + for (int i = 0; i < 256; i++) + _lpPeriods[i] = 0; } RMMessage::~RMMessage() { -- cgit v1.2.3 From 71aa08c7f0f00be2e2c9ca013aa7682d79b6796f Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 15 Jun 2012 08:42:24 +0200 Subject: TONY: Silent more CppCheck warnings --- engines/tony/tony.cpp | 15 +++++++++++++++ engines/tony/utils.cpp | 8 +++++--- 2 files changed, 20 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index b1e45c8bfa..012dc854b9 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -61,6 +61,21 @@ TonyEngine::TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc) : Eng if (slotNumber >= 0 && slotNumber <= 99) _initialLoadSlotNumber = slotNumber; } + + _hEndOfFrame = 0; + for (int i = 0; i < 6; i++) + _stream[i] = NULL; + for (int i = 0; i < MAX_SFX_CHANNELS; i++) { + _sfx[i] = NULL; + _utilSfx[i] = NULL; + } + _bPaused = false; + _bDrawLocation = false; + _startTime = 0; + _curThumbnail = NULL; + _bQuitNow = false; + _bTimeFreezed = false; + _nTimeFreezed = 0; } TonyEngine::~TonyEngine() { diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index 8e751a811a..b6af8736bd 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -209,11 +209,9 @@ const RMString &RMString::operator=(const int ch) { * @param size Length of the string */ void RMString::connect(const char *str, int size) { - int nlen; - if (size > 0) { // Calculate the new lenght - nlen = _length + size; + int nlen = _length + size; // Resize resize(nlen + 1, true); @@ -511,6 +509,9 @@ RMDataStream::RMDataStream() { _length = 0; _pos = 0; _bError = false; + + _buf = NULL; + _ecode = 0; } /** @@ -1002,6 +1003,7 @@ RMDataStream &operator>>(RMDataStream &ds, RMRect &rc) { RMResUpdate::RMResUpdate() { _infos = NULL; + _numUpd = 0; } RMResUpdate::~RMResUpdate() { -- cgit v1.2.3 From cdbc4aa28b5c47392369879b209f9635ff431195 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 16 Jun 2012 10:57:35 +1000 Subject: TONY: Initial commit of in progress dirty rect handling --- engines/tony/gfxcore.cpp | 79 +++++++++++++++++++++++++++++++++++++++++++++- engines/tony/gfxcore.h | 22 +++++++++++++ engines/tony/gfxengine.cpp | 4 +-- engines/tony/gfxengine.h | 4 +-- engines/tony/loc.cpp | 34 ++++++++++++++------ engines/tony/loc.h | 3 ++ engines/tony/tony.cpp | 3 +- engines/tony/utils.cpp | 4 +++ engines/tony/utils.h | 1 + engines/tony/window.cpp | 35 ++++++++++++++------ engines/tony/window.h | 3 +- 11 files changed, 167 insertions(+), 25 deletions(-) (limited to 'engines') diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index e168d2b7c9..d34923e455 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -256,6 +256,7 @@ RMGfxClearTask RMGfxTargetBuffer::taskClear; RMGfxTargetBuffer::RMGfxTargetBuffer() { _otlist = NULL; _otSize = 0; + _trackDirtyRects = false; // csModifyingOT = g_system->createMutex(); } @@ -380,6 +381,66 @@ void RMGfxTargetBuffer::addClearTask(void) { addPrim(new RMGfxPrimitive(&taskClear)); } +void RMGfxTargetBuffer::addDirtyRect(const Common::Rect &r) { + assert(r.isValidRect()); + if (_trackDirtyRects && r.width() > 0 && r.height() > 0) + _currentDirtyRects.push_back(r); +} + +Common::List &RMGfxTargetBuffer::getDirtyRects() { + // Copy rects from both the current and previous frame into the output dirty rects list + Common::List::iterator i; + _dirtyRects.clear(); + for (i = _previousDirtyRects.begin(); i != _previousDirtyRects.end(); ++i) + _dirtyRects.push_back(*i); + for (i = _currentDirtyRects.begin(); i != _currentDirtyRects.end(); ++i) + _dirtyRects.push_back(*i); + + mergeDirtyRects(); + return _dirtyRects; +} + +/** + * Move the set of dirty rects from the finished current frame into the previous frame list. + */ +void RMGfxTargetBuffer::clearDirtyRects() { + Common::List::iterator i; + _previousDirtyRects.clear(); + for (i = _currentDirtyRects.begin(); i != _currentDirtyRects.end(); ++i) + _previousDirtyRects.push_back(*i); + + _currentDirtyRects.clear(); +} + +/** + * Merges any clipping rectangles that overlap to try and reduce + * the total number of clip rectangles. + */ +void RMGfxTargetBuffer::mergeDirtyRects() { + if (_dirtyRects.size() <= 1) + return; + + Common::List::iterator rOuter, rInner; + + for (rOuter = _dirtyRects.begin(); rOuter != _dirtyRects.end(); ++rOuter) { + rInner = rOuter; + while (++rInner != _dirtyRects.end()) { + + if ((*rOuter).intersects(*rInner)) { + // these two rectangles overlap or + // are next to each other - merge them + + (*rOuter).extend(*rInner); + + // remove the inner rect from the list + _dirtyRects.erase(rInner); + + // move back to beginning of list + rInner = rOuter; + } + } + } +} /****************************************************************************\ * RMGfxSourceBufferPal Methods @@ -550,6 +611,9 @@ void RMGfxSourceBuffer8::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimit buf += bufx - width; } } + + // Specify the drawn area + bigBuf.addDirtyRect(Common::Rect(dst._x1, dst._y1, dst._x1 + width, dst._y1 + height)); } RMGfxSourceBuffer8::RMGfxSourceBuffer8(int dimx, int dimy, bool bUseDDraw) @@ -660,7 +724,8 @@ void RMGfxSourceBuffer8AB::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrim } } - return; + // Specify the drawn area + bigBuf.addDirtyRect(Common::Rect(dst._x1, dst._y1, dst._x1 + width, dst._y1 + height)); } @@ -857,6 +922,9 @@ void RMGfxSourceBuffer8RLE::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPri buf += bigBuf.getDimx(); } } + + // Specify the drawn area + bigBuf.addDirtyRect(Common::Rect(x1, y1, x1 + width, y1 + height)); } @@ -1709,6 +1777,9 @@ void RMGfxSourceBuffer8AA::drawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri // Skip to the next line buf += bigBuf.getDimx(); } + + // Specify the drawn area + bigBuf.addDirtyRect(Common::Rect(x1, y1, x1 + width, y1 + height)); } @@ -1871,6 +1942,9 @@ void RMGfxSourceBuffer16::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimi raw += _dimx; } } + + // Specify the drawn area + bigBuf.addDirtyRect(Common::Rect(x1, y1, x1 + dimx, y1 + dimy)); } void RMGfxSourceBuffer16::prepareImage(void) { @@ -1922,6 +1996,9 @@ void RMGfxBox::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) uint16 *buf = bigBuf; RMRect rcDst; + // Specify the drawn area + bigBuf.addDirtyRect(rcDst); + // It takes the destination rectangle rcDst = prim->getDst(); buf += rcDst._y1 * bigBuf.getDimx() + rcDst._x1; diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index 9a00ed1646..82862d6846 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -112,11 +112,13 @@ public: _task = NULL; _src.setEmpty(); _dst.setEmpty(); + _bStretch = false; } RMGfxPrimitive(RMGfxTask *task) { _task = task; _bFlag = 0; + _bStretch = false; } RMGfxPrimitive(RMGfxTask *task, const RMRect &src, RMRect &dst) { @@ -132,6 +134,7 @@ public: _src.topLeft() = src; _dst = dst; _bFlag = 0; + _bStretch = false; } RMGfxPrimitive(RMGfxTask *task, const RMPoint &src, RMPoint &dst) { @@ -139,6 +142,7 @@ public: _src.topLeft() = src; _dst.topLeft() = dst; _bFlag = 0; + _bStretch = false; } RMGfxPrimitive(RMGfxTask *task, const RMRect &src, RMPoint &dst) { @@ -146,6 +150,7 @@ public: _src = src; _dst.topLeft() = dst; _bFlag = 0; + _bStretch = false; } RMGfxPrimitive(RMGfxTask *task, const RMRect &dst) { @@ -153,6 +158,7 @@ public: _dst = dst; _src.setEmpty(); _bFlag = 0; + _bStretch = false; } RMGfxPrimitive(RMGfxTask *task, const RMPoint &dst) { @@ -160,6 +166,7 @@ public: _dst.topLeft() = dst; _src.setEmpty(); _bFlag = 0; + _bStretch = false; } virtual ~RMGfxPrimitive() { } @@ -553,6 +560,10 @@ private: } }; + bool _trackDirtyRects; + Common::List _currentDirtyRects, _previousDirtyRects, _dirtyRects; + + void mergeDirtyRects(); private: // OSystem::MutexRef csModifyingOT; @@ -587,6 +598,17 @@ public: void offsetY(int nLines) { RMGfxBuffer::offsetY(nLines, 16); } + + // Dirty rect methods + void addDirtyRect(const Common::Rect &r); + Common::List &getDirtyRects(); + void clearDirtyRects(); + void setTrackDirtyRects(bool v) { + _trackDirtyRects = v; + } + bool getTrackDirtyRects() const { + return _trackDirtyRects; + } }; diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index deae0cb641..3ea83a8867 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -63,6 +63,7 @@ RMGfxEngine::RMGfxEngine() { // Create big buffer where the frame will be rendered _bigBuf.create(RM_BBX, RM_BBY, 16); _bigBuf.offsetY(RM_SKIPY); + _bigBuf.setTrackDirtyRects(true); _csMainLoop = NULL; _nCurLoc = 0; @@ -475,8 +476,7 @@ void RMGfxEngine::init() { delete load; // Display 'Loading' screen - // TODO: The loading screen isn't currently optimal, since the game doesn't respond to events - // whilst the mpalInit code is being executed. + _bigBuf.addDirtyRect(Common::Rect(0, 0, RM_SX, RM_SY)); _vm->_window.getNewFrame(*this, NULL); _vm->_window.repaint(); diff --git a/engines/tony/gfxengine.h b/engines/tony/gfxengine.h index 18c13d8d3d..1a37de98e1 100644 --- a/engines/tony/gfxengine.h +++ b/engines/tony/gfxengine.h @@ -109,8 +109,8 @@ public: void enableMouse(void); void disableMouse(void); - operator byte *() { - return (byte *)_bigBuf; + operator RMGfxTargetBuffer &() { + return _bigBuf; } RMInput &getInput() { return _input; diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index b2bf3b3565..26a13037c0 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -710,14 +710,13 @@ void RMItem::setStatus(int nStatus) { } void RMItem::setPattern(int nPattern, bool bPlayP0) { - int i; - assert(nPattern >= 0 && nPattern <= _nPatterns); - if (_sfx) + if (_sfx) { if (_nCurPattern > 0) _patterns[_nCurPattern].stopSfx(_sfx); - + } + // Remember the current pattern _nCurPattern = nPattern; @@ -728,10 +727,12 @@ void RMItem::setPattern(int nPattern, bool bPlayP0) { _nCurSprite = -1; // Look for the sound effect for pattern 0 - if (bPlayP0) - for (i = 0; i < _nSfx; i++) + if (bPlayP0) { + for (int i = 0; i < _nSfx; i++) { if (strcmp(_sfx[i]._name, "p0") == 0) _sfx[i].play(); + } + } } } @@ -783,6 +784,8 @@ RMItem::RMItem() { _bPal = 0; _nCurSprite = 0; + _bIsActive = false; + _hEndPattern = CoroScheduler.createEvent(false, false); } @@ -1933,6 +1936,8 @@ RMLocation::RMLocation() { _nItems = 0; _items = NULL; _buf = NULL; + _prevScroll.set(-1, -1); + _prevFixedScroll.set(-1, -1); } @@ -1967,11 +1972,8 @@ bool RMLocation::load(const char *lpszFileName) { * @returns True if succeeded OK, false in case of error. */ bool RMLocation::load(Common::File &file) { - int size; bool bRet; - // Get the file size - size = file.size(); file.seek(0); RMFileStreamSlow fs; @@ -2126,6 +2128,8 @@ bool RMLocation::loadLOX(RMDataStream &ds) { */ void RMLocation::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CONTEXT; + bool priorTracking; + bool hasChanges; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -2137,9 +2141,21 @@ void RMLocation::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri prim->setDst(_fixedScroll); + // Check whether dirty rects are being tracked, and if there are changes, leave tracking + // turned on so a dirty rect will be added for the entire background + _ctx->priorTracking = bigBuf.getTrackDirtyRects(); + _ctx->hasChanges = (_prevScroll != _curScroll) || (_prevFixedScroll != _fixedScroll); + bigBuf.setTrackDirtyRects(_ctx->priorTracking && _ctx->hasChanges); + // Invoke the drawing method fo the image class, which will draw the location background CORO_INVOKE_2(_buf->draw, bigBuf, prim); + if (_ctx->hasChanges) { + _prevScroll = _curScroll; + _prevFixedScroll = _fixedScroll; + } + bigBuf.setTrackDirtyRects(_ctx->priorTracking); + CORO_END_CODE; } diff --git a/engines/tony/loc.h b/engines/tony/loc.h index 4231c99eab..944e206ae2 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -539,6 +539,9 @@ private: RMPoint _curScroll; // Current scroll position RMPoint _fixedScroll; + RMPoint _prevScroll; // Previous scroll position + RMPoint _prevFixedScroll; + public: // @@@@@@@@@@@@@@@@@@@@@@@ RMPoint TEMPTonyStart; diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index b1e45c8bfa..28726f0a33 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -623,8 +623,9 @@ Common::Error TonyEngine::saveGameState(int slot, const Common::String &desc) { if (!GLOBALS._gfxEngine) return Common::kUnknownError; + RMGfxTargetBuffer &bigBuf = *GLOBALS._gfxEngine; RMSnapshot s; - s.grabScreenshot(*GLOBALS._gfxEngine, 4, _curThumbnail); + s.grabScreenshot(bigBuf, 4, _curThumbnail); GLOBALS._gfxEngine->saveState(getSaveStateFileName(slot), (byte *)_curThumbnail, desc); return Common::kNoError; diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index 8e751a811a..f9c2622eb2 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -922,6 +922,10 @@ int RMRect::size() const { return width() * height(); } +RMRect::operator Common::Rect() const { + return Common::Rect(_x1, _y1, _x2, _y2); +} + bool RMRect::isEmpty() const { return (_x1 == 0 && _y1 == 0 && _x2 == 0 && _y2 == 0); } diff --git a/engines/tony/utils.h b/engines/tony/utils.h index 33e2db7d7e..82c5bb020c 100644 --- a/engines/tony/utils.h +++ b/engines/tony/utils.h @@ -268,6 +268,7 @@ public: int height() const; bool isEmpty() const; int size() const; + operator Common::Rect() const; // Set void setRect(int x1, int y1, int x2, int y2); diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index db21be0ded..bf0094ff2a 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -40,7 +40,6 @@ namespace Tony { \****************************************************************************/ RMWindow::RMWindow() { - } RMWindow::~RMWindow() { @@ -61,6 +60,7 @@ void RMWindow::init() { _bGrabScreenshot = false; _bGrabThumbnail = false; _bGrabMovie = false; + _wiping = false; } /** @@ -108,13 +108,29 @@ void RMWindow::wipeEffect(Common::Rect &rcBoundEllipse) { } } -void RMWindow::getNewFrame(byte *lpBuf, Common::Rect *rcBoundEllipse) { +void RMWindow::getNewFrame(RMGfxTargetBuffer &bigBuf, Common::Rect *rcBoundEllipse) { + // Get a pointer to the bytes of the source buffer + byte *lpBuf = bigBuf; + if (rcBoundEllipse != NULL) { // Circular wipe effect getNewFrameWipe(lpBuf, *rcBoundEllipse); - } else { - // Standard screen copy + _wiping = true; + } else if (_wiping) { + // Just finished a wiping effect, so copy the full screen g_system->copyRectToScreen(lpBuf, RM_SX * 2, 0, 0, RM_SX, RM_SY); + _wiping = false; + + } else { + // Standard screen copy - iterate through the dirty rects + Common::List dirtyRects = bigBuf.getDirtyRects(); + Common::List::iterator i; + + for (i = dirtyRects.begin(); i != dirtyRects.end(); ++i) { + Common::Rect &r = *i; + const byte *lpSrc = lpBuf + (RM_SX * 2) * r.top + (r.left * 2); + g_system->copyRectToScreen(lpSrc, RM_SX * 2, r.left, r.top, r.width(), r.height()); + } } if (_bGrabThumbnail) { @@ -124,6 +140,9 @@ void RMWindow::getNewFrame(byte *lpBuf, Common::Rect *rcBoundEllipse) { s.grabScreenshot(lpBuf, 4, _wThumbBuf); _bGrabThumbnail = false; } + + // Clear the dirty rect list + bigBuf.clearDirtyRects(); } /** @@ -214,10 +233,7 @@ void RMSnapshot::grabScreenshot(byte *lpBuf, int dezoom, uint16 *lpDestBuf) { int dimx = RM_SX / dezoom; int dimy = RM_SY / dezoom; - int u, v, curv; - uint32 k = 0; - int sommar, sommab, sommag; uint16 *cursrc; if (lpDestBuf == NULL) @@ -247,10 +263,11 @@ void RMSnapshot::grabScreenshot(byte *lpBuf, int dezoom, uint16 *lpDestBuf) { for (int y = 0; y < dimy; y++) { for (int x = 0; x < dimx; x++) { cursrc = &src[RM_SKIPX + x * dezoom]; + int sommar, sommab, sommag, curv; sommar = sommab = sommag = 0; - for (v = 0; v < dezoom; v++) { - for (u = 0; u < dezoom; u++) { + for (int v = 0; v < dezoom; v++) { + for (int u = 0; u < dezoom; u++) { if (lpDestBuf == NULL) curv = -v; else diff --git a/engines/tony/window.h b/engines/tony/window.h index 34f0c1cb51..6189dd391f 100644 --- a/engines/tony/window.h +++ b/engines/tony/window.h @@ -64,6 +64,7 @@ protected: int lastsecond, lastfcount; int mskRed, mskGreen, mskBlue; + bool _wiping; bool _bGrabScreenshot; bool _bGrabThumbnail; @@ -90,7 +91,7 @@ public: void switchFullscreen(bool bFull) {} // Reads the next frame - void getNewFrame(byte *lpBuf, Common::Rect *rcBoundEllipse); + void getNewFrame(RMGfxTargetBuffer &lpBuf, Common::Rect *rcBoundEllipse); // Request a thumbnail be grabbed during the next frame void grabThumbnail(uint16 *buf); -- cgit v1.2.3 From 37f772c2d7acf314fa1b347aae410daa1337edc2 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 16 Jun 2012 18:33:38 +1000 Subject: TONY: Bugfix for hanging after giving 'shrimp' to the parrot --- engines/tony/mpal/mpal.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'engines') diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 92ece3b0b4..7e1831ec4d 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -1937,6 +1937,12 @@ void mpalQueryCORO(CORO_PARAM, uint16 wQueryType, uint32 *dwRet, ...) { */ CORO_INVOKE_2(CoroScheduler.waitForSingleObject, GLOBALS._hAskChoice, CORO_INFINITE); + // WORKAROUND: Introduce a single frame delay so that if there are multiple actions running, + // they all have time to be signalled before resetting the event. This fixes a problem where + // if you try to use the 'shrimp' on the parrot a second time after trying to first use it + // whilst the parrot was talking, the cursor wouldn't be re-enabled afterwards + CORO_SLEEP(1); + CoroScheduler.resetEvent(GLOBALS._hAskChoice); if (GLOBALS._bExecutingDialog) -- cgit v1.2.3 From 638b06660141677421aa7a342a606b0e4e593389 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 16 Jun 2012 11:09:08 +0200 Subject: TONY: Translate some Italian terms, rename enums --- engines/tony/custom.cpp | 420 +++++++++++++++++++++++----------------------- engines/tony/font.h | 10 +- engines/tony/game.cpp | 2 +- engines/tony/game.h | 26 +-- engines/tony/globals.cpp | 4 +- engines/tony/globals.h | 20 +-- engines/tony/inventory.h | 4 +- engines/tony/loc.h | 10 +- engines/tony/sound.h | 2 +- engines/tony/tony.h | 4 +- engines/tony/tonychar.cpp | 12 +- engines/tony/tonychar.h | 24 +-- 12 files changed, 267 insertions(+), 271 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index eea134e442..9acdc84932 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -92,7 +92,7 @@ const MusicFileEntry musicFiles[] = { }; -const char *staccFileNames[] = { +const char *jingleFileNames[] = { "S00.ADP", "S01.ADP", "S02.ADP", "S03.ADP", "S04.ADP", "S05.ADP", @@ -499,8 +499,8 @@ DECLARE_CUSTOM_FUNCTION(SendFullscreenMessage)(CORO_PARAM, uint32 nMsg, uint32 n CORO_END_CODE; } -DECLARE_CUSTOM_FUNCTION(NoOcchioDiBue)(CORO_PARAM, uint32, uint32, uint32, uint32) { - GLOBALS._bNoOcchioDiBue = true; +DECLARE_CUSTOM_FUNCTION(NoBullsEye)(CORO_PARAM, uint32, uint32, uint32, uint32) { + GLOBALS._bNoBullsEye = true; } DECLARE_CUSTOM_FUNCTION(CloseLocation)(CORO_PARAM, uint32, uint32, uint32, uint32) { @@ -509,7 +509,7 @@ DECLARE_CUSTOM_FUNCTION(CloseLocation)(CORO_PARAM, uint32, uint32, uint32, uint3 CORO_BEGIN_CODE(_ctx); - if (!GLOBALS._bNoOcchioDiBue) { + if (!GLOBALS._bNoBullsEye) { GLOBALS.InitWipe(1); CORO_INVOKE_0(GLOBALS.WaitWipeEnd); } @@ -531,7 +531,7 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint CORO_BEGIN_CODE(_ctx); - if (!GLOBALS._bNoOcchioDiBue) { + if (!GLOBALS._bNoBullsEye) { GLOBALS.InitWipe(1); CORO_INVOKE_0(GLOBALS.WaitWipeEnd); } @@ -555,7 +555,7 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint _vm->playMusic(4, tappetiFile[GLOBALS._lastTappeto], 0, true, 2000); } - if (!GLOBALS._bNoOcchioDiBue) { + if (!GLOBALS._bNoBullsEye) { GLOBALS.InitWipe(2); } @@ -564,12 +564,12 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint _ctx->h = mpalQueryDoAction(0, nLoc, 0); - if (!GLOBALS._bNoOcchioDiBue) { + if (!GLOBALS._bNoBullsEye) { CORO_INVOKE_0(GLOBALS.WaitWipeEnd); GLOBALS.CloseWipe(); } - GLOBALS._bNoOcchioDiBue = false; + GLOBALS._bNoBullsEye = false; // On Enter? if (_ctx->h != CORO_INVALID_PID_VALUE) @@ -1372,7 +1372,7 @@ DECLARE_CUSTOM_FUNCTION(AbortGame)(CORO_PARAM, uint32, uint32, uint32, uint32) { _vm->abortGame(); } -DECLARE_CUSTOM_FUNCTION(TremaSchermo)(CORO_PARAM, uint32 nScosse, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(ShakeScreen)(CORO_PARAM, uint32 nScosse, uint32, uint32, uint32) { CORO_BEGIN_CONTEXT; uint32 i; uint32 curTime; @@ -2131,7 +2131,7 @@ void ThreadFadeOutMusic(CORO_PARAM, const void *nMusic) { if (!GLOBALS._bFadeOutStop) _vm->setMusicVolume(nChannel, 0); - // If there is a stacchetto, stop all + // If a jingle is played, stop it if (nChannel == 2) _vm->stopMusic(2); @@ -2142,55 +2142,51 @@ void ThreadFadeOutMusic(CORO_PARAM, const void *nMusic) { CORO_END_CODE; } -DECLARE_CUSTOM_FUNCTION(FadeInSonoriz)(CORO_PARAM, uint32, uint32, uint32, uint32) { - CoroScheduler.createProcess(ThreadFadeInMusic, &GLOBALS._curSonoriz, sizeof(int)); +DECLARE_CUSTOM_FUNCTION(FadeInSoundEffect)(CORO_PARAM, uint32, uint32, uint32, uint32) { + CoroScheduler.createProcess(ThreadFadeInMusic, &GLOBALS._curSoundEffect, sizeof(int)); } -DECLARE_CUSTOM_FUNCTION(FadeOutSonoriz)(CORO_PARAM, uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(FadeOutSoundEffect)(CORO_PARAM, uint32, uint32, uint32, uint32) { GLOBALS._bFadeOutStop = false; - CoroScheduler.createProcess(ThreadFadeOutMusic, &GLOBALS._curSonoriz, sizeof(int)); + CoroScheduler.createProcess(ThreadFadeOutMusic, &GLOBALS._curSoundEffect, sizeof(int)); } -DECLARE_CUSTOM_FUNCTION(FadeOutStacchetto)(CORO_PARAM, uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(FadeOutJingle)(CORO_PARAM, uint32, uint32, uint32, uint32) { GLOBALS._bFadeOutStop = false; int channel = 2; CoroScheduler.createProcess(ThreadFadeOutMusic, &channel, sizeof(int)); } -DECLARE_CUSTOM_FUNCTION(FadeInStacchetto)(CORO_PARAM, uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(FadeInJingle)(CORO_PARAM, uint32, uint32, uint32, uint32) { int channel = 2; CoroScheduler.createProcess(ThreadFadeInMusic, &channel, sizeof(int)); } -DECLARE_CUSTOM_FUNCTION(StopSonoriz)(CORO_PARAM, uint32, uint32, uint32, uint32) { - _vm->stopMusic(GLOBALS._curSonoriz); +DECLARE_CUSTOM_FUNCTION(StopSoundEffect)(CORO_PARAM, uint32, uint32, uint32, uint32) { + _vm->stopMusic(GLOBALS._curSoundEffect); } -DECLARE_CUSTOM_FUNCTION(StopStacchetto)(CORO_PARAM, uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(StopJingle)(CORO_PARAM, uint32, uint32, uint32, uint32) { _vm->stopMusic(2); } -DECLARE_CUSTOM_FUNCTION(MuteSonoriz)(CORO_PARAM, uint32, uint32, uint32, uint32) { - _vm->setMusicVolume(GLOBALS._curSonoriz, 0); +DECLARE_CUSTOM_FUNCTION(MuteSoundEffect)(CORO_PARAM, uint32, uint32, uint32, uint32) { + _vm->setMusicVolume(GLOBALS._curSoundEffect, 0); } -DECLARE_CUSTOM_FUNCTION(DemuteSonoriz)(CORO_PARAM, uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(DemuteSoundEffect)(CORO_PARAM, uint32, uint32, uint32, uint32) { GLOBALS._bFadeOutStop = true; - _vm->setMusicVolume(GLOBALS._curSonoriz, 64); + _vm->setMusicVolume(GLOBALS._curSoundEffect, 64); } -DECLARE_CUSTOM_FUNCTION(MuteStacchetto)(CORO_PARAM, uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(MuteJingle)(CORO_PARAM, uint32, uint32, uint32, uint32) { _vm->setMusicVolume(2, 0); } -DECLARE_CUSTOM_FUNCTION(DemuteStacchetto)(CORO_PARAM, uint32, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(DemuteJingle)(CORO_PARAM, uint32, uint32, uint32, uint32) { _vm->setMusicVolume(2, 64); } - - - - void CustPlayMusic(uint32 nChannel, const char *mFN, uint32 nFX, bool bLoop, int nSync = 0) { if (nSync == 0) nSync = 2000; @@ -2199,18 +2195,18 @@ void CustPlayMusic(uint32 nChannel, const char *mFN, uint32 nFX, bool bLoop, int debug("End CustPlayMusic"); } -DECLARE_CUSTOM_FUNCTION(PlaySonoriz)(CORO_PARAM, uint32 nMusic, uint32 nFX, uint32 bNoLoop, uint32) { +DECLARE_CUSTOM_FUNCTION(PlaySoundEffect)(CORO_PARAM, uint32 nMusic, uint32 nFX, uint32 bNoLoop, uint32) { if (nFX == 0 || nFX == 1 || nFX == 2) { - debug("PlaySonoriz stop fadeout"); + debug("PlaySoundEffect stop fadeout"); GLOBALS._bFadeOutStop = true; } GLOBALS._lastMusic = nMusic; - CustPlayMusic(GLOBALS._curSonoriz, musicFiles[nMusic].name, nFX, bNoLoop ? false : true, musicFiles[nMusic].sync); + CustPlayMusic(GLOBALS._curSoundEffect, musicFiles[nMusic].name, nFX, bNoLoop ? false : true, musicFiles[nMusic].sync); } -DECLARE_CUSTOM_FUNCTION(PlayStacchetto)(CORO_PARAM, uint32 nMusic, uint32 nFX, uint32 bLoop, uint32) { - CustPlayMusic(2, staccFileNames[nMusic], nFX, bLoop); +DECLARE_CUSTOM_FUNCTION(PlayJingle)(CORO_PARAM, uint32 nMusic, uint32 nFX, uint32 bLoop, uint32) { + CustPlayMusic(2, jingleFileNames[nMusic], nFX, bLoop); } DECLARE_CUSTOM_FUNCTION(PlayItemSfx)(CORO_PARAM, uint32 nItem, uint32 nSFX, uint32, uint32) { @@ -2230,7 +2226,7 @@ void RestoreMusic(CORO_PARAM) { CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_4(PlaySonoriz, GLOBALS._lastMusic, 0, 0, 0); + CORO_INVOKE_4(PlaySoundEffect, GLOBALS._lastMusic, 0, 0, 0); if (GLOBALS._lastTappeto != 0) CustPlayMusic(4, tappetiFile[GLOBALS._lastTappeto], 0, true); @@ -2249,28 +2245,28 @@ void LoadMusic(Common::InSaveFile *f) { } -DECLARE_CUSTOM_FUNCTION(StacchettoFadeStart)(CORO_PARAM, uint32 nStacc, uint32 bLoop, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(JingleFadeStart)(CORO_PARAM, uint32 nJingle, uint32 bLoop, uint32, uint32) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_4(FadeOutSonoriz, 0, 0, 0, 0); - CORO_INVOKE_4(MuteStacchetto, 0, 0, 0, 0); - CORO_INVOKE_4(PlayStacchetto, nStacc, 0, bLoop, 0); - CORO_INVOKE_4(FadeInStacchetto, 0, 0, 0, 0); + CORO_INVOKE_4(FadeOutSoundEffect, 0, 0, 0, 0); + CORO_INVOKE_4(MuteJingle, 0, 0, 0, 0); + CORO_INVOKE_4(PlayJingle, nJingle, 0, bLoop, 0); + CORO_INVOKE_4(FadeInJingle, 0, 0, 0, 0); CORO_END_CODE; } -DECLARE_CUSTOM_FUNCTION(StacchettoFadeEnd)(CORO_PARAM, uint32 nStacc, uint32 bLoop, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(JingleFadeEnd)(CORO_PARAM, uint32 nJingle, uint32 bLoop, uint32, uint32) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_4(FadeOutStacchetto, 0, 0, 0, 0); - CORO_INVOKE_4(FadeInSonoriz, 0, 0, 0, 0); + CORO_INVOKE_4(FadeOutJingle, 0, 0, 0, 0); + CORO_INVOKE_4(FadeInSoundEffect, 0, 0, 0, 0); CORO_END_CODE; } @@ -2396,146 +2392,146 @@ DECLARE_CUSTOM_FUNCTION(DoCredits)(CORO_PARAM, uint32 nMsg, uint32 dwTime, uint3 BEGIN_CUSTOM_FUNCTION_MAP() ASSIGN(1, CustLoadLocation) -ASSIGN(2, MySleep) +ASSIGN(2, MySleep) ASSIGN(3, SetPointer) ASSIGN(5, MoveTony) -ASSIGN(6, FaceToMe) -ASSIGN(7, BackToMe) -ASSIGN(8, LeftToMe) -ASSIGN(9, RightToMe) -ASSIGN(10, SendTonyMessage) -ASSIGN(11, ChangeBoxStatus) -ASSIGN(12, ChangeLocation) -ASSIGN(13, DisableTony) -ASSIGN(14, EnableTony) -ASSIGN(15, WaitForPatternEnd) -ASSIGN(16, SetLocStartPosition) -ASSIGN(17, ScrollLocation) -ASSIGN(18, MoveTonyAndWait) -ASSIGN(19, ChangeHotspot) -ASSIGN(20, AddInventory) -ASSIGN(21, RemoveInventory) -ASSIGN(22, ChangeInventoryStatus) -ASSIGN(23, SetTonyPosition) -ASSIGN(24, SendFullscreenMessage) -ASSIGN(25, SaveTonyPosition) -ASSIGN(26, RestoreTonyPosition) -ASSIGN(27, DisableInput) -ASSIGN(28, EnableInput) -ASSIGN(29, StopTony) - -ASSIGN(30, TonyTakeUp1) -ASSIGN(31, TonyTakeMid1) -ASSIGN(32, TonyTakeDown1) -ASSIGN(33, TonyTakeUp2) -ASSIGN(34, TonyTakeMid2) -ASSIGN(35, TonyTakeDown2) - -ASSIGN(72, TonyPutUp1) -ASSIGN(73, TonyPutMid1) -ASSIGN(74, TonyPutDown1) -ASSIGN(75, TonyPutUp2) -ASSIGN(76, TonyPutMid2) -ASSIGN(77, TonyPutDown2) - -ASSIGN(36, TonyOnTheFloor) -ASSIGN(37, TonyGetUp) -ASSIGN(38, TonyShepherdess) -ASSIGN(39, TonyWhistle) - -ASSIGN(40, TonyRide) -ASSIGN(41, TonyFianchi) -ASSIGN(42, TonySing) -ASSIGN(43, TonyIndicate) -ASSIGN(44, TonyScaredWithHands) -ASSIGN(49, TonyScaredWithoutHands) -ASSIGN(45, TonyWithGlasses) -ASSIGN(46, TonyWithWorm) -ASSIGN(47, TonyWithHammer) -ASSIGN(48, TonyWithRope) -ASSIGN(90, TonyWithRabbitANIM) -ASSIGN(91, TonyWithRecipeANIM) -ASSIGN(92, TonyWithCardsANIM) -ASSIGN(93, TonyWithSnowmanANIM) -ASSIGN(94, TonyWithSnowmanStart) -ASSIGN(95, TonyWithSnowmanEnd) -ASSIGN(96, TonyWithRabbitStart) -ASSIGN(97, TonyWithRabbitEnd) -ASSIGN(98, TonyWithRecipeStart) -ASSIGN(99, TonyWithRecipeEnd) -ASSIGN(100, TonyWithCardsStart) -ASSIGN(101, TonyWithCardsEnd) -ASSIGN(102, TonyWithNotebookStart) -ASSIGN(103, TonyWithNotebookEnd) -ASSIGN(104, TonyWithMegaphoneStart) -ASSIGN(105, TonyWithMegaphoneEnd) -ASSIGN(106, TonyWithBeardStart) -ASSIGN(107, TonyWithBeardEnd) -ASSIGN(108, TonyGiggle) -ASSIGN(109, TonyDisgusted) -ASSIGN(110, TonyNaah) -ASSIGN(111, TonyMacbeth) -ASSIGN(112, TonySniffLeft) -ASSIGN(113, TonySniffRight) -ASSIGN(114, TonyScaredStart) -ASSIGN(115, TonyScaredEnd) -ASSIGN(116, TonyWithSecretary) - -ASSIGN(50, CharSetCode) -ASSIGN(51, CharSetColor) -ASSIGN(52, CharSetTalkPattern) -ASSIGN(53, CharSendMessage) -ASSIGN(54, CharSetStartEndTalkPattern) - -ASSIGN(60, MCharSetCode) -ASSIGN(61, MCharSetColor) -ASSIGN(62, MCharSetCurrentGroup) -ASSIGN(63, MCharSetNumTalksInGroup) -ASSIGN(64, MCharSetNumTexts) -ASSIGN(65, MCharSendMessage) -ASSIGN(66, MCharSetPosition) -ASSIGN(67, MCharSetAlwaysBack) -ASSIGN(68, MCharResetCode) - -ASSIGN(70, StartDialog) -ASSIGN(71, SendDialogMessage) - -ASSIGN(80, TakeOwnership) -ASSIGN(81, ReleaseOwnership) - -ASSIGN(86, PlaySonoriz) -ASSIGN(87, PlayStacchetto) -ASSIGN(88, FadeInSonoriz) -ASSIGN(89, FadeOutSonoriz) -ASSIGN(123, FadeInStacchetto) -ASSIGN(124, FadeOutStacchetto) -ASSIGN(125, MuteSonoriz) -ASSIGN(126, DemuteSonoriz) -ASSIGN(127, MuteStacchetto) -ASSIGN(128, DemuteStacchetto) -ASSIGN(84, StopSonoriz) -ASSIGN(85, StopStacchetto) -ASSIGN(83, PlayItemSfx) -ASSIGN(129, StacchettoFadeStart) -ASSIGN(130, StacchettoFadeEnd) - -ASSIGN(120, TremaSchermo) -ASSIGN(121, AutoSave) -ASSIGN(122, AbortGame) -ASSIGN(131, NoOcchioDiBue) -ASSIGN(132, SendFullscreenMsgStart) -ASSIGN(133, SendFullscreenMsgEnd) -ASSIGN(134, CustEnableGUI) -ASSIGN(135, CustDisableGUI) -ASSIGN(136, ClearScreen) -ASSIGN(137, PatIrqFreeze) -ASSIGN(138, TonySetPerorate) -ASSIGN(139, OpenInitLoadMenu) -ASSIGN(140, OpenInitOptions) -ASSIGN(141, SyncScrollLocation) -ASSIGN(142, CloseLocation) -ASSIGN(143, SetAlwaysDisplay) -ASSIGN(144, DoCredits) +ASSIGN(6, FaceToMe) +ASSIGN(7, BackToMe) +ASSIGN(8, LeftToMe) +ASSIGN(9, RightToMe) +ASSIGN(10, SendTonyMessage) +ASSIGN(11, ChangeBoxStatus) +ASSIGN(12, ChangeLocation) +ASSIGN(13, DisableTony) +ASSIGN(14, EnableTony) +ASSIGN(15, WaitForPatternEnd) +ASSIGN(16, SetLocStartPosition) +ASSIGN(17, ScrollLocation) +ASSIGN(18, MoveTonyAndWait) +ASSIGN(19, ChangeHotspot) +ASSIGN(20, AddInventory) +ASSIGN(21, RemoveInventory) +ASSIGN(22, ChangeInventoryStatus) +ASSIGN(23, SetTonyPosition) +ASSIGN(24, SendFullscreenMessage) +ASSIGN(25, SaveTonyPosition) +ASSIGN(26, RestoreTonyPosition) +ASSIGN(27, DisableInput) +ASSIGN(28, EnableInput) +ASSIGN(29, StopTony) + +ASSIGN(30, TonyTakeUp1) +ASSIGN(31, TonyTakeMid1) +ASSIGN(32, TonyTakeDown1) +ASSIGN(33, TonyTakeUp2) +ASSIGN(34, TonyTakeMid2) +ASSIGN(35, TonyTakeDown2) + +ASSIGN(72, TonyPutUp1) +ASSIGN(73, TonyPutMid1) +ASSIGN(74, TonyPutDown1) +ASSIGN(75, TonyPutUp2) +ASSIGN(76, TonyPutMid2) +ASSIGN(77, TonyPutDown2) + +ASSIGN(36, TonyOnTheFloor) +ASSIGN(37, TonyGetUp) +ASSIGN(38, TonyShepherdess) +ASSIGN(39, TonyWhistle) + +ASSIGN(40, TonyRide) +ASSIGN(41, TonyFianchi) +ASSIGN(42, TonySing) +ASSIGN(43, TonyIndicate) +ASSIGN(44, TonyScaredWithHands) +ASSIGN(49, TonyScaredWithoutHands) +ASSIGN(45, TonyWithGlasses) +ASSIGN(46, TonyWithWorm) +ASSIGN(47, TonyWithHammer) +ASSIGN(48, TonyWithRope) +ASSIGN(90, TonyWithRabbitANIM) +ASSIGN(91, TonyWithRecipeANIM) +ASSIGN(92, TonyWithCardsANIM) +ASSIGN(93, TonyWithSnowmanANIM) +ASSIGN(94, TonyWithSnowmanStart) +ASSIGN(95, TonyWithSnowmanEnd) +ASSIGN(96, TonyWithRabbitStart) +ASSIGN(97, TonyWithRabbitEnd) +ASSIGN(98, TonyWithRecipeStart) +ASSIGN(99, TonyWithRecipeEnd) +ASSIGN(100, TonyWithCardsStart) +ASSIGN(101, TonyWithCardsEnd) +ASSIGN(102, TonyWithNotebookStart) +ASSIGN(103, TonyWithNotebookEnd) +ASSIGN(104, TonyWithMegaphoneStart) +ASSIGN(105, TonyWithMegaphoneEnd) +ASSIGN(106, TonyWithBeardStart) +ASSIGN(107, TonyWithBeardEnd) +ASSIGN(108, TonyGiggle) +ASSIGN(109, TonyDisgusted) +ASSIGN(110, TonyNaah) +ASSIGN(111, TonyMacbeth) +ASSIGN(112, TonySniffLeft) +ASSIGN(113, TonySniffRight) +ASSIGN(114, TonyScaredStart) +ASSIGN(115, TonyScaredEnd) +ASSIGN(116, TonyWithSecretary) + +ASSIGN(50, CharSetCode) +ASSIGN(51, CharSetColor) +ASSIGN(52, CharSetTalkPattern) +ASSIGN(53, CharSendMessage) +ASSIGN(54, CharSetStartEndTalkPattern) + +ASSIGN(60, MCharSetCode) +ASSIGN(61, MCharSetColor) +ASSIGN(62, MCharSetCurrentGroup) +ASSIGN(63, MCharSetNumTalksInGroup) +ASSIGN(64, MCharSetNumTexts) +ASSIGN(65, MCharSendMessage) +ASSIGN(66, MCharSetPosition) +ASSIGN(67, MCharSetAlwaysBack) +ASSIGN(68, MCharResetCode) + +ASSIGN(70, StartDialog) +ASSIGN(71, SendDialogMessage) + +ASSIGN(80, TakeOwnership) +ASSIGN(81, ReleaseOwnership) + +ASSIGN(86, PlaySoundEffect) +ASSIGN(87, PlayJingle) +ASSIGN(88, FadeInSoundEffect) +ASSIGN(89, FadeOutSoundEffect) +ASSIGN(123, FadeInJingle) +ASSIGN(124, FadeOutJingle) +ASSIGN(125, MuteSoundEffect) +ASSIGN(126, DemuteSoundEffect) +ASSIGN(127, MuteJingle) +ASSIGN(128, DemuteJingle) +ASSIGN(84, StopSoundEffect) +ASSIGN(85, StopJingle) +ASSIGN(83, PlayItemSfx) +ASSIGN(129, JingleFadeStart) +ASSIGN(130, JingleFadeEnd) + +ASSIGN(120, ShakeScreen) +ASSIGN(121, AutoSave) +ASSIGN(122, AbortGame) +ASSIGN(131, NoBullsEye) +ASSIGN(132, SendFullscreenMsgStart) +ASSIGN(133, SendFullscreenMsgEnd) +ASSIGN(134, CustEnableGUI) +ASSIGN(135, CustDisableGUI) +ASSIGN(136, ClearScreen) +ASSIGN(137, PatIrqFreeze) +ASSIGN(138, TonySetPerorate) +ASSIGN(139, OpenInitLoadMenu) +ASSIGN(140, OpenInitOptions) +ASSIGN(141, SyncScrollLocation) +ASSIGN(142, CloseLocation) +ASSIGN(143, SetAlwaysDisplay) +ASSIGN(144, DoCredits) ASSIGN(200, MustSkipIdleStart); ASSIGN(201, MustSkipIdleEnd); @@ -2573,37 +2569,37 @@ void setupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation for (i = 0; i < 200; i++) GLOBALS._tappeti[i] = 0; - GLOBALS._tappeti[6] = T_GRILLI; - GLOBALS._tappeti[7] = T_GRILLI; - GLOBALS._tappeti[8] = T_GRILLIOV; - GLOBALS._tappeti[10] = T_GRILLI; - GLOBALS._tappeti[12] = T_GRILLI; - GLOBALS._tappeti[13] = T_GRILLIOV; - GLOBALS._tappeti[15] = T_GRILLI; - GLOBALS._tappeti[16] = T_GRILLIVENTO; - GLOBALS._tappeti[18] = T_GRILLI; - GLOBALS._tappeti[19] = T_GRILLIVENTO; - GLOBALS._tappeti[20] = T_GRILLI; - GLOBALS._tappeti[23] = T_GRILLI; - GLOBALS._tappeti[26] = T_MAREMETA; - GLOBALS._tappeti[27] = T_GRILLI; - GLOBALS._tappeti[28] = T_GRILLIVENTO; - GLOBALS._tappeti[31] = T_GRILLI; - GLOBALS._tappeti[33] = T_MARE; - GLOBALS._tappeti[35] = T_MARE; - GLOBALS._tappeti[36] = T_GRILLI; - GLOBALS._tappeti[37] = T_GRILLI; - GLOBALS._tappeti[40] = T_GRILLI; - GLOBALS._tappeti[41] = T_GRILLI; - GLOBALS._tappeti[42] = T_GRILLI; - GLOBALS._tappeti[45] = T_GRILLI; - GLOBALS._tappeti[51] = T_GRILLI; - GLOBALS._tappeti[52] = T_GRILLIVENTO1; - GLOBALS._tappeti[53] = T_GRILLI; - GLOBALS._tappeti[54] = T_GRILLI; - GLOBALS._tappeti[57] = T_VENTO; - GLOBALS._tappeti[58] = T_VENTO; - GLOBALS._tappeti[60] = T_VENTO; + GLOBALS._tappeti[6] = TAPPETI_GRILLI; + GLOBALS._tappeti[7] = TAPPETI_GRILLI; + GLOBALS._tappeti[8] = TAPPETI_GRILLIOV; + GLOBALS._tappeti[10] = TAPPETI_GRILLI; + GLOBALS._tappeti[12] = TAPPETI_GRILLI; + GLOBALS._tappeti[13] = TAPPETI_GRILLIOV; + GLOBALS._tappeti[15] = TAPPETI_GRILLI; + GLOBALS._tappeti[16] = TAPPETI_GRILLIVENTO; + GLOBALS._tappeti[18] = TAPPETI_GRILLI; + GLOBALS._tappeti[19] = TAPPETI_GRILLIVENTO; + GLOBALS._tappeti[20] = TAPPETI_GRILLI; + GLOBALS._tappeti[23] = TAPPETI_GRILLI; + GLOBALS._tappeti[26] = TAPPETI_MAREMETA; + GLOBALS._tappeti[27] = TAPPETI_GRILLI; + GLOBALS._tappeti[28] = TAPPETI_GRILLIVENTO; + GLOBALS._tappeti[31] = TAPPETI_GRILLI; + GLOBALS._tappeti[33] = TAPPETI_MARE; + GLOBALS._tappeti[35] = TAPPETI_MARE; + GLOBALS._tappeti[36] = TAPPETI_GRILLI; + GLOBALS._tappeti[37] = TAPPETI_GRILLI; + GLOBALS._tappeti[40] = TAPPETI_GRILLI; + GLOBALS._tappeti[41] = TAPPETI_GRILLI; + GLOBALS._tappeti[42] = TAPPETI_GRILLI; + GLOBALS._tappeti[45] = TAPPETI_GRILLI; + GLOBALS._tappeti[51] = TAPPETI_GRILLI; + GLOBALS._tappeti[52] = TAPPETI_GRILLIVENTO1; + GLOBALS._tappeti[53] = TAPPETI_GRILLI; + GLOBALS._tappeti[54] = TAPPETI_GRILLI; + GLOBALS._tappeti[57] = TAPPETI_VENTO; + GLOBALS._tappeti[58] = TAPPETI_VENTO; + GLOBALS._tappeti[60] = TAPPETI_VENTO; diff --git a/engines/tony/font.h b/engines/tony/font.h index 328d501e27..f24223d551 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -178,22 +178,22 @@ private: int _maxLineLength; public: - enum HORALIGN { + enum HorAlign { HLEFT, HLEFTPAR, HCENTER, HRIGHT }; - enum VERALIGN { + enum VerAlign { VTOP, VCENTER, VBOTTOM }; private: - HORALIGN _aHorType; - VERALIGN _aVerType; + HorAlign _aHorType; + VerAlign _aVerType; byte _textR, _textG, _textB; protected: @@ -206,7 +206,7 @@ public: static void unload(); // Set the alignment type - void setAlignType(HORALIGN aHor, VERALIGN aVer) { + void setAlignType(HorAlign aHor, VerAlign aVer) { _aHorType = aHor; _aVerType = aVer; } diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 03479d96a5..cca55f00dd 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -1003,7 +1003,7 @@ int RMOptionScreen::priority() { return 190; } -void RMOptionScreen::changeState(CORO_PARAM, STATE newState) { +void RMOptionScreen::changeState(CORO_PARAM, OptionScreenState newState) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); diff --git a/engines/tony/game.h b/engines/tony/game.h index 9ac8f76bcc..bd15b962e6 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -70,7 +70,7 @@ private: void updateCursor(); public: - enum POINTER { + enum PointerType { PTR_NONE = 0, PTR_FRECCIASU, PTR_FRECCIAGIU, @@ -107,15 +107,15 @@ public: } // Sets a new pointer - void setSpecialPointer(POINTER ptr) { + void setSpecialPointer(PointerType ptr) { _nCurSpecialPointer = ptr; if (_nCurSpecialPointer && _nCurSpecialPointer != PTR_CUSTOM) _specialPointer[ptr - 1]->setPattern(1); updateCursor(); } - POINTER getSpecialPointer(void) { - return (POINTER)_nCurSpecialPointer; + PointerType getSpecialPointer(void) { + return (PointerType)_nCurSpecialPointer; } // Set the new custom pointer @@ -251,17 +251,17 @@ private: bool _bNoLoadSave; bool _bAlterGfx; - enum STATE { - MENUGAME, - MENUGFX, - MENUSOUND, - MENULOAD, - MENUSAVE, + enum OptionScreenState { + MENUGAME, + MENUGFX, + MENUSOUND, + MENULOAD, + MENUSAVE, MENUNONE }; - STATE _nState; - STATE _nLastState; + OptionScreenState _nState; + OptionScreenState _nLastState; public: RMOptionScreen(); @@ -291,7 +291,7 @@ protected: // Initialisation and state change void initState(CORO_PARAM); void closeState(void); - void changeState(CORO_PARAM, STATE newState); + void changeState(CORO_PARAM, OptionScreenState newState); // Repaint the options menu void refreshAll(CORO_PARAM); diff --git a/engines/tony/globals.cpp b/engines/tony/globals.cpp index 45ab5f8722..9115dafd63 100644 --- a/engines/tony/globals.cpp +++ b/engines/tony/globals.cpp @@ -80,9 +80,9 @@ Globals::Globals() { _nCfgSFXVolume = 0; _bIdleExited = false; _bSkipSfxNoLoop = false; - _bNoOcchioDiBue = false; + _bNoBullsEye = false; _curDialog = 0; - _curSonoriz = 0; + _curSoundEffect = 0; _bFadeOutStop = false; // OSystem::MutexRef vdb; diff --git a/engines/tony/globals.h b/engines/tony/globals.h index 2301e621aa..33ed36751a 100644 --- a/engines/tony/globals.h +++ b/engines/tony/globals.h @@ -35,13 +35,13 @@ namespace Tony { -#define T_GRILLI 1 -#define T_GRILLIOV 2 -#define T_GRILLIVENTO 3 -#define T_GRILLIVENTO1 4 -#define T_VENTO 5 -#define T_MARE 6 -#define T_MAREMETA 7 +#define TAPPETI_GRILLI 1 +#define TAPPETI_GRILLIOV 2 +#define TAPPETI_GRILLIVENTO 3 +#define TAPPETI_GRILLIVENTO1 4 +#define TAPPETI_VENTO 5 +#define TAPPETI_MARE 6 +#define TAPPETI_MAREMETA 7 #define MAX_PATH 255 @@ -207,9 +207,9 @@ public: int _nCfgSFXVolume; bool _bSkipSfxNoLoop; bool _bIdleExited; - bool _bNoOcchioDiBue; + bool _bNoBullsEye; int _curDialog; - int _curSonoriz; + int _curSoundEffect; bool _bFadeOutStop; RMTony *_tony; @@ -237,7 +237,7 @@ public: uint32 _dwTonyNumTexts; bool _bTonyInTexts; bool _bStaticTalk; - RMTony::TALKTYPE _nTonyNextTalkType; + RMTony::CharacterTalkType _nTonyNextTalkType; RMPoint _startLocPos[256]; uint32 _mut[10]; diff --git a/engines/tony/inventory.h b/engines/tony/inventory.h index b739e16f72..e010a09dd5 100644 --- a/engines/tony/inventory.h +++ b/engines/tony/inventory.h @@ -46,7 +46,7 @@ struct RMInventoryItem { class RMInventory : public RMGfxWoodyBuffer { private: - enum STATE { + enum InventoryState { CLOSED, OPENING, OPENED, @@ -64,7 +64,7 @@ protected: uint32 _curPutTime; int _curPos; - STATE _state; + InventoryState _state; bool _bHasFocus; int _nSelectObj; int _nCombine; diff --git a/engines/tony/loc.h b/engines/tony/loc.h index 4231c99eab..00fcb579c8 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -314,7 +314,7 @@ protected: class RMBox { public: - struct T_HOTSPOT { + struct Hotspot { int _hotx, _hoty; // Hotspot coordinates int _destination; // Hotspot destination }; @@ -324,7 +324,7 @@ public: int _adj[MAXBOXES]; // List of adjacent bounding boxes int _numHotspot; // Hotspot number uint8 _destZ; // Z value for the bounding box - T_HOTSPOT _hotspot[MAXHOTSPOT]; // List of hotspots + Hotspot _hotspot[MAXHOTSPOT]; // List of hotspots bool _bActive; bool _bReversed; @@ -388,7 +388,7 @@ public: class RMCharacter : protected RMItem { public: - enum PATTERNS { + enum Patterns { PAT_STANDUP = 1, PAT_STANDDOWN, PAT_STANDLEFT, @@ -400,7 +400,7 @@ public: }; private: - enum STATUS { + enum CharacterStatus { STAND, WALK }; @@ -416,7 +416,7 @@ private: short _pathLength, _pathCount; int _curBox; - STATUS _status; + CharacterStatus _status; int _curSpeed; bool _bEndOfPath; uint32 _hEndOfPath; diff --git a/engines/tony/sound.h b/engines/tony/sound.h index 24e7f34921..abd7e06cae 100644 --- a/engines/tony/sound.h +++ b/engines/tony/sound.h @@ -44,7 +44,7 @@ namespace Tony { class FPSTREAM; class FPSFX; -enum CODECS { +enum SoundCodecs { FPCODEC_RAW, FPCODEC_ADPCM }; diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 43bc23c636..8df2da697c 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -104,7 +104,7 @@ public: Globals _globals; Debugger *_debugger; - enum DATADIR { + enum DataDir { DD_BASE = 1, DD_SAVE, DD_SHOTS, @@ -161,7 +161,7 @@ public: void close(); void abortGame(); - void getDataDirectory(DATADIR dir, char *path); + void getDataDirectory(DataDir dir, char *path); void switchFullscreen(bool bFull); void optionScreen(void); diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index 0f16bc45c3..17f046fb92 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -550,7 +550,7 @@ void RMTony::put(int nWhere, int nPart) { } -bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &bodyStartPat, +bool RMTony::startTalkCalculate(CharacterTalkType nTalkType, int &headStartPat, int &bodyStartPat, int &headLoopPat, int &bodyLoopPat) { assert(!_bIsTalking); @@ -1109,7 +1109,7 @@ bool RMTony::startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &body return true; } -void RMTony::startTalk(CORO_PARAM, TALKTYPE nTalkType) { +void RMTony::startTalk(CORO_PARAM, CharacterTalkType nTalkType) { CORO_BEGIN_CONTEXT; int headStartPat, bodyStartPat; int headLoopPat, bodyLoopPat; @@ -1518,7 +1518,7 @@ void RMTony::endTalk(CORO_PARAM) { CORO_END_CODE; } -void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat, +void RMTony::startStaticCalculate(CharacterTalkType nTalk, int &headPat, int &headLoopPat, int &bodyStartPat, int &bodyLoopPat) { int nPat = getCurPattern(); @@ -1725,7 +1725,7 @@ void RMTony::startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat } } -void RMTony::startStatic(CORO_PARAM, TALKTYPE nTalk) { +void RMTony::startStatic(CORO_PARAM, CharacterTalkType nTalk) { CORO_BEGIN_CONTEXT; int headPat, headLoopPat; int bodyStartPat, bodyLoopPat; @@ -1760,7 +1760,7 @@ void RMTony::startStatic(CORO_PARAM, TALKTYPE nTalk) { } -void RMTony::endStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, int &headEndPat) { +void RMTony::endStaticCalculate(CharacterTalkType nTalk, int &bodyEndPat, int &finalPat, int &headEndPat) { switch (_talkDirection) { case UP: case LEFT: @@ -1896,7 +1896,7 @@ void RMTony::endStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, } } -void RMTony::endStatic(CORO_PARAM, TALKTYPE nTalk) { +void RMTony::endStatic(CORO_PARAM, CharacterTalkType nTalk) { CORO_BEGIN_CONTEXT; int bodyEndPat; int finalPat; diff --git a/engines/tony/tonychar.h b/engines/tony/tonychar.h index e5231d89fd..203d391fbe 100644 --- a/engines/tony/tonychar.h +++ b/engines/tony/tonychar.h @@ -36,12 +36,12 @@ namespace Tony { class RMTony : public RMCharacter { private: - enum DIRECTION { + enum CharacterDirection { UP, DOWN, LEFT, RIGHT }; public: - enum TALKTYPE { + enum CharacterTalkType { TALK_NORMAL, TALK_FIANCHI, TALK_SING, @@ -97,8 +97,8 @@ private: bool _bIsStaticTalk; bool _bIsTalking; int _nPatB4Talking; - TALKTYPE _nTalkType; - DIRECTION _talkDirection; + CharacterTalkType _nTalkType; + CharacterDirection _talkDirection; RMPoint _nBodyOffset; int _nTimeLastStep; @@ -114,7 +114,7 @@ protected: static void waitEndOfAction(CORO_PARAM, const void *param); public: - enum PATTERNS { + enum CharacterPatterns { PAT_TAKEUP_UP1 = 9, PAT_TAKEUP_UP2, PAT_TAKEUP_MID1, @@ -247,7 +247,7 @@ public: PAT_WITHSECRETARY }; - enum BODYPATTERNS { + enum CharacterBodyPatterns { BPAT_STANDUP = 1, BPAT_STANDDOWN, BPAT_STANDLEFT, @@ -421,18 +421,18 @@ public: void put(int nWhere, int nPart); // Start or End Talk - bool startTalkCalculate(TALKTYPE nTalkType, int &headStartPat, int &bodyStartPat, + bool startTalkCalculate(CharacterTalkType nTalkType, int &headStartPat, int &bodyStartPat, int &headLoopPat, int &bodyLoopPat); - void startTalk(CORO_PARAM, TALKTYPE nTalkType); + void startTalk(CORO_PARAM, CharacterTalkType nTalkType); bool endTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPat, int &finalPat, bool &bStatic); void endTalk(CORO_PARAM); // Start or End Static - void startStaticCalculate(TALKTYPE nTalk, int &headPat, int &headLoopPat, + void startStaticCalculate(CharacterTalkType nTalk, int &headPat, int &headLoopPat, int &bodyStartPat, int &bodyLoopPat); - void startStatic(CORO_PARAM, TALKTYPE nTalkType); - void endStaticCalculate(TALKTYPE nTalk, int &bodyEndPat, int &finalPat, int &headEndPat); - void endStatic(CORO_PARAM, TALKTYPE nTalkType); + void startStatic(CORO_PARAM, CharacterTalkType nTalkType); + void endStaticCalculate(CharacterTalkType nTalk, int &bodyEndPat, int &finalPat, int &headEndPat); + void endStatic(CORO_PARAM, CharacterTalkType nTalkType); // Tony disguises himself! void setShepherdess(bool bIsPast) { -- cgit v1.2.3 From ddd1414a56568d62348e56ccc907b8ba7bb296eb Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 16 Jun 2012 11:32:50 +0200 Subject: TONY: Rename sound functions and class names --- engines/tony/custom.cpp | 72 +++++++++++---------- engines/tony/loc.cpp | 14 ++-- engines/tony/loc.h | 2 +- engines/tony/sound.cpp | 165 +++++++++++++++++++++++++----------------------- engines/tony/sound.h | 152 ++++++++++++++++++++++---------------------- engines/tony/tony.cpp | 54 ++++++++-------- engines/tony/tony.h | 12 ++-- 7 files changed, 239 insertions(+), 232 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 9acdc84932..ef4f889a12 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -253,7 +253,7 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX int i; int curOffset; VoiceHeader *curVoc; - FPSFX *voice; + FPSfx *voice; RMTextDialog text; CORO_END_CONTEXT(_ctx); @@ -276,12 +276,12 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX // First time allocation _vm->_vdbFP.seek(_ctx->curOffset); - _vm->_theSound.CreateSfx(&_ctx->voice); + _vm->_theSound.createSfx(&_ctx->voice); - _ctx->voice->LoadVoiceFromVDB(_vm->_vdbFP); + _ctx->voice->loadVoiceFromVDB(_vm->_vdbFP); _ctx->curOffset = _vm->_vdbFP.pos(); - _ctx->voice->SetLoop(false); + _ctx->voice->setLoop(false); } if (GLOBALS._nTonyNextTalkType != GLOBALS._tony->TALK_NORMAL) { @@ -330,16 +330,16 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX if (_ctx->curVoc) { if (_ctx->i == 0) { - _ctx->voice->Play(); + _ctx->voice->play(); _ctx->text.setCustomSkipHandle2(_ctx->voice->hEndOfBuffer); } else { _vm->_vdbFP.seek(_ctx->curOffset); - _vm->_theSound.CreateSfx(&_ctx->voice); - _ctx->voice->LoadVoiceFromVDB(_vm->_vdbFP); + _vm->_theSound.createSfx(&_ctx->voice); + _ctx->voice->loadVoiceFromVDB(_vm->_vdbFP); _ctx->curOffset = _vm->_vdbFP.pos(); - _ctx->voice->SetLoop(false); - _ctx->voice->Play(); + _ctx->voice->setLoop(false); + _ctx->voice->play(); _ctx->text.setCustomSkipHandle2(_ctx->voice->hEndOfBuffer); } } @@ -349,8 +349,8 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX CORO_INVOKE_0(_ctx->text.waitForEndDisplay); if (_ctx->curVoc) { - _ctx->voice->Stop(); - _ctx->voice->Release(); + _ctx->voice->stop(); + _ctx->voice->release(); _ctx->voice = NULL; } } @@ -1458,7 +1458,7 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess RMTextDialog *text; int curOffset; VoiceHeader *curVoc; - FPSFX *voice; + FPSfx *voice; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -1524,12 +1524,12 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess GLOBALS.LinkGraphicTask(_ctx->text); if (_ctx->curVoc) { - _vm->_theSound.CreateSfx(&_ctx->voice); + _vm->_theSound.createSfx(&_ctx->voice); _vm->_vdbFP.seek(_ctx->curOffset); - _ctx->voice->LoadVoiceFromVDB(_vm->_vdbFP); - _ctx->voice->SetLoop(false); - if (bIsBack) _ctx->voice->SetVolume(55); - _ctx->voice->Play(); + _ctx->voice->loadVoiceFromVDB(_vm->_vdbFP); + _ctx->voice->setLoop(false); + if (bIsBack) _ctx->voice->setVolume(55); + _ctx->voice->play(); _ctx->text->setCustomSkipHandle2(_ctx->voice->hEndOfBuffer); _ctx->curOffset = _vm->_vdbFP.pos(); } @@ -1539,8 +1539,8 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess CORO_INVOKE_0(_ctx->text->waitForEndDisplay); if (_ctx->curVoc) { - _ctx->voice->Stop(); - _ctx->voice->Release(); + _ctx->voice->stop(); + _ctx->voice->release(); _ctx->voice = NULL; } @@ -1662,7 +1662,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes RMTextDialog *text; int curOffset; VoiceHeader *curVoc; - FPSFX *voice; + FPSfx *voice; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -1737,12 +1737,13 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes GLOBALS.LinkGraphicTask(_ctx->text); if (_ctx->curVoc) { - _vm->_theSound.CreateSfx(&_ctx->voice); + _vm->_theSound.createSfx(&_ctx->voice); _vm->_vdbFP.seek(_ctx->curOffset); - _ctx->voice->LoadVoiceFromVDB(_vm->_vdbFP); - _ctx->voice->SetLoop(false); - if (bIsBack) _ctx->voice->SetVolume(55); - _ctx->voice->Play(); + _ctx->voice->loadVoiceFromVDB(_vm->_vdbFP); + _ctx->voice->setLoop(false); + if (bIsBack) + _ctx->voice->setVolume(55); + _ctx->voice->play(); _ctx->text->setCustomSkipHandle2(_ctx->voice->hEndOfBuffer); _ctx->curOffset = _vm->_vdbFP.pos(); } @@ -1752,8 +1753,8 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes CORO_INVOKE_0(_ctx->text->waitForEndDisplay); if (_ctx->curVoc) { - _ctx->voice->Stop(); - _ctx->voice->Release(); + _ctx->voice->stop(); + _ctx->voice->release(); _ctx->voice = NULL; } @@ -1787,7 +1788,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg uint32 h; bool bIsBack; VoiceHeader *curVoc; - FPSFX *voice; + FPSfx *voice; RMPoint pt; CORO_END_CONTEXT(_ctx); @@ -1805,10 +1806,11 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg if (_ctx->curVoc) { // Position within the database of entries, beginning at the first _vm->_vdbFP.seek(_ctx->curVoc->_offset); - _vm->_theSound.CreateSfx(&_ctx->voice); - _ctx->voice->LoadVoiceFromVDB(_vm->_vdbFP); - _ctx->voice->SetLoop(false); - if (_ctx->bIsBack) _ctx->voice->SetVolume(55); + _vm->_theSound.createSfx(&_ctx->voice); + _ctx->voice->loadVoiceFromVDB(_vm->_vdbFP); + _ctx->voice->setLoop(false); + if (_ctx->bIsBack) + _ctx->voice->setVolume(55); } _ctx->string = mpalQueryDialogPeriod(nMsg); @@ -1904,7 +1906,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg GLOBALS.LinkGraphicTask(_ctx->text); if (_ctx->curVoc) { - _ctx->voice->Play(); + _ctx->voice->play(); _ctx->text->setCustomSkipHandle2(_ctx->voice->hEndOfBuffer); } @@ -1914,8 +1916,8 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg } if (_ctx->curVoc) { - _ctx->voice->Stop(); - _ctx->voice->Release(); + _ctx->voice->stop(); + _ctx->voice->release(); _ctx->voice = NULL; } diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 42c96076f9..d36c004baf 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -409,7 +409,7 @@ void RMSfx::readFromStream(RMDataStream &ds, bool bLOX) { // Create the sound effect _fx = _vm->createSFX(stream); - _fx->SetLoop(false); + _fx->setLoop(false); } RMSfx::RMSfx() { @@ -419,15 +419,15 @@ RMSfx::RMSfx() { RMSfx::~RMSfx() { if (_fx) { - _fx->Release(); + _fx->release(); _fx = NULL; } } void RMSfx::play(bool bLoop) { if (_fx && !_bPlayingLoop) { - _fx->SetLoop(bLoop); - _fx->Play(); + _fx->setLoop(bLoop); + _fx->play(); if (bLoop) _bPlayingLoop = true; @@ -436,19 +436,19 @@ void RMSfx::play(bool bLoop) { void RMSfx::setVolume(int vol) { if (_fx) { - _fx->SetVolume(vol); + _fx->setVolume(vol); } } void RMSfx::pause(bool bPause) { if (_fx) { - _fx->Pause(bPause); + _fx->pause(bPause); } } void RMSfx::stop(void) { if (_fx) { - _fx->Stop(); + _fx->stop(); _bPlayingLoop = false; } } diff --git a/engines/tony/loc.h b/engines/tony/loc.h index 00fcb579c8..ac0bb1d69a 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -72,7 +72,7 @@ public: class RMSfx { public: RMString _name; - FPSFX *_fx; + FPSfx *_fx; bool _bPlayingLoop; public: diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index b3bdd1be9a..35db3ced38 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -41,28 +41,28 @@ namespace Tony { * Defines \****************************************************************************/ -#define RELEASE(x) {if ((x) != NULL) { (x)->Release(); x = NULL; }} +#define RELEASE(x) {if ((x) != NULL) { (x)->release(); x = NULL; }} /****************************************************************************\ -* Metodi per FPSOUND +* Metodi per FPSound \****************************************************************************/ /****************************************************************************\ * -* Function: FPSOUND::FPSOUND(); +* Function: FPSound::FPSound(); * * Description: Costruttore di default. Inizializza gli attributi. * \****************************************************************************/ -FPSOUND::FPSOUND() { +FPSound::FPSound() { bSoundSupported = false; } /****************************************************************************\ * -* Function: bool FPSOUND::Init(); +* Function: bool FPSound::Init(); * * Description: Inizializza l'oggetto, e prepara tutto il necessario per * creare stream e effetti sonori. @@ -71,7 +71,7 @@ FPSOUND::FPSOUND() { * \****************************************************************************/ -bool FPSOUND::Init() { +bool FPSound::init() { bSoundSupported = g_system->getMixer()->isReady(); return bSoundSupported; } @@ -79,40 +79,40 @@ bool FPSOUND::Init() { /****************************************************************************\ * -* Function: FPSOUND::~FPSOUND(); +* Function: FPSound::~FPSound(); * * Description: Deinizializza l'oggetto, disallocando la memoria. * \****************************************************************************/ -FPSOUND::~FPSOUND() { +FPSound::~FPSound() { } /****************************************************************************\ * -* Function: bool CreateStream(FPSTREAM** lplpStream); +* Function: bool CreateStream(FPStream** lplpStream); * -* Description: Alloca un oggetti di tipo FPSTREAM, e ritorna il suo +* Description: Alloca un oggetti di tipo FPStream, e ritorna il suo * puntatore dopo averlo inizializzato. * -* Input: FPSTREAM** lplpStream Conterra' il pointer all'oggetto +* Input: FPStream** lplpStream Conterra' il pointer all'oggetto * appena creato. * * Return: true se tutto OK, false in caso di errore * * Note: L'utilizzo di funzioni del tipo CreateStream(), CreateSfx(), -* sono dovute al fatto che i costruttori delle classi FPSTREAM -* e FPSFX richiedono che DirectSound sia gia' stato +* sono dovute al fatto che i costruttori delle classi FPStream +* e FPSfx richiedono che DirectSound sia gia' stato * inzializzato. In questo modo quindi si evitano dei bugs * che si verrebbero a creare se venisse dichiarata un oggetto -* di tipo FPSTREAM o FPSFX globale (o cmq prima della +* di tipo FPStream o FPSfx globale (o cmq prima della * inizializzazione di DirectSound). * \****************************************************************************/ -bool FPSOUND::CreateStream(FPSTREAM **lplpStream) { - (*lplpStream) = new FPSTREAM(bSoundSupported); +bool FPSound::createStream(FPStream **lplpStream) { + (*lplpStream) = new FPStream(bSoundSupported); return (*lplpStream != NULL); } @@ -121,12 +121,12 @@ bool FPSOUND::CreateStream(FPSTREAM **lplpStream) { /****************************************************************************\ * -* Function: bool CreateSfx(FPSFX** lplpSfx); +* Function: bool CreateSfx(FPSfx** lplpSfx); * -* Description: Alloca un oggetti di tipo FPSFX e ritorna il suo +* Description: Alloca un oggetti di tipo FPSfx e ritorna il suo * puntatore dopo averlo inizializzato. * -* Input: FPSFX** lplpSfx Conterra' il pointer all'oggetto +* Input: FPSfx** lplpSfx Conterra' il pointer all'oggetto * appena creato. * * Return: true se tutto OK, false in caso di errore @@ -135,8 +135,8 @@ bool FPSOUND::CreateStream(FPSTREAM **lplpStream) { * \****************************************************************************/ -bool FPSOUND::CreateSfx(FPSFX **lplpSfx) { - (*lplpSfx) = new FPSFX(bSoundSupported); +bool FPSound::createSfx(FPSfx **lplpSfx) { + (*lplpSfx) = new FPSfx(bSoundSupported); return (*lplpSfx != NULL); } @@ -153,7 +153,7 @@ bool FPSOUND::CreateSfx(FPSFX **lplpSfx) { * \****************************************************************************/ -void FPSOUND::SetMasterVolume(int dwVolume) { +void FPSound::setMasterVolume(int dwVolume) { if (!bSoundSupported) return; @@ -171,7 +171,7 @@ void FPSOUND::SetMasterVolume(int dwVolume) { * \****************************************************************************/ -void FPSOUND::GetMasterVolume(int *lpdwVolume) { +void FPSound::getMasterVolume(int *lpdwVolume) { if (!bSoundSupported) return; @@ -180,19 +180,19 @@ void FPSOUND::GetMasterVolume(int *lpdwVolume) { /****************************************************************************\ -* Metodi di FPSFX +* Metodi di FPSfx \****************************************************************************/ /****************************************************************************\ * -* Function: FPSFX(bool bSoundOn); +* Function: FPSfx(bool bSoundOn); * * Description: Costruttore di default. *NON* bisogna dichiarare direttamente -* un oggetto, ma crearlo piuttosto tramite FPSOUND::CreateSfx() +* un oggetto, ma crearlo piuttosto tramite FPSound::CreateSfx() * \****************************************************************************/ -FPSFX::FPSFX(bool bSoundOn) { +FPSfx::FPSfx(bool bSoundOn) { bSoundSupported = bSoundOn; bFileLoaded = false; lastVolume = 63; @@ -208,7 +208,7 @@ FPSFX::FPSFX(bool bSoundOn) { /****************************************************************************\ * -* Function: ~FPSFX(); +* Function: ~FPSfx(); * * Description: Distruttore di default. Si preoccupa anche di fermare il sound * effect eventualmente in esecuzione, e disallocare la memoria @@ -216,7 +216,7 @@ FPSFX::FPSFX(bool bSoundOn) { * \****************************************************************************/ -FPSFX::~FPSFX() { +FPSfx::~FPSfx() { if (!bSoundSupported) return; @@ -240,14 +240,14 @@ FPSFX::~FPSFX() { * * Description: Rilascia la memoria dell'oggetto. Deve essere richiamata quando * l'oggetto non serve piu' e **SOLO SE** l'oggetto e' stato -* creato con la FPSOUND::CreateStream(). +* creato con la FPSound::CreateStream(). * * Note: Eventuali puntatori all'oggetto non sono piu' validi dopo * questa chiamata. * \****************************************************************************/ -void FPSFX::Release() { +void FPSfx::release() { delete this; } @@ -267,7 +267,7 @@ void FPSFX::Release() { * \****************************************************************************/ -bool FPSFX::loadWave(Common::SeekableReadStream *stream) { +bool FPSfx::loadWave(Common::SeekableReadStream *stream) { if (!stream) return false; @@ -277,7 +277,7 @@ bool FPSFX::loadWave(Common::SeekableReadStream *stream) { return false; bFileLoaded = true; - SetVolume(lastVolume); + setVolume(lastVolume); return true; } @@ -296,7 +296,7 @@ bool FPSFX::loadWave(Common::SeekableReadStream *stream) { * \****************************************************************************/ -bool FPSFX::LoadVoiceFromVDB(Common::File &vdbFP) { +bool FPSfx::loadVoiceFromVDB(Common::File &vdbFP) { if (!bSoundSupported) return true; @@ -307,23 +307,23 @@ bool FPSFX::LoadVoiceFromVDB(Common::File &vdbFP) { _rewindableStream = Audio::makeADPCMStream(vdbFP.readStream(size), DisposeAfterUse::YES, 0, Audio::kADPCMDVI, rate, 1); bFileLoaded = true; - SetVolume(62); + setVolume(62); return true; } -bool FPSFX::LoadFile(const char *lpszFileName, uint32 dwCodec) { +bool FPSfx::loadFile(const char *lpszFileName, uint32 dwCodec) { if (!bSoundSupported) return true; Common::File file; if (!file.open(lpszFileName)) { - warning("FPSFX::LoadFile(): Cannot open sfx file!"); + warning("FPSfx::LoadFile(): Cannot open sfx file!"); return false; } if (file.readUint32BE() != MKTAG('A', 'D', 'P', 0x10)) { - warning("FPSFX::LoadFile(): Invalid ADP header!"); + warning("FPSfx::LoadFile(): Invalid ADP header!"); return false; } @@ -358,8 +358,8 @@ bool FPSFX::LoadFile(const char *lpszFileName, uint32 dwCodec) { * \****************************************************************************/ -bool FPSFX::Play() { - Stop(); // sanity check +bool FPSfx::play() { + stop(); // sanity check if (bFileLoaded) { // FIXME @@ -380,7 +380,7 @@ bool FPSFX::Play() { g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &_handle, stream, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO); - SetVolume(lastVolume); + setVolume(lastVolume); if (bPaused) g_system->getMixer()->pauseHandle(_handle, true); @@ -400,7 +400,7 @@ bool FPSFX::Play() { * \****************************************************************************/ -bool FPSFX::Stop() { +bool FPSfx::stop() { if (bFileLoaded) { g_system->getMixer()->stopHandle(_handle); bPaused = false; @@ -427,11 +427,11 @@ bool FPSFX::Stop() { * \****************************************************************************/ -void FPSFX::SetLoop(bool bLop) { +void FPSfx::setLoop(bool bLop) { bLoop = bLop; } -void FPSFX::Pause(bool bPause) { +void FPSfx::pause(bool bPause) { if (bFileLoaded) { if (g_system->getMixer()->isSoundHandleActive(_handle) && (bPause ^ bPaused)) g_system->getMixer()->pauseHandle(_handle, bPause); @@ -451,23 +451,28 @@ void FPSFX::Pause(bool bPause) { * \****************************************************************************/ -void FPSFX::SetVolume(int dwVolume) { - if (dwVolume > 63) dwVolume = 63; - if (dwVolume < 0) dwVolume = 0; +void FPSfx::setVolume(int dwVolume) { + if (dwVolume > 63) + dwVolume = 63; + if (dwVolume < 0) + dwVolume = 0; lastVolume = dwVolume; if (bIsVoice) { - if (!GLOBALS._bCfgDubbing) dwVolume = 0; + if (!GLOBALS._bCfgDubbing) + dwVolume = 0; else { dwVolume -= (10 - GLOBALS._nCfgDubbingVolume) * 2; if (dwVolume < 0) dwVolume = 0; } } else { - if (!GLOBALS._bCfgSFX) dwVolume = 0; + if (!GLOBALS._bCfgSFX) + dwVolume = 0; else { dwVolume -= (10 - GLOBALS._nCfgSFXVolume) * 2; - if (dwVolume < 0) dwVolume = 0; + if (dwVolume < 0) + dwVolume = 0; } } @@ -488,7 +493,7 @@ void FPSFX::SetVolume(int dwVolume) { * \****************************************************************************/ -void FPSFX::GetVolume(int *lpdwVolume) { +void FPSfx::getVolume(int *lpdwVolume) { if (g_system->getMixer()->isSoundHandleActive(_handle)) *lpdwVolume = g_system->getMixer()->getChannelVolume(_handle) * 63 / Audio::Mixer::kMaxChannelVolume; else @@ -498,7 +503,7 @@ void FPSFX::GetVolume(int *lpdwVolume) { /** * Returns true if the underlying sound has ended */ -bool FPSFX::endOfBuffer() const { +bool FPSfx::endOfBuffer() const { return !g_system->getMixer()->isSoundHandleActive(_handle) && (!_rewindableStream || _rewindableStream->endOfData()); } @@ -506,9 +511,9 @@ bool FPSFX::endOfBuffer() const { * Continually checks to see if active sounds have finished playing * Sets the event signalling the sound has ended */ -void FPSFX::soundCheckProcess(CORO_PARAM, const void *param) { +void FPSfx::soundCheckProcess(CORO_PARAM, const void *param) { CORO_BEGIN_CONTEXT; - Common::List::iterator i; + Common::List::iterator i; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); @@ -516,7 +521,7 @@ void FPSFX::soundCheckProcess(CORO_PARAM, const void *param) { for (;;) { // Check each active sound for (_ctx->i = _vm->_activeSfx.begin(); _ctx->i != _vm->_activeSfx.end(); ++_ctx->i) { - FPSFX *sfx = *_ctx->i; + FPSfx *sfx = *_ctx->i; if (sfx->endOfBuffer()) CoroScheduler.setEvent(sfx->hEndOfBuffer); } @@ -529,19 +534,19 @@ void FPSFX::soundCheckProcess(CORO_PARAM, const void *param) { } /****************************************************************************\ -* Metodi di FPSTREAM +* Metodi di FPStream \****************************************************************************/ /****************************************************************************\ * -* Function: FPSTREAM(LPDIRECTSOUND lpDS, bool bSoundOn); +* Function: FPStream(LPDIRECTSOUND lpDS, bool bSoundOn); * * Description: Costruttore di default. *NON* bisogna dichiarare direttamente -* un oggetto, ma crearlo piuttosto tramite FPSOUND::CreateStream() +* un oggetto, ma crearlo piuttosto tramite FPSound::CreateStream() * \****************************************************************************/ -FPSTREAM::FPSTREAM(bool bSoundOn) { +FPStream::FPStream(bool bSoundOn) { #ifdef REFACTOR_ME //hwnd=hWnd; lpDS = LPDS; @@ -556,7 +561,7 @@ FPSTREAM::FPSTREAM(bool bSoundOn) { #endif } -bool FPSTREAM::CreateBuffer(int nBufSize) { +bool FPStream::createBuffer(int nBufSize) { #ifdef REFACTOR_ME static PCMWAVEFORMAT pcmwf; static DSBUFFERDESC dsbdesc; @@ -585,7 +590,7 @@ bool FPSTREAM::CreateBuffer(int nBufSize) { if ((err = lpDS->CreateSoundBuffer(&dsbdesc, &lpDSBuffer, NULL)) != DS_OK) { wsprintf(errbuf, "Error creating the secondary buffer (%lx)", err); - MessageBox(hwnd, errbuf, "FPSTREAM::FPSTREAM()", MB_OK); + MessageBox(hwnd, errbuf, "FPStream::FPStream()", MB_OK); bSoundSupported = false; return false; } @@ -599,7 +604,7 @@ bool FPSTREAM::CreateBuffer(int nBufSize) { if (FAILED(err)) { wsprintf(errbuf, "Error creating notify object! (%lx)", err); - MessageBox(hwnd, errbuf, "FPSTREAM::FPSTREAM()", MB_OK); + MessageBox(hwnd, errbuf, "FPStream::FPStream()", MB_OK); bSoundSupported = false; return false; } @@ -626,14 +631,14 @@ bool FPSTREAM::CreateBuffer(int nBufSize) { /****************************************************************************\ * -* Function: ~FPSTREAM(); +* Function: ~FPStream(); * * Description: Distruttore di default. Richiama anche la CloseFile() se ce * ne e' bisogno. * \****************************************************************************/ -FPSTREAM::~FPSTREAM() { +FPStream::~FPStream() { #ifdef REFACTOR_ME if (!bSoundSupported) @@ -680,14 +685,14 @@ FPSTREAM::~FPSTREAM() { * * Description: Rilascia la memoria dell'oggetto. Deve essere richiamata quando * l'oggetto non serve piu' e **SOLO SE** l'oggetto e' stato -* creato con la FPSOUND::CreateStream(). +* creato con la FPSound::CreateStream(). * * Note: Eventuali puntatori all'oggetto non sono piu' validi dopo * questa chiamata. * \****************************************************************************/ -void FPSTREAM::Release() { +void FPStream::release() { delete this; // return NULL; } @@ -707,7 +712,7 @@ void FPSTREAM::Release() { * \****************************************************************************/ -bool FPSTREAM::LoadFile(const char *lpszFileName, uint32 dwCodType, int nBufSize) { +bool FPStream::loadFile(const char *lpszFileName, uint32 dwCodType, int nBufSize) { #ifdef REFACTOR_ME HRESULT err; void *lpBuf; @@ -725,7 +730,7 @@ bool FPSTREAM::LoadFile(const char *lpszFileName, uint32 dwCodType, int nBufSize /* Apre il file di stream in lettura */ if (!_file.open(lpszFileName)) - //MessageBox(hwnd,"Cannot open stream file!","FPSTREAM::LoadFile()", MB_OK); + //MessageBox(hwnd,"Cannot open stream file!","FPStream::LoadFile()", MB_OK); return false; } @@ -755,7 +760,7 @@ return true; * \****************************************************************************/ -bool FPSTREAM::UnloadFile() { +bool FPStream::unloadFile() { #ifdef REFACTOR_ME if (!bSoundSupported || !bFileLoaded) @@ -783,7 +788,7 @@ bool FPSTREAM::UnloadFile() { * \****************************************************************************/ -void FPSTREAM::Prefetch(void) { +void FPStream::prefetch(void) { #ifdef REFACTOR_ME uint32 dwId; void *lpBuf; @@ -850,7 +855,7 @@ void FPSTREAM::Prefetch(void) { #endif } -void FPSTREAM::PlayFast(void) { +void FPStream::playFast(void) { #ifdef REFACTOR_ME dspnHot[0].dwOffset = 32; dspnHot[0].hEventNotify = hHot1; @@ -873,7 +878,7 @@ void FPSTREAM::PlayFast(void) { #endif } -bool FPSTREAM::Play() { +bool FPStream::play() { #ifdef REFACTOR_ME uint32 dwId; void *lpBuf; @@ -961,7 +966,7 @@ bool FPSTREAM::Play() { * \****************************************************************************/ -bool FPSTREAM::Stop(bool bSync) { +bool FPStream::stop(bool bSync) { #ifdef REFACTOR_ME if (!bSoundSupported) @@ -1001,7 +1006,7 @@ bool FPSTREAM::Stop(bool bSync) { return true; } -void FPSTREAM::WaitForSync(FPSTREAM *toplay) { +void FPStream::waitForSync(FPStream *toplay) { #ifdef REFACTOR_ME if (!bSoundSupported) return; @@ -1035,13 +1040,13 @@ void FPSTREAM::WaitForSync(FPSTREAM *toplay) { /****************************************************************************\ * -* Function: void FPSTREAM::PlayThread(); +* Function: void FPStream::PlayThread(); * * Description: Thread che si occupa del play dello stream * \****************************************************************************/ -void FPSTREAM::PlayThread(FPSTREAM *This) { +void FPStream::playThread(FPStream *This) { #ifdef REFACTOR_ME byte *lpLockBuf; uint32 dwResult; @@ -1172,12 +1177,12 @@ void FPSTREAM::PlayThread(FPSTREAM *This) { * \****************************************************************************/ -void FPSTREAM::SetLoop(bool loop) { +void FPStream::setLoop(bool loop) { bLoop = loop; } -void FPSTREAM::Pause(bool bPause) { +void FPStream::pause(bool bPause) { #ifdef REFACTOR_ME if (bFileLoaded) { @@ -1222,7 +1227,7 @@ void FPSTREAM::Pause(bool bPause) { * \****************************************************************************/ -void FPSTREAM::SetVolume(int dwVolume) { +void FPStream::setVolume(int dwVolume) { #ifdef REFACTOR_ME if (dwVolume > 63) dwVolume = 63; if (dwVolume < 0) dwVolume = 0; @@ -1253,7 +1258,7 @@ void FPSTREAM::SetVolume(int dwVolume) { * \****************************************************************************/ -void FPSTREAM::GetVolume(int *lpdwVolume) { +void FPStream::getVolume(int *lpdwVolume) { #ifdef REFACTOR_ME if (lpDSBuffer) lpDSBuffer->GetVolume((uint32 *)lpdwVolume); diff --git a/engines/tony/sound.h b/engines/tony/sound.h index abd7e06cae..f47393b86d 100644 --- a/engines/tony/sound.h +++ b/engines/tony/sound.h @@ -41,8 +41,8 @@ class RewindableAudioStream; namespace Tony { -class FPSTREAM; -class FPSFX; +class FPStream; +class FPSfx; enum SoundCodecs { FPCODEC_RAW, @@ -58,7 +58,7 @@ enum SoundCodecs { ***************************************************************************** \****************************************************************************/ -class FPSOUND { +class FPSound { private: @@ -72,27 +72,27 @@ public: /****************************************************************************\ * - * Function: FPSOUND::FPSOUND(); + * Function: FPSound::FPSound(); * * Description: Default constructor. Initializes the attributes * \****************************************************************************/ - FPSOUND(); + FPSound(); /****************************************************************************\ * - * Function: FPSOUND::~FPSOUND(); + * Function: FPSound::~FPSound(); * * Description: Deinitialize the object, free memory * \****************************************************************************/ - ~FPSOUND(); + ~FPSound(); /****************************************************************************\ * - * Function: bool FPSOUND::Init(); + * Function: bool FPSound::Init(); * * Description: Initializes the objects, and prepare everything required to * create streams and sound effects. @@ -101,38 +101,38 @@ public: * \****************************************************************************/ - bool Init(); + bool init(); /****************************************************************************\ * - * Function: bool CreateStream(FPSTREAM** lplpStream); + * Function: bool CreateStream(FPStream** lplpStream); * - * Description: Allocates an object of type FPSTREAM, and return its + * Description: Allocates an object of type FPStream, and return its * pointer after it has been initialized. * - * Input: FPSTREAM** lplpStream Will contain the pointer of the + * Input: FPStream** lplpStream Will contain the pointer of the * object * * Return: True is everything i OK, False otherwise * * Note: The use of functions like CreateStream () and CreateSfx () * are due to the fact that the class constructors and - * FPSTREAM FPSFX require that DirectSound is already initialized. + * FPStream FPSfx require that DirectSound is already initialized. * In this way, you avoid the bugs that would be created if an - * object type is declared FPSTREAM FPSFX or global + * object type is declared FPStream FPSfx or global * (or anyway before initializing DirectSound). \****************************************************************************/ - bool CreateStream(FPSTREAM **lplpStream); + bool createStream(FPStream **lplpStream); /****************************************************************************\ * - * Function: bool CreateSfx(FPSFX** lplpSfx); + * Function: bool CreateSfx(FPSfx** lplpSfx); * - * Description: Allocates an object of type FPSFX and returns a pointer + * Description: Allocates an object of type FPSfx and returns a pointer * pointing to it * - * Input: FPSFX** lplpSfx Will contain the pointer of the + * Input: FPSfx** lplpSfx Will contain the pointer of the * object * * Return: True is everything i OK, False otherwise @@ -141,7 +141,7 @@ public: * \****************************************************************************/ - bool CreateSfx(FPSFX **lplpSfx); + bool createSfx(FPSfx **lplpSfx); /****************************************************************************\ * @@ -153,7 +153,7 @@ public: * \****************************************************************************/ - void SetMasterVolume(int dwVolume); + void setMasterVolume(int dwVolume); /****************************************************************************\ * @@ -166,10 +166,10 @@ public: * \****************************************************************************/ - void GetMasterVolume(int *lpdwVolume); + void getMasterVolume(int *lpdwVolume); }; -class FPSFX { +class FPSfx { /****************************************************************************\ * Attributes @@ -206,43 +206,43 @@ public: /****************************************************************************\ * - * Function: FPSFX(bool bSoundOn); + * Function: FPSfx(bool bSoundOn); * * Description: Default constructor. *DO NOT* declare the object directly, - * create it though FPSOUND::CreateSfx() instead + * create it though FPSound::CreateSfx() instead * \****************************************************************************/ - FPSFX(bool bSoundOn); + FPSfx(bool bSoundOn); /****************************************************************************\ * - * Function: ~FPSFX(); + * Function: ~FPSfx(); * * Description: Default destructor. It also stops the sound effect that * may be running, and free the memory used. * \****************************************************************************/ - ~FPSFX(); + ~FPSfx(); /****************************************************************************\ * - * Function: Release(); + * Function: release(); * * Description: Releases the memory object. Must be called when the object * is no longer useful and **ONLY** when the object was created - * with the FPSOUND :: CreateStream (). + * with the FPSound :: CreateStream (). * * Note: Any object pointers are no longer valid after this call. * \****************************************************************************/ - void Release(); + void release(); /****************************************************************************\ * - * Function: bool LoadFile(char *lpszFileName, uint32 dwCodec=FPCODEC_RAW); + * Function: bool loadFile(char *lpszFileName, uint32 dwCodec=FPCODEC_RAW); * * Description: Opens a file and load sound effect * @@ -254,13 +254,13 @@ public: * \****************************************************************************/ - bool LoadFile(const char *lpszFileName, uint32 dwCodec = FPCODEC_RAW); + bool loadFile(const char *lpszFileName, uint32 dwCodec = FPCODEC_RAW); bool loadWave(Common::SeekableReadStream *stream); - bool LoadVoiceFromVDB(Common::File &vdbFP); + bool loadVoiceFromVDB(Common::File &vdbFP); /****************************************************************************\ * - * Function: bool Play(); + * Function: bool play(); * * Description: Play the loaded FX. * @@ -268,11 +268,11 @@ public: * \****************************************************************************/ - bool Play(); + bool play(); /****************************************************************************\ * - * Function: bool Stop(); + * Function: bool stop(); * * Description: Stop a FX * @@ -280,21 +280,21 @@ public: * \****************************************************************************/ - bool Stop(); + bool stop(); /****************************************************************************\ * - * Function: void Pause(bool bPause); + * Function: void pause(bool bPause); * * Description: Pause a FX * \****************************************************************************/ - void Pause(bool bPause); + void pause(bool bPause); /****************************************************************************\ * - * Function: bool SetLoop(bool bLoop); + * Function: bool setLoop(bool bLoop); * * Description: Enables or disables SFX loop * @@ -306,11 +306,11 @@ public: * \****************************************************************************/ - void SetLoop(bool bLoop); + void setLoop(bool bLoop); /****************************************************************************\ * - * Function: void SetVolume(int dwVolume); + * Function: void setVolume(int dwVolume); * * Description: Set SFX Volume * @@ -318,11 +318,11 @@ public: * \****************************************************************************/ - void SetVolume(int dwVolume); + void setVolume(int dwVolume); /****************************************************************************\ * - * Function: void GetVolume(int * lpdwVolume); + * Function: void getVolume(int * lpdwVolume); * * Description: Get SFX volume * @@ -330,7 +330,7 @@ public: * \****************************************************************************/ - void GetVolume(int *lpdwVolume); + void getVolume(int *lpdwVolume); /** * Returns true if the sound has finished playing @@ -338,7 +338,7 @@ public: bool endOfBuffer() const; }; -class FPSTREAM { +class FPStream { /****************************************************************************\ * Attributes @@ -372,17 +372,17 @@ private: bool bSyncExit; bool bPaused; int lastVolume; - FPSTREAM *SyncToPlay; + FPStream *SyncToPlay; // DSBPOSITIONNOTIFY dspnHot[3]; - bool CreateBuffer(int nBufSize); + bool createBuffer(int nBufSize); public: bool bIsPlaying; // True if the stream is playing private: - static void PlayThread(FPSTREAM *This); + static void playThread(FPStream *This); /****************************************************************************\ * Methods @@ -392,43 +392,43 @@ public: /****************************************************************************\ * - * Function: FPSTREAM(bool bSoundOn); + * Function: FPStream(bool bSoundOn); * * Description: Default contractor. *DO NOT* declare the object directly: use - * FPSOUND::CreateStream() indtead + * FPSound::CreateStream() indtead * \****************************************************************************/ - FPSTREAM(bool bSoundOn); + FPStream(bool bSoundOn); /****************************************************************************\ * - * Function: ~FPSTREAM(); + * Function: ~FPStream(); * * Description: Destructor by default. Stops the playing stream (if any) and * frees the memory used by them * \****************************************************************************/ - ~FPSTREAM(); + ~FPStream(); /****************************************************************************\ * - * Function: Release(); + * Function: release(); * * Description: Releases memory used by object. Must be used when the object * is no longer used. *ONLY*for objects created by - * FPSOUND::CreateStream(). + * FPSound::CreateStream(). * * Note: Object pointers are no longer valid after this call. * \****************************************************************************/ - void Release(); + void release(); /****************************************************************************\ * - * Function: bool LoadFile(char *lpszFileName, uint32 dwCodec=FPCODEC_RAW); + * Function: bool loadFile(char *lpszFileName, uint32 dwCodec=FPCODEC_RAW); * * Description: Open a file for a stream. * @@ -440,11 +440,11 @@ public: * \****************************************************************************/ - bool LoadFile(const char *lpszFileName, uint32 dwCodec = FPCODEC_RAW, int nSync = 2000); + bool loadFile(const char *lpszFileName, uint32 dwCodec = FPCODEC_RAW, int nSync = 2000); /****************************************************************************\ * - * Function: UnloadFile(); + * Function: unloadFile(); * * Description: Close a file stream (if opened). This function must be * called to free the memory used by the stream @@ -454,11 +454,11 @@ public: * \****************************************************************************/ - bool UnloadFile(); + bool unloadFile(); /****************************************************************************\ * - * Function: bool Play(); + * Function: bool play(); * * Description: Play the loaded stream. * @@ -466,13 +466,13 @@ public: * \****************************************************************************/ - bool Play(); - void PlayFast(void); - void Prefetch(void); + bool play(); + void playFast(void); + void prefetch(void); /****************************************************************************\ * - * Function: bool Stop(); + * Function: bool stop(); * * Description: Stops the play of the stream. * @@ -480,22 +480,22 @@ public: * \****************************************************************************/ - bool Stop(bool bSync = false); - void WaitForSync(FPSTREAM *toplay); + bool stop(bool bSync = false); + void waitForSync(FPStream *toplay); /****************************************************************************\ * - * Function: void Pause(bool bPause); + * Function: void pause(bool bPause); * * Description: Pause sound effect * \****************************************************************************/ - void Pause(bool bPause); + void pause(bool bPause); /****************************************************************************\ * - * Function: bool SetLoop(bool bLoop); + * Function: bool setLoop(bool bLoop); * * Description: Enable of disable stream loop * @@ -507,11 +507,11 @@ public: * \****************************************************************************/ - void SetLoop(bool bLoop); + void setLoop(bool bLoop); /****************************************************************************\ * - * Function: void SetVolume(int dwVolume); + * Function: void setVolume(int dwVolume); * * Description: Change stream colume * @@ -519,13 +519,13 @@ public: * \****************************************************************************/ - void SetVolume(int dwVolume); + void setVolume(int dwVolume); /****************************************************************************\ * - * Function: void GetVolume(LPINT lpdwVolume); + * Function: void getVolume(LPINT lpdwVolume); * * Description: Get stream volume * @@ -533,7 +533,7 @@ public: * \****************************************************************************/ - void GetVolume(int *lpdwVolume); + void getVolume(int *lpdwVolume); }; diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 012dc854b9..094e1bd038 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -213,8 +213,8 @@ void TonyEngine::playMusic(int nChannel, const char *fn, int nFX, bool bLoop, in case 0: case 1: case 2: - _stream[nChannel]->Stop(); - _stream[nChannel]->UnloadFile(); + _stream[nChannel]->stop(); + _stream[nChannel]->unloadFile(); break; case 22: @@ -287,30 +287,30 @@ void TonyEngine::playSFX(int nChannel, int nFX) { switch (nFX) { case 0: - _sfx[nChannel]->SetLoop(false); + _sfx[nChannel]->setLoop(false); break; case 1: - _sfx[nChannel]->SetLoop(true); + _sfx[nChannel]->setLoop(true); break; } - _sfx[nChannel]->Play(); + _sfx[nChannel]->play(); } void TonyEngine::stopMusic(int nChannel) { // g_system->lockMutex(csMusic); if (nChannel < 4) - _stream[nChannel + GLOBALS._flipflop]->Stop(); + _stream[nChannel + GLOBALS._flipflop]->stop(); else - _stream[nChannel]->Stop(); + _stream[nChannel]->stop(); // g_system->unlockMutex(csMusic); } void TonyEngine::stopSFX(int nChannel) { - _sfx[nChannel]->Stop(); + _sfx[nChannel]->stop(); } void TonyEngine::playUtilSFX(int nChannel, int nFX) { @@ -319,38 +319,38 @@ void TonyEngine::playUtilSFX(int nChannel, int nFX) { switch (nFX) { case 0: - _utilSfx[nChannel]->SetLoop(false); + _utilSfx[nChannel]->setLoop(false); break; case 1: - _utilSfx[nChannel]->SetLoop(true); + _utilSfx[nChannel]->setLoop(true); break; } - _utilSfx[nChannel]->SetVolume(52); - _utilSfx[nChannel]->Play(); + _utilSfx[nChannel]->setVolume(52); + _utilSfx[nChannel]->play(); } void TonyEngine::stopUtilSFX(int nChannel) { - _utilSfx[nChannel]->Stop(); + _utilSfx[nChannel]->stop(); } void TonyEngine::preloadSFX(int nChannel, const char *fn) { if (_sfx[nChannel] != NULL) { - _sfx[nChannel]->Stop(); - _sfx[nChannel]->Release(); + _sfx[nChannel]->stop(); + _sfx[nChannel]->release(); _sfx[nChannel] = NULL; } - _theSound.CreateSfx(&_sfx[nChannel]); + _theSound.createSfx(&_sfx[nChannel]); - _sfx[nChannel]->LoadFile(fn, FPCODEC_ADPCM); + _sfx[nChannel]->loadFile(fn, FPCODEC_ADPCM); } -FPSFX *TonyEngine::createSFX(Common::SeekableReadStream *stream) { - FPSFX *sfx; +FPSfx *TonyEngine::createSFX(Common::SeekableReadStream *stream) { + FPSfx *sfx; - _theSound.CreateSfx(&sfx); + _theSound.createSfx(&sfx); sfx->loadWave(stream); return sfx; } @@ -370,11 +370,11 @@ void TonyEngine::unloadAllUtilSFX(void) { void TonyEngine::initMusic() { int i; - _theSound.Init(/*_window*/); - _theSound.SetMasterVolume(63); + _theSound.init(/*_window*/); + _theSound.setMasterVolume(63); for (i = 0; i < 6; i++) - _theSound.CreateStream(&_stream[i]); + _theSound.createStream(&_stream[i]); for (i = 0; i < MAX_SFX_CHANNELS; i++) { _sfx[i] = _utilSfx[i] = NULL; @@ -388,14 +388,14 @@ void TonyEngine::initMusic() { preloadUtilSFX(1, "U02.ADP"); // Start check processes for sound - CoroScheduler.createProcess(FPSFX::soundCheckProcess, NULL); + CoroScheduler.createProcess(FPSfx::soundCheckProcess, NULL); } void TonyEngine::closeMusic() { for (int i = 0; i < 6; i++) { - _stream[i]->Stop(); - _stream[i]->UnloadFile(); - _stream[i]->Release(); + _stream[i]->stop(); + _stream[i]->unloadFile(); + _stream[i]->release(); } // g_system->deleteMutex(csMusic); diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 8df2da697c..93232b950d 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -99,8 +99,8 @@ public: uint32 _hEndOfFrame; Common::File _vdbFP; Common::Array _voices; - FPSOUND _theSound; - Common::List _activeSfx; + FPSound _theSound; + Common::List _activeSfx; Globals _globals; Debugger *_debugger; @@ -115,9 +115,9 @@ public: DD_BASE2 }; - FPSTREAM *_stream[6]; - FPSFX *_sfx[MAX_SFX_CHANNELS]; - FPSFX *_utilSfx[MAX_SFX_CHANNELS]; + FPStream *_stream[6]; + FPSfx *_sfx[MAX_SFX_CHANNELS]; + FPSfx *_utilSfx[MAX_SFX_CHANNELS]; // RMFont *_fonts[2]; bool _bPaused; bool _bDrawLocation; @@ -189,7 +189,7 @@ public: void playUtilSFX(int nSfx, int nFX = 0); void stopUtilSFX(int nSfx); - FPSFX *createSFX(Common::SeekableReadStream *stream); + FPSfx *createSFX(Common::SeekableReadStream *stream); void preloadSFX(int nSfx, const char *fn); void unloadAllSFX(void); -- cgit v1.2.3 From 25d95bd5e357187cde9634b0379b8469cee0397d Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 16 Jun 2012 22:05:06 +1000 Subject: TONY: Workaround for original game bug opening the door in the first scene In the original, after moving to the door, the game scripts have Tony start immediately moving back to the desk. Unfortunately, they didn't realise that the _hEndOfPath event would still be briefly set from finishing the walk to the door, so the game didn't wait until Tony had reached the desk to start the conversation. --- engines/tony/custom.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index ef4f889a12..160fafa47f 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -1198,6 +1198,11 @@ DECLARE_CUSTOM_FUNCTION(MoveTonyAndWait)(CORO_PARAM, uint32 nX, uint32 nY, uint3 CORO_BEGIN_CODE(_ctx); + // WORKAROUND: Delay for a frame before starting the move to give any previous move time to finish. + // This fixes a bug in the first scene where if you immediately 'Use Door', Tony moves to the door, + // and then floats to the right rather than properly walking. + CORO_SLEEP(1); + CORO_INVOKE_1(GLOBALS._tony->move, RMPoint(nX, nY)); if (!GLOBALS._bSkipIdle) -- cgit v1.2.3 From ac4567dcb6608bbcde680df36bba088ce0191dd5 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 16 Jun 2012 19:04:19 +0200 Subject: TONY: Rename sound variables --- engines/tony/custom.cpp | 10 +++---- engines/tony/sound.cpp | 72 ++++++++++++++++++++++++------------------------- engines/tony/sound.h | 57 +++++++++++++++++++-------------------- 3 files changed, 68 insertions(+), 71 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 160fafa47f..375b405400 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -331,7 +331,7 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX if (_ctx->curVoc) { if (_ctx->i == 0) { _ctx->voice->play(); - _ctx->text.setCustomSkipHandle2(_ctx->voice->hEndOfBuffer); + _ctx->text.setCustomSkipHandle2(_ctx->voice->_hEndOfBuffer); } else { _vm->_vdbFP.seek(_ctx->curOffset); _vm->_theSound.createSfx(&_ctx->voice); @@ -340,7 +340,7 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX _ctx->curOffset = _vm->_vdbFP.pos(); _ctx->voice->setLoop(false); _ctx->voice->play(); - _ctx->text.setCustomSkipHandle2(_ctx->voice->hEndOfBuffer); + _ctx->text.setCustomSkipHandle2(_ctx->voice->_hEndOfBuffer); } } @@ -1535,7 +1535,7 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess _ctx->voice->setLoop(false); if (bIsBack) _ctx->voice->setVolume(55); _ctx->voice->play(); - _ctx->text->setCustomSkipHandle2(_ctx->voice->hEndOfBuffer); + _ctx->text->setCustomSkipHandle2(_ctx->voice->_hEndOfBuffer); _ctx->curOffset = _vm->_vdbFP.pos(); } @@ -1749,7 +1749,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes if (bIsBack) _ctx->voice->setVolume(55); _ctx->voice->play(); - _ctx->text->setCustomSkipHandle2(_ctx->voice->hEndOfBuffer); + _ctx->text->setCustomSkipHandle2(_ctx->voice->_hEndOfBuffer); _ctx->curOffset = _vm->_vdbFP.pos(); } @@ -1912,7 +1912,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg if (_ctx->curVoc) { _ctx->voice->play(); - _ctx->text->setCustomSkipHandle2(_ctx->voice->hEndOfBuffer); + _ctx->text->setCustomSkipHandle2(_ctx->voice->_hEndOfBuffer); } // Wait for the end of display diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index 35db3ced38..479cb05a0b 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -56,7 +56,7 @@ namespace Tony { \****************************************************************************/ FPSound::FPSound() { - bSoundSupported = false; + _bSoundSupported = false; } @@ -72,8 +72,8 @@ FPSound::FPSound() { \****************************************************************************/ bool FPSound::init() { - bSoundSupported = g_system->getMixer()->isReady(); - return bSoundSupported; + _bSoundSupported = g_system->getMixer()->isReady(); + return _bSoundSupported; } @@ -112,7 +112,7 @@ FPSound::~FPSound() { \****************************************************************************/ bool FPSound::createStream(FPStream **lplpStream) { - (*lplpStream) = new FPStream(bSoundSupported); + (*lplpStream) = new FPStream(_bSoundSupported); return (*lplpStream != NULL); } @@ -136,7 +136,7 @@ bool FPSound::createStream(FPStream **lplpStream) { \****************************************************************************/ bool FPSound::createSfx(FPSfx **lplpSfx) { - (*lplpSfx) = new FPSfx(bSoundSupported); + (*lplpSfx) = new FPSfx(_bSoundSupported); return (*lplpSfx != NULL); } @@ -154,7 +154,7 @@ bool FPSound::createSfx(FPSfx **lplpSfx) { \****************************************************************************/ void FPSound::setMasterVolume(int dwVolume) { - if (!bSoundSupported) + if (!_bSoundSupported) return; g_system->getMixer()->setVolumeForSoundType(Audio::Mixer::kPlainSoundType, CLIP(dwVolume, 0, 63) * Audio::Mixer::kMaxChannelVolume / 63); @@ -172,7 +172,7 @@ void FPSound::setMasterVolume(int dwVolume) { \****************************************************************************/ void FPSound::getMasterVolume(int *lpdwVolume) { - if (!bSoundSupported) + if (!_bSoundSupported) return; *lpdwVolume = g_system->getMixer()->getVolumeForSoundType(Audio::Mixer::kPlainSoundType) * 63 / Audio::Mixer::kMaxChannelVolume; @@ -193,14 +193,14 @@ void FPSound::getMasterVolume(int *lpdwVolume) { \****************************************************************************/ FPSfx::FPSfx(bool bSoundOn) { - bSoundSupported = bSoundOn; - bFileLoaded = false; - lastVolume = 63; - hEndOfBuffer = CORO_INVALID_PID_VALUE; - bIsVoice = false; + _bSoundSupported = bSoundOn; + _bFileLoaded = false; + _lastVolume = 63; + _hEndOfBuffer = CORO_INVALID_PID_VALUE; + _bIsVoice = false; _loopStream = 0; _rewindableStream = 0; - bPaused = false; + _bPaused = false; _vm->_activeSfx.push_back(this); } @@ -217,7 +217,7 @@ FPSfx::FPSfx(bool bSoundOn) { \****************************************************************************/ FPSfx::~FPSfx() { - if (!bSoundSupported) + if (!_bSoundSupported) return; g_system->getMixer()->stopHandle(_handle); @@ -276,8 +276,8 @@ bool FPSfx::loadWave(Common::SeekableReadStream *stream) { if (!_rewindableStream) return false; - bFileLoaded = true; - setVolume(lastVolume); + _bFileLoaded = true; + setVolume(_lastVolume); return true; } @@ -297,23 +297,23 @@ bool FPSfx::loadWave(Common::SeekableReadStream *stream) { \****************************************************************************/ bool FPSfx::loadVoiceFromVDB(Common::File &vdbFP) { - if (!bSoundSupported) + if (!_bSoundSupported) return true; uint32 size = vdbFP.readUint32LE(); uint32 rate = vdbFP.readUint32LE(); - bIsVoice = true; + _bIsVoice = true; _rewindableStream = Audio::makeADPCMStream(vdbFP.readStream(size), DisposeAfterUse::YES, 0, Audio::kADPCMDVI, rate, 1); - bFileLoaded = true; + _bFileLoaded = true; setVolume(62); return true; } bool FPSfx::loadFile(const char *lpszFileName, uint32 dwCodec) { - if (!bSoundSupported) + if (!_bSoundSupported) return true; Common::File file; @@ -343,7 +343,7 @@ bool FPSfx::loadFile(const char *lpszFileName, uint32 dwCodec) { _rewindableStream = Audio::makeRawStream(buffer, rate, flags, DisposeAfterUse::YES); } - bFileLoaded = true; + _bFileLoaded = true; return true; } @@ -361,7 +361,7 @@ bool FPSfx::loadFile(const char *lpszFileName, uint32 dwCodec) { bool FPSfx::play() { stop(); // sanity check - if (bFileLoaded) { + if (_bFileLoaded) { // FIXME //if (hEndOfBuffer != CORO_INVALID_PID_VALUE) // ResetEvent(hEndOfBuffer); @@ -370,7 +370,7 @@ bool FPSfx::play() { Audio::AudioStream *stream = _rewindableStream; - if (bLoop) { + if (_bLoop) { if (!_loopStream) _loopStream = Audio::makeLoopingAudioStream(_rewindableStream, 0); @@ -380,9 +380,9 @@ bool FPSfx::play() { g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &_handle, stream, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO); - setVolume(lastVolume); + setVolume(_lastVolume); - if (bPaused) + if (_bPaused) g_system->getMixer()->pauseHandle(_handle, true); } @@ -401,9 +401,9 @@ bool FPSfx::play() { \****************************************************************************/ bool FPSfx::stop() { - if (bFileLoaded) { + if (_bFileLoaded) { g_system->getMixer()->stopHandle(_handle); - bPaused = false; + _bPaused = false; } return true; @@ -428,15 +428,15 @@ bool FPSfx::stop() { \****************************************************************************/ void FPSfx::setLoop(bool bLop) { - bLoop = bLop; + _bLoop = bLop; } void FPSfx::pause(bool bPause) { - if (bFileLoaded) { - if (g_system->getMixer()->isSoundHandleActive(_handle) && (bPause ^ bPaused)) + if (_bFileLoaded) { + if (g_system->getMixer()->isSoundHandleActive(_handle) && (bPause ^ _bPaused)) g_system->getMixer()->pauseHandle(_handle, bPause); - bPaused = bPause; + _bPaused = bPause; } } @@ -457,9 +457,9 @@ void FPSfx::setVolume(int dwVolume) { if (dwVolume < 0) dwVolume = 0; - lastVolume = dwVolume; + _lastVolume = dwVolume; - if (bIsVoice) { + if (_bIsVoice) { if (!GLOBALS._bCfgDubbing) dwVolume = 0; else { @@ -523,7 +523,7 @@ void FPSfx::soundCheckProcess(CORO_PARAM, const void *param) { for (_ctx->i = _vm->_activeSfx.begin(); _ctx->i != _vm->_activeSfx.end(); ++_ctx->i) { FPSfx *sfx = *_ctx->i; if (sfx->endOfBuffer()) - CoroScheduler.setEvent(sfx->hEndOfBuffer); + CoroScheduler.setEvent(sfx->_hEndOfBuffer); } // Delay until the next check is done @@ -1035,7 +1035,7 @@ void FPStream::waitForSync(FPStream *toplay) { /* Disalloca e chiude il CODEC */ delete lpCodec; #endif - bIsPlaying = false; + _bIsPlaying = false; } /****************************************************************************\ @@ -1178,7 +1178,7 @@ void FPStream::playThread(FPStream *This) { \****************************************************************************/ void FPStream::setLoop(bool loop) { - bLoop = loop; + _bLoop = loop; } diff --git a/engines/tony/sound.h b/engines/tony/sound.h index f47393b86d..5e50c31554 100644 --- a/engines/tony/sound.h +++ b/engines/tony/sound.h @@ -62,7 +62,7 @@ class FPSound { private: - bool bSoundSupported; + bool _bSoundSupported; /****************************************************************************\ * Methods @@ -176,20 +176,20 @@ class FPSfx { \****************************************************************************/ private: - bool bSoundSupported; // True if the sound is active - bool bFileLoaded; // True is a file is opened - bool bLoop; // True is sound effect should loop - int lastVolume; + bool _bSoundSupported; // True if the sound is active + bool _bFileLoaded; // True is a file is opened + bool _bLoop; // True is sound effect should loop + int _lastVolume; - bool bIsVoice; - bool bPaused; + bool _bIsVoice; + bool _bPaused; Audio::AudioStream *_loopStream; Audio::RewindableAudioStream *_rewindableStream; Audio::SoundHandle _handle; public: - uint32 hEndOfBuffer; + uint32 _hEndOfBuffer; private: @@ -352,33 +352,33 @@ private: LPDIRECTSOUNDBUFFER lpDSBuffer; // DirectSound circular buffer LPDIRECTSOUNDNOTIFY lpDSNotify; // Notify hotspots in the buffer */ - byte *lpTempBuffer; // Temporary buffer use for decompression + byte *_lpTempBuffer; // Temporary buffer use for decompression - uint32 dwBufferSize; // Buffer size (bytes) - uint32 dwSize; // Stream size (bytes) - uint32 dwCodec; // CODEC used + uint32 _dwBufferSize; // Buffer size (bytes) + uint32 _dwSize; // Stream size (bytes) + uint32 _dwCodec; // CODEC used - HANDLE hThreadEnd; // Event used to close thread + HANDLE _hThreadEnd; // Event used to close thread Common::File _file; // File handle used for the stream - HANDLE hPlayThread; // Handle of the Play thread - HANDLE hHot1, hHot2, hHot3; // Events set by DirectSoundNotify - HANDLE hPlayThread_PlayFast; - HANDLE hPlayThread_PlayNormal; - - bool bSoundSupported; // True if the sound is active - bool bFileLoaded; // True if the file is open - bool bLoop; // True if the stream should loop - bool bDoFadeOut; // True if fade out is required - bool bSyncExit; - bool bPaused; - int lastVolume; - FPStream *SyncToPlay; + HANDLE _hPlayThread; // Handle of the Play thread + HANDLE _hHot1, _hHot2, _hHot3; // Events set by DirectSoundNotify + HANDLE _hPlayThreadPlayFast; + HANDLE _hPlayThreadPlayNormal; + + bool _bSoundSupported; // True if the sound is active + bool _bFileLoaded; // True if the file is open + bool _bLoop; // True if the stream should loop + bool _bDoFadeOut; // True if fade out is required + bool _bSyncExit; + bool _bPaused; + int _lastVolume; + FPStream *_syncToPlay; // DSBPOSITIONNOTIFY dspnHot[3]; bool createBuffer(int nBufSize); public: - bool bIsPlaying; // True if the stream is playing + bool _bIsPlaying; // True if the stream is playing private: @@ -521,8 +521,6 @@ public: void setVolume(int dwVolume); - - /****************************************************************************\ * * Function: void getVolume(LPINT lpdwVolume); @@ -536,7 +534,6 @@ public: void getVolume(int *lpdwVolume); }; - } // End of namespace Tony #endif -- cgit v1.2.3 From 011b15966cb7168ff0087cf8a206f8ea95dbd734 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 16 Jun 2012 23:48:16 +0200 Subject: TONY: Translate comments in sound.cpp --- engines/tony/sound.cpp | 303 +++++++++++++++++++++---------------------------- 1 file changed, 132 insertions(+), 171 deletions(-) (limited to 'engines') diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index 479cb05a0b..e650a5d74b 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -44,14 +44,14 @@ namespace Tony { #define RELEASE(x) {if ((x) != NULL) { (x)->release(); x = NULL; }} /****************************************************************************\ -* Metodi per FPSound +* Methods for FPSound \****************************************************************************/ /****************************************************************************\ * * Function: FPSound::FPSound(); * -* Description: Costruttore di default. Inizializza gli attributi. +* Description: Default constructor. Initializes the attributes. * \****************************************************************************/ @@ -62,12 +62,12 @@ FPSound::FPSound() { /****************************************************************************\ * -* Function: bool FPSound::Init(); +* Function: bool FPSound::init(); * -* Description: Inizializza l'oggetto, e prepara tutto il necessario per -* creare stream e effetti sonori. +* Description: Initializes the object, and prepare everything you need to + create streams and sound effects. * -* Return: True se tutto OK, false in caso di errore. +* Return: True if everything's OK, False otherwise. * \****************************************************************************/ @@ -81,7 +81,7 @@ bool FPSound::init() { * * Function: FPSound::~FPSound(); * -* Description: Deinizializza l'oggetto, disallocando la memoria. +* Description: Destroy the object and free the memory. * \****************************************************************************/ @@ -93,21 +93,12 @@ FPSound::~FPSound() { * * Function: bool CreateStream(FPStream** lplpStream); * -* Description: Alloca un oggetti di tipo FPStream, e ritorna il suo -* puntatore dopo averlo inizializzato. +* Description: Allocates an object of type FPStream, and return its pointer * -* Input: FPStream** lplpStream Conterra' il pointer all'oggetto -* appena creato. +* Input: FPStream** lplpStream Will contain a pointer to the object +* you just created. * -* Return: true se tutto OK, false in caso di errore -* -* Note: L'utilizzo di funzioni del tipo CreateStream(), CreateSfx(), -* sono dovute al fatto che i costruttori delle classi FPStream -* e FPSfx richiedono che DirectSound sia gia' stato -* inzializzato. In questo modo quindi si evitano dei bugs -* che si verrebbero a creare se venisse dichiarata un oggetto -* di tipo FPStream o FPSfx globale (o cmq prima della -* inizializzazione di DirectSound). +* Return: True is everything is OK, False otherwise * \****************************************************************************/ @@ -117,21 +108,16 @@ bool FPSound::createStream(FPStream **lplpStream) { return (*lplpStream != NULL); } - - /****************************************************************************\ * * Function: bool CreateSfx(FPSfx** lplpSfx); * -* Description: Alloca un oggetti di tipo FPSfx e ritorna il suo -* puntatore dopo averlo inizializzato. +* Description: Allocates an object of type FpSfx, and return its pointer * -* Input: FPSfx** lplpSfx Conterra' il pointer all'oggetto -* appena creato. +* Input: FPSfx** lplpSfx Will contain a pointer to the object +* you just created. * -* Return: true se tutto OK, false in caso di errore -* -* Note: Vedi le note di CreateStream() +* Return: True is everything is OK, False otherwise * \****************************************************************************/ @@ -141,15 +127,13 @@ bool FPSound::createSfx(FPSfx **lplpSfx) { return (*lplpSfx != NULL); } - - /****************************************************************************\ * -* Function: void SetMasterVolume(int dwVolume); +* Function: void setMasterVolume(int dwVolume); * -* Description: Setta il volume generale +* Description: Set the general volume * -* Input: int dwVolume Volume da settare (0-63) +* Input: int dwVolume Volume to set (0-63) * \****************************************************************************/ @@ -160,14 +144,14 @@ void FPSound::setMasterVolume(int dwVolume) { g_system->getMixer()->setVolumeForSoundType(Audio::Mixer::kPlainSoundType, CLIP(dwVolume, 0, 63) * Audio::Mixer::kMaxChannelVolume / 63); } - /****************************************************************************\ * -* Function: void GetMasterVolume(int *lpdwVolume); +* Function: void getMasterVolume(int *lpdwVolume); * -* Description: Richiede il volume generale +* Description: Get the general volume * -* Input: int *lpdwVolume Variabile che conterra' il volume (0-63) +* Input: int *lpdwVolume Variable that will contain the +* volume (0-63) * \****************************************************************************/ @@ -178,17 +162,16 @@ void FPSound::getMasterVolume(int *lpdwVolume) { *lpdwVolume = g_system->getMixer()->getVolumeForSoundType(Audio::Mixer::kPlainSoundType) * 63 / Audio::Mixer::kMaxChannelVolume; } - /****************************************************************************\ -* Metodi di FPSfx +* Methods for FPSfx \****************************************************************************/ /****************************************************************************\ * * Function: FPSfx(bool bSoundOn); * -* Description: Costruttore di default. *NON* bisogna dichiarare direttamente -* un oggetto, ma crearlo piuttosto tramite FPSound::CreateSfx() +* Description: Default constructor. Do *NOT* declare an object directly, +* but rather create it using FPSound::CreateSfx() * \****************************************************************************/ @@ -210,9 +193,8 @@ FPSfx::FPSfx(bool bSoundOn) { * * Function: ~FPSfx(); * -* Description: Distruttore di default. Si preoccupa anche di fermare il sound -* effect eventualmente in esecuzione, e disallocare la memoria -* da esso occupata. +* Description: Default Destructor. It is also stops the sound effect that +* may be currently played, and free the memory it uses. * \****************************************************************************/ @@ -233,17 +215,15 @@ FPSfx::~FPSfx() { // CloseHandle(hEndOfBuffer); } - /****************************************************************************\ * -* Function: Release(); +* Function: release(); * -* Description: Rilascia la memoria dell'oggetto. Deve essere richiamata quando -* l'oggetto non serve piu' e **SOLO SE** l'oggetto e' stato -* creato con la FPSound::CreateStream(). +* Description: Releases the memory used by the object. +* Must be called when the object is no longer used and +* **ONLY** if the object was created by FPSound::CreateStream() * -* Note: Eventuali puntatori all'oggetto non sono piu' validi dopo -* questa chiamata. +* Note: Object pointers are no longer valid after this call. * \****************************************************************************/ @@ -251,19 +231,16 @@ void FPSfx::release() { delete this; } - - /****************************************************************************\ * * Function: bool loadWave(Common::SeekableReadStream *stream); * -* Description: Apre un file di effetto sonoro e lo carica. +* Description: Opens a file and loads a sound effect. * -* Input: byte *lpBuf Buffer dove si trova l'sfx -* uint32 dwCoded CODEC da utilizzare per decomprimere -* i campioni sonori +* Input: byte *lpBuf Buffer containing the Sfx +* uint32 dwCodec CODEC used to uncompress the samples * -* Return: true se tutto OK, false in caso di errore +* Return: True is everything is OK, False otherwise * \****************************************************************************/ @@ -284,15 +261,14 @@ bool FPSfx::loadWave(Common::SeekableReadStream *stream) { /****************************************************************************\ * -* Function: bool LoadFile(LPSTR lpszFileName, uint32 dwCodec=FPCODEC_RAW); +* Function: bool LoadFile(const char * lpszFileName, uint32 dwCodec=FPCODEC_RAW); * -* Description: Apre un file di effetto sonoro e lo carica. +* Description: Opens a file and loads a sound effect. * -* Input: LPSTR lpszFile Nome del file di sfx da aprire -* uint32 dwCodec CODEC da utilizzare per decomprimere -* i campioni sonori +* Input: LPSTR lpszFile Sfx filename +* uint32 dwCodec CODEC used to uncompress the samples * -* Return: true se tutto OK, false in caso di errore +* Return: True is everything is OK, False otherwise * \****************************************************************************/ @@ -350,11 +326,11 @@ bool FPSfx::loadFile(const char *lpszFileName, uint32 dwCodec) { /****************************************************************************\ * -* Function: bool Play(); +* Function: bool play(); * -* Description: Suona lo sfx caricato. +* Description: Play the Sfx in memory. * -* Return: true se tutto OK, false in caso di errore. +* Return: True is everything is OK, False otherwise * \****************************************************************************/ @@ -392,11 +368,11 @@ bool FPSfx::play() { /****************************************************************************\ * -* Function: bool Stop(void); +* Function: bool stop(void); * -* Description: Ferma il play dello sfx. +* Description: Stop an sfx. * -* Return: true se tutto OK, false in caso di errore. +* Return: True is everything is OK, False otherwise * \****************************************************************************/ @@ -413,17 +389,15 @@ bool FPSfx::stop() { /****************************************************************************\ * -* Function: bool SetLoop(bool bLoop); +* Function: bool setLoop(bool bLoop); * -* Description: Attiva o disattiva il loop dello sfx. +* Description: Enables or disables the Sfx loop. * -* Input: bool bLoop true per attivare il loop, false per -* disattivarlo +* Input: bool bLoop True to enable the loop, False to disable * -* Note: Il loop deve essere attivato PRIMA di eseguire il play -* dello sfx. Qualsiasi modifica effettuata durante il play -* non avra' effetto fino a che lo sfx non viene fermato, -* e poi rimesso in play. +* Note: The loop must be activated BEFORE the sfx starts playing. +* Any changes made during the play will have no effect until +* the sfx is stopped then played again. * \****************************************************************************/ @@ -440,14 +414,13 @@ void FPSfx::pause(bool bPause) { } } - /****************************************************************************\ * -* Function: void SetVolume(int dwVolume); +* Function: void setVolume(int dwVolume); * -* Description: Cambia il volume dello sfx +* Description: Change the volume of Sfx * -* Input: int dwVolume Volume da settare (0-63) +* Input: int dwVolume Volume to be set (0-63) * \****************************************************************************/ @@ -486,10 +459,9 @@ void FPSfx::setVolume(int dwVolume) { * * Function: void GetVolume(int *lpdwVolume); * -* Description: Chiede il volume dello sfx +* Description: Gets the Sfx volume * -* Input: int *lpdwVolume Variabile in cui verra' inserito -* il volume corrente +* Input: int *lpdwVolume Will contain the current Sfx volume * \****************************************************************************/ @@ -534,15 +506,15 @@ void FPSfx::soundCheckProcess(CORO_PARAM, const void *param) { } /****************************************************************************\ -* Metodi di FPStream +* Methods for FPStream \****************************************************************************/ /****************************************************************************\ * * Function: FPStream(LPDIRECTSOUND lpDS, bool bSoundOn); * -* Description: Costruttore di default. *NON* bisogna dichiarare direttamente -* un oggetto, ma crearlo piuttosto tramite FPSound::CreateStream() +* Description: Default constructor. Do *NOT* declare an object directly, +* but rather create it using FPSound::CreateStream() * \****************************************************************************/ @@ -571,11 +543,10 @@ bool FPStream::createBuffer(int nBufSize) { if (bSoundSupported == false) return true; - /* Setta le strutture necessarie per la creazione di un secondary buffer - per lo stream lungo esattamente 1 secondo di musica. Attiviamo inoltre - il controllo del volume, in modo da poter abbassare e alzare il volume - della musica indipendentemente da quello generale. Ovviamente si tratta - di un buffer in RAM */ + /* Set the required structures for the creation of a secondary buffer for the stream containing exactly 1 second of music. + Also activate the volume control, in order to lower and raise the volume of the music regardless of the general volume. + Obviously it is a buffer in RAM */ + pcmwf.wBitsPerSample = 16; pcmwf.wf.wFormatTag = WAVE_FORMAT_PCM; pcmwf.wf.nChannels = 2; @@ -597,9 +568,9 @@ bool FPStream::createBuffer(int nBufSize) { SetVolume(63); - /* Crea il notify per avvertire quando vengono raggiunte le posizioni chiave - all'interno dello stream. Le posizioni chiave si trovano rispettivamente - subito dopo l'inizio e subito dopo la meta' del buffer */ + /* Create an alert when key positions are reached in the stream. + Key positions are located, respectively, immediately after + the start and immediately after the middle of the buffer */ err = lpDSBuffer->QueryInterface(IID_IDirectSoundNotify, (void **)&lpDSNotify); if (FAILED(err)) { @@ -633,8 +604,7 @@ bool FPStream::createBuffer(int nBufSize) { * * Function: ~FPStream(); * -* Description: Distruttore di default. Richiama anche la CloseFile() se ce -* ne e' bisogno. +* Description: Default destructor. It calls CloseFile() if needed. * \****************************************************************************/ @@ -681,14 +651,13 @@ FPStream::~FPStream() { /****************************************************************************\ * -* Function: Release(); +* Function: release(); * -* Description: Rilascia la memoria dell'oggetto. Deve essere richiamata quando -* l'oggetto non serve piu' e **SOLO SE** l'oggetto e' stato -* creato con la FPSound::CreateStream(). +* Description: Releases the memory object. Must be called when the object +* is no longer used and **ONLY** if the object was created by +* FPSound::CreateStream(). * -* Note: Eventuali puntatori all'oggetto non sono piu' validi dopo -* questa chiamata. +* Note: Object pointers are no longer valid after this call. * \****************************************************************************/ @@ -700,15 +669,14 @@ void FPStream::release() { /****************************************************************************\ * -* Function: bool LoadFile(LPSTREAM lpszFileName, uint32 dwCodec=FPCODEC_RAW); +* Function: bool loadFile(const char *lpszFileName, uint32 dwCodec=FPCODEC_RAW); * -* Description: Apre un file di stream. +* Description: Opens a file stream. * -* Input: LPSTR lpszFile Nome del file di stream da aprire -* uint32 dwCodec CODEC da utilizzare per decomprimere -* i campioni sonori +* Input: LPSTR lpszFile Filename to be opened +* uint32 dwCodec CODEC to be used to uncompress samples * -* Return: true se tutto OK, false in caso di errore +* Return: True is everything is OK, False otherwise * \****************************************************************************/ @@ -749,14 +717,13 @@ return true; /****************************************************************************\ * -* Function: UnloadFile(); +* Function: unloadFile(); * -* Description: Chiude un file di stream eventualmente aperto. E' necessario -* richiamare questa funzione per disallocare la memoria -* occupata dallo stream. +* Description: Closes a file stream (opened or not). It is necessary to call +* this function to free the memory used by the stream. * -* Return: Il distruttore della classe per sicurezza richiama la -* UnloadFile() se non e' stata richiamata esplicitamente. +* Return: For safety, the destructor calls unloadFile() if it has not +* been mentioned explicitly. * \****************************************************************************/ @@ -766,13 +733,13 @@ bool FPStream::unloadFile() { if (!bSoundSupported || !bFileLoaded) return true; - /* Chiude gli handle del file di stream */ + /* Closes the file handle stream */ _file.close(); RELEASE(lpDSNotify); RELEASE(lpDSBuffer); - /* Si ricorda che non c'e' piu' nessun file in memoria */ + /* Remember no more file is loaded in memory */ bFileLoaded = false; #endif return true; @@ -782,9 +749,9 @@ bool FPStream::unloadFile() { * * Function: bool Play(); * -* Description: Suona lo stream caricato. +* Description: Play the stream. * -* Return: true se tutto OK, false in caso di errore. +* Return: True is everything is OK, False otherwise * \****************************************************************************/ @@ -798,7 +765,7 @@ void FPStream::prefetch(void) { if (!bSoundSupported || !bFileLoaded) return; - /* Alloca un buffer temporaneo */ + /* Allocates a temporary buffer */ lpTempBuffer = (byte *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, dwBufferSize / 2); if (lpTempBuffer == NULL) return; @@ -816,27 +783,27 @@ void FPStream::prefetch(void) { return; } - /* Posiziona lo stream file all'inizio */ + /* reset the file position */ _file.seek(0); - /* Riempie il buffer per avere i dati gia' pronti */ + /* Fills the buffer for the data already ready */ if ((err = lpDSBuffer->Lock(0, dwBufferSize / 2, &lpBuf, (uint32 *)&dwHi, NULL, NULL, 0)) != DS_OK) { MessageBox(hwnd, "Cannot lock stream buffer!", "soundLoadStream()", MB_OK); return; } - /* Decomprime i dati dello stream direttamente dentro il buffer lockato */ + /* Uncompress the data from the stream directly into the locked buffer */ lpCodec->Decompress(hFile, lpBuf, dwBufferSize / 2); - /* Unlocka il buffer */ + /* Unlock the buffer */ lpDSBuffer->Unlock(lpBuf, dwBufferSize / 2, NULL, NULL); - /* Crea il thread che fa il play dello stream */ + /* Create a thread to play the stream */ hThreadEnd = CreateEvent(NULL, false, false, NULL); hPlayThread = CreateThread(NULL, 10240, (LPTHREAD_START_ROUTINE)PlayThread, (void *)this, 0, &dwId); SetThreadPriority(hPlayThread, THREAD_PRIORITY_HIGHEST); - /* Start il play del buffer DirectSound */ + /* Start to play the buffer */ lpDSBuffer->SetCurrentPosition(0); bIsPlaying = true; @@ -888,7 +855,7 @@ bool FPStream::play() { if (!bSoundSupported || !bFileLoaded) return false; - /* Alloca un buffer temporaneo */ + /* Allocate a temporary buffer */ lpTempBuffer = (byte *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, dwBufferSize / 2); if (lpTempBuffer == NULL) return false; @@ -906,23 +873,23 @@ bool FPStream::play() { return false; } - /* Posiziona lo stream file all'inizio */ + /* Reset the file position */ _file.seek(0); lpDSBuffer->Stop(); lpDSBuffer->SetCurrentPosition(0); - /* Riempie il buffer per avere i dati gia' pronti */ + /* Fills the buffer for the data already ready */ if ((err = lpDSBuffer->Lock(0, dwBufferSize / 2, &lpBuf, (uint32 *)&dwHi, NULL, NULL, 0)) != DS_OK) { error("Cannot lock stream buffer!", "soundLoadStream()"); } - /* Decomprime i dati dello stream direttamente dentro il buffer lockato */ + /* Uncompress the data from the stream directly into the locked buffer */ lpCodec->Decompress(hFile, lpBuf, dwBufferSize / 2); - /* Unlocka il buffer */ + /* Unlock the buffer */ lpDSBuffer->Unlock(lpBuf, dwBufferSize / 2, NULL, NULL); - /* Crea il thread che fa il play dello stream */ + /* Create a thread to play the stream */ hThreadEnd = CreateEvent(NULL, false, false, NULL); hPlayThread = CreateThread(NULL, 10240, (LPTHREAD_START_ROUTINE)PlayThread, (void *)this, 0, &dwId); SetThreadPriority(hPlayThread, THREAD_PRIORITY_HIGHEST); @@ -930,7 +897,7 @@ bool FPStream::play() { SetEvent(hPlayThread_PlayFast); #if 0 - /* Start il play del buffer DirectSound */ + /* Start to play the buffer */ lpDSBuffer->SetCurrentPosition(0); dspnHot[0].dwOffset = 32; @@ -958,11 +925,11 @@ bool FPStream::play() { /****************************************************************************\ * -* Function: bool Stop(bool bSync); +* Function: bool stop(bool bSync); * -* Description: Ferma il play dello stream. +* Description: Closes the stream. * -* Return: true se tutto OK, false in caso di errore. +* Return: True is everything is OK, False otherwise * \****************************************************************************/ @@ -984,19 +951,19 @@ bool FPStream::stop(bool bSync) { // lpDSBuffer->Play(0, 0, 0); return true; } else { - /* Ferma il buffer DirectSound */ + /* Close the DirectSound buffer */ lpDSBuffer->Stop(); - /* Avverte il thread che deve uscire e aspetta che si chiuda */ + /* Notify the thread is should stop */ SetEvent(hThreadEnd); WaitForSingleObject(hPlayThread, CORO_INFINITE); - /* Chiude l'handle del thread e disalloca la memoria temporanea */ + /* Closes the handle used by the stream and free its memory */ CloseHandle(hPlayThread); CloseHandle(hThreadEnd); GlobalFree(lpTempBuffer); - /* Disalloca e chiude il CODEC */ + /* Close and free the CODEC */ delete lpCodec; bIsPlaying = false; @@ -1027,12 +994,12 @@ void FPStream::waitForSync(FPStream *toplay) { WaitForSingleObject(hPlayThread, CORO_INFINITE); - /* Chiude l'handle del thread e disalloca la memoria temporanea */ + /* Closes the handle used by the stream and free its memory */ CloseHandle(hPlayThread); CloseHandle(hThreadEnd); GlobalFree(lpTempBuffer); - /* Disalloca e chiude il CODEC */ + /* Close and free the CODEC */ delete lpCodec; #endif _bIsPlaying = false; @@ -1042,7 +1009,7 @@ void FPStream::waitForSync(FPStream *toplay) { * * Function: void FPStream::PlayThread(); * -* Description: Thread che si occupa del play dello stream +* Description: Thread playing the stream * \****************************************************************************/ @@ -1057,7 +1024,7 @@ void FPStream::playThread(FPStream *This) { bool bPrecache; char buf[1024]; - /* Eventi che segnalano quando bisogna eseguire qualcosa */ + /* Events that signal when you need to do something */ HANDLE hList[5] = { This->hThreadEnd, This->hHot1, This->hHot2, This->hHot3, This->hPlayThread_PlayFast }; bPrecache = true; @@ -1069,7 +1036,7 @@ void FPStream::playThread(FPStream *This) { break; } - /* Decomprime i dati che stanno per essere scritti dentro il buffer temporaneo */ + /* Uncompresses the data being written into the temporary buffer */ if (This->lastVolume == 0) ZeroMemory(This->lpTempBuffer, This->dwBufferSize / 2); else if (bPrecache) @@ -1077,8 +1044,7 @@ void FPStream::playThread(FPStream *This) { bPrecache = false; - /* Attende il set di un evento. Dato che sono tutti in automatic reset, - non c'e' bisogno di resettarlo dopo */ + /* Waits for an event. Since they are all in automatic reset, there is no need to reset it after */ // uint32 dwBufStatus; // This->lpDSBuffer->GetStatus(&dwBufStatus); @@ -1093,15 +1059,15 @@ void FPStream::playThread(FPStream *This) { sprintf(buf, "CP Play: %u, Write: %u\n", dwPlay, dwWrite); warning(buf); */ - /* Fa uno switch per stabilire quale evento e' stato settato */ + /* Make a switch to determine which event has been set */ switch (dwResult - WAIT_OBJECT_0) { case 0: - /* Bisogna uscire dal thread */ + /* Must leave the thread */ cicla = false; break; case 1: - /* Bisogna riempire la seconda meta' del buffer */ + /* Must fill the second half of the buffer */ // if (dwPlay >= This->dspnHot[0].dwOffset && dwPlay <= This->dspnHot[0].dwOffset+1024 ) { // sprintf(buf, "Prima met buffer: %x\n", This->lpDSBuffer); @@ -1116,7 +1082,7 @@ void FPStream::playThread(FPStream *This) { break; case 2: - /* Bisogna riempire la prima meta' del buffer */ + /* Must fill the first half of the buffer */ // if (dwPlay >= This->dspnHot[1].dwOffset && dwPlay <= This->dspnHot[1].dwOffset+1024 ) { // sprintf(buf, "Seconda met buffer: %x\n", This->lpDSBuffer); @@ -1151,7 +1117,7 @@ void FPStream::playThread(FPStream *This) { } } - /* Ferma il buffer DirectSound */ + /* Close the DirectSound buffer */ // sprintf(buf, "Exiting thread. Buffer = %x, MyThread = 0x%x\n", This->lpDSBuffer, GetCurrentThreadId()); // warning(buf); This->lpDSBuffer->Stop(); @@ -1163,17 +1129,15 @@ void FPStream::playThread(FPStream *This) { /****************************************************************************\ * -* Function: bool SetLoop(bool bLoop); +* Function: bool setLoop(bool bLoop); * -* Description: Attiva o disattiva il loop dello stream. +* Description: Unables or disables stream loop. * -* Input: bool bLoop true per attivare il loop, false per -* disattivarlo +* Input: bool bLoop True enable loop, False disables it * -* Note: Il loop deve essere attivato PRIMA di eseguire il play -* dello stream. Qualsiasi modifica effettuata durante il play -* non avra' effetto fino a che lo stream non viene fermato, -* e poi rimesso in play. +* Note: The loop must be activated BEFORE the stream starts playing. +* Any changes made during the play will have no effect until +* the stream is stopped then played again. * \****************************************************************************/ @@ -1208,8 +1172,7 @@ void FPStream::pause(bool bPause) { bIsPlaying = true; bPaused = false; - // Trucchetto per risettare il volume secondo le - // possibili nuove configurazioni sonore + // Trick to reset the volume after a possible new sound configuration SetVolume(lastVolume); } } @@ -1221,9 +1184,9 @@ void FPStream::pause(bool bPause) { * * Function: void SetVolume(int dwVolume); * -* Description: Cambia il volume dello stream +* Description: Change the volume of the stream * -* Input: int dwVolume Volume da settare (0-63) +* Input: int dwVolume Volume to be set (0-63) * \****************************************************************************/ @@ -1245,16 +1208,14 @@ void FPStream::setVolume(int dwVolume) { #endif } - - /****************************************************************************\ * * Function: void GetVolume(int *lpdwVolume); * -* Description: Chiede il volume dello stream +* Description: Gets the vgolume of the stream * -* Input: int *lpdwVolume Variabile in cui verra' inserito -* il volume corrente +* Input: int *lpdwVolume Variable that will contain the +* current volume * \****************************************************************************/ -- cgit v1.2.3 From 8335c25cb96f970bbc546caecd845d05df06a778 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 17 Jun 2012 08:45:38 +1000 Subject: TONY: Fix memory leak in ActionThread if game exists whilst it is active --- engines/tony/mpal/mpal.cpp | 42 +++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 7e1831ec4d..3b98acea59 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -699,38 +699,45 @@ void ActionThread(CORO_PARAM, const void *param) { // COROUTINE CORO_BEGIN_CONTEXT; int j, k; - CORO_END_CONTEXT(_ctx); + LPMPALITEM item; - const LPMPALITEM item = *(const LPMPALITEM *)param; + ~CoroContextTag() { + if (item) globalDestroy(item); + } + CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); + // The ActionThread owns the data block pointed to, so we need to make sure it's + // freed when the process exits + _ctx->item = *(LPMPALITEM *)param; + GLOBALS._mpalError = 0; - for (_ctx->j = 0; _ctx->j < item->Action[item->dwRes].nCmds; _ctx->j++) { - _ctx->k = item->Action[item->dwRes].CmdNum[_ctx->j]; + for (_ctx->j = 0; _ctx->j < _ctx->item->Action[_ctx->item->dwRes].nCmds; _ctx->j++) { + _ctx->k = _ctx->item->Action[_ctx->item->dwRes].CmdNum[_ctx->j]; - if (item->_command[_ctx->k].type == 1) { + if (_ctx->item->_command[_ctx->k].type == 1) { // Custom function debugC(DEBUG_DETAILED, kTonyDebugActions, "Action Process %d Call=%s params=%d,%d,%d,%d", - CoroScheduler.getCurrentPID(), GLOBALS._lplpFunctionStrings[item->_command[_ctx->k]._nCf].c_str(), - item->_command[_ctx->k]._arg1, item->_command[_ctx->k]._arg2, - item->_command[_ctx->k]._arg3, item->_command[_ctx->k]._arg4 + CoroScheduler.getCurrentPID(), GLOBALS._lplpFunctionStrings[_ctx->item->_command[_ctx->k]._nCf].c_str(), + _ctx->item->_command[_ctx->k]._arg1, _ctx->item->_command[_ctx->k]._arg2, + _ctx->item->_command[_ctx->k]._arg3, _ctx->item->_command[_ctx->k]._arg4 ); - CORO_INVOKE_4(GLOBALS._lplpFunctions[item->_command[_ctx->k]._nCf], - item->_command[_ctx->k]._arg1, - item->_command[_ctx->k]._arg2, - item->_command[_ctx->k]._arg3, - item->_command[_ctx->k]._arg4 + CORO_INVOKE_4(GLOBALS._lplpFunctions[_ctx->item->_command[_ctx->k]._nCf], + _ctx->item->_command[_ctx->k]._arg1, + _ctx->item->_command[_ctx->k]._arg2, + _ctx->item->_command[_ctx->k]._arg3, + _ctx->item->_command[_ctx->k]._arg4 ); - } else if (item->_command[_ctx->k].type == 2) { + } else if (_ctx->item->_command[_ctx->k].type == 2) { // Variable assign debugC(DEBUG_DETAILED, kTonyDebugActions, "Action Process %d Variable=%s", - CoroScheduler.getCurrentPID(), item->_command[_ctx->k].lpszVarName); + CoroScheduler.getCurrentPID(), _ctx->item->_command[_ctx->k].lpszVarName); lockVar(); - varSetValue(item->_command[_ctx->k].lpszVarName, evaluateExpression(item->_command[_ctx->k].expr)); + varSetValue(_ctx->item->_command[_ctx->k].lpszVarName, evaluateExpression(_ctx->item->_command[_ctx->k].expr)); unlockVar(); } else { @@ -739,7 +746,8 @@ void ActionThread(CORO_PARAM, const void *param) { } } - globalDestroy(item); + globalDestroy(_ctx->item); + _ctx->item = NULL; debugC(DEBUG_DETAILED, kTonyDebugActions, "Action Process %d ended", CoroScheduler.getCurrentPID()); -- cgit v1.2.3 From a91553efeb0e2beaf942fc3f7db30868ac8c6afa Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 17 Jun 2012 09:09:18 +1000 Subject: TONY: Cleaned up the @defgroup comments --- engines/tony/custom.cpp | 3 ++- engines/tony/globals.h | 6 ++++-- engines/tony/mpal/expr.cpp | 5 +++++ engines/tony/mpal/loadmpc.cpp | 3 +++ engines/tony/mpal/mpal.cpp | 3 +++ engines/tony/mpal/mpal.h | 6 +++++- 6 files changed, 22 insertions(+), 4 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 375b405400..6e057cf031 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -131,7 +131,7 @@ void LoadChangedHotspot(Common::InSaveFile *f) { /** - * @defgroup Classes required for custom functions + * Classes required for custom functions * * Tony (To Move him) -> You can do MPAL through the animation? I really think so * @@ -139,6 +139,7 @@ void LoadChangedHotspot(Common::InSaveFile *f) { * ChangeLocation -> theEngine.ChangeLocation() * AddInventory -> theEngine.AddInventory() */ + void MCharResetCodes(void) { for (int i = 0; i < 10; i++) GLOBALS._mCharacter[i]._item = GLOBALS._loc->getItemFromCode(GLOBALS._mCharacter[i]._code); diff --git a/engines/tony/globals.h b/engines/tony/globals.h index 33ed36751a..098a98025e 100644 --- a/engines/tony/globals.h +++ b/engines/tony/globals.h @@ -253,8 +253,8 @@ public: /** * @defgroup MPAL variables - * - */ + */ + //@{ uint32 _mpalError; LPITEMIRQFUNCTION _lpiifCustom; LPLPCUSTOMFUNCTION _lplpFunctions; @@ -292,6 +292,8 @@ public: uint32 _nExecutingDialog; uint32 _nExecutingChoice; uint32 _nSelectedChoice; + + //@} }; } // End of namespace Tony diff --git a/engines/tony/mpal/expr.cpp b/engines/tony/mpal/expr.cpp index 52751120f6..c2fadd63df 100644 --- a/engines/tony/mpal/expr.cpp +++ b/engines/tony/mpal/expr.cpp @@ -42,6 +42,7 @@ namespace MPAL { /** * @defgroup Mathamatical operations */ +//@{ #define OP_MUL ((1 << 4) | 0) #define OP_DIV ((1 << 4) | 1) @@ -73,9 +74,12 @@ enum ExprListTypes { ELT_PARENTH2 = 4 }; +//@} + /** * @defgroup Structures */ +//@{ /** * Mathamatical framework to manage operations @@ -96,6 +100,7 @@ typedef struct { } EXPRESSION; typedef EXPRESSION *LPEXPRESSION; +//@} /** * Duplicate a mathematical expression. diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index 6ed4545d67..b589827a5a 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -517,6 +517,7 @@ static const byte *ParseLocation(const byte *lpBuf, LPMPALLOCATION lpmlLocation) /** * @defgroup Exported functions */ +//@{ /** * Reads and interprets the MPC file, and create structures for various directives @@ -796,6 +797,8 @@ void FreeMpc() { } } +//@} + } // end of namespace MPAL } // end of namespace Tony diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 3b98acea59..72d8d3045c 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -1395,6 +1395,7 @@ bool doSelection(uint32 i, uint32 dwData) { /** * @defgroup Exported functions */ +//@{ /** * Initialises the MPAL library and opens the .MPC file, which will be used for all queries. @@ -2918,6 +2919,8 @@ void mpalDumpDialogs(void) { unlockDialogs(); } +//@} + } // end of namespace MPAL } // end of namespace Tony diff --git a/engines/tony/mpal/mpal.h b/engines/tony/mpal/mpal.h index 9ea0c40bbc..1ec96c97d0 100644 --- a/engines/tony/mpal/mpal.h +++ b/engines/tony/mpal/mpal.h @@ -187,6 +187,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * * The following are defines used for simplifying calling the mpalQuery variants */ +//@{ /** * Gets the current version of MPAL @@ -386,11 +387,12 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; #define mpalQueryDoDialog(nDialog,nGroup) \ mpalQueryDWORD(MPQ_DO_DIALOG, (uint32)(nDialog),(uint32)(nGroup)) +//@} /** * @defgroup Functions exported to the main game */ - +//@{ /** * Initializes the MPAL library, and opens an .MPC file, which will be 'used for all queries @@ -526,6 +528,8 @@ void lockVar(void); */ void unlockVar(void); +//@} + } // end of namespace MPAL } // end of namespace Tony -- cgit v1.2.3 From d0c649721276e289745124f28005c08d61381070 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 17 Jun 2012 14:22:53 +1000 Subject: TONY: Fix crash opening the Options menu in-game --- engines/tony/game.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index cca55f00dd..2e7297cac3 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -888,7 +888,7 @@ void RMOptionScreen::init(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool &result) { bigBuf.addPrim(new RMGfxPrimitive(this)); - if (_nState == MENULOAD || _nState == MENUSAVE) + if (_nState == MENULOAD || _nState == MENUSAVE || _nState == MENUNONE) _nState = MENUGAME; CORO_INVOKE_0(initState); -- cgit v1.2.3 From b554063d3018a39f328f0cd818b03546918c60d6 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 17 Jun 2012 15:01:13 +1000 Subject: TONY: Moved global initialisations out of TonyEngine and into Globals class --- engines/tony/globals.cpp | 37 +++++++++++++++++++------------------ engines/tony/tony.cpp | 18 ------------------ 2 files changed, 19 insertions(+), 36 deletions(-) (limited to 'engines') diff --git a/engines/tony/globals.cpp b/engines/tony/globals.cpp index 9115dafd63..3042b5843a 100644 --- a/engines/tony/globals.cpp +++ b/engines/tony/globals.cpp @@ -60,24 +60,7 @@ Globals::Globals() { _bTonyInTexts = false; _bStaticTalk = false; _bPatIrqFreeze = false; - _bCfgInvLocked = false; - _bCfgInvNoScroll = false; - _bCfgTimerizedText = false; - _bCfgInvUp = false; - _bCfgAnni30 = false; - _bCfgAntiAlias = false; - _bCfgSottotitoli = false; - _bCfgTransparence = false; - _bCfgInterTips = false; - _bCfgDubbing = false; - _bCfgMusic = false; - _bCfgSFX = false; _bAlwaysDisplay = false; - _nCfgTonySpeed = 0; - _nCfgTextSpeed = 0; - _nCfgDubbingVolume = 0; - _nCfgMusicVolume = 0; - _nCfgSFXVolume = 0; _bIdleExited = false; _bSkipSfxNoLoop = false; _bNoBullsEye = false; @@ -85,7 +68,6 @@ Globals::Globals() { _curSoundEffect = 0; _bFadeOutStop = false; -// OSystem::MutexRef vdb; Common::fill(&_mut[0], &_mut[10], 0); _bSkipIdle = false; _hSkipIdle = 0; @@ -143,6 +125,25 @@ Globals::Globals() { Common::fill((byte *)&_mCharacter[i], (byte *)&_mCharacter[i] + sizeof(MCharacterStruct), 0); for (int i = 0; i < 256; ++i) Common::fill((byte *)&_changedHotspot[i], (byte *)&_changedHotspot[i] + sizeof(ChangedHotspotStruct), 0); + + // Set up globals that have explicit initial values + _bCfgInvLocked = false; + _bCfgInvNoScroll = false; + _bCfgTimerizedText = true; + _bCfgInvUp = false; + _bCfgAnni30 = false; + _bCfgAntiAlias = false; + _bCfgTransparence = true; + _bCfgInterTips = true; + _bCfgSottotitoli = true; + _nCfgTonySpeed = 3; + _nCfgTextSpeed = 5; + _bCfgDubbing = true; + _bCfgMusic = true; + _bCfgSFX = true; + _nCfgDubbingVolume = 10; + _nCfgMusicVolume = 7; + _nCfgSFXVolume = 10; } } // End of namespace Tony diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 094e1bd038..91204763b3 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -167,24 +167,6 @@ Common::ErrorCode TonyEngine::init() { // Allocate space for thumbnails when saving the game _curThumbnail = new uint16[160 * 120]; - // Set up global defaults - GLOBALS._bCfgInvLocked = false; - GLOBALS._bCfgInvNoScroll = false; - GLOBALS._bCfgTimerizedText = true; - GLOBALS._bCfgInvUp = false; - GLOBALS._bCfgAnni30 = false; - GLOBALS._bCfgAntiAlias = false; - GLOBALS._bCfgTransparence = true; - GLOBALS._bCfgInterTips = true; - GLOBALS._bCfgSottotitoli = true; - GLOBALS._nCfgTonySpeed = 3; - GLOBALS._nCfgTextSpeed = 5; - GLOBALS._bCfgDubbing = true; - GLOBALS._bCfgMusic = true; - GLOBALS._bCfgSFX = true; - GLOBALS._nCfgDubbingVolume = 10; - GLOBALS._nCfgMusicVolume = 7; - GLOBALS._nCfgSFXVolume = 10; _bQuitNow = false; return Common::kNoError; -- cgit v1.2.3 From 9405f9eb4aed1d4c248e57ab4972b0132b2253f5 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 17 Jun 2012 17:04:10 +1000 Subject: TONY: Added code to load and save the ScummVM sound settings --- engines/tony/font.cpp | 2 +- engines/tony/game.cpp | 7 +++++-- engines/tony/gfxengine.cpp | 4 ++-- engines/tony/globals.cpp | 2 +- engines/tony/globals.h | 2 +- engines/tony/tony.cpp | 32 ++++++++++++++++++++++++++++++++ engines/tony/tony.h | 3 +++ 7 files changed, 45 insertions(+), 7 deletions(-) (limited to 'engines') diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index a567fe20cd..af6f5d687c 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -2144,7 +2144,7 @@ void RMTextDialog::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *p _startTime = _vm->getTime(); if (_bShowed) { - if (GLOBALS._bCfgSottotitoli || _bAlwaysDisplay) { + if (GLOBALS._bShowSubtitles || _bAlwaysDisplay) { prim->getDst().topLeft() = _dst; CORO_INVOKE_2(RMText::draw, bigBuf, prim); } diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 2e7297cac3..7b2834a8fa 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -700,7 +700,7 @@ void RMOptionScreen::initState(CORO_PARAM) { _buttonGfx_AntiAlias->setActiveState(!GLOBALS._bCfgAntiAlias); assert(_buttonGfx_Sottotitoli == NULL); _buttonGfx_Sottotitoli = new RMOptionButton(20017, RMPoint(98, 82), true); - _buttonGfx_Sottotitoli->setActiveState(!GLOBALS._bCfgSottotitoli); + _buttonGfx_Sottotitoli->setActiveState(!GLOBALS._bShowSubtitles); assert(_buttonGfx_Tips == NULL); _buttonGfx_Tips = new RMOptionButton(20018, RMPoint(431, 246), true); _buttonGfx_Tips->setActiveState(GLOBALS._bCfgInterTips); @@ -822,7 +822,7 @@ void RMOptionScreen::closeState(void) { delete _buttonGfx_AntiAlias; _buttonGfx_AntiAlias = NULL; - GLOBALS._bCfgSottotitoli = !_buttonGfx_Sottotitoli->isActive(); + GLOBALS._bShowSubtitles = !_buttonGfx_Sottotitoli->isActive(); delete _buttonGfx_Sottotitoli; _buttonGfx_Sottotitoli = NULL; @@ -858,6 +858,9 @@ void RMOptionScreen::closeState(void) { delete _buttonSound_SFXOn; _buttonSound_SFXOn = NULL; } + + // Save the new settings to ScummVM + _vm->saveSoundSettings(); } _nState = MENUNONE; diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index deae0cb641..9dab3eeb52 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -659,7 +659,7 @@ void RMGfxEngine::saveState(const Common::String &fn, byte *curThumb, const Comm f->writeByte(GLOBALS._bCfgInvUp); f->writeByte(GLOBALS._bCfgAnni30); f->writeByte(GLOBALS._bCfgAntiAlias); - f->writeByte(GLOBALS._bCfgSottotitoli); + f->writeByte(GLOBALS._bShowSubtitles); f->writeByte(GLOBALS._bCfgTransparence); f->writeByte(GLOBALS._bCfgInterTips); f->writeByte(GLOBALS._bCfgDubbing); @@ -795,7 +795,7 @@ void RMGfxEngine::loadState(CORO_PARAM, const Common::String &fn) { GLOBALS._bCfgInvUp = _ctx->f->readByte(); GLOBALS._bCfgAnni30 = _ctx->f->readByte(); GLOBALS._bCfgAntiAlias = _ctx->f->readByte(); - GLOBALS._bCfgSottotitoli = _ctx->f->readByte(); + GLOBALS._bShowSubtitles = _ctx->f->readByte(); GLOBALS._bCfgTransparence = _ctx->f->readByte(); GLOBALS._bCfgInterTips = _ctx->f->readByte(); GLOBALS._bCfgDubbing = _ctx->f->readByte(); diff --git a/engines/tony/globals.cpp b/engines/tony/globals.cpp index 3042b5843a..48b04007b4 100644 --- a/engines/tony/globals.cpp +++ b/engines/tony/globals.cpp @@ -135,7 +135,7 @@ Globals::Globals() { _bCfgAntiAlias = false; _bCfgTransparence = true; _bCfgInterTips = true; - _bCfgSottotitoli = true; + _bShowSubtitles = true; _nCfgTonySpeed = 3; _nCfgTextSpeed = 5; _bCfgDubbing = true; diff --git a/engines/tony/globals.h b/engines/tony/globals.h index 098a98025e..cf231018a6 100644 --- a/engines/tony/globals.h +++ b/engines/tony/globals.h @@ -194,7 +194,7 @@ public: bool _bCfgInvUp; bool _bCfgAnni30; bool _bCfgAntiAlias; - bool _bCfgSottotitoli; + bool _bShowSubtitles; bool _bCfgTransparence; bool _bCfgInterTips; bool _bCfgDubbing; diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 91204763b3..654a3f8222 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -42,6 +42,7 @@ TonyEngine::TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc) : Eng _vm = this; _loadSlotNumber = -1; + // Set the up the debugger _debugger = new Debugger(); DebugMan.addDebugChannel(kTonyDebugAnimations, "animations", "Animations debugging"); DebugMan.addDebugChannel(kTonyDebugActions, "actions", "Actions debugging"); @@ -62,6 +63,9 @@ TonyEngine::TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc) : Eng _initialLoadSlotNumber = slotNumber; } + // Load the ScummVM sound settings + syncSoundSettings(); + _hEndOfFrame = 0; for (int i = 0; i < 6; i++) _stream[i] = NULL; @@ -627,4 +631,32 @@ Common::Error TonyEngine::saveGameState(int slot, const Common::String &desc) { return Common::kNoError; } +void TonyEngine::syncSoundSettings() { + Engine::syncSoundSettings(); + + GLOBALS._bCfgDubbing = !ConfMan.getBool("mute") && !ConfMan.getBool("speech_mute"); + GLOBALS._bCfgSFX = !ConfMan.getBool("mute") && !ConfMan.getBool("sfx_mute"); + GLOBALS._bCfgMusic = !ConfMan.getBool("mute") && !ConfMan.getBool("music_mute"); + + GLOBALS._nCfgDubbingVolume = ConfMan.getInt("speech_volume") * 10 / 256; + GLOBALS._nCfgSFXVolume = ConfMan.getInt("sfx_volume") * 10 / 256; + GLOBALS._nCfgMusicVolume = ConfMan.getInt("music_volume") * 10 / 256; + + GLOBALS._bShowSubtitles = ConfMan.getBool("subtitles"); + GLOBALS._nCfgTextSpeed = ConfMan.getInt("talkspeed") * 10 / 256; +} + +void TonyEngine::saveSoundSettings() { + ConfMan.setBool("speech_mute", GLOBALS._bCfgDubbing); + ConfMan.setBool("sfx_mute", GLOBALS._bCfgSFX); + ConfMan.setBool("music_mute", GLOBALS._bCfgMusic); + + ConfMan.setInt("speech_volume", GLOBALS._nCfgDubbingVolume * 256 / 10); + ConfMan.setInt("sfx_volume", GLOBALS._nCfgSFXVolume * 256 / 10); + ConfMan.setInt("music_volume", GLOBALS._nCfgMusicVolume * 256 / 10); + + ConfMan.setBool("subtitles", GLOBALS._bShowSubtitles); + ConfMan.setBool("talkspeed", GLOBALS._nCfgTextSpeed); +} + } // End of namespace Tony diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 93232b950d..709465ca89 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -221,6 +221,9 @@ public: void openInitLoadMenu(CORO_PARAM); void openInitOptions(CORO_PARAM); + + virtual void syncSoundSettings(); + void saveSoundSettings(); }; // Global reference to the TonyEngine object -- cgit v1.2.3 From d24fc8b5d895b595ec62ba1588d734392bc3a5e7 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 17 Jun 2012 17:42:29 +1000 Subject: TONY: Fix memory leak in LocationPollThread --- engines/tony/mpal/mpal.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 72d8d3045c..07042ec077 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -824,12 +824,24 @@ void LocationPollThread(CORO_PARAM, const void *param) { MYACTION *MyActions; MYTHREAD *MyThreads; + + ~CoroContextTag() { + // Free data blocks + if (MyThreads) + globalDestroy(MyThreads); + if (MyActions) + globalDestroy(MyActions); + } CORO_END_CONTEXT(_ctx); uint32 id = *((const uint32 *)param); CORO_BEGIN_CODE(_ctx); + /* Initialise data pointers */ + _ctx->MyActions = NULL; + _ctx->MyThreads = NULL; + /* To begin with, we need to request the item list from the location */ _ctx->il = mpalQueryItemList(GLOBALS._nPollingLocations[id]); @@ -1045,12 +1057,6 @@ void LocationPollThread(CORO_PARAM, const void *param) { // Set idle skip off CORO_INVOKE_4(GLOBALS._lplpFunctions[201], 0, 0, 0, 0); - /* We're finished */ - globalDestroy(_ctx->MyThreads); - globalDestroy(_ctx->MyActions); - - CORO_KILL_SELF(); - CORO_END_CODE; } -- cgit v1.2.3 From e36f36168d0e0b6e2abf29386c2761797735d857 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 17 Jun 2012 18:09:52 +0200 Subject: TONY: Doxygen-ify comments in sound files --- engines/tony/sound.cpp | 494 ++++++++++++++++++----------------------------- engines/tony/sound.h | 514 ++++++++++++++++++------------------------------- 2 files changed, 372 insertions(+), 636 deletions(-) (limited to 'engines') diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index e650a5d74b..d8b3655d2e 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -37,70 +37,43 @@ namespace Tony { -/****************************************************************************\ -* Defines -\****************************************************************************/ - #define RELEASE(x) {if ((x) != NULL) { (x)->release(); x = NULL; }} -/****************************************************************************\ -* Methods for FPSound -\****************************************************************************/ - -/****************************************************************************\ -* -* Function: FPSound::FPSound(); -* -* Description: Default constructor. Initializes the attributes. -* -\****************************************************************************/ +/** + * Default constructor. Initializes the attributes. + * + */ FPSound::FPSound() { _bSoundSupported = false; } - -/****************************************************************************\ -* -* Function: bool FPSound::init(); -* -* Description: Initializes the object, and prepare everything you need to - create streams and sound effects. -* -* Return: True if everything's OK, False otherwise. -* -\****************************************************************************/ +/** + * Initializes the object, and prepare everything you need to create streams and sound effects. + * + * @returns True is everything is OK, False otherwise + */ bool FPSound::init() { _bSoundSupported = g_system->getMixer()->isReady(); return _bSoundSupported; } - -/****************************************************************************\ -* -* Function: FPSound::~FPSound(); -* -* Description: Destroy the object and free the memory. -* -\****************************************************************************/ +/** + * Destroy the object and free the memory + * + */ FPSound::~FPSound() { } - -/****************************************************************************\ -* -* Function: bool CreateStream(FPStream** lplpStream); -* -* Description: Allocates an object of type FPStream, and return its pointer -* -* Input: FPStream** lplpStream Will contain a pointer to the object -* you just created. -* -* Return: True is everything is OK, False otherwise -* -\****************************************************************************/ +/** + * Allocates an object of type FPStream, and return its pointer + * + * @param lplpStream Will contain a pointer to the object you just created. + * + * @returns True is everything is OK, False otherwise + */ bool FPSound::createStream(FPStream **lplpStream) { (*lplpStream) = new FPStream(_bSoundSupported); @@ -108,18 +81,13 @@ bool FPSound::createStream(FPStream **lplpStream) { return (*lplpStream != NULL); } -/****************************************************************************\ -* -* Function: bool CreateSfx(FPSfx** lplpSfx); -* -* Description: Allocates an object of type FpSfx, and return its pointer -* -* Input: FPSfx** lplpSfx Will contain a pointer to the object -* you just created. -* -* Return: True is everything is OK, False otherwise -* -\****************************************************************************/ +/** + * Allocates an object of type FpSfx, and return its pointer + * + * @param lplpSfx Will contain a pointer to the object you just created. + * + * @returns True is everything is OK, False otherwise + */ bool FPSound::createSfx(FPSfx **lplpSfx) { (*lplpSfx) = new FPSfx(_bSoundSupported); @@ -127,15 +95,11 @@ bool FPSound::createSfx(FPSfx **lplpSfx) { return (*lplpSfx != NULL); } -/****************************************************************************\ -* -* Function: void setMasterVolume(int dwVolume); -* -* Description: Set the general volume -* -* Input: int dwVolume Volume to set (0-63) -* -\****************************************************************************/ +/** + * Set the general volume + * + * @param dwVolume Volume to set (0-63) + */ void FPSound::setMasterVolume(int dwVolume) { if (!_bSoundSupported) @@ -144,16 +108,11 @@ void FPSound::setMasterVolume(int dwVolume) { g_system->getMixer()->setVolumeForSoundType(Audio::Mixer::kPlainSoundType, CLIP(dwVolume, 0, 63) * Audio::Mixer::kMaxChannelVolume / 63); } -/****************************************************************************\ -* -* Function: void getMasterVolume(int *lpdwVolume); -* -* Description: Get the general volume -* -* Input: int *lpdwVolume Variable that will contain the -* volume (0-63) -* -\****************************************************************************/ +/** + * Get the general volume + * + * @param lpdwVolume Variable that will contain the volume (0-63) + */ void FPSound::getMasterVolume(int *lpdwVolume) { if (!_bSoundSupported) @@ -162,18 +121,13 @@ void FPSound::getMasterVolume(int *lpdwVolume) { *lpdwVolume = g_system->getMixer()->getVolumeForSoundType(Audio::Mixer::kPlainSoundType) * 63 / Audio::Mixer::kMaxChannelVolume; } -/****************************************************************************\ -* Methods for FPSfx -\****************************************************************************/ - -/****************************************************************************\ -* -* Function: FPSfx(bool bSoundOn); -* -* Description: Default constructor. Do *NOT* declare an object directly, -* but rather create it using FPSound::CreateSfx() -* -\****************************************************************************/ +/** + * Default constructor. + * + * @remarks Do *NOT* declare an object directly, but rather + * create it using FPSound::CreateSfx() + * + */ FPSfx::FPSfx(bool bSoundOn) { _bSoundSupported = bSoundOn; @@ -188,15 +142,13 @@ FPSfx::FPSfx(bool bSoundOn) { _vm->_activeSfx.push_back(this); } - -/****************************************************************************\ -* -* Function: ~FPSfx(); -* -* Description: Default Destructor. It is also stops the sound effect that -* may be currently played, and free the memory it uses. -* -\****************************************************************************/ +/** + * Default Destructor. + * + * @remarks It is also stops the sound effect that may be + * currently played, and free the memory it uses. + * + */ FPSfx::~FPSfx() { if (!_bSoundSupported) @@ -215,35 +167,19 @@ FPSfx::~FPSfx() { // CloseHandle(hEndOfBuffer); } -/****************************************************************************\ -* -* Function: release(); -* -* Description: Releases the memory used by the object. -* Must be called when the object is no longer used and -* **ONLY** if the object was created by FPSound::CreateStream() -* -* Note: Object pointers are no longer valid after this call. -* -\****************************************************************************/ +/** + * Releases the memory used by the object. + * + * @remarks Must be called when the object is no longer used and + * **ONLY** if the object was created by + * FPSound::CreateStream(). + * Object pointers are no longer valid after this call. + */ void FPSfx::release() { delete this; } -/****************************************************************************\ -* -* Function: bool loadWave(Common::SeekableReadStream *stream); -* -* Description: Opens a file and loads a sound effect. -* -* Input: byte *lpBuf Buffer containing the Sfx -* uint32 dwCodec CODEC used to uncompress the samples -* -* Return: True is everything is OK, False otherwise -* -\****************************************************************************/ - bool FPSfx::loadWave(Common::SeekableReadStream *stream) { if (!stream) return false; @@ -258,20 +194,6 @@ bool FPSfx::loadWave(Common::SeekableReadStream *stream) { return true; } - -/****************************************************************************\ -* -* Function: bool LoadFile(const char * lpszFileName, uint32 dwCodec=FPCODEC_RAW); -* -* Description: Opens a file and loads a sound effect. -* -* Input: LPSTR lpszFile Sfx filename -* uint32 dwCodec CODEC used to uncompress the samples -* -* Return: True is everything is OK, False otherwise -* -\****************************************************************************/ - bool FPSfx::loadVoiceFromVDB(Common::File &vdbFP) { if (!_bSoundSupported) return true; @@ -287,6 +209,14 @@ bool FPSfx::loadVoiceFromVDB(Common::File &vdbFP) { return true; } +/** + * Opens a file and loads a sound effect. + * + * @param lpszFileName Sfx filename + * @param dwCodec CODEC used to uncompress the samples + * + * @returns True is everything is OK, False otherwise + */ bool FPSfx::loadFile(const char *lpszFileName, uint32 dwCodec) { if (!_bSoundSupported) @@ -323,16 +253,11 @@ bool FPSfx::loadFile(const char *lpszFileName, uint32 dwCodec) { return true; } - -/****************************************************************************\ -* -* Function: bool play(); -* -* Description: Play the Sfx in memory. -* -* Return: True is everything is OK, False otherwise -* -\****************************************************************************/ +/** + * Play the Sfx in memory. + * + * @returns True is everything is OK, False otherwise + */ bool FPSfx::play() { stop(); // sanity check @@ -365,16 +290,11 @@ bool FPSfx::play() { return true; } - -/****************************************************************************\ -* -* Function: bool stop(void); -* -* Description: Stop an sfx. -* -* Return: True is everything is OK, False otherwise -* -\****************************************************************************/ +/** + * Stops a Sfx. + * + * @returns True is everything is OK, False otherwise + */ bool FPSfx::stop() { if (_bFileLoaded) { @@ -385,26 +305,25 @@ bool FPSfx::stop() { return true; } - - -/****************************************************************************\ -* -* Function: bool setLoop(bool bLoop); -* -* Description: Enables or disables the Sfx loop. -* -* Input: bool bLoop True to enable the loop, False to disable -* -* Note: The loop must be activated BEFORE the sfx starts playing. -* Any changes made during the play will have no effect until -* the sfx is stopped then played again. -* -\****************************************************************************/ +/** + * Enables or disables the Sfx loop. + * + * @param bLoop True to enable the loop, False to disable + * + * @remarks The loop must be activated BEFORE the sfx starts + * playing. Any changes made during the play will have + * no effect until the sfx is stopped then played again. + */ void FPSfx::setLoop(bool bLop) { _bLoop = bLop; } +/** + * Pauses a Sfx. + * + */ + void FPSfx::pause(bool bPause) { if (_bFileLoaded) { if (g_system->getMixer()->isSoundHandleActive(_handle) && (bPause ^ _bPaused)) @@ -414,15 +333,12 @@ void FPSfx::pause(bool bPause) { } } -/****************************************************************************\ -* -* Function: void setVolume(int dwVolume); -* -* Description: Change the volume of Sfx -* -* Input: int dwVolume Volume to be set (0-63) -* -\****************************************************************************/ +/** + * Change the volume of Sfx + * + * @param dwVolume Volume to be set (0-63) + * + */ void FPSfx::setVolume(int dwVolume) { if (dwVolume > 63) @@ -453,17 +369,12 @@ void FPSfx::setVolume(int dwVolume) { g_system->getMixer()->setChannelVolume(_handle, dwVolume * Audio::Mixer::kMaxChannelVolume / 63); } - - -/****************************************************************************\ -* -* Function: void GetVolume(int *lpdwVolume); -* -* Description: Gets the Sfx volume -* -* Input: int *lpdwVolume Will contain the current Sfx volume -* -\****************************************************************************/ +/** + * Gets the Sfx volume + * + * @param lpdwVolume Will contain the current Sfx volume + * + */ void FPSfx::getVolume(int *lpdwVolume) { if (g_system->getMixer()->isSoundHandleActive(_handle)) @@ -475,6 +386,7 @@ void FPSfx::getVolume(int *lpdwVolume) { /** * Returns true if the underlying sound has ended */ + bool FPSfx::endOfBuffer() const { return !g_system->getMixer()->isSoundHandleActive(_handle) && (!_rewindableStream || _rewindableStream->endOfData()); } @@ -505,18 +417,12 @@ void FPSfx::soundCheckProcess(CORO_PARAM, const void *param) { CORO_END_CODE; } -/****************************************************************************\ -* Methods for FPStream -\****************************************************************************/ - -/****************************************************************************\ -* -* Function: FPStream(LPDIRECTSOUND lpDS, bool bSoundOn); -* -* Description: Default constructor. Do *NOT* declare an object directly, -* but rather create it using FPSound::CreateStream() -* -\****************************************************************************/ +/** + * Default constructor. + * + * @remarks Do *NOT* declare an object directly, but rather + * create it using FPSound::CreateStream() + */ FPStream::FPStream(bool bSoundOn) { #ifdef REFACTOR_ME @@ -599,14 +505,11 @@ bool FPStream::createBuffer(int nBufSize) { return true; } - -/****************************************************************************\ -* -* Function: ~FPStream(); -* -* Description: Default destructor. It calls CloseFile() if needed. -* -\****************************************************************************/ +/** + * Default destructor. + * + * @remarks It calls CloseFile() if needed. + */ FPStream::~FPStream() { #ifdef REFACTOR_ME @@ -648,37 +551,27 @@ FPStream::~FPStream() { #endif } - -/****************************************************************************\ -* -* Function: release(); -* -* Description: Releases the memory object. Must be called when the object -* is no longer used and **ONLY** if the object was created by -* FPSound::CreateStream(). -* -* Note: Object pointers are no longer valid after this call. -* -\****************************************************************************/ +/** + * Releases the memory object. + * + * @remarks Must be called when the object is no longer used + * and **ONLY** if the object was created by + * FPSound::CreateStream(). + * Object pointers are no longer valid after this call. + */ void FPStream::release() { delete this; -// return NULL; } - -/****************************************************************************\ -* -* Function: bool loadFile(const char *lpszFileName, uint32 dwCodec=FPCODEC_RAW); -* -* Description: Opens a file stream. -* -* Input: LPSTR lpszFile Filename to be opened -* uint32 dwCodec CODEC to be used to uncompress samples -* -* Return: True is everything is OK, False otherwise -* -\****************************************************************************/ +/** + * Opens a file stream + * + * @param lpszFile Filename to be opened + * @param dwCodec CODEC to be used to uncompress samples + * + * @returns True is everything is OK, False otherwise + */ bool FPStream::loadFile(const char *lpszFileName, uint32 dwCodType, int nBufSize) { #ifdef REFACTOR_ME @@ -714,18 +607,15 @@ bPaused = false; return true; } - -/****************************************************************************\ -* -* Function: unloadFile(); -* -* Description: Closes a file stream (opened or not). It is necessary to call -* this function to free the memory used by the stream. -* -* Return: For safety, the destructor calls unloadFile() if it has not -* been mentioned explicitly. -* -\****************************************************************************/ +/** + * Closes a file stream (opened or not). + * + * @returns For safety, the destructor calls unloadFile() if it has not + * been mentioned explicitly. + * + * @remarks It is necessary to call this function to free the + * memory used by the stream. + */ bool FPStream::unloadFile() { #ifdef REFACTOR_ME @@ -745,16 +635,6 @@ bool FPStream::unloadFile() { return true; } -/****************************************************************************\ -* -* Function: bool Play(); -* -* Description: Play the stream. -* -* Return: True is everything is OK, False otherwise -* -\****************************************************************************/ - void FPStream::prefetch(void) { #ifdef REFACTOR_ME uint32 dwId; @@ -845,6 +725,12 @@ void FPStream::playFast(void) { #endif } +/** + * Play the stream. + * + * @returns True is everything is OK, False otherwise + */ + bool FPStream::play() { #ifdef REFACTOR_ME uint32 dwId; @@ -922,16 +808,12 @@ bool FPStream::play() { return true; } - -/****************************************************************************\ -* -* Function: bool stop(bool bSync); -* -* Description: Closes the stream. -* -* Return: True is everything is OK, False otherwise -* -\****************************************************************************/ +/** + * Closes the stream. + * + * @returns True is everything is OK, False otherwise + * + */ bool FPStream::stop(bool bSync) { #ifdef REFACTOR_ME @@ -1005,13 +887,10 @@ void FPStream::waitForSync(FPStream *toplay) { _bIsPlaying = false; } -/****************************************************************************\ -* -* Function: void FPStream::PlayThread(); -* -* Description: Thread playing the stream -* -\****************************************************************************/ +/** + * Thread playing the stream + * + */ void FPStream::playThread(FPStream *This) { #ifdef REFACTOR_ME @@ -1126,26 +1005,27 @@ void FPStream::playThread(FPStream *This) { #endif } - -/****************************************************************************\ -* -* Function: bool setLoop(bool bLoop); -* -* Description: Unables or disables stream loop. -* -* Input: bool bLoop True enable loop, False disables it -* -* Note: The loop must be activated BEFORE the stream starts playing. -* Any changes made during the play will have no effect until -* the stream is stopped then played again. -* -\****************************************************************************/ +/** + * Unables or disables stream loop. + * + * @param bLoop True enable loop, False disables it + * + * @remarks The loop must be activated BEFORE the stream starts + * playing. Any changes made during the play will have no + * effect until the stream is stopped then played again. + */ void FPStream::setLoop(bool loop) { _bLoop = loop; } +/** + * Pause sound effect + * + * @param bPause True enables pause, False disables it + */ + void FPStream::pause(bool bPause) { #ifdef REFACTOR_ME @@ -1179,16 +1059,12 @@ void FPStream::pause(bool bPause) { #endif } - -/****************************************************************************\ -* -* Function: void SetVolume(int dwVolume); -* -* Description: Change the volume of the stream -* -* Input: int dwVolume Volume to be set (0-63) -* -\****************************************************************************/ +/** + * Change the volume of the stream + * + * @param dwVolume Volume to be set (0-63) + * + */ void FPStream::setVolume(int dwVolume) { #ifdef REFACTOR_ME @@ -1208,16 +1084,12 @@ void FPStream::setVolume(int dwVolume) { #endif } -/****************************************************************************\ -* -* Function: void GetVolume(int *lpdwVolume); -* -* Description: Gets the vgolume of the stream -* -* Input: int *lpdwVolume Variable that will contain the -* current volume -* -\****************************************************************************/ +/** + * Gets the vgolume of the stream + * + * @param lpdwVolume Variable that will contain the current volume + * + */ void FPStream::getVolume(int *lpdwVolume) { #ifdef REFACTOR_ME diff --git a/engines/tony/sound.h b/engines/tony/sound.h index 5e50c31554..e1f0e40851 100644 --- a/engines/tony/sound.h +++ b/engines/tony/sound.h @@ -50,131 +50,77 @@ enum SoundCodecs { }; -/****************************************************************************\ -***************************************************************************** -* class FPSound -* ------------- -* Description: Sound driver per Falling Pumpkins -***************************************************************************** -\****************************************************************************/ +//**************************************************************************** +//* class FPSound +//* ------------- +//* Description: Sound driver For Tony Tough +//**************************************************************************** class FPSound { - private: - bool _bSoundSupported; - /****************************************************************************\ - * Methods - \****************************************************************************/ - public: - - /****************************************************************************\ - * - * Function: FPSound::FPSound(); - * - * Description: Default constructor. Initializes the attributes - * - \****************************************************************************/ + /** + * Default constructor. Initializes the attributes. + * + */ FPSound(); - /****************************************************************************\ - * - * Function: FPSound::~FPSound(); - * - * Description: Deinitialize the object, free memory - * - \****************************************************************************/ + /** + * Destroy the object and free the memory + * + */ ~FPSound(); - /****************************************************************************\ - * - * Function: bool FPSound::Init(); - * - * Description: Initializes the objects, and prepare everything required to - * create streams and sound effects. - * - * Return: True if everything is OK, False otherwise. - * - \****************************************************************************/ + /** + * Initializes the object, and prepare everything you need to create streams and sound effects. + * + * @returns True is everything is OK, False otherwise + */ bool init(); - /****************************************************************************\ - * - * Function: bool CreateStream(FPStream** lplpStream); - * - * Description: Allocates an object of type FPStream, and return its - * pointer after it has been initialized. - * - * Input: FPStream** lplpStream Will contain the pointer of the - * object - * - * Return: True is everything i OK, False otherwise - * - * Note: The use of functions like CreateStream () and CreateSfx () - * are due to the fact that the class constructors and - * FPStream FPSfx require that DirectSound is already initialized. - * In this way, you avoid the bugs that would be created if an - * object type is declared FPStream FPSfx or global - * (or anyway before initializing DirectSound). - \****************************************************************************/ + /** + * Allocates an object of type FPStream, and return its pointer + * + * @param lplpStream Will contain a pointer to the object you just created. + * + * @returns True is everything is OK, False otherwise + */ bool createStream(FPStream **lplpStream); - /****************************************************************************\ - * - * Function: bool CreateSfx(FPSfx** lplpSfx); - * - * Description: Allocates an object of type FPSfx and returns a pointer - * pointing to it - * - * Input: FPSfx** lplpSfx Will contain the pointer of the - * object - * - * Return: True is everything i OK, False otherwise - * - * Note: See notes about CreateStream() - * - \****************************************************************************/ + /** + * Allocates an object of type FpSfx, and return its pointer + * + * @param lplpSfx Will contain a pointer to the object you just created. + * + * @returns True is everything is OK, False otherwise + */ bool createSfx(FPSfx **lplpSfx); - /****************************************************************************\ - * - * Function: void SetMasterVolume(int dwVolume); - * - * Description: Set main volume - * - * Input: int dwVolume Volume to be set (0-63) - * - \****************************************************************************/ + /** + * Set the general volume + * + * @param dwVolume Volume to set (0-63) + */ void setMasterVolume(int dwVolume); - /****************************************************************************\ - * - * Function: void GetMasterVolume(LPINT lpdwVolume); - * - * Description: Get main volume - * - * Input: LPINT lpdwVolume This variable will contain the - * current volume (0-63) - * - \****************************************************************************/ + /** + * Get the general volume + * + * @param lpdwVolume Variable that will contain the volume (0-63) + */ void getMasterVolume(int *lpdwVolume); }; class FPSfx { - - /****************************************************************************\ - * Attributes - \****************************************************************************/ - private: bool _bSoundSupported; // True if the sound is active bool _bFileLoaded; // True is a file is opened @@ -191,167 +137,121 @@ private: public: uint32 _hEndOfBuffer; -private: - - - /****************************************************************************\ - * Methods - \****************************************************************************/ - -public: /** * Check process for whether sounds have finished playing */ static void soundCheckProcess(CORO_PARAM, const void *param); - /****************************************************************************\ - * - * Function: FPSfx(bool bSoundOn); - * - * Description: Default constructor. *DO NOT* declare the object directly, - * create it though FPSound::CreateSfx() instead - * - \****************************************************************************/ + /** + * Default constructor. + * + * @remarks Do *NOT* declare an object directly, but rather + * create it using FPSound::CreateSfx() + * + */ FPSfx(bool bSoundOn); - /****************************************************************************\ - * - * Function: ~FPSfx(); - * - * Description: Default destructor. It also stops the sound effect that - * may be running, and free the memory used. - * - \****************************************************************************/ + /** + * Default Destructor. + * + * @remarks It is also stops the sound effect that may be + * currently played, and free the memory it uses. + * + */ ~FPSfx(); - /****************************************************************************\ - * - * Function: release(); - * - * Description: Releases the memory object. Must be called when the object - * is no longer useful and **ONLY** when the object was created - * with the FPSound :: CreateStream (). - * - * Note: Any object pointers are no longer valid after this call. - * - \****************************************************************************/ + /** + * Releases the memory used by the object. + * + * @remarks Must be called when the object is no longer used and + * **ONLY** if the object was created by + * FPSound::CreateStream(). + * Object pointers are no longer valid after this call. + */ void release(); - /****************************************************************************\ - * - * Function: bool loadFile(char *lpszFileName, uint32 dwCodec=FPCODEC_RAW); - * - * Description: Opens a file and load sound effect - * - * Input: char *lpszFile SFX filename - * uint32 dwCodec CODEC to be used to decompress - * the sound samples - * - * Return: True if everything is OK, False otherwise - * - \****************************************************************************/ + /** + * Opens a file and loads a sound effect. + * + * @param lpszFileName Sfx filename + * @param dwCodec CODEC used to uncompress the samples + * + * @returns True is everything is OK, False otherwise + */ bool loadFile(const char *lpszFileName, uint32 dwCodec = FPCODEC_RAW); bool loadWave(Common::SeekableReadStream *stream); bool loadVoiceFromVDB(Common::File &vdbFP); - /****************************************************************************\ - * - * Function: bool play(); - * - * Description: Play the loaded FX. - * - * Return: True if everything is OK, False otherwise - * - \****************************************************************************/ + /** + * Play the Sfx in memory. + * + * @returns True is everything is OK, False otherwise + */ bool play(); - /****************************************************************************\ - * - * Function: bool stop(); - * - * Description: Stop a FX - * - * Return: True if everything is OK, False otherwise - * - \****************************************************************************/ + /** + * Stops a Sfx. + * + * @returns True is everything is OK, False otherwise + */ bool stop(); - /****************************************************************************\ - * - * Function: void pause(bool bPause); - * - * Description: Pause a FX - * - \****************************************************************************/ + /** + * Pauses a Sfx. + * + */ void pause(bool bPause); - /****************************************************************************\ - * - * Function: bool setLoop(bool bLoop); - * - * Description: Enables or disables SFX loop - * - * Input: bool bLoop True to activate the loop, else False - * - * Note: The loop must be activated before the SFX starts to play, - * else the effect will only be noticable next time the SFX is - * played - * - \****************************************************************************/ + /** + * Enables or disables the Sfx loop. + * + * @param bLoop True to enable the loop, False to disable + * + * @remarks The loop must be activated BEFORE the sfx starts + * playing. Any changes made during the play will have + * no effect until the sfx is stopped then played again. + */ void setLoop(bool bLoop); - /****************************************************************************\ - * - * Function: void setVolume(int dwVolume); - * - * Description: Set SFX Volume - * - * Input: int dwVolume Volume to set (0-63) - * - \****************************************************************************/ + /** + * Change the volume of Sfx + * + * @param dwVolume Volume to be set (0-63) + * + */ void setVolume(int dwVolume); - /****************************************************************************\ - * - * Function: void getVolume(int * lpdwVolume); - * - * Description: Get SFX volume - * - * Input: int * lpdwVolume Will contain the current volume - * - \****************************************************************************/ + /** + * Gets the Sfx volume + * + * @param lpdwVolume Will contain the current Sfx volume + * + */ void getVolume(int *lpdwVolume); /** - * Returns true if the sound has finished playing + * Returns true if the underlying sound has ended */ bool endOfBuffer() const; }; class FPStream { - - /****************************************************************************\ - * Attributes - \****************************************************************************/ - private: + // HWND hwnd; + // LPDIRECTSOUND lpDS; + // LPDIRECTSOUNDBUFFER lpDSBuffer; // DirectSound circular buffer + // LPDIRECTSOUNDNOTIFY lpDSNotify; // Notify hotspots in the buffer - /* - HWND hwnd; - LPDIRECTSOUND lpDS; - LPDIRECTSOUNDBUFFER lpDSBuffer; // DirectSound circular buffer - LPDIRECTSOUNDNOTIFY lpDSNotify; // Notify hotspots in the buffer - */ byte *_lpTempBuffer; // Temporary buffer use for decompression uint32 _dwBufferSize; // Buffer size (bytes) @@ -373,7 +273,8 @@ private: bool _bPaused; int _lastVolume; FPStream *_syncToPlay; -// DSBPOSITIONNOTIFY dspnHot[3]; + + // DSBPOSITIONNOTIFY dspnHot[3]; bool createBuffer(int nBufSize); @@ -381,155 +282,118 @@ public: bool _bIsPlaying; // True if the stream is playing private: - + /** + * Thread playing the stream + * + */ static void playThread(FPStream *This); - /****************************************************************************\ - * Methods - \****************************************************************************/ - public: - /****************************************************************************\ - * - * Function: FPStream(bool bSoundOn); - * - * Description: Default contractor. *DO NOT* declare the object directly: use - * FPSound::CreateStream() indtead - * - \****************************************************************************/ + /** + * Default constructor. + * + * @remarks Do *NOT* declare an object directly, but rather + * create it using FPSound::CreateStream() + */ FPStream(bool bSoundOn); - /****************************************************************************\ - * - * Function: ~FPStream(); - * - * Description: Destructor by default. Stops the playing stream (if any) and - * frees the memory used by them - * - \****************************************************************************/ + /** + * Default destructor. + * + * @remarks It calls CloseFile() if needed. + */ ~FPStream(); - /****************************************************************************\ - * - * Function: release(); - * - * Description: Releases memory used by object. Must be used when the object - * is no longer used. *ONLY*for objects created by - * FPSound::CreateStream(). - * - * Note: Object pointers are no longer valid after this call. - * - \****************************************************************************/ + /** + * Releases the memory object. + * + * @remarks Must be called when the object is no longer used + * and **ONLY** if the object was created by + * FPSound::CreateStream(). + * Object pointers are no longer valid after this call. + */ void release(); - /****************************************************************************\ - * - * Function: bool loadFile(char *lpszFileName, uint32 dwCodec=FPCODEC_RAW); - * - * Description: Open a file for a stream. - * - * Input: char *lpszFile Filename to be opened - * uint32 dwCodec CODEC to be used to decompress - * sound samples - * - * Return: True if everything is OK, False otherwise - * - \****************************************************************************/ + /** + * Opens a file stream + * + * @param lpszFile Filename to be opened + * @param dwCodec CODEC to be used to uncompress samples + * + * @returns True is everything is OK, False otherwise + */ bool loadFile(const char *lpszFileName, uint32 dwCodec = FPCODEC_RAW, int nSync = 2000); - /****************************************************************************\ - * - * Function: unloadFile(); - * - * Description: Close a file stream (if opened). This function must be - * called to free the memory used by the stream - * - * Return: Just to be sure, the destructor of this class calls - * UnloadFile() if it has not been mentioned explicitly - * - \****************************************************************************/ + /** + * Closes a file stream (opened or not). + * + * @returns For safety, the destructor calls unloadFile() if it has not + * been mentioned explicitly. + * + * @remarks It is necessary to call this function to free the + * memory used by the stream. + */ bool unloadFile(); - /****************************************************************************\ - * - * Function: bool play(); - * - * Description: Play the loaded stream. - * - * Return: True if everything is OK, False otherwise - * - \****************************************************************************/ + /** + * Play the stream. + * + * @returns True is everything is OK, False otherwise + */ bool play(); void playFast(void); void prefetch(void); - /****************************************************************************\ - * - * Function: bool stop(); - * - * Description: Stops the play of the stream. - * - * Return: True if everything is OK, False otherwise - * - \****************************************************************************/ + /** + * Closes the stream. + * + * @returns True is everything is OK, False otherwise + */ bool stop(bool bSync = false); void waitForSync(FPStream *toplay); - /****************************************************************************\ - * - * Function: void pause(bool bPause); - * - * Description: Pause sound effect - * - \****************************************************************************/ + /** + * Pause sound effect + * + * @param bPause True enables pause, False disables it + */ void pause(bool bPause); - /****************************************************************************\ - * - * Function: bool setLoop(bool bLoop); - * - * Description: Enable of disable stream loop - * - * Input: bool bLoop True to enable loop, false otherwise - * - * Note: The loop must be activated BEFORE you play back the stream. - * Any changes made during play will not have 'effect until - * the stream is not stopped, and then comes back into play. - * - \****************************************************************************/ + /** + * Unables or disables stream loop. + * + * @param bLoop True enable loop, False disables it + * + * @remarks The loop must be activated BEFORE the stream starts + * playing. Any changes made during the play will have no + * effect until the stream is stopped then played again. + */ void setLoop(bool bLoop); - /****************************************************************************\ - * - * Function: void setVolume(int dwVolume); - * - * Description: Change stream colume - * - * Input: int dwVolume Volume to be set (0-63) - * - \****************************************************************************/ + /** + * Change the volume of the stream + * + * @param dwVolume Volume to be set (0-63) + */ void setVolume(int dwVolume); - /****************************************************************************\ - * - * Function: void getVolume(LPINT lpdwVolume); - * - * Description: Get stream volume - * - * Input: LPINT lpdwVolume Will contain the current stream volume - * - \****************************************************************************/ + /** + * Gets the vgolume of the stream + * + * @param lpdwVolume Variable that will contain the current volume + * + */ void getVolume(int *lpdwVolume); }; -- cgit v1.2.3 From b36b66630086044c54f745acfb64f91d90713045 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 17 Jun 2012 18:36:23 +0200 Subject: TONY: American-ification of English used --- engines/tony/custom.cpp | 12 ++++++------ engines/tony/font.cpp | 16 ++++++++-------- engines/tony/font.h | 2 +- engines/tony/gfxcore.cpp | 4 ++-- engines/tony/gfxcore.h | 12 ++++++------ engines/tony/gfxengine.cpp | 10 +++++----- engines/tony/gfxengine.h | 2 +- engines/tony/inventory.cpp | 2 +- engines/tony/loc.cpp | 10 +++++----- engines/tony/loc.h | 2 +- engines/tony/mpal/loadmpc.cpp | 2 +- engines/tony/mpal/mpal.cpp | 4 ++-- engines/tony/tony.cpp | 14 +++++++------- engines/tony/tonychar.h | 2 +- engines/tony/utils.h | 2 +- engines/tony/window.cpp | 2 +- 16 files changed, 49 insertions(+), 49 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 6e057cf031..fd5d17470b 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -308,7 +308,7 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX // Alignment _ctx->text.setAlignType(RMText::HCENTER, RMText::VBOTTOM); - // Colour + // Color _ctx->text.setColor(0, 255, 0); // Writes the text @@ -427,7 +427,7 @@ DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgStart)(CORO_PARAM, uint32 nMsg, uint32 // Forces the text to disappear in time _ctx->text.forceTime(); - // Colour + // Color _ctx->text.setColor(255, 255, 255); // Write the text @@ -1511,7 +1511,7 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess // Alignment _ctx->text->setAlignType(RMText::HCENTER, RMText::VBOTTOM); - // Colour + // Color _ctx->text->setColor(GLOBALS._character[nChar]._r, GLOBALS._character[nChar]._g, GLOBALS._character[nChar]._b); // Write the text @@ -1690,7 +1690,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes _ctx->parm = (GLOBALS._mCharacter[nChar]._curGroup * 10) + _vm->_randomSource.getRandomNumber( GLOBALS._mCharacter[nChar]._numTalks[GLOBALS._mCharacter[nChar]._curGroup] - 1) + 1; - // Try to run the custom function to initialise the speech + // Try to run the custom function to initialize the speech if (GLOBALS._mCharacter[nChar]._item) { _ctx->h = mpalQueryDoAction(30, GLOBALS._mCharacter[nChar]._item->mpalCode(), _ctx->parm); if (_ctx->h != CORO_INVALID_PID_VALUE) { @@ -1724,7 +1724,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes // Alignment _ctx->text->setAlignType(RMText::HCENTER, RMText::VBOTTOM); - // Colour + // Color _ctx->text->setColor(GLOBALS._mCharacter[nChar]._r, GLOBALS._mCharacter[nChar]._g, GLOBALS._mCharacter[nChar]._b); // Write the text @@ -1874,7 +1874,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg if (GLOBALS._mCharacter[nPers]._numTexts != 0 && GLOBALS._mCharacter[nPers]._bInTexts) { GLOBALS._mCharacter[nPers]._numTexts--; } else { - // Try to run the custom function to initialise the speech + // Try to run the custom function to initialize the speech _ctx->h = mpalQueryDoAction(30, GLOBALS._mCharacter[nPers]._item->mpalCode(), _ctx->parm); if (_ctx->h != CORO_INVALID_PID_VALUE) CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->h, CORO_INFINITE); diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index af6f5d687c..874d3d490b 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -67,9 +67,9 @@ void DumpFontBMP(const char *filename, const byte *buf, int nChars, int charX, i void RMFont::load(const byte *buf, int nChars, int dimx, int dimy, uint32 palResID) { _letter = new RMGfxSourceBuffer8RLEByte[nChars]; - // Initialise the fonts + // Initialize the fonts for (int i = 0; i < nChars; i++) { - // Initialise the buffer with the letters + // Initialize the buffer with the letters _letter[i].init(buf + i * (dimx * dimy + 8) + 8, dimx, dimy); _letter[i].loadPaletteWA(palResID); } @@ -172,7 +172,7 @@ void RMFontColor::setBaseColor(byte r1, byte g1, byte b1) { int i; byte pal[768 * 3]; - // Check if we are already on the right colour + // Check if we are already on the right color if (_fontR == r1 && _fontG == g1 && _fontB == b1) return; @@ -219,7 +219,7 @@ void RMFontParla::init(void) { load(RES_F_PARL, nchars, 20, 20); - // Initialise the f**king table + // Initialize the f**king table _lDefault = 13; _hDefault = 18; Common::fill(&_l2Table[0][0], &_l2Table[0][0] + (256 * 256), '\0'); @@ -1456,7 +1456,7 @@ void RMFontObj::init(void) { load(RES_F_OBJ, nchars, 25, 30); - // Initialise the f**king table + // Initialize the f**king table _lDefault = 26; _hDefault = 30; Common::fill(&_l2Table[0][0], &_l2Table[0][0] + (256 * 256), '\0'); @@ -1767,7 +1767,7 @@ void RMText::initStatics() { } RMText::RMText() { - // Default colour: white + // Default color: white _textR = _textG = _textB = 255; // Default length @@ -1804,7 +1804,7 @@ void RMText::removeThis(CORO_PARAM, bool &result) { void RMText::writeText(const RMString &text, int nFont, int *time) { - // Initialises the font (only once) + // Initializes the font (only once) if (_fonts[0] == NULL) { _fonts[0] = new RMFontParla; _fonts[0]->init(); @@ -1830,7 +1830,7 @@ void RMText::writeText(const RMString &text, RMFontColor *font, int *time) { char *string; int numlines; - // Set the base colour + // Set the base color font->setBaseColor(_textR, _textG, _textB); // Destroy the buffer before starting diff --git a/engines/tony/font.h b/engines/tony/font.h index f24223d551..1da1e063f7 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -224,7 +224,7 @@ public: // Overloading of the Draw to center the text, if necessary virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - // Set the base colour + // Set the base color void setColor(byte r, byte g, byte b) { _textR = r; _textG = g; diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 2f38f5d05d..e973fe9f6b 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -204,7 +204,7 @@ bool RMGfxSourceBuffer::clip2D(int &x1, int &y1, int &u, int &v, int &width, int /** - * Initialises a surface by resource Id + * Initializes a surface by resource Id * * @param resID Resource ID * @param dimx Buffer X dimension @@ -1870,7 +1870,7 @@ void RMGfxSourceBuffer16::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimi } void RMGfxSourceBuffer16::prepareImage(void) { - // Colour space conversion if necessary! + // Color space conversion if necessary! int i; uint16 *buf = (uint16 *)_buf; diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index e221753a47..bec33183c6 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -272,7 +272,7 @@ public: /** - * Task that draws a coloured box + * Task that draws a colored box */ class RMGfxBox : public RMGfxTaskSetPrior { protected: @@ -312,7 +312,7 @@ public: /** - * 16-bit colour source + * 16-bit color source */ class RMGfxSourceBuffer16 : public RMGfxSourceBuffer { protected: @@ -358,7 +358,7 @@ public: /** - * Buffer source with a 256 colour palette + * Buffer source with a 256 color palette */ class RMGfxSourceBuffer8 : public RMGfxSourceBufferPal { protected: @@ -378,7 +378,7 @@ public: /** - * Buffer source with a 256 colour palette, and alpha blending + * Buffer source with a 256 color palette, and alpha blending */ class RMGfxSourceBuffer8AB : public RMGfxSourceBuffer8 { protected: @@ -391,7 +391,7 @@ public: /** - * Buffer source with a 256 colour palette, RLE compressed + * Buffer source with a 256 color palette, RLE compressed */ class RMGfxSourceBuffer8RLE : public virtual RMGfxSourceBuffer8 { @@ -528,7 +528,7 @@ public: /** - * Source buffer with 16 colours + * Source buffer with 16 colors */ class RMGfxSourceBuffer4 : public RMGfxSourceBufferPal { public: diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 9dab3eeb52..bb48be11c4 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -497,21 +497,21 @@ void RMGfxEngine::init() { // Create the freeze event _csMainLoop = g_system->createMutex(); - // Initialise the IRQ function for items for MPAL + // Initialize the IRQ function for items for MPAL GLOBALS._gfxEngine = this; mpalInstallItemIrq(itemIrq); - // Initialise the input + // Initialize the input _input.init(); - // Initialise the mouse pointer + // Initialize the mouse pointer _point.init(); - // Initialise Tony + // Initialize Tony _tony.init(); _tony.linkToBoxes(&_vm->_theBoxes); - // Initialise the inventory and the interface + // Initialize the inventory and the interface _inv.init(); _inter.init(); diff --git a/engines/tony/gfxengine.h b/engines/tony/gfxengine.h index 18c13d8d3d..9cc586d25d 100644 --- a/engines/tony/gfxengine.h +++ b/engines/tony/gfxengine.h @@ -86,7 +86,7 @@ public: // Draw the next frame void doFrame(CORO_PARAM, bool bDrawLocation); - // Initialises the graphics engine + // Initializes the graphics engine void init(); // Closes the graphics engine diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index 4d824bb10a..7b111f8f58 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -99,7 +99,7 @@ void RMInventory::init(void) { assert(res.isValid()); - // Initialise the MPAL inventory item by reading it in. + // Initialize the MPAL inventory item by reading it in. _items[i]._icon.setInitCurPattern(false); ds.openBuffer(res); ds >> _items[i]._icon; diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index d36c004baf..d92b28845b 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -614,7 +614,7 @@ void RMItem::readFromStream(RMDataStream &ds, bool bLOX) { _patterns[i].readFromStream(ds, false); } - // Initialise the current pattern + // Initialize the current pattern if (_bInitCurPattern) setPattern(mpalQueryItemPattern(_mpalCode)); @@ -2051,11 +2051,11 @@ bool RMLocation::load(RMDataStream &ds) { ds >> dimx >> dimy; _curScroll.set(0, 0); - // Read the colour mode + // Read the color mode ds >> cm; _cmode = (RMColorMode)cm; - // Initialise the source buffer and read the location + // Initialize the source buffer and read the location switch (_cmode) { case CM_256: _buf = new RMGfxSourceBuffer8; @@ -2070,7 +2070,7 @@ bool RMLocation::load(RMDataStream &ds) { break; }; - // Initialise the surface, loading the palette if necessary + // Initialize the surface, loading the palette if necessary _buf->init(ds, dimx, dimy, true); // Check the size of the location @@ -2117,7 +2117,7 @@ bool RMLocation::loadLOX(RMDataStream &ds) { _cmode = CM_65K; _buf = new RMGfxSourceBuffer16; - // Initialise the surface, loading in the palette if necessary + // Initialize the surface, loading in the palette if necessary _buf->init(ds, dimx, dimy, true); // Number of items diff --git a/engines/tony/loc.h b/engines/tony/loc.h index ac0bb1d69a..b863a3af1b 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -42,7 +42,7 @@ namespace Tony { \****************************************************************************/ /** - * Valid colour modes + * Valid color modes */ typedef enum { CM_256, diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index b589827a5a..1ec921dbd4 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -334,7 +334,7 @@ static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { * data of the item. * @returns Pointer to the buffer after the item, or NULL on failure. * @remarks It's necessary that the structure that is passed has been - * completely initialised to 0 beforehand. + * completely initialized to 0 beforehand. */ static const byte *parseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { byte len; diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 07042ec077..bb3df1662f 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -838,7 +838,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { CORO_BEGIN_CODE(_ctx); - /* Initialise data pointers */ + /* Initialize data pointers */ _ctx->MyActions = NULL; _ctx->MyThreads = NULL; @@ -1404,7 +1404,7 @@ bool doSelection(uint32 i, uint32 dwData) { //@{ /** - * Initialises the MPAL library and opens the .MPC file, which will be used for all queries. + * Initializes the MPAL library and opens the .MPC file, which will be used for all queries. * * @param lpszMpcFileName Name of the MPC file * @param lpszMprFileName Name of the MPR file diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 654a3f8222..c2f3cc4c89 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -107,7 +107,7 @@ Common::Error TonyEngine::run() { } /** - * Initialise the game + * Initialize the game */ Common::ErrorCode TonyEngine::init() { if (isCompressed()) { @@ -135,10 +135,10 @@ Common::ErrorCode TonyEngine::init() { // Reset the scheduler CoroScheduler.reset(); - // Initialise the graphics window + // Initialize the graphics window _window.init(); - // Initialise the function list + // Initialize the function list Common::fill(_funcList, _funcList + 300, (LPCUSTOMFUNCTION)NULL); initCustomFunctionMap(); @@ -151,17 +151,17 @@ Common::ErrorCode TonyEngine::init() { if (!mpalInit("ROASTED.MPC", "ROASTED.MPR", _funcList, _funcListStrings)) return Common::kUnknownError; - // Initialise the update resources + // Initialize the update resources _resUpdate.init("ROASTED.MPU"); - // Initialise the music + // Initialize the music initMusic(); - // Initialise the voices database + // Initialize the voices database if (!openVoiceDatabase()) return Common::kReadingFailed; - // Initialise the boxes + // Initialize the boxes _theBoxes.init(); // Link to the custom graphics engine diff --git a/engines/tony/tonychar.h b/engines/tony/tonychar.h index 203d391fbe..507ff28f6b 100644 --- a/engines/tony/tonychar.h +++ b/engines/tony/tonychar.h @@ -362,7 +362,7 @@ public: static void initStatics(); RMTony(); - // Initialise Tony + // Initialize Tony void init(void); // Free all memory diff --git a/engines/tony/utils.h b/engines/tony/utils.h index 33e2db7d7e..4b0074f94c 100644 --- a/engines/tony/utils.h +++ b/engines/tony/utils.h @@ -293,7 +293,7 @@ public: bool operator==(const RMRect &rc); bool operator!=(const RMRect &rc); - // Normalise + // Normalize void normalizeRect(); // Point in rect diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index 3b60e480f6..dd7c70fe19 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -49,7 +49,7 @@ RMWindow::~RMWindow() { } /** - * Initialises the graphics window + * Initializes the graphics window */ void RMWindow::init() { Graphics::PixelFormat pixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0); -- cgit v1.2.3 From 31c0210f22bb4cc839abb9fa59539fd97d3a74f6 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 17 Jun 2012 18:38:34 +0200 Subject: TONY: Missed one word in previous commit (thanks clone2727) --- engines/tony/detection_tables.h | 2 +- engines/tony/mpal/mpaldll.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/tony/detection_tables.h b/engines/tony/detection_tables.h index bf4af08d2f..e37ba11dbf 100644 --- a/engines/tony/detection_tables.h +++ b/engines/tony/detection_tables.h @@ -29,7 +29,7 @@ static const TonyGameDescription gameDescriptions[] = { "tony", 0, { - // TODO: AdvancedDetector seems to have a problem where it thinks data1.cab is unrecognised. + // TODO: AdvancedDetector seems to have a problem where it thinks data1.cab is unrecognized. // Is it perhaps because the Agos engine also has detection entries for data1.cab? {"data1.cab", 0, "ce82907242166bfb594d97bdb68f96d2", 4350}, /*{"roasted.mpr", 0, "06203dbbc85fdd1e6dc8fc211c1a6207", 135911071}, diff --git a/engines/tony/mpal/mpaldll.h b/engines/tony/mpal/mpaldll.h index 952a0957c5..fe1eb2b34a 100644 --- a/engines/tony/mpal/mpaldll.h +++ b/engines/tony/mpal/mpaldll.h @@ -114,7 +114,7 @@ typedef LPMPALLOCATION *LPLPMPALLOCATION; */ struct command { /* - * Types of commands that are recognised + * Types of commands that are recognized * * #1 -> Custom function call (ITEM, SCRIPT, DIALOG) * #2 -> Variable assignment (ITEM, SCRIPT, DIALOG) -- cgit v1.2.3 From a46b06a587cc0b5e5767b55ba0d56264a8078f0c Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 17 Jun 2012 19:39:58 +0200 Subject: TONY: Move functions comment to doxygen format --- engines/tony/font.cpp | 2 +- engines/tony/font.h | 6 +-- engines/tony/game.cpp | 8 +--- engines/tony/game.h | 58 ++++++++++++++++++++-------- engines/tony/gfxcore.h | 14 +++---- engines/tony/gfxengine.cpp | 2 - engines/tony/globals.h | 5 --- engines/tony/input.h | 32 ++++++++++++---- engines/tony/inventory.h | 96 ++++++++++++++++++++++++++++++++++------------ engines/tony/resid.h | 4 +- engines/tony/tony.cpp | 3 -- engines/tony/tony.h | 21 +++++++--- engines/tony/tonychar.cpp | 11 +----- engines/tony/tonychar.h | 84 ++++++++++++++++++++++++++++++---------- engines/tony/window.h | 24 +++++++++--- 15 files changed, 249 insertions(+), 121 deletions(-) (limited to 'engines') diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 874d3d490b..a16179d507 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -2380,7 +2380,7 @@ void RMDialogChoice::setNumChoices(int num) { _drawedStrings = new RMText[num]; _ptDrawStrings = new RMPoint[num]; - // Initialisation + // Initialization for (i = 0; i < _numChoices; i++) { _drawedStrings[i].setColor(0, 255, 0); _drawedStrings[i].setAlignType(RMText::HLEFTPAR, RMText::VTOP); diff --git a/engines/tony/font.h b/engines/tony/font.h index 1da1e063f7..1b10304b5a 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -89,7 +89,7 @@ public: RMFont(); virtual ~RMFont(); - // Initialisation and closing + // Initialization and closing virtual void init(void) = 0; virtual void close(void); @@ -366,11 +366,11 @@ public: void Unregister(void); public: - // Initialisation + // Initialization RMDialogChoice(); virtual ~RMDialogChoice(); - // Initialisation and closure + // Initialization and closure void init(void); void close(void); diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 7b2834a8fa..493887cfa9 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -316,8 +316,6 @@ void RMOptionSlide::addToList(RMGfxTargetBuffer &bigBuf) { bigBuf.addPrim(new RMGfxPrimitive(this)); } - - /****************************************************************************\ * RMOptionScreen Methods \****************************************************************************/ @@ -379,7 +377,6 @@ RMOptionScreen::RMOptionScreen(void) { _nLastState = MENUGAME; } - RMOptionScreen::~RMOptionScreen(void) { closeState(); } @@ -567,7 +564,6 @@ void RMOptionScreen::refreshThumbnails(void) { } } - void RMOptionScreen::initState(CORO_PARAM) { CORO_BEGIN_CONTEXT; RMResRaw *raw; @@ -1097,7 +1093,6 @@ void RMOptionScreen::doFrame(CORO_PARAM, RMInput *input) { _ctx->bRefresh |= _buttonSave_ArrowLeft->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); if (_statePos < 90) _ctx->bRefresh |= _buttonSave_ArrowRight->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); - } } @@ -1195,7 +1190,7 @@ void RMOptionScreen::doFrame(CORO_PARAM, RMInput *input) { if (_buttonSave_States[_ctx->i]->isActive()) { // There by saving or loading!!! if (_nState == MENULOAD && _curThumb[_ctx->i] != NULL) { - // Caricamento + // Loading CORO_INVOKE_1(_vm->loadState, _statePos + _ctx->i); close(); } else if (_nState == MENUSAVE && (_statePos != 0 || _ctx->i != 0)) { @@ -1468,7 +1463,6 @@ bool RMOptionScreen::loadThumbnailFromSaveState(int nState, byte *lpDestBuf, RMS return true; } - /****************************************************************************\ * RMPointer Methods \****************************************************************************/ diff --git a/engines/tony/game.h b/engines/tony/game.h index bd15b962e6..64f4fb8e30 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -81,32 +81,48 @@ public: }; public: - // Constructor & destructor + /** + * Constructor & destructor + */ RMPointer(); virtual ~RMPointer(); - // Initialisation + /** + * Initialization + */ void init(void); - // Deinitialisation + /** + * Deinitialization + */ void close(void); - // Process a frame + /** + * Process a frame + */ void doFrame(RMGfxTargetBuffer *bigBuf); - // Overloading of priorities + /** + * Overloading of priorities + */ int priority(); - // draw method + /** + * draw method + */ void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - // Sets a new action as current + /** + * Sets a new action as current + */ void setAction(RMTonyAction action) { _nCurPointer = action; updateCursor(); } - // Sets a new pointer + /** + * Sets a new pointer + */ void setSpecialPointer(PointerType ptr) { _nCurSpecialPointer = ptr; if (_nCurSpecialPointer && _nCurSpecialPointer != PTR_CUSTOM) @@ -118,19 +134,27 @@ public: return (PointerType)_nCurSpecialPointer; } - // Set the new custom pointer + /** + * Set the new custom pointer + */ void setCustomPointer(RMGfxSourceBuffer8 *ptr) { _nCurCustomPointer = ptr; updateCursor(); } - // Return the current action to be applied according to the pointer + /** + * Return the current action to be applied according to the pointer + */ int curAction(void); - /** Show the cursor */ + /** + * Show the cursor + */ void showCursor(); - /** Hide the cursor */ + /** + * Hide the cursor + */ void hideCursor(); }; @@ -280,15 +304,19 @@ public: virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); virtual void removeThis(CORO_PARAM, bool &result); - // Polling for the option screen + /** + * Polling for the option screen + */ void doFrame(CORO_PARAM, RMInput *m_input); - // Retrieves a savegame's thumbnail, description, and difficulty level + /** + * Retrieves a savegame's thumbnail, description, and difficulty level + */ static bool loadThumbnailFromSaveState(int numState, byte *lpDestBuf, RMString &name, byte &diff); protected: - // Initialisation and state change + // Initialization and state change void initState(CORO_PARAM); void closeState(void); void changeState(CORO_PARAM, OptionScreenState newState); diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index bec33183c6..3b8384f614 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -324,7 +324,7 @@ public: RMGfxSourceBuffer16(int dimx, int dimy, bool bUseDDraw = false); virtual ~RMGfxSourceBuffer16(); - // Initialisation + // Initialization void create(int dimx, int dimy, bool bUseDDraw = false); int getBpp(); @@ -369,7 +369,7 @@ public: RMGfxSourceBuffer8(int dimx, int dimy, bool bUseDDraw = false); virtual ~RMGfxSourceBuffer8(); - // Initialisation + // Initialization void create(int dimx, int dimy, bool bUseDDraw = false); int getBpp(); @@ -414,7 +414,7 @@ protected: void compressRLE(void); protected: - // Overriding initialisation methods + // Overriding initialization methods virtual void prepareImage(void); virtual void preparePalette(void); @@ -422,7 +422,7 @@ public: RMGfxSourceBuffer8RLE(); virtual ~RMGfxSourceBuffer8RLE(); - // Overload of the initialisation method + // Overload of the initialization method virtual void init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette = false); virtual int init(const byte *buf, int dimx, int dimy, bool bLoadPalette = false); @@ -505,7 +505,7 @@ protected: public: virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - // Overloaded initialisation methods + // Overloaded initialization methods virtual void init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette = false); virtual int init(const byte *buf, int dimx, int dimy, bool bLoadPalette = false); @@ -519,7 +519,7 @@ protected: public: virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - // Overloaded initialisation methods + // Overloaded initialization methods virtual void init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette = false); virtual int init(byte *buf, int dimx, int dimy, bool bLoadPalette = false); @@ -535,7 +535,7 @@ public: RMGfxSourceBuffer4(); RMGfxSourceBuffer4(int dimx, int dimy, bool bUseDDraw = false); - // Initialisation + // Initialization void create(int dimx, int dimy, bool bUseDDraw = false); int getBpp(); diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index bb48be11c4..08eff0a991 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -353,7 +353,6 @@ SKIPCLICKSINISTRO: CORO_END_CODE; } - void RMGfxEngine::initCustomDll(void) { setupGlobalVars(&_tony, &_point, &_vm->_theBoxes, &_loc, &_inv, &_input); } @@ -378,7 +377,6 @@ void RMGfxEngine::itemIrq(uint32 dwItem, int nPattern, int nStatus) { } } - void RMGfxEngine::initForNewLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { if (start._x == -1 || start._y == -1) { start._x = ptTonyStart._x - RM_SX / 2; diff --git a/engines/tony/globals.h b/engines/tony/globals.h index cf231018a6..d3f5eb0849 100644 --- a/engines/tony/globals.h +++ b/engines/tony/globals.h @@ -43,10 +43,8 @@ namespace Tony { #define TAPPETI_MARE 6 #define TAPPETI_MAREMETA 7 - #define MAX_PATH 255 - struct CharacterStruct { uint32 _code; RMItem *_item; @@ -254,7 +252,6 @@ public: /** * @defgroup MPAL variables */ - //@{ uint32 _mpalError; LPITEMIRQFUNCTION _lpiifCustom; LPLPCUSTOMFUNCTION _lplpFunctions; @@ -292,8 +289,6 @@ public: uint32 _nExecutingDialog; uint32 _nExecutingChoice; uint32 _nSelectedChoice; - - //@} }; } // End of namespace Tony diff --git a/engines/tony/input.h b/engines/tony/input.h index fd194d0fc5..81fa3433c4 100644 --- a/engines/tony/input.h +++ b/engines/tony/input.h @@ -47,32 +47,46 @@ private: // Keyboard related fields bool _keyDown[350]; private: - // Deinitialize DirectInput + /** + * Deinitialize DirectInput + */ void DIClose(void); public: RMInput(); ~RMInput(); - // Class initialisation + /** + * Class initialization + */ void init(/*uint32 hInst*/); - // Closes the class + /** + * Closes the class + */ void close(void); - // Polling (must be performed once per frame) + /** + * Polling (must be performed once per frame) + */ void poll(void); - // Reading of the mouse + /** + * Reading of the mouse + */ RMPoint mousePos() { return _mousePos; } - // Current status of the mouse buttons + /** + * Current status of the mouse buttons + */ bool mouseLeft(); bool mouseRight(); - // Events of mouse clicks + /** + * Events of mouse clicks + */ bool mouseLeftClicked() { return _leftClickMouse; } @@ -92,7 +106,9 @@ public: return _leftReleaseMouse && _rightReleaseMouse; } - // Returns true if the given key is pressed + /** + * Returns true if the given key is pressed + */ bool getAsyncKeyState(Common::KeyCode kc); }; diff --git a/engines/tony/inventory.h b/engines/tony/inventory.h index e010a09dd5..dfbde5bad0 100644 --- a/engines/tony/inventory.h +++ b/engines/tony/inventory.h @@ -79,48 +79,72 @@ protected: OSystem::MutexRef _csModifyInterface; protected: - // Prepare the image inventory. It should be recalled whenever the inventory changes + /** + * Prepare the image inventory. It should be recalled whenever the inventory changes + */ void prepare(void); - // Check if the mouse Y position is conrrect, even under the inventory portion of the screen + /** + * Check if the mouse Y position is conrrect, even under the inventory portion of the screen + */ bool checkPointInside(const RMPoint &pt); public: RMInventory(); virtual ~RMInventory(); - // Prepare a frame + /** + * Prepare a frame + */ void doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpos, bool bCanOpen); - // Initialisation and closing + /** + * Initialization and closing + */ void init(void); void close(void); void reset(void); - // Overload test for removal from OT list + /** + * Overload test for removal from OT list + */ virtual void removeThis(CORO_PARAM, bool &result); - // Overload the drawing of the inventory + /** + * Overload the drawing of the inventory + */ virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - // Method for determining whether the inventory currently has the focus + /** + * Method for determining whether the inventory currently has the focus + */ bool haveFocus(const RMPoint &mpos); - // Method for determining if the mini interface is active + /** + * Method for determining if the mini interface is active + */ bool miniActive(void); - // Handle the left mouse click (only when the inventory has the focus) + /** + * Handle the left mouse click (only when the inventory has the focus) + */ bool leftClick(const RMPoint &mpos, int &nCombineObj); - // Handle the right mouse button (only when the inventory has the focus) + /** + * Handle the right mouse button (only when the inventory has the focus) + */ void rightClick(const RMPoint &mpos); bool rightRelease(const RMPoint &mpos, RMTonyAction &curAction); - // Warn that an item combine is over + /** + * Warn that an item combine is over + */ void endCombine(void); public: - // Add an item to the inventory + /** + * Add an item to the inventory + */ void addItem(int code); RMInventory &operator+=(RMItem *item) { addItem(item->mpalCode()); @@ -135,17 +159,25 @@ public: return *this; } - // Removes an item + /** + * Removes an item + */ void removeItem(int code); - // We are on an object? + /** + * We are on an object? + */ RMItem *whichItemIsIn(const RMPoint &mpt); bool itemInFocus(const RMPoint &mpt); - // Change the icon of an item + /** + * Change the icon of an item + */ void changeItemStatus(uint32 dwCode, uint32 dwStatus); - // Save methods + /** + * Save methods + */ int getSaveStateSize(void); void saveState(byte *state); int loadState(byte *state); @@ -165,35 +197,51 @@ private: int _lastHotZone; protected: - // Return which box a given point is in + /** + * Return which box a given point is in + */ int onWhichBox(RMPoint pt); public: RMInterface(); virtual ~RMInterface(); - // The usual DoFrame (poll the graphics engine) + /** + * The usual DoFrame (poll the graphics engine) + */ void doFrame(RMGfxTargetBuffer &bigBuf, RMPoint mousepos); - // TRUE if it is active (you can select items) + /** + * TRUE if it is active (you can select items) + */ bool active(); - // Initialisation + /** + * Initialization + */ void init(void); void close(void); - // Reset the interface + /** + * Reset the interface + */ void reset(void); - // Warns of mouse clicks and releases + /** + * Warns of mouse clicks and releases + */ void clicked(const RMPoint &mousepos); bool released(const RMPoint &mousepos, RMTonyAction &action); - // Enalbes or disables the fifth verb + /** + * Enables or disables the fifth verb + */ void setPerorate(bool bOn); bool getPerorate(void); - // Overloaded Draw + /** + * Overloaded Draw + */ virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); }; diff --git a/engines/tony/resid.h b/engines/tony/resid.h index 7f2dc7bb54..f4d2c9a4fa 100644 --- a/engines/tony/resid.h +++ b/engines/tony/resid.h @@ -26,9 +26,7 @@ * Copyright (c) 1997-2003 Nayma Software */ -/* - Da 10500 in poi ci sono gli .OGG per l'inventario e i ritagli -*/ +// From 10500 onwards there are .OGG for inventory and scrap #ifndef TONY_RESID_H #define TONY_RESID_H diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index c2f3cc4c89..79694b2601 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -422,13 +422,11 @@ void TonyEngine::autoSave(CORO_PARAM) { CORO_END_CODE; } - void TonyEngine::saveState(int n, const char *name) { Common::String buf = getSaveStateFileName(n); _theEngine.saveState(buf.c_str(), (byte *)_curThumbnail, name); } - void TonyEngine::loadState(CORO_PARAM, int n) { CORO_BEGIN_CONTEXT; Common::String buf; @@ -600,7 +598,6 @@ void TonyEngine::unfreezeTime(void) { _bTimeFreezed = false; } - /** * Returns the millisecond timer */ diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 709465ca89..817147805a 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -118,7 +118,6 @@ public: FPStream *_stream[6]; FPSfx *_sfx[MAX_SFX_CHANNELS]; FPSfx *_utilSfx[MAX_SFX_CHANNELS]; -// RMFont *_fonts[2]; bool _bPaused; bool _bDrawLocation; int _startTime; @@ -154,7 +153,9 @@ public: Common::Error loadGameState(int slot); Common::Error saveGameState(int slot, const Common::String &desc); - // Warn when are being controlled by the GDI + /** + * Warn when are being controlled by the GDI + */ void GDIControl(bool bCon); void play(); @@ -173,7 +174,9 @@ public: _bDrawLocation = false; } - // Reads the time + /** + * Reads the time + */ uint32 getTime(void); void freezeTime(void); void unfreezeTime(void); @@ -197,19 +200,25 @@ public: void preloadUtilSFX(int nSfx, const char *fn); void unloadAllUtilSFX(void); - // Stop all the audio + /** + * Stop all the audio + */ void pauseSound(bool bPause); void setMusicVolume(int nChannel, int volume); int getMusicVolume(int nChannel); - // Handle saving + /** + * Handle saving + */ void autoSave(CORO_PARAM); void saveState(int n, const char *name); void loadState(CORO_PARAM, int n); static Common::String getSaveStateFileName(int n); - // Get a thumbnail + /** + * Get a thumbnail + */ void grabThumbnail(void); uint16 *getThumbnail(void) { return _curThumbnail; diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index 17f046fb92..700b69a643 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -34,10 +34,6 @@ namespace Tony { -/****************************************************************************\ -* Metodi di RMTony -\****************************************************************************/ - bool RMTony::_bAction = false; void RMTony::initStatics() { @@ -124,7 +120,7 @@ void RMTony::init(void) { void RMTony::close(void) { - // Disalloca @@@ Deallocation of missing item + // Deallocation of missing item // _shadow.destroy(); } @@ -479,7 +475,6 @@ void RMTony::put(int nWhere, int nPart) { if (nPart == 0) { switch (getCurPattern()) { case PAT_STANDDOWN: - //assert(0); break; case PAT_STANDUP: @@ -690,7 +685,6 @@ bool RMTony::startTalkCalculate(CharacterTalkType nTalkType, int &headStartPat, } break; - case TALK_SING: _nBodyOffset.set(-10, 25); headStartPat = PAT_HEAD_LEFT; @@ -744,7 +738,6 @@ bool RMTony::startTalkCalculate(CharacterTalkType nTalkType, int &headStartPat, } break; - case TALK_INDICATE: switch (_talkDirection) { case UP: @@ -1181,7 +1174,6 @@ bool RMTony::endTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa return false; } - bStatic = false; switch (_nTalkType) { case TALK_NORMAL: @@ -1759,7 +1751,6 @@ void RMTony::startStatic(CORO_PARAM, CharacterTalkType nTalk) { CORO_END_CODE; } - void RMTony::endStaticCalculate(CharacterTalkType nTalk, int &bodyEndPat, int &finalPat, int &headEndPat) { switch (_talkDirection) { case UP: diff --git a/engines/tony/tonychar.h b/engines/tony/tonychar.h index 507ff28f6b..70765abfd8 100644 --- a/engines/tony/tonychar.h +++ b/engines/tony/tonychar.h @@ -107,10 +107,14 @@ private: uint32 _hActionThread; protected: - // Overload of the allocation allocation of sprites + /** + * Overload of the allocation allocation of sprites + */ virtual RMGfxSourceBuffer *newItemSpriteBuffer(int dimx, int dimy, bool bPreRLE); - // Watch thread which waits for the end of an action + /** + * Watch thread which waits for the end of an action + */ static void waitEndOfAction(CORO_PARAM, const void *param); public: @@ -362,79 +366,115 @@ public: static void initStatics(); RMTony(); - // Initialize Tony + /** + * Initialize Tony + */ void init(void); - // Free all memory + /** + * Free all memory + */ void close(void); - // Tony makes a frame, updating the movement, etc. + /** + * Tony makes a frame, updating the movement, etc. + */ void doFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int curLoc); - // Draw method, which controls chararacter display + /** + * Draw method, which controls chararacter display + */ virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - // Show or hide + /** + * Show or hide + */ void show(void); void hide(bool bShowShadow = false); - // Move and make an action, if necessary + /** + * Move and make an action, if necessary + */ void moveAndDoAction(CORO_PARAM, RMPoint dst, RMItem *item, int nAction, int nActionParm = 0); - // Tony stops (on the right side with respect to any subject) + /** + * Tony stops (on the right side with respect to any subject) + */ virtual void stop(CORO_PARAM); void stopNoAction(CORO_PARAM); - // Set a pattern + /** + * Set a pattern + */ void setPattern(int npatt, bool bPlayP0 = false); - // Reads the current pattern + /** + * Reads the current pattern + */ int getCurPattern(); - // Waits until the end of a pattern + /** + * Waits until the end of a pattern + */ void waitForEndPattern(CORO_PARAM, uint32 hCustomSkip = CORO_INVALID_PID_VALUE) { RMCharacter::waitForEndPattern(coroParam, hCustomSkip); } - // Check if currently in an action + /** + * Check if currently in an action + */ bool inAction() { return (_bActionPending && _action != 0) | _bAction; } - // Check if there needs to be an update for scrolling movement + /** + * Check if there needs to be an update for scrolling movement + */ bool mustUpdateScrolling() { return ((!inAction()) || (isMoving())); } - // Returns Tony's position + /** + * Returns Tony's position + */ RMPoint position() { return _pos; } - // Set the scrolling position + /** + * Set the scrolling position + */ void setScrollPosition(const RMPoint &pt) { RMCharacter::setScrollPosition(pt); } - // Set the take animation + /** + * Set the take animation + */ void take(int nWhere, int nPart); void put(int nWhere, int nPart); - // Start or End Talk + /** + * Start or End Talk + */ bool startTalkCalculate(CharacterTalkType nTalkType, int &headStartPat, int &bodyStartPat, int &headLoopPat, int &bodyLoopPat); void startTalk(CORO_PARAM, CharacterTalkType nTalkType); bool endTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPat, int &finalPat, bool &bStatic); void endTalk(CORO_PARAM); - // Start or End Static + /** + * Start or End Static + */ void startStaticCalculate(CharacterTalkType nTalk, int &headPat, int &headLoopPat, int &bodyStartPat, int &bodyLoopPat); void startStatic(CORO_PARAM, CharacterTalkType nTalkType); void endStaticCalculate(CharacterTalkType nTalk, int &bodyEndPat, int &finalPat, int &headEndPat); void endStatic(CORO_PARAM, CharacterTalkType nTalkType); - // Tony disguises himself! + /** + * Tony disguises himself! + */ void setShepherdess(bool bIsPast) { _bShepherdess = bIsPast; } @@ -442,7 +482,9 @@ public: return _bShepherdess; } - // Perform an action + /** + * Perform an action + */ void executeAction(int nAction, int nActionItem, int nParm); void playSfx(int nSfx) { diff --git a/engines/tony/window.h b/engines/tony/window.h index 34f0c1cb51..876bbf6973 100644 --- a/engines/tony/window.h +++ b/engines/tony/window.h @@ -44,7 +44,9 @@ private: // Buffer used to convert to RGB static byte rgb[RM_SX *RM_SY * 3]; public: - // Take a screenshot + /** + * Take a screenshot + */ void grabScreenshot(byte *lpBuf, int dezoom = 1, uint16 *lpDestBuf = NULL); }; @@ -78,21 +80,31 @@ public: RMWindow(); ~RMWindow(); - // Initialisation + /** + * Initialization + */ void init(/*HINSTANCE hInst*/); void initDirectDraw(void); void close(void); - // Drawing + /** + * Drawing + */ void repaint(void); - // Switch between windowed and fullscreen + /** + * Switch between windowed and fullscreen + */ void switchFullscreen(bool bFull) {} - // Reads the next frame + /** + * Reads the next frame + */ void getNewFrame(byte *lpBuf, Common::Rect *rcBoundEllipse); - // Request a thumbnail be grabbed during the next frame + /** + * Request a thumbnail be grabbed during the next frame + */ void grabThumbnail(uint16 *buf); int getFps() const { -- cgit v1.2.3 From 6a7fa693ef0e68e08e45bc7b7c8397357deffa04 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 18 Jun 2012 07:58:19 +0200 Subject: TONY: Fix a typo in utils comments --- engines/tony/utils.cpp | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'engines') diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index b6af8736bd..6c36781f51 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -127,7 +127,7 @@ char &RMString::operator[](int nIndex) { /** * Copies a string * @param str String to copy - * @returns Refrence to our string + * @returns Reference to our string */ const RMString &RMString::operator=(const RMString &str) { // Set the new length @@ -154,7 +154,7 @@ const RMString &RMString::operator=(const RMString &str) { /** * Copies a char * string * @param str String to copy - * @returns Refrence to our string + * @returns Reference to our string */ const RMString &RMString::operator=(const char *str) { // If the source is empty, then destroy the current string buffer @@ -181,7 +181,7 @@ const RMString &RMString::operator=(const char *str) { /** * Forms a string from a passed character * @param ch Character to copy - * @returns Refrence to our string + * @returns Reference to our string */ const RMString &RMString::operator=(const int ch) { if (ch == '\0') { @@ -227,7 +227,7 @@ void RMString::connect(const char *str, int size) { /** * Concatenate a string * @param str String to concatenate - * @returns Refrence to our string + * @returns Reference to our string */ const RMString &RMString::operator+=(RMString &str) { connect(str, str.length()); @@ -237,7 +237,7 @@ const RMString &RMString::operator+=(RMString &str) { /** * Concatenate a string * @param str String to concatenate - * @returns Refrence to our string + * @returns Reference to our string */ const RMString &RMString::operator+=(const char *str) { connect(str, strlen(str)); @@ -247,7 +247,7 @@ const RMString &RMString::operator+=(const char *str) { /** * Concatenate a character * @param ch Character to concatenate - * @returns Refrence to our string + * @returns Reference to our string */ const RMString &RMString::operator+=(const int ch) { char str[2]; @@ -406,7 +406,6 @@ bool RMFileStreamSlow::openFile(Common::File &file) { return true; } - bool RMFileStreamSlow::openFile(const char *lpFN) { // Open file for reading Common::File f; @@ -419,7 +418,6 @@ bool RMFileStreamSlow::openFile(const char *lpFN) { return true; } - RMDataStream &RMFileStreamSlow::operator+=(int nBytes) { seek(nBytes); return *this; @@ -433,7 +431,6 @@ bool RMFileStreamSlow::isEOF() { return (pos() >= _length); } - int RMFileStreamSlow::seek(int nBytes, RMDSPos where) { switch (where) { case START: @@ -450,7 +447,6 @@ int RMFileStreamSlow::seek(int nBytes, RMDSPos where) { } } - bool RMFileStreamSlow::read(void *buf, int size) { uint32 dwRead; @@ -458,7 +454,6 @@ bool RMFileStreamSlow::read(void *buf, int size) { return ((int)dwRead == size); } - RMFileStreamSlow &operator>>(RMFileStreamSlow &df, char &var) { df.read(&var, 1); return df; @@ -497,7 +492,6 @@ RMFileStreamSlow &operator>>(RMFileStreamSlow &df, uint32 &var) { return df; } - /****************************************************************************\ * RMDataStream methods \****************************************************************************/ @@ -996,7 +990,6 @@ RMDataStream &operator>>(RMDataStream &ds, RMRect &rc) { return ds; } - /****************************************************************************\ * Resource Update \****************************************************************************/ -- cgit v1.2.3 From bb55045cc85e1c9b70bd7267de0b578e6662725b Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 18 Jun 2012 08:03:02 +0200 Subject: TONY: Rename two variables --- engines/tony/custom.cpp | 6 +++--- engines/tony/globals.cpp | 2 +- engines/tony/globals.h | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index fd5d17470b..e91d6873a4 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -408,8 +408,8 @@ DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgStart)(CORO_PARAM, uint32 nMsg, uint32 _ctx->msg = new RMMessage(nMsg); - GLOBALS.SFM_nLoc = GLOBALS._loc->TEMPGetNumLoc(); - GLOBALS.SFM_pt = GLOBALS._tony->position(); + GLOBALS._fullScreenMessageLoc = GLOBALS._loc->TEMPGetNumLoc(); + GLOBALS._fullScreenMessagePt = GLOBALS._tony->position(); if (GLOBALS._bSkipIdle) return; @@ -478,7 +478,7 @@ DECLARE_CUSTOM_FUNCTION(ClearScreen)(CORO_PARAM, uint32, uint32, uint32, uint32) DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgEnd)(CORO_PARAM, uint32 bNotEnableTony, uint32, uint32, uint32) { GLOBALS.Freeze(); - GLOBALS.LoadLocation(GLOBALS.SFM_nLoc, RMPoint(GLOBALS.SFM_pt._x, GLOBALS.SFM_pt._y), RMPoint(-1, -1)); + GLOBALS.LoadLocation(GLOBALS._fullScreenMessageLoc, RMPoint(GLOBALS._fullScreenMessagePt._x, GLOBALS._fullScreenMessagePt._y), RMPoint(-1, -1)); if (!bNotEnableTony) GLOBALS._tony->show(); GLOBALS.Unfreeze(); diff --git a/engines/tony/globals.cpp b/engines/tony/globals.cpp index 48b04007b4..893322942a 100644 --- a/engines/tony/globals.cpp +++ b/engines/tony/globals.cpp @@ -74,7 +74,7 @@ Globals::Globals() { _lastMusic = 0; _lastTappeto = 0; Common::fill(&_tappeti[0], &_tappeti[200], 0); - SFM_nLoc = 0; + _fullScreenMessageLoc = 0; // MPAL global variables _mpalError = 0; diff --git a/engines/tony/globals.h b/engines/tony/globals.h index d3f5eb0849..96a61ffd9c 100644 --- a/engines/tony/globals.h +++ b/engines/tony/globals.h @@ -246,8 +246,8 @@ public: int _lastMusic, _lastTappeto; int _tappeti[200]; - RMPoint SFM_pt; - int SFM_nLoc; + RMPoint _fullScreenMessagePt; + int _fullScreenMessageLoc; /** * @defgroup MPAL variables -- cgit v1.2.3 From e8a6f61f8815fcf36e7a43383695c74b8925993f Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 18 Jun 2012 08:24:33 +0200 Subject: TONY: Remove useless void in function declaration --- engines/tony/adv.h | 18 +++++----- engines/tony/custom.cpp | 4 +-- engines/tony/font.cpp | 33 +++++++++--------- engines/tony/font.h | 36 ++++++++++---------- engines/tony/game.cpp | 36 ++++++++++---------- engines/tony/game.h | 12 +++---- engines/tony/gfxcore.cpp | 44 +++++++++--------------- engines/tony/gfxcore.h | 34 +++++++++---------- engines/tony/gfxengine.cpp | 22 ++++++------ engines/tony/gfxengine.h | 18 +++++----- engines/tony/globals.h | 84 +++++++++++++++++++++++----------------------- engines/tony/input.cpp | 5 ++- engines/tony/input.h | 6 ++-- engines/tony/inventory.cpp | 28 ++++++---------- engines/tony/inventory.h | 22 ++++++------ engines/tony/loc.cpp | 31 +++++++---------- engines/tony/loc.h | 26 +++++++------- engines/tony/mpal/mpal.cpp | 56 ++++++++++--------------------- engines/tony/mpal/mpal.h | 25 +++----------- engines/tony/sound.cpp | 4 +-- engines/tony/sound.h | 4 +-- engines/tony/tony.cpp | 18 +++++----- engines/tony/tony.h | 22 ++++++------ engines/tony/tonychar.cpp | 8 ++--- engines/tony/tonychar.h | 8 ++--- engines/tony/utils.cpp | 8 ++--- engines/tony/utils.h | 10 +++--- engines/tony/window.cpp | 4 +-- engines/tony/window.h | 8 ++--- 29 files changed, 283 insertions(+), 351 deletions(-) (limited to 'engines') diff --git a/engines/tony/adv.h b/engines/tony/adv.h index b2d61a5da5..fe1dd32eae 100644 --- a/engines/tony/adv.h +++ b/engines/tony/adv.h @@ -67,19 +67,19 @@ enum RMTonyAction { uint32 mainLoadLocation(int nLoc, RMPoint pt, RMPoint start); void mainUnloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result); void mainLinkGraphicTask(RMGfxTask *task); -void mainFreeze(void); -void mainUnfreeze(void); +void mainFreeze(); +void mainUnfreeze(); void mainWaitFrame(CORO_PARAM); -void mainShowMouse(void); -void mainHideMouse(void); -void mainEnableInput(void); -void mainDisableInput(void); +void mainShowMouse(); +void mainHideMouse(); +void mainEnableInput(); +void mainDisableInput(); void mainPlayMusic(int nChannel, const char *filename, int nFX, bool bLoop, int nSync); void mainInitWipe(int type); -void mainCloseWipe(void); +void mainCloseWipe(); void mainWaitWipeEnd(CORO_PARAM); -void mainEnableGUI(void); -void mainDisableGUI(void); +void mainEnableGUI(); +void mainDisableGUI(); void mainSetPerorate(bool bPerorate); } // End of namespace Tony diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index e91d6873a4..016c84ab39 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -106,7 +106,7 @@ const char *jingleFileNames[] = { }; -void ReapplyChangedHotspot(void) { +void ReapplyChangedHotspot() { int i; for (i = 0; i < GLOBALS._curChangedHotspot; i++) GLOBALS._loc->getItemFromCode(GLOBALS._changedHotspot[i]._dwCode)->changeHotspot(RMPoint(GLOBALS._changedHotspot[i]._nX, GLOBALS._changedHotspot[i]._nY)); @@ -140,7 +140,7 @@ void LoadChangedHotspot(Common::InSaveFile *f) { * AddInventory -> theEngine.AddInventory() */ -void MCharResetCodes(void) { +void MCharResetCodes() { for (int i = 0; i < 10; i++) GLOBALS._mCharacter[i]._item = GLOBALS._loc->getItemFromCode(GLOBALS._mCharacter[i]._code); for (int i = 0; i < 10; i++) diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index a16179d507..c4a95d0493 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -89,7 +89,7 @@ void RMFont::load(uint32 resID, int nChars, int dimx, int dimy, uint32 palResID) load(res, nChars, dimx, dimy, palResID); } -void RMFont::unload(void) { +void RMFont::unload() { if (_letter != NULL) { delete[] _letter; _letter = NULL; @@ -130,7 +130,7 @@ void RMFont::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim2) CORO_END_CODE; } -void RMFont::close(void) { +void RMFont::close() { unload(); } @@ -200,12 +200,11 @@ void RMFontColor::setBaseColor(byte r1, byte g1, byte b1) { _letter[i].loadPaletteWA(pal); } - /***************************************************************************\ * RMFontParla Methods \****************************************************************************/ -void RMFontParla::init(void) { +void RMFontParla::init() { int i; // bernie: Number of characters in the font @@ -612,7 +611,7 @@ void RMFontParla::init(void) { * RMFontMacc Methods \****************************************************************************/ -void RMFontMacc::init(void) { +void RMFontMacc::init() { int i; // bernie: Number of characters in the font @@ -976,7 +975,7 @@ void RMFontMacc::init(void) { * RMFontCredits Methods \****************************************************************************/ -void RMFontCredits::init(void) { +void RMFontCredits::init() { int i; // bernie: Number of characters in the font @@ -1441,7 +1440,7 @@ void RMFontObj::setBothCase(int nChar, int nNext, signed char spiazz) { } -void RMFontObj::init(void) { +void RMFontObj::init() { int i; //bernie: Number of characters in the font (solo maiuscolo) @@ -2015,7 +2014,7 @@ RMTextDialog::~RMTextDialog() { CoroScheduler.closeEvent(_hEndDisplay); } -void RMTextDialog::show(void) { +void RMTextDialog::show() { _bShowed = true; } @@ -2042,15 +2041,15 @@ void RMTextDialog::setSkipStatus(bool bEnabled) { _bSkipStatus = bEnabled; } -void RMTextDialog::forceTime(void) { +void RMTextDialog::forceTime() { _bForceTime = true; } -void RMTextDialog::forceNoTime(void) { +void RMTextDialog::forceNoTime() { _bForceNoTime = true; } -void RMTextDialog::setNoTab(void) { +void RMTextDialog::setNoTab() { _bNoTab = true; } @@ -2058,7 +2057,7 @@ void RMTextDialog::setForcedTime(uint32 dwTime) { _time = dwTime; } -void RMTextDialog::setAlwaysDisplay(void) { +void RMTextDialog::setAlwaysDisplay() { _bAlwaysDisplay = true; } @@ -2128,7 +2127,7 @@ void RMTextDialog::removeThis(CORO_PARAM, bool &result) { CORO_END_CODE; } -void RMTextDialog::Unregister(void) { +void RMTextDialog::Unregister() { RMGfxTask::Unregister(); assert(_nInList == 0); CoroScheduler.setEvent(_hEndDisplay); @@ -2337,7 +2336,7 @@ RMDialogChoice::~RMDialogChoice() { CoroScheduler.closeEvent(_hUnreg); } -void RMDialogChoice::Unregister(void) { +void RMDialogChoice::Unregister() { RMGfxWoodyBuffer::Unregister(); assert(!_nInList); CoroScheduler.pulseEvent(_hUnreg); @@ -2345,7 +2344,7 @@ void RMDialogChoice::Unregister(void) { _bRemoveFromOT = false; } -void RMDialogChoice::init(void) { +void RMDialogChoice::init() { _numChoices = 0; _drawedStrings = NULL; _ptDrawStrings = NULL; @@ -2356,7 +2355,7 @@ void RMDialogChoice::init(void) { } -void RMDialogChoice::close(void) { +void RMDialogChoice::close() { if (_drawedStrings != NULL) { delete[] _drawedStrings; _drawedStrings = NULL; @@ -2581,7 +2580,7 @@ void RMDialogChoice::doFrame(CORO_PARAM, RMPoint ptMousePos) { CORO_END_CODE; } -int RMDialogChoice::getSelection(void) { +int RMDialogChoice::getSelection() { return _curSelection; } diff --git a/engines/tony/font.h b/engines/tony/font.h index 1b10304b5a..595cb726a6 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -73,7 +73,7 @@ protected: void load(const byte *buf, int nChars, int dimx, int dimy, uint32 palResID = RES_F_PAL); // Remove the font - void unload(void); + void unload(); protected: // Conversion form character to font index @@ -83,15 +83,15 @@ protected: virtual int letterLength(int nChar, int nNext = 0) = 0; public: - virtual int letterHeight(void) = 0; + virtual int letterHeight() = 0; public: RMFont(); virtual ~RMFont(); // Initialization and closing - virtual void init(void) = 0; - virtual void close(void); + virtual void init() = 0; + virtual void close(); // Drawing virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBug, RMGfxPrimitive *prim); @@ -143,7 +143,7 @@ public: class RMFontParla : public RMFontColor, public RMFontWithTables { public: - void init(void); + void init(); virtual ~RMFontParla() {} }; @@ -152,19 +152,19 @@ private: void setBothCase(int nChar, int nNext, signed char spiazz); public: - void init(void); + void init(); virtual ~RMFontObj() {} }; class RMFontMacc : public RMFontColor, public RMFontWithTables { public: - void init(void); + void init(); virtual ~RMFontMacc() {} }; class RMFontCredits : public RMFontColor, public RMFontWithTables { public: - void init(void); + void init(); virtual ~RMFontCredits() {} virtual void setBaseColor(byte r, byte g, byte b) {} }; @@ -263,7 +263,7 @@ public: virtual void removeThis(CORO_PARAM, bool &result); // Overloaded de-registration - virtual void Unregister(void); + virtual void Unregister(); // Overloading of the Draw to center the text, if necessary virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); @@ -279,15 +279,15 @@ public: void setCustomSkipHandle2(uint32 hCustomSkip); void setSkipStatus(bool bEnabled); void setForcedTime(uint32 dwTime); - void setNoTab(void); - void forceTime(void); - void forceNoTime(void); - void setAlwaysDisplay(void); + void setNoTab(); + void forceTime(); + void forceNoTime(); + void setAlwaysDisplay(); // Set the input device, to allow skip from mouse void setInput(RMInput *input); - void show(void); + void show(); void hide(CORO_PARAM); }; @@ -363,7 +363,7 @@ protected: public: virtual void removeThis(CORO_PARAM, bool &result); virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); - void Unregister(void); + void Unregister(); public: // Initialization @@ -371,8 +371,8 @@ public: virtual ~RMDialogChoice(); // Initialization and closure - void init(void); - void close(void); + void init(); + void close(); // Sets the number of possible sentences, which then be added with AddChoice() void setNumChoices(int num); @@ -390,7 +390,7 @@ public: void doFrame(CORO_PARAM, RMPoint ptMousePos); // Returns the currently selected item, or -1 if none is selected - int getSelection(void); + int getSelection(); }; } // End of namespace Tony diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 493887cfa9..4e9e2abc38 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -59,11 +59,11 @@ void mainLinkGraphicTask(RMGfxTask *task) { _vm->getEngine()->linkGraphicTask(task); } -void mainFreeze(void) { +void mainFreeze() { _vm->getEngine()->freeze(); } -void mainUnfreeze(void) { +void mainUnfreeze() { _vm->getEngine()->unfreeze(); } @@ -71,11 +71,11 @@ void mainWaitFrame(CORO_PARAM) { CoroScheduler.waitForSingleObject(coroParam, _vm->_hEndOfFrame, CORO_INFINITE); } -void mainShowMouse(void) { +void mainShowMouse() { _vm->getEngine()->enableMouse(); } -void mainHideMouse(void) { +void mainHideMouse() { _vm->getEngine()->disableMouse(); } @@ -83,11 +83,11 @@ void mainPlayMusic(int nChannel, const char *filename, int nFX, bool bLoop, int _vm->playMusic(nChannel, filename, nFX, bLoop, nSync); } -void mainDisableInput(void) { +void mainDisableInput() { _vm->getEngine()->disableInput(); } -void mainEnableInput(void) { +void mainEnableInput() { _vm->getEngine()->enableInput(); } @@ -95,7 +95,7 @@ void mainInitWipe(int type) { _vm->getEngine()->initWipe(type); } -void mainCloseWipe(void) { +void mainCloseWipe() { _vm->getEngine()->closeWipe(); } @@ -103,13 +103,13 @@ void mainWaitWipeEnd(CORO_PARAM) { _vm->getEngine()->waitWipeEnd(coroParam); } -void mainEnableGUI(void) { +void mainEnableGUI() { _vm->getEngine()->_bGUIInterface = true; _vm->getEngine()->_bGUIInventory = true; _vm->getEngine()->_bGUIOption = true; } -void mainDisableGUI(void) { +void mainDisableGUI() { _vm->getEngine()->_bGUIInterface = false; _vm->getEngine()->_bGUIInventory = false; _vm->getEngine()->_bGUIOption = false; @@ -320,7 +320,7 @@ void RMOptionSlide::addToList(RMGfxTargetBuffer &bigBuf) { * RMOptionScreen Methods \****************************************************************************/ -RMOptionScreen::RMOptionScreen(void) { +RMOptionScreen::RMOptionScreen() { _nState = MENUNONE; _menu = NULL; _hideLoadSave = NULL; @@ -377,7 +377,7 @@ RMOptionScreen::RMOptionScreen(void) { _nLastState = MENUGAME; } -RMOptionScreen::~RMOptionScreen(void) { +RMOptionScreen::~RMOptionScreen() { closeState(); } @@ -546,7 +546,7 @@ void RMOptionScreen::refreshAll(CORO_PARAM) { CORO_END_CODE; } -void RMOptionScreen::refreshThumbnails(void) { +void RMOptionScreen::refreshThumbnails() { int i; for (i = 0; i < 6; i++) { @@ -729,7 +729,7 @@ void RMOptionScreen::initState(CORO_PARAM) { CORO_END_CODE; } -void RMOptionScreen::closeState(void) { +void RMOptionScreen::closeState() { delete _menu; _menu = NULL; @@ -983,7 +983,7 @@ void RMOptionScreen::initNoLoadSave(CORO_PARAM, RMGfxTargetBuffer &bigBuf, bool CORO_END_CODE; } -bool RMOptionScreen::close(void) { +bool RMOptionScreen::close() { if (_fadeStep != 6) return false; @@ -993,7 +993,7 @@ bool RMOptionScreen::close(void) { return true; } -bool RMOptionScreen::isClosing(void) { +bool RMOptionScreen::isClosing() { return _bExit; } @@ -1479,7 +1479,7 @@ RMPointer::~RMPointer() { close(); } -void RMPointer::init(void) { +void RMPointer::init() { int i; for (i = 0; i < 5; i++) { @@ -1511,7 +1511,7 @@ void RMPointer::init(void) { _nCurSpecialPointer = 0; } -void RMPointer::close(void) { +void RMPointer::close() { int i; for (i = 0; i < 5; i++) { @@ -1560,7 +1560,7 @@ void RMPointer::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim CORO_END_CODE; } -int RMPointer::curAction(void) { +int RMPointer::curAction() { if (_nCurSpecialPointer != 0) return 0; diff --git a/engines/tony/game.h b/engines/tony/game.h index 64f4fb8e30..e231287c0f 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -90,12 +90,12 @@ public: /** * Initialization */ - void init(void); + void init(); /** * Deinitialization */ - void close(void); + void close(); /** * Process a frame @@ -130,7 +130,7 @@ public: updateCursor(); } - PointerType getSpecialPointer(void) { + PointerType getSpecialPointer() { return (PointerType)_nCurSpecialPointer; } @@ -145,7 +145,7 @@ public: /** * Return the current action to be applied according to the pointer */ - int curAction(void); + int curAction(); /** * Show the cursor @@ -318,12 +318,12 @@ protected: // Initialization and state change void initState(CORO_PARAM); - void closeState(void); + void closeState(); void changeState(CORO_PARAM, OptionScreenState newState); // Repaint the options menu void refreshAll(CORO_PARAM); - void refreshThumbnails(void); + void refreshThumbnails(); }; } // End of namespace Tony diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index e973fe9f6b..a4d8b9332b 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -91,7 +91,7 @@ void RMGfxBuffer::create(int dimx, int dimy, int nBpp, bool bUseDDraw) { } } -void RMGfxBuffer::destroy(void) { +void RMGfxBuffer::destroy() { if (!_bUseDDraw) { if (_origBuf != NULL && _origBuf == _buf) { delete[] _origBuf; @@ -100,13 +100,13 @@ void RMGfxBuffer::destroy(void) { } } -void RMGfxBuffer::lock(void) { +void RMGfxBuffer::lock() { if (_bUseDDraw) { // Manages acceleration } } -void RMGfxBuffer::unlock(void) { +void RMGfxBuffer::unlock() { if (_bUseDDraw) { // Manages acceleration } @@ -143,7 +143,6 @@ int RMGfxSourceBuffer::init(const byte *buf, int dimx, int dimy, bool bLoadPalet return dimx * dimy * getBpp() / 8; } - void RMGfxSourceBuffer::init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette) { create(dimx, dimy, getBpp()); ds.read(_buf, dimx * dimy * getBpp() / 8); @@ -155,7 +154,7 @@ void RMGfxSourceBuffer::init(RMDataStream &ds, int dimx, int dimy, bool bLoadPal RMGfxSourceBuffer::~RMGfxSourceBuffer() { } -void RMGfxSourceBuffer::prepareImage(void) { +void RMGfxSourceBuffer::prepareImage() { // Do nothing. Can be overloaded if necessary } @@ -243,10 +242,8 @@ RMGfxWoodyBuffer::RMGfxWoodyBuffer() { RMGfxWoodyBuffer::RMGfxWoodyBuffer(int dimx, int dimy, bool bUseDDraw) : RMGfxBuffer(dimx, dimy, 16, bUseDDraw) { - } - /****************************************************************************\ * RMGfxTargetBuffer Methods \****************************************************************************/ @@ -262,7 +259,7 @@ RMGfxTargetBuffer::~RMGfxTargetBuffer() { // g_system->deleteMutex(csModifyingOT); } -void RMGfxTargetBuffer::clearOT(void) { +void RMGfxTargetBuffer::clearOT() { OTList *cur, *n; // g_system->lockMutex(csModifyingOT); @@ -409,8 +406,7 @@ int RMGfxSourceBufferPal::loadPalette(const byte *buf) { return (1 << getBpp()) * 4; } - -void RMGfxSourceBufferPal::preparePalette(void) { +void RMGfxSourceBufferPal::preparePalette() { int i; for (i = 0; i < 256; i++) { @@ -704,7 +700,7 @@ void RMGfxSourceBuffer8RLE::init(RMDataStream &ds, int dimx, int dimy, bool bLoa } } -void RMGfxSourceBuffer8RLE::preparePalette(void) { +void RMGfxSourceBuffer8RLE::preparePalette() { // Invoke the parent method RMGfxSourceBuffer8::preparePalette(); @@ -716,7 +712,7 @@ void RMGfxSourceBuffer8RLE::preparePalette(void) { } } -void RMGfxSourceBuffer8RLE::prepareImage(void) { +void RMGfxSourceBuffer8RLE::prepareImage() { // Invoke the parent method RMGfxSourceBuffer::prepareImage(); @@ -724,12 +720,11 @@ void RMGfxSourceBuffer8RLE::prepareImage(void) { compressRLE(); } -void RMGfxSourceBuffer8RLE::setAlreadyCompressed(void) { +void RMGfxSourceBuffer8RLE::setAlreadyCompressed() { _bNeedRLECompress = false; } - -void RMGfxSourceBuffer8RLE::compressRLE(void) { +void RMGfxSourceBuffer8RLE::compressRLE() { int x, y; byte *startline; byte *cur; @@ -1515,11 +1510,9 @@ RLEWordDoCopy2: return; assert(nLength > 0); - } } - /****************************************************************************\ * Methods for RMGfxSourceBuffer8AA \****************************************************************************/ @@ -1527,7 +1520,7 @@ RLEWordDoCopy2: byte RMGfxSourceBuffer8AA::_megaAABuf[256 * 1024]; byte RMGfxSourceBuffer8AA::_megaAABuf2[64 * 1024]; -void RMGfxSourceBuffer8AA::prepareImage(void) { +void RMGfxSourceBuffer8AA::prepareImage() { // Invoke the parent method RMGfxSourceBuffer::prepareImage(); @@ -1535,8 +1528,7 @@ void RMGfxSourceBuffer8AA::prepareImage(void) { calculateAA(); } - -void RMGfxSourceBuffer8AA::calculateAA(void) { +void RMGfxSourceBuffer8AA::calculateAA() { int x, y; byte *src, *srcaa; @@ -1721,16 +1713,14 @@ void RMGfxSourceBuffer8AA::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrim CORO_END_CODE; } - /****************************************************************************\ * RMGfxSourceBuffer8RLEAA Methods \****************************************************************************/ RMGfxSourceBuffer8RLEByteAA::~RMGfxSourceBuffer8RLEByteAA() { - } -void RMGfxSourceBuffer8RLEByteAA::prepareImage(void) { +void RMGfxSourceBuffer8RLEByteAA::prepareImage() { RMGfxSourceBuffer::prepareImage(); calculateAA(); compressRLE(); @@ -1763,12 +1753,10 @@ void RMGfxSourceBuffer8RLEByteAA::init(RMDataStream &ds, int dimx, int dimy, boo } } - RMGfxSourceBuffer8RLEWordAA::~RMGfxSourceBuffer8RLEWordAA() { - } -void RMGfxSourceBuffer8RLEWordAA::prepareImage(void) { +void RMGfxSourceBuffer8RLEWordAA::prepareImage() { RMGfxSourceBuffer::prepareImage(); calculateAA(); compressRLE(); @@ -1869,7 +1857,7 @@ void RMGfxSourceBuffer16::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimi } } -void RMGfxSourceBuffer16::prepareImage(void) { +void RMGfxSourceBuffer16::prepareImage() { // Color space conversion if necessary! int i; uint16 *buf = (uint16 *)_buf; @@ -1878,14 +1866,12 @@ void RMGfxSourceBuffer16::prepareImage(void) { WRITE_LE_UINT16(&buf[i], FROM_LE_16(buf[i]) & 0x7FFF); } - RMGfxSourceBuffer16::RMGfxSourceBuffer16(int dimx, int dimy, bool bUseDDraw) : RMGfxBuffer(dimx, dimy, 16, bUseDDraw) { setPriority(0); _bTrasp0 = false; } - /** * Returns the number of bits per pixel of the surface * diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index 3b8384f614..be89c1713c 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -78,11 +78,11 @@ public: // Creation virtual void create(int dimx, int dimy, int nBpp, bool bUseDDraw = false); - virtual void destroy(void); + virtual void destroy(); // Buffer access - void lock(void); - void unlock(void); + void lock(); + void unlock(); // These are valid only if the buffer is locked operator byte *(); @@ -238,10 +238,10 @@ public: virtual void removeThis(CORO_PARAM, bool &result); // Registration - virtual void Register(void) { + virtual void Register() { _nInList++; } - virtual void Unregister(void) { + virtual void Unregister() { _nInList--; assert(_nInList >= 0); } @@ -300,7 +300,7 @@ public: virtual ~RMGfxSourceBuffer(); protected: - virtual void prepareImage(void); + virtual void prepareImage(); bool clip2D(int &x1, int &y1, int &u, int &v, int &width, int &height, bool bUseSrc, RMGfxTargetBuffer *buf); void offsetY(int nLines) { RMGfxBuffer::offsetY(nLines, getBpp()); @@ -316,7 +316,7 @@ public: */ class RMGfxSourceBuffer16 : public RMGfxSourceBuffer { protected: - virtual void prepareImage(void); + virtual void prepareImage(); bool _bTrasp0; public: @@ -342,7 +342,7 @@ protected: uint16 _palFinal[256]; // Post process to prepare the palette for drawing - virtual void preparePalette(void); + virtual void preparePalette(); public: virtual ~RMGfxSourceBufferPal(); @@ -411,12 +411,12 @@ protected: virtual void RLEDecompressLineFlipped(uint16 *dst, byte *src, int nStartSkip, int nLength) = 0; // Perform image compression in RLE - void compressRLE(void); + void compressRLE(); protected: // Overriding initialization methods - virtual void prepareImage(void); - virtual void preparePalette(void); + virtual void prepareImage(); + virtual void preparePalette(); public: RMGfxSourceBuffer8RLE(); @@ -433,7 +433,7 @@ public: void setAlphaBlendColor(int color); // Warn if the data is already compressed - void setAlreadyCompressed(void); + void setAlreadyCompressed(); }; class RMGfxSourceBuffer8RLEByte : public RMGfxSourceBuffer8RLE { @@ -481,13 +481,13 @@ protected: byte *_aabuf; // Calculate the buffer for the anti-aliasing - void calculateAA(void); + void calculateAA(); // Draw the AA void drawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); protected: - void prepareImage(void); + void prepareImage(); public: RMGfxSourceBuffer8AA(); @@ -500,7 +500,7 @@ public: class RMGfxSourceBuffer8RLEByteAA : public RMGfxSourceBuffer8RLEByte, public RMGfxSourceBuffer8AA { protected: - void prepareImage(void); + void prepareImage(); public: virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); @@ -514,7 +514,7 @@ public: class RMGfxSourceBuffer8RLEWordAA : public RMGfxSourceBuffer8RLEWord, public RMGfxSourceBuffer8AA { protected: - void prepareImage(void); + void prepareImage(); public: virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); @@ -570,7 +570,7 @@ public: virtual ~RMGfxTargetBuffer(); // management of the OT list - void clearOT(void); + void clearOT(); void drawOT(CORO_PARAM); void addPrim(RMGfxPrimitive *prim); // The pointer must be delted diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 08eff0a991..0785ec534c 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -353,7 +353,7 @@ SKIPCLICKSINISTRO: CORO_END_CODE; } -void RMGfxEngine::initCustomDll(void) { +void RMGfxEngine::initCustomDll() { setupGlobalVars(&_tony, &_point, &_vm->_theBoxes, &_loc, &_inv, &_input); } @@ -522,7 +522,7 @@ void RMGfxEngine::init() { _tony.executeAction(20, 1, 0); } -void RMGfxEngine::close(void) { +void RMGfxEngine::close() { _bigBuf.clearOT(); _inter.close(); @@ -538,37 +538,37 @@ void RMGfxEngine::switchFullscreen(bool bFull) { void RMGfxEngine::GDIControl(bool bCon) { } -void RMGfxEngine::enableInput(void) { +void RMGfxEngine::enableInput() { _bInput = true; } -void RMGfxEngine::disableInput(void) { +void RMGfxEngine::disableInput() { _bInput = false; _inter.reset(); } -void RMGfxEngine::enableMouse(void) { +void RMGfxEngine::enableMouse() { _bAlwaysDrawMouse = true; } -void RMGfxEngine::disableMouse(void) { +void RMGfxEngine::disableMouse() { _bAlwaysDrawMouse = false; } -void RMGfxEngine::freeze(void) { +void RMGfxEngine::freeze() { g_system->lockMutex(_csMainLoop); } -void RMGfxEngine::unfreeze(void) { +void RMGfxEngine::unfreeze() { g_system->unlockMutex(_csMainLoop); } void CharsSaveAll(Common::OutSaveFile *f); void CharsLoadAll(Common::InSaveFile *f); -void MCharResetCodes(void); +void MCharResetCodes(); void SaveChangedHotspot(Common::OutSaveFile *f); void LoadChangedHotspot(Common::InSaveFile *f); -void ReapplyChangedHotspot(void); +void ReapplyChangedHotspot(); void RestoreMusic(CORO_PARAM); void SaveMusic(Common::OutSaveFile *f); @@ -856,7 +856,7 @@ void RMGfxEngine::initWipe(int type) { _rcWipeEllipse = Common::Rect(320 - FSTEP, 240 - FSTEP, 320 + FSTEP, 240 + FSTEP); } -void RMGfxEngine::closeWipe(void) { +void RMGfxEngine::closeWipe() { _bWiping = false; } diff --git a/engines/tony/gfxengine.h b/engines/tony/gfxengine.h index 9cc586d25d..74aafd15f6 100644 --- a/engines/tony/gfxengine.h +++ b/engines/tony/gfxengine.h @@ -90,7 +90,7 @@ public: void init(); // Closes the graphics engine - void close(void); + void close(); // Warns when changing void switchFullscreen(bool bFull); @@ -102,12 +102,12 @@ public: void openOptionScreen(CORO_PARAM, int type); // Enables or disables mouse input - void enableInput(void); - void disableInput(void); + void enableInput(); + void disableInput(); // Enables and disables mouse draw - void enableMouse(void); - void disableMouse(void); + void enableMouse(); + void disableMouse(); operator byte *() { return (byte *)_bigBuf; @@ -117,7 +117,7 @@ public: } // Link to the custom function list - void initCustomDll(void); + void initCustomDll(); // Link to graphic task void linkGraphicTask(RMGfxTask *task) { @@ -129,8 +129,8 @@ public: void unloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result); // Freeze and unfreeze - void freeze(void); - void unfreeze(void); + void freeze(); + void unfreeze(); // State management void saveState(const Common::String &fn, byte *curThumb, const Common::String &name); @@ -141,7 +141,7 @@ public: // Wipe void initWipe(int type); - void closeWipe(void); + void closeWipe(); void waitWipeEnd(CORO_PARAM); void setPerorate(bool bpal) { diff --git a/engines/tony/globals.h b/engines/tony/globals.h index 96a61ffd9c..7b5d6db9cf 100644 --- a/engines/tony/globals.h +++ b/engines/tony/globals.h @@ -221,15 +221,15 @@ public: uint32(*LoadLocation)(int, RMPoint, RMPoint start); void (*UnloadLocation)(CORO_PARAM, bool bDoOnExit, uint32 *result); void (*LinkGraphicTask)(RMGfxTask *task); - void (*Freeze)(void); - void (*Unfreeze)(void); + void (*Freeze)(); + void (*Unfreeze)(); void (*WaitFrame)(CORO_PARAM); void (*PlayMusic)(int nChannel, const char *fileName, int nFX, bool bLoop, int nSync); void (*WaitWipeEnd)(CORO_PARAM); - void (*CloseWipe)(void); + void (*CloseWipe)(); void (*InitWipe)(int type); - void (*EnableGUI)(void); - void (*DisableGUI)(void); + void (*EnableGUI)(); + void (*DisableGUI)(); void (*SetPerorate)(bool bpal); uint32 _dwTonyNumTexts; @@ -252,43 +252,43 @@ public: /** * @defgroup MPAL variables */ - uint32 _mpalError; - LPITEMIRQFUNCTION _lpiifCustom; - LPLPCUSTOMFUNCTION _lplpFunctions; - Common::String *_lplpFunctionStrings; - uint16 _nObjs; - uint16 _nVars; - HGLOBAL _hVars; - LPMPALVAR _lpmvVars; - uint16 _nMsgs; - HGLOBAL _hMsgs; - LPMPALMSG _lpmmMsgs; - uint16 _nDialogs; - HGLOBAL _hDialogs; - LPMPALDIALOG _lpmdDialogs; - uint16 _nItems; - HGLOBAL _hItems; - LPMPALITEM _lpmiItems; - uint16 _nLocations; - HGLOBAL _hLocations; - LPMPALLOCATION _lpmlLocations; - uint16 _nScripts; - HGLOBAL _hScripts; - LPMPALSCRIPT _lpmsScripts; - Common::File _hMpr; - uint16 _nResources; - uint32 *_lpResources; - bool _bExecutingAction; - bool _bExecutingDialog; - uint32 _nPollingLocations[MAXPOLLINGLOCATIONS]; - uint32 _hEndPollingLocations[MAXPOLLINGLOCATIONS]; - uint32 _pollingThreads[MAXPOLLINGLOCATIONS]; - uint32 _hAskChoice; - uint32 _hDoneChoice; - uint32 _nExecutingAction; - uint32 _nExecutingDialog; - uint32 _nExecutingChoice; - uint32 _nSelectedChoice; + uint32 _mpalError; + LPITEMIRQFUNCTION _lpiifCustom; + LPLPCUSTOMFUNCTION _lplpFunctions; + Common::String *_lplpFunctionStrings; + uint16 _nObjs; + uint16 _nVars; + HGLOBAL _hVars; + LPMPALVAR _lpmvVars; + uint16 _nMsgs; + HGLOBAL _hMsgs; + LPMPALMSG _lpmmMsgs; + uint16 _nDialogs; + HGLOBAL _hDialogs; + LPMPALDIALOG _lpmdDialogs; + uint16 _nItems; + HGLOBAL _hItems; + LPMPALITEM _lpmiItems; + uint16 _nLocations; + HGLOBAL _hLocations; + LPMPALLOCATION _lpmlLocations; + uint16 _nScripts; + HGLOBAL _hScripts; + LPMPALSCRIPT _lpmsScripts; + Common::File _hMpr; + uint16 _nResources; + uint32 *_lpResources; + bool _bExecutingAction; + bool _bExecutingDialog; + uint32 _nPollingLocations[MAXPOLLINGLOCATIONS]; + uint32 _hEndPollingLocations[MAXPOLLINGLOCATIONS]; + uint32 _pollingThreads[MAXPOLLINGLOCATIONS]; + uint32 _hAskChoice; + uint32 _hDoneChoice; + uint32 _nExecutingAction; + uint32 _nExecutingDialog; + uint32 _nExecutingChoice; + uint32 _nSelectedChoice; }; } // End of namespace Tony diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp index 36cad4c6a1..2a8cdc10c3 100644 --- a/engines/tony/input.cpp +++ b/engines/tony/input.cpp @@ -46,10 +46,9 @@ RMInput::RMInput() { } RMInput::~RMInput() { - } -void RMInput::poll(void) { +void RMInput::poll() { _leftClickMouse = _leftReleaseMouse = _rightClickMouse = _rightReleaseMouse = false; // Get pending events @@ -105,7 +104,7 @@ void RMInput::poll(void) { void RMInput::init() { } -void RMInput::close(void) { +void RMInput::close() { } bool RMInput::mouseLeft() { diff --git a/engines/tony/input.h b/engines/tony/input.h index 81fa3433c4..d9b6dc7e89 100644 --- a/engines/tony/input.h +++ b/engines/tony/input.h @@ -50,7 +50,7 @@ private: /** * Deinitialize DirectInput */ - void DIClose(void); + void DIClose(); public: RMInput(); @@ -64,12 +64,12 @@ public: /** * Closes the class */ - void close(void); + void close(); /** * Polling (must be performed once per frame) */ - void poll(void); + void poll(); /** * Reading of the mouse diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index 7b111f8f58..0438d7252b 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -72,7 +72,7 @@ bool RMInventory::checkPointInside(const RMPoint &pt) { } -void RMInventory::init(void) { +void RMInventory::init() { int i, j; int curres; @@ -160,7 +160,7 @@ void RMInventory::init(void) { clearOT(); } -void RMInventory::close(void) { +void RMInventory::close() { // Has memory if (_items != NULL) { // Delete the item pointers @@ -175,7 +175,7 @@ void RMInventory::close(void) { destroy(); } -void RMInventory::reset(void) { +void RMInventory::reset() { _state = CLOSED; endCombine(); } @@ -288,7 +288,7 @@ void RMInventory::changeItemStatus(uint32 code, uint32 dwStatus) { } -void RMInventory::prepare(void) { +void RMInventory::prepare() { int i; for (i = 1; i < RM_SX / 64 - 1; i++) { @@ -303,7 +303,7 @@ void RMInventory::prepare(void) { addPrim(new RMGfxPrimitive(&_items[28]._icon, RMPoint(640 - 64, 0))); } -bool RMInventory::miniActive(void) { +bool RMInventory::miniActive() { return _state == SELECTING; } @@ -323,7 +323,7 @@ bool RMInventory::haveFocus(const RMPoint &mpos) { return false; } -void RMInventory::endCombine(void) { +void RMInventory::endCombine() { _bCombining = false; } @@ -661,7 +661,6 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo } } - bool RMInventory::itemInFocus(const RMPoint &mpt) { if ((_state == OPENED || _state == OPENING) && checkPointInside(mpt)) return true; @@ -681,9 +680,7 @@ RMItem *RMInventory::whichItemIsIn(const RMPoint &mpt) { return NULL; } - - -int RMInventory::getSaveStateSize(void) { +int RMInventory::getSaveStateSize() { // m_inv pattern m_nInv return 256 * 4 + 256 * 4 + 4 ; } @@ -742,7 +739,6 @@ int RMInventory::loadState(byte *state) { return getSaveStateSize(); } - /****************************************************************************\ * RMInterface methods \****************************************************************************/ @@ -753,7 +749,6 @@ RMInterface::RMInterface() : RMGfxSourceBuffer8RLEByte() { } RMInterface::~RMInterface() { - } bool RMInterface::active() { @@ -810,7 +805,6 @@ void RMInterface::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr CORO_END_CODE; } - void RMInterface::doFrame(RMGfxTargetBuffer &bigBuf, RMPoint mousepos) { // If needed, add to the OT schedule list if (!_nInList && _bActive) @@ -875,7 +869,7 @@ bool RMInterface::released(const RMPoint &mousepos, RMTonyAction &action) { return true; } -void RMInterface::reset(void) { +void RMInterface::reset() { _bActive = false; } @@ -883,11 +877,11 @@ void RMInterface::setPerorate(bool bOn) { _bPerorate = bOn; } -bool RMInterface::getPerorate(void) { +bool RMInterface::getPerorate() { return _bPerorate; } -void RMInterface::init(void) { +void RMInterface::init() { int i; RMResRaw inter(RES_I_INTERFACE); RMRes pal(RES_I_INTERPPAL); @@ -934,7 +928,7 @@ void RMInterface::init(void) { _lastHotZone = 0; } -void RMInterface::close(void) { +void RMInterface::close() { int i; destroy(); diff --git a/engines/tony/inventory.h b/engines/tony/inventory.h index dfbde5bad0..a5b37748c3 100644 --- a/engines/tony/inventory.h +++ b/engines/tony/inventory.h @@ -82,7 +82,7 @@ protected: /** * Prepare the image inventory. It should be recalled whenever the inventory changes */ - void prepare(void); + void prepare(); /** * Check if the mouse Y position is conrrect, even under the inventory portion of the screen @@ -101,9 +101,9 @@ public: /** * Initialization and closing */ - void init(void); - void close(void); - void reset(void); + void init(); + void close(); + void reset(); /** * Overload test for removal from OT list @@ -123,7 +123,7 @@ public: /** * Method for determining if the mini interface is active */ - bool miniActive(void); + bool miniActive(); /** * Handle the left mouse click (only when the inventory has the focus) @@ -139,7 +139,7 @@ public: /** * Warn that an item combine is over */ - void endCombine(void); + void endCombine(); public: /** @@ -178,7 +178,7 @@ public: /** * Save methods */ - int getSaveStateSize(void); + int getSaveStateSize(); void saveState(byte *state); int loadState(byte *state); }; @@ -219,13 +219,13 @@ public: /** * Initialization */ - void init(void); - void close(void); + void init(); + void close(); /** * Reset the interface */ - void reset(void); + void reset(); /** * Warns of mouse clicks and releases @@ -237,7 +237,7 @@ public: * Enables or disables the fifth verb */ void setPerorate(bool bOn); - bool getPerorate(void); + bool getPerorate(); /** * Overloaded Draw diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index d92b28845b..e8dbb4fa69 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -138,7 +138,7 @@ void RMPattern::readFromStream(RMDataStream &ds, bool bLOX) { } } -void RMPattern::updateCoord(void) { +void RMPattern::updateCoord() { _curPos = _pos + _slots[_nCurSlot].pos(); } @@ -446,7 +446,7 @@ void RMSfx::pause(bool bPause) { } } -void RMSfx::stop(void) { +void RMSfx::stop() { if (_fx) { _fx->stop(); _bPlayingLoop = false; @@ -665,7 +665,7 @@ bool RMItem::doFrame(RMGfxTargetBuffer *bigBuf, bool bAddToList) { return oldSprite != _nCurSprite; } -RMPoint RMItem::calculatePos(void) { +RMPoint RMItem::calculatePos() { return _pos + _patterns[_nCurPattern].pos(); } @@ -736,7 +736,6 @@ void RMItem::setPattern(int nPattern, bool bPlayP0) { } } - bool RMItem::getName(RMString &name) { char buf[256]; @@ -747,8 +746,7 @@ bool RMItem::getName(RMString &name) { return true; } - -void RMItem::unload(void) { +void RMItem::unload() { if (_patterns != NULL) { delete[] _patterns; _patterns = NULL; @@ -856,11 +854,11 @@ RMWipe::~RMWipe() { CoroScheduler.closeEvent(_hEndOfFade); } -int RMWipe::priority(void) { +int RMWipe::priority() { return 200; } -void RMWipe::Unregister(void) { +void RMWipe::Unregister() { RMGfxTask::Unregister(); assert(_nInList == 0); CoroScheduler.setEvent(_hUnregistered); @@ -887,7 +885,7 @@ void RMWipe::waitForFadeEnd(CORO_PARAM) { CORO_END_CODE; } -void RMWipe::closeFade(void) { +void RMWipe::closeFade() { _wip0r.unload(); } @@ -1786,8 +1784,7 @@ void RMBoxLoc::readFromStream(RMDataStream &ds) { ds >> _boxes[i]; } - -void RMBoxLoc::recalcAllAdj(void) { +void RMBoxLoc::recalcAllAdj() { int i, j; for (i = 0; i < _numbBox; i++) { @@ -1819,7 +1816,7 @@ RMGameBoxes::~RMGameBoxes() { delete _allBoxes[i]; } -void RMGameBoxes::init(void) { +void RMGameBoxes::init() { int i; RMString fn; RMDataStream ds; @@ -1840,7 +1837,7 @@ void RMGameBoxes::init(void) { } } -void RMGameBoxes::close(void) { +void RMGameBoxes::close() { } RMBoxLoc *RMGameBoxes::getBoxes(int nLoc) { @@ -1878,8 +1875,7 @@ void RMGameBoxes::changeBoxStatus(int nLoc, int nBox, int status) { _allBoxes[nLoc]->recalcAllAdj(); } - -int RMGameBoxes::getSaveStateSize(void) { +int RMGameBoxes::getSaveStateSize() { int size; int i; @@ -2204,12 +2200,11 @@ RMItem *RMLocation::whichItemIsIn(const RMPoint &pt) { return &_items[found]; } - RMLocation::~RMLocation() { unload(); } -void RMLocation::unload(void) { +void RMLocation::unload() { // Clear memory if (_items) { delete[] _items; @@ -2323,7 +2318,7 @@ void RMMessage::load(uint32 dwId) { parseMessage(); } -void RMMessage::parseMessage(void) { +void RMMessage::parseMessage() { char *p; assert(_lpMessage != NULL); diff --git a/engines/tony/loc.h b/engines/tony/loc.h index b863a3af1b..35674736dd 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -84,7 +84,7 @@ public: void play(bool bLoop = false); void setVolume(int vol); void pause(bool bPause); - void stop(void); + void stop(); void readFromStream(RMDataStream &ds, bool bLOX = false); }; @@ -165,7 +165,7 @@ public: void readFromStream(RMDataStream &ds, bool bLOX = false); private: - void updateCoord(void); + void updateCoord(); }; @@ -235,7 +235,7 @@ private: bool _bInitCurPattern; public: - RMPoint calculatePos(void); + RMPoint calculatePos(); public: RMItem(); @@ -282,7 +282,7 @@ public: } // Unload - void unload(void); + void unload(); // Wait for the end of the current pattern void waitForEndPattern(CORO_PARAM, uint32 hCustomSkip = CORO_INVALID_PID_VALUE); @@ -350,7 +350,7 @@ public: virtual ~RMBoxLoc(); friend RMDataStream &operator >>(RMDataStream &ds, RMBoxLoc &bl); - void recalcAllAdj(void); + void recalcAllAdj(); }; #define GAME_BOXES_SIZE 200 @@ -364,8 +364,8 @@ public: RMGameBoxes(); ~RMGameBoxes(); - void init(void); - void close(void); + void init(); + void close(); // Get binding boxes for a given location RMBoxLoc *getBoxes(int nLoc); @@ -381,7 +381,7 @@ public: void changeBoxStatus(int nLoc, int nBox, int status); // Save state handling - int getSaveStateSize(void); + int getSaveStateSize(); void saveState(byte *buf); void loadState(byte *buf); }; @@ -513,12 +513,12 @@ public: virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); void initFade(int type); - void closeFade(void); + void closeFade(); void waitForFadeEnd(CORO_PARAM); - virtual void Unregister(void); + virtual void Unregister(); virtual void removeThis(CORO_PARAM, bool &result); - virtual int priority(void); + virtual int priority(); }; @@ -563,7 +563,7 @@ public: bool loadLOX(RMDataStream &ds); // Unload - void unload(void); + void unload(); // Overloaded draw virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); @@ -606,7 +606,7 @@ private: int _nPeriods; private: - void parseMessage(void); + void parseMessage(); public: RMMessage(); diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index bb3df1662f..7385e60b66 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -59,101 +59,91 @@ const char *mpalCopyright = /** * Locks the variables for access */ -void lockVar(void) { +void lockVar() { GLOBALS._lpmvVars = (LPMPALVAR)globalLock(GLOBALS._hVars); } /** * Unlocks variables after use */ -void unlockVar(void) { +void unlockVar() { globalUnlock(GLOBALS._hVars); } /** * Locks the messages for access */ -static void LockMsg(void) { +static void LockMsg() { #ifdef NEED_LOCK_MSGS GLOBALS._lpmmMsgs = (LPMPALMSG)globalLock(GLOBALS._hMsgs); #endif } - /** * Unlocks the messages after use */ -static void UnlockMsg(void) { +static void UnlockMsg() { #ifdef NEED_LOCK_MSGS globalUnlock(GLOBALS._hMsgs); #endif } - /** * Locks the dialogs for access */ -static void lockDialogs(void) { +static void lockDialogs() { GLOBALS._lpmdDialogs = (LPMPALDIALOG)globalLock(GLOBALS._hDialogs); } - /** * Unlocks the dialogs after use */ -static void unlockDialogs(void) { +static void unlockDialogs() { globalUnlock(GLOBALS._hDialogs); } - /** * Locks the location data structures for access */ -static void lockLocations(void) { +static void lockLocations() { GLOBALS._lpmlLocations = (LPMPALLOCATION)globalLock(GLOBALS._hLocations); } - /** * Unlocks the location structures after use */ -static void unlockLocations(void) { +static void unlockLocations() { globalUnlock(GLOBALS._hLocations); } - /** * Locks the items structures for use */ -static void lockItems(void) { +static void lockItems() { GLOBALS._lpmiItems = (LPMPALITEM)globalLock(GLOBALS._hItems); } - /** * Unlocks the items structures after use */ -static void unlockItems(void) { +static void unlockItems() { globalUnlock(GLOBALS._hItems); } - /** * Locks the script data structures for use */ -static void LockScripts(void) { +static void LockScripts() { GLOBALS._lpmsScripts = (LPMPALSCRIPT)globalLock(GLOBALS._hScripts); } - /** * Unlocks the script data structures after use */ -static void unlockScripts(void) { +static void unlockScripts() { globalUnlock(GLOBALS._hScripts); } - /** * Returns the current value of a global variable * @@ -175,7 +165,6 @@ int32 varGetValue(const char *lpszVarName) { return 0; } - /** * Sets the value of a MPAL global variable * @param lpszVarName Name of the variable @@ -204,7 +193,6 @@ void varSetValue(const char *lpszVarName, int32 val) { return; } - /** * Find the index of a location within the location array. Remember to call LockLoc() beforehand. * @@ -1973,17 +1961,15 @@ void mpalQueryCORO(CORO_PARAM, uint16 wQueryType, uint32 *dwRet, ...) { va_end(v); } - /** * Returns the current MPAL error code * * @returns Error code */ -uint32 mpalGetError(void) { +uint32 mpalGetError() { return GLOBALS._mpalError; } - /** * Execute a script. The script runs on multitasking by a thread. * @@ -2091,17 +2077,15 @@ void mpalEndIdlePoll(CORO_PARAM, int nLoc, bool *result) { CORO_END_CODE; } - /** * Retrieve the length of a save state * * @returns Length in bytes */ -int mpalGetSaveStateSize(void) { +int mpalGetSaveStateSize() { return GLOBALS._nVars * sizeof(MPALVAR) + 4; } - /** * Store the save state into a buffer. The buffer must be * length at least the size specified with mpalGetSaveStateSize @@ -2251,7 +2235,6 @@ int OutputStartOther(uint16 wNum, Common::OutSaveFile *f) { return 0; } - void outputEndOther(uint16 wNum, Common::OutSaveFile *f) { int i; @@ -2262,8 +2245,7 @@ void outputEndOther(uint16 wNum, Common::OutSaveFile *f) { } } - -void mpalDumpMessages(void) { +void mpalDumpMessages() { int i, j; char *lpMessage; char *p; @@ -2354,9 +2336,7 @@ void mpalDumpMessages(void) { UnlockMsg(); } - - -void mpalDumpOthers(void) { +void mpalDumpOthers() { int i,j; char *lpMessage; char *p; @@ -2914,7 +2894,7 @@ void mpalDumpDialog(LPMPALDIALOG dlg) { delete v1; } -void mpalDumpDialogs(void) { +void mpalDumpDialogs() { int i; lockDialogs(); @@ -2925,8 +2905,6 @@ void mpalDumpDialogs(void) { unlockDialogs(); } -//@} - } // end of namespace MPAL } // end of namespace Tony diff --git a/engines/tony/mpal/mpal.h b/engines/tony/mpal/mpal.h index 1ec96c97d0..251e78afdf 100644 --- a/engines/tony/mpal/mpal.h +++ b/engines/tony/mpal/mpal.h @@ -327,7 +327,6 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; #define mpalQueryDialogWaitForChoice(dwRet) \ CORO_INVOKE_2(mpalQueryCORO, MPQ_DIALOG_WAITFORCHOICE, dwRet) - /** * Requires a list of various options for some choice within the current dialog. * @@ -340,7 +339,6 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; #define mpalQueryDialogSelectList(nChoice) \ (uint32 *)mpalQueryHANDLE(MPQ_DIALOG_SELECTLIST, (uint32)(nChoice)) - /** * Warns the library that the user has selected, in a certain choice of the current dialog, * corresponding option at a certain given. @@ -358,7 +356,6 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; #define mpalQueryDialogSelectionDWORD(nChoice, dwData) \ mpalQueryDWORD(MPQ_DIALOG_SELECTION, (uint32)(nChoice), (uint32)(dwData)) - /** * Warns the library an action was performed on a Object. * The library will call custom functions, if necessary. @@ -375,7 +372,6 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; #define mpalQueryDoAction(nAction, nItem, dwParam) \ mpalQueryDWORD(MPQ_DO_ACTION, (uint32)(nAction), (uint32)(nItem), (uint32)(dwParam)) - /** * Warns the library a dialogue was required. * @@ -387,8 +383,6 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; #define mpalQueryDoDialog(nDialog,nGroup) \ mpalQueryDWORD(MPQ_DO_DIALOG, (uint32)(nDialog),(uint32)(nGroup)) -//@} - /** * @defgroup Functions exported to the main game */ @@ -442,7 +436,6 @@ HANDLE mpalQueryHANDLE(uint16 wQueryType, ...); */ void mpalQueryCORO(CORO_PARAM, uint16 wQueryType, uint32 *dwRet, ...); - /** * Execute a script. The script runs on multitasking by a thread. * @@ -451,14 +444,12 @@ void mpalQueryCORO(CORO_PARAM, uint16 wQueryType, uint32 *dwRet, ...); */ bool mpalExecuteScript(int nScript); - /** * Returns the current MPAL error code * * @returns Error code */ -uint32 mpalGetError(void); - +uint32 mpalGetError(); /** * Install a custom routine That will be called by MPAL every time the pattern @@ -468,7 +459,6 @@ uint32 mpalGetError(void); */ void mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCustom); - /** * Process the idle actions of the items on one location. * @@ -480,7 +470,6 @@ void mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCustom); */ bool mpalStartIdlePoll(int nLoc); - /** * Stop processing the idle actions of the items on one location. * @@ -499,7 +488,6 @@ void mpalEndIdlePoll(CORO_PARAM, int nLoc, bool *result); */ int mpalLoadState(byte *buf); - /** * Store the save state into a buffer. The buffer must be * length at least the size specified with mpalGetSaveStateSize @@ -508,27 +496,22 @@ int mpalLoadState(byte *buf); */ void mpalSaveState(byte *buf); - /** * Retrieve the length of a save state * * @returns Length in bytes */ -int mpalGetSaveStateSize(void); - +int mpalGetSaveStateSize(); /** * Locks the variables for access */ -void lockVar(void); - +void lockVar(); /** * Unlocks variables after use */ -void unlockVar(void); - -//@} +void unlockVar(); } // end of namespace MPAL diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index d8b3655d2e..7e786a2f11 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -635,7 +635,7 @@ bool FPStream::unloadFile() { return true; } -void FPStream::prefetch(void) { +void FPStream::prefetch() { #ifdef REFACTOR_ME uint32 dwId; void *lpBuf; @@ -702,7 +702,7 @@ void FPStream::prefetch(void) { #endif } -void FPStream::playFast(void) { +void FPStream::playFast() { #ifdef REFACTOR_ME dspnHot[0].dwOffset = 32; dspnHot[0].hEventNotify = hHot1; diff --git a/engines/tony/sound.h b/engines/tony/sound.h index e1f0e40851..4dd00a3028 100644 --- a/engines/tony/sound.h +++ b/engines/tony/sound.h @@ -348,8 +348,8 @@ public: */ bool play(); - void playFast(void); - void prefetch(void); + void playFast(); + void prefetch(); /** * Closes the stream. diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 79694b2601..9e9e032e49 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -345,11 +345,11 @@ void TonyEngine::preloadUtilSFX(int nChannel, const char *fn) { warning("TonyEngine::preloadUtilSFX"); } -void TonyEngine::unloadAllSFX(void) { +void TonyEngine::unloadAllSFX() { warning("TonyEngine::unloadAllSFX"); } -void TonyEngine::unloadAllUtilSFX(void) { +void TonyEngine::unloadAllUtilSFX() { warning("TonyEngine::unloadAllUtilSFX"); } @@ -480,11 +480,11 @@ void TonyEngine::closeVoiceDatabase() { _voices.clear(); } -void TonyEngine::grabThumbnail(void) { +void TonyEngine::grabThumbnail() { _window.grabThumbnail(_curThumbnail); } -void TonyEngine::optionScreen(void) { +void TonyEngine::optionScreen() { } void TonyEngine::openInitLoadMenu(CORO_PARAM) { @@ -495,7 +495,7 @@ void TonyEngine::openInitOptions(CORO_PARAM) { _theEngine.openOptionScreen(coroParam, 2); } -void TonyEngine::abortGame(void) { +void TonyEngine::abortGame() { _bQuitNow = true; } @@ -555,7 +555,7 @@ void TonyEngine::playProcess(CORO_PARAM, const void *param) { /** * Play the game */ -void TonyEngine::play(void) { +void TonyEngine::play() { // Create the game player process CoroScheduler.createProcess(playProcess, NULL); @@ -569,7 +569,7 @@ void TonyEngine::play(void) { } } -void TonyEngine::close(void) { +void TonyEngine::close() { closeMusic(); CoroScheduler.closeEvent(_hEndOfFrame); _theBoxes.close(); @@ -589,12 +589,12 @@ void TonyEngine::GDIControl(bool bCon) { _theEngine.GDIControl(bCon); } -void TonyEngine::freezeTime(void) { +void TonyEngine::freezeTime() { _bTimeFreezed = true; _nTimeFreezed = getTime() - _startTime; } -void TonyEngine::unfreezeTime(void) { +void TonyEngine::unfreezeTime() { _bTimeFreezed = false; } diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 817147805a..5f6fd8cb44 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -165,21 +165,21 @@ public: void getDataDirectory(DataDir dir, char *path); void switchFullscreen(bool bFull); - void optionScreen(void); + void optionScreen(); - void showLocation(void) { + void showLocation() { _bDrawLocation = true; } - void hideLocation(void) { + void hideLocation() { _bDrawLocation = false; } /** * Reads the time */ - uint32 getTime(void); - void freezeTime(void); - void unfreezeTime(void); + uint32 getTime(); + void freezeTime(); + void unfreezeTime(); // Music // ****** @@ -195,10 +195,10 @@ public: FPSfx *createSFX(Common::SeekableReadStream *stream); void preloadSFX(int nSfx, const char *fn); - void unloadAllSFX(void); + void unloadAllSFX(); void preloadUtilSFX(int nSfx, const char *fn); - void unloadAllUtilSFX(void); + void unloadAllUtilSFX(); /** * Stop all the audio @@ -219,12 +219,12 @@ public: /** * Get a thumbnail */ - void grabThumbnail(void); - uint16 *getThumbnail(void) { + void grabThumbnail(); + uint16 *getThumbnail() { return _curThumbnail; } - void quitGame(void) { + void quitGame() { _bQuitNow = true; } diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index 700b69a643..cd5bbdad8b 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -84,7 +84,7 @@ RMGfxSourceBuffer *RMTony::newItemSpriteBuffer(int dimx, int dimy, bool bPreRLE) return spr; } -void RMTony::init(void) { +void RMTony::init() { RMRes tony(0); RMRes body(9999); RMDataStream ds; @@ -119,7 +119,7 @@ void RMTony::init(void) { } -void RMTony::close(void) { +void RMTony::close() { // Deallocation of missing item // _shadow.destroy(); } @@ -156,7 +156,7 @@ void RMTony::doFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int curLoc) { CORO_END_CODE; } -void RMTony::show(void) { +void RMTony::show() { _bShow = true; _bShowShadow = true; } @@ -334,7 +334,7 @@ void RMTony::stop(CORO_PARAM) { } -int RMTony::getCurPattern(void) { +int RMTony::getCurPattern() { int nPatt = RMCharacter::getCurPattern(); if (!_bShepherdess) diff --git a/engines/tony/tonychar.h b/engines/tony/tonychar.h index 70765abfd8..a50641bf25 100644 --- a/engines/tony/tonychar.h +++ b/engines/tony/tonychar.h @@ -369,12 +369,12 @@ public: /** * Initialize Tony */ - void init(void); + void init(); /** * Free all memory */ - void close(void); + void close(); /** * Tony makes a frame, updating the movement, etc. @@ -389,7 +389,7 @@ public: /** * Show or hide */ - void show(void); + void show(); void hide(bool bShowShadow = false); /** @@ -478,7 +478,7 @@ public: void setShepherdess(bool bIsPast) { _bShepherdess = bIsPast; } - int getShepherdess(void) { + int getShepherdess() { return _bShepherdess; } diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index 6c36781f51..7661c600da 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -296,7 +296,7 @@ void RMString::resize(int size, bool bMantain) { /** * Compacts the string to occupy less memory if possible. */ -void RMString::compact(void) { +void RMString::compact() { if (_realLength + 1 > _length) { char *app; @@ -518,7 +518,7 @@ RMDataStream::~RMDataStream() { /** * Close a stream */ -void RMDataStream::close(void) { +void RMDataStream::close() { _length = 0; _pos = 0; } @@ -850,7 +850,7 @@ RMRect::RMRect() { setEmpty(); } -void RMRect::setEmpty(void) { +void RMRect::setEmpty() { _x1 = _y1 = _x2 = _y2 = 0; } @@ -981,7 +981,7 @@ bool RMRect::operator!=(const RMRect &rc) { return ((_x1 != rc._x1) || (_y1 != rc._y1) || (_x2 != rc._x2) || (_y2 != rc._y2)); } -void RMRect::normalizeRect(void) { +void RMRect::normalizeRect() { setRect(MIN(_x1, _x2), MIN(_y1, _y2), MAX(_x1, _x2), MAX(_y1, _y2)); } diff --git a/engines/tony/utils.h b/engines/tony/utils.h index 4b0074f94c..c4f7386739 100644 --- a/engines/tony/utils.h +++ b/engines/tony/utils.h @@ -69,7 +69,7 @@ public: // Loading buffer void openBuffer(const byte *buf, int size = SIZENOTKNOWN); - void close(void); + void close(); // Attributei int length(); @@ -99,7 +99,6 @@ public: bool isError(); }; - /** * Data stream per lettura di dati aperto da file */ @@ -115,10 +114,9 @@ public: bool openFile(const char *lpFN); bool openFile(Common::File &file); - void close(void); + void close(); }; - class RMFileStreamSlow : public RMDataStream { private: Common::SeekableReadStream *_stream; @@ -129,7 +127,7 @@ public: bool openFile(const char *lpFN); bool openFile(Common::File &file); - void close(void); + void close(); RMDataStream &operator+=(int nBytes); int seek(int nBytes, RMDSPos where = CUR); @@ -272,7 +270,7 @@ public: // Set void setRect(int x1, int y1, int x2, int y2); void setRect(const RMPoint &p1, const RMPoint &p2); - void setEmpty(void); + void setEmpty(); // Copiers void setRect(const RMRect &rc); diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index dd7c70fe19..ba030e6a36 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -66,7 +66,7 @@ void RMWindow::init() { /** * Close the window */ -void RMWindow::close(void) { +void RMWindow::close() { } void RMWindow::grabThumbnail(uint16 *thumbmem) { @@ -77,7 +77,7 @@ void RMWindow::grabThumbnail(uint16 *thumbmem) { /** * Repaint the screen */ -void RMWindow::repaint(void) { +void RMWindow::repaint() { g_system->updateScreen(); } diff --git a/engines/tony/window.h b/engines/tony/window.h index 876bbf6973..0d4c20b0fe 100644 --- a/engines/tony/window.h +++ b/engines/tony/window.h @@ -72,7 +72,7 @@ protected: bool _bGrabMovie; uint16 *_wThumbBuf; - void createBWPrecalcTable(void); + void createBWPrecalcTable(); void wipeEffect(Common::Rect &rcBoundEllipse); void getNewFrameWipe(byte *lpBuf, Common::Rect &rcBoundEllipse); @@ -84,13 +84,13 @@ public: * Initialization */ void init(/*HINSTANCE hInst*/); - void initDirectDraw(void); - void close(void); + void initDirectDraw(); + void close(); /** * Drawing */ - void repaint(void); + void repaint(); /** * Switch between windowed and fullscreen -- cgit v1.2.3 From f2e6b4615356d17205a1d4e04100f6de8676a194 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 18 Jun 2012 08:28:13 +0200 Subject: TONY: Rename RMFontDialog --- engines/tony/font.cpp | 8 +++----- engines/tony/font.h | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) (limited to 'engines') diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index c4a95d0493..efce8dbe6e 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -201,10 +201,10 @@ void RMFontColor::setBaseColor(byte r1, byte g1, byte b1) { } /***************************************************************************\ -* RMFontParla Methods +* RMFontDialog Methods \****************************************************************************/ -void RMFontParla::init() { +void RMFontDialog::init() { int i; // bernie: Number of characters in the font @@ -1801,11 +1801,10 @@ void RMText::removeThis(CORO_PARAM, bool &result) { result = true; } - void RMText::writeText(const RMString &text, int nFont, int *time) { // Initializes the font (only once) if (_fonts[0] == NULL) { - _fonts[0] = new RMFontParla; + _fonts[0] = new RMFontDialog; _fonts[0]->init(); _fonts[1] = new RMFontObj; _fonts[1]->init(); @@ -1818,7 +1817,6 @@ void RMText::writeText(const RMString &text, int nFont, int *time) { writeText(text, _fonts[nFont], time); } - void RMText::writeText(const RMString &text, RMFontColor *font, int *time) { RMGfxPrimitive *prim; char *p, *old_p; diff --git a/engines/tony/font.h b/engines/tony/font.h index 595cb726a6..9971e536ed 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -141,10 +141,10 @@ public: }; -class RMFontParla : public RMFontColor, public RMFontWithTables { +class RMFontDialog : public RMFontColor, public RMFontWithTables { public: void init(); - virtual ~RMFontParla() {} + virtual ~RMFontDialog() {} }; class RMFontObj : public RMFontColor, public RMFontWithTables { -- cgit v1.2.3 From 565bf7383a0000cf8564ac63da08a61778194254 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 18 Jun 2012 19:50:29 +1000 Subject: TONY: Refactored the RMRect topLeft/bottomRight properties into a cleaner implementation --- engines/tony/utils.cpp | 32 ++++++++++++++++++-------------- engines/tony/utils.h | 17 +++++++++++++++-- 2 files changed, 33 insertions(+), 16 deletions(-) (limited to 'engines') diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index 7661c600da..647ef0ed82 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -842,11 +842,25 @@ RMDataStream &operator>>(RMDataStream &ds, RMPoint &p) { return ds; } +/****************************************************************************\ +* RMPointReference methods +\****************************************************************************/ + +RMPointReference &RMPointReference::operator=(const RMPoint &p) { + _x = p._x; _y = p._y; + return *this; +} + +RMPointReference &RMPointReference::operator-=(const RMPoint &p) { + _x -= p._x; _y -= p._y; + return *this; +} + /****************************************************************************\ * RMRect methods \****************************************************************************/ -RMRect::RMRect() { +RMRect::RMRect(): _topLeft(_x1, _y1), _bottomRight(_x2, _y2) { setEmpty(); } @@ -854,15 +868,15 @@ void RMRect::setEmpty() { _x1 = _y1 = _x2 = _y2 = 0; } -RMRect::RMRect(const RMPoint &p1, const RMPoint &p2) { +RMRect::RMRect(const RMPoint &p1, const RMPoint &p2): _topLeft(_x1, _y1), _bottomRight(_x2, _y2) { setRect(p1, p2); } -RMRect::RMRect(int X1, int Y1, int X2, int Y2) { +RMRect::RMRect(int X1, int Y1, int X2, int Y2): _topLeft(_x1, _y1), _bottomRight(_x2, _y2) { setRect(X1, Y1, X2, Y2); } -RMRect::RMRect(const RMRect &rc) { +RMRect::RMRect(const RMRect &rc): _topLeft(_x1, _y1), _bottomRight(_x2, _y2) { copyRect(rc); } @@ -891,16 +905,6 @@ void RMRect::copyRect(const RMRect &rc) { _y2 = rc._y2; } -RMPoint &RMRect::topLeft() { - // FIXME: This seems very bad - return *((RMPoint *)this); -} - -RMPoint &RMRect::bottomRight() { - // FIXME: This seems very bad - return *((RMPoint *)this + 1); -} - RMPoint RMRect::center() { return RMPoint((_x2 - _x1) / 2, (_y2 - _y1) / 2); } diff --git a/engines/tony/utils.h b/engines/tony/utils.h index c4f7386739..e7f943b231 100644 --- a/engines/tony/utils.h +++ b/engines/tony/utils.h @@ -247,10 +247,23 @@ public: friend RMDataStream &operator>>(RMDataStream &ds, RMPoint &p); }; +class RMPointReference { +public: + int &_x; + int &_y; + + RMPointReference(int &x, int &y): _x(x), _y(y) {} + RMPointReference &operator=(const RMPoint &p); + RMPointReference &operator-=(const RMPoint &p); + operator RMPoint() const { return RMPoint(_x, _y); } +}; + class RMRect { public: int _x1, _y1; int _x2, _y2; + RMPointReference _topLeft; + RMPointReference _bottomRight; public: RMRect(); @@ -259,8 +272,8 @@ public: RMRect(const RMRect &rc); // Attributes - RMPoint &topLeft(); - RMPoint &bottomRight(); + RMPointReference &topLeft() { return _topLeft; } + RMPointReference &bottomRight() { return _bottomRight; } RMPoint center(); int width() const; int height() const; -- cgit v1.2.3 From 0aa3d39cf7034dc35cda9e5062469886b0eb74d2 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 18 Jun 2012 19:56:28 +1000 Subject: TONY: Remove unused stubs for LZO compression --- engines/tony/mpal/lzo.cpp | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/lzo.cpp b/engines/tony/mpal/lzo.cpp index 17b059455c..48a0d8ea87 100644 --- a/engines/tony/mpal/lzo.cpp +++ b/engines/tony/mpal/lzo.cpp @@ -506,19 +506,6 @@ lookbehind_overrun: #endif } -int lzo1x_1_compress(const byte *src, uint32 src_len, byte *dst, uint32 *dst_len, void *wrkmem) { - warning("TODO: lzo1x_1_compress"); - return 0; -} - -/** - * better compression ratio at the cost of more memory and time - */ -int lzo1x_999_compress(const byte *src, uint32 src_len, byte *dst, uint32 *dst_len, void *wrkmem) { - warning("TODO: lzo1x_999_compress"); - return 0; -} - } // end of namespace MPAL } // end of namespace Tony -- cgit v1.2.3 From 61d460a854ff4883411846703543bb2f797fcd6b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 19 Jun 2012 20:50:48 +1000 Subject: TONY: Implement more of the music related code from the original --- engines/tony/custom.cpp | 6 +- engines/tony/gfxengine.cpp | 2 - engines/tony/sound.cpp | 809 ++++++++++++++++++++++++++++++++------------- engines/tony/sound.h | 35 +- engines/tony/tony.cpp | 99 +++--- engines/tony/tony.h | 4 +- 6 files changed, 671 insertions(+), 284 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 016c84ab39..ce1c2860f8 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -2198,14 +2198,14 @@ DECLARE_CUSTOM_FUNCTION(DemuteJingle)(CORO_PARAM, uint32, uint32, uint32, uint32 void CustPlayMusic(uint32 nChannel, const char *mFN, uint32 nFX, bool bLoop, int nSync = 0) { if (nSync == 0) nSync = 2000; - debug("Start CustPlayMusic"); + debugC(DEBUG_INTERMEDIATE, kTonyDebugMusic, "Start CustPlayMusic"); GLOBALS.PlayMusic(nChannel, mFN, nFX, bLoop, nSync); - debug("End CustPlayMusic"); + debugC(DEBUG_INTERMEDIATE, kTonyDebugMusic, "End CustPlayMusic"); } DECLARE_CUSTOM_FUNCTION(PlaySoundEffect)(CORO_PARAM, uint32 nMusic, uint32 nFX, uint32 bNoLoop, uint32) { if (nFX == 0 || nFX == 1 || nFX == 2) { - debug("PlaySoundEffect stop fadeout"); + debugC(DEBUG_INTERMEDIATE, kTonyDebugSound, "PlaySoundEffect stop fadeout"); GLOBALS._bFadeOutStop = true; } diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 0785ec534c..cc53a1d8e2 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -473,8 +473,6 @@ void RMGfxEngine::init() { delete load; // Display 'Loading' screen - // TODO: The loading screen isn't currently optimal, since the game doesn't respond to events - // whilst the mpalInit code is being executed. _vm->_window.getNewFrame(*this, NULL); _vm->_window.repaint(); diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index 7e786a2f11..484b279cda 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -39,11 +39,406 @@ namespace Tony { #define RELEASE(x) {if ((x) != NULL) { (x)->release(); x = NULL; }} + +/****************************************************************************\ +***************************************************************************** +* class CODECRAW +* -------------- +* Description: CODEC to play hard from pure samples +***************************************************************************** +\****************************************************************************/ + +class CODECRAW : public CODEC { +public: + CODECRAW(bool _bLoop = true); + + virtual ~CODECRAW(); + virtual uint32 decompress(Common::SeekableReadStream *stream, void *lpBuf, uint32 dwSize); + virtual void loopReset(); +}; + + +/****************************************************************************\ +***************************************************************************** +* class CODECADPCM +* ---------------- +* Description: Play ADPCM compressed data +***************************************************************************** +\****************************************************************************/ + +class CODECADPCM : public CODECRAW { +protected: + byte *lpTemp; + static const int indexTable[16]; + static const int stepSizeTable[89]; + +public: + CODECADPCM(bool _bLoop = true, byte *lpTempBuffer = NULL); + virtual ~CODECADPCM(); + virtual uint32 decompress(Common::SeekableReadStream *stream, void *lpBuf, uint32 dwSize) = 0; + virtual void loopReset() = 0; +}; + +class CODECADPCMSTEREO : public CODECADPCM { +protected: + int valpred[2], index[2]; + +public: + CODECADPCMSTEREO(bool _bLoop=true, byte *lpTempBuffer = NULL); + virtual ~CODECADPCMSTEREO(); + virtual uint32 decompress(Common::SeekableReadStream *stream, void *lpBuf, uint32 dwSize); + virtual void loopReset(); +}; + +class CODECADPCMMONO : public CODECADPCM { +protected: + int valpred, index; + +public: + CODECADPCMMONO(bool _bLoop = true, byte *lpTempBuffer = NULL); + virtual ~CODECADPCMMONO(); + virtual uint32 decompress(Common::SeekableReadStream *stream, void *lpBuf, uint32 dwSize); + virtual void loopReset(); +}; + +/****************************************************************************\ +* CODEC Methods +\****************************************************************************/ + /** - * Default constructor. Initializes the attributes. + * Standard cosntructor. It's possible to specify whether you want to + * enable or disable the loop (which by default, and 'active). + * + * @param loop True if you want to loop, false to disable + */ +CODEC::CODEC(bool loop) { + _bLoop = loop; + _bEndReached = false; +} + +CODEC::~CODEC() { +} + +/** + * Tell whether we have reached the end of the stream * + * @return True if we're done, false otherwise. + */ +bool CODEC::endOfStream() { + return _bEndReached; +} + + +/****************************************************************************\ +* CODECRAW Methods +\****************************************************************************/ + +/** + * Standard cosntructor. Simply calls the inherited constructor + */ +CODECRAW::CODECRAW(bool loop) : CODEC(loop) { +} + +CODECRAW::~CODECRAW() { +} + +/** + * Reset the stream to the beginning of the file. In the case of RAW files, does nothing + */ +void CODECRAW::loopReset() { +} + +/** + * Manage the RAW format. Simply copies the file's stream buffer + * + * @return Indicates the position of the file for the end of the loop + */ +uint32 CODECRAW::decompress(Common::SeekableReadStream *stream, void *buf, uint32 dwSize) { + byte *lpBuf = (byte *)buf; + uint32 dwRead; + uint32 dwEOF; + + _bEndReached = false; + dwEOF = 0; + dwRead = stream->read(lpBuf, dwSize); + + if (dwRead < dwSize) { + dwEOF = dwRead; + _bEndReached = true; + + if (!_bLoop) { + Common::fill(lpBuf + dwRead, lpBuf + dwRead + (dwSize - dwRead), 0); + } else { + stream->seek(0); + dwRead = stream->read(lpBuf + dwRead, dwSize - dwRead); + } + } + + return dwEOF; +} + +/****************************************************************************\ +* CODECADPCM Methods +\****************************************************************************/ + +const int CODECADPCM::indexTable[16] = { + -1, -1, -1, -1, 2, 4, 6, 8, + -1, -1, -1, -1, 2, 4, 6, 8, +}; + +const int CODECADPCM::stepSizeTable[89] = { + 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, + 19, 21, 23, 25, 28, 31, 34, 37, 41, 45, + 50, 55, 60, 66, 73, 80, 88, 97, 107, 118, + 130, 143, 157, 173, 190, 209, 230, 253, 279, 307, + 337, 371, 408, 449, 494, 544, 598, 658, 724, 796, + 876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066, + 2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358, + 5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899, + 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767 +}; + +#define MAXDECODESIZE (44100 * 2 * 2) + +/** + * Standard constructor. Initialises and allocates temporary memory tables + */ +CODECADPCM::CODECADPCM(bool loop, byte *lpTempBuffer) : CODECRAW(loop) { + // Alloca la memoria temporanea + if (lpTempBuffer != NULL) { + lpTemp = lpTempBuffer; + } else { + lpTemp = (byte *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, MAXDECODESIZE); + + if (lpTemp == NULL) { + error("Insufficient memory!"); + return; + } + } +} + + +CODECADPCMMONO::CODECADPCMMONO(bool loop, byte *lpTempBuffer) : CODECADPCM(loop,lpTempBuffer) { + // Inizializza per il playing + loopReset(); +} + +CODECADPCMMONO::~CODECADPCMMONO() { +} + + +CODECADPCMSTEREO::CODECADPCMSTEREO(bool loop, byte *lpTempBuffer) : CODECADPCM(loop, lpTempBuffer) { + // Initialise for playing + loopReset(); +} + +CODECADPCMSTEREO::~CODECADPCMSTEREO() { +} + +/** + * Destructor. Free the buffer + */ +CODECADPCM::~CODECADPCM() { + globalDestroy(lpTemp); +} + + +/** + * Reset the player before each play or loop + */ +void CODECADPCMSTEREO::loopReset() { + valpred[0] = 0; + valpred[1] = 0; + index[0] = 0; + index[1] = 0; +} + +void CODECADPCMMONO::loopReset() { + valpred = 0; + index = 0; +} + + +/** + * Manages decompressing the ADPCM 16:4 format. */ +uint32 CODECADPCMMONO::decompress(Common::SeekableReadStream *stream, void *buf, uint32 dwSize) { + uint16 *lpBuf = (uint16 *)buf; + byte *inp; + int bufferstep; + int cache; + int delta; + int sign; + int vpdiff; + uint32 eof, i; + int step; + + bufferstep = 1; + step = stepSizeTable[index]; + + // Invokes the raw codec to read the stream from disk to loop. + eof = CODECRAW::decompress(stream, lpTemp, dwSize / 4); + inp = lpTemp; + + eof *= 2; + + // If you must do an immediate loop + if (endOfStream() && eof == 0) { + loopReset(); + bufferstep = 1; + step = stepSizeTable[index]; + } else if (!endOfStream()) + eof = 0; + + dwSize /= 2; + for (i = 0; i < dwSize; i++) { + // Check if we are at the end of the file, and are looping + if (eof != 0 && i == eof) { + loopReset(); + bufferstep=1; + step = stepSizeTable[index]; + } + + // Read the delta (4 bits) + if (bufferstep) { + cache = *inp++; + delta = (cache >> 4) & 0xF; + } else + delta = cache & 0xF; + + // Find the new index + index += indexTable[delta]; + if (index < 0) index = 0; + if (index > 88) index = 88; + + // Reads the sign and separates it + sign = delta & 8; + delta = delta & 7; + + // Find the difference from the previous value + vpdiff = step >> 3; + if (delta & 4) vpdiff += step; + if (delta & 2) vpdiff += step >> 1; + if (delta & 1) vpdiff += step >> 2; + + if (sign) + valpred -= vpdiff; + else + valpred += vpdiff; + + // Check the limits of the found value + if (valpred > 32767) + valpred = 32767; + else if (valpred < -32768) + valpred = -32768; + + // Update the step + step = stepSizeTable[index]; + + // Write the value found + *lpBuf++ = (uint16)valpred; + + bufferstep = !bufferstep; + } + + return eof / 2; +} + +uint32 CODECADPCMSTEREO::decompress(Common::SeekableReadStream *stream, void *buf, uint32 dwSize) { + uint16 *lpBuf=(uint16 *)buf; + byte *inp; + int bufferstep; + int cache; + int delta; + int sign; + int vpdiff; + uint32 eof, i; + int step[2]; + + bufferstep = 1; + step[0] = stepSizeTable[index[0]]; + step[1] = stepSizeTable[index[1]]; + + // Invokes the RAW codec to read the stream from disk. + eof = CODECRAW::decompress(stream, lpTemp, dwSize / 4); + inp = lpTemp; + + eof *= 2; + + // If you must do an immediate loop + if (endOfStream() && eof == 0) { + loopReset(); + bufferstep = 1; + step[0] = stepSizeTable[index[0]]; + step[1] = stepSizeTable[index[1]]; + + } else if (!endOfStream()) + eof = 0; + + dwSize /= 2; + + for (i = 0;i < dwSize; i++) { + // If you must do an immediate loop + if (eof != 0 && i == eof) { + loopReset(); + bufferstep = 1; + step[0] = stepSizeTable[index[0]]; + step[1] = stepSizeTable[index[1]]; + } + + // Reads the delta (4 bits) + if (bufferstep) { + cache = *inp++; + delta = cache & 0xF; + } else + delta = (cache >> 4) & 0xF; + + // Find the new index + index[bufferstep] += indexTable[delta]; + if (index[bufferstep] < 0) index[bufferstep] = 0; + if (index[bufferstep] > 88) index[bufferstep] = 88; + + // Reads the sign and separates it + sign = delta & 8; + delta = delta & 7; + + // Find the difference from the previous value + vpdiff = step[bufferstep] >> 3; + if (delta & 4) vpdiff += step[bufferstep]; + if (delta & 2) vpdiff += step[bufferstep] >> 1; + if (delta & 1) vpdiff += step[bufferstep] >> 2; + + if (sign) + valpred[bufferstep] -= vpdiff; + else + valpred[bufferstep] += vpdiff; + + // Check the limits of the value + if (valpred[bufferstep] > 32767) + valpred[bufferstep] = 32767; + else if (valpred[bufferstep] < -32768) + valpred[bufferstep] =- 32768; + + // Update the step + step[bufferstep] = stepSizeTable[index[bufferstep]]; + + // Write the found value + *lpBuf++ = (uint16)valpred[bufferstep]; + + bufferstep = !bufferstep; + } + + return eof / 2; +} + +/****************************************************************************\ +* FPSOUND Methods +\****************************************************************************/ +/** + * Default constructor. Initializes the attributes. + * + */ FPSound::FPSound() { _bSoundSupported = false; } @@ -53,7 +448,6 @@ FPSound::FPSound() { * * @returns True is everything is OK, False otherwise */ - bool FPSound::init() { _bSoundSupported = g_system->getMixer()->isReady(); return _bSoundSupported; @@ -308,7 +702,7 @@ bool FPSfx::stop() { /** * Enables or disables the Sfx loop. * - * @param bLoop True to enable the loop, False to disable + * @param _bLoop True to enable the loop, False to disable * * @remarks The loop must be activated BEFORE the sfx starts * playing. Any changes made during the play will have @@ -423,20 +817,19 @@ void FPSfx::soundCheckProcess(CORO_PARAM, const void *param) { * @remarks Do *NOT* declare an object directly, but rather * create it using FPSound::CreateStream() */ - FPStream::FPStream(bool bSoundOn) { #ifdef REFACTOR_ME - //hwnd=hWnd; + hwnd=hWnd; lpDS = LPDS; - bSoundSupported = bSoundOn; - bFileLoaded = false; - bIsPlaying = false; - bPaused = false; - bSyncExit = false; - lpDSBuffer = NULL; - lpDSNotify = NULL; - hHot1 = hHot2 = hHot3 = hPlayThread_PlayFast = hPlayThread_PlayNormal = NULL; + _lpDSBuffer = NULL; + _lpDSNotify = NULL; #endif + _bSoundSupported = bSoundOn; + _bFileLoaded = false; + _bIsPlaying = false; + _bPaused = false; + _bSyncExit = false; + _hHot1 = _hHot2 = _hHot3 = _hPlayThreadPlayFast = _hPlayThreadPlayNormal = CORO_INVALID_PID_VALUE; } bool FPStream::createBuffer(int nBufSize) { @@ -512,40 +905,38 @@ bool FPStream::createBuffer(int nBufSize) { */ FPStream::~FPStream() { -#ifdef REFACTOR_ME - - if (!bSoundSupported) + if (!_bSoundSupported) return; - if (bIsPlaying) - Stop(); + if (_bIsPlaying) + stop(); - if (bFileLoaded) - UnloadFile(); + if (_bFileLoaded) + unloadFile(); - if (hHot1) { - CloseHandle(hHot1); - hHot1 = NULL; + if (_hHot1) { + CoroScheduler.closeEvent(_hHot1); + _hHot1 = CORO_INVALID_PID_VALUE; } - if (hHot2) { - CloseHandle(hHot2); - hHot2 = NULL; + if (_hHot2) { + CoroScheduler.closeEvent(_hHot2); + _hHot2 = CORO_INVALID_PID_VALUE; } - if (hHot3) { - CloseHandle(hHot3); - hHot3 = NULL; + if (_hHot3) { + CoroScheduler.closeEvent(_hHot3); + _hHot3 = CORO_INVALID_PID_VALUE; } - if (hPlayThread_PlayFast) { - CloseHandle(hPlayThread_PlayFast); - hPlayThread_PlayFast = NULL; + if (_hPlayThreadPlayFast != CORO_INVALID_PID_VALUE) { + CoroScheduler.closeEvent(_hPlayThreadPlayFast); + _hPlayThreadPlayFast = CORO_INVALID_PID_VALUE; } - if (hPlayThread_PlayNormal) { - CloseHandle(hPlayThread_PlayNormal); - hPlayThread_PlayNormal = NULL; + if (_hPlayThreadPlayNormal != CORO_INVALID_PID_VALUE) { + CoroScheduler.closeEvent(_hPlayThreadPlayNormal); + _hPlayThreadPlayNormal = CORO_INVALID_PID_VALUE; } - SyncToPlay = NULL; - + _syncToPlay = NULL; +#ifdef REFACTOR_ME RELEASE(lpDSNotify); RELEASE(lpDSBuffer); #endif @@ -559,7 +950,6 @@ FPStream::~FPStream() { * FPSound::CreateStream(). * Object pointers are no longer valid after this call. */ - void FPStream::release() { delete this; } @@ -567,44 +957,35 @@ void FPStream::release() { /** * Opens a file stream * - * @param lpszFile Filename to be opened + * @param fileName Filename to be opened * @param dwCodec CODEC to be used to uncompress samples * * @returns True is everything is OK, False otherwise */ - -bool FPStream::loadFile(const char *lpszFileName, uint32 dwCodType, int nBufSize) { -#ifdef REFACTOR_ME - HRESULT err; - void *lpBuf; - uint32 dwHi; - - if (!bSoundSupported) +bool FPStream::loadFile(const Common::String &fileName, uint32 dwCodType, int nBufSize) { + if (!_bSoundSupported) return true; - /* Si salva il tipo di codec */ - dwCodec = dwCodType; + // Save the codec type + _dwCodec = dwCodType; - /* Crea il buffer */ - if (!CreateBuffer(nBufSize)) + // Create the buffer + if (!createBuffer(nBufSize)) return true; - /* Apre il file di stream in lettura */ - if (!_file.open(lpszFileName)) - //MessageBox(hwnd,"Cannot open stream file!","FPStream::LoadFile()", MB_OK); + // Open the file stream for reading + if (!_file.open(fileName)) return false; -} -/* Si salva la lunghezza dello stream */ -dwSize = _file.size(); -_file.seek(0); + // Save the size of the stream + _dwSize = _file.size(); -/* Tutto a posto, possiamo uscire */ -bFileLoaded = true; -bIsPlaying = false; -bPaused = false; -#endif -return true; + // All done + _bFileLoaded = true; + _bIsPlaying = false; + _bPaused = false; + + return true; } /** @@ -616,85 +997,80 @@ return true; * @remarks It is necessary to call this function to free the * memory used by the stream. */ - bool FPStream::unloadFile() { -#ifdef REFACTOR_ME - - if (!bSoundSupported || !bFileLoaded) + if (!_bSoundSupported || !_bFileLoaded) return true; /* Closes the file handle stream */ _file.close(); - +#ifdef REFACTOR_ME RELEASE(lpDSNotify); RELEASE(lpDSBuffer); - - /* Remember no more file is loaded in memory */ - bFileLoaded = false; #endif + + // Flag that the file is no longer in memory + _bFileLoaded = false; + return true; } void FPStream::prefetch() { -#ifdef REFACTOR_ME - uint32 dwId; void *lpBuf; - uint32 dwHi; - HRESULT err; - if (!bSoundSupported || !bFileLoaded) + if (!_bSoundSupported || !_bFileLoaded) return; - /* Allocates a temporary buffer */ - lpTempBuffer = (byte *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, dwBufferSize / 2); - if (lpTempBuffer == NULL) + // Allocates a temporary buffer + _lpTempBuffer = (byte *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, _dwBufferSize / 2); + if (_lpTempBuffer == NULL) return; - switch (dwCodec) { - case FPCODEC_RAW: - lpCodec = new CODECRAW(bLoop); - break; - - case FPCODEC_ADPCM: - lpCodec = new CODECADPCMSTEREO(bLoop); - break; - - default: + if (_dwCodec == FPCODEC_RAW) { + _codec = new CODECRAW(_bLoop); + } else if (_dwCodec == FPCODEC_ADPCM) { + _codec = new CODECADPCMSTEREO(_bLoop); + } else { return; } - /* reset the file position */ + // reset the file position _file.seek(0); - /* Fills the buffer for the data already ready */ +#ifdef REFACTOR_ME + // Fills the buffer for the data already ready if ((err = lpDSBuffer->Lock(0, dwBufferSize / 2, &lpBuf, (uint32 *)&dwHi, NULL, NULL, 0)) != DS_OK) { - MessageBox(hwnd, "Cannot lock stream buffer!", "soundLoadStream()", MB_OK); + _vm->GUIError("Cannot lock stream buffer!", "soundLoadStream()"); return; } +#endif - /* Uncompress the data from the stream directly into the locked buffer */ - lpCodec->Decompress(hFile, lpBuf, dwBufferSize / 2); - - /* Unlock the buffer */ - lpDSBuffer->Unlock(lpBuf, dwBufferSize / 2, NULL, NULL); + // Uncompress the data from the stream directly into the locked buffer + _codec->decompress(_file.readStream(_file.size()), lpBuf, _dwBufferSize / 2); - /* Create a thread to play the stream */ - hThreadEnd = CreateEvent(NULL, false, false, NULL); - hPlayThread = CreateThread(NULL, 10240, (LPTHREAD_START_ROUTINE)PlayThread, (void *)this, 0, &dwId); - SetThreadPriority(hPlayThread, THREAD_PRIORITY_HIGHEST); + // Unlock the buffer +#ifdef REFACTOR_ME + lpDSBuffer->unlock(lpBuf, _dwBufferSize / 2, NULL, NULL); +#endif - /* Start to play the buffer */ - lpDSBuffer->SetCurrentPosition(0); - bIsPlaying = true; + // Create a thread to play the stream + _hThreadEnd = CoroScheduler.createEvent(false, false); + _hPlayThread = CoroScheduler.createProcess(playThread, this, sizeof(FPStream *)); + + // Start to play the buffer +#ifdef REFACTOR_ME + lpDSBuffer->setCurrentPosition(0); +#endif + _bIsPlaying = true; - dspnHot[0].dwOffset = 32; - dspnHot[0].hEventNotify = hHot1; +#ifdef REFACTOR_ME + _dspnHot[0].dwOffset = 32; + _dspnHot[0].hEventNotify = _hHot1; - dspnHot[1].dwOffset = dwBufferSize / 2 + 32; - dspnHot[1].hEventNotify = hHot2; + _dspnHot[1].dwOffset = dwBufferSize / 2 + 32; + _dspnHot[1].hEventNotify = _hHot2; - dspnHot[2].dwOffset = dwBufferSize - 32; //DSBPN_OFFSETSTOP; - dspnHot[2].hEventNotify = hHot3; + _dspnHot[2].dwOffset = dwBufferSize - 32; //DSBPN_OFFSETSTOP; + _dspnHot[2].hEventNotify = _hHot3; if (FAILED(lpDSNotify->SetNotificationPositions(3, dspnHot))) { int a = 1; @@ -748,11 +1124,11 @@ bool FPStream::play() { switch (dwCodec) { case FPCODEC_RAW: - lpCodec = new CODECRAW(bLoop); + _codec = new CODECRAW(_bLoop); break; case FPCODEC_ADPCM: - lpCodec = new CODECADPCMSTEREO(bLoop); + _codec = new CODECADPCMSTEREO(_bLoop); break; default: @@ -770,7 +1146,7 @@ bool FPStream::play() { } /* Uncompress the data from the stream directly into the locked buffer */ - lpCodec->Decompress(hFile, lpBuf, dwBufferSize / 2); + _codec->Decompress(hFile, lpBuf, dwBufferSize / 2); /* Unlock the buffer */ lpDSBuffer->Unlock(lpBuf, dwBufferSize / 2, NULL, NULL); @@ -846,7 +1222,7 @@ bool FPStream::stop(bool bSync) { GlobalFree(lpTempBuffer); /* Close and free the CODEC */ - delete lpCodec; + delete _codec; bIsPlaying = false; bPaused = false; @@ -882,7 +1258,7 @@ void FPStream::waitForSync(FPStream *toplay) { GlobalFree(lpTempBuffer); /* Close and free the CODEC */ - delete lpCodec; + delete _codec; #endif _bIsPlaying = false; } @@ -892,129 +1268,110 @@ void FPStream::waitForSync(FPStream *toplay) { * */ -void FPStream::playThread(FPStream *This) { -#ifdef REFACTOR_ME - byte *lpLockBuf; - uint32 dwResult; - byte *lpLockBuf2; - uint32 dwResult2; - bool cicla = true; - uint32 countEnd; - bool bPrecache; - char buf[1024]; +void FPStream::playThread(CORO_PARAM, const void *param) { + CORO_BEGIN_CONTEXT; + byte *lpLockBuf; + uint32 dwResult; + byte *lpLockBuf2; + uint32 dwResult2; + bool cicla; + uint32 countEnd; + bool bPrecache; + char buf[1024]; + uint32 hList[5]; + CORO_END_CONTEXT(_ctx); - /* Events that signal when you need to do something */ - HANDLE hList[5] = { This->hThreadEnd, This->hHot1, This->hHot2, This->hHot3, This->hPlayThread_PlayFast }; +// FPStream *This = *(FPStream **)param; - bPrecache = true; - countEnd = 0; - while (cicla) { - if (This->lpCodec->EndOfStream() && This->lpCodec->bLoop == false) { - countEnd++; - if (countEnd == 3) + CORO_BEGIN_CODE(_ctx); +#ifdef REFACTOR_ME + // Events that signal when you need to do something + _ctx->hList[0] = This->_hThreadEnd; + _ctx->hList[1] = This->_hHot1; + _ctx->hList[2] = This->_hHot2; + _ctx->hList[3] = This->_hHot3; + _ctx->hList[4] = This->_hPlayThreadPlayFast; + + _ctx->cicla = true; + _ctx->bPrecache = true; + _ctx->countEnd = 0; + while (_ctx->cicla) { + if (This->_codec->endOfStream() && This->_codec->_bLoop == false) { + _ctx->countEnd++; + if (_ctx->countEnd == 3) break; } - /* Uncompresses the data being written into the temporary buffer */ - if (This->lastVolume == 0) - ZeroMemory(This->lpTempBuffer, This->dwBufferSize / 2); - else if (bPrecache) - This->lpCodec->Decompress(This->_file, This->lpTempBuffer, This->dwBufferSize / 2); + // Uncompresses the data being written into the temporary buffer + if (This->_lastVolume == 0) + ZeroMemory(This->_lpTempBuffer, This->_dwBufferSize / 2); + else if (_ctx->bPrecache) + This->_codec->decompress(This->_file.readStream(This->_file.size()), This->_lpTempBuffer, This->_dwBufferSize / 2); + + _ctx->bPrecache = false; - bPrecache = false; + // Waits for an event. Since they are all in automatic reset, there is no need to reset it after - /* Waits for an event. Since they are all in automatic reset, there is no need to reset it after */ + uint32 dwBufStatus; -// uint32 dwBufStatus; -// This->lpDSBuffer->GetStatus(&dwBufStatus); + CORO_INVOKE_4(CoroScheduler.waitForMultipleObjects, 5, _ctx->hList, false, CORO_INFINITE, &_ctx->dwResult); + // Check to determine which event has been set + if (CoroScheduler.getEvent(This->_hThreadEnd)->signalled) { + /* Must leave the thread */ + _ctx->cicla = false; + + } else if (CoroScheduler.getEvent(This->_hHot1)->signalled) { + // Must fill the second half of the buffer + This->lpDSBuffer->Lock(This->_dwBufferSize / 2, This->_dwBufferSize / 2, (void **)&_ctx->lpLockBuf, &_ctx->dwResult, (void **)&_ctx->lpLockBuf2, &_ctx->dwResult2, 0); -// sprintf(buf, "WFMO: %x (buf status: %x) MyThread: 0x%x\n", This->lpDSBuffer, dwBufStatus, GetCurrentThreadId()); -// warning(buf); - dwResult = WaitForMultipleObjects(5, hList, false, CORO_INFINITE); + copyMemory(_ctx->lpLockBuf, This->_lpTempBuffer, This->_dwBufferSize / 2); + This->lpDSBuffer->Unlock(_ctx->lpLockBuf, This->_dwBufferSize / 2, _ctx->lpLockBuf2, 0); - /* uint32 dwPlay, dwWrite; - This->lpDSBuffer->GetCurrentPosition(&dwPlay, &dwWrite); - sprintf(buf, "CP Play: %u, Write: %u\n", dwPlay, dwWrite); - warning(buf); */ + _ctx->bPrecache = true; - /* Make a switch to determine which event has been set */ - switch (dwResult - WAIT_OBJECT_0) { - case 0: - /* Must leave the thread */ - cicla = false; - break; - - case 1: - /* Must fill the second half of the buffer */ -// if (dwPlay >= This->dspnHot[0].dwOffset && dwPlay <= This->dspnHot[0].dwOffset+1024 ) - { -// sprintf(buf, "Prima met buffer: %x\n", This->lpDSBuffer); -// warning(buf); - This->lpDSBuffer->Lock(This->dwBufferSize / 2, This->dwBufferSize / 2, (void **)&lpLockBuf, &dwResult, (void **)&lpLockBuf2, &dwResult2, 0); - // sprintf(buf, "LockedBuf: dwResult=%x, dwBufferSize/2=%x, lpLockBuf2=%x, dwResult2=%x\n", dwResult, This->dwBufferSize/2, lpLockBuf2, dwResult2); - // warning(buf); - copyMemory(lpLockBuf, This->lpTempBuffer, This->dwBufferSize / 2); - This->lpDSBuffer->Unlock(lpLockBuf, This->dwBufferSize / 2, lpLockBuf2, 0); - bPrecache = true; - } - break; + } else if (CoroScheduler.getEvent(This->_hHot2)->signalled) { + This->lpDSBuffer->Lock(0, This->_dwBufferSize / 2, (void **)&_ctx->lpLockBuf, &_ctx->dwResult, NULL, NULL, 0); - case 2: - /* Must fill the first half of the buffer */ -// if (dwPlay >= This->dspnHot[1].dwOffset && dwPlay <= This->dspnHot[1].dwOffset+1024 ) - { -// sprintf(buf, "Seconda met buffer: %x\n", This->lpDSBuffer); -// warning(buf); - This->lpDSBuffer->Lock(0, This->dwBufferSize / 2, (void **)&lpLockBuf, &dwResult, NULL, NULL, 0); - copyMemory(lpLockBuf, This->lpTempBuffer, This->dwBufferSize / 2); - This->lpDSBuffer->Unlock(lpLockBuf, This->dwBufferSize / 2, NULL, NULL); - bPrecache = true; - } - break; + copyMemory(_ctx->lpLockBuf, This->_lpTempBuffer, This->_dwBufferSize / 2); + This->lpDSBuffer->Unlock(_ctx->lpLockBuf, This->_dwBufferSize / 2, NULL, NULL); + + _ctx->bPrecache = true; + + } else if (CoroScheduler.getEvent(This->_hHot3)->signalled) { + + if (This->_bSyncExit) { + CoroScheduler.setEvent(This->_syncToPlay->_hPlayThreadPlayFast); - case 3: { -// sprintf(buf, "End of buffer %x (SyncToPlay [%x]=%x, SyncExit: [%x]=%d)\n", This->lpDSBuffer, &This->SyncToPlay, This->SyncToPlay, &This->bSyncExit, This->bSyncExit); -// warning(buf); - if (This->bSyncExit) { -// sprintf(buf, "Go with sync (Buffer: %x) MyThread: %x!\n", This->SyncToPlay->lpDSBuffer, GetCurrentThreadId()); -// warning(buf); - //This->SyncToPlay->PlayFast(); - SetEvent(This->SyncToPlay->hPlayThread_PlayFast); // Transfer immediatly control to the other threads - Sleep(0); - This->bSyncExit = false; - cicla = false; + CORO_SLEEP(1); + + This->_bSyncExit = false; + _ctx->cicla = false; break; } - } - break; - - case 4: - This->PlayFast(); - break; + } else if (CoroScheduler.getEvent(This->_hPlayThreadPlayFast)->signalled) { + This->playFast(); } } - /* Close the DirectSound buffer */ -// sprintf(buf, "Exiting thread. Buffer = %x, MyThread = 0x%x\n", This->lpDSBuffer, GetCurrentThreadId()); -// warning(buf); + // Close the DirectSound buffer This->lpDSBuffer->Stop(); - - ExitThread(0); #endif + + CORO_END_CODE; } + /** * Unables or disables stream loop. * - * @param bLoop True enable loop, False disables it + * @param _bLoop True enable loop, False disables it * * @remarks The loop must be activated BEFORE the stream starts * playing. Any changes made during the play will have no * effect until the stream is stopped then played again. */ - void FPStream::setLoop(bool loop) { _bLoop = loop; } @@ -1025,38 +1382,38 @@ void FPStream::setLoop(bool loop) { * * @param bPause True enables pause, False disables it */ - void FPStream::pause(bool bPause) { + if (_bFileLoaded) { + if (bPause && _bIsPlaying) { #ifdef REFACTOR_ME + _lpDSBuffer->Stop(); +#endif + _bIsPlaying = false; + _bPaused = true; + } else if (!bPause && _bPaused) { +#ifdef REFACTOR_ME + _dspnHot[0].dwOffset = 32; + _dspnHot[0].hEventNotify = hHot1; - if (bFileLoaded) { - if (bPause && bIsPlaying) { - lpDSBuffer->Stop(); - bIsPlaying = false; - bPaused = true; - } else if (!bPause && bPaused) { - dspnHot[0].dwOffset = 32; - dspnHot[0].hEventNotify = hHot1; - - dspnHot[1].dwOffset = dwBufferSize / 2 + 32; - dspnHot[1].hEventNotify = hHot2; + _dspnHot[1].dwOffset = dwBufferSize / 2 + 32; + _dspnHot[1].hEventNotify = hHot2; - dspnHot[2].dwOffset = dwBufferSize - 32; //DSBPN_OFFSETSTOP; - dspnHot[2].hEventNotify = hHot3; + _dspnHot[2].dwOffset = dwBufferSize - 32; //DSBPN_OFFSETSTOP; + _dspnHot[2].hEventNotify = hHot3; if (FAILED(lpDSNotify->SetNotificationPositions(3, dspnHot))) { int a = 1; } - lpDSBuffer->Play(0, 0, bLoop); - bIsPlaying = true; - bPaused = false; + lpDSBuffer->Play(0, 0, _bLoop); +#endif + _bIsPlaying = true; + _bPaused = false; // Trick to reset the volume after a possible new sound configuration - SetVolume(lastVolume); + setVolume(_lastVolume); } } -#endif } /** diff --git a/engines/tony/sound.h b/engines/tony/sound.h index 4dd00a3028..38ce6de2a7 100644 --- a/engines/tony/sound.h +++ b/engines/tony/sound.h @@ -245,6 +245,24 @@ public: bool endOfBuffer() const; }; +/** + * Codec base class + */ +class CODEC { +protected: + bool _bEndReached; + +public: + bool _bLoop; + + CODEC(bool _bLoop = true); + virtual ~CODEC(); + virtual uint32 decompress(Common::SeekableReadStream *stream, void *lpBuf, uint32 dwSize) = 0; + virtual void loopReset() = 0; + bool endOfStream(); +}; + + class FPStream { private: // HWND hwnd; @@ -258,12 +276,12 @@ private: uint32 _dwSize; // Stream size (bytes) uint32 _dwCodec; // CODEC used - HANDLE _hThreadEnd; // Event used to close thread + uint32 _hThreadEnd; // Event used to close thread Common::File _file; // File handle used for the stream - HANDLE _hPlayThread; // Handle of the Play thread - HANDLE _hHot1, _hHot2, _hHot3; // Events set by DirectSoundNotify - HANDLE _hPlayThreadPlayFast; - HANDLE _hPlayThreadPlayNormal; + uint32 _hPlayThread; // Handle of the Play thread + uint32 _hHot1, _hHot2, _hHot3; // Events set by DirectSoundNotify + uint32 _hPlayThreadPlayFast; + uint32 _hPlayThreadPlayNormal; bool _bSoundSupported; // True if the sound is active bool _bFileLoaded; // True if the file is open @@ -273,6 +291,7 @@ private: bool _bPaused; int _lastVolume; FPStream *_syncToPlay; + CODEC *_codec; // DSBPOSITIONNOTIFY dspnHot[3]; @@ -286,7 +305,7 @@ private: * Thread playing the stream * */ - static void playThread(FPStream *This); + static void playThread(CORO_PARAM, const void *param); public: @@ -321,13 +340,13 @@ public: /** * Opens a file stream * - * @param lpszFile Filename to be opened + * @param fileName Filename to be opened * @param dwCodec CODEC to be used to uncompress samples * * @returns True is everything is OK, False otherwise */ - bool loadFile(const char *lpszFileName, uint32 dwCodec = FPCODEC_RAW, int nSync = 2000); + bool loadFile(const Common::String &fileName, uint32 dwCodec = FPCODEC_RAW, int nSync = 2000); /** * Closes a file stream (opened or not). diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 9e9e032e49..2c102f5c8b 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -187,10 +187,7 @@ void TonyEngine::GUIError(const Common::String &msg) { GUIErrorMessage(msg); } -void TonyEngine::playMusic(int nChannel, const char *fn, int nFX, bool bLoop, int nSync) { - warning("TODO: TonyEngine::playMusic"); -// g_system->lockMutex(csMusic); - +void TonyEngine::playMusic(int nChannel, const Common::String &fname, int nFX, bool bLoop, int nSync) { if (nChannel < 4) if (GLOBALS._flipflop) nChannel = nChannel + 1; @@ -207,64 +204,78 @@ void TonyEngine::playMusic(int nChannel, const char *fn, int nFX, bool bLoop, in break; } -#ifdef REFACTOR_ME - // Mette il path giusto - if (nChannel < 4) - GetDataDirectory(DD_MUSIC, path_buffer); - else - GetDataDirectory(DD_LAYER, path_buffer); - _splitpath(path_buffer, drive, dir, NULL, NULL); - _splitpath(fn, NULL, NULL, fname, ext); - _makepath(path_buffer, drive, dir, fname, ext); - - _makepath(path_buffer, drive, dir, fname, ext); - if (nFX == 22) { // Sync a tempo - curChannel = nChannel; - strcpy(nextMusic, path_buffer); - nextLoop = bLoop; - nextSync = nSync; - if (flipflop) - nextChannel = nChannel - 1; + GLOBALS._curChannel = nChannel; + GLOBALS._nextLoop = bLoop; + GLOBALS._nextSync = nSync; + if (GLOBALS._flipflop) + GLOBALS._nextChannel = nChannel - 1; else - nextChannel = nChannel + 1; - DWORD id; - HANDLE hThread = CreateThread(NULL, 10240, (LPTHREAD_START_ROUTINE)DoNextMusic, _stream, 0, &id); - SetThreadPriority(hThread, THREAD_PRIORITY_HIGHEST); + GLOBALS._nextChannel = nChannel + 1; + + uint32 hThread = CoroScheduler.createProcess(doNextMusic, &_stream, sizeof(FPStream ***)); + assert(hThread != CORO_INVALID_PID_VALUE); + } else if (nFX == 44) { // Cambia canale e lascia finire il primo - if (flipflop) - nextChannel = nChannel - 1; + if (GLOBALS._flipflop) + GLOBALS._nextChannel = nChannel - 1; else - nextChannel = nChannel + 1; + GLOBALS._nextChannel = nChannel + 1; - _stream[nextChannel]->Stop(); - _stream[nextChannel]->UnloadFile(); + _stream[GLOBALS._nextChannel]->stop(); + _stream[GLOBALS._nextChannel]->unloadFile(); if (!getIsDemo()) { - if (!_stream[nextChannel]->LoadFile(path_buffer, FPCODEC_ADPCM, nSync)) - theGame.Abort(); + if (!_stream[GLOBALS._nextChannel]->loadFile(fname, FPCODEC_ADPCM, nSync)) + _vm->abortGame(); } else { - _stream[nextChannel]->LoadFile(path_buffer, FPCODEC_ADPCM, nSync); + _stream[GLOBALS._nextChannel]->loadFile(fname, FPCODEC_ADPCM, nSync); } - _stream[nextChannel]->SetLoop(bLoop); - _stream[nextChannel]->Play(); + _stream[GLOBALS._nextChannel]->setLoop(bLoop); + _stream[GLOBALS._nextChannel]->play(); - flipflop = 1 - flipflop; + GLOBALS._flipflop = 1 - GLOBALS._flipflop; } else { if (!getIsDemo()) { - if (!_stream[nChannel]->LoadFile(path_buffer, FPCODEC_ADPCM, nSync)) - theGame.Abort(); + if (!_stream[nChannel]->loadFile(fname, FPCODEC_ADPCM, nSync)) + _vm->abortGame(); } else { - _stream[nChannel]->LoadFile(path_buffer, FPCODEC_ADPCM, nSync); + _stream[nChannel]->loadFile(fname, FPCODEC_ADPCM, nSync); } - _stream[nChannel]->SetLoop(bLoop); - _stream[nChannel]->Play(); + _stream[nChannel]->setLoop(bLoop); + _stream[nChannel]->play(); } -#endif +} -// g_system->unlockMutex(csMusic); +void TonyEngine::doNextMusic(CORO_PARAM, const void *param) { + CORO_BEGIN_CONTEXT; + Common::String fn; + CORO_END_CONTEXT(_ctx); + + FPStream **streams = *(FPStream ***)param; + + CORO_BEGIN_CODE(_ctx); + + if (!_vm->getIsDemo()) { + if (!streams[GLOBALS._nextChannel]->loadFile(GLOBALS._nextMusic, FPCODEC_ADPCM, GLOBALS._nextSync)) + _vm->abortGame(); + } else { + streams[GLOBALS._nextChannel]->loadFile(GLOBALS._nextMusic, FPCODEC_ADPCM, GLOBALS._nextSync); + } + + streams[GLOBALS._nextChannel]->setLoop(GLOBALS._nextLoop); + streams[GLOBALS._nextChannel]->prefetch(); + + streams[GLOBALS._curChannel]->stop(true); + streams[GLOBALS._curChannel]->waitForSync(streams[GLOBALS._nextChannel]); + + streams[GLOBALS._curChannel]->unloadFile(); + + GLOBALS._flipflop = 1 - GLOBALS._flipflop; + + CORO_END_CODE; } void TonyEngine::playSFX(int nChannel, int nFX) { diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 5f6fd8cb44..94dc3de92d 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -87,6 +87,8 @@ private: void closeVoiceDatabase(); void initCustomFunctionMap(); static void playProcess(CORO_PARAM, const void *param); + static void doNextMusic(CORO_PARAM, const void *param); + protected: // Engine APIs virtual Common::Error run(); @@ -183,7 +185,7 @@ public: // Music // ****** - void playMusic(int nChannel, const char *fn, int nFX, bool bLoop, int nSync); + void playMusic(int nChannel, const Common::String &fn, int nFX, bool bLoop, int nSync); void stopMusic(int nChannel); void playSFX(int nSfx, int nFX = 0); -- cgit v1.2.3 From b8d5e17fefd2a36e253a150fee324c912ca35384 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 19 Jun 2012 21:14:56 +1000 Subject: TONY: Added an extra check for shouldQuit into the main event loop --- engines/tony/input.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp index 2a8cdc10c3..7d663c1465 100644 --- a/engines/tony/input.cpp +++ b/engines/tony/input.cpp @@ -52,7 +52,7 @@ void RMInput::poll() { _leftClickMouse = _leftReleaseMouse = _rightClickMouse = _rightReleaseMouse = false; // Get pending events - while (g_system->getEventManager()->pollEvent(_event)) { + while (g_system->getEventManager()->pollEvent(_event) && !_vm->shouldQuit()) { switch (_event.type) { case Common::EVENT_MOUSEMOVE: case Common::EVENT_LBUTTONDOWN: -- cgit v1.2.3 From 9d437a26dd296d6cf7e4db4749a90cafe9787377 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 19 Jun 2012 21:19:17 +1000 Subject: TONY: Fix some compiler warnings in the newly added sound code --- engines/tony/sound.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index 484b279cda..e4f46af146 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -266,7 +266,7 @@ uint32 CODECADPCMMONO::decompress(Common::SeekableReadStream *stream, void *buf, uint16 *lpBuf = (uint16 *)buf; byte *inp; int bufferstep; - int cache; + int cache = 0; int delta; int sign; int vpdiff; @@ -348,7 +348,7 @@ uint32 CODECADPCMSTEREO::decompress(Common::SeekableReadStream *stream, void *bu uint16 *lpBuf=(uint16 *)buf; byte *inp; int bufferstep; - int cache; + int cache = 0; int delta; int sign; int vpdiff; @@ -1015,7 +1015,7 @@ bool FPStream::unloadFile() { } void FPStream::prefetch() { - void *lpBuf; + void *lpBuf = NULL; if (!_bSoundSupported || !_bFileLoaded) return; @@ -1042,6 +1042,8 @@ void FPStream::prefetch() { _vm->GUIError("Cannot lock stream buffer!", "soundLoadStream()"); return; } +#else + error("lpBuf isn't set"); #endif // Uncompress the data from the stream directly into the locked buffer -- cgit v1.2.3 From d2061f29bef9f2dadd5eda149384b5fdfbcc3ac1 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 19 Jun 2012 22:06:30 +1000 Subject: TONY: Added initialisation of FPSound fields in it's constructor --- engines/tony/sound.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index e4f46af146..e79b06191e 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -828,8 +828,18 @@ FPStream::FPStream(bool bSoundOn) { _bFileLoaded = false; _bIsPlaying = false; _bPaused = false; + _bLoop = false; + _bDoFadeOut = false; _bSyncExit = false; - _hHot1 = _hHot2 = _hHot3 = _hPlayThreadPlayFast = _hPlayThreadPlayNormal = CORO_INVALID_PID_VALUE; + _hHot1 = _hHot2 = _hHot3 = CORO_INVALID_PID_VALUE; + _hPlayThread = _hPlayThreadPlayFast = _hPlayThreadPlayNormal = CORO_INVALID_PID_VALUE; + _hThreadEnd = CORO_INVALID_PID_VALUE; + _dwBufferSize = _dwSize = 0; + _dwCodec = 0; + _lastVolume = 0; + _lpTempBuffer = NULL; + _syncToPlay = NULL; + _codec = NULL; } bool FPStream::createBuffer(int nBufSize) { -- cgit v1.2.3 From aa775b4497746d978599dda06ca9a385c5e6dc59 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 19 Jun 2012 22:37:56 +1000 Subject: TONY: Some bugfixes and cleanup for the music support code --- engines/tony/globals.cpp | 1 - engines/tony/globals.h | 4 +--- engines/tony/sound.cpp | 3 ++- engines/tony/tony.cpp | 6 ++++-- 4 files changed, 7 insertions(+), 7 deletions(-) (limited to 'engines') diff --git a/engines/tony/globals.cpp b/engines/tony/globals.cpp index 893322942a..f28a22e4a5 100644 --- a/engines/tony/globals.cpp +++ b/engines/tony/globals.cpp @@ -26,7 +26,6 @@ namespace Tony { Globals::Globals() { - Common::fill(_nextMusic, _nextMusic + MAX_PATH, 0); _nextLoop = false; _nextChannel = 0; _nextSync = 0; diff --git a/engines/tony/globals.h b/engines/tony/globals.h index 7b5d6db9cf..b63dce7c45 100644 --- a/engines/tony/globals.h +++ b/engines/tony/globals.h @@ -43,8 +43,6 @@ namespace Tony { #define TAPPETI_MARE 6 #define TAPPETI_MAREMETA 7 -#define MAX_PATH 255 - struct CharacterStruct { uint32 _code; RMItem *_item; @@ -168,7 +166,7 @@ class Globals { public: Globals(); - char _nextMusic[MAX_PATH]; + Common::String _nextMusic; bool _nextLoop; int _nextChannel; int _nextSync; diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index e79b06191e..75ae82298d 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -1053,7 +1053,8 @@ void FPStream::prefetch() { return; } #else - error("lpBuf isn't set"); + // Return, since lpBuf hasn't been set + return; #endif // Uncompress the data from the stream directly into the locked buffer diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 2c102f5c8b..8ae95af862 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -208,12 +208,14 @@ void TonyEngine::playMusic(int nChannel, const Common::String &fname, int nFX, b GLOBALS._curChannel = nChannel; GLOBALS._nextLoop = bLoop; GLOBALS._nextSync = nSync; + GLOBALS._nextMusic = fname; + if (GLOBALS._flipflop) GLOBALS._nextChannel = nChannel - 1; else GLOBALS._nextChannel = nChannel + 1; - uint32 hThread = CoroScheduler.createProcess(doNextMusic, &_stream, sizeof(FPStream ***)); + uint32 hThread = CoroScheduler.createProcess(doNextMusic, NULL, 0); assert(hThread != CORO_INVALID_PID_VALUE); } else if (nFX == 44) { // Cambia canale e lascia finire il primo @@ -254,7 +256,7 @@ void TonyEngine::doNextMusic(CORO_PARAM, const void *param) { Common::String fn; CORO_END_CONTEXT(_ctx); - FPStream **streams = *(FPStream ***)param; + FPStream **streams = _vm->_stream; CORO_BEGIN_CODE(_ctx); -- cgit v1.2.3 From 1ee68078c1272287db82f819f2fdc99c6fe04622 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Wed, 20 Jun 2012 17:58:01 +0200 Subject: TONY: Replace the FPStream code. This just removes the original code and replaces it with a quickly- written trivial implementation similar to clone2727's sfx code. It seems to at least sort of work. :-) --- engines/tony/sound.cpp | 937 ++++--------------------------------------------- engines/tony/sound.h | 32 +- engines/tony/tony.cpp | 2 +- 3 files changed, 79 insertions(+), 892 deletions(-) (limited to 'engines') diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index 75ae82298d..b0a2c69fd6 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -36,401 +36,6 @@ namespace Tony { - -#define RELEASE(x) {if ((x) != NULL) { (x)->release(); x = NULL; }} - - -/****************************************************************************\ -***************************************************************************** -* class CODECRAW -* -------------- -* Description: CODEC to play hard from pure samples -***************************************************************************** -\****************************************************************************/ - -class CODECRAW : public CODEC { -public: - CODECRAW(bool _bLoop = true); - - virtual ~CODECRAW(); - virtual uint32 decompress(Common::SeekableReadStream *stream, void *lpBuf, uint32 dwSize); - virtual void loopReset(); -}; - - -/****************************************************************************\ -***************************************************************************** -* class CODECADPCM -* ---------------- -* Description: Play ADPCM compressed data -***************************************************************************** -\****************************************************************************/ - -class CODECADPCM : public CODECRAW { -protected: - byte *lpTemp; - static const int indexTable[16]; - static const int stepSizeTable[89]; - -public: - CODECADPCM(bool _bLoop = true, byte *lpTempBuffer = NULL); - virtual ~CODECADPCM(); - virtual uint32 decompress(Common::SeekableReadStream *stream, void *lpBuf, uint32 dwSize) = 0; - virtual void loopReset() = 0; -}; - -class CODECADPCMSTEREO : public CODECADPCM { -protected: - int valpred[2], index[2]; - -public: - CODECADPCMSTEREO(bool _bLoop=true, byte *lpTempBuffer = NULL); - virtual ~CODECADPCMSTEREO(); - virtual uint32 decompress(Common::SeekableReadStream *stream, void *lpBuf, uint32 dwSize); - virtual void loopReset(); -}; - -class CODECADPCMMONO : public CODECADPCM { -protected: - int valpred, index; - -public: - CODECADPCMMONO(bool _bLoop = true, byte *lpTempBuffer = NULL); - virtual ~CODECADPCMMONO(); - virtual uint32 decompress(Common::SeekableReadStream *stream, void *lpBuf, uint32 dwSize); - virtual void loopReset(); -}; - -/****************************************************************************\ -* CODEC Methods -\****************************************************************************/ - -/** - * Standard cosntructor. It's possible to specify whether you want to - * enable or disable the loop (which by default, and 'active). - * - * @param loop True if you want to loop, false to disable - */ -CODEC::CODEC(bool loop) { - _bLoop = loop; - _bEndReached = false; -} - -CODEC::~CODEC() { -} - -/** - * Tell whether we have reached the end of the stream - * - * @return True if we're done, false otherwise. - */ -bool CODEC::endOfStream() { - return _bEndReached; -} - - -/****************************************************************************\ -* CODECRAW Methods -\****************************************************************************/ - -/** - * Standard cosntructor. Simply calls the inherited constructor - */ -CODECRAW::CODECRAW(bool loop) : CODEC(loop) { -} - -CODECRAW::~CODECRAW() { -} - -/** - * Reset the stream to the beginning of the file. In the case of RAW files, does nothing - */ -void CODECRAW::loopReset() { -} - -/** - * Manage the RAW format. Simply copies the file's stream buffer - * - * @return Indicates the position of the file for the end of the loop - */ -uint32 CODECRAW::decompress(Common::SeekableReadStream *stream, void *buf, uint32 dwSize) { - byte *lpBuf = (byte *)buf; - uint32 dwRead; - uint32 dwEOF; - - _bEndReached = false; - dwEOF = 0; - dwRead = stream->read(lpBuf, dwSize); - - if (dwRead < dwSize) { - dwEOF = dwRead; - _bEndReached = true; - - if (!_bLoop) { - Common::fill(lpBuf + dwRead, lpBuf + dwRead + (dwSize - dwRead), 0); - } else { - stream->seek(0); - dwRead = stream->read(lpBuf + dwRead, dwSize - dwRead); - } - } - - return dwEOF; -} - -/****************************************************************************\ -* CODECADPCM Methods -\****************************************************************************/ - -const int CODECADPCM::indexTable[16] = { - -1, -1, -1, -1, 2, 4, 6, 8, - -1, -1, -1, -1, 2, 4, 6, 8, -}; - -const int CODECADPCM::stepSizeTable[89] = { - 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, - 19, 21, 23, 25, 28, 31, 34, 37, 41, 45, - 50, 55, 60, 66, 73, 80, 88, 97, 107, 118, - 130, 143, 157, 173, 190, 209, 230, 253, 279, 307, - 337, 371, 408, 449, 494, 544, 598, 658, 724, 796, - 876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066, - 2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358, - 5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899, - 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767 -}; - -#define MAXDECODESIZE (44100 * 2 * 2) - -/** - * Standard constructor. Initialises and allocates temporary memory tables - */ -CODECADPCM::CODECADPCM(bool loop, byte *lpTempBuffer) : CODECRAW(loop) { - // Alloca la memoria temporanea - if (lpTempBuffer != NULL) { - lpTemp = lpTempBuffer; - } else { - lpTemp = (byte *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, MAXDECODESIZE); - - if (lpTemp == NULL) { - error("Insufficient memory!"); - return; - } - } -} - - -CODECADPCMMONO::CODECADPCMMONO(bool loop, byte *lpTempBuffer) : CODECADPCM(loop,lpTempBuffer) { - // Inizializza per il playing - loopReset(); -} - -CODECADPCMMONO::~CODECADPCMMONO() { -} - - -CODECADPCMSTEREO::CODECADPCMSTEREO(bool loop, byte *lpTempBuffer) : CODECADPCM(loop, lpTempBuffer) { - // Initialise for playing - loopReset(); -} - -CODECADPCMSTEREO::~CODECADPCMSTEREO() { -} - -/** - * Destructor. Free the buffer - */ -CODECADPCM::~CODECADPCM() { - globalDestroy(lpTemp); -} - - -/** - * Reset the player before each play or loop - */ -void CODECADPCMSTEREO::loopReset() { - valpred[0] = 0; - valpred[1] = 0; - index[0] = 0; - index[1] = 0; -} - -void CODECADPCMMONO::loopReset() { - valpred = 0; - index = 0; -} - - -/** - * Manages decompressing the ADPCM 16:4 format. - */ -uint32 CODECADPCMMONO::decompress(Common::SeekableReadStream *stream, void *buf, uint32 dwSize) { - uint16 *lpBuf = (uint16 *)buf; - byte *inp; - int bufferstep; - int cache = 0; - int delta; - int sign; - int vpdiff; - uint32 eof, i; - int step; - - bufferstep = 1; - step = stepSizeTable[index]; - - // Invokes the raw codec to read the stream from disk to loop. - eof = CODECRAW::decompress(stream, lpTemp, dwSize / 4); - inp = lpTemp; - - eof *= 2; - - // If you must do an immediate loop - if (endOfStream() && eof == 0) { - loopReset(); - bufferstep = 1; - step = stepSizeTable[index]; - } else if (!endOfStream()) - eof = 0; - - dwSize /= 2; - for (i = 0; i < dwSize; i++) { - // Check if we are at the end of the file, and are looping - if (eof != 0 && i == eof) { - loopReset(); - bufferstep=1; - step = stepSizeTable[index]; - } - - // Read the delta (4 bits) - if (bufferstep) { - cache = *inp++; - delta = (cache >> 4) & 0xF; - } else - delta = cache & 0xF; - - // Find the new index - index += indexTable[delta]; - if (index < 0) index = 0; - if (index > 88) index = 88; - - // Reads the sign and separates it - sign = delta & 8; - delta = delta & 7; - - // Find the difference from the previous value - vpdiff = step >> 3; - if (delta & 4) vpdiff += step; - if (delta & 2) vpdiff += step >> 1; - if (delta & 1) vpdiff += step >> 2; - - if (sign) - valpred -= vpdiff; - else - valpred += vpdiff; - - // Check the limits of the found value - if (valpred > 32767) - valpred = 32767; - else if (valpred < -32768) - valpred = -32768; - - // Update the step - step = stepSizeTable[index]; - - // Write the value found - *lpBuf++ = (uint16)valpred; - - bufferstep = !bufferstep; - } - - return eof / 2; -} - -uint32 CODECADPCMSTEREO::decompress(Common::SeekableReadStream *stream, void *buf, uint32 dwSize) { - uint16 *lpBuf=(uint16 *)buf; - byte *inp; - int bufferstep; - int cache = 0; - int delta; - int sign; - int vpdiff; - uint32 eof, i; - int step[2]; - - bufferstep = 1; - step[0] = stepSizeTable[index[0]]; - step[1] = stepSizeTable[index[1]]; - - // Invokes the RAW codec to read the stream from disk. - eof = CODECRAW::decompress(stream, lpTemp, dwSize / 4); - inp = lpTemp; - - eof *= 2; - - // If you must do an immediate loop - if (endOfStream() && eof == 0) { - loopReset(); - bufferstep = 1; - step[0] = stepSizeTable[index[0]]; - step[1] = stepSizeTable[index[1]]; - - } else if (!endOfStream()) - eof = 0; - - dwSize /= 2; - - for (i = 0;i < dwSize; i++) { - // If you must do an immediate loop - if (eof != 0 && i == eof) { - loopReset(); - bufferstep = 1; - step[0] = stepSizeTable[index[0]]; - step[1] = stepSizeTable[index[1]]; - } - - // Reads the delta (4 bits) - if (bufferstep) { - cache = *inp++; - delta = cache & 0xF; - } else - delta = (cache >> 4) & 0xF; - - // Find the new index - index[bufferstep] += indexTable[delta]; - if (index[bufferstep] < 0) index[bufferstep] = 0; - if (index[bufferstep] > 88) index[bufferstep] = 88; - - // Reads the sign and separates it - sign = delta & 8; - delta = delta & 7; - - // Find the difference from the previous value - vpdiff = step[bufferstep] >> 3; - if (delta & 4) vpdiff += step[bufferstep]; - if (delta & 2) vpdiff += step[bufferstep] >> 1; - if (delta & 1) vpdiff += step[bufferstep] >> 2; - - if (sign) - valpred[bufferstep] -= vpdiff; - else - valpred[bufferstep] += vpdiff; - - // Check the limits of the value - if (valpred[bufferstep] > 32767) - valpred[bufferstep] = 32767; - else if (valpred[bufferstep] < -32768) - valpred[bufferstep] =- 32768; - - // Update the step - step[bufferstep] = stepSizeTable[index[bufferstep]]; - - // Write the found value - *lpBuf++ = (uint16)valpred[bufferstep]; - - bufferstep = !bufferstep; - } - - return eof / 2; -} - /****************************************************************************\ * FPSOUND Methods \****************************************************************************/ @@ -818,94 +423,17 @@ void FPSfx::soundCheckProcess(CORO_PARAM, const void *param) { * create it using FPSound::CreateStream() */ FPStream::FPStream(bool bSoundOn) { -#ifdef REFACTOR_ME - hwnd=hWnd; - lpDS = LPDS; - _lpDSBuffer = NULL; - _lpDSNotify = NULL; -#endif _bSoundSupported = bSoundOn; _bFileLoaded = false; - _bIsPlaying = false; _bPaused = false; _bLoop = false; _bDoFadeOut = false; _bSyncExit = false; - _hHot1 = _hHot2 = _hHot3 = CORO_INVALID_PID_VALUE; - _hPlayThread = _hPlayThreadPlayFast = _hPlayThreadPlayNormal = CORO_INVALID_PID_VALUE; - _hThreadEnd = CORO_INVALID_PID_VALUE; _dwBufferSize = _dwSize = 0; - _dwCodec = 0; _lastVolume = 0; - _lpTempBuffer = NULL; _syncToPlay = NULL; - _codec = NULL; -} - -bool FPStream::createBuffer(int nBufSize) { -#ifdef REFACTOR_ME - static PCMWAVEFORMAT pcmwf; - static DSBUFFERDESC dsbdesc; - static HRESULT err; - static char errbuf[128]; - - if (bSoundSupported == false) - return true; - - /* Set the required structures for the creation of a secondary buffer for the stream containing exactly 1 second of music. - Also activate the volume control, in order to lower and raise the volume of the music regardless of the general volume. - Obviously it is a buffer in RAM */ - - pcmwf.wBitsPerSample = 16; - pcmwf.wf.wFormatTag = WAVE_FORMAT_PCM; - pcmwf.wf.nChannels = 2; - pcmwf.wf.nSamplesPerSec = 44100; - pcmwf.wf.nBlockAlign = (pcmwf.wBitsPerSample / 8) * pcmwf.wf.nChannels; - pcmwf.wf.nAvgBytesPerSec = (uint32)pcmwf.wf.nBlockAlign * (uint32)pcmwf.wf.nSamplesPerSec; - - dsbdesc.dwSize = sizeof(dsbdesc); - dsbdesc.dwFlags = DSBCAPS_CTRLVOLUME | DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLPOSITIONNOTIFY; - dwBufferSize = dsbdesc.dwBufferBytes = (((uint32)(pcmwf.wf.nAvgBytesPerSec * nBufSize) / 1000 + 31) / 32) * 32; - dsbdesc.lpwfxFormat = (LPWAVEFORMATEX) & pcmwf; - - if ((err = lpDS->CreateSoundBuffer(&dsbdesc, &lpDSBuffer, NULL)) != DS_OK) { - wsprintf(errbuf, "Error creating the secondary buffer (%lx)", err); - MessageBox(hwnd, errbuf, "FPStream::FPStream()", MB_OK); - bSoundSupported = false; - return false; - } - SetVolume(63); - - - /* Create an alert when key positions are reached in the stream. - Key positions are located, respectively, immediately after - the start and immediately after the middle of the buffer */ - err = lpDSBuffer->QueryInterface(IID_IDirectSoundNotify, (void **)&lpDSNotify); - - if (FAILED(err)) { - wsprintf(errbuf, "Error creating notify object! (%lx)", err); - MessageBox(hwnd, errbuf, "FPStream::FPStream()", MB_OK); - bSoundSupported = false; - return false; - } - - hHot1 = CreateEvent(NULL, false, false, NULL); - hHot2 = CreateEvent(NULL, false, false, NULL); - hHot3 = CreateEvent(NULL, false, false, NULL); - hPlayThread_PlayFast = CreateEvent(NULL, false, false, NULL); - - dspnHot[0].dwOffset = 32; - dspnHot[0].hEventNotify = hHot1; - - dspnHot[1].dwOffset = dwBufferSize / 2 + 32; - dspnHot[1].hEventNotify = hHot2; - - dspnHot[2].dwOffset = dwBufferSize - 32; //DSBPN_OFFSETSTOP; - dspnHot[2].hEventNotify = hHot3; - - lpDSNotify->SetNotificationPositions(3, dspnHot); -#endif - return true; + _loopStream = NULL; + _rewindableStream = NULL; } /** @@ -918,38 +446,13 @@ FPStream::~FPStream() { if (!_bSoundSupported) return; - if (_bIsPlaying) + if (g_system->getMixer()->isSoundHandleActive(_handle)) stop(); if (_bFileLoaded) unloadFile(); - if (_hHot1) { - CoroScheduler.closeEvent(_hHot1); - _hHot1 = CORO_INVALID_PID_VALUE; - } - if (_hHot2) { - CoroScheduler.closeEvent(_hHot2); - _hHot2 = CORO_INVALID_PID_VALUE; - } - if (_hHot3) { - CoroScheduler.closeEvent(_hHot3); - _hHot3 = CORO_INVALID_PID_VALUE; - } - if (_hPlayThreadPlayFast != CORO_INVALID_PID_VALUE) { - CoroScheduler.closeEvent(_hPlayThreadPlayFast); - _hPlayThreadPlayFast = CORO_INVALID_PID_VALUE; - } - if (_hPlayThreadPlayNormal != CORO_INVALID_PID_VALUE) { - CoroScheduler.closeEvent(_hPlayThreadPlayNormal); - _hPlayThreadPlayNormal = CORO_INVALID_PID_VALUE; - } - _syncToPlay = NULL; -#ifdef REFACTOR_ME - RELEASE(lpDSNotify); - RELEASE(lpDSBuffer); -#endif } /** @@ -976,13 +479,12 @@ bool FPStream::loadFile(const Common::String &fileName, uint32 dwCodType, int nB if (!_bSoundSupported) return true; + if (_bFileLoaded) + unloadFile(); + // Save the codec type _dwCodec = dwCodType; - // Create the buffer - if (!createBuffer(nBufSize)) - return true; - // Open the file stream for reading if (!_file.open(fileName)) return false; @@ -990,11 +492,26 @@ bool FPStream::loadFile(const Common::String &fileName, uint32 dwCodType, int nB // Save the size of the stream _dwSize = _file.size(); + switch (_dwCodec) { + case FPCODEC_RAW: + _rewindableStream = Audio::makeRawStream(&_file, 44100, Audio::FLAG_16BITS | Audio::FLAG_LITTLE_ENDIAN | Audio::FLAG_STEREO, DisposeAfterUse::NO); + break; + + case FPCODEC_ADPCM: + _rewindableStream = Audio::makeADPCMStream(&_file, DisposeAfterUse::NO, 0, Audio::kADPCMDVI, 44100, 2); + break; + + default: + _file.close(); + return false; + } + // All done _bFileLoaded = true; - _bIsPlaying = false; _bPaused = false; + setVolume(63); + return true; } @@ -1011,12 +528,12 @@ bool FPStream::unloadFile() { if (!_bSoundSupported || !_bFileLoaded) return true; + assert(!g_system->getMixer()->isSoundHandleActive(_handle)); + /* Closes the file handle stream */ + delete _loopStream; + delete _rewindableStream; _file.close(); -#ifdef REFACTOR_ME - RELEASE(lpDSNotify); - RELEASE(lpDSBuffer); -#endif // Flag that the file is no longer in memory _bFileLoaded = false; @@ -1024,96 +541,6 @@ bool FPStream::unloadFile() { return true; } -void FPStream::prefetch() { - void *lpBuf = NULL; - - if (!_bSoundSupported || !_bFileLoaded) - return; - - // Allocates a temporary buffer - _lpTempBuffer = (byte *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, _dwBufferSize / 2); - if (_lpTempBuffer == NULL) - return; - - if (_dwCodec == FPCODEC_RAW) { - _codec = new CODECRAW(_bLoop); - } else if (_dwCodec == FPCODEC_ADPCM) { - _codec = new CODECADPCMSTEREO(_bLoop); - } else { - return; - } - - // reset the file position - _file.seek(0); - -#ifdef REFACTOR_ME - // Fills the buffer for the data already ready - if ((err = lpDSBuffer->Lock(0, dwBufferSize / 2, &lpBuf, (uint32 *)&dwHi, NULL, NULL, 0)) != DS_OK) { - _vm->GUIError("Cannot lock stream buffer!", "soundLoadStream()"); - return; - } -#else - // Return, since lpBuf hasn't been set - return; -#endif - - // Uncompress the data from the stream directly into the locked buffer - _codec->decompress(_file.readStream(_file.size()), lpBuf, _dwBufferSize / 2); - - // Unlock the buffer -#ifdef REFACTOR_ME - lpDSBuffer->unlock(lpBuf, _dwBufferSize / 2, NULL, NULL); -#endif - - // Create a thread to play the stream - _hThreadEnd = CoroScheduler.createEvent(false, false); - _hPlayThread = CoroScheduler.createProcess(playThread, this, sizeof(FPStream *)); - - // Start to play the buffer -#ifdef REFACTOR_ME - lpDSBuffer->setCurrentPosition(0); -#endif - _bIsPlaying = true; - -#ifdef REFACTOR_ME - _dspnHot[0].dwOffset = 32; - _dspnHot[0].hEventNotify = _hHot1; - - _dspnHot[1].dwOffset = dwBufferSize / 2 + 32; - _dspnHot[1].hEventNotify = _hHot2; - - _dspnHot[2].dwOffset = dwBufferSize - 32; //DSBPN_OFFSETSTOP; - _dspnHot[2].hEventNotify = _hHot3; - - if (FAILED(lpDSNotify->SetNotificationPositions(3, dspnHot))) { - int a = 1; - } -#endif -} - -void FPStream::playFast() { -#ifdef REFACTOR_ME - dspnHot[0].dwOffset = 32; - dspnHot[0].hEventNotify = hHot1; - - dspnHot[1].dwOffset = dwBufferSize / 2 + 32; - dspnHot[1].hEventNotify = hHot2; - - dspnHot[2].dwOffset = dwBufferSize - 32; //DSBPN_OFFSETSTOP; - dspnHot[2].hEventNotify = hHot3; - - lpDSBuffer->Stop(); - - if (FAILED(lpDSNotify->SetNotificationPositions(3, dspnHot))) { - warning("PlayFast SNP failed!"); - } - - if (FAILED(lpDSBuffer->Play(0, 0, DSBPLAY_LOOPING))) { - warning("PlayFast failed!\n"); - } -#endif -} - /** * Play the stream. * @@ -1121,79 +548,27 @@ void FPStream::playFast() { */ bool FPStream::play() { -#ifdef REFACTOR_ME - uint32 dwId; - void *lpBuf; - uint32 dwHi; - HRESULT err; - - if (!bSoundSupported || !bFileLoaded) - return false; - - /* Allocate a temporary buffer */ - lpTempBuffer = (byte *)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, dwBufferSize / 2); - if (lpTempBuffer == NULL) - return false; - - switch (dwCodec) { - case FPCODEC_RAW: - _codec = new CODECRAW(_bLoop); - break; - - case FPCODEC_ADPCM: - _codec = new CODECADPCMSTEREO(_bLoop); - break; - - default: + if (!_bSoundSupported || !_bFileLoaded) return false; - } - - /* Reset the file position */ - _file.seek(0); - lpDSBuffer->Stop(); - lpDSBuffer->SetCurrentPosition(0); - - /* Fills the buffer for the data already ready */ - if ((err = lpDSBuffer->Lock(0, dwBufferSize / 2, &lpBuf, (uint32 *)&dwHi, NULL, NULL, 0)) != DS_OK) { - error("Cannot lock stream buffer!", "soundLoadStream()"); - } - - /* Uncompress the data from the stream directly into the locked buffer */ - _codec->Decompress(hFile, lpBuf, dwBufferSize / 2); - - /* Unlock the buffer */ - lpDSBuffer->Unlock(lpBuf, dwBufferSize / 2, NULL, NULL); - - /* Create a thread to play the stream */ - hThreadEnd = CreateEvent(NULL, false, false, NULL); - hPlayThread = CreateThread(NULL, 10240, (LPTHREAD_START_ROUTINE)PlayThread, (void *)this, 0, &dwId); - SetThreadPriority(hPlayThread, THREAD_PRIORITY_HIGHEST); - SetEvent(hPlayThread_PlayFast); + stop(); -#if 0 - /* Start to play the buffer */ - lpDSBuffer->SetCurrentPosition(0); + _rewindableStream->rewind(); - dspnHot[0].dwOffset = 32; - dspnHot[0].hEventNotify = hHot1; + Audio::AudioStream *stream = _rewindableStream; - dspnHot[1].dwOffset = dwBufferSize / 2 + 32; - dspnHot[1].hEventNotify = hHot2; + if (_bLoop) { + if (!_loopStream) + _loopStream = new Audio::LoopingAudioStream(_rewindableStream, 0, DisposeAfterUse::NO); - dspnHot[2].dwOffset = dwBufferSize - 32; //DSBPN_OFFSETSTOP; - dspnHot[2].hEventNotify = hHot3; - - if (FAILED(lpDSNotify->SetNotificationPositions(3, dspnHot))) { - int a = 1; + stream = _loopStream; } + // FIXME: Should this be kMusicSoundType or KPlainSoundType? + g_system->getMixer()->playStream(Audio::Mixer::kMusicSoundType, &_handle, stream, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO); + setVolume(_lastVolume); + _bPaused = false; - lpDSBuffer->Play(0, 0, DSBPLAY_LOOPING); -#endif - - bIsPlaying = true; -#endif return true; } @@ -1205,177 +580,37 @@ bool FPStream::play() { */ bool FPStream::stop(bool bSync) { -#ifdef REFACTOR_ME - - if (!bSoundSupported) + if (!_bSoundSupported) return true; - if (!bFileLoaded) + if (!_bFileLoaded) return false; - if (!bIsPlaying) + if (!g_system->getMixer()->isSoundHandleActive(_handle)) return false; if (bSync) { -// bSyncExit = true; -// lpDSBuffer->Stop(); -// lpDSBuffer->Play(0, 0, 0); + // The caller intends to call waitForSync. + // FIXME: Why call this in that case?! Looks like old code. Remove that parameter. return true; } else { - /* Close the DirectSound buffer */ - lpDSBuffer->Stop(); - - /* Notify the thread is should stop */ - SetEvent(hThreadEnd); - WaitForSingleObject(hPlayThread, CORO_INFINITE); - - /* Closes the handle used by the stream and free its memory */ - CloseHandle(hPlayThread); - CloseHandle(hThreadEnd); - GlobalFree(lpTempBuffer); - - /* Close and free the CODEC */ - delete _codec; + g_system->getMixer()->stopHandle(_handle); - bIsPlaying = false; - bPaused = false; + _bPaused = false; } -#endif + return true; } void FPStream::waitForSync(FPStream *toplay) { -#ifdef REFACTOR_ME - if (!bSoundSupported) - return; - - if (!bFileLoaded) - return; - - if (!bIsPlaying) - return; - - SyncToPlay = toplay; - bSyncExit = true; - - char buf[1024]; - sprintf(buf, "Wait for sync: %x (SyncToPlay: [%x]=%x, SyncExit: [%x]=%d) MyThread: 0x%x\n", - this->lpDSBuffer, &this->SyncToPlay, SyncToPlay, &bSyncExit, bSyncExit, GetCurrentThreadId()); - warning(buf); - - WaitForSingleObject(hPlayThread, CORO_INFINITE); - - /* Closes the handle used by the stream and free its memory */ - CloseHandle(hPlayThread); - CloseHandle(hThreadEnd); - GlobalFree(lpTempBuffer); - - /* Close and free the CODEC */ - delete _codec; -#endif - _bIsPlaying = false; -} - -/** - * Thread playing the stream - * - */ - -void FPStream::playThread(CORO_PARAM, const void *param) { - CORO_BEGIN_CONTEXT; - byte *lpLockBuf; - uint32 dwResult; - byte *lpLockBuf2; - uint32 dwResult2; - bool cicla; - uint32 countEnd; - bool bPrecache; - char buf[1024]; - uint32 hList[5]; - CORO_END_CONTEXT(_ctx); - -// FPStream *This = *(FPStream **)param; - - CORO_BEGIN_CODE(_ctx); -#ifdef REFACTOR_ME - // Events that signal when you need to do something - _ctx->hList[0] = This->_hThreadEnd; - _ctx->hList[1] = This->_hHot1; - _ctx->hList[2] = This->_hHot2; - _ctx->hList[3] = This->_hHot3; - _ctx->hList[4] = This->_hPlayThreadPlayFast; - - _ctx->cicla = true; - _ctx->bPrecache = true; - _ctx->countEnd = 0; - while (_ctx->cicla) { - if (This->_codec->endOfStream() && This->_codec->_bLoop == false) { - _ctx->countEnd++; - if (_ctx->countEnd == 3) - break; - } - - // Uncompresses the data being written into the temporary buffer - if (This->_lastVolume == 0) - ZeroMemory(This->_lpTempBuffer, This->_dwBufferSize / 2); - else if (_ctx->bPrecache) - This->_codec->decompress(This->_file.readStream(This->_file.size()), This->_lpTempBuffer, This->_dwBufferSize / 2); - - _ctx->bPrecache = false; - - // Waits for an event. Since they are all in automatic reset, there is no need to reset it after - - uint32 dwBufStatus; - - CORO_INVOKE_4(CoroScheduler.waitForMultipleObjects, 5, _ctx->hList, false, CORO_INFINITE, &_ctx->dwResult); - - // Check to determine which event has been set - if (CoroScheduler.getEvent(This->_hThreadEnd)->signalled) { - /* Must leave the thread */ - _ctx->cicla = false; - - } else if (CoroScheduler.getEvent(This->_hHot1)->signalled) { - // Must fill the second half of the buffer - This->lpDSBuffer->Lock(This->_dwBufferSize / 2, This->_dwBufferSize / 2, (void **)&_ctx->lpLockBuf, &_ctx->dwResult, (void **)&_ctx->lpLockBuf2, &_ctx->dwResult2, 0); + // FIXME: The idea here is that you wait for this stream to reach + // a buffer which is a multiple of nBufSize/nSync, and then the + // thread stops it and immediately starts the 'toplay' stream. - copyMemory(_ctx->lpLockBuf, This->_lpTempBuffer, This->_dwBufferSize / 2); - This->lpDSBuffer->Unlock(_ctx->lpLockBuf, This->_dwBufferSize / 2, _ctx->lpLockBuf2, 0); - - _ctx->bPrecache = true; - - } else if (CoroScheduler.getEvent(This->_hHot2)->signalled) { - This->lpDSBuffer->Lock(0, This->_dwBufferSize / 2, (void **)&_ctx->lpLockBuf, &_ctx->dwResult, NULL, NULL, 0); - - copyMemory(_ctx->lpLockBuf, This->_lpTempBuffer, This->_dwBufferSize / 2); - This->lpDSBuffer->Unlock(_ctx->lpLockBuf, This->_dwBufferSize / 2, NULL, NULL); - - _ctx->bPrecache = true; - - } else if (CoroScheduler.getEvent(This->_hHot3)->signalled) { - - if (This->_bSyncExit) { - CoroScheduler.setEvent(This->_syncToPlay->_hPlayThreadPlayFast); - - // Transfer immediatly control to the other threads - CORO_SLEEP(1); - - This->_bSyncExit = false; - _ctx->cicla = false; - break; - } - } else if (CoroScheduler.getEvent(This->_hPlayThreadPlayFast)->signalled) { - This->playFast(); - } - } - - // Close the DirectSound buffer - This->lpDSBuffer->Stop(); -#endif - - CORO_END_CODE; + stop(); + toplay->play(); } - /** * Unables or disables stream loop. * @@ -1389,44 +624,25 @@ void FPStream::setLoop(bool loop) { _bLoop = loop; } - /** * Pause sound effect * * @param bPause True enables pause, False disables it */ void FPStream::pause(bool bPause) { - if (_bFileLoaded) { - if (bPause && _bIsPlaying) { -#ifdef REFACTOR_ME - _lpDSBuffer->Stop(); -#endif - _bIsPlaying = false; - _bPaused = true; - } else if (!bPause && _bPaused) { -#ifdef REFACTOR_ME - _dspnHot[0].dwOffset = 32; - _dspnHot[0].hEventNotify = hHot1; - - _dspnHot[1].dwOffset = dwBufferSize / 2 + 32; - _dspnHot[1].hEventNotify = hHot2; - - _dspnHot[2].dwOffset = dwBufferSize - 32; //DSBPN_OFFSETSTOP; - _dspnHot[2].hEventNotify = hHot3; - - if (FAILED(lpDSNotify->SetNotificationPositions(3, dspnHot))) { - int a = 1; - } - - lpDSBuffer->Play(0, 0, _bLoop); -#endif - _bIsPlaying = true; - _bPaused = false; - - // Trick to reset the volume after a possible new sound configuration - setVolume(_lastVolume); - } - } + if (!_bFileLoaded) + return; + + if (bPause == _bPaused) + return; + + if (g_system->getMixer()->isSoundHandleActive(_handle)) + g_system->getMixer()->pauseHandle(_handle, bPause); + + _bPaused = bPause; + + // Trick to reset the volume after a possible new sound configuration + setVolume(_lastVolume); } /** @@ -1437,38 +653,33 @@ void FPStream::pause(bool bPause) { */ void FPStream::setVolume(int dwVolume) { -#ifdef REFACTOR_ME if (dwVolume > 63) dwVolume = 63; if (dwVolume < 0) dwVolume = 0; - lastVolume = dwVolume; + _lastVolume = dwVolume; - if (!GLOBALS.bCfgMusic) dwVolume = 0; + if (!GLOBALS._bCfgMusic) dwVolume = 0; else { - dwVolume -= (10 - GLOBALS.nCfgMusicVolume) * 2; + dwVolume -= (10 - GLOBALS._nCfgMusicVolume) * 2; if (dwVolume < 0) dwVolume = 0; } - if (lpDSBuffer) - lpDSBuffer->SetVolume(dwVolume * (DSBVOLUME_MAX - DSBVOLUME_MIN) / 64 + DSBVOLUME_MIN); -#endif + if (g_system->getMixer()->isSoundHandleActive(_handle)) + g_system->getMixer()->setChannelVolume(_handle, dwVolume * Audio::Mixer::kMaxChannelVolume / 63); } /** - * Gets the vgolume of the stream + * Gets the volume of the stream * * @param lpdwVolume Variable that will contain the current volume * */ void FPStream::getVolume(int *lpdwVolume) { -#ifdef REFACTOR_ME - if (lpDSBuffer) - lpDSBuffer->GetVolume((uint32 *)lpdwVolume); - *lpdwVolume -= (DSBVOLUME_MIN); - *lpdwVolume *= 64; - *lpdwVolume /= (DSBVOLUME_MAX - DSBVOLUME_MIN); -#endif + if (g_system->getMixer()->isSoundHandleActive(_handle)) + *lpdwVolume = g_system->getMixer()->getChannelVolume(_handle) * 63 / Audio::Mixer::kMaxChannelVolume; + else + *lpdwVolume = 0; } } // End of namespace Tony diff --git a/engines/tony/sound.h b/engines/tony/sound.h index 38ce6de2a7..585247db83 100644 --- a/engines/tony/sound.h +++ b/engines/tony/sound.h @@ -265,23 +265,11 @@ public: class FPStream { private: - // HWND hwnd; - // LPDIRECTSOUND lpDS; - // LPDIRECTSOUNDBUFFER lpDSBuffer; // DirectSound circular buffer - // LPDIRECTSOUNDNOTIFY lpDSNotify; // Notify hotspots in the buffer - - byte *_lpTempBuffer; // Temporary buffer use for decompression - uint32 _dwBufferSize; // Buffer size (bytes) uint32 _dwSize; // Stream size (bytes) uint32 _dwCodec; // CODEC used - uint32 _hThreadEnd; // Event used to close thread Common::File _file; // File handle used for the stream - uint32 _hPlayThread; // Handle of the Play thread - uint32 _hHot1, _hHot2, _hHot3; // Events set by DirectSoundNotify - uint32 _hPlayThreadPlayFast; - uint32 _hPlayThreadPlayNormal; bool _bSoundSupported; // True if the sound is active bool _bFileLoaded; // True if the file is open @@ -291,21 +279,10 @@ private: bool _bPaused; int _lastVolume; FPStream *_syncToPlay; - CODEC *_codec; - - // DSBPOSITIONNOTIFY dspnHot[3]; - - bool createBuffer(int nBufSize); -public: - bool _bIsPlaying; // True if the stream is playing - -private: - /** - * Thread playing the stream - * - */ - static void playThread(CORO_PARAM, const void *param); + Audio::AudioStream *_loopStream; + Audio::RewindableAudioStream *_rewindableStream; + Audio::SoundHandle _handle; public: @@ -368,7 +345,6 @@ public: bool play(); void playFast(); - void prefetch(); /** * Closes the stream. @@ -408,7 +384,7 @@ public: void setVolume(int dwVolume); /** - * Gets the vgolume of the stream + * Gets the volume of the stream * * @param lpdwVolume Variable that will contain the current volume * diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 8ae95af862..475683d0f4 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -268,7 +268,7 @@ void TonyEngine::doNextMusic(CORO_PARAM, const void *param) { } streams[GLOBALS._nextChannel]->setLoop(GLOBALS._nextLoop); - streams[GLOBALS._nextChannel]->prefetch(); + //streams[GLOBALS._nextChannel]->prefetch(); streams[GLOBALS._curChannel]->stop(true); streams[GLOBALS._curChannel]->waitForSync(streams[GLOBALS._nextChannel]); -- cgit v1.2.3 From 2d1d6630d6caff8fa47559e91c8a9a667dfa2df4 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 20 Jun 2012 22:17:41 +0200 Subject: TONY: Remove useless CODEC class definition --- engines/tony/sound.h | 19 ------------------- 1 file changed, 19 deletions(-) (limited to 'engines') diff --git a/engines/tony/sound.h b/engines/tony/sound.h index 585247db83..ca71652f20 100644 --- a/engines/tony/sound.h +++ b/engines/tony/sound.h @@ -49,7 +49,6 @@ enum SoundCodecs { FPCODEC_ADPCM }; - //**************************************************************************** //* class FPSound //* ------------- @@ -245,24 +244,6 @@ public: bool endOfBuffer() const; }; -/** - * Codec base class - */ -class CODEC { -protected: - bool _bEndReached; - -public: - bool _bLoop; - - CODEC(bool _bLoop = true); - virtual ~CODEC(); - virtual uint32 decompress(Common::SeekableReadStream *stream, void *lpBuf, uint32 dwSize) = 0; - virtual void loopReset() = 0; - bool endOfStream(); -}; - - class FPStream { private: uint32 _dwBufferSize; // Buffer size (bytes) -- cgit v1.2.3 From 85150232f036d1dead6a0807bac7b10c5ba923e1 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 21 Jun 2012 00:20:16 +0200 Subject: TONY: Some more renaming (thanks Hkz) --- engines/tony/custom.cpp | 119 ++++++++++++++++++++++------------------------ engines/tony/game.h | 10 ++-- engines/tony/globals.cpp | 2 +- engines/tony/globals.h | 16 +++---- engines/tony/tonychar.cpp | 78 +++++++++++++++--------------- engines/tony/tonychar.h | 62 ++++++++++++------------ 6 files changed, 142 insertions(+), 145 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index ce1c2860f8..78b8f4e798 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -42,7 +42,7 @@ namespace Tony { -const char *tappetiFile[] = { +const char *ambianceFile[] = { "None", "1.ADP", // Grilli.WAV "2.ADP", // Grilli-Ovattati.WAV @@ -50,7 +50,7 @@ const char *tappetiFile[] = { "3.ADP", // Grilli-Vento1.WAV "5.ADP", // Vento1.WAV "4.ADP", // Mare1.WAV - "6.ADP" // Mare1.WAV met volume + "6.ADP" // Mare1.WAV half volume }; struct MusicFileEntry { @@ -210,19 +210,19 @@ DECLARE_CUSTOM_FUNCTION(SetAlwaysDisplay)(CORO_PARAM, uint32 val, uint32, uint32 DECLARE_CUSTOM_FUNCTION(SetPointer)(CORO_PARAM, uint32 dwPointer, uint32, uint32, uint32) { switch (dwPointer) { case 1: - GLOBALS._pointer->setSpecialPointer(GLOBALS._pointer->PTR_FRECCIASU); + GLOBALS._pointer->setSpecialPointer(GLOBALS._pointer->PTR_ARROWUP); break; case 2: - GLOBALS._pointer->setSpecialPointer(GLOBALS._pointer->PTR_FRECCIAGIU); + GLOBALS._pointer->setSpecialPointer(GLOBALS._pointer->PTR_ARROWDOWN); break; case 3: - GLOBALS._pointer->setSpecialPointer(GLOBALS._pointer->PTR_FRECCIASINISTRA); + GLOBALS._pointer->setSpecialPointer(GLOBALS._pointer->PTR_ARROWLEFT); break; case 4: - GLOBALS._pointer->setSpecialPointer(GLOBALS._pointer->PTR_FRECCIADESTRA); + GLOBALS._pointer->setSpecialPointer(GLOBALS._pointer->PTR_ARROWRIGHT); break; case 5: - GLOBALS._pointer->setSpecialPointer(GLOBALS._pointer->PTR_FRECCIAMAPPA); + GLOBALS._pointer->setSpecialPointer(GLOBALS._pointer->PTR_ARROWMAP); break; default: @@ -232,15 +232,12 @@ DECLARE_CUSTOM_FUNCTION(SetPointer)(CORO_PARAM, uint32 dwPointer, uint32, uint32 } VoiceHeader *SearchVoiceHeader(uint32 codehi, uint32 codelo) { - uint i; - int code; - - code = (codehi << 16) | codelo; + int code = (codehi << 16) | codelo; if (_vm->_voices.size() == 0) return NULL; - for (i = 0; i < _vm->_voices.size(); i++) + for (uint i = 0; i < _vm->_voices.size(); i++) if (_vm->_voices[i]._code == code) return &_vm->_voices[i]; @@ -292,7 +289,7 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_NORMAL; } else { if (_ctx->msg.numPeriods() > 1) - CORO_INVOKE_1(GLOBALS._tony->startTalk, GLOBALS._tony->TALK_FIANCHI); + CORO_INVOKE_1(GLOBALS._tony->startTalk, GLOBALS._tony->TALK_HIPS); else CORO_INVOKE_1(GLOBALS._tony->startTalk, GLOBALS._tony->TALK_NORMAL); } @@ -537,7 +534,7 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint CORO_INVOKE_0(GLOBALS.WaitWipeEnd); } - if (GLOBALS._lastTappeto != GLOBALS._tappeti[nLoc]) { + if (GLOBALS._lastTappeto != GLOBALS._ambiance[nLoc]) { _vm->stopMusic(4); } @@ -550,10 +547,10 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint else GLOBALS.LoadLocation(nLoc, RMPoint(tX, tY), RMPoint(-1, -1)); - if (GLOBALS._lastTappeto != GLOBALS._tappeti[nLoc]) { - GLOBALS._lastTappeto = GLOBALS._tappeti[nLoc]; + if (GLOBALS._lastTappeto != GLOBALS._ambiance[nLoc]) { + GLOBALS._lastTappeto = GLOBALS._ambiance[nLoc]; if (GLOBALS._lastTappeto != 0) - _vm->playMusic(4, tappetiFile[GLOBALS._lastTappeto], 0, true, 2000); + _vm->playMusic(4, ambianceFile[GLOBALS._lastTappeto], 0, true, 2000); } if (!GLOBALS._bNoBullsEye) { @@ -802,19 +799,19 @@ void TonySetNumTexts(uint32 dwText) { GLOBALS._bTonyInTexts = false; } -DECLARE_CUSTOM_FUNCTION(TonyRide)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyLaugh)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_RIDE; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_LAUGH; } DECLARE_CUSTOM_FUNCTION(TonyGiggle)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_RIDE2; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_LAUGH2; } -DECLARE_CUSTOM_FUNCTION(TonyFianchi)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonyHips)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_FIANCHI; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_HIPS; } DECLARE_CUSTOM_FUNCTION(TonySing)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { @@ -1127,9 +1124,9 @@ DECLARE_CUSTOM_FUNCTION(TonySniffRight)(CORO_PARAM, uint32, uint32, uint32, uint CORO_END_CODE; } -DECLARE_CUSTOM_FUNCTION(TonyNaah)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { +DECLARE_CUSTOM_FUNCTION(TonySarcastic)(CORO_PARAM, uint32 dwText, uint32, uint32, uint32) { TonySetNumTexts(dwText); - GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_NAAH; + GLOBALS._nTonyNextTalkType = GLOBALS._tony->TALK_SARCASTIC; } DECLARE_CUSTOM_FUNCTION(TonyMacbeth)(CORO_PARAM, uint32 nPos, uint32, uint32, uint32) { @@ -2237,7 +2234,7 @@ void RestoreMusic(CORO_PARAM) { CORO_INVOKE_4(PlaySoundEffect, GLOBALS._lastMusic, 0, 0, 0); if (GLOBALS._lastTappeto != 0) - CustPlayMusic(4, tappetiFile[GLOBALS._lastTappeto], 0, true); + CustPlayMusic(4, ambianceFile[GLOBALS._lastTappeto], 0, true); CORO_END_CODE; } @@ -2447,8 +2444,8 @@ ASSIGN(37, TonyGetUp) ASSIGN(38, TonyShepherdess) ASSIGN(39, TonyWhistle) -ASSIGN(40, TonyRide) -ASSIGN(41, TonyFianchi) +ASSIGN(40, TonyLaugh) +ASSIGN(41, TonyHips) ASSIGN(42, TonySing) ASSIGN(43, TonyIndicate) ASSIGN(44, TonyScaredWithHands) @@ -2477,7 +2474,7 @@ ASSIGN(106, TonyWithBeardStart) ASSIGN(107, TonyWithBeardEnd) ASSIGN(108, TonyGiggle) ASSIGN(109, TonyDisgusted) -ASSIGN(110, TonyNaah) +ASSIGN(110, TonySarcastic) ASSIGN(111, TonyMacbeth) ASSIGN(112, TonySniffLeft) ASSIGN(113, TonySniffRight) @@ -2575,39 +2572,39 @@ void setupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation GLOBALS._mut[i] = CoroScheduler.createEvent(false, false); for (i = 0; i < 200; i++) - GLOBALS._tappeti[i] = 0; - - GLOBALS._tappeti[6] = TAPPETI_GRILLI; - GLOBALS._tappeti[7] = TAPPETI_GRILLI; - GLOBALS._tappeti[8] = TAPPETI_GRILLIOV; - GLOBALS._tappeti[10] = TAPPETI_GRILLI; - GLOBALS._tappeti[12] = TAPPETI_GRILLI; - GLOBALS._tappeti[13] = TAPPETI_GRILLIOV; - GLOBALS._tappeti[15] = TAPPETI_GRILLI; - GLOBALS._tappeti[16] = TAPPETI_GRILLIVENTO; - GLOBALS._tappeti[18] = TAPPETI_GRILLI; - GLOBALS._tappeti[19] = TAPPETI_GRILLIVENTO; - GLOBALS._tappeti[20] = TAPPETI_GRILLI; - GLOBALS._tappeti[23] = TAPPETI_GRILLI; - GLOBALS._tappeti[26] = TAPPETI_MAREMETA; - GLOBALS._tappeti[27] = TAPPETI_GRILLI; - GLOBALS._tappeti[28] = TAPPETI_GRILLIVENTO; - GLOBALS._tappeti[31] = TAPPETI_GRILLI; - GLOBALS._tappeti[33] = TAPPETI_MARE; - GLOBALS._tappeti[35] = TAPPETI_MARE; - GLOBALS._tappeti[36] = TAPPETI_GRILLI; - GLOBALS._tappeti[37] = TAPPETI_GRILLI; - GLOBALS._tappeti[40] = TAPPETI_GRILLI; - GLOBALS._tappeti[41] = TAPPETI_GRILLI; - GLOBALS._tappeti[42] = TAPPETI_GRILLI; - GLOBALS._tappeti[45] = TAPPETI_GRILLI; - GLOBALS._tappeti[51] = TAPPETI_GRILLI; - GLOBALS._tappeti[52] = TAPPETI_GRILLIVENTO1; - GLOBALS._tappeti[53] = TAPPETI_GRILLI; - GLOBALS._tappeti[54] = TAPPETI_GRILLI; - GLOBALS._tappeti[57] = TAPPETI_VENTO; - GLOBALS._tappeti[58] = TAPPETI_VENTO; - GLOBALS._tappeti[60] = TAPPETI_VENTO; + GLOBALS._ambiance[i] = 0; + + GLOBALS._ambiance[6] = AMBIANCE_CRICKETS; + GLOBALS._ambiance[7] = AMBIANCE_CRICKETS; + GLOBALS._ambiance[8] = AMBIANCE_CRICKETSMUFFLED; + GLOBALS._ambiance[10] = AMBIANCE_CRICKETS; + GLOBALS._ambiance[12] = AMBIANCE_CRICKETS; + GLOBALS._ambiance[13] = AMBIANCE_CRICKETSMUFFLED; + GLOBALS._ambiance[15] = AMBIANCE_CRICKETS; + GLOBALS._ambiance[16] = AMBIANCE_CRICKETSWIND; + GLOBALS._ambiance[18] = AMBIANCE_CRICKETS; + GLOBALS._ambiance[19] = AMBIANCE_CRICKETSWIND; + GLOBALS._ambiance[20] = AMBIANCE_CRICKETS; + GLOBALS._ambiance[23] = AMBIANCE_CRICKETS; + GLOBALS._ambiance[26] = AMBIANCE_SEAHALFVOLUME; + GLOBALS._ambiance[27] = AMBIANCE_CRICKETS; + GLOBALS._ambiance[28] = AMBIANCE_CRICKETSWIND; + GLOBALS._ambiance[31] = AMBIANCE_CRICKETS; + GLOBALS._ambiance[33] = AMBIANCE_SEA; + GLOBALS._ambiance[35] = AMBIANCE_SEA; + GLOBALS._ambiance[36] = AMBIANCE_CRICKETS; + GLOBALS._ambiance[37] = AMBIANCE_CRICKETS; + GLOBALS._ambiance[40] = AMBIANCE_CRICKETS; + GLOBALS._ambiance[41] = AMBIANCE_CRICKETS; + GLOBALS._ambiance[42] = AMBIANCE_CRICKETS; + GLOBALS._ambiance[45] = AMBIANCE_CRICKETS; + GLOBALS._ambiance[51] = AMBIANCE_CRICKETS; + GLOBALS._ambiance[52] = AMBIANCE_CRICKETSWIND1; + GLOBALS._ambiance[53] = AMBIANCE_CRICKETS; + GLOBALS._ambiance[54] = AMBIANCE_CRICKETS; + GLOBALS._ambiance[57] = AMBIANCE_WIND; + GLOBALS._ambiance[58] = AMBIANCE_WIND; + GLOBALS._ambiance[60] = AMBIANCE_WIND; diff --git a/engines/tony/game.h b/engines/tony/game.h index e231287c0f..d8aceefc12 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -72,11 +72,11 @@ private: public: enum PointerType { PTR_NONE = 0, - PTR_FRECCIASU, - PTR_FRECCIAGIU, - PTR_FRECCIASINISTRA, - PTR_FRECCIADESTRA, - PTR_FRECCIAMAPPA, + PTR_ARROWUP, + PTR_ARROWDOWN, + PTR_ARROWLEFT, + PTR_ARROWRIGHT, + PTR_ARROWMAP, PTR_CUSTOM }; diff --git a/engines/tony/globals.cpp b/engines/tony/globals.cpp index f28a22e4a5..ba2698a50b 100644 --- a/engines/tony/globals.cpp +++ b/engines/tony/globals.cpp @@ -72,7 +72,7 @@ Globals::Globals() { _hSkipIdle = 0; _lastMusic = 0; _lastTappeto = 0; - Common::fill(&_tappeti[0], &_tappeti[200], 0); + Common::fill(&_ambiance[0], &_ambiance[200], 0); _fullScreenMessageLoc = 0; // MPAL global variables diff --git a/engines/tony/globals.h b/engines/tony/globals.h index b63dce7c45..02bd79eee7 100644 --- a/engines/tony/globals.h +++ b/engines/tony/globals.h @@ -35,13 +35,13 @@ namespace Tony { -#define TAPPETI_GRILLI 1 -#define TAPPETI_GRILLIOV 2 -#define TAPPETI_GRILLIVENTO 3 -#define TAPPETI_GRILLIVENTO1 4 -#define TAPPETI_VENTO 5 -#define TAPPETI_MARE 6 -#define TAPPETI_MAREMETA 7 +#define AMBIANCE_CRICKETS 1 +#define AMBIANCE_CRICKETSMUFFLED 2 +#define AMBIANCE_CRICKETSWIND 3 +#define AMBIANCE_CRICKETSWIND1 4 +#define AMBIANCE_WIND 5 +#define AMBIANCE_SEA 6 +#define AMBIANCE_SEAHALFVOLUME 7 struct CharacterStruct { uint32 _code; @@ -243,7 +243,7 @@ public: int _lastMusic, _lastTappeto; - int _tappeti[200]; + int _ambiance[200]; RMPoint _fullScreenMessagePt; int _fullScreenMessageLoc; diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index cd5bbdad8b..74d9f20181 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -648,39 +648,39 @@ bool RMTony::startTalkCalculate(CharacterTalkType nTalkType, int &headStartPat, } break; - case TALK_FIANCHI: + case TALK_HIPS: _bBodyFront = false; switch (_talkDirection) { case UP: _nBodyOffset.set(2, 42); headStartPat = PAT_HEAD_UP; - bodyStartPat = BPAT_FIANCHIUP_START; + bodyStartPat = BPAT_HIPSUP_START; headLoopPat = PAT_TALK_UP; - bodyLoopPat = BPAT_FIANCHIUP_LOOP; + bodyLoopPat = BPAT_HIPSUP_LOOP; break; case DOWN: _nBodyOffset.set(2, 48); headStartPat = PAT_HEAD_DOWN; - bodyStartPat = BPAT_FIANCHIDOWN_START; + bodyStartPat = BPAT_HIPSDOWN_START; headLoopPat = PAT_TALK_DOWN; - bodyLoopPat = BPAT_FIANCHIDOWN_LOOP; + bodyLoopPat = BPAT_HIPSDOWN_LOOP; break; case LEFT: _nBodyOffset.set(-3, 53); headStartPat = PAT_HEAD_LEFT; - bodyStartPat = BPAT_FIANCHILEFT_START; + bodyStartPat = BPAT_HIPSLEFT_START; headLoopPat = PAT_TALK_LEFT; - bodyLoopPat = BPAT_FIANCHILEFT_LOOP; + bodyLoopPat = BPAT_HIPSLEFT_LOOP; break; case RIGHT: _nBodyOffset.set(2, 53); headStartPat = PAT_HEAD_RIGHT; - bodyStartPat = BPAT_FIANCHIRIGHT_START; + bodyStartPat = BPAT_HIPSRIGHT_START; headLoopPat = PAT_TALK_RIGHT; - bodyLoopPat = BPAT_FIANCHIRIGHT_LOOP; + bodyLoopPat = BPAT_HIPSRIGHT_LOOP; break; } break; @@ -693,47 +693,47 @@ bool RMTony::startTalkCalculate(CharacterTalkType nTalkType, int &headStartPat, bodyLoopPat = BPAT_SINGLEFT_LOOP; break; - case TALK_RIDE: + case TALK_LAUGH: _bBodyFront = false; switch (_talkDirection) { case UP: case DOWN: case LEFT: _nBodyOffset.set(6, 56); - headStartPat = PAT_RIDELEFT_START; + headStartPat = PAT_LAUGHLEFT_START; bodyStartPat = BPAT_STANDLEFT; - headLoopPat = PAT_RIDELEFT_LOOP; - bodyLoopPat = BPAT_RIDELEFT; + headLoopPat = PAT_LAUGHLEFT_LOOP; + bodyLoopPat = BPAT_LAUGHLEFT; break; case RIGHT: _nBodyOffset.set(6, 56); - headStartPat = PAT_RIDERIGHT_START; + headStartPat = PAT_LAUGHRIGHT_START; bodyStartPat = BPAT_STANDRIGHT; - headLoopPat = PAT_RIDERIGHT_LOOP; - bodyLoopPat = BPAT_RIDERIGHT; + headLoopPat = PAT_LAUGHRIGHT_LOOP; + bodyLoopPat = BPAT_LAUGHRIGHT; break; } break; - case TALK_RIDE2: + case TALK_LAUGH2: _bBodyFront = false; switch (_talkDirection) { case UP: case DOWN: case LEFT: _nBodyOffset.set(6, 56); - headStartPat = PAT_RIDELEFT_START; + headStartPat = PAT_LAUGHLEFT_START; bodyStartPat = BPAT_STANDLEFT; - headLoopPat = PAT_RIDELEFT_LOOP; + headLoopPat = PAT_LAUGHLEFT_LOOP; break; case RIGHT: _nBodyOffset.set(6, 56); - headStartPat = PAT_RIDERIGHT_START; + headStartPat = PAT_LAUGHRIGHT_START; bodyStartPat = BPAT_STANDRIGHT; - headLoopPat = PAT_RIDERIGHT_LOOP; - bodyLoopPat = BPAT_RIDERIGHT; + headLoopPat = PAT_LAUGHRIGHT_LOOP; + bodyLoopPat = BPAT_LAUGHRIGHT; break; } break; @@ -997,22 +997,22 @@ bool RMTony::startTalkCalculate(CharacterTalkType nTalkType, int &headStartPat, } break; - case TALK_NAAH: + case TALK_SARCASTIC: switch (_talkDirection) { case LEFT: case UP: _nBodyOffset.set(6, 56); - headStartPat = PAT_NAAHLEFT_START; + headStartPat = PAT_SARCASTICLEFT_START; bodyStartPat = BPAT_STANDLEFT; - headLoopPat = PAT_NAAHLEFT_LOOP; + headLoopPat = PAT_SARCASTICLEFT_LOOP; break; case DOWN: case RIGHT: _nBodyOffset.set(6, 56); - headStartPat = PAT_NAAHRIGHT_START; + headStartPat = PAT_SARCASTICRIGHT_START; bodyStartPat = BPAT_STANDRIGHT; - headLoopPat = PAT_NAAHRIGHT_LOOP; + headLoopPat = PAT_SARCASTICRIGHT_LOOP; break; } break; @@ -1180,22 +1180,22 @@ bool RMTony::endTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa bodyEndPat = 0; break; - case TALK_FIANCHI: + case TALK_HIPS: switch (_talkDirection) { case UP: - bodyEndPat = BPAT_FIANCHIUP_END; + bodyEndPat = BPAT_HIPSUP_END; break; case DOWN: - bodyEndPat = BPAT_FIANCHIDOWN_END; + bodyEndPat = BPAT_HIPSDOWN_END; break; case LEFT: - bodyEndPat = BPAT_FIANCHILEFT_END; + bodyEndPat = BPAT_HIPSLEFT_END; break; case RIGHT: - bodyEndPat = BPAT_FIANCHIRIGHT_END; + bodyEndPat = BPAT_HIPSRIGHT_END; break; } break; @@ -1204,12 +1204,12 @@ bool RMTony::endTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa bodyEndPat = BPAT_SINGLEFT_END; break; - case TALK_RIDE: - case TALK_RIDE2: + case TALK_LAUGH: + case TALK_LAUGH2: if (_talkDirection == LEFT) - headEndPat = PAT_RIDELEFT_END; + headEndPat = PAT_LAUGHLEFT_END; else if (_talkDirection == RIGHT) - headEndPat = PAT_RIDERIGHT_END; + headEndPat = PAT_LAUGHRIGHT_END; bodyEndPat = 0; break; @@ -1230,16 +1230,16 @@ bool RMTony::endTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa bodyEndPat = 0; break; - case TALK_NAAH: + case TALK_SARCASTIC: switch (_talkDirection) { case UP: case LEFT: - headEndPat = PAT_NAAHLEFT_END; + headEndPat = PAT_SARCASTICLEFT_END; break; case DOWN: case RIGHT: - headEndPat = PAT_NAAHRIGHT_END; + headEndPat = PAT_SARCASTICRIGHT_END; break; } diff --git a/engines/tony/tonychar.h b/engines/tony/tonychar.h index a50641bf25..775c27a4e0 100644 --- a/engines/tony/tonychar.h +++ b/engines/tony/tonychar.h @@ -43,9 +43,9 @@ private: public: enum CharacterTalkType { TALK_NORMAL, - TALK_FIANCHI, + TALK_HIPS, TALK_SING, - TALK_RIDE, + TALK_LAUGH, TALK_INDICATE, TALK_SCARED, TALK_SCARED2, @@ -64,9 +64,9 @@ public: TALK_WITH_NOTEBOOK, TALK_WITHMEGAPHONESTATIC, TALK_WITHBEARDSTATIC, - TALK_RIDE2, + TALK_LAUGH2, TALK_DISGUSTED, - TALK_NAAH, + TALK_SARCASTIC, TALK_MACBETH1, TALK_MACBETH2, TALK_MACBETH3, @@ -169,12 +169,12 @@ public: PAT_HEAD_RIGHT, // Laugh - PAT_RIDELEFT_START, - PAT_RIDELEFT_LOOP, - PAT_RIDELEFT_END, - PAT_RIDERIGHT_START, - PAT_RIDERIGHT_LOOP, - PAT_RIDERIGHT_END, + PAT_LAUGHLEFT_START, + PAT_LAUGHLEFT_LOOP, + PAT_LAUGHLEFT_END, + PAT_LAUGHRIGHT_START, + PAT_LAUGHRIGHT_LOOP, + PAT_LAUGHRIGHT_END, // Speaking as a shepherdess PAT_PAST_TALKUP, @@ -217,12 +217,12 @@ public: PAT_DISGUSTEDRIGHT_START, PAT_DISGUSTEDRIGHT_LOOP, PAT_DISGUSTEDRIGHT_END, - PAT_NAAHLEFT_START, - PAT_NAAHLEFT_LOOP, - PAT_NAAHLEFT_END, - PAT_NAAHRIGHT_START, - PAT_NAAHRIGHT_LOOP, - PAT_NAAHRIGHT_END, + PAT_SARCASTICLEFT_START, + PAT_SARCASTICLEFT_LOOP, + PAT_SARCASTICLEFT_END, + PAT_SARCASTICRIGHT_START, + PAT_SARCASTICRIGHT_LOOP, + PAT_SARCASTICRIGHT_END, // Stand scared PAT_SCAREDLEFT_STAND, @@ -266,21 +266,21 @@ public: BPAT_SINGLEFT_LOOP, BPAT_SINGLEFT_END, - BPAT_FIANCHILEFT_START, - BPAT_FIANCHILEFT_LOOP, - BPAT_FIANCHILEFT_END, - BPAT_FIANCHIRIGHT_START, - BPAT_FIANCHIRIGHT_LOOP, - BPAT_FIANCHIRIGHT_END, - BPAT_FIANCHIUP_START, - BPAT_FIANCHIUP_LOOP, - BPAT_FIANCHIUP_END, - BPAT_FIANCHIDOWN_START, - BPAT_FIANCHIDOWN_LOOP, - BPAT_FIANCHIDOWN_END, - - BPAT_RIDELEFT, - BPAT_RIDERIGHT, + BPAT_HIPSLEFT_START, + BPAT_HIPSLEFT_LOOP, + BPAT_HIPSLEFT_END, + BPAT_HIPSRIGHT_START, + BPAT_HIPSRIGHT_LOOP, + BPAT_HIPSRIGHT_END, + BPAT_HIPSUP_START, + BPAT_HIPSUP_LOOP, + BPAT_HIPSUP_END, + BPAT_HIPSDOWN_START, + BPAT_HIPSDOWN_LOOP, + BPAT_HIPSDOWN_END, + + BPAT_LAUGHLEFT, + BPAT_LAUGHRIGHT, BPAT_INDICATELEFT, BPAT_INDICATERIGHT, -- cgit v1.2.3 From fdc619191b4778608263e57a815bd99b3823c11d Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 21 Jun 2012 07:31:38 +0200 Subject: TONY: Translate two comments --- engines/tony/custom.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 78b8f4e798..3a0792252b 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -1413,10 +1413,8 @@ DECLARE_CUSTOM_FUNCTION(ShakeScreen)(CORO_PARAM, uint32 nScosse, uint32, uint32, CORO_END_CODE; } - - /* - * Personaggi + * Characters */ DECLARE_CUSTOM_FUNCTION(CharSetCode)(CORO_PARAM, uint32 nChar, uint32 nCode, uint32, uint32) { @@ -1778,7 +1776,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes } /* - * Dialoghi + * Dialogs */ int curDialog; -- cgit v1.2.3 From 17289089e6232d464d9eef15f510d66542fbbec5 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 21 Jun 2012 22:58:58 +1000 Subject: TONY: Fix for adding dirty rects for 8-bit RLE images --- engines/tony/gfxcore.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index d34923e455..751802bb29 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -900,6 +900,9 @@ void RMGfxSourceBuffer8RLE::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPri u = _dimx - (width + u); x1 = (prim->getDst()._x1 + _dimx - 1) - u; + // Specify the drawn area + bigBuf.addDirtyRect(Common::Rect(x1 - width, y1, x1, y1 + height)); + for (y = 0; y < height; y++) { // Decompression RLEDecompressLineFlipped(buf + x1, src + 2, u, width); @@ -911,6 +914,9 @@ void RMGfxSourceBuffer8RLE::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPri buf += bigBuf.getDimx(); } } else { + // Specify the drawn area + bigBuf.addDirtyRect(Common::Rect(x1, y1, x1 + width, y1 + height)); + for (y = 0; y < height; y++) { // Decompression RLEDecompressLine(buf + x1, src + 2, u, width); @@ -922,9 +928,6 @@ void RMGfxSourceBuffer8RLE::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPri buf += bigBuf.getDimx(); } } - - // Specify the drawn area - bigBuf.addDirtyRect(Common::Rect(x1, y1, x1 + width, y1 + height)); } -- cgit v1.2.3 From 2990482406710c77280c67f3b7672a569b9d5a92 Mon Sep 17 00:00:00 2001 From: Torbj旦rn Andersson Date: Thu, 21 Jun 2012 21:30:09 +0200 Subject: TONY: Fix Valgrind warning The loop uses _ctx->msg, so don't delete it until the loop is done. --- engines/tony/custom.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 3a0792252b..35ae8849f1 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -1761,9 +1761,9 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes GLOBALS._curBackText = NULL; delete _ctx->text; - delete _ctx->msg; } + delete _ctx->msg; // Try to run the custom function to close the speech if (GLOBALS._mCharacter[nChar]._item) { -- cgit v1.2.3 From eef6b444df766b90d1323941c7ff9bd8355c111b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 22 Jun 2012 23:47:39 +1000 Subject: TONY: Created a debugger command 'dirty_rects' to show dirty rect areas on-screen --- engines/tony/debugger.cpp | 14 ++++++++++++++ engines/tony/debugger.h | 1 + engines/tony/window.cpp | 16 ++++++++++++++++ engines/tony/window.h | 5 ++--- 4 files changed, 33 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/tony/debugger.cpp b/engines/tony/debugger.cpp index 8beb7285a4..75e58d68d4 100644 --- a/engines/tony/debugger.cpp +++ b/engines/tony/debugger.cpp @@ -30,6 +30,7 @@ namespace Tony { Debugger::Debugger() : GUI::Debugger() { DCmd_Register("continue", WRAP_METHOD(Debugger, Cmd_Exit)); DCmd_Register("scene", WRAP_METHOD(Debugger, Cmd_Scene)); + DCmd_Register("dirty_rects", WRAP_METHOD(Debugger, Cmd_DirtyRects)); } static int strToInt(const char *s) { @@ -113,4 +114,17 @@ bool Debugger::Cmd_Scene(int argc, const char **argv) { return false; } +/** + * Turns showing dirty rects on or off + */ +bool Debugger::Cmd_DirtyRects(int argc, const char **argv) { + if (argc != 2) { + DebugPrintf("Usage; %s [on | off]\n", argv[0]); + return true; + } else { + _vm->_window.showDirtyRects(strcmp(argv[1], "on") == 0); + return false; + } +} + } // End of namespace Tony diff --git a/engines/tony/debugger.h b/engines/tony/debugger.h index c5ed5e417e..85ba9d75b6 100644 --- a/engines/tony/debugger.h +++ b/engines/tony/debugger.h @@ -35,6 +35,7 @@ public: protected: bool Cmd_Scene(int argc, const char **argv); + bool Cmd_DirtyRects(int argc, const char **argv); }; } // End of namespace Tony diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index bf0094ff2a..a35e765b6c 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -27,6 +27,7 @@ */ #include "common/scummsys.h" +#include "graphics/surface.h" #include "util.h" #include "tony/window.h" #include "tony/game.h" @@ -40,6 +41,7 @@ namespace Tony { \****************************************************************************/ RMWindow::RMWindow() { + _showDirtyRects = false; } RMWindow::~RMWindow() { @@ -126,11 +128,25 @@ void RMWindow::getNewFrame(RMGfxTargetBuffer &bigBuf, Common::Rect *rcBoundEllip Common::List dirtyRects = bigBuf.getDirtyRects(); Common::List::iterator i; + // If showing dirty rects, copy the entire screen background and set up a surface pointer + Graphics::Surface *s = NULL; + if (_showDirtyRects) { + g_system->copyRectToScreen(lpBuf, RM_SX * 2, 0, 0, RM_SX, RM_SY); + s = g_system->lockScreen(); + } + for (i = dirtyRects.begin(); i != dirtyRects.end(); ++i) { Common::Rect &r = *i; const byte *lpSrc = lpBuf + (RM_SX * 2) * r.top + (r.left * 2); g_system->copyRectToScreen(lpSrc, RM_SX * 2, r.left, r.top, r.width(), r.height()); + + if (_showDirtyRects) + // Frame the copied area with a rectangle + s->frameRect(r, 0xffffff); } + + if (_showDirtyRects) + g_system->unlockScreen(); } if (_bGrabThumbnail) { diff --git a/engines/tony/window.h b/engines/tony/window.h index 6189dd391f..562e5fe062 100644 --- a/engines/tony/window.h +++ b/engines/tony/window.h @@ -57,14 +57,12 @@ private: void plotLines(const byte *lpBuf, const Common::Point ¢er, int x, int y); protected: -// void * /*LPDIRECTDRAWCLIPPER*/ _MainClipper; -// void * /*LPDIRECTDRAWCLIPPER*/ _BackClipper; - int fps, fcount; int lastsecond, lastfcount; int mskRed, mskGreen, mskBlue; bool _wiping; + bool _showDirtyRects; bool _bGrabScreenshot; bool _bGrabThumbnail; @@ -99,6 +97,7 @@ public: int getFps() const { return fps; } + void showDirtyRects(bool v) { _showDirtyRects = v; } }; } // End of namespace Tony -- cgit v1.2.3 From 46d87ef76a7e2b7b8c53c4dee2d043192accf159 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 23 Jun 2012 15:25:03 +1000 Subject: TONY: Bugfix for loading ambient music when restoring a savegame --- engines/tony/sound.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index b0a2c69fd6..31e008eb62 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -486,8 +486,11 @@ bool FPStream::loadFile(const Common::String &fileName, uint32 dwCodType, int nB _dwCodec = dwCodType; // Open the file stream for reading - if (!_file.open(fileName)) - return false; + if (!_file.open(fileName)) { + // Fallback: try with an extra '0' prefix + if (!_file.open("0" + fileName)) + return false; + } // Save the size of the stream _dwSize = _file.size(); -- cgit v1.2.3 From 69ce6e35f48491a87886751e9d8cc2d004cf8f7a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 23 Jun 2012 16:28:03 +1000 Subject: TONY: Bugfix for crash when changing scene whilst music is playing --- engines/tony/sound.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'engines') diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index 31e008eb62..7380b3a93a 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -536,6 +536,8 @@ bool FPStream::unloadFile() { /* Closes the file handle stream */ delete _loopStream; delete _rewindableStream; + _loopStream = NULL; + _rewindableStream = NULL; _file.close(); // Flag that the file is no longer in memory -- cgit v1.2.3 From 65a8799f9653956cfced0b77e8c638be7c805824 Mon Sep 17 00:00:00 2001 From: Torbj旦rn Andersson Date: Sun, 24 Jun 2012 11:09:08 +0200 Subject: TONY: Added "sepia mode". This works by adding a wrapper function for copyRectToScreen(). As far as the engine is concerned, it still draws everything in color. The mouse cursors are still in color, but that can be fixed later. --- engines/tony/window.cpp | 61 ++++++++++++++++++++++++++++++++++++++++++++----- engines/tony/window.h | 2 ++ 2 files changed, 57 insertions(+), 6 deletions(-) (limited to 'engines') diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index b8cd34d049..5c08ab1eec 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -63,12 +63,61 @@ void RMWindow::init() { _bGrabThumbnail = false; _bGrabMovie = false; _wiping = false; + + _precalcTable = 0; +} + +void RMWindow::createBWPrecalcTable() { + _precalcTable = new uint16[0x8000]; + + for (int i = 0; i < 0x8000; i++) { + int r = (i >> 10) & 0x1F; + int g = (i >> 5) & 0x1F; + int b = i & 0x1F; + + int min = MIN(r, MIN(g, b)); + int max = MAX(r, MAX(g, b)); + + min = (min + max) / 2; + + r = CLIP(min + 8 - 8, 0, 31); + g = CLIP(min + 5 - 8, 0, 31); + b = CLIP(min + 0 - 8, 0, 31); + + _precalcTable[i] = (r << 10) | (g << 5) | b; + } } +void RMWindow::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) { + if (GLOBALS._bCfgAnni30) { + if (!_precalcTable) { + createBWPrecalcTable(); + } + Graphics::Surface *screen = g_system->lockScreen(); + const uint16 *src = (const uint16 *)buf; + for (int i = 0; i < h; i++) { + uint16 *dst = (uint16 *)screen->getBasePtr(x, y + i); + for (int j = 0; j < w; j++) { + dst[j] = _precalcTable[src[j] & 0x7FFF]; + } + src += (pitch / 2); + } + g_system->unlockScreen(); + } else { + if (_precalcTable) { + delete[] _precalcTable; + _precalcTable = 0; + } + g_system->copyRectToScreen(buf, pitch, x, y, w, h); + } + } + /** * Close the window */ void RMWindow::close() { + delete[] _precalcTable; + _precalcTable = 0; } void RMWindow::grabThumbnail(uint16 *thumbmem) { @@ -105,7 +154,7 @@ void RMWindow::wipeEffect(Common::Rect &rcBoundEllipse) { // Loop through each line for (int yp = rcBoundEllipse.top; yp < rcBoundEllipse.bottom; ++yp) { - g_system->copyRectToScreen((const byte *)&line[0], RM_SX * 2, rcBoundEllipse.left, yp, rcBoundEllipse.width(), 1); + copyRectToScreen((const byte *)&line[0], RM_SX * 2, rcBoundEllipse.left, yp, rcBoundEllipse.width(), 1); } } } @@ -120,7 +169,7 @@ void RMWindow::getNewFrame(RMGfxTargetBuffer &bigBuf, Common::Rect *rcBoundEllip _wiping = true; } else if (_wiping) { // Just finished a wiping effect, so copy the full screen - g_system->copyRectToScreen(lpBuf, RM_SX * 2, 0, 0, RM_SX, RM_SY); + copyRectToScreen(lpBuf, RM_SX * 2, 0, 0, RM_SX, RM_SY); _wiping = false; } else { @@ -131,14 +180,14 @@ void RMWindow::getNewFrame(RMGfxTargetBuffer &bigBuf, Common::Rect *rcBoundEllip // If showing dirty rects, copy the entire screen background and set up a surface pointer Graphics::Surface *s = NULL; if (_showDirtyRects) { - g_system->copyRectToScreen(lpBuf, RM_SX * 2, 0, 0, RM_SX, RM_SY); + copyRectToScreen(lpBuf, RM_SX * 2, 0, 0, RM_SX, RM_SY); s = g_system->lockScreen(); } for (i = dirtyRects.begin(); i != dirtyRects.end(); ++i) { Common::Rect &r = *i; const byte *lpSrc = lpBuf + (RM_SX * 2) * r.top + (r.left * 2); - g_system->copyRectToScreen(lpSrc, RM_SX * 2, r.left, r.top, r.width(), r.height()); + copyRectToScreen(lpSrc, RM_SX * 2, r.left, r.top, r.width(), r.height()); if (_showDirtyRects) // Frame the copied area with a rectangle @@ -227,13 +276,13 @@ void RMWindow::plotLines(const byte *lpBuf, const Common::Point ¢er, int x, if ((center.y - y) >= 0) { // Draw line in top half of circle pSrc = lpBuf + ((center.y - y) * RM_SX * 2) + xs * 2; - g_system->copyRectToScreen(pSrc, RM_SX * 2, xs, center.y - y, width, 1); + copyRectToScreen(pSrc, RM_SX * 2, xs, center.y - y, width, 1); } if ((center.y + y) < RM_SY) { // Draw line in bottom half of circle pSrc = lpBuf + ((center.y + y) * RM_SX * 2) + xs * 2; - g_system->copyRectToScreen(pSrc, RM_SX * 2, xs, center.y + y, width, 1); + copyRectToScreen(pSrc, RM_SX * 2, xs, center.y + y, width, 1); } } diff --git a/engines/tony/window.h b/engines/tony/window.h index 571a02829a..c72a3afd8e 100644 --- a/engines/tony/window.h +++ b/engines/tony/window.h @@ -70,8 +70,10 @@ protected: bool _bGrabThumbnail; bool _bGrabMovie; uint16 *_wThumbBuf; + uint16 *_precalcTable; void createBWPrecalcTable(); + void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h); void wipeEffect(Common::Rect &rcBoundEllipse); void getNewFrameWipe(byte *lpBuf, Common::Rect &rcBoundEllipse); -- cgit v1.2.3 From 58b03ec446737164782867aedc324cce3b491218 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 2 Jul 2012 20:53:31 +1000 Subject: TONY: Refactored the Sepia (B & W) mode so the cursor is converted as well --- engines/tony/game.cpp | 16 +++++++++++++++- engines/tony/game.h | 7 +++++-- engines/tony/gfxcore.cpp | 35 +++++++++++++++++++++++++++++++++++ engines/tony/gfxcore.h | 5 +++++ engines/tony/gfxengine.h | 3 +++ engines/tony/window.cpp | 39 ++++++++------------------------------- engines/tony/window.h | 2 -- 7 files changed, 71 insertions(+), 36 deletions(-) (limited to 'engines') diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 4e9e2abc38..abc7f1a2e0 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -1596,8 +1596,22 @@ void RMPointer::updateCursor() { draw(Common::nullContext, buf, &prim); + // Get a pointer to the cursor data + byte *cursorData = buf; + + // If in black & white mode, convert the cursor + if (GLOBALS._bCfgAnni30) { + uint16 *src = (uint16 *)cursorData; + for (int i = 0; i < 64; i++) { + uint16 *lineP = src; + for (int j = 0; j < 64; j++, lineP) { + lineP[j] = RMGfxTargetBuffer::_precalcTable[lineP[j] & 0x7FFF]; + } + src += 64; + } + } + // Get the raw pixel data and set the cursor to it - const byte *cursorData = buf; Graphics::PixelFormat pixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0); CursorMan.replaceCursor(cursorData, 64, 64, _cursorHotspot._x, _cursorHotspot._y, 0, 1, &pixelFormat); } diff --git a/engines/tony/game.h b/engines/tony/game.h index d8aceefc12..9804ac87fe 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -67,8 +67,6 @@ private: RMGfxSourceBuffer8 *_nCurCustomPointer; - void updateCursor(); - public: enum PointerType { PTR_NONE = 0, @@ -147,6 +145,11 @@ public: */ int curAction(); + /** + * Update the cursor + */ + void updateCursor(); + /** * Show the cursor */ diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index d91f5bab4e..119b730303 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -433,6 +433,41 @@ void RMGfxTargetBuffer::mergeDirtyRects() { } } +uint16 *RMGfxTargetBuffer::_precalcTable = NULL; + +/** + * Set up the black & white precalculated mapping table. This is only + * called if the user selects the black & white option. + */ +void RMGfxTargetBuffer::createBWPrecalcTable() { + _precalcTable = new uint16[0x8000]; + + for (int i = 0; i < 0x8000; i++) { + int r = (i >> 10) & 0x1F; + int g = (i >> 5) & 0x1F; + int b = i & 0x1F; + + int min = MIN(r, MIN(g, b)); + int max = MAX(r, MAX(g, b)); + + min = (min + max) / 2; + + r = CLIP(min + 8 - 8, 0, 31); + g = CLIP(min + 5 - 8, 0, 31); + b = CLIP(min + 0 - 8, 0, 31); + + _precalcTable[i] = (r << 10) | (g << 5) | b; + } +} + +/** + * Frees the black & white precalculated mapping table. + */ +void RMGfxTargetBuffer::freeBWPrecalcTable() { + delete[] _precalcTable; + _precalcTable = NULL; +} + /****************************************************************************\ * RMGfxSourceBufferPal Methods \****************************************************************************/ diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index 32e3c96881..78c4c9bc70 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -562,6 +562,7 @@ private: Common::List _currentDirtyRects, _previousDirtyRects, _dirtyRects; void mergeDirtyRects(); + private: // OSystem::MutexRef csModifyingOT; @@ -573,6 +574,10 @@ public: RMGfxTargetBuffer(); virtual ~RMGfxTargetBuffer(); + static uint16 *_precalcTable; + static void createBWPrecalcTable(); + static void freeBWPrecalcTable(); + // management of the OT list void clearOT(); void drawOT(CORO_PARAM); diff --git a/engines/tony/gfxengine.h b/engines/tony/gfxengine.h index 2c48612c4d..a69182d032 100644 --- a/engines/tony/gfxengine.h +++ b/engines/tony/gfxengine.h @@ -115,6 +115,9 @@ public: RMInput &getInput() { return _input; } + RMPointer &getPointer() { + return _point; + } // Link to the custom function list void initCustomDll(); diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index 5c08ab1eec..c509a12f9e 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -47,6 +47,7 @@ RMWindow::RMWindow() { RMWindow::~RMWindow() { close(); RMText::unload(); + RMGfxTargetBuffer::freeBWPrecalcTable(); } /** @@ -63,50 +64,28 @@ void RMWindow::init() { _bGrabThumbnail = false; _bGrabMovie = false; _wiping = false; - - _precalcTable = 0; -} - -void RMWindow::createBWPrecalcTable() { - _precalcTable = new uint16[0x8000]; - - for (int i = 0; i < 0x8000; i++) { - int r = (i >> 10) & 0x1F; - int g = (i >> 5) & 0x1F; - int b = i & 0x1F; - - int min = MIN(r, MIN(g, b)); - int max = MAX(r, MAX(g, b)); - - min = (min + max) / 2; - - r = CLIP(min + 8 - 8, 0, 31); - g = CLIP(min + 5 - 8, 0, 31); - b = CLIP(min + 0 - 8, 0, 31); - - _precalcTable[i] = (r << 10) | (g << 5) | b; - } } void RMWindow::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) { if (GLOBALS._bCfgAnni30) { - if (!_precalcTable) { - createBWPrecalcTable(); + if (!RMGfxTargetBuffer::_precalcTable) { + RMGfxTargetBuffer::createBWPrecalcTable(); + _vm->getEngine()->getPointer().updateCursor(); } Graphics::Surface *screen = g_system->lockScreen(); const uint16 *src = (const uint16 *)buf; for (int i = 0; i < h; i++) { uint16 *dst = (uint16 *)screen->getBasePtr(x, y + i); for (int j = 0; j < w; j++) { - dst[j] = _precalcTable[src[j] & 0x7FFF]; + dst[j] = RMGfxTargetBuffer::_precalcTable[src[j] & 0x7FFF]; } src += (pitch / 2); } g_system->unlockScreen(); } else { - if (_precalcTable) { - delete[] _precalcTable; - _precalcTable = 0; + if (RMGfxTargetBuffer::_precalcTable) { + RMGfxTargetBuffer::freeBWPrecalcTable(); + _vm->getEngine()->getPointer().updateCursor(); } g_system->copyRectToScreen(buf, pitch, x, y, w, h); } @@ -116,8 +95,6 @@ void RMWindow::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, * Close the window */ void RMWindow::close() { - delete[] _precalcTable; - _precalcTable = 0; } void RMWindow::grabThumbnail(uint16 *thumbmem) { diff --git a/engines/tony/window.h b/engines/tony/window.h index c72a3afd8e..6528060f17 100644 --- a/engines/tony/window.h +++ b/engines/tony/window.h @@ -70,9 +70,7 @@ protected: bool _bGrabThumbnail; bool _bGrabMovie; uint16 *_wThumbBuf; - uint16 *_precalcTable; - void createBWPrecalcTable(); void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h); void wipeEffect(Common::Rect &rcBoundEllipse); void getNewFrameWipe(byte *lpBuf, Common::Rect &rcBoundEllipse); -- cgit v1.2.3 From 924aac4389abaf7bd3ce266fbd53c0bcdf474ba9 Mon Sep 17 00:00:00 2001 From: Torbj旦rn Andersson Date: Mon, 2 Jul 2012 20:48:57 +0200 Subject: TONY: Fix warning about statement without effect. --- engines/tony/game.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index abc7f1a2e0..5b9502468a 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -1604,7 +1604,7 @@ void RMPointer::updateCursor() { uint16 *src = (uint16 *)cursorData; for (int i = 0; i < 64; i++) { uint16 *lineP = src; - for (int j = 0; j < 64; j++, lineP) { + for (int j = 0; j < 64; j++) { lineP[j] = RMGfxTargetBuffer::_precalcTable[lineP[j] & 0x7FFF]; } src += 64; -- cgit v1.2.3 From 9cc7d6c6c5fc260fd88135db3d14fa61841370eb Mon Sep 17 00:00:00 2001 From: Torbj旦rn Andersson Date: Mon, 2 Jul 2012 20:51:14 +0200 Subject: TONY: Fix crash when entering "sepia" mode by loading a savegame. Apparently, in this case the cursor is updated before _precalcTable has been created. Added safeguard against that. --- engines/tony/game.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'engines') diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 5b9502468a..f1e8f0e614 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -1601,6 +1601,9 @@ void RMPointer::updateCursor() { // If in black & white mode, convert the cursor if (GLOBALS._bCfgAnni30) { + if (!RMGfxTargetBuffer::_precalcTable) { + RMGfxTargetBuffer::createBWPrecalcTable(); + } uint16 *src = (uint16 *)cursorData; for (int i = 0; i < 64; i++) { uint16 *lineP = src; -- cgit v1.2.3 From 09d9b0d8c989eb57c9e2254ecf9074cdc1963636 Mon Sep 17 00:00:00 2001 From: Torbj旦rn Andersson Date: Sun, 15 Jul 2012 20:48:43 +0200 Subject: TONY: Change platform from DOS to Windows This is cosmetic, just to keep the detector from saying that Tony Tough is a DOS game. --- engines/tony/detection_tables.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'engines') diff --git a/engines/tony/detection_tables.h b/engines/tony/detection_tables.h index e37ba11dbf..f9881c29f2 100644 --- a/engines/tony/detection_tables.h +++ b/engines/tony/detection_tables.h @@ -37,7 +37,7 @@ static const TonyGameDescription gameDescriptions[] = { AD_LISTEND }, Common::EN_ANY, - Common::kPlatformPC, + Common::kPlatformWindows, ADGF_NO_FLAGS, GUIO1(GUIO_NONE) }, @@ -54,7 +54,7 @@ static const TonyGameDescription gameDescriptions[] = { AD_LISTEND }, Common::EN_ANY, - Common::kPlatformPC, + Common::kPlatformWindows, ADGF_DEMO, GUIO1(GUIO_NONE) }, @@ -70,7 +70,7 @@ static const TonyGameDescription gameDescriptions[] = { AD_LISTEND }, Common::EN_ANY, - Common::kPlatformPC, + Common::kPlatformWindows, ADGF_DEMO | GF_COMPRESSED, GUIO1(GUIO_NONE) }, @@ -86,7 +86,7 @@ static const TonyGameDescription gameDescriptions[] = { AD_LISTEND }, Common::FR_FRA, - Common::kPlatformPC, + Common::kPlatformWindows, ADGF_NO_FLAGS, GUIO1(GUIO_NONE) }, @@ -102,7 +102,7 @@ static const TonyGameDescription gameDescriptions[] = { AD_LISTEND }, Common::DE_DEU, - Common::kPlatformPC, + Common::kPlatformWindows, ADGF_NO_FLAGS, GUIO1(GUIO_NONE) }, @@ -118,7 +118,7 @@ static const TonyGameDescription gameDescriptions[] = { AD_LISTEND }, Common::IT_ITA, - Common::kPlatformPC, + Common::kPlatformWindows, ADGF_NO_FLAGS, GUIO1(GUIO_NONE) }, @@ -134,7 +134,7 @@ static const TonyGameDescription gameDescriptions[] = { AD_LISTEND }, Common::PL_POL, - Common::kPlatformPC, + Common::kPlatformWindows, ADGF_NO_FLAGS, GUIO1(GUIO_NONE) }, -- cgit v1.2.3 From a5bfbeed32c175119db2eb2510a7afd3626fae47 Mon Sep 17 00:00:00 2001 From: Torbj旦rn Andersson Date: Thu, 26 Jul 2012 20:15:32 +0200 Subject: TONY: Don't pass uninitialised rect to addDirtyRect() Wait until after we have the destination rect. Unfortunately, this does not fix any of the graphical glitches during the intro. --- engines/tony/gfxcore.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 119b730303..ca6dd45c14 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -2018,9 +2018,6 @@ void RMGfxBox::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) uint16 *buf = bigBuf; RMRect rcDst; - // Specify the drawn area - bigBuf.addDirtyRect(rcDst); - // It takes the destination rectangle rcDst = prim->getDst(); buf += rcDst._y1 * bigBuf.getDimx() + rcDst._x1; @@ -2032,6 +2029,9 @@ void RMGfxBox::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) buf += bigBuf.getDimx() - rcDst.width(); } + + // Specify the drawn area + bigBuf.addDirtyRect(rcDst); } -- cgit v1.2.3 From 3b40d141529160d48da954397fa7b58659b46da5 Mon Sep 17 00:00:00 2001 From: Torbj旦rn Andersson Date: Tue, 31 Jul 2012 20:36:48 +0200 Subject: TONY: Whitespace changes. --- engines/tony/mpal/expr.cpp | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/expr.cpp b/engines/tony/mpal/expr.cpp index c2fadd63df..7cf2cb3fc8 100644 --- a/engines/tony/mpal/expr.cpp +++ b/engines/tony/mpal/expr.cpp @@ -141,41 +141,41 @@ static int Compute(int a, int b, byte symbol) { switch (symbol) { case OP_MUL: return a * b; - case OP_DIV: + case OP_DIV: return a / b; - case OP_MODULE: + case OP_MODULE: return a % b; - case OP_ADD: + case OP_ADD: return a + b; - case OP_SUB: + case OP_SUB: return a - b; - case OP_SHL: + case OP_SHL: return a << b; - case OP_SHR: + case OP_SHR: return a >> b; - case OP_MINOR: + case OP_MINOR: return a < b; - case OP_MAJOR: + case OP_MAJOR: return a > b; - case OP_MINEQ: + case OP_MINEQ: return a <= b; - case OP_MAJEQ: + case OP_MAJEQ: return a >= b; - case OP_EQUAL: + case OP_EQUAL: return a == b; - case OP_NOEQUAL: + case OP_NOEQUAL: return a != b; - case OP_BITAND: + case OP_BITAND: return a & b; - case OP_BITXOR: + case OP_BITXOR: return a ^ b; - case OP_BITOR: + case OP_BITOR: return a | b; - case OP_AND: + case OP_AND: return a && b; - case OP_OR: + case OP_OR: return a || b; - default: + default: GLOBALS._mpalError = 1; break; } -- cgit v1.2.3 From fab814b7747be31278fbbfa1d46e28115cd6624e Mon Sep 17 00:00:00 2001 From: Torbj旦rn Andersson Date: Tue, 31 Jul 2012 21:29:25 +0200 Subject: TONY: Remove unused variable. It wasn't used in the original engine either. --- engines/tony/mpal/loadmpc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index 1ec921dbd4..371a94e24a 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -529,7 +529,7 @@ static const byte *ParseLocation(const byte *lpBuf, LPMPALLOCATION lpmlLocation) bool ParseMpc(const byte *lpBuf) { uint16 i, j; uint16 wLen; - byte *lpTemp, *lpTemp2; + byte *lpTemp; /* 1. Variables */ if (lpBuf[0] != 'V' || lpBuf[1] != 'A' || lpBuf[2] != 'R' || lpBuf[3] != 'S') @@ -587,7 +587,7 @@ bool ParseMpc(const byte *lpBuf) { j += lpBuf[j] + 1; GLOBALS._lpmmMsgs->_hText = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, j + 1); - lpTemp2 = lpTemp = (byte *)globalLock(GLOBALS._lpmmMsgs->_hText); + lpTemp = (byte *)globalLock(GLOBALS._lpmmMsgs->_hText); for (j = 0; lpBuf[j] != 0;) { copyMemory(lpTemp, &lpBuf[j + 1], lpBuf[j]); -- cgit v1.2.3 From 846f9644ddd471b6e6c7b147e971382dddda14fb Mon Sep 17 00:00:00 2001 From: Torbj旦rn Andersson Date: Wed, 1 Aug 2012 22:34:00 +0200 Subject: TONY: Clip width to avoid crash when drawing flipped sprite This fixes - or at least work around - a failed assertion when Pantagruel leaves the office at the beginning of the game. --- engines/tony/gfxcore.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'engines') diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index ca6dd45c14..0c331cc0e9 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -927,6 +927,9 @@ void RMGfxSourceBuffer8RLE::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPri u = _dimx - (width + u); x1 = (prim->getDst()._x1 + _dimx - 1) - u; + if (width > x1) + width = x1; + // Specify the drawn area bigBuf.addDirtyRect(Common::Rect(x1 - width, y1, x1, y1 + height)); -- cgit v1.2.3 From dfb0e4f7001347aa50ee9707229647783f8f88c0 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 12 Aug 2012 19:47:48 +1000 Subject: TONY: Fix dirty rect refresh glitch in the introduction sequence --- engines/tony/gfxengine.h | 1 + engines/tony/window.cpp | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/tony/gfxengine.h b/engines/tony/gfxengine.h index a69182d032..8be09ddd8b 100644 --- a/engines/tony/gfxengine.h +++ b/engines/tony/gfxengine.h @@ -130,6 +130,7 @@ public: // Manage a location uint32 loadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start); void unloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result); + int getCurrentLocation() const { return _nCurLoc; } // Freeze and unfreeze void freeze(); diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index c509a12f9e..2d5954a74c 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -140,11 +140,16 @@ void RMWindow::getNewFrame(RMGfxTargetBuffer &bigBuf, Common::Rect *rcBoundEllip // Get a pointer to the bytes of the source buffer byte *lpBuf = bigBuf; + // FIXME: The current dirty rect handling code has a minor issue with screen refresh in one + // scene in the introduction sequence as the scene changes. For now, we're working around the + // problem by explicitly having full screen refreshes on that scene + bool fullRefresh = _vm->getEngine()->getCurrentLocation() == 98; + if (rcBoundEllipse != NULL) { // Circular wipe effect getNewFrameWipe(lpBuf, *rcBoundEllipse); _wiping = true; - } else if (_wiping) { + } else if (_wiping || fullRefresh) { // Just finished a wiping effect, so copy the full screen copyRectToScreen(lpBuf, RM_SX * 2, 0, 0, RM_SX, RM_SY); _wiping = false; -- cgit v1.2.3 From 482c1a71b04bf1b5d0f18847ce445c45085e77fa Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 22 Aug 2012 22:28:08 +1000 Subject: TONY: Removed some TODO warnings that aren't needed any longer --- engines/tony/tony.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 30ab716c20..a44d9410f3 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -355,15 +355,15 @@ FPSfx *TonyEngine::createSFX(Common::SeekableReadStream *stream) { } void TonyEngine::preloadUtilSFX(int nChannel, const char *fn) { - warning("TonyEngine::preloadUtilSFX"); + // No preloading is needed in ScummVM } void TonyEngine::unloadAllSFX() { - warning("TonyEngine::unloadAllSFX"); + // No preloading is needed in ScummVM } void TonyEngine::unloadAllUtilSFX() { - warning("TonyEngine::unloadAllUtilSFX"); + // No preloading is needed in ScummVM } void TonyEngine::initMusic() { -- cgit v1.2.3 From c3407390013b1e1826bdb31979a50f5e8a957f04 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Wed, 22 Aug 2012 14:00:46 +0200 Subject: TONY: Replace _vm with g_vm. --- engines/tony/custom.cpp | 110 ++++++++++++++++++++-------------------- engines/tony/debugger.cpp | 6 +-- engines/tony/font.cpp | 58 ++++++++++----------- engines/tony/game.cpp | 66 ++++++++++++------------ engines/tony/gfxengine.cpp | 24 ++++----- engines/tony/input.cpp | 6 +-- engines/tony/inventory.cpp | 32 ++++++------ engines/tony/loc.cpp | 10 ++-- engines/tony/mpal/mpal.cpp | 22 ++++---- engines/tony/mpal/mpalutils.cpp | 2 +- engines/tony/sound.cpp | 6 +-- engines/tony/tony.cpp | 36 ++++++------- engines/tony/tony.h | 4 +- engines/tony/tonychar.cpp | 4 +- engines/tony/window.cpp | 6 +-- 15 files changed, 196 insertions(+), 196 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 35ae8849f1..6853cf51a0 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -234,12 +234,12 @@ DECLARE_CUSTOM_FUNCTION(SetPointer)(CORO_PARAM, uint32 dwPointer, uint32, uint32 VoiceHeader *SearchVoiceHeader(uint32 codehi, uint32 codelo) { int code = (codehi << 16) | codelo; - if (_vm->_voices.size() == 0) + if (g_vm->_voices.size() == 0) return NULL; - for (uint i = 0; i < _vm->_voices.size(); i++) - if (_vm->_voices[i]._code == code) - return &_vm->_voices[i]; + for (uint i = 0; i < g_vm->_voices.size(); i++) + if (g_vm->_voices[i]._code == code) + return &g_vm->_voices[i]; return NULL; } @@ -273,11 +273,11 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX _ctx->curOffset = _ctx->curVoc->_offset; // First time allocation - _vm->_vdbFP.seek(_ctx->curOffset); - _vm->_theSound.createSfx(&_ctx->voice); + g_vm->_vdbFP.seek(_ctx->curOffset); + g_vm->_theSound.createSfx(&_ctx->voice); - _ctx->voice->loadVoiceFromVDB(_vm->_vdbFP); - _ctx->curOffset = _vm->_vdbFP.pos(); + _ctx->voice->loadVoiceFromVDB(g_vm->_vdbFP); + _ctx->curOffset = g_vm->_vdbFP.pos(); _ctx->voice->setLoop(false); } @@ -331,11 +331,11 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX _ctx->voice->play(); _ctx->text.setCustomSkipHandle2(_ctx->voice->_hEndOfBuffer); } else { - _vm->_vdbFP.seek(_ctx->curOffset); - _vm->_theSound.createSfx(&_ctx->voice); - _ctx->voice->loadVoiceFromVDB(_vm->_vdbFP); + g_vm->_vdbFP.seek(_ctx->curOffset); + g_vm->_theSound.createSfx(&_ctx->voice); + _ctx->voice->loadVoiceFromVDB(g_vm->_vdbFP); - _ctx->curOffset = _vm->_vdbFP.pos(); + _ctx->curOffset = g_vm->_vdbFP.pos(); _ctx->voice->setLoop(false); _ctx->voice->play(); _ctx->text.setCustomSkipHandle2(_ctx->voice->_hEndOfBuffer); @@ -512,7 +512,7 @@ DECLARE_CUSTOM_FUNCTION(CloseLocation)(CORO_PARAM, uint32, uint32, uint32, uint3 CORO_INVOKE_0(GLOBALS.WaitWipeEnd); } - _vm->stopMusic(4); + g_vm->stopMusic(4); // On exit, unload and unfreeze CORO_INVOKE_2(GLOBALS.UnloadLocation, true, NULL); @@ -535,7 +535,7 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint } if (GLOBALS._lastTappeto != GLOBALS._ambiance[nLoc]) { - _vm->stopMusic(4); + g_vm->stopMusic(4); } // On exit, unfreeze @@ -550,7 +550,7 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint if (GLOBALS._lastTappeto != GLOBALS._ambiance[nLoc]) { GLOBALS._lastTappeto = GLOBALS._ambiance[nLoc]; if (GLOBALS._lastTappeto != 0) - _vm->playMusic(4, ambianceFile[GLOBALS._lastTappeto], 0, true, 2000); + g_vm->playMusic(4, ambianceFile[GLOBALS._lastTappeto], 0, true, 2000); } if (!GLOBALS._bNoBullsEye) { @@ -1286,7 +1286,7 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui _ctx->startpt = GLOBALS._loc->scrollPosition(); - _ctx->dwStartTime = _vm->getTime(); + _ctx->dwStartTime = g_vm->getTime(); if (sX) _ctx->dwTotalTime = _ctx->dimx * (1000 / 35) / sX; @@ -1294,7 +1294,7 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui _ctx->dwTotalTime = _ctx->dimy * (1000 / 35) / sY; while ((_ctx->lx != 0 || _ctx->ly != 0) && !GLOBALS._bSkipIdle) { - _ctx->dwCurTime = _vm->getTime() - _ctx->dwStartTime; + _ctx->dwCurTime = g_vm->getTime() - _ctx->dwStartTime; if (_ctx->dwCurTime > _ctx->dwTotalTime) break; @@ -1368,11 +1368,11 @@ DECLARE_CUSTOM_FUNCTION(ChangeHotspot)(CORO_PARAM, uint32 dwCode, uint32 nX, uin DECLARE_CUSTOM_FUNCTION(AutoSave)(CORO_PARAM, uint32, uint32, uint32, uint32) { - _vm->autoSave(coroParam); + g_vm->autoSave(coroParam); } DECLARE_CUSTOM_FUNCTION(AbortGame)(CORO_PARAM, uint32, uint32, uint32, uint32) { - _vm->abortGame(); + g_vm->abortGame(); } DECLARE_CUSTOM_FUNCTION(ShakeScreen)(CORO_PARAM, uint32 nScosse, uint32, uint32, uint32) { @@ -1384,12 +1384,12 @@ DECLARE_CUSTOM_FUNCTION(ShakeScreen)(CORO_PARAM, uint32 nScosse, uint32, uint32, CORO_BEGIN_CODE(_ctx); - _ctx->curTime = _vm->getTime(); + _ctx->curTime = g_vm->getTime(); _ctx->dirx = 1; _ctx->diry = 1; - while (_vm->getTime() < _ctx->curTime + nScosse) { + while (g_vm->getTime() < _ctx->curTime + nScosse) { CORO_INVOKE_0(GLOBALS.WaitFrame); GLOBALS.Freeze(); @@ -1397,7 +1397,7 @@ DECLARE_CUSTOM_FUNCTION(ShakeScreen)(CORO_PARAM, uint32 nScosse, uint32, uint32, GLOBALS._tony->setFixedScroll(RMPoint(1 * _ctx->dirx, 1 * _ctx->diry)); GLOBALS.Unfreeze(); - _ctx->i = _vm->_randomSource.getRandomNumber(2); + _ctx->i = g_vm->_randomSource.getRandomNumber(2); if (_ctx->i == 0 || _ctx->i == 2) _ctx->dirx = -_ctx->dirx; @@ -1486,7 +1486,7 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess _ctx->voice = NULL; if (_ctx->curVoc) { // Position within the database of entries, beginning at the first - _vm->_vdbFP.seek(_ctx->curVoc->_offset); + g_vm->_vdbFP.seek(_ctx->curVoc->_offset); _ctx->curOffset = _ctx->curVoc->_offset; } @@ -1525,14 +1525,14 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess GLOBALS.LinkGraphicTask(_ctx->text); if (_ctx->curVoc) { - _vm->_theSound.createSfx(&_ctx->voice); - _vm->_vdbFP.seek(_ctx->curOffset); - _ctx->voice->loadVoiceFromVDB(_vm->_vdbFP); + g_vm->_theSound.createSfx(&_ctx->voice); + g_vm->_vdbFP.seek(_ctx->curOffset); + _ctx->voice->loadVoiceFromVDB(g_vm->_vdbFP); _ctx->voice->setLoop(false); if (bIsBack) _ctx->voice->setVolume(55); _ctx->voice->play(); _ctx->text->setCustomSkipHandle2(_ctx->voice->_hEndOfBuffer); - _ctx->curOffset = _vm->_vdbFP.pos(); + _ctx->curOffset = g_vm->_vdbFP.pos(); } // Wait for the end of display @@ -1682,7 +1682,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes _ctx->pt = RMPoint(GLOBALS._mCharacter[nChar]._x, GLOBALS._mCharacter[nChar]._y); // Parameter for special actions: random between the spoken - _ctx->parm = (GLOBALS._mCharacter[nChar]._curGroup * 10) + _vm->_randomSource.getRandomNumber( + _ctx->parm = (GLOBALS._mCharacter[nChar]._curGroup * 10) + g_vm->_randomSource.getRandomNumber( GLOBALS._mCharacter[nChar]._numTalks[GLOBALS._mCharacter[nChar]._curGroup] - 1) + 1; // Try to run the custom function to initialize the speech @@ -1697,8 +1697,8 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes _ctx->voice = NULL; if (_ctx->curVoc) { // Position within the database of entries, beginning at the first - // fseek(_vm->m_vdbFP, curVoc->offset, SEEK_SET); - _vm->_vdbFP.seek(_ctx->curVoc->_offset); + // fseek(g_vm->m_vdbFP, curVoc->offset, SEEK_SET); + g_vm->_vdbFP.seek(_ctx->curVoc->_offset); _ctx->curOffset = _ctx->curVoc->_offset; } @@ -1738,15 +1738,15 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes GLOBALS.LinkGraphicTask(_ctx->text); if (_ctx->curVoc) { - _vm->_theSound.createSfx(&_ctx->voice); - _vm->_vdbFP.seek(_ctx->curOffset); - _ctx->voice->loadVoiceFromVDB(_vm->_vdbFP); + g_vm->_theSound.createSfx(&_ctx->voice); + g_vm->_vdbFP.seek(_ctx->curOffset); + _ctx->voice->loadVoiceFromVDB(g_vm->_vdbFP); _ctx->voice->setLoop(false); if (bIsBack) _ctx->voice->setVolume(55); _ctx->voice->play(); _ctx->text->setCustomSkipHandle2(_ctx->voice->_hEndOfBuffer); - _ctx->curOffset = _vm->_vdbFP.pos(); + _ctx->curOffset = g_vm->_vdbFP.pos(); } // Wait for the end of display @@ -1806,9 +1806,9 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg if (_ctx->curVoc) { // Position within the database of entries, beginning at the first - _vm->_vdbFP.seek(_ctx->curVoc->_offset); - _vm->_theSound.createSfx(&_ctx->voice); - _ctx->voice->loadVoiceFromVDB(_vm->_vdbFP); + g_vm->_vdbFP.seek(_ctx->curVoc->_offset); + g_vm->_theSound.createSfx(&_ctx->voice); + _ctx->voice->loadVoiceFromVDB(g_vm->_vdbFP); _ctx->voice->setLoop(false); if (_ctx->bIsBack) _ctx->voice->setVolume(55); @@ -1863,7 +1863,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg _ctx->pt = RMPoint(GLOBALS._mCharacter[nPers]._x, GLOBALS._mCharacter[nPers]._y); // Parameter for special actions. Random between the spoken. - _ctx->parm = (GLOBALS._mCharacter[nPers]._curGroup * 10) + _vm->_randomSource.getRandomNumber( + _ctx->parm = (GLOBALS._mCharacter[nPers]._curGroup * 10) + g_vm->_randomSource.getRandomNumber( GLOBALS._mCharacter[nPers]._numTalks[GLOBALS._mCharacter[nPers]._curGroup] - 1) + 1; if (GLOBALS._mCharacter[nPers]._numTexts != 0 && GLOBALS._mCharacter[nPers]._bInTexts) { @@ -2097,11 +2097,11 @@ void ThreadFadeInMusic(CORO_PARAM, const void *nMusic) { debug("Start FadeIn Music"); for (_ctx->i = 0; _ctx->i < 16; _ctx->i++) { - _vm->setMusicVolume(nChannel, _ctx->i * 4); + g_vm->setMusicVolume(nChannel, _ctx->i * 4); CORO_INVOKE_1(CoroScheduler.sleep, 100); } - _vm->setMusicVolume(nChannel, 64); + g_vm->setMusicVolume(nChannel, 64); debug("End FadeIn Music"); @@ -2120,23 +2120,23 @@ void ThreadFadeOutMusic(CORO_PARAM, const void *nMusic) { CORO_BEGIN_CODE(_ctx); - _ctx->startVolume = _vm->getMusicVolume(nChannel); + _ctx->startVolume = g_vm->getMusicVolume(nChannel); debug("Start FadeOut Music"); for (_ctx->i = 16; _ctx->i > 0 && !GLOBALS._bFadeOutStop; _ctx->i--) { if (_ctx->i * 4 < _ctx->startVolume) - _vm->setMusicVolume(nChannel, _ctx->i * 4); + g_vm->setMusicVolume(nChannel, _ctx->i * 4); CORO_INVOKE_1(CoroScheduler.sleep, 100); } if (!GLOBALS._bFadeOutStop) - _vm->setMusicVolume(nChannel, 0); + g_vm->setMusicVolume(nChannel, 0); // If a jingle is played, stop it if (nChannel == 2) - _vm->stopMusic(2); + g_vm->stopMusic(2); debug("End FadeOut Music"); @@ -2166,28 +2166,28 @@ DECLARE_CUSTOM_FUNCTION(FadeInJingle)(CORO_PARAM, uint32, uint32, uint32, uint32 } DECLARE_CUSTOM_FUNCTION(StopSoundEffect)(CORO_PARAM, uint32, uint32, uint32, uint32) { - _vm->stopMusic(GLOBALS._curSoundEffect); + g_vm->stopMusic(GLOBALS._curSoundEffect); } DECLARE_CUSTOM_FUNCTION(StopJingle)(CORO_PARAM, uint32, uint32, uint32, uint32) { - _vm->stopMusic(2); + g_vm->stopMusic(2); } DECLARE_CUSTOM_FUNCTION(MuteSoundEffect)(CORO_PARAM, uint32, uint32, uint32, uint32) { - _vm->setMusicVolume(GLOBALS._curSoundEffect, 0); + g_vm->setMusicVolume(GLOBALS._curSoundEffect, 0); } DECLARE_CUSTOM_FUNCTION(DemuteSoundEffect)(CORO_PARAM, uint32, uint32, uint32, uint32) { GLOBALS._bFadeOutStop = true; - _vm->setMusicVolume(GLOBALS._curSoundEffect, 64); + g_vm->setMusicVolume(GLOBALS._curSoundEffect, 64); } DECLARE_CUSTOM_FUNCTION(MuteJingle)(CORO_PARAM, uint32, uint32, uint32, uint32) { - _vm->setMusicVolume(2, 0); + g_vm->setMusicVolume(2, 0); } DECLARE_CUSTOM_FUNCTION(DemuteJingle)(CORO_PARAM, uint32, uint32, uint32, uint32) { - _vm->setMusicVolume(2, 64); + g_vm->setMusicVolume(2, 64); } void CustPlayMusic(uint32 nChannel, const char *mFN, uint32 nFX, bool bLoop, int nSync = 0) { @@ -2298,7 +2298,7 @@ DECLARE_CUSTOM_FUNCTION(OpenInitLoadMenu)(CORO_PARAM, uint32, uint32, uint32, ui CORO_BEGIN_CODE(_ctx); GLOBALS.Freeze(); - CORO_INVOKE_0(_vm->openInitLoadMenu); + CORO_INVOKE_0(g_vm->openInitLoadMenu); GLOBALS.Unfreeze(); CORO_END_CODE; @@ -2311,7 +2311,7 @@ DECLARE_CUSTOM_FUNCTION(OpenInitOptions)(CORO_PARAM, uint32, uint32, uint32, uin CORO_BEGIN_CODE(_ctx); GLOBALS.Freeze(); - CORO_INVOKE_0(_vm->openInitOptions); + CORO_INVOKE_0(g_vm->openInitOptions); GLOBALS.Unfreeze(); CORO_END_CODE; @@ -2367,13 +2367,13 @@ DECLARE_CUSTOM_FUNCTION(DoCredits)(CORO_PARAM, uint32 nMsg, uint32 dwTime, uint3 GLOBALS.LinkGraphicTask(&_ctx->text[_ctx->i]); } - _ctx->startTime = _vm->getTime(); + _ctx->startTime = g_vm->getTime(); - while (_ctx->startTime + dwTime * 1000 > _vm->getTime()) { + while (_ctx->startTime + dwTime * 1000 > g_vm->getTime()) { CORO_INVOKE_0(GLOBALS.WaitFrame); if (GLOBALS._input->mouseLeftClicked() || GLOBALS._input->mouseRightClicked()) break; - if (_vm->getEngine()->getInput().getAsyncKeyState(Common::KEYCODE_TAB)) + if (g_vm->getEngine()->getInput().getAsyncKeyState(Common::KEYCODE_TAB)) break; } diff --git a/engines/tony/debugger.cpp b/engines/tony/debugger.cpp index 75e58d68d4..6355284ece 100644 --- a/engines/tony/debugger.cpp +++ b/engines/tony/debugger.cpp @@ -88,7 +88,7 @@ bool Debugger::Cmd_Scene(int argc, const char **argv) { } int sceneNumber = strToInt(argv[1]); - if (sceneNumber >= _vm->_theBoxes.getLocBoxesCount()) { + if (sceneNumber >= g_vm->_theBoxes.getLocBoxesCount()) { DebugPrintf("Invalid scene\n"); return true; } @@ -100,7 +100,7 @@ bool Debugger::Cmd_Scene(int argc, const char **argv) { } else { // Get the box areas for the scene, and choose one so as to have a default // position for Tony that will be in the walkable areas - RMBoxLoc *box = _vm->_theBoxes.getBoxes(sceneNumber); + RMBoxLoc *box = g_vm->_theBoxes.getBoxes(sceneNumber); scenePos.set(box->_boxes[0]._hotspot[0]._hotx, box->_boxes[0]._hotspot[0]._hoty); } @@ -122,7 +122,7 @@ bool Debugger::Cmd_DirtyRects(int argc, const char **argv) { DebugPrintf("Usage; %s [on | off]\n", argv[0]); return true; } else { - _vm->_window.showDirtyRects(strcmp(argv[1], "on") == 0); + g_vm->_window.showDirtyRects(strcmp(argv[1], "on") == 0); return false; } } diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index efce8dbe6e..2d334434d4 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -322,7 +322,7 @@ void RMFontDialog::init() { _lTable['E'] = 10; _lTable['F'] = 11; - if (_vm->getLanguage() == Common::PL_POL) { + if (g_vm->getLanguage() == Common::PL_POL) { // Polish characters //AaCcEeLlNnOoSsZzZz //ス謎戊3剔囀 @@ -365,7 +365,7 @@ void RMFontDialog::init() { _lTable[(byte)''] = 14; _lTable[(byte)''] = 13; - } else if (_vm->getLanguage() == Common::RU_RUS) { + } else if (g_vm->getLanguage() == Common::RU_RUS) { // Russian Characters // WARNING: The Russian font uses many of the ISO-Latin-1 font, @@ -508,7 +508,7 @@ void RMFontDialog::init() { _lTable[(byte)''] = 15; _lTable[(byte)''] = 14; - } else if (_vm->getLanguage() == Common::CZ_CZE) { + } else if (g_vm->getLanguage() == Common::CZ_CZE) { // Czech _cTable[(byte)''] = 196; _cTable[(byte)''] = 197; @@ -574,7 +574,7 @@ void RMFontDialog::init() { _lTable[(byte)''] = 13; _lTable[(byte)''] = 13; - } else if (_vm->getLanguage() == Common::FR_FRA) { + } else if (g_vm->getLanguage() == Common::FR_FRA) { // French _cTable[(byte)''] = 226; @@ -595,7 +595,7 @@ void RMFontDialog::init() { _lTable[(byte)''] = 11; _lTable[(byte)''] = 11; - } else if (_vm->getLanguage() == Common::DE_DEU) { + } else if (g_vm->getLanguage() == Common::DE_DEU) { _cTable[(byte)''] = 234; // 'SS' = 235 _cTable[(byte)''] = 236; @@ -686,7 +686,7 @@ void RMFontMacc::init() { //_cTable[(byte)''] = 100; // u with ball _cTable[(byte)''] = 101; - if (_vm->getLanguage() == Common::PL_POL) { + if (g_vm->getLanguage() == Common::PL_POL) { // Polish characters //AaCcEeLlNnOoSsZzZz //ス謎戊3剔囀 @@ -729,7 +729,7 @@ void RMFontMacc::init() { _lTable[(byte)''] = 14; _lTable[(byte)''] = 13; - } else if (_vm->getLanguage() == Common::RU_RUS) { + } else if (g_vm->getLanguage() == Common::RU_RUS) { // Russian Characters // WARNING: The Russian font uses many of the ISO-Latin-1 font, // allowing for further translations. To support Tonyin other langauges, @@ -870,7 +870,7 @@ void RMFontMacc::init() { _lTable[(byte)''] = 11; _lTable[(byte)''] = 11; - } else if (_vm->getLanguage() == Common::CZ_CZE) { + } else if (g_vm->getLanguage() == Common::CZ_CZE) { // Czech _cTable[(byte)''] = 186; @@ -937,7 +937,7 @@ void RMFontMacc::init() { _lTable[(byte)''] = 11; _lTable[(byte)''] = 11; - } else if (_vm->getLanguage() == Common::FR_FRA) { + } else if (g_vm->getLanguage() == Common::FR_FRA) { // French _cTable[(byte)''] = 226; @@ -958,7 +958,7 @@ void RMFontMacc::init() { _lTable[(byte)''] = 10; _lTable[(byte)''] = 10; - } else if (_vm->getLanguage() == Common::DE_DEU) { + } else if (g_vm->getLanguage() == Common::DE_DEU) { // German _cTable[(byte)''] = 234; @@ -1136,7 +1136,7 @@ void RMFontCredits::init() { _lTable[':'] = 5; _lTable['\''] = 5; - if (_vm->getLanguage() == Common::PL_POL) { + if (g_vm->getLanguage() == Common::PL_POL) { // Polish characters //AaCcEeLlNnOoSsZzZz //ス謎戊3剔囀 @@ -1179,7 +1179,7 @@ void RMFontCredits::init() { _lTable[(byte)''] = 15; _lTable[(byte)''] = 10; - } else if (_vm->getLanguage() == Common::RU_RUS) { + } else if (g_vm->getLanguage() == Common::RU_RUS) { // Russian Characters // WARNING: The Russian font uses many of the ISO-Latin-1 font, // allowing for further translations. To support Tonyin other langauges, @@ -1320,7 +1320,7 @@ void RMFontCredits::init() { _lTable[(byte)''] = 13; _lTable[(byte)''] = 11; - } else if (_vm->getLanguage() == Common::CZ_CZE) { + } else if (g_vm->getLanguage() == Common::CZ_CZE) { // CZECH Language _cTable[(byte)''] = 196; @@ -1387,7 +1387,7 @@ void RMFontCredits::init() { _lTable[(byte)''] = 10; _lTable[(byte)''] = 10; - } else if (_vm->getLanguage() == Common::FR_FRA) { + } else if (g_vm->getLanguage() == Common::FR_FRA) { // French _cTable[(byte)''] = 226; @@ -1408,7 +1408,7 @@ void RMFontCredits::init() { _lTable[(byte)''] = 11; _lTable[(byte)''] = 11; - } else if (_vm->getLanguage() == Common::DE_DEU) { + } else if (g_vm->getLanguage() == Common::DE_DEU) { // German _cTable[(byte)''] = 234; @@ -1580,7 +1580,7 @@ void RMFontObj::init() { setBothCase('R', 'R', 1); setBothCase('R', 'U', 3); - if (_vm->getLanguage() == Common::PL_POL) { + if (g_vm->getLanguage() == Common::PL_POL) { // Polish characters //ス謎戊3剔囀 //AaCcEeLlNnOoSsZzZz @@ -1611,7 +1611,7 @@ void RMFontObj::init() { _cTable[(byte)''] = _cTable[(byte)''] = 93; _lTable[(byte)''] = _lTable[(byte)''] = 21; - } else if (_vm->getLanguage() == Common::RU_RUS) { + } else if (g_vm->getLanguage() == Common::RU_RUS) { // Russian Characters // WARNING: The Russian font uses many of the ISO-Latin-1 font, // allowing for further translations. To support Tonyin other langauges, @@ -1689,7 +1689,7 @@ void RMFontObj::init() { _lTable[(byte)''] = _lTable[(byte)''] = 18; _lTable[(byte)''] = _lTable[(byte)''] = 18; - } else if (_vm->getLanguage() == Common::CZ_CZE) { + } else if (g_vm->getLanguage() == Common::CZ_CZE) { // Czech _cTable[(byte)''] = _cTable[(byte)''] = 127; @@ -1724,7 +1724,7 @@ void RMFontObj::init() { _lTable[(byte)''] = _lTable[(byte)''] = 16; _lTable[(byte)''] = _lTable[(byte)''] = 16; - } else if (_vm->getLanguage() == Common::FR_FRA) { + } else if (g_vm->getLanguage() == Common::FR_FRA) { // French // Translate accented characters as normal letters @@ -1744,7 +1744,7 @@ void RMFontObj::init() { _cTable[(byte)''] = _cTable[(byte)''] = 20; // u _lTable[(byte)''] = _lTable[(byte)''] = 15; - } else if (_vm->getLanguage() == Common::DE_DEU) { + } else if (g_vm->getLanguage() == Common::DE_DEU) { // German _cTable[''] = 142; @@ -2074,14 +2074,14 @@ void RMTextDialog::removeThis(CORO_PARAM, bool &result) { if (!(GLOBALS._bCfgDubbing && _hCustomSkip2 != CORO_INVALID_PID_VALUE)) { if (GLOBALS._bCfgTimerizedText) { if (!_bForceNoTime) { - if (_vm->getTime() > (uint32)_time + _startTime) + if (g_vm->getTime() > (uint32)_time + _startTime) return; } } } if (!_bNoTab) { - if (_vm->getEngine()->getInput().getAsyncKeyState(Common::KEYCODE_TAB)) + if (g_vm->getEngine()->getInput().getAsyncKeyState(Common::KEYCODE_TAB)) return; } @@ -2095,14 +2095,14 @@ void RMTextDialog::removeThis(CORO_PARAM, bool &result) { // Erase the background else if (!(GLOBALS._bCfgDubbing && _hCustomSkip2 != CORO_INVALID_PID_VALUE)) { if (!_bForceNoTime) { - if (_vm->getTime() > (uint32)_time + _startTime) + if (g_vm->getTime() > (uint32)_time + _startTime) return; } } // If time is forced if (_bForceTime) { - if (_vm->getTime() > (uint32)_time + _startTime) + if (g_vm->getTime() > (uint32)_time + _startTime) return; } @@ -2138,7 +2138,7 @@ void RMTextDialog::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *p CORO_BEGIN_CODE(_ctx); if (_startTime == 0) - _startTime = _vm->getTime(); + _startTime = g_vm->getTime(); if (_bShowed) { if (GLOBALS._bShowSubtitles || _bAlwaysDisplay) { @@ -2481,7 +2481,7 @@ void RMDialogChoice::show(CORO_PARAM, RMGfxTargetBuffer *bigBuf) { if (0) { _bShow = true; } else { - _ctx->starttime = _vm->getTime(); + _ctx->starttime = g_vm->getTime(); _ctx->deltay = 480 - _ptDrawPos._y; _ctx->destpt = _ptDrawPos; _ptDrawPos.set(0, 480); @@ -2494,7 +2494,7 @@ void RMDialogChoice::show(CORO_PARAM, RMGfxTargetBuffer *bigBuf) { while (_ctx->elaps < 700) { CORO_INVOKE_0(mainWaitFrame); mainFreeze(); - _ctx->elaps = _vm->getTime() - _ctx->starttime; + _ctx->elaps = g_vm->getTime() - _ctx->starttime; _ptDrawPos._y = 480 - ((_ctx->deltay * 100) / 700 * _ctx->elaps) / 100; mainUnfreeze(); } @@ -2531,14 +2531,14 @@ void RMDialogChoice::hide(CORO_PARAM) { CORO_BEGIN_CODE(_ctx); if (1) { - _ctx->starttime = _vm->getTime(); + _ctx->starttime = g_vm->getTime(); _ctx->deltay = 480 - _ptDrawPos._y; _ctx->elaps = 0; while (_ctx->elaps < 700) { CORO_INVOKE_0(mainWaitFrame); mainFreeze(); - _ctx->elaps = _vm->getTime() - _ctx->starttime; + _ctx->elaps = g_vm->getTime() - _ctx->starttime; _ptDrawPos._y = 480 - ((_ctx->deltay * 100) / 700 * (700 - _ctx->elaps)) / 100; mainUnfreeze(); } diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index f1e8f0e614..d50f480625 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -48,75 +48,75 @@ using namespace MPAL; /****************************************/ uint32 mainLoadLocation(int nLoc, RMPoint pt, RMPoint start) { - return _vm->getEngine()->loadLocation(nLoc, pt, start); + return g_vm->getEngine()->loadLocation(nLoc, pt, start); } void mainUnloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result) { - _vm->getEngine()->unloadLocation(coroParam, bDoOnExit, result); + g_vm->getEngine()->unloadLocation(coroParam, bDoOnExit, result); } void mainLinkGraphicTask(RMGfxTask *task) { - _vm->getEngine()->linkGraphicTask(task); + g_vm->getEngine()->linkGraphicTask(task); } void mainFreeze() { - _vm->getEngine()->freeze(); + g_vm->getEngine()->freeze(); } void mainUnfreeze() { - _vm->getEngine()->unfreeze(); + g_vm->getEngine()->unfreeze(); } void mainWaitFrame(CORO_PARAM) { - CoroScheduler.waitForSingleObject(coroParam, _vm->_hEndOfFrame, CORO_INFINITE); + CoroScheduler.waitForSingleObject(coroParam, g_vm->_hEndOfFrame, CORO_INFINITE); } void mainShowMouse() { - _vm->getEngine()->enableMouse(); + g_vm->getEngine()->enableMouse(); } void mainHideMouse() { - _vm->getEngine()->disableMouse(); + g_vm->getEngine()->disableMouse(); } void mainPlayMusic(int nChannel, const char *filename, int nFX, bool bLoop, int nSync) { - _vm->playMusic(nChannel, filename, nFX, bLoop, nSync); + g_vm->playMusic(nChannel, filename, nFX, bLoop, nSync); } void mainDisableInput() { - _vm->getEngine()->disableInput(); + g_vm->getEngine()->disableInput(); } void mainEnableInput() { - _vm->getEngine()->enableInput(); + g_vm->getEngine()->enableInput(); } void mainInitWipe(int type) { - _vm->getEngine()->initWipe(type); + g_vm->getEngine()->initWipe(type); } void mainCloseWipe() { - _vm->getEngine()->closeWipe(); + g_vm->getEngine()->closeWipe(); } void mainWaitWipeEnd(CORO_PARAM) { - _vm->getEngine()->waitWipeEnd(coroParam); + g_vm->getEngine()->waitWipeEnd(coroParam); } void mainEnableGUI() { - _vm->getEngine()->_bGUIInterface = true; - _vm->getEngine()->_bGUIInventory = true; - _vm->getEngine()->_bGUIOption = true; + g_vm->getEngine()->_bGUIInterface = true; + g_vm->getEngine()->_bGUIInventory = true; + g_vm->getEngine()->_bGUIOption = true; } void mainDisableGUI() { - _vm->getEngine()->_bGUIInterface = false; - _vm->getEngine()->_bGUIInventory = false; - _vm->getEngine()->_bGUIOption = false; + g_vm->getEngine()->_bGUIInterface = false; + g_vm->getEngine()->_bGUIInventory = false; + g_vm->getEngine()->_bGUIOption = false; } void mainSetPerorate(bool bPerorate) { - _vm->getEngine()->setPerorate(bPerorate); + g_vm->getEngine()->setPerorate(bPerorate); } /****************************************************************************\ @@ -489,7 +489,7 @@ void RMOptionScreen::refreshAll(CORO_PARAM) { if (_bEditSaveName) { _ctx->thumb = new RMGfxSourceBuffer16; - _ctx->thumb->init((byte *)_vm->getThumbnail(), 640 / 4, 480 / 4); + _ctx->thumb->init((byte *)g_vm->getThumbnail(), 640 / 4, 480 / 4); if (_nEditPos == 0) addPrim(new RMGfxPrimitive(_ctx->thumb, RMPoint(48, 57))); @@ -856,7 +856,7 @@ void RMOptionScreen::closeState() { } // Save the new settings to ScummVM - _vm->saveSoundSettings(); + g_vm->saveSoundSettings(); } _nState = MENUNONE; @@ -989,7 +989,7 @@ bool RMOptionScreen::close() { // Start fade out _fadeStep++; - _fadeTime = _vm->getTime(); + _fadeTime = g_vm->getTime(); return true; } @@ -1053,7 +1053,7 @@ void RMOptionScreen::doFrame(CORO_PARAM, RMInput *input) { // Buttons with graphics if (!_bNoLoadSave) { - if (!_vm->getIsDemo()) { + if (!g_vm->getIsDemo()) { _ctx->bRefresh |= _buttonLoad->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); _ctx->bRefresh |= _buttonSave->doFrame(_ctx->mousePos, _ctx->bLeftClick, _ctx->bRightClick); } @@ -1096,7 +1096,7 @@ void RMOptionScreen::doFrame(CORO_PARAM, RMInput *input) { } } -#define KEYPRESS(c) (_vm->getEngine()->getInput().getAsyncKeyState(c)) +#define KEYPRESS(c) (g_vm->getEngine()->getInput().getAsyncKeyState(c)) #define PROCESS_CHAR(cod,c) if (KEYPRESS(cod)) { \ _editName[strlen(_editName) + 1] = '\0'; _editName[strlen(_editName)] = c; _ctx->bRefresh = true; } @@ -1153,7 +1153,7 @@ void RMOptionScreen::doFrame(CORO_PARAM, RMInput *input) { // OK if (KEYPRESS(Common::KEYCODE_RETURN)) { _bEditSaveName = false; - _vm->saveState(_statePos + _nEditPos, _editName); + g_vm->saveState(_statePos + _nEditPos, _editName); close(); } @@ -1191,7 +1191,7 @@ void RMOptionScreen::doFrame(CORO_PARAM, RMInput *input) { // There by saving or loading!!! if (_nState == MENULOAD && _curThumb[_ctx->i] != NULL) { // Loading - CORO_INVOKE_1(_vm->loadState, _statePos + _ctx->i); + CORO_INVOKE_1(g_vm->loadState, _statePos + _ctx->i); close(); } else if (_nState == MENUSAVE && (_statePos != 0 || _ctx->i != 0)) { // Turn on edit mode @@ -1215,7 +1215,7 @@ void RMOptionScreen::doFrame(CORO_PARAM, RMInput *input) { _bQuitConfirm = false; _ctx->bRefresh = true; - _vm->quitGame(); + g_vm->quitGame(); } } else { if (_buttonQuit->isActive()) { @@ -1281,7 +1281,7 @@ void RMOptionScreen::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive CORO_BEGIN_CODE(_ctx); - _ctx->curTime = _vm->getTime(); + _ctx->curTime = g_vm->getTime(); #define FADE_SPEED 20 #define SYNC (_ctx->curTime - _fadeTime) / 25 @@ -1337,7 +1337,7 @@ void RMOptionScreen::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive if (_fadeY > 480) { _fadeY = 480; _fadeStep++; - _vm->hideLocation(); + g_vm->hideLocation(); } prim->setSrc(RMRect(0, 480 - _fadeY, 640, 480)); @@ -1347,7 +1347,7 @@ void RMOptionScreen::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive } else if (_fadeStep == 7) { // Menu OFF - _vm->showLocation(); + g_vm->showLocation(); _fadeStep++; } else if (_fadeStep == 8) { @@ -1399,7 +1399,7 @@ bool RMOptionScreen::loadThumbnailFromSaveState(int nState, byte *lpDestBuf, RMS diff = 10; // Get the savegame filename for the given slot - buf = _vm->getSaveStateFileName(nState); + buf = g_vm->getSaveStateFileName(nState); // Try and open the savegame f = g_system->getSavefileManager()->openForLoading(buf); diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 726ee07e28..183e68c8c6 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -110,7 +110,7 @@ void RMGfxEngine::openOptionScreen(CORO_PARAM, int type) { CORO_INVOKE_3(_opt.initSaveMenuOnly, _bigBuf, false, _ctx->bRes); if (_ctx->bRes) { - _vm->pauseSound(true); + g_vm->pauseSound(true); disableInput(); _inv.endCombine(); @@ -120,7 +120,7 @@ void RMGfxEngine::openOptionScreen(CORO_PARAM, int type) { _point.setSpecialPointer(RMPointer::PTR_NONE); _point.setCustomPointer(NULL); enableMouse(); - _vm->grabThumbnail(); + g_vm->grabThumbnail(); // Exists the IDLE to avoid premature death in loading _bMustEnterMenu = true; @@ -162,7 +162,7 @@ void RMGfxEngine::doFrame(CORO_PARAM, bool bDrawLocation) { disableMouse(); enableInput(); mpalStartIdlePoll(_nCurLoc); - _vm->pauseSound(false); + g_vm->pauseSound(false); } } @@ -214,7 +214,7 @@ void RMGfxEngine::doFrame(CORO_PARAM, bool bDrawLocation) { goto SKIPCLICKSINISTRO; } else if (_input.getAsyncKeyState(Common::KEYCODE_ESCAPE)) CORO_INVOKE_1(openOptionScreen, 0); - else if (!_vm->getIsDemo()) { + else if (!g_vm->getIsDemo()) { if (_input.getAsyncKeyState(Common::KEYCODE_F3) || _input.getAsyncKeyState(Common::KEYCODE_F5)) // Save game screen CORO_INVOKE_1(openOptionScreen, 4); @@ -355,7 +355,7 @@ SKIPCLICKSINISTRO: } void RMGfxEngine::initCustomDll() { - setupGlobalVars(&_tony, &_point, &_vm->_theBoxes, &_loc, &_inv, &_input); + setupGlobalVars(&_tony, &_point, &g_vm->_theBoxes, &_loc, &_inv, &_input); } void RMGfxEngine::itemIrq(uint32 dwItem, int nPattern, int nStatus) { @@ -475,8 +475,8 @@ void RMGfxEngine::init() { // Display 'Loading' screen _bigBuf.addDirtyRect(Common::Rect(0, 0, RM_SX, RM_SY)); - _vm->_window.getNewFrame(*this, NULL); - _vm->_window.repaint(); + g_vm->_window.getNewFrame(*this, NULL); + g_vm->_window.repaint(); GLOBALS._bPatIrqFreeze = true; @@ -507,7 +507,7 @@ void RMGfxEngine::init() { // Initialize Tony _tony.init(); - _tony.linkToBoxes(&_vm->_theBoxes); + _tony.linkToBoxes(&g_vm->_theBoxes); // Initialize the inventory and the interface _inv.init(); @@ -631,9 +631,9 @@ void RMGfxEngine::saveState(const Common::String &fn, byte *curThumb, const Comm delete[] state; // boxes - size = _vm->_theBoxes.getSaveStateSize(); + size = g_vm->_theBoxes.getSaveStateSize(); state = new byte[size]; - _vm->_theBoxes.saveState(state); + g_vm->_theBoxes.saveState(state); f->writeUint32LE(size); f->write(state, size); delete[] state; @@ -769,7 +769,7 @@ void RMGfxEngine::loadState(CORO_PARAM, const Common::String &fn) { _ctx->size = _ctx->f->readUint32LE(); _ctx->state = new byte[_ctx->size]; _ctx->f->read(_ctx->state, _ctx->size); - _vm->_theBoxes.loadState(_ctx->state); + g_vm->_theBoxes.loadState(_ctx->state); delete[] _ctx->state; } @@ -865,7 +865,7 @@ void RMGfxEngine::waitWipeEnd(CORO_PARAM) { } bool RMGfxEngine::canLoadSave() { - return _bInput && !_tony.inAction() && !_vm->getIsDemo(); + return _bInput && !_tony.inAction() && !g_vm->getIsDemo(); } } // End of namespace Tony diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp index 7d663c1465..1e79032af2 100644 --- a/engines/tony/input.cpp +++ b/engines/tony/input.cpp @@ -52,7 +52,7 @@ void RMInput::poll() { _leftClickMouse = _leftReleaseMouse = _rightClickMouse = _rightReleaseMouse = false; // Get pending events - while (g_system->getEventManager()->pollEvent(_event) && !_vm->shouldQuit()) { + while (g_system->getEventManager()->pollEvent(_event) && !g_vm->shouldQuit()) { switch (_event.type) { case Common::EVENT_MOUSEMOVE: case Common::EVENT_LBUTTONDOWN: @@ -83,8 +83,8 @@ void RMInput::poll() { // Check for debugger if ((_event.kbd.keycode == Common::KEYCODE_d) && (_event.kbd.flags & Common::KBD_CTRL)) { // Attach to the debugger - _vm->_debugger->attach(); - _vm->_debugger->onFrame(); + g_vm->_debugger->attach(); + g_vm->_debugger->onFrame(); } else { // Flag the given key as being down _keyDown[(int)_event.kbd.keycode] = true; diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index 0438d7252b..175d9fc6a9 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -339,7 +339,7 @@ bool RMInventory::leftClick(const RMPoint &mpos, int &nCombineObj) { _nCombine = _inv[n - 1 + _curPos]; nCombineObj = _nCombine + 10000; - _vm->playUtilSFX(1); + g_vm->playUtilSFX(1); return true; } } @@ -402,7 +402,7 @@ void RMInventory::rightClick(const RMPoint &mpos) { _miniAction = 0; _nSelectObj = n - 1; - _vm->playUtilSFX(0); + g_vm->playUtilSFX(0); } } @@ -524,7 +524,7 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo g_system->unlockMutex(_csModifyInterface); } - if (_vm->getEngine()->getInput().getAsyncKeyState(Common::KEYCODE_i)) { + if (g_vm->getEngine()->getInput().getAsyncKeyState(Common::KEYCODE_i)) { GLOBALS._bCfgInvLocked = !GLOBALS._bCfgInvLocked; } @@ -538,7 +538,7 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo if (!GLOBALS._bCfgInvNoScroll) { _state = OPENING; _curPutY = RM_SY - 1; - _curPutTime = _vm->getTime(); + _curPutTime = g_vm->getTime(); } else { _state = OPENED; _curPutY = RM_SY - 68; @@ -548,13 +548,13 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo if (!GLOBALS._bCfgInvNoScroll) { _state = CLOSING; _curPutY = RM_SY - 68; - _curPutTime = _vm->getTime(); + _curPutTime = g_vm->getTime(); } else { _state = CLOSED; } } } else if (_state == OPENING) { - while (_curPutTime + INVSPEED < _vm->getTime()) { + while (_curPutTime + INVSPEED < g_vm->getTime()) { _curPutY -= 3; _curPutTime += INVSPEED; } @@ -565,7 +565,7 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo } } else if (_state == CLOSING) { - while (_curPutTime + INVSPEED < _vm->getTime()) { + while (_curPutTime + INVSPEED < g_vm->getTime()) { _curPutY += 3; _curPutTime += INVSPEED; } @@ -578,7 +578,7 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo if (!GLOBALS._bCfgInvNoScroll) { _state = OPENING; _curPutY = - 68; - _curPutTime = _vm->getTime(); + _curPutTime = g_vm->getTime(); } else { _state = OPENED; _curPutY = 0; @@ -588,13 +588,13 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo if (!GLOBALS._bCfgInvNoScroll) { _state = CLOSING; _curPutY = -2; - _curPutTime = _vm->getTime(); + _curPutTime = g_vm->getTime(); } else { _state = CLOSED; } } } else if (_state == OPENING) { - while (_curPutTime + INVSPEED < _vm->getTime()) { + while (_curPutTime + INVSPEED < g_vm->getTime()) { _curPutY += 3; _curPutTime += INVSPEED; } @@ -604,7 +604,7 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo _curPutY = 0; } } else if (_state == CLOSING) { - while (_curPutTime + INVSPEED < _vm->getTime()) { + while (_curPutTime + INVSPEED < g_vm->getTime()) { _curPutY -= 3; _curPutTime += INVSPEED; } @@ -629,19 +629,19 @@ void RMInventory::doFrame(RMGfxTargetBuffer &bigBuf, RMPointer &ptr, RMPoint mpo if (_miniAction != 1) { _miniInterface.setPattern(2); _miniAction = 1; - _vm->playUtilSFX(1); + g_vm->playUtilSFX(1); } } else if (mpos._x >= startx + 40 && mpos._x < startx + 80) { if (_miniAction != 2) { _miniInterface.setPattern(3); _miniAction = 2; - _vm->playUtilSFX(1); + g_vm->playUtilSFX(1); } } else if (mpos._x >= startx + 80 && mpos._x < startx + 108) { if (_miniAction != 3) { _miniInterface.setPattern(4); _miniAction = 3; - _vm->playUtilSFX(1); + g_vm->playUtilSFX(1); } } else { _miniInterface.setPattern(1); @@ -792,7 +792,7 @@ void RMInterface::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pr if (_lastHotZone != _ctx->h) { _lastHotZone = _ctx->h; - _vm->playUtilSFX(1); + g_vm->playUtilSFX(1); } if (GLOBALS._bCfgInterTips) { @@ -832,7 +832,7 @@ void RMInterface::clicked(const RMPoint &mousepos) { _openStart._y = RM_SY - _dimy; // Play the sound effect - _vm->playUtilSFX(0); + g_vm->playUtilSFX(0); } bool RMInterface::released(const RMPoint &mousepos, RMTonyAction &action) { diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index d02bd9640f..eaed3b49e2 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -157,7 +157,7 @@ int RMPattern::init(RMSfx *sfx, bool bPlayP0, byte *bFlag) { int i; // Read the current time - _nStartTime = _vm->getTime(); + _nStartTime = g_vm->getTime(); _nCurSlot = 0; // Find the first frame of the pattern @@ -210,7 +210,7 @@ int RMPattern::init(RMSfx *sfx, bool bPlayP0, byte *bFlag) { } int RMPattern::update(uint32 hEndPattern, byte &bFlag, RMSfx *sfx) { - int CurTime = _vm->getTime(); + int CurTime = g_vm->getTime(); // If the speed is 0, then the pattern never advances if (_speed == 0) { @@ -408,7 +408,7 @@ void RMSfx::readFromStream(RMDataStream &ds, bool bLOX) { Common::SeekableReadStream *stream = new Common::MemoryReadStream(buffer, size, DisposeAfterUse::YES); // Create the sound effect - _fx = _vm->createSFX(stream); + _fx = g_vm->createSFX(stream); _fx->setLoop(false); } @@ -2083,10 +2083,10 @@ bool RMLocation::load(RMDataStream &ds) { _items = new RMItem[_nItems]; - _vm->freezeTime(); + g_vm->freezeTime(); for (i = 0; i < _nItems && !ds.isError(); i++) ds >> _items[i]; - _vm->unfreezeTime(); + g_vm->unfreezeTime(); return ds.isError(); } diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 7385e60b66..20c28c5c93 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -607,7 +607,7 @@ void ScriptThread(CORO_PARAM, const void *param) { CORO_BEGIN_CODE(_ctx); - _ctx->dwStartTime = _vm->getTime(); + _ctx->dwStartTime = g_vm->getTime(); _ctx->numHandles = 0; // debugC(DEBUG_BASIC, kTonyDebugMPAL, "PlayScript(): Moments: %u\n",s->nMoments); @@ -615,9 +615,9 @@ void ScriptThread(CORO_PARAM, const void *param) { // Sleep for the required time if (s->Moment[_ctx->i].dwTime == -1) { CORO_INVOKE_4(CoroScheduler.waitForMultipleObjects, _ctx->numHandles, cfHandles, true, CORO_INFINITE); - _ctx->dwStartTime = _vm->getTime(); + _ctx->dwStartTime = g_vm->getTime(); } else { - _ctx->dwCurTime = _vm->getTime(); + _ctx->dwCurTime = g_vm->getTime(); if (_ctx->dwCurTime < _ctx->dwStartTime + (s->Moment[_ctx->i].dwTime * 100)) { // debugC(DEBUG_BASIC, kTonyDebugMPAL, "PlayScript(): Sleeping %lums\n",_ctx->dwStartTime+(s->Moment[_ctx->i].dwTime*100)-_ctx->dwCurTime); CORO_INVOKE_1(CoroScheduler.sleep, _ctx->dwStartTime+(s->Moment[_ctx->i].dwTime * 100) - _ctx->dwCurTime); @@ -761,11 +761,11 @@ void ShutUpActionThread(CORO_PARAM, const void *param) { GLOBALS._bExecutingAction = false; - if (_vm->_initialLoadSlotNumber != -1) { - _ctx->slotNumber = _vm->_initialLoadSlotNumber; - _vm->_initialLoadSlotNumber = -1; + if (g_vm->_initialLoadSlotNumber != -1) { + _ctx->slotNumber = g_vm->_initialLoadSlotNumber; + g_vm->_initialLoadSlotNumber = -1; - CORO_INVOKE_1(_vm->loadState, _ctx->slotNumber); + CORO_INVOKE_1(g_vm->loadState, _ctx->slotNumber); } @@ -909,7 +909,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { copyMemory(_ctx->MyActions[_ctx->k].CmdNum, _ctx->curItem->Action[_ctx->j].CmdNum, MAX_COMMANDS_PER_ACTION * sizeof(uint16)); - _ctx->MyActions[_ctx->k].dwLastTime = _vm->getTime(); + _ctx->MyActions[_ctx->k].dwLastTime = g_vm->getTime(); _ctx->k++; } } @@ -925,7 +925,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { while (1) { /* Cerchiamo tra tutte le idle actions quella a cui manca meno tempo per l'esecuzione */ - _ctx->curTime = _vm->getTime(); + _ctx->curTime = g_vm->getTime(); _ctx->dwSleepTime = (uint32)-1L; for (_ctx->k = 0;_ctx->k<_ctx->nIdleActions;_ctx->k++) @@ -951,7 +951,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { _ctx->MyThreads[_ctx->i].nItem = 0; } - _ctx->curTime = _vm->getTime(); + _ctx->curTime = g_vm->getTime(); /* Loop through all the necessary idle actions */ for (_ctx->k = 0; _ctx->k < _ctx->nIdleActions; _ctx->k++) @@ -959,7 +959,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { _ctx->MyActions[_ctx->k].dwLastTime += _ctx->MyActions[_ctx->k].wTime; /* It's time to check to see if fortune is on the side of the idle action */ - byte randomVal = (byte)_vm->_randomSource.getRandomNumber(99); + byte randomVal = (byte)g_vm->_randomSource.getRandomNumber(99); if (randomVal < _ctx->MyActions[_ctx->k].perc) { /* Check if there is an action running on the item */ if ((GLOBALS._bExecutingAction) && (GLOBALS._nExecutingAction == _ctx->MyActions[_ctx->k].nItem)) diff --git a/engines/tony/mpal/mpalutils.cpp b/engines/tony/mpal/mpalutils.cpp index aba92a86cd..aa22456a4b 100644 --- a/engines/tony/mpal/mpalutils.cpp +++ b/engines/tony/mpal/mpalutils.cpp @@ -37,7 +37,7 @@ namespace MPAL { * @param resId MPAL resource to open */ RMRes::RMRes(uint32 resID) { - _h = _vm->_resUpdate.queryResource(resID); + _h = g_vm->_resUpdate.queryResource(resID); if (_h == NULL) _h = mpalQueryResource(resID); if (_h != NULL) diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index 7380b3a93a..781172df52 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -138,7 +138,7 @@ FPSfx::FPSfx(bool bSoundOn) { _rewindableStream = 0; _bPaused = false; - _vm->_activeSfx.push_back(this); + g_vm->_activeSfx.push_back(this); } /** @@ -154,7 +154,7 @@ FPSfx::~FPSfx() { return; g_system->getMixer()->stopHandle(_handle); - _vm->_activeSfx.remove(this); + g_vm->_activeSfx.remove(this); if (_loopStream) delete _loopStream; // _rewindableStream is deleted by deleting _loopStream @@ -403,7 +403,7 @@ void FPSfx::soundCheckProcess(CORO_PARAM, const void *param) { for (;;) { // Check each active sound - for (_ctx->i = _vm->_activeSfx.begin(); _ctx->i != _vm->_activeSfx.end(); ++_ctx->i) { + for (_ctx->i = g_vm->_activeSfx.begin(); _ctx->i != g_vm->_activeSfx.end(); ++_ctx->i) { FPSfx *sfx = *_ctx->i; if (sfx->endOfBuffer()) CoroScheduler.setEvent(sfx->_hEndOfBuffer); diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index a44d9410f3..6100596b0e 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -35,11 +35,11 @@ namespace Tony { -TonyEngine *_vm; +TonyEngine *g_vm; TonyEngine::TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc), _randomSource("tony") { - _vm = this; + g_vm = this; _loadSlotNumber = -1; // Set the up the debugger @@ -229,7 +229,7 @@ void TonyEngine::playMusic(int nChannel, const Common::String &fname, int nFX, b if (!getIsDemo()) { if (!_stream[GLOBALS._nextChannel]->loadFile(fname, FPCODEC_ADPCM, nSync)) - _vm->abortGame(); + g_vm->abortGame(); } else { _stream[GLOBALS._nextChannel]->loadFile(fname, FPCODEC_ADPCM, nSync); } @@ -241,7 +241,7 @@ void TonyEngine::playMusic(int nChannel, const Common::String &fname, int nFX, b } else { if (!getIsDemo()) { if (!_stream[nChannel]->loadFile(fname, FPCODEC_ADPCM, nSync)) - _vm->abortGame(); + g_vm->abortGame(); } else { _stream[nChannel]->loadFile(fname, FPCODEC_ADPCM, nSync); } @@ -256,13 +256,13 @@ void TonyEngine::doNextMusic(CORO_PARAM, const void *param) { Common::String fn; CORO_END_CONTEXT(_ctx); - FPStream **streams = _vm->_stream; + FPStream **streams = g_vm->_stream; CORO_BEGIN_CODE(_ctx); - if (!_vm->getIsDemo()) { + if (!g_vm->getIsDemo()) { if (!streams[GLOBALS._nextChannel]->loadFile(GLOBALS._nextMusic, FPCODEC_ADPCM, GLOBALS._nextSync)) - _vm->abortGame(); + g_vm->abortGame(); } else { streams[GLOBALS._nextChannel]->loadFile(GLOBALS._nextMusic, FPCODEC_ADPCM, GLOBALS._nextSync); } @@ -532,34 +532,34 @@ void TonyEngine::playProcess(CORO_PARAM, const void *param) { // and kill the scheudler and all the processes, including this one for (;;) { // If a savegame needs to be loaded, then do so - if (_vm->_loadSlotNumber != -1 && GLOBALS._gfxEngine != NULL) { - _ctx->fn = getSaveStateFileName(_vm->_loadSlotNumber); + if (g_vm->_loadSlotNumber != -1 && GLOBALS._gfxEngine != NULL) { + _ctx->fn = getSaveStateFileName(g_vm->_loadSlotNumber); CORO_INVOKE_1(GLOBALS._gfxEngine->loadState, _ctx->fn); - _vm->_loadSlotNumber = -1; + g_vm->_loadSlotNumber = -1; } // Wait for the next frame CORO_INVOKE_1(CoroScheduler.sleep, 50); // Call the engine to handle the next frame - CORO_INVOKE_1(_vm->_theEngine.doFrame, _vm->_bDrawLocation); + CORO_INVOKE_1(g_vm->_theEngine.doFrame, g_vm->_bDrawLocation); // Warns that a frame is finished - CoroScheduler.pulseEvent(_vm->_hEndOfFrame); + CoroScheduler.pulseEvent(g_vm->_hEndOfFrame); // Handle drawing the frame - if (!_vm->_bPaused) { - if (!_vm->_theEngine._bWiping) - _vm->_window.getNewFrame(_vm->_theEngine, NULL); + if (!g_vm->_bPaused) { + if (!g_vm->_theEngine._bWiping) + g_vm->_window.getNewFrame(g_vm->_theEngine, NULL); else - _vm->_window.getNewFrame(_vm->_theEngine, &_vm->_theEngine._rcWipeEllipse); + g_vm->_window.getNewFrame(g_vm->_theEngine, &g_vm->_theEngine._rcWipeEllipse); } // Paint the frame onto the screen - _vm->_window.repaint(); + g_vm->_window.repaint(); // Signal the ScummVM debugger - _vm->_debugger->onFrame(); + g_vm->_debugger->onFrame(); } CORO_END_CODE; diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 94dc3de92d..18cddf3f2a 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -238,9 +238,9 @@ public: }; // Global reference to the TonyEngine object -extern TonyEngine *_vm; +extern TonyEngine *g_vm; -#define GLOBALS _vm->_globals +#define GLOBALS g_vm->_globals } // End of namespace Tony diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index 74d9f20181..8593ece480 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -115,7 +115,7 @@ void RMTony::init() { ds.close(); _body.setPattern(0); - _nTimeLastStep = _vm->getTime(); + _nTimeLastStep = g_vm->getTime(); } @@ -137,7 +137,7 @@ void RMTony::doFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int curLoc) { setSpeed(GLOBALS._nCfgTonySpeed); // Runs the normal character movement - _ctx->time = _vm->getTime(); + _ctx->time = g_vm->getTime(); do { _nTimeLastStep += (1000 / 40); diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index 2d5954a74c..3806aa67c8 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -70,7 +70,7 @@ void RMWindow::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, if (GLOBALS._bCfgAnni30) { if (!RMGfxTargetBuffer::_precalcTable) { RMGfxTargetBuffer::createBWPrecalcTable(); - _vm->getEngine()->getPointer().updateCursor(); + g_vm->getEngine()->getPointer().updateCursor(); } Graphics::Surface *screen = g_system->lockScreen(); const uint16 *src = (const uint16 *)buf; @@ -85,7 +85,7 @@ void RMWindow::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, } else { if (RMGfxTargetBuffer::_precalcTable) { RMGfxTargetBuffer::freeBWPrecalcTable(); - _vm->getEngine()->getPointer().updateCursor(); + g_vm->getEngine()->getPointer().updateCursor(); } g_system->copyRectToScreen(buf, pitch, x, y, w, h); } @@ -143,7 +143,7 @@ void RMWindow::getNewFrame(RMGfxTargetBuffer &bigBuf, Common::Rect *rcBoundEllip // FIXME: The current dirty rect handling code has a minor issue with screen refresh in one // scene in the introduction sequence as the scene changes. For now, we're working around the // problem by explicitly having full screen refreshes on that scene - bool fullRefresh = _vm->getEngine()->getCurrentLocation() == 98; + bool fullRefresh = g_vm->getEngine()->getCurrentLocation() == 98; if (rcBoundEllipse != NULL) { // Circular wipe effect -- cgit v1.2.3 From 93f145773e316a5ec9e37f02e1c2f803e89ccf66 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Wed, 22 Aug 2012 21:52:22 +0200 Subject: TONY: Fix saveSoundSettings to use setInt for talkspeed. --- engines/tony/tony.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 6100596b0e..081556572a 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -667,7 +667,7 @@ void TonyEngine::saveSoundSettings() { ConfMan.setInt("music_volume", GLOBALS._nCfgMusicVolume * 256 / 10); ConfMan.setBool("subtitles", GLOBALS._bShowSubtitles); - ConfMan.setBool("talkspeed", GLOBALS._nCfgTextSpeed); + ConfMan.setInt("talkspeed", GLOBALS._nCfgTextSpeed * 256 / 10); } } // End of namespace Tony -- cgit v1.2.3 From b1486aa5feb3fa074e91cb8436054608119062ed Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Wed, 22 Aug 2012 21:56:12 +0200 Subject: TONY: Fix spelling of setStretch. --- engines/tony/gfxcore.h | 2 +- engines/tony/loc.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index 78c4c9bc70..2402b1e029 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -189,7 +189,7 @@ public: void setDst(const RMPoint &dst) { _dst.topLeft() = dst; } - void setStrecth(bool bStretch) { + void setStretch(bool bStretch) { _bStretch = bStretch; } diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index eaed3b49e2..a2dd7e097d 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -690,7 +690,7 @@ void RMItem::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { prim->getDst().offset(calculatePos()); // No stretching, please - prim->setStrecth(false); + prim->setStretch(false); // Now we turn to the generic surface drawing routines CORO_INVOKE_2(_sprites[_nCurSprite].draw, bigBuf, prim); -- cgit v1.2.3 From 93e10b52108e84e4db0e05a10d274a90e6cc50ff Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 22 Aug 2012 22:35:42 +1000 Subject: TONY: Removed some debug warnings which aren't needed any longer --- engines/tony/custom.cpp | 4 ---- 1 file changed, 4 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 6853cf51a0..e082e5fcde 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -2122,8 +2122,6 @@ void ThreadFadeOutMusic(CORO_PARAM, const void *nMusic) { _ctx->startVolume = g_vm->getMusicVolume(nChannel); - debug("Start FadeOut Music"); - for (_ctx->i = 16; _ctx->i > 0 && !GLOBALS._bFadeOutStop; _ctx->i--) { if (_ctx->i * 4 < _ctx->startVolume) g_vm->setMusicVolume(nChannel, _ctx->i * 4); @@ -2138,8 +2136,6 @@ void ThreadFadeOutMusic(CORO_PARAM, const void *nMusic) { if (nChannel == 2) g_vm->stopMusic(2); - debug("End FadeOut Music"); - CORO_KILL_SELF(); CORO_END_CODE; -- cgit v1.2.3 From bad6ec838876bd88e3638bd07ad6e7d12c9af727 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 23 Aug 2012 22:01:52 +1000 Subject: TONY: Fixed problem with spoken voices being clipped when timed text mode is on. --- engines/tony/sound.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'engines') diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index 781172df52..87e142df48 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -132,7 +132,7 @@ FPSfx::FPSfx(bool bSoundOn) { _bSoundSupported = bSoundOn; _bFileLoaded = false; _lastVolume = 63; - _hEndOfBuffer = CORO_INVALID_PID_VALUE; + _hEndOfBuffer = CoroScheduler.createEvent(true, false); _bIsVoice = false; _loopStream = 0; _rewindableStream = 0; @@ -161,9 +161,8 @@ FPSfx::~FPSfx() { else delete _rewindableStream; - // FIXME - //if (hEndOfBuffer != CORO_INVALID_PID_VALUE) - // CloseHandle(hEndOfBuffer); + // Free the buffer end event + CoroScheduler.closeEvent(_hEndOfBuffer); } /** -- cgit v1.2.3 From 61b11037c3d05e527932b37b556b655531836373 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Thu, 23 Aug 2012 22:59:19 +0200 Subject: TONY: Ignore draw attempts with non-positive width/height. This avoids an invalid dirty rect (width -1) during the introduction scene inside Halloween Park. --- engines/tony/gfxcore.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 0c331cc0e9..0241d96af1 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -198,7 +198,7 @@ bool RMGfxSourceBuffer::clip2D(int &x1, int &y1, int &u, int &v, int &width, int if (y1 + height - 1 > desth - 1) height = desth - y1; - return true; + return (width > 1 && height > 1); } -- cgit v1.2.3 From 0163bd38e8ba45635237340a69894c3678ed5f50 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Thu, 23 Aug 2012 23:16:52 +0200 Subject: TONY: Fix background dirty rect handling. Reset the scrolling state on load, so that when a new scene is loaded, the background is redrawn. Also, revert the workaround in d0d15af9, since this (hopefully) fixes the underlying problem. --- engines/tony/loc.cpp | 7 ++++--- engines/tony/window.cpp | 7 +------ 2 files changed, 5 insertions(+), 9 deletions(-) (limited to 'engines') diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index a2dd7e097d..dedac199fa 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -1945,9 +1945,6 @@ RMLocation::RMLocation() { _buf = NULL; TEMPNumLoc = 0; _cmode = CM_256; - - _prevScroll.set(-1, -1); - _prevFixedScroll.set(-1, -1); } @@ -2020,6 +2017,10 @@ bool RMLocation::load(RMDataStream &ds) { byte cm; int i; + // Reset dirty rectangling + _prevScroll.set(-1, -1); + _prevFixedScroll.set(-1, -1); + // Check the ID ds >> id[0] >> id[1] >> id[2]; diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index 3806aa67c8..b603fa39f3 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -140,16 +140,11 @@ void RMWindow::getNewFrame(RMGfxTargetBuffer &bigBuf, Common::Rect *rcBoundEllip // Get a pointer to the bytes of the source buffer byte *lpBuf = bigBuf; - // FIXME: The current dirty rect handling code has a minor issue with screen refresh in one - // scene in the introduction sequence as the scene changes. For now, we're working around the - // problem by explicitly having full screen refreshes on that scene - bool fullRefresh = g_vm->getEngine()->getCurrentLocation() == 98; - if (rcBoundEllipse != NULL) { // Circular wipe effect getNewFrameWipe(lpBuf, *rcBoundEllipse); _wiping = true; - } else if (_wiping || fullRefresh) { + } else if (_wiping) { // Just finished a wiping effect, so copy the full screen copyRectToScreen(lpBuf, RM_SX * 2, 0, 0, RM_SX, RM_SY); _wiping = false; -- cgit v1.2.3 From 68c6109e7645c46be7c4bbd20fc0f3d68897ccc5 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Thu, 23 Aug 2012 23:20:32 +0200 Subject: TONY: Draw the dirty rectangle debugging last. Otherwise the rects are overwritten by the actual drawing. --- engines/tony/window.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'engines') diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index b603fa39f3..1e60e636f3 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -165,14 +165,16 @@ void RMWindow::getNewFrame(RMGfxTargetBuffer &bigBuf, Common::Rect *rcBoundEllip Common::Rect &r = *i; const byte *lpSrc = lpBuf + (RM_SX * 2) * r.top + (r.left * 2); copyRectToScreen(lpSrc, RM_SX * 2, r.left, r.top, r.width(), r.height()); + } - if (_showDirtyRects) + if (_showDirtyRects) { + for (i = dirtyRects.begin(); i != dirtyRects.end(); ++i) { // Frame the copied area with a rectangle - s->frameRect(r, 0xffffff); - } + s->frameRect(*i, 0xffffff); + } - if (_showDirtyRects) g_system->unlockScreen(); + } } if (_bGrabThumbnail) { -- cgit v1.2.3 From 7815c0522094b058409974618867d683b86564d1 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Thu, 23 Aug 2012 23:21:08 +0200 Subject: TONY: Use the right dirty rects for drawAA. This makes it match the relevant non-AA code, and fixes problems due to the invalid rects. (Perhaps we don't need dirty rects here at all though, since all the callers seem to call the non-AA code first with the same parameters?) --- engines/tony/gfxcore.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 0241d96af1..06c74dd231 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -1720,7 +1720,17 @@ void RMGfxSourceBuffer8AA::drawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri if (prim->isFlipped()) { u = _dimx - (width + u); x1 = (prim->getDst()._x1 + _dimx - 1) - u; + + if (width > x1) + width = x1; + + // Specify the drawn area + bigBuf.addDirtyRect(Common::Rect(x1 - width, y1, x1, y1 + height)); + } else { + // Specify the drawn area + bigBuf.addDirtyRect(Common::Rect(x1, y1, x1 + width, y1 + height)); } + // width = _dimx; // x1 = prim->Dst().x1; @@ -1807,9 +1817,6 @@ void RMGfxSourceBuffer8AA::drawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri // Skip to the next line buf += bigBuf.getDimx(); } - - // Specify the drawn area - bigBuf.addDirtyRect(Common::Rect(x1, y1, x1 + width, y1 + height)); } -- cgit v1.2.3 From aa603bc208c6b26e78e66d66a120a24ba80c28c4 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Fri, 24 Aug 2012 19:15:58 +0200 Subject: TONY: Mark screen dirty in RMGfxClearTask. This fixes the "A LONG TIME AFTER..." screen when talking to the old woman in the booth. Thanks to eriktorbjorn for noticing it. --- engines/tony/gfxcore.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines') diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 06c74dd231..27b90b7d48 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -2057,6 +2057,7 @@ int RMGfxClearTask::priority() { void RMGfxClearTask::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *) { // Clean the target buffer Common::fill((byte *)bigBuf, (byte *)bigBuf + (bigBuf.getDimx() * bigBuf.getDimy() * 2), 0x0); + bigBuf.addDirtyRect(Common::Rect(bigBuf.getDimx(), bigBuf.getDimy())); } void RMGfxClearTask::removeThis(CORO_PARAM, bool &result) { -- cgit v1.2.3 From af134e02448c7e4d5d17711c0cb7f53ddc0674f6 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Fri, 24 Aug 2012 19:43:22 +0200 Subject: TONY: Animate mouse cursors. This restores the forgotten doFrame code for RMPointer, which fixes the bird mouse cursor. Thanks to eriktorbjorn for noticing it. --- engines/tony/game.cpp | 11 ++++++++++- engines/tony/game.h | 2 +- engines/tony/gfxengine.cpp | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index d50f480625..a27b8ea544 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -1587,13 +1587,22 @@ void RMPointer::hideCursor() { } } +void RMPointer::doFrame() { + // Update the cursor animation if needed. + if (_nCurSpecialPointer == 0 || _nCurSpecialPointer == PTR_CUSTOM) + return; + + RMGfxTargetBuffer buf; + if (_specialPointer[_nCurSpecialPointer - 1]->doFrame(&buf, false)) + updateCursor(); +} void RMPointer::updateCursor() { // Create an intermediate buffer and draw the cursor onto it RMGfxTargetBuffer buf; buf.create(64, 64, 16); RMGfxPrimitive prim; - + draw(Common::nullContext, buf, &prim); // Get a pointer to the cursor data diff --git a/engines/tony/game.h b/engines/tony/game.h index 9804ac87fe..1a758dc8ca 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -98,7 +98,7 @@ public: /** * Process a frame */ - void doFrame(RMGfxTargetBuffer *bigBuf); + void doFrame(); /** * Overloading of priorities diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 183e68c8c6..5431a0ca7d 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -310,6 +310,7 @@ SKIPCLICKSINISTRO: } else { _point.hideCursor(); } + _point.doFrame(); // ********************** // Draw the list in the OT -- cgit v1.2.3 From f917a4beabff01e85159de6a34fd705470ba993c Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Fri, 24 Aug 2012 22:35:22 +0200 Subject: TONY: Use Common::String in writeText. This uses an array of lines rather than trying to stick nulls into the string, and so fixes wrapping on hyphens (which overwrote the character before the hyphen). Thanks to eriktorbjorn for both finding the bug and working out what was going wrong. --- engines/tony/font.cpp | 77 +++++++++++++++++++++++++++------------------------ engines/tony/font.h | 4 +-- engines/tony/game.cpp | 8 +++--- 3 files changed, 47 insertions(+), 42 deletions(-) (limited to 'engines') diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 2d334434d4..7e65369bfc 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -1801,7 +1801,7 @@ void RMText::removeThis(CORO_PARAM, bool &result) { result = true; } -void RMText::writeText(const RMString &text, int nFont, int *time) { +void RMText::writeText(const Common::String &text, int nFont, int *time) { // Initializes the font (only once) if (_fonts[0] == NULL) { _fonts[0] = new RMFontDialog; @@ -1817,15 +1817,13 @@ void RMText::writeText(const RMString &text, int nFont, int *time) { writeText(text, _fonts[nFont], time); } -void RMText::writeText(const RMString &text, RMFontColor *font, int *time) { +void RMText::writeText(Common::String text, RMFontColor *font, int *time) { RMGfxPrimitive *prim; - char *p, *old_p; - int i, j, x, y; + uint p, old_p; + int j, x, y; int len; int numchar; int width, height; - char *string; - int numlines; // Set the base color font->setBaseColor(_textR, _textG, _textB); @@ -1834,17 +1832,18 @@ void RMText::writeText(const RMString &text, RMFontColor *font, int *time) { destroy(); // If the string is empty, do nothing - if (text == NULL || text[0] == '\0') + if (text.empty()) return; // Divide the words into lines. In this cycle, X contains the maximum length reached by a line, // and the number of lines - string = p = text; - i = j = x = 0; - while (*p != '\0') { - j += font->stringLen(*p); - if (j > (((_aHorType == HLEFTPAR) && (i > 0)) ? _maxLineLength - 25 : _maxLineLength)) { - j -= font->stringLen(*p, p[1]); + Common::Array lines; + p = 0; + j = x = 0; + while (p < text.size()) { + j += font->stringLen(text[p]); + if (j > (((_aHorType == HLEFTPAR) && (lines.size() > 0)) ? _maxLineLength - 25 : _maxLineLength)) { + j -= font->stringLen(text[p], (p + 1 == text.size()) ? '\0' : text[p + 1]); if (j > x) x = j; @@ -1855,21 +1854,24 @@ void RMText::writeText(const RMString &text, RMFontColor *font, int *time) { // This workaround has the partial word broken up so it will still display // old_p = p; - while (*p != ' ' && *p != '-' && p > string) + while (text[p] != ' ' && text[p] != '-' && p > 0) p--; - if (p == string) + if (p == 0) p = old_p; // Check if there are any blanks to end - while (*p == ' ' && *p != '\0') + while ((text[p] == ' ' || text[p] == '-') && p + 1 < text.size()) p++; - if (*p == '\0') + if (p == text.size()) break; - p--; - i++; - *p = '\0'; + lines.push_back(Common::String(text.c_str(), p)); + if (text[p] == ' ') + p++; + text = text.c_str() + p; + p = 0; j = 0; + continue; } p++; } @@ -1877,27 +1879,29 @@ void RMText::writeText(const RMString &text, RMFontColor *font, int *time) { if (j > x) x = j; - i++; - numlines = i; + // Add the last line of text. + lines.push_back(text); x += 8; // Starting position for the surface: X1, Y width = x; - height = (numlines - 1) * font->letterHeight() + font->_fontDimy; + height = (lines.size() - 1) * font->letterHeight() + font->_fontDimy; // Create the surface create(width, height); Common::fill(_buf, _buf + width * height * 2, 0); - p = string; + p = 0; y = 0; numchar = 0; - for (; i > 0; i--) { + for (uint i = 0; i < lines.size(); ++i) { + const Common::String &line = lines[i]; + // Measure the length of the line x = 0; - j = font->stringLen(RMString(p)); + j = font->stringLen(RMString(line.c_str())); switch (_aHorType) { case HLEFT: @@ -1905,7 +1909,7 @@ void RMText::writeText(const RMString &text, RMFontColor *font, int *time) { break; case HLEFTPAR: - if (i == numlines) + if (i == 0) x = 0; else x = 25; @@ -1920,21 +1924,22 @@ void RMText::writeText(const RMString &text, RMFontColor *font, int *time) { break; } - while (*p != '\0') { - if (*p == ' ') { - x += font->stringLen(*p); + p = 0; + while (p < line.size()) { + if (line[p] == ' ') { + x += font->stringLen(line[p]); p++; continue; } - prim = font->makeLetterPrimitive(*p, len); + prim = font->makeLetterPrimitive(line[p], len); prim->getDst()._x1 = x; prim->getDst()._y1 = y; addPrim(prim); numchar++; - x += font->stringLen(*p, p[1]); + x += font->stringLen(line[p], (p + 1 == line.size()) ? '\0' : line[p + 1]); p++; } p++; @@ -2021,14 +2026,14 @@ void RMTextDialog::hide(CORO_PARAM) { } void RMTextDialog::writeText(const RMString &text, int font, int *time) { - RMText::writeText(text, font, &_time); + RMText::writeText(Common::String(text), font, &_time); if (time != NULL) *time = _time; } void RMTextDialog::writeText(const RMString &text, RMFontColor *font, int *time) { - RMText::writeText(text, font, &_time); + RMText::writeText(Common::String(text), font, &_time); if (time != NULL) *time = _time; @@ -2251,7 +2256,7 @@ void RMTextItemName::doFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation & _item->getName(itemName); // Write it - writeText(itemName, 1); + writeText(Common::String(itemName), 1); // Handle the change If the selected item is different from the previous one if (_ctx->lastItem != _item) { @@ -2389,7 +2394,7 @@ void RMDialogChoice::setNumChoices(int num) { void RMDialogChoice::addChoice(const RMString &string) { // Draw the string assert(_curAdded < _numChoices); - _drawedStrings[_curAdded++].writeText(string, 0); + _drawedStrings[_curAdded++].writeText(Common::String(string), 0); } void RMDialogChoice::prepare(CORO_PARAM) { diff --git a/engines/tony/font.h b/engines/tony/font.h index 9971e536ed..1e84ecb527 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -215,8 +215,8 @@ public: void setMaxLineLength(int max); // Write the text - void writeText(const RMString &text, int font, int *time = NULL); - void writeText(const RMString &text, RMFontColor *font, int *time = NULL); + void writeText(const Common::String &text, int font, int *time = NULL); + void writeText(Common::String text, RMFontColor *font, int *time = NULL); // Overloaded function to decide when you delete the object from the OT list virtual void removeThis(CORO_PARAM, bool &result); diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index a27b8ea544..b3b6fe2347 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -506,15 +506,15 @@ void RMOptionScreen::refreshAll(CORO_PARAM) { } for (_ctx->i = 0; _ctx->i < 6; _ctx->i++) { - RMString s; + Common::String s; if (_bEditSaveName && _nEditPos == _ctx->i) - s.format("%02d)%s*", _statePos + _ctx->i, _editName); + s = Common::String::format("%02d)%s*", _statePos + _ctx->i, _editName); else { if (_statePos == 0 && _ctx->i == 0) - s.format("Autosave"); + s = "Autosave"; else - s.format("%02d)%s", _statePos + _ctx->i, (const char *)_curThumbName[_ctx->i]); + s = Common::String::format("%02d)%s", _statePos + _ctx->i, (const char *)_curThumbName[_ctx->i]); } _ctx->num[_ctx->i] = new RMText; -- cgit v1.2.3 From ba20f1d90dd21986f8eb250e93d794db87b9a51c Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Sat, 25 Aug 2012 00:07:49 +0200 Subject: TONY: Remove unused members of RMTextItemName. --- engines/tony/font.cpp | 4 ---- engines/tony/font.h | 2 -- 2 files changed, 6 deletions(-) (limited to 'engines') diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 7e65369bfc..f83677373f 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -2308,10 +2308,6 @@ bool RMTextItemName::isItemSelected() { return _item != NULL; } -bool RMTextItemName::isNormalItemSelected() { - return _item != NULL && _itemName.length() > 0; -} - /****************************************************************************\ * RMDialogChoice Methods diff --git a/engines/tony/font.h b/engines/tony/font.h index 1e84ecb527..e6543ef5d7 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -315,7 +315,6 @@ protected: RMPoint _mpos; RMPoint _curscroll; RMItem *_item; - RMString _itemName; public: RMTextItemName(); @@ -331,7 +330,6 @@ public: RMPoint getHotspot(); RMItem *getSelectedItem(); bool isItemSelected(); - bool isNormalItemSelected(); virtual void removeThis(CORO_PARAM, bool &result) { result = true; -- cgit v1.2.3 From ff9569572a3587b96b849fe4ef572ed91c7e6f5d Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Sat, 25 Aug 2012 00:08:13 +0200 Subject: TONY: Store savegame names with Common::String. --- engines/tony/detection.cpp | 8 ++++---- engines/tony/game.cpp | 8 ++++---- engines/tony/game.h | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) (limited to 'engines') diff --git a/engines/tony/detection.cpp b/engines/tony/detection.cpp index c408da3f24..8e6d5a64c3 100644 --- a/engines/tony/detection.cpp +++ b/engines/tony/detection.cpp @@ -128,12 +128,12 @@ SaveStateList TonyMetaEngine::listSaves(const char *target) const { if (slotNum >= 0 && slotNum <= 999) { byte thumbnailData[160 * 120 * 2]; - Tony::RMString saveName; + Common::String saveName; byte difficulty; if (Tony::RMOptionScreen::loadThumbnailFromSaveState(slotNum, thumbnailData, saveName, difficulty)) { // Add the save name to the savegame list - saveList.push_back(SaveStateDescriptor(slotNum, (const char *)saveName)); + saveList.push_back(SaveStateDescriptor(slotNum, saveName)); } } } @@ -152,7 +152,7 @@ void TonyMetaEngine::removeSaveState(const char *target, int slot) const { } SaveStateDescriptor TonyMetaEngine::querySaveMetaInfos(const char *target, int slot) const { - Tony::RMString saveName; + Common::String saveName; byte difficulty; byte thumbData[160 * 120 * 2]; @@ -175,7 +175,7 @@ SaveStateDescriptor TonyMetaEngine::querySaveMetaInfos(const char *target, int s } // Create the return descriptor - SaveStateDescriptor desc(slot, (const char *)saveName); + SaveStateDescriptor desc(slot, saveName); desc.setDeletableFlag(true); desc.setWriteProtectedFlag(false); desc.setThumbnail(to); diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index b3b6fe2347..9b1d85f827 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -514,7 +514,7 @@ void RMOptionScreen::refreshAll(CORO_PARAM) { if (_statePos == 0 && _ctx->i == 0) s = "Autosave"; else - s = Common::String::format("%02d)%s", _statePos + _ctx->i, (const char *)_curThumbName[_ctx->i]); + s = Common::String::format("%02d)%s", _statePos + _ctx->i, _curThumbName[_ctx->i].c_str()); } _ctx->num[_ctx->i] = new RMText; @@ -558,7 +558,7 @@ void RMOptionScreen::refreshThumbnails() { if (!loadThumbnailFromSaveState(_statePos + i, *_curThumb[i], _curThumbName[i], _curThumbDiff[i])) { delete _curThumb[i]; _curThumb[i] = NULL; - _curThumbName[i] = ""; + _curThumbName[i].clear(); _curThumbDiff[i] = 11; } } @@ -1197,7 +1197,7 @@ void RMOptionScreen::doFrame(CORO_PARAM, RMInput *input) { // Turn on edit mode _bEditSaveName = true; _nEditPos = _ctx->i; - strcpy(_editName, _curThumbName[_ctx->i]); + strcpy(_editName, _curThumbName[_ctx->i].c_str()); _ctx->bRefresh = true; } @@ -1386,7 +1386,7 @@ void RMOptionScreen::removeThis(CORO_PARAM, bool &result) { } -bool RMOptionScreen::loadThumbnailFromSaveState(int nState, byte *lpDestBuf, RMString &name, byte &diff) { +bool RMOptionScreen::loadThumbnailFromSaveState(int nState, byte *lpDestBuf, Common::String &name, byte &diff) { Common::String buf; char namebuf[256]; int i; diff --git a/engines/tony/game.h b/engines/tony/game.h index 1a758dc8ca..aa7d45bce6 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -229,7 +229,7 @@ private: RMGfxSourceBuffer8 *_saveEasy; RMGfxSourceBuffer8 *_saveHard; RMGfxSourceBuffer16 *_curThumb[6]; - RMString _curThumbName[6]; + Common::String _curThumbName[6]; byte _curThumbDiff[6]; RMOptionButton *_buttonSave_States[6]; RMOptionButton *_buttonSave_ArrowLeft; @@ -315,7 +315,7 @@ public: /** * Retrieves a savegame's thumbnail, description, and difficulty level */ - static bool loadThumbnailFromSaveState(int numState, byte *lpDestBuf, RMString &name, byte &diff); + static bool loadThumbnailFromSaveState(int numState, byte *lpDestBuf, Common::String &name, byte &diff); protected: -- cgit v1.2.3 From b77306bfcc26d17b1fca71360d1fcbd2ebdbe0ee Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Sat, 25 Aug 2012 00:21:58 +0200 Subject: TONY: Convert more strings to Common::String. --- engines/tony/font.cpp | 26 ++++++++++++-------------- engines/tony/font.h | 8 ++++---- engines/tony/loc.cpp | 3 +-- engines/tony/loc.h | 2 +- 4 files changed, 18 insertions(+), 21 deletions(-) (limited to 'engines') diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index f83677373f..a3d253a52c 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -134,11 +134,11 @@ void RMFont::close() { unload(); } -int RMFont::stringLen(const RMString &text) { - int len, i; +int RMFont::stringLen(const Common::String &text) { + uint len, i; len = 0; - for (i = 0; i < text.length() - 1; i++) + for (i = 0; i < text.size() - 1; i++) len += letterLength(text[i], text[i + 1]); len += letterLength(text[i]); @@ -1901,7 +1901,7 @@ void RMText::writeText(Common::String text, RMFontColor *font, int *time) { // Measure the length of the line x = 0; - j = font->stringLen(RMString(line.c_str())); + j = font->stringLen(line); switch (_aHorType) { case HLEFT: @@ -2025,15 +2025,15 @@ void RMTextDialog::hide(CORO_PARAM) { _bShowed = false; } -void RMTextDialog::writeText(const RMString &text, int font, int *time) { - RMText::writeText(Common::String(text), font, &_time); +void RMTextDialog::writeText(const Common::String &text, int font, int *time) { + RMText::writeText(text, font, &_time); if (time != NULL) *time = _time; } -void RMTextDialog::writeText(const RMString &text, RMFontColor *font, int *time) { - RMText::writeText(Common::String(text), font, &_time); +void RMTextDialog::writeText(const Common::String &text, RMFontColor *font, int *time) { + RMText::writeText(text, font, &_time); if (time != NULL) *time = _time; @@ -2230,7 +2230,7 @@ void RMTextItemName::doFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation & uint32 hThread; CORO_END_CONTEXT(_ctx); - RMString itemName; + Common::String itemName; CORO_BEGIN_CODE(_ctx); @@ -2249,14 +2249,12 @@ void RMTextItemName::doFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation & else _item = loc.whichItemIsIn(_mpos); - itemName = ""; - // If there an item, get its name if (_item != NULL) _item->getName(itemName); // Write it - writeText(Common::String(itemName), 1); + writeText(itemName, 1); // Handle the change If the selected item is different from the previous one if (_ctx->lastItem != _item) { @@ -2387,10 +2385,10 @@ void RMDialogChoice::setNumChoices(int num) { } } -void RMDialogChoice::addChoice(const RMString &string) { +void RMDialogChoice::addChoice(const Common::String &string) { // Draw the string assert(_curAdded < _numChoices); - _drawedStrings[_curAdded++].writeText(Common::String(string), 0); + _drawedStrings[_curAdded++].writeText(string, 0); } void RMDialogChoice::prepare(CORO_PARAM) { diff --git a/engines/tony/font.h b/engines/tony/font.h index e6543ef5d7..97434b9770 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -100,7 +100,7 @@ public: RMGfxPrimitive *makeLetterPrimitive(byte bChar, int &nLength); // Length in pixels of a string with the current font - int stringLen(const RMString &text); + int stringLen(const Common::String &text); int stringLen(char bChar, char bNext = 0); }; @@ -256,8 +256,8 @@ public: virtual ~RMTextDialog(); // Write the text - void writeText(const RMString &text, int font, int *time = NULL); - void writeText(const RMString &text, RMFontColor *font, int *time = NULL); + void writeText(const Common::String &text, int font, int *time = NULL); + void writeText(const Common::String &text, RMFontColor *font, int *time = NULL); // Overloaded function to decide when you delete the object from the OT list virtual void removeThis(CORO_PARAM, bool &result); @@ -376,7 +376,7 @@ public: void setNumChoices(int num); // Adds a string with the choice - void addChoice(const RMString &string); + void addChoice(const Common::String &string); // Show and hide the selection, with possible animations. // NOTE: If no parameter is passed to Show(), it is the obligation of diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index dedac199fa..9fba2dd51a 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -736,7 +736,7 @@ void RMItem::setPattern(int nPattern, bool bPlayP0) { } } -bool RMItem::getName(RMString &name) { +bool RMItem::getName(Common::String &name) { char buf[256]; mpalQueryItemName(_mpalCode, buf); @@ -1818,7 +1818,6 @@ RMGameBoxes::~RMGameBoxes() { void RMGameBoxes::init() { int i; - RMString fn; RMDataStream ds; // Load boxes from disk diff --git a/engines/tony/loc.h b/engines/tony/loc.h index 35f07fe637..f8a795cc42 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -276,7 +276,7 @@ public: RMPoint hotspot() { return _hot; } - bool getName(RMString &name); + bool getName(Common::String &name); int mpalCode() { return _mpalCode; } -- cgit v1.2.3 From b14a616f3f7f667946f617facd301369a0996582 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Sat, 25 Aug 2012 00:31:00 +0200 Subject: TONY: Get rid of RMString. --- engines/tony/loc.cpp | 12 +- engines/tony/loc.h | 10 +- engines/tony/utils.cpp | 342 +------------------------------------------------ engines/tony/utils.h | 60 +-------- 4 files changed, 18 insertions(+), 406 deletions(-) (limited to 'engines') diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 9fba2dd51a..e767584e9b 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -145,7 +145,7 @@ void RMPattern::updateCoord() { void RMPattern::stopSfx(RMSfx *sfx) { for (int i = 0; i < _nSlots; i++) { if (_slots[i]._type == SOUND) { - if (sfx[_slots[i]._data]._name[0] == '_') + if (!sfx[_slots[i]._data]._name.empty() && sfx[_slots[i]._data]._name[0] == '_') sfx[_slots[i]._data].stop(); else if (GLOBALS._bSkipSfxNoLoop) sfx[_slots[i]._data].stop(); @@ -182,7 +182,7 @@ int RMPattern::init(RMSfx *sfx, bool bPlayP0, byte *bFlag) { for (i = 0; i < _nSlots; i++) { if (_slots[i]._type == SOUND) { if (i == 0) { - if (sfx[_slots[i]._data]._name[0] == '_') { + if (!sfx[_slots[i]._data]._name.empty() && sfx[_slots[i]._data]._name[0] == '_') { sfx[_slots[i]._data].setVolume(_slots[i].pos()._x); sfx[_slots[i]._data].play(true); } else { @@ -193,12 +193,12 @@ int RMPattern::init(RMSfx *sfx, bool bPlayP0, byte *bFlag) { if (bPlayP0) { sfx[_slots[i]._data].setVolume(_slots[i].pos()._x); sfx[_slots[i]._data].play(); - } else if (sfx[_slots[i]._data]._name[0] == '_') { + } else if (!sfx[_slots[i]._data]._name.empty() && sfx[_slots[i]._data]._name[0] == '_') { sfx[_slots[i]._data].setVolume(_slots[i].pos()._x); sfx[_slots[i]._data].play(true); } } else { - if (_bLoop && sfx[_slots[i]._data]._name[0] == '_') { + if (_bLoop && !sfx[_slots[i]._data]._name.empty() && sfx[_slots[i]._data]._name[0] == '_') { sfx[_slots[i]._data].setVolume(_slots[i].pos()._x); sfx[_slots[i]._data].play(true); } @@ -253,7 +253,7 @@ int RMPattern::update(uint32 hEndPattern, byte &bFlag, RMSfx *sfx) { if (sfx != NULL) { sfx[_slots[_nCurSlot]._data].setVolume(_slots[_nCurSlot].pos()._x); - if (sfx[_slots[_nCurSlot]._data]._name[0] != '_') + if (sfx[_slots[_nCurSlot]._data]._name.empty() || sfx[_slots[_nCurSlot]._data]._name[0] != '_') sfx[_slots[_nCurSlot]._data].play(false); else sfx[_slots[_nCurSlot]._data].play(true); @@ -729,7 +729,7 @@ void RMItem::setPattern(int nPattern, bool bPlayP0) { // Look for the sound effect for pattern 0 if (bPlayP0) { for (int i = 0; i < _nSfx; i++) { - if (strcmp(_sfx[i]._name, "p0") == 0) + if (_sfx[i]._name == "p0") _sfx[i].play(); } } diff --git a/engines/tony/loc.h b/engines/tony/loc.h index f8a795cc42..acfbd45cdb 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -71,7 +71,7 @@ public: */ class RMSfx { public: - RMString _name; + Common::String _name; FPSfx *_fx; bool _bPlayingLoop; @@ -126,7 +126,7 @@ public: }; public: - RMString _name; + Common::String _name; private: int _speed; @@ -174,7 +174,7 @@ private: */ class RMSprite : public RMGfxTask { public: - RMString _name; + Common::String _name; RMRect _rcBox; protected: @@ -200,7 +200,7 @@ public: */ class RMItem : public RMGfxTask { public: - RMString _name; + Common::String _name; protected: int _z; @@ -527,7 +527,7 @@ public: */ class RMLocation : public RMGfxTaskSetPrior { public: - RMString _name; // Name + Common::String _name; // Name private: RMColorMode _cmode; // Color mode diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index 54a2209659..8dc1f5d615 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -32,356 +32,26 @@ namespace Tony { -/****************************************************************************\ -* RMString methods -\****************************************************************************/ - -/** - * Constructor - */ -RMString::RMString() { - _string = NULL; - _length = 0; - _realLength = 0; -} - -/** - * Destructor - */ -RMString::~RMString() { - if (_string != NULL) - delete[] _string; -} - -/** - * Copy constructor - */ -RMString::RMString(const RMString &str) { - // Use the overloaded '=' when copying - _string = NULL; - _length = 0; - _realLength = 0; - *this = str; -} - -/** - * Constructor from a char * - */ -RMString::RMString(const char *str) { - // Use the overloaded '=' when copying - _string = NULL; - _length = 0; - _realLength = 0; - *this = str; -} - -/** - * Constructor with a single passed character - */ -RMString::RMString(const int ch) { - // Use the overloaded '=' when copying - _string = NULL; - _length = 0; - _realLength = 0; - *this = ch; -} - -/** - * Returns the length of the string - * @returns Length - */ -int RMString::length() const { - return _length; -} - -/** - * Gets the character at the given index - * @param nIndex Position of the character to return - * @returns Character - */ -char RMString::getAt(int nIndex) { - assert(nIndex < _length); - return _string[nIndex]; -} - -/** - * Sets the character at the given index - * @param nIndex Position of the character to change - * @param c Character - */ -void RMString::setAt(int nIndex, char c) { - assert(nIndex < _length); - _string[nIndex] = c; -} - -/** - * Overloaded square brackets operator for accessing characters within the string - * @param nIndex Position of the charactre to reference - * @params Reference to the character - */ -char &RMString::operator[](int nIndex) { - assert(nIndex < _length); - return _string[nIndex]; -} - -/** - * Copies a string - * @param str String to copy - * @returns Reference to our string - */ -const RMString &RMString::operator=(const RMString &str) { - // Set the new length - _length = str._length; - - // If the source is empty, then destroy the current string buffer - if (_length == 0) { - if (_realLength > 0) { - delete[] _string; - _string = NULL; - _realLength = 0; - } - } else { - // Resize if necessary - resize(_length + 1); - - // Copy the string - Common::copy(str._string, str._string + _length + 1, _string); - } - - return *this; -} - -/** - * Copies a char * string - * @param str String to copy - * @returns Reference to our string - */ -const RMString &RMString::operator=(const char *str) { - // If the source is empty, then destroy the current string buffer - if (str == NULL) { - if (_realLength > 0) { - delete[] _string; - _string = NULL; - _realLength = _length = 0; - } - } else { - // Calculate the new length - _length = strlen(str); - - // Resize if necessary - resize(_length + 1); - - // Copy the string - Common::copy(str, str + _length + 1, _string); - } - - return *this; -} - -/** - * Forms a string from a passed character - * @param ch Character to copy - * @returns Reference to our string - */ -const RMString &RMString::operator=(const int ch) { - if (ch == '\0') { - // Destroy the current string - if (_realLength > 0) { - delete [] _string; - _string = NULL; - _length = _realLength = 0; - } - } else { - // Resize if necessary - resize(2); - - _string[0] = ch; - _string[1] = '\0'; - _length = 1; - } - - return *this; -} - -/** - * Concatenate a string into the current one - * @param str String to concatenate - * @param size Length of the string - */ -void RMString::connect(const char *str, int size) { - if (size > 0) { - // Calculate the new lenght - int nlen = _length + size; - - // Resize - resize(nlen + 1, true); - - // Linkage with '\0' - Common::copy(str, str + size + 1, _string + _length); - - // Save the new length - _length = nlen; - } -} - -/** - * Concatenate a string - * @param str String to concatenate - * @returns Reference to our string - */ -const RMString &RMString::operator+=(RMString &str) { - connect(str, str.length()); - return *this; -} - -/** - * Concatenate a string - * @param str String to concatenate - * @returns Reference to our string - */ -const RMString &RMString::operator+=(const char *str) { - connect(str, strlen(str)); - return *this; -} - -/** - * Concatenate a character - * @param ch Character to concatenate - * @returns Reference to our string - */ -const RMString &RMString::operator+=(const int ch) { - char str[2]; - - // Create a simple string buffer to hold the single character - str[0] = ch; - str[1] = '\0'; - - connect(str, 1); - return *this; -} - -/** - * Casts a string as char * - * @returns char * reference to string - */ -RMString::operator char *() const { - return _string; -} - -/** - * Resize a string as necessary - * @param size New size necessary (in bytes) - * @param bMaintain If true we must keep the original string, - if false we can destroy. - */ -void RMString::resize(int size, bool bMantain) { - if (_realLength == 0) { - _string = new char[size]; - _realLength = size; - } else if (size > _realLength) { - if (bMantain) { - char *app; - - app = new char[size]; - Common::copy(_string, _string + _length + 1, app); - delete[] _string; - _string = app; - } else { - delete[] _string; - _string = new char[size]; - } - } -} - -/** - * Compacts the string to occupy less memory if possible. - */ -void RMString::compact() { - if (_realLength + 1 > _length) { - char *app; - - app = new char[_length + 1]; - Common::copy(_string, _string + _length + 1, app); - - delete[] _string; - _string = app; - } -} - -/** - * Operator to concatenate two strings - */ -RMString operator+(const RMString &str1, const RMString &str2) { - RMString ret(str1); - - return (ret += str2); -} - -/** - * Operator to concatenate a character to a string - */ -RMString operator+(RMString &str, const int ch) { - RMString ret(str); - - return (ret += ch); -} - -RMString operator+(const int ch, RMString &str) { - RMString ret(ch); - - return (ret += str); -} - -/** - * Operator to concatenate a char * string to an RMString - */ -RMString operator+(RMString &str, const char *s) { - RMString ret(str); - - return (ret += s); -} - -RMString operator+(const char *s, RMString &str) { - RMString ret(s); - - return (ret += str); -} - /** * Extracts a string from a data stream * @param df data stream * @param var String */ -RMDataStream &operator>>(RMDataStream &df, RMString &var) { +RMDataStream &operator>>(RMDataStream &df, Common::String &var) { uint8 len; int i; df >> len; - var.resize(len + 1); - var._length = len + 1; - for (i = 0; i < len; i++) - df >> var[i]; - - var[i] = '\0'; - var._length = len; + for (i = 0; i < len; i++) { + char c; + df >> c; + var += c; + } return df; } -/** - * Formats a string - */ -void RMString::format(const char *str, ...) { - static char buf[2048]; - va_list argList; - - va_start(argList, str); - vsprintf(buf, str, argList); - va_end(argList); - *this = buf; -} - /****************************************************************************\ * RMFileStreamSlow Methods \****************************************************************************/ diff --git a/engines/tony/utils.h b/engines/tony/utils.h index f755a57c39..50b18d8aa7 100644 --- a/engines/tony/utils.h +++ b/engines/tony/utils.h @@ -145,65 +145,7 @@ public: friend RMFileStreamSlow &operator>>(RMFileStreamSlow &df, uint32 &var); }; -/** - * String class - */ -class RMString { -private: - char *_string; - int _length; - int _realLength; - -public: - RMString(); - ~RMString(); - - // Assignment constructors - RMString(const RMString &str); - RMString(const char *str); - RMString(const int ch); - - // General methods - int length() const; - void compact(); - - // Access characters within string - char getAt(int nIndex); - void setAt(int nIndex, char c); - char &operator[](int nIndex); - - // String cast - operator char *() const; - - // String assignments - const RMString &operator=(const RMString &str); - const RMString &operator=(const char *str); - const RMString &operator=(const int ch); - - // String concatenation - const RMString &operator+=(RMString &str); - const RMString &operator+=(const char *str); - const RMString &operator+=(const int ch); - - // Concatentation of string or character - friend RMString operator+(const RMString &str1, const RMString &str2); - - friend RMString operator+(RMString &str, const int ch); - friend RMString operator+(const int ch, RMString &str); - - friend RMString operator+(RMString &str, const char *s); - friend RMString operator+(const char *s, RMString &str); - - // Extraction from data streams - friend RMDataStream &operator>>(RMDataStream &df, RMString &var); - - // String formatting - void format(const char *str, ...); - -private: - void resize(int size, bool bMantain = false); - void connect(const char *str, int size); -}; +RMDataStream &operator>>(RMDataStream &df, Common::String &var); /** * Point class -- cgit v1.2.3 From a9828c88184a4c1a9161ca1fe80f5e6fff9c4f4e Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Sat, 25 Aug 2012 10:06:10 +0200 Subject: TONY: Replace copyMemory with memcpy. --- engines/tony/gfxcore.cpp | 12 ++++++------ engines/tony/mpal/expr.cpp | 8 ++++---- engines/tony/mpal/loadmpc.cpp | 10 +++++----- engines/tony/mpal/memory.cpp | 9 --------- engines/tony/mpal/memory.h | 3 --- engines/tony/mpal/mpal.cpp | 24 ++++++++++++------------ 6 files changed, 27 insertions(+), 39 deletions(-) (limited to 'engines') diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 27b90b7d48..806f4d07bb 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -135,7 +135,7 @@ RMGfxBuffer::RMGfxBuffer(int dimx, int dimy, int nBpp, bool bUseDDraw) { int RMGfxSourceBuffer::init(const byte *buf, int dimx, int dimy, bool bLoadPalette) { create(dimx, dimy, getBpp()); - copyMemory(_buf, buf, dimx * dimy * getBpp() / 8); + memcpy(_buf, buf, dimx * dimy * getBpp() / 8); // Invokes the method for preparing the surface (inherited) prepareImage(); @@ -484,7 +484,7 @@ int RMGfxSourceBufferPal::loadPaletteWA(const byte *buf, bool bSwapped) { _pal[i * 3 + 2] = buf[i * 3 + 0]; } } else { - copyMemory(_pal, buf, (1 << getBpp()) * 3); + memcpy(_pal, buf, (1 << getBpp()) * 3); } preparePalette(); @@ -496,7 +496,7 @@ int RMGfxSourceBufferPal::loadPalette(const byte *buf) { int i; for (i = 0; i < 256; i++) - copyMemory(_pal + i * 3, buf + i * 4, 3); + memcpy(_pal + i * 3, buf + i * 4, 3); preparePalette(); @@ -984,7 +984,7 @@ void RMGfxSourceBuffer8RLEByte::RLEWriteData(byte *&cur, int rep, byte *src) { *cur ++ = rep; if (rep > 0) { - copyMemory(cur, src, rep); + memcpy(cur, src, rep); cur += rep; src += rep; } @@ -1232,7 +1232,7 @@ void RMGfxSourceBuffer8RLEWord::RLEWriteData(byte *&cur, int rep, byte *src) { cur += 2; if (rep > 0) { - copyMemory(cur, src, rep); + memcpy(cur, src, rep); cur += rep; src += rep; } @@ -1683,7 +1683,7 @@ void RMGfxSourceBuffer8AA::calculateAA() { delete[] _aabuf; _aabuf = new byte[_dimx * _dimy]; - copyMemory(_aabuf, _megaAABuf, _dimx * _dimy); + memcpy(_aabuf, _megaAABuf, _dimx * _dimy); } RMGfxSourceBuffer8AA::RMGfxSourceBuffer8AA() : RMGfxSourceBuffer8() { diff --git a/engines/tony/mpal/expr.cpp b/engines/tony/mpal/expr.cpp index 7cf2cb3fc8..eb6b485ef6 100644 --- a/engines/tony/mpal/expr.cpp +++ b/engines/tony/mpal/expr.cpp @@ -121,7 +121,7 @@ static byte *duplicateExpression(HGLOBAL h) { clone = (byte *)globalAlloc(GMEM_FIXED, sizeof(EXPRESSION) * num + 1); two = (LPEXPRESSION)(clone + 1); - copyMemory(clone, orig, sizeof(EXPRESSION) * num + 1); + memcpy(clone, orig, sizeof(EXPRESSION) * num + 1); for (i = 0; i < num; i++) { if (one->type == ELT_PARENTH) { @@ -191,7 +191,7 @@ static void solve(LPEXPRESSION one, int num) { two = one + 1; if ((two->symbol == 0) || (one->symbol & 0xF0) <= (two->symbol & 0xF0)) { two->val.num = Compute(one->val.num, two->val.num, one->symbol); - copyMemory(one, two, (num - 1) * sizeof(EXPRESSION)); + memcpy(one, two, (num - 1) * sizeof(EXPRESSION)); --num; } else { j = 1; @@ -203,7 +203,7 @@ static void solve(LPEXPRESSION one, int num) { } three->val.num = Compute(two->val.num, three->val.num, two->symbol); - copyMemory(two, three, (num - j - 1) * sizeof(EXPRESSION)); + memcpy(two, three, (num - j - 1) * sizeof(EXPRESSION)); --num; } } @@ -291,7 +291,7 @@ const byte *parseExpression(const byte *lpBuf, HGLOBAL *h) { cur->val.name = (char *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, (*lpBuf) + 1); if (cur->val.name == NULL) return NULL; - copyMemory(cur->val.name, lpBuf + 1, *lpBuf); + memcpy(cur->val.name, lpBuf + 1, *lpBuf); lpBuf += *lpBuf + 1; break; diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index 371a94e24a..a0dff2927a 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -102,7 +102,7 @@ static const byte *ParseScript(const byte *lpBuf, LPMPALSCRIPT lpmsScript) { lpmsScript->_command[curCmd].lpszVarName = (char *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, len + 1); if (lpmsScript->_command[curCmd].lpszVarName == NULL) return NULL; - copyMemory(lpmsScript->_command[curCmd].lpszVarName, lpBuf, len); + memcpy(lpmsScript->_command[curCmd].lpszVarName, lpBuf, len); lpBuf += len; lpBuf = parseExpression(lpBuf, &lpmsScript->_command[curCmd].expr); @@ -346,7 +346,7 @@ static const byte *parseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { len = *lpBuf; lpBuf++; - copyMemory(lpmiItem->lpszDescribe, lpBuf, MIN((byte)127, len)); + memcpy(lpmiItem->lpszDescribe, lpBuf, MIN((byte)127, len)); lpBuf += len; if (len >= MAX_DESCRIBE_SIZE) @@ -416,7 +416,7 @@ static const byte *parseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { lpmiItem->_command[curCmd].lpszVarName = (char *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, len + 1); if (lpmiItem->_command[curCmd].lpszVarName == NULL) return NULL; - copyMemory(lpmiItem->_command[curCmd].lpszVarName, lpBuf, len); + memcpy(lpmiItem->_command[curCmd].lpszVarName, lpBuf, len); lpBuf += len; lpBuf = parseExpression(lpBuf, &lpmiItem->_command[curCmd].expr); @@ -548,7 +548,7 @@ bool ParseMpc(const byte *lpBuf) { for (i = 0; i < GLOBALS._nVars; i++) { wLen = *(const byte *)lpBuf; lpBuf++; - copyMemory(GLOBALS._lpmvVars->lpszVarName, lpBuf, MIN(wLen, (uint16)32)); + memcpy(GLOBALS._lpmvVars->lpszVarName, lpBuf, MIN(wLen, (uint16)32)); lpBuf += wLen; GLOBALS._lpmvVars->dwVal = READ_LE_UINT32(lpBuf); lpBuf += 4; @@ -590,7 +590,7 @@ bool ParseMpc(const byte *lpBuf) { lpTemp = (byte *)globalLock(GLOBALS._lpmmMsgs->_hText); for (j = 0; lpBuf[j] != 0;) { - copyMemory(lpTemp, &lpBuf[j + 1], lpBuf[j]); + memcpy(lpTemp, &lpBuf[j + 1], lpBuf[j]); lpTemp += lpBuf[j]; *lpTemp ++= '\0'; j += lpBuf[j] + 1; diff --git a/engines/tony/mpal/memory.cpp b/engines/tony/mpal/memory.cpp index c5e752d390..3a68ecb559 100644 --- a/engines/tony/mpal/memory.cpp +++ b/engines/tony/mpal/memory.cpp @@ -124,15 +124,6 @@ void MemoryManager::unlockItem(HANDLE handle) { } -/****************************************************************************\ -* Stand-alone methods -\****************************************************************************/ - -void copyMemory(void *dst, const void *first, int size) { - Common::copy((const byte *)first, (const byte *)first + size, (byte *)dst); -} - - } // end of namespace MPAL } // end of namespace Tony diff --git a/engines/tony/mpal/memory.h b/engines/tony/mpal/memory.h index 52d527544a..c7e4896cf9 100644 --- a/engines/tony/mpal/memory.h +++ b/engines/tony/mpal/memory.h @@ -70,9 +70,6 @@ public: #define GMEM_MOVEABLE 2 #define GMEM_ZEROINIT 4 -// Stand-alone methods -extern void copyMemory(void *dst, const void *first, int size); - } // end of namespace MPAL } // end of namespace Tony diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 20c28c5c93..76ca8a5db3 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -313,7 +313,7 @@ static char *DuplicateMessage(uint32 nMsgOrd) { if (clonemsg == NULL) return NULL; - copyMemory(clonemsg, origmsg, j); + memcpy(clonemsg, origmsg, j); globalUnlock(GLOBALS._lpmmMsgs[nMsgOrd]._hText); return clonemsg; @@ -346,7 +346,7 @@ static char *duplicateDialogPeriod(uint32 nPeriod) { if (clonemsg == NULL) return NULL; - copyMemory(clonemsg, origmsg, i); + memcpy(clonemsg, origmsg, i); globalUnlock(dialog->_periods[j]); @@ -546,7 +546,7 @@ static LPITEM getItemData(uint32 nOrdItem) { if (ret->_frames[i] == NULL) return NULL; - copyMemory(ret->_frames[i], dat, dim); + memcpy(ret->_frames[i], dat, dim); dat += dim; } @@ -906,7 +906,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { _ctx->MyActions[_ctx->k].perc = _ctx->curItem->Action[_ctx->j].perc; _ctx->MyActions[_ctx->k].when = _ctx->curItem->Action[_ctx->j].when; _ctx->MyActions[_ctx->k].nCmds = _ctx->curItem->Action[_ctx->j].nCmds; - copyMemory(_ctx->MyActions[_ctx->k].CmdNum, _ctx->curItem->Action[_ctx->j].CmdNum, + memcpy(_ctx->MyActions[_ctx->k].CmdNum, _ctx->curItem->Action[_ctx->j].CmdNum, MAX_COMMANDS_PER_ACTION * sizeof(uint16)); _ctx->MyActions[_ctx->k].dwLastTime = g_vm->getTime(); @@ -995,12 +995,12 @@ void LocationPollThread(CORO_PARAM, const void *param) { return; } - copyMemory(_ctx->newItem,_ctx->curItem, sizeof(MPALITEM)); + memcpy(_ctx->newItem,_ctx->curItem, sizeof(MPALITEM)); unlockItems(); /* We copy the action in #0 */ // _ctx->newItem->Action[0].nCmds = _ctx->curItem->Action[_ctx->j].nCmds; -// copyMemory(_ctx->newItem->Action[0].CmdNum,_ctx->curItem->Action[_ctx->j].CmdNum,_ctx->newItem->Action[0].nCmds*sizeof(_ctx->newItem->Action[0].CmdNum[0])); +// memcpy(_ctx->newItem->Action[0].CmdNum,_ctx->curItem->Action[_ctx->j].CmdNum,_ctx->newItem->Action[0].nCmds*sizeof(_ctx->newItem->Action[0].CmdNum[0])); _ctx->newItem->dwRes=_ctx->j; /* We will create an action, and will provide the necessary details */ @@ -1298,7 +1298,7 @@ static uint32 doAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { // In the new version number of the action in writing dwRes Common::copy((byte *)item, (byte *)item + sizeof(MPALITEM), (byte *)newitem); /* newitem->Action[0].nCmds=item->Action[i].nCmds; - copyMemory(newitem->Action[0].CmdNum,item->Action[i].CmdNum,newitem->Action[0].nCmds*sizeof(newitem->Action[0].CmdNum[0])); + memcpy(newitem->Action[0].CmdNum,item->Action[i].CmdNum,newitem->Action[0].nCmds*sizeof(newitem->Action[0].CmdNum[0])); */ newitem->dwRes = i; @@ -1679,7 +1679,7 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { else { lockItems(); y = itemGetOrderFromNum(x); - copyMemory(n, (char *)(GLOBALS._lpmiItems + y)->lpszDescribe, MAX_DESCRIBE_SIZE); + memcpy(n, (char *)(GLOBALS._lpmiItems + y)->lpszDescribe, MAX_DESCRIBE_SIZE); unlockItems(); } @@ -1857,7 +1857,7 @@ HANDLE mpalQueryHANDLE(uint16 wQueryType, ...) { else { lockItems(); y = itemGetOrderFromNum(x); - copyMemory(n, (char *)(GLOBALS._lpmiItems + y)->lpszDescribe, MAX_DESCRIBE_SIZE); + memcpy(n, (char *)(GLOBALS._lpmiItems + y)->lpszDescribe, MAX_DESCRIBE_SIZE); unlockItems(); } @@ -1986,7 +1986,7 @@ bool mpalExecuteScript(int nScript) { if (s == NULL) return false; - copyMemory(s, GLOBALS._lpmsScripts + n, sizeof(MPALSCRIPT)); + memcpy(s, GLOBALS._lpmsScripts + n, sizeof(MPALSCRIPT)); unlockScripts(); // !!! New process management @@ -2095,7 +2095,7 @@ int mpalGetSaveStateSize() { void mpalSaveState(byte *buf) { lockVar(); WRITE_LE_UINT32(buf, GLOBALS._nVars); - copyMemory(buf + 4, (byte *)GLOBALS._lpmvVars, GLOBALS._nVars * sizeof(MPALVAR)); + memcpy(buf + 4, (byte *)GLOBALS._lpmvVars, GLOBALS._nVars * sizeof(MPALVAR)); unlockVar(); } @@ -2114,7 +2114,7 @@ int mpalLoadState(byte *buf) { GLOBALS._hVars = globalAllocate(GMEM_ZEROINIT | GMEM_MOVEABLE, GLOBALS._nVars * sizeof(MPALVAR)); lockVar(); - copyMemory((byte *)GLOBALS._lpmvVars, buf + 4, GLOBALS._nVars * sizeof(MPALVAR)); + memcpy((byte *)GLOBALS._lpmvVars, buf + 4, GLOBALS._nVars * sizeof(MPALVAR)); unlockVar(); return GLOBALS._nVars * sizeof(MPALVAR) + 4; -- cgit v1.2.3 From 659436739f1e32297bdd8faac83b71e51d4a4937 Mon Sep 17 00:00:00 2001 From: Torbj旦rn Andersson Date: Sat, 25 Aug 2012 12:56:02 +0200 Subject: TONY: Make the verb menu sound effects play At least for now, preloading utility sound effects *is* needed in ScummVM. And since we now have preloading of both normal and utility sound effects, I've unstubbed the unloading functions as well. --- engines/tony/tony.cpp | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 081556572a..ec2ee49ba2 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -54,6 +54,7 @@ TonyEngine::TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc) : Eng SearchMan.addSubDirectoryMatching(gameDataDir, "Voices"); SearchMan.addSubDirectoryMatching(gameDataDir, "Roasted"); SearchMan.addSubDirectoryMatching(gameDataDir, "Music"); + SearchMan.addSubDirectoryMatching(gameDataDir, "Music/utilsfx"); // Set up load slot number _initialLoadSlotNumber = -1; @@ -355,15 +356,36 @@ FPSfx *TonyEngine::createSFX(Common::SeekableReadStream *stream) { } void TonyEngine::preloadUtilSFX(int nChannel, const char *fn) { - // No preloading is needed in ScummVM + if (_utilSfx[nChannel] != NULL) { + _utilSfx[nChannel]->stop(); + _utilSfx[nChannel]->release(); + _utilSfx[nChannel] = NULL; + } + + _theSound.createSfx(&_utilSfx[nChannel]); + + _utilSfx[nChannel]->loadFile(fn, FPCODEC_ADPCM); + _utilSfx[nChannel]->setVolume(63); } void TonyEngine::unloadAllSFX() { - // No preloading is needed in ScummVM + for (int i = 0; i < MAX_SFX_CHANNELS; i++) { + if (_sfx[i] != NULL) { + _sfx[i]->stop(); + _sfx[i]->release(); + _sfx[i] = NULL; + } + } } void TonyEngine::unloadAllUtilSFX() { - // No preloading is needed in ScummVM + for (int i = 0; i < MAX_SFX_CHANNELS; i++) { + if (_utilSfx[i] != NULL) { + _utilSfx[i]->stop(); + _utilSfx[i]->release(); + _utilSfx[i] = NULL; + } + } } void TonyEngine::initMusic() { -- cgit v1.2.3 From 8b0dca3862da10e87fe0fec237c694c48e12f83c Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Sat, 25 Aug 2012 13:15:28 +0200 Subject: TONY: Fix Take/ReleaseOwnership. --- engines/tony/custom.cpp | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index e082e5fcde..fcb304c623 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -2052,25 +2052,12 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr */ DECLARE_CUSTOM_FUNCTION(TakeOwnership)(CORO_PARAM, uint32 num, uint32, uint32, uint32) { - CORO_BEGIN_CONTEXT; - bool expired; - CORO_END_CONTEXT(_ctx); - - CORO_BEGIN_CODE(_ctx); - // The event is operating as a mutex, so if the event is already set, wait until it's reset - do { - CORO_INVOKE_3(CoroScheduler.waitForSingleObject, GLOBALS._mut[num], 0, &_ctx->expired); - } while (!_ctx->expired); - - // Set the event to flag ownership - CoroScheduler.setEvent(GLOBALS._mut[num]); - - CORO_END_CODE; + CoroScheduler.waitForSingleObject(coroParam, GLOBALS._mut[num], CORO_INFINITE); } DECLARE_CUSTOM_FUNCTION(ReleaseOwnership)(CORO_PARAM, uint32 num, uint32, uint32, uint32) { - CoroScheduler.resetEvent(GLOBALS._mut[num]); + CoroScheduler.setEvent(GLOBALS._mut[num]); } /* @@ -2563,7 +2550,7 @@ void setupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation int i; for (i = 0; i < 10; i++) - GLOBALS._mut[i] = CoroScheduler.createEvent(false, false); + GLOBALS._mut[i] = CoroScheduler.createEvent(false, true); for (i = 0; i < 200; i++) GLOBALS._ambiance[i] = 0; -- cgit v1.2.3 From ca82454d74c27f496666a76ef2c96528375d8b92 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Sat, 25 Aug 2012 14:08:35 +0200 Subject: TONY: Reset _hEndOfBuffer when restarting sounds. --- engines/tony/sound.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index 87e142df48..8ea7aa03c3 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -261,9 +261,7 @@ bool FPSfx::play() { stop(); // sanity check if (_bFileLoaded) { - // FIXME - //if (hEndOfBuffer != CORO_INVALID_PID_VALUE) - // ResetEvent(hEndOfBuffer); + CoroScheduler.resetEvent(_hEndOfBuffer); _rewindableStream->rewind(); -- cgit v1.2.3 From 5cc63df5134834a49a44a929dd549dc924040793 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Sat, 25 Aug 2012 14:42:14 +0200 Subject: TONY: Fix exiting from the save menu. We have to copy _nState before it gets reset in closeState. --- engines/tony/game.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 9b1d85f827..321a4fa88d 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -1008,8 +1008,8 @@ void RMOptionScreen::changeState(CORO_PARAM, OptionScreenState newState) { CORO_BEGIN_CODE(_ctx); - closeState(); _nLastState = _nState; + closeState(); _nState = newState; CORO_INVOKE_0(initState); -- cgit v1.2.3 From 7cb29f1522095484e44d0529e73d3712f33fca92 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 26 Aug 2012 23:33:46 +0200 Subject: TONY: Move font related arrays to a DAT file --- engines/tony/font.cpp | 1426 +------------------------------------------------ engines/tony/tony.cpp | 92 ++++ engines/tony/tony.h | 12 + 3 files changed, 113 insertions(+), 1417 deletions(-) (limited to 'engines') diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index a3d253a52c..55e3b7627a 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -222,387 +222,10 @@ void RMFontDialog::init() { _lDefault = 13; _hDefault = 18; Common::fill(&_l2Table[0][0], &_l2Table[0][0] + (256 * 256), '\0'); - for (i = 0; i < 256; i++) { - _cTable[i] = -1; - _lTable[i] = _lDefault; - } - for (i = 0; i < 26; i++) - _cTable['A' + i] = i + 0; - - for (i = 0; i < 26; i++) - _cTable['a' + i] = i + 26; - - for (i = 0; i < 10; i++) - _cTable['0' + i] = i + 52; - - _cTable[';'] = 62; - _cTable[','] = 63; - _cTable['.'] = 64; - _cTable[':'] = 65; - _cTable['-'] = 66; - _cTable['_'] = 67; - _cTable['+'] = 68; - _cTable['<'] = 69; - _cTable['>'] = 70; - _cTable['!'] = 71; - //_cTable['!'] = 72; Exclamation countdown - _cTable['?'] = 73; - //_cTable['?'] = 74; Question down - _cTable['('] = 75; - _cTable[')'] = 76; - _cTable['\"'] = 77; - _cTable['^'] = 77; - _cTable['/'] = 78; - _cTable[(byte)''] = 79; - _cTable['$'] = 80; - _cTable['%'] = 81; - _cTable['&'] = 82; - _cTable['='] = 83; - _cTable[(byte)''] = 84; - _cTable[(byte)''] = 85; - _cTable[(byte)''] = 86; - _cTable[(byte)''] = 87; - _cTable[(byte)''] = 88; - _cTable[(byte)''] = 89; - _cTable[(byte)''] = 89; - _cTable[(byte)''] = 90; - _cTable[(byte)''] = 91; - _cTable[(byte)''] = 92; - _cTable[(byte)''] = 93; - _cTable[(byte)''] = 94; - _cTable[(byte)''] = 95; - _cTable[(byte)''] = 96; - _cTable[(byte)''] = 97; - _cTable[(byte)''] = 98; - _cTable[(byte)''] = 99; - //_cTable[' '] = 100; e circlet - //_cTable[' '] = 101; i circlet - //_cTable[' '] = 102; o circlet - //_cTable[' '] = 103; u circlet - _cTable[(byte)''] = 104; - _cTable[(byte)''] = 105; - _cTable[(byte)''] = 106; - _cTable[(byte)''] = 107; - _cTable[(byte)''] = 108; - _cTable[(byte)''] = 109; - //_cTable[''] = 110; integral - _cTable['\''] = 111; - - // Little lengths - _lTable[' '] = 9; - _lTable['\''] = 5; - _lTable['.'] = 5; - _lTable[','] = 5; - _lTable[':'] = 5; - _lTable[';'] = 5; - _lTable['!'] = 5; - _lTable['?'] = 10; - _lTable['\"'] = 5; - _lTable['^'] = 5; - _lTable['('] = 7; - _lTable[')'] = 7; - - _lTable['4'] = 10; - - _lTable['a'] = 14; - _lTable['b'] = 15; - _lTable['c'] = 12; - _lTable['e'] = 12; - _lTable['i'] = 6; - _lTable[''] = 6; - _lTable['l'] = 5; - _lTable['m'] = 16; - _lTable['n'] = 12; - _lTable['o'] = 11; - _lTable['p'] = 11; - _lTable['s'] = 12; - _lTable['u'] = 12; - - _lTable['E'] = 10; - _lTable['F'] = 11; - - if (g_vm->getLanguage() == Common::PL_POL) { - // Polish characters - //AaCcEeLlNnOoSsZzZz - //ス謎戊3剔囀 - - _cTable[(byte)''] = 112; - _cTable[(byte)''] = 113; - _cTable[(byte)''] = 114; - _cTable[(byte)''] = 115; - _cTable[(byte)''] = 116; - _cTable[(byte)''] = 117; - _cTable[(byte)''] = 118; - _cTable[(byte)''] = 119; - _cTable[(byte)''] = 120; - _cTable[(byte)''] = 121; - _cTable[(byte)''] = 122; - _cTable[(byte)''] = 123; - _cTable[(byte)''] = 124; - _cTable[(byte)''] = 125; - _cTable[(byte)''] = 126; - _cTable[(byte)''] = 127; - _cTable[(byte)''] = 128; - _cTable[(byte)''] = 129; - - _lTable[(byte)''] = 14; - _lTable[(byte)''] = 16; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 14; - _lTable[(byte)''] = 9; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 13; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 13; - _lTable[(byte)''] = 13; - _lTable[(byte)''] = 14; - _lTable[(byte)''] = 13; - - } else if (g_vm->getLanguage() == Common::RU_RUS) { - - // Russian Characters - // WARNING: The Russian font uses many of the ISO-Latin-1 font, - // allowing for further translations. To support Tonyin other langauges, - // these mappings could be used as a basis - - _cTable[(byte)''] = 130; - _cTable[(byte)''] = 131; - _cTable[(byte)''] = 132; - _cTable[(byte)''] = 133; - _cTable[(byte)''] = 134; - _cTable[(byte)''] = 135; - _cTable[(byte)''] = 136; - _cTable[(byte)''] = 137; - _cTable[(byte)''] = 138; - _cTable[(byte)''] = 139; - _cTable[(byte)''] = 140; - _cTable[(byte)''] = 141; - _cTable[(byte)''] = 142; - _cTable[(byte)''] = 143; - _cTable[(byte)''] = 144; - _cTable[(byte)''] = 145; - _cTable[(byte)''] = 146; - _cTable[(byte)''] = 147; - _cTable[(byte)''] = 148; - _cTable[(byte)''] = 149; - _cTable[(byte)''] = 150; - _cTable[(byte)''] = 151; - _cTable[(byte)''] = 152; - _cTable[(byte)''] = 153; - _cTable[(byte)''] = 154; - _cTable[(byte)''] = 155; - _cTable[(byte)''] = 156; - _cTable[(byte)''] = 157; - _cTable[(byte)''] = 158; - _cTable[(byte)''] = 159; - _cTable[(byte)''] = 160; - _cTable[(byte)''] = 161; - _cTable[(byte)''] = 162; - - _cTable[(byte)''] = 163; - _cTable[(byte)''] = 164; - _cTable[(byte)''] = 165; - _cTable[(byte)''] = 166; - _cTable[(byte)''] = 167; - _cTable[(byte)''] = 168; - _cTable[(byte)''] = 169; - _cTable[(byte)''] = 170; - _cTable[(byte)''] = 171; - _cTable[(byte)''] = 172; - _cTable[(byte)''] = 173; - _cTable[(byte)''] = 174; - _cTable[(byte)''] = 175; - _cTable[(byte)''] = 176; - _cTable[(byte)''] = 177; - _cTable[(byte)''] = 178; - _cTable[(byte)''] = 179; - _cTable[(byte)''] = 180; - _cTable[(byte)''] = 181; - _cTable[(byte)''] = 182; - _cTable[(byte)''] = 183; - _cTable[(byte)''] = 184; - _cTable[(byte)''] = 185; - _cTable[(byte)''] = 186; - _cTable[(byte)''] = 187; - _cTable[(byte)''] = 188; - _cTable[(byte)''] = 189; - _cTable[(byte)''] = 190; - _cTable[(byte)''] = 191; - _cTable[(byte)''] = 192; - _cTable[(byte)''] = 193; - _cTable[(byte)''] = 194; - _cTable[(byte)''] = 195; - - _lTable[(byte)''] = 13; - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 13; - _lTable[(byte)''] = 13; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 13; - _lTable[(byte)''] = 14; - _lTable[(byte)''] = 14; - _lTable[(byte)''] = 13; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 18; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 13; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 13; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 17; - _lTable[(byte)''] = 18; - _lTable[(byte)''] = 16; - _lTable[(byte)''] = 18; - _lTable[(byte)''] = 19; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 16; - _lTable[(byte)''] = 14; - - _lTable[(byte)''] = 14; - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 13; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 14; - _lTable[(byte)''] = 8; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 16; - _lTable[(byte)''] = 14; - _lTable[(byte)''] = 16; - _lTable[(byte)''] = 16; - _lTable[(byte)''] = 9; - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 14; - - } else if (g_vm->getLanguage() == Common::CZ_CZE) { - // Czech - _cTable[(byte)''] = 196; - _cTable[(byte)''] = 197; - _cTable[(byte)''] = 198; - _cTable[(byte)''] = 199; - _cTable[(byte)''] = 200; - _cTable[(byte)''] = 201; - _cTable[(byte)''] = 202; - _cTable[(byte)''] = 203; - _cTable[(byte)''] = 204; - _cTable[(byte)''] = 205; - _cTable[(byte)''] = 206; - _cTable[(byte)''] = 207; - _cTable[(byte)''] = 208; - _cTable[(byte)''] = 209; - _cTable[(byte)''] = 210; - - _cTable[(byte)''] = 211; - _cTable[(byte)''] = 212; - _cTable[(byte)''] = 213; - _cTable[(byte)''] = 214; - _cTable[(byte)''] = 215; - _cTable[(byte)''] = 216; - _cTable[(byte)''] = 217; - _cTable[(byte)''] = 218; - _cTable[(byte)''] = 219; - _cTable[(byte)''] = 220; - _cTable[(byte)''] = 221; - _cTable[(byte)''] = 222; - _cTable[(byte)''] = 223; - _cTable[(byte)''] = 224; - _cTable[(byte)''] = 225; - - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 14; - _lTable[(byte)''] = 13; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 13; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 19; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 13; - _lTable[(byte)''] = 13; - _lTable[(byte)''] = 13; - - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 13; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 7; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 17; - _lTable[(byte)''] = 16; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 13; - _lTable[(byte)''] = 13; - - } else if (g_vm->getLanguage() == Common::FR_FRA) { - // French - - _cTable[(byte)''] = 226; - _cTable[(byte)''] = 227; - _cTable[(byte)''] = 228; - _cTable[(byte)''] = 229; - _cTable[(byte)''] = 230; - _cTable[(byte)''] = 231; - _cTable[(byte)''] = 232; - _cTable[(byte)''] = 233; - - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 9; - _lTable[(byte)''] = 13; - _lTable[(byte)''] = 13; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - - } else if (g_vm->getLanguage() == Common::DE_DEU) { - _cTable[(byte)''] = 234; - // 'SS' = 235 - _cTable[(byte)''] = 236; - _cTable[(byte)''] = 237; - _cTable[(byte)''] = 238; - - _lTable[(byte)''] = 15; + for (i = 0; i < 256; i++) { + _cTable[i] = g_vm->_cTableDialog[i]; + _lTable[i] = g_vm->_lTableDialog[i]; } } @@ -632,342 +255,8 @@ void RMFontMacc::init() { Common::fill(&_l2Table[0][0], &_l2Table[0][0] + (256 * 256), '\0'); for (i = 0; i < 256; i++) { - _cTable[i] = -1; - _lTable[i] = _lDefault; - } - - for (i = 0; i < 26; i++) - _cTable['A' + i] = i + 0; - - for (i = 0; i < 26; i++) - _cTable['a' + i] = i + 26; - - for (i = 0; i < 10; i++) - _cTable['0' + i] = i + 52; - - _cTable['!'] = 62; - //_cTable['!'] = 63; // ! rovescia - _cTable['\"'] = 64; - _cTable['$'] = 65; - _cTable['%'] = 66; - _cTable['&'] = 67; - _cTable['/'] = 68; - _cTable['('] = 69; - _cTable[')'] = 70; - _cTable['='] = 71; - _cTable['?'] = 72; - //_cTable['?'] = 73; // ? rovescia - _cTable['*'] = 74; - _cTable['+'] = 75; - _cTable[(byte)''] = 76; - _cTable[';'] = 77; - _cTable[','] = 78; - _cTable['.'] = 79; - _cTable[':'] = 80; - _cTable['-'] = 81; - _cTable['<'] = 82; - _cTable['>'] = 83; - _cTable['/'] = 84; - _cTable[(byte)''] = 85; - _cTable[(byte)''] = 86; - _cTable[(byte)''] = 87; - _cTable[(byte)''] = 88; - _cTable[(byte)''] = 89; - _cTable[(byte)''] = 90; - //_cTable[(byte)''] = 91; // e with ball - _cTable[(byte)''] = 92; - _cTable[(byte)''] = 93; - //_cTable[(byte)''] = 94; // i with ball - _cTable[(byte)''] = 95; - _cTable[(byte)''] = 96; - //_cTable[(byte)''] = 97; // o with ball - _cTable[(byte)''] = 98; - _cTable[(byte)''] = 99; - //_cTable[(byte)''] = 100; // u with ball - _cTable[(byte)''] = 101; - - if (g_vm->getLanguage() == Common::PL_POL) { - // Polish characters - //AaCcEeLlNnOoSsZzZz - //ス謎戊3剔囀 - - _cTable[(byte)''] = 102; - _cTable[(byte)''] = 103; - _cTable[(byte)''] = 104; - _cTable[(byte)''] = 105; - _cTable[(byte)''] = 106; - _cTable[(byte)''] = 107; - _cTable[(byte)''] = 108; - _cTable[(byte)''] = 109; - _cTable[(byte)''] = 110; - _cTable[(byte)''] = 111; - _cTable[(byte)''] = 112; - _cTable[(byte)''] = 113; - _cTable[(byte)''] = 114; - _cTable[(byte)''] = 115; - _cTable[(byte)''] = 116; - _cTable[(byte)''] = 117; - _cTable[(byte)''] = 118; - _cTable[(byte)''] = 119; - - _lTable[(byte)''] = 14; - _lTable[(byte)''] = 16; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 14; - _lTable[(byte)''] = 9; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 13; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 13; - _lTable[(byte)''] = 13; - _lTable[(byte)''] = 14; - _lTable[(byte)''] = 13; - - } else if (g_vm->getLanguage() == Common::RU_RUS) { - // Russian Characters - // WARNING: The Russian font uses many of the ISO-Latin-1 font, - // allowing for further translations. To support Tonyin other langauges, - // these mappings could be used as a basis - _cTable[(byte)''] = 120; - _cTable[(byte)''] = 121; - _cTable[(byte)''] = 122; - _cTable[(byte)''] = 123; - _cTable[(byte)''] = 124; - _cTable[(byte)''] = 125; - _cTable[(byte)''] = 126; - _cTable[(byte)''] = 127; - _cTable[(byte)''] = 128; - _cTable[(byte)''] = 129; - _cTable[(byte)''] = 130; - _cTable[(byte)''] = 131; - _cTable[(byte)''] = 132; - _cTable[(byte)''] = 133; - _cTable[(byte)''] = 134; - _cTable[(byte)''] = 135; - _cTable[(byte)''] = 136; - _cTable[(byte)''] = 137; - _cTable[(byte)''] = 138; - _cTable[(byte)''] = 139; - _cTable[(byte)''] = 140; - _cTable[(byte)''] = 141; - _cTable[(byte)''] = 142; - _cTable[(byte)''] = 143; - _cTable[(byte)''] = 144; - _cTable[(byte)''] = 145; - _cTable[(byte)''] = 146; - _cTable[(byte)''] = 147; - _cTable[(byte)''] = 148; - _cTable[(byte)''] = 149; - _cTable[(byte)''] = 150; - _cTable[(byte)''] = 151; - _cTable[(byte)''] = 152; - - _cTable[(byte)''] = 153; - _cTable[(byte)''] = 154; - _cTable[(byte)''] = 155; - _cTable[(byte)''] = 156; - _cTable[(byte)''] = 157; - _cTable[(byte)''] = 158; - _cTable[(byte)''] = 159; - _cTable[(byte)''] = 160; - _cTable[(byte)''] = 161; - _cTable[(byte)''] = 162; - _cTable[(byte)''] = 163; - _cTable[(byte)''] = 164; - _cTable[(byte)''] = 165; - _cTable[(byte)''] = 166; - _cTable[(byte)''] = 167; - _cTable[(byte)''] = 168; - _cTable[(byte)''] = 169; - _cTable[(byte)''] = 170; - _cTable[(byte)''] = 171; - _cTable[(byte)''] = 172; - _cTable[(byte)''] = 173; - _cTable[(byte)''] = 174; - _cTable[(byte)''] = 175; - _cTable[(byte)''] = 176; - _cTable[(byte)''] = 177; - _cTable[(byte)''] = 178; - _cTable[(byte)''] = 179; - _cTable[(byte)''] = 180; - _cTable[(byte)''] = 181; - _cTable[(byte)''] = 182; - _cTable[(byte)''] = 183; - _cTable[(byte)''] = 184; - _cTable[(byte)''] = 185; - - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 9; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 9; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 8; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 9; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 9; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 9; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 9; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 9; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 9; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - - } else if (g_vm->getLanguage() == Common::CZ_CZE) { - // Czech - - _cTable[(byte)''] = 186; - _cTable[(byte)''] = 187; - _cTable[(byte)''] = 188; - _cTable[(byte)''] = 189; - _cTable[(byte)''] = 190; - _cTable[(byte)''] = 191; - _cTable[(byte)''] = 192; - _cTable[(byte)''] = 193; - _cTable[(byte)''] = 194; - _cTable[(byte)''] = 195; - _cTable[(byte)''] = 196; - _cTable[(byte)''] = 197; - _cTable[(byte)''] = 198; - _cTable[(byte)''] = 199; - _cTable[(byte)''] = 200; - - _cTable[(byte)''] = 201; - _cTable[(byte)''] = 202; - _cTable[(byte)''] = 203; - _cTable[(byte)''] = 204; - _cTable[(byte)''] = 205; - _cTable[(byte)''] = 206; - _cTable[(byte)''] = 207; - _cTable[(byte)''] = 208; - _cTable[(byte)''] = 209; - _cTable[(byte)''] = 210; - _cTable[(byte)''] = 211; - _cTable[(byte)''] = 212; - _cTable[(byte)''] = 213; - _cTable[(byte)''] = 214; - _cTable[(byte)''] = 215; - - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 9; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 9; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 9; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 9; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 9; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - - } else if (g_vm->getLanguage() == Common::FR_FRA) { - // French - - _cTable[(byte)''] = 226; - _cTable[(byte)''] = 227; - _cTable[(byte)''] = 228; - _cTable[(byte)''] = 229; - _cTable[(byte)''] = 230; - _cTable[(byte)''] = 231; - _cTable[(byte)''] = 232; - _cTable[(byte)''] = 233; - - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 8; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 10; - - } else if (g_vm->getLanguage() == Common::DE_DEU) { - // German - - _cTable[(byte)''] = 234; - // 'SS' = 235 - _cTable[(byte)''] = 236; - _cTable[(byte)''] = 237; - _cTable[(byte)''] = 238; - - _lTable[(byte)''] = 11; + _cTable[i] = g_vm->_cTableMacc[i]; + _lTable[i] = g_vm->_lTableMacc[i]; } } @@ -996,430 +285,8 @@ void RMFontCredits::init() { Common::fill(&_l2Table[0][0], &_l2Table[0][0] + (256 * 256), '\0'); for (i = 0; i < 256; i++) { - _cTable[i] = -1; - _lTable[i] = _lDefault; - } - - for (i = 0; i < 26; i++) - _cTable['A' + i] = i + 0; - - for (i = 0; i < 26; i++) - _cTable['a' + i] = i + 26; - - - - _cTable[(byte)''] = 52; - _cTable[(byte)''] = 53; -// _cTable[''] = 54; // a ^ -// _cTable[''] = 55; // a pallini - _cTable[(byte)''] = 56; - _cTable[(byte)''] = 57; -// _cTable[''] = 58; // e ^ -// _cTable[''] = 59; // e pallini - _cTable[(byte)''] = 60; - _cTable[(byte)''] = 61; -// _cTable[''] = 62; // i ^ -// _cTable[''] = 63; // i pallini - _cTable[(byte)''] = 64; - _cTable[(byte)''] = 65; -// _cTable[''] = 66; // o ^ -// _cTable[''] = 67; // o pallini - _cTable[(byte)''] = 68; - _cTable[(byte)''] = 69; -// _cTable[''] = 70; // u ^ -// _cTable[''] = 71; // u pallini -// _cTable[''] = 72; // y pallini - _cTable[(byte)''] = 73; - _cTable[(byte)''] = 74; -// _cTable[''] = 75; // o barrato -// _cTable[''] = 76; // ac - _cTable[(byte)''] = 77; -// _cTable[''] = 78; // ? rovesciato - _cTable['?'] = 79; -// _cTable[''] = 80; // ! rovesciato - _cTable['!'] = 81; -// _cTable[''] = 82; // 1/2 -// _cTable[''] = 83; // 1/4 - _cTable['('] = 84; - _cTable[')'] = 85; - _cTable[(byte)''] = 86; - _cTable[(byte)''] = 87; -// _cTable[''] = 88; // AE - _cTable[':'] = 89; - _cTable['%'] = 90; - _cTable['&'] = 91; - _cTable['/'] = 92; - _cTable['+'] = 93; - _cTable[';'] = 94; - _cTable[','] = 95; - _cTable['^'] = 96; - _cTable['='] = 97; - _cTable['_'] = 98; - _cTable['*'] = 99; - _cTable['.'] = 100; - - for (i = 0; i < 10; i++) - _cTable['0' + i] = i + 101; - _cTable['\''] = 111; - - _lTable[' '] = 11; - _lTable[(byte)''] = _lTable['A'] = 19; - _lTable['B'] = 15; - _lTable['C'] = 14; - _lTable['D'] = 13; - _lTable['E'] = 14; - _lTable['F'] = 13; - _lTable['G'] = 16; - _lTable['H'] = 15; - _lTable['I'] = 5; - _lTable['J'] = 8; - _lTable['K'] = 15; - _lTable['L'] = 13; - _lTable['M'] = 17; - _lTable['N'] = 15; - _lTable[''] = _lTable['O'] = 14; - _lTable['P'] = 12; - _lTable['Q'] = 14; - _lTable['R'] = 14; - _lTable['S'] = 15; - _lTable['T'] = 11; - _lTable[''] = _lTable['U'] = 12; - _lTable['V'] = 12; - _lTable['W'] = 16; - _lTable['X'] = 12; - _lTable['Y'] = 13; - _lTable['Z'] = 14; - - _lTable['a'] = 11; - _lTable['b'] = 9; - _lTable['c'] = 9; - _lTable['d'] = 10; - _lTable['e'] = 9; - _lTable['f'] = 8; - _lTable['g'] = 9; - _lTable['h'] = 10; - _lTable['i'] = 5; - _lTable['j'] = 6; - _lTable['k'] = 12; - _lTable['l'] = 6; - _lTable['m'] = 14; - _lTable['n'] = 10; - _lTable['o'] = 11; - _lTable['p'] = 11; - _lTable['q'] = 9; - _lTable['r'] = 9; - _lTable['s'] = 9; - _lTable['t'] = 6; - _lTable['u'] = 9; - _lTable['v'] = 10; - _lTable['w'] = 14; - _lTable['x'] = 9; - _lTable['y'] = 10; - _lTable['z'] = 9; - - _lTable['0'] = 12; - _lTable['1'] = 8; - _lTable['2'] = 10; - _lTable['3'] = 11; - _lTable['4'] = 12; - _lTable['5'] = 11; - _lTable['6'] = 12; - _lTable['7'] = 10; - _lTable['8'] = 11; - _lTable['9'] = 10; - - _lTable['/'] = 10; - _lTable['^'] = 9; - _lTable[','] = 5; - _lTable['.'] = 5; - _lTable[';'] = 5; - _lTable[':'] = 5; - _lTable['\''] = 5; - - if (g_vm->getLanguage() == Common::PL_POL) { - // Polish characters - //AaCcEeLlNnOoSsZzZz - //ス謎戊3剔囀 - - _cTable[(byte)''] = 112; - _cTable[(byte)''] = 113; - _cTable[(byte)''] = 114; - _cTable[(byte)''] = 115; - _cTable[(byte)''] = 116; - _cTable[(byte)''] = 117; - _cTable[(byte)''] = 118; - _cTable[(byte)''] = 119; - _cTable[(byte)''] = 120; - _cTable[(byte)''] = 121; - _cTable[(byte)''] = 122; - _cTable[(byte)''] = 123; - _cTable[(byte)''] = 124; - _cTable[(byte)''] = 125; - _cTable[(byte)''] = 126; - _cTable[(byte)''] = 127; - _cTable[(byte)''] = 128; - _cTable[(byte)''] = 129; - - _lTable[(byte)''] = 20; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 14; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 16; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 10; - - } else if (g_vm->getLanguage() == Common::RU_RUS) { - // Russian Characters - // WARNING: The Russian font uses many of the ISO-Latin-1 font, - // allowing for further translations. To support Tonyin other langauges, - // these mappings could be used as a basis - _cTable[(byte)''] = 130; - _cTable[(byte)''] = 131; - _cTable[(byte)''] = 132; - _cTable[(byte)''] = 133; - _cTable[(byte)''] = 134; - _cTable[(byte)''] = 135; - _cTable[(byte)''] = 136; - _cTable[(byte)''] = 137; - _cTable[(byte)''] = 138; - _cTable[(byte)''] = 139; - _cTable[(byte)''] = 140; - _cTable[(byte)''] = 141; - _cTable[(byte)''] = 142; - _cTable[(byte)''] = 143; - _cTable[(byte)''] = 144; - _cTable[(byte)''] = 145; - _cTable[(byte)''] = 146; - _cTable[(byte)''] = 147; - _cTable[(byte)''] = 148; - _cTable[(byte)''] = 149; - _cTable[(byte)''] = 150; - _cTable[(byte)''] = 151; - _cTable[(byte)''] = 152; - _cTable[(byte)''] = 153; - _cTable[(byte)''] = 154; - _cTable[(byte)''] = 155; - _cTable[(byte)''] = 156; - _cTable[(byte)''] = 157; - _cTable[(byte)''] = 158; - _cTable[(byte)''] = 159; - _cTable[(byte)''] = 160; - _cTable[(byte)''] = 161; - _cTable[(byte)''] = 162; - - _cTable[(byte)''] = 163; - _cTable[(byte)''] = 164; - _cTable[(byte)''] = 165; - _cTable[(byte)''] = 166; - _cTable[(byte)''] = 167; - _cTable[(byte)''] = 168; - _cTable[(byte)''] = 169; - _cTable[(byte)''] = 170; - _cTable[(byte)''] = 171; - _cTable[(byte)''] = 172; - _cTable[(byte)''] = 173; - _cTable[(byte)''] = 174; - _cTable[(byte)''] = 175; - _cTable[(byte)''] = 176; - _cTable[(byte)''] = 177; - _cTable[(byte)''] = 178; - _cTable[(byte)''] = 179; - _cTable[(byte)''] = 180; - _cTable[(byte)''] = 181; - _cTable[(byte)''] = 182; - _cTable[(byte)''] = 183; - _cTable[(byte)''] = 184; - _cTable[(byte)''] = 185; - _cTable[(byte)''] = 186; - _cTable[(byte)''] = 187; - _cTable[(byte)''] = 188; - _cTable[(byte)''] = 189; - _cTable[(byte)''] = 190; - _cTable[(byte)''] = 191; - _cTable[(byte)''] = 192; - _cTable[(byte)''] = 193; - _cTable[(byte)''] = 194; - _cTable[(byte)''] = 195; - - _lTable[(byte)''] = 20; - _lTable[(byte)''] = 16; - _lTable[(byte)''] = 16; - _lTable[(byte)''] = 14; - _lTable[(byte)''] = 22; - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 20; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 16; - _lTable[(byte)''] = 16; - _lTable[(byte)''] = 16; - _lTable[(byte)''] = 22; - _lTable[(byte)''] = 18; - _lTable[(byte)''] = 16; - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 14; - _lTable[(byte)''] = 13; - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 14; - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 13; - _lTable[(byte)''] = 16; - _lTable[(byte)''] = 14; - _lTable[(byte)''] = 23; - _lTable[(byte)''] = 23; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 16; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 20; - _lTable[(byte)''] = 15; - - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 16; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 13; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 13; - _lTable[(byte)''] = 13; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 13; - _lTable[(byte)''] = 14; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 16; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 13; - _lTable[(byte)''] = 11; - - } else if (g_vm->getLanguage() == Common::CZ_CZE) { - // CZECH Language - - _cTable[(byte)''] = 196; - _cTable[(byte)''] = 197; - _cTable[(byte)''] = 198; - _cTable[(byte)''] = 199; - _cTable[(byte)''] = 200; - _cTable[(byte)''] = 201; - _cTable[(byte)''] = 202; - _cTable[(byte)''] = 203; - _cTable[(byte)''] = 204; - _cTable[(byte)''] = 205; - _cTable[(byte)''] = 206; - _cTable[(byte)''] = 207; - _cTable[(byte)''] = 208; - _cTable[(byte)''] = 209; - _cTable[(byte)''] = 210; - - _cTable[(byte)''] = 211; - _cTable[(byte)''] = 212; - _cTable[(byte)''] = 213; - _cTable[(byte)''] = 214; - _cTable[(byte)''] = 215; - _cTable[(byte)''] = 216; - _cTable[(byte)''] = 217; - _cTable[(byte)''] = 218; - _cTable[(byte)''] = 219; - _cTable[(byte)''] = 220; - _cTable[(byte)''] = 221; - _cTable[(byte)''] = 222; - _cTable[(byte)''] = 223; - _cTable[(byte)''] = 224; - _cTable[(byte)''] = 225; - - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 14; - _lTable[(byte)''] = 20; - _lTable[(byte)''] = 7; - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 20; - _lTable[(byte)''] = 19; - _lTable[(byte)''] = 16; - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 13; - _lTable[(byte)''] = 13; - - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 6; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 15; - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 10; - - } else if (g_vm->getLanguage() == Common::FR_FRA) { - // French - - _cTable[(byte)''] = 226; - _cTable[(byte)''] = 227; - _cTable[(byte)''] = 228; - _cTable[(byte)''] = 229; - _cTable[(byte)''] = 230; - _cTable[(byte)''] = 231; - _cTable[(byte)''] = 232; - _cTable[(byte)''] = 233; - - _lTable[(byte)''] = 12; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 6; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 10; - _lTable[(byte)''] = 11; - _lTable[(byte)''] = 11; - - } else if (g_vm->getLanguage() == Common::DE_DEU) { - // German - - _cTable[(byte)''] = 234; - // 'SS' = 235 - - // old chars overrides - _cTable[(byte)''] = _cTable[(byte)''] = 55; - _cTable[(byte)''] = _cTable[(byte)''] = 67; - _cTable[(byte)''] = _cTable[(byte)''] = 71; - - _lTable[(byte)''] = 11; + _cTable[i] = g_vm->_cTableCred[i]; + _lTable[i] = g_vm->_lTableCred[i]; } } @@ -1461,112 +328,10 @@ void RMFontObj::init() { Common::fill(&_l2Table[0][0], &_l2Table[0][0] + (256 * 256), '\0'); for (i = 0; i < 256; i++) { - _cTable[i] = -1; - _lTable[i] = _lDefault; - } - - for (i = 0; i < 26; i++) { - _cTable['A' + i] = i + 0; - _cTable['a' + i] = i + 0; + _cTable[i] = g_vm->_cTableObj[i]; + _lTable[i] = g_vm->_lTableObj[i]; } - for (i = 0; i < 10; i++) - _cTable['0' + i] = i + 26; - - _cTable[','] = 36; - _cTable[';'] = 37; - _cTable['.'] = 38; - _cTable[':'] = 39; - _cTable['-'] = 40; - _cTable['+'] = 41; - _cTable['!'] = 42; - // _cTable['!'] = 43; Exclamation countdown - _cTable['?'] = 44; - // _cTable['?'] = 45; Interrogativo alla rovescia - _cTable['/'] = 46; - _cTable['('] = 47; - _cTable[')'] = 48; - _cTable['='] = 49; - _cTable['\''] = 50; - _cTable['\"'] = 51; - _cTable[(byte)''] = 52; - _cTable[(byte)'$'] = 53; - _cTable[(byte)'%'] = 54; - _cTable[(byte)'&'] = 55; - _cTable[(byte)'^'] = 56; - _cTable[(byte)'*'] = 57; - _cTable[(byte)'<'] = 58; - _cTable[(byte)'>'] = 59; - _cTable[(byte)''] = 60; - _cTable[(byte)''] = 61; - _cTable[(byte)''] = 62; - _cTable[(byte)''] = 63; - //_cTable[(byte)''] = 64; integral - _cTable[(byte)''] = 65; - _cTable[(byte)''] = 66; - _cTable[(byte)''] = 67; - _cTable[(byte)''] = 68; - _cTable[(byte)''] = 69; - _cTable[(byte)''] = _cTable[(byte)''] = 70; - _cTable[(byte)''] = 71; - _cTable[(byte)''] = 72; - _cTable[(byte)''] = 73; - //_cTable[(byte)' '] = 74; e circlet - _cTable[(byte)''] = 75; - _cTable[(byte)''] = 76; - //_cTable[(byte)' '] = 77; i circlet - _cTable[(byte)''] = 78; - _cTable[(byte)''] = _cTable[(byte)''] = 79; - //_cTable[(byte)' '] = 80; o circlet - _cTable[(byte)''] = 81; - _cTable[(byte)''] = _cTable[(byte)''] = 82; - //_cTable[' '] = 83; u circlet - //_cTable[' '] = 84; y dieresi - - /* Little lengths */ - _lTable[' '] = 11; - _lTable['.'] = 8; - _lTable['-'] = 12; - _lTable['\''] = 8; - _lTable['0'] = 20; - _lTable['1'] = 20; - _lTable['2'] = 15; - _lTable['3'] = 20; - _lTable['4'] = 20; - _lTable['5'] = 20; - _lTable['6'] = 20; - _lTable['7'] = 20; - _lTable['8'] = 20; - _lTable['9'] = 20; - - - _lTable['a'] = _lTable['A'] = _lTable[''] = _lTable[''] = 17; - _lTable['b'] = _lTable['B'] = 17; - _lTable['c'] = _lTable['C'] = 19; - _lTable['d'] = _lTable['D'] = 17; - _lTable['e'] = _lTable['E'] = 15; - _lTable['f'] = _lTable['F'] = 17; - _lTable['g'] = _lTable['G'] = 19; - _lTable['i'] = _lTable['I'] = 16; - _lTable['h'] = _lTable['H'] = 17; - _lTable['k'] = _lTable['K'] = 17; - _lTable['l'] = _lTable['L'] = 14; - _lTable['m'] = _lTable['M'] = 19; - _lTable['n'] = _lTable['N'] = 17; - _lTable['o'] = _lTable['O'] = _lTable[''] = _lTable[''] = 19; - _lTable['p'] = _lTable['P'] = 17; - _lTable['q'] = _lTable['Q'] = 19; - _lTable['r'] = _lTable['R'] = 14; - _lTable['s'] = _lTable['S'] = 13; - _lTable['t'] = _lTable['T'] = 15; - _lTable['u'] = _lTable['U'] = _lTable[''] = _lTable[''] = 15; - _lTable['v'] = _lTable['V'] = 13; - _lTable['x'] = _lTable['X'] = 15; - _lTable['y'] = _lTable['Y'] = 13; - _lTable['w'] = _lTable['W'] = 19; - _lTable['z'] = _lTable['Z'] = 20; - _lTable[(byte)''] = 17; - /* Casi particolari */ setBothCase('C', 'C', 2); setBothCase('A', 'T', -2); @@ -1579,179 +344,6 @@ void RMFontObj::init() { setBothCase('Z', 'A', -1); setBothCase('R', 'R', 1); setBothCase('R', 'U', 3); - - if (g_vm->getLanguage() == Common::PL_POL) { - // Polish characters - //ス謎戊3剔囀 - //AaCcEeLlNnOoSsZzZz - _cTable[(byte)''] = _cTable[(byte)''] = 85; - _lTable[(byte)''] = _lTable[(byte)''] = 20; - - _cTable[(byte)''] = _cTable[(byte)''] = 86; - _lTable[(byte)''] = _lTable[(byte)''] = 22; - - _cTable[(byte)''] = _cTable[(byte)''] = 87; - _lTable[(byte)''] = _lTable[(byte)''] = 17; - - _cTable[(byte)''] = _cTable[(byte)''] = 88; - _lTable[(byte)''] = _lTable[(byte)''] = 19; - - _cTable[(byte)''] = _cTable[(byte)''] = 89; - _lTable[(byte)''] = _lTable[(byte)''] = 17; - - _cTable[(byte)''] = _cTable[(byte)''] = 90; - _lTable[(byte)''] = _lTable[(byte)''] = 22; - - _cTable[(byte)''] = _cTable[(byte)''] = 91; - _lTable[(byte)''] = _lTable[(byte)''] = 15; - - _cTable[(byte)''] = _cTable[(byte)''] = 92; - _lTable[(byte)''] = _lTable[(byte)''] = 21; - - _cTable[(byte)''] = _cTable[(byte)''] = 93; - _lTable[(byte)''] = _lTable[(byte)''] = 21; - - } else if (g_vm->getLanguage() == Common::RU_RUS) { - // Russian Characters - // WARNING: The Russian font uses many of the ISO-Latin-1 font, - // allowing for further translations. To support Tonyin other langauges, - // these mappings could be used as a basis - - _cTable[(byte)''] = _cTable[(byte)''] = 85; - _lTable[(byte)''] = _lTable[(byte)''] = 20; - - _cTable[(byte)''] = _cTable[(byte)''] = 94; - _cTable[(byte)''] = _cTable[(byte)''] = 95; - _cTable[(byte)''] = _cTable[(byte)''] = 96; - _cTable[(byte)''] = _cTable[(byte)''] = 97; - _cTable[(byte)''] = _cTable[(byte)''] = 98; - _cTable[(byte)''] = _cTable[(byte)''] = 99; - _cTable[(byte)''] = _cTable[(byte)''] = 100; - _cTable[(byte)''] = _cTable[(byte)''] = 101; - _cTable[(byte)''] = _cTable[(byte)''] = 102; - _cTable[(byte)''] = _cTable[(byte)''] = 103; - _cTable[(byte)''] = _cTable[(byte)''] = 104; - _cTable[(byte)''] = _cTable[(byte)''] = 105; - _cTable[(byte)''] = _cTable[(byte)''] = 106; - _cTable[(byte)''] = _cTable[(byte)''] = 107; - _cTable[(byte)''] = _cTable[(byte)''] = 108; - _cTable[(byte)''] = _cTable[(byte)''] = 109; - _cTable[(byte)''] = _cTable[(byte)''] = 110; - _cTable[(byte)''] = _cTable[(byte)''] = 111; - _cTable[(byte)''] = _cTable[(byte)''] = 112; - _cTable[(byte)''] = _cTable[(byte)''] = 113; - _cTable[(byte)''] = _cTable[(byte)''] = 114; - _cTable[(byte)''] = _cTable[(byte)''] = 115; - _cTable[(byte)''] = _cTable[(byte)''] = 116; - _cTable[(byte)''] = _cTable[(byte)''] = 117; - _cTable[(byte)''] = _cTable[(byte)''] = 118; - _cTable[(byte)''] = _cTable[(byte)''] = 119; - _cTable[(byte)''] = _cTable[(byte)''] = 120; - _cTable[(byte)''] = _cTable[(byte)''] = 121; - _cTable[(byte)''] = _cTable[(byte)''] = 122; - _cTable[(byte)''] = _cTable[(byte)''] = 123; - _cTable[(byte)''] = _cTable[(byte)''] = 124; - _cTable[(byte)''] = _cTable[(byte)''] = 125; - _cTable[(byte)''] = _cTable[(byte)''] = 126; - - - _lTable[(byte)''] = _lTable[(byte)''] = 18; - _lTable[(byte)''] = _lTable[(byte)''] = 18; - _lTable[(byte)''] = _lTable[(byte)''] = 18; - _lTable[(byte)''] = _lTable[(byte)''] = 17; - _lTable[(byte)''] = _lTable[(byte)''] = 16; - _lTable[(byte)''] = _lTable[(byte)''] = 18; - _lTable[(byte)''] = _lTable[(byte)''] = 18; - _lTable[(byte)''] = _lTable[(byte)''] = 20; - _lTable[(byte)''] = _lTable[(byte)''] = 18; - _lTable[(byte)''] = _lTable[(byte)''] = 18; - _lTable[(byte)''] = _lTable[(byte)''] = 18; - _lTable[(byte)''] = _lTable[(byte)''] = 18; - _lTable[(byte)''] = _lTable[(byte)''] = 16; - _lTable[(byte)''] = _lTable[(byte)''] = 18; - _lTable[(byte)''] = _lTable[(byte)''] = 15; - _lTable[(byte)''] = _lTable[(byte)''] = 22; - _lTable[(byte)''] = _lTable[(byte)''] = 15; - _lTable[(byte)''] = _lTable[(byte)''] = 18; - _lTable[(byte)''] = _lTable[(byte)''] = 22; - _lTable[(byte)''] = _lTable[(byte)''] = 19; - _lTable[(byte)''] = _lTable[(byte)''] = 16; - _lTable[(byte)''] = _lTable[(byte)''] = 21; - _lTable[(byte)''] = _lTable[(byte)''] = 20; - _lTable[(byte)''] = _lTable[(byte)''] = 16; - _lTable[(byte)''] = _lTable[(byte)''] = 16; - _lTable[(byte)''] = _lTable[(byte)''] = 19; - _lTable[(byte)''] = _lTable[(byte)''] = 22; - _lTable[(byte)''] = _lTable[(byte)''] = 18; - _lTable[(byte)''] = _lTable[(byte)''] = 19; - _lTable[(byte)''] = _lTable[(byte)''] = 19; - _lTable[(byte)''] = _lTable[(byte)''] = 15; - _lTable[(byte)''] = _lTable[(byte)''] = 18; - _lTable[(byte)''] = _lTable[(byte)''] = 18; - - } else if (g_vm->getLanguage() == Common::CZ_CZE) { - // Czech - - _cTable[(byte)''] = _cTable[(byte)''] = 127; - _cTable[(byte)''] = _cTable[(byte)''] = 128; - _cTable[(byte)''] = _cTable[(byte)''] = 129; - _cTable[(byte)''] = _cTable[(byte)''] = 130; - _cTable[(byte)''] = _cTable[(byte)''] = 131; - _cTable[(byte)''] = _cTable[(byte)''] = 132; - _cTable[(byte)''] = _cTable[(byte)''] = 133; - _cTable[(byte)''] = _cTable[(byte)''] = 134; - _cTable[(byte)''] = _cTable[(byte)''] = 135; - _cTable[(byte)''] = _cTable[(byte)''] = 136; - _cTable[(byte)''] = _cTable[(byte)''] = 137; - _cTable[(byte)''] = _cTable[(byte)''] = 138; - _cTable[(byte)''] = _cTable[(byte)''] = 139; - _cTable[(byte)''] = _cTable[(byte)''] = 140; - _cTable[(byte)''] = _cTable[(byte)''] = 141; - - _lTable[(byte)''] = _lTable[(byte)''] = 17; - _lTable[(byte)''] = _lTable[(byte)''] = 15; - _lTable[(byte)''] = _lTable[(byte)''] = 22; - _lTable[(byte)''] = _lTable[(byte)''] = 18; - _lTable[(byte)''] = _lTable[(byte)''] = 21; - _lTable[(byte)''] = _lTable[(byte)''] = 16; - _lTable[(byte)''] = _lTable[(byte)''] = 18; - _lTable[(byte)''] = _lTable[(byte)''] = 19; - _lTable[(byte)''] = _lTable[(byte)''] = 17; - _lTable[(byte)''] = _lTable[(byte)''] = 23; - _lTable[(byte)''] = _lTable[(byte)''] = 24; - _lTable[(byte)''] = _lTable[(byte)''] = 17; - _lTable[(byte)''] = _lTable[(byte)''] = 22; - _lTable[(byte)''] = _lTable[(byte)''] = 16; - _lTable[(byte)''] = _lTable[(byte)''] = 16; - - } else if (g_vm->getLanguage() == Common::FR_FRA) { - // French - - // Translate accented characters as normal letters - - _cTable[(byte)''] = _cTable[(byte)''] = _cTable[(byte)''] = 0; // a - _lTable[(byte)''] = _lTable[(byte)''] = _lTable[(byte)''] = 17; - - _cTable[(byte)''] = _cTable[(byte)''] = 4; // e - _lTable[(byte)''] = _lTable[(byte)''] = 15; - - _cTable[(byte)''] = _cTable[(byte)''] = _cTable[(byte)''] = 8; // i - _lTable[(byte)''] = _lTable[(byte)''] = _lTable[(byte)''] = 16; - - _cTable[(byte)''] = _cTable[(byte)''] = _cTable[(byte)''] = _cTable[(byte)''] = 14; // o - _lTable[(byte)''] = _lTable[(byte)''] = _lTable[(byte)''] = _lTable[(byte)''] = 19; - - _cTable[(byte)''] = _cTable[(byte)''] = 20; // u - _lTable[(byte)''] = _lTable[(byte)''] = 15; - - } else if (g_vm->getLanguage() == Common::DE_DEU) { - // German - - _cTable[''] = 142; - // SS = 143 - - _lTable[''] = 24; - } } diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index ec2ee49ba2..9124bed50d 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -111,6 +111,10 @@ Common::Error TonyEngine::run() { * Initialize the game */ Common::ErrorCode TonyEngine::init() { + // Load DAT file (used by font manager) + if (!loadTonyDat()) + return Common::kUnknownError; + if (isCompressed()) { Common::SeekableReadStream *stream = SearchMan.createReadStreamForMember("data1.cab"); if (!stream) @@ -177,6 +181,94 @@ Common::ErrorCode TonyEngine::init() { return Common::kNoError; } +bool TonyEngine::loadTonyDat() { + Common::String msg; + Common::File in; + + in.open("tony.dat"); + + if (!in.isOpen()) { + msg = "You're missing the 'tony.dat' file. Get it from the ScummVM website"; + GUIErrorMessage(msg); + warning("%s", msg.c_str()); + return false; + } + + // Read header + char buf[4+1]; + in.read(buf, 4); + buf[4] = '\0'; + + if (strcmp(buf, "TONY")) { + msg = "File 'tony.dat' is corrupt. Get it from the ScummVM website"; + GUIErrorMessage(msg); + warning("%s", msg.c_str()); + return false; + } + + int majVer = in.readByte(); + int minVer = in.readByte(); + + if ((majVer != TONY_DAT_VER_MAJ) || (minVer != TONY_DAT_VER_MIN)) { + msg = Common::String::format("File 'tony.dat' is wrong version. Expected %d.%d but got %d.%d. Get it from the ScummVM website", TONY_DAT_VER_MAJ, TONY_DAT_VER_MIN, majVer, minVer); + GUIErrorMessage(msg); + warning("%s", msg.c_str()); + + return false; + } + + int expectedLangVariant = -1; + switch (g_vm->getLanguage()) { + case Common::IT_ITA: + expectedLangVariant = 0; + break; + case Common::PL_POL: + expectedLangVariant = 1; + break; + case Common::RU_RUS: + expectedLangVariant = 2; + break; + case Common::CZ_CZE: + expectedLangVariant = 3; + break; + case Common::FR_FRA: + expectedLangVariant = 4; + break; + case Common::DE_DEU: + expectedLangVariant = 5; + break; + default: + msg = Common::String::format("Font variant not present in 'tony.dat'. Get it from the ScummVM website"); + GUIErrorMessage(msg); + warning("%s", msg.c_str()); + + return false; + } + + int numVariant = in.readUint16BE(); + if (expectedLangVariant > numVariant) { + msg = Common::String::format("Font variant not present in 'tony.dat'. Get it from the ScummVM website"); + GUIErrorMessage(msg); + warning("%s", msg.c_str()); + + return false; + } + + in.seek(in.pos() + (2 * 256 * 8 * expectedLangVariant)); + for (int i = 0; i < 256; i++) { + _cTableDialog[i] = in.readSint16BE(); + _lTableDialog[i] = in.readSint16BE(); + _cTableMacc[i] = in.readSint16BE(); + _lTableMacc[i] = in.readSint16BE(); + _cTableCred[i] = in.readSint16BE(); + _lTableCred[i] = in.readSint16BE(); + _cTableObj[i] = in.readSint16BE(); + _lTableObj[i] = in.readSint16BE(); + } + + return true; +} + void TonyEngine::initCustomFunctionMap() { INIT_CUSTOM_FUNCTION(_funcList, _funcListStrings); } diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 18cddf3f2a..f8358b15a7 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -70,6 +70,8 @@ enum { struct TonyGameDescription; #define MAX_SFX_CHANNELS 32 +#define TONY_DAT_VER_MAJ 0 +#define TONY_DAT_VER_MIN 1 struct VoiceHeader { int _offset; @@ -81,6 +83,7 @@ struct VoiceHeader { class TonyEngine : public Engine { private: Common::ErrorCode init(); + bool loadTonyDat(); void initMusic(); void closeMusic(); bool openVoiceDatabase(); @@ -106,6 +109,15 @@ public: Globals _globals; Debugger *_debugger; + int16 _cTableDialog[256]; + int16 _lTableDialog[256]; + int16 _cTableMacc[256]; + int16 _lTableMacc[256]; + int16 _cTableCred[256]; + int16 _lTableCred[256]; + int16 _cTableObj[256]; + int16 _lTableObj[256]; + enum DataDir { DD_BASE = 1, DD_SAVE, -- cgit v1.2.3 From 2ce6576515dee78a4377352130f407c199e4dc05 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 26 Aug 2012 23:58:06 +0200 Subject: TONY: Add English in loadTonyDat --- engines/tony/tony.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines') diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 9124bed50d..3a89caf055 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -220,6 +220,7 @@ bool TonyEngine::loadTonyDat() { int expectedLangVariant = -1; switch (g_vm->getLanguage()) { case Common::IT_ITA: + case Common::EN_ANY: expectedLangVariant = 0; break; case Common::PL_POL: -- cgit v1.2.3 From 72604fa3a67938d0126cf7c7331363ae29018222 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 27 Aug 2012 00:17:28 +0200 Subject: TONY: USe default fonts (Italian/English) when the language is unhandled instead of erroring out --- engines/tony/tony.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'engines') diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 3a89caf055..bb174dfbb1 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -239,11 +239,9 @@ bool TonyEngine::loadTonyDat() { expectedLangVariant = 5; break; default: - msg = Common::String::format("Font variant not present in 'tony.dat'. Get it from the ScummVM website"); - GUIErrorMessage(msg); - warning("%s", msg.c_str()); - - return false; + warning("Unhandled language, falling back to English/Italian fonts."); + expectedLangVariant = 0; + break; } int numVariant = in.readUint16BE(); -- cgit v1.2.3 From addca5d8567717bec3015f7fd0d99a707f96288a Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 27 Aug 2012 06:51:29 +0200 Subject: TONY: _rgb buffer is no longer static --- engines/tony/window.cpp | 14 ++++++-------- engines/tony/window.h | 2 +- 2 files changed, 7 insertions(+), 9 deletions(-) (limited to 'engines') diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index 1e60e636f3..9cf8167030 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -269,8 +269,6 @@ void RMWindow::plotLines(const byte *lpBuf, const Common::Point ¢er, int x, * RMSnapshot Methods \****************************************************************************/ -byte RMSnapshot::rgb[RM_SX *RM_SY * 3]; - void RMSnapshot::grabScreenshot(byte *lpBuf, int dezoom, uint16 *lpDestBuf) { uint16 *src = (uint16 *)lpBuf; @@ -284,7 +282,7 @@ void RMSnapshot::grabScreenshot(byte *lpBuf, int dezoom, uint16 *lpDestBuf) { src += (RM_SY - 1) * RM_BBX; if (dezoom == 1 && 0) { - byte *curOut = rgb; + byte *curOut = _rgb; for (int y = 0; y < dimy; y++) { for (int x = 0; x < dimx; x++) { @@ -322,13 +320,13 @@ void RMSnapshot::grabScreenshot(byte *lpBuf, int dezoom, uint16 *lpDestBuf) { sommar += (cursrc[curv * RM_BBX + u] >> 10) & 0x1F; } } - rgb[k + 0] = (byte)(sommab * 8 / (dezoom * dezoom)); - rgb[k + 1] = (byte)(sommag * 8 / (dezoom * dezoom)); - rgb[k + 2] = (byte)(sommar * 8 / (dezoom * dezoom)); + _rgb[k + 0] = (byte)(sommab * 8 / (dezoom * dezoom)); + _rgb[k + 1] = (byte)(sommag * 8 / (dezoom * dezoom)); + _rgb[k + 2] = (byte)(sommar * 8 / (dezoom * dezoom)); if (lpDestBuf != NULL) - lpDestBuf[k / 3] = ((int)rgb[k + 0] >> 3) | (((int)rgb[k + 1] >> 3) << 5) | - (((int)rgb[k + 2] >> 3) << 10); + lpDestBuf[k / 3] = ((int)_rgb[k + 0] >> 3) | (((int)_rgb[k + 1] >> 3) << 5) | + (((int)_rgb[k + 2] >> 3) << 10); k += 3; } diff --git a/engines/tony/window.h b/engines/tony/window.h index 6528060f17..25ec349196 100644 --- a/engines/tony/window.h +++ b/engines/tony/window.h @@ -42,7 +42,7 @@ struct DDSURFACEDESC { class RMSnapshot { private: // Buffer used to convert to RGB - static byte rgb[RM_SX *RM_SY * 3]; + byte _rgb[RM_SX *RM_SY * 3]; public: /** * Take a screenshot -- cgit v1.2.3 From 037920bf76bbf9320b5a96d8f98720e253a0956e Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Mon, 27 Aug 2012 12:30:02 +0200 Subject: TONY: Fix width of flipped dirty rects. --- engines/tony/gfxcore.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 806f4d07bb..406ed8043b 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -931,7 +931,7 @@ void RMGfxSourceBuffer8RLE::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPri width = x1; // Specify the drawn area - bigBuf.addDirtyRect(Common::Rect(x1 - width, y1, x1, y1 + height)); + bigBuf.addDirtyRect(Common::Rect(x1 - width, y1, x1 + 1, y1 + height)); for (y = 0; y < height; y++) { // Decompression @@ -1725,7 +1725,7 @@ void RMGfxSourceBuffer8AA::drawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri width = x1; // Specify the drawn area - bigBuf.addDirtyRect(Common::Rect(x1 - width, y1, x1, y1 + height)); + bigBuf.addDirtyRect(Common::Rect(x1 - width, y1, x1 + 1, y1 + height)); } else { // Specify the drawn area bigBuf.addDirtyRect(Common::Rect(x1, y1, x1 + width, y1 + height)); -- cgit v1.2.3 From 7b4dd0a682bf79cc86024d77d16411a6e2681f47 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Mon, 27 Aug 2012 12:39:58 +0200 Subject: TONY: Remove various bits of unused code. --- engines/tony/font.cpp | 19 ++--------- engines/tony/game.cpp | 6 ---- engines/tony/game.h | 5 --- engines/tony/gfxcore.cpp | 85 +++++++++++++--------------------------------- engines/tony/gfxcore.h | 23 +++++-------- engines/tony/gfxengine.cpp | 10 ------ engines/tony/gfxengine.h | 6 ---- engines/tony/input.cpp | 6 ---- engines/tony/input.h | 15 -------- engines/tony/tony.cpp | 12 ------- engines/tony/tony.h | 8 ----- engines/tony/window.cpp | 7 ---- engines/tony/window.h | 8 ----- 13 files changed, 35 insertions(+), 175 deletions(-) (limited to 'engines') diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 55e3b7627a..91dd8c0c39 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -49,21 +49,6 @@ RMFont::~RMFont() { unload(); } - -/** - * Dumps a font to a buffer - * @param buf Buffer for font contents - * @param nChars Number of characters (max 256) - * @param dimx X dimension in pixels - * @param dimy Y dimension in pixels -* -\****************************************************************************/ - -void DumpFontBMP(const char *filename, const byte *buf, int nChars, int charX, int charY, byte *pal) { - error("DumpFontBMP not supported in ScummVM"); -} - - void RMFont::load(const byte *buf, int nChars, int dimx, int dimy, uint32 palResID) { _letter = new RMGfxSourceBuffer8RLEByte[nChars]; @@ -150,7 +135,7 @@ int RMFont::stringLen(char bChar, char bNext) { } /****************************************************************************\ -* Metodi di RMFontColor +* RMFontColor Methods \****************************************************************************/ RMFontColor::RMFontColor() : RMFont() { @@ -180,7 +165,7 @@ void RMFontColor::setBaseColor(byte r1, byte g1, byte b1) { _fontG = g1; _fontB = b1; - // Constructs a new paletter for the font + // Constructs a new palette for the font for (i = 1; i < 16; i++) { pal[i * 3 + 0] = r >> 16; pal[i * 3 + 1] = g >> 16; diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 321a4fa88d..4699a9b9aa 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -1527,12 +1527,6 @@ void RMPointer::close() { } } - -int RMPointer::priority() { - // Pointer has minimum priority so it will be drawn last - return 200; -} - void RMPointer::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_BEGIN_CONTEXT; int n; diff --git a/engines/tony/game.h b/engines/tony/game.h index aa7d45bce6..9c58f28714 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -100,11 +100,6 @@ public: */ void doFrame(); - /** - * Overloading of priorities - */ - int priority(); - /** * draw method */ diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 406ed8043b..f9f7cb02ec 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -65,7 +65,6 @@ void RMGfxTaskSetPrior::setPriority(int nPrior) { RMGfxBuffer::RMGfxBuffer() { _dimx = _dimy = 0; - _bUseDDraw = false; _origBuf = _buf = NULL; } @@ -73,7 +72,7 @@ RMGfxBuffer::~RMGfxBuffer() { destroy(); } -void RMGfxBuffer::create(int dimx, int dimy, int nBpp, bool bUseDDraw) { +void RMGfxBuffer::create(int dimx, int dimy, int nBpp) { // Destroy the buffer it is already exists if (_buf != NULL) destroy(); @@ -81,34 +80,17 @@ void RMGfxBuffer::create(int dimx, int dimy, int nBpp, bool bUseDDraw) { // Copy the parameters in the private members _dimx = dimx; _dimy = dimy; - _bUseDDraw = bUseDDraw; - if (!_bUseDDraw) { - // Allocate a buffer - _origBuf = _buf = new byte[_dimx * _dimy * nBpp / 8]; - assert(_buf != NULL); - Common::fill(_origBuf, _origBuf + _dimx * _dimy * nBpp / 8, 0); - } + // Allocate a buffer + _origBuf = _buf = new byte[_dimx * _dimy * nBpp / 8]; + assert(_buf != NULL); + Common::fill(_origBuf, _origBuf + _dimx * _dimy * nBpp / 8, 0); } void RMGfxBuffer::destroy() { - if (!_bUseDDraw) { - if (_origBuf != NULL && _origBuf == _buf) { - delete[] _origBuf; - _origBuf = _buf = NULL; - } - } -} - -void RMGfxBuffer::lock() { - if (_bUseDDraw) { - // Manages acceleration - } -} - -void RMGfxBuffer::unlock() { - if (_bUseDDraw) { - // Manages acceleration + if (_origBuf != NULL && _origBuf == _buf) { + delete[] _origBuf; + _origBuf = _buf = NULL; } } @@ -125,8 +107,8 @@ RMGfxBuffer::operator void *() { return (void *)_buf; } -RMGfxBuffer::RMGfxBuffer(int dimx, int dimy, int nBpp, bool bUseDDraw) { - create(dimx, dimy, nBpp, bUseDDraw); +RMGfxBuffer::RMGfxBuffer(int dimx, int dimy, int nBpp) { + create(dimx, dimy, nBpp); } /****************************************************************************\ @@ -240,8 +222,8 @@ RMGfxWoodyBuffer::RMGfxWoodyBuffer() { } -RMGfxWoodyBuffer::RMGfxWoodyBuffer(int dimx, int dimy, bool bUseDDraw) - : RMGfxBuffer(dimx, dimy, 16, bUseDDraw) { +RMGfxWoodyBuffer::RMGfxWoodyBuffer(int dimx, int dimy) + : RMGfxBuffer(dimx, dimy, 16) { } /****************************************************************************\ @@ -252,19 +234,15 @@ RMGfxTargetBuffer::RMGfxTargetBuffer() { _otlist = NULL; _otSize = 0; _trackDirtyRects = false; -// csModifyingOT = g_system->createMutex(); } RMGfxTargetBuffer::~RMGfxTargetBuffer() { clearOT(); -// g_system->deleteMutex(csModifyingOT); } void RMGfxTargetBuffer::clearOT() { OTList *cur, *n; -// g_system->lockMutex(csModifyingOT); - cur = _otlist; while (cur != NULL) { @@ -276,8 +254,6 @@ void RMGfxTargetBuffer::clearOT() { } _otlist = NULL; - -// g_system->unlockMutex(csModifyingOT); } void RMGfxTargetBuffer::drawOT(CORO_PARAM) { @@ -294,10 +270,6 @@ void RMGfxTargetBuffer::drawOT(CORO_PARAM) { _ctx->prev = NULL; _ctx->cur = _otlist; - // Lock the buffer to access it - lock(); -// g_system->lockMutex(csModifyingOT); - while (_ctx->cur != NULL) { // Call the task Draw method, passing it a copy of the original _ctx->myprim = _ctx->cur->_prim->duplicate(); @@ -330,11 +302,6 @@ void RMGfxTargetBuffer::drawOT(CORO_PARAM) { } } -// g_system->unlockMutex(csModifyingOT); - - //Unlock after writing - unlock(); - CORO_END_CODE; } @@ -342,8 +309,6 @@ void RMGfxTargetBuffer::addPrim(RMGfxPrimitive *prim) { int nPrior; OTList *cur, *n; -// g_system->lockMutex(csModifyingOT); - // Warn of the OT listing prim->_task->Register(); @@ -368,8 +333,6 @@ void RMGfxTargetBuffer::addPrim(RMGfxPrimitive *prim) { n->_next = cur->_next; cur->_next = n; } - -// g_system->unlockMutex(csModifyingOT); } void RMGfxTargetBuffer::addDirtyRect(const Common::Rect &r) { @@ -554,8 +517,8 @@ int RMGfxSourceBufferPal::loadPaletteWA(uint32 resID, bool bSwapped) { void RMGfxSourceBuffer4::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { } -RMGfxSourceBuffer4::RMGfxSourceBuffer4(int dimx, int dimy, bool bUseDDraw) - : RMGfxBuffer(dimx, dimy, 4, bUseDDraw) { +RMGfxSourceBuffer4::RMGfxSourceBuffer4(int dimx, int dimy) + : RMGfxBuffer(dimx, dimy, 4) { setPriority(0); } @@ -569,8 +532,8 @@ int RMGfxSourceBuffer4::getBpp() { return 4; } -void RMGfxSourceBuffer4::create(int dimx, int dimy, bool bUseDDraw) { - RMGfxBuffer::create(dimx, dimy, 4, bUseDDraw); +void RMGfxSourceBuffer4::create(int dimx, int dimy) { + RMGfxBuffer::create(dimx, dimy, 4); } /****************************************************************************\ @@ -641,8 +604,8 @@ void RMGfxSourceBuffer8::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimit bigBuf.addDirtyRect(Common::Rect(dst._x1, dst._y1, dst._x1 + width, dst._y1 + height)); } -RMGfxSourceBuffer8::RMGfxSourceBuffer8(int dimx, int dimy, bool bUseDDraw) - : RMGfxBuffer(dimx, dimy, 8, bUseDDraw) { +RMGfxSourceBuffer8::RMGfxSourceBuffer8(int dimx, int dimy) + : RMGfxBuffer(dimx, dimy, 8) { setPriority(0); _bTrasp0 = false; } @@ -661,8 +624,8 @@ int RMGfxSourceBuffer8::getBpp() { return 8; } -void RMGfxSourceBuffer8::create(int dimx, int dimy, bool bUseDDraw) { - RMGfxBuffer::create(dimx, dimy, 8, bUseDDraw); +void RMGfxSourceBuffer8::create(int dimx, int dimy) { + RMGfxBuffer::create(dimx, dimy, 8); } #define GETRED(x) (((x) >> 10) & 0x1F) @@ -1989,8 +1952,8 @@ void RMGfxSourceBuffer16::prepareImage() { WRITE_LE_UINT16(&buf[i], FROM_LE_16(buf[i]) & 0x7FFF); } -RMGfxSourceBuffer16::RMGfxSourceBuffer16(int dimx, int dimy, bool bUseDDraw) - : RMGfxBuffer(dimx, dimy, 16, bUseDDraw) { +RMGfxSourceBuffer16::RMGfxSourceBuffer16(int dimx, int dimy) + : RMGfxBuffer(dimx, dimy, 16) { setPriority(0); _bTrasp0 = false; } @@ -2004,8 +1967,8 @@ int RMGfxSourceBuffer16::getBpp() { return 16; } -void RMGfxSourceBuffer16::create(int dimx, int dimy, bool bUseDDraw) { - RMGfxBuffer::create(dimx, dimy, 16, bUseDDraw); +void RMGfxSourceBuffer16::create(int dimx, int dimy) { + RMGfxBuffer::create(dimx, dimy, 16); } /****************************************************************************\ diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index 2402b1e029..cd7830be24 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -61,11 +61,10 @@ protected: int _dimx, _dimy; byte *_buf; byte *_origBuf; - bool _bUseDDraw; public: RMGfxBuffer(); - RMGfxBuffer(int dimx, int dimy, int nBpp, bool bUseDDraw = false); + RMGfxBuffer(int dimx, int dimy, int nBpp); virtual ~RMGfxBuffer(); // Attributes @@ -77,13 +76,9 @@ public: } // Creation - virtual void create(int dimx, int dimy, int nBpp, bool bUseDDraw = false); + virtual void create(int dimx, int dimy, int nBpp); virtual void destroy(); - // Buffer access - void lock(); - void unlock(); - // These are valid only if the buffer is locked operator byte *(); operator void *(); @@ -321,11 +316,11 @@ protected: public: RMGfxSourceBuffer16(bool bUseTrasp = false); - RMGfxSourceBuffer16(int dimx, int dimy, bool bUseDDraw = false); + RMGfxSourceBuffer16(int dimx, int dimy); virtual ~RMGfxSourceBuffer16(); // Initialization - void create(int dimx, int dimy, bool bUseDDraw = false); + void create(int dimx, int dimy); int getBpp(); virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); @@ -366,11 +361,11 @@ protected: public: RMGfxSourceBuffer8(bool bTrasp0 = true); - RMGfxSourceBuffer8(int dimx, int dimy, bool bUseDDraw = false); + RMGfxSourceBuffer8(int dimx, int dimy); virtual ~RMGfxSourceBuffer8(); // Initialization - void create(int dimx, int dimy, bool bUseDDraw = false); + void create(int dimx, int dimy); int getBpp(); virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); @@ -533,10 +528,10 @@ public: class RMGfxSourceBuffer4 : public RMGfxSourceBufferPal { public: RMGfxSourceBuffer4(); - RMGfxSourceBuffer4(int dimx, int dimy, bool bUseDDraw = false); + RMGfxSourceBuffer4(int dimx, int dimy); // Initialization - void create(int dimx, int dimy, bool bUseDDraw = false); + void create(int dimx, int dimy); int getBpp(); virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); @@ -618,7 +613,7 @@ public: class RMGfxWoodyBuffer: public RMGfxSourceBuffer16, public RMGfxTargetBuffer { public: RMGfxWoodyBuffer(); - RMGfxWoodyBuffer(int dimx, int dimy, bool bUseDDraw = false); + RMGfxWoodyBuffer(int dimx, int dimy); virtual ~RMGfxWoodyBuffer(); virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 5431a0ca7d..25aaa625f4 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -500,9 +500,6 @@ void RMGfxEngine::init() { GLOBALS._gfxEngine = this; mpalInstallItemIrq(itemIrq); - // Initialize the input - _input.init(); - // Initialize the mouse pointer _point.init(); @@ -530,13 +527,6 @@ void RMGfxEngine::close() { _inv.close(); _tony.close(); _point.close(); - _input.close(); -} - -void RMGfxEngine::switchFullscreen(bool bFull) { -} - -void RMGfxEngine::GDIControl(bool bCon) { } void RMGfxEngine::enableInput() { diff --git a/engines/tony/gfxengine.h b/engines/tony/gfxengine.h index 8be09ddd8b..7206496aaa 100644 --- a/engines/tony/gfxengine.h +++ b/engines/tony/gfxengine.h @@ -92,12 +92,6 @@ public: // Closes the graphics engine void close(); - // Warns when changing - void switchFullscreen(bool bFull); - - // Warn that we are guided by the GDI - void GDIControl(bool bCon); - // Warns when entering or exits the options menu void openOptionScreen(CORO_PARAM, int type); diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp index 1e79032af2..88bc3f4092 100644 --- a/engines/tony/input.cpp +++ b/engines/tony/input.cpp @@ -101,12 +101,6 @@ void RMInput::poll() { } } -void RMInput::init() { -} - -void RMInput::close() { -} - bool RMInput::mouseLeft() { return _leftButton; } diff --git a/engines/tony/input.h b/engines/tony/input.h index d9b6dc7e89..55b067ec43 100644 --- a/engines/tony/input.h +++ b/engines/tony/input.h @@ -46,26 +46,11 @@ private: // Keyboard related fields bool _keyDown[350]; -private: - /** - * Deinitialize DirectInput - */ - void DIClose(); public: RMInput(); ~RMInput(); - /** - * Class initialization - */ - void init(/*uint32 hInst*/); - - /** - * Closes the class - */ - void close(); - /** * Polling (must be performed once per frame) */ diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index bb174dfbb1..b0ca074c16 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -610,9 +610,6 @@ void TonyEngine::grabThumbnail() { _window.grabThumbnail(_curThumbnail); } -void TonyEngine::optionScreen() { -} - void TonyEngine::openInitLoadMenu(CORO_PARAM) { _theEngine.openOptionScreen(coroParam, 1); } @@ -706,15 +703,6 @@ void TonyEngine::close() { delete[] _curThumbnail; } -void TonyEngine::switchFullscreen(bool bFull) { - _window.switchFullscreen(bFull); - _theEngine.switchFullscreen(bFull); -} - -void TonyEngine::GDIControl(bool bCon) { - _theEngine.GDIControl(bCon); -} - void TonyEngine::freezeTime() { _bTimeFreezed = true; _nTimeFreezed = getTime() - _startTime; diff --git a/engines/tony/tony.h b/engines/tony/tony.h index f8358b15a7..9a25f2ce35 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -167,20 +167,12 @@ public: Common::Error loadGameState(int slot); Common::Error saveGameState(int slot, const Common::String &desc); - /** - * Warn when are being controlled by the GDI - */ - void GDIControl(bool bCon); - void play(); void close(); void abortGame(); void getDataDirectory(DataDir dir, char *path); - void switchFullscreen(bool bFull); - void optionScreen(); - void showLocation() { _bDrawLocation = true; } diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index 9cf8167030..c412a53655 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -109,13 +109,6 @@ void RMWindow::repaint() { g_system->updateScreen(); } -bool RMWindow::lock() { - return true; -} - -void RMWindow::unlock() { -} - /** * Wipes an area of the screen */ diff --git a/engines/tony/window.h b/engines/tony/window.h index 25ec349196..4dfd63a3d8 100644 --- a/engines/tony/window.h +++ b/engines/tony/window.h @@ -53,8 +53,6 @@ public: class RMWindow { private: - bool lock(); - void unlock(); void plotSplices(const byte *lpBuf, const Common::Point ¢er, int x, int y); void plotLines(const byte *lpBuf, const Common::Point ¢er, int x, int y); @@ -83,7 +81,6 @@ public: * Initialization */ void init(/*HINSTANCE hInst*/); - void initDirectDraw(); void close(); /** @@ -91,11 +88,6 @@ public: */ void repaint(); - /** - * Switch between windowed and fullscreen - */ - void switchFullscreen(bool bFull) {} - /** * Reads the next frame */ -- cgit v1.2.3 From 6805c2cec20cb41f20abdbd4ecb8b2dfa52f2143 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Mon, 27 Aug 2012 13:07:34 +0200 Subject: TONY: Translate some minor Italian comments --- engines/tony/mpal/loadmpc.cpp | 2 +- engines/tony/mpal/loadmpc.h | 2 +- engines/tony/mpal/mpaldll.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index a0dff2927a..ed4ad9d228 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -39,7 +39,7 @@ namespace Tony { namespace MPAL { /****************************************************************************\ -* Funzioni statiche +* Static functions \****************************************************************************/ static bool compareCommands(struct command *cmd1, struct command *cmd2) { diff --git a/engines/tony/mpal/loadmpc.h b/engines/tony/mpal/loadmpc.h index 83463f0092..b805b1e7a1 100644 --- a/engines/tony/mpal/loadmpc.h +++ b/engines/tony/mpal/loadmpc.h @@ -34,7 +34,7 @@ namespace Tony { namespace MPAL { /****************************************************************************\ -* Prototipi di funzione +* Function prototypes \****************************************************************************/ /** diff --git a/engines/tony/mpal/mpaldll.h b/engines/tony/mpal/mpaldll.h index fe1eb2b34a..e637362bdf 100644 --- a/engines/tony/mpal/mpaldll.h +++ b/engines/tony/mpal/mpaldll.h @@ -69,7 +69,7 @@ namespace MPAL { /****************************************************************************\ -* Strutture +* Structures \****************************************************************************/ #include "common/pack-start.h" -- cgit v1.2.3 From 28681a32eeaeba6029d6040da89bd810a0dd2b35 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Mon, 27 Aug 2012 23:41:23 +0200 Subject: TONY: Remove more unused bits. --- engines/tony/window.cpp | 3 --- engines/tony/window.h | 11 ----------- 2 files changed, 14 deletions(-) (limited to 'engines') diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index c412a53655..9385db27c7 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -57,9 +57,6 @@ void RMWindow::init() { Graphics::PixelFormat pixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0); initGraphics(RM_SX, RM_SY, true, &pixelFormat); - // Initialize FPS counters - fps = lastfcount = fcount = lastsecond = 0; - _bGrabScreenshot = false; _bGrabThumbnail = false; _bGrabMovie = false; diff --git a/engines/tony/window.h b/engines/tony/window.h index 4dfd63a3d8..9aaca16d3e 100644 --- a/engines/tony/window.h +++ b/engines/tony/window.h @@ -35,10 +35,6 @@ namespace Tony { -typedef uint32 HWND; -struct DDSURFACEDESC { -}; - class RMSnapshot { private: // Buffer used to convert to RGB @@ -57,10 +53,6 @@ private: void plotLines(const byte *lpBuf, const Common::Point ¢er, int x, int y); protected: - int fps, fcount; - int lastsecond, lastfcount; - - int mskRed, mskGreen, mskBlue; bool _wiping; bool _showDirtyRects; @@ -98,9 +90,6 @@ public: */ void grabThumbnail(uint16 *buf); - int getFps() const { - return fps; - } void showDirtyRects(bool v) { _showDirtyRects = v; } }; -- cgit v1.2.3 From 3570a0153dfa1034fc8acece5f755038487a5886 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Tue, 28 Aug 2012 09:19:10 +0200 Subject: TONY: Improve Take/ReleaseOwnership. This releases all held 'mutexes' when processes die, and keeps track of the lock count too, just in case. --- engines/tony/custom.cpp | 49 ++++++++++++++++++++++++++++++++++++++++++++---- engines/tony/globals.cpp | 1 - engines/tony/globals.h | 10 +++++++++- engines/tony/tony.cpp | 1 + 4 files changed, 55 insertions(+), 6 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index fcb304c623..3031fc342b 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -2052,12 +2052,39 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr */ DECLARE_CUSTOM_FUNCTION(TakeOwnership)(CORO_PARAM, uint32 num, uint32, uint32, uint32) { - // The event is operating as a mutex, so if the event is already set, wait until it's reset - CoroScheduler.waitForSingleObject(coroParam, GLOBALS._mut[num], CORO_INFINITE); + CORO_BEGIN_CONTEXT; + CORO_END_CONTEXT(_ctx); + + CORO_BEGIN_CODE(_ctx); + + if (GLOBALS._mut[num]._ownerPid != (uint32)CoroScheduler.getCurrentPID()) { + // The mutex is currently owned by a different process. + // Wait for the event to be signalled, which means the mutex is free. + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, GLOBALS._mut[num]._eventId, CORO_INFINITE); + GLOBALS._mut[num]._ownerPid = (uint32)CoroScheduler.getCurrentPID(); + } + + GLOBALS._mut[num]._lockCount++; + + CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(ReleaseOwnership)(CORO_PARAM, uint32 num, uint32, uint32, uint32) { - CoroScheduler.setEvent(GLOBALS._mut[num]); + if (!GLOBALS._mut[num]._lockCount) { + warning("ReleaseOwnership tried to release mutex %d, which isn't held", num); + return; + } + + if (GLOBALS._mut[num]._ownerPid != (uint32)CoroScheduler.getCurrentPID()) + error("ReleaseOwnership tried to release mutex %d, which is held by a different process", num); + + GLOBALS._mut[num]._lockCount--; + if (!GLOBALS._mut[num]._lockCount) { + GLOBALS._mut[num]._ownerPid = 0; + + // Signal the event, to wake up processes waiting for the lock. + CoroScheduler.setEvent(GLOBALS._mut[num]._eventId); + } } /* @@ -2524,6 +2551,19 @@ ASSIGN(201, MustSkipIdleEnd); END_CUSTOM_FUNCTION_MAP() +void processKilledCallback(Common::PROCESS *p) { + for (uint i = 0; i < 10; i++) + if (GLOBALS._mut[i]._ownerPid == p->pid) { + // Handle scripts which don't call ReleaseOwnership, such as + // the one in loc37's vEnter when Tony is chasing the mouse. + debug(DEBUG_BASIC, "Force-releasing mutex %d after process died", i); + + GLOBALS._mut[i]._ownerPid = 0; + GLOBALS._mut[i]._lockCount = 0; + CoroScheduler.setEvent(GLOBALS._mut[i]._eventId); + } +} + void setupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation *loc, RMInventory *inv, RMInput *input) { GLOBALS._tony = tony; GLOBALS._pointer = ptr; @@ -2549,8 +2589,9 @@ void setupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation GLOBALS._bAlwaysDisplay = false; int i; + CoroScheduler.setResourceCallback(processKilledCallback); for (i = 0; i < 10; i++) - GLOBALS._mut[i] = CoroScheduler.createEvent(false, true); + GLOBALS._mut[i]._eventId = CoroScheduler.createEvent(false, true); for (i = 0; i < 200; i++) GLOBALS._ambiance[i] = 0; diff --git a/engines/tony/globals.cpp b/engines/tony/globals.cpp index ba2698a50b..dd35d8c5ec 100644 --- a/engines/tony/globals.cpp +++ b/engines/tony/globals.cpp @@ -67,7 +67,6 @@ Globals::Globals() { _curSoundEffect = 0; _bFadeOutStop = false; - Common::fill(&_mut[0], &_mut[10], 0); _bSkipIdle = false; _hSkipIdle = 0; _lastMusic = 0; diff --git a/engines/tony/globals.h b/engines/tony/globals.h index 02bd79eee7..483ced1817 100644 --- a/engines/tony/globals.h +++ b/engines/tony/globals.h @@ -155,6 +155,14 @@ typedef CFCALL *LPCFCALL; typedef LPCFCALL *LPLPCFCALL; +struct CoroutineMutex { + CoroutineMutex() : _eventId(0), _ownerPid(0), _lockCount(0) { } + + uint32 _eventId; + uint32 _ownerPid; + uint32 _lockCount; +}; + /****************************************************************************\ * Global variables \****************************************************************************/ @@ -236,7 +244,7 @@ public: RMTony::CharacterTalkType _nTonyNextTalkType; RMPoint _startLocPos[256]; - uint32 _mut[10]; + CoroutineMutex _mut[10]; bool _bSkipIdle; uint32 _hSkipIdle; diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index b0ca074c16..b9d12beb11 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -89,6 +89,7 @@ TonyEngine::~TonyEngine() { // Reset the coroutine scheduler CoroScheduler.reset(); + CoroScheduler.setResourceCallback(NULL); delete _debugger; } -- cgit v1.2.3 From e6bd426398c75fb6e268e58508b19307ab0c53eb Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Tue, 28 Aug 2012 09:47:21 +0200 Subject: TONY: Rename curDialog to g_curDialog. --- engines/tony/custom.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 3031fc342b..c73c7dec36 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -1779,7 +1779,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes * Dialogs */ -int curDialog; +int g_curDialog; DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg, uint32, uint32) { CORO_BEGIN_CONTEXT; @@ -1801,7 +1801,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg if (nPers != 0 && GLOBALS._isMChar[nPers] && GLOBALS._mCharacter[nPers]._bAlwaysBack) _ctx->bIsBack = true; - _ctx->curVoc = SearchVoiceHeader(curDialog, nMsg); + _ctx->curVoc = SearchVoiceHeader(g_curDialog, nMsg); _ctx->voice = NULL; if (_ctx->curVoc) { @@ -1978,7 +1978,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr CORO_BEGIN_CODE(_ctx); - curDialog = nDialog; + g_curDialog = nDialog; // Call MPAL to start the dialog mpalQueryDoDialog(nDialog, nStartGroup); -- cgit v1.2.3 From fbf771ea55b321e5f7914eb989d82bdd2a579f98 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Tue, 28 Aug 2012 10:08:37 +0200 Subject: TONY: Fix stringLen for empty strings. --- engines/tony/font.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'engines') diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 91dd8c0c39..41dfa1f7bf 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -122,6 +122,9 @@ void RMFont::close() { int RMFont::stringLen(const Common::String &text) { uint len, i; + if (text.empty()) + return letterLength('\0'); + len = 0; for (i = 0; i < text.size() - 1; i++) len += letterLength(text[i], text[i + 1]); -- cgit v1.2.3 From 18b1f6d7c6e5a70d2073178cffbde53236225b4b Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Tue, 28 Aug 2012 13:33:24 +0200 Subject: TONY: Remove unused data dumping code. --- engines/tony/mpal/mpal.cpp | 785 --------------------------------------------- 1 file changed, 785 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 76ca8a5db3..16d8a3213b 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -2120,791 +2120,6 @@ int mpalLoadState(byte *buf) { return GLOBALS._nVars * sizeof(MPALVAR) + 4; } -bool bDontOutput; - -struct MsgCommentsStruct { - uint16 wStart; - uint16 wEnd; - const char *pComment; -}; -const MsgCommentsStruct MsgComments[] = { - { 10, 16, "###" }, - { 560, 563, "@@@ BUTCH & DUDLEY:" }, - { 551, 553, "@@@ JACK'S LETTER (JACK'S VOICE):" }, - { 679, 679, "@@@ OFF-SCREEN VOICE:" }, - { 799, 799, "###" }, - { 830, 838, "RE-HASHING (FROM MACBETH):" }, - { 890, 894, "@@@ BEARDED LADY FROM WITHIN HER ROOM:" }, - { 1175, 1175, "###" }, - { 1210, 1210, "###" }, - { 1347, 1349, "###" }, - { 1175, 1175, "###" }, - { 1342, 1343, "###" }, - { 1742, 1742, "@@@ OFF-SCREEN VOICE:" }, - { 1749, 1749, "###" }, - { 1759, 1759, "###" }, - { 2165, 2166, "@@@ MORTIMER:" }, - { 2370, 2372, "@@@ ELECTRONIC VOICE FROM AN AUTOMATIC PICTURE MACHINE:" }, - { 2580, 2589, "@@@ BIFF:" }, - { 2590, 2593, "@@@ BARTENDER:" }, - { 2596, 2596, "@@@ SAD PIRATE:" }, - { 2760, 2767, "@@@ EGGHEAD:" }, - { 2959, 2959, "@@@ MONSTROUS VOICE FROM BEHIND A LOCKED DOOR:" }, - { 3352, 3352, "@@@ POLLY:" }, - { 3378, 3379, "@@@ POLLY:" }, - { 3461, 3469, "@@@ RANDALL:" }, - { 3571, 3574, "@@@ CAPTAIN'S JOURNAL (CAPTAIN'S VOICE):" }, - { 3646, 3646, "NOTE: THIS SENTENCE ENDS THE STORY TOLD IN SENTENCES 03640 - 03643:" }, - { 3647, 3648, "TONY SPEAKS TRYING TO IMITATE CAPTAIN CORNELIUS' VOICE:" }, - { 3670, 3671, "###" }, - { 3652, 3652, "###" }, - { 3656, 3657, "@@@ GATEKEEPER:" }, - { 3658, 3659, "@@@ GATEKEEPER (FAR AWAY):" }, - { 3790, 3795, "@@@ GATEKEEPER:" }, - { 3798, 3799, "@@@ OFF-SCREEN VOICE:" }, - { 4384, 4384, "###" }, - { 4394, 4395, "###" }, - { 4780, 4780, "###" }, - { 5089, 5089, "TONY PLAYING SOMEONE ELSE, WITH A DEEPER TONE:" }, - { 5090, 5090, "NORMAL TONY:" }, - { 5091, 5091, "TONY PLAYING SOMEONE ELSE, WITH A DEEPER TONE:" }, - { 5262, 5262, "@@@ OFF-SCREEN VOICE" }, - { 5276, 5277, "###" }, - { 5326, 5326, "###" }, - { 5472, 5472, "LYRICS FROM THE SONG \"I AM ONE\", BY SMASHING PUMPKINS:" }, - { 5488, 5488, "LYRICS FROM THE SONG \"I AM ONE\", BY SMASHING PUMPKINS:" }, - { 5652, 5653, "###" }, -//bernie { 11000, 15000, "###" }, - { 11000, 11111, "###" }, - - - { 0, 0, NULL } -}; - -void outputStartMsgComment(uint16 wNum, Common::OutSaveFile *f) { - int i; - - for (i = 0; MsgComments[i].wStart != 0; i++) - if (MsgComments[i].wStart == wNum) { - debugC(DEBUG_BASIC, kTonyDebugMPAL, "Start: %d\n", wNum); - - f->writeString("
%s %s %s
\n

\n

\n"); - - if (strcmp(MsgComments[i].pComment, "###") != 0 && strncmp(MsgComments[i].pComment, "@@@", 3) != 0) { - f->writeString(Common::String::format("%s\n", MsgComments[i].pComment)); - f->writeString("

\n

\n\n"); - } else - bDontOutput = true; - return; - } -} - -void OutputEndMsgComment(uint16 wNum, Common::OutSaveFile *f) { - int i; - - for (i = 0; MsgComments[i].wEnd != 0; i++) - if (MsgComments[i].wEnd == wNum) { - debugC(DEBUG_BASIC, kTonyDebugMPAL, "End: %d\n", wNum); - - if (strcmp(MsgComments[i].pComment, "###") != 0 && strncmp(MsgComments[i].pComment, "@@@", 3) != 0) { - f->writeString("
\n

\n"); - } else - bDontOutput = false; - - f->writeString("

\n

\n\n"); - return; - } -} - - -int OutputStartOther(uint16 wNum, Common::OutSaveFile *f) { - int i; - - for (i = 0; MsgComments[i].wStart != 0; i++) - if (MsgComments[i].wStart <= wNum && MsgComments[i].wEnd >= wNum) { - if (strncmp(MsgComments[i].pComment, "@@@", 3) == 0) { - if (MsgComments[i].wStart == wNum) { - f->writeString(Common::String::format("%s\n", MsgComments[i].pComment + 4)); - f->writeString("

\n

\n

\n"); - } - - return 1; - } - } - - return 0; -} - -void outputEndOther(uint16 wNum, Common::OutSaveFile *f) { - int i; - - for (i = 0; MsgComments[i].wStart != 0; i++) - if (MsgComments[i].wEnd == wNum && strncmp(MsgComments[i].pComment, "@@@", 3) == 0) { - f->writeString("
\n

\n"); - break; - } -} - -void mpalDumpMessages() { - int i, j; - char *lpMessage; - char *p; - char *lpPeriods[30]; - char fname[64]; - char frase[2048]; - int nPeriods; - Common::OutSaveFile *f, *v1; - - v1 = g_system->getSavefileManager()->openForSaving("voicelist.txt"); - - LockMsg(); - - bDontOutput = false; - - debugC(DEBUG_BASIC, kTonyDebugMPAL, "Dumping MESSAGES.HTM...\n"); - - f = g_system->getSavefileManager()->openForSaving("Messages.htm"); - f->writeString("\n\n\n"); - - for (i = 0; i < GLOBALS._nMsgs; i++) { - lpMessage = (char *)globalLock(GLOBALS._lpmmMsgs[i]._hText); - if (*lpMessage != '\0') { - // bernie: debug - /*if (GLOBALS.lpmmMsgs[i].wNum == 1950) { - int a = 1; - }*/ - - nPeriods = 1; - p = lpPeriods[0] = lpMessage; - - outputStartMsgComment(GLOBALS._lpmmMsgs[i]._wNum, f); - - while (1) { - // Find the end of the current period - while (*p != '\0') - p++; - - // If there is another '\0' at the end of the message, then finish - p++; - if (*p == '\0') - break; - - // Otherwise there is another line, so remember the next one's start - lpPeriods[nPeriods++] = p; - } - - // Now make a loop over all the periods - for (j = 0; j < nPeriods; j++) { - if (nPeriods == 1) - sprintf(fname, "000-%05d.WAV", GLOBALS._lpmmMsgs[i]._wNum); - else - sprintf(fname, "000-%05d-%02d.WAV", GLOBALS._lpmmMsgs[i]._wNum,j); - - strcpy(frase, lpPeriods[j]); - - while ((p = strchr(frase,'^')) != NULL) - *p = '\"'; - - p = frase; - while (*p == ' ') - p++; - if (*p == '\0') - continue; - - if (!bDontOutput) { - v1->writeString(Common::String::format("%s\n", fname)); - f->writeString("\t\n"); - f->writeString(Common::String::format("\t\t\n", fname)); - f->writeString(Common::String::format("\t\t\n", frase)); - f->writeString("\t\n"); - } - } - - OutputEndMsgComment(GLOBALS._lpmmMsgs[i]._wNum, f); - - globalUnlock(GLOBALS._lpmmMsgs[i]._hText); - } - } - - f->writeString("
%s %s
\n\n\n"); - - f->finalize(); - v1->finalize(); - delete f; - delete v1; - - UnlockMsg(); -} - -void mpalDumpOthers() { - int i,j; - char *lpMessage; - char *p; - char *lpPeriods[30]; - char fname[64]; - char frase[2048]; - int nPeriods; - - Common::OutSaveFile *f, *v1; - - v1 = g_system->getSavefileManager()->openForSaving("voicelist.txt"); - f = g_system->getSavefileManager()->openForSaving("Others.htm"); - LockMsg(); - - bDontOutput = false; - - debugC(DEBUG_BASIC, kTonyDebugMPAL, "Dumping OTHERS.HTM...\n"); - - f->writeString("\n\n"); - - for (i = 0; i < GLOBALS._nMsgs; i++) { - lpMessage = (char *)globalLock(GLOBALS._lpmmMsgs[i]._hText); - if (*lpMessage != '\0') { - nPeriods = 1; - p = lpPeriods[0] = lpMessage; - - if (OutputStartOther(GLOBALS._lpmmMsgs[i]._wNum, f)) { - while (1) { - // Find the end of the current period - while (*p != '\0') - p++; - - // If there is another '0' at the end, then the message is finished - p++; - if (*p == '\0') - break; - - // Remember the start of the next line - lpPeriods[nPeriods++] = p; - } - - // Now loop over all the periods - for (j = 0; j < nPeriods; j++) { - if (nPeriods == 1) - sprintf(fname, "000-%05d.WAV", GLOBALS._lpmmMsgs[i]._wNum); - else - sprintf(fname, "000-%05d-%02d.WAV", GLOBALS._lpmmMsgs[i]._wNum,j); - - strcpy(frase,lpPeriods[j]); - - while ((p = strchr(frase, '^')) != NULL) - *p = '\"'; - - p = frase; - while (*p == ' ') - p++; - if (*p == '\0') - continue; - - if (!bDontOutput) { - v1->writeString(Common::String::format("%s\n", fname)); - f->writeString("\t\n"); - f->writeString(Common::String::format("\t\t %s \n", fname)); - f->writeString(Common::String::format("\t\t %s \n", frase)); - f->writeString("\t\n"); - } - } - } - - outputEndOther(GLOBALS._lpmmMsgs[i]._wNum, f); - - globalUnlock(GLOBALS._lpmmMsgs[i]._hText); - } - } - - f->writeString("\n\n"); - - f->finalize(); - v1->finalize(); - - delete f; - delete v1; - UnlockMsg(); -} - - -#if 0 // English names -const char *DLG10[] = { "Tony", NULL }; -const char *DLG51[] = { "Tony", "Butch", "Dudley" }; -const char *DLG52[] = { "Tony", NULL }; -const char *DLG61[] = { "Tony", "Old lady 1", NULL }; -const char *DLG71[] = { "Tony", "Timothy", "Convict", NULL, NULL, "Jack (with microphone)", "Old lady 1", NULL }; -const char *DLG90[] = { "Tony", "Bearded lady", NULL }; -const char *DLG110[] = { "Tony", "Lorenz", NULL }; -const char *DLG111[] = { "Tony", "Lorenz", NULL }; -const char *DLG130[] = { "Tony", "Piranha", NULL }; -const char *DLG150[] = { "Tony", "Rufus", "Snowman", NULL }; -const char *DLG151[] = { "Tony", "Rufus", "Snowman", NULL }; -const char *DLG152[] = { "Tony", "Rufus", "Snowman", NULL }; -const char *DLG153[] = { "Tony", "Rufus", "Snowman", NULL }; -const char *DLG154[] = { "Tony", "Rufus", "Snowman", NULL }; -const char *DLG160[] = { "Tony", "Shmiley", NULL }; -const char *DLG161[] = { "Tony", "Shmiley", NULL }; -const char *DLG162[] = { "Tony", "Shmiley", NULL }; -const char *DLG163[] = { "Tony", "Shmiley", NULL }; -const char *DLG180[] = { "Tony", "Beast", NULL }; -const char *DLG190[] = { "Tony", "Beast", NULL }; -const char *DLG191[] = { "Tony", "Beast", NULL }; -const char *DLG201[] = { "Tony", NULL }; -const char *DLG210[] = { "Tony", "Mortimer", NULL }; -const char *DLG211[] = { "Tony", "Mortimer", NULL }; -const char *DLG212[] = { "Tony", "Mortimer", NULL }; -const char *DLG240[] = { "Tony", "Isabella", NULL }; -const char *DLG250[] = { "Tony", "Bartender", "Sad pirate", "Anchorman", "Biff", NULL }; -const char *DLG251[] = { "Tony", "Bartender", "Sad pirate", "Anchorman", "Biff", NULL }; -const char *DLG260[] = { "Tony", "Captain", "Captain (tale)", NULL }; -const char *DLG270[] = { "Tony", "Egghead", NULL }; -const char *DLG271[] = { "Tony", "Egghead", NULL }; -const char *DLG272[] = { "Tony", "Egghead", NULL }; -const char *DLG290[] = { "Tony", "Old lady 2", NULL }; -const char *DLG310[] = { "Tony", "Wally", NULL }; -const char *DLG330[] = { "Tony", "Polly", "Captain (off scene)", NULL }; -const char *DLG340[] = { "Tony", "Randall", NULL }; -const char *DLG360[] = { "Tony", NULL }; -const char *DLG361[] = { "Tony", NULL }; -const char *DLG370[] = { "Tony", "Gatekeeper", NULL }; -const char *DLG371[] = { "Tony", "Gatekeeper", NULL }; -const char *DLG372[] = { "Tony", "Gatekeeper", NULL }; -const char *DLG373[] = { "Tony", "Gatekeeper", NULL }; -const char *DLG380[] = { "Tony", NULL }; -const char *DLG410[] = { "Tony", "Gwendel", NULL }; -const char *DLG430[] = { "Tony", "Harold", "Chuck", "Pigeons", "Housekeeper (off scene)", NULL }; -const char *DLG460[] = { "Tony", NULL }; -const char *DLG470[] = { "Tony", "Housekeeper", "Mirror", NULL }; -const char *DLG471[] = { "Tony", "Housekeeper", "Mirror", NULL }; -const char *DLG472[] = { "Tony", "Housekeeper", "Mirror", NULL }; -const char *DLG473[] = { "Tony", "Housekeeper", "Mirror", NULL }; -const char *DLG474[] = { "Tony", "Housekeeper", "Mirror", NULL }; -const char *DLG480[] = { "Tony", "Pin-up", NULL }; -const char *DLG490[] = { "Tony", "Gwendel", NULL }; -const char *DLG530[] = { "Tony", "Harold", "Chuck", NULL }; -const char *DLG550[] = { "Tony", "Mr. Wishing Well", "Tony (from the top of the well)", NULL }; -const char *DLG560[] = { "Tony", "Superintendent", NULL }; -const char *DLG590[] = { "Tony", "Pantagruel", NULL }; -const char *DLG600[] = { "Tony", "Jack", "Jack", NULL, "Jack", NULL, NULL, NULL, "Storyteller", "Mr. Wishing Well", NULL }; -#endif - -#if 0 // Polish names -const char *DLG10[] = { "Tony", NULL }; -const char *DLG51[] = { "Tony", "Butch", "Dudley" }; -const char *DLG52[] = { "Tony", NULL }; -const char *DLG61[] = { "Tony", "Staruszka 1", NULL }; -const char *DLG71[] = { "Tony", "Timothy", "Skazaniec", NULL, NULL, "ebster (przez mikrofon)", "Staruszka 1", NULL }; -const char *DLG90[] = { "Tony", "Kobieta z Brod", NULL }; -const char *DLG110[] = { "Tony", "Lorenz", NULL }; -const char *DLG111[] = { "Tony", "Lorenz", NULL }; -const char *DLG130[] = { "Tony", "Pirania", NULL }; -const char *DLG150[] = { "Tony", "Rufus", "Bawan", NULL }; -const char *DLG151[] = { "Tony", "Rufus", "Bawan", NULL }; -const char *DLG152[] = { "Tony", "Rufus", "Bawan", NULL }; -const char *DLG153[] = { "Tony", "Rufus", "Bawan", NULL }; -const char *DLG154[] = { "Tony", "Rufus", "Bawan", NULL }; -const char *DLG160[] = { "Tony", "miechozol", NULL }; -const char *DLG161[] = { "Tony", "miechozol", NULL }; -const char *DLG162[] = { "Tony", "miechozol", NULL }; -const char *DLG163[] = { "Tony", "miechozol", NULL }; -const char *DLG180[] = { "Tony", "Wycz", NULL }; -const char *DLG190[] = { "Tony", "Wycz", NULL }; -const char *DLG191[] = { "Tony", "Wycz", NULL }; -const char *DLG201[] = { "Tony", NULL }; -const char *DLG210[] = { "Tony", "Mortimer (Okropny)", NULL }; -const char *DLG211[] = { "Tony", "Mortimer (Okropny)", NULL }; -const char *DLG212[] = { "Tony", "Mortimer (Okropny)", NULL }; -const char *DLG240[] = { "Tony", "Isabella", NULL }; -const char *DLG250[] = { "Tony", "Barman", "Smutny Pirat", "Wodzirej", "Biff", NULL }; -const char *DLG251[] = { "Tony", "Barman", "Smutny Pirat", "Wodzirej", "Biff", NULL }; -const char *DLG260[] = { "Tony", "Kapitan", "Captain (opowie)", NULL }; -const char *DLG270[] = { "Tony", "Jajogowy", NULL }; -const char *DLG271[] = { "Tony", "Jajogowy", NULL }; -const char *DLG272[] = { "Tony", "Jajogowy", NULL }; -const char *DLG290[] = { "Tony", "Staruszka 2", NULL }; -const char *DLG310[] = { "Tony", "Wally", NULL }; -const char *DLG330[] = { "Tony", "Polly", "Kapitan (zza sceny)", NULL }; -const char *DLG340[] = { "Tony", "Randall", NULL }; -const char *DLG360[] = { "Tony", NULL }; -const char *DLG361[] = { "Tony", NULL }; -const char *DLG370[] = { "Tony", "Stranik", NULL }; -const char *DLG371[] = { "Tony", "Stranik", NULL }; -const char *DLG372[] = { "Tony", "Stranik", NULL }; -const char *DLG373[] = { "Tony", "Stranik", NULL }; -const char *DLG380[] = { "Tony", NULL }; -const char *DLG410[] = { "Tony", "Gwendel", NULL }; -const char *DLG430[] = { "Tony", "Harold", "Chuck", "Pigeons", "Gospodyni (zza sceny)", NULL }; -const char *DLG460[] = { "Tony", NULL }; -const char *DLG470[] = { "Tony", "Gospodyni", "Mirror", NULL }; -const char *DLG471[] = { "Tony", "Gospodyni", "Mirror", NULL }; -const char *DLG472[] = { "Tony", "Gospodyni", "Mirror", NULL }; -const char *DLG473[] = { "Tony", "Gospodyni", "Mirror", NULL }; -const char *DLG474[] = { "Tony", "Gospodyni", "Mirror", NULL }; -const char *DLG480[] = { "Tony", "Pin-up", NULL }; -const char *DLG490[] = { "Tony", "Gwendel", NULL }; -const char *DLG530[] = { "Tony", "Harold", "Chuck", NULL }; -const char *DLG550[] = { "Tony", "Pan Studnia ycze", "Tony (nad studni)", NULL }; -const char *DLG560[] = { "Tony", "Inspektor", NULL }; -const char *DLG590[] = { "Tony", "Pantaloniarz", NULL }; -const char *DLG600[] = { "Tony", "ebster", "ebster", NULL, "ebster", NULL, NULL, NULL, "Narrator", "Pan Studnia ycze", NULL }; -#endif // Polish - - -#if 0 // Russian -const char *DLG10[] = { "呷辷", NULL }; -const char *DLG51[] = { "呷辷", "蒼", "釣粳" }; -const char *DLG52[] = { "呷辷", NULL }; -const char *DLG61[] = { "呷辷", "剪瑁齪袱 1", NULL }; -const char *DLG71[] = { "呷辷", "呎跪鱶", "暦黽粤迯", NULL, NULL, "剃繩 ( 跏褓銓鉈鉤)", "剪瑁齪袱 1", NULL }; -const char *DLG90[] = { "呷辷", "綜韲籥鰰 聽逋蓁", NULL }; -const char *DLG110[] = { "呷辷", "鮪鞳逍", NULL }; -const char *DLG111[] = { "呷辷", "鮪鞳逍", NULL }; -const char *DLG130[] = { "呷辷", "蒡琿", NULL }; -const char *DLG150[] = { "呷辷", "偕齣", "剄繝鈞蒻", NULL }; -const char *DLG151[] = { "呷辷", "偕齣", "剄繝鈞蒻", NULL }; -const char *DLG152[] = { "呷辷", "偕齣", "剄繝鈞蒻", NULL }; -const char *DLG153[] = { "呷辷", "偕齣", "剄繝鈞蒻", NULL }; -const char *DLG154[] = { "呷辷", "偕齣", "剄繝鈞蒻", NULL }; -const char *DLG160[] = { "呷辷", "懋珸謌", NULL }; -const char *DLG161[] = { "呷辷", "懋珸謌", NULL }; -const char *DLG162[] = { "呷辷", "懋珸謌", NULL }; -const char *DLG163[] = { "呷辷", "懋珸謌", NULL }; -const char *DLG180[] = { "呷辷", "恣粮礦", NULL }; -const char *DLG190[] = { "呷辷", "恣粮礦", NULL }; -const char *DLG191[] = { "呷辷", "恣粮礦", NULL }; -const char *DLG201[] = { "呷辷", NULL }; -const char *DLG210[] = { "呷辷", "野頏蓐辮", NULL }; -const char *DLG211[] = { "呷辷", "野頏蓐辮", NULL }; -const char *DLG212[] = { "呷辷", "野頏蓐辮", NULL }; -const char *DLG240[] = { "呷辷", "泌珀繼諤", NULL }; -const char *DLG250[] = { "呷辷", "操韭纃", "註齣鴉 闊鞐", "代糂蓍", "争", NULL }; -const char *DLG251[] = { "呷辷", "操韭纃", "註齣鴉 闊鞐", "代糂蓍", "争", NULL }; -const char *DLG260[] = { "呷辷", "圃闊鰰", "圃闊鰰 (鞐髑袱)", NULL }; -const char *DLG270[] = { "呷辷", "煢繝鉉鈞", NULL }; -const char *DLG271[] = { "呷辷", "煢繝鉉鈞", NULL }; -const char *DLG272[] = { "呷辷", "煢繝鉉鈞", NULL }; -const char *DLG290[] = { "呷辷", "剪瑁齪袱 2", NULL }; -const char *DLG310[] = { "呷辷", "嚴諡", NULL }; -const char *DLG330[] = { "呷辷", "鉉謌", "圃闊鰰 (艢 髢纃鉗)", NULL }; -const char *DLG340[] = { "呷辷", "傴辟琺", NULL }; -const char *DLG360[] = { "呷辷", NULL }; -const char *DLG361[] = { "呷辷", NULL }; -const char *DLG370[] = { "呷辷", "韆碚瑩辷", NULL }; -const char *DLG371[] = { "呷辷", "韆碚瑩辷", NULL }; -const char *DLG372[] = { "呷辷", "韆碚瑩辷", NULL }; -const char *DLG373[] = { "呷辷", "韆碚瑩辷", NULL }; -const char *DLG380[] = { "呷辷", NULL }; -const char *DLG410[] = { "呷辷", "窒纃粤譛", NULL }; -const char *DLG430[] = { "呷辷", "逐韲譛", "怙", "Pigeons", "Housekeeper (off scene)", NULL }; -const char *DLG460[] = { "呷辷", NULL }; -const char *DLG470[] = { "呷辷", "Housekeeper", "Mirror", NULL }; -const char *DLG471[] = { "呷辷", "Housekeeper", "Mirror", NULL }; -const char *DLG472[] = { "呷辷", "Housekeeper", "Mirror", NULL }; -const char *DLG473[] = { "呷辷", "Housekeeper", "Mirror", NULL }; -const char *DLG474[] = { "呷辷", "Housekeeper", "Mirror", NULL }; -const char *DLG480[] = { "呷辷", "Pin-up", NULL }; -const char *DLG490[] = { "呷辷", "窒纃粤譛", NULL }; -const char *DLG530[] = { "呷辷", "逐韲譛", "怙", NULL }; -const char *DLG550[] = { "呷辷", "虫髀鈔蓁 菩謗粤 聽諤辷", "呷辷 ( 矼頽蓁 褌謗糜)", NULL }; -const char *DLG560[] = { "呷辷", "沃琺辷 銛鞐逶", NULL }; -const char *DLG590[] = { "呷辷", "琿鰰竦譛", NULL }; -const char *DLG600[] = { "呷辷", "剃繩", "剃繩", NULL, "剃繩", NULL, NULL, NULL, "俥髑袱范蒻", "虫髀鈔蓁 菩謗粤 聽諤辷", NULL }; -#endif // Russian - - -#if 0 // Czech names -const char *DLG10[] = { "Tony", NULL }; -const char *DLG51[] = { "Tony", "Butch", "Dudley" }; -const char *DLG52[] = { "Tony", NULL }; -const char *DLG61[] = { "Tony", "Star pan 1", NULL }; -const char *DLG71[] = { "Tony", "Timothy", "Trestanec", NULL, NULL, "Jack (s mikrofonem)", "Star pan 1", NULL }; -const char *DLG90[] = { "Tony", "Vousat ena", NULL }; -const char *DLG110[] = { "Tony", "Lorenz", NULL }; -const char *DLG111[] = { "Tony", "Lorenz", NULL }; -const char *DLG130[] = { "Tony", "Piraa", NULL }; -const char *DLG150[] = { "Tony", "Rufus", "Snhulk", NULL }; -const char *DLG151[] = { "Tony", "Rufus", "Snhulk", NULL }; -const char *DLG152[] = { "Tony", "Rufus", "Snhulk", NULL }; -const char *DLG153[] = { "Tony", "Rufus", "Snhulk", NULL }; -const char *DLG154[] = { "Tony", "Rufus", "Snhulk", NULL }; -const char *DLG160[] = { "Tony", "Shmiley", NULL }; -const char *DLG161[] = { "Tony", "Shmiley", NULL }; -const char *DLG162[] = { "Tony", "Shmiley", NULL }; -const char *DLG163[] = { "Tony", "Shmiley", NULL }; -const char *DLG180[] = { "Tony", "Zv逖e", NULL }; -const char *DLG190[] = { "Tony", "Zv逖e", NULL }; -const char *DLG191[] = { "Tony", "Zv逖e", NULL }; -const char *DLG201[] = { "Tony", NULL }; -const char *DLG210[] = { "Tony", "Mortimer", NULL }; -const char *DLG211[] = { "Tony", "Mortimer", NULL }; -const char *DLG212[] = { "Tony", "Mortimer", NULL }; -const char *DLG240[] = { "Tony", "Isabella", NULL }; -const char *DLG250[] = { "Tony", "Barman", "Smutn pirt", "Modertor", "Biff", NULL }; -const char *DLG251[] = { "Tony", "Barman", "Smutn pirt", "Modertor", "Biff", NULL }; -const char *DLG260[] = { "Tony", "Kapitn", "Kapitn (pbh)", NULL }; -const char *DLG270[] = { "Tony", "Intelektul", NULL }; -const char *DLG271[] = { "Tony", "Intelektul", NULL }; -const char *DLG272[] = { "Tony", "Intelektul", NULL }; -const char *DLG290[] = { "Tony", "Star pan 2", NULL }; -const char *DLG310[] = { "Tony", "Wally", NULL }; -const char *DLG330[] = { "Tony", "Lra", "Kapitn (mimo scnu)", NULL }; -const char *DLG340[] = { "Tony", "Randall", NULL }; -const char *DLG360[] = { "Tony", NULL }; -const char *DLG361[] = { "Tony", NULL }; -const char *DLG370[] = { "Tony", "Strn", NULL }; -const char *DLG371[] = { "Tony", "Strn", NULL }; -const char *DLG372[] = { "Tony", "Strn", NULL }; -const char *DLG373[] = { "Tony", "Strn", NULL }; -const char *DLG380[] = { "Tony", NULL }; -const char *DLG410[] = { "Tony", "Gwendel", NULL }; -const char *DLG430[] = { "Tony", "Harold", "Chuck", "Pigeons", "Housekeeper (off scene)", NULL }; -const char *DLG460[] = { "Tony", NULL }; -const char *DLG470[] = { "Tony", "Housekeeper", "Mirror", NULL }; -const char *DLG471[] = { "Tony", "Housekeeper", "Mirror", NULL }; -const char *DLG472[] = { "Tony", "Housekeeper", "Mirror", NULL }; -const char *DLG473[] = { "Tony", "Housekeeper", "Mirror", NULL }; -const char *DLG474[] = { "Tony", "Housekeeper", "Mirror", NULL }; -const char *DLG480[] = { "Tony", "Pin-up", NULL }; -const char *DLG490[] = { "Tony", "Gwendel", NULL }; -const char *DLG530[] = { "Tony", "Harold", "Chuck", NULL }; -const char *DLG550[] = { "Tony", "Pan Studna pn", "Tony (z vrcholu studny)", NULL }; -const char *DLG560[] = { "Tony", "Sprvce", NULL }; -const char *DLG590[] = { "Tony", "Pantagruel", NULL }; -const char *DLG600[] = { "Tony", "Jack", "Jack", NULL, "Jack", NULL, NULL, NULL, "Vyprav跏", "Pan Studna pn", NULL }; -#endif // Czech names - -#if 1 // Deutsch names -const char *DLG10[] = { "Tony", NULL }; -const char *DLG51[] = { "Tony", "Butch", "Dudley" }; -const char *DLG52[] = { "Tony", NULL }; -const char *DLG61[] = { "Tony", "Alte Dame 1", NULL }; -const char *DLG71[] = { "Tony", "Timothy", "Strfling", NULL, NULL, "Jack (mit Mikrofon)", "Alte Dame 1", NULL }; -const char *DLG90[] = { "Tony", "Brtige Dame", NULL }; -const char *DLG110[] = { "Tony", "Lorenz", NULL }; -const char *DLG111[] = { "Tony", "Lorenz", NULL }; -const char *DLG130[] = { "Tony", "Piranha", NULL }; -const char *DLG150[] = { "Tony", "Rufus", "Schneemann", NULL }; -const char *DLG151[] = { "Tony", "Rufus", "Schneemann", NULL }; -const char *DLG152[] = { "Tony", "Rufus", "Schneemann", NULL }; -const char *DLG153[] = { "Tony", "Rufus", "Schneemann", NULL }; -const char *DLG154[] = { "Tony", "Rufus", "Schneemann", NULL }; -const char *DLG160[] = { "Tony", "Shmiley", NULL }; -const char *DLG161[] = { "Tony", "Shmiley", NULL }; -const char *DLG162[] = { "Tony", "Shmiley", NULL }; -const char *DLG163[] = { "Tony", "Shmiley", NULL }; -const char *DLG180[] = { "Tony", "Biest", NULL }; -const char *DLG190[] = { "Tony", "Biest", NULL }; -const char *DLG191[] = { "Tony", "Biest", NULL }; -const char *DLG201[] = { "Tony", NULL }; -const char *DLG210[] = { "Tony", "Mortimer", NULL }; -const char *DLG211[] = { "Tony", "Mortimer", NULL }; -const char *DLG212[] = { "Tony", "Mortimer", NULL }; -const char *DLG240[] = { "Tony", "Isabella", NULL }; -const char *DLG250[] = { "Tony", "Barmann", "Trauriger Pirat", "Chefanimateur", "Biff", NULL }; -const char *DLG251[] = { "Tony", "Barmann", "Trauriger Pirat", "Chefanimateur", "Biff", NULL }; -const char *DLG260[] = { "Tony", "Kapitn", "Kapitn (Erzhlung)", NULL }; -const char *DLG270[] = { "Tony", "Eierkopf", NULL }; -const char *DLG271[] = { "Tony", "Eierkopf", NULL }; -const char *DLG272[] = { "Tony", "Eierkopf", NULL }; -const char *DLG290[] = { "Tony", "Alte Dame 2", NULL }; -const char *DLG310[] = { "Tony", "Wally", NULL }; -const char *DLG330[] = { "Tony", "Polly", "Kapitn (im Off)", NULL }; -const char *DLG340[] = { "Tony", "Randall", NULL }; -const char *DLG360[] = { "Tony", NULL }; -const char *DLG361[] = { "Tony", NULL }; -const char *DLG370[] = { "Tony", "Pfrtner", NULL }; -const char *DLG371[] = { "Tony", "Pfrtner", NULL }; -const char *DLG372[] = { "Tony", "Pfrtner", NULL }; -const char *DLG373[] = { "Tony", "Pfrtner", NULL }; -const char *DLG380[] = { "Tony", NULL }; -const char *DLG410[] = { "Tony", "Gwendel", NULL }; -const char *DLG430[] = { "Tony", "Harold", "Chuck", "Pigeons", "Housekeeper (off scene)", NULL }; -const char *DLG460[] = { "Tony", NULL }; -const char *DLG470[] = { "Tony", "Housekeeper", "Mirror", NULL }; -const char *DLG471[] = { "Tony", "Housekeeper", "Mirror", NULL }; -const char *DLG472[] = { "Tony", "Housekeeper", "Mirror", NULL }; -const char *DLG473[] = { "Tony", "Housekeeper", "Mirror", NULL }; -const char *DLG474[] = { "Tony", "Housekeeper", "Mirror", NULL }; -const char *DLG480[] = { "Tony", "Pin-up", NULL }; -const char *DLG490[] = { "Tony", "Gwendel", NULL }; -const char *DLG530[] = { "Tony", "Harold", "Chuck", NULL }; -const char *DLG550[] = { "Tony", "Herr Wunschbrunnen", "Tony (ber dem Brunnen)", NULL }; -const char *DLG560[] = { "Tony", "Verwalter", NULL }; -const char *DLG590[] = { "Tony", "Pantagruel", NULL }; -const char *DLG600[] = { "Tony", "Jack", "Jack", NULL, "Jack", NULL, NULL, NULL, "Erzhler", "Herr Wunschbrunnen", NULL }; -#endif - - -#define HANDLE_DIALOG(num) \ -case num: \ - if (nPers >= (int)(sizeof(DLG##num) / sizeof(const char *)) || DLG##num[nPers] == NULL) \ - { \ - warning("ERROR: The character #%d does not exist in dialog %d!\n", nPers, nDlg); \ - return "ERROR"; \ - } \ - else \ - return DLG##num[nPers]; - - -const char *getPersonName(uint16 nDlg, int nPers) { - switch (nDlg) { - HANDLE_DIALOG(10); - HANDLE_DIALOG(51); - HANDLE_DIALOG(52); - HANDLE_DIALOG(61); - HANDLE_DIALOG(71); - HANDLE_DIALOG(90); - HANDLE_DIALOG(110); - HANDLE_DIALOG(111); - HANDLE_DIALOG(130); - HANDLE_DIALOG(150); - HANDLE_DIALOG(151); - HANDLE_DIALOG(152); - HANDLE_DIALOG(153); - HANDLE_DIALOG(154); - HANDLE_DIALOG(160); - HANDLE_DIALOG(161); - HANDLE_DIALOG(162); - HANDLE_DIALOG(163); - HANDLE_DIALOG(180); - HANDLE_DIALOG(190); - HANDLE_DIALOG(191); - HANDLE_DIALOG(201); - HANDLE_DIALOG(210); - HANDLE_DIALOG(211); - HANDLE_DIALOG(212); - HANDLE_DIALOG(240); - HANDLE_DIALOG(250); - HANDLE_DIALOG(251); - HANDLE_DIALOG(260); - HANDLE_DIALOG(270); - HANDLE_DIALOG(271); - HANDLE_DIALOG(272); - HANDLE_DIALOG(290); - HANDLE_DIALOG(310); - HANDLE_DIALOG(330); - HANDLE_DIALOG(340); - HANDLE_DIALOG(360); - HANDLE_DIALOG(361); - HANDLE_DIALOG(370); - HANDLE_DIALOG(371); - HANDLE_DIALOG(372); - HANDLE_DIALOG(373); - HANDLE_DIALOG(380); - HANDLE_DIALOG(410); - HANDLE_DIALOG(430); - HANDLE_DIALOG(460); - HANDLE_DIALOG(470); - HANDLE_DIALOG(471); - HANDLE_DIALOG(472); - HANDLE_DIALOG(473); - HANDLE_DIALOG(474); - HANDLE_DIALOG(480); - HANDLE_DIALOG(490); - HANDLE_DIALOG(530); - HANDLE_DIALOG(550); - HANDLE_DIALOG(560); - HANDLE_DIALOG(590); - HANDLE_DIALOG(600); - - default: - warning("ERROR: Dialog %d does not exist!", (int)nDlg); - return "ERROR"; - } -} - -void mpalDumpDialog(LPMPALDIALOG dlg) { - char dfn[64]; - char fname[64]; - int g,c,j; - struct command* curCmd; - char *frase; char *p; - char copia[2048]; - bool bAtLeastOne; - Common::OutSaveFile *f, *v1; - - v1 = g_system->getSavefileManager()->openForSaving("voicelist.txt"); - - sprintf(dfn,"DIALOG%03d.HTM", dlg->nObj); - warning("Dumping %s...\n", dfn); - - f = g_system->getSavefileManager()->openForSaving(dfn); - - f->writeString("\n\n"); - - for (g = 0; dlg->_group[g].num != 0; g++) { - bAtLeastOne = false; - - for (c = 0; c_group[g].nCmds; c++) { - curCmd = &dlg->_command[dlg->_group[g].CmdNum[c]]; - if (curCmd->type == 1 && curCmd->_nCf == 71) { - bAtLeastOne = true; - break; - } - } - - if (!bAtLeastOne) - continue; - - f->writeString(Common::String::format("

\n

Group %d

\n

\n", g)); - f->writeString("\n"); - - for (c = 0; c < dlg->_group[g].nCmds; c++) { - curCmd = &dlg->_command[dlg->_group[g].CmdNum[c]]; - - // If it's a custom function, call SendDialogMessage(nPers, nMsg) - if (curCmd->type == 1 && curCmd->_nCf == 71) { - sprintf(fname, "%03d-%05d.WAV", dlg->nObj, curCmd->_arg2); - - for (j = 0; dlg->_periods[j] != NULL; j++) - if (dlg->_periodNums[j] == curCmd->_arg2) - break; - - if (dlg->_periods[j] == NULL) - warning("ERROR: Dialog %d, Period %d not found!", (int)dlg->nObj, (int)curCmd->_arg2); - else { - frase = (char *)globalLock(dlg->_periods[j]); - strcpy(copia, frase); - globalUnlock(dlg->_periods[j]); - - while ((p = strchr(copia,'^')) != NULL) - *p = '\"'; - - p = frase; - while (*p == ' ') - p++; - if (*p == '\0') - continue; - - v1->writeString(Common::String::format("%s\n", fname)); - f->writeString("\t\n"); - f->writeString(Common::String::format("\t\t\n", fname)); - f->writeString(Common::String::format("\t\t\n", - getPersonName(dlg->nObj, curCmd->_arg1))); - f->writeString(Common::String::format("\t\t\n",copia)); - f->writeString("\t\n"); - //fprintf(f, "(%s) <%s> %s\n", fname, GetPersonName(dlg->nObj, curCmd->arg1), copia); - } - } - } - - f->writeString("
%s %s %s

\n"); - //fprintf(f,"\n\n\n\n"); - } - - f->finalize(); - v1->finalize(); - delete f; - delete v1; -} - -void mpalDumpDialogs() { - int i; - - lockDialogs(); - - for (i = 0; i < GLOBALS._nDialogs; i++) - mpalDumpDialog(&GLOBALS._lpmdDialogs[i]); - - unlockDialogs(); -} - } // end of namespace MPAL } // end of namespace Tony -- cgit v1.2.3 From 35fd91793b34b72624a89f2a76f45bc8e59020d2 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Tue, 28 Aug 2012 14:26:00 +0200 Subject: TONY: Get rid of RMDataStream. --- engines/tony/game.cpp | 7 +- engines/tony/gfxcore.cpp | 12 +- engines/tony/gfxcore.h | 10 +- engines/tony/gfxengine.cpp | 5 +- engines/tony/inventory.cpp | 15 +- engines/tony/loc.cpp | 358 ++++++++++++--------------------------- engines/tony/loc.h | 42 ++--- engines/tony/mpal/mpalutils.cpp | 5 + engines/tony/mpal/mpalutils.h | 6 + engines/tony/tonychar.cpp | 13 +- engines/tony/utils.cpp | 363 ++-------------------------------------- engines/tony/utils.h | 112 +------------ 12 files changed, 180 insertions(+), 768 deletions(-) (limited to 'engines') diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 4699a9b9aa..1ba8094ac4 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -1492,11 +1492,10 @@ void RMPointer::init() { for (i = 0; i < 5; i++) { RMRes res(RES_P_PAP1 + i); - RMDataStream ds; - - ds.openBuffer(res); + Common::SeekableReadStream *ds = res.getReadStream(); _specialPointer[i] = new RMItem; - ds >> *_specialPointer[i]; + _specialPointer[i]->readFromStream(*ds); + delete ds; } //m_hotspot[0].set(19,5); diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index f9f7cb02ec..44befa3755 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -125,7 +125,7 @@ int RMGfxSourceBuffer::init(const byte *buf, int dimx, int dimy, bool bLoadPalet return dimx * dimy * getBpp() / 8; } -void RMGfxSourceBuffer::init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette) { +void RMGfxSourceBuffer::init(Common::ReadStream &ds, int dimx, int dimy, bool bLoadPalette) { create(dimx, dimy, getBpp()); ds.read(_buf, dimx * dimy * getBpp() / 8); @@ -489,7 +489,7 @@ int RMGfxSourceBufferPal::init(const byte *buf, int dimx, int dimy, bool bLoadPa return read; } -void RMGfxSourceBufferPal::init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette) { +void RMGfxSourceBufferPal::init(Common::ReadStream &ds, int dimx, int dimy, bool bLoadPalette) { // Load the RAW image RMGfxSourceBuffer::init(ds, dimx, dimy); @@ -749,13 +749,13 @@ int RMGfxSourceBuffer8RLE::init(const byte *buf, int dimx, int dimy, bool bLoadP return RMGfxSourceBufferPal::init(buf, dimx, dimy, bLoadPalette); } -void RMGfxSourceBuffer8RLE::init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette) { +void RMGfxSourceBuffer8RLE::init(Common::ReadStream &ds, int dimx, int dimy, bool bLoadPalette) { if (_bNeedRLECompress) { RMGfxSourceBufferPal::init(ds, dimx, dimy, bLoadPalette); } else { int size; - ds >> size; + size = ds.readSint32LE(); _buf = new byte[size]; ds.read(_buf, size); @@ -1826,7 +1826,7 @@ int RMGfxSourceBuffer8RLEByteAA::init(const byte *buf, int dimx, int dimy, bool return RMGfxSourceBuffer8RLE::init(buf, dimx, dimy, bLoadPalette); } -void RMGfxSourceBuffer8RLEByteAA::init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette) { +void RMGfxSourceBuffer8RLEByteAA::init(Common::ReadStream &ds, int dimx, int dimy, bool bLoadPalette) { RMGfxSourceBuffer8RLE::init(ds, dimx, dimy, bLoadPalette); if (!_bNeedRLECompress) { @@ -1862,7 +1862,7 @@ int RMGfxSourceBuffer8RLEWordAA::init(byte *buf, int dimx, int dimy, bool bLoadP return RMGfxSourceBuffer8RLE::init(buf, dimx, dimy, bLoadPalette); } -void RMGfxSourceBuffer8RLEWordAA::init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette) { +void RMGfxSourceBuffer8RLEWordAA::init(Common::ReadStream &ds, int dimx, int dimy, bool bLoadPalette) { RMGfxSourceBuffer8RLE::init(ds, dimx, dimy, bLoadPalette); if (!_bNeedRLECompress) { diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index cd7830be24..472a4ad13a 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -290,7 +290,7 @@ public: // Load the data for the surface virtual int init(uint32 resID, int dimx, int dimy, bool bLoadPalette = false); virtual int init(const byte *buf, int dimx, int dimy, bool bLoadPalette = false); - virtual void init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette = false); + virtual void init(Common::ReadStream &ds, int dimx, int dimy, bool bLoadPalette = false); virtual ~RMGfxSourceBuffer(); @@ -343,7 +343,7 @@ public: virtual ~RMGfxSourceBufferPal(); virtual int init(const byte *buf, int dimx, int dimy, bool bLoadPalette = false); - virtual void init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette = false); + virtual void init(Common::ReadStream &ds, int dimx, int dimy, bool bLoadPalette = false); int loadPaletteWA(uint32 resID, bool bSwapped = false); int loadPaletteWA(const byte *buf, bool bSwapped = false); @@ -418,7 +418,7 @@ public: virtual ~RMGfxSourceBuffer8RLE(); // Overload of the initialization method - virtual void init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette = false); + virtual void init(Common::ReadStream &ds, int dimx, int dimy, bool bLoadPalette = false); virtual int init(const byte *buf, int dimx, int dimy, bool bLoadPalette = false); // Draw image with RLE decompression @@ -501,7 +501,7 @@ public: virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Overloaded initialization methods - virtual void init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette = false); + virtual void init(Common::ReadStream &ds, int dimx, int dimy, bool bLoadPalette = false); virtual int init(const byte *buf, int dimx, int dimy, bool bLoadPalette = false); virtual ~RMGfxSourceBuffer8RLEByteAA(); @@ -515,7 +515,7 @@ public: virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Overloaded initialization methods - virtual void init(RMDataStream &ds, int dimx, int dimy, bool bLoadPalette = false); + virtual void init(Common::ReadStream &ds, int dimx, int dimy, bool bLoadPalette = false); virtual int init(byte *buf, int dimx, int dimy, bool bLoadPalette = false); virtual ~RMGfxSourceBuffer8RLEWordAA(); diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 25aaa625f4..e8a5df29e9 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -416,7 +416,10 @@ uint32 RMGfxEngine::loadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { if (!res.isValid()) continue; - _loc.load(res); + Common::SeekableReadStream *ds = res.getReadStream(); + _loc.load(*ds); + delete ds; + initForNewLocation(nLoc, ptTonyStart, start); bLoaded = true; break; diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index 175d9fc6a9..dbd3ad6840 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -95,15 +95,13 @@ void RMInventory::init() { for (i = 0; i <= _nItems; i++) { // Load the items from the resource RMRes res(curres); - RMDataStream ds; - assert(res.isValid()); + Common::SeekableReadStream *ds = res.getReadStream(); // Initialize the MPAL inventory item by reading it in. _items[i]._icon.setInitCurPattern(false); - ds.openBuffer(res); - ds >> _items[i]._icon; - ds.close(); + _items[i]._icon.readFromStream(*ds); + delete ds; // Puts in the default pattern 1 _items[i]._pointer = NULL; @@ -131,13 +129,12 @@ void RMInventory::init() { _items[29]._icon.setPattern(1); // Download interface - RMDataStream ds; RMRes res(RES_I_MINIINTER); assert(res.isValid()); - ds.openBuffer(res); - ds >> _miniInterface; + Common::SeekableReadStream *ds = res.getReadStream(); + _miniInterface.readFromStream(*ds); _miniInterface.setPattern(1); - ds.close(); + delete ds; // Create the text for hints on the mini interface _hints[0].setAlignType(RMText::HCENTER, RMText::VTOP); diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index e767584e9b..32c857ceaa 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -42,52 +42,29 @@ using namespace ::Tony::MPAL; * RMPalette Methods \****************************************************************************/ -/** - * Operator for reading palette information from a data stream. - * - * @param ds Data stream - * @param pal Destination palette - * - * @returns Reference to the data stream - */ -RMDataStream &operator>>(RMDataStream &ds, RMPalette &pal) { - ds.read(pal._data, 1024); - return ds; +void RMPalette::readFromStream(Common::ReadStream &ds) { + ds.read(_data, 1024); } /****************************************************************************\ * RMSlot Methods \****************************************************************************/ -/** - * Operator for reading slot information from a data stream. - * - * @param ds Data stream - * @param slot Destination slot - * - * @returns Reference to the data stream - */ -RMDataStream &operator>>(RMDataStream &ds, RMPattern::RMSlot &slot) { - slot.readFromStream(ds); - return ds; -} - - -void RMPattern::RMSlot::readFromStream(RMDataStream &ds, bool bLOX) { +void RMPattern::RMSlot::readFromStream(Common::ReadStream &ds, bool bLOX) { byte type; // Type - ds >> type; + type = ds.readByte(); _type = (RMPattern::RMSlotType)type; // Dati - ds >> _data; + _data = ds.readSint32LE(); // Posizione - ds >> _pos; + _pos.readFromStream(ds); // Flag generica - ds >> _flag; + _flag = ds.readByte(); } @@ -95,42 +72,29 @@ void RMPattern::RMSlot::readFromStream(RMDataStream &ds, bool bLOX) { * Metodi di RMPattern \****************************************************************************/ -/** - * Operator for reading pattern information from a data stream - * - * @param ds Data stream - * @param pat Destination pattern - * - * @returns Reference to the data stream - */ -RMDataStream &operator>>(RMDataStream &ds, RMPattern &pat) { - pat.readFromStream(ds); - return ds; -} - -void RMPattern::readFromStream(RMDataStream &ds, bool bLOX) { +void RMPattern::readFromStream(Common::ReadStream &ds, bool bLOX) { int i; // Pattern name if (!bLOX) - ds >> _name; + _name = readString(ds); // Velocity - ds >> _speed; + _speed = ds.readSint32LE(); // Position - ds >> _pos; + _pos.readFromStream(ds); // Flag for pattern looping - ds >> _bLoop; + _bLoop = ds.readSint32LE(); // Number of slots - ds >> _nSlots; + _nSlots = ds.readSint32LE(); // Create and read the slots _slots = new RMSlot[_nSlots]; - for (i = 0; i < _nSlots && !ds.isError(); i++) { + for (i = 0; i < _nSlots && !ds.err(); i++) { if (bLOX) _slots[i].readFromStream(ds, true); else @@ -302,56 +266,46 @@ RMPattern::~RMPattern() { * RMSprite Methods \****************************************************************************/ -/** - * Operator for reading sprite information from a data stream. - * - * @param ds Data stream - * @param sprite Destination slot - * - * @returns Reference to the data stream - */ -RMDataStream &operator>>(RMDataStream &ds, RMSprite &sprite) { - sprite.readFromStream(ds); - return ds; -} - void RMSprite::init(RMGfxSourceBuffer *buf) { _buf = buf; } -void RMSprite::LOXGetSizeFromStream(RMDataStream &ds, int *dimx, int *dimy) { - int pos = ds.pos(); +void RMSprite::LOXGetSizeFromStream(Common::SeekableReadStream &ds, int *dimx, int *dimy) { + uint32 pos = ds.pos(); - ds >> *dimx >> *dimy; + *dimx = ds.readSint32LE(); + *dimy = ds.readSint32LE(); - ds.seek(pos, ds.START); + ds.seek(pos); } -void RMSprite::getSizeFromStream(RMDataStream &ds, int *dimx, int *dimy) { - int pos = ds.pos(); +void RMSprite::getSizeFromStream(Common::SeekableReadStream &ds, int *dimx, int *dimy) { + uint32 pos = ds.pos(); - ds >> _name; - ds >> *dimx >> *dimy; + _name = readString(ds); + *dimx = ds.readSint32LE(); + *dimy = ds.readSint32LE(); - ds.seek(pos, ds.START); + ds.seek(pos); } -void RMSprite::readFromStream(RMDataStream &ds, bool bLOX) { +void RMSprite::readFromStream(Common::SeekableReadStream &ds, bool bLOX) { int dimx, dimy; // Sprite name if (!bLOX) - ds >> _name; + _name = readString(ds); // Dimensions - ds >> dimx >> dimy; + dimx = ds.readSint32LE(); + dimy = ds.readSint32LE(); // Bounding box - ds >> _rcBox; + _rcBox.readFromStream(ds); // Unused space if (!bLOX) - ds += 32; + ds.skip(32); // Create buffer and read _buf->init(ds, dimx, dimy); @@ -381,26 +335,13 @@ RMSprite::~RMSprite() { * RMSfx Methods \****************************************************************************/ -/** - * Operator for reading SFX information from a data stream. - * - * @param ds Data stream - * @param sfx Destination SFX - * - * @returns Reference to the data stream - */ -RMDataStream &operator>>(RMDataStream &ds, RMSfx &sfx) { - sfx.readFromStream(ds); - return ds; -} - -void RMSfx::readFromStream(RMDataStream &ds, bool bLOX) { +void RMSfx::readFromStream(Common::ReadStream &ds, bool bLOX) { int size; // sfx name - ds >> _name; + _name = readString(ds); - ds >> size; + size = ds.readSint32LE(); // Read the entire buffer into a MemoryReadStream byte *buffer = (byte *)malloc(size); @@ -459,20 +400,6 @@ void RMSfx::stop() { * RMItem Methods \****************************************************************************/ -/** - * Operator for reading item information from a data stream. - * - * @param ds Data stream - * @param tem Destination item - * - * @returns Reference to the data stream - */ -RMDataStream &operator>>(RMDataStream &ds, RMItem &item) { - item.readFromStream(ds); - return ds; -} - - RMGfxSourceBuffer *RMItem::newItemSpriteBuffer(int dimx, int dimy, bool bPreRLE) { if (_cm == CM_256) { RMGfxSourceBuffer8RLE *spr; @@ -524,53 +451,55 @@ bool RMItem::isIn(const RMPoint &pt, int *size) { return rc.ptInRect(pt + _curScroll); } -void RMItem::readFromStream(RMDataStream &ds, bool bLOX) { +void RMItem::readFromStream(Common::SeekableReadStream &ds, bool bLOX) { int i, dimx, dimy; byte cm; // MPAL code - ds >> _mpalCode; + _mpalCode = ds.readSint32LE(); // Object name - ds >> _name; + _name = readString(ds); // Z (signed) - ds >> _z; + _z = ds.readSint32LE(); // Parent position - ds >> _pos; + _pos.readFromStream(ds); // Hotspot - ds >> _hot; + _hot.readFromStream(ds); // Bounding box - ds >> _rcBox; + _rcBox.readFromStream(ds); // Number of sprites, sound effects, and patterns - ds >> _nSprites >> _nSfx >> _nPatterns; + _nSprites = ds.readSint32LE(); + _nSfx = ds.readSint32LE(); + _nPatterns = ds.readSint32LE(); // Color mode - ds >> cm; + cm = ds.readByte(); _cm = (RMColorMode)cm; // Flag for the presence of custom palette differences - ds >> _bPal; + _bPal = ds.readByte(); if (_cm == CM_256) { // If there is a palette, read it in if (_bPal) - ds >> _pal; + _pal.readFromStream(ds); } // MPAL data if (!bLOX) - ds += 20; + ds.skip(20); - ds >> _FX; - ds >> _FXparm; + _FX = ds.readByte(); + _FXparm = ds.readByte(); if (!bLOX) - ds += 106; + ds.skip(106); // Create sub-classes if (_nSprites > 0) @@ -580,8 +509,8 @@ void RMItem::readFromStream(RMDataStream &ds, bool bLOX) { _patterns = new RMPattern[_nPatterns + 1]; // Read in class data - if (!ds.isError()) - for (i = 0; i < _nSprites && !ds.isError(); i++) { + if (!ds.err()) + for (i = 0; i < _nSprites && !ds.err(); i++) { // Download the sprites if (bLOX) { _sprites[i].LOXGetSizeFromStream(ds, &dimx, &dimy); @@ -597,8 +526,8 @@ void RMItem::readFromStream(RMDataStream &ds, bool bLOX) { _sprites[i].setPalette(_pal._data); } - if (!ds.isError()) - for (i = 0; i < _nSfx && !ds.isError(); i++) { + if (!ds.err()) + for (i = 0; i < _nSfx && !ds.err(); i++) { if (bLOX) _sfx[i].readFromStream(ds, true); else @@ -606,8 +535,8 @@ void RMItem::readFromStream(RMDataStream &ds, bool bLOX) { } // Read the pattern from pattern 1 - if (!ds.isError()) - for (i = 1; i <= _nPatterns && !ds.isError(); i++) { + if (!ds.err()) + for (i = 1; i <= _nPatterns && !ds.err(); i++) { if (bLOX) _patterns[i].readFromStream(ds, true); else @@ -899,11 +828,9 @@ void RMWipe::initFade(int type) { _bMustRegister = true; RMRes res(RES_W_CIRCLE); - RMDataStream ds; - - ds.openBuffer(res); - ds >> _wip0r; - ds.close(); + Common::SeekableReadStream *ds = res.getReadStream(); + _wip0r.readFromStream(*ds); + delete ds; _wip0r.setPattern(1); @@ -1706,50 +1633,45 @@ void RMCharacter::linkToBoxes(RMGameBoxes *boxes) { * RMBox Methods \****************************************************************************/ -void RMBox::readFromStream(RMDataStream &ds) { +void RMBox::readFromStream(Common::ReadStream &ds) { uint16 w; int i; byte b; // Bbox - ds >> _left; - ds >> _top; - ds >> _right; - ds >> _bottom; + _left = ds.readSint32LE(); + _top = ds.readSint32LE(); + _right = ds.readSint32LE(); + _bottom = ds.readSint32LE(); // Adjacency for (i = 0; i < MAXBOXES; i++) { - ds >> _adj[i]; + _adj[i] = ds.readSint32LE(); } // Misc - ds >> _numHotspot; - ds >> _destZ; - ds >> b; + _numHotspot = ds.readSint32LE(); + _destZ = ds.readByte(); + b = ds.readByte(); _bActive = b; - ds >> b; + b = ds.readByte(); _bReversed = b; // Reversed expansion space - ds += 30; + for (i = 0; i < 30; i++) + ds.readByte(); // Hotspots for (i = 0; i < _numHotspot; i++) { - ds >> w; + w = ds.readUint16LE(); _hotspot[i]._hotx = w; - ds >> w; + w = ds.readUint16LE(); _hotspot[i]._hoty = w; - ds >> w; + w = ds.readUint16LE(); _hotspot[i]._destination = w; } } -RMDataStream &operator>>(RMDataStream &ds, RMBox &box) { - box.readFromStream(ds); - - return ds; -} - /****************************************************************************\ * RMBoxLoc Methods \****************************************************************************/ @@ -1763,25 +1685,27 @@ RMBoxLoc::~RMBoxLoc() { delete[] _boxes; } -void RMBoxLoc::readFromStream(RMDataStream &ds) { +void RMBoxLoc::readFromStream(Common::ReadStream &ds) { int i; char buf[2]; byte ver; // ID and version - ds >> buf[0] >> buf[1] >> ver; + buf[0] = ds.readByte(); + buf[1] = ds.readByte(); + ver = ds.readByte(); assert(buf[0] == 'B' && buf[1] == 'X'); assert(ver == 3); // Number of boxes - ds >> _numbBox; + _numbBox = ds.readSint32LE(); // Allocate memory for the boxes _boxes = new RMBox[_numbBox]; // Read in boxes for (i = 0; i < _numbBox; i++) - ds >> _boxes[i]; + _boxes[i].readFromStream(ds); } void RMBoxLoc::recalcAllAdj() { @@ -1796,12 +1720,6 @@ void RMBoxLoc::recalcAllAdj() { } } -RMDataStream &operator>>(RMDataStream &ds, RMBoxLoc &bl) { - bl.readFromStream(ds); - - return ds; -} - /****************************************************************************\ * RMGameBoxes methods \****************************************************************************/ @@ -1818,21 +1736,20 @@ RMGameBoxes::~RMGameBoxes() { void RMGameBoxes::init() { int i; - RMDataStream ds; // Load boxes from disk _nLocBoxes = 130; for (i = 1; i <= _nLocBoxes; i++) { RMRes res(10000 + i); - ds.openBuffer(res); + Common::SeekableReadStream *ds = res.getReadStream(); _allBoxes[i] = new RMBoxLoc(); - ds >> *_allBoxes[i]; + _allBoxes[i]->readFromStream(*ds); _allBoxes[i]->recalcAllAdj(); - ds.close(); + delete ds; } } @@ -1946,70 +1863,13 @@ RMLocation::RMLocation() { _cmode = CM_256; } - -/** - * Load a location (.LOC) from a file that is provided. - * - * @param lpszFileName Name of the file - */ -bool RMLocation::load(const char *lpszFileName) { - Common::File f; - bool bRet; - - // Open the file for reading - if (!f.open(lpszFileName)) - return false; - - // Passes to the method variation for loading from the opened file - bRet = load(f); - - // Close the file - f.close(); - - return bRet; -} - - -/** - * Load a location (.LOC) from a given open file - * - * @param hFile File reference - * - * @returns True if succeeded OK, false in case of error. - */ -bool RMLocation::load(Common::File &file) { - bool bRet; - - file.seek(0); - - RMFileStreamSlow fs; - - fs.openFile(file); - bRet = load(fs); - fs.close(); - - return bRet; -} - - -bool RMLocation::load(const byte *buf) { - RMDataStream ds; - bool bRet; - - ds.openBuffer(buf); - bRet = load(ds); - ds.close(); - return bRet; -} - - /** * Load a location (.LOC) from a given data stream * * @param ds Data stream * @returns True if succeeded OK, false in case of error. */ -bool RMLocation::load(RMDataStream &ds) { +bool RMLocation::load(Common::SeekableReadStream &ds) { char id[3]; int dimx, dimy; byte ver; @@ -2021,7 +1881,7 @@ bool RMLocation::load(RMDataStream &ds) { _prevFixedScroll.set(-1, -1); // Check the ID - ds >> id[0] >> id[1] >> id[2]; + ds.read(id, 3); // Check if we are in a LOX if (id[0] == 'L' && id[1] == 'O' && id[2] == 'X') @@ -2032,26 +1892,28 @@ bool RMLocation::load(RMDataStream &ds) { return false; // Version - ds >> ver; + ver = ds.readByte(); assert(ver == 6); // Location name - ds >> _name; + _name = readString(ds); // Skip the MPAL bailouts (64 bytes) - ds >> TEMPNumLoc; - ds >> TEMPTonyStart._x >> TEMPTonyStart._y; - ds += 64 - 4 * 3; + TEMPNumLoc = ds.readSint32LE(); + TEMPTonyStart._x = ds.readSint32LE(); + TEMPTonyStart._y = ds.readSint32LE(); + ds.skip(64 - 4 * 3); // Skip flag associated with the background (?) - ds += 1; + ds.skip(1); // Location dimensions - ds >> dimx >> dimy; + dimx = ds.readSint32LE(); + dimy = ds.readSint32LE(); _curScroll.set(0, 0); // Read the color mode - ds >> cm; + cm = ds.readByte(); _cmode = (RMColorMode)cm; // Initialize the source buffer and read the location @@ -2076,7 +1938,7 @@ bool RMLocation::load(RMDataStream &ds) { // assert(dimy!=512); // Number of objects - ds >> _nItems; + _nItems = ds.readSint32LE(); // Create and read in the objects if (_nItems > 0) @@ -2084,32 +1946,34 @@ bool RMLocation::load(RMDataStream &ds) { g_vm->freezeTime(); - for (i = 0; i < _nItems && !ds.isError(); i++) - ds >> _items[i]; + for (i = 0; i < _nItems && !ds.err(); i++) + _items[i].readFromStream(ds); g_vm->unfreezeTime(); - return ds.isError(); + return ds.err(); } -bool RMLocation::loadLOX(RMDataStream &ds) { +bool RMLocation::loadLOX(Common::SeekableReadStream &ds) { int dimx, dimy; byte ver; int i; // Version - ds >> ver; + ver = ds.readByte(); assert(ver == 1); // Location name - ds >> _name; + _name = readString(ds); // Location number - ds >> TEMPNumLoc; - ds >> TEMPTonyStart._x >> TEMPTonyStart._y; + TEMPNumLoc = ds.readSint32LE(); + TEMPTonyStart._x = ds.readSint32LE(); + TEMPTonyStart._y = ds.readSint32LE(); // Dimensions - ds >> dimx >> dimy; + dimx = ds.readSint32LE(); + dimy = ds.readSint32LE(); _curScroll.set(0, 0); // It's always 65K (16-bit) mode @@ -2120,16 +1984,16 @@ bool RMLocation::loadLOX(RMDataStream &ds) { _buf->init(ds, dimx, dimy, true); // Number of items - ds >> _nItems; + _nItems = ds.readSint32LE(); // Create and read objects if (_nItems > 0) _items = new RMItem[_nItems]; - for (i = 0; i < _nItems && !ds.isError(); i++) + for (i = 0; i < _nItems && !ds.err(); i++) _items[i].readFromStream(ds, true); - return ds.isError(); + return ds.err(); } diff --git a/engines/tony/loc.h b/engines/tony/loc.h index acfbd45cdb..7b0a2ddd6b 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -62,7 +62,7 @@ public: byte _data[1024]; public: - friend RMDataStream &operator>>(RMDataStream &ds, RMPalette &pal); + void readFromStream(Common::ReadStream &ds); }; @@ -79,14 +79,12 @@ public: RMSfx(); virtual ~RMSfx(); - friend RMDataStream &operator>>(RMDataStream &ds, RMSfx &sfx); - void play(bool bLoop = false); void setVolume(int vol); void pause(bool bPause); void stop(); - void readFromStream(RMDataStream &ds, bool bLOX = false); + void readFromStream(Common::ReadStream &ds, bool bLOX = false); }; @@ -116,13 +114,11 @@ public: byte _flag; public: - friend RMDataStream &operator>>(RMDataStream &ds, RMSlot &slot); - RMPoint pos() { return _pos; } - void readFromStream(RMDataStream &ds, bool bLOX = false); + void readFromStream(Common::ReadStream &ds, bool bLOX = false); }; public: @@ -145,8 +141,6 @@ public: RMPattern(); virtual ~RMPattern(); - friend RMDataStream &operator>>(RMDataStream &ds, RMPattern &pat); - // A warning that the pattern now and the current int init(RMSfx *sfx, bool bPlayP0 = false, byte *bFlag = NULL); @@ -162,7 +156,7 @@ public: return _curPos; } - void readFromStream(RMDataStream &ds, bool bLOX = false); + void readFromStream(Common::ReadStream &ds, bool bLOX = false); private: void updateCoord(); @@ -185,13 +179,12 @@ public: virtual ~RMSprite(); void init(RMGfxSourceBuffer *buf); - friend RMDataStream &operator>>(RMDataStream &ds, RMSprite &sprite); virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); void setPalette(byte *lpBuf); - void getSizeFromStream(RMDataStream &ds, int *dimx, int *dimy); - void LOXGetSizeFromStream(RMDataStream &ds, int *dimx, int *dimy); + void getSizeFromStream(Common::SeekableReadStream &ds, int *dimx, int *dimy); + void LOXGetSizeFromStream(Common::SeekableReadStream &ds, int *dimx, int *dimy); - void readFromStream(RMDataStream &ds, bool bLOX = false); + void readFromStream(Common::SeekableReadStream &ds, bool bLOX = false); }; @@ -241,8 +234,6 @@ public: RMItem(); virtual ~RMItem(); - friend RMDataStream &operator>>(RMDataStream &ds, RMItem &item); - // Process to make the object move on any animations. // Returns TRUE if it should be redrawn on the next frame bool doFrame(RMGfxTargetBuffer *bigBuf, bool bAddToList = true); @@ -296,7 +287,7 @@ public: void playSfx(int nSfx); - void readFromStream(RMDataStream &ds, bool bLOX = false); + void readFromStream(Common::SeekableReadStream &ds, bool bLOX = false); void pauseSound(bool bPause); @@ -329,11 +320,7 @@ public: bool _bActive; bool _bReversed; -private: - void readFromStream(RMDataStream &ds); - -public: - friend RMDataStream &operator>>(RMDataStream &ds, RMBox &box); + void readFromStream(Common::ReadStream &ds); }; @@ -342,14 +329,12 @@ public: int _numbBox; RMBox *_boxes; -private: - void readFromStream(RMDataStream &ds); + void readFromStream(Common::ReadStream &ds); public: RMBoxLoc(); virtual ~RMBoxLoc(); - friend RMDataStream &operator >>(RMDataStream &ds, RMBoxLoc &bl); void recalcAllAdj(); }; @@ -559,11 +544,8 @@ public: virtual ~RMLocation(); // Load variations - bool load(const char *lpszFileName); - bool load(Common::File &file); - bool load(const byte *buf); - bool load(RMDataStream &ds); - bool loadLOX(RMDataStream &ds); + bool load(Common::SeekableReadStream &ds); + bool loadLOX(Common::SeekableReadStream &ds); // Unload void unload(); diff --git a/engines/tony/mpal/mpalutils.cpp b/engines/tony/mpal/mpalutils.cpp index aa22456a4b..bfc97a5f3d 100644 --- a/engines/tony/mpal/mpalutils.cpp +++ b/engines/tony/mpal/mpalutils.cpp @@ -23,6 +23,7 @@ #include "tony/mpal/mpalutils.h" #include "tony/tony.h" +#include "common/memstream.h" namespace Tony { @@ -75,6 +76,10 @@ unsigned int RMRes::size() { return globalSize(_h); } +Common::SeekableReadStream *RMRes::getReadStream() { + return new Common::MemoryReadStream(_buf, size()); +} + /****************************************************************************\ * RMResRaw methods \****************************************************************************/ diff --git a/engines/tony/mpal/mpalutils.h b/engines/tony/mpal/mpalutils.h index 19810cf3a1..19e4fa7778 100644 --- a/engines/tony/mpal/mpalutils.h +++ b/engines/tony/mpal/mpalutils.h @@ -27,6 +27,10 @@ #include "common/scummsys.h" #include "tony/mpal/memory.h" +namespace Common { + class SeekableReadStream; +} + namespace Tony { namespace MPAL { @@ -47,6 +51,8 @@ public: // Casting for access to data operator const byte*(); + + Common::SeekableReadStream *getReadStream(); }; class RMResRaw : public RMRes { diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index 8593ece480..9caa10bd46 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -87,7 +87,6 @@ RMGfxSourceBuffer *RMTony::newItemSpriteBuffer(int dimx, int dimy, bool bPreRLE) void RMTony::init() { RMRes tony(0); RMRes body(9999); - RMDataStream ds; // Tony is shown by default _bShow = _bShowShadow = true; @@ -101,18 +100,18 @@ void RMTony::init() { _bIsStaticTalk = false; // Opens the buffer - ds.openBuffer(tony); + Common::SeekableReadStream *ds = tony.getReadStream(); // Reads his details from the stream - readFromStream(ds, true); + readFromStream(*ds, true); // Closes the buffer - ds.close(); + delete ds; // Reads Tony's body - ds.openBuffer(body); - _body.readFromStream(ds, true); - ds.close(); + ds = body.getReadStream(); + _body.readFromStream(*ds, true); + delete ds; _body.setPattern(0); _nTimeLastStep = g_vm->getTime(); diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index 8dc1f5d615..a3f79decaf 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -35,360 +35,21 @@ namespace Tony { /** * Extracts a string from a data stream * @param df data stream - * @param var String */ -RMDataStream &operator>>(RMDataStream &df, Common::String &var) { +Common::String readString(Common::ReadStream &df) { + Common::String var; uint8 len; int i; - df >> len; + len = df.readByte(); for (i = 0; i < len; i++) { char c; - df >> c; + c = df.readByte(); var += c; } - return df; -} - -/****************************************************************************\ -* RMFileStreamSlow Methods -\****************************************************************************/ - -RMFileStreamSlow::RMFileStreamSlow() : RMDataStream() { - _stream = NULL; -} - -RMFileStreamSlow::~RMFileStreamSlow() { - close(); -} - -void RMFileStreamSlow::close() { - delete _stream; -} - -bool RMFileStreamSlow::openFile(Common::File &file) { - _stream = file.readStream(file.size()); - - _length = _stream->pos(); - - return true; -} - -bool RMFileStreamSlow::openFile(const char *lpFN) { - // Open file for reading - Common::File f; - if (!f.open(lpFN)) - return false; - - _length = f.size(); - _stream = f.readStream(f.size()); - - return true; -} - -RMDataStream &RMFileStreamSlow::operator+=(int nBytes) { - seek(nBytes); - return *this; -} - -int RMFileStreamSlow::pos() { - return _stream->pos(); -} - -bool RMFileStreamSlow::isEOF() { - return (pos() >= _length); -} - -int RMFileStreamSlow::seek(int nBytes, RMDSPos where) { - switch (where) { - case START: - return _stream->seek(nBytes); - - case END: - return _stream->seek(nBytes, SEEK_END); - - case CUR: - return _stream->seek(nBytes, SEEK_CUR); - - default: - return 0; - } -} - -bool RMFileStreamSlow::read(void *buf, int size) { - uint32 dwRead; - - dwRead = _stream->read(buf, size); - return ((int)dwRead == size); -} - -RMFileStreamSlow &operator>>(RMFileStreamSlow &df, char &var) { - df.read(&var, 1); - return df; -} - -RMFileStreamSlow &operator>>(RMFileStreamSlow &df, byte &var) { - df.read(&var, 1); - return df; -} - -RMFileStreamSlow &operator>>(RMFileStreamSlow &df, uint16 &var) { - uint16 v; - df.read(&v, 2); - v = FROM_LE_16(v); - return df; -} - -RMFileStreamSlow &operator>>(RMFileStreamSlow &df, int16 &var) { - uint16 v; - df.read(&v, 2); - var = (int16)FROM_LE_16(v); - return df; -} - -RMFileStreamSlow &operator>>(RMFileStreamSlow &df, int &var) { - int v; - df.read(&v, 4); - var = FROM_LE_32(v); - return df; -} - -RMFileStreamSlow &operator>>(RMFileStreamSlow &df, uint32 &var) { - uint32 v; - df.read(&v, 4); - var = FROM_LE_32(v); - return df; -} - -/****************************************************************************\ -* RMDataStream methods -\****************************************************************************/ - -/** - * Constructor - */ -RMDataStream::RMDataStream() { - _length = 0; - _pos = 0; - _bError = false; - - _buf = NULL; - _ecode = 0; -} - -/** - * Destructor - */ -RMDataStream::~RMDataStream() { - close(); -} - -/** - * Close a stream - */ -void RMDataStream::close() { - _length = 0; - _pos = 0; -} - -/** - * Takes the address of the buffer from which will be read the data. - * @param lpBuf Data buffer - * @param size Size of the buffer - * @remarks If the length of the buffer is not known, and cannot be - * specified, then EOF() and Seek() to end won't work. - */ -void RMDataStream::openBuffer(const byte *lpBuf, int size) { - _length = size; - _buf = lpBuf; - _bError = false; - _pos = 0; -} - -/** - * Returns the length of the stream - * @returns Stream length - */ -int RMDataStream::length() { - return _length; -} - -/** - * Determines if the end of the stream has been reached - * @returns true if end of stream reached, false if not - */ -bool RMDataStream::isEOF() { - return (_pos >= _length); -} - -/** - * Extracts data from the stream - * @param df Stream - * @param var Variable of a supported type - * @returns Value read from the stream - */ -RMDataStream &operator>>(RMDataStream &df, char &var) { - df.read(&var, 1); - return df; -} - -/** - * Extracts data from the stream - * @param df Stream - * @param var Variable of a supported type - * @returns Value read from the stream - */ -RMDataStream &operator>>(RMDataStream &df, uint8 &var) { - df.read(&var, 1); - return df; -} - -/** - * Extracts data from the stream - * @param df Stream - * @param var Variable of a supported type - * @returns Value read from the stream - */ -RMDataStream &operator>>(RMDataStream &df, uint16 &var) { - uint16 v; - df.read(&v, 2); - - var = FROM_LE_16(v); - return df; -} - -/** - * Extracts data from the stream - * @param df Stream - * @param var Variable of a supported type - * @returns Value read from the stream - */ -RMDataStream &operator>>(RMDataStream &df, int16 &var) { - uint16 v; - df.read(&v, 2); - - var = (int16)FROM_LE_16(v); - return df; -} - -/** - * Extracts data from the stream - * @param df Stream - * @param var Variable of a supported type - * @returns Value read from the stream - */ -RMDataStream &operator>>(RMDataStream &df, int &var) { - uint32 v; - df.read(&v, 4); - - var = (int)FROM_LE_32(v); - return df; -} - -/** - * Extracts data from the stream - * @param df Stream - * @param var Variable of a supported type - * @returns Value read from the stream - */ -RMDataStream &operator>>(RMDataStream &df, uint32 &var) { - uint32 v; - df.read(&v, 4); - - var = FROM_LE_32(v); - return df; -} - -/** - * Reads a series of data from the stream in a buffer - * @param lpBuf Data buffer - * @param size Size of the buffer - * @returns true if we have reached the end, false if not - */ -bool RMDataStream::read(void *lpBuf, int size) { - byte *dest = (byte *)lpBuf; - - if ((_pos + size) > _length) { - Common::copy(_buf + _pos, _buf + _pos + (_length - _pos), dest); - - return true; - } else { - Common::copy(_buf + _pos, _buf + _pos + size, dest); - - _pos += size; - return false; - } -} - -/** - * Skips a number of bytes in the stream - * @param nBytres Number of bytes to skip - * @returns The stream - */ -RMDataStream &RMDataStream::operator+=(int nBytes) { - _pos += nBytes; - return *this; -} - -/** - * Seeks to a position within the stream - * @param nBytes Number of bytes from specified origin - * @param origin Origin to do offset from - * @returns The absolute current position in bytes - */ -int RMDataStream::seek(int nBytes, RMDSPos origin) { - switch (origin) { - case CUR: - break; - - case START: - _pos = 0; - break; - - case END: - if (_length == SIZENOTKNOWN) - return _pos; - _pos = _length; - break; - } - - _pos += nBytes; - return _pos; -} - -/** - * Returns the current position of the stream - * @returns The current position - */ -int RMDataStream::pos() { - return _pos; -} - -/** - * Check if an error occurred during reading the stream - * @returns true if there was an error, false otherwise - */ -bool RMDataStream::isError() { - return _bError; -} - -/** - * Sets an error code for the stream - * @param code Error code - */ -void RMDataStream::setError(int code) { - _bError = true; - _ecode = code; -} - -/** - * Returns the error code for the stream - * @returns Error code - */ -int RMDataStream::getError() { - return _ecode; + return var; } /****************************************************************************\ @@ -507,9 +168,9 @@ bool RMPoint::operator!=(RMPoint p) { /** * Reads a point from a stream */ -RMDataStream &operator>>(RMDataStream &ds, RMPoint &p) { - ds >> p._x >> p._y; - return ds; +void RMPoint::readFromStream(Common::ReadStream &ds) { + _x = ds.readSint32LE(); + _y = ds.readSint32LE(); } /****************************************************************************\ @@ -663,9 +324,11 @@ void RMRect::normalizeRect() { setRect(MIN(_x1, _x2), MIN(_y1, _y2), MAX(_x1, _x2), MAX(_y1, _y2)); } -RMDataStream &operator>>(RMDataStream &ds, RMRect &rc) { - ds >> rc._x1 >> rc._y1 >> rc._x2 >> rc._y2; - return ds; +void RMRect::readFromStream(Common::ReadStream &ds) { + _x1 = ds.readSint32LE(); + _y1 = ds.readSint32LE(); + _x2 = ds.readSint32LE(); + _y2 = ds.readSint32LE(); } /****************************************************************************\ diff --git a/engines/tony/utils.h b/engines/tony/utils.h index 50b18d8aa7..d3f93e06ef 100644 --- a/engines/tony/utils.h +++ b/engines/tony/utils.h @@ -39,113 +39,7 @@ namespace Tony { using namespace ::Tony::MPAL; -/** - * Data stream for reading data - */ -class RMDataStream { -protected: - const byte *_buf; - int _length; - int _pos; - bool _bError; - int _ecode; - -public: - enum RMDSPos { - CUR, - START, - END - }; - -private: - enum { - SIZENOTKNOWN = 0x7FFFFFFF - }; - -public: - // Constructor and destructor - RMDataStream(); - virtual ~RMDataStream(); - - // Loading buffer - void openBuffer(const byte *buf, int size = SIZENOTKNOWN); - void close(); - - // Attributei - int length(); - virtual int pos(); - - // EOF - virtual bool isEOF(); - - // Read methods - friend RMDataStream &operator>>(RMDataStream &df, char &var); - friend RMDataStream &operator>>(RMDataStream &df, byte &var); - friend RMDataStream &operator>>(RMDataStream &df, uint16 &var); - friend RMDataStream &operator>>(RMDataStream &df, int16 &var); - friend RMDataStream &operator>>(RMDataStream &df, int &var); - friend RMDataStream &operator>>(RMDataStream &df, uint32 &var); - - // General read - virtual bool read(void *buf, int size); - - // Skipping & Seeking - virtual RMDataStream &operator+=(int nBytes); - virtual int seek(int nBytes, RMDSPos origin = CUR); - - // Error handling - void setError(int ecode); - int getError(); - bool isError(); -}; - -/** - * Data stream per lettura di dati aperto da file - */ -class RMFileStream : public RMDataStream { -private: - byte *_buf; - -public: - RMFileStream(); - virtual ~RMFileStream(); - - // Methods for opening file - bool openFile(const char *lpFN); - bool openFile(Common::File &file); - - void close(); -}; - -class RMFileStreamSlow : public RMDataStream { -private: - Common::SeekableReadStream *_stream; -public: - RMFileStreamSlow(); - virtual ~RMFileStreamSlow(); - - bool openFile(const char *lpFN); - bool openFile(Common::File &file); - - void close(); - - RMDataStream &operator+=(int nBytes); - int seek(int nBytes, RMDSPos where = CUR); - - int pos(); - virtual bool isEOF(); - - bool read(void *buf, int size); - - friend RMFileStreamSlow &operator>>(RMFileStreamSlow &df, char &var); - friend RMFileStreamSlow &operator>>(RMFileStreamSlow &df, byte &var); - friend RMFileStreamSlow &operator>>(RMFileStreamSlow &df, uint16 &var); - friend RMFileStreamSlow &operator>>(RMFileStreamSlow &df, int16 &var); - friend RMFileStreamSlow &operator>>(RMFileStreamSlow &df, int &var); - friend RMFileStreamSlow &operator>>(RMFileStreamSlow &df, uint32 &var); -}; - -RMDataStream &operator>>(RMDataStream &df, Common::String &var); +Common::String readString(Common::ReadStream &ds); /** * Point class @@ -186,7 +80,7 @@ public: operator Common::Point() const; // Extraction from data streams - friend RMDataStream &operator>>(RMDataStream &ds, RMPoint &p); + void readFromStream(Common::ReadStream &ds); }; class RMPointReference { @@ -256,7 +150,7 @@ public: } // Extract from data stream - friend RMDataStream &operator>>(RMDataStream &ds, RMRect &rc); + void readFromStream(Common::ReadStream &ds); }; /** -- cgit v1.2.3 From 23638a07d34c9d4c30e0b4e65b419c7862853e24 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Tue, 28 Aug 2012 17:19:00 +0200 Subject: TONY: Fix crash with TA_PERORATE. --- engines/tony/game.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'engines') diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 1ba8094ac4..e832b9687e 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -1537,6 +1537,11 @@ void RMPointer::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim _ctx->n = _nCurPointer; if (_ctx->n == TA_COMBINE) _ctx->n = TA_USE; + // WORKAROUND: updateCursor gets called too early sometimes (for example, when + // the cursor is released over the TA_PERORATE option), via setAction. + if (_ctx->n > 4) + _ctx->n = 0; + _cursorHotspot = _hotspot[_ctx->n]; // Call the Draw method of the pointer -- cgit v1.2.3 From 9ebbeda949c0a4da2c5a3ecb588a718bb867c0d4 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Tue, 28 Aug 2012 20:25:48 +0200 Subject: TONY: Implement some forgotten sound/music functions. --- engines/tony/tony.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index b9d12beb11..05c195f8ba 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -518,13 +518,28 @@ void TonyEngine::closeMusic() { } void TonyEngine::pauseSound(bool bPause) { + _theEngine.pauseSound(bPause); + + for (uint i = 0; i < 6; i++) + if (_stream[i]) + _stream[i]->pause(bPause); + + for (uint i = 0; i < MAX_SFX_CHANNELS; i++) { + if (_sfx[i]) + _sfx[i]->pause(bPause); + if (_utilSfx[i]) + _utilSfx[i]->pause(bPause); + } } void TonyEngine::setMusicVolume(int nChannel, int volume) { + _stream[nChannel + GLOBALS._flipflop]->setVolume(volume); } int TonyEngine::getMusicVolume(int nChannel) { - return 255; + int volume; + _stream[nChannel + GLOBALS._flipflop]->getVolume(&volume); + return volume; } Common::String TonyEngine::getSaveStateFileName(int n) { -- cgit v1.2.3 From 3c986af9ce531f4d9cab889b196991be14cb88f6 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Tue, 28 Aug 2012 22:10:10 +0200 Subject: TONY: Remove unnecessary mainloop mutex. Also, all the related freeze functions/members. --- engines/tony/adv.h | 2 -- engines/tony/custom.cpp | 56 ++-------------------------------------------- engines/tony/font.cpp | 4 ---- engines/tony/game.cpp | 8 ------- engines/tony/gfxengine.cpp | 26 --------------------- engines/tony/gfxengine.h | 5 ----- engines/tony/globals.cpp | 3 --- engines/tony/globals.h | 3 --- engines/tony/tony.cpp | 2 -- engines/tony/tonychar.cpp | 34 ---------------------------- 10 files changed, 2 insertions(+), 141 deletions(-) (limited to 'engines') diff --git a/engines/tony/adv.h b/engines/tony/adv.h index fe1dd32eae..8e497bc1f2 100644 --- a/engines/tony/adv.h +++ b/engines/tony/adv.h @@ -67,8 +67,6 @@ enum RMTonyAction { uint32 mainLoadLocation(int nLoc, RMPoint pt, RMPoint start); void mainUnloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result); void mainLinkGraphicTask(RMGfxTask *task); -void mainFreeze(); -void mainUnfreeze(); void mainWaitFrame(CORO_PARAM); void mainShowMouse(); void mainHideMouse(); diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index c73c7dec36..593d27655d 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -374,15 +374,12 @@ DECLARE_CUSTOM_FUNCTION(CustLoadLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, ui CORO_BEGIN_CODE(_ctx); - GLOBALS.Freeze(); - GLOBALS._curChangedHotspot = 0; if (bUseStartPos != 0) GLOBALS.LoadLocation(nLoc, RMPoint(tX, tY), GLOBALS._startLocPos[nLoc]); else GLOBALS.LoadLocation(nLoc, RMPoint(tX, tY), RMPoint(-1, -1)); - GLOBALS.Unfreeze(); _ctx->h = mpalQueryDoAction(0, nLoc, 0); // On Enter? @@ -413,7 +410,6 @@ DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgStart)(CORO_PARAM, uint32 nMsg, uint32 CORO_INVOKE_2(GLOBALS.UnloadLocation, false, NULL); GLOBALS._tony->hide(); - GLOBALS.Unfreeze(); for (_ctx->i = 0; _ctx->i < _ctx->msg->numPeriods() && !GLOBALS._bSkipIdle; _ctx->i++) { _ctx->text.setInput(GLOBALS._input); @@ -474,11 +470,9 @@ DECLARE_CUSTOM_FUNCTION(ClearScreen)(CORO_PARAM, uint32, uint32, uint32, uint32) } DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgEnd)(CORO_PARAM, uint32 bNotEnableTony, uint32, uint32, uint32) { - GLOBALS.Freeze(); GLOBALS.LoadLocation(GLOBALS._fullScreenMessageLoc, RMPoint(GLOBALS._fullScreenMessagePt._x, GLOBALS._fullScreenMessagePt._y), RMPoint(-1, -1)); if (!bNotEnableTony) GLOBALS._tony->show(); - GLOBALS.Unfreeze(); MCharResetCodes(); ReapplyChangedHotspot(); @@ -514,9 +508,8 @@ DECLARE_CUSTOM_FUNCTION(CloseLocation)(CORO_PARAM, uint32, uint32, uint32, uint3 g_vm->stopMusic(4); - // On exit, unload and unfreeze + // On exit, unload CORO_INVOKE_2(GLOBALS.UnloadLocation, true, NULL); - GLOBALS.Unfreeze(); CORO_END_CODE; } @@ -557,9 +550,6 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint GLOBALS.InitWipe(2); } - GLOBALS.Unfreeze(); - - _ctx->h = mpalQueryDoAction(0, nLoc, 0); if (!GLOBALS._bNoBullsEye) { @@ -626,9 +616,7 @@ void TonyGenericTake1(CORO_PARAM, uint32 nDirection) { CORO_BEGIN_CODE(_ctx); - GLOBALS.Freeze(); GLOBALS._tony->take(nDirection, 0); - GLOBALS.Unfreeze(); if (!GLOBALS._bSkipIdle) CORO_INVOKE_0(GLOBALS._tony->waitForEndPattern); @@ -642,16 +630,12 @@ void TonyGenericTake2(CORO_PARAM, uint32 nDirection) { CORO_BEGIN_CODE(_ctx); - GLOBALS.Freeze(); GLOBALS._tony->take(nDirection, 1); - GLOBALS.Unfreeze(); if (!GLOBALS._bSkipIdle) CORO_INVOKE_0(GLOBALS._tony->waitForEndPattern); - GLOBALS.Freeze(); GLOBALS._tony->take(nDirection, 2); - GLOBALS.Unfreeze(); CORO_END_CODE; } @@ -662,9 +646,7 @@ void TonyGenericPut1(CORO_PARAM, uint32 nDirection) { CORO_BEGIN_CODE(_ctx); - GLOBALS.Freeze(); GLOBALS._tony->put(nDirection, 0); - GLOBALS.Unfreeze(); if (!GLOBALS._bSkipIdle) CORO_INVOKE_0(GLOBALS._tony->waitForEndPattern); @@ -678,16 +660,12 @@ void TonyGenericPut2(CORO_PARAM, uint32 nDirection) { CORO_BEGIN_CODE(_ctx); - GLOBALS.Freeze(); GLOBALS._tony->put(nDirection, 1); - GLOBALS.Unfreeze(); if (!GLOBALS._bSkipIdle) CORO_INVOKE_0(GLOBALS._tony->waitForEndPattern); - GLOBALS.Freeze(); GLOBALS._tony->put(nDirection, 2); - GLOBALS.Unfreeze(); CORO_END_CODE; } @@ -1250,10 +1228,8 @@ DECLARE_CUSTOM_FUNCTION(ScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, uint32 CORO_INVOKE_0(GLOBALS.WaitFrame); - GLOBALS.Freeze(); GLOBALS._loc->setScrollPosition(_ctx->pt); GLOBALS._tony->setScrollPosition(_ctx->pt); - GLOBALS.Unfreeze(); } CORO_END_CODE; @@ -1315,10 +1291,8 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui CORO_INVOKE_0(GLOBALS.WaitFrame); - GLOBALS.Freeze(); GLOBALS._loc->setScrollPosition(_ctx->pt); GLOBALS._tony->setScrollPosition(_ctx->pt); - GLOBALS.Unfreeze(); } @@ -1336,10 +1310,8 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui _ctx->pt._y = _ctx->startpt._y - _ctx->dimy; } - GLOBALS.Freeze(); GLOBALS._loc->setScrollPosition(_ctx->pt); GLOBALS._tony->setScrollPosition(_ctx->pt); - GLOBALS.Unfreeze(); CORO_END_CODE; } @@ -1392,10 +1364,8 @@ DECLARE_CUSTOM_FUNCTION(ShakeScreen)(CORO_PARAM, uint32 nScosse, uint32, uint32, while (g_vm->getTime() < _ctx->curTime + nScosse) { CORO_INVOKE_0(GLOBALS.WaitFrame); - GLOBALS.Freeze(); GLOBALS._loc->setFixedScroll(RMPoint(1 * _ctx->dirx, 1 * _ctx->diry)); GLOBALS._tony->setFixedScroll(RMPoint(1 * _ctx->dirx, 1 * _ctx->diry)); - GLOBALS.Unfreeze(); _ctx->i = g_vm->_randomSource.getRandomNumber(2); @@ -1405,10 +1375,8 @@ DECLARE_CUSTOM_FUNCTION(ShakeScreen)(CORO_PARAM, uint32 nScosse, uint32, uint32, _ctx->diry = -_ctx->diry; } - GLOBALS.Freeze(); GLOBALS._loc->setFixedScroll(RMPoint(0, 0)); GLOBALS._tony->setFixedScroll(RMPoint(0, 0)); - GLOBALS.Unfreeze(); CORO_END_CODE; } @@ -1471,16 +1439,12 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess _ctx->pt = GLOBALS._character[nChar]._item->calculatePos() - RMPoint(-60, 20) - GLOBALS._loc->scrollPosition(); if (GLOBALS._character[nChar]._startTalkPattern != 0) { - GLOBALS.Freeze(); GLOBALS._character[nChar]._item->setPattern(GLOBALS._character[nChar]._startTalkPattern); - GLOBALS.Unfreeze(); CORO_INVOKE_0(GLOBALS._character[nChar]._item->waitForEndPattern); } - GLOBALS.Freeze(); GLOBALS._character[nChar]._item->setPattern(GLOBALS._character[nChar]._talkPattern); - GLOBALS.Unfreeze(); _ctx->curVoc = SearchVoiceHeader(0, dwMessage); _ctx->voice = NULL; @@ -1551,15 +1515,11 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess } if (GLOBALS._character[nChar]._endTalkPattern != 0) { - GLOBALS.Freeze(); GLOBALS._character[nChar]._item->setPattern(GLOBALS._character[nChar]._endTalkPattern); - GLOBALS.Unfreeze(); CORO_INVOKE_0(GLOBALS._character[nChar]._item->waitForEndPattern); } - GLOBALS.Freeze(); GLOBALS._character[nChar]._item->setPattern(GLOBALS._character[nChar]._standPattern); - GLOBALS.Unfreeze(); delete _ctx->msg; CORO_END_CODE; @@ -1845,9 +1805,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg _ctx->pt = GLOBALS._character[nPers]._item->calculatePos() - RMPoint(-60, 20) - GLOBALS._loc->scrollPosition(); if (GLOBALS._character[nPers]._startTalkPattern != 0) { - GLOBALS.Freeze(); GLOBALS._character[nPers]._item->setPattern(GLOBALS._character[nPers]._startTalkPattern); - GLOBALS.Unfreeze(); CORO_INVOKE_0(GLOBALS._character[nPers]._item->waitForEndPattern); } @@ -1925,9 +1883,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg if (nPers != 0) { if (!GLOBALS._isMChar[nPers]) { if (GLOBALS._character[nPers]._endTalkPattern != 0) { - GLOBALS.Freeze(); GLOBALS._character[nPers]._item->setPattern(GLOBALS._character[nPers]._endTalkPattern); - GLOBALS.Unfreeze(); CORO_INVOKE_0(GLOBALS._character[nPers]._item->waitForEndPattern); } @@ -2023,9 +1979,7 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr while (!(GLOBALS._input->mouseLeftClicked() && ((_ctx->sel = _ctx->dc.getSelection()) != -1))) { CORO_INVOKE_0(GLOBALS.WaitFrame); - GLOBALS.Freeze(); CORO_INVOKE_1(_ctx->dc.doFrame, GLOBALS._input->mousePos()); - GLOBALS.Unfreeze(); } // Hide the pointer @@ -2298,7 +2252,7 @@ DECLARE_CUSTOM_FUNCTION(MustSkipIdleEnd)(CORO_PARAM, uint32, uint32, uint32, uin } DECLARE_CUSTOM_FUNCTION(PatIrqFreeze)(CORO_PARAM, uint32 bStatus, uint32, uint32, uint32) { - GLOBALS._bPatIrqFreeze = bStatus; + // Unused in ScummVM. } DECLARE_CUSTOM_FUNCTION(OpenInitLoadMenu)(CORO_PARAM, uint32, uint32, uint32, uint32) { @@ -2307,9 +2261,7 @@ DECLARE_CUSTOM_FUNCTION(OpenInitLoadMenu)(CORO_PARAM, uint32, uint32, uint32, ui CORO_BEGIN_CODE(_ctx); - GLOBALS.Freeze(); CORO_INVOKE_0(g_vm->openInitLoadMenu); - GLOBALS.Unfreeze(); CORO_END_CODE; } @@ -2320,9 +2272,7 @@ DECLARE_CUSTOM_FUNCTION(OpenInitOptions)(CORO_PARAM, uint32, uint32, uint32, uin CORO_BEGIN_CODE(_ctx); - GLOBALS.Freeze(); CORO_INVOKE_0(g_vm->openInitOptions); - GLOBALS.Unfreeze(); CORO_END_CODE; } @@ -2575,8 +2525,6 @@ void setupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation GLOBALS.LoadLocation = mainLoadLocation; GLOBALS.UnloadLocation = mainUnloadLocation; GLOBALS.LinkGraphicTask = mainLinkGraphicTask; - GLOBALS.Freeze = mainFreeze; - GLOBALS.Unfreeze = mainUnfreeze; GLOBALS.WaitFrame = mainWaitFrame; GLOBALS.PlayMusic = mainPlayMusic; GLOBALS.InitWipe = mainInitWipe; diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 41dfa1f7bf..ece418d9a8 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -1072,10 +1072,8 @@ void RMDialogChoice::show(CORO_PARAM, RMGfxTargetBuffer *bigBuf) { _ctx->elaps = 0; while (_ctx->elaps < 700) { CORO_INVOKE_0(mainWaitFrame); - mainFreeze(); _ctx->elaps = g_vm->getTime() - _ctx->starttime; _ptDrawPos._y = 480 - ((_ctx->deltay * 100) / 700 * _ctx->elaps) / 100; - mainUnfreeze(); } _ptDrawPos._y = _ctx->destpt._y; @@ -1116,10 +1114,8 @@ void RMDialogChoice::hide(CORO_PARAM) { _ctx->elaps = 0; while (_ctx->elaps < 700) { CORO_INVOKE_0(mainWaitFrame); - mainFreeze(); _ctx->elaps = g_vm->getTime() - _ctx->starttime; _ptDrawPos._y = 480 - ((_ctx->deltay * 100) / 700 * (700 - _ctx->elaps)) / 100; - mainUnfreeze(); } } diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index e832b9687e..1958adfaa0 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -59,14 +59,6 @@ void mainLinkGraphicTask(RMGfxTask *task) { g_vm->getEngine()->linkGraphicTask(task); } -void mainFreeze() { - g_vm->getEngine()->freeze(); -} - -void mainUnfreeze() { - g_vm->getEngine()->unfreeze(); -} - void mainWaitFrame(CORO_PARAM) { CoroScheduler.waitForSingleObject(coroParam, g_vm->_hEndOfFrame, CORO_INFINITE); } diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index e8a5df29e9..da8218fa99 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -65,7 +65,6 @@ RMGfxEngine::RMGfxEngine() { _bigBuf.offsetY(RM_SKIPY); _bigBuf.setTrackDirtyRects(true); - _csMainLoop = NULL; _nCurLoc = 0; _curAction = TA_GOTO; _curActionObj = 0; @@ -86,7 +85,6 @@ RMGfxEngine::RMGfxEngine() { RMGfxEngine::~RMGfxEngine() { // Close the buffer _bigBuf.destroy(); - g_system->deleteMutex(_csMainLoop); } void RMGfxEngine::openOptionScreen(CORO_PARAM, int type) { @@ -144,8 +142,6 @@ void RMGfxEngine::doFrame(CORO_PARAM, bool bDrawLocation) { CORO_BEGIN_CODE(_ctx); - g_system->lockMutex(_csMainLoop); - // Poll of input devices _input.poll(); @@ -350,8 +346,6 @@ SKIPCLICKSINISTRO: } } - g_system->unlockMutex(_csMainLoop); - CORO_END_CODE; } @@ -367,11 +361,7 @@ void RMGfxEngine::itemIrq(uint32 dwItem, int nPattern, int nStatus) { item = GLOBALS._gfxEngine->_loc.getItemFromCode(dwItem); if (item != NULL) { if (nPattern != -1) { - if (GLOBALS._bPatIrqFreeze) - mainFreeze(); item->setPattern(nPattern, true); - if (GLOBALS._bPatIrqFreeze) - mainUnfreeze(); } if (nStatus != -1) item->setStatus(nStatus); @@ -454,8 +444,6 @@ void RMGfxEngine::unloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result) { CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->h, CORO_INFINITE); } - mainFreeze(); - _bLocationLoaded = false; _bigBuf.clearOT(); @@ -482,8 +470,6 @@ void RMGfxEngine::init() { g_vm->_window.getNewFrame(*this, NULL); g_vm->_window.repaint(); - GLOBALS._bPatIrqFreeze = true; - // Activate GUI _bGUIOption = true; _bGUIInterface = true; @@ -496,9 +482,6 @@ void RMGfxEngine::init() { _bWiping = false; _hWipeEvent = CoroScheduler.createEvent(false, false); - // Create the freeze event - _csMainLoop = g_system->createMutex(); - // Initialize the IRQ function for items for MPAL GLOBALS._gfxEngine = this; mpalInstallItemIrq(itemIrq); @@ -549,14 +532,6 @@ void RMGfxEngine::disableMouse() { _bAlwaysDrawMouse = false; } -void RMGfxEngine::freeze() { - g_system->lockMutex(_csMainLoop); -} - -void RMGfxEngine::unfreeze() { - g_system->unlockMutex(_csMainLoop); -} - void CharsSaveAll(Common::OutSaveFile *f); void CharsLoadAll(Common::InSaveFile *f); void MCharResetCodes(); @@ -812,7 +787,6 @@ void RMGfxEngine::loadState(CORO_PARAM, const Common::String &fn) { CORO_INVOKE_2(unloadLocation, false, NULL); loadLocation(_ctx->loc, _ctx->tp, RMPoint(-1, -1)); _tony.setPattern(RMTony::PAT_STANDRIGHT); - mainUnfreeze(); // On older versions, need to an enter action if (_ctx->ver < 5) diff --git a/engines/tony/gfxengine.h b/engines/tony/gfxengine.h index 7206496aaa..2e22e1ca62 100644 --- a/engines/tony/gfxengine.h +++ b/engines/tony/gfxengine.h @@ -63,7 +63,6 @@ private: int _nCurLoc; RMTonyAction _curAction; int _curActionObj; - OSystem::MutexRef _csMainLoop; int _nWipeType; uint32 _hWipeEvent; @@ -126,10 +125,6 @@ public: void unloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result); int getCurrentLocation() const { return _nCurLoc; } - // Freeze and unfreeze - void freeze(); - void unfreeze(); - // State management void saveState(const Common::String &fn, byte *curThumb, const Common::String &name); void loadState(CORO_PARAM, const Common::String &fn); diff --git a/engines/tony/globals.cpp b/engines/tony/globals.cpp index dd35d8c5ec..50ae2e529a 100644 --- a/engines/tony/globals.cpp +++ b/engines/tony/globals.cpp @@ -44,8 +44,6 @@ Globals::Globals() { LoadLocation = NULL; UnloadLocation = NULL; LinkGraphicTask = NULL; - Freeze = NULL; - Unfreeze = NULL; WaitFrame = NULL; PlayMusic = NULL; WaitWipeEnd = NULL; @@ -58,7 +56,6 @@ Globals::Globals() { _dwTonyNumTexts = 0; _bTonyInTexts = false; _bStaticTalk = false; - _bPatIrqFreeze = false; _bAlwaysDisplay = false; _bIdleExited = false; _bSkipSfxNoLoop = false; diff --git a/engines/tony/globals.h b/engines/tony/globals.h index 483ced1817..19276237c2 100644 --- a/engines/tony/globals.h +++ b/engines/tony/globals.h @@ -191,7 +191,6 @@ public: RMTextDialog *_curBackText; bool _bTonyIsSpeaking; int _curChangedHotspot; - bool _bPatIrqFreeze; bool _bCfgInvLocked; bool _bCfgInvNoScroll; bool _bCfgTimerizedText; @@ -227,8 +226,6 @@ public: uint32(*LoadLocation)(int, RMPoint, RMPoint start); void (*UnloadLocation)(CORO_PARAM, bool bDoOnExit, uint32 *result); void (*LinkGraphicTask)(RMGfxTask *task); - void (*Freeze)(); - void (*Unfreeze)(); void (*WaitFrame)(CORO_PARAM); void (*PlayMusic)(int nChannel, const char *fileName, int nFX, bool bLoop, int nSync); void (*WaitWipeEnd)(CORO_PARAM); diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 05c195f8ba..18eccf4615 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -556,10 +556,8 @@ void TonyEngine::autoSave(CORO_PARAM) { grabThumbnail(); CORO_INVOKE_0(mainWaitFrame); CORO_INVOKE_0(mainWaitFrame); - mainFreeze(); _ctx->buf = getSaveStateFileName(0); _theEngine.saveState(_ctx->buf, (byte *)_curThumbnail, "Autosave"); - mainUnfreeze(); CORO_END_CODE; } diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index 9caa10bd46..c80203fae2 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -589,7 +589,6 @@ bool RMTony::startTalkCalculate(CharacterTalkType nTalkType, int &headStartPat, if (_bShepherdess) { // Talking whilst a shepherdess - mainFreeze(); switch (_talkDirection) { case UP: setPattern(PAT_PAST_TALKUP); @@ -607,7 +606,6 @@ bool RMTony::startTalkCalculate(CharacterTalkType nTalkType, int &headStartPat, setPattern(PAT_PAST_TALKRIGHT); break; } - mainUnfreeze(); return false; } @@ -1118,10 +1116,8 @@ void RMTony::startTalk(CORO_PARAM, CharacterTalkType nTalkType) { // Perform the set pattern if (_ctx->headStartPat != 0 || _ctx->bodyStartPat != 0) { - mainFreeze(); setPattern(_ctx->headStartPat); _body.setPattern(_ctx->bodyStartPat); - mainUnfreeze(); if (_ctx->bodyStartPat != 0) CORO_INVOKE_0(_body.waitForEndPattern); @@ -1129,11 +1125,9 @@ void RMTony::startTalk(CORO_PARAM, CharacterTalkType nTalkType) { CORO_INVOKE_0(waitForEndPattern); } - mainFreeze(); setPattern(_ctx->headLoopPat); if (_ctx->bodyLoopPat) _body.setPattern(_ctx->bodyLoopPat); - mainUnfreeze(); CORO_END_CODE; } @@ -1166,9 +1160,7 @@ bool RMTony::endTalkCalculate(int &headStandPat, int &headEndPat, int &bodyEndPa } if (_bShepherdess) { - mainFreeze(); setPattern(finalPat); - mainUnfreeze(); _bIsTalking = false; return false; } @@ -1437,7 +1429,6 @@ void RMTony::endTalk(CORO_PARAM) { // Handles the end of an animated and static, leaving everything unchanged if (_bIsStaticTalk) { if (_nTalkType == TALK_WITHBEARDSTATIC) { - mainFreeze(); setPattern(0); if (_talkDirection == UP || _talkDirection == LEFT) { _body.setPattern(BPAT_WITHBEARDLEFT_STATIC); @@ -1446,11 +1437,8 @@ void RMTony::endTalk(CORO_PARAM) { _body.setPattern(BPAT_WITHBEARDRIGHT_STATIC); _nBodyOffset.set(-26, -14); } - mainUnfreeze(); } else { - mainFreeze(); setPattern(_ctx->headStandPat); - mainUnfreeze(); CORO_INVOKE_0(_body.waitForEndPattern); } @@ -1461,36 +1449,26 @@ void RMTony::endTalk(CORO_PARAM) { // Set the pattern if (_ctx->headEndPat != 0 && _ctx->bodyEndPat != 0) { - mainFreeze(); setPattern(_ctx->headEndPat); - mainUnfreeze(); CORO_INVOKE_0(_body.waitForEndPattern); - mainFreeze(); _body.setPattern(_ctx->bodyEndPat); - mainUnfreeze(); CORO_INVOKE_0(waitForEndPattern); CORO_INVOKE_0(_body.waitForEndPattern); } else if (_ctx->bodyEndPat != 0) { - mainFreeze(); setPattern(_ctx->headStandPat); - mainUnfreeze(); CORO_INVOKE_0(_body.waitForEndPattern); - mainFreeze(); _body.setPattern(_ctx->bodyEndPat); - mainUnfreeze(); CORO_INVOKE_0(_body.waitForEndPattern); } else if (_ctx->headEndPat != 0) { CORO_INVOKE_0(_body.waitForEndPattern); - mainFreeze(); setPattern(_ctx->headEndPat); - mainUnfreeze(); CORO_INVOKE_0(waitForEndPattern); } else { @@ -1498,10 +1476,8 @@ void RMTony::endTalk(CORO_PARAM) { } if (_ctx->finalPat != 0) { - mainFreeze(); _body.setPattern(0); setPattern(_ctx->finalPat); - mainUnfreeze(); } _bIsTalking = false; @@ -1733,19 +1709,15 @@ void RMTony::startStatic(CORO_PARAM, CharacterTalkType nTalk) { // e vai con i pattern _bIsStaticTalk = true; - mainFreeze(); setPattern(_ctx->headPat); _body.setPattern(_ctx->bodyStartPat); - mainUnfreeze(); CORO_INVOKE_0(_body.waitForEndPattern); CORO_INVOKE_0(waitForEndPattern); - mainFreeze(); if (_ctx->headLoopPat != -1) setPattern(_ctx->headLoopPat); _body.setPattern(_ctx->bodyLoopPat); - mainUnfreeze(); CORO_END_CODE; } @@ -1902,24 +1874,18 @@ void RMTony::endStatic(CORO_PARAM, CharacterTalkType nTalk) { endStaticCalculate(nTalk, _ctx->bodyEndPat, _ctx->finalPat, _ctx->headEndPat); if (_ctx->headEndPat != 0) { - mainFreeze(); setPattern(_ctx->headEndPat); - mainUnfreeze(); CORO_INVOKE_0(waitForEndPattern); } else { // Play please - mainFreeze(); _body.setPattern(_ctx->bodyEndPat); - mainUnfreeze(); CORO_INVOKE_0(_body.waitForEndPattern); } - mainFreeze(); setPattern(_ctx->finalPat); _body.setPattern(0); - mainUnfreeze(); _bIsStaticTalk = false; -- cgit v1.2.3 From 142ac7600f61e193612ec81c7fd7070ec2ca5c0e Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Tue, 28 Aug 2012 22:28:44 +0200 Subject: TONY: Remove most of the remaining global functions. --- engines/tony/adv.h | 13 ------- engines/tony/custom.cpp | 87 +++++++++++++++++++++-------------------------- engines/tony/debugger.cpp | 4 +-- engines/tony/font.cpp | 4 +-- engines/tony/game.cpp | 52 ---------------------------- engines/tony/globals.cpp | 9 ----- engines/tony/globals.h | 9 ----- engines/tony/loc.cpp | 4 +-- engines/tony/tony.cpp | 4 +-- 9 files changed, 47 insertions(+), 139 deletions(-) (limited to 'engines') diff --git a/engines/tony/adv.h b/engines/tony/adv.h index 8e497bc1f2..e3171aa3ee 100644 --- a/engines/tony/adv.h +++ b/engines/tony/adv.h @@ -64,21 +64,8 @@ enum RMTonyAction { }; // Global Functions -uint32 mainLoadLocation(int nLoc, RMPoint pt, RMPoint start); -void mainUnloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result); -void mainLinkGraphicTask(RMGfxTask *task); -void mainWaitFrame(CORO_PARAM); -void mainShowMouse(); -void mainHideMouse(); -void mainEnableInput(); -void mainDisableInput(); -void mainPlayMusic(int nChannel, const char *filename, int nFX, bool bLoop, int nSync); -void mainInitWipe(int type); -void mainCloseWipe(); -void mainWaitWipeEnd(CORO_PARAM); void mainEnableGUI(); void mainDisableGUI(); -void mainSetPerorate(bool bPerorate); } // End of namespace Tony diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 593d27655d..27de5cf717 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -186,7 +186,7 @@ DECLARE_CUSTOM_FUNCTION(RightToMe)(CORO_PARAM, uint32, uint32, uint32, uint32) { DECLARE_CUSTOM_FUNCTION(TonySetPerorate)(CORO_PARAM, uint32 bStatus, uint32, uint32, uint32) { - GLOBALS.SetPerorate(bStatus); + g_vm->getEngine()->setPerorate(bStatus); } DECLARE_CUSTOM_FUNCTION(MySleep)(CORO_PARAM, uint32 dwTime, uint32, uint32, uint32) { @@ -324,7 +324,7 @@ DECLARE_CUSTOM_FUNCTION(SendTonyMessage)(CORO_PARAM, uint32 dwMessage, uint32 nX } // Record the text - GLOBALS.LinkGraphicTask(&_ctx->text); + g_vm->getEngine()->linkGraphicTask(&_ctx->text); if (_ctx->curVoc) { if (_ctx->i == 0) { @@ -376,9 +376,9 @@ DECLARE_CUSTOM_FUNCTION(CustLoadLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, ui GLOBALS._curChangedHotspot = 0; if (bUseStartPos != 0) - GLOBALS.LoadLocation(nLoc, RMPoint(tX, tY), GLOBALS._startLocPos[nLoc]); + g_vm->getEngine()->loadLocation(nLoc, RMPoint(tX, tY), GLOBALS._startLocPos[nLoc]); else - GLOBALS.LoadLocation(nLoc, RMPoint(tX, tY), RMPoint(-1, -1)); + g_vm->getEngine()->loadLocation(nLoc, RMPoint(tX, tY), RMPoint(-1, -1)); _ctx->h = mpalQueryDoAction(0, nLoc, 0); @@ -408,7 +408,7 @@ DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgStart)(CORO_PARAM, uint32 nMsg, uint32 if (GLOBALS._bSkipIdle) return; - CORO_INVOKE_2(GLOBALS.UnloadLocation, false, NULL); + CORO_INVOKE_2(g_vm->getEngine()->unloadLocation, false, NULL); GLOBALS._tony->hide(); for (_ctx->i = 0; _ctx->i < _ctx->msg->numPeriods() && !GLOBALS._bSkipIdle; _ctx->i++) { @@ -436,8 +436,8 @@ DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgStart)(CORO_PARAM, uint32 nMsg, uint32 _ctx->text.forceTime(); // Record the text - GLOBALS.LinkGraphicTask(&_ctx->clear); - GLOBALS.LinkGraphicTask(&_ctx->text); + g_vm->getEngine()->linkGraphicTask(&_ctx->clear); + g_vm->getEngine()->linkGraphicTask(&_ctx->text); // Wait for the end of display _ctx->text.setCustomSkipHandle(GLOBALS._hSkipIdle); @@ -457,20 +457,20 @@ DECLARE_CUSTOM_FUNCTION(ClearScreen)(CORO_PARAM, uint32, uint32, uint32, uint32) CORO_BEGIN_CODE(_ctx); - GLOBALS.LinkGraphicTask(&_ctx->clear); + g_vm->getEngine()->linkGraphicTask(&_ctx->clear); - CORO_INVOKE_0(GLOBALS.WaitFrame); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, g_vm->_hEndOfFrame, CORO_INFINITE); // WORKAROUND: This fixes a bug in the original source where the linked clear task // didn't have time to be drawn and removed from the draw list before the method // ended, thus remaining in the draw list and causing a later crash - CORO_INVOKE_0(GLOBALS.WaitFrame); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, g_vm->_hEndOfFrame, CORO_INFINITE); CORO_END_CODE; } DECLARE_CUSTOM_FUNCTION(SendFullscreenMsgEnd)(CORO_PARAM, uint32 bNotEnableTony, uint32, uint32, uint32) { - GLOBALS.LoadLocation(GLOBALS._fullScreenMessageLoc, RMPoint(GLOBALS._fullScreenMessagePt._x, GLOBALS._fullScreenMessagePt._y), RMPoint(-1, -1)); + g_vm->getEngine()->loadLocation(GLOBALS._fullScreenMessageLoc, RMPoint(GLOBALS._fullScreenMessagePt._x, GLOBALS._fullScreenMessagePt._y), RMPoint(-1, -1)); if (!bNotEnableTony) GLOBALS._tony->show(); @@ -502,14 +502,14 @@ DECLARE_CUSTOM_FUNCTION(CloseLocation)(CORO_PARAM, uint32, uint32, uint32, uint3 CORO_BEGIN_CODE(_ctx); if (!GLOBALS._bNoBullsEye) { - GLOBALS.InitWipe(1); - CORO_INVOKE_0(GLOBALS.WaitWipeEnd); + g_vm->getEngine()->initWipe(1); + CORO_INVOKE_0(g_vm->getEngine()->waitWipeEnd); } g_vm->stopMusic(4); // On exit, unload - CORO_INVOKE_2(GLOBALS.UnloadLocation, true, NULL); + CORO_INVOKE_2(g_vm->getEngine()->unloadLocation, true, NULL); CORO_END_CODE; } @@ -523,8 +523,8 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint CORO_BEGIN_CODE(_ctx); if (!GLOBALS._bNoBullsEye) { - GLOBALS.InitWipe(1); - CORO_INVOKE_0(GLOBALS.WaitWipeEnd); + g_vm->getEngine()->initWipe(1); + CORO_INVOKE_0(g_vm->getEngine()->waitWipeEnd); } if (GLOBALS._lastTappeto != GLOBALS._ambiance[nLoc]) { @@ -532,13 +532,13 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint } // On exit, unfreeze - CORO_INVOKE_2(GLOBALS.UnloadLocation, true, NULL); + CORO_INVOKE_2(g_vm->getEngine()->unloadLocation, true, NULL); GLOBALS._curChangedHotspot = 0; if (bUseStartPos != 0) - GLOBALS.LoadLocation(nLoc, RMPoint(tX, tY), GLOBALS._startLocPos[nLoc]); + g_vm->getEngine()->loadLocation(nLoc, RMPoint(tX, tY), GLOBALS._startLocPos[nLoc]); else - GLOBALS.LoadLocation(nLoc, RMPoint(tX, tY), RMPoint(-1, -1)); + g_vm->getEngine()->loadLocation(nLoc, RMPoint(tX, tY), RMPoint(-1, -1)); if (GLOBALS._lastTappeto != GLOBALS._ambiance[nLoc]) { GLOBALS._lastTappeto = GLOBALS._ambiance[nLoc]; @@ -547,14 +547,14 @@ DECLARE_CUSTOM_FUNCTION(ChangeLocation)(CORO_PARAM, uint32 nLoc, uint32 tX, uint } if (!GLOBALS._bNoBullsEye) { - GLOBALS.InitWipe(2); + g_vm->getEngine()->initWipe(2); } _ctx->h = mpalQueryDoAction(0, nLoc, 0); if (!GLOBALS._bNoBullsEye) { - CORO_INVOKE_0(GLOBALS.WaitWipeEnd); - GLOBALS.CloseWipe(); + CORO_INVOKE_0(g_vm->getEngine()->waitWipeEnd); + g_vm->getEngine()->closeWipe(); } GLOBALS._bNoBullsEye = false; @@ -589,11 +589,11 @@ DECLARE_CUSTOM_FUNCTION(RestoreTonyPosition)(CORO_PARAM, uint32, uint32, uint32, } DECLARE_CUSTOM_FUNCTION(DisableInput)(CORO_PARAM, uint32, uint32, uint32, uint32) { - mainDisableInput(); + g_vm->getEngine()->disableInput(); } DECLARE_CUSTOM_FUNCTION(EnableInput)(CORO_PARAM, uint32, uint32, uint32, uint32) { - mainEnableInput(); + g_vm->getEngine()->enableInput(); } DECLARE_CUSTOM_FUNCTION(StopTony)(CORO_PARAM, uint32, uint32, uint32, uint32) { @@ -1226,7 +1226,7 @@ DECLARE_CUSTOM_FUNCTION(ScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, uint32 _ctx->pt.offset(0, -(int32)sY); } - CORO_INVOKE_0(GLOBALS.WaitFrame); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, g_vm->_hEndOfFrame, CORO_INFINITE); GLOBALS._loc->setScrollPosition(_ctx->pt); GLOBALS._tony->setScrollPosition(_ctx->pt); @@ -1289,7 +1289,7 @@ DECLARE_CUSTOM_FUNCTION(SyncScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, ui } - CORO_INVOKE_0(GLOBALS.WaitFrame); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, g_vm->_hEndOfFrame, CORO_INFINITE); GLOBALS._loc->setScrollPosition(_ctx->pt); GLOBALS._tony->setScrollPosition(_ctx->pt); @@ -1362,7 +1362,7 @@ DECLARE_CUSTOM_FUNCTION(ShakeScreen)(CORO_PARAM, uint32 nScosse, uint32, uint32, _ctx->diry = 1; while (g_vm->getTime() < _ctx->curTime + nScosse) { - CORO_INVOKE_0(GLOBALS.WaitFrame); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, g_vm->_hEndOfFrame, CORO_INFINITE); GLOBALS._loc->setFixedScroll(RMPoint(1 * _ctx->dirx, 1 * _ctx->diry)); GLOBALS._tony->setFixedScroll(RMPoint(1 * _ctx->dirx, 1 * _ctx->diry)); @@ -1486,7 +1486,7 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess } // Record the text - GLOBALS.LinkGraphicTask(_ctx->text); + g_vm->getEngine()->linkGraphicTask(_ctx->text); if (_ctx->curVoc) { g_vm->_theSound.createSfx(&_ctx->voice); @@ -1695,7 +1695,7 @@ DECLARE_CUSTOM_FUNCTION(MCharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMes } // Record the text - GLOBALS.LinkGraphicTask(_ctx->text); + g_vm->getEngine()->linkGraphicTask(_ctx->text); if (_ctx->curVoc) { g_vm->_theSound.createSfx(&_ctx->voice); @@ -1862,7 +1862,7 @@ DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg _ctx->text->forceTime(); } _ctx->text->setAlignType(RMText::HCENTER, RMText::VBOTTOM); - GLOBALS.LinkGraphicTask(_ctx->text); + g_vm->getEngine()->linkGraphicTask(_ctx->text); if (_ctx->curVoc) { _ctx->voice->play(); @@ -1970,20 +1970,20 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr } // Activate the object - GLOBALS.LinkGraphicTask(&_ctx->dc); + g_vm->getEngine()->linkGraphicTask(&_ctx->dc); CORO_INVOKE_0(_ctx->dc.show); // Draw the pointer GLOBALS._pointer->setSpecialPointer(GLOBALS._pointer->PTR_NONE); - mainShowMouse(); + g_vm->getEngine()->enableMouse(); while (!(GLOBALS._input->mouseLeftClicked() && ((_ctx->sel = _ctx->dc.getSelection()) != -1))) { - CORO_INVOKE_0(GLOBALS.WaitFrame); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, g_vm->_hEndOfFrame, CORO_INFINITE); CORO_INVOKE_1(_ctx->dc.doFrame, GLOBALS._input->mousePos()); } // Hide the pointer - mainHideMouse(); + g_vm->getEngine()->disableMouse(); CORO_INVOKE_0(_ctx->dc.hide); mpalQueryDialogSelectionDWORD(_ctx->nChoice, _ctx->sl[_ctx->sel]); @@ -2158,7 +2158,7 @@ void CustPlayMusic(uint32 nChannel, const char *mFN, uint32 nFX, bool bLoop, int if (nSync == 0) nSync = 2000; debugC(DEBUG_INTERMEDIATE, kTonyDebugMusic, "Start CustPlayMusic"); - GLOBALS.PlayMusic(nChannel, mFN, nFX, bLoop, nSync); + g_vm->playMusic(nChannel, mFN, nFX, bLoop, nSync); debugC(DEBUG_INTERMEDIATE, kTonyDebugMusic, "End CustPlayMusic"); } @@ -2324,13 +2324,13 @@ DECLARE_CUSTOM_FUNCTION(DoCredits)(CORO_PARAM, uint32 nMsg, uint32 dwTime, uint3 _ctx->text[_ctx->i].setCustomSkipHandle(_ctx->hDisable); // Record the text - GLOBALS.LinkGraphicTask(&_ctx->text[_ctx->i]); + g_vm->getEngine()->linkGraphicTask(&_ctx->text[_ctx->i]); } _ctx->startTime = g_vm->getTime(); while (_ctx->startTime + dwTime * 1000 > g_vm->getTime()) { - CORO_INVOKE_0(GLOBALS.WaitFrame); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, g_vm->_hEndOfFrame, CORO_INFINITE); if (GLOBALS._input->mouseLeftClicked() || GLOBALS._input->mouseRightClicked()) break; if (g_vm->getEngine()->getInput().getAsyncKeyState(Common::KEYCODE_TAB)) @@ -2339,8 +2339,8 @@ DECLARE_CUSTOM_FUNCTION(DoCredits)(CORO_PARAM, uint32 nMsg, uint32 dwTime, uint3 CoroScheduler.setEvent(_ctx->hDisable); - CORO_INVOKE_0(GLOBALS.WaitFrame); - CORO_INVOKE_0(GLOBALS.WaitFrame); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, g_vm->_hEndOfFrame, CORO_INFINITE); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, g_vm->_hEndOfFrame, CORO_INFINITE); delete[] _ctx->text; delete _ctx->msg; @@ -2522,17 +2522,8 @@ void setupGlobalVars(RMTony *tony, RMPointer *ptr, RMGameBoxes *box, RMLocation GLOBALS._inventory = inv; GLOBALS._input = input; - GLOBALS.LoadLocation = mainLoadLocation; - GLOBALS.UnloadLocation = mainUnloadLocation; - GLOBALS.LinkGraphicTask = mainLinkGraphicTask; - GLOBALS.WaitFrame = mainWaitFrame; - GLOBALS.PlayMusic = mainPlayMusic; - GLOBALS.InitWipe = mainInitWipe; - GLOBALS.CloseWipe = mainCloseWipe; - GLOBALS.WaitWipeEnd = mainWaitWipeEnd; GLOBALS.DisableGUI = mainDisableGUI; GLOBALS.EnableGUI = mainEnableGUI; - GLOBALS.SetPerorate = mainSetPerorate; GLOBALS._bAlwaysDisplay = false; int i; diff --git a/engines/tony/debugger.cpp b/engines/tony/debugger.cpp index 6355284ece..85d9469519 100644 --- a/engines/tony/debugger.cpp +++ b/engines/tony/debugger.cpp @@ -68,9 +68,9 @@ void DebugChangeScene(CORO_PARAM, const void *param) { CORO_BEGIN_CODE(_ctx); - CORO_INVOKE_2(GLOBALS.UnloadLocation, false, &result); + CORO_INVOKE_2(g_vm->getEngine()->unloadLocation, false, &result); - GLOBALS.LoadLocation(details->sceneNumber, scenePos, RMPoint(-1, -1)); + g_vm->getEngine()->loadLocation(details->sceneNumber, scenePos, RMPoint(-1, -1)); mainEnableGUI(); diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index ece418d9a8..89cf2ffa1b 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -1071,7 +1071,7 @@ void RMDialogChoice::show(CORO_PARAM, RMGfxTargetBuffer *bigBuf) { _ctx->elaps = 0; while (_ctx->elaps < 700) { - CORO_INVOKE_0(mainWaitFrame); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, g_vm->_hEndOfFrame, CORO_INFINITE); _ctx->elaps = g_vm->getTime() - _ctx->starttime; _ptDrawPos._y = 480 - ((_ctx->deltay * 100) / 700 * _ctx->elaps) / 100; } @@ -1113,7 +1113,7 @@ void RMDialogChoice::hide(CORO_PARAM) { _ctx->deltay = 480 - _ptDrawPos._y; _ctx->elaps = 0; while (_ctx->elaps < 700) { - CORO_INVOKE_0(mainWaitFrame); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, g_vm->_hEndOfFrame, CORO_INFINITE); _ctx->elaps = g_vm->getTime() - _ctx->starttime; _ptDrawPos._y = 480 - ((_ctx->deltay * 100) / 700 * (700 - _ctx->elaps)) / 100; } diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 1958adfaa0..00c0a1ad7a 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -47,54 +47,6 @@ using namespace MPAL; /* Global functions */ /****************************************/ -uint32 mainLoadLocation(int nLoc, RMPoint pt, RMPoint start) { - return g_vm->getEngine()->loadLocation(nLoc, pt, start); -} - -void mainUnloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result) { - g_vm->getEngine()->unloadLocation(coroParam, bDoOnExit, result); -} - -void mainLinkGraphicTask(RMGfxTask *task) { - g_vm->getEngine()->linkGraphicTask(task); -} - -void mainWaitFrame(CORO_PARAM) { - CoroScheduler.waitForSingleObject(coroParam, g_vm->_hEndOfFrame, CORO_INFINITE); -} - -void mainShowMouse() { - g_vm->getEngine()->enableMouse(); -} - -void mainHideMouse() { - g_vm->getEngine()->disableMouse(); -} - -void mainPlayMusic(int nChannel, const char *filename, int nFX, bool bLoop, int nSync) { - g_vm->playMusic(nChannel, filename, nFX, bLoop, nSync); -} - -void mainDisableInput() { - g_vm->getEngine()->disableInput(); -} - -void mainEnableInput() { - g_vm->getEngine()->enableInput(); -} - -void mainInitWipe(int type) { - g_vm->getEngine()->initWipe(type); -} - -void mainCloseWipe() { - g_vm->getEngine()->closeWipe(); -} - -void mainWaitWipeEnd(CORO_PARAM) { - g_vm->getEngine()->waitWipeEnd(coroParam); -} - void mainEnableGUI() { g_vm->getEngine()->_bGUIInterface = true; g_vm->getEngine()->_bGUIInventory = true; @@ -107,10 +59,6 @@ void mainDisableGUI() { g_vm->getEngine()->_bGUIOption = false; } -void mainSetPerorate(bool bPerorate) { - g_vm->getEngine()->setPerorate(bPerorate); -} - /****************************************************************************\ * RMOptionButton Methods \****************************************************************************/ diff --git a/engines/tony/globals.cpp b/engines/tony/globals.cpp index 50ae2e529a..8e4ae240a0 100644 --- a/engines/tony/globals.cpp +++ b/engines/tony/globals.cpp @@ -41,17 +41,8 @@ Globals::Globals() { _inventory = NULL; _input = NULL; _gfxEngine = NULL; - LoadLocation = NULL; - UnloadLocation = NULL; - LinkGraphicTask = NULL; - WaitFrame = NULL; - PlayMusic = NULL; - WaitWipeEnd = NULL; - CloseWipe = NULL; - InitWipe = NULL; EnableGUI = NULL; DisableGUI = NULL; - SetPerorate = NULL; _dwTonyNumTexts = 0; _bTonyInTexts = false; diff --git a/engines/tony/globals.h b/engines/tony/globals.h index 19276237c2..e353d40f3b 100644 --- a/engines/tony/globals.h +++ b/engines/tony/globals.h @@ -223,17 +223,8 @@ public: RMInput *_input; RMGfxEngine *_gfxEngine; - uint32(*LoadLocation)(int, RMPoint, RMPoint start); - void (*UnloadLocation)(CORO_PARAM, bool bDoOnExit, uint32 *result); - void (*LinkGraphicTask)(RMGfxTask *task); - void (*WaitFrame)(CORO_PARAM); - void (*PlayMusic)(int nChannel, const char *fileName, int nFX, bool bLoop, int nSync); - void (*WaitWipeEnd)(CORO_PARAM); - void (*CloseWipe)(); - void (*InitWipe)(int type); void (*EnableGUI)(); void (*DisableGUI)(); - void (*SetPerorate)(bool bpal); uint32 _dwTonyNumTexts; bool _bTonyInTexts; diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 32c857ceaa..d8548cc570 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -808,8 +808,8 @@ void RMWipe::waitForFadeEnd(CORO_PARAM) { _bEndFade = true; _bFading = false; - CORO_INVOKE_0(mainWaitFrame); - CORO_INVOKE_0(mainWaitFrame); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, g_vm->_hEndOfFrame, CORO_INFINITE); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, g_vm->_hEndOfFrame, CORO_INFINITE); CORO_END_CODE; } diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 18eccf4615..bb28848362 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -554,8 +554,8 @@ void TonyEngine::autoSave(CORO_PARAM) { CORO_BEGIN_CODE(_ctx); grabThumbnail(); - CORO_INVOKE_0(mainWaitFrame); - CORO_INVOKE_0(mainWaitFrame); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, g_vm->_hEndOfFrame, CORO_INFINITE); + CORO_INVOKE_2(CoroScheduler.waitForSingleObject, g_vm->_hEndOfFrame, CORO_INFINITE); _ctx->buf = getSaveStateFileName(0); _theEngine.saveState(_ctx->buf, (byte *)_curThumbnail, "Autosave"); -- cgit v1.2.3 From cdeecf1521e95a8ad250bc18a398b32fd2886c36 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Tue, 28 Aug 2012 22:47:10 +0200 Subject: TONY: Replace overlapping memcpy with memmove --- engines/tony/mpal/expr.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/expr.cpp b/engines/tony/mpal/expr.cpp index eb6b485ef6..772d3da075 100644 --- a/engines/tony/mpal/expr.cpp +++ b/engines/tony/mpal/expr.cpp @@ -191,7 +191,7 @@ static void solve(LPEXPRESSION one, int num) { two = one + 1; if ((two->symbol == 0) || (one->symbol & 0xF0) <= (two->symbol & 0xF0)) { two->val.num = Compute(one->val.num, two->val.num, one->symbol); - memcpy(one, two, (num - 1) * sizeof(EXPRESSION)); + memmove(one, two, (num - 1) * sizeof(EXPRESSION)); --num; } else { j = 1; @@ -203,7 +203,7 @@ static void solve(LPEXPRESSION one, int num) { } three->val.num = Compute(two->val.num, three->val.num, two->symbol); - memcpy(two, three, (num - j - 1) * sizeof(EXPRESSION)); + memmove(two, three, (num - j - 1) * sizeof(EXPRESSION)); --num; } } -- cgit v1.2.3 From 56f4bc0225653be13813c662115b67152e78cf1a Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 28 Aug 2012 23:05:48 +0200 Subject: TONY: Fix some for and if statements with bad coding style --- engines/tony/custom.cpp | 18 +++++++---- engines/tony/game.cpp | 22 +++++++++----- engines/tony/gfxcore.cpp | 17 +++++++---- engines/tony/inventory.cpp | 3 +- engines/tony/loc.cpp | 24 ++++++++++----- engines/tony/mpal/loadmpc.cpp | 3 +- engines/tony/mpal/mpal.cpp | 70 ++++++++++++++++++++++++++++--------------- engines/tony/sound.cpp | 17 +++++++---- engines/tony/tony.cpp | 3 +- 9 files changed, 119 insertions(+), 58 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 27de5cf717..9aef809826 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -237,9 +237,10 @@ VoiceHeader *SearchVoiceHeader(uint32 codehi, uint32 codelo) { if (g_vm->_voices.size() == 0) return NULL; - for (uint i = 0; i < g_vm->_voices.size(); i++) + for (uint i = 0; i < g_vm->_voices.size(); i++) { if (g_vm->_voices[i]._code == code) return &g_vm->_voices[i]; + } return NULL; } @@ -1208,21 +1209,25 @@ DECLARE_CUSTOM_FUNCTION(ScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, uint32 while ((_ctx->lx != 0 || _ctx->ly != 0) && !GLOBALS._bSkipIdle) { if (_ctx->lx > 0) { _ctx->lx -= (int32)sX; - if (_ctx->lx < 0) _ctx->lx = 0; + if (_ctx->lx < 0) + _ctx->lx = 0; _ctx->pt.offset((int32)sX, 0); } else if (_ctx->lx < 0) { _ctx->lx += (int32)sX; - if (_ctx->lx > 0) _ctx->lx = 0; + if (_ctx->lx > 0) + _ctx->lx = 0; _ctx->pt.offset(-(int32)sX, 0); } if (_ctx->ly > 0) { _ctx->ly -= sY; - if (_ctx->ly < 0) _ctx->ly = 0; + if (_ctx->ly < 0) + _ctx->ly = 0; _ctx->pt.offset(0, sY); } else if (_ctx->ly < 0) { _ctx->ly += sY; - if (_ctx->ly > 0) _ctx->ly = 0; + if (_ctx->ly > 0) + _ctx->ly = 0; _ctx->pt.offset(0, -(int32)sY); } @@ -1493,7 +1498,8 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess g_vm->_vdbFP.seek(_ctx->curOffset); _ctx->voice->loadVoiceFromVDB(g_vm->_vdbFP); _ctx->voice->setLoop(false); - if (bIsBack) _ctx->voice->setVolume(55); + if (bIsBack) + _ctx->voice->setVolume(55); _ctx->voice->play(); _ctx->text->setCustomSkipHandle2(_ctx->voice->_hEndOfBuffer); _ctx->curOffset = g_vm->_vdbFP.pos(); diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 00c0a1ad7a..c17b611b0c 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -476,11 +476,16 @@ void RMOptionScreen::refreshAll(CORO_PARAM) { CORO_INVOKE_0(drawOT); if (_nState == MENULOAD || _nState == MENUSAVE) { - if (_ctx->thumb) delete _ctx->thumb; - if (_ctx->title) delete _ctx->title; + if (_ctx->thumb) + delete _ctx->thumb; - for (_ctx->i = 0; _ctx->i < 6; _ctx->i++) - if (_ctx->num[_ctx->i]) delete _ctx->num[_ctx->i]; + if (_ctx->title) + delete _ctx->title; + + for (_ctx->i = 0; _ctx->i < 6; _ctx->i++) { + if (_ctx->num[_ctx->i]) + delete _ctx->num[_ctx->i]; + } } CORO_END_CODE; @@ -1049,13 +1054,14 @@ void RMOptionScreen::doFrame(CORO_PARAM, RMInput *input) { } } - for (_ctx->i = 0; _ctx->i < 26 && strlen(_editName) < 12; _ctx->i++) + for (_ctx->i = 0; _ctx->i < 26 && strlen(_editName) < 12; _ctx->i++) { if (KEYPRESS(Common::KEYCODE_LSHIFT) || KEYPRESS(Common::KEYCODE_RSHIFT)) { PROCESS_CHAR((Common::KeyCode)((int)'a' + _ctx->i), _ctx->i + 'A'); } else { PROCESS_CHAR((Common::KeyCode)((int)'a' + _ctx->i), _ctx->i + 'a'); } + } for (_ctx->i = 0; _ctx->i < 10 && strlen(_editName) < 12; _ctx->i++) PROCESS_CHAR((Common::KeyCode)((int)'0' + _ctx->i), _ctx->i + '0'); @@ -1203,9 +1209,10 @@ void RMOptionScreen::doFrame(CORO_PARAM, RMInput *input) { } } - if (_nState == MENUGAME || _nState == MENUGFX || _nState == MENUSOUND) + if (_nState == MENUGAME || _nState == MENUGFX || _nState == MENUSOUND) { if (!_bQuitConfirm && KEYPRESS(Common::KEYCODE_ESCAPE)) close(); + } if (_ctx->bRefresh) CORO_INVOKE_0(refreshAll); @@ -1475,7 +1482,8 @@ void RMPointer::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim // Check the pointer _ctx->n = _nCurPointer; - if (_ctx->n == TA_COMBINE) _ctx->n = TA_USE; + if (_ctx->n == TA_COMBINE) + _ctx->n = TA_USE; // WORKAROUND: updateCursor gets called too early sometimes (for example, when // the cursor is released over the TA_PERORATE option), via setAction. diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 44befa3755..2e368bbc64 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -648,9 +648,14 @@ int RMGfxSourceBuffer8AB::calcTrasp(int fore, int back) { g = (GETGREEN(fore) >> 2) + (GETGREEN(back) >> 1); b = (GETBLUE(fore) >> 2) + (GETBLUE(back) >> 1); - if (r > 0x1F) r = 0x1F; - if (g > 0x1F) g = 0x1F; - if (b > 0x1F) b = 0x1F; + if (r > 0x1F) + r = 0x1F; + + if (g > 0x1F) + g = 0x1F; + + if (b > 0x1F) + b = 0x1F; return (r << 10) | (g << 5) | b; } @@ -1717,7 +1722,7 @@ void RMGfxSourceBuffer8AA::drawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri */ mybuf = &buf[x1]; - for (x = 0; x < width; x++, mybuf += step) + for (x = 0; x < width; x++, mybuf += step) { if (_aabuf[(y + v) * _dimx + x + u] == 2 && x != 0 && x != width - 1) { r = GETRED(mybuf[1]) + GETRED(mybuf[-1]) + GETRED(mybuf[-bigBuf.getDimx()]) + GETRED(mybuf[bigBuf.getDimx()]); g = GETGREEN(mybuf[1]) + GETGREEN(mybuf[-1]) + GETGREEN(mybuf[-bigBuf.getDimx()]) + GETGREEN(mybuf[bigBuf.getDimx()]); @@ -1737,6 +1742,7 @@ void RMGfxSourceBuffer8AA::drawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri mybuf[0] = (r << 10) | (g << 5) | b; } + } // Skip to the next line buf += bigBuf.getDimx(); @@ -1756,7 +1762,7 @@ void RMGfxSourceBuffer8AA::drawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri */ mybuf = &buf[x1]; - for (x = 0; x < width; x++, mybuf += step) + for (x = 0; x < width; x++, mybuf += step) { if (_aabuf[(y + v) * _dimx + x + u] == 1 && x != 0 && x != width - 1) { r = GETRED(mybuf[1]) + GETRED(mybuf[-1]) + GETRED(mybuf[-bigBuf.getDimx()]) + GETRED(mybuf[bigBuf.getDimx()]); g = GETGREEN(mybuf[1]) + GETGREEN(mybuf[-1]) + GETGREEN(mybuf[-bigBuf.getDimx()]) + GETGREEN(mybuf[bigBuf.getDimx()]); @@ -1776,6 +1782,7 @@ void RMGfxSourceBuffer8AA::drawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri mybuf[0] = (r << 10) | (g << 5) | b; } + } // Skip to the next line buf += bigBuf.getDimx(); diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index dbd3ad6840..647e4264c7 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -763,9 +763,10 @@ int RMInterface::onWhichBox(RMPoint pt) { max = 5; // Find the verb - for (i = 0; i < max; i++) + for (i = 0; i < max; i++) { if (_hotbbox[i].ptInRect(pt)) return i; + } // Found no verb return -1; diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index d8548cc570..6401e1337f 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -141,7 +141,7 @@ int RMPattern::init(RMSfx *sfx, bool bPlayP0, byte *bFlag) { // Check for sound: // If the slot is 0, play - // If speed = 0, must playing unless it goes into loop '_', or if specified by the parameter + // If speed == 0, must play unless it goes into loop '_', or if specified by the parameter // If speed != 0, play only the loop for (i = 0; i < _nSlots; i++) { if (_slots[i]._type == SOUND) { @@ -1108,7 +1108,9 @@ RMPoint RMCharacter::searching(char UP, char DOWN, char RIGHT, char LEFT, RMPoin } } - if (minimo == 32000) trovato = punto; + if (minimo == 32000) + trovato = punto; + return trovato; } @@ -1137,11 +1139,13 @@ short RMCharacter::scanLine(const RMPoint &punto) { if (Ldx > Ldy) { Lslope = Lfy / Lfx; - if (Lend._x < Lstart._x) Lspeed = -Lspeed; + if (Lend._x < Lstart._x) + Lspeed = -Lspeed; Lstatus = 1; } else { Lslope = Lfx / Lfy; - if (Lend._y < Lstart._y) Lspeed = - Lspeed; + if (Lend._y < Lstart._y) + Lspeed = - Lspeed; Lstatus = 0; } @@ -1777,11 +1781,13 @@ int RMGameBoxes::whichBox(int nLoc, const RMPoint &punto) { if (!cur) return -1; - for (i = 0; i < cur->_numbBox; i++) - if (cur->_boxes[i]._bActive) + for (i = 0; i < cur->_numbBox; i++) { + if (cur->_boxes[i]._bActive) { if ((punto._x >= cur->_boxes[i]._left) && (punto._x <= cur->_boxes[i]._right) && (punto._y >= cur->_boxes[i]._top) && (punto._y <= cur->_boxes[i]._bottom)) return i; + } + } return -1; } @@ -2053,9 +2059,10 @@ void RMLocation::doFrame(RMGfxTargetBuffer *bigBuf) { RMItem *RMLocation::getItemFromCode(uint32 dwCode) { int i; - for (i = 0; i < _nItems; i++) + for (i = 0; i < _nItems; i++) { if (_items[i].mpalCode() == (int)dwCode) return &_items[i]; + } return NULL; } @@ -2133,9 +2140,10 @@ void RMLocation::updateScrolling(const RMPoint &ptShowThis) { if (_curScroll._y + RM_SY > _buf->getDimy()) _curScroll._y = _buf->getDimy() - RM_SY; - if (oldScroll != _curScroll) + if (oldScroll != _curScroll) { for (int i = 0; i < _nItems; i++) _items[i].setScrollPosition(_curScroll); + } } void RMLocation::setFixedScroll(const RMPoint &scroll) { diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index ed4ad9d228..2d2f8ecd00 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -628,9 +628,10 @@ bool ParseMpc(const byte *lpBuf) { GLOBALS._lpmdDialogs = (LPMPALDIALOG)globalLock(GLOBALS._hDialogs); - for (i = 0;i < GLOBALS._nDialogs; i++) + for (i = 0;i < GLOBALS._nDialogs; i++) { if ((lpBuf = parseDialog(lpBuf + 7, &GLOBALS._lpmdDialogs[i])) == NULL) return false; + } globalUnlock(GLOBALS._hDialogs); } diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 16d8a3213b..721552b80c 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -224,9 +224,10 @@ static int msgGetOrderFromNum(uint32 nMsg) { int i; LPMPALMSG msg = GLOBALS._lpmmMsgs; - for (i = 0; i < GLOBALS._nMsgs; i++, msg++) + for (i = 0; i < GLOBALS._nMsgs; i++, msg++) { if (msg->_wNum == nMsg) return i; + } return -1; } @@ -242,9 +243,10 @@ static int itemGetOrderFromNum(uint32 nItem) { int i; LPMPALITEM item = GLOBALS._lpmiItems; - for (i = 0; i < GLOBALS._nItems; i++, item++) + for (i = 0; i < GLOBALS._nItems; i++, item++) { if (item->nObj == nItem) return i; + } return -1; } @@ -261,9 +263,10 @@ static int scriptGetOrderFromNum(uint32 nScript) { int i; LPMPALSCRIPT script = GLOBALS._lpmsScripts; - for (i = 0; i < GLOBALS._nScripts; i++, script++) + for (i = 0; i < GLOBALS._nScripts; i++, script++) { if (script->nObj == nScript) return i; + } return -1; } @@ -280,9 +283,10 @@ static int dialogGetOrderFromNum(uint32 nDialog) { int i; LPMPALDIALOG dialog = GLOBALS._lpmdDialogs; - for (i = 0; i < GLOBALS._nDialogs; i++, dialog++) + for (i = 0; i < GLOBALS._nDialogs; i++, dialog++) { if (dialog->nObj == nDialog) return i; + } return -1; } @@ -333,14 +337,15 @@ static char *duplicateDialogPeriod(uint32 nPeriod) { LPMPALDIALOG dialog = GLOBALS._lpmdDialogs + GLOBALS._nExecutingDialog; int i, j; - for (j = 0; dialog->_periods[j] != NULL; j++) + for (j = 0; dialog->_periods[j] != NULL; j++) { if (dialog->_periodNums[j] == nPeriod) { /* Found the phrase, it should be duplicated */ origmsg = (const char *)globalLock(dialog->_periods[j]); /* Calculate the length and allocate memory */ i = 0; - while (origmsg[i] != '\0') i++; + while (origmsg[i] != '\0') + i++; clonemsg = (char *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, i + 1); if (clonemsg == NULL) @@ -352,7 +357,8 @@ static char *duplicateDialogPeriod(uint32 nPeriod) { return clonemsg; } - + } + return NULL; } @@ -415,9 +421,10 @@ static uint32 *getSelectList(uint32 i) { /* Count how many are active selects */ num = 0; - for (j = 0; dialog->_choice[i]._select[j].dwData != 0; j++) + for (j = 0; dialog->_choice[i]._select[j].dwData != 0; j++) { if (dialog->_choice[i]._select[j].curActive) num++; + } /* If there are 0, it's a mistake */ if (num == 0) @@ -429,9 +436,10 @@ static uint32 *getSelectList(uint32 i) { /* Copy all the data inside the active select list */ k = 0; - for (j = 0; dialog->_choice[i]._select[j].dwData != 0; j++) + for (j = 0; dialog->_choice[i]._select[j].dwData != 0; j++) { if (dialog->_choice[i]._select[j].curActive) sl[k++] = dialog->_choice[i]._select[j].dwData; + } sl[k] = (uint32)NULL; return sl; @@ -690,7 +698,8 @@ void ActionThread(CORO_PARAM, const void *param) { LPMPALITEM item; ~CoroContextTag() { - if (item) globalDestroy(item); + if (item) + globalDestroy(item); } CORO_END_CONTEXT(_ctx); @@ -844,14 +853,16 @@ void LocationPollThread(CORO_PARAM, const void *param) { for (_ctx->i = 0; _ctx->i < _ctx->numitems; _ctx->i++) { _ctx->ord = itemGetOrderFromNum(_ctx->il[_ctx->i]); - if (_ctx->ord == -1) continue; + if (_ctx->ord == -1) + continue; _ctx->curItem = GLOBALS._lpmiItems + _ctx->ord; _ctx->k = 0; - for (_ctx->j = 0; _ctx->j < _ctx->curItem->nActions; _ctx->j++) + for (_ctx->j = 0; _ctx->j < _ctx->curItem->nActions; _ctx->j++) { if (_ctx->curItem->Action[_ctx->j].num == 0xFF) _ctx->k++; + } _ctx->nIdleActions += _ctx->k; @@ -928,12 +939,13 @@ void LocationPollThread(CORO_PARAM, const void *param) { _ctx->curTime = g_vm->getTime(); _ctx->dwSleepTime = (uint32)-1L; - for (_ctx->k = 0;_ctx->k<_ctx->nIdleActions;_ctx->k++) + for (_ctx->k = 0;_ctx->k<_ctx->nIdleActions;_ctx->k++) { if (_ctx->curTime >= _ctx->MyActions[_ctx->k].dwLastTime + _ctx->MyActions[_ctx->k].wTime) { _ctx->dwSleepTime = 0; break; - } else + } else _ctx->dwSleepTime = MIN(_ctx->dwSleepTime, _ctx->MyActions[_ctx->k].dwLastTime + _ctx->MyActions[_ctx->k].wTime - _ctx->curTime); + } /* We fall alseep, but always checking that the event is set when prompted for closure */ CORO_INVOKE_3(CoroScheduler.waitForSingleObject, GLOBALS._hEndPollingLocations[id], _ctx->dwSleepTime, &_ctx->expired); @@ -942,7 +954,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { if (!_ctx->expired) break; - for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) + for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) { if (_ctx->MyThreads[_ctx->i].nItem != 0) { CORO_INVOKE_3(CoroScheduler.waitForSingleObject, _ctx->MyThreads[_ctx->i].hThread, 0, &_ctx->delayExpired); @@ -950,11 +962,12 @@ void LocationPollThread(CORO_PARAM, const void *param) { if (!_ctx->delayExpired) _ctx->MyThreads[_ctx->i].nItem = 0; } + } _ctx->curTime = g_vm->getTime(); /* Loop through all the necessary idle actions */ - for (_ctx->k = 0; _ctx->k < _ctx->nIdleActions; _ctx->k++) + for (_ctx->k = 0; _ctx->k < _ctx->nIdleActions; _ctx->k++) { if (_ctx->curTime >= _ctx->MyActions[_ctx->k].dwLastTime + _ctx->MyActions[_ctx->k].wTime) { _ctx->MyActions[_ctx->k].dwLastTime += _ctx->MyActions[_ctx->k].wTime; @@ -966,9 +979,10 @@ void LocationPollThread(CORO_PARAM, const void *param) { continue; /* Check to see if there already another idle funning running on the item */ - for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) + for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) { if (_ctx->MyThreads[_ctx->i].nItem == _ctx->MyActions[_ctx->k].nItem) break; + } if (_ctx->i < _ctx->nRealItems) continue; @@ -979,11 +993,12 @@ void LocationPollThread(CORO_PARAM, const void *param) { /* Check if there is a WhenExecute expression */ _ctx->j=_ctx->MyActions[_ctx->k].nAction; - if (_ctx->curItem->Action[_ctx->j].when != NULL) + if (_ctx->curItem->Action[_ctx->j].when != NULL) { if (!evaluateExpression(_ctx->curItem->Action[_ctx->j].when)) { unlockItems(); continue; } + } /* Ok, we can perform the action. For convenience, we do it in a new process */ _ctx->newItem = (LPMPALITEM)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MPALITEM)); @@ -1004,9 +1019,10 @@ void LocationPollThread(CORO_PARAM, const void *param) { _ctx->newItem->dwRes=_ctx->j; /* We will create an action, and will provide the necessary details */ - for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) + for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) { if (_ctx->MyThreads[_ctx->i].nItem == 0) break; + } _ctx->MyThreads[_ctx->i].nItem = _ctx->MyActions[_ctx->k].nItem; @@ -1024,13 +1040,14 @@ void LocationPollThread(CORO_PARAM, const void *param) { /* Skip all idle actions of the same item */ } } + } } // Set idle skip on CORO_INVOKE_4(GLOBALS._lplpFunctions[200], 0, 0, 0, 0); - for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) + for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) { if (_ctx->MyThreads[_ctx->i].nItem != 0) { CORO_INVOKE_3(CoroScheduler.waitForSingleObject, _ctx->MyThreads[_ctx->i].hThread, 5000, &_ctx->delayExpired); @@ -1041,6 +1058,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { */ CoroScheduler.killMatchingProcess(_ctx->MyThreads[_ctx->i].hThread); } + } // Set idle skip off CORO_INVOKE_4(GLOBALS._lplpFunctions[201], 0, 0, 0, 0); @@ -1178,9 +1196,10 @@ void doChoice(CORO_PARAM, uint32 nChoice) { _ctx->dialog = GLOBALS._lpmdDialogs + GLOBALS._nExecutingDialog; /* Search the choice between those required in the dialog */ - for (_ctx->i = 0; _ctx->dialog->_choice[_ctx->i].nChoice != 0; _ctx->i++) + for (_ctx->i = 0; _ctx->dialog->_choice[_ctx->i].nChoice != 0; _ctx->i++) { if (_ctx->dialog->_choice[_ctx->i].nChoice == nChoice) break; + } /* If nothing has been found, exit with an error */ if (_ctx->dialog->_choice[_ctx->i].nChoice == 0) { @@ -1200,7 +1219,7 @@ void doChoice(CORO_PARAM, uint32 nChoice) { _ctx->k = 0; /* Calculate the expression of each selection, to see if they're active or inactive */ - for (_ctx->j = 0; _ctx->dialog->_choice[_ctx->i]._select[_ctx->j].dwData != 0; _ctx->j++) + for (_ctx->j = 0; _ctx->dialog->_choice[_ctx->i]._select[_ctx->j].dwData != 0; _ctx->j++) { if (_ctx->dialog->_choice[_ctx->i]._select[_ctx->j].when == NULL) { _ctx->dialog->_choice[_ctx->i]._select[_ctx->j].curActive = 1; _ctx->k++; @@ -1209,6 +1228,7 @@ void doChoice(CORO_PARAM, uint32 nChoice) { _ctx->k++; } else _ctx->dialog->_choice[_ctx->i]._select[_ctx->j].curActive = 0; + } /* If there are no choices activated, then the dialog is finished. */ if (_ctx->k == 0) { @@ -1373,9 +1393,10 @@ bool doSelection(uint32 i, uint32 dwData) { LPMPALDIALOG dialog = GLOBALS._lpmdDialogs + GLOBALS._nExecutingDialog; int j; - for (j = 0; dialog->_choice[i]._select[j].dwData != 0; j++) + for (j = 0; dialog->_choice[i]._select[j].dwData != 0; j++) { if (dialog->_choice[i]._select[j].dwData == dwData && dialog->_choice[i]._select[j].curActive != 0) break; + } if (dialog->_choice[i]._select[j].dwData == 0) return false; @@ -2020,9 +2041,10 @@ void mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCus) { bool mpalStartIdlePoll(int nLoc) { uint32 i; - for (i = 0; i < MAXPOLLINGLOCATIONS; i++) + for (i = 0; i < MAXPOLLINGLOCATIONS; i++) { if (GLOBALS._nPollingLocations[i] == (uint32)nLoc) return false; + } for (i = 0; i < MAXPOLLINGLOCATIONS; i++) { if (GLOBALS._nPollingLocations[i] == 0) { diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index 8ea7aa03c3..3a1c6746c8 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -339,6 +339,7 @@ void FPSfx::pause(bool bPause) { void FPSfx::setVolume(int dwVolume) { if (dwVolume > 63) dwVolume = 63; + if (dwVolume < 0) dwVolume = 0; @@ -349,7 +350,8 @@ void FPSfx::setVolume(int dwVolume) { dwVolume = 0; else { dwVolume -= (10 - GLOBALS._nCfgDubbingVolume) * 2; - if (dwVolume < 0) dwVolume = 0; + if (dwVolume < 0) + dwVolume = 0; } } else { if (!GLOBALS._bCfgSFX) @@ -655,15 +657,20 @@ void FPStream::pause(bool bPause) { */ void FPStream::setVolume(int dwVolume) { - if (dwVolume > 63) dwVolume = 63; - if (dwVolume < 0) dwVolume = 0; + if (dwVolume > 63) + dwVolume = 63; + + if (dwVolume < 0) + dwVolume = 0; _lastVolume = dwVolume; - if (!GLOBALS._bCfgMusic) dwVolume = 0; + if (!GLOBALS._bCfgMusic) + dwVolume = 0; else { dwVolume -= (10 - GLOBALS._nCfgMusicVolume) * 2; - if (dwVolume < 0) dwVolume = 0; + if (dwVolume < 0) + dwVolume = 0; } if (g_system->getMixer()->isSoundHandleActive(_handle)) diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index bb28848362..79300ca1ee 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -281,9 +281,10 @@ void TonyEngine::GUIError(const Common::String &msg) { } void TonyEngine::playMusic(int nChannel, const Common::String &fname, int nFX, bool bLoop, int nSync) { - if (nChannel < 4) + if (nChannel < 4) { if (GLOBALS._flipflop) nChannel = nChannel + 1; + } switch (nFX) { case 0: -- cgit v1.2.3 From d2b33ca4cce2794e7b4fcf3ccb3f00dc74fff68d Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 28 Aug 2012 23:25:50 +0200 Subject: TONY: Janitorial - remove trailing spaces --- engines/tony/game.cpp | 8 ++--- engines/tony/mpal/expr.cpp | 16 +++++----- engines/tony/mpal/expr.h | 2 +- engines/tony/mpal/loadmpc.cpp | 8 ++--- engines/tony/mpal/loadmpc.h | 2 +- engines/tony/mpal/mpal.cpp | 70 +++++++++++++++++++++---------------------- engines/tony/mpal/mpal.h | 44 +++++++++++++-------------- engines/tony/mpal/mpaldll.h | 2 +- engines/tony/sound.cpp | 14 ++++----- engines/tony/sound.h | 16 +++++----- engines/tony/utils.cpp | 6 ++-- 11 files changed, 94 insertions(+), 94 deletions(-) (limited to 'engines') diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index c17b611b0c..0793d97215 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -1513,8 +1513,8 @@ int RMPointer::curAction() { return _nCurPointer; } -/** - * Show the cursor +/** + * Show the cursor */ void RMPointer::showCursor() { if (!CursorMan.isVisible()) { @@ -1524,8 +1524,8 @@ void RMPointer::showCursor() { } } -/** - * Hide the cursor +/** + * Hide the cursor */ void RMPointer::hideCursor() { if (CursorMan.isVisible()) { diff --git a/engines/tony/mpal/expr.cpp b/engines/tony/mpal/expr.cpp index 772d3da075..ef58208d3f 100644 --- a/engines/tony/mpal/expr.cpp +++ b/engines/tony/mpal/expr.cpp @@ -88,7 +88,7 @@ typedef struct { byte type; // Tipo di oggetto (vedi enum ExprListTypes) byte unary; // Unary operatore (NON SUPPORTATO) - union { + union { int num; // Numero (se type==ELT_NUMBER) char *name; // Nome variabile (se type==ELT_VAR) HGLOBAL son; // Handle a espressione (type==ELT_PARENTH) @@ -179,7 +179,7 @@ static int Compute(int a, int b, byte symbol) { GLOBALS._mpalError = 1; break; } - + return 0; } @@ -211,7 +211,7 @@ static void solve(LPEXPRESSION one, int num) { /** - * Calculates the result of a mathematical expression, replacing the current + * Calculates the result of a mathematical expression, replacing the current * value of any variable. * * @param expr Pointer to an expression duplicated by DuplicateExpression @@ -253,7 +253,7 @@ static int evaluateAndFreeExpression(byte *expr) { * Parses a mathematical expression from the MPC file * * @param buf Buffer containing the expression to evaluate - * @param h Pointer to a handle that, at the end of execution, + * @param h Pointer to a handle that, at the end of execution, * will point to the area of memory containing the parsed expression * @returns Pointer to the buffer immediately after the expression, or NULL if error. */ @@ -377,7 +377,7 @@ bool compareExpressions(HGLOBAL h1, HGLOBAL h2) { return false; } break; - + case ELT_VAR: if (strcmp(one->val.name, two->val.name) != 0) { globalUnlock(h1); @@ -385,7 +385,7 @@ bool compareExpressions(HGLOBAL h1, HGLOBAL h2) { return false; } break; - + case ELT_PARENTH: if (!compareExpressions(one->val.son, two->val.son)) { globalUnlock(h1); @@ -395,13 +395,13 @@ bool compareExpressions(HGLOBAL h1, HGLOBAL h2) { break; } - ++one; + ++one; ++two; } globalUnlock(h1); globalUnlock(h2); - + return true; } diff --git a/engines/tony/mpal/expr.h b/engines/tony/mpal/expr.h index 3130539000..f9c8a7c48f 100644 --- a/engines/tony/mpal/expr.h +++ b/engines/tony/mpal/expr.h @@ -43,7 +43,7 @@ namespace MPAL { * Parses a mathematical expression from the MPC file * * @param buf Buffer containing the expression to evaluate - * @param h Pointer to a handle that, at the end of execution, + * @param h Pointer to a handle that, at the end of execution, * will point to the area of memory containing the parsed expression * @returns Pointer to the buffer immediately after the expression, or NULL if error. */ diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index 2d2f8ecd00..9da2cc121e 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -157,7 +157,7 @@ static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { /* Periodi */ num = READ_LE_UINT16(lpBuf); lpBuf += 2; - + if (num >= MAX_PERIODS_PER_DIALOG - 1) error("Too much periods in dialog #%d", lpmdDialog->nObj); @@ -252,7 +252,7 @@ static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { } } - if (kk == curCmd) { + if (kk == curCmd) { lpmdDialog->_group[i].CmdNum[j] = curCmd; curCmd++; } @@ -445,7 +445,7 @@ static const byte *parseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { } } - if (kk == curCmd) { + if (kk == curCmd) { lpmiItem->Action[i].CmdNum[j] = curCmd; curCmd++; @@ -520,7 +520,7 @@ static const byte *ParseLocation(const byte *lpBuf, LPMPALLOCATION lpmlLocation) //@{ /** - * Reads and interprets the MPC file, and create structures for various directives + * Reads and interprets the MPC file, and create structures for various directives * in the global variables * * @param lpBuf Buffer containing the MPC file data, excluding the header. diff --git a/engines/tony/mpal/loadmpc.h b/engines/tony/mpal/loadmpc.h index b805b1e7a1..c0e2ca7fb5 100644 --- a/engines/tony/mpal/loadmpc.h +++ b/engines/tony/mpal/loadmpc.h @@ -38,7 +38,7 @@ namespace MPAL { \****************************************************************************/ /** - * Reads and interprets the MPC file, and create structures for various directives + * Reads and interprets the MPC file, and create structures for various directives * in the global variables * * @param lpBuf Buffer containing the MPC file data, excluding the header. diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 721552b80c..be2f6db43f 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -31,7 +31,7 @@ #include "common/savefile.h" #include "common/system.h" #include "tony/tony.h" -#include "tony/mpal/lzo.h" +#include "tony/mpal/lzo.h" #include "tony/mpal/mpal.h" #include "tony/mpal/mpaldll.h" @@ -358,7 +358,7 @@ static char *duplicateDialogPeriod(uint32 nPeriod) { return clonemsg; } } - + return NULL; } @@ -551,7 +551,7 @@ static LPITEM getItemData(uint32 nOrdItem) { dim = (uint32)(ret->_frameslocations[i].right - ret->_frameslocations[i].left) * (uint32)(ret->_frameslocations[i].bottom - ret->_frameslocations[i].top); ret->_frames[i] = (char *)globalAlloc(GMEM_FIXED,dim); - + if (ret->_frames[i] == NULL) return NULL; memcpy(ret->_frames[i], dat, dim); @@ -570,7 +570,7 @@ static LPITEM getItemData(uint32 nOrdItem) { } -/** +/** * Thread that calls a custom function. It is used in scripts, so that each script * function is executed without delaying the others. * @@ -685,7 +685,7 @@ void ScriptThread(CORO_PARAM, const void *param) { /** - * Thread that performs an action on an item. the thread always executes the action, + * Thread that performs an action on an item. the thread always executes the action, * so it should create a new item in which the action is the one required. * Furthermore, the expression is not checked, but it is always performed the action. * @@ -745,7 +745,7 @@ void ActionThread(CORO_PARAM, const void *param) { globalDestroy(_ctx->item); _ctx->item = NULL; - + debugC(DEBUG_DETAILED, kTonyDebugActions, "Action Process %d ended", CoroScheduler.getCurrentPID()); CORO_END_CODE; @@ -855,7 +855,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { if (_ctx->ord == -1) continue; - + _ctx->curItem = GLOBALS._lpmiItems + _ctx->ord; _ctx->k = 0; @@ -1005,7 +1005,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { if (_ctx->newItem == false) { globalDestroy(_ctx->MyThreads); globalDestroy(_ctx->MyActions); - + CORO_KILL_SELF(); return; } @@ -1032,7 +1032,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { globalDestroy(_ctx->newItem); globalDestroy(_ctx->MyThreads); globalDestroy(_ctx->MyActions); - + CORO_KILL_SELF(); return; } @@ -1068,10 +1068,10 @@ void LocationPollThread(CORO_PARAM, const void *param) { /** - * Wait for the end of the dialog execution thread, and then restore global + * Wait for the end of the dialog execution thread, and then restore global * variables indicating that the dialogue has finished. * - * @param param Pointer to a handle to the dialog + * @param param Pointer to a handle to the dialog * @remarks This additional process is used, instead of clearing variables * within the same dialog thread, because due to the recursive nature of a dialog, * it would be difficult to know within it when the dialog is actually ending. @@ -1132,9 +1132,9 @@ void GroupThread(CORO_PARAM, const void *param) { if (_ctx->type == 1) { // Call custom function CORO_INVOKE_4(GLOBALS._lplpFunctions[_ctx->dialog->_command[_ctx->k]._nCf], - _ctx->dialog->_command[_ctx->k]._arg1, + _ctx->dialog->_command[_ctx->k]._arg1, _ctx->dialog->_command[_ctx->k]._arg2, - _ctx->dialog->_command[_ctx->k]._arg3, + _ctx->dialog->_command[_ctx->k]._arg3, _ctx->dialog->_command[_ctx->k]._arg4 ); @@ -1143,22 +1143,22 @@ void GroupThread(CORO_PARAM, const void *param) { lockVar(); varSetValue(_ctx->dialog->_command[_ctx->k].lpszVarName, evaluateExpression(_ctx->dialog->_command[_ctx->k].expr)); unlockVar(); - + } else if (_ctx->type == 3) { // DoChoice: call the chosen function CORO_INVOKE_1(doChoice, (uint32)_ctx->dialog->_command[_ctx->k].nChoice); - + } else { GLOBALS._mpalError = 1; unlockDialogs(); - + CORO_KILL_SELF(); return; } } /* The gruop is finished, so we can return to the calling function. - * If the group was the first called, then the process will automatically + * If the group was the first called, then the process will automatically * end. Otherwise it returns to the caller method */ return; @@ -1168,7 +1168,7 @@ void GroupThread(CORO_PARAM, const void *param) { /* If we are here, it means that we have not found the requested group */ GLOBALS._mpalError = 1; unlockDialogs(); - + CORO_KILL_SELF(); CORO_END_CODE; @@ -1259,7 +1259,7 @@ void doChoice(CORO_PARAM, uint32 nChoice) { if (_ctx->dialog->_choice[_ctx->i]._select[_ctx->j].attr & (1 << 1)) { /* Bit 1 set: the end of the dialog */ unlockDialogs(); - + CORO_KILL_SELF(); return; } @@ -1348,8 +1348,8 @@ static uint32 doAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { * @param nGroup Number of the group to perform * @returns The process Id of the process running the dialog * or CORO_INVALID_PID_VALUE on error - * @remarks The dialogue runs in a thread created on purpose, - * so that must inform through an event and when 'necessary to you make a choice. + * @remarks The dialogue runs in a thread created on purpose, + * so that must inform through an event and when 'necessary to you make a choice. * The data on the choices may be obtained through various queries. */ static uint32 doDialog(uint32 nDlgOrd, uint32 nGroup) { @@ -1382,7 +1382,7 @@ static uint32 doDialog(uint32 nDlgOrd, uint32 nGroup) { /** - * Takes note of the selection chosen by the user, and warns the process that was running + * Takes note of the selection chosen by the user, and warns the process that was running * the box that it can continue. * * @param nChoice Number of choice that was in progress @@ -1420,7 +1420,7 @@ bool doSelection(uint32 i, uint32 dwData) { * @param lplpcfArray Array of pointers to custom functions. * @returns True if everything is OK, false on failure */ -bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, +bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, LPLPCUSTOMFUNCTION lplpcfArray, Common::String *lpcfStrings) { Common::File hMpc; byte buf[5]; @@ -1620,7 +1620,7 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { */ error("mpalQuery(MPQ_MESSAGE, uint32 nMsg) used incorrect method variant"); - + } else if (wQueryType == MPQ_ITEM_PATTERN) { /* * uint32 mpalQuery(MPQ_ITEM_PATTERN, uint32 nItem); @@ -1629,7 +1629,7 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { buf = Common::String::format("Pattern.%u", GETARG(uint32)); dwRet = (uint32)varGetValue(buf.c_str()); unlockVar(); - + } else if (wQueryType == MPQ_LOCATION_SIZE) { /* * uint32 mpalQuery(MPQ_LOCATION_SIZE, uint32 nLoc, uint32 dwCoord); @@ -1648,7 +1648,7 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { GLOBALS._mpalError = 1; unlockLocations(); - + } else if (wQueryType == MPQ_LOCATION_IMAGE) { /* * HGLOBAL mpalQuery(MPQ_LOCATION_IMAGE, uint32 nLoc); @@ -1815,19 +1815,19 @@ HANDLE mpalQueryHANDLE(uint16 wQueryType, ...) { LockMsg(); hRet = DuplicateMessage(msgGetOrderFromNum(GETARG(uint32))); UnlockMsg(); - + } else if (wQueryType == MPQ_ITEM_PATTERN) { /* * uint32 mpalQuery(MPQ_ITEM_PATTERN, uint32 nItem); */ error("mpalQuery(MPQ_ITEM_PATTERN, uint32 nItem) used incorrect variant"); - + } else if (wQueryType == MPQ_LOCATION_SIZE) { /* * uint32 mpalQuery(MPQ_LOCATION_SIZE, uint32 nLoc, uint32 dwCoord); */ error("mpalQuery(MPQ_LOCATION_SIZE, uint32 nLoc, uint32 dwCoord) used incorrect variant"); - + } else if (wQueryType == MPQ_LOCATION_IMAGE) { /* * HGLOBAL mpalQuery(MPQ_LOCATION_IMAGE, uint32 nLoc); @@ -1961,9 +1961,9 @@ void mpalQueryCORO(CORO_PARAM, uint16 wQueryType, uint32 *dwRet, ...) { */ CORO_INVOKE_2(CoroScheduler.waitForSingleObject, GLOBALS._hAskChoice, CORO_INFINITE); - // WORKAROUND: Introduce a single frame delay so that if there are multiple actions running, + // WORKAROUND: Introduce a single frame delay so that if there are multiple actions running, // they all have time to be signalled before resetting the event. This fixes a problem where - // if you try to use the 'shrimp' on the parrot a second time after trying to first use it + // if you try to use the 'shrimp' on the parrot a second time after trying to first use it // whilst the parrot was talking, the cursor wouldn't be re-enabled afterwards CORO_SLEEP(1); @@ -2019,7 +2019,7 @@ bool mpalExecuteScript(int nScript) { /** - * Install a custom routine That will be called by MPAL every time the pattern + * Install a custom routine That will be called by MPAL every time the pattern * of an item has been changed. * * @param lpiifCustom Custom function to install @@ -2032,7 +2032,7 @@ void mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCus) { /** * Process the idle actions of the items on one location. * - * @param nLoc Number of the location whose items must be processed + * @param nLoc Number of the location whose items must be processed * for idle actions. * @returns TRUE if all OK, and FALSE if it exceeded the maximum limit. * @remarks The maximum number of locations that can be polled @@ -2118,7 +2118,7 @@ void mpalSaveState(byte *buf) { lockVar(); WRITE_LE_UINT32(buf, GLOBALS._nVars); memcpy(buf + 4, (byte *)GLOBALS._lpmvVars, GLOBALS._nVars * sizeof(MPALVAR)); - unlockVar(); + unlockVar(); } @@ -2133,7 +2133,7 @@ int mpalLoadState(byte *buf) { globalFree(GLOBALS._hVars); GLOBALS._nVars = READ_LE_UINT32(buf); - + GLOBALS._hVars = globalAllocate(GMEM_ZEROINIT | GMEM_MOVEABLE, GLOBALS._nVars * sizeof(MPALVAR)); lockVar(); memcpy((byte *)GLOBALS._lpmvVars, buf + 4, GLOBALS._nVars * sizeof(MPALVAR)); diff --git a/engines/tony/mpal/mpal.h b/engines/tony/mpal/mpal.h index 251e78afdf..20f2b0b170 100644 --- a/engines/tony/mpal/mpal.h +++ b/engines/tony/mpal/mpal.h @@ -34,9 +34,9 @@ /* * MPAL (MultiPurpose Adventure Language) is a high level language * for the definition of adventure. Through the use of MPAL you can describe - * storyboard the adventure, and then use it with any user interface. - * In fact, unlike many other similar products, MPAL is not programmed through - * the whole adventure, but are defined only the locations, objects, as they may + * storyboard the adventure, and then use it with any user interface. + * In fact, unlike many other similar products, MPAL is not programmed through + * the whole adventure, but are defined only the locations, objects, as they may * interact with each other, etc.. thus making MPAL useful for any type of adventure. */ @@ -64,16 +64,16 @@ /* * A custom function and a function specified by the program that uses the * library, to perform the particular code. The custom functions are - * retrieved from the library as specified in the source MPAL, and in particular + * retrieved from the library as specified in the source MPAL, and in particular * in defining the behavior of an item with some action. * * To use the custom functions, you need to prepare an array of - * pointers to functions (such as using the type casting LPCUSTOMFUNCTION, + * pointers to functions (such as using the type casting LPCUSTOMFUNCTION, * (defined below), and pass it as second parameter to mpalInit (). Note you - * must specify the size of the array, as elements of pointers and which do not - * contain the same: the library will call it only those functions specified in - * the source MPAL. It can be useful, for debugging reasons, do not bet - * the shares of arrays used to debugging function, to avoid unpleasant crash, + * must specify the size of the array, as elements of pointers and which do not + * contain the same: the library will call it only those functions specified in + * the source MPAL. It can be useful, for debugging reasons, do not bet + * the shares of arrays used to debugging function, to avoid unpleasant crash, * if it has been made an error in source and / or some oversight in the code. * */ @@ -115,7 +115,7 @@ enum QueryCoordinates { /** - * Query can be used with mpalQuery methods. In practice corresponds all claims + * Query can be used with mpalQuery methods. In practice corresponds all claims * that can do at the library */ enum QueryTypes { @@ -176,7 +176,7 @@ typedef void (*LPCUSTOMFUNCTION)(CORO_PARAM, uint32, uint32, uint32, uint32); typedef LPCUSTOMFUNCTION *LPLPCUSTOMFUNCTION; /** - * + * * Define an IRQ of an item that is called when the pattern changes or the status of an item */ typedef void (*LPITEMIRQFUNCTION)(uint32, int, int); @@ -202,8 +202,8 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * * @param lpszVarName Nome della variabile (ASCIIZ) * @returns Global variable value - * @remarks This query was implemented for debugging. The program, - * if well designed, should not need to access variables from + * @remarks This query was implemented for debugging. The program, + * if well designed, should not need to access variables from * within the library. */ #define mpalQueryGlobalVar(lpszVarName) \ @@ -313,7 +313,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * @param nPeriod Number of words * @returns A pointer to the string of words, or NULL on failure. * @remarks The string must be freed after use using the memory manager. - * Unlike normal messages, the sentences of dialogue are formed by a single + * Unlike normal messages, the sentences of dialogue are formed by a single * string terminated with 0. */ #define mpalQueryDialogPeriod(nPeriod) \ @@ -340,14 +340,14 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; (uint32 *)mpalQueryHANDLE(MPQ_DIALOG_SELECTLIST, (uint32)(nChoice)) /** - * Warns the library that the user has selected, in a certain choice of the current dialog, + * Warns the library that the user has selected, in a certain choice of the current dialog, * corresponding option at a certain given. * * @param nChoice Choice number of the choice that was in progress * @param dwData Option that was selected by the user. * @returns TRUE if all OK, FALSE on failure. - * @remarks After execution of this query, MPAL continue - * Groups according to the execution of the dialogue. And necessary so the game + * @remarks After execution of this query, MPAL continue + * Groups according to the execution of the dialogue. And necessary so the game * remains on hold again for another chosen by mpalQueryDialogWaitForChoice (). */ #define mpalQueryDialogSelection(nChoice, dwData) \ @@ -357,15 +357,15 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; mpalQueryDWORD(MPQ_DIALOG_SELECTION, (uint32)(nChoice), (uint32)(dwData)) /** - * Warns the library an action was performed on a Object. + * Warns the library an action was performed on a Object. * The library will call custom functions, if necessary. * * @param nAction Action number * @param nItem Item number * @param dwParam Action parameter - * @returns Handle to the thread that is performing the action, or CORO_INVALID_PID_VALUE + * @returns Handle to the thread that is performing the action, or CORO_INVALID_PID_VALUE * if the action is not defined for the item, or the item is inactive. - * @remarks The parameter is used primarily to implement actions + * @remarks The parameter is used primarily to implement actions * as "U.S." involving two objects together. The action will be executed only * if the item is active, ie if its status is a positive number greater than 0. */ @@ -452,7 +452,7 @@ bool mpalExecuteScript(int nScript); uint32 mpalGetError(); /** - * Install a custom routine That will be called by MPAL every time the pattern + * Install a custom routine That will be called by MPAL every time the pattern * of an item has been changed. * * @param lpiifCustom Custom function to install @@ -462,7 +462,7 @@ void mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCustom); /** * Process the idle actions of the items on one location. * - * @param nLoc Number of the location whose items must be processed + * @param nLoc Number of the location whose items must be processed * for idle actions. * @returns TRUE if all OK, and FALSE if it exceeded the maximum limit. * @remarks The maximum number of locations that can be polled diff --git a/engines/tony/mpal/mpaldll.h b/engines/tony/mpal/mpaldll.h index e637362bdf..a95003ef97 100644 --- a/engines/tony/mpal/mpaldll.h +++ b/engines/tony/mpal/mpaldll.h @@ -230,7 +230,7 @@ struct MPALSCRIPT { byte nCmds; uint32 CmdNum[MAX_COMMANDS_PER_MOMENT]; - + } Moment[MAX_MOMENTS_PER_SCRIPT]; } PACKED_STRUCT; diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index 3a1c6746c8..0f9f1c2bbe 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -416,7 +416,7 @@ void FPSfx::soundCheckProcess(CORO_PARAM, const void *param) { } /** - * Default constructor. + * Default constructor. * * @remarks Do *NOT* declare an object directly, but rather * create it using FPSound::CreateStream() @@ -436,7 +436,7 @@ FPStream::FPStream(bool bSoundOn) { } /** - * Default destructor. + * Default destructor. * * @remarks It calls CloseFile() if needed. */ @@ -455,9 +455,9 @@ FPStream::~FPStream() { } /** - * Releases the memory object. + * Releases the memory object. * - * @remarks Must be called when the object is no longer used + * @remarks Must be called when the object is no longer used * and **ONLY** if the object was created by * FPSound::CreateStream(). * Object pointers are no longer valid after this call. @@ -522,8 +522,8 @@ bool FPStream::loadFile(const Common::String &fileName, uint32 dwCodType, int nB * * @returns For safety, the destructor calls unloadFile() if it has not * been mentioned explicitly. - * - * @remarks It is necessary to call this function to free the + * + * @remarks It is necessary to call this function to free the * memory used by the stream. */ bool FPStream::unloadFile() { @@ -580,7 +580,7 @@ bool FPStream::play() { * Closes the stream. * * @returns True is everything is OK, False otherwise - * + * */ bool FPStream::stop(bool bSync) { diff --git a/engines/tony/sound.h b/engines/tony/sound.h index ca71652f20..bd858e5bca 100644 --- a/engines/tony/sound.h +++ b/engines/tony/sound.h @@ -36,7 +36,7 @@ #include "tony/utils.h" namespace Audio { -class RewindableAudioStream; +class RewindableAudioStream; } namespace Tony { @@ -253,7 +253,7 @@ private: Common::File _file; // File handle used for the stream bool _bSoundSupported; // True if the sound is active - bool _bFileLoaded; // True if the file is open + bool _bFileLoaded; // True if the file is open bool _bLoop; // True if the stream should loop bool _bDoFadeOut; // True if fade out is required bool _bSyncExit; @@ -268,7 +268,7 @@ private: public: /** - * Default constructor. + * Default constructor. * * @remarks Do *NOT* declare an object directly, but rather * create it using FPSound::CreateStream() @@ -277,7 +277,7 @@ public: FPStream(bool bSoundOn); /** - * Default destructor. + * Default destructor. * * @remarks It calls CloseFile() if needed. */ @@ -285,9 +285,9 @@ public: ~FPStream(); /** - * Releases the memory object. + * Releases the memory object. * - * @remarks Must be called when the object is no longer used + * @remarks Must be called when the object is no longer used * and **ONLY** if the object was created by * FPSound::CreateStream(). * Object pointers are no longer valid after this call. @@ -311,8 +311,8 @@ public: * * @returns For safety, the destructor calls unloadFile() if it has not * been mentioned explicitly. - * - * @remarks It is necessary to call this function to free the + * + * @remarks It is necessary to call this function to free the * memory used by the stream. */ diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index a3f79decaf..70c33e71ee 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -177,13 +177,13 @@ void RMPoint::readFromStream(Common::ReadStream &ds) { * RMPointReference methods \****************************************************************************/ -RMPointReference &RMPointReference::operator=(const RMPoint &p) { - _x = p._x; _y = p._y; +RMPointReference &RMPointReference::operator=(const RMPoint &p) { + _x = p._x; _y = p._y; return *this; } RMPointReference &RMPointReference::operator-=(const RMPoint &p) { - _x -= p._x; _y -= p._y; + _x -= p._x; _y -= p._y; return *this; } -- cgit v1.2.3 From b12ccad9943c99ecfc4edc6f4a46e4d88db609cf Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 29 Aug 2012 00:30:07 +0200 Subject: TONY: Reduce scope of some variables --- engines/tony/mpal/expr.cpp | 30 +++++------ engines/tony/mpal/loadmpc.cpp | 88 +++++++++++++----------------- engines/tony/mpal/mpal.cpp | 121 +++++++++++++++++------------------------- engines/tony/utils.cpp | 13 ++--- engines/tony/window.cpp | 2 +- 5 files changed, 107 insertions(+), 147 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/expr.cpp b/engines/tony/mpal/expr.cpp index ef58208d3f..2b2dbf2529 100644 --- a/engines/tony/mpal/expr.cpp +++ b/engines/tony/mpal/expr.cpp @@ -109,13 +109,12 @@ typedef EXPRESSION *LPEXPRESSION; * @retruns Pointer to the cloned expression */ static byte *duplicateExpression(HGLOBAL h) { - int i, num; byte *orig, *clone; LPEXPRESSION one, two; orig = (byte *)globalLock(h); - num = *(byte *)orig; + int num = *(byte *)orig; one = (LPEXPRESSION)(orig+1); clone = (byte *)globalAlloc(GMEM_FIXED, sizeof(EXPRESSION) * num + 1); @@ -123,7 +122,7 @@ static byte *duplicateExpression(HGLOBAL h) { memcpy(clone, orig, sizeof(EXPRESSION) * num + 1); - for (i = 0; i < num; i++) { + for (int i = 0; i < num; i++) { if (one->type == ELT_PARENTH) { two->type = ELT_PARENTH2; two->val.pson = duplicateExpression(two->val.son); @@ -218,14 +217,14 @@ static void solve(LPEXPRESSION one, int num) { * @returns Value */ static int evaluateAndFreeExpression(byte *expr) { - int i,num,val; - LPEXPRESSION one,cur; + LPEXPRESSION one, cur; - num = *expr; + int num = *expr; one = (LPEXPRESSION)(expr + 1); // 1) Sostituzioni delle variabili - for (i = 0, cur = one; i < num; i++, cur++) { + cur = one; + for (int i = 0; i < num; i++, cur++) { if (cur->type == ELT_VAR) { cur->type = ELT_NUMBER; cur->val.num = varGetValue(cur->val.name); @@ -233,7 +232,8 @@ static int evaluateAndFreeExpression(byte *expr) { } // 2) Sostituzioni delle parentesi (tramite ricorsione) - for (i = 0, cur = one; i < num; i++, cur++) { + cur = one; + for (int i = 0; i < num; i++, cur++) { if (cur->type == ELT_PARENTH2) { cur->type = ELT_NUMBER; cur->val.num = evaluateAndFreeExpression(cur->val.pson); @@ -242,7 +242,7 @@ static int evaluateAndFreeExpression(byte *expr) { // 3) Risoluzione algebrica solve(one, num); - val = one->val.num; + int val = one->val.num; globalDestroy(expr); return val; @@ -260,9 +260,8 @@ static int evaluateAndFreeExpression(byte *expr) { const byte *parseExpression(const byte *lpBuf, HGLOBAL *h) { LPEXPRESSION cur; byte *start; - uint32 num, i; - num = *lpBuf; + uint32 num = *lpBuf; lpBuf++; if (num == 0) @@ -277,7 +276,7 @@ const byte *parseExpression(const byte *lpBuf, HGLOBAL *h) { cur = (LPEXPRESSION)(start + 1); - for (i = 0;i < num; i++) { + for (uint32 i = 0;i < num; i++) { cur->type = *(lpBuf); cur->unary = *(lpBuf + 1); lpBuf += 2; @@ -343,15 +342,14 @@ int evaluateExpression(HGLOBAL h) { * @param h2 Expression to be compared */ bool compareExpressions(HGLOBAL h1, HGLOBAL h2) { - int i, num1, num2; byte *e1, *e2; LPEXPRESSION one, two; e1 = (byte *)globalLock(h1); e2 = (byte *)globalLock(h2); - num1 = *(byte *)e1; - num2 = *(byte *)e2; + int num1 = *(byte *)e1; + int num2 = *(byte *)e2; if (num1 != num2) { globalUnlock(h1); @@ -362,7 +360,7 @@ bool compareExpressions(HGLOBAL h1, HGLOBAL h2) { one = (LPEXPRESSION)(e1 + 1); two = (LPEXPRESSION)(e2 + 1); - for (i = 0; i < num1; i++) { + for (int i = 0; i < num1; i++) { if (one->type != two->type || (i != num1 - 1 && one->symbol != two->symbol)) { globalUnlock(h1); globalUnlock(h2); diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index 9da2cc121e..790d8d4903 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -62,24 +62,21 @@ static bool compareCommands(struct command *cmd1, struct command *cmd2) { * @returns Pointer to the buffer after the item, or NULL on failure. */ static const byte *ParseScript(const byte *lpBuf, LPMPALSCRIPT lpmsScript) { - int curCmd, j, len; - uint i; - lpmsScript->nObj = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; lpmsScript->nMoments = READ_LE_UINT16(lpBuf); lpBuf += 2; - curCmd = 0; + int curCmd = 0; - for (i = 0; i < lpmsScript->nMoments; i++) { + for (uint i = 0; i < lpmsScript->nMoments; i++) { lpmsScript->Moment[i].dwTime = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; lpmsScript->Moment[i].nCmds = *lpBuf; lpBuf++; - for (j = 0; j < lpmsScript->Moment[i].nCmds; j++) { + for (int j = 0; j < lpmsScript->Moment[i].nCmds; j++) { lpmsScript->_command[curCmd].type = *lpBuf; lpBuf++; switch (lpmsScript->_command[curCmd].type) { @@ -96,8 +93,8 @@ static const byte *ParseScript(const byte *lpBuf, LPMPALSCRIPT lpmsScript) { lpBuf += 4; break; - case 2: // Variable assign - len = *lpBuf; + case 2: { // Variable assign + int len = *lpBuf; lpBuf++; lpmsScript->_command[curCmd].lpszVarName = (char *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, len + 1); if (lpmsScript->_command[curCmd].lpszVarName == NULL) @@ -109,7 +106,7 @@ static const byte *ParseScript(const byte *lpBuf, LPMPALSCRIPT lpmsScript) { if (lpBuf == NULL) return NULL; break; - + } default: return NULL; } @@ -145,22 +142,20 @@ static void FreeScript(LPMPALSCRIPT lpmsScript) { * @returns Pointer to the buffer after the item, or NULL on failure. */ static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { - uint32 i, j, z, kk; - uint32 num, num2, num3; + uint32 num2, num3; byte *lpLock; - uint32 curCmd; - uint32 len; lpmdDialog->nObj = READ_LE_UINT32(lpBuf); lpBuf += 4; /* Periodi */ - num = READ_LE_UINT16(lpBuf); + uint32 num = READ_LE_UINT16(lpBuf); lpBuf += 2; if (num >= MAX_PERIODS_PER_DIALOG - 1) error("Too much periods in dialog #%d", lpmdDialog->nObj); + uint32 i; for (i = 0; i < num; i++) { lpmdDialog->_periodNums[i] = READ_LE_UINT16(lpBuf); lpBuf += 2; @@ -177,7 +172,7 @@ static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { /* Gruppi */ num = READ_LE_UINT16(lpBuf); lpBuf += 2; - curCmd = 0; + uint32 curCmd = 0; if (num >= MAX_GROUPS_PER_DIALOG) error("Too much groups in dialog #%d", lpmdDialog->nObj); @@ -190,7 +185,7 @@ static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { if (lpmdDialog->_group[i].nCmds >= MAX_COMMANDS_PER_GROUP) error("Too much commands in group #%d in dialog #%d",lpmdDialog->_group[i].num,lpmdDialog->nObj); - for (j = 0; j < lpmdDialog->_group[i].nCmds; j++) { + for (uint32 j = 0; j < lpmdDialog->_group[i].nCmds; j++) { lpmdDialog->_command[curCmd].type = *lpBuf; lpBuf++; @@ -210,8 +205,8 @@ static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { break; // Variable assign - case 2: - len = *lpBuf; + case 2: { + uint32 len = *lpBuf; lpBuf++; lpmdDialog->_command[curCmd].lpszVarName = (char *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, len + 1); if (lpmdDialog->_command[curCmd].lpszVarName == NULL) @@ -224,7 +219,7 @@ static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { if (lpBuf == NULL) return NULL; break; - + } // Do Choice case 3: lpmdDialog->_command[curCmd].nChoice = READ_LE_UINT16(lpBuf); @@ -235,6 +230,7 @@ static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { return NULL; } + uint32 kk; for (kk = 0;kk < curCmd; kk++) { if (compareCommands(&lpmdDialog->_command[kk], &lpmdDialog->_command[curCmd])) { lpmdDialog->_group[i].CmdNum[j] = kk; @@ -278,7 +274,7 @@ static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { if (num2 >= MAX_SELECTS_PER_CHOICE) error("Too much selects in choice #%d in dialog #%d", lpmdDialog->_choice[i].nChoice, lpmdDialog->nObj); - for (j = 0; j < num2; j++) { + for (uint32 j = 0; j < num2; j++) { // When switch (*lpBuf++) { case 0: @@ -308,7 +304,7 @@ static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { if (num3 >= MAX_PLAYGROUPS_PER_SELECT) error("Too much playgroups in select #%d in choice #%d in dialog #%d", j, lpmdDialog->_choice[i].nChoice, lpmdDialog->nObj); - for (z = 0; z < num3; z++) { + for (uint32 z = 0; z < num3; z++) { lpmdDialog->_choice[i]._select[j].wPlayGroup[z] = READ_LE_UINT16(lpBuf); lpBuf += 2; } @@ -337,14 +333,10 @@ static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { * completely initialized to 0 beforehand. */ static const byte *parseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { - byte len; - uint32 i, j, kk; - uint32 curCmd; - lpmiItem->nObj = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; - len = *lpBuf; + byte len = *lpBuf; lpBuf++; memcpy(lpmiItem->lpszDescribe, lpBuf, MIN((byte)127, len)); lpBuf += len; @@ -359,9 +351,9 @@ static const byte *parseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { if (lpmiItem->nActions > 0) lpmiItem->Action = (ItemAction *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(struct ItemAction) * (int)lpmiItem->nActions); - curCmd = 0; + uint32 curCmd = 0; - for (i = 0; i < lpmiItem->nActions; i++) { + for (uint32 i = 0; i < lpmiItem->nActions; i++) { lpmiItem->Action[i].num = *lpBuf; lpBuf++; @@ -393,7 +385,7 @@ static const byte *parseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { if (lpmiItem->Action[i].nCmds >= MAX_COMMANDS_PER_ACTION) error("Too much commands in action #%d in item #%d",lpmiItem->Action[i].num,lpmiItem->nObj); - for (j = 0; j < lpmiItem->Action[i].nCmds; j++) { + for (uint32 j = 0; j < lpmiItem->Action[i].nCmds; j++) { lpmiItem->_command[curCmd].type = *lpBuf; lpBuf++; switch (lpmiItem->_command[curCmd].type) { @@ -428,6 +420,7 @@ static const byte *parseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { return NULL; } + uint32 kk; for (kk = 0; kk < curCmd; kk++) { if (compareCommands(&lpmiItem->_command[kk], &lpmiItem->_command[curCmd])) { lpmiItem->Action[i].CmdNum[j] = kk; @@ -527,8 +520,6 @@ static const byte *ParseLocation(const byte *lpBuf, LPMPALLOCATION lpmlLocation) * @returns True if succeeded OK, false if failure. */ bool ParseMpc(const byte *lpBuf) { - uint16 i, j; - uint16 wLen; byte *lpTemp; /* 1. Variables */ @@ -545,8 +536,8 @@ bool ParseMpc(const byte *lpBuf) { GLOBALS._lpmvVars = (LPMPALVAR)globalLock(GLOBALS._hVars); - for (i = 0; i < GLOBALS._nVars; i++) { - wLen = *(const byte *)lpBuf; + for (uint16 i = 0; i < GLOBALS._nVars; i++) { + uint16 wLen = *(const byte *)lpBuf; lpBuf++; memcpy(GLOBALS._lpmvVars->lpszVarName, lpBuf, MIN(wLen, (uint16)32)); lpBuf += wLen; @@ -579,10 +570,11 @@ bool ParseMpc(const byte *lpBuf) { return false; #endif - for (i = 0; i < GLOBALS._nMsgs; i++) { + for (uint16 i = 0; i < GLOBALS._nMsgs; i++) { GLOBALS._lpmmMsgs->_wNum = READ_LE_UINT16(lpBuf); lpBuf += 2; + uint16 j; for (j = 0; lpBuf[j] != 0;) j += lpBuf[j] + 1; @@ -628,7 +620,7 @@ bool ParseMpc(const byte *lpBuf) { GLOBALS._lpmdDialogs = (LPMPALDIALOG)globalLock(GLOBALS._hDialogs); - for (i = 0;i < GLOBALS._nDialogs; i++) { + for (uint16 i = 0; i < GLOBALS._nDialogs; i++) { if ((lpBuf = parseDialog(lpBuf + 7, &GLOBALS._lpmdDialogs[i])) == NULL) return false; } @@ -650,7 +642,7 @@ bool ParseMpc(const byte *lpBuf) { GLOBALS._lpmiItems = (LPMPALITEM)globalLock(GLOBALS._hItems); - for (i = 0; i < GLOBALS._nItems; i++) { + for (uint16 i = 0; i < GLOBALS._nItems; i++) { if ((lpBuf = parseItem(lpBuf + 5, &GLOBALS._lpmiItems[i])) == NULL) return false; } @@ -672,7 +664,7 @@ bool ParseMpc(const byte *lpBuf) { GLOBALS._lpmlLocations = (LPMPALLOCATION)globalLock(GLOBALS._hLocations); - for (i = 0; i < GLOBALS._nLocations; i++) { + for (uint16 i = 0; i < GLOBALS._nLocations; i++) { if ((lpBuf = ParseLocation(lpBuf + 9, &GLOBALS._lpmlLocations[i])) == NULL) return false; } @@ -694,7 +686,7 @@ bool ParseMpc(const byte *lpBuf) { GLOBALS._lpmsScripts = (LPMPALSCRIPT)globalLock(GLOBALS._hScripts); - for (i = 0; i < GLOBALS._nScripts; i++) { + for (uint16 i = 0; i < GLOBALS._nScripts; i++) { if ((lpBuf = ParseScript(lpBuf + 7, &GLOBALS._lpmsScripts[i])) == NULL) return false; @@ -721,12 +713,10 @@ bool ParseMpc(const byte *lpBuf) { */ static void freeDialog(LPMPALDIALOG lpmdDialog) { // Free the periods - int i, j; - - for (i = 0; i < MAX_PERIODS_PER_DIALOG && (lpmdDialog->_periods[i]); ++i) + for (int i = 0; i < MAX_PERIODS_PER_DIALOG && (lpmdDialog->_periods[i]); ++i) globalFree(lpmdDialog->_periods[i]); - for (i = 0; i < MAX_COMMANDS_PER_DIALOG && (lpmdDialog->_command[i].type); i++) { + for (int i = 0; i < MAX_COMMANDS_PER_DIALOG && (lpmdDialog->_command[i].type); i++) { if (lpmdDialog->_command[i].type == 2) { // Variable assign globalDestroy(lpmdDialog->_command[i].lpszVarName); @@ -735,8 +725,8 @@ static void freeDialog(LPMPALDIALOG lpmdDialog) { } // Free the choices - for (i = 0; i < MAX_CHOICES_PER_DIALOG; ++i) { - for (j = 0; j < MAX_SELECTS_PER_CHOICE; j++) { + for (int i = 0; i < MAX_CHOICES_PER_DIALOG; ++i) { + for (int j = 0; j < MAX_SELECTS_PER_CHOICE; j++) { if (lpmdDialog->_choice[i]._select[j].when) freeExpression(lpmdDialog->_choice[i]._select[j].when); } @@ -747,14 +737,12 @@ static void freeDialog(LPMPALDIALOG lpmdDialog) { * Frees any data allocated from the parsing of the MPC file */ void FreeMpc() { - int i; - // Free variables globalFree(GLOBALS._hVars); // Free messages LPMPALMSG lpmmMsgs = (LPMPALMSG)globalLock(GLOBALS._hMsgs); - for (i = 0; i < GLOBALS._nMsgs; i++, ++lpmmMsgs) + for (int i = 0; i < GLOBALS._nMsgs; i++, ++lpmmMsgs) globalFree(lpmmMsgs->_hText); globalUnlock(GLOBALS._hMsgs); @@ -764,7 +752,7 @@ void FreeMpc() { if (GLOBALS._hDialogs) { LPMPALDIALOG lpmdDialogs = (LPMPALDIALOG)globalLock(GLOBALS._hDialogs); - for (i = 0; i < GLOBALS._nDialogs; i++, ++lpmdDialogs) + for (int i = 0; i < GLOBALS._nDialogs; i++, ++lpmdDialogs) freeDialog(lpmdDialogs); globalFree(GLOBALS._hDialogs); @@ -774,7 +762,7 @@ void FreeMpc() { if (GLOBALS._hItems) { LPMPALITEM lpmiItems = (LPMPALITEM)globalLock(GLOBALS._hItems); - for (i = 0; i < GLOBALS._nItems; ++i, ++lpmiItems) + for (int i = 0; i < GLOBALS._nItems; ++i, ++lpmiItems) freeItem(lpmiItems); globalUnlock(GLOBALS._hItems); @@ -790,7 +778,7 @@ void FreeMpc() { if (GLOBALS._hScripts) { LPMPALSCRIPT lpmsScripts = (LPMPALSCRIPT)globalLock(GLOBALS._hScripts); - for (i = 0; i < GLOBALS._nScripts; ++i, ++lpmsScripts) { + for (int i = 0; i < GLOBALS._nScripts; ++i, ++lpmsScripts) { FreeScript(lpmsScripts); } diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index be2f6db43f..540dee664f 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -154,10 +154,9 @@ static void unlockScripts() { * need to remember to call UnlockVar() */ int32 varGetValue(const char *lpszVarName) { - int i; LPMPALVAR v = GLOBALS._lpmvVars; - for (i = 0; i < GLOBALS._nVars; v++, i++) + for (int i = 0; i < GLOBALS._nVars; v++, i++) if (strcmp(lpszVarName, v->lpszVarName) == 0) return v->dwVal; @@ -171,10 +170,9 @@ int32 varGetValue(const char *lpszVarName) { * @param val Value to set */ void varSetValue(const char *lpszVarName, int32 val) { - uint i; LPMPALVAR v = GLOBALS._lpmvVars; - for (i = 0; i < GLOBALS._nVars; v++, i++) + for (uint i = 0; i < GLOBALS._nVars; v++, i++) if (strcmp(lpszVarName, v->lpszVarName) == 0) { v->dwVal = val; if (GLOBALS._lpiifCustom != NULL && strncmp(v->lpszVarName, "Pattern.", 8) == 0) { @@ -202,10 +200,9 @@ void varSetValue(const char *lpszVarName, int32 val) { * first been locked with a call to LockLoc(). */ static int locGetOrderFromNum(uint32 nLoc) { - int i; LPMPALLOCATION loc = GLOBALS._lpmlLocations; - for (i = 0; i < GLOBALS._nLocations; i++, loc++) + for (int i = 0; i < GLOBALS._nLocations; i++, loc++) if (loc->nObj == nLoc) return i; @@ -221,10 +218,9 @@ static int locGetOrderFromNum(uint32 nLoc) { * first been locked with a call to LockMsg() */ static int msgGetOrderFromNum(uint32 nMsg) { - int i; LPMPALMSG msg = GLOBALS._lpmmMsgs; - for (i = 0; i < GLOBALS._nMsgs; i++, msg++) { + for (int i = 0; i < GLOBALS._nMsgs; i++, msg++) { if (msg->_wNum == nMsg) return i; } @@ -240,10 +236,9 @@ static int msgGetOrderFromNum(uint32 nMsg) { * first been locked with a call to LockItems() */ static int itemGetOrderFromNum(uint32 nItem) { - int i; LPMPALITEM item = GLOBALS._lpmiItems; - for (i = 0; i < GLOBALS._nItems; i++, item++) { + for (int i = 0; i < GLOBALS._nItems; i++, item++) { if (item->nObj == nItem) return i; } @@ -260,10 +255,9 @@ static int itemGetOrderFromNum(uint32 nItem) { * first been locked with a call to LockScripts() */ static int scriptGetOrderFromNum(uint32 nScript) { - int i; LPMPALSCRIPT script = GLOBALS._lpmsScripts; - for (i = 0; i < GLOBALS._nScripts; i++, script++) { + for (int i = 0; i < GLOBALS._nScripts; i++, script++) { if (script->nObj == nScript) return i; } @@ -280,10 +274,9 @@ static int scriptGetOrderFromNum(uint32 nScript) { * first been locked with a call to LockDialogs() */ static int dialogGetOrderFromNum(uint32 nDialog) { - int i; LPMPALDIALOG dialog = GLOBALS._lpmdDialogs; - for (i = 0; i < GLOBALS._nDialogs; i++, dialog++) { + for (int i = 0; i < GLOBALS._nDialogs; i++, dialog++) { if (dialog->nObj == nDialog) return i; } @@ -301,14 +294,13 @@ static int dialogGetOrderFromNum(uint32 nDialog) { static char *DuplicateMessage(uint32 nMsgOrd) { const char *origmsg; char *clonemsg; - int j; if (nMsgOrd == (uint32)-1) return NULL; origmsg = (const char *)globalLock(GLOBALS._lpmmMsgs[nMsgOrd]._hText); - j = 0; + int j = 0; while (origmsg[j] != '\0' || origmsg[j + 1] != '\0') j++; j += 2; @@ -335,15 +327,14 @@ static char *duplicateDialogPeriod(uint32 nPeriod) { const char *origmsg; char *clonemsg; LPMPALDIALOG dialog = GLOBALS._lpmdDialogs + GLOBALS._nExecutingDialog; - int i, j; - for (j = 0; dialog->_periods[j] != NULL; j++) { + for (int j = 0; dialog->_periods[j] != NULL; j++) { if (dialog->_periodNums[j] == nPeriod) { /* Found the phrase, it should be duplicated */ origmsg = (const char *)globalLock(dialog->_periods[j]); /* Calculate the length and allocate memory */ - i = 0; + int i = 0; while (origmsg[i] != '\0') i++; @@ -370,14 +361,13 @@ static char *duplicateDialogPeriod(uint32 nPeriod) { * @returns Handle to the loaded resource */ HGLOBAL resLoad(uint32 dwId) { - int i; HGLOBAL h; char head[4]; uint32 nBytesRead; uint32 nSizeComp, nSizeDecomp; byte *temp, *buf; - for (i = 0; i < GLOBALS._nResources; i++) + for (int i = 0; i < GLOBALS._nResources; i++) if (GLOBALS._lpResources[i * 2] == dwId) { GLOBALS._hMpr.seek(GLOBALS._lpResources[i * 2 + 1]); nBytesRead = GLOBALS._hMpr.read(head, 4); @@ -416,12 +406,11 @@ HGLOBAL resLoad(uint32 dwId) { static uint32 *getSelectList(uint32 i) { uint32 *sl; - int j, k, num; LPMPALDIALOG dialog = GLOBALS._lpmdDialogs + GLOBALS._nExecutingDialog; /* Count how many are active selects */ - num = 0; - for (j = 0; dialog->_choice[i]._select[j].dwData != 0; j++) { + int num = 0; + for (int j = 0; dialog->_choice[i]._select[j].dwData != 0; j++) { if (dialog->_choice[i]._select[j].curActive) num++; } @@ -430,13 +419,13 @@ static uint32 *getSelectList(uint32 i) { if (num == 0) return NULL; - sl= (uint32 *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(uint32) * (num + 1)); + sl = (uint32 *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(uint32) * (num + 1)); if (sl == NULL) return NULL; /* Copy all the data inside the active select list */ - k = 0; - for (j = 0; dialog->_choice[i]._select[j].dwData != 0; j++) { + int k = 0; + for (int j = 0; dialog->_choice[i]._select[j].dwData != 0; j++) { if (dialog->_choice[i]._select[j].curActive) sl[k++] = dialog->_choice[i]._select[j].dwData; } @@ -447,11 +436,10 @@ static uint32 *getSelectList(uint32 i) { static uint32 *GetItemList(uint32 nLoc) { uint32 *il; - uint32 num,i,j; LPMPALVAR v = GLOBALS._lpmvVars; - num = 0; - for (i = 0; i < GLOBALS._nVars; i++, v++) { + uint32 num = 0; + for (uint32 i = 0; i < GLOBALS._nVars; i++, v++) { if (strncmp(v->lpszVarName,"Location",8) == 0 && v->dwVal == nLoc) num++; } @@ -461,8 +449,8 @@ static uint32 *GetItemList(uint32 nLoc) { return NULL; v = GLOBALS._lpmvVars; - j = 0; - for (i = 0; i < GLOBALS._nVars; i++, v++) { + uint32 j = 0; + for (uint32 i = 0; i < GLOBALS._nVars; i++, v++) { if (strncmp(v->lpszVarName, "Location", 8) == 0 && v->dwVal == nLoc) { sscanf(v->lpszVarName, "Location.%u", &il[j]); j++; @@ -478,9 +466,7 @@ static LPITEM getItemData(uint32 nOrdItem) { LPITEM ret; HGLOBAL hDat; char *dat; - int i, j; char *patlength; - uint32 dim; // Zeroing out the allocated memory is required!!! ret = (LPITEM)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(ITEM)); @@ -492,7 +478,7 @@ static LPITEM getItemData(uint32 nOrdItem) { dat = (char *)globalLock(hDat); if (dat[0] == 'D' && dat[1] == 'A' && dat[2] == 'T') { - i = dat[3]; // For version 1.0!! + int i = dat[3]; // For version 1.0!! dat += 4; if (i >= 0x10) { // From 1.0, there's a destination point for each object @@ -513,21 +499,21 @@ static LPITEM getItemData(uint32 nOrdItem) { ret->_destZ = *dat++; // Upload the left & top co-ordinates of each frame - for (i = 0; i < ret->_numframe; i++) { + for (int i = 0; i < ret->_numframe; i++) { ret->_frameslocations[i].left = (int16)READ_LE_UINT16(dat); ret->_frameslocations[i].top = (int16)READ_LE_UINT16(dat + 2); dat += 4; } // Upload the size of each frame and calculate the right & bottom - for (i = 0; i < ret->_numframe; i++) { + for (int i = 0; i < ret->_numframe; i++) { ret->_frameslocations[i].right = (int16)READ_LE_UINT16(dat) + ret->_frameslocations[i].left; ret->_frameslocations[i].bottom = (int16)READ_LE_UINT16(dat + 2) + ret->_frameslocations[i].top; dat += 4; } // Upload the bounding boxes of each frame - for (i = 0; i < ret->_numframe; i++) { + for (int i = 0; i < ret->_numframe; i++) { ret->_bbox[i].left = (int16)READ_LE_UINT16(dat); ret->_bbox[i].top = (int16)READ_LE_UINT16(dat + 2); ret->_bbox[i].right = (int16)READ_LE_UINT16(dat + 4); @@ -539,16 +525,16 @@ static LPITEM getItemData(uint32 nOrdItem) { patlength = dat; dat += ret->_numpattern; - for (i = 1; i < ret->_numpattern; i++) { - for (j = 0; j < patlength[i]; j++) + for (int i = 1; i < ret->_numpattern; i++) { + for (int j = 0; j < patlength[i]; j++) ret->_pattern[i][j] = dat[j]; ret->_pattern[i][(int)patlength[i]] = 255; // Terminate pattern dat += patlength[i]; } // Upload the individual frames of animations - for (i = 1; i < ret->_numframe; i++) { - dim = (uint32)(ret->_frameslocations[i].right - ret->_frameslocations[i].left) * + for (int i = 1; i < ret->_numframe; i++) { + uint32 dim = (uint32)(ret->_frameslocations[i].right - ret->_frameslocations[i].left) * (uint32)(ret->_frameslocations[i].bottom - ret->_frameslocations[i].top); ret->_frames[i] = (char *)globalAlloc(GMEM_FIXED,dim); @@ -559,7 +545,7 @@ static LPITEM getItemData(uint32 nOrdItem) { } // Check if we've got to the end of the file - i = READ_LE_UINT16(dat); + int i = READ_LE_UINT16(dat); if (i != 0xABCD) return NULL; @@ -1288,16 +1274,14 @@ void doChoice(CORO_PARAM, uint32 nChoice) { */ static uint32 doAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { LPMPALITEM item = GLOBALS._lpmiItems; - int i; LPMPALITEM newitem; - uint32 h; item+=ordItem; Common::String buf = Common::String::format("Status.%u", item->nObj); if (varGetValue(buf.c_str()) <= 0) return CORO_INVALID_PID_VALUE; - for (i = 0; i < item->nActions; i++) { + for (int i = 0; i < item->nActions; i++) { if (item->Action[i].num != nAction) continue; @@ -1326,6 +1310,7 @@ static uint32 doAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { // and a second process to free up the memory when the action is finished. // !!! New process management + uint32 h; if ((h = CoroScheduler.createProcess(ActionThread, &newitem, sizeof(LPMPALITEM))) == CORO_INVALID_PID_VALUE) return CORO_INVALID_PID_VALUE; @@ -1353,8 +1338,6 @@ static uint32 doAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { * The data on the choices may be obtained through various queries. */ static uint32 doDialog(uint32 nDlgOrd, uint32 nGroup) { - uint32 h; - // Store the running dialog in a global variable GLOBALS._nExecutingDialog = nDlgOrd; @@ -1367,6 +1350,7 @@ static uint32 doDialog(uint32 nDlgOrd, uint32 nGroup) { // Create a thread that performs the dialogue group // Create the process + uint32 h; if ((h = CoroScheduler.createProcess(GroupThread, &nGroup, sizeof(uint32))) == CORO_INVALID_PID_VALUE) return CORO_INVALID_PID_VALUE; @@ -1589,7 +1573,6 @@ void mpalFree() { * method that returns numeric results. */ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { - int x, y; Common::String buf; uint32 dwRet = 0; char *n; @@ -1635,8 +1618,8 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { * uint32 mpalQuery(MPQ_LOCATION_SIZE, uint32 nLoc, uint32 dwCoord); */ lockLocations(); - x = locGetOrderFromNum(GETARG(uint32)); - y = GETARG(uint32); + int x = locGetOrderFromNum(GETARG(uint32)); + int y = GETARG(uint32); if (x != -1) { if (y == MPQ_X) dwRet = GLOBALS._lpmlLocations[x].dwXlen; @@ -1678,7 +1661,7 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { * bool mpalQuery(MPQ_ITEM_IS_ACTIVE, uint32 nItem); */ lockVar(); - x = GETARG(uint32); + int x = GETARG(uint32); buf = Common::String::format("Status.%u", x); if (varGetValue(buf.c_str()) <= 0) dwRet = (uint32)false; @@ -1692,14 +1675,14 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { * uint32 mpalQuery(MPQ_ITEM_NAME, uint32 nItem, char * lpszName); */ lockVar(); - x = GETARG(uint32); + int x = GETARG(uint32); n = GETARG(char *); buf = Common::String::format("Status.%u", x); if (varGetValue(buf.c_str()) <= 0) n[0]='\0'; else { lockItems(); - y = itemGetOrderFromNum(x); + int y = itemGetOrderFromNum(x); memcpy(n, (char *)(GLOBALS._lpmiItems + y)->lpszDescribe, MAX_DESCRIBE_SIZE); unlockItems(); } @@ -1729,8 +1712,8 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { * bool mpalQuery(MPQ_DIALOG_SELECTION, uint32 nChoice, uint32 dwData); */ lockDialogs(); - x = GETARG(uint32); - y = GETARG(uint32); + int x = GETARG(uint32); + int y = GETARG(uint32); dwRet = (uint32)doSelection(x, y); unlockDialogs(); @@ -1741,9 +1724,9 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { */ lockItems(); lockVar(); - x = GETARG(uint32); + int x = GETARG(uint32); int z = GETARG(uint32); - y = itemGetOrderFromNum(z); + int y = itemGetOrderFromNum(z); if (y != -1) { dwRet = doAction(x, y, GETARG(uint32)); } else { @@ -1761,8 +1744,8 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { if (!GLOBALS._bExecutingDialog) { lockDialogs(); - x = dialogGetOrderFromNum(GETARG(uint32)); - y = GETARG(uint32); + int x = dialogGetOrderFromNum(GETARG(uint32)); + int y = GETARG(uint32); dwRet = doDialog(x, y); unlockDialogs(); } @@ -1787,7 +1770,6 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { * method that returns a pointer or handle. */ HANDLE mpalQueryHANDLE(uint16 wQueryType, ...) { - int x, y; char *n; Common::String buf; va_list v; @@ -1833,7 +1815,7 @@ HANDLE mpalQueryHANDLE(uint16 wQueryType, ...) { * HGLOBAL mpalQuery(MPQ_LOCATION_IMAGE, uint32 nLoc); */ lockLocations(); - x = locGetOrderFromNum(GETARG(uint32)); + int x = locGetOrderFromNum(GETARG(uint32)); hRet = resLoad(GLOBALS._lpmlLocations[x].dwPicRes); unlockLocations(); @@ -1870,14 +1852,14 @@ HANDLE mpalQueryHANDLE(uint16 wQueryType, ...) { * uint32 mpalQuery(MPQ_ITEM_NAME, uint32 nItem, char *lpszName); */ lockVar(); - x = GETARG(uint32); + int x = GETARG(uint32); n = GETARG(char *); buf = Common::String::format("Status.%u", x); if (varGetValue(buf.c_str()) <= 0) n[0] = '\0'; else { lockItems(); - y = itemGetOrderFromNum(x); + int y = itemGetOrderFromNum(x); memcpy(n, (char *)(GLOBALS._lpmiItems + y)->lpszDescribe, MAX_DESCRIBE_SIZE); unlockItems(); } @@ -1889,7 +1871,7 @@ HANDLE mpalQueryHANDLE(uint16 wQueryType, ...) { * char * mpalQuery(MPQ_DIALOG_PERIOD, uint32 nDialog, uint32 nPeriod); */ lockDialogs(); - y = GETARG(uint32); + int y = GETARG(uint32); hRet = duplicateDialogPeriod(y); unlockDialogs(); @@ -1998,11 +1980,10 @@ uint32 mpalGetError() { * @returns TRUE if the script 'was launched, FALSE on failure */ bool mpalExecuteScript(int nScript) { - int n; LPMPALSCRIPT s; LockScripts(); - n = scriptGetOrderFromNum(nScript); + int n = scriptGetOrderFromNum(nScript); s = (LPMPALSCRIPT)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MPALSCRIPT)); if (s == NULL) return false; @@ -2039,14 +2020,12 @@ void mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCus) { * simultaneously is defined defined by MAXPOLLINGFUNCIONS */ bool mpalStartIdlePoll(int nLoc) { - uint32 i; - - for (i = 0; i < MAXPOLLINGLOCATIONS; i++) { + for (uint32 i = 0; i < MAXPOLLINGLOCATIONS; i++) { if (GLOBALS._nPollingLocations[i] == (uint32)nLoc) return false; } - for (i = 0; i < MAXPOLLINGLOCATIONS; i++) { + for (uint32 i = 0; i < MAXPOLLINGLOCATIONS; i++) { if (GLOBALS._nPollingLocations[i] == 0) { GLOBALS._nPollingLocations[i] = nLoc; diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index 70c33e71ee..db83c2910b 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -38,12 +38,9 @@ namespace Tony { */ Common::String readString(Common::ReadStream &df) { Common::String var; - uint8 len; - int i; + uint8 len = df.readByte(); - len = df.readByte(); - - for (i = 0; i < len; i++) { + for (int i = 0; i < len; i++) { char c; c = df.readByte(); var += c; @@ -356,16 +353,14 @@ void RMResUpdate::init(const Common::String &fileName) { // It doesn't exist, so exit immediately return; - uint8 version; - uint32 i; + uint8 version = _hFile.readByte(); - version = _hFile.readByte(); _numUpd = _hFile.readUint32LE(); _infos = new ResUpdInfo[_numUpd]; // Load the index of the resources in the file - for (i = 0; i < _numUpd; ++i) { + for (uint32 i = 0; i < _numUpd; ++i) { ResUpdInfo &info = _infos[i]; info._dwRes = _hFile.readUint32LE(); diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index 9385db27c7..0746b267bd 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -265,7 +265,6 @@ void RMSnapshot::grabScreenshot(byte *lpBuf, int dezoom, uint16 *lpDestBuf) { int dimx = RM_SX / dezoom; int dimy = RM_SY / dezoom; - uint32 k = 0; uint16 *cursrc; if (lpDestBuf == NULL) @@ -292,6 +291,7 @@ void RMSnapshot::grabScreenshot(byte *lpBuf, int dezoom, uint16 *lpDestBuf) { src += RM_BBX; } } else { + uint32 k = 0; for (int y = 0; y < dimy; y++) { for (int x = 0; x < dimx; x++) { cursrc = &src[RM_SKIPX + x * dezoom]; -- cgit v1.2.3 From 92a9820f3371037fa9009e4b2c9831f169cd8809 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 29 Aug 2012 08:11:52 +0200 Subject: TONY: Translate some remaining italian comments --- engines/tony/mpal/expr.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/expr.cpp b/engines/tony/mpal/expr.cpp index 2b2dbf2529..5f3026144c 100644 --- a/engines/tony/mpal/expr.cpp +++ b/engines/tony/mpal/expr.cpp @@ -222,7 +222,7 @@ static int evaluateAndFreeExpression(byte *expr) { int num = *expr; one = (LPEXPRESSION)(expr + 1); - // 1) Sostituzioni delle variabili + // 1) Substitutions of variables cur = one; for (int i = 0; i < num; i++, cur++) { if (cur->type == ELT_VAR) { @@ -231,7 +231,7 @@ static int evaluateAndFreeExpression(byte *expr) { } } - // 2) Sostituzioni delle parentesi (tramite ricorsione) + // 2) Replacement of brackets (using recursive calls) cur = one; for (int i = 0; i < num; i++, cur++) { if (cur->type == ELT_PARENTH2) { @@ -240,7 +240,7 @@ static int evaluateAndFreeExpression(byte *expr) { } } - // 3) Risoluzione algebrica + // 3) algebraic resolution solve(one, num); int val = one->val.num; globalDestroy(expr); -- cgit v1.2.3 From a29f1fb04ca4ee84986c359f1a1743d16c675487 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 29 Aug 2012 08:14:41 +0200 Subject: TONY: Remove some dead code --- engines/tony/mpal/mpal.cpp | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) (limited to 'engines') diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 540dee664f..862ea53824 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -637,7 +637,7 @@ void ScriptThread(CORO_PARAM, const void *param) { _ctx->p->_arg3 = s->_command[_ctx->k]._arg3; _ctx->p->_arg4 = s->_command[_ctx->k]._arg4; - // !!! New process management + // !!! New process management if ((cfHandles[_ctx->numHandles++] = CoroScheduler.createProcess(CustomThread, &_ctx->p, sizeof(LPCFCALL))) == 0) { GLOBALS._mpalError = 1; @@ -1413,10 +1413,6 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, uint32 dwSizeDecomp, dwSizeComp; byte *cmpbuf; - //printf("Item: %lu\n", sizeof(MPALITEM)); - //printf("Script: %lu\n", sizeof(MPALSCRIPT)); - //printf("Dialog: %lu\n", sizeof(MPALDIALOG)); - /* Save the array of custom functions */ GLOBALS._lplpFunctions = lplpcfArray; GLOBALS._lplpFunctionStrings = lpcfStrings; @@ -1480,21 +1476,6 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, globalDestroy(lpMpcImage); - /* Calculate memory usage */ - /* - { - char errbuf[256]; - wsprintf(errbuf,"Utilizzo in RAM: VAR %lu, MSG %lu, DLG %lu, ITM %lu, LOC %lu, SCR %lu", - GLOBALS.nVars*sizeof(MPALVAR), - GLOBALS.nMsgs*sizeof(MPALMSG), - GLOBALS.nDialogs*sizeof(MPALDIALOG), - GLOBALS.nItems*sizeof(MPALITEM), - GLOBALS.nLocations*sizeof(MPALLOCATION), - GLOBALS.nScripts*sizeof(MPALSCRIPT)); - MessageBox(NULL,errbuf,"Dump",MB_OK); - } -*/ - /* Open the MPR file */ if (!GLOBALS._hMpr.open(lpszMprFileName)) return false; -- cgit v1.2.3 From a6673aaf906505341d8ef259db69efc0f4c540fe Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Wed, 29 Aug 2012 09:12:53 +0200 Subject: TONY: Remove useless/commented music code. --- engines/tony/globals.h | 1 - engines/tony/sound.cpp | 12 +++--------- engines/tony/sound.h | 2 +- engines/tony/tony.cpp | 12 +----------- 4 files changed, 5 insertions(+), 22 deletions(-) (limited to 'engines') diff --git a/engines/tony/globals.h b/engines/tony/globals.h index e353d40f3b..0911782eac 100644 --- a/engines/tony/globals.h +++ b/engines/tony/globals.h @@ -180,7 +180,6 @@ public: int _nextSync; int _curChannel; int _flipflop; - // OSystem::MutexRef csMusic; CharacterStruct _character[16]; MCharacterStruct _mCharacter[10]; ChangedHotspotStruct _changedHotspot[256]; diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index 0f9f1c2bbe..e8b9dfc42a 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -583,7 +583,7 @@ bool FPStream::play() { * */ -bool FPStream::stop(bool bSync) { +bool FPStream::stop() { if (!_bSoundSupported) return true; @@ -593,15 +593,9 @@ bool FPStream::stop(bool bSync) { if (!g_system->getMixer()->isSoundHandleActive(_handle)) return false; - if (bSync) { - // The caller intends to call waitForSync. - // FIXME: Why call this in that case?! Looks like old code. Remove that parameter. - return true; - } else { - g_system->getMixer()->stopHandle(_handle); + g_system->getMixer()->stopHandle(_handle); - _bPaused = false; - } + _bPaused = false; return true; } diff --git a/engines/tony/sound.h b/engines/tony/sound.h index bd858e5bca..73938ecd8c 100644 --- a/engines/tony/sound.h +++ b/engines/tony/sound.h @@ -333,7 +333,7 @@ public: * @returns True is everything is OK, False otherwise */ - bool stop(bool bSync = false); + bool stop(); void waitForSync(FPStream *toplay); /** diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 79300ca1ee..d135f66fde 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -364,7 +364,6 @@ void TonyEngine::doNextMusic(CORO_PARAM, const void *param) { streams[GLOBALS._nextChannel]->setLoop(GLOBALS._nextLoop); //streams[GLOBALS._nextChannel]->prefetch(); - streams[GLOBALS._curChannel]->stop(true); streams[GLOBALS._curChannel]->waitForSync(streams[GLOBALS._nextChannel]); streams[GLOBALS._curChannel]->unloadFile(); @@ -392,14 +391,10 @@ void TonyEngine::playSFX(int nChannel, int nFX) { } void TonyEngine::stopMusic(int nChannel) { -// g_system->lockMutex(csMusic); - if (nChannel < 4) _stream[nChannel + GLOBALS._flipflop]->stop(); else _stream[nChannel]->stop(); - -// g_system->unlockMutex(csMusic); } void TonyEngine::stopSFX(int nChannel) { @@ -484,7 +479,7 @@ void TonyEngine::unloadAllUtilSFX() { void TonyEngine::initMusic() { int i; - _theSound.init(/*_window*/); + _theSound.init(); _theSound.setMasterVolume(63); for (i = 0; i < 6; i++) @@ -494,9 +489,6 @@ void TonyEngine::initMusic() { _sfx[i] = _utilSfx[i] = NULL; } - // Create the mutex for controlling music access -// csMusic = g_system->createMutex(); - // Preload sound effects preloadUtilSFX(0, "U01.ADP"); // Reversed!! preloadUtilSFX(1, "U02.ADP"); @@ -512,8 +504,6 @@ void TonyEngine::closeMusic() { _stream[i]->release(); } -// g_system->deleteMutex(csMusic); - unloadAllSFX(); unloadAllUtilSFX(); } -- cgit v1.2.3 From 985151fe13d878739287be7827e9b6168010e3ea Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Wed, 29 Aug 2012 09:13:37 +0200 Subject: TONY: Limit effect of cursor workaround. This avoids incorrect hotspot offsets. --- engines/tony/game.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'engines') diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 0793d97215..00aa9c1109 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -1485,15 +1485,15 @@ void RMPointer::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim if (_ctx->n == TA_COMBINE) _ctx->n = TA_USE; - // WORKAROUND: updateCursor gets called too early sometimes (for example, when - // the cursor is released over the TA_PERORATE option), via setAction. - if (_ctx->n > 4) - _ctx->n = 0; - _cursorHotspot = _hotspot[_ctx->n]; // Call the Draw method of the pointer if (_nCurSpecialPointer == 0) { + // WORKAROUND: updateCursor gets called too early sometimes (for example, when + // the cursor is released over the TA_PERORATE option), via setAction. + if (_ctx->n > 4) + _ctx->n = 0; + CORO_INVOKE_2(_pointer[_ctx->n]->draw, bigBuf, prim); } else { if (_nCurSpecialPointer == PTR_CUSTOM) -- cgit v1.2.3 From 766eadeef98e6adcd52e5fb5325a1f7586572402 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 29 Aug 2012 22:47:33 +0200 Subject: TONY: Translate some remaining Italian comments --- engines/tony/loc.cpp | 12 ++++++------ engines/tony/mpal/loadmpc.cpp | 13 +++++-------- engines/tony/mpal/mpal.cpp | 3 +-- engines/tony/mpal/mpal.h | 2 +- 4 files changed, 13 insertions(+), 17 deletions(-) (limited to 'engines') diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 6401e1337f..5d11672e34 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -57,19 +57,19 @@ void RMPattern::RMSlot::readFromStream(Common::ReadStream &ds, bool bLOX) { type = ds.readByte(); _type = (RMPattern::RMSlotType)type; - // Dati + // Data _data = ds.readSint32LE(); - // Posizione + // Position _pos.readFromStream(ds); - // Flag generica + // Generic flag _flag = ds.readByte(); } /****************************************************************************\ -* Metodi di RMPattern +* RMPattern Methods \****************************************************************************/ void RMPattern::readFromStream(Common::ReadStream &ds, bool bLOX) { @@ -547,7 +547,7 @@ void RMItem::readFromStream(Common::SeekableReadStream &ds, bool bLOX) { if (_bInitCurPattern) setPattern(mpalQueryItemPattern(_mpalCode)); - // Initailise the current activation state + // Initialize the current activation state _bIsActive = mpalQueryItemIsActive(_mpalCode); } @@ -883,7 +883,7 @@ short RMCharacter::findPath(short source, short destination) { static RMBox BOX[MAXBOXES]; // Matrix of adjacent boxes static short COSTO[MAXBOXES]; // Cost per node static short VALIDO[MAXBOXES]; // 0:Invalid 1:Valid 2:Saturated - static short NEXT[MAXBOXES]; // Prossimo Nodo + static short NEXT[MAXBOXES]; // Next node short i, j, k, costominimo, fine, errore = 0; RMBoxLoc *cur; diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index 790d8d4903..e23197144b 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -26,9 +26,6 @@ * Copyright (c) 1997-2003 Nayma Software */ -/* -#include "lzo1x.h" -*/ #include "mpal.h" #include "mpaldll.h" #include "memory.h" @@ -148,7 +145,7 @@ static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { lpmdDialog->nObj = READ_LE_UINT32(lpBuf); lpBuf += 4; - /* Periodi */ + /* Periods */ uint32 num = READ_LE_UINT16(lpBuf); lpBuf += 2; @@ -169,7 +166,7 @@ static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { lpmdDialog->_periodNums[i] = 0; lpmdDialog->_periods[i] = NULL; - /* Gruppi */ + /* Groups */ num = READ_LE_UINT16(lpBuf); lpBuf += 2; uint32 curCmd = 0; @@ -347,7 +344,7 @@ static const byte *parseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { lpmiItem->nActions=*lpBuf; lpBuf++; - /* Alloca le azioni */ + /* Allocation action */ if (lpmiItem->nActions > 0) lpmiItem->Action = (ItemAction *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(struct ItemAction) * (int)lpmiItem->nActions); @@ -544,7 +541,7 @@ bool ParseMpc(const byte *lpBuf) { GLOBALS._lpmvVars->dwVal = READ_LE_UINT32(lpBuf); lpBuf += 4; - lpBuf++; // Salta 'ext' + lpBuf++; // Skip 'ext' GLOBALS._lpmvVars++; } @@ -688,7 +685,7 @@ bool ParseMpc(const byte *lpBuf) { for (uint16 i = 0; i < GLOBALS._nScripts; i++) { if ((lpBuf = ParseScript(lpBuf + 7, &GLOBALS._lpmsScripts[i])) == NULL) - return false; + return false; // Sort the various moments of the script //qsort( diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 862ea53824..b4b18749ef 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -920,8 +920,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { /* Here's the main loop */ while (1) { - /* Cerchiamo tra tutte le idle actions quella a cui manca meno tempo per - l'esecuzione */ + // Searching for idle actions requiring time to execute _ctx->curTime = g_vm->getTime(); _ctx->dwSleepTime = (uint32)-1L; diff --git a/engines/tony/mpal/mpal.h b/engines/tony/mpal/mpal.h index 20f2b0b170..4c8ca481b0 100644 --- a/engines/tony/mpal/mpal.h +++ b/engines/tony/mpal/mpal.h @@ -200,7 +200,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; /** * Gets the numerical value of a global variable * - * @param lpszVarName Nome della variabile (ASCIIZ) + * @param lpszVarName Variable name (ASCIIZ) * @returns Global variable value * @remarks This query was implemented for debugging. The program, * if well designed, should not need to access variables from -- cgit v1.2.3 From 825e0896dc52c26e7e31447a434619e190e5c183 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 29 Aug 2012 23:25:14 +0200 Subject: TONY: Replace C-style comments by C++-style ones. Also translate some more Italian comments --- engines/tony/custom.h | 5 -- engines/tony/font.cpp | 8 +-- engines/tony/game.cpp | 7 +-- engines/tony/gfxcore.cpp | 20 +++--- engines/tony/mpal/expr.cpp | 4 -- engines/tony/mpal/loadmpc.cpp | 14 ++--- engines/tony/mpal/mpal.cpp | 141 +++++++++++++++++++++--------------------- engines/tony/mpal/mpal.h | 12 ++-- engines/tony/sound.cpp | 2 +- engines/tony/window.h | 2 +- 10 files changed, 99 insertions(+), 116 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.h b/engines/tony/custom.h index 514af1223c..9e18ae2090 100644 --- a/engines/tony/custom.h +++ b/engines/tony/custom.h @@ -18,7 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * */ /* @@ -37,10 +36,6 @@ namespace Tony { using namespace MPAL; -/* - * Defines - */ - typedef uint32 HWND; #define INIT_CUSTOM_FUNCTION MapCustomFunctions diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 89cf2ffa1b..901a41b7c4 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -206,7 +206,7 @@ void RMFontDialog::init() { load(RES_F_PARL, nchars, 20, 20); - // Initialize the f**king table + // Initialize the font table _lDefault = 13; _hDefault = 18; Common::fill(&_l2Table[0][0], &_l2Table[0][0] + (256 * 256), '\0'); @@ -281,7 +281,7 @@ void RMFontCredits::init() { /***************************************************************************\ -* Metodi di RMFontObj +* RMFontObj Methods \****************************************************************************/ #define TOUPPER(a) ((a) >= 'a' && (a) <= 'z' ? (a) + 'A' - 'a' : (a)) @@ -310,7 +310,7 @@ void RMFontObj::init() { load(RES_F_OBJ, nchars, 25, 30); - // Initialize the f**king table + // Initialize the font table _lDefault = 26; _hDefault = 30; Common::fill(&_l2Table[0][0], &_l2Table[0][0] + (256 * 256), '\0'); @@ -320,7 +320,7 @@ void RMFontObj::init() { _lTable[i] = g_vm->_lTableObj[i]; } - /* Casi particolari */ + // Special case setBothCase('C', 'C', 2); setBothCase('A', 'T', -2); setBothCase('R', 'S', 2); diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 00aa9c1109..224427d10f 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -43,10 +43,7 @@ namespace Tony { using namespace MPAL; -/****************************************/ -/* Global functions */ -/****************************************/ - +// Global functions void mainEnableGUI() { g_vm->getEngine()->_bGUIInterface = true; g_vm->getEngine()->_bGUIInventory = true; @@ -1045,7 +1042,7 @@ void RMOptionScreen::doFrame(CORO_PARAM, RMInput *input) { #define PROCESS_CHAR(cod,c) if (KEYPRESS(cod)) { \ _editName[strlen(_editName) + 1] = '\0'; _editName[strlen(_editName)] = c; _ctx->bRefresh = true; } - /**************** State Buttons **************/ + // State Buttons if (_bEditSaveName) { if (KEYPRESS(Common::KEYCODE_BACKSPACE)) { if (_editName[0] != '\0') { diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 2e368bbc64..53f64aad12 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -1610,7 +1610,7 @@ void RMGfxSourceBuffer8AA::calculateAA() { int x, y; byte *src, *srcaa; - /* First pass: fill the edges */ + // First pass: fill the edges Common::fill(_megaAABuf, _megaAABuf + _dimx * _dimy, 0); src = _buf; @@ -1715,11 +1715,9 @@ void RMGfxSourceBuffer8AA::drawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri // Loop buf += bigBuf.getDimx(); // Skip the first line for (y = 1; y < height - 1; y++) { - /* - if (prim->IsFlipped()) - mybuf=&buf[x1+m_dimx-1]; - else - */ + // if (prim->IsFlipped()) + // mybuf=&buf[x1+m_dimx-1]; + // else mybuf = &buf[x1]; for (x = 0; x < width; x++, mybuf += step) { @@ -1748,18 +1746,16 @@ void RMGfxSourceBuffer8AA::drawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri buf += bigBuf.getDimx(); } -// Position into the destination buffer + // Position into the destination buffer buf = bigBuf; buf += y1 * bigBuf.getDimx(); // Looppone buf += bigBuf.getDimx(); for (y = 1; y < height - 1; y++) { - /* - if (prim->IsFlipped()) - mybuf=&buf[x1+m_dimx-1]; - else - */ + // if (prim->IsFlipped()) + // mybuf=&buf[x1+m_dimx-1]; + // else mybuf = &buf[x1]; for (x = 0; x < width; x++, mybuf += step) { diff --git a/engines/tony/mpal/expr.cpp b/engines/tony/mpal/expr.cpp index 5f3026144c..31abeb0810 100644 --- a/engines/tony/mpal/expr.cpp +++ b/engines/tony/mpal/expr.cpp @@ -31,10 +31,6 @@ #include "tony/mpal/mpaldll.h" #include "tony/tony.h" -/* -#include "lzo1x.h" -*/ - namespace Tony { namespace MPAL { diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index e23197144b..9927f9fe8e 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -145,7 +145,7 @@ static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { lpmdDialog->nObj = READ_LE_UINT32(lpBuf); lpBuf += 4; - /* Periods */ + // Periods uint32 num = READ_LE_UINT16(lpBuf); lpBuf += 2; @@ -166,7 +166,7 @@ static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { lpmdDialog->_periodNums[i] = 0; lpmdDialog->_periods[i] = NULL; - /* Groups */ + // Groups num = READ_LE_UINT16(lpBuf); lpBuf += 2; uint32 curCmd = 0; @@ -255,7 +255,7 @@ static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { if (curCmd >= MAX_COMMANDS_PER_DIALOG) error("Too much commands in dialog #%d",lpmdDialog->nObj); - /* Choices */ + // Choices num = READ_LE_UINT16(lpBuf); lpBuf += 2; @@ -344,7 +344,7 @@ static const byte *parseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { lpmiItem->nActions=*lpBuf; lpBuf++; - /* Allocation action */ + // Allocation action if (lpmiItem->nActions > 0) lpmiItem->Action = (ItemAction *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(struct ItemAction) * (int)lpmiItem->nActions); @@ -519,7 +519,7 @@ static const byte *ParseLocation(const byte *lpBuf, LPMPALLOCATION lpmlLocation) bool ParseMpc(const byte *lpBuf) { byte *lpTemp; - /* 1. Variables */ + // 1. Variables if (lpBuf[0] != 'V' || lpBuf[1] != 'A' || lpBuf[2] != 'R' || lpBuf[3] != 'S') return false; @@ -547,7 +547,7 @@ bool ParseMpc(const byte *lpBuf) { globalUnlock(GLOBALS._hVars); - /* 2. Messages */ + // 2. Messages if (lpBuf[0] != 'M' || lpBuf[1] != 'S' || lpBuf[2] != 'G' || lpBuf[3] != 'S') return false; @@ -596,7 +596,7 @@ bool ParseMpc(const byte *lpBuf) { globalUnlock(GLOBALS._hMsgs); #endif - /* 3. Objects */ + // 3. Objects if (lpBuf[0] != 'O' || lpBuf[1] != 'B' || lpBuf[2] != 'J' || lpBuf[3] != 'S') return false; diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index b4b18749ef..514001eda7 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -330,10 +330,10 @@ static char *duplicateDialogPeriod(uint32 nPeriod) { for (int j = 0; dialog->_periods[j] != NULL; j++) { if (dialog->_periodNums[j] == nPeriod) { - /* Found the phrase, it should be duplicated */ + // Found the phrase, it should be duplicated origmsg = (const char *)globalLock(dialog->_periods[j]); - /* Calculate the length and allocate memory */ + // Calculate the length and allocate memory int i = 0; while (origmsg[i] != '\0') i++; @@ -408,14 +408,14 @@ static uint32 *getSelectList(uint32 i) { uint32 *sl; LPMPALDIALOG dialog = GLOBALS._lpmdDialogs + GLOBALS._nExecutingDialog; - /* Count how many are active selects */ + // Count how many are active selects int num = 0; for (int j = 0; dialog->_choice[i]._select[j].dwData != 0; j++) { if (dialog->_choice[i]._select[j].curActive) num++; } - /* If there are 0, it's a mistake */ + // If there are 0, it's a mistake if (num == 0) return NULL; @@ -423,7 +423,7 @@ static uint32 *getSelectList(uint32 i) { if (sl == NULL) return NULL; - /* Copy all the data inside the active select list */ + // Copy all the data inside the active select list int k = 0; for (int j = 0; dialog->_choice[i]._select[j].dwData != 0; j++) { if (dialog->_choice[i]._select[j].curActive) @@ -821,18 +821,18 @@ void LocationPollThread(CORO_PARAM, const void *param) { CORO_BEGIN_CODE(_ctx); - /* Initialize data pointers */ + // Initialize data pointers _ctx->MyActions = NULL; _ctx->MyThreads = NULL; - /* To begin with, we need to request the item list from the location */ + // To begin with, we need to request the item list from the location _ctx->il = mpalQueryItemList(GLOBALS._nPollingLocations[id]); - /* Count the items */ + // Count the items for (_ctx->numitems = 0; _ctx->il[_ctx->numitems] != 0; _ctx->numitems++) ; - /* We look for items without idle actions, and eliminate them from the list */ + // We look for items without idle actions, and eliminate them from the list lockItems(); _ctx->nIdleActions = 0; _ctx->nRealItems = 0; @@ -853,14 +853,14 @@ void LocationPollThread(CORO_PARAM, const void *param) { _ctx->nIdleActions += _ctx->k; if (_ctx->k == 0) - /* We can remove this item from the list */ + // We can remove this item from the list _ctx->il[_ctx->i] = (uint32)NULL; else _ctx->nRealItems++; } unlockItems(); - /* If there is nothing left, we can exit */ + // If there is nothing left, we can exit if (_ctx->nRealItems == 0) { globalDestroy(_ctx->il); CORO_KILL_SELF(); @@ -875,8 +875,8 @@ void LocationPollThread(CORO_PARAM, const void *param) { } - /* We have established that there is at least one item that contains idle actions. - Now we created the mirrored copies of the idle actions. */ + // We have established that there is at least one item that contains idle actions. + // Now we created the mirrored copies of the idle actions. _ctx->MyActions = (MYACTION *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, _ctx->nIdleActions * sizeof(MYACTION)); if (_ctx->MyActions == NULL) { globalDestroy(_ctx->MyThreads); @@ -914,11 +914,11 @@ void LocationPollThread(CORO_PARAM, const void *param) { unlockItems(); - /* We don't need the item list anymore */ + // We don't need the item list anymore globalDestroy(_ctx->il); - /* Here's the main loop */ + // Here's the main loop while (1) { // Searching for idle actions requiring time to execute _ctx->curTime = g_vm->getTime(); @@ -932,7 +932,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { _ctx->dwSleepTime = MIN(_ctx->dwSleepTime, _ctx->MyActions[_ctx->k].dwLastTime + _ctx->MyActions[_ctx->k].wTime - _ctx->curTime); } - /* We fall alseep, but always checking that the event is set when prompted for closure */ + // We fall alseep, but always checking that the event is set when prompted for closure CORO_INVOKE_3(CoroScheduler.waitForSingleObject, GLOBALS._hEndPollingLocations[id], _ctx->dwSleepTime, &_ctx->expired); //if (_ctx->k == WAIT_OBJECT_0) @@ -951,19 +951,19 @@ void LocationPollThread(CORO_PARAM, const void *param) { _ctx->curTime = g_vm->getTime(); - /* Loop through all the necessary idle actions */ + // Loop through all the necessary idle actions for (_ctx->k = 0; _ctx->k < _ctx->nIdleActions; _ctx->k++) { if (_ctx->curTime >= _ctx->MyActions[_ctx->k].dwLastTime + _ctx->MyActions[_ctx->k].wTime) { _ctx->MyActions[_ctx->k].dwLastTime += _ctx->MyActions[_ctx->k].wTime; - /* It's time to check to see if fortune is on the side of the idle action */ + // It's time to check to see if fortune is on the side of the idle action byte randomVal = (byte)g_vm->_randomSource.getRandomNumber(99); if (randomVal < _ctx->MyActions[_ctx->k].perc) { - /* Check if there is an action running on the item */ + // Check if there is an action running on the item if ((GLOBALS._bExecutingAction) && (GLOBALS._nExecutingAction == _ctx->MyActions[_ctx->k].nItem)) continue; - /* Check to see if there already another idle funning running on the item */ + // Check to see if there already another idle funning running on the item for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) { if (_ctx->MyThreads[_ctx->i].nItem == _ctx->MyActions[_ctx->k].nItem) break; @@ -972,11 +972,11 @@ void LocationPollThread(CORO_PARAM, const void *param) { if (_ctx->i < _ctx->nRealItems) continue; - /* Ok, we are the only ones :) */ + // Ok, we are the only ones :) lockItems(); _ctx->curItem = GLOBALS._lpmiItems + itemGetOrderFromNum(_ctx->MyActions[_ctx->k].nItem); - /* Check if there is a WhenExecute expression */ + // Check if there is a WhenExecute expression _ctx->j=_ctx->MyActions[_ctx->k].nAction; if (_ctx->curItem->Action[_ctx->j].when != NULL) { if (!evaluateExpression(_ctx->curItem->Action[_ctx->j].when)) { @@ -985,7 +985,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { } } - /* Ok, we can perform the action. For convenience, we do it in a new process */ + // Ok, we can perform the action. For convenience, we do it in a new process _ctx->newItem = (LPMPALITEM)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MPALITEM)); if (_ctx->newItem == false) { globalDestroy(_ctx->MyThreads); @@ -998,12 +998,12 @@ void LocationPollThread(CORO_PARAM, const void *param) { memcpy(_ctx->newItem,_ctx->curItem, sizeof(MPALITEM)); unlockItems(); - /* We copy the action in #0 */ -// _ctx->newItem->Action[0].nCmds = _ctx->curItem->Action[_ctx->j].nCmds; -// memcpy(_ctx->newItem->Action[0].CmdNum,_ctx->curItem->Action[_ctx->j].CmdNum,_ctx->newItem->Action[0].nCmds*sizeof(_ctx->newItem->Action[0].CmdNum[0])); + // We copy the action in #0 + //_ctx->newItem->Action[0].nCmds = _ctx->curItem->Action[_ctx->j].nCmds; + //memcpy(_ctx->newItem->Action[0].CmdNum,_ctx->curItem->Action[_ctx->j].CmdNum,_ctx->newItem->Action[0].nCmds*sizeof(_ctx->newItem->Action[0].CmdNum[0])); _ctx->newItem->dwRes=_ctx->j; - /* We will create an action, and will provide the necessary details */ + // We will create an action, and will provide the necessary details for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) { if (_ctx->MyThreads[_ctx->i].nItem == 0) break; @@ -1022,7 +1022,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { return; } - /* Skip all idle actions of the same item */ + // Skip all idle actions of the same item } } } @@ -1036,11 +1036,10 @@ void LocationPollThread(CORO_PARAM, const void *param) { if (_ctx->MyThreads[_ctx->i].nItem != 0) { CORO_INVOKE_3(CoroScheduler.waitForSingleObject, _ctx->MyThreads[_ctx->i].hThread, 5000, &_ctx->delayExpired); -/* //if (result != WAIT_OBJECT_0) - if (_ctx->delayExpired) - TerminateThread(_ctx->MyThreads[_ctx->i].hThread, 0); -*/ + //if (_ctx->delayExpired) + // TerminateThread(_ctx->MyThreads[_ctx->i].hThread, 0); + CoroScheduler.killMatchingProcess(_ctx->MyThreads[_ctx->i].hThread); } } @@ -1142,15 +1141,15 @@ void GroupThread(CORO_PARAM, const void *param) { } } - /* The gruop is finished, so we can return to the calling function. - * If the group was the first called, then the process will automatically - * end. Otherwise it returns to the caller method - */ + // The gruop is finished, so we can return to the calling function. + // If the group was the first called, then the process will automatically + // end. Otherwise it returns to the caller method + return; } } - /* If we are here, it means that we have not found the requested group */ + // If we are here, it means that we have not found the requested group GLOBALS._mpalError = 1; unlockDialogs(); @@ -1174,21 +1173,21 @@ void doChoice(CORO_PARAM, uint32 nChoice) { CORO_BEGIN_CODE(_ctx); - /* Lock the dialogs */ + // Lock the dialogs lockDialogs(); - /* Get a pointer to the current dialog */ + // Get a pointer to the current dialog _ctx->dialog = GLOBALS._lpmdDialogs + GLOBALS._nExecutingDialog; - /* Search the choice between those required in the dialog */ + // Search the choice between those required in the dialog for (_ctx->i = 0; _ctx->dialog->_choice[_ctx->i].nChoice != 0; _ctx->i++) { if (_ctx->dialog->_choice[_ctx->i].nChoice == nChoice) break; } - /* If nothing has been found, exit with an error */ + // If nothing has been found, exit with an error if (_ctx->dialog->_choice[_ctx->i].nChoice == 0) { - /* If we're here, we did not find the required choice */ + // If we're here, we did not find the required choice GLOBALS._mpalError = 1; unlockDialogs(); @@ -1196,14 +1195,14 @@ void doChoice(CORO_PARAM, uint32 nChoice) { return; } - /* We've found the requested choice. Remember what in global variables */ + // We've found the requested choice. Remember what in global variables GLOBALS._nExecutingChoice = _ctx->i; while (1) { GLOBALS._nExecutingChoice = _ctx->i; _ctx->k = 0; - /* Calculate the expression of each selection, to see if they're active or inactive */ + // Calculate the expression of each selection, to see if they're active or inactive for (_ctx->j = 0; _ctx->dialog->_choice[_ctx->i]._select[_ctx->j].dwData != 0; _ctx->j++) { if (_ctx->dialog->_choice[_ctx->i]._select[_ctx->j].when == NULL) { _ctx->dialog->_choice[_ctx->i]._select[_ctx->j].curActive = 1; @@ -1215,41 +1214,40 @@ void doChoice(CORO_PARAM, uint32 nChoice) { _ctx->dialog->_choice[_ctx->i]._select[_ctx->j].curActive = 0; } - /* If there are no choices activated, then the dialog is finished. */ + // If there are no choices activated, then the dialog is finished. if (_ctx->k == 0) { unlockDialogs(); break; } - /* There are choices available to the user, so wait for them to make one */ + // There are choices available to the user, so wait for them to make one CoroScheduler.resetEvent(GLOBALS._hDoneChoice); CoroScheduler.setEvent(GLOBALS._hAskChoice); CORO_INVOKE_2(CoroScheduler.waitForSingleObject, GLOBALS._hDoneChoice, CORO_INFINITE); - /* Now that the choice has been made, we can run the groups associated with the choice tbontbtitq - */ + // Now that the choice has been made, we can run the groups associated with the choice tbontbtitq _ctx->j = GLOBALS._nSelectedChoice; for (_ctx->k = 0; _ctx->dialog->_choice[_ctx->i]._select[_ctx->j].wPlayGroup[_ctx->k] != 0; _ctx->k++) { _ctx->nGroup = _ctx->dialog->_choice[_ctx->i]._select[_ctx->j].wPlayGroup[_ctx->k]; CORO_INVOKE_1(GroupThread, &_ctx->nGroup); } - /* Control attribute */ + // Control attribute if (_ctx->dialog->_choice[_ctx->i]._select[_ctx->j].attr & (1 << 0)) { - /* Bit 0 set: the end of the choice */ + // Bit 0 set: the end of the choice unlockDialogs(); break; } if (_ctx->dialog->_choice[_ctx->i]._select[_ctx->j].attr & (1 << 1)) { - /* Bit 1 set: the end of the dialog */ + // Bit 1 set: the end of the dialog unlockDialogs(); CORO_KILL_SELF(); return; } - /* End of choic ewithout attributes. We must do it again */ + // End of choic ewithout attributes. We must do it again } // If we're here, we found an end choice. Return to the caller group @@ -1300,9 +1298,10 @@ static uint32 doAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { // In the new version number of the action in writing dwRes Common::copy((byte *)item, (byte *)item + sizeof(MPALITEM), (byte *)newitem); -/* newitem->Action[0].nCmds=item->Action[i].nCmds; - memcpy(newitem->Action[0].CmdNum,item->Action[i].CmdNum,newitem->Action[0].nCmds*sizeof(newitem->Action[0].CmdNum[0])); -*/ + + //newitem->Action[0].nCmds=item->Action[i].nCmds; + //memcpy(newitem->Action[0].CmdNum,item->Action[i].CmdNum,newitem->Action[0].nCmds*sizeof(newitem->Action[0].CmdNum[0])); + newitem->dwRes = i; // And finally we can laucnh the process that will execute the action, @@ -1412,15 +1411,15 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, uint32 dwSizeDecomp, dwSizeComp; byte *cmpbuf; - /* Save the array of custom functions */ + // Save the array of custom functions GLOBALS._lplpFunctions = lplpcfArray; GLOBALS._lplpFunctionStrings = lpcfStrings; - /* OPen the MPC file for reading */ + // OPen the MPC file for reading if (!hMpc.open(lpszMpcFileName)) return false; - /* Read and check the header */ + // Read and check the header nBytesRead = hMpc.read(buf, 5); if (nBytesRead != 5) return false; @@ -1430,7 +1429,7 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, bCompress = buf[4]; - /* Reads the size of the uncompressed file, and allocate memory */ + // Reads the size of the uncompressed file, and allocate memory dwSizeDecomp = hMpc.readUint32LE(); if (hMpc.err()) return false; @@ -1440,7 +1439,7 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, return false; if (bCompress) { - /* Get the compressed size and read the data in */ + // Get the compressed size and read the data in dwSizeComp = hMpc.readUint32LE(); if (hMpc.err()) return false; @@ -1453,33 +1452,33 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, if (nBytesRead != dwSizeComp) return false; - /* Decompress the data */ + // Decompress the data lzo1x_decompress(cmpbuf, dwSizeComp, lpMpcImage, &nBytesRead); if (nBytesRead != dwSizeDecomp) return false; globalDestroy(cmpbuf); } else { - /* If the file is not compressed, we directly read in the data */ + // If the file is not compressed, we directly read in the data nBytesRead = hMpc.read(lpMpcImage, dwSizeDecomp); if (nBytesRead != dwSizeDecomp) return false; } - /* Close the file */ + // Close the file hMpc.close(); - /* Process the data */ + // Process the data if (ParseMpc(lpMpcImage) == false) return false; globalDestroy(lpMpcImage); - /* Open the MPR file */ + // Open the MPR file if (!GLOBALS._hMpr.open(lpszMprFileName)) return false; - /* Seek to the end of the file to read overall information */ + // Seek to the end of the file to read overall information GLOBALS._hMpr.seek(-12, SEEK_END); dwSizeComp = GLOBALS._hMpr.readUint32LE(); @@ -1497,7 +1496,7 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, if (buf[0] !='E' || buf[1] != 'N' || buf[2] != 'D' || buf[3] != '0') return false; - /* Move to the start of the resources header */ + // Move to the start of the resources header GLOBALS._hMpr.seek(-(12 + (int)dwSizeComp), SEEK_END); GLOBALS._lpResources = (uint32 *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, GLOBALS._nResources * 8); @@ -1518,17 +1517,17 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, globalDestroy(cmpbuf); - /* Reset back to the start of the file, leaving it open */ + // Reset back to the start of the file, leaving it open GLOBALS._hMpr.seek(0, SEEK_SET); - /* There is no action or dialog running by default */ + // There is no action or dialog running by default GLOBALS._bExecutingAction = false; GLOBALS._bExecutingDialog = false; - /* There's no polling location */ + // There's no polling location Common::fill(GLOBALS._nPollingLocations, GLOBALS._nPollingLocations + MAXPOLLINGLOCATIONS, 0); - /* Create the event that will be used to co-ordinate making choices and choices finishing */ + // Create the event that will be used to co-ordinate making choices and choices finishing GLOBALS._hAskChoice = CoroScheduler.createEvent(true, false); GLOBALS._hDoneChoice = CoroScheduler.createEvent(true, false); diff --git a/engines/tony/mpal/mpal.h b/engines/tony/mpal/mpal.h index 4c8ca481b0..492889d88a 100644 --- a/engines/tony/mpal/mpal.h +++ b/engines/tony/mpal/mpal.h @@ -95,7 +95,7 @@ namespace MPAL { * Macro definitions and structures \****************************************************************************/ -/* OK value for the error codes */ +// OK value for the error codes #define OK 0 #define MAXFRAMES 400 // frame animation of an object @@ -119,31 +119,31 @@ enum QueryCoordinates { * that can do at the library */ enum QueryTypes { - /* General Query */ + // General Query MPQ_VERSION=10, MPQ_GLOBAL_VAR=50, MPQ_RESOURCE, MPQ_MESSAGE, - /* Query on leases */ + // Query on leases MPQ_LOCATION_IMAGE=100, MPQ_LOCATION_SIZE, - /* Queries about items */ + // Queries about items MPQ_ITEM_LIST=200, MPQ_ITEM_DATA, MPQ_ITEM_PATTERN, MPQ_ITEM_NAME, MPQ_ITEM_IS_ACTIVE, - /* Query dialog */ + // Query dialog MPQ_DIALOG_PERIOD=300, MPQ_DIALOG_WAITFORCHOICE, MPQ_DIALOG_SELECTLIST, MPQ_DIALOG_SELECTION, - /* Query execution */ + // Query execution MPQ_DO_ACTION=400, MPQ_DO_DIALOG }; diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index e8b9dfc42a..2c2c280eb2 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -532,7 +532,7 @@ bool FPStream::unloadFile() { assert(!g_system->getMixer()->isSoundHandleActive(_handle)); - /* Closes the file handle stream */ + // Closes the file handle stream delete _loopStream; delete _rewindableStream; _loopStream = NULL; diff --git a/engines/tony/window.h b/engines/tony/window.h index 9aaca16d3e..c4cbcb6643 100644 --- a/engines/tony/window.h +++ b/engines/tony/window.h @@ -72,7 +72,7 @@ public: /** * Initialization */ - void init(/*HINSTANCE hInst*/); + void init(); void close(); /** -- cgit v1.2.3 From 56c5961fb4790345d71dde1ea286960abfb3c25b Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 30 Aug 2012 08:06:10 +0200 Subject: TONY: Translate some variables in findPath, reduce some variable scopes --- engines/tony/loc.cpp | 86 ++++++++++++++++++++++++++-------------------------- 1 file changed, 43 insertions(+), 43 deletions(-) (limited to 'engines') diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 5d11672e34..a92282cc3f 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -880,11 +880,11 @@ void RMWipe::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { /****************************************************************************/ short RMCharacter::findPath(short source, short destination) { - static RMBox BOX[MAXBOXES]; // Matrix of adjacent boxes - static short COSTO[MAXBOXES]; // Cost per node - static short VALIDO[MAXBOXES]; // 0:Invalid 1:Valid 2:Saturated - static short NEXT[MAXBOXES]; // Next node - short i, j, k, costominimo, fine, errore = 0; + static RMBox box[MAXBOXES]; // Matrix of adjacent boxes + static short nodeCost[MAXBOXES]; // Cost per node + static short valid[MAXBOXES]; // 0:Invalid 1:Valid 2:Saturated + static short nextNode[MAXBOXES]; // Next node + short minCost, error = 0; RMBoxLoc *cur; g_system->lockMutex(_csMove); @@ -898,67 +898,67 @@ short RMCharacter::findPath(short source, short destination) { cur = _theBoxes->getBoxes(_curLocation); // Make a backup copy to work on - for (i = 0; i < cur->_numbBox; i++) - memcpy(&BOX[i], &cur->_boxes[i], sizeof(RMBox)); + for (int i = 0; i < cur->_numbBox; i++) + memcpy(&box[i], &cur->_boxes[i], sizeof(RMBox)); // Invalidate all nodes - for (i = 0; i < cur->_numbBox; i++) - VALIDO[i] = 0; + for (int i = 0; i < cur->_numbBox; i++) + valid[i] = 0; // Prepare source and variables for the procedure - COSTO[source] = 0; - VALIDO[source] = 1; - fine = 0; + nodeCost[source] = 0; + valid[source] = 1; + bool finish = false; // Find the shortest path - while (!fine) { - costominimo = 32000; // Reset the minimum cost - errore = 1; // Possible error + while (!finish) { + minCost = 32000; // Reset the minimum cost + error = 1; // Possible error // 1st cycle: explore possible new nodes - for (i = 0; i < cur->_numbBox; i++) - if (VALIDO[i] == 1) { - errore = 0; // Failure de-bunked - j = 0; - while (((BOX[i]._adj[j]) != 1) && (j < cur->_numbBox)) + for (int i = 0; i < cur->_numbBox; i++) + if (valid[i] == 1) { + error = 0; // Failure de-bunked + int j = 0; + while (((box[i]._adj[j]) != 1) && (j < cur->_numbBox)) j++; if (j >= cur->_numbBox) - VALIDO[i] = 2; // nodo saturated? + valid[i] = 2; // nodo saturated? else { - NEXT[i] = j; - if (COSTO[i] + 1 < costominimo) - costominimo = COSTO[i] + 1; + nextNode[i] = j; + if (nodeCost[i] + 1 < minCost) + minCost = nodeCost[i] + 1; } } - if (errore) - fine = 1; // All nodes saturated + if (error) + finish = true; // All nodes saturated // 2nd cycle: adding new nodes that were found, saturate old nodes - for (i = 0; i < cur->_numbBox; i++) - if ((VALIDO[i] == 1) && ((COSTO[i] + 1) == costominimo)) { - BOX[i]._adj[NEXT[i]] = 2; - COSTO[NEXT[i]] = costominimo; - VALIDO[NEXT[i]] = 1; - for (j = 0; j < cur->_numbBox; j++) - if (BOX[j]._adj[NEXT[i]] == 1) - BOX[j]._adj[NEXT[i]] = 0; - - if (NEXT[i] == destination) - fine = 1; + for (int i = 0; i < cur->_numbBox; i++) + if ((valid[i] == 1) && ((nodeCost[i] + 1) == minCost)) { + box[i]._adj[nextNode[i]] = 2; + nodeCost[nextNode[i]] = minCost; + valid[nextNode[i]] = 1; + for (int j = 0; j < cur->_numbBox; j++) + if (box[j]._adj[nextNode[i]] == 1) + box[j]._adj[nextNode[i]] = 0; + + if (nextNode[i] == destination) + finish = true; } } // Remove the path from the adjacent modified matrixes - if (!errore) { - _pathLength = COSTO[destination]; - k = _pathLength; + if (!error) { + _pathLength = nodeCost[destination]; + short k = _pathLength; _path[k] = destination; while (_path[k] != source) { - i = 0; - while (BOX[i]._adj[_path[k]] != 2) + int i = 0; + while (box[i]._adj[_path[k]] != 2) i++; k--; _path[k] = i; @@ -969,7 +969,7 @@ short RMCharacter::findPath(short source, short destination) { g_system->unlockMutex(_csMove); - return !errore; + return !error; } -- cgit v1.2.3 From 7fbfbc8e6b57729e1a5008d256b28b0571f1c3b6 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 31 Aug 2012 23:08:02 +0200 Subject: TONY: Rename some more variables and structures --- engines/tony/globals.h | 12 +- engines/tony/mpal/loadmpc.cpp | 276 ++++++++++++++++---------------- engines/tony/mpal/loadmpc.h | 4 +- engines/tony/mpal/mpal.cpp | 355 +++++++++++++++++++++--------------------- engines/tony/mpal/mpal.h | 13 +- engines/tony/mpal/mpaldll.h | 170 +++++++++----------- engines/tony/tony.cpp | 4 +- 7 files changed, 405 insertions(+), 429 deletions(-) (limited to 'engines') diff --git a/engines/tony/globals.h b/engines/tony/globals.h index 0911782eac..6966bd7264 100644 --- a/engines/tony/globals.h +++ b/engines/tony/globals.h @@ -252,22 +252,22 @@ public: uint16 _nObjs; uint16 _nVars; HGLOBAL _hVars; - LPMPALVAR _lpmvVars; + LpMpalVar _lpmvVars; uint16 _nMsgs; HGLOBAL _hMsgs; - LPMPALMSG _lpmmMsgs; + LpMpalMsg _lpmmMsgs; uint16 _nDialogs; HGLOBAL _hDialogs; - LPMPALDIALOG _lpmdDialogs; + LpMpalDialog _lpmdDialogs; uint16 _nItems; HGLOBAL _hItems; - LPMPALITEM _lpmiItems; + LpMpalItem _lpmiItems; uint16 _nLocations; HGLOBAL _hLocations; - LPMPALLOCATION _lpmlLocations; + LpMpalLocation _lpmlLocations; uint16 _nScripts; HGLOBAL _hScripts; - LPMPALSCRIPT _lpmsScripts; + LpMpalScript _lpmsScripts; Common::File _hMpr; uint16 _nResources; uint32 *_lpResources; diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index 9927f9fe8e..b3c4193414 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -39,15 +39,15 @@ namespace MPAL { * Static functions \****************************************************************************/ -static bool compareCommands(struct command *cmd1, struct command *cmd2) { - if (cmd1->type == 2 && cmd2->type == 2) { - if (strcmp(cmd1->lpszVarName, cmd2->lpszVarName) == 0 && - compareExpressions(cmd1->expr, cmd2->expr)) +static bool compareCommands(struct Command *cmd1, struct Command *cmd2) { + if (cmd1->_type == 2 && cmd2->_type == 2) { + if (strcmp(cmd1->_lpszVarName, cmd2->_lpszVarName) == 0 && + compareExpressions(cmd1->_expr, cmd2->_expr)) return true; else return false; } else - return (memcmp(cmd1, cmd2, sizeof(struct command)) == 0); + return (memcmp(cmd1, cmd2, sizeof(struct Command)) == 0); } /** @@ -58,25 +58,25 @@ static bool compareCommands(struct command *cmd1, struct command *cmd2) { * data of the script. * @returns Pointer to the buffer after the item, or NULL on failure. */ -static const byte *ParseScript(const byte *lpBuf, LPMPALSCRIPT lpmsScript) { - lpmsScript->nObj = (int32)READ_LE_UINT32(lpBuf); +static const byte *ParseScript(const byte *lpBuf, LpMpalScript lpmsScript) { + lpmsScript->_nObj = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmsScript->nMoments = READ_LE_UINT16(lpBuf); + lpmsScript->_nMoments = READ_LE_UINT16(lpBuf); lpBuf += 2; int curCmd = 0; - for (uint i = 0; i < lpmsScript->nMoments; i++) { - lpmsScript->Moment[i].dwTime = (int32)READ_LE_UINT32(lpBuf); + for (uint i = 0; i < lpmsScript->_nMoments; i++) { + lpmsScript->_moment[i]._dwTime = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmsScript->Moment[i].nCmds = *lpBuf; + lpmsScript->_moment[i]._nCmds = *lpBuf; lpBuf++; - for (int j = 0; j < lpmsScript->Moment[i].nCmds; j++) { - lpmsScript->_command[curCmd].type = *lpBuf; + for (int j = 0; j < lpmsScript->_moment[i]._nCmds; j++) { + lpmsScript->_command[curCmd]._type = *lpBuf; lpBuf++; - switch (lpmsScript->_command[curCmd].type) { + switch (lpmsScript->_command[curCmd]._type) { case 1: lpmsScript->_command[curCmd]._nCf = READ_LE_UINT16(lpBuf); lpBuf += 2; @@ -93,13 +93,13 @@ static const byte *ParseScript(const byte *lpBuf, LPMPALSCRIPT lpmsScript) { case 2: { // Variable assign int len = *lpBuf; lpBuf++; - lpmsScript->_command[curCmd].lpszVarName = (char *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, len + 1); - if (lpmsScript->_command[curCmd].lpszVarName == NULL) + lpmsScript->_command[curCmd]._lpszVarName = (char *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, len + 1); + if (lpmsScript->_command[curCmd]._lpszVarName == NULL) return NULL; - memcpy(lpmsScript->_command[curCmd].lpszVarName, lpBuf, len); + memcpy(lpmsScript->_command[curCmd]._lpszVarName, lpBuf, len); lpBuf += len; - lpBuf = parseExpression(lpBuf, &lpmsScript->_command[curCmd].expr); + lpBuf = parseExpression(lpBuf, &lpmsScript->_command[curCmd]._expr); if (lpBuf == NULL) return NULL; break; @@ -108,7 +108,7 @@ static const byte *ParseScript(const byte *lpBuf, LPMPALSCRIPT lpmsScript) { return NULL; } - lpmsScript->Moment[i].CmdNum[j] = curCmd; + lpmsScript->_moment[i]._cmdNum[j] = curCmd; curCmd++; } } @@ -120,12 +120,12 @@ static const byte *ParseScript(const byte *lpBuf, LPMPALSCRIPT lpmsScript) { * * @param lpmsScript Pointer to a script structure */ -static void FreeScript(LPMPALSCRIPT lpmsScript) { - for (int i = 0; i < MAX_COMMANDS_PER_SCRIPT && (lpmsScript->_command[i].type); ++i, ++lpmsScript) { - if (lpmsScript->_command[i].type == 2) { +static void FreeScript(LpMpalScript lpmsScript) { + for (int i = 0; i < MAX_COMMANDS_PER_SCRIPT && (lpmsScript->_command[i]._type); ++i, ++lpmsScript) { + if (lpmsScript->_command[i]._type == 2) { // Variable Assign - globalDestroy(lpmsScript->_command[i].lpszVarName); - freeExpression(lpmsScript->_command[i].expr); + globalDestroy(lpmsScript->_command[i]._lpszVarName); + freeExpression(lpmsScript->_command[i]._expr); } } } @@ -138,11 +138,11 @@ static void FreeScript(LPMPALSCRIPT lpmsScript) { * data of the dialog. * @returns Pointer to the buffer after the item, or NULL on failure. */ -static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { +static const byte *parseDialog(const byte *lpBuf, LpMpalDialog lpmdDialog) { uint32 num2, num3; byte *lpLock; - lpmdDialog->nObj = READ_LE_UINT32(lpBuf); + lpmdDialog->_nObj = READ_LE_UINT32(lpBuf); lpBuf += 4; // Periods @@ -150,7 +150,7 @@ static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { lpBuf += 2; if (num >= MAX_PERIODS_PER_DIALOG - 1) - error("Too much periods in dialog #%d", lpmdDialog->nObj); + error("Too much periods in dialog #%d", lpmdDialog->_nObj); uint32 i; for (i = 0; i < num; i++) { @@ -172,21 +172,21 @@ static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { uint32 curCmd = 0; if (num >= MAX_GROUPS_PER_DIALOG) - error("Too much groups in dialog #%d", lpmdDialog->nObj); + error("Too much groups in dialog #%d", lpmdDialog->_nObj); for (i = 0; i < num; i++) { - lpmdDialog->_group[i].num = READ_LE_UINT16(lpBuf); + lpmdDialog->_group[i]._num = READ_LE_UINT16(lpBuf); lpBuf += 2; - lpmdDialog->_group[i].nCmds = *lpBuf; lpBuf++; + lpmdDialog->_group[i]._nCmds = *lpBuf; lpBuf++; - if (lpmdDialog->_group[i].nCmds >= MAX_COMMANDS_PER_GROUP) - error("Too much commands in group #%d in dialog #%d",lpmdDialog->_group[i].num,lpmdDialog->nObj); + if (lpmdDialog->_group[i]._nCmds >= MAX_COMMANDS_PER_GROUP) + error("Too much commands in group #%d in dialog #%d", lpmdDialog->_group[i]._num, lpmdDialog->_nObj); - for (uint32 j = 0; j < lpmdDialog->_group[i].nCmds; j++) { - lpmdDialog->_command[curCmd].type = *lpBuf; + for (uint32 j = 0; j < lpmdDialog->_group[i]._nCmds; j++) { + lpmdDialog->_command[curCmd]._type = *lpBuf; lpBuf++; - switch (lpmdDialog->_command[curCmd].type) { + switch (lpmdDialog->_command[curCmd]._type) { // Call custom function case 1: lpmdDialog->_command[curCmd]._nCf = READ_LE_UINT16(lpBuf); @@ -205,21 +205,21 @@ static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { case 2: { uint32 len = *lpBuf; lpBuf++; - lpmdDialog->_command[curCmd].lpszVarName = (char *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, len + 1); - if (lpmdDialog->_command[curCmd].lpszVarName == NULL) + lpmdDialog->_command[curCmd]._lpszVarName = (char *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, len + 1); + if (lpmdDialog->_command[curCmd]._lpszVarName == NULL) return NULL; - Common::copy(lpBuf, lpBuf + len, lpmdDialog->_command[curCmd].lpszVarName); + Common::copy(lpBuf, lpBuf + len, lpmdDialog->_command[curCmd]._lpszVarName); lpBuf += len; - lpBuf = parseExpression(lpBuf, &lpmdDialog->_command[curCmd].expr); + lpBuf = parseExpression(lpBuf, &lpmdDialog->_command[curCmd]._expr); if (lpBuf == NULL) return NULL; break; } // Do Choice case 3: - lpmdDialog->_command[curCmd].nChoice = READ_LE_UINT16(lpBuf); + lpmdDialog->_command[curCmd]._nChoice = READ_LE_UINT16(lpBuf); lpBuf += 2; break; @@ -230,56 +230,56 @@ static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { uint32 kk; for (kk = 0;kk < curCmd; kk++) { if (compareCommands(&lpmdDialog->_command[kk], &lpmdDialog->_command[curCmd])) { - lpmdDialog->_group[i].CmdNum[j] = kk; + lpmdDialog->_group[i]._cmdNum[j] = kk; // Free any data allocated for the duplictaed command - if (lpmdDialog->_command[curCmd].type == 2) { - globalDestroy(lpmdDialog->_command[curCmd].lpszVarName); - freeExpression(lpmdDialog->_command[curCmd].expr); + if (lpmdDialog->_command[curCmd]._type == 2) { + globalDestroy(lpmdDialog->_command[curCmd]._lpszVarName); + freeExpression(lpmdDialog->_command[curCmd]._expr); - lpmdDialog->_command[curCmd].lpszVarName = NULL; - lpmdDialog->_command[curCmd].expr = 0; - lpmdDialog->_command[curCmd].type = 0; + lpmdDialog->_command[curCmd]._lpszVarName = NULL; + lpmdDialog->_command[curCmd]._expr = 0; + lpmdDialog->_command[curCmd]._type = 0; } break; } } if (kk == curCmd) { - lpmdDialog->_group[i].CmdNum[j] = curCmd; + lpmdDialog->_group[i]._cmdNum[j] = curCmd; curCmd++; } } } if (curCmd >= MAX_COMMANDS_PER_DIALOG) - error("Too much commands in dialog #%d",lpmdDialog->nObj); + error("Too much commands in dialog #%d",lpmdDialog->_nObj); // Choices num = READ_LE_UINT16(lpBuf); lpBuf += 2; if (num >= MAX_CHOICES_PER_DIALOG) - error("Too much choices in dialog #%d",lpmdDialog->nObj); + error("Too much choices in dialog #%d",lpmdDialog->_nObj); for (i = 0; i < num; i++) { - lpmdDialog->_choice[i].nChoice = READ_LE_UINT16(lpBuf); + lpmdDialog->_choice[i]._nChoice = READ_LE_UINT16(lpBuf); lpBuf += 2; num2 = *lpBuf++; if (num2 >= MAX_SELECTS_PER_CHOICE) - error("Too much selects in choice #%d in dialog #%d", lpmdDialog->_choice[i].nChoice, lpmdDialog->nObj); + error("Too much selects in choice #%d in dialog #%d", lpmdDialog->_choice[i]._nChoice, lpmdDialog->_nObj); for (uint32 j = 0; j < num2; j++) { // When switch (*lpBuf++) { case 0: - lpmdDialog->_choice[i]._select[j].when = NULL; + lpmdDialog->_choice[i]._select[j]._when = NULL; break; case 1: - lpBuf = parseExpression(lpBuf, &lpmdDialog->_choice[i]._select[j].when); + lpBuf = parseExpression(lpBuf, &lpmdDialog->_choice[i]._select[j]._when); if (lpBuf == NULL) return NULL; break; @@ -289,31 +289,31 @@ static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { } // Attrib - lpmdDialog->_choice[i]._select[j].attr = *lpBuf++; + lpmdDialog->_choice[i]._select[j]._attr = *lpBuf++; // Data - lpmdDialog->_choice[i]._select[j].dwData = READ_LE_UINT32(lpBuf); + lpmdDialog->_choice[i]._select[j]._dwData = READ_LE_UINT32(lpBuf); lpBuf += 4; // PlayGroup num3 = *lpBuf++; if (num3 >= MAX_PLAYGROUPS_PER_SELECT) - error("Too much playgroups in select #%d in choice #%d in dialog #%d", j, lpmdDialog->_choice[i].nChoice, lpmdDialog->nObj); + error("Too much playgroups in select #%d in choice #%d in dialog #%d", j, lpmdDialog->_choice[i]._nChoice, lpmdDialog->_nObj); for (uint32 z = 0; z < num3; z++) { - lpmdDialog->_choice[i]._select[j].wPlayGroup[z] = READ_LE_UINT16(lpBuf); + lpmdDialog->_choice[i]._select[j]._wPlayGroup[z] = READ_LE_UINT16(lpBuf); lpBuf += 2; } - lpmdDialog->_choice[i]._select[j].wPlayGroup[num3] = 0; + lpmdDialog->_choice[i]._select[j]._wPlayGroup[num3] = 0; } // Mark the last selection - lpmdDialog->_choice[i]._select[num2].dwData = 0; + lpmdDialog->_choice[i]._select[num2]._dwData = 0; } - lpmdDialog->_choice[num].nChoice = 0; + lpmdDialog->_choice[num]._nChoice = 0; return lpBuf; } @@ -329,63 +329,63 @@ static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { * @remarks It's necessary that the structure that is passed has been * completely initialized to 0 beforehand. */ -static const byte *parseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { - lpmiItem->nObj = (int32)READ_LE_UINT32(lpBuf); +static const byte *parseItem(const byte *lpBuf, LpMpalItem lpmiItem) { + lpmiItem->_nObj = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; byte len = *lpBuf; lpBuf++; - memcpy(lpmiItem->lpszDescribe, lpBuf, MIN((byte)127, len)); + memcpy(lpmiItem->_lpszDescribe, lpBuf, MIN((byte)127, len)); lpBuf += len; if (len >= MAX_DESCRIBE_SIZE) - error("Describe too long in item #%d", lpmiItem->nObj); + error("Describe too long in item #%d", lpmiItem->_nObj); - lpmiItem->nActions=*lpBuf; + lpmiItem->_nActions=*lpBuf; lpBuf++; // Allocation action - if (lpmiItem->nActions > 0) - lpmiItem->Action = (ItemAction *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(struct ItemAction) * (int)lpmiItem->nActions); + if (lpmiItem->_nActions > 0) + lpmiItem->_action = (ItemAction *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(struct ItemAction) * (int)lpmiItem->_nActions); uint32 curCmd = 0; - for (uint32 i = 0; i < lpmiItem->nActions; i++) { - lpmiItem->Action[i].num = *lpBuf; + for (uint32 i = 0; i < lpmiItem->_nActions; i++) { + lpmiItem->_action[i]._num = *lpBuf; lpBuf++; - lpmiItem->Action[i].wParm = READ_LE_UINT16(lpBuf); + lpmiItem->_action[i]._wParm = READ_LE_UINT16(lpBuf); lpBuf += 2; - if (lpmiItem->Action[i].num == 0xFF) { - lpmiItem->Action[i].wTime = READ_LE_UINT16(lpBuf); + if (lpmiItem->_action[i]._num == 0xFF) { + lpmiItem->_action[i]._wTime = READ_LE_UINT16(lpBuf); lpBuf += 2; - lpmiItem->Action[i].perc = *lpBuf; + lpmiItem->_action[i]._perc = *lpBuf; lpBuf++; } if (*lpBuf == 0) { lpBuf++; - lpmiItem->Action[i].when = NULL; + lpmiItem->_action[i]._when = NULL; } else { lpBuf++; - lpBuf = parseExpression(lpBuf,&lpmiItem->Action[i].when); + lpBuf = parseExpression(lpBuf,&lpmiItem->_action[i]._when); if (lpBuf == NULL) return NULL; } - lpmiItem->Action[i].nCmds=*lpBuf; + lpmiItem->_action[i]._nCmds=*lpBuf; lpBuf++; - if (lpmiItem->Action[i].nCmds >= MAX_COMMANDS_PER_ACTION) - error("Too much commands in action #%d in item #%d",lpmiItem->Action[i].num,lpmiItem->nObj); + if (lpmiItem->_action[i]._nCmds >= MAX_COMMANDS_PER_ACTION) + error("Too much commands in action #%d in item #%d",lpmiItem->_action[i]._num, lpmiItem->_nObj); - for (uint32 j = 0; j < lpmiItem->Action[i].nCmds; j++) { - lpmiItem->_command[curCmd].type = *lpBuf; + for (uint32 j = 0; j < lpmiItem->_action[i]._nCmds; j++) { + lpmiItem->_command[curCmd]._type = *lpBuf; lpBuf++; - switch (lpmiItem->_command[curCmd].type) { + switch (lpmiItem->_command[curCmd]._type) { case 1: // Call custom function lpmiItem->_command[curCmd]._nCf = READ_LE_UINT16(lpBuf); lpBuf += 2; @@ -402,13 +402,13 @@ static const byte *parseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { case 2: // Variable assign len = *lpBuf; lpBuf++; - lpmiItem->_command[curCmd].lpszVarName = (char *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, len + 1); - if (lpmiItem->_command[curCmd].lpszVarName == NULL) + lpmiItem->_command[curCmd]._lpszVarName = (char *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, len + 1); + if (lpmiItem->_command[curCmd]._lpszVarName == NULL) return NULL; - memcpy(lpmiItem->_command[curCmd].lpszVarName, lpBuf, len); + memcpy(lpmiItem->_command[curCmd]._lpszVarName, lpBuf, len); lpBuf += len; - lpBuf = parseExpression(lpBuf, &lpmiItem->_command[curCmd].expr); + lpBuf = parseExpression(lpBuf, &lpmiItem->_command[curCmd]._expr); if (lpBuf == NULL) return NULL; break; @@ -420,34 +420,34 @@ static const byte *parseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { uint32 kk; for (kk = 0; kk < curCmd; kk++) { if (compareCommands(&lpmiItem->_command[kk], &lpmiItem->_command[curCmd])) { - lpmiItem->Action[i].CmdNum[j] = kk; + lpmiItem->_action[i]._cmdNum[j] = kk; // Free any data allocated for the duplictaed command - if (lpmiItem->_command[curCmd].type == 2) { - globalDestroy(lpmiItem->_command[curCmd].lpszVarName); - freeExpression(lpmiItem->_command[curCmd].expr); + if (lpmiItem->_command[curCmd]._type == 2) { + globalDestroy(lpmiItem->_command[curCmd]._lpszVarName); + freeExpression(lpmiItem->_command[curCmd]._expr); - lpmiItem->_command[curCmd].lpszVarName = NULL; - lpmiItem->_command[curCmd].expr = 0; - lpmiItem->_command[curCmd].type = 0; + lpmiItem->_command[curCmd]._lpszVarName = NULL; + lpmiItem->_command[curCmd]._expr = 0; + lpmiItem->_command[curCmd]._type = 0; } break; } } if (kk == curCmd) { - lpmiItem->Action[i].CmdNum[j] = curCmd; + lpmiItem->_action[i]._cmdNum[j] = curCmd; curCmd++; if (curCmd >= MAX_COMMANDS_PER_ITEM) { - error("Too much commands in item #%d",lpmiItem->nObj); + error("Too much commands in item #%d", lpmiItem->_nObj); //curCmd=0; } } } } - lpmiItem->dwRes = READ_LE_UINT32(lpBuf); + lpmiItem->_dwRes = READ_LE_UINT32(lpBuf); lpBuf += 4; return lpBuf; @@ -458,23 +458,23 @@ static const byte *parseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { * * @param lpmiItem Pointer to an item structure */ -static void freeItem(LPMPALITEM lpmiItem) { +static void freeItem(LpMpalItem lpmiItem) { // Free the actions - if (lpmiItem->Action) { - for (int i = 0; i < lpmiItem->nActions; ++i) { - if (lpmiItem->Action[i].when != 0) - freeExpression(lpmiItem->Action[i].when); + if (lpmiItem->_action) { + for (int i = 0; i < lpmiItem->_nActions; ++i) { + if (lpmiItem->_action[i]._when != 0) + freeExpression(lpmiItem->_action[i]._when); } - globalDestroy(lpmiItem->Action); + globalDestroy(lpmiItem->_action); } // Free the commands - for (int i = 0; i < MAX_COMMANDS_PER_ITEM && (lpmiItem->_command[i].type); ++i) { - if (lpmiItem->_command[i].type == 2) { + for (int i = 0; i < MAX_COMMANDS_PER_ITEM && (lpmiItem->_command[i]._type); ++i) { + if (lpmiItem->_command[i]._type == 2) { // Variable Assign - globalDestroy(lpmiItem->_command[i].lpszVarName); - freeExpression(lpmiItem->_command[i].expr); + globalDestroy(lpmiItem->_command[i]._lpszVarName); + freeExpression(lpmiItem->_command[i]._expr); } } } @@ -487,14 +487,14 @@ static void freeItem(LPMPALITEM lpmiItem) { * data of the location. * @returns Pointer to the buffer after the location, or NULL on failure. */ -static const byte *ParseLocation(const byte *lpBuf, LPMPALLOCATION lpmlLocation) { - lpmlLocation->nObj = (int32)READ_LE_UINT32(lpBuf); +static const byte *ParseLocation(const byte *lpBuf, LpMpalLocation lpmlLocation) { + lpmlLocation->_nObj = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmlLocation->dwXlen = READ_LE_UINT16(lpBuf); + lpmlLocation->_dwXlen = READ_LE_UINT16(lpBuf); lpBuf += 2; - lpmlLocation->dwYlen = READ_LE_UINT16(lpBuf); + lpmlLocation->_dwYlen = READ_LE_UINT16(lpBuf); lpBuf += 2; - lpmlLocation->dwPicRes = READ_LE_UINT32(lpBuf); + lpmlLocation->_dwPicRes = READ_LE_UINT32(lpBuf); lpBuf += 4; return lpBuf; @@ -516,7 +516,7 @@ static const byte *ParseLocation(const byte *lpBuf, LPMPALLOCATION lpmlLocation) * @param lpBuf Buffer containing the MPC file data, excluding the header. * @returns True if succeeded OK, false if failure. */ -bool ParseMpc(const byte *lpBuf) { +bool parseMpc(const byte *lpBuf) { byte *lpTemp; // 1. Variables @@ -527,18 +527,18 @@ bool ParseMpc(const byte *lpBuf) { GLOBALS._nVars = READ_LE_UINT16(lpBuf); lpBuf += 2; - GLOBALS._hVars = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof(MPALVAR) * (uint32)GLOBALS._nVars); + GLOBALS._hVars = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof(MpalVar) * (uint32)GLOBALS._nVars); if (GLOBALS._hVars == NULL) return false; - GLOBALS._lpmvVars = (LPMPALVAR)globalLock(GLOBALS._hVars); + GLOBALS._lpmvVars = (LpMpalVar)globalLock(GLOBALS._hVars); for (uint16 i = 0; i < GLOBALS._nVars; i++) { uint16 wLen = *(const byte *)lpBuf; lpBuf++; - memcpy(GLOBALS._lpmvVars->lpszVarName, lpBuf, MIN(wLen, (uint16)32)); + memcpy(GLOBALS._lpmvVars->_lpszVarName, lpBuf, MIN(wLen, (uint16)32)); lpBuf += wLen; - GLOBALS._lpmvVars->dwVal = READ_LE_UINT32(lpBuf); + GLOBALS._lpmvVars->_dwVal = READ_LE_UINT32(lpBuf); lpBuf += 4; lpBuf++; // Skip 'ext' @@ -556,11 +556,11 @@ bool ParseMpc(const byte *lpBuf) { lpBuf += 2; #ifdef NEED_LOCK_MSGS - GLOBALS._hMsgs = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof(MPALMSG) * (uint32)GLOBALS._nMsgs); + GLOBALS._hMsgs = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof(MpalMsg) * (uint32)GLOBALS._nMsgs); if (GLOBALS._hMsgs == NULL) return false; - GLOBALS._lpmmMsgs = (LPMPALMSG)globalLock(GLOBALS._hMsgs); + GLOBALS._lpmmMsgs = (LpMpalMsg)globalLock(GLOBALS._hMsgs); #else GLOBALS._lpmmMsgs=(LPMPALMSG)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MPALMSG) * (uint32)GLOBALS._nMsgs); if (GLOBALS._lpmmMsgs==NULL) @@ -611,11 +611,11 @@ bool ParseMpc(const byte *lpBuf) { GLOBALS._nDialogs = READ_LE_UINT16(lpBuf); lpBuf += 2; - GLOBALS._hDialogs = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS._nDialogs * sizeof(MPALDIALOG)); + GLOBALS._hDialogs = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS._nDialogs * sizeof(MpalDialog)); if (GLOBALS._hDialogs == NULL) return false; - GLOBALS._lpmdDialogs = (LPMPALDIALOG)globalLock(GLOBALS._hDialogs); + GLOBALS._lpmdDialogs = (LpMpalDialog)globalLock(GLOBALS._hDialogs); for (uint16 i = 0; i < GLOBALS._nDialogs; i++) { if ((lpBuf = parseDialog(lpBuf + 7, &GLOBALS._lpmdDialogs[i])) == NULL) @@ -633,11 +633,11 @@ bool ParseMpc(const byte *lpBuf) { lpBuf += 2; // Allocate memory and read them in - GLOBALS._hItems = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS._nItems * sizeof(MPALITEM)); + GLOBALS._hItems = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS._nItems * sizeof(MpalItem)); if (GLOBALS._hItems == NULL) return false; - GLOBALS._lpmiItems = (LPMPALITEM)globalLock(GLOBALS._hItems); + GLOBALS._lpmiItems = (LpMpalItem)globalLock(GLOBALS._hItems); for (uint16 i = 0; i < GLOBALS._nItems; i++) { if ((lpBuf = parseItem(lpBuf + 5, &GLOBALS._lpmiItems[i])) == NULL) @@ -655,11 +655,11 @@ bool ParseMpc(const byte *lpBuf) { lpBuf += 2; // Allocate memory and read them in - GLOBALS._hLocations = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS._nLocations * sizeof(MPALLOCATION)); + GLOBALS._hLocations = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS._nLocations * sizeof(MpalLocation)); if (GLOBALS._hLocations == NULL) return false; - GLOBALS._lpmlLocations = (LPMPALLOCATION)globalLock(GLOBALS._hLocations); + GLOBALS._lpmlLocations = (LpMpalLocation)globalLock(GLOBALS._hLocations); for (uint16 i = 0; i < GLOBALS._nLocations; i++) { if ((lpBuf = ParseLocation(lpBuf + 9, &GLOBALS._lpmlLocations[i])) == NULL) @@ -677,11 +677,11 @@ bool ParseMpc(const byte *lpBuf) { lpBuf += 2; // Allocate memory - GLOBALS._hScripts = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS._nScripts * sizeof(MPALSCRIPT)); + GLOBALS._hScripts = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS._nScripts * sizeof(MpalScript)); if (GLOBALS._hScripts == NULL) return false; - GLOBALS._lpmsScripts = (LPMPALSCRIPT)globalLock(GLOBALS._hScripts); + GLOBALS._lpmsScripts = (LpMpalScript)globalLock(GLOBALS._hScripts); for (uint16 i = 0; i < GLOBALS._nScripts; i++) { if ((lpBuf = ParseScript(lpBuf + 7, &GLOBALS._lpmsScripts[i])) == NULL) @@ -708,24 +708,24 @@ bool ParseMpc(const byte *lpBuf) { /** * Free the given dialog */ -static void freeDialog(LPMPALDIALOG lpmdDialog) { +static void freeDialog(LpMpalDialog lpmdDialog) { // Free the periods for (int i = 0; i < MAX_PERIODS_PER_DIALOG && (lpmdDialog->_periods[i]); ++i) globalFree(lpmdDialog->_periods[i]); - for (int i = 0; i < MAX_COMMANDS_PER_DIALOG && (lpmdDialog->_command[i].type); i++) { - if (lpmdDialog->_command[i].type == 2) { + for (int i = 0; i < MAX_COMMANDS_PER_DIALOG && (lpmdDialog->_command[i]._type); i++) { + if (lpmdDialog->_command[i]._type == 2) { // Variable assign - globalDestroy(lpmdDialog->_command[i].lpszVarName); - freeExpression(lpmdDialog->_command[i].expr); + globalDestroy(lpmdDialog->_command[i]._lpszVarName); + freeExpression(lpmdDialog->_command[i]._expr); } } // Free the choices for (int i = 0; i < MAX_CHOICES_PER_DIALOG; ++i) { for (int j = 0; j < MAX_SELECTS_PER_CHOICE; j++) { - if (lpmdDialog->_choice[i]._select[j].when) - freeExpression(lpmdDialog->_choice[i]._select[j].when); + if (lpmdDialog->_choice[i]._select[j]._when) + freeExpression(lpmdDialog->_choice[i]._select[j]._when); } } } @@ -733,12 +733,12 @@ static void freeDialog(LPMPALDIALOG lpmdDialog) { /** * Frees any data allocated from the parsing of the MPC file */ -void FreeMpc() { +void freeMpc() { // Free variables globalFree(GLOBALS._hVars); // Free messages - LPMPALMSG lpmmMsgs = (LPMPALMSG)globalLock(GLOBALS._hMsgs); + LpMpalMsg lpmmMsgs = (LpMpalMsg)globalLock(GLOBALS._hMsgs); for (int i = 0; i < GLOBALS._nMsgs; i++, ++lpmmMsgs) globalFree(lpmmMsgs->_hText); @@ -747,7 +747,7 @@ void FreeMpc() { // Free objects if (GLOBALS._hDialogs) { - LPMPALDIALOG lpmdDialogs = (LPMPALDIALOG)globalLock(GLOBALS._hDialogs); + LpMpalDialog lpmdDialogs = (LpMpalDialog)globalLock(GLOBALS._hDialogs); for (int i = 0; i < GLOBALS._nDialogs; i++, ++lpmdDialogs) freeDialog(lpmdDialogs); @@ -757,7 +757,7 @@ void FreeMpc() { // Free items if (GLOBALS._hItems) { - LPMPALITEM lpmiItems = (LPMPALITEM)globalLock(GLOBALS._hItems); + LpMpalItem lpmiItems = (LpMpalItem)globalLock(GLOBALS._hItems); for (int i = 0; i < GLOBALS._nItems; ++i, ++lpmiItems) freeItem(lpmiItems); @@ -773,7 +773,7 @@ void FreeMpc() { // Free the scripts if (GLOBALS._hScripts) { - LPMPALSCRIPT lpmsScripts = (LPMPALSCRIPT)globalLock(GLOBALS._hScripts); + LpMpalScript lpmsScripts = (LpMpalScript)globalLock(GLOBALS._hScripts); for (int i = 0; i < GLOBALS._nScripts; ++i, ++lpmsScripts) { FreeScript(lpmsScripts); diff --git a/engines/tony/mpal/loadmpc.h b/engines/tony/mpal/loadmpc.h index c0e2ca7fb5..20956288aa 100644 --- a/engines/tony/mpal/loadmpc.h +++ b/engines/tony/mpal/loadmpc.h @@ -44,12 +44,12 @@ namespace MPAL { * @param lpBuf Buffer containing the MPC file data, excluding the header. * @returns True if succeeded OK, false if failure. */ -bool ParseMpc(const byte *lpBuf); +bool parseMpc(const byte *lpBuf); /** * Frees any data allocated from the parsing of the MPC file */ -void FreeMpc(); +void freeMpc(); } // end of namespace MPAL diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 514001eda7..9a92fd7766 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -60,7 +60,7 @@ const char *mpalCopyright = * Locks the variables for access */ void lockVar() { - GLOBALS._lpmvVars = (LPMPALVAR)globalLock(GLOBALS._hVars); + GLOBALS._lpmvVars = (LpMpalVar)globalLock(GLOBALS._hVars); } /** @@ -75,7 +75,7 @@ void unlockVar() { */ static void LockMsg() { #ifdef NEED_LOCK_MSGS - GLOBALS._lpmmMsgs = (LPMPALMSG)globalLock(GLOBALS._hMsgs); + GLOBALS._lpmmMsgs = (LpMpalMsg)globalLock(GLOBALS._hMsgs); #endif } @@ -92,7 +92,7 @@ static void UnlockMsg() { * Locks the dialogs for access */ static void lockDialogs() { - GLOBALS._lpmdDialogs = (LPMPALDIALOG)globalLock(GLOBALS._hDialogs); + GLOBALS._lpmdDialogs = (LpMpalDialog)globalLock(GLOBALS._hDialogs); } /** @@ -106,7 +106,7 @@ static void unlockDialogs() { * Locks the location data structures for access */ static void lockLocations() { - GLOBALS._lpmlLocations = (LPMPALLOCATION)globalLock(GLOBALS._hLocations); + GLOBALS._lpmlLocations = (LpMpalLocation)globalLock(GLOBALS._hLocations); } /** @@ -120,7 +120,7 @@ static void unlockLocations() { * Locks the items structures for use */ static void lockItems() { - GLOBALS._lpmiItems = (LPMPALITEM)globalLock(GLOBALS._hItems); + GLOBALS._lpmiItems = (LpMpalItem)globalLock(GLOBALS._hItems); } /** @@ -134,7 +134,7 @@ static void unlockItems() { * Locks the script data structures for use */ static void LockScripts() { - GLOBALS._lpmsScripts = (LPMPALSCRIPT)globalLock(GLOBALS._hScripts); + GLOBALS._lpmsScripts = (LpMpalScript)globalLock(GLOBALS._hScripts); } /** @@ -154,11 +154,11 @@ static void unlockScripts() { * need to remember to call UnlockVar() */ int32 varGetValue(const char *lpszVarName) { - LPMPALVAR v = GLOBALS._lpmvVars; + LpMpalVar v = GLOBALS._lpmvVars; for (int i = 0; i < GLOBALS._nVars; v++, i++) - if (strcmp(lpszVarName, v->lpszVarName) == 0) - return v->dwVal; + if (strcmp(lpszVarName, v->_lpszVarName) == 0) + return v->_dwVal; GLOBALS._mpalError = 1; return 0; @@ -170,18 +170,18 @@ int32 varGetValue(const char *lpszVarName) { * @param val Value to set */ void varSetValue(const char *lpszVarName, int32 val) { - LPMPALVAR v = GLOBALS._lpmvVars; + LpMpalVar v = GLOBALS._lpmvVars; for (uint i = 0; i < GLOBALS._nVars; v++, i++) - if (strcmp(lpszVarName, v->lpszVarName) == 0) { - v->dwVal = val; - if (GLOBALS._lpiifCustom != NULL && strncmp(v->lpszVarName, "Pattern.", 8) == 0) { + if (strcmp(lpszVarName, v->_lpszVarName) == 0) { + v->_dwVal = val; + if (GLOBALS._lpiifCustom != NULL && strncmp(v->_lpszVarName, "Pattern.", 8) == 0) { i = 0; - sscanf(v->lpszVarName, "Pattern.%u", &i); + sscanf(v->_lpszVarName, "Pattern.%u", &i); GLOBALS._lpiifCustom(i, val, -1); - } else if (GLOBALS._lpiifCustom != NULL && strncmp(v->lpszVarName, "Status.", 7) == 0) { + } else if (GLOBALS._lpiifCustom != NULL && strncmp(v->_lpszVarName, "Status.", 7) == 0) { i = 0; - sscanf(v->lpszVarName,"Status.%u", &i); + sscanf(v->_lpszVarName,"Status.%u", &i); GLOBALS._lpiifCustom(i, -1, val); } return; @@ -200,10 +200,10 @@ void varSetValue(const char *lpszVarName, int32 val) { * first been locked with a call to LockLoc(). */ static int locGetOrderFromNum(uint32 nLoc) { - LPMPALLOCATION loc = GLOBALS._lpmlLocations; + LpMpalLocation loc = GLOBALS._lpmlLocations; for (int i = 0; i < GLOBALS._nLocations; i++, loc++) - if (loc->nObj == nLoc) + if (loc->_nObj == nLoc) return i; return -1; @@ -218,7 +218,7 @@ static int locGetOrderFromNum(uint32 nLoc) { * first been locked with a call to LockMsg() */ static int msgGetOrderFromNum(uint32 nMsg) { - LPMPALMSG msg = GLOBALS._lpmmMsgs; + LpMpalMsg msg = GLOBALS._lpmmMsgs; for (int i = 0; i < GLOBALS._nMsgs; i++, msg++) { if (msg->_wNum == nMsg) @@ -236,10 +236,10 @@ static int msgGetOrderFromNum(uint32 nMsg) { * first been locked with a call to LockItems() */ static int itemGetOrderFromNum(uint32 nItem) { - LPMPALITEM item = GLOBALS._lpmiItems; + LpMpalItem item = GLOBALS._lpmiItems; for (int i = 0; i < GLOBALS._nItems; i++, item++) { - if (item->nObj == nItem) + if (item->_nObj == nItem) return i; } @@ -255,10 +255,10 @@ static int itemGetOrderFromNum(uint32 nItem) { * first been locked with a call to LockScripts() */ static int scriptGetOrderFromNum(uint32 nScript) { - LPMPALSCRIPT script = GLOBALS._lpmsScripts; + LpMpalScript script = GLOBALS._lpmsScripts; for (int i = 0; i < GLOBALS._nScripts; i++, script++) { - if (script->nObj == nScript) + if (script->_nObj == nScript) return i; } @@ -274,10 +274,10 @@ static int scriptGetOrderFromNum(uint32 nScript) { * first been locked with a call to LockDialogs() */ static int dialogGetOrderFromNum(uint32 nDialog) { - LPMPALDIALOG dialog = GLOBALS._lpmdDialogs; + LpMpalDialog dialog = GLOBALS._lpmdDialogs; for (int i = 0; i < GLOBALS._nDialogs; i++, dialog++) { - if (dialog->nObj == nDialog) + if (dialog->_nObj == nDialog) return i; } @@ -326,7 +326,7 @@ static char *DuplicateMessage(uint32 nMsgOrd) { static char *duplicateDialogPeriod(uint32 nPeriod) { const char *origmsg; char *clonemsg; - LPMPALDIALOG dialog = GLOBALS._lpmdDialogs + GLOBALS._nExecutingDialog; + LpMpalDialog dialog = GLOBALS._lpmdDialogs + GLOBALS._nExecutingDialog; for (int j = 0; dialog->_periods[j] != NULL; j++) { if (dialog->_periodNums[j] == nPeriod) { @@ -386,7 +386,7 @@ HGLOBAL resLoad(uint32 dwId) { h = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, nSizeDecomp + (nSizeDecomp / 1024) * 16); buf = (byte *)globalLock(h); - temp = (byte *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT,nSizeComp); + temp = (byte *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, nSizeComp); nBytesRead = GLOBALS._hMpr.read(temp, nSizeComp); if (nBytesRead != nSizeComp) @@ -406,12 +406,12 @@ HGLOBAL resLoad(uint32 dwId) { static uint32 *getSelectList(uint32 i) { uint32 *sl; - LPMPALDIALOG dialog = GLOBALS._lpmdDialogs + GLOBALS._nExecutingDialog; + LpMpalDialog dialog = GLOBALS._lpmdDialogs + GLOBALS._nExecutingDialog; // Count how many are active selects int num = 0; - for (int j = 0; dialog->_choice[i]._select[j].dwData != 0; j++) { - if (dialog->_choice[i]._select[j].curActive) + for (int j = 0; dialog->_choice[i]._select[j]._dwData != 0; j++) { + if (dialog->_choice[i]._select[j]._curActive) num++; } @@ -425,9 +425,9 @@ static uint32 *getSelectList(uint32 i) { // Copy all the data inside the active select list int k = 0; - for (int j = 0; dialog->_choice[i]._select[j].dwData != 0; j++) { - if (dialog->_choice[i]._select[j].curActive) - sl[k++] = dialog->_choice[i]._select[j].dwData; + for (int j = 0; dialog->_choice[i]._select[j]._dwData != 0; j++) { + if (dialog->_choice[i]._select[j]._curActive) + sl[k++] = dialog->_choice[i]._select[j]._dwData; } sl[k] = (uint32)NULL; @@ -436,11 +436,11 @@ static uint32 *getSelectList(uint32 i) { static uint32 *GetItemList(uint32 nLoc) { uint32 *il; - LPMPALVAR v = GLOBALS._lpmvVars; + LpMpalVar v = GLOBALS._lpmvVars; uint32 num = 0; for (uint32 i = 0; i < GLOBALS._nVars; i++, v++) { - if (strncmp(v->lpszVarName,"Location",8) == 0 && v->dwVal == nLoc) + if (strncmp(v->_lpszVarName, "Location", 8) == 0 && v->_dwVal == nLoc) num++; } @@ -451,8 +451,8 @@ static uint32 *GetItemList(uint32 nLoc) { v = GLOBALS._lpmvVars; uint32 j = 0; for (uint32 i = 0; i < GLOBALS._nVars; i++, v++) { - if (strncmp(v->lpszVarName, "Location", 8) == 0 && v->dwVal == nLoc) { - sscanf(v->lpszVarName, "Location.%u", &il[j]); + if (strncmp(v->_lpszVarName, "Location", 8) == 0 && v->_dwVal == nLoc) { + sscanf(v->_lpszVarName, "Location.%u", &il[j]); j++; } } @@ -462,7 +462,7 @@ static uint32 *GetItemList(uint32 nLoc) { } static LPITEM getItemData(uint32 nOrdItem) { - LPMPALITEM curitem = GLOBALS._lpmiItems + nOrdItem; + LpMpalItem curitem = GLOBALS._lpmiItems + nOrdItem; LPITEM ret; HGLOBAL hDat; char *dat; @@ -474,7 +474,7 @@ static LPITEM getItemData(uint32 nOrdItem) { return NULL; ret->_speed = 150; - hDat = resLoad(curitem->dwRes); + hDat = resLoad(curitem->_dwRes); dat = (char *)globalLock(hDat); if (dat[0] == 'D' && dat[1] == 'A' && dat[2] == 'T') { @@ -597,7 +597,7 @@ void ScriptThread(CORO_PARAM, const void *param) { CORO_END_CONTEXT(_ctx); static uint32 cfHandles[MAX_COMMANDS_PER_MOMENT]; - LPMPALSCRIPT s = *(const LPMPALSCRIPT *)param; + LpMpalScript s = *(const LpMpalScript *)param; CORO_BEGIN_CODE(_ctx); @@ -605,24 +605,24 @@ void ScriptThread(CORO_PARAM, const void *param) { _ctx->numHandles = 0; // debugC(DEBUG_BASIC, kTonyDebugMPAL, "PlayScript(): Moments: %u\n",s->nMoments); - for (_ctx->i = 0; _ctx->i < s->nMoments; _ctx->i++) { + for (_ctx->i = 0; _ctx->i < s->_nMoments; _ctx->i++) { // Sleep for the required time - if (s->Moment[_ctx->i].dwTime == -1) { + if (s->_moment[_ctx->i]._dwTime == -1) { CORO_INVOKE_4(CoroScheduler.waitForMultipleObjects, _ctx->numHandles, cfHandles, true, CORO_INFINITE); _ctx->dwStartTime = g_vm->getTime(); } else { _ctx->dwCurTime = g_vm->getTime(); - if (_ctx->dwCurTime < _ctx->dwStartTime + (s->Moment[_ctx->i].dwTime * 100)) { + if (_ctx->dwCurTime < _ctx->dwStartTime + (s->_moment[_ctx->i]._dwTime * 100)) { // debugC(DEBUG_BASIC, kTonyDebugMPAL, "PlayScript(): Sleeping %lums\n",_ctx->dwStartTime+(s->Moment[_ctx->i].dwTime*100)-_ctx->dwCurTime); - CORO_INVOKE_1(CoroScheduler.sleep, _ctx->dwStartTime+(s->Moment[_ctx->i].dwTime * 100) - _ctx->dwCurTime); + CORO_INVOKE_1(CoroScheduler.sleep, _ctx->dwStartTime+(s->_moment[_ctx->i]._dwTime * 100) - _ctx->dwCurTime); } } _ctx->numHandles = 0; - for (_ctx->j = 0; _ctx->j < s->Moment[_ctx->i].nCmds; _ctx->j++) { - _ctx->k = s->Moment[_ctx->i].CmdNum[_ctx->j]; + for (_ctx->j = 0; _ctx->j < s->_moment[_ctx->i]._nCmds; _ctx->j++) { + _ctx->k = s->_moment[_ctx->i]._cmdNum[_ctx->j]; - if (s->_command[_ctx->k].type == 1) { + if (s->_command[_ctx->k]._type == 1) { _ctx->p = (LPCFCALL)globalAlloc(GMEM_FIXED, sizeof(CFCALL)); if (_ctx->p == NULL) { GLOBALS._mpalError = 1; @@ -644,11 +644,11 @@ void ScriptThread(CORO_PARAM, const void *param) { CORO_KILL_SELF(); return; } - } else if (s->_command[_ctx->k].type == 2) { + } else if (s->_command[_ctx->k]._type == 2) { lockVar(); varSetValue( - s->_command[_ctx->k].lpszVarName, - evaluateExpression(s->_command[_ctx->k].expr) + s->_command[_ctx->k]._lpszVarName, + evaluateExpression(s->_command[_ctx->k]._expr) ); unlockVar(); @@ -681,7 +681,7 @@ void ActionThread(CORO_PARAM, const void *param) { // COROUTINE CORO_BEGIN_CONTEXT; int j, k; - LPMPALITEM item; + LpMpalItem item; ~CoroContextTag() { if (item) @@ -693,13 +693,13 @@ void ActionThread(CORO_PARAM, const void *param) { // The ActionThread owns the data block pointed to, so we need to make sure it's // freed when the process exits - _ctx->item = *(LPMPALITEM *)param; + _ctx->item = *(LpMpalItem *)param; GLOBALS._mpalError = 0; - for (_ctx->j = 0; _ctx->j < _ctx->item->Action[_ctx->item->dwRes].nCmds; _ctx->j++) { - _ctx->k = _ctx->item->Action[_ctx->item->dwRes].CmdNum[_ctx->j]; + for (_ctx->j = 0; _ctx->j < _ctx->item->_action[_ctx->item->_dwRes]._nCmds; _ctx->j++) { + _ctx->k = _ctx->item->_action[_ctx->item->_dwRes]._cmdNum[_ctx->j]; - if (_ctx->item->_command[_ctx->k].type == 1) { + if (_ctx->item->_command[_ctx->k]._type == 1) { // Custom function debugC(DEBUG_DETAILED, kTonyDebugActions, "Action Process %d Call=%s params=%d,%d,%d,%d", CoroScheduler.getCurrentPID(), GLOBALS._lplpFunctionStrings[_ctx->item->_command[_ctx->k]._nCf].c_str(), @@ -714,13 +714,13 @@ void ActionThread(CORO_PARAM, const void *param) { _ctx->item->_command[_ctx->k]._arg4 ); - } else if (_ctx->item->_command[_ctx->k].type == 2) { + } else if (_ctx->item->_command[_ctx->k]._type == 2) { // Variable assign debugC(DEBUG_DETAILED, kTonyDebugActions, "Action Process %d Variable=%s", - CoroScheduler.getCurrentPID(), _ctx->item->_command[_ctx->k].lpszVarName); + CoroScheduler.getCurrentPID(), _ctx->item->_command[_ctx->k]._lpszVarName); lockVar(); - varSetValue(_ctx->item->_command[_ctx->k].lpszVarName, evaluateExpression(_ctx->item->_command[_ctx->k].expr)); + varSetValue(_ctx->item->_command[_ctx->k]._lpszVarName, evaluateExpression(_ctx->item->_command[_ctx->k]._expr)); unlockVar(); } else { @@ -775,20 +775,19 @@ void ShutUpActionThread(CORO_PARAM, const void *param) { */ void LocationPollThread(CORO_PARAM, const void *param) { typedef struct { - uint32 nItem, nAction; - - uint16 wTime; - byte perc; - HGLOBAL when; - byte nCmds; - uint16 CmdNum[MAX_COMMANDS_PER_ACTION]; - - uint32 dwLastTime; + uint32 _nItem, _nAction; + + uint16 _wTime; + byte _perc; + HGLOBAL _when; + byte _nCmds; + uint16 _cmdNum[MAX_COMMANDS_PER_ACTION]; + uint32 _dwLastTime; } MYACTION; typedef struct { - uint32 nItem; - uint32 hThread; + uint32 _nItem; + uint32 _hThread; } MYTHREAD; CORO_BEGIN_CONTEXT; @@ -796,7 +795,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { int i, j, k; int numitems; int nRealItems; - LPMPALITEM curItem,newItem; + LpMpalItem curItem,newItem; int nIdleActions; uint32 curTime; uint32 dwSleepTime; @@ -805,15 +804,15 @@ void LocationPollThread(CORO_PARAM, const void *param) { bool delayExpired; bool expired; - MYACTION *MyActions; - MYTHREAD *MyThreads; + MYACTION *myActions; + MYTHREAD *myThreads; ~CoroContextTag() { // Free data blocks - if (MyThreads) - globalDestroy(MyThreads); - if (MyActions) - globalDestroy(MyActions); + if (myThreads) + globalDestroy(myThreads); + if (myActions) + globalDestroy(myActions); } CORO_END_CONTEXT(_ctx); @@ -822,8 +821,8 @@ void LocationPollThread(CORO_PARAM, const void *param) { CORO_BEGIN_CODE(_ctx); // Initialize data pointers - _ctx->MyActions = NULL; - _ctx->MyThreads = NULL; + _ctx->myActions = NULL; + _ctx->myThreads = NULL; // To begin with, we need to request the item list from the location _ctx->il = mpalQueryItemList(GLOBALS._nPollingLocations[id]); @@ -845,8 +844,8 @@ void LocationPollThread(CORO_PARAM, const void *param) { _ctx->curItem = GLOBALS._lpmiItems + _ctx->ord; _ctx->k = 0; - for (_ctx->j = 0; _ctx->j < _ctx->curItem->nActions; _ctx->j++) { - if (_ctx->curItem->Action[_ctx->j].num == 0xFF) + for (_ctx->j = 0; _ctx->j < _ctx->curItem->_nActions; _ctx->j++) { + if (_ctx->curItem->_action[_ctx->j]._num == 0xFF) _ctx->k++; } @@ -867,8 +866,8 @@ void LocationPollThread(CORO_PARAM, const void *param) { return; } - _ctx->MyThreads = (MYTHREAD *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, _ctx->nRealItems * sizeof(MYTHREAD)); - if (_ctx->MyThreads == NULL) { + _ctx->myThreads = (MYTHREAD *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, _ctx->nRealItems * sizeof(MYTHREAD)); + if (_ctx->myThreads == NULL) { globalDestroy(_ctx->il); CORO_KILL_SELF(); return; @@ -877,9 +876,9 @@ void LocationPollThread(CORO_PARAM, const void *param) { // We have established that there is at least one item that contains idle actions. // Now we created the mirrored copies of the idle actions. - _ctx->MyActions = (MYACTION *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, _ctx->nIdleActions * sizeof(MYACTION)); - if (_ctx->MyActions == NULL) { - globalDestroy(_ctx->MyThreads); + _ctx->myActions = (MYACTION *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, _ctx->nIdleActions * sizeof(MYACTION)); + if (_ctx->myActions == NULL) { + globalDestroy(_ctx->myThreads); globalDestroy(_ctx->il); CORO_KILL_SELF(); return; @@ -894,19 +893,19 @@ void LocationPollThread(CORO_PARAM, const void *param) { _ctx->curItem = GLOBALS._lpmiItems + itemGetOrderFromNum(_ctx->il[_ctx->i]); - for (_ctx->j = 0; _ctx->j < _ctx->curItem->nActions; _ctx->j++) { - if (_ctx->curItem->Action[_ctx->j].num == 0xFF) { - _ctx->MyActions[_ctx->k].nItem = _ctx->il[_ctx->i]; - _ctx->MyActions[_ctx->k].nAction = _ctx->j; + for (_ctx->j = 0; _ctx->j < _ctx->curItem->_nActions; _ctx->j++) { + if (_ctx->curItem->_action[_ctx->j]._num == 0xFF) { + _ctx->myActions[_ctx->k]._nItem = _ctx->il[_ctx->i]; + _ctx->myActions[_ctx->k]._nAction = _ctx->j; - _ctx->MyActions[_ctx->k].wTime = _ctx->curItem->Action[_ctx->j].wTime; - _ctx->MyActions[_ctx->k].perc = _ctx->curItem->Action[_ctx->j].perc; - _ctx->MyActions[_ctx->k].when = _ctx->curItem->Action[_ctx->j].when; - _ctx->MyActions[_ctx->k].nCmds = _ctx->curItem->Action[_ctx->j].nCmds; - memcpy(_ctx->MyActions[_ctx->k].CmdNum, _ctx->curItem->Action[_ctx->j].CmdNum, + _ctx->myActions[_ctx->k]._wTime = _ctx->curItem->_action[_ctx->j]._wTime; + _ctx->myActions[_ctx->k]._perc = _ctx->curItem->_action[_ctx->j]._perc; + _ctx->myActions[_ctx->k]._when = _ctx->curItem->_action[_ctx->j]._when; + _ctx->myActions[_ctx->k]._nCmds = _ctx->curItem->_action[_ctx->j]._nCmds; + memcpy(_ctx->myActions[_ctx->k]._cmdNum, _ctx->curItem->_action[_ctx->j]._cmdNum, MAX_COMMANDS_PER_ACTION * sizeof(uint16)); - _ctx->MyActions[_ctx->k].dwLastTime = g_vm->getTime(); + _ctx->myActions[_ctx->k]._dwLastTime = g_vm->getTime(); _ctx->k++; } } @@ -925,11 +924,11 @@ void LocationPollThread(CORO_PARAM, const void *param) { _ctx->dwSleepTime = (uint32)-1L; for (_ctx->k = 0;_ctx->k<_ctx->nIdleActions;_ctx->k++) { - if (_ctx->curTime >= _ctx->MyActions[_ctx->k].dwLastTime + _ctx->MyActions[_ctx->k].wTime) { + if (_ctx->curTime >= _ctx->myActions[_ctx->k]._dwLastTime + _ctx->myActions[_ctx->k]._wTime) { _ctx->dwSleepTime = 0; break; } else - _ctx->dwSleepTime = MIN(_ctx->dwSleepTime, _ctx->MyActions[_ctx->k].dwLastTime + _ctx->MyActions[_ctx->k].wTime - _ctx->curTime); + _ctx->dwSleepTime = MIN(_ctx->dwSleepTime, _ctx->myActions[_ctx->k]._dwLastTime + _ctx->myActions[_ctx->k]._wTime - _ctx->curTime); } // We fall alseep, but always checking that the event is set when prompted for closure @@ -940,12 +939,12 @@ void LocationPollThread(CORO_PARAM, const void *param) { break; for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) { - if (_ctx->MyThreads[_ctx->i].nItem != 0) { - CORO_INVOKE_3(CoroScheduler.waitForSingleObject, _ctx->MyThreads[_ctx->i].hThread, 0, &_ctx->delayExpired); + if (_ctx->myThreads[_ctx->i]._nItem != 0) { + CORO_INVOKE_3(CoroScheduler.waitForSingleObject, _ctx->myThreads[_ctx->i]._hThread, 0, &_ctx->delayExpired); // if result == WAIT_OBJECT_0) if (!_ctx->delayExpired) - _ctx->MyThreads[_ctx->i].nItem = 0; + _ctx->myThreads[_ctx->i]._nItem = 0; } } @@ -953,19 +952,19 @@ void LocationPollThread(CORO_PARAM, const void *param) { // Loop through all the necessary idle actions for (_ctx->k = 0; _ctx->k < _ctx->nIdleActions; _ctx->k++) { - if (_ctx->curTime >= _ctx->MyActions[_ctx->k].dwLastTime + _ctx->MyActions[_ctx->k].wTime) { - _ctx->MyActions[_ctx->k].dwLastTime += _ctx->MyActions[_ctx->k].wTime; + if (_ctx->curTime >= _ctx->myActions[_ctx->k]._dwLastTime + _ctx->myActions[_ctx->k]._wTime) { + _ctx->myActions[_ctx->k]._dwLastTime += _ctx->myActions[_ctx->k]._wTime; // It's time to check to see if fortune is on the side of the idle action byte randomVal = (byte)g_vm->_randomSource.getRandomNumber(99); - if (randomVal < _ctx->MyActions[_ctx->k].perc) { + if (randomVal < _ctx->myActions[_ctx->k]._perc) { // Check if there is an action running on the item - if ((GLOBALS._bExecutingAction) && (GLOBALS._nExecutingAction == _ctx->MyActions[_ctx->k].nItem)) + if ((GLOBALS._bExecutingAction) && (GLOBALS._nExecutingAction == _ctx->myActions[_ctx->k]._nItem)) continue; // Check to see if there already another idle funning running on the item for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) { - if (_ctx->MyThreads[_ctx->i].nItem == _ctx->MyActions[_ctx->k].nItem) + if (_ctx->myThreads[_ctx->i]._nItem == _ctx->myActions[_ctx->k]._nItem) break; } @@ -974,49 +973,49 @@ void LocationPollThread(CORO_PARAM, const void *param) { // Ok, we are the only ones :) lockItems(); - _ctx->curItem = GLOBALS._lpmiItems + itemGetOrderFromNum(_ctx->MyActions[_ctx->k].nItem); + _ctx->curItem = GLOBALS._lpmiItems + itemGetOrderFromNum(_ctx->myActions[_ctx->k]._nItem); // Check if there is a WhenExecute expression - _ctx->j=_ctx->MyActions[_ctx->k].nAction; - if (_ctx->curItem->Action[_ctx->j].when != NULL) { - if (!evaluateExpression(_ctx->curItem->Action[_ctx->j].when)) { + _ctx->j=_ctx->myActions[_ctx->k]._nAction; + if (_ctx->curItem->_action[_ctx->j]._when != NULL) { + if (!evaluateExpression(_ctx->curItem->_action[_ctx->j]._when)) { unlockItems(); continue; } } // Ok, we can perform the action. For convenience, we do it in a new process - _ctx->newItem = (LPMPALITEM)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MPALITEM)); + _ctx->newItem = (LpMpalItem)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MpalItem)); if (_ctx->newItem == false) { - globalDestroy(_ctx->MyThreads); - globalDestroy(_ctx->MyActions); + globalDestroy(_ctx->myThreads); + globalDestroy(_ctx->myActions); CORO_KILL_SELF(); return; } - memcpy(_ctx->newItem,_ctx->curItem, sizeof(MPALITEM)); + memcpy(_ctx->newItem,_ctx->curItem, sizeof(MpalItem)); unlockItems(); // We copy the action in #0 //_ctx->newItem->Action[0].nCmds = _ctx->curItem->Action[_ctx->j].nCmds; //memcpy(_ctx->newItem->Action[0].CmdNum,_ctx->curItem->Action[_ctx->j].CmdNum,_ctx->newItem->Action[0].nCmds*sizeof(_ctx->newItem->Action[0].CmdNum[0])); - _ctx->newItem->dwRes=_ctx->j; + _ctx->newItem->_dwRes = _ctx->j; // We will create an action, and will provide the necessary details for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) { - if (_ctx->MyThreads[_ctx->i].nItem == 0) + if (_ctx->myThreads[_ctx->i]._nItem == 0) break; } - _ctx->MyThreads[_ctx->i].nItem = _ctx->MyActions[_ctx->k].nItem; + _ctx->myThreads[_ctx->i]._nItem = _ctx->myActions[_ctx->k]._nItem; // Create the process - if ((_ctx->MyThreads[_ctx->i].hThread = CoroScheduler.createProcess(ActionThread, &_ctx->newItem, sizeof(LPMPALITEM))) == CORO_INVALID_PID_VALUE) { - //if ((_ctx->MyThreads[_ctx->i].hThread = (void*)_beginthread(ActionThread, 10240,(void *)_ctx->newItem))= = (void*)-1) + if ((_ctx->myThreads[_ctx->i]._hThread = CoroScheduler.createProcess(ActionThread, &_ctx->newItem, sizeof(LpMpalItem))) == CORO_INVALID_PID_VALUE) { + //if ((_ctx->myThreads[_ctx->i]._hThread = (void*)_beginthread(ActionThread, 10240,(void *)_ctx->newItem)) == (void*)-1) globalDestroy(_ctx->newItem); - globalDestroy(_ctx->MyThreads); - globalDestroy(_ctx->MyActions); + globalDestroy(_ctx->myThreads); + globalDestroy(_ctx->myActions); CORO_KILL_SELF(); return; @@ -1033,14 +1032,14 @@ void LocationPollThread(CORO_PARAM, const void *param) { CORO_INVOKE_4(GLOBALS._lplpFunctions[200], 0, 0, 0, 0); for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) { - if (_ctx->MyThreads[_ctx->i].nItem != 0) { - CORO_INVOKE_3(CoroScheduler.waitForSingleObject, _ctx->MyThreads[_ctx->i].hThread, 5000, &_ctx->delayExpired); + if (_ctx->myThreads[_ctx->i]._nItem != 0) { + CORO_INVOKE_3(CoroScheduler.waitForSingleObject, _ctx->myThreads[_ctx->i]._hThread, 5000, &_ctx->delayExpired); //if (result != WAIT_OBJECT_0) //if (_ctx->delayExpired) // TerminateThread(_ctx->MyThreads[_ctx->i].hThread, 0); - CoroScheduler.killMatchingProcess(_ctx->MyThreads[_ctx->i].hThread); + CoroScheduler.killMatchingProcess(_ctx->myThreads[_ctx->i]._hThread); } } @@ -1090,7 +1089,7 @@ void doChoice(CORO_PARAM, uint32 nChoice); */ void GroupThread(CORO_PARAM, const void *param) { CORO_BEGIN_CONTEXT; - LPMPALDIALOG dialog; + LpMpalDialog dialog; int i, j, k; int type; CORO_END_CONTEXT(_ctx); @@ -1106,13 +1105,13 @@ void GroupThread(CORO_PARAM, const void *param) { _ctx->dialog = GLOBALS._lpmdDialogs + GLOBALS._nExecutingDialog; // Search inside the group requesting the _ctx->dialog - for (_ctx->i = 0; _ctx->dialog->_group[_ctx->i].num != 0; _ctx->i++) { - if (_ctx->dialog->_group[_ctx->i].num == nGroup) { + for (_ctx->i = 0; _ctx->dialog->_group[_ctx->i]._num != 0; _ctx->i++) { + if (_ctx->dialog->_group[_ctx->i]._num == nGroup) { // Cycle through executing the commands of the group - for (_ctx->j = 0; _ctx->j < _ctx->dialog->_group[_ctx->i].nCmds; _ctx->j++) { - _ctx->k = _ctx->dialog->_group[_ctx->i].CmdNum[_ctx->j]; + for (_ctx->j = 0; _ctx->j < _ctx->dialog->_group[_ctx->i]._nCmds; _ctx->j++) { + _ctx->k = _ctx->dialog->_group[_ctx->i]._cmdNum[_ctx->j]; - _ctx->type = _ctx->dialog->_command[_ctx->k].type; + _ctx->type = _ctx->dialog->_command[_ctx->k]._type; if (_ctx->type == 1) { // Call custom function CORO_INVOKE_4(GLOBALS._lplpFunctions[_ctx->dialog->_command[_ctx->k]._nCf], @@ -1125,12 +1124,12 @@ void GroupThread(CORO_PARAM, const void *param) { } else if (_ctx->type == 2) { // Set a variable lockVar(); - varSetValue(_ctx->dialog->_command[_ctx->k].lpszVarName, evaluateExpression(_ctx->dialog->_command[_ctx->k].expr)); + varSetValue(_ctx->dialog->_command[_ctx->k]._lpszVarName, evaluateExpression(_ctx->dialog->_command[_ctx->k]._expr)); unlockVar(); } else if (_ctx->type == 3) { // DoChoice: call the chosen function - CORO_INVOKE_1(doChoice, (uint32)_ctx->dialog->_command[_ctx->k].nChoice); + CORO_INVOKE_1(doChoice, (uint32)_ctx->dialog->_command[_ctx->k]._nChoice); } else { GLOBALS._mpalError = 1; @@ -1166,7 +1165,7 @@ void GroupThread(CORO_PARAM, const void *param) { */ void doChoice(CORO_PARAM, uint32 nChoice) { CORO_BEGIN_CONTEXT; - LPMPALDIALOG dialog; + LpMpalDialog dialog; int i, j, k; uint32 nGroup; CORO_END_CONTEXT(_ctx); @@ -1180,13 +1179,13 @@ void doChoice(CORO_PARAM, uint32 nChoice) { _ctx->dialog = GLOBALS._lpmdDialogs + GLOBALS._nExecutingDialog; // Search the choice between those required in the dialog - for (_ctx->i = 0; _ctx->dialog->_choice[_ctx->i].nChoice != 0; _ctx->i++) { - if (_ctx->dialog->_choice[_ctx->i].nChoice == nChoice) + for (_ctx->i = 0; _ctx->dialog->_choice[_ctx->i]._nChoice != 0; _ctx->i++) { + if (_ctx->dialog->_choice[_ctx->i]._nChoice == nChoice) break; } // If nothing has been found, exit with an error - if (_ctx->dialog->_choice[_ctx->i].nChoice == 0) { + if (_ctx->dialog->_choice[_ctx->i]._nChoice == 0) { // If we're here, we did not find the required choice GLOBALS._mpalError = 1; unlockDialogs(); @@ -1203,15 +1202,15 @@ void doChoice(CORO_PARAM, uint32 nChoice) { _ctx->k = 0; // Calculate the expression of each selection, to see if they're active or inactive - for (_ctx->j = 0; _ctx->dialog->_choice[_ctx->i]._select[_ctx->j].dwData != 0; _ctx->j++) { - if (_ctx->dialog->_choice[_ctx->i]._select[_ctx->j].when == NULL) { - _ctx->dialog->_choice[_ctx->i]._select[_ctx->j].curActive = 1; + for (_ctx->j = 0; _ctx->dialog->_choice[_ctx->i]._select[_ctx->j]._dwData != 0; _ctx->j++) { + if (_ctx->dialog->_choice[_ctx->i]._select[_ctx->j]._when == NULL) { + _ctx->dialog->_choice[_ctx->i]._select[_ctx->j]._curActive = 1; _ctx->k++; - } else if (evaluateExpression(_ctx->dialog->_choice[_ctx->i]._select[_ctx->j].when)) { - _ctx->dialog->_choice[_ctx->i]._select[_ctx->j].curActive = 1; + } else if (evaluateExpression(_ctx->dialog->_choice[_ctx->i]._select[_ctx->j]._when)) { + _ctx->dialog->_choice[_ctx->i]._select[_ctx->j]._curActive = 1; _ctx->k++; } else - _ctx->dialog->_choice[_ctx->i]._select[_ctx->j].curActive = 0; + _ctx->dialog->_choice[_ctx->i]._select[_ctx->j]._curActive = 0; } // If there are no choices activated, then the dialog is finished. @@ -1227,19 +1226,19 @@ void doChoice(CORO_PARAM, uint32 nChoice) { // Now that the choice has been made, we can run the groups associated with the choice tbontbtitq _ctx->j = GLOBALS._nSelectedChoice; - for (_ctx->k = 0; _ctx->dialog->_choice[_ctx->i]._select[_ctx->j].wPlayGroup[_ctx->k] != 0; _ctx->k++) { - _ctx->nGroup = _ctx->dialog->_choice[_ctx->i]._select[_ctx->j].wPlayGroup[_ctx->k]; + for (_ctx->k = 0; _ctx->dialog->_choice[_ctx->i]._select[_ctx->j]._wPlayGroup[_ctx->k] != 0; _ctx->k++) { + _ctx->nGroup = _ctx->dialog->_choice[_ctx->i]._select[_ctx->j]._wPlayGroup[_ctx->k]; CORO_INVOKE_1(GroupThread, &_ctx->nGroup); } // Control attribute - if (_ctx->dialog->_choice[_ctx->i]._select[_ctx->j].attr & (1 << 0)) { + if (_ctx->dialog->_choice[_ctx->i]._select[_ctx->j]._attr & (1 << 0)) { // Bit 0 set: the end of the choice unlockDialogs(); break; } - if (_ctx->dialog->_choice[_ctx->i]._select[_ctx->j].attr & (1 << 1)) { + if (_ctx->dialog->_choice[_ctx->i]._select[_ctx->j]._attr & (1 << 1)) { // Bit 1 set: the end of the dialog unlockDialogs(); @@ -1270,52 +1269,52 @@ void doChoice(CORO_PARAM, uint32 nChoice) { * by calling LockItem(). */ static uint32 doAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { - LPMPALITEM item = GLOBALS._lpmiItems; - LPMPALITEM newitem; + LpMpalItem item = GLOBALS._lpmiItems; + LpMpalItem newitem; item+=ordItem; - Common::String buf = Common::String::format("Status.%u", item->nObj); + Common::String buf = Common::String::format("Status.%u", item->_nObj); if (varGetValue(buf.c_str()) <= 0) return CORO_INVALID_PID_VALUE; - for (int i = 0; i < item->nActions; i++) { - if (item->Action[i].num != nAction) + for (int i = 0; i < item->_nActions; i++) { + if (item->_action[i]._num != nAction) continue; - if (item->Action[i].wParm != dwParam) + if (item->_action[i]._wParm != dwParam) continue; - if (item->Action[i].when != NULL) { - if (!evaluateExpression(item->Action[i].when)) + if (item->_action[i]._when != NULL) { + if (!evaluateExpression(item->_action[i]._when)) continue; } // Now we find the right action to be performed // Duplicate the item and copy the current action in #i into #0 - newitem = (LPMPALITEM)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MPALITEM)); + newitem = (LpMpalItem)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MpalItem)); if (newitem == NULL) return CORO_INVALID_PID_VALUE; // In the new version number of the action in writing dwRes - Common::copy((byte *)item, (byte *)item + sizeof(MPALITEM), (byte *)newitem); + Common::copy((byte *)item, (byte *)item + sizeof(MpalItem), (byte *)newitem); //newitem->Action[0].nCmds=item->Action[i].nCmds; //memcpy(newitem->Action[0].CmdNum,item->Action[i].CmdNum,newitem->Action[0].nCmds*sizeof(newitem->Action[0].CmdNum[0])); - newitem->dwRes = i; + newitem->_dwRes = i; // And finally we can laucnh the process that will execute the action, // and a second process to free up the memory when the action is finished. // !!! New process management uint32 h; - if ((h = CoroScheduler.createProcess(ActionThread, &newitem, sizeof(LPMPALITEM))) == CORO_INVALID_PID_VALUE) + if ((h = CoroScheduler.createProcess(ActionThread, &newitem, sizeof(LpMpalItem))) == CORO_INVALID_PID_VALUE) return CORO_INVALID_PID_VALUE; if (CoroScheduler.createProcess(ShutUpActionThread, &h, sizeof(uint32)) == CORO_INVALID_PID_VALUE) return CORO_INVALID_PID_VALUE; - GLOBALS._nExecutingAction = item->nObj; + GLOBALS._nExecutingAction = item->_nObj; GLOBALS._bExecutingAction = true; return h; @@ -1372,15 +1371,15 @@ static uint32 doDialog(uint32 nDlgOrd, uint32 nGroup) { * @returns True if everything is OK, false on failure */ bool doSelection(uint32 i, uint32 dwData) { - LPMPALDIALOG dialog = GLOBALS._lpmdDialogs + GLOBALS._nExecutingDialog; + LpMpalDialog dialog = GLOBALS._lpmdDialogs + GLOBALS._nExecutingDialog; int j; - for (j = 0; dialog->_choice[i]._select[j].dwData != 0; j++) { - if (dialog->_choice[i]._select[j].dwData == dwData && dialog->_choice[i]._select[j].curActive != 0) + for (j = 0; dialog->_choice[i]._select[j]._dwData != 0; j++) { + if (dialog->_choice[i]._select[j]._dwData == dwData && dialog->_choice[i]._select[j]._curActive != 0) break; } - if (dialog->_choice[i]._select[j].dwData == 0) + if (dialog->_choice[i]._select[j]._dwData == 0) return false; GLOBALS._nSelectedChoice = j; @@ -1469,7 +1468,7 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, hMpc.close(); // Process the data - if (ParseMpc(lpMpcImage) == false) + if (parseMpc(lpMpcImage) == false) return false; globalDestroy(lpMpcImage); @@ -1601,9 +1600,9 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { int y = GETARG(uint32); if (x != -1) { if (y == MPQ_X) - dwRet = GLOBALS._lpmlLocations[x].dwXlen; + dwRet = GLOBALS._lpmlLocations[x]._dwXlen; else if (y == MPQ_Y) - dwRet = GLOBALS._lpmlLocations[x].dwYlen; + dwRet = GLOBALS._lpmlLocations[x]._dwYlen; else GLOBALS._mpalError = 1; } else @@ -1662,7 +1661,7 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { else { lockItems(); int y = itemGetOrderFromNum(x); - memcpy(n, (char *)(GLOBALS._lpmiItems + y)->lpszDescribe, MAX_DESCRIBE_SIZE); + memcpy(n, (char *)(GLOBALS._lpmiItems + y)->_lpszDescribe, MAX_DESCRIBE_SIZE); unlockItems(); } @@ -1795,7 +1794,7 @@ HANDLE mpalQueryHANDLE(uint16 wQueryType, ...) { */ lockLocations(); int x = locGetOrderFromNum(GETARG(uint32)); - hRet = resLoad(GLOBALS._lpmlLocations[x].dwPicRes); + hRet = resLoad(GLOBALS._lpmlLocations[x]._dwPicRes); unlockLocations(); } else if (wQueryType == MPQ_RESOURCE) { @@ -1839,7 +1838,7 @@ HANDLE mpalQueryHANDLE(uint16 wQueryType, ...) { else { lockItems(); int y = itemGetOrderFromNum(x); - memcpy(n, (char *)(GLOBALS._lpmiItems + y)->lpszDescribe, MAX_DESCRIBE_SIZE); + memcpy(n, (char *)(GLOBALS._lpmiItems + y)->_lpszDescribe, MAX_DESCRIBE_SIZE); unlockItems(); } @@ -1959,25 +1958,24 @@ uint32 mpalGetError() { * @returns TRUE if the script 'was launched, FALSE on failure */ bool mpalExecuteScript(int nScript) { - LPMPALSCRIPT s; + LpMpalScript s; LockScripts(); int n = scriptGetOrderFromNum(nScript); - s = (LPMPALSCRIPT)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MPALSCRIPT)); + s = (LpMpalScript)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MpalScript)); if (s == NULL) return false; - memcpy(s, GLOBALS._lpmsScripts + n, sizeof(MPALSCRIPT)); + memcpy(s, GLOBALS._lpmsScripts + n, sizeof(MpalScript)); unlockScripts(); // !!! New process management - if (CoroScheduler.createProcess(ScriptThread, &s, sizeof(LPMPALSCRIPT)) == CORO_INVALID_PID_VALUE) + if (CoroScheduler.createProcess(ScriptThread, &s, sizeof(LpMpalScript)) == CORO_INVALID_PID_VALUE) return false; return true; } - /** * Install a custom routine That will be called by MPAL every time the pattern * of an item has been changed. @@ -1988,7 +1986,6 @@ void mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCus) { GLOBALS._lpiifCustom = lpiifCus; } - /** * Process the idle actions of the items on one location. * @@ -2063,7 +2060,7 @@ void mpalEndIdlePoll(CORO_PARAM, int nLoc, bool *result) { * @returns Length in bytes */ int mpalGetSaveStateSize() { - return GLOBALS._nVars * sizeof(MPALVAR) + 4; + return GLOBALS._nVars * sizeof(MpalVar) + 4; } /** @@ -2075,7 +2072,7 @@ int mpalGetSaveStateSize() { void mpalSaveState(byte *buf) { lockVar(); WRITE_LE_UINT32(buf, GLOBALS._nVars); - memcpy(buf + 4, (byte *)GLOBALS._lpmvVars, GLOBALS._nVars * sizeof(MPALVAR)); + memcpy(buf + 4, (byte *)GLOBALS._lpmvVars, GLOBALS._nVars * sizeof(MpalVar)); unlockVar(); } @@ -2092,12 +2089,12 @@ int mpalLoadState(byte *buf) { GLOBALS._nVars = READ_LE_UINT32(buf); - GLOBALS._hVars = globalAllocate(GMEM_ZEROINIT | GMEM_MOVEABLE, GLOBALS._nVars * sizeof(MPALVAR)); + GLOBALS._hVars = globalAllocate(GMEM_ZEROINIT | GMEM_MOVEABLE, GLOBALS._nVars * sizeof(MpalVar)); lockVar(); - memcpy((byte *)GLOBALS._lpmvVars, buf + 4, GLOBALS._nVars * sizeof(MPALVAR)); + memcpy((byte *)GLOBALS._lpmvVars, buf + 4, GLOBALS._nVars * sizeof(MpalVar)); unlockVar(); - return GLOBALS._nVars * sizeof(MPALVAR) + 4; + return GLOBALS._nVars * sizeof(MpalVar) + 4; } } // end of namespace MPAL diff --git a/engines/tony/mpal/mpal.h b/engines/tony/mpal/mpal.h index 492889d88a..1af0f2c9e9 100644 --- a/engines/tony/mpal/mpal.h +++ b/engines/tony/mpal/mpal.h @@ -120,31 +120,31 @@ enum QueryCoordinates { */ enum QueryTypes { // General Query - MPQ_VERSION=10, + MPQ_VERSION = 10, - MPQ_GLOBAL_VAR=50, + MPQ_GLOBAL_VAR = 50, MPQ_RESOURCE, MPQ_MESSAGE, // Query on leases - MPQ_LOCATION_IMAGE=100, + MPQ_LOCATION_IMAGE = 100, MPQ_LOCATION_SIZE, // Queries about items - MPQ_ITEM_LIST=200, + MPQ_ITEM_LIST = 200, MPQ_ITEM_DATA, MPQ_ITEM_PATTERN, MPQ_ITEM_NAME, MPQ_ITEM_IS_ACTIVE, // Query dialog - MPQ_DIALOG_PERIOD=300, + MPQ_DIALOG_PERIOD = 300, MPQ_DIALOG_WAITFORCHOICE, MPQ_DIALOG_SELECTLIST, MPQ_DIALOG_SELECTION, // Query execution - MPQ_DO_ACTION=400, + MPQ_DO_ACTION = 400, MPQ_DO_DIALOG }; @@ -164,7 +164,6 @@ typedef struct { short _destX, _destY; signed char _destZ; short _objectID; -// char TAG; } ITEM; typedef ITEM *LPITEM; diff --git a/engines/tony/mpal/mpaldll.h b/engines/tony/mpal/mpaldll.h index a95003ef97..853b5b2dac 100644 --- a/engines/tony/mpal/mpaldll.h +++ b/engines/tony/mpal/mpaldll.h @@ -42,32 +42,27 @@ namespace MPAL { * Defines \****************************************************************************/ -#define HEX_VERSION 0x0170 - - -#define MAX_ACTIONS_PER_ITEM 40 -#define MAX_COMMANDS_PER_ITEM 128 -#define MAX_COMMANDS_PER_ACTION 128 -#define MAX_DESCRIBE_SIZE 64 - - -#define MAX_MOMENTS_PER_SCRIPT 256 -#define MAX_COMMANDS_PER_SCRIPT 256 -#define MAX_COMMANDS_PER_MOMENT 32 - - -#define MAX_GROUPS_PER_DIALOG 128 -#define MAX_COMMANDS_PER_DIALOG 480 -#define MAX_COMMANDS_PER_GROUP 64 -#define MAX_CHOICES_PER_DIALOG 64 -#define MAX_SELECTS_PER_CHOICE 64 +#define HEX_VERSION 0x0170 + +#define MAX_ACTIONS_PER_ITEM 40 +#define MAX_COMMANDS_PER_ITEM 128 +#define MAX_COMMANDS_PER_ACTION 128 +#define MAX_DESCRIBE_SIZE 64 + +#define MAX_MOMENTS_PER_SCRIPT 256 +#define MAX_COMMANDS_PER_SCRIPT 256 +#define MAX_COMMANDS_PER_MOMENT 32 + +#define MAX_GROUPS_PER_DIALOG 128 +#define MAX_COMMANDS_PER_DIALOG 480 +#define MAX_COMMANDS_PER_GROUP 64 +#define MAX_CHOICES_PER_DIALOG 64 +#define MAX_SELECTS_PER_CHOICE 64 #define MAX_PLAYGROUPS_PER_SELECT 9 -#define MAX_PERIODS_PER_DIALOG 400 - +#define MAX_PERIODS_PER_DIALOG 400 #define NEED_LOCK_MSGS - /****************************************************************************\ * Structures \****************************************************************************/ @@ -77,42 +72,36 @@ namespace MPAL { /** * MPAL global variables */ -struct MPALVAR { - uint32 dwVal; // Variable value - char lpszVarName[33]; // Variable name +struct MpalVar { + uint32 _dwVal; // Variable value + char _lpszVarName[33]; // Variable name } PACKED_STRUCT; -typedef MPALVAR *LPMPALVAR; -typedef LPMPALVAR *LPLPMPALVAR; - +typedef MpalVar *LpMpalVar; /** * MPAL Messages */ -struct MPALMSG { - HGLOBAL _hText; // Handle to the message text - uint16 _wNum; // Message number +struct MpalMsg { + HGLOBAL _hText; // Handle to the message text + uint16 _wNum; // Message number } PACKED_STRUCT; -typedef MPALMSG *LPMPALMSG; -typedef LPMPALMSG *LPLPMPALMSG; - +typedef MpalMsg *LpMpalMsg; /** * MPAL Locations */ -struct MPALLOCATION { - uint32 nObj; // Location number - uint32 dwXlen, dwYlen; // Dimensions - uint32 dwPicRes; // Resource that contains the image +struct MpalLocation { + uint32 _nObj; // Location number + uint32 _dwXlen, _dwYlen; // Dimensions + uint32 _dwPicRes; // Resource that contains the image } PACKED_STRUCT; -typedef MPALLOCATION *LPMPALLOCATION; -typedef LPMPALLOCATION *LPLPMPALLOCATION; - +typedef MpalLocation *LpMpalLocation; /** * All the data for a command, ie. tags used by OnAction in the item, the time * in the script, and in the group dialog. */ -struct command { +struct Command { /* * Types of commands that are recognized * @@ -121,55 +110,54 @@ struct command { * #3 -> Making a choice (DIALOG) * */ - byte type; // Type of control + byte _type; // Type of control union { - int32 _nCf; // Custom function call [#1] - char *lpszVarName; // Variable name [#2] - int32 nChoice; // Number of choice you make [#3] + int32 _nCf; // Custom function call [#1] + char *_lpszVarName; // Variable name [#2] + int32 _nChoice; // Number of choice you make [#3] }; union { - int32 _arg1; // Argument for custom function [#1] - HGLOBAL expr; // Expression to assign to a variable [#2] + int32 _arg1; // Argument for custom function [#1] + HGLOBAL _expr; // Expression to assign to a variable [#2] }; - int32 _arg2, _arg3, _arg4; // Arguments for custom function [#1] + int32 _arg2, _arg3, _arg4; // Arguments for custom function [#1] } PACKED_STRUCT; /** * MPAL dialog */ -struct MPALDIALOG { - uint32 nObj; // Dialog number +struct MpalDialog { + uint32 _nObj; // Dialog number - struct command _command[MAX_COMMANDS_PER_DIALOG]; + struct Command _command[MAX_COMMANDS_PER_DIALOG]; struct { - uint16 num; - - byte nCmds; - uint16 CmdNum[MAX_COMMANDS_PER_GROUP]; + uint16 _num; + byte _nCmds; + uint16 _cmdNum[MAX_COMMANDS_PER_GROUP]; } _group[MAX_GROUPS_PER_DIALOG]; struct { // The last choice has nChoice == 0 - uint16 nChoice; + uint16 _nChoice; // The select number (we're pretty stingy with RAM). The last select has dwData == 0 struct { - HGLOBAL when; - uint32 dwData; - uint16 wPlayGroup[MAX_PLAYGROUPS_PER_SELECT]; + HGLOBAL _when; + uint32 _dwData; + uint16 _wPlayGroup[MAX_PLAYGROUPS_PER_SELECT]; // Bit 0=endchoice Bit 1=enddialog - byte attr; + byte _attr; // Modified at run-time: 0 if the select is currently disabled, // and 1 if currently active - byte curActive; + byte _curActive; } _select[MAX_SELECTS_PER_CHOICE]; } _choice[MAX_CHOICES_PER_DIALOG]; @@ -178,68 +166,60 @@ struct MPALDIALOG { HGLOBAL _periods[MAX_PERIODS_PER_DIALOG]; } PACKED_STRUCT; -typedef MPALDIALOG *LPMPALDIALOG; -typedef LPMPALDIALOG *LPLPMPALDIALOG; - +typedef MpalDialog *LpMpalDialog; /** * MPAL Item */ struct ItemAction { - byte num; // Action number - uint16 wTime; // If idle, the time which must pass - byte perc; // Percentage of the idle run - HGLOBAL when; // Expression to compute. If != 0, then + byte _num; // Action number + uint16 _wTime; // If idle, the time which must pass + byte _perc; // Percentage of the idle run + HGLOBAL _when; // Expression to compute. If != 0, then // action can be done - uint16 wParm; // Parameter for action + uint16 _wParm; // Parameter for action - byte nCmds; // Number of commands to be executed - uint32 CmdNum[MAX_COMMANDS_PER_ACTION]; // Commands to execute + byte _nCmds; // Number of commands to be executed + uint32 _cmdNum[MAX_COMMANDS_PER_ACTION]; // Commands to execute } PACKED_STRUCT; -struct MPALITEM { - uint32 nObj; // Item number +struct MpalItem { + uint32 _nObj; // Item number - byte lpszDescribe[MAX_DESCRIBE_SIZE]; // Name - byte nActions; // Number of managed actions - uint32 dwRes; // Resource that contains frames and patterns + byte _lpszDescribe[MAX_DESCRIBE_SIZE]; // Name + byte _nActions; // Number of managed actions + uint32 _dwRes; // Resource that contains frames and patterns - struct command _command[MAX_COMMANDS_PER_ITEM]; + struct Command _command[MAX_COMMANDS_PER_ITEM]; // Pointer to array of structures containing various managed activities. In practice, of // every action we know what commands to run, including those defined in structures above - struct ItemAction *Action; + struct ItemAction *_action; } PACKED_STRUCT; -typedef MPALITEM *LPMPALITEM; -typedef LPMPALITEM *LPLPMPALITEM; - +typedef MpalItem *LpMpalItem; /** * MPAL Script */ -struct MPALSCRIPT { - uint32 nObj; - - uint32 nMoments; +struct MpalScript { + uint32 _nObj; + uint32 _nMoments; - struct command _command[MAX_COMMANDS_PER_SCRIPT]; + struct Command _command[MAX_COMMANDS_PER_SCRIPT]; struct { - int32 dwTime; + int32 _dwTime; + byte _nCmds; + uint32 _cmdNum[MAX_COMMANDS_PER_MOMENT]; - byte nCmds; - uint32 CmdNum[MAX_COMMANDS_PER_MOMENT]; - - } Moment[MAX_MOMENTS_PER_SCRIPT]; + } _moment[MAX_MOMENTS_PER_SCRIPT]; } PACKED_STRUCT; -typedef MPALSCRIPT *LPMPALSCRIPT; -typedef LPMPALSCRIPT *LPLPMPALSCRIPT; +typedef MpalScript *LpMpalScript; #include "common/pack-end.h" - /****************************************************************************\ * Function prototypes \****************************************************************************/ diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index d135f66fde..9426a37a8b 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -312,7 +312,7 @@ void TonyEngine::playMusic(int nChannel, const Common::String &fname, int nFX, b uint32 hThread = CoroScheduler.createProcess(doNextMusic, NULL, 0); assert(hThread != CORO_INVALID_PID_VALUE); - } else if (nFX == 44) { // Cambia canale e lascia finire il primo + } else if (nFX == 44) { // Change the channel and let the first finish if (GLOBALS._flipflop) GLOBALS._nextChannel = nChannel - 1; else @@ -704,7 +704,7 @@ void TonyEngine::close() { _theEngine.close(); _window.close(); mpalFree(); - FreeMpc(); + freeMpc(); delete[] _curThumbnail; } -- cgit v1.2.3 From f2df769aab10e719cc4fba6cb71e1500eb3acae4 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 1 Sep 2012 00:25:35 +0200 Subject: TONY: More renaming --- engines/tony/custom.cpp | 2 +- engines/tony/custom.h | 3 - engines/tony/game.cpp | 2 +- engines/tony/game.h | 2 +- engines/tony/gfxengine.cpp | 2 +- engines/tony/globals.h | 34 +++++------ engines/tony/mpal/expr.cpp | 128 +++++++++++++++++++++--------------------- engines/tony/mpal/expr.h | 8 +-- engines/tony/mpal/loadmpc.cpp | 6 +- engines/tony/mpal/lzo.cpp | 32 +++++------ engines/tony/mpal/memory.cpp | 16 +++--- engines/tony/mpal/memory.h | 17 +++--- engines/tony/mpal/mpal.cpp | 62 ++++++++++---------- engines/tony/mpal/mpal.h | 24 ++++---- engines/tony/mpal/mpaldll.h | 26 ++++----- engines/tony/mpal/mpalutils.h | 2 +- engines/tony/utils.cpp | 4 +- engines/tony/utils.h | 2 +- 18 files changed, 182 insertions(+), 190 deletions(-) (limited to 'engines') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 9aef809826..4171691e87 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -1749,7 +1749,7 @@ int g_curDialog; DECLARE_CUSTOM_FUNCTION(SendDialogMessage)(CORO_PARAM, uint32 nPers, uint32 nMsg, uint32, uint32) { CORO_BEGIN_CONTEXT; - LPSTR string; + char *string; RMTextDialog *text; int parm; uint32 h; diff --git a/engines/tony/custom.h b/engines/tony/custom.h index 9e18ae2090..524ab14aab 100644 --- a/engines/tony/custom.h +++ b/engines/tony/custom.h @@ -36,10 +36,7 @@ namespace Tony { using namespace MPAL; -typedef uint32 HWND; - #define INIT_CUSTOM_FUNCTION MapCustomFunctions -#define INIT_CUSTOM_FUNCTION_STRING "MapCustomFunctions" #define DECLARE_CUSTOM_FUNCTION(x) void x diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 224427d10f..3031dabf3c 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -1039,7 +1039,7 @@ void RMOptionScreen::doFrame(CORO_PARAM, RMInput *input) { } #define KEYPRESS(c) (g_vm->getEngine()->getInput().getAsyncKeyState(c)) -#define PROCESS_CHAR(cod,c) if (KEYPRESS(cod)) { \ +#define PROCESS_CHAR(cod, c) if (KEYPRESS(cod)) { \ _editName[strlen(_editName) + 1] = '\0'; _editName[strlen(_editName)] = c; _ctx->bRefresh = true; } // State Buttons diff --git a/engines/tony/game.h b/engines/tony/game.h index 9c58f28714..626ec73afb 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -42,7 +42,7 @@ namespace Tony { assert(raw->isValid()); \ assert((buf16) == NULL); \ (buf16) = new RMGfxSourceBuffer16(false); \ - (buf16)->init(*raw,raw->width(),raw->height()); \ + (buf16)->init(*raw, raw->width(), raw->height()); \ delete raw; #define INIT_GFX8_FROMRAW(raw, dwRes, buf8) \ diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index da8218fa99..6f976ef37c 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -424,7 +424,7 @@ uint32 RMGfxEngine::loadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start) { _bLocationLoaded = true; // On entering the location - return CORO_INVALID_PID_VALUE; //mpalQueryDoAction(0,m_nCurLoc,0); + return CORO_INVALID_PID_VALUE; //mpalQueryDoAction(0, m_nCurLoc, 0); } void RMGfxEngine::unloadLocation(CORO_PARAM, bool bDoOnExit, uint32 *result) { diff --git a/engines/tony/globals.h b/engines/tony/globals.h index 6966bd7264..eda99eeee2 100644 --- a/engines/tony/globals.h +++ b/engines/tony/globals.h @@ -150,9 +150,9 @@ typedef struct { int _nCf; int _arg1, _arg2, _arg3, _arg4; -} CFCALL; -typedef CFCALL *LPCFCALL; -typedef LPCFCALL *LPLPCFCALL; +} CfCall; +typedef CfCall *LpCfCall; +typedef LpCfCall *LPLPCFCALL; struct CoroutineMutex { @@ -176,20 +176,20 @@ public: Common::String _nextMusic; bool _nextLoop; - int _nextChannel; - int _nextSync; - int _curChannel; - int _flipflop; + int _nextChannel; + int _nextSync; + int _curChannel; + int _flipflop; CharacterStruct _character[16]; MCharacterStruct _mCharacter[10]; ChangedHotspotStruct _changedHotspot[256]; bool _isMChar[16]; bool _bAlwaysDisplay; RMPoint _saveTonyPos; - int _saveTonyLoc; + int _saveTonyLoc; RMTextDialog *_curBackText; bool _bTonyIsSpeaking; - int _curChangedHotspot; + int _curChangedHotspot; bool _bCfgInvLocked; bool _bCfgInvNoScroll; bool _bCfgTimerizedText; @@ -210,8 +210,8 @@ public: bool _bSkipSfxNoLoop; bool _bIdleExited; bool _bNoBullsEye; - int _curDialog; - int _curSoundEffect; + int _curDialog; + int _curSoundEffect; bool _bFadeOutStop; RMTony *_tony; @@ -251,22 +251,22 @@ public: Common::String *_lplpFunctionStrings; uint16 _nObjs; uint16 _nVars; - HGLOBAL _hVars; + MpalHandle _hVars; LpMpalVar _lpmvVars; uint16 _nMsgs; - HGLOBAL _hMsgs; + MpalHandle _hMsgs; LpMpalMsg _lpmmMsgs; uint16 _nDialogs; - HGLOBAL _hDialogs; + MpalHandle _hDialogs; LpMpalDialog _lpmdDialogs; uint16 _nItems; - HGLOBAL _hItems; + MpalHandle _hItems; LpMpalItem _lpmiItems; uint16 _nLocations; - HGLOBAL _hLocations; + MpalHandle _hLocations; LpMpalLocation _lpmlLocations; uint16 _nScripts; - HGLOBAL _hScripts; + MpalHandle _hScripts; LpMpalScript _lpmsScripts; Common::File _hMpr; uint16 _nResources; diff --git a/engines/tony/mpal/expr.cpp b/engines/tony/mpal/expr.cpp index 31abeb0810..7923d263c0 100644 --- a/engines/tony/mpal/expr.cpp +++ b/engines/tony/mpal/expr.cpp @@ -81,20 +81,20 @@ enum ExprListTypes { * Mathamatical framework to manage operations */ typedef struct { - byte type; // Tipo di oggetto (vedi enum ExprListTypes) - byte unary; // Unary operatore (NON SUPPORTATO) + byte _type; // Tipo di oggetto (vedi enum ExprListTypes) + byte _unary; // Unary operatore (NON SUPPORTATO) union { - int num; // Numero (se type==ELT_NUMBER) - char *name; // Nome variabile (se type==ELT_VAR) - HGLOBAL son; // Handle a espressione (type==ELT_PARENTH) - byte *pson; // Handle lockato (type==ELT_PARENTH2) - } val; + int _num; // Numero (se type==ELT_NUMBER) + char *_name; // Nome variabile (se type==ELT_VAR) + MpalHandle _son; // Handle a espressione (type==ELT_PARENTH) + byte *_pson; // Handle lockato (type==ELT_PARENTH2) + } _val; - byte symbol; // Simbolo matematico (vedi #define OP_*) + byte _symbol; // Simbolo matematico (vedi #define OP_*) -} EXPRESSION; -typedef EXPRESSION *LPEXPRESSION; +} Expression; +typedef Expression *LpExpression; //@} @@ -104,24 +104,24 @@ typedef EXPRESSION *LPEXPRESSION; * @param h Handle to the original expression * @retruns Pointer to the cloned expression */ -static byte *duplicateExpression(HGLOBAL h) { +static byte *duplicateExpression(MpalHandle h) { byte *orig, *clone; - LPEXPRESSION one, two; + LpExpression one, two; orig = (byte *)globalLock(h); int num = *(byte *)orig; - one = (LPEXPRESSION)(orig+1); + one = (LpExpression)(orig+1); - clone = (byte *)globalAlloc(GMEM_FIXED, sizeof(EXPRESSION) * num + 1); - two = (LPEXPRESSION)(clone + 1); + clone = (byte *)globalAlloc(GMEM_FIXED, sizeof(Expression) * num + 1); + two = (LpExpression)(clone + 1); - memcpy(clone, orig, sizeof(EXPRESSION) * num + 1); + memcpy(clone, orig, sizeof(Expression) * num + 1); for (int i = 0; i < num; i++) { - if (one->type == ELT_PARENTH) { - two->type = ELT_PARENTH2; - two->val.pson = duplicateExpression(two->val.son); + if (one->_type == ELT_PARENTH) { + two->_type = ELT_PARENTH2; + two->_val._pson = duplicateExpression(two->_val._son); } ++one; @@ -178,27 +178,27 @@ static int Compute(int a, int b, byte symbol) { return 0; } -static void solve(LPEXPRESSION one, int num) { - LPEXPRESSION two, three; +static void solve(LpExpression one, int num) { + LpExpression two, three; int j; while (num > 1) { two = one + 1; - if ((two->symbol == 0) || (one->symbol & 0xF0) <= (two->symbol & 0xF0)) { - two->val.num = Compute(one->val.num, two->val.num, one->symbol); - memmove(one, two, (num - 1) * sizeof(EXPRESSION)); + if ((two->_symbol == 0) || (one->_symbol & 0xF0) <= (two->_symbol & 0xF0)) { + two->_val._num = Compute(one->_val._num, two->_val._num, one->_symbol); + memmove(one, two, (num - 1) * sizeof(Expression)); --num; } else { j = 1; three = two + 1; - while ((three->symbol != 0) && (two->symbol & 0xF0) > (three->symbol & 0xF0)) { + while ((three->_symbol != 0) && (two->_symbol & 0xF0) > (three->_symbol & 0xF0)) { ++two; ++three; ++j; } - three->val.num = Compute(two->val.num, three->val.num, two->symbol); - memmove(two, three, (num - j - 1) * sizeof(EXPRESSION)); + three->_val._num = Compute(two->_val._num, three->_val._num, two->_symbol); + memmove(two, three, (num - j - 1) * sizeof(Expression)); --num; } } @@ -213,32 +213,32 @@ static void solve(LPEXPRESSION one, int num) { * @returns Value */ static int evaluateAndFreeExpression(byte *expr) { - LPEXPRESSION one, cur; + LpExpression one, cur; int num = *expr; - one = (LPEXPRESSION)(expr + 1); + one = (LpExpression)(expr + 1); // 1) Substitutions of variables cur = one; for (int i = 0; i < num; i++, cur++) { - if (cur->type == ELT_VAR) { - cur->type = ELT_NUMBER; - cur->val.num = varGetValue(cur->val.name); + if (cur->_type == ELT_VAR) { + cur->_type = ELT_NUMBER; + cur->_val._num = varGetValue(cur->_val._name); } } // 2) Replacement of brackets (using recursive calls) cur = one; for (int i = 0; i < num; i++, cur++) { - if (cur->type == ELT_PARENTH2) { - cur->type = ELT_NUMBER; - cur->val.num = evaluateAndFreeExpression(cur->val.pson); + if (cur->_type == ELT_PARENTH2) { + cur->_type = ELT_NUMBER; + cur->_val._num = evaluateAndFreeExpression(cur->_val._pson); } } // 3) algebraic resolution solve(one, num); - int val = one->val.num; + int val = one->_val._num; globalDestroy(expr); return val; @@ -253,8 +253,8 @@ static int evaluateAndFreeExpression(byte *expr) { * will point to the area of memory containing the parsed expression * @returns Pointer to the buffer immediately after the expression, or NULL if error. */ -const byte *parseExpression(const byte *lpBuf, HGLOBAL *h) { - LPEXPRESSION cur; +const byte *parseExpression(const byte *lpBuf, MpalHandle *h) { + LpExpression cur; byte *start; uint32 num = *lpBuf; @@ -263,35 +263,35 @@ const byte *parseExpression(const byte *lpBuf, HGLOBAL *h) { if (num == 0) return NULL; - *h = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, num * sizeof(EXPRESSION) + 1); + *h = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, num * sizeof(Expression) + 1); if (*h == NULL) return NULL; start = (byte *)globalLock(*h); *start = (byte)num; - cur = (LPEXPRESSION)(start + 1); + cur = (LpExpression)(start + 1); for (uint32 i = 0;i < num; i++) { - cur->type = *(lpBuf); - cur->unary = *(lpBuf + 1); + cur->_type = *(lpBuf); + cur->_unary = *(lpBuf + 1); lpBuf += 2; - switch (cur->type) { + switch (cur->_type) { case ELT_NUMBER: - cur->val.num = (int32)READ_LE_UINT32(lpBuf); + cur->_val._num = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; break; case ELT_VAR: - cur->val.name = (char *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, (*lpBuf) + 1); - if (cur->val.name == NULL) + cur->_val._name = (char *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, (*lpBuf) + 1); + if (cur->_val._name == NULL) return NULL; - memcpy(cur->val.name, lpBuf + 1, *lpBuf); + memcpy(cur->_val._name, lpBuf + 1, *lpBuf); lpBuf += *lpBuf + 1; break; case ELT_PARENTH: - lpBuf = parseExpression(lpBuf, &cur->val.son); + lpBuf = parseExpression(lpBuf, &cur->_val._son); if (lpBuf == NULL) return NULL; break; @@ -300,7 +300,7 @@ const byte *parseExpression(const byte *lpBuf, HGLOBAL *h) { return NULL; } - cur->symbol = *lpBuf; + cur->_symbol = *lpBuf; lpBuf++; cur++; @@ -321,7 +321,7 @@ const byte *parseExpression(const byte *lpBuf, HGLOBAL *h) { * @param h Handle to the expression * @returns Numeric value */ -int evaluateExpression(HGLOBAL h) { +int evaluateExpression(MpalHandle h) { int ret; lockVar(); @@ -337,9 +337,9 @@ int evaluateExpression(HGLOBAL h) { * @param h1 Expression to be compared * @param h2 Expression to be compared */ -bool compareExpressions(HGLOBAL h1, HGLOBAL h2) { +bool compareExpressions(MpalHandle h1, MpalHandle h2) { byte *e1, *e2; - LPEXPRESSION one, two; + LpExpression one, two; e1 = (byte *)globalLock(h1); e2 = (byte *)globalLock(h2); @@ -353,19 +353,19 @@ bool compareExpressions(HGLOBAL h1, HGLOBAL h2) { return false; } - one = (LPEXPRESSION)(e1 + 1); - two = (LPEXPRESSION)(e2 + 1); + one = (LpExpression)(e1 + 1); + two = (LpExpression)(e2 + 1); for (int i = 0; i < num1; i++) { - if (one->type != two->type || (i != num1 - 1 && one->symbol != two->symbol)) { + if (one->_type != two->_type || (i != num1 - 1 && one->_symbol != two->_symbol)) { globalUnlock(h1); globalUnlock(h2); return false; } - switch (one->type) { + switch (one->_type) { case ELT_NUMBER: - if (one->val.num != two->val.num) { + if (one->_val._num != two->_val._num) { globalUnlock(h1); globalUnlock(h2); return false; @@ -373,7 +373,7 @@ bool compareExpressions(HGLOBAL h1, HGLOBAL h2) { break; case ELT_VAR: - if (strcmp(one->val.name, two->val.name) != 0) { + if (strcmp(one->_val._name, two->_val._name) != 0) { globalUnlock(h1); globalUnlock(h2); return false; @@ -381,7 +381,7 @@ bool compareExpressions(HGLOBAL h1, HGLOBAL h2) { break; case ELT_PARENTH: - if (!compareExpressions(one->val.son, two->val.son)) { + if (!compareExpressions(one->_val._son, two->_val._son)) { globalUnlock(h1); globalUnlock(h2); return false; @@ -404,19 +404,19 @@ bool compareExpressions(HGLOBAL h1, HGLOBAL h2) { * * @param h Handle for the expression */ -void freeExpression(HGLOBAL h) { +void freeExpression(MpalHandle h) { byte *data = (byte *)globalLock(h); int num = *data; - LPEXPRESSION cur = (LPEXPRESSION)(data + 1); + LpExpression cur = (LpExpression)(data + 1); for (int i = 0; i < num; ++i, ++cur) { - switch (cur->type) { + switch (cur->_type) { case ELT_VAR: - globalDestroy(cur->val.name); + globalDestroy(cur->_val._name); break; case ELT_PARENTH: - freeExpression(cur->val.son); + freeExpression(cur->_val._son); break; default: diff --git a/engines/tony/mpal/expr.h b/engines/tony/mpal/expr.h index f9c8a7c48f..9036099993 100644 --- a/engines/tony/mpal/expr.h +++ b/engines/tony/mpal/expr.h @@ -47,7 +47,7 @@ namespace MPAL { * will point to the area of memory containing the parsed expression * @returns Pointer to the buffer immediately after the expression, or NULL if error. */ -const byte *parseExpression(const byte *lpBuf, HGLOBAL *h); +const byte *parseExpression(const byte *lpBuf, MpalHandle *h); /** * Calculate the value of a mathamatical expression @@ -55,7 +55,7 @@ const byte *parseExpression(const byte *lpBuf, HGLOBAL *h); * @param h Handle to the expression * @returns Numeric value */ -int evaluateExpression(HGLOBAL h); +int evaluateExpression(MpalHandle h); /** * Compare two mathematical expressions together @@ -63,14 +63,14 @@ int evaluateExpression(HGLOBAL h); * @param h1 Expression to be compared * @param h2 Expression to be compared */ -bool compareExpressions(HGLOBAL h1, HGLOBAL h2); +bool compareExpressions(MpalHandle h1, MpalHandle h2); /** * Frees an expression that was previously parsed * * @param h Handle for the expression */ -void freeExpression(HGLOBAL h); +void freeExpression(MpalHandle h); } // end of namespace MPAL diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index b3c4193414..953820be74 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -253,14 +253,14 @@ static const byte *parseDialog(const byte *lpBuf, LpMpalDialog lpmdDialog) { } if (curCmd >= MAX_COMMANDS_PER_DIALOG) - error("Too much commands in dialog #%d",lpmdDialog->_nObj); + error("Too much commands in dialog #%d", lpmdDialog->_nObj); // Choices num = READ_LE_UINT16(lpBuf); lpBuf += 2; if (num >= MAX_CHOICES_PER_DIALOG) - error("Too much choices in dialog #%d",lpmdDialog->_nObj); + error("Too much choices in dialog #%d", lpmdDialog->_nObj); for (i = 0; i < num; i++) { lpmdDialog->_choice[i]._nChoice = READ_LE_UINT16(lpBuf); @@ -380,7 +380,7 @@ static const byte *parseItem(const byte *lpBuf, LpMpalItem lpmiItem) { lpBuf++; if (lpmiItem->_action[i]._nCmds >= MAX_COMMANDS_PER_ACTION) - error("Too much commands in action #%d in item #%d",lpmiItem->_action[i]._num, lpmiItem->_nObj); + error("Too much commands in action #%d in item #%d", lpmiItem->_action[i]._num, lpmiItem->_nObj); for (uint32 j = 0; j < lpmiItem->_action[i]._nCmds; j++) { lpmiItem->_command[curCmd]._type = *lpBuf; diff --git a/engines/tony/mpal/lzo.cpp b/engines/tony/mpal/lzo.cpp index 48a0d8ea87..3d0751a5ca 100644 --- a/engines/tony/mpal/lzo.cpp +++ b/engines/tony/mpal/lzo.cpp @@ -69,10 +69,10 @@ namespace Tony { namespace MPAL { -#define pd(a,b) ((uint32) ((a)-(b))) +#define pd(a, b) ((uint32) ((a) - (b))) #define TEST_IP (ip < ip_end) -#define TEST_OP 1 +#define TEST_OP 1 #define NEED_IP(x) ((void) 0) #define NEED_OP(x) ((void) 0) #define TEST_LB(m_pos) ((void) 0) @@ -83,7 +83,7 @@ namespace MPAL { /** * Decompresses an LZO compressed resource */ -int lzo1x_decompress(const byte *in , uint32 in_len, byte *out, uint32 *out_len) { +int lzo1x_decompress(const byte *in, uint32 in_len, byte *out, uint32 *out_len) { register byte *op; register const byte *ip; register uint32 t = 0; @@ -155,12 +155,12 @@ int lzo1x_decompress(const byte *in , uint32 in_len, byte *out, uint32 *out_len) t += 3; if (t >= 8) do { - UA_COPY64(op,ip); + UA_COPY64(op, ip); op += 8; ip += 8; t -= 8; } while (t >= 8); if (t >= 4) { - UA_COPY32(op,ip); + UA_COPY32(op, ip); op += 4; ip += 4; t -= 4; } if (t > 0) @@ -170,17 +170,17 @@ int lzo1x_decompress(const byte *in , uint32 in_len, byte *out, uint32 *out_len) } #elif defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4) #if !defined(LZO_UNALIGNED_OK_4) - if (PTR_ALIGNED2_4(op,ip)) + if (PTR_ALIGNED2_4(op, ip)) { #endif - UA_COPY32(op,ip); + UA_COPY32(op, ip); op += 4; ip += 4; if (--t > 0) { if (t >= 4) { do { - UA_COPY32(op,ip); + UA_COPY32(op, ip); op += 4; ip += 4; t -= 4; } while (t >= 4); if (t > 0) do *op++ = *ip++; while (--t > 0); @@ -213,7 +213,7 @@ first_literal_run: m_off = (1 + M2_MAX_OFFSET) + (t >> 2) + (*ip++ << 2); #endif NEED_OP(3); - t = 3; COPY_DICT(t,m_off) + t = 3; COPY_DICT(t, m_off) #else #if defined(LZO1Z) t = (1 + M2_MAX_OFFSET) + (t << 6) + (*ip++ >> 2); @@ -382,7 +382,7 @@ match: m_off = 1 + (t >> 2) + (*ip++ << 2); #endif NEED_OP(2); - t = 2; COPY_DICT(t,m_off) + t = 2; COPY_DICT(t, m_off) #else #if defined(LZO1Z) t = 1 + (t << 6) + (*ip++ >> 2); @@ -402,7 +402,7 @@ match: #if defined(COPY_DICT) NEED_OP(t+3-1); - t += 3-1; COPY_DICT(t,m_off) + t += 3-1; COPY_DICT(t, m_off) #else @@ -413,12 +413,12 @@ match: t += (3 - 1); if (t >= 8) do { - UA_COPY64(op,m_pos); + UA_COPY64(op, m_pos); op += 8; m_pos += 8; t -= 8; } while (t >= 8); if (t >= 4) { - UA_COPY32(op,m_pos); + UA_COPY32(op, m_pos); op += 4; m_pos += 4; t -= 4; } if (t > 0) @@ -430,17 +430,17 @@ match: else #elif defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4) #if !defined(LZO_UNALIGNED_OK_4) - if (t >= 2 * 4 - (3 - 1) && PTR_ALIGNED2_4(op,m_pos)) + if (t >= 2 * 4 - (3 - 1) && PTR_ALIGNED2_4(op, m_pos)) { assert((op - m_pos) >= 4); #else if (t >= 2 * 4 - (3 - 1) && (op - m_pos) >= 4) { #endif - UA_COPY32(op,m_pos); + UA_COPY32(op, m_pos); op += 4; m_pos += 4; t -= 4 - (3 - 1); do { - UA_COPY32(op,m_pos); + UA_COPY32(op, m_pos); op += 4; m_pos += 4; t -= 4; } while (t >= 4); if (t > 0) do *op++ = *m_pos++; while (--t > 0); diff --git a/engines/tony/mpal/memory.cpp b/engines/tony/mpal/memory.cpp index 3a68ecb559..428c07b3b7 100644 --- a/engines/tony/mpal/memory.cpp +++ b/engines/tony/mpal/memory.cpp @@ -39,7 +39,7 @@ const uint32 BLOCK_ID = 0x12345678; * Allocates a new memory block * @return Returns a MemoryItem instance for the new block */ -HANDLE MemoryManager::allocate(uint32 size, uint flags) { +MpalHandle MemoryManager::allocate(uint32 size, uint flags) { MemoryItem *newItem = (MemoryItem *)malloc(sizeof(MemoryItem) + size); newItem->_id = BLOCK_ID; newItem->_size = size; @@ -51,7 +51,7 @@ HANDLE MemoryManager::allocate(uint32 size, uint flags) { Common::fill(dataP, dataP + size, 0); } - return (HANDLE)newItem; + return (MpalHandle)newItem; } /** @@ -70,7 +70,7 @@ void *MemoryManager::alloc(uint32 size, uint flags) { * Returns a reference to the MemoryItem for a gien byte pointer * @param block Byte pointer */ -MemoryItem *MemoryManager::getItem(HGLOBAL handle) { +MemoryItem *MemoryManager::getItem(MpalHandle handle) { MemoryItem *rec = (MemoryItem *)((byte *)handle - OFFSETOF(MemoryItem, _data)); assert(rec->_id == BLOCK_ID); return rec; @@ -79,7 +79,7 @@ MemoryItem *MemoryManager::getItem(HGLOBAL handle) { /** * Returns a size of a memory block given its pointer */ -uint32 MemoryManager::getSize(HANDLE handle) { +uint32 MemoryManager::getSize(MpalHandle handle) { MemoryItem *item = (MemoryItem *)handle; assert(item->_id == BLOCK_ID); return item->_size; @@ -88,7 +88,7 @@ uint32 MemoryManager::getSize(HANDLE handle) { /** * Erases a given item */ -void MemoryManager::freeBlock(HANDLE handle) { +void MemoryManager::freeBlock(MpalHandle handle) { MemoryItem *item = (MemoryItem *)handle; assert(item->_id == BLOCK_ID); free(item); @@ -97,7 +97,7 @@ void MemoryManager::freeBlock(HANDLE handle) { /** * Erases a given item */ -void MemoryManager::destroyItem(HANDLE handle) { +void MemoryManager::destroyItem(MpalHandle handle) { MemoryItem *item = getItem(handle); assert(item->_id == BLOCK_ID); free(item); @@ -106,7 +106,7 @@ void MemoryManager::destroyItem(HANDLE handle) { /** * Locks an item for access */ -byte *MemoryManager::lockItem(HANDLE handle) { +byte *MemoryManager::lockItem(MpalHandle handle) { MemoryItem *item = (MemoryItem *)handle; assert(item->_id == BLOCK_ID); ++item->_lockCount; @@ -116,7 +116,7 @@ byte *MemoryManager::lockItem(HANDLE handle) { /** * Unlocks a locked item */ -void MemoryManager::unlockItem(HANDLE handle) { +void MemoryManager::unlockItem(MpalHandle handle) { MemoryItem *item = (MemoryItem *)handle; assert(item->_id == BLOCK_ID); assert(item->_lockCount > 0); diff --git a/engines/tony/mpal/memory.h b/engines/tony/mpal/memory.h index c7e4896cf9..b557743512 100644 --- a/engines/tony/mpal/memory.h +++ b/engines/tony/mpal/memory.h @@ -31,8 +31,7 @@ namespace Tony { namespace MPAL { -typedef void *HANDLE; -typedef HANDLE HGLOBAL; +typedef void *MpalHandle; struct MemoryItem { uint32 _id; @@ -46,15 +45,15 @@ struct MemoryItem { class MemoryManager { private: - static MemoryItem *getItem(HGLOBAL handle); + static MemoryItem *getItem(MpalHandle handle); public: - static HANDLE allocate(uint32 size, uint flags); + static MpalHandle allocate(uint32 size, uint flags); static void *alloc(uint32 size, uint flags); - static void freeBlock(HANDLE handle); - static void destroyItem(HANDLE handle); - static uint32 getSize(HANDLE handle); - static byte *lockItem(HANDLE handle); - static void unlockItem(HANDLE handle); + static void freeBlock(MpalHandle handle); + static void destroyItem(MpalHandle handle); + static uint32 getSize(MpalHandle handle); + static byte *lockItem(MpalHandle handle); + static void unlockItem(MpalHandle handle); }; // defines diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 9a92fd7766..533a4d22b9 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -360,8 +360,8 @@ static char *duplicateDialogPeriod(uint32 nPeriod) { * @param dwId ID of the resource to load * @returns Handle to the loaded resource */ -HGLOBAL resLoad(uint32 dwId) { - HGLOBAL h; +MpalHandle resLoad(uint32 dwId) { + MpalHandle h; char head[4]; uint32 nBytesRead; uint32 nSizeComp, nSizeDecomp; @@ -461,15 +461,15 @@ static uint32 *GetItemList(uint32 nLoc) { return il; } -static LPITEM getItemData(uint32 nOrdItem) { +static LpItem getItemData(uint32 nOrdItem) { LpMpalItem curitem = GLOBALS._lpmiItems + nOrdItem; - LPITEM ret; - HGLOBAL hDat; + LpItem ret; + MpalHandle hDat; char *dat; char *patlength; // Zeroing out the allocated memory is required!!! - ret = (LPITEM)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(ITEM)); + ret = (LpItem)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(Item)); if (ret == NULL) return NULL; ret->_speed = 150; @@ -536,7 +536,7 @@ static LPITEM getItemData(uint32 nOrdItem) { for (int i = 1; i < ret->_numframe; i++) { uint32 dim = (uint32)(ret->_frameslocations[i].right - ret->_frameslocations[i].left) * (uint32)(ret->_frameslocations[i].bottom - ret->_frameslocations[i].top); - ret->_frames[i] = (char *)globalAlloc(GMEM_FIXED,dim); + ret->_frames[i] = (char *)globalAlloc(GMEM_FIXED, dim); if (ret->_frames[i] == NULL) return NULL; @@ -565,12 +565,12 @@ static LPITEM getItemData(uint32 nOrdItem) { */ void CustomThread(CORO_PARAM, const void *param) { CORO_BEGIN_CONTEXT; - LPCFCALL p; + LpCfCall p; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); - _ctx->p = *(LPCFCALL *)param; + _ctx->p = *(LpCfCall *)param; CORO_INVOKE_4(GLOBALS._lplpFunctions[_ctx->p->_nCf], _ctx->p->_arg1, _ctx->p->_arg2, _ctx->p->_arg3, _ctx->p->_arg4); @@ -593,7 +593,7 @@ void ScriptThread(CORO_PARAM, const void *param) { uint32 dwCurTime; uint32 dwId; int numHandles; - LPCFCALL p; + LpCfCall p; CORO_END_CONTEXT(_ctx); static uint32 cfHandles[MAX_COMMANDS_PER_MOMENT]; @@ -604,7 +604,7 @@ void ScriptThread(CORO_PARAM, const void *param) { _ctx->dwStartTime = g_vm->getTime(); _ctx->numHandles = 0; -// debugC(DEBUG_BASIC, kTonyDebugMPAL, "PlayScript(): Moments: %u\n",s->nMoments); +// debugC(DEBUG_BASIC, kTonyDebugMPAL, "PlayScript(): Moments: %u\n", s->_nMoments); for (_ctx->i = 0; _ctx->i < s->_nMoments; _ctx->i++) { // Sleep for the required time if (s->_moment[_ctx->i]._dwTime == -1) { @@ -613,8 +613,8 @@ void ScriptThread(CORO_PARAM, const void *param) { } else { _ctx->dwCurTime = g_vm->getTime(); if (_ctx->dwCurTime < _ctx->dwStartTime + (s->_moment[_ctx->i]._dwTime * 100)) { - // debugC(DEBUG_BASIC, kTonyDebugMPAL, "PlayScript(): Sleeping %lums\n",_ctx->dwStartTime+(s->Moment[_ctx->i].dwTime*100)-_ctx->dwCurTime); - CORO_INVOKE_1(CoroScheduler.sleep, _ctx->dwStartTime+(s->_moment[_ctx->i]._dwTime * 100) - _ctx->dwCurTime); + // debugC(DEBUG_BASIC, kTonyDebugMPAL, "PlayScript(): Sleeping %lums\n",_ctx->dwStartTime + (s->_moment[_ctx->i]._dwTime*100) - _ctx->dwCurTime); + CORO_INVOKE_1(CoroScheduler.sleep, _ctx->dwStartTime + (s->_moment[_ctx->i]._dwTime * 100) - _ctx->dwCurTime); } } @@ -623,7 +623,7 @@ void ScriptThread(CORO_PARAM, const void *param) { _ctx->k = s->_moment[_ctx->i]._cmdNum[_ctx->j]; if (s->_command[_ctx->k]._type == 1) { - _ctx->p = (LPCFCALL)globalAlloc(GMEM_FIXED, sizeof(CFCALL)); + _ctx->p = (LpCfCall)globalAlloc(GMEM_FIXED, sizeof(CfCall)); if (_ctx->p == NULL) { GLOBALS._mpalError = 1; @@ -638,7 +638,7 @@ void ScriptThread(CORO_PARAM, const void *param) { _ctx->p->_arg4 = s->_command[_ctx->k]._arg4; // !!! New process management - if ((cfHandles[_ctx->numHandles++] = CoroScheduler.createProcess(CustomThread, &_ctx->p, sizeof(LPCFCALL))) == 0) { + if ((cfHandles[_ctx->numHandles++] = CoroScheduler.createProcess(CustomThread, &_ctx->p, sizeof(LpCfCall))) == 0) { GLOBALS._mpalError = 1; CORO_KILL_SELF(); @@ -775,14 +775,14 @@ void ShutUpActionThread(CORO_PARAM, const void *param) { */ void LocationPollThread(CORO_PARAM, const void *param) { typedef struct { - uint32 _nItem, _nAction; - - uint16 _wTime; - byte _perc; - HGLOBAL _when; - byte _nCmds; - uint16 _cmdNum[MAX_COMMANDS_PER_ACTION]; - uint32 _dwLastTime; + uint32 _nItem, _nAction; + + uint16 _wTime; + byte _perc; + MpalHandle _when; + byte _nCmds; + uint16 _cmdNum[MAX_COMMANDS_PER_ACTION]; + uint32 _dwLastTime; } MYACTION; typedef struct { @@ -795,7 +795,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { int i, j, k; int numitems; int nRealItems; - LpMpalItem curItem,newItem; + LpMpalItem curItem, newItem; int nIdleActions; uint32 curTime; uint32 dwSleepTime; @@ -1012,7 +1012,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { // Create the process if ((_ctx->myThreads[_ctx->i]._hThread = CoroScheduler.createProcess(ActionThread, &_ctx->newItem, sizeof(LpMpalItem))) == CORO_INVALID_PID_VALUE) { - //if ((_ctx->myThreads[_ctx->i]._hThread = (void*)_beginthread(ActionThread, 10240,(void *)_ctx->newItem)) == (void*)-1) + //if ((_ctx->myThreads[_ctx->i]._hThread = (void*)_beginthread(ActionThread, 10240, (void *)_ctx->newItem)) == (void*)-1) globalDestroy(_ctx->newItem); globalDestroy(_ctx->myThreads); globalDestroy(_ctx->myActions); @@ -1298,8 +1298,8 @@ static uint32 doAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { // In the new version number of the action in writing dwRes Common::copy((byte *)item, (byte *)item + sizeof(MpalItem), (byte *)newitem); - //newitem->Action[0].nCmds=item->Action[i].nCmds; - //memcpy(newitem->Action[0].CmdNum,item->Action[i].CmdNum,newitem->Action[0].nCmds*sizeof(newitem->Action[0].CmdNum[0])); + //newitem->_action[0]._nCmds=item->_action[i]._nCmds; + //memcpy(newitem->_action[0]._cmdNum, item->_action[i]._cmdNum, newitem->Action[0].nCmds * sizeof(newitem->_action[0]._cmdNum[0])); newitem->_dwRes = i; @@ -1630,7 +1630,7 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { } else if (wQueryType == MPQ_ITEM_DATA) { /* - * LPITEM mpalQuery(MPQ_ITEM_DATA, uint32 nItem); + * LpItem mpalQuery(MPQ_ITEM_DATA, uint32 nItem); */ error("mpalQuery(MPQ_ITEM_DATA, uint32 nItem) used incorrect variant"); @@ -1747,7 +1747,7 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { * @remarks This is the specialised version of the original single mpalQuery * method that returns a pointer or handle. */ -HANDLE mpalQueryHANDLE(uint16 wQueryType, ...) { +MpalHandle mpalQueryHANDLE(uint16 wQueryType, ...) { char *n; Common::String buf; va_list v; @@ -1813,7 +1813,7 @@ HANDLE mpalQueryHANDLE(uint16 wQueryType, ...) { } else if (wQueryType == MPQ_ITEM_DATA) { /* - * LPITEM mpalQuery(MPQ_ITEM_DATA, uint32 nItem); + * LpItem mpalQuery(MPQ_ITEM_DATA, uint32 nItem); */ lockItems(); hRet = getItemData(itemGetOrderFromNum(GETARG(uint32))); @@ -2008,7 +2008,7 @@ bool mpalStartIdlePoll(int nLoc) { GLOBALS._hEndPollingLocations[i] = CoroScheduler.createEvent(true, false); // !!! New process management if ((GLOBALS._pollingThreads[i] = CoroScheduler.createProcess(LocationPollThread, &i, sizeof(uint32))) == CORO_INVALID_PID_VALUE) -// if ((GLOBALS.hEndPollingLocations[i] = (void*)_beginthread(LocationPollThread, 10240,(void *)i))= = (void*)-1) +// if ((GLOBALS.hEndPollingLocations[i] = (void*)_beginthread(LocationPollThread, 10240, (void *)i))= = (void*)-1) return false; return true; diff --git a/engines/tony/mpal/mpal.h b/engines/tony/mpal/mpal.h index 1af0f2c9e9..c5f505063f 100644 --- a/engines/tony/mpal/mpal.h +++ b/engines/tony/mpal/mpal.h @@ -100,11 +100,8 @@ namespace MPAL { #define MAXFRAMES 400 // frame animation of an object #define MAXPATTERN 40 // pattern of animation of an object - #define MAXPOLLINGLOCATIONS 64 -#define LPSTR char * - /** * Macro for use with queries that may refer to X and Y co-ordinates */ @@ -113,7 +110,6 @@ enum QueryCoordinates { MPQ_Y }; - /** * Query can be used with mpalQuery methods. In practice corresponds all claims * that can do at the library @@ -164,8 +160,8 @@ typedef struct { short _destX, _destY; signed char _destZ; short _objectID; -} ITEM; -typedef ITEM *LPITEM; +} Item; +typedef Item *LpItem; /** @@ -228,7 +224,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * after use. The message will be in ASCIIZ format. */ #define mpalQueryMessage(nMsg) \ - (LPSTR)mpalQueryHANDLE(MPQ_MESSAGE, (uint32)(nMsg)) + (char *)mpalQueryHANDLE(MPQ_MESSAGE, (uint32)(nMsg)) /** @@ -246,7 +242,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * @param dwCoord MPQ_X or MPQ_Y coordinate to retrieve * @returns Size */ -#define mpalQueryLocationSize(nLoc,dwCoord) \ +#define mpalQueryLocationSize(nLoc, dwCoord) \ mpalQueryDWORD(MPQ_LOCATION_SIZE, (uint32)(nLoc), (uint32)(dwCoord)) @@ -268,7 +264,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * @returns Structure filled with requested information */ #define mpalQueryItemData(nItem) \ - (LPITEM)mpalQueryHANDLE(MPQ_ITEM_DATA, (uint32)(nItem)) + (LpItem)mpalQueryHANDLE(MPQ_ITEM_DATA, (uint32)(nItem)) /** @@ -302,7 +298,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * is less than or equal to 0), the string will be empty. */ #define mpalQueryItemName(nItem, lpszName) \ - mpalQueryHANDLE(MPQ_ITEM_NAME, (uint32)(nItem), (LPSTR)(lpszName)) + mpalQueryHANDLE(MPQ_ITEM_NAME, (uint32)(nItem), (char *)(lpszName)) /** @@ -316,7 +312,7 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * string terminated with 0. */ #define mpalQueryDialogPeriod(nPeriod) \ - (LPSTR)mpalQueryHANDLE(MPQ_DIALOG_PERIOD, (uint32)(nPeriod)) + (char *)mpalQueryHANDLE(MPQ_DIALOG_PERIOD, (uint32)(nPeriod)) /** @@ -379,8 +375,8 @@ typedef LPITEMIRQFUNCTION* LPLPITEMIRQFUNCTION; * @returns Handle to the thread that is running the box, or * CORO_INVALID_PID_VALUE if the dialogue does not exist. */ -#define mpalQueryDoDialog(nDialog,nGroup) \ - mpalQueryDWORD(MPQ_DO_DIALOG, (uint32)(nDialog),(uint32)(nGroup)) +#define mpalQueryDoDialog(nDialog, nGroup) \ + mpalQueryDWORD(MPQ_DO_DIALOG, (uint32)(nDialog), (uint32)(nGroup)) /** * @defgroup Functions exported to the main game @@ -422,7 +418,7 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...); * @remarks This is the specialised version of the original single mpalQuery * method that returns a pointer or handle. */ -HANDLE mpalQueryHANDLE(uint16 wQueryType, ...); +MpalHandle mpalQueryHANDLE(uint16 wQueryType, ...); /** * This is a general function to communicate with the library, to request information diff --git a/engines/tony/mpal/mpaldll.h b/engines/tony/mpal/mpaldll.h index 853b5b2dac..8897096f51 100644 --- a/engines/tony/mpal/mpaldll.h +++ b/engines/tony/mpal/mpaldll.h @@ -82,8 +82,8 @@ typedef MpalVar *LpMpalVar; * MPAL Messages */ struct MpalMsg { - HGLOBAL _hText; // Handle to the message text - uint16 _wNum; // Message number + MpalHandle _hText; // Handle to the message text + uint16 _wNum; // Message number } PACKED_STRUCT; typedef MpalMsg *LpMpalMsg; @@ -110,7 +110,7 @@ struct Command { * #3 -> Making a choice (DIALOG) * */ - byte _type; // Type of control + byte _type; // Type of control union { int32 _nCf; // Custom function call [#1] @@ -120,10 +120,10 @@ struct Command { union { int32 _arg1; // Argument for custom function [#1] - HGLOBAL _expr; // Expression to assign to a variable [#2] + MpalHandle _expr; // Expression to assign to a variable [#2] }; - int32 _arg2, _arg3, _arg4; // Arguments for custom function [#1] + int32 _arg2, _arg3, _arg4; // Arguments for custom function [#1] } PACKED_STRUCT; @@ -148,7 +148,7 @@ struct MpalDialog { // The select number (we're pretty stingy with RAM). The last select has dwData == 0 struct { - HGLOBAL _when; + MpalHandle _when; uint32 _dwData; uint16 _wPlayGroup[MAX_PLAYGROUPS_PER_SELECT]; @@ -163,7 +163,7 @@ struct MpalDialog { } _choice[MAX_CHOICES_PER_DIALOG]; uint16 _periodNums[MAX_PERIODS_PER_DIALOG]; - HGLOBAL _periods[MAX_PERIODS_PER_DIALOG]; + MpalHandle _periods[MAX_PERIODS_PER_DIALOG]; } PACKED_STRUCT; typedef MpalDialog *LpMpalDialog; @@ -175,20 +175,20 @@ struct ItemAction { byte _num; // Action number uint16 _wTime; // If idle, the time which must pass byte _perc; // Percentage of the idle run - HGLOBAL _when; // Expression to compute. If != 0, then - // action can be done + MpalHandle _when; // Expression to compute. If != 0, then + // action can be done uint16 _wParm; // Parameter for action - byte _nCmds; // Number of commands to be executed + byte _nCmds; // Number of commands to be executed uint32 _cmdNum[MAX_COMMANDS_PER_ACTION]; // Commands to execute } PACKED_STRUCT; struct MpalItem { - uint32 _nObj; // Item number + uint32 _nObj; // Item number byte _lpszDescribe[MAX_DESCRIBE_SIZE]; // Name - byte _nActions; // Number of managed actions - uint32 _dwRes; // Resource that contains frames and patterns + byte _nActions; // Number of managed actions + uint32 _dwRes; // Resource that contains frames and patterns struct Command _command[MAX_COMMANDS_PER_ITEM]; diff --git a/engines/tony/mpal/mpalutils.h b/engines/tony/mpal/mpalutils.h index 19e4fa7778..8bc3e1d7c6 100644 --- a/engines/tony/mpal/mpalutils.h +++ b/engines/tony/mpal/mpalutils.h @@ -37,7 +37,7 @@ namespace MPAL { class RMRes { protected: - HGLOBAL _h; + MpalHandle _h; byte *_buf; public: diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index db83c2910b..99ba84ab19 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -370,7 +370,7 @@ void RMResUpdate::init(const Common::String &fileName) { } } -HGLOBAL RMResUpdate::queryResource(uint32 dwRes) { +MpalHandle RMResUpdate::queryResource(uint32 dwRes) { // If there isn't an update file, return NULL if (!_hFile.isOpen()) return NULL; @@ -400,7 +400,7 @@ HGLOBAL RMResUpdate::queryResource(uint32 dwRes) { } // Allocate space for the output resource - HGLOBAL destBuf = globalAllocate(0, info._size); + MpalHandle destBuf = globalAllocate(0, info._size); byte *lpDestBuf = (byte *)globalLock(destBuf); uint32 dwSize; diff --git a/engines/tony/utils.h b/engines/tony/utils.h index d3f93e06ef..a24e11f2b6 100644 --- a/engines/tony/utils.h +++ b/engines/tony/utils.h @@ -173,7 +173,7 @@ public: ~RMResUpdate(); void init(const Common::String &fileName); - HGLOBAL queryResource(uint32 dwRes); + MpalHandle queryResource(uint32 dwRes); }; } // End of namespace Tony -- cgit v1.2.3 From 8c753c96a097c3b6e67b061470606278a0d8f102 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 1 Sep 2012 01:05:22 +0200 Subject: TONY: Move some functions from .h to .cpp files --- engines/tony/game.cpp | 31 ++++++++++++++++++++++++++++ engines/tony/game.h | 44 ++++++++++++++-------------------------- engines/tony/gfxengine.cpp | 23 +++++++++++++++++++++ engines/tony/gfxengine.h | 21 ++++++------------- engines/tony/loc.h | 1 + engines/tony/sound.h | 8 +++----- engines/tony/tony.cpp | 16 +++++++++++++++ engines/tony/tony.h | 16 ++++----------- engines/tony/tonychar.cpp | 50 ++++++++++++++++++++++++++++++++++++++++++++++ engines/tony/tonychar.h | 33 +++++++++--------------------- 10 files changed, 158 insertions(+), 85 deletions(-) (limited to 'engines') diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 3031dabf3c..3abc7a20f8 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -1571,4 +1571,35 @@ void RMPointer::updateCursor() { CursorMan.replaceCursor(cursorData, 64, 64, _cursorHotspot._x, _cursorHotspot._y, 0, 1, &pixelFormat); } +/** + * Sets a new action as current + */ +void RMPointer::setAction(RMTonyAction action) { + _nCurPointer = action; + updateCursor(); +} + +/** + * Sets a new pointer + */ +void RMPointer::setSpecialPointer(PointerType ptr) { + _nCurSpecialPointer = ptr; + if (_nCurSpecialPointer && _nCurSpecialPointer != PTR_CUSTOM) + _specialPointer[ptr - 1]->setPattern(1); + + updateCursor(); +} + +RMPointer::PointerType RMPointer::getSpecialPointer() { + return (PointerType)_nCurSpecialPointer; +} + +/** + * Set the new custom pointer + */ +void RMPointer::setCustomPointer(RMGfxSourceBuffer8 *ptr) { + _nCurCustomPointer = ptr; + updateCursor(); +} + } // End of namespace Tony diff --git a/engines/tony/game.h b/engines/tony/game.h index 626ec73afb..bb6a356f0a 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -53,8 +53,18 @@ namespace Tony { (buf8)->init(*raw, raw->width(), raw->height(), true); \ delete raw; - class RMPointer { +public: + enum PointerType { + PTR_NONE = 0, + PTR_ARROWUP, + PTR_ARROWDOWN, + PTR_ARROWLEFT, + PTR_ARROWRIGHT, + PTR_ARROWMAP, + PTR_CUSTOM + }; + private: RMGfxSourceBuffer8 *_pointer[16]; RMPoint _hotspot[16]; @@ -67,17 +77,6 @@ private: RMGfxSourceBuffer8 *_nCurCustomPointer; -public: - enum PointerType { - PTR_NONE = 0, - PTR_ARROWUP, - PTR_ARROWDOWN, - PTR_ARROWLEFT, - PTR_ARROWRIGHT, - PTR_ARROWMAP, - PTR_CUSTOM - }; - public: /** * Constructor & destructor @@ -108,32 +107,19 @@ public: /** * Sets a new action as current */ - void setAction(RMTonyAction action) { - _nCurPointer = action; - updateCursor(); - } + void setAction(RMTonyAction action); /** * Sets a new pointer */ - void setSpecialPointer(PointerType ptr) { - _nCurSpecialPointer = ptr; - if (_nCurSpecialPointer && _nCurSpecialPointer != PTR_CUSTOM) - _specialPointer[ptr - 1]->setPattern(1); + void setSpecialPointer(PointerType ptr); - updateCursor(); - } - PointerType getSpecialPointer() { - return (PointerType)_nCurSpecialPointer; - } + PointerType getSpecialPointer(); /** * Set the new custom pointer */ - void setCustomPointer(RMGfxSourceBuffer8 *ptr) { - _nCurCustomPointer = ptr; - updateCursor(); - } + void setCustomPointer(RMGfxSourceBuffer8 *ptr); /** * Return the current action to be applied according to the pointer diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp index 6f976ef37c..5c038e154d 100644 --- a/engines/tony/gfxengine.cpp +++ b/engines/tony/gfxengine.cpp @@ -836,4 +836,27 @@ bool RMGfxEngine::canLoadSave() { return _bInput && !_tony.inAction() && !g_vm->getIsDemo(); } +RMGfxEngine::operator RMGfxTargetBuffer &() { + return _bigBuf; +} + +RMInput &RMGfxEngine::getInput() { + return _input; +} + +RMPointer &RMGfxEngine::getPointer() { + return _point; +} + +/** + * Link to graphic task + */ +void RMGfxEngine::linkGraphicTask(RMGfxTask *task) { + _bigBuf.addPrim(new RMGfxPrimitive(task)); +} + +void RMGfxEngine::setPerorate(bool bpal) { + _inter.setPerorate(bpal); +} + } // End of namespace Tony diff --git a/engines/tony/gfxengine.h b/engines/tony/gfxengine.h index 2e22e1ca62..ab32a01972 100644 --- a/engines/tony/gfxengine.h +++ b/engines/tony/gfxengine.h @@ -102,23 +102,15 @@ public: void enableMouse(); void disableMouse(); - operator RMGfxTargetBuffer &() { - return _bigBuf; - } - RMInput &getInput() { - return _input; - } - RMPointer &getPointer() { - return _point; - } + operator RMGfxTargetBuffer &(); + RMInput &getInput(); + RMPointer &getPointer(); // Link to the custom function list void initCustomDll(); // Link to graphic task - void linkGraphicTask(RMGfxTask *task) { - _bigBuf.addPrim(new RMGfxPrimitive(task)); - }; + void linkGraphicTask(RMGfxTask *task); // Manage a location uint32 loadLocation(int nLoc, RMPoint ptTonyStart, RMPoint start); @@ -137,9 +129,8 @@ public: void closeWipe(); void waitWipeEnd(CORO_PARAM); - void setPerorate(bool bpal) { - _inter.setPerorate(bpal); - } + void setPerorate(bool bpal); + bool canLoadSave(); }; diff --git a/engines/tony/loc.h b/engines/tony/loc.h index 7b0a2ddd6b..6c28a66f65 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -529,6 +529,7 @@ private: public: // @@@@@@@@@@@@@@@@@@@@@@@ + RMPoint TEMPTonyStart; RMPoint TEMPGetTonyStart() { return TEMPTonyStart; diff --git a/engines/tony/sound.h b/engines/tony/sound.h index 73938ecd8c..c859f781f4 100644 --- a/engines/tony/sound.h +++ b/engines/tony/sound.h @@ -49,11 +49,9 @@ enum SoundCodecs { FPCODEC_ADPCM }; -//**************************************************************************** -//* class FPSound -//* ------------- -//* Description: Sound driver For Tony Tough -//**************************************************************************** +/** + * Sound driver For Tony Tough + */ class FPSound { private: diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 9426a37a8b..4ffb84ced8 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -615,6 +615,14 @@ void TonyEngine::grabThumbnail() { _window.grabThumbnail(_curThumbnail); } +uint16 *TonyEngine::getThumbnail() { + return _curThumbnail; +} + +void TonyEngine::quitGame() { + _bQuitNow = true; +} + void TonyEngine::openInitLoadMenu(CORO_PARAM) { _theEngine.openOptionScreen(coroParam, 1); } @@ -776,4 +784,12 @@ void TonyEngine::saveSoundSettings() { ConfMan.setInt("talkspeed", GLOBALS._nCfgTextSpeed * 256 / 10); } +void TonyEngine::showLocation() { + _bDrawLocation = true; +} + +void TonyEngine::hideLocation() { + _bDrawLocation = false; +} + } // End of namespace Tony diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 9a25f2ce35..22090dfe51 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -173,12 +173,8 @@ public: void getDataDirectory(DataDir dir, char *path); - void showLocation() { - _bDrawLocation = true; - } - void hideLocation() { - _bDrawLocation = false; - } + void showLocation(); + void hideLocation(); /** * Reads the time @@ -226,13 +222,9 @@ public: * Get a thumbnail */ void grabThumbnail(); - uint16 *getThumbnail() { - return _curThumbnail; - } + uint16 *getThumbnail(); - void quitGame() { - _bQuitNow = true; - } + void quitGame(); void openInitLoadMenu(CORO_PARAM); void openInitOptions(CORO_PARAM); diff --git a/engines/tony/tonychar.cpp b/engines/tony/tonychar.cpp index c80203fae2..c7fa1e4a7b 100644 --- a/engines/tony/tonychar.cpp +++ b/engines/tony/tonychar.cpp @@ -1892,4 +1892,54 @@ void RMTony::endStatic(CORO_PARAM, CharacterTalkType nTalk) { CORO_END_CODE; } +/** + * Waits until the end of a pattern + */ +void RMTony::waitForEndPattern(CORO_PARAM, uint32 hCustomSkip) { + RMCharacter::waitForEndPattern(coroParam, hCustomSkip); +} + +/** + * Check if currently in an action + */ +bool RMTony::inAction() { + return (_bActionPending && _action != 0) | _bAction; +} + +/** + * Check if there needs to be an update for scrolling movement + */ +bool RMTony::mustUpdateScrolling() { + return ((!inAction()) || (isMoving())); +} + +/** + * Returns Tony's position + */ +RMPoint RMTony::position() { + return _pos; +} + +/** + * Set the scrolling position + */ +void RMTony::setScrollPosition(const RMPoint &pt) { + RMCharacter::setScrollPosition(pt); +} + +/** + * Tony disguises himself! + */ +void RMTony::setShepherdess(bool bIsPast) { + _bShepherdess = bIsPast; +} + +int RMTony::getShepherdess() { + return _bShepherdess; +} + +void RMTony::playSfx(int nSfx) { + RMItem::playSfx(nSfx); +} + } // End of namespace Tony diff --git a/engines/tony/tonychar.h b/engines/tony/tonychar.h index 775c27a4e0..d9f18f61ec 100644 --- a/engines/tony/tonychar.h +++ b/engines/tony/tonychar.h @@ -416,37 +416,27 @@ public: /** * Waits until the end of a pattern */ - void waitForEndPattern(CORO_PARAM, uint32 hCustomSkip = CORO_INVALID_PID_VALUE) { - RMCharacter::waitForEndPattern(coroParam, hCustomSkip); - } + void waitForEndPattern(CORO_PARAM, uint32 hCustomSkip = CORO_INVALID_PID_VALUE); /** * Check if currently in an action */ - bool inAction() { - return (_bActionPending && _action != 0) | _bAction; - } + bool inAction(); /** * Check if there needs to be an update for scrolling movement */ - bool mustUpdateScrolling() { - return ((!inAction()) || (isMoving())); - } + bool mustUpdateScrolling(); /** * Returns Tony's position */ - RMPoint position() { - return _pos; - } + RMPoint position(); /** * Set the scrolling position */ - void setScrollPosition(const RMPoint &pt) { - RMCharacter::setScrollPosition(pt); - } + void setScrollPosition(const RMPoint &pt); /** * Set the take animation @@ -475,21 +465,16 @@ public: /** * Tony disguises himself! */ - void setShepherdess(bool bIsPast) { - _bShepherdess = bIsPast; - } - int getShepherdess() { - return _bShepherdess; - } + void setShepherdess(bool bIsPast); + + int getShepherdess(); /** * Perform an action */ void executeAction(int nAction, int nActionItem, int nParm); - void playSfx(int nSfx) { - RMItem::playSfx(nSfx); - } + void playSfx(int nSfx); }; } // End of namespace Tony -- cgit v1.2.3 From 3ab8ebc4f72e54a5ffcabaa22d3cf8e250062457 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 1 Sep 2012 02:27:31 +0200 Subject: TONY: Move some more code from .h to .cpp files --- engines/tony/gfxcore.cpp | 136 ++++++++++++++++++++++++++++++++++++++++ engines/tony/gfxcore.h | 136 +++++++--------------------------------- engines/tony/globals.h | 4 +- engines/tony/input.cpp | 34 ++++++++++ engines/tony/input.h | 28 +++------ engines/tony/mpal/memory.h | 14 ++--- engines/tony/mpal/mpalutils.cpp | 4 ++ engines/tony/mpal/mpalutils.h | 6 +- engines/tony/window.cpp | 4 ++ engines/tony/window.h | 2 +- 10 files changed, 221 insertions(+), 147 deletions(-) (limited to 'engines') diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 53f64aad12..38d8d0046d 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -111,6 +111,15 @@ RMGfxBuffer::RMGfxBuffer(int dimx, int dimy, int nBpp) { create(dimx, dimy, nBpp); } +int RMGfxBuffer::getDimx() { + return _dimx; +} + +int RMGfxBuffer::getDimy() { + return _dimy; +} + + /****************************************************************************\ * RMGfxSourceBuffer Methods \****************************************************************************/ @@ -2031,4 +2040,131 @@ void RMGfxClearTask::removeThis(CORO_PARAM, bool &result) { result = true; } +/****************************************************************************\ +* RMGfxPrimitive Methods +\****************************************************************************/ + +RMGfxPrimitive::RMGfxPrimitive() { + _bFlag = 0; + _task = NULL; + _src.setEmpty(); + _dst.setEmpty(); + _bStretch = false; +} + +RMGfxPrimitive::RMGfxPrimitive(RMGfxTask *task) { + _task = task; + _bFlag = 0; + _bStretch = false; +} + +RMGfxPrimitive::RMGfxPrimitive(RMGfxTask *task, const RMRect &src, RMRect &dst) { + _task = task; + _src = src; + _dst = dst; + _bFlag = 0; + _bStretch = (src.width() != dst.width() || src.height() != dst.height()); +} + +RMGfxPrimitive::RMGfxPrimitive(RMGfxTask *task, const RMPoint &src, RMRect &dst) { + _task = task; + _src.topLeft() = src; + _dst = dst; + _bFlag = 0; + _bStretch = false; +} + +RMGfxPrimitive::RMGfxPrimitive(RMGfxTask *task, const RMPoint &src, RMPoint &dst) { + _task = task; + _src.topLeft() = src; + _dst.topLeft() = dst; + _bFlag = 0; + _bStretch = false; +} + +RMGfxPrimitive::RMGfxPrimitive(RMGfxTask *task, const RMRect &src, RMPoint &dst) { + _task = task; + _src = src; + _dst.topLeft() = dst; + _bFlag = 0; + _bStretch = false; +} + +RMGfxPrimitive::RMGfxPrimitive(RMGfxTask *task, const RMRect &dst) { + _task = task; + _dst = dst; + _src.setEmpty(); + _bFlag = 0; + _bStretch = false; +} + +RMGfxPrimitive::RMGfxPrimitive(RMGfxTask *task, const RMPoint &dst) { + _task = task; + _dst.topLeft() = dst; + _src.setEmpty(); + _bFlag = 0; + _bStretch = false; +} + +RMGfxPrimitive::~RMGfxPrimitive() { +} + +void RMGfxPrimitive::setFlag(byte bFlag) { + _bFlag = bFlag; +} + +void RMGfxPrimitive::setTask(RMGfxTask *task) { + _task = task; +} + +void RMGfxPrimitive::setSrc(const RMRect &src) { + _src = src; +} + +void RMGfxPrimitive::setSrc(const RMPoint &src) { + _src.topLeft() = src; +} + +void RMGfxPrimitive::setDst(const RMRect &dst) { + _dst = dst; +} + +void RMGfxPrimitive::setDst(const RMPoint &dst) { + _dst.topLeft() = dst; +} + +void RMGfxPrimitive::setStretch(bool bStretch) { + _bStretch = bStretch; +} + +bool RMGfxPrimitive::haveDst() { + return !_dst.isEmpty(); +} + +RMRect &RMGfxPrimitive::getDst() { + return _dst; +} + +bool RMGfxPrimitive::haveSrc() { + return !_src.isEmpty(); +} + +RMRect &RMGfxPrimitive::getSrc() { + return _src; +} + +/** + * Flags + */ +bool RMGfxPrimitive::isFlipped() { + return _bFlag & 1; +} + +/** + * Duplicate + */ +RMGfxPrimitive *RMGfxPrimitive::duplicate() { + return new RMGfxPrimitive(*this); +} + } // End of namespace Tony diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index 472a4ad13a..4750e42d00 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -68,12 +68,8 @@ public: virtual ~RMGfxBuffer(); // Attributes - int getDimx() { - return _dimx; - } - int getDimy() { - return _dimy; - } + int getDimx(); + int getDimy(); // Creation virtual void create(int dimx, int dimy, int nBpp); @@ -102,116 +98,32 @@ protected: byte _bFlag; public: - RMGfxPrimitive() { - _bFlag = 0; - _task = NULL; - _src.setEmpty(); - _dst.setEmpty(); - _bStretch = false; - } - - RMGfxPrimitive(RMGfxTask *task) { - _task = task; - _bFlag = 0; - _bStretch = false; - } - - RMGfxPrimitive(RMGfxTask *task, const RMRect &src, RMRect &dst) { - _task = task; - _src = src; - _dst = dst; - _bFlag = 0; - _bStretch = (src.width() != dst.width() || src.height() != dst.height()); - } - - RMGfxPrimitive(RMGfxTask *task, const RMPoint &src, RMRect &dst) { - _task = task; - _src.topLeft() = src; - _dst = dst; - _bFlag = 0; - _bStretch = false; - } - - RMGfxPrimitive(RMGfxTask *task, const RMPoint &src, RMPoint &dst) { - _task = task; - _src.topLeft() = src; - _dst.topLeft() = dst; - _bFlag = 0; - _bStretch = false; - } - - RMGfxPrimitive(RMGfxTask *task, const RMRect &src, RMPoint &dst) { - _task = task; - _src = src; - _dst.topLeft() = dst; - _bFlag = 0; - _bStretch = false; - } - - RMGfxPrimitive(RMGfxTask *task, const RMRect &dst) { - _task = task; - _dst = dst; - _src.setEmpty(); - _bFlag = 0; - _bStretch = false; - } - - RMGfxPrimitive(RMGfxTask *task, const RMPoint &dst) { - _task = task; - _dst.topLeft() = dst; - _src.setEmpty(); - _bFlag = 0; - _bStretch = false; - } - - virtual ~RMGfxPrimitive() { } - - void setFlag(byte bFlag) { - _bFlag = bFlag; - } - void setTask(RMGfxTask *task) { - _task = task; - } - void setSrc(const RMRect &src) { - _src = src; - } - void setSrc(const RMPoint &src) { - _src.topLeft() = src; - } - void setDst(const RMRect &dst) { - _dst = dst; - } - void setDst(const RMPoint &dst) { - _dst.topLeft() = dst; - } - void setStretch(bool bStretch) { - _bStretch = bStretch; - } - - bool haveDst() { - return !_dst.isEmpty(); - } - - RMRect &getDst() { - return _dst; - } - - bool haveSrc() { - return !_src.isEmpty(); - } - RMRect &getSrc() { - return _src; - } + RMGfxPrimitive(); + RMGfxPrimitive(RMGfxTask *task); + RMGfxPrimitive(RMGfxTask *task, const RMRect &src, RMRect &dst); + RMGfxPrimitive(RMGfxTask *task, const RMPoint &src, RMRect &dst); + RMGfxPrimitive(RMGfxTask *task, const RMPoint &src, RMPoint &dst); + RMGfxPrimitive(RMGfxTask *task, const RMRect &src, RMPoint &dst); + RMGfxPrimitive(RMGfxTask *task, const RMRect &dst); + RMGfxPrimitive(RMGfxTask *task, const RMPoint &dst); + virtual ~RMGfxPrimitive(); + void setFlag(byte bFlag); + void setTask(RMGfxTask *task); + void setSrc(const RMRect &src); + void setSrc(const RMPoint &src); + void setDst(const RMRect &dst); + void setDst(const RMPoint &dst); + void setStretch(bool bStretch); + bool haveDst(); + RMRect &getDst(); + bool haveSrc(); + RMRect &getSrc(); // Flags - bool isFlipped() { - return _bFlag & 1; - } + bool isFlipped(); // Duplicate - virtual RMGfxPrimitive *duplicate() { - return new RMGfxPrimitive(*this); - } + virtual RMGfxPrimitive *duplicate(); }; diff --git a/engines/tony/globals.h b/engines/tony/globals.h index eda99eeee2..75f7f8d1dd 100644 --- a/engines/tony/globals.h +++ b/engines/tony/globals.h @@ -148,12 +148,10 @@ struct ChangedHotspotStruct { */ typedef struct { int _nCf; - int _arg1, _arg2, _arg3, _arg4; } CfCall; -typedef CfCall *LpCfCall; -typedef LpCfCall *LPLPCFCALL; +typedef CfCall *LpCfCall; struct CoroutineMutex { CoroutineMutex() : _eventId(0), _ownerPid(0), _lockCount(0) { } diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp index 88bc3f4092..b96ccaf842 100644 --- a/engines/tony/input.cpp +++ b/engines/tony/input.cpp @@ -120,4 +120,38 @@ bool RMInput::getAsyncKeyState(Common::KeyCode kc) { return result; } +/** + * Reading of the mouse + */ +RMPoint RMInput::mousePos() { + return _mousePos; +} + +/** + * Events of mouse clicks + */ +bool RMInput::mouseLeftClicked() { + return _leftClickMouse; +} + +bool RMInput::mouseRightClicked() { + return _rightClickMouse; +} + +bool RMInput::mouseBothClicked() { + return _leftClickMouse && _rightClickMouse; +} + +bool RMInput::mouseLeftReleased() { + return _leftReleaseMouse; +} + +bool RMInput::mouseRightReleased() { + return _rightReleaseMouse; +} + +bool RMInput::mouseBothReleased() { + return _leftReleaseMouse && _rightReleaseMouse; +} + } // End of namespace Tony diff --git a/engines/tony/input.h b/engines/tony/input.h index 55b067ec43..d07eaefe34 100644 --- a/engines/tony/input.h +++ b/engines/tony/input.h @@ -59,9 +59,7 @@ public: /** * Reading of the mouse */ - RMPoint mousePos() { - return _mousePos; - } + RMPoint mousePos(); /** * Current status of the mouse buttons @@ -72,24 +70,12 @@ public: /** * Events of mouse clicks */ - bool mouseLeftClicked() { - return _leftClickMouse; - } - bool mouseRightClicked() { - return _rightClickMouse; - } - bool mouseBothClicked() { - return _leftClickMouse && _rightClickMouse; - } - bool mouseLeftReleased() { - return _leftReleaseMouse; - } - bool mouseRightReleased() { - return _rightReleaseMouse; - } - bool mouseBothReleased() { - return _leftReleaseMouse && _rightReleaseMouse; - } + bool mouseLeftClicked(); + bool mouseRightClicked(); + bool mouseBothClicked(); + bool mouseLeftReleased(); + bool mouseRightReleased(); + bool mouseBothReleased(); /** * Returns true if the given key is pressed diff --git a/engines/tony/mpal/memory.h b/engines/tony/mpal/memory.h index b557743512..ba7865938f 100644 --- a/engines/tony/mpal/memory.h +++ b/engines/tony/mpal/memory.h @@ -57,13 +57,13 @@ public: }; // defines -#define globalAlloc(flags, size) MemoryManager::alloc(size, flags) -#define globalAllocate(flags, size) MemoryManager::allocate(size, flags) -#define globalFree(handle) MemoryManager::freeBlock(handle) -#define globalDestroy(handle) MemoryManager::destroyItem(handle) -#define globalLock(handle) MemoryManager::lockItem(handle) -#define globalUnlock(handle) MemoryManager::unlockItem(handle) -#define globalSize(handle) MemoryManager::getSize(handle) +#define globalAlloc(flags, size) MemoryManager::alloc(size, flags) +#define globalAllocate(flags, size) MemoryManager::allocate(size, flags) +#define globalFree(handle) MemoryManager::freeBlock(handle) +#define globalDestroy(handle) MemoryManager::destroyItem(handle) +#define globalLock(handle) MemoryManager::lockItem(handle) +#define globalUnlock(handle) MemoryManager::unlockItem(handle) +#define globalSize(handle) MemoryManager::getSize(handle) #define GMEM_FIXED 1 #define GMEM_MOVEABLE 2 diff --git a/engines/tony/mpal/mpalutils.cpp b/engines/tony/mpal/mpalutils.cpp index bfc97a5f3d..92d4af37fc 100644 --- a/engines/tony/mpal/mpalutils.cpp +++ b/engines/tony/mpal/mpalutils.cpp @@ -80,6 +80,10 @@ Common::SeekableReadStream *RMRes::getReadStream() { return new Common::MemoryReadStream(_buf, size()); } +bool RMRes::isValid() { + return _h != NULL; +} + /****************************************************************************\ * RMResRaw methods \****************************************************************************/ diff --git a/engines/tony/mpal/mpalutils.h b/engines/tony/mpal/mpalutils.h index 8bc3e1d7c6..629e157e29 100644 --- a/engines/tony/mpal/mpalutils.h +++ b/engines/tony/mpal/mpalutils.h @@ -47,7 +47,7 @@ public: // Attributes unsigned int size(); const byte *dataPointer(); - bool isValid() { return _h != NULL; } + bool isValid(); // Casting for access to data operator const byte*(); @@ -63,8 +63,8 @@ public: const byte *dataPointer(); operator const byte*(); - int width(); - int height(); + int width(); + int height(); }; } // end of namespace MPAL diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index 0746b267bd..013be84b4b 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -255,6 +255,10 @@ void RMWindow::plotLines(const byte *lpBuf, const Common::Point ¢er, int x, } } +void RMWindow::showDirtyRects(bool v) { + _showDirtyRects = v; +} + /****************************************************************************\ * RMSnapshot Methods \****************************************************************************/ diff --git a/engines/tony/window.h b/engines/tony/window.h index c4cbcb6643..b2732a3f0c 100644 --- a/engines/tony/window.h +++ b/engines/tony/window.h @@ -90,7 +90,7 @@ public: */ void grabThumbnail(uint16 *buf); - void showDirtyRects(bool v) { _showDirtyRects = v; } + void showDirtyRects(bool v); }; } // End of namespace Tony -- cgit v1.2.3 From 1f41e5573175fb712e829a9c72b3e4f75afa8fdf Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 1 Sep 2012 02:36:54 +0200 Subject: TONY: Remove adv.h --- engines/tony/adv.h | 72 ------------------------------------------------- engines/tony/custom.cpp | 1 - engines/tony/game.h | 33 ++++++++++++++++++++++- engines/tony/globals.h | 1 - engines/tony/loc.cpp | 2 +- engines/tony/window.h | 2 +- 6 files changed, 34 insertions(+), 77 deletions(-) delete mode 100644 engines/tony/adv.h (limited to 'engines') diff --git a/engines/tony/adv.h b/engines/tony/adv.h deleted file mode 100644 index e3171aa3ee..0000000000 --- a/engines/tony/adv.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 code is based on original Tony Tough source code - * - * Copyright (c) 1997-2003 Nayma Software - */ - -#ifndef TONY_ADV_H -#define TONY_ADV_H - -#include "common/coroutines.h" -#include "tony/mpal/memory.h" -#include "tony/gfxcore.h" - - -namespace Tony { - -// X & Y dimensions of the adventure -#define RM_SX 640 -#define RM_SY 480 - -// X & Y dimensions of bigbuf -#define RM_BBX (RM_SX) -#define RM_BBY (RM_SY) - -// Skipping X & Y -#define RM_SKIPY ((RM_BBY - RM_SY) / 2) -#define RM_SKIPX 0 - -// Tony's actions -enum RMTonyAction { - TA_GOTO = 0, - TA_TAKE, - TA_USE, - TA_EXAMINE, - TA_TALK, - TA_PERORATE, - - TA_COMBINE = 10, - TA_RECEIVECOMBINE, - TA_COMBINEGIVE, - TA_RECEIVECOMBINEGIVE -}; - -// Global Functions -void mainEnableGUI(); -void mainDisableGUI(); - -} // End of namespace Tony - -#endif diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 4171691e87..f0a9197c6d 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -31,7 +31,6 @@ #include "common/savefile.h" #include "tony/mpal/mpal.h" #include "tony/mpal/memory.h" -#include "tony/adv.h" #include "tony/custom.h" #include "tony/font.h" #include "tony/game.h" diff --git a/engines/tony/game.h b/engines/tony/game.h index bb6a356f0a..1c955176bf 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -29,7 +29,6 @@ #ifndef TONY_GAME_H #define TONY_GAME_H -#include "tony/adv.h" #include "tony/gfxcore.h" #include "tony/input.h" #include "tony/loc.h" @@ -53,6 +52,38 @@ namespace Tony { (buf8)->init(*raw, raw->width(), raw->height(), true); \ delete raw; +// X & Y dimensions of the adventure +#define RM_SX 640 +#define RM_SY 480 + +// X & Y dimensions of bigbuf +#define RM_BBX (RM_SX) +#define RM_BBY (RM_SY) + +// Skipping X & Y +#define RM_SKIPY ((RM_BBY - RM_SY) / 2) +#define RM_SKIPX 0 + +// Tony's actions +enum RMTonyAction { + TA_GOTO = 0, + TA_TAKE, + TA_USE, + TA_EXAMINE, + TA_TALK, + TA_PERORATE, + + TA_COMBINE = 10, + TA_RECEIVECOMBINE, + TA_COMBINEGIVE, + TA_RECEIVECOMBINEGIVE +}; + +// Global Functions +void mainEnableGUI(); +void mainDisableGUI(); + +// Classes class RMPointer { public: enum PointerType { diff --git a/engines/tony/globals.h b/engines/tony/globals.h index 75f7f8d1dd..d8d8d3eba5 100644 --- a/engines/tony/globals.h +++ b/engines/tony/globals.h @@ -24,7 +24,6 @@ #define TONY_GLOBALS #include "common/savefile.h" -#include "tony/adv.h" #include "tony/gfxengine.h" #include "tony/input.h" #include "tony/inventory.h" diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index a92282cc3f..7a151ac292 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -29,7 +29,7 @@ #include "common/memstream.h" #include "common/scummsys.h" #include "tony/mpal/mpalutils.h" -#include "tony/adv.h" +#include "tony/game.h" #include "tony/loc.h" #include "tony/tony.h" diff --git a/engines/tony/window.h b/engines/tony/window.h index b2732a3f0c..2e8769707f 100644 --- a/engines/tony/window.h +++ b/engines/tony/window.h @@ -31,7 +31,7 @@ #include "common/scummsys.h" #include "common/rect.h" -#include "tony/adv.h" +#include "tony/game.h" namespace Tony { -- cgit v1.2.3 From c737e6429866f18638a6b61103e4e1c7095407e6 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 2 Sep 2012 10:34:11 +0200 Subject: TONY: Move code from .h to .cpp files --- engines/tony/font.cpp | 44 +++++++++++++++++++++-- engines/tony/font.h | 31 ++++------------ engines/tony/game.cpp | 12 +++++++ engines/tony/game.h | 12 ++----- engines/tony/gfxcore.cpp | 44 ++++++++++++++++++++++- engines/tony/gfxcore.h | 38 +++++--------------- engines/tony/inventory.cpp | 15 ++++++++ engines/tony/inventory.h | 15 ++------ engines/tony/loc.cpp | 89 ++++++++++++++++++++++++++++++++++++++++++++++ engines/tony/loc.h | 77 +++++++++++---------------------------- engines/tony/utils.cpp | 30 ++++++++++++++++ engines/tony/utils.h | 17 ++++----- 12 files changed, 279 insertions(+), 145 deletions(-) (limited to 'engines') diff --git a/engines/tony/font.cpp b/engines/tony/font.cpp index 901a41b7c4..927adf9006 100644 --- a/engines/tony/font.cpp +++ b/engines/tony/font.cpp @@ -188,6 +188,17 @@ void RMFontColor::setBaseColor(byte r1, byte g1, byte b1) { _letter[i].loadPaletteWA(pal); } +/***************************************************************************\ +* RMFontWithTables Methods +\****************************************************************************/ +int RMFontWithTables::convertToLetter(byte nChar) { + return _cTable[nChar]; +} + +int RMFontWithTables::letterLength(int nChar, int nNext) { + return (nChar != -1 ? _lTable[(byte)nChar] + _l2Table[(byte)nChar][(byte)nNext] : _lDefault); +} + /***************************************************************************\ * RMFontDialog Methods \****************************************************************************/ @@ -359,7 +370,6 @@ RMText::RMText() { } RMText::~RMText() { - } void RMText::unload() { @@ -571,6 +581,23 @@ void RMText::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_END_CODE; } +/** + * Set the alignment type + */ +void RMText::setAlignType(HorAlign aHor, VerAlign aVer) { + _aHorType = aHor; + _aVerType = aVer; +} + +/** + * Set the base color + */ +void RMText::setColor(byte r, byte g, byte b) { + _textR = r; + _textG = g; + _textB = b; +} + /****************************************************************************\ * RMTextDialog Methods \****************************************************************************/ @@ -751,6 +778,13 @@ void RMTextDialog::setInput(RMInput *input) { _input = input; } +/** + * Set the position + */ +void RMTextDialog::setPosition(const RMPoint &pt) { + _dst = pt; +} + /****************************************************************************\ * RMTextDialogScrolling Methods \****************************************************************************/ @@ -801,7 +835,6 @@ RMTextItemName::RMTextItemName() : RMText() { } RMTextItemName::~RMTextItemName() { - } void RMTextItemName::doFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation &loc, RMPointer &ptr, RMInventory &inv) { @@ -886,6 +919,13 @@ bool RMTextItemName::isItemSelected() { return _item != NULL; } +void RMTextItemName::setMouseCoord(const RMPoint &m) { + _mpos = m; +} + +void RMTextItemName::removeThis(CORO_PARAM, bool &result) { + result = true; +} /****************************************************************************\ * RMDialogChoice Methods diff --git a/engines/tony/font.h b/engines/tony/font.h index 97434b9770..99b20571b1 100644 --- a/engines/tony/font.h +++ b/engines/tony/font.h @@ -126,12 +126,8 @@ protected: protected: // Overloaded methods - int convertToLetter(byte nChar) { - return _cTable[nChar]; - } - int letterLength(int nChar, int nNext = 0) { - return (nChar != -1 ? _lTable[(byte)nChar] + _l2Table[(byte)nChar][(byte)nNext] : _lDefault); - } + int convertToLetter(byte nChar); + int letterLength(int nChar, int nNext = 0); public: int letterHeight() { @@ -206,10 +202,7 @@ public: static void unload(); // Set the alignment type - void setAlignType(HorAlign aHor, VerAlign aVer) { - _aHorType = aHor; - _aVerType = aVer; - } + void setAlignType(HorAlign aHor, VerAlign aVer); // Sets the maximum length of a line in pixels (used to format the text) void setMaxLineLength(int max); @@ -225,11 +218,7 @@ public: virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Set the base color - void setColor(byte r, byte g, byte b) { - _textR = r; - _textG = g; - _textB = b; - } + void setColor(byte r, byte g, byte b); }; /** @@ -269,9 +258,7 @@ public: virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Set the position - void setPosition(const RMPoint &pt) { - _dst = pt; - } + void setPosition(const RMPoint &pt); // Waiting void waitForEndDisplay(CORO_PARAM); @@ -320,9 +307,7 @@ public: RMTextItemName(); virtual ~RMTextItemName(); - void setMouseCoord(const RMPoint &m) { - _mpos = m; - } + void setMouseCoord(const RMPoint &m); void doFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation &loc, RMPointer &ptr, RMInventory &inv); virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); @@ -331,9 +316,7 @@ public: RMItem *getSelectedItem(); bool isItemSelected(); - virtual void removeThis(CORO_PARAM, bool &result) { - result = true; - } + virtual void removeThis(CORO_PARAM, bool &result); }; diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 3abc7a20f8..2bcfdc7fc2 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -128,6 +128,14 @@ void RMOptionButton::addToList(RMGfxTargetBuffer &bigBuf) { bigBuf.addPrim(new RMGfxPrimitive(this, _rect)); } +bool RMOptionButton::isActive() { + return _bActive; +} + +void RMOptionButton::setActiveState(bool bState) { + _bActive = bState; +} + /****************************************************************************\ * RMOptionSlide Methods \****************************************************************************/ @@ -253,6 +261,10 @@ void RMOptionSlide::addToList(RMGfxTargetBuffer &bigBuf) { bigBuf.addPrim(new RMGfxPrimitive(this)); } +int RMOptionSlide::getValue() { + return _nValue; +} + /****************************************************************************\ * RMOptionScreen Methods \****************************************************************************/ diff --git a/engines/tony/game.h b/engines/tony/game.h index 1c955176bf..83a1ddaea1 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -189,12 +189,8 @@ public: bool doFrame(const RMPoint &mousePos, bool bLeftClick, bool bRightClick); virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); void addToList(RMGfxTargetBuffer &bigBuf); - bool isActive() { - return _bActive; - } - void setActiveState(bool bState) { - _bActive = bState; - } + bool isActive(); + void setActiveState(bool bState); }; class RMOptionSlide : public RMGfxTaskSetPrior { @@ -219,9 +215,7 @@ public: virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); void addToList(RMGfxTargetBuffer &bigBuf); - int getValue() { - return _nValue; - } + int getValue(); }; class RMOptionScreen : public RMGfxWoodyBuffer { diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 38d8d0046d..71bf31396c 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -49,6 +49,17 @@ void RMGfxTask::removeThis(CORO_PARAM, bool &result) { result = true; } +/** + * Registration + */ +void RMGfxTask::Register() { + _nInList++; +} + +void RMGfxTask::Unregister() { + _nInList--; + assert(_nInList >= 0); +} /****************************************************************************\ * RMGfxTaskSetPrior Methods @@ -192,7 +203,6 @@ bool RMGfxSourceBuffer::clip2D(int &x1, int &y1, int &u, int &v, int &width, int return (width > 1 && height > 1); } - /** * Initializes a surface by resource Id * @@ -204,6 +214,10 @@ int RMGfxSourceBuffer::init(uint32 resID, int dimx, int dimy, bool bLoadPalette) return init(RMRes(resID), dimx, dimy, bLoadPalette); } +void RMGfxSourceBuffer::offsetY(int nLines) { + RMGfxBuffer::offsetY(nLines, getBpp()); +} + /****************************************************************************\ * RMGfxWoodyBuffer Methods \****************************************************************************/ @@ -440,6 +454,34 @@ void RMGfxTargetBuffer::freeBWPrecalcTable() { _precalcTable = NULL; } +RMGfxTargetBuffer::operator byte *() { + return _buf; +} + +RMGfxTargetBuffer::operator void *() { + return (void *)_buf; +} + +RMGfxTargetBuffer::operator uint16 *() { + // FIXME: This may not be endian safe + return (uint16 *)_buf; +} + +/** + * Offseting buffer + */ +void RMGfxTargetBuffer::offsetY(int nLines) { + RMGfxBuffer::offsetY(nLines, 16); +} + +void RMGfxTargetBuffer::setTrackDirtyRects(bool v) { + _trackDirtyRects = v; +} + +bool RMGfxTargetBuffer::getTrackDirtyRects() const { + return _trackDirtyRects; +} + /****************************************************************************\ * RMGfxSourceBufferPal Methods \****************************************************************************/ diff --git a/engines/tony/gfxcore.h b/engines/tony/gfxcore.h index 4750e42d00..ac4eee05e4 100644 --- a/engines/tony/gfxcore.h +++ b/engines/tony/gfxcore.h @@ -145,13 +145,8 @@ public: virtual void removeThis(CORO_PARAM, bool &result); // Registration - virtual void Register() { - _nInList++; - } - virtual void Unregister() { - _nInList--; - assert(_nInList >= 0); - } + virtual void Register(); + virtual void Unregister(); }; @@ -209,9 +204,7 @@ public: protected: virtual void prepareImage(); bool clip2D(int &x1, int &y1, int &u, int &v, int &width, int &height, bool bUseSrc, RMGfxTargetBuffer *buf); - void offsetY(int nLines) { - RMGfxBuffer::offsetY(nLines, getBpp()); - } + void offsetY(int nLines); public: virtual int getBpp() = 0; @@ -490,32 +483,19 @@ public: void drawOT(CORO_PARAM); void addPrim(RMGfxPrimitive *prim); // The pointer must be delted - operator byte *() { - return _buf; - } - operator void *() { - return (void *)_buf; - } - operator uint16 *() { - // FIXME: This may not be endian safe - return (uint16 *)_buf; - } + operator byte *(); + operator void *(); + operator uint16 *(); // Offseting buffer - void offsetY(int nLines) { - RMGfxBuffer::offsetY(nLines, 16); - } + void offsetY(int nLines); // Dirty rect methods void addDirtyRect(const Common::Rect &r); Common::List &getDirtyRects(); void clearDirtyRects(); - void setTrackDirtyRects(bool v) { - _trackDirtyRects = v; - } - bool getTrackDirtyRects() const { - return _trackDirtyRects; - } + void setTrackDirtyRects(bool v); + bool getTrackDirtyRects() const; }; diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index 647e4264c7..81d62a035c 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -736,6 +736,21 @@ int RMInventory::loadState(byte *state) { return getSaveStateSize(); } +RMInventory &RMInventory::operator+=(RMItem *item) { + addItem(item->mpalCode()); + return *this; +} + +RMInventory &RMInventory::operator+=(RMItem &item) { + addItem(item.mpalCode()); + return *this; +} + +RMInventory &RMInventory::operator+=(int code) { + addItem(code); + return *this; +} + /****************************************************************************\ * RMInterface methods \****************************************************************************/ diff --git a/engines/tony/inventory.h b/engines/tony/inventory.h index a5b37748c3..ce94c86c1b 100644 --- a/engines/tony/inventory.h +++ b/engines/tony/inventory.h @@ -146,18 +146,9 @@ public: * Add an item to the inventory */ void addItem(int code); - RMInventory &operator+=(RMItem *item) { - addItem(item->mpalCode()); - return *this; - } - RMInventory &operator+=(RMItem &item) { - addItem(item.mpalCode()); - return *this; - } - RMInventory &operator+=(int code) { - addItem(code); - return *this; - } + RMInventory &operator+=(RMItem *item); + RMInventory &operator+=(RMItem &item); + RMInventory &operator+=(int code); /** * Removes an item diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 7a151ac292..4fe19594f9 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -255,6 +255,13 @@ RMPattern::RMPattern() { _slots = NULL; } +/** + * Reads the position of the pattern + */ +RMPoint RMPattern::pos() { + return _curPos; +} + RMPattern::~RMPattern() { if (_slots != NULL) { delete[] _slots; @@ -400,6 +407,10 @@ void RMSfx::stop() { * RMItem Methods \****************************************************************************/ +int RMItem::getCurPattern() { + return _nCurPattern; +} + RMGfxSourceBuffer *RMItem::newItemSpriteBuffer(int dimx, int dimy, bool bPreRLE) { if (_cm == CM_256) { RMGfxSourceBuffer8RLE *spr; @@ -627,6 +638,19 @@ void RMItem::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { CORO_END_CODE; } +/** + * Overloaded priority: it's based on Z ordering + */ +int RMItem::priority() { + return _z; +} + +/** + * Pattern number + */ +int RMItem::numPattern() { + return _nPatterns; +} void RMItem::removeThis(CORO_PARAM, bool &result) { // Remove from the OT list if the current frame is -1 (pattern over) @@ -638,6 +662,14 @@ void RMItem::setStatus(int nStatus) { _bIsActive = (nStatus > 0); } +RMPoint RMItem::hotspot() { + return _hot; +} + +int RMItem::mpalCode() { + return _mpalCode; +} + void RMItem::setPattern(int nPattern, bool bPlayP0) { assert(nPattern >= 0 && nPattern <= _nPatterns); @@ -747,6 +779,10 @@ void RMItem::changeHotspot(const RMPoint &pt) { _hot = pt; } +void RMItem::setInitCurPattern(bool status) { + _bInitCurPattern = status; +} + void RMItem::playSfx(int nSfx) { if (nSfx < _nSfx) _sfx[nSfx].play(); @@ -1429,6 +1465,10 @@ void RMCharacter::doFrame(CORO_PARAM, RMGfxTargetBuffer *bigBuf, int loc) { CORO_END_CODE; } +bool RMCharacter::endOfPath() { + return _bEndOfPath; +} + void RMCharacter::stop(CORO_PARAM) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); @@ -1471,6 +1511,13 @@ void RMCharacter::stop(CORO_PARAM) { CORO_END_CODE; } +/** + * Check if the character is moving + */ +bool RMCharacter::isMoving() { + return _bMoving; +} + inline int RMCharacter::inWhichBox(const RMPoint &pt) { return _theBoxes->whichBox(_curLocation, pt); } @@ -1582,6 +1629,14 @@ void RMCharacter::waitForEndMovement(CORO_PARAM) { CORO_END_CODE; } +void RMCharacter::setFixedScroll(const RMPoint &fix) { + _fixedScroll = fix; +} + +void RMCharacter::setSpeed(int speed) { + _curSpeed = speed; +} + void RMCharacter::removeThis(CORO_PARAM, bool &result) { CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); @@ -1764,6 +1819,10 @@ RMBoxLoc *RMGameBoxes::getBoxes(int nLoc) { return _allBoxes[nLoc]; } +int RMGameBoxes::getLocBoxesCount() const { + return _nLocBoxes; +} + bool RMGameBoxes::isInBox(int nLoc, int nBox, const RMPoint &pt) { RMBoxLoc *cur = getBoxes(nLoc); @@ -1869,6 +1928,14 @@ RMLocation::RMLocation() { _cmode = CM_256; } +RMPoint RMLocation::TEMPGetTonyStart() { + return TEMPTonyStart; +} + +int RMLocation::TEMPGetNumLoc() { + return TEMPNumLoc; +} + /** * Load a location (.LOC) from a given data stream * @@ -2178,6 +2245,12 @@ void RMLocation::pauseSound(bool bPause) { _items[i].pauseSound(bPause); } +/** + * Read the current scroll position + */ +RMPoint RMLocation::scrollPosition() { + return _curScroll; +} /****************************************************************************\ * RMMessage Methods @@ -2230,4 +2303,20 @@ void RMMessage::parseMessage() { } } +bool RMMessage::isValid() { + return _lpMessage != NULL; +} + +int RMMessage::numPeriods() { + return _nPeriods; +} + +char *RMMessage::period(int num) { + return _lpPeriods[num]; +} + +char *RMMessage::operator[](int num) { + return _lpPeriods[num]; +} + } // End of namespace Tony diff --git a/engines/tony/loc.h b/engines/tony/loc.h index 6c28a66f65..61eece2440 100644 --- a/engines/tony/loc.h +++ b/engines/tony/loc.h @@ -152,9 +152,7 @@ public: void stopSfx(RMSfx *sfx); // Reads the position of the pattern - RMPoint pos() { - return _curPos; - } + RMPoint pos(); void readFromStream(Common::ReadStream &ds, bool bLOX = false); @@ -197,16 +195,14 @@ public: protected: int _z; - RMPoint _pos; // Coordinate nonno + RMPoint _pos; // Coordinate ancestor RMColorMode _cm; RMPoint _curScroll; byte _FX; byte _FXparm; - virtual int getCurPattern() { - return _nCurPattern; - } + virtual int getCurPattern(); private: int _nCurPattern; @@ -248,14 +244,10 @@ public: virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // Overloaded priority: it's based on Z ordering - virtual int priority() { - return _z; - } + virtual int priority(); // Pattern number - int numPattern() { - return _nPatterns; - } + int numPattern(); // Set anew animation pattern, changing abruptly from the current virtual void setPattern(int nPattern, bool bPlayP0 = false); @@ -264,13 +256,9 @@ public: void setStatus(int nStatus); bool isIn(const RMPoint &pt, int *size = NULL); - RMPoint hotspot() { - return _hot; - } + RMPoint hotspot(); bool getName(Common::String &name); - int mpalCode() { - return _mpalCode; - } + int mpalCode(); // Unload void unload(); @@ -281,9 +269,7 @@ public: // Sets a new hotspot fro the object void changeHotspot(const RMPoint &pt); - void setInitCurPattern(bool status) { - _bInitCurPattern = status; - } + void setInitCurPattern(bool status); void playSfx(int nSfx); @@ -354,7 +340,7 @@ public: // Get binding boxes for a given location RMBoxLoc *getBoxes(int nLoc); - int getLocBoxesCount() const { return _nLocBoxes; } + int getLocBoxesCount() const; // Return the box which contains a given point int whichBox(int nLoc, const RMPoint &pt); @@ -431,7 +417,6 @@ protected: bool _bMoving; bool _bDrawNow; bool _bNeedToStop; -// virtual RMGfxPrimitive *NewItemPrimitive(); public: RMCharacter(); @@ -448,17 +433,13 @@ public: virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim); // TRUE if you just stopped - bool endOfPath() { - return _bEndOfPath; - } + bool endOfPath(); // Change the pattern of a character to STOP virtual void stop(CORO_PARAM); // Check if the character is moving - bool isMoving() { - return _bMoving; - } + bool isMoving(); // Move the character to a certain position void move(CORO_PARAM, RMPoint pt, bool *result = NULL); @@ -469,12 +450,8 @@ public: // Wait for the end of movement void waitForEndMovement(CORO_PARAM); - void setFixedScroll(const RMPoint &fix) { - _fixedScroll = fix; - } - void setSpeed(int speed) { - _curSpeed = speed; - } + void setFixedScroll(const RMPoint &fix); + void setSpeed(int speed); }; @@ -531,14 +508,10 @@ public: // @@@@@@@@@@@@@@@@@@@@@@@ RMPoint TEMPTonyStart; - RMPoint TEMPGetTonyStart() { - return TEMPTonyStart; - } + RMPoint TEMPGetTonyStart(); int TEMPNumLoc; - int TEMPGetNumLoc() { - return TEMPNumLoc; - } + int TEMPGetNumLoc(); public: RMLocation(); @@ -573,9 +546,7 @@ public: void updateScrolling(const RMPoint &ptShowThis); // Read the current scroll position - RMPoint scrollPosition() { - return _curScroll; - } + RMPoint scrollPosition(); // Pause sound void pauseSound(bool bPause); @@ -600,18 +571,10 @@ public: virtual ~RMMessage(); void load(uint32 dwId); - bool isValid() { - return _lpMessage != NULL; - } - int numPeriods() { - return _nPeriods; - } - char *period(int num) { - return _lpPeriods[num]; - } - char *operator[](int num) { - return _lpPeriods[num]; - } + bool isValid(); + int numPeriods(); + char *period(int num); + char *operator[](int num); }; } // End of namespace Tony diff --git a/engines/tony/utils.cpp b/engines/tony/utils.cpp index 99ba84ab19..3cc09a1454 100644 --- a/engines/tony/utils.cpp +++ b/engines/tony/utils.cpp @@ -86,6 +86,14 @@ RMPoint &RMPoint::operator=(RMPoint p) { return *this; } +/** + * Set a point + */ +void RMPoint::set(int x1, int y1) { + _x = x1; + _y = y1; +} + /** * Offsets the point by another point */ @@ -174,6 +182,9 @@ void RMPoint::readFromStream(Common::ReadStream &ds) { * RMPointReference methods \****************************************************************************/ +RMPointReference::RMPointReference(int &x, int &y): _x(x), _y(y) { +} + RMPointReference &RMPointReference::operator=(const RMPoint &p) { _x = p._x; _y = p._y; return *this; @@ -184,6 +195,10 @@ RMPointReference &RMPointReference::operator-=(const RMPoint &p) { return *this; } +RMPointReference::operator RMPoint() const { + return RMPoint(_x, _y); +} + /****************************************************************************\ * RMRect methods \****************************************************************************/ @@ -233,6 +248,14 @@ void RMRect::copyRect(const RMRect &rc) { _y2 = rc._y2; } +RMPointReference &RMRect::topLeft() { + return _topLeft; +} + +RMPointReference &RMRect::bottomRight() { + return _bottomRight; +} + RMPoint RMRect::center() { return RMPoint((_x2 - _x1) / 2, (_y2 - _y1) / 2); } @@ -328,6 +351,13 @@ void RMRect::readFromStream(Common::ReadStream &ds) { _y2 = ds.readSint32LE(); } +/** + * Check if RMPoint is in RMRect + */ +bool RMRect::ptInRect(const RMPoint &pt) { + return (pt._x >= _x1 && pt._x <= _x2 && pt._y >= _y1 && pt._y <= _y2); +} + /****************************************************************************\ * Resource Update \****************************************************************************/ diff --git a/engines/tony/utils.h b/engines/tony/utils.h index a24e11f2b6..9f13e5f19b 100644 --- a/engines/tony/utils.h +++ b/engines/tony/utils.h @@ -58,10 +58,7 @@ public: RMPoint &operator=(RMPoint p); // Set - void set(int x1, int y1) { - _x = x1; - _y = y1; - } + void set(int x1, int y1); // Offset void offset(int xOff, int yOff); @@ -88,10 +85,10 @@ public: int &_x; int &_y; - RMPointReference(int &x, int &y): _x(x), _y(y) {} + RMPointReference(int &x, int &y); RMPointReference &operator=(const RMPoint &p); RMPointReference &operator-=(const RMPoint &p); - operator RMPoint() const { return RMPoint(_x, _y); } + operator RMPoint() const; }; class RMRect { @@ -108,8 +105,8 @@ public: RMRect(const RMRect &rc); // Attributes - RMPointReference &topLeft() { return _topLeft; } - RMPointReference &bottomRight() { return _bottomRight; } + RMPointReference &topLeft(); + RMPointReference &bottomRight(); RMPoint center(); int width() const; int height() const; @@ -145,9 +142,7 @@ public: void normalizeRect(); // Point in rect - bool ptInRect(const RMPoint &pt) { - return (pt._x >= _x1 && pt._x <= _x2 && pt._y >= _y1 && pt._y <= _y2); - } + bool ptInRect(const RMPoint &pt); // Extract from data stream void readFromStream(Common::ReadStream &ds); -- cgit v1.2.3