~ubuntu-branches/debian/jessie/scummvm/jessie

« back to all changes in this revision

Viewing changes to engines/sci/graphics/transitions.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Moritz Muehlenhoff
  • Date: 2010-05-07 18:57:09 UTC
  • mto: This revision was merged to the branch mainline in revision 18.
  • Revision ID: james.westby@ubuntu.com-20100507185709-34v8yycywjrou5o3
Tags: upstream-1.1.1
ImportĀ upstreamĀ versionĀ 1.1.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* ScummVM - Graphic Adventure Engine
 
2
 *
 
3
 * ScummVM is the legal property of its developers, whose names
 
4
 * are too numerous to list here. Please refer to the COPYRIGHT
 
5
 * file distributed with this source distribution.
 
6
 *
 
7
 * This program is free software; you can redistribute it and/or
 
8
 * modify it under the terms of the GNU General Public License
 
9
 * as published by the Free Software Foundation; either version 2
 
10
 * of the License, or (at your option) any later version.
 
11
 
 
12
 * This program is distributed in the hope that it will be useful,
 
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
 * GNU General Public License for more details.
 
16
 
 
17
 * You should have received a copy of the GNU General Public License
 
18
 * along with this program; if not, write to the Free Software
 
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
20
 *
 
21
 * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/tags/release-1-1-1/engines/sci/graphics/transitions.cpp $
 
22
 * $Id: transitions.cpp 48084 2010-02-17 23:37:32Z fingolfin $
 
23
 *
 
24
 */
 
25
 
 
26
#include "common/events.h"
 
27
#include "common/util.h"
 
28
#include "common/stack.h"
 
29
#include "common/system.h"
 
30
#include "graphics/surface.h"
 
31
 
 
32
#include "sci/sci.h"
 
33
#include "sci/engine/state.h"
 
34
#include "sci/graphics/gui.h"
 
35
#include "sci/graphics/screen.h"
 
36
#include "sci/graphics/palette.h"
 
37
#include "sci/graphics/transitions.h"
 
38
 
 
39
namespace Sci {
 
40
 
 
41
GfxTransitions::GfxTransitions(SciGui *gui, GfxScreen *screen, GfxPalette *palette, bool isVGA)
 
42
        : _gui(gui), _screen(screen), _palette(palette), _isVGA(isVGA) {
 
43
        init();
 
44
}
 
45
 
 
46
GfxTransitions::~GfxTransitions() {
 
47
        delete[] _oldScreen;
 
48
}
 
49
 
 
50
// This table contains a mapping between oldIDs (prior SCI1LATE) and newIDs
 
51
static const GfxTransitionTranslateEntry oldTransitionIDs[] = {
 
52
        {   0, SCI_TRANSITIONS_VERTICALROLL_FROMCENTER,         false },
 
53
        {   1, SCI_TRANSITIONS_HORIZONTALROLL_FROMCENTER,       false },
 
54
        {   2, SCI_TRANSITIONS_STRAIGHT_FROM_RIGHT,                     false },
 
55
        {   3, SCI_TRANSITIONS_STRAIGHT_FROM_LEFT,                      false },
 
56
        {   4, SCI_TRANSITIONS_STRAIGHT_FROM_BOTTOM,            false },
 
57
        {   5, SCI_TRANSITIONS_STRAIGHT_FROM_TOP,                       false },
 
58
        {   6, SCI_TRANSITIONS_DIAGONALROLL_FROMCENTER,         false },
 
59
        {   7, SCI_TRANSITIONS_DIAGONALROLL_TOCENTER,           false },
 
60
        {   8, SCI_TRANSITIONS_BLOCKS,                                          false },
 
61
        {   9, SCI_TRANSITIONS_VERTICALROLL_TOCENTER,           false },
 
62
        {  10, SCI_TRANSITIONS_HORIZONTALROLL_TOCENTER,         false },
 
63
        {  11, SCI_TRANSITIONS_STRAIGHT_FROM_RIGHT,                     true },
 
64
        {  12, SCI_TRANSITIONS_STRAIGHT_FROM_LEFT,                      true },
 
65
        {  13, SCI_TRANSITIONS_STRAIGHT_FROM_BOTTOM,            true },
 
66
        {  14, SCI_TRANSITIONS_STRAIGHT_FROM_TOP,                       true },
 
67
        {  15, SCI_TRANSITIONS_DIAGONALROLL_FROMCENTER,         true },
 
68
        {  16, SCI_TRANSITIONS_DIAGONALROLL_TOCENTER,           true },
 
69
        {  17, SCI_TRANSITIONS_BLOCKS,                                          true },
 
70
        {  18, SCI_TRANSITIONS_PIXELATION,                                      false },
 
71
        {  27, SCI_TRANSITIONS_PIXELATION       ,                               true },
 
72
        {  30, SCI_TRANSITIONS_FADEPALETTE,                                     false },
 
73
        {  40, SCI_TRANSITIONS_SCROLL_RIGHT,                            false },
 
74
        {  41, SCI_TRANSITIONS_SCROLL_LEFT,                                     false },
 
75
        {  42, SCI_TRANSITIONS_SCROLL_UP,                                       false },
 
76
        {  43, SCI_TRANSITIONS_SCROLL_DOWN,                                     false },
 
77
        { 100, SCI_TRANSITIONS_NONE,                                            false },
 
78
        { 255, 255,                                                                                     false }
 
79
};
 
80
 
 
81
// this table defines the blackout-transition that needs to be done prior doing the actual transition
 
82
static const GfxTransitionTranslateEntry blackoutTransitionIDs[] = {
 
83
        { SCI_TRANSITIONS_VERTICALROLL_FROMCENTER,                      SCI_TRANSITIONS_VERTICALROLL_TOCENTER,          true },
 
84
        { SCI_TRANSITIONS_HORIZONTALROLL_FROMCENTER,            SCI_TRANSITIONS_HORIZONTALROLL_TOCENTER,        true },
 
85
        { SCI_TRANSITIONS_STRAIGHT_FROM_RIGHT,                          SCI_TRANSITIONS_STRAIGHT_FROM_LEFT,                     true },
 
86
        { SCI_TRANSITIONS_STRAIGHT_FROM_LEFT,                           SCI_TRANSITIONS_STRAIGHT_FROM_RIGHT,            true },
 
87
        { SCI_TRANSITIONS_STRAIGHT_FROM_BOTTOM,                         SCI_TRANSITIONS_STRAIGHT_FROM_TOP,                      true },
 
88
        { SCI_TRANSITIONS_STRAIGHT_FROM_TOP,                            SCI_TRANSITIONS_STRAIGHT_FROM_BOTTOM,           true },
 
89
        { SCI_TRANSITIONS_DIAGONALROLL_FROMCENTER,                      SCI_TRANSITIONS_DIAGONALROLL_TOCENTER,          true },
 
90
        { SCI_TRANSITIONS_DIAGONALROLL_TOCENTER,                        SCI_TRANSITIONS_DIAGONALROLL_FROMCENTER,        true },
 
91
        { SCI_TRANSITIONS_BLOCKS,                                                       SCI_TRANSITIONS_BLOCKS,                                         true },
 
92
        { SCI_TRANSITIONS_PIXELATION,                                           SCI_TRANSITIONS_PIXELATION,                                     true },
 
93
        { SCI_TRANSITIONS_FADEPALETTE,                                          SCI_TRANSITIONS_NONE,                                           true },
 
94
        { SCI_TRANSITIONS_SCROLL_RIGHT,                                         SCI_TRANSITIONS_NONE,                                           true },
 
95
        { SCI_TRANSITIONS_SCROLL_LEFT,                                          SCI_TRANSITIONS_NONE,                                           true },
 
96
        { SCI_TRANSITIONS_SCROLL_UP,                                            SCI_TRANSITIONS_NONE,                                           true },
 
97
        { SCI_TRANSITIONS_SCROLL_DOWN,                                          SCI_TRANSITIONS_NONE,                                           true },
 
98
        { SCI_TRANSITIONS_NONE_LONGBOW,                                         SCI_TRANSITIONS_NONE,                                           true },
 
99
        { SCI_TRANSITIONS_NONE,                                                         SCI_TRANSITIONS_NONE,                                           true },
 
100
        { SCI_TRANSITIONS_VERTICALROLL_TOCENTER,                        SCI_TRANSITIONS_NONE,                                           true },
 
101
        { SCI_TRANSITIONS_HORIZONTALROLL_TOCENTER,                      SCI_TRANSITIONS_NONE,                                           true },
 
102
        { 255,                                                                                          255,                                                                            true }
 
103
};
 
104
 
 
105
void GfxTransitions::init() {
 
106
        _oldScreen = new byte[_screen->getDisplayHeight() * _screen->getDisplayWidth()];
 
107
 
 
108
        if (getSciVersion() >= SCI_VERSION_1_LATE)
 
109
                _translationTable = NULL;
 
110
        else
 
111
                _translationTable = oldTransitionIDs;
 
112
 
 
113
        // setup default transition
 
114
        _number = SCI_TRANSITIONS_HORIZONTALROLL_FROMCENTER;
 
115
        _blackoutFlag = false;
 
116
}
 
117
 
 
118
void GfxTransitions::setup(int16 number, bool blackoutFlag) {
 
119
        if (number != -1) {
 
120
                _number = number;
 
121
                _blackoutFlag = blackoutFlag;
 
122
        }
 
123
}
 
124
 
 
125
void GfxTransitions::updateScreenAndWait(int msec) {
 
126
        Common::Event ev;
 
127
        g_system->updateScreen();
 
128
        g_system->delayMillis(msec);
 
129
        while (g_system->getEventManager()->pollEvent(ev)) {}   // discard all events
 
130
}
 
131
 
 
132
// will translate a number and return corresponding translationEntry
 
133
const GfxTransitionTranslateEntry *GfxTransitions::translateNumber (int16 number, const GfxTransitionTranslateEntry *tablePtr) {
 
134
        while (1) {
 
135
                if (tablePtr->orgId == 255)
 
136
                        return NULL;
 
137
                if (tablePtr->orgId == number)
 
138
                        return tablePtr;
 
139
                tablePtr++;
 
140
        }
 
141
}
 
142
 
 
143
void GfxTransitions::doit(Common::Rect picRect) {
 
144
        const GfxTransitionTranslateEntry *translationEntry = _translationTable;
 
145
 
 
146
        _picRect = picRect;
 
147
 
 
148
        if (_translationTable) {
 
149
                // We need to translate the ID
 
150
                translationEntry = translateNumber(_number, _translationTable);
 
151
                if (translationEntry) {
 
152
                        _number = translationEntry->newId;
 
153
                        _blackoutFlag = translationEntry->blackoutFlag;
 
154
                } else {
 
155
                        warning("Transitions: old ID %d not supported", _number);
 
156
                        _number = SCI_TRANSITIONS_NONE;
 
157
                        _blackoutFlag = false;
 
158
                }
 
159
        }
 
160
 
 
161
        if (_blackoutFlag) {
 
162
                // We need to find out what transition we are supposed to use for blackout
 
163
                translationEntry = translateNumber(_number, blackoutTransitionIDs);
 
164
                if (translationEntry) {
 
165
                        doTransition(translationEntry->newId, true);
 
166
                } else {
 
167
                        warning("Transitions: ID %d not listed in blackoutTransitionIDs", _number);
 
168
                }
 
169
        }
 
170
 
 
171
        // Now we do the actual transition to the new screen
 
172
        doTransition(_number, false);
 
173
 
 
174
        if (picRect.bottom != _screen->getHeight()) {
 
175
                // TODO: this is a workaround for lsl6 not showing menubar when playing
 
176
                //  There is some new code in the sierra sci in ShowPic that seems to do something similar to this
 
177
                _screen->copyToScreen();
 
178
                g_system->updateScreen();
 
179
        }
 
180
 
 
181
        _screen->_picNotValid = 0;
 
182
}
 
183
 
 
184
// This may get called twice, if blackoutFlag is set. It will get once called with blackoutFlag set and another time
 
185
//  with no blackoutFlag.
 
186
void GfxTransitions::doTransition(int16 number, bool blackoutFlag) {
 
187
        if (number != SCI_TRANSITIONS_FADEPALETTE) {
 
188
                setNewPalette(blackoutFlag);
 
189
        }
 
190
 
 
191
        switch (number) {
 
192
        case SCI_TRANSITIONS_VERTICALROLL_FROMCENTER:
 
193
                verticalRollFromCenter(blackoutFlag);
 
194
                break;
 
195
        case SCI_TRANSITIONS_VERTICALROLL_TOCENTER:
 
196
                verticalRollFromCenter(blackoutFlag);
 
197
                break;
 
198
        case SCI_TRANSITIONS_HORIZONTALROLL_FROMCENTER:
 
199
                horizontalRollFromCenter(blackoutFlag);
 
200
                break;
 
201
        case SCI_TRANSITIONS_HORIZONTALROLL_TOCENTER:
 
202
                horizontalRollToCenter(blackoutFlag);
 
203
                break;
 
204
        case SCI_TRANSITIONS_DIAGONALROLL_TOCENTER:
 
205
                diagonalRollToCenter(blackoutFlag);
 
206
                break;
 
207
        case SCI_TRANSITIONS_DIAGONALROLL_FROMCENTER:
 
208
                diagonalRollFromCenter(blackoutFlag);
 
209
                break;
 
210
 
 
211
        case SCI_TRANSITIONS_STRAIGHT_FROM_RIGHT:
 
212
        case SCI_TRANSITIONS_STRAIGHT_FROM_LEFT:
 
213
        case SCI_TRANSITIONS_STRAIGHT_FROM_BOTTOM:
 
214
        case SCI_TRANSITIONS_STRAIGHT_FROM_TOP:
 
215
                straight(number, blackoutFlag);
 
216
                break;
 
217
 
 
218
        case SCI_TRANSITIONS_PIXELATION:
 
219
                pixelation(blackoutFlag);
 
220
                break;
 
221
 
 
222
        case SCI_TRANSITIONS_BLOCKS:
 
223
                blocks(blackoutFlag);
 
224
                break;
 
225
 
 
226
        case SCI_TRANSITIONS_FADEPALETTE:
 
227
                if (!blackoutFlag) {
 
228
                        fadeOut(); setNewScreen(blackoutFlag); fadeIn();
 
229
                }
 
230
                break;
 
231
 
 
232
        case SCI_TRANSITIONS_SCROLL_RIGHT:
 
233
        case SCI_TRANSITIONS_SCROLL_LEFT:
 
234
        case SCI_TRANSITIONS_SCROLL_UP:
 
235
        case SCI_TRANSITIONS_SCROLL_DOWN:
 
236
                scroll(number);
 
237
                break;
 
238
 
 
239
        case SCI_TRANSITIONS_NONE_LONGBOW:
 
240
        case SCI_TRANSITIONS_NONE:
 
241
                setNewScreen(blackoutFlag);
 
242
                break;
 
243
 
 
244
        default:
 
245
                warning("Transitions: ID %d not implemented", number);
 
246
                setNewScreen(blackoutFlag);
 
247
        }
 
248
}
 
249
 
 
250
void GfxTransitions::setNewPalette(bool blackoutFlag) {
 
251
        if (!blackoutFlag)
 
252
                if (_isVGA)
 
253
                        _palette->setOnScreen();
 
254
}
 
255
 
 
256
void GfxTransitions::setNewScreen(bool blackoutFlag) {
 
257
        if (!blackoutFlag) {
 
258
                _screen->copyRectToScreen(_picRect);
 
259
                g_system->updateScreen();
 
260
        }
 
261
}
 
262
 
 
263
void GfxTransitions::copyRectToScreen(const Common::Rect rect, bool blackoutFlag) {
 
264
        if (!blackoutFlag) {
 
265
                _screen->copyRectToScreen(rect);
 
266
        } else {
 
267
                Graphics::Surface *surface = g_system->lockScreen();
 
268
                surface->fillRect(rect, 0);
 
269
                g_system->unlockScreen();
 
270
        }
 
271
}
 
272
 
 
273
// Note: dont do too many steps in here, otherwise cpu will crap out because of the load
 
274
void GfxTransitions::fadeOut() {
 
275
        byte oldPalette[4 * 256], workPalette[4 * 256];
 
276
        int16 stepNr, colorNr;
 
277
 
 
278
        g_system->grabPalette(oldPalette, 0, 256);
 
279
 
 
280
        for (stepNr = 100; stepNr >= 0; stepNr -= 10) {
 
281
                for (colorNr = 1; colorNr < 255; colorNr++){
 
282
                        workPalette[colorNr * 4 + 0] = oldPalette[colorNr * 4] * stepNr / 100;
 
283
                        workPalette[colorNr * 4 + 1] = oldPalette[colorNr * 4 + 1] * stepNr / 100;
 
284
                        workPalette[colorNr * 4 + 2] = oldPalette[colorNr * 4 + 2] * stepNr / 100;
 
285
                }
 
286
                g_system->setPalette(workPalette + 4, 1, 254);
 
287
                _gui->wait(2);
 
288
        }
 
289
}
 
290
 
 
291
// Note: dont do too many steps in here, otherwise cpu will crap out because of the load
 
292
void GfxTransitions::fadeIn() {
 
293
        int16 stepNr;
 
294
 
 
295
        for (stepNr = 0; stepNr <= 100; stepNr += 10) {
 
296
                _palette->kernelSetIntensity(1, 255, stepNr, true);
 
297
                _gui->wait(2);
 
298
        }
 
299
}
 
300
 
 
301
// pixelates the new picture over the old one - works against the whole screen
 
302
// TODO: it seems this needs to get applied on _picRect only if possible
 
303
void GfxTransitions::pixelation (bool blackoutFlag) {
 
304
        uint16 mask = 0x40, stepNr = 0;
 
305
        Common::Rect pixelRect;
 
306
 
 
307
        do {
 
308
                mask = (mask & 1) ? (mask >> 1) ^ 0xB400 : mask >> 1;
 
309
                if (mask >= _screen->getWidth() * _screen->getHeight())
 
310
                        continue;
 
311
                pixelRect.left = mask % _screen->getWidth(); pixelRect.right = pixelRect.left + 1;
 
312
                pixelRect.top = mask / _screen->getWidth();     pixelRect.bottom = pixelRect.top + 1;
 
313
                pixelRect.clip(_picRect);
 
314
                if (!pixelRect.isEmpty())
 
315
                        copyRectToScreen(pixelRect, blackoutFlag);
 
316
                if ((stepNr & 0x3FF) == 0) {
 
317
                        updateScreenAndWait(5);
 
318
                }
 
319
                stepNr++;
 
320
        } while (mask != 0x40);
 
321
}
 
322
 
 
323
// like pixelation but uses 8x8 blocks - works against the whole screen
 
324
// TODO: it seems this needs to get applied on _picRect only if possible
 
325
void GfxTransitions::blocks(bool blackoutFlag) {
 
326
        uint16 mask = 0x40, stepNr = 0;
 
327
        Common::Rect blockRect;
 
328
 
 
329
        do {
 
330
                mask = (mask & 1) ? (mask >> 1) ^ 0x240 : mask >> 1;
 
331
                if (mask >= 40 * 25)
 
332
                        continue;
 
333
                blockRect.left = (mask % 40) << 3; blockRect.right = blockRect.left + 8;
 
334
                blockRect.top = (mask / 40) << 3; blockRect.bottom = blockRect.top + 8;
 
335
                blockRect.clip(_picRect);
 
336
                if (!blockRect.isEmpty())
 
337
                        copyRectToScreen(blockRect, blackoutFlag);
 
338
                if ((stepNr & 7) == 0) {
 
339
                        updateScreenAndWait(4);
 
340
                }
 
341
                stepNr++;
 
342
        } while (mask != 0x40);
 
343
}
 
344
 
 
345
// directly shows new screen starting up/down/left/right and going to the opposite direction - works on _picRect area only
 
346
void GfxTransitions::straight(int16 number, bool blackoutFlag) {
 
347
        int16 stepNr = 0;
 
348
        Common::Rect newScreenRect = _picRect;
 
349
 
 
350
        switch (number) {
 
351
        case SCI_TRANSITIONS_STRAIGHT_FROM_RIGHT:
 
352
                newScreenRect.left = newScreenRect.right - 1;
 
353
                while (newScreenRect.left >= _picRect.left) {
 
354
                        copyRectToScreen(newScreenRect, blackoutFlag);
 
355
                        if ((stepNr & 1) == 0) {
 
356
                                updateScreenAndWait(1);
 
357
                        }
 
358
                        stepNr++;
 
359
                        newScreenRect.translate(-1, 0);
 
360
                }
 
361
                break;
 
362
 
 
363
        case SCI_TRANSITIONS_STRAIGHT_FROM_LEFT:
 
364
                newScreenRect.right = newScreenRect.left + 1;
 
365
                while (newScreenRect.right <= _picRect.right) {
 
366
                        copyRectToScreen(newScreenRect, blackoutFlag);
 
367
                        if ((stepNr & 1) == 0) {
 
368
                                updateScreenAndWait(1);
 
369
                        }
 
370
                        stepNr++;
 
371
                        newScreenRect.translate(1, 0);
 
372
                }
 
373
                break;
 
374
 
 
375
        case SCI_TRANSITIONS_STRAIGHT_FROM_BOTTOM:
 
376
                newScreenRect.top = newScreenRect.bottom - 1;
 
377
                while (newScreenRect.top >= _picRect.top) {
 
378
                        copyRectToScreen(newScreenRect, blackoutFlag);
 
379
                        updateScreenAndWait(3);
 
380
                        stepNr++;
 
381
                        newScreenRect.translate(0, -1);
 
382
                }
 
383
                break;
 
384
 
 
385
        case SCI_TRANSITIONS_STRAIGHT_FROM_TOP:
 
386
                newScreenRect.bottom = newScreenRect.top + 1;
 
387
                while (newScreenRect.bottom <= _picRect.bottom) {
 
388
                        copyRectToScreen(newScreenRect, blackoutFlag);
 
389
                        updateScreenAndWait(3);
 
390
                        stepNr++;
 
391
                        newScreenRect.translate(0, 1);
 
392
                }
 
393
                break;
 
394
        }
 
395
}
 
396
 
 
397
// scroll old screen (up/down/left/right) and insert new screen that way - works on _picRect area only
 
398
void GfxTransitions::scroll(int16 number) {
 
399
        int16 screenWidth, screenHeight;
 
400
        byte *oldScreenPtr;
 
401
        int16 stepNr = 0;
 
402
        Common::Rect oldMoveRect = _picRect;
 
403
        Common::Rect newMoveRect = _picRect;
 
404
        Common::Rect newScreenRect = _picRect;
 
405
 
 
406
        _screen->copyFromScreen(_oldScreen);
 
407
        screenWidth = _screen->getDisplayWidth(); screenHeight = _screen->getDisplayHeight();
 
408
 
 
409
        oldScreenPtr = _oldScreen + _picRect.left + _picRect.top * screenWidth;
 
410
 
 
411
        switch (number) {
 
412
        case SCI_TRANSITIONS_SCROLL_LEFT:
 
413
                newScreenRect.right = newScreenRect.left;
 
414
                newMoveRect.left = newMoveRect.right;
 
415
                while (oldMoveRect.left < oldMoveRect.right) {
 
416
                        oldScreenPtr++; oldMoveRect.right--;
 
417
                        if (oldMoveRect.right > oldMoveRect.left)
 
418
                                g_system->copyRectToScreen(oldScreenPtr, screenWidth, oldMoveRect.left, oldMoveRect.top, oldMoveRect.width(), oldMoveRect.height());
 
419
                        newScreenRect.right++; newMoveRect.left--;
 
420
                        _screen->copyRectToScreen(newScreenRect, newMoveRect.left, newMoveRect.top);
 
421
                        if ((stepNr & 1) == 0) {
 
422
                                updateScreenAndWait(1);
 
423
                        }
 
424
                        stepNr++;
 
425
                }
 
426
                if ((stepNr & 1) == 0)
 
427
                        g_system->updateScreen();
 
428
                break;
 
429
 
 
430
        case SCI_TRANSITIONS_SCROLL_RIGHT:
 
431
                newScreenRect.left = newScreenRect.right;
 
432
                while (oldMoveRect.left < oldMoveRect.right) {
 
433
                        oldMoveRect.left++;
 
434
                        if (oldMoveRect.right > oldMoveRect.left)
 
435
                                g_system->copyRectToScreen(oldScreenPtr, screenWidth, oldMoveRect.left, oldMoveRect.top, oldMoveRect.width(), oldMoveRect.height());
 
436
                        newScreenRect.left--;
 
437
                        _screen->copyRectToScreen(newScreenRect, newMoveRect.left, newMoveRect.top);
 
438
                        if ((stepNr & 1) == 0) {
 
439
                                updateScreenAndWait(1);
 
440
                        }
 
441
                        stepNr++;
 
442
                }
 
443
                if ((stepNr & 1) == 0)
 
444
                        g_system->updateScreen();
 
445
                break;
 
446
 
 
447
        case SCI_TRANSITIONS_SCROLL_UP:
 
448
                newScreenRect.bottom = newScreenRect.top;
 
449
                newMoveRect.top = newMoveRect.bottom;
 
450
                while (oldMoveRect.top < oldMoveRect.bottom) {
 
451
                        oldScreenPtr += screenWidth; oldMoveRect.top++;
 
452
                        if (oldMoveRect.top < oldMoveRect.bottom)
 
453
                                g_system->copyRectToScreen(oldScreenPtr, screenWidth, _picRect.left, _picRect.top, oldMoveRect.width(), oldMoveRect.height());
 
454
                        newScreenRect.bottom++; newMoveRect.top--;
 
455
                        _screen->copyRectToScreen(newScreenRect, newMoveRect.left, newMoveRect.top);
 
456
                        updateScreenAndWait(3);
 
457
                }
 
458
                break;
 
459
 
 
460
        case SCI_TRANSITIONS_SCROLL_DOWN:
 
461
                newScreenRect.top = newScreenRect.bottom;
 
462
                while (oldMoveRect.top < oldMoveRect.bottom) {
 
463
                        oldMoveRect.top++;
 
464
                        if (oldMoveRect.top < oldMoveRect.bottom)
 
465
                                g_system->copyRectToScreen(oldScreenPtr, screenWidth, oldMoveRect.left, oldMoveRect.top, oldMoveRect.width(), oldMoveRect.height());
 
466
                        newScreenRect.top--;
 
467
                        _screen->copyRectToScreen(newScreenRect, _picRect.left, _picRect.top);
 
468
                        updateScreenAndWait(3);
 
469
                }
 
470
                break;
 
471
        }
 
472
}
 
473
 
 
474
// vertically displays new screen starting from center - works on _picRect area only
 
475
void GfxTransitions::verticalRollFromCenter(bool blackoutFlag) {
 
476
        Common::Rect leftRect = Common::Rect(_picRect.left + (_picRect.width() / 2) -1, _picRect.top, _picRect.left + (_picRect.width() / 2), _picRect.bottom);
 
477
        Common::Rect rightRect = Common::Rect(leftRect.right, _picRect.top, leftRect.right + 1, _picRect.bottom);
 
478
 
 
479
        while ((leftRect.left >= _picRect.left) || (rightRect.right <= _picRect.right)) {
 
480
                if (leftRect.left < _picRect.left)
 
481
                        leftRect.translate(1, 0);
 
482
                if (rightRect.right > _picRect.right)
 
483
                        rightRect.translate(-1, 0);
 
484
                copyRectToScreen(leftRect, blackoutFlag); leftRect.translate(-1, 0);
 
485
                copyRectToScreen(rightRect, blackoutFlag); rightRect.translate(1, 0);
 
486
                updateScreenAndWait(2);
 
487
        }
 
488
}
 
489
 
 
490
// vertically displays new screen starting from edges - works on _picRect area only
 
491
void GfxTransitions::verticalRollToCenter(bool blackoutFlag) {
 
492
        Common::Rect leftRect = Common::Rect(_picRect.left, _picRect.top, _picRect.left + 1, _picRect.bottom);
 
493
        Common::Rect rightRect = Common::Rect(leftRect.right - 1, _picRect.top, leftRect.right, _picRect.bottom);
 
494
 
 
495
        while (leftRect.left < rightRect.right) {
 
496
                copyRectToScreen(leftRect, blackoutFlag); leftRect.translate(1, 0);
 
497
                copyRectToScreen(rightRect, blackoutFlag); rightRect.translate(-1, 0);
 
498
                updateScreenAndWait(2);
 
499
        }
 
500
}
 
501
 
 
502
// horizontally displays new screen starting from center - works on _picRect area only
 
503
void GfxTransitions::horizontalRollFromCenter(bool blackoutFlag) {
 
504
        Common::Rect upperRect = Common::Rect(_picRect.left, _picRect.top + (_picRect.height() / 2) - 1, _picRect.right, _picRect.top + (_picRect.height() / 2));
 
505
        Common::Rect lowerRect = Common::Rect(upperRect.left, upperRect.bottom, upperRect.right, upperRect.bottom + 1);
 
506
 
 
507
        while ((upperRect.top >= _picRect.top) || (lowerRect.bottom <= _picRect.bottom)) {
 
508
                if (upperRect.top < _picRect.top)
 
509
                        upperRect.translate(0, 1);
 
510
                if (lowerRect.bottom > _picRect.bottom)
 
511
                        lowerRect.translate(0, -1);
 
512
                copyRectToScreen(upperRect, blackoutFlag); upperRect.translate(0, -1);
 
513
                copyRectToScreen(lowerRect, blackoutFlag); lowerRect.translate(0, 1);
 
514
                updateScreenAndWait(3);
 
515
        }
 
516
}
 
517
 
 
518
// horizontally displays new screen starting from upper and lower edge - works on _picRect area only
 
519
void GfxTransitions::horizontalRollToCenter(bool blackoutFlag) {
 
520
        Common::Rect upperRect = Common::Rect(_picRect.left, _picRect.top, _picRect.right, _picRect.top + 1);
 
521
        Common::Rect lowerRect = Common::Rect(upperRect.left, _picRect.bottom - 1, upperRect.right, _picRect.bottom);
 
522
 
 
523
        while (upperRect.top < lowerRect.bottom) {
 
524
                copyRectToScreen(upperRect, blackoutFlag); upperRect.translate(0, 1);
 
525
                copyRectToScreen(lowerRect, blackoutFlag); lowerRect.translate(0, -1);
 
526
                updateScreenAndWait(3);
 
527
        }
 
528
}
 
529
 
 
530
// diagonally displays new screen starting from center - works on _picRect area only
 
531
//  assumes that height of rect is larger than width
 
532
void GfxTransitions::diagonalRollFromCenter(bool blackoutFlag) {
 
533
        int16 halfHeight = _picRect.height() / 2;
 
534
        Common::Rect upperRect(_picRect.left + halfHeight - 2, _picRect.top + halfHeight, _picRect.right - halfHeight + 1, _picRect.top + halfHeight + 1);
 
535
        Common::Rect lowerRect(upperRect.left, upperRect.top, upperRect.right, upperRect.bottom);
 
536
        Common::Rect leftRect(upperRect.left, upperRect.top, upperRect.left + 1, lowerRect.bottom);
 
537
        Common::Rect rightRect(upperRect.right, upperRect.top, upperRect.right + 1, lowerRect.bottom);
 
538
 
 
539
        while ((upperRect.top >= _picRect.top) || (lowerRect.bottom <= _picRect.bottom)) {
 
540
                if (upperRect.top < _picRect.top) {
 
541
                        upperRect.translate(0, 1); leftRect.top++; rightRect.top++;
 
542
                }
 
543
                if (lowerRect.bottom > _picRect.bottom) {
 
544
                        lowerRect.translate(0, -1); leftRect.bottom--; rightRect.bottom--;
 
545
                }
 
546
                if (leftRect.left < _picRect.left) {
 
547
                        leftRect.translate(1, 0); upperRect.left++; lowerRect.left++;
 
548
                }
 
549
                if (rightRect.right > _picRect.right) {
 
550
                        rightRect.translate(-1, 0); upperRect.right--; lowerRect.right--;
 
551
                }
 
552
                copyRectToScreen(upperRect, blackoutFlag); upperRect.translate(0, -1); upperRect.left--; upperRect.right++;
 
553
                copyRectToScreen(lowerRect, blackoutFlag); lowerRect.translate(0, 1); lowerRect.left--; lowerRect.right++;
 
554
                copyRectToScreen(leftRect, blackoutFlag); leftRect.translate(-1, 0);    leftRect.top--; leftRect.bottom++;
 
555
                copyRectToScreen(rightRect, blackoutFlag); rightRect.translate(1, 0); rightRect.top--; rightRect.bottom++;
 
556
                updateScreenAndWait(3);
 
557
        }
 
558
}
 
559
 
 
560
// diagonally displays new screen starting from edges - works on _picRect area only
 
561
//  assumes that height of rect is larger than width
 
562
void GfxTransitions::diagonalRollToCenter(bool blackoutFlag) {
 
563
        Common::Rect upperRect(_picRect.left, _picRect.top, _picRect.right, _picRect.top + 1);
 
564
        Common::Rect lowerRect(_picRect.left, _picRect.bottom - 1, _picRect.right, _picRect.bottom);
 
565
        Common::Rect leftRect(_picRect.left, _picRect.top, _picRect.left + 1, _picRect.bottom);
 
566
        Common::Rect rightRect(_picRect.right - 1, _picRect.top, _picRect.right, _picRect.bottom);
 
567
 
 
568
        while (upperRect.top < lowerRect.bottom) {
 
569
                copyRectToScreen(upperRect, blackoutFlag); upperRect.translate(0, 1); upperRect.left++; upperRect.right--;
 
570
                copyRectToScreen(lowerRect, blackoutFlag); lowerRect.translate(0, -1); lowerRect.left++; lowerRect.right--;
 
571
                copyRectToScreen(leftRect, blackoutFlag); leftRect.translate(1, 0);
 
572
                copyRectToScreen(rightRect, blackoutFlag); rightRect.translate(-1, 0);
 
573
                updateScreenAndWait(3);
 
574
        }
 
575
}
 
576
 
 
577
} // End of namespace Sci