Skip to content

Commit

Permalink
PRINCE: line() fix, shadowHeroShadow() testing
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaslw committed Jun 22, 2014
1 parent fff1ff5 commit 2dc0b21
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 24 deletions.
66 changes: 43 additions & 23 deletions engines/prince/hero.cpp
Expand Up @@ -39,10 +39,12 @@ Hero::Hero(PrinceEngine *vm) : _vm(vm), _number(0), _visible(false), _state(MOVE
{
_zoomBitmap = new Animation();
_shadowBitmap = new Animation();
_linijka = new byte[2*1280*4];
}

Hero::~Hero() {
delete _zoomBitmap;
delete[] _linijka;
}

bool Hero::loadAnimSet(uint32 animSetNr) {
Expand Down Expand Up @@ -278,54 +280,67 @@ void Hero::line(int x1, int y1, int x2, int y2) {
int ly2 = y2;
int lfa = 0;

int shadowLineLen = 0;
Common::MemoryWriteStream writeStream(_linijka, 2*1280*4);
//loop
//if (x1 != x2 && y1 != y2) {
while (lx != lx2 && ly != ly2) {
// not_end
// pushad
// LineCode() ?
// popad
while (lx != lx2 || ly != ly2) {
//not_end
//nopik
if(shadowLineLen == 1280) {
break;
}
writeStream.writeUint16LE(lx);
writeStream.writeUint16LE(ly);
shadowLineLen++;

int lfx = lfa + lvx;
int lfy = lfa + lvy;
int lfxy = lfx + lfy - lfa;
int abs_lfxy, abs_lfx, abs_lfy;

if (lfxy < 0) {
lfxy = -1 * lfxy;
abs_lfxy = -1 * lfxy;
} else {
abs_lfxy = lfxy;
}
//abs_fxy_done
if (lfx < 0) {
lfx = -1 * lfx;
abs_lfx = -1 * lfx;
} else {
abs_lfx = lfx;
}
//abs_fx_done
if (lfy < 0) {
lfy = -1 * lfy;
abs_lfy = -1 * lfy;
} else {
abs_lfy = lfy;
}
//abs_fy_done
if (lfx > lfy || lfx > lfxy) {

if (abs_lfx > abs_lfy || abs_lfx > abs_lfxy) {
//c2
if (lfy >= lfx || lfy > lfxy) {
if (abs_lfy >= abs_lfx || abs_lfy > abs_lfxy) {
//c3
ly += dY;
lx += dX;
lfa = lfxy;
} else {
ly += dY;
lfa = lfa + lvy; // lfx / lfy = ?
lfa = lfa + lvy;
}
} else {
lx += dX;
lfa = lfa + lvx; //9600 ???
// jump to @@next
lfa = lfa + lvx;
}
//next
//
}

}

Graphics::Surface *Hero::showHeroShadow(Graphics::Surface *heroFrame) {
void Hero::showHeroShadow() {
//Graphics::Surface *Hero::showHeroShadow(Graphics::Surface *heroFrame) {
int16 frameXSize = _moveSet[_moveSetType]->getFrameWidth(_phase);
int16 frameYSize = _moveSet[_moveSetType]->getFrameHeight(_phase);

/*
Graphics::Surface *makeShadow = new Graphics::Surface();
makeShadow->create(frameXSize, frameYSize, Graphics::PixelFormat::createFormatCLUT8());
Expand All @@ -342,8 +357,7 @@ Graphics::Surface *Hero::showHeroShadow(Graphics::Surface *heroFrame) {
}
}
}
return makeShadow;

*/
// source Bitmap of sprite - esi
int destX = _drawX; // eax
int destY = _middleY - _shadMinus; // ecx
Expand All @@ -370,7 +384,11 @@ Graphics::Surface *Hero::showHeroShadow(Graphics::Surface *heroFrame) {
// int shadowLine = Linijka();
// push lineCode
// mov lineCode <- @@Nopik
// Line();
//EAX - x1 <- LightX
//EBX - y1 <- LightY
//ECX - x2 <- DestX
//EDX - y2 <- DestY
line(_lightX, _lightY, destX, destY);
// pop lineCode
// popad

Expand All @@ -390,7 +408,7 @@ Graphics::Surface *Hero::showHeroShadow(Graphics::Surface *heroFrame) {
int shadMaxY = sprDestY;
// destY * kMaxPicWidth / 8 + destX / 8
int shadBitAddr = _shadowBitmap->getZoom(destY * kMaxPicWidth / 8 + destX / 8);
int shadBitMask = 128 / (destX % 8);
int shadBitMask = 128 / pow(2.0, (destX % 8));

int shadZoomY2 = _shadScaleValue;
int shadZoomY = _scaleValue;
Expand Down Expand Up @@ -428,6 +446,7 @@ Graphics::Surface *Hero::showHeroShadow(Graphics::Surface *heroFrame) {
}
//}
}
//return makeShadow;
}

void Hero::showHeroAnimFrame() {
Expand All @@ -437,7 +456,8 @@ void Hero::showHeroAnimFrame() {
_phase = 0;
}
countDrawPosition();
//showHeroShadow();
//temp:
showHeroShadow();
//debug("_drawX: %d", _drawX);
//debug("_drawY: %d", _drawY);
//debug("_middleX: %d", _middleX);
Expand Down
5 changes: 4 additions & 1 deletion engines/prince/hero.h
Expand Up @@ -25,6 +25,7 @@

#include "common/scummsys.h"
#include "common/array.h"
#include "common/memstream.h"

#include "graphics/surface.h"

Expand Down Expand Up @@ -115,7 +116,8 @@ class Hero {
Graphics::Surface *zoomSprite(Graphics::Surface *heroFrame);
void showHeroAnimFrame();
void line(int x1, int y1, int x2, int y2);
Graphics::Surface *showHeroShadow(Graphics::Surface *heroFrame);
//Graphics::Surface *showHeroShadow(Graphics::Surface *heroFrame);
void showHeroShadow();
void setShadowScale(int32 shadowScale);
void specialAnim();
void getState();
Expand Down Expand Up @@ -167,6 +169,7 @@ class Hero {
// TurnAnim ??
Animation *_zoomBitmap; // change to sth else, not Animation ??
Animation *_shadowBitmap;
byte *_linijka;

uint32 _moveDelay;
uint32 _shadMinus;
Expand Down

0 comments on commit 2dc0b21

Please sign in to comment.