Skip to content

Commit

Permalink
PRINCE: scrollHero()
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaslw committed Jun 22, 2014
1 parent 452895e commit 583d6bd
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 16 deletions.
82 changes: 75 additions & 7 deletions engines/prince/hero.cpp
Expand Up @@ -26,11 +26,12 @@
#include "prince/hero_set.h"
#include "prince/animation.h"
#include "prince/resource.h"
#include "prince/prince.h"


namespace Prince {

Hero::Hero() : _number(0), _visible(false), _state(MOVE), _middleX(0), _middleY(0)
Hero::Hero(PrinceEngine *vm) : _vm(vm), _number(0), _visible(false), _state(MOVE), _middleX(0), _middleY(0)
, _boreNum(1), _currHeight(0), _moveDelay(0), _shadMinus(0), _moveSetType(0)
, _lastDirection(DOWN), _destDirection(DOWN), _talkTime(0), _boredomTime(0), _phase(0)
, _specAnim(0), _drawX(0), _drawY(0), _randomSource("prince"), _zoomFactor(0), _scaleValue(0)
Expand Down Expand Up @@ -269,12 +270,44 @@ Graphics::Surface *Hero::showHeroShadow(Graphics::Surface *heroFrame) {
}
}
return makeShadow;
// TODO
/*
int scaledX = getScaledValue(frameXSize);
int drawX = _middleX - scaledX / 2; // just _drawX
int DN_ECX5070 = _middleY - _shadMinus;
*/

// source Bitmap of sprite - esi
//int destX = _drawX; // eax
int destY = _middleY - _shadMinus; // ecx
// modulo of source Bitmap - ebp
//int scaledX = getScaledValue(frameXSize); // ebx
//int scaledY = getScaledValue(frameYSize); // edx
// shadowTable70 - edi

if (destY > 1 && destY < kMaxPicHeight) {
// pushad
// edx = destY
// ecx = destX
// ebx = _lightY
// eax = _lightX

int shadowDirection;
if (_lightY > destY) {
shadowDirection = 1;
} else {
shadowDirection = 0;
}
//int shadowLineLen = 0;
//int shadWallDown = 0;
// int shadowLine = Linijka();
// push lineCode
// mov lineCode <- @@Nopik
// Line();
// pop lineCode
// popad

// sprShadow = shadowTable70
// sprModulo = modulo of source Bitmap
// sprWidth = scaledX
// sprHeight = scaledY
//int sprDestX = destX - PicWindowX;
//int sprDestY = destY - PicWindowY;
}
}

void Hero::showHeroAnimFrame() {
Expand Down Expand Up @@ -491,6 +524,41 @@ void Hero::showHero() {
return;
}
}

void Hero::scrollHero() {
//FLAGI+SCROLLTYPE ??
//int scrollType = 0;
int position = _middleX;

/*
switch (scrollType) {
case 0:
position = _middleX;
break;
case 1:
break;
case 2:
break;
}
*/

int locationWidth = _vm->_sceneWidth;
int difference = locationWidth - kNormalWidth / 2;

int destValue = 0;
if (position > kNormalWidth / 2) {
destValue = difference - kNormalWidth / 2;
}
if (position < difference) {
destValue = position - kNormalWidth / 2;
}
if(destValue < 0) {
destValue = 0;
}
_vm->_picWindowX = destValue;
_drawX -= destValue;
}

}

/* vim: set tabstop=4 noexpandtab: */
7 changes: 6 additions & 1 deletion engines/prince/hero.h
Expand Up @@ -31,13 +31,16 @@
namespace Prince {

class Animation;
class PrinceEngine;

class Hero {
public:
static const uint32 kMoveSetSize = 26;
static const int16 kZoomStep = 4;
static const int16 kMaxPicWidth = 1280;
static const int16 kMaxPicHeight = 480;
static const int16 kZoomBitmapWidth = kMaxPicWidth / kZoomStep;
static const int16 kNormalWidth = 640;

static const uint8 kShadowColor = 191;

Expand Down Expand Up @@ -90,7 +93,7 @@ class Hero {
Move_BORED2
};

Hero();
Hero(PrinceEngine *vm);
~Hero();
Common::RandomSource _randomSource;
bool loadAnimSet(uint32 heroAnimNumber);
Expand All @@ -103,6 +106,7 @@ class Hero {
void showHero();
void moveHero();
void rotateHero();
void scrollHero();
void setScale(int8 zoomBitmapValue);
int getScaledValue(int size);
void selectZoom();
Expand All @@ -116,6 +120,7 @@ class Hero {
void getState();

//private:
PrinceEngine *_vm;
uint16 _number;
uint16 _visible;
int16 _state;
Expand Down
13 changes: 9 additions & 4 deletions engines/prince/prince.cpp
Expand Up @@ -78,7 +78,7 @@ PrinceEngine::PrinceEngine(OSystem *syst, const PrinceGameDescription *gameDesc)
Engine(syst), _gameDescription(gameDesc), _graph(nullptr), _script(nullptr), _interpreter(nullptr), _flags(nullptr),
_locationNr(0), _debugger(nullptr), _midiPlayer(nullptr),
_cameraX(0), _newCameraX(0), _frameNr(0), _cursor1(nullptr), _cursor2(nullptr), _font(nullptr),
_walizkaBmp(nullptr), _roomBmp(nullptr), _cursorNr(0) {
_walizkaBmp(nullptr), _roomBmp(nullptr), _cursorNr(0), _picWindowX(0) {

// Debug/console setup
DebugMan.addDebugChannel(DebugChannel::kScript, "script", "Prince Script debug channel");
Expand Down Expand Up @@ -186,8 +186,8 @@ void PrinceEngine::init() {

_roomBmp = new Image::BitmapDecoder();

_mainHero = new Hero();
_secondHero = new Hero();
_mainHero = new Hero(this);
_secondHero = new Hero(this);

_mainHero->loadAnimSet(0);
}
Expand Down Expand Up @@ -288,6 +288,8 @@ bool PrinceEngine::loadLocation(uint16 locationNr) {
Resource::loadResource(_mainHero->_shadowBitmap, "shadow2", false);
}

_picWindowX = 0;

_mainHero->_lightX = _script->getLightX(_locationNr);
_mainHero->_lightY = _script->getLightY(_locationNr);
_mainHero->setShadowScale(_script->getShadowScale(_locationNr));
Expand Down Expand Up @@ -633,7 +635,7 @@ void PrinceEngine::drawScreen() {
const Graphics::Surface *roomSurface = _roomBmp->getSurface();
if (roomSurface) {
_graph->setPalette(_roomBmp->getPalette());
const Graphics::Surface visiblePart = roomSurface->getSubArea(Common::Rect(_cameraX, 0, roomSurface->w, roomSurface->h));
const Graphics::Surface visiblePart = roomSurface->getSubArea(Common::Rect(_picWindowX, 0, roomSurface->w, roomSurface->h));
_graph->draw(0, 0, &visiblePart);
}

Expand Down Expand Up @@ -695,6 +697,9 @@ void PrinceEngine::mainLoop() {

// TODO: Update all structures, animations, naks, heros etc.
_mainHero -> showHero();
if(_mainHero->_visible == 1) {
_mainHero -> scrollHero();
}

_interpreter->step();

Expand Down
9 changes: 5 additions & 4 deletions engines/prince/prince.h
Expand Up @@ -140,6 +140,11 @@ class PrinceEngine : public Engine {
Hero* _mainHero;
Hero* _secondHero;

uint16 _cameraX;
uint16 _newCameraX;
uint16 _sceneWidth;
uint32 _picWindowX;

private:
bool playNextFrame();
void keyHandler(Common::Event event);
Expand Down Expand Up @@ -181,10 +186,6 @@ class PrinceEngine : public Engine {
Common::Array<Object *> _objList;
Common::Array<AnimListItem> _animList;

uint16 _cameraX;
uint16 _newCameraX;
uint16 _sceneWidth;

bool _flicLooped;

void mainLoop();
Expand Down

0 comments on commit 583d6bd

Please sign in to comment.