PRINCE: scrollHero()

This commit is contained in:
lukaslw 2014-05-04 18:02:53 +02:00
parent 452895e650
commit 583d6bdca1
4 changed files with 95 additions and 16 deletions

View File

@ -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)
@ -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() {
@ -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: */

View File

@ -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;
@ -90,7 +93,7 @@ public:
Move_BORED2
};
Hero();
Hero(PrinceEngine *vm);
~Hero();
Common::RandomSource _randomSource;
bool loadAnimSet(uint32 heroAnimNumber);
@ -103,6 +106,7 @@ public:
void showHero();
void moveHero();
void rotateHero();
void scrollHero();
void setScale(int8 zoomBitmapValue);
int getScaledValue(int size);
void selectZoom();
@ -116,6 +120,7 @@ public:
void getState();
//private:
PrinceEngine *_vm;
uint16 _number;
uint16 _visible;
int16 _state;

View File

@ -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");
@ -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);
}
@ -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));
@ -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);
}
@ -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();

View File

@ -140,6 +140,11 @@ public:
Hero* _mainHero;
Hero* _secondHero;
uint16 _cameraX;
uint16 _newCameraX;
uint16 _sceneWidth;
uint32 _picWindowX;
private:
bool playNextFrame();
void keyHandler(Common::Event event);
@ -181,10 +186,6 @@ private:
Common::Array<Object *> _objList;
Common::Array<AnimListItem> _animList;
uint16 _cameraX;
uint16 _newCameraX;
uint16 _sceneWidth;
bool _flicLooped;
void mainLoop();