mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-15 06:08:35 +00:00
TOLTECS: Fixed tabs and formatting.
This commit is contained in:
parent
7c2835313e
commit
f4e156b3b3
@ -39,7 +39,7 @@
|
||||
namespace Toltecs {
|
||||
|
||||
AnimationPlayer::AnimationPlayer(ToltecsEngine *vm) : _vm(vm) {
|
||||
_animBuffer = new byte[262144];
|
||||
_animBuffer = new byte[262144];
|
||||
}
|
||||
|
||||
AnimationPlayer::~AnimationPlayer() {
|
||||
@ -64,7 +64,7 @@ void AnimationPlayer::start(uint resIndex) {
|
||||
|
||||
debug(1, "AnimationPlayer::start() width = %d; height = %d; frameCount = %d", _width, _height, _frameCount);
|
||||
|
||||
unpackFrame();
|
||||
unpackFrame();
|
||||
|
||||
_keepFrameCounter = 0;
|
||||
_frameNumber = 0;
|
||||
@ -92,8 +92,8 @@ void AnimationPlayer::nextFrame() {
|
||||
debug(1, "AnimationPlayer::nextFrame() frameNumber = %d", _frameNumber);
|
||||
|
||||
if (_keepFrameCounter > 0) {
|
||||
_keepFrameCounter--;
|
||||
return;
|
||||
_keepFrameCounter--;
|
||||
return;
|
||||
}
|
||||
|
||||
_vm->_arc->openResource(_resIndex);
|
||||
@ -101,18 +101,18 @@ void AnimationPlayer::nextFrame() {
|
||||
_curFrameSize = _nextFrameSize;
|
||||
|
||||
if (_curFrameSize == 0)
|
||||
_curFrameSize = 1;
|
||||
_curFrameSize = 1;
|
||||
|
||||
_vm->_arc->read(_animBuffer, _curFrameSize);
|
||||
_nextFrameSize = _vm->_arc->readUint32LE();
|
||||
_nextFrameOffset += _curFrameSize + 4;
|
||||
|
||||
if (_curFrameSize > 1) {
|
||||
unpackFrame();
|
||||
// TODO mov animDrawFrameFlag, 0FFFFh
|
||||
unpackFrame();
|
||||
// TODO mov animDrawFrameFlag, 0FFFFh
|
||||
} else {
|
||||
_keepFrameCounter = _animBuffer[0] - 1;
|
||||
// TODO mov animDrawFrameFlag, 0
|
||||
_keepFrameCounter = _animBuffer[0] - 1;
|
||||
// TODO mov animDrawFrameFlag, 0
|
||||
}
|
||||
|
||||
_vm->_arc->closeResource();
|
||||
@ -124,16 +124,16 @@ int16 AnimationPlayer::getStatus() {
|
||||
debug(1, "AnimationPlayer::getStatus()");
|
||||
int16 status = -1;
|
||||
if (_frameNumber == _frameCount)
|
||||
status = 0;
|
||||
status = 0;
|
||||
else if (_frameNumber == _frameCount - 1)
|
||||
status = 1;
|
||||
status = 1;
|
||||
debug(1, "AnimationPlayer::getStatus() status = %d", status);
|
||||
return status;
|
||||
}
|
||||
|
||||
void AnimationPlayer::unpackFrame() {
|
||||
_vm->_screen->unpackRle(_animBuffer, _vm->_screen->_frontScreen, _width, _height);
|
||||
_vm->_screen->unpackRle(_animBuffer, _vm->_screen->_backScreen, _width, _height);
|
||||
_vm->_screen->unpackRle(_animBuffer, _vm->_screen->_frontScreen, _width, _height);
|
||||
_vm->_screen->unpackRle(_animBuffer, _vm->_screen->_backScreen, _width, _height);
|
||||
}
|
||||
|
||||
} // End of namespace Toltecs
|
||||
|
@ -49,23 +49,23 @@ namespace Toltecs {
|
||||
|
||||
class AnimationPlayer {
|
||||
public:
|
||||
AnimationPlayer(ToltecsEngine *vm);
|
||||
~AnimationPlayer();
|
||||
|
||||
void start(uint resIndex);
|
||||
void nextFrame();
|
||||
int16 getStatus();
|
||||
uint16 getFrameNumber() const { return _frameNumber; }
|
||||
|
||||
AnimationPlayer(ToltecsEngine *vm);
|
||||
~AnimationPlayer();
|
||||
|
||||
void start(uint resIndex);
|
||||
void nextFrame();
|
||||
int16 getStatus();
|
||||
uint16 getFrameNumber() const { return _frameNumber; }
|
||||
|
||||
//protected:
|
||||
public:
|
||||
ToltecsEngine *_vm;
|
||||
ToltecsEngine *_vm;
|
||||
|
||||
// 262144
|
||||
byte *_animBuffer;
|
||||
|
||||
uint _resIndex;
|
||||
byte _palette[768];
|
||||
byte *_animBuffer;
|
||||
|
||||
uint _resIndex;
|
||||
byte _palette[768];
|
||||
|
||||
uint16 _width, _height;
|
||||
uint16 _frameNumber, _frameCount;
|
||||
|
@ -47,11 +47,11 @@ Input::Input(ToltecsEngine *vm) : _vm(vm) {
|
||||
_mouseCounter = 0;
|
||||
_mouseButtonPressedFlag = false;
|
||||
_mouseButton = 0;
|
||||
_mouseDisabled = 0;
|
||||
_mouseDisabled = 0;
|
||||
|
||||
_leftButtonDown = false;
|
||||
_leftButtonDown = false;
|
||||
_rightButtonDown = false;
|
||||
|
||||
|
||||
}
|
||||
|
||||
Input::~Input() {
|
||||
@ -73,22 +73,22 @@ void Input::update() {
|
||||
case Common::EVENT_LBUTTONDOWN:
|
||||
_mouseX = event.mouse.x;
|
||||
_mouseY = event.mouse.y;
|
||||
_leftButtonDown = true;
|
||||
_leftButtonDown = true;
|
||||
break;
|
||||
case Common::EVENT_LBUTTONUP:
|
||||
_mouseX = event.mouse.x;
|
||||
_mouseY = event.mouse.y;
|
||||
_leftButtonDown = false;
|
||||
_leftButtonDown = false;
|
||||
break;
|
||||
case Common::EVENT_RBUTTONDOWN:
|
||||
_mouseX = event.mouse.x;
|
||||
_mouseY = event.mouse.y;
|
||||
_rightButtonDown = true;
|
||||
_rightButtonDown = true;
|
||||
break;
|
||||
case Common::EVENT_RBUTTONUP:
|
||||
_mouseX = event.mouse.x;
|
||||
_mouseY = event.mouse.y;
|
||||
_rightButtonDown = false;
|
||||
_rightButtonDown = false;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -99,27 +99,27 @@ void Input::update() {
|
||||
_mousePosDelta = _mousePosDelta + _mouseY - _mouseX;
|
||||
|
||||
if (_mouseCounter > 0)
|
||||
_mouseCounter--;
|
||||
|
||||
_mouseCounter--;
|
||||
|
||||
byte mouseButtons = 0;
|
||||
if (_leftButtonDown)
|
||||
mouseButtons |= 1;
|
||||
mouseButtons |= 1;
|
||||
if (_rightButtonDown)
|
||||
mouseButtons |= 2;
|
||||
|
||||
mouseButtons |= 2;
|
||||
|
||||
if (mouseButtons != 0) {
|
||||
if (!_mouseButtonPressedFlag) {
|
||||
_mouseButton = mouseButtons;
|
||||
if (_mouseCounter != 0)
|
||||
_mouseButton |= 0x80;
|
||||
_mouseButton = mouseButtons;
|
||||
if (_mouseCounter != 0)
|
||||
_mouseButton |= 0x80;
|
||||
_mouseCounter = 30; // maybe TODO
|
||||
_mouseButtonPressedFlag = true;
|
||||
} else {
|
||||
_mouseButton = 0;
|
||||
_mouseButton = 0;
|
||||
}
|
||||
} else {
|
||||
_mouseButtonPressedFlag = false;
|
||||
_mouseButton = 0;
|
||||
_mouseButtonPressedFlag = false;
|
||||
_mouseButton = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -46,8 +46,8 @@ namespace Toltecs {
|
||||
|
||||
class Input {
|
||||
public:
|
||||
Input(ToltecsEngine *vm);
|
||||
~Input();
|
||||
Input(ToltecsEngine *vm);
|
||||
~Input();
|
||||
|
||||
void update();
|
||||
|
||||
@ -58,7 +58,7 @@ public:
|
||||
|
||||
//protected:
|
||||
public:
|
||||
ToltecsEngine *_vm;
|
||||
ToltecsEngine *_vm;
|
||||
|
||||
int16 _mouseX, _mouseY;
|
||||
int16 _mousePosDelta;
|
||||
|
@ -50,13 +50,13 @@ Palette::~Palette() {
|
||||
void Palette::setFullPalette(byte *palette) {
|
||||
byte colors[1024];
|
||||
for (int i = 0; i < 256; i++) {
|
||||
colors[i * 4 + 0] = palette[i * 3 + 0] << 2;
|
||||
colors[i * 4 + 1] = palette[i * 3 + 1] << 2;
|
||||
colors[i * 4 + 2] = palette[i * 3 + 2] << 2;
|
||||
colors[i * 4 + 3] = 255;
|
||||
colors[i * 4 + 0] = palette[i * 3 + 0] << 2;
|
||||
colors[i * 4 + 1] = palette[i * 3 + 1] << 2;
|
||||
colors[i * 4 + 2] = palette[i * 3 + 2] << 2;
|
||||
colors[i * 4 + 3] = 255;
|
||||
}
|
||||
_vm->_system->setPalette((const byte *)colors, 0, 256);
|
||||
_vm->_system->updateScreen();
|
||||
_vm->_system->setPalette((const byte *)colors, 0, 256);
|
||||
_vm->_system->updateScreen();
|
||||
}
|
||||
|
||||
void Palette::setDeltaPalette(byte *palette, byte mask, char deltaValue, int16 count, int16 startIndex) {
|
||||
@ -74,32 +74,32 @@ void Palette::setDeltaPalette(byte *palette, byte mask, char deltaValue, int16 c
|
||||
_vm->_system->grabPalette(colors, 0, 256);
|
||||
|
||||
if (deltaValue < 0) {
|
||||
deltaValue = -deltaValue;
|
||||
while (count--) {
|
||||
rgb = *palPtr++;
|
||||
if (mask & 1) colors[index * 4 + 0] = CLIP<int>(rgb + deltaValue, 0, 63) << 2;
|
||||
rgb = *palPtr++;
|
||||
if (mask & 2) colors[index * 4 + 1] = CLIP<int>(rgb + deltaValue, 0, 63) << 2;
|
||||
rgb = *palPtr++;
|
||||
if (mask & 4) colors[index * 4 + 2] = CLIP<int>(rgb + deltaValue, 0, 63) << 2;
|
||||
index++;
|
||||
deltaValue = -deltaValue;
|
||||
while (count--) {
|
||||
rgb = *palPtr++;
|
||||
if (mask & 1) colors[index * 4 + 0] = CLIP<int>(rgb + deltaValue, 0, 63) << 2;
|
||||
rgb = *palPtr++;
|
||||
if (mask & 2) colors[index * 4 + 1] = CLIP<int>(rgb + deltaValue, 0, 63) << 2;
|
||||
rgb = *palPtr++;
|
||||
if (mask & 4) colors[index * 4 + 2] = CLIP<int>(rgb + deltaValue, 0, 63) << 2;
|
||||
index++;
|
||||
}
|
||||
} else {
|
||||
while (count--) {
|
||||
rgb = *palPtr++;
|
||||
if (mask & 1) colors[index * 4 + 0] = CLIP<int>(rgb - deltaValue, deltaValue, 255) << 2;
|
||||
rgb = *palPtr++;
|
||||
if (mask & 2) colors[index * 4 + 1] = CLIP<int>(rgb - deltaValue, deltaValue, 255) << 2;
|
||||
rgb = *palPtr++;
|
||||
if (mask & 4) colors[index * 4 + 2] = CLIP<int>(rgb - deltaValue, deltaValue, 255) << 2;
|
||||
index++;
|
||||
while (count--) {
|
||||
rgb = *palPtr++;
|
||||
if (mask & 1) colors[index * 4 + 0] = CLIP<int>(rgb - deltaValue, deltaValue, 255) << 2;
|
||||
rgb = *palPtr++;
|
||||
if (mask & 2) colors[index * 4 + 1] = CLIP<int>(rgb - deltaValue, deltaValue, 255) << 2;
|
||||
rgb = *palPtr++;
|
||||
if (mask & 4) colors[index * 4 + 2] = CLIP<int>(rgb - deltaValue, deltaValue, 255) << 2;
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
debug(0, "startIndex = %d; colorCount = %d", startIndex, colorCount);
|
||||
|
||||
_vm->_system->setPalette((const byte *)colors, 0, 256);
|
||||
|
||||
_vm->_system->setPalette((const byte *)colors, 0, 256);
|
||||
|
||||
}
|
||||
|
||||
void Palette::loadAddPalette(uint resIndex, byte startIndex) {
|
||||
@ -136,10 +136,10 @@ uint16 Palette::findFragment(int16 id) {
|
||||
|
||||
uint16 result = 0;
|
||||
for (PaletteFragmentArray::iterator iter = _fragments.begin(); iter != _fragments.end(); iter++) {
|
||||
PaletteFragment fragment = *iter;
|
||||
if (fragment.id == id) {
|
||||
result = (fragment.count << 8) | fragment.index;
|
||||
break;
|
||||
PaletteFragment fragment = *iter;
|
||||
if (fragment.id == id) {
|
||||
result = (fragment.count << 8) | fragment.index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -49,37 +49,37 @@ namespace Toltecs {
|
||||
|
||||
class Palette {
|
||||
public:
|
||||
Palette(ToltecsEngine *vm);
|
||||
~Palette();
|
||||
Palette(ToltecsEngine *vm);
|
||||
~Palette();
|
||||
|
||||
void setFullPalette(byte *palette);
|
||||
void setDeltaPalette(byte *palette, byte mask, char deltaValue, int16 count, int16 startIndex);
|
||||
|
||||
void loadAddPalette(uint resIndex, byte startIndex);
|
||||
void loadAddPaletteFrom(byte *source, byte startIndex, byte count);
|
||||
|
||||
void addFragment(uint resIndex, int16 id);
|
||||
uint16 findFragment(int16 id);
|
||||
void clearFragments();
|
||||
|
||||
byte *getMainPalette() { return _mainPalette; }
|
||||
|
||||
void loadAddPalette(uint resIndex, byte startIndex);
|
||||
void loadAddPaletteFrom(byte *source, byte startIndex, byte count);
|
||||
|
||||
void addFragment(uint resIndex, int16 id);
|
||||
uint16 findFragment(int16 id);
|
||||
void clearFragments();
|
||||
|
||||
byte *getMainPalette() { return _mainPalette; }
|
||||
|
||||
protected:
|
||||
|
||||
struct PaletteFragment {
|
||||
int16 id;
|
||||
byte index, count;
|
||||
int16 id;
|
||||
byte index, count;
|
||||
};
|
||||
|
||||
typedef Common::Array<PaletteFragment> PaletteFragmentArray;
|
||||
|
||||
ToltecsEngine *_vm;
|
||||
|
||||
byte _mainPalette[768];
|
||||
|
||||
ToltecsEngine *_vm;
|
||||
|
||||
byte _mainPalette[768];
|
||||
|
||||
PaletteFragmentArray _fragments;
|
||||
byte _fragmentIndex;
|
||||
|
||||
|
||||
};
|
||||
|
||||
} // End of namespace Toltecs
|
||||
|
@ -49,7 +49,7 @@ ArchiveReader::~ArchiveReader() {
|
||||
void ArchiveReader::openArchive(const char *filename) {
|
||||
open(filename);
|
||||
for (uint i = 0; i < 10000; i++)
|
||||
_offsets[i] = readUint32LE();
|
||||
_offsets[i] = readUint32LE();
|
||||
}
|
||||
|
||||
uint32 ArchiveReader::openResource(uint resIndex) {
|
||||
@ -98,8 +98,8 @@ ResourceCache::ResourceCache(ToltecsEngine *vm) : _vm(vm) {
|
||||
memset(_cache, 0, sizeof(_cache));
|
||||
_cacheCount = 0;
|
||||
|
||||
_curItemOffset = 0;
|
||||
_curItemSize = 0;
|
||||
_curItemOffset = 0;
|
||||
_curItemSize = 0;
|
||||
|
||||
}
|
||||
|
||||
@ -110,11 +110,11 @@ ResourceCache::~ResourceCache() {
|
||||
byte *ResourceCache::load(uint resIndex) {
|
||||
byte *data = NULL;
|
||||
if (existsItem(resIndex)) {
|
||||
debug(1, "ResourceCache::load(%d) From cache", resIndex);
|
||||
data = _base + _curItemOffset;
|
||||
debug(1, "ResourceCache::load(%d) From cache", resIndex);
|
||||
data = _base + _curItemOffset;
|
||||
} else {
|
||||
debug(1, "ResourceCache::load(%d) From disk", resIndex);
|
||||
uint32 size = _vm->_arc->openResource(resIndex);
|
||||
debug(1, "ResourceCache::load(%d) From disk", resIndex);
|
||||
uint32 size = _vm->_arc->openResource(resIndex);
|
||||
data = addItem(resIndex, size);
|
||||
_vm->_arc->read(data, size);
|
||||
_vm->_arc->closeResource();
|
||||
@ -124,10 +124,10 @@ byte *ResourceCache::load(uint resIndex) {
|
||||
|
||||
bool ResourceCache::existsItem(uint resIndex) {
|
||||
for (uint i = 0; i < _cacheCount; i++) {
|
||||
if (_cache[i].resIndex == resIndex) {
|
||||
_curItemOffset = _cache[i].offset;
|
||||
_curItemSize = _cache[i].size;
|
||||
return true;
|
||||
if (_cache[i].resIndex == resIndex) {
|
||||
_curItemOffset = _cache[i].offset;
|
||||
_curItemSize = _cache[i].size;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@ -137,15 +137,15 @@ byte *ResourceCache::addItem(uint resIndex, uint32 size) {
|
||||
|
||||
checkCapacity(size);
|
||||
|
||||
_curItemOffset = _bytesUsed;
|
||||
_curItemSize = size;
|
||||
_curItemOffset = _bytesUsed;
|
||||
_curItemSize = size;
|
||||
|
||||
_cache[_cacheCount].resIndex = resIndex;
|
||||
_cache[_cacheCount].offset = _curItemOffset;
|
||||
_cache[_cacheCount].size = _curItemSize;
|
||||
_cacheCount++;
|
||||
|
||||
_bytesUsed += size;
|
||||
_cache[_cacheCount].resIndex = resIndex;
|
||||
_cache[_cacheCount].offset = _curItemOffset;
|
||||
_cache[_cacheCount].size = _curItemSize;
|
||||
_cacheCount++;
|
||||
|
||||
_bytesUsed += size;
|
||||
|
||||
return _base + _curItemOffset;
|
||||
|
||||
@ -153,8 +153,8 @@ byte *ResourceCache::addItem(uint resIndex, uint32 size) {
|
||||
|
||||
void ResourceCache::checkCapacity(uint32 size) {
|
||||
if (_cacheCount > kMaxCacheItems || _bytesUsed + size > kMaxCacheSize) {
|
||||
_cacheCount = 0;
|
||||
_bytesUsed = 0;
|
||||
_cacheCount = 0;
|
||||
_bytesUsed = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ namespace Toltecs {
|
||||
TODO:
|
||||
|
||||
ArchiveReader:
|
||||
- Add support for external resources; and check if they're used
|
||||
- Add support for external resources; and check if they're used
|
||||
|
||||
*/
|
||||
|
||||
@ -58,20 +58,20 @@ const uint kMaxCacheSize = 8 * 1024 * 1024; // 8 MB
|
||||
|
||||
class ArchiveReader : public Common::File {
|
||||
public:
|
||||
ArchiveReader();
|
||||
~ArchiveReader();
|
||||
|
||||
void openArchive(const char *filename);
|
||||
|
||||
// Returns the size of the opened resource
|
||||
uint32 openResource(uint resIndex);
|
||||
// Closes the resource
|
||||
void closeResource();
|
||||
// Returns the size of the resource
|
||||
uint32 getResourceSize(uint resIndex);
|
||||
ArchiveReader();
|
||||
~ArchiveReader();
|
||||
|
||||
void openArchive(const char *filename);
|
||||
|
||||
// Returns the size of the opened resource
|
||||
uint32 openResource(uint resIndex);
|
||||
// Closes the resource
|
||||
void closeResource();
|
||||
// Returns the size of the resource
|
||||
uint32 getResourceSize(uint resIndex);
|
||||
|
||||
void dump(uint resIndex, const char *prefix = NULL);
|
||||
|
||||
void dump(uint resIndex, const char *prefix = NULL);
|
||||
|
||||
protected:
|
||||
uint32 _offsets[10000];
|
||||
|
||||
@ -79,23 +79,23 @@ protected:
|
||||
|
||||
class ResourceCache {
|
||||
public:
|
||||
ResourceCache(ToltecsEngine *vm);
|
||||
~ResourceCache();
|
||||
|
||||
byte *load(uint resIndex);
|
||||
uint32 getCurItemSize() const { return _curItemSize; }
|
||||
ResourceCache(ToltecsEngine *vm);
|
||||
~ResourceCache();
|
||||
|
||||
byte *load(uint resIndex);
|
||||
uint32 getCurItemSize() const { return _curItemSize; }
|
||||
|
||||
protected:
|
||||
|
||||
struct CacheItem {
|
||||
uint resIndex;
|
||||
//int value; // what is this?
|
||||
int32 offset; // offset into _base
|
||||
uint32 size; // size of the item
|
||||
uint resIndex;
|
||||
//int value; // what is this?
|
||||
int32 offset; // offset into _base
|
||||
uint32 size; // size of the item
|
||||
};
|
||||
|
||||
ToltecsEngine *_vm;
|
||||
|
||||
ToltecsEngine *_vm;
|
||||
|
||||
byte *_base;
|
||||
uint32 _bytesUsed;
|
||||
uint32 _curItemOffset, _curItemSize;
|
||||
|
@ -45,12 +45,12 @@ namespace Toltecs {
|
||||
|
||||
Screen::Screen(ToltecsEngine *vm) : _vm(vm) {
|
||||
|
||||
_frontScreen = new byte[268800];
|
||||
_frontScreen = new byte[268800];
|
||||
_backScreen = new byte[870400];
|
||||
|
||||
memset(_fontResIndexArray, 0, sizeof(_fontResIndexArray));
|
||||
_fontColor1 = 0;
|
||||
_fontColor2 = 0;
|
||||
_fontColor1 = 0;
|
||||
_fontColor2 = 0;
|
||||
|
||||
// Screen shaking
|
||||
_shakeActive = false;
|
||||
@ -85,37 +85,37 @@ Screen::~Screen() {
|
||||
|
||||
void Screen::unpackRle(byte *source, byte *dest, uint16 width, uint16 height) {
|
||||
int32 size = width * height;
|
||||
while (size > 0) {
|
||||
byte a = *source++;
|
||||
byte b = *source++;
|
||||
if (a == 0) {
|
||||
dest += b;
|
||||
size -= b;
|
||||
} else {
|
||||
b = ((b << 4) & 0xF0) | ((b >> 4) & 0x0F);
|
||||
memset(dest, b, a);
|
||||
dest += a;
|
||||
size -= a;
|
||||
}
|
||||
}
|
||||
while (size > 0) {
|
||||
byte a = *source++;
|
||||
byte b = *source++;
|
||||
if (a == 0) {
|
||||
dest += b;
|
||||
size -= b;
|
||||
} else {
|
||||
b = ((b << 4) & 0xF0) | ((b >> 4) & 0x0F);
|
||||
memset(dest, b, a);
|
||||
dest += a;
|
||||
size -= a;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Screen::loadMouseCursor(uint resIndex) {
|
||||
byte mouseCursor[16 * 16], *mouseCursorP = mouseCursor;
|
||||
byte *cursorData = _vm->_res->load(resIndex);
|
||||
for (int i = 0; i < 32; i++) {
|
||||
byte pixel;
|
||||
byte mask1 = *cursorData++;
|
||||
byte mask2 = *cursorData++;
|
||||
for (int j = 0; j < 8; j++) {
|
||||
pixel = 0xE5;
|
||||
if ((mask2 & 0x80) == 0)
|
||||
pixel = 0xE0;
|
||||
mask2 <<= 1;
|
||||
if ((mask1 & 0x80) == 0)
|
||||
pixel = 0;
|
||||
mask1 <<= 1;
|
||||
*mouseCursorP++ = pixel;
|
||||
byte pixel;
|
||||
byte mask1 = *cursorData++;
|
||||
byte mask2 = *cursorData++;
|
||||
for (int j = 0; j < 8; j++) {
|
||||
pixel = 0xE5;
|
||||
if ((mask2 & 0x80) == 0)
|
||||
pixel = 0xE0;
|
||||
mask2 <<= 1;
|
||||
if ((mask1 & 0x80) == 0)
|
||||
pixel = 0;
|
||||
mask1 <<= 1;
|
||||
*mouseCursorP++ = pixel;
|
||||
}
|
||||
}
|
||||
//CursorMan.replaceCursor((const byte*)mouseCursor, 16, 16, 0, 0, 0);
|
||||
@ -151,9 +151,9 @@ void Screen::drawGuiImage(int16 x, int16 y, uint resIndex) {
|
||||
*dest++ = pixel;
|
||||
workWidth--;
|
||||
if (workWidth == 0) {
|
||||
workHeight--;
|
||||
dest += 640 - width;
|
||||
workWidth = width;
|
||||
workHeight--;
|
||||
dest += 640 - width;
|
||||
workWidth = width;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -174,11 +174,11 @@ void Screen::stopShakeScreen() {
|
||||
|
||||
void Screen::updateShakeScreen() {
|
||||
if (_shakeActive) {
|
||||
_shakeCounter--;
|
||||
if (_shakeCounter == 0) {
|
||||
_shakeCounter = _shakeCounterInit;
|
||||
_shakePos ^= 8;
|
||||
_vm->_system->setShakePos(_shakePos);
|
||||
_shakeCounter--;
|
||||
if (_shakeCounter == 0) {
|
||||
_shakeCounter = _shakeCounterInit;
|
||||
_shakePos ^= 8;
|
||||
_vm->_system->setShakePos(_shakePos);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -198,13 +198,13 @@ void Screen::addStaticSprite(byte *spriteItem) {
|
||||
|
||||
debug(0, "Screen::addStaticSprite() x = %d; y = %d; baseColor = %d; resIndex = %d; flags = %04X", drawRequest.x, drawRequest.y, drawRequest.baseColor, drawRequest.resIndex, drawRequest.flags);
|
||||
|
||||
addDrawRequest(drawRequest);
|
||||
addDrawRequest(drawRequest);
|
||||
|
||||
}
|
||||
|
||||
void Screen::addAnimatedSprite(int16 x, int16 y, int16 fragmentId, byte *data, int16 *spriteArray, bool loop, int mode) {
|
||||
|
||||
debug(0, "Screen::addAnimatedSprite(%d, %d, %d)", x, y, fragmentId);
|
||||
debug(0, "Screen::addAnimatedSprite(%d, %d, %d)", x, y, fragmentId);
|
||||
|
||||
DrawRequest drawRequest;
|
||||
memset(&drawRequest, 0, sizeof(drawRequest));
|
||||
@ -245,13 +245,13 @@ void Screen::addAnimatedSprite(int16 x, int16 y, int16 fragmentId, byte *data, i
|
||||
loopNum++;
|
||||
if (loopNum == loopCount) {
|
||||
if (loop) {
|
||||
loopNum = 0;
|
||||
loopNum = 0;
|
||||
} else {
|
||||
loopNum--;
|
||||
loopNum--;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
loopNum |= 0x8000;
|
||||
loopNum |= 0x8000;
|
||||
}
|
||||
|
||||
WRITE_LE_UINT16(spriteItem + 0, loopNum);
|
||||
@ -263,8 +263,8 @@ void Screen::addAnimatedSprite(int16 x, int16 y, int16 fragmentId, byte *data, i
|
||||
|
||||
void Screen::clearSprites() {
|
||||
|
||||
_spriteDrawList.clear();
|
||||
// TODO
|
||||
_spriteDrawList.clear();
|
||||
// TODO
|
||||
|
||||
}
|
||||
|
||||
@ -275,12 +275,12 @@ void Screen::addDrawRequest(const DrawRequest &drawRequest) {
|
||||
byte *spriteData;
|
||||
int16 frameNum;
|
||||
|
||||
SpriteDrawItem sprite;
|
||||
memset(&sprite, 0, sizeof(SpriteDrawItem));
|
||||
SpriteDrawItem sprite;
|
||||
memset(&sprite, 0, sizeof(SpriteDrawItem));
|
||||
|
||||
if (drawRequest.flags == 0xFFFF)
|
||||
return;
|
||||
|
||||
return;
|
||||
|
||||
sprite.flags = 0;
|
||||
sprite.baseColor = drawRequest.baseColor;
|
||||
sprite.x = drawRequest.x;
|
||||
@ -291,11 +291,11 @@ void Screen::addDrawRequest(const DrawRequest &drawRequest) {
|
||||
spriteData = _vm->_res->load(drawRequest.resIndex);
|
||||
|
||||
if (drawRequest.flags & 0x2000) {
|
||||
sprite.flags |= 0x10;
|
||||
sprite.flags |= 0x10;
|
||||
}
|
||||
|
||||
if (drawRequest.flags & 0x4000) {
|
||||
sprite.flags |= 0x40;
|
||||
sprite.flags |= 0x40;
|
||||
}
|
||||
|
||||
frameNum = drawRequest.flags & 0x0FFF;
|
||||
@ -305,7 +305,7 @@ void Screen::addDrawRequest(const DrawRequest &drawRequest) {
|
||||
SpriteFrameEntry spriteFrameEntry(spriteData + frameNum * 12);
|
||||
|
||||
if (spriteFrameEntry.w == 0 || spriteFrameEntry.h == 0)
|
||||
return;
|
||||
return;
|
||||
|
||||
sprite.offset = spriteFrameEntry.offset;
|
||||
|
||||
@ -316,9 +316,9 @@ void Screen::addDrawRequest(const DrawRequest &drawRequest) {
|
||||
sprite.origHeight = spriteFrameEntry.h;
|
||||
|
||||
if (drawRequest.flags & 0x1000) {
|
||||
spriteDraw_X = spriteFrameEntry.w - spriteFrameEntry.x;
|
||||
spriteDraw_X = spriteFrameEntry.w - spriteFrameEntry.x;
|
||||
} else {
|
||||
spriteDraw_X = spriteFrameEntry.x;
|
||||
spriteDraw_X = spriteFrameEntry.x;
|
||||
}
|
||||
|
||||
spriteDraw_Y = spriteFrameEntry.y;
|
||||
@ -327,7 +327,7 @@ void Screen::addDrawRequest(const DrawRequest &drawRequest) {
|
||||
|
||||
if (drawRequest.scaling != 0) {
|
||||
|
||||
byte scaleValue = ABS(drawRequest.scaling);
|
||||
byte scaleValue = ABS(drawRequest.scaling);
|
||||
|
||||
scaleValueX = scaleValue * sprite.origWidth;
|
||||
sprite.xdelta = (10000 * sprite.origWidth) / scaleValueX;
|
||||
@ -338,63 +338,63 @@ void Screen::addDrawRequest(const DrawRequest &drawRequest) {
|
||||
scaleValueY /= 100;
|
||||
|
||||
if (drawRequest.scaling > 0) {
|
||||
sprite.flags |= 2;
|
||||
sprite.width = sprite.origWidth + scaleValueX;
|
||||
sprite.height = sprite.origHeight + scaleValueY;
|
||||
spriteDraw_X += (spriteDraw_X * scaleValue) / 100;
|
||||
spriteDraw_Y += (spriteDraw_Y * scaleValue) / 100;
|
||||
sprite.flags |= 2;
|
||||
sprite.width = sprite.origWidth + scaleValueX;
|
||||
sprite.height = sprite.origHeight + scaleValueY;
|
||||
spriteDraw_X += (spriteDraw_X * scaleValue) / 100;
|
||||
spriteDraw_Y += (spriteDraw_Y * scaleValue) / 100;
|
||||
} else {
|
||||
sprite.flags |= 1;
|
||||
sprite.flags |= 1;
|
||||
sprite.width = sprite.origWidth - scaleValueX;
|
||||
sprite.height = sprite.origHeight - 1 - scaleValueY;
|
||||
sprite.height = sprite.origHeight - 1 - scaleValueY;
|
||||
if (sprite.width <= 0 || sprite.height <= 0)
|
||||
return;
|
||||
spriteDraw_X -= (spriteDraw_X * scaleValue) / 100;
|
||||
spriteDraw_Y -= (spriteDraw_Y * scaleValue) / 100;
|
||||
return;
|
||||
spriteDraw_X -= (spriteDraw_X * scaleValue) / 100;
|
||||
spriteDraw_Y -= (spriteDraw_Y * scaleValue) / 100;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sprite.x -= spriteDraw_X;
|
||||
sprite.y -= spriteDraw_Y;
|
||||
sprite.y -= spriteDraw_Y;
|
||||
|
||||
sprite.yerror = sprite.ydelta;
|
||||
sprite.yerror = sprite.ydelta;
|
||||
|
||||
// Now we check if the sprite needs to be clipped
|
||||
|
||||
// Clip Y
|
||||
if (sprite.y - _vm->_cameraY < 0) {
|
||||
|
||||
int16 clipHeight = ABS(sprite.y - _vm->_cameraY);
|
||||
int16 chopHeight, skipHeight, lineWidth;
|
||||
byte *spriteFrameData;
|
||||
if (sprite.y - _vm->_cameraY < 0) {
|
||||
|
||||
int16 clipHeight = ABS(sprite.y - _vm->_cameraY);
|
||||
int16 chopHeight, skipHeight, lineWidth;
|
||||
byte *spriteFrameData;
|
||||
|
||||
sprite.height -= clipHeight;
|
||||
if (sprite.height <= 0)
|
||||
return;
|
||||
return;
|
||||
|
||||
sprite.y = _vm->_cameraY;
|
||||
|
||||
// If the sprite is scaled
|
||||
if (sprite.flags & 3) {
|
||||
chopHeight = sprite.ydelta;
|
||||
sprite.y = _vm->_cameraY;
|
||||
|
||||
// If the sprite is scaled
|
||||
if (sprite.flags & 3) {
|
||||
chopHeight = sprite.ydelta;
|
||||
skipHeight = clipHeight;
|
||||
if ((sprite.flags & 2) == 0) {
|
||||
do {
|
||||
chopHeight -= 100;
|
||||
if (chopHeight <= 0) {
|
||||
skipHeight++;
|
||||
chopHeight += sprite.ydelta;
|
||||
if ((sprite.flags & 2) == 0) {
|
||||
do {
|
||||
chopHeight -= 100;
|
||||
if (chopHeight <= 0) {
|
||||
skipHeight++;
|
||||
chopHeight += sprite.ydelta;
|
||||
} else {
|
||||
clipHeight--;
|
||||
clipHeight--;
|
||||
}
|
||||
} while (clipHeight > 0);
|
||||
} else {
|
||||
do {
|
||||
chopHeight -= 100;
|
||||
if (chopHeight < 0) {
|
||||
skipHeight--;
|
||||
chopHeight += sprite.ydelta + 100;
|
||||
do {
|
||||
chopHeight -= 100;
|
||||
if (chopHeight < 0) {
|
||||
skipHeight--;
|
||||
chopHeight += sprite.ydelta + 100;
|
||||
}
|
||||
clipHeight--;
|
||||
} while (clipHeight > 0);
|
||||
@ -407,72 +407,72 @@ void Screen::addDrawRequest(const DrawRequest &drawRequest) {
|
||||
// Now the sprite's offset is adjusted to point to the starting line
|
||||
if ((sprite.flags & 0x10) == 0) {
|
||||
while (clipHeight--) {
|
||||
lineWidth = 0;
|
||||
while (lineWidth </*CHECKME was != */ sprite.origWidth) {
|
||||
sprite.offset++;
|
||||
lineWidth += (*spriteFrameData++) & 0x0F;
|
||||
lineWidth = 0;
|
||||
while (lineWidth </*CHECKME was != */ sprite.origWidth) {
|
||||
sprite.offset++;
|
||||
lineWidth += (*spriteFrameData++) & 0x0F;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
lineWidth = 0;
|
||||
lineWidth = 0;
|
||||
while (clipHeight--) {
|
||||
while (lineWidth < sprite.origWidth) {
|
||||
sprite.offset += 2;
|
||||
spriteFrameData++;
|
||||
while (lineWidth < sprite.origWidth) {
|
||||
sprite.offset += 2;
|
||||
spriteFrameData++;
|
||||
lineWidth += *spriteFrameData++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (sprite.y + sprite.height - _vm->_cameraY - _vm->_cameraHeight > 0)
|
||||
sprite.height -= sprite.y + sprite.height - _vm->_cameraY - _vm->_cameraHeight;
|
||||
sprite.height -= sprite.y + sprite.height - _vm->_cameraY - _vm->_cameraHeight;
|
||||
if (sprite.height <= 0)
|
||||
return;
|
||||
|
||||
return;
|
||||
|
||||
sprite.value1 = 0;
|
||||
|
||||
if (drawRequest.flags & 0x1000) {
|
||||
// Left border
|
||||
sprite.flags |= 4;
|
||||
if (sprite.x - _vm->_cameraX < 0) {
|
||||
sprite.width -= ABS(sprite.x - _vm->_cameraX);
|
||||
if (sprite.width <= 0)
|
||||
return;
|
||||
// Left border
|
||||
sprite.flags |= 4;
|
||||
if (sprite.x - _vm->_cameraX < 0) {
|
||||
sprite.width -= ABS(sprite.x - _vm->_cameraX);
|
||||
if (sprite.width <= 0)
|
||||
return;
|
||||
sprite.x = _vm->_cameraX;
|
||||
}
|
||||
// Right border
|
||||
// Right border
|
||||
if (sprite.x + sprite.width - _vm->_cameraX - 640 > 0) {
|
||||
sprite.flags |= 8;
|
||||
sprite.width -= sprite.x + sprite.width - _vm->_cameraX - 640;
|
||||
if (sprite.width <= 0)
|
||||
return;
|
||||
sprite.flags |= 8;
|
||||
sprite.width -= sprite.x + sprite.width - _vm->_cameraX - 640;
|
||||
if (sprite.width <= 0)
|
||||
return;
|
||||
sprite.value1 = sprite.x + sprite.width - _vm->_cameraX - 640;
|
||||
}
|
||||
} else {
|
||||
// Left border
|
||||
if (sprite.x - _vm->_cameraX < 0) {
|
||||
sprite.flags |= 8;
|
||||
sprite.width -= ABS(sprite.x - _vm->_cameraX);
|
||||
if (sprite.width <= 0)
|
||||
return;
|
||||
sprite.value1 = ABS(sprite.x - _vm->_cameraX);
|
||||
sprite.x = _vm->_cameraX;
|
||||
// Left border
|
||||
if (sprite.x - _vm->_cameraX < 0) {
|
||||
sprite.flags |= 8;
|
||||
sprite.width -= ABS(sprite.x - _vm->_cameraX);
|
||||
if (sprite.width <= 0)
|
||||
return;
|
||||
sprite.value1 = ABS(sprite.x - _vm->_cameraX);
|
||||
sprite.x = _vm->_cameraX;
|
||||
}
|
||||
// Right border
|
||||
// Right border
|
||||
if (sprite.x + sprite.width - _vm->_cameraX - 640 > 0) {
|
||||
sprite.flags |= 8;
|
||||
sprite.flags |= 8;
|
||||
sprite.width -= sprite.x + sprite.width - _vm->_cameraX - 640;
|
||||
if (sprite.width <= 0)
|
||||
return;
|
||||
if (sprite.width <= 0)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Add sprite sorted by priority
|
||||
Common::List<SpriteDrawItem>::iterator iter = _spriteDrawList.begin();
|
||||
while (iter != _spriteDrawList.end() && (*iter).ybottom <= sprite.ybottom) {
|
||||
iter++;
|
||||
iter++;
|
||||
}
|
||||
_spriteDrawList.insert(iter, sprite);
|
||||
|
||||
@ -480,43 +480,43 @@ void Screen::addDrawRequest(const DrawRequest &drawRequest) {
|
||||
|
||||
void Screen::drawSprite(SpriteDrawItem *sprite) {
|
||||
|
||||
debug(0, "Screen::drawSprite() x = %d; y = %d; flags = %04X; resIndex = %d; offset = %08X; drawX = %d; drawY = %d",
|
||||
debug(0, "Screen::drawSprite() x = %d; y = %d; flags = %04X; resIndex = %d; offset = %08X; drawX = %d; drawY = %d",
|
||||
sprite->x, sprite->y, sprite->flags, sprite->resIndex, sprite->offset,
|
||||
sprite->x - _vm->_cameraX, sprite->y - _vm->_cameraY);
|
||||
debug(0, "Screen::drawSprite() width = %d; height = %d; origWidth = %d; origHeight = %d",
|
||||
debug(0, "Screen::drawSprite() width = %d; height = %d; origWidth = %d; origHeight = %d",
|
||||
sprite->width, sprite->height, sprite->origWidth, sprite->origHeight);
|
||||
|
||||
byte *source = _vm->_res->load(sprite->resIndex) + sprite->offset;
|
||||
byte *dest = _frontScreen + (sprite->x - _vm->_cameraX) + (sprite->y - _vm->_cameraY) * 640;
|
||||
byte *source = _vm->_res->load(sprite->resIndex) + sprite->offset;
|
||||
byte *dest = _frontScreen + (sprite->x - _vm->_cameraX) + (sprite->y - _vm->_cameraY) * 640;
|
||||
|
||||
// FIXME: Temporary hack until proper clipping is implemented
|
||||
/*
|
||||
int16 dx = sprite->x - _vm->_cameraX, dy = sprite->y - _vm->_cameraY;
|
||||
if (dx < 0 || dy < 0 || dx + sprite->width >= 640 || dy + sprite->height >= 400)
|
||||
return;
|
||||
*/
|
||||
return;
|
||||
*/
|
||||
|
||||
SpriteReader spriteReader(source, sprite);
|
||||
|
||||
SpriteReader spriteReader(source, sprite);
|
||||
|
||||
if (sprite->flags & 0x40) {
|
||||
// TODO: Shadow sprites
|
||||
// TODO: Shadow sprites
|
||||
} else if (sprite->flags & 0x10) {
|
||||
// 256 color sprite
|
||||
drawSpriteCore(dest, spriteReader, sprite);
|
||||
// 256 color sprite
|
||||
drawSpriteCore(dest, spriteReader, sprite);
|
||||
} else {
|
||||
// 16 color sprite
|
||||
if (sprite->flags & 1) {
|
||||
SpriteFilterScaleDown spriteScaler(sprite, &spriteReader);
|
||||
drawSpriteCore(dest, spriteScaler, sprite);
|
||||
// 16 color sprite
|
||||
if (sprite->flags & 1) {
|
||||
SpriteFilterScaleDown spriteScaler(sprite, &spriteReader);
|
||||
drawSpriteCore(dest, spriteScaler, sprite);
|
||||
} else if (sprite->flags & 2) {
|
||||
SpriteFilterScaleUp spriteScaler(sprite, &spriteReader);
|
||||
drawSpriteCore(dest, spriteScaler, sprite);
|
||||
SpriteFilterScaleUp spriteScaler(sprite, &spriteReader);
|
||||
drawSpriteCore(dest, spriteScaler, sprite);
|
||||
} else {
|
||||
drawSpriteCore(dest, spriteReader, sprite);
|
||||
drawSpriteCore(dest, spriteReader, sprite);
|
||||
}
|
||||
}
|
||||
|
||||
debug(0, "Screen::drawSprite() ok");
|
||||
debug(0, "Screen::drawSprite() ok");
|
||||
|
||||
}
|
||||
|
||||
@ -526,14 +526,14 @@ void Screen::drawSpriteCore(byte *dest, SpriteFilter &reader, SpriteDrawItem *sp
|
||||
|
||||
/*
|
||||
if ((sprite->flags & 8))
|
||||
return;
|
||||
*/
|
||||
return;
|
||||
*/
|
||||
|
||||
if (sprite->flags & 4) {
|
||||
destInc = -1;
|
||||
destInc = -1;
|
||||
dest += sprite->width;
|
||||
} else {
|
||||
destInc = 1;
|
||||
destInc = 1;
|
||||
}
|
||||
|
||||
SpriteReaderStatus status;
|
||||
@ -546,29 +546,29 @@ void Screen::drawSpriteCore(byte *dest, SpriteFilter &reader, SpriteDrawItem *sp
|
||||
status = reader.readPacket(packet);
|
||||
|
||||
if (skipX > 0) {
|
||||
while (skipX > 0) {
|
||||
skipX -= packet.count;
|
||||
if (skipX < 0) {
|
||||
while (skipX > 0) {
|
||||
skipX -= packet.count;
|
||||
if (skipX < 0) {
|
||||
packet.count = ABS(skipX);
|
||||
break;
|
||||
}
|
||||
status = reader.readPacket(packet);
|
||||
status = reader.readPacket(packet);
|
||||
}
|
||||
}
|
||||
|
||||
if (((sprite->flags & 0x10) && (packet.pixel != 0xFF)) || !(sprite->flags & 0x10) && (packet.pixel != 0)) {
|
||||
if (sprite->flags & 0x40) {
|
||||
} else if (sprite->flags & 0x10) {
|
||||
packet.pixel = ((packet.pixel << 4) & 0xF0) | ((packet.pixel >> 4) & 0x0F);
|
||||
packet.pixel = ((packet.pixel << 4) & 0xF0) | ((packet.pixel >> 4) & 0x0F);
|
||||
} else {
|
||||
packet.pixel += sprite->baseColor - 1;
|
||||
}
|
||||
while (packet.count--) {
|
||||
*dest = packet.pixel;
|
||||
packet.pixel += sprite->baseColor - 1;
|
||||
}
|
||||
while (packet.count--) {
|
||||
*dest = packet.pixel;
|
||||
dest += destInc;
|
||||
}
|
||||
} else {
|
||||
dest += packet.count * destInc;
|
||||
dest += packet.count * destInc;
|
||||
}
|
||||
|
||||
if (status == kSrsEndOfLine) {
|
||||
@ -583,7 +583,7 @@ void Screen::drawSpriteCore(byte *dest, SpriteFilter &reader, SpriteDrawItem *sp
|
||||
|
||||
void Screen::drawSprites() {
|
||||
for (Common::List<SpriteDrawItem>::iterator iter = _spriteDrawList.begin(); iter != _spriteDrawList.end(); iter++) {
|
||||
SpriteDrawItem *sprite = &(*iter);
|
||||
SpriteDrawItem *sprite = &(*iter);
|
||||
drawSprite(sprite);
|
||||
_vm->_segmap->restoreMasksBySprite(sprite);
|
||||
}
|
||||
@ -596,16 +596,16 @@ void Screen::updateVerbLine(int16 slotIndex, int16 slotOffset) {
|
||||
|
||||
Font font(_vm->_res->load(_fontResIndexArray[0]));
|
||||
|
||||
_verbLineItems[_verbLineNum].slotIndex = slotIndex;
|
||||
_verbLineItems[_verbLineNum].slotOffset = slotOffset;
|
||||
_verbLineItems[_verbLineNum].slotIndex = slotIndex;
|
||||
_verbLineItems[_verbLineNum].slotOffset = slotOffset;
|
||||
|
||||
// First clear the line
|
||||
int16 y = _verbLineY;
|
||||
for (int16 i = 0; i < _verbLineCount; i++) {
|
||||
byte *dest = _frontScreen + _verbLineX - _verbLineWidth / 2 + (y - 1 + _vm->_cameraHeight) * 640;
|
||||
for (int16 j = 0; j < 20; j++) {
|
||||
memset(dest, 0xE0, _verbLineWidth);
|
||||
dest += 640;
|
||||
memset(dest, 0xE0, _verbLineWidth);
|
||||
dest += 640;
|
||||
}
|
||||
y += 18;
|
||||
}
|
||||
@ -622,19 +622,19 @@ void Screen::updateVerbLine(int16 slotIndex, int16 slotOffset) {
|
||||
memset(_tempString, 0, sizeof(_tempString));
|
||||
|
||||
for (int16 i = 0; i <= _verbLineNum; i++) {
|
||||
sourceString = _vm->_script->getSlotData(_verbLineItems[i].slotIndex) + _verbLineItems[i].slotOffset;
|
||||
sourceString = _vm->_script->getSlotData(_verbLineItems[i].slotIndex) + _verbLineItems[i].slotOffset;
|
||||
preprocessText(_fontResIndexArray[0], _verbLineWidth, width, sourceString, destString, len);
|
||||
_tempStringLen1 += len;
|
||||
}
|
||||
|
||||
if (_verbLineCount != 1) {
|
||||
int16 charWidth;
|
||||
if (*sourceString < 0xF0) {
|
||||
int16 charWidth;
|
||||
if (*sourceString < 0xF0) {
|
||||
while (*sourceString > 0x20 && *sourceString < 0xF0 && len > 0/*CHECKME, len check added*/) {
|
||||
byte ch = *sourceString--;
|
||||
_tempStringLen1--;
|
||||
len--;
|
||||
charWidth = font.getCharWidth(ch) + font.getSpacing() - 1;
|
||||
byte ch = *sourceString--;
|
||||
_tempStringLen1--;
|
||||
len--;
|
||||
charWidth = font.getCharWidth(ch) + font.getSpacing() - 1;
|
||||
width -= charWidth;
|
||||
}
|
||||
width += charWidth;
|
||||
@ -642,14 +642,14 @@ void Screen::updateVerbLine(int16 slotIndex, int16 slotOffset) {
|
||||
_tempStringLen1 -= len;
|
||||
_tempStringLen2 = len + 1;
|
||||
|
||||
drawString(_verbLineX - 1 - (width / 2), y, 0xF9, 0xFF, _fontResIndexArray[0]);
|
||||
drawString(_verbLineX - 1 - (width / 2), y, 0xF9, 0xFF, _fontResIndexArray[0]);
|
||||
|
||||
destString = _tempString;
|
||||
width = 0;
|
||||
preprocessText(_fontResIndexArray[0], _verbLineWidth, width, sourceString, destString, len);
|
||||
|
||||
_tempStringLen1 += len;
|
||||
y += 9;
|
||||
y += 9;
|
||||
}
|
||||
y += 9;
|
||||
}
|
||||
@ -667,10 +667,10 @@ void Screen::updateTalkText(int16 slotIndex, int16 slotOffset) {
|
||||
byte durationModifier = 1;
|
||||
byte *textData = _vm->_script->getSlotData(slotIndex) + slotOffset;
|
||||
|
||||
TalkTextItem *item = &_talkTextItems[_talkTextItemNum];
|
||||
TalkTextItem *item = &_talkTextItems[_talkTextItemNum];
|
||||
|
||||
item->fontNum = 0;
|
||||
item->color = _talkTextFontColor;
|
||||
item->fontNum = 0;
|
||||
item->color = _talkTextFontColor;
|
||||
|
||||
//debug(0, "## _talkTextMaxWidth = %d", _talkTextMaxWidth);
|
||||
|
||||
@ -680,53 +680,53 @@ void Screen::updateTalkText(int16 slotIndex, int16 slotOffset) {
|
||||
maxWidth = 624 - ABS(x - 320) * 2;
|
||||
|
||||
while (1) {
|
||||
if (*textData == 0x0A) {
|
||||
if (*textData == 0x0A) {
|
||||
x = CLIP<int16>(textData[3], 120, _talkTextMaxWidth);
|
||||
y = CLIP<int16>(READ_LE_UINT16(&textData[1]), 4, _vm->_cameraHeight - 16);
|
||||
maxWidth = 624 - ABS(x - 320) * 2;
|
||||
textData += 4;
|
||||
} else if (*textData == 0x14) {
|
||||
item->color = textData[1];
|
||||
textData += 2;
|
||||
item->color = textData[1];
|
||||
textData += 2;
|
||||
} else if (*textData == 0x19) {
|
||||
durationModifier = textData[1];
|
||||
textData += 2;
|
||||
durationModifier = textData[1];
|
||||
textData += 2;
|
||||
} else if (*textData < 0x0A) {
|
||||
item->fontNum = textData[1];
|
||||
textData += 2;
|
||||
item->fontNum = textData[1];
|
||||
textData += 2;
|
||||
} else
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
item->slotIndex = slotIndex;
|
||||
item->slotOffset = textData - _vm->_script->getSlotData(slotIndex);
|
||||
|
||||
width = 0;
|
||||
length = 0;
|
||||
|
||||
item->rectCount = 0;
|
||||
|
||||
Font font(_vm->_res->load(_fontResIndexArray[item->fontNum]));
|
||||
item->slotIndex = slotIndex;
|
||||
item->slotOffset = textData - _vm->_script->getSlotData(slotIndex);
|
||||
|
||||
width = 0;
|
||||
length = 0;
|
||||
|
||||
item->rectCount = 0;
|
||||
|
||||
Font font(_vm->_res->load(_fontResIndexArray[item->fontNum]));
|
||||
int16 wordLength, wordWidth;
|
||||
|
||||
while (*textData < 0xF0) {
|
||||
while (*textData < 0xF0) {
|
||||
if (*textData == 0x1E) {
|
||||
textData++;
|
||||
addTalkTextRect(font, x, y, length, width, item);
|
||||
// CHECKME?
|
||||
textData++;
|
||||
addTalkTextRect(font, x, y, length, width, item);
|
||||
// CHECKME?
|
||||
width = 0;
|
||||
length = 0;
|
||||
} else {
|
||||
wordLength = 0;
|
||||
wordWidth = 0;
|
||||
while (*textData >= 0x20 && *textData < 0xF0) {
|
||||
byte ch = *textData++;
|
||||
wordLength++;
|
||||
if (ch == 0x20) {
|
||||
wordWidth += font.getWidth();
|
||||
break;
|
||||
wordLength = 0;
|
||||
wordWidth = 0;
|
||||
while (*textData >= 0x20 && *textData < 0xF0) {
|
||||
byte ch = *textData++;
|
||||
wordLength++;
|
||||
if (ch == 0x20) {
|
||||
wordWidth += font.getWidth();
|
||||
break;
|
||||
} else {
|
||||
wordWidth += font.getCharWidth(ch) + font.getSpacing() - 1;
|
||||
wordWidth += font.getCharWidth(ch) + font.getSpacing() - 1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -751,7 +751,7 @@ void Screen::updateTalkText(int16 slotIndex, int16 slotOffset) {
|
||||
int16 textDurationMultiplier = item->duration + 8;
|
||||
// TODO: Check sound/text flags
|
||||
if (*textData == 0xFE) {
|
||||
//textDurationMultiplier += 100;
|
||||
//textDurationMultiplier += 100;
|
||||
}
|
||||
item->duration = 4 * textDurationMultiplier * durationModifier;
|
||||
|
||||
@ -760,14 +760,14 @@ void Screen::updateTalkText(int16 slotIndex, int16 slotOffset) {
|
||||
void Screen::addTalkTextRect(Font &font, int16 x, int16 &y, int16 length, int16 width, TalkTextItem *item) {
|
||||
|
||||
if (width > 0) {
|
||||
TextRect *textRect = &item->rects[item->rectCount];
|
||||
width = width + 1 - font.getSpacing();
|
||||
textRect->width = width;
|
||||
item->duration += length;
|
||||
textRect->length = length;
|
||||
textRect->y = y;
|
||||
textRect->x = CLIP<int16>(x - width / 2, 0, 640);
|
||||
item->rectCount++;
|
||||
TextRect *textRect = &item->rects[item->rectCount];
|
||||
width = width + 1 - font.getSpacing();
|
||||
textRect->width = width;
|
||||
item->duration += length;
|
||||
textRect->length = length;
|
||||
textRect->y = y;
|
||||
textRect->x = CLIP<int16>(x - width / 2, 0, 640);
|
||||
item->rectCount++;
|
||||
}
|
||||
|
||||
y += font.getHeight() - 1;
|
||||
@ -782,25 +782,25 @@ void Screen::drawTalkTextItems() {
|
||||
TalkTextItem *item = &_talkTextItems[i];
|
||||
byte *text = _vm->_script->getSlotData(item->slotIndex) + item->slotOffset;
|
||||
|
||||
if (item->fontNum == -1 || item->duration == 0)
|
||||
continue;
|
||||
if (item->fontNum == -1 || item->duration == 0)
|
||||
continue;
|
||||
|
||||
item->duration -= _vm->_counter01;
|
||||
if (item->duration < 0)
|
||||
item->duration = 0;
|
||||
|
||||
Font font(_vm->_res->load(_fontResIndexArray[item->fontNum]));
|
||||
item->duration = 0;
|
||||
|
||||
Font font(_vm->_res->load(_fontResIndexArray[item->fontNum]));
|
||||
for (byte j = 0; j < item->rectCount; j++) {
|
||||
int16 x = item->rects[j].x;
|
||||
for (byte pos = 0; pos < item->rects[j].length; pos++) {
|
||||
byte ch = *text++;
|
||||
if (ch < 0x20)
|
||||
continue;
|
||||
if (ch == 0x20) {
|
||||
x += font.getWidth();
|
||||
byte ch = *text++;
|
||||
if (ch < 0x20)
|
||||
continue;
|
||||
if (ch == 0x20) {
|
||||
x += font.getWidth();
|
||||
} else {
|
||||
drawChar2(font, _frontScreen, x, item->rects[j].y, ch, item->color);
|
||||
x += font.getCharWidth(ch) + font.getSpacing() - 1;
|
||||
drawChar2(font, _frontScreen, x, item->rects[j].y, ch, item->color);
|
||||
x += font.getCharWidth(ch) + font.getSpacing() - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -822,30 +822,30 @@ void Screen::printText(byte *textData) {
|
||||
|
||||
// Really strange stuff.
|
||||
for (int i = 30; i >= 0; i--) {
|
||||
if (textData[i] >= 0xF0)
|
||||
break;
|
||||
if (textData[i] >= 0xF0)
|
||||
break;
|
||||
if (i == 0)
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
do {
|
||||
|
||||
if (*textData == 0x0A) {
|
||||
// Set text position
|
||||
y = textData[1];
|
||||
x = READ_LE_UINT32(textData + 2);
|
||||
textData += 4;
|
||||
if (*textData == 0x0A) {
|
||||
// Set text position
|
||||
y = textData[1];
|
||||
x = READ_LE_UINT32(textData + 2);
|
||||
textData += 4;
|
||||
} else if (*textData == 0x0B) {
|
||||
// Inc text position
|
||||
y += textData[1]; // CHECKME: Maybe these are signed?
|
||||
x += textData[2];
|
||||
textData += 3;
|
||||
// Inc text position
|
||||
y += textData[1]; // CHECKME: Maybe these are signed?
|
||||
x += textData[2];
|
||||
textData += 3;
|
||||
} else {
|
||||
byte *destString = _tempString;
|
||||
int width = 0;
|
||||
_tempStringLen1 = 0;
|
||||
preprocessText(_fontResIndexArray[1], 640, width, textData, destString, _tempStringLen2);
|
||||
drawString(x - width / 2, y, _fontColor1, _fontColor2, _fontResIndexArray[1]);
|
||||
preprocessText(_fontResIndexArray[1], 640, width, textData, destString, _tempStringLen2);
|
||||
drawString(x - width / 2, y, _fontColor1, _fontColor2, _fontResIndexArray[1]);
|
||||
}
|
||||
|
||||
} while (*textData != 0xFF);
|
||||
@ -858,17 +858,17 @@ void Screen::preprocessText(uint fontResIndex, int maxWidth, int &width, byte *&
|
||||
|
||||
len = 0;
|
||||
while (*sourceString >= 0x20 && *sourceString < 0xF0) {
|
||||
byte ch = *sourceString;
|
||||
byte ch = *sourceString;
|
||||
byte charWidth;
|
||||
if (ch <= 0x20)
|
||||
charWidth = font.getWidth();
|
||||
if (ch <= 0x20)
|
||||
charWidth = font.getWidth();
|
||||
else
|
||||
charWidth = font.getCharWidth(ch) + font.getSpacing() - 1;
|
||||
if (width + charWidth >= maxWidth)
|
||||
break;
|
||||
break;
|
||||
len++;
|
||||
width += charWidth;
|
||||
*destString++ = *sourceString++;
|
||||
*destString++ = *sourceString++;
|
||||
}
|
||||
}
|
||||
|
||||
@ -884,16 +884,16 @@ void Screen::drawString(int16 x, int16 y, byte fontColor1, byte fontColor2, uint
|
||||
int16 yadd = 1;
|
||||
|
||||
for (byte pos = 0; pos < len; pos++) {
|
||||
if (pos == _tempStringLen1) {
|
||||
color = fontColor2;
|
||||
if (pos == _tempStringLen1) {
|
||||
color = fontColor2;
|
||||
}
|
||||
byte ch = *text++;
|
||||
if (ch <= 0x20) {
|
||||
x += font.getWidth();
|
||||
byte ch = *text++;
|
||||
if (ch <= 0x20) {
|
||||
x += font.getWidth();
|
||||
} else {
|
||||
drawChar(font, _frontScreen, x + 1, y + _vm->_cameraHeight - yadd, ch, color);
|
||||
x += font.getCharWidth(ch) + font.getSpacing() - 1;
|
||||
yadd = -yadd;
|
||||
drawChar(font, _frontScreen, x + 1, y + _vm->_cameraHeight - yadd, ch, color);
|
||||
x += font.getCharWidth(ch) + font.getSpacing() - 1;
|
||||
yadd = -yadd;
|
||||
}
|
||||
}
|
||||
|
||||
@ -912,19 +912,19 @@ void Screen::drawChar(const Font &font, byte *dest, int16 x, int16 y, byte ch, b
|
||||
charHeight = font.getHeight() - 2;
|
||||
charData = font.getCharData(ch);
|
||||
|
||||
while (charHeight--) {
|
||||
byte lineWidth = charWidth;
|
||||
while (lineWidth > 0) {
|
||||
byte count = charData[0] & 0x0F;
|
||||
byte flags = charData[0] & 0xF0;
|
||||
while (charHeight--) {
|
||||
byte lineWidth = charWidth;
|
||||
while (lineWidth > 0) {
|
||||
byte count = charData[0] & 0x0F;
|
||||
byte flags = charData[0] & 0xF0;
|
||||
charData++;
|
||||
lineWidth -= count;
|
||||
if (!(flags & 0x80) && (flags & 0x10)) {
|
||||
memset(dest, color, count);
|
||||
memset(dest, color, count);
|
||||
}
|
||||
dest += count;
|
||||
}
|
||||
dest += 640 - charWidth;
|
||||
dest += 640 - charWidth;
|
||||
}
|
||||
|
||||
}
|
||||
@ -940,25 +940,25 @@ void Screen::drawChar2(const Font &font, byte *dest, int16 x, int16 y, byte ch,
|
||||
charHeight = font.getHeight() - 2;
|
||||
charData = font.getCharData(ch);
|
||||
|
||||
while (charHeight--) {
|
||||
byte lineWidth = charWidth;
|
||||
while (lineWidth > 0) {
|
||||
byte count = charData[0] & 0x0F;
|
||||
byte flags = charData[0] & 0xF0;
|
||||
while (charHeight--) {
|
||||
byte lineWidth = charWidth;
|
||||
while (lineWidth > 0) {
|
||||
byte count = charData[0] & 0x0F;
|
||||
byte flags = charData[0] & 0xF0;
|
||||
charData++;
|
||||
lineWidth -= count;
|
||||
|
||||
if ((flags & 0x80) == 0) {
|
||||
if ((flags & 0x10) == 0) {
|
||||
memset(dest, 0, count);
|
||||
} else {
|
||||
memset(dest, color, count);
|
||||
memset(dest, 0, count);
|
||||
} else {
|
||||
memset(dest, color, count);
|
||||
}
|
||||
}
|
||||
|
||||
dest += count;
|
||||
}
|
||||
dest += 640 - charWidth;
|
||||
dest += 640 - charWidth;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -122,16 +122,16 @@ enum SpriteReaderStatus {
|
||||
|
||||
class SpriteFilter {
|
||||
public:
|
||||
SpriteFilter(SpriteDrawItem *sprite) : _sprite(sprite) {
|
||||
SpriteFilter(SpriteDrawItem *sprite) : _sprite(sprite) {
|
||||
}
|
||||
virtual SpriteReaderStatus readPacket(PixelPacket &packet) = 0;
|
||||
protected:
|
||||
SpriteDrawItem *_sprite;
|
||||
SpriteDrawItem *_sprite;
|
||||
};
|
||||
|
||||
class SpriteReader : public SpriteFilter {
|
||||
public:
|
||||
SpriteReader(byte *source, SpriteDrawItem *sprite) : SpriteFilter(sprite), _source(source) {
|
||||
SpriteReader(byte *source, SpriteDrawItem *sprite) : SpriteFilter(sprite), _source(source) {
|
||||
_curWidth = _sprite->origWidth;
|
||||
_curHeight = _sprite->origHeight;
|
||||
}
|
||||
@ -146,23 +146,23 @@ public:
|
||||
}
|
||||
_curWidth -= packet.count;
|
||||
if (_curWidth <= 0) {
|
||||
_curHeight--;
|
||||
if (_curHeight == 0) {
|
||||
return kSrsEndOfSprite;
|
||||
_curHeight--;
|
||||
if (_curHeight == 0) {
|
||||
return kSrsEndOfSprite;
|
||||
} else {
|
||||
_curWidth = _sprite->origWidth;
|
||||
return kSrsEndOfLine;
|
||||
_curWidth = _sprite->origWidth;
|
||||
return kSrsEndOfLine;
|
||||
}
|
||||
} else {
|
||||
return kSrsPixelsLeft;
|
||||
return kSrsPixelsLeft;
|
||||
}
|
||||
}
|
||||
byte *getSource() {
|
||||
return _source;
|
||||
return _source;
|
||||
}
|
||||
void setSource(byte *source) {
|
||||
_source = source;
|
||||
_curHeight++;
|
||||
_source = source;
|
||||
_curHeight++;
|
||||
}
|
||||
protected:
|
||||
byte *_source;
|
||||
@ -171,49 +171,49 @@ protected:
|
||||
|
||||
class SpriteFilterScaleDown : public SpriteFilter {
|
||||
public:
|
||||
SpriteFilterScaleDown(SpriteDrawItem *sprite, SpriteReader *reader) : SpriteFilter(sprite), _reader(reader) {
|
||||
SpriteFilterScaleDown(SpriteDrawItem *sprite, SpriteReader *reader) : SpriteFilter(sprite), _reader(reader) {
|
||||
_height = _sprite->height;
|
||||
_yerror = _sprite->yerror;
|
||||
_origHeight = _sprite->origHeight;
|
||||
_scalerStatus = 0;
|
||||
}
|
||||
SpriteReaderStatus readPacket(PixelPacket &packet) {
|
||||
SpriteReaderStatus status;
|
||||
SpriteReaderStatus status;
|
||||
if (_scalerStatus == 0) {
|
||||
_xerror = _sprite->xdelta;
|
||||
_yerror -= 100;
|
||||
while (_yerror <= 0) {
|
||||
do {
|
||||
status = _reader->readPacket(packet);
|
||||
do {
|
||||
status = _reader->readPacket(packet);
|
||||
} while (status == kSrsPixelsLeft);
|
||||
_yerror += _sprite->ydelta - 100;
|
||||
}
|
||||
if (status == kSrsEndOfSprite)
|
||||
return kSrsEndOfSprite;
|
||||
_scalerStatus = 1;
|
||||
return kSrsEndOfSprite;
|
||||
_scalerStatus = 1;
|
||||
}
|
||||
if (_scalerStatus == 1) {
|
||||
status = _reader->readPacket(packet);
|
||||
byte updcount = packet.count;
|
||||
while (updcount--) {
|
||||
status = _reader->readPacket(packet);
|
||||
byte updcount = packet.count;
|
||||
while (updcount--) {
|
||||
_xerror -= 100;
|
||||
if (_xerror <= 0) {
|
||||
if (packet.count > 0)
|
||||
packet.count--;
|
||||
_xerror += _sprite->xdelta;
|
||||
if (packet.count > 0)
|
||||
packet.count--;
|
||||
_xerror += _sprite->xdelta;
|
||||
}
|
||||
}
|
||||
if (status == kSrsEndOfLine) {
|
||||
if (--_height == 0)
|
||||
return kSrsEndOfSprite;
|
||||
_scalerStatus = 0;
|
||||
return kSrsEndOfLine;
|
||||
_scalerStatus = 0;
|
||||
return kSrsEndOfLine;
|
||||
}
|
||||
}
|
||||
return kSrsPixelsLeft;
|
||||
}
|
||||
protected:
|
||||
SpriteReader *_reader;
|
||||
SpriteReader *_reader;
|
||||
int16 _xerror, _yerror;
|
||||
int16 _height;
|
||||
int16 _origHeight;
|
||||
@ -222,46 +222,46 @@ protected:
|
||||
|
||||
class SpriteFilterScaleUp : public SpriteFilter {
|
||||
public:
|
||||
SpriteFilterScaleUp(SpriteDrawItem *sprite, SpriteReader *reader) : SpriteFilter(sprite), _reader(reader) {
|
||||
SpriteFilterScaleUp(SpriteDrawItem *sprite, SpriteReader *reader) : SpriteFilter(sprite), _reader(reader) {
|
||||
_height = _sprite->height;
|
||||
_yerror = _sprite->yerror;
|
||||
_origHeight = _sprite->origHeight;
|
||||
_scalerStatus = 0;
|
||||
}
|
||||
SpriteReaderStatus readPacket(PixelPacket &packet) {
|
||||
SpriteReaderStatus status;
|
||||
if (_scalerStatus == 0) {
|
||||
SpriteReaderStatus status;
|
||||
if (_scalerStatus == 0) {
|
||||
_xerror = _sprite->xdelta;
|
||||
_sourcep = _reader->getSource();
|
||||
_scalerStatus = 1;
|
||||
_scalerStatus = 1;
|
||||
}
|
||||
if (_scalerStatus == 1) {
|
||||
status = _reader->readPacket(packet);
|
||||
byte updcount = packet.count;
|
||||
status = _reader->readPacket(packet);
|
||||
byte updcount = packet.count;
|
||||
while (updcount--) {
|
||||
_xerror -= 100;
|
||||
if (_xerror <= 0) {
|
||||
packet.count++;
|
||||
_xerror += _sprite->xdelta;
|
||||
_xerror -= 100;
|
||||
if (_xerror <= 0) {
|
||||
packet.count++;
|
||||
_xerror += _sprite->xdelta;
|
||||
}
|
||||
}
|
||||
if (status == kSrsEndOfLine) {
|
||||
if (--_height == 0)
|
||||
return kSrsEndOfSprite;
|
||||
_yerror -= 100;
|
||||
_yerror -= 100;
|
||||
if (_yerror <= 0) {
|
||||
_reader->setSource(_sourcep);
|
||||
_reader->setSource(_sourcep);
|
||||
_yerror += _sprite->ydelta + 100;
|
||||
}
|
||||
_scalerStatus = 0;
|
||||
return kSrsEndOfLine;
|
||||
_scalerStatus = 0;
|
||||
return kSrsEndOfLine;
|
||||
}
|
||||
}
|
||||
return kSrsPixelsLeft;
|
||||
}
|
||||
protected:
|
||||
SpriteReader *_reader;
|
||||
byte *_sourcep;
|
||||
SpriteReader *_reader;
|
||||
byte *_sourcep;
|
||||
int16 _xerror, _yerror;
|
||||
int16 _height;
|
||||
int16 _origHeight;
|
||||
@ -271,7 +271,7 @@ protected:
|
||||
//*END*TEST*CODE**********************************************************************************************
|
||||
|
||||
struct TextRect {
|
||||
int16 x, y;
|
||||
int16 x, y;
|
||||
int16 width, length;
|
||||
};
|
||||
|
||||
@ -306,8 +306,8 @@ public:
|
||||
void clearSprites();
|
||||
|
||||
// Sprite drawing
|
||||
void drawSprite(SpriteDrawItem *sprite);
|
||||
void drawSpriteCore(byte *dest, SpriteFilter &reader, SpriteDrawItem *sprite);
|
||||
void drawSprite(SpriteDrawItem *sprite);
|
||||
void drawSpriteCore(byte *dest, SpriteFilter &reader, SpriteDrawItem *sprite);
|
||||
void drawSprites();
|
||||
|
||||
// Verb line
|
||||
@ -331,12 +331,12 @@ public:
|
||||
public:
|
||||
|
||||
struct VerbLineItem {
|
||||
int16 slotIndex;
|
||||
int16 slotIndex;
|
||||
int16 slotOffset;
|
||||
};
|
||||
|
||||
struct Rect {
|
||||
int16 x, y, width, height;
|
||||
int16 x, y, width, height;
|
||||
};
|
||||
|
||||
ToltecsEngine *_vm;
|
||||
@ -345,11 +345,11 @@ public:
|
||||
|
||||
Common::List<SpriteDrawItem> _spriteDrawList;
|
||||
|
||||
uint _fontResIndexArray[10];
|
||||
byte _fontColor1, _fontColor2;
|
||||
|
||||
byte _tempString[100];
|
||||
byte _tempStringLen1, _tempStringLen2;
|
||||
uint _fontResIndexArray[10];
|
||||
byte _fontColor1, _fontColor2;
|
||||
|
||||
byte _tempString[100];
|
||||
byte _tempStringLen1, _tempStringLen2;
|
||||
|
||||
// Screen shaking
|
||||
bool _shakeActive;
|
||||
|
@ -60,7 +60,7 @@ ScriptInterpreter::~ScriptInterpreter() {
|
||||
void ScriptInterpreter::loadScript(uint resIndex, uint slotIndex) {
|
||||
|
||||
if (_slots[slotIndex].data) {
|
||||
delete[] _slots[slotIndex].data;
|
||||
delete[] _slots[slotIndex].data;
|
||||
}
|
||||
|
||||
_slots[slotIndex].resIndex = resIndex;
|
||||
@ -355,8 +355,8 @@ void ScriptInterpreter::execOpcode(byte opcode) {
|
||||
_switchStack1 = true;
|
||||
break;
|
||||
case 49:
|
||||
ofs = readByte();
|
||||
debug(0, "49, len = %d", ofs);
|
||||
ofs = readByte();
|
||||
debug(0, "49, len = %d", ofs);
|
||||
_code += ofs;
|
||||
break;
|
||||
case 50:
|
||||
@ -1047,8 +1047,8 @@ int16 ScriptInterpreter::getGameVar(uint variable) {
|
||||
value = _vm->_sceneResIndex;
|
||||
break;
|
||||
case 19:
|
||||
value = _vm->_cameraTop;
|
||||
break;
|
||||
value = _vm->_cameraTop;
|
||||
break;
|
||||
case 20:
|
||||
value = _vm->_sceneHeight;
|
||||
break;
|
||||
@ -1121,8 +1121,8 @@ void ScriptInterpreter::setGameVar(uint variable, int16 value) {
|
||||
_vm->_sceneResIndex = value;
|
||||
break;
|
||||
case 19:
|
||||
_vm->_cameraTop = value;
|
||||
break;
|
||||
_vm->_cameraTop = value;
|
||||
break;
|
||||
case 20:
|
||||
_vm->_sceneHeight = value;
|
||||
break;
|
||||
|
@ -48,19 +48,19 @@ const int kMaxScriptSlots = 50;
|
||||
|
||||
class ScriptInterpreter {
|
||||
public:
|
||||
ScriptInterpreter(ToltecsEngine *vm);
|
||||
~ScriptInterpreter();
|
||||
|
||||
ScriptInterpreter(ToltecsEngine *vm);
|
||||
~ScriptInterpreter();
|
||||
|
||||
void loadScript(uint resIndex, uint slotIndex);
|
||||
void runScript(uint slotIndex);
|
||||
|
||||
|
||||
byte *getSlotData(int slotIndex) const { return _slots[slotIndex].data; }
|
||||
|
||||
protected:
|
||||
|
||||
enum VarType {
|
||||
vtByte,
|
||||
vtWord
|
||||
vtByte,
|
||||
vtWord
|
||||
};
|
||||
|
||||
struct ScriptRegs {
|
||||
@ -76,15 +76,15 @@ protected:
|
||||
};
|
||||
|
||||
struct ScriptSlot {
|
||||
byte *data;
|
||||
int32 size;
|
||||
uint resIndex;
|
||||
byte *data;
|
||||
int32 size;
|
||||
uint resIndex;
|
||||
};
|
||||
|
||||
ToltecsEngine *_vm;
|
||||
|
||||
byte *_stack;
|
||||
|
||||
ToltecsEngine *_vm;
|
||||
|
||||
byte *_stack;
|
||||
|
||||
byte *_code, *_subCode;
|
||||
byte *_localData;
|
||||
bool _switchStack1, _switchStack2, _switchStack3;
|
||||
|
@ -43,7 +43,7 @@
|
||||
namespace Toltecs {
|
||||
|
||||
SegmentMap::SegmentMap(ToltecsEngine *vm) : _vm(vm) {
|
||||
_maskRectData = new byte[32768];
|
||||
_maskRectData = new byte[32768];
|
||||
}
|
||||
|
||||
SegmentMap::~SegmentMap() {
|
||||
@ -54,9 +54,9 @@ void SegmentMap::load(byte *source) {
|
||||
|
||||
// TODO: Use MemoryReadStream
|
||||
|
||||
_maskRects.clear();
|
||||
_pathRects.clear();
|
||||
_infoRects.clear();
|
||||
_maskRects.clear();
|
||||
_pathRects.clear();
|
||||
_infoRects.clear();
|
||||
|
||||
// Load mask rects
|
||||
uint16 maskSize = READ_LE_UINT16(source);
|
||||
@ -85,7 +85,7 @@ void SegmentMap::load(byte *source) {
|
||||
}
|
||||
|
||||
memcpy(_maskRectData, source, maskSize - maskRectDataSize);
|
||||
source += maskSize - maskRectDataSize;
|
||||
source += maskSize - maskRectDataSize;
|
||||
|
||||
// Load path rects
|
||||
|
||||
@ -213,65 +213,65 @@ int SegmentMap::findNextPathRect(int srcRectIndex) {
|
||||
|
||||
for (uint rectIndex = 0; rectIndex < _pathRects.size(); ++rectIndex) {
|
||||
|
||||
if ( y1 == _pathRects[rectIndex].height + _pathRects[rectIndex].y && x1 < _pathRects[rectIndex].x + _pathRects[rectIndex].width && x2 > _pathRects[rectIndex].x ) {
|
||||
if (y1 == _pathRects[rectIndex].height + _pathRects[rectIndex].y && x1 < _pathRects[rectIndex].x + _pathRects[rectIndex].width && x2 > _pathRects[rectIndex].x) {
|
||||
ny = y1;
|
||||
|
||||
LABEL_28:
|
||||
if ( x1 >= _pathRects[rectIndex].x ) {
|
||||
if (x1 >= _pathRects[rectIndex].x) {
|
||||
nx1 = x1;
|
||||
} else {
|
||||
nx1 = _pathRects[rectIndex].x;
|
||||
}
|
||||
if ( x2 <= _pathRects[rectIndex].x + _pathRects[rectIndex].width ) {
|
||||
if (x2 <= _pathRects[rectIndex].x + _pathRects[rectIndex].width) {
|
||||
nx2 = x2 - 1;
|
||||
} else {
|
||||
nx2 = _pathRects[rectIndex].x + _pathRects[rectIndex].width - 1;
|
||||
}
|
||||
if ( ABS(_x - nx1) >= ABS(_x - nx2) ) {
|
||||
if (ABS(_x - nx1) >= ABS(_x - nx2)) {
|
||||
nx3 = nx2 - 1;
|
||||
} else {
|
||||
nx3 = nx1;
|
||||
}
|
||||
if ( _x > nx1 && _x < nx2 ) {
|
||||
if (_x > nx1 && _x < nx2) {
|
||||
nx3 = _x;
|
||||
}
|
||||
goto LABEL_55;
|
||||
}
|
||||
if ( y2 == _pathRects[rectIndex].y && x1 < _pathRects[rectIndex].x + _pathRects[rectIndex].width && x2 > _pathRects[rectIndex].x ) {
|
||||
if (y2 == _pathRects[rectIndex].y && x1 < _pathRects[rectIndex].x + _pathRects[rectIndex].width && x2 > _pathRects[rectIndex].x) {
|
||||
ny = y2 - 1;
|
||||
goto LABEL_28;
|
||||
}
|
||||
if ( x1 == _pathRects[rectIndex].x + _pathRects[rectIndex].width && y1 < _pathRects[rectIndex].y + _pathRects[rectIndex].height && y2 > _pathRects[rectIndex].y ) {
|
||||
if (x1 == _pathRects[rectIndex].x + _pathRects[rectIndex].width && y1 < _pathRects[rectIndex].y + _pathRects[rectIndex].height && y2 > _pathRects[rectIndex].y) {
|
||||
nx3 = x1;
|
||||
} else {
|
||||
if ( x2 != _pathRects[rectIndex].x || y1 >= _pathRects[rectIndex].y + _pathRects[rectIndex].height || y2 <= _pathRects[rectIndex].y )
|
||||
if (x2 != _pathRects[rectIndex].x || y1 >= _pathRects[rectIndex].y + _pathRects[rectIndex].height || y2 <= _pathRects[rectIndex].y)
|
||||
continue;
|
||||
nx3 = x2 - 1;
|
||||
}
|
||||
if ( y1 >= _pathRects[rectIndex].y ) {
|
||||
if (y1 >= _pathRects[rectIndex].y) {
|
||||
ny3 = y1;
|
||||
} else {
|
||||
ny3 = _pathRects[rectIndex].y;
|
||||
}
|
||||
if ( y2 <= _pathRects[rectIndex].y + _pathRects[rectIndex].height ) {
|
||||
if (y2 <= _pathRects[rectIndex].y + _pathRects[rectIndex].height) {
|
||||
ny2 = y2 - 1;
|
||||
} else {
|
||||
ny2 = _pathRects[rectIndex].y + _pathRects[rectIndex].height - 1;
|
||||
}
|
||||
if ( ABS(_y - ny3) >= ABS(_y - ny2) ) {
|
||||
if (ABS(_y - ny3) >= ABS(_y - ny2)) {
|
||||
ny = ny2 - 1;
|
||||
} else {
|
||||
ny = ny3;
|
||||
}
|
||||
if ( _y > ny3 && _y < ny2 ) {
|
||||
if (_y > ny3 && _y < ny2) {
|
||||
ny = _y;
|
||||
}
|
||||
|
||||
LABEL_55:
|
||||
distance = ABS(_x - nx3) + ABS(_y - ny);
|
||||
v28 = 0;
|
||||
while ( v28 < _rectIndexArray2Count ) {
|
||||
if ( rectIndex == _rectIndexArray2[v28] ) {
|
||||
while (v28 < _rectIndexArray2Count) {
|
||||
if (rectIndex == _rectIndexArray2[v28]) {
|
||||
distance = minDistance;
|
||||
break;
|
||||
}
|
||||
@ -279,15 +279,15 @@ LABEL_55:
|
||||
}
|
||||
|
||||
v28 = 0;
|
||||
while ( v28 < _rectIndexArray1Count ) {
|
||||
if ( rectIndex == _rectIndexArray1[v28] ) {
|
||||
while (v28 < _rectIndexArray1Count) {
|
||||
if (rectIndex == _rectIndexArray1[v28]) {
|
||||
distance = minDistance;
|
||||
break;
|
||||
}
|
||||
++v28;
|
||||
}
|
||||
|
||||
if ( distance < minDistance ) {
|
||||
if (distance < minDistance) {
|
||||
result = rectIndex;
|
||||
minDistance = distance;
|
||||
_pointsArray[_pointsCount].y = ny;
|
||||
@ -321,7 +321,7 @@ void SegmentMap::findPath(int16 *pointsArray, int destX, int destY, int x, int y
|
||||
debug(0, "SegmentMap::findPath(fromX: %d; fromY: %d; toX: %d; toY: %d)", x, y, destX, destY);
|
||||
|
||||
sourceRectIndex = findPathRectAtPoint(x, y);
|
||||
if ( sourceRectIndex == -1 ) {
|
||||
if (sourceRectIndex == -1) {
|
||||
adjustPathPoint(x, y);
|
||||
x = _x;
|
||||
y = _y;
|
||||
@ -337,22 +337,22 @@ void SegmentMap::findPath(int16 *pointsArray, int destX, int destY, int x, int y
|
||||
adjustPathPoint(_x, _y);
|
||||
destRectIndex = findPathRectAtPoint(_x, _y);
|
||||
sourceRectIndex = findPathRectAtPoint(x, y);
|
||||
if ( sourceRectIndex != -1 ) {
|
||||
if ( destRectIndex != sourceRectIndex ) {
|
||||
while ( 1 ) {
|
||||
if (sourceRectIndex != -1) {
|
||||
if (destRectIndex != sourceRectIndex) {
|
||||
while (1) {
|
||||
do {
|
||||
_rectIndexArray2[_rectIndexArray2Count++] = sourceRectIndex;
|
||||
sourceRectIndex = findNextPathRect(sourceRectIndex);
|
||||
_pointsCount++;
|
||||
} while ( sourceRectIndex != -1 && sourceRectIndex != destRectIndex );
|
||||
if ( sourceRectIndex != -1 && sourceRectIndex == destRectIndex )
|
||||
} while (sourceRectIndex != -1 && sourceRectIndex != destRectIndex);
|
||||
if (sourceRectIndex != -1 && sourceRectIndex == destRectIndex)
|
||||
break;
|
||||
_rectIndexArray1[_rectIndexArray1Count++] = _rectIndexArray2[--_rectIndexArray2Count];
|
||||
_pointsCount -= 2;
|
||||
sourceRectIndex = _rectIndexArray2[--_rectIndexArray2Count];
|
||||
}
|
||||
sourceRectIndex = 0;
|
||||
while ( sourceRectIndex < _pointsCount ) {
|
||||
while (sourceRectIndex < _pointsCount) {
|
||||
pointsArray[pointsCount++] = _pointsArray[sourceRectIndex].y;
|
||||
pointsArray[pointsCount++] = _pointsArray[sourceRectIndex].x;
|
||||
index++;
|
||||
@ -375,9 +375,9 @@ void SegmentMap::findPath(int16 *pointsArray, int destX, int destY, int x, int y
|
||||
ld.pitch = _vm->_sceneWidth;
|
||||
ld.surf = _vm->_screen->_backScreen;
|
||||
for (int16 i = 0; i < pointsArray[1] * 2; i+=2) {
|
||||
debug(0, "x = %d; y = %d", pointsArray[3+i], pointsArray[2+i]);
|
||||
Graphics::drawLine(sx, sy, pointsArray[3+i], pointsArray[2+i], 0xFF, plotProc, &ld);
|
||||
sx = pointsArray[3+i];
|
||||
debug(0, "x = %d; y = %d", pointsArray[3+i], pointsArray[2+i]);
|
||||
Graphics::drawLine(sx, sy, pointsArray[3+i], pointsArray[2+i], 0xFF, plotProc, &ld);
|
||||
sx = pointsArray[3+i];
|
||||
sy = pointsArray[2+i];
|
||||
}
|
||||
*/
|
||||
@ -393,7 +393,7 @@ int8 SegmentMap::getScalingAtPoint(int16 x, int16 y) {
|
||||
char topScaling = (char)_infoRects[i].b;
|
||||
char bottomScaling = (char)_infoRects[i].c;
|
||||
if (y - _infoRects[i].y > 0) {
|
||||
scaling = (ABS(y - _infoRects[i].y) * (bottomScaling - topScaling) / _infoRects[i].height) + topScaling;
|
||||
scaling = (ABS(y - _infoRects[i].y) * (bottomScaling - topScaling) / _infoRects[i].height) + topScaling;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -422,23 +422,23 @@ void SegmentMap::restoreMasksBySprite(SpriteDrawItem *sprite) {
|
||||
for (uint i = 0; i < _maskRects.size(); i++) {
|
||||
|
||||
#if 0
|
||||
if ( *(__int16 *)((char *)&spriteDrawList[0].y2 + v5) <= (unsigned __int16)v3->ybottom )
|
||||
{
|
||||
if ( (unsigned __int16)(*(__int16 *)((char *)&spriteDrawList[0].height + v5)
|
||||
+ *(__int16 *)((char *)&spriteDrawList[0].y + v5)) > v3->y )
|
||||
{
|
||||
if ( (unsigned __int16)(v3->height + v3->y) > *(__int16 *)((char *)&spriteDrawList[0].y + v5) )
|
||||
{
|
||||
if ( (unsigned __int16)(*(__int16 *)((char *)&spriteDrawList[0].width + v5)
|
||||
+ *(__int16 *)((char *)&spriteDrawList[0].x + v5)) > v3->x )
|
||||
{
|
||||
if ( (unsigned __int16)(v3->width + v3->x) > *(__int16 *)((char *)&spriteDrawList[0].x + v5) )
|
||||
{
|
||||
if ( *(__int16 *)((char *)&spriteDrawList[0].y2 + v5) <= (unsigned __int16)v3->ybottom )
|
||||
{
|
||||
if ( (unsigned __int16)(*(__int16 *)((char *)&spriteDrawList[0].height + v5)
|
||||
+ *(__int16 *)((char *)&spriteDrawList[0].y + v5)) > v3->y )
|
||||
{
|
||||
if ( (unsigned __int16)(v3->height + v3->y) > *(__int16 *)((char *)&spriteDrawList[0].y + v5) )
|
||||
{
|
||||
if ( (unsigned __int16)(*(__int16 *)((char *)&spriteDrawList[0].width + v5)
|
||||
+ *(__int16 *)((char *)&spriteDrawList[0].x + v5)) > v3->x )
|
||||
{
|
||||
if ( (unsigned __int16)(v3->width + v3->x) > *(__int16 *)((char *)&spriteDrawList[0].x + v5) )
|
||||
{
|
||||
|
||||
#endif
|
||||
|
||||
if (sprite->ybottom <= _maskRects[i].ybottom) {
|
||||
restoreMask(i);
|
||||
if (sprite->ybottom <= _maskRects[i].ybottom) {
|
||||
restoreMask(i);
|
||||
}
|
||||
}
|
||||
|
||||
@ -456,63 +456,63 @@ void SegmentMap::restoreMask(int16 index) {
|
||||
int16 height = maskRect->height;
|
||||
byte *mask = _maskRectData + maskRect->maskOffset;
|
||||
|
||||
debug(0, "SegmentMap::restoreMask() screenX = %d; screenY = %d; maskX = %d; maskY = %d",
|
||||
debug(0, "SegmentMap::restoreMask() screenX = %d; screenY = %d; maskX = %d; maskY = %d",
|
||||
x, y, maskRect->x, maskRect->y);
|
||||
|
||||
// Not on screen, skip
|
||||
if (x + width < 0 || y + height < 0 || x >= 640 || y >= _vm->_cameraHeight)
|
||||
return;
|
||||
return;
|
||||
|
||||
if (x < 0) {
|
||||
skipX = -x;
|
||||
x = 0;
|
||||
skipX = -x;
|
||||
x = 0;
|
||||
}
|
||||
|
||||
if (y < 0) {
|
||||
int16 skipY = -y;
|
||||
int16 skipY = -y;
|
||||
for (int16 h = 0; h < skipY; h++) {
|
||||
int16 w = width;
|
||||
while (w > 0) {
|
||||
int16 w = width;
|
||||
while (w > 0) {
|
||||
w -= (*mask++) & 0x7F;
|
||||
}
|
||||
}
|
||||
y = 0;
|
||||
height -= skipY;
|
||||
maskY += skipY;
|
||||
y = 0;
|
||||
height -= skipY;
|
||||
maskY += skipY;
|
||||
}
|
||||
|
||||
if (x + width >= 640) {
|
||||
width -= x + width - 640;
|
||||
width -= x + width - 640;
|
||||
}
|
||||
|
||||
if (y + height >= _vm->_cameraHeight) {
|
||||
height -= y + height - _vm->_cameraHeight;
|
||||
height -= y + height - _vm->_cameraHeight;
|
||||
}
|
||||
|
||||
byte *backScreen = _vm->_screen->_backScreen + maskX + (maskY * _vm->_sceneWidth);
|
||||
byte *frontScreen = _vm->_screen->_frontScreen + x + (y * 640);
|
||||
|
||||
for (int16 h = 0; h < height; h++) {
|
||||
byte *src = backScreen;
|
||||
byte *dst = frontScreen;
|
||||
byte maskLine[640], *maskLineP = maskLine;
|
||||
|
||||
int16 w = width;
|
||||
while (w > 0) {
|
||||
byte m = *mask++;
|
||||
byte count = m & 0x7F;
|
||||
if (m & 0x80)
|
||||
byte *src = backScreen;
|
||||
byte *dst = frontScreen;
|
||||
byte maskLine[640], *maskLineP = maskLine;
|
||||
|
||||
int16 w = width;
|
||||
while (w > 0) {
|
||||
byte m = *mask++;
|
||||
byte count = m & 0x7F;
|
||||
if (m & 0x80)
|
||||
memset(maskLineP, 1, count);
|
||||
else
|
||||
memset(maskLineP, 0, count);
|
||||
memset(maskLineP, 0, count);
|
||||
maskLineP += count;
|
||||
w -= count;
|
||||
}
|
||||
|
||||
src += skipX;
|
||||
for (int16 c = skipX; c < width; c++) {
|
||||
if (maskLine[c] == 1)
|
||||
*dst = *src;
|
||||
if (maskLine[c] == 1)
|
||||
*dst = *src;
|
||||
dst++;
|
||||
src++;
|
||||
}
|
||||
|
@ -58,17 +58,17 @@ struct ScriptWalk {
|
||||
|
||||
class SegmentMap {
|
||||
public:
|
||||
SegmentMap(ToltecsEngine *vm);
|
||||
~SegmentMap();
|
||||
SegmentMap(ToltecsEngine *vm);
|
||||
~SegmentMap();
|
||||
|
||||
void load(byte *source);
|
||||
|
||||
int findPathRectAtPoint(int x, int y);
|
||||
void adjustPathPoint(int x, int y);
|
||||
|
||||
void findPath(int16 *pointsArray, int destX, int destY, int x, int y);
|
||||
|
||||
int8 getScalingAtPoint(int16 x, int16 y);
|
||||
|
||||
int findPathRectAtPoint(int x, int y);
|
||||
void adjustPathPoint(int x, int y);
|
||||
|
||||
void findPath(int16 *pointsArray, int destX, int destY, int x, int y);
|
||||
|
||||
int8 getScalingAtPoint(int16 x, int16 y);
|
||||
void getRgbModifiertAtPoint(int16 x, int16 y, int16 id, byte &r, byte &g, byte &b);
|
||||
|
||||
void restoreMasksBySprite(SpriteDrawItem *sprite);
|
||||
@ -99,20 +99,20 @@ public: // for debugging purposes
|
||||
};
|
||||
|
||||
struct PathPoint {
|
||||
int16 y, x;
|
||||
int16 y, x;
|
||||
};
|
||||
|
||||
typedef Common::Array<SegmapMaskRect> SegmapMaskRectArray;
|
||||
typedef Common::Array<SegmapPathRect> SegmapPathRectArray;
|
||||
typedef Common::Array<SegmapInfoRect> SegmapInfoRectArray;
|
||||
|
||||
ToltecsEngine *_vm;
|
||||
|
||||
SegmapMaskRectArray _maskRects;
|
||||
byte *_maskRectData;
|
||||
ToltecsEngine *_vm;
|
||||
|
||||
SegmapPathRectArray _pathRects;
|
||||
SegmapInfoRectArray _infoRects;
|
||||
SegmapMaskRectArray _maskRects;
|
||||
byte *_maskRectData;
|
||||
|
||||
SegmapPathRectArray _pathRects;
|
||||
SegmapInfoRectArray _infoRects;
|
||||
|
||||
int _rectIndexArray1[1000];
|
||||
uint _rectIndexArray1Count;
|
||||
@ -123,10 +123,10 @@ public: // for debugging purposes
|
||||
PathPoint _pointsArray[1000];
|
||||
int16 _pointsCount;
|
||||
|
||||
int _x, _y;
|
||||
|
||||
int findNextPathRect(int srcRectIndex);
|
||||
|
||||
int _x, _y;
|
||||
|
||||
int findNextPathRect(int srcRectIndex);
|
||||
|
||||
};
|
||||
|
||||
} // End of namespace Toltecs
|
||||
|
@ -86,8 +86,8 @@ int ToltecsEngine::init() {
|
||||
|
||||
int ToltecsEngine::go() {
|
||||
|
||||
_system->setFeatureState(OSystem::kFeatureAutoComputeDirtyRects, true);
|
||||
|
||||
_system->setFeatureState(OSystem::kFeatureAutoComputeDirtyRects, true);
|
||||
|
||||
_quitGame = false;
|
||||
_counter01 = 0;
|
||||
_counter02 = 0;
|
||||
@ -108,7 +108,7 @@ int ToltecsEngine::go() {
|
||||
_doSpeech = true;
|
||||
_doText = true;
|
||||
|
||||
_walkSpeedY = 5;
|
||||
_walkSpeedY = 5;
|
||||
_walkSpeedX = 1;
|
||||
|
||||
_arc = new ArchiveReader();
|
||||
@ -124,8 +124,8 @@ int ToltecsEngine::go() {
|
||||
_segmap = new SegmentMap(this);
|
||||
_input = new Input(this);
|
||||
|
||||
_system->showMouse(true);
|
||||
|
||||
_system->showMouse(true);
|
||||
|
||||
#if 1
|
||||
|
||||
_script->loadScript(0, 0);
|
||||
@ -151,7 +151,7 @@ void ToltecsEngine::loadScene(uint resIndex) {
|
||||
byte *scene = _res->load(resIndex);
|
||||
|
||||
uint32 imageSize = READ_LE_UINT32(scene);
|
||||
_sceneResIndex = resIndex;
|
||||
_sceneResIndex = resIndex;
|
||||
_sceneHeight = READ_LE_UINT16(scene + 4);
|
||||
_sceneWidth = READ_LE_UINT16(scene + 6);
|
||||
|
||||
@ -192,10 +192,10 @@ void ToltecsEngine::updateScreen() {
|
||||
srcp += _sceneWidth;
|
||||
}
|
||||
|
||||
_screen->drawSprites();
|
||||
_screen->clearSprites();
|
||||
_screen->drawSprites();
|
||||
_screen->clearSprites();
|
||||
|
||||
_screen->drawTalkTextItems();
|
||||
_screen->drawTalkTextItems();
|
||||
|
||||
_system->copyRectToScreen((const byte *)_screen->_frontScreen, 640, 0, 0, 640, 400);
|
||||
_system->updateScreen();
|
||||
@ -208,10 +208,10 @@ void ToltecsEngine::setCamera(int16 x, int16 y) {
|
||||
// TODO font_sub_4B5BB()
|
||||
|
||||
if (x > _sceneWidth)
|
||||
x = _sceneWidth;
|
||||
x = _sceneWidth;
|
||||
|
||||
if (y > _sceneHeight - _cameraHeight)
|
||||
y = _sceneHeight - _cameraHeight;
|
||||
y = _sceneHeight - _cameraHeight;
|
||||
|
||||
// TODO DirtyRect clearing stuff
|
||||
|
||||
@ -321,28 +321,28 @@ void ToltecsEngine::talk(int16 slotIndex, int16 slotOffset) {
|
||||
|
||||
while (*scanData < 0xF0) {
|
||||
|
||||
if (*scanData == 0x19) {
|
||||
scanData++;
|
||||
if (*scanData == 0x19) {
|
||||
scanData++;
|
||||
} else if (*scanData == 0x14) {
|
||||
scanData++;
|
||||
scanData++;
|
||||
} else if (*scanData == 0x0A) {
|
||||
scanData += 4;
|
||||
scanData += 4;
|
||||
} else if (*scanData < 0x0A) {
|
||||
scanData++;
|
||||
scanData++;
|
||||
}
|
||||
|
||||
scanData++;
|
||||
scanData++;
|
||||
}
|
||||
|
||||
if (*scanData == 0xFE) {
|
||||
if (_doSpeech) {
|
||||
int16 resIndex = READ_LE_UINT16(scanData + 1);
|
||||
debug(0, "ToltecsEngine::talk() playSound(resIndex: %d)", resIndex);
|
||||
if (_doSpeech) {
|
||||
int16 resIndex = READ_LE_UINT16(scanData + 1);
|
||||
debug(0, "ToltecsEngine::talk() playSound(resIndex: %d)", resIndex);
|
||||
}
|
||||
if (_doText) {
|
||||
_screen->updateTalkText(slotIndex, slotOffset);
|
||||
_screen->updateTalkText(slotIndex, slotOffset);
|
||||
} else {
|
||||
// TODO: font_sub_4B3E2
|
||||
// TODO: font_sub_4B3E2
|
||||
}
|
||||
} else {
|
||||
_screen->updateTalkText(slotIndex, slotOffset);
|
||||
@ -358,9 +358,9 @@ void ToltecsEngine::playText(int16 slotIndex, int16 slotOffset) {
|
||||
|
||||
Common::String str;
|
||||
while (*textData < 0xF0) {
|
||||
if (*textData >= 32)
|
||||
str += (char)*textData;
|
||||
textData++;
|
||||
if (*textData >= 32)
|
||||
str += (char)*textData;
|
||||
textData++;
|
||||
}
|
||||
|
||||
debug(0, "ToltecsEngine::playText() [%s]", str.c_str());
|
||||
@ -387,21 +387,21 @@ void ToltecsEngine::walk(byte *walkData) {
|
||||
walkInfo.scaling = -_segmap->getScalingAtPoint(walkInfo.x, walkInfo.y);
|
||||
|
||||
if (walkInfo.y1 < walkInfo.y2)
|
||||
ystep = -1;
|
||||
ystep = -1;
|
||||
else
|
||||
ystep = 1;
|
||||
ydelta = ABS(walkInfo.y1 - walkInfo.y2) * _walkSpeedY;
|
||||
|
||||
if (walkInfo.x1 < walkInfo.x2)
|
||||
xstep = -1;
|
||||
xstep = -1;
|
||||
else
|
||||
xstep = 1;
|
||||
xdelta = ABS(walkInfo.x1 - walkInfo.x2) * _walkSpeedX;
|
||||
|
||||
debug(0, "ToltecsEngine::walk() xdelta = %d; ydelta = %d", xdelta, ydelta);
|
||||
debug(0, "ToltecsEngine::walk() xdelta = %d; ydelta = %d", xdelta, ydelta);
|
||||
|
||||
if (xdelta > ydelta)
|
||||
SWAP(xdelta, ydelta);
|
||||
SWAP(xdelta, ydelta);
|
||||
|
||||
v8 = 100 * xdelta;
|
||||
if (v8 != 0) {
|
||||
@ -414,8 +414,8 @@ void ToltecsEngine::walk(byte *walkData) {
|
||||
}
|
||||
|
||||
if (ydelta > ABS(walkInfo.x1 - walkInfo.x2) * _walkSpeedX) {
|
||||
v10 = 100 - walkInfo.scaling;
|
||||
v11 = v8;
|
||||
v10 = 100 - walkInfo.scaling;
|
||||
v11 = v8;
|
||||
} else {
|
||||
v10 = v8;
|
||||
v11 = 100 - walkInfo.scaling;
|
||||
@ -459,18 +459,18 @@ int16 ToltecsEngine::findRectAtPoint(byte *rectData, int16 x, int16 y, int16 ind
|
||||
rectData += index * itemSize;
|
||||
|
||||
while (1) {
|
||||
int16 rectY = READ_LE_UINT16(rectData);
|
||||
if (rectY == -10)
|
||||
break;
|
||||
int16 rectX = READ_LE_UINT16(rectData + 2);
|
||||
int16 rectH = READ_LE_UINT16(rectData + 4);
|
||||
int16 rectW = READ_LE_UINT16(rectData + 6);
|
||||
|
||||
debug(0, "x = %d; y = %d; x1 = %d; y2 = %d; w = %d; h = %d",
|
||||
x, y, rectX, rectY, rectW, rectH);
|
||||
|
||||
if (x >= rectX && x <= rectX + rectW && y >= rectY && y <= rectY + rectH) {
|
||||
return index;
|
||||
int16 rectY = READ_LE_UINT16(rectData);
|
||||
if (rectY == -10)
|
||||
break;
|
||||
int16 rectX = READ_LE_UINT16(rectData + 2);
|
||||
int16 rectH = READ_LE_UINT16(rectData + 4);
|
||||
int16 rectW = READ_LE_UINT16(rectData + 6);
|
||||
|
||||
debug(0, "x = %d; y = %d; x1 = %d; y2 = %d; w = %d; h = %d",
|
||||
x, y, rectX, rectY, rectW, rectH);
|
||||
|
||||
if (x >= rectX && x <= rectX + rectW && y >= rectY && y <= rectY + rectH) {
|
||||
return index;
|
||||
}
|
||||
index++;
|
||||
rectData += itemSize;
|
||||
|
@ -79,7 +79,7 @@ public:
|
||||
|
||||
void updateScreen();
|
||||
|
||||
void setCamera(int16 x, int16 y);
|
||||
void setCamera(int16 x, int16 y);
|
||||
void setCameraTop(int16 top);
|
||||
void scrollCameraUp(int16 delta);
|
||||
void scrollCameraDown(int16 delta);
|
||||
|
Loading…
Reference in New Issue
Block a user