Skip to content

Commit

Permalink
SHERLOCK: Changed engine to use Graphics::ManagedSurface
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Mar 15, 2016
1 parent b4e3d4a commit 3da3dda
Show file tree
Hide file tree
Showing 44 changed files with 905 additions and 1,112 deletions.
6 changes: 4 additions & 2 deletions engines/sherlock/animation.cpp
Expand Up @@ -23,6 +23,8 @@
#include "sherlock/animation.h"
#include "sherlock/sherlock.h"
#include "sherlock/scalpel/scalpel_screen.h"
#include "sherlock/scalpel/3do/scalpel_3do_screen.h"

#include "common/algorithm.h"

namespace Sherlock {
Expand Down Expand Up @@ -89,7 +91,7 @@ bool Animation::play(const Common::String &filename, bool intro, int minDelay, i

// Draw the sprite. Note that we explicitly use the raw frame below, rather than the ImageFrame,
// since we don't want the offsets in the image file to be used, just the explicit position we specify
screen.transBlitFrom(images[imageFrame]._frame, pt);
screen.SHtransBlitFrom(images[imageFrame]._frame, pt);
} else {
// At this point, either the sprites for the frame has been complete, or there weren't any sprites
// at all to draw for the frame
Expand Down Expand Up @@ -201,7 +203,7 @@ bool Animation::play3DO(const Common::String &filename, bool intro, int minDelay

// Draw the sprite. Note that we explicitly use the raw frame below, rather than the ImageFrame,
// since we don't want the offsets in the image file to be used, just the explicit position we specify
screen._backBuffer1.transBlitFrom(images[imageFrame]._frame, pt);
screen._backBuffer1.SHtransBlitFrom(images[imageFrame]._frame, pt);
if (!fadeActive)
screen.slamArea(pt.x, pt.y, images[imageFrame]._frame.w, images[imageFrame]._frame.h);
} else {
Expand Down
8 changes: 4 additions & 4 deletions engines/sherlock/events.cpp
Expand Up @@ -143,27 +143,27 @@ void Events::setCursor(CursorId cursorId, const Common::Point &cursorPos, const

// Form a single surface containing both frames
Surface s(r.width(), r.height());
s.fill(TRANSPARENCY);
s.clear(TRANSPARENCY);

// Draw the passed image
Common::Point drawPos;
if (cursorPt.x < 0)
drawPos.x = -cursorPt.x;
if (cursorPt.y < 0)
drawPos.y = -cursorPt.y;
s.blitFrom(surface, Common::Point(drawPos.x, drawPos.y));
s.SHblitFrom(surface, Common::Point(drawPos.x, drawPos.y));

// Draw the cursor image
drawPos = Common::Point(MAX(cursorPt.x, (int16)0), MAX(cursorPt.y, (int16)0));
s.transBlitFrom(cursorImg, Common::Point(drawPos.x, drawPos.y));
s.SHtransBlitFrom(cursorImg, Common::Point(drawPos.x, drawPos.y));

// Set up hotspot position for cursor, adjusting for cursor image's position within the surface
Common::Point hotspot;
if (cursorId == MAGNIFY)
hotspot = Common::Point(8, 8);
hotspot += drawPos;
// Set the cursor
setCursor(s.getRawSurface(), hotspot.x, hotspot.y);
setCursor(s, hotspot.x, hotspot.y);
}

void Events::animateCursorIfNeeded() {
Expand Down
4 changes: 2 additions & 2 deletions engines/sherlock/fonts.cpp
Expand Up @@ -43,7 +43,7 @@ void Fonts::setVm(SherlockEngine *vm) {
_charCount = 0;
}

void Fonts::free() {
void Fonts::freeFont() {
delete _font;
}

Expand Down Expand Up @@ -213,7 +213,7 @@ void Fonts::writeString(Surface *surface, const Common::String &str,

if (curChar < _charCount) {
ImageFrame &frame = (*_font)[curChar];
surface->transBlitFrom(frame, Common::Point(charPos.x, charPos.y + _yOffsets[curChar]), false, overrideColor);
surface->SHtransBlitFrom(frame, Common::Point(charPos.x, charPos.y + _yOffsets[curChar]), false, overrideColor);
charPos.x += frame._frame.w + 1;
} else {
warning("Invalid character encountered - %d", (int)curChar);
Expand Down
2 changes: 1 addition & 1 deletion engines/sherlock/fonts.h
Expand Up @@ -57,7 +57,7 @@ class Fonts {
/**
* Frees the font manager
*/
static void free();
static void freeFont();

/**
* Set the font to use for writing text on the screen
Expand Down
5 changes: 5 additions & 0 deletions engines/sherlock/image_file.h
Expand Up @@ -45,6 +45,11 @@ struct ImageFrame {
byte _rleMarker;
Graphics::Surface _frame;

/**
* Converts an ImageFrame record to a surface for convenience in passing to drawing methods
*/
operator const Graphics::Surface &() { return _frame; }

/**
* Decompress a single frame for the sprite
*/
Expand Down
2 changes: 2 additions & 0 deletions engines/sherlock/module.mk
Expand Up @@ -3,6 +3,7 @@ MODULE := engines/sherlock
MODULE_OBJS = \
scalpel/scalpel.o \
scalpel/3do/movie_decoder.o \
scalpel/3do/scalpel_3do_screen.o \
scalpel/drivers/adlib.o \
scalpel/drivers/mt32.o \
scalpel/tsage/logo.o \
Expand Down Expand Up @@ -30,6 +31,7 @@ MODULE_OBJS = \
tattoo/tattoo_people.o \
tattoo/tattoo_resources.o \
tattoo/tattoo_scene.o \
tattoo/tattoo_screen.o \
tattoo/tattoo_talk.o \
tattoo/tattoo_user_interface.o \
tattoo/widget_base.o \
Expand Down
4 changes: 2 additions & 2 deletions engines/sherlock/objects.cpp
Expand Up @@ -365,8 +365,8 @@ bool BaseObject::checkEndOfSequence() {

if (seq == 99) {
--_frameNumber;
screen._backBuffer1.transBlitFrom(*_imageFrame, _position);
screen._backBuffer2.transBlitFrom(*_imageFrame, _position);
screen._backBuffer1.SHtransBlitFrom(*_imageFrame, _position);
screen._backBuffer2.SHtransBlitFrom(*_imageFrame, _position);
_type = INVALID;
} else if (IS_ROSE_TATTOO && _talkSeq && seq == 0) {
setObjTalkSequence(_talkSeq);
Expand Down

0 comments on commit 3da3dda

Please sign in to comment.