Permalink
Browse files

STARTREK: Implement draw modes 2 and 3 for sprites

  • Loading branch information...
Drenn1 authored and sev- committed Feb 23, 2018
1 parent c71a8a6 commit cd45502501787c8003cfd86b7adf48a6f86d68de
@@ -0,0 +1,55 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

#include "startrek/bitmap.h"
#include "startrek/startrek.h"

namespace StarTrek {

Bitmap::Bitmap(Common::ReadStreamEndian *stream) {
xoffset = stream->readUint16();
yoffset = stream->readUint16();
width = stream->readUint16();
height = stream->readUint16();

pixels = new byte[width*height];
stream->read(pixels, width*height);
}

Bitmap::Bitmap(int w, int h) : width(w), height(h), xoffset(0), yoffset(0) {
pixels = new byte[width*height];
}

Bitmap::~Bitmap() {
delete[] pixels;
}


TextBitmap::TextBitmap(int w, int h) {
width = w;
height = h;
// Width and Height are the total dimensions. Since each character takes 8 pixels in
// each dimension, the "pixels" array (which actually stores character indices) must
// be smaller.
pixels = new byte[width/8*height/8];
}

}
@@ -0,0 +1,34 @@
#ifndef STARTREK_BITMAP_H
#define STARTREK_BITMAP_H

#include "common/stream.h"

namespace StarTrek {

struct Bitmap {
uint16 xoffset;
uint16 yoffset;
uint16 width;
uint16 height;
byte *pixels;

Bitmap(Common::ReadStreamEndian *stream);
Bitmap(int w, int h);
~Bitmap();

protected:
Bitmap() : xoffset(0),yoffset(0),width(0),height(0),pixels(nullptr) {}
};


// TextBitmap is the same as Bitmap, except it stores character indices in its "pixels"
// array instead of actual pixels.
// A consequence of this is that the pixels array is smaller than otherwise expected
// (since width/height still reflect the actual size when drawn).
struct TextBitmap : Bitmap {
TextBitmap(int w, int h);
};

}

#endif
@@ -66,4 +66,8 @@ Font::~Font() {
delete[] _characters;
}

byte *Font::getCharData(int i) {
return _characters[i].data;
}

}
@@ -36,6 +36,8 @@ class Font {
public:
Font(StarTrekEngine *vm);
~Font();

byte *getCharData(int i);

private:
StarTrekEngine *_vm;
Oops, something went wrong.

0 comments on commit cd45502

Please sign in to comment.