Initial commit
This commit is contained in:
93
engines/got/gfx/font.cpp
Normal file
93
engines/got/gfx/font.cpp
Normal file
@@ -0,0 +1,93 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "got/gfx/font.h"
|
||||
#include "common/file.h"
|
||||
#include "got/gfx/gfx_pics.h"
|
||||
|
||||
namespace Got {
|
||||
namespace Gfx {
|
||||
|
||||
const byte DIALOG_COLOR[] = {14, 54, 120, 138, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
|
||||
void Font::load() {
|
||||
Common::File f;
|
||||
if (!f.open("TEXT"))
|
||||
error("Could not open font");
|
||||
|
||||
_font.resize(f.size() / 72 + 32);
|
||||
|
||||
for (uint i = 32; i < _font.size(); ++i) {
|
||||
byte buff[8 * 9];
|
||||
f.read(buff, 8 * 9);
|
||||
|
||||
_font[i].create(8, 9);
|
||||
convertPaneDataToSurface(buff, _font[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void Font::drawString(Graphics::ManagedSurface *src, const Common::Point &pos, const Common::String &text, int color) {
|
||||
const char *string = text.c_str();
|
||||
Common::Point pt = pos;
|
||||
|
||||
while (*string) {
|
||||
char ch = *string++;
|
||||
if (ch == '~' && Common::isXDigit(*string)) {
|
||||
ch = *string++;
|
||||
if (Common::isDigit(ch)) {
|
||||
ch -= 48;
|
||||
} else {
|
||||
ch = toupper(ch) - 55;
|
||||
}
|
||||
color = DIALOG_COLOR[(byte)ch];
|
||||
continue;
|
||||
}
|
||||
if (ch > 31 && ch < 127)
|
||||
drawChar(src, ch, pt.x, pt.y, color);
|
||||
|
||||
pt.x += 8;
|
||||
}
|
||||
}
|
||||
|
||||
void Font::drawChar(Graphics::Surface *dst, const uint32 chr, const int x, const int y, const uint32 color) const {
|
||||
// Character drawing is done twice in the original:
|
||||
// first at y + 1 with color 0, then at y with the given color
|
||||
rawDrawChar(dst, chr, x, y + 1, 0);
|
||||
rawDrawChar(dst, chr, x, y, color);
|
||||
}
|
||||
|
||||
void Font::rawDrawChar(Graphics::Surface *dst, const uint32 chr, const int x, const int y, const uint32 color) const {
|
||||
const Graphics::ManagedSurface &glyph = _font[chr];
|
||||
|
||||
for (int yp = 0; yp < glyph.h; ++yp) {
|
||||
const int startY = y + yp;
|
||||
const byte *srcP = (const byte *)glyph.getBasePtr(0, yp);
|
||||
byte *destP = (byte *)dst->getBasePtr(x, startY);
|
||||
|
||||
for (int xp = 0; xp < glyph.w; ++xp, ++srcP, ++destP) {
|
||||
if (*srcP)
|
||||
*destP = color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Gfx
|
||||
} // namespace Got
|
||||
63
engines/got/gfx/font.h
Normal file
63
engines/got/gfx/font.h
Normal file
@@ -0,0 +1,63 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef GOT_GFX_FONT_H
|
||||
#define GOT_GFX_FONT_H
|
||||
|
||||
#include "common/array.h"
|
||||
#include "graphics/font.h"
|
||||
#include "graphics/managed_surface.h"
|
||||
|
||||
namespace Got {
|
||||
namespace Gfx {
|
||||
|
||||
extern const byte DIALOG_COLOR[];
|
||||
|
||||
class Font : public Graphics::Font {
|
||||
private:
|
||||
Common::Array<Graphics::ManagedSurface> _font;
|
||||
|
||||
public:
|
||||
void load();
|
||||
|
||||
int getFontHeight() const override {
|
||||
return 9;
|
||||
}
|
||||
int getMaxCharWidth() const override {
|
||||
return 8;
|
||||
}
|
||||
int getCharWidth(uint32 chr) const override {
|
||||
return 8;
|
||||
}
|
||||
void drawChar(Graphics::Surface *dst, uint32 chr, int x, int y, uint32 color) const override;
|
||||
void drawChar(Graphics::ManagedSurface *dst, uint32 chr, int x, int y, uint32 color) const override {
|
||||
Graphics::Font::drawChar(dst, chr, x, y, color);
|
||||
}
|
||||
void rawDrawChar(Graphics::Surface *dst, uint32 chr, int x, int y, uint32 color) const;
|
||||
|
||||
void drawString(Graphics::ManagedSurface *src, const Common::Point &pos,
|
||||
const Common::String &text, int color);
|
||||
};
|
||||
|
||||
} // namespace Gfx
|
||||
} // namespace Got
|
||||
|
||||
#endif
|
||||
146
engines/got/gfx/gfx_chunks.cpp
Normal file
146
engines/got/gfx/gfx_chunks.cpp
Normal file
@@ -0,0 +1,146 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "got/gfx/gfx_chunks.h"
|
||||
#include "common/file.h"
|
||||
#include "got/utils/compression.h"
|
||||
|
||||
namespace Got {
|
||||
namespace Gfx {
|
||||
|
||||
void GraphicChunk::load(Common::SeekableReadStream *src, const byte *data) {
|
||||
_compressMode = src->readUint16LE();
|
||||
_offset = src->readUint32LE();
|
||||
_uncompressedSize = src->readUint16LE();
|
||||
_compressedSize = src->readUint16LE();
|
||||
_width = src->readUint16LE();
|
||||
_height = src->readUint16LE();
|
||||
|
||||
_data = data + _offset;
|
||||
}
|
||||
|
||||
void GraphicChunk::enable() {
|
||||
// Data already uncompressed, nothing further needed
|
||||
if (_compressMode == UNCOMPRESSED)
|
||||
return;
|
||||
|
||||
_decompressedData.resize(_uncompressedSize);
|
||||
|
||||
switch (_compressMode) {
|
||||
case LZSS:
|
||||
decompressLzss(_data, &_decompressedData[0], _uncompressedSize);
|
||||
break;
|
||||
|
||||
case RLE:
|
||||
decompressRle(_data, &_decompressedData[0], _uncompressedSize);
|
||||
break;
|
||||
|
||||
default:
|
||||
error("Unknown compression type %d", _compressMode);
|
||||
}
|
||||
|
||||
// Mark the entry as uncompressed, and point to the data
|
||||
_compressMode = UNCOMPRESSED;
|
||||
_data = &_decompressedData[0];
|
||||
}
|
||||
|
||||
GraphicChunk::operator const Graphics::ManagedSurface() const {
|
||||
Graphics::ManagedSurface s;
|
||||
s.w = s.pitch = _width;
|
||||
s.h = _height;
|
||||
s.format = Graphics::PixelFormat::createFormatCLUT8();
|
||||
s.setPixels(const_cast<byte *>(_data));
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
GraphicChunk::operator const Gfx::Palette63() const {
|
||||
return Gfx::Palette63(_data);
|
||||
}
|
||||
|
||||
void GfxChunks::load() {
|
||||
// Get stream to access images
|
||||
Common::SeekableReadStream *f = getStream();
|
||||
|
||||
#if 0
|
||||
Common::DumpFile df;
|
||||
if (df.open("got.gfx")) {
|
||||
df.writeStream(f);
|
||||
f->seek(0);
|
||||
}
|
||||
df.close();
|
||||
#endif
|
||||
|
||||
// Keep a copy in memory for decoding images as needed
|
||||
_data = new byte[f->size()];
|
||||
f->read(_data, f->size());
|
||||
|
||||
// Set the number of images
|
||||
f->seek(0);
|
||||
_chunks.resize(f->readUint16LE());
|
||||
|
||||
// Iterate through loading the image metrics
|
||||
for (uint i = 0; i < _chunks.size(); ++i)
|
||||
_chunks[i].load(f, _data);
|
||||
|
||||
// Close the file
|
||||
delete f;
|
||||
|
||||
// Decompress two ranges of chunks by default
|
||||
for (uint i = 0; i < 34; ++i)
|
||||
_chunks[i].enable();
|
||||
}
|
||||
|
||||
GraphicChunk &GfxChunks::operator[](uint idx) {
|
||||
GraphicChunk &chunk = _chunks[idx];
|
||||
chunk.enable();
|
||||
|
||||
return chunk;
|
||||
}
|
||||
|
||||
Common::SeekableReadStream *GfxChunks::getStream() const {
|
||||
// Check for stand-alone graphics file
|
||||
Common::File *f = new Common::File;
|
||||
if (f->open("got.gfx"))
|
||||
return f;
|
||||
delete f;
|
||||
|
||||
// Check for got.exe executable
|
||||
Common::File fExe;
|
||||
if (!fExe.open("got.exe"))
|
||||
error("Could not locate got graphics");
|
||||
|
||||
if (fExe.readUint16BE() != MKTAG16('M', 'Z'))
|
||||
error("Invalid exe header");
|
||||
|
||||
const int lastPageSize = fExe.readUint16LE();
|
||||
const int totalPages = fExe.readUint16LE();
|
||||
const int offset = lastPageSize ? ((totalPages - 1) << 9) + lastPageSize : totalPages << 9;
|
||||
|
||||
fExe.seek(offset);
|
||||
if (fExe.readUint16BE() != MKTAG16(0xe2, 0x4a))
|
||||
error("Invalid embedded graphics signature");
|
||||
|
||||
return fExe.readStream(fExe.size() - fExe.pos());
|
||||
}
|
||||
|
||||
} // namespace Gfx
|
||||
} // namespace Got
|
||||
109
engines/got/gfx/gfx_chunks.h
Normal file
109
engines/got/gfx/gfx_chunks.h
Normal file
@@ -0,0 +1,109 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef GOT_GFX_GFX_CHUNKS_H
|
||||
#define GOT_GFX_GFX_CHUNKS_H
|
||||
|
||||
#include "common/stream.h"
|
||||
#include "got/gfx/palette.h"
|
||||
#include "graphics/managed_surface.h"
|
||||
|
||||
namespace Got {
|
||||
namespace Gfx {
|
||||
|
||||
class GfxChunks;
|
||||
|
||||
enum CompressMode { UNCOMPRESSED = 0,
|
||||
LZSS = 1,
|
||||
RLE = 2 };
|
||||
|
||||
struct GraphicChunk {
|
||||
private:
|
||||
Common::Array<byte> _decompressedData;
|
||||
|
||||
public:
|
||||
int _compressMode = UNCOMPRESSED;
|
||||
uint32 _offset = 0;
|
||||
uint16 _uncompressedSize = 0;
|
||||
uint16 _compressedSize = 0;
|
||||
uint16 _width = 0;
|
||||
uint16 _height = 0;
|
||||
|
||||
const byte *_data = nullptr;
|
||||
|
||||
/**
|
||||
* Load the overall info for a chunk
|
||||
*/
|
||||
void load(Common::SeekableReadStream *src, const byte *data);
|
||||
|
||||
/**
|
||||
* Handles any decompression necessary for the entry
|
||||
*/
|
||||
void enable();
|
||||
|
||||
/**
|
||||
* Provides a managed surface wrapper for raw data
|
||||
*/
|
||||
operator const Graphics::ManagedSurface() const;
|
||||
|
||||
/**
|
||||
* Provides a data pointer, used for getting palette chunks
|
||||
*/
|
||||
operator const Gfx::Palette63() const;
|
||||
};
|
||||
|
||||
/**
|
||||
* Interface for accessing the graphics.got file.
|
||||
* In the release, this is embedded in the executable starting
|
||||
* at offset 18af2h onwards. The preceding two bytes should be E2 4A.
|
||||
* The collection is mostly images, but there are some palettes and
|
||||
* sounds included as well.
|
||||
*/
|
||||
class GfxChunks {
|
||||
private:
|
||||
Common::Array<GraphicChunk> _chunks;
|
||||
byte *_data = nullptr;
|
||||
|
||||
/**
|
||||
* Opens the graphics for access
|
||||
*/
|
||||
Common::SeekableReadStream *getStream() const;
|
||||
|
||||
public:
|
||||
~GfxChunks() {
|
||||
delete[] _data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the graphic data
|
||||
*/
|
||||
void load();
|
||||
|
||||
/**
|
||||
* Access a chunk
|
||||
*/
|
||||
GraphicChunk &operator[](uint idx);
|
||||
};
|
||||
|
||||
} // namespace Gfx
|
||||
} // namespace Got
|
||||
|
||||
#endif
|
||||
117
engines/got/gfx/gfx_pics.cpp
Normal file
117
engines/got/gfx/gfx_pics.cpp
Normal file
@@ -0,0 +1,117 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "got/gfx/gfx_pics.h"
|
||||
#include "common/file.h"
|
||||
#include "got/utils/file.h"
|
||||
|
||||
namespace Got {
|
||||
namespace Gfx {
|
||||
|
||||
void convertPaneDataToSurface(const byte *src, Graphics::ManagedSurface &surf) {
|
||||
surf.setTransparentColor(0);
|
||||
|
||||
// It's split into 4 panes per 4 pixels, so we need
|
||||
// to juggle the pixels into their correct order
|
||||
for (int plane = 0; plane < 4; ++plane) {
|
||||
for (int y = 0; y < surf.h; ++y) {
|
||||
byte *dest = (byte *)surf.getBasePtr(plane, y);
|
||||
|
||||
for (int x = 0; x < (surf.w / 4); ++x, dest += 4, ++src) {
|
||||
// For some reason, both '0' and '15' are both hard-coded
|
||||
// as transparent colors in the graphics drawing. Simplify
|
||||
// this for ScummVM by changing all 15's to 0
|
||||
*dest = (*src == 15) ? 0 : *src;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GfxPics::clear() {
|
||||
delete[] _array;
|
||||
_array = nullptr;
|
||||
}
|
||||
|
||||
void GfxPics::resize(uint newSize) {
|
||||
assert(!_array); // Don't support multiple resizes
|
||||
_array = new Graphics::ManagedSurface[newSize];
|
||||
_size = newSize;
|
||||
}
|
||||
|
||||
void GfxPics::load(const Common::String &name, int blockSize) {
|
||||
File f(name);
|
||||
|
||||
// Set up array of images
|
||||
clear();
|
||||
if (blockSize == -1) {
|
||||
// Only a single image
|
||||
resize(1);
|
||||
blockSize = f.size();
|
||||
} else {
|
||||
resize(f.size() / blockSize);
|
||||
}
|
||||
|
||||
byte *buff = new byte[blockSize];
|
||||
|
||||
for (uint idx = 0; idx < size(); ++idx) {
|
||||
int w = f.readUint16LE() * 4;
|
||||
int h = f.readUint16LE();
|
||||
f.skip(2); // Unused transparent color. It's always 15
|
||||
f.read(buff, blockSize - 6);
|
||||
|
||||
Graphics::ManagedSurface &s = (*this)[idx];
|
||||
s.create(w, h);
|
||||
|
||||
convertPaneDataToSurface(buff, s);
|
||||
}
|
||||
|
||||
delete[] buff;
|
||||
}
|
||||
|
||||
GfxPics &GfxPics::operator=(const GfxPics &src) {
|
||||
clear();
|
||||
resize(src._size);
|
||||
|
||||
for (size_t i = 0; i < _size; ++i)
|
||||
_array[i].copyFrom(src._array[i]);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
void BgPics::setArea(int area) {
|
||||
_area = area;
|
||||
load();
|
||||
}
|
||||
|
||||
void BgPics::load() {
|
||||
const Common::String name = Common::String::format("BPICS%d", _area);
|
||||
GfxPics::load(name, 262);
|
||||
|
||||
if (_area == 2) {
|
||||
// FIXME: Background tile 0xbe in part 2 is used for the invisible
|
||||
// maze in part 2 to get the shovel, but it's not drawing as black.
|
||||
// Manually set the transparent color for it so it's properly transparent
|
||||
(*this)[0xbe].setTransparentColor(31);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Gfx
|
||||
} // namespace Got
|
||||
98
engines/got/gfx/gfx_pics.h
Normal file
98
engines/got/gfx/gfx_pics.h
Normal file
@@ -0,0 +1,98 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef GOT_GFX_GFX_PICS_H
|
||||
#define GOT_GFX_GFX_PICS_H
|
||||
|
||||
#include "graphics/managed_surface.h"
|
||||
|
||||
namespace Got {
|
||||
namespace Gfx {
|
||||
|
||||
/**
|
||||
* The original graphics screen was set up to use 4 panes,
|
||||
* where each pane had a single pixel, repeating every 4 pixels.
|
||||
* Because of this, graphics were stored with all the data for
|
||||
* each pane one at a time. This helper methods takes care of
|
||||
* "de-paneing" the graphics into a provided surface
|
||||
*/
|
||||
extern void convertPaneDataToSurface(const byte *src, Graphics::ManagedSurface &surf);
|
||||
|
||||
class GfxPics {
|
||||
private:
|
||||
Graphics::ManagedSurface *_array = nullptr;
|
||||
size_t _size = 0;
|
||||
|
||||
protected:
|
||||
public:
|
||||
~GfxPics() {
|
||||
clear();
|
||||
}
|
||||
|
||||
void clear();
|
||||
void resize(uint newSize);
|
||||
void load(const Common::String &name, int blockSize);
|
||||
|
||||
Graphics::ManagedSurface &operator[](uint idx) {
|
||||
return _array[idx];
|
||||
}
|
||||
size_t size() const {
|
||||
return _size;
|
||||
}
|
||||
|
||||
GfxPics &operator=(const GfxPics &src);
|
||||
};
|
||||
|
||||
class BgPics : public GfxPics {
|
||||
private:
|
||||
int _area = 1;
|
||||
|
||||
public:
|
||||
void load();
|
||||
|
||||
bool getArea() const {
|
||||
return _area;
|
||||
}
|
||||
void setArea(int area);
|
||||
};
|
||||
|
||||
class Pics : public GfxPics {
|
||||
private:
|
||||
Common::String _resName;
|
||||
int _blockSize = -1;
|
||||
|
||||
public:
|
||||
Pics(const Common::String &resName, int blockSize = -1,
|
||||
bool immediateLoad = true) : _resName(resName), _blockSize(blockSize) {
|
||||
if (immediateLoad)
|
||||
load();
|
||||
}
|
||||
Pics() {}
|
||||
|
||||
void load() {
|
||||
GfxPics::load(_resName, _blockSize);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace Gfx
|
||||
} // namespace Got
|
||||
|
||||
#endif
|
||||
42
engines/got/gfx/gfx_surface.cpp
Normal file
42
engines/got/gfx/gfx_surface.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "got/gfx/gfx_surface.h"
|
||||
#include "got/vars.h"
|
||||
|
||||
namespace Got {
|
||||
namespace Gfx {
|
||||
|
||||
void GfxSurface::print(const Common::Point &pos,
|
||||
const Common::String &text, int color) {
|
||||
_G(font).drawString(this, pos, text, color);
|
||||
}
|
||||
|
||||
void GfxSurface::printChar(uint32 chr, int x, int y, uint32 color) {
|
||||
_G(font).drawChar(this, chr, x, y, color);
|
||||
}
|
||||
|
||||
void GfxSurface::rawPrintChar(uint32 chr, int x, int y, uint32 color) {
|
||||
_G(font).rawDrawChar(surfacePtr(), chr, x, y, color);
|
||||
}
|
||||
|
||||
} // namespace Gfx
|
||||
} // namespace Got
|
||||
46
engines/got/gfx/gfx_surface.h
Normal file
46
engines/got/gfx/gfx_surface.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef GOT_GFX_SURFACE_H
|
||||
#define GOT_GFX_SURFACE_H
|
||||
|
||||
#include "graphics/managed_surface.h"
|
||||
|
||||
namespace Got {
|
||||
namespace Gfx {
|
||||
|
||||
class GfxSurface : public Graphics::ManagedSurface {
|
||||
public:
|
||||
GfxSurface() : Graphics::ManagedSurface() {}
|
||||
GfxSurface(Graphics::ManagedSurface &surf, const Common::Rect &bounds) : Graphics::ManagedSurface(surf, bounds) {}
|
||||
|
||||
/**
|
||||
* Write some text to the surface
|
||||
*/
|
||||
void print(const Common::Point &pos, const Common::String &text, int color);
|
||||
void printChar(uint32 chr, int x, int y, uint32 color);
|
||||
void rawPrintChar(uint32 chr, int x, int y, uint32 color);
|
||||
};
|
||||
|
||||
} // namespace Gfx
|
||||
} // namespace Got
|
||||
|
||||
#endif
|
||||
273
engines/got/gfx/image.cpp
Normal file
273
engines/got/gfx/image.cpp
Normal file
@@ -0,0 +1,273 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "got/gfx/image.h"
|
||||
#include "common/memstream.h"
|
||||
#include "got/events.h"
|
||||
#include "got/got.h"
|
||||
#include "got/utils/file.h"
|
||||
#include "got/vars.h"
|
||||
|
||||
namespace Got {
|
||||
|
||||
static void createSurface(Graphics::ManagedSurface &s, const byte *src) {
|
||||
s.create(16, 16);
|
||||
|
||||
// Both 0 and 15 are transparent colors, so as we load the
|
||||
// surface, standard on a single color
|
||||
byte *dest = (byte *)s.getPixels();
|
||||
for (int i = 0; i < 16 * 16; ++i, ++src, ++dest)
|
||||
*dest = (*src == 15) ? 0 : *src;
|
||||
|
||||
s.setTransparentColor(0);
|
||||
}
|
||||
|
||||
void setupActor(Actor *actor, const char num, const char dir, const int x, const int y) {
|
||||
actor->_nextFrame = 0; // Next frame to be shown
|
||||
actor->_frameCount = actor->_frameSpeed;
|
||||
actor->_dir = dir; // Direction of travel
|
||||
actor->_lastDir = dir; // Last direction of travel
|
||||
if (actor->_directions == 1)
|
||||
actor->_dir = 0;
|
||||
if (actor->_directions == 2)
|
||||
actor->_dir &= 1;
|
||||
if (actor->_directions == 4 && actor->_framesPerDirection == 1) {
|
||||
actor->_dir = 0;
|
||||
actor->_nextFrame = dir;
|
||||
}
|
||||
|
||||
actor->_x = x; // Actual X coordinates
|
||||
actor->_y = y; // Actual Y coordinates
|
||||
actor->_width = 16; // Actual X coordinates
|
||||
actor->_height = 16; // Actual Y coordinates
|
||||
actor->_center = 0; // Center of object
|
||||
actor->_lastX[0] = x; // Last X coordinates on each page
|
||||
actor->_lastX[1] = x;
|
||||
actor->_lastY[0] = y; // Last Y coordinates on each page
|
||||
actor->_lastY[1] = y;
|
||||
actor->_active = true; // true=active, false=not active
|
||||
actor->_moveCountdown = 8; // Count down to movement
|
||||
actor->_vulnerableCountdown = STAMINA; // Count down to vulnerability
|
||||
actor->_shotCountdown = 20; // Count down to another shot
|
||||
actor->_currNumShots = 0; // # of shots currently on screen
|
||||
actor->_creator = 0; // which actor # created this actor
|
||||
actor->_unpauseCountdown = 0; // Pause must be 0 to move
|
||||
actor->_show = 0;
|
||||
actor->_actorNum = num;
|
||||
actor->_counter = 0;
|
||||
actor->_moveCounter = 0;
|
||||
actor->_edgeCounter = 20;
|
||||
actor->_hitThor = false;
|
||||
actor->_rand = g_engine->getRandomNumber(99);
|
||||
actor->_temp1 = 0;
|
||||
actor->_initHealth = actor->_health;
|
||||
}
|
||||
|
||||
void make_actor_surface(Actor *actor) {
|
||||
assert(actor->_directions <= 4 && actor->_framesPerDirection <= 4);
|
||||
for (int d = 0; d < actor->_directions; d++) {
|
||||
for (int f = 0; f < actor->_framesPerDirection; f++) {
|
||||
Graphics::ManagedSurface &s = actor->pic[d][f];
|
||||
const byte *src = &_G(tmpBuff[256 * ((d * 4) + f)]);
|
||||
createSurface(s, src);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int loadStandardActors() {
|
||||
loadActor(0, 100 + _G(thorInfo)._armor); // Load Thor
|
||||
_G(actor[0]).loadFixed(_G(tmpBuff) + 5120);
|
||||
setupActor(&_G(actor[0]), 0, 0, 100, 100);
|
||||
_G(thor) = &_G(actor[0]);
|
||||
|
||||
make_actor_surface(&_G(actor[0]));
|
||||
|
||||
_G(thorX1) = _G(thor)->_x + 2;
|
||||
_G(thorY1) = _G(thor)->_y + 2;
|
||||
_G(thorX2) = _G(thor)->_x + 14;
|
||||
_G(thorY2) = _G(thor)->_y + 14;
|
||||
|
||||
loadActor(0, 103 + _G(thorInfo)._armor); // Load hammer
|
||||
_G(actor[1]).loadFixed(_G(tmpBuff) + 5120);
|
||||
setupActor(&_G(actor[1]), 1, 0, 100, 100);
|
||||
_G(actor[1])._active = false;
|
||||
_G(hammer) = &_G(actor[1]);
|
||||
|
||||
make_actor_surface(&_G(actor[1]));
|
||||
|
||||
// Load sparkle
|
||||
loadActor(0, 106);
|
||||
_G(sparkle).loadFixed(_G(tmpBuff) + 5120);
|
||||
setupActor(&_G(sparkle), 20, 0, 100, 100);
|
||||
_G(sparkle)._active = false;
|
||||
make_actor_surface(&_G(sparkle));
|
||||
|
||||
// Load explosion
|
||||
loadActor(0, 107);
|
||||
_G(explosion).loadFixed(_G(tmpBuff) + 5120);
|
||||
setupActor(&_G(explosion), 21, 0, 100, 100);
|
||||
_G(explosion)._active = false;
|
||||
make_actor_surface(&_G(explosion));
|
||||
|
||||
// Load tornado
|
||||
loadActor(0, 108);
|
||||
_G(magicItem[0]).loadFixed((const byte *)_G(tmpBuff) + 5120);
|
||||
Common::copy(_G(tmpBuff), _G(tmpBuff) + 1024, _G(magicPic[0]));
|
||||
|
||||
setupActor(&_G(magicItem[0]), 20, 0, 0, 0);
|
||||
_G(magicItem[0])._active = false;
|
||||
|
||||
// Load shield
|
||||
loadActor(0, 109);
|
||||
_G(magicItem[1]).loadFixed((const byte *)_G(tmpBuff) + 5120);
|
||||
Common::copy(_G(tmpBuff), _G(tmpBuff) + 1024, _G(magicPic[1]));
|
||||
|
||||
setupActor(&_G(magicItem[1]), 20, 0, 0, 0);
|
||||
_G(magicItem[1])._active = false;
|
||||
|
||||
_G(actor[2])._active = false;
|
||||
|
||||
make_actor_surface(&_G(magicItem[0]));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void showEnemies() {
|
||||
for (int i = 3; i < MAX_ACTORS; i++)
|
||||
_G(actor[i])._active = false;
|
||||
|
||||
for (int i = 0; i < MAX_ENEMIES; i++)
|
||||
_G(enemyType[i]) = 0;
|
||||
|
||||
for (int i = 0; i < MAX_ENEMIES; i++) {
|
||||
if (_G(scrn)._actorType[i] > 0) {
|
||||
const int id = loadEnemy(_G(scrn)._actorType[i]);
|
||||
if (id >= 0) {
|
||||
_G(actor[i + 3]) = _G(enemy[id]);
|
||||
|
||||
const int d = _G(scrn)._actorDir[i];
|
||||
|
||||
setupActor(&_G(actor[i + 3]), i + 3, d, (_G(scrn)._actorLoc[i] % 20) * 16,
|
||||
(_G(scrn)._actorLoc[i] / 20) * 16);
|
||||
_G(actor[i + 3])._initDir = _G(scrn)._actorDir[i];
|
||||
_G(actor[i + 3])._passValue = _G(scrn)._actorValue[i];
|
||||
|
||||
if (_G(actor[i + 3])._moveType == 23) {
|
||||
// Spinball
|
||||
if (_G(actor[i + 3])._passValue & 1)
|
||||
_G(actor[i + 3])._moveType = 24;
|
||||
}
|
||||
|
||||
if (_G(scrn)._actorInvis[i])
|
||||
_G(actor[i + 3])._active = false;
|
||||
}
|
||||
|
||||
_G(etype[i]) = id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int loadEnemy(const int type) {
|
||||
for (int i = 0; i < MAX_ENEMIES; i++) {
|
||||
if (_G(enemyType[i]) == type)
|
||||
return i;
|
||||
}
|
||||
|
||||
if (!loadActor(1, type)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int e = -1;
|
||||
for (int i = 0; i < MAX_ENEMIES; i++) {
|
||||
if (!_G(enemyType[i])) {
|
||||
e = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (e == -1)
|
||||
return -1;
|
||||
|
||||
Common::MemoryReadStream inf(_G(tmpBuff) + 5120, 40);
|
||||
_G(enemy[e]).loadFixed(&inf);
|
||||
|
||||
make_actor_surface(&_G(enemy[e]));
|
||||
_G(enemyType[e]) = type;
|
||||
_G(enemy[e])._shotType = 0;
|
||||
|
||||
if (_G(enemy[e])._numShotsAllowed) {
|
||||
_G(enemy[e])._shotType = e + 1;
|
||||
|
||||
// Set up shot info
|
||||
_G(shot[e]).loadFixed(_G(tmpBuff) + 5160);
|
||||
|
||||
// Loop to set up graphics
|
||||
for (int d = 0; d < _G(shot[e])._directions; d++) {
|
||||
for (int f = 0; f < _G(shot[e])._framesPerDirection; f++) {
|
||||
if (_G(shot[e])._directions < _G(shot[e])._framesPerDirection) {
|
||||
Graphics::ManagedSurface &s = _G(shot[e]).pic[d][f];
|
||||
const byte *src = &_G(tmpBuff[4096 + (256 * ((d * 4) + f))]);
|
||||
createSurface(s, src);
|
||||
} else {
|
||||
Graphics::ManagedSurface &s = _G(shot[e]).pic[f][d];
|
||||
const byte *src = &_G(tmpBuff[4096 + (256 * ((f * 4) + d))]);
|
||||
createSurface(s, src);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return e;
|
||||
}
|
||||
|
||||
int actorVisible(const int invisNum) {
|
||||
for (int i = 0; i < MAX_ENEMIES; i++) {
|
||||
if (_G(scrn)._actorInvis[i] == invisNum) {
|
||||
const int etype = _G(etype[i]);
|
||||
if (etype >= 0 && !_G(actor[i + 3])._active) {
|
||||
_G(actor[i + 3]) = _G(enemy[etype]);
|
||||
|
||||
int d = _G(scrn)._actorDir[i];
|
||||
setupActor(&_G(actor[i + 3]), i + 3, d, (_G(scrn)._actorLoc[i] % 20) * 16,
|
||||
(_G(scrn)._actorLoc[i] / 20) * 16);
|
||||
_G(actor[i + 3])._initDir = _G(scrn)._actorDir[i];
|
||||
_G(actor[i + 3])._passValue = _G(scrn)._actorValue[i];
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void setupMagicItem(const int item) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
createSurface(_G(magicItem[item]).pic[i / 4][i % 4], &_G(magicPic[item][256 * i]));
|
||||
}
|
||||
}
|
||||
|
||||
void loadNewThor() {
|
||||
loadActor(0, 100 + _G(thorInfo)._armor); // Load Thor
|
||||
|
||||
make_actor_surface(&_G(actor[0]));
|
||||
}
|
||||
|
||||
} // namespace Got
|
||||
39
engines/got/gfx/image.h
Normal file
39
engines/got/gfx/image.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef GOT_GFX_IMAGE_H
|
||||
#define GOT_GFX_IMAGE_H
|
||||
|
||||
#include "got/data/defines.h"
|
||||
|
||||
namespace Got {
|
||||
|
||||
extern void setupActor(Actor *actor, char num, char dir, int x, int y);
|
||||
extern int loadStandardActors();
|
||||
extern void showEnemies();
|
||||
extern int loadEnemy(int type);
|
||||
extern int actorVisible(int invisNum);
|
||||
extern void setupMagicItem(int item);
|
||||
extern void loadNewThor();
|
||||
|
||||
} // namespace Got
|
||||
|
||||
#endif
|
||||
144
engines/got/gfx/palette.cpp
Normal file
144
engines/got/gfx/palette.cpp
Normal file
@@ -0,0 +1,144 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "got/gfx/palette.h"
|
||||
#include "common/events.h"
|
||||
#include "common/system.h"
|
||||
#include "got/got.h"
|
||||
#include "got/utils/file.h"
|
||||
#include "got/vars.h"
|
||||
#include "graphics/paletteman.h"
|
||||
|
||||
namespace Got {
|
||||
namespace Gfx {
|
||||
|
||||
#define FADE_STEPS 10
|
||||
|
||||
static byte saved_palette[Graphics::PALETTE_SIZE];
|
||||
|
||||
Palette63::Palette63(const byte *pal) {
|
||||
for (uint i = 0; i < Graphics::PALETTE_SIZE; ++i)
|
||||
_pal[i] = pal[i] << 2;
|
||||
}
|
||||
|
||||
void loadPalette() {
|
||||
if (resourceRead("PALETTE", saved_palette) < 0)
|
||||
error("Cannot Read PALETTE");
|
||||
|
||||
g_system->getPaletteManager()->setPalette(saved_palette, 0, 256);
|
||||
}
|
||||
|
||||
void setScreenPal() {
|
||||
byte pal[3];
|
||||
|
||||
xGetPal(pal, 1, _G(scrn)._palColors[0]);
|
||||
xSetPal(251, pal[0], pal[1], pal[2]);
|
||||
xGetPal(pal, 1, _G(scrn)._palColors[1]);
|
||||
xSetPal(252, pal[0], pal[1], pal[2]);
|
||||
xGetPal(pal, 1, _G(scrn)._palColors[2]);
|
||||
xSetPal(253, pal[0], pal[1], pal[2]);
|
||||
}
|
||||
|
||||
void xSetPal(const byte color, const byte R, const byte G, const byte B) {
|
||||
byte rgb[3] = {R, G, B};
|
||||
g_system->getPaletteManager()->setPalette(rgb, color, 1);
|
||||
}
|
||||
|
||||
void xSetPal(const byte *pal) {
|
||||
g_system->getPaletteManager()->setPalette(pal, 0, Graphics::PALETTE_COUNT);
|
||||
}
|
||||
|
||||
void setPalette(const byte *pal) {
|
||||
xSetPal(pal);
|
||||
Common::copy(pal, pal + Graphics::PALETTE_SIZE, saved_palette);
|
||||
}
|
||||
|
||||
void xGetPal(byte *pal, const int numColors, const int startIndex) {
|
||||
g_system->getPaletteManager()->grabPalette(pal, startIndex, numColors);
|
||||
}
|
||||
|
||||
void fadeOut() {
|
||||
byte tempPal[Graphics::PALETTE_SIZE];
|
||||
const byte *srcP;
|
||||
byte *destP;
|
||||
int count;
|
||||
Common::Event evt;
|
||||
|
||||
xGetPal(saved_palette, Graphics::PALETTE_COUNT, 0);
|
||||
|
||||
for (int step = FADE_STEPS - 1; step >= 0; --step) {
|
||||
// Set each palette RGB proportionately
|
||||
for (srcP = &saved_palette[0], destP = &tempPal[0], count = 0;
|
||||
count < Graphics::PALETTE_SIZE; ++count, ++srcP, ++destP) {
|
||||
*destP = *srcP * step / FADE_STEPS;
|
||||
}
|
||||
|
||||
// Set new palette
|
||||
xSetPal(tempPal);
|
||||
|
||||
// Use up any pending events and update the screen
|
||||
while (g_system->getEventManager()->pollEvent(evt)) {
|
||||
if (evt.type == Common::EVENT_QUIT)
|
||||
return;
|
||||
}
|
||||
|
||||
g_events->getScreen()->update();
|
||||
g_system->delayMillis(10);
|
||||
}
|
||||
}
|
||||
|
||||
void fadeIn(const byte *pal) {
|
||||
byte tempPal[Graphics::PALETTE_SIZE];
|
||||
const byte *srcP;
|
||||
byte *destP;
|
||||
int count;
|
||||
Common::Event evt;
|
||||
|
||||
if (pal)
|
||||
Common::copy(pal, pal + Graphics::PALETTE_SIZE, saved_palette);
|
||||
|
||||
// Start with a black palette
|
||||
Common::fill(tempPal, tempPal + Graphics::PALETTE_SIZE, 0);
|
||||
xSetPal(tempPal);
|
||||
|
||||
for (int step = 1; step <= FADE_STEPS; ++step) {
|
||||
// Set each palette RGB proportionately
|
||||
for (srcP = &saved_palette[0], destP = &tempPal[0], count = 0;
|
||||
count < Graphics::PALETTE_SIZE; ++count, ++srcP, ++destP) {
|
||||
*destP = *srcP * step / FADE_STEPS;
|
||||
}
|
||||
|
||||
// Set new palette
|
||||
xSetPal(tempPal);
|
||||
|
||||
// Use up any pending events and update the screen
|
||||
while (g_system->getEventManager()->pollEvent(evt)) {
|
||||
if (evt.type == Common::EVENT_QUIT)
|
||||
return;
|
||||
}
|
||||
|
||||
g_events->getScreen()->update();
|
||||
g_system->delayMillis(10);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Gfx
|
||||
} // namespace Got
|
||||
52
engines/got/gfx/palette.h
Normal file
52
engines/got/gfx/palette.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef GOT_GFX_PALETTE_H
|
||||
#define GOT_GFX_PALETTE_H
|
||||
|
||||
#include "graphics/paletteman.h"
|
||||
|
||||
namespace Got {
|
||||
namespace Gfx {
|
||||
|
||||
struct Palette63 {
|
||||
byte _pal[Graphics::PALETTE_SIZE] = {};
|
||||
Palette63() {}
|
||||
Palette63(const byte *pal);
|
||||
|
||||
operator const byte *() const {
|
||||
return _pal;
|
||||
}
|
||||
};
|
||||
|
||||
extern void loadPalette();
|
||||
extern void setScreenPal();
|
||||
extern void setPalette(const byte *pal);
|
||||
extern void xSetPal(byte color, byte R, byte G, byte B);
|
||||
extern void xSetPal(const byte *pal);
|
||||
extern void xGetPal(byte *pal, int numColors, int startIndex);
|
||||
extern void fadeOut();
|
||||
extern void fadeIn(const byte *pal = nullptr);
|
||||
|
||||
} // namespace Gfx
|
||||
} // namespace Got
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user