aboutsummaryrefslogtreecommitdiff
path: root/engines/parallaction/graphics.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/parallaction/graphics.cpp')
-rw-r--r--engines/parallaction/graphics.cpp189
1 files changed, 115 insertions, 74 deletions
diff --git a/engines/parallaction/graphics.cpp b/engines/parallaction/graphics.cpp
index 59645381b6..8d45c4aaa9 100644
--- a/engines/parallaction/graphics.cpp
+++ b/engines/parallaction/graphics.cpp
@@ -30,9 +30,6 @@
#include "parallaction/parallaction.h"
-
-extern OSystem *g_system;
-
namespace Parallaction {
byte * Gfx::_buffers[];
@@ -83,7 +80,7 @@ void Gfx::drawBalloon(const Common::Rect& r, uint16 winding) {
winding = (winding == 0 ? 1 : 0);
byte *s = _resBalloon[winding];
- byte *d = _buffers[kBitFront] + (r.left + (r.width()+5)/2 - 5) + (r.bottom - 1) * SCREEN_WIDTH;
+ byte *d = _buffers[kBitFront] + (r.left + (r.width()+5)/2 - 5) + (r.bottom - 1) * _vm->_screenWidth;
for (uint16 i = 0; i < BALLOON_HEIGHT; i++) {
for (uint16 j = 0; j < BALLOON_WIDTH; j++) {
@@ -92,7 +89,7 @@ void Gfx::drawBalloon(const Common::Rect& r, uint16 winding) {
s++;
}
- d += (SCREEN_WIDTH - BALLOON_WIDTH);
+ d += (_vm->_screenWidth - BALLOON_WIDTH);
}
// printf("done\n");
@@ -142,7 +139,7 @@ void Gfx::setPalette(Palette pal, uint32 first, uint32 num) {
if (_vm->getPlatform() == Common::kPlatformAmiga)
g_system->setPalette(sysExtraPal, first+FIRST_EHB_COLOR, num);
- g_system->updateScreen();
+// g_system->updateScreen();
return;
}
@@ -206,14 +203,7 @@ void Gfx::animatePalette() {
return;
}
-void Gfx::fadePalette(Palette pal) {
- for (uint16 i = 0; i < BASE_PALETTE_COLORS * 3; i++)
- if (pal[i] < _palette[i]) pal[i]++;
-
- return;
-}
-
-void Gfx::buildBWPalette(Palette pal) {
+void Gfx::makeGrayscalePalette(Palette pal) {
for (uint16 i = 0; i < BASE_PALETTE_COLORS; i++) {
byte max;
@@ -229,11 +219,19 @@ void Gfx::buildBWPalette(Palette pal) {
return;
}
-void Gfx::quickFadePalette(Palette pal) {
+void Gfx::fadePalette(Palette pal, Palette target, uint step) {
+
+ if (step == 0)
+ return;
for (uint16 i = 0; i < BASE_PALETTE_COLORS * 3; i++) {
- if (pal[i] == _palette[i]) continue;
- pal[i] += (pal[i] < _palette[i] ? 4 : -4);
+ if (pal[i] == target[i]) continue;
+
+ if (pal[i] < target[i])
+ pal[i] = CLIP(pal[i] + step, (uint)0, (uint)target[i]);
+ else
+ pal[i] = CLIP(pal[i] - step, (uint)target[i], (uint)255);
+
}
return;
@@ -258,7 +256,7 @@ void Gfx::setHalfbriteMode(bool enable) {
void Gfx::updateScreen() {
// printf("Gfx::updateScreen()\n");
- g_system->copyRectToScreen(_buffers[kBitFront], SCREEN_WIDTH, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
+ g_system->copyRectToScreen(_buffers[kBitFront], _vm->_screenWidth, 0, 0, _vm->_screenWidth, _vm->_screenHeight);
g_system->updateScreen();
return;
}
@@ -277,7 +275,7 @@ void Gfx::swapBuffers() {
// graphic primitives
//
void Gfx::clearScreen(Gfx::Buffers buffer) {
- memset(_buffers[buffer], 0, SCREEN_WIDTH*SCREEN_HEIGHT);
+ memset(_buffers[buffer], 0, _vm->_screenSize);
if (buffer == kBitFront) updateScreen();
@@ -286,9 +284,9 @@ void Gfx::clearScreen(Gfx::Buffers buffer) {
void Gfx::copyScreen(Gfx::Buffers srcbuffer, Gfx::Buffers dstbuffer) {
- memcpy(_buffers[dstbuffer], _buffers[srcbuffer], SCREEN_WIDTH*SCREEN_HEIGHT);
+ memcpy(_buffers[dstbuffer], _buffers[srcbuffer], _vm->_screenSize);
- if (dstbuffer == kBitFront) updateScreen();
+// if (dstbuffer == kBitFront) updateScreen();
return;
}
@@ -296,25 +294,25 @@ void Gfx::copyScreen(Gfx::Buffers srcbuffer, Gfx::Buffers dstbuffer) {
void Gfx::floodFill(Gfx::Buffers buffer, const Common::Rect& r, byte color) {
// printf("Gfx::floodFill(%i, %i, %i, %i, %i)\n", color, left, top, right, bottom);
- byte *d = _buffers[buffer] + (r.left + r.top * SCREEN_WIDTH);
+ byte *d = _buffers[buffer] + (r.left + r.top * _vm->_screenWidth);
uint16 w = r.width() + 1;
uint16 h = r.height() + 1;
for (uint16 i = 0; i < h; i++) {
memset(d, color, w);
- d += SCREEN_WIDTH;
+ d += _vm->_screenWidth;
}
return;
}
-void screenClip(Common::Rect& r, Common::Point& p) {
+void Gfx::screenClip(Common::Rect& r, Common::Point& p) {
int32 x = r.left;
int32 y = r.top;
- Common::Rect screen(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
+ Common::Rect screen(0, 0, _vm->_screenWidth, _vm->_screenHeight);
r.clip(screen);
@@ -335,7 +333,7 @@ void Gfx::flatBlit(const Common::Rect& r, byte *data, Gfx::Buffers buffer) {
screenClip(q, dp);
byte *s = data + q.left + q.top * r.width();
- byte *d = _buffers[buffer] + dp.x + dp.y * SCREEN_WIDTH;
+ byte *d = _buffers[buffer] + dp.x + dp.y * _vm->_screenWidth;
for (uint16 i = q.top; i < q.bottom; i++) {
for (uint16 j = q.left; j < q.right; j++) {
@@ -345,7 +343,7 @@ void Gfx::flatBlit(const Common::Rect& r, byte *data, Gfx::Buffers buffer) {
}
s += (r.width() - q.width());
- d += (SCREEN_WIDTH - q.width());
+ d += (_vm->_screenWidth - q.width());
}
return;
@@ -360,12 +358,12 @@ void Gfx::blit(const Common::Rect& r, uint16 z, byte *data, Gfx::Buffers buffer)
screenClip(q, dp);
byte *s = data + q.left + q.top * r.width();
- byte *d = _buffers[buffer] + dp.x + dp.y * SCREEN_WIDTH;
+ byte *d = _buffers[buffer] + dp.x + dp.y * _vm->_screenWidth;
for (uint16 i = q.top; i < q.bottom; i++) {
uint16 n = dp.x % 4;
- byte *m = _buffers[kMask0] + dp.x/4 + (dp.y + i - q.top)*SCREENMASK_WIDTH;
+ byte *m = _buffers[kMask0] + dp.x/4 + (dp.y + i - q.top)*_vm->_screenMaskWidth;
for (uint16 j = q.left; j < q.right; j++) {
if (*s != 0) {
@@ -382,7 +380,7 @@ void Gfx::blit(const Common::Rect& r, uint16 z, byte *data, Gfx::Buffers buffer)
}
s += (r.width() - q.right + q.left);
- d += (SCREEN_WIDTH - q.right + q.left);
+ d += (_vm->_screenWidth - q.right + q.left);
}
return;
@@ -420,8 +418,8 @@ void jobEraseLabel(void *parm, Job *j) {
if (_si < 0) _si = 0;
if (_di > 190) _di = 190;
- if (label->_cnv._width + _si > SCREEN_WIDTH)
- _si = SCREEN_WIDTH - label->_cnv._width;
+ if (label->_cnv._width + _si > _vm->_screenWidth)
+ _si = _vm->_screenWidth - label->_cnv._width;
Common::Rect r(label->_cnv._width, label->_cnv._height);
r.moveTo(_vm->_gfx->_labelPosition[1]);
@@ -438,8 +436,8 @@ void Gfx::initMouse(uint16 arg_0) {
_mouseComposedArrow = _vm->_disk->loadPointer();
- byte temp[16*16];
- memcpy(temp, _mouseArrow, 16*16);
+ byte temp[MOUSEARROW_WIDTH*MOUSEARROW_HEIGHT];
+ memcpy(temp, _mouseArrow, MOUSEARROW_WIDTH*MOUSEARROW_HEIGHT);
uint16 k = 0;
for (uint16 i = 0; i < 4; i++) {
@@ -449,20 +447,30 @@ void Gfx::initMouse(uint16 arg_0) {
return;
}
+
void Gfx::setMousePointer(int16 index) {
if (index == kCursorArrow) { // standard mouse pointer
- g_system->setMouseCursor(_mouseArrow, 16, 16, 0, 0, 0);
+ g_system->setMouseCursor(_mouseArrow, MOUSEARROW_WIDTH, MOUSEARROW_HEIGHT, 0, 0, 0);
g_system->showMouse(true);
} else {
// inventory item pointer
byte *v8 = _mouseComposedArrow->_data0;
- // FIXME: target offseting is not clear
- extractInventoryGraphics(index, v8 + 7 + 32 * 7);
- g_system->setMouseCursor(v8, 32, 32, 0, 0, 0);
+ // FIXME: destination offseting is not clear
+ byte* s = _vm->_char._objs->getFramePtr(getInventoryItemIndex(index));
+ byte* d = v8 + 7 + MOUSECOMBO_WIDTH * 7;
+
+ for (uint32 i = 0; i < INVENTORYITEM_HEIGHT; i++) {
+ memcpy(d, s, INVENTORYITEM_WIDTH);
+
+ s += INVENTORYITEM_PITCH;
+ d += MOUSECOMBO_WIDTH;
+ }
+
+ g_system->setMouseCursor(v8, MOUSECOMBO_WIDTH, MOUSECOMBO_HEIGHT, 0, 0, 0);
}
return;
@@ -505,13 +513,13 @@ void Gfx::blitCnv(StaticCnv *cnv, int16 x, int16 y, uint16 z, Gfx::Buffers buffe
void Gfx::backupDoorBackground(DoorData *data, int16 x, int16 y) {
- byte *s = _buffers[kBit2] + x + y * SCREEN_WIDTH;
+ byte *s = _buffers[kBit2] + x + y * _vm->_screenWidth;
byte *d = data->_background;
for (uint16 i = 0; i < data->_cnv->_height ; i++) {
memcpy(d, s, data->_cnv->_width);
- s += SCREEN_WIDTH;
+ s += _vm->_screenWidth;
d += data->_cnv->_width;
}
@@ -521,7 +529,7 @@ void Gfx::backupDoorBackground(DoorData *data, int16 x, int16 y) {
void Gfx::backupGetBackground(GetData *data, int16 x, int16 y) {
byte *t = data->_cnv->_data0;
- byte *s = _buffers[kBitBack] + x + y * SCREEN_WIDTH;
+ byte *s = _buffers[kBitBack] + x + y * _vm->_screenWidth;
byte *d = data->_backup;
for (uint16 i = 0; i < data->_cnv->_height ; i++) {
@@ -533,16 +541,48 @@ void Gfx::backupGetBackground(GetData *data, int16 x, int16 y) {
s++;
}
- s += (SCREEN_WIDTH - data->_cnv->_width);
+ s += (_vm->_screenWidth - data->_cnv->_width);
+ }
+
+ return;
+}
+
+//
+// restores background according to specified frame
+//
+void Gfx::restoreDoorBackground(StaticCnv *cnv, const Common::Rect& r, byte* background) {
+
+ byte *t = cnv->_data0;
+ byte *s = background;
+ byte *d0 = _buffers[kBitBack] + r.left + r.top * _vm->_screenWidth;
+ byte *d1 = _buffers[kBit2] + r.left + r.top * _vm->_screenWidth;
+
+ for (uint16 i = 0; i < r.height() ; i++) {
+ for (uint16 j = 0; j < r.width() ; j++) {
+ if (*t) {
+ *d0 = *s;
+ *d1 = *s;
+ }
+
+ d0++;
+ d1++;
+ t++;
+ s++;
+ }
+
+ d0 += (_vm->_screenWidth - r.width());
+ d1 += (_vm->_screenWidth - r.width());
}
+
return;
}
+
//
// copies a rectangular bitmap on the background
//
-void Gfx::restoreZoneBackground(const Common::Rect& r, byte *data) {
+void Gfx::restoreGetBackground(const Common::Rect& r, byte *data) {
StaticCnv cnv;
@@ -584,17 +624,17 @@ void Gfx::makeCnvFromString(StaticCnv *cnv, char *text) {
}
void Gfx::displayString(uint16 x, uint16 y, const char *text, byte color) {
- byte *dst = _buffers[kBitFront] + x + y*SCREEN_WIDTH;
+ byte *dst = _buffers[kBitFront] + x + y*_vm->_screenWidth;
_font->setColor(color);
- _font->drawString(dst, SCREEN_WIDTH, text);
+ _font->drawString(dst, _vm->_screenWidth, text);
}
void Gfx::displayCenteredString(uint16 y, const char *text) {
- uint16 x = (SCREEN_WIDTH - getStringWidth(text)) / 2;
+ uint16 x = (_vm->_screenWidth - getStringWidth(text)) / 2;
displayString(x, y, text, 1);
}
-bool Gfx::displayWrappedString(char *text, uint16 x, uint16 y, byte color, uint16 wrapwidth) {
+bool Gfx::displayWrappedString(char *text, uint16 x, uint16 y, byte color, int16 wrapwidth) {
// printf("Gfx::displayWrappedString(%s, %i, %i, %i, %i)...", text, x, y, color, wrapwidth);
uint16 lines = 0;
@@ -606,6 +646,9 @@ bool Gfx::displayWrappedString(char *text, uint16 x, uint16 y, byte color, uint1
char token[40];
+ if (wrapwidth == -1)
+ wrapwidth = _vm->_screenWidth;
+
while (strlen(text) > 0) {
text = parseNextToken(text, token, 40, " ", true);
@@ -694,11 +737,11 @@ void Gfx::restoreBackground(const Common::Rect& r) {
if (left < 0) left = 0;
if (top < 0) top = 0;
- if (left >= SCREEN_WIDTH) return;
- if (top >= SCREEN_HEIGHT) return;
+ if (left >= _vm->_screenWidth) return;
+ if (top >= _vm->_screenHeight) return;
- if (left+width >= SCREEN_WIDTH) width = SCREEN_WIDTH - left;
- if (top+height >= SCREEN_HEIGHT) height = SCREEN_HEIGHT - top;
+ if (left+width >= _vm->_screenWidth) width = _vm->_screenWidth - left;
+ if (top+height >= _vm->_screenHeight) height = _vm->_screenHeight - top;
Common::Rect q(width, height);
q.moveTo(left, top);
@@ -706,8 +749,8 @@ void Gfx::restoreBackground(const Common::Rect& r) {
copyRect(
kBitBack,
q,
- _buffers[kBit2] + q.left + q.top * SCREEN_WIDTH,
- SCREEN_WIDTH
+ _buffers[kBit2] + q.left + q.top * _vm->_screenWidth,
+ _vm->_screenWidth
);
return;
@@ -728,26 +771,26 @@ void Gfx::freeStaticCnv(StaticCnv *cnv) {
void Gfx::setBackground(byte *background) {
- memcpy(_buffers[kBitBack], background, SCREEN_WIDTH*SCREEN_HEIGHT);
+ memcpy(_buffers[kBitBack], background, _vm->_screenSize);
copyScreen(kBitBack, kBit2);
}
void Gfx::setMask(byte *mask) {
- memcpy(_buffers[kMask0], mask, SCREENMASK_WIDTH*SCREEN_HEIGHT);
+ memcpy(_buffers[kMask0], mask, _vm->_screenMaskSize);
}
void Gfx::copyRect(Gfx::Buffers dstbuffer, const Common::Rect& r, byte *src, uint16 pitch) {
- byte *d = _buffers[dstbuffer] + r.left + SCREEN_WIDTH * r.top;
+ byte *d = _buffers[dstbuffer] + r.left + _vm->_screenWidth * r.top;
byte *s = src;
for (uint16 _si = 0; _si < r.height(); _si++) {
memcpy(d, s, r.width());
s += pitch;
- d += SCREEN_WIDTH;
+ d += _vm->_screenWidth;
}
@@ -756,51 +799,49 @@ void Gfx::copyRect(Gfx::Buffers dstbuffer, const Common::Rect& r, byte *src, uin
void Gfx::grabRect(byte *dst, const Common::Rect& r, Gfx::Buffers srcbuffer, uint16 pitch) {
- byte *s = _buffers[srcbuffer] + r.left + SCREEN_WIDTH * r.top;
+ byte *s = _buffers[srcbuffer] + r.left + _vm->_screenWidth * r.top;
for (uint16 i = 0; i < r.height(); i++) {
memcpy(dst, s, r.width());
- s += SCREEN_WIDTH;
+ s += _vm->_screenWidth;
dst += pitch;
}
return;
}
+/*
+ the following 3 routines are hacks for Nippon Safes coming from the original code,
+ so they shouldn't be modified when adding support for other games
+*/
void Gfx::plotMaskPixel(uint16 x, uint16 y, byte color) {
- uint16 _ax = x + y * SCREEN_WIDTH;
+ uint16 _ax = x + y * _vm->_screenWidth;
_buffers[kMask0][_ax >> 2] &= ~(3 << ((_ax & 3) << 1));
return;
}
-
-
-
void Gfx::fillMaskRect(const Common::Rect& r, byte color) {
- uint16 _di = r.left/4 + r.top*80;
+ uint16 _di = r.left/4 + r.top * _vm->_screenMaskWidth;
for (uint16 _si = r.top; _si < r.bottom; _si++) {
memset(&_buffers[kMask0][_di], color, r.width()/4+1);
- _di += 80;
+ _di += _vm->_screenMaskWidth;
}
return;
}
-
-// HACK
-// this routine is only invoked from the 'intgrotta scenario'
-//
void Gfx::intGrottaHackMask() {
memset(_buffers[kMask0] + 3600, 0, 3600);
_bgLayers[1] = 500;
return;
}
+
int16 Gfx::queryMask(int16 v) {
for (uint16 _si = 0; _si < 3; _si++) {
@@ -814,13 +855,13 @@ Gfx::Gfx(Parallaction* vm) :
_vm(vm) {
g_system->beginGFXTransaction();
- g_system->initSize(SCREEN_WIDTH, SCREEN_HEIGHT);
+ g_system->initSize(_vm->_screenWidth, _vm->_screenHeight);
g_system->endGFXTransaction();
- _buffers[kBitFront] = (byte*)malloc(SCREEN_SIZE);
- _buffers[kBitBack] = (byte*)malloc(SCREEN_SIZE);
- _buffers[kBit2] = (byte*)malloc(SCREEN_SIZE);
- _buffers[kMask0] = (byte*)malloc(SCREENMASK_WIDTH * SCREEN_HEIGHT);
+ _buffers[kBitFront] = (byte*)malloc(_vm->_screenSize);
+ _buffers[kBitBack] = (byte*)malloc(_vm->_screenSize);
+ _buffers[kBit2] = (byte*)malloc(_vm->_screenSize);
+ _buffers[kMask0] = (byte*)malloc(_vm->_screenMaskWidth * _vm->_screenHeight);
setBlackPalette();