mirror of
https://github.com/libretro/scummvm.git
synced 2025-03-05 17:57:14 +00:00
PRINCE: loadTrans(), drawTransparentWithTransDrawNode() - implementation
This commit is contained in:
parent
075ea1a0e0
commit
7026f687ff
@ -164,15 +164,62 @@ void GraphicsMan::drawTransparentDrawNode(Graphics::Surface *screen, DrawNode *d
|
||||
byte *dst1 = (byte *)screen->getBasePtr(drawNode->posX, drawNode->posY);
|
||||
|
||||
for (int y = 0; y < drawNode->s->h; y++) {
|
||||
byte *src2 = src1;
|
||||
byte *dst2 = dst1;
|
||||
for (int x = 0; x < drawNode->s->w; x++, src2++, dst2++) {
|
||||
if (*src2 != 255) {
|
||||
if (x + drawNode->posX < screen->w && x + drawNode->posX >= 0) {
|
||||
if (y + drawNode->posY < screen->h && y + drawNode->posY >= 0) {
|
||||
*dst2 = *src2;
|
||||
}
|
||||
}
|
||||
if (y + drawNode->posY < screen->h && y + drawNode->posY >= 0) {
|
||||
byte *src2 = src1;
|
||||
byte *dst2 = dst1;
|
||||
for (int x = 0; x < drawNode->s->w; x++, src2++, dst2++) {
|
||||
if (*src2 != 255) {
|
||||
if (x + drawNode->posX < screen->w && x + drawNode->posX >= 0) {
|
||||
*dst2 = *src2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
src1 += drawNode->s->pitch;
|
||||
dst1 += screen->pitch;
|
||||
}
|
||||
}
|
||||
|
||||
void GraphicsMan::drawTransparentWithTransDrawNode(Graphics::Surface *screen, DrawNode *drawNode) {
|
||||
byte *src1 = (byte *)drawNode->s->getBasePtr(0, 0);
|
||||
byte *dst1 = (byte *)screen->getBasePtr(drawNode->posX, drawNode->posY);
|
||||
byte *transTableData = (byte *)drawNode->data;
|
||||
|
||||
for (int y = 0; y < drawNode->s->h; y++) {
|
||||
if (y + drawNode->posY < screen->h && y + drawNode->posY >= 0) {
|
||||
byte *src2 = src1;
|
||||
byte *dst2 = dst1;
|
||||
for (int x = 0; x < drawNode->s->w; x++, src2++, dst2++) {
|
||||
if (x + drawNode->posX < screen->w && x + drawNode->posX >= 0) {
|
||||
if (*src2 != 255) {
|
||||
*dst2 = *src2;
|
||||
} else if (x) {
|
||||
if (*(src2 - 1) == 255) {
|
||||
if (x != drawNode->s->w - 1) {
|
||||
if (*(src2 + 1) == 255) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (*(src2 + 1) == 255) {
|
||||
continue;
|
||||
}
|
||||
byte value = 0;
|
||||
if (y != drawNode->s->h - 1) {
|
||||
value = *(src1 + drawNode->s->pitch + x);
|
||||
if (value == 255) {
|
||||
if (y) {
|
||||
value = *(src1 + x);
|
||||
if (value == 255) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
*dst2 = transTableData[*dst2 * 256 + value];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
src1 += drawNode->s->pitch;
|
||||
|
@ -49,6 +49,7 @@ public:
|
||||
void drawTransparentWithBlendSurface(Graphics::Surface *screen, int32 posX, int32 posY, const Graphics::Surface *s, int transColor);
|
||||
|
||||
static void drawTransparentDrawNode(Graphics::Surface *screen, DrawNode *drawNode);
|
||||
static void drawTransparentWithTransDrawNode(Graphics::Surface *screen, DrawNode *drawNode);
|
||||
static void drawAsShadowDrawNode(Graphics::Surface *screen, DrawNode *drawNode);
|
||||
static void drawMaskDrawNode(Graphics::Surface *screen, DrawNode *drawNode);
|
||||
static void drawBackSpriteDrawNode(Graphics::Surface *screen, DrawNode *drawNode);
|
||||
|
@ -892,8 +892,8 @@ void Hero::drawHero() {
|
||||
newDrawNode.width = 0;
|
||||
newDrawNode.height = 0;
|
||||
newDrawNode.originalRoomSurface = nullptr;
|
||||
newDrawNode.data = nullptr;
|
||||
newDrawNode.drawFunction = &_graph->drawTransparentDrawNode;
|
||||
newDrawNode.data = _vm->_transTable;
|
||||
newDrawNode.drawFunction = &_graph->drawTransparentWithTransDrawNode;
|
||||
|
||||
if (_zoomFactor) {
|
||||
_zoomedHeroSurface = zoomSprite(mainHeroSurface);
|
||||
|
@ -94,7 +94,7 @@ PrinceEngine::PrinceEngine(OSystem *syst, const PrinceGameDescription *gameDesc)
|
||||
_checkBitmapTemp(nullptr), _checkBitmap(nullptr), _checkMask(0), _checkX(0), _checkY(0), _traceLineFirstPointFlag(false),
|
||||
_tracePointFirstPointFlag(false), _coordsBuf2(nullptr), _coords2(nullptr), _coordsBuf3(nullptr), _coords3(nullptr),
|
||||
_shanLen(0), _directionTable(nullptr), _currentMidi(0), _lightX(0), _lightY(0), _curveData(nullptr), _curvPos(0),
|
||||
_creditsData(nullptr), _creditsDataSize(0), _currentTime(0) {
|
||||
_creditsData(nullptr), _creditsDataSize(0), _currentTime(0), _zoomBitmap(nullptr), _shadowBitmap(nullptr), _transTable(nullptr) {
|
||||
|
||||
// Debug/console setup
|
||||
DebugMan.addDebugChannel(DebugChannel::kScript, "script", "Prince Script debug channel");
|
||||
@ -191,6 +191,7 @@ PrinceEngine::~PrinceEngine() {
|
||||
|
||||
free(_zoomBitmap);
|
||||
free(_shadowBitmap);
|
||||
free(_transTable);
|
||||
|
||||
free(_curveData);
|
||||
|
||||
@ -339,6 +340,7 @@ void PrinceEngine::init() {
|
||||
|
||||
_zoomBitmap = (byte *)malloc(kZoomBitmapLen);
|
||||
_shadowBitmap = (byte *)malloc(2 * kShadowBitmapSize);
|
||||
_transTable = (byte *)malloc(kTransTableSize);
|
||||
|
||||
_curveData = (int16 *)malloc(2 * kCurveLen * sizeof(int16));
|
||||
|
||||
@ -444,6 +446,7 @@ bool PrinceEngine::loadLocation(uint16 locationNr) {
|
||||
|
||||
loadZoom(_zoomBitmap, kZoomBitmapLen, "zoom");
|
||||
loadShadow(_shadowBitmap, kShadowBitmapSize, "shadow", "shadow2");
|
||||
loadTrans(_transTable, "trans");
|
||||
loadPath("path");
|
||||
|
||||
for (uint32 i = 0; i < _pscrList.size(); i++) {
|
||||
@ -832,6 +835,25 @@ bool PrinceEngine::loadShadow(byte *shadowBitmap, uint32 dataSize, const char *r
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PrinceEngine::loadTrans(byte *transTable, const char *resourceName) {
|
||||
Common::SeekableReadStream *stream = SearchMan.createReadStreamForMember(resourceName);
|
||||
if (!stream) {
|
||||
delete stream;
|
||||
for (int i = 0; i < 256; i++) {
|
||||
for (int j = 0; j < 256; j++) {
|
||||
transTable[i * 256 + j] = j;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (stream->read(transTable, kTransTableSize) != kTransTableSize) {
|
||||
delete stream;
|
||||
return false;
|
||||
}
|
||||
delete stream;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PrinceEngine::loadPath(const char *resourceName) {
|
||||
Common::SeekableReadStream *stream = SearchMan.createReadStreamForMember(resourceName);
|
||||
if (!stream) {
|
||||
@ -1305,8 +1327,8 @@ void PrinceEngine::showSprite(Graphics::Surface *spriteSurface, int destX, int d
|
||||
newDrawNode.height = 0;
|
||||
newDrawNode.s = spriteSurface;
|
||||
newDrawNode.originalRoomSurface = nullptr;
|
||||
newDrawNode.data = nullptr;
|
||||
newDrawNode.drawFunction = &_graph->drawTransparentDrawNode;
|
||||
newDrawNode.data = _transTable;
|
||||
newDrawNode.drawFunction = &_graph->drawTransparentWithTransDrawNode;
|
||||
_drawNodeList.push_back(newDrawNode);
|
||||
}
|
||||
}
|
||||
@ -1690,12 +1712,16 @@ void PrinceEngine::showObjects() {
|
||||
newDrawNode.height = 0;
|
||||
newDrawNode.s = objSurface;
|
||||
newDrawNode.originalRoomSurface = nullptr;
|
||||
newDrawNode.data = nullptr;
|
||||
|
||||
if ((_objList[nr]->_flags & 0x2000)) {
|
||||
newDrawNode.data = nullptr;
|
||||
newDrawNode.drawFunction = &_graph->drawBackSpriteDrawNode;
|
||||
} else {
|
||||
newDrawNode.drawFunction = &_graph->drawTransparentDrawNode;
|
||||
newDrawNode.data = _transTable;
|
||||
if (_flags->getFlagValue(Flags::NOANTIALIAS)) {
|
||||
newDrawNode.drawFunction = &_graph->drawTransparentDrawNode;
|
||||
} else {
|
||||
newDrawNode.drawFunction = &_graph->drawTransparentWithTransDrawNode;
|
||||
}
|
||||
}
|
||||
_drawNodeList.push_back(newDrawNode);
|
||||
}
|
||||
|
@ -285,6 +285,7 @@ public:
|
||||
bool loadSample(uint32 sampleSlot, const Common::String &name);
|
||||
bool loadZoom(byte *zoomBitmap, uint32 dataSize, const char *resourceName);
|
||||
bool loadShadow(byte *shadowBitmap, uint32 dataSize, const char *resourceName1, const char *resourceName2);
|
||||
bool loadTrans(byte *transTable, const char *resourceName);
|
||||
bool loadMobPriority(const char *resourceName);
|
||||
|
||||
bool loadMusic(int musNumber);
|
||||
@ -334,6 +335,7 @@ public:
|
||||
uint8 _currentMidi;
|
||||
byte *_zoomBitmap;
|
||||
byte *_shadowBitmap;
|
||||
byte *_transTable;
|
||||
|
||||
static const int16 kFPS = 15;
|
||||
|
||||
@ -346,6 +348,7 @@ public:
|
||||
static const int16 kZoomBitmapHeight = kMaxPicHeight / kZoomStep;
|
||||
static const int16 kNormalWidth = 640;
|
||||
static const int16 kNormalHeight = 480;
|
||||
static const int32 kTransTableSize = 256 * 256;
|
||||
|
||||
static const int kMaxNormAnims = 64;
|
||||
static const int kMaxBackAnims = 64;
|
||||
|
Loading…
x
Reference in New Issue
Block a user