2004-04-12 21:40:49 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
2005-01-01 16:20:17 +00:00
|
|
|
* Copyright (C) 2004-2005 The ScummVM project
|
2004-04-12 21:40:49 +00:00
|
|
|
*
|
|
|
|
* The ReInherit Engine is (C)2000-2003 by Daniel Balsom.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* $Header$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2004-05-01 07:32:48 +00:00
|
|
|
// Misc. graphics routines
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-06-25 21:47:37 +00:00
|
|
|
#include "saga/saga.h"
|
|
|
|
#include "saga/gfx.h"
|
2005-01-20 13:59:12 +00:00
|
|
|
#include "saga/interface.h"
|
2005-10-05 01:31:46 +00:00
|
|
|
#include "saga/resnames.h"
|
|
|
|
#include "saga/rscfile.h"
|
2005-08-13 19:41:11 +00:00
|
|
|
#include "saga/scene.h"
|
2005-10-05 01:31:46 +00:00
|
|
|
#include "saga/stream.h"
|
2004-06-25 21:47:37 +00:00
|
|
|
|
|
|
|
#include "common/system.h"
|
2004-04-12 21:40:49 +00:00
|
|
|
|
|
|
|
namespace Saga {
|
|
|
|
|
2005-07-19 19:05:52 +00:00
|
|
|
Gfx::Gfx(SagaEngine *vm, OSystem *system, int width, int height, GameDetector &detector) : _vm(vm), _system(system) {
|
2004-11-24 00:14:21 +00:00
|
|
|
_system->beginGFXTransaction();
|
|
|
|
_vm->initCommonGFX(detector);
|
|
|
|
_system->initSize(width, height);
|
|
|
|
_system->endGFXTransaction();
|
2004-05-02 00:00:39 +00:00
|
|
|
|
2005-07-05 16:58:36 +00:00
|
|
|
debug(5, "Init screen %dx%d", width, height);
|
2004-07-31 12:39:26 +00:00
|
|
|
// Convert surface data to R surface data
|
2005-07-09 16:23:45 +00:00
|
|
|
_backBuffer.create(width, height, 1);
|
2004-05-02 00:00:39 +00:00
|
|
|
|
|
|
|
// Set module data
|
2004-08-02 11:27:50 +00:00
|
|
|
_init = 1;
|
2004-05-02 15:44:19 +00:00
|
|
|
|
|
|
|
// For now, always show the mouse cursor.
|
2005-01-15 13:41:57 +00:00
|
|
|
setCursor();
|
2004-11-24 00:14:21 +00:00
|
|
|
_system->showMouse(true);
|
2004-05-02 00:00:39 +00:00
|
|
|
}
|
|
|
|
|
2005-07-09 16:23:45 +00:00
|
|
|
Gfx::~Gfx() {
|
2005-10-11 17:39:31 +00:00
|
|
|
_backBuffer.free();
|
2004-05-02 00:00:39 +00:00
|
|
|
}
|
|
|
|
|
2005-07-09 16:23:45 +00:00
|
|
|
void Surface::drawPalette() {
|
2004-04-12 21:40:49 +00:00
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
int color = 0;
|
2005-07-09 16:23:45 +00:00
|
|
|
Rect palRect;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
|
|
|
for (y = 0; y < 16; y++) {
|
2005-07-09 16:23:45 +00:00
|
|
|
palRect.top = (y * 8) + 4;
|
|
|
|
palRect.bottom = palRect.top + 8;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
|
|
|
for (x = 0; x < 16; x++) {
|
2005-07-09 16:23:45 +00:00
|
|
|
palRect.left = (x * 8) + 4;
|
|
|
|
palRect.right = palRect.left + 8;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-07-09 16:23:45 +00:00
|
|
|
drawRect(palRect, color);
|
2004-04-12 21:40:49 +00:00
|
|
|
color++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-05-01 07:32:48 +00:00
|
|
|
// * Copies a rectangle from a raw 8 bit pixel buffer to the specified surface.
|
|
|
|
// - The surface must match the logical dimensions of the buffer exactly.
|
2005-07-09 16:23:45 +00:00
|
|
|
void Surface::blit(const Common::Rect &destRect, const byte *sourceBuffer) {
|
|
|
|
const byte *readPointer;
|
|
|
|
byte *writePointer;
|
2005-07-29 17:58:00 +00:00
|
|
|
int row;
|
2005-07-09 16:23:45 +00:00
|
|
|
ClipData clipData;
|
|
|
|
|
|
|
|
clipData.sourceRect.left = 0;
|
|
|
|
clipData.sourceRect.top = 0;
|
|
|
|
clipData.sourceRect.right = destRect.width();
|
|
|
|
clipData.sourceRect.bottom = destRect.height();
|
|
|
|
|
|
|
|
clipData.destPoint.x = destRect.left;
|
|
|
|
clipData.destPoint.y = destRect.top;
|
|
|
|
clipData.destRect.left = 0;
|
|
|
|
clipData.destRect.right = w;
|
|
|
|
clipData.destRect.top = 0;
|
|
|
|
clipData.destRect.bottom = h;
|
2005-07-29 17:58:00 +00:00
|
|
|
|
2005-07-09 16:23:45 +00:00
|
|
|
if (!clipData.calcClip()) {
|
|
|
|
return;
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
2005-07-29 17:58:00 +00:00
|
|
|
|
2004-05-01 07:32:48 +00:00
|
|
|
// Transfer buffer data to surface
|
2005-07-29 17:58:00 +00:00
|
|
|
readPointer = (sourceBuffer + clipData.drawSource.x) +
|
2005-07-09 16:23:45 +00:00
|
|
|
(clipData.sourceRect.right * clipData.drawSource.y);
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-07-09 16:23:45 +00:00
|
|
|
writePointer = ((byte *)pixels + clipData.drawDest.x) + (pitch * clipData.drawDest.y);
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-07-09 16:23:45 +00:00
|
|
|
for (row = 0; row < clipData.drawHeight; row++) {
|
|
|
|
memcpy(writePointer, readPointer, clipData.drawWidth);
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-07-09 16:23:45 +00:00
|
|
|
writePointer += pitch;
|
|
|
|
readPointer += clipData.sourceRect.right;
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-07-09 16:23:45 +00:00
|
|
|
void Surface::drawPolyLine(const Point *points, int count, int color) {
|
|
|
|
int i;
|
|
|
|
if (count >= 3) {
|
|
|
|
for (i = 1; i < count; i++) {
|
|
|
|
drawLine(points[i].x, points[i].y, points[i - 1].x, points[i - 1].y, color);
|
|
|
|
}
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-07-09 16:23:45 +00:00
|
|
|
drawLine(points[count - 1].x, points[count - 1].y, points->x, points->y, color);
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-07-09 17:11:41 +00:00
|
|
|
/**
|
|
|
|
* Dissolve one image with another.
|
|
|
|
* If flags if set to 1, do zero masking.
|
|
|
|
*/
|
|
|
|
void Surface::transitionDissolve(const byte *sourceBuffer, const Common::Rect &sourceRect, int flags, double percent) {
|
|
|
|
#define XOR_MASK 0xB400;
|
|
|
|
int pixelcount = w * h;
|
|
|
|
int seqlimit = (int)(65535 * percent);
|
|
|
|
int seq = 1;
|
|
|
|
int i, x1, y1;
|
|
|
|
byte color;
|
|
|
|
|
|
|
|
for (i = 0; i < seqlimit; i++) {
|
|
|
|
if (seq & 1) {
|
|
|
|
seq = (seq >> 1) ^ XOR_MASK;
|
|
|
|
} else {
|
|
|
|
seq = seq >> 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (seq == 1) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (seq >= pixelcount) {
|
|
|
|
continue;
|
|
|
|
} else {
|
|
|
|
x1 = seq % w;
|
|
|
|
y1 = seq / w;
|
|
|
|
|
|
|
|
if (sourceRect.contains(x1, y1)) {
|
|
|
|
color = sourceBuffer[(x1-sourceRect.left) + sourceRect.width()*(y1-sourceRect.top)];
|
|
|
|
if (flags == 0 || color)
|
|
|
|
((byte*)pixels)[seq] = color;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-10-05 01:31:46 +00:00
|
|
|
void Gfx::initPalette() {
|
|
|
|
if(_vm->getGameType() != GType_IHNM)
|
|
|
|
return;
|
|
|
|
|
|
|
|
ResourceContext *resourceContext = _vm->_resource->getContext(GAME_RESOURCEFILE);
|
|
|
|
if (resourceContext == NULL) {
|
|
|
|
error("Resource::loadGlobalResources() resource context not found");
|
|
|
|
}
|
|
|
|
|
|
|
|
byte *resourcePointer;
|
|
|
|
size_t resourceLength;
|
|
|
|
|
|
|
|
_vm->_resource->loadResource(resourceContext, RID_IHNM_DEFAULT_PALETTE,
|
|
|
|
resourcePointer, resourceLength);
|
|
|
|
|
|
|
|
MemoryReadStream metaS(resourcePointer, resourceLength);
|
|
|
|
|
|
|
|
for(int i = 0; i < 256; i++) {
|
|
|
|
_globalPalette[i].red = metaS.readByte();
|
|
|
|
_globalPalette[i].green = metaS.readByte();
|
|
|
|
_globalPalette[i].blue = metaS.readByte();
|
|
|
|
}
|
|
|
|
|
|
|
|
free(resourcePointer);
|
|
|
|
|
2005-10-05 01:40:55 +00:00
|
|
|
setPalette(_globalPalette, true);
|
2005-10-05 01:31:46 +00:00
|
|
|
}
|
|
|
|
|
2005-10-05 01:40:55 +00:00
|
|
|
void Gfx::setPalette(const PalEntry *pal, bool full) {
|
2004-05-02 00:00:39 +00:00
|
|
|
int i;
|
|
|
|
byte *ppal;
|
2005-10-05 01:40:55 +00:00
|
|
|
int from, numcolors;
|
|
|
|
|
|
|
|
if (_vm->getGameType() != GType_IHNM || full) {
|
|
|
|
from = 0;
|
|
|
|
numcolors = PAL_ENTRIES;
|
|
|
|
} else {
|
2005-10-05 02:01:52 +00:00
|
|
|
from = 0;
|
|
|
|
numcolors = 248;
|
2005-10-05 01:40:55 +00:00
|
|
|
}
|
2004-05-02 00:00:39 +00:00
|
|
|
|
2005-10-05 01:31:46 +00:00
|
|
|
for (i = 0, ppal = &_currentPal[from * 4]; i < numcolors; i++, ppal += 4) {
|
|
|
|
ppal[0] = _globalPalette[i].red = pal[i].red;
|
|
|
|
ppal[1] = _globalPalette[i].green = pal[i].green;
|
|
|
|
ppal[2] = _globalPalette[i].blue = pal[i].blue;
|
2004-05-02 00:00:39 +00:00
|
|
|
ppal[3] = 0;
|
|
|
|
}
|
|
|
|
|
2005-08-11 19:11:15 +00:00
|
|
|
// Make 256th color black. See bug #1256368
|
2005-08-13 19:41:11 +00:00
|
|
|
if (_vm->getFeatures() & GF_MAC_RESOURCES && !_vm->_scene->isInIntro())
|
2005-08-11 19:11:15 +00:00
|
|
|
memset(&_currentPal[255 * 4], 0, 4);
|
|
|
|
|
2005-07-09 16:23:45 +00:00
|
|
|
_system->setPalette(_currentPal, 0, PAL_ENTRIES);
|
2004-05-02 00:00:39 +00:00
|
|
|
}
|
|
|
|
|
2005-10-04 17:44:41 +00:00
|
|
|
void Gfx::setPaletteColor(int n, int r, int g, int b) {
|
2005-10-04 18:19:14 +00:00
|
|
|
bool update = false;
|
2005-10-04 17:44:41 +00:00
|
|
|
|
2005-10-04 18:19:14 +00:00
|
|
|
// This function may get called a lot. To avoid forcing full-screen
|
|
|
|
// updates, only update the palette if the color actually changes.
|
|
|
|
|
|
|
|
if (_currentPal[4 * n + 0] != r) {
|
2005-10-05 01:31:46 +00:00
|
|
|
_currentPal[4 * n + 0] = _globalPalette[n].red = r;
|
2005-10-04 18:19:14 +00:00
|
|
|
update = true;
|
|
|
|
}
|
|
|
|
if (_currentPal[4 * n + 1] != g) {
|
2005-10-05 01:31:46 +00:00
|
|
|
_currentPal[4 * n + 1] = _globalPalette[n].green = g;
|
2005-10-04 18:19:14 +00:00
|
|
|
update = true;
|
|
|
|
}
|
|
|
|
if (_currentPal[4 * n + 2] != b) {
|
2005-10-05 01:31:46 +00:00
|
|
|
_currentPal[4 * n + 2] = _globalPalette[n].blue = b;
|
2005-10-04 18:19:14 +00:00
|
|
|
update = true;
|
|
|
|
}
|
|
|
|
if (_currentPal[4 * n + 3] != 0) {
|
|
|
|
_currentPal[4 * n + 3] = 0;
|
|
|
|
update = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (update)
|
|
|
|
_system->setPalette(_currentPal, n, 1);
|
2005-10-04 17:44:41 +00:00
|
|
|
}
|
|
|
|
|
2005-07-09 16:23:45 +00:00
|
|
|
void Gfx::getCurrentPal(PalEntry *src_pal) {
|
2004-05-02 00:00:39 +00:00
|
|
|
int i;
|
|
|
|
byte *ppal;
|
|
|
|
|
2005-07-09 16:23:45 +00:00
|
|
|
for (i = 0, ppal = _currentPal; i < PAL_ENTRIES; i++, ppal += 4) {
|
2004-05-02 00:00:39 +00:00
|
|
|
src_pal[i].red = ppal[0];
|
|
|
|
src_pal[i].green = ppal[1];
|
|
|
|
src_pal[i].blue = ppal[2];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-10-05 01:40:55 +00:00
|
|
|
void Gfx::palToBlack(PalEntry *srcPal, double percent) {
|
2004-05-02 00:00:39 +00:00
|
|
|
int i;
|
|
|
|
//int fade_max = 255;
|
|
|
|
int new_entry;
|
|
|
|
byte *ppal;
|
2005-10-05 01:31:46 +00:00
|
|
|
PalEntry *palE;
|
2005-10-05 01:40:55 +00:00
|
|
|
int from, numcolors;
|
2004-05-02 00:00:39 +00:00
|
|
|
|
|
|
|
double fpercent;
|
|
|
|
|
2005-10-05 01:40:55 +00:00
|
|
|
if (_vm->getGameType() != GType_IHNM) {
|
|
|
|
from = 0;
|
|
|
|
numcolors = PAL_ENTRIES;
|
|
|
|
} else {
|
2005-10-05 02:01:52 +00:00
|
|
|
from = 0;
|
|
|
|
numcolors = 248;
|
2005-10-05 01:40:55 +00:00
|
|
|
}
|
|
|
|
|
2004-05-02 00:00:39 +00:00
|
|
|
if (percent > 1.0) {
|
|
|
|
percent = 1.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Exponential fade
|
|
|
|
fpercent = percent * percent;
|
|
|
|
|
|
|
|
fpercent = 1.0 - fpercent;
|
|
|
|
|
2005-07-29 17:58:00 +00:00
|
|
|
// Use the correct percentage change per frame for each palette entry
|
2005-07-09 16:23:45 +00:00
|
|
|
for (i = 0, ppal = _currentPal; i < PAL_ENTRIES; i++, ppal += 4) {
|
2005-10-05 01:31:46 +00:00
|
|
|
if (i < from || i >= from + numcolors)
|
|
|
|
palE = &_globalPalette[i];
|
|
|
|
else
|
|
|
|
palE = &srcPal[i];
|
|
|
|
|
|
|
|
new_entry = (int)(palE->red * fpercent);
|
2004-05-02 00:00:39 +00:00
|
|
|
|
|
|
|
if (new_entry < 0) {
|
|
|
|
ppal[0] = 0;
|
|
|
|
} else {
|
|
|
|
ppal[0] = (byte) new_entry;
|
|
|
|
}
|
|
|
|
|
2005-10-05 01:31:46 +00:00
|
|
|
new_entry = (int)(palE->green * fpercent);
|
2004-05-02 00:00:39 +00:00
|
|
|
|
|
|
|
if (new_entry < 0) {
|
|
|
|
ppal[1] = 0;
|
|
|
|
} else {
|
|
|
|
ppal[1] = (byte) new_entry;
|
|
|
|
}
|
|
|
|
|
2005-10-05 01:31:46 +00:00
|
|
|
new_entry = (int)(palE->blue * fpercent);
|
2004-05-02 00:00:39 +00:00
|
|
|
|
|
|
|
if (new_entry < 0) {
|
|
|
|
ppal[2] = 0;
|
|
|
|
} else {
|
|
|
|
ppal[2] = (byte) new_entry;
|
|
|
|
}
|
|
|
|
ppal[3] = 0;
|
|
|
|
}
|
|
|
|
|
2005-08-11 19:11:15 +00:00
|
|
|
// Make 256th color black. See bug #1256368
|
2005-08-13 19:41:11 +00:00
|
|
|
if (_vm->getFeatures() & GF_MAC_RESOURCES && !_vm->_scene->isInIntro())
|
2005-08-11 19:11:15 +00:00
|
|
|
memset(&_currentPal[255 * 4], 0, 4);
|
|
|
|
|
2005-07-09 16:23:45 +00:00
|
|
|
_system->setPalette(_currentPal, 0, PAL_ENTRIES);
|
2004-05-02 00:00:39 +00:00
|
|
|
}
|
|
|
|
|
2005-10-05 01:40:55 +00:00
|
|
|
void Gfx::blackToPal(PalEntry *srcPal, double percent) {
|
2004-05-02 00:00:39 +00:00
|
|
|
int new_entry;
|
|
|
|
double fpercent;
|
|
|
|
byte *ppal;
|
|
|
|
int i;
|
2005-10-05 01:31:46 +00:00
|
|
|
PalEntry *palE;
|
2005-10-05 01:40:55 +00:00
|
|
|
int from, numcolors;
|
|
|
|
|
|
|
|
if (_vm->getGameType() != GType_IHNM) {
|
|
|
|
from = 0;
|
|
|
|
numcolors = PAL_ENTRIES;
|
|
|
|
} else {
|
2005-10-05 02:01:52 +00:00
|
|
|
from = 0;
|
|
|
|
numcolors = 248;
|
2005-10-05 01:40:55 +00:00
|
|
|
}
|
2004-05-02 00:00:39 +00:00
|
|
|
|
|
|
|
if (percent > 1.0) {
|
|
|
|
percent = 1.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Exponential fade
|
|
|
|
fpercent = percent * percent;
|
|
|
|
|
|
|
|
fpercent = 1.0 - fpercent;
|
|
|
|
|
|
|
|
// Use the correct percentage change per frame for each palette entry
|
2005-07-09 16:23:45 +00:00
|
|
|
for (i = 0, ppal = _currentPal; i < PAL_ENTRIES; i++, ppal += 4) {
|
2005-10-05 01:31:46 +00:00
|
|
|
if (i < from || i >= from + numcolors)
|
|
|
|
palE = &_globalPalette[i];
|
|
|
|
else
|
|
|
|
palE = &srcPal[i];
|
|
|
|
|
|
|
|
new_entry = (int)(palE->red - palE->red * fpercent);
|
2004-05-02 00:00:39 +00:00
|
|
|
|
|
|
|
if (new_entry < 0) {
|
|
|
|
ppal[0] = 0;
|
|
|
|
} else {
|
2005-10-05 01:31:46 +00:00
|
|
|
ppal[0] = (byte)new_entry;
|
2004-05-02 00:00:39 +00:00
|
|
|
}
|
|
|
|
|
2005-10-05 01:31:46 +00:00
|
|
|
new_entry = (int)(palE->green - palE->green * fpercent);
|
2004-05-02 00:00:39 +00:00
|
|
|
|
|
|
|
if (new_entry < 0) {
|
|
|
|
ppal[1] = 0;
|
|
|
|
} else {
|
|
|
|
ppal[1] = (byte) new_entry;
|
|
|
|
}
|
|
|
|
|
2005-10-05 01:31:46 +00:00
|
|
|
new_entry = (int)(palE->blue - palE->blue * fpercent);
|
2004-05-02 00:00:39 +00:00
|
|
|
|
|
|
|
if (new_entry < 0) {
|
|
|
|
ppal[2] = 0;
|
|
|
|
} else {
|
|
|
|
ppal[2] = (byte) new_entry;
|
|
|
|
}
|
|
|
|
ppal[3] = 0;
|
|
|
|
}
|
|
|
|
|
2005-08-11 19:11:15 +00:00
|
|
|
// Make 256th color black. See bug #1256368
|
2005-08-13 19:41:11 +00:00
|
|
|
if (_vm->getFeatures() & GF_MAC_RESOURCES && !_vm->_scene->isInIntro())
|
2005-08-11 19:11:15 +00:00
|
|
|
memset(&_currentPal[255 * 4], 0, 4);
|
|
|
|
|
2005-07-09 16:23:45 +00:00
|
|
|
_system->setPalette(_currentPal, 0, PAL_ENTRIES);
|
2004-05-02 00:00:39 +00:00
|
|
|
}
|
|
|
|
|
2004-11-20 00:05:50 +00:00
|
|
|
void Gfx::showCursor(bool state) {
|
|
|
|
updateCursor();
|
|
|
|
g_system->showMouse(state);
|
|
|
|
}
|
|
|
|
|
2005-10-09 19:10:59 +00:00
|
|
|
void Gfx::setCursor(CursorType cursorType) {
|
|
|
|
if (_vm->getGameType() == GType_ITE) {
|
|
|
|
// Set up the mouse cursor
|
|
|
|
const byte A = kITEColorLightGrey;
|
|
|
|
const byte B = kITEColorWhite;
|
|
|
|
|
|
|
|
const byte cursor_img[CURSOR_W * CURSOR_H] = {
|
|
|
|
0, 0, 0, A, 0, 0, 0,
|
|
|
|
0, 0, 0, A, 0, 0, 0,
|
|
|
|
0, 0, 0, A, 0, 0, 0,
|
|
|
|
A, A, A, B, A, A, A,
|
|
|
|
0, 0, 0, A, 0, 0, 0,
|
|
|
|
0, 0, 0, A, 0, 0, 0,
|
|
|
|
0, 0, 0, A, 0, 0, 0,
|
|
|
|
};
|
|
|
|
|
|
|
|
_system->setMouseCursor(cursor_img, CURSOR_W, CURSOR_H, 3, 3, 0);
|
|
|
|
} else {
|
|
|
|
uint32 resourceId;
|
|
|
|
|
|
|
|
switch (cursorType) {
|
|
|
|
case kCursorBusy:
|
|
|
|
resourceId = RID_IHNM_HOURGLASS_CURSOR;
|
|
|
|
break;
|
|
|
|
default:
|
2005-10-09 19:43:15 +00:00
|
|
|
resourceId = (uint32)-1;
|
2005-10-09 19:10:59 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
byte *resource;
|
|
|
|
size_t resourceLength;
|
|
|
|
byte *image;
|
|
|
|
size_t imageLength;
|
|
|
|
int width, height;
|
|
|
|
|
2005-10-09 19:43:15 +00:00
|
|
|
if (resourceId != (uint32)-1) {
|
|
|
|
ResourceContext *context = _vm->_resource->getContext(GAME_RESOURCEFILE);
|
|
|
|
|
|
|
|
_vm->_resource->loadResource(context, resourceId, resource, resourceLength);
|
2005-10-09 19:10:59 +00:00
|
|
|
|
2005-10-09 19:43:15 +00:00
|
|
|
_vm->decodeBGImage(resource, resourceLength, &image, &imageLength, &width, &height);
|
|
|
|
} else {
|
|
|
|
resource = NULL;
|
|
|
|
width = height = 31;
|
|
|
|
image = (byte *)calloc(width, height);
|
|
|
|
|
|
|
|
for (int i = 0; i < 14; i++) {
|
|
|
|
image[15 * 31 + i] = 1;
|
|
|
|
image[15 * 31 + 30 - i] = 1;
|
|
|
|
image[i * 31 + 15] = 1;
|
|
|
|
image[(30 - i) * 31 + 15] = 1;
|
|
|
|
}
|
|
|
|
}
|
2005-10-09 19:10:59 +00:00
|
|
|
|
2005-10-09 19:43:15 +00:00
|
|
|
// Note: Hard-coded hotspot
|
|
|
|
_system->setMouseCursor(image, width, height, 15, 15, 0);
|
2005-10-09 19:10:59 +00:00
|
|
|
|
|
|
|
free(image);
|
|
|
|
free(resource);
|
|
|
|
}
|
2004-05-02 16:32:28 +00:00
|
|
|
}
|
|
|
|
|
2004-10-30 22:34:08 +00:00
|
|
|
bool hitTestPoly(const Point *points, unsigned int npoints, const Point& test_point) {
|
2004-10-08 01:22:39 +00:00
|
|
|
int yflag0;
|
|
|
|
int yflag1;
|
|
|
|
bool inside_flag = false;
|
|
|
|
unsigned int pt;
|
|
|
|
|
2004-10-08 19:58:49 +00:00
|
|
|
const Point *vtx0 = &points[npoints - 1];
|
|
|
|
const Point *vtx1 = &points[0];
|
2004-10-08 01:22:39 +00:00
|
|
|
|
|
|
|
yflag0 = (vtx0->y >= test_point.y);
|
|
|
|
for (pt = 0; pt < npoints; pt++, vtx1++) {
|
|
|
|
yflag1 = (vtx1->y >= test_point.y);
|
|
|
|
if (yflag0 != yflag1) {
|
|
|
|
if (((vtx1->y - test_point.y) * (vtx0->x - vtx1->x) >=
|
|
|
|
(vtx1->x - test_point.x) * (vtx0->y - vtx1->y)) == yflag1) {
|
|
|
|
inside_flag = !inside_flag;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
yflag0 = yflag1;
|
|
|
|
vtx0 = vtx1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return inside_flag;
|
|
|
|
}
|
|
|
|
|
2004-04-12 21:40:49 +00:00
|
|
|
} // End of namespace Saga
|