[Scummvm-cvs-logs] SF.net SVN: scummvm:[49487] scummvm/trunk/engines/groovie

jvprat at users.sourceforge.net jvprat at users.sourceforge.net
Mon Jun 7 19:14:43 CEST 2010


Revision: 49487
          http://scummvm.svn.sourceforge.net/scummvm/?rev=49487&view=rev
Author:   jvprat
Date:     2010-06-07 17:14:42 +0000 (Mon, 07 Jun 2010)

Log Message:
-----------
Groovie:
- Rewritten T7G's font code to subclass Graphics::Font and make it cleaner.
- Use theme fonts for the Mac version of T7G (which used ugly system fonts
  originally). With this the Mac version should be completable.
- Cleanup include interdependencies.

Modified Paths:
--------------
    scummvm/trunk/engines/groovie/cell.h
    scummvm/trunk/engines/groovie/cursor.h
    scummvm/trunk/engines/groovie/debug.cpp
    scummvm/trunk/engines/groovie/debug.h
    scummvm/trunk/engines/groovie/detection.cpp
    scummvm/trunk/engines/groovie/font.cpp
    scummvm/trunk/engines/groovie/font.h
    scummvm/trunk/engines/groovie/graphics.cpp
    scummvm/trunk/engines/groovie/graphics.h
    scummvm/trunk/engines/groovie/groovie.cpp
    scummvm/trunk/engines/groovie/groovie.h
    scummvm/trunk/engines/groovie/music.cpp
    scummvm/trunk/engines/groovie/music.h
    scummvm/trunk/engines/groovie/player.cpp
    scummvm/trunk/engines/groovie/resource.cpp
    scummvm/trunk/engines/groovie/roq.cpp
    scummvm/trunk/engines/groovie/script.cpp
    scummvm/trunk/engines/groovie/script.h
    scummvm/trunk/engines/groovie/vdx.cpp
    scummvm/trunk/engines/groovie/vdx.h

Modified: scummvm/trunk/engines/groovie/cell.h
===================================================================
--- scummvm/trunk/engines/groovie/cell.h	2010-06-07 15:14:58 UTC (rev 49486)
+++ scummvm/trunk/engines/groovie/cell.h	2010-06-07 17:14:42 UTC (rev 49487)
@@ -26,12 +26,8 @@
 #ifndef GROOVIE_CELL_H
 #define GROOVIE_CELL_H
 
-#include "common/file.h"
-#include "common/util.h"
+#include "common/textconsole.h"
 
-#include "groovie/cell.h"
-#include "groovie/groovie.h"
-
 #define BOARDSIZE 7
 #define CELL_CLEAR 0
 #define CELL_BLUE 1

Modified: scummvm/trunk/engines/groovie/cursor.h
===================================================================
--- scummvm/trunk/engines/groovie/cursor.h	2010-06-07 15:14:58 UTC (rev 49486)
+++ scummvm/trunk/engines/groovie/cursor.h	2010-06-07 17:14:42 UTC (rev 49487)
@@ -26,9 +26,8 @@
 #ifndef GROOVIE_CURSOR_H
 #define GROOVIE_CURSOR_H
 
-#include "common/system.h"
 #include "common/array.h"
-#include "common/file.h"
+#include "common/system.h"
 
 namespace Common {
 	class MacResManager;

Modified: scummvm/trunk/engines/groovie/debug.cpp
===================================================================
--- scummvm/trunk/engines/groovie/debug.cpp	2010-06-07 15:14:58 UTC (rev 49486)
+++ scummvm/trunk/engines/groovie/debug.cpp	2010-06-07 17:14:42 UTC (rev 49487)
@@ -24,15 +24,17 @@
  */
 
 #include "groovie/debug.h"
+#include "groovie/graphics.h"
 #include "groovie/groovie.h"
 #include "groovie/script.h"
 
 #include "common/debug-channels.h"
+#include "common/system.h"
 
 namespace Groovie {
 
 Debugger::Debugger(GroovieEngine *vm) :
-	_vm (vm), _script(_vm->_script), _syst(_vm->_system) {
+	_vm(vm), _script(_vm->_script) {
 
 	// Register the debugger comands
 	DCmd_Register("step", WRAP_METHOD(Debugger, cmd_step));
@@ -136,7 +138,7 @@
 bool Debugger::cmd_dumppal(int argc, const char **argv) {
 	uint16 i;
 	byte palettedump[256 * 4];
-	_syst->grabPalette(palettedump, 0, 256);
+	_vm->_system->grabPalette(palettedump, 0, 256);
 
 	for (i = 0; i < 256; i++) {
 		DebugPrintf("%3d: %3d,%3d,%3d,%3d\n", i, palettedump[(i * 4)], palettedump[(i * 4) + 1], palettedump[(i * 4) + 2], palettedump[(i * 4) + 3]);

Modified: scummvm/trunk/engines/groovie/debug.h
===================================================================
--- scummvm/trunk/engines/groovie/debug.h	2010-06-07 15:14:58 UTC (rev 49486)
+++ scummvm/trunk/engines/groovie/debug.h	2010-06-07 17:14:42 UTC (rev 49487)
@@ -27,12 +27,11 @@
 #define GROOVIE_DEBUG_H
 
 #include "gui/debugger.h"
-#include "engines/engine.h"
 
 namespace Groovie {
 
-class Script;
 class GroovieEngine;
+class Script;
 
 class Debugger : public GUI::Debugger {
 public:
@@ -42,7 +41,6 @@
 private:
 	GroovieEngine *_vm;
 	Script *_script;
-	OSystem *_syst;
 
 	int getNumber(const char *arg);
 

Modified: scummvm/trunk/engines/groovie/detection.cpp
===================================================================
--- scummvm/trunk/engines/groovie/detection.cpp	2010-06-07 15:14:58 UTC (rev 49486)
+++ scummvm/trunk/engines/groovie/detection.cpp	2010-06-07 17:14:42 UTC (rev 49487)
@@ -23,12 +23,12 @@
  *
  */
 
-#include "common/savefile.h"
-
 #include "groovie/groovie.h"
 #include "groovie/detection.h"
 #include "groovie/saveload.h"
 
+#include "common/system.h"
+
 namespace Groovie {
 
 static const PlainGameDescriptor groovieGames[] = {

Modified: scummvm/trunk/engines/groovie/font.cpp
===================================================================
--- scummvm/trunk/engines/groovie/font.cpp	2010-06-07 15:14:58 UTC (rev 49486)
+++ scummvm/trunk/engines/groovie/font.cpp	2010-06-07 17:14:42 UTC (rev 49487)
@@ -23,106 +23,105 @@
  *
  */
 
-#include "common/file.h"
-#include "graphics/surface.h"
-
 #include "groovie/font.h"
 
 namespace Groovie {
 
-Font::Font(OSystem *syst) :
-	_syst(syst), _sphinxfnt(NULL) {
-
-	Common::File fontfile;
-	if (!fontfile.open("sphinx.fnt")) {
-		error("Groovie::Font: Couldn't open sphinx.fnt");
-	}
-	uint16 fontfilesize = fontfile.size();
-	_sphinxfnt = fontfile.readStream(fontfilesize);
-	fontfile.close();
+T7GFont::T7GFont() : _maxHeight(0), _maxWidth(0), _glyphs(0) {
 }
 
-Font::~Font() {
-	delete _sphinxfnt;
+T7GFont::~T7GFont() {
+	delete[] _glyphs;
 }
 
-void Font::printstring(const char *messagein) {
-	uint16 totalwidth = 0, currxoffset, i;
+bool T7GFont::load(Common::SeekableReadStream &stream) {
+	// Read the mapping of characters to glyphs
+	if (stream.read(_mapChar2Glyph, 128) < 128) {
+		error("Groovie::T7GFont: Couldn't read the character to glyph map");
+		return false;
+	}
 
-	char message[15];
-	memset(message, 0, 15);
+	// Calculate the number of glyphs
+	byte numGlyphs = 0;
+	for (int i = 0; i < 128; i++)
+		if (_mapChar2Glyph[i] >= numGlyphs)
+			numGlyphs = _mapChar2Glyph[i] + 1;
 
-	// Clear the top bar
-	Common::Rect topbar(640, 80);
-	Graphics::Surface *gamescreen;
-	gamescreen = _syst->lockScreen();
-	gamescreen->fillRect(topbar, 0);
-	_syst->unlockScreen();
+	// Read the glyph offsets
+	uint16 *glyphOffsets = new uint16[numGlyphs];
+	for (int i = 0; i < numGlyphs; i++)
+		glyphOffsets[i] = stream.readUint16LE();
 
-	for (i = 0; i < 14; i++) {
-		char chartocopy = messagein[i];
-		if (chartocopy <= 0x00 || chartocopy == 0x24) {
-			break;
+	if (stream.eos()) {
+		error("Groovie::T7GFont: Couldn't read the glyph offsets");
+		return false;
+	}
+
+	// Allocate the glyph data
+	delete[] _glyphs;
+	_glyphs = new Glyph[numGlyphs];
+
+	// Read the glyphs
+	_maxHeight = _maxWidth = 0;
+	for (int i = 0; (i < numGlyphs) && !stream.eos(); i++) {
+		// Verify we're at the expected stream position
+		if (stream.pos() != glyphOffsets[i]) {
+			error("Groovie::T7GFont: Glyph %d starts at %d but the current "
+				"offset is %d", i, glyphOffsets[i], stream.pos());
+			return false;
 		}
-		message[i] = chartocopy;
+
+		// Read the glyph information
+		Glyph *g = &_glyphs[i];
+		g->width = stream.readByte();
+		g->julia = stream.readByte();
+
+		// Read the pixels data into a dynamic array (we don't know its length)
+		Common::Array<byte> data;
+		data.reserve(300);
+		byte b = stream.readByte();
+		while (!stream.eos() && (b != 0xFF)) {
+			data.push_back(b);
+			b = stream.readByte();
+		}
+
+		// Verify the pixel data size
+		assert (data.size() % g->width == 0);
+		g->height = data.size() / g->width;
+
+		// Copy the pixel data into the definitive static array
+		g->pixels = new byte[data.size()];
+		memcpy(g->pixels, data.begin(), data.size());
+
+		// Update the max values
+		if (g->width > _maxWidth)
+			_maxWidth = g->width;
+		if (g->height > _maxHeight)
+			_maxHeight = g->height;
 	}
-	Common::rtrim(message);
-	for (i = 0; i < strlen(message); i++) {
-		totalwidth += letterwidth(message[i]);
-	}
-	currxoffset = (640 - totalwidth) / 2;
-	char *currpos = message;
-	while (*(currpos) != 0) {
-		currxoffset += printletter(*(currpos++), currxoffset);
-	}
-}
 
-uint16 Font::letteroffset(char letter) {
-	uint16 offset;
-	offset = letter;
-	_sphinxfnt->seek(offset);
-	offset = _sphinxfnt->readByte() * 2 + 128;
-	_sphinxfnt->seek(offset);
-	offset = _sphinxfnt->readUint16LE();
-	return offset;
+	delete[] glyphOffsets;
+	return true;
 }
 
-uint8 Font::letterwidth(char letter) {
-	uint16 offset = letteroffset(letter);
-	_sphinxfnt->seek(offset);
-	return _sphinxfnt->readByte();
-}
+void T7GFont::drawChar(Graphics::Surface *dst, byte chr, int x, int y, uint32 color) const {
+	// We ignore the color, as the font is already colored
+	const Glyph *glyph = getGlyph(chr);
+	const byte *src = glyph->pixels;
+	byte *target = (byte *)dst->getBasePtr(x, y);
 
-uint8 Font::letterheight(char letter) {
-	uint16 offset, width, julia, data, counter = 0;
-	offset = letteroffset(letter);
-	_sphinxfnt->seek(offset);
-	width = _sphinxfnt->readByte();
-	julia = _sphinxfnt->readByte();
-	data = _sphinxfnt->readByte();
-	while (data != 0xFF) {
-		data = _sphinxfnt->readByte();
-		counter++;
+	for (int i = 0; i < glyph->height; i++) {
+		memcpy(target, src, glyph->width);
+		src += glyph->width;
+		target += dst->pitch;
 	}
-	if (counter % width != 0) assert("font file corrupt");
-	return counter / width;
 }
 
+const T7GFont::Glyph *T7GFont::getGlyph(byte chr) const {
+	assert (chr < 128);
 
-uint8 Font::printletter(char letter, uint16 xoffset) {
-	uint16 offset, width, height, julia;
-	offset = letteroffset(letter);
-	height = letterheight(letter);
-	_sphinxfnt->seek(offset);
-	width = _sphinxfnt->readByte();
-	julia = _sphinxfnt->readByte();
-
-	byte *data = new byte[width * height];
-	_sphinxfnt->read(data, width * height);
-	_syst->copyRectToScreen(data, width, xoffset, 16, width, height);
-	delete[] data;
-
-	return width;
+	byte numGlyph = _mapChar2Glyph[chr];
+	return &_glyphs[numGlyph];
 }
 
 } // End of Groovie namespace

Modified: scummvm/trunk/engines/groovie/font.h
===================================================================
--- scummvm/trunk/engines/groovie/font.h	2010-06-07 15:14:58 UTC (rev 49486)
+++ scummvm/trunk/engines/groovie/font.h	2010-06-07 17:14:42 UTC (rev 49487)
@@ -27,24 +27,38 @@
 #define GROOVIE_FONT_H
 
 #include "common/stream.h"
-#include "common/system.h"
+#include "graphics/font.h"
 
 namespace Groovie {
 
-class Font {
+class T7GFont : public Graphics::Font {
 public:
-	Font(OSystem *syst);
-	~Font();
-	void printstring(const char *messagein);
+	T7GFont();
+	~T7GFont();
 
+	bool load(Common::SeekableReadStream &stream);
+
+	int getFontHeight() const { return _maxHeight; }
+	int getMaxCharWidth() const { return _maxWidth; }
+	int getCharWidth(byte chr) const { return getGlyph(chr)->width; }
+	void drawChar(Graphics::Surface *dst, byte chr, int x, int y, uint32 color) const;
+
 private:
-	OSystem *_syst;
-	Common::MemoryReadStream *_sphinxfnt;
+	int _maxHeight, _maxWidth;
 
-	uint16 letteroffset(char letter);
-	uint8 letterwidth(char letter);
-	uint8 letterheight(char letter);
-	uint8 printletter(char letter, uint16 xoffset);
+	struct Glyph {
+		Glyph() : pixels(0) {}
+		~Glyph() { delete[] pixels; }
+
+		byte width;
+		byte height;
+		byte julia;
+		byte *pixels;
+	};
+
+	byte _mapChar2Glyph[128];
+	Glyph *_glyphs;
+	const Glyph *getGlyph(byte chr) const;
 };
 
 } // End of Groovie namespace

Modified: scummvm/trunk/engines/groovie/graphics.cpp
===================================================================
--- scummvm/trunk/engines/groovie/graphics.cpp	2010-06-07 15:14:58 UTC (rev 49486)
+++ scummvm/trunk/engines/groovie/graphics.cpp	2010-06-07 17:14:42 UTC (rev 49487)
@@ -23,8 +23,9 @@
  *
  */
 
+#include "groovie/graphics.h"
 #include "groovie/groovie.h"
-#include "groovie/graphics.h"
+#include "common/system.h"
 
 namespace Groovie {
 

Modified: scummvm/trunk/engines/groovie/graphics.h
===================================================================
--- scummvm/trunk/engines/groovie/graphics.h	2010-06-07 15:14:58 UTC (rev 49486)
+++ scummvm/trunk/engines/groovie/graphics.h	2010-06-07 17:14:42 UTC (rev 49487)
@@ -26,6 +26,8 @@
 #ifndef GROOVIE_GRAPHICS_H
 #define GROOVIE_GRAPHICS_H
 
+#include "graphics/surface.h"
+
 namespace Groovie {
 
 class GroovieEngine;

Modified: scummvm/trunk/engines/groovie/groovie.cpp
===================================================================
--- scummvm/trunk/engines/groovie/groovie.cpp	2010-06-07 15:14:58 UTC (rev 49486)
+++ scummvm/trunk/engines/groovie/groovie.cpp	2010-06-07 17:14:42 UTC (rev 49487)
@@ -23,27 +23,30 @@
  *
  */
 
+#include "groovie/groovie.h"
+#include "groovie/cursor.h"
+#include "groovie/detection.h"
+#include "groovie/graphics.h"
+#include "groovie/music.h"
+#include "groovie/resource.h"
+#include "groovie/roq.h"
+#include "groovie/vdx.h"
+
 #include "common/config-manager.h"
 #include "common/debug-channels.h"
 #include "common/events.h"
 #include "common/macresman.h"
 
 #include "engines/util.h"
-
+#include "graphics/fontman.h"
 #include "sound/mixer.h"
 
-#include "groovie/groovie.h"
-#include "groovie/detection.h"
-#include "groovie/music.h"
-#include "groovie/roq.h"
-#include "groovie/vdx.h"
-
 namespace Groovie {
 
 GroovieEngine::GroovieEngine(OSystem *syst, const GroovieGameDescription *gd) :
 	Engine(syst), _gameDescription(gd), _debugger(NULL), _script(NULL),
 	_resMan(NULL), _grvCursorMan(NULL), _videoPlayer(NULL), _musicPlayer(NULL),
-	_graphicsMan(NULL), _macResFork(NULL), _waitingForInput(false) {
+	_graphicsMan(NULL), _macResFork(NULL), _waitingForInput(false), _font(NULL) {
 
 	// Adding the default directories
 	const Common::FSNode gameDataDir(ConfMan.get("path"));
@@ -104,12 +107,26 @@
 	_graphicsMan = new GraphicsMan(this);
 
 	// Create the resource and cursor managers and the video player
+	// Prepare the font too
 	switch (_gameDescription->version) {
 	case kGroovieT7G:
 		if (_gameDescription->desc.platform == Common::kPlatformMacintosh) {
 			_macResFork = new Common::MacResManager();
 			if (!_macResFork->open(_gameDescription->desc.filesDescriptions[0].fileName))
 				error("Could not open %s as a resource fork", _gameDescription->desc.filesDescriptions[0].fileName);
+			// The Macintosh release used system fonts. We use GUI fonts.
+			_font = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont);
+		} else {
+			Common::File fontfile;
+			if (!fontfile.open("sphinx.fnt")) {
+				error("Couldn't open sphinx.fnt");
+				return Common::kNoGameDataFoundError;
+			} else if (!_sphinxFont.load(fontfile)) {
+				error("Error loading sphinx.fnt");
+				return Common::kUnknownError;
+			}
+			fontfile.close();
+			_font = &_sphinxFont;
 		}
 
 		_resMan = new ResMan_t7g(_macResFork);

Modified: scummvm/trunk/engines/groovie/groovie.h
===================================================================
--- scummvm/trunk/engines/groovie/groovie.h	2010-06-07 15:14:58 UTC (rev 49486)
+++ scummvm/trunk/engines/groovie/groovie.h	2010-06-07 17:14:42 UTC (rev 49487)
@@ -26,16 +26,12 @@
 #ifndef GROOVIE_H
 #define GROOVIE_H
 
+#include "groovie/debug.h"
+#include "groovie/font.h"
+
 #include "engines/engine.h"
-#include "graphics/surface.h"
+#include "graphics/pixelformat.h"
 
-#include "groovie/cursor.h"
-#include "groovie/debug.h"
-#include "groovie/graphics.h"
-#include "groovie/player.h"
-#include "groovie/resource.h"
-#include "groovie/script.h"
-
 namespace Common {
 	class MacResManager;
 }
@@ -57,7 +53,12 @@
  */
 namespace Groovie {
 
+class GraphicsMan;
+class GrvCursorMan;
 class MusicPlayer;
+class ResMan;
+class Script;
+class VideoPlayer;
 
 enum DebugLevels {
 	kGroovieDebugAll = 1 << 0,
@@ -106,6 +107,7 @@
 	VideoPlayer *_videoPlayer;
 	MusicPlayer *_musicPlayer;
 	GraphicsMan *_graphicsMan;
+	const Graphics::Font *_font;
 
 	Common::MacResManager *_macResFork;
 
@@ -113,6 +115,7 @@
 	const GroovieGameDescription *_gameDescription;
 	Debugger *_debugger;
 	bool _waitingForInput;
+	T7GFont _sphinxFont;
 };
 
 } // End of namespace Groovie

Modified: scummvm/trunk/engines/groovie/music.cpp
===================================================================
--- scummvm/trunk/engines/groovie/music.cpp	2010-06-07 15:14:58 UTC (rev 49486)
+++ scummvm/trunk/engines/groovie/music.cpp	2010-06-07 17:14:42 UTC (rev 49487)
@@ -23,13 +23,14 @@
  *
  */
 
-#include "groovie/lzss.h"
 #include "groovie/music.h"
+#include "groovie/groovie.h"
 #include "groovie/resource.h"
 
 #include "common/config-manager.h"
 #include "common/macresman.h"
 #include "sound/audiocd.h"
+#include "sound/midiparser.h"
 
 namespace Groovie {
 

Modified: scummvm/trunk/engines/groovie/music.h
===================================================================
--- scummvm/trunk/engines/groovie/music.h	2010-06-07 15:14:58 UTC (rev 49486)
+++ scummvm/trunk/engines/groovie/music.h	2010-06-07 17:14:42 UTC (rev 49487)
@@ -26,14 +26,16 @@
 #ifndef GROOVIE_MUSIC_H
 #define GROOVIE_MUSIC_H
 
-#include "groovie/groovie.h"
-
+#include "common/array.h"
+#include "common/mutex.h"
 #include "sound/mididrv.h"
-#include "sound/midiparser.h"
-#include "common/mutex.h"
 
+class MidiParser;
+
 namespace Groovie {
 
+class GroovieEngine;
+
 class MusicPlayer {
 public:
 	MusicPlayer(GroovieEngine *vm);

Modified: scummvm/trunk/engines/groovie/player.cpp
===================================================================
--- scummvm/trunk/engines/groovie/player.cpp	2010-06-07 15:14:58 UTC (rev 49486)
+++ scummvm/trunk/engines/groovie/player.cpp	2010-06-07 17:14:42 UTC (rev 49487)
@@ -23,8 +23,8 @@
  *
  */
 
+#include "groovie/player.h"
 #include "groovie/groovie.h"
-#include "groovie/player.h"
 
 namespace Groovie {
 

Modified: scummvm/trunk/engines/groovie/resource.cpp
===================================================================
--- scummvm/trunk/engines/groovie/resource.cpp	2010-06-07 15:14:58 UTC (rev 49486)
+++ scummvm/trunk/engines/groovie/resource.cpp	2010-06-07 17:14:42 UTC (rev 49487)
@@ -26,8 +26,8 @@
 #include "common/archive.h"
 #include "common/macresman.h"
 
+#include "groovie/resource.h"
 #include "groovie/groovie.h"
-#include "groovie/resource.h"
 
 namespace Groovie {
 

Modified: scummvm/trunk/engines/groovie/roq.cpp
===================================================================
--- scummvm/trunk/engines/groovie/roq.cpp	2010-06-07 15:14:58 UTC (rev 49486)
+++ scummvm/trunk/engines/groovie/roq.cpp	2010-06-07 17:14:42 UTC (rev 49487)
@@ -26,8 +26,9 @@
 // ROQ video player based on this specification by Dr. Tim Ferguson:
 // http://www.csse.monash.edu.au/~timf/videocodec/idroq.txt
 
+#include "groovie/roq.h"
+#include "groovie/graphics.h"
 #include "groovie/groovie.h"
-#include "groovie/roq.h"
 
 #include "graphics/jpeg.h"
 

Modified: scummvm/trunk/engines/groovie/script.cpp
===================================================================
--- scummvm/trunk/engines/groovie/script.cpp	2010-06-07 15:14:58 UTC (rev 49486)
+++ scummvm/trunk/engines/groovie/script.cpp	2010-06-07 17:14:42 UTC (rev 49487)
@@ -23,18 +23,19 @@
  *
  */
 
-#include "groovie/debug.h"
-#include "groovie/music.h"
 #include "groovie/script.h"
+#include "groovie/cell.h"
+#include "groovie/cursor.h"
+#include "groovie/graphics.h"
 #include "groovie/groovie.h"
-#include "groovie/cell.h"
+#include "groovie/music.h"
+#include "groovie/player.h"
+#include "groovie/resource.h"
 #include "groovie/saveload.h"
 
 #include "common/archive.h"
 #include "common/config-manager.h"
 #include "common/debug-channels.h"
-#include "common/endian.h"
-#include "common/events.h"
 #include "common/EventRecorder.h"
 #include "common/macresman.h"
 
@@ -63,9 +64,8 @@
 }
 
 Script::Script(GroovieEngine *vm, EngineVersion version) :
-	_code(NULL), _savedCode(NULL), _stacktop(0),
-	_debugger(NULL), _vm(vm),
-	_videoFile(NULL), _videoRef(0), _font(NULL), _staufsMove(NULL) {
+	_code(NULL), _savedCode(NULL), _stacktop(0), _debugger(NULL), _vm(vm),
+	_videoFile(NULL), _videoRef(0), _staufsMove(NULL) {
 	// Initialize the opcode set depending on the engine version
 	switch (version) {
 	case kGroovieT7G:
@@ -112,7 +112,6 @@
 	delete[] _code;
 	delete[] _savedCode;
 
-	delete _font;
 	delete _videoFile;
 }
 
@@ -429,6 +428,22 @@
 	_saveNames[slot] = save;
 }
 
+void Script::printString(Graphics::Surface *surface, const char *str) {
+	char message[15];
+	memset(message, 0, 15);
+
+	// Preprocess the string
+	for (int i = 0; i < 14; i++) {
+		if (str[i] <= 0x00 || str[i] == 0x24)
+			break;
+		message[i] = str[i];
+	}
+	Common::rtrim(message);
+
+	// Draw the string
+	_vm->_font->drawString(surface, message, 0, 16, 640, 0xE2, Graphics::kTextAlignCenter);
+}
+
 // OPCODES
 
 void Script::o_invalid() {
@@ -1249,11 +1264,16 @@
 
 	stringstorage[counter] = 0;
 
-	// Load the font if required
-	if (!_font) {
-		_font = new Font(_vm->_system);
-	}
-	_font->printstring(stringstorage);
+	Common::Rect topbar(640, 80);
+	Graphics::Surface *gamescreen = _vm->_system->lockScreen();
+
+	// Clear the top bar
+	gamescreen->fillRect(topbar, 0);
+
+	// Draw the string
+	printString(gamescreen, stringstorage);
+
+	_vm->_system->unlockScreen();
 }
 
 void Script::o_hotspot_slot() {
@@ -1273,12 +1293,16 @@
 			return;
 		}
 
-		// Load the font if required
-		if (!_font) {
-			_font = new Font(_vm->_system);
-		}
-		_font->printstring(_saveNames[slot].c_str());
+		Common::Rect topbar(640, 80);
+		Graphics::Surface *gamescreen = _vm->_system->lockScreen();
 
+		// Clear the top bar
+		gamescreen->fillRect(topbar, 0);
+
+		printString(gamescreen, _saveNames[slot].c_str());
+
+		_vm->_system->unlockScreen();
+
 		// Save the currently highlighted slot
 		_hotspotSlot = slot;
 	} else {

Modified: scummvm/trunk/engines/groovie/script.h
===================================================================
--- scummvm/trunk/engines/groovie/script.h	2010-06-07 15:14:58 UTC (rev 49486)
+++ scummvm/trunk/engines/groovie/script.h	2010-06-07 17:14:42 UTC (rev 49487)
@@ -26,13 +26,17 @@
 #ifndef GROOVIE_SCRIPT_H
 #define GROOVIE_SCRIPT_H
 
-#include "common/file.h"
 #include "common/random.h"
 #include "common/rect.h"
 
-#include "groovie/font.h"
-#include "groovie/cell.h"
+namespace Common {
+class SeekableReadStream;
+}
 
+namespace Graphics {
+class Surface;
+}
+
 namespace Groovie {
 
 enum EngineVersion {
@@ -40,8 +44,9 @@
 	kGroovieV2
 };
 
+class CellGame;
+class Debugger;
 class GroovieEngine;
-class CellGame;
 
 class Script {
 	friend class Debugger;
@@ -112,7 +117,6 @@
 	uint16 _hotspotSlot;
 
 	// Video
-	Font *_font;
 	Common::SeekableReadStream *_videoFile;
 	uint32 _videoRef;
 	uint16 _bitflags;
@@ -140,6 +144,7 @@
 	void loadgame(uint slot);
 	void savegame(uint slot);
 	bool playvideofromref(uint32 fileref);
+	void printString(Graphics::Surface *surface, const char *str);
 
 	// Opcodes
 	typedef void (Script::*OpcodeFunc)();

Modified: scummvm/trunk/engines/groovie/vdx.cpp
===================================================================
--- scummvm/trunk/engines/groovie/vdx.cpp	2010-06-07 15:14:58 UTC (rev 49486)
+++ scummvm/trunk/engines/groovie/vdx.cpp	2010-06-07 17:14:42 UTC (rev 49487)
@@ -23,9 +23,10 @@
  *
  */
 
+#include "groovie/vdx.h"
+#include "groovie/graphics.h"
 #include "groovie/groovie.h"
 #include "groovie/lzss.h"
-#include "groovie/vdx.h"
 
 #include "common/debug-channels.h"
 #include "sound/mixer.h"

Modified: scummvm/trunk/engines/groovie/vdx.h
===================================================================
--- scummvm/trunk/engines/groovie/vdx.h	2010-06-07 15:14:58 UTC (rev 49486)
+++ scummvm/trunk/engines/groovie/vdx.h	2010-06-07 17:14:42 UTC (rev 49487)
@@ -28,6 +28,10 @@
 
 #include "groovie/player.h"
 
+namespace Common {
+	class ReadStream;
+}
+
 namespace Groovie {
 
 class VDXPlayer : public VideoPlayer {


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list