diff options
179 files changed, 7049 insertions, 5254 deletions
@@ -29,6 +29,8 @@ For a more comprehensive changelog of the latest experimental code, see:     - Changed "F5 (menu)" gesture to open up the global main menu instead.     - Added support for custom cursor palettes, this makes the moderm theme use       the red pointer cursor for example. +   - Added aspect ratio correction feature. +   - Implemented 16 bits per pixel support for games.   Windows port:     - Changed default savegames location for Windows NT4/2000/XP/Vista/7. diff --git a/audio/mididrv.cpp b/audio/mididrv.cpp index 6817791c6b..0518915e81 100644 --- a/audio/mididrv.cpp +++ b/audio/mididrv.cpp @@ -22,6 +22,7 @@  #include "common/config-manager.h"  #include "common/error.h" +#include "common/gui_options.h"  #include "common/str.h"  #include "common/system.h"  #include "common/textconsole.h" diff --git a/backends/keymapper/keymapper.cpp b/backends/keymapper/keymapper.cpp index aafdd604a2..189f862469 100644 --- a/backends/keymapper/keymapper.cpp +++ b/backends/keymapper/keymapper.cpp @@ -119,7 +119,7 @@ void Keymapper::cleanupGameKeymaps() {  	// the game specific (=deleted) ones.  	Stack<MapRecord> newStack; -	for (int i = 0; i < _activeMaps.size(); i++) { +	for (Stack<MapRecord>::size_type i = 0; i < _activeMaps.size(); i++) {  		if (_activeMaps[i].global)  			newStack.push(_activeMaps[i]);  	} diff --git a/backends/midi/windows.cpp b/backends/midi/windows.cpp index 828411cd22..f4c5431d6e 100644 --- a/backends/midi/windows.cpp +++ b/backends/midi/windows.cpp @@ -177,13 +177,49 @@ MusicDevices WindowsMusicPlugin::getDevices() const {  	int numDevs = midiOutGetNumDevs();  	MIDIOUTCAPS tmp; +	Common::StringArray deviceNames;  	for (int i = 0; i < numDevs; i++) {  		if (midiOutGetDevCaps(i, &tmp, sizeof(MIDIOUTCAPS)) != MMSYSERR_NOERROR)  			break; +		deviceNames.push_back(tmp.szPname); +	} + +	// Check for non-unique device names. This may happen if someone has devices with identical +	// names (e. g. more than one USB device of the exact same hardware type). It seems that this +	// does happen in reality sometimes. We generate index numbers for these devices. +	// This is not an ideal solution, since this index could change whenever another USB +	// device gets plugged in or removed, switched off or just plugged into a different port. +	// Unfortunately midiOutGetDevCaps() does not generate any other unique information +	// that could be used. Our index numbers which match the device order should at least be +	// a little more stable than just using the midiOutGetDevCaps() device ID, since a missing +	// device (e.g. switched off) should actually not be harmful to our indices (as it would be +	// when using the device IDs). The cases where users have devices with identical names should +	// be rare enough anyway. +	Common::Array<int> nonUniqueIndex; +	for (int i = 0; i < numDevs; i++) { +		int match = -1; +		for (int ii = 0; ii < i; ii++) { +			if (deviceNames[i] == deviceNames[ii]) { +				if (nonUniqueIndex[ii] == -1) +					nonUniqueIndex[ii] = 0; +				if (++match == 0) +					++match; +			} +		} +		nonUniqueIndex.push_back(match); +	} + +	// We now add the index number to the non-unique device names to make them unique. +	for (int i = 0; i < numDevs; i++) { +		if (nonUniqueIndex[i] != -1) +			deviceNames[i] = Common::String::format("%s - #%.02d", deviceNames[i].c_str(), nonUniqueIndex[i]); +	} + +	for (Common::StringArray::iterator i = deviceNames.begin(); i != deviceNames.end(); ++i)  		// There is no way to detect the "MusicType" so I just set it to MT_GM  		// The user will have to manually select his MT32 type device and his GM type device. -		devices.push_back(MusicDevice(this, tmp.szPname, MT_GM)); -	} +		devices.push_back(MusicDevice(this, *i, MT_GM)); +  	return devices;  } diff --git a/backends/platform/dc/dc.h b/backends/platform/dc/dc.h index 2e32ff3eb4..8ca48bf19e 100644 --- a/backends/platform/dc/dc.h +++ b/backends/platform/dc/dc.h @@ -29,6 +29,8 @@  #include "backends/audiocd/default/default-audiocd.h"  #include "backends/fs/fs-factory.h"  #include "audio/mixer_intern.h" +#include "common/language.h" +#include "common/platform.h"  #ifdef DYNAMIC_MODULES  #include "backends/plugins/dynamic-plugin.h"  #endif diff --git a/backends/platform/iphone/iphone_common.h b/backends/platform/iphone/iphone_common.h index 5a46a6dde6..19e4f2ce9b 100644 --- a/backends/platform/iphone/iphone_common.h +++ b/backends/platform/iphone/iphone_common.h @@ -23,6 +23,8 @@  #ifndef BACKENDS_PLATFORM_IPHONE_IPHONE_COMMON_H  #define BACKENDS_PLATFORM_IPHONE_IPHONE_COMMON_H +#include "graphics/surface.h" +  enum InputEvent {  	kInputMouseDown,  	kInputMouseUp, @@ -55,21 +57,40 @@ enum GraphicsModes {  	kGraphicsModeNone = 1  }; +struct VideoContext { +	VideoContext() : asprectRatioCorrection(), screenWidth(), screenHeight(), overlayVisible(false), +	                 overlayWidth(), overlayHeight(), mouseX(), mouseY(), +	                 mouseHotspotX(), mouseHotspotY(), mouseWidth(), mouseHeight(), +	                 mouseIsVisible(), graphicsMode(kGraphicsModeLinear), shakeOffsetY() { +	} + +	// Game screen state +	bool asprectRatioCorrection; +	uint screenWidth, screenHeight; +	Graphics::Surface screenTexture; + +	// Overlay state +	bool overlayVisible; +	uint overlayWidth, overlayHeight; +	Graphics::Surface overlayTexture; + +	// Mouse cursor state +	uint mouseX, mouseY; +	int mouseHotspotX, mouseHotspotY; +	uint mouseWidth, mouseHeight; +	bool mouseIsVisible; +	Graphics::Surface mouseTexture; + +	// Misc state +	GraphicsModes graphicsMode; +	int shakeOffsetY; +}; +  // On the ObjC side -void iPhone_setGraphicsMode(GraphicsModes mode); -void iPhone_updateScreen(int mouseX, int mouseY); -void iPhone_updateScreenRect(unsigned short *screen, int x1, int y1, int x2, int y2); -void iPhone_updateOverlayRect(unsigned short *screen, int x1, int y1, int x2, int y2); -void iPhone_initSurface(int width, int height); -void iPhone_setShakeOffset(int offset); +void iPhone_updateScreen();  bool iPhone_fetchEvent(int *outEvent, int *outX, int *outY);  const char *iPhone_getDocumentsDir();  bool iPhone_isHighResDevice(); -int iPhone_getScreenHeight(); -int iPhone_getScreenWidth(); -void iPhone_enableOverlay(int state); -void iPhone_showCursor(int state); -void iPhone_setMouseCursor(unsigned short *buffer, int width, int height, int hotspotX, int hotspotY);  uint getSizeNextPOT(uint size); diff --git a/backends/platform/iphone/iphone_main.mm b/backends/platform/iphone/iphone_main.mm index 1559ef8a6e..20406e6342 100644 --- a/backends/platform/iphone/iphone_main.mm +++ b/backends/platform/iphone/iphone_main.mm @@ -20,6 +20,9 @@   *   */ +// Disable symbol overrides so that we can use system headers. +#define FORBIDDEN_SYMBOL_ALLOW_ALL +  #include <UIKit/UIKit.h>  #include <Foundation/NSThread.h> diff --git a/backends/platform/iphone/iphone_video.h b/backends/platform/iphone/iphone_video.h index 43a643ab4a..55a4acb7c7 100644 --- a/backends/platform/iphone/iphone_video.h +++ b/backends/platform/iphone/iphone_video.h @@ -32,9 +32,11 @@  #include <OpenGLES/ES1/glext.h>  #include "iphone_keyboard.h" +#include "iphone_common.h"  @interface iPhoneView : UIView { -	void *_screenSurface; +	VideoContext _videoContext; +  	NSMutableArray *_events;  	SoftKeyboard *_keyboardView; @@ -47,19 +49,33 @@  	UIDeviceOrientation _orientation; +	GLint _renderBufferWidth; +	GLint _renderBufferHeight; +  	GLfloat _gameScreenVertCoords[4 * 2];  	GLfloat _gameScreenTexCoords[4 * 2]; +	CGRect _gameScreenRect;  	GLfloat _overlayVertCoords[4 * 2];  	GLfloat _overlayTexCoords[4 * 2]; +	CGRect _overlayRect; + +	GLfloat _mouseVertCoords[4 * 2]; +	GLfloat _mouseTexCoords[4 * 2]; +	GLint _mouseHotspotX, _mouseHotspotY; +	GLint _mouseWidth, _mouseHeight; +	GLfloat _mouseScaleX, _mouseScaleY; + +	int _scaledShakeOffsetY;  }  - (id)initWithFrame:(struct CGRect)frame; -- (void)drawRect:(CGRect)frame; +- (VideoContext *)getVideoContext; -- (void *)getSurface; +- (void)drawRect:(CGRect)frame; +- (void)createScreenTexture;  - (void)initSurface;  - (void)setViewTransformation; @@ -71,6 +87,8 @@  - (void)updateMouseSurface;  - (void)clearColorBuffer; +- (void)notifyMouseMove; +- (void)updateMouseCursorScaling;  - (void)updateMouseCursor;  - (id)getEvent; @@ -83,4 +101,6 @@  @end +extern iPhoneView *g_iPhoneViewInstance; +  #endif diff --git a/backends/platform/iphone/iphone_video.mm b/backends/platform/iphone/iphone_video.mm index 86365cbefe..04aaf59b21 100644 --- a/backends/platform/iphone/iphone_video.mm +++ b/backends/platform/iphone/iphone_video.mm @@ -20,49 +20,22 @@   *   */ +// Disable symbol overrides so that we can use system headers. +#define FORBIDDEN_SYMBOL_ALLOW_ALL +  #include "iphone_video.h" -#include "iphone_common.h" -static iPhoneView *sharedInstance = nil; -static GraphicsModes _graphicsMode = kGraphicsModeLinear; -static int _width = 0; -static int _height = 0; +#include "graphics/colormasks.h" + +iPhoneView *g_iPhoneViewInstance = nil;  static int _fullWidth;  static int _fullHeight; -static CGRect _gameScreenRect; - -static char *_gameScreenTextureBuffer = 0; -static int _gameScreenTextureWidth = 0; -static int _gameScreenTextureHeight = 0; - -static char *_overlayTexBuffer = 0; -static int _overlayTexWidth = 0; -static int _overlayTexHeight = 0; -static int _overlayWidth = 0; -static int _overlayHeight = 0; -static CGRect _overlayRect;  static int _needsScreenUpdate = 0; -static int _overlayIsEnabled = 0;  static UITouch *_firstTouch = NULL;  static UITouch *_secondTouch = NULL; -static unsigned short *_mouseCursor = NULL; -static int _mouseCursorHeight = 0; -static int _mouseCursorWidth = 0; -static int _mouseCursorHotspotX = 0; -static int _mouseCursorHotspotY = 0; -static int _mouseX = 0; -static int _mouseY = 0; -static int _mouseCursorEnabled = 0; - -static GLint _renderBufferWidth; -static GLint _renderBufferHeight; - -static int _shakeOffsetY; -static int _scaledShakeOffsetY; -  #if 0  static long lastTick = 0;  static int frames = 0; @@ -83,83 +56,20 @@ int printOglError(const char *file, int line) {  	return retCode;  } -void iPhone_setGraphicsMode(GraphicsModes mode) { -	_graphicsMode = mode; - -	[sharedInstance performSelectorOnMainThread:@selector(setGraphicsMode) withObject:nil waitUntilDone: YES]; -} - -void iPhone_showCursor(int state) { -	_mouseCursorEnabled = state; -} - -void iPhone_setMouseCursor(unsigned short *buffer, int width, int height, int hotspotX, int hotspotY) { -	_mouseCursor = buffer; - -	_mouseCursorWidth = width; -	_mouseCursorHeight = height; - -	_mouseCursorHotspotX = hotspotX; -	_mouseCursorHotspotY = hotspotY; - -	[sharedInstance performSelectorOnMainThread:@selector(updateMouseCursor) withObject:nil waitUntilDone: YES]; -} - -void iPhone_enableOverlay(int state) { -	_overlayIsEnabled = state; - -	[sharedInstance performSelectorOnMainThread:@selector(clearColorBuffer) withObject:nil waitUntilDone: YES]; -} - -int iPhone_getScreenHeight() { -	return _overlayHeight; -} - -int iPhone_getScreenWidth() { -	return _overlayWidth; -} -  bool iPhone_isHighResDevice() {  	return _fullHeight > 480;  } -void iPhone_updateScreen(int mouseX, int mouseY) { +void iPhone_updateScreen() {  	//printf("Mouse: (%i, %i)\n", mouseX, mouseY); - -	_mouseX = mouseX; -	_mouseY = mouseY; -  	if (!_needsScreenUpdate) {  		_needsScreenUpdate = 1; -		[sharedInstance performSelectorOnMainThread:@selector(updateSurface) withObject:nil waitUntilDone: NO]; +		[g_iPhoneViewInstance performSelectorOnMainThread:@selector(updateSurface) withObject:nil waitUntilDone: NO];  	}  } -void iPhone_updateScreenRect(unsigned short *screen, int x1, int y1, int x2, int y2) { -	for (int y = y1; y < y2; ++y) -		memcpy(&_gameScreenTextureBuffer[(y * _gameScreenTextureWidth + x1) * 2], &screen[y * _width + x1], (x2 - x1) * 2); -} - -void iPhone_updateOverlayRect(unsigned short *screen, int x1, int y1, int x2, int y2) { -	//printf("Overlaywidth: %u, fullwidth %u\n", _overlayWidth, _fullWidth); -	for (int y = y1; y < y2; ++y) -		memcpy(&_overlayTexBuffer[(y * _overlayTexWidth + x1) * 2], &screen[y * _overlayWidth + x1], (x2 - x1) * 2); -} - -void iPhone_initSurface(int width, int height) { -	_width = width; -	_height = height; -	_shakeOffsetY = 0; -	[sharedInstance performSelectorOnMainThread:@selector(initSurface) withObject:nil waitUntilDone: YES]; -} - -void iPhone_setShakeOffset(int offset) { -	_shakeOffsetY = offset; -	[sharedInstance performSelectorOnMainThread:@selector(setViewTransformation) withObject:nil waitUntilDone: YES]; -} -  bool iPhone_fetchEvent(int *outEvent, int *outX, int *outY) { -	id event = [sharedInstance getEvent]; +	id event = [g_iPhoneViewInstance getEvent];  	if (event == nil) {  		return false;  	} @@ -196,92 +106,16 @@ const char *iPhone_getDocumentsDir() {  	return [documentsDirectory UTF8String];  } -/** - * Converts portrait mode coordinates into rotated mode coordinates. - */ -static bool convertToRotatedCoords(UIDeviceOrientation orientation, CGPoint point, CGPoint *result) { -	switch (orientation) { -	case UIDeviceOrientationLandscapeLeft: -		result->x = point.y; -		result->y = _renderBufferWidth - point.x; -		return true; - -	case UIDeviceOrientationLandscapeRight: -		result->x = _renderBufferHeight - point.y; -		result->y = point.x; -		return true; - -	case UIDeviceOrientationPortrait: -		result->x = point.x; -		result->y = point.y; -		return true; - -	default: -		return false; -	} -} - -static bool getMouseCoords(UIDeviceOrientation orientation, CGPoint point, int *x, int *y) { -	if (!convertToRotatedCoords(orientation, point, &point)) -		return false; - -	CGRect *area; -	int width, height, offsetY; -	if (_overlayIsEnabled) { -		area = &_overlayRect; -		width = _overlayWidth; -		height = _overlayHeight; -		offsetY = _shakeOffsetY; -	} else { -		area = &_gameScreenRect; -		width = _width; -		height = _height; -		offsetY = _scaledShakeOffsetY; -	} - -	point.x = (point.x - CGRectGetMinX(*area)) / CGRectGetWidth(*area); -	point.y = (point.y - CGRectGetMinY(*area)) / CGRectGetHeight(*area); - -	*x = (int)(point.x * width); -	// offsetY describes the translation of the screen in the upward direction, -	// thus we need to add it here. -	*y = (int)(point.y * height + offsetY); - -	// Clip coordinates -	if (*x < 0 || *x > CGRectGetWidth(*area) || *y < 0 || *y > CGRectGetHeight(*area)) -			return false; - -	return true; -} - -static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { -	if (!tex) -		return; - -	glBindTexture(GL_TEXTURE_2D, tex); printOpenGLError(); - -	GLint filter = GL_LINEAR; - -	switch (mode) { -	case kGraphicsModeLinear: -		filter = GL_LINEAR; -		break; - -	case kGraphicsModeNone: -		filter = GL_NEAREST; -		break; -	} - -	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter); printOpenGLError(); -	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter); printOpenGLError(); -} -  @implementation iPhoneView  + (Class)layerClass {  	return [CAEAGLLayer class];  } +- (VideoContext *)getVideoContext { +	return &_videoContext; +} +  - (void)createContext {  	CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer; @@ -317,20 +151,18 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) {  			return;  		} -		_overlayHeight = _renderBufferWidth; -		_overlayWidth = _renderBufferHeight; -		_overlayTexWidth = getSizeNextPOT(_overlayHeight); -		_overlayTexHeight = getSizeNextPOT(_overlayWidth); +		_videoContext.overlayHeight = _renderBufferWidth; +		_videoContext.overlayWidth = _renderBufferHeight; +		uint overlayTextureWidth = getSizeNextPOT(_videoContext.overlayHeight); +		uint overlayTextureHeight = getSizeNextPOT(_videoContext.overlayWidth);  		// Since the overlay size won't change the whole run, we can  		// precalculate the texture coordinates for the overlay texture here  		// and just use it later on. -		_overlayTexCoords[2] = _overlayTexCoords[6] = _overlayWidth / (GLfloat)_overlayTexWidth; -		_overlayTexCoords[5] = _overlayTexCoords[7] = _overlayHeight / (GLfloat)_overlayTexHeight; +		_overlayTexCoords[2] = _overlayTexCoords[6] = _videoContext.overlayWidth / (GLfloat)overlayTextureWidth; +		_overlayTexCoords[5] = _overlayTexCoords[7] = _videoContext.overlayHeight / (GLfloat)overlayTextureHeight; -		int textureSize = _overlayTexWidth * _overlayTexHeight * 2; -		_overlayTexBuffer = (char *)malloc(textureSize); -		memset(_overlayTexBuffer, 0, textureSize); +		_videoContext.overlayTexture.create(overlayTextureWidth, overlayTextureHeight, Graphics::createPixelFormat<5551>());  		glViewport(0, 0, _renderBufferWidth, _renderBufferHeight); printOpenGLError();  		glClearColor(0.0f, 0.0f, 0.0f, 1.0f); printOpenGLError(); @@ -356,13 +188,15 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) {  	_fullWidth = (int)frame.size.width;  	_fullHeight = (int)frame.size.height; -	sharedInstance = self; +	g_iPhoneViewInstance = self;  	_keyboardView = nil;  	_screenTexture = 0;  	_overlayTexture = 0;  	_mouseCursorTexture = 0; +	_scaledShakeOffsetY = 0; +  	_gameScreenVertCoords[0] = _gameScreenVertCoords[1] =  	    _gameScreenVertCoords[2] = _gameScreenVertCoords[3] =  	    _gameScreenVertCoords[4] = _gameScreenVertCoords[5] = @@ -383,6 +217,16 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) {  	    _overlayTexCoords[4] = _overlayTexCoords[5] =  	    _overlayTexCoords[6] = _overlayTexCoords[7] = 0; +	_mouseVertCoords[0] = _mouseVertCoords[1] = +	    _mouseVertCoords[2] = _mouseVertCoords[3] = +	    _mouseVertCoords[4] = _mouseVertCoords[5] = +	    _mouseVertCoords[6] = _mouseVertCoords[7] = 0; + +	_mouseTexCoords[0] = _mouseTexCoords[1] = +	    _mouseTexCoords[2] = _mouseTexCoords[3] = +	    _mouseTexCoords[4] = _mouseTexCoords[5] = +	    _mouseTexCoords[6] = _mouseTexCoords[7] = 0; +  	// Initialize the OpenGL ES context  	[self createContext]; @@ -396,12 +240,9 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) {  		[_keyboardView dealloc];  	} -	free(_gameScreenTextureBuffer); -	free(_overlayTexBuffer); -} - -- (void *)getSurface { -	return _screenSurface; +	_videoContext.screenTexture.free(); +	_videoContext.overlayTexture.free(); +	_videoContext.mouseTexture.free();  }  - (void)drawRect:(CGRect)frame { @@ -419,10 +260,32 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) {  #endif  } +- (void)setFilterModeForTexture:(GLuint)tex { +	if (!tex) +		return; + +	glBindTexture(GL_TEXTURE_2D, tex); printOpenGLError(); + +	GLint filter = GL_LINEAR; + +	switch (_videoContext.graphicsMode) { +	case kGraphicsModeLinear: +		filter = GL_LINEAR; +		break; + +	case kGraphicsModeNone: +		filter = GL_NEAREST; +		break; +	} + +	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter); printOpenGLError(); +	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter); printOpenGLError(); +} +  - (void)setGraphicsMode { -	setFilterModeForTexture(_screenTexture, _graphicsMode); -	setFilterModeForTexture(_overlayTexture, _graphicsMode); -	setFilterModeForTexture(_mouseCursorTexture, _graphicsMode); +	[self setFilterModeForTexture:_screenTexture]; +	[self setFilterModeForTexture:_overlayTexture]; +	[self setFilterModeForTexture:_mouseCursorTexture];  }  - (void)updateSurface { @@ -435,10 +298,10 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) {  	[self updateMainSurface]; -	if (_overlayIsEnabled) +	if (_videoContext.overlayVisible)  		[self updateOverlaySurface]; -	if (_mouseCursorEnabled) +	if (_videoContext.mouseIsVisible)  		[self updateMouseSurface];  	glBindRenderbufferOES(GL_RENDERBUFFER_OES, _viewRenderbuffer); printOpenGLError(); @@ -446,17 +309,70 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) {  } +- (void)notifyMouseMove { +	const GLint mouseX = (GLint)(_videoContext.mouseX * _mouseScaleX) - _mouseHotspotX; +	const GLint mouseY = (GLint)(_videoContext.mouseY * _mouseScaleY) - _mouseHotspotY; + +	_mouseVertCoords[0] = _mouseVertCoords[4] = mouseX; +	_mouseVertCoords[1] = _mouseVertCoords[3] = mouseY; +	_mouseVertCoords[2] = _mouseVertCoords[6] = mouseX + _mouseWidth; +	_mouseVertCoords[5] = _mouseVertCoords[7] = mouseY + _mouseHeight; +} + +- (void)updateMouseCursorScaling { +	CGRect *rect; +	int maxWidth, maxHeight; + +	if (!_videoContext.overlayVisible) { +		rect = &_gameScreenRect; +		maxWidth = _videoContext.screenWidth; +		maxHeight = _videoContext.screenHeight; +	} else { +		rect = &_overlayRect; +		maxWidth = _videoContext.overlayWidth; +		maxHeight = _videoContext.overlayHeight; +	} + +	if (!maxWidth || !maxHeight) { +		printf("WARNING: updateMouseCursorScaling called when screen was not ready (%d)!\n", _videoContext.overlayVisible); +		return; +	} + +	_mouseScaleX = CGRectGetWidth(*rect) / (GLfloat)maxWidth; +	_mouseScaleY = CGRectGetHeight(*rect) / (GLfloat)maxHeight; + +	_mouseWidth = (GLint)(_videoContext.mouseWidth * _mouseScaleX); +	_mouseHeight = (GLint)(_videoContext.mouseHeight * _mouseScaleY); + +	_mouseHotspotX = (GLint)(_videoContext.mouseHotspotX * _mouseScaleX); +	_mouseHotspotY = (GLint)(_videoContext.mouseHotspotY * _mouseScaleY); + +	// We subtract the screen offset to the hotspot here to simplify the +	// screen offset handling in the mouse code. Note the subtraction here +	// makes sure that the offset actually gets added to the mouse position, +	// since the hotspot offset is substracted from the position. +	_mouseHotspotX -= (GLint)CGRectGetMinX(*rect); +	_mouseHotspotY -= (GLint)CGRectGetMinY(*rect); + +	// FIXME: For now we also adapt the mouse position here. In reality we +	// would be better off to also adjust the event position when switching +	// from overlay to game screen or vica versa. +	[self notifyMouseMove]; +} +  - (void)updateMouseCursor {  	if (_mouseCursorTexture == 0) {  		glGenTextures(1, &_mouseCursorTexture); printOpenGLError(); -		setFilterModeForTexture(_mouseCursorTexture, _graphicsMode); +		[self setFilterModeForTexture:_mouseCursorTexture];  	} -	glBindTexture(GL_TEXTURE_2D, _mouseCursorTexture); printOpenGLError(); -	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, getSizeNextPOT(_mouseCursorWidth), getSizeNextPOT(_mouseCursorHeight), 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, _mouseCursor); printOpenGLError(); +	[self updateMouseCursorScaling]; -	free(_mouseCursor); -	_mouseCursor = NULL; +	_mouseTexCoords[2] = _mouseTexCoords[6] = _videoContext.mouseWidth / (GLfloat)_videoContext.mouseTexture.w; +	_mouseTexCoords[5] = _mouseTexCoords[7] = _videoContext.mouseHeight / (GLfloat)_videoContext.mouseTexture.h; + +	glBindTexture(GL_TEXTURE_2D, _mouseCursorTexture); printOpenGLError(); +	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, _videoContext.mouseTexture.w, _videoContext.mouseTexture.h, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, _videoContext.mouseTexture.pixels); printOpenGLError();  }  - (void)updateMainSurface { @@ -468,7 +384,7 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) {  	// Unfortunately we have to update the whole texture every frame, since glTexSubImage2D is actually slower in all cases  	// due to the iPhone internals having to convert the whole texture back from its internal format when used.  	// In the future we could use several tiled textures instead. -	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, _gameScreenTextureWidth, _gameScreenTextureHeight, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, _gameScreenTextureBuffer); printOpenGLError(); +	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, _videoContext.screenTexture.w, _videoContext.screenTexture.h, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, _videoContext.screenTexture.pixels); printOpenGLError();  	glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); printOpenGLError();  } @@ -477,147 +393,83 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) {  	glTexCoordPointer(2, GL_FLOAT, 0, _overlayTexCoords); printOpenGLError();  	glBindTexture(GL_TEXTURE_2D, _overlayTexture); printOpenGLError(); -	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, _overlayTexWidth, _overlayTexHeight, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, _overlayTexBuffer); printOpenGLError(); +	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, _videoContext.overlayTexture.w, _videoContext.overlayTexture.h, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, _videoContext.overlayTexture.pixels); printOpenGLError();  	glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); printOpenGLError();  }  - (void)updateMouseSurface { -	int width = _mouseCursorWidth; -	int height = _mouseCursorHeight; - -	int mouseX = _mouseX; -	int mouseY = _mouseY; - -	int hotspotX = _mouseCursorHotspotX; -	int hotspotY = _mouseCursorHotspotY; - -	CGRect *rect; -	int maxWidth, maxHeight; - -	if (!_overlayIsEnabled) { -		rect = &_gameScreenRect; -		maxWidth = _width; -		maxHeight = _height; -	} else { -		rect = &_overlayRect; -		maxWidth = _overlayWidth; -		maxHeight = _overlayHeight; -	} - -	const GLfloat scaleX = CGRectGetWidth(*rect) / (GLfloat)maxWidth; -	const GLfloat scaleY = CGRectGetHeight(*rect) / (GLfloat)maxHeight; - -	mouseX = (int)(mouseX * scaleX); -	mouseY = (int)(mouseY * scaleY); -	hotspotX = (int)(hotspotX * scaleX); -	hotspotY = (int)(hotspotY * scaleY); -	width = (int)(width * scaleX); -	height = (int)(height * scaleY); - -	mouseX -= hotspotX; -	mouseY -= hotspotY; - -	mouseX += (int)CGRectGetMinX(*rect); -	mouseY += (int)CGRectGetMinY(*rect); - -	GLfloat vertices[] = { -		// Top left -		mouseX        , mouseY, -		// Top right -		mouseX + width, mouseY, -		// Bottom left -		mouseX        , mouseY + height, -		// Bottom right -		mouseX + width, mouseY + height -	}; - -	//printf("Cursor: width %u height %u\n", _mouseCursorWidth, _mouseCursorHeight); - -	float texWidth = _mouseCursorWidth / (float)getSizeNextPOT(_mouseCursorWidth); -	float texHeight = _mouseCursorHeight / (float)getSizeNextPOT(_mouseCursorHeight); - -	const GLfloat texCoords[] = { -		// Top left -		0       , 0, -		// Top right -		texWidth, 0, -		// Bottom left -		0       , texHeight, -		// Bottom right -		texWidth, texHeight -	}; - -	glVertexPointer(2, GL_FLOAT, 0, vertices); printOpenGLError(); -	glTexCoordPointer(2, GL_FLOAT, 0, texCoords); printOpenGLError(); +	glVertexPointer(2, GL_FLOAT, 0, _mouseVertCoords); printOpenGLError(); +	glTexCoordPointer(2, GL_FLOAT, 0, _mouseTexCoords); printOpenGLError();  	glBindTexture(GL_TEXTURE_2D, _mouseCursorTexture); printOpenGLError();  	glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); printOpenGLError();  } -- (void)initSurface { -	_gameScreenTextureWidth = getSizeNextPOT(_width); -	_gameScreenTextureHeight = getSizeNextPOT(_height); - -	_gameScreenTexCoords[2] = _gameScreenTexCoords[6] = _width / (GLfloat)_gameScreenTextureWidth; -	_gameScreenTexCoords[5] = _gameScreenTexCoords[7] = _height / (GLfloat)_gameScreenTextureHeight; +- (void)setUpOrientation:(UIDeviceOrientation)orientation width:(int *)width height:(int *)height { +	_orientation = orientation; -	_orientation = [[UIDevice currentDevice] orientation]; +	glMatrixMode(GL_PROJECTION); +	glLoadIdentity(); +	// We always force the origin (0,0) to be in the upper left corner.  	switch (_orientation) { -	case UIDeviceOrientationLandscapeLeft:  	case UIDeviceOrientationLandscapeRight: -	case UIDeviceOrientationPortrait: +		glRotatef( 90, 0, 0, 1); printOpenGLError(); +		glOrthof(0, _renderBufferHeight, _renderBufferWidth, 0, 0, 1); printOpenGLError(); + +		*width = _renderBufferHeight; +		*height = _renderBufferWidth; +		break; + +	case UIDeviceOrientationLandscapeLeft: +		glRotatef(-90, 0, 0, 1); printOpenGLError(); +		glOrthof(0, _renderBufferHeight, _renderBufferWidth, 0, 0, 1); printOpenGLError(); + +		*width = _renderBufferHeight; +		*height = _renderBufferWidth;  		break; +	case UIDeviceOrientationPortrait:  	default: +		// We must force the portrait orientation here, since we might not know +		// the real orientation.  		_orientation = UIDeviceOrientationPortrait; -	} - -	//printf("Window: (%d, %d), Surface: (%d, %d), Texture(%d, %d)\n", _fullWidth, _fullHeight, _width, _height, _gameScreenTextureWidth, _gameScreenTextureHeight); -	glMatrixMode(GL_PROJECTION); -	glLoadIdentity(); +		glOrthof(0, _renderBufferWidth, _renderBufferHeight, 0, 0, 1); printOpenGLError(); -	int screenWidth, screenHeight; +		*width = _renderBufferWidth; +		*height = _renderBufferHeight; +		break; +	} +} -	// Set the origin (0,0) depending on the rotation mode. -	if (_orientation ==  UIDeviceOrientationLandscapeRight) { -		glRotatef( 90, 0, 0, 1); printOpenGLError(); -		glOrthof(0, _renderBufferHeight, _renderBufferWidth, 0, 0, 1); printOpenGLError(); +- (void)createScreenTexture { +	const uint screenTexWidth = getSizeNextPOT(_videoContext.screenWidth); +	const uint screenTexHeight = getSizeNextPOT(_videoContext.screenHeight); -		screenWidth = _renderBufferHeight; -		screenHeight = _renderBufferWidth; -	} else if (_orientation == UIDeviceOrientationLandscapeLeft) { -		glRotatef(-90, 0, 0, 1); printOpenGLError(); -		glOrthof(0, _renderBufferHeight, _renderBufferWidth, 0, 0, 1); printOpenGLError(); +	_gameScreenTexCoords[2] = _gameScreenTexCoords[6] = _videoContext.screenWidth / (GLfloat)screenTexWidth; +	_gameScreenTexCoords[5] = _gameScreenTexCoords[7] = _videoContext.screenHeight / (GLfloat)screenTexHeight; -		screenWidth = _renderBufferHeight; -		screenHeight = _renderBufferWidth; -	} else if (_orientation == UIDeviceOrientationPortrait) { -		glOrthof(0, _renderBufferWidth, _renderBufferHeight, 0, 0, 1); printOpenGLError(); +	_videoContext.screenTexture.create(screenTexWidth, screenTexHeight, Graphics::createPixelFormat<565>()); +} -		screenWidth = _renderBufferWidth; -		screenHeight = _renderBufferHeight; -	} +- (void)initSurface { +	int screenWidth, screenHeight; +	[self setUpOrientation:[[UIDevice currentDevice] orientation] width:&screenWidth height:&screenHeight];  	if (_screenTexture > 0) {  		glDeleteTextures(1, &_screenTexture); printOpenGLError();  	}  	glGenTextures(1, &_screenTexture); printOpenGLError(); -	setFilterModeForTexture(_screenTexture, _graphicsMode); +	[self setFilterModeForTexture:_screenTexture];  	if (_overlayTexture > 0) {  		glDeleteTextures(1, &_overlayTexture); printOpenGLError();  	}  	glGenTextures(1, &_overlayTexture); printOpenGLError(); -	setFilterModeForTexture(_overlayTexture, _graphicsMode); - -	free(_gameScreenTextureBuffer); -	int textureSize = _gameScreenTextureWidth * _gameScreenTextureHeight * 2; -	_gameScreenTextureBuffer = (char *)malloc(textureSize); -	memset(_gameScreenTextureBuffer, 0, textureSize); +	[self setFilterModeForTexture:_overlayTexture];  	glBindRenderbufferOES(GL_RENDERBUFFER_OES, _viewRenderbuffer); printOpenGLError(); @@ -628,10 +480,19 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) {  		[[_keyboardView inputView] removeFromSuperview];  	} +	GLfloat adjustedWidth = _videoContext.screenWidth; +	GLfloat adjustedHeight = _videoContext.screenHeight; +	if (_videoContext.asprectRatioCorrection) { +		if (_videoContext.screenWidth == 320 && _videoContext.screenHeight == 200) +			adjustedHeight = 240; +		else if (_videoContext.screenWidth == 640 && _videoContext.screenHeight == 400) +			adjustedHeight = 480; +	} +	  	float overlayPortraitRatio;  	if (_orientation == UIDeviceOrientationLandscapeLeft || _orientation ==  UIDeviceOrientationLandscapeRight) { -		GLfloat gameScreenRatio = (GLfloat)_width / (GLfloat)_height; +		GLfloat gameScreenRatio = adjustedWidth / adjustedHeight;  		GLfloat screenRatio = (GLfloat)screenWidth / (GLfloat)screenHeight;  		// These are the width/height according to the portrait layout! @@ -660,7 +521,7 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) {  		_gameScreenRect = CGRectMake(xOffset, yOffset, rectWidth, rectHeight);  		overlayPortraitRatio = 1.0f;  	} else { -		float ratio = (float)_height / (float)_width; +		GLfloat ratio = adjustedHeight / adjustedWidth;  		int height = (int)(screenWidth * ratio);  		//printf("Making rect (%u, %u)\n", screenWidth, height);  		_gameScreenRect = CGRectMake(0, 0, screenWidth, height); @@ -674,7 +535,7 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) {  		[self addSubview:[_keyboardView inputView]];  		[self addSubview: _keyboardView];  		[[_keyboardView inputView] becomeFirstResponder]; -		overlayPortraitRatio = (_overlayHeight * ratio) / _overlayWidth; +		overlayPortraitRatio = (_videoContext.overlayHeight * ratio) / _videoContext.overlayWidth;  	}  	_overlayRect = CGRectMake(0, 0, screenWidth, screenHeight * overlayPortraitRatio); @@ -688,6 +549,7 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) {  	_overlayVertCoords[5] = _overlayVertCoords[7] = CGRectGetMaxY(_overlayRect);  	[self setViewTransformation]; +	[self updateMouseCursorScaling];  }  - (void)setViewTransformation { @@ -698,7 +560,7 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) {  	// Scale the shake offset according to the overlay size. We need this to  	// adjust the overlay mouse click coordinates when an offset is set. -	_scaledShakeOffsetY = (int)(_shakeOffsetY / (GLfloat)_height * CGRectGetHeight(_overlayRect)); +	_scaledShakeOffsetY = (int)(_videoContext.shakeOffsetY / (GLfloat)_videoContext.screenHeight * CGRectGetHeight(_overlayRect));  	// Apply the shakeing to the output screen.  	glTranslatef(0, -_scaledShakeOffsetY, 0); @@ -732,6 +594,64 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) {  	[_events addObject: event];  } +/** + * Converts portrait mode coordinates into rotated mode coordinates. + */ +- (bool)convertToRotatedCoords:(CGPoint)point result:(CGPoint *)result { +	switch (_orientation) { +	case UIDeviceOrientationLandscapeLeft: +		result->x = point.y; +		result->y = _renderBufferWidth - point.x; +		return true; + +	case UIDeviceOrientationLandscapeRight: +		result->x = _renderBufferHeight - point.y; +		result->y = point.x; +		return true; + +	case UIDeviceOrientationPortrait: +		result->x = point.x; +		result->y = point.y; +		return true; + +	default: +		return false; +	} +} + +- (bool)getMouseCoords:(CGPoint)point eventX:(int *)x eventY:(int *)y { +	if (![self convertToRotatedCoords:point result:&point]) +		return false; + +	CGRect *area; +	int width, height, offsetY; +	if (_videoContext.overlayVisible) { +		area = &_overlayRect; +		width = _videoContext.overlayWidth; +		height = _videoContext.overlayHeight; +		offsetY = _scaledShakeOffsetY; +	} else { +		area = &_gameScreenRect; +		width = _videoContext.screenWidth; +		height = _videoContext.screenHeight; +		offsetY = _videoContext.shakeOffsetY; +	} + +	point.x = (point.x - CGRectGetMinX(*area)) / CGRectGetWidth(*area); +	point.y = (point.y - CGRectGetMinY(*area)) / CGRectGetHeight(*area); + +	*x = (int)(point.x * width); +	// offsetY describes the translation of the screen in the upward direction, +	// thus we need to add it here. +	*y = (int)(point.y * height + offsetY); + +	// Clip coordinates +	if (*x < 0 || *x > width || *y < 0 || *y > height) +		return false; + +	return true; +} +  - (void)deviceOrientationChanged:(UIDeviceOrientation)orientation {  	switch (orientation) {  	case UIDeviceOrientationLandscapeLeft: @@ -762,7 +682,7 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) {  	case 1: {  		UITouch *touch = [touches anyObject];  		CGPoint point = [touch locationInView:self]; -		if (!getMouseCoords(_orientation, point, &x, &y)) +		if (![self getMouseCoords:point eventX:&x eventY:&y])  			return;  		_firstTouch = touch; @@ -780,7 +700,7 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) {  	case 2: {  		UITouch *touch = [touches anyObject];  		CGPoint point = [touch locationInView:self]; -		if (!getMouseCoords(_orientation, point, &x, &y)) +		if (![self getMouseCoords:point eventX:&x eventY:&y])  			return;  		_secondTouch = touch; @@ -804,7 +724,7 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) {  	for (UITouch *touch in touches) {  		if (touch == _firstTouch) {  			CGPoint point = [touch locationInView:self]; -			if (!getMouseCoords(_orientation, point, &x, &y)) +			if (![self getMouseCoords:point eventX:&x eventY:&y])  				return;  			[self addEvent: @@ -817,7 +737,7 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) {  			 ];  		} else if (touch == _secondTouch) {  			CGPoint point = [touch locationInView:self]; -			if (!getMouseCoords(_orientation, point, &x, &y)) +			if (![self getMouseCoords:point eventX:&x eventY:&y])  				return;  			[self addEvent: @@ -840,7 +760,7 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) {  	case 1: {  		UITouch *touch = [[allTouches allObjects] objectAtIndex:0];  		CGPoint point = [touch locationInView:self]; -		if (!getMouseCoords(_orientation, point, &x, &y)) +		if (![self getMouseCoords:point eventX:&x eventY:&y])  			return;  		[self addEvent: @@ -857,7 +777,7 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) {  	case 2: {  		UITouch *touch = [[allTouches allObjects] objectAtIndex:1];  		CGPoint point = [touch locationInView:self]; -		if (!getMouseCoords(_orientation, point, &x, &y)) +		if (![self getMouseCoords:point eventX:&x eventY:&y])  			return;  		[self addEvent: diff --git a/backends/platform/iphone/osys_events.cpp b/backends/platform/iphone/osys_events.cpp index c167da35e6..85efbda208 100644 --- a/backends/platform/iphone/osys_events.cpp +++ b/backends/platform/iphone/osys_events.cpp @@ -122,8 +122,8 @@ bool OSystem_IPHONE::handleEvent_mouseDown(Common::Event &event, int x, int y) {  	if (_mouseClickAndDragEnabled) {  		event.type = Common::EVENT_LBUTTONDOWN; -		event.mouse.x = _mouseX; -		event.mouse.y = _mouseY; +		event.mouse.x = _videoContext->mouseX; +		event.mouse.y = _videoContext->mouseY;  		return true;  	} else {  		_lastMouseDown = getMillis(); @@ -140,17 +140,17 @@ bool OSystem_IPHONE::handleEvent_mouseUp(Common::Event &event, int x, int y) {  			return false;  	} else if (_mouseClickAndDragEnabled) {  		event.type = Common::EVENT_LBUTTONUP; -		event.mouse.x = _mouseX; -		event.mouse.y = _mouseY; +		event.mouse.x = _videoContext->mouseX; +		event.mouse.y = _videoContext->mouseY;  	} else {  		if (getMillis() - _lastMouseDown < 250) {  			event.type = Common::EVENT_LBUTTONDOWN; -			event.mouse.x = _mouseX; -			event.mouse.y = _mouseY; +			event.mouse.x = _videoContext->mouseX; +			event.mouse.y = _videoContext->mouseY;  			_queuedInputEvent.type = Common::EVENT_LBUTTONUP; -			_queuedInputEvent.mouse.x = _mouseX; -			_queuedInputEvent.mouse.y = _mouseY; +			_queuedInputEvent.mouse.x = _videoContext->mouseX; +			_queuedInputEvent.mouse.y = _videoContext->mouseY;  			_lastMouseTap = getMillis();  			_queuedEventTime = _lastMouseTap + kQueuedInputEventDelay;  		} else @@ -167,12 +167,12 @@ bool OSystem_IPHONE::handleEvent_secondMouseDown(Common::Event &event, int x, in  	if (_mouseClickAndDragEnabled) {  		event.type = Common::EVENT_LBUTTONUP; -		event.mouse.x = _mouseX; -		event.mouse.y = _mouseY; +		event.mouse.x = _videoContext->mouseX; +		event.mouse.y = _videoContext->mouseY;  		_queuedInputEvent.type = Common::EVENT_RBUTTONDOWN; -		_queuedInputEvent.mouse.x = _mouseX; -		_queuedInputEvent.mouse.y = _mouseY; +		_queuedInputEvent.mouse.x = _videoContext->mouseX; +		_queuedInputEvent.mouse.y = _videoContext->mouseY;  	} else  		return false; @@ -184,7 +184,7 @@ bool OSystem_IPHONE::handleEvent_secondMouseUp(Common::Event &event, int x, int  	if (curTime - _lastSecondaryDown < 400) {  		//printf("Right tap!\n"); -		if (curTime - _lastSecondaryTap < 400 && !_overlayVisible) { +		if (curTime - _lastSecondaryTap < 400 && !_videoContext->overlayVisible) {  			//printf("Right escape!\n");  			event.type = Common::EVENT_KEYDOWN;  			_queuedInputEvent.type = Common::EVENT_KEYUP; @@ -197,11 +197,11 @@ bool OSystem_IPHONE::handleEvent_secondMouseUp(Common::Event &event, int x, int  		} else if (!_mouseClickAndDragEnabled) {  			//printf("Rightclick!\n");  			event.type = Common::EVENT_RBUTTONDOWN; -			event.mouse.x = _mouseX; -			event.mouse.y = _mouseY; +			event.mouse.x = _videoContext->mouseX; +			event.mouse.y = _videoContext->mouseY;  			_queuedInputEvent.type = Common::EVENT_RBUTTONUP; -			_queuedInputEvent.mouse.x = _mouseX; -			_queuedInputEvent.mouse.y = _mouseY; +			_queuedInputEvent.mouse.x = _videoContext->mouseX; +			_queuedInputEvent.mouse.y = _videoContext->mouseY;  			_lastSecondaryTap = curTime;  			_queuedEventTime = curTime + kQueuedInputEventDelay;  		} else { @@ -211,8 +211,8 @@ bool OSystem_IPHONE::handleEvent_secondMouseUp(Common::Event &event, int x, int  	}  	if (_mouseClickAndDragEnabled) {  		event.type = Common::EVENT_RBUTTONUP; -		event.mouse.x = _mouseX; -		event.mouse.y = _mouseY; +		event.mouse.x = _videoContext->mouseX; +		event.mouse.y = _videoContext->mouseY;  	}  	return true; @@ -234,11 +234,11 @@ bool OSystem_IPHONE::handleEvent_mouseDragged(Common::Event &event, int x, int y  		_lastPadX = x;  		_lastPadY = y; -		mouseNewPosX = (int)(_mouseX - deltaX / 0.5f); -		mouseNewPosY = (int)(_mouseY - deltaY / 0.5f); +		mouseNewPosX = (int)(_videoContext->mouseX - deltaX / 0.5f); +		mouseNewPosY = (int)(_videoContext->mouseY - deltaY / 0.5f); -		int widthCap = _overlayVisible ? _overlayWidth : _screenWidth; -		int heightCap = _overlayVisible ? _overlayHeight : _screenHeight; +		int widthCap = _videoContext->overlayVisible ? _videoContext->overlayWidth : _videoContext->screenWidth; +		int heightCap = _videoContext->overlayVisible ? _videoContext->overlayHeight : _videoContext->screenHeight;  		if (mouseNewPosX < 0)  			mouseNewPosX = 0; @@ -350,10 +350,10 @@ void  OSystem_IPHONE::handleEvent_orientationChanged(int orientation) {  	if (_screenOrientation != newOrientation) {  		_screenOrientation = newOrientation; -		iPhone_initSurface(_screenWidth, _screenHeight); +		updateOutputSurface();  		dirtyFullScreen(); -		if (_overlayVisible) +		if (_videoContext->overlayVisible)  			dirtyFullOverlayScreen();  		updateScreen();  	} diff --git a/backends/platform/iphone/osys_main.cpp b/backends/platform/iphone/osys_main.cpp index 2bdc09c9ce..f3e0d97b97 100644 --- a/backends/platform/iphone/osys_main.cpp +++ b/backends/platform/iphone/osys_main.cpp @@ -55,26 +55,28 @@ SoundProc OSystem_IPHONE::s_soundCallback = NULL;  void *OSystem_IPHONE::s_soundParam = NULL;  OSystem_IPHONE::OSystem_IPHONE() : -	_mixer(NULL), _gameScreenRaw(NULL), -	_overlayVisible(false), _gameScreenConverted(NULL), -	_mouseHeight(0), _mouseWidth(0), _mouseBuf(NULL), _lastMouseTap(0), _queuedEventTime(0), +	_mixer(NULL), _lastMouseTap(0), _queuedEventTime(0),  	_mouseNeedTextureUpdate(false), _secondaryTapped(false), _lastSecondaryTap(0),  	_screenOrientation(kScreenOrientationFlippedLandscape), _mouseClickAndDragEnabled(false),  	_gestureStartX(-1), _gestureStartY(-1), _fullScreenIsDirty(false), _fullScreenOverlayIsDirty(false),  	_mouseDirty(false), _timeSuspended(0), _lastDragPosX(-1), _lastDragPosY(-1), _screenChangeCount(0), -	_overlayHeight(0), _overlayWidth(0), _overlayBuffer(0), _mouseCursorPaletteEnabled(false), -	_currentGraphicsMode(kGraphicsModeLinear) { +	_mouseCursorPaletteEnabled(false) {  	_queuedInputEvent.type = Common::EVENT_INVALID;  	_touchpadModeEnabled = !iPhone_isHighResDevice();  	_fsFactory = new POSIXFilesystemFactory(); +	initVideoContext();  }  OSystem_IPHONE::~OSystem_IPHONE() {  	AudioQueueDispose(s_AudioQueue.queue, true);  	delete _mixer; -	free(_gameScreenRaw); -	free(_gameScreenConverted); +	// Prevent accidental freeing of the screen texture here. This needs to be +	// checked since we might use the screen texture as framebuffer in the case +	// of hi-color games for example. +	if (_framebuffer.pixels == _videoContext->screenTexture.pixels) +		_framebuffer.free(); +	_mouseBuffer.free();  }  int OSystem_IPHONE::timerHandler(int t) { @@ -120,6 +122,9 @@ void OSystem_IPHONE::setFeatureState(Feature f, bool enable) {  			_mouseCursorPaletteEnabled = enable;  		}  		break; +	case kFeatureAspectRatioCorrection: +		_videoContext->asprectRatioCorrection = enable; +		break;  	default:  		break; @@ -130,6 +135,8 @@ bool OSystem_IPHONE::getFeatureState(Feature f) {  	switch (f) {  	case kFeatureCursorPalette:  		return _mouseCursorPaletteEnabled; +	case kFeatureAspectRatioCorrection: +		return _videoContext->asprectRatioCorrection;  	default:  		return false; diff --git a/backends/platform/iphone/osys_main.h b/backends/platform/iphone/osys_main.h index e4b3d358d5..5d0f60c34c 100644 --- a/backends/platform/iphone/osys_main.h +++ b/backends/platform/iphone/osys_main.h @@ -59,39 +59,27 @@ protected:  	static SoundProc s_soundCallback;  	static void *s_soundParam; -	int _currentGraphicsMode; -  	Audio::MixerImpl *_mixer; -	Graphics::Surface _framebuffer; -	byte *_gameScreenRaw; -	OverlayColor  *_overlayBuffer; -	uint16 _overlayHeight; -	uint16 _overlayWidth; +	VideoContext *_videoContext; -	uint16 *_gameScreenConverted; +	Graphics::Surface _framebuffer;  	// For use with the game texture  	uint16  _gamePalette[256];  	// For use with the mouse texture  	uint16  _gamePaletteRGBA5551[256]; -	bool _overlayVisible; -	uint16 _screenWidth; -	uint16 _screenHeight;  	struct timeval _startTime;  	uint32 _timeSuspended; -	bool _mouseVisible;  	bool _mouseCursorPaletteEnabled;  	uint16 _mouseCursorPalette[256]; -	byte *_mouseBuf; -	byte _mouseKeyColor; -	uint _mouseWidth, _mouseHeight; -	uint _mouseX, _mouseY; -	int _mouseHotspotX, _mouseHotspotY; +	Graphics::Surface _mouseBuffer; +	uint16 _mouseKeyColor;  	bool _mouseDirty;  	bool _mouseNeedTextureUpdate; +  	long _lastMouseDown;  	long _lastMouseTap;  	long _queuedEventTime; @@ -133,9 +121,18 @@ public:  	virtual bool setGraphicsMode(int mode);  	virtual int getGraphicsMode() const;  	virtual void initSize(uint width, uint height, const Graphics::PixelFormat *format); + +	virtual void beginGFXTransaction(); +	virtual TransactionError endGFXTransaction(); +  	virtual int16 getHeight();  	virtual int16 getWidth(); +#ifdef USE_RGB_COLOR +	virtual Graphics::PixelFormat getScreenFormat() const { return _framebuffer.format; } +	virtual Common::List<Graphics::PixelFormat> getSupportedFormats() const; +#endif +  	virtual PaletteManager *getPaletteManager() { return this; }  protected:  	// PaletteManager API @@ -192,13 +189,14 @@ public:  	virtual void logMessage(LogMessageType::Type type, const char *message);  protected: +	void initVideoContext(); +	void updateOutputSurface(); +  	void internUpdateScreen();  	void dirtyFullScreen();  	void dirtyFullOverlayScreen();  	void suspendLoop();  	void drawDirtyRect(const Common::Rect &dirtyRect); -	void drawDirtyOverlayRect(const Common::Rect &dirtyRect); -	void updateHardwareSurfaceForRect(const Common::Rect &updatedRect);  	void updateMouseTexture();  	static void AQBufferCallback(void *in, AudioQueueRef inQ, AudioQueueBufferRef outQB);  	static int timerHandler(int t); diff --git a/backends/platform/iphone/osys_video.cpp b/backends/platform/iphone/osys_video.cpp deleted file mode 100644 index e26c360c82..0000000000 --- a/backends/platform/iphone/osys_video.cpp +++ /dev/null @@ -1,432 +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. - * - */ - -// Disable symbol overrides so that we can use system headers. -#define FORBIDDEN_SYMBOL_ALLOW_ALL - -#include "osys_main.h" - -const OSystem::GraphicsMode *OSystem_IPHONE::getSupportedGraphicsModes() const { -	return s_supportedGraphicsModes; -} - - -int OSystem_IPHONE::getDefaultGraphicsMode() const { -	return kGraphicsModeLinear; -} - -bool OSystem_IPHONE::setGraphicsMode(int mode) { -	switch (mode) { -	case kGraphicsModeNone: -	case kGraphicsModeLinear: -		_currentGraphicsMode = mode; -		iPhone_setGraphicsMode((GraphicsModes)mode); -		return true; - -	default: -		return false; -	} -} - -int OSystem_IPHONE::getGraphicsMode() const { -	return _currentGraphicsMode; -} - -void OSystem_IPHONE::initSize(uint width, uint height, const Graphics::PixelFormat *format) { -	//printf("initSize(%i, %i)\n", width, height); - -	_screenWidth = width; -	_screenHeight = height; - -	free(_gameScreenRaw); - -	_gameScreenRaw = (byte *)malloc(width * height); -	bzero(_gameScreenRaw, width * height); - -	//free(_overlayBuffer); - -	int fullSize = _screenWidth * _screenHeight * sizeof(OverlayColor); -	//_overlayBuffer = (OverlayColor *)malloc(fullSize); -	clearOverlay(); - -	free(_gameScreenConverted); - -	_gameScreenConverted = (uint16 *)malloc(fullSize); -	bzero(_gameScreenConverted, fullSize); - -	iPhone_initSurface(width, height); - -	if (_overlayBuffer == NULL) { -		_overlayHeight = iPhone_getScreenHeight(); -		_overlayWidth = iPhone_getScreenWidth(); - -		printf("Overlay: (%u x %u)\n", _overlayWidth, _overlayHeight); -		_overlayBuffer = new OverlayColor[_overlayHeight * _overlayWidth]; -	} - -	_fullScreenIsDirty = false; -	dirtyFullScreen(); -	_mouseVisible = false; -	_mouseCursorPaletteEnabled = false; -	_screenChangeCount++; -	updateScreen(); -} - -int16 OSystem_IPHONE::getHeight() { -	return _screenHeight; -} - -int16 OSystem_IPHONE::getWidth() { -	return _screenWidth; -} - -void OSystem_IPHONE::setPalette(const byte *colors, uint start, uint num) { -	assert(start + num <= 256); -	const byte *b = colors; - -	for (uint i = start; i < start + num; ++i) { -		_gamePalette[i] = Graphics::RGBToColor<Graphics::ColorMasks<565> >(b[0], b[1], b[2]); -		_gamePaletteRGBA5551[i] = Graphics::RGBToColor<Graphics::ColorMasks<5551> >(b[0], b[1], b[2]); -		b += 3; -	} - -	dirtyFullScreen(); -} - -void OSystem_IPHONE::grabPalette(byte *colors, uint start, uint num) { -	assert(start + num <= 256); -	byte *b = colors; - -	for (uint i = start; i < start + num; ++i) { -		Graphics::colorToRGB<Graphics::ColorMasks<565> >(_gamePalette[i], b[0], b[1], b[2]); -		b += 3; -	} -} - -void OSystem_IPHONE::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) { -	//printf("copyRectToScreen(%i, %i, %i, %i)\n", x, y, w, h); -	//Clip the coordinates -	if (x < 0) { -		w += x; -		buf -= x; -		x = 0; -	} - -	if (y < 0) { -		h += y; -		buf -= y * pitch; -		y = 0; -	} - -	if (w > _screenWidth - x) { -		w = _screenWidth - x; -	} - -	if (h > _screenHeight - y) { -		h = _screenHeight - y; -	} - -	if (w <= 0 || h <= 0) -		return; - -	if (!_fullScreenIsDirty) { -		_dirtyRects.push_back(Common::Rect(x, y, x + w, y + h)); -	} - - -	byte *dst = _gameScreenRaw + y * _screenWidth + x; -	if (_screenWidth == pitch && pitch == w) -		memcpy(dst, buf, h * w); -	else { -		do { -			memcpy(dst, buf, w); -			buf += pitch; -			dst += _screenWidth; -		} while (--h); -	} -} - -void OSystem_IPHONE::updateScreen() { -	//printf("updateScreen(): %i dirty rects.\n", _dirtyRects.size()); - -	if (_dirtyRects.size() == 0 && _dirtyOverlayRects.size() == 0 && !_mouseDirty) -		return; - -	internUpdateScreen(); -	_mouseDirty = false; -	_fullScreenIsDirty = false; -	_fullScreenOverlayIsDirty = false; - -	iPhone_updateScreen(_mouseX, _mouseY); -} - -void OSystem_IPHONE::internUpdateScreen() { -	if (_mouseNeedTextureUpdate) { -		updateMouseTexture(); -		_mouseNeedTextureUpdate = false; -	} - -	while (_dirtyRects.size()) { -		Common::Rect dirtyRect = _dirtyRects.remove_at(_dirtyRects.size() - 1); - -		//printf("Drawing: (%i, %i) -> (%i, %i)\n", dirtyRect.left, dirtyRect.top, dirtyRect.right, dirtyRect.bottom); -		drawDirtyRect(dirtyRect); -		updateHardwareSurfaceForRect(dirtyRect); -	} - -	if (_overlayVisible) { -		while (_dirtyOverlayRects.size()) { -			Common::Rect dirtyRect = _dirtyOverlayRects.remove_at(_dirtyOverlayRects.size() - 1); - -			//printf("Drawing: (%i, %i) -> (%i, %i)\n", dirtyRect.left, dirtyRect.top, dirtyRect.right, dirtyRect.bottom); -			drawDirtyOverlayRect(dirtyRect); -		} -	} -} - -void OSystem_IPHONE::drawDirtyRect(const Common::Rect &dirtyRect) { -	int h = dirtyRect.bottom - dirtyRect.top; -	int w = dirtyRect.right - dirtyRect.left; - -	byte  *src = &_gameScreenRaw[dirtyRect.top * _screenWidth + dirtyRect.left]; -	uint16 *dst = &_gameScreenConverted[dirtyRect.top * _screenWidth + dirtyRect.left]; -	for (int y = h; y > 0; y--) { -		for (int x = w; x > 0; x--) -			*dst++ = _gamePalette[*src++]; - -		dst += _screenWidth - w; -		src += _screenWidth - w; -	} -} - -void OSystem_IPHONE::drawDirtyOverlayRect(const Common::Rect &dirtyRect) { -	iPhone_updateOverlayRect(_overlayBuffer, dirtyRect.left, dirtyRect.top, dirtyRect.right, dirtyRect.bottom); -} - -void OSystem_IPHONE::updateHardwareSurfaceForRect(const Common::Rect &updatedRect) { -	iPhone_updateScreenRect(_gameScreenConverted, updatedRect.left, updatedRect.top, updatedRect.right, updatedRect.bottom); -} - -Graphics::Surface *OSystem_IPHONE::lockScreen() { -	//printf("lockScreen()\n"); - -	_framebuffer.pixels = _gameScreenRaw; -	_framebuffer.w = _screenWidth; -	_framebuffer.h = _screenHeight; -	_framebuffer.pitch = _screenWidth; -	_framebuffer.format = Graphics::PixelFormat::createFormatCLUT8(); - -	return &_framebuffer; -} - -void OSystem_IPHONE::unlockScreen() { -	//printf("unlockScreen()\n"); -	dirtyFullScreen(); -} - -void OSystem_IPHONE::setShakePos(int shakeOffset) { -	//printf("setShakePos(%i)\n", shakeOffset); -	iPhone_setShakeOffset(shakeOffset); -	// HACK: We use this to force a redraw. -	_mouseDirty = true; -} - -void OSystem_IPHONE::showOverlay() { -	//printf("showOverlay()\n"); -	_overlayVisible = true; -	dirtyFullOverlayScreen(); -	updateScreen(); -	iPhone_enableOverlay(true); -} - -void OSystem_IPHONE::hideOverlay() { -	//printf("hideOverlay()\n"); -	_overlayVisible = false; -	_dirtyOverlayRects.clear(); -	dirtyFullScreen(); -	iPhone_enableOverlay(false); -} - -void OSystem_IPHONE::clearOverlay() { -	//printf("clearOverlay()\n"); -	bzero(_overlayBuffer, _overlayWidth * _overlayHeight * sizeof(OverlayColor)); -	dirtyFullOverlayScreen(); -} - -void OSystem_IPHONE::grabOverlay(OverlayColor *buf, int pitch) { -	//printf("grabOverlay()\n"); -	int h = _overlayHeight; -	OverlayColor *src = _overlayBuffer; - -	do { -		memcpy(buf, src, _overlayWidth * sizeof(OverlayColor)); -		src += _overlayWidth; -		buf += pitch; -	} while (--h); -} - -void OSystem_IPHONE::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) { -	//printf("copyRectToOverlay(buf, pitch=%i, x=%i, y=%i, w=%i, h=%i)\n", pitch, x, y, w, h); - -	//Clip the coordinates -	if (x < 0) { -		w += x; -		buf -= x; -		x = 0; -	} - -	if (y < 0) { -		h += y; -		buf -= y * pitch; -		y = 0; -	} - -	if (w > _overlayWidth - x) -		w = _overlayWidth - x; - -	if (h > _overlayHeight - y) -		h = _overlayHeight - y; - -	if (w <= 0 || h <= 0) -		return; - -	if (!_fullScreenOverlayIsDirty) { -		_dirtyOverlayRects.push_back(Common::Rect(x, y, x + w, y + h)); -	} - -	OverlayColor *dst = _overlayBuffer + (y * _overlayWidth + x); -	if (_overlayWidth == pitch && pitch == w) -		memcpy(dst, buf, h * w * sizeof(OverlayColor)); -	else { -		do { -			memcpy(dst, buf, w * sizeof(OverlayColor)); -			buf += pitch; -			dst += _overlayWidth; -		} while (--h); -	} -} - -int16 OSystem_IPHONE::getOverlayHeight() { -	return _overlayHeight; -} - -int16 OSystem_IPHONE::getOverlayWidth() { -	return _overlayWidth; -} - -bool OSystem_IPHONE::showMouse(bool visible) { -	bool last = _mouseVisible; -	_mouseVisible = visible; -	iPhone_showCursor(visible); -	_mouseDirty = true; - -	return last; -} - -void OSystem_IPHONE::warpMouse(int x, int y) { -	//printf("warpMouse()\n"); - -	_mouseX = x; -	_mouseY = y; -	_mouseDirty = true; -} - -void OSystem_IPHONE::dirtyFullScreen() { -	if (!_fullScreenIsDirty) { -		_dirtyRects.clear(); -		_dirtyRects.push_back(Common::Rect(0, 0, _screenWidth, _screenHeight)); -		_fullScreenIsDirty = true; -	} -} - -void OSystem_IPHONE::dirtyFullOverlayScreen() { -	if (!_fullScreenOverlayIsDirty) { -		_dirtyOverlayRects.clear(); -		_dirtyOverlayRects.push_back(Common::Rect(0, 0, _overlayWidth, _overlayHeight)); -		_fullScreenOverlayIsDirty = true; -	} -} - -void OSystem_IPHONE::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format) { -	//printf("setMouseCursor(%i, %i, scale %u)\n", hotspotX, hotspotY, cursorTargetScale); - -	if (_mouseBuf != NULL && (_mouseWidth != w || _mouseHeight != h)) { -		free(_mouseBuf); -		_mouseBuf = NULL; -	} - -	if (_mouseBuf == NULL) -		_mouseBuf = (byte *)malloc(w * h); - -	_mouseWidth = w; -	_mouseHeight = h; - -	_mouseHotspotX = hotspotX; -	_mouseHotspotY = hotspotY; - -	_mouseKeyColor = (byte)keycolor; - -	memcpy(_mouseBuf, buf, w * h); - -	_mouseDirty = true; -	_mouseNeedTextureUpdate = true; -} - -void OSystem_IPHONE::setCursorPalette(const byte *colors, uint start, uint num) { -	assert(start + num <= 256); - -	for (uint i = start; i < start + num; ++i, colors += 3) -		_mouseCursorPalette[i] = Graphics::RGBToColor<Graphics::ColorMasks<5551> >(colors[0], colors[1], colors[2]); -	 -	// FIXME: This is just stupid, our client code seems to assume that this -	// automatically enables the cursor palette. -	_mouseCursorPaletteEnabled = true; - -	if (_mouseCursorPaletteEnabled) -		_mouseDirty = _mouseNeedTextureUpdate = true; -} - -void OSystem_IPHONE::updateMouseTexture() { -	int texWidth = getSizeNextPOT(_mouseWidth); -	int texHeight = getSizeNextPOT(_mouseHeight); -	int bufferSize = texWidth * texHeight * sizeof(int16); -	uint16 *mouseBuf = (uint16 *)malloc(bufferSize); -	memset(mouseBuf, 0, bufferSize); - -	const uint16 *palette; -	if (_mouseCursorPaletteEnabled) -		palette = _mouseCursorPalette; -	else -		palette = _gamePaletteRGBA5551; - -	for (uint x = 0; x < _mouseWidth; ++x) { -		for (uint y = 0; y < _mouseHeight; ++y) { -			const byte color = _mouseBuf[y * _mouseWidth + x]; -			if (color != _mouseKeyColor) -				mouseBuf[y * texWidth + x] = palette[color] | 0x1; -			else -				mouseBuf[y * texWidth + x] = 0x0; -		} -	} - -	iPhone_setMouseCursor(mouseBuf, _mouseWidth, _mouseHeight, _mouseHotspotX, _mouseHotspotY); -} diff --git a/backends/platform/iphone/osys_video.mm b/backends/platform/iphone/osys_video.mm new file mode 100644 index 0000000000..2b5e78bd35 --- /dev/null +++ b/backends/platform/iphone/osys_video.mm @@ -0,0 +1,485 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +// Disable symbol overrides so that we can use system headers. +#define FORBIDDEN_SYMBOL_ALLOW_ALL + +#include "osys_main.h" +#include "iphone_video.h" + +#include "graphics/conversion.h" + +void OSystem_IPHONE::initVideoContext() { +	_videoContext = [g_iPhoneViewInstance getVideoContext]; +} + +const OSystem::GraphicsMode *OSystem_IPHONE::getSupportedGraphicsModes() const { +	return s_supportedGraphicsModes; +} + +int OSystem_IPHONE::getDefaultGraphicsMode() const { +	return kGraphicsModeLinear; +} + +bool OSystem_IPHONE::setGraphicsMode(int mode) { +	switch (mode) { +	case kGraphicsModeNone: +	case kGraphicsModeLinear: +		_videoContext->graphicsMode = (GraphicsModes)mode; +		return true; + +	default: +		return false; +	} +} + +int OSystem_IPHONE::getGraphicsMode() const { +	return _videoContext->graphicsMode; +} + +#ifdef USE_RGB_COLOR +Common::List<Graphics::PixelFormat> OSystem_IPHONE::getSupportedFormats() const { +	Common::List<Graphics::PixelFormat> list; +	// RGB565 +	list.push_back(Graphics::createPixelFormat<565>()); +	// CLUT8 +	list.push_back(Graphics::PixelFormat::createFormatCLUT8()); +	return list; +} +#endif + +void OSystem_IPHONE::initSize(uint width, uint height, const Graphics::PixelFormat *format) { +	//printf("initSize(%u, %u, %p)\n", width, height, (const void *)format); + +	_videoContext->screenWidth = width; +	_videoContext->screenHeight = height; +	_videoContext->shakeOffsetY = 0; + +	// In case we use the screen texture as frame buffer we reset the pixels +	// pointer here to avoid freeing the screen texture. +	if (_framebuffer.pixels == _videoContext->screenTexture.pixels) +		_framebuffer.pixels = 0; + +	// Create the screen texture right here. We need to do this here, since +	// when a game requests hi-color mode, we actually set the framebuffer +	// to the texture buffer to avoid an additional copy step. +	[g_iPhoneViewInstance performSelectorOnMainThread:@selector(createScreenTexture) withObject:nil waitUntilDone: YES]; + +	if (!format || format->bytesPerPixel == 1) { +		_framebuffer.create(width, height, Graphics::PixelFormat::createFormatCLUT8()); +	} else { +#if 0 +		printf("bytesPerPixel: %u RGBAlosses: %u,%u,%u,%u RGBAshifts: %u,%u,%u,%u\n", format->bytesPerPixel, +		       format->rLoss, format->gLoss, format->bLoss, format->aLoss, +		       format->rShift, format->gShift, format->bShift, format->aShift); +#endif +		assert(_videoContext->screenTexture.format == *format); +		// We directly draw on the screen texture in hi-color mode. Thus +		// we copy over its settings here and just replace the width and +		// height to avoid any problems. +		_framebuffer = _videoContext->screenTexture; +		_framebuffer.w = width; +		_framebuffer.h = height; +	} + +	_fullScreenIsDirty = false; +	dirtyFullScreen(); +	_mouseCursorPaletteEnabled = false; +} + +void OSystem_IPHONE::beginGFXTransaction() { +} + +OSystem::TransactionError OSystem_IPHONE::endGFXTransaction() { +	_screenChangeCount++; +	updateOutputSurface(); +	[g_iPhoneViewInstance performSelectorOnMainThread:@selector(setGraphicsMode) withObject:nil waitUntilDone: YES]; + +	// TODO: Can we return better error codes? +	return kTransactionSuccess; +} + +void OSystem_IPHONE::updateOutputSurface() { +	[g_iPhoneViewInstance performSelectorOnMainThread:@selector(initSurface) withObject:nil waitUntilDone: YES]; +} + +int16 OSystem_IPHONE::getHeight() { +	return _videoContext->screenHeight; +} + +int16 OSystem_IPHONE::getWidth() { +	return _videoContext->screenWidth; +} + +void OSystem_IPHONE::setPalette(const byte *colors, uint start, uint num) { +	assert(start + num <= 256); +	const byte *b = colors; + +	for (uint i = start; i < start + num; ++i) { +		_gamePalette[i] = Graphics::RGBToColor<Graphics::ColorMasks<565> >(b[0], b[1], b[2]); +		_gamePaletteRGBA5551[i] = Graphics::RGBToColor<Graphics::ColorMasks<5551> >(b[0], b[1], b[2]); +		b += 3; +	} + +	dirtyFullScreen(); +} + +void OSystem_IPHONE::grabPalette(byte *colors, uint start, uint num) { +	assert(start + num <= 256); +	byte *b = colors; + +	for (uint i = start; i < start + num; ++i) { +		Graphics::colorToRGB<Graphics::ColorMasks<565> >(_gamePalette[i], b[0], b[1], b[2]); +		b += 3; +	} +} + +void OSystem_IPHONE::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) { +	//printf("copyRectToScreen(%i, %i, %i, %i)\n", x, y, w, h); +	//Clip the coordinates +	if (x < 0) { +		w += x; +		buf -= x; +		x = 0; +	} + +	if (y < 0) { +		h += y; +		buf -= y * pitch; +		y = 0; +	} + +	if (w > (int)_framebuffer.w - x) { +		w = _framebuffer.w - x; +	} + +	if (h > (int)_framebuffer.h - y) { +		h = _framebuffer.h - y; +	} + +	if (w <= 0 || h <= 0) +		return; + +	if (!_fullScreenIsDirty) { +		_dirtyRects.push_back(Common::Rect(x, y, x + w, y + h)); +	} + +	byte *dst = (byte *)_framebuffer.getBasePtr(x, y); +	if (_framebuffer.pitch == pitch && _framebuffer.w == w) { +		memcpy(dst, buf, h * pitch); +	} else { +		do { +			memcpy(dst, buf, w * _framebuffer.format.bytesPerPixel); +			buf += pitch; +			dst += _framebuffer.pitch; +		} while (--h); +	} +} + +void OSystem_IPHONE::updateScreen() { +	//printf("updateScreen(): %i dirty rects.\n", _dirtyRects.size()); + +	if (_dirtyRects.size() == 0 && _dirtyOverlayRects.size() == 0 && !_mouseDirty) +		return; + +	internUpdateScreen(); +	_mouseDirty = false; +	_fullScreenIsDirty = false; +	_fullScreenOverlayIsDirty = false; + +	iPhone_updateScreen(); +} + +void OSystem_IPHONE::internUpdateScreen() { +	if (_mouseNeedTextureUpdate) { +		updateMouseTexture(); +		_mouseNeedTextureUpdate = false; +	} + +	while (_dirtyRects.size()) { +		Common::Rect dirtyRect = _dirtyRects.remove_at(_dirtyRects.size() - 1); + +		//printf("Drawing: (%i, %i) -> (%i, %i)\n", dirtyRect.left, dirtyRect.top, dirtyRect.right, dirtyRect.bottom); +		drawDirtyRect(dirtyRect); +		// TODO: Implement dirty rect code +		//updateHardwareSurfaceForRect(dirtyRect); +	} + +	if (_videoContext->overlayVisible) { +		// TODO: Implement dirty rect code +		_dirtyOverlayRects.clear(); +		/*while (_dirtyOverlayRects.size()) { +			Common::Rect dirtyRect = _dirtyOverlayRects.remove_at(_dirtyOverlayRects.size() - 1); + +			//printf("Drawing: (%i, %i) -> (%i, %i)\n", dirtyRect.left, dirtyRect.top, dirtyRect.right, dirtyRect.bottom); +			drawDirtyOverlayRect(dirtyRect); +		}*/ +	} +} + +void OSystem_IPHONE::drawDirtyRect(const Common::Rect &dirtyRect) { +	// We only need to do a color look up for CLUT8 +	if (_framebuffer.format.bytesPerPixel != 1) +		return; + +	int h = dirtyRect.bottom - dirtyRect.top; +	int w = dirtyRect.right - dirtyRect.left; + +	const byte *src = (const byte *)_framebuffer.getBasePtr(dirtyRect.left, dirtyRect.top); +	byte *dstRaw = (byte *)_videoContext->screenTexture.getBasePtr(dirtyRect.left, dirtyRect.top); + +	// When we use CLUT8 do a color look up +	for (int y = h; y > 0; y--) { +		uint16 *dst = (uint16 *)dstRaw; +		for (int x = w; x > 0; x--) +			*dst++ = _gamePalette[*src++]; + +		dstRaw += _videoContext->screenTexture.pitch; +		src += _framebuffer.pitch - w; +	} +} + +Graphics::Surface *OSystem_IPHONE::lockScreen() { +	//printf("lockScreen()\n"); +	return &_framebuffer; +} + +void OSystem_IPHONE::unlockScreen() { +	//printf("unlockScreen()\n"); +	dirtyFullScreen(); +} + +void OSystem_IPHONE::setShakePos(int shakeOffset) { +	//printf("setShakePos(%i)\n", shakeOffset); +	_videoContext->shakeOffsetY = shakeOffset; +	[g_iPhoneViewInstance performSelectorOnMainThread:@selector(setViewTransformation) withObject:nil waitUntilDone: YES]; +	// HACK: We use this to force a redraw. +	_mouseDirty = true; +} + +void OSystem_IPHONE::showOverlay() { +	//printf("showOverlay()\n"); +	_videoContext->overlayVisible = true; +	dirtyFullOverlayScreen(); +	updateScreen(); +	[g_iPhoneViewInstance performSelectorOnMainThread:@selector(updateMouseCursorScaling) withObject:nil waitUntilDone: YES]; +	[g_iPhoneViewInstance performSelectorOnMainThread:@selector(clearColorBuffer) withObject:nil waitUntilDone: YES]; +} + +void OSystem_IPHONE::hideOverlay() { +	//printf("hideOverlay()\n"); +	_videoContext->overlayVisible = false; +	_dirtyOverlayRects.clear(); +	dirtyFullScreen(); +	[g_iPhoneViewInstance performSelectorOnMainThread:@selector(updateMouseCursorScaling) withObject:nil waitUntilDone: YES]; +	[g_iPhoneViewInstance performSelectorOnMainThread:@selector(clearColorBuffer) withObject:nil waitUntilDone: YES]; +} + +void OSystem_IPHONE::clearOverlay() { +	//printf("clearOverlay()\n"); +	bzero(_videoContext->overlayTexture.getBasePtr(0, 0), _videoContext->overlayTexture.h * _videoContext->overlayTexture.pitch); +	dirtyFullOverlayScreen(); +} + +void OSystem_IPHONE::grabOverlay(OverlayColor *buf, int pitch) { +	//printf("grabOverlay()\n"); +	int h = _videoContext->overlayHeight; + +	const byte *src = (const byte *)_videoContext->overlayTexture.getBasePtr(0, 0); +	do { +		memcpy(buf, src, _videoContext->overlayWidth * sizeof(OverlayColor)); +		src += _videoContext->overlayTexture.pitch; +		buf += pitch; +	} while (--h); +} + +void OSystem_IPHONE::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) { +	//printf("copyRectToOverlay(buf, pitch=%i, x=%i, y=%i, w=%i, h=%i)\n", pitch, x, y, w, h); + +	//Clip the coordinates +	if (x < 0) { +		w += x; +		buf -= x; +		x = 0; +	} + +	if (y < 0) { +		h += y; +		buf -= y * pitch; +		y = 0; +	} + +	if (w > (int)_videoContext->overlayWidth - x) +		w = _videoContext->overlayWidth - x; + +	if (h > (int)_videoContext->overlayHeight - y) +		h = _videoContext->overlayHeight - y; + +	if (w <= 0 || h <= 0) +		return; + +	if (!_fullScreenOverlayIsDirty) { +		_dirtyOverlayRects.push_back(Common::Rect(x, y, x + w, y + h)); +	} + +	byte *dst = (byte *)_videoContext->overlayTexture.getBasePtr(x, y); +	do {  +		memcpy(dst, buf, w * sizeof(OverlayColor)); +		buf += pitch; +		dst += _videoContext->overlayTexture.pitch; +	} while (--h); +} + +int16 OSystem_IPHONE::getOverlayHeight() { +	return _videoContext->overlayHeight; +} + +int16 OSystem_IPHONE::getOverlayWidth() { +	return _videoContext->overlayWidth; +} + +bool OSystem_IPHONE::showMouse(bool visible) { +	bool last = _videoContext->mouseIsVisible; +	_videoContext->mouseIsVisible = visible; +	_mouseDirty = true; + +	return last; +} + +void OSystem_IPHONE::warpMouse(int x, int y) { +	//printf("warpMouse()\n"); +	_videoContext->mouseX = x; +	_videoContext->mouseY = y; +	[g_iPhoneViewInstance performSelectorOnMainThread:@selector(notifyMouseMove) withObject:nil waitUntilDone: YES]; +	_mouseDirty = true; +} + +void OSystem_IPHONE::dirtyFullScreen() { +	if (!_fullScreenIsDirty) { +		_dirtyRects.clear(); +		_dirtyRects.push_back(Common::Rect(0, 0, _videoContext->screenWidth, _videoContext->screenHeight)); +		_fullScreenIsDirty = true; +	} +} + +void OSystem_IPHONE::dirtyFullOverlayScreen() { +	if (!_fullScreenOverlayIsDirty) { +		_dirtyOverlayRects.clear(); +		_dirtyOverlayRects.push_back(Common::Rect(0, 0, _videoContext->overlayWidth, _videoContext->overlayHeight)); +		_fullScreenOverlayIsDirty = true; +	} +} + +void OSystem_IPHONE::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format) { +	//printf("setMouseCursor(%i, %i, scale %u)\n", hotspotX, hotspotY, cursorTargetScale); + +	const Graphics::PixelFormat pixelFormat = format ? *format : Graphics::PixelFormat::createFormatCLUT8(); +#if 0 +	printf("bytesPerPixel: %u RGBAlosses: %u,%u,%u,%u RGBAshifts: %u,%u,%u,%u\n", pixelFormat.bytesPerPixel, +	       pixelFormat.rLoss, pixelFormat.gLoss, pixelFormat.bLoss, pixelFormat.aLoss, +	       pixelFormat.rShift, pixelFormat.gShift, pixelFormat.bShift, pixelFormat.aShift); +#endif +	assert(pixelFormat.bytesPerPixel == 1 || pixelFormat.bytesPerPixel == 2); + +	if (_mouseBuffer.w != w || _mouseBuffer.h != h || _mouseBuffer.format != pixelFormat || !_mouseBuffer.pixels) +		_mouseBuffer.create(w, h, pixelFormat); + +	_videoContext->mouseWidth = w; +	_videoContext->mouseHeight = h; + +	_videoContext->mouseHotspotX = hotspotX; +	_videoContext->mouseHotspotY = hotspotY; + +	_mouseKeyColor = keycolor; + +	memcpy(_mouseBuffer.getBasePtr(0, 0), buf, h * _mouseBuffer.pitch); + +	_mouseDirty = true; +	_mouseNeedTextureUpdate = true; +} + +void OSystem_IPHONE::setCursorPalette(const byte *colors, uint start, uint num) { +	assert(start + num <= 256); + +	for (uint i = start; i < start + num; ++i, colors += 3) +		_mouseCursorPalette[i] = Graphics::RGBToColor<Graphics::ColorMasks<5551> >(colors[0], colors[1], colors[2]); +	 +	// FIXME: This is just stupid, our client code seems to assume that this +	// automatically enables the cursor palette. +	_mouseCursorPaletteEnabled = true; + +	if (_mouseCursorPaletteEnabled) +		_mouseDirty = _mouseNeedTextureUpdate = true; +} + +void OSystem_IPHONE::updateMouseTexture() { +	uint texWidth = getSizeNextPOT(_videoContext->mouseWidth); +	uint texHeight = getSizeNextPOT(_videoContext->mouseHeight); + +	Graphics::Surface &mouseTexture = _videoContext->mouseTexture; +	if (mouseTexture.w != texWidth || mouseTexture.h != texHeight) +		mouseTexture.create(texWidth, texHeight, Graphics::createPixelFormat<5551>()); + +	if (_mouseBuffer.format.bytesPerPixel == 1) { +		const uint16 *palette; +		if (_mouseCursorPaletteEnabled) +			palette = _mouseCursorPalette; +		else +			palette = _gamePaletteRGBA5551; + +		uint16 *mouseBuf = (uint16 *)mouseTexture.getBasePtr(0, 0); +		for (uint x = 0; x < _videoContext->mouseWidth; ++x) { +			for (uint y = 0; y < _videoContext->mouseHeight; ++y) { +				const byte color = *(const byte *)_mouseBuffer.getBasePtr(x, y); +				if (color != _mouseKeyColor) +					mouseBuf[y * texWidth + x] = palette[color] | 0x1; +				else +					mouseBuf[y * texWidth + x] = 0x0; +			} +		} +	} else { +		if (crossBlit((byte *)mouseTexture.getBasePtr(0, 0), (const byte *)_mouseBuffer.getBasePtr(0, 0), mouseTexture.pitch, +			          _mouseBuffer.pitch, _mouseBuffer.w, _mouseBuffer.h, mouseTexture.format, _mouseBuffer.format)) { +			if (!_mouseBuffer.format.aBits()) { +				// Apply color keying since the original cursor had no alpha channel. +				const uint16 *src = (const uint16 *)_mouseBuffer.getBasePtr(0, 0); +				uint8 *dstRaw = (uint8 *)mouseTexture.getBasePtr(0, 0); + +				for (uint y = 0; y < _mouseBuffer.h; ++y, dstRaw += mouseTexture.pitch) { +					uint16 *dst = (uint16 *)dstRaw; +					for (uint x = 0; x < _mouseBuffer.w; ++x, ++dst) { +						if (*src++ == _mouseKeyColor) +							*dst &= ~1; +						else +							*dst |= 1; +					} +				} +			} +		} else { +			// TODO: Log this! +			// Make the cursor all transparent... we really need a better fallback ;-). +			memset(mouseTexture.getBasePtr(0, 0), 0, mouseTexture.h * mouseTexture.pitch); +		} +	} + +	[g_iPhoneViewInstance performSelectorOnMainThread:@selector(updateMouseCursor) withObject:nil waitUntilDone: YES]; +} diff --git a/backends/platform/maemo/maemo-common.h b/backends/platform/maemo/maemo-common.h index 453c70c45f..0442b9c0ae 100644 --- a/backends/platform/maemo/maemo-common.h +++ b/backends/platform/maemo/maemo-common.h @@ -43,15 +43,6 @@ struct Model {  	bool hasMenuKey;  }; -static const Model models[] = { -	{"SU-18", kModelType770, "770", false, true}, -	{"RX-34", kModelTypeN800, "N800", false, true}, -	{"RX-44", kModelTypeN810, "N810", true, true}, -	{"RX-48", kModelTypeN810, "N810W", true, true}, -	{"RX-51", kModelTypeN900, "N900", true, false}, -	{0, kModelTypeInvalid, 0, true, true} -}; -  enum CustomEventType {  	kEventClickMode = 1,  	kEventInvalid = 0 diff --git a/backends/platform/maemo/maemo.cpp b/backends/platform/maemo/maemo.cpp index 209e527e3f..a127926eb0 100644 --- a/backends/platform/maemo/maemo.cpp +++ b/backends/platform/maemo/maemo.cpp @@ -156,10 +156,19 @@ void OSystem_SDL_Maemo::setWindowCaption(const char *caption) {  	setXWindowName(cap.c_str());  } +static const Model models[] = { +	{"SU-18", kModelType770, "770", false, true}, +	{"RX-34", kModelTypeN800, "N800", false, true}, +	{"RX-44", kModelTypeN810, "N810", true, true}, +	{"RX-48", kModelTypeN810, "N810W", true, true}, +	{"RX-51", kModelTypeN900, "N900", true, false}, +	{0, kModelTypeInvalid, 0, true, true} +}; +  const Maemo::Model OSystem_SDL_Maemo::detectModel() {  	Common::String deviceHwId = Common::String(getenv("SCUMMVM_MAEMO_DEVICE"));  	const Model *model; -	for (model = models; model->hwId; model++) { +	for (model = models; model->hwId; ++model) {  		if (deviceHwId.equals(model->hwId))  			return *model;  	} diff --git a/base/commandLine.cpp b/base/commandLine.cpp index aa589ed15f..08838167e9 100644 --- a/base/commandLine.cpp +++ b/base/commandLine.cpp @@ -33,9 +33,10 @@  #include "base/version.h"  #include "common/config-manager.h" +#include "common/fs.h" +#include "common/rendermode.h"  #include "common/system.h"  #include "common/textconsole.h" -#include "common/fs.h"  #include "gui/ThemeEngine.h" diff --git a/base/main.cpp b/base/main.cpp index 5311b6fd78..5e9f1d4f25 100644 --- a/base/main.cpp +++ b/base/main.cpp @@ -264,9 +264,7 @@ static void setupKeymapper(OSystem &system) {  	Keymapper *mapper = system.getEventManager()->getKeymapper(); -	HardwareKeySet *keySet; - -	keySet = system.getHardwareKeySet(); +	HardwareKeySet *keySet = system.getHardwareKeySet();  	// Query backend for hardware keys and register them  	mapper->registerHardwareKeySet(keySet); diff --git a/common/gui_options.cpp b/common/gui_options.cpp new file mode 100644 index 0000000000..5b7d939dc4 --- /dev/null +++ b/common/gui_options.cpp @@ -0,0 +1,132 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public 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/gui_options.h" + +#include "common/config-manager.h" +#include "common/str.h" + +namespace Common { + +const struct GameOpt { +	const char *option; +	const char *desc; +} g_gameOptions[] = { +	{ GUIO_NOSUBTITLES,  "sndNoSubs" }, +	{ GUIO_NOMUSIC,      "sndNoMusic" }, +	{ GUIO_NOSPEECH,     "sndNoSpeech" }, +	{ GUIO_NOSFX,        "sndNoSFX" }, +	{ GUIO_NOMIDI,       "sndNoMIDI" }, + +	{ GUIO_NOLAUNCHLOAD, "launchNoLoad" }, + +	{ GUIO_MIDIPCSPK,    "midiPCSpk" }, +	{ GUIO_MIDICMS,      "midiCMS" }, +	{ GUIO_MIDIPCJR,     "midiPCJr" }, +	{ GUIO_MIDIADLIB,    "midiAdLib" }, +	{ GUIO_MIDIC64,      "midiC64" }, +	{ GUIO_MIDIAMIGA,    "midiAmiga" }, +	{ GUIO_MIDIAPPLEIIGS,"midiAppleIIgs" }, +	{ GUIO_MIDITOWNS,    "midiTowns" }, +	{ GUIO_MIDIPC98,     "midiPC98" }, +	{ GUIO_MIDIMT32,     "midiMt32" }, +	{ GUIO_MIDIGM,       "midiGM" }, + +	{ GUIO_NOASPECT,     "noAspect" }, +	{ GUIO_EGAUNDITHER,  "egaUndither" }, + +	{ GUIO_RENDERHERCGREEN,	"hercGreen" }, +	{ GUIO_RENDERHERCAMBER,	"hercAmber" }, +	{ GUIO_RENDERCGA,		"cga" }, +	{ GUIO_RENDEREGA,		"ega" }, +	{ GUIO_RENDERVGA,		"vga" }, +	{ GUIO_RENDERAMIGA,		"amiga" }, +	{ GUIO_RENDERFMTOWNS,	"fmtowns" }, +	{ GUIO_RENDERPC9821,	"pc9821" }, +	{ GUIO_RENDERPC9801,	"pc9801" }, + +	{ GUIO_NONE, 0 } +}; + +bool checkGameGUIOption(const String &option, const String &str) { +	for (int i = 0; g_gameOptions[i].desc; i++) { +		if (option.contains(g_gameOptions[i].option)) { +			if (str.contains(g_gameOptions[i].desc)) +				return true; +			else +				return false; +		} +	} +	return false; +} + +bool checkGameGUIOptionLanguage(Language lang, const String &str) { +	if (!str.contains("lang_")) // If no languages are specified +		return true; + +	if (str.contains(getGameGUIOptionsDescriptionLanguage(lang))) +		return true; + +	return false; +} + +const String getGameGUIOptionsDescriptionLanguage(Language lang) { +	if (lang == UNK_LANG) +		return ""; + +	return String("lang_") + getLanguageDescription(lang); +} + +String parseGameGUIOptions(const String &str) { +	String res; + +	for (int i = 0; g_gameOptions[i].desc; i++) +		if (str.contains(g_gameOptions[i].desc)) +			res += g_gameOptions[i].option; + +	return res; +} + +const String getGameGUIOptionsDescription(const String &options) { +	String res; + +	for (int i = 0; g_gameOptions[i].desc; i++) +		if (options.contains(g_gameOptions[i].option[0])) +			res += String(g_gameOptions[i].desc) + " "; + +	res.trim(); + +	return res; +} + +void updateGameGUIOptions(const String &options, const String &langOption) { +	const String newOptionString = getGameGUIOptionsDescription(options) + " " + langOption; + +	if ((!options.empty() && !ConfMan.hasKey("guioptions")) || +	    (ConfMan.hasKey("guioptions") && ConfMan.get("guioptions") != newOptionString)) { +		ConfMan.set("guioptions", newOptionString); +		ConfMan.flushToDisk(); +	} +} + + +} // End of namespace Common diff --git a/common/gui_options.h b/common/gui_options.h new file mode 100644 index 0000000000..5649f1103d --- /dev/null +++ b/common/gui_options.h @@ -0,0 +1,88 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef COMMON_GUI_OPTIONS_H +#define COMMON_GUI_OPTIONS_H + +#include "common/language.h" + +#define GUIO_NONE			"\000" +#define GUIO_NOSUBTITLES	"\001" +#define GUIO_NOMUSIC		"\002" +#define GUIO_NOSPEECH		"\003" +#define GUIO_NOSFX			"\004" +#define GUIO_NOMIDI			"\005" +#define GUIO_NOLAUNCHLOAD	"\006" + +#define GUIO_MIDIPCSPK		"\007" +#define GUIO_MIDICMS		"\010" +#define GUIO_MIDIPCJR		"\011" +#define GUIO_MIDIADLIB		"\012" +#define GUIO_MIDIC64        "\013" +#define GUIO_MIDIAMIGA      "\014" +#define GUIO_MIDIAPPLEIIGS  "\015" +#define GUIO_MIDITOWNS		"\016" +#define GUIO_MIDIPC98		"\017" +#define GUIO_MIDIMT32		"\020" +#define GUIO_MIDIGM			"\021" + +#define GUIO_NOASPECT		"\022" +#define GUIO_EGAUNDITHER	"\023" + +#define GUIO_RENDERHERCGREEN	"\030" +#define GUIO_RENDERHERCAMBER	"\031" +#define GUIO_RENDERCGA		"\032" +#define GUIO_RENDEREGA		"\033" +#define GUIO_RENDERVGA		"\034" +#define GUIO_RENDERAMIGA	"\035" +#define GUIO_RENDERFMTOWNS	"\036" +#define GUIO_RENDERPC9821	"\037" +#define GUIO_RENDERPC9801	"\040" + +#define GUIO0() (GUIO_NONE) +#define GUIO1(a) (a) +#define GUIO2(a,b) (a b) +#define GUIO3(a,b,c) (a b c) +#define GUIO4(a,b,c,d) (a b c d) +#define GUIO5(a,b,c,d,e) (a b c d e) +#define GUIO6(a,b,c,d,e,f) (a b c d e f) + +namespace Common { + + +bool checkGameGUIOption(const String &option, const String &str); +bool checkGameGUIOptionLanguage(Common::Language lang, const String &str); +String parseGameGUIOptions(const String &str); +const String getGameGUIOptionsDescription(const String &options); +const String getGameGUIOptionsDescriptionLanguage(Common::Language lang); + +/** + * Updates the GUI options of the current config manager + * domain, when they differ to the ones passed as + * parameter. + */ +void updateGameGUIOptions(const String &options, const String &langOption); + + +} // End of namespace Common + +#endif diff --git a/common/language.cpp b/common/language.cpp new file mode 100644 index 0000000000..1de01b0207 --- /dev/null +++ b/common/language.cpp @@ -0,0 +1,107 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "common/language.h" +#include "common/str.h" + +namespace Common { + +const LanguageDescription g_languages[] = { +	{ "zh-cn", "zh_CN", "Chinese (China)", ZH_CNA }, +	{    "zh", "zh_TW", "Chinese (Taiwan)", ZH_TWN }, +	{    "cz", "cs_CZ", "Czech", CZ_CZE }, +	{    "nl", "nl_NL", "Dutch", NL_NLD }, +	{    "en",    "en", "English", EN_ANY }, // Generic English (when only one game version exist) +	{    "gb", "en_GB", "English (GB)", EN_GRB }, +	{    "us", "en_US", "English (US)", EN_USA }, +	{    "fr", "fr_FR", "French", FR_FRA }, +	{    "de", "de_DE", "German", DE_DEU }, +	{    "gr", "el_GR", "Greek", GR_GRE }, +	{    "he", "he_IL", "Hebrew", HE_ISR }, +	{    "hb", "he_IL", "Hebrew", HE_ISR }, // Deprecated +	{    "hr", "hr_HR", "Croatian", HR_HRV }, +	{    "hu", "hu_HU", "Hungarian", HU_HUN }, +	{    "it", "it_IT", "Italian", IT_ITA }, +	{    "jp", "ja_JP", "Japanese", JA_JPN }, +	{    "kr", "ko_KR", "Korean", KO_KOR }, +	{    "nb", "nb_NO", "Norwegian Bokm\xE5l", NB_NOR }, // TODO Someone should verify the unix locale +	{    "pl", "pl_PL", "Polish", PL_POL }, +	{    "br", "pt_BR", "Portuguese", PT_BRA }, +	{    "ru", "ru_RU", "Russian", RU_RUS }, +	{    "es", "es_ES", "Spanish", ES_ESP }, +	{    "se", "sv_SE", "Swedish", SE_SWE }, +	{       0,       0, 0, UNK_LANG } +}; + +Language parseLanguage(const String &str) { +	if (str.empty()) +		return UNK_LANG; + +	const LanguageDescription *l = g_languages; +	for (; l->code; ++l) { +		if (str.equalsIgnoreCase(l->code)) +			return l->id; +	} + +	return UNK_LANG; +} + +Language parseLanguageFromLocale(const char *locale) { +	if (!locale || !*locale) +		return UNK_LANG; + +	const LanguageDescription *l = g_languages; +	for (; l->code; ++l) { +		if (!strcmp(l->unixLocale, locale)) +			return l->id; +	} + +	return UNK_LANG; +} + +const char *getLanguageCode(Language id) { +	const LanguageDescription *l = g_languages; +	for (; l->code; ++l) { +		if (l->id == id) +			return l->code; +	} +	return 0; +} + +const char *getLanguageLocale(Language id) { +	const LanguageDescription *l = g_languages; +	for (; l->code; ++l) { +		if (l->id == id) +			return l->unixLocale; +	} +	return 0; +} + +const char *getLanguageDescription(Language id) { +	const LanguageDescription *l = g_languages; +	for (; l->code; ++l) { +		if (l->id == id) +			return l->description; +	} +	return 0; +} + +} // End of namespace Common diff --git a/common/language.h b/common/language.h new file mode 100644 index 0000000000..b83f0d34fd --- /dev/null +++ b/common/language.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 COMMON_LANGUAGE_H +#define COMMON_LANGUAGE_H + +#include "common/scummsys.h" + +namespace Common { + +class String; + +/** + * List of game language. + */ +enum Language { +	ZH_CNA, +	ZH_TWN, +	CZ_CZE, +	NL_NLD, +	EN_ANY,     // Generic English (when only one game version exist) +	EN_GRB, +	EN_USA, +	FR_FRA, +	DE_DEU, +	GR_GRE, +	HE_ISR, +	HR_HRV, +	HU_HUN, +	IT_ITA, +	JA_JPN, +	KO_KOR, +	NB_NOR, +	PL_POL, +	PT_BRA, +	RU_RUS, +	ES_ESP, +	SE_SWE, + +	UNK_LANG = -1	// Use default language (i.e. none specified) +}; + +struct LanguageDescription { +	const char *code; +	const char *unixLocale; +	const char *description; +	Language id; +}; + +extern const LanguageDescription g_languages[]; + + +/** Convert a string containing a language name into a Language enum value. */ +extern Language parseLanguage(const String &str); +extern Language parseLanguageFromLocale(const char *locale); +extern const char *getLanguageCode(Language id); +extern const char *getLanguageLocale(Language id); +extern const char *getLanguageDescription(Language id); + +}	// End of namespace Common + +#endif diff --git a/common/localization.h b/common/localization.h index 3945cf5fab..e908485b99 100644 --- a/common/localization.h +++ b/common/localization.h @@ -22,7 +22,7 @@  #ifndef COMMON_LOCALIZATION_H  #define COMMON_LOCALIZATION_H -#include "common/util.h" +#include "common/language.h"  #include "common/keyboard.h"  namespace Common { diff --git a/common/module.mk b/common/module.mk index ae5e41cb8c..b4928fabda 100644 --- a/common/module.mk +++ b/common/module.mk @@ -12,16 +12,20 @@ MODULE_OBJS := \  	EventRecorder.o \  	file.o \  	fs.o \ +	gui_options.o \  	hashmap.o \  	iff_container.o \ +	language.o \  	localization.o \  	macresman.o \  	memorypool.o \  	md5.o \  	mutex.o \ +	platform.o \  	quicktime.o \  	random.o \  	rational.o \ +	rendermode.o \  	str.o \  	stream.o \  	system.o \ diff --git a/common/platform.cpp b/common/platform.cpp new file mode 100644 index 0000000000..9986048b48 --- /dev/null +++ b/common/platform.cpp @@ -0,0 +1,107 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "common/platform.h" +#include "common/str.h" + +namespace Common { + +const PlatformDescription g_platforms[] = { +	{ "2gs", "2gs", "2gs", "Apple IIgs", kPlatformApple2GS }, +	{ "3do", "3do", "3do", "3DO", kPlatform3DO }, +	{ "acorn", "acorn", "acorn", "Acorn", kPlatformAcorn }, +	{ "amiga", "ami", "amiga", "Amiga", kPlatformAmiga }, +	{ "atari", "atari-st", "st", "Atari ST", kPlatformAtariST }, +	{ "c64", "c64", "c64", "Commodore 64", kPlatformC64 }, +	{ "pc", "dos", "ibm", "DOS", kPlatformPC }, +	{ "pc98", "pc98", "pc98", "PC-98", kPlatformPC98 }, +	{ "wii", "wii", "wii", "Nintendo Wii", kPlatformWii }, +	{ "coco3", "coco3", "coco3", "CoCo3", kPlatformCoCo3 }, + +	// The 'official' spelling seems to be "FM-TOWNS" (e.g. in the Indy4 demo). +	// However, on the net many variations can be seen, like "FMTOWNS", +	// "FM TOWNS", "FmTowns", etc. +	{ "fmtowns", "towns", "fm", "FM-TOWNS", kPlatformFMTowns }, + +	{ "linux", "linux", "linux", "Linux", kPlatformLinux }, +	{ "macintosh", "mac", "mac", "Macintosh", kPlatformMacintosh }, +	{ "pce", "pce", "pce", "PC-Engine", kPlatformPCEngine }, +	{ "nes", "nes", "nes", "NES", kPlatformNES }, +	{ "segacd", "segacd", "sega", "SegaCD", kPlatformSegaCD }, +	{ "windows", "win", "win", "Windows", kPlatformWindows }, +	{ "playstation", "psx", "psx", "Sony PlayStation", kPlatformPSX }, +	{ "cdi", "cdi", "cdi", "Philips CD-i", kPlatformCDi }, +	{ "ios", "ios", "ios", "Apple iOS", kPlatformIOS }, + +	{ 0, 0, 0, "Default", kPlatformUnknown } +}; + +Platform parsePlatform(const String &str) { +	if (str.empty()) +		return kPlatformUnknown; + +	// Handle some special case separately, for compatibility with old config +	// files. +	if (str == "1") +		return kPlatformAmiga; +	else if (str == "2") +		return kPlatformAtariST; +	else if (str == "3") +		return kPlatformMacintosh; + +	const PlatformDescription *l = g_platforms; +	for (; l->code; ++l) { +		if (str.equalsIgnoreCase(l->code) || str.equalsIgnoreCase(l->code2) || str.equalsIgnoreCase(l->abbrev)) +			return l->id; +	} + +	return kPlatformUnknown; +} + + +const char *getPlatformCode(Platform id) { +	const PlatformDescription *l = g_platforms; +	for (; l->code; ++l) { +		if (l->id == id) +			return l->code; +	} +	return 0; +} + +const char *getPlatformAbbrev(Platform id) { +	const PlatformDescription *l = g_platforms; +	for (; l->code; ++l) { +		if (l->id == id) +			return l->abbrev; +	} +	return 0; +} + +const char *getPlatformDescription(Platform id) { +	const PlatformDescription *l = g_platforms; +	for (; l->code; ++l) { +		if (l->id == id) +			return l->description; +	} +	return l->description; +} + +} // End of namespace Common diff --git a/common/platform.h b/common/platform.h new file mode 100644 index 0000000000..1891c7096d --- /dev/null +++ b/common/platform.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 COMMON_PLATFORM_H +#define COMMON_PLATFORM_H + +#include "common/scummsys.h" + +namespace Common { + +class String; + +/** + * List of game platforms. Specifying a platform for a target can be used to + * give the game engines a hint for which platform the game data file are. + * This may be optional or required, depending on the game engine and the + * game in question. + */ +enum Platform { +	kPlatformPC, +	kPlatformAmiga, +	kPlatformAtariST, +	kPlatformMacintosh, +	kPlatformFMTowns, +	kPlatformWindows, +	kPlatformNES, +	kPlatformC64, +	kPlatformCoCo3, +	kPlatformLinux, +	kPlatformAcorn, +	kPlatformSegaCD, +	kPlatform3DO, +	kPlatformPCEngine, +	kPlatformApple2GS, +	kPlatformPC98, +	kPlatformWii, +	kPlatformPSX, +	kPlatformCDi, +	kPlatformIOS, + +	kPlatformUnknown = -1 +}; + +struct PlatformDescription { +	const char *code; +	const char *code2; +	const char *abbrev; +	const char *description; +	Platform id; +}; + +extern const PlatformDescription g_platforms[]; + +/** Convert a string containing a platform name into a Platform enum value. */ +extern Platform parsePlatform(const String &str); +extern const char *getPlatformCode(Platform id); +extern const char *getPlatformAbbrev(Platform id); +extern const char *getPlatformDescription(Platform id); + +}	// End of namespace Common + +#endif diff --git a/common/rendermode.cpp b/common/rendermode.cpp new file mode 100644 index 0000000000..62b67faee5 --- /dev/null +++ b/common/rendermode.cpp @@ -0,0 +1,81 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public 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/rendermode.h" + +#include "common/str.h" +#include "common/translation.h" + + +namespace Common { + + +const RenderModeDescription g_renderModes[] = { +	// I18N: Hercules is graphics card name +	{ "hercGreen", _s("Hercules Green"), kRenderHercG }, +	{ "hercAmber", _s("Hercules Amber"), kRenderHercA }, +	{ "cga", "CGA", kRenderCGA }, +	{ "ega", "EGA", kRenderEGA }, +	{ "vga", "VGA", kRenderVGA }, +	{ "amiga", "Amiga", kRenderAmiga }, +	{ "fmtowns", "FM-Towns", kRenderFMTowns }, +	{ "pc9821", "PC-9821 (256 Colors)", kRenderPC9821 }, +	{ "pc9801", "PC-9801 (16 Colors)", kRenderPC9801 }, +	{0, 0, kRenderDefault} +}; + +DECLARE_TRANSLATION_ADDITIONAL_CONTEXT("Hercules Green", "lowres") +DECLARE_TRANSLATION_ADDITIONAL_CONTEXT("Hercules Amber", "lowres") + +RenderMode parseRenderMode(const String &str) { +	if (str.empty()) +		return kRenderDefault; + +	const RenderModeDescription *l = g_renderModes; +	for (; l->code; ++l) { +		if (str.equalsIgnoreCase(l->code)) +			return l->id; +	} + +	return kRenderDefault; +} + +const char *getRenderModeCode(RenderMode id) { +	const RenderModeDescription *l = g_renderModes; +	for (; l->code; ++l) { +		if (l->id == id) +			return l->code; +	} +	return 0; +} + +const char *getRenderModeDescription(RenderMode id) { +	const RenderModeDescription *l = g_renderModes; +	for (; l->code; ++l) { +		if (l->id == id) +			return l->description; +	} +	return 0; +} + + +} // End of namespace Common diff --git a/common/rendermode.h b/common/rendermode.h new file mode 100644 index 0000000000..c2fece77ee --- /dev/null +++ b/common/rendermode.h @@ -0,0 +1,67 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef COMMON_RENDERMODE_H +#define COMMON_RENDERMODE_H + +#include "common/scummsys.h" + +namespace Common { + +class String; + +/** + * List of render modes. It specifies which original graphics mode + * to use. Some targets used postprocessing dithering routines for + * reducing color depth of final image which let it to be rendered on + * such low-level adapters as CGA or Hercules. + */ +enum RenderMode { +	kRenderDefault = 0, +	kRenderVGA = 1, +	kRenderEGA = 2, +	kRenderCGA = 3, +	kRenderHercG = 4, +	kRenderHercA = 5, +	kRenderAmiga = 6, +	kRenderFMTowns = 7, +	kRenderPC9821 = 8, +	kRenderPC9801 = 9 +}; + +struct RenderModeDescription { +	const char *code; +	const char *description; +	RenderMode id; +}; + +extern const RenderModeDescription g_renderModes[]; + +/** Convert a string containing a render mode name into a RenderingMode enum value. */ +extern RenderMode parseRenderMode(const String &str); +extern const char *getRenderModeCode(RenderMode id); +extern const char *getRenderModeDescription(RenderMode id); + + +} // End of namespace Common + +#endif diff --git a/common/util.cpp b/common/util.cpp index 05d29fac94..4d9ff11c5c 100644 --- a/common/util.cpp +++ b/common/util.cpp @@ -29,8 +29,6 @@  #include "common/util.h" -#include "common/translation.h" -#include "common/config-manager.h"  #include "common/debug.h"  namespace Common { @@ -112,321 +110,6 @@ bool parseBool(const String &val, bool &valAsBool) {  #pragma mark - -const LanguageDescription g_languages[] = { -	{ "zh-cn", "zh_CN", "Chinese (China)", ZH_CNA }, -	{    "zh", "zh_TW", "Chinese (Taiwan)", ZH_TWN }, -	{    "cz", "cs_CZ", "Czech", CZ_CZE }, -	{    "nl", "nl_NL", "Dutch", NL_NLD }, -	{    "en",    "en", "English", EN_ANY }, // Generic English (when only one game version exist) -	{    "gb", "en_GB", "English (GB)", EN_GRB }, -	{    "us", "en_US", "English (US)", EN_USA }, -	{    "fr", "fr_FR", "French", FR_FRA }, -	{    "de", "de_DE", "German", DE_DEU }, -	{    "gr", "el_GR", "Greek", GR_GRE }, -	{    "he", "he_IL", "Hebrew", HE_ISR }, -	{    "hb", "he_IL", "Hebrew", HE_ISR }, // Deprecated -	{    "hr", "hr_HR", "Croatian", HR_HRV }, -	{    "hu", "hu_HU", "Hungarian", HU_HUN }, -	{    "it", "it_IT", "Italian", IT_ITA }, -	{    "jp", "ja_JP", "Japanese", JA_JPN }, -	{    "kr", "ko_KR", "Korean", KO_KOR }, -	{    "nb", "nb_NO", "Norwegian Bokm\xE5l", NB_NOR }, // TODO Someone should verify the unix locale -	{    "pl", "pl_PL", "Polish", PL_POL }, -	{    "br", "pt_BR", "Portuguese", PT_BRA }, -	{    "ru", "ru_RU", "Russian", RU_RUS }, -	{    "es", "es_ES", "Spanish", ES_ESP }, -	{    "se", "sv_SE", "Swedish", SE_SWE }, -	{       0,       0, 0, UNK_LANG } -}; - -Language parseLanguage(const String &str) { -	if (str.empty()) -		return UNK_LANG; - -	const LanguageDescription *l = g_languages; -	for (; l->code; ++l) { -		if (str.equalsIgnoreCase(l->code)) -			return l->id; -	} - -	return UNK_LANG; -} - -Language parseLanguageFromLocale(const char *locale) { -	if (!locale || !*locale) -		return UNK_LANG; - -	const LanguageDescription *l = g_languages; -	for (; l->code; ++l) { -		if (!strcmp(l->unixLocale, locale)) -			return l->id; -	} - -	return UNK_LANG; -} - -const char *getLanguageCode(Language id) { -	const LanguageDescription *l = g_languages; -	for (; l->code; ++l) { -		if (l->id == id) -			return l->code; -	} -	return 0; -} - -const char *getLanguageLocale(Language id) { -	const LanguageDescription *l = g_languages; -	for (; l->code; ++l) { -		if (l->id == id) -			return l->unixLocale; -	} -	return 0; -} - -const char *getLanguageDescription(Language id) { -	const LanguageDescription *l = g_languages; -	for (; l->code; ++l) { -		if (l->id == id) -			return l->description; -	} -	return 0; -} - - -#pragma mark - - - -const PlatformDescription g_platforms[] = { -	{ "2gs", "2gs", "2gs", "Apple IIgs", kPlatformApple2GS }, -	{ "3do", "3do", "3do", "3DO", kPlatform3DO }, -	{ "acorn", "acorn", "acorn", "Acorn", kPlatformAcorn }, -	{ "amiga", "ami", "amiga", "Amiga", kPlatformAmiga }, -	{ "atari", "atari-st", "st", "Atari ST", kPlatformAtariST }, -	{ "c64", "c64", "c64", "Commodore 64", kPlatformC64 }, -	{ "pc", "dos", "ibm", "DOS", kPlatformPC }, -	{ "pc98", "pc98", "pc98", "PC-98", kPlatformPC98 }, -	{ "wii", "wii", "wii", "Nintendo Wii", kPlatformWii }, -	{ "coco3", "coco3", "coco3", "CoCo3", kPlatformCoCo3 }, - -	// The 'official' spelling seems to be "FM-TOWNS" (e.g. in the Indy4 demo). -	// However, on the net many variations can be seen, like "FMTOWNS", -	// "FM TOWNS", "FmTowns", etc. -	{ "fmtowns", "towns", "fm", "FM-TOWNS", kPlatformFMTowns }, - -	{ "linux", "linux", "linux", "Linux", kPlatformLinux }, -	{ "macintosh", "mac", "mac", "Macintosh", kPlatformMacintosh }, -	{ "pce", "pce", "pce", "PC-Engine", kPlatformPCEngine }, -	{ "nes", "nes", "nes", "NES", kPlatformNES }, -	{ "segacd", "segacd", "sega", "SegaCD", kPlatformSegaCD }, -	{ "windows", "win", "win", "Windows", kPlatformWindows }, -	{ "playstation", "psx", "psx", "Sony PlayStation", kPlatformPSX }, -	{ "cdi", "cdi", "cdi", "Philips CD-i", kPlatformCDi }, -	{ "ios", "ios", "ios", "Apple iOS", kPlatformIOS }, - -	{ 0, 0, 0, "Default", kPlatformUnknown } -}; - -Platform parsePlatform(const String &str) { -	if (str.empty()) -		return kPlatformUnknown; - -	// Handle some special case separately, for compatibility with old config -	// files. -	if (str == "1") -		return kPlatformAmiga; -	else if (str == "2") -		return kPlatformAtariST; -	else if (str == "3") -		return kPlatformMacintosh; - -	const PlatformDescription *l = g_platforms; -	for (; l->code; ++l) { -		if (str.equalsIgnoreCase(l->code) || str.equalsIgnoreCase(l->code2) || str.equalsIgnoreCase(l->abbrev)) -			return l->id; -	} - -	return kPlatformUnknown; -} - - -const char *getPlatformCode(Platform id) { -	const PlatformDescription *l = g_platforms; -	for (; l->code; ++l) { -		if (l->id == id) -			return l->code; -	} -	return 0; -} - -const char *getPlatformAbbrev(Platform id) { -	const PlatformDescription *l = g_platforms; -	for (; l->code; ++l) { -		if (l->id == id) -			return l->abbrev; -	} -	return 0; -} - -const char *getPlatformDescription(Platform id) { -	const PlatformDescription *l = g_platforms; -	for (; l->code; ++l) { -		if (l->id == id) -			return l->description; -	} -	return l->description; -} - - -#pragma mark - - - -const RenderModeDescription g_renderModes[] = { -	// I18N: Hercules is graphics card name -	{ "hercGreen", _s("Hercules Green"), kRenderHercG }, -	{ "hercAmber", _s("Hercules Amber"), kRenderHercA }, -	{ "cga", "CGA", kRenderCGA }, -	{ "ega", "EGA", kRenderEGA }, -	{ "vga", "VGA", kRenderVGA }, -	{ "amiga", "Amiga", kRenderAmiga }, -	{ "fmtowns", "FM-Towns", kRenderFMTowns }, -	{ "pc98", "PC-98", kRenderPC98 }, -	{0, 0, kRenderDefault} -}; - -DECLARE_TRANSLATION_ADDITIONAL_CONTEXT("Hercules Green", "lowres") -DECLARE_TRANSLATION_ADDITIONAL_CONTEXT("Hercules Amber", "lowres") - -RenderMode parseRenderMode(const String &str) { -	if (str.empty()) -		return kRenderDefault; - -	const RenderModeDescription *l = g_renderModes; -	for (; l->code; ++l) { -		if (str.equalsIgnoreCase(l->code)) -			return l->id; -	} - -	return kRenderDefault; -} - -const char *getRenderModeCode(RenderMode id) { -	const RenderModeDescription *l = g_renderModes; -	for (; l->code; ++l) { -		if (l->id == id) -			return l->code; -	} -	return 0; -} - -const char *getRenderModeDescription(RenderMode id) { -	const RenderModeDescription *l = g_renderModes; -	for (; l->code; ++l) { -		if (l->id == id) -			return l->description; -	} -	return 0; -} - -const struct GameOpt { -	const char *option; -	const char *desc; -} g_gameOptions[] = { -	{ GUIO_NOSUBTITLES,  "sndNoSubs" }, -	{ GUIO_NOMUSIC,      "sndNoMusic" }, -	{ GUIO_NOSPEECH,     "sndNoSpeech" }, -	{ GUIO_NOSFX,        "sndNoSFX" }, -	{ GUIO_NOMIDI,       "sndNoMIDI" }, - -	{ GUIO_NOLAUNCHLOAD, "launchNoLoad" }, - -	{ GUIO_MIDIPCSPK,    "midiPCSpk" }, -	{ GUIO_MIDICMS,      "midiCMS" }, -	{ GUIO_MIDIPCJR,     "midiPCJr" }, -	{ GUIO_MIDIADLIB,    "midiAdLib" }, -	{ GUIO_MIDIC64,      "midiC64" }, -	{ GUIO_MIDIAMIGA,    "midiAmiga" }, -	{ GUIO_MIDIAPPLEIIGS,"midiAppleIIgs" }, -	{ GUIO_MIDITOWNS,    "midiTowns" }, -	{ GUIO_MIDIPC98,     "midiPC98" }, -	{ GUIO_MIDIMT32,     "midiMt32" }, -	{ GUIO_MIDIGM,       "midiGM" }, - -	{ GUIO_NOASPECT,     "noAspect" }, -	{ GUIO_EGAUNDITHER,  "egaUndither" }, - -	{ GUIO_RENDERHERCGREEN,	"hercGreen" }, -	{ GUIO_RENDERHERCAMBER,	"hercAmber" }, -	{ GUIO_RENDERCGA,		"cga" }, -	{ GUIO_RENDEREGA,		"ega" }, -	{ GUIO_RENDERVGA,		"vga" }, -	{ GUIO_RENDERAMIGA,		"amiga" }, -	{ GUIO_RENDERFMTOWNS,	"fmtowns" }, -	{ GUIO_RENDERPC98,		"pc98" }, - -	{ GUIO_NONE, 0 } -}; - -bool checkGameGUIOption(const String &option, const String &str) { -	for (int i = 0; g_gameOptions[i].desc; i++) { -		if (option.contains(g_gameOptions[i].option)) { -			if (str.contains(g_gameOptions[i].desc)) -				return true; -			else -				return false; -		} -	} -	return false; -} - -bool checkGameGUIOptionLanguage(Language lang, const String &str) { -	if (!str.contains("lang_")) // If no languages are specified -		return true; - -	if (str.contains(getGameGUIOptionsDescriptionLanguage(lang))) -		return true; - -	return false; -} - -const String getGameGUIOptionsDescriptionLanguage(Language lang) { -	if (lang == UNK_LANG) -		return ""; - -	return String(String("lang_") + getLanguageDescription(lang)); -} - -String parseGameGUIOptions(const String &str) { -	Common::String res; - -	for (int i = 0; g_gameOptions[i].desc; i++) -		if (str.contains(g_gameOptions[i].desc)) -			res += g_gameOptions[i].option; - -	return res; -} - -const String getGameGUIOptionsDescription(const String &options) { -	String res; - -	for (int i = 0; g_gameOptions[i].desc; i++) -		if (options.contains(g_gameOptions[i].option[0])) -			res += String(g_gameOptions[i].desc) + " "; - -	res.trim(); - -	return res; -} - -void updateGameGUIOptions(const String &options, const String &langOption) { -	const String newOptionString = getGameGUIOptionsDescription(options) + " " + langOption; - -	if ((!options.empty() && !ConfMan.hasKey("guioptions")) || -	    (ConfMan.hasKey("guioptions") && ConfMan.get("guioptions") != newOptionString)) { -		ConfMan.set("guioptions", newOptionString); -		ConfMan.flushToDisk(); -	} -} -  #define ENSURE_ASCII_CHAR(c) \  		if (c < 0 || c > 127) \  			return false diff --git a/common/util.h b/common/util.h index b6f63702d4..b90be0675b 100644 --- a/common/util.h +++ b/common/util.h @@ -25,7 +25,6 @@  #include "common/scummsys.h"  #include "common/str.h" -  /**   * Check whether a given pointer is aligned correctly.   * Note that 'alignment' must be a power of two! @@ -78,46 +77,6 @@ template<typename T> inline void SWAP(T &a, T &b) { T tmp = a; a = b; b = tmp; }  #  define SCUMMVM_CURRENT_FUNCTION "<unknown>"  #endif -#define GUIO_NONE			"\000" -#define GUIO_NOSUBTITLES	"\001" -#define GUIO_NOMUSIC		"\002" -#define GUIO_NOSPEECH		"\003" -#define GUIO_NOSFX			"\004" -#define GUIO_NOMIDI			"\005" -#define GUIO_NOLAUNCHLOAD	"\006" - -#define GUIO_MIDIPCSPK		"\007" -#define GUIO_MIDICMS		"\010" -#define GUIO_MIDIPCJR		"\011" -#define GUIO_MIDIADLIB		"\012" -#define GUIO_MIDIC64        "\013" -#define GUIO_MIDIAMIGA      "\014" -#define GUIO_MIDIAPPLEIIGS  "\015" -#define GUIO_MIDITOWNS		"\016" -#define GUIO_MIDIPC98		"\017" -#define GUIO_MIDIMT32		"\020" -#define GUIO_MIDIGM			"\021" - -#define GUIO_NOASPECT		"\022" -#define GUIO_EGAUNDITHER	"\023" - -#define GUIO_RENDERHERCGREEN	"\030" -#define GUIO_RENDERHERCAMBER	"\031" -#define GUIO_RENDERCGA		"\032" -#define GUIO_RENDEREGA		"\033" -#define GUIO_RENDERVGA		"\034" -#define GUIO_RENDERAMIGA	"\035" -#define GUIO_RENDERFMTOWNS	"\036" -#define GUIO_RENDERPC98		"\037" - -#define GUIO0() (GUIO_NONE) -#define GUIO1(a) (a) -#define GUIO2(a,b) (a b) -#define GUIO3(a,b,c) (a b c) -#define GUIO4(a,b,c,d) (a b c d) -#define GUIO5(a,b,c,d,e) (a b c d e) -#define GUIO6(a,b,c,d,e,f) (a b c d e f) -  namespace Common {  /** @@ -206,145 +165,6 @@ bool isSpace(int c);   */  bool isUpper(int c); - -/** - * List of game language. - */ -enum Language { -	ZH_CNA, -	ZH_TWN, -	CZ_CZE, -	NL_NLD, -	EN_ANY,     // Generic English (when only one game version exist) -	EN_GRB, -	EN_USA, -	FR_FRA, -	DE_DEU, -	GR_GRE, -	HE_ISR, -	HR_HRV, -	HU_HUN, -	IT_ITA, -	JA_JPN, -	KO_KOR, -	NB_NOR, -	PL_POL, -	PT_BRA, -	RU_RUS, -	ES_ESP, -	SE_SWE, - -	UNK_LANG = -1	// Use default language (i.e. none specified) -}; - -struct LanguageDescription { -	const char *code; -	const char *unixLocale; -	const char *description; -	Language id; -}; - -extern const LanguageDescription g_languages[]; - - -/** Convert a string containing a language name into a Language enum value. */ -extern Language parseLanguage(const String &str); -extern Language parseLanguageFromLocale(const char *locale); -extern const char *getLanguageCode(Language id); -extern const char *getLanguageLocale(Language id); -extern const char *getLanguageDescription(Language id); - -/** - * List of game platforms. Specifying a platform for a target can be used to - * give the game engines a hint for which platform the game data file are. - * This may be optional or required, depending on the game engine and the - * game in question. - */ -enum Platform { -	kPlatformPC, -	kPlatformAmiga, -	kPlatformAtariST, -	kPlatformMacintosh, -	kPlatformFMTowns, -	kPlatformWindows, -	kPlatformNES, -	kPlatformC64, -	kPlatformCoCo3, -	kPlatformLinux, -	kPlatformAcorn, -	kPlatformSegaCD, -	kPlatform3DO, -	kPlatformPCEngine, -	kPlatformApple2GS, -	kPlatformPC98, -	kPlatformWii, -	kPlatformPSX, -	kPlatformCDi, -	kPlatformIOS, - -	kPlatformUnknown = -1 -}; - -struct PlatformDescription { -	const char *code; -	const char *code2; -	const char *abbrev; -	const char *description; -	Platform id; -}; - -extern const PlatformDescription g_platforms[]; - -/** Convert a string containing a platform name into a Platform enum value. */ -extern Platform parsePlatform(const String &str); -extern const char *getPlatformCode(Platform id); -extern const char *getPlatformAbbrev(Platform id); -extern const char *getPlatformDescription(Platform id); - -/** - * List of render modes. It specifies which original graphics mode - * to use. Some targets used postprocessing dithering routines for - * reducing color depth of final image which let it to be rendered on - * such low-level adapters as CGA or Hercules. - */ -enum RenderMode { -	kRenderDefault = 0, -	kRenderVGA = 1, -	kRenderEGA = 2, -	kRenderCGA = 3, -	kRenderHercG = 4, -	kRenderHercA = 5, -	kRenderAmiga = 6, -	kRenderFMTowns = 7, -	kRenderPC98 = 8 -}; - -struct RenderModeDescription { -	const char *code; -	const char *description; -	RenderMode id; -}; - -extern const RenderModeDescription g_renderModes[]; - -/** Convert a string containing a render mode name into a RenderingMode enum value. */ -extern RenderMode parseRenderMode(const String &str); -extern const char *getRenderModeCode(RenderMode id); -extern const char *getRenderModeDescription(RenderMode id); - -bool checkGameGUIOption(const String &option, const String &str); -bool checkGameGUIOptionLanguage(Language lang, const String &str); -String parseGameGUIOptions(const String &str); -const String getGameGUIOptionsDescription(const String &options); -const String getGameGUIOptionsDescriptionLanguage(Language lang); - -/** - * Updates the GUI options of the current config manager - * domain, when they differ to the ones passed as - * parameter. - */ -void updateGameGUIOptions(const String &options, const String &langOption); -  }	// End of namespace Common  #endif @@ -2366,8 +2366,10 @@ if test -n "$_host"; then  		iphone)  			DEFINES="$DEFINES -DIPHONE"  			_backend="iphone" -			_build_hq_scalers=no +			_build_scalers=no +			_mt32emu=no  			_seq_midi=no +			_timidity=no  			;;  		m68k-atari-mint)  			DEFINES="$DEFINES -DSYSTEM_NOT_SUPPORTING_D_TYPE" @@ -2639,7 +2641,6 @@ case $_backend in  	gph)  		;;  	iphone) -		OBJCFLAGS="$OBJCFLAGS --std=c99"  		LIBS="$LIBS -lobjc -framework UIKit -framework CoreGraphics -framework OpenGLES"  		LIBS="$LIBS -framework QuartzCore -framework GraphicsServices -framework CoreFoundation"  		LIBS="$LIBS -framework Foundation -framework AudioToolbox -framework CoreAudio" @@ -2756,7 +2757,7 @@ esac  # Enable 16bit support only for backends which support it  #  case $_backend in -	android | bada | dingux | dreamcast | gph | maemo | openpandora | psp | samsungtv | sdl | webos | wii) +	android | bada | dingux | dreamcast | gph | iphone | maemo | openpandora | psp | samsungtv | sdl | webos | wii)  		if test "$_16bit" = auto ; then  			_16bit=yes  		else diff --git a/dists/win32/ScummVM.iss b/dists/win32/ScummVM.iss index 36088911d4..d0448c5620 100644 --- a/dists/win32/ScummVM.iss +++ b/dists/win32/ScummVM.iss @@ -45,6 +45,7 @@ Name: {group}\ScummVM; Filename: {app}\scummvm.exe; WorkingDir: {app}; Comment:  Name: {group}\ScummVM (noconsole); Filename: {app}\scummvm.exe; Parameters: "--no-console"; WorkingDir: {app}; Comment: scummvm; Flags: createonlyiffileexists; IconIndex: 0  Name: {group}\Authors; Filename: {app}\AUTHORS.txt; WorkingDir: {app}; Comment: AUTHORS; Flags: createonlyiffileexists  Name: {group}\Copying; Filename: {app}\COPYING.txt; WorkingDir: {app}; Comment: COPYING; Flags: createonlyiffileexists +Name: {group}\Copying.FREEFONT; Filename: {app}\COPYING.FREEFONT.txt; WorkingDir: {app}; Comment: COPYING.FREEFONT; Flags: createonlyiffileexists  Name: {group}\Copying.LGPL; Filename: {app}\COPYING.LGPL.txt; WorkingDir: {app}; Comment: COPYING.LGPL; Flags: createonlyiffileexists  Name: {group}\Copyright; Filename: {app}\COPYRIGHT.txt; WorkingDir: {app}; Comment: COPYRIGHT; Flags: createonlyiffileexists  ;NEWS @@ -83,6 +84,7 @@ Name: "{userappdata}\ScummVM\Saved Games"; MinVersion: 0, 1  [Files]  Source: AUTHORS.txt; DestDir: {app}; Flags: ignoreversion  Source: COPYING.txt; DestDir: {app}; Flags: ignoreversion +Source: COPYING.FREEFONT.txt; DestDir: {app}; Flags: ignoreversion  Source: COPYING.LGPL.txt; DestDir: {app}; Flags: ignoreversion  Source: COPYRIGHT.txt; DestDir: {app}; Flags: ignoreversion  ;NEWS diff --git a/engines/advancedDetector.h b/engines/advancedDetector.h index c31c8bd66e..3bb00618b1 100644 --- a/engines/advancedDetector.h +++ b/engines/advancedDetector.h @@ -26,6 +26,8 @@  #include "engines/metaengine.h"  #include "engines/engine.h" +#include "common/gui_options.h" // FIXME: Temporary hack? +  namespace Common {  class Error;  class FSList; diff --git a/engines/agi/agi.h b/engines/agi/agi.h index ea3afa5ca3..55b4805022 100644 --- a/engines/agi/agi.h +++ b/engines/agi/agi.h @@ -28,6 +28,7 @@  #include "common/util.h"  #include "common/file.h"  #include "common/rect.h" +#include "common/rendermode.h"  #include "common/stack.h"  #include "common/system.h" diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp index 4b5034756c..37f4eb070e 100644 --- a/engines/cge/bitmap.cpp +++ b/engines/cge/bitmap.cpp @@ -198,7 +198,7 @@ BitmapPtr Bitmap::code() {  					if ((pix == kPixelTransp) != skip || cnt >= 0x3FF0) { // end of block  						cnt |= (skip) ? kBmpSKP : kBmpCPY;  						if (_v) -							*cp = TO_LE_16(cnt);                          // store block description uint16 +							WRITE_LE_UINT16(cp, cnt); // store block description uint16  						cp = (uint16 *) im;  						im += 2; @@ -220,7 +220,7 @@ BitmapPtr Bitmap::code() {  					} else {  						cnt |= kBmpCPY;  						if (_v) -							*cp = TO_LE_16(cnt); +							WRITE_LE_UINT16(cp, cnt);  						cp = (uint16 *) im;  						im += 2; @@ -232,13 +232,13 @@ BitmapPtr Bitmap::code() {  			if (cnt && ! skip) {  				cnt |= kBmpCPY;  				if (_v) -					*cp = TO_LE_16(cnt); +					WRITE_LE_UINT16(cp, cnt);  				cp = (uint16 *) im;  				im += 2;  			}  			if (_v) -				*cp = TO_LE_16(kBmpEOI); +				WRITE_LE_UINT16(cp, kBmpEOI);  			cp = (uint16 *) im;  			im += 2;  		} diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index 34e7d3f2f9..875ac34cd0 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -28,6 +28,7 @@  #include "common/EventRecorder.h"  #include "common/file.h"  #include "common/fs.h" +#include "engines/advancedDetector.h"  #include "engines/util.h"  #include "cge/cge.h"  #include "cge/vga13h.h" diff --git a/engines/cge/cge.h b/engines/cge/cge.h index d324b293fa..4ebc836ee0 100644 --- a/engines/cge/cge.h +++ b/engines/cge/cge.h @@ -31,11 +31,12 @@  #include "engines/engine.h"  #include "gui/debugger.h"  #include "graphics/surface.h" -#include "engines/advancedDetector.h"  #include "cge/console.h"  #include "cge/bitmap.h"  #include "cge/sound.h" +struct ADGameDescription; +  namespace CGE {  class Console; diff --git a/engines/cge/events.cpp b/engines/cge/events.cpp index 7c98f00b7b..3c561c5659 100644 --- a/engines/cge/events.cpp +++ b/engines/cge/events.cpp @@ -30,6 +30,7 @@  #include "gui/message.h"  #include "common/config-manager.h"  #include "common/events.h" +#include "engines/advancedDetector.h"  #include "cge/events.h"  #include "cge/events.h"  #include "cge/text.h" diff --git a/engines/dreamweb/detection.cpp b/engines/dreamweb/detection.cpp index b891c2a3ea..9d3797db03 100644 --- a/engines/dreamweb/detection.cpp +++ b/engines/dreamweb/detection.cpp @@ -25,6 +25,8 @@  #include "common/algorithm.h"  #include "common/system.h" +#include "engines/advancedDetector.h" +  #include "graphics/thumbnail.h"  #include "dreamweb/dreamweb.h" @@ -215,4 +217,12 @@ bool DreamWebEngine::canSaveGameStateCurrently() {  	return false;  } +Common::Language DreamWebEngine::getLanguage() const { +	return _gameDescription->desc.language; +} + +bool DreamWebEngine::isCD() { +	return _gameDescription->desc.flags & ADGF_CD; +} +  } // End of namespace DreamWeb diff --git a/engines/dreamweb/detection_tables.h b/engines/dreamweb/detection_tables.h index 75f5786268..216e6715dc 100644 --- a/engines/dreamweb/detection_tables.h +++ b/engines/dreamweb/detection_tables.h @@ -25,6 +25,10 @@  namespace DreamWeb { +struct DreamWebGameDescription { +	ADGameDescription desc; +}; +  static const DreamWebGameDescription gameDescriptions[] = {  	// International floppy release  	{ diff --git a/engines/dreamweb/dreamweb.cpp b/engines/dreamweb/dreamweb.cpp index 0a5deb4657..9c02cd74ad 100644 --- a/engines/dreamweb/dreamweb.cpp +++ b/engines/dreamweb/dreamweb.cpp @@ -30,6 +30,8 @@  #include "common/timer.h"  #include "common/util.h" +#include "engines/advancedDetector.h" +  #include "graphics/palette.h"  #include "graphics/surface.h" @@ -60,7 +62,7 @@ DreamWebEngine::DreamWebEngine(OSystem *syst, const DreamWebGameDescription *gam  	_channel0 = 0;  	_channel1 = 0; -	_language = gameDesc->desc.language; +	_datafilePrefix = "DREAMWEB.";  	_openChangeSize = kInventx+(4*kItempicsize);  	_quitRequested = false; @@ -477,10 +479,9 @@ uint8 DreamWebEngine::modifyChar(uint8 c) const {  	if (c < 128)  		return c; -	switch(_language) { +	switch(getLanguage()) {  	case Common::DE_DEU: -		switch(c) -		{ +		switch(c) {  		case 129:  			return 'Z' + 3;  		case 132: @@ -528,11 +529,8 @@ uint8 DreamWebEngine::modifyChar(uint8 c) const {  	}  } -bool DreamWebEngine::isCD() { -	return _gameDescription->desc.flags & ADGF_CD; -} -  bool DreamWebEngine::hasSpeech() {  	return isCD() && _hasSpeech;  } +  } // End of namespace DreamWeb diff --git a/engines/dreamweb/dreamweb.h b/engines/dreamweb/dreamweb.h index 38016e5897..e80b5538ad 100644 --- a/engines/dreamweb/dreamweb.h +++ b/engines/dreamweb/dreamweb.h @@ -34,7 +34,6 @@  #include "audio/audiostream.h"  #include "audio/mixer.h" -#include "engines/advancedDetector.h"  #include "engines/engine.h"  #include "dreamweb/console.h" @@ -76,6 +75,7 @@ const unsigned int kSymbolx = 64;  const unsigned int kSymboly = 56;  const unsigned int kLengthofvars = 68;  const unsigned int kFrameBlocksize = 2080; +const unsigned int kGraphicsFileFrameSize = 347; // ceil(2080 / sizeof(Frame))  const unsigned int kNumexobjects = 114;  const unsigned int kNumExTexts = kNumexobjects + 2;  const uint16 kExtextlen = 18000; @@ -98,9 +98,7 @@ enum {  	kDebugSaveLoad = (1 << 1)  }; -struct DreamWebGameDescription { -	ADGameDescription desc; -}; +struct DreamWebGameDescription;  class DreamWebEngine : public Engine {  private: @@ -144,16 +142,18 @@ public:  	void quit(); -	void loadSounds(uint bank, const Common::String &file); +	void loadSounds(uint bank, const Common::String &suffix);  	bool loadSpeech(const Common::String &filename);  	void enableSavingOrLoading(bool enable = true) { _enableSavingOrLoading = enable; } -	Common::Language getLanguage() const { return _language; } +	Common::Language getLanguage() const;  	uint8 modifyChar(uint8 c) const;  	void stopSound(uint8 channel); +	const Common::String& getDatafilePrefix() { return _datafilePrefix; }; +  private:  	void keyPressed(uint16 ascii);  	void setSpeed(uint speed); @@ -162,12 +162,12 @@ private:  	const DreamWebGameDescription	*_gameDescription;  	Common::RandomSource			_rnd; +	Common::String _datafilePrefix;  	uint _speed;  	bool _turbo;  	uint _oldMouseState;  	bool _enableSavingOrLoading; -	Common::Language _language;  	struct Sample {  		uint offset; @@ -265,13 +265,28 @@ protected:  	TextFile _puzzleText;  	TextFile _commandText; -	// graphics files -	GraphicsFile _tempGraphics; -	GraphicsFile _tempGraphics2; -	GraphicsFile _tempGraphics3; +	// local graphics files +	GraphicsFile _keypadGraphics; +	GraphicsFile _menuGraphics; +	GraphicsFile _menuGraphics2; +	GraphicsFile _folderGraphics; +	GraphicsFile _folderGraphics2; +	GraphicsFile _folderGraphics3; +	GraphicsFile _folderCharset; +	GraphicsFile _symbolGraphics; +	GraphicsFile _diaryGraphics; +	GraphicsFile _diaryCharset; +	GraphicsFile _monitorGraphics; +	GraphicsFile _monitorCharset; +	GraphicsFile _newplaceGraphics; +	GraphicsFile _newplaceGraphics2; +	GraphicsFile _newplaceGraphics3; +	GraphicsFile _cityGraphics; +	GraphicsFile _saveGraphics; + +	// global graphics files  	GraphicsFile _icons1;  	GraphicsFile _icons2; -	GraphicsFile _tempCharset;  	GraphicsFile _charset1;  	GraphicsFile _mainSprites;  	const GraphicsFile *_currentCharset; @@ -793,19 +808,15 @@ public:  	const uint8 *getTextInFile1(uint16 index);  	uint8 findNextColon(const uint8 **string);  	void allocateBuffers(); -	void loadTextFile(TextFile &file, const char *fileName); -	void loadGraphicsFile(GraphicsFile &file, const char *fileName); +	void loadTextFile(TextFile &file, const char *suffix); +	void loadGraphicsFile(GraphicsFile &file, const char *suffix);  	void loadGraphicsSegment(GraphicsFile &file, Common::File &inFile, unsigned int len);  	void loadTextSegment(TextFile &file, Common::File &inFile, unsigned int len); -	void loadIntoTemp(const char *fileName); -	void loadIntoTemp2(const char *fileName); -	void loadIntoTemp3(const char *fileName); -	void loadTempCharset(const char *fileName);  	void loadTravelText(); -	void loadTempText(const char *fileName); +	void loadTempText(const char *suffix);  	void sortOutMap();  	void loadRoomData(const Room &room, bool skipDat); -	void useTempCharset(); +	void useTempCharset(GraphicsFile *charset);  	void useCharset1();  	void printMessage(uint16 x, uint16 y, uint8 index, uint8 maxWidth, bool centered);  	void printMessage2(uint16 x, uint16 y, uint8 index, uint8 maxWidth, bool centered, uint8 count); @@ -848,11 +859,7 @@ public:  	bool isItWorn(const DynObject *object);  	bool compare(uint8 index, uint8 flag, const char id[4]);  	void hangOnW(uint16 frameCount); -	void getRidOfTemp();  	void getRidOfTempText(); -	void getRidOfTemp2(); -	void getRidOfTemp3(); -	void getRidOfTempCharset();  	void getRidOfAll();  	void placeSetObject(uint8 index);  	void removeSetObject(uint8 index); @@ -1129,7 +1136,7 @@ public:  	void doShake();  	void vSync();  	void setMode(); -	void showPCX(const Common::String &name); +	void showPCX(const Common::String &suffix);  	void showFrameInternal(const uint8 *pSrc, uint16 x, uint16 y, uint8 effectsFlag, uint8 width, uint8 height);  	void showFrame(const GraphicsFile &frameData, uint16 x, uint16 y, uint16 frameNumber, uint8 effectsFlag, uint8 *width, uint8 *height);  	void showFrame(const GraphicsFile &frameData, uint16 x, uint16 y, uint16 frameNumber, uint8 effectsFlag); diff --git a/engines/dreamweb/keypad.cpp b/engines/dreamweb/keypad.cpp index 2a31652ace..2ab5835997 100644 --- a/engines/dreamweb/keypad.cpp +++ b/engines/dreamweb/keypad.cpp @@ -93,7 +93,7 @@ void DreamWebEngine::enterCode(uint8 digit0, uint8 digit1, uint8 digit2, uint8 d  		}  	}  	_manIsOffScreen = 0; -	getRidOfTemp(); +	_keypadGraphics.clear();  	restoreReels();  	redrawMainScrn();  	workToScreenM(); @@ -108,7 +108,7 @@ bool DreamWebEngine::isItRight(uint8 digit0, uint8 digit1, uint8 digit2, uint8 d  }  void DreamWebEngine::loadKeypad() { -	loadIntoTemp("DREAMWEB.G02"); +	loadGraphicsFile(_keypadGraphics, "G02");  }  void DreamWebEngine::quitKey() { @@ -185,8 +185,8 @@ void DreamWebEngine::buttonPress(uint8 buttonId) {  }  void DreamWebEngine::showOuterPad() { -	showFrame(_tempGraphics, kKeypadx-3, kKeypady-4, 1, 0); -	showFrame(_tempGraphics, kKeypadx+74, kKeypady+76, 37, 0); +	showFrame(_keypadGraphics, kKeypadx-3, kKeypady-4, 1, 0); +	showFrame(_keypadGraphics, kKeypadx+74, kKeypady+76, 37, 0);  }  void DreamWebEngine::showKeypad() { @@ -214,7 +214,7 @@ void DreamWebEngine::showKeypad() {  		}  		if ((_lightCount >= 60) && (_lightCount < 100))  			--frameIndex; -		showFrame(_tempGraphics, kKeypadx+60, y, frameIndex, 0); +		showFrame(_keypadGraphics, kKeypadx+60, y, frameIndex, 0);  	}  } @@ -225,7 +225,7 @@ void DreamWebEngine::singleKey(uint8 key, uint16 x, uint16 y) {  			key -= 11;  	}  	key -= 20; -	showFrame(_tempGraphics, x, y, key, 0); +	showFrame(_keypadGraphics, x, y, key, 0);  }  void DreamWebEngine::dumpKeypad() { @@ -241,9 +241,9 @@ void DreamWebEngine::useMenu() {  	_vars._newObs = 0;  	drawFloor();  	printSprites(); -	showFrame(_tempGraphics2, kMenux-48, kMenuy-4, 4, 0); +	showFrame(_menuGraphics2, kMenux-48, kMenuy-4, 4, 0);  	getUnderMenu(); -	showFrame(_tempGraphics2, kMenux+54, kMenuy+72, 5, 0); +	showFrame(_menuGraphics2, kMenux+54, kMenuy+72, 5, 0);  	workToScreenM();  	_getBack = 0;  	do { @@ -265,8 +265,8 @@ void DreamWebEngine::useMenu() {  	} while ((_getBack != 1) && !_quitRequested);  	_manIsOffScreen = 0;  	redrawMainScrn(); -	getRidOfTemp(); -	getRidOfTemp2(); +	_menuGraphics.clear(); +	_menuGraphics2.clear();  	restoreReels();  	workToScreenM();  } @@ -289,12 +289,12 @@ void DreamWebEngine::showMenu() {  	++_menuCount;  	if (_menuCount == 37*2)  		_menuCount = 0; -	showFrame(_tempGraphics, kMenux, kMenuy, _menuCount / 2, 0); +	showFrame(_menuGraphics, kMenux, kMenuy, _menuCount / 2, 0);  }  void DreamWebEngine::loadMenu() { -	loadIntoTemp("DREAMWEB.S02"); // sprite name 3 -	loadIntoTemp2("DREAMWEB.G07"); // mon. graphics 2 +	loadGraphicsFile(_menuGraphics, "S02"); // sprite name 3 +	loadGraphicsFile(_menuGraphics2, "G07"); // mon. graphics 2  }  void DreamWebEngine::viewFolder() { @@ -317,10 +317,10 @@ void DreamWebEngine::viewFolder() {  		checkFolderCoords();  	} while (_getBack == 0);  	_manIsOffScreen = 0; -	getRidOfTemp(); -	getRidOfTemp2(); -	getRidOfTemp3(); -	getRidOfTempCharset(); +	_folderGraphics.clear(); +	_folderGraphics2.clear(); +	_folderGraphics3.clear(); +	_folderCharset.clear();  	restoreAll();  	redrawMainScrn();  	workToScreenM(); @@ -394,22 +394,22 @@ void DreamWebEngine::checkFolderCoords() {  }  void DreamWebEngine::loadFolder() { -	loadIntoTemp("DREAMWEB.G09"); // folder graphics 1 -	loadIntoTemp2("DREAMWEB.G10"); // folder graphics 2 -	loadIntoTemp3("DREAMWEB.G11"); // folder graphics 3 -	loadTempCharset("DREAMWEB.C02"); // character set 3 -	loadTempText("DREAMWEB.T50"); // folder text +	loadGraphicsFile(_folderGraphics, "G09"); // folder graphics 1 +	loadGraphicsFile(_folderGraphics2, "G10"); // folder graphics 2 +	loadGraphicsFile(_folderGraphics3, "G11"); // folder graphics 3 +	loadGraphicsFile(_folderCharset, "C02"); // character set 3 +	loadTempText("T50"); // folder text  }  void DreamWebEngine::showFolder() {  	_commandType = 255;  	if (_folderPage) { -		useTempCharset(); +		useTempCharset(&_folderCharset);  		createPanel2(); -		showFrame(_tempGraphics, 0, 0, 0, 0); -		showFrame(_tempGraphics, 143, 0, 1, 0); -		showFrame(_tempGraphics, 0, 92, 2, 0); -		showFrame(_tempGraphics, 143, 92, 3, 0); +		showFrame(_folderGraphics, 0, 0, 0, 0); +		showFrame(_folderGraphics, 143, 0, 1, 0); +		showFrame(_folderGraphics, 0, 92, 2, 0); +		showFrame(_folderGraphics, 143, 92, 3, 0);  		folderExit();  		if (_folderPage != 1)  			showLeftPage(); @@ -419,25 +419,25 @@ void DreamWebEngine::showFolder() {  		underTextLine();  	} else {  		createPanel2(); -		showFrame(_tempGraphics3, 143-28, 0, 0, 0); -		showFrame(_tempGraphics3, 143-28, 92, 1, 0); +		showFrame(_folderGraphics3, 143-28, 0, 0, 0); +		showFrame(_folderGraphics3, 143-28, 92, 1, 0);  		folderExit();  		underTextLine();  	}  }  void DreamWebEngine::folderExit() { -	showFrame(_tempGraphics2, 296, 178, 6, 0); +	showFrame(_folderGraphics2, 296, 178, 6, 0);  }  void DreamWebEngine::showLeftPage() { -	showFrame(_tempGraphics2, 0, 12, 3, 0); +	showFrame(_folderGraphics2, 0, 12, 3, 0);  	uint16 y = 12+5;  	for (size_t i = 0; i < 9; ++i) { -		showFrame(_tempGraphics2, 0, y, 4, 0); +		showFrame(_folderGraphics2, 0, y, 4, 0);  		y += 16;  	} -	showFrame(_tempGraphics2, 0, y, 5, 0); +	showFrame(_folderGraphics2, 0, y, 5, 0);  	_lineSpacing = 8;  	_charShift = 91;  	_kerning = 1; @@ -464,14 +464,14 @@ void DreamWebEngine::showLeftPage() {  }  void DreamWebEngine::showRightPage() { -	showFrame(_tempGraphics2, 143, 12, 0, 0); +	showFrame(_folderGraphics2, 143, 12, 0, 0);  	uint16 y = 12+37;  	for (size_t i = 0; i < 7; ++i) { -		showFrame(_tempGraphics2, 143, y, 1, 0); +		showFrame(_folderGraphics2, 143, y, 1, 0);  		y += 16;  	} -	showFrame(_tempGraphics2, 143, y, 2, 0); +	showFrame(_folderGraphics2, 143, y, 2, 0);  	_lineSpacing = 8;  	_kerning = 1;  	uint8 pageIndex = _folderPage - 1; @@ -491,7 +491,7 @@ void DreamWebEngine::showRightPage() {  void DreamWebEngine::enterSymbol() {  	_manIsOffScreen = 1;  	getRidOfReels(); -	loadIntoTemp("DREAMWEB.G12"); // symbol graphics +	loadGraphicsFile(_symbolGraphics, "G12"); // symbol graphics  	_symbolTopX = 24;  	_symbolTopDir = 0;  	_symbolBotX = 24; @@ -529,7 +529,7 @@ void DreamWebEngine::enterSymbol() {  		turnAnyPathOn(0, _roomNum + 12);  		_manIsOffScreen = 0;  		redrawMainScrn(); -		getRidOfTemp(); +		_symbolGraphics.clear();  		restoreReels();  		workToScreenM();  		playChannel1(13); @@ -539,7 +539,7 @@ void DreamWebEngine::enterSymbol() {  		turnAnyPathOff(0, _roomNum + 12);  		_manIsOffScreen = 0;  		redrawMainScrn(); -		getRidOfTemp(); +		_symbolGraphics.clear();  		restoreReels();  		workToScreenM();  	} @@ -616,19 +616,19 @@ void DreamWebEngine::dumpSymbol() {  }  void DreamWebEngine::showSymbol() { -	showFrame(_tempGraphics, kSymbolx, kSymboly, 12, 0); +	showFrame(_symbolGraphics, kSymbolx, kSymboly, 12, 0); -	showFrame(_tempGraphics, _symbolTopX + kSymbolx-44, kSymboly+20, _symbolTopNum, 32); +	showFrame(_symbolGraphics, _symbolTopX + kSymbolx-44, kSymboly+20, _symbolTopNum, 32);  	uint8 nextTopSymbol = nextSymbol(_symbolTopNum); -	showFrame(_tempGraphics, _symbolTopX + kSymbolx+5, kSymboly+20, nextTopSymbol, 32); +	showFrame(_symbolGraphics, _symbolTopX + kSymbolx+5, kSymboly+20, nextTopSymbol, 32);  	uint8 nextNextTopSymbol = nextSymbol(nextTopSymbol); -	showFrame(_tempGraphics, _symbolTopX + kSymbolx+54, kSymboly+20, nextNextTopSymbol, 32); +	showFrame(_symbolGraphics, _symbolTopX + kSymbolx+54, kSymboly+20, nextNextTopSymbol, 32); -	showFrame(_tempGraphics, _symbolBotX + kSymbolx-44, kSymboly+49, 6 + _symbolBotNum, 32); +	showFrame(_symbolGraphics, _symbolBotX + kSymbolx-44, kSymboly+49, 6 + _symbolBotNum, 32);  	uint8 nextBotSymbol = nextSymbol(_symbolBotNum); -	showFrame(_tempGraphics, _symbolBotX + kSymbolx+5, kSymboly+49, 6 + nextBotSymbol, 32); +	showFrame(_symbolGraphics, _symbolBotX + kSymbolx+5, kSymboly+49, 6 + nextBotSymbol, 32);  	uint8 nextNextBotSymbol = nextSymbol(nextBotSymbol); -	showFrame(_tempGraphics, _symbolBotX + kSymbolx+54, kSymboly+49, 6 + nextNextBotSymbol, 32); +	showFrame(_symbolGraphics, _symbolBotX + kSymbolx+54, kSymboly+49, 6 + nextNextBotSymbol, 32);  }  uint8 DreamWebEngine::nextSymbol(uint8 symbol) { @@ -716,9 +716,9 @@ void DreamWebEngine::updateSymbolBot() {  void DreamWebEngine::useDiary() {  	getRidOfReels(); -	loadIntoTemp("DREAMWEB.G14"); -	loadTempText("DREAMWEB.T51"); -	loadTempCharset("DREAMWEB.C02"); +	loadGraphicsFile(_diaryGraphics, "G14"); +	loadTempText("T51"); +	loadGraphicsFile(_diaryCharset, "C02");  	createPanel();  	showIcon();  	showDiary(); @@ -751,9 +751,9 @@ void DreamWebEngine::useDiary() {  	} while (!_getBack && !_quitRequested); -	getRidOfTemp(); +	_diaryGraphics.clear();  	getRidOfTempText(); -	getRidOfTempCharset(); +	_diaryCharset.clear();  	restoreReels();  	_manIsOffScreen = 0;  	redrawMainScrn(); @@ -761,8 +761,8 @@ void DreamWebEngine::useDiary() {  }  void DreamWebEngine::showDiary() { -	showFrame(_tempGraphics, kDiaryx, kDiaryy + 37, 1, 0); -	showFrame(_tempGraphics, kDiaryx + 176, kDiaryy + 108, 2, 0); +	showFrame(_diaryGraphics, kDiaryx, kDiaryy + 37, 1, 0); +	showFrame(_diaryGraphics, kDiaryx + 176, kDiaryy + 108, 2, 0);  }  void DreamWebEngine::showDiaryKeys() { @@ -776,10 +776,10 @@ void DreamWebEngine::showDiaryKeys() {  	if (_pressed == 'N') {  		byte frame = (_pressCount == 1) ? 3 : 4; -		showFrame(_tempGraphics, kDiaryx + 94, kDiaryy + 97, frame, 0); +		showFrame(_diaryGraphics, kDiaryx + 94, kDiaryy + 97, frame, 0);  	} else {  		byte frame = (_pressCount == 1) ? 5 : 6; -		showFrame(_tempGraphics, kDiaryx + 151, kDiaryy + 71, frame, 0); +		showFrame(_diaryGraphics, kDiaryx + 151, kDiaryy + 71, frame, 0);  	}  	if (_pressCount == 1) @@ -847,9 +847,9 @@ void DreamWebEngine::diaryKeyN() {  }  void DreamWebEngine::showDiaryPage() { -	showFrame(_tempGraphics, kDiaryx, kDiaryy, 0, 0); +	showFrame(_diaryGraphics, kDiaryx, kDiaryy, 0, 0);  	_kerning = 1; -	useTempCharset(); +	useTempCharset(&_diaryCharset);  	_charShift = 91+91;  	const uint8 *string = getTextInFile1(_diaryPage);  	uint16 y = kDiaryy + 16; diff --git a/engines/dreamweb/monitor.cpp b/engines/dreamweb/monitor.cpp index d2f6b376ae..cdef60e94d 100644 --- a/engines/dreamweb/monitor.cpp +++ b/engines/dreamweb/monitor.cpp @@ -54,11 +54,11 @@ void DreamWebEngine::useMon() {  	showIcon();  	drawFloor();  	getRidOfAll(); -	loadIntoTemp("DREAMWEB.G03"); // mon. graphic name +	loadGraphicsFile(_monitorGraphics, "G03"); // mon. graphic name  	loadPersonal();  	loadNews();  	loadCart(); -	loadTempCharset("DREAMWEB.C01"); // character set 2 +	loadGraphicsFile(_monitorCharset, "C01"); // character set 2  	printOuterMon();  	initialMonCols();  	printLogo(); @@ -89,8 +89,8 @@ void DreamWebEngine::useMon() {  		if (_quitRequested) //TODO : Check why it crashes when put before the execcommand  			break;  	} while (!stop); -	getRidOfTemp(); -	getRidOfTempCharset(); +	_monitorGraphics.clear(); +	_monitorCharset.clear();  	_textFile1.clear();  	_textFile2.clear(); @@ -188,14 +188,14 @@ void DreamWebEngine::monitorLogo() {  }  void DreamWebEngine::printLogo() { -	showFrame(_tempGraphics, 56, 32, 0, 0); +	showFrame(_monitorGraphics, 56, 32, 0, 0);  	showCurrentFile();  }  void DreamWebEngine::input() {  	memset(_inputLine, 0, 64);  	_curPos = 0; -	printChar(_tempCharset, _monAdX, _monAdY, '>', 0, NULL, NULL); +	printChar(_monitorCharset, _monAdX, _monAdY, '>', 0, NULL, NULL);  	multiDump(_monAdX, _monAdY, 6, 8);  	_monAdX += 6;  	_cursLocX = _monAdX; @@ -227,7 +227,7 @@ void DreamWebEngine::input() {  			continue;  		multiGet(_mapStore + _curPos * 256, _monAdX, _monAdY, 8, 8);  		uint8 charWidth; -		printChar(_tempCharset, _monAdX, _monAdY, currentKey, 0, &charWidth, NULL); +		printChar(_monitorCharset, _monAdX, _monAdY, currentKey, 0, &charWidth, NULL);  		_inputLine[_curPos * 2 + 1] = charWidth;  		_monAdX += charWidth;  		++_curPos; @@ -266,7 +266,7 @@ void DreamWebEngine::printCurs() {  	multiGet(_textUnder, x, y, 6, height);  	++_mainTimer;  	if ((_mainTimer & 16) == 0) -		showFrame(_tempCharset, x, y, '/' - 32, 0); +		showFrame(_monitorCharset, x, y, '/' - 32, 0);  	multiDump(x - 6, y, 12, height);  } @@ -302,17 +302,17 @@ void DreamWebEngine::showCurrentFile() {  	while (*currentFile) {  		char c = *currentFile++;  		c = modifyChar(c); -		printChar(_tempCharset, &x, 37, c, 0, NULL, NULL); +		printChar(_monitorCharset, &x, 37, c, 0, NULL, NULL);  	}  }  void DreamWebEngine::accessLightOn() { -	showFrame(_tempGraphics, 74, 182, 8, 0); +	showFrame(_monitorGraphics, 74, 182, 8, 0);  	multiDump(74, 182, 12, 8);  }  void DreamWebEngine::accessLightOff() { -	showFrame(_tempGraphics, 74, 182, 7, 0); +	showFrame(_monitorGraphics, 74, 182, 7, 0);  	multiDump(74, 182, 12, 8);  } @@ -345,22 +345,22 @@ void DreamWebEngine::netError() {  }  void DreamWebEngine::powerLightOn() { -	showFrame(_tempGraphics, 257+4, 182, 6, 0); +	showFrame(_monitorGraphics, 257+4, 182, 6, 0);  	multiDump(257+4, 182, 12, 8);  }  void DreamWebEngine::powerLightOff() { -	showFrame(_tempGraphics, 257+4, 182, 5, 0); +	showFrame(_monitorGraphics, 257+4, 182, 5, 0);  	multiDump(257+4, 182, 12, 8);  }  void DreamWebEngine::lockLightOn() { -	showFrame(_tempGraphics, 56, 182, 10, 0); +	showFrame(_monitorGraphics, 56, 182, 10, 0);  	multiDump(58, 182, 12, 8);  }  void DreamWebEngine::lockLightOff() { -	showFrame(_tempGraphics, 56, 182, 9, 0); +	showFrame(_monitorGraphics, 56, 182, 9, 0);  	multiDump(58, 182, 12, 8);  } @@ -375,29 +375,29 @@ void DreamWebEngine::turnOnPower() {  }  void DreamWebEngine::printOuterMon() { -	showFrame(_tempGraphics, 40, 32, 1, 0); -	showFrame(_tempGraphics, 264, 32, 2, 0); -	showFrame(_tempGraphics, 40, 12, 3, 0); -	showFrame(_tempGraphics, 40, 164, 4, 0); +	showFrame(_monitorGraphics, 40, 32, 1, 0); +	showFrame(_monitorGraphics, 264, 32, 2, 0); +	showFrame(_monitorGraphics, 40, 12, 3, 0); +	showFrame(_monitorGraphics, 40, 164, 4, 0);  }  void DreamWebEngine::loadPersonal() {  	if (_vars._location == 0 || _vars._location == 42) -		loadTextFile(_textFile1, "DREAMWEB.T01"); // monitor file 1 +		loadTextFile(_textFile1, "T01"); // monitor file 1  	else -		loadTextFile(_textFile1, "DREAMWEB.T02"); // monitor file 2 +		loadTextFile(_textFile1, "T02"); // monitor file 2  }  void DreamWebEngine::loadNews() {  	// textfile2 holds information accessible by anyone  	if (_vars._newsItem == 0) -		loadTextFile(_textFile2, "DREAMWEB.T10"); // monitor file 10 +		loadTextFile(_textFile2, "T10"); // monitor file 10  	else if (_vars._newsItem == 1) -		loadTextFile(_textFile2, "DREAMWEB.T11"); // monitor file 11 +		loadTextFile(_textFile2, "T11"); // monitor file 11  	else if (_vars._newsItem == 2) -		loadTextFile(_textFile2, "DREAMWEB.T12"); // monitor file 12 +		loadTextFile(_textFile2, "T12"); // monitor file 12  	else -		loadTextFile(_textFile2, "DREAMWEB.T13"); // monitor file 13 +		loadTextFile(_textFile2, "T13"); // monitor file 13  }  void DreamWebEngine::loadCart() { @@ -408,15 +408,15 @@ void DreamWebEngine::loadCart() {  		cartridgeId = getExAd(cartridgeIndex)->objId[3] + 1;  	if (cartridgeId == 0) -		loadTextFile(_textFile3, "DREAMWEB.T20"); // monitor file 20 +		loadTextFile(_textFile3, "T20"); // monitor file 20  	else if (cartridgeId == 1) -		loadTextFile(_textFile3, "DREAMWEB.T21"); // monitor file 21 +		loadTextFile(_textFile3, "T21"); // monitor file 21  	else if (cartridgeId == 2) -		loadTextFile(_textFile3, "DREAMWEB.T22"); // monitor file 22 +		loadTextFile(_textFile3, "T22"); // monitor file 22  	else if (cartridgeId == 3) -		loadTextFile(_textFile3, "DREAMWEB.T23"); // monitor file 23 +		loadTextFile(_textFile3, "T23"); // monitor file 23  	else -		loadTextFile(_textFile3, "DREAMWEB.T24"); // monitor file 24 +		loadTextFile(_textFile3, "T24"); // monitor file 24  }  void DreamWebEngine::showKeys() { diff --git a/engines/dreamweb/newplace.cpp b/engines/dreamweb/newplace.cpp index 8083055da6..529c45bd4a 100644 --- a/engines/dreamweb/newplace.cpp +++ b/engines/dreamweb/newplace.cpp @@ -41,7 +41,7 @@ void DreamWebEngine::selectLocation() {  	_pointerFrame = 22;  	readCityPic();  	showCity(); -	getRidOfTemp(); +	_cityGraphics.clear();  	readDestIcon();  	loadTravelText();  	showPanel(); @@ -89,17 +89,17 @@ void DreamWebEngine::selectLocation() {  		_getBack = 0;  	} -	getRidOfTemp(); -	getRidOfTemp2(); -	getRidOfTemp3(); +	_newplaceGraphics.clear(); +	_newplaceGraphics2.clear(); +	_newplaceGraphics3.clear();  	_travelText.clear();  }  void DreamWebEngine::showCity() {  	clearWork(); -	showFrame(_tempGraphics, 57, 32, 0, 0); -	showFrame(_tempGraphics, 120+57, 32, 1, 0); +	showFrame(_cityGraphics, 57, 32, 0, 0); +	showFrame(_cityGraphics, 120+57, 32, 1, 0);  }  void DreamWebEngine::lookAtPlace() { @@ -113,10 +113,10 @@ void DreamWebEngine::lookAtPlace() {  	delPointer();  	delTextLine();  	getUnderCentre(); -	showFrame(_tempGraphics3, 60, 72, 0, 0); -	showFrame(_tempGraphics3, 60, 72 + 55, 4, 0); +	showFrame(_newplaceGraphics3, 60, 72, 0, 0); +	showFrame(_newplaceGraphics3, 60, 72 + 55, 4, 0);  	if (_foreignRelease) -		showFrame(_tempGraphics3, 60, 72+55+21, 4, 0); +		showFrame(_newplaceGraphics3, 60, 72+55+21, 4, 0);  	const uint8 *string = (const uint8 *)_travelText.getString(_destPos);  	findNextColon(&string); @@ -143,21 +143,21 @@ void DreamWebEngine::locationPic() {  	byte picture = roomPics[_destPos];  	if (picture >= 6) -		showFrame(_tempGraphics2, 104, 138 + 14, picture - 6, 0);	// Second slot +		showFrame(_newplaceGraphics2, 104, 138 + 14, picture - 6, 0);	// Second slot  	else -		showFrame(_tempGraphics,  104, 138 + 14, picture + 4, 0); +		showFrame(_newplaceGraphics,  104, 138 + 14, picture + 4, 0);  	if (_destPos == _realLocation) -		showFrame(_tempGraphics, 104, 140 + 14, 3, 0);	// Currently in this location +		showFrame(_newplaceGraphics, 104, 140 + 14, 3, 0);	// Currently in this location  	const uint8 *string = (const uint8 *)_travelText.getString(_destPos);  	printDirect(string, 50, 20, 241, 241 & 1);  }  void DreamWebEngine::showArrows() { -	showFrame(_tempGraphics, 116 - 12, 16, 0, 0); -	showFrame(_tempGraphics, 226 + 12, 16, 1, 0); -	showFrame(_tempGraphics, 280, 14, 2, 0); +	showFrame(_newplaceGraphics, 116 - 12, 16, 0, 0); +	showFrame(_newplaceGraphics, 226 + 12, 16, 1, 0); +	showFrame(_newplaceGraphics, 280, 14, 2, 0);  }  void DreamWebEngine::nextDest() { @@ -259,13 +259,13 @@ void DreamWebEngine::resetLocation(uint8 index) {  }  void DreamWebEngine::readDestIcon() { -	loadIntoTemp("DREAMWEB.G05"); -	loadIntoTemp2("DREAMWEB.G06"); -	loadIntoTemp3("DREAMWEB.G08"); +	loadGraphicsFile(_newplaceGraphics, "G05"); +	loadGraphicsFile(_newplaceGraphics2, "G06"); +	loadGraphicsFile(_newplaceGraphics3, "G08");  }  void DreamWebEngine::readCityPic() { -	loadIntoTemp("DREAMWEB.G04"); +	loadGraphicsFile(_cityGraphics, "G04");  }  } // End of namespace DreamWeb diff --git a/engines/dreamweb/people.cpp b/engines/dreamweb/people.cpp index 1b8ee1b4de..316a1689c9 100644 --- a/engines/dreamweb/people.cpp +++ b/engines/dreamweb/people.cpp @@ -178,7 +178,7 @@ void DreamWebEngine::madman(ReelRoutine &routine) {  			return;  		}  		if (newReelPointer == 10) { -			loadTempText("DREAMWEB.T82"); +			loadTempText("T82");  			_vars._combatCount = (uint8)-1;  			_speechCount = 0;  		} diff --git a/engines/dreamweb/print.cpp b/engines/dreamweb/print.cpp index 24e0183a07..a6b93a5590 100644 --- a/engines/dreamweb/print.cpp +++ b/engines/dreamweb/print.cpp @@ -210,7 +210,7 @@ const char *DreamWebEngine::monPrint(const char *string) {  	bool done = false;  	while (!done) { -		uint16 count = getNumber(_tempCharset, (const uint8 *)iterator, 166, false, &x); +		uint16 count = getNumber(_monitorCharset, (const uint8 *)iterator, 166, false, &x);  		do {	  			char c = *iterator++;  			if (c == ':') @@ -226,7 +226,7 @@ const char *DreamWebEngine::monPrint(const char *string) {  				break;  			}  			c = modifyChar(c); -			printChar(_tempCharset, &x, _monAdY, c, 0, NULL, NULL); +			printChar(_monitorCharset, &x, _monAdY, c, 0, NULL, NULL);  			_cursLocX = x;  			_cursLocY = _monAdY;  			_mainTimer = 1; diff --git a/engines/dreamweb/saveload.cpp b/engines/dreamweb/saveload.cpp index 4779d0baef..a526c8a3bc 100644 --- a/engines/dreamweb/saveload.cpp +++ b/engines/dreamweb/saveload.cpp @@ -178,7 +178,7 @@ void DreamWebEngine::doLoad(int savegameId) {  	// If we reach this point, loadPosition() has just been called.  	// Among other things, it will have filled g_MadeUpRoomDat. -	getRidOfTemp(); +	_saveGraphics.clear();  	startLoading(g_madeUpRoomDat);  	loadRoomsSample(); @@ -270,7 +270,7 @@ void DreamWebEngine::saveGame() {  			descbuf[++desclen] = 1;  		// TODO: The below is copied from actualsave -		getRidOfTemp(); +		_saveGraphics.clear();  		restoreAll(); // reels  		_textAddressX = 13;  		_textAddressY = 182; @@ -360,7 +360,7 @@ void DreamWebEngine::doSaveLoad() {  	_textAddressY = 182;  	_textLen = 240;  	if (_getBack != 4) { -		getRidOfTemp(); +		_saveGraphics.clear();  		restoreAll();  		redrawMainScrn();  		workToScreenM(); @@ -388,16 +388,16 @@ void DreamWebEngine::getBackToOps() {  }  void DreamWebEngine::showMainOps() { -	showFrame(_tempGraphics, kOpsx+10, kOpsy+10, 8, 0); -	showFrame(_tempGraphics, kOpsx+59, kOpsy+30, 7, 0); -	showFrame(_tempGraphics, kOpsx+128+4, kOpsy+12, 1, 0); +	showFrame(_saveGraphics, kOpsx+10, kOpsy+10, 8, 0); +	showFrame(_saveGraphics, kOpsx+59, kOpsy+30, 7, 0); +	showFrame(_saveGraphics, kOpsx+128+4, kOpsy+12, 1, 0);  }  void DreamWebEngine::showDiscOps() { -	showFrame(_tempGraphics, kOpsx+128+4, kOpsy+12, 1, 0); -	showFrame(_tempGraphics, kOpsx+10, kOpsy+10, 9, 0); -	showFrame(_tempGraphics, kOpsx+59, kOpsy+30, 10, 0); -	showFrame(_tempGraphics, kOpsx+176+2, kOpsy+60-4, 5, 0); +	showFrame(_saveGraphics, kOpsx+128+4, kOpsy+12, 1, 0); +	showFrame(_saveGraphics, kOpsx+10, kOpsy+10, 9, 0); +	showFrame(_saveGraphics, kOpsx+59, kOpsy+30, 10, 0); +	showFrame(_saveGraphics, kOpsx+176+2, kOpsy+60-4, 5, 0);  }  void DreamWebEngine::discOps() { @@ -450,7 +450,7 @@ void DreamWebEngine::actualSave() {  	savePosition(slot, desc); -	getRidOfTemp(); +	_saveGraphics.clear();  	restoreAll(); // reels  	_textAddressX = 13;  	_textAddressY = 182; @@ -703,12 +703,12 @@ void DreamWebEngine::loadOld() {  void DreamWebEngine::showDecisions() {  	createPanel2();  	showOpBox(); -	showFrame(_tempGraphics, kOpsx + 17, kOpsy + 13, 6, 0); +	showFrame(_saveGraphics, kOpsx + 17, kOpsy + 13, 6, 0);  	underTextLine();  }  void DreamWebEngine::loadSaveBox() { -	loadIntoTemp("DREAMWEB.G08"); +	loadGraphicsFile(_saveGraphics, "G08");  }  // show savegame names (original interface), and set kCursorpos @@ -822,37 +822,37 @@ void DreamWebEngine::selectSlot() {  void DreamWebEngine::showSlots() {  	showFrame(_icons1, kOpsx + 158, kOpsy - 11, 12, 0);  	showFrame(_icons1, kOpsx + 158 + 18 * _saveLoadPage, kOpsy - 11, 13 + _saveLoadPage, 0); -	showFrame(_tempGraphics, kOpsx + 7, kOpsy + 8, 2, 0); +	showFrame(_saveGraphics, kOpsx + 7, kOpsy + 8, 2, 0);  	uint16 y = kOpsy + 11;  	for (int slot = 0; slot < 7; slot++) {  		if (slot == _currentSlot) -			showFrame(_tempGraphics, kOpsx + 10, y, 3, 0); +			showFrame(_saveGraphics, kOpsx + 10, y, 3, 0);  		y += 10;  	}  }  void DreamWebEngine::showOpBox() { -	showFrame(_tempGraphics, kOpsx, kOpsy, 0, 0); +	showFrame(_saveGraphics, kOpsx, kOpsy, 0, 0);  	// This call displays half of the ops dialog in the CD version. It's not  	// in the floppy version, and if it's called, a stray red dot is shown in  	// the game dialogs.  	if (isCD()) -		showFrame(_tempGraphics, kOpsx, kOpsy + 55, 4, 0); +		showFrame(_saveGraphics, kOpsx, kOpsy + 55, 4, 0);  }  void DreamWebEngine::showLoadOps() { -	showFrame(_tempGraphics, kOpsx + 128 + 4, kOpsy + 12, 1, 0); -	showFrame(_tempGraphics, kOpsx + 176 + 2, kOpsy + 60 - 4, 5, 0); +	showFrame(_saveGraphics, kOpsx + 128 + 4, kOpsy + 12, 1, 0); +	showFrame(_saveGraphics, kOpsx + 176 + 2, kOpsy + 60 - 4, 5, 0);  	printMessage(kOpsx + 104, kOpsy + 14, 55, 101, (101 & 1));  }  void DreamWebEngine::showSaveOps() { -	showFrame(_tempGraphics, kOpsx + 128 + 4, kOpsy + 12, 1, 0); -	showFrame(_tempGraphics, kOpsx + 176 + 2, kOpsy + 60 - 4, 5, 0); +	showFrame(_saveGraphics, kOpsx + 128 + 4, kOpsy + 12, 1, 0); +	showFrame(_saveGraphics, kOpsx + 176 + 2, kOpsy + 60 - 4, 5, 0);  	printMessage(kOpsx + 104, kOpsy + 14, 54, 101, (101 & 1));  } diff --git a/engines/dreamweb/sound.cpp b/engines/dreamweb/sound.cpp index b79be28cea..b51527a8cd 100644 --- a/engines/dreamweb/sound.cpp +++ b/engines/dreamweb/sound.cpp @@ -89,7 +89,7 @@ void DreamWebEngine::loadRoomsSample() {  		return; // loaded already  	assert(sample < 100); -	Common::String sampleName = Common::String::format("DREAMWEB.V%02d", sample); +	Common::String sampleSuffix = Common::String::format("V%02d", sample);  	_currentSample = sample;  	uint8 ch0 = _channel0Playing; @@ -98,7 +98,7 @@ void DreamWebEngine::loadRoomsSample() {  	uint8 ch1 = _channel1Playing;  	if (ch1 >= 12)  		cancelCh1(); -	loadSounds(1, sampleName.c_str()); +	loadSounds(1, sampleSuffix.c_str());  }  } // End of namespace DreamWeb @@ -240,7 +240,8 @@ void DreamWebEngine::soundHandler() {  } -void DreamWebEngine::loadSounds(uint bank, const Common::String &filename) { +void DreamWebEngine::loadSounds(uint bank, const Common::String &suffix) { +	Common::String filename = getDatafilePrefix() + suffix;  	debug(1, "loadSounds(%u, %s)", bank, filename.c_str());  	Common::File file;  	if (!file.open(filename)) { diff --git a/engines/dreamweb/structs.h b/engines/dreamweb/structs.h index cedf2b6d76..24b67e317a 100644 --- a/engines/dreamweb/structs.h +++ b/engines/dreamweb/structs.h @@ -339,9 +339,9 @@ struct TextFile {  };  struct GraphicsFile { -	GraphicsFile() : _data(0) { } +	GraphicsFile() : _data(0), _frames(0) { } -	Frame _frames[347]; +	Frame *_frames;  	uint8 *_data;  	const uint8 *getFrameData(unsigned int i) const { @@ -351,6 +351,8 @@ struct GraphicsFile {  		return _data + _frames[i].ptr();  	}  	void clear() { +		delete[] _frames; +		_frames = 0;  		delete[] _data;  		_data = 0;  	} diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index 5f8ea53ada..8e63774317 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -510,12 +510,27 @@ void DreamWebEngine::dreamwebFinalize() {  	_icons1.clear();  	_icons2.clear();  	_charset1.clear(); -	_tempGraphics.clear(); -	_tempGraphics2.clear(); -	_tempGraphics3.clear(); -	_tempCharset.clear();  	_mainSprites.clear(); +	// clear local graphics, just in case +	_keypadGraphics.clear(); +	_menuGraphics.clear(); +	_menuGraphics2.clear(); +	_folderGraphics.clear(); +	_folderGraphics2.clear(); +	_folderGraphics3.clear(); +	_folderCharset.clear(); +	_symbolGraphics.clear(); +	_diaryGraphics.clear(); +	_diaryCharset.clear(); +	_monitorGraphics.clear(); +	_monitorCharset.clear(); +	_newplaceGraphics.clear(); +	_newplaceGraphics2.clear(); +	_newplaceGraphics3.clear(); +	_cityGraphics.clear(); +	_saveGraphics.clear(); +  	_exFrames.clear();  	_exText.clear(); @@ -564,7 +579,7 @@ void DreamWebEngine::dreamweb() {  	readSetData();  	_wonGame = false; -	loadSounds(0, "DREAMWEB.V99"); // basic sample +	loadSounds(0, "V99"); // basic sample  	bool firstLoop = true; @@ -713,8 +728,8 @@ void DreamWebEngine::dreamweb() {  	}  } -void DreamWebEngine::loadTextFile(TextFile &file, const char *fileName) -{ +void DreamWebEngine::loadTextFile(TextFile &file, const char *suffix) { +	Common::String fileName = getDatafilePrefix() + suffix;  	FileHeader header;  	Common::File f; @@ -819,7 +834,8 @@ void DreamWebEngine::switchRyanOff() {  	_vars._ryanOn = 1;  } -void DreamWebEngine::loadGraphicsFile(GraphicsFile &file, const char *fileName) { +void DreamWebEngine::loadGraphicsFile(GraphicsFile &file, const char *suffix) { +	Common::String fileName = getDatafilePrefix() + suffix;  	FileHeader header;  	Common::File f; @@ -828,17 +844,18 @@ void DreamWebEngine::loadGraphicsFile(GraphicsFile &file, const char *fileName)  	uint16 sizeInBytes = header.len(0);  	assert(sizeInBytes >= kFrameBlocksize); -	delete[] file._data; +	file.clear();  	file._data = new uint8[sizeInBytes - kFrameBlocksize]; - +	file._frames = new Frame[kGraphicsFileFrameSize];  	f.read((uint8 *)file._frames, kFrameBlocksize);  	f.read(file._data, sizeInBytes - kFrameBlocksize);  }  void DreamWebEngine::loadGraphicsSegment(GraphicsFile &file, Common::File &inFile, unsigned int len) {  	assert(len >= kFrameBlocksize); -	delete[] file._data; +	file.clear();  	file._data = new uint8[len - kFrameBlocksize]; +	file._frames = new Frame[kGraphicsFileFrameSize];  	inFile.read((uint8 *)file._frames, kFrameBlocksize);  	inFile.read(file._data, len - kFrameBlocksize);  } @@ -852,22 +869,6 @@ void DreamWebEngine::loadTextSegment(TextFile &file, Common::File &inFile, unsig  	inFile.read((uint8 *)file._text, len - headerSize);  } -void DreamWebEngine::loadIntoTemp(const char *fileName) { -	loadGraphicsFile(_tempGraphics, fileName); -} - -void DreamWebEngine::loadIntoTemp2(const char *fileName) { -	loadGraphicsFile(_tempGraphics2, fileName); -} - -void DreamWebEngine::loadIntoTemp3(const char *fileName) { -	loadGraphicsFile(_tempGraphics3, fileName); -} - -void DreamWebEngine::loadTempCharset(const char *fileName) { -	loadGraphicsFile(_tempCharset, fileName); -} -  void DreamWebEngine::hangOnCurs(uint16 frameCount) {  	for (uint16 i = 0; i < frameCount; ++i) {  		printCurs(); @@ -1991,16 +1992,16 @@ void DreamWebEngine::loadRoom() {  }  void DreamWebEngine::readSetData() { -	loadGraphicsFile(_charset1, "DREAMWEB.C00"); -	loadGraphicsFile(_icons1, "DREAMWEB.G00"); -	loadGraphicsFile(_icons2, "DREAMWEB.G01"); -	loadGraphicsFile(_mainSprites, "DREAMWEB.S00"); -	loadTextFile(_puzzleText, "DREAMWEB.T80"); -	loadTextFile(_commandText, "DREAMWEB.T84"); +	loadGraphicsFile(_charset1, "C00"); +	loadGraphicsFile(_icons1, "G00"); +	loadGraphicsFile(_icons2, "G01"); +	loadGraphicsFile(_mainSprites, "S00"); +	loadTextFile(_puzzleText, "T80"); +	loadTextFile(_commandText, "T84");  	useCharset1();  	// FIXME: Why is this commented out? -	//openFile("DREAMWEB.VOL"); +	//openFile(getDatafilePrefix() + "VOL");  	//uint8 *volumeTab = getSegment(data.word(kSoundbuffer)).ptr(16384, 0);  	//readFromFile(volumeTab, 2048-256);  	//closeFile(); @@ -2065,30 +2066,14 @@ void DreamWebEngine::useCharset1() {  	_currentCharset = &_charset1;  } -void DreamWebEngine::useTempCharset() { -	_currentCharset = &_tempCharset; -} - -void DreamWebEngine::getRidOfTemp() { -	_tempGraphics.clear(); +void DreamWebEngine::useTempCharset(GraphicsFile *charset) { +	_currentCharset = charset;  }  void DreamWebEngine::getRidOfTempText() {  	_textFile1.clear();  } -void DreamWebEngine::getRidOfTemp2() { -	_tempGraphics2.clear(); -} - -void DreamWebEngine::getRidOfTemp3() { -	_tempGraphics3.clear(); -} - -void DreamWebEngine::getRidOfTempCharset() { -	_tempCharset.clear(); -} -  void DreamWebEngine::getRidOfAll() {  	delete[] _backdropBlocks;  	_backdropBlocks = 0; @@ -2251,11 +2236,11 @@ const uint8 *DreamWebEngine::getTextInFile1(uint16 index) {  }  void DreamWebEngine::loadTravelText() { -	loadTextFile(_travelText, "DREAMWEB.T81"); // location descs +	loadTextFile(_travelText, "T81"); // location descs  } -void DreamWebEngine::loadTempText(const char *fileName) { -	loadTextFile(_textFile1, fileName); +void DreamWebEngine::loadTempText(const char *suffix) { +	loadTextFile(_textFile1, suffix);  }  void DreamWebEngine::drawFloor() { @@ -2274,6 +2259,7 @@ void DreamWebEngine::drawFloor() {  void DreamWebEngine::allocateBuffers() {  	_exFrames.clear();  	_exFrames._data = new uint8[kExframeslen]; +	_exFrames._frames = new Frame[kGraphicsFileFrameSize];  	_exText.clear();  	_exText._text = new char[kExtextlen];  } @@ -2765,7 +2751,7 @@ void DreamWebEngine::decide() {  	} while (!_getBack);  	if (_getBack != 4) -		getRidOfTemp();	// room not loaded +		_saveGraphics.clear();	// room not loaded  	_textAddressX = 13;  	_textAddressY = 182; @@ -2794,16 +2780,17 @@ void DreamWebEngine::showGun() {  	_roomsSample = 34;  	loadRoomsSample();  	_volume = 0; -	loadIntoTemp("DREAMWEB.G13"); +	GraphicsFile graphics; +	loadGraphicsFile(graphics, "G13");  	createPanel2(); -	showFrame(_tempGraphics, 100, 4, 0, 0); -	showFrame(_tempGraphics, 158, 106, 1, 0); +	showFrame(graphics, 100, 4, 0, 0); +	showFrame(graphics, 158, 106, 1, 0);  	workToScreen(); -	getRidOfTemp(); +	graphics.clear();  	fadeScreenUp();  	hangOn(160);  	playChannel0(12, 0); -	loadTempText("DREAMWEB.T83"); +	loadTempText("T83");  	rollEndCreditsGameLost();  	getRidOfTempText();  } @@ -3018,7 +3005,7 @@ void DreamWebEngine::lookAtCard() {  	getRidOfReels();  	loadKeypad();  	createPanel2(); -	showFrame(_tempGraphics, 160, 80, 42, 128); +	showFrame(_keypadGraphics, 160, 80, 42, 128);  	const uint8 *obText = getObTextStart();  	findNextColon(&obText);  	findNextColon(&obText); @@ -3028,12 +3015,12 @@ void DreamWebEngine::lookAtCard() {  	workToScreenM();  	hangOnW(280);  	createPanel2(); -	showFrame(_tempGraphics, 160, 80, 42, 128); +	showFrame(_keypadGraphics, 160, 80, 42, 128);  	printDirect(obText, 36, 130, 241, 241 & 1);  	workToScreenM();  	hangOnW(200);  	_manIsOffScreen = 0; -	getRidOfTemp(); +	_keypadGraphics.clear();  	restoreReels();  	putBackObStuff();  } diff --git a/engines/dreamweb/titles.cpp b/engines/dreamweb/titles.cpp index 8ca5aa70b3..f7486ce687 100644 --- a/engines/dreamweb/titles.cpp +++ b/engines/dreamweb/titles.cpp @@ -26,7 +26,7 @@  namespace DreamWeb {  void DreamWebEngine::endGame() { -	loadTempText("DREAMWEB.T83"); +	loadTempText("T83");  	monkSpeaking();  	if (_quitRequested)  		return; @@ -40,9 +40,10 @@ void DreamWebEngine::endGame() {  void DreamWebEngine::monkSpeaking() {  	_roomsSample = 35;  	loadRoomsSample(); -	loadIntoTemp("DREAMWEB.G15"); +	GraphicsFile graphics; +	loadGraphicsFile(graphics, "G15");  	clearWork(); -	showFrame(_tempGraphics, 160, 72, 0, 128);	// show monk +	showFrame(graphics, 160, 72, 0, 128);	// show monk  	workToScreen();  	_volume = 7;  	_volumeDirection = -1; @@ -74,7 +75,7 @@ void DreamWebEngine::monkSpeaking() {  				printResult = printDirect(&string, 36, &y, 239, 239 & 1);  				workToScreen();  				clearWork(); -				showFrame(_tempGraphics, 160, 72, 0, 128);	// show monk +				showFrame(graphics, 160, 72, 0, 128);	// show monk  				hangOnP(240);  				if (_quitRequested)  					return; @@ -86,7 +87,7 @@ void DreamWebEngine::monkSpeaking() {  	_volumeTo = 7;  	fadeScreenDowns();  	hangOn(300); -	getRidOfTemp(); +	graphics.clear();  }  void DreamWebEngine::gettingShot() { @@ -103,7 +104,7 @@ void DreamWebEngine::gettingShot() {  void DreamWebEngine::bibleQuote() {  	initGraphics(640, 480, true); -	showPCX("DREAMWEB.I00"); +	showPCX("I00");  	fadeScreenUps();  	hangOne(80); @@ -140,7 +141,7 @@ void DreamWebEngine::hangOne(uint16 delay) {  }  void DreamWebEngine::intro() { -	loadTempText("DREAMWEB.T82"); +	loadTempText("T82");  	loadPalFromIFF();  	setMode();  	_newLocation = 50; @@ -291,7 +292,7 @@ void DreamWebEngine::realCredits() {  	initGraphics(640, 480, true);  	hangOn(35); -	showPCX("DREAMWEB.I01"); +	showPCX("I01");  	playChannel0(12, 0);  	hangOne(2); @@ -317,7 +318,7 @@ void DreamWebEngine::realCredits() {  		return; // "realcreditsearly"  	} -	showPCX("DREAMWEB.I02"); +	showPCX("I02");  	playChannel0(12, 0);  	hangOne(2); @@ -342,7 +343,7 @@ void DreamWebEngine::realCredits() {  		return; // "realcreditsearly"  	} -	showPCX("DREAMWEB.I03"); +	showPCX("I03");  	playChannel0(12, 0);  	hangOne(2); @@ -367,7 +368,7 @@ void DreamWebEngine::realCredits() {  		return; // "realcreditsearly"  	} -	showPCX("DREAMWEB.I04"); +	showPCX("I04");  	playChannel0(12, 0);  	hangOne(2); @@ -392,7 +393,7 @@ void DreamWebEngine::realCredits() {  		return; // "realcreditsearly"  	} -	showPCX("DREAMWEB.I05"); +	showPCX("I05");  	playChannel0(12, 0);  	hangOne(2); @@ -417,7 +418,7 @@ void DreamWebEngine::realCredits() {  		return; // "realcreditsearly"  	} -	showPCX("DREAMWEB.I06"); +	showPCX("I06");  	fadeScreenUps();  	hangOne(60); diff --git a/engines/dreamweb/use.cpp b/engines/dreamweb/use.cpp index fc0398c7b9..e59843539f 100644 --- a/engines/dreamweb/use.cpp +++ b/engines/dreamweb/use.cpp @@ -1501,7 +1501,7 @@ void DreamWebEngine::useCashCard() {  	showExit();  	showMan();  	uint16 y = (!_foreignRelease) ? 120 : 120 - 3; -	showFrame(_tempGraphics, 114, y, 39, 0); +	showFrame(_keypadGraphics, 114, y, 39, 0);  	const uint8 *obText = getObTextStart();  	findNextColon(&obText);  	findNextColon(&obText); @@ -1517,7 +1517,7 @@ void DreamWebEngine::useCashCard() {  	_charShift = 0;  	workToScreenM();  	hangOnP(400); -	getRidOfTemp(); +	_keypadGraphics.clear();  	restoreReels();  	putBackObStuff();  } diff --git a/engines/dreamweb/vgagrafx.cpp b/engines/dreamweb/vgagrafx.cpp index 26b5e60b9d..be7d210999 100644 --- a/engines/dreamweb/vgagrafx.cpp +++ b/engines/dreamweb/vgagrafx.cpp @@ -153,7 +153,8 @@ void DreamWebEngine::setMode() {  	initGraphics(320, 200, false);  } -void DreamWebEngine::showPCX(const Common::String &name) { +void DreamWebEngine::showPCX(const Common::String &suffix) { +	Common::String name = getDatafilePrefix() + suffix;  	Common::File pcxFile;  	if (!pcxFile.open(name)) { @@ -408,7 +409,7 @@ bool DreamWebEngine::pixelCheckSet(const ObjPos *pos, uint8 x, uint8 y) {  void DreamWebEngine::loadPalFromIFF() {  	Common::File palFile;  	uint8* buf = new uint8[2000]; -	palFile.open("DREAMWEB.PAL"); +	palFile.open(getDatafilePrefix() + "PAL");  	palFile.read(buf, 2000);  	palFile.close(); diff --git a/engines/engine.h b/engines/engine.h index a020dc4951..4f4223384a 100644 --- a/engines/engine.h +++ b/engines/engine.h @@ -24,6 +24,8 @@  #include "common/scummsys.h"  #include "common/str.h" +#include "common/language.h" +#include "common/platform.h"  class OSystem; diff --git a/engines/game.cpp b/engines/game.cpp index be15240745..4bfd8f3bf2 100644 --- a/engines/game.cpp +++ b/engines/game.cpp @@ -21,6 +21,7 @@   */  #include "engines/game.h" +#include "common/gui_options.h"  const PlainGameDescriptor *findPlainGameDescriptor(const char *gameid, const PlainGameDescriptor *list) { diff --git a/engines/game.h b/engines/game.h index d5136936bc..3417203ea7 100644 --- a/engines/game.h +++ b/engines/game.h @@ -26,7 +26,8 @@  #include "common/array.h"  #include "common/hash-str.h"  #include "common/str.h" -#include "common/util.h" +#include "common/language.h" +#include "common/platform.h"  /**   * A simple structure used to map gameids (like "monkey", "sword1", ...) to diff --git a/engines/gob/databases.h b/engines/gob/databases.h index fb65d8cf96..cde123e6a8 100644 --- a/engines/gob/databases.h +++ b/engines/gob/databases.h @@ -26,7 +26,7 @@  #include "common/str.h"  #include "common/hashmap.h"  #include "common/hash-str.h" -#include "common/util.h" +#include "common/language.h"  #include "gob/dbase.h" diff --git a/engines/gob/minigames/geisha/meter.cpp b/engines/gob/minigames/geisha/meter.cpp index 335622c5df..e3b9bd1ccf 100644 --- a/engines/gob/minigames/geisha/meter.cpp +++ b/engines/gob/minigames/geisha/meter.cpp @@ -101,7 +101,7 @@ void Meter::update() {  	_surface->fill(_backColor); -	int32 n = floor((((float) _width) / _maxValue * _value) + 0.5); +	int32 n = (int32)floor((((float) _width) / _maxValue * _value) + 0.5);  	if (n <= 0)  		return; diff --git a/engines/kyra/chargen.cpp b/engines/kyra/chargen.cpp index 73f5fccb92..54e1abcc2c 100644 --- a/engines/kyra/chargen.cpp +++ b/engines/kyra/chargen.cpp @@ -1496,7 +1496,7 @@ TransferPartyWiz::~TransferPartyWiz() {  }  bool TransferPartyWiz::start() { -	_screen->copyPage(0, (_screen->getPageScaleFactor(0) == 2) ? 1 : 12); +	_screen->copyPage(0, _vm->_useHiResDithering ? 1 : 12);  	if (!selectAndLoadTransferFile())  		return false; @@ -1536,7 +1536,7 @@ bool TransferPartyWiz::start() {  bool TransferPartyWiz::selectAndLoadTransferFile() {  	do { -		_screen->copyPage((_screen->getPageScaleFactor(0) == 2) ? 1 : 12, 0); +		_screen->copyPage(_vm->_useHiResDithering ? 1 : 12, 0);  		 if (transferFileDialogue(_vm->_savegameFilename))  			 break;  	} while (_vm->_gui->confirmDialogue2(15, 68, 1)); @@ -1566,7 +1566,7 @@ bool TransferPartyWiz::selectAndLoadTransferFile() {  		return false;  	Common::String target = _vm->_gui->transferTargetMenu(eobTargets); -	_screen->copyPage((_screen->getPageScaleFactor(0) == 2) ? 1 : 12, 0); +	_screen->copyPage(_vm->_useHiResDithering ? 1 : 12, 0);  	if (target.empty())  		return true; @@ -1579,10 +1579,10 @@ bool TransferPartyWiz::selectAndLoadTransferFile() {  			return true;  	} -	_screen->copyPage((_screen->getPageScaleFactor(0) == 2) ? 1 : 12, 0); +	_screen->copyPage(_vm->_useHiResDithering ? 1 : 12, 0);  	bool result = _vm->_gui->transferFileMenu(target, dest); -	_screen->copyPage((_screen->getPageScaleFactor(0) == 2) ? 1 : 12, 0); +	_screen->copyPage(_vm->_useHiResDithering ? 1 : 12, 0);  	return result;  } diff --git a/engines/kyra/detection.cpp b/engines/kyra/detection.cpp index 1a4fd3bd9d..46dfec84ff 100644 --- a/engines/kyra/detection.cpp +++ b/engines/kyra/detection.cpp @@ -140,6 +140,8 @@ bool KyraMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGame  		*engine = new Kyra::EoBEngine(syst, flags);  		break;  	case Kyra::GI_EOB2: +		 if (Common::parseRenderMode(ConfMan.get("render_mode")) == Common::kRenderEGA) +			 flags.useHiRes = true;  		*engine = new Kyra::DarkMoonEngine(syst, flags);  		break;  #endif // ENABLE_EOB diff --git a/engines/kyra/detection_tables.h b/engines/kyra/detection_tables.h index 44e604c44d..204c49cd2c 100644 --- a/engines/kyra/detection_tables.h +++ b/engines/kyra/detection_tables.h @@ -297,7 +297,7 @@ const KYRAGameDescription adGameDescs[] = {  			Common::JA_JPN,  			Common::kPlatformPC98,  			ADGF_NO_FLAGS, -			GUIO3(GUIO_NOSPEECH, GUIO_MIDIPC98, GUIO_RENDERPC98) +			GUIO4(GUIO_NOSPEECH, GUIO_MIDIPC98, GUIO_RENDERPC9821, GUIO_RENDERPC9801)  		},  		KYRA1_TOWNS_SJIS_FLAGS  	}, @@ -743,7 +743,7 @@ const KYRAGameDescription adGameDescs[] = {  			Common::EN_ANY,  			Common::kPlatformPC98,  			ADGF_CD, -			GUIO3(GUIO_NOSPEECH, GUIO_MIDIPC98, GUIO_RENDERPC98) +			GUIO3(GUIO_NOSPEECH, GUIO_MIDIPC98, GUIO_RENDERPC9821)  		},  		KYRA2_TOWNS_FLAGS  	}, @@ -755,7 +755,7 @@ const KYRAGameDescription adGameDescs[] = {  			Common::JA_JPN,  			Common::kPlatformPC98,  			ADGF_CD, -			GUIO3(GUIO_NOSPEECH, GUIO_MIDIPC98, GUIO_RENDERPC98) +			GUIO3(GUIO_NOSPEECH, GUIO_MIDIPC98, GUIO_RENDERPC9821)  		},  		KYRA2_TOWNS_SJIS_FLAGS  	}, @@ -1418,7 +1418,7 @@ const KYRAGameDescription adGameDescs[] = {  			Common::JA_JPN,  			Common::kPlatformPC98,  			ADGF_NO_FLAGS, -			GUIO3(GUIO_NOSPEECH, GUIO_MIDIPC98, GUIO_RENDERPC98) +			GUIO3(GUIO_NOSPEECH, GUIO_MIDIPC98, GUIO_RENDERPC9801)  		},  		LOL_PC98_SJIS_FLAGS  	}, diff --git a/engines/kyra/eobcommon.cpp b/engines/kyra/eobcommon.cpp index ff53ba8b0a..1489e4f1f5 100644 --- a/engines/kyra/eobcommon.cpp +++ b/engines/kyra/eobcommon.cpp @@ -57,6 +57,8 @@ EoBCoreEngine::EoBCoreEngine(OSystem *system, const GameFlags &flags)  	_configMouse = true;  	_loading = false; +	_useHiResDithering = false; +  	_envAudioTimer = 0;  	_flashShapeTimer = 0;  	_drawSceneTimer = 0; @@ -369,9 +371,11 @@ Common::Error EoBCoreEngine::init() {  	if (ConfMan.hasKey("render_mode"))  		_configRenderMode = Common::parseRenderMode(ConfMan.get("render_mode")); +	_useHiResDithering = (_configRenderMode == Common::kRenderEGA && _flags.useHiRes); +  	_screen = new Screen_EoB(this, _system);  	assert(_screen); -	_screen->setResolution(_flags.useHiResOverlay || (_flags.gameID == GI_EOB2 && _configRenderMode == Common::kRenderEGA)); +	_screen->setResolution();  	//MidiDriverType midiDriver = MidiDriver::detectDevice(MDT_PCSPK | MDT_ADLIB);  	_sound = new SoundAdLibPC(this, _mixer); @@ -390,7 +394,7 @@ Common::Error EoBCoreEngine::init() {  	if (!_staticres->init())  		error("_staticres->init() failed"); -	if (!_screen->init(_flags.gameID == GI_EOB2 && _configRenderMode == Common::kRenderEGA)) +	if (!_screen->init())  		error("screen()->init() failed");  	if (ConfMan.hasKey("save_slot")) { @@ -413,6 +417,12 @@ Common::Error EoBCoreEngine::init() {  	_screen->loadFont(Screen::FID_6_FNT, "FONT6.FNT");  	_screen->loadFont(Screen::FID_8_FNT, "FONT8.FNT"); +	if (_useHiResDithering) { +		_vcnBlockWidth <<= 1; +		_vcnBlockHeight <<= 1; +		SWAP(_vcnFlip0, _vcnFlip1); +	} +  	Common::Error err = KyraRpgEngine::init();  	if (err.getCode() != Common::kNoError)  		return err; @@ -1738,7 +1748,7 @@ void EoBCoreEngine::seq_portal() {  bool EoBCoreEngine::checkPassword() {  	char answ[20];  	Screen::FontId of = _screen->setFont(Screen::FID_8_FNT); -	_screen->copyPage(0, (_screen->getPageScaleFactor(0) == 2) ? 4 : 10); +	_screen->copyPage(0, _useHiResDithering ? 4 : 10);  	_screen->setScreenDim(13);  	gui_drawBox(_screen->_curDim->sx << 3, _screen->_curDim->sy, _screen->_curDim->w << 3, _screen->_curDim->h, guiSettings()->colors.frame1, guiSettings()->colors.frame2, -1); @@ -1765,7 +1775,7 @@ bool EoBCoreEngine::checkPassword() {  	_screen->modifyScreenDim(13, _screen->_curDim->sx - 1, _screen->_curDim->sy - 2, _screen->_curDim->w + 2, _screen->_curDim->h + 16);  	_screen->setFont(of); -	_screen->copyPage((_screen->getPageScaleFactor(0) == 2) ? 4 : 10, 0); +	_screen->copyPage(_useHiResDithering ? 4 : 10, 0);  	return true;  } diff --git a/engines/kyra/eobcommon.h b/engines/kyra/eobcommon.h index 38be2a64e8..050fe2b794 100644 --- a/engines/kyra/eobcommon.h +++ b/engines/kyra/eobcommon.h @@ -845,6 +845,8 @@ protected:  	const uint8 *_cgaMappingLevel[5];  	const uint8 *_cgaLevelMappingIndex; +	bool _useHiResDithering; +  	// Default parameters will import all present original save files and push them to the top of the save dialog.  	bool importOriginalSaveFile(int destSlot, const char *sourceFile = 0);  	Common::String readOriginalSaveFile(Common::String &file); diff --git a/engines/kyra/gui_eob.cpp b/engines/kyra/gui_eob.cpp index eadfd10d1e..e8e69d5b1f 100644 --- a/engines/kyra/gui_eob.cpp +++ b/engines/kyra/gui_eob.cpp @@ -777,11 +777,11 @@ int EoBCoreEngine::clickedCamp(Button *button) {  	}  	_screen->copyPage(0, 7); -	_screen->copyRegion(0, 120, 0, 0, 176, 24, 0, (_screen->getPageScaleFactor(0) == 2) ? 1 : 12, Screen::CR_NO_P_CHECK); +	_screen->copyRegion(0, 120, 0, 0, 176, 24, 0, _useHiResDithering ? 1 : 12, Screen::CR_NO_P_CHECK);  	_gui->runCampMenu(); -	_screen->copyRegion(0, 0, 0, 120, 176, 24, (_screen->getPageScaleFactor(0) == 2) ? 1 : 12, 2, Screen::CR_NO_P_CHECK); +	_screen->copyRegion(0, 0, 0, 120, 176, 24, _useHiResDithering ? 1 : 12, 2, Screen::CR_NO_P_CHECK);  	_screen->setScreenDim(cd);  	drawScene(0); @@ -1170,7 +1170,7 @@ int EoBCoreEngine::clickedSceneSpecial(Button *button) {  int EoBCoreEngine::clickedSpellbookAbort(Button *button) {  	_updateFlags = 0; -	_screen->copyRegion(0, 0, 64, 121, 112, 56, (_screen->getPageScaleFactor(0) == 2) ? 4 : 10, 0, Screen::CR_NO_P_CHECK); +	_screen->copyRegion(0, 0, 64, 121, 112, 56, _useHiResDithering ? 4 : 10, 0, Screen::CR_NO_P_CHECK);  	_screen->updateScreen();  	gui_drawCompass(true);  	gui_toggleButtons(); @@ -2172,7 +2172,7 @@ void GUI_EoB::runCampMenu() {  				if (cnt > 4) {  					_vm->dropCharacter(selectCharacterDialogue(53));  					_vm->gui_drawPlayField(false); -					_screen->copyRegion(0, 120, 0, 0, 176, 24, 0, (_screen->getPageScaleFactor(0) == 2) ? 1 : 12, Screen::CR_NO_P_CHECK); +					_screen->copyRegion(0, 120, 0, 0, 176, 24, 0, _vm->_useHiResDithering ? 1 : 12, Screen::CR_NO_P_CHECK);  					_screen->setFont(Screen::FID_6_FNT);  					_vm->gui_drawAllCharPortraitsWithStats();  					_screen->setFont(Screen::FID_8_FNT); @@ -2607,7 +2607,7 @@ Common::String GUI_EoB::transferTargetMenu(Common::Array<Common::String> &target  			break;  	} while (_saveSlotIdTemp[slot] == -1); -	_screen->copyRegion(72, 14, 72, 14, 176, 144, (_screen->getPageScaleFactor(0) == 2) ? 7 : 12, 0, Screen::CR_NO_P_CHECK); +	_screen->copyRegion(72, 14, 72, 14, 176, 144, _vm->_useHiResDithering ? 7 : 12, 0, Screen::CR_NO_P_CHECK);  	_screen->modifyScreenDim(11, xo, yo, dm->w, dm->h);  	return (slot < 6) ? _savegameList[_savegameOffset + slot] : Common::String(); @@ -2648,7 +2648,14 @@ bool GUI_EoB::transferFileMenu(Common::String &targetName, Common::String &selec  void GUI_EoB::createScreenThumbnail(Graphics::Surface &dst) {  	uint8 *screenPal = new uint8[768];  	_screen->getRealPalette(0, screenPal); -	::createThumbnail(&dst, _screen->getCPagePtr(7), Screen::SCREEN_W, Screen::SCREEN_H, screenPal); +	uint16 width = Screen::SCREEN_W; +	uint16 height = Screen::SCREEN_H; +	if (_vm->_useHiResDithering) { +		width <<= 1; +		height <<= 1; +	} + +	::createThumbnail(&dst, _screen->getCPagePtr(7), width, height, screenPal);  	delete[] screenPal;  } diff --git a/engines/kyra/kyra_hof.cpp b/engines/kyra/kyra_hof.cpp index b07e3a4965..0ba173d9d0 100644 --- a/engines/kyra/kyra_hof.cpp +++ b/engines/kyra/kyra_hof.cpp @@ -221,7 +221,7 @@ void KyraEngine_HoF::pauseEngineIntern(bool pause) {  Common::Error KyraEngine_HoF::init() {  	_screen = new Screen_HoF(this, _system);  	assert(_screen); -	_screen->setResolution(_flags.useHiResOverlay); +	_screen->setResolution();  	_debugger = new Debugger_HoF(this);  	assert(_debugger); diff --git a/engines/kyra/kyra_lok.cpp b/engines/kyra/kyra_lok.cpp index e8a2c02e6e..ece4a0daba 100644 --- a/engines/kyra/kyra_lok.cpp +++ b/engines/kyra/kyra_lok.cpp @@ -167,12 +167,12 @@ KyraEngine_LoK::~KyraEngine_LoK() {  }  Common::Error KyraEngine_LoK::init() { -	if (_flags.platform == Common::kPlatformPC98 && _flags.useHiResOverlay && ConfMan.getBool("16_color")) +	if (Common::parseRenderMode(ConfMan.get("render_mode")) == Common::kRenderPC9801)  		_screen = new Screen_LoK_16(this, _system);  	else  		_screen = new Screen_LoK(this, _system);  	assert(_screen); -	_screen->setResolution(_flags.useHiResOverlay); +	_screen->setResolution();  	_debugger = new Debugger_LoK(this);  	assert(_debugger); @@ -960,9 +960,6 @@ void KyraEngine_LoK::registerDefaultSettings() {  	// Most settings already have sensible defaults. This one, however, is  	// specific to the Kyra engine.  	ConfMan.registerDefault("walkspeed", 2); - -	if (_flags.platform == Common::kPlatformPC98 && _flags.useHiResOverlay) -		ConfMan.registerDefault("16_color", false);  }  void KyraEngine_LoK::readSettings() { diff --git a/engines/kyra/kyra_mr.cpp b/engines/kyra/kyra_mr.cpp index 38f473a619..39ed0d038a 100644 --- a/engines/kyra/kyra_mr.cpp +++ b/engines/kyra/kyra_mr.cpp @@ -203,7 +203,7 @@ KyraEngine_MR::~KyraEngine_MR() {  Common::Error KyraEngine_MR::init() {  	_screen = new Screen_MR(this, _system);  	assert(_screen); -	_screen->setResolution(_flags.useHiResOverlay); +	_screen->setResolution();  	_debugger = new Debugger_v2(this);  	assert(_debugger); diff --git a/engines/kyra/kyra_rpg.cpp b/engines/kyra/kyra_rpg.cpp index 121731e394..8857f64f7e 100644 --- a/engines/kyra/kyra_rpg.cpp +++ b/engines/kyra/kyra_rpg.cpp @@ -171,12 +171,6 @@ Common::Error KyraRpgEngine::init() {  	_wllWallFlags = new uint8[256];  	memset(_wllWallFlags, 0, 256); -	if (_flags.gameID == GI_EOB2 && _configRenderMode == Common::kRenderEGA) { -		_vcnBlockWidth <<= 1; -		_vcnBlockHeight <<= 1; -		SWAP(_vcnFlip0, _vcnFlip1); -	} -  	_blockDrawingBuffer = new uint16[1320];  	memset(_blockDrawingBuffer, 0, 1320 * sizeof(uint16));  	uint32 swbSize = 22 * _vcnBlockWidth * 2 * 15 * _vcnBlockHeight; diff --git a/engines/kyra/kyra_v1.cpp b/engines/kyra/kyra_v1.cpp index 7c67af2f13..2672618c67 100644 --- a/engines/kyra/kyra_v1.cpp +++ b/engines/kyra/kyra_v1.cpp @@ -233,19 +233,16 @@ KyraEngine_v1::~KyraEngine_v1() {  Common::Point KyraEngine_v1::getMousePos() {  	Common::Point mouse = _eventMan->getMousePos(); -	if (_flags.useHiResOverlay) { +	if (_flags.useHiRes) {  		mouse.x >>= 1;  		mouse.y >>= 1;  	} -	mouse.x /= screen()->getPageScaleFactor(0); -	mouse.y /= screen()->getPageScaleFactor(0); -  	return mouse;  }  void KyraEngine_v1::setMousePos(int x, int y) { -	if (_flags.useHiResOverlay) { +	if (_flags.useHiRes) {  		x <<= 1;  		y <<= 1;  	} @@ -312,12 +309,10 @@ int KyraEngine_v1::checkInput(Button *buttonList, bool mainLoop, int eventFlag)  		case Common::EVENT_LBUTTONUP: {  			_mouseX = event.mouse.x;  			_mouseY = event.mouse.y; -			if (_flags.useHiResOverlay) { +			if (_flags.useHiRes) {  				_mouseX >>= 1;  				_mouseY >>= 1;  			} -			_mouseX /= screen()->getPageScaleFactor(0); -			_mouseY /= screen()->getPageScaleFactor(0);  			keys = (event.type == Common::EVENT_LBUTTONDOWN ? 199 : (200 | 0x800));  			breakLoop = true;  			} break; @@ -326,12 +321,10 @@ int KyraEngine_v1::checkInput(Button *buttonList, bool mainLoop, int eventFlag)  		case Common::EVENT_RBUTTONUP: {  			_mouseX = event.mouse.x;  			_mouseY = event.mouse.y; -			if (_flags.useHiResOverlay) { +			if (_flags.useHiRes) {  				_mouseX >>= 1;  				_mouseY >>= 1;  			} -			_mouseX /= screen()->getPageScaleFactor(0); -			_mouseY /= screen()->getPageScaleFactor(0);  			keys = (event.type == Common::EVENT_RBUTTONDOWN ? 201 : (202 | 0x800));  			breakLoop = true;  			} break; diff --git a/engines/kyra/kyra_v1.h b/engines/kyra/kyra_v1.h index 95d58d4ab2..11173a45c7 100644 --- a/engines/kyra/kyra_v1.h +++ b/engines/kyra/kyra_v1.h @@ -28,8 +28,9 @@  #include "common/array.h"  #include "common/error.h"  #include "common/events.h" -#include "common/random.h"  #include "common/hashmap.h" +#include "common/random.h" +#include "common/rendermode.h"  #include "audio/mixer.h" @@ -118,7 +119,7 @@ struct GameFlags {  	bool useAltShapeHeader    : 1;    // alternative shape header (uses 2 bytes more, those are unused though)  	bool isTalkie             : 1;  	bool isOldFloppy          : 1; -	bool useHiResOverlay      : 1; +	bool useHiRes      : 1;  	bool use16ColorMode       : 1;  	bool useDigSound          : 1;  	bool useInstallerPackage  : 1; diff --git a/engines/kyra/lol.cpp b/engines/kyra/lol.cpp index 022a878e0a..38e9d33259 100644 --- a/engines/kyra/lol.cpp +++ b/engines/kyra/lol.cpp @@ -364,7 +364,7 @@ GUI *LoLEngine::gui() const {  Common::Error LoLEngine::init() {  	_screen = new Screen_LoL(this, _system);  	assert(_screen); -	_screen->setResolution(_flags.useHiResOverlay); +	_screen->setResolution();  	_debugger = new Debugger_LoL(this);  	assert(_debugger); diff --git a/engines/kyra/magic_eob.cpp b/engines/kyra/magic_eob.cpp index b2949ce1d5..985286854b 100644 --- a/engines/kyra/magic_eob.cpp +++ b/engines/kyra/magic_eob.cpp @@ -60,7 +60,7 @@ void EoBCoreEngine::useMagicBookOrSymbol(int charIndex, int type) {  	}  	if (!_updateFlags) -		_screen->copyRegion(64, 121, 0, 0, 112, 56, 0, (_screen->getPageScaleFactor(0) == 2) ? 4 : 10, Screen::CR_NO_P_CHECK); +		_screen->copyRegion(64, 121, 0, 0, 112, 56, 0, _useHiResDithering ? 4 : 10, Screen::CR_NO_P_CHECK);  	_updateFlags = 1;  	gui_setPlayFieldButtons();  	gui_drawSpellbook(); diff --git a/engines/kyra/saveload_eob.cpp b/engines/kyra/saveload_eob.cpp index 4a446aa3f3..f7d7d95b57 100644 --- a/engines/kyra/saveload_eob.cpp +++ b/engines/kyra/saveload_eob.cpp @@ -298,7 +298,7 @@ Common::Error EoBCoreEngine::loadGameState(int slot) {  		useMagicBookOrSymbol(_openBookChar, _openBookType);  	} -	_screen->copyRegion(0, 120, 0, 0, 176, 24, 0, (_screen->getPageScaleFactor(0) == 2) ? 1 : 12, Screen::CR_NO_P_CHECK); +	_screen->copyRegion(0, 120, 0, 0, 176, 24, 0, _useHiResDithering ? 1 : 12, Screen::CR_NO_P_CHECK);  	gui_toggleButtons();  	setHandItem(_itemInHand); diff --git a/engines/kyra/screen.cpp b/engines/kyra/screen.cpp index ef6333b350..d3b4d6f943 100644 --- a/engines/kyra/screen.cpp +++ b/engines/kyra/screen.cpp @@ -106,8 +106,9 @@ bool Screen::init() {  	memset(_fonts, 0, sizeof(_fonts)); -	if (_vm->gameFlags().useHiResOverlay) { -		_useOverlays = true; +	_useOverlays = (_vm->gameFlags().useHiRes && _renderMode != Common::kRenderEGA); + +	if (_useOverlays) {  		_useSJIS = (_vm->gameFlags().lang == Common::JA_JPN);  		_sjisInvisibleColor = (_vm->game() == GI_KYRA1) ? 0x80 : 0xF6; @@ -226,7 +227,7 @@ bool Screen::enableScreenDebug(bool enable) {  	if (_debugEnabled != enable) {  		_debugEnabled = enable; -		setResolution(_vm->gameFlags().useHiResOverlay); +		setResolution();  		_forceFullUpdate = true;  		updateScreen();  	} @@ -234,14 +235,14 @@ bool Screen::enableScreenDebug(bool enable) {  	return temp;  } -void Screen::setResolution(bool hiRes) { +void Screen::setResolution() {  	byte palette[3*256];  	_system->getPaletteManager()->grabPalette(palette, 0, 256);  	int width = 320, height = 200;  	bool defaultTo1xScaler = false; -	if (hiRes) { +	if (_vm->gameFlags().useHiRes) {  		defaultTo1xScaler = true;  		height = 400; @@ -466,11 +467,6 @@ const uint8 *Screen::getCPagePtr(int pageNum) const {  	return _pagePtrs[pageNum];  } -int Screen::getPageScaleFactor(int pageNum) { -	assert(pageNum < SCREEN_PAGE_NUM); -	return _pageScaleFactor[pageNum]; -} -  uint8 *Screen::getPageRect(int pageNum, int x, int y, int w, int h) {  	assert(pageNum < SCREEN_PAGE_NUM);  	if (pageNum == 0 || pageNum == 1) @@ -1226,7 +1222,7 @@ bool Screen::loadFont(FontId fontId, const char *filename) {  			fnt = new AMIGAFont();  #ifdef ENABLE_EOB  		else if (_vm->game() == GI_EOB1 || _vm->game() == GI_EOB2) -			fnt = new OldDOSFont(_renderMode, (_vm->game() == GI_EOB2) && (_renderMode == Common::kRenderEGA)); +			fnt = new OldDOSFont(_renderMode, _vm->gameFlags().useHiRes);  #endif // ENABLE_EOB  		else  			fnt = new DOSFont(); @@ -2896,21 +2892,20 @@ void Screen::setMouseCursor(int x, int y, const byte *shape) {  	if (_vm->gameFlags().useAltShapeHeader)  		shape -= 2; -	if (_vm->gameFlags().useHiResOverlay) { +	if (_vm->gameFlags().useHiRes) {  		x <<= 1;  		y <<= 1;  		mouseWidth <<= 1;  		mouseHeight <<= 1;  	} -  	uint8 *cursor = new uint8[mouseHeight * mouseWidth];  	fillRect(0, 0, mouseWidth, mouseHeight, _cursorColorKey, 8);  	drawShape(8, shape, 0, 0, 0, 0);  	int xOffset = 0; -	if (_vm->gameFlags().useHiResOverlay) { +	if (_vm->gameFlags().useHiRes) {  		xOffset = mouseWidth;  		scale2x(getPagePtr(8) + mouseWidth, SCREEN_W, getPagePtr(8), SCREEN_W, mouseWidth, mouseHeight);  		postProcessCursor(getPagePtr(8) + mouseWidth, mouseWidth, mouseHeight, SCREEN_W); diff --git a/engines/kyra/screen.h b/engines/kyra/screen.h index 18c0aa90f7..b064c72bb0 100644 --- a/engines/kyra/screen.h +++ b/engines/kyra/screen.h @@ -28,6 +28,7 @@  #include "common/list.h"  #include "common/array.h"  #include "common/rect.h" +#include "common/rendermode.h"  #include "common/stream.h"  class OSystem; @@ -168,6 +169,7 @@ private:  	Common::RenderMode _renderMode;  	bool _useHiResEGADithering; +	bool _useLoResEGA;  	static uint16 *_cgaDitheringTable;  	static int _numRef; @@ -398,7 +400,7 @@ public:  	// init  	virtual bool init(); -	virtual void setResolution(bool hiRes = false); +	virtual void setResolution();  	void updateScreen(); @@ -433,8 +435,6 @@ public:  	virtual void setPagePixel(int pageNum, int x, int y, uint8 color);  	const uint8 *getCPagePtr(int pageNum) const; -	int getPageScaleFactor(int pageNum); -  	uint8 *getPageRect(int pageNum, int x, int y, int w, int h);  	// palette handling @@ -453,7 +453,7 @@ public:  	void enableInterfacePalette(bool e);  	void setInterfacePalette(const Palette &pal, uint8 r, uint8 g, uint8 b); -	void getRealPalette(int num, uint8 *dst); +	virtual void getRealPalette(int num, uint8 *dst);  	Palette &getPalette(int num);  	void copyPalette(const int dst, const int src); @@ -580,6 +580,8 @@ protected:  	bool _useOverlays;  	bool _useSJIS;  	bool _use16ColorMode; +	bool _useHiResEGADithering; +	bool _useLoResEGA;  	bool _isAmiga;  	Common::RenderMode _renderMode; diff --git a/engines/kyra/screen_eob.cpp b/engines/kyra/screen_eob.cpp index 38521d757c..9fae729bc4 100644 --- a/engines/kyra/screen_eob.cpp +++ b/engines/kyra/screen_eob.cpp @@ -55,7 +55,7 @@ Screen_EoB::Screen_EoB(EoBCoreEngine *vm, OSystem *system) : Screen(vm, system,  	_egaPixelValueTable = 0;  	_cgaMappingDefault = 0;  	_cgaDitheringTables[0] = _cgaDitheringTables[1] = 0; -	_useHiResEGADithering = false; +	_useLoResEGA = _useHiResEGADithering = false;  }  Screen_EoB::~Screen_EoB() { @@ -69,12 +69,8 @@ Screen_EoB::~Screen_EoB() {  }  bool Screen_EoB::init() { -	return init(false); -} - -bool Screen_EoB::init(bool useHiResEGADithering) {  	// Define hi-res pages for EGA mode in EOB II -	if (useHiResEGADithering) { +	if (_vm->gameFlags().useHiRes) {  		for (int i = 0; i < 8; i++)  			_pageScaleFactor[i] = 2;  	} @@ -99,15 +95,16 @@ bool Screen_EoB::init(bool useHiResEGADithering) {  		_dsTempPage = new uint8[12000]; -		if (_renderMode == Common::kRenderEGA) { -			_useHiResEGADithering = useHiResEGADithering; +		if (_vm->gameFlags().useHiRes && _renderMode == Common::kRenderEGA) { +			_useHiResEGADithering = true;  			_egaDitheringTable = new uint8[256];  			_egaPixelValueTable = new uint8[256];  			for (int i = 0; i < 256; i++) {  				_egaDitheringTable[i] = i & 0x0f;  				_egaPixelValueTable[i] = i & 0x0f;  			} - +		} else if (_renderMode == Common::kRenderEGA) { +			_useLoResEGA = true;  		} else if (_renderMode == Common::kRenderCGA) {  			_cgaMappingDefault = _vm->staticres()->loadRawData(kEoB1CgaMappingDefault, temp);  			_cgaDitheringTables[0] = new uint16[256]; @@ -425,6 +422,21 @@ void Screen_EoB::setScreenPalette(const Palette &pal) {  	}  } +void Screen_EoB::getRealPalette(int num, uint8 *dst) { +	if (_renderMode == Common::kRenderCGA || _renderMode == Common::kRenderEGA) { +		const uint8 *pal = _screenPalette->getData(); +		for (int i = 0; i < 16; ++i) { +			dst[0] = (pal[0] << 2) | (pal[0] & 3); +			dst[1] = (pal[1] << 2) | (pal[1] & 3); +			dst[2] = (pal[2] << 2) | (pal[2] & 3); +			dst += 3; +			pal += 3; +		} +	} else { +		Screen::getRealPalette(num, dst); +	} +} +  uint8 *Screen_EoB::encodeShape(uint16 x, uint16 y, uint16 w, uint16 h, bool encode8bit, const uint8 *cgaMapping) {  	uint8 *shp = 0;  	uint16 shapesize = 0; @@ -432,7 +444,7 @@ uint8 *Screen_EoB::encodeShape(uint16 x, uint16 y, uint16 w, uint16 h, bool enco  	uint8 *srcLineStart = getPagePtr(_curPage | 1) + y * 320 + (x << 3);  	uint8 *src = srcLineStart; -	if (_renderMode == Common::kRenderEGA && !_useHiResEGADithering) +	if (_useLoResEGA)  		encode8bit = false;  	if (_renderMode == Common::kRenderCGA) { @@ -556,7 +568,7 @@ uint8 *Screen_EoB::encodeShape(uint16 x, uint16 y, uint16 w, uint16 h, bool enco  		*dst++ = (w & 0xff);  		*dst++ = (h & 0xff); -		if (_renderMode == Common::kRenderEGA && !_useHiResEGADithering) { +		if (_useLoResEGA) {  			for (int i = 0; i < 16; i++)  				dst[i] = i;  		} else { @@ -1538,6 +1550,7 @@ OldDOSFont::OldDOSFont(Common::RenderMode mode, bool useHiResEGADithering) : _re  	_data = 0;  	_width = _height = _numGlyphs = 0;  	_bitmapOffsets = 0; +	_useLoResEGA = (_renderMode == Common::kRenderEGA && !_useHiResEGADithering);  	_numRef++;  	if (!_cgaDitheringTable && _numRef == 1) { @@ -1664,7 +1677,7 @@ void OldDOSFont::drawChar(uint16 c, byte *dst, int pitch) const {  	uint16 cgaMask1 = cgaColorMask[color1 & 3];  	uint16 cgaMask2 = cgaColorMask[color2 & 3]; -	if (_renderMode == Common::kRenderCGA || (_renderMode == Common::kRenderEGA && !_useHiResEGADithering)) { +	if (_renderMode == Common::kRenderCGA || _useLoResEGA) {  		color1 &= 0x0f;  		color2 &= 0x0f;  	} diff --git a/engines/kyra/screen_eob.h b/engines/kyra/screen_eob.h index 2bcfbd8f60..fc40cfe903 100644 --- a/engines/kyra/screen_eob.h +++ b/engines/kyra/screen_eob.h @@ -36,7 +36,6 @@ public:  	virtual ~Screen_EoB();  	bool init(); -	bool init(bool useHiResEGADithering);  	void setClearScreenDim(int dim);  	void clearCurDim(); @@ -60,6 +59,7 @@ public:  	void setPagePixel(int pageNum, int x, int y, uint8 color);  	void setScreenPalette(const Palette &pal); +	void getRealPalette(int num, uint8 *dst);  	uint8 *encodeShape(uint16 x, uint16 y, uint16 w, uint16 h, bool encode8bit = false, const uint8 *cgaMapping = 0);  	void drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y, int sd = -1, int flags = 0, ...); @@ -116,7 +116,6 @@ private:  	uint8 *_egaDitheringTable;  	uint8 *_egaPixelValueTable; -	bool _useHiResEGADithering;  	static const uint8 _egaMatchTable[];  	static const ScreenDim _screenDimTable[]; diff --git a/engines/queen/input.h b/engines/queen/input.h index 0aa04dd026..b3bf811cd1 100644 --- a/engines/queen/input.h +++ b/engines/queen/input.h @@ -23,7 +23,7 @@  #ifndef QUEEN_INPUT_H  #define QUEEN_INPUT_H -#include "common/util.h" +#include "common/language.h"  #include "common/rect.h"  #include "common/events.h"  #include "queen/defs.h" diff --git a/engines/queen/queen.cpp b/engines/queen/queen.cpp index c610ef9921..d17268e16b 100644 --- a/engines/queen/queen.cpp +++ b/engines/queen/queen.cpp @@ -25,6 +25,7 @@  #include "common/config-manager.h"  #include "common/file.h"  #include "common/fs.h" +#include "common/gui_options.h"  #include "common/savefile.h"  #include "common/system.h"  #include "common/events.h" diff --git a/engines/queen/resource.h b/engines/queen/resource.h index ef8e463631..7317ec5134 100644 --- a/engines/queen/resource.h +++ b/engines/queen/resource.h @@ -25,7 +25,8 @@  #include "common/file.h"  #include "common/str-array.h" -#include "common/util.h" +#include "common/language.h" +#include "common/platform.h"  #include "queen/defs.h"  namespace Queen { diff --git a/engines/scumm/detection.h b/engines/scumm/detection.h index ad8b3cec12..b6dfa757bb 100644 --- a/engines/scumm/detection.h +++ b/engines/scumm/detection.h @@ -23,7 +23,8 @@  #ifndef SCUMM_DETECTION_H  #define SCUMM_DETECTION_H -#include "common/util.h" +#include "common/language.h" +#include "common/platform.h"  namespace Scumm { diff --git a/engines/scumm/detection_tables.h b/engines/scumm/detection_tables.h index 844ac3e5c4..22708de2d3 100644 --- a/engines/scumm/detection_tables.h +++ b/engines/scumm/detection_tables.h @@ -24,6 +24,7 @@  #define SCUMM_DETECTION_TABLES_H  #include "engines/obsolete.h" +#include "common/gui_options.h"  #include "common/rect.h"  #include "common/util.h" diff --git a/engines/scumm/gfx.cpp b/engines/scumm/gfx.cpp index 48ccdfd1cf..2cf4a429db 100644 --- a/engines/scumm/gfx.cpp +++ b/engines/scumm/gfx.cpp @@ -680,11 +680,10 @@ void ScummEngine::drawStripToScreen(VirtScreen *vs, int x, int width, int top, i  				srcPtr += vsPitch;  				textPtr += _textSurface.pitch - width * m;  			} -		} +		} else {  #ifdef USE_ARM_GFX_ASM -		asmDrawStripToScreen(height, width, text, src, _compositeBuf, vs->pitch, width, _textSurface.pitch); +			asmDrawStripToScreen(height, width, text, src, _compositeBuf, vs->pitch, width, _textSurface.pitch);  #else -		else {  			// We blit four pixels at a time, for improved performance.  			const uint32 *src32 = (const uint32 *)src;  			uint32 *dst32 = (uint32 *)_compositeBuf; @@ -715,8 +714,8 @@ void ScummEngine::drawStripToScreen(VirtScreen *vs, int x, int width, int top, i  				src32 += vsPitch;  				text32 += textPitch;  			} -		}  #endif +		}  		src = _compositeBuf;  		pitch = width * vs->format.bytesPerPixel; diff --git a/engines/scumm/gfxARM.s b/engines/scumm/gfxARM.s index 92f8951466..9238888831 100644 --- a/engines/scumm/gfxARM.s +++ b/engines/scumm/gfxARM.s @@ -59,10 +59,6 @@ _asmDrawStripToScreen:  	CMP	r1,#4			@ If width<4  	BLT	end			@    return -	@ Width &= ~4 ? What''s that about then? Width &= ~3 I could have -	@ understood... -	BIC	r1,r1,#4 -  	SUB	r5,r5,r1		@ vsPitch          -= width  	SUB	r6,r6,r1		@ vmScreenWidth    -= width  	SUB	r7,r7,r1		@ textSurfacePitch -= width diff --git a/engines/scumm/help.h b/engines/scumm/help.h index 5ba6bdc65c..a3948566c4 100644 --- a/engines/scumm/help.h +++ b/engines/scumm/help.h @@ -24,6 +24,7 @@  #define SCUMM_HELP_H  #include "common/str.h" +#include "common/platform.h"  namespace Scumm { diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h index 2f1e536f0a..cacf8c214e 100644 --- a/engines/scumm/scumm.h +++ b/engines/scumm/scumm.h @@ -24,6 +24,7 @@  #define SCUMM_H  #include "engines/engine.h" +  #include "common/endian.h"  #include "common/events.h"  #include "common/file.h" @@ -31,6 +32,7 @@  #include "common/keyboard.h"  #include "common/random.h"  #include "common/rect.h" +#include "common/rendermode.h"  #include "common/str.h"  #include "common/textconsole.h"  #include "graphics/surface.h" diff --git a/engines/sword1/animation.cpp b/engines/sword1/animation.cpp index e274e02cfd..1e2964054a 100644 --- a/engines/sword1/animation.cpp +++ b/engines/sword1/animation.cpp @@ -37,6 +37,11 @@  #include "gui/message.h" +#include "video/psx_decoder.h" +#include "video/smk_decoder.h" + +#include "engines/util.h" +  namespace Sword1 {  static const char *const sequenceList[20] = { @@ -62,6 +67,31 @@ static const char *const sequenceList[20] = {  	"credits",  // 19 CD2   credits, to follow "finale" sequence  }; +// This is the list of the names of the PlayStation videos +// TODO: fight.str, flashy.str,  +static const char *const sequenceListPSX[20] = { +	"e_ferr1", +	"ladder1", +	"steps1", +	"sewer1", +	"e_intro1", +	"river1", +	"truck1", +	"grave1", +	"montfcn1", +	"tapesty1", +	"ireland1", +	"e_fin1", +	"e_hist1", +	"spanish1", +	"well1", +	"candle1", +	"geodrop1", +	"vulture1", +	"", // demo video not present +	""  // credits are not a video +}; +  ///////////////////////////////////////////////////////////////////////////////  // Basic movie player  /////////////////////////////////////////////////////////////////////////////// @@ -150,6 +180,21 @@ bool MoviePlayer::load(uint32 id) {  	case kVideoDecoderSMK:  		filename = Common::String::format("%s.smk", sequenceList[id]);  		break; +	case kVideoDecoderPSX: +		filename = Common::String::format("%s.str", (_vm->_systemVars.isDemo) ? sequenceList[id] : sequenceListPSX[id]); + +		// Need to switch to true color +		initGraphics(g_system->getWidth(), g_system->getHeight(), true, 0); + +		// Need to load here in case it fails in which case we'd need +		// to go back to paletted mode +		if (_decoder->loadFile(filename)) { +			return true; +		} else { +			initGraphics(g_system->getWidth(), g_system->getHeight(), true); +			return false; +		} +		break;  	}  	return _decoder->loadFile(filename.c_str()); @@ -187,6 +232,11 @@ void MoviePlayer::play() {  }  void MoviePlayer::performPostProcessing(byte *screen) { +	// TODO: We don't support the PSX stream videos yet +	// nor using the PSX fonts to display subtitles. +	if (_vm->isPsx()) +		return; +  	if (!_movieTexts.empty()) {  		if (_decoder->getCurFrame() == _movieTexts.front()._startFrame) {  			_textMan->makeTextSprite(2, (const uint8 *)_movieTexts.front()._text.c_str(), 600, LETTER_COL); @@ -215,10 +265,10 @@ void MoviePlayer::performPostProcessing(byte *screen) {  			for (x = 0; x < _textWidth; x++) {  				switch (src[x]) {  				case BORDER_COL: -					dst[x] = findBlackPalIndex(); +					dst[x] = getBlackColor();  					break;  				case LETTER_COL: -					dst[x] = findTextColorPalIndex(); +					dst[x] = findTextColor();  					break;  				}  			} @@ -238,12 +288,12 @@ void MoviePlayer::performPostProcessing(byte *screen) {  		for (y = 0; y < _textHeight; y++) {  			if (_textY + y < frameY || _textY + y >= frameY + frameHeight) { -				memset(dst + _textX, findBlackPalIndex(), _textWidth); +				memset(dst + _textX, getBlackColor(), _textWidth);  			} else {  				if (frameX > _textX) -					memset(dst + _textX, findBlackPalIndex(), frameX - _textX); +					memset(dst + _textX, getBlackColor(), frameX - _textX);  				if (frameX + frameWidth < _textX + _textWidth) -					memset(dst + frameX + frameWidth, findBlackPalIndex(), _textX + _textWidth - (frameX + frameWidth)); +					memset(dst + frameX + frameWidth, getBlackColor(), _textX + _textWidth - (frameX + frameWidth));  			}  			dst += _system->getWidth(); @@ -255,14 +305,19 @@ void MoviePlayer::performPostProcessing(byte *screen) {  }  bool MoviePlayer::playVideo() { +	bool skipped = false;  	uint16 x = (g_system->getWidth() - _decoder->getWidth()) / 2;  	uint16 y = (g_system->getHeight() - _decoder->getHeight()) / 2; -	while (!_vm->shouldQuit() && !_decoder->endOfVideo()) { +	while (!_vm->shouldQuit() && !_decoder->endOfVideo() && !skipped) {  		if (_decoder->needsUpdate()) {  			const Graphics::Surface *frame = _decoder->decodeNextFrame(); -			if (frame) -				_vm->_system->copyRectToScreen((byte *)frame->pixels, frame->pitch, x, y, frame->w, frame->h); +			if (frame) { +				if (_decoderType == kVideoDecoderPSX) +					drawFramePSX(frame); +				else +					_vm->_system->copyRectToScreen((byte *)frame->pixels, frame->pitch, x, y, frame->w, frame->h); +			}  			if (_decoder->hasDirtyPalette()) {  				_decoder->setSystemPalette(); @@ -362,19 +417,40 @@ bool MoviePlayer::playVideo() {  		Common::Event event;  		while (_vm->_system->getEventManager()->pollEvent(event))  			if ((event.type == Common::EVENT_KEYDOWN && event.kbd.keycode == Common::KEYCODE_ESCAPE) || event.type == Common::EVENT_LBUTTONUP) -				return false; +				skipped = true;  		_vm->_system->delayMillis(10);  	} -	return !_vm->shouldQuit(); +	if (_decoderType == kVideoDecoderPSX) { +		// Need to jump back to paletted color +		initGraphics(g_system->getWidth(), g_system->getHeight(), true); +	} + +	return !_vm->shouldQuit() && !skipped;  } -byte MoviePlayer::findBlackPalIndex() { -	return _black; +uint32 MoviePlayer::getBlackColor() { +	return (_decoderType == kVideoDecoderPSX) ? g_system->getScreenFormat().RGBToColor(0x00, 0x00, 0x00) : _black;  } -	 -byte MoviePlayer::findTextColorPalIndex() { + +uint32 MoviePlayer::findTextColor() { +	if (_decoderType == kVideoDecoderPSX) { +		// We're in true color mode, so return the actual colors +		switch (_textColor) { +		case 1: +			return g_system->getScreenFormat().RGBToColor(248, 252, 248); +		case 2: +			return g_system->getScreenFormat().RGBToColor(184, 188, 184); +		case 3: +			return g_system->getScreenFormat().RGBToColor(200, 120, 184); +		case 4: +			return g_system->getScreenFormat().RGBToColor(80, 152, 184); +		} + +		return g_system->getScreenFormat().RGBToColor(0xFF, 0xFF, 0xFF); +	} +  	switch (_textColor) {  	case 1:  		return _c1Color; @@ -413,6 +489,23 @@ void MoviePlayer::convertColor(byte r, byte g, byte b, float &h, float &s, float  	}  } +void MoviePlayer::drawFramePSX(const Graphics::Surface *frame) { +	// The PSX videos have half resolution + +	Graphics::Surface scaledFrame; +	scaledFrame.create(frame->w, frame->h * 2, frame->format); + +	for (int y = 0; y < scaledFrame.h; y++) +		memcpy(scaledFrame.getBasePtr(0, y), frame->getBasePtr(0, y / 2), scaledFrame.w * scaledFrame.format.bytesPerPixel); + +	uint16 x = (g_system->getWidth() - scaledFrame.w) / 2; +	uint16 y = (g_system->getHeight() - scaledFrame.h) / 2; + +	_vm->_system->copyRectToScreen((byte *)scaledFrame.pixels, scaledFrame.pitch, x, y, scaledFrame.w, scaledFrame.h); + +	scaledFrame.free(); +} +  DXADecoderWithSound::DXADecoderWithSound(Audio::Mixer *mixer, Audio::SoundHandle *bgSoundHandle)  	: _mixer(mixer), _bgSoundHandle(bgSoundHandle)  {  } @@ -432,6 +525,24 @@ MoviePlayer *makeMoviePlayer(uint32 id, SwordEngine *vm, Text *textMan, ResMan *  	Common::String filename;  	Audio::SoundHandle *bgSoundHandle = new Audio::SoundHandle; +	// For the PSX version, we'll try the PlayStation stream files +	if (vm->isPsx()) { +		// The demo uses the normal file names +		filename = ((vm->_systemVars.isDemo) ? Common::String(sequenceList[id]) : Common::String(sequenceListPSX[id])) + ".str"; + +		if (Common::File::exists(filename)) { +#ifdef USE_RGB_COLOR +			// All BS1 PSX videos run the videos at 2x speed +			Video::VideoDecoder *psxDecoder = new Video::PSXStreamDecoder(Video::PSXStreamDecoder::kCD2x); +			return new MoviePlayer(vm, textMan, resMan, snd, system, bgSoundHandle, psxDecoder, kVideoDecoderPSX); +#else +			GUI::MessageDialog dialog(Common::String::format(_("PSX stream cutscene '%s' cannot be played in paletted mode"), filename.c_str()), _("OK")); +			dialog.runModal(); +			return 0; +#endif +		} +	} +  	filename = Common::String::format("%s.smk", sequenceList[id]);  	if (Common::File::exists(filename)) { @@ -461,9 +572,11 @@ MoviePlayer *makeMoviePlayer(uint32 id, SwordEngine *vm, Text *textMan, ResMan *  		return NULL;  	} -	Common::String buf = Common::String::format(_("Cutscene '%s' not found"), sequenceList[id]); -	GUI::MessageDialog dialog(buf, _("OK")); -	dialog.runModal(); +	if (!vm->isPsx() || scumm_stricmp(sequenceList[id], "enddemo") != 0) { +		Common::String buf = Common::String::format(_("Cutscene '%s' not found"), sequenceList[id]); +		GUI::MessageDialog dialog(buf, _("OK")); +		dialog.runModal(); +	}  	return NULL;  } diff --git a/engines/sword1/animation.h b/engines/sword1/animation.h index c436607211..f64b03dd1b 100644 --- a/engines/sword1/animation.h +++ b/engines/sword1/animation.h @@ -24,7 +24,6 @@  #define SWORD1_ANIMATION_H  #include "video/dxa_decoder.h" -#include "video/smk_decoder.h"  #include "video/video_decoder.h"  #include "common/list.h" @@ -38,7 +37,8 @@ namespace Sword1 {  enum DecoderType {  	kVideoDecoderDXA = 0, -	kVideoDecoderSMK = 1 +	kVideoDecoderSMK = 1, +	kVideoDecoderPSX = 2  };  class MovieText { @@ -83,8 +83,8 @@ protected:  	Common::List<MovieText> _movieTexts;  	int _textX, _textY, _textWidth, _textHeight;  	int _textColor; -	byte _black; -	byte _c1Color, _c2Color, _c3Color, _c4Color; +	uint32 _black; +	uint32 _c1Color, _c2Color, _c3Color, _c4Color;  	DecoderType _decoderType;  	Video::VideoDecoder *_decoder; @@ -93,9 +93,10 @@ protected:  	bool playVideo();  	void performPostProcessing(byte *screen); +	void drawFramePSX(const Graphics::Surface *frame); -	byte findBlackPalIndex(); -	byte findTextColorPalIndex(); +	uint32 getBlackColor(); +	uint32 findTextColor();  	void convertColor(byte r, byte g, byte b, float &h, float &s, float &v);  }; diff --git a/engines/sword1/detection.cpp b/engines/sword1/detection.cpp index 2214e72067..087dcd09d8 100644 --- a/engines/sword1/detection.cpp +++ b/engines/sword1/detection.cpp @@ -25,6 +25,7 @@  #include "base/plugins.h"  #include "common/fs.h" +#include "common/gui_options.h"  #include "common/savefile.h"  #include "common/system.h"  #include "graphics/thumbnail.h" diff --git a/engines/sword1/sword1.cpp b/engines/sword1/sword1.cpp index 865e025786..75e8f72d9d 100644 --- a/engines/sword1/sword1.cpp +++ b/engines/sword1/sword1.cpp @@ -62,8 +62,9 @@ SwordEngine::SwordEngine(OSystem *syst)  	SearchMan.addSubDirectoryMatching(gameDataDir, "speech");  	SearchMan.addSubDirectoryMatching(gameDataDir, "video");  	SearchMan.addSubDirectoryMatching(gameDataDir, "smackshi"); -	SearchMan.addSubDirectoryMatching(gameDataDir, "english");//PSX Demo -	SearchMan.addSubDirectoryMatching(gameDataDir, "italian");//PSX Demo +	SearchMan.addSubDirectoryMatching(gameDataDir, "streams"); // PSX videos +	SearchMan.addSubDirectoryMatching(gameDataDir, "english"); // PSX Demo +	SearchMan.addSubDirectoryMatching(gameDataDir, "italian"); // PSX Demo  	_console = new SwordConsole(this);  } diff --git a/engines/sword2/animation.cpp b/engines/sword2/animation.cpp index 80b4809722..e77ae98163 100644 --- a/engines/sword2/animation.cpp +++ b/engines/sword2/animation.cpp @@ -40,6 +40,11 @@  #include "gui/message.h" +#include "video/smk_decoder.h" +#include "video/psx_decoder.h" + +#include "engines/util.h" +  namespace Sword2 {  /////////////////////////////////////////////////////////////////////////////// @@ -66,6 +71,10 @@ MoviePlayer::~MoviePlayer() {   * @param id the id of the file   */  bool MoviePlayer::load(const char *name) { +	// This happens when quitting during the "eye" cutscene. +	if (_vm->shouldQuit()) +		return false; +  	if (_decoderType == kVideoDecoderDXA)  		_bgSoundStream = Audio::SeekableAudioStream::openStreamFile(name);  	else @@ -81,16 +90,26 @@ bool MoviePlayer::load(const char *name) {  	case kVideoDecoderSMK:  		filename = Common::String::format("%s.smk", name);  		break; +	case kVideoDecoderPSX: +		filename = Common::String::format("%s.str", name); + +		// Need to switch to true color +		initGraphics(640, 480, true, 0); + +		// Need to load here in case it fails in which case we'd need +		// to go back to paletted mode +		if (_decoder->loadFile(filename)) { +			return true; +		} else { +			initGraphics(640, 480, true); +			return false; +		}  	}  	return _decoder->loadFile(filename.c_str());  }  void MoviePlayer::play(MovieText *movieTexts, uint32 numMovieTexts, uint32 leadIn, uint32 leadOut) { -	// This happens when quitting during the "eye" cutscene. -	if (_vm->shouldQuit()) -		return; -  	_leadOutFrame = _decoder->getFrameCount();  	if (_leadOutFrame > 60)  		_leadOutFrame -= 60; @@ -120,6 +139,11 @@ void MoviePlayer::play(MovieText *movieTexts, uint32 numMovieTexts, uint32 leadI  	while (_snd->isSoundHandleActive(*_bgSoundHandle))  		_system->delayMillis(100); + +	if (_decoderType == kVideoDecoderPSX) { +		// Need to jump back to paletted color +		initGraphics(640, 480, true); +	}  }  void MoviePlayer::openTextObject(uint32 index) { @@ -165,7 +189,7 @@ void MoviePlayer::openTextObject(uint32 index) {  	}  } -void MoviePlayer::closeTextObject(uint32 index, byte *screen, uint16 pitch) { +void MoviePlayer::closeTextObject(uint32 index, Graphics::Surface *screen, uint16 pitch) {  	if (index < _numMovieTexts) {  		MovieText *text = &_movieTexts[index]; @@ -180,23 +204,23 @@ void MoviePlayer::closeTextObject(uint32 index, byte *screen, uint16 pitch) {  				int frameWidth = _decoder->getWidth();  				int frameHeight = _decoder->getHeight(); + +				if (_decoderType == kVideoDecoderPSX) +					frameHeight *= 2; +  				int frameX = (_system->getWidth() - frameWidth) / 2;  				int frameY = (_system->getHeight() - frameHeight) / 2; -				byte black = findBlackPalIndex(); - -				byte *dst = screen + _textY * pitch; +				uint32 black = getBlackColor();  				for (int y = 0; y < text->_textSprite.h; y++) {  					if (_textY + y < frameY || _textY + y >= frameY + frameHeight) { -						memset(dst + _textX, black, text->_textSprite.w); +						screen->hLine(_textX, _textY + y, _textX + text->_textSprite.w, black);  					} else {  						if (frameX > _textX) -							memset(dst + _textX, black, frameX - _textX); +							screen->hLine(_textX, _textY + y, frameX, black);  						if (frameX + frameWidth < _textX + text->_textSprite.w) -							memset(dst + frameX + frameWidth, black, _textX + text->_textSprite.w - (frameX + frameWidth)); +							screen->hLine(frameX + frameWidth, _textY + y, text->_textSprite.w, black);  					} - -					dst += pitch;  				}  			} @@ -206,11 +230,24 @@ void MoviePlayer::closeTextObject(uint32 index, byte *screen, uint16 pitch) {  	}  } -void MoviePlayer::drawTextObject(uint32 index, byte *screen, uint16 pitch) { +#define PUT_PIXEL(c) \ +	switch (screen->format.bytesPerPixel) { \ +	case 1: \ +		*dst = (c); \ +		break; \ +	case 2: \ +		WRITE_UINT16(dst, (c)); \ +		break; \ +	case 4: \ +		WRITE_UINT32(dst, (c)); \ +		break; \ +	} + +void MoviePlayer::drawTextObject(uint32 index, Graphics::Surface *screen, uint16 pitch) {  	MovieText *text = &_movieTexts[index]; -	byte white = findWhitePalIndex(); -	byte black = findBlackPalIndex(); +	uint32 white = getWhiteColor(); +	uint32 black = getBlackColor();  	if (text->_textMem && _textSurface) {  		byte *src = text->_textSprite.data; @@ -226,17 +263,20 @@ void MoviePlayer::drawTextObject(uint32 index, byte *screen, uint16 pitch) {  			src = psxSpriteBuffer;  		} -		byte *dst = screen + _textY * pitch + _textX; -  		for (int y = 0; y < height; y++) { +			byte *dst = (byte *)screen->getBasePtr(_textX, _textY + y); +  			for (int x = 0; x < width; x++) { -				if (src[x] == 1) -					dst[x] = black; -				else if (src[x] == 255) -					dst[x] = white; +				if (src[x] == 1) { +					PUT_PIXEL(black); +				} else if (src[x] == 255) { +					PUT_PIXEL(white); +				} + +				dst += screen->format.bytesPerPixel;  			} +  			src += width; -			dst += pitch;  		}  		// Free buffer used to resize psx sprite @@ -245,7 +285,9 @@ void MoviePlayer::drawTextObject(uint32 index, byte *screen, uint16 pitch) {  	}  } -void MoviePlayer::performPostProcessing(byte *screen, uint16 pitch) { +#undef PUT_PIXEL + +void MoviePlayer::performPostProcessing(Graphics::Surface *screen, uint16 pitch) {  	MovieText *text;  	int frame = _decoder->getCurFrame(); @@ -286,8 +328,12 @@ bool MoviePlayer::playVideo() {  	while (!_vm->shouldQuit() && !_decoder->endOfVideo()) {  		if (_decoder->needsUpdate()) {  			const Graphics::Surface *frame = _decoder->decodeNextFrame(); -			if (frame) -				_vm->_system->copyRectToScreen((byte *)frame->pixels, frame->pitch, x, y, frame->w, frame->h); +			if (frame) { +				if (_decoderType == kVideoDecoderPSX) +					drawFramePSX(frame); +				else +					_vm->_system->copyRectToScreen((byte *)frame->pixels, frame->pitch, x, y, frame->w, frame->h); +			}  			if (_decoder->hasDirtyPalette()) {  				_decoder->setSystemPalette(); @@ -319,7 +365,7 @@ bool MoviePlayer::playVideo() {  			}  			Graphics::Surface *screen = _vm->_system->lockScreen(); -			performPostProcessing((byte *)screen->pixels, screen->pitch); +			performPostProcessing(screen, screen->pitch);  			_vm->_system->unlockScreen();  			_vm->_system->updateScreen();  		} @@ -335,12 +381,29 @@ bool MoviePlayer::playVideo() {  	return !_vm->shouldQuit();  } -byte MoviePlayer::findBlackPalIndex() { -	return _black; +uint32 MoviePlayer::getBlackColor() { +	return (_decoderType == kVideoDecoderPSX) ? g_system->getScreenFormat().RGBToColor(0x00, 0x00, 0x00) : _black;  } -byte MoviePlayer::findWhitePalIndex() { -	return _white; +uint32 MoviePlayer::getWhiteColor() { +	return (_decoderType == kVideoDecoderPSX) ? g_system->getScreenFormat().RGBToColor(0xFF, 0xFF, 0xFF) : _white; +} + +void MoviePlayer::drawFramePSX(const Graphics::Surface *frame) { +	// The PSX videos have half resolution + +	Graphics::Surface scaledFrame; +	scaledFrame.create(frame->w, frame->h * 2, frame->format); + +	for (int y = 0; y < scaledFrame.h; y++) +		memcpy(scaledFrame.getBasePtr(0, y), frame->getBasePtr(0, y / 2), scaledFrame.w * scaledFrame.format.bytesPerPixel); + +	uint16 x = (g_system->getWidth() - scaledFrame.w) / 2; +	uint16 y = (g_system->getHeight() - scaledFrame.h) / 2; + +	_vm->_system->copyRectToScreen((byte *)scaledFrame.pixels, scaledFrame.pitch, x, y, scaledFrame.w, scaledFrame.h); + +	scaledFrame.free();  }  DXADecoderWithSound::DXADecoderWithSound(Audio::Mixer *mixer, Audio::SoundHandle *bgSoundHandle) @@ -358,10 +421,23 @@ uint32 DXADecoderWithSound::getElapsedTime() const {  // Factory function for creating the appropriate cutscene player  /////////////////////////////////////////////////////////////////////////////// -MoviePlayer *makeMoviePlayer(const char *name, Sword2Engine *vm, Audio::Mixer *snd, OSystem *system) { +MoviePlayer *makeMoviePlayer(const char *name, Sword2Engine *vm, Audio::Mixer *snd, OSystem *system, uint32 frameCount) {  	Common::String filename;  	Audio::SoundHandle *bgSoundHandle = new Audio::SoundHandle; +	filename = Common::String::format("%s.str", name); + +	if (Common::File::exists(filename)) { +#ifdef USE_RGB_COLOR +		Video::VideoDecoder *psxDecoder = new Video::PSXStreamDecoder(Video::PSXStreamDecoder::kCD2x, frameCount); +		return new MoviePlayer(vm, snd, system, bgSoundHandle, psxDecoder, kVideoDecoderPSX); +#else +		GUI::MessageDialog dialog(_("PSX cutscenes found but ScummVM has been built without RGB color support"), _("OK")); +		dialog.runModal(); +		return NULL; +#endif +	} +  	filename = Common::String::format("%s.smk", name);  	if (Common::File::exists(filename)) { diff --git a/engines/sword2/animation.h b/engines/sword2/animation.h index 1f5fced03b..3ef8dac754 100644 --- a/engines/sword2/animation.h +++ b/engines/sword2/animation.h @@ -26,7 +26,6 @@  #define SWORD2_ANIMATION_H  #include "video/dxa_decoder.h" -#include "video/smk_decoder.h"  #include "video/video_decoder.h"  #include "audio/mixer.h" @@ -36,7 +35,8 @@ namespace Sword2 {  enum DecoderType {  	kVideoDecoderDXA = 0, -	kVideoDecoderSMK = 1 +	kVideoDecoderSMK = 1, +	kVideoDecoderPSX = 2  };  struct MovieText { @@ -93,18 +93,19 @@ protected:  	uint32 _leadOut;  	int _leadOutFrame; -	void performPostProcessing(byte *screen, uint16 pitch); +	void performPostProcessing(Graphics::Surface *screen, uint16 pitch);  	bool playVideo(); +	void drawFramePSX(const Graphics::Surface *frame);  	void openTextObject(uint32 index); -	void closeTextObject(uint32 index, byte *screen, uint16 pitch); -	void drawTextObject(uint32 index, byte *screen, uint16 pitch); +	void closeTextObject(uint32 index, Graphics::Surface *screen, uint16 pitch); +	void drawTextObject(uint32 index, Graphics::Surface *screen, uint16 pitch); -	byte findBlackPalIndex(); -	byte findWhitePalIndex(); +	uint32 getBlackColor(); +	uint32 getWhiteColor();  }; -MoviePlayer *makeMoviePlayer(const char *name, Sword2Engine *vm, Audio::Mixer *snd, OSystem *system); +MoviePlayer *makeMoviePlayer(const char *name, Sword2Engine *vm, Audio::Mixer *snd, OSystem *system, uint32 frameCount);  } // End of namespace Sword2 diff --git a/engines/sword2/function.cpp b/engines/sword2/function.cpp index 60ee6176a4..836b252d6c 100644 --- a/engines/sword2/function.cpp +++ b/engines/sword2/function.cpp @@ -2137,7 +2137,9 @@ int32 Logic::fnPlaySequence(int32 *params) {  	// pause sfx during sequence  	_vm->_sound->pauseFx(); -	_moviePlayer = makeMoviePlayer(filename, _vm, _vm->_mixer, _vm->_system); +	uint32 frameCount = Sword2Engine::isPsx() ? params[1] : 0; + +	_moviePlayer = makeMoviePlayer(filename, _vm, _vm->_mixer, _vm->_system, frameCount);  	if (_moviePlayer && _moviePlayer->load(filename)) {  		_moviePlayer->play(_sequenceTextList, _sequenceTextLines, _smackerLeadIn, _smackerLeadOut); diff --git a/engines/sword2/sword2.cpp b/engines/sword2/sword2.cpp index 3b7965259c..c395186570 100644 --- a/engines/sword2/sword2.cpp +++ b/engines/sword2/sword2.cpp @@ -25,9 +25,10 @@  #include "base/plugins.h"  #include "common/config-manager.h" +#include "common/events.h"  #include "common/file.h"  #include "common/fs.h" -#include "common/events.h" +#include "common/gui_options.h"  #include "common/savefile.h"  #include "common/system.h"  #include "common/textconsole.h" @@ -255,6 +256,7 @@ Sword2Engine::Sword2Engine(OSystem *syst) : Engine(syst), _rnd("sword2") {  	SearchMan.addSubDirectoryMatching(gameDataDir, "sword2");  	SearchMan.addSubDirectoryMatching(gameDataDir, "video");  	SearchMan.addSubDirectoryMatching(gameDataDir, "smacks"); +	SearchMan.addSubDirectoryMatching(gameDataDir, "streams"); // PSX video  	if (!scumm_stricmp(ConfMan.get("gameid").c_str(), "sword2demo") || !scumm_stricmp(ConfMan.get("gameid").c_str(), "sword2psxdemo"))  		_features = GF_DEMO; diff --git a/engines/sword25/util/lua/scummvm_file.cpp b/engines/sword25/util/lua/scummvm_file.cpp index 33053a71cb..b5f1388129 100644 --- a/engines/sword25/util/lua/scummvm_file.cpp +++ b/engines/sword25/util/lua/scummvm_file.cpp @@ -22,7 +22,7 @@  #include "sword25/util/lua/scummvm_file.h"  #include "common/config-manager.h" -#include "common/util.h" +#include "common/language.h"  namespace Sword25 { diff --git a/engines/tinsel/background.cpp b/engines/tinsel/background.cpp index 72397db97f..8e3fc50f12 100644 --- a/engines/tinsel/background.cpp +++ b/engines/tinsel/background.cpp @@ -34,7 +34,7 @@ namespace Tinsel {  // FIXME: Avoid non-const global vars  // current background -const BACKGND *pCurBgnd = NULL; +const BACKGND *g_pCurBgnd = NULL;  /**   * Called to initialize a background. @@ -46,7 +46,7 @@ void InitBackground(const BACKGND *pBgnd) {  	PLAYFIELD *pPlayfield;	// pointer to current playfield  	// set current background -	pCurBgnd = pBgnd; +	g_pCurBgnd = pBgnd;  	// init background sky color  	SetBgndColor(pBgnd->rgbSkyColor); @@ -83,13 +83,13 @@ void PlayfieldSetPos(int which, int newXpos, int newYpos) {  	PLAYFIELD *pPlayfield;	// pointer to relavent playfield  	// make sure there is a background -	assert(pCurBgnd != NULL); +	assert(g_pCurBgnd != NULL);  	// make sure the playfield number is in range -	assert(which >= 0 && which < pCurBgnd->numPlayfields); +	assert(which >= 0 && which < g_pCurBgnd->numPlayfields);  	// get playfield pointer -	pPlayfield = pCurBgnd->fieldArray + which; +	pPlayfield = g_pCurBgnd->fieldArray + which;  	// set new integer position  	pPlayfield->fieldX = intToFrac(newXpos); @@ -110,13 +110,13 @@ void PlayfieldGetPos(int which, int *pXpos, int *pYpos) {  	PLAYFIELD *pPlayfield;	// pointer to relavent playfield  	// make sure there is a background -	assert(pCurBgnd != NULL); +	assert(g_pCurBgnd != NULL);  	// make sure the playfield number is in range -	assert(which >= 0 && which < pCurBgnd->numPlayfields); +	assert(which >= 0 && which < g_pCurBgnd->numPlayfields);  	// get playfield pointer -	pPlayfield = pCurBgnd->fieldArray + which; +	pPlayfield = g_pCurBgnd->fieldArray + which;  	// get current integer position  	*pXpos = fracToInt(pPlayfield->fieldX); @@ -132,13 +132,13 @@ int PlayfieldGetCenterX(int which) {  	PLAYFIELD *pPlayfield; // pointer to relavent playfield  	// make sure there is a background -	assert(pCurBgnd != NULL); +	assert(g_pCurBgnd != NULL);  	// make sure the playfield number is in range -	assert(which >= 0 && which < pCurBgnd->numPlayfields); +	assert(which >= 0 && which < g_pCurBgnd->numPlayfields);  	// get playfield pointer -	pPlayfield = pCurBgnd->fieldArray + which; +	pPlayfield = g_pCurBgnd->fieldArray + which;  	// get current integer position  	return fracToInt(pPlayfield->fieldX) + SCREEN_WIDTH/2; @@ -153,13 +153,13 @@ OBJECT **GetPlayfieldList(int which) {  	PLAYFIELD *pPlayfield;	// pointer to relavent playfield  	// make sure there is a background -	assert(pCurBgnd != NULL); +	assert(g_pCurBgnd != NULL);  	// make sure the playfield number is in range -	assert(which >= 0 && which < pCurBgnd->numPlayfields); +	assert(which >= 0 && which < g_pCurBgnd->numPlayfields);  	// get playfield pointer -	pPlayfield = pCurBgnd->fieldArray + which; +	pPlayfield = g_pCurBgnd->fieldArray + which;  	// return the display list pointer for this playfield  	return &pPlayfield->pDispList; @@ -177,13 +177,13 @@ void DrawBackgnd() {  	int prevX, prevY;	// save interger part of position  	Common::Point ptWin;	// window top left -	if (pCurBgnd == NULL) +	if (g_pCurBgnd == NULL)  		return;		// no current background  	// scroll each background playfield -	for (i = 0; i < pCurBgnd->numPlayfields; i++) { +	for (i = 0; i < g_pCurBgnd->numPlayfields; i++) {  		// get pointer to correct playfield -		pPlay = pCurBgnd->fieldArray + i; +		pPlay = g_pCurBgnd->fieldArray + i;  		// save integer part of position  		prevX = fracToInt(pPlay->fieldX); @@ -220,11 +220,11 @@ void DrawBackgnd() {  	for (RectList::const_iterator r = clipRects.begin(); r != clipRects.end(); ++r) {  		// clear the clip rectangle on the virtual screen  		// for each background playfield -		for (i = 0; i < pCurBgnd->numPlayfields; i++) { +		for (i = 0; i < g_pCurBgnd->numPlayfields; i++) {  			Common::Rect rcPlayClip;	// clip rect for this playfield  			// get pointer to correct playfield -			pPlay = pCurBgnd->fieldArray + i; +			pPlay = g_pCurBgnd->fieldArray + i;  			// convert fixed point window pos to a int  			ptWin.x = fracToInt(pPlay->fieldX); diff --git a/engines/tinsel/bg.cpp b/engines/tinsel/bg.cpp index cf692e16ea..72ba05f0b9 100644 --- a/engines/tinsel/bg.cpp +++ b/engines/tinsel/bg.cpp @@ -47,59 +47,59 @@ namespace Tinsel {  #define MAX_BG	10  // FIXME: Avoid non-const global vars -static SCNHANDLE hBgPal = 0;	// Background's palette -static POBJECT pBG[MAX_BG]; -static ANIM	thisAnim[MAX_BG];	// used by BGmainProcess() -static int BGspeed = 0; -static SCNHANDLE hBackground = 0;	// Current scene handle - stored in case of Save_Scene() -static bool bDoFadeIn = false; -static int bgReels; +static SCNHANDLE g_hBgPal = 0;	// Background's palette +static POBJECT g_pBG[MAX_BG]; +static ANIM	g_thisAnim[MAX_BG];	// used by BGmainProcess() +static int g_BGspeed = 0; +static SCNHANDLE g_hBackground = 0;	// Current scene handle - stored in case of Save_Scene() +static bool g_bDoFadeIn = false; +static int g_bgReels;  /**   * GetBgObject   */  OBJECT *GetBgObject() { -	return pBG[0]; +	return g_pBG[0];  }  /**   * BackPal   */  SCNHANDLE BgPal() { -	return hBgPal; +	return g_hBgPal;  }  /**   * SetDoFadeIn  */  void SetDoFadeIn(bool tf) { -	bDoFadeIn = tf; +	g_bDoFadeIn = tf;  }  /**   * Called before scene change.   */  void DropBackground() { -	pBG[0] = NULL;	// No background +	g_pBG[0] = NULL;	// No background  	if (!TinselV2) -		hBgPal = 0;	// No background palette +		g_hBgPal = 0;	// No background palette  }  /**   * Return the width of the current background.   */  int BgWidth() { -	assert(pBG[0]); -	return MultiRightmost(pBG[0]) + 1; +	assert(g_pBG[0]); +	return MultiRightmost(g_pBG[0]) + 1;  }  /**   * Return the height of the current background.   */  int BgHeight() { -	assert(pBG[0]); -	return MultiLowest(pBG[0]) + 1; +	assert(g_pBG[0]); +	return MultiLowest(g_pBG[0]) + 1;  }  /** @@ -117,7 +117,7 @@ static void BGmainProcess(CORO_PARAM, const void *param) {  	const MULTI_INIT *pmi;  	// get the stuff copied to process when it was created -	if (pBG[0] == NULL) { +	if (g_pBG[0] == NULL) {  		/*** At start of scene ***/  		if (!TinselV2) { @@ -127,40 +127,40 @@ static void BGmainProcess(CORO_PARAM, const void *param) {  			pmi = (const MULTI_INIT *)LockMem(FROM_LE_32(pReel->mobj));  			// Initialize and insert the object, and initialize its script. -			pBG[0] = MultiInitObject(pmi); -			MultiInsertObject(GetPlayfieldList(FIELD_WORLD), pBG[0]); -			InitStepAnimScript(&thisAnim[0], pBG[0], FROM_LE_32(pReel->script), BGspeed); -			bgReels = 1; +			g_pBG[0] = MultiInitObject(pmi); +			MultiInsertObject(GetPlayfieldList(FIELD_WORLD), g_pBG[0]); +			InitStepAnimScript(&g_thisAnim[0], g_pBG[0], FROM_LE_32(pReel->script), g_BGspeed); +			g_bgReels = 1;  		} else {  			/*** At start of scene ***/ -			pFilm = (const FILM *)LockMem(hBackground); -			bgReels = FROM_LE_32(pFilm->numreels); +			pFilm = (const FILM *)LockMem(g_hBackground); +			g_bgReels = FROM_LE_32(pFilm->numreels);  			int i; -			for (i = 0; i < bgReels; i++) { +			for (i = 0; i < g_bgReels; i++) {  				// Get the MULTI_INIT structure  				pmi = (PMULTI_INIT) LockMem(FROM_LE_32(pFilm->reels[i].mobj));  				// Initialize and insert the object, and initialize its script. -				pBG[i] = MultiInitObject(pmi); -				MultiInsertObject(GetPlayfieldList(FIELD_WORLD), pBG[i]); -				MultiSetZPosition(pBG[i], 0); -				InitStepAnimScript(&thisAnim[i], pBG[i], FROM_LE_32(pFilm->reels[i].script), BGspeed); +				g_pBG[i] = MultiInitObject(pmi); +				MultiInsertObject(GetPlayfieldList(FIELD_WORLD), g_pBG[i]); +				MultiSetZPosition(g_pBG[i], 0); +				InitStepAnimScript(&g_thisAnim[i], g_pBG[i], FROM_LE_32(pFilm->reels[i].script), g_BGspeed);  				if (i > 0) -					pBG[i-1]->pSlave = pBG[i]; +					g_pBG[i-1]->pSlave = g_pBG[i];  			}  		} -		if (bDoFadeIn) { +		if (g_bDoFadeIn) {  			FadeInFast(NULL); -			bDoFadeIn = false; +			g_bDoFadeIn = false;  		} else if (TinselV2)  			PokeInTagColor();  		for (;;) { -			for (int i = 0; i < bgReels; i++) { -				if (StepAnimScript(&thisAnim[i]) == ScriptFinished) +			for (int i = 0; i < g_bgReels; i++) { +				if (StepAnimScript(&g_thisAnim[i]) == ScriptFinished)  					error("Background animation has finished");  			} @@ -170,16 +170,16 @@ static void BGmainProcess(CORO_PARAM, const void *param) {  		// New background during scene  		if (!TinselV2) {  			pReel = (const FREEL *)param; -			InitStepAnimScript(&thisAnim[0], pBG[0], FROM_LE_32(pReel->script), BGspeed); -			StepAnimScript(&thisAnim[0]); +			InitStepAnimScript(&g_thisAnim[0], g_pBG[0], FROM_LE_32(pReel->script), g_BGspeed); +			StepAnimScript(&g_thisAnim[0]);  		} else { -			pFilm = (const FILM *)LockMem(hBackground); -			assert(bgReels == (int32)FROM_LE_32(pFilm->numreels)); +			pFilm = (const FILM *)LockMem(g_hBackground); +			assert(g_bgReels == (int32)FROM_LE_32(pFilm->numreels));  			// Just re-initialize the scripts. -			for (int i = 0; i < bgReels; i++) { -				InitStepAnimScript(&thisAnim[i], pBG[i], pFilm->reels[i].script, BGspeed); -				StepAnimScript(&thisAnim[i]); +			for (int i = 0; i < g_bgReels; i++) { +				InitStepAnimScript(&g_thisAnim[i], g_pBG[i], pFilm->reels[i].script, g_BGspeed); +				StepAnimScript(&g_thisAnim[i]);  			}  		}  	} @@ -206,7 +206,7 @@ static void BGotherProcess(CORO_PARAM, const void *param) {  	_ctx->pObj = MultiInitObject(pmi);  	MultiInsertObject(GetPlayfieldList(FIELD_WORLD), _ctx->pObj); -	InitStepAnimScript(&_ctx->anim, pBG[0], FROM_LE_32(pReel->script), BGspeed); +	InitStepAnimScript(&_ctx->anim, g_pBG[0], FROM_LE_32(pReel->script), g_BGspeed);  	while (StepAnimScript(&_ctx->anim) != ScriptFinished)  		CORO_SLEEP(1); @@ -218,14 +218,14 @@ static void BGotherProcess(CORO_PARAM, const void *param) {   * AetBgPal()   */  void SetBackPal(SCNHANDLE hPal) { -	hBgPal = hPal; +	g_hBgPal = hPal; -	FettleFontPal(hBgPal); -	CreateTranslucentPalette(hBgPal); +	FettleFontPal(g_hBgPal); +	CreateTranslucentPalette(g_hBgPal);  }  void ChangePalette(SCNHANDLE hPal) { -	SwapPalette(FindPalette(hBgPal), hPal); +	SwapPalette(FindPalette(g_hBgPal), hPal);  	SetBackPal(hPal);  } @@ -245,14 +245,14 @@ void StartupBackground(CORO_PARAM, SCNHANDLE hFilm) {  	const FILM *pfilm;  	IMAGE *pim; -	hBackground = hFilm;		// Save handle in case of Save_Scene() +	g_hBackground = hFilm;		// Save handle in case of Save_Scene()  	pim = GetImageFromFilm(hFilm, 0, NULL, NULL, &pfilm);  	SetBackPal(FROM_LE_32(pim->hImgPal));  	// Extract the film speed -	BGspeed = ONE_SECOND / FROM_LE_32(pfilm->frate); +	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)); @@ -262,7 +262,7 @@ void StartupBackground(CORO_PARAM, SCNHANDLE hFilm) {  			g_scheduler->createProcess(PID_REEL, BGotherProcess, &pfilm->reels[i], sizeof(FREEL));  	} -	if (pBG[0] == NULL) +	if (g_pBG[0] == NULL)  		ControlStartOff();  	if (TinselV2 && (coroParam != nullContext)) @@ -275,7 +275,7 @@ void StartupBackground(CORO_PARAM, SCNHANDLE hFilm) {   * Return the current scene handle.   */  SCNHANDLE GetBgroundHandle() { -	return hBackground; +	return g_hBackground;  }  } // End of namespace Tinsel diff --git a/engines/tinsel/cursor.cpp b/engines/tinsel/cursor.cpp index 8248609a81..bf901c03b6 100644 --- a/engines/tinsel/cursor.cpp +++ b/engines/tinsel/cursor.cpp @@ -56,36 +56,36 @@ namespace Tinsel {  // FIXME: Avoid non-const global vars -static OBJECT *McurObj = NULL;		// Main cursor object -static OBJECT *AcurObj = NULL;		// Auxiliary cursor object +static OBJECT *g_McurObj = NULL;		// Main cursor object +static OBJECT *g_AcurObj = NULL;		// Auxiliary cursor object -static ANIM McurAnim = {0,0,0,0,0};		// Main cursor animation structure -static ANIM AcurAnim = {0,0,0,0,0};		// Auxiliary cursor animation structure +static ANIM g_McurAnim = {0,0,0,0,0};		// Main cursor animation structure +static ANIM g_AcurAnim = {0,0,0,0,0};		// Auxiliary cursor animation structure -static bool bHiddenCursor = false;		// Set when cursor is hidden -static bool bTempNoTrailers = false;	// Set when cursor trails are hidden -static bool bTempHide = false;			// Set when cursor is hidden +static bool g_bHiddenCursor = false;		// Set when cursor is hidden +static bool g_bTempNoTrailers = false;	// Set when cursor trails are hidden +static bool g_bTempHide = false;			// Set when cursor is hidden -static bool bFrozenCursor = false;	// Set when cursor position is frozen +static bool g_bFrozenCursor = false;	// Set when cursor position is frozen -static frac_t IterationSize = 0; +static frac_t g_IterationSize = 0; -static SCNHANDLE hCursorFilm = 0;	// Handle to cursor reel data +static SCNHANDLE g_hCursorFilm = 0;	// Handle to cursor reel data -static int numTrails = 0; -static int nextTrail = 0; +static int g_numTrails = 0; +static int g_nextTrail = 0; -static bool bWhoa = false;		// Set by DropCursor() at the end of a scene +static bool g_bWhoa = false;		// Set by DropCursor() at the end of a scene  				// - causes cursor processes to do nothing  				// Reset when main cursor has re-initialized -static uint16 restart = 0;	// When main cursor has been bWhoa-ed, it waits +static uint16 g_restart = 0;	// When main cursor has been bWhoa-ed, it waits  							// for this to be set to 0x8000.  							// Main cursor sets all the bits after a re-start  							// - each cursor trail examines it's own bit  							// to trigger a trail restart. -static short ACoX = 0, ACoY = 0;	// Auxillary cursor image's animation offsets +static short g_ACoX = 0, g_ACoY = 0;	// Auxillary cursor image's animation offsets @@ -96,9 +96,9 @@ static struct {  	ANIM	trailAnim;	// Animation structure  	OBJECT *trailObj;	// This trailer's object -} ntrailData [MAX_TRAILERS]; +} g_ntrailData [MAX_TRAILERS]; -static int lastCursorX = 0, lastCursorY = 0; +static int g_lastCursorX = 0, g_lastCursorY = 0;  //----------------- FORWARD REFERENCES -------------------- @@ -116,26 +116,26 @@ static void InitCurTrailObj(int i, int x, int y) {  	const FILM *pfilm; -	if (!numTrails) +	if (!g_numTrails)  		return;  	// Get rid of old object -	if (ntrailData[i].trailObj != NULL) -		MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), ntrailData[i].trailObj); +	if (g_ntrailData[i].trailObj != NULL) +		MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_ntrailData[i].trailObj); -	pim = GetImageFromFilm(hCursorFilm, i+1, &pfr, &pmi, &pfilm);// Get pointer to image +	pim = GetImageFromFilm(g_hCursorFilm, i+1, &pfr, &pmi, &pfilm);// Get pointer to image  	assert(BgPal()); // No background palette  	pim->hImgPal = TO_LE_32(BgPal());  	// Initialize and insert the object, set its Z-pos, and hide it -	ntrailData[i].trailObj = MultiInitObject(pmi); -	MultiInsertObject(GetPlayfieldList(FIELD_STATUS), ntrailData[i].trailObj); -	MultiSetZPosition(ntrailData[i].trailObj, Z_CURSORTRAIL); -	MultiSetAniXY(ntrailData[i].trailObj, x, y); +	g_ntrailData[i].trailObj = MultiInitObject(pmi); +	MultiInsertObject(GetPlayfieldList(FIELD_STATUS), g_ntrailData[i].trailObj); +	MultiSetZPosition(g_ntrailData[i].trailObj, Z_CURSORTRAIL); +	MultiSetAniXY(g_ntrailData[i].trailObj, x, y);  	// Initialize the animation script -	InitStepAnimScript(&ntrailData[i].trailAnim, ntrailData[i].trailObj, FROM_LE_32(pfr->script), ONE_SECOND / FROM_LE_32(pfilm->frate)); -	StepAnimScript(&ntrailData[i].trailAnim); +	InitStepAnimScript(&g_ntrailData[i].trailAnim, g_ntrailData[i].trailObj, FROM_LE_32(pfr->script), ONE_SECOND / FROM_LE_32(pfilm->frate)); +	StepAnimScript(&g_ntrailData[i].trailAnim);  }  /** @@ -196,12 +196,12 @@ void SetCursorScreenXY(int newx, int newy) {   * Returns false if there is no cursor object.   */  bool GetCursorXYNoWait(int *x, int *y, bool absolute) { -	if (McurObj == NULL) { +	if (g_McurObj == NULL) {  		*x = *y = 0;  		return false;  	} -	GetAniPosition(McurObj, x, y); +	GetAniPosition(g_McurObj, x, y);  	if (absolute) {  		int	Loffset, Toffset;	// Screen offset @@ -222,7 +222,7 @@ bool GetCursorXYNoWait(int *x, int *y, bool absolute) {  void GetCursorXY(int *x, int *y, bool absolute) {  	//while (McurObj == NULL)  	//	ProcessSleepSelf(); -	assert(McurObj); +	assert(g_McurObj);  	GetCursorXYNoWait(x, y, absolute);  } @@ -234,22 +234,22 @@ void GetCursorXY(int *x, int *y, bool absolute) {  void RestoreMainCursor() {  	const FILM *pfilm; -	if (McurObj != NULL) { -		pfilm = (const FILM *)LockMem(hCursorFilm); +	if (g_McurObj != NULL) { +		pfilm = (const FILM *)LockMem(g_hCursorFilm); -		InitStepAnimScript(&McurAnim, McurObj, FROM_LE_32(pfilm->reels->script), ONE_SECOND / FROM_LE_32(pfilm->frate)); -		StepAnimScript(&McurAnim); +		InitStepAnimScript(&g_McurAnim, g_McurObj, FROM_LE_32(pfilm->reels->script), ONE_SECOND / FROM_LE_32(pfilm->frate)); +		StepAnimScript(&g_McurAnim);  	} -	bHiddenCursor = false; -	bFrozenCursor = false; +	g_bHiddenCursor = false; +	g_bFrozenCursor = false;  }  /**   * Called from INVENTRY.C to customise the main cursor.   */  void SetTempCursor(SCNHANDLE pScript) { -	if (McurObj != NULL) -		InitStepAnimScript(&McurAnim, McurObj, pScript, 2); +	if (g_McurObj != NULL) +		InitStepAnimScript(&g_McurAnim, g_McurObj, pScript, 2);  }  /** @@ -258,17 +258,17 @@ void SetTempCursor(SCNHANDLE pScript) {  void DwHideCursor() {  	int i; -	bHiddenCursor = true; +	g_bHiddenCursor = true; -	if (McurObj) -		MultiHideObject(McurObj); -	if (AcurObj) -		MultiHideObject(AcurObj); +	if (g_McurObj) +		MultiHideObject(g_McurObj); +	if (g_AcurObj) +		MultiHideObject(g_AcurObj); -	for (i = 0; i < numTrails; i++) { -		if (ntrailData[i].trailObj != NULL) { -			MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), ntrailData[i].trailObj); -			ntrailData[i].trailObj = NULL; +	for (i = 0; i < g_numTrails; i++) { +		if (g_ntrailData[i].trailObj != NULL) { +			MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_ntrailData[i].trailObj); +			g_ntrailData[i].trailObj = NULL;  		}  	}  } @@ -277,21 +277,21 @@ void DwHideCursor() {   * Unhide the cursor.   */  void UnHideCursor() { -	bHiddenCursor = false; +	g_bHiddenCursor = false;  }  /**   * Freeze the cursor.   */  void FreezeCursor() { -	bFrozenCursor = true; +	g_bFrozenCursor = true;  }  /**   * Freeze the cursor, or not.   */  void DoFreezeCursor(bool bFreeze) { -	bFrozenCursor = bFreeze; +	g_bFrozenCursor = bFreeze;  }  /** @@ -300,12 +300,12 @@ void DoFreezeCursor(bool bFreeze) {  void HideCursorTrails() {  	int i; -	bTempNoTrailers = true; +	g_bTempNoTrailers = true; -	for (i = 0; i < numTrails; i++)	{ -		if (ntrailData[i].trailObj != NULL) { -			MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), ntrailData[i].trailObj); -			ntrailData[i].trailObj = NULL; +	for (i = 0; i < g_numTrails; i++)	{ +		if (g_ntrailData[i].trailObj != NULL) { +			MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_ntrailData[i].trailObj); +			g_ntrailData[i].trailObj = NULL;  		}  	}  } @@ -314,7 +314,7 @@ void HideCursorTrails() {   * UnHideCursorTrails   */  void UnHideCursorTrails() { -	bTempNoTrailers = false; +	g_bTempNoTrailers = false;  }  /** @@ -356,9 +356,9 @@ IMAGE *GetImageFromFilm(SCNHANDLE hFilm, int reel, const FREEL **ppfr, const MUL   * Delete auxillary cursor. Restore animation offsets in the image.   */  void DelAuxCursor() { -	if (AcurObj != NULL) { -		MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), AcurObj); -		AcurObj = NULL; +	if (g_AcurObj != NULL) { +		MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_AcurObj); +		g_AcurObj = NULL;  	}  } @@ -381,21 +381,21 @@ void SetAuxCursor(SCNHANDLE hFilm) {  	assert(BgPal()); // no background palette  	pim->hImgPal = TO_LE_32(BgPal());			// Poke in the background palette -	ACoX = (short)(FROM_LE_16(pim->imgWidth)/2 - ((int16) FROM_LE_16(pim->anioffX))); -	ACoY = (short)((FROM_LE_16(pim->imgHeight) & ~C16_FLAG_MASK)/2 - +	g_ACoX = (short)(FROM_LE_16(pim->imgWidth)/2 - ((int16) FROM_LE_16(pim->anioffX))); +	g_ACoY = (short)((FROM_LE_16(pim->imgHeight) & ~C16_FLAG_MASK)/2 -  		((int16) FROM_LE_16(pim->anioffY)));  	// Initialize and insert the auxillary cursor object -	AcurObj = MultiInitObject(pmi); -	MultiInsertObject(GetPlayfieldList(FIELD_STATUS), AcurObj); +	g_AcurObj = MultiInitObject(pmi); +	MultiInsertObject(GetPlayfieldList(FIELD_STATUS), g_AcurObj);  	// Initialize the animation and set its position -	InitStepAnimScript(&AcurAnim, AcurObj, FROM_LE_32(pfr->script), ONE_SECOND / FROM_LE_32(pfilm->frate)); -	MultiSetAniXY(AcurObj, x - ACoX, y - ACoY); -	MultiSetZPosition(AcurObj, Z_ACURSOR); +	InitStepAnimScript(&g_AcurAnim, g_AcurObj, FROM_LE_32(pfr->script), ONE_SECOND / FROM_LE_32(pfilm->frate)); +	MultiSetAniXY(g_AcurObj, x - g_ACoX, y - g_ACoY); +	MultiSetZPosition(g_AcurObj, Z_ACURSOR); -	if (bHiddenCursor) -		MultiHideObject(AcurObj); +	if (g_bHiddenCursor) +		MultiHideObject(g_AcurObj);  }  /** @@ -421,52 +421,52 @@ static void DoCursorMove() {  	dir = _vm->getKeyDirection();  	if (dir != 0) {  		if (dir & MSK_LEFT) -			newX -= IterationSize; +			newX -= g_IterationSize;  		if (dir & MSK_RIGHT) -			newX += IterationSize; +			newX += g_IterationSize;  		if (dir & MSK_UP) -			newY -= IterationSize; +			newY -= g_IterationSize;  		if (dir & MSK_DOWN) -			newY += IterationSize; +			newY += g_IterationSize; -		IterationSize += ITER_ACCELERATION; +		g_IterationSize += ITER_ACCELERATION;  		// set new mouse driver position  		_vm->setMousePosition(Common::Point(fracToInt(newX), fracToInt(newY)));  	} else -		IterationSize = ITERATION_BASE; +		g_IterationSize = ITERATION_BASE;  	// get new mouse driver position - could have been modified  	ptMouse = _vm->getMousePosition(); -	if (lastCursorX != ptMouse.x || lastCursorY != ptMouse.y) { +	if (g_lastCursorX != ptMouse.x || g_lastCursorY != ptMouse.y) {  		resetUserEventTime(); -		if (!bTempNoTrailers && !bHiddenCursor) { -			InitCurTrailObj(nextTrail++, lastCursorX, lastCursorY); -			if (nextTrail == numTrails) -				nextTrail = 0; +		if (!g_bTempNoTrailers && !g_bHiddenCursor) { +			InitCurTrailObj(g_nextTrail++, g_lastCursorX, g_lastCursorY); +			if (g_nextTrail == g_numTrails) +				g_nextTrail = 0;  		}  	}  	// adjust cursor to new mouse position -	if (McurObj) -		MultiSetAniXY(McurObj, ptMouse.x, ptMouse.y); -	if (AcurObj != NULL) -		MultiSetAniXY(AcurObj, ptMouse.x - ACoX, ptMouse.y - ACoY); +	if (g_McurObj) +		MultiSetAniXY(g_McurObj, ptMouse.x, ptMouse.y); +	if (g_AcurObj != NULL) +		MultiSetAniXY(g_AcurObj, ptMouse.x - g_ACoX, ptMouse.y - g_ACoY); -	if (InventoryActive() && McurObj) { +	if (InventoryActive() && g_McurObj) {  		// Notify the inventory  		Xmovement(ptMouse.x - startX);  		Ymovement(ptMouse.y - startY);  	} -	lastCursorX = ptMouse.x; -	lastCursorY = ptMouse.y; +	g_lastCursorX = ptMouse.x; +	g_lastCursorY = ptMouse.y;  }  /** @@ -479,7 +479,7 @@ static void InitCurObj() {  	IMAGE *pim;  	if (TinselV2) { -		pFilm = (const FILM *)LockMem(hCursorFilm); +		pFilm = (const FILM *)LockMem(g_hCursorFilm);  		pfr = (const FREEL *)&pFilm->reels[0];  		pmi = (MULTI_INIT *)LockMem(FROM_LE_32(pfr->mobj)); @@ -487,16 +487,16 @@ static void InitCurObj() {  	} else {  		assert(BgPal()); // no background palette -		pim = GetImageFromFilm(hCursorFilm, 0, &pfr, &pmi, &pFilm);// Get pointer to image +		pim = GetImageFromFilm(g_hCursorFilm, 0, &pfr, &pmi, &pFilm);// Get pointer to image  		pim->hImgPal = TO_LE_32(BgPal()); -		AcurObj = NULL;		// No auxillary cursor +		g_AcurObj = NULL;		// No auxillary cursor  	} -	McurObj = MultiInitObject(pmi); -	MultiInsertObject(GetPlayfieldList(FIELD_STATUS), McurObj); +	g_McurObj = MultiInitObject(pmi); +	MultiInsertObject(GetPlayfieldList(FIELD_STATUS), g_McurObj); -	InitStepAnimScript(&McurAnim, McurObj, FROM_LE_32(pfr->script), ONE_SECOND / FROM_LE_32(pFilm->frate)); +	InitStepAnimScript(&g_McurAnim, g_McurObj, FROM_LE_32(pfr->script), ONE_SECOND / FROM_LE_32(pFilm->frate));  }  /** @@ -504,14 +504,14 @@ static void InitCurObj() {   */  static void InitCurPos() {  	Common::Point ptMouse = _vm->getMousePosition(); -	lastCursorX = ptMouse.x; -	lastCursorY = ptMouse.y; +	g_lastCursorX = ptMouse.x; +	g_lastCursorY = ptMouse.y; -	MultiSetZPosition(McurObj, Z_CURSOR); +	MultiSetZPosition(g_McurObj, Z_CURSOR);  	DoCursorMove(); -	MultiHideObject(McurObj); +	MultiHideObject(g_McurObj); -	IterationSize = ITERATION_BASE; +	g_IterationSize = ITERATION_BASE;  }  /** @@ -525,9 +525,9 @@ static void CursorStoppedCheck(CORO_PARAM) {  	CORO_BEGIN_CODE(_ctx);  	// If scene is closing down -	if (bWhoa) { +	if (g_bWhoa) {  		// ...wait for next scene start-up -		while (restart != 0x8000) +		while (g_restart != 0x8000)  			CORO_SLEEP(1);  		// Re-initialize @@ -536,8 +536,8 @@ static void CursorStoppedCheck(CORO_PARAM) {  		InventoryIconCursor(false);	// May be holding something  		// Re-start the cursor trails -		restart = (uint16)-1;		// set all bits -		bWhoa = false; +		g_restart = (uint16)-1;		// set all bits +		g_bWhoa = false;  	}  	CORO_END_CODE;  } @@ -552,15 +552,15 @@ void CursorProcess(CORO_PARAM, const void *) {  	CORO_BEGIN_CODE(_ctx); -	while (!hCursorFilm || !BgPal()) +	while (!g_hCursorFilm || !BgPal())  		CORO_SLEEP(1);  	InitCurObj();  	InitCurPos();  	InventoryIconCursor(false);		// May be holding something -	bWhoa = false; -	restart = 0; +	g_bWhoa = false; +	g_restart = 0;  	while (1) {  		// allow rescheduling @@ -570,36 +570,36 @@ void CursorProcess(CORO_PARAM, const void *) {  		CORO_INVOKE_0(CursorStoppedCheck);  		// Step the animation script(s) -		StepAnimScript(&McurAnim); -		if (AcurObj != NULL) -			StepAnimScript(&AcurAnim); -		for (int i = 0; i < numTrails; i++) { -			if (ntrailData[i].trailObj != NULL) { -				if (StepAnimScript(&ntrailData[i].trailAnim) == ScriptFinished) { -					MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), ntrailData[i].trailObj); -					ntrailData[i].trailObj = NULL; +		StepAnimScript(&g_McurAnim); +		if (g_AcurObj != NULL) +			StepAnimScript(&g_AcurAnim); +		for (int i = 0; i < g_numTrails; i++) { +			if (g_ntrailData[i].trailObj != NULL) { +				if (StepAnimScript(&g_ntrailData[i].trailAnim) == ScriptFinished) { +					MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_ntrailData[i].trailObj); +					g_ntrailData[i].trailObj = NULL;  				}  			}  		}  		// Move the cursor as appropriate -		if (!bFrozenCursor) +		if (!g_bFrozenCursor)  			DoCursorMove();  		// If the cursor should be hidden... -		if (bHiddenCursor || bTempHide) { +		if (g_bHiddenCursor || g_bTempHide) {  			// ...hide the cursor object(s) -			MultiHideObject(McurObj); -			if (AcurObj) -				MultiHideObject(AcurObj); +			MultiHideObject(g_McurObj); +			if (g_AcurObj) +				MultiHideObject(g_AcurObj); -			for (int i = 0; i < numTrails; i++) { -				if (ntrailData[i].trailObj != NULL) -					MultiHideObject(ntrailData[i].trailObj); +			for (int i = 0; i < g_numTrails; i++) { +				if (g_ntrailData[i].trailObj != NULL) +					MultiHideObject(g_ntrailData[i].trailObj);  			}  			// Wait 'til cursor is again required. -			while (bHiddenCursor) { +			while (g_bHiddenCursor) {  				CORO_SLEEP(1);  				// Stop/start between scenes @@ -617,12 +617,12 @@ void CursorProcess(CORO_PARAM, const void *) {  void DwInitCursor(SCNHANDLE bfilm) {  	const FILM *pfilm; -	hCursorFilm = bfilm; +	g_hCursorFilm = bfilm; -	pfilm = (const FILM *)LockMem(hCursorFilm); -	numTrails = FROM_LE_32(pfilm->numreels) - 1; +	pfilm = (const FILM *)LockMem(g_hCursorFilm); +	g_numTrails = FROM_LE_32(pfilm->numreels) - 1; -	assert(numTrails <= MAX_TRAILERS); +	assert(g_numTrails <= MAX_TRAILERS);  }  /** @@ -630,24 +630,24 @@ void DwInitCursor(SCNHANDLE bfilm) {   */  void DropCursor() {  	if (TinselV2) { -		if (AcurObj) -			MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), AcurObj); -		if (McurObj) -			MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), McurObj); +		if (g_AcurObj) +			MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_AcurObj); +		if (g_McurObj) +			MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_McurObj); -		restart = 0; +		g_restart = 0;  	} -	AcurObj = NULL;		// No auxillary cursor -	McurObj = NULL;		// No cursor object (imminently deleted elsewhere) -	bHiddenCursor = false;	// Not hidden in next scene -	bTempNoTrailers = false;	// Trailers not hidden in next scene -	bWhoa = true;		// Suspend cursor processes +	g_AcurObj = NULL;		// No auxillary cursor +	g_McurObj = NULL;		// No cursor object (imminently deleted elsewhere) +	g_bHiddenCursor = false;	// Not hidden in next scene +	g_bTempNoTrailers = false;	// Trailers not hidden in next scene +	g_bWhoa = true;		// Suspend cursor processes -	for (int i = 0; i < numTrails; i++) { -		if (ntrailData[i].trailObj != NULL)		{ -			MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), ntrailData[i].trailObj); -			ntrailData[i].trailObj = NULL; +	for (int i = 0; i < g_numTrails; i++) { +		if (g_ntrailData[i].trailObj != NULL)		{ +			MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_ntrailData[i].trailObj); +			g_ntrailData[i].trailObj = NULL;  		}  	}  } @@ -656,7 +656,7 @@ void DropCursor() {   * RestartCursor is called when a new scene is starting up.   */  void RestartCursor() { -	restart = 0x8000;	// Get the main cursor to re-initialize +	g_restart = 0x8000;	// Get the main cursor to re-initialize  }  /** @@ -664,32 +664,32 @@ void RestartCursor() {   * pointers etc.   */  void RebootCursor() { -	McurObj = AcurObj = NULL; +	g_McurObj = g_AcurObj = NULL;  	for (int i = 0; i < MAX_TRAILERS; i++) -		ntrailData[i].trailObj = NULL; +		g_ntrailData[i].trailObj = NULL; -	bHiddenCursor = bTempNoTrailers = bFrozenCursor = false; +	g_bHiddenCursor = g_bTempNoTrailers = g_bFrozenCursor = false; -	hCursorFilm = 0; +	g_hCursorFilm = 0; -	bWhoa = false; -	restart = 0; +	g_bWhoa = false; +	g_restart = 0;  }  void StartCursorFollowed() {  	DelAuxCursor();  	if (!SysVar(SV_ENABLEPRINTCURSOR)) -		bTempHide = true; +		g_bTempHide = true;  }  void EndCursorFollowed() {  	InventoryIconCursor(false);	// May be holding something -	bTempHide = false; +	g_bTempHide = false;  }  bool isCursorShown() { -	return !(bTempHide || bHiddenCursor); +	return !(g_bTempHide || g_bHiddenCursor);  }  } // End of namespace Tinsel diff --git a/engines/tinsel/dialogs.cpp b/engines/tinsel/dialogs.cpp index 6ca070b67a..5396e47566 100644 --- a/engines/tinsel/dialogs.cpp +++ b/engines/tinsel/dialogs.cpp @@ -63,17 +63,6 @@  namespace Tinsel { -//----------------- EXTERNAL GLOBAL DATA -------------------- - -// In DOS_DW.C -extern bool bRestart;		// restart flag - set to restart the game - -#ifdef MAC_OPTIONS -// In MAC_SOUND.C -extern int volMaster; -#endif - -  //----------------- LOCAL DEFINES --------------------  #define HOPPER_FILENAME		"hopper" @@ -312,23 +301,23 @@ static const int vFillers[MAXVICONS] = {  //----- Permanent data (set once) ----- -static SCNHANDLE hWinParts = 0;	// Window members and cursors' graphic data -static SCNHANDLE flagFilm = 0;	// Window members and cursors' graphic data -static SCNHANDLE configStrings[20]; +static SCNHANDLE g_hWinParts = 0;	// Window members and cursors' graphic data +static SCNHANDLE g_flagFilm = 0;	// Window members and cursors' graphic data +static SCNHANDLE g_configStrings[20]; -static INV_OBJECT *invObjects = NULL;	// Inventory objects' data -static int numObjects = 0;				// Number of inventory objects -static SCNHANDLE *invFilms = NULL; -static bool bNoLanguage = false; -static DIRECTION initialDirection; +static INV_OBJECT *g_invObjects = NULL;	// Inventory objects' data +static int g_numObjects = 0;				// Number of inventory objects +static SCNHANDLE *g_invFilms = NULL; +static bool g_bNoLanguage = false; +static DIRECTION g_initialDirection;  //----- Permanent data (updated, valid while inventory closed) ----- -static enum {NO_INV, IDLE_INV, ACTIVE_INV, BOGUS_INV} InventoryState; +static enum {NO_INV, IDLE_INV, ACTIVE_INV, BOGUS_INV} g_InventoryState; -static int HeldItem = INV_NOICON;	// Current held item +static int g_heldItem = INV_NOICON;	// Current held item -static SCNHANDLE heldFilm; +static SCNHANDLE g_heldFilm;  struct INV_DEF { @@ -364,60 +353,60 @@ struct INV_DEF {  }; -static INV_DEF InvD[NUM_INV];		// Conversation + 2 inventories + ... +static INV_DEF g_InvD[NUM_INV];		// Conversation + 2 inventories + ...  // Permanent contents of conversation inventory -static int permIcons[MAX_PERMICONS];	// Basic items i.e. permanent contents -static int numPermIcons = 0;			// - copy to conv. inventory at pop-up time -static int numEndIcons = 0; +static int g_permIcons[MAX_PERMICONS];	// Basic items i.e. permanent contents +static int g_numPermIcons = 0;			// - copy to conv. inventory at pop-up time +static int g_numEndIcons = 0;  //----- Data pertinant to current active inventory ----- -static int ino = 0;		// Which inventory is currently active +static int g_ino = 0;		// Which inventory is currently active -static bool InventoryHidden = false; -static bool InventoryMaximised = false; +static bool g_InventoryHidden = false; +static bool g_InventoryMaximised = false;  static enum {	ID_NONE, ID_MOVE, ID_SLIDE,  		ID_BOTTOM, ID_TOP, ID_LEFT, ID_RIGHT,  		ID_TLEFT, ID_TRIGHT, ID_BLEFT, ID_BRIGHT, -		ID_CSLIDE, ID_MDCONT } InvDragging; +		ID_CSLIDE, ID_MDCONT } g_InvDragging; -static int SuppH = 0;		// 'Linear' element of -static int SuppV = 0;		// dimensions during re-sizing +static int g_SuppH = 0;		// 'Linear' element of +static int g_SuppV = 0;		// dimensions during re-sizing -static int Ychange = 0;		// -static int Ycompensate = 0;		// All to do with re-sizing. -static int Xchange = 0;		// -static int Xcompensate = 0;		// +static int g_Ychange = 0;		// +static int g_Ycompensate = 0;		// All to do with re-sizing. +static int g_Xchange = 0;		// +static int g_Xcompensate = 0;		// -static bool ItemsChanged = 0;	// When set, causes items to be re-drawn +static bool g_ItemsChanged = 0;	// When set, causes items to be re-drawn -static bool bReOpenMenu = 0; +static bool g_bReOpenMenu = 0; -static int TL = 0, TR = 0, BL = 0, BR = 0;	// Used during window construction -static int TLwidth = 0, TLheight = 0;	// -static int TRwidth = 0;		// -static int BLheight = 0;		// +static int g_TL = 0, g_TR = 0, g_BL = 0, g_BR = 0;	// Used during window construction +static int g_TLwidth = 0, g_TLheight = 0;	// +static int g_TRwidth = 0;		// +static int g_BLheight = 0;		// -static LANGUAGE displayedLanguage; +static LANGUAGE g_displayedLanguage; -static OBJECT	*objArray[MAX_WCOMP];	// Current display objects (window) -static OBJECT	*iconArray[MAX_ICONS];	// Current display objects (icons) -static ANIM		iconAnims[MAX_ICONS]; -static OBJECT	*DobjArray[MAX_WCOMP];	// Current display objects (re-sizing window) +static OBJECT	*g_objArray[MAX_WCOMP];	// Current display objects (window) +static OBJECT	*g_iconArray[MAX_ICONS];	// Current display objects (icons) +static ANIM		g_iconAnims[MAX_ICONS]; +static OBJECT	*g_DobjArray[MAX_WCOMP];	// Current display objects (re-sizing window) -static OBJECT *RectObject = 0, *SlideObject = 0;	// Current display objects, for reference +static OBJECT *g_RectObject = 0, *g_SlideObject = 0;	// Current display objects, for reference  					// objects are in objArray. -static int sliderYpos = 0;			// For positioning the slider -static int sliderYmax = 0, sliderYmin = 0;	// +static int g_sliderYpos = 0;			// For positioning the slider +static int g_sliderYmax = 0, g_sliderYmin = 0;	// -#define sliderRange	(sliderYmax - sliderYmin) +#define sliderRange	(g_sliderYmax - g_sliderYmin)  // Also to do with the slider -static struct { int n; int y; } slideStuff[MAX_ININV_TOT+1]; +static struct { int n; int y; } g_slideStuff[MAX_ININV_TOT+1];  #define MAXSLIDES 4  struct MDSLIDES { @@ -425,25 +414,25 @@ struct MDSLIDES {  	OBJECT	*obj;  	int	min, max;  }; -static MDSLIDES mdSlides[MAXSLIDES]; -static int numMdSlides = 0; +static MDSLIDES g_mdSlides[MAXSLIDES]; +static int g_numMdSlides = 0; -static int GlitterIndex = 0; +static int g_GlitterIndex = 0;  // Icon clicked on to cause an event  // - Passed to conversation polygon or actor code via Topic()  // - (sometimes) Passed to inventory icon code via OtherObject() -static int thisIcon = 0; +static int g_thisIcon = 0; -static CONV_PARAM thisConvFn;				// Top, 'Middle' or Bottom -static HPOLYGON thisConvPoly = 0;			// Conversation code is in a polygon code block -static int thisConvActor;					// ...or an actor's code block. -static int pointedIcon = INV_NOICON;		// used by InvLabels - icon pointed to on last call -static volatile int PointedWaitCount = 0;	// used by ObjectProcess - fix the 'repeated pressing bug' -static int sX = 0;							// used by SlideMSlider() - current x-coordinate -static int lX = 0;							// used by SlideMSlider() - last x-coordinate +static CONV_PARAM g_thisConvFn;				// Top, 'Middle' or Bottom +static HPOLYGON g_thisConvPoly = 0;			// Conversation code is in a polygon code block +static int g_thisConvActor;					// ...or an actor's code block. +static int g_pointedIcon = INV_NOICON;		// used by InvLabels - icon pointed to on last call +static volatile int g_PointedWaitCount = 0;	// used by ObjectProcess - fix the 'repeated pressing bug' +static int g_sX = 0;							// used by SlideMSlider() - current x-coordinate +static int g_lX = 0;							// used by SlideMSlider() - last x-coordinate -static bool bMoveOnUnHide;	// Set before start of conversation +static bool g_bMoveOnUnHide;	// Set before start of conversation  				// - causes conversation to be started in a sensible place  //----- Data pertinant to configure (incl. load/save game) ----- @@ -486,16 +475,16 @@ typedef HOPENTRY *PHOPENTRY;  #include "common/pack-end.h"	// END STRUCT PACKING -static PHOPPER		pHopper; -static PHOPENTRY	pEntries; -static int numScenes; +static PHOPPER		g_pHopper; +static PHOPENTRY	g_pEntries; +static int g_numScenes; -static int numEntries; +static int g_numEntries; -static PHOPPER pChosenScene = NULL; +static PHOPPER g_pChosenScene = NULL; -static int lastChosenScene; -static bool bRemember; +static int g_lastChosenScene; +static bool g_bRemember;  //-------------------------------------------------------------- @@ -970,7 +959,7 @@ static struct {  };  // For editing save game names -static char sedit[SG_DESC_LEN+2]; +static char g_sedit[SG_DESC_LEN+2];  #define HL1	0	// Hilight that moves with the cursor  #define HL2	1	// Hilight on selected RGROUP box @@ -1096,7 +1085,7 @@ static void PrimeSceneHopper() {  	vSize = f.readUint32LE();  	// allocate a buffer for it all -	assert(pHopper == NULL); +	assert(g_pHopper == NULL);  	uint32 size = f.size() - 8;  	// make sure memory allocated @@ -1111,9 +1100,9 @@ static void PrimeSceneHopper() {  		error(FILE_IS_CORRUPT, HOPPER_FILENAME);  	// Set data pointers -	pHopper = (PHOPPER)pBuffer; -	pEntries = (PHOPENTRY)(pBuffer + vSize); -	numScenes = vSize / sizeof(HOPPER); +	g_pHopper = (PHOPPER)pBuffer; +	g_pEntries = (PHOPENTRY)(pBuffer + vSize); +	g_numScenes = vSize / sizeof(HOPPER);  	// close the file  	f.close(); @@ -1123,31 +1112,31 @@ static void PrimeSceneHopper() {   * Free the scene hopper data file   */  static void FreeSceneHopper() { -	free(pHopper); -	pHopper = NULL; +	free(g_pHopper); +	g_pHopper = NULL;  }  static void FirstScene(int first) {  	int	i; -	assert(numScenes && pHopper); +	assert(g_numScenes && g_pHopper); -	if (bRemember) { +	if (g_bRemember) {  		assert(first == 0); -		first = lastChosenScene; -		bRemember = false; +		first = g_lastChosenScene; +		g_bRemember = false;  	}  	// Force it to a sensible value -	if (first > numScenes - NUM_RGROUP_BOXES) -		first = numScenes - NUM_RGROUP_BOXES; +	if (first > g_numScenes - NUM_RGROUP_BOXES) +		first = g_numScenes - NUM_RGROUP_BOXES;  	if (first < 0)  		first = 0;  	// Fill in the rest -	for (i = 0; i < NUM_RGROUP_BOXES && i + first < numScenes; i++) { +	for (i = 0; i < NUM_RGROUP_BOXES && i + first < g_numScenes; i++) {  		cd.box[i].textMethod = TM_STRINGNUM; -		cd.box[i].ixText = FROM_LE_32(pHopper[i + first].hSceneDesc); +		cd.box[i].ixText = FROM_LE_32(g_pHopper[i + first].hSceneDesc);  	}  	// Blank out the spare ones (if any)  	while (i < NUM_RGROUP_BOXES) { @@ -1159,31 +1148,31 @@ static void FirstScene(int first) {  }  static void RememberChosenScene() { -	bRemember = true; +	g_bRemember = true;  }  static void SetChosenScene() { -	lastChosenScene = cd.selBox + cd.extraBase; -	pChosenScene = &pHopper[cd.selBox + cd.extraBase]; +	g_lastChosenScene = cd.selBox + cd.extraBase; +	g_pChosenScene = &g_pHopper[cd.selBox + cd.extraBase];  }  static void FirstEntry(int first) {  	int	i; -	InvD[INV_MENU].hInvTitle = FROM_LE_32(pChosenScene->hSceneDesc); +	g_InvD[INV_MENU].hInvTitle = FROM_LE_32(g_pChosenScene->hSceneDesc);  	// get number of entrances -	numEntries = FROM_LE_32(pChosenScene->numEntries); +	g_numEntries = FROM_LE_32(g_pChosenScene->numEntries);  	// Force first to a sensible value -	if (first > numEntries-NUM_RGROUP_BOXES) -		first = numEntries-NUM_RGROUP_BOXES; +	if (first > g_numEntries-NUM_RGROUP_BOXES) +		first = g_numEntries-NUM_RGROUP_BOXES;  	if (first < 0)  		first = 0; -	for (i = 0; i < NUM_RGROUP_BOXES && i < numEntries; i++) { +	for (i = 0; i < NUM_RGROUP_BOXES && i < g_numEntries; i++) {  		cd.box[i].textMethod = TM_STRINGNUM; -		cd.box[i].ixText = FROM_LE_32(pEntries[FROM_LE_32(pChosenScene->entryIndex) + i + first].hDesc); +		cd.box[i].ixText = FROM_LE_32(g_pEntries[FROM_LE_32(g_pChosenScene->entryIndex) + i + first].hDesc);  	}  	// Blank out the spare ones (if any)  	while (i < NUM_RGROUP_BOXES) { @@ -1195,15 +1184,15 @@ static void FirstEntry(int first) {  }  static void HopAction() { -	PHOPENTRY pEntry = pEntries + FROM_LE_32(pChosenScene->entryIndex) + cd.selBox + cd.extraBase; +	PHOPENTRY pEntry = g_pEntries + FROM_LE_32(g_pChosenScene->entryIndex) + cd.selBox + cd.extraBase; -	uint32 hScene = FROM_LE_32(pChosenScene->hScene); +	uint32 hScene = FROM_LE_32(g_pChosenScene->hScene);  	uint32 eNumber = FROM_LE_32(pEntry->eNumber);  	debugC(DEBUG_BASIC, kTinselDebugAnimations, "Scene hopper chose scene %xh,%d\n", hScene, eNumber);  	if (FROM_LE_32(pEntry->flags) & fCall) {  		SaveScene(nullContext); -		NewScene(nullContext, pChosenScene->hScene, pEntry->eNumber, TRANS_FADE); +		NewScene(nullContext, g_pChosenScene->hScene, pEntry->eNumber, TRANS_FADE);  	}  	else if (FROM_LE_32(pEntry->flags) & fHook)  		HookScene(hScene, eNumber, TRANS_FADE); @@ -1220,9 +1209,9 @@ static void HopAction() {   */  static void DumpIconArray() {  	for (int i = 0; i < MAX_ICONS; i++) { -		if (iconArray[i] != NULL) { -			MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), iconArray[i]); -			iconArray[i] = NULL; +		if (g_iconArray[i] != NULL) { +			MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_iconArray[i]); +			g_iconArray[i] = NULL;  		}  	}  } @@ -1232,9 +1221,9 @@ static void DumpIconArray() {   */  static void DumpDobjArray() {  	for (int i = 0; i < MAX_WCOMP; i++) { -		if (DobjArray[i] != NULL) { -			MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), DobjArray[i]); -			DobjArray[i] = NULL; +		if (g_DobjArray[i] != NULL) { +			MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_DobjArray[i]); +			g_DobjArray[i] = NULL;  		}  	}  } @@ -1244,9 +1233,9 @@ static void DumpDobjArray() {   */  static void DumpObjArray() {  	for (int i = 0; i < MAX_WCOMP; i++) { -		if (objArray[i] != NULL) { -			MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), objArray[i]); -			objArray[i] = NULL; +		if (g_objArray[i] != NULL) { +			MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_objArray[i]); +			g_objArray[i] = NULL;  		}  	}  } @@ -1256,9 +1245,9 @@ static void DumpObjArray() {   * i.e. Image data and Glitter code.   */  static INV_OBJECT *GetInvObject(int id) { -	INV_OBJECT *pObject = invObjects; +	INV_OBJECT *pObject = g_invObjects; -	for (int i = 0; i < numObjects; i++, pObject++) { +	for (int i = 0; i < g_numObjects; i++, pObject++) {  		if (pObject->id == id)  			return pObject;  	} @@ -1270,9 +1259,9 @@ static INV_OBJECT *GetInvObject(int id) {   * Convert item ID number to index.   */  static int GetObjectIndex(int id) { -	INV_OBJECT *pObject = invObjects; +	INV_OBJECT *pObject = g_invObjects; -	for (int i = 0; i < numObjects; i++, pObject++) { +	for (int i = 0; i < g_numObjects; i++, pObject++) {  		if (pObject->id == id)  			return i;  	} @@ -1287,15 +1276,15 @@ static int GetObjectIndex(int id) {  extern int InventoryPos(int num) {  	int	i; -	for (i = 0; i < InvD[INV_1].NoofItems; i++)	// First inventory -		if (InvD[INV_1].contents[i] == num) +	for (i = 0; i < g_InvD[INV_1].NoofItems; i++)	// First inventory +		if (g_InvD[INV_1].contents[i] == num)  			return i; -	for (i = 0; i < InvD[INV_2].NoofItems; i++)	// Second inventory -		if (InvD[INV_2].contents[i] == num) +	for (i = 0; i < g_InvD[INV_2].NoofItems; i++)	// Second inventory +		if (g_InvD[INV_2].contents[i] == num)  			return i; -	if (HeldItem == num) +	if (g_heldItem == num)  		return INV_HELDNOTIN;	// Held, but not in either inventory  	return INV_NOICON;		// Not held, not in either inventory @@ -1304,8 +1293,8 @@ extern int InventoryPos(int num) {  extern bool IsInInventory(int object, int invnum) {  	assert(invnum == INV_1 || invnum == INV_2); -	for (int i = 0; i < InvD[invnum].NoofItems; i++)	// First inventory -		if (InvD[invnum].contents[i] == object) +	for (int i = 0; i < g_InvD[invnum].NoofItems; i++)	// First inventory +		if (g_InvD[invnum].contents[i] == object)  			return true;  	return false; @@ -1315,7 +1304,7 @@ extern bool IsInInventory(int object, int invnum) {   * Returns which item is held (INV_NOICON (-1) if none)   */  extern int WhichItemHeld() { -	return HeldItem; +	return g_heldItem;  }  /** @@ -1324,15 +1313,15 @@ extern int WhichItemHeld() {   */  extern void InventoryIconCursor(bool bNewItem) { -	if (HeldItem != INV_NOICON) { +	if (g_heldItem != INV_NOICON) {  		if (TinselV2) {  			if (bNewItem) { -				int	objIndex = GetObjectIndex(HeldItem); -				heldFilm = invFilms[objIndex]; +				int	objIndex = GetObjectIndex(g_heldItem); +				g_heldFilm = g_invFilms[objIndex];  			} -			SetAuxCursor(heldFilm); +			SetAuxCursor(g_heldFilm);  		} else { -			INV_OBJECT *invObj = GetInvObject(HeldItem); +			INV_OBJECT *invObj = GetInvObject(g_heldItem);  			SetAuxCursor(invObj->hIconFilm);  		}  	} @@ -1342,14 +1331,14 @@ extern void InventoryIconCursor(bool bNewItem) {   * Returns true if the inventory is active.   */  extern bool InventoryActive() { -	return (InventoryState == ACTIVE_INV); +	return (g_InventoryState == ACTIVE_INV);  }  extern int WhichInventoryOpen() { -	if (InventoryState != ACTIVE_INV) +	if (g_InventoryState != ACTIVE_INV)  		return 0;  	else -		return ino; +		return g_ino;  } @@ -1387,7 +1376,7 @@ static void ObjectProcess(CORO_PARAM, const void *param) {  	CORO_INVOKE_1(Interpret, _ctx->pic);  	if (to->event == POINTED) { -		_ctx->ThisPointedWait = ++PointedWaitCount; +		_ctx->ThisPointedWait = ++g_PointedWaitCount;  		while (1) {  			CORO_SLEEP(1);  			int	x, y; @@ -1396,7 +1385,7 @@ static void ObjectProcess(CORO_PARAM, const void *param) {  				break;  			// Fix the 'repeated pressing bug' -			if (_ctx->ThisPointedWait != PointedWaitCount) +			if (_ctx->ThisPointedWait != g_PointedWaitCount)  				CORO_KILL_SELF();  		} @@ -1413,10 +1402,10 @@ static void ObjectProcess(CORO_PARAM, const void *param) {  static void InvTinselEvent(INV_OBJECT *pinvo, TINSEL_EVENT event, PLR_EVENT be, int index) {  	OP_INIT to = { pinvo, event, be, 0 }; -	if (InventoryHidden || (TinselV2 && !pinvo->hScript)) +	if (g_InventoryHidden || (TinselV2 && !pinvo->hScript))  		return; -	GlitterIndex = index; +	g_GlitterIndex = index;  	g_scheduler->createProcess(PID_TCODE, ObjectProcess, &to, sizeof(to));  } @@ -1491,9 +1480,9 @@ static void FirstFile(int first) {  static void InvSaveGame() {  	if (cd.selBox != NOBOX) {  #ifndef JAPAN -		sedit[strlen(sedit)-1] = 0;	// Don't include the cursor! +		g_sedit[strlen(g_sedit)-1] = 0;	// Don't include the cursor!  #endif -		SaveGame(ListEntry(cd.selBox-cd.modifier+cd.extraBase, LE_NAME), sedit); +		SaveGame(ListEntry(cd.selBox-cd.modifier+cd.extraBase, LE_NAME), g_sedit);  	}  } @@ -1506,17 +1495,17 @@ static void InvLoadGame() {  	if (cd.selBox != NOBOX && (cd.selBox+cd.extraBase < cd.numSaved)) {  		rGame = cd.selBox;  		cd.selBox = NOBOX; -		if (iconArray[HL3] != NULL) { -			MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), iconArray[HL3]); -			iconArray[HL3] = NULL; +		if (g_iconArray[HL3] != NULL) { +			MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_iconArray[HL3]); +			g_iconArray[HL3] = NULL;  		} -		if (iconArray[HL2] != NULL) { -			MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), iconArray[HL2]); -			iconArray[HL2] = NULL; +		if (g_iconArray[HL2] != NULL) { +			MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_iconArray[HL2]); +			g_iconArray[HL2] = NULL;  		} -		if (iconArray[HL1] != NULL) { -			MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), iconArray[HL1]); -			iconArray[HL1] = NULL; +		if (g_iconArray[HL1] != NULL) { +			MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_iconArray[HL1]); +			g_iconArray[HL1] = NULL;  		}  		RestoreGame(rGame+cd.extraBase);  	} @@ -1533,7 +1522,7 @@ static bool UpdateString(const Common::KeyState &kbd) {  	if (!cd.editableRgroup)  		return false; -	cpos = strlen(sedit)-1; +	cpos = strlen(g_sedit)-1;  	if (kbd.ascii == 0)  		return false; @@ -1541,18 +1530,18 @@ static bool UpdateString(const Common::KeyState &kbd) {  	if (kbd.keycode == Common::KEYCODE_BACKSPACE) {  		if (!cpos)  			return false; -		sedit[cpos] = 0; +		g_sedit[cpos] = 0;  		cpos--; -		sedit[cpos] = CURSOR_CHAR; +		g_sedit[cpos] = CURSOR_CHAR;  		return true;  //	} else if (isalnum(c) || c == ',' || c == '.' || c == '\'' || (c == ' ' && cpos != 0)) {  	} else if (IsCharImage(GetTagFontHandle(), kbd.ascii) || (kbd.ascii == ' ' && cpos != 0)) {  		if (cpos == SG_DESC_LEN)  			return false; -		sedit[cpos] = kbd.ascii; +		g_sedit[cpos] = kbd.ascii;  		cpos++; -		sedit[cpos] = CURSOR_CHAR; -		sedit[cpos+1] = 0; +		g_sedit[cpos] = CURSOR_CHAR; +		g_sedit[cpos+1] = 0;  		return true;  	}  	return false; @@ -1582,25 +1571,25 @@ static bool InvKeyIn(const Common::KeyState &kbd) {  			* Delete display of text currently being edited,  			* and replace it with freshly edited text.  			*/ -			if (iconArray[HL3] != NULL) { -				MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), iconArray[HL3]); -				iconArray[HL3] = NULL; +			if (g_iconArray[HL3] != NULL) { +				MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_iconArray[HL3]); +				g_iconArray[HL3] = NULL;  			} -			iconArray[HL3] = ObjectTextOut( -				GetPlayfieldList(FIELD_STATUS), sedit, 0, -				InvD[ino].inventoryX + cd.box[cd.selBox].xpos + 2, -				InvD[ino].inventoryY + cd.box[cd.selBox].ypos + TYOFF, +			g_iconArray[HL3] = ObjectTextOut( +				GetPlayfieldList(FIELD_STATUS), g_sedit, 0, +				g_InvD[g_ino].inventoryX + cd.box[cd.selBox].xpos + 2, +				g_InvD[g_ino].inventoryY + cd.box[cd.selBox].ypos + TYOFF,  				GetTagFontHandle(), 0); -			if (MultiRightmost(iconArray[HL3]) > MAX_NAME_RIGHT) { -				MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), iconArray[HL3]); +			if (MultiRightmost(g_iconArray[HL3]) > MAX_NAME_RIGHT) { +				MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_iconArray[HL3]);  				UpdateString(Common::KeyState(Common::KEYCODE_BACKSPACE)); -				iconArray[HL3] = ObjectTextOut( -					GetPlayfieldList(FIELD_STATUS), sedit, 0, -					InvD[ino].inventoryX + cd.box[cd.selBox].xpos + 2, -					InvD[ino].inventoryY + cd.box[cd.selBox].ypos + TYOFF, +				g_iconArray[HL3] = ObjectTextOut( +					GetPlayfieldList(FIELD_STATUS), g_sedit, 0, +					g_InvD[g_ino].inventoryX + cd.box[cd.selBox].xpos + 2, +					g_InvD[g_ino].inventoryY + cd.box[cd.selBox].ypos + TYOFF,  					GetTagFontHandle(), 0);  			} -			MultiSetZPosition(iconArray[HL3], Z_INV_ITEXT + 2); +			MultiSetZPosition(g_iconArray[HL3], Z_INV_ITEXT + 2);  		}  #endif  	} @@ -1625,28 +1614,28 @@ static void Select(int i, bool force) {  	cd.selBox = i;  	// Clear previous selected highlight and text -	if (iconArray[HL2] != NULL) { -		MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), iconArray[HL2]); -		iconArray[HL2] = NULL; +	if (g_iconArray[HL2] != NULL) { +		MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_iconArray[HL2]); +		g_iconArray[HL2] = NULL;  	} -	if (iconArray[HL3] != NULL) { -		MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), iconArray[HL3]); -		iconArray[HL3] = NULL; +	if (g_iconArray[HL3] != NULL) { +		MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_iconArray[HL3]); +		g_iconArray[HL3] = NULL;  	}  	// New highlight box  	switch (cd.box[i].boxType) {  	case RGROUP: -		iconArray[HL2] = RectangleObject(BgPal(), +		g_iconArray[HL2] = RectangleObject(BgPal(),  			(TinselV2 ? HighlightColor() : COL_HILIGHT), cd.box[i].w, cd.box[i].h); -		MultiInsertObject(GetPlayfieldList(FIELD_STATUS), iconArray[HL2]); -		MultiSetAniXY(iconArray[HL2], -		InvD[ino].inventoryX + cd.box[i].xpos, -		InvD[ino].inventoryY + cd.box[i].ypos); +		MultiInsertObject(GetPlayfieldList(FIELD_STATUS), g_iconArray[HL2]); +		MultiSetAniXY(g_iconArray[HL2], +		g_InvD[g_ino].inventoryX + cd.box[i].xpos, +		g_InvD[g_ino].inventoryY + cd.box[i].ypos);  		// Z-position of box, and add edit text if appropriate  		if (cd.editableRgroup) { -			MultiSetZPosition(iconArray[HL2], Z_INV_ITEXT+1); +			MultiSetZPosition(g_iconArray[HL2], Z_INV_ITEXT+1);  			if (TinselV2) {  				assert(cd.box[i].textMethod == TM_POINTER); @@ -1657,29 +1646,29 @@ static void Select(int i, bool force) {  			// Current date and time  			time(&secs_now);  			time_now = localtime(&secs_now); -			strftime(sedit, SG_DESC_LEN, "%D %H:%M", time_now); +			strftime(g_sedit, SG_DESC_LEN, "%D %H:%M", time_now);  #else  			// Current description with cursor appended  			if (cd.box[i].boxText != NULL) { -				strcpy(sedit, cd.box[i].boxText); -				strcat(sedit, sCursor); +				strcpy(g_sedit, cd.box[i].boxText); +				strcat(g_sedit, sCursor);  			} else { -				strcpy(sedit, sCursor); +				strcpy(g_sedit, sCursor);  			}  #endif -			iconArray[HL3] = ObjectTextOut( -				GetPlayfieldList(FIELD_STATUS), sedit, 0, -				InvD[ino].inventoryX + cd.box[i].xpos + 2, +			g_iconArray[HL3] = ObjectTextOut( +				GetPlayfieldList(FIELD_STATUS), g_sedit, 0, +				g_InvD[g_ino].inventoryX + cd.box[i].xpos + 2,  #ifdef JAPAN -				InvD[ino].inventoryY + cd.box[i].ypos + 2, +				g_InvD[g_ino].inventoryY + cd.box[i].ypos + 2,  #else -				InvD[ino].inventoryY + cd.box[i].ypos + TYOFF, +				g_InvD[g_ino].inventoryY + cd.box[i].ypos + TYOFF,  #endif  				GetTagFontHandle(), 0); -			MultiSetZPosition(iconArray[HL3], Z_INV_ITEXT + 2); +			MultiSetZPosition(g_iconArray[HL3], Z_INV_ITEXT + 2);  		} else { -			MultiSetZPosition(iconArray[HL2], Z_INV_ICONS + 1); +			MultiSetZPosition(g_iconArray[HL2], Z_INV_ICONS + 1);  		}  		_vm->divertKeyInput(InvKeyIn); @@ -1687,12 +1676,12 @@ static void Select(int i, bool force) {  		break;  	case FRGROUP: -		iconArray[HL2] = RectangleObject(BgPal(), COL_HILIGHT, cd.box[i].w+6, cd.box[i].h+6); -		MultiInsertObject(GetPlayfieldList(FIELD_STATUS), iconArray[HL2]); -		MultiSetAniXY(iconArray[HL2], -		InvD[ino].inventoryX + cd.box[i].xpos - 2, -		InvD[ino].inventoryY + cd.box[i].ypos - 2); -		MultiSetZPosition(iconArray[HL2], Z_INV_BRECT+1); +		g_iconArray[HL2] = RectangleObject(BgPal(), COL_HILIGHT, cd.box[i].w+6, cd.box[i].h+6); +		MultiInsertObject(GetPlayfieldList(FIELD_STATUS), g_iconArray[HL2]); +		MultiSetAniXY(g_iconArray[HL2], +		g_InvD[g_ino].inventoryX + cd.box[i].xpos - 2, +		g_InvD[g_ino].inventoryY + cd.box[i].ypos - 2); +		MultiSetZPosition(g_iconArray[HL2], Z_INV_BRECT+1);  		break; @@ -1710,13 +1699,13 @@ static void Select(int i, bool force) {   * Stop holding an item.   */  extern void DropItem(int item) { -	if (HeldItem == item) { -		HeldItem = INV_NOICON;		// Item not held +	if (g_heldItem == item) { +		g_heldItem = INV_NOICON;		// Item not held  		DelAuxCursor();			// no longer aux cursor  	}  	// Redraw contents - held item was not displayed as a content. -	ItemsChanged = true; +	g_ItemsChanged = true;  }  /** @@ -1725,8 +1714,8 @@ extern void DropItem(int item) {  extern void ClearInventory(int invno) {  	assert(invno == INV_1 || invno == INV_2); -	InvD[invno].NoofItems = 0; -	memset(InvD[invno].contents, 0, sizeof(InvD[invno].contents)); +	g_InvD[invno].NoofItems = 0; +	memset(g_InvD[invno].contents, 0, sizeof(g_InvD[invno].contents));  }  /** @@ -1743,12 +1732,12 @@ extern void AddToInventory(int invno, int icon, bool hold) {  		|| invno == INV_OPEN || (invno == INV_DEFAULT && TinselV2));  	if (invno == INV_OPEN) { -		assert(InventoryState == ACTIVE_INV && (ino == INV_1 || ino == INV_2)); // addopeninv() with inventry not open -		invno = ino; +		assert(g_InventoryState == ACTIVE_INV && (g_ino == INV_1 || g_ino == INV_2)); // addopeninv() with inventry not open +		invno = g_ino;  		bOpen = true;  		// Make sure it doesn't get in both! -		RemFromInventory(ino == INV_1 ? INV_2 : INV_1, icon); +		RemFromInventory(g_ino == INV_1 ? INV_2 : INV_1, icon);  	} else {  		bOpen = false; @@ -1769,61 +1758,61 @@ extern void AddToInventory(int invno, int icon, bool hold) {  		RemFromInventory(INV_1, icon);  	// See if it's already there -	for (i = 0; i < InvD[invno].NoofItems; i++) { -		if (InvD[invno].contents[i] == icon) +	for (i = 0; i < g_InvD[invno].NoofItems; i++) { +		if (g_InvD[invno].contents[i] == icon)  			break;  	}  	// Add it if it isn't already there -	if (i == InvD[invno].NoofItems) { +	if (i == g_InvD[invno].NoofItems) {  		if (!bOpen) {  			if (invno == INV_CONV) {  				if (TinselV2) {  					int nei;  					// Count how many current contents have end attribute -					for (i = 0, nei = 0; i < InvD[INV_CONV].NoofItems; i++) { -						invObj = GetInvObject(InvD[INV_CONV].contents[i]); +					for (i = 0, nei = 0; i < g_InvD[INV_CONV].NoofItems; i++) { +						invObj = GetInvObject(g_InvD[INV_CONV].contents[i]);  						if (invObj->attribute & CONVENDITEM)  							nei++;  					}  					// For conversation, insert before end icons -					memmove(&InvD[INV_CONV].contents[i-nei+1], -						&InvD[INV_CONV].contents[i-nei], nei * sizeof(int)); -					InvD[INV_CONV].contents[i - nei] = icon; -					InvD[INV_CONV].NoofItems++; -					InvD[INV_CONV].NoofHicons = InvD[INV_CONV].NoofItems; +					memmove(&g_InvD[INV_CONV].contents[i-nei+1], +						&g_InvD[INV_CONV].contents[i-nei], nei * sizeof(int)); +					g_InvD[INV_CONV].contents[i - nei] = icon; +					g_InvD[INV_CONV].NoofItems++; +					g_InvD[INV_CONV].NoofHicons = g_InvD[INV_CONV].NoofItems;  					// Get the window to re-position -					bMoveOnUnHide = true; +					g_bMoveOnUnHide = true;  				} else {  					// For conversation, insert before last icon  					// which will always be the goodbye icon -					InvD[invno].contents[InvD[invno].NoofItems] = InvD[invno].contents[InvD[invno].NoofItems-1]; -					InvD[invno].contents[InvD[invno].NoofItems-1] = icon; -					InvD[invno].NoofItems++; +					g_InvD[invno].contents[g_InvD[invno].NoofItems] = g_InvD[invno].contents[g_InvD[invno].NoofItems-1]; +					g_InvD[invno].contents[g_InvD[invno].NoofItems-1] = icon; +					g_InvD[invno].NoofItems++;  				}  			} else { -				InvD[invno].contents[InvD[invno].NoofItems++] = icon; +				g_InvD[invno].contents[g_InvD[invno].NoofItems++] = icon;  			} -			ItemsChanged = true; +			g_ItemsChanged = true;  		} else {  			// It could be that the index is beyond what you'd expect  			// as delinv may well have been called -			if (GlitterIndex < InvD[invno].NoofItems) { -				memmove(&InvD[invno].contents[GlitterIndex + 1], -					&InvD[invno].contents[GlitterIndex], -					(InvD[invno].NoofItems - GlitterIndex) * sizeof(int)); -				InvD[invno].contents[GlitterIndex] = icon; +			if (g_GlitterIndex < g_InvD[invno].NoofItems) { +				memmove(&g_InvD[invno].contents[g_GlitterIndex + 1], +					&g_InvD[invno].contents[g_GlitterIndex], +					(g_InvD[invno].NoofItems - g_GlitterIndex) * sizeof(int)); +				g_InvD[invno].contents[g_GlitterIndex] = icon;  			} else { -				InvD[invno].contents[InvD[invno].NoofItems] = icon; +				g_InvD[invno].contents[g_InvD[invno].NoofItems] = icon;  			} -			InvD[invno].NoofItems++; +			g_InvD[invno].NoofItems++;  		}  		// Move here after bug on Japenese DW1 -		ItemsChanged = true; +		g_ItemsChanged = true;  	}  	// Hold it if requested @@ -1841,25 +1830,25 @@ extern bool RemFromInventory(int invno, int icon) {  	assert(invno == INV_1 || invno == INV_2 || invno == INV_CONV); // Trying to delete from illegal inventory  	// See if it's there -	for (i = 0; i < InvD[invno].NoofItems; i++) { -		if (InvD[invno].contents[i] == icon) +	for (i = 0; i < g_InvD[invno].NoofItems; i++) { +		if (g_InvD[invno].contents[i] == icon)  			break;  	} -	if (i == InvD[invno].NoofItems) +	if (i == g_InvD[invno].NoofItems)  		return false;			// Item wasn't there  	else { -		memmove(&InvD[invno].contents[i], &InvD[invno].contents[i+1], (InvD[invno].NoofItems-i)*sizeof(int)); -		InvD[invno].NoofItems--; +		memmove(&g_InvD[invno].contents[i], &g_InvD[invno].contents[i+1], (g_InvD[invno].NoofItems-i)*sizeof(int)); +		g_InvD[invno].NoofItems--;  		if (TinselV2 && invno == INV_CONV) { -			InvD[INV_CONV].NoofHicons = InvD[invno].NoofItems; +			g_InvD[INV_CONV].NoofHicons = g_InvD[invno].NoofItems;  			// Get the window to re-position -			bMoveOnUnHide = true; +			g_bMoveOnUnHide = true;  		} -		ItemsChanged = true; +		g_ItemsChanged = true;  		return true;			// Item removed  	}  } @@ -1870,27 +1859,27 @@ extern bool RemFromInventory(int invno, int icon) {  extern void HoldItem(int item, bool bKeepFilm) {  	INV_OBJECT *invObj; -	if (HeldItem != item) { -		if (TinselV2 && (HeldItem != NOOBJECT)) { +	if (g_heldItem != item) { +		if (TinselV2 && (g_heldItem != NOOBJECT)) {  			// No longer holding previous item  			DelAuxCursor();	 // no longer aux cursor  			// If old held object is not in an inventory, and  			// has a default, stick it in its default inventory. -			if (!IsInInventory(HeldItem, INV_1) && !IsInInventory(HeldItem, INV_2)) { -				invObj = GetInvObject(HeldItem); +			if (!IsInInventory(g_heldItem, INV_1) && !IsInInventory(g_heldItem, INV_2)) { +				invObj = GetInvObject(g_heldItem);  				if (invObj->attribute & DEFINV1) -					AddToInventory(INV_1, HeldItem); +					AddToInventory(INV_1, g_heldItem);  				else if (invObj->attribute & DEFINV2) -					AddToInventory(INV_2, HeldItem); +					AddToInventory(INV_2, g_heldItem);  				else  					// Hook for definable default inventory -					AddToInventory(INV_1, HeldItem); +					AddToInventory(INV_1, g_heldItem);  			}  		} else if (!TinselV2) { -			if (item == INV_NOICON && HeldItem != INV_NOICON) +			if (item == INV_NOICON && g_heldItem != INV_NOICON)  				DelAuxCursor();			// no longer aux cursor  			if (item != INV_NOICON) { @@ -1899,19 +1888,19 @@ extern void HoldItem(int item, bool bKeepFilm) {  			}  		} -		HeldItem = item;			// Item held +		g_heldItem = item;			// Item held  		if (TinselV2) {  			InventoryIconCursor(!bKeepFilm);  			// Redraw contents - held item not displayed as a content. -			ItemsChanged = true; +			g_ItemsChanged = true;  		}  	}  	if (!TinselV2)  		// Redraw contents - held item not displayed as a content. -		ItemsChanged = true; +		g_ItemsChanged = true;  }  /**************************************************************************/ @@ -1929,8 +1918,8 @@ enum {	I_NOTIN, I_HEADER, I_BODY,  			// the active area of the borders for re-sizing.  /*---------------------------------*/ -#define LeftX	InvD[ino].inventoryX -#define TopY	InvD[ino].inventoryY +#define LeftX	g_InvD[g_ino].inventoryX +#define TopY	g_InvD[g_ino].inventoryY  /*---------------------------------*/  /** @@ -1943,8 +1932,8 @@ enum {	I_NOTIN, I_HEADER, I_BODY,   */  static int InvArea(int x, int y) {  	if (TinselV2) { -		int RightX = MultiRightmost(RectObject) - NM_BG_SIZ_X - NM_BG_POS_X - NM_RS_R_INSET; -		int BottomY = MultiLowest(RectObject) - NM_BG_SIZ_Y - NM_BG_POS_Y - NM_RS_B_INSET; +		int RightX = MultiRightmost(g_RectObject) - NM_BG_SIZ_X - NM_BG_POS_X - NM_RS_R_INSET; +		int BottomY = MultiLowest(g_RectObject) - NM_BG_SIZ_Y - NM_BG_POS_Y - NM_RS_B_INSET;  		// Outside the whole rectangle?  		if (x <= LeftX || x > RightX || y <= TopY || y > BottomY) @@ -1983,7 +1972,7 @@ static int InvArea(int x, int y) {  			return I_HEADER;  		// Scroll bits -		if (!(ino == INV_MENU && cd.bExtraWin)) { +		if (!(g_ino == INV_MENU && cd.bExtraWin)) {  			if (x > RightX - NM_SLIDE_INSET && x <= RightX - NM_SLIDE_INSET + NM_SLIDE_THICKNESS) {  				if (y > TopY + NM_UP_ARROW_TOP && y < TopY + NM_UP_ARROW_BOTTOM)  					return I_UP; @@ -1992,10 +1981,10 @@ static int InvArea(int x, int y) {  				/* '3' is a magic adjustment with no apparent sense */ -				if (y >= TopY + sliderYmin - 3 && y < TopY + sliderYmax + NM_SLH) { -					if (y < TopY + sliderYpos - 3) +				if (y >= TopY + g_sliderYmin - 3 && y < TopY + g_sliderYmax + NM_SLH) { +					if (y < TopY + g_sliderYpos - 3)  						return I_SLIDE_UP; -					if (y < TopY + sliderYpos + NM_SLH - 3) +					if (y < TopY + g_sliderYpos + NM_SLH - 3)  						return I_SLIDE;  					else  						return I_SLIDE_DOWN; @@ -2003,8 +1992,8 @@ static int InvArea(int x, int y) {  			}  		}  	} else { -		int RightX = MultiRightmost(RectObject) + 1; -		int BottomY = MultiLowest(RectObject) + 1; +		int RightX = MultiRightmost(g_RectObject) + 1; +		int BottomY = MultiLowest(g_RectObject) + 1;  		// Outside the whole rectangle?  		if (x <= LeftX - EXTRA || x > RightX + EXTRA @@ -2041,7 +2030,7 @@ static int InvArea(int x, int y) {  		/*  		 * In the move area?  		 */ -		if (ino != INV_CONF +		if (g_ino != INV_CONF  		&& x >= LeftX + M_SW - 2 && x <= RightX - M_SW + 3 &&  		   y >= TopY + M_TH - 2  && y < TopY + M_TBB + 2)  			return I_HEADER; @@ -2049,17 +2038,17 @@ static int InvArea(int x, int y) {  		/*  		 * Scroll bits  		 */ -		if (!(ino == INV_CONF && cd.bExtraWin)) { +		if (!(g_ino == INV_CONF && cd.bExtraWin)) {  			if (x > RightX - NM_SLIDE_INSET && x <= RightX - NM_SLIDE_INSET + NM_SLIDE_THICKNESS) {  				if (y > TopY + M_IUT + 1 && y < TopY + M_IUB - 1)  					return I_UP;  				if (y > BottomY - M_IDT + 4 && y <= BottomY - M_IDB + 1)  					return I_DOWN; -				if (y >= TopY + sliderYmin && y < TopY + sliderYmax + M_SH) { -					if (y < TopY + sliderYpos) +				if (y >= TopY + g_sliderYmin && y < TopY + g_sliderYmax + M_SH) { +					if (y < TopY + g_sliderYpos)  						return I_SLIDE_UP; -					if (y < TopY + sliderYpos + M_SH) +					if (y < TopY + g_sliderYpos + M_SH)  						return I_SLIDE;  					else  						return I_SLIDE_DOWN; @@ -2081,14 +2070,14 @@ extern int InvItem(int *x, int *y, bool update) {  	int item;  	int IconsX; -	itop = InvD[ino].inventoryY + START_ICONY; +	itop = g_InvD[g_ino].inventoryY + START_ICONY; -	IconsX = InvD[ino].inventoryX + START_ICONX; +	IconsX = g_InvD[g_ino].inventoryX + START_ICONX; -	for (item = InvD[ino].FirstDisp, row = 0; row < InvD[ino].NoofVicons; row++) { +	for (item = g_InvD[g_ino].FirstDisp, row = 0; row < g_InvD[g_ino].NoofVicons; row++) {  		ileft = IconsX; -		for (col = 0; col < InvD[ino].NoofHicons; col++, item++) { +		for (col = 0; col < g_InvD[g_ino].NoofHicons; col++, item++) {  			if (*x >= ileft && *x < ileft + ITEM_WIDTH &&  			   *y >= itop  && *y < itop + ITEM_HEIGHT) {  				if (update) { @@ -2121,20 +2110,20 @@ int InvItemId(int x, int y) {  	int row, col;  	int item; -	if (InventoryHidden || InventoryState == IDLE_INV) +	if (g_InventoryHidden || g_InventoryState == IDLE_INV)  		return INV_NOICON; -	itop = InvD[ino].inventoryY + START_ICONY; +	itop = g_InvD[g_ino].inventoryY + START_ICONY; -	int IconsX = InvD[ino].inventoryX + START_ICONX; +	int IconsX = g_InvD[g_ino].inventoryX + START_ICONX; -	for (item = InvD[ino].FirstDisp, row = 0; row < InvD[ino].NoofVicons; row++) { +	for (item = g_InvD[g_ino].FirstDisp, row = 0; row < g_InvD[g_ino].NoofVicons; row++) {  		ileft = IconsX; -		for (col = 0; col < InvD[ino].NoofHicons; col++, item++) { +		for (col = 0; col < g_InvD[g_ino].NoofHicons; col++, item++) {  			if (x >= ileft && x < ileft + ITEM_WIDTH &&  			   y >= itop  && y < itop + ITEM_HEIGHT) { -				return InvD[ino].contents[item]; +				return g_InvD[g_ino].contents[item];  			}  			ileft += ITEM_WIDTH + 1; @@ -2149,15 +2138,15 @@ int InvItemId(int x, int y) {   */  static int WhichMenuBox(int curX, int curY, bool bSlides) {  	if (bSlides) { -		for (int i = 0; i < numMdSlides; i++) { -			if (curY > MultiHighest(mdSlides[i].obj) && curY < MultiLowest(mdSlides[i].obj) -			&& curX > MultiLeftmost(mdSlides[i].obj) && curX < MultiRightmost(mdSlides[i].obj)) -				return mdSlides[i].num | IS_SLIDER; +		for (int i = 0; i < g_numMdSlides; i++) { +			if (curY > MultiHighest(g_mdSlides[i].obj) && curY < MultiLowest(g_mdSlides[i].obj) +			&& curX > MultiLeftmost(g_mdSlides[i].obj) && curX < MultiRightmost(g_mdSlides[i].obj)) +				return g_mdSlides[i].num | IS_SLIDER;  		}  	} -	curX -= InvD[ino].inventoryX; -	curY -= InvD[ino].inventoryY; +	curX -= g_InvD[g_ino].inventoryX; +	curY -= g_InvD[g_ino].inventoryY;  	for (int i = 0; i < cd.NumBoxes; i++) {  		switch (cd.box[i].boxType) { @@ -2184,7 +2173,7 @@ static int WhichMenuBox(int curX, int curY, bool bSlides) {  			break;  		case ROTATE: -			if (bNoLanguage) +			if (g_bNoLanguage)  				break;  			if (curY > cd.box[i].ypos && curY < cd.box[i].ypos + cd.box[i].h) { @@ -2222,9 +2211,9 @@ static int WhichMenuBox(int curX, int curY, bool bSlides) {  				return IB_UP;  			else if (curY > (r.bottom - (TinselV2 ? 18 : 5)))  				return IB_DOWN; -			else if (curY + InvD[ino].inventoryY < sliderYpos) +			else if (curY + g_InvD[g_ino].inventoryY < g_sliderYpos)  				return IB_SLIDE_UP; -			else if (curY + InvD[ino].inventoryY >= sliderYpos + NM_SLH) +			else if (curY + g_InvD[g_ino].inventoryY >= g_sliderYpos + NM_SLH)  				return IB_SLIDE_DOWN;  			else  				return IB_SLIDE; @@ -2260,60 +2249,60 @@ static void InvBoxes(bool InBody, int curX, int curY) {  	if (index < 0) {  		// unhigh-light box (if one was)  		cd.pointBox = NOBOX; -		if (iconArray[HL1] != NULL) { -			MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), iconArray[HL1]); -			iconArray[HL1] = NULL; +		if (g_iconArray[HL1] != NULL) { +			MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_iconArray[HL1]); +			g_iconArray[HL1] = NULL;  		}  	} else if (index != cd.pointBox) {  		cd.pointBox = index;  		// A new box is pointed to - high-light it -		if (iconArray[HL1] != NULL) { -			MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), iconArray[HL1]); -			iconArray[HL1] = NULL; +		if (g_iconArray[HL1] != NULL) { +			MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_iconArray[HL1]); +			g_iconArray[HL1] = NULL;  		}  		if ((cd.box[cd.pointBox].boxType == ARSBUT && cd.selBox != NOBOX) ||  ///* I don't agree */ cd.box[cd.pointBox].boxType == RGROUP ||  		    cd.box[cd.pointBox].boxType == AATBUT ||  		    cd.box[cd.pointBox].boxType == AABUT) { -			iconArray[HL1] = RectangleObject(BgPal(), +			g_iconArray[HL1] = RectangleObject(BgPal(),  				(TinselV2 ? HighlightColor() : COL_HILIGHT),  				cd.box[cd.pointBox].w, cd.box[cd.pointBox].h); -			MultiInsertObject(GetPlayfieldList(FIELD_STATUS), iconArray[HL1]); -			MultiSetAniXY(iconArray[HL1], -				InvD[ino].inventoryX + cd.box[cd.pointBox].xpos, -				InvD[ino].inventoryY + cd.box[cd.pointBox].ypos); -			MultiSetZPosition(iconArray[HL1], Z_INV_ICONS+1); +			MultiInsertObject(GetPlayfieldList(FIELD_STATUS), g_iconArray[HL1]); +			MultiSetAniXY(g_iconArray[HL1], +				g_InvD[g_ino].inventoryX + cd.box[cd.pointBox].xpos, +				g_InvD[g_ino].inventoryY + cd.box[cd.pointBox].ypos); +			MultiSetZPosition(g_iconArray[HL1], Z_INV_ICONS+1);  		} else if (cd.box[cd.pointBox].boxType == AAGBUT ||  				cd.box[cd.pointBox].boxType == ARSGBUT ||  				cd.box[cd.pointBox].boxType == TOGGLE ||  				cd.box[cd.pointBox].boxType == TOGGLE1 ||  				cd.box[cd.pointBox].boxType == TOGGLE2) { -			pfilm = (const FILM *)LockMem(hWinParts); +			pfilm = (const FILM *)LockMem(g_hWinParts); -			iconArray[HL1] = AddObject(&pfilm->reels[cd.box[cd.pointBox].bi+HIGRAPH], -1); -			MultiSetAniXY(iconArray[HL1], -				InvD[ino].inventoryX + cd.box[cd.pointBox].xpos, -				InvD[ino].inventoryY + cd.box[cd.pointBox].ypos); -			MultiSetZPosition(iconArray[HL1], Z_INV_ICONS+1); +			g_iconArray[HL1] = AddObject(&pfilm->reels[cd.box[cd.pointBox].bi+HIGRAPH], -1); +			MultiSetAniXY(g_iconArray[HL1], +				g_InvD[g_ino].inventoryX + cd.box[cd.pointBox].xpos, +				g_InvD[g_ino].inventoryY + cd.box[cd.pointBox].ypos); +			MultiSetZPosition(g_iconArray[HL1], Z_INV_ICONS+1);  		} else if (cd.box[cd.pointBox].boxType == ROTATE) { -			if (bNoLanguage) +			if (g_bNoLanguage)  				return; -			pfilm = (const FILM *)LockMem(hWinParts); +			pfilm = (const FILM *)LockMem(g_hWinParts);  			rotateIndex = cd.box[cd.pointBox].bi;  			if (rotateIndex == IX2_LEFT1) { -				iconArray[HL1] = AddObject(&pfilm->reels[IX2_LEFT2], -1 ); -				MultiSetAniXY(iconArray[HL1], -					InvD[ino].inventoryX + cd.box[cd.pointBox].xpos - ROTX1, -					InvD[ino].inventoryY + cd.box[cd.pointBox].ypos); -				MultiSetZPosition(iconArray[HL1], Z_INV_ICONS+1); +				g_iconArray[HL1] = AddObject(&pfilm->reels[IX2_LEFT2], -1 ); +				MultiSetAniXY(g_iconArray[HL1], +					g_InvD[g_ino].inventoryX + cd.box[cd.pointBox].xpos - ROTX1, +					g_InvD[g_ino].inventoryY + cd.box[cd.pointBox].ypos); +				MultiSetZPosition(g_iconArray[HL1], Z_INV_ICONS+1);  			} else if (rotateIndex == IX2_RIGHT1) { -				iconArray[HL1] = AddObject(&pfilm->reels[IX2_RIGHT2], -1); -				MultiSetAniXY(iconArray[HL1], -					InvD[ino].inventoryX + cd.box[cd.pointBox].xpos + ROTX1, -					InvD[ino].inventoryY + cd.box[cd.pointBox].ypos); -				MultiSetZPosition(iconArray[HL1], Z_INV_ICONS + 1); +				g_iconArray[HL1] = AddObject(&pfilm->reels[IX2_RIGHT2], -1); +				MultiSetAniXY(g_iconArray[HL1], +					g_InvD[g_ino].inventoryX + cd.box[cd.pointBox].xpos + ROTX1, +					g_InvD[g_ino].inventoryY + cd.box[cd.pointBox].ypos); +				MultiSetZPosition(g_iconArray[HL1], Z_INV_ICONS + 1);  			}  		}  	} @@ -2330,37 +2319,37 @@ static void ButtonPress(CORO_PARAM, CONFBOX *box) {  	assert(box->boxType == AAGBUT || box->boxType == ARSGBUT);  	// Replace highlight image with normal image -	pfilm = (const FILM *)LockMem(hWinParts); -	if (iconArray[HL1] != NULL) -		MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), iconArray[HL1]); -	pfilm = (const FILM *)LockMem(hWinParts); -	iconArray[HL1] = AddObject(&pfilm->reels[box->bi+NORMGRAPH], -1); -	MultiSetAniXY(iconArray[HL1], InvD[ino].inventoryX + box->xpos, InvD[ino].inventoryY + box->ypos); -	MultiSetZPosition(iconArray[HL1], Z_INV_ICONS+1); +	pfilm = (const FILM *)LockMem(g_hWinParts); +	if (g_iconArray[HL1] != NULL) +		MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_iconArray[HL1]); +	pfilm = (const FILM *)LockMem(g_hWinParts); +	g_iconArray[HL1] = AddObject(&pfilm->reels[box->bi+NORMGRAPH], -1); +	MultiSetAniXY(g_iconArray[HL1], g_InvD[g_ino].inventoryX + box->xpos, g_InvD[g_ino].inventoryY + box->ypos); +	MultiSetZPosition(g_iconArray[HL1], Z_INV_ICONS+1);  	// Hold normal image for 1 frame  	CORO_SLEEP(1); -	if (iconArray[HL1] == NULL) +	if (g_iconArray[HL1] == NULL)  		return;  	// Replace normal image with depresses image -	pfilm = (const FILM *)LockMem(hWinParts); -	MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), iconArray[HL1]); -	iconArray[HL1] = AddObject(&pfilm->reels[box->bi+DOWNGRAPH], -1); -	MultiSetAniXY(iconArray[HL1], InvD[ino].inventoryX + box->xpos, InvD[ino].inventoryY + box->ypos); -	MultiSetZPosition(iconArray[HL1], Z_INV_ICONS+1); +	pfilm = (const FILM *)LockMem(g_hWinParts); +	MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_iconArray[HL1]); +	g_iconArray[HL1] = AddObject(&pfilm->reels[box->bi+DOWNGRAPH], -1); +	MultiSetAniXY(g_iconArray[HL1], g_InvD[g_ino].inventoryX + box->xpos, g_InvD[g_ino].inventoryY + box->ypos); +	MultiSetZPosition(g_iconArray[HL1], Z_INV_ICONS+1);  	// Hold depressed image for 2 frames  	CORO_SLEEP(2); -	if (iconArray[HL1] == NULL) +	if (g_iconArray[HL1] == NULL)  		return;  	// Replace depressed image with normal image -	pfilm = (const FILM *)LockMem(hWinParts); -	MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), iconArray[HL1]); -	iconArray[HL1] = AddObject(&pfilm->reels[box->bi+NORMGRAPH], -1); -	MultiSetAniXY(iconArray[HL1], InvD[ino].inventoryX + box->xpos, InvD[ino].inventoryY + box->ypos); -	MultiSetZPosition(iconArray[HL1], Z_INV_ICONS+1); +	pfilm = (const FILM *)LockMem(g_hWinParts); +	MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_iconArray[HL1]); +	g_iconArray[HL1] = AddObject(&pfilm->reels[box->bi+NORMGRAPH], -1); +	MultiSetAniXY(g_iconArray[HL1], g_InvD[g_ino].inventoryX + box->xpos, g_InvD[g_ino].inventoryY + box->ypos); +	MultiSetZPosition(g_iconArray[HL1], Z_INV_ICONS+1);  	CORO_SLEEP(1); @@ -2379,25 +2368,25 @@ static void ButtonToggle(CORO_PARAM, CONFBOX *box) {  		|| (box->boxType == TOGGLE2));  	// Remove hilight image -	if (iconArray[HL1] != NULL) { -		MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), iconArray[HL1]); -		iconArray[HL1] = NULL; +	if (g_iconArray[HL1] != NULL) { +		MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_iconArray[HL1]); +		g_iconArray[HL1] = NULL;  	}  	// Hold normal image for 1 frame  	CORO_SLEEP(1); -	if (InventoryState != ACTIVE_INV) +	if (g_InventoryState != ACTIVE_INV)  		return;  	// Add depressed image -	pfilm = (const FILM *)LockMem(hWinParts); -	iconArray[HL1] = AddObject(&pfilm->reels[box->bi+DOWNGRAPH], -1); -	MultiSetAniXY(iconArray[HL1], InvD[ino].inventoryX + box->xpos, InvD[ino].inventoryY + box->ypos); -	MultiSetZPosition(iconArray[HL1], Z_INV_ICONS+1); +	pfilm = (const FILM *)LockMem(g_hWinParts); +	g_iconArray[HL1] = AddObject(&pfilm->reels[box->bi+DOWNGRAPH], -1); +	MultiSetAniXY(g_iconArray[HL1], g_InvD[g_ino].inventoryX + box->xpos, g_InvD[g_ino].inventoryY + box->ypos); +	MultiSetZPosition(g_iconArray[HL1], Z_INV_ICONS+1);  	// Hold depressed image for 1 frame  	CORO_SLEEP(1); -	if (iconArray[HL1] == NULL) +	if (g_iconArray[HL1] == NULL)  		return;  	// Toggle state @@ -2409,34 +2398,34 @@ static void ButtonToggle(CORO_PARAM, CONFBOX *box) {  		Select(cd.selBox, true);  	// New state, depressed image -	pfilm = (const FILM *)LockMem(hWinParts); -	if (iconArray[HL1] != NULL) -		MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), iconArray[HL1]); -	iconArray[HL1] = AddObject(&pfilm->reels[box->bi+DOWNGRAPH], -1); -	MultiSetAniXY(iconArray[HL1], InvD[ino].inventoryX + box->xpos, InvD[ino].inventoryY + box->ypos); -	MultiSetZPosition(iconArray[HL1], Z_INV_ICONS+1); +	pfilm = (const FILM *)LockMem(g_hWinParts); +	if (g_iconArray[HL1] != NULL) +		MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_iconArray[HL1]); +	g_iconArray[HL1] = AddObject(&pfilm->reels[box->bi+DOWNGRAPH], -1); +	MultiSetAniXY(g_iconArray[HL1], g_InvD[g_ino].inventoryX + box->xpos, g_InvD[g_ino].inventoryY + box->ypos); +	MultiSetZPosition(g_iconArray[HL1], Z_INV_ICONS+1);  	// Hold new depressed image for 1 frame  	CORO_SLEEP(1); -	if (iconArray[HL1] == NULL) +	if (g_iconArray[HL1] == NULL)  		return;  	// New state, normal -	MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), iconArray[HL1]); -	iconArray[HL1] = NULL; +	MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_iconArray[HL1]); +	g_iconArray[HL1] = NULL;  	// Hold normal image for 1 frame  	CORO_SLEEP(1); -	if (InventoryState != ACTIVE_INV) +	if (g_InventoryState != ACTIVE_INV)  		return;  	// New state, highlighted -	pfilm = (const FILM *)LockMem(hWinParts); -	if (iconArray[HL1] != NULL) -		MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), iconArray[HL1]); -	iconArray[HL1] = AddObject(&pfilm->reels[box->bi+HIGRAPH], -1); -	MultiSetAniXY(iconArray[HL1], InvD[ino].inventoryX + box->xpos, InvD[ino].inventoryY + box->ypos); -	MultiSetZPosition(iconArray[HL1], Z_INV_ICONS+1); +	pfilm = (const FILM *)LockMem(g_hWinParts); +	if (g_iconArray[HL1] != NULL) +		MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), g_iconArray[HL1]); +	g_iconArray[HL1] = AddObject(&pfilm->reels[box->bi+HIGRAPH], -1); +	MultiSetAniXY(g_iconArray[HL1], g_InvD[g_ino].inventoryX + box->xpos, g_InvD[g_ino].inventoryY + box->ypos); +	MultiSetZPosition(g_iconArray[HL1], Z_INV_ICONS+1);  	CORO_END_CODE;  } @@ -2454,23 +2443,23 @@ static void InvLabels(bool InBody, int aniX, int aniY) {  	else {  		index = InvItem(&aniX, &aniY, false);  		if (index != INV_NOICON) { -			if (index >= InvD[ino].NoofItems) +			if (index >= g_InvD[g_ino].NoofItems)  				index = INV_NOICON;  			else -				index = InvD[ino].contents[index]; +				index = g_InvD[g_ino].contents[index];  		}  	}  	// If no icon pointed to, or points to (logical position of)  	// currently held icon, then no icon is pointed to! -	if (index == INV_NOICON || index == HeldItem) { -		pointedIcon = INV_NOICON; -	} else if (index != pointedIcon) { +	if (index == INV_NOICON || index == g_heldItem) { +		g_pointedIcon = INV_NOICON; +	} else if (index != g_pointedIcon) {  		// A new icon is pointed to - run its script with POINTED event  		invObj = GetInvObject(index);  		if (invObj->hScript)  			InvTinselEvent(invObj, POINTED, PLR_NOEVENT, index); -		pointedIcon = index; +		g_pointedIcon = index;  	}  } @@ -2492,54 +2481,54 @@ static void AdjustTop() {  	int n, i;  	// Only do this if there's a slider -	if (!SlideObject) +	if (!g_SlideObject)  		return; -	rowsWanted = (InvD[ino].NoofItems - InvD[ino].FirstDisp + InvD[ino].NoofHicons-1) / InvD[ino].NoofHicons; +	rowsWanted = (g_InvD[g_ino].NoofItems - g_InvD[g_ino].FirstDisp + g_InvD[g_ino].NoofHicons-1) / g_InvD[g_ino].NoofHicons; -	while (rowsWanted < InvD[ino].NoofVicons) { -		if (InvD[ino].FirstDisp) { -			InvD[ino].FirstDisp -= InvD[ino].NoofHicons; -			if (InvD[ino].FirstDisp < 0) -				InvD[ino].FirstDisp = 0; +	while (rowsWanted < g_InvD[g_ino].NoofVicons) { +		if (g_InvD[g_ino].FirstDisp) { +			g_InvD[g_ino].FirstDisp -= g_InvD[g_ino].NoofHicons; +			if (g_InvD[g_ino].FirstDisp < 0) +				g_InvD[g_ino].FirstDisp = 0;  			rowsWanted++;  		} else  			break;  	} -	tMissing = InvD[ino].FirstDisp ? (InvD[ino].FirstDisp + InvD[ino].NoofHicons-1)/InvD[ino].NoofHicons : 0; -	bMissing = (rowsWanted > InvD[ino].NoofVicons) ? rowsWanted - InvD[ino].NoofVicons : 0; +	tMissing = g_InvD[g_ino].FirstDisp ? (g_InvD[g_ino].FirstDisp + g_InvD[g_ino].NoofHicons-1)/g_InvD[g_ino].NoofHicons : 0; +	bMissing = (rowsWanted > g_InvD[g_ino].NoofVicons) ? rowsWanted - g_InvD[g_ino].NoofVicons : 0;  	nMissing = tMissing + bMissing; -	slideRange = sliderYmax - sliderYmin; +	slideRange = g_sliderYmax - g_sliderYmin;  	if (!tMissing) -		nsliderYpos = sliderYmin; +		nsliderYpos = g_sliderYmin;  	else if (!bMissing) -		nsliderYpos = sliderYmax; +		nsliderYpos = g_sliderYmax;  	else {  		nsliderYpos = tMissing*slideRange/nMissing; -		nsliderYpos += sliderYmin; +		nsliderYpos += g_sliderYmin;  	}  	if (nMissing) { -		n = InvD[ino].FirstDisp - tMissing*InvD[ino].NoofHicons; -		for (i = 0; i <= nMissing; i++, n += InvD[ino].NoofHicons) { -			slideStuff[i].n = n; -			slideStuff[i].y = (i*slideRange/nMissing) + sliderYmin; +		n = g_InvD[g_ino].FirstDisp - tMissing*g_InvD[g_ino].NoofHicons; +		for (i = 0; i <= nMissing; i++, n += g_InvD[g_ino].NoofHicons) { +			g_slideStuff[i].n = n; +			g_slideStuff[i].y = (i*slideRange/nMissing) + g_sliderYmin;  		} -		if (slideStuff[0].n < 0) -			slideStuff[0].n = 0; +		if (g_slideStuff[0].n < 0) +			g_slideStuff[0].n = 0;  		assert(i < MAX_ININV + 1); -		slideStuff[i].n = -1; +		g_slideStuff[i].n = -1;  	} else { -		slideStuff[0].n = 0; -		slideStuff[0].y = sliderYmin; -		slideStuff[1].n = -1; +		g_slideStuff[0].n = 0; +		g_slideStuff[0].y = g_sliderYmin; +		g_slideStuff[1].n = -1;  	} -	if (nsliderYpos != sliderYpos) { -		MultiMoveRelXY(SlideObject, 0, nsliderYpos - sliderYpos); -		sliderYpos = nsliderYpos; +	if (nsliderYpos != g_sliderYpos) { +		MultiMoveRelXY(g_SlideObject, 0, nsliderYpos - g_sliderYpos); +		g_sliderYpos = nsliderYpos;  	}  } @@ -2580,26 +2569,26 @@ static void FillInInventory() {  	DumpIconArray(); -	if (InvDragging != ID_SLIDE) +	if (g_InvDragging != ID_SLIDE)  		AdjustTop();		// Set up slideStuff[] -	Index = InvD[ino].FirstDisp;	// Start from first displayed object +	Index = g_InvD[g_ino].FirstDisp;	// Start from first displayed object  	n = 0;  	ypos = START_ICONY;		// Y-offset of first display row -	for (row = 0; row < InvD[ino].NoofVicons; row++,	ypos += ITEM_HEIGHT + 1) { +	for (row = 0; row < g_InvD[g_ino].NoofVicons; row++,	ypos += ITEM_HEIGHT + 1) {  		xpos = START_ICONX;		// X-offset of first display column -		for (col = 0; col < InvD[ino].NoofHicons; col++) { -			if (Index >= InvD[ino].NoofItems) +		for (col = 0; col < g_InvD[g_ino].NoofHicons; col++) { +			if (Index >= g_InvD[g_ino].NoofItems)  				break; -			else if (InvD[ino].contents[Index] != HeldItem) { +			else if (g_InvD[g_ino].contents[Index] != g_heldItem) {  				// Create a display object and position it -				iconArray[n] = AddInvObject(InvD[ino].contents[Index], &pfr, &pfilm); -				MultiSetAniXY(iconArray[n], InvD[ino].inventoryX + xpos , InvD[ino].inventoryY + ypos); -				MultiSetZPosition(iconArray[n], Z_INV_ICONS); +				g_iconArray[n] = AddInvObject(g_InvD[g_ino].contents[Index], &pfr, &pfilm); +				MultiSetAniXY(g_iconArray[n], g_InvD[g_ino].inventoryX + xpos , g_InvD[g_ino].inventoryY + ypos); +				MultiSetZPosition(g_iconArray[n], Z_INV_ICONS); -				InitStepAnimScript(&iconAnims[n], iconArray[n], FROM_LE_32(pfr->script), ONE_SECOND / FROM_LE_32(pfilm->frate)); +				InitStepAnimScript(&g_iconAnims[n], g_iconArray[n], FROM_LE_32(pfr->script), ONE_SECOND / FROM_LE_32(pfilm->frate));  				n++;  			} @@ -2617,16 +2606,16 @@ enum {FROM_HANDLE, FROM_STRING};   */  static void AddBackground(OBJECT **rect, OBJECT **title, int extraH, int extraV, int textFrom) {  	// Why not 2 ???? -	int width = TLwidth + extraH + TRwidth + NM_BG_SIZ_X; -	int height = TLheight + extraV + BLheight + NM_BG_SIZ_Y; +	int width = g_TLwidth + extraH + g_TRwidth + NM_BG_SIZ_X; +	int height = g_TLheight + extraV + g_BLheight + NM_BG_SIZ_Y;  	// Create a rectangle object -	RectObject = *rect = TranslucentObject(width, height); +	g_RectObject = *rect = TranslucentObject(width, height);  	// add it to display list and position it  	MultiInsertObject(GetPlayfieldList(FIELD_STATUS), *rect); -	MultiSetAniXY(*rect, InvD[ino].inventoryX + NM_BG_POS_X, -		InvD[ino].inventoryY + NM_BG_POS_Y); +	MultiSetAniXY(*rect, g_InvD[g_ino].inventoryX + NM_BG_POS_X, +		g_InvD[g_ino].inventoryY + NM_BG_POS_Y);  	MultiSetZPosition(*rect, Z_INV_BRECT);  	if (title == NULL) @@ -2634,16 +2623,16 @@ static void AddBackground(OBJECT **rect, OBJECT **title, int extraH, int extraV,  	// Create text object using title string  	if (textFrom == FROM_HANDLE) { -		LoadStringRes(InvD[ino].hInvTitle, TextBufferAddr(), TBUFSZ); +		LoadStringRes(g_InvD[g_ino].hInvTitle, TextBufferAddr(), TBUFSZ);  		*title = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), TextBufferAddr(), 0, -					InvD[ino].inventoryX + width/2, InvD[ino].inventoryY + M_TOFF, +					g_InvD[g_ino].inventoryX + width/2, g_InvD[g_ino].inventoryY + M_TOFF,  					GetTagFontHandle(), TXT_CENTER);  		assert(*title); // Inventory title string produced NULL text  		MultiSetZPosition(*title, Z_INV_HTEXT);  	} else if (textFrom == FROM_STRING && cd.ixHeading != NO_HEADING) { -		LoadStringRes(configStrings[cd.ixHeading], TextBufferAddr(), TBUFSZ); +		LoadStringRes(g_configStrings[cd.ixHeading], TextBufferAddr(), TBUFSZ);  		*title = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), TextBufferAddr(), 0, -					InvD[ino].inventoryX + width/2, InvD[ino].inventoryY + M_TOFF, +					g_InvD[g_ino].inventoryX + width/2, g_InvD[g_ino].inventoryY + M_TOFF,  					GetTagFontHandle(), TXT_CENTER);  		assert(*title); // Inventory title string produced NULL text  		MultiSetZPosition(*title, Z_INV_HTEXT); @@ -2661,13 +2650,13 @@ static void AddBackground(OBJECT **rect, int extraH, int extraV) {   * Adds a title for a dialog   */  static void AddTitle(POBJECT *title, int extraH) { -	int width = TLwidth + extraH + TRwidth + NM_BG_SIZ_X; +	int width = g_TLwidth + extraH + g_TRwidth + NM_BG_SIZ_X;  	// Create text object using title string -	if (InvD[ino].hInvTitle != (SCNHANDLE)NO_HEADING) { -		LoadStringRes(InvD[ino].hInvTitle, TextBufferAddr(), TBUFSZ); +	if (g_InvD[g_ino].hInvTitle != (SCNHANDLE)NO_HEADING) { +		LoadStringRes(g_InvD[g_ino].hInvTitle, TextBufferAddr(), TBUFSZ);  		*title = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), TextBufferAddr(), 0, -					InvD[ino].inventoryX + (width/2)+NM_BG_POS_X, InvD[ino].inventoryY + NM_TOFF, +					g_InvD[g_ino].inventoryX + (width/2)+NM_BG_POS_X, g_InvD[g_ino].inventoryY + NM_TOFF,  					GetTagFontHandle(), TXT_CENTER, 0);  		assert(*title);  		MultiSetZPosition(*title, Z_INV_HTEXT); @@ -2691,13 +2680,13 @@ static OBJECT *AddObject(const FREEL *pfreel, int num) {  	// Horrible bodge involving global variables to save  	// width and/or height of some window frame components -	if (num == TL) { -		TLwidth = FROM_LE_16(pim->imgWidth); -		TLheight = FROM_LE_16(pim->imgHeight) & ~C16_FLAG_MASK; -	} else if (num == TR) { -		TRwidth = FROM_LE_16(pim->imgWidth); -	} else if (num == BL) { -		BLheight = FROM_LE_16(pim->imgHeight) & ~C16_FLAG_MASK; +	if (num == g_TL) { +		g_TLwidth = FROM_LE_16(pim->imgWidth); +		g_TLheight = FROM_LE_16(pim->imgHeight) & ~C16_FLAG_MASK; +	} else if (num == g_TR) { +		g_TRwidth = FROM_LE_16(pim->imgWidth); +	} else if (num == g_BL) { +		g_BLheight = FROM_LE_16(pim->imgHeight) & ~C16_FLAG_MASK;  	}  	// Set up and insert the multi-object @@ -2712,9 +2701,9 @@ static OBJECT *AddObject(const FREEL *pfreel, int num) {   */  static void AddSlider(OBJECT **slide, const FILM *pfilm) { -	SlideObject = *slide = AddObject(&pfilm->reels[IX_SLIDE], -1); -	MultiSetAniXY(*slide, MultiRightmost(RectObject) + (TinselV2 ? NM_SLX : -M_SXOFF + 2) - 1, -		InvD[ino].inventoryY + sliderYpos); +	g_SlideObject = *slide = AddObject(&pfilm->reels[IX_SLIDE], -1); +	MultiSetAniXY(*slide, MultiRightmost(g_RectObject) + (TinselV2 ? NM_SLX : -M_SXOFF + 2) - 1, +		g_InvD[g_ino].inventoryY + g_sliderYpos);  	MultiSetZPosition(*slide, Z_INV_MFRAME);  } @@ -2722,8 +2711,8 @@ static void AddSlider(OBJECT **slide, const FILM *pfilm) {   * Display a box with some text in it.   */  static void AddBox(int *pi, const int i) { -	int x	= InvD[ino].inventoryX + cd.box[i].xpos; -	int y	= InvD[ino].inventoryY + cd.box[i].ypos; +	int x	= g_InvD[g_ino].inventoryX + cd.box[i].xpos; +	int y	= g_InvD[g_ino].inventoryY + cd.box[i].ypos;  	int *pival = cd.box[i].ival;  	int	xdisp;  	const FILM *pFilm; @@ -2735,11 +2724,11 @@ static void AddBox(int *pi, const int i) {  			break;  		// Give us a box -		iconArray[*pi] = RectangleObject(BgPal(), TinselV2 ? BoxColor() : COL_BOX, +		g_iconArray[*pi] = RectangleObject(BgPal(), TinselV2 ? BoxColor() : COL_BOX,  			cd.box[i].w, cd.box[i].h); -		MultiInsertObject(GetPlayfieldList(FIELD_STATUS), iconArray[*pi]); -		MultiSetAniXY(iconArray[*pi], x, y); -		MultiSetZPosition(iconArray[*pi], Z_INV_BRECT + 1); +		MultiInsertObject(GetPlayfieldList(FIELD_STATUS), g_iconArray[*pi]); +		MultiSetAniXY(g_iconArray[*pi], x, y); +		MultiSetZPosition(g_iconArray[*pi], Z_INV_BRECT + 1);  		*pi += 1;  		// Stick in the text @@ -2747,14 +2736,14 @@ static void AddBox(int *pi, const int i) {  				(!TinselV2 && (cd.box[i].ixText == USE_POINTER))) {  			if (cd.box[i].boxText != NULL) {  				if (cd.box[i].boxType == RGROUP) { -					iconArray[*pi] = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), cd.box[i].boxText, 0, +					g_iconArray[*pi] = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), cd.box[i].boxText, 0,  #ifdef JAPAN  							x + 2, y+2, GetTagFontHandle(), 0);  #else  							x + 2, y + TYOFF, GetTagFontHandle(), 0);  #endif  				} else { -					iconArray[*pi] = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), cd.box[i].boxText, 0, +					g_iconArray[*pi] = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), cd.box[i].boxText, 0,  #ifdef JAPAN  // Note: it never seems to go here!  							x + cd.box[i].w/2, y+2, GetTagFontHandle(), TXT_CENTER); @@ -2763,7 +2752,7 @@ static void AddBox(int *pi, const int i) {  #endif  				} -				MultiSetZPosition(iconArray[*pi], Z_INV_ITEXT); +				MultiSetZPosition(g_iconArray[*pi], Z_INV_ITEXT);  				*pi += 1;  			}  		} else { @@ -2775,61 +2764,61 @@ static void AddBox(int *pi, const int i) {  					LoadStringRes(cd.box[i].ixText, TextBufferAddr(), TBUFSZ);  				}  			} else { -				LoadStringRes(configStrings[cd.box[i].ixText], TextBufferAddr(), TBUFSZ); +				LoadStringRes(g_configStrings[cd.box[i].ixText], TextBufferAddr(), TBUFSZ);  				assert(cd.box[i].boxType != RGROUP); // You'll need to add some code!  			}  			if (TinselV2 && (cd.box[i].boxType == RGROUP)) -				iconArray[*pi] = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), TextBufferAddr(), +				g_iconArray[*pi] = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), TextBufferAddr(),  						0, x + 2, y + TYOFF, GetTagFontHandle(), 0, 0);  			else -				iconArray[*pi] = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), +				g_iconArray[*pi] = ObjectTextOut(GetPlayfieldList(FIELD_STATUS),  					TextBufferAddr(), 0,  #ifdef JAPAN  					x + cd.box[i].w/2, y+2, GetTagFontHandle(), TXT_CENTER);  #else  					x + cd.box[i].w / 2, y + TYOFF, GetTagFontHandle(), TXT_CENTER);  #endif -			MultiSetZPosition(iconArray[*pi], Z_INV_ITEXT); +			MultiSetZPosition(g_iconArray[*pi], Z_INV_ITEXT);  			*pi += 1;  		}  		break;  	case AAGBUT:  	case ARSGBUT: -		pFilm = (const FILM *)LockMem(hWinParts); +		pFilm = (const FILM *)LockMem(g_hWinParts); -		iconArray[*pi] = AddObject(&pFilm->reels[cd.box[i].bi + NORMGRAPH], -1); -		MultiSetAniXY(iconArray[*pi], x, y); -		MultiSetZPosition(iconArray[*pi], Z_INV_BRECT + 1); +		g_iconArray[*pi] = AddObject(&pFilm->reels[cd.box[i].bi + NORMGRAPH], -1); +		MultiSetAniXY(g_iconArray[*pi], x, y); +		MultiSetZPosition(g_iconArray[*pi], Z_INV_BRECT + 1);  		*pi += 1;  		break;  	case FRGROUP: -		assert(flagFilm != 0); // Language flags not declared! +		assert(g_flagFilm != 0); // Language flags not declared! -		pFilm = (const FILM *)LockMem(flagFilm); +		pFilm = (const FILM *)LockMem(g_flagFilm);  		if (_vm->_config->_isAmericanEnglishVersion && cd.box[i].bi == FIX_UK)  			cd.box[i].bi = FIX_USA; -		iconArray[*pi] = AddObject(&pFilm->reels[cd.box[i].bi], -1); -		MultiSetAniXY(iconArray[*pi], x, y); -		MultiSetZPosition(iconArray[*pi], Z_INV_BRECT+2); +		g_iconArray[*pi] = AddObject(&pFilm->reels[cd.box[i].bi], -1); +		MultiSetAniXY(g_iconArray[*pi], x, y); +		MultiSetZPosition(g_iconArray[*pi], Z_INV_BRECT+2);  		*pi += 1;  		break;  	case FLIP: -		pFilm = (const FILM *)LockMem(hWinParts); +		pFilm = (const FILM *)LockMem(g_hWinParts);  		if (*pival) -			iconArray[*pi] = AddObject(&pFilm->reels[cd.box[i].bi], -1); +			g_iconArray[*pi] = AddObject(&pFilm->reels[cd.box[i].bi], -1);  		else -			iconArray[*pi] = AddObject(&pFilm->reels[cd.box[i].bi+1], -1); -		MultiSetAniXY(iconArray[*pi], x, y); -		MultiSetZPosition(iconArray[*pi], Z_INV_BRECT+1); +			g_iconArray[*pi] = AddObject(&pFilm->reels[cd.box[i].bi+1], -1); +		MultiSetAniXY(g_iconArray[*pi], x, y); +		MultiSetZPosition(g_iconArray[*pi], Z_INV_BRECT+1);  		*pi += 1;  		// Stick in the text @@ -2838,23 +2827,23 @@ static void AddBox(int *pi, const int i) {  			LoadStringRes(SysString(cd.box[i].ixText), TextBufferAddr(), TBUFSZ);  		} else {  			assert(cd.box[i].ixText != USE_POINTER); -			LoadStringRes(configStrings[cd.box[i].ixText], TextBufferAddr(), TBUFSZ); +			LoadStringRes(g_configStrings[cd.box[i].ixText], TextBufferAddr(), TBUFSZ);  		} -		iconArray[*pi] = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), +		g_iconArray[*pi] = ObjectTextOut(GetPlayfieldList(FIELD_STATUS),  			TextBufferAddr(), 0, x + MDTEXT_XOFF, y + MDTEXT_YOFF, GetTagFontHandle(), TXT_RIGHT); -		MultiSetZPosition(iconArray[*pi], Z_INV_ITEXT); +		MultiSetZPosition(g_iconArray[*pi], Z_INV_ITEXT);  		*pi += 1;  		break;  	case TOGGLE:  	case TOGGLE1:  	case TOGGLE2: -		pFilm = (const FILM *)LockMem(hWinParts); +		pFilm = (const FILM *)LockMem(g_hWinParts);  		cd.box[i].bi = *pival ? IX_TICK1 : IX_CROSS1; -		iconArray[*pi] = AddObject(&pFilm->reels[cd.box[i].bi + NORMGRAPH], -1); -		MultiSetAniXY(iconArray[*pi], x, y); -		MultiSetZPosition(iconArray[*pi], Z_INV_BRECT+1); +		g_iconArray[*pi] = AddObject(&pFilm->reels[cd.box[i].bi + NORMGRAPH], -1); +		MultiSetAniXY(g_iconArray[*pi], x, y); +		MultiSetZPosition(g_iconArray[*pi], Z_INV_BRECT+1);  		*pi += 1;  		// Stick in the text @@ -2863,39 +2852,39 @@ static void AddBox(int *pi, const int i) {  			LoadStringRes(SysString(cd.box[i].ixText), TextBufferAddr(), TBUFSZ);  		} else {  			assert(cd.box[i].ixText != USE_POINTER); -			LoadStringRes(configStrings[cd.box[i].ixText], TextBufferAddr(), TBUFSZ); +			LoadStringRes(g_configStrings[cd.box[i].ixText], TextBufferAddr(), TBUFSZ);  		}  		if (cd.box[i].boxType == TOGGLE2) { -			iconArray[*pi] = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), +			g_iconArray[*pi] = ObjectTextOut(GetPlayfieldList(FIELD_STATUS),  				TextBufferAddr(), 0, x + cd.box[i].w / 2, y + TOG2_YOFF,  				GetTagFontHandle(), TXT_CENTER, 0);  		} else { -			iconArray[*pi] = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), +			g_iconArray[*pi] = ObjectTextOut(GetPlayfieldList(FIELD_STATUS),  				TextBufferAddr(), 0, x + MDTEXT_XOFF, y + MDTEXT_YOFF,  				GetTagFontHandle(), TXT_RIGHT, 0);  		} -		MultiSetZPosition(iconArray[*pi], Z_INV_ITEXT); +		MultiSetZPosition(g_iconArray[*pi], Z_INV_ITEXT);  		*pi += 1;  		break;  	case SLIDER: -		pFilm = (const FILM *)LockMem(hWinParts); +		pFilm = (const FILM *)LockMem(g_hWinParts);  		xdisp = SLIDE_RANGE*(*pival)/cd.box[i].w; -		iconArray[*pi] = AddObject(&pFilm->reels[IX_MDGROOVE], -1); -		MultiSetAniXY(iconArray[*pi], x, y); -		MultiSetZPosition(iconArray[*pi], Z_MDGROOVE); +		g_iconArray[*pi] = AddObject(&pFilm->reels[IX_MDGROOVE], -1); +		MultiSetAniXY(g_iconArray[*pi], x, y); +		MultiSetZPosition(g_iconArray[*pi], Z_MDGROOVE);  		*pi += 1; -		iconArray[*pi] = AddObject(&pFilm->reels[IX_MDSLIDER], -1); -		MultiSetAniXY(iconArray[*pi], x+SLIDE_MINX+xdisp, y); -		MultiSetZPosition(iconArray[*pi], Z_MDSLIDER); -		assert(numMdSlides < MAXSLIDES); -		mdSlides[numMdSlides].num = i; -		mdSlides[numMdSlides].min = x + SLIDE_MINX; -		mdSlides[numMdSlides].max = x + SLIDE_MAXX; -		mdSlides[numMdSlides++].obj = iconArray[*pi]; +		g_iconArray[*pi] = AddObject(&pFilm->reels[IX_MDSLIDER], -1); +		MultiSetAniXY(g_iconArray[*pi], x+SLIDE_MINX+xdisp, y); +		MultiSetZPosition(g_iconArray[*pi], Z_MDSLIDER); +		assert(g_numMdSlides < MAXSLIDES); +		g_mdSlides[g_numMdSlides].num = i; +		g_mdSlides[g_numMdSlides].min = x + SLIDE_MINX; +		g_mdSlides[g_numMdSlides].max = x + SLIDE_MAXX; +		g_mdSlides[g_numMdSlides++].obj = g_iconArray[*pi];  		*pi += 1;  		// Stick in the text @@ -2904,55 +2893,55 @@ static void AddBox(int *pi, const int i) {  			LoadStringRes(SysString(cd.box[i].ixText), TextBufferAddr(), TBUFSZ);  		} else {  			assert(cd.box[i].ixText != USE_POINTER); -			LoadStringRes(configStrings[cd.box[i].ixText], TextBufferAddr(), TBUFSZ); +			LoadStringRes(g_configStrings[cd.box[i].ixText], TextBufferAddr(), TBUFSZ);  		} -		iconArray[*pi] = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), +		g_iconArray[*pi] = ObjectTextOut(GetPlayfieldList(FIELD_STATUS),  			TextBufferAddr(), 0, x+MDTEXT_XOFF, y+MDTEXT_YOFF, GetTagFontHandle(), TXT_RIGHT); -		MultiSetZPosition(iconArray[*pi], Z_INV_ITEXT); +		MultiSetZPosition(g_iconArray[*pi], Z_INV_ITEXT);  		*pi += 1;  		break;  	case ROTATE: -		pFilm = (const FILM *)LockMem(hWinParts); +		pFilm = (const FILM *)LockMem(g_hWinParts);  		// Left one -		if (!bNoLanguage) { -			iconArray[*pi] = AddObject(&pFilm->reels[IX2_LEFT1], -1); -			MultiSetAniXY(iconArray[*pi], x-ROTX1, y); -			MultiSetZPosition(iconArray[*pi], Z_INV_BRECT + 1); +		if (!g_bNoLanguage) { +			g_iconArray[*pi] = AddObject(&pFilm->reels[IX2_LEFT1], -1); +			MultiSetAniXY(g_iconArray[*pi], x-ROTX1, y); +			MultiSetZPosition(g_iconArray[*pi], Z_INV_BRECT + 1);  			*pi += 1;  			// Right one -			iconArray[*pi] = AddObject( &pFilm->reels[IX2_RIGHT1], -1); -			MultiSetAniXY(iconArray[*pi], x + ROTX1, y); -			MultiSetZPosition(iconArray[*pi], Z_INV_BRECT + 1); +			g_iconArray[*pi] = AddObject( &pFilm->reels[IX2_RIGHT1], -1); +			MultiSetAniXY(g_iconArray[*pi], x + ROTX1, y); +			MultiSetZPosition(g_iconArray[*pi], Z_INV_BRECT + 1);  			*pi += 1;  			// Stick in the text  			assert(cd.box[i].textMethod == TM_INDEX);  			LoadStringRes(SysString(cd.box[i].ixText), TextBufferAddr(), TBUFSZ); -			iconArray[*pi] = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), +			g_iconArray[*pi] = ObjectTextOut(GetPlayfieldList(FIELD_STATUS),  				TextBufferAddr(), 0, x + cd.box[i].w / 2, y + TOG2_YOFF,  				GetTagFontHandle(), TXT_CENTER, 0); -			MultiSetZPosition(iconArray[*pi], Z_INV_ITEXT); +			MultiSetZPosition(g_iconArray[*pi], Z_INV_ITEXT);  			*pi += 1;  		}  		// Current language's text -		if (LanguageDesc(displayedLanguage) == 0) +		if (LanguageDesc(g_displayedLanguage) == 0)  			break; -		LoadStringRes(LanguageDesc(displayedLanguage), TextBufferAddr(), TBUFSZ); -		iconArray[*pi] = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), TextBufferAddr(), 0, +		LoadStringRes(LanguageDesc(g_displayedLanguage), TextBufferAddr(), TBUFSZ); +		g_iconArray[*pi] = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), TextBufferAddr(), 0,  				x + cd.box[i].w / 2, y + ROT_YOFF, GetTagFontHandle(), TXT_CENTER, 0); -		MultiSetZPosition(iconArray[*pi], Z_INV_ITEXT); +		MultiSetZPosition(g_iconArray[*pi], Z_INV_ITEXT);  		*pi += 1;  		// Current language's flag -		pFilm = (const FILM *)LockMem(LanguageFlag(displayedLanguage)); -		iconArray[*pi] = AddObject(&pFilm->reels[0], -1); -		MultiSetAniXY(iconArray[*pi], x + FLAGX, y + FLAGY); -		MultiSetZPosition(iconArray[*pi], Z_INV_BRECT + 1); +		pFilm = (const FILM *)LockMem(LanguageFlag(g_displayedLanguage)); +		g_iconArray[*pi] = AddObject(&pFilm->reels[0], -1); +		MultiSetAniXY(g_iconArray[*pi], x + FLAGX, y + FLAGY); +		MultiSetZPosition(g_iconArray[*pi], Z_INV_BRECT + 1);  		*pi += 1;  		break;  	} @@ -2965,7 +2954,7 @@ static void AddBoxes(bool bPosnSlide) {  	int	objCount = NUMHL;	// Object count - allow for HL1, HL2 etc.  	DumpIconArray(); -	numMdSlides = 0; +	g_numMdSlides = 0;  	for (int i = 0; i < cd.NumBoxes; i++) {  		AddBox(&objCount, i); @@ -2973,32 +2962,32 @@ static void AddBoxes(bool bPosnSlide) {  	if (cd.bExtraWin) {  		if (bPosnSlide && !TinselV2) -			sliderYpos = sliderYmin + (cd.extraBase*(sliderYmax-sliderYmin))/(MAX_SAVED_FILES-NUM_RGROUP_BOXES); +			g_sliderYpos = g_sliderYmin + (cd.extraBase*(g_sliderYmax-g_sliderYmin))/(MAX_SAVED_FILES-NUM_RGROUP_BOXES);  		else if (bPosnSlide) {  			// Tinsel 2 bPosnSlide code -			int lastY = sliderYpos; +			int lastY = g_sliderYpos;  			if (cd.box == loadBox || cd.box == saveBox) -				sliderYpos = sliderYmin + (cd.extraBase * (sliderRange)) / +				g_sliderYpos = g_sliderYmin + (cd.extraBase * (sliderRange)) /  				(MAX_SAVED_FILES - NUM_RGROUP_BOXES);  			else if (cd.box == hopperBox1) { -				if (numScenes <= NUM_RGROUP_BOXES) -					sliderYpos = sliderYmin; +				if (g_numScenes <= NUM_RGROUP_BOXES) +					g_sliderYpos = g_sliderYmin;  				else -					sliderYpos = sliderYmin + (cd.extraBase*(sliderRange))/(numScenes-NUM_RGROUP_BOXES); +					g_sliderYpos = g_sliderYmin + (cd.extraBase*(sliderRange))/(g_numScenes-NUM_RGROUP_BOXES);  			} else if (cd.box == hopperBox2) { -				if (numEntries <= NUM_RGROUP_BOXES) -					sliderYpos = sliderYmin; +				if (g_numEntries <= NUM_RGROUP_BOXES) +					g_sliderYpos = g_sliderYmin;  				else -					sliderYpos = sliderYmin + (cd.extraBase * (sliderRange)) / -					(numEntries-NUM_RGROUP_BOXES); +					g_sliderYpos = g_sliderYmin + (cd.extraBase * (sliderRange)) / +					(g_numEntries-NUM_RGROUP_BOXES);  			} -			MultiMoveRelXY(SlideObject, 0, sliderYpos - lastY); +			MultiMoveRelXY(g_SlideObject, 0, g_sliderYpos - lastY);  		}  		if (!TinselV2) -			MultiSetAniXY(SlideObject, InvD[ino].inventoryX + 24 + 179, sliderYpos); +			MultiSetAniXY(g_SlideObject, g_InvD[g_ino].inventoryX + 24 + 179, g_sliderYpos);  	}  	assert(objCount < MAX_ICONS); // added too many icons @@ -3008,8 +2997,8 @@ static void AddBoxes(bool bPosnSlide) {   * Display the scroll bar slider.   */  static void AddEWSlider(OBJECT **slide, const FILM *pfilm) { -	SlideObject = *slide = AddObject(&pfilm->reels[IX_SLIDE], -1); -	MultiSetAniXY(*slide, InvD[ino].inventoryX + 24 + 127, sliderYpos); +	g_SlideObject = *slide = AddObject(&pfilm->reels[IX_SLIDE], -1); +	MultiSetAniXY(*slide, g_InvD[g_ino].inventoryX + 24 + 127, g_sliderYpos);  	MultiSetZPosition(*slide, Z_INV_MFRAME);  } @@ -3021,7 +3010,7 @@ static int AddExtraWindow(int x, int y, OBJECT **retObj) {  	const FILM *pfilm;  	// Get the frame's data -	pfilm = (const FILM *)LockMem(hWinParts); +	pfilm = (const FILM *)LockMem(g_hWinParts);  	x += TinselV2 ? 30 : 20;  	y += TinselV2 ? 38 : 24; @@ -3032,56 +3021,56 @@ static int AddExtraWindow(int x, int y, OBJECT **retObj) {  	MultiSetZPosition(retObj[n], Z_INV_MFRAME);  	n++;  	retObj[n] = AddObject(&pfilm->reels[IX_NTR], -1);	// Top right -	MultiSetAniXY(retObj[n], x + (TinselV2 ? TLwidth + 312 : 152), y); +	MultiSetAniXY(retObj[n], x + (TinselV2 ? g_TLwidth + 312 : 152), y);  	MultiSetZPosition(retObj[n], Z_INV_MFRAME);  	n++;  	retObj[n] = AddObject(&pfilm->reels[IX_BL], -1);	// Bottom left -	MultiSetAniXY(retObj[n], x, y + (TinselV2 ? TLheight + 208 : 124)); +	MultiSetAniXY(retObj[n], x, y + (TinselV2 ? g_TLheight + 208 : 124));  	MultiSetZPosition(retObj[n], Z_INV_MFRAME);  	n++;  	retObj[n] = AddObject(&pfilm->reels[IX_BR], -1);	// Bottom right -	MultiSetAniXY(retObj[n], x + (TinselV2 ? TLwidth + 312 : 152), -		y + (TinselV2 ? TLheight + 208 : 124)); +	MultiSetAniXY(retObj[n], x + (TinselV2 ? g_TLwidth + 312 : 152), +		y + (TinselV2 ? g_TLheight + 208 : 124));  	MultiSetZPosition(retObj[n], Z_INV_MFRAME);  	n++;  	// Draw the edges  	retObj[n] = AddObject(&pfilm->reels[IX_H156], -1);	// Top -	MultiSetAniXY(retObj[n], x + (TinselV2 ? TLwidth : 6), y + NM_TBT); +	MultiSetAniXY(retObj[n], x + (TinselV2 ? g_TLwidth : 6), y + NM_TBT);  	MultiSetZPosition(retObj[n], Z_INV_MFRAME);  	n++;  	retObj[n] = AddObject(&pfilm->reels[IX_H156], -1);	// Bottom -	MultiSetAniXY(retObj[n], x + (TinselV2 ? TLwidth : 6), y + -		(TinselV2 ? TLheight + 208 + BLheight + NM_BSY : 143)); +	MultiSetAniXY(retObj[n], x + (TinselV2 ? g_TLwidth : 6), y + +		(TinselV2 ? g_TLheight + 208 + g_BLheight + NM_BSY : 143));  	MultiSetZPosition(retObj[n], Z_INV_MFRAME);  	n++;  	retObj[n] = AddObject(&pfilm->reels[IX_V104], -1);	// Left -	MultiSetAniXY(retObj[n], x + NM_LSX, y + (TinselV2 ? TLheight : 20)); +	MultiSetAniXY(retObj[n], x + NM_LSX, y + (TinselV2 ? g_TLheight : 20));  	MultiSetZPosition(retObj[n], Z_INV_MFRAME);  	n++;  	retObj[n] = AddObject(&pfilm->reels[IX_V104], -1);	// Right 1 -	MultiSetAniXY(retObj[n], x + (TinselV2 ? TLwidth + 312 + TRwidth + NM_RSX : 179), -		y + (TinselV2 ? TLheight : 20)); +	MultiSetAniXY(retObj[n], x + (TinselV2 ? g_TLwidth + 312 + g_TRwidth + NM_RSX : 179), +		y + (TinselV2 ? g_TLheight : 20));  	MultiSetZPosition(retObj[n], Z_INV_MFRAME);  	n++;  	retObj[n] = AddObject(&pfilm->reels[IX_V104], -1);	// Right 2 -	MultiSetAniXY(retObj[n], x + (TinselV2 ? TLwidth + 312 + TRwidth + NM_SBL : 188), -		y + (TinselV2 ? TLheight : 20)); +	MultiSetAniXY(retObj[n], x + (TinselV2 ? g_TLwidth + 312 + g_TRwidth + NM_SBL : 188), +		y + (TinselV2 ? g_TLheight : 20));  	MultiSetZPosition(retObj[n], Z_INV_MFRAME);  	n++;  	if (TinselV2) { -		sliderYpos = sliderYmin = y + 27; -		sliderYmax = y + 273; - -		retObj[n++] = SlideObject = AddObject( &pfilm->reels[IX_SLIDE], -1); -		MultiSetAniXY(SlideObject, -			x + TLwidth + 320 + TRwidth - NM_BG_POS_X + NM_BG_SIZ_X - 2, -			sliderYpos); -		MultiSetZPosition(SlideObject, Z_INV_MFRAME); +		g_sliderYpos = g_sliderYmin = y + 27; +		g_sliderYmax = y + 273; + +		retObj[n++] = g_SlideObject = AddObject( &pfilm->reels[IX_SLIDE], -1); +		MultiSetAniXY(g_SlideObject, +			x + g_TLwidth + 320 + g_TRwidth - NM_BG_POS_X + NM_BG_SIZ_X - 2, +			g_sliderYpos); +		MultiSetZPosition(g_SlideObject, Z_INV_MFRAME);  	} else { -		sliderYpos = sliderYmin = y + 9; -		sliderYmax = y + 134; +		g_sliderYpos = g_sliderYmin = y + 9; +		g_sliderYmax = y + 134;  		AddEWSlider(&retObj[n++], pfilm);  	} @@ -3099,17 +3088,17 @@ static void ConstructInventory(InventoryType filling) {  	int	eH, eV;		// Extra width and height  	int	n = 0;		// Index into object array  	int	zpos;		// Z-position of frame -	int	invX = InvD[ino].inventoryX; -	int	invY = InvD[ino].inventoryY; +	int	invX = g_InvD[g_ino].inventoryX; +	int	invY = g_InvD[g_ino].inventoryY;  	OBJECT **retObj;  	const FILM *pfilm;  	// Select the object array to use  	if (filling == FULL || filling == CONF) { -		retObj = objArray;		// Standard window +		retObj = g_objArray;		// Standard window  		zpos = Z_INV_MFRAME;  	} else { -		retObj = DobjArray;		// Re-sizing window +		retObj = g_DobjArray;		// Re-sizing window  		zpos = Z_INV_RFRAME;  	} @@ -3122,83 +3111,83 @@ static void ConstructInventory(InventoryType filling) {  	}  	// Get the frame's data -	pfilm = (const FILM *)LockMem(hWinParts); +	pfilm = (const FILM *)LockMem(g_hWinParts);  	// Standard window is of granular dimensions  	if (filling == FULL) {  		// Round-up/down to nearest number of icons -		if (SuppH > ITEM_WIDTH / 2) -			InvD[ino].NoofHicons++; -		if (SuppV > ITEM_HEIGHT / 2) -			InvD[ino].NoofVicons++; -		SuppH = SuppV = 0; +		if (g_SuppH > ITEM_WIDTH / 2) +			g_InvD[g_ino].NoofHicons++; +		if (g_SuppV > ITEM_HEIGHT / 2) +			g_InvD[g_ino].NoofVicons++; +		g_SuppH = g_SuppV = 0;  	}  	// Extra width and height -	eH = (InvD[ino].NoofHicons - 1) * (ITEM_WIDTH+I_SEPARATION) + SuppH; -	eV = (InvD[ino].NoofVicons - 1) * (ITEM_HEIGHT+I_SEPARATION) + SuppV; +	eH = (g_InvD[g_ino].NoofHicons - 1) * (ITEM_WIDTH+I_SEPARATION) + g_SuppH; +	eV = (g_InvD[g_ino].NoofVicons - 1) * (ITEM_HEIGHT+I_SEPARATION) + g_SuppV;  	// Which window frame corners to use -	if (TinselV2 && (ino == INV_CONV)) { -		TL = IX_TL; -		TR = IX2_TR4; -		BL = IX_BL; -		BR = IX_RBR; -	} else if ((filling == FULL) && (ino != INV_CONV)) { -		TL = IX_TL; -		TR = IX_TR; -		BL = IX_BL; -		BR = IX_BR; +	if (TinselV2 && (g_ino == INV_CONV)) { +		g_TL = IX_TL; +		g_TR = IX2_TR4; +		g_BL = IX_BL; +		g_BR = IX_RBR; +	} else if ((filling == FULL) && (g_ino != INV_CONV)) { +		g_TL = IX_TL; +		g_TR = IX_TR; +		g_BL = IX_BL; +		g_BR = IX_BR;  	} else { -		TL = IX_RTL; -		TR = IX_RTR; -		BL = IX_BL; -		BR = IX_RBR; +		g_TL = IX_RTL; +		g_TR = IX_RTR; +		g_BL = IX_BL; +		g_BR = IX_RBR;  	}  	// Draw the four corners -	retObj[n] = AddObject(&pfilm->reels[TL], TL); +	retObj[n] = AddObject(&pfilm->reels[g_TL], g_TL);  	MultiSetAniXY(retObj[n], invX, invY);  	MultiSetZPosition(retObj[n], zpos);  	n++; -	retObj[n] = AddObject(&pfilm->reels[TR], TR); -	MultiSetAniXY(retObj[n], invX + TLwidth + eH, invY); +	retObj[n] = AddObject(&pfilm->reels[g_TR], g_TR); +	MultiSetAniXY(retObj[n], invX + g_TLwidth + eH, invY);  	MultiSetZPosition(retObj[n], zpos);  	n++; -	retObj[n] = AddObject(&pfilm->reels[BL], BL); -	MultiSetAniXY(retObj[n], invX, invY + TLheight + eV); +	retObj[n] = AddObject(&pfilm->reels[g_BL], g_BL); +	MultiSetAniXY(retObj[n], invX, invY + g_TLheight + eV);  	MultiSetZPosition(retObj[n], zpos);  	n++; -	retObj[n] = AddObject(&pfilm->reels[BR], BR); -	MultiSetAniXY(retObj[n], invX + TLwidth + eH, invY + TLheight + eV); +	retObj[n] = AddObject(&pfilm->reels[g_BR], g_BR); +	MultiSetAniXY(retObj[n], invX + g_TLwidth + eH, invY + g_TLheight + eV);  	MultiSetZPosition(retObj[n], zpos);  	n++;  	// Draw extra Top and bottom parts -	if (InvD[ino].NoofHicons > 1) { +	if (g_InvD[g_ino].NoofHicons > 1) {  		// Top side -		retObj[n] = AddObject(&pfilm->reels[hFillers[InvD[ino].NoofHicons-2]], -1); -		MultiSetAniXY(retObj[n], invX + TLwidth, invY + NM_TBT); +		retObj[n] = AddObject(&pfilm->reels[hFillers[g_InvD[g_ino].NoofHicons-2]], -1); +		MultiSetAniXY(retObj[n], invX + g_TLwidth, invY + NM_TBT);  		MultiSetZPosition(retObj[n], zpos);  		n++;  		// Bottom of header box  		if (filling == FULL) {  			if (TinselV2) { -				retObj[n] = AddObject(&pfilm->reels[hFillers[InvD[ino].NoofHicons-2]], -1); -				MultiSetAniXY(retObj[n], invX + TLwidth, invY + NM_TBB); +				retObj[n] = AddObject(&pfilm->reels[hFillers[g_InvD[g_ino].NoofHicons-2]], -1); +				MultiSetAniXY(retObj[n], invX + g_TLwidth, invY + NM_TBB);  				MultiSetZPosition(retObj[n], zpos);  				n++;  			} else { -				retObj[n] = AddObject(&pfilm->reels[hFillers[InvD[ino].NoofHicons-2]], -1); -				MultiSetAniXY(retObj[n], invX + TLwidth, invY + M_TBB + 1); +				retObj[n] = AddObject(&pfilm->reels[hFillers[g_InvD[g_ino].NoofHicons-2]], -1); +				MultiSetAniXY(retObj[n], invX + g_TLwidth, invY + M_TBB + 1);  				MultiSetZPosition(retObj[n], zpos);  				n++;  				// Extra bits for conversation - hopefully temporary -				if (ino == INV_CONV) { +				if (g_ino == INV_CONV) {  					retObj[n] = AddObject(&pfilm->reels[IX_H26], -1); -					MultiSetAniXY(retObj[n], invX + TLwidth - 2, invY + M_TBB + 1); +					MultiSetAniXY(retObj[n], invX + g_TLwidth - 2, invY + M_TBB + 1);  					MultiSetZPosition(retObj[n], zpos);  					n++; @@ -3211,16 +3200,16 @@ static void ConstructInventory(InventoryType filling) {  		}  		// Bottom side -		retObj[n] = AddObject(&pfilm->reels[hFillers[InvD[ino].NoofHicons-2]], -1); -		MultiSetAniXY(retObj[n], invX + TLwidth, invY + TLheight + eV + BLheight + NM_BSY); +		retObj[n] = AddObject(&pfilm->reels[hFillers[g_InvD[g_ino].NoofHicons-2]], -1); +		MultiSetAniXY(retObj[n], invX + g_TLwidth, invY + g_TLheight + eV + g_BLheight + NM_BSY);  		MultiSetZPosition(retObj[n], zpos);  		n++;  	} -	if (SuppH) { -		int offx = TLwidth + eH - (TinselV2 ? ITEM_WIDTH + I_SEPARATION : 26); -		if (offx < TLwidth)	// Not too far! -			offx = TLwidth; +	if (g_SuppH) { +		int offx = g_TLwidth + eH - (TinselV2 ? ITEM_WIDTH + I_SEPARATION : 26); +		if (offx < g_TLwidth)	// Not too far! +			offx = g_TLwidth;  		// Top side extra  		retObj[n] = AddObject(&pfilm->reels[IX_H26], -1); @@ -3230,39 +3219,39 @@ static void ConstructInventory(InventoryType filling) {  		// Bottom side extra  		retObj[n] = AddObject(&pfilm->reels[IX_H26], -1); -		MultiSetAniXY(retObj[n], invX + offx, invY + TLheight + eV + BLheight + NM_BSY); +		MultiSetAniXY(retObj[n], invX + offx, invY + g_TLheight + eV + g_BLheight + NM_BSY);  		MultiSetZPosition(retObj[n], zpos);  		n++;  	}  	// Draw extra side parts -	if (InvD[ino].NoofVicons > 1) { +	if (g_InvD[g_ino].NoofVicons > 1) {  		// Left side -		retObj[n] = AddObject(&pfilm->reels[vFillers[InvD[ino].NoofVicons-2]], -1); -		MultiSetAniXY(retObj[n], invX + NM_LSX, invY + TLheight); +		retObj[n] = AddObject(&pfilm->reels[vFillers[g_InvD[g_ino].NoofVicons-2]], -1); +		MultiSetAniXY(retObj[n], invX + NM_LSX, invY + g_TLheight);  		MultiSetZPosition(retObj[n], zpos);  		n++;  		// Left side of scroll bar -		if (filling == FULL && ino != INV_CONV) { -			retObj[n] = AddObject(&pfilm->reels[vFillers[InvD[ino].NoofVicons-2]], -1); +		if (filling == FULL && g_ino != INV_CONV) { +			retObj[n] = AddObject(&pfilm->reels[vFillers[g_InvD[g_ino].NoofVicons-2]], -1);  			if (TinselV2) -				MultiSetAniXY(retObj[n], invX + TLwidth + eH + TRwidth + NM_SBL, invY + TLheight); +				MultiSetAniXY(retObj[n], invX + g_TLwidth + eH + g_TRwidth + NM_SBL, invY + g_TLheight);  			else -				MultiSetAniXY(retObj[n], invX + TLwidth + eH + M_SBL + 1, invY + TLheight); +				MultiSetAniXY(retObj[n], invX + g_TLwidth + eH + M_SBL + 1, invY + g_TLheight);  			MultiSetZPosition(retObj[n], zpos);  			n++;  		}  		// Right side -		retObj[n] = AddObject(&pfilm->reels[vFillers[InvD[ino].NoofVicons-2]], -1); -		MultiSetAniXY(retObj[n], invX + TLwidth + eH + TRwidth + NM_RSX, invY + TLheight); +		retObj[n] = AddObject(&pfilm->reels[vFillers[g_InvD[g_ino].NoofVicons-2]], -1); +		MultiSetAniXY(retObj[n], invX + g_TLwidth + eH + g_TRwidth + NM_RSX, invY + g_TLheight);  		MultiSetZPosition(retObj[n], zpos);  		n++;  	} -	if (SuppV) { -		int offy = TLheight + eV - (TinselV2 ? ITEM_HEIGHT + I_SEPARATION : 26); +	if (g_SuppV) { +		int offy = g_TLheight + eV - (TinselV2 ? ITEM_HEIGHT + I_SEPARATION : 26);  		int minAmount = TinselV2 ? 20 : 5;  		if (offy < minAmount)  			offy = minAmount; @@ -3275,7 +3264,7 @@ static void ConstructInventory(InventoryType filling) {  		// Right side extra  		retObj[n] = AddObject(&pfilm->reels[IX_V26], -1); -		MultiSetAniXY(retObj[n], invX + TLwidth + eH + TRwidth + NM_RSX, invY + offy); +		MultiSetAniXY(retObj[n], invX + g_TLwidth + eH + g_TRwidth + NM_RSX, invY + offy);  		MultiSetZPosition(retObj[n], zpos);  		n++;  	} @@ -3296,20 +3285,20 @@ static void ConstructInventory(InventoryType filling) {  			AddBackground(rect, title, eH, eV, FROM_HANDLE);  		} -		if (ino == INV_CONV) { -			SlideObject = NULL; +		if (g_ino == INV_CONV) { +			g_SlideObject = NULL;  			if (TinselV2) {  				// !!!!! MAGIC NUMBER ALERT !!!!!  				// Make sure it's big enough for the heading -				if (MultiLeftmost(retObj[n-1]) < InvD[INV_CONV].inventoryX + 10) { -					InvD[INV_CONV].NoofHicons++; +				if (MultiLeftmost(retObj[n-1]) < g_InvD[INV_CONV].inventoryX + 10) { +					g_InvD[INV_CONV].NoofHicons++;  					ConstructInventory(FULL);  				}  			} -		} else if (InvD[ino].NoofItems > InvD[ino].NoofHicons*InvD[ino].NoofVicons) { -			sliderYmin = TLheight - (TinselV2 ? 2 : 1); -			sliderYmax = TLheight + eV + (TinselV2 ? 12 : 10); +		} else if (g_InvD[g_ino].NoofItems > g_InvD[g_ino].NoofHicons*g_InvD[g_ino].NoofVicons) { +			g_sliderYmin = g_TLheight - (TinselV2 ? 2 : 1); +			g_sliderYmax = g_TLheight + eV + (TinselV2 ? 12 : 10);  			AddSlider(&retObj[n++], pfilm);  		} @@ -3333,7 +3322,7 @@ static void ConstructInventory(InventoryType filling) {  	assert(n < MAX_WCOMP); // added more parts than we can handle!  	// Reposition returns true if needs to move -	if (InvD[ino].bMoveable && filling == FULL && RePosition()) { +	if (g_InvD[g_ino].bMoveable && filling == FULL && RePosition()) {  		ConstructInventory(FULL);  	}  } @@ -3348,32 +3337,32 @@ static bool RePosition() {  	int	p;  	bool	bMoveitMoveit = false; -	assert(RectObject); // no recangle object! +	assert(g_RectObject); // no recangle object!  	// Test for off-screen horizontally -	p = MultiLeftmost(RectObject); +	p = MultiLeftmost(g_RectObject);  	if (p > MAXLEFT) {  		// Too far to the right -		InvD[ino].inventoryX += MAXLEFT - p; +		g_InvD[g_ino].inventoryX += MAXLEFT - p;  		bMoveitMoveit = true;			// I like to....  	} else {  		// Too far to the left? -		p = MultiRightmost(RectObject); +		p = MultiRightmost(g_RectObject);  		if (p < MINRIGHT) { -			InvD[ino].inventoryX += MINRIGHT - p; +			g_InvD[g_ino].inventoryX += MINRIGHT - p;  			bMoveitMoveit = true;		// I like to....  		}  	}  	// Test for off-screen vertically -	p = MultiHighest(RectObject); +	p = MultiHighest(g_RectObject);  	if (p < MINTOP) {  		// Too high -		InvD[ino].inventoryY += MINTOP - p; +		g_InvD[g_ino].inventoryY += MINTOP - p;  		bMoveitMoveit = true;			// I like to....  	} else if (p > MAXTOP) {  		// Too low -		InvD[ino].inventoryY += MAXTOP - p; +		g_InvD[g_ino].inventoryY += MAXTOP - p;  		bMoveitMoveit = true;			// I like to....  	} @@ -3393,7 +3382,7 @@ static void AlterCursor(int num) {  	IMAGE *pim;  	// Get pointer to image -	pim = GetImageFromFilm(hWinParts, num, &pfreel); +	pim = GetImageFromFilm(g_hWinParts, num, &pfreel);  	// Poke in the background palette  	pim->hImgPal = TO_LE_32(BgPal()); @@ -3414,7 +3403,7 @@ static void InvCursor(InvCursorFN fn, int CurX, int CurY) {  	bool	restoreMain = false;  	// If currently dragging, don't be messing about with the cursor shape -	if (InvDragging != ID_NONE) +	if (g_InvDragging != ID_NONE)  		return;  	switch (fn) { @@ -3427,7 +3416,7 @@ static void InvCursor(InvCursorFN fn, int CurX, int CurY) {  		area = InvArea(CurX, CurY);  		// Check for POINTED events -		if (ino == INV_CONF) +		if (g_ino == INV_CONF)  			InvBoxes(area == I_BODY, CurX, CurY);  		else  			InvLabels(area == I_BODY, CurX, CurY); @@ -3445,7 +3434,7 @@ static void InvCursor(InvCursorFN fn, int CurX, int CurY) {  		case I_TLEFT:  		case I_BRIGHT: -			if (!InvD[ino].resizable) +			if (!g_InvD[g_ino].resizable)  				restoreMain = true;  			else if (ICursor != IC_DR) {  				AlterCursor(IX_CURDD); @@ -3455,7 +3444,7 @@ static void InvCursor(InvCursorFN fn, int CurX, int CurY) {  		case I_TRIGHT:  		case I_BLEFT: -			if (!InvD[ino].resizable) +			if (!g_InvD[g_ino].resizable)  				restoreMain = true;  			else if (ICursor != IC_UR) {  				AlterCursor(IX_CURDU); @@ -3465,7 +3454,7 @@ static void InvCursor(InvCursorFN fn, int CurX, int CurY) {  		case I_TOP:  		case I_BOTTOM: -			if (!InvD[ino].resizable) { +			if (!g_InvD[g_ino].resizable) {  				restoreMain = true;  				break;  			} @@ -3477,7 +3466,7 @@ static void InvCursor(InvCursorFN fn, int CurX, int CurY) {  		case I_LEFT:  		case I_RIGHT: -			if (!InvD[ino].resizable) +			if (!g_InvD[g_ino].resizable)  				restoreMain = true;  			else if (ICursor != IC_LR) {  				AlterCursor(IX_CURLR); @@ -3516,7 +3505,7 @@ static void InvCursor(InvCursorFN fn, int CurX, int CurY) {  extern void ConvAction(int index) { -	assert(ino == INV_CONV); // not conv. window! +	assert(g_ino == INV_CONV); // not conv. window!  	PMOVER pMover = TinselV2 ? GetMover(GetLeadId()) : NULL;  	switch (index) { @@ -3524,36 +3513,36 @@ extern void ConvAction(int index) {  		return;  	case INV_CLOSEICON: -		thisIcon = -1;	// Postamble +		g_thisIcon = -1;	// Postamble  		break;  	case INV_OPENICON:  		// Store the direction the lead character is facing in when the conversation starts  		if (TinselV2) -			initialDirection = GetMoverDirection(pMover); -		thisIcon = -2;	// Preamble +			g_initialDirection = GetMoverDirection(pMover); +		g_thisIcon = -2;	// Preamble  		break;  	default: -		thisIcon = InvD[ino].contents[index]; +		g_thisIcon = g_InvD[g_ino].contents[index];  		break;  	}  	if (!TinselV2) -		RunPolyTinselCode(thisConvPoly, CONVERSE, PLR_NOEVENT, true); +		RunPolyTinselCode(g_thisConvPoly, CONVERSE, PLR_NOEVENT, true);  	else {  		// If the lead's direction has changed for any reason (such as having broken the  		// fourth wall and talked to the screen), reset back to the original direction  		DIRECTION currDirection = GetMoverDirection(pMover); -		if (currDirection != initialDirection) { -			SetMoverDirection(pMover, initialDirection); +		if (currDirection != g_initialDirection) { +			SetMoverDirection(pMover, g_initialDirection);  			SetMoverStanding(pMover);  		} -		if (thisConvPoly != NOPOLY) -			PolygonEvent(nullContext, thisConvPoly, CONVERSE, 0, false, 0); +		if (g_thisConvPoly != NOPOLY) +			PolygonEvent(nullContext, g_thisConvPoly, CONVERSE, 0, false, 0);  		else -			ActorEvent(nullContext, thisConvActor, CONVERSE, false, 0); +			ActorEvent(nullContext, g_thisConvActor, CONVERSE, false, 0);  	}  } @@ -3566,18 +3555,18 @@ extern void ConvAction(int index) {   * Note: ano may (will probably) be set when it's a polygon.   */  extern void SetConvDetails(CONV_PARAM fn, HPOLYGON hPoly, int ano) { -	thisConvFn = fn; -	thisConvPoly = hPoly; -	thisConvActor = ano; +	g_thisConvFn = fn; +	g_thisConvPoly = hPoly; +	g_thisConvActor = ano; -	bMoveOnUnHide = true; +	g_bMoveOnUnHide = true;  	// Get the Actor Tag's or Tagged Actor's label for the conversation window title  	if (hPoly != NOPOLY)	{  		int x, y; -		GetTagTag(hPoly, &InvD[INV_CONV].hInvTitle, &x, &y); +		GetTagTag(hPoly, &g_InvD[INV_CONV].hInvTitle, &x, &y);  	} else { -		InvD[INV_CONV].hInvTitle = GetActorTagHandle(ano); +		g_InvD[INV_CONV].hInvTitle = GetActorTagHandle(ano);  	}  } @@ -3590,27 +3579,27 @@ extern void PermaConvIcon(int icon, bool bEnd) {  	int i;  	// See if it's already there -	for (i = 0; i < numPermIcons; i++) { -		if (permIcons[i] == icon) +	for (i = 0; i < g_numPermIcons; i++) { +		if (g_permIcons[i] == icon)  			break;  	}  	// Add it if it isn't already there -	if (i == numPermIcons) { -		assert(numPermIcons < MAX_PERMICONS); +	if (i == g_numPermIcons) { +		assert(g_numPermIcons < MAX_PERMICONS); -		if (bEnd || !numEndIcons) { +		if (bEnd || !g_numEndIcons) {  			// Add it at the end -			permIcons[numPermIcons++] = icon; +			g_permIcons[g_numPermIcons++] = icon;  			if (bEnd) -				numEndIcons++; +				g_numEndIcons++;  		} else {  			// Insert before end icons -			memmove(&permIcons[numPermIcons-numEndIcons+1], -				&permIcons[numPermIcons-numEndIcons], -				numEndIcons * sizeof(int)); -			permIcons[numPermIcons-numEndIcons] = icon; -			numPermIcons++; +			memmove(&g_permIcons[g_numPermIcons-g_numEndIcons+1], +				&g_permIcons[g_numPermIcons-g_numEndIcons], +				g_numEndIcons * sizeof(int)); +			g_permIcons[g_numPermIcons-g_numEndIcons] = icon; +			g_numPermIcons++;  		}  	}  } @@ -3619,21 +3608,21 @@ extern void PermaConvIcon(int icon, bool bEnd) {  extern void convPos(int fn) {  	if (fn == CONV_DEF) -		InvD[INV_CONV].inventoryY = 8; +		g_InvD[INV_CONV].inventoryY = 8;  	else if (fn == CONV_BOTTOM) -		InvD[INV_CONV].inventoryY = 150; +		g_InvD[INV_CONV].inventoryY = 150;  }  extern void ConvPoly(HPOLYGON hPoly) { -	thisConvPoly = hPoly; +	g_thisConvPoly = hPoly;  }  extern int GetIcon() { -	return thisIcon; +	return g_thisIcon;  }  extern void CloseDownConv() { -	if (InventoryState == ACTIVE_INV && ino == INV_CONV) { +	if (g_InventoryState == ACTIVE_INV && g_ino == INV_CONV) {  		KillInventory();  	}  } @@ -3642,43 +3631,43 @@ extern void HideConversation(bool bHide) {  	int aniX, aniY;  	int i; -	if (InventoryState == ACTIVE_INV && ino == INV_CONV) { +	if (g_InventoryState == ACTIVE_INV && g_ino == INV_CONV) {  		if (bHide) {  			// Move all the window and icons off-screen -			for (i = 0; objArray[i] && i < MAX_WCOMP; i++) { -				MultiAdjustXY(objArray[i], 2 * SCREEN_WIDTH, 0); +			for (i = 0; g_objArray[i] && i < MAX_WCOMP; i++) { +				MultiAdjustXY(g_objArray[i], 2 * SCREEN_WIDTH, 0);  			} -			for (i = 0; iconArray[i] && i < MAX_ICONS; i++) { -				MultiAdjustXY(iconArray[i], 2 * SCREEN_WIDTH, 0); +			for (i = 0; g_iconArray[i] && i < MAX_ICONS; i++) { +				MultiAdjustXY(g_iconArray[i], 2 * SCREEN_WIDTH, 0);  			}  			// Window is hidden -			InventoryHidden = true; +			g_InventoryHidden = true;  			// Remove any labels  			InvLabels(false, 0, 0);  		} else {  			// Window is not hidden -			InventoryHidden = false; +			g_InventoryHidden = false; -			if (TinselV2 && ItemsChanged) +			if (TinselV2 && g_ItemsChanged)  				// Just rebuild the whole thing  				ConstructInventory(FULL);  			else {  				// Move it all back on-screen -				for (i = 0; objArray[i] && i < MAX_WCOMP; i++) { -					MultiAdjustXY(objArray[i], -2 * SCREEN_WIDTH, 0); +				for (i = 0; g_objArray[i] && i < MAX_WCOMP; i++) { +					MultiAdjustXY(g_objArray[i], -2 * SCREEN_WIDTH, 0);  				}  				// Don't flash if items changed. If they have, will be redrawn anyway. -				if (TinselV2 || !ItemsChanged) { -					for (i = 0; iconArray[i] && i < MAX_ICONS; i++) { -						MultiAdjustXY(iconArray[i], -2*SCREEN_WIDTH, 0); +				if (TinselV2 || !g_ItemsChanged) { +					for (i = 0; g_iconArray[i] && i < MAX_ICONS; i++) { +						MultiAdjustXY(g_iconArray[i], -2*SCREEN_WIDTH, 0);  					}  				}  			} -			if (TinselV2 && bMoveOnUnHide) { +			if (TinselV2 && g_bMoveOnUnHide) {  				/*  				 * First time, position it appropriately  				 */ @@ -3686,17 +3675,17 @@ extern void HideConversation(bool bHide) {  				int x, y, deltay;  				// Only do it once per conversation -				bMoveOnUnHide = false; +				g_bMoveOnUnHide = false;  				// Current center of the window -				left = MultiLeftmost(RectObject); -				center = (MultiRightmost(RectObject) + left) / 2; +				left = MultiLeftmost(g_RectObject); +				center = (MultiRightmost(g_RectObject) + left) / 2;  				// Get the x-offset for the conversation window -				if (thisConvActor) { +				if (g_thisConvActor) {  					int Loffset, Toffset; -					GetActorMidTop(thisConvActor, &x, &y); +					GetActorMidTop(g_thisConvActor, &x, &y);  					PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset);  					x -= Loffset;  					y -= Toffset; @@ -3706,19 +3695,19 @@ extern void HideConversation(bool bHide) {  				}  				// Save old y-position -				deltay = InvD[INV_CONV].inventoryY; +				deltay = g_InvD[INV_CONV].inventoryY; -				switch (thisConvFn) { +				switch (g_thisConvFn) {  				case CONV_TOP: -					InvD[INV_CONV].inventoryY = SysVar(SV_CONV_TOPY); +					g_InvD[INV_CONV].inventoryY = SysVar(SV_CONV_TOPY);  					break;  				case CONV_BOTTOM: -					InvD[INV_CONV].inventoryY = SysVar(SV_CONV_BOTY); +					g_InvD[INV_CONV].inventoryY = SysVar(SV_CONV_BOTY);  					break;  				case CONV_DEF: -					InvD[INV_CONV].inventoryY = y - SysVar(SV_CONV_ABOVE_Y); +					g_InvD[INV_CONV].inventoryY = y - SysVar(SV_CONV_ABOVE_Y);  					break;  				default: @@ -3726,34 +3715,34 @@ extern void HideConversation(bool bHide) {  				}  				// Calculate y change -				deltay = InvD[INV_CONV].inventoryY - deltay; +				deltay = g_InvD[INV_CONV].inventoryY - deltay;  				// Move it all -				for (i = 0; objArray[i] && i < MAX_WCOMP; i++) { -					MultiMoveRelXY(objArray[i], x - center, deltay); +				for (i = 0; g_objArray[i] && i < MAX_WCOMP; i++) { +					MultiMoveRelXY(g_objArray[i], x - center, deltay);  				} -				for (i = 0; iconArray[i] && i < MAX_ICONS; i++) { -					MultiMoveRelXY(iconArray[i], x - center, deltay); +				for (i = 0; g_iconArray[i] && i < MAX_ICONS; i++) { +					MultiMoveRelXY(g_iconArray[i], x - center, deltay);  				} -				InvD[INV_CONV].inventoryX += x - center; +				g_InvD[INV_CONV].inventoryX += x - center;  				/*  				 * Now positioned as worked out  				 * - but it must be in a sensible place  				*/ -				if (MultiLeftmost(RectObject) < SysVar(SV_CONV_MINX)) -					x = SysVar(SV_CONV_MINX) - MultiLeftmost(RectObject); -				else if (MultiRightmost(RectObject) > SCREEN_WIDTH - SysVar(SV_CONV_MINX)) -					x = SCREEN_WIDTH - SysVar(SV_CONV_MINX) - MultiRightmost(RectObject); +				if (MultiLeftmost(g_RectObject) < SysVar(SV_CONV_MINX)) +					x = SysVar(SV_CONV_MINX) - MultiLeftmost(g_RectObject); +				else if (MultiRightmost(g_RectObject) > SCREEN_WIDTH - SysVar(SV_CONV_MINX)) +					x = SCREEN_WIDTH - SysVar(SV_CONV_MINX) - MultiRightmost(g_RectObject);  				else  					x = 0; -				if (thisConvFn == CONV_DEF && MultiHighest(RectObject) < SysVar(SV_CONV_MINY) -						&& thisConvActor) { +				if (g_thisConvFn == CONV_DEF && MultiHighest(g_RectObject) < SysVar(SV_CONV_MINY) +						&& g_thisConvActor) {  					int Loffset, Toffset;  					PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset); -					y = GetActorBottom(thisConvActor) - MultiHighest(RectObject) + +					y = GetActorBottom(g_thisConvActor) - MultiHighest(g_RectObject) +  						SysVar(SV_CONV_BELOW_Y);  					y -= Toffset;  				} @@ -3761,28 +3750,28 @@ extern void HideConversation(bool bHide) {  					y = 0;  				if (x || y) { -					for (i = 0; objArray[i] && i < MAX_WCOMP; i++) { -						MultiMoveRelXY(objArray[i], x, y); +					for (i = 0; g_objArray[i] && i < MAX_WCOMP; i++) { +						MultiMoveRelXY(g_objArray[i], x, y);  					} -					for (i = 0; iconArray[i] && i < MAX_ICONS; i++) { -						MultiMoveRelXY(iconArray[i], x, y); +					for (i = 0; g_iconArray[i] && i < MAX_ICONS; i++) { +						MultiMoveRelXY(g_iconArray[i], x, y);  					} -					InvD[INV_CONV].inventoryX += x; -					InvD[INV_CONV].inventoryY += y; +					g_InvD[INV_CONV].inventoryX += x; +					g_InvD[INV_CONV].inventoryY += y;  				}  				/*  				 * Oh shit! We might have gone off the bottom  				 */ -				if (MultiLowest(RectObject) > SCREEN_BOX_HEIGHT2 - SysVar(SV_CONV_MINY)) { -					y = (SCREEN_BOX_HEIGHT2 - SysVar(SV_CONV_MINY)) - MultiLowest(RectObject); -					for (i = 0; objArray[i] && i < MAX_WCOMP; i++) { -						MultiMoveRelXY(objArray[i], 0, y); +				if (MultiLowest(g_RectObject) > SCREEN_BOX_HEIGHT2 - SysVar(SV_CONV_MINY)) { +					y = (SCREEN_BOX_HEIGHT2 - SysVar(SV_CONV_MINY)) - MultiLowest(g_RectObject); +					for (i = 0; g_objArray[i] && i < MAX_WCOMP; i++) { +						MultiMoveRelXY(g_objArray[i], 0, y);  					} -					for (i = 0; iconArray[i] && i < MAX_ICONS; i++) { -						MultiMoveRelXY(iconArray[i], 0, y); +					for (i = 0; g_iconArray[i] && i < MAX_ICONS; i++) { +						MultiMoveRelXY(g_iconArray[i], 0, y);  					} -					InvD[INV_CONV].inventoryY += y; +					g_InvD[INV_CONV].inventoryY += y;  				}  			} @@ -3793,7 +3782,7 @@ extern void HideConversation(bool bHide) {  }  extern bool ConvIsHidden() { -	return InventoryHidden; +	return g_InventoryHidden;  } @@ -3808,8 +3797,8 @@ extern void PopUpInventory(int invno) {  	assert(invno == INV_1 || invno == INV_2 || invno == INV_CONV  		|| invno == INV_CONF || invno == INV_MENU); // Trying to open illegal inventory -	if (InventoryState == IDLE_INV) { -		bReOpenMenu = false;	// Better safe than sorry... +	if (g_InventoryState == IDLE_INV) { +		g_bReOpenMenu = false;	// Better safe than sorry...  		DisableTags();		// Tags disabled during inventory  		if (TinselV2) @@ -3821,25 +3810,25 @@ extern void PopUpInventory(int invno) {  				_vm->_pcmMusic->dim(false);  			// Start conversation with permanent contents -			memset(InvD[INV_CONV].contents, 0, MAX_ININV*sizeof(int)); -			memcpy(InvD[INV_CONV].contents, permIcons, numPermIcons*sizeof(int)); -			InvD[INV_CONV].NoofItems = numPermIcons; +			memset(g_InvD[INV_CONV].contents, 0, MAX_ININV*sizeof(int)); +			memcpy(g_InvD[INV_CONV].contents, g_permIcons, g_numPermIcons*sizeof(int)); +			g_InvD[INV_CONV].NoofItems = g_numPermIcons;  			if (TinselV2) -				InvD[INV_CONV].NoofHicons = numPermIcons; +				g_InvD[INV_CONV].NoofHicons = g_numPermIcons;  			else -				thisIcon = 0; +				g_thisIcon = 0;  		} else if (invno == INV_CONF) {	// Configuration window?  			cd.selBox = NOBOX;  			cd.pointBox = NOBOX;  		} -		ino = invno;			// The open inventory +		g_ino = invno;			// The open inventory -		ItemsChanged = false;		// Nothing changed -		InvDragging = ID_NONE;		// Not dragging -		InventoryState = ACTIVE_INV;	// Inventory actiive -		InventoryHidden = false;	// Not hidden -		InventoryMaximised = InvD[ino].bMax; +		g_ItemsChanged = false;		// Nothing changed +		g_InvDragging = ID_NONE;		// Not dragging +		g_InventoryState = ACTIVE_INV;	// Inventory actiive +		g_InventoryHidden = false;	// Not hidden +		g_InventoryMaximised = g_InvD[g_ino].bMax;  		if (invno != INV_CONF)	// Configuration window?  			ConstructInventory(FULL);	// Draw it up  		else { @@ -3849,10 +3838,10 @@ extern void PopUpInventory(int invno) {  }  static void SetMenuGlobals(CONFINIT *ci) { -	InvD[INV_CONF].MinHicons = InvD[INV_CONF].MaxHicons = InvD[INV_CONF].NoofHicons = ci->h; -	InvD[INV_CONF].MaxVicons = InvD[INV_CONF].MinVicons = InvD[INV_CONF].NoofVicons = ci->v; -	InvD[INV_CONF].inventoryX = ci->x; -	InvD[INV_CONF].inventoryY = ci->y; +	g_InvD[INV_CONF].MinHicons = g_InvD[INV_CONF].MaxHicons = g_InvD[INV_CONF].NoofHicons = ci->h; +	g_InvD[INV_CONF].MaxVicons = g_InvD[INV_CONF].MinVicons = g_InvD[INV_CONF].NoofVicons = ci->v; +	g_InvD[INV_CONF].inventoryX = ci->x; +	g_InvD[INV_CONF].inventoryY = ci->y;  	cd.bExtraWin = ci->bExtraWin;  	cd.box = ci->Box;  	cd.NumBoxes = ci->NumBoxes; @@ -3860,9 +3849,9 @@ static void SetMenuGlobals(CONFINIT *ci) {  	if (TinselV2) {  		if ((ci->ixHeading != NO_HEADING) && SysString(ci->ixHeading)) -			InvD[INV_MENU].hInvTitle = SysString(ci->ixHeading); +			g_InvD[INV_MENU].hInvTitle = SysString(ci->ixHeading);  		else -			InvD[INV_MENU].hInvTitle = NO_HEADING; +			g_InvD[INV_MENU].hInvTitle = NO_HEADING;  	}  } @@ -3876,11 +3865,11 @@ extern void OpenMenu(CONFTYPE menuType) {  	if (TinselV0)  		return; -	if (InventoryState != IDLE_INV) +	if (g_InventoryState != IDLE_INV)  		return; -	InvD[INV_CONF].resizable = false; -	InvD[INV_CONF].bMoveable = false; +	g_InvD[INV_CONF].resizable = false; +	g_InvD[INV_CONF].bMoveable = false;  	switch (menuType) {  	case MAIN_MENU: @@ -3915,7 +3904,7 @@ extern void OpenMenu(CONFTYPE menuType) {  	case SOUND_MENU:  		if (TinselV2) -			displayedLanguage = TextLanguage(); +			g_displayedLanguage = TextLanguage();  #if 1  		// FIXME: Hack to setup CONFBOX pointer to data in the global Config object  		if (TinselV2) { @@ -4003,16 +3992,16 @@ extern void OpenMenu(CONFTYPE menuType) {  	case TOP_WINDOW:  		SetMenuGlobals(&ciTopWin); -		ino = INV_CONF; +		g_ino = INV_CONF;  		ConstructInventory(CONF);	// Draw it up -		InventoryState = BOGUS_INV; +		g_InventoryState = BOGUS_INV;  		return;  	default:  		return;  	} -	if (HeldItem != INV_NOICON) +	if (g_heldItem != INV_NOICON)  		DelAuxCursor();			// no longer aux cursor  	PopUpInventory(INV_CONF); @@ -4045,38 +4034,38 @@ extern void OpenMenu(CONFTYPE menuType) {   * Close down an inventory window.   */  extern void KillInventory() { -	if (objArray[0] != NULL) { +	if (g_objArray[0] != NULL) {  		DumpObjArray();  		DumpDobjArray();  		DumpIconArray();  	} -	if (InventoryState == ACTIVE_INV) { +	if (g_InventoryState == ACTIVE_INV) {  		EnableTags();  		if (TinselV2)  			EnablePointing(); -		InvD[ino].bMax = InventoryMaximised; +		g_InvD[g_ino].bMax = g_InventoryMaximised;  		UnHideCursorTrails();  		_vm->divertKeyInput(NULL);  	} -	InventoryState = IDLE_INV; +	g_InventoryState = IDLE_INV; -	if (bReOpenMenu) { -		bReOpenMenu = false; +	if (g_bReOpenMenu) { +		g_bReOpenMenu = false;  		OpenMenu(MAIN_MENU);  		// Write config changes  		_vm->_config->writeToDisk(); -	} else if (ino == INV_CONF) +	} else if (g_ino == INV_CONF)  		InventoryIconCursor(false);  	if (TinselV2)  		// Pump up the volume -		if (ino == INV_CONV) +		if (g_ino == INV_CONV)  			_vm->_pcmMusic->unDim(false);  	g_system->setFeatureState(OSystem::kFeatureVirtualKeyboard, false);	// Hide VK after save dialog closes @@ -4084,15 +4073,15 @@ extern void KillInventory() {  extern void CloseInventory() {  	// If not active, ignore this -	if (InventoryState != ACTIVE_INV) +	if (g_InventoryState != ACTIVE_INV)  		return;  	// If hidden, a conversation action is still underway - ignore this -	if (InventoryHidden) +	if (g_InventoryHidden)  		return;  	// If conversation, this is a closeing event -	if (ino == INV_CONV) +	if (g_ino == INV_CONV)  		ConvAction(INV_CLOSEICON);  	KillInventory(); @@ -4117,13 +4106,13 @@ extern void InventoryProcess(CORO_PARAM, const void *) {  	CORO_BEGIN_CODE(_ctx);  	if (NumberOfLanguages() <= 1) -		bNoLanguage = true; +		g_bNoLanguage = true;  	while (1) {  		CORO_SLEEP(1);		// allow scheduling -		if (objArray[0] != NULL) { -			if (ItemsChanged && ino != INV_CONF && !InventoryHidden) { +		if (g_objArray[0] != NULL) { +			if (g_ItemsChanged && g_ino != INV_CONF && !g_InventoryHidden) {  				FillInInventory();  				// Needed when clicking on scroll bar. @@ -4131,15 +4120,15 @@ extern void InventoryProcess(CORO_PARAM, const void *) {  				GetCursorXY(&curX, &curY, false);  				InvCursor(IC_AREA, curX, curY); -				ItemsChanged = false; +				g_ItemsChanged = false;  			} -			if (ino != INV_CONF) { +			if (g_ino != INV_CONF) {  				for (int i = 0; i < MAX_ICONS; i++) { -					if (iconArray[i] != NULL) -						StepAnimScript(&iconAnims[i]); +					if (g_iconArray[i] != NULL) +						StepAnimScript(&g_iconAnims[i]);  				}  			} -			if (InvDragging == ID_MDCONT) { +			if (g_InvDragging == ID_MDCONT) {  				// Mixing desk control  				int sval, index, *pival; @@ -4263,12 +4252,12 @@ static int NearestSlideY(int fity) {  	int i = 0;  	do { -		thisDist = ABS(slideStuff[i].y - fity); +		thisDist = ABS(g_slideStuff[i].y - fity);  		if (thisDist < nearDist) {  			nearDist = thisDist;  			nearI = i;  		} -	} while (slideStuff[++i].n != -1); +	} while (g_slideStuff[++i].n != -1);  	return nearI;  } @@ -4281,44 +4270,44 @@ static void SlideSlider(int y, SSFN fn) {  	int gotoY, ati;  	// Only do this if there's a slider -	if (!SlideObject) +	if (!g_SlideObject)  		return;  	switch (fn) {  	case S_START:			// Start of a drag on the slider -		newY = sliderYpos; -		lasti = NearestSlideY(sliderYpos); +		newY = g_sliderYpos; +		lasti = NearestSlideY(g_sliderYpos);  		break;  	case S_SLIDE:			// Y-movement during drag  		newY = newY + y;		// New y-position -		if (newY < sliderYmin) -			gotoY = sliderYmin;	// Above top limit -		else if (newY > sliderYmax) -			gotoY = sliderYmax;	// Below bottom limit +		if (newY < g_sliderYmin) +			gotoY = g_sliderYmin;	// Above top limit +		else if (newY > g_sliderYmax) +			gotoY = g_sliderYmax;	// Below bottom limit  		else  			gotoY = newY;		// Hunky-Dory  		// Move slider to new position -		MultiMoveRelXY(SlideObject, 0, gotoY - sliderYpos); -		sliderYpos = gotoY; +		MultiMoveRelXY(g_SlideObject, 0, gotoY - g_sliderYpos); +		g_sliderYpos = gotoY;  		// Re-draw icons if necessary -		ati = NearestSlideY(sliderYpos); +		ati = NearestSlideY(g_sliderYpos);  		if (ati != lasti) { -			InvD[ino].FirstDisp = slideStuff[ati].n; -			assert(InvD[ino].FirstDisp >= 0); // negative first displayed -			ItemsChanged = true; +			g_InvD[g_ino].FirstDisp = g_slideStuff[ati].n; +			assert(g_InvD[g_ino].FirstDisp >= 0); // negative first displayed +			g_ItemsChanged = true;  			lasti = ati;  		}  		break;  	case S_END:			// End of a drag on the slider  		// Draw icons from new start icon -		ati = NearestSlideY(sliderYpos); -		InvD[ino].FirstDisp = slideStuff[ati].n; -		ItemsChanged = true; +		ati = NearestSlideY(g_sliderYpos); +		g_InvD[g_ino].FirstDisp = g_slideStuff[ati].n; +		g_ItemsChanged = true;  		break;  	default: @@ -4336,38 +4325,38 @@ static void SlideCSlider(int y, SSFN fn) {  	int	fc;  	// Only do this if there's a slider -	if (!SlideObject) +	if (!g_SlideObject)  		return;  	switch (fn) {  	case S_START:			// Start of a drag on the slider -		newY = sliderYpos; +		newY = g_sliderYpos;  		break;  	case S_SLIDE:			// Y-movement during drag  		newY = newY + y;		// New y-position -		if (newY < sliderYmin) -			gotoY = sliderYmin;	// Above top limit -		else if (newY > sliderYmax) -			gotoY = sliderYmax;	// Below bottom limit +		if (newY < g_sliderYmin) +			gotoY = g_sliderYmin;	// Above top limit +		else if (newY > g_sliderYmax) +			gotoY = g_sliderYmax;	// Below bottom limit  		else  			gotoY = newY;		// Hunky-Dory  		// Move slider to new position  		if (TinselV2) -			MultiMoveRelXY(SlideObject, 0, gotoY - sliderYpos); -		sliderYpos = gotoY; +			MultiMoveRelXY(g_SlideObject, 0, gotoY - g_sliderYpos); +		g_sliderYpos = gotoY;  		fc = cd.extraBase;  		if ((cd.box == saveBox || cd.box == loadBox)) -			FirstFile((sliderYpos - sliderYmin) * (MAX_SAVED_FILES - NUM_RGROUP_BOXES) / -				(sliderYmax - sliderYmin)); +			FirstFile((g_sliderYpos - g_sliderYmin) * (MAX_SAVED_FILES - NUM_RGROUP_BOXES) / +				(g_sliderYmax - g_sliderYmin));  		else if (cd.box == hopperBox1) -			FirstScene((sliderYpos - sliderYmin) * (numScenes - NUM_RGROUP_BOXES) / sliderRange); +			FirstScene((g_sliderYpos - g_sliderYmin) * (g_numScenes - NUM_RGROUP_BOXES) / sliderRange);  		else if (cd.box == hopperBox2) -			FirstEntry((sliderYpos - sliderYmin) * (numEntries - NUM_RGROUP_BOXES) / sliderRange); +			FirstEntry((g_sliderYpos - g_sliderYmin) * (g_numEntries - NUM_RGROUP_BOXES) / sliderRange);  		// If extraBase has changed...  		if (fc != cd.extraBase) { @@ -4409,16 +4398,16 @@ static void SlideMSlider(int x, SSFN fn) {  	// Work out the indices  	index = cd.selBox & ~IS_MASK; -	for (i = 0; i < numMdSlides; i++) -		if (mdSlides[i].num == index) +	for (i = 0; i < g_numMdSlides; i++) +		if (g_mdSlides[i].num == index)  			break; -	assert(i < numMdSlides); +	assert(i < g_numMdSlides);  	switch (fn) {  	case S_START:			// Start of a drag on the slider  		// can use index as a throw-away value -		GetAniPosition(mdSlides[i].obj, &newX, &index); -		lX = sX = newX; +		GetAniPosition(g_mdSlides[i].obj, &newX, &index); +		g_lX = g_sX = newX;  		break;  	case S_SLIDE:			// X-movement during drag @@ -4427,19 +4416,19 @@ static void SlideMSlider(int x, SSFN fn) {  		newX = newX + x;	// New x-position -		if (newX < mdSlides[i].min) -			gotoX = mdSlides[i].min;	// Below bottom limit -		else if (newX > mdSlides[i].max) -			gotoX = mdSlides[i].max;	// Above top limit +		if (newX < g_mdSlides[i].min) +			gotoX = g_mdSlides[i].min;	// Below bottom limit +		else if (newX > g_mdSlides[i].max) +			gotoX = g_mdSlides[i].max;	// Above top limit  		else  			gotoX = newX;		// Hunky-Dory  		// Move slider to new position -		MultiMoveRelXY(mdSlides[i].obj, gotoX - sX, 0); -		sX = gotoX; +		MultiMoveRelXY(g_mdSlides[i].obj, gotoX - g_sX, 0); +		g_sX = gotoX; -		if (lX != sX) { -			*cd.box[index].ival = (sX - mdSlides[i].min)*cd.box[index].w/SLIDE_RANGE; +		if (g_lX != g_sX) { +			*cd.box[index].ival = (g_sX - g_mdSlides[i].min)*cd.box[index].w/SLIDE_RANGE;  			if (cd.box[index].boxFunc == MUSICVOL)  				SetMidiVolume(*cd.box[index].ival);  #ifdef MAC_OPTIONS @@ -4449,14 +4438,14 @@ static void SlideMSlider(int x, SSFN fn) {  			if (cd.box[index].boxFunc == SAMPVOL)  				SetSampleVolume(*cd.box[index].ival);  #endif -			lX = sX; +			g_lX = g_sX;  		}  		break;  	case S_TIMEUP:  	case S_TIMEDN:  		gotoX = SLIDE_RANGE*(*cd.box[index].ival)/cd.box[index].w; -		MultiSetAniX(mdSlides[i].obj, mdSlides[i].min+gotoX); +		MultiSetAniX(g_mdSlides[i].obj, g_mdSlides[i].min+gotoX);  		if (cd.box[index].boxFunc == MUSICVOL)  			SetMidiVolume(*cd.box[index].ival); @@ -4471,7 +4460,7 @@ static void SlideMSlider(int x, SSFN fn) {  	case S_END:			// End of a drag on the slider  		AddBoxes(false);	// Might change position slightly -		if (ino == INV_CONF && cd.box == subtitlesBox) +		if (g_ino == INV_CONF && cd.box == subtitlesBox)  			Select(_vm->_config->_language, false);  		break;  	} @@ -4481,23 +4470,23 @@ static void SlideMSlider(int x, SSFN fn) {   * Called from ChangeingSize() during re-sizing.   */  static void GettingTaller() { -	if (SuppV) { -		Ychange += SuppV; -		if (Ycompensate == 'T') -			InvD[ino].inventoryY += SuppV; -		SuppV = 0; +	if (g_SuppV) { +		g_Ychange += g_SuppV; +		if (g_Ycompensate == 'T') +			g_InvD[g_ino].inventoryY += g_SuppV; +		g_SuppV = 0;  	} -	while (Ychange > (ITEM_HEIGHT+1) && InvD[ino].NoofVicons < InvD[ino].MaxVicons) { -		Ychange -= (ITEM_HEIGHT+1); -		InvD[ino].NoofVicons++; -		if (Ycompensate == 'T') -			InvD[ino].inventoryY -= (ITEM_HEIGHT+1); +	while (g_Ychange > (ITEM_HEIGHT+1) && g_InvD[g_ino].NoofVicons < g_InvD[g_ino].MaxVicons) { +		g_Ychange -= (ITEM_HEIGHT+1); +		g_InvD[g_ino].NoofVicons++; +		if (g_Ycompensate == 'T') +			g_InvD[g_ino].inventoryY -= (ITEM_HEIGHT+1);  	} -	if (InvD[ino].NoofVicons < InvD[ino].MaxVicons) { -		SuppV = Ychange; -		Ychange = 0; -		if (Ycompensate == 'T') -			InvD[ino].inventoryY -= SuppV; +	if (g_InvD[g_ino].NoofVicons < g_InvD[g_ino].MaxVicons) { +		g_SuppV = g_Ychange; +		g_Ychange = 0; +		if (g_Ycompensate == 'T') +			g_InvD[g_ino].inventoryY -= g_SuppV;  	}  } @@ -4505,73 +4494,73 @@ static void GettingTaller() {   * Called from ChangeingSize() during re-sizing.   */  static void GettingShorter() { -	int StartNvi = InvD[ino].NoofVicons; -	int StartUv = SuppV; +	int StartNvi = g_InvD[g_ino].NoofVicons; +	int StartUv = g_SuppV; -	if (SuppV) { -		Ychange += (SuppV - (ITEM_HEIGHT+1)); -		InvD[ino].NoofVicons++; -		SuppV = 0; +	if (g_SuppV) { +		g_Ychange += (g_SuppV - (ITEM_HEIGHT+1)); +		g_InvD[g_ino].NoofVicons++; +		g_SuppV = 0;  	} -	while (Ychange < -(ITEM_HEIGHT+1) && InvD[ino].NoofVicons > InvD[ino].MinVicons) { -		Ychange += (ITEM_HEIGHT+1); -		InvD[ino].NoofVicons--; +	while (g_Ychange < -(ITEM_HEIGHT+1) && g_InvD[g_ino].NoofVicons > g_InvD[g_ino].MinVicons) { +		g_Ychange += (ITEM_HEIGHT+1); +		g_InvD[g_ino].NoofVicons--;  	} -	if (InvD[ino].NoofVicons > InvD[ino].MinVicons && Ychange) { -		SuppV = (ITEM_HEIGHT+1) + Ychange; -		InvD[ino].NoofVicons--; -		Ychange = 0; +	if (g_InvD[g_ino].NoofVicons > g_InvD[g_ino].MinVicons && g_Ychange) { +		g_SuppV = (ITEM_HEIGHT+1) + g_Ychange; +		g_InvD[g_ino].NoofVicons--; +		g_Ychange = 0;  	} -	if (Ycompensate == 'T') -		InvD[ino].inventoryY += (ITEM_HEIGHT+1)*(StartNvi - InvD[ino].NoofVicons) - (SuppV - StartUv); +	if (g_Ycompensate == 'T') +		g_InvD[g_ino].inventoryY += (ITEM_HEIGHT+1)*(StartNvi - g_InvD[g_ino].NoofVicons) - (g_SuppV - StartUv);  }  /**   * Called from ChangeingSize() during re-sizing.   */  static void GettingWider() { -	int StartNhi = InvD[ino].NoofHicons; -	int StartUh = SuppH; +	int StartNhi = g_InvD[g_ino].NoofHicons; +	int StartUh = g_SuppH; -	if (SuppH) { -		Xchange += SuppH; -		SuppH = 0; +	if (g_SuppH) { +		g_Xchange += g_SuppH; +		g_SuppH = 0;  	} -	while (Xchange > (ITEM_WIDTH+1) && InvD[ino].NoofHicons < InvD[ino].MaxHicons) { -		Xchange -= (ITEM_WIDTH+1); -		InvD[ino].NoofHicons++; +	while (g_Xchange > (ITEM_WIDTH+1) && g_InvD[g_ino].NoofHicons < g_InvD[g_ino].MaxHicons) { +		g_Xchange -= (ITEM_WIDTH+1); +		g_InvD[g_ino].NoofHicons++;  	} -	if (InvD[ino].NoofHicons < InvD[ino].MaxHicons) { -		SuppH = Xchange; -		Xchange = 0; +	if (g_InvD[g_ino].NoofHicons < g_InvD[g_ino].MaxHicons) { +		g_SuppH = g_Xchange; +		g_Xchange = 0;  	} -	if (Xcompensate == 'L') -		InvD[ino].inventoryX += (ITEM_WIDTH+1)*(StartNhi - InvD[ino].NoofHicons) - (SuppH - StartUh); +	if (g_Xcompensate == 'L') +		g_InvD[g_ino].inventoryX += (ITEM_WIDTH+1)*(StartNhi - g_InvD[g_ino].NoofHicons) - (g_SuppH - StartUh);  }  /**   * Called from ChangeingSize() during re-sizing.   */  static void GettingNarrower() { -	int StartNhi = InvD[ino].NoofHicons; -	int StartUh = SuppH; +	int StartNhi = g_InvD[g_ino].NoofHicons; +	int StartUh = g_SuppH; -	if (SuppH) { -		Xchange += (SuppH - (ITEM_WIDTH+1)); -		InvD[ino].NoofHicons++; -		SuppH = 0; +	if (g_SuppH) { +		g_Xchange += (g_SuppH - (ITEM_WIDTH+1)); +		g_InvD[g_ino].NoofHicons++; +		g_SuppH = 0;  	} -	while (Xchange < -(ITEM_WIDTH+1) && InvD[ino].NoofHicons > InvD[ino].MinHicons) { -		Xchange += (ITEM_WIDTH+1); -		InvD[ino].NoofHicons--; +	while (g_Xchange < -(ITEM_WIDTH+1) && g_InvD[g_ino].NoofHicons > g_InvD[g_ino].MinHicons) { +		g_Xchange += (ITEM_WIDTH+1); +		g_InvD[g_ino].NoofHicons--;  	} -	if (InvD[ino].NoofHicons > InvD[ino].MinHicons && Xchange) { -		SuppH = (ITEM_WIDTH+1) + Xchange; -		InvD[ino].NoofHicons--; -		Xchange = 0; +	if (g_InvD[g_ino].NoofHicons > g_InvD[g_ino].MinHicons && g_Xchange) { +		g_SuppH = (ITEM_WIDTH+1) + g_Xchange; +		g_InvD[g_ino].NoofHicons--; +		g_Xchange = 0;  	} -	if (Xcompensate == 'L') -		InvD[ino].inventoryX += (ITEM_WIDTH+1)*(StartNhi - InvD[ino].NoofHicons) - (SuppH - StartUh); +	if (g_Xcompensate == 'L') +		g_InvD[g_ino].inventoryX += (ITEM_WIDTH+1)*(StartNhi - g_InvD[g_ino].NoofHicons) - (g_SuppH - StartUh);  } @@ -4580,15 +4569,15 @@ static void GettingNarrower() {   */  static void ChangeingSize() {  	/* Make it taller or shorter if necessary. */ -	if (Ychange > 0) +	if (g_Ychange > 0)  		GettingTaller(); -	else if (Ychange < 0) +	else if (g_Ychange < 0)  		GettingShorter();  	/* Make it wider or narrower if necessary. */ -	if (Xchange > 0) +	if (g_Xchange > 0)  		GettingWider(); -	else if (Xchange < 0) +	else if (g_Xchange < 0)  		GettingNarrower();  	ConstructInventory(EMPTY); @@ -4601,29 +4590,29 @@ extern void Xmovement(int x) {  	int aniX, aniY;  	int i; -	if (x && objArray[0] != NULL) { -		switch (InvDragging) { +	if (x && g_objArray[0] != NULL) { +		switch (g_InvDragging) {  		case ID_MOVE: -			GetAniPosition(objArray[0], &InvD[ino].inventoryX, &aniY); -			InvD[ino].inventoryX +=x; -			MultiSetAniX(objArray[0], InvD[ino].inventoryX); -			for (i = 1; objArray[i] && i < MAX_WCOMP; i++) -				MultiMoveRelXY(objArray[i], x, 0); -			for (i = 0; iconArray[i] && i < MAX_ICONS; i++) -				MultiMoveRelXY(iconArray[i], x, 0); +			GetAniPosition(g_objArray[0], &g_InvD[g_ino].inventoryX, &aniY); +			g_InvD[g_ino].inventoryX +=x; +			MultiSetAniX(g_objArray[0], g_InvD[g_ino].inventoryX); +			for (i = 1; g_objArray[i] && i < MAX_WCOMP; i++) +				MultiMoveRelXY(g_objArray[i], x, 0); +			for (i = 0; g_iconArray[i] && i < MAX_ICONS; i++) +				MultiMoveRelXY(g_iconArray[i], x, 0);  			break;  		case ID_LEFT:  		case ID_TLEFT:  		case ID_BLEFT: -			Xchange -= x; +			g_Xchange -= x;  			ChangeingSize();  			break;  		case ID_RIGHT:  		case ID_TRIGHT:  		case ID_BRIGHT: -			Xchange += x; +			g_Xchange += x;  			ChangeingSize();  			break; @@ -4649,16 +4638,16 @@ extern void Ymovement(int y) {  	int aniX, aniY;  	int i; -	if (y && objArray[0] != NULL) { -		switch (InvDragging) { +	if (y && g_objArray[0] != NULL) { +		switch (g_InvDragging) {  		case ID_MOVE: -			GetAniPosition(objArray[0], &aniX, &InvD[ino].inventoryY); -			InvD[ino].inventoryY +=y; -			MultiSetAniY(objArray[0], InvD[ino].inventoryY); -			for (i = 1; objArray[i] && i < MAX_WCOMP; i++) -				MultiMoveRelXY(objArray[i], 0, y); -			for (i = 0; iconArray[i] && i < MAX_ICONS; i++) -				MultiMoveRelXY(iconArray[i], 0, y); +			GetAniPosition(g_objArray[0], &aniX, &g_InvD[g_ino].inventoryY); +			g_InvD[g_ino].inventoryY +=y; +			MultiSetAniY(g_objArray[0], g_InvD[g_ino].inventoryY); +			for (i = 1; g_objArray[i] && i < MAX_WCOMP; i++) +				MultiMoveRelXY(g_objArray[i], 0, y); +			for (i = 0; g_iconArray[i] && i < MAX_ICONS; i++) +				MultiMoveRelXY(g_iconArray[i], 0, y);  			break;  		case ID_SLIDE: @@ -4672,14 +4661,14 @@ extern void Ymovement(int y) {  		case ID_BOTTOM:  		case ID_BLEFT:  		case ID_BRIGHT: -			Ychange += y; +			g_Ychange += y;  			ChangeingSize();  			break;  		case ID_TOP:  		case ID_TLEFT:  		case ID_TRIGHT: -			Ychange -= y; +			g_Ychange -= y;  			ChangeingSize();  			break; @@ -4705,16 +4694,16 @@ static void InvDragStart() {  	/*  	 * Do something different for Save/Restore screens  	 */ -	if (ino == INV_CONF) { +	if (g_ino == INV_CONF) {  		int	whichbox;  		whichbox = WhichMenuBox(curX, curY, true);  		if (whichbox == IB_SLIDE) { -			InvDragging = ID_CSLIDE; +			g_InvDragging = ID_CSLIDE;  			SlideCSlider(0, S_START);  		} else if (whichbox > 0 && (whichbox & IS_MASK)) { -			InvDragging = ID_MDCONT;	// Mixing desk control +			g_InvDragging = ID_MDCONT;	// Mixing desk control  			cd.selBox = whichbox;  			SlideMSlider(0, S_START);  		} @@ -4726,85 +4715,85 @@ static void InvDragStart() {  	 */  	switch (InvArea(curX, curY)) {  	case I_HEADER: -		if (InvD[ino].bMoveable) { -			InvDragging = ID_MOVE; +		if (g_InvD[g_ino].bMoveable) { +			g_InvDragging = ID_MOVE;  		}  		break;  	case I_SLIDE: -		InvDragging = ID_SLIDE; +		g_InvDragging = ID_SLIDE;  		SlideSlider(0, S_START);  		break;  	case I_BOTTOM: -		if (InvD[ino].resizable) { -			Ychange = 0; -			InvDragging = ID_BOTTOM; -			Ycompensate = 'B'; +		if (g_InvD[g_ino].resizable) { +			g_Ychange = 0; +			g_InvDragging = ID_BOTTOM; +			g_Ycompensate = 'B';  		}  		break;  	case I_TOP: -		if (InvD[ino].resizable) { -			Ychange = 0; -			InvDragging = ID_TOP; -			Ycompensate = 'T'; +		if (g_InvD[g_ino].resizable) { +			g_Ychange = 0; +			g_InvDragging = ID_TOP; +			g_Ycompensate = 'T';  		}  		break;  	case I_LEFT: -		if (InvD[ino].resizable) { -			Xchange = 0; -			InvDragging = ID_LEFT; -			Xcompensate = 'L'; +		if (g_InvD[g_ino].resizable) { +			g_Xchange = 0; +			g_InvDragging = ID_LEFT; +			g_Xcompensate = 'L';  		}  		break;  	case I_RIGHT: -		if (InvD[ino].resizable) { -			Xchange = 0; -			InvDragging = ID_RIGHT; -			Xcompensate = 'R'; +		if (g_InvD[g_ino].resizable) { +			g_Xchange = 0; +			g_InvDragging = ID_RIGHT; +			g_Xcompensate = 'R';  		}  		break;  	case I_TLEFT: -		if (InvD[ino].resizable) { -			Ychange = 0; -			Ycompensate = 'T'; -			Xchange = 0; -			Xcompensate = 'L'; -			InvDragging = ID_TLEFT; +		if (g_InvD[g_ino].resizable) { +			g_Ychange = 0; +			g_Ycompensate = 'T'; +			g_Xchange = 0; +			g_Xcompensate = 'L'; +			g_InvDragging = ID_TLEFT;  		}  		break;  	case I_TRIGHT: -		if (InvD[ino].resizable) { -			Ychange = 0; -			Ycompensate = 'T'; -			Xchange = 0; -			Xcompensate = 'R'; -			InvDragging = ID_TRIGHT; +		if (g_InvD[g_ino].resizable) { +			g_Ychange = 0; +			g_Ycompensate = 'T'; +			g_Xchange = 0; +			g_Xcompensate = 'R'; +			g_InvDragging = ID_TRIGHT;  		}  		break;  	case I_BLEFT: -		if (InvD[ino].resizable) { -			Ychange = 0; -			Ycompensate = 'B'; -			Xchange = 0; -			Xcompensate = 'L'; -			InvDragging = ID_BLEFT; +		if (g_InvD[g_ino].resizable) { +			g_Ychange = 0; +			g_Ycompensate = 'B'; +			g_Xchange = 0; +			g_Xcompensate = 'L'; +			g_InvDragging = ID_BLEFT;  		}  		break;  	case I_BRIGHT: -		if (InvD[ino].resizable) { -			Ychange = 0; -			Ycompensate = 'B'; -			Xchange = 0; -			Xcompensate = 'R'; -			InvDragging = ID_BRIGHT; +		if (g_InvD[g_ino].resizable) { +			g_Ychange = 0; +			g_Ycompensate = 'B'; +			g_Xchange = 0; +			g_Xcompensate = 'R'; +			g_InvDragging = ID_BRIGHT;  		}  		break;  	} @@ -4818,14 +4807,14 @@ static void InvDragEnd() {  	GetCursorXY(&curX, &curY, false); -	if (InvDragging != ID_NONE) { -		if (InvDragging == ID_SLIDE) { +	if (g_InvDragging != ID_NONE) { +		if (g_InvDragging == ID_SLIDE) {  			SlideSlider(0, S_END); -		} else if (InvDragging == ID_CSLIDE) { +		} else if (g_InvDragging == ID_CSLIDE) {  			;	// No action -		} else if (InvDragging == ID_MDCONT) { +		} else if (g_InvDragging == ID_MDCONT) {  			SlideMSlider(0, S_END); -		} else if (InvDragging == ID_MOVE) { +		} else if (g_InvDragging == ID_MOVE) {  			;	// No action  		} else {  			// Were re-sizing. Redraw the whole thing. @@ -4834,21 +4823,21 @@ static void InvDragEnd() {  			ConstructInventory(FULL);  			// If this was the maximised, it no longer is! -			if (InventoryMaximised) { -				InventoryMaximised = false; -				InvD[ino].otherX = InvD[ino].inventoryX; -				InvD[ino].otherY = InvD[ino].inventoryY; +			if (g_InventoryMaximised) { +				g_InventoryMaximised = false; +				g_InvD[g_ino].otherX = g_InvD[g_ino].inventoryX; +				g_InvD[g_ino].otherY = g_InvD[g_ino].inventoryY;  			}  		} -		InvDragging = ID_NONE; +		g_InvDragging = ID_NONE;  		ProcessedProvisional();  	}  	// Cursor could well now be inappropriate  	InvCursor(IC_AREA, curX, curY); -	Xchange = Ychange = 0;		// Probably no need, but does no harm! +	g_Xchange = g_Ychange = 0;		// Probably no need, but does no harm!  }  static void MenuPageDown() { @@ -4860,7 +4849,7 @@ static void MenuPageDown() {  			Select(cd.selBox, true);  		}  	} else if (cd.box == hopperBox1) { -		if (cd.extraBase < numScenes - NUM_RGROUP_BOXES) { +		if (cd.extraBase < g_numScenes - NUM_RGROUP_BOXES) {  			FirstScene(cd.extraBase + (NUM_RGROUP_BOXES - 1));  			AddBoxes(true);  			if (cd.selBox) @@ -4868,7 +4857,7 @@ static void MenuPageDown() {  			Select(cd.selBox, true);  		}  	} else if (cd.box == hopperBox2) { -		if (cd.extraBase < numEntries - NUM_RGROUP_BOXES) { +		if (cd.extraBase < g_numEntries - NUM_RGROUP_BOXES) {  			FirstEntry(cd.extraBase+(NUM_RGROUP_BOXES - 1));  			AddBoxes(true);  			if (cd.selBox) @@ -5010,7 +4999,7 @@ static void ConfActionSpecial(int i) {  				Select(cd.selBox, true);  			}  		} else if (cd.box == hopperBox1) { -			if (cd.extraBase < numScenes - NUM_RGROUP_BOXES) { +			if (cd.extraBase < g_numScenes - NUM_RGROUP_BOXES) {  				FirstScene(cd.extraBase + 1);  				AddBoxes(true);  				if (cd.selBox) @@ -5018,7 +5007,7 @@ static void ConfActionSpecial(int i) {  				Select(cd.selBox, true);  			}  		} else if (cd.box == hopperBox2) { -			if (cd.extraBase < numEntries - NUM_RGROUP_BOXES) { +			if (cd.extraBase < g_numEntries - NUM_RGROUP_BOXES) {  				FirstEntry(cd.extraBase + 1);  				AddBoxes(true);  				if (cd.selBox) @@ -5045,25 +5034,25 @@ static void InvPutDown(int index) {  	int hiIndex;	// Current position of held item (if in)  	// Find where the held item is positioned in this inventory (if it is) -	for (hiIndex = 0; hiIndex < InvD[ino].NoofItems; hiIndex++) -		if (InvD[ino].contents[hiIndex] == HeldItem) +	for (hiIndex = 0; hiIndex < g_InvD[g_ino].NoofItems; hiIndex++) +		if (g_InvD[g_ino].contents[hiIndex] == g_heldItem)  			break;  	// If drop position would leave a gap, move it up -	if (index >= InvD[ino].NoofItems) { -		if (hiIndex == InvD[ino].NoofItems)	// Not in, add it -			index = InvD[ino].NoofItems; +	if (index >= g_InvD[g_ino].NoofItems) { +		if (hiIndex == g_InvD[g_ino].NoofItems)	// Not in, add it +			index = g_InvD[g_ino].NoofItems;  		else -			index = InvD[ino].NoofItems - 1; +			index = g_InvD[g_ino].NoofItems - 1;  	} -	if (hiIndex == InvD[ino].NoofItems) {	// Not in, add it -		if (InvD[ino].NoofItems < InvD[ino].MaxInvObj) { -			InvD[ino].NoofItems++; +	if (hiIndex == g_InvD[g_ino].NoofItems) {	// Not in, add it +		if (g_InvD[g_ino].NoofItems < g_InvD[g_ino].MaxInvObj) { +			g_InvD[g_ino].NoofItems++;  			// Don't leave it in the other inventory! -			if (InventoryPos(HeldItem) != INV_HELDNOTIN) -				RemFromInventory(ino == INV_1 ? INV_2 : INV_1, HeldItem); +			if (InventoryPos(g_heldItem) != INV_HELDNOTIN) +				RemFromInventory(g_ino == INV_1 ? INV_2 : INV_1, g_heldItem);  		} else {  			// No room at the inn!  			return; @@ -5072,17 +5061,17 @@ static void InvPutDown(int index) {  	// Position it in the inventory  	if (index < hiIndex) { -		memmove(&InvD[ino].contents[index + 1], &InvD[ino].contents[index], (hiIndex-index)*sizeof(int)); -		InvD[ino].contents[index] = HeldItem; +		memmove(&g_InvD[g_ino].contents[index + 1], &g_InvD[g_ino].contents[index], (hiIndex-index)*sizeof(int)); +		g_InvD[g_ino].contents[index] = g_heldItem;  	} else if (index > hiIndex) { -		memmove(&InvD[ino].contents[hiIndex], &InvD[ino].contents[hiIndex+1], (index-hiIndex)*sizeof(int)); -		InvD[ino].contents[index] = HeldItem; +		memmove(&g_InvD[g_ino].contents[hiIndex], &g_InvD[g_ino].contents[hiIndex+1], (index-hiIndex)*sizeof(int)); +		g_InvD[g_ino].contents[index] = g_heldItem;  	} else { -		InvD[ino].contents[index] = HeldItem; +		g_InvD[g_ino].contents[index] = g_heldItem;  	} -	HeldItem = INV_NOICON; -	ItemsChanged = true; +	g_heldItem = INV_NOICON; +	g_ItemsChanged = true;  	DelAuxCursor();  	RestoreMainCursor();  	GetCursorXY(&aniX, &aniY, false); @@ -5116,26 +5105,26 @@ static void InvPickup(int index) {  		return;  	// If not holding anything -	if (HeldItem == INV_NOICON && InvD[ino].contents[index] && -			(!TinselV2 || InvD[ino].contents[index] != HeldItem)) { +	if (g_heldItem == INV_NOICON && g_InvD[g_ino].contents[index] && +			(!TinselV2 || g_InvD[g_ino].contents[index] != g_heldItem)) {  		// Pick-up -		invObj = GetInvObject(InvD[ino].contents[index]); -		thisIcon = InvD[ino].contents[index]; +		invObj = GetInvObject(g_InvD[g_ino].contents[index]); +		g_thisIcon = g_InvD[g_ino].contents[index];  		if (TinselV2)  			InvTinselEvent(invObj, PICKUP, INV_PICKUP, index);  		else if (invObj->hScript)  			InvTinselEvent(invObj, WALKTO, INV_PICKUP, index); -	} else if (HeldItem != INV_NOICON) { +	} else if (g_heldItem != INV_NOICON) {  		// Put-down -		invObj = GetInvObject(HeldItem); +		invObj = GetInvObject(g_heldItem);  		// If DROPCODE set, send event, otherwise it's a putdown  		if (invObj->attribute & IO_DROPCODE && invObj->hScript)  			InvTinselEvent(invObj, PUTDOWN, INV_PICKUP, index); -		else if (!(invObj->attribute & IO_ONLYINV1 && ino != INV_1) -				&& !(invObj->attribute & IO_ONLYINV2 && ino != INV_2)) { +		else if (!(invObj->attribute & IO_ONLYINV1 && g_ino != INV_1) +				&& !(invObj->attribute & IO_ONLYINV2 && g_ino != INV_2)) {  			if (TinselV2)  				InvPutDown(index);  			else @@ -5152,7 +5141,7 @@ static void InvWalkTo(const Common::Point &coOrds) {  	switch (InvArea(coOrds.x, coOrds.y)) {  	case I_NOTIN: -		if (ino == INV_CONV) +		if (g_ino == INV_CONV)  			ConvAction(INV_CLOSEICON);  		if ((cd.box == hopperBox1) || (cd.box == hopperBox2))  			FreeSceneHopper(); @@ -5160,43 +5149,43 @@ static void InvWalkTo(const Common::Point &coOrds) {  		break;  	case I_SLIDE_UP: -		if (InvD[ino].NoofVicons == 1) -			InvD[ino].FirstDisp -= InvD[ino].NoofHicons; -		for (i = 1; i < InvD[ino].NoofVicons; i++) -			InvD[ino].FirstDisp -= InvD[ino].NoofHicons; -		if (InvD[ino].FirstDisp < 0) -			InvD[ino].FirstDisp = 0; -		ItemsChanged = true; +		if (g_InvD[g_ino].NoofVicons == 1) +			g_InvD[g_ino].FirstDisp -= g_InvD[g_ino].NoofHicons; +		for (i = 1; i < g_InvD[g_ino].NoofVicons; i++) +			g_InvD[g_ino].FirstDisp -= g_InvD[g_ino].NoofHicons; +		if (g_InvD[g_ino].FirstDisp < 0) +			g_InvD[g_ino].FirstDisp = 0; +		g_ItemsChanged = true;  		break;  	case I_UP: -		InvD[ino].FirstDisp -= InvD[ino].NoofHicons; -		if (InvD[ino].FirstDisp < 0) -			InvD[ino].FirstDisp = 0; -		ItemsChanged = true; +		g_InvD[g_ino].FirstDisp -= g_InvD[g_ino].NoofHicons; +		if (g_InvD[g_ino].FirstDisp < 0) +			g_InvD[g_ino].FirstDisp = 0; +		g_ItemsChanged = true;  		break;  	case I_SLIDE_DOWN: -		if (InvD[ino].NoofVicons == 1) -			if (InvD[ino].FirstDisp + InvD[ino].NoofHicons*InvD[ino].NoofVicons < InvD[ino].NoofItems) -				InvD[ino].FirstDisp += InvD[ino].NoofHicons; -		for (i = 1; i < InvD[ino].NoofVicons; i++) { -			if (InvD[ino].FirstDisp + InvD[ino].NoofHicons*InvD[ino].NoofVicons < InvD[ino].NoofItems) -				InvD[ino].FirstDisp += InvD[ino].NoofHicons; +		if (g_InvD[g_ino].NoofVicons == 1) +			if (g_InvD[g_ino].FirstDisp + g_InvD[g_ino].NoofHicons*g_InvD[g_ino].NoofVicons < g_InvD[g_ino].NoofItems) +				g_InvD[g_ino].FirstDisp += g_InvD[g_ino].NoofHicons; +		for (i = 1; i < g_InvD[g_ino].NoofVicons; i++) { +			if (g_InvD[g_ino].FirstDisp + g_InvD[g_ino].NoofHicons*g_InvD[g_ino].NoofVicons < g_InvD[g_ino].NoofItems) +				g_InvD[g_ino].FirstDisp += g_InvD[g_ino].NoofHicons;  		} -		ItemsChanged = true; +		g_ItemsChanged = true;  		break;  	case I_DOWN: -		if (InvD[ino].FirstDisp + InvD[ino].NoofHicons*InvD[ino].NoofVicons < InvD[ino].NoofItems) { -			InvD[ino].FirstDisp += InvD[ino].NoofHicons; -			ItemsChanged = true; +		if (g_InvD[g_ino].FirstDisp + g_InvD[g_ino].NoofHicons*g_InvD[g_ino].NoofVicons < g_InvD[g_ino].NoofItems) { +			g_InvD[g_ino].FirstDisp += g_InvD[g_ino].NoofHicons; +			g_ItemsChanged = true;  		}  		break;  	case I_BODY: -		if (ino == INV_CONF) { -			if (!InventoryHidden) +		if (g_ino == INV_CONF) { +			if (!g_InventoryHidden)  				MenuAction(WhichMenuBox(coOrds.x, coOrds.y, false), false);  		} else {  			Common::Point pt = coOrds; @@ -5204,8 +5193,8 @@ static void InvWalkTo(const Common::Point &coOrds) {  			// To cater for drop in dead space between icons,  			// look 1 pixel right, then 1 down, then 1 right and down. -			if (i == INV_NOICON && HeldItem != INV_NOICON && -					(ino == INV_1 || ino == INV_2)) { +			if (i == INV_NOICON && g_heldItem != INV_NOICON && +					(g_ino == INV_1 || g_ino == INV_2)) {  				pt.x += 1;				// 1 to the right  				i = InvItem(pt, false);  				if (i == INV_NOICON) { @@ -5219,7 +5208,7 @@ static void InvWalkTo(const Common::Point &coOrds) {  				}  			} -			if (ino == INV_CONV) { +			if (g_ino == INV_CONV) {  				ConvAction(i);  			} else  				InvPickup(i); @@ -5238,19 +5227,19 @@ static void InvAction() {  	switch (InvArea(aniX, aniY)) {  	case I_BODY: -		if (ino == INV_CONF) { -			if (!InventoryHidden) +		if (g_ino == INV_CONF) { +			if (!g_InventoryHidden)  				MenuAction(WhichMenuBox(aniX, aniY, false), true); -		} else if (ino == INV_CONV) { +		} else if (g_ino == INV_CONV) {  			index = InvItem(&aniX, &aniY, false);  			ConvAction(index);  		} else {  			index = InvItem(&aniX, &aniY, false);  			if (index != INV_NOICON) { -				if (InvD[ino].contents[index] && InvD[ino].contents[index] != HeldItem) { -					invObj = GetInvObject(InvD[ino].contents[index]); +				if (g_InvD[g_ino].contents[index] && g_InvD[g_ino].contents[index] != g_heldItem) { +					invObj = GetInvObject(g_InvD[g_ino].contents[index]);  					if (TinselV2) -						thisIcon = InvD[ino].contents[index]; +						g_thisIcon = g_InvD[g_ino].contents[index];  					if (TinselV2 || (invObj->hScript))  						InvTinselEvent(invObj, ACTION, INV_ACTION, index);  				} @@ -5259,33 +5248,33 @@ static void InvAction() {  		break;  	case I_HEADER:	// Maximise/unmaximise inventory -		if (!InvD[ino].resizable) +		if (!g_InvD[g_ino].resizable)  			break; -		if (!InventoryMaximised) { -			InvD[ino].sNoofHicons = InvD[ino].NoofHicons; -			InvD[ino].sNoofVicons = InvD[ino].NoofVicons; -			InvD[ino].NoofHicons = InvD[ino].MaxHicons; -			InvD[ino].NoofVicons = InvD[ino].MaxVicons; -			InventoryMaximised = true; - -			i = InvD[ino].inventoryX; -			InvD[ino].inventoryX = InvD[ino].otherX; -			InvD[ino].otherX = i; -			i = InvD[ino].inventoryY; -			InvD[ino].inventoryY = InvD[ino].otherY; -			InvD[ino].otherY = i; +		if (!g_InventoryMaximised) { +			g_InvD[g_ino].sNoofHicons = g_InvD[g_ino].NoofHicons; +			g_InvD[g_ino].sNoofVicons = g_InvD[g_ino].NoofVicons; +			g_InvD[g_ino].NoofHicons = g_InvD[g_ino].MaxHicons; +			g_InvD[g_ino].NoofVicons = g_InvD[g_ino].MaxVicons; +			g_InventoryMaximised = true; + +			i = g_InvD[g_ino].inventoryX; +			g_InvD[g_ino].inventoryX = g_InvD[g_ino].otherX; +			g_InvD[g_ino].otherX = i; +			i = g_InvD[g_ino].inventoryY; +			g_InvD[g_ino].inventoryY = g_InvD[g_ino].otherY; +			g_InvD[g_ino].otherY = i;  		} else { -			InvD[ino].NoofHicons = InvD[ino].sNoofHicons; -			InvD[ino].NoofVicons = InvD[ino].sNoofVicons; -			InventoryMaximised = false; - -			i = InvD[ino].inventoryX; -			InvD[ino].inventoryX = InvD[ino].otherX; -			InvD[ino].otherX = i; -			i = InvD[ino].inventoryY; -			InvD[ino].inventoryY = InvD[ino].otherY; -			InvD[ino].otherY = i; +			g_InvD[g_ino].NoofHicons = g_InvD[g_ino].sNoofHicons; +			g_InvD[g_ino].NoofVicons = g_InvD[g_ino].sNoofVicons; +			g_InventoryMaximised = false; + +			i = g_InvD[g_ino].inventoryX; +			g_InvD[g_ino].inventoryX = g_InvD[g_ino].otherX; +			g_InvD[g_ino].otherX = i; +			i = g_InvD[g_ino].inventoryY; +			g_InvD[g_ino].inventoryY = g_InvD[g_ino].otherY; +			g_InvD[g_ino].otherY = i;  		}  		// Delete current, and re-draw @@ -5295,15 +5284,15 @@ static void InvAction() {  		break;  	case I_UP: -		InvD[ino].FirstDisp -= InvD[ino].NoofHicons; -		if (InvD[ino].FirstDisp < 0) -			InvD[ino].FirstDisp = 0; -		ItemsChanged = true; +		g_InvD[g_ino].FirstDisp -= g_InvD[g_ino].NoofHicons; +		if (g_InvD[g_ino].FirstDisp < 0) +			g_InvD[g_ino].FirstDisp = 0; +		g_ItemsChanged = true;  		break;  	case I_DOWN: -		if (InvD[ino].FirstDisp + InvD[ino].NoofHicons*InvD[ino].NoofVicons < InvD[ino].NoofItems) { -			InvD[ino].FirstDisp += InvD[ino].NoofHicons; -			ItemsChanged = true; +		if (g_InvD[g_ino].FirstDisp + g_InvD[g_ino].NoofHicons*g_InvD[g_ino].NoofVicons < g_InvD[g_ino].NoofItems) { +			g_InvD[g_ino].FirstDisp += g_InvD[g_ino].NoofHicons; +			g_ItemsChanged = true;  		}  		break;  	} @@ -5319,8 +5308,8 @@ static void InvLook(const Common::Point &coOrds) {  	case I_BODY:  		index = InvItem(pt, false);  		if (index != INV_NOICON) { -			if (InvD[ino].contents[index] && InvD[ino].contents[index] != HeldItem) { -				invObj = GetInvObject(InvD[ino].contents[index]); +			if (g_InvD[g_ino].contents[index] && g_InvD[g_ino].contents[index] != g_heldItem) { +				invObj = GetInvObject(g_InvD[g_ino].contents[index]);  				if (invObj->hScript)  					InvTinselEvent(invObj, LOOK, INV_LOOK, index);  			} @@ -5328,7 +5317,7 @@ static void InvLook(const Common::Point &coOrds) {  		break;  	case I_NOTIN: -		if (ino == INV_CONV) +		if (g_ino == INV_CONV)  			ConvAction(INV_CLOSEICON);  		KillInventory();  		break; @@ -5341,7 +5330,7 @@ static void InvLook(const Common::Point &coOrds) {  /**************************************************************************/  extern void EventToInventory(PLR_EVENT pEvent, const Common::Point &coOrds) { -	if (InventoryHidden) +	if (g_InventoryHidden)  		return;  	switch (pEvent) { @@ -5364,7 +5353,7 @@ extern void EventToInventory(PLR_EVENT pEvent, const Common::Point &coOrds) {  		break;  	case PLR_ACTION:		// PLR_DLEFT -		if (InvDragging != ID_MDCONT) +		if (g_InvDragging != ID_MDCONT)  			InvDragEnd();  		InvAction();  		break; @@ -5380,7 +5369,7 @@ extern void EventToInventory(PLR_EVENT pEvent, const Common::Point &coOrds) {  	case PLR_ESCAPE:  		if (MenuActive()) {  			if (cd.box != optionBox && cd.box != hopperBox1 && cd.box != hopperBox2) -				bReOpenMenu = true; +				g_bReOpenMenu = true;  			if ((cd.box == hopperBox1) || (cd.box == hopperBox2))  				FreeSceneHopper();  		} @@ -5388,42 +5377,42 @@ extern void EventToInventory(PLR_EVENT pEvent, const Common::Point &coOrds) {  		break;  	case PLR_PGDN: -		if (ino == INV_MENU) { +		if (g_ino == INV_MENU) {  			// Only act if load or save screen  			MenuPageDown();  		} else {  			// This code is a copy of the IB_SLIDE_DOWN case in InvWalkTo  			// TODO: So share this duplicate code -			if (InvD[ino].NoofVicons == 1) -				if (InvD[ino].FirstDisp + InvD[ino].NoofHicons*InvD[ino].NoofVicons < InvD[ino].NoofItems) -					InvD[ino].FirstDisp += InvD[ino].NoofHicons; -			for (int i = 1; i < InvD[ino].NoofVicons; i++) { -				if (InvD[ino].FirstDisp + InvD[ino].NoofHicons*InvD[ino].NoofVicons < InvD[ino].NoofItems) -					InvD[ino].FirstDisp += InvD[ino].NoofHicons; +			if (g_InvD[g_ino].NoofVicons == 1) +				if (g_InvD[g_ino].FirstDisp + g_InvD[g_ino].NoofHicons*g_InvD[g_ino].NoofVicons < g_InvD[g_ino].NoofItems) +					g_InvD[g_ino].FirstDisp += g_InvD[g_ino].NoofHicons; +			for (int i = 1; i < g_InvD[g_ino].NoofVicons; i++) { +				if (g_InvD[g_ino].FirstDisp + g_InvD[g_ino].NoofHicons*g_InvD[g_ino].NoofVicons < g_InvD[g_ino].NoofItems) +					g_InvD[g_ino].FirstDisp += g_InvD[g_ino].NoofHicons;  			} -			ItemsChanged = true; +			g_ItemsChanged = true;  		}  		break;  	case PLR_PGUP: -		if (ino == INV_MENU) { +		if (g_ino == INV_MENU) {  			// Only act if load or save screen  			MenuPageUp();  		} else {  			// This code is a copy of the I_SLIDE_UP case in InvWalkTo  			// TODO: So share this duplicate code -			if (InvD[ino].NoofVicons == 1) -				InvD[ino].FirstDisp -= InvD[ino].NoofHicons; -			for (int i = 1; i < InvD[ino].NoofVicons; i++) -				InvD[ino].FirstDisp -= InvD[ino].NoofHicons; -			if (InvD[ino].FirstDisp < 0) -				InvD[ino].FirstDisp = 0; -			ItemsChanged = true; +			if (g_InvD[g_ino].NoofVicons == 1) +				g_InvD[g_ino].FirstDisp -= g_InvD[g_ino].NoofHicons; +			for (int i = 1; i < g_InvD[g_ino].NoofVicons; i++) +				g_InvD[g_ino].FirstDisp -= g_InvD[g_ino].NoofHicons; +			if (g_InvD[g_ino].FirstDisp < 0) +				g_InvD[g_ino].FirstDisp = 0; +			g_ItemsChanged = true;  		}  		break;  	case PLR_HOME: -		if (ino == INV_MENU) { +		if (g_ino == INV_MENU) {  			// Only act if load or save screen  			if (cd.box == loadBox || cd.box == saveBox)  				FirstFile(0); @@ -5438,19 +5427,19 @@ extern void EventToInventory(PLR_EVENT pEvent, const Common::Point &coOrds) {  			cd.selBox = 0;  			Select(cd.selBox, true);  		} else { -			InvD[ino].FirstDisp = 0; -			ItemsChanged = true; +			g_InvD[g_ino].FirstDisp = 0; +			g_ItemsChanged = true;  		}  		break;  	case PLR_END: -		if (ino == INV_MENU) { +		if (g_ino == INV_MENU) {  			if (cd.box == loadBox || cd.box == saveBox)  				FirstFile(MAX_SAVED_FILES);	// Will get reduced to appropriate value  			else if (cd.box == hopperBox1) -				FirstScene(numScenes);		// Will get reduced to appropriate value +				FirstScene(g_numScenes);		// Will get reduced to appropriate value  			else if (cd.box == hopperBox2) -				FirstEntry(numEntries);		// Will get reduced to appropriate value +				FirstEntry(g_numEntries);		// Will get reduced to appropriate value  			else  				break; @@ -5458,10 +5447,10 @@ extern void EventToInventory(PLR_EVENT pEvent, const Common::Point &coOrds) {  			cd.selBox = 0;  			Select(cd.selBox, true);  		} else { -			InvD[ino].FirstDisp = InvD[ino].NoofItems - InvD[ino].NoofHicons*InvD[ino].NoofVicons; -			if (InvD[ino].FirstDisp < 0) -				InvD[ino].FirstDisp = 0; -			ItemsChanged = true; +			g_InvD[g_ino].FirstDisp = g_InvD[g_ino].NoofItems - g_InvD[g_ino].NoofHicons*g_InvD[g_ino].NoofVicons; +			if (g_InvD[g_ino].FirstDisp < 0) +				g_InvD[g_ino].FirstDisp = 0; +			g_ItemsChanged = true;  		}  		break;  	default: @@ -5483,8 +5472,8 @@ extern void SetObjectFilm(int object, SCNHANDLE hFilm) {  	invObj = GetInvObject(object);  	invObj->hIconFilm = hFilm; -	if (HeldItem != object) -		ItemsChanged = true; +	if (g_heldItem != object) +		g_ItemsChanged = true;  }  /** @@ -5492,34 +5481,34 @@ extern void SetObjectFilm(int object, SCNHANDLE hFilm) {   */  extern void syncInvInfo(Common::Serializer &s) {  	for (int i = 0; i < NUM_INV; i++) { -		s.syncAsSint32LE(InvD[i].MinHicons); -		s.syncAsSint32LE(InvD[i].MinVicons); -		s.syncAsSint32LE(InvD[i].MaxHicons); -		s.syncAsSint32LE(InvD[i].MaxVicons); -		s.syncAsSint32LE(InvD[i].NoofHicons); -		s.syncAsSint32LE(InvD[i].NoofVicons); +		s.syncAsSint32LE(g_InvD[i].MinHicons); +		s.syncAsSint32LE(g_InvD[i].MinVicons); +		s.syncAsSint32LE(g_InvD[i].MaxHicons); +		s.syncAsSint32LE(g_InvD[i].MaxVicons); +		s.syncAsSint32LE(g_InvD[i].NoofHicons); +		s.syncAsSint32LE(g_InvD[i].NoofVicons);  		for (int j = 0; j < MAX_ININV; j++) { -			s.syncAsSint32LE(InvD[i].contents[j]); +			s.syncAsSint32LE(g_InvD[i].contents[j]);  		} -		s.syncAsSint32LE(InvD[i].NoofItems); -		s.syncAsSint32LE(InvD[i].FirstDisp); -		s.syncAsSint32LE(InvD[i].inventoryX); -		s.syncAsSint32LE(InvD[i].inventoryY); -		s.syncAsSint32LE(InvD[i].otherX); -		s.syncAsSint32LE(InvD[i].otherY); -		s.syncAsSint32LE(InvD[i].MaxInvObj); -		s.syncAsSint32LE(InvD[i].hInvTitle); -		s.syncAsSint32LE(InvD[i].resizable); -		s.syncAsSint32LE(InvD[i].bMoveable); -		s.syncAsSint32LE(InvD[i].sNoofHicons); -		s.syncAsSint32LE(InvD[i].sNoofVicons); -		s.syncAsSint32LE(InvD[i].bMax); +		s.syncAsSint32LE(g_InvD[i].NoofItems); +		s.syncAsSint32LE(g_InvD[i].FirstDisp); +		s.syncAsSint32LE(g_InvD[i].inventoryX); +		s.syncAsSint32LE(g_InvD[i].inventoryY); +		s.syncAsSint32LE(g_InvD[i].otherX); +		s.syncAsSint32LE(g_InvD[i].otherY); +		s.syncAsSint32LE(g_InvD[i].MaxInvObj); +		s.syncAsSint32LE(g_InvD[i].hInvTitle); +		s.syncAsSint32LE(g_InvD[i].resizable); +		s.syncAsSint32LE(g_InvD[i].bMoveable); +		s.syncAsSint32LE(g_InvD[i].sNoofHicons); +		s.syncAsSint32LE(g_InvD[i].sNoofVicons); +		s.syncAsSint32LE(g_InvD[i].bMax);  	}  	if (TinselV2) { -		for (int i = 0; i < numObjects; ++i) -			s.syncAsUint32LE(invFilms[i]); -		s.syncAsUint32LE(heldFilm); +		for (int i = 0; i < g_numObjects; ++i) +			s.syncAsUint32LE(g_invFilms[i]); +		s.syncAsUint32LE(g_heldFilm);  	}  } @@ -5533,18 +5522,18 @@ extern void syncInvInfo(Common::Serializer &s) {   */  // Note: the SCHANDLE type here has been changed to a void*  extern void RegisterIcons(void *cptr, int num) { -	numObjects = num; -	invObjects = (INV_OBJECT *) cptr; +	g_numObjects = num; +	g_invObjects = (INV_OBJECT *) cptr;  	if (TinselV0) {  		// In Tinsel 0, the INV_OBJECT structure doesn't have an attributes field, so we  		// need to 'unpack' the source structures into the standard Tinsel v1/v2 format -		MEM_NODE *node = MemoryAllocFixed(numObjects * sizeof(INV_OBJECT)); +		MEM_NODE *node = MemoryAllocFixed(g_numObjects * sizeof(INV_OBJECT));  		assert(node); -		invObjects = (INV_OBJECT *)MemoryDeref(node); -		assert(invObjects); +		g_invObjects = (INV_OBJECT *)MemoryDeref(node); +		assert(g_invObjects);  		byte *srcP = (byte *)cptr; -		INV_OBJECT *destP = (INV_OBJECT *)invObjects; +		INV_OBJECT *destP = (INV_OBJECT *)g_invObjects;  		for (int i = 0; i < num; ++i, ++destP, srcP += 12) {  			memmove(destP, srcP, 12); @@ -5552,12 +5541,12 @@ extern void RegisterIcons(void *cptr, int num) {  		}  	} else if (TinselV1Mac) {  		// Macintosh version has BE encoded resources, so the values need to be byte swapped -		MEM_NODE *node = MemoryAllocFixed(numObjects * sizeof(INV_OBJECT)); +		MEM_NODE *node = MemoryAllocFixed(g_numObjects * sizeof(INV_OBJECT));  		assert(node); -		invObjects = (INV_OBJECT *)MemoryDeref(node); -		assert(invObjects); +		g_invObjects = (INV_OBJECT *)MemoryDeref(node); +		assert(g_invObjects);  		INV_OBJECT *srcP = (INV_OBJECT *)cptr; -		INV_OBJECT *destP = (INV_OBJECT *)invObjects; +		INV_OBJECT *destP = (INV_OBJECT *)g_invObjects;  		for (int i = 0; i < num; ++i, ++destP, ++srcP) {  			destP->id = FROM_BE_32(srcP->id); @@ -5566,14 +5555,14 @@ extern void RegisterIcons(void *cptr, int num) {  			destP->attribute = FROM_BE_32(srcP->attribute);  		}  	} else if (TinselV2) { -		if (invFilms == NULL) { +		if (g_invFilms == NULL) {  			// First time - allocate memory -			MEM_NODE *node = MemoryAllocFixed(numObjects * sizeof(SCNHANDLE)); +			MEM_NODE *node = MemoryAllocFixed(g_numObjects * sizeof(SCNHANDLE));  			assert(node); -			invFilms = (SCNHANDLE *)MemoryDeref(node); -			if (invFilms == NULL) +			g_invFilms = (SCNHANDLE *)MemoryDeref(node); +			if (g_invFilms == NULL)  				error(NO_MEM, "inventory scripts"); -			memset(invFilms, 0, numObjects * sizeof(SCNHANDLE)); +			memset(g_invFilms, 0, g_numObjects * sizeof(SCNHANDLE));  		} @@ -5581,11 +5570,11 @@ extern void RegisterIcons(void *cptr, int num) {  		// and store all the films separately  		int i;  		INV_OBJECT *pio; -		for (i = 0, pio = invObjects; i < numObjects; i++, pio++) { +		for (i = 0, pio = g_invObjects; i < g_numObjects; i++, pio++) {  			if (pio->attribute & PERMACONV)  				PermaConvIcon(pio->id, pio->attribute & CONVENDITEM); -			invFilms[i] = pio->hIconFilm; +			g_invFilms[i] = pio->hIconFilm;  		}  	}  } @@ -5599,7 +5588,7 @@ extern void setInvWinParts(SCNHANDLE hf) {  	const FILM *pfilm;  #endif -	hWinParts = hf; +	g_hWinParts = hf;  #ifdef DEBUG  	pfilm = (const FILM *)LockMem(hf); @@ -5616,7 +5605,7 @@ extern void setFlagFilms(SCNHANDLE hf) {  	const FILM *pfilm;  #endif -	flagFilm = hf; +	g_flagFilm = hf;  #ifdef DEBUG  	pfilm = (const FILM *)LockMem(hf); @@ -5628,7 +5617,7 @@ extern void setFlagFilms(SCNHANDLE hf) {   * Called from Glitter function 'DecCStrings()'   */  extern void setConfigStrings(SCNHANDLE *tp) { -	memcpy(configStrings, tp, sizeof(configStrings)); +	memcpy(g_configStrings, tp, sizeof(g_configStrings));  }  /** @@ -5652,36 +5641,36 @@ extern void idec_inv(int num, SCNHANDLE text, int MaxContents,  	if (StartHeight > MaxHeight)  		StartHeight = MaxHeight; -	InventoryState = IDLE_INV; +	g_InventoryState = IDLE_INV; -	InvD[num].MaxHicons = MaxWidth; -	InvD[num].MinHicons = MinWidth; -	InvD[num].MaxVicons = MaxHeight; -	InvD[num].MinVicons = MinHeight; +	g_InvD[num].MaxHicons = MaxWidth; +	g_InvD[num].MinHicons = MinWidth; +	g_InvD[num].MaxVicons = MaxHeight; +	g_InvD[num].MinVicons = MinHeight; -	InvD[num].NoofHicons = StartWidth; -	InvD[num].NoofVicons = StartHeight; +	g_InvD[num].NoofHicons = StartWidth; +	g_InvD[num].NoofVicons = StartHeight; -	memset(InvD[num].contents, 0, sizeof(InvD[num].contents)); -	InvD[num].NoofItems = 0; +	memset(g_InvD[num].contents, 0, sizeof(g_InvD[num].contents)); +	g_InvD[num].NoofItems = 0; -	InvD[num].FirstDisp = 0; +	g_InvD[num].FirstDisp = 0; -	InvD[num].inventoryX = startx; -	InvD[num].inventoryY = starty; -	InvD[num].otherX = 21; -	InvD[num].otherY = 15; +	g_InvD[num].inventoryX = startx; +	g_InvD[num].inventoryY = starty; +	g_InvD[num].otherX = 21; +	g_InvD[num].otherY = 15; -	InvD[num].MaxInvObj = MaxContents; +	g_InvD[num].MaxInvObj = MaxContents; -	InvD[num].hInvTitle = text; +	g_InvD[num].hInvTitle = text;  	if (MaxWidth != MinWidth && MaxHeight != MinHeight) -		InvD[num].resizable = true; +		g_InvD[num].resizable = true; -	InvD[num].bMoveable = moveable; +	g_InvD[num].bMoveable = moveable; -	InvD[num].bMax = false; +	g_InvD[num].bMax = false;  }  /** @@ -5729,7 +5718,7 @@ extern void idec_inv2(SCNHANDLE text, int MaxContents,  extern int InvGetLimit(int invno) {  	assert(invno == INV_1 || invno == INV_2); // only INV_1 and INV_2 supported -	return InvD[invno].MaxInvObj; +	return g_InvD[invno].MaxInvObj;  }  /** @@ -5737,12 +5726,12 @@ extern int InvGetLimit(int invno) {   */  extern void InvSetLimit(int invno, int MaxContents) {  	assert(invno == INV_1 || invno == INV_2); // only INV_1 and INV_2 supported -	assert(MaxContents >= InvD[invno].NoofItems); // can't reduce maximum contents below current contents +	assert(MaxContents >= g_InvD[invno].NoofItems); // can't reduce maximum contents below current contents  	if (MaxContents > MAX_ININV)  		MaxContents = MAX_ININV;	// Max contents -	InvD[invno].MaxInvObj = MaxContents; +	g_InvD[invno].MaxInvObj = MaxContents;  }  /** @@ -5757,34 +5746,34 @@ extern void InvSetSize(int invno, int MinWidth, int MinHeight,  	if (StartHeight > MaxHeight)  		StartHeight = MaxHeight; -	InvD[invno].MaxHicons = MaxWidth; -	InvD[invno].MinHicons = MinWidth; -	InvD[invno].MaxVicons = MaxHeight; -	InvD[invno].MinVicons = MinHeight; +	g_InvD[invno].MaxHicons = MaxWidth; +	g_InvD[invno].MinHicons = MinWidth; +	g_InvD[invno].MaxVicons = MaxHeight; +	g_InvD[invno].MinVicons = MinHeight; -	InvD[invno].NoofHicons = StartWidth; -	InvD[invno].NoofVicons = StartHeight; +	g_InvD[invno].NoofHicons = StartWidth; +	g_InvD[invno].NoofVicons = StartHeight;  	if (MaxWidth != MinWidth && MaxHeight != MinHeight) -		InvD[invno].resizable = true; +		g_InvD[invno].resizable = true;  	else -		InvD[invno].resizable = false; +		g_InvD[invno].resizable = false; -	InvD[invno].bMax = false; +	g_InvD[invno].bMax = false;  }  /**************************************************************************/  extern bool IsTopWindow() { -	return (InventoryState == BOGUS_INV); +	return (g_InventoryState == BOGUS_INV);  }  extern bool MenuActive() { -	return (InventoryState == ACTIVE_INV && ino == INV_CONF); +	return (g_InventoryState == ACTIVE_INV && g_ino == INV_CONF);  }  extern bool IsConvWindow() { -	return (InventoryState == ACTIVE_INV && ino == INV_CONV); +	return (g_InventoryState == ACTIVE_INV && g_ino == INV_CONV);  }  } // End of namespace Tinsel diff --git a/engines/tinsel/drives.cpp b/engines/tinsel/drives.cpp index 5977d3b718..d815fd165d 100644 --- a/engines/tinsel/drives.cpp +++ b/engines/tinsel/drives.cpp @@ -32,13 +32,13 @@ namespace Tinsel {  // FIXME: Avoid non-const global vars -char currentCD = '1'; +char g_currentCD = '1'; -static bool bChangingCD = false; -static char nextCD = '\0'; +static bool g_bChangingCD = false; +static char g_nextCD = '\0'; -static uint32 lastTime = 0; -extern LANGUAGE sampleLanguage; +static uint32 g_lastTime = 0; +extern LANGUAGE g_sampleLanguage;  void CdCD(CORO_PARAM) { @@ -47,7 +47,7 @@ void CdCD(CORO_PARAM) {  	CORO_BEGIN_CODE(_ctx); -	while (bChangingCD) { +	while (g_bChangingCD) {  		if (g_scheduler->getCurrentProcess()) {  			// FIXME: CdCD gets passed a nullContext in RegisterGlobals() and  			//        PrimeSceneHopper(), because I didn't know how to get a proper @@ -66,13 +66,13 @@ void CdCD(CORO_PARAM) {  int GetCurrentCD() {  	// count from 1 -	return (currentCD - '1' + 1); +	return (g_currentCD - '1' + 1);  }  static const uint32 cdFlags[] = { fCd1, fCd2, fCd3, fCd4, fCd5, fCd6, fCd7, fCd8 };  void SetCD(int flags) { -	if (flags & cdFlags[currentCD - '1']) +	if (flags & cdFlags[g_currentCD - '1'])  		return;  	error("SetCD() problem"); @@ -82,7 +82,7 @@ int GetCD(int flags) {  	int i;  	char cd = '\0'; -	if (flags & cdFlags[currentCD - '1']) +	if (flags & cdFlags[g_currentCD - '1'])  		return GetCurrentCD();  	for (i = 0; i < 8; i++) { @@ -93,19 +93,19 @@ int GetCD(int flags) {  	}  	assert(i != 8); -	nextCD = cd; +	g_nextCD = cd;  	return cd;  }  void DoCdChange() { -	if (bChangingCD && (g_system->getMillis() > (lastTime + 1000))) { -		lastTime = g_system->getMillis(); +	if (g_bChangingCD && (g_system->getMillis() > (g_lastTime + 1000))) { +		g_lastTime = g_system->getMillis();  		_vm->_sound->closeSampleStream();  		// Use the filesize of the sample file to determine, for Discworld 2, which CD it is  		if (TinselV2) {  			TinselFile f; -			if (!f.open(_vm->getSampleFile(sampleLanguage))) +			if (!f.open(_vm->getSampleFile(g_sampleLanguage)))  				// No CD present  				return; @@ -113,28 +113,28 @@ void DoCdChange() {  			f.close(); -			if (currentCD != sampleCdNumber) +			if (g_currentCD != sampleCdNumber)  				return;  		}  		_vm->_sound->openSampleFiles();  		ChangeLanguage(TextLanguage()); -		bChangingCD = false; +		g_bChangingCD = false;  	}  }  void SetNextCD(int cdNumber) {  	assert(cdNumber == 1 || cdNumber == 2); -	nextCD = (char)(cdNumber + '1' - 1); +	g_nextCD = (char)(cdNumber + '1' - 1);  }  bool GotoCD() {  	// WORKAROUND: Somehow, CdDoChange() is called twice... Hopefully, this guard helps -	if (currentCD == nextCD) +	if (g_currentCD == g_nextCD)  		return false; -	currentCD = nextCD; +	g_currentCD = g_nextCD;  /*	if (bNoCD)	{  		strcpy(cdDirectory, hdDirectory); @@ -142,7 +142,7 @@ bool GotoCD() {  		strcat(cdDirectory, cdLastBit);  	}  */ -	bChangingCD = true; +	g_bChangingCD = true;  	return true;  } diff --git a/engines/tinsel/events.cpp b/engines/tinsel/events.cpp index e701ddca99..74454c5f2a 100644 --- a/engines/tinsel/events.cpp +++ b/engines/tinsel/events.cpp @@ -54,37 +54,37 @@ extern HPOLYGON GetTaggedPoly();  //----------------- EXTERNAL GLOBAL DATA --------------------- -extern bool bEnableMenu; +extern bool g_bEnableMenu;  //----------------- LOCAL GLOBAL DATA --------------------  // FIXME: Avoid non-const global vars -static uint32 lastUserEvent = 0;	// Time it hapenned -static int leftEvents = 0;		// Single or double, left or right. Or escape key. -static int escEvents = 1;		// Escape key -static int userEvents = 0;		// Whenever a button or a key comes in +static uint32 g_lastUserEvent = 0;	// Time it hapenned +static int g_leftEvents = 0;		// Single or double, left or right. Or escape key. +static int g_escEvents = 1;		// Escape key +static int g_userEvents = 0;		// Whenever a button or a key comes in -static int eCount = 0; +static int g_eCount = 0; -static int controlState; -static bool bStartOff; +static int g_controlState; +static bool g_bStartOff; -static int controlX, controlY; -static bool bProvNotProcessed = false; +static int g_controlX, g_controlY; +static bool g_bProvNotProcessed = false;  /**   * Gets called before each schedule, only 1 user action per schedule   * is allowed.   */  void ResetEcount() { -	eCount = 0; +	g_eCount = 0;  }  void IncUserEvents() { -	userEvents++; -	lastUserEvent = DwGetCurrentTime(); +	g_userEvents++; +	g_lastUserEvent = DwGetCurrentTime();  }  /** @@ -104,7 +104,7 @@ void AllowDclick(CORO_PARAM, PLR_EVENT be) {  		FreeToken(TOKEN_LEFT_BUT);  		// Prevent activation of 2 events on the same tick -		if (++eCount != 1) +		if (++g_eCount != 1)  			CORO_KILL_SELF();  		break; @@ -125,17 +125,17 @@ void ControlOn() {  		return;  	} -	bEnableMenu = false; +	g_bEnableMenu = false; -	if (controlState == CONTROL_OFF) { +	if (g_controlState == CONTROL_OFF) {  		// Control is on -		controlState = CONTROL_ON; +		g_controlState = CONTROL_ON;  		// Restore cursor to where it was -		if (bStartOff == true) -			bStartOff = false; +		if (g_bStartOff == true) +			g_bStartOff = false;  		else -			SetCursorXY(controlX, controlY); +			SetCursorXY(g_controlX, g_controlY);  		// Re-instate cursor  		UnHideCursor(); @@ -155,14 +155,14 @@ void ControlOff() {  		return;  	} -	bEnableMenu = false; +	g_bEnableMenu = false; -	if (controlState == CONTROL_ON) { +	if (g_controlState == CONTROL_ON) {  		// Control is off -		controlState = CONTROL_OFF; +		g_controlState = CONTROL_OFF;  		// Store cursor position -		GetCursorXY(&controlX, &controlY, true); +		GetCursorXY(&g_controlX, &g_controlY, true);  		// Blank out cursor  		DwHideCursor(); @@ -181,10 +181,10 @@ void ControlStartOff() {  		return;  	} -	bEnableMenu = false; +	g_bEnableMenu = false;  	// Control is off -	controlState = CONTROL_OFF; +	g_controlState = CONTROL_OFF;  	// Blank out cursor  	DwHideCursor(); @@ -192,7 +192,7 @@ void ControlStartOff() {  	// Switch off tags  	DisableTags(); -	bStartOff = true; +	g_bStartOff = true;  }  /** @@ -211,7 +211,7 @@ bool GetControl(int param) {  }  bool GetControl() { -	if (controlState == CONTROL_ON) { +	if (g_controlState == CONTROL_ON) {  		ControlOff();  		return true;  	} else @@ -220,7 +220,7 @@ bool GetControl() {  bool ControlIsOn() {  	if (TinselV2) -		return (controlState == CONTROL_ON); +		return (g_controlState == CONTROL_ON);  	return TestToken(TOKEN_CONTROL);  } @@ -289,7 +289,7 @@ static void ProcessUserEvent(TINSEL_EVENT uEvent, const Common::Point &coOrds, P  	HPOLYGON hPoly;  	// Prevent activation of 2 events on the same tick -	if (++eCount != 1) +	if (++g_eCount != 1)  		return;  	if ((actor = GetTaggedActor()) != 0) { @@ -395,19 +395,19 @@ void PlayerEvent(PLR_EVENT pEvent, const Common::Point &coOrds) {  	static uint32 lastRealAction = 0;	// FIXME: Avoid non-const global vars  	// This stuff to allow F1 key during startup. -	if (bEnableMenu && pEvent == PLR_MENU) +	if (g_bEnableMenu && pEvent == PLR_MENU)  		Control(CONTROL_ON);  	else  		IncUserEvents();  	if (pEvent == PLR_ESCAPE) { -		++escEvents; -		++leftEvents;		// Yes, I do mean this +		++g_escEvents; +		++g_leftEvents;		// Yes, I do mean this  	} else if ((pEvent == PLR_PROV_WALKTO)  			|| (pEvent == PLR_WALKTO)  			|| (pEvent == PLR_LOOK)  			|| (pEvent == PLR_ACTION)) { -		++leftEvents; +		++g_leftEvents;  	}  	// Only allow events if player control is on @@ -484,18 +484,18 @@ void PlayerEvent(PLR_EVENT pEvent, const Common::Point &coOrds) {   * For ESCapable Glitter sequences   */  int GetEscEvents() { -	return escEvents; +	return g_escEvents;  }  /**   * For cutting short talk()s etc.   */  int GetLeftEvents() { -	return leftEvents; +	return g_leftEvents;  }  bool LeftEventChange(int myleftEvent) { -	if (leftEvents != myleftEvent) { +	if (g_leftEvents != myleftEvent) {  		ProcessedProvisional();  		return true;  	} else @@ -506,15 +506,15 @@ bool LeftEventChange(int myleftEvent) {   * For waitkey() Glitter function   */  int getUserEvents() { -	return userEvents; +	return g_userEvents;  }  uint32 getUserEventTime() { -	return DwGetCurrentTime() - lastUserEvent; +	return DwGetCurrentTime() - g_lastUserEvent;  }  void resetUserEventTime() { -	lastUserEvent = DwGetCurrentTime(); +	g_lastUserEvent = DwGetCurrentTime();  }  struct PTP_INIT { @@ -655,18 +655,18 @@ void effRunPolyTinselCode(HPOLYGON hPoly, TINSEL_EVENT event, int actor) {   * subsequent 'real' event.   */  void ProcessedProvisional() { -	bProvNotProcessed = false; +	g_bProvNotProcessed = false;  }  /**   * Resets the bProvNotProcessed flag   */  void ProvNotProcessed() { -	bProvNotProcessed = true; +	g_bProvNotProcessed = true;  }  bool GetProvNotProcessed() { -	return bProvNotProcessed; +	return g_bProvNotProcessed;  }  } // End of namespace Tinsel diff --git a/engines/tinsel/font.cpp b/engines/tinsel/font.cpp index e857dca509..54aa7cc15f 100644 --- a/engines/tinsel/font.cpp +++ b/engines/tinsel/font.cpp @@ -34,38 +34,38 @@ namespace Tinsel {  // FIXME: Avoid non-const global vars -static char tBuffer[TBUFSZ]; +static char g_tBuffer[TBUFSZ]; -static SCNHANDLE hTagFont = 0, hTalkFont = 0; -static SCNHANDLE hRegularTalkFont = 0, hRegularTagFont = 0; +static SCNHANDLE g_hTagFont = 0, g_hTalkFont = 0; +static SCNHANDLE g_hRegularTalkFont = 0, g_hRegularTagFont = 0;  /**   * Return address of tBuffer   */  char *TextBufferAddr() { -	return tBuffer; +	return g_tBuffer;  }  /**   * Return hTagFont handle.   */  SCNHANDLE GetTagFontHandle() { -	return hTagFont; +	return g_hTagFont;  }  /**   * Return hTalkFont handle.   */  SCNHANDLE GetTalkFontHandle() { -	return hTalkFont; +	return g_hTalkFont;  }  /**   * Called from dec_tagfont() Glitter function. Store the tag font handle.   */  void SetTagFontHandle(SCNHANDLE hFont) { -	hTagFont = hRegularTagFont = hFont;		// Store the font handle +	g_hTagFont = g_hRegularTagFont = hFont;		// Store the font handle  }  /** @@ -73,20 +73,20 @@ void SetTagFontHandle(SCNHANDLE hFont) {   * Store the talk font handle.   */  void SetTalkFontHandle(SCNHANDLE hFont) { -	hTalkFont = hRegularTalkFont = hFont;		// Store the font handle +	g_hTalkFont = g_hRegularTalkFont = hFont;		// Store the font handle  }  void SetTempTagFontHandle(SCNHANDLE hFont) { -	hTagFont = hFont; +	g_hTagFont = hFont;  }  void SetTempTalkFontHandle(SCNHANDLE hFont) { -	hTalkFont = hFont; +	g_hTalkFont = hFont;  }  void ResetFontHandles() { -	hTagFont = hRegularTagFont; -	hTalkFont = hRegularTalkFont; +	g_hTagFont = g_hRegularTagFont; +	g_hTalkFont = g_hRegularTalkFont;  } @@ -98,17 +98,17 @@ void FettleFontPal(SCNHANDLE fontPal) {  	IMAGE *pImg;  	assert(fontPal); -	assert(hTagFont); // Tag font not declared -	assert(hTalkFont); // Talk font not declared +	assert(g_hTagFont); // Tag font not declared +	assert(g_hTalkFont); // Talk font not declared -	pFont = (const FONT *)LockMem(hTagFont); +	pFont = (const FONT *)LockMem(g_hTagFont);  	pImg = (IMAGE *)LockMem(FROM_LE_32(pFont->fontInit.hObjImg));	// get image for char 0  	if (!TinselV2)  		pImg->hImgPal = TO_LE_32(fontPal);  	else  		pImg->hImgPal = 0; -	pFont = (const FONT *)LockMem(hTalkFont); +	pFont = (const FONT *)LockMem(g_hTalkFont);  	pImg = (IMAGE *)LockMem(FROM_LE_32(pFont->fontInit.hObjImg));	// get image for char 0  	if (!TinselV2)  		pImg->hImgPal = TO_LE_32(fontPal); diff --git a/engines/tinsel/graphics.cpp b/engines/tinsel/graphics.cpp index 4f3cc36994..9b06b1a501 100644 --- a/engines/tinsel/graphics.cpp +++ b/engines/tinsel/graphics.cpp @@ -40,7 +40,7 @@ namespace Tinsel {  #define CHAR_WIDTH 4  #define CHAR_HEIGHT 4 -extern uint8 transPalette[MAX_COLORS]; +extern uint8 g_transPalette[MAX_COLORS];  //----------------- SUPPORT FUNCTIONS --------------------- @@ -559,7 +559,7 @@ static void WrtTrans(DRAWOBJECT *pObj, uint8 *destP, bool applyClipping) {  	// Loop through any remaining lines  	while (pObj->height > 0) {  		for (int i = 0; i < pObj->width; ++i, ++destP) -			*destP = transPalette[*destP]; +			*destP = g_transPalette[*destP];  		--pObj->height;  		destP += lineOffset; diff --git a/engines/tinsel/handle.cpp b/engines/tinsel/handle.cpp index eeb83b1f98..e31b2141f5 100644 --- a/engines/tinsel/handle.cpp +++ b/engines/tinsel/handle.cpp @@ -69,17 +69,17 @@ enum {  // FIXME: Avoid non-const global vars  // handle table gets loaded from index file at runtime -static MEMHANDLE *handleTable = 0; +static MEMHANDLE *g_handleTable = 0;  // number of handles in the handle table -static uint numHandles = 0; +static uint g_numHandles = 0; -static uint32 cdPlayHandle = (uint32)-1; +static uint32 g_cdPlayHandle = (uint32)-1; -static SCNHANDLE cdBaseHandle = 0, cdTopHandle = 0; -static Common::File *cdGraphStream = 0; +static SCNHANDLE g_cdBaseHandle = 0, g_cdTopHandle = 0; +static Common::File *g_cdGraphStream = 0; -static char szCdPlayFile[100]; +static char g_szCdPlayFile[100];  //----------------- FORWARD REFERENCES -------------------- @@ -110,24 +110,24 @@ void SetupHandleTable() {  			}  			// calc number of handles -			numHandles = len / RECORD_SIZE; +			g_numHandles = len / RECORD_SIZE;  			// allocate memory for the index file -			handleTable = (MEMHANDLE *)calloc(numHandles, sizeof(struct MEMHANDLE)); +			g_handleTable = (MEMHANDLE *)calloc(g_numHandles, sizeof(struct MEMHANDLE));  			// make sure memory allocated -			assert(handleTable); +			assert(g_handleTable);  			// load data -			for (i = 0; i < numHandles; i++) { -				f.read(handleTable[i].szName, 12); -				handleTable[i].filesize = f.readUint32(); +			for (i = 0; i < g_numHandles; i++) { +				f.read(g_handleTable[i].szName, 12); +				g_handleTable[i].filesize = f.readUint32();  				// The pointer should always be NULL. We don't  				// need to read that from the file. -				handleTable[i]._node = NULL; +				g_handleTable[i]._node = NULL;  				f.seek(4, SEEK_CUR);  				// For Discworld 2, read in the flags2 field -				handleTable[i].flags2 = t2Flag ? f.readUint32() : 0; +				g_handleTable[i].flags2 = t2Flag ? f.readUint32() : 0;  			}  			if (f.eos() || f.err()) { @@ -145,7 +145,7 @@ void SetupHandleTable() {  	}  	// allocate memory nodes and load all permanent graphics -	for (i = 0, pH = handleTable; i < numHandles; i++, pH++) { +	for (i = 0, pH = g_handleTable; i < g_numHandles; i++, pH++) {  		if (pH->filesize & fPreload) {  			// allocate a fixed memory node for permanent files  			pH->_node = MemoryAllocFixed((pH->filesize & FSIZE_MASK)); @@ -172,24 +172,24 @@ void SetupHandleTable() {  }  void FreeHandleTable() { -	free(handleTable); -	handleTable = NULL; +	free(g_handleTable); +	g_handleTable = NULL; -	delete cdGraphStream; -	cdGraphStream = NULL; +	delete g_cdGraphStream; +	g_cdGraphStream = NULL;  }  /**   * Loads a memory block as a file.   */  void OpenCDGraphFile() { -	delete cdGraphStream; +	delete g_cdGraphStream;  	// As the theory goes, the right CD will be in there! -	cdGraphStream = new Common::File; -	if (!cdGraphStream->open(szCdPlayFile)) -		error(CANNOT_FIND_FILE, szCdPlayFile); +	g_cdGraphStream = new Common::File; +	if (!g_cdGraphStream->open(g_szCdPlayFile)) +		error(CANNOT_FIND_FILE, g_szCdPlayFile);  }  void LoadCDGraphData(MEMHANDLE *pH) { @@ -210,15 +210,15 @@ void LoadCDGraphData(MEMHANDLE *pH) {  	assert(addr);  	// Move to correct place in file and load the required data -	assert(cdGraphStream); -	cdGraphStream->seek(cdBaseHandle & OFFSETMASK, SEEK_SET); -	bytes = cdGraphStream->read(addr, (cdTopHandle - cdBaseHandle) & OFFSETMASK); +	assert(g_cdGraphStream); +	g_cdGraphStream->seek(g_cdBaseHandle & OFFSETMASK, SEEK_SET); +	bytes = g_cdGraphStream->read(addr, (g_cdTopHandle - g_cdBaseHandle) & OFFSETMASK);  	// New code to try and handle CD read failures 24/2/97 -	while (bytes != ((cdTopHandle - cdBaseHandle) & OFFSETMASK) && retries++ < MAX_READ_RETRIES)	{ +	while (bytes != ((g_cdTopHandle - g_cdBaseHandle) & OFFSETMASK) && retries++ < MAX_READ_RETRIES)	{  		// Try again -		cdGraphStream->seek(cdBaseHandle & OFFSETMASK, SEEK_SET); -		bytes = cdGraphStream->read(addr, (cdTopHandle - cdBaseHandle) & OFFSETMASK); +		g_cdGraphStream->seek(g_cdBaseHandle & OFFSETMASK, SEEK_SET); +		bytes = g_cdGraphStream->read(addr, (g_cdTopHandle - g_cdBaseHandle) & OFFSETMASK);  	}  	// discardable - unlock the memory @@ -230,7 +230,7 @@ void LoadCDGraphData(MEMHANDLE *pH) {  	// clear the loading flag  //	pH->filesize &= ~fLoading; -	if (bytes != ((cdTopHandle - cdBaseHandle) & OFFSETMASK)) +	if (bytes != ((g_cdTopHandle - g_cdBaseHandle) & OFFSETMASK))  		// file is corrupt  		error(FILE_READ_ERROR, "CD play file");  } @@ -245,22 +245,22 @@ void LoadCDGraphData(MEMHANDLE *pH) {  void LoadExtraGraphData(SCNHANDLE start, SCNHANDLE next) {  	OpenCDGraphFile(); -	MemoryDiscard((handleTable + cdPlayHandle)->_node); // Free it +	MemoryDiscard((g_handleTable + g_cdPlayHandle)->_node); // Free it  	// It must always be the same -	assert(cdPlayHandle == (start >> SCNHANDLE_SHIFT)); -	assert(cdPlayHandle == (next >> SCNHANDLE_SHIFT)); +	assert(g_cdPlayHandle == (start >> SCNHANDLE_SHIFT)); +	assert(g_cdPlayHandle == (next >> SCNHANDLE_SHIFT)); -	cdBaseHandle = start; -	cdTopHandle = next; +	g_cdBaseHandle = start; +	g_cdTopHandle = next;  }  void SetCdPlaySceneDetails(int fileNum, const char *fileName) { -	strcpy(szCdPlayFile, fileName); +	strcpy(g_szCdPlayFile, fileName);  }  void SetCdPlayHandle(int fileNum) { -	cdPlayHandle = fileNum; +	g_cdPlayHandle = fileNum;  } @@ -323,26 +323,26 @@ byte *LockMem(SCNHANDLE offset) {  	MEMHANDLE *pH;			// points to table entry  	// range check the memory handle -	assert(handle < numHandles); +	assert(handle < g_numHandles);  #ifdef DEBUG  	if (handle != s_lockedScene)  		warning("  Calling LockMem(0x%x), handle %d differs from active scene %d", offset, handle, s_lockedScene);  #endif -	pH = handleTable + handle; +	pH = g_handleTable + handle;  	if (pH->filesize & fPreload) {  		// permanent files are already loaded, nothing to be done -	} else if (handle == cdPlayHandle) { +	} else if (handle == g_cdPlayHandle) {  		// Must be in currently loaded/loadable range -		if (offset < cdBaseHandle || offset >= cdTopHandle) +		if (offset < g_cdBaseHandle || offset >= g_cdTopHandle)  			error("Overlapping (in time) CD-plays");  		// May have been discarded, if so, we have to reload  		if (!MemoryDeref(pH->_node)) {  			// Data was discarded, we have to reload -			MemoryReAlloc(pH->_node, cdTopHandle - cdBaseHandle); +			MemoryReAlloc(pH->_node, g_cdTopHandle - g_cdBaseHandle);  			LoadCDGraphData(pH); @@ -353,7 +353,7 @@ byte *LockMem(SCNHANDLE offset) {  		// make sure address is valid  		assert(pH->filesize & fLoaded); -		offset -= cdBaseHandle; +		offset -= g_cdBaseHandle;  	} else {  		if (!MemoryDeref(pH->_node)) {  			// Data was discarded, we have to reload @@ -387,9 +387,9 @@ void LockScene(SCNHANDLE offset) {  #endif  	// range check the memory handle -	assert(handle < numHandles); +	assert(handle < g_numHandles); -	pH = handleTable + handle; +	pH = g_handleTable + handle;  	if ((pH->filesize & fPreload) == 0) {  		// Ensure the scene handle is allocated. @@ -414,9 +414,9 @@ void UnlockScene(SCNHANDLE offset) {  	MEMHANDLE *pH;					// points to table entry  	// range check the memory handle -	assert(handle < numHandles); +	assert(handle < g_numHandles); -	pH = handleTable + handle; +	pH = g_handleTable + handle;  	if ((pH->filesize & fPreload) == 0) {  		// unlock the scene data @@ -441,9 +441,9 @@ bool ValidHandle(SCNHANDLE offset) {  	MEMHANDLE *pH;					// points to table entry  	// range check the memory handle -	assert(handle < numHandles); +	assert(handle < g_numHandles); -	pH = handleTable + handle; +	pH = g_handleTable + handle;  	return (pH->filesize & FSIZE_MASK) != 8;  } @@ -458,7 +458,7 @@ void TouchMem(SCNHANDLE offset) {  	uint32 handle = offset >> SCNHANDLE_SHIFT;	// calc memory handle to use  	if (offset != 0) { -		pH = handleTable + handle; +		pH = g_handleTable + handle;  		// update the LRU time whether its loaded or not!  		if (pH->_node) @@ -474,9 +474,9 @@ bool IsCdPlayHandle(SCNHANDLE offset) {  	uint32 handle = offset >> SCNHANDLE_SHIFT;	// calc memory handle to use  	// range check the memory handle -	assert(handle < numHandles); +	assert(handle < g_numHandles); -	return (handle == cdPlayHandle); +	return (handle == g_cdPlayHandle);  }  /** @@ -486,9 +486,9 @@ int CdNumber(SCNHANDLE offset) {  	uint handle = offset >> SCNHANDLE_SHIFT;	// calc memory handle to use  	// range check the memory handle -	assert(handle < numHandles); +	assert(handle < g_numHandles); -	MEMHANDLE *pH = handleTable + handle; +	MEMHANDLE *pH = g_handleTable + handle;  	if (!TinselV2)  		return 1; diff --git a/engines/tinsel/heapmem.cpp b/engines/tinsel/heapmem.cpp index 819493bda1..597cc69e66 100644 --- a/engines/tinsel/heapmem.cpp +++ b/engines/tinsel/heapmem.cpp @@ -58,16 +58,16 @@ static const uint32 MemoryPoolSize[3] = {5 * 1024 * 1024, 5 * 1024 * 1024, 10 *  // list of all memory nodes -MEM_NODE mnodeList[NUM_MNODES]; +MEM_NODE g_mnodeList[NUM_MNODES];  // pointer to the linked list of free mnodes -static MEM_NODE *pFreeMemNodes; +static MEM_NODE *g_pFreeMemNodes;  // list of all fixed memory nodes -MEM_NODE s_fixedMnodesList[5]; +MEM_NODE g_s_fixedMnodesList[5];  // the mnode heap sentinel -static MEM_NODE heapSentinel; +static MEM_NODE g_heapSentinel;  //  static MEM_NODE *AllocMemNode(); @@ -80,7 +80,7 @@ static void MemoryStats() {  	int lockedSize = 0;  	int totalSize = 0; -	const MEM_NODE *pHeap = &heapSentinel; +	const MEM_NODE *pHeap = &g_heapSentinel;  	MEM_NODE *pCur;  	for (pCur = pHeap->pNext; pCur != pHeap; pCur = pCur->pNext) { @@ -104,43 +104,43 @@ static void MemoryStats() {   */  void MemoryInit() {  	// place first node on free list -	pFreeMemNodes = mnodeList; +	g_pFreeMemNodes = g_mnodeList;  	// link all other objects after first -	memset(mnodeList, 0, sizeof(mnodeList)); +	memset(g_mnodeList, 0, sizeof(g_mnodeList));  	for (int i = 1; i < NUM_MNODES; i++) { -		mnodeList[i - 1].pNext = mnodeList + i; +		g_mnodeList[i - 1].pNext = g_mnodeList + i;  	}  	// null the last mnode -	mnodeList[NUM_MNODES - 1].pNext = NULL; +	g_mnodeList[NUM_MNODES - 1].pNext = NULL;  	// clear list of fixed memory nodes -	memset(s_fixedMnodesList, 0, sizeof(s_fixedMnodesList)); +	memset(g_s_fixedMnodesList, 0, sizeof(g_s_fixedMnodesList));  	// set cyclic links to the sentinel -	heapSentinel.pPrev = &heapSentinel; -	heapSentinel.pNext = &heapSentinel; +	g_heapSentinel.pPrev = &g_heapSentinel; +	g_heapSentinel.pNext = &g_heapSentinel;  	// flag sentinel as locked -	heapSentinel.flags = DWM_LOCKED | DWM_SENTINEL; +	g_heapSentinel.flags = DWM_LOCKED | DWM_SENTINEL;  	// store the current heap size in the sentinel  	uint32 size = MemoryPoolSize[0];  	if (TinselVersion == TINSEL_V1) size = MemoryPoolSize[1];  	else if (TinselVersion == TINSEL_V2) size = MemoryPoolSize[2]; -	heapSentinel.size = size; +	g_heapSentinel.size = size;  }  /**   * Deinitializes the memory manager.   */  void MemoryDeinit() { -	const MEM_NODE *pHeap = &heapSentinel; +	const MEM_NODE *pHeap = &g_heapSentinel;  	MEM_NODE *pCur; -	pCur = s_fixedMnodesList; -	for (int i = 0; i < ARRAYSIZE(s_fixedMnodesList); ++i, ++pCur) { +	pCur = g_s_fixedMnodesList; +	for (int i = 0; i < ARRAYSIZE(g_s_fixedMnodesList); ++i, ++pCur) {  		free(pCur->pBaseAddr);  		pCur->pBaseAddr = 0;  	} @@ -157,13 +157,13 @@ void MemoryDeinit() {   */  static MEM_NODE *AllocMemNode() {  	// get the first free mnode -	MEM_NODE *pMemNode = pFreeMemNodes; +	MEM_NODE *pMemNode = g_pFreeMemNodes;  	// make sure a mnode is available  	assert(pMemNode); // Out of memory nodes  	// the next free mnode -	pFreeMemNodes = pMemNode->pNext; +	g_pFreeMemNodes = pMemNode->pNext;  	// wipe out the mnode  	memset(pMemNode, 0, sizeof(MEM_NODE)); @@ -178,13 +178,13 @@ static MEM_NODE *AllocMemNode() {   */  void FreeMemNode(MEM_NODE *pMemNode) {  	// validate mnode pointer -	assert(pMemNode >= mnodeList && pMemNode <= mnodeList + NUM_MNODES - 1); +	assert(pMemNode >= g_mnodeList && pMemNode <= g_mnodeList + NUM_MNODES - 1);  	// place free list in mnode next -	pMemNode->pNext = pFreeMemNodes; +	pMemNode->pNext = g_pFreeMemNodes;  	// add mnode to top of free list -	pFreeMemNodes = pMemNode; +	g_pFreeMemNodes = pMemNode;  } @@ -194,11 +194,11 @@ void FreeMemNode(MEM_NODE *pMemNode) {   * @return true if any blocks were discarded, false otherwise   */  static bool HeapCompact(long size) { -	const MEM_NODE *pHeap = &heapSentinel; +	const MEM_NODE *pHeap = &g_heapSentinel;  	MEM_NODE *pCur, *pOldest;  	uint32 oldest;		// time of the oldest discardable block -	while (heapSentinel.size < size) { +	while (g_heapSentinel.size < size) {  		// find the oldest discardable block  		oldest = DwGetCurrentTime(); @@ -231,7 +231,7 @@ static bool HeapCompact(long size) {   * @param size			Number of bytes to allocate   */  static MEM_NODE *MemoryAlloc(long size) { -	MEM_NODE *pHeap = &heapSentinel; +	MEM_NODE *pHeap = &g_heapSentinel;  #ifdef SCUMM_NEED_ALIGNMENT  	const int alignPadding = sizeof(void *) - 1; @@ -255,7 +255,7 @@ static MEM_NODE *MemoryAlloc(long size) {  	assert(pNode->pBaseAddr);  	// Subtract size of new block from total -	heapSentinel.size -= size; +	g_heapSentinel.size -= size;  #ifdef DEBUG  	MemoryStats(); @@ -282,7 +282,7 @@ static MEM_NODE *MemoryAlloc(long size) {   * by using MemoryReAlloc().   */  MEM_NODE *MemoryNoAlloc() { -	MEM_NODE *pHeap = &heapSentinel; +	MEM_NODE *pHeap = &g_heapSentinel;  	// chain a discarded node onto the end of the heap  	MEM_NODE *pNode = AllocMemNode(); @@ -315,8 +315,8 @@ MEM_NODE *MemoryAllocFixed(long size) {  #endif  	// Search for a free entry in s_fixedMnodesList -	MEM_NODE *pNode = s_fixedMnodesList; -	for (int i = 0; i < ARRAYSIZE(s_fixedMnodesList); ++i, ++pNode) { +	MEM_NODE *pNode = g_s_fixedMnodesList; +	for (int i = 0; i < ARRAYSIZE(g_s_fixedMnodesList); ++i, ++pNode) {  		if (!pNode->pBaseAddr) {  			pNode->pNext = 0;  			pNode->pPrev = 0; @@ -326,7 +326,7 @@ MEM_NODE *MemoryAllocFixed(long size) {  			pNode->flags = DWM_USED;  			// Subtract size of new block from total -			heapSentinel.size -= size; +			g_heapSentinel.size -= size;  			return pNode;  		} @@ -342,7 +342,7 @@ MEM_NODE *MemoryAllocFixed(long size) {   */  void MemoryDiscard(MEM_NODE *pMemNode) {  	// validate mnode pointer -	assert(pMemNode >= mnodeList && pMemNode <= mnodeList + NUM_MNODES - 1); +	assert(pMemNode >= g_mnodeList && pMemNode <= g_mnodeList + NUM_MNODES - 1);  	// object must be in use and locked  	assert((pMemNode->flags & (DWM_USED | DWM_LOCKED)) == DWM_USED); @@ -351,7 +351,7 @@ void MemoryDiscard(MEM_NODE *pMemNode) {  	if ((pMemNode->flags & DWM_DISCARDED) == 0) {  		// free memory  		free(pMemNode->pBaseAddr); -		heapSentinel.size += pMemNode->size; +		g_heapSentinel.size += pMemNode->size;  #ifdef DEBUG  		MemoryStats(); @@ -416,7 +416,7 @@ void MemoryReAlloc(MEM_NODE *pMemNode, long size) {  	MEM_NODE *pNew;  	// validate mnode pointer -	assert(pMemNode >= mnodeList && pMemNode <= mnodeList + NUM_MNODES - 1); +	assert(pMemNode >= g_mnodeList && pMemNode <= g_mnodeList + NUM_MNODES - 1);  	// align the size to machine boundary requirements  	size = (size + sizeof(void *) - 1) & ~(sizeof(void *) - 1); diff --git a/engines/tinsel/mareels.cpp b/engines/tinsel/mareels.cpp index bd267a2c65..7dd905d0f2 100644 --- a/engines/tinsel/mareels.cpp +++ b/engines/tinsel/mareels.cpp @@ -48,9 +48,9 @@ struct SCIdataStruct {  // FIXME: Avoid non-const global vars -static SCIdataStruct SCIdata[MAX_SCRENTRIES]; +static SCIdataStruct g_SCIdata[MAX_SCRENTRIES]; -static int scrEntries = 0; +static int g_scrEntries = 0;  /**   * Sets an actor's walk reels @@ -131,16 +131,16 @@ void SetScalingReels(int actor, int scale, int direction,  	assert(!(scale == 1 && direction == D_UP) &&  		!(scale == NUM_MAINSCALES && direction == D_DOWN)); // illegal direction from scale -	assert(scrEntries < MAX_SCRENTRIES); // Scaling reels limit reached! +	assert(g_scrEntries < MAX_SCRENTRIES); // Scaling reels limit reached! -	SCIdata[scrEntries].actor = actor; -	SCIdata[scrEntries].scale = scale; -	SCIdata[scrEntries].direction = direction; -	SCIdata[scrEntries].reels[LEFTREEL]	= left; -	SCIdata[scrEntries].reels[RIGHTREEL]	= right; -	SCIdata[scrEntries].reels[FORWARD]	= forward; -	SCIdata[scrEntries].reels[AWAY]		= away; -	scrEntries++; +	g_SCIdata[g_scrEntries].actor = actor; +	g_SCIdata[g_scrEntries].scale = scale; +	g_SCIdata[g_scrEntries].direction = direction; +	g_SCIdata[g_scrEntries].reels[LEFTREEL]	= left; +	g_SCIdata[g_scrEntries].reels[RIGHTREEL]	= right; +	g_SCIdata[g_scrEntries].reels[FORWARD]	= forward; +	g_SCIdata[g_scrEntries].reels[AWAY]		= away; +	g_scrEntries++;  }  /** @@ -155,12 +155,12 @@ SCNHANDLE ScalingReel(int ano, int scale1, int scale2, DIRECTION reel) {  	else  		d = D_UP; -	for (int i = 0; i < scrEntries; i++)	{ -		if (SCIdata[i].actor == ano && SCIdata[i].scale == scale1 && SCIdata[i].direction == d) { -			if (SCIdata[i].reels[reel] == TF_NONE) +	for (int i = 0; i < g_scrEntries; i++)	{ +		if (g_SCIdata[i].actor == ano && g_SCIdata[i].scale == scale1 && g_SCIdata[i].direction == d) { +			if (g_SCIdata[i].reels[reel] == TF_NONE)  				return 0;  			else -				return SCIdata[i].reels[reel]; +				return g_SCIdata[i].reels[reel];  		}  	}  	return 0; @@ -170,8 +170,8 @@ SCNHANDLE ScalingReel(int ano, int scale1, int scale2, DIRECTION reel) {   * RebootScalingReels   */  void RebootScalingReels() { -	scrEntries = 0; -	memset(SCIdata, 0, sizeof(SCIdata)); +	g_scrEntries = 0; +	memset(g_SCIdata, 0, sizeof(g_SCIdata));  }  /** diff --git a/engines/tinsel/move.cpp b/engines/tinsel/move.cpp index e20f28d528..bb49e59fe7 100644 --- a/engines/tinsel/move.cpp +++ b/engines/tinsel/move.cpp @@ -77,14 +77,14 @@ HPOLYGON InitExtraBlock(PMOVER ca, PMOVER ta);  // FIXME: Avoid non-const global vars  #if SLOW_RINCE_DOWN -static int Interlude = 0;	// For slowing down walking, for testing -static int BogusVar = 0;	// For slowing down walking, for testing +static int g_Interlude = 0;	// For slowing down walking, for testing +static int g_BogusVar = 0;	// For slowing down walking, for testing  #endif -static int32 DefaultRefer = 0; -static int lastLeadXdest = 0, lastLeadYdest = 0; +static int32 g_DefaultRefer = 0; +static int g_lastLeadXdest = 0, g_lastLeadYdest = 0; -static int hSlowVar = 0;	// used by MoveActor() +static int g_hSlowVar = 0;	// used by MoveActor()  //----------------- FORWARD REFERENCES -------------------- @@ -101,9 +101,9 @@ static void NewCoOrdinates(int fromx, int fromy, int *targetX, int *targetY,   */  void AddInterlude(int n) { -	Interlude += n; -	if (Interlude < 0) -		Interlude = 0; +	g_Interlude += n; +	if (g_Interlude < 0) +		g_Interlude = 0;  }  #endif @@ -251,7 +251,7 @@ static int ClickedOnNothing(int clickX, int clickY, int *ptgtX, int *ptgtY) {  	PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset); -	switch (DefaultRefer) { +	switch (g_DefaultRefer) {  	case REF_DEFAULT:  		// Try searching down and up (onscreen).  		for (i = clickY+1; i < SCREEN_HEIGHT+Toffset; i++) @@ -1353,15 +1353,15 @@ int SetActorDest(PMOVER pMover, int clickX, int clickY, bool igPath, SCNHANDLE h  		targetY = clickY;  		if (pMover->actorID == GetLeadId()) { -			lastLeadXdest = targetX; -			lastLeadYdest = targetY; +			g_lastLeadXdest = targetX; +			g_lastLeadYdest = targetY;  		}  	} else {  		int wodResult = WorkOutDestination(clickX, clickY, &targetX, &targetY);  		if (pMover->actorID == GetLeadId()) { -			lastLeadXdest = targetX; -			lastLeadYdest = targetY; +			g_lastLeadXdest = targetX; +			g_lastLeadYdest = targetY;  		}  		if (wodResult == ALL_SORTED) { @@ -1613,17 +1613,17 @@ void MoveActor(PMOVER pMover) {  	}  #if SLOW_RINCE_DOWN -/**/	if (BogusVar++ < Interlude)	// Temporary slow-down-the-action code +/**/	if (g_BogusVar++ < g_Interlude)	// Temporary slow-down-the-action code  /**/		return;			// -/**/	BogusVar = 0;			// +/**/	g_BogusVar = 0;			//  #endif  	if (!TinselV2) {  		// During swalk()s, movement while hidden may be slowed down.  		if (pMover->bHidden) { -			if (++hSlowVar < pMover->SlowFactor) +			if (++g_hSlowVar < pMover->SlowFactor)  				return; -			hSlowVar = 0; +			g_hSlowVar = 0;  		}  	} @@ -1705,15 +1705,15 @@ void MoveActor(PMOVER pMover) {   * Store the default refer type for the current scene.   */  void SetDefaultRefer(int32 defRefer) { -	DefaultRefer = defRefer; +	g_DefaultRefer = defRefer;  }  int GetLastLeadXdest() { -	return lastLeadXdest; +	return g_lastLeadXdest;  }  int GetLastLeadYdest() { -	return lastLeadYdest; +	return g_lastLeadYdest;  } diff --git a/engines/tinsel/music.cpp b/engines/tinsel/music.cpp index f552c49491..781a378f13 100644 --- a/engines/tinsel/music.cpp +++ b/engines/tinsel/music.cpp @@ -64,13 +64,13 @@ struct SOUND_BUFFER {  // FIXME: Avoid non-const global vars  // MIDI buffer -static SOUND_BUFFER midiBuffer = { 0, 0 }; +static SOUND_BUFFER g_midiBuffer = { 0, 0 }; -static SCNHANDLE	currentMidi = 0; -static bool		currentLoop = false; +static SCNHANDLE	g_currentMidi = 0; +static bool		g_currentLoop = false;  // We allocate 155 entries because that's the maximum, used in the SCN version -static SCNHANDLE midiOffsets[155]; +static SCNHANDLE g_midiOffsets[155];  static const int enhancedAudioGRAVersion[] = {  	 1,   2,   1,   1,   3,   3,   4,   4,   5,   6, //   1-10 @@ -110,16 +110,16 @@ static const int enhancedAudioSCNVersion[] = {  };  int GetTrackNumber(SCNHANDLE hMidi) { -	for (int i = 0; i < ARRAYSIZE(midiOffsets); i++) -		if (midiOffsets[i] == hMidi) +	for (int i = 0; i < ARRAYSIZE(g_midiOffsets); i++) +		if (g_midiOffsets[i] == hMidi)  			return i;  	return -1;  }  SCNHANDLE GetTrackOffset(int trackNumber) { -	assert(trackNumber < ARRAYSIZE(midiOffsets)); -	return midiOffsets[trackNumber]; +	assert(trackNumber < ARRAYSIZE(g_midiOffsets)); +	return g_midiOffsets[trackNumber];  }  /** @@ -128,8 +128,8 @@ SCNHANDLE GetTrackOffset(int trackNumber) {   * @param bLoop				Whether to loop the sequence   */  bool PlayMidiSequence(uint32 dwFileOffset, bool bLoop) { -	currentMidi = dwFileOffset; -	currentLoop = bLoop; +	g_currentMidi = dwFileOffset; +	g_currentLoop = bLoop;  	// Tinsel V1 PSX uses a different music format, so i  	// disable it here. @@ -166,8 +166,8 @@ bool PlayMidiSequence(uint32 dwFileOffset, bool bLoop) {  				StopMidi();  				// StopMidi resets these fields, so set them again -				currentMidi = dwFileOffset; -				currentLoop = bLoop; +				g_currentMidi = dwFileOffset; +				g_currentLoop = bLoop;  				// try to play track, but don't fall back to a true CD  				g_system->getAudioCDManager()->play(track, bLoop ? -1 : 1, 0, 0, true); @@ -203,13 +203,13 @@ bool PlayMidiSequence(uint32 dwFileOffset, bool bLoop) {  		dwSeqLen = midiStream.readUint32LE();  		// make sure buffer is large enough for this sequence -		assert(dwSeqLen > 0 && dwSeqLen <= midiBuffer.size); +		assert(dwSeqLen > 0 && dwSeqLen <= g_midiBuffer.size);  		// stop any currently playing tune  		_vm->_midiMusic->stop();  		// read the sequence -		if (midiStream.read(midiBuffer.pDat, dwSeqLen) != dwSeqLen) +		if (midiStream.read(g_midiBuffer.pDat, dwSeqLen) != dwSeqLen)  			error(FILE_IS_CORRUPT, MIDI_FILE);  		midiStream.close(); @@ -231,14 +231,14 @@ bool PlayMidiSequence(uint32 dwFileOffset, bool bLoop) {  			_vm->_midiMusic->send(0x7F07B0 | 13);  		} -		_vm->_midiMusic->playXMIDI(midiBuffer.pDat, dwSeqLen, bLoop); +		_vm->_midiMusic->playXMIDI(g_midiBuffer.pDat, dwSeqLen, bLoop);  		// Store the length  		//dwLastSeqLen = dwSeqLen;  	} else {  	 	// dwFileOffset == dwLastMidiIndex  		_vm->_midiMusic->stop(); -		_vm->_midiMusic->playXMIDI(midiBuffer.pDat, dwSeqLen, bLoop); +		_vm->_midiMusic->playXMIDI(g_midiBuffer.pDat, dwSeqLen, bLoop);  	}  	return true; @@ -259,8 +259,8 @@ bool MidiPlaying() {   * Stops any currently playing midi.   */  bool StopMidi() { -	currentMidi = 0; -	currentLoop = false; +	g_currentMidi = 0; +	g_currentLoop = false;  	if (_vm->getFeatures() & GF_ENHANCED_AUDIO_SUPPORT) {  		g_system->getAudioCDManager()->stop(); @@ -295,8 +295,8 @@ void SetMidiVolume(int vol) {  		_vm->_midiMusic->setVolume(vol);  	} else if (vol != 0 && priorVolMusic == 0) {  		// Perhaps restart last midi sequence -		if (currentLoop) -			PlayMidiSequence(currentMidi, true); +		if (g_currentLoop) +			PlayMidiSequence(g_currentMidi, true);  		_vm->_midiMusic->setVolume(vol);  	} else if (vol != 0 && priorVolMusic != 0) { @@ -318,7 +318,7 @@ void OpenMidiFiles() {  	if ((_vm->getFeatures() & GF_DEMO) || (TinselVersion == TINSEL_V2) || TinselV1PSX)  		return; -	if (midiBuffer.pDat) +	if (g_midiBuffer.pDat)  		// already allocated  		return; @@ -327,15 +327,15 @@ void OpenMidiFiles() {  		error(CANNOT_FIND_FILE, MIDI_FILE);  	// gen length of the largest sequence -	midiBuffer.size = midiStream.readUint32LE(); +	g_midiBuffer.size = midiStream.readUint32LE();  	if (midiStream.eos() || midiStream.err())  		error(FILE_IS_CORRUPT, MIDI_FILE); -	if (midiBuffer.size) { +	if (g_midiBuffer.size) {  		// allocate a buffer big enough for the largest MIDI sequence -		if ((midiBuffer.pDat = (uint8 *)malloc(midiBuffer.size)) != NULL) { +		if ((g_midiBuffer.pDat = (uint8 *)malloc(g_midiBuffer.size)) != NULL) {  			// clear out the buffer -			memset(midiBuffer.pDat, 0, midiBuffer.size); +			memset(g_midiBuffer.pDat, 0, g_midiBuffer.size);  //			VMM_lock(midiBuffer.pDat, midiBuffer.size);  		} else {  			//mSeqHandle = NULL; @@ -352,15 +352,15 @@ void OpenMidiFiles() {  	uint32 songLength = 0;  	// Init -	for (int i = 0; i < ARRAYSIZE(midiOffsets); i++) -		midiOffsets[i] = 0; +	for (int i = 0; i < ARRAYSIZE(g_midiOffsets); i++) +		g_midiOffsets[i] = 0;  	while (!midiStream.eos() && !midiStream.err()) {  		if (curOffset + (4 * curTrack) >= (uint32)midiStream.size())  			break; -		assert(curTrack < ARRAYSIZE(midiOffsets)); -		midiOffsets[curTrack] = curOffset + (4 * curTrack); +		assert(curTrack < ARRAYSIZE(g_midiOffsets)); +		g_midiOffsets[curTrack] = curOffset + (4 * curTrack);  		//debug("%d: %d", curTrack, midiOffsets[curTrack]);  		songLength = midiStream.readUint32LE(); @@ -374,8 +374,8 @@ void OpenMidiFiles() {  }  void DeleteMidiBuffer() { -	free(midiBuffer.pDat); -	midiBuffer.pDat = NULL; +	free(g_midiBuffer.pDat); +	g_midiBuffer.pDat = NULL;  }  MidiMusicPlayer::MidiMusicPlayer() { @@ -860,22 +860,22 @@ void PCMMusicPlayer::stop() {  }  void CurrentMidiFacts(SCNHANDLE	*pMidi, bool *pLoop) { -	*pMidi = currentMidi; -	*pLoop = currentLoop; +	*pMidi = g_currentMidi; +	*pLoop = g_currentLoop;  }  void RestoreMidiFacts(SCNHANDLE	Midi, bool Loop) {  	StopMidi(); -	currentMidi = Midi; -	currentLoop = Loop; +	g_currentMidi = Midi; +	g_currentLoop = Loop;  	if (_vm->_config->_musicVolume != 0 && Loop) {  		bool mute = false;  		if (ConfMan.hasKey("mute"))  			mute = ConfMan.getBool("mute"); -		PlayMidiSequence(currentMidi, true); +		PlayMidiSequence(g_currentMidi, true);  		SetMidiVolume(mute ? 0 : _vm->_config->_musicVolume);  	}  } diff --git a/engines/tinsel/palette.cpp b/engines/tinsel/palette.cpp index f2437bd17e..e6c9467fab 100644 --- a/engines/tinsel/palette.cpp +++ b/engines/tinsel/palette.cpp @@ -54,33 +54,33 @@ struct VIDEO_DAC_Q {  // FIXME: Avoid non-const global vars  /** palette allocator data */ -static PALQ palAllocData[NUM_PALETTES]; +static PALQ g_palAllocData[NUM_PALETTES];  /** video DAC transfer Q length */  #define VDACQLENGTH (NUM_PALETTES+2)  /** video DAC transfer Q */ -static VIDEO_DAC_Q vidDACdata[VDACQLENGTH]; +static VIDEO_DAC_Q g_vidDACdata[VDACQLENGTH];  /** video DAC transfer Q head pointer */ -static VIDEO_DAC_Q *pDAChead; +static VIDEO_DAC_Q *g_pDAChead;  /** color index of the 4 colors used for the translucent palette */  #define COL_HILIGHT	TBLUE1  /** the translucent palette lookup table */ -uint8 transPalette[MAX_COLORS];	// used in graphics.cpp +uint8 g_transPalette[MAX_COLORS];	// used in graphics.cpp -uint8 ghostPalette[MAX_COLORS]; +uint8 g_ghostPalette[MAX_COLORS]; -static int translucentIndex	= 228; +static int g_translucentIndex	= 228; -static int talkIndex		= 233; +static int g_talkIndex		= 233; -static COLORREF talkColRef; +static COLORREF g_talkColRef; -static COLORREF tagColRef; +static COLORREF g_tagColRef;  #ifdef DEBUG @@ -131,11 +131,11 @@ void psxPaletteMapper(PALQ *originalPal, uint8 *psxClut, byte *mapperTable) {   */  void PalettesToVideoDAC() {  	PALQ *pPalQ;				// palette Q iterator -	VIDEO_DAC_Q *pDACtail = vidDACdata;	// set tail pointer +	VIDEO_DAC_Q *pDACtail = g_vidDACdata;	// set tail pointer  	byte pal[768];  	// while Q is not empty -	while (pDAChead != pDACtail) { +	while (g_pDAChead != pDACtail) {  		const PALETTE *pPalette;	// pointer to hardware palette  		const COLORREF *pColors;	// pointer to list of RGB triples @@ -179,10 +179,10 @@ void PalettesToVideoDAC() {  	}  	// reset video DAC transfer Q head pointer -	pDAChead = vidDACdata; +	g_pDAChead = g_vidDACdata;  	// clear all palette moved bits -	for (pPalQ = palAllocData; pPalQ < palAllocData + NUM_PALETTES; pPalQ++) +	for (pPalQ = g_palAllocData; pPalQ < g_palAllocData + NUM_PALETTES; pPalQ++)  		pPalQ->posInDAC &= ~PALETTE_MOVED;  } @@ -196,10 +196,10 @@ void ResetPalAllocator() {  #endif  	// wipe out the palette allocator data -	memset(palAllocData, 0, sizeof(palAllocData)); +	memset(g_palAllocData, 0, sizeof(g_palAllocData));  	// reset video DAC transfer Q head pointer -	pDAChead = vidDACdata; +	g_pDAChead = g_vidDACdata;  }  #ifdef	DEBUG @@ -220,19 +220,19 @@ void PaletteStats() {   */  void UpdateDACqueueHandle(int posInDAC, int numColors, SCNHANDLE hPalette) {  	// check Q overflow -	assert(pDAChead < vidDACdata + VDACQLENGTH); +	assert(g_pDAChead < g_vidDACdata + VDACQLENGTH); -	pDAChead->destDACindex = posInDAC & ~PALETTE_MOVED;	// set index in video DAC -	pDAChead->numColors = numColors;	// set number of colors -	pDAChead->pal.hRGBarray = hPalette;	// set handle of palette -	pDAChead->bHandle = true;		// we are using a palette handle +	g_pDAChead->destDACindex = posInDAC & ~PALETTE_MOVED;	// set index in video DAC +	g_pDAChead->numColors = numColors;	// set number of colors +	g_pDAChead->pal.hRGBarray = hPalette;	// set handle of palette +	g_pDAChead->bHandle = true;		// we are using a palette handle  	// update head pointer -	++pDAChead; +	++g_pDAChead;  #ifdef DEBUG -	if ((pDAChead-vidDACdata) > maxDACQ) -		maxDACQ = pDAChead-vidDACdata; +	if ((g_pDAChead-g_vidDACdata) > maxDACQ) +		maxDACQ = g_pDAChead-g_vidDACdata;  #endif  } @@ -244,22 +244,22 @@ void UpdateDACqueueHandle(int posInDAC, int numColors, SCNHANDLE hPalette) {   */  void UpdateDACqueue(int posInDAC, int numColors, COLORREF *pColors) {  	// check Q overflow -	assert(pDAChead < vidDACdata + NUM_PALETTES); +	assert(g_pDAChead < g_vidDACdata + NUM_PALETTES); -	pDAChead->destDACindex = posInDAC & ~PALETTE_MOVED;	// set index in video DAC -	pDAChead->numColors = numColors;	// set number of colors +	g_pDAChead->destDACindex = posInDAC & ~PALETTE_MOVED;	// set index in video DAC +	g_pDAChead->numColors = numColors;	// set number of colors  	if (numColors == 1) -		pDAChead->pal.singleRGB = *pColors;	// set single color of which the "palette" consists +		g_pDAChead->pal.singleRGB = *pColors;	// set single color of which the "palette" consists  	else -		pDAChead->pal.pRGBarray = pColors;	// set addr of palette -	pDAChead->bHandle = false;		// we are not using a palette handle +		g_pDAChead->pal.pRGBarray = pColors;	// set addr of palette +	g_pDAChead->bHandle = false;		// we are not using a palette handle  	// update head pointer -	++pDAChead; +	++g_pDAChead;  #ifdef DEBUG -	if ((pDAChead-vidDACdata) > maxDACQ) -		maxDACQ = pDAChead-vidDACdata; +	if ((g_pDAChead-g_vidDACdata) > maxDACQ) +		maxDACQ = g_pDAChead-g_vidDACdata;  #endif  } @@ -271,19 +271,19 @@ void UpdateDACqueue(int posInDAC, int numColors, COLORREF *pColors) {   */  void UpdateDACqueue(int posInDAC, COLORREF color) {  	// check Q overflow -	assert(pDAChead < vidDACdata + NUM_PALETTES); +	assert(g_pDAChead < g_vidDACdata + NUM_PALETTES); -	pDAChead->destDACindex = posInDAC & ~PALETTE_MOVED;	// set index in video DAC -	pDAChead->numColors = 1;	// set number of colors -	pDAChead->pal.singleRGB = color;	// set single color of which the "palette" consists -	pDAChead->bHandle = false;		// we are not using a palette handle +	g_pDAChead->destDACindex = posInDAC & ~PALETTE_MOVED;	// set index in video DAC +	g_pDAChead->numColors = 1;	// set number of colors +	g_pDAChead->pal.singleRGB = color;	// set single color of which the "palette" consists +	g_pDAChead->bHandle = false;		// we are not using a palette handle  	// update head pointer -	++pDAChead; +	++g_pDAChead;  #ifdef DEBUG -	if ((pDAChead-vidDACdata) > maxDACQ) -		maxDACQ = pDAChead-vidDACdata; +	if ((g_pDAChead-g_vidDACdata) > maxDACQ) +		maxDACQ = g_pDAChead-g_vidDACdata;  #endif  } @@ -301,7 +301,7 @@ PALQ *AllocPalette(SCNHANDLE hNewPal) {  	pNewPal = (PALETTE *)LockMem(hNewPal);  	// search all structs in palette allocator - see if palette already allocated -	for (p = palAllocData; p < palAllocData + NUM_PALETTES; p++) { +	for (p = g_palAllocData; p < g_palAllocData + NUM_PALETTES; p++) {  		if (p->hPal == hNewPal) {  			// found the desired palette in palette allocator  			p->objCount++;	// update number of objects using palette @@ -312,7 +312,7 @@ PALQ *AllocPalette(SCNHANDLE hNewPal) {  	// search all structs in palette allocator - find a free slot  	iDAC = FGND_DAC_INDEX;	// init DAC index to first available foreground color -	for (p = palAllocData; p < palAllocData + NUM_PALETTES; p++) { +	for (p = g_palAllocData; p < g_palAllocData + NUM_PALETTES; p++) {  		if (p->hPal == 0) {  			// found a free slot in palette allocator  			p->objCount = 1;	// init number of objects using palette @@ -337,7 +337,7 @@ PALQ *AllocPalette(SCNHANDLE hNewPal) {  				UpdateDACqueueHandle(p->posInDAC, p->numColors, p->hPal);  			// move all palettes after this one down (if necessary) -			for (pPrev = p, pNxtPal = pPrev + 1; pNxtPal < palAllocData + NUM_PALETTES; pNxtPal++) { +			for (pPrev = p, pNxtPal = pPrev + 1; pNxtPal < g_palAllocData + NUM_PALETTES; pNxtPal++) {  				if (pNxtPal->hPal != 0) {  					// palette slot is in use  					if (pNxtPal->posInDAC >= pPrev->posInDAC + pPrev->numColors) @@ -381,7 +381,7 @@ PALQ *AllocPalette(SCNHANDLE hNewPal) {   */  void FreePalette(PALQ *pFreePal) {  	// validate palette Q pointer -	assert(pFreePal >= palAllocData && pFreePal <= palAllocData + NUM_PALETTES - 1); +	assert(pFreePal >= g_palAllocData && pFreePal <= g_palAllocData + NUM_PALETTES - 1);  	// reduce the palettes object reference count  	pFreePal->objCount--; @@ -408,7 +408,7 @@ PALQ *FindPalette(SCNHANDLE hSrchPal) {  	PALQ *pPal;		// palette allocator iterator  	// search all structs in palette allocator -	for (pPal = palAllocData; pPal < palAllocData + NUM_PALETTES; pPal++) { +	for (pPal = g_palAllocData; pPal < g_palAllocData + NUM_PALETTES; pPal++) {  		if (pPal->hPal == hSrchPal)  			// found palette in palette allocator  			return pPal; @@ -428,7 +428,7 @@ void SwapPalette(PALQ *pPalQ, SCNHANDLE hNewPal) {  	PALETTE *pNewPal = (PALETTE *)LockMem(hNewPal);  	// validate palette Q pointer -	assert(pPalQ >= palAllocData && pPalQ <= palAllocData + NUM_PALETTES - 1); +	assert(pPalQ >= g_palAllocData && pPalQ <= g_palAllocData + NUM_PALETTES - 1);  	if (pPalQ->numColors >= (int)FROM_LE_32(pNewPal->numColors)) {  		// new palette will fit the slot @@ -455,7 +455,7 @@ void SwapPalette(PALQ *pPalQ, SCNHANDLE hNewPal) {  		PALQ *pNxtPalQ;		// next palette queue position -		for (pNxtPalQ = pPalQ + 1; pNxtPalQ < palAllocData + NUM_PALETTES; pNxtPalQ++) { +		for (pNxtPalQ = pPalQ + 1; pNxtPalQ < g_palAllocData + NUM_PALETTES; pNxtPalQ++) {  			if (pNxtPalQ->posInDAC >= pPalQ->posInDAC + pPalQ->numColors)  				// no need to move palettes down  				break; @@ -482,14 +482,14 @@ void SwapPalette(PALQ *pPalQ, SCNHANDLE hNewPal) {  PALQ *GetNextPalette(PALQ *pStrtPal) {  	if (pStrtPal == NULL) {  		// start of palette iteration - return 1st palette -		return (palAllocData[0].objCount) ? palAllocData : NULL; +		return (g_palAllocData[0].objCount) ? g_palAllocData : NULL;  	}  	// validate palette Q pointer -	assert(pStrtPal >= palAllocData && pStrtPal <= palAllocData + NUM_PALETTES - 1); +	assert(pStrtPal >= g_palAllocData && pStrtPal <= g_palAllocData + NUM_PALETTES - 1);  	// return next active palette in list -	while (++pStrtPal < palAllocData + NUM_PALETTES) { +	while (++pStrtPal < g_palAllocData + NUM_PALETTES) {  		if (pStrtPal->objCount)  			// active palette found  			return pStrtPal; @@ -515,7 +515,7 @@ void SetBgndColor(COLORREF color) {   */  void FadingPalette(PALQ *pPalQ, bool bFading) {  	// validate palette Q pointer -	assert(pPalQ >= palAllocData && pPalQ <= palAllocData + NUM_PALETTES - 1); +	assert(pPalQ >= g_palAllocData && pPalQ <= g_palAllocData + NUM_PALETTES - 1);  	// validate that this is a change  	assert(pPalQ->bFading != bFading); @@ -530,7 +530,7 @@ void FadingPalette(PALQ *pPalQ, bool bFading) {  void NoFadingPalettes() {  	PALQ *pPalQ; -	for (pPalQ = palAllocData; pPalQ <= palAllocData + NUM_PALETTES - 1; pPalQ++) { +	for (pPalQ = g_palAllocData; pPalQ <= g_palAllocData + NUM_PALETTES - 1; pPalQ++) {  		pPalQ->bFading = false;  	}  } @@ -544,7 +544,7 @@ void CreateTranslucentPalette(SCNHANDLE hPalette) {  	PALETTE *pPal = (PALETTE *)LockMem(hPalette);  	// leave background color alone -	transPalette[0] = 0; +	g_transPalette[0] = 0;  	for (uint i = 0; i < FROM_LE_32(pPal->numColors); i++) {  		// get the RGB color model values @@ -558,7 +558,7 @@ void CreateTranslucentPalette(SCNHANDLE hPalette) {  		// map the Value field to one of the 4 colors reserved for the translucent palette  		val /= 63; -		transPalette[i + 1] = (uint8)((val == 0) ? 0 : val + +		g_transPalette[i + 1] = (uint8)((val == 0) ? 0 : val +  			(TinselV2 ? TranslucentColor() : COL_HILIGHT) - 1);  	}  } @@ -572,7 +572,7 @@ void CreateGhostPalette(SCNHANDLE hPalette) {  	int i;  	// leave background color alone -	ghostPalette[0] = 0; +	g_ghostPalette[0] = 0;  	for (i = 0; i < (int)FROM_LE_32(pPal->numColors); i++) {  		// get the RGB color model values @@ -587,7 +587,7 @@ void CreateGhostPalette(SCNHANDLE hPalette) {  		// map the Value field to one of the 4 colors reserved for the translucent palette  		val /= 64;  		assert(/*val >= 0 &&*/ val <= 3); -		ghostPalette[i + 1] = (uint8)(val + SysVar(ISV_GHOST_BASE)); +		g_ghostPalette[i + 1] = (uint8)(val + SysVar(ISV_GHOST_BASE));  	}  } @@ -648,41 +648,41 @@ void DimPartPalette(SCNHANDLE hDimPal, int startColor, int length, int brightnes  }  int TranslucentColor() { -	return translucentIndex; +	return g_translucentIndex;  }  int HighlightColor() { -	UpdateDACqueue(talkIndex, (COLORREF)SysVar(SYS_HighlightRGB)); +	UpdateDACqueue(g_talkIndex, (COLORREF)SysVar(SYS_HighlightRGB)); -	return talkIndex; +	return g_talkIndex;  }  int TalkColor() { -	return TinselV2 ? talkIndex : TALKFONT_COL; +	return TinselV2 ? g_talkIndex : TALKFONT_COL;  }  void SetTalkColorRef(COLORREF colRef) { -	talkColRef = colRef; +	g_talkColRef = colRef;  }  COLORREF GetTalkColorRef() { -	return talkColRef; +	return g_talkColRef;  }  void SetTagColorRef(COLORREF colRef) { -	tagColRef = colRef; +	g_tagColRef = colRef;  }  COLORREF GetTagColorRef() { -	return tagColRef; +	return g_tagColRef;  }  void SetTranslucencyOffset(int offset) { -	translucentIndex = offset; +	g_translucentIndex = offset;  }  void SetTalkTextOffset(int offset) { -	talkIndex = offset; +	g_talkIndex = offset;  }  } // End of namespace Tinsel diff --git a/engines/tinsel/pcode.cpp b/engines/tinsel/pcode.cpp index 2ab1e653d4..145a6a8e5d 100644 --- a/engines/tinsel/pcode.cpp +++ b/engines/tinsel/pcode.cpp @@ -100,19 +100,19 @@ enum OPCODE {  #define	OPMASK		0x3F	///< mask to isolate the opcode -bool bNoPause = false; +bool g_bNoPause = false;  //----------------- LOCAL GLOBAL DATA --------------------  // FIXME: Avoid non-const global vars -static int32 *pGlobals = 0;		// global vars +static int32 *g_pGlobals = 0;		// global vars -static int numGlobals = 0;		// How many global variables to save/restore +static int g_numGlobals = 0;		// How many global variables to save/restore -static INT_CONTEXT *icList = 0; +static INT_CONTEXT *g_icList = 0; -static uint32 hMasterScript; +static uint32 g_hMasterScript;  //----------------- SCRIPT BUGS WORKAROUNDS -------------- @@ -227,7 +227,7 @@ void LockCode(INT_CONTEXT *ic) {  	if (ic->GSort == GS_MASTER) {  		if (TinselV2)  			// Get the srcipt handle from a specific global chunk -			ic->code = (byte *)LockMem(hMasterScript); +			ic->code = (byte *)LockMem(g_hMasterScript);  		else  			ic->code = (byte *)FindChunk(MASTER_SCNHANDLE, CHUNK_PCODE);  	} else @@ -241,7 +241,7 @@ static INT_CONTEXT *AllocateInterpretContext(GSORT gsort) {  	INT_CONTEXT *pic;  	int	i; -	for (i = 0, pic = icList; i < NUM_INTERPRET; i++, pic++) { +	for (i = 0, pic = g_icList; i < NUM_INTERPRET; i++, pic++) {  		if (pic->GSort == GS_NONE) {  			pic->pProc = g_scheduler->getCurrentProcess();  			pic->GSort = gsort; @@ -264,8 +264,8 @@ static void FreeWaitCheck(PINT_CONTEXT pic, bool bVoluntary) {  	// Is this waiting for something?  	if (pic->waitNumber1) {  		for (i = 0; i < NUM_INTERPRET; i++) { -			if ((icList + i)->waitNumber2 == pic->waitNumber1) { -				(icList + i)->waitNumber2 = 0; +			if ((g_icList + i)->waitNumber2 == pic->waitNumber1) { +				(g_icList + i)->waitNumber2 = 0;  				break;  			}  		} @@ -274,10 +274,10 @@ static void FreeWaitCheck(PINT_CONTEXT pic, bool bVoluntary) {  	// Is someone waiting for this?  	if (pic->waitNumber2) {  		for (i = 0; i < NUM_INTERPRET; i++) { -			if ((icList + i)->waitNumber1 == pic->waitNumber2) { -				(icList + i)->waitNumber1 = 0; -				(icList + i)->resumeCode = bVoluntary ? RES_FINISHED : RES_CUTSHORT; -				g_scheduler->reschedule((icList + i)->pProc); +			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);  				break;  			}  		} @@ -305,7 +305,7 @@ void FreeInterpretContextPr(PROCESS *pProc) {  	INT_CONTEXT *pic;  	int	i; -	for (i = 0, pic = icList; i < NUM_INTERPRET; i++, pic++) { +	for (i = 0, pic = g_icList; i < NUM_INTERPRET; i++, pic++) {  		if (pic->GSort != GS_NONE && pic->pProc == pProc) {  			FreeWaitCheck(pic, false);  			if (TinselV2) @@ -323,7 +323,7 @@ void FreeMostInterpretContexts() {  	INT_CONTEXT *pic;  	int	i; -	for (i = 0, pic = icList; i < NUM_INTERPRET; i++, pic++) { +	for (i = 0, pic = g_icList; i < NUM_INTERPRET; i++, pic++) {  		if ((pic->GSort != GS_MASTER) && (pic->GSort != GS_GPROCESS)) {  			memset(pic, 0, sizeof(INT_CONTEXT));  			pic->GSort = GS_NONE; @@ -338,7 +338,7 @@ void FreeMasterInterpretContext() {  	INT_CONTEXT *pic;  	int	i; -	for (i = 0, pic = icList; i < NUM_INTERPRET; i++, pic++)	{ +	for (i = 0, pic = g_icList; i < NUM_INTERPRET; i++, pic++)	{  		if ((pic->GSort == GS_MASTER) || (pic->GSort == GS_GPROCESS)) {  			memset(pic, 0, sizeof(INT_CONTEXT));  			pic->GSort = GS_NONE; @@ -405,30 +405,30 @@ INT_CONTEXT *RestoreInterpretContext(INT_CONTEXT *ric) {   * Allocates enough RAM to hold the global Glitter variables.   */  void RegisterGlobals(int num) { -	if (pGlobals == NULL) { -		numGlobals = num; +	if (g_pGlobals == NULL) { +		g_numGlobals = num; -		hMasterScript = !TinselV2 ? 0 : +		g_hMasterScript = !TinselV2 ? 0 :  			READ_LE_UINT32(FindChunk(MASTER_SCNHANDLE, CHUNK_MASTER_SCRIPT));  		// Allocate RAM for pGlobals and make sure it's allocated -		pGlobals = (int32 *)calloc(numGlobals, sizeof(int32)); -		if (pGlobals == NULL) { +		g_pGlobals = (int32 *)calloc(g_numGlobals, sizeof(int32)); +		if (g_pGlobals == NULL) {  			error("Cannot allocate memory for global data");  		}  		// Allocate RAM for interpret contexts and make sure it's allocated -		icList = (INT_CONTEXT *)calloc(NUM_INTERPRET, sizeof(INT_CONTEXT)); -		if (icList == NULL) { +		g_icList = (INT_CONTEXT *)calloc(NUM_INTERPRET, sizeof(INT_CONTEXT)); +		if (g_icList == NULL) {  			error("Cannot allocate memory for interpret contexts");  		}  		g_scheduler->setResourceCallback(FreeInterpretContextPr);  	} else {  		// Check size is still the same -		assert(numGlobals == num); +		assert(g_numGlobals == num); -		memset(pGlobals, 0, numGlobals * sizeof(int32)); -		memset(icList, 0, NUM_INTERPRET * sizeof(INT_CONTEXT)); +		memset(g_pGlobals, 0, g_numGlobals * sizeof(int32)); +		memset(g_icList, 0, NUM_INTERPRET * sizeof(INT_CONTEXT));  	}  	if (TinselV2) { @@ -444,7 +444,7 @@ void RegisterGlobals(int num) {  			error(FILE_IS_CORRUPT, GLOBALS_FILENAME);  		for (int i = 0; i < length; ++i) -			pGlobals[i] = f.readSint32LE(); +			g_pGlobals[i] = f.readSint32LE();  		if (f.eos() || f.err())  			error(FILE_IS_CORRUPT, GLOBALS_FILENAME); @@ -454,19 +454,19 @@ void RegisterGlobals(int num) {  }  void FreeGlobals() { -	free(pGlobals); -	pGlobals = NULL; +	free(g_pGlobals); +	g_pGlobals = NULL; -	free(icList); -	icList = NULL; +	free(g_icList); +	g_icList = NULL;  }  /**   * (Un)serialize the global data for save/restore game.   */  void syncGlobInfo(Common::Serializer &s) { -	for (int i = 0; i < numGlobals; i++) { -		s.syncAsSint32LE(pGlobals[i]); +	for (int i = 0; i < g_numGlobals; i++) { +		s.syncAsSint32LE(g_pGlobals[i]);  	}  } @@ -502,7 +502,7 @@ void INT_CONTEXT::syncWithSerializer(Common::Serializer &s) {   * Return pointer to and size of global data for save/restore game.   */  void SaveInterpretContexts(INT_CONTEXT *sICInfo) { -	memcpy(sICInfo, icList, NUM_INTERPRET * sizeof(INT_CONTEXT)); +	memcpy(sICInfo, g_icList, NUM_INTERPRET * sizeof(INT_CONTEXT));  }  /** @@ -633,8 +633,8 @@ void Interpret(CORO_PARAM, INT_CONTEXT *ic) {  		case OP_GLOAD:				// loads global variable onto stack  			tmp = Fetch(opcode, ic->code, wkEntry, ip); -			assert(0 <= tmp && tmp < numGlobals); -			ic->stack[++ic->sp] = pGlobals[tmp]; +			assert(0 <= tmp && tmp < g_numGlobals); +			ic->stack[++ic->sp] = g_pGlobals[tmp];  			break;  		case OP_STORE:				// pops stack and stores in local variable @@ -645,8 +645,8 @@ void Interpret(CORO_PARAM, INT_CONTEXT *ic) {  		case OP_GSTORE:				// pops stack and stores in global variable  			tmp = Fetch(opcode, ic->code, wkEntry, ip); -			assert(0 <= tmp && tmp < numGlobals); -			pGlobals[tmp] = ic->stack[ic->sp--]; +			assert(0 <= tmp && tmp < g_numGlobals); +			g_pGlobals[tmp] = ic->stack[ic->sp--];  			break;  		case OP_CALL:				// procedure call @@ -809,7 +809,7 @@ void Interpret(CORO_PARAM, INT_CONTEXT *ic) {  			break;  		case OP_ESCON: -			bNoPause = true; +			g_bNoPause = true;  			ic->escOn = true;  			ic->myEscape = GetEscEvents();  			break; @@ -856,8 +856,8 @@ static uint32 UniqueWaitNumber() {  			retval = (uint32)-1;  		for (i = 0; i < NUM_INTERPRET; i++) { -			if ((icList+i)->waitNumber1 == retval -			 || (icList+i)->waitNumber2 == retval) +			if ((g_icList+i)->waitNumber1 == retval +			 || (g_icList+i)->waitNumber2 == retval)  				break;  		} @@ -887,7 +887,7 @@ void WaitInterpret(CORO_PARAM, PPROCESS pWaitProc, bool *result) {  	CORO_BEGIN_CODE(_ctx); -	for (i = 0, _ctx->picWaiter = icList; i < NUM_INTERPRET; i++, _ctx->picWaiter++) { +	for (i = 0, _ctx->picWaiter = g_icList; i < NUM_INTERPRET; i++, _ctx->picWaiter++) {  		if (_ctx->picWaiter->GSort != GS_NONE && _ctx->picWaiter->pProc == currentProcess) {  			break;  		} @@ -896,7 +896,7 @@ void WaitInterpret(CORO_PARAM, PPROCESS pWaitProc, bool *result) {  	/*  	 * Find the interpret context of the process we're waiting for  	 */ -	for (i = 0, _ctx->picWaitee = icList; i < NUM_INTERPRET; i++, _ctx->picWaitee++) { +	for (i = 0, _ctx->picWaitee = g_icList; i < NUM_INTERPRET; i++, _ctx->picWaitee++) {  		if (_ctx->picWaitee->GSort != GS_NONE && _ctx->picWaitee->pProc == pWaitProc) {  			break;  		} @@ -931,11 +931,11 @@ void CheckOutWaiters() {  	// Check all waited for have someone waiting  	for (i = 0; i < NUM_INTERPRET; i++)	{  		// If someone is supposedly waiting for this one -		if ((icList + i)->GSort != GS_NONE && (icList + i)->waitNumber2) { +		if ((g_icList + i)->GSort != GS_NONE && (g_icList + i)->waitNumber2) {  			// Someone really must be waiting for this one  			for (j = 0; j < NUM_INTERPRET; j++) { -				if ((icList + j)->GSort != GS_NONE -				 && (icList + j)->waitNumber1 == (icList + i)->waitNumber2) { +				if ((g_icList + j)->GSort != GS_NONE +				 && (g_icList + j)->waitNumber1 == (g_icList + i)->waitNumber2) {  					break;  				}  			} @@ -946,11 +946,11 @@ void CheckOutWaiters() {  	// Check waiting for someone to wait for  	for (i = 0; i < NUM_INTERPRET; i++) {  		// If someone is supposedly waiting for this one -		if ((icList + i)->GSort != GS_NONE && (icList + i)->waitNumber1) { +		if ((g_icList + i)->GSort != GS_NONE && (g_icList + i)->waitNumber1) {  			// Someone really must be waiting for this one  			for (j = 0; j < NUM_INTERPRET; j++) { -				if ((icList + j)->GSort != GS_NONE -				 && (icList + j)->waitNumber2 == (icList + i)->waitNumber1) { +				if ((g_icList + j)->GSort != GS_NONE +				 && (g_icList + j)->waitNumber2 == (g_icList + i)->waitNumber1) {  					break;  				}  			} diff --git a/engines/tinsel/pdisplay.cpp b/engines/tinsel/pdisplay.cpp index 7439c6f77d..9a9e6ab00f 100644 --- a/engines/tinsel/pdisplay.cpp +++ b/engines/tinsel/pdisplay.cpp @@ -50,7 +50,7 @@ namespace Tinsel {  #ifdef DEBUG  //extern int Overrun;		// The overrun counter, in DOS_DW.C -extern int newestString;	// The overrun counter, in STRRES.C +extern int g_newestString;	// The overrun counter, in STRRES.C  #endif @@ -73,17 +73,17 @@ enum HotSpotTag {  // FIXME: Avoid non-const global vars -static bool DispPath = false; -static bool bShowString = false; +static bool g_DispPath = false; +static bool g_bShowString = false; -static int	TaggedActor = 0; -static HPOLYGON	hTaggedPolygon = NOPOLY; +static int	g_TaggedActor = 0; +static HPOLYGON	g_hTaggedPolygon = NOPOLY; -static bool bTagsActive = true; +static bool g_bTagsActive = true; -static bool bPointingActive = true; +static bool g_bPointingActive = true; -static char tagBuffer[64]; +static char g_tagBuffer[64];  #ifdef DEBUG  /** @@ -158,7 +158,7 @@ void CursorPositionProcess(CORO_PARAM, const void *) {  			sprintf(PositionString, "%d %d", aniX + Loffset, aniY + Toffset);  			_ctx->cpText = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), PositionString,  						0, CPOSX, POSY, GetTagFontHandle(), TXT_CENTER); -			if (DispPath) { +			if (g_DispPath) {  				HPOLYGON hp = InPolygon(aniX + Loffset, aniY + Toffset, PATH);  				if (hp == NOPOLY)  					sprintf(PositionString, "No path"); @@ -226,18 +226,18 @@ void CursorPositionProcess(CORO_PARAM, const void *) {  		/*-------------*\  		| String number	|  		\*-------------*/ -		if (bShowString && newestString != _ctx->prevString) { +		if (g_bShowString && g_newestString != _ctx->prevString) {  			// kill current text objects  			if (_ctx->spText) {  				MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), _ctx->spText);  			} -			sprintf(PositionString, "String: %d", newestString); +			sprintf(PositionString, "String: %d", g_newestString);  			_ctx->spText = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), PositionString,  						0, SPOSX, POSY+10, GetTalkFontHandle(), TXT_CENTER);  			// update previous value -			_ctx->prevString = newestString; +			_ctx->prevString = g_newestString;  		}  		// update previous playfield position @@ -257,7 +257,7 @@ void DisablePointing() {  	int	i;  	HPOLYGON hPoly;		// Polygon handle -	bPointingActive = false; +	g_bPointingActive = false;  	for (i = 0; i < MAX_POLY; i++)	{  		hPoly = GetPolyHandle(i); @@ -284,7 +284,7 @@ void DisablePointing() {   * EnablePointing()   */  void EnablePointing() { -	bPointingActive = true; +	g_bPointingActive = true;  }  /** @@ -292,7 +292,7 @@ void EnablePointing() {   * (if one is). Tag process asks us for this information, as does ProcessUserEvent().   */  static void SaveTaggedActor(int ano) { -	TaggedActor = ano; +	g_TaggedActor = ano;  }  /** @@ -300,7 +300,7 @@ static void SaveTaggedActor(int ano) {   * (if one is). Tag process asks us for this information, as does ProcessUserEvent().   */  int GetTaggedActor() { -	return TaggedActor; +	return g_TaggedActor;  }  /** @@ -308,11 +308,11 @@ int GetTaggedActor() {   * (if one is). Tag process asks us for this information, as does ProcessUserEvent().   */  static void SaveTaggedPoly(HPOLYGON hp) { -	hTaggedPolygon = hp; +	g_hTaggedPolygon = hp;  }  HPOLYGON GetTaggedPoly() { -	return hTaggedPolygon; +	return g_hTaggedPolygon;  }  /** @@ -405,11 +405,11 @@ static bool ActorTag(int curX, int curY, HotSpotTag *pTag, OBJECT **ppText) {  			if (ActorTagIsWanted(actor)) {  				GetActorTagPos(actor, &tagX, &tagY, false); -				LoadStringRes(GetActorTagHandle(actor), tagBuffer, sizeof(tagBuffer)); +				LoadStringRes(GetActorTagHandle(actor), g_tagBuffer, sizeof(g_tagBuffer));  				// May have buggered cursor  				EndCursorFollowed(); -				*ppText = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), tagBuffer, +				*ppText = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), g_tagBuffer,  						0, tagX, tagY, GetTagFontHandle(), TXT_CENTER, 0);  				assert(*ppText);  				MultiSetZPosition(*ppText, Z_TAG_TEXT); @@ -653,7 +653,7 @@ void TagProcess(CORO_PARAM, const void *) {  	SaveTaggedPoly(NOPOLY);		// No tagged polygon yet  	while (1) { -		if (bTagsActive) { +		if (g_bTagsActive) {  			int	curX, curY;	// cursor position  			while (!GetCursorXYNoWait(&curX, &curY, true))  				CORO_SLEEP(1); @@ -804,7 +804,7 @@ void PointProcess(CORO_PARAM, const void *) {  			// allow re-scheduling  			do {  				CORO_SLEEP(1); -			} while (!bPointingActive); +			} while (!g_bPointingActive);  		} else {  			// allow re-scheduling  			CORO_SLEEP(1); @@ -815,15 +815,15 @@ void PointProcess(CORO_PARAM, const void *) {  }  void DisableTags() { -	bTagsActive = false; +	g_bTagsActive = false;  }  void EnableTags() { -	bTagsActive = true; +	g_bTagsActive = true;  }  bool DisableTagsIfEnabled() { -	if (bTagsActive) { +	if (g_bTagsActive) {  		DisableTags();  		return true;  	} else @@ -836,12 +836,12 @@ bool DisableTagsIfEnabled() {   * cursor is in.   */  void TogglePathDisplay() { -	DispPath ^= 1;	// Toggle path display (XOR with true) +	g_DispPath ^= 1;	// Toggle path display (XOR with true)  }  void setshowstring() { -	bShowString = true; +	g_bShowString = true;  }  } // End of namespace Tinsel diff --git a/engines/tinsel/play.cpp b/engines/tinsel/play.cpp index 71e07721a6..40729d9f3a 100644 --- a/engines/tinsel/play.cpp +++ b/engines/tinsel/play.cpp @@ -62,10 +62,10 @@ struct PPINIT {  // FIXME: Avoid non-const global vars -static SOUNDREELS soundReels[MAX_SOUNDREELS]; -static int soundReelNumbers[MAX_SOUNDREELS]; +static SOUNDREELS g_soundReels[MAX_SOUNDREELS]; +static int g_soundReelNumbers[MAX_SOUNDREELS]; -static int soundReelWait; +static int g_soundReelWait;  //-------------------- METHODS ---------------------- @@ -148,31 +148,31 @@ static int RegisterSoundReel(SCNHANDLE hFilm, int column, int actorCol) {  	for (i = 0; i < MAX_SOUNDREELS; i++) {  		// Should assert this doesn't happen, but let's be tolerant -		if (soundReels[i].hFilm == hFilm && soundReels[i].column == column) +		if (g_soundReels[i].hFilm == hFilm && g_soundReels[i].column == column)  			break; -		if (!soundReels[i].hFilm) { -			soundReels[i].hFilm = hFilm; -			soundReels[i].column = column; -			soundReels[i].actorCol = actorCol; +		if (!g_soundReels[i].hFilm) { +			g_soundReels[i].hFilm = hFilm; +			g_soundReels[i].column = column; +			g_soundReels[i].actorCol = actorCol;  			break;  		}  	} -	soundReelNumbers[i]++; +	g_soundReelNumbers[i]++;  	return i;  }  void NoSoundReels() { -	memset(soundReels, 0, sizeof(soundReels)); -	soundReelWait = 0; +	memset(g_soundReels, 0, sizeof(g_soundReels)); +	g_soundReelWait = 0;  }  static void DeRegisterSoundReel(SCNHANDLE hFilm, int column) {  	for (int i = 0; i < MAX_SOUNDREELS; i++) {  		// Should assert this doesn't happen, but let's be tolerant -		if (soundReels[i].hFilm == hFilm && soundReels[i].column == column) { -			soundReels[i].hFilm = 0; +		if (g_soundReels[i].hFilm == hFilm && g_soundReels[i].column == column) { +			g_soundReels[i].hFilm = 0;  			break;  		}  	} @@ -180,15 +180,15 @@ static void DeRegisterSoundReel(SCNHANDLE hFilm, int column) {  void SaveSoundReels(PSOUNDREELS psr) {  	for (int i = 0; i < MAX_SOUNDREELS; i++) { -		if (IsCdPlayHandle(soundReels[i].hFilm)) -			soundReels[i].hFilm = 0; +		if (IsCdPlayHandle(g_soundReels[i].hFilm)) +			g_soundReels[i].hFilm = 0;  	} -	memcpy(psr, soundReels, sizeof(soundReels)); +	memcpy(psr, g_soundReels, sizeof(g_soundReels));  }  void RestoreSoundReels(PSOUNDREELS psr) { -	memcpy(soundReels, psr, sizeof(soundReels)); +	memcpy(g_soundReels, psr, sizeof(g_soundReels));  }  static uint32 GetZfactor(int actorID, PMOVER pMover, bool bNewMover) { @@ -245,7 +245,7 @@ static void SoundReel(CORO_PARAM, SCNHANDLE hFilm, int column, int speed,  	_ctx->bFinished = false;  	_ctx->bLooped = false;  	_ctx->myId = RegisterSoundReel(hFilm, column, actorCol); -	_ctx->myNum = soundReelNumbers[_ctx->myId]; +	_ctx->myNum = g_soundReelNumbers[_ctx->myId];  	do {  		pFilm = (FILM *)LockMem(hFilm); @@ -366,10 +366,10 @@ static void SoundReel(CORO_PARAM, SCNHANDLE hFilm, int column, int speed,  			_ctx->bFinished = true;  		} -	} while (!_ctx->bFinished && _ctx->myNum == soundReelNumbers[_ctx->myId]); +	} while (!_ctx->bFinished && _ctx->myNum == g_soundReelNumbers[_ctx->myId]);  	// De-register - if not been replaced -	if (_ctx->myNum == soundReelNumbers[_ctx->myId]) +	if (_ctx->myNum == g_soundReelNumbers[_ctx->myId])  		DeRegisterSoundReel(hFilm, column);  	CORO_END_CODE; @@ -384,17 +384,17 @@ static void ResSoundReel(CORO_PARAM, const void *param) {  	CORO_BEGIN_CODE(_ctx); -	CORO_INVOKE_ARGS(SoundReel, (CORO_SUBCTX, soundReels[i].hFilm, soundReels[i].column, -		-1, 0, soundReels[i].actorCol)); +	CORO_INVOKE_ARGS(SoundReel, (CORO_SUBCTX, g_soundReels[i].hFilm, g_soundReels[i].column, +		-1, 0, g_soundReels[i].actorCol));  	CORO_KILL_SELF();  	CORO_END_CODE;  }  static void SoundReelWaitCheck() { -	if (--soundReelWait == 0) { +	if (--g_soundReelWait == 0) {  		for (int i = 0; i < MAX_SOUNDREELS; i++) { -			if (soundReels[i].hFilm) { +			if (g_soundReels[i].hFilm) {  				g_scheduler->createProcess(PID_REEL, ResSoundReel, &i, sizeof(i));  			}  		} @@ -1162,7 +1162,7 @@ void RestoreActorReels(SCNHANDLE hFilm, int actor, int x, int y) {  			// Start display process for the reel  			g_scheduler->createProcess(PID_REEL, PlayProcess, &ppi, sizeof(ppi)); -			soundReelWait++; +			g_soundReelWait++;  		}  	}  } diff --git a/engines/tinsel/rince.cpp b/engines/tinsel/rince.cpp index ca196aac92..bb0aeabd2f 100644 --- a/engines/tinsel/rince.cpp +++ b/engines/tinsel/rince.cpp @@ -51,7 +51,7 @@ namespace Tinsel {  //----------------- LOCAL GLOBAL DATA -------------------- -static MOVER Movers[MAX_MOVERS];	// FIXME: Avoid non-const global vars +static MOVER g_Movers[MAX_MOVERS];	// FIXME: Avoid non-const global vars  //----------------- FUNCTIONS ---------------------------- @@ -115,7 +115,7 @@ void MoverBrightness(PMOVER pMover, int brightness) {   * RebootMovers   */  void RebootMovers() { -	memset(Movers, 0, sizeof(Movers)); +	memset(g_Movers, 0, sizeof(g_Movers));  }  /** @@ -127,11 +127,11 @@ PMOVER GetMover(int ano) {  	// Slot 0 is reserved for lead actor  	if (ano == GetLeadId() || ano == LEAD_ACTOR) -		return &Movers[0]; +		return &g_Movers[0];  	for (i = 1; i < MAX_MOVERS; i++) -		if (Movers[i].actorID == ano) -			return &Movers[i]; +		if (g_Movers[i].actorID == ano) +			return &g_Movers[i];  	return NULL;  } @@ -144,25 +144,25 @@ PMOVER RegisterMover(int ano) {  	// Slot 0 is reserved for lead actor  	if (ano == GetLeadId() || ano == LEAD_ACTOR) { -		Movers[0].actorToken = TOKEN_LEAD; -		Movers[0].actorID = GetLeadId(); -		return &Movers[0]; +		g_Movers[0].actorToken = TOKEN_LEAD; +		g_Movers[0].actorID = GetLeadId(); +		return &g_Movers[0];  	}  	// Check it hasn't already been declared  	for (i = 1; i < MAX_MOVERS; i++) { -		if (Movers[i].actorID == ano) { +		if (g_Movers[i].actorID == ano) {  			// Actor is already a moving actor -			return &Movers[i]; +			return &g_Movers[i];  		}  	}  	// Find an empty slot  	for (i = 1; i < MAX_MOVERS; i++) -		if (!Movers[i].actorID) { -			Movers[i].actorToken = TOKEN_LEAD + i; -			Movers[i].actorID = ano; -			return &Movers[i]; +		if (!g_Movers[i].actorID) { +			g_Movers[i].actorToken = TOKEN_LEAD + i; +			g_Movers[i].actorID = ano; +			return &g_Movers[i];  		}  	error("Too many moving actors"); @@ -176,8 +176,8 @@ PMOVER RegisterMover(int ano) {  PMOVER GetLiveMover(int index) {  	assert(index >= 0 && index < MAX_MOVERS); // out of range -	if (Movers[index].bActive) -		return &Movers[index]; +	if (g_Movers[index].bActive) +		return &g_Movers[index];  	else  		return NULL;  } @@ -185,13 +185,13 @@ PMOVER GetLiveMover(int index) {  bool IsMAinEffectPoly(int index) {  	assert(index >= 0 && index < MAX_MOVERS); // out of range -	return Movers[index].bInEffect; +	return g_Movers[index].bInEffect;  }  void SetMoverInEffect(int index, bool tf) {  	assert(index >= 0 && index < MAX_MOVERS); // out of range -	Movers[index].bInEffect = tf; +	g_Movers[index].bInEffect = tf;  }  /** @@ -392,7 +392,7 @@ static void InitMover(PMOVER pMover) {   */  void DropMovers() {  	for (int i = 0; i < MAX_MOVERS; i++) -		InitMover(&Movers[i]); +		InitMover(&g_Movers[i]);  } @@ -880,30 +880,30 @@ PMOVER InMoverBlock(PMOVER pMover, int x, int y) {  	caR = GetMoverRight(pMover) + x - caX;  	for (int i = 0; i < MAX_MOVERS; i++) { -		if (pMover == &Movers[i] || -				(TinselV2 && (Movers[i].actorObj == NULL)) || -				(!TinselV2 && !Movers[i].bActive)) +		if (pMover == &g_Movers[i] || +				(TinselV2 && (g_Movers[i].actorObj == NULL)) || +				(!TinselV2 && !g_Movers[i].bActive))  			continue;  		// At around the same height? -		GetMoverPosition(&Movers[i], &taX, &taY); -		if (Movers[i].hFnpath != NOPOLY) +		GetMoverPosition(&g_Movers[i], &taX, &taY); +		if (g_Movers[i].hFnpath != NOPOLY)  			continue;  		if (ABS(y - taY) > 2)	// 2 was 8  			continue;  		// To the left? -		taL = GetMoverLeft(&Movers[i]); +		taL = GetMoverLeft(&g_Movers[i]);  		if (caR <= taL)  			continue;  		// To the right? -		taR = GetMoverRight(&Movers[i]); +		taR = GetMoverRight(&g_Movers[i]);  		if (caL >= taR)  			continue; -		return &Movers[i]; +		return &g_Movers[i];  	}  	return NULL;  } @@ -913,33 +913,33 @@ PMOVER InMoverBlock(PMOVER pMover, int x, int y) {   */  void SaveMovers(SAVED_MOVER *sMoverInfo) {  	for (int i = 0; i < MAX_MOVERS; i++) { -		sMoverInfo[i].bActive = !TinselV2 ? Movers[i].bActive : Movers[i].actorObj != NULL; -		sMoverInfo[i].actorID	= Movers[i].actorID; -		sMoverInfo[i].objX	= Movers[i].objX; -		sMoverInfo[i].objY	= Movers[i].objY; -		sMoverInfo[i].hLastfilm	= Movers[i].hLastFilm; +		sMoverInfo[i].bActive = !TinselV2 ? g_Movers[i].bActive : g_Movers[i].actorObj != NULL; +		sMoverInfo[i].actorID	= g_Movers[i].actorID; +		sMoverInfo[i].objX	= g_Movers[i].objX; +		sMoverInfo[i].objY	= g_Movers[i].objY; +		sMoverInfo[i].hLastfilm	= g_Movers[i].hLastFilm;  		if (TinselV2) { -			sMoverInfo[i].bHidden = Movers[i].bHidden; -			sMoverInfo[i].brightness = Movers[i].brightness; -			sMoverInfo[i].startColor = Movers[i].startColor; -			sMoverInfo[i].paletteLength = Movers[i].paletteLength; +			sMoverInfo[i].bHidden = g_Movers[i].bHidden; +			sMoverInfo[i].brightness = g_Movers[i].brightness; +			sMoverInfo[i].startColor = g_Movers[i].startColor; +			sMoverInfo[i].paletteLength = g_Movers[i].paletteLength;  		} -		memcpy(sMoverInfo[i].walkReels, Movers[i].walkReels, TOTAL_SCALES * 4 * sizeof(SCNHANDLE)); -		memcpy(sMoverInfo[i].standReels, Movers[i].standReels, TOTAL_SCALES * 4 * sizeof(SCNHANDLE)); -		memcpy(sMoverInfo[i].talkReels, Movers[i].talkReels, TOTAL_SCALES * 4 * sizeof(SCNHANDLE)); +		memcpy(sMoverInfo[i].walkReels, g_Movers[i].walkReels, TOTAL_SCALES * 4 * sizeof(SCNHANDLE)); +		memcpy(sMoverInfo[i].standReels, g_Movers[i].standReels, TOTAL_SCALES * 4 * sizeof(SCNHANDLE)); +		memcpy(sMoverInfo[i].talkReels, g_Movers[i].talkReels, TOTAL_SCALES * 4 * sizeof(SCNHANDLE));  	}  }  void RestoreAuxScales(SAVED_MOVER *sMoverInfo) {  	for (int i = 0; i < MAX_MOVERS; i++) {  		if (TinselV2) -			Movers[i].actorID = sMoverInfo[i].actorID; +			g_Movers[i].actorID = sMoverInfo[i].actorID; -		memcpy(Movers[i].walkReels, sMoverInfo[i].walkReels, TOTAL_SCALES * 4 * sizeof(SCNHANDLE)); -		memcpy(Movers[i].standReels, sMoverInfo[i].standReels, TOTAL_SCALES * 4 * sizeof(SCNHANDLE)); -		memcpy(Movers[i].talkReels, sMoverInfo[i].talkReels, TOTAL_SCALES * 4 * sizeof(SCNHANDLE)); +		memcpy(g_Movers[i].walkReels, sMoverInfo[i].walkReels, TOTAL_SCALES * 4 * sizeof(SCNHANDLE)); +		memcpy(g_Movers[i].standReels, sMoverInfo[i].standReels, TOTAL_SCALES * 4 * sizeof(SCNHANDLE)); +		memcpy(g_Movers[i].talkReels, sMoverInfo[i].talkReels, TOTAL_SCALES * 4 * sizeof(SCNHANDLE));  	}  } @@ -950,10 +950,10 @@ PMOVER NextMover(PMOVER pMover) {  	if (pMover == NULL)  		next = 0;  	else -		next = pMover - Movers + 1; +		next = pMover - g_Movers + 1; -	if (Movers[next].actorID) -		return &Movers[next]; +	if (g_Movers[next].actorID) +		return &g_Movers[next];  	else  		return NULL;  } diff --git a/engines/tinsel/saveload.cpp b/engines/tinsel/saveload.cpp index f8598c05f8..0a552c8c2b 100644 --- a/engines/tinsel/saveload.cpp +++ b/engines/tinsel/saveload.cpp @@ -68,9 +68,9 @@ namespace Tinsel {  //----------------- GLOBAL GLOBAL DATA -------------------- -int	thingHeld = 0; -int	restoreCD = 0; -SRSTATE SRstate = SR_IDLE; +int	g_thingHeld = 0; +int	g_restoreCD = 0; +SRSTATE g_SRstate = SR_IDLE;  //----------------- EXTERN FUNCTIONS -------------------- @@ -83,9 +83,9 @@ extern void syncGlobInfo(Common::Serializer &s);  // in POLYGONS.C  extern void syncPolyInfo(Common::Serializer &s); -extern int sceneCtr; +extern int g_sceneCtr; -extern bool ASceneIsSaved; +extern bool g_ASceneIsSaved;  //----------------- LOCAL DEFINES -------------------- @@ -123,21 +123,23 @@ struct SFILES {  // FIXME: Avoid non-const global vars -static int	numSfiles = 0; -static SFILES	savedFiles[MAX_SAVED_FILES]; +static int	g_numSfiles = 0; +static SFILES	g_savedFiles[MAX_SAVED_FILES]; -static bool NeedLoad = true; +static bool g_NeedLoad = true; -static SAVED_DATA *srsd = 0; -static int RestoreGameNumber = 0; -static char *SaveSceneName = 0; -static const char *SaveSceneDesc = 0; -static int *SaveSceneSsCount = 0; -static SAVED_DATA *SaveSceneSsData = 0;	// points to 'SAVED_DATA ssdata[MAX_NEST]' +static SAVED_DATA *g_srsd = 0; +static int g_RestoreGameNumber = 0; +static char *g_SaveSceneName = 0; +static const char *g_SaveSceneDesc = 0; +static int *g_SaveSceneSsCount = 0; +static SAVED_DATA *g_SaveSceneSsData = 0;	// points to 'SAVED_DATA ssdata[MAX_NEST]'  //------------- SAVE/LOAD SUPPORT METHODS ---------------- -void setNeedLoad() { NeedLoad = true; } +void setNeedLoad() { +	g_NeedLoad = true; +}  static void syncTime(Common::Serializer &s, TimeDate &t) {  	s.syncAsUint16LE(t.tm_year); @@ -345,18 +347,18 @@ static int cmpTimeDate(const TimeDate &a, const TimeDate &b) {  int getList(Common::SaveFileManager *saveFileMan, const Common::String &target) {  	// No change since last call?  	// TODO/FIXME: Just always reload this data? Be careful about slow downs!!! -	if (!NeedLoad) -		return numSfiles; +	if (!g_NeedLoad) +		return g_numSfiles;  	int i;  	const Common::String pattern = target +  ".???";  	Common::StringArray files = saveFileMan->listSavefiles(pattern); -	numSfiles = 0; +	g_numSfiles = 0;  	for (Common::StringArray::const_iterator file = files.begin(); file != files.end(); ++file) { -		if (numSfiles >= MAX_SAVED_FILES) +		if (g_numSfiles >= MAX_SAVED_FILES)  			break;  		const Common::String &fname = *file; @@ -376,46 +378,46 @@ int getList(Common::SaveFileManager *saveFileMan, const Common::String &target)  			// "incompatible version".  		} -		i = numSfiles; +		i = g_numSfiles;  #ifndef DISABLE_SAVEGAME_SORTING -		for (i = 0; i < numSfiles; i++) { -			if (cmpTimeDate(hdr.dateTime, savedFiles[i].dateTime) > 0) { -				Common::copy_backward(&savedFiles[i], &savedFiles[numSfiles], &savedFiles[numSfiles + 1]); +		for (i = 0; i < g_numSfiles; i++) { +			if (cmpTimeDate(hdr.dateTime, g_savedFiles[i].dateTime) > 0) { +				Common::copy_backward(&g_savedFiles[i], &g_savedFiles[g_numSfiles], &g_savedFiles[g_numSfiles + 1]);  				break;  			}  		}  #endif -		Common::strlcpy(savedFiles[i].name, fname.c_str(), FNAMELEN); -		Common::strlcpy(savedFiles[i].desc, hdr.desc, SG_DESC_LEN); -		savedFiles[i].dateTime = hdr.dateTime; +		Common::strlcpy(g_savedFiles[i].name, fname.c_str(), FNAMELEN); +		Common::strlcpy(g_savedFiles[i].desc, hdr.desc, SG_DESC_LEN); +		g_savedFiles[i].dateTime = hdr.dateTime; -		++numSfiles; +		++g_numSfiles;  	}  	// Next getList() needn't do its stuff again -	NeedLoad = false; +	g_NeedLoad = false; -	return numSfiles; +	return g_numSfiles;  }  int getList() {  	// No change since last call?  	// TODO/FIXME: Just always reload this data? Be careful about slow downs!!! -	if (!NeedLoad) -		return numSfiles; +	if (!g_NeedLoad) +		return g_numSfiles;  	return getList(_vm->getSaveFileMan(), _vm->getTargetName());  }  char *ListEntry(int i, letype which) {  	if (i == -1) -		i = numSfiles; +		i = g_numSfiles;  	assert(i >= 0); -	if (i < numSfiles) -		return which == LE_NAME ? savedFiles[i].name : savedFiles[i].desc; +	if (i < g_numSfiles) +		return which == LE_NAME ? g_savedFiles[i].name : g_savedFiles[i].desc;  	else  		return NULL;  } @@ -425,14 +427,14 @@ static void DoSync(Common::Serializer &s) {  	if (TinselV2) {  		if (s.isSaving()) -			restoreCD = GetCurrentCD(); -		s.syncAsSint16LE(restoreCD); +			g_restoreCD = GetCurrentCD(); +		s.syncAsSint16LE(g_restoreCD);  	}  	if (TinselV2 && s.isLoading())  		HoldItem(INV_NOICON); -	syncSavedData(s, *srsd); +	syncSavedData(s, *g_srsd);  	syncGlobInfo(s);		// Glitter globals  	syncInvInfo(s);			// Inventory data @@ -442,7 +444,7 @@ static void DoSync(Common::Serializer &s) {  	s.syncAsSint32LE(sg);  	if (s.isLoading()) {  		if (TinselV2) -			thingHeld = sg; +			g_thingHeld = sg;  		else  			HoldItem(sg);  	} @@ -452,17 +454,17 @@ static void DoSync(Common::Serializer &s) {  		syncPolyInfo(s);		// Dead polygon data  	syncSCdata(s);			// Hook Scene and delayed scene -	s.syncAsSint32LE(*SaveSceneSsCount); +	s.syncAsSint32LE(*g_SaveSceneSsCount); -	if (*SaveSceneSsCount != 0) { -		SAVED_DATA *sdPtr = SaveSceneSsData; -		for (int i = 0; i < *SaveSceneSsCount; ++i, ++sdPtr) +	if (*g_SaveSceneSsCount != 0) { +		SAVED_DATA *sdPtr = g_SaveSceneSsData; +		for (int i = 0; i < *g_SaveSceneSsCount; ++i, ++sdPtr)  			syncSavedData(s, *sdPtr);  		// Flag that there is a saved scene to return to. Note that in this context 'saved scene'  		// is a stored scene to return to from another scene, such as from the Summoning Book close-up  		// in Discworld 1 to whatever scene Rincewind was in prior to that -		ASceneIsSaved = true; +		g_ASceneIsSaved = true;  	}  	if (!TinselV2) @@ -473,7 +475,7 @@ static void DoSync(Common::Serializer &s) {   * DoRestore   */  static bool DoRestore() { -	Common::InSaveFile *f =  _vm->getSaveFileMan()->openForLoading(savedFiles[RestoreGameNumber].name); +	Common::InSaveFile *f =  _vm->getSaveFileMan()->openForLoading(g_savedFiles[g_RestoreGameNumber].name);  	if (f == NULL) {  		return false; @@ -507,8 +509,8 @@ static bool DoRestore() {  static void SaveFailure(Common::OutSaveFile *f) {  	if (f) {  		delete f; -		_vm->getSaveFileMan()->removeSavefile(SaveSceneName); -		SaveSceneName = NULL;	// Invalidate save name +		_vm->getSaveFileMan()->removeSavefile(g_SaveSceneName); +		g_SaveSceneName = NULL;	// Invalidate save name  	}  	GUI::MessageDialog dialog(_("Failed to save game state to file."));  	dialog.runModal(); @@ -522,9 +524,9 @@ static void DoSave() {  	char tmpName[FNAMELEN];  	// Next getList() must do its stuff again -	NeedLoad = true; +	g_NeedLoad = true; -	if (SaveSceneName == NULL) { +	if (g_SaveSceneName == NULL) {  		// Generate a new unique save name  		int	i;  		int	ano = 1;	// Allocated number @@ -533,23 +535,23 @@ static void DoSave() {  			Common::String fname = _vm->getSavegameFilename(ano);  			strcpy(tmpName, fname.c_str()); -			for (i = 0; i < numSfiles; i++) -				if (!strcmp(savedFiles[i].name, tmpName)) +			for (i = 0; i < g_numSfiles; i++) +				if (!strcmp(g_savedFiles[i].name, tmpName))  					break; -			if (i == numSfiles) +			if (i == g_numSfiles)  				break;  			ano++;  		} -		SaveSceneName = tmpName; +		g_SaveSceneName = tmpName;  	} -	if (SaveSceneDesc[0] == 0) -		SaveSceneDesc = "unnamed"; +	if (g_SaveSceneDesc[0] == 0) +		g_SaveSceneDesc = "unnamed"; -	f = _vm->getSaveFileMan()->openForSaving(SaveSceneName); +	f = _vm->getSaveFileMan()->openForSaving(g_SaveSceneName);  	Common::Serializer s(0, f);  	if (f == NULL) { @@ -562,7 +564,7 @@ static void DoSave() {  	hdr.id = SAVEGAME_ID;  	hdr.size = SAVEGAME_HEADER_SIZE;  	hdr.ver = CURRENT_VER; -	memcpy(hdr.desc, SaveSceneDesc, SG_DESC_LEN); +	memcpy(hdr.desc, g_SaveSceneDesc, SG_DESC_LEN);  	hdr.desc[SG_DESC_LEN - 1] = 0;  	g_system->getTimeAndDate(hdr.dateTime);  	hdr.scnFlag = _vm->getFeatures() & GF_SCNFILES; @@ -584,28 +586,29 @@ static void DoSave() {  	f->finalize();  	delete f; -	SaveSceneName = NULL;	// Invalidate save name +	g_SaveSceneName = NULL;	// Invalidate save name  }  /**   * ProcessSRQueue   */  void ProcessSRQueue() { -	switch (SRstate) { +	switch (g_SRstate) {  	case SR_DORESTORE:  		// If a load has been done directly from title screens, set a larger value for scene ctr so the  		// code used to skip the title screens in Discworld 1 gets properly disabled -		if (sceneCtr < 10) sceneCtr = 10; +		if (g_sceneCtr < 10) +			g_sceneCtr = 10;  		if (DoRestore()) { -			DoRestoreScene(srsd, false); +			DoRestoreScene(g_srsd, false);  		} -		SRstate = SR_IDLE; +		g_SRstate = SR_IDLE;  		break;  	case SR_DOSAVE:  		DoSave(); -		SRstate = SR_IDLE; +		g_SRstate = SR_IDLE;  		break;  	default:  		break; @@ -614,14 +617,14 @@ void ProcessSRQueue() {  void RequestSaveGame(char *name, char *desc, SAVED_DATA *sd, int *pSsCount, SAVED_DATA *pSsData) { -	assert(SRstate == SR_IDLE); - -	SaveSceneName = name; -	SaveSceneDesc = desc; -	SaveSceneSsCount = pSsCount; -	SaveSceneSsData = pSsData; -	srsd = sd; -	SRstate = SR_DOSAVE; +	assert(g_SRstate == SR_IDLE); + +	g_SaveSceneName = name; +	g_SaveSceneDesc = desc; +	g_SaveSceneSsCount = pSsCount; +	g_SaveSceneSsData = pSsData; +	g_srsd = sd; +	g_SRstate = SR_DOSAVE;  }  void RequestRestoreGame(int num, SAVED_DATA *sd, int *pSsCount, SAVED_DATA *pSsData) { @@ -630,17 +633,17 @@ void RequestRestoreGame(int num, SAVED_DATA *sd, int *pSsCount, SAVED_DATA *pSsD  			return;  		else if (num == -2) {  			// From CD change for restore -			num = RestoreGameNumber; +			num = g_RestoreGameNumber;  		}  	}  	assert(num >= 0); -	RestoreGameNumber = num; -	SaveSceneSsCount = pSsCount; -	SaveSceneSsData = pSsData; -	srsd = sd; -	SRstate = SR_DORESTORE; +	g_RestoreGameNumber = num; +	g_SaveSceneSsCount = pSsCount; +	g_SaveSceneSsData = pSsData; +	g_srsd = sd; +	g_SRstate = SR_DORESTORE;  }  /** diff --git a/engines/tinsel/savescn.cpp b/engines/tinsel/savescn.cpp index 39a8033d45..1b06e3929c 100644 --- a/engines/tinsel/savescn.cpp +++ b/engines/tinsel/savescn.cpp @@ -75,29 +75,29 @@ enum {  //----------------- EXTERNAL GLOBAL DATA -------------------- -extern int	thingHeld; -extern int	restoreCD; -extern SRSTATE SRstate; +extern int	g_thingHeld; +extern int	g_restoreCD; +extern SRSTATE g_SRstate;  //----------------- LOCAL GLOBAL DATA --------------------  // FIXME: Avoid non-const global vars -bool ASceneIsSaved = false; +bool g_ASceneIsSaved = false; -static int savedSceneCount = 0; +static int g_savedSceneCount = 0; -static bool bNotDoneYet = false; +static bool g_bNotDoneYet = false;  //static SAVED_DATA ssData[MAX_NEST]; -static SAVED_DATA *ssData = NULL; -static SAVED_DATA sgData; +static SAVED_DATA *g_ssData = NULL; +static SAVED_DATA g_sgData; -static SAVED_DATA *rsd = 0; +static SAVED_DATA *g_rsd = 0; -static int RestoreSceneCount = 0; +static int g_RestoreSceneCount = 0; -static bool bNoFade = false; +static bool g_bNoFade = false;  //----------------- FORWARD REFERENCES -------------------- @@ -133,7 +133,7 @@ void DoSaveScene(SAVED_DATA *sd) {  		CurrentMidiFacts(&sd->SavedMidi, &sd->SavedLoop);  	} -	ASceneIsSaved = true; +	g_ASceneIsSaved = true;  }  /** @@ -142,29 +142,29 @@ void DoSaveScene(SAVED_DATA *sd) {   * @param bFadeOut		Flag to perform a fade out   */  void DoRestoreScene(SAVED_DATA *sd, bool bFadeOut) { -	rsd = sd; +	g_rsd = sd;  	if (bFadeOut) -		RestoreSceneCount = RS_COUNT + COUNTOUT_COUNT;	// Set restore scene count +		g_RestoreSceneCount = RS_COUNT + COUNTOUT_COUNT;	// Set restore scene count  	else -		RestoreSceneCount = RS_COUNT;	// Set restore scene count +		g_RestoreSceneCount = RS_COUNT;	// Set restore scene count  }  void InitializeSaveScenes() { -	if (ssData == NULL) { -		ssData = (SAVED_DATA *)calloc(MAX_NEST, sizeof(SAVED_DATA)); -		if (ssData == NULL) { +	if (g_ssData == NULL) { +		g_ssData = (SAVED_DATA *)calloc(MAX_NEST, sizeof(SAVED_DATA)); +		if (g_ssData == NULL) {  			error("Cannot allocate memory for scene changes");  		}  	} else {  		// Re-initialize - no scenes saved -		savedSceneCount = 0; +		g_savedSceneCount = 0;  	}  }  void FreeSaveScenes() { -	free(ssData); -	ssData = NULL; +	free(g_ssData); +	g_ssData = NULL;  }  /** @@ -212,29 +212,29 @@ static void SortMAProcess(CORO_PARAM, const void *) {  	_ctx->viaActor = SysVar(ISV_DIVERT_ACTOR);  	SetSysVar(ISV_DIVERT_ACTOR, 0); -	RestoreAuxScales(rsd->SavedMoverInfo); +	RestoreAuxScales(g_rsd->SavedMoverInfo);  	for (_ctx->i = 0; _ctx->i < MAX_MOVERS; _ctx->i++) { -		if (rsd->SavedMoverInfo[_ctx->i].bActive) { -			CORO_INVOKE_ARGS(Stand, (CORO_SUBCTX, rsd->SavedMoverInfo[_ctx->i].actorID, -				rsd->SavedMoverInfo[_ctx->i].objX, rsd->SavedMoverInfo[_ctx->i].objY, -				rsd->SavedMoverInfo[_ctx->i].hLastfilm)); +		if (g_rsd->SavedMoverInfo[_ctx->i].bActive) { +			CORO_INVOKE_ARGS(Stand, (CORO_SUBCTX, g_rsd->SavedMoverInfo[_ctx->i].actorID, +				g_rsd->SavedMoverInfo[_ctx->i].objX, g_rsd->SavedMoverInfo[_ctx->i].objY, +				g_rsd->SavedMoverInfo[_ctx->i].hLastfilm)); -			if (rsd->SavedMoverInfo[_ctx->i].bHidden) -				HideMover(GetMover(rsd->SavedMoverInfo[_ctx->i].actorID)); +			if (g_rsd->SavedMoverInfo[_ctx->i].bHidden) +				HideMover(GetMover(g_rsd->SavedMoverInfo[_ctx->i].actorID));  		} -		ActorPalette(rsd->SavedMoverInfo[_ctx->i].actorID, -			rsd->SavedMoverInfo[_ctx->i].startColor, rsd->SavedMoverInfo[_ctx->i].paletteLength); +		ActorPalette(g_rsd->SavedMoverInfo[_ctx->i].actorID, +			g_rsd->SavedMoverInfo[_ctx->i].startColor, g_rsd->SavedMoverInfo[_ctx->i].paletteLength); -		if (rsd->SavedMoverInfo[_ctx->i].brightness != BOGUS_BRIGHTNESS) -			ActorBrightness(rsd->SavedMoverInfo[_ctx->i].actorID, rsd->SavedMoverInfo[_ctx->i].brightness); +		if (g_rsd->SavedMoverInfo[_ctx->i].brightness != BOGUS_BRIGHTNESS) +			ActorBrightness(g_rsd->SavedMoverInfo[_ctx->i].actorID, g_rsd->SavedMoverInfo[_ctx->i].brightness);  	}  	// Restore via actor  	SetSysVar(ISV_DIVERT_ACTOR, _ctx->viaActor); -	bNotDoneYet = false; +	g_bNotDoneYet = false;  	CORO_END_CODE;  } @@ -244,49 +244,49 @@ static void SortMAProcess(CORO_PARAM, const void *) {  void ResumeInterprets() {  	// Master script only affected on restore game, not restore scene -	if (!TinselV2 && (rsd == &sgData)) { +	if (!TinselV2 && (g_rsd == &g_sgData)) {  		g_scheduler->killMatchingProcess(PID_MASTER_SCR, -1);  		FreeMasterInterpretContext();  	}  	for (int i = 0; i < NUM_INTERPRET; i++) { -		switch (rsd->SavedICInfo[i].GSort) { +		switch (g_rsd->SavedICInfo[i].GSort) {  		case GS_NONE:  			break;  		case GS_INVENTORY: -			if (rsd->SavedICInfo[i].event != POINTED) { -				RestoreProcess(&rsd->SavedICInfo[i]); +			if (g_rsd->SavedICInfo[i].event != POINTED) { +				RestoreProcess(&g_rsd->SavedICInfo[i]);  			}  			break;  		case GS_MASTER:  			// Master script only affected on restore game, not restore scene -			if (rsd == &sgData) -				RestoreMasterProcess(&rsd->SavedICInfo[i]); +			if (g_rsd == &g_sgData) +				RestoreMasterProcess(&g_rsd->SavedICInfo[i]);  			break;  		case GS_PROCESS:  			// Tinsel 2 process -			RestoreSceneProcess(&rsd->SavedICInfo[i]); +			RestoreSceneProcess(&g_rsd->SavedICInfo[i]);  			break;  		case GS_GPROCESS:  			// Tinsel 2 Global processes only affected on restore game, not restore scene -			if (rsd == &sgData) -				RestoreGlobalProcess(&rsd->SavedICInfo[i]); +			if (g_rsd == &g_sgData) +				RestoreGlobalProcess(&g_rsd->SavedICInfo[i]);  			break;  		case GS_ACTOR:  			if (TinselV2) -				RestoreProcess(&rsd->SavedICInfo[i]); +				RestoreProcess(&g_rsd->SavedICInfo[i]);  			else -				RestoreActorProcess(rsd->SavedICInfo[i].idActor, &rsd->SavedICInfo[i], rsd == &sgData); +				RestoreActorProcess(g_rsd->SavedICInfo[i].idActor, &g_rsd->SavedICInfo[i], g_rsd == &g_sgData);  			break;  		case GS_POLYGON:  		case GS_SCENE: -			RestoreProcess(&rsd->SavedICInfo[i]); +			RestoreProcess(&g_rsd->SavedICInfo[i]);  			break;  		default: @@ -313,7 +313,7 @@ static int DoRestoreSceneFrame(SAVED_DATA *sd, int n) {  		if (TinselV2) {  			// Master script only affected on restore game, not restore scene -			if (sd == &sgData) { +			if (sd == &g_sgData) {  				g_scheduler->killMatchingProcess(PID_MASTER_SCR);  				KillGlobalProcesses();  				FreeMasterInterpretContext(); @@ -322,12 +322,12 @@ static int DoRestoreSceneFrame(SAVED_DATA *sd, int n) {  			RestorePolygonStuff(sd->SavedPolygonStuff);  			// Abandon temporarily if different CD -			if (sd == &sgData && restoreCD != GetCurrentCD()) { -				SRstate = SR_IDLE; +			if (sd == &g_sgData && g_restoreCD != GetCurrentCD()) { +				g_SRstate = SR_IDLE;  				EndScene(); -				SetNextCD(restoreCD); -				CDChangeForRestore(restoreCD); +				SetNextCD(g_restoreCD); +				CDChangeForRestore(g_restoreCD);  				return 0;  			} @@ -338,8 +338,8 @@ static int DoRestoreSceneFrame(SAVED_DATA *sd, int n) {  		// Start up the scene  		StartNewScene(sd->SavedSceneHandle, NO_ENTRY_NUM); -		SetDoFadeIn(!bNoFade); -		bNoFade = false; +		SetDoFadeIn(!g_bNoFade); +		g_bNoFade = false;  		StartupBackground(nullContext, sd->SavedBgroundHandle);  		if (TinselV2) { @@ -355,7 +355,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); -			bNotDoneYet = true; +			g_bNotDoneYet = true;  			RestoreActorZ(sd->savedActorZ);  			RestoreZpositions(sd->zPositions); @@ -374,11 +374,11 @@ static int DoRestoreSceneFrame(SAVED_DATA *sd, int n) {  	case 1:  		if (TinselV2) { -			if (bNotDoneYet) +			if (g_bNotDoneYet)  				return n; -			if (sd == &sgData) -				HoldItem(thingHeld, true); +			if (sd == &g_sgData) +				HoldItem(g_thingHeld, true);  			if (sd->bTinselDim)  				_vm->_pcmMusic->dim(true);  			_vm->_pcmMusic->restoreThatTune(sd->SavedTune); @@ -406,7 +406,7 @@ static int DoRestoreSceneFrame(SAVED_DATA *sd, int n) {  void RestoreGame(int num) {  	KillInventory(); -	RequestRestoreGame(num, &sgData, &savedSceneCount, ssData); +	RequestRestoreGame(num, &g_sgData, &g_savedSceneCount, g_ssData);  	// Actual restoring is performed by ProcessSRQueue  } @@ -418,9 +418,9 @@ void RestoreGame(int num) {   */  void SaveGame(char *name, char *desc) {  	// Get current scene data -	DoSaveScene(&sgData); +	DoSaveScene(&g_sgData); -	RequestSaveGame(name, desc, &sgData, &savedSceneCount, ssData); +	RequestSaveGame(name, desc, &g_sgData, &g_savedSceneCount, g_ssData);  	// Actual saving is performed by ProcessSRQueue  } @@ -429,11 +429,11 @@ void SaveGame(char *name, char *desc) {  //---------------------------------------------------------------------------------  bool IsRestoringScene() { -	if (RestoreSceneCount) { -		RestoreSceneCount = DoRestoreSceneFrame(rsd, RestoreSceneCount); +	if (g_RestoreSceneCount) { +		g_RestoreSceneCount = DoRestoreSceneFrame(g_rsd, g_RestoreSceneCount);  	} -	return RestoreSceneCount ? true : false; +	return g_RestoreSceneCount ? true : false;  }  /** @@ -441,13 +441,13 @@ bool IsRestoringScene() {   */  void TinselRestoreScene(bool bFade) {  	// only called by restore_scene PCODE -	if (RestoreSceneCount == 0) { -		assert(savedSceneCount >= 1); // No saved scene to restore +	if (g_RestoreSceneCount == 0) { +		assert(g_savedSceneCount >= 1); // No saved scene to restore -		if (ASceneIsSaved) -			DoRestoreScene(&ssData[--savedSceneCount], bFade); +		if (g_ASceneIsSaved) +			DoRestoreScene(&g_ssData[--g_savedSceneCount], bFade);  		if (!bFade) -			bNoFade = true; +			g_bNoFade = true;  	}  } @@ -461,14 +461,14 @@ void TinselSaveScene(CORO_PARAM) {  	CORO_BEGIN_CODE(_ctx); -	assert(savedSceneCount < MAX_NEST); // nesting limit reached +	assert(g_savedSceneCount < MAX_NEST); // nesting limit reached  	// Don't save the same thing multiple times!  	// FIXME/TODO: Maybe this can be changed to an assert? -	if (savedSceneCount && ssData[savedSceneCount-1].SavedSceneHandle == GetSceneHandle()) +	if (g_savedSceneCount && g_ssData[g_savedSceneCount-1].SavedSceneHandle == GetSceneHandle())  		CORO_KILL_SELF(); -	DoSaveScene(&ssData[savedSceneCount++]); +	DoSaveScene(&g_ssData[g_savedSceneCount++]);  	CORO_END_CODE;  } diff --git a/engines/tinsel/scene.cpp b/engines/tinsel/scene.cpp index 89b0da7d65..f635ce13a3 100644 --- a/engines/tinsel/scene.cpp +++ b/engines/tinsel/scene.cpp @@ -107,15 +107,15 @@ struct ENTRANCE_STRUC {  // FIXME: Avoid non-const global vars  #ifdef DEBUG -static bool ShowPosition = false;	// Set when showpos() has been called +static bool g_ShowPosition = false;	// Set when showpos() has been called  #endif -int sceneCtr = 0; -static int initialMyEscape; +int g_sceneCtr = 0; +static int g_initialMyEscape; -static SCNHANDLE SceneHandle = 0;	// Current scene handle - stored in case of Save_Scene() +static SCNHANDLE g_SceneHandle = 0;	// Current scene handle - stored in case of Save_Scene() -SCENE_STRUC tempStruc; +SCENE_STRUC g_tempStruc;  struct TP_INIT {  	SCNHANDLE hTinselCode;		// Code @@ -128,18 +128,18 @@ const SCENE_STRUC *GetSceneStruc(const byte *pStruc) {  	// Copy appropriate fields into tempStruc, and return a pointer to it  	const byte *p = pStruc; -	memset(&tempStruc, 0, sizeof(SCENE_STRUC)); - -	tempStruc.numEntrance = READ_UINT32(p); p += sizeof(uint32); -	tempStruc.numPoly = READ_UINT32(p); p += sizeof(uint32); -	tempStruc.numTaggedActor = READ_UINT32(p); p += sizeof(uint32); -	tempStruc.defRefer = READ_UINT32(p); p += sizeof(uint32); -	tempStruc.hSceneScript = READ_UINT32(p); p += sizeof(uint32); -	tempStruc.hEntrance = READ_UINT32(p); p += sizeof(uint32); -	tempStruc.hPoly = READ_UINT32(p); p += sizeof(uint32); -	tempStruc.hTaggedActor = READ_UINT32(p); p += sizeof(uint32); - -	return &tempStruc; +	memset(&g_tempStruc, 0, sizeof(SCENE_STRUC)); + +	g_tempStruc.numEntrance = READ_UINT32(p); p += sizeof(uint32); +	g_tempStruc.numPoly = READ_UINT32(p); p += sizeof(uint32); +	g_tempStruc.numTaggedActor = READ_UINT32(p); p += sizeof(uint32); +	g_tempStruc.defRefer = READ_UINT32(p); p += sizeof(uint32); +	g_tempStruc.hSceneScript = READ_UINT32(p); p += sizeof(uint32); +	g_tempStruc.hEntrance = READ_UINT32(p); p += sizeof(uint32); +	g_tempStruc.hPoly = READ_UINT32(p); p += sizeof(uint32); +	g_tempStruc.hTaggedActor = READ_UINT32(p); p += sizeof(uint32); + +	return &g_tempStruc;  } @@ -157,8 +157,8 @@ static void SceneTinselProcess(CORO_PARAM, const void *param) {  	CORO_BEGIN_CODE(_ctx);  	// The following myEscape value setting is used for enabling title screen skipping in DW1 -	if (TinselV1 && (sceneCtr == 1)) initialMyEscape = GetEscEvents(); -	_ctx->myEscape = (TinselV1 && (sceneCtr < 4)) ? initialMyEscape : 0; +	if (TinselV1 && (g_sceneCtr == 1)) g_initialMyEscape = GetEscEvents(); +	_ctx->myEscape = (TinselV1 && (g_sceneCtr < 4)) ? g_initialMyEscape : 0;  	// get the stuff copied to process when it was created  	_ctx->pInit = (const TP_INIT *)param; @@ -184,8 +184,8 @@ static void SceneTinselProcess(CORO_PARAM, const void *param) {  void SendSceneTinselProcess(TINSEL_EVENT event) {  	SCENE_STRUC	*ss; -	if (SceneHandle != (SCNHANDLE)NULL) { -		ss = (SCENE_STRUC *) FindChunk(SceneHandle, CHUNK_SCENE); +	if (g_SceneHandle != (SCNHANDLE)NULL) { +		ss = (SCENE_STRUC *) FindChunk(g_SceneHandle, CHUNK_SCENE);  		if (ss->hSceneScript) {  			TP_INIT	init; @@ -214,9 +214,9 @@ static void LoadScene(SCNHANDLE scene, int entry) {  	const ENTRANCE_STRUC	*es;  	// Scene handle -	SceneHandle = scene;		// Save scene handle in case of Save_Scene() -	LockMem(SceneHandle);		// Make sure scene is loaded -	LockScene(SceneHandle);		// Prevent current scene from being discarded +	g_SceneHandle = scene;		// Save scene handle in case of Save_Scene() +	LockMem(g_SceneHandle);		// Make sure scene is loaded +	LockScene(g_SceneHandle);		// Prevent current scene from being discarded  	if (TinselV2) {  		// CdPlay() stuff @@ -307,9 +307,9 @@ static void LoadScene(SCNHANDLE scene, int entry) {   * Wrap up the last scene.   */  void EndScene() { -	if (SceneHandle != 0) { -		UnlockScene(SceneHandle); -		SceneHandle = 0; +	if (g_SceneHandle != 0) { +		UnlockScene(g_SceneHandle); +		g_SceneHandle = 0;  	}  	KillInventory();	// Close down any open inventory @@ -409,7 +409,7 @@ void PrimeScene() {  	g_scheduler->createProcess(PID_SCROLL, EffectPolyProcess, NULL, 0);  #ifdef DEBUG -	if (ShowPosition) +	if (g_ShowPosition)  		g_scheduler->createProcess(PID_POSITION, CursorPositionProcess, NULL, 0);  #endif @@ -445,7 +445,7 @@ void StartNewScene(SCNHANDLE scene, int entry) {   */  void setshowpos() { -	ShowPosition = true; +	g_ShowPosition = true;  }  #endif @@ -454,7 +454,7 @@ void setshowpos() {   */  SCNHANDLE GetSceneHandle() { -	return SceneHandle; +	return g_SceneHandle;  }  /** diff --git a/engines/tinsel/sched.cpp b/engines/tinsel/sched.cpp index d6cd806eb2..343758d924 100644 --- a/engines/tinsel/sched.cpp +++ b/engines/tinsel/sched.cpp @@ -47,11 +47,11 @@ struct PROCESS_STRUC {  // FIXME: Avoid non-const global vars -static uint32 numSceneProcess; -static SCNHANDLE hSceneProcess; +static uint32 g_numSceneProcess; +static SCNHANDLE g_hSceneProcess; -static uint32 numGlobalProcess; -static PROCESS_STRUC *pGlobalProcess; +static uint32 g_numGlobalProcess; +static PROCESS_STRUC *g_pGlobalProcess;  //--------------------- FUNCTIONS ------------------------ @@ -574,8 +574,8 @@ void RestoreSceneProcess(INT_CONTEXT *pic) {  	uint32 i;  	PROCESS_STRUC	*pStruc; -	pStruc = (PROCESS_STRUC *)LockMem(hSceneProcess); -	for (i = 0; i < numSceneProcess; i++) { +	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,  					 &pic, sizeof(pic)); @@ -583,7 +583,7 @@ void RestoreSceneProcess(INT_CONTEXT *pic) {  		}  	} -	assert(i < numSceneProcess); +	assert(i < g_numSceneProcess);  }  /** @@ -602,8 +602,8 @@ void SceneProcessEvent(CORO_PARAM, uint32 procID, TINSEL_EVENT event, bool bWait  	CORO_BEGIN_CODE(_ctx); -	_ctx->pStruc = (PROCESS_STRUC *)LockMem(hSceneProcess); -	for (i = 0; i < numSceneProcess; i++) { +	_ctx->pStruc = (PROCESS_STRUC *)LockMem(g_hSceneProcess); +	for (i = 0; i < g_numSceneProcess; i++) {  		if (FROM_LE_32(_ctx->pStruc[i].processId) == procID) {  			assert(_ctx->pStruc[i].hProcessCode);		// Must have some code to run @@ -624,7 +624,7 @@ void SceneProcessEvent(CORO_PARAM, uint32 procID, TINSEL_EVENT event, bool bWait  		}  	} -	if (i == numSceneProcess) +	if (i == g_numSceneProcess)  		return;  	if (bWait) { @@ -641,8 +641,8 @@ void KillSceneProcess(uint32 procID) {  	uint32 i;		// Loop counter  	PROCESS_STRUC	*pStruc; -	pStruc = (PROCESS_STRUC *) LockMem(hSceneProcess); -	for (i = 0; i < numSceneProcess; i++) { +	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);  			break; @@ -654,8 +654,8 @@ void KillSceneProcess(uint32 procID) {   * Register the scene processes in a scene.   */  void SceneProcesses(uint32 numProcess, SCNHANDLE hProcess) { -	numSceneProcess = numProcess; -	hSceneProcess = hProcess; +	g_numSceneProcess = numProcess; +	g_hSceneProcess = hProcess;  } @@ -669,15 +669,15 @@ void SceneProcesses(uint32 numProcess, SCNHANDLE hProcess) {  void RestoreGlobalProcess(INT_CONTEXT *pic) {  	uint32 i;		// Loop counter -	for (i = 0; i < numGlobalProcess; i++) { -		if (pGlobalProcess[i].hProcessCode == pic->hCode) { +	for (i = 0; i < g_numGlobalProcess; i++) { +		if (g_pGlobalProcess[i].hProcessCode == pic->hCode) {  			g_scheduler->createProcess(PID_GPROCESS + i, RestoredProcessProcess,  					 &pic, sizeof(pic));  			break;  		}  	} -	assert(i < numGlobalProcess); +	assert(i < g_numGlobalProcess);  }  /** @@ -685,7 +685,7 @@ void RestoreGlobalProcess(INT_CONTEXT *pic) {   */  void KillGlobalProcesses() { -	for (uint32 i = 0; i < numGlobalProcess; ++i)	{ +	for (uint32 i = 0; i < g_numGlobalProcess; ++i)	{  		g_scheduler->killMatchingProcess(PID_GPROCESS + i, -1);  	}  } @@ -706,12 +706,12 @@ bool GlobalProcessEvent(CORO_PARAM, uint32 procID, TINSEL_EVENT event, bool bWai  	uint32	i;		// Loop counter  	_ctx->pProc = NULL; -	for (i = 0; i < numGlobalProcess; ++i)	{ -		if (pGlobalProcess[i].processId == procID) { -			assert(pGlobalProcess[i].hProcessCode);		// Must have some code to run +	for (i = 0; i < g_numGlobalProcess; ++i)	{ +		if (g_pGlobalProcess[i].processId == procID) { +			assert(g_pGlobalProcess[i].hProcessCode);		// Must have some code to run  			_ctx->pic = InitInterpretContext(GS_GPROCESS, -				pGlobalProcess[i].hProcessCode, +				g_pGlobalProcess[i].hProcessCode,  				event,  				NOPOLY,			// No polygon  				0,			// No actor @@ -728,7 +728,7 @@ bool GlobalProcessEvent(CORO_PARAM, uint32 procID, TINSEL_EVENT event, bool bWai  		}  	} -	if ((i == numGlobalProcess) || (_ctx->pic == NULL)) +	if ((i == g_numGlobalProcess) || (_ctx->pic == NULL))  		result = false;  	else if (bWait)  		CORO_INVOKE_ARGS_V(WaitInterpret, false, (CORO_SUBCTX, _ctx->pProc, &result)); @@ -743,8 +743,8 @@ bool GlobalProcessEvent(CORO_PARAM, uint32 procID, TINSEL_EVENT event, bool bWai  void xKillGlobalProcess(uint32 procID) {  	uint32 i;		// Loop counter -	for (i = 0; i < numGlobalProcess; ++i) { -		if (pGlobalProcess[i].processId == procID) { +	for (i = 0; i < g_numGlobalProcess; ++i) { +		if (g_pGlobalProcess[i].processId == procID) {  			g_scheduler->killMatchingProcess(PID_GPROCESS + i, -1);  			break;  		} @@ -755,13 +755,13 @@ void xKillGlobalProcess(uint32 procID) {   * Register the global processes list   */  void GlobalProcesses(uint32 numProcess, byte *pProcess) { -	pGlobalProcess = new PROCESS_STRUC[numProcess]; -	numGlobalProcess = numProcess; +	g_pGlobalProcess = new PROCESS_STRUC[numProcess]; +	g_numGlobalProcess = numProcess;  	byte *p = pProcess;  	for (uint i = 0; i < numProcess; ++i, p += 8) { -		pGlobalProcess[i].processId = READ_LE_UINT32(p); -		pGlobalProcess[i].hProcessCode = READ_LE_UINT32(p + 4); +		g_pGlobalProcess[i].processId = READ_LE_UINT32(p); +		g_pGlobalProcess[i].hProcessCode = READ_LE_UINT32(p + 4);  	}  } @@ -769,9 +769,9 @@ void GlobalProcesses(uint32 numProcess, byte *pProcess) {   * Frees the global processes list   */  void FreeGlobalProcesses() { -	delete[] pGlobalProcess; -	pGlobalProcess = 0; -	numGlobalProcess = 0; +	delete[] g_pGlobalProcess; +	g_pGlobalProcess = 0; +	g_numGlobalProcess = 0;  }  } // End of namespace Tinsel diff --git a/engines/tinsel/scroll.cpp b/engines/tinsel/scroll.cpp index d75e649be3..0a6a281d35 100644 --- a/engines/tinsel/scroll.cpp +++ b/engines/tinsel/scroll.cpp @@ -49,14 +49,14 @@ namespace Tinsel {  // FIXME: Avoid non-const global vars -static int LeftScroll = 0, DownScroll = 0;	// Number of iterations outstanding +static int g_LeftScroll = 0, g_DownScroll = 0;	// Number of iterations outstanding -static int scrollActor = 0; -static PMOVER pScrollMover = 0; -static int oldx = 0, oldy = 0; +static int g_scrollActor = 0; +static PMOVER g_pScrollMover = 0; +static int g_oldx = 0, g_oldy = 0;  /** Boundaries and numbers of boundaries */ -static SCROLLDATA sd = { +static SCROLLDATA g_sd = {  		{  			{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0},  			{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0} @@ -77,28 +77,28 @@ static SCROLLDATA sd = {  		0  	}; -static int ImageH = 0, ImageW = 0; +static int g_ImageH = 0, g_ImageW = 0; -static bool ScrollCursor = 0;	// If a TAG or EXIT polygon is clicked on, +static bool g_ScrollCursor = 0;	// If a TAG or EXIT polygon is clicked on,  				// the cursor is kept over that polygon  				// whilst scrolling -static int scrollPixelsX = SCROLLPIXELS; -static int scrollPixelsY = SCROLLPIXELS; +static int g_scrollPixelsX = SCROLLPIXELS; +static int g_scrollPixelsY = SCROLLPIXELS;  /**   * Reset the ScrollCursor flag   */  void DontScrollCursor() { -	ScrollCursor = false; +	g_ScrollCursor = false;  }  /**   * Set the ScrollCursor flag   */  void DoScrollCursor() { -	ScrollCursor = true; +	g_ScrollCursor = true;  }  /** @@ -107,20 +107,20 @@ void DoScrollCursor() {  void SetNoScroll(int x1, int y1, int x2, int y2) {  	if (x1 == x2) {  		/* Vertical line */ -		assert(sd.NumNoH < MAX_HNOSCROLL); +		assert(g_sd.NumNoH < MAX_HNOSCROLL); -		sd.NoHScroll[sd.NumNoH].ln = x1;	// X pos of vertical line -		sd.NoHScroll[sd.NumNoH].c1 = y1; -		sd.NoHScroll[sd.NumNoH].c2 = y2; -		sd.NumNoH++; +		g_sd.NoHScroll[g_sd.NumNoH].ln = x1;	// X pos of vertical line +		g_sd.NoHScroll[g_sd.NumNoH].c1 = y1; +		g_sd.NoHScroll[g_sd.NumNoH].c2 = y2; +		g_sd.NumNoH++;  	} else if (y1 == y2) {  		/* Horizontal line */ -		assert(sd.NumNoV < MAX_VNOSCROLL); +		assert(g_sd.NumNoV < MAX_VNOSCROLL); -		sd.NoVScroll[sd.NumNoV].ln = y1;	// Y pos of horizontal line -		sd.NoVScroll[sd.NumNoV].c1 = x1; -		sd.NoVScroll[sd.NumNoV].c2 = x2; -		sd.NumNoV++; +		g_sd.NoVScroll[g_sd.NumNoV].ln = y1;	// Y pos of horizontal line +		g_sd.NoVScroll[g_sd.NumNoV].c1 = x1; +		g_sd.NoVScroll[g_sd.NumNoV].c2 = x2; +		g_sd.NumNoV++;  	} else {  		/* No-scroll lines must be horizontal or vertical */  	} @@ -144,21 +144,21 @@ static void NeedScroll(int direction) {  		BottomLine = Toffset + (SCREEN_HEIGHT - 1);  		RightCol = Loffset + (SCREEN_WIDTH - 1); -		for (i = 0; i < sd.NumNoH; i++) { -			if (RightCol >= sd.NoHScroll[i].ln - 1 && RightCol <= sd.NoHScroll[i].ln + 1 && -					((sd.NoHScroll[i].c1 >= Toffset && sd.NoHScroll[i].c1 <= BottomLine) || -					(sd.NoHScroll[i].c2 >= Toffset && sd.NoHScroll[i].c2 <= BottomLine) || -					(sd.NoHScroll[i].c1 < Toffset && sd.NoHScroll[i].c2 > BottomLine))) +		for (i = 0; i < g_sd.NumNoH; i++) { +			if (RightCol >= g_sd.NoHScroll[i].ln - 1 && RightCol <= g_sd.NoHScroll[i].ln + 1 && +					((g_sd.NoHScroll[i].c1 >= Toffset && g_sd.NoHScroll[i].c1 <= BottomLine) || +					(g_sd.NoHScroll[i].c2 >= Toffset && g_sd.NoHScroll[i].c2 <= BottomLine) || +					(g_sd.NoHScroll[i].c1 < Toffset && g_sd.NoHScroll[i].c2 > BottomLine)))  				return;  		} -		if (LeftScroll <= 0) { +		if (g_LeftScroll <= 0) {  			if (TinselV2) { -				scrollPixelsX = sd.xSpeed; -				LeftScroll += sd.xDistance; +				g_scrollPixelsX = g_sd.xSpeed; +				g_LeftScroll += g_sd.xDistance;  			} else { -				scrollPixelsX = SCROLLPIXELS; -				LeftScroll = RLSCROLL; +				g_scrollPixelsX = SCROLLPIXELS; +				g_LeftScroll = RLSCROLL;  			}  		}  		break; @@ -167,21 +167,21 @@ static void NeedScroll(int direction) {  		BottomLine = Toffset + (SCREEN_HEIGHT - 1); -		for (i = 0; i < sd.NumNoH; i++) { -			if (Loffset >= sd.NoHScroll[i].ln - 1 && Loffset <= sd.NoHScroll[i].ln + 1 && -					((sd.NoHScroll[i].c1 >= Toffset && sd.NoHScroll[i].c1 <= BottomLine) || -					(sd.NoHScroll[i].c2 >= Toffset && sd.NoHScroll[i].c2 <= BottomLine) || -					(sd.NoHScroll[i].c1 < Toffset && sd.NoHScroll[i].c2 > BottomLine))) +		for (i = 0; i < g_sd.NumNoH; i++) { +			if (Loffset >= g_sd.NoHScroll[i].ln - 1 && Loffset <= g_sd.NoHScroll[i].ln + 1 && +					((g_sd.NoHScroll[i].c1 >= Toffset && g_sd.NoHScroll[i].c1 <= BottomLine) || +					(g_sd.NoHScroll[i].c2 >= Toffset && g_sd.NoHScroll[i].c2 <= BottomLine) || +					(g_sd.NoHScroll[i].c1 < Toffset && g_sd.NoHScroll[i].c2 > BottomLine)))  				return;  		} -		if (LeftScroll >= 0) { +		if (g_LeftScroll >= 0) {  			if (TinselV2) { -				scrollPixelsX = sd.xSpeed; -				LeftScroll -= sd.xDistance; +				g_scrollPixelsX = g_sd.xSpeed; +				g_LeftScroll -= g_sd.xDistance;  			} else { -				scrollPixelsX = SCROLLPIXELS; -				LeftScroll = -RLSCROLL; +				g_scrollPixelsX = SCROLLPIXELS; +				g_LeftScroll = -RLSCROLL;  			}  		}  		break; @@ -191,21 +191,21 @@ static void NeedScroll(int direction) {  		BottomLine = Toffset + (SCREEN_HEIGHT - 1);  		RightCol = Loffset + (SCREEN_WIDTH - 1); -		for (i = 0; i < sd.NumNoV; i++) { -			if ((BottomLine >= sd.NoVScroll[i].ln - 1 && BottomLine <= sd.NoVScroll[i].ln + 1) && -					((sd.NoVScroll[i].c1 >= Loffset && sd.NoVScroll[i].c1 <= RightCol) || -					(sd.NoVScroll[i].c2 >= Loffset && sd.NoVScroll[i].c2 <= RightCol) || -					(sd.NoVScroll[i].c1 < Loffset && sd.NoVScroll[i].c2 > RightCol))) +		for (i = 0; i < g_sd.NumNoV; i++) { +			if ((BottomLine >= g_sd.NoVScroll[i].ln - 1 && BottomLine <= g_sd.NoVScroll[i].ln + 1) && +					((g_sd.NoVScroll[i].c1 >= Loffset && g_sd.NoVScroll[i].c1 <= RightCol) || +					(g_sd.NoVScroll[i].c2 >= Loffset && g_sd.NoVScroll[i].c2 <= RightCol) || +					(g_sd.NoVScroll[i].c1 < Loffset && g_sd.NoVScroll[i].c2 > RightCol)))  				return;  			} -		if (DownScroll <= 0) { +		if (g_DownScroll <= 0) {  			if (TinselV2) { -				scrollPixelsY = sd.ySpeed; -				DownScroll += sd.yDistance; +				g_scrollPixelsY = g_sd.ySpeed; +				g_DownScroll += g_sd.yDistance;  			} else { -				scrollPixelsY = SCROLLPIXELS; -				DownScroll = UDSCROLL; +				g_scrollPixelsY = SCROLLPIXELS; +				g_DownScroll = UDSCROLL;  			}  		}  		break; @@ -214,21 +214,21 @@ static void NeedScroll(int direction) {  		RightCol = Loffset + (SCREEN_WIDTH - 1); -		for (i = 0; i < sd.NumNoV; i++) { -			if (Toffset >= sd.NoVScroll[i].ln - 1  && Toffset <= sd.NoVScroll[i].ln + 1  && -					((sd.NoVScroll[i].c1 >= Loffset && sd.NoVScroll[i].c1 <= RightCol) || -					(sd.NoVScroll[i].c2 >= Loffset && sd.NoVScroll[i].c2 <= RightCol) || -					(sd.NoVScroll[i].c1 < Loffset && sd.NoVScroll[i].c2 > RightCol))) +		for (i = 0; i < g_sd.NumNoV; i++) { +			if (Toffset >= g_sd.NoVScroll[i].ln - 1  && Toffset <= g_sd.NoVScroll[i].ln + 1  && +					((g_sd.NoVScroll[i].c1 >= Loffset && g_sd.NoVScroll[i].c1 <= RightCol) || +					(g_sd.NoVScroll[i].c2 >= Loffset && g_sd.NoVScroll[i].c2 <= RightCol) || +					(g_sd.NoVScroll[i].c1 < Loffset && g_sd.NoVScroll[i].c2 > RightCol)))  				return;  		} -		if (DownScroll >= 0) { +		if (g_DownScroll >= 0) {  			if (TinselV2) { -				scrollPixelsY = sd.ySpeed; -				DownScroll -= sd.yDistance; +				g_scrollPixelsY = g_sd.ySpeed; +				g_DownScroll -= g_sd.yDistance;  			} else { -				scrollPixelsY = SCROLLPIXELS; -				DownScroll = -UDSCROLL; +				g_scrollPixelsY = SCROLLPIXELS; +				g_DownScroll = -UDSCROLL;  			}  		}  		break; @@ -249,39 +249,39 @@ static void ScrollImage() {  	/*  	 * Keeping cursor on a tag?  	 */ -	if (ScrollCursor) { +	if (g_ScrollCursor) {  		GetCursorXYNoWait(&curX, &curY, true);  		if (InPolygon(curX, curY, TAG) != NOPOLY || InPolygon(curX, curY, EXIT) != NOPOLY) {  			OldLoffset = Loffset;  			OldToffset = Toffset;  		} else -			ScrollCursor = false; +			g_ScrollCursor = false;  	}  	/*  	 * Horizontal scrolling  	 */ -	if (LeftScroll > 0) { -		LeftScroll -= scrollPixelsX; -		if (LeftScroll < 0) { -			Loffset += LeftScroll; -			LeftScroll = 0; +	if (g_LeftScroll > 0) { +		g_LeftScroll -= g_scrollPixelsX; +		if (g_LeftScroll < 0) { +			Loffset += g_LeftScroll; +			g_LeftScroll = 0;  		} -		Loffset += scrollPixelsX;		// Move right -		if (Loffset > ImageW - SCREEN_WIDTH) -			Loffset = ImageW - SCREEN_WIDTH;// Now at extreme right +		Loffset += g_scrollPixelsX;		// Move right +		if (Loffset > g_ImageW - SCREEN_WIDTH) +			Loffset = g_ImageW - SCREEN_WIDTH;// Now at extreme right  		/*** New feature to prop up rickety scroll boundaries ***/  		if (TinselV2 && SysVar(SV_MaximumXoffset) &&  (Loffset > SysVar(SV_MaximumXoffset)))  			Loffset = SysVar(SV_MaximumXoffset); -	} else if (LeftScroll < 0) { -		LeftScroll += scrollPixelsX; -		if (LeftScroll > 0) { -			Loffset += LeftScroll; -			LeftScroll = 0; +	} else if (g_LeftScroll < 0) { +		g_LeftScroll += g_scrollPixelsX; +		if (g_LeftScroll > 0) { +			Loffset += g_LeftScroll; +			g_LeftScroll = 0;  		} -		Loffset -= scrollPixelsX;	// Move left +		Loffset -= g_scrollPixelsX;	// Move left  		if (Loffset < 0)  			Loffset = 0;		// Now at extreme left @@ -293,28 +293,28 @@ static void ScrollImage() {  	/*  	 * Vertical scrolling  	 */ -	if (DownScroll > 0) { -		DownScroll -= scrollPixelsY; -		if (DownScroll < 0) { -			Toffset += DownScroll; -			DownScroll = 0; +	if (g_DownScroll > 0) { +		g_DownScroll -= g_scrollPixelsY; +		if (g_DownScroll < 0) { +			Toffset += g_DownScroll; +			g_DownScroll = 0;  		} -		Toffset += scrollPixelsY;		// Move down +		Toffset += g_scrollPixelsY;		// Move down -		if (Toffset > ImageH - SCREEN_HEIGHT) -			Toffset = ImageH - SCREEN_HEIGHT;// Now at extreme bottom +		if (Toffset > g_ImageH - SCREEN_HEIGHT) +			Toffset = g_ImageH - SCREEN_HEIGHT;// Now at extreme bottom  		/*** New feature to prop up rickety scroll boundaries ***/  		if (TinselV2 && SysVar(SV_MaximumYoffset) &&  Toffset > SysVar(SV_MaximumYoffset))  			Toffset = SysVar(SV_MaximumYoffset); -	} else if (DownScroll < 0) { -		DownScroll += scrollPixelsY; -		if (DownScroll > 0) { -			Toffset += DownScroll; -			DownScroll = 0; +	} else if (g_DownScroll < 0) { +		g_DownScroll += g_scrollPixelsY; +		if (g_DownScroll > 0) { +			Toffset += g_DownScroll; +			g_DownScroll = 0;  		} -		Toffset -= scrollPixelsY;		// Move up +		Toffset -= g_scrollPixelsY;		// Move up  		if (Toffset < 0)  			Toffset = 0;			// Now at extreme top @@ -327,7 +327,7 @@ static void ScrollImage() {  	/*  	 * Move cursor if keeping cursor on a tag.  	 */ -	if (ScrollCursor) +	if (g_ScrollCursor)  		AdjustCursorXY(OldLoffset - Loffset, OldToffset - Toffset);  	PlayfieldSetPos(FIELD_WORLD, Loffset, Toffset); @@ -345,12 +345,12 @@ static void MonitorScroll() {  	/*  	 * Only do it if the actor is there and is visible  	 */ -	if (!pScrollMover || MoverHidden(pScrollMover) || !MoverIs(pScrollMover)) +	if (!g_pScrollMover || MoverHidden(g_pScrollMover) || !MoverIs(g_pScrollMover))  		return; -	GetActorPos(scrollActor, &newx, &newy); +	GetActorPos(g_scrollActor, &newx, &newy); -	if (oldx == newx && oldy == newy) +	if (g_oldx == newx && g_oldy == newy)  		return;  	PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset); @@ -358,49 +358,49 @@ static void MonitorScroll() {  	/*  	 * Approaching right side or left side of the screen?  	 */ -	if (newx > Loffset+SCREEN_WIDTH - RLDISTANCE && Loffset < ImageW - SCREEN_WIDTH) { -		if (newx > oldx) +	if (newx > Loffset+SCREEN_WIDTH - RLDISTANCE && Loffset < g_ImageW - SCREEN_WIDTH) { +		if (newx > g_oldx)  				NeedScroll(LEFT);  	} else if (newx < Loffset + RLDISTANCE  &&  Loffset) { -		if (newx < oldx) +		if (newx < g_oldx)  				NeedScroll(RIGHT);  	}  	/*  	 * Approaching bottom or top of the screen?  	 */ -	if (newy > Toffset+SCREEN_HEIGHT-DDISTANCE && Toffset < ImageH-SCREEN_HEIGHT) { -		if (newy > oldy) +	if (newy > Toffset+SCREEN_HEIGHT-DDISTANCE && Toffset < g_ImageH-SCREEN_HEIGHT) { +		if (newy > g_oldy)  				NeedScroll(UP); -	} else if (Toffset && newy < Toffset + UDISTANCE + GetActorBottom(scrollActor) - GetActorTop(scrollActor)) { -		if (newy < oldy) +	} else if (Toffset && newy < Toffset + UDISTANCE + GetActorBottom(g_scrollActor) - GetActorTop(g_scrollActor)) { +		if (newy < g_oldy)  				NeedScroll(DOWN);  	} -	oldx = newx; -	oldy = newy; +	g_oldx = newx; +	g_oldy = newy;  }  static void RestoreScrollDefaults() { -	sd.xTrigger		= SysVar(SV_SCROLL_XTRIGGER); -	sd.xDistance	= SysVar(SV_SCROLL_XDISTANCE); -	sd.xSpeed		= SysVar(SV_SCROLL_XSPEED); -	sd.yTriggerTop	= SysVar(SV_SCROLL_YTRIGGERTOP); -	sd.yTriggerBottom= SysVar(SV_SCROLL_YTRIGGERBOT); -	sd.yDistance	= SysVar(SV_SCROLL_YDISTANCE); -	sd.ySpeed		= SysVar(SV_SCROLL_YSPEED); +	g_sd.xTrigger		= SysVar(SV_SCROLL_XTRIGGER); +	g_sd.xDistance	= SysVar(SV_SCROLL_XDISTANCE); +	g_sd.xSpeed		= SysVar(SV_SCROLL_XSPEED); +	g_sd.yTriggerTop	= SysVar(SV_SCROLL_YTRIGGERTOP); +	g_sd.yTriggerBottom= SysVar(SV_SCROLL_YTRIGGERBOT); +	g_sd.yDistance	= SysVar(SV_SCROLL_YDISTANCE); +	g_sd.ySpeed		= SysVar(SV_SCROLL_YSPEED);  }  /**   * Does the obvious - called at the end of a scene.   */  void DropScroll() { -	sd.NumNoH = sd.NumNoV = 0; +	g_sd.NumNoH = g_sd.NumNoV = 0;  	if (TinselV2) { -		LeftScroll = DownScroll = 0;		// No iterations outstanding -		oldx = oldy = 0; -		scrollPixelsX = sd.xSpeed; -		scrollPixelsY = sd.ySpeed; +		g_LeftScroll = g_DownScroll = 0;		// No iterations outstanding +		g_oldx = g_oldy = 0; +		g_scrollPixelsX = g_sd.xSpeed; +		g_scrollPixelsY = g_sd.ySpeed;  		RestoreScrollDefaults();  	}  } @@ -420,28 +420,28 @@ void ScrollProcess(CORO_PARAM, const void *) {  	while (!GetBgObject())  		CORO_SLEEP(1); -	ImageH = BgHeight();		// Dimensions -	ImageW = BgWidth();		//  of this scene. +	g_ImageH = BgHeight();		// Dimensions +	g_ImageW = BgWidth();		//  of this scene.  	// Give up if there'll be no purpose in this process -	if (ImageW == SCREEN_WIDTH  &&  ImageH == SCREEN_HEIGHT) +	if (g_ImageW == SCREEN_WIDTH  &&  g_ImageH == SCREEN_HEIGHT)  		CORO_KILL_SELF();  	if (!TinselV2) { -		LeftScroll = DownScroll = 0;		// No iterations outstanding -		oldx = oldy = 0; -		scrollPixelsX = scrollPixelsY = SCROLLPIXELS; +		g_LeftScroll = g_DownScroll = 0;		// No iterations outstanding +		g_oldx = g_oldy = 0; +		g_scrollPixelsX = g_scrollPixelsY = SCROLLPIXELS;  	} -	if (!scrollActor) -		scrollActor = GetLeadId(); +	if (!g_scrollActor) +		g_scrollActor = GetLeadId(); -	pScrollMover = GetMover(scrollActor); +	g_pScrollMover = GetMover(g_scrollActor);  	while (1) {  		MonitorScroll();		// Set scroll requirement -		if (LeftScroll || DownScroll)	// Scroll if required +		if (g_LeftScroll || g_DownScroll)	// Scroll if required  			ScrollImage();  		CORO_SLEEP(1);		// allow re-scheduling @@ -454,11 +454,11 @@ void ScrollProcess(CORO_PARAM, const void *) {   * Change which actor the camera is following.   */  void ScrollFocus(int ano) { -	if (scrollActor != ano) { -		oldx = oldy = 0; -		scrollActor = ano; +	if (g_scrollActor != ano) { +		g_oldx = g_oldy = 0; +		g_scrollActor = ano; -		pScrollMover = ano ? GetMover(scrollActor) : NULL; +		g_pScrollMover = ano ? GetMover(g_scrollActor) : NULL;  	}  } @@ -466,7 +466,7 @@ void ScrollFocus(int ano) {   * Returns the actor which the camera is following   */  int GetScrollFocus() { -	return scrollActor; +	return g_scrollActor;  } @@ -476,29 +476,29 @@ int GetScrollFocus() {  void ScrollTo(int x, int y, int xIter, int yIter) {  	int Loffset, Toffset;		// for background offsets -	scrollPixelsX = xIter != 0 ? xIter : (TinselV2 ? sd.xSpeed : SCROLLPIXELS); -	scrollPixelsY = yIter != 0 ? yIter : (TinselV2 ? sd.ySpeed : SCROLLPIXELS); +	g_scrollPixelsX = xIter != 0 ? xIter : (TinselV2 ? g_sd.xSpeed : SCROLLPIXELS); +	g_scrollPixelsY = yIter != 0 ? yIter : (TinselV2 ? g_sd.ySpeed : SCROLLPIXELS);  	PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset);	// get background offsets -	LeftScroll = x - Loffset; -	DownScroll = y - Toffset; +	g_LeftScroll = x - Loffset; +	g_DownScroll = y - Toffset;  }  /**   * Kill of any current scroll.   */  void KillScroll() { -	LeftScroll = DownScroll = 0; +	g_LeftScroll = g_DownScroll = 0;  }  void GetNoScrollData(SCROLLDATA *ssd) { -	memcpy(ssd, &sd, sizeof(SCROLLDATA)); +	memcpy(ssd, &g_sd, sizeof(SCROLLDATA));  }  void RestoreNoScrollData(SCROLLDATA *ssd) { -	memcpy(&sd, ssd, sizeof(SCROLLDATA)); +	memcpy(&g_sd, ssd, sizeof(SCROLLDATA));  }  /** @@ -512,24 +512,24 @@ void SetScrollParameters(int xTrigger, int xDistance, int xSpeed, int yTriggerTo  		RestoreScrollDefaults();  	} else {  		if (xTrigger) -			sd.xTrigger = xTrigger; +			g_sd.xTrigger = xTrigger;  		if (xDistance) -			sd.xDistance = xDistance; +			g_sd.xDistance = xDistance;  		if (xSpeed) -			sd.xSpeed = xSpeed; +			g_sd.xSpeed = xSpeed;  		if (yTriggerTop) -			sd.yTriggerTop = yTriggerTop; +			g_sd.yTriggerTop = yTriggerTop;  		if (yTriggerBottom) -			sd.yTriggerBottom = yTriggerBottom; +			g_sd.yTriggerBottom = yTriggerBottom;  		if (yDistance) -			sd.yDistance = yDistance; +			g_sd.yDistance = yDistance;  		if (ySpeed) -			sd.ySpeed = ySpeed; +			g_sd.ySpeed = ySpeed;  	}  }  bool IsScrolling() { -	return (LeftScroll || DownScroll); +	return (g_LeftScroll || g_DownScroll);  }  } // End of namespace Tinsel diff --git a/engines/tinsel/scroll.h b/engines/tinsel/scroll.h index 62562b20b2..bcdc15cda6 100644 --- a/engines/tinsel/scroll.h +++ b/engines/tinsel/scroll.h @@ -28,9 +28,9 @@ namespace Tinsel {  #define SCROLLPIXELS 8	// Number of pixels to scroll per iteration  // Distance from edge that triggers a scroll -#define RLDISTANCE (TinselV2 ? sd.xTrigger : 50) -#define UDISTANCE (TinselV2 ? sd.yTriggerTop : 20) -#define DDISTANCE (TinselV2 ? sd.yTriggerBottom : 20) +#define RLDISTANCE (TinselV2 ? g_sd.xTrigger : 50) +#define UDISTANCE (TinselV2 ? g_sd.yTriggerTop : 20) +#define DDISTANCE (TinselV2 ? g_sd.yTriggerBottom : 20)  // Number of iterations to make  #define RLSCROLL 160	// 20*8 = 160 = half a screen diff --git a/engines/tinsel/sound.cpp b/engines/tinsel/sound.cpp index 130928d885..f575b03270 100644 --- a/engines/tinsel/sound.cpp +++ b/engines/tinsel/sound.cpp @@ -49,7 +49,7 @@  namespace Tinsel { -extern LANGUAGE sampleLanguage; +extern LANGUAGE g_sampleLanguage;  //--------------------------- General data ---------------------------------- @@ -99,12 +99,12 @@ bool SoundManager::playSample(int id, Audio::Mixer::SoundType type, Audio::Sound  	// move to correct position in the sample file  	_sampleStream.seek(dwSampleIndex);  	if (_sampleStream.eos() || _sampleStream.err() || (uint32)_sampleStream.pos() != dwSampleIndex) -		error(FILE_IS_CORRUPT, _vm->getSampleFile(sampleLanguage)); +		error(FILE_IS_CORRUPT, _vm->getSampleFile(g_sampleLanguage));  	// read the length of the sample  	uint32 sampleLen = _sampleStream.readUint32();  	if (_sampleStream.eos() || _sampleStream.err()) -		error(FILE_IS_CORRUPT, _vm->getSampleFile(sampleLanguage)); +		error(FILE_IS_CORRUPT, _vm->getSampleFile(g_sampleLanguage));  	if (TinselV1PSX) {  		// Read the stream and create a XA ADPCM audio stream @@ -124,7 +124,7 @@ bool SoundManager::playSample(int id, Audio::Mixer::SoundType type, Audio::Sound  		// read all of the sample  		if (_sampleStream.read(sampleBuf, sampleLen) != sampleLen) -			error(FILE_IS_CORRUPT, _vm->getSampleFile(sampleLanguage)); +			error(FILE_IS_CORRUPT, _vm->getSampleFile(g_sampleLanguage));  		// FIXME: Should set this in a different place ;)  		_vm->_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, _vm->_config->_soundVolume); @@ -254,12 +254,12 @@ bool SoundManager::playSample(int id, int sub, bool bLooped, int x, int y, int p  	// move to correct position in the sample file  	_sampleStream.seek(dwSampleIndex);  	if (_sampleStream.eos() || _sampleStream.err() || (uint32)_sampleStream.pos() != dwSampleIndex) -		error(FILE_IS_CORRUPT, _vm->getSampleFile(sampleLanguage)); +		error(FILE_IS_CORRUPT, _vm->getSampleFile(g_sampleLanguage));  	// read the length of the sample  	uint32 sampleLen = _sampleStream.readUint32();  	if (_sampleStream.eos() || _sampleStream.err()) -		error(FILE_IS_CORRUPT, _vm->getSampleFile(sampleLanguage)); +		error(FILE_IS_CORRUPT, _vm->getSampleFile(g_sampleLanguage));  	if (sampleLen & 0x80000000) {  		// Has sub samples @@ -273,11 +273,11 @@ bool SoundManager::playSample(int id, int sub, bool bLooped, int x, int y, int p  			sampleLen = _sampleStream.readUint32();  			_sampleStream.skip(sampleLen);  			if (_sampleStream.eos() || _sampleStream.err()) -				error(FILE_IS_CORRUPT, _vm->getSampleFile(sampleLanguage)); +				error(FILE_IS_CORRUPT, _vm->getSampleFile(g_sampleLanguage));  		}  		sampleLen = _sampleStream.readUint32();  		if (_sampleStream.eos() || _sampleStream.err()) -			error(FILE_IS_CORRUPT, _vm->getSampleFile(sampleLanguage)); +			error(FILE_IS_CORRUPT, _vm->getSampleFile(g_sampleLanguage));  	}  	debugC(DEBUG_DETAILED, kTinselDebugSound, "Playing sound %d.%d, %d bytes at %d (pan %d)", id, sub, sampleLen, @@ -289,7 +289,7 @@ bool SoundManager::playSample(int id, int sub, bool bLooped, int x, int y, int p  	// read all of the sample  	if (_sampleStream.read(sampleBuf, sampleLen) != sampleLen) -		error(FILE_IS_CORRUPT, _vm->getSampleFile(sampleLanguage)); +		error(FILE_IS_CORRUPT, _vm->getSampleFile(g_sampleLanguage));  	Common::MemoryReadStream *compressedStream =  		new Common::MemoryReadStream(sampleBuf, sampleLen, DisposeAfterUse::YES); @@ -481,7 +481,7 @@ void SoundManager::openSampleFiles() {  		return;  	// open sample index file in binary mode -	if (f.open(_vm->getSampleIndex(sampleLanguage)))	{ +	if (f.open(_vm->getSampleIndex(g_sampleLanguage)))	{  		// get length of index file  		f.seek(0, SEEK_END);		// move to end of file  		_sampleIndexLen = f.pos();	// get file pointer @@ -502,7 +502,7 @@ void SoundManager::openSampleFiles() {  		// load data  		if (f.read(_sampleIndex, _sampleIndexLen) != (uint32)_sampleIndexLen)  			// file must be corrupt if we get to here -			error(FILE_IS_CORRUPT, _vm->getSampleFile(sampleLanguage)); +			error(FILE_IS_CORRUPT, _vm->getSampleFile(g_sampleLanguage));  		// close the file  		f.close(); @@ -542,28 +542,28 @@ void SoundManager::openSampleFiles() {  		_sampleIndex[0] = 0;  	} else {  		char buf[50]; -		sprintf(buf, CANNOT_FIND_FILE, _vm->getSampleIndex(sampleLanguage)); +		sprintf(buf, CANNOT_FIND_FILE, _vm->getSampleIndex(g_sampleLanguage));  		GUI::MessageDialog dialog(buf, "OK");  		dialog.runModal(); -		error(CANNOT_FIND_FILE, _vm->getSampleIndex(sampleLanguage)); +		error(CANNOT_FIND_FILE, _vm->getSampleIndex(g_sampleLanguage));  	}  	// open sample file in binary mode -	if (!_sampleStream.open(_vm->getSampleFile(sampleLanguage))) { +	if (!_sampleStream.open(_vm->getSampleFile(g_sampleLanguage))) {  		char buf[50]; -		sprintf(buf, CANNOT_FIND_FILE, _vm->getSampleFile(sampleLanguage)); +		sprintf(buf, CANNOT_FIND_FILE, _vm->getSampleFile(g_sampleLanguage));  		GUI::MessageDialog dialog(buf, "OK");  		dialog.runModal(); -		error(CANNOT_FIND_FILE, _vm->getSampleFile(sampleLanguage)); +		error(CANNOT_FIND_FILE, _vm->getSampleFile(g_sampleLanguage));  	}  /*  	// gen length of the largest sample  	sampleBuffer.size = _sampleStream.readUint32LE();  	if (_sampleStream.eos() || _sampleStream.err()) -		error(FILE_IS_CORRUPT, _vm->getSampleFile(sampleLanguage)); +		error(FILE_IS_CORRUPT, _vm->getSampleFile(g_sampleLanguage));  */  } diff --git a/engines/tinsel/strres.cpp b/engines/tinsel/strres.cpp index f3a7278993..5a29a4d2cd 100644 --- a/engines/tinsel/strres.cpp +++ b/engines/tinsel/strres.cpp @@ -38,11 +38,11 @@ namespace Tinsel {  #ifdef DEBUG  // Diagnostic number -int newestString; +int g_newestString;  #endif  // buffer for resource strings -static uint8 *textBuffer = 0; +static uint8 *g_textBuffer = 0;  static struct {  	bool		bPresent; @@ -50,7 +50,7 @@ static struct {  	SCNHANDLE	hDescription;  	SCNHANDLE	hFlagFilm; -} languages[NUM_LANGUAGES] = { +} g_languages[NUM_LANGUAGES] = {  	{ false, "English",	0, 0 },  	{ false, "French",	0, 0 }, @@ -65,9 +65,9 @@ static struct {  // Set if we're handling 2-byte characters. -bool bMultiByte = false; +bool g_bMultiByte = false; -LANGUAGE textLanguage, sampleLanguage = TXT_ENGLISH; +LANGUAGE g_textLanguage, g_sampleLanguage = TXT_ENGLISH;  //----------------- LOCAL DEFINES ---------------------------- @@ -85,12 +85,12 @@ void ChangeLanguage(LANGUAGE newLang) {  	TinselFile f;  	uint32 textLen = 0;	// length of buffer -	textLanguage = newLang; -	sampleLanguage = newLang; +	g_textLanguage = newLang; +	g_sampleLanguage = newLang;  	// free the previous buffer -	free(textBuffer); -	textBuffer = NULL; +	free(g_textBuffer); +	g_textBuffer = NULL;  	// Try and open the specified language file. If it fails, and the language  	// isn't English, try falling back on opening 'english.txt' - some foreign @@ -116,22 +116,22 @@ void ChangeLanguage(LANGUAGE newLang) {  	if (textLen == CHUNK_STRING || textLen == CHUNK_MBSTRING) {  		// the file is uncompressed -		bMultiByte = (textLen == CHUNK_MBSTRING); +		g_bMultiByte = (textLen == CHUNK_MBSTRING);  		// get length of uncompressed file  		textLen = f.size();  		f.seek(0, SEEK_SET);	// Set to beginning of file -		if (textBuffer == NULL) { +		if (g_textBuffer == NULL) {  			// allocate a text buffer for the strings -			textBuffer = (uint8 *)malloc(textLen); +			g_textBuffer = (uint8 *)malloc(textLen);  			// make sure memory allocated -			assert(textBuffer); +			assert(g_textBuffer);  		}  		// load data -		if (f.read(textBuffer, textLen) != textLen) +		if (f.read(g_textBuffer, textLen) != textLen)  			// file must be corrupt if we get to here  			error(FILE_IS_CORRUPT, _vm->getTextFile(newLang)); @@ -147,7 +147,7 @@ void ChangeLanguage(LANGUAGE newLang) {   */  static byte *FindStringBase(int id) {  	// base of string resource table -	byte *pText = textBuffer; +	byte *pText = g_textBuffer;  	// For Tinsel 0, Ids are decremented by 1  	if (TinselV0) @@ -353,8 +353,8 @@ int SubStringCount(int id) {  void FreeTextBuffer() { -	free(textBuffer); -	textBuffer = NULL; +	free(g_textBuffer); +	g_textBuffer = NULL;  }  /** @@ -364,29 +364,29 @@ void FreeTextBuffer() {  void LanguageFacts(int language, SCNHANDLE hDescription, SCNHANDLE hFlagFilm) {  	assert(language >= 0 && language < NUM_LANGUAGES); -	languages[language].hDescription = hDescription; -	languages[language].hFlagFilm	 = hFlagFilm; +	g_languages[language].hDescription = hDescription; +	g_languages[language].hFlagFilm	 = hFlagFilm;  }  /**   * Gets the current subtitles language   */  LANGUAGE TextLanguage() { -	return textLanguage; +	return g_textLanguage;  }  /**   * Gets the current voice language   */  LANGUAGE SampleLanguage() { -	return sampleLanguage; +	return g_sampleLanguage;  }  int NumberOfLanguages() {  	int i, count;  	for (i = 0, count = 0; i < NUM_LANGUAGES; i++) { -		if (languages[i].bPresent) +		if (g_languages[i].bPresent)  			count++;  	}  	return count; @@ -396,12 +396,12 @@ LANGUAGE NextLanguage(LANGUAGE thisOne) {  	int i;  	for (i = thisOne+1; i < NUM_LANGUAGES; i++) { -		if (languages[i].bPresent) +		if (g_languages[i].bPresent)  			return (LANGUAGE)i;  	}  	for (i = 0; i < thisOne; i++) { -		if (languages[i].bPresent) +		if (g_languages[i].bPresent)  			return (LANGUAGE)i;  	} @@ -413,12 +413,12 @@ LANGUAGE PrevLanguage(LANGUAGE thisOne) {  	int i;  	for (i = thisOne-1; i >= 0; i--) { -		if (languages[i].bPresent) +		if (g_languages[i].bPresent)  			return (LANGUAGE)i;  	}  	for (i = NUM_LANGUAGES-1; i > thisOne; i--) { -		if (languages[i].bPresent) +		if (g_languages[i].bPresent)  			return (LANGUAGE)i;  	} @@ -427,11 +427,11 @@ LANGUAGE PrevLanguage(LANGUAGE thisOne) {  }  SCNHANDLE LanguageDesc(LANGUAGE thisOne) { -	return languages[thisOne].hDescription; +	return g_languages[thisOne].hDescription;  }  SCNHANDLE LanguageFlag(LANGUAGE thisOne) { -	return languages[thisOne].hFlagFilm; +	return g_languages[thisOne].hFlagFilm;  }  } // End of namespace Tinsel diff --git a/engines/tinsel/strres.h b/engines/tinsel/strres.h index f6e86951b6..772896c81f 100644 --- a/engines/tinsel/strres.h +++ b/engines/tinsel/strres.h @@ -35,7 +35,7 @@ namespace Tinsel {  #define	MAX_STRRES_SIZE		300000	// maximum size of string resource file  // Set if we're handling 2-byte characters. -extern bool bMultiByte; +extern bool g_bMultiByte;  /*----------------------------------------------------------------------*\  |*				Function Prototypes			*| diff --git a/engines/tinsel/sysvar.cpp b/engines/tinsel/sysvar.cpp index 88053f15c6..6ef4f165ab 100644 --- a/engines/tinsel/sysvar.cpp +++ b/engines/tinsel/sysvar.cpp @@ -43,7 +43,7 @@ extern int NewestSavedGame();  // FIXME: Avoid non-const global vars -static int systemVars[SV_TOPVALID] = { +static int g_systemVars[SV_TOPVALID] = {  		INV_1,		// Default inventory @@ -105,7 +105,7 @@ static int systemVars[SV_TOPVALID] = {  		0		// ISV_GHOST_COLOR  }; -static SCNHANDLE systemStrings[SS_MAX_VALID];	// FIXME: Avoid non-const global vars +static SCNHANDLE g_systemStrings[SS_MAX_VALID];	// FIXME: Avoid non-const global vars  //static bool bFlagNoBlocking = false; @@ -116,8 +116,8 @@ static SCNHANDLE systemStrings[SS_MAX_VALID];	// FIXME: Avoid non-const global v   */  void InitSysVars() { -	systemVars[SV_SCROLL_XDISTANCE] = SCREEN_WIDTH / 2; -	systemVars[SV_SCROLL_YDISTANCE] = SCREEN_BOX_HEIGHT1 / 2; +	g_systemVars[SV_SCROLL_XDISTANCE] = SCREEN_WIDTH / 2; +	g_systemVars[SV_SCROLL_YDISTANCE] = SCREEN_BOX_HEIGHT1 / 2;  }  /** @@ -138,7 +138,7 @@ void SetSysVar(int varId, int newValue) {  		error("SetSystemVar(): read only identifier");  	default: -		systemVars[varId] = newValue; +		g_systemVars[varId] = newValue;  	}  } @@ -167,28 +167,28 @@ int SysVar(int varId) {  		//return bDebuggingAllowed;  	default: -		return systemVars[varId]; +		return g_systemVars[varId];  	}  }  void SaveSysVars(int *pSv) { -	memcpy(pSv, systemVars, sizeof(systemVars)); +	memcpy(pSv, g_systemVars, sizeof(g_systemVars));  }  void RestoreSysVars(int *pSv) { -	memcpy(systemVars, pSv, sizeof(systemVars)); +	memcpy(g_systemVars, pSv, sizeof(g_systemVars));  }  void SetSysString(int number, SCNHANDLE hString) {  	assert(number >= 0 && number < SS_MAX_VALID); -	systemStrings[number] = hString; +	g_systemStrings[number] = hString;  }  SCNHANDLE SysString(int number) {  	assert(number >= 0 && number < SS_MAX_VALID); -	return systemStrings[number]; +	return g_systemStrings[number];  }  /** diff --git a/engines/tinsel/text.cpp b/engines/tinsel/text.cpp index ecb1e153f3..5eb092d00d 100644 --- a/engines/tinsel/text.cpp +++ b/engines/tinsel/text.cpp @@ -25,7 +25,7 @@  #include "tinsel/graphics.h"	// object plotting  #include "tinsel/handle.h"  #include "tinsel/sched.h"	// process scheduler defines -#include "tinsel/strres.h"	// bMultiByte +#include "tinsel/strres.h"	// g_bMultiByte  #include "tinsel/text.h"	// text defines  namespace Tinsel { @@ -42,7 +42,7 @@ int StringLengthPix(char *szStr, const FONT *pFont) {  	// while not end of string or end of line  	for (strLen = 0; (c = *szStr) != EOS_CHAR && c != LF_CHAR; szStr++) { -		if (bMultiByte) { +		if (g_bMultiByte) {  			if (c & 0x80)  				c = ((c & ~0x80) << 8) + *++szStr;  		} @@ -136,7 +136,7 @@ OBJECT *ObjectTextOut(OBJECT **pList, char *szStr, int color,  		// repeat until end of string or end of line  		while ((c = *szStr) != EOS_CHAR && c != LF_CHAR) { -			if (bMultiByte) { +			if (g_bMultiByte) {  				if (c & 0x80)  					c = ((c & ~0x80) << 8) + *++szStr;  			} @@ -265,7 +265,7 @@ bool IsCharImage(SCNHANDLE hFont, char c) {  	// Inventory save game name editor needs to be more clever for  	// multi-byte characters. This bodge will stop it erring. -	if (bMultiByte && (c2 & 0x80)) +	if (g_bMultiByte && (c2 & 0x80))  		return false;  	// get font pointer diff --git a/engines/tinsel/timers.cpp b/engines/tinsel/timers.cpp index 1c3ff9b260..d3a7446565 100644 --- a/engines/tinsel/timers.cpp +++ b/engines/tinsel/timers.cpp @@ -49,7 +49,7 @@ struct TIMER {  //----------------- LOCAL GLOBAL DATA -------------------- -static TIMER timers[MAX_TIMERS];	// FIXME: Avoid non-const global vars +static TIMER g_timers[MAX_TIMERS];	// FIXME: Avoid non-const global vars  //-------------------------------------------------------- @@ -72,7 +72,7 @@ uint32 DwGetCurrentTime() {   */  void RebootTimers() { -	memset(timers, 0, sizeof(timers)); +	memset(g_timers, 0, sizeof(g_timers));  }  /** @@ -80,11 +80,11 @@ void RebootTimers() {   */  void syncTimerInfo(Common::Serializer &s) {  	for (int i = 0; i < MAX_TIMERS; i++) { -		s.syncAsSint32LE(timers[i].tno); -		s.syncAsSint32LE(timers[i].ticks); -		s.syncAsSint32LE(timers[i].secs); -		s.syncAsSint32LE(timers[i].delta); -		s.syncAsSint32LE(timers[i].frame); +		s.syncAsSint32LE(g_timers[i].tno); +		s.syncAsSint32LE(g_timers[i].ticks); +		s.syncAsSint32LE(g_timers[i].secs); +		s.syncAsSint32LE(g_timers[i].delta); +		s.syncAsSint32LE(g_timers[i].frame);  	}  } @@ -95,8 +95,8 @@ void syncTimerInfo(Common::Serializer &s) {   */  static TIMER *findTimer(int num) {  	for (int i = 0; i < MAX_TIMERS; i++) { -		if (timers[i].tno == num) -			return &timers[i]; +		if (g_timers[i].tno == num) +			return &g_timers[i];  	}  	return NULL;  } @@ -109,9 +109,9 @@ static TIMER *allocateTimer(int num) {  	assert(!findTimer(num)); // Allocating already existant timer  	for (int i = 0; i < MAX_TIMERS; i++) { -		if (!timers[i].tno) { -			timers[i].tno = num; -			return &timers[i]; +		if (!g_timers[i].tno) { +			g_timers[i].tno = num; +			return &g_timers[i];  		}  	} @@ -123,23 +123,23 @@ static TIMER *allocateTimer(int num) {   */  void FettleTimers() {  	for (int i = 0; i < MAX_TIMERS; i++) { -		if (!timers[i].tno) +		if (!g_timers[i].tno)  			continue; -		timers[i].ticks += timers[i].delta;	// Update tick value +		g_timers[i].ticks += g_timers[i].delta;	// Update tick value -		if (timers[i].frame) { -			if (timers[i].ticks < 0) -				timers[i].ticks = 0;	// Have reached zero +		if (g_timers[i].frame) { +			if (g_timers[i].ticks < 0) +				g_timers[i].ticks = 0;	// Have reached zero  		} else { -			if (timers[i].ticks < 0) { -				timers[i].ticks = ONE_SECOND; -				timers[i].secs--; -				if (timers[i].secs < 0) -					timers[i].secs = 0;	// Have reached zero -			} else if (timers[i].ticks == ONE_SECOND) { -				timers[i].ticks = 0; -				timers[i].secs++;		// Another second has passed +			if (g_timers[i].ticks < 0) { +				g_timers[i].ticks = ONE_SECOND; +				g_timers[i].secs--; +				if (g_timers[i].secs < 0) +					g_timers[i].secs = 0;	// Have reached zero +			} else if (g_timers[i].ticks == ONE_SECOND) { +				g_timers[i].ticks = 0; +				g_timers[i].secs++;		// Another second has passed  			}  		}  	} diff --git a/engines/tinsel/tinlib.cpp b/engines/tinsel/tinlib.cpp index 7fbec69cbf..c652abca25 100644 --- a/engines/tinsel/tinlib.cpp +++ b/engines/tinsel/tinlib.cpp @@ -74,11 +74,11 @@ namespace Tinsel {  //----------------- EXTERNAL GLOBAL DATA --------------------  // In DOS_DW.C -extern bool bRestart;		// restart flag - set to restart the game -extern bool bHasRestarted;	// Set after a restart +extern bool g_bRestart;		// restart flag - set to restart the game +extern bool g_bHasRestarted;	// Set after a restart  // In PCODE.CPP -extern bool bNoPause; +extern bool g_bNoPause;  // In DOS_MAIN.C  // TODO/FIXME: From dos_main.c: "Only used on PSX so far" @@ -100,7 +100,7 @@ extern int NewestSavedGame();  // in SCENE.CPP  extern void setshowpos(); -extern int sceneCtr; +extern int g_sceneCtr;  // in TINSEL.CPP  extern void SetCdChangeScene(SCNHANDLE hScene); @@ -122,10 +122,10 @@ SCNHANDLE GetSceneHandle();  // FIXME: Avoid non-const global vars -bool bEnableMenu; +bool g_bEnableMenu; -static bool bInstantScroll = false; -static bool bEscapedCdPlay = false; +static bool g_bInstantScroll = false; +static bool g_bEscapedCdPlay = false;  //----------------- LOCAL DEFINES -------------------- @@ -298,13 +298,13 @@ static const MASTER_LIB_CODES DW2_CODES[] = {  // as it was at control(off).  // They are global so that MoveCursor(..) has a net effect if it  // precedes control(on). -static int controlX = 0, controlY = 0; +static int g_controlX = 0, g_controlY = 0; -static int offtype = 0;			// used by Control() -static uint32 lastValue = 0;	// used by RandomFn() -static int scrollNumber = 0;	// used by scroll() +static int g_offtype = 0;			// used by Control() +static uint32 g_lastValue = 0;	// used by RandomFn() +static int g_scrollNumber = 0;	// used by scroll() -static bool bNotPointedRunning = false;	// Used in Printobj and PrintObjPointed +static bool g_bNotPointedRunning = false;	// Used in Printobj and PrintObjPointed  //----------------- FORWARD REFERENCES -------------------- @@ -404,7 +404,7 @@ static void ScrollMonitorProcess(CORO_PARAM, const void *param) {  		CORO_SLEEP(1);  		// give up if have been superseded -		if (psm->thisScroll != scrollNumber) +		if (psm->thisScroll != g_scrollNumber)  			break;  		// If ESCAPE is pressed... @@ -706,7 +706,7 @@ static void CDload(SCNHANDLE start, SCNHANDLE next, int myEscape) {  	if (TinselV2) {  		if (myEscape && myEscape != GetEscEvents()) { -			bEscapedCdPlay = true; +			g_bEscapedCdPlay = true;  			return;  		} @@ -754,14 +754,14 @@ void Control(int param) {  	}  	// Tinsel 1 handling code -	bEnableMenu = false; +	g_bEnableMenu = false;  	switch (param) {  	case CONTROL_STARTOFF:  		GetControlToken();	// Take control  		DisableTags();			// Switch off tags  		DwHideCursor();			// Blank out cursor -		offtype = param; +		g_offtype = param;  		break;  	case CONTROL_OFF: @@ -771,17 +771,17 @@ void Control(int param) {  			GetControlToken();	// Take control  			DisableTags();			// Switch off tags -			GetCursorXYNoWait(&controlX, &controlY, true);	// Store cursor position +			GetCursorXYNoWait(&g_controlX, &g_controlY, true);	// Store cursor position  			// There may be a button timing out  			GetToken(TOKEN_LEFT_BUT);  			FreeToken(TOKEN_LEFT_BUT);  		} -		if (offtype == CONTROL_STARTOFF) -			GetCursorXYNoWait(&controlX, &controlY, true);	// Store cursor position +		if (g_offtype == CONTROL_STARTOFF) +			GetCursorXYNoWait(&g_controlX, &g_controlY, true);	// Store cursor position -		offtype = param; +		g_offtype = param;  		if (param == CONTROL_OFF)  			DwHideCursor();		// Blank out cursor @@ -794,8 +794,8 @@ void Control(int param) {  		break;  	case CONTROL_ON: -		if (offtype != CONTROL_OFFV2 && offtype != CONTROL_STARTOFF) -			SetCursorXY(controlX, controlY);// ... where it was +		if (g_offtype != CONTROL_OFFV2 && g_offtype != CONTROL_STARTOFF) +			SetCursorXY(g_controlX, g_controlY);// ... where it was  		FreeControlToken();	// Release control @@ -1092,7 +1092,7 @@ static void DropEverything() {   * EnableMenu   */  static void EnableMenu() { -	bEnableMenu = true; +	g_bEnableMenu = true;  }  /** @@ -1212,7 +1212,7 @@ static void HailScene(SCNHANDLE scene) {   * Returns TRUE if the game has been restarted, FALSE if not.   */  static bool HasRestarted() { -	return bHasRestarted; +	return g_bHasRestarted;  }  /** @@ -1308,7 +1308,7 @@ static int IdleTime() {   * Set flag if InstantScroll(on), reset if InstantScroll(off)   */  void InstantScroll(int onoff) { -	bInstantScroll = (onoff != 0); +	g_bInstantScroll = (onoff != 0);  }  /** @@ -1419,8 +1419,8 @@ static int LToffset(int lort) {  static void MoveCursor(int x, int y) {  	SetCursorXY(x, y); -	controlX = x;		// Save these values so that -	controlY = y;		// control(on) doesn't undo this +	g_controlX = x;		// Save these values so that +	g_controlY = y;		// control(on) doesn't undo this  }  /** @@ -1465,7 +1465,7 @@ void NewScene(CORO_PARAM, SCNHANDLE scene, int entrance, int transition) {  		GetControl(CONTROL_STARTOFF);  	if (TinselV1) -		++sceneCtr; +		++g_sceneCtr;  	// Prevent code subsequent to this call running before scene changes  	if (g_scheduler->getCurrentPID() != PID_MASTER_SCR) @@ -1541,8 +1541,8 @@ static void Play(CORO_PARAM, SCNHANDLE hFilm, int x, int y, int compit, int acto  	// Don't do CDPlay() for now if already escaped -	if (bEscapedCdPlay) { -		bEscapedCdPlay = false; +	if (g_bEscapedCdPlay) { +		g_bEscapedCdPlay = false;  		return;  	} @@ -1583,8 +1583,8 @@ static void Play(CORO_PARAM, SCNHANDLE hFilm, int x, int y, bool bComplete, int  	assert(hFilm != 0);  	// Don't do CdPlay() for now if already escaped -	if (bEscapedCdPlay) { -		bEscapedCdPlay = false; +	if (g_bEscapedCdPlay) { +		g_bEscapedCdPlay = false;  		return;  	} @@ -2068,11 +2068,11 @@ static void PrintObj(CORO_PARAM, const SCNHANDLE hText, const INV_OBJECT *pinvo,  	_ctx->myEscape = myEscape;  	if (hText == (SCNHANDLE)-1) {	// 'OFF' -		bNotPointedRunning = true; +		g_bNotPointedRunning = true;  		return;  	}  	if (hText == (SCNHANDLE)-2) {	// 'ON' -		bNotPointedRunning = false; +		g_bNotPointedRunning = false;  		return;  	} @@ -2092,10 +2092,10 @@ static void PrintObj(CORO_PARAM, const SCNHANDLE hText, const INV_OBJECT *pinvo,  	* POINT/other event PrintObj() arbitration...  	*/  	if (event != POINTED) { -		bNotPointedRunning = true;	// Get POINTED text to die +		g_bNotPointedRunning = true;	// Get POINTED text to die  		CORO_SLEEP(1);		// Give it chance to  	} else if (!TinselV2) -		bNotPointedRunning = false;	// There may have been an OFF without an ON +		g_bNotPointedRunning = false;	// There may have been an OFF without an ON  	// Make multi-ones escape  	if (TinselV2 && (SubStringCount(hText) > 1) && !_ctx->myEscape) @@ -2163,12 +2163,12 @@ static void PrintObj(CORO_PARAM, const SCNHANDLE hText, const INV_OBJECT *pinvo,  						break;  					// Give way to non-POINTED-generated text -					if (bNotPointedRunning) { +					if (g_bNotPointedRunning) {  						// Delete the text, and wait for the all-clear  						MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), _ctx->pText);  						_ctx->pText = NULL; -						while (bNotPointedRunning) +						while (g_bNotPointedRunning)  							CORO_SLEEP(1);  						GetCursorXY(&x, &y, false); @@ -2262,7 +2262,7 @@ static void PrintObj(CORO_PARAM, const SCNHANDLE hText, const INV_OBJECT *pinvo,  	// Let POINTED text back in if this is the last  	if (event != POINTED) -		bNotPointedRunning = false; +		g_bNotPointedRunning = false;  	CORO_END_CODE;  } @@ -2281,11 +2281,11 @@ static void PrintObjPointed(CORO_PARAM, const SCNHANDLE text, const INV_OBJECT *  				break;  			// Give way to non-POINTED-generated text -			if (bNotPointedRunning) { +			if (g_bNotPointedRunning) {  				// Delete the text, and wait for the all-clear  				MultiDeleteObject(GetPlayfieldList(FIELD_STATUS), pText);  				pText = NULL; -				while (bNotPointedRunning) +				while (g_bNotPointedRunning)  					CORO_SLEEP(1);  				GetCursorXY(&x, &y, false); @@ -2372,7 +2372,7 @@ static void PrintObjNonPointed(CORO_PARAM, const SCNHANDLE text, const OBJECT *p  			}  		} while (1); -		bNotPointedRunning = false;	// Let POINTED text back in +		g_bNotPointedRunning = false;	// Let POINTED text back in  		if (_ctx->took_control)  			Control(CONTROL_ON);	// Free control if we took it @@ -2425,9 +2425,9 @@ static int RandomFn(int n1, int n2, int norpt) {  	do {  		value = n1 + _vm->getRandomNumber(n2 - n1); -	} while ((lastValue == value) && (norpt == RAND_NORPT) && (++i <= 10)); +	} while ((g_lastValue == value) && (norpt == RAND_NORPT) && (++i <= 10)); -	lastValue = value; +	g_lastValue = value;  	return value;  } @@ -2446,8 +2446,8 @@ void FnRestartGame() {  	StopMidi();  	StopSample(); -	bRestart = true; -	sceneCtr = 0; +	g_bRestart = true; +	g_sceneCtr = 0;  }  /** @@ -2554,15 +2554,15 @@ static void Scroll(CORO_PARAM, EXTREME extreme, int xp, int yp, int xIter, int y  	CORO_BEGIN_CODE(_ctx); -	++scrollNumber; +	++g_scrollNumber;  	_ctx->x = xp;  	_ctx->y = yp; -	if ((TinselV2 && bInstantScroll) || (escOn && myEscape != GetEscEvents())) { +	if ((TinselV2 && g_bInstantScroll) || (escOn && myEscape != GetEscEvents())) {  		// Instant completion!  		Offset(extreme, _ctx->x, _ctx->y);  	} else { -		_ctx->thisScroll = scrollNumber; +		_ctx->thisScroll = g_scrollNumber;  		if (TinselV2)  			DecodeExtreme(extreme, &_ctx->x, &_ctx->y); @@ -2581,7 +2581,7 @@ static void Scroll(CORO_PARAM, EXTREME extreme, int xp, int yp, int xIter, int y  				}  				// give up if have been superseded -				if (_ctx->thisScroll != scrollNumber) +				if (_ctx->thisScroll != g_scrollNumber)  					CORO_KILL_SELF();  				PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset); @@ -2592,7 +2592,7 @@ static void Scroll(CORO_PARAM, EXTREME extreme, int xp, int yp, int xIter, int y  			// Scroll is escapable even though we're not waiting for it  			sm.x = _ctx->x;  			sm.y = _ctx->y; -			sm.thisScroll = scrollNumber; +			sm.thisScroll = g_scrollNumber;  			sm.myEscape = myEscape;  			g_scheduler->createProcess(PID_TCODE, ScrollMonitorProcess, &sm, sizeof(sm));  		} @@ -3410,8 +3410,8 @@ static void TalkOrSay(CORO_PARAM, SPEECH_TYPE speechType, SCNHANDLE hText, int x  		if (TinselV2 && _ctx->bSample) {  			// Kick off the sample now (perhaps with a delay) -			if (bNoPause) -				bNoPause = false; +			if (g_bNoPause) +				g_bNoPause = false;  			else if (!IsDemo)  				CORO_SLEEP(SysVar(SV_SPEECHDELAY)); @@ -4899,7 +4899,7 @@ int CallLibraryRoutine(CORO_PARAM, int operand, int32 *pp, const INT_CONTEXT *pi  	case NOPAUSE:  		// DW2 only -		bNoPause = true; +		g_bNoPause = true;  		return 0;  	case NOSCROLL: diff --git a/engines/tinsel/tinsel.cpp b/engines/tinsel/tinsel.cpp index cd0f9b9fa4..65900cc7f3 100644 --- a/engines/tinsel/tinsel.cpp +++ b/engines/tinsel/tinsel.cpp @@ -66,7 +66,7 @@ namespace Tinsel {  // In BG.CPP  extern void SetDoFadeIn(bool tf);  extern void DropBackground(); -extern const BACKGND *pCurBgnd; +extern const BACKGND *g_pCurBgnd;  // In CURSOR.CPP  extern void CursorProcess(CORO_PARAM, const void *); @@ -85,16 +85,16 @@ void SetNewScene(SCNHANDLE scene, int entrance, int transition);  // FIXME: Avoid non-const global vars -bool bRestart = false; -bool bHasRestarted = false; -bool loadingFromGMM = false; +bool g_bRestart = false; +bool g_bHasRestarted = false; +bool g_loadingFromGMM = false; -static bool bCuttingScene = false; +static bool g_bCuttingScene = false; -static bool bChangingForRestore = false; +static bool g_bChangingForRestore = false;  #ifdef DEBUG -bool bFast;		// set to make it go ludicrously fast +bool g_bFast;		// set to make it go ludicrously fast  #endif  //----------------- LOCAL GLOBAL DATA -------------------- @@ -105,14 +105,14 @@ struct Scene {  	int	trans;		// Transition - not yet used  }; -static Scene NextScene = { 0, 0, 0 }; -static Scene HookScene = { 0, 0, 0 }; -static Scene DelayedScene = { 0, 0, 0 }; +static Scene g_NextScene = { 0, 0, 0 }; +static Scene g_HookScene = { 0, 0, 0 }; +static Scene g_DelayedScene = { 0, 0, 0 }; -static PROCESS *pMouseProcess = 0; -static PROCESS *pKeyboardProcess = 0; +static PROCESS *g_pMouseProcess = 0; +static PROCESS *g_pKeyboardProcess = 0; -static SCNHANDLE hCdChangeScene; +static SCNHANDLE g_hCdChangeScene;  //----------------- LOCAL PROCEDURES -------------------- @@ -457,49 +457,49 @@ static void MasterScriptProcess(CORO_PARAM, const void *) {   * Store the facts pertaining to a scene change.   */  void SetNewScene(SCNHANDLE scene, int entrance, int transition) { -	if (!bCuttingScene && TinselV2) +	if (!g_bCuttingScene && TinselV2)  		WrapScene();  	// If we're loading from the GMM, load the scene as a delayed one -	if (loadingFromGMM) { -		DelayedScene.scene = scene; -		DelayedScene.entry = entrance; -		DelayedScene.trans = transition; -		loadingFromGMM = false; +	if (g_loadingFromGMM) { +		g_DelayedScene.scene = scene; +		g_DelayedScene.entry = entrance; +		g_DelayedScene.trans = transition; +		g_loadingFromGMM = false;  		return;  	}  	// If CD change will be required, stick in the scene change scene  	if (CdNumber(scene) != GetCurrentCD()) {  		// This scene gets delayed -		DelayedScene.scene = scene; -		DelayedScene.entry = entrance; -		DelayedScene.trans = transition; +		g_DelayedScene.scene = scene; +		g_DelayedScene.entry = entrance; +		g_DelayedScene.trans = transition; -		NextScene.scene = hCdChangeScene; -		NextScene.entry = CdNumber(scene) - '0'; -		NextScene.trans = TRANS_FADE; +		g_NextScene.scene = g_hCdChangeScene; +		g_NextScene.entry = CdNumber(scene) - '0'; +		g_NextScene.trans = TRANS_FADE;  		return;  	} -	if (HookScene.scene == 0 || bCuttingScene) { +	if (g_HookScene.scene == 0 || g_bCuttingScene) {  		// This scene comes next -		NextScene.scene = scene; -		NextScene.entry = entrance; -		NextScene.trans = transition; +		g_NextScene.scene = scene; +		g_NextScene.entry = entrance; +		g_NextScene.trans = transition;  	} else {  		// This scene gets delayed -		DelayedScene.scene = scene; -		DelayedScene.entry = entrance; -		DelayedScene.trans = transition; +		g_DelayedScene.scene = scene; +		g_DelayedScene.entry = entrance; +		g_DelayedScene.trans = transition;  		// The hooked scene comes next -		NextScene.scene = HookScene.scene; -		NextScene.entry = HookScene.entry; -		NextScene.trans = HookScene.trans; +		g_NextScene.scene = g_HookScene.scene; +		g_NextScene.entry = g_HookScene.entry; +		g_NextScene.trans = g_HookScene.trans; -		HookScene.scene = 0; +		g_HookScene.scene = 0;  	}  	// Workaround for "Missing Red Dragon in square" bug in Discworld 1 PSX, act IV. @@ -509,10 +509,10 @@ void SetNewScene(SCNHANDLE scene, int entrance, int transition) {  	// I'm forcing the load of the right scene by checking that the player has (or has not) the  	// right items: player must have Mambo the swamp dragon, and mustn't have fireworks (used on  	// the swamp dragon previously to "load it up"). -	if (TinselV1PSX && NextScene.scene == 0x1800000 && NextScene.entry == 2) { +	if (TinselV1PSX && g_NextScene.scene == 0x1800000 && g_NextScene.entry == 2) {  		if ((IsInInventory(261, INV_1) || IsInInventory(261, INV_2)) &&  			(!IsInInventory(232, INV_1) && !IsInInventory(232, INV_2))) -			NextScene.entry = 1; +			g_NextScene.entry = 1;  	}  } @@ -520,72 +520,72 @@ void SetNewScene(SCNHANDLE scene, int entrance, int transition) {   * Store a scene as hooked   */  void SetHookScene(SCNHANDLE scene, int entrance, int transition) { -	assert(HookScene.scene == 0); // scene already hooked +	assert(g_HookScene.scene == 0); // scene already hooked -	HookScene.scene = scene; -	HookScene.entry = entrance; -	HookScene.trans = transition; +	g_HookScene.scene = scene; +	g_HookScene.entry = entrance; +	g_HookScene.trans = transition;  }  /**   * Hooked scene is over, trigger a change to the delayed scene   */  void UnHookScene() { -	assert(DelayedScene.scene != 0); // no scene delayed +	assert(g_DelayedScene.scene != 0); // no scene delayed  	// The delayed scene can go now -	NextScene.scene = DelayedScene.scene; -	NextScene.entry = DelayedScene.entry; -	NextScene.trans = DelayedScene.trans; +	g_NextScene.scene = g_DelayedScene.scene; +	g_NextScene.entry = g_DelayedScene.entry; +	g_NextScene.trans = g_DelayedScene.trans; -	DelayedScene.scene = 0; +	g_DelayedScene.scene = 0;  }  void SuspendHook() { -	bCuttingScene = true; +	g_bCuttingScene = true;  }  void CdHasChanged() { -	if (bChangingForRestore) { -		bChangingForRestore = false; +	if (g_bChangingForRestore) { +		g_bChangingForRestore = false;  		RestoreGame(-2);  	} else { -		assert(DelayedScene.scene != 0); +		assert(g_DelayedScene.scene != 0);  		WrapScene();  		// The delayed scene can go now -		NextScene.scene = DelayedScene.scene; -		NextScene.entry = DelayedScene.entry; -		NextScene.trans = DelayedScene.trans; +		g_NextScene.scene = g_DelayedScene.scene; +		g_NextScene.entry = g_DelayedScene.entry; +		g_NextScene.trans = g_DelayedScene.trans; -		DelayedScene.scene = 0; +		g_DelayedScene.scene = 0;  	}  }  void SetCdChangeScene(SCNHANDLE hScene) { -	hCdChangeScene = hScene; +	g_hCdChangeScene = hScene;  }  void CDChangeForRestore(int cdNumber) { -	NextScene.scene = hCdChangeScene; -	NextScene.entry = cdNumber; -	NextScene.trans = TRANS_FADE; -	bChangingForRestore = true; +	g_NextScene.scene = g_hCdChangeScene; +	g_NextScene.entry = cdNumber; +	g_NextScene.trans = TRANS_FADE; +	g_bChangingForRestore = true;  }  void UnSuspendHook() { -	bCuttingScene = false; +	g_bCuttingScene = false;  }  void syncSCdata(Common::Serializer &s) { -	s.syncAsUint32LE(HookScene.scene); -	s.syncAsSint32LE(HookScene.entry); -	s.syncAsSint32LE(HookScene.trans); +	s.syncAsUint32LE(g_HookScene.scene); +	s.syncAsSint32LE(g_HookScene.entry); +	s.syncAsSint32LE(g_HookScene.trans); -	s.syncAsUint32LE(DelayedScene.scene); -	s.syncAsSint32LE(DelayedScene.entry); -	s.syncAsSint32LE(DelayedScene.trans); +	s.syncAsUint32LE(g_DelayedScene.scene); +	s.syncAsSint32LE(g_DelayedScene.entry); +	s.syncAsSint32LE(g_DelayedScene.trans);  } @@ -640,16 +640,16 @@ bool ChangeScene(bool bReset) {  	// Prevent attempt to fade-out when restarting game  	if (bReset) {  		CountOut = 1;	// immediate start of first scene again -		DelayedScene.scene = HookScene.scene = 0; +		g_DelayedScene.scene = g_HookScene.scene = 0;  		return false;  	}  	if (IsRestoringScene())  		return true; -	if (NextScene.scene != 0) { +	if (g_NextScene.scene != 0) {  		if (!CountOut) { -			switch (NextScene.trans) { +			switch (g_NextScene.trans) {  			case TRANS_CUT:  				CountOut = 1;  				break; @@ -667,10 +667,10 @@ bool ChangeScene(bool bReset) {  			if (!TinselV2)  				ClearScreen(); -			StartNewScene(NextScene.scene, NextScene.entry); -			NextScene.scene = 0; +			StartNewScene(g_NextScene.scene, g_NextScene.entry); +			g_NextScene.scene = 0; -			switch (NextScene.trans) { +			switch (g_NextScene.trans) {  			case TRANS_CUT:  				SetDoFadeIn(false);  				break; @@ -691,7 +691,7 @@ bool ChangeScene(bool bReset) {   * CuttingScene   */  void CuttingScene(bool bCutting) { -	bCuttingScene = bCutting; +	g_bCuttingScene = bCutting;  	if (!bCutting)  		WrapScene(); @@ -927,7 +927,7 @@ Common::Error TinselEngine::run() {  	RebootTimers();  	RebootScalingReels(); -	DelayedScene.scene = HookScene.scene = 0; +	g_DelayedScene.scene = g_HookScene.scene = 0;  #endif  	// Load in text strings @@ -957,7 +957,7 @@ Common::Error TinselEngine::run() {  	if (ConfMan.hasKey("save_slot")) {  		if (loadGameState(ConfMan.getInt("save_slot")).getCode() == Common::kNoError) -			loadingFromGMM = true; +			g_loadingFromGMM = true;  	}  	// Foreground loop @@ -973,10 +973,10 @@ Common::Error TinselEngine::run() {  			NextGameCycle();  		} -		if (bRestart) { +		if (g_bRestart) {  			RestartGame(); -			bRestart = false; -			bHasRestarted = true;	// Set restarted flag +			g_bRestart = false; +			g_bHasRestarted = true;	// Set restarted flag  		}  		// Save/Restore scene file transfers @@ -986,7 +986,7 @@ Common::Error TinselEngine::run() {  		_bmv->FettleBMV();  #ifdef DEBUG -		if (bFast) +		if (g_bFast)  			continue;		// run flat-out  #endif  		// Loop processing events while there are any pending @@ -1005,7 +1005,7 @@ Common::Error TinselEngine::run() {  	_vm->_config->writeToDisk();  	EndScene(); -	pCurBgnd = NULL; +	g_pCurBgnd = NULL;  	return Common::kNoError;  } @@ -1106,7 +1106,7 @@ void TinselEngine::RestartGame() {  	RebootTimers();  	RebootScalingReels(); -	DelayedScene.scene = HookScene.scene = 0; +	g_DelayedScene.scene = g_HookScene.scene = 0;  	// remove keyboard, mouse and joystick drivers  	ChopDrivers(); @@ -1135,8 +1135,8 @@ void TinselEngine::RestartDrivers() {  	_scheduler->reset();  	// init the event handlers -	pMouseProcess = _scheduler->createProcess(PID_MOUSE, MouseProcess, NULL, 0); -	pKeyboardProcess = _scheduler->createProcess(PID_KEYBOARD, KeyboardProcess, NULL, 0); +	g_pMouseProcess = _scheduler->createProcess(PID_MOUSE, MouseProcess, NULL, 0); +	g_pKeyboardProcess = _scheduler->createProcess(PID_KEYBOARD, KeyboardProcess, NULL, 0);  	// open MIDI files  	OpenMidiFiles(); @@ -1164,8 +1164,8 @@ void TinselEngine::ChopDrivers() {  	DeleteMidiBuffer();  	// remove event drivers -	_scheduler->killProcess(pMouseProcess); -	_scheduler->killProcess(pKeyboardProcess); +	_scheduler->killProcess(g_pMouseProcess); +	_scheduler->killProcess(g_pKeyboardProcess);  }  /** diff --git a/engines/tinsel/token.cpp b/engines/tinsel/token.cpp index c7490a100b..c26fa40466 100644 --- a/engines/tinsel/token.cpp +++ b/engines/tinsel/token.cpp @@ -34,7 +34,7 @@ struct Token {  	PROCESS		*proc;  }; -static Token tokens[NUMTOKENS];	// FIXME: Avoid non-const global vars +static Token g_tokens[NUMTOKENS];	// FIXME: Avoid non-const global vars  /** @@ -44,8 +44,8 @@ static void TerminateProcess(PROCESS *tProc) {  	// Release tokens held by the process  	for (int i = 0; i < NUMTOKENS; i++) { -		if (tokens[i].proc == tProc) { -			tokens[i].proc = NULL; +		if (g_tokens[i].proc == tProc) { +			g_tokens[i].proc = NULL;  		}  	} @@ -59,8 +59,8 @@ static void TerminateProcess(PROCESS *tProc) {  void GetControlToken() {  	const int which = TOKEN_CONTROL; -	if (tokens[which].proc == NULL) { -		tokens[which].proc = g_scheduler->getCurrentProcess(); +	if (g_tokens[which].proc == NULL) { +		g_tokens[which].proc = g_scheduler->getCurrentProcess();  	}  } @@ -69,7 +69,7 @@ void GetControlToken() {   */  void FreeControlToken() {  	// Allow anyone to free TOKEN_CONTROL -	tokens[TOKEN_CONTROL].proc = NULL; +	g_tokens[TOKEN_CONTROL].proc = NULL;  } @@ -84,12 +84,12 @@ void FreeControlToken() {  void GetToken(int which) {  	assert(TOKEN_LEAD <= which && which < NUMTOKENS); -	if (tokens[which].proc != NULL) { -		assert(tokens[which].proc != g_scheduler->getCurrentProcess()); -		TerminateProcess(tokens[which].proc); +	if (g_tokens[which].proc != NULL) { +		assert(g_tokens[which].proc != g_scheduler->getCurrentProcess()); +		TerminateProcess(g_tokens[which].proc);  	} -	tokens[which].proc = g_scheduler->getCurrentProcess(); +	g_tokens[which].proc = g_scheduler->getCurrentProcess();  }  /** @@ -99,9 +99,9 @@ void GetToken(int which) {  void FreeToken(int which) {  	assert(TOKEN_LEAD <= which && which < NUMTOKENS); -	assert(tokens[which].proc == g_scheduler->getCurrentProcess());	// we'd have been killed if some other proc had taken this token +	assert(g_tokens[which].proc == g_scheduler->getCurrentProcess());	// we'd have been killed if some other proc had taken this token -	tokens[which].proc = NULL; +	g_tokens[which].proc = NULL;  }  /** @@ -111,7 +111,7 @@ bool TestToken(int which) {  	if (which < 0 || which >= NUMTOKENS)  		return false; -	return (tokens[which].proc == NULL); +	return (g_tokens[which].proc == NULL);  }  /** @@ -119,7 +119,7 @@ bool TestToken(int which) {   */  void FreeAllTokens() {  	for (int i = 0; i < NUMTOKENS; i++) { -		tokens[i].proc = NULL; +		g_tokens[i].proc = NULL;  	}  } diff --git a/engines/touche/graphics.h b/engines/touche/graphics.h index 4b769b0a66..5b2ea39a24 100644 --- a/engines/touche/graphics.h +++ b/engines/touche/graphics.h @@ -23,7 +23,7 @@  #ifndef TOUCHE_GRAPHICS_H  #define TOUCHE_GRAPHICS_H -#include "common/util.h" +#include "common/language.h"  namespace Touche { diff --git a/engines/tsage/blue_force/blueforce_logic.cpp b/engines/tsage/blue_force/blueforce_logic.cpp index eef48ad58e..3aef18f4f0 100644 --- a/engines/tsage/blue_force/blueforce_logic.cpp +++ b/engines/tsage/blue_force/blueforce_logic.cpp @@ -733,7 +733,7 @@ void SceneExt::remove() {  			_action->_endHandler = NULL;  		_action->remove();  	} -	 +  	_focusObject = NULL;  } @@ -1326,7 +1326,7 @@ bool BlueForceInvObjectList::SelectItem(int objectNumber) {  		AmmoBeltDialog *dlg = new AmmoBeltDialog();  		dlg->execute();  		delete dlg; -	 +  		return true;  	} @@ -1408,7 +1408,7 @@ void SceneMessage::signal() {  }  void SceneMessage::process(Event &event) { -	if ((event.eventType == EVENT_BUTTON_DOWN) ||  +	if ((event.eventType == EVENT_BUTTON_DOWN) ||  		((event.eventType == EVENT_KEYPRESS) && (event.kbd.keycode == Common::KEYCODE_RETURN))) {  		signal();  	} @@ -1439,7 +1439,7 @@ void SceneMessage::draw() {  void SceneMessage::clear() {  	// Fade out the text display -	static const uint32 black = 0;	 +	static const uint32 black = 0;  	BF_GLOBALS._scenePalette.fade((const byte *)&black, false, 100);  	// Refresh the background diff --git a/engines/tsage/blue_force/blueforce_scenes1.cpp b/engines/tsage/blue_force/blueforce_scenes1.cpp index c067cd87ea..9f1e9ce36e 100644 --- a/engines/tsage/blue_force/blueforce_scenes1.cpp +++ b/engines/tsage/blue_force/blueforce_scenes1.cpp @@ -430,7 +430,7 @@ void Scene110::Action1::signal() {  	case 6:  		// Play "Vroum"  		scene->_sound.play(31); -		// The guy starts the engine  +		// The guy starts the engine  		scene->_object4.setStrip(3);  		scene->_object4._frame = 1;  		scene->_object4.animate(ANIM_MODE_5, NULL); @@ -837,7 +837,7 @@ void Scene110::postInit(SceneObjectList *OwnerList) {  	_object10._moveDiff.y = 10;  	_object10.setPosition(_object9._position);  	_object10.hide(); -	 +  	setAction(&_action1);  }  /*-------------------------------------------------------------------------- @@ -987,7 +987,7 @@ void Scene114::signal() {   *--------------------------------------------------------------------------*/  bool Scene115::Kate::startAction(CursorType action, Event &event) {  	Scene115 *scene = (Scene115 *)BF_GLOBALS._sceneManager._scene; -	 +  	switch (action) {  	case CURSOR_LOOK:  		SceneItem::display(115, 8, SET_WIDTH, 312, @@ -1061,7 +1061,7 @@ bool Scene115::Kate::startAction(CursorType action, Event &event) {  bool Scene115::Tony::startAction(CursorType action, Event &event) {  	Scene115 *scene = (Scene115 *)BF_GLOBALS._sceneManager._scene; -	 +  	switch (action) {  	case CURSOR_LOOK:  		SceneItem::display(115, 7, SET_WIDTH, 312, @@ -1164,7 +1164,7 @@ bool Scene115::Tony::startAction(CursorType action, Event &event) {  bool Scene115::Object3::startAction(CursorType action, Event &event) {  	Scene115 *scene = (Scene115 *)BF_GLOBALS._sceneManager._scene; -	 +  	switch (action) {  	case CURSOR_LOOK:  		SceneItem::display(115, 9, SET_WIDTH, 312, @@ -1195,7 +1195,7 @@ bool Scene115::Object3::startAction(CursorType action, Event &event) {  bool Scene115::Object4::startAction(CursorType action, Event &event) {  	Scene115 *scene = (Scene115 *)BF_GLOBALS._sceneManager._scene; -	 +  	switch (action) {  	case CURSOR_LOOK:  		SceneItem::display(115, 42, SET_WIDTH, 312, @@ -1217,7 +1217,7 @@ bool Scene115::Object4::startAction(CursorType action, Event &event) {  void Scene115::Jukebox::signal() {  	Scene115 *scene = (Scene115 *)BF_GLOBALS._sceneManager._scene; -	 +  	if (_jokeboxPlayingCtr == 2)  		_jokeboxPlayingCtr = 0;  	else if (_jokeboxPlayingCtr == 1) { @@ -1228,7 +1228,7 @@ void Scene115::Jukebox::signal() {  bool Scene115::Jukebox::startAction(CursorType action, Event &event) {  	Scene115 *scene = (Scene115 *)BF_GLOBALS._sceneManager._scene; -	 +  	if (action == CURSOR_USE) {  		if (_jokeboxPlayingCtr == 0) {  			_jokeboxPlayingCtr = 1; @@ -1241,7 +1241,7 @@ bool Scene115::Jukebox::startAction(CursorType action, Event &event) {  				SET_FONT, 4, SET_BG_COLOR, 1, SET_FG_COLOR, 19, SET_EXT_BGCOLOR, 9,  				SET_EXT_FGCOLOR, 13, LIST_END);  		return true; -	} else  +	} else  		return NamedHotspot::startAction(action, event);  } @@ -1265,7 +1265,7 @@ void Scene115::EventHandler1::dispatch() {  bool Scene115::Item10::startAction(CursorType action, Event &event) {  	Scene115 *scene = (Scene115 *)BF_GLOBALS._sceneManager._scene; -	 +  	if (BF_GLOBALS.getFlag(fWithLyle)) {  		scene->_object4.setStrip2(6);  		Common::Point pt(-20, 122); @@ -1591,7 +1591,7 @@ Scene115::Scene115() : SceneExt () {  void Scene115::postInit(SceneObjectList *OwnerList) {  	SceneExt::postInit(); -	 +  	BF_GLOBALS._sound1.fadeSound(15);  	loadScene(115);  	setZoomPercents(98, 85, 115, 100); @@ -1641,7 +1641,7 @@ void Scene115::postInit(SceneObjectList *OwnerList) {  	_object11.postInit();  	_object11.hide(); -	 +  	_object12.postInit();  	_object12.hide(); @@ -1817,7 +1817,7 @@ void Scene125::Action1::signal() {  	case 0:  	// No break on purpose  	default: -		break;		 +		break;  	}  } @@ -2054,7 +2054,7 @@ void Scene125::Action3::dispatch() {  	SceneObject *owner = static_cast<SceneObject *>(this->_owner);  	Action::dispatch(); -	 +  	if ((_actionIndex == 9) && (owner->_percent > 70))  		owner->changeZoom(owner->_percent - 1);  } @@ -2095,7 +2095,7 @@ void Scene125::Action4::dispatch() {  	SceneObject *owner = static_cast<SceneObject *>(this->_owner);  	Action::dispatch(); -	 +  	if ((_actionIndex == 4) && (owner->_percent > 80))  		owner->changeZoom(owner->_percent - 1);  } @@ -2134,7 +2134,7 @@ void Scene125::Action6::dispatch() {  	SceneObject *owner = static_cast<SceneObject *>(this->_owner);  	Action::dispatch(); -	 +  	if ((_actionIndex == 2) && (owner->_percent < 100))  		owner->changeZoom(owner->_percent + 1);  } @@ -2169,7 +2169,7 @@ void Scene125::postInit(SceneObjectList *OwnerList) {  	BF_GLOBALS._player._moveDiff.x = 6;  	BF_GLOBALS._player._moveDiff.y = 6;  	BF_GLOBALS._player.disableControl(); -	 +  	_object5.postInit();  	_object5.setVisage(128);  	_object5.setPosition(Common::Point(150, 117)); @@ -2457,7 +2457,7 @@ void Scene160::Action1::signal() {  		scene->_kid.setStrip(2);  		scene->_kid.animate(ANIM_MODE_5, this); -		scene->_kidBody.setPosition(scene->_kid._position);  +		scene->_kidBody.setPosition(scene->_kid._position);  		scene->_kidBody.setFrame(1);  		scene->_kidBody.setStrip(3);  		break; @@ -2630,7 +2630,7 @@ void Scene160::Action2::signal() {  		break;  	case 25:  		BF_GLOBALS._sound1.fade(0, 10, 10, true, this); -// FIXME: Currently, fade() doesn't end properly with this song,  +// FIXME: Currently, fade() doesn't end properly with this song,  //        thus never returns here. This hack skips the wait and changes  //        directly to the next scene  // Start of hack @@ -2895,7 +2895,7 @@ void Scene180::postInit(SceneObjectList *OwnerList) {  				_vechile.setStrip(3);  				_vechile._frame = 5;  				_vechile.changeZoom(75); -				 +  				_dispatchMode = 1;  				_vechile._moveDiff.x = 45;  			} else { diff --git a/engines/tsage/blue_force/blueforce_scenes1.h b/engines/tsage/blue_force/blueforce_scenes1.h index b304c2aeaa..ddde200370 100644 --- a/engines/tsage/blue_force/blueforce_scenes1.h +++ b/engines/tsage/blue_force/blueforce_scenes1.h @@ -137,7 +137,7 @@ class Scene110: public SceneExt {  		virtual void signal();  	};  public: -	NamedObject _object1, _object2, _object3, _object4, _object5, _object6, _object7, _object8, _object9, _object10;  +	NamedObject _object1, _object2, _object3, _object4, _object5, _object6, _object7, _object8, _object9, _object10;  	ASound _sound;  	Action1 _action1;  	Action2 _action2; @@ -354,7 +354,7 @@ public:  	NamedObject _object1;  	NamedObject _object2;  	IntroSceneText _text; -	 +  	void postInit(SceneObjectList *OwnerList);  }; diff --git a/engines/tsage/blue_force/blueforce_scenes2.cpp b/engines/tsage/blue_force/blueforce_scenes2.cpp index 340baae6a9..c992afe620 100644 --- a/engines/tsage/blue_force/blueforce_scenes2.cpp +++ b/engines/tsage/blue_force/blueforce_scenes2.cpp @@ -67,7 +67,7 @@ void Scene200::Action1::signal() {  		rot->setDelay(10);  		rot = BF_GLOBALS._scenePalette.addRotation(96, 111, 1);  		rot->setDelay(10); -		 +  		scene->setAction(&scene->_sequenceManager, this, 201, &scene->_object1, &scene->_object2,  			&scene->_object3, &scene->_object4, &scene->_object5, &scene->_object6, NULL);  		break; @@ -99,7 +99,7 @@ void Scene200::Action2::signal() {  		break;  	}  } -	 +  /*--------------------------------------------------------------------------*/ @@ -133,7 +133,7 @@ void Scene200::postInit(SceneObjectList *OwnerList) {  	_object11.setVisage(200);  	_object11.setPosition(Common::Point(96, 112), 1000);  	_object11.setStrip(3); -	_object11.setFrame(1);  +	_object11.setFrame(1);  	_object11.changeZoom(100);  	_object10.setAction(&_action1); @@ -168,7 +168,7 @@ void Scene210::Action1::signal() {  		rot->setDelay(10);  		rot = BF_GLOBALS._scenePalette.addRotation(96, 111, 1);  		rot->setDelay(10); -		 +  		scene->setAction(&scene->_sequenceManager, this, 210, &scene->_object10, &scene->_object11,  			&scene->_object12, &scene->_object13, &scene->_object14, &scene->_object15, NULL);  		break; @@ -301,7 +301,7 @@ void Scene220::Action1::signal() {  		rot->setDelay(10);  		rot = BF_GLOBALS._scenePalette.addRotation(96, 111, 1);  		rot->setDelay(10); -		 +  		scene->setAction(&scene->_sequenceManager, this, 220, &scene->_object4, &scene->_object5,  			&scene->_object6, &scene->_object7, &scene->_object8, &scene->_object9, NULL);  		break; @@ -508,7 +508,7 @@ void Scene225::Action1::signal() {  		rot->setDelay(10);  		rot = BF_GLOBALS._scenePalette.addRotation(96, 111, 1);  		rot->setDelay(10); -		 +  		scene->setAction(&scene->_sequenceManager, this, 225, &scene->_object15, &scene->_object16,  			&scene->_object17, &scene->_object18, &scene->_object19, &scene->_object20, NULL);  		break; @@ -661,7 +661,7 @@ void Scene225::postInit(SceneObjectList *OwnerList) {  	_object11._frame = 1;  	_object11.changeZoom(100);  	_object11._numFrames = 2; -	 +  	_object12.postInit();  	_object12.setVisage(1225);  	_object12.setPosition(Common::Point(368, 35)); @@ -1007,14 +1007,14 @@ void Scene270::postInit(SceneObjectList *OwnerList) {  	BF_GLOBALS._player._moveDiff.x = 8;  	BF_GLOBALS._player.changeZoom(-1);  	BF_GLOBALS._player.disableControl(); -	 +  	switch (BF_GLOBALS._sceneManager._previousScene) {  	case 560:  		if (BF_GLOBALS._bookmark == bTalkedToGrannyAboutSkipsCard) {  			_field219A = 1;  			BF_GLOBALS._player._moveDiff.x = 5;  			_field386 = 0; -			 +  			_grandma.animate(ANIM_MODE_1, NULL);  			setAction(&_sequenceManager1, NULL, 2720, &BF_GLOBALS._player, &_grandma, NULL);  			BF_GLOBALS._bookmark = bLyleStoppedBy; @@ -1138,7 +1138,7 @@ void Scene270::signal() {  	case 2717:  		_sceneMode = 2718;  		_lyle.setFrame2(-1); -		setAction(&_sequenceManager1, this, 2718, &BF_GLOBALS._player, &_laura, &_skip,  +		setAction(&_sequenceManager1, this, 2718, &BF_GLOBALS._player, &_laura, &_skip,  			&_lyle, &_grandma, NULL);  		break;  	case 2718: @@ -1167,7 +1167,7 @@ void Scene270::signal() {  		break;  	default:  		break; -	}		 +	}  }  void Scene270::process(Event &event) { @@ -1374,7 +1374,7 @@ Scene271::Scene271() {  void Scene271::synchronize(Serializer &s) {  	PalettedScene::synchronize(s); -	 +  	s.syncAsSint16LE(_field796);  	s.syncAsSint16LE(_field2E16);  	s.syncAsSint16LE(_tempPos.x); @@ -1396,7 +1396,7 @@ void Scene271::postInit(SceneObjectList *OwnerList) {  	_stripManager.addSpeaker(&_gameTextSpeaker);  	_stripManager.addSpeaker(&_granTextSpeaker);  	_stripManager.addSpeaker(&_lyleTextSpeaker); -	 +  	_exit.setDetails(Rect(310, 115, 320, 167), 270, -1, -1, -1, 1, NULL);  	_tv.postInit(); @@ -1433,7 +1433,7 @@ void Scene271::postInit(SceneObjectList *OwnerList) {  	_item2.setDetails(3, 270, 24, 25, 26, 1);  	_item4.setDetails(2, 270, 30, 31, 32, 1);  	_item11.setDetails(Rect(0, 0, SCREEN_WIDTH, UI_INTERFACE_Y), 270, 0, 1, 2, 1, NULL); -	 +  	BF_GLOBALS._player.postInit();  	BF_GLOBALS._player._moveDiff.x = 8;  	BF_GLOBALS._player.changeZoom(-1); @@ -1477,7 +1477,7 @@ void Scene271::postInit(SceneObjectList *OwnerList) {  		_object11.setStrip(1);  		_object11._frame = 2;  		_object11.setPosition(Common::Point(35, 136)); -		 +  		_object6.postInit();  		_object6.hide(); @@ -1508,15 +1508,15 @@ void Scene271::postInit(SceneObjectList *OwnerList) {  		_object7.setVisage(277);  		_object7.setStrip(7);  		_object7.setPosition(Common::Point(48, 149)); -		 +  		BF_GLOBALS._walkRegions.disableRegion(6);  		BF_GLOBALS._walkRegions.disableRegion(14);  		BF_GLOBALS._walkRegions.disableRegion(19); -		 +  		_object12.postInit();  		_object12.setVisage(276);  		_object12.setPosition(Common::Point(129, 130)); -		 +  		_object2.postInit();  		_object2.setVisage(270);  		_object2.setStrip(3); @@ -1637,10 +1637,10 @@ void Scene271::signal() {  		BF_GLOBALS._player.enableControl();  		_field796 = 1;  		_field2E16 = 1; -		 +  		_object1.remove();  		_object11.remove(); -		 +  		BF_INVENTORY.setObjectScene(INV_LYLE_CARD, 1);  		break;  	case 2709: @@ -1754,7 +1754,7 @@ void Scene280::Action1::signal() {  		scene->_jake.setFrame(1);  		scene->_jake.animate(ANIM_MODE_8, NULL);  		scene->_jake._numFrames = 5; -		 +  		scene->_stripManager.start(2800, this);  		break;  	case 2: diff --git a/engines/tsage/blue_force/blueforce_scenes3.cpp b/engines/tsage/blue_force/blueforce_scenes3.cpp index 8955199286..22c831f531 100644 --- a/engines/tsage/blue_force/blueforce_scenes3.cpp +++ b/engines/tsage/blue_force/blueforce_scenes3.cpp @@ -945,7 +945,7 @@ void Scene315::Action1::signal() {  			T2_GLOBALS._uiElements.addScore(30);  			BF_INVENTORY.setObjectScene(INV_MUG_SHOT, 1);  			//HACK: This has to be checked wether or not it occurs in the original. -			//When the _sceneMode is set to 3169, the value desn't change.  +			//When the _sceneMode is set to 3169, the value desn't change.  			//If you show the forest rapsheet, it gives points (and again... and again...)  			scene->_sceneMode = 3154;  		} @@ -4509,12 +4509,12 @@ void Scene360::signal() {  		break;  	case 3607:  	case 3609: -		// Original game was only using at this place visage 1363.  +		// Original game was only using at this place visage 1363.  		// This workaround allow Harrison to keep his gun handy  		// when entering the romm (if required)  		if (! BF_GLOBALS.getFlag(gunDrawn))  			_harrison.setVisage(1363); -		else  +		else  			_harrison.setVisage(363);  		BF_GLOBALS._player.enableControl();  		break; @@ -5365,7 +5365,7 @@ bool Scene385::Jim::startAction(CursorType action, Event &event) {  	} else if (action < CURSOR_WALK)  		// Any other inventory item  		return false; -	else  +	else  		return NamedObject::startAction(action, event);  } diff --git a/engines/tsage/blue_force/blueforce_scenes4.cpp b/engines/tsage/blue_force/blueforce_scenes4.cpp index e966daf34e..a10f311791 100644 --- a/engines/tsage/blue_force/blueforce_scenes4.cpp +++ b/engines/tsage/blue_force/blueforce_scenes4.cpp @@ -1083,7 +1083,7 @@ void Scene415::postInit(SceneObjectList *OwnerList) {  	_animatedSeat.setStrip(1);  	_animatedSeat.setPosition(Common::Point(306, 116));  	_animatedSeat.fixPriority(80); -	 +  	_windowLever.setDetails(16, 415, 25, -1, 26, 1);  	_item7.setDetails(17, 415, 32, -1, 33, 1);  	_seatBelt.setDetails(14, 415, 29, -1, 30, 1); @@ -1271,7 +1271,7 @@ void Scene440::postInit(SceneObjectList *OwnerList) {  		BF_GLOBALS._player.setVisage(303);  		BF_GLOBALS._player.setPosition(Common::Point(187, 104)); -		 +  		_lyle.setPosition(Common::Point(135, 128));  		_lyle.show(); @@ -1291,7 +1291,7 @@ void Scene440::postInit(SceneObjectList *OwnerList) {  			_vechile.setVisage(580);  			_vechile.setStrip(2);  			_vechile.setFrame(3); -			 +  			BF_GLOBALS._player.setVisage(303);  		}  	} @@ -1310,7 +1310,7 @@ void Scene440::postInit(SceneObjectList *OwnerList) {  		_lyle.setPosition(Common::Point(143, 93));  		_lyle.setStrip(5);  		_lyle.fixPriority(90); -		 +  		_doorway.setFrame(_doorway.getFrameCount());  		_sceneMode = 4401;  		setAction(&_sequenceManager, this, 4401, &BF_GLOBALS._player, &_doorway, NULL); @@ -1375,7 +1375,7 @@ bool Scene450::Weasel::startAction(CursorType action, Event &event) {  		T2_GLOBALS._uiElements.addScore(30);  		scene->_sceneMode = 4505; -		scene->setAction(&scene->_sequenceManager, scene, 4505, &BF_GLOBALS._player, this,  +		scene->setAction(&scene->_sequenceManager, scene, 4505, &BF_GLOBALS._player, this,  			&scene->_counterDoor, &scene->_object2, NULL);  		return true;  	default: @@ -1427,7 +1427,7 @@ bool Scene450::Manager::startAction(CursorType action, Event &event) {  		if (BF_GLOBALS.getFlag(takenWeasel) && !BF_GLOBALS.getFlag(gotTrailer450)) {  			BF_GLOBALS.setFlag(gotTrailer450);  			scene->_sceneMode = 4517; -			scene->setAction(&scene->_sequenceManager, scene, 4517, &BF_GLOBALS._player, this,  +			scene->setAction(&scene->_sequenceManager, scene, 4517, &BF_GLOBALS._player, this,  				&scene->_door, NULL);  		} else {  			animate(ANIM_MODE_8, 1, NULL); @@ -1485,11 +1485,11 @@ bool Scene450::Manager::startAction(CursorType action, Event &event) {  		} else {  			animate(ANIM_MODE_8, 1, NULL);  			BF_GLOBALS._player.disableControl(); -			 +  			if (!BF_GLOBALS.getFlag(showEugeneID))  				T2_GLOBALS._uiElements.addScore(30);  			BF_GLOBALS.setFlag(showEugeneID); -			 +  			if ((BF_GLOBALS.getFlag(showRapEugene) || BF_GLOBALS.getFlag(showEugeneNapkin)) &&  					!BF_GLOBALS.getFlag(fMgrCallsWeasel)) {  				T2_GLOBALS._uiElements.addScore(30); diff --git a/engines/tsage/blue_force/blueforce_scenes5.cpp b/engines/tsage/blue_force/blueforce_scenes5.cpp index 692e142f55..abadc4300a 100644 --- a/engines/tsage/blue_force/blueforce_scenes5.cpp +++ b/engines/tsage/blue_force/blueforce_scenes5.cpp @@ -60,7 +60,7 @@ bool Scene550::Lyle::startAction(CursorType action, Event &event) {  	switch (action) {  	case CURSOR_TALK: -		if ((BF_INVENTORY.getObjectScene(INV_SCHEDULE) == 1) ||  +		if ((BF_INVENTORY.getObjectScene(INV_SCHEDULE) == 1) ||  				(BF_INVENTORY.getObjectScene(INV_9MM_BULLETS) == 1)) {  			if ((BF_INVENTORY.getObjectScene(INV_SCHEDULE) == 1) &&  					(BF_INVENTORY.getObjectScene(INV_9MM_BULLETS) == 1)) { @@ -132,7 +132,7 @@ bool Scene550::Vechile::startAction(CursorType action, Event &event) {  			BF_GLOBALS._player.disableControl();  			scene->_sceneMode = 2;  			scene->setAction(&scene->_sequenceManager, scene, 5501, &BF_GLOBALS._player, NULL); -		} else if ((BF_INVENTORY.getObjectScene(INV_SCHEDULE) == 1) ||  +		} else if ((BF_INVENTORY.getObjectScene(INV_SCHEDULE) == 1) ||  					(BF_INVENTORY.getObjectScene(INV_9MM_BULLETS) == 1)) {  			if (BF_INVENTORY.getObjectScene(INV_9MM_BULLETS) == 1) {  				scene->_sceneMode = 5501; @@ -164,11 +164,11 @@ void Scene550::postInit(SceneObjectList *OwnerList) {  		_sceneMode = 1;  		signal();  		return; -	}  +	}  	SceneExt::postInit();  	loadScene(550); -	 +  	_stripManager.addSpeaker(&_gameTextSpeaker);  	_stripManager.addSpeaker(&_lyleHatSpeaker);  	_stripManager.addSpeaker(&_jakeJacketSpeaker); @@ -216,7 +216,7 @@ void Scene550::postInit(SceneObjectList *OwnerList) {  		if (BF_GLOBALS.getFlag(onDuty)) {  			_vechile.setVisage(301);  			_vechile.setStrip(1); -			 +  			BF_GLOBALS._player.setVisage(304);  		} else {  			_vechile.setVisage(580); @@ -224,7 +224,7 @@ void Scene550::postInit(SceneObjectList *OwnerList) {  			_vechile.setFrame(2);  			BF_GLOBALS._player.setVisage(303); -		}		 +		}  	}  	BF_GLOBALS._sceneItems.push_back(&_vechile); @@ -299,7 +299,7 @@ void Scene551::Action2::signal() {  		BF_GLOBALS._walkRegions.enableRegion(18);  		BF_GLOBALS._walkRegions.enableRegion(4);  		scene->_field1CD2 = 1; -		 +  		scene->_harrison.setObjectWrapper(new SceneObjectWrapper());  		scene->_harrison.animate(ANIM_MODE_1, NULL); @@ -506,7 +506,7 @@ void Scene551::TrunkInset::remove() {  	BF_GLOBALS._player.disableControl();  	scene->_sceneMode = 0; -	scene->setAction(&scene->_sequenceManager, scene, 5516, &scene->_harrison,  +	scene->setAction(&scene->_sequenceManager, scene, 5516, &scene->_harrison,  		&scene->_patrolCarTrunk, NULL);  	FocusObject::remove(); @@ -711,7 +711,7 @@ void Scene551::postInit(SceneObjectList *OwnerList) {  		_object12.show();  		_object12.setDetails(550, 25, -1, 26, 1, (SceneItem *)NULL);  		BF_GLOBALS._sceneItems.push_front(&_object12); -		 +  		_harrison.postInit();  		_harrison.setVisage(304);  		_harrison.setPosition(Common::Point(67, 102)); @@ -1076,7 +1076,7 @@ void Scene560::SafeInset::postInit(SceneObjectList *OwnerList) {  		_item4.setDetails(Rect(143, 86, 159, 102), 560, 49, 50, -1, 1, NULL);  		_item5.setDetails(Rect(159, 86, 175, 102), 560, 49, 50, -1, 1, NULL);  		_item6.setDetails(Rect(175, 86, 191, 102), 560, 49, 50, -1, 1, NULL); -		 +  		BF_GLOBALS._sceneItems.remove(&_item1);  		BF_GLOBALS._sceneItems.remove(&_item2);  		BF_GLOBALS._sceneItems.remove(&_item3); @@ -1114,9 +1114,9 @@ void Scene560::SafeInset::postInit(SceneObjectList *OwnerList) {  		_digit0.setStrip(3);  		_digit0.setPosition(Common::Point(183, 94));  		_digit0.fixPriority(252); -		 +  		int amount = (BF_GLOBALS._safeCombination != 0) ? BF_GLOBALS._safeCombination : 1000; -		 +  		// Get digit 0 portion  		int remainder = amount % 10;  		amount /= 10; @@ -1135,7 +1135,7 @@ void Scene560::SafeInset::postInit(SceneObjectList *OwnerList) {  void Scene560::SafeInset::remove() {  	Scene560 *scene = (Scene560 *)BF_GLOBALS._sceneManager._scene; -	 +  	_item1.remove();  	_item2.remove();  	_item3.remove(); @@ -1145,7 +1145,7 @@ void Scene560::SafeInset::remove() {  	_digit2.remove();  	_digit1.remove();  	_digit0.remove(); -	 +  	scene->_nickel.remove();  	if (BF_GLOBALS._events.getCursor() == CURSOR_USE) { @@ -1293,7 +1293,7 @@ bool Scene560::SafeInset::Item::startAction(CursorType action, Event &event) {  		default:  			break;  		} -		 +  		scene->_safeInset.signal();  		scene->_sound1.play(75);  		return true; @@ -1345,7 +1345,7 @@ bool Scene560::BoxInset::Item1::startAction(CursorType action, Event &event) {  		scene->_safeInset.setPosition(Common::Point(160, 141));  		scene->_safeInset.fixPriority(251);  		scene->_safeInset.setDetails(560, 45, 46, -1); -		 +  		scene->_sceneMode = 3;  		scene->_boxInset.remove(); @@ -1414,7 +1414,7 @@ void Scene560::postInit(SceneObjectList *OwnerList) {  	_deskChair.setPosition(Common::Point(81, 149));  	_deskChair.fixPriority(151);  	_deskChair.changeZoom(81); -	 +  	if (BF_GLOBALS._sceneManager._previousScene == 570) {  		// Returning from using computer  		BF_GLOBALS._events.setCursor(CURSOR_USE); @@ -1448,7 +1448,7 @@ void Scene560::postInit(SceneObjectList *OwnerList) {  		BF_GLOBALS._player._moveDiff.x = 11;  		BF_GLOBALS._player.changeZoom(-1);  		BF_GLOBALS._player.disableControl(); -		 +  		_sceneMode = 10;  		ADD_MOVER(BF_GLOBALS._player, 85, 115);  	} @@ -1516,7 +1516,7 @@ void Scene560::signal() {  				T2_GLOBALS._uiElements.addScore(10);  				BF_GLOBALS.setFlag(fGotPointsForPunch);  			} -			 +  			_boxInset.postInit();  			_boxInset.setVisage(560);  			_boxInset.setStrip(2); @@ -1605,7 +1605,7 @@ void Scene570::PasswordEntry::postInit(SceneObjectList *OwnerList) {  void Scene570::PasswordEntry::process(Event &event) {  	Scene570 *scene = (Scene570 *)BF_GLOBALS._sceneManager._scene;  	bool entryChanged = false; -	 +  	switch (event.eventType) {  	case EVENT_KEYPRESS: {  		int key = toupper(event.kbd.ascii); @@ -1648,7 +1648,7 @@ void Scene570::PasswordEntry::process(Event &event) {  		_entryText.setPosition(Common::Point(213, 40));  		_entryText.fixPriority(255);  		_entryText.setup(_entryBuffer); -		 +  		// Pad entered text with spaces to make up the allowed width and then display  		Common::String msg = _entryBuffer;  		while (msg.size() < 10) @@ -1658,7 +1658,7 @@ void Scene570::PasswordEntry::process(Event &event) {  }  void Scene570::PasswordEntry::checkPassword() { -	// Check if the password is correctly entered as 'JACKIE' or, as a nod to the  +	// Check if the password is correctly entered as 'JACKIE' or, as a nod to the  	// reimplementation in ScummVM, as the project name.  	Scene570 *scene = (Scene570 *)BF_GLOBALS._sceneManager._scene; @@ -1794,7 +1794,7 @@ void Scene570::Icon::remove() {  }  bool Scene570::Icon::startAction(CursorType action, Event &event) { -	Scene570 *scene = (Scene570 *)BF_GLOBALS._sceneManager._scene;		 +	Scene570 *scene = (Scene570 *)BF_GLOBALS._sceneManager._scene;  	switch (action) {  	case CURSOR_LOOK: @@ -1907,7 +1907,7 @@ bool Scene570::Icon::startAction(CursorType action, Event &event) {  }  void Scene570::Icon::setDetails(int iconId, int folderId, int parentFolderId, int unused, const Common::String &msg) { -	Scene570 *scene = (Scene570 *)BF_GLOBALS._sceneManager._scene;	 +	Scene570 *scene = (Scene570 *)BF_GLOBALS._sceneManager._scene;  	NamedObject::postInit();  	_iconId = iconId; @@ -1929,7 +1929,7 @@ void Scene570::Icon::setDetails(int iconId, int folderId, int parentFolderId, in  /*--------------------------------------------------------------------------*/  bool Scene570::PowerSwitch::startAction(CursorType action, Event &event) { -	Scene570 *scene = (Scene570 *)BF_GLOBALS._sceneManager._scene;		 +	Scene570 *scene = (Scene570 *)BF_GLOBALS._sceneManager._scene;  	switch (action) {  	case CURSOR_USE: @@ -1972,7 +1972,7 @@ bool Scene570::PrinterIcon::startAction(CursorType action, Event &event) {  }  void Scene570::Object3::remove() { -	Scene570 *scene = (Scene570 *)BF_GLOBALS._sceneManager._scene;		 +	Scene570 *scene = (Scene570 *)BF_GLOBALS._sceneManager._scene;  	scene->_object4._flag = 0;  	scene->_printerIcon.remove(); @@ -1998,7 +1998,7 @@ void Scene570::Object3::remove() {  /*--------------------------------------------------------------------------*/  bool Scene570::FloppyDrive::startAction(CursorType action, Event &event) { -	Scene570 *scene = (Scene570 *)BF_GLOBALS._sceneManager._scene;		 +	Scene570 *scene = (Scene570 *)BF_GLOBALS._sceneManager._scene;  	switch (action) {  	case CURSOR_USE: @@ -2326,7 +2326,7 @@ bool Scene590::Skip::startAction(CursorType action, Event &event) {  		} else {  			scene->_stripNumber = !scene->_field17DC ? 5901 : 5902;  		} -		 +  		scene->setAction(&scene->_action1);  		scene->_field17DC = 1;  		return true; @@ -2404,7 +2404,7 @@ void Scene590::Action2::signal() {  	case 4:  		scene->_skip.setStrip(1);  		scene->_skip.animate(ANIM_MODE_1, NULL); -		 +  		BF_GLOBALS._player.setVisage(368);  		BF_GLOBALS._player.setStrip(7);  		BF_GLOBALS._player.setPosition(Common::Point(238, 131)); @@ -2456,7 +2456,7 @@ void Scene590::postInit(SceneObjectList *OwnerList) {  	_stripManager.addSpeaker(&_skipSpeaker);  	_stripManager.addSpeaker(&_lauraSpeaker);  	_stripManager.addSpeaker(&_jakeJacketSpeaker); -	 +  	if (BF_GLOBALS.getFlag(onDuty)) {  		BF_GLOBALS._player.setVisage(361);  		BF_GLOBALS._player._moveDiff = Common::Point(6, 2); @@ -2488,7 +2488,7 @@ void Scene590::postInit(SceneObjectList *OwnerList) {  	_item10.setDetails(13, 590, 9, -1, 21, 1);  	_item11.setDetails(15, 590, 10, -1, 22, 1);  	_item12.setDetails(17, 590, 11, -1, 23, 1); -	 +  	BF_GLOBALS._player.disableControl();  	_sceneMode = 0;  	setAction(&_sequenceManager, this, 5900, &BF_GLOBALS._player, NULL); diff --git a/engines/tsage/blue_force/blueforce_scenes5.h b/engines/tsage/blue_force/blueforce_scenes5.h index 76bf4cdbc3..73d323fc54 100644 --- a/engines/tsage/blue_force/blueforce_scenes5.h +++ b/engines/tsage/blue_force/blueforce_scenes5.h @@ -228,7 +228,7 @@ public:  	NamedHotspot _chair, _lamp, _item4, _trophy, _watercolours, _fileCabinets;  	NamedHotspot _certificate, _bookcase, _desk, _carpet, _item12, _office;  	ASound _sound1; -	bool _field380;  +	bool _field380;  	bool _field11EA;  	Common::Point _destPosition; diff --git a/engines/tsage/blue_force/blueforce_scenes6.cpp b/engines/tsage/blue_force/blueforce_scenes6.cpp index e5e7c71bef..9467df7917 100644 --- a/engines/tsage/blue_force/blueforce_scenes6.cpp +++ b/engines/tsage/blue_force/blueforce_scenes6.cpp @@ -49,7 +49,7 @@ void Scene600::Action1::signal() {  		break;  	case 2:  		scene->_sound1.play(59); -		setAction(&scene->_sequenceManager, this, 600, &scene->_object2, &scene->_ryan,  +		setAction(&scene->_sequenceManager, this, 600, &scene->_object2, &scene->_ryan,  			&BF_GLOBALS._player, &scene->_skidMarks, NULL);  		break;  	case 3: @@ -149,7 +149,7 @@ void Scene600::remove() {  void Scene620::postInit(SceneObjectList *OwnerList) {  	SceneExt::postInit();  	loadScene(999); -	 +  	BF_GLOBALS._player.postInit();  	BF_GLOBALS._player.disableControl();  	BF_GLOBALS._player.setVisage(621); @@ -176,14 +176,14 @@ void Scene620::signal() {  	case 13:  	case 16:  	case 19: -		addFader((const byte *)&black, 2, this);	 +		addFader((const byte *)&black, 2, this);  		break;  	case 2:  		BF_GLOBALS._player.remove();  		_object1.postInit();  		_object1.setVisage(622);  		_object1.setPosition(Common::Point(101, 41)); -		add2Faders((const byte *)&black, 2, 622, this);	 +		add2Faders((const byte *)&black, 2, 622, this);  		break;  	case 5:  		_object1.remove(); @@ -441,7 +441,7 @@ void Scene690::postInit(SceneObjectList *OwnerList) {  		BF_GLOBALS._dayNumber = 1;  	_stripManager.addSpeaker(&_jakeSpeaker); -	 +  	_object1.postInit();  	_object1.setVisage(690);  	_object1.setStrip2(2); diff --git a/engines/tsage/blue_force/blueforce_scenes8.cpp b/engines/tsage/blue_force/blueforce_scenes8.cpp index ceee748374..5a60cd7c5e 100644 --- a/engines/tsage/blue_force/blueforce_scenes8.cpp +++ b/engines/tsage/blue_force/blueforce_scenes8.cpp @@ -434,7 +434,7 @@ void Scene810::Action2::signal() {  		scene->_lyle.setVisage(813);  		scene->_lyle.setStrip(2);  		scene->_lyle.setFrame(1); -		 +  		ADD_PLAYER_MOVER(84, 113);  		break;  	case 5: @@ -611,7 +611,7 @@ bool Scene810::Lyle::startAction(CursorType action, Event &event) {  	default:  		return NamedObjectExt::startAction(action, event);  	} -}		 +}  bool Scene810::Chair::startAction(CursorType action, Event &event) {  	switch (action) { @@ -709,7 +709,7 @@ bool Scene810::Object5::startAction(CursorType action, Event &event) {  	case CURSOR_USE: {  		scene->_sceneMode = 8195;  		BF_GLOBALS._player.disableControl(); -		 +  		PlayerMover *mover = new PlayerMover();  		Common::Point destPos(67, 111);  		BF_GLOBALS._player.addMover(mover, &destPos, scene); @@ -804,7 +804,7 @@ bool Scene810::FaxMachine::startAction(CursorType action, Event &event) {  			scene->_sceneMode = 811;  			if (BF_GLOBALS._sceneObjects->contains(&scene->_lyle)) { -				scene->setAction(&scene->_sequenceManager1, scene, BF_GLOBALS.getFlag(onDuty) ? 8108 : 8105,  +				scene->setAction(&scene->_sequenceManager1, scene, BF_GLOBALS.getFlag(onDuty) ? 8108 : 8105,  					&BF_GLOBALS._player, &scene->_object6, NULL);  			} else {  				scene->setAction(&scene->_sequenceManager1, scene, 8111, &BF_GLOBALS._player, @@ -1058,12 +1058,12 @@ void Scene810::postInit(SceneObjectList *OwnerList) {  	case 820:  		BF_GLOBALS._player.setStrip(7);  		BF_GLOBALS._player.setPosition(Common::Point(278, 116)); -		 +  		_lyle.setVisage(845);  		_lyle.setPosition(Common::Point(340, 175));  		_lyle.setObjectWrapper(new SceneObjectWrapper());  		_lyle.animate(ANIM_MODE_1, NULL); -		 +  		_chair.show();  		BF_GLOBALS._player.disableControl(); @@ -1121,7 +1121,7 @@ void Scene810::postInit(SceneObjectList *OwnerList) {  	_item12._sceneRegionId = 8;  	BF_GLOBALS._sceneItems.push_back(&_item12); -	BF_GLOBALS._sceneItems.addItems(&_microficheReader, &_map, &_window, &_bookcase, &_garbageCan,  +	BF_GLOBALS._sceneItems.addItems(&_microficheReader, &_map, &_window, &_bookcase, &_garbageCan,  		&_fileCabinets, &_coffeeMaker, &_shelves, &_background, NULL);  	_background.setBounds(Rect(0, 0, SCREEN_WIDTH, UI_INTERFACE_Y));  } @@ -1276,7 +1276,7 @@ void Scene810::dispatch() {  		_lyle.updateAngle(BF_GLOBALS._player._position);  	} -	if (BF_GLOBALS._sceneObjects->contains(&_faxMachineInset) && (BF_GLOBALS._player._position.x != 67) &&  +	if (BF_GLOBALS._sceneObjects->contains(&_faxMachineInset) && (BF_GLOBALS._player._position.x != 67) &&  			(BF_GLOBALS._player._position.y != 111)) {  		_faxMachineInset.remove();  	} @@ -1341,7 +1341,7 @@ bool Scene820::PowerButton::startAction(CursorType action, Event &event) {  			BF_GLOBALS._scenePalette.loadPalette(821);  			BF_GLOBALS._scenePalette.refresh(); -			SceneItem::display(820, scene->_pageNumber, SET_WIDTH, 240, SET_X, 41, SET_Y, 0,  +			SceneItem::display(820, scene->_pageNumber, SET_WIDTH, 240, SET_X, 41, SET_Y, 0,  				SET_FONT, 50, SET_FG_COLOR, 18, SET_EXT_BGCOLOR, 12, SET_KEEP_ONSCREEN, true, LIST_END);  		} else {  			BF_GLOBALS._scenePalette.loadPalette(820); @@ -1388,7 +1388,7 @@ bool Scene820::BackButton::startAction(CursorType action, Event &event) {  			scene->_object5.hide();  		} -		SceneItem::display(820, scene->_pageNumber, SET_WIDTH, 240, SET_X, 41, SET_Y, 0,  +		SceneItem::display(820, scene->_pageNumber, SET_WIDTH, 240, SET_X, 41, SET_Y, 0,  			SET_FONT, 50, SET_FG_COLOR, 18, SET_EXT_BGCOLOR, 12, SET_KEEP_ONSCREEN, true, LIST_END);  		return true;  	default: @@ -1419,7 +1419,7 @@ bool Scene820::ForwardButton::startAction(CursorType action, Event &event) {  		if (scene->_pageNumber < 4)  			++scene->_pageNumber; -		SceneItem::display(820, scene->_pageNumber, SET_WIDTH, 240, SET_X, 41, SET_Y, 0,  +		SceneItem::display(820, scene->_pageNumber, SET_WIDTH, 240, SET_X, 41, SET_Y, 0,  			SET_FONT, 50, SET_FG_COLOR, 18, SET_EXT_BGCOLOR, 12, SET_KEEP_ONSCREEN, true, LIST_END);  		if (scene->_pageNumber == 4) { @@ -1447,7 +1447,7 @@ void Scene820::synchronize(Serializer &s) {  void Scene820::postInit(SceneObjectList *OwnerList) {  	SceneExt::postInit();  	loadScene(820); -	 +  	_stripManager.addSpeaker(&_gameTextSpeaker);  	_powerButton.postInit(); @@ -3115,7 +3115,7 @@ void Scene870::postInit(SceneObjectList *OwnerList) {  			_lyle.setPosition(Common::Point(156, 148));  			_lyle.fixPriority(149);  		} -	 +  		if ((BF_INVENTORY.getObjectScene(INV_HANDCUFFS) != 1) &&  				(BF_INVENTORY.getObjectScene(INV_GRENADES) == 355)) {  			_object4.postInit(); @@ -3135,7 +3135,7 @@ void Scene870::postInit(SceneObjectList *OwnerList) {  		}  		break;  	} -	 +  	_boat.setDetails(7, 870, 3, 4, 5, 1);  	_crate.setDetails(14, 870, 12, 13, 14, 1);  	_water.setDetails(5, 870, 24, 25, 26, 1); @@ -3393,7 +3393,7 @@ void Scene880::postInit(SceneObjectList *OwnerList) {  			_object4.setFrame2(_object4.getFrameCount());  			_object4.fixPriority(160);  			_object4.setPosition(Common::Point(255, 148)); -			 +  			_seqNumber = 8816;  		} else if (BF_GLOBALS.getFlag(fBlowUpGoon)) {  			_object4.setStrip(7); @@ -3405,7 +3405,7 @@ void Scene880::postInit(SceneObjectList *OwnerList) {  		} else {  			_object4.setStrip(2);  			_object4.setPosition(Common::Point(258, 147)); -		 +  			_object3.postInit();  			_object3.setVisage(871);  			_object3.setStrip(4); @@ -3600,7 +3600,7 @@ void Scene880::handleAction(Action *action) {  		action->_owner = NULL;  	}  } -	 +  void Scene880::dispatch() {  	SceneExt::dispatch(); diff --git a/engines/tsage/blue_force/blueforce_scenes9.cpp b/engines/tsage/blue_force/blueforce_scenes9.cpp index f5705eb471..a303576928 100644 --- a/engines/tsage/blue_force/blueforce_scenes9.cpp +++ b/engines/tsage/blue_force/blueforce_scenes9.cpp @@ -386,7 +386,7 @@ void Scene900::Action3::signal() {  		break;  	default:  		break; -	}  +	}  }  void Scene900::Action4::signal() { @@ -540,7 +540,7 @@ void Scene900::postInit(SceneObjectList *OwnerList) {  				_lyle.setDetails(900, 19, 20, 21, ANIM_MODE_1, (SceneItem *)NULL);  				_lyle.animate(ANIM_MODE_1, NULL);  				_lyle.setObjectWrapper(new SceneObjectWrapper()); -			}  +			}  			_sceneMode = 9000;  			setAction(&_sequenceManager1, this, 9000, &BF_GLOBALS._player, NULL); @@ -2125,7 +2125,7 @@ void Scene910::postInit(SceneObjectList *OwnerList) {  		_lyle.setFrame(3);  		_lyle._field90 = 1;  		_lyle.setDetails(910, 69, 70 ,71 , 5, &_item4); -	 +  		BF_GLOBALS._walkRegions.disableRegion(15);  		BF_GLOBALS._walkRegions.disableRegion(16);  		BF_GLOBALS._walkRegions.disableRegion(14); diff --git a/engines/tsage/core.cpp b/engines/tsage/core.cpp index c2ce426052..0a8c4ef1b4 100644 --- a/engines/tsage/core.cpp +++ b/engines/tsage/core.cpp @@ -1354,13 +1354,15 @@ void ScenePalette::setEntry(int index, uint r, uint g, uint b) {   * @param g			G component   * @param b			B component   * @param threshold	Closeness threshold. + * @param start		Starting index + * @param count		Number of indexes to scan   * @remarks	A threshold may be provided to specify how close the matching color must be   */ -uint8 ScenePalette::indexOf(uint r, uint g, uint b, int threshold) { +uint8 ScenePalette::indexOf(uint r, uint g, uint b, int threshold, int start, int count) {  	int palIndex = -1;  	byte *palData = &_palette[0]; -	for (int i = 0; i < 256; ++i) { +	for (int i = start; i < (start + count); ++i) {  		byte ir = *palData++;  		byte ig = *palData++;  		byte ib = *palData++; diff --git a/engines/tsage/core.h b/engines/tsage/core.h index 45bb3506d5..60a7930eab 100644 --- a/engines/tsage/core.h +++ b/engines/tsage/core.h @@ -378,7 +378,7 @@ public:  	void setPalette(int index, int count);  	void getEntry(int index, uint *r, uint *g, uint *b);  	void setEntry(int index, uint r, uint g, uint b); -	uint8 indexOf(uint r, uint g, uint b, int threshold = 0xffff); +	uint8 indexOf(uint r, uint g, uint b, int threshold = 0xffff, int start = 0, int count = 256);  	void getPalette(int start = 0, int count = 256);  	void signalListeners();  	void clearListeners(); diff --git a/engines/tsage/debugger.cpp b/engines/tsage/debugger.cpp index f7ba5c20f2..82645f2d62 100644 --- a/engines/tsage/debugger.cpp +++ b/engines/tsage/debugger.cpp @@ -305,7 +305,7 @@ bool Debugger::Cmd_Hotspots(int argc, const char **argv) {  			if (ri != g_globals->_sceneRegions.end()) {  				// Fill out the areas defined by the region  				Region &r = *ri; -			 +  				for (int y = r._bounds.top; y < r._bounds.bottom; ++y) {  					LineSliceSet set = r.getLineSlices(y); @@ -615,7 +615,7 @@ bool BlueForceDebugger::Cmd_MoveObject(int argc, const char **argv) {  	if ((objNum > 0) && (objNum < 65))  		BF_INVENTORY.setObjectScene(objNum, sceneNum); -	else  +	else  		DebugPrintf("Invalid object Id %s\n", argv[1]);  	return true; @@ -702,7 +702,7 @@ bool Ringworld2Debugger::Cmd_MoveObject(int argc, const char **argv) {  	if ((objNum > 0) && (objNum < 53))  		R2_INVENTORY.setObjectScene(objNum, sceneNum); -	else  +	else  		DebugPrintf("Invalid object Id %s\n", argv[1]);  	return true; diff --git a/engines/tsage/events.h b/engines/tsage/events.h index cf2d1a34ed..475db47315 100644 --- a/engines/tsage/events.h +++ b/engines/tsage/events.h @@ -86,25 +86,25 @@ enum CursorType {  	INV_CARAVAN_KEY = 67, BF_LAST_INVENT = 68,  	// Ringworld 2 objects -	R2_OPTO_DISK = 1, R2_READER = 2, R2_NEGATOR_GUN = 3, R2_STEPPING_DISKS = 4,  -	R2_ATTRACTOR_UNIT = 5, R2_SENSOR_PROBE = 6, R2_SONIC_STUNNER = 7,  -	R2_CABLE_HARNESS = 8, R2_COM_SCANNER = 9, R2_SPENT_POWER_CAPSULE = 10,  -	R2_CHARGED_POWER_CAPSULE = 11, R2_AEROSOL = 12, R2_REMOTE_CONTROL = 13,  -	R2_OPTICAL_FIBRE = 14, R2_CLAMP = 15, R2_ATTRACTOR_CABLE_HARNESS = 16,  -	R2_FUEL_CELL = 17, R2_GYROSCOPE = 18, R2_AIRBAG = 19, R2_REBREATHER_TANK = 20,  +	R2_OPTO_DISK = 1, R2_READER = 2, R2_NEGATOR_GUN = 3, R2_STEPPING_DISKS = 4, +	R2_ATTRACTOR_UNIT = 5, R2_SENSOR_PROBE = 6, R2_SONIC_STUNNER = 7, +	R2_CABLE_HARNESS = 8, R2_COM_SCANNER = 9, R2_SPENT_POWER_CAPSULE = 10, +	R2_CHARGED_POWER_CAPSULE = 11, R2_AEROSOL = 12, R2_REMOTE_CONTROL = 13, +	R2_OPTICAL_FIBRE = 14, R2_CLAMP = 15, R2_ATTRACTOR_CABLE_HARNESS = 16, +	R2_FUEL_CELL = 17, R2_GYROSCOPE = 18, R2_AIRBAG = 19, R2_REBREATHER_TANK = 20,  	R2_RESERVE_REBREATHER_TANK = 21, R2_GUIDANCE_MODULE = 22, R2_THRUSTER_VALVE = 23, -	R2_BALLOON_BACKPACK = 24, R2_RADAR_MECHANISM = 25, R2_JOYSTICK = 26,  -	R2_IGNITOR = 27, R2_DIAGNOSTICS_DISPLAY = 28, R2_GLASS_DOME = 29, R2_WICK_LAMP = 30,  -	R2_SCRITH_KEY = 31, R2_TANNER_MASK = 32, R2_PURE_GRAIN_ALCOHOL = 33, R2_SAPPHIRE_BLUE = 34,  -	R2_ANCIENT_SCROLLS = 35, R2_FLUTE = 36, R2_GUNPOWDER = 37, R2_NONAME = 38,  +	R2_BALLOON_BACKPACK = 24, R2_RADAR_MECHANISM = 25, R2_JOYSTICK = 26, +	R2_IGNITOR = 27, R2_DIAGNOSTICS_DISPLAY = 28, R2_GLASS_DOME = 29, R2_WICK_LAMP = 30, +	R2_SCRITH_KEY = 31, R2_TANNER_MASK = 32, R2_PURE_GRAIN_ALCOHOL = 33, R2_SAPPHIRE_BLUE = 34, +	R2_ANCIENT_SCROLLS = 35, R2_FLUTE = 36, R2_GUNPOWDER = 37, R2_NONAME = 38,  	R2_COM_SCANNER_2 = 39, R2_SUPERCONDUCTOR_WIRE = 40, R2_PILLOW = 41, R2_FOOD_TRAY = 42, -	R2_LASER_HACKSAW = 43, R2_PHOTON_STUNNER = 44, R2_BATTERY = 45, R2_SOAKED_FACEMASK = 46,  -	R2_LIGHT_BULB = 47, R2_ALCOHOL_LAMP = 48, R2_ALCOHOL_LAMP_2 = 49, R2_ALCOHOL_LAMP_3 = 50,  +	R2_LASER_HACKSAW = 43, R2_PHOTON_STUNNER = 44, R2_BATTERY = 45, R2_SOAKED_FACEMASK = 46, +	R2_LIGHT_BULB = 47, R2_ALCOHOL_LAMP = 48, R2_ALCOHOL_LAMP_2 = 49, R2_ALCOHOL_LAMP_3 = 50,  	R2_BROKEN_DISPLAY = 51, R2_TOOLBOX = 52, R2_LAST_INVENT = 53,  	// Ringworld 2 cursors -	R2CURSORS_START = 0x8000, EXITCURSOR_N  = 0x8007,  EXITCURSOR_S  = 0x8008, EXITCURSOR_W = 0x8009,  -	EXITCURSOR_E = 0x800A, EXITCURSOR_LEFT_HAND = 0x800B, CURSOR_INVALID = 0x800C,  +	R2CURSORS_START = 0x8000, EXITCURSOR_N  = 0x8007,  EXITCURSOR_S  = 0x8008, EXITCURSOR_W = 0x8009, +	EXITCURSOR_E = 0x800A, EXITCURSOR_LEFT_HAND = 0x800B, CURSOR_INVALID = 0x800C,  	EXITCURSOR_NE = 0x800D, EXITCURSOR_SE = 0x800E, EXITCURSOR_SW = 0x800F, EXITCURSOR_NW = 0x8010,  	SHADECURSOR_UP = 0x8011, SHADECURSOR_DOWN = 0x8012, SHADECURSOR_HAND = 0x8013,  	R2_CURSOR_20 = 0x8014, R2_CURSOR_21 = 0x8015, R2_CURSOR_22 = 0x8016, R2_CURSOR_23 = 0x8017, diff --git a/engines/tsage/globals.cpp b/engines/tsage/globals.cpp index b4c3127ea8..59eb59b194 100644 --- a/engines/tsage/globals.cpp +++ b/engines/tsage/globals.cpp @@ -380,6 +380,7 @@ void Ringworld2Globals::reset() {  	_v5589E.set(0, 0, 0, 0);  	_v558B6.set(0, 0, 0, 0);  	_v558C2 = 0; +	_animationCtr = 0;  	_v5657C = 0;  	_v565E1 = 0;  	_v565E3 = 0; @@ -493,6 +494,7 @@ void Ringworld2Globals::synchronize(Serializer &s) {  	_v558B6.synchronize(s);  	s.syncAsSint16LE(_v558C2); +	s.syncAsSint16LE(_animationCtr);  	s.syncAsSint16LE(_v5657C);  	s.syncAsSint16LE(_v565E1);  	s.syncAsSint16LE(_v565E3); diff --git a/engines/tsage/globals.h b/engines/tsage/globals.h index d80e4d9859..45226c921b 100644 --- a/engines/tsage/globals.h +++ b/engines/tsage/globals.h @@ -260,6 +260,7 @@ public:  	Rect _v5589E;  	Rect _v558B6;  	int _v558C2; +	int _animationCtr;  	int _v565E1;  	int _v565E3;  	int _v565E5; diff --git a/engines/tsage/graphics.cpp b/engines/tsage/graphics.cpp index acb615abae..5ddc7b6a1a 100644 --- a/engines/tsage/graphics.cpp +++ b/engines/tsage/graphics.cpp @@ -266,7 +266,7 @@ void GfxSurface::updateScreen() {  			continue;  		const byte *srcP = (const byte *)_customSurface->getBasePtr(r.left, r.top); -		g_system->copyRectToScreen(srcP, _customSurface->pitch, r.left, r.top,  +		g_system->copyRectToScreen(srcP, _customSurface->pitch, r.left, r.top,  			r.width(), r.height());  	} @@ -287,7 +287,7 @@ void GfxSurface::addDirtyRect(const Rect &r) {  		r2.translate(_bounds.left, _bounds.top);  		// Add to the dirty rect list -		_dirtyRects.push_back(Rect(r2.left, r2.top,  +		_dirtyRects.push_back(Rect(r2.left, r2.top,  		MIN(r2.right + 1, SCREEN_WIDTH), MIN(r2.bottom + 1, SCREEN_HEIGHT)));  	}  } @@ -1194,7 +1194,7 @@ void GfxDialog::setPalette() {  		g_globals->_scenePalette.setPalette(g_globals->_fontColors.background, 1);  		g_globals->_scenePalette.setPalette(g_globals->_fontColors.foreground, 1);  		g_globals->_scenePalette.setEntry(255, 0xff, 0xff, 0xff); -		g_globals->_scenePalette.setPalette(255, 1);	 +		g_globals->_scenePalette.setPalette(255, 1);  	} else {  		g_globals->_scenePalette.loadPalette(0);  		g_globals->_scenePalette.setPalette(0, 1); diff --git a/engines/tsage/resources.cpp b/engines/tsage/resources.cpp index f6f870be20..5987d78067 100644 --- a/engines/tsage/resources.cpp +++ b/engines/tsage/resources.cpp @@ -166,37 +166,7 @@ void TLib::loadSection(uint32 fileOffset) {  	_file.seek(fileOffset);  	_sections.fileOffset = fileOffset; -	loadSection(_file, _resources); -} - -/** - * Inner logic for decoding a section index into a passed resource list object - */ -void TLib::loadSection(Common::File &f, ResourceList &resources) { -	if (f.readUint32BE() != 0x544D492D) -		error("Data block is not valid Rlb data"); - -	/*uint8 unknown1 = */f.readByte(); -	uint16 numEntries = f.readByte(); - -	for (uint i = 0; i < numEntries; ++i) { -		uint16 id = f.readUint16LE(); -		uint16 size = f.readUint16LE(); -		uint16 uncSize = f.readUint16LE(); -		uint8 sizeHi = f.readByte(); -		uint8 type = f.readByte() >> 5; -		assert(type <= 1); -		uint32 offset = f.readUint32LE(); - -		ResourceEntry re; -		re.id = id; -		re.fileOffset = offset; -		re.isCompressed = type != 0; -		re.size = ((sizeHi & 0xF) << 16) | size; -		re.uncompressedSize = ((sizeHi & 0xF0) << 12) | uncSize; - -		resources.push_back(re); -	} +	ResourceManager::loadSection(_file, _resources);  }  struct DecodeReference { @@ -342,6 +312,40 @@ byte *TLib::getResource(ResourceType resType, uint16 resNum, uint16 rlbNum, bool  	return getResource(rlbNum, suppressErrors);  } +/** + * Gets the offset of the start of a resource in the resource file + */ +uint32 TLib::getResourceStart(ResourceType resType, uint16 resNum, uint16 rlbNum, ResourceEntry &entry) { +	// Find the correct section +	SectionList::iterator i = _sections.begin(); +	while ((i != _sections.end()) && ((*i).resType != resType || (*i).resNum != resNum)) +		++i; +	if (i == _sections.end()) { +		error("Unknown resource type %d num %d", resType, resNum); +	} + +	// Load in the section index +	loadSection((*i).fileOffset); + +	// Scan for an entry for the given Id +	ResourceEntry *re = NULL; +	ResourceList::iterator iter; +	for (iter = _resources.begin(); iter != _resources.end(); ++iter) { +		if ((*iter).id == rlbNum) { +			re = &(*iter); +			break; +		} +	} + +	// Throw an error if no resource was found, or the resource is compressed +	if (!re || re->isCompressed) +		error("Invalid resource Id #%d", rlbNum); + +	// Return the resource entry as well as the file offset +	entry = *re; +	return _sections.fileOffset + entry.fileOffset; +} +  void TLib::loadIndex() {  	uint16 resNum, configId, fileOffset; @@ -437,7 +441,7 @@ bool TLib::getMessage(int resNum, int lineNum, Common::String &result, bool supp  	while (lineNum-- > 0) {  		srcP += strlen(srcP) + 1; -		 +  		if (srcP >= endP) {  			if (suppressErrors)  				return false; @@ -453,36 +457,6 @@ bool TLib::getMessage(int resNum, int lineNum, Common::String &result, bool supp  /*--------------------------------------------------------------------------*/ -/** - * Open up the main resource file and get an entry from the root section - */ -bool TLib::getSectionEntry(Common::File &f, ResourceType resType, int rlbNum, int resNum,  -									  ResourceEntry &resEntry) { -	// Try and open the resource file -	if (!f.open(_filename)) -	  return false; - -	// Load the root section index -	ResourceList resList; -	loadSection(f, resList); - -	// Loop through the index for the desired entry -	ResourceList::iterator iter; -	for (iter = _resources.begin(); iter != _resources.end(); ++iter) { -		ResourceEntry &re = *iter; -		if (re.id == resNum) { -			// Found it, so exit -			resEntry = re; -			return true; -		} -	} - -	// No matching entry found -	return false; -} - -/*--------------------------------------------------------------------------*/ -  ResourceManager::~ResourceManager() {  	for (uint idx = 0; idx < _libList.size(); ++idx)  		delete _libList[idx]; @@ -557,4 +531,62 @@ Common::String ResourceManager::getMessage(int resNum, int lineNum, bool suppres  	return Common::String();  } +/*--------------------------------------------------------------------------*/ + +/** + * Open up the given resource file using a passed file object. If the desired entry is found + * in the index, return the index entry for it, and move the file to the start of the resource + */ +bool ResourceManager::scanIndex(Common::File &f, ResourceType resType, int rlbNum, int resNum, +									  ResourceEntry &resEntry) { +	// Load the root section index +	ResourceList resList; +	loadSection(f, resList); + +	// Loop through the index for the desired entry +	ResourceList::iterator iter; +	for (iter = resList.begin(); iter != resList.end(); ++iter) { +		ResourceEntry &re = *iter; +		if (re.id == resNum) { +			// Found it, so exit +			resEntry = re; +			f.seek(re.fileOffset); +			return true; +		} +	} + +	// No matching entry found +	return false; +} + +/** + * Inner logic for decoding a section index into a passed resource list object + */ +void ResourceManager::loadSection(Common::File &f, ResourceList &resources) { +	if (f.readUint32BE() != 0x544D492D) +		error("Data block is not valid Rlb data"); + +	/*uint8 unknown1 = */f.readByte(); +	uint16 numEntries = f.readByte(); + +	for (uint i = 0; i < numEntries; ++i) { +		uint16 id = f.readUint16LE(); +		uint16 size = f.readUint16LE(); +		uint16 uncSize = f.readUint16LE(); +		uint8 sizeHi = f.readByte(); +		uint8 type = f.readByte() >> 5; +		assert(type <= 1); +		uint32 offset = f.readUint32LE(); + +		ResourceEntry re; +		re.id = id; +		re.fileOffset = offset; +		re.isCompressed = type != 0; +		re.size = ((sizeHi & 0xF) << 16) | size; +		re.uncompressedSize = ((sizeHi & 0xF0) << 12) | uncSize; + +		resources.push_back(re); +	} +} +  } // end of namespace TsAGE diff --git a/engines/tsage/resources.h b/engines/tsage/resources.h index 2b5561b184..45cecf8521 100644 --- a/engines/tsage/resources.h +++ b/engines/tsage/resources.h @@ -150,19 +150,19 @@ private:  	SectionList _sections;  	void loadSection(uint32 fileOffset); -	void loadSection(Common::File &f, ResourceList &resources);  	void loadIndex();  public:  	TLib(MemoryManager &memManager, const Common::String &filename);  	~TLib(); +	const Common::String &getFilename() { return _filename; } +	const SectionList &getSections() { return _sections; }  	byte *getResource(uint16 id, bool suppressErrors = false);  	byte *getResource(ResourceType resType, uint16 resNum, uint16 rlbNum, bool suppressErrors = false); +	uint32 getResourceStart(ResourceType resType, uint16 resNum, uint16 rlbNum, ResourceEntry &entry);  	bool getPalette(int paletteNum, byte *palData, uint *startNum, uint *numEntries);  	byte *getSubResource(int resNum, int rlbNum, int index, uint *size, bool suppressErrors = false);  	bool getMessage(int resNum, int lineNum, Common::String &result, bool suppressErrors = false); - -	bool getSectionEntry(Common::File &f, ResourceType resType, int rlbNum, int resNum, ResourceEntry &resEntry);  };  class ResourceManager { @@ -179,6 +179,9 @@ public:  	byte *getSubResource(int resNum, int rlbNum, int index, uint *size, bool suppressErrors = false);  	Common::String getMessage(int resNum, int lineNum, bool suppressErrors = false);  	TLib &first() { return **_libList.begin(); } + +	static bool scanIndex(Common::File &f, ResourceType resType, int rlbNum, int resNum, ResourceEntry &resEntry); +	static void loadSection(Common::File &f, ResourceList &resources);  }; diff --git a/engines/tsage/ringworld2/ringworld2_dialogs.cpp b/engines/tsage/ringworld2/ringworld2_dialogs.cpp index 5178fe6418..30ae6be7b1 100644 --- a/engines/tsage/ringworld2/ringworld2_dialogs.cpp +++ b/engines/tsage/ringworld2/ringworld2_dialogs.cpp @@ -389,7 +389,7 @@ HelpDialog::HelpDialog() {  	_msgTitle._bounds.moveTo(5, 0);  	_msgVersion.set(GAME_VERSION, 172, ALIGN_CENTER);  	_msgVersion._bounds.moveTo(5, _msgTitle._bounds.bottom + 3); -	addElements(&_msgTitle, &_msgVersion, NULL);	 +	addElements(&_msgTitle, &_msgVersion, NULL);  	// Set buttons  	_btnList[0].setText(F2); diff --git a/engines/tsage/ringworld2/ringworld2_logic.cpp b/engines/tsage/ringworld2/ringworld2_logic.cpp index 89cf831088..3c5530feec 100644 --- a/engines/tsage/ringworld2/ringworld2_logic.cpp +++ b/engines/tsage/ringworld2/ringworld2_logic.cpp @@ -40,16 +40,16 @@ Scene *Ringworld2Game::createScene(int sceneNumber) {  	switch (sceneNumber) {  	/* Scene group #0 */ -	case 50:  +	case 50:  		// Waking up cutscene  		return new Scene50(); -	case 100:  +	case 100:  		// Quinn's room  		return new Scene100(); -	case 125:  +	case 125:  		// Computer console  		return new Scene125(); -	case 150:  +	case 150:  		// Empty Bedroom #1  		return new Scene150();  	case 160: @@ -166,7 +166,7 @@ Scene *Ringworld2Game::createScene(int sceneNumber) {  		// Ice Maze: Large empty room  		return new Scene2400();  	case 2425: -		// Ice Maze:  +		// Ice Maze:  		return new Scene2425();  	case 2430:  		// Ice Maze: Bedroom @@ -326,7 +326,7 @@ void SceneExt::postInit(SceneObjectList *OwnerList) {  	int prevScene = R2_GLOBALS._sceneManager._previousScene;  	int sceneNumber = R2_GLOBALS._sceneManager._sceneNumber; -	if (((prevScene == -1) && (sceneNumber != 180) && (sceneNumber != 205) && (sceneNumber != 50))  +	if (((prevScene == -1) && (sceneNumber != 180) && (sceneNumber != 205) && (sceneNumber != 50))  			|| (sceneNumber == 50)  			|| ((prevScene == 205) && (sceneNumber == 100))  			|| ((prevScene == 180) && (sceneNumber == 100))) { @@ -549,7 +549,7 @@ void SceneExt::scalePalette(int RFactor, int GFactor, int BFactor) {  			tmp += abs(tmpPal[(3 * j) + 2] - newB);  			if (tmp >= varC)  				continue; -			 +  			varC = tmp;  			varD = j;  		} @@ -628,11 +628,11 @@ void SceneHandlerExt::setupPaletteMaps() {  					diffSum += ABS(palP[pIndex2 * 3 + 1] - g);  					if (diffSum >= threshold)  						continue; -					 +  					diffSum += ABS(palP[pIndex2 * 3 + 2] - b);  					if (diffSum >= threshold)  						continue; -					 +  					threshold = diffSum;  					foundIndex = pIndex2;  				} @@ -1257,12 +1257,12 @@ void SceneAreaObject::setDetails(int visage, int strip, int frameNumber, const C  	_cursorNum = CURSOR_INVALID;  	Scene500 *scene = (Scene500 *)R2_GLOBALS._sceneManager._scene;  	scene->_sceneAreas.push_front(this); -	 +  	_insetCount = ++R2_GLOBALS._insetUp;  }  void SceneAreaObject::setDetails(int resNum, int lookLineNum, int talkLineNum, int useLineNum) { -	((SceneHotspot *)(this))->setDetails(resNum, lookLineNum, talkLineNum, useLineNum,  +	((SceneHotspot *)(this))->setDetails(resNum, lookLineNum, talkLineNum, useLineNum,  		2, (SceneItem *)NULL);  } @@ -1306,7 +1306,7 @@ void UnkObject1200::sub51AE9(int arg1) {  int UnkObject1200::sub51AF8(Common::Point pt) {  	if (!_rect1.contains(pt))  		return -1; -	 +  	int tmp1 = (pt.x - _rect1.left + _field2E) / _field2A;  	int tmp2 = (pt.y - _rect1.top + _field30) / _field2C; @@ -1358,7 +1358,7 @@ void UnkObject1200::sub9EDE8(Rect rect) {  int UnkObject1200::sub9EE22(int &arg1, int &arg2) {  	arg1 /= _field2A;  	arg2 /= _field2C; -	 +  	if ((arg1 >= 0) && (arg2 >= 0) && (_field26 > arg1) && (_field28 > arg2)) {  		return _field16[(((_field26 * arg2) + arg1) * 2)];  	} @@ -1368,13 +1368,13 @@ int UnkObject1200::sub9EE22(int &arg1, int &arg2) {  void Scene1200::sub9DAD6(int indx) {  	_object1.sub9EE22(R2_GLOBALS._v56AA2, R2_GLOBALS._v56AA4); -	 +  	switch (indx) {  	case 0: -		if ( ((_object1.sub51AF8(Common::Point(200, 50)) > 36) || (_object1.sub51AF8(Common::Point(200, 88)) > 36))  -			&& ( ((R2_GLOBALS._v56AA2 == 3) && (R2_GLOBALS._v56AA4 == 33) && (_field418 != 4))  -				|| ((R2_GLOBALS._v56AA2 == 13) && (R2_GLOBALS._v56AA4 == 21) && (_field418 != 2))  -				|| ((R2_GLOBALS._v56AA2 == 29) && (R2_GLOBALS._v56AA4 == 17) && (_field418 != 1))  +		if ( ((_object1.sub51AF8(Common::Point(200, 50)) > 36) || (_object1.sub51AF8(Common::Point(200, 88)) > 36)) +			&& ( ((R2_GLOBALS._v56AA2 == 3) && (R2_GLOBALS._v56AA4 == 33) && (_field418 != 4)) +				|| ((R2_GLOBALS._v56AA2 == 13) && (R2_GLOBALS._v56AA4 == 21) && (_field418 != 2)) +				|| ((R2_GLOBALS._v56AA2 == 29) && (R2_GLOBALS._v56AA4 == 17) && (_field418 != 1))  				|| ((R2_GLOBALS._v56AA2 == 33) && (R2_GLOBALS._v56AA4 == 41)) )  				)	{  			R2_GLOBALS._player.disableControl(); @@ -1415,10 +1415,10 @@ void Scene1200::sub9DAD6(int indx) {  		}  		break;  	case 1: -		if ( ((_object1.sub51AF8(Common::Point(120, 50)) > 36) || (_object1.sub51AF8(Common::Point(120, 88)) > 36))  -			&& ( ((R2_GLOBALS._v56AA2 == 7) && (R2_GLOBALS._v56AA4 == 33) && (_field418 != 4))  -				|| ((R2_GLOBALS._v56AA2 == 17) && (R2_GLOBALS._v56AA4 == 21) && (_field418 != 2))  -				|| ((R2_GLOBALS._v56AA2 == 33) && (R2_GLOBALS._v56AA4 == 17) && (_field418 != 1))  +		if ( ((_object1.sub51AF8(Common::Point(120, 50)) > 36) || (_object1.sub51AF8(Common::Point(120, 88)) > 36)) +			&& ( ((R2_GLOBALS._v56AA2 == 7) && (R2_GLOBALS._v56AA4 == 33) && (_field418 != 4)) +				|| ((R2_GLOBALS._v56AA2 == 17) && (R2_GLOBALS._v56AA4 == 21) && (_field418 != 2)) +				|| ((R2_GLOBALS._v56AA2 == 33) && (R2_GLOBALS._v56AA4 == 17) && (_field418 != 1))  				|| ((R2_GLOBALS._v56AA2 == 5) && (R2_GLOBALS._v56AA4 == 5)) )  				)	{  			R2_GLOBALS._player.disableControl(); @@ -1459,8 +1459,8 @@ void Scene1200::sub9DAD6(int indx) {  		}  		break;  	case 2: -		if ( ((_object1.sub51AF8(Common::Point(140, 110)) > 36) || (_object1.sub51AF8(Common::Point(178, 110)) > 36))  -			&& ( ((R2_GLOBALS._v56AA2 == 17) && (R2_GLOBALS._v56AA4 == 5) && (_field418 != 3))  +		if ( ((_object1.sub51AF8(Common::Point(140, 110)) > 36) || (_object1.sub51AF8(Common::Point(178, 110)) > 36)) +			&& ( ((R2_GLOBALS._v56AA2 == 17) && (R2_GLOBALS._v56AA4 == 5) && (_field418 != 3))  				|| ((R2_GLOBALS._v56AA2 == 41) && (R2_GLOBALS._v56AA4 == 21)) )  				)	{  			R2_GLOBALS._player.disableControl(); @@ -1501,8 +1501,8 @@ void Scene1200::sub9DAD6(int indx) {  		}  		break;  	case 3: -		if ( ((_object1.sub51AF8(Common::Point(140, 30)) > 36) || (_object1.sub51AF8(Common::Point(178, 30)) > 36))  -			&& ( ((R2_GLOBALS._v56AA2 == 17) && (R2_GLOBALS._v56AA4 == 9) && (_field418 != 3))  +		if ( ((_object1.sub51AF8(Common::Point(140, 30)) > 36) || (_object1.sub51AF8(Common::Point(178, 30)) > 36)) +			&& ( ((R2_GLOBALS._v56AA2 == 17) && (R2_GLOBALS._v56AA4 == 9) && (_field418 != 3))  				|| ((R2_GLOBALS._v56AA2 == 35) && (R2_GLOBALS._v56AA4 == 17)) )  				)	{  			R2_GLOBALS._player.disableControl(); @@ -1551,24 +1551,88 @@ void Scene1200::sub9DAD6(int indx) {  /*--------------------------------------------------------------------------*/ +void AnimationSplice::load(Common::File &f) { +	_spliceOffset = f.readUint32LE(); +	f.skip(6); +	_drawMode = f.readByte(); +	_secondaryIndex = f.readByte(); +} + +/*--------------------------------------------------------------------------*/ + +AnimationSplices::AnimationSplices() { +	_pixelData = NULL; +} + +AnimationSplices::~AnimationSplices() { +	delete[] _pixelData; +} + +void AnimationSplices::load(Common::File &f) { +	f.skip(4); +	_dataSize = f.readUint32LE(); +	f.skip(8); +	_dataSize2 = f.readUint32LE(); +	f.skip(28); + +	// Load the four splice indexes +	for (int idx = 0; idx < 4; ++idx) +		_splices[idx].load(f); +} + +int AnimationSplices::loadPixels(Common::File &f, int splicesSize) { +	delete[] _pixelData; +	_pixelData = new byte[splicesSize]; +	return f.read(_pixelData, splicesSize); +} + +/*--------------------------------------------------------------------------*/ + +void AnimationPlayerSubData::load(Common::File &f) { +	uint32 posStart = f.pos(); + +	f.skip(6); +	_field6 = f.readUint16LE(); +	f.skip(2); +	_fieldA = f.readUint16LE(); +	_fieldC = f.readUint16LE(); +	_fieldE = f.readUint16LE(); +	f.skip(2); +	_sliceSize = f.readUint16LE(); +	_ySlices = f.readUint16LE(); +	_field16 = f.readUint16LE(); +	f.skip(4); +	_palStart = f.readUint16LE(); +	_palSize = f.readUint16LE(); +	f.read(_palData, 768); +	_field320 = f.readSint32LE(); +	f.skip(12); +	_splices.load(f); + +	uint32 posEnd = f.pos(); +	assert((posEnd - posStart) == 0x390); +} + +/*--------------------------------------------------------------------------*/ +  AnimationPlayer::AnimationPlayer(): EventHandler() {  	_endAction = NULL; -	 -	_fieldA = NULL; -	_field16 = NULL; -	 + +	_animData1 = NULL; +	_animData2 = NULL; +  	_screenBounds = R2_GLOBALS._gfxManagerInstance._bounds;  	_rect1 = R2_GLOBALS._gfxManagerInstance._bounds; -	_field3C = 0; +	_paletteMode = 0;  	_field3A = 1; -	_field5A = 0; -	_field58 = 0; +	_sliceHeight = 1; +	_field58 = 1;  	_endAction = NULL;  }  AnimationPlayer::~AnimationPlayer() {  	if (!method3()) -		method4(); +		close();  }  void AnimationPlayer::synchronize(Serializer &s) { @@ -1586,8 +1650,8 @@ void AnimationPlayer::remove() {  void AnimationPlayer::process(Event &event) {  	if ((event.eventType == EVENT_KEYPRESS) && (event.kbd.keycode == Common::KEYCODE_ESCAPE) &&  			(_field3A)) { -		_field90C = _field576; -	}  +		_field90C = _subData._field6; +	}  }  void AnimationPlayer::dispatch() { @@ -1595,9 +1659,9 @@ void AnimationPlayer::dispatch() {  	uint32 gameDiff = (gameFrame > _gameFrame) ? gameFrame - _gameFrame : _gameFrame - gameFrame;  	if (gameDiff >= _field910) { -		drawFrame(_field904 % _field57C); +		drawFrame(_field904 % _subData._fieldC);  		++_field904; -		_field90C = _field904 / _field57C; +		_field90C = _field904 / _subData._fieldC;  		if (_field90C == _field90E)  			method2(); @@ -1607,53 +1671,222 @@ void AnimationPlayer::dispatch() {  	}  } -bool AnimationPlayer::load(int rlbNum, Action *endAction) { -	ResourceEntry resEntry; -	if (!g_resourceManager->first().getSectionEntry(_resourceFile, RES_IMAGE, rlbNum, 0, resEntry)) { -		warning("Couldn't find resource index"); -		// TODO: Complete animation loading +bool AnimationPlayer::load(int animId, Action *endAction) { +	// Open up the main resource file for access +	TLib &libFile = g_resourceManager->first(); +	if (!_resourceFile.open(libFile.getFilename())) +		error("Could not open resource"); + +	// Get the offset of the given resource and seek to it in the player's file reference +	ResourceEntry entry; +	uint32 fileOffset = libFile.getResourceStart(RES_IMAGE, animId, 0, entry); +	_resourceFile.seek(fileOffset); + +	// At this point, the file is pointing to the start of the resource data + +	// Set the end action +	_endAction = endAction; + +	// Load the sub data block +	_subData.load(_resourceFile); + +	// Set other properties +	_field908 = -1; +	_field904 = 0; +	_field910 = 60 / _subData._fieldA; +	_gameFrame = R2_GLOBALS._events.getFrameNumber() - _field910; + +	if (_subData._field320) { +		_dataNeeded = _subData._field320; +	} else { +		int v = (_subData._sliceSize + 2) * _subData._ySlices * _subData._fieldC; +		_dataNeeded = (_subData._field16 / _subData._fieldC) + v + 96;  	} +	 +	debugC(1, ktSageDebugGraphics, "Data needed %d", _dataNeeded); -	_resourceFile.close(); -	return false; +	// Set up animation data array +	_animData1 = new AnimationData(); +	_sliceCurrent = _animData1; + +	if (_subData._fieldC <= 1) { +		_animData2 = NULL; +		_sliceNext = _sliceCurrent; +	} else { +		_animData2 = new AnimationData(); +		_sliceNext = _animData2; +	} + +	_field90C = 0; +	_field90E = 1; + +	// Load up the first splices set +	_sliceCurrent->_dataSize = _subData._splices._dataSize; +	_sliceCurrent->_splices = _subData._splices; +	int splicesSize = _sliceCurrent->_dataSize - 96; +	int readSize = _sliceCurrent->_splices.loadPixels(_resourceFile, splicesSize); +	_sliceCurrent->_animSlicesSize = readSize + 96; + +	if (_sliceNext != _sliceCurrent) { +		getSlices(); +	} + +	// Handle starting palette +	switch (_paletteMode) { +	case 0: +		// Use existing active palette +		_palette.getPalette(); +		for (int idx = _subData._palStart; idx < (_subData._palStart + _subData._palSize); ++idx) { +			uint r, g, b; +			_palette.getEntry(idx, &r, &g, &b); +			R2_GLOBALS._scenePalette.setEntry(idx, r, g, b); +		} + +		R2_GLOBALS._sceneManager._hasPalette = true; +		break; +	case 2: +		break; + +	default: +		for (int idx = _subData._palStart; idx < (_subData._palStart + _subData._palSize); ++idx) { +			byte r = _subData._palData[idx * 3]; +			byte g = _subData._palData[idx * 3 + 1]; +			byte b = _subData._palData[idx * 3 + 2]; +		 +			int palIndex = R2_GLOBALS._scenePalette.indexOf(r, g, b); +			_palIndexes[idx] = palIndex; +		} +		break; +	} + +	++R2_GLOBALS._animationCtr; +	_field38 = 1; +	return true;  } -void AnimationPlayer::drawFrame(int frameIndex) { -	uint32 v = READ_LE_UINT32(_dataP); -warning("v = %d", v); -//TODO +void AnimationPlayer::drawFrame(int spliceIndex) { +	assert(spliceIndex < 4); +	AnimationSplices &splices = _sliceCurrent->_splices; +	AnimationSplice &splice = _sliceCurrent->_splices._splices[spliceIndex]; -	// End check -	if (_field56 == 42) { -		_screenBounds.expandPanes(); +	byte *sliceDataStart = &splices._pixelData[splice._spliceOffset]; +	byte *sliceData1 = sliceDataStart; -		R2_GLOBALS._sceneObjects->draw(); -	} else { -		if (R2_GLOBALS._sceneManager._hasPalette) { -			R2_GLOBALS._sceneManager._hasPalette = false; -			R2_GLOBALS._scenePalette.refresh(); +	Rect playerBounds = _screenBounds; +	int y = _screenBounds.top; +	R2_GLOBALS._screenSurface.addDirtyRect(playerBounds); + +	Graphics::Surface surface = R2_GLOBALS._screenSurface.lockSurface(); + +	// Handle different drawing modes +	switch (splice._drawMode) { +	case 0: +		// Draw from uncompressed source +		for (int sliceNum = 0; sliceNum < _subData._ySlices; ++sliceNum) { +			for (int yIndex = 0; yIndex < _sliceHeight; ++yIndex) { +				// TODO: Check of _subData._fieldE was done for two different kinds of +				// line slice drawing in original +				const byte *pSrc = (const byte *)sliceDataStart + READ_LE_UINT16(sliceData1 + sliceNum * 2); +				byte *pDest = (byte *)surface.getBasePtr(playerBounds.left, y++); + +				Common::copy(pSrc, pSrc + _subData._sliceSize, pDest); +			}  		} +		break; + +	case 1: +		switch (splice._secondaryIndex) { +		case 0xfe: +			// Draw from uncompressed source with optional skipped rows +			for (int sliceNum = 0; sliceNum < _subData._ySlices; ++sliceNum) { +				for (int yIndex = 0; yIndex < _sliceHeight; ++yIndex) { +					int offset = READ_LE_UINT16(sliceData1 + sliceNum * 2); + +					if (offset) { +						const byte *pSrc = (const byte *)sliceDataStart + offset; +						byte *pDest = (byte *)surface.getBasePtr(playerBounds.left, y++); + +						Common::copy(pSrc, pSrc + _subData._sliceSize, pDest); +					} +				} +			} +			break; +		case 0xff: +			// Draw from RLE compressed source +			for (int sliceNum = 0; sliceNum < _subData._ySlices; ++sliceNum) { +				for (int yIndex = 0; yIndex < _sliceHeight; ++yIndex) { +					// TODO: Check of _subData._fieldE was done for two different kinds of +					// line slice drawing in original +					const byte *pSrc = (const byte *)sliceDataStart + READ_LE_UINT16(sliceData1 + sliceNum * 2); +					byte *pDest = (byte *)surface.getBasePtr(playerBounds.left, y++); + +					rleDecode(pSrc, pDest, _subData._sliceSize); +				} +			} +			break; +		default: { +			// Draw from two splice sets simultaneously +			AnimationSplice &splice2 = _sliceCurrent->_splices._splices[splice._secondaryIndex]; +			byte *sliceData2 = &splices._pixelData[splice2._spliceOffset]; + +			for (int sliceNum = 0; sliceNum < _subData._ySlices; ++sliceNum) { +				for (int yIndex = 0; yIndex < _sliceHeight; ++yIndex) { +					const byte *pSrc1 = (const byte *)sliceDataStart + READ_LE_UINT16(sliceData2 + sliceNum * 2); +					const byte *pSrc2 = (const byte *)sliceDataStart + READ_LE_UINT16(sliceData1 + sliceNum * 2); +					byte *pDest = (byte *)surface.getBasePtr(playerBounds.left, y++); + +					if (splice2._drawMode == 0) { +						// Uncompressed background, foreground compressed +						Common::copy(pSrc1, pSrc1 + _subData._sliceSize, pDest); +						rleDecode(pSrc2, pDest, _subData._sliceSize); +					} else { +						// Both background and foreground is compressed +						rleDecode(pSrc1, pDest, _subData._sliceSize); +						rleDecode(pSrc2, pDest, _subData._sliceSize); +					} +				} +			} +			break; +		} +		} +	default: +		break;  	}  }  void AnimationPlayer::method2() { - +	_field90C = _field90E++; +	_field904 = _field90C * _subData._fieldC; +	_field908 = _field904 - 1; + +	if (_sliceNext == _sliceCurrent) { +		int dataSize = _sliceCurrent->_splices._dataSize2; +		_sliceCurrent->_dataSize = dataSize; + +		dataSize -= 96; +		assert(dataSize >= 0); +		_sliceCurrent->_splices.load(_resourceFile); +		_sliceCurrent->_animSlicesSize = _sliceCurrent->_splices.loadPixels(_resourceFile, dataSize); +	} else { +		SWAP(_sliceCurrent, _sliceNext); +		getSlices(); +	}  }  bool AnimationPlayer::method3() { -	return (_field90C >= _field576); +	return (_field90C >= _subData._field6);  } -void AnimationPlayer::method4() { +void AnimationPlayer::close() {  	if (_field38) { -		switch (_field3C) { +		switch (_paletteMode) {  		case 0:  			R2_GLOBALS._scenePalette.replace(&_palette);  			changePane();  			R2_GLOBALS._sceneManager._hasPalette = true;  			break;  		case 2: -			proc14(); +			closing();  			break;  		default:  			changePane(); @@ -1661,7 +1894,61 @@ void AnimationPlayer::method4() {  		}  	} -// TODO +	// Close the resource file +	_resourceFile.close(); + +	if (_field56 != 42) { +		// flip screen in original +	} + +	// Free animation objects +	delete _animData1; +	delete _animData2; +	_animData1 = NULL; +	_animData2 = NULL; + +	_field38 = 0; +	R2_GLOBALS._animationCtr = MAX(R2_GLOBALS._animationCtr, 0); +} + +void AnimationPlayer::rleDecode(const byte *pSrc, byte *pDest, int size) { +	while (size > 0) { +		byte v = *pSrc++; +		if (!(v & 0x80)) { +			// Following uncompressed set of bytes +			Common::copy(pSrc, pSrc + v, pDest); +			pSrc += v; +			pDest += v; +			size -= v; +		} else { +			int count = v & 0x3F; +			size -= count; + +			if (!(v & 0x40)) { +				// Skip over a number of bytes +				pDest += count; +			} else { +				// Replicate a number of bytes +				Common::fill(pDest, pDest + count, *pSrc++); +				pDest += count; +			} +		} +	} +} + +void AnimationPlayer::getSlices() { +	assert((_sliceNext == _animData1) || (_sliceNext == _animData2)); +	assert((_sliceCurrent == _animData1) || (_sliceCurrent == _animData2)); + +	_sliceNext->_dataSize = _sliceCurrent->_splices._dataSize2; +	if (_sliceNext->_dataSize) { +		if (_sliceNext->_dataSize >= _dataNeeded) +			error("Bogus dataNeeded == %d / %d", _sliceNext->_dataSize, _dataNeeded); +	} + +	int dataSize = _sliceNext->_dataSize - 96; +	_sliceNext->_splices.load(_resourceFile); +	_sliceNext->_animSlicesSize = _sliceNext->_splices.loadPixels(_resourceFile, dataSize);  }  /*--------------------------------------------------------------------------*/ diff --git a/engines/tsage/ringworld2/ringworld2_logic.h b/engines/tsage/ringworld2/ringworld2_logic.h index 98fcaae981..6100efc8bc 100644 --- a/engines/tsage/ringworld2/ringworld2_logic.h +++ b/engines/tsage/ringworld2/ringworld2_logic.h @@ -325,24 +325,78 @@ public:  	virtual Common::String getClassName() { return "UnkObject1200"; }  }; +/*--------------------------------------------------------------------------*/ + +class AnimationSplice { +public: +	int _spliceOffset; +	int _drawMode; +	int _secondaryIndex; +public: +	void load(Common::File &f); +}; + +class AnimationSplices { +public: +	int _dataSize; +	int _dataSize2; +	AnimationSplice _splices[4]; +	byte *_pixelData; +public: +	AnimationSplices(); +	~AnimationSplices(); + +	void load(Common::File &f); +	int loadPixels(Common::File &f, int splicesSize); +}; + +class AnimationPlayerSubData { +public: +	int _field6; +	int _fieldA; +	int _fieldC; +	int _fieldE; +	int _sliceSize; +	int _ySlices; +	int _field16; +	int _palStart; +	int _palSize; +	byte _palData[256 * 3]; +	int32 _field320; +	AnimationSplices _splices; +public: +	void load(Common::File &f); +}; + +class AnimationData { +public: +	AnimationSplices _splices; +	int _dataSize; +	int _animSlicesSize; +}; +  class AnimationPlayer: public EventHandler { +private: +	void rleDecode(const byte *pSrc, byte *pDest, int size); + +	void drawFrame(int spliceIndex); +	void method2(); +	void getSlices();  public: +	AnimationData *_animData1, *_animData2; +	AnimationData *_sliceCurrent; +	AnimationData *_sliceNext;  	Common::File _resourceFile; -	void *_fieldA; -	void *_field16; - -	byte *_dataP;  	Rect _rect1, _screenBounds;  	int _field38; -	int _field3A, _field3C; +	int _field3A, _paletteMode;  	int _field56; -	int _field58, _field5A; +	int _field58, _sliceHeight; +	byte _palIndexes[256];  	ScenePalette _palette; -	byte _palData[256 * 3]; +	AnimationPlayerSubData _subData;  	Action *_endAction; -	int _field576; -	int _field57C; -	int _palStart, _palSize; +	int _dataNeeded;  	int _field904;  	int _field908;  	int _field90C; @@ -359,14 +413,11 @@ public:  	virtual void dispatch();  	virtual void flipPane() {}  	virtual void changePane() {} -	virtual void proc14() {} +	virtual void closing() {} -	bool load(int rlbNum, Action *endAction = NULL); -	void drawFrame(int frameIndex); -	void method2(); +	bool load(int animId, Action *endAction = NULL);  	bool method3(); -	void method4(); -	void method5() {} +	void close();  };  class AnimationPlayerExt: public AnimationPlayer { diff --git a/engines/tsage/ringworld2/ringworld2_scenes0.cpp b/engines/tsage/ringworld2/ringworld2_scenes0.cpp index dab9afb269..292e9c2f5e 100644 --- a/engines/tsage/ringworld2/ringworld2_scenes0.cpp +++ b/engines/tsage/ringworld2/ringworld2_scenes0.cpp @@ -125,17 +125,17 @@ bool Scene100::Table::startAction(CursorType action, Event &event) {  				scene->_stasisNegator.setDetails(100, 21, 22, 23, 2, (SceneItem *)NULL);  			} -			scene->setAction(&scene->_sequenceManager2, scene, 108, this, &scene->_object3,  +			scene->setAction(&scene->_sequenceManager2, scene, 108, this, &scene->_object3,  				&scene->_stasisNegator, &R2_GLOBALS._player, NULL);  		} else {  			scene->_sceneMode = 109; -			scene->setAction(&scene->_sequenceManager2, scene, 109, this, &scene->_object3,  +			scene->setAction(&scene->_sequenceManager2, scene, 109, this, &scene->_object3,  				&scene->_stasisNegator, &R2_GLOBALS._player, NULL);  		}  		return true;  	case CURSOR_TALK:  		R2_GLOBALS._player.disableControl(); -		 +  		if (_strip == 2) {  			SceneItem::display2(100, 18);  			scene->_sceneMode = 102; @@ -149,12 +149,12 @@ bool Scene100::Table::startAction(CursorType action, Event &event) {  				scene->_stasisNegator.setDetails(100, 21, 22, 23, 2, (SceneItem *)NULL);  			} -			scene->setAction(&scene->_sequenceManager2, scene, 102, this, &scene->_object3,  +			scene->setAction(&scene->_sequenceManager2, scene, 102, this, &scene->_object3,  				&scene->_stasisNegator, NULL);  		} else {  			SceneItem::display2(100, 19);  			scene->_sceneMode = 103; -			scene->setAction(&scene->_sequenceManager2, scene, 103, this, &scene->_object3,  +			scene->setAction(&scene->_sequenceManager2, scene, 103, this, &scene->_object3,  				&scene->_stasisNegator, NULL);  		}  		return true; @@ -264,7 +264,7 @@ void Scene100::postInit(SceneObjectList *OwnerList) {  	_bedLights2.setup(100, 3, 1);  	_bedLights2.setPosition(Common::Point(89, 147));  	_bedLights2.fixPriority(250); -	_bedLights2.animate(ANIM_MODE_7, 0, NULL);  +	_bedLights2.animate(ANIM_MODE_7, 0, NULL);  	_bedLights2._numFrames = 3;  	_wardrobe.postInit(); @@ -289,7 +289,7 @@ void Scene100::postInit(SceneObjectList *OwnerList) {  	R2_GLOBALS._player.setVisage(10);  	R2_GLOBALS._player.animate(ANIM_MODE_1, NULL);  	R2_GLOBALS._player.disableControl(); -	 +  	_background.setDetails(Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT), 100, 0, 1, -1, 1, NULL);  	switch (R2_GLOBALS._sceneManager._previousScene) { @@ -330,7 +330,7 @@ void Scene100::signal() {  	case 109:  		_table.setStrip(2);  		_table.setFrame(3); -		 +  		_object3.remove();  		_stasisNegator.remove();  		R2_GLOBALS._player.enableControl(); @@ -413,7 +413,7 @@ Scene125::Icon::Icon(): SceneActor()  {  void Scene125::Icon::postInit(SceneObjectList *OwnerList) {  	SceneObject::postInit(); -	 +  	_object1.postInit();  	_object1.fixPriority(255);  	_object1.hide(); @@ -621,7 +621,7 @@ void Scene125::postInit(SceneObjectList *OwnerList) {  	loadScene(160);  	_palette.loadPalette(0); -	if (R2_GLOBALS._sceneManager._previousScene != 125)  +	if (R2_GLOBALS._sceneManager._previousScene != 125)  		// Save the prior scene to return to when the console is turned off  		R2_GLOBALS._player._oldCharacterScene[1] = R2_GLOBALS._sceneManager._previousScene; @@ -638,7 +638,7 @@ void Scene125::postInit(SceneObjectList *OwnerList) {  	_object6.postInit();  	_object6.setup(162, 1, 1);  	_object6.setPosition(Common::Point(214, 168)); -	 +  	_item4.setDetails(Rect(27, 145, 81, 159), 126, 9, -1, -1, 1, NULL);  	_item3.setDetails(Rect(144, 119, 286, 167), 126, 6, 7, 8, 1, NULL);  	_item2.setDetails(1, 126, 3, 4, 5); @@ -669,7 +669,7 @@ void Scene125::signal() {  		_icon1._object2.postInit();  		_icon1._object2.setup(160, 7, 1);  		_icon1._object2.setPosition(Common::Point(106, 41)); -		 +  		_icon2.setup(160, 1, 1);  		_icon2.setPosition(Common::Point(80, 32));  		_icon2._object2.postInit(); @@ -766,7 +766,7 @@ void Scene125::signal() {  	case 11:  		R2_GLOBALS._player.enableControl();  		R2_GLOBALS._player._canWalk = false; -		 +  		if ((_consoleMode >= 27) && (_consoleMode <= 30)) {  			consoleAction(11);  		} @@ -915,7 +915,7 @@ void Scene125::consoleAction(int id) {  		_icon2.hideIcon();  		_icon3.hideIcon();  		_icon5.setIcon(24); -		 +  		_icon4.setPosition(Common::Point(52, 107));  		_icon4._sceneRegionId = 9;  		_icon4.setIcon(25); @@ -923,7 +923,7 @@ void Scene125::consoleAction(int id) {  		_icon6.setIcon(26);  		_sceneMode = 10; -		 +  		_palette.loadPalette(161);  		R2_GLOBALS._scenePalette.addFader(_palette._palette, 256, 5, this);  		break; @@ -958,7 +958,7 @@ void Scene125::consoleAction(int id) {  			_icon2.hideIcon();  			_icon3.hideIcon();  			_icon5.setIcon(24); -			 +  			_icon4.setPosition(Common::Point(52, 107));  			_icon4._sceneRegionId = 9;  			_icon4.setIcon(25); @@ -966,7 +966,7 @@ void Scene125::consoleAction(int id) {  			_icon6.setIcon(26);  			_sceneMode = 10; -			 +  			_palette.loadPalette(161);  			R2_GLOBALS._scenePalette.addFader(_palette._palette, 256, 5, this);  		} @@ -1089,7 +1089,7 @@ void Scene125::consoleAction(int id) {  		_icon3.hideIcon();  		_icon4.hideIcon();  		_icon5.setIcon(24); -		 +  		_icon4.setPosition(Common::Point(52, 107));  		_icon4._sceneRegionId = 9;  		_icon4.setIcon(25); @@ -1097,7 +1097,7 @@ void Scene125::consoleAction(int id) {  		_icon6.setIcon(26);  		_sceneMode = 10; -		 +  		_palette.loadPalette(161);  		R2_GLOBALS._scenePalette.addFader(_palette._palette, 256, 5, this);  		break; @@ -1134,7 +1134,7 @@ void Scene125::consoleAction(int id) {   */  void Scene125::setDetails(int resNum, int lineNum) {  	stop(); -	 +  	Common::String msg = g_resourceManager->getMessage(resNum, lineNum, true);  	if (!msg.empty()) { @@ -1243,7 +1243,7 @@ void Scene150::postInit(SceneObjectList *OwnerList) {  	R2_GLOBALS._player.setVisage(10);  	R2_GLOBALS._player.animate(ANIM_MODE_1, NULL);  	R2_GLOBALS._player.disableControl(); -	 +  	_background.setDetails(Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT), 150, 0, 1, -1, 1, NULL);  	_sceneMode = 100; @@ -1420,7 +1420,7 @@ void Scene160::postInit(SceneObjectList *OwnerList) {  	R2_GLOBALS._player._uiEnabled = false;  	R2_GLOBALS._player.enableControl();  	R2_GLOBALS._player._canWalk = false; -	 +  	R2_GLOBALS._uiElements.hide();  	R2_GLOBALS._interfaceY = SCREEN_HEIGHT; @@ -1555,13 +1555,13 @@ void Scene180::signal() {  	case 1:  		_field412 = 1;  		R2_GLOBALS._sceneManager._hasPalette = true; -		_animationPlayer._field3C = 2; +		_animationPlayer._paletteMode = 2;  		_animationPlayer._v = 1;  		_animationPlayer._field56 = 1;  		R2_GLOBALS._scene180Mode = 1;  		_animationPlayer.load(1, NULL); -		R2_GLOBALS._scenePalette.loadPalette(_animationPlayer._palData, 0, 256); +		R2_GLOBALS._scenePalette.loadPalette(_animationPlayer._subData._palData, 0, 256);  		R2_GLOBALS._sound1.play(1);  		break; @@ -1598,14 +1598,14 @@ void Scene180::signal() {  		break;  	case 5: -		_animationPlayer._field3C = 2; +		_animationPlayer._paletteMode = 2;  		_animationPlayer._v = 1;  		_animationPlayer._field56 = 1;  		R2_GLOBALS._scene180Mode = 2;  		_animationPlayer.load(2);  		_field412 = 1; -		R2_GLOBALS._scenePalette.addFader(_animationPlayer._palData, 256, 6, NULL); +		R2_GLOBALS._scenePalette.addFader(_animationPlayer._subData._palData, 256, 6, NULL);  		R2_GLOBALS._sound1.play(2);  		break; @@ -1664,7 +1664,7 @@ void Scene180::signal() {  	case 15:  		setAction(&_sequenceManager, this, 4002, &_object4, &_object5, NULL);  		break; -	 +  	case 17:  		setAction(&_sequenceManager, this, 4003, &_object4, &_object5, NULL);  		break; @@ -1701,7 +1701,7 @@ void Scene180::signal() {  	case 29:  		_field412 = 1; -		_animationPlayer._field3C = 0; +		_animationPlayer._paletteMode = 0;  		_animationPlayer._v = 1;  		_animationPlayer._field56 = 42;  		R2_GLOBALS._scene180Mode = 3; @@ -1730,7 +1730,7 @@ void Scene180::signal() {  	case 32:  		_field412 = 1; -		 +  		_object2.postInit();  		_object2.setPosition(Common::Point(161, 97));  		_object2.hide(); @@ -1790,7 +1790,7 @@ void Scene180::signal() {  		_object4.remove();  		_object5.setAction(NULL);  		_object5.remove(); -		 +  		R2_GLOBALS._sound2.fadeOut2(NULL);  		R2_GLOBALS._sound1.fadeOut2(NULL);  		break; @@ -1801,12 +1801,12 @@ void Scene180::signal() {  		break;  	case 40: -		_animationPlayer._field3C = 2; +		_animationPlayer._paletteMode = 2;  		_animationPlayer._field56 = 1;  		R2_GLOBALS._scene180Mode = 4;  		if (_animationPlayer.load(4)) {  			_animationPlayer.dispatch(); -			R2_GLOBALS._scenePalette.addFader(_animationPlayer._palData, 256, 8, this); +			R2_GLOBALS._scenePalette.addFader(_animationPlayer._subData._palData, 256, 8, this);  		} else {  			_sceneMode = 43;  			setFrameInc(1); @@ -1834,19 +1834,19 @@ void Scene180::signal() {  		break;  	case 45: -		R2_GLOBALS._scenePalette.addFader(_animationPlayer._palData, 256, 28, this); +		R2_GLOBALS._scenePalette.addFader(_animationPlayer._subData._palData, 256, 28, this);  		break;  	case 48:  		_field412 = 1; -		_animationPlayer._field3C = 2; +		_animationPlayer._paletteMode = 2;  		_animationPlayer._v = 1;  		_animationPlayer._field56 = 1;  		R2_GLOBALS._scene180Mode = 15;  		_animationPlayer.load(15, NULL);  		R2_GLOBALS._sound1.play(9); -		R2_GLOBALS._scenePalette.addFader(_animationPlayer._palData, 256, 6, NULL); +		R2_GLOBALS._scenePalette.addFader(_animationPlayer._subData._palData, 256, 6, NULL);  		break;  	case 49: @@ -1900,7 +1900,7 @@ void Scene180::dispatch() {  	if (_animationPlayer._v) {  		if (_animationPlayer.method3()) {  			_animationPlayer._v = 0; -			_animationPlayer.method4(); +			_animationPlayer.close();  			_animationPlayer.remove();  			signal(); @@ -2389,7 +2389,7 @@ void Scene205::dispatch() {  void Scene205::setup() {  	const Common::Point pointList1[3] = { Common::Point(2, 50), Common::Point(100, 28), Common::Point(53, 15) };  	const Common::Point pointList2[3] = { Common::Point(289, 192), Common::Point(125, 60), Common::Point(130, 40) }; -	const Common::Point pointList3[4] = {  +	const Common::Point pointList3[4] = {  		Common::Point(140, 149), Common::Point(91, 166), Common::Point(299, 46), Common::Point(314, 10)  	}; @@ -2445,13 +2445,13 @@ void Scene205::setup() {  /**   * Handles moving a group of stars in the scene background   */ -void Scene205::processList(Object **ObjList, int count, const Common::Rect &bounds,  +void Scene205::processList(Object **ObjList, int count, const Common::Rect &bounds,  						   int xMultiply, int yMultiply, int xCenter, int yCenter) {  	for (int idx = 0; idx < count; ++idx) {  		Object *obj = ObjList[idx];  		Common::Point pt(obj->_position.x - xCenter, obj->_position.y - yCenter); -		if ((obj->_position.x <= 319) && (obj->_position.x >= 0) &&  +		if ((obj->_position.x <= 319) && (obj->_position.x >= 0) &&  				(obj->_position.y <= 199) && (obj->_position.y >= 0)) {  			if (!pt.x && !pt.y) {  				pt.x = pt.y = 1; @@ -2484,7 +2484,7 @@ void Scene205::handleText() {  	GfxFont font;  	font.setFontNumber(4);  	int width = font.getStringWidth(_message.c_str()); -	 +  	_textList[_textIndex].setPosition(Common::Point(160 - (width / 2), _yp));  } @@ -2681,13 +2681,13 @@ void Scene250::signal() {  		_field412 += 12;  		R2_GLOBALS._player.setPosition(Common::Point(261, 185));  		ADD_MOVER(R2_GLOBALS._player, 261, 15); -		 +  		if ((_field414 - 12) == _field412)  			_sceneMode = 4;  		break;  	case 4:  		_sound1.play(21); -		 +  		_currentFloor.setPosition(Common::Point(111, _currentFloor._position.y + 12));  		R2_GLOBALS._player.setPosition(Common::Point(261, 185));  		ADD_MOVER(R2_GLOBALS._player, 261, 15); @@ -2837,7 +2837,7 @@ void Scene300::Action2::signal() {  	case 2:  		if (!R2_GLOBALS._playStream.isPlaying())  			_actionIndex = R2_GLOBALS._randomSource.getRandomNumber(1); -			 +  		setDelay(60 + R2_GLOBALS._randomSource.getRandomNumber(119));  		break;  	default: @@ -2860,7 +2860,7 @@ void Scene300::Action3::signal() {  	case 2:  		if (!R2_GLOBALS._playStream.isPlaying())  			_actionIndex = R2_GLOBALS._randomSource.getRandomNumber(1); -			 +  		setDelay(60 + R2_GLOBALS._randomSource.getRandomNumber(119));  		break;  	default: @@ -2922,7 +2922,7 @@ bool Scene300::MirandaWorkstation::startAction(CursorType action, Event &event)  		if (R2_GLOBALS._player._characterIndex != 3)  			SceneItem::display2(300, 49);  		else -			R2_GLOBALS._sceneManager.changeScene(325);			 +			R2_GLOBALS._sceneManager.changeScene(325);  		return true;  	case CURSOR_LOOK: @@ -2952,7 +2952,7 @@ bool Scene300::SeekerWorkstation::startAction(CursorType action, Event &event) {  		if (R2_GLOBALS._player._characterIndex != 2)  			SceneItem::display2(300, 48);  		else -			R2_GLOBALS._sceneManager.changeScene(325);			 +			R2_GLOBALS._sceneManager.changeScene(325);  		return true;  	default: @@ -3107,7 +3107,7 @@ bool Scene300::Seeker::startAction(CursorType action, Event &event) {  		scene->_sceneMode = 310;  		scene->setAction(&scene->_sequenceManager1, scene, 310, &R2_GLOBALS._player, NULL);  		return true; -	 +  	default:  		break;  	} @@ -3153,7 +3153,7 @@ bool Scene300::Doorway::startAction(CursorType action, Event &event) {  	Scene300 *scene = (Scene300 *)R2_GLOBALS._sceneManager._scene;  	if (action == CURSOR_USE) { -		if ((R2_GLOBALS._player._characterIndex == R2_QUINN) &&  +		if ((R2_GLOBALS._player._characterIndex == R2_QUINN) &&  				(!R2_GLOBALS.getFlag(44) || R2_GLOBALS._player._characterScene[R2_MIRANDA] == 500)) {  			R2_GLOBALS._player.disableControl();  			scene->_sceneMode = 301; @@ -3161,7 +3161,7 @@ bool Scene300::Doorway::startAction(CursorType action, Event &event) {  		} else {  			SceneItem::display2(300, 45);  		} -		 +  		return true;  	} else {  		return SceneActor::startAction(action, event); @@ -3373,7 +3373,7 @@ void Scene300::postInit(SceneObjectList *OwnerList) {  				R2_GLOBALS._player.setup(302, 3, 1);  				R2_GLOBALS._player.setPosition(Common::Point(271, 150));  				R2_GLOBALS._player.setAction(&_action1); -				 +  				if (R2_GLOBALS.getFlag(55)) {  					if (R2_GLOBALS.getFlag(57)) {  						R2_GLOBALS.clearFlag(60); @@ -3689,7 +3689,7 @@ void Scene300::signal309() {  	if (R2_GLOBALS.getFlag(39))  		R2_GLOBALS._stripManager_lookupList[1] = 2; -	 +  	if (R2_GLOBALS.getFlag(5))  		R2_GLOBALS._stripManager_lookupList[1] = 3; @@ -3728,7 +3728,7 @@ Scene325::Icon::Icon(): SceneActor()  {  void Scene325::Icon::postInit(SceneObjectList *OwnerList) {  	SceneObject::postInit(); -	 +  	_object1.postInit();  	_object1.fixPriority(21);  	_object1.hide(); @@ -3895,7 +3895,7 @@ Scene325::Scene325(): SceneExt() {  	_field416 = _field418 = 0;  	_field41A = _field41C = _field41E = _field420 = 0;  	_soundCount = _soundIndex = 0; -	 +  	for (int idx = 0; idx < 10; ++idx)  		_soundQueue[idx] = 0;  } @@ -3907,7 +3907,7 @@ void Scene325::postInit(SceneObjectList *OwnerList) {  	R2_GLOBALS.clearFlag(50);  	_stripManager.addSpeaker(&_quinnSpeaker);  	_palette.loadPalette(0); -	 +  	R2_GLOBALS._player.postInit();  	R2_GLOBALS._player.hide();  	R2_GLOBALS._player.disableControl(); @@ -3917,7 +3917,7 @@ void Scene325::postInit(SceneObjectList *OwnerList) {  	_sceneMode = 1;  	signal();  } -	 +  void Scene325::synchronize(Serializer &s) {  	SceneExt::synchronize(s); @@ -3953,7 +3953,7 @@ void Scene325::signal() {  		_icon4.postInit();  		_icon4._sceneRegionId = 5; -		setAction(&_sequenceManager1, this, 127, &_icon1, &_icon2, &_icon3, &_icon4,  +		setAction(&_sequenceManager1, this, 127, &_icon1, &_icon2, &_icon3, &_icon4,  			&R2_GLOBALS._player, NULL);  		_sceneMode = 2;  		break; @@ -3969,7 +3969,7 @@ void Scene325::signal() {  		_icon2._object2.postInit();  		_icon2._object2.setup(160, 7, 2);  		_icon2._object2.setPosition(Common::Point(106, 56)); -		 +  		_icon3.setup(160, 1, 1);  		_icon3.setPosition(Common::Point(65, 47));  		_icon3._object2.postInit(); @@ -4008,7 +4008,7 @@ void Scene325::signal() {  			_object3.postInit();  			if (R2_GLOBALS.getFlag(13)) {  				_object4.postInit(); -				setAction(&_sequenceManager1, this, 130, &R2_GLOBALS._player, &_object1,  +				setAction(&_sequenceManager1, this, 130, &R2_GLOBALS._player, &_object1,  					&_object2, &_object3, &_object4, NULL);  			} else {  				setAction(&_sequenceManager1, this, 129, &R2_GLOBALS._player, &_object1, @@ -4042,12 +4042,12 @@ void Scene325::signal() {  					_object13.setup(326, 4, 2);  					_object13.setPosition(Common::Point(149, (int)(_field420 * ADJUST_FACTOR)));  					_object13.fixPriority(21); -					 +  					_object10.postInit();  					_object10.setup(326, 1, 1);  					_object10.setPosition(Common::Point(210, 20));  					_object10.fixPriority(10); -					 +  					_object1.postInit();  					_object1.setup(326, 1, 1);  					_object1.setPosition(Common::Point(210, 32)); @@ -4072,7 +4072,7 @@ void Scene325::signal() {  					_object5.setup(326, 1, 1);  					_object5.setPosition(Common::Point(210, 80));  					_object5.fixPriority(10); -				 +  					_object6.postInit();  					_object6.setup(326, 1, 1);  					_object6.setPosition(Common::Point(210, 92)); @@ -4450,7 +4450,7 @@ void Scene325::dispatch() {  		for (int idx = 0; idx < 4; ++idx)  			_objList[idx].remove(); -	 +  		if (flag) {  			int v = _field420 - 758;  			_object10.setFrame((v++ <= 0) ? 1 : v); @@ -4522,7 +4522,7 @@ void Scene325::setMessage(int resNum, int lineNum) {  		_text1.setPosition(Common::Point(49, 19));  		R2_GLOBALS._sceneObjects->draw(); -		 +  		if ((_soundCount != 0) && (R2_GLOBALS._speechSubtitles != 2)) {  			_sceneMode = 15;  			R2_GLOBALS._playStream.play(_soundQueue[_soundIndex++], this); @@ -4804,7 +4804,7 @@ bool Scene500::ControlPanel::startAction(CursorType action, Event &event) {  	if ((action == CURSOR_USE) && (R2_GLOBALS._player._characterIndex == R2_QUINN)) {  		R2_GLOBALS._player.disableControl(); -		 +  		if (R2_GLOBALS.getFlag(26)) {  			scene->_stripNumber = 1104;  			scene->_sceneMode = 524; @@ -4818,7 +4818,7 @@ bool Scene500::ControlPanel::startAction(CursorType action, Event &event) {  		return SceneHotspot::startAction(action, event);  	}  } -	 +  /*--------------------------------------------------------------------------*/  bool Scene500::Object2::startAction(CursorType action, Event &event) { @@ -4910,7 +4910,7 @@ bool Scene500::Doorway::startAction(CursorType action, Event &event) {  			scene->setAction(&scene->_sequenceManager1, scene, 524, &R2_GLOBALS._player, NULL);  		} else {  			scene->_sceneMode = 500; -			scene->setAction(&scene->_sequenceManager1, scene, 500, &R2_GLOBALS._player, NULL);  +			scene->setAction(&scene->_sequenceManager1, scene, 500, &R2_GLOBALS._player, NULL);  		}  		return true; @@ -4931,17 +4931,17 @@ bool Scene500::OxygenTanks::startAction(CursorType action, Event &event) {  		if (R2_GLOBALS._player._characterIndex != R2_QUINN) {  			SceneItem::display2(500, 52);  			return true; -		} else if ((R2_INVENTORY.getObjectScene(R2_REBREATHER_TANK) != 1) &&  +		} else if ((R2_INVENTORY.getObjectScene(R2_REBREATHER_TANK) != 1) &&  				(R2_GLOBALS._player._characterIndex != R2_SEEKER) && !R2_GLOBALS.getFlag(28)) {  			R2_GLOBALS._player.disableControl(); -			 +  			if (_position.y == 120) {  				scene->_sceneMode = 513; -				scene->setAction(&scene->_sequenceManager1, scene, scene->_sceneMode, &R2_GLOBALS._player,  +				scene->setAction(&scene->_sequenceManager1, scene, scene->_sceneMode, &R2_GLOBALS._player,  					&scene->_tanks1, NULL);  			} else {  				scene->_sceneMode = 514; -				scene->setAction(&scene->_sequenceManager1, scene, scene->_sceneMode, &R2_GLOBALS._player,  +				scene->setAction(&scene->_sequenceManager1, scene, scene->_sceneMode, &R2_GLOBALS._player,  					&scene->_tanks2, NULL);  			}  			return true; @@ -4961,7 +4961,7 @@ bool Scene500::AirLock::startAction(CursorType action, Event &event) {  	if ((action == CURSOR_USE) && R2_GLOBALS.getFlag(26)) {  		R2_GLOBALS._player.disableControl();  		scene->_sceneMode = (R2_GLOBALS._player._characterIndex == R2_QUINN) ? 521 : 522; -		scene->setAction(&scene->_sequenceManager1, scene, scene->_sceneMode, &R2_GLOBALS._player,  +		scene->setAction(&scene->_sequenceManager1, scene, scene->_sceneMode, &R2_GLOBALS._player,  			&scene->_object2, &scene->_airLock, NULL);  		return true;  	} else { @@ -5144,7 +5144,7 @@ void Scene500::postInit(SceneObjectList *OwnerList) {  	_object1.setup(502, 1, 1);  	_object1.setPosition(Common::Point(258, 99));  	_object1.fixPriority(50); -	 +  	_object8.postInit();  	_object8.setPosition(Common::Point(250, 111)); @@ -5322,16 +5322,16 @@ void Scene525::postInit(SceneObjectList *OwnerList) {  	loadScene(525);  	R2_GLOBALS._uiElements._active = false;  	SceneExt::postInit(); -	 +  	R2_GLOBALS._sound1.play(105); -	 +  	_actor1.postInit();  	_actor1._effect = 1; -	 +  	R2_GLOBALS._player.postInit();  	R2_GLOBALS._player.animate(ANIM_MODE_1, NULL);  	R2_GLOBALS._player.disableControl(); -	 +  	setAction(&_sequenceManager, this, 525, &R2_GLOBALS._player, &_actor1, NULL);  } @@ -5340,7 +5340,7 @@ void Scene525::signal() {  }  /*-------------------------------------------------------------------------- - * Scene 600 -  + * Scene 600 -   *   *--------------------------------------------------------------------------*/  Scene600::Scene600() { @@ -5368,28 +5368,28 @@ bool Scene600::Item1::startAction(CursorType action, Event &event) {  bool Scene600::Item4::startAction(CursorType action, Event &event) {  	if ((action != R2_NEGATOR_GUN) || (!R2_GLOBALS.getFlag(1)))  		return SceneHotspot::startAction(action, event); -	 +  	if ((R2_GLOBALS.getFlag(5)) && (!R2_GLOBALS.getFlag(8))) {  		SceneItem::display(600, 32, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, -999);  		return true;  	} -	 +  	if (R2_GLOBALS.getFlag(5)) {  		SceneItem::display(600, 30, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, -999);  		return true;  	} -	 +  	if ((!R2_GLOBALS.getFlag(8)) || (R2_GLOBALS.getFlag(9)))  		return SceneHotspot::startAction(action, event);  	R2_GLOBALS._player.disableControl(); -	 +  	Scene600 *scene = (Scene600 *)R2_GLOBALS._sceneManager._scene;  	scene->_object1.setup2(603, 3, 1, 239, 54, 10, 0);  	scene->_actor3.postInit();  	scene->_actor2.postInit(); -	 +  	scene->_sceneMode = 612;  	setAction(&scene->_sequenceManager1, this, 612, &scene->_actor3, &scene->_actor2, &R2_GLOBALS._player, NULL);  	return true; @@ -5405,7 +5405,7 @@ bool Scene600::Actor4::startAction(CursorType action, Event &event) {  	if ((action >= CURSOR_WALK) && (action < R2CURSORS_START))  	// Only action cursors  		return SceneActor::startAction(action, event); -	 +  	return false;  } @@ -5417,10 +5417,10 @@ void Scene600::Actor4::draw() {  bool Scene600::Actor5::startAction(CursorType action, Event &event) {  	if ((action < CURSOR_WALK) && (action >= R2CURSORS_START))  		return false; -		 +  	if (action != CURSOR_USE)  		return SceneActor::startAction(action, event); -	 +  	Scene600 *scene = (Scene600 *)R2_GLOBALS._sceneManager._scene;  	if ((R2_INVENTORY.getObjectScene(R2_CLAMP) == 600) && (!R2_GLOBALS.getFlag(6))) { @@ -5431,17 +5431,17 @@ bool Scene600::Actor5::startAction(CursorType action, Event &event) {  		scene->setAction(&scene->_sequenceManager1, scene, 609, &R2_GLOBALS._player, &scene->_actor5, &scene->_actor6, &scene->_actor1, NULL);  		return true;  	} -	 +  	if (_frame != 1)  		return false; -	 +  	if (!R2_GLOBALS.getFlag(6)) {  		R2_GLOBALS._player.disableControl();  		scene->_sceneMode = 616;  		scene->setAction(&scene->_sequenceManager1, scene, 616, &R2_GLOBALS._player, &scene->_actor5, &scene->_actor6, NULL);  		return true;  	} -	 +  	if ((R2_GLOBALS.getFlag(9)) && (R2_INVENTORY.getObjectScene(R2_COM_SCANNER) == 600))  		SceneItem::display(600, 31, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, -999);  	else { @@ -5860,10 +5860,10 @@ bool Scene700::Actor2::startAction(CursorType action, Event &event) {  	if (action != CURSOR_USE)  		return SceneActor::startAction(action, event); -	 +  	if (R2_GLOBALS._player._position.y <= 100)  		return false; -	 +  	R2_GLOBALS._player.disableControl();  	scene->_sceneMode = 701;  	scene->setAction(&scene->_sequenceManager, scene, 701, &R2_GLOBALS._player, this, NULL); @@ -5876,10 +5876,10 @@ bool Scene700::Actor3::startAction(CursorType action, Event &event) {  	if (action != CURSOR_USE)  		return SceneActor::startAction(action, event); -	 +  	if (R2_GLOBALS._player._position.y <= 100)  		return false; -	 +  	R2_GLOBALS._player.disableControl();  	scene->_sceneMode = 702;  	scene->setAction(&scene->_sequenceManager, scene, 702, &R2_GLOBALS._player, this, NULL); @@ -5892,10 +5892,10 @@ bool Scene700::Actor4::startAction(CursorType action, Event &event) {  	if (action != CURSOR_USE)  		return SceneActor::startAction(action, event); -	 +  	if (R2_GLOBALS._player._position.y <= 100)  		return false; -	 +  	R2_GLOBALS._player.disableControl();  	scene->_sceneMode = 704;  	scene->setAction(&scene->_sequenceManager, scene, 704, &R2_GLOBALS._player, this, NULL); @@ -5951,7 +5951,7 @@ bool Scene700::Actor5::startAction(CursorType action, Event &event) {  		return SceneActor::startAction(action, event);  		break;  	} -	 +  	return true;  } @@ -5960,7 +5960,7 @@ bool Scene700::Actor6::startAction(CursorType action, Event &event) {  	if ((action != CURSOR_USE) || (R2_GLOBALS._player._position.y >= 100))  		return SceneActor::startAction(action, event); -	 +  	R2_GLOBALS._player.disableControl();  	scene->_sceneMode = 1;  	Common::Point pt(_position.x, 69); @@ -5973,7 +5973,7 @@ bool Scene700::Actor6::startAction(CursorType action, Event &event) {  void Scene700::postInit(SceneObjectList *OwnerList) {  	if (R2_GLOBALS._sceneManager._previousScene == 900)  		g_globals->gfxManager()._bounds.moveTo(Common::Point(160, 0)); -	 +  	loadScene(700);  	R2_GLOBALS._v558B6.set(60, 0, 260, 200);  	SceneExt::postInit(); @@ -5993,7 +5993,7 @@ void Scene700::postInit(SceneObjectList *OwnerList) {  	_actor3.setPosition(Common::Point(217, 120));  	_actor3.fixPriority(10);  	_actor3.setDetails(700, 15, -1, -1, 1, (SceneItem *) NULL); -	 +  	_actor1.postInit();  	_actor1.setup(700, 4, 1);  	_actor1.setPosition(Common::Point(355 - ((R2_GLOBALS._v565E3 * 8) / 5), ((R2_GLOBALS._v565E1 + 20 ) / 5) - 12)); @@ -6132,7 +6132,7 @@ void Scene700::remove() {  	R2_GLOBALS._sound1.play(10);  // CHECKME: Present in the original... But it crashes badly.  // The instruction was removed as it's not used in other scene coded the same way -// and reversed by dreammaster. A double check is required in order to verify it doesn't hide  +// and reversed by dreammaster. A double check is required in order to verify it doesn't hide  // a memory leak  //	_rotation->remove();  	SceneExt::remove(); @@ -6445,7 +6445,7 @@ void Scene800::postInit(SceneObjectList *OwnerList) {  	if (R2_INVENTORY.getObjectScene(R2_READER) == 800) {  		_reader.postInit(); -		 +  		if (R2_INVENTORY.getObjectScene(R2_OPTICAL_FIBRE) == 800) {  			_opticalFibre.setup(800, 4, 1);  			_reader.hide(); @@ -6776,7 +6776,7 @@ void Scene825::process(Event &event) {  }  void Scene825::dispatch() { -	if (R2_GLOBALS._sceneObjects->contains(&_object4) &&  +	if (R2_GLOBALS._sceneObjects->contains(&_object4) &&  			((_object4._frame == 1) || (_object4._frame == 3)) &&  			(_object4._frame != _frame1)) {  		_sound2.play(25); @@ -6828,7 +6828,7 @@ void Scene825::doButtonPress(int buttonId) {  					_sceneText.setup(NO_TREATMENT_REQUIRED);  				} else {  					_button6._buttonId = 5; -					 +  					_object5.postInit();  					setAction(&_sequenceManager1, this, 827, &_object5, NULL);  				} @@ -6853,7 +6853,7 @@ void Scene825::doButtonPress(int buttonId) {  		case 4:  			_sound4.play(27);  			_button6._buttonId = 5; -			 +  			_object1.postInit();  			_object1.setup(826, 7, 1);  			_object1.setPosition(Common::Point(112, 67)); @@ -7002,7 +7002,7 @@ bool Scene850::Panel::startAction(CursorType action, Event &event) {  		scene->_sceneMode = 852;  		scene->setAction(&scene->_sequenceManager1, scene, 852, &R2_GLOBALS._player, this, &scene->_object1, NULL);  		return true; -	}		 +	}  }  /*--------------------------------------------------------------------------*/ @@ -7171,7 +7171,7 @@ bool Scene900::Actor4::startAction(CursorType action, Event &event) {  					scene->_aSound1.play(53);  					setup(900, 3, 9);  					R2_GLOBALS._v565E5 = 0; -					 +  					if ((R2_INVENTORY.getObjectScene(R2_CABLE_HARNESS) == 0) && (R2_INVENTORY.getObjectScene(R2_ATTRACTOR_CABLE_HARNESS) == 700) && (scene->_actor2._frame < 8) && (scene->_actor2._animateMode != ANIM_MODE_5)) {  							scene->_actor2.animate(ANIM_MODE_5, NULL);  					} else if ((R2_INVENTORY.getObjectScene(R2_CABLE_HARNESS) == 700) && (R2_INVENTORY.getObjectScene(R2_ATTRACTOR_CABLE_HARNESS) == 700) && (scene->_actor2._frame < 8)) { @@ -7292,7 +7292,7 @@ void Scene900::postInit(SceneObjectList *OwnerList) {  		_actor2.postInit();  		_actor2.setPosition(Common::Point(0, 0));  		_actor2.fixPriority(1); -		 +  		if (R2_INVENTORY.getObjectScene(R2_CABLE_HARNESS) == 0) {  			if (R2_INVENTORY.getObjectScene(R2_ATTRACTOR_CABLE_HARNESS) != 700) {  				_actor2.setup(901, 3, 2); @@ -7321,7 +7321,7 @@ void Scene900::postInit(SceneObjectList *OwnerList) {  void Scene900::remove() {  	if (_sceneMode != 901)  		R2_GLOBALS._sound1.play(10); -	 +  	SceneExt::remove();  } @@ -7348,7 +7348,7 @@ void Scene900::signal() {  		break;  	case 2:  		_field412 = 2; -		 +  		_actor5.remove();  		_actor6.remove(); @@ -7358,7 +7358,7 @@ void Scene900::signal() {  		else  			_actor5.setup(900, 3, 11);  		_actor5.setPosition(Common::Point(36, 166)); -		 +  		_actor7.sub96135(5);  		_actor7.setup(900, 3, 3);  		_actor7.setPosition(Common::Point(76, 134)); @@ -7374,7 +7374,7 @@ void Scene900::signal() {  		_actor10.sub96135(7);  		_actor10.setup(900, 3, 5);  		_actor10.setPosition(Common::Point(99, 144)); -		 +  		break;  	case 3:  		_field412 = 3; @@ -7405,11 +7405,11 @@ void Scene900::signal() {  		R2_GLOBALS._player._canWalk = false;  		_actor1.setup(900, 1, 1); -		 +  		_actor4.sub96135(1);  		_actor4.setup(900, 1, 3);  		_actor4.setPosition(Common::Point(77, 168)); -		 +  		_sceneMode = 1;  		signal();  		break; diff --git a/engines/tsage/ringworld2/ringworld2_scenes0.h b/engines/tsage/ringworld2/ringworld2_scenes0.h index d757080156..e39efbca3d 100644 --- a/engines/tsage/ringworld2/ringworld2_scenes0.h +++ b/engines/tsage/ringworld2/ringworld2_scenes0.h @@ -45,9 +45,9 @@ class Scene50: public SceneExt {  	public:  		void signal();  	}; -	 +  public: -	Action1 _action1;	 +	Action1 _action1;  	virtual void postInit(SceneObjectList *OwnerList = NULL);  	virtual void process(Event &event); @@ -208,7 +208,7 @@ public:  	SequenceManager _sequenceManager;  	Action1 _action1;  	ASoundExt _sound1; -	 +  	int _frameNumber;  	int _field412, _field480;  	int _field482, _frameInc; @@ -217,7 +217,7 @@ public:  public:  	Scene180(); -	virtual void postInit(SceneObjectList *OwnerList = NULL);	 +	virtual void postInit(SceneObjectList *OwnerList = NULL);  	virtual void synchronize(Serializer &s);  	virtual void remove();  	virtual void signal(); @@ -283,7 +283,7 @@ class Scene205: public SceneExt {  	};  private:  	void setup(); -	void processList(Object **ObjList, int count, const Common::Rect &bounds,  +	void processList(Object **ObjList, int count, const Common::Rect &bounds,  					int xMultiply, int yMultiply, int xCenter, int yCenter);  	void handleText();  public: @@ -445,7 +445,7 @@ class Scene325: public SceneExt {  		void showIcon();  		void hideIcon();  	}; -	 +  private:  	void removeText();  	void consoleAction(int id); @@ -531,7 +531,7 @@ class Scene500: public SceneExt {  	public:  		virtual bool startAction(CursorType action, Event &event);  	}; -	 +  	/* Objects */  	class Object2: public SceneActor {  	public: diff --git a/engines/tsage/ringworld2/ringworld2_scenes1.cpp b/engines/tsage/ringworld2/ringworld2_scenes1.cpp index 23a9eb2590..304d3a4298 100644 --- a/engines/tsage/ringworld2/ringworld2_scenes1.cpp +++ b/engines/tsage/ringworld2/ringworld2_scenes1.cpp @@ -118,7 +118,7 @@ void Scene1020::postInit(SceneObjectList *OwnerList) {  	if (R2_GLOBALS._sceneManager._previousScene == 1010)  		_sceneMode = 0; -	else  +	else  		_sceneMode = 10;  } @@ -345,7 +345,7 @@ void Scene1100::postInit(SceneObjectList *OwnerList) {  	}  	SceneExt::postInit(); -		 +  	if (R2_GLOBALS._sceneManager._previousScene == -1)  		R2_GLOBALS._sceneManager._previousScene = 1000; @@ -397,7 +397,7 @@ void Scene1100::postInit(SceneObjectList *OwnerList) {  			_actor18.setDetails(1100, 4, -1, -1, 1, (SceneItem *) NULL);  		else  			_actor18.setDetails(1100, 3, -1, -1, 1, (SceneItem *) NULL); -		 +  		_actor17.postInit();  		_actor17.setup(1105, 3, 1);  		_actor17.setPosition(Common::Point(312, 165)); @@ -450,7 +450,7 @@ void Scene1100::postInit(SceneObjectList *OwnerList) {  		_actor4._field9C = _field312;  		R2_GLOBALS._sound1.play(86); -		 +  		_sceneMode = 0;  		setAction(&_sequenceManager1, this, 1, &R2_GLOBALS._player, NULL); @@ -463,7 +463,7 @@ void Scene1100::postInit(SceneObjectList *OwnerList) {  		R2_GLOBALS._player.postInit();  		R2_GLOBALS._player.animate(ANIM_MODE_1, NULL); -		 +  		_actor16.postInit();  		if (R2_GLOBALS.getFlag(52)) { @@ -492,7 +492,7 @@ void Scene1100::postInit(SceneObjectList *OwnerList) {  			R2_GLOBALS._player.enableControl();  			R2_GLOBALS._player._canWalk = false;  		} -		 +  		if (R2_GLOBALS._player._characterIndex == 1)  			_actor16.setDetails(9002, 0, 4, 3, 1, (SceneItem *) NULL);  		else @@ -535,7 +535,7 @@ void Scene1100::postInit(SceneObjectList *OwnerList) {  	_item6.setDetails(Rect(123, 69, 222, 105), 1100, 13, -1, -1, 1, NULL);  	_item2.setDetails(Rect(0, 0, 480, 46), 1100, 0, -1, -1, 1, NULL);  	_item1.setDetails(Rect(0, 0, 480, 200), 1100, 40, 41, 42, 1, NULL); -}	 +}  void Scene1100::remove() {  	R2_GLOBALS._scrollFollower = &R2_GLOBALS._player; @@ -703,7 +703,7 @@ void Scene1100::signal() {  		R2_GLOBALS._player.disableControl();  		R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS);  		_stripManager.start(302, this); -		break;		 +		break;  	case 27:  		R2_GLOBALS._player.disableControl();  		setAction(&_sequenceManager1, this, 1120, &_actor16, &R2_GLOBALS._player, NULL); @@ -761,7 +761,7 @@ void Scene1100::signal() {  			R2_GLOBALS._player.disableControl();  			_sceneMode = 1125;  			setAction(&_sequenceManager1, this, 1125, &R2_GLOBALS._player, &_actor16, NULL); -		} else  +		} else  			R2_GLOBALS._player.enableControl(CURSOR_TALK);  		break;  	case 55: @@ -832,22 +832,22 @@ void Scene1100::dispatch() {  			R2_GLOBALS._scenePalette.refresh();  		_field414 = 1;  	} -	 +  	Scene::dispatch(); -	 +  	if (R2_GLOBALS._player._bounds.contains(_actor13._position))  		_actor13._shade = 3; -	else  +	else  		_actor13._shade = 0;  	if (R2_GLOBALS._player._bounds.contains(_actor14._position))  		_actor14._shade = 3; -	else  +	else  		_actor14._shade = 0;  	if (R2_GLOBALS._player._bounds.contains(_actor15._position))  		_actor15._shade = 3; -	else  +	else  		_actor15._shade = 0;  } @@ -952,7 +952,7 @@ void Scene1200::Area1::Actor3::init(int state) {  bool Scene1200::Area1::Actor3::startAction(CursorType action, Event &event) {  	if (action != CURSOR_USE)  		return SceneActor::startAction(action, event); -	 +  	R2_GLOBALS._sound2.play(260);  	switch (_state) {  	case 1: @@ -1002,10 +1002,10 @@ bool Scene1200::Area1::Actor3::startAction(CursorType action, Event &event) {  	default:  		break;  	} -	 +  	Scene1200 *scene = (Scene1200 *)R2_GLOBALS._sceneManager._scene;  	scene->_field418 = 0; -	 +  	if ((R2_GLOBALS._v56AA6 == 1) && (R2_GLOBALS._v56AA7 == 1) && (R2_GLOBALS._v56AA8 == 1))  		scene->_field418 = 1;  	else if ((R2_GLOBALS._v56AA6 == 2) && (R2_GLOBALS._v56AA7 == 1) && (R2_GLOBALS._v56AA8 == 1)) @@ -1014,7 +1014,7 @@ bool Scene1200::Area1::Actor3::startAction(CursorType action, Event &event) {  		scene->_field418 = 3;  	else if ((R2_GLOBALS._v56AA6 == 2) && (R2_GLOBALS._v56AA7 == 3) && (R2_GLOBALS._v56AA8 == 1))  		scene->_field418 = 4; -	 +  	return true;  } @@ -1035,7 +1035,7 @@ void Scene1200::Area1::postInit(SceneObjectList *OwnerList) {  void Scene1200::Area1::remove() {  	Scene1200 *scene = (Scene1200 *)R2_GLOBALS._sceneManager._scene; -	 +  	scene->_field41A = 0;  	warning("Unexpected _sceneAreas.remove() call");  //	scene->_sceneAreas.remove(&_actor3); @@ -1044,14 +1044,14 @@ void Scene1200::Area1::remove() {  	_actor3.remove();  	_actor4.remove();  	_actor5.remove(); -	 +  	// sub201EA  	R2_GLOBALS._sceneItems.remove((SceneItem *)this);  	_actor2.remove();  	SceneArea::remove();  	R2_GLOBALS._insetUp--;  	// -	 +  	R2_GLOBALS._player._canWalk = true;  } @@ -1388,9 +1388,9 @@ void Scene1200::signal() {  void Scene1200::process(Event &event) {  	if (_field414 != 0)  		return; -	 +  	Scene::process(event); -	 +  	if (!R2_GLOBALS._player._canWalk)  		return; @@ -1405,10 +1405,10 @@ void Scene1200::process(Event &event) {  			if ((event.mousePos.x > 109) && (event.mousePos.x < 140) && (event.mousePos.y > 50) && (event.mousePos.y < 89))  				sub9DAD6(2); -				 +  			if ((event.mousePos.x > 140) && (event.mousePos.x < 179) && (event.mousePos.y > 89) && (event.mousePos.y < 120))  				sub9DAD6(3); -				 +  			if ((event.mousePos.x > 140) && (event.mousePos.x < 179) && (event.mousePos.y > 19) && (event.mousePos.y < 50))  				sub9DAD6(4);  			break; @@ -1511,7 +1511,7 @@ void Scene1200::process(Event &event) {  			event.handled = false;  			return;  		} -		 +  		switch (event.kbd.keycode) {  		case Common::KEYCODE_1:  			warning("FIXME: keycode = 0x4800"); @@ -1538,7 +1538,7 @@ void Scene1200::process(Event &event) {  		return;  	}  } -	 +  void Scene1200::dispatch() {  	Rect tmpRect;  	Scene::dispatch(); @@ -1550,7 +1550,7 @@ void Scene1200::dispatch() {  		warning("tmpRect.sub14DF3();");  		_field41C = 0;  	} -	 +  	if (_field414 != 0) {  		tmpRect.set(110, 20, 210, 120);  		_field414--; @@ -1575,7 +1575,7 @@ void Scene1200::dispatch() {  		_object1.sub51B02();  		warning("_gfxManager.sub294AC(unk);");  		warning("tmpRect.sub14DF3();"); -		 +  		if (_field416 != 0) {  			switch(_field412 - 1) {  			case 0: @@ -1664,7 +1664,7 @@ void Scene1337::Action1337::subD18B5(int resNum, int stripNum, int frameNum) {  void Scene1337::Action1337::skipFrames(int32 skipCount) {  	uint32 firstFrameNumber = g_globals->_events.getFrameNumber();  	uint32 tmpFrameNumber = firstFrameNumber; -	 +  	while (tmpFrameNumber < firstFrameNumber + skipCount)  		tmpFrameNumber = g_globals->_events.getFrameNumber(); @@ -1824,7 +1824,7 @@ void Scene1337::Action1::signal() {  		scene->_aSound1.play(62);  		R2_GLOBALS._sceneObjects->draw(); -		 +  		skipFrames(120);  		scene->_arrunkObj1337[2]._arr2[0]._object1.remove();  		scene->_arrunkObj1337[2]._arr2[1]._object1.remove(); @@ -1938,7 +1938,7 @@ void Scene1337::Action1::signal() {  		scene->_arrunkObj1337[0]._arr1[2]._object1.fixPriority(170);  		R2_GLOBALS._sceneObjects->draw(); -		 +  		scene->actionDisplay(1331, 10, 159, 10, 1, 200, 0, 7, 0, 154, 154);  		scene->_item2._object1.setPosition(Common::Point(162, 95), 0);  		scene->_item2._object1.show(); @@ -1976,7 +1976,7 @@ void Scene1337::Action1::signal() {  		scene->_item2._object1.setStrip(scene->_arrunkObj1337[2]._arr1[2]._object1._strip);  		scene->_item2._object1.setFrame(scene->_arrunkObj1337[2]._arr1[2]._object1._frame);  		scene->_item2._object1.animate(ANIM_MODE_NONE, NULL); -		 +  		scene->_arrunkObj1337[2]._arr1[2]._field34 = 0;  		scene->_arrunkObj1337[2]._arr1[2]._object1.remove(); @@ -2102,7 +2102,7 @@ void Scene1337::Action1::signal() {  		R2_GLOBALS._sceneObjects->draw();  		skipFrames(240); -		 +  		scene->_arrObject1[0].remove();  		scene->_arrObject1[1].remove();  		scene->_arrObject1[2].remove(); @@ -2125,7 +2125,7 @@ void Scene1337::Action1::signal() {  		scene->_arrunkObj1337[2]._arr3[0]._field34 = 0;  		scene->_arrunkObj1337[2]._arr3[0]._object1.remove(); -		 +  		scene->_item2._object1.setPosition(scene->_arrunkObj1337[2]._arr3[0]._field36, 0);  		scene->_item2._object1.show(); @@ -2219,7 +2219,7 @@ void Scene1337::Action1::signal() {  		R2_GLOBALS._sceneObjects->draw();  		skipFrames(240); -		 +  		scene->_arrObject1[0].remove();  		scene->_arrObject1[1].remove();  		scene->_arrObject1[2].remove(); @@ -2289,7 +2289,7 @@ void Scene1337::Action1::signal() {  		scene->_arrObject2[0].setStrip(7);  		scene->_arrObject2[0].setFrame(1);  		scene->_arrObject2[0].fixPriority(180); -			  +  		scene->_arrObject1[1].postInit();  		scene->_arrObject1[1].setVisage(1332);  		scene->_arrObject1[1].setPosition(Common::Point(160, 71), 0); @@ -2303,35 +2303,35 @@ void Scene1337::Action1::signal() {  		scene->_arrObject2[1].setStrip(7);  		scene->_arrObject2[1].setFrame(1);  		scene->_arrObject2[1].fixPriority(180); -			  +  		scene->_arrObject1[2].postInit();  		scene->_arrObject1[2].setVisage(1332);  		scene->_arrObject1[2].setPosition(Common::Point(131, 100), 0);  		scene->_arrObject1[2].fixPriority(190);  		scene->_arrObject1[2].setStrip(4);  		scene->_arrObject1[2].setFrame(4); -			  +  		scene->_arrObject2[2].postInit();  		scene->_arrObject2[2].setVisage(1332);  		scene->_arrObject2[2].setPosition(Common::Point(131, 100), 0);  		scene->_arrObject2[2].setStrip(7);  		scene->_arrObject2[2].setFrame(1);  		scene->_arrObject2[2].fixPriority(180); -			  +  		scene->_arrObject1[3].postInit();  		scene->_arrObject1[3].setVisage(1332);  		scene->_arrObject1[3].setPosition(Common::Point(160, 100), 0);  		scene->_arrObject1[3].fixPriority(190);  		scene->_arrObject1[3].setStrip(4);  		scene->_arrObject1[3].setFrame(2); -			  +  		scene->_arrObject2[3].postInit();  		scene->_arrObject2[3].setVisage(1332);  		scene->_arrObject2[3].setPosition(Common::Point(160, 100), 0);  		scene->_arrObject2[3].setStrip(7);  		scene->_arrObject2[3].setFrame(1);  		scene->_arrObject2[3].fixPriority(180); -			  +  		R2_GLOBALS._sceneObjects->draw();  		skipFrames(240); @@ -2353,14 +2353,14 @@ void Scene1337::Action1::signal() {  		R2_GLOBALS._sceneObjects->draw();  		scene->actionDisplay(1331, 19, 159, 10, 1, 220, 0, 7, 0, 154, 154); -		 +  		scene->_object1.hide();  		scene->actionDisplay(1331, 20, 159, 10, 1, 220, 0, 7, 0, 154, 154);  		scene->actionDisplay(1331, 21, 159, 10, 1, 220, 0, 7, 0, 154, 154);  		scene->_item7._field34 = scene->_arrunkObj1337[2]._arr1[1]._field34; -		 +  		scene->_item2._object1.setStrip(scene->_arrunkObj1337[2]._arr1[1]._object1._strip);  		scene->_item2._object1.setFrame(scene->_arrunkObj1337[2]._arr1[1]._object1._frame);  		scene->_item2._object1.animate(ANIM_MODE_NONE, NULL); @@ -2384,7 +2384,7 @@ void Scene1337::Action1::signal() {  		scene->_item2._object1.animate(ANIM_MODE_2, NULL);  		R2_GLOBALS._sceneObjects->draw(); -		 +  		scene->actionDisplay(1331, 22, 159, 10, 1, 200, 0, 7, 0, 154, 154);  		int i = -1; @@ -2452,13 +2452,13 @@ void Scene1337::Action2::signal() {  		scene->_item7._object1.remove();  		scene->_item7._field34 = 0; -		 +  		scene->_aSound1.play(60);  		scene->_item3._object1.animate(ANIM_MODE_5, this);  		break;  	case 1:  		scene->_item3._object1.setFrame(1); -		 +  		scene->_aSound1.play(60);  		scene->_item3._object1.animate(ANIM_MODE_5, this);  		break; @@ -2482,7 +2482,7 @@ void Scene1337::Action3::signal() {  	Scene1337 *scene = (Scene1337 *)R2_GLOBALS._sceneManager._scene;  	scene->_item2._object1.setPosition(Common::Point(162, 95), 0); -	 +  	switch (_actionIndex++) {  	case 0: {  		scene->_item2._object1._moveDiff = Common::Point(30, 30); @@ -2651,7 +2651,7 @@ void Scene1337::Action3::signal() {  		scene->_arrunkObj1337[0]._arr1[1]._object1.setFrame(1);  		scene->_arrunkObj1337[0]._arr1[1]._object1.fixPriority(170);  		scene->_aSound2.play(61); -		 +  		Common::Point pt(283, 102);  		NpcMover *mover = new NpcMover();  		scene->_item2._object1.addMover(mover, &pt, this); @@ -2668,7 +2668,7 @@ void Scene1337::Action3::signal() {  		scene->_arrunkObj1337[1]._arr1[2]._object1.setFrame(4);  		scene->_arrunkObj1337[1]._arr1[2]._object1.fixPriority(170);  		scene->_aSound2.play(61); -		 +  		Common::Point pt(64, 174);  		NpcMover *mover = new NpcMover();  		scene->_item2._object1.addMover(mover, &pt, this); @@ -2714,7 +2714,7 @@ void Scene1337::Action3::signal() {  		scene->_arrunkObj1337[3]._arr1[2]._object1.setFrame(3);  		scene->_arrunkObj1337[3]._arr1[2]._object1.fixPriority(170);  		scene->_aSound2.play(61); -		 +  		Common::Point pt(226, 5);  		NpcMover *mover = new NpcMover();  		scene->_item2._object1.addMover(mover, &pt, this); @@ -2734,7 +2734,7 @@ void Scene1337::Action3::signal() {  	default:  		break;  	} -	 +  	if (_actionIndex > 12) {  		scene->_field423E = 0;  		R2_GLOBALS._sceneObjects->draw(); @@ -2764,9 +2764,9 @@ void Scene1337::Action4::signal() {  			scene->_arrunkObj1337[scene->_field423E]._arr1[0]._field34 = scene->_field3E28[scene->_field3E24];  			scene->_field3E28[scene->_field3E24] = 0;  			scene->_field3E24--; -			 +  			if (scene->_field3E24 < 0) -				scene->_background2.remove();  +				scene->_background2.remove();  		} else {  			// Self call, forcing next actionIndex  			signal(); @@ -2786,7 +2786,7 @@ void Scene1337::Action4::signal() {  		if ((scene->_field4248 == 1) || (scene->_field423E == 2))  			scene->setAnimationInfo(&scene->_arrunkObj1337[scene->_field423E]._arr1[0]); -			 +  		scene->_item2._object1.hide();  		if ((scene->_arrunkObj1337[scene->_field423E]._arr1[0]._field34 == 0) && (scene->subC264B(scene->_arrunkObj1337[scene->_field423E]._arr3[0]._field34 == 0))) {  			if (scene->_field3E24 < 0) @@ -2798,7 +2798,7 @@ void Scene1337::Action4::signal() {  			NpcMover *mover = new NpcMover();  			scene->_item2._object1.addMover(mover, &scene->_arrunkObj1337[scene->_field423E]._fieldB98, this); -			 +  			scene->_arrunkObj1337[scene->_field423E]._arr1[1]._field34 = scene->_field3E28[scene->_field3E24];  			scene->_field3E28[scene->_field3E24] = 0;  			scene->_field3E24--; @@ -2821,7 +2821,7 @@ void Scene1337::Action4::signal() {  		if ((scene->_field4248 == 1) || (scene->_field423E == 2))  			scene->setAnimationInfo(&scene->_arrunkObj1337[scene->_field423E]._arr1[1]); -			 +  		scene->_item2._object1.hide();  		if ((scene->_arrunkObj1337[scene->_field423E]._arr1[2]._field34 == 0) && (scene->subC264B(scene->_arrunkObj1337[scene->_field423E]._arr3[0]._field34 == 0))) {  			if (scene->_field3E24 < 0) @@ -2833,7 +2833,7 @@ void Scene1337::Action4::signal() {  			NpcMover *mover = new NpcMover();  			scene->_item2._object1.addMover(mover, &scene->_arrunkObj1337[scene->_field423E]._fieldB9C, this); -			 +  			scene->_arrunkObj1337[scene->_field423E]._arr1[2]._field34 = scene->_field3E28[scene->_field3E24];  			scene->_field3E28[scene->_field3E24] = 0;  			scene->_field3E24--; @@ -2856,7 +2856,7 @@ void Scene1337::Action4::signal() {  		if ((scene->_field4248 == 1) || (scene->_field423E == 2))  			scene->setAnimationInfo(&scene->_arrunkObj1337[scene->_field423E]._arr1[2]); -			 +  		scene->_item2._object1.hide();  		if ((scene->_arrunkObj1337[scene->_field423E]._arr1[3]._field34 == 0) && (scene->subC264B(scene->_arrunkObj1337[scene->_field423E]._arr3[0]._field34 == 0))) {  			if (scene->_field3E24 < 0) @@ -2868,7 +2868,7 @@ void Scene1337::Action4::signal() {  			NpcMover *mover = new NpcMover();  			scene->_item2._object1.addMover(mover, &scene->_arrunkObj1337[scene->_field423E]._fieldBA0, this); -			 +  			scene->_arrunkObj1337[scene->_field423E]._arr1[3]._field34 = scene->_field3E28[scene->_field3E24];  			scene->_field3E28[scene->_field3E24] = 0;  			scene->_field3E24--; @@ -2891,7 +2891,7 @@ void Scene1337::Action4::signal() {  		if ((scene->_field4248 == 1) || (scene->_field423E == 2))  			scene->setAnimationInfo(&scene->_arrunkObj1337[scene->_field423E]._arr1[3]); -			 +  		scene->_item2._object1.hide();  		switch (scene->_field423E) {  		case 0: @@ -2929,7 +2929,7 @@ void Scene1337::Action5::signal() {  			scene->_item7._object1.setPosition(scene->_item7._field36, 0);  			scene->_item7._object1.fixPriority(170);  		} -		 +  		scene->_item7._field34 = scene->_field3EF0->_field34;  		scene->_field3EF0->_field34 = 0;  		scene->_field3EF0->_object1.remove(); @@ -3095,7 +3095,7 @@ void Scene1337::Action9::signal() {  			subD18B5(5, 1, 4);  			scene->subC4CEC();  		} -		 +  		scene->subC20F9();  		break;  	default: @@ -3143,7 +3143,7 @@ void Scene1337::Action10::signal() {  				if (scene->_arrunkObj1337[0]._arr1[indexFound]._field34 == 29) {  					found = true;  					break; -				}  +				}  			}  			break;  		case 1: @@ -3151,7 +3151,7 @@ void Scene1337::Action10::signal() {  				if (scene->_arrunkObj1337[1]._arr1[indexFound]._field34 == 29) {  					found = true;  					break; -				}  +				}  			}  			break;  		case 2: @@ -3159,7 +3159,7 @@ void Scene1337::Action10::signal() {  				if (scene->_arrunkObj1337[2]._arr1[indexFound]._field34 == 29) {  					found = true;  					break; -				}  +				}  			}  			break;  		case 3: @@ -3167,7 +3167,7 @@ void Scene1337::Action10::signal() {  				if (scene->_arrunkObj1337[3]._arr1[indexFound]._field34 == 29) {  					found = true;  					break; -				}  +				}  			}  			break;  		default: @@ -3190,7 +3190,7 @@ void Scene1337::Action10::signal() {  				scene->subC4CD2();  				if (MessageDialog::show(USE_INTERCEPTOR, NO_MSG, YES_MSG) == 0)  					scene->subC4CEC(); -				else {			 +				else {  					scene->subC51A0(&scene->_arrunkObj1337[2]._arr1[indexFound], scene->_field3EF8);  					found2 = true;  				} @@ -3213,7 +3213,7 @@ void Scene1337::Action10::signal() {  				if (scene->_arrunkObj1337[2]._arr2[i]._field34 != 0)  					++j;  			} -			 +  			if (j <= 1) {  				for (int i = 0; i <= 7; i++) {  					if (scene->_arrunkObj1337[2]._arr2[i]._field34 != 0) { @@ -3223,11 +3223,11 @@ void Scene1337::Action10::signal() {  				}  			} else {  				scene->subC4CD2(); -				 +  				found2 = false;  				while (!found2) {  					scene->actionDisplay(1330, 130, 159, 10, 1, 200, 0, 7, 0, 154, 154); -					 +  					// Wait for a mouse or keypress  					Event event;  					while (!g_globals->_events.getEvent(event, EVENT_BUTTON_DOWN | EVENT_KEYPRESS) && !g_vm->shouldQuit()) { @@ -3235,9 +3235,9 @@ void Scene1337::Action10::signal() {  						R2_GLOBALS._sceneObjects->draw();  						g_globals->_events.delay(g_globals->_sceneHandler->_delayTicks);  					} -	 +  					scene->_item6._field36 = event.mousePos; -	 +  					for (int i = 0; i <= 7; i++) {  						if ((scene->subC2BF8(&scene->_arrunkObj1337[2]._arr2[i], scene->_item6._field36) != 0) && (scene->_arrunkObj1337[2]._arr2[i]._field34 != 0)) {  							scene->_field3EF4 = &scene->_arrunkObj1337[2]._arr2[0]; @@ -3249,15 +3249,15 @@ void Scene1337::Action10::signal() {  				scene->subC4CEC();  			}  		} -		 +  		scene->_field3E28[scene->_field3E26] = scene->_field3EF4->_field34;  		scene->_field3E26--;  		scene->_field3EF4->_field34 = 0;  		scene->_field3EF4->_object1.remove(); -		 +  		scene->_item2._object1.setPosition(scene->_field3EF4->_field36, 0);  		scene->_item2._object1.show(); -		 +  		NpcMover *mover = new NpcMover();  		scene->_item2._object1.addMover(mover, &scene->_field3EF8->_field36, this);  		} @@ -3284,7 +3284,7 @@ void Scene1337::Action11::signal() {  		scene->_field3EF4->_object1.setPosition(scene->_field3EF4->_field36, 0);  		scene->_field3EF4->_object1.fixPriority(170);  		scene->_field3EF4->_field34 = 25; -		 +  		if (scene->_field4240 == 2) {  			scene->_item2._object1.setPosition(scene->_field3EF4->_field36, 0);  			subD18B5(5, 1, 4); @@ -3353,7 +3353,7 @@ void Scene1337::Action11::signal() {  					break;  				}  			} -			 +  			if ((found) && (scene->subC3E92(scene->_field4240) != -1)) {  				scene->subC4CD2();  				if (MessageDialog::show(USE_DOUBLE_AGENT, NO_MSG, YES_MSG) == 0) @@ -3393,7 +3393,7 @@ void Scene1337::Action11::signal() {  		default:  			break;  		} -		 +  		if (!noAction)  			return; @@ -3431,9 +3431,9 @@ void Scene1337::Action11::signal() {  						R2_GLOBALS._sceneObjects->draw();  						g_globals->_events.delay(g_globals->_sceneHandler->_delayTicks);  					} -					 +  					scene->_item6._field36 = event.mousePos; -					 +  					found = false;  					if (scene->_field4242 != 2) { @@ -3499,7 +3499,7 @@ void Scene1337::Action11::signal() {  			scene->setAnimationInfo(scene->_field3EF0);  			break;  		} -			 +  		scene->subC4A39(scene->_field3EF4);  		break;  	default: @@ -3560,7 +3560,7 @@ void Scene1337::Action12::signal() {  				scene->subC4CD2();  				bool found = false; -				 +  				while (!found) {  					switch (scene->_field4240) {  					case 0: @@ -3582,7 +3582,7 @@ void Scene1337::Action12::signal() {  						R2_GLOBALS._sceneObjects->draw();  						g_globals->_events.delay(g_globals->_sceneHandler->_delayTicks);  					} -					 +  					scene->_item6._field36 = event.mousePos;  					if (scene->_field4240 == 0) { @@ -3594,7 +3594,7 @@ void Scene1337::Action12::signal() {  							}  						}  					} -					 +  					if (scene->_field4240 == 3) {  						for (i = 0; i <= 3; i++) {  							if ((scene->subC2BF8(&scene->_arrunkObj1337[3]._arr1[i], scene->_item6._field36) != 0) && (scene->_arrunkObj1337[3]._arr1[i]._field34 != 0)) { @@ -3882,14 +3882,14 @@ void Scene1337::dispatch() {  void Scene1337::actionDisplay(int resNum, int lineNum, int x, int y, int arg5, int width, int textMode, int fontNum, int colFG, int colBGExt, int colFGExt) {  	// TODO: Check if it's normal that arg5 is unused and replaced by an hardcoded 0 value  	// May hide an original bug -	 +  	SceneItem::display(resNum, lineNum, SET_X, x, SET_Y, y, SET_KEEP_ONSCREEN, 0, SET_WIDTH, width, SET_POS_MODE, -1, SET_TEXT_MODE, textMode, SET_FONT, fontNum, SET_FG_COLOR, colFG, SET_EXT_BGCOLOR, colBGExt, SET_EXT_FGCOLOR, colFGExt, LIST_END);  }  void Scene1337::setAnimationInfo(unkObj1337sub1 *subObj) {  	if (!subObj)  		return; -	 +  	if (subObj->_field34 > 9) {  		if (subObj->_field34 > 25) {  			subObj->_object1.setStrip2(4); @@ -3902,7 +3902,7 @@ void Scene1337::setAnimationInfo(unkObj1337sub1 *subObj) {  		subObj->_object1.setStrip2(2);  		subObj->_object1.setFrame(subObj->_field34);  	} -	 +  	subObj->_object1.show();  	R2_GLOBALS._sceneObjects->draw();  } @@ -3938,7 +3938,7 @@ void Scene1337::subC20F9() {  			default:  				break;  			} -			 +  			if (!_autoplay)  				_unkFctPtr412 = &Scene1337::subC20E5;  			else @@ -3995,7 +3995,7 @@ void Scene1337::subC2586() {  	switch (_field423E) {  	case 2:  		subC4CD2(); -		if (_field4246 == 1)  +		if (_field4246 == 1)  			actionDisplay(1330, 114, 159, 10, 1, 200, 0, 7, 0, 154, 154);  		_field4246 = 0;  	// No break on purpose @@ -4190,7 +4190,7 @@ void Scene1337::subC2835(int arg1) {  		if (found)  			break; -		 +  		for (i = 0; i <= 3; i++) {  			if (_arrunkObj1337[arg1]._arr1[i]._field34 == 13) {  				found = true; @@ -4329,7 +4329,7 @@ void Scene1337::subC2C2F() {  		return;  	int randIndx = R2_GLOBALS._randomSource.getRandomNumber(3); -	 +  	if (_arrunkObj1337[3]._arr1[randIndx]._field34 == 1) {  		found = false; @@ -4358,15 +4358,15 @@ void Scene1337::subC2C2F() {  			for (int i = 0; i <= 7; i++) {  				if ((_arrunkObj1337[3]._arr2[i]._field34 == 1) && (!subC2687(_arrunkObj1337[3]._arr3[i]._field34))) {  					int tmpVal = 0; -					 +  					for (int j = 0; j <= 7; j++) {  						if ((_arrunkObj1337[3]._arr2[j]._field34 > 1) && (_arrunkObj1337[3]._arr2[j]._field34 <= 9))  							++tmpVal;  					} -					 +  					if (tmpVal == 7)  						_field424A = 3; -					 +  					subC33C0(&_arrunkObj1337[3]._arr1[randIndx], &_arrunkObj1337[3]._arr2[i]);  					found = true;  					break; @@ -4386,7 +4386,7 @@ void Scene1337::subC2C2F() {  		int tmpVal = -1;  		found = false;  		int tmpRandIndx = R2_GLOBALS._randomSource.getRandomNumber(3); -		 +  		for (int i = 0; i <= 3; i++) {  			if (  (tmpRandIndx != 3)  			  && (  (_arrunkObj1337[tmpRandIndx]._arr1[0]._field34 != 0) @@ -4396,7 +4396,7 @@ void Scene1337::subC2C2F() {  				tmpVal = tmpRandIndx;  				break;  			} -			 +  			++tmpRandIndx;  			if (tmpRandIndx > 3)  				tmpRandIndx = 0; @@ -4433,7 +4433,7 @@ void Scene1337::subC2C2F() {  		case 24: {  			int tmpVal = -1;  			int tmpRandIndx = R2_GLOBALS._randomSource.getRandomNumber(3); -			 +  			for (int i = 0; i <= 3; i++) {  				if (tmpRandIndx != 3) {  				// The variables 'i' and 'j' are not used in the inner code of the loop. @@ -4449,11 +4449,11 @@ void Scene1337::subC2C2F() {  				++tmpRandIndx;  				if (tmpRandIndx > 3)  					tmpRandIndx = 0; -				 +  				if (tmpVal != -1)  					break;  			} -			 +  			if (tmpVal != -1) {  				// Useless second identical check skipped  				subC3456(&_arrunkObj1337[3]._arr1[randIndx], &_arrunkObj1337[tmpVal]._arr3[0]); @@ -4473,7 +4473,7 @@ void Scene1337::subC318B(int arg1, unkObj1337sub1 *subObj1, int arg3) {  	_field4242 = arg3;  	int randIndx; -	 +  	for (;;) {  		randIndx = R2_GLOBALS._randomSource.getRandomNumber(3);  		if (_arrunkObj1337[arg3]._arr1[randIndx]._field34 != 0) @@ -4581,7 +4581,7 @@ void Scene1337::subC33C0(unkObj1337sub1 *subObj1, unkObj1337sub1 *subObj2) {  }  int Scene1337::subC3E92(int arg1) { -	if ( (_arrunkObj1337[arg1]._arr1[0]._field34 == 0)  +	if ( (_arrunkObj1337[arg1]._arr1[0]._field34 == 0)  	  && (_arrunkObj1337[arg1]._arr1[1]._field34 == 0)  	  && (_arrunkObj1337[arg1]._arr1[2]._field34 == 0)  	  && (_arrunkObj1337[arg1]._arr1[3]._field34 == 0)) @@ -4624,13 +4624,13 @@ Scene1337::unkObj1337sub1 *Scene1337::subC34EC(int arg1) {  			return &_arrunkObj1337[arg1]._arr2[i];  		}  	} -	 +  	for (int i = 0; i <= 7; i++) {  		if ((_arrunkObj1337[arg1]._arr2[i]._field34 != 0) && (_arrunkObj1337[arg1]._arr2[i]._field34 < 10)) {  			return &_arrunkObj1337[arg1]._arr2[i];  		}  	} -	 +  	return NULL;  } @@ -5003,7 +5003,7 @@ void Scene1337::subCD193() {  void Scene1337::subCDB90(int arg1, Common::Point pt) {  	bool found = false;  	int curReg = R2_GLOBALS._sceneRegions.indexOf(g_globals->_events._mousePos); -	 +  	if (arg1 == 3) {  		int i;  		for (i = 0; i <= 7; i++) { @@ -5015,7 +5015,7 @@ void Scene1337::subCDB90(int arg1, Common::Point pt) {  				break;  			}  		} -		 +  		if (found) {  			switch (curReg) {  			case 5: @@ -5052,7 +5052,7 @@ void Scene1337::subCDB90(int arg1, Common::Point pt) {  			  || (subC2BF8(&_arrunkObj1337[3]._arr3[0], pt)) ) {  				found = true;  			} -			 +  			if (found) {  				switch (curReg) {  				case 5: @@ -5140,10 +5140,10 @@ void Scene1337::subCDB90(int arg1, Common::Point pt) {  			}  		}  	} -	 +  	if (arg1 != 1)  		return; -		 +  	for (int i = 0; i <= 7; i++) {  		if (subC2BF8(&_arrunkObj1337[2]._arr2[i], pt)) {  			switch (_arrunkObj1337[2]._arr2[i]._field34) { @@ -5203,7 +5203,7 @@ void Scene1337::subCDB90(int arg1, Common::Point pt) {  		}  		found = true;  	} -	 +  	if (subC2BF8(&_arrunkObj1337[3]._arr3[0], pt)) {  		if (_arrunkObj1337[3]._arr3[0]._field34 != 0) {  			actionDisplay(1330, 145, 20, 99, 1, 136, 0, 7, 0, 172, 172); @@ -5212,7 +5212,7 @@ void Scene1337::subCDB90(int arg1, Common::Point pt) {  		}  		found = true;  	} -	 +  	if (subC2BF8(&_arrunkObj1337[1]._arr3[0], pt)) {  		if (_arrunkObj1337[1]._arr3[0]._field34 != 0) {  			actionDisplay(1330, 144, 300, 99, 1, 136, 0, 7, 0, 117, 117); @@ -5221,7 +5221,7 @@ void Scene1337::subCDB90(int arg1, Common::Point pt) {  		}  		found = true;  	} -	 +  	if (subC2BF8(&_arrunkObj1337[0]._arr3[0], pt)) {  		if (_arrunkObj1337[0]._arr3[0]._field34 != 0) {  			actionDisplay(1330, 1, 159, 10, 1, 200, 0, 7, 0, 154, 154); @@ -5248,12 +5248,12 @@ void Scene1337::subCDB90(int arg1, Common::Point pt) {  	if (found)  		return; -	 +  	if (_background1._bounds.contains(pt)) {  		subCD193();  		return;  	} -	 +  	if (subC2BF8(&_item7, pt))  		actionDisplay(1330, 9, 159, 10, 1, 200, 0, 7, 0, 154, 154);  	else if (subC2BF8(&_item8, pt)) @@ -5353,7 +5353,7 @@ void Scene1337::subCF31D() {  		int tmpIndx = subC26CB(1, i);  		if (tmpIndx == -1)  			break; -		 +  		tmpVal = 0;  		for (int j = 0; j <= 7; j++) {  			if (_arrunkObj1337[1]._arr2[j]._field34 == _arrunkObj1337[1]._arr1[tmpIndx]._field34) { @@ -5361,7 +5361,7 @@ void Scene1337::subCF31D() {  				break;  			}  		} -		 +  		if (tmpVal == 0)  			break; @@ -5373,7 +5373,7 @@ void Scene1337::subCF31D() {  						if ((_arrunkObj1337[1]._arr2[k]._field34 > 1) && (_arrunkObj1337[1]._arr2[k]._field34 <= 9))  							++count;  					} -					 +  					if (count == 7)  						_field424A = 1; @@ -5397,7 +5397,7 @@ void Scene1337::subCF31D() {  			}  		}  	} -	 +  	if (found)  		return; @@ -5416,9 +5416,9 @@ void Scene1337::subCF31D() {  		int rndVal = R2_GLOBALS._randomSource.getRandomNumber(3);  		for (int i = 0; i <= 3; i++) {  			if (rndVal != 1) { -				if (  (_arrunkObj1337[rndVal]._arr1[0]._field34 != 0)  -				   || (_arrunkObj1337[rndVal]._arr1[1]._field34 != 0)  -				   || (_arrunkObj1337[rndVal]._arr1[2]._field34 != 0)  +				if (  (_arrunkObj1337[rndVal]._arr1[0]._field34 != 0) +				   || (_arrunkObj1337[rndVal]._arr1[1]._field34 != 0) +				   || (_arrunkObj1337[rndVal]._arr1[2]._field34 != 0)  				   || (_arrunkObj1337[rndVal]._arr1[3]._field34 == 0)) {  					count = rndVal;  					break; @@ -5435,7 +5435,7 @@ void Scene1337::subCF31D() {  			found = true;  		}  	} -	 +  	if (found)  		return; @@ -5449,7 +5449,7 @@ void Scene1337::subCF31D() {  			for (int j = 0; j <= 3; j++) {  				if (tmpVal != 1) {  					for (int k = 0; k <= 7; k++) { -						// 'k' is not used in that loop.  +						// 'k' is not used in that loop.  						// It looks suspicious.  						if ((_arrunkObj1337[tmpVal]._arr3[0]._field34 == 0) && (subC32B1(tmpVal, _arrunkObj1337[1]._arr1[i]._field34))) {  							count = tmpVal; @@ -5510,7 +5510,7 @@ void Scene1337::subCF31D() {  		if (found) {  			if (count == -1) -				return;	 +				return;  			subC3456(&_arrunkObj1337[1]._arr1[j], &_arrunkObj1337[count]._arr3[0]);  		} else { @@ -5561,10 +5561,10 @@ void Scene1337::subCF979() {  			break;  		}  	} -	 +  	if (found)  		return; -	 +  	int tmpVal;  	found = false;  	for (int i = 0; i <= 3; i++) { @@ -5578,7 +5578,7 @@ void Scene1337::subCF979() {  					break;  				}  			} -			 +  			if (!flag) {  				for (int j = 0; j <= 7; j++) {  					if ((_arrunkObj1337[0]._arr2[j]._field34 == 1) && (!subC2687(_arrunkObj1337[0]._arr3[0]._field34))) { @@ -5591,21 +5591,21 @@ void Scene1337::subCF979() {  						if (count == 7)  							_field424A = 0; -						 +  						subC33C0(&_arrunkObj1337[0]._arr1[tmpVal], &_arrunkObj1337[0]._arr2[j]);  						found = true;  					}  				}  			}  		} -		 +  		if (found)  			break;  	}  	if (found)  		return; -	 +  	found = false;  	tmpVal = subC2719(0); @@ -5618,10 +5618,10 @@ void Scene1337::subCF979() {  			}  		}  	} -	 +  	if (found)  		return; -	 +  	tmpVal = subC274D(0);  	if (tmpVal != -1) {  		for (int i = 0; i <= 7; i++) { @@ -5632,10 +5632,10 @@ void Scene1337::subCF979() {  			}  		}  	} -	 -	if (found)  + +	if (found)  		return; -	 +  	tmpVal = subC2781(0);  	if (tmpVal != -1) {  		if ( (_arrunkObj1337[2]._arr1[0]._field34 != 0) @@ -5646,10 +5646,10 @@ void Scene1337::subCF979() {  			found = true;  		}  	} -	 -	if (found)  + +	if (found)  		return; -	 +  	for (int i = 0; i <= 3; i++) {  		if (subC27B5(_arrunkObj1337[0]._arr1[i]._field34) != -1) {  			// The variable 'j' is not used in the inner code of the loop. It's suspect @@ -5666,7 +5666,7 @@ void Scene1337::subCF979() {  		}  	} -	if (found)  +	if (found)  		return;  	for (int i = 0; i <= 3; i++) { @@ -5678,26 +5678,26 @@ void Scene1337::subCF979() {  					found = true;  				}  			} -			 +  			if (found)  				break;  		}  	} -		 -	if (found)  + +	if (found)  		return;  	tmpVal = subC274D(0);  	int tmpVal2 = subC331B(0); -	 +  	if ((tmpVal != -1) && (tmpVal2 != -1)) {  		subC358E(&_arrunkObj1337[0]._arr1[tmpVal], tmpVal2);  		found = true;  	} -	 +  	if (found)  		return; -	 +  	tmpVal = subC2781(0);  	if (tmpVal != -1) {  		if ( (_arrunkObj1337[1]._arr1[0]._field34 != 0) @@ -5708,7 +5708,7 @@ void Scene1337::subCF979() {  			found = true;  		}  	} -	 +  	if (found)  		return; @@ -5722,7 +5722,7 @@ void Scene1337::subCF979() {  					found = true;  				}  			} -			 +  			if (!found) {  			// The variable 'j' is not used in the inner code of the loop. It's suspect.  				for (int j = 0; j <= 7; j++) { @@ -5732,7 +5732,7 @@ void Scene1337::subCF979() {  					}  				}  			} -			 +  			if (found)  				break;  		} @@ -5761,12 +5761,12 @@ void Scene1337::subCF979() {  					}  				}  			} -			 +  			if (found)  				break;  		}  	} -	 +  	if (found)  		return; @@ -5847,7 +5847,7 @@ void Scene1337::subD02CA() {  				_item6._object1 = _arrunkObj1337[2]._arr1[di]._object1;  			}  		} -		 +  		if (di == 4) {  			subCDB90(1, _item6._field36);  			subD0281(); @@ -5862,7 +5862,7 @@ void Scene1337::subD02CA() {  		subD0281();  		return;  	} -	 +  	// That continues the block when R2_GLOBALS._v57810 == 200 and di != 4  	subD18B5(1332, _item6._object1._strip, _item6._object1._frame);  	R2_GLOBALS._sceneObjects->draw(); @@ -5874,7 +5874,7 @@ void Scene1337::subD02CA() {  			|| (g_globals->_events.getEvent(event, EVENT_KEYPRESS)) ){  			_item6._field36 = g_globals->_events._mousePos;  			found_di = false; -			 +  			for (int i = 0; i <= 3; i ++) {  				if (subC2BF8(&_arrunkObj1337[2]._arr1[i], Common::Point(_item6._field36.x + 12, _item6._field36.y + 12)) != 0) {  					if (_arrunkObj1337[2]._arr1[i]._field34 == 0) { @@ -5897,7 +5897,7 @@ void Scene1337::subD02CA() {  					break;  				}  			} -			 +  			if ((!found) && (!found_di)) {  				if (subC2BF8(&_item7, Common::Point(_item6._field36.x + 12, _item6._field36.y + 12)) != 0) {  					subC4A39(&_item6); @@ -5947,7 +5947,7 @@ void Scene1337::subD02CA() {  							} else {  								if (j == 7)  									_field424A = 2; -								 +  								subC33C0(&_item6, &_arrunkObj1337[2]._arr2[i]);  								return;  							} @@ -6048,7 +6048,7 @@ void Scene1337::subD02CA() {  											actionDisplay(1330, 99, 159, 10, 1, 200, 0, 7, 0, 154, 154);  										}  									} -									 +  									if (subC2BF8(&_arrunkObj1337[3]._arr4[0], Common::Point(_item6._field36.x + 12, _item6._field36.y + 12)) != 0) {  										if ( (_arrunkObj1337[3]._arr1[0]._field34 != 0)  											|| (_arrunkObj1337[3]._arr1[1]._field34 != 0) @@ -6188,7 +6188,7 @@ void Scene1337::subD02CA() {  					}  				}  			} -			 +  			if (found)  				return;  		} else { @@ -6234,7 +6234,7 @@ int Scene1337::subD18F5() {  		// The cursor looks... very dummy  		// To be checked  		warning("TODO: CursorManager.setData(R2_GLOBALS.off_57705)"); -		 +  	++R2_GLOBALS._v57709;  	return R2_GLOBALS._v57709; @@ -6339,7 +6339,7 @@ void Scene1500::postInit(SceneObjectList *OwnerList) {  		R2_GLOBALS._sound1.play(110);  	} else if (R2_GLOBALS._sceneManager._previousScene == 1550) {  		_actor1.setPosition(Common::Point(189, 139), 5); -		 +  		_actor3.setup(1400, 2, 1);  		_actor3.changeZoom(-1);  		_actor3.setPosition(Common::Point(298, 258), 5); @@ -6505,7 +6505,7 @@ void Scene1530::postInit(SceneObjectList *OwnerList) {  	_stripManager.addSpeaker(&_quinnSpeaker);  	_stripManager.addSpeaker(&_seekerSpeaker); -		 +  	if (R2_GLOBALS._sceneManager._previousScene == 1000) {  		R2_GLOBALS._player.postInit();  		R2_GLOBALS._player.hide(); @@ -6677,7 +6677,7 @@ bool Scene1550::UnkObj15502::startAction(CursorType action, Event &event) {  			R2_GLOBALS._player.disableControl();  			if (R2_GLOBALS._player._characterIndex == 1)  				scene->_sceneMode = 1576; -			else  +			else  				scene->_sceneMode = 1584;  			// strcpy(scene->_arrUnkObj15502[7]._actorName, 'hatch');  			scene->setAction(&scene->_sequenceManager1, scene, scene->_sceneMode, &R2_GLOBALS._player, &scene->_arrUnkObj15502[7], NULL); @@ -6887,7 +6887,7 @@ bool Scene1550::UnkObj15503::startAction(CursorType action, Event &event) {  		} else {  			if (scene->_actor4._frame == 1)  				scene->_sceneMode = 24; -			else  +			else  				scene->_sceneMode = 22;  			scene->setAction(&scene->_sequenceManager1, scene, 1561, this, NULL);  		} @@ -6911,7 +6911,7 @@ void Scene1550::UnkArea1550::remove() {  	//  	if ((scene->_sceneMode >= 20) && (scene->_sceneMode <= 29))  		return; -	 +  	R2_GLOBALS._player.disableControl();  	if (scene->_actor4._frame == 1) {  		scene->_sceneMode = 1559; @@ -7016,14 +7016,14 @@ bool Scene1550::Actor7::startAction(CursorType action, Event &event) {  	Scene1550 *scene = (Scene1550 *)R2_GLOBALS._sceneManager._scene;  	scene->_sceneMode = 80;  	scene->signal(); -	 +  	return true;  }  bool Scene1550::Actor8::startAction(CursorType action, Event &event) {  	if (action != CURSOR_USE)  		return SceneActor::startAction(action, event); -	 +  	R2_GLOBALS._player.disableControl();  	Scene1550 *scene = (Scene1550 *)R2_GLOBALS._sceneManager._scene;  	scene->_field412 = 1; @@ -7031,7 +7031,7 @@ bool Scene1550::Actor8::startAction(CursorType action, Event &event) {  		scene->_sceneMode = 1552;  	else  		scene->_sceneMode = 1588; -	 +  	scene->setAction(&scene->_sequenceManager1, scene, scene->_sceneMode, &R2_GLOBALS._player, &scene->_actor8, NULL);  	return true;  } @@ -7071,7 +7071,7 @@ bool Scene1550::Actor10::startAction(CursorType action, Event &event) {  		scene->_sceneMode = 1589;  	scene->setAction(&scene->_sequenceManager1, scene, scene->_sceneMode, &R2_GLOBALS._player, &scene->_actor10, NULL); -	return true;		 +	return true;  }  bool Scene1550::Actor11::startAction(CursorType action, Event &event) { @@ -7087,7 +7087,7 @@ bool Scene1550::Actor11::startAction(CursorType action, Event &event) {  		scene->_sceneMode = 1587;  	scene->setAction(&scene->_sequenceManager1, scene, scene->_sceneMode, &R2_GLOBALS._player, &scene->_actor11, NULL); -	return true;		 +	return true;  }  bool Scene1550::Actor12::startAction(CursorType action, Event &event) { @@ -7132,7 +7132,7 @@ bool Scene1550::Actor13::startAction(CursorType action, Event &event) {  	case CURSOR_USE:  		if (scene->_field415 != 2)  			return SceneActor::startAction(action, event); -		 +  		if (R2_INVENTORY.getObjectScene(R2_BATTERY) == 1550) {  			R2_GLOBALS._player.disableControl();  			scene->_sceneMode = 1564; @@ -7180,13 +7180,13 @@ void Scene1550::postInit(SceneObjectList *OwnerList) {  		loadScene(1234);  	else  		loadScene(1550); -	 +  	scalePalette(65, 65, 65);  	setZoomPercents(30, 75, 170, 100);  	_field417 = 1550;  	_field419 = 0;  	SceneExt::postInit(); -	 +  	if (R2_GLOBALS._sceneManager._previousScene == -1)  		R2_GLOBALS.setFlag(R2_ATTRACTOR_CABLE_HARNESS); @@ -7194,12 +7194,12 @@ void Scene1550::postInit(SceneObjectList *OwnerList) {  		R2_GLOBALS._player._characterScene[1] = 1550;  		R2_GLOBALS._player._characterScene[2] = 1550;  	} -	 +  	_stripManager.setColors(60, 255);  	_stripManager.setFontNumber(3);  	_stripManager.addSpeaker(&_quinnSpeaker);  	_stripManager.addSpeaker(&_seekerSpeaker); -	 +  	R2_GLOBALS._player.postInit();  	R2_GLOBALS._player._effect = 6; @@ -7209,19 +7209,19 @@ void Scene1550::postInit(SceneObjectList *OwnerList) {  		R2_GLOBALS._player.setup(1505, 3, 1);  	R2_GLOBALS._player._moveDiff = Common::Point(5, 3); -	 +  	if ((R2_GLOBALS._v565EC[R2_GLOBALS._player._characterIndex] == 9) && (R2_GLOBALS._v565EC[R2_GLOBALS._player._characterIndex + 2] == 11))  		R2_GLOBALS._player.setPosition(Common::Point(157, 135));  	else  		R2_GLOBALS._player.setPosition(Common::Point(160, 100)); -	 +  	R2_GLOBALS._player.animate(ANIM_MODE_1, NULL);  	R2_GLOBALS._player.disableControl(); -	 +  	_field414 = 0;  	_actor7.changeZoom(-1);  	R2_GLOBALS._player.changeZoom(-1); -	 +  	switch (R2_GLOBALS._sceneManager._previousScene) {  	case 1530:  		R2_GLOBALS._v565AE = 0; @@ -7237,9 +7237,9 @@ void Scene1550::postInit(SceneObjectList *OwnerList) {  		if (R2_GLOBALS._player._oldCharacterScene[R2_GLOBALS._player._characterIndex] == 1580) {  			R2_GLOBALS._player.disableControl();  			R2_GLOBALS._player.animate(ANIM_MODE_NONE, NULL); -			 +  			_field412 = 1; -			 +  			_actor1.postInit();  			_arrUnkObj15502[7].subA5CDF(8);  			_arrUnkObj15502[7].hide(); @@ -7247,7 +7247,7 @@ void Scene1550::postInit(SceneObjectList *OwnerList) {  				_sceneMode = 1577;  			else  				_sceneMode = 1578; -			 +  			setAction(&_sequenceManager1, this, _sceneMode, &R2_GLOBALS._player, &_actor1, &_arrUnkObj15502[7], NULL);  			R2_GLOBALS._player._oldCharacterScene[R2_GLOBALS._player._characterIndex] = 1550;  		} else { @@ -7257,13 +7257,13 @@ void Scene1550::postInit(SceneObjectList *OwnerList) {  	default:  		break;  	} -	 +  	subA2B2F(); -	 +  	_item1.setDetails(16, 1550, 10, -1, -1);  	_item2.setDetails(24, 1550, 10, -1, -1);  	_item3.setDetails(Rect(0, 0, 320, 200), 1550, 0, 1, -1, 1, NULL); -	 +  	if ((R2_GLOBALS._sceneManager._previousScene == 1500) && (R2_GLOBALS.getFlag(16))) {  		_sceneMode = 70;  		if (!R2_GLOBALS._sceneObjects->contains(&_actor7)) @@ -7454,7 +7454,7 @@ void Scene1550::signal() {  				++R2_GLOBALS._v565AE;  				if (R2_GLOBALS._player._characterIndex == 1)  					_stripManager.start(499 + R2_GLOBALS._v565AE, this); -				else					 +				else  					_stripManager.start(502 + R2_GLOBALS._v565AE, this);  			}  		} else { @@ -7470,7 +7470,7 @@ void Scene1550::signal() {  				++R2_GLOBALS._v565AE;  				if (R2_GLOBALS._player._characterIndex == 1)  					_stripManager.start(563 + R2_GLOBALS._v565AE, this); -				else					 +				else  					_stripManager.start(567 + R2_GLOBALS._v565AE, this);  			}  		} @@ -7635,11 +7635,11 @@ void Scene1550::process(Event &event) {  			_field412 = 1;  		else  			_field412 = 0; -		 +  		if ((curReg == 13) || (curReg == 14))  			_field412 = 0;  	} -	 +  	Scene::process(event);  } @@ -7675,10 +7675,10 @@ void Scene1550::dispatch() {  			break;  		}  	} -	 +  	if (_field412 != 0)  		return; -	 +  	switch (R2_GLOBALS._player.getRegionIndex() - 11) {  	case 0:  	// No break on purpose @@ -7687,9 +7687,9 @@ void Scene1550::dispatch() {  		_sceneMode = 1;  		_field412 = 1;  		--R2_GLOBALS._v565EC[2 + R2_GLOBALS._player._characterIndex]; -		 +  		subA2B2F(); -		 +  		R2_GLOBALS._player.setPosition(Common::Point( 160 - (((((160 - R2_GLOBALS._player._position.x) * 100) / 108) * 172) / 100), 145));  		if (R2_GLOBALS._player._position.x < 160) {  			Common::Point pt(R2_GLOBALS._player._position.x + 5, 135); @@ -7710,9 +7710,9 @@ void Scene1550::dispatch() {  		_sceneMode = 3;  		_field412 = 1;  		++R2_GLOBALS._v565EC[2 + R2_GLOBALS._player._characterIndex]; -		 +  		subA2B2F(); -		 +  		R2_GLOBALS._player.setPosition(Common::Point( 160 - (((((160 - R2_GLOBALS._player._position.x) * 100) / 172) * 108) / 100), 19));  		if (R2_GLOBALS._player._position.x < 160) {  			Common::Point pt(R2_GLOBALS._player._position.x + 5, 29); @@ -7733,9 +7733,9 @@ void Scene1550::dispatch() {  		_sceneMode = 5;  		_field412 = 1;  		++R2_GLOBALS._v565EC[R2_GLOBALS._player._characterIndex]; -		 +  		subA2B2F(); -		 +  		if ((R2_GLOBALS._v565EC[R2_GLOBALS._player._characterIndex] == 9) && (R2_GLOBALS._v565EC[R2_GLOBALS._player._characterIndex + 2] == 11) && (R2_GLOBALS._player._position.y > 50) && (R2_GLOBALS._player._position.y < 135)) {  			if (R2_GLOBALS._player._position.y >= 85) {  				R2_GLOBALS._player.setPosition(Common::Point(320 - R2_GLOBALS._player._position.x, R2_GLOBALS._player._position.y + 10)); @@ -7792,7 +7792,7 @@ void Scene1550::dispatch() {  void Scene1550::saveCharacter(int characterIndex) {  	if (R2_GLOBALS._player._characterIndex == 3)  		R2_GLOBALS._sound1.fadeOut2(NULL); -	 +  	SceneExt::saveCharacter(characterIndex);  } @@ -7913,7 +7913,7 @@ void Scene1550::SceneActor1550::subA4D14(int frameNumber, int strip) {  			fixPriority(2);  			if (scene->_field414 == 2)  				setup(1553, 2, 1); -			else  +			else  				setup(1556, 2, 1);  			setPosition(Common::Point(160, 44));  			break; @@ -7943,7 +7943,7 @@ void Scene1550::SceneActor1550::subA4D14(int frameNumber, int strip) {  		} else {  			fixPriority(2);  		} -		 +  		if (frameNumber != 1)  			setDetails(1550, 6, -1, -1, 2, (SceneItem *) NULL); @@ -7984,40 +7984,40 @@ void Scene1550::subA2B2F() {  	Rect tmpRect;  	_field419 = 0;  	_field415 = 0; -	 +  	tmpRect = R2_GLOBALS._v5589E; -	 +  	_actor14.remove();  	_actor17.remove();  	_actor15.remove();  	_actor19.remove();  	_actor16.remove();  	_actor18.remove(); -	 +  	for (int i = 0; i < 8; ++i)  		_arrUnkObj15501[i].remove(); -	 +  	_actor6.remove();  	for (int i = 0; i < 8; ++i)  		_arrUnkObj15502[i].remove(); -	 +  	_actor8.remove();  	_actor9.remove();  	_actor10.remove();  	_actor3.remove();  	_actor11.remove(); -	 +  	if ((_sceneMode != 1577) && (_sceneMode != 1578))  		_actor1.remove(); -	 +  	_actor2.remove();  	_actor7.remove();  	_actor13.remove();  	_actor5.remove();  	_actor12.remove();  	_actor4.remove(); -	 +  	switch (R2_GLOBALS._v565EC[R2_GLOBALS._player._characterIndex + 2]) {  	case 0:  		switch (R2_GLOBALS._v565EC[R2_GLOBALS._player._characterIndex]) { @@ -8218,7 +8218,7 @@ void Scene1550::subA2B2F() {  		} else {  			_field414 = 2;  		} -		 +  		if (R2_GLOBALS._sceneManager._sceneNumber == 1550){  			warning("Mouse_hideIfNeeded()");  			warning("gfx_set_pane_p"); @@ -8528,7 +8528,7 @@ void Scene1550::subA2B2F() {  				_actor6.setPosition(Common::Point(243, 131));  				_actor6.fixPriority(10);  				_actor6.setDetails(1550, 9, -1, -1, 2, (SceneItem *) NULL); -				 +  				_actor1.postInit();  				_actor1.setup(1550, 2, 3);  				_actor1.setPosition(Common::Point(243, 64)); @@ -8658,7 +8658,7 @@ void Scene1550::subA2B2F() {  }  /*-------------------------------------------------------------------------- - * Scene 1575 -  + * Scene 1575 -   *   *--------------------------------------------------------------------------*/  Scene1575::Scene1575() { @@ -8709,7 +8709,7 @@ void Scene1575::Hotspot1::process(Event &event) {  		return;  	}  	int di = scene->_actor1._position.x; -	 +  	switch (_field34 - 1) {  	case 0:  		if (R2_GLOBALS.getFlag(18)) { @@ -8730,10 +8730,10 @@ void Scene1575::Hotspot1::process(Event &event) {  				di -= 65;  			di += 2;  			scene->_field41A += 2; -			 +  			for (int i = 0; i < 17; i++)  				scene->_arrActor[i].setPosition(Common::Point(scene->_arrActor[i]._position.x + 2, scene->_arrActor[i]._position.y)); -			 +  			scene->_actor13.setPosition(Common::Point(scene->_actor13._position.x + 2, scene->_actor13._position.y));  			scene->_actor12.setPosition(Common::Point(scene->_actor12._position.x + 2, scene->_actor12._position.y));  			scene->_actor1.setPosition(Common::Point(di, scene->_actor1._position.y)); @@ -8745,12 +8745,12 @@ void Scene1575::Hotspot1::process(Event &event) {  		if (scene->_field41A > 0) {  			if (di < -8)  				di += 65; -			 +  			di -= 2;  			scene->_field41A -= 2;  			for (int i = 0; i < 178; i++)  				scene->_arrActor[i].setPosition(Common::Point(scene->_arrActor[i]._position.x - 2, scene->_arrActor[i]._position.y)); -			 +  			scene->_actor13.setPosition(Common::Point(scene->_actor13._position.x - 2, scene->_actor13._position.y));  			scene->_actor12.setPosition(Common::Point(scene->_actor12._position.x - 2, scene->_actor12._position.y));  			scene->_actor1.setPosition(Common::Point(di, scene->_actor1._position.y)); @@ -9061,9 +9061,9 @@ bool Scene1580::Hotspot1::startAction(CursorType action, Event &event) {  		scene->_actor2.setup(1580, 1, 4);  		scene->_actor2.setPosition(Common::Point(159, 163));  		scene->_actor2.setDetails(1550, 78, -1, -1, 2, (SceneItem *) NULL); -		 +  		scene->_arrActor[5].remove(); -		 +  		return true;  	} @@ -9082,12 +9082,12 @@ bool Scene1580::Hotspot2::startAction(CursorType action, Event &event) {  		scene->_actor3.setup(1580, 1, 1);  		scene->_actor3.setPosition(Common::Point(124, 108));  		scene->_actor3.fixPriority(10); -		 +  		if (R2_INVENTORY.getObjectScene(26) == 1580)  			scene->_actor3.setDetails(1550, 14, -1, -1, 5, &scene->_actor2);  		else  			scene->_actor3.setDetails(1550, 14, -1, -1, 2, (SceneItem *)NULL); -		 +  		scene->_actor1.postInit();  		scene->_actor1.setup(1580, 3, 1);  		scene->_actor1.setPosition(Common::Point(124, 109)); @@ -9115,7 +9115,7 @@ bool Scene1580::Actor2::startAction(CursorType action, Event &event) {  			scene->_stripManager.start(536, scene);  		else  			scene->_stripManager.start(537, scene); -		 +  		return true;  	} @@ -9132,35 +9132,35 @@ bool Scene1580::Actor3::startAction(CursorType action, Event &event) {  		remove();  		return true;  	} -	 +  	return SceneActor::startAction(action, event);  }  bool Scene1580::Actor4::startAction(CursorType action, Event &event) {  	if (action != CURSOR_USE)  		return SceneActor::startAction(action, event); -	 +  	Scene1580 *scene = (Scene1580 *)R2_GLOBALS._sceneManager._scene;  	R2_GLOBALS._player.disableControl();  	R2_GLOBALS._sceneItems.remove(&scene->_actor4);  	scene->_sceneMode = 0;  	animate(ANIM_MODE_5, scene); -	 +  	return true;  }  bool Scene1580::Actor5::startAction(CursorType action, Event &event) {  	if (action != CURSOR_USE)  		return SceneActor::startAction(action, event); -	 +  	Scene1580 *scene = (Scene1580 *)R2_GLOBALS._sceneManager._scene;  	R2_GLOBALS._player.disableControl();  	setFrame(2);  	scene->_sceneMode = 20;  	scene->setAction(&scene->_sequenceManager, scene, 2, &R2_GLOBALS._player, NULL); -	 +  	return true;  } @@ -9238,9 +9238,9 @@ void Scene1580::postInit(SceneObjectList *OwnerList) {  	_stripManager.setFontNumber(3);  	_stripManager.addSpeaker(&_quinnSpeaker);  	_stripManager.addSpeaker(&_seekerSpeaker); -	 +  	_sceneMode = 0; -	 +  	R2_GLOBALS._player.disableControl();  	if (R2_INVENTORY.getObjectScene(26) == 1580) {  		_actor2.postInit(); @@ -9250,14 +9250,14 @@ void Scene1580::postInit(SceneObjectList *OwnerList) {  	} else {  		_item1.setDetails(Rect(141, 148, 179, 167), 1550, 79, -1, -1, 1, NULL);  	} -	 +  	if (R2_INVENTORY.getObjectScene(51) == 1580) {  		_actor3.postInit();  		_actor3.setup(1580, 1, 1);  		_actor3.setPosition(Common::Point(124, 108));  		_actor3.fixPriority(10);  		_actor3.setDetails(1550, 13, -1, -1, 1, (SceneItem *) NULL); -		 +  		_actor1.postInit();  		_actor1.setup(1580, 1, 3);  		_actor1.setPosition(Common::Point(124, 96)); @@ -9273,7 +9273,7 @@ void Scene1580::postInit(SceneObjectList *OwnerList) {  		_actor1.setup(1580, 3, 1);  		_actor1.setPosition(Common::Point(124, 109));  		_actor1.fixPriority(20); -			 +  		_sceneMode = 10;  	} else {  		_item2.setDetails(Rect(69, 29, 177, 108), 1550, 82, -1, -1, 1, NULL); @@ -9289,7 +9289,7 @@ void Scene1580::postInit(SceneObjectList *OwnerList) {  	_actor4.setPosition(Common::Point(216, 108));  	_actor4.fixPriority(100); -	 +  	_actor5.postInit();  	_actor5.setup(1580, 4, 1);  	_actor5.setPosition(Common::Point(291, 147)); @@ -9303,7 +9303,7 @@ void Scene1580::postInit(SceneObjectList *OwnerList) {  		_actor6.fixPriority(50);  		_actor6.setDetails(1550, 32, -1, 34, 1, (SceneItem *) NULL);  	} -	 +  	if (R2_INVENTORY.getObjectScene(27) == 1580) {  		_actor7.postInit();  		_actor7.setup(1580, 6, 1); @@ -9311,13 +9311,13 @@ void Scene1580::postInit(SceneObjectList *OwnerList) {  		_actor7.fixPriority(50);  		_actor7.setDetails(1550, 38, -1, 34, 1, (SceneItem *) NULL);  	} -	 +  	R2_GLOBALS._player.postInit();  	R2_GLOBALS._player._oldCharacterScene[R2_GLOBALS._player._characterIndex] = 1580;  	R2_GLOBALS._player.hide();  	setAction(&_sequenceManager, this, 1, &R2_GLOBALS._player, NULL);  	_item3.setDetails(Rect(0, 0, 320, 200), 1550, 50, -1, -1, 1, NULL); -	 +  }  void Scene1580::signal() { @@ -9334,7 +9334,7 @@ void Scene1580::signal() {  			_arrActor[0].setup(1580, 2, 1);  			_arrActor[0].setPosition(Common::Point(138, 56));  		} -		 +  		if (R2_INVENTORY.getObjectScene(25) != 0) {  			_arrActor[1].postInit();  			_arrActor[1].setup(1580, 2, 2); @@ -9663,7 +9663,7 @@ void Scene1625::process(Event &event) {  }  /*-------------------------------------------------------------------------- - * Scene 1700 -  + * Scene 1700 -   *   *--------------------------------------------------------------------------*/  Scene1700::Scene1700() { @@ -9751,7 +9751,7 @@ void Scene1700::Exit3::changeScene() {  void Scene1700::subAF3F8() {  	Rect tmpRect;  	R2_GLOBALS._walkRegions.load(1700); -	 +  	_actor3.remove();  	_actor4.remove();  	_actor5.remove(); @@ -9759,22 +9759,22 @@ void Scene1700::subAF3F8() {  	_actor7.remove();  	_actor8.remove();  	_actor11.remove(); -	 +  	if (_sceneMode != 40) {  		_actor9.remove();  		_actor10.remove();  	} -	 +  	warning("tmpRect = _v5589E;");  	warning("Mouse_hideIfNeeded");  	warning("set_pane_p(_paneNumber);");  	warning("Big loop calling gfx_draw_slice_p"); -	 +  	if (_field77A == 0)  		_field77A = 1;  	else  		_field77A = 0; -	 +  	warning("set_pane_p(_paneNumber);");  	if ((_sceneMode != 40) && (R2_GLOBALS._v565F6 != 0)){ @@ -9784,57 +9784,57 @@ void Scene1700::subAF3F8() {  		_actor9.setDetails(1700, 6, -1, -1, 2, (SceneItem *) NULL);  		R2_GLOBALS._walkRegions.enableRegion(2);  		R2_GLOBALS._walkRegions.enableRegion(12); -	}  -	 +	} +  	if ((R2_GLOBALS._v565F6 + 2) % 4 == 0) {  		_actor3.postInit();  		_actor3.setup(1700, 1, 1);  		_actor3.setPosition(Common::Point(222, 82));  		_actor3.setDetails(100, -1, -1, -1, 2, (SceneItem *) NULL); -		 +  		_actor5.postInit();  		_actor5.setup(1700, 2, 1);  		_actor5.setPosition(Common::Point(177, 82));  		_actor5.fixPriority(0); -		 +  		_actor6.postInit();  		_actor6.setup(1700, 2, 2);  		_actor6.setPosition(Common::Point(332, 96));  		_actor6.fixPriority(0); -	 +  		_actor4.postInit();  		_actor4.setup(1700, 1, 2);  		_actor4.setPosition(Common::Point(424, 84)); -		 +  		R2_GLOBALS._walkRegions.enableRegion(11);  	} -	 +  	if ((R2_GLOBALS._v565F6 + 399) % 800 == 0) {  		_actor7.postInit();  		_actor7.setup(1700, 3, 2);  		_actor7.setPosition(Common::Point(51, 141));  		_actor7.fixPriority(0);  		_actor7.setDetails(100, -1, -1, -1, 2, (SceneItem *) NULL); -		 +  		_exit3._enabled = true;  	} else {  		R2_GLOBALS._walkRegions.enableRegion(1);  		_exit3._enabled = false;  	} -	 -	if (  ((!R2_GLOBALS.getFlag(15)) && ((R2_GLOBALS._v565F6 == 25) || (R2_GLOBALS._v565F6 == -3)))  + +	if (  ((!R2_GLOBALS.getFlag(15)) && ((R2_GLOBALS._v565F6 == 25) || (R2_GLOBALS._v565F6 == -3)))  		 || ((R2_GLOBALS.getFlag(15)) && (R2_GLOBALS._v565F6 == R2_GLOBALS._v565FA))  		 ) {  		R2_GLOBALS._v565FA = R2_GLOBALS._v565F6;  		if (!R2_GLOBALS.getFlag(15))  			_field77C = 1; -		 +  		_actor11.postInit();  		_actor11.setup(1700, 3, 1);  		_actor11.setPosition(Common::Point(338, 150));  		_actor11.setDetails(1700, 9, -1, -1, 2, (SceneItem *) NULL);  		_actor11.fixPriority(15); -		 +  		_actor8.postInit();  		_actor8.setup(1700, 4, 1);  		_actor8.setPosition(Common::Point(312, 106)); @@ -9847,14 +9847,14 @@ void Scene1700::postInit(SceneObjectList *OwnerList) {  	SceneExt::postInit();  	if (R2_GLOBALS._sceneManager._previousScene == -1)  		R2_GLOBALS._sceneManager._previousScene = 1530; -	 +  	scalePalette(65, 65, 65);  	_stripManager.addSpeaker(&_quinnSpeaker);  	_stripManager.addSpeaker(&_seekerSpeaker);  	_field77A = 0;  	_field77C = 0; -	 +  	_exit1.setDetails(Rect(94, 0, 319, 12), EXITCURSOR_N, 1700);  	_exit2.setDetails(Rect(0, 161, 319, 168), EXITCURSOR_S, 1700);  	_exit3.setDetails(Rect(0, 0, 2, 138), EXITCURSOR_W, 1800); @@ -9869,11 +9869,11 @@ void Scene1700::postInit(SceneObjectList *OwnerList) {  		R2_GLOBALS._player.setVisage(1506);  		R2_GLOBALS._player._moveDiff = Common::Point(3, 1);  	} -	 +  	_actor12.postInit();  	_actor12.animate(ANIM_MODE_1, NULL);  	_actor12.setObjectWrapper(new SceneObjectWrapper()); -	 +  	if (R2_GLOBALS._player._characterIndex == R2_QUINN) {  		_actor12.setVisage(1506);  		_actor12._moveDiff = Common::Point(3, 1); @@ -9883,41 +9883,41 @@ void Scene1700::postInit(SceneObjectList *OwnerList) {  		_actor12._moveDiff = Common::Point(2, 1);  		_actor12.setDetails(9001, 1, -1, -1, 1, (SceneItem *) NULL);  	} -	 +  	R2_GLOBALS._sound1.play(134); -	 +  	_actor1.postInit();  	_actor1.fixPriority(10); -	 +  	if (R2_GLOBALS._player._characterIndex == R2_QUINN)  		_actor1.setVisage(1112); -	else  +	else  		_actor1.setVisage(1111); -	 +  	_actor1._effect = 5;  	_actor1._field9C = _field312;  	R2_GLOBALS._player._linkedActor = &_actor1; -	 +  	_actor2.postInit();  	_actor2.fixPriority(10);  	if (R2_GLOBALS._player._characterIndex == R2_QUINN)  		_actor2.setVisage(1111); -	else  +	else  		_actor2.setVisage(1112); -	 +  	_actor2._effect = 5;  	_actor2._field9C = _field312;  	_actor12._linkedActor = &_actor2; -	 +  	R2_GLOBALS._sound1.play(134); -	 +  	switch (R2_GLOBALS._sceneManager._previousScene) {  	case 1530:  		R2_GLOBALS._player._characterIndex = R2_QUINN;  		R2_GLOBALS._player.disableControl();  		R2_GLOBALS._player.hide();  		_actor12.hide(); -		 +  		_actor10.postInit();  		warning("_actor10._actorName = \"hatch\";");  		_actor10.hide(); @@ -9926,7 +9926,7 @@ void Scene1700::postInit(SceneObjectList *OwnerList) {  		_actor9.setup(1701, 1, 1);  		_actor9.setPosition(Common::Point(220, 137));  		_actor9.setDetails(1700, 6, -1, -1, 1, (SceneItem *) NULL); -		 +  		_actor1.hide();  		_actor2.hide();  		R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); @@ -10003,7 +10003,7 @@ void Scene1700::signal() {  		Common::Point pt(R2_GLOBALS._player._position.x, 160);  		NpcMover *mover = new NpcMover();  		R2_GLOBALS._player.addMover(mover, &pt, this); -		 +  		if (R2_GLOBALS._player._position.x < 132) {  			_actor12.setPosition(Common::Point(156, 170));  			Common::Point pt2(156, 160); @@ -10028,7 +10028,7 @@ void Scene1700::signal() {  		Common::Point pt(R2_GLOBALS._player._position.x, 10);  		NpcMover *mover = new NpcMover();  		R2_GLOBALS._player.addMover(mover, &pt, this); -		 +  		if (R2_GLOBALS._player._position.x >= 171) {  			_actor12.setPosition(Common::Point(155, 0));  			Common::Point pt2(155, 10); @@ -10112,7 +10112,7 @@ void Scene1700::signal() {  			R2_GLOBALS._walkRegions.enableRegion(15);  		else  			R2_GLOBALS._walkRegions.enableRegion(17); -		 +  		R2_GLOBALS._player.enableControl();  		break;  	case 1704: @@ -10130,7 +10130,7 @@ void Scene1700::signal() {  }  /*-------------------------------------------------------------------------- - * Scene 1750 -  + * Scene 1750 -   *   *--------------------------------------------------------------------------*/  Scene1750::Actor4::Actor4() { @@ -10193,7 +10193,7 @@ void Scene1750::Actor4::subB1A76(int arg1, int arg2, int arg3, int arg4, int arg  	_fieldA8 = arg3;  	_fieldAA = arg4;  	_fieldAC = arg5; -	 +  	postInit();  	setup(1750, 1, 1);  	fixPriority(255); @@ -10227,7 +10227,7 @@ void Scene1750::Actor4::process(Event &event) {  		addMover(NULL);  		subB1B27();  	} -	 +  	if (_fieldAE != 0) {  		event.handled = true;  		if (event.mousePos.y >= _fieldA8) { @@ -10251,7 +10251,7 @@ bool Scene1750::Actor4::startAction(CursorType action, Event &event) {  bool Scene1750::Actor5::startAction(CursorType action, Event &event) {  	if (action != CURSOR_USE)  		return SceneActor::startAction(action, event); -	 +  	Scene1750 *scene = (Scene1750 *)R2_GLOBALS._sceneManager._scene;  	switch (_fieldA4) { @@ -10294,7 +10294,7 @@ void Scene1750::postInit(SceneObjectList *OwnerList) {  	R2_GLOBALS._uiElements._active = false;  	R2_GLOBALS._v5589E.set(0, 0, 320, 200);  	SceneExt::postInit(); -	 +  	R2_GLOBALS._player._characterScene[1] = 1750;  	R2_GLOBALS._player._characterScene[2] = 1750;  	R2_GLOBALS._player._oldCharacterScene[1] = 1750; @@ -10304,7 +10304,7 @@ void Scene1750::postInit(SceneObjectList *OwnerList) {  	_rotation->setDelay(0);  	_rotation->_idxChange = 0;  	_rotation->_countdown = 2; -	 +  	switch ((R2_GLOBALS._v565F6 + 2) % 4) {  	case 0:  		_rotation->_currIndex = 247; @@ -10321,7 +10321,7 @@ void Scene1750::postInit(SceneObjectList *OwnerList) {  	default:  		break;  	} -	 +  	byte tmpPal[768];  	for (int i = 224; i < 255; i++) { @@ -10348,40 +10348,40 @@ void Scene1750::postInit(SceneObjectList *OwnerList) {  	_actor3.setPosition(Common::Point(49, 185));  	_actor3.fixPriority(7);  	_actor3.setDetails(1750, 30, -1, -1, 1, (SceneItem *) NULL); -	 +  	_actor1.postInit();  	_actor1.setup(1750, 2, 1);  	_actor1.setPosition(Common::Point(35, ((_rotation->_currIndex - 218) % 4) + ((R2_GLOBALS._v565F6 % 800) * 4) - 1440));  	_actor1.fixPriority(8); -	 +  	_actor2.postInit();  	_actor2.setup(1750, 1, 4); -	 +  	int tmpVar = abs(_actor1._position.y - 158) / 100; -	 +  	if (tmpVar >= 8)  		_actor2.hide();  	else if (_actor1._position.y <= 158)  		_actor2.setPosition(Common::Point(137, (tmpVar * 7) + 122));  	else  		_actor2.setPosition(Common::Point(148, (tmpVar * 7) + 122)); -	 +  	_actor4.subB1A76(1, 286, 143, 41, 15);  	_actor4.setDetails(1750, 24, 1, -1, 1, (SceneItem *) NULL); -	 +  	_actor5.postInit();  	_actor5._fieldA4 = 1;  	_actor5.setup(1750, 1, 2);  	_actor5.setPosition(Common::Point(192, 140));  	_actor5.setDetails(1750, 18, 1, -1, 1, (SceneItem *) NULL); -	 +  	_actor6.postInit();  	_actor6._fieldA4 = 2;  	_actor6.setup(1750, 1, 3);  	_actor6.setPosition(Common::Point(192, 163));  	_actor6.setDetails(1750, 18, 1, -1, 1, (SceneItem *) NULL);  	_actor6.hide(); -	 +  	_actor7.postInit();  	_actor7._fieldA4 = 3;  	_actor7.setup(1750, 1, 5); @@ -10393,7 +10393,7 @@ void Scene1750::postInit(SceneObjectList *OwnerList) {  	_field413 = 0;  	_field415 = 0;  	_field419 = ((_rotation->_currIndex - 218) / 4) % 4; -	 +  	_item2.setDetails(Rect(129, 112, 155, 175), 1750, 21, -1, -1, 1, NULL);  	_item3.setDetails(Rect(93, 122, 126, 172), 1750, 15, -1, -1, 1, NULL);  	_item4.setDetails(Rect(3, 3, 157, 99), 1750, 9, -1, -1, 1, NULL); @@ -10403,15 +10403,15 @@ void Scene1750::postInit(SceneObjectList *OwnerList) {  void Scene1750::remove() {  	_rotation->remove(); -	 +  	if (R2_GLOBALS._v565F6 == 2400)  		R2_GLOBALS._v565F6 = 2399; -	 +  	if (R2_GLOBALS._v565F6 == -2400)  		R2_GLOBALS._v565F6 = -2399; -	 +  	R2_GLOBALS._v565FA = R2_GLOBALS._v565F6; -	 +  	SceneExt::remove();  	R2_GLOBALS._sound1.fadeOut2(NULL);  	R2_GLOBALS._v5589E.top = 3; @@ -10432,7 +10432,7 @@ void Scene1750::process(Event &event) {  void Scene1750::dispatch() {}  /*-------------------------------------------------------------------------- - * Scene 1800 -  + * Scene 1800 -   *   *--------------------------------------------------------------------------*/  Scene1800::Scene1800() { @@ -10448,10 +10448,10 @@ void Scene1800::synchronize(Serializer &s) {  bool Scene1800::Hotspot5::startAction(CursorType action, Event &event) {  	if ((action != R2_COM_SCANNER) && (action != R2_COM_SCANNER_2))  		return false; -	 +  	Scene1800 *scene = (Scene1800 *)R2_GLOBALS._sceneManager._scene; -	R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS);	 +	R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS);  	if (R2_GLOBALS._player._characterIndex == R2_QUINN) {  		if (R2_GLOBALS._v565F6 == 1201) { @@ -10624,41 +10624,41 @@ void Scene1800::postInit(SceneObjectList *OwnerList) {  	R2_GLOBALS._sound1.play(116);  	_stripManager.addSpeaker(&_quinnSpeaker);  	_stripManager.addSpeaker(&_seekerSpeaker); -	 +  	if (R2_GLOBALS._sceneManager._previousScene == -1)  		R2_GLOBALS._v565F6 = 1201; -	 +  	if (R2_GLOBALS._v565F6 == 1201)  		_field412 = 2;  	else  		_field412 = 0; -	 +  	scalePalette(65, 65, 65);  	_exit1.setDetails(Rect(0, 160, 319, 168), EXITCURSOR_S, 1800);  	_item5.setDetails(Rect(0, 0, 320, 200), -1, -1, -1, -1, 1, NULL); -	 +  	_actor6.postInit();  	_actor6.setup(1801, 4, 1);  	_actor6.setPosition(Common::Point(170, 24));  	_actor6.setDetails(1800, 13, 14, 15, 1, (SceneItem *) NULL); -	 +  	_actor7.postInit();  	_actor7.setup(1801, 3, 1);  	_actor7.setPosition(Common::Point(160, 139));  	_actor7.setDetails(1800, 6, -1, -1, 1, (SceneItem *) NULL); -	 +  	_actor8.postInit();  	_actor8.setup(1800, 1, 1);  	_actor8.setPosition(Common::Point(110, 78));  	_actor8.fixPriority(135);  	_actor8.setDetails(1800, 20, -1, -1, 1, (SceneItem *) NULL); -	 +  	_actor9.postInit();  	_actor9.setup(1800, 2, 1);  	_actor9.setPosition(Common::Point(209, 78));  	_actor9.fixPriority(135);  	_actor9.setDetails(1800, 20, -1, -1, 1, (SceneItem *) NULL); -	 +  	_actor4.postInit();  	if ((_field412 != 1) && (_field412 != 3) && (!R2_GLOBALS.getFlag(64)))  		_actor4.setup(1801, 2, 1); @@ -10666,7 +10666,7 @@ void Scene1800::postInit(SceneObjectList *OwnerList) {  		_actor4.setup(1801, 2, 10);  	_actor4.setPosition(Common::Point(76, 142));  	_actor4.setDetails(1800, 3, -1, -1, 1, (SceneItem *) NULL); -	 +  	_actor5.postInit();  	if ((_field412 != 1) && (_field412 != 3) && (!R2_GLOBALS.getFlag(64)))  		_actor5.setup(1801, 1, 1); @@ -10674,7 +10674,7 @@ void Scene1800::postInit(SceneObjectList *OwnerList) {  		_actor5.setup(1801, 1, 10);  	_actor5.setPosition(Common::Point(243, 142));  	_actor5.setDetails(1800, 3, -1, -1, 1, (SceneItem *) NULL); -	 +  	R2_GLOBALS._player.postInit();  	R2_GLOBALS._player.animate(ANIM_MODE_1, NULL);  	if (R2_GLOBALS._player._characterIndex == R2_QUINN) { @@ -10693,7 +10693,7 @@ void Scene1800::postInit(SceneObjectList *OwnerList) {  		R2_GLOBALS._player.setVisage(1503);  		R2_GLOBALS._player._moveDiff = Common::Point(2, 2);  	} -	 +  	_actor2.postInit();  	_actor2.animate(ANIM_MODE_1, NULL);  	_actor2.setObjectWrapper(new SceneObjectWrapper()); @@ -10716,7 +10716,7 @@ void Scene1800::postInit(SceneObjectList *OwnerList) {  		_actor2.setVisage(1503);  		_actor2._moveDiff = Common::Point(2, 2);  	} -	 +  	if (R2_GLOBALS._player._oldCharacterScene[R2_GLOBALS._player._characterIndex] == 1800) {  		if (R2_GLOBALS._player._characterIndex == R2_QUINN) {  			R2_GLOBALS._player.setPosition(Common::Point(114, 150)); @@ -10751,34 +10751,34 @@ void Scene1800::postInit(SceneObjectList *OwnerList) {  			_actor2.setPosition(Common::Point(140, 160));  		}  	} -	 +  	_actor1.postInit();  	_actor1.fixPriority(10);  	if (R2_GLOBALS._player._characterIndex == R2_QUINN)  		_actor1.setVisage(1111);  	else  		_actor1.setVisage(1110); -	 +  	_actor1._effect = 5;  	_actor1._field9C = _field312;  	R2_GLOBALS._player._linkedActor = &_actor1; -	 +  	_actor3.postInit();  	_actor3.fixPriority(10);  	if (R2_GLOBALS._player._characterIndex == R2_QUINN)  		_actor3.setVisage(1110);  	else  		_actor3.setVisage(1111); -	 +  	_actor3._effect = 5;  	_actor3._field9C = _field312; -	 +  	_actor2._linkedActor = &_actor3; -	 +  	R2_GLOBALS._player._characterScene[1] = 1800;  	R2_GLOBALS._player._characterScene[2] = 1800; -	 +  	_item2.setDetails(Rect(128, 95, 190, 135), 1800, 10, -1, -1, 1, NULL);  	_item1.setDetails(Rect(95, 3, 223, 135), 1800, 0, -1, -1, 1, NULL); @@ -10786,7 +10786,7 @@ void Scene1800::postInit(SceneObjectList *OwnerList) {  	// This is *wrong*. The following statement is a wild guess based on good common sense  	_item3.setDetails(11, 1800, 23, 24, 25);  	_item4.setDetails(Rect(0, 0, 320, 200), 1800, 17, -1, 19, 1, NULL); -	 +  	R2_GLOBALS._player.disableControl();  	if (R2_GLOBALS._player._oldCharacterScene[R2_GLOBALS._player._characterIndex] == 1800) {  		if ((R2_GLOBALS.getFlag(14)) && (R2_GLOBALS._player._characterIndex == R2_SEEKER)) { @@ -10822,7 +10822,7 @@ void Scene1800::postInit(SceneObjectList *OwnerList) {  			setAction(&_sequenceManager, this, 1801, &R2_GLOBALS._player, &_actor2, NULL);  		}  	} -	 +  	R2_GLOBALS._player._oldCharacterScene[1] = 1800;  	R2_GLOBALS._player._oldCharacterScene[2] = 1800;  } @@ -10956,7 +10956,7 @@ void Scene1800::saveCharacter(int characterIndex) {  }  /*-------------------------------------------------------------------------- - * Scene 1850 -  + * Scene 1850 -   *   *--------------------------------------------------------------------------*/  Scene1850::Scene1850() { @@ -10970,7 +10970,7 @@ void Scene1850::synchronize(Serializer &s) {  bool Scene1850::Hotspot2::startAction(CursorType action, Event &event) {  	if (action != CURSOR_USE)  		return SceneHotspot::startAction(action, event); -	 +  	Scene1850 *scene = (Scene1850 *)R2_GLOBALS._sceneManager._scene;  	R2_GLOBALS._player.disableControl(); @@ -10988,7 +10988,7 @@ bool Scene1850::Hotspot2::startAction(CursorType action, Event &event) {  			scene->setAction(&scene->_sequenceManager1, scene, 1860, &R2_GLOBALS._player, &scene->_actor5, NULL);  		else  			scene->setAction(&scene->_sequenceManager1, scene, 1859, &R2_GLOBALS._player, &scene->_actor5, NULL); -		 +  		R2_GLOBALS.clearFlag(30);  	} else {  		scene->_sceneMode = 1853; @@ -10998,7 +10998,7 @@ bool Scene1850::Hotspot2::startAction(CursorType action, Event &event) {  		else  			scene->setAction(&scene->_sequenceManager1, scene, 1853, &R2_GLOBALS._player, NULL);  	} -	 +  	return true;  } @@ -11009,10 +11009,10 @@ bool Scene1850::Actor5::startAction(CursorType action, Event &event) {  	case CURSOR_USE:  		if ((R2_GLOBALS._player._characterIndex != R2_SEEKER) || (R2_GLOBALS.getFlag(33)) || (R2_GLOBALS.getFlag(30)))  			return SceneActor::startAction(action, event); -		 +  		R2_GLOBALS._player.disableControl();  		scene->_sceneMode = 1857; -		 +  		if (R2_GLOBALS.getFlag(32))  			scene->setAction(&scene->_sequenceManager1, scene, 1858, &R2_GLOBALS._player, &scene->_actor5, NULL);  		else @@ -11026,7 +11026,7 @@ bool Scene1850::Actor5::startAction(CursorType action, Event &event) {  			SceneItem::display(1850, 2, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, -999);  		else  			SceneItem::display(1850, 1, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, -999); -		 +  		return true;  		break;  	case R2_AIRBAG: @@ -11046,7 +11046,7 @@ bool Scene1850::Actor5::startAction(CursorType action, Event &event) {  			R2_GLOBALS._player.disableControl();  			scene->_sceneMode = 1875;  			scene->_actor2.postInit(); -			 +  			if (R2_GLOBALS.getFlag(32))  				scene->setAction(&scene->_sequenceManager1, scene, 1876, &R2_GLOBALS._player, &scene->_actor2, NULL);  			else @@ -11059,7 +11059,7 @@ bool Scene1850::Actor5::startAction(CursorType action, Event &event) {  			R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS);  			scene->_stripManager.start(557, scene);  			R2_GLOBALS.setFlag(69); -			 +  			return true;  		} else {  			return SceneActor::startAction(action, event); @@ -11074,7 +11074,7 @@ bool Scene1850::Actor5::startAction(CursorType action, Event &event) {  			scene->_sceneMode = 1878;  			scene->setAction(&scene->_sequenceManager1, scene, 1878, &R2_GLOBALS._player, &scene->_actor5, &scene->_actor2, NULL);  		} -		 +  		return true;  		break;  	default: @@ -11086,31 +11086,31 @@ bool Scene1850::Actor5::startAction(CursorType action, Event &event) {  bool Scene1850::Actor6::startAction(CursorType action, Event &event) {  	if (action != CURSOR_USE)  		return SceneHotspot::startAction(action, event); -	 +  	Scene1850 *scene = (Scene1850 *)R2_GLOBALS._sceneManager._scene; -	 +  	if (R2_GLOBALS.getFlag(32)) {  		SceneItem::display(3240, 4, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, -999);  		return true;  	} -	 +  	R2_GLOBALS._player.disableControl();  	if (scene->_field412 == 1851)  		R2_GLOBALS._player._effect = 1; -	 +  	if (_position.x >= 160)  		R2_GLOBALS.setFlag(29); -	else  +	else  		R2_GLOBALS.clearFlag(29); -	 +  	if ((R2_GLOBALS._player._characterIndex == R2_SEEKER) && (R2_GLOBALS.getFlag(30))) {  		if (_position.x >= 160)  			scene->_field41E = 3;  		else  			scene->_field41E = 2; -		 +  		scene->_sceneMode = 1860; -		 +  		if (R2_GLOBALS.getFlag(32)) {  			scene->setAction(&scene->_sequenceManager1, scene, 1860, &R2_GLOBALS._player, &scene->_actor5, NULL);  		} else { @@ -11136,13 +11136,13 @@ bool Scene1850::Actor8::startAction(CursorType action, Event &event) {  	R2_GLOBALS._player.disableControl();  	scene->_sceneMode = 1881; -	 +  	if (R2_GLOBALS._player._characterIndex == R2_QUINN) {  		scene->setAction(&scene->_sequenceManager1, scene, 1881, &R2_GLOBALS._player, NULL);  	} else {  		scene->setAction(&scene->_sequenceManager1, scene, 1880, &R2_GLOBALS._player, NULL);  	} -	 +  	return true;  } @@ -11166,10 +11166,10 @@ void Scene1850::postInit(SceneObjectList *OwnerList) {  	if (R2_GLOBALS._sceneManager._previousScene == 3150)  		R2_GLOBALS._sound1.play(116); -	 +  	_stripManager.addSpeaker(&_quinnSpeaker);  	_stripManager.addSpeaker(&_seekerSpeaker); -	 +  	_field418 = 0;  	_field41E = 0;  	_field41A = Common::Point(0, 0); @@ -11192,7 +11192,7 @@ void Scene1850::postInit(SceneObjectList *OwnerList) {  	R2_GLOBALS._walkRegions.enableRegion(1);  	_actor5.postInit(); -	 +  	if (R2_GLOBALS.getFlag(34)) {  		R2_GLOBALS._walkRegions.enableRegion(2);  		_actor5.setup(1851, 4, 3); @@ -11371,7 +11371,7 @@ void Scene1850::postInit(SceneObjectList *OwnerList) {  				R2_GLOBALS._player.setPosition(Common::Point(164, 106));  			} -		}  +		}  		R2_GLOBALS._player.enableControl();  	} else { // R2_GLOBALS._player._oldCharacterScene[R2_GLOBALS._player._characterIndex] != 1850 @@ -11412,7 +11412,7 @@ void Scene1850::postInit(SceneObjectList *OwnerList) {  	}  	_actor8.fixPriority(113); -	 +  	if (R2_GLOBALS.getFlag(34)) {  		_actor8.setDetails(1850, 25, -1, -1, 4, &_actor5);  	} else { @@ -11432,10 +11432,10 @@ void Scene1850::postInit(SceneObjectList *OwnerList) {  void Scene1850::remove() {  	g_globals->_scenePalette.loadPalette(0); -	R2_GLOBALS._scenePalette._palette[771] = 255; -	R2_GLOBALS._scenePalette._palette[772] = 255; -	R2_GLOBALS._scenePalette._palette[773] = 255; -	 +	R2_GLOBALS._scenePalette._palette[765] = 255; +	R2_GLOBALS._scenePalette._palette[766] = 255; +	R2_GLOBALS._scenePalette._palette[767] = 255; +  	SceneExt::remove();  } @@ -11447,9 +11447,9 @@ void Scene1850::signal() {  		_actor1._effect = 6;  		_actor1._shade = 6; -		 +  		R2_GLOBALS._walkRegions.enableRegion(5); -		 +  		if (R2_GLOBALS.getFlag(68)) {  			R2_GLOBALS._player.enableControl();  		} else { @@ -11495,7 +11495,7 @@ void Scene1850::signal() {  			_palette1.loadPalette(1851);  			_field412 = 1851;  		} -		 +  		_field418 = 1;  		if (R2_GLOBALS.getFlag(30)) {  			_actor8.setAction(&_sequenceManager2, NULL, 1867, &_actor8, NULL); @@ -11511,33 +11511,33 @@ void Scene1850::signal() {  				R2_GLOBALS.setFlag(62);  				R2_GLOBALS.setFlag(34);  				R2_GLOBALS._walkRegions.enableRegion(2); -				 +  				_actor2.postInit();  				_actor2.setDetails(1850, 6, -1, -1, 5, &_actor5); -				 +  				_sceneMode = 1879;  				_actor8.setAction(&_sequenceManager2, this, 1879, &_actor5, &_actor8, &_actor2, NULL);  		} else {  			_actor8.setAction(&_sequenceManager2, NULL, 1867, &_actor8, NULL);  		} -		 +  		if (R2_GLOBALS.getFlag(34))  			R2_GLOBALS._scenePalette.addFader(_palette1._palette, 256, 5, NULL);  		else  			R2_GLOBALS._scenePalette.addFader(_palette1._palette, 256, 5, this); -		 +  		if (_field412 == 1851)  			_field416 = -20;  		else  			_field416 = 20; -		 +  		_field414 = 20; -		 +  		if (R2_GLOBALS._player._characterIndex == R2_QUINN) {  			if (_sceneMode == 1879)  				_sceneMode = 1854; -			 +  			if (R2_GLOBALS.getFlag(32)) {  				setAction(&_sequenceManager1, NULL, 1873, &R2_GLOBALS._player, NULL);  			} else { @@ -11546,7 +11546,7 @@ void Scene1850::signal() {  		} else {  			if (_sceneMode == 1879)  				_sceneMode = 1855; -			 +  			if (R2_GLOBALS.getFlag(32)) {  				setAction(&_sequenceManager1, NULL, 1874, &R2_GLOBALS._player, NULL);  			} else { @@ -11583,10 +11583,10 @@ void Scene1850::signal() {  			PlayerMover *mover = new PlayerMover();  			R2_GLOBALS._player.addMover(mover, &_field41A, this); -			 +  			_field41A = Common::Point(0, 0);  		} -		 +  		switch (_field41E) {  		case 1:  			_sceneMode = 1853; @@ -11608,7 +11608,7 @@ void Scene1850::signal() {  		default:  			break;  		} -		 +  		_field41E = 0;  		break;  	case 1870: @@ -11632,16 +11632,16 @@ void Scene1850::signal() {  		} else {  			_actor3.setDetails(1850, 30, -1, -1, 2, (SceneItem *)NULL);  		} -		 +  		_actor4.postInit();  		_actor4._effect = 6; -		 +  		if (R2_GLOBALS._player._characterIndex == R2_QUINN) {  			_actor4.setDetails(1850, 29, -1, -1, 2, (SceneItem *)NULL);  		} else {  			_actor4.setDetails(1850, 28, -1, -1, 2, (SceneItem *)NULL);  		} -		 +  		if (R2_GLOBALS.getFlag(31)) {  			_actor3._shade = 0;  			_actor4._shade = 0; @@ -11649,12 +11649,12 @@ void Scene1850::signal() {  			_actor3._shade = 6;  			_actor4._shade = 6;  		} -			 +  		R2_GLOBALS.clearFlag(30);  		_sceneMode = 15;  		setAction(&_sequenceManager1, this, 1869, &R2_GLOBALS._player, &_actor3, NULL);  		setAction(&_sequenceManager2, this, 1868, &_actor1, &_actor4, NULL); -		break;		 +		break;  	case 1878:  		R2_INVENTORY.setObjectScene(R2_REBREATHER_TANK, 1850);  		R2_GLOBALS.setFlag(33); @@ -11678,7 +11678,7 @@ void Scene1850::signal() {  }  void Scene1850::process(Event &event) { -	if ( (event.eventType == EVENT_BUTTON_DOWN) && (R2_GLOBALS._events.getCursor() == CURSOR_ARROW)  +	if ( (event.eventType == EVENT_BUTTON_DOWN) && (R2_GLOBALS._events.getCursor() == CURSOR_ARROW)  		&& (R2_GLOBALS._player._characterIndex == R2_SEEKER) && (R2_GLOBALS.getFlag(30))) {  		_field41A = event.mousePos;  		R2_GLOBALS._player.disableControl(); @@ -11691,7 +11691,7 @@ void Scene1850::process(Event &event) {  		R2_GLOBALS.clearFlag(32);  		event.handled = true;  	} -	 +  	Scene::process(event);  } @@ -11700,7 +11700,7 @@ void Scene1850::dispatch() {  		_field414--;  		if (_field414 == 0)  			_field418 = 0; -		 +  		if (_field416 >= 0) {  			R2_GLOBALS._player._shade = (_field414 * 6) / _field416;  		} else { @@ -11726,12 +11726,12 @@ void Scene1850::dispatch() {  	if (R2_INVENTORY.getObjectScene(R2_AIRBAG) == 1850) {  		_actor2.setPosition(Common::Point(_actor8._position.x + 20, _actor8._position.y - 71));  	} -	 +  	Scene::dispatch();  }  /*-------------------------------------------------------------------------- - * Scene 1875 -  + * Scene 1875 -   *   *--------------------------------------------------------------------------*/  Scene1875::Actor1875::Actor1875() { @@ -11821,7 +11821,7 @@ void Scene1875::Actor1875::subB8271(int indx) {  void Scene1875::Actor1875::process(Event &event) {  	if ((R2_GLOBALS._player._uiEnabled) || (event.handled))  		return; -	 +  	Scene1875 *scene = (Scene1875 *)R2_GLOBALS._sceneManager._scene;  	if ((event.eventType == EVENT_BUTTON_DOWN) && (R2_GLOBALS._events.getCursor() == R2_STEPPING_DISKS) && (_bounds.contains(event.mousePos)) && (_fieldA6 == 0)) { @@ -11841,7 +11841,7 @@ void Scene1875::Actor1875::process(Event &event) {  		_fieldA6 = 1;  		event.handled = true;  	} -	 +  	if ((event.eventType == EVENT_BUTTON_UP) && (_fieldA6 != 0)) {  		if ((_fieldA4 == 3) || (_fieldA4 == 4) || (_fieldA4 == 5)) {  			setStrip(1); @@ -11855,10 +11855,10 @@ void Scene1875::Actor1875::process(Event &event) {  void Scene1875::postInit(SceneObjectList *OwnerList) {  	loadScene(1875);  	SceneExt::postInit(); -	 +  	R2_GLOBALS._player._characterScene[1] = 1875;  	R2_GLOBALS._player._characterScene[2] = 1875; -	 +  	_stripManager.addSpeaker(&_quinnSpeaker);  	_stripManager.addSpeaker(&_seekerSpeaker); @@ -11867,11 +11867,11 @@ void Scene1875::postInit(SceneObjectList *OwnerList) {  	_actor6.subB8271(3);  	_actor7.subB8271(4);  	_actor8.subB8271(5); -	 +  	_actor1.postInit();  	_actor1.setup(1855, 4, 1);  	_actor1.setPosition(Common::Point(160, 116)); -	 +  	R2_GLOBALS._player.postInit();  	if (R2_GLOBALS._sceneManager._previousScene == 1625) {  		R2_GLOBALS._sound1.play(122); @@ -11885,10 +11885,10 @@ void Scene1875::postInit(SceneObjectList *OwnerList) {  		R2_GLOBALS._player.enableControl();  		R2_GLOBALS._player._canWalk = false;  	} -	 +  	_item2.setDetails(Rect(43, 14, 275, 122), 1875, 9, 1, -1, 1, NULL);  	_item1.setDetails(Rect(0, 0, 320, 200), 1875, 3, -1, -1, 1, NULL); -	 +  	R2_GLOBALS._player._characterScene[1] = 1875;  	R2_GLOBALS._player._characterScene[2] = 1875;  	R2_GLOBALS._player._oldCharacterScene[1] = 1875; @@ -11930,7 +11930,7 @@ void Scene1875::signal() {  void Scene1875::process(Event &event) {  	Scene::process(event); -	 +  	_actor4.process(event);  	_actor5.process(event);  	_actor6.process(event); @@ -11939,7 +11939,7 @@ void Scene1875::process(Event &event) {  }  /*-------------------------------------------------------------------------- - * Scene 1900 -  + * Scene 1900 -   *   *--------------------------------------------------------------------------*/  bool Scene1900::Actor2::startAction(CursorType action, Event &event) { @@ -12005,11 +12005,11 @@ void Scene1900::postInit(SceneObjectList *OwnerList) {  	if (R2_GLOBALS._sceneManager._previousScene != 1875)  		R2_GLOBALS._sound1.play(200); -	 +  	_stripManager.setColors(60, 255);  	_stripManager.setFontNumber(3);  	_stripManager.addSpeaker(&_seekerSpeaker); -	 +  	_exit1.setDetails(Rect(0, 105, 14, 145), R2_COM_SCANNER, 2000);  	_exit1.setDest(Common::Point(14, 135)); @@ -12027,7 +12027,7 @@ void Scene1900::postInit(SceneObjectList *OwnerList) {  	else  		R2_GLOBALS._player._moveDiff = Common::Point(5, 3);  	R2_GLOBALS._player.disableControl(); -	 +  	if (R2_GLOBALS._sceneManager._previousScene != 1925)  		R2_GLOBALS.clearFlag(29); @@ -12061,7 +12061,7 @@ void Scene1900::postInit(SceneObjectList *OwnerList) {  		_object2.setPosition(Common::Point(223, 109));  		_object2.fixPriority(80);  	} -	 +  	if (R2_GLOBALS._player._oldCharacterScene[R2_GLOBALS._player._characterIndex] == 1875) {  		R2_GLOBALS._player._characterIndex = R2_QUINN;  		_actor1.postInit(); @@ -12129,7 +12129,7 @@ void Scene1900::postInit(SceneObjectList *OwnerList) {  		}  		R2_GLOBALS._player._oldCharacterScene[R2_GLOBALS._player._characterIndex] = 1900;  	} -	 +  	_item2.setDetails(Rect(77, 2, 240, 103), 1900, 6, -1, -1, 1, NULL);  	_item1.setDetails(Rect(0, 0, 320, 200), 1900, 3, -1, -1, 1, NULL);  } @@ -12242,17 +12242,17 @@ bool Scene1925::Hotspot3::startAction(CursorType action, Event &event) {  		scene->_sceneMode = 1925;  		scene->setAction(&scene->_sequenceManager, scene, scene->_sceneMode, &R2_GLOBALS._player, &scene->_actor1, NULL);  		return true; -	}  -	 +	} +  	if ((R2_GLOBALS._player._position.x == 154) && (R2_GLOBALS._player._position.y == 20) && (event.mousePos.y >= 30)) {  		scene->_sceneMode = 1931;  	} else if ((R2_GLOBALS._player._position.x == 154) && (R2_GLOBALS._player._position.y == 200) && (event.mousePos.y < 140)) {  		scene->_sceneMode = 1932; -	} else if ( (   ((R2_GLOBALS._player._position.x == 112) && (R2_GLOBALS._player._position.y == 101))  +	} else if ( (   ((R2_GLOBALS._player._position.x == 112) && (R2_GLOBALS._player._position.y == 101))  		         || ((R2_GLOBALS._player._position.x == 154) && (R2_GLOBALS._player._position.y == 110))  				 ) && (event.mousePos.y >= 100)) {  		scene->_sceneMode = 1926; -	} else if ( (   ((R2_GLOBALS._player._position.x == 112) && (R2_GLOBALS._player._position.y == 101))  +	} else if ( (   ((R2_GLOBALS._player._position.x == 112) && (R2_GLOBALS._player._position.y == 101))  		         || ((R2_GLOBALS._player._position.x == 154) && (R2_GLOBALS._player._position.y == 110))  				 ) && (event.mousePos.y < 60)) {  		scene->_sceneMode = 1927; @@ -12415,7 +12415,7 @@ void Scene1925::postInit(SceneObjectList *OwnerList) {  		_actor1.setDetails(1925, 0, 1, 2, 1, (SceneItem *) NULL);  		_item2.setDetails(Rect(133, 68, 140, 77), 1925, 3, -1, 5, 1, NULL);  	// No break on purpose -	case -3:  +	case -3:  		_exit3.setDetails(Rect(83, 38, 128, 101), EXITCURSOR_W, 1925);  	// No break on purpose  	default: @@ -12510,7 +12510,7 @@ void Scene1925::signal() {  }  /*-------------------------------------------------------------------------- - * Scene 1945 -  + * Scene 1945 -   *   *--------------------------------------------------------------------------*/  Scene1945::Scene1945() { @@ -12588,7 +12588,7 @@ bool Scene1945::Hotspot4::startAction(CursorType action, Event &event) {  		R2_GLOBALS._player.enableControl(CURSOR_USE);  		R2_GLOBALS._player._canWalk = false;  	} -	 +  	if (scene->_sceneMode != 0)  		scene->setAction(&scene->_sequenceManager1, scene, scene->_sceneMode, &R2_GLOBALS._player, NULL); @@ -12822,7 +12822,7 @@ void Scene1945::signal() {  }  /*-------------------------------------------------------------------------- - * Scene 1950 -  + * Scene 1950 -   *   *--------------------------------------------------------------------------*/  Scene1950::Area1::Area1() { @@ -12831,7 +12831,7 @@ Scene1950::Area1::Area1() {  }  void Scene1950::Area1::synchronize(Serializer &s) {  	SceneArea::synchronize(s); -	 +  	s.syncAsByte(_field20);  	s.syncAsSint16LE(_fieldB65);  } @@ -12846,7 +12846,7 @@ Scene1950::Scene1950() {  void Scene1950::synchronize(Serializer &s) {  	SceneExt::synchronize(s); -	 +  	s.syncAsSint16LE(_field412);  	s.syncAsSint16LE(_field414);  	s.syncAsSint16LE(_field416); @@ -12863,7 +12863,7 @@ Scene1950::Area1::Actor10::Actor10() {  void Scene1950::Area1::Actor10::synchronize(Serializer &s) {  	SceneActor::synchronize(s); -	 +  	s.syncAsSint16LE(_fieldA4);  	s.syncAsSint16LE(_fieldA6);  	s.syncAsSint16LE(_fieldA8); @@ -12925,7 +12925,7 @@ void Scene1950::Area1::remove() {  	SceneArea::remove();  	R2_GLOBALS._insetUp--;  	// -	 +  	if (!R2_GLOBALS.getFlag(37))  		R2_GLOBALS._sound2.play(278); @@ -12990,7 +12990,7 @@ void Scene1950::Area1::proc12(int visage, int stripFrameNum, int frameNum, int p  	_areaActor.fixPriority(248);  	scene->_exit3._enabled = false;  	proc13(1950, 27, 28, 27); -	 +  	for (_fieldB65 = 0; _fieldB65 < 16; _fieldB65++)  		_arrActor1[_fieldB65].init(_fieldB65);  } @@ -13068,7 +13068,7 @@ Scene1950::Actor8::Actor8() {  void Scene1950::Actor8::synchronize(Serializer &s) {  	SceneActor::synchronize(s); -	 +  	s.syncAsSint16LE(_fieldA4);  	s.syncAsSint16LE(_fieldA6);  	s.syncAsSint16LE(_fieldA8); @@ -13111,7 +13111,7 @@ void Scene1950::Actor8::signal() {  		_fieldA6 = _position.y -4;  		setVisage(1961); -		 +  		if (R2_GLOBALS._v566A5 == 3)  			setStrip(2);  		else @@ -13155,7 +13155,7 @@ void Scene1950::Actor8::signal() {  		for (_fieldAF = 0; _fieldAF < 18; ++_fieldAF)  			if (R2_GLOBALS._v56613[4 * _fieldAF] == 0)  				++_fieldAE; -		 +  		if (_fieldAE == 18) {  			R2_GLOBALS.setFlag(36);  			_fieldAC = 23; @@ -13197,14 +13197,14 @@ bool Scene1950::Actor8::startAction(CursorType action, Event &event) {  	if ((R2_GLOBALS._v56613[(scene->_field41C - 1) * 4] == 0) || (action != R2_PHOTON_STUNNER))  		return SceneActor::startAction(action, event); -	 +  	R2_GLOBALS._player.disableControl();  	if (R2_GLOBALS._v56613[((scene->_field41C - 1) * 4) + 1] <= 1)  		_fieldAC = 21;  	else  		_fieldAC = 20; -	 +  	R2_GLOBALS._player.setVisage(25);  	if (R2_GLOBALS._v566A5 == 3)  		R2_GLOBALS._player.setStrip(2); @@ -13212,7 +13212,7 @@ bool Scene1950::Actor8::startAction(CursorType action, Event &event) {  		R2_GLOBALS._player.setStrip(1);  	R2_GLOBALS._player.animate(ANIM_MODE_5, this);  	R2_GLOBALS._sound3.play(99); -	 +  	return true;  } @@ -13305,7 +13305,7 @@ void Scene1950::Exit6::changeScene() {  			Common::Point pt(-20, 160);  			NpcMover *mover = new NpcMover();  			R2_GLOBALS._player.addMover(mover, &pt, scene); -		} else {  +		} else {  			if (!R2_GLOBALS.getFlag(36))  				SceneItem::display(1950, 33, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, -999);  			if ((R2_INVENTORY.getObjectScene(34) == 1950) || (R2_INVENTORY.getObjectScene(35) == 1950)) @@ -13612,7 +13612,7 @@ void Scene1950::subBDC1E() {  	default:  		break;  	} -	 +  	if (R2_GLOBALS._v566A4 != 1)  		R2_GLOBALS._walkRegions.load(1950); @@ -13806,11 +13806,11 @@ void Scene1950::subBDC1E() {  		R2_GLOBALS._walkRegions.enableRegion(13);  		break;  	} -	 +  	_object1.remove();  	_object1.removeObject();  	_actor1.remove(); -	 +  	switch (R2_GLOBALS._v566A4 - 4) {  	case 0:  	// No break on purpose @@ -13934,7 +13934,7 @@ void Scene1950::subBDC1E() {  		_actor1.fixPriority(220);  		break;  	} -	 +  	switch (R2_GLOBALS._v566A4 - 3) {  	case 0:  	// No break on purpose @@ -14162,7 +14162,7 @@ void Scene1950::subBE59B() {  			_actor6.setFrame(1);  		_actor6.setPosition(Common::Point(193, 158));  		_actor6.setDetails(1950, 3, 4, 5, 2, (SceneItem *) NULL); -		 +  		_actor7.postInit();  		_actor7.setVisage(1970);  		_actor7.setStrip(3); @@ -14172,7 +14172,7 @@ void Scene1950::subBE59B() {  		_actor7.fixPriority(159);  		_item2.setDetails(Rect(188, 124, 199, 133), 1950, 27, 28, -1, 2, NULL); -		 +  		if (R2_INVENTORY.getObjectScene(34) == 1950) {  			_actor5.postInit();  			_actor5.setVisage(1970); @@ -14180,7 +14180,7 @@ void Scene1950::subBE59B() {  			_actor5.setFrame(2);  			_actor5.fixPriority(160);  		} -		 +  		if (R2_GLOBALS.getFlag(37)) {  			_actor5.setPosition(Common::Point(192, 118));  			_actor5.setDetails(1950, 9, 4, -1, 2, (SceneItem *) NULL); @@ -14193,11 +14193,11 @@ void Scene1950::subBE59B() {  			_actor4.setPosition(Common::Point(192, 121));  			_actor4.fixPriority(159);  			_actor4.setDetails(1950, 6, 7, 8, 2, (SceneItem *) NULL); -			 +  			_actor5.setPosition(Common::Point(192, 109));  			_actor5.setDetails(1950, 9, 7, 8, 2, (SceneItem *) NULL);  		} -		 +  		_actor3.postInit();  		_actor3.setVisage(1972);  		_actor3.setStrip(1); @@ -14208,7 +14208,7 @@ void Scene1950::subBE59B() {  			_actor3.setFrame(2);  		else  			_actor3.setFrame(1); -		 +  		_field414 = 1;  	} else if (_field414 != 0) {  		_actor6.remove(); @@ -14219,7 +14219,7 @@ void Scene1950::subBE59B() {  		_item1.setDetails(Rect(0, 0, 320, 200), 1950, 0, 1, 2, 2, NULL);  	} -	 +  	switch (R2_GLOBALS._v566A5) {  	case 0:  		_sceneMode = 1950; @@ -14263,7 +14263,7 @@ void Scene1950::subBE59B() {  			_actor8.setStrip(2);  			NpcMover *mover = new NpcMover();  			_actor8.addMover(mover, &_field418, this); -			 +  			R2_GLOBALS._player.setPosition(Common::Point(-20, 160));  			Common::Point pt2(30, 160);  			NpcMover *mover2 = new NpcMover(); @@ -14311,11 +14311,11 @@ void Scene1950::subBE59B() {  			R2_GLOBALS._v56AAB = 0;  			R2_GLOBALS._player.enableControl(CURSOR_USE);  			R2_GLOBALS._player._canWalk = false; -			 +  			_actor8.setStrip(1);  			NpcMover *mover = new NpcMover();  			_actor8.addMover(mover, &_field418, this); -			 +  			R2_GLOBALS._player.setPosition(Common::Point(340, 160));  			Common::Point pt2(289, 160);  			NpcMover *mover2 = new NpcMover(); @@ -14335,7 +14335,7 @@ void Scene1950::subBF4B4(int indx) {  			si = 3;  	} else  		si = 4; -	 +  	if (_area1._arrActor1[si]._fieldA8 == 0) {  		_area1._arrActor1[si].setFrame(2);  		_area1._arrActor1[si]._fieldA8 = 1; @@ -14343,14 +14343,14 @@ void Scene1950::subBF4B4(int indx) {  		_area1._arrActor1[si].setFrame(1);  		_area1._arrActor1[si]._fieldA8 = 0;  	} -	 +  	si = indx + 1;  	if ((indx / 4) == (si / 4)) {  		if (si >  15)  			si = 12;  	} else  		si -= 4; -	 +  	if (_area1._arrActor1[si]._fieldA8 == 0) {  		_area1._arrActor1[si].setFrame(2);  		_area1._arrActor1[si]._fieldA8 = 1; @@ -14358,7 +14358,7 @@ void Scene1950::subBF4B4(int indx) {  		_area1._arrActor1[si].setFrame(1);  		_area1._arrActor1[si]._fieldA8 = 0;  	} -	 +  	si = indx - 4;  	if (si < 0)  		si += 16; @@ -14370,7 +14370,7 @@ void Scene1950::subBF4B4(int indx) {  		_area1._arrActor1[si].setFrame(1);  		_area1._arrActor1[si]._fieldA8 = 0;  	} -	 +  	si = indx + 4;  	if (si > 15)  		si -= 16; @@ -14395,7 +14395,7 @@ void Scene1950::subBF4B4(int indx) {  	} else {  		R2_GLOBALS.setFlag(37);  		_sceneMode = 24; -		// TODO: check if correct. The original doesn't countain a sceneActor in  +		// TODO: check if correct. The original doesn't countain a sceneActor in  		// this call, but it's extremely unusual  		setAction(&_sequenceManager, this, 1976, NULL);  	} @@ -14408,45 +14408,45 @@ void Scene1950::postInit(SceneObjectList *OwnerList) {  	_field41C = 0;  	if (R2_GLOBALS._sceneManager._previousScene == 300)  		R2_GLOBALS._v566A4 = 103; -	 +  	subBDC1E();  	SceneExt::postInit();  	R2_GLOBALS._sound1.play(105);  	_exit1.setDetails(Rect(130, 46, 189, 135), SHADECURSOR_UP, 1950);  	_exit1.setDest(Common::Point(160, 145)); -	 +  	_exit2.setDetails(Rect(208, 0, 255, 73), EXITCURSOR_N, 1950);  	_exit2.setDest(Common::Point(200, 151)); -	 +  	_exit3.setDetails(Rect(305, 95, 320, 147), EXITCURSOR_E, 1950);  	_exit3.setDest(Common::Point(312, 160)); -	 +  	_exit4.setDetails(Rect(208, 99, 255, 143), EXITCURSOR_S, 1950);  	_exit4.setDest(Common::Point(200, 151)); -	 +  	_exit5.setDetails(Rect(113, 154, 206, 168), SHADECURSOR_DOWN, 1950);  	_exit5.setDest(Common::Point(160, 165)); -	 +  	_exit6.setDetails(Rect(0, 95, 14, 147), EXITCURSOR_W, 1950);  	_exit6.setDest(Common::Point(7, 160)); -	 +  	_exit7.setDetails(Rect(72, 54, 120, 128), EXITCURSOR_NW, 1950);  	_exit7.setDest(Common::Point(120, 140)); -	 +  	_exit8.setDetails(Rect(258, 60, 300, 145), EXITCURSOR_NE, 1950);  	_exit8.setDest(Common::Point(268, 149)); -	 +  	R2_GLOBALS._player.postInit(); -	if ( (R2_INVENTORY.getObjectScene(32) == 0) && (R2_INVENTORY.getObjectScene(33) == 0)  +	if ( (R2_INVENTORY.getObjectScene(32) == 0) && (R2_INVENTORY.getObjectScene(33) == 0)  		&& (R2_INVENTORY.getObjectScene(46) == 0) && (!R2_GLOBALS.getFlag(36)) )  		R2_GLOBALS._player.setVisage(22);  	else  		R2_GLOBALS._player.setVisage(20); -	 +  	R2_GLOBALS._player._moveDiff = Common::Point(5, 3);  	_item1.setDetails(Rect(0, 0, 320, 200), 1950, 0, 1, 2, 1, NULL); -	 +  	subBE59B();  } @@ -14578,7 +14578,7 @@ void Scene1950::signal() {  			R2_GLOBALS._player.setVisage(20);  		else  			R2_GLOBALS._player.setVisage(22); -		 +  		R2_GLOBALS._player.animate(ANIM_MODE_1, NULL);  		Common::Point pt(218, 165);  		NpcMover *mover = new NpcMover(); @@ -14593,7 +14593,7 @@ void Scene1950::signal() {  			R2_GLOBALS._player.setVisage(20);  		else  			R2_GLOBALS._player.setVisage(22); -		R2_GLOBALS._player.animate(ANIM_MODE_1, NULL);		 +		R2_GLOBALS._player.animate(ANIM_MODE_1, NULL);  		break;  	default:  		R2_GLOBALS._v56AAB = 0; @@ -14604,7 +14604,7 @@ void Scene1950::signal() {  void Scene1950::process(Event &event) {  	if ( (event.eventType == EVENT_BUTTON_DOWN) -		&& (R2_GLOBALS._player._uiEnabled)  +		&& (R2_GLOBALS._player._uiEnabled)  		&& (R2_GLOBALS._events.getCursor() == R2_LIGHT_BULB)  		&& (R2_GLOBALS._player._bounds.contains(event.mousePos))  		&& (R2_INVENTORY.getObjectScene(31) == 0)) { diff --git a/engines/tsage/ringworld2/ringworld2_scenes1.h b/engines/tsage/ringworld2/ringworld2_scenes1.h index 5906030c5f..f65a89972d 100644 --- a/engines/tsage/ringworld2/ringworld2_scenes1.h +++ b/engines/tsage/ringworld2/ringworld2_scenes1.h @@ -142,7 +142,7 @@ class Scene1200 : public SceneExt {  		virtual void proc12(int visage, int stripFrameNum, int frameNum, int posX, int posY);  		virtual void proc13(int resNum, int lookLineNum, int talkLineNum, int useLineNum);  	}; -		 +  public:  	NamedHotspot _item1;  	SceneActor _actor1; @@ -567,7 +567,7 @@ class Scene1575 : public SceneExt {  	public:  		int _field34;  		int _field36; -		 +  		Hotspot1();  		void synchronize(Serializer &s);  		void subA910D(int indx); @@ -750,7 +750,7 @@ public:  	Exit2 _exit2;  	Exit3 _exit3;  	SequenceManager _sequenceManager; -	 +  	int _field77A;  	int _field77C; @@ -772,7 +772,7 @@ class Scene1750 : public SceneExt {  		int _fieldAA;  		int _fieldAC;  		int _fieldAE; -		 +  		Actor4();  		virtual void synchronize(Serializer &s);  		void subB1A76(int arg1, int arg2, int arg3, int arg4, int arg5); @@ -782,11 +782,11 @@ class Scene1750 : public SceneExt {  		virtual void process(Event &event);  		virtual bool startAction(CursorType action, Event &event);  	}; -	 +  	class Actor5 : public SceneActor {  	public:  		int _fieldA4; -		 +  		Actor5();  		virtual void synchronize(Serializer &s); @@ -845,7 +845,7 @@ class Scene1800 : public SceneExt {  	public:  		virtual bool startAction(CursorType action, Event &event);  	}; -	 +  	class Exit1 : public SceneExit {  	public:  		virtual void changeScene(); @@ -897,7 +897,7 @@ class Scene1850 : public SceneExt {  	public:  		virtual bool startAction(CursorType action, Event &event);  	}; -	 +  public:  	int _field412;  	int _field414; @@ -936,11 +936,11 @@ class Scene1875 : public SceneExt {  	public:  		int _fieldA4;  		int _fieldA6; -		 +  		Actor1875();  		void subB84AB();  		void subB8271(int indx); -		 +  		void synchronize(Serializer &s);  		virtual void process(Event &event);  	}; diff --git a/engines/tsage/ringworld2/ringworld2_scenes2.cpp b/engines/tsage/ringworld2/ringworld2_scenes2.cpp index 5567519046..6a030e5b44 100644 --- a/engines/tsage/ringworld2/ringworld2_scenes2.cpp +++ b/engines/tsage/ringworld2/ringworld2_scenes2.cpp @@ -261,7 +261,7 @@ void Scene2000::initExits() {  				_mazePlayerMode = 0;  		} else if (R2_GLOBALS._player._oldCharacterScene[R2_GLOBALS._player._characterIndex] == 2350)  			_mazePlayerMode = 1; -		else  +		else  			_mazePlayerMode = 10;  		R2_GLOBALS._player._oldCharacterScene[R2_GLOBALS._player._characterIndex] = 2000;  		R2_GLOBALS._sceneManager._previousScene = 2000; @@ -422,12 +422,12 @@ void Scene2000::Action1::signal() {  		default:  			break;  		} -		 +  		if (R2_GLOBALS._v56605[3 + _state] == R2_GLOBALS._v56605[R2_GLOBALS._player._characterIndex])  			scene->_objList1[_state].show();  		else  			scene->_objList1[_state].hide(); -		 +  		signal();  		break;  	case 5: { @@ -783,7 +783,7 @@ void Scene2000::postInit(SceneObjectList *OwnerList) {  	R2_GLOBALS._sound1.play(200);  	initExits();  	g_globals->_sceneManager._fadeMode = FADEMODE_IMMEDIATE; -	 +  	R2_GLOBALS._player.postInit();  	R2_GLOBALS._player.animate(ANIM_MODE_1, NULL); @@ -1003,9 +1003,9 @@ void Scene2000::signal() {  }  void Scene2000::process(Event &event) { -	if ((R2_GLOBALS._player._canWalk) && (event.eventType == EVENT_BUTTON_DOWN) &&  +	if ((R2_GLOBALS._player._canWalk) && (event.eventType == EVENT_BUTTON_DOWN) &&  			(R2_GLOBALS._events.getCursor() == CURSOR_CROSSHAIRS)) { -		 +  		Common::Point pt(event.mousePos.x, 129);  		PlayerMover *mover = new PlayerMover();  		R2_GLOBALS._player.addMover(mover, &pt, this); @@ -1048,7 +1048,7 @@ bool Scene2350::Actor3::startAction(CursorType action, Event &event) {  void Scene2350::ExitUp::changeScene() {  	Scene2350 *scene = (Scene2350 *)R2_GLOBALS._sceneManager._scene; -	 +  	R2_GLOBALS._player.disableControl(CURSOR_CROSSHAIRS);  	scene->_sceneMode = 12;  	if (R2_GLOBALS._player._characterIndex == 1) @@ -1056,7 +1056,7 @@ void Scene2350::ExitUp::changeScene() {  	else  		scene->setAction(&scene->_sequenceManager, scene, 2352, &R2_GLOBALS._player, NULL);  } -	 +  void Scene2350::ExitWest::changeScene() {  	Scene2350 *scene = (Scene2350 *)R2_GLOBALS._sceneManager._scene; @@ -1129,7 +1129,7 @@ void Scene2350::postInit(SceneObjectList *OwnerList) {  		if (R2_GLOBALS._v56605[R2_GLOBALS._player._characterIndex] == 34) {  			if (R2_GLOBALS._player._characterIndex == 1)  				_sceneMode = 2351; -			else  +			else  				_sceneMode = 2353;  			setAction(&_sequenceManager, this, _sceneMode, &R2_GLOBALS._player, NULL);  		} else { @@ -1147,7 +1147,7 @@ void Scene2350::postInit(SceneObjectList *OwnerList) {  	}  	R2_GLOBALS._player._oldCharacterScene[R2_GLOBALS._player._characterIndex] = 2350;  } -	 +  void Scene2350::remove() {  	R2_GLOBALS._sound1.fadeOut(NULL);  	SceneExt::remove(); @@ -1189,7 +1189,7 @@ void Scene2350::signal() {  }  void Scene2350::process(Event &event) { -	if ((R2_GLOBALS._player._canWalk) && (event.eventType != EVENT_BUTTON_DOWN) &&  +	if ((R2_GLOBALS._player._canWalk) && (event.eventType != EVENT_BUTTON_DOWN) &&  			(R2_GLOBALS._events.getCursor() == CURSOR_CROSSHAIRS)){  		Common::Point pt(event.mousePos.x, 129);  		PlayerMover *mover = new PlayerMover(); @@ -1205,7 +1205,7 @@ void Scene2350::process(Event &event) {   *--------------------------------------------------------------------------*/  void Scene2400::Exit1::changeScene() {  	Scene2400 *scene = (Scene2400 *)R2_GLOBALS._sceneManager._scene; -	 +  	R2_GLOBALS._player.disableControl();  	scene->_sceneMode = 10; @@ -1214,7 +1214,7 @@ void Scene2400::Exit1::changeScene() {  	R2_GLOBALS._player.addMover(mover, &pt, scene);  } -	 +  void Scene2400::Exit2::changeScene() {  	Scene2400 *scene = (Scene2400 *)R2_GLOBALS._sceneManager._scene; @@ -1244,7 +1244,7 @@ void Scene2400::postInit(SceneObjectList *OwnerList) {  		setAction(&_sequenceManager, this, 2401, &R2_GLOBALS._player, NULL);  	}  } -	 +  void Scene2400::signal() {  	switch (_sceneMode) {  	case 10: @@ -1339,7 +1339,7 @@ bool Scene2425::Actor1::startAction(CursorType action, Event &event) {  		}  	} else if (R2_GLOBALS._events.getCursor() == R2_GUNPOWDER)  		return false; -	else  +	else  		return SceneActor::startAction(action, event);  } @@ -1405,7 +1405,7 @@ void Scene2425::postInit(SceneObjectList *OwnerList) {  		_actor1.setup(2426, 1, 1);  	else  		_actor1.setup(2426, 1, 2); -	 +  	_actor1.setPosition(Common::Point(290, 9));  	_actor1.fixPriority(20);  	_actor1.setDetails(2455, 12, -1, -1, 1, (SceneItem *)NULL); @@ -1511,7 +1511,7 @@ bool Scene2430::Actor3::startAction(CursorType action, Event &event) {  void Scene2430::Exit1::changeScene() {  	Scene2430 *scene = (Scene2430 *)R2_GLOBALS._sceneManager._scene; -	 +  	scene->_sceneMode = 0;  	R2_GLOBALS._events.setCursor(R2_NEGATOR_GUN);  	R2_GLOBALS._player.disableControl(); @@ -1790,7 +1790,7 @@ bool Scene2440::Actor2::startAction(CursorType action, Event &event) {  		scene->_sceneMode = 2440;  		scene->setAction(&scene->_sequenceManager, scene, 2440, &R2_GLOBALS._player, &scene->_actor2, NULL);  		return true; -	}  +	}  	return SceneActor::startAction(action, event);  } @@ -2296,7 +2296,7 @@ void Scene2455::postInit(SceneObjectList *OwnerList) {  			_actor1.setup(2456, 3, 3);  			_actor1.setPosition(Common::Point(162, 165));  			_actor1.setDetails(2455, 15, 1, -1, 1, (SceneItem *)NULL); -		}	 +		}  	} else {  		_actor3.postInit();  		_actor3.setup(2456, 3, 1); @@ -2309,9 +2309,9 @@ void Scene2455::postInit(SceneObjectList *OwnerList) {  		_actor2.setup(2456, 3, 2);  		_actor2.setDetails(2455, 9, 1, -1, 1, (SceneItem *)NULL);  	} else { -		if ((R2_INVENTORY.getObjectScene(50) != 2455) && (R2_INVENTORY.getObjectScene(49) != 2455))  +		if ((R2_INVENTORY.getObjectScene(50) != 2455) && (R2_INVENTORY.getObjectScene(49) != 2455))  			_actor2.setup(2455, 1, 1); -		else  +		else  			_actor2.setup(2456, 1, 1);  		_actor2.setDetails(2455, 3, 1, -1, 1, (SceneItem *)NULL);  	} @@ -3679,7 +3679,7 @@ void Scene2700::process(Event &event) {  					break;  				}  			} -		}  +		}  	}  	Scene::process(event);  } @@ -4184,7 +4184,7 @@ bool Scene2800::Actor1::startAction(CursorType action, Event &event) {  		scene->_sceneMode = 10;  		scene->setAction(&scene->_sequenceManager, scene, 2802, &R2_GLOBALS._player, &scene->_actor2, &scene->_actor1, NULL);  		return true; -	} else  +	} else  		return SceneActor::startAction(action, event);  } @@ -4432,7 +4432,7 @@ void Scene2800::postInit(SceneObjectList *OwnerList) {  		_actor1.animate(ANIM_MODE_NONE, NULL);  		_actor1.setDetails(2800, -1, -1, -1, 1, (SceneItem *)NULL);  	} -	 +  	_item1.setDetails(Rect(0, 0, 320, 200), 2800, -1, -1, -1, 1, NULL);  	_stripManager.setColors(60, 255); diff --git a/engines/tsage/ringworld2/ringworld2_scenes3.cpp b/engines/tsage/ringworld2/ringworld2_scenes3.cpp index 2b97cba8e9..3dd566c900 100644 --- a/engines/tsage/ringworld2/ringworld2_scenes3.cpp +++ b/engines/tsage/ringworld2/ringworld2_scenes3.cpp @@ -30,7 +30,7 @@ namespace TsAGE {  namespace Ringworld2 {  /*-------------------------------------------------------------------------- - * Scene 3100 -  + * Scene 3100 -   *   *--------------------------------------------------------------------------*/  Scene3100::Scene3100() { @@ -131,7 +131,7 @@ void Scene3100::postInit(SceneObjectList *OwnerList) {  		_guard.changeZoom(50);  		_guard.setPosition(Common::Point(10, 149));  		_guard.setDetails(3100, 6, -1, -1, 2, (SceneItem *)NULL); -		 +  		_actor4.postInit();  		_actor4.setup(3103, 1, 1);  		_actor4.setPosition(Common::Point(278, 113)); @@ -152,7 +152,7 @@ void Scene3100::postInit(SceneObjectList *OwnerList) {  		R2_GLOBALS._sound1.play(243);  	} -	 +  	R2_GLOBALS._player._oldCharacterScene[1] = 3100;  } @@ -322,7 +322,7 @@ void Scene3125::postInit(SceneObjectList *OwnerList) {  	_actor4.setup(3126, 1, 1);  	_actor4.setPosition(Common::Point(171, 160));  	_actor4.fixPriority(201); -	 +  	_item3.setDetails(12, 3125, 9, 13, -1);  	_item2.setDetails(11, 3125, 15, 13, -1);  	_item1.setDetails(Rect(0, 0, 320, 200), 3125, 0, 1, 2, 1, NULL); @@ -442,7 +442,7 @@ bool Scene3150::Actor4::startAction(CursorType action, Event &event) {  	case CURSOR_USE:  		if (R2_GLOBALS.getFlag(75))  			return SceneActor::startAction(action, event); -		 +  		R2_GLOBALS._player.disableControl();  		scene->_sceneMode = 3151;  		scene->setAction(&scene->_sequenceManager, scene, 3151, &R2_GLOBALS._player, &scene->_actor4, NULL); @@ -504,7 +504,7 @@ bool Scene3150::Actor7::startAction(CursorType action, Event &event) {  		scene->setAction(&scene->_sequenceManager, scene, 3160, &R2_GLOBALS._player, &scene->_actor7, NULL);  		return true;  	} -	 +  	return SceneActor::startAction(action, event);  } @@ -554,7 +554,7 @@ void Scene3150::postInit(SceneObjectList *OwnerList) {  	R2_GLOBALS._player.postInit();  	R2_GLOBALS._player.disableControl(); -	 +  	_actor2.postInit();  	_actor2.setPosition(Common::Point(64, 139));  	if (R2_GLOBALS.getFlag(78)) { @@ -686,7 +686,7 @@ void Scene3150::postInit(SceneObjectList *OwnerList) {  			_actor5.postInit();  			_actor5._effect = 6;  			_actor5._shade = 3; -				 +  			setAction(&_sequenceManager, this, 3156, &R2_GLOBALS._player, &_actor1, &_actor2, &_actor5, NULL);  		} else {  			if (R2_GLOBALS._v56AA0 != 2) @@ -1699,7 +1699,7 @@ void Scene3350::signal() {  }  /*-------------------------------------------------------------------------- - * Scene 3375 -  + * Scene 3375 -   *   *--------------------------------------------------------------------------*/  Scene3375::Scene3375() { @@ -1799,13 +1799,13 @@ bool Scene3375::Actor1::startAction(CursorType action, Event &event) {  	if (action != CURSOR_TALK)  		return SceneActor::startAction(action, event); -	 +  	scene->_sceneMode = 9999;  	if (R2_GLOBALS._player._characterIndex == 2)  		scene->_stripManager.start(3302, scene);  	else  		scene->_stripManager.start(3304, scene); -	 +  	return true;  } @@ -1814,13 +1814,13 @@ bool Scene3375::Actor2::startAction(CursorType action, Event &event) {  	if (action != CURSOR_TALK)  		return SceneActor::startAction(action, event); -	 +  	scene->_sceneMode = 9999;  	if (R2_GLOBALS._player._characterIndex == 3)  		scene->_stripManager.start(3302, scene);  	else  		scene->_stripManager.start(3301, scene); -	 +  	return true;  } @@ -1829,10 +1829,10 @@ bool Scene3375::Actor3::startAction(CursorType action, Event &event) {  	if (action != CURSOR_TALK)  		return SceneActor::startAction(action, event); -	 +  	scene->_sceneMode = 9999;  	scene->_stripManager.start(3303, scene); -	 +  	return true;  } @@ -1841,7 +1841,7 @@ bool Scene3375::Actor4::startAction(CursorType action, Event &event) {  	if (action != CURSOR_USE)  		return SceneActor::startAction(action, event); -	 +  	if (R2_GLOBALS._v56A9E != 0) {  		R2_GLOBALS._walkRegions.disableRegion(2);  		R2_GLOBALS._walkRegions.disableRegion(3); @@ -1855,10 +1855,10 @@ bool Scene3375::Actor4::startAction(CursorType action, Event &event) {  	R2_GLOBALS._walkRegions.disableRegion(8);  	R2_GLOBALS._player.disableControl(CURSOR_ARROW); -	 +  	scene->_sceneMode = 3375;  	scene->setAction(&scene->_sequenceManager, scene, 3375, &R2_GLOBALS._player, &scene->_actor1, &scene->_actor2, &scene->_actor3, &scene->_actor4, NULL); -	 +  	return true;  } @@ -1944,10 +1944,10 @@ void Scene3375::postInit(SceneObjectList *OwnerList) {  	_field148A[1] = 3377;  	_field148A[2] = 3375;  	_field148A[3] = 3378; -	 +  	loadScene(_field148A[R2_GLOBALS._v56A9E]);  	SceneExt::postInit(); -	 +  	R2_GLOBALS._sound1.play(313);  	_stripManager.setColors(60, 255); @@ -1963,14 +1963,14 @@ void Scene3375::postInit(SceneObjectList *OwnerList) {  	setZoomPercents(126, 55, 200, 167);  	R2_GLOBALS._player.postInit(); -	 +  	if (R2_GLOBALS._player._characterIndex == 2) {  		R2_GLOBALS._player._moveDiff = Common::Point(5, 3);  	} else {  		R2_GLOBALS._player._moveDiff = Common::Point(3, 2);  	}  	R2_GLOBALS._player.changeZoom(-1); -	 +  	switch (R2_GLOBALS._player._characterIndex) {  	case 2:  		if (R2_GLOBALS._sceneManager._previousScene == 3385) @@ -1991,7 +1991,7 @@ void Scene3375::postInit(SceneObjectList *OwnerList) {  			R2_GLOBALS._player.setup(10, 3, 1);  		break;  	} -	 +  	R2_GLOBALS._player.animate(ANIM_MODE_1, NULL);  	R2_GLOBALS._player.disableControl(); @@ -2005,21 +2005,21 @@ void Scene3375::postInit(SceneObjectList *OwnerList) {  	}  	_actor1.changeZoom(-1);  	_actor1._effect = 1; -	 +  	int tmpStrip, tmpVisage;  	if (R2_GLOBALS._sceneManager._previousScene == 3385)  		tmpStrip = 1;  	else  		tmpStrip = 4; -	 +  	if (R2_GLOBALS._player._characterIndex == 2)  		tmpVisage = 10;  	else  		tmpVisage = 20; -	 +  	_actor1.setup(tmpVisage, tmpStrip, 1);  	_actor1.animate(ANIM_MODE_1, NULL); -	 +  	_actor2.postInit();  	_actor2._moveDiff = Common::Point(3, 2);  	_actor2.changeZoom(-1); @@ -2033,10 +2033,10 @@ void Scene3375::postInit(SceneObjectList *OwnerList) {  		tmpVisage = 10;  	else  		tmpVisage = 30; -	 +  	_actor2.setup(tmpVisage, tmpStrip, 1);  	_actor2.animate(ANIM_MODE_1, NULL); -	 +  	_actor3.postInit();  	_actor3._moveRate = 7;  	_actor3._moveDiff = Common::Point(5, 3); @@ -2049,34 +2049,34 @@ void Scene3375::postInit(SceneObjectList *OwnerList) {  	_actor3.setup(40, tmpStrip, 1);  	_actor3.animate(ANIM_MODE_1, NULL); -	 +  	_actor2.setDetails(3375, -1, -1, -1, 1, (SceneItem *)NULL);  	_actor3.setDetails(3375, 21, -1, -1, 1, (SceneItem *)NULL);  	_actor1.setDetails(3375, -1, -1, -1, 1, (SceneItem *)NULL); -	 +  	_actor4.postInit();  	_actor4.setup(3375, 1, 1);  	_actor4.setPosition(Common::Point(254, 166));  	_actor4.fixPriority(140);  	_actor4.hide(); -	 +  	_exit1.setDetails(Rect(0, 84, 24, 167), EXITCURSOR_W, 3375);  	_exit1.setDest(Common::Point(65, 155));  	_exit2.setDetails(Rect(103, 152, 183, 170), SHADECURSOR_DOWN, 3375);  	_exit2.setDest(Common::Point(158, 151));  	_exit3.setDetails(Rect(180, 75, 213, 132), EXITCURSOR_E, 3375);  	_exit3.setDest(Common::Point(201, 131)); -		 +  	for (int i = 0; i <= 12; ++i)  		_itemArray[i].setDetails(i, 3375, 3, -1, -1); -	 +  	_item1.setDetails(Rect(0, 0, 320, 200), 3375, 0, -1, 1, 1, NULL);  	if (R2_GLOBALS._sceneManager._previousScene == 3385)  		_sceneMode = 3379;  	else  		_sceneMode = 0; -	 +  	subFC696(_sceneMode);  } @@ -2186,7 +2186,7 @@ void Scene3375::dispatch() {  }  /*-------------------------------------------------------------------------- - * Scene 3385 -  + * Scene 3385 -   *   *--------------------------------------------------------------------------*/  Scene3385::Scene3385() { @@ -2204,13 +2204,13 @@ bool Scene3385::Actor1::startAction(CursorType action, Event &event) {  	if (action != CURSOR_TALK)  		return SceneActor::startAction(action, event); -	 +  	scene->_sceneMode = 9999;  	if (R2_GLOBALS._player._characterIndex == 2)  		scene->_stripManager.start(3302, scene);  	else  		scene->_stripManager.start(3304, scene); -	 +  	return true;  } @@ -2219,13 +2219,13 @@ bool Scene3385::Actor2::startAction(CursorType action, Event &event) {  	if (action != CURSOR_TALK)  		return SceneActor::startAction(action, event); -	 +  	scene->_sceneMode = 9999;  	if (R2_GLOBALS._player._characterIndex == 3)  		scene->_stripManager.start(3302, scene);  	else  		scene->_stripManager.start(3301, scene); -	 +  	return true;  } @@ -2234,10 +2234,10 @@ bool Scene3385::Actor3::startAction(CursorType action, Event &event) {  	if (action != CURSOR_TALK)  		return SceneActor::startAction(action, event); -	 +  	scene->_sceneMode = 9999;  	scene->_stripManager.start(3303, scene); -	 +  	return true;  } @@ -2253,7 +2253,7 @@ bool Scene3385::Actor4::startAction(CursorType action, Event &event) {  	scene->_sceneMode = 3386;  	scene->setAction(&scene->_sequenceManager, scene, 3386, &R2_GLOBALS._player, &scene->_actor1, &scene->_actor2, &scene->_actor3, &scene->_actor4, NULL); -	 +  	return true;  } @@ -2303,21 +2303,21 @@ void Scene3385::postInit(SceneObjectList *OwnerList) {  	setZoomPercents(102, 40, 200, 160);  	R2_GLOBALS._player.postInit(); -	 +  	if (R2_GLOBALS._player._characterIndex == 2)  		R2_GLOBALS._player._moveDiff = Common::Point(5, 3);  	else  		R2_GLOBALS._player._moveDiff = Common::Point(3, 2);  	R2_GLOBALS._player.changeZoom(-1); -	 +  	if (R2_GLOBALS._player._characterIndex == 2)  		R2_GLOBALS._player.setup(20, _field11B2, 1);  	else if (R2_GLOBALS._player._characterIndex == 3)  		R2_GLOBALS._player.setup(30, _field11B2, 1);  	else  		R2_GLOBALS._player.setup(10, _field11B2, 1); -	 +  	R2_GLOBALS._player.animate(ANIM_MODE_1, NULL);  	R2_GLOBALS._player.disableControl(); @@ -2337,7 +2337,7 @@ void Scene3385::postInit(SceneObjectList *OwnerList) {  		_actor1.setup(20, _field11B2, 1);  	_actor1.animate(ANIM_MODE_1, NULL);  	_actor1.setDetails(3385, -1, -1, -1, 1, (SceneItem *) NULL); -	 +  	_actor2.postInit();  	_actor2._moveDiff = Common::Point(3, 2);  	_actor2.changeZoom(-1); @@ -2356,15 +2356,15 @@ void Scene3385::postInit(SceneObjectList *OwnerList) {  	_actor3.setup(40, _field11B2, 1);  	_actor3.animate(ANIM_MODE_1, NULL);  	_actor3.setDetails(3385, 15, -1, -1, 1, (SceneItem *) NULL); -	 +  	_exit1.setDetails(Rect(103, 152, 217, 170), SHADECURSOR_DOWN, 3395);  	_exit1.setDest(Common::Point(158, 151)); -	 +  	_actor4.postInit();  	_actor4.setPosition(Common::Point(160, 100));  	_actor4.fixPriority(90);  	_actor4.setDetails(3385, 3, 4, -1, 1, (SceneItem *) NULL); -	 +  	if (R2_GLOBALS._sceneManager._previousScene == 3375) {  		R2_GLOBALS._player.setPosition(Common::Point(158, 102));  		_actor1.setPosition(Common::Point(164, 100)); @@ -2385,7 +2385,7 @@ void Scene3385::postInit(SceneObjectList *OwnerList) {  		_actor4.setup(3385, 1, 1);  		_sceneMode = 3385;  		setAction(&_sequenceManager, this, _sceneMode, &R2_GLOBALS._player, &_actor1, &_actor2, &_actor3, NULL); -	}	 +	}  	_item1.setDetails(Rect(0, 0, 320, 200), 3385, 0, -1, -1, 1, NULL);  	R2_GLOBALS._v56A9E = 0; @@ -2418,7 +2418,7 @@ void Scene3385::signal() {  }  /*-------------------------------------------------------------------------- - * Scene 3395 -  + * Scene 3395 -   *   *--------------------------------------------------------------------------*/  Scene3395::Scene3395() { @@ -2436,13 +2436,13 @@ bool Scene3395::Actor1::startAction(CursorType action, Event &event) {  	if (action != CURSOR_TALK)  		return SceneActor::startAction(action, event); -	 +  	scene->_sceneMode = 9999;  	if (R2_GLOBALS._player._characterIndex == 2)  		scene->_stripManager.start(3302, scene);  	else  		scene->_stripManager.start(3304, scene); -	 +  	return true;  } @@ -2451,13 +2451,13 @@ bool Scene3395::Actor2::startAction(CursorType action, Event &event) {  	if (action != CURSOR_TALK)  		return SceneActor::startAction(action, event); -	 +  	scene->_sceneMode = 9999;  	if (R2_GLOBALS._player._characterIndex == 3)  		scene->_stripManager.start(3302, scene);  	else  		scene->_stripManager.start(3301, scene); -	 +  	return true;  } @@ -2466,10 +2466,10 @@ bool Scene3395::Actor3::startAction(CursorType action, Event &event) {  	if (action != CURSOR_TALK)  		return SceneActor::startAction(action, event); -	 +  	scene->_sceneMode = 9999;  	scene->_stripManager.start(3303, scene); -	 +  	return true;  } @@ -2485,7 +2485,7 @@ bool Scene3395::Actor4::startAction(CursorType action, Event &event) {  	scene->_sceneMode = 3396;  	scene->setAction(&scene->_sequenceManager, scene, 3396, &R2_GLOBALS._player, &scene->_actor1, &scene->_actor2, &scene->_actor3, &scene->_actor4, NULL); -	 +  	return true;  } @@ -2523,21 +2523,21 @@ void Scene3395::postInit(SceneObjectList *OwnerList) {  	setZoomPercents(51, 40, 200, 137);  	R2_GLOBALS._player.postInit(); -	 +  	if (R2_GLOBALS._player._characterIndex == 2)  		R2_GLOBALS._player._moveDiff = Common::Point(5, 3);  	else  		R2_GLOBALS._player._moveDiff = Common::Point(3, 2);  	R2_GLOBALS._player.changeZoom(-1); -	 +  	if (R2_GLOBALS._player._characterIndex == 2)  		R2_GLOBALS._player.setup(20, _field142E, 1);  	else if (R2_GLOBALS._player._characterIndex == 3)  		R2_GLOBALS._player.setup(30, _field142E, 1);  	else  		R2_GLOBALS._player.setup(10, _field142E, 1); -	 +  	R2_GLOBALS._player.animate(ANIM_MODE_1, NULL);  	R2_GLOBALS._player.disableControl(); @@ -2576,7 +2576,7 @@ void Scene3395::postInit(SceneObjectList *OwnerList) {  	_actor3.setup(40, _field142E, 1);  	_actor3.animate(ANIM_MODE_1, NULL);  	_actor3.setDetails(3385, 18, -1, -1, 1, (SceneItem *) NULL); -	 +  	_actor4.postInit();  	_actor4.setPosition(Common::Point(159, 50));  	_actor4.fixPriority(40); @@ -2638,7 +2638,7 @@ void Scene3395::signal() {  }  /*-------------------------------------------------------------------------- - * Scene 3400 -  + * Scene 3400 -   *   *--------------------------------------------------------------------------*/  Scene3400::Scene3400() { @@ -2802,7 +2802,7 @@ void Scene3400::signal() {  		_sceneMode = 3403;  		if (R2_GLOBALS._player._characterIndex == 2)  			setAction(&_sequenceManager, this, 3403, &R2_GLOBALS._player, &_actor3, &_actor7, NULL); -		else  +		else  			setAction(&_sequenceManager, this, 3403, &_actor1, &_actor3, &_actor7, NULL);  		break;  	case 3309: @@ -2811,7 +2811,7 @@ void Scene3400::signal() {  		_sceneMode = 3405;  		if (R2_GLOBALS._player._characterIndex == 3)  			setAction(&_sequenceManager, this, 3405, &R2_GLOBALS._player, &_actor7, NULL); -		else  +		else  			setAction(&_sequenceManager, this, 3405, &_actor2, &_actor7, NULL);  		break;  	case 3310: @@ -2885,7 +2885,7 @@ void Scene3400::signal() {  }  /*-------------------------------------------------------------------------- - * Scene 3500 -  + * Scene 3500 -   *   *--------------------------------------------------------------------------*/  Scene3500::Action1::Action1() { @@ -2910,10 +2910,10 @@ void Scene3500::Action1::sub108670(int arg1) {  	_field1E = arg1;  	_field20 = 1;  	_field24 = 1; -	 +  	scene->_actor9.setStrip(2);  	scene->_actor9.show(); -	 +  	if (_field1E == 1)  		scene->_actor6.show();  	else @@ -2954,7 +2954,7 @@ void Scene3500::Action1::sub108732(int arg1) {  		Common::Point pt(160, 73);  		NpcMover *mover = new NpcMover();  		scene->_actor8.addMover(mover, &pt, NULL); -		 +  		scene->_fieldB9E = 160 - (_field1E * 2 * 160);  		Common::Point pt2(scene->_fieldB9E, 73);  		NpcMover *mover2 = new NpcMover(); @@ -3153,7 +3153,7 @@ void Scene3500::sub107F71(int arg1) {  			_action1.signal();  		} else if (_action == 0) {  			_action1.sub108670(1); -			setAction(&_action1, &_actor1, NULL);			 +			setAction(&_action1, &_actor1, NULL);  		}  		break;  	case 104: @@ -3177,7 +3177,7 @@ void Scene3500::sub107F71(int arg1) {  			_action1.signal();  		} else if (_action == 0) {  			_action1.sub108670(-1); -			setAction(&_action1, &_actor1, NULL);			 +			setAction(&_action1, &_actor1, NULL);  		}  		break;  	default: @@ -3221,16 +3221,16 @@ void Scene3500::Action1::signal() {  		int var4 = scene->_unkObj1.sub1097EF(scene->_field127C + 46) - 46;  		int di = abs(var2 - scene->_field127A);  		int var6 = abs(var4 - scene->_field127C); -		 +  		if ((scene->_actor1._frame % 2) != 0) {  			scene->_actor1._frameChange = _field1E;  			scene->_actor1.setFrame(scene->_actor1.changeFrame());  		}  		int var8 = (scene->_action1._field1E * 2 + scene->_field1276); -		if (var8 > 7)  +		if (var8 > 7)  			var8 = 1; -		else if (var8 < 1)  +		else if (var8 < 1)  			var8 = 7;  		switch (var8) { @@ -3293,7 +3293,7 @@ void Scene3500::Action1::signal() {  		Common::Point pt(scene->_fieldAF8, 73);  		NpcMover *mover = new NpcMover();  		scene->_actor8.addMover(mover, &pt, this); -		 +  		scene->_actor9.setPosition(Common::Point(160 + ((_field1E * 2) * 160), 73));;  		scene->_actor9._moveDiff.x = 160 - scene->_field126E;  		scene->_fieldB9E = 160; @@ -3315,7 +3315,7 @@ void Scene3500::Action1::signal() {  		else  			scene->_actor8.setStrip(2);  		scene->_actor8.fixPriority(1); -		 +  		scene->_actor9.setPosition(Common::Point(-160, 73));  		scene->_actor9.setStrip(9);  		scene->_actor9.fixPriority(11); @@ -3343,12 +3343,12 @@ void Scene3500::Action1::signal() {  		// The following code allows the switch to work properly.  		warning("Checkme: fix for dead code");  		int var_8 = (_field1E * 2 + scene->_field1276); -		if (var_8 > 7)  +		if (var_8 > 7)  			var_8 = 1; -		else if (var_8 < 1)  +		else if (var_8 < 1)  			var_8 = 7;  		// -		 +  		switch (var_8 - 1) {  		case 0:  		// No break on purpose @@ -3378,7 +3378,7 @@ void Scene3500::Action1::signal() {  		Common::Point pt(160, 73);  		NpcMover *mover = new NpcMover();  		scene->_actor8.addMover(mover, &pt, NULL); -		 +  		scene->_fieldB9E = 160 - (_field1E * 2 * 160);  		Common::Point pt2(scene->_fieldB9E, 73);  		NpcMover *mover2 = new NpcMover(); @@ -3419,7 +3419,7 @@ void Scene3500::Action1::dispatch() {  	if ((_actionIndex == 1) && (scene->_field126E <= 4)) {  		scene->_rotation->_idxChange = 0;  		signal(); -	}	 +	}  }  void Scene3500::Action2::sub10831F(int arg1) { @@ -3451,12 +3451,12 @@ void Scene3500::Action2::signal() {  			scene->_fieldB9E = scene->_actor9._position.y;  			di = scene->_fieldB9E;  		} -		 +  		scene->_actor8._moveDiff.y = 9 - (scene->_field126E / 2);  		Common::Point pt(si, 73 - (_field1E * 12));  		NpcMover *mover = new NpcMover();  		scene->_actor8.addMover(mover, &pt, NULL); -		 +  		scene->_actor9._moveDiff.y = 9 - (scene->_field126E / 2);  		Common::Point pt2(di, 73 - (_field1E * 12));  		NpcMover *mover2 = new NpcMover(); @@ -3474,7 +3474,7 @@ void Scene3500::Action2::signal() {  			si = scene->_actor8._position.x;  			di = scene->_actor9._position.x;  		} -		 +  		scene->_actor7.sub1094ED();  		scene->_actor8._moveDiff.y = 9 - (scene->_field126E / 2); @@ -3486,7 +3486,7 @@ void Scene3500::Action2::signal() {  		Common::Point pt2(di, 73);  		NpcMover *mover2 = new NpcMover();  		scene->_actor9.addMover(mover2, &pt2, NULL); -		 +  		scene->_actor3.setFrame2(2);  		}  		break; @@ -3500,13 +3500,13 @@ bool Scene3500::Item4::startAction(CursorType action, Event &event) {  	if (scene->_field1286 == 0)  		return true; -	 +  	if (scene->_field1286 != 4)  		return SceneHotspot::startAction(action, event); -	 +  	R2_GLOBALS._sound2.play(14);  	scene->sub107F71(_field34); -	 +  	return true;  } @@ -3515,22 +3515,22 @@ void Scene3500::Actor7::process(Event &event) {  	if (scene->_field1286 == 0)  		return; -	 +  	if ((event.eventType == EVENT_BUTTON_DOWN) && (R2_GLOBALS._events.getCursor() == CURSOR_USE) && (_bounds.contains(event.mousePos))) {  		_fieldAE = 1 + event.mousePos.y - _position.y;  		event.eventType = EVENT_NONE;  	} -	 +  	if ((event.eventType == EVENT_BUTTON_UP) && (_fieldAE != 0)) {  		_fieldAE = 0;  		event.handled = true;  		if (scene->_action1._field24 == 0)  			sub1094ED();  	} -	 +  	if (_fieldAE == 0)  		return; -	 +  	R2_GLOBALS._sound2.play(338);  	event.handled = true; @@ -3550,10 +3550,10 @@ bool Scene3500::Actor7::startAction(CursorType action, Event &event) {  	if (scene->_field1286 == 0)  		return true; -	 +  	if (scene->_field1286 == 4)  		return false; -	 +  	return SceneActor::startAction(action, event);  } @@ -3586,7 +3586,7 @@ void Scene3500::postInit(SceneObjectList *OwnerList) {  		if (tmpIndex > 254)  			tmpIndex--; -		 +  		tmpPal[3 * i] = R2_GLOBALS._scenePalette._palette[3 * tmpIndex];  		tmpPal[(3 * i) + 1] = R2_GLOBALS._scenePalette._palette[(3 * tmpIndex) + 1];  		tmpPal[(3 * i) + 2] = R2_GLOBALS._scenePalette._palette[(3 * tmpIndex) + 2]; @@ -3597,7 +3597,7 @@ void Scene3500::postInit(SceneObjectList *OwnerList) {  		R2_GLOBALS._scenePalette._palette[(3 * i) + 1] = tmpPal[(3 * i) + 1];  		R2_GLOBALS._scenePalette._palette[(3 * i) + 2] = tmpPal[(3 * i) + 2];  	} -	 +  	_actor7.sub109466(38, 165, 16, 32, _field1270);  	_actor7.setDetails(3500, 6, 7, -1, 1, (SceneItem *)NULL);  	R2_GLOBALS._sound1.play(276); @@ -3696,7 +3696,7 @@ void Scene3500::signal() {  void Scene3500::process(Event &event) {  	if (_field1286 == 0)  		return; -	 +  	if (event.eventType == EVENT_KEYPRESS) {  		switch (event.kbd.keycode) {  		case Common::KEYCODE_1: @@ -3765,7 +3765,7 @@ void Scene3500::process(Event &event) {  			break;  		}  	} -	 +  	if (!event.handled)  		_actor7.process(event); @@ -3864,7 +3864,7 @@ void Scene3500::dispatch() {  					var_a = abs(var_6 - di);  					tmpVar = _unkObj1.sub109C09(Common::Point(var_field127A + 70, di + 46)); -					if ( (((tmpVar == 23) || (tmpVar == 24) || (tmpVar == 4)) && (di <= var_6) && (_field127C>= var_6))  +					if ( (((tmpVar == 23) || (tmpVar == 24) || (tmpVar == 4)) && (di <= var_6) && (_field127C>= var_6))  						|| (((tmpVar == 25) || (tmpVar == 26) || (tmpVar == 5) || (tmpVar == 14) || (tmpVar == 15)) && (_field126E >= var_a) && (_field126E > 3) && (_action1._field24 != 0)) ) {  						di = var_6;  						if ((tmpVar != 25) && (tmpVar != 26) && (tmpVar != 5) && (tmpVar != 14) && (tmpVar == 15)) @@ -3894,7 +3894,7 @@ void Scene3500::dispatch() {  			break;  		case 2:  			tmpVar = _unkObj1.sub109C09(Common::Point(var_field127A + 70, di + 46)); -			if (  ((tmpVar == 12) || (tmpVar == 13) || (tmpVar == 11) || (tmpVar == 16) || (tmpVar == 31))  +			if (  ((tmpVar == 12) || (tmpVar == 13) || (tmpVar == 11) || (tmpVar == 16) || (tmpVar == 31))  			  || (((tmpVar == 25) || (tmpVar == 23) || (tmpVar == 14) || (tmpVar == 5) || (tmpVar == 4)) && (var_a > 3)) ) {  				R2_GLOBALS._sound2.play(339);  				_rotation->_idxChange = 0; @@ -4003,7 +4003,7 @@ void Scene3500::dispatch() {  					var_6 = _unkObj1.sub1097EF(di + 46) - 46;  					var_a = abs(di - var_6);  					tmpVar = _unkObj1.sub109C09(Common::Point(var_field127A + 70, di + 46)); -					if ( (((tmpVar == 25) || (tmpVar == 26) || (tmpVar == 5)) && (di >= var_6) && (_field127C <= var_6))  +					if ( (((tmpVar == 25) || (tmpVar == 26) || (tmpVar == 5)) && (di >= var_6) && (_field127C <= var_6))  					  || (((tmpVar == 23) || (tmpVar == 24) || (tmpVar == 4) || (tmpVar == 14) || (tmpVar == 15)) && (_field126E >= var_a) && (_field126E <= 3) && (_action1._field24 != 0)) ){  						if ((tmpVar != 23) && (tmpVar != 24) && (tmpVar != 4) && (tmpVar != 14) && (tmpVar != 15))  							R2_GLOBALS._sound2.play(339); @@ -4179,7 +4179,7 @@ void Scene3500::dispatch() {  }  /*-------------------------------------------------------------------------- - * Scene 3600 -  + * Scene 3600 -   *   *--------------------------------------------------------------------------*/  Scene3600::Scene3600() { @@ -4227,7 +4227,7 @@ void Scene3600::Action3600::signal() {  			R2_GLOBALS._sound2.fade(127, 5, 10, false, NULL);  		}  		setDelay(1); -		warning("TODO: Palette fader using parameter 2 = 256");  +		warning("TODO: Palette fader using parameter 2 = 256");  		R2_GLOBALS._scenePalette.fade((const byte *)&scene->_palette1._palette, true, _field20);  		if (_field20 > 0)  			_field20 -= 2; @@ -4359,7 +4359,7 @@ void Scene3600::postInit(SceneObjectList *OwnerList) {  		g_globals->gfxManager()._bounds.moveTo(Common::Point(160, 0));  		R2_GLOBALS._v558B6.set(25, 0, 260, 200);  	} -	 +  	loadScene(3600);  	SceneExt::postInit();  	_field254C = 0; @@ -4502,7 +4502,7 @@ void Scene3600::postInit(SceneObjectList *OwnerList) {  		_action1._field1E = 1;  		_action1._field20 = 0;  		_action1.setActionIndex(1); -	 +  		_actor3.setAction(&_action1);  		_sceneMode = 3623; @@ -4768,7 +4768,7 @@ void Scene3600::signal() {  			R2_GLOBALS.setFlag(71);  			_sceneMode = 3626;  			setAction(&_sequenceManager1, this, 3626, &_actor13, NULL); -		}  +		}  		break;  	case 3624:  		R2_GLOBALS._player.disableControl(); @@ -4946,7 +4946,7 @@ void Scene3700::signal() {  }  /*-------------------------------------------------------------------------- - * Scene 3800 -  + * Scene 3800 -   *   *--------------------------------------------------------------------------*/  Scene3800::Scene3800() { @@ -5227,7 +5227,7 @@ void Scene3800::postInit(SceneObjectList *OwnerList) {  	_field412 = 0;  	initScene3800(); -	 +  	SceneExt::postInit();  	R2_GLOBALS._sound1.play(231); @@ -5338,7 +5338,7 @@ void Scene3800::process(Event &event) {  }  /*-------------------------------------------------------------------------- - * Scene 3900 -  + * Scene 3900 -   *   *--------------------------------------------------------------------------*/  void Scene3900::Exit1::changeScene() { @@ -5350,7 +5350,7 @@ void Scene3900::Exit1::changeScene() {  	R2_GLOBALS._v566AA = 1;  	R2_GLOBALS._v566A8 = 1;  	scene->_sceneMode = 14; -	 +  	Common::Point pt(160, 115);  	NpcMover *mover = new NpcMover();  	R2_GLOBALS._player.addMover(mover, &pt, scene); @@ -5365,7 +5365,7 @@ void Scene3900::Exit2::changeScene() {  	R2_GLOBALS._v566AA = 2;  	R2_GLOBALS._v566A8 = 1;  	scene->_sceneMode = 14; -	 +  	Common::Point pt(330, 145);  	NpcMover *mover = new NpcMover();  	R2_GLOBALS._player.addMover(mover, &pt, scene); @@ -5380,7 +5380,7 @@ void Scene3900::Exit3::changeScene() {  	R2_GLOBALS._v566AA = 3;  	R2_GLOBALS._v566A8 = 1;  	scene->_sceneMode = 14; -	 +  	Common::Point pt(160, 220);  	NpcMover *mover = new NpcMover();  	R2_GLOBALS._player.addMover(mover, &pt, scene); @@ -5395,7 +5395,7 @@ void Scene3900::Exit4::changeScene() {  	R2_GLOBALS._v566AA = 4;  	R2_GLOBALS._v566A8 = 1;  	scene->_sceneMode = 14; -	 +  	Common::Point pt(-10, 145);  	NpcMover *mover = new NpcMover();  	R2_GLOBALS._player.addMover(mover, &pt, scene); @@ -5407,7 +5407,7 @@ void Scene3900::Exit5::changeScene() {  	_enabled = false;  	R2_GLOBALS._player.disableControl(CURSOR_ARROW);  	scene->_sceneMode = 13; -	 +  	if (R2_GLOBALS._v566A9 == 4) {  		Common::Point pt(-10, 135);  		NpcMover *mover = new NpcMover(); diff --git a/engines/tsage/ringworld2/ringworld2_scenes3.h b/engines/tsage/ringworld2/ringworld2_scenes3.h index 6088c88479..44787b9eef 100644 --- a/engines/tsage/ringworld2/ringworld2_scenes3.h +++ b/engines/tsage/ringworld2/ringworld2_scenes3.h @@ -494,7 +494,7 @@ public:  	Exit1 _exit1;  	Action1 _action1;  	SequenceManager _sequenceManager; -	 +  	int _field11B2;  	Scene3385(); @@ -536,7 +536,7 @@ public:  	Actor4 _actor4;  	Action1 _action1;  	SequenceManager _sequenceManager; -	 +  	int _field142E;  	Scene3395(); @@ -600,10 +600,10 @@ class Scene3500 : public SceneExt {  	class Item4 : public NamedHotspot {  	public:  		int _field34; -		 +  		Item4();  		virtual void synchronize(Serializer &s); -		 +  		virtual bool startAction(CursorType action, Event &event);  	}; @@ -615,7 +615,7 @@ class Scene3500 : public SceneExt {  		int _fieldAA;  		int _fieldAC;  		int _fieldAE; -		 +  		Actor7();  		virtual void synchronize(Serializer &s); @@ -695,7 +695,7 @@ class Scene3600 : public SceneExt {  	class Action3600: public ActionExt {  	public:  		int _field1E, _field20; -		 +  		Action3600();  		virtual void synchronize(Serializer &s);  		virtual void signal(); diff --git a/engines/tsage/ringworld2/ringworld2_speakers.cpp b/engines/tsage/ringworld2/ringworld2_speakers.cpp index f729881e8f..da1449efdf 100644 --- a/engines/tsage/ringworld2/ringworld2_speakers.cpp +++ b/engines/tsage/ringworld2/ringworld2_speakers.cpp @@ -159,7 +159,7 @@ void VisualSpeaker::setText(const Common::String &msg) {  	if (s.empty())  		_numFrames = 0; -	 +  	if (_fieldF6) {  		if ((R2_GLOBALS._speechSubtitles & SPEECH_TEXT) || !_soundId)  			_sceneText.hide(); @@ -229,7 +229,7 @@ void SpeakerCaptain3210::proc15() {  		_object1.postInit();  		_object1.setPosition(_object2->_position); -		if (_object2->_mover)  +		if (_object2->_mover)  			_object2->addMover(NULL);  	} @@ -285,7 +285,7 @@ void SpeakerChief1100::proc15() {  		_object1.setPosition(_object2->_position);  		_object1._numFrames = 7; -		if (_object2->_mover)  +		if (_object2->_mover)  			_object2->addMover(NULL);  	} @@ -342,7 +342,7 @@ void SpeakerGuard2800::proc15() {  		_object1.postInit();  		_object1.setPosition(_object2->_position); -		if (_object2->_mover)  +		if (_object2->_mover)  			_object2->addMover(NULL);  	} @@ -382,7 +382,7 @@ void SpeakerJocko3200::proc15() {  		_object1.postInit();  		_object1.setPosition(_object2->_position); -		if (_object2->_mover)  +		if (_object2->_mover)  			_object2->addMover(NULL);  	} @@ -405,7 +405,7 @@ void SpeakerJocko3220::proc15() {  		_object1.postInit();  		_object1.setPosition(_object2->_position); -		if (_object2->_mover)  +		if (_object2->_mover)  			_object2->addMover(NULL);  	} @@ -428,7 +428,7 @@ void SpeakerJocko3230::proc15() {  		_object1.postInit();  		_object1.setPosition(_object2->_position); -		if (_object2->_mover)  +		if (_object2->_mover)  			_object2->addMover(NULL);  	} @@ -442,7 +442,7 @@ void SpeakerJocko3230::proc15() {  }  //---------------------------------------------------------------------------- -// Classes related to MIRANDA  +// Classes related to MIRANDA  //----------------------------------------------------------------------------  SpeakerMiranda::SpeakerMiranda(): VisualSpeaker() { @@ -472,7 +472,7 @@ void SpeakerMiranda300::proc15() {  		_object1.postInit();  		_object1.setPosition(_object2->_position); -		if (_object2->_mover)  +		if (_object2->_mover)  			_object2->addMover(NULL);  	} @@ -507,7 +507,7 @@ void SpeakerMiranda1625::proc15() {  		_object1.postInit();  		_object1.setPosition(Common::Point(196, 65)); -		if (_object2->_mover)  +		if (_object2->_mover)  			_object2->addMover(NULL);  	} @@ -547,7 +547,7 @@ void SpeakerMiranda3375::proc15() {  	int v = _fieldF6;  	if (!_object2) { -		if (R2_GLOBALS._player._characterIndex == 3)  +		if (R2_GLOBALS._player._characterIndex == 3)  			_object2 = &R2_GLOBALS._player;  		else  			_object2 = &scene->_actor2; @@ -558,7 +558,7 @@ void SpeakerMiranda3375::proc15() {  		_object1._numFrames = 7;  		_object1._effect = 1;  		_object1.changeZoom(-1); -		 +  		if (scene->_actor1._position.y != 163)  			R2_GLOBALS._player.setStrip(8);  		else @@ -574,7 +574,7 @@ void SpeakerMiranda3375::proc15() {  		if (_object2->_mover)  			_object2->addMover(NULL);  	} -	 +  	switch (v) {  	case 0: @@ -597,7 +597,7 @@ void SpeakerMiranda3385::proc15() {  	int v = _fieldF6;  	if (!_object2) { -		if (R2_GLOBALS._player._characterIndex == 3)  +		if (R2_GLOBALS._player._characterIndex == 3)  			_object2 = &R2_GLOBALS._player;  		else  			_object2 = &scene->_actor2; @@ -608,7 +608,7 @@ void SpeakerMiranda3385::proc15() {  		_object1._numFrames = 7;  		_object1._effect = 1;  		_object1.changeZoom(-1); -		 +  		if (R2_GLOBALS._sceneManager._previousScene == 3375)  			R2_GLOBALS._player.setStrip(4);  		else @@ -623,7 +623,7 @@ void SpeakerMiranda3385::proc15() {  		if (_object2->_mover)  			_object2->addMover(NULL);  	} -	 +  	switch (v) {  	case 0: @@ -646,7 +646,7 @@ void SpeakerMiranda3395::proc15() {  	int v = _fieldF6;  	if (!_object2) { -		if (R2_GLOBALS._player._characterIndex == 3)  +		if (R2_GLOBALS._player._characterIndex == 3)  			_object2 = &R2_GLOBALS._player;  		else  			_object2 = &scene->_actor2; @@ -657,7 +657,7 @@ void SpeakerMiranda3395::proc15() {  		_object1._numFrames = 7;  		_object1._effect = 1;  		_object1.changeZoom(-1); -		 +  		if (R2_GLOBALS._sceneManager._previousScene == 3385)  			R2_GLOBALS._player.setStrip(4);  		else @@ -673,7 +673,7 @@ void SpeakerMiranda3395::proc15() {  		if (_object2->_mover)  			_object2->addMover(NULL);  	} -	 +  	switch (v) {  	case 0: @@ -696,7 +696,7 @@ void SpeakerMiranda3400::proc15() {  	int v = _fieldF6;  	if (!_object2) { -		if (R2_GLOBALS._player._characterIndex == 3)  +		if (R2_GLOBALS._player._characterIndex == 3)  			_object2 = &R2_GLOBALS._player;  		else  			_object2 = &scene->_actor2; @@ -740,7 +740,7 @@ void SpeakerMiranda3600::proc15() {  	int v = _fieldF6;  	if (!_object2) { -		if (R2_GLOBALS._player._characterIndex == 3)  +		if (R2_GLOBALS._player._characterIndex == 3)  			_object2 = &R2_GLOBALS._player;  		else  			_object2 = &scene->_actor12; @@ -858,7 +858,7 @@ void SpeakerNej2700::proc15() {  		_object1.postInit();  		_object1.setPosition(_object2->_position); -		if (_object2->_mover)  +		if (_object2->_mover)  			_object2->addMover(NULL);  	} @@ -893,7 +893,7 @@ void SpeakerNej2750::proc15() {  		_object1.postInit();  		_object1.setPosition(_object2->_position); -		if (_object2->_mover)  +		if (_object2->_mover)  			_object2->addMover(NULL);  	} @@ -925,7 +925,7 @@ void SpeakerNej2800::proc15() {  		_object1.postInit();  		_object1.setPosition(_object2->_position); -		if (_object2->_mover)  +		if (_object2->_mover)  			_object2->addMover(NULL);  	} @@ -1002,7 +1002,7 @@ void SpeakerPrivate3210::proc15() {  		_object1.postInit();  		_object1.setPosition(_object2->_position); -		if (_object2->_mover)  +		if (_object2->_mover)  			_object2->addMover(NULL);  	} @@ -1047,7 +1047,7 @@ void SpeakerProtector3600::proc15() {  		R2_GLOBALS._player.disableControl();  		R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); -		if (_object2->_mover)  +		if (_object2->_mover)  			_object2->addMover(NULL);  	} @@ -1107,7 +1107,7 @@ void SpeakerQuinn300::proc15() {  		_object1.postInit();  		_object1.setPosition(_object2->_position); -		if (_object2->_mover)  +		if (_object2->_mover)  			_object2->addMover(NULL);  	} @@ -1122,7 +1122,7 @@ void SpeakerQuinn300::proc15() {  		_object1.animate(ANIM_MODE_6, this);  	} else {  		((SceneItem *)_action)->_sceneRegionId = 0; -		 +  		switch (_object2->_visage) {  		case 10:  			_object1.setup((v - 1) / 4 + 4010, ((v - ((v - 1) / 4 * 4) - 1) % 8) * 2 + 1, 1); @@ -1158,7 +1158,7 @@ void SpeakerQuinn1100::proc15() {  		_object1.setPosition(_object2->_position);  		_object1._numFrames = 7; -		if (_object2->_mover)  +		if (_object2->_mover)  			_object2->addMover(NULL);  	} @@ -1250,7 +1250,7 @@ void SpeakerQuinn2700::proc15() {  		_object1.postInit();  		_object1.setPosition(_object2->_position); -		if (_object2->_mover)  +		if (_object2->_mover)  			_object2->addMover(NULL);  	} @@ -1281,7 +1281,7 @@ void SpeakerQuinn2750::proc15() {  		_object1.postInit();  		_object1.setPosition(_object2->_position); -		if (_object2->_mover)  +		if (_object2->_mover)  			_object2->addMover(NULL);  	} @@ -1312,7 +1312,7 @@ void SpeakerQuinn2800::proc15() {  		_object1.postInit();  		_object1.setPosition(_object2->_position); -		if (_object2->_mover)  +		if (_object2->_mover)  			_object2->addMover(NULL);  	} @@ -1371,9 +1371,9 @@ void SpeakerQuinn3375::proc15() {  	int v = _fieldF6;  	if (!_object2) { -		if (R2_GLOBALS._player._characterIndex == 1)  +		if (R2_GLOBALS._player._characterIndex == 1)  			_object2 = &R2_GLOBALS._player; -		else if (R2_GLOBALS._player._characterIndex == 2)  +		else if (R2_GLOBALS._player._characterIndex == 2)  			_object2 = &scene->_actor1;  		else  			_object2 = &scene->_actor2; @@ -1384,7 +1384,7 @@ void SpeakerQuinn3375::proc15() {  		_object1._numFrames = 7;  		_object1._effect = 1;  		_object1.changeZoom(-1); -		 +  		if (scene->_actor1._position.y != 163)  			R2_GLOBALS._player.setStrip(8);  		else @@ -1399,7 +1399,7 @@ void SpeakerQuinn3375::proc15() {  		if (_object2->_mover)  			_object2->addMover(NULL);  	} -	 +  	switch (v) {  	case 0: @@ -1422,9 +1422,9 @@ void SpeakerQuinn3385::proc15() {  	int v = _fieldF6;  	if (!_object2) { -		if (R2_GLOBALS._player._characterIndex == 1)  +		if (R2_GLOBALS._player._characterIndex == 1)  			_object2 = &R2_GLOBALS._player; -		else if (R2_GLOBALS._player._characterIndex == 2)  +		else if (R2_GLOBALS._player._characterIndex == 2)  			_object2 = &scene->_actor1;  		else  			_object2 = &scene->_actor2; @@ -1435,7 +1435,7 @@ void SpeakerQuinn3385::proc15() {  		_object1._numFrames = 7;  		_object1._effect = 1;  		_object1.changeZoom(-1); -		 +  		if (R2_GLOBALS._sceneManager._previousScene == 3375)  			R2_GLOBALS._player.setStrip(4);  		else @@ -1450,7 +1450,7 @@ void SpeakerQuinn3385::proc15() {  		if (_object2->_mover)  			_object2->addMover(NULL);  	} -	 +  	switch (v) {  	case 0: @@ -1477,9 +1477,9 @@ void SpeakerQuinn3395::proc15() {  	int v = _fieldF6;  	if (!_object2) { -		if (R2_GLOBALS._player._characterIndex == 1)  +		if (R2_GLOBALS._player._characterIndex == 1)  			_object2 = &R2_GLOBALS._player; -		else if (R2_GLOBALS._player._characterIndex == 2)  +		else if (R2_GLOBALS._player._characterIndex == 2)  			_object2 = &scene->_actor1;  		else  			_object2 = &scene->_actor2; @@ -1490,7 +1490,7 @@ void SpeakerQuinn3395::proc15() {  		_object1._numFrames = 7;  		_object1._effect = 1;  		_object1.changeZoom(-1); -		 +  		if (R2_GLOBALS._sceneManager._previousScene == 3385)  			R2_GLOBALS._player.setStrip(4);  		else @@ -1505,7 +1505,7 @@ void SpeakerQuinn3395::proc15() {  		if (_object2->_mover)  			_object2->addMover(NULL);  	} -	 +  	switch (v) {  	case 0: @@ -1532,9 +1532,9 @@ void SpeakerQuinn3400::proc15() {  	int v = _fieldF6;  	if (!_object2) { -		if (R2_GLOBALS._player._characterIndex == 1)  +		if (R2_GLOBALS._player._characterIndex == 1)  			_object2 = &R2_GLOBALS._player; -		else if (R2_GLOBALS._player._characterIndex == 2)  +		else if (R2_GLOBALS._player._characterIndex == 2)  			_object2 = &scene->_actor1;  		else  			_object2 = &scene->_actor2; @@ -1581,7 +1581,7 @@ void SpeakerQuinn3600::proc15() {  	int v = _fieldF6;  	if (!_object2) { -		if (R2_GLOBALS._player._characterIndex == 1)  +		if (R2_GLOBALS._player._characterIndex == 1)  			_object2 = &R2_GLOBALS._player;  		else  			_object2 = &scene->_actor10; @@ -1736,7 +1736,7 @@ void SpeakerRalf3245::proc15() {  		_object1.postInit();  		_object1.setPosition(_object2->_position); -		if (_object2->_mover)  +		if (_object2->_mover)  			_object2->addMover(NULL);  	} @@ -1788,7 +1788,7 @@ void SpeakerRocko3200::proc15() {  		_object1.postInit();  		_object1.setPosition(_object2->_position); -		if (_object2->_mover)  +		if (_object2->_mover)  			_object2->addMover(NULL);  	} @@ -1811,7 +1811,7 @@ void SpeakerRocko3220::proc15() {  		_object1.postInit();  		_object1.setPosition(_object2->_position); -		if (_object2->_mover)  +		if (_object2->_mover)  			_object2->addMover(NULL);  	} @@ -1834,7 +1834,7 @@ void SpeakerRocko3230::proc15() {  		_object1.postInit();  		_object1.setPosition(_object2->_position); -		if (_object2->_mover)  +		if (_object2->_mover)  			_object2->addMover(NULL);  	} @@ -1879,7 +1879,7 @@ void SpeakerSeeker300::proc15() {  		_object1.fixPriority(140);  		_object1.setPosition(_object2->_position); -		if (_object2->_mover)  +		if (_object2->_mover)  			_object2->addMover(NULL);  	} @@ -1918,7 +1918,7 @@ void SpeakerSeeker1100::proc15() {  		_object1.setPosition(_object2->_position);  		_object1._numFrames = 7; -		if (_object2->_mover)  +		if (_object2->_mover)  			_object2->addMover(NULL);  	} @@ -1974,7 +1974,7 @@ void SpeakerSeeker1900::proc15() {  		_object1.setPosition(_object2->_position);  		_object1._numFrames = 7; -		if (_object2->_mover)  +		if (_object2->_mover)  			_object2->addMover(NULL);  	} @@ -2045,7 +2045,7 @@ void SpeakerSeeker3375::proc15() {  	int v = _fieldF6;  	if (!_object2) { -		if (R2_GLOBALS._player._characterIndex == 2)  +		if (R2_GLOBALS._player._characterIndex == 2)  			_object2 = &R2_GLOBALS._player;  		else  			_object2 = &scene->_actor1; @@ -2056,7 +2056,7 @@ void SpeakerSeeker3375::proc15() {  		_object1._numFrames = 7;  		_object1._effect = 1;  		_object1.changeZoom(-1); -		 +  		if (scene->_actor1._position.y != 163)  			R2_GLOBALS._player.setStrip(8);  		else @@ -2071,7 +2071,7 @@ void SpeakerSeeker3375::proc15() {  		if (_object2->_mover)  			_object2->addMover(NULL);  	} -	 +  	switch (v) {  	case 0: @@ -2094,7 +2094,7 @@ void SpeakerSeeker3385::proc15() {  	int v = _fieldF6;  	if (!_object2) { -		if (R2_GLOBALS._player._characterIndex == 2)  +		if (R2_GLOBALS._player._characterIndex == 2)  			_object2 = &R2_GLOBALS._player;  		else  			_object2 = &scene->_actor1; @@ -2105,7 +2105,7 @@ void SpeakerSeeker3385::proc15() {  		_object1._numFrames = 7;  		_object1._effect = 1;  		_object1.changeZoom(-1); -		 +  		if (R2_GLOBALS._sceneManager._previousScene == 3375)  			R2_GLOBALS._player.setStrip(4);  		else @@ -2120,7 +2120,7 @@ void SpeakerSeeker3385::proc15() {  		if (_object2->_mover)  			_object2->addMover(NULL);  	} -	 +  	switch (v) {  	case 0: @@ -2143,7 +2143,7 @@ void SpeakerSeeker3395::proc15() {  	int v = _fieldF6;  	if (!_object2) { -		if (R2_GLOBALS._player._characterIndex == 2)  +		if (R2_GLOBALS._player._characterIndex == 2)  			_object2 = &R2_GLOBALS._player;  		else  			_object2 = &scene->_actor1; @@ -2154,7 +2154,7 @@ void SpeakerSeeker3395::proc15() {  		_object1._numFrames = 7;  		_object1._effect = 1;  		_object1.changeZoom(-1); -		 +  		if (R2_GLOBALS._sceneManager._previousScene == 3385)  			R2_GLOBALS._player.setStrip(4);  		else @@ -2169,7 +2169,7 @@ void SpeakerSeeker3395::proc15() {  		if (_object2->_mover)  			_object2->addMover(NULL);  	} -	 +  	switch (v) {  	case 0: @@ -2192,7 +2192,7 @@ void SpeakerSeeker3400::proc15() {  	int v = _fieldF6;  	if (!_object2) { -		if (R2_GLOBALS._player._characterIndex == 2)  +		if (R2_GLOBALS._player._characterIndex == 2)  			_object2 = &R2_GLOBALS._player;  		else  			_object2 = &scene->_actor1; @@ -2251,7 +2251,7 @@ void SpeakerSeeker3600::proc15() {  	int v = _fieldF6;  	if (!_object2) { -		if (R2_GLOBALS._player._characterIndex == 2)  +		if (R2_GLOBALS._player._characterIndex == 2)  			_object2 = &R2_GLOBALS._player;  		else  			_object2 = &scene->_actor11; @@ -2394,7 +2394,7 @@ void SpeakerSocko3200::proc15() {  		_object1.postInit();  		_object1.setPosition(_object2->_position); -		if (_object2->_mover)  +		if (_object2->_mover)  			_object2->addMover(NULL);  	} @@ -2434,7 +2434,7 @@ void SpeakerSoldier300::proc15() {  		_object1.postInit();  		_object1.setPosition(_object2->_position); -		if (_object2->_mover)  +		if (_object2->_mover)  			_object2->addMover(NULL);  	} @@ -2478,7 +2478,7 @@ void SpeakerTeal300::proc15() {  		_object1.postInit();  		_object1.setPosition(_object2->_position); -		if (_object2->_mover)  +		if (_object2->_mover)  			_object2->addMover(NULL);  	} @@ -2502,7 +2502,7 @@ void SpeakerTeal1625::proc15() {  		_object1.postInit();  		_object1.setPosition(Common::Point(68, 68)); -		if (_object2->_mover)  +		if (_object2->_mover)  			_object2->addMover(NULL);  	} @@ -2525,7 +2525,7 @@ void SpeakerTeal3240::proc15() {  		_object1.postInit();  		_object1.setPosition(_object2->_position); -		if (_object2->_mover)  +		if (_object2->_mover)  			_object2->addMover(NULL);  	} @@ -2677,7 +2677,7 @@ void SpeakerTomko3245::proc15() {  		_object1.postInit();  		_object1.setPosition(_object2->_position); -		if (_object2->_mover)  +		if (_object2->_mover)  			_object2->addMover(NULL);  	} @@ -2729,7 +2729,7 @@ void SpeakerWebbster3240::proc15() {  		_object1.postInit();  		_object1.setPosition(_object2->_position); -		if (_object2->_mover)  +		if (_object2->_mover)  			_object2->addMover(NULL);  	} @@ -2755,7 +2755,7 @@ void SpeakerWebbster3375::proc15() {  		_object1._numFrames = 7;  		_object1._effect = 1;  		_object1.changeZoom(-1); -		 +  		if (scene->_actor1._position.y != 163)  			R2_GLOBALS._player.setStrip(8);  		else @@ -2799,7 +2799,7 @@ void SpeakerWebbster3385::proc15() {  		_object1._numFrames = 7;  		_object1._effect = 1;  		_object1.changeZoom(-1); -		 +  		if (R2_GLOBALS._sceneManager._previousScene == 3375)  			R2_GLOBALS._player.setStrip(4);  		else @@ -2843,7 +2843,7 @@ void SpeakerWebbster3395::proc15() {  		_object1._numFrames = 7;  		_object1._effect = 1;  		_object1.changeZoom(-1); -		 +  		if (R2_GLOBALS._sceneManager._previousScene == 3385)  			R2_GLOBALS._player.setStrip(4);  		else diff --git a/engines/tsage/scenes.cpp b/engines/tsage/scenes.cpp index c091afe34c..0756d71d4c 100644 --- a/engines/tsage/scenes.cpp +++ b/engines/tsage/scenes.cpp @@ -240,7 +240,7 @@ void SceneManager::listenerSynchronize(Serializer &s) {  	if (s.isLoading()) {  		changeScene(_sceneNumber); -		 +  		if (_nextSceneNumber != -1) {  			sceneChange();  			_nextSceneNumber = -1; @@ -317,7 +317,7 @@ void Scene::loadSceneData(int sceneNum) {  	_activeScreenNumber = sceneNum;  	if (g_vm->getGameID() == GType_Ringworld2) { -		// Most scenes in Ringworld 2 don't have a scene size resource, but rather just have  +		// Most scenes in Ringworld 2 don't have a scene size resource, but rather just have  		// a standard 320x200 size. Only read the scene size data for the specific few scenes  		switch (sceneNum) {  		case 700: @@ -457,7 +457,7 @@ void Scene::refreshBackground(int xAmount, int yAmount) {  						Rect destBounds(xSectionDest * 160, ySectionDest * 100,  								(xSectionDest + 1) * 160, (ySectionDest + 1) * 100);  						if (g_vm->getGameID() != GType_Ringworld) { -							// For Blue Force and Return to Ringworld, if the scene has an interface area,  +							// For Blue Force and Return to Ringworld, if the scene has an interface area,  							// exclude it from the copy  							srcBounds.bottom = MIN<int16>(srcBounds.bottom, BF_GLOBALS._interfaceY);  							destBounds.bottom = MIN<int16>(destBounds.bottom, BF_GLOBALS._interfaceY); diff --git a/engines/tsage/staticres.cpp b/engines/tsage/staticres.cpp index c254565aca..a273ec2a0b 100644 --- a/engines/tsage/staticres.cpp +++ b/engines/tsage/staticres.cpp @@ -400,8 +400,8 @@ const byte k5A4D6[] = {  const byte k5A72E[] = {0,  98, 135, 183, 229, 81, 133, 185, 235, 75, 131, 187, 241, 70,  129, 190, 247};  const byte k5A73F[] = {0,  42, 42,  42,  42,  67, 67,  67,  67,  92, 92,  92,  92,  116, 116, 116, 116};  const byte k5A750[] = { -	9, 10, 7, 13, 7, 8, 9,  7, 9, 10,  -	2, 3,  3, 2,  2, 2, 4,  3, 3, 4,  +	9, 10, 7, 13, 7, 8, 9,  7, 9, 10, +	2, 3,  3, 2,  2, 2, 4,  3, 3, 4,  	3, 2,  3, 4,  3, 8, 10, 4, 0  };  const byte k5A76D[] = { diff --git a/engines/tsage/tsage.h b/engines/tsage/tsage.h index eb36cf0790..41179c4915 100644 --- a/engines/tsage/tsage.h +++ b/engines/tsage/tsage.h @@ -54,7 +54,8 @@ enum {  enum {  	kRingDebugScripts = 1 << 0,  	ktSageSound = 1 << 1, -	ktSageCore = 1 << 2 +	ktSageCore = 1 << 2, +	ktSageDebugGraphics = 1 << 3  };  struct tSageGameDescription; diff --git a/engines/tsage/user_interface.cpp b/engines/tsage/user_interface.cpp index ca9fddc6ce..10cb6961dc 100644 --- a/engines/tsage/user_interface.cpp +++ b/engines/tsage/user_interface.cpp @@ -316,7 +316,7 @@ void UIElements::synchronize(Serializer &s) {  }  void UIElements::process(Event &event) { -	if (_clearScreen && GLOBALS._player._enabled &&  +	if (_clearScreen && GLOBALS._player._enabled &&  			((g_vm->getGameID() != GType_BlueForce) || (GLOBALS._sceneManager._sceneNumber != 50))) {  		if (_bounds.contains(event.mousePos)) {  			// Cursor inside UI area diff --git a/graphics/sjis.h b/graphics/sjis.h index f96eef6ad1..2d05005fc3 100644 --- a/graphics/sjis.h +++ b/graphics/sjis.h @@ -43,7 +43,7 @@  #endif  #include "common/scummsys.h" -#include "common/util.h" +#include "common/platform.h"  namespace Graphics { diff --git a/gui/dialog.cpp b/gui/dialog.cpp index 0522b40b46..fd15ba5e09 100644 --- a/gui/dialog.cpp +++ b/gui/dialog.cpp @@ -334,25 +334,7 @@ void Dialog::removeWidget(Widget *del) {  	if (del == _dragWidget)  		_dragWidget = NULL; -	Widget *w = _firstWidget; - -	if (del == _firstWidget) { -		Widget *del_next = del->_next; -		del->_next = 0; -		_firstWidget = del_next; -		return; -	} - -	w = _firstWidget; -	while (w) { -		if (w->_next == del) { -			Widget *del_next = del->_next; -			del->_next = 0; -			w->_next = del_next; -			return; -		} -		w = w->_next; -	} +	GuiObject::removeWidget(del);  }  } // End of namespace GUI diff --git a/gui/launcher.cpp b/gui/launcher.cpp index 5bb358452a..a3e4925848 100644 --- a/gui/launcher.cpp +++ b/gui/launcher.cpp @@ -24,6 +24,7 @@  #include "common/config-manager.h"  #include "common/events.h"  #include "common/fs.h" +#include "common/gui_options.h"  #include "common/util.h"  #include "common/system.h"  #include "common/translation.h" diff --git a/gui/object.cpp b/gui/object.cpp index 2ec42df9d7..73c4f74d6c 100644 --- a/gui/object.cpp +++ b/gui/object.cpp @@ -59,4 +59,24 @@ void GuiObject::reflowLayout() {  	}  } +void GuiObject::removeWidget(Widget *del) { +	if (del == _firstWidget) { +		Widget *del_next = del->next(); +		del->setNext(0); +		_firstWidget = del_next; +		return; +	} + +	Widget *w = _firstWidget; +	while (w) { +		if (w->next() == del) { +			Widget *del_next = del->next(); +			del->setNext(0); +			w->setNext(del_next); +			return; +		} +		w = w->next(); +	} +} +  } // End of namespace GUI diff --git a/gui/object.h b/gui/object.h index 34ff0d47f2..bce3cd7846 100644 --- a/gui/object.h +++ b/gui/object.h @@ -83,6 +83,8 @@ public:  	virtual void	reflowLayout(); +	virtual void	removeWidget(Widget *widget); +  protected:  	virtual void	releaseFocus() = 0;  }; diff --git a/gui/options.cpp b/gui/options.cpp index bfad81c07b..5085f9cdd9 100644 --- a/gui/options.cpp +++ b/gui/options.cpp @@ -30,6 +30,8 @@  #include "common/fs.h"  #include "common/config-manager.h" +#include "common/gui_options.h" +#include "common/rendermode.h"  #include "common/system.h"  #include "common/textconsole.h"  #include "common/translation.h" @@ -79,7 +81,7 @@ static const char *outputRateLabels[] = { _s("<default>"), _s("8 kHz"), _s("11kH  static const int outputRateValues[] = { 0, 8000, 11025, 22050, 44100, 48000, -1 };  OptionsDialog::OptionsDialog(const Common::String &domain, int x, int y, int w, int h) -	: Dialog(x, y, w, h), _domain(domain), _graphicsTabId(-1), _tabWidget(0) { +	: Dialog(x, y, w, h), _domain(domain), _graphicsTabId(-1), _midiTabId(-1), _pathsTabId(-1), _tabWidget(0) {  	init();  } @@ -1050,7 +1052,8 @@ Common::String OptionsDialog::renderType2GUIO(uint32 renderType) {  		{ Common::kRenderVGA,		GUIO_RENDERVGA },  		{ Common::kRenderAmiga,		GUIO_RENDERAMIGA },  		{ Common::kRenderFMTowns,	GUIO_RENDERFMTOWNS }, -		{ Common::kRenderPC98,		GUIO_RENDERPC98 } +		{ Common::kRenderPC9821,	GUIO_RENDERPC9821 }, +		{ Common::kRenderPC9801,	GUIO_RENDERPC9801 }  	};  	Common::String res; @@ -1119,7 +1122,7 @@ GlobalOptionsDialog::GlobalOptionsDialog()  	//  	// 3) The MIDI tab  	// -	tab->addTab(_("MIDI")); +	_midiTabId = tab->addTab(_("MIDI"));  	addMIDIControls(tab, "GlobalOptions_MIDI.");  	// @@ -1132,9 +1135,9 @@ GlobalOptionsDialog::GlobalOptionsDialog()  	// 5) The Paths tab  	//  	if (g_system->getOverlayWidth() > 320) -		tab->addTab(_("Paths")); +		_pathsTabId = tab->addTab(_("Paths"));  	else -		tab->addTab(_c("Paths", "lowres")); +		_pathsTabId = tab->addTab(_c("Paths", "lowres"));  #if !( defined(__DC__) || defined(__GP32__) )  	// These two buttons have to be extra wide, or the text will be @@ -1493,4 +1496,39 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3  	}  } +void GlobalOptionsDialog::reflowLayout() { +	int activeTab = _tabWidget->getActiveTab(); + +	if (_midiTabId != -1) { +		_tabWidget->setActiveTab(_midiTabId); + +		_tabWidget->removeWidget(_soundFontClearButton); +		_soundFontClearButton->setNext(0); +		delete _soundFontClearButton; +		_soundFontClearButton = addClearButton(_tabWidget, "GlobalOptions_MIDI.mcFontClearButton", kClearSoundFontCmd); +	} + +	if (_pathsTabId != -1) { +		_tabWidget->setActiveTab(_pathsTabId); + +		_tabWidget->removeWidget(_savePathClearButton); +		_savePathClearButton->setNext(0); +		delete _savePathClearButton; +		_savePathClearButton = addClearButton(_tabWidget, "GlobalOptions_Paths.SavePathClearButton", kSavePathClearCmd); + +		_tabWidget->removeWidget(_themePathClearButton); +		_themePathClearButton->setNext(0); +		delete _themePathClearButton; +		_themePathClearButton = addClearButton(_tabWidget, "GlobalOptions_Paths.ThemePathClearButton", kThemePathClearCmd); + +		_tabWidget->removeWidget(_extraPathClearButton); +		_extraPathClearButton->setNext(0); +		delete _extraPathClearButton; +		_extraPathClearButton = addClearButton(_tabWidget, "GlobalOptions_Paths.ExtraPathClearButton", kExtraPathClearCmd); +	} + +	_tabWidget->setActiveTab(activeTab); +	OptionsDialog::reflowLayout(); +} +  } // End of namespace GUI diff --git a/gui/options.h b/gui/options.h index 4e0187f50f..83c9d60d59 100644 --- a/gui/options.h +++ b/gui/options.h @@ -89,6 +89,8 @@ protected:  	TabWidget *_tabWidget;  	int _graphicsTabId; +	int _midiTabId; +	int _pathsTabId;  private:  	// @@ -193,6 +195,8 @@ public:  	void close();  	void handleCommand(CommandSender *sender, uint32 cmd, uint32 data); +	virtual void reflowLayout(); +  protected:  #ifdef SMALL_SCREEN_DEVICE  	KeysDialog *_keysDialog; diff --git a/gui/themes/scummclassic.zip b/gui/themes/scummclassic.zip Binary files differindex 8b2a3e7899..d4cfd0cba3 100644 --- a/gui/themes/scummclassic.zip +++ b/gui/themes/scummclassic.zip diff --git a/gui/themes/scummmodern.zip b/gui/themes/scummmodern.zip Binary files differindex 84416636bc..fc4c89cbcc 100644 --- a/gui/themes/scummmodern.zip +++ b/gui/themes/scummmodern.zip diff --git a/gui/themes/scummmodern/scummmodern_gfx.stx b/gui/themes/scummmodern/scummmodern_gfx.stx index b420ce0903..5f7cc69acd 100644 --- a/gui/themes/scummmodern/scummmodern_gfx.stx +++ b/gui/themes/scummmodern/scummmodern_gfx.stx @@ -125,7 +125,7 @@  		/>  		<font	id = 'text_normal'  				file = 'helvb12.bdf' -				scalable_file = 'FreeSansBold.ttf' +				scalable_file = 'FreeSans.ttf'  		/>  		<font	resolution = 'y<400'  		   		id = 'text_normal' diff --git a/gui/widgets/edittext.cpp b/gui/widgets/edittext.cpp index af8ab8aa5b..4b266e8194 100644 --- a/gui/widgets/edittext.cpp +++ b/gui/widgets/edittext.cpp @@ -33,6 +33,7 @@ EditTextWidget::EditTextWidget(GuiObject *boss, int x, int y, int w, int h, cons  	_finishCmd = finishCmd;  	setEditString(text); +	setFontStyle(ThemeEngine::kFontStyleNormal);  }  EditTextWidget::EditTextWidget(GuiObject *boss, const String &name, const String &text, const char *tooltip, uint32 cmd, uint32 finishCmd) @@ -42,6 +43,7 @@ EditTextWidget::EditTextWidget(GuiObject *boss, const String &name, const String  	_finishCmd = finishCmd;  	setEditString(text); +	setFontStyle(ThemeEngine::kFontStyleNormal);  }  void EditTextWidget::setEditString(const String &str) { diff --git a/video/module.mk b/video/module.mk index ceeac94384..900a781d0a 100644 --- a/video/module.mk +++ b/video/module.mk @@ -5,6 +5,7 @@ MODULE_OBJS := \  	coktel_decoder.o \  	dxa_decoder.o \  	flic_decoder.o \ +	psx_decoder.o \  	qt_decoder.o \  	smk_decoder.o \  	video_decoder.o \ diff --git a/video/psx_decoder.cpp b/video/psx_decoder.cpp new file mode 100644 index 0000000000..7c04b7f041 --- /dev/null +++ b/video/psx_decoder.cpp @@ -0,0 +1,697 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +// PlayStation Stream demuxer and XA audio decoder based on FFmpeg/libav +// MDEC video emulation based on http://kenai.com/downloads/jpsxdec/Old/PlayStation1_STR_format1-00.txt + +#include "audio/audiostream.h" +#include "audio/mixer.h" +#include "audio/decoders/raw.h" +#include "common/bitstream.h" +#include "common/huffman.h" +#include "common/memstream.h" +#include "common/stream.h" +#include "common/system.h" +#include "common/textconsole.h" +#include "graphics/yuv_to_rgb.h" + +#include "video/psx_decoder.h" + +namespace Video { + +// Here are the codes/lengths/symbols that are used for decoding +// DC coefficients (version 3 frames only) + +#define DC_CODE_COUNT 9 +#define DC_HUFF_VAL(b, n, p) (((b) << 16) | ((n) << 8) | (p)) +#define GET_DC_BITS(x) ((x) >> 16) +#define GET_DC_NEG(x) ((int)(((x) >> 8) & 0xff)) +#define GET_DC_POS(x) ((int)((x) & 0xff)) + +static const uint32 s_huffmanDCChromaCodes[DC_CODE_COUNT] = { +	254, 126, 62, 30, 14, 6, 2, 1, 0 +}; + +static const byte s_huffmanDCChromaLengths[DC_CODE_COUNT] = { +	8, 7, 6, 5, 4, 3, 2, 2, 2 +}; + +static const uint32 s_huffmanDCLumaCodes[DC_CODE_COUNT] = { +	126, 62, 30, 14, 6, 5, 1, 0, 4 +}; + +static const byte s_huffmanDCLumaLengths[DC_CODE_COUNT] = { +	7, 6, 5, 4, 3, 3, 2, 2, 3 +}; + +static const uint32 s_huffmanDCSymbols[DC_CODE_COUNT] = { +	DC_HUFF_VAL(8, 255, 128), DC_HUFF_VAL(7, 127, 64), DC_HUFF_VAL(6, 63, 32), +	DC_HUFF_VAL(5, 31, 16), DC_HUFF_VAL(4, 15, 8), DC_HUFF_VAL(3, 7, 4), +	DC_HUFF_VAL(2, 3, 2), DC_HUFF_VAL(1, 1, 1), DC_HUFF_VAL(0, 0, 0) +}; + +// Here are the codes/lengths/symbols that are used for decoding +// DC coefficients (version 2 and 3 frames) + +#define AC_CODE_COUNT 113 +#define AC_HUFF_VAL(z, a) ((z << 8) | a) +#define ESCAPE_CODE  ((uint32)-1) // arbitrary, just so we can tell what code it is +#define END_OF_BLOCK ((uint32)-2) // arbitrary, just so we can tell what code it is +#define GET_AC_ZERO_RUN(code) (code >> 8) +#define GET_AC_COEFFICIENT(code) ((int)(code & 0xff)) + +static const uint32 s_huffmanACCodes[AC_CODE_COUNT] = { +	// Regular codes +	3, 3, 4, 5, 5, 6, 7, 4, 5, 6, 7, 4, 5, 6, 7, +	32, 33, 34, 35, 36, 37, 38, 39, 8, 9, 10, 11, +	12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, +	23, 24, 25, 26, 27, 28, 29, 30, 31, 16, 17, +	18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, +	29, 30, 31, 16, 17, 18, 19, 20, 21, 22, 23, +	24, 25, 26, 27, 28, 29, 30, 31, 16, 17, 18, +	19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, +	30, 31, 16, 17, 18, 19, 20, 21, 22, 23, 24, +	25, 26, 27, 28, 29, 30, 31, + +	// Escape code +	1, +	// End of block code +	2 +}; + +static const byte s_huffmanACLengths[AC_CODE_COUNT] = { +	// Regular codes +	2, 3, 4, 4, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, +	8, 8, 8, 8, 8, 8, 8, 8, 10, 10, 10, 10, 10, +	10, 10, 10, 12, 12, 12, 12, 12, 12, 12, 12, +	12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, +	13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, +	13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, +	14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, +	15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, +	15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, +	16, 16, 16, 16, 16, 16, + +	// Escape code +	6, +	// End of block code +	2 +}; + +static const uint32 s_huffmanACSymbols[AC_CODE_COUNT] = { +	// Regular codes +	AC_HUFF_VAL(0, 1), AC_HUFF_VAL(1, 1), AC_HUFF_VAL(0, 2), AC_HUFF_VAL(2, 1), AC_HUFF_VAL(0, 3), +	AC_HUFF_VAL(4, 1), AC_HUFF_VAL(3, 1), AC_HUFF_VAL(7, 1), AC_HUFF_VAL(6, 1), AC_HUFF_VAL(1, 2), +	AC_HUFF_VAL(5, 1), AC_HUFF_VAL(2, 2), AC_HUFF_VAL(9, 1), AC_HUFF_VAL(0, 4), AC_HUFF_VAL(8, 1), +	AC_HUFF_VAL(13, 1), AC_HUFF_VAL(0, 6), AC_HUFF_VAL(12, 1), AC_HUFF_VAL(11, 1), AC_HUFF_VAL(3, 2), +	AC_HUFF_VAL(1, 3), AC_HUFF_VAL(0, 5), AC_HUFF_VAL(10, 1), AC_HUFF_VAL(16, 1), AC_HUFF_VAL(5, 2), +	AC_HUFF_VAL(0, 7), AC_HUFF_VAL(2, 3), AC_HUFF_VAL(1, 4), AC_HUFF_VAL(15, 1), AC_HUFF_VAL(14, 1), +	AC_HUFF_VAL(4, 2), AC_HUFF_VAL(0, 11), AC_HUFF_VAL(8, 2), AC_HUFF_VAL(4, 3), AC_HUFF_VAL(0, 10), +	AC_HUFF_VAL(2, 4), AC_HUFF_VAL(7, 2), AC_HUFF_VAL(21, 1), AC_HUFF_VAL(20, 1), AC_HUFF_VAL(0, 9), +	AC_HUFF_VAL(19, 1), AC_HUFF_VAL(18, 1), AC_HUFF_VAL(1, 5), AC_HUFF_VAL(3, 3), AC_HUFF_VAL(0, 8), +	AC_HUFF_VAL(6, 2), AC_HUFF_VAL(17, 1), AC_HUFF_VAL(10, 2), AC_HUFF_VAL(9, 2), AC_HUFF_VAL(5, 3), +	AC_HUFF_VAL(3, 4), AC_HUFF_VAL(2, 5), AC_HUFF_VAL(1, 7), AC_HUFF_VAL(1, 6), AC_HUFF_VAL(0, 15), +	AC_HUFF_VAL(0, 14), AC_HUFF_VAL(0, 13), AC_HUFF_VAL(0, 12), AC_HUFF_VAL(26, 1), AC_HUFF_VAL(25, 1), +	AC_HUFF_VAL(24, 1), AC_HUFF_VAL(23, 1), AC_HUFF_VAL(22, 1), AC_HUFF_VAL(0, 31), AC_HUFF_VAL(0, 30), +	AC_HUFF_VAL(0, 29), AC_HUFF_VAL(0, 28), AC_HUFF_VAL(0, 27), AC_HUFF_VAL(0, 26), AC_HUFF_VAL(0, 25), +	AC_HUFF_VAL(0, 24), AC_HUFF_VAL(0, 23), AC_HUFF_VAL(0, 22), AC_HUFF_VAL(0, 21), AC_HUFF_VAL(0, 20), +	AC_HUFF_VAL(0, 19), AC_HUFF_VAL(0, 18), AC_HUFF_VAL(0, 17), AC_HUFF_VAL(0, 16), AC_HUFF_VAL(0, 40), +	AC_HUFF_VAL(0, 39), AC_HUFF_VAL(0, 38), AC_HUFF_VAL(0, 37), AC_HUFF_VAL(0, 36), AC_HUFF_VAL(0, 35), +	AC_HUFF_VAL(0, 34), AC_HUFF_VAL(0, 33), AC_HUFF_VAL(0, 32), AC_HUFF_VAL(1, 14), AC_HUFF_VAL(1, 13), +	AC_HUFF_VAL(1, 12), AC_HUFF_VAL(1, 11), AC_HUFF_VAL(1, 10), AC_HUFF_VAL(1, 9), AC_HUFF_VAL(1, 8), +	AC_HUFF_VAL(1, 18), AC_HUFF_VAL(1, 17), AC_HUFF_VAL(1, 16), AC_HUFF_VAL(1, 15), AC_HUFF_VAL(6, 3), +	AC_HUFF_VAL(16, 2), AC_HUFF_VAL(15, 2), AC_HUFF_VAL(14, 2), AC_HUFF_VAL(13, 2), AC_HUFF_VAL(12, 2), +	AC_HUFF_VAL(11, 2), AC_HUFF_VAL(31, 1), AC_HUFF_VAL(30, 1), AC_HUFF_VAL(29, 1), AC_HUFF_VAL(28, 1), +	AC_HUFF_VAL(27, 1), + +	// Escape code +	ESCAPE_CODE, +	// End of block code +	END_OF_BLOCK +}; + +PSXStreamDecoder::PSXStreamDecoder(CDSpeed speed, uint32 frameCount) : _nextFrameStartTime(0, speed), _frameCount(frameCount) { +	_stream = 0; +	_audStream = 0; +	_surface = new Graphics::Surface(); +	_yBuffer = _cbBuffer = _crBuffer = 0; +	_acHuffman = new Common::Huffman(0, AC_CODE_COUNT, s_huffmanACCodes, s_huffmanACLengths, s_huffmanACSymbols); +	_dcHuffmanChroma = new Common::Huffman(0, DC_CODE_COUNT, s_huffmanDCChromaCodes, s_huffmanDCChromaLengths, s_huffmanDCSymbols); +	_dcHuffmanLuma = new Common::Huffman(0, DC_CODE_COUNT, s_huffmanDCLumaCodes, s_huffmanDCLumaLengths, s_huffmanDCSymbols); +} + +PSXStreamDecoder::~PSXStreamDecoder() { +	close(); +	delete _surface; +	delete _acHuffman; +	delete _dcHuffmanLuma; +	delete _dcHuffmanChroma; +} + +#define RAW_CD_SECTOR_SIZE 2352 + +#define CDXA_TYPE_MASK     0x0E +#define CDXA_TYPE_DATA     0x08 +#define CDXA_TYPE_AUDIO    0x04 +#define CDXA_TYPE_VIDEO    0x02 + +bool PSXStreamDecoder::loadStream(Common::SeekableReadStream *stream) { +	close(); + +	_stream = stream; + +	Common::SeekableReadStream *sector = readSector(); + +	if (!sector) { +		close(); +		return false; +	} + +	// Rip out video info from the first frame +	sector->seek(18); +	byte sectorType = sector->readByte() & CDXA_TYPE_MASK; + +	if (sectorType != CDXA_TYPE_VIDEO && sectorType != CDXA_TYPE_DATA) { +		close(); +		return false; +	} + +	sector->seek(40); + +	uint16 width = sector->readUint16LE(); +	uint16 height = sector->readUint16LE(); +	_surface->create(width, height, g_system->getScreenFormat()); + +	_macroBlocksW = (width + 15) / 16; +	_macroBlocksH = (height + 15) / 16; +	_yBuffer = new byte[_macroBlocksW * _macroBlocksH * 16 * 16]; +	_cbBuffer = new byte[_macroBlocksW * _macroBlocksH * 8 * 8]; +	_crBuffer = new byte[_macroBlocksW * _macroBlocksH * 8 * 8]; + +	delete sector; +	_stream->seek(0); + +	return true; +} + +void PSXStreamDecoder::close() { +	if (!_stream) +		return; + +	delete _stream; +	_stream = 0; + +	// Deinitialize sound +	g_system->getMixer()->stopHandle(_audHandle); +	_audStream = 0; + +	_surface->free(); + +	memset(&_adpcmStatus, 0, sizeof(_adpcmStatus)); + +	_macroBlocksW = _macroBlocksH = 0; +	delete[] _yBuffer; _yBuffer = 0; +	delete[] _cbBuffer; _cbBuffer = 0; +	delete[] _crBuffer; _crBuffer = 0; + +	reset(); +} + +uint32 PSXStreamDecoder::getElapsedTime() const { +	// TODO: Currently, the audio is always after the video so using this +	// can often lead to gaps in the audio... +	//if (_audStream) +	//	return _mixer->getSoundElapsedTime(_audHandle); + +	return VideoDecoder::getElapsedTime(); +} + +uint32 PSXStreamDecoder::getTimeToNextFrame() const { +	if (!isVideoLoaded() || endOfVideo()) +		return 0; + +	uint32 nextTimeMillis = _nextFrameStartTime.msecs(); +	uint32 elapsedTime = getElapsedTime(); + +	if (elapsedTime > nextTimeMillis) +		return 0; + +	return nextTimeMillis - elapsedTime; +} + +#define VIDEO_DATA_CHUNK_SIZE   2016 +#define VIDEO_DATA_HEADER_SIZE  56 + +const Graphics::Surface *PSXStreamDecoder::decodeNextFrame() { +	Common::SeekableReadStream *sector = 0; +	byte *partialFrame = 0; +	int sectorsRead = 0; + +	while (!endOfVideo()) { +		sector = readSector(); +		sectorsRead++; + +		if (!sector) +			error("Corrupt PSX stream sector"); + +		sector->seek(0x11); +		byte track = sector->readByte(); +		if (track >= 32) +			error("Bad PSX stream track"); + +		byte sectorType = sector->readByte() & CDXA_TYPE_MASK; + +		switch (sectorType) { +		case CDXA_TYPE_DATA: +		case CDXA_TYPE_VIDEO: +			if (track == 1) { +				sector->seek(28); +				uint16 curSector = sector->readUint16LE(); +				uint16 sectorCount = sector->readUint16LE(); +				sector->readUint32LE(); +				uint16 frameSize = sector->readUint32LE(); + +				if (curSector >= sectorCount) +					error("Bad sector"); + +				if (!partialFrame) +					partialFrame = (byte *)malloc(sectorCount * VIDEO_DATA_CHUNK_SIZE); + +				sector->seek(VIDEO_DATA_HEADER_SIZE); +				sector->read(partialFrame + curSector * VIDEO_DATA_CHUNK_SIZE, VIDEO_DATA_CHUNK_SIZE); + +				if (curSector == sectorCount - 1) { +					// Done assembling the frame +					Common::SeekableReadStream *frame = new Common::MemoryReadStream(partialFrame, frameSize, DisposeAfterUse::YES); + +					decodeFrame(frame); +					 +					delete frame; +					delete sector; + +					_curFrame++; +					if (_curFrame == 0) +						_startTime = g_system->getMillis(); + +					// Increase the time by the amount of sectors we read +					// One may notice that this is still not the most precise +					// method since a frame takes up the time its sectors took +					// up instead of the amount of time it takes the next frame +					// to be read from the sectors. The actual frame rate should +					// be constant instead of variable, so the slight difference +					// in a frame's showing time is negligible (1/150 of a second). +					_nextFrameStartTime = _nextFrameStartTime.addFrames(sectorsRead); + +					return _surface; +				} +			} else +				error("Unhandled multi-track video"); +			break; +		case CDXA_TYPE_AUDIO: +			// We only handle one audio channel so far +			if (track == 1) +				queueAudioFromSector(sector); +			else +				warning("Unhandled multi-track audio"); +			break; +		default: +			// This shows up way too often, but the other sectors +			// are safe to ignore +			//warning("Unknown PSX sector type 0x%x", sectorType); +			break; +		} + +		delete sector; +	} + +	return 0; +} + +static const byte s_syncHeader[12] = { 0x00, 0xff ,0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00 }; + +Common::SeekableReadStream *PSXStreamDecoder::readSector() { +	assert(_stream); + +	Common::SeekableReadStream *stream = _stream->readStream(RAW_CD_SECTOR_SIZE); + +	byte syncHeader[12]; +	stream->read(syncHeader, 12); +	if (!memcmp(s_syncHeader, syncHeader, 12)) +		return stream; + +	return 0; +} + +// Ha! It's palindromic! +#define AUDIO_DATA_CHUNK_SIZE   2304 +#define AUDIO_DATA_SAMPLE_COUNT 4032  + +static const int s_xaTable[5][2] = { +   {   0,   0 }, +   {  60,   0 }, +   { 115, -52 }, +   {  98, -55 }, +   { 122, -60 } +}; + +void PSXStreamDecoder::queueAudioFromSector(Common::SeekableReadStream *sector) { +	assert(sector); + +	if (!_audStream) { +		// Initialize audio stream +		sector->seek(19); +		byte format = sector->readByte(); + +		bool stereo = (format & (1 << 0)) != 0; +		uint rate = (format & (1 << 2)) ? 18900 : 37800; + +		_audStream = Audio::makeQueuingAudioStream(rate, stereo); +		g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &_audHandle, _audStream); +	} + +	sector->seek(24); + +	// This XA audio is different (yet similar) from normal XA audio! Watch out! +	// TODO: It's probably similar enough to normal XA that we can merge it somehow... +	// TODO: RTZ PSX needs the same audio code in a regular AudioStream class. Probably +	// will do something similar to QuickTime and creating a base class 'ISOMode2Parser' +	// or something similar. +	byte *buf = new byte[AUDIO_DATA_CHUNK_SIZE]; +	sector->read(buf, AUDIO_DATA_CHUNK_SIZE); + +	int channels = _audStream->isStereo() ? 2 : 1; +	int16 *dst = new int16[AUDIO_DATA_SAMPLE_COUNT]; +	int16 *leftChannel = dst; +	int16 *rightChannel = dst + 1; + +	for (byte *src = buf; src < buf + AUDIO_DATA_CHUNK_SIZE; src += 128) { +		for (int i = 0; i < 4; i++) { +			int shift = 12 - (src[4 + i * 2] & 0xf); +			int filter = src[4 + i * 2] >> 4; +			int f0 = s_xaTable[filter][0]; +			int f1 = s_xaTable[filter][1]; +			int16 s_1 = _adpcmStatus[0].sample[0]; +			int16 s_2 = _adpcmStatus[0].sample[1]; + +			for (int j = 0; j < 28; j++) { +				byte d = src[16 + i + j * 4]; +				int t = (int8)(d << 4) >> 4; +				int s = (t << shift) + ((s_1 * f0 + s_2 * f1 + 32) >> 6); +				s_2 = s_1; +				s_1 = CLIP<int>(s, -32768, 32767); +				*leftChannel = s_1; +				leftChannel += channels; +			} + +			if (channels == 2) { +				_adpcmStatus[0].sample[0] = s_1; +				_adpcmStatus[0].sample[1] = s_2; +				s_1 = _adpcmStatus[1].sample[0]; +				s_2 = _adpcmStatus[1].sample[1]; +			} + +			shift = 12 - (src[5 + i * 2] & 0xf); +			filter = src[5 + i * 2] >> 4; +			f0 = s_xaTable[filter][0]; +			f1 = s_xaTable[filter][1]; + +			for (int j = 0; j < 28; j++) { +				byte d = src[16 + i + j * 4]; +				int t = (int8)d >> 4; +				int s = (t << shift) + ((s_1 * f0 + s_2 * f1 + 32) >> 6); +				s_2 = s_1; +				s_1 = CLIP<int>(s, -32768, 32767); + +				if (channels == 2) { +					*rightChannel = s_1; +					rightChannel += 2; +				} else { +					*leftChannel++ = s_1; +				} +			} + +			if (channels == 2) { +				_adpcmStatus[1].sample[0] = s_1; +				_adpcmStatus[1].sample[1] = s_2; +			} else { +				_adpcmStatus[0].sample[0] = s_1; +				_adpcmStatus[0].sample[1] = s_2; +			} +		} +	} + +	int flags = Audio::FLAG_16BITS; + +	if (_audStream->isStereo()) +		flags |= Audio::FLAG_STEREO; + +#ifdef SCUMM_LITTLE_ENDIAN +	flags |= Audio::FLAG_LITTLE_ENDIAN; +#endif + +	_audStream->queueBuffer((byte *)dst, AUDIO_DATA_SAMPLE_COUNT * 2, DisposeAfterUse::YES, flags); +	delete[] buf; +} + +void PSXStreamDecoder::decodeFrame(Common::SeekableReadStream *frame) { +	// A frame is essentially an MPEG-1 intra frame + +	Common::BitStream16LEMSB bits(frame); + +	bits.skip(16); // unknown +	bits.skip(16); // 0x3800 +	uint16 scale = bits.getBits(16); +	uint16 version = bits.getBits(16); + +	if (version != 2 && version != 3) +		error("Unknown PSX stream frame version"); + +	// Initalize default v3 DC here +	_lastDC[0] = _lastDC[1] = _lastDC[2] = 0; + +	for (int mbX = 0; mbX < _macroBlocksW; mbX++) +		for (int mbY = 0; mbY < _macroBlocksH; mbY++) +			decodeMacroBlock(&bits, mbX, mbY, scale, version); + +	// Output data onto the frame +	Graphics::convertYUV420ToRGB(_surface, _yBuffer, _cbBuffer, _crBuffer, _surface->w, _surface->h, _macroBlocksW * 16, _macroBlocksW * 8); +} + +void PSXStreamDecoder::decodeMacroBlock(Common::BitStream *bits, int mbX, int mbY, uint16 scale, uint16 version) { +	int pitchY = _macroBlocksW * 16; +	int pitchC = _macroBlocksW * 8; + +	// Note the strange order of red before blue +	decodeBlock(bits, _crBuffer + (mbY * pitchC + mbX) * 8, pitchC, scale, version, kPlaneV); +	decodeBlock(bits, _cbBuffer + (mbY * pitchC + mbX) * 8, pitchC, scale, version, kPlaneU); +	decodeBlock(bits, _yBuffer + (mbY * pitchY + mbX) * 16, pitchY, scale, version, kPlaneY); +	decodeBlock(bits, _yBuffer + (mbY * pitchY + mbX) * 16 + 8, pitchY, scale, version, kPlaneY); +	decodeBlock(bits, _yBuffer + (mbY * pitchY + mbX) * 16 + 8 * pitchY, pitchY, scale, version, kPlaneY); +	decodeBlock(bits, _yBuffer + (mbY * pitchY + mbX) * 16 + 8 * pitchY + 8, pitchY, scale, version, kPlaneY); +} + +// Standard JPEG/MPEG zig zag table +static const byte s_zigZagTable[8 * 8] = { +	 0,  1,  5,  6, 14, 15, 27, 28, +	 2,  4,  7, 13, 16, 26, 29, 42, +	 3,  8, 12, 17, 25, 30, 41, 43, +	 9, 11, 18, 24, 31, 40, 44, 53, +	10, 19, 23, 32, 39, 45, 52, 54, +	20, 22, 33, 38, 46, 51, 55, 60, +	21, 34, 37, 47, 50, 56, 59, 61, +	35, 36, 48, 49, 57, 58, 62, 63 +}; + +// One byte different from the standard MPEG-1 table +static const byte s_quantizationTable[8 * 8] = { +	 2, 16, 19, 22, 26, 27, 29, 34, +	16, 16, 22, 24, 27, 29, 34, 37, +	19, 22, 26, 27, 29, 34, 34, 38, +	22, 22, 26, 27, 29, 34, 37, 40, +	22, 26, 27, 29, 32, 35, 40, 48, +	26, 27, 29, 32, 35, 40, 48, 58, +	26, 27, 29, 34, 38, 46, 56, 69, +	27, 29, 35, 38, 46, 56, 69, 83 +}; + +void PSXStreamDecoder::dequantizeBlock(int *coefficients, float *block, uint16 scale) { +	// Dequantize the data, un-zig-zagging as we go along +	for (int i = 0; i < 8 * 8; i++) { +		if (i == 0) // Special case for the DC coefficient +			block[i] = coefficients[i] * s_quantizationTable[i]; +		else +			block[i] = (float)coefficients[s_zigZagTable[i]] * s_quantizationTable[i] * scale / 8; +	} +} + +int PSXStreamDecoder::readDC(Common::BitStream *bits, uint16 version, PlaneType plane) { +	// Version 2 just has its coefficient as 10-bits +	if (version == 2) +		return readSignedCoefficient(bits); + +	// Version 3 has it stored as huffman codes as a difference from the previous DC value + +	Common::Huffman *huffman = (plane == kPlaneY) ? _dcHuffmanLuma : _dcHuffmanChroma; + +	uint32 symbol = huffman->getSymbol(*bits); +	int dc = 0; + +	if (GET_DC_BITS(symbol) != 0) { +		bool negative = (bits->getBit() == 0); +		dc = bits->getBits(GET_DC_BITS(symbol) - 1); + +		if (negative) +			dc -= GET_DC_NEG(symbol); +		else +			dc += GET_DC_POS(symbol); +	} + +	_lastDC[plane] += dc * 4; // convert from 8-bit to 10-bit +	return _lastDC[plane]; +} + +#define BLOCK_OVERFLOW_CHECK() \ +	if (count > 63) \ +		error("PSXStreamDecoder::readAC(): Too many coefficients") + +void PSXStreamDecoder::readAC(Common::BitStream *bits, int *block) { +	// Clear the block first +	for (int i = 0; i < 63; i++) +		block[i] = 0; + +	int count = 0; + +	while (!bits->eos()) { +		uint32 symbol = _acHuffman->getSymbol(*bits); + +		if (symbol == ESCAPE_CODE) { +			// The escape code! +			int zeroes = bits->getBits(6); +			count += zeroes + 1; +			BLOCK_OVERFLOW_CHECK(); +			block += zeroes; +			*block++ = readSignedCoefficient(bits); +		} else if (symbol == END_OF_BLOCK) { +			// We're done +			break; +		} else { +			// Normal huffman code +			int zeroes = GET_AC_ZERO_RUN(symbol); +			count += zeroes + 1; +			BLOCK_OVERFLOW_CHECK(); +			block += zeroes; + +			if (bits->getBit()) +				*block++ = -GET_AC_COEFFICIENT(symbol); +			else +				*block++ = GET_AC_COEFFICIENT(symbol); +		} +	} +} + +int PSXStreamDecoder::readSignedCoefficient(Common::BitStream *bits) { +	uint val = bits->getBits(10); + +	// extend the sign +	uint shift = 8 * sizeof(int) - 10; +	return (int)(val << shift) >> shift; +} + +// IDCT table built with : +// _idct8x8[x][y] = cos(((2 * x + 1) * y) * (M_PI / 16.0)) * 0.5; +// _idct8x8[x][y] /= sqrt(2.0) if y == 0 +static const double s_idct8x8[8][8] = { +	{ 0.353553390593274,  0.490392640201615,  0.461939766255643,  0.415734806151273,  0.353553390593274,  0.277785116509801,  0.191341716182545,  0.097545161008064 }, +	{ 0.353553390593274,  0.415734806151273,  0.191341716182545, -0.097545161008064, -0.353553390593274, -0.490392640201615, -0.461939766255643, -0.277785116509801 }, +	{ 0.353553390593274,  0.277785116509801, -0.191341716182545, -0.490392640201615, -0.353553390593274,  0.097545161008064,  0.461939766255643,  0.415734806151273 }, +	{ 0.353553390593274,  0.097545161008064, -0.461939766255643, -0.277785116509801,  0.353553390593274,  0.415734806151273, -0.191341716182545, -0.490392640201615 }, +	{ 0.353553390593274, -0.097545161008064, -0.461939766255643,  0.277785116509801,  0.353553390593274, -0.415734806151273, -0.191341716182545,  0.490392640201615 }, +	{ 0.353553390593274, -0.277785116509801, -0.191341716182545,  0.490392640201615, -0.353553390593273, -0.097545161008064,  0.461939766255643, -0.415734806151273 }, +	{ 0.353553390593274, -0.415734806151273,  0.191341716182545,  0.097545161008064, -0.353553390593274,  0.490392640201615, -0.461939766255643,  0.277785116509801 }, +	{ 0.353553390593274, -0.490392640201615,  0.461939766255643, -0.415734806151273,  0.353553390593273, -0.277785116509801,  0.191341716182545, -0.097545161008064 } +}; + +void PSXStreamDecoder::idct(float *dequantData, float *result) { +	// IDCT code based on JPEG's IDCT code +	// TODO: Switch to the integer-based one mentioned in the docs +	// This is by far the costliest operation here + +	float tmp[8 * 8]; + +	// Apply 1D IDCT to rows +	for (int y = 0; y < 8; y++) { +		for (int x = 0; x < 8; x++) { +			tmp[y + x * 8] = dequantData[0] * s_idct8x8[x][0] +							+ dequantData[1] * s_idct8x8[x][1] +							+ dequantData[2] * s_idct8x8[x][2] +							+ dequantData[3] * s_idct8x8[x][3] +							+ dequantData[4] * s_idct8x8[x][4] +							+ dequantData[5] * s_idct8x8[x][5] +							+ dequantData[6] * s_idct8x8[x][6] +							+ dequantData[7] * s_idct8x8[x][7]; +		} + +		dequantData += 8; +	} + +	// Apply 1D IDCT to columns +	for (int x = 0; x < 8; x++) { +		const float *u = tmp + x * 8; +		for (int y = 0; y < 8; y++) { +			result[y * 8 + x] = u[0] * s_idct8x8[y][0] +								+ u[1] * s_idct8x8[y][1] +								+ u[2] * s_idct8x8[y][2] +								+ u[3] * s_idct8x8[y][3] +								+ u[4] * s_idct8x8[y][4] +								+ u[5] * s_idct8x8[y][5] +								+ u[6] * s_idct8x8[y][6] +								+ u[7] * s_idct8x8[y][7]; +		} +	} +} + +void PSXStreamDecoder::decodeBlock(Common::BitStream *bits, byte *block, int pitch, uint16 scale, uint16 version, PlaneType plane) { +	// Version 2 just has signed 10 bits for DC +	// Version 3 has them huffman coded +	int coefficients[8 * 8]; +	coefficients[0] = readDC(bits, version, plane); +	readAC(bits, &coefficients[1]); // Read in the AC + +	// Dequantize +	float dequantData[8 * 8]; +	dequantizeBlock(coefficients, dequantData, scale); + +	// Perform IDCT +	float idctData[8 * 8]; +	idct(dequantData, idctData); + +	// Now output the data +	for (int y = 0; y < 8; y++) { +		byte *start = block + pitch * y; + +		// Convert the result to be in the range [0, 255] +		for (int x = 0; x < 8; x++) +			*start++ = (int)CLIP<float>(idctData[y * 8 + x], -128.0f, 127.0f) + 128; +	} +} + +} // End of namespace Video diff --git a/video/psx_decoder.h b/video/psx_decoder.h new file mode 100644 index 0000000000..c8ad92c45a --- /dev/null +++ b/video/psx_decoder.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. + * + */ + +#ifndef VIDEO_PSX_DECODER_H +#define VIDEO_PSX_DECODER_H + +#include "common/endian.h" +#include "common/rational.h" +#include "common/rect.h" +#include "common/str.h" +#include "graphics/surface.h" +#include "video/video_decoder.h" + +namespace Audio { +class QueuingAudioStream; +} + +namespace Common { +class BitStream; +class Huffman; +class SeekableReadStream; +} + +namespace Graphics { +struct PixelFormat; +} + +namespace Video { + +/** + * Decoder for PSX stream videos. + * This currently implements the most basic PSX stream format that is + * used by most games on the system. Special variants are not supported + * at this time. + * + * Video decoder used in engines: + *  - sword1 (psx) + *  - sword2 (psx) + */ +class PSXStreamDecoder : public VideoDecoder { +public: +	// CD speed in sectors/second +	// Calling code should use these enum values instead of the constants +	enum CDSpeed { +		kCD1x = 75, +		kCD2x = 150 +	}; + +	PSXStreamDecoder(CDSpeed speed, uint32 frameCount = 0); +	virtual ~PSXStreamDecoder(); + +	bool loadStream(Common::SeekableReadStream *stream); +	void close(); + +	bool isVideoLoaded() const { return _stream != 0; } +	uint16 getWidth() const { return _surface->w; } +	uint16 getHeight() const { return _surface->h; } +	uint32 getFrameCount() const { return _frameCount; } +	uint32 getElapsedTime() const; +	uint32 getTimeToNextFrame() const; +	const Graphics::Surface *decodeNextFrame(); +	Graphics::PixelFormat getPixelFormat() const { return _surface->format; } +	bool endOfVideo() const { return _stream->pos() >= _stream->size(); } + +private: +	void initCommon(); +	Common::SeekableReadStream *_stream; +	Graphics::Surface *_surface; + +	uint32 _frameCount; +	Audio::Timestamp _nextFrameStartTime; + +	Audio::SoundHandle _audHandle; +	Audio::QueuingAudioStream *_audStream; +	void queueAudioFromSector(Common::SeekableReadStream *sector); + +	enum PlaneType { +		kPlaneY = 0, +		kPlaneU = 1, +		kPlaneV = 2 +	}; + +	uint16 _macroBlocksW, _macroBlocksH; +	byte *_yBuffer, *_cbBuffer, *_crBuffer; +	void decodeFrame(Common::SeekableReadStream *frame); +	void decodeMacroBlock(Common::BitStream *bits, int mbX, int mbY, uint16 scale, uint16 version); +	void decodeBlock(Common::BitStream *bits, byte *block, int pitch, uint16 scale, uint16 version, PlaneType plane); + +	void readAC(Common::BitStream *bits, int *block); +	Common::Huffman *_acHuffman; + +	int readDC(Common::BitStream *bits, uint16 version, PlaneType plane); +	Common::Huffman *_dcHuffmanLuma, *_dcHuffmanChroma; +	int _lastDC[3]; + +	void dequantizeBlock(int *coefficients, float *block, uint16 scale); +	void idct(float *dequantData, float *result); +	int readSignedCoefficient(Common::BitStream *bits); + +	struct ADPCMStatus { +		int16 sample[2]; +	} _adpcmStatus[2]; + +	Common::SeekableReadStream *readSector(); +}; + +} // End of namespace Video + +#endif  | 
