aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorMax Horn2009-12-07 18:22:18 +0000
committerMax Horn2009-12-07 18:22:18 +0000
commitf8126d9da676e69dff384b8a8f7136ad27fb014d (patch)
treedf1b86f98b4792fa4c44f71237f0722aca762584 /engines
parent6d1e4dd0344f9baef12709e2c90ac98e17392786 (diff)
downloadscummvm-rg350-f8126d9da676e69dff384b8a8f7136ad27fb014d.tar.gz
scummvm-rg350-f8126d9da676e69dff384b8a8f7136ad27fb014d.tar.bz2
scummvm-rg350-f8126d9da676e69dff384b8a8f7136ad27fb014d.zip
M4: Make M4Surface member w, h, pixels protected; some cleanup
svn-id: r46280
Diffstat (limited to 'engines')
-rw-r--r--engines/m4/actor.cpp8
-rw-r--r--engines/m4/animation.cpp2
-rw-r--r--engines/m4/console.cpp2
-rw-r--r--engines/m4/events.cpp2
-rw-r--r--engines/m4/graphics.h19
-rw-r--r--engines/m4/m4_menus.cpp8
-rw-r--r--engines/m4/mads_anim.cpp4
-rw-r--r--engines/m4/mads_menus.cpp2
-rw-r--r--engines/m4/rails.cpp2
-rw-r--r--engines/m4/scene.cpp6
-rw-r--r--engines/m4/viewmgr.cpp10
-rw-r--r--engines/m4/ws_sequence.cpp8
12 files changed, 38 insertions, 35 deletions
diff --git a/engines/m4/actor.cpp b/engines/m4/actor.cpp
index ab670f5a55..bfb4a14615 100644
--- a/engines/m4/actor.cpp
+++ b/engines/m4/actor.cpp
@@ -44,8 +44,8 @@ Actor::~Actor() {
unloadWalkers();
}
-int Actor::getWalkerWidth() { return _walkerSprites[kFacingSouth]->getFrame(0)->w; }
-int Actor::getWalkerHeight() { return _walkerSprites[kFacingSouth]->getFrame(0)->h; }
+int Actor::getWalkerWidth() { return _walkerSprites[kFacingSouth]->getFrame(0)->width(); }
+int Actor::getWalkerHeight() { return _walkerSprites[kFacingSouth]->getFrame(0)->height(); }
void Actor::placeWalkerSpriteAt(int spriteNum, int x, int y) {
if (_direction < 1 || _direction > 9) {
@@ -55,8 +55,8 @@ void Actor::placeWalkerSpriteAt(int spriteNum, int x, int y) {
SpriteInfo info;
info.sprite = _walkerSprites[_direction]->getFrame(spriteNum);
info.hotX = info.hotY = 0;
- info.width = info.sprite->w;
- info.height = info.sprite->h;
+ info.width = info.sprite->width();
+ info.height = info.sprite->height();
info.scaleX = info.scaleY = _scaling;
info.palette = _walkerSprites[_direction]->getPalette();
info.inverseColorTable = _vm->_scene->getInverseColorTable();
diff --git a/engines/m4/animation.cpp b/engines/m4/animation.cpp
index 4b063241fc..53d00cb5c0 100644
--- a/engines/m4/animation.cpp
+++ b/engines/m4/animation.cpp
@@ -176,7 +176,7 @@ bool Animation::updateAnim() {
M4Sprite *spr = _spriteSeries->getFrame(seriesFrameIndex);
// FIXME: We assume that the transparent color is the color of the top left pixel
- byte *transparentColor = (byte *)spr->pixels;
+ byte *transparentColor = spr->getBasePtr(0, 0);
// FIXME: correct x, y
spr->copyTo(bg, frame->x, frame->y, (int)*transparentColor);
diff --git a/engines/m4/console.cpp b/engines/m4/console.cpp
index 1f58101851..c95108066c 100644
--- a/engines/m4/console.cpp
+++ b/engines/m4/console.cpp
@@ -224,7 +224,7 @@ bool Console::cmdShowSprite(int argc, const char **argv) {
break;
// FIXME: We assume that the transparent color is the color of the top left pixel
- byte *transparentColor = (byte *)spr->pixels;
+ byte *transparentColor = spr->getBasePtr(0, 0);
spr->copyTo(bg, x, y, (int)*transparentColor);
diff --git a/engines/m4/events.cpp b/engines/m4/events.cpp
index 8ac8346838..498c40561b 100644
--- a/engines/m4/events.cpp
+++ b/engines/m4/events.cpp
@@ -240,7 +240,7 @@ bool Mouse::setCursorNum(int cursorIndex) {
_cursor = _cursorSprites->getFrame(cursorIndex);
// Set the cursor to the sprite
- CursorMan.replaceCursor((const byte *)_cursor->getBasePtr(), _cursor->w, _cursor->h, _cursor->xOffset, _cursor->yOffset, 0);
+ CursorMan.replaceCursor((const byte *)_cursor->getBasePtr(), _cursor->width(), _cursor->height(), _cursor->xOffset, _cursor->yOffset, 0);
return true;
}
diff --git a/engines/m4/graphics.h b/engines/m4/graphics.h
index 0fc448dad1..ca33f6150b 100644
--- a/engines/m4/graphics.h
+++ b/engines/m4/graphics.h
@@ -83,7 +83,7 @@ struct SpriteInfo {
RGB8 *palette;
};
-class M4Surface : public Graphics::Surface {
+class M4Surface : protected Graphics::Surface {
private:
byte _color;
bool _isScreen;
@@ -96,7 +96,10 @@ public:
create(g_system->getWidth(), g_system->getHeight(), 1);
_isScreen = isScreen;
}
- M4Surface(int Width, int Height) { create(Width, Height, 1); _isScreen = false; }
+ M4Surface(int width_, int height_) {
+ create(width_, height_, 1);
+ _isScreen = false;
+ }
// loads a .COD file into the M4Surface
// TODO: maybe move this to the rail system? check where it makes sense
@@ -110,7 +113,7 @@ public:
void madsloadInterface(int index, RGBList **palData);
void setColor(byte value) { _color = value; }
- byte getColor() { return _color; }
+ inline byte getColor() const { return _color; }
void vLine(int x, int y1, int y2);
void hLine(int x1, int x2, int y);
void vLineXor(int x, int y1, int y2);
@@ -122,8 +125,8 @@ public:
void drawSprite(int x, int y, SpriteInfo &info, const Common::Rect &clipRect);
// Surface methods
- int width() { return w; }
- int height() { return h; }
+ inline int width() const { return w; }
+ inline int height() const { return h; }
void setSize(int sizeX, int sizeY) { create(sizeX, sizeY, 1); }
inline byte *getBasePtr() {
return (byte *)pixels;
@@ -149,13 +152,13 @@ public:
}
// copyTo methods
- void copyTo(M4Surface *dest, int transparentColor = -1) {
+ inline void copyTo(M4Surface *dest, int transparentColor = -1) {
dest->copyFrom(this, Common::Rect(width(), height()), 0, 0, transparentColor);
}
- void copyTo(M4Surface *dest, int x, int y, int transparentColor = -1) {
+ inline void copyTo(M4Surface *dest, int x, int y, int transparentColor = -1) {
dest->copyFrom(this, Common::Rect(width(), height()), x, y, transparentColor);
}
- void copyTo(M4Surface *dest, const Common::Rect &srcBounds, int destX, int destY,
+ inline void copyTo(M4Surface *dest, const Common::Rect &srcBounds, int destX, int destY,
int transparentColor = -1) {
dest->copyFrom(this, srcBounds, destX, destY, transparentColor);
}
diff --git a/engines/m4/m4_menus.cpp b/engines/m4/m4_menus.cpp
index 88bcf85d05..0f36139b45 100644
--- a/engines/m4/m4_menus.cpp
+++ b/engines/m4/m4_menus.cpp
@@ -472,8 +472,8 @@ M4Surface *OrionMenuView::createThumbnail() {
// Translate the scene data
_vm->_scene->onRefresh(NULL, &srcSurface);
- byte *srcP = (byte *)srcSurface.pixels;
- byte *destP = (byte *)result->pixels;
+ byte *srcP = srcSurface.getBasePtr(0, 0);
+ byte *destP = result->getBasePtr(0, 0);
for (int yCtr = 0; yCtr < _vm->_scene->height() / 3; ++yCtr, srcP += g_system->getWidth() * 3) {
byte *src0P = srcP;
@@ -499,12 +499,12 @@ M4Surface *OrionMenuView::createThumbnail() {
// averaged, simply take the top left pixel of every 3x3 pixel block
_vm->_interfaceView->onRefresh(NULL, &srcSurface);
- destP = (byte *)result->pixels + (_vm->_screen->width() / 3) * (_vm->_interfaceView->bounds().top / 3);
+ destP = result->getBasePtr(0, 0) + (_vm->_screen->width() / 3) * (_vm->_interfaceView->bounds().top / 3);
int yStart = _vm->_interfaceView->bounds().top;
int yEnd = MIN(_vm->_screen->height() - 1, (int) _vm->_interfaceView->bounds().bottom - 1);
for (int yCtr = yStart; yCtr <= yEnd; yCtr += 3) {
- srcP = (byte *)srcSurface.pixels + (yCtr * _vm->_screen->width());
+ srcP = (byte *)srcSurface.getBasePtr(0, yCtr) + (yCtr * _vm->_screen->width());
for (int xCtr = 0; xCtr < result->width(); ++xCtr, srcP += 3)
*destP++ = *srcP;
diff --git a/engines/m4/mads_anim.cpp b/engines/m4/mads_anim.cpp
index 536ebb500e..ef099a6bcc 100644
--- a/engines/m4/mads_anim.cpp
+++ b/engines/m4/mads_anim.cpp
@@ -206,13 +206,13 @@ void TextviewView::updateState() {
Common::copy(srcP, srcP + _bgSurface.width(), destP);
}
- Common::copy(linesTemp, linesTemp + _panY * _bgSurface.width(), (byte *)_bgSurface.pixels);
+ Common::copy(linesTemp, linesTemp + _panY * _bgSurface.width(), _bgSurface.getBasePtr(0, 0));
delete[] linesTemp;
}
}
// Scroll the text surface up by one row
- byte *pixelsP = (byte *)_textSurface.pixels;
+ byte *pixelsP = _textSurface.getBasePtr(0, 0);
Common::copy(pixelsP + width(), pixelsP + _textSurface.width() * _textSurface.height(), pixelsP);
pixelsP = _textSurface.getBasePtr(0, _textSurface.height() - 1);
Common::set_to(pixelsP, pixelsP + _textSurface.width(), _vm->_palette->BLACK);
diff --git a/engines/m4/mads_menus.cpp b/engines/m4/mads_menus.cpp
index a67b933860..01bfe96e25 100644
--- a/engines/m4/mads_menus.cpp
+++ b/engines/m4/mads_menus.cpp
@@ -529,7 +529,7 @@ void DragonMainMenuView::updateState() {
spr = _menuItem->getFrame(1);
// FIXME: We assume that the transparent color is the color of the top left pixel
- byte *transparentColor = (byte *)spr->pixels;
+ byte *transparentColor = spr->getBasePtr(0, 0);
spr->copyTo(this, spr->xOffset - 140, spr->yOffset - spr->height(), (int)*transparentColor);
_vm->_mouse->cursorOn();
diff --git a/engines/m4/rails.cpp b/engines/m4/rails.cpp
index 18b3bf7232..56faf204f0 100644
--- a/engines/m4/rails.cpp
+++ b/engines/m4/rails.cpp
@@ -79,7 +79,7 @@ static void checkPoint(int x, int y, int color, void *data) {
return;
else {
M4Surface *codes = isWalkableData->codes;
- if (x >= 0 && x < codes->w && y >= 0 && y < codes->h) {
+ if (x >= 0 && x < codes->width() && y >= 0 && y < codes->height()) {
isWalkableData->result = !((*((uint8*)codes->getBasePtr(x, y))) & 0x10);
} else {
isWalkableData->result = false;
diff --git a/engines/m4/scene.cpp b/engines/m4/scene.cpp
index b1942fa27a..3d99e62961 100644
--- a/engines/m4/scene.cpp
+++ b/engines/m4/scene.cpp
@@ -435,8 +435,8 @@ void Scene::showHotSpots() {
// Test function, shows all scene codes
void Scene::showCodes() {
- uint8 *pixelData = (uint8*)_codeSurface->pixels;
- for (int i = 0; i < _codeSurface->w * _codeSurface->h; i++)
+ uint8 *pixelData = _codeSurface->getBasePtr(0, 0);
+ for (int i = 0; i < _codeSurface->width() * _codeSurface->height(); i++)
if (pixelData[i] & 0x10)
pixelData[i] = 0xFF;
else
@@ -450,7 +450,7 @@ void Scene::showCodes() {
_vm->_palette->setPalette(colors, 0, 256);
_backgroundSurface->copyFrom(_codeSurface, Common::Rect(0, 0, 640, 480), 0, 0);
- //_system->copyRectToScreen((byte *)codes->pixels, codes->w, 0, 0, codes->w, codes->h);
+ //_system->copyRectToScreen(codes->getBasePtr(0, 0), codes->w, 0, 0, codes->w, codes->h);
}
void Scene::playIntro() {
diff --git a/engines/m4/viewmgr.cpp b/engines/m4/viewmgr.cpp
index 108f97e979..6d91a12a9b 100644
--- a/engines/m4/viewmgr.cpp
+++ b/engines/m4/viewmgr.cpp
@@ -68,8 +68,7 @@ int RectList::find(const Common::Point &pt) {
//--------------------------------------------------------------------------
-HotkeyList::HotkeyList(View *owner) {
- _view = owner;
+HotkeyList::HotkeyList(View *owner) : _view(owner) {
}
HotkeyList::~HotkeyList() {
@@ -106,14 +105,15 @@ bool HotkeyList::call(uint32 key) {
// View constructor
-View::View(M4Engine *vm, const Common::Rect &viewBounds, bool transparent):
- _hotkeys(HotkeyList(this)), M4Surface(viewBounds.width(), viewBounds.height()), _vm(vm) {
+View::View(M4Engine *vm, const Common::Rect &viewBounds, bool transparent)
+ : M4Surface(viewBounds.width(), viewBounds.height()), _hotkeys(this), _vm(vm) {
SCREEN_FLAGS_DEFAULT;
_coords = viewBounds;
_transparent = transparent;
}
-View::View(M4Engine *vm, int x, int y, bool transparent): _hotkeys(HotkeyList(this)), M4Surface(), _vm(vm) {
+View::View(M4Engine *vm, int x, int y, bool transparent)
+ : M4Surface(), _hotkeys(this), _vm(vm) {
SCREEN_FLAGS_DEFAULT;
_coords.left = x;
_coords.top = y;
diff --git a/engines/m4/ws_sequence.cpp b/engines/m4/ws_sequence.cpp
index cc850b8cd7..0cbb94e307 100644
--- a/engines/m4/ws_sequence.cpp
+++ b/engines/m4/ws_sequence.cpp
@@ -291,8 +291,8 @@ void Sequence::draw(M4Surface *surface, const Common::Rect &clipRect, Common::Re
info.encoding = _curFrame->encoding;
info.inverseColorTable = _vm->_scene->getInverseColorTable();
info.palette = _ws->getMainPalette();
- info.width = _curFrame->w;
- info.height = _curFrame->h;
+ info.width = _curFrame->width();
+ info.height = _curFrame->height();
int32 scaler = FixedMul(_vars[kSeqVarScale], 100 << 16) >> 16;
info.scaleX = _vars[kSeqVarWidth] < 0 ? -scaler : scaler;
info.scaleY = scaler;
@@ -750,8 +750,8 @@ bool Sequence::streamNextFrame() {
_streamSpriteAsset->loadStreamingFrame(_curFrame, frameNum, _vars[kSeqVarX], _vars[kSeqVarY]);
- _vars[kSeqVarWidth] = _curFrame->w << 16;
- _vars[kSeqVarHeight] = _curFrame->h << 16;
+ _vars[kSeqVarWidth] = _curFrame->width() << 16;
+ _vars[kSeqVarHeight] = _curFrame->height() << 16;
return true;
}