[Scummvm-cvs-logs] SF.net SVN: scummvm:[52697] scummvm/trunk

strangerke at users.sourceforge.net strangerke at users.sourceforge.net
Mon Sep 13 00:59:32 CEST 2010


Revision: 52697
          http://scummvm.svn.sourceforge.net/scummvm/?rev=52697&view=rev
Author:   strangerke
Date:     2010-09-12 22:59:32 +0000 (Sun, 12 Sep 2010)

Log Message:
-----------
HUGO: Use fonts in HUGO.DAT for the DOS version

This is only a temporary solution, to be replaced by a proper .FON 
handling. Hugo 2 and 3 (dos) now start.

Modified Paths:
--------------
    scummvm/trunk/dists/engine-data/hugo.dat
    scummvm/trunk/engines/hugo/display.cpp
    scummvm/trunk/engines/hugo/display.h
    scummvm/trunk/engines/hugo/hugo.cpp
    scummvm/trunk/engines/hugo/hugo.h
    scummvm/trunk/engines/hugo/mouse.cpp
    scummvm/trunk/engines/hugo/parser.cpp

Modified: scummvm/trunk/dists/engine-data/hugo.dat
===================================================================
(Binary files differ)

Modified: scummvm/trunk/engines/hugo/display.cpp
===================================================================
--- scummvm/trunk/engines/hugo/display.cpp	2010-09-12 22:54:37 UTC (rev 52696)
+++ scummvm/trunk/engines/hugo/display.cpp	2010-09-12 22:59:32 UTC (rev 52697)
@@ -453,4 +453,49 @@
 	           "ESC - Return to game");
 }
 
+Screen_v2::Screen_v2(HugoEngine &vm) : Screen(vm) {
+}
+
+Screen_v2::~Screen_v2() {
+}
+
+// Load font file, construct font ptrs and reverse data bytes
+// TODO: This uses hardcoded fonts in hugo.dat, it should be replaced
+//       by a proper implementation of .FON files
+void Screen_v2::loadFont(int16 fontId) {
+	byte  height, width;
+	static bool fontLoadedFl[NUM_FONTS] = {false, false, false};
+
+	debugC(2, kDebugDisplay, "loadFont(%d)", fontId);
+
+	_fnt = fontId - FIRST_FONT;                     // Set current font number
+
+	if (fontLoadedFl[_fnt])                             // If already loaded, return
+		return;
+
+	fontLoadedFl[_fnt] = true;
+
+	memcpy(_fontdata[_fnt], _vm._arrayFont[_fnt], _vm._arrayFontSize[_fnt]);
+	_font[_fnt][0] = _fontdata[_fnt];               // Store height,width of fonts
+
+	int16 offset = 2;                                       // Start at fontdata[2] ([0],[1] used for height,width)
+
+	// Setup the font array (127 characters)
+	for (int i = 1; i < 128; i++) {
+		if (i == 127) 
+			i = i;
+
+		_font[_fnt][i] = _fontdata[_fnt] + offset;
+		height = *(_fontdata[_fnt] + offset);
+		width  = *(_fontdata[_fnt] + offset + 1);
+
+		int16 size = height * ((width + 7) >> 3);
+		for (int j = 0; j < size; j++)
+			Utils::reverseByte(&_fontdata[_fnt][offset + 2 + j]);
+
+		offset += 2 + size;
+	}
+}
+
 } // End of namespace Hugo
+

Modified: scummvm/trunk/engines/hugo/display.h
===================================================================
--- scummvm/trunk/engines/hugo/display.h	2010-09-12 22:54:37 UTC (rev 52696)
+++ scummvm/trunk/engines/hugo/display.h	2010-09-12 22:59:32 UTC (rev 52697)
@@ -49,7 +49,7 @@
 	void     displayList(dupdate_t update, ...);
 	void     displayRect(int16 x, int16 y, int16 dx, int16 dy);
 	void     initDisplay();
-	void     loadFont(int16 fontId);
+	virtual void loadFont(int16 fontId);
 	void     moveImage(image_pt srcImage, uint16 x1, uint16 y1, uint16 dx, uint16 dy, uint16 width1, image_pt dstImage, uint16 x2, uint16 y2, uint16 width2);
 	void     remapPal(uint16 oldIndex, uint16 newIndex);
 	void     restorePal(Common::SeekableReadStream *f);
@@ -76,7 +76,7 @@
 		return _GUIBuffer;
 	}
 
-private:
+protected:
 	HugoEngine &_vm;
 
 	// Fonts used in dib (non-GDI)
@@ -84,6 +84,7 @@
 	byte _fontdata[NUM_FONTS][FONTSIZE];            // Font data
 	byte *_font[NUM_FONTS][FONT_LEN];               // Ptrs to each char
 
+private:
 	viewdib_t _frontBuffer;
 	viewdib_t _backBuffer;
 	viewdib_t _GUIBuffer;                           // User interface images
@@ -98,6 +99,15 @@
 	int16 center(char *s);
 };
 
+class Screen_v2 : public Screen {
+public:
+	Screen_v2(HugoEngine &vm);
+	~Screen_v2();
+
+	virtual void loadFont(int16 fontId);
+};
+
+
 } // End of namespace Hugo
 
 #endif //HUGO_DISPLAY_H

Modified: scummvm/trunk/engines/hugo/hugo.cpp
===================================================================
--- scummvm/trunk/engines/hugo/hugo.cpp	2010-09-12 22:54:37 UTC (rev 52696)
+++ scummvm/trunk/engines/hugo/hugo.cpp	2010-09-12 22:59:32 UTC (rev 52697)
@@ -122,6 +122,15 @@
 
 	free(_defltTunes);
 	free(_screenStates);
+
+	if (_arrayFont[0])
+		free(_arrayFont[0]);
+
+	if (_arrayFont[1])
+		free(_arrayFont[1]);
+
+	if (_arrayFont[2])
+		free(_arrayFont[2]);
 }
 
 GameType HugoEngine::getGameType() const {
@@ -140,7 +149,6 @@
 	s_Engine = this;
 	initGraphics(320, 200, false);
 
-	_screen = new Screen(*this);
 	_mouseHandler = new MouseHandler(*this);
 	_inventoryHandler = new InventoryHandler(*this);
 	_parser = new Parser(*this);
@@ -152,31 +160,37 @@
 		_fileManager = new FileManager_v3(*this);
 		_scheduler = new Scheduler_v2(*this);
 		_introHandler = new intro_1w(*this);
+		_screen = new Screen(*this);
 		break;
 	case 1:
 		_fileManager = new FileManager_v2(*this);
 		_scheduler = new Scheduler_v2(*this);
 		_introHandler = new intro_2w(*this);
+		_screen = new Screen(*this);
 		break;
 	case 2:
 		_fileManager = new FileManager_v2(*this);
 		_scheduler = new Scheduler_v2(*this);
 		_introHandler = new intro_3w(*this);
+		_screen = new Screen(*this);
 		break;
 	case 3: // H1 DOS
 		_fileManager = new FileManager_v1(*this);
 		_scheduler = new Scheduler_v1(*this);
 		_introHandler = new intro_1d(*this);
+		_screen = new Screen_v2(*this);
 		break;
 	case 4:
 		_fileManager = new FileManager_v2(*this);
 		_scheduler = new Scheduler_v1(*this);
 		_introHandler = new intro_2d(*this);
+		_screen = new Screen_v2(*this);
 		break;
 	case 5:
 		_fileManager = new FileManager_v4(*this);
 		_scheduler = new Scheduler_v2(*this);
 		_introHandler = new intro_3d(*this);
+		_screen = new Screen_v2(*this);
 		break;
 	}
 
@@ -1332,6 +1346,37 @@
 			_alNewscrIndex = numElem;
 	}
 
+	for (int j = 0; j < NUM_FONTS; j++)
+		_arrayFont[j] = 0;
+
+	if (_gameVariant > 2) {
+		_arrayFontSize[0] = in.readUint16BE();
+		_arrayFont[0] = (byte *)malloc(sizeof(byte) * _arrayFontSize[0]);
+		for (int j = 0; j < _arrayFontSize[0]; j++)
+			_arrayFont[0][j] = in.readByte();
+
+		_arrayFontSize[1] = in.readUint16BE();
+		_arrayFont[1] = (byte *)malloc(sizeof(byte) * _arrayFontSize[1]);
+		for (int j = 0; j < _arrayFontSize[1]; j++)
+			_arrayFont[1][j] = in.readByte();
+
+		_arrayFontSize[2] = in.readUint16BE();
+		_arrayFont[2] = (byte *)malloc(sizeof(byte) * _arrayFontSize[2]);
+		for (int j = 0; j < _arrayFontSize[2]; j++)
+			_arrayFont[2][j] = in.readByte();
+	} else {
+		numElem = in.readUint16BE();
+		for (int j = 0; j < numElem; j++)
+			in.readByte();
+
+		numElem = in.readUint16BE();
+		for (int j = 0; j < numElem; j++)
+			in.readByte();
+
+		numElem = in.readUint16BE();
+		for (int j = 0; j < numElem; j++)
+			in.readByte();
+	}
 	return true;
 }
 

Modified: scummvm/trunk/engines/hugo/hugo.h
===================================================================
--- scummvm/trunk/engines/hugo/hugo.h	2010-09-12 22:54:37 UTC (rev 52696)
+++ scummvm/trunk/engines/hugo/hugo.h	2010-09-12 22:59:32 UTC (rev 52697)
@@ -33,7 +33,7 @@
 #include "hugo/game.h"
 
 #define HUGO_DAT_VER_MAJ 0  // 1 byte
-#define HUGO_DAT_VER_MIN 21 // 1 byte
+#define HUGO_DAT_VER_MIN 22 // 1 byte
 #define DATAALIGNMENT 4
 
 namespace Common {
@@ -97,6 +97,8 @@
 	byte  *_introX;
 	byte  *_introY;
 	byte  *_screenStates;
+	byte  *_arrayFont[3];
+	int16  _arrayFontSize[3];
 	char  **_textData;
 	char  **_stringtData;
 	char  **_screenNames;

Modified: scummvm/trunk/engines/hugo/mouse.cpp
===================================================================
--- scummvm/trunk/engines/hugo/mouse.cpp	2010-09-12 22:54:37 UTC (rev 52696)
+++ scummvm/trunk/engines/hugo/mouse.cpp	2010-09-12 22:59:32 UTC (rev 52697)
@@ -67,8 +67,7 @@
 
 	debugC(1, kDebugMouse, "cursorText(%s, %d, %d, %d, %d)", buffer, cx, cy, fontId, color);
 
-	if (_vm.getPlatform() == Common::kPlatformWindows)
-		_vm.screen().loadFont(fontId);
+	_vm.screen().loadFont(fontId);
 
 	// Find bounding rect for string
 	int16 sdx = _vm.screen().stringLength(buffer);

Modified: scummvm/trunk/engines/hugo/parser.cpp
===================================================================
--- scummvm/trunk/engines/hugo/parser.cpp	2010-09-12 22:54:37 UTC (rev 52696)
+++ scummvm/trunk/engines/hugo/parser.cpp	2010-09-12 22:59:32 UTC (rev 52697)
@@ -197,8 +197,7 @@
 void Parser::drawStatusText() {
 	debugC(4, kDebugParser, "drawStatusText");
 
-	if (_vm.getPlatform() == Common::kPlatformWindows)
-		_vm.screen().loadFont(U_FONT8);
+	_vm.screen().loadFont(U_FONT8);
 	uint16 sdx = _vm.screen().stringLength(_statusLine);
 	uint16 sdy = _vm.screen().fontHeight() + 1;                 // + 1 for shadow
 	uint16 posX = 0;


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