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

« back to all changes in this revision

Viewing changes to engines/m4/graphics.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:
18
18
 * along with this program; if not, write to the Free Software
19
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
20
 *
21
 
 * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/tags/release-1-0-0/engines/m4/graphics.cpp $
22
 
 * $Id: graphics.cpp 36127 2009-01-29 05:26:12Z fingolfin $
 
21
 * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/tags/release-1-1-1/engines/m4/graphics.cpp $
 
22
 * $Id: graphics.cpp 48039 2010-02-13 11:49:18Z dreammaster $
23
23
 *
24
24
 */
25
25
 
59
59
        delete[] _palIndexes;
60
60
}
61
61
 
 
62
void RGBList::setRange(int start, int count, const RGB8 *src) {
 
63
        assert((start + count) <= _size);
 
64
 
 
65
        Common::copy(&src[0], &src[count], &_data[start]);
 
66
}
 
67
 
62
68
//--------------------------------------------------------------------------
63
69
 
64
70
#define VGA_COLOR_TRANS(x) (x == 0x3f ? 255 : x << 2)
100
106
                                *ptr++ = 0;
101
107
                }
102
108
        }
 
109
 
 
110
        delete[] walkMap;
103
111
}
104
112
 
105
113
// Sprite related methods
155
163
 
156
164
}
157
165
 
158
 
void M4Surface::line(int x1, int y1, int x2, int y2, byte color) {
 
166
void M4Surface::drawLine(int x1, int y1, int x2, int y2, byte color) {
159
167
        Graphics::Surface::drawLine(x1, y1, x2, y2, color);
160
168
}
161
169
 
216
224
                return;
217
225
        int heightAmt = scaledHeight;
218
226
 
219
 
        byte *src = info.sprite->getData();
 
227
        byte *src = info.sprite->getBasePtr();
220
228
        byte *dst = getBasePtr(x - info.hotX - clipX, y - info.hotY - clipY);
221
229
 
222
230
        int status = kStatusSkip;
309
317
 
310
318
// Surface methods
311
319
 
312
 
byte *M4Surface::getData() {
313
 
        return (byte *)pixels;
314
 
}
315
 
 
316
 
byte *M4Surface::getBasePtr(int x, int y) {
317
 
        return (byte *)Graphics::Surface::getBasePtr(x, y);
318
 
}
319
 
 
320
320
void M4Surface::freeData() {
321
321
}
322
322
 
323
323
void M4Surface::clear() {
324
 
        Common::set_to((byte *) pixels, (byte *) pixels + w * h, _vm->_palette->BLACK);
 
324
        Common::set_to((byte *)pixels, (byte *)pixels + w * h, _vm->_palette->BLACK);
325
325
}
326
326
 
327
327
void M4Surface::frameRect(const Common::Rect &r, uint8 color) {
357
357
 
358
358
        // Copy the specified area
359
359
 
360
 
        byte *data = src->getData();
 
360
        byte *data = src->getBasePtr();
361
361
        byte *srcPtr = data + (src->width() * copyRect.top + copyRect.left);
362
362
        byte *destPtr = (byte *)pixels + (destY * width()) + destX;
363
363
 
718
718
 
719
719
// Support function for fading in or out
720
720
 
721
 
static void fadeRange(M4Engine *vm, RGB8 *srcPal, RGB8 *destPal,  int startIndex, int endIndex,
 
721
static void fadeRange(MadsM4Engine *vm, RGB8 *srcPal, RGB8 *destPal,  int startIndex, int endIndex,
722
722
                                         int numSteps, uint delayAmount) {
723
723
        RGB8 tempPal[256];
724
724
 
746
746
        vm->_palette->setPalette(&destPal[startIndex], startIndex, endIndex - startIndex + 1);
747
747
}
748
748
 
749
 
Palette::Palette(M4Engine *vm) : _vm(vm) {
 
749
Palette::Palette(MadsM4Engine *vm) : _vm(vm) {
750
750
        reset();
751
751
        _fading_in_progress = false;
752
752
        Common::set_to(&_usageCount[0], &_usageCount[256], 0);
767
767
        reset();
768
768
}
769
769
 
 
770
void Palette::setEntry(uint index, uint8 r, uint8 g, uint8 b) {
 
771
        uint32 c = (r << 16) | (g << 8) || b;
 
772
        g_system->setPalette((const byte *)&c, index, 1);
 
773
}
 
774
 
770
775
uint8 Palette::palIndexFromRgb(byte r, byte g, byte b, RGB8 *paletteData) {
771
776
        byte index = 0;
772
777
        int32 minDist = 0x7fffffff;
855
860
 
856
861
        // Remap all pixels into the #32-63 range
857
862
 
858
 
        tempP = _vm->_scene->getData();
 
863
        tempP = _vm->_scene->getBasePtr();
859
864
        for (int pixelCtr = 0; pixelCtr < _vm->_scene->width() * _vm->_scene->height();
860
865
                        ++pixelCtr, ++tempP) {
861
866
                // If pixel is in #32-63 range already, remap to higher palette entries