Skip to content

Commit

Permalink
PRINCE: draw(), drawTransparentDrawNode() update
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaslw committed Jun 22, 2014
1 parent f4f09ef commit 1c02028
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
23 changes: 16 additions & 7 deletions engines/prince/graphics.cpp
Expand Up @@ -67,28 +67,37 @@ void GraphicsMan::change() {
_changed = true;
}

void GraphicsMan::draw(Graphics::Surface *screen, uint16 posX, uint16 posY, const Graphics::Surface *s) {
void GraphicsMan::draw(Graphics::Surface *screen, const Graphics::Surface *s) {
uint16 w = MIN(screen->w, s->w);
byte *src = (byte *)s->getBasePtr(0, 0);
byte *dst = (byte *)screen->getBasePtr(0, 0);
for (uint y = 0; y < s->h; y++) {
if (y < screen->h) {
memcpy((byte*)screen->getBasePtr(0, y), (byte*)s->getBasePtr(0, y), w);
memcpy(dst, src, w);
}
src += s->pitch;
dst += screen->pitch;
}
change();
}

void GraphicsMan::drawTransparentSurface(Graphics::Surface *screen, int32 posX, int32 posY, const Graphics::Surface *s, int transColor) {
byte *src1 = (byte *)s->getBasePtr(0, 0);
byte *dst1 = (byte *)screen->getBasePtr(posX, posY);
for (int y = 0; y < s->h; y++) {
for (int x = 0; x < s->w; x++) {
byte pixel = *((byte*)s->getBasePtr(x, y));
if (pixel != transColor) {
byte *src2 = src1;
byte *dst2 = dst1;
for (int x = 0; x < s->w; x++, src2++, dst2++) {
if (*src2 != transColor) {
if (x + posX < screen->w && x + posX >= 0) {
if (y + posY < screen->h && y + posY >= 0) {
*((byte*)screen->getBasePtr(x + posX, y + posY)) = pixel;
*dst2 = *src2;
}
}
}
}
src1 += s->pitch;
dst1 += screen->pitch;
}
change();
}
Expand Down Expand Up @@ -119,7 +128,7 @@ void GraphicsMan::drawTransparentWithBlend(Graphics::Surface *screen, int32 posX
change();
}

void GraphicsMan::drawTransparent(Graphics::Surface *screen, DrawNode *drawNode) {
void GraphicsMan::drawTransparentDrawNode(Graphics::Surface *screen, DrawNode *drawNode) {
byte *src1 = (byte *)drawNode->s->getBasePtr(0, 0);
byte *dst1 = (byte *)screen->getBasePtr(drawNode->posX, drawNode->posY);

Expand Down
4 changes: 2 additions & 2 deletions engines/prince/graphics.h
Expand Up @@ -44,11 +44,11 @@ class GraphicsMan {
void setPalette(const byte *palette);
void makeShadowTable(int brightness, byte *shadowTable);

void draw(Graphics::Surface *screen, uint16 x, uint16 y, const Graphics::Surface *s);
void draw(Graphics::Surface *screen, const Graphics::Surface *s);
void drawTransparentSurface(Graphics::Surface *screen, int32 posX, int32 poxY, const Graphics::Surface *s, int transColor);
void drawTransparentWithBlend(Graphics::Surface *screen, int32 posX, int32 poxY, const Graphics::Surface *s, int transColor);

static void drawTransparent(Graphics::Surface *screen, DrawNode *drawNode);
static void drawTransparentDrawNode(Graphics::Surface *screen, DrawNode *drawNode);
static void drawAsShadow(Graphics::Surface *screen, DrawNode *drawNode);
static void drawMask(Graphics::Surface *screen, DrawNode *drawNode);

Expand Down

0 comments on commit 1c02028

Please sign in to comment.