[Scummvm-cvs-logs] SF.net SVN: scummvm:[54103] scummvm/trunk/engines/hugo

strangerke at users.sourceforge.net strangerke at users.sourceforge.net
Sun Nov 7 01:02:49 CET 2010


Revision: 54103
          http://scummvm.svn.sourceforge.net/scummvm/?rev=54103&view=rev
Author:   strangerke
Date:     2010-11-07 00:02:48 +0000 (Sun, 07 Nov 2010)

Log Message:
-----------
HUGO: Move fonts to display.cpp

Some cleanup

Modified Paths:
--------------
    scummvm/trunk/engines/hugo/display.cpp
    scummvm/trunk/engines/hugo/display.h
    scummvm/trunk/engines/hugo/display_v1d.cpp
    scummvm/trunk/engines/hugo/display_v1w.cpp
    scummvm/trunk/engines/hugo/hugo.cpp
    scummvm/trunk/engines/hugo/hugo.h

Modified: scummvm/trunk/engines/hugo/display.cpp
===================================================================
--- scummvm/trunk/engines/hugo/display.cpp	2010-11-06 13:21:18 UTC (rev 54102)
+++ scummvm/trunk/engines/hugo/display.cpp	2010-11-07 00:02:48 UTC (rev 54103)
@@ -49,7 +49,10 @@
 #define OVERLAP(A, B) ((INX(A->x, B) || INX(A->x + A->dx, B) || INX(B->x, A) || INX(B->x + B->dx, A)) && (INY(A->y, B) || INY(A->y + A->dy, B) || INY(B->y, A) || INY(B->y + B->dy, A)))
 
 Screen::Screen(HugoEngine *vm) : _vm(vm), _palette(0) {
-
+	for (int j = 0; j < NUM_FONTS; j++) {
+		_arrayFont[j] = 0;
+		fontLoadedFl[j] = false;
+	}
 }
 
 Screen::~Screen() {
@@ -507,5 +510,14 @@
 	free(_palette);
 }
 
+/**
+* Free fonts
+*/
+void Screen::freeFonts() {
+	for (int i = 0; i < NUM_FONTS; i++) {
+		if (_arrayFont[i])
+			free(_arrayFont[i]);
+	}
+}
 } // End of namespace Hugo
 

Modified: scummvm/trunk/engines/hugo/display.h
===================================================================
--- scummvm/trunk/engines/hugo/display.h	2010-11-06 13:21:18 UTC (rev 54102)
+++ scummvm/trunk/engines/hugo/display.h	2010-11-07 00:02:48 UTC (rev 54103)
@@ -50,6 +50,7 @@
 	virtual ~Screen();
 
 	virtual void loadFont(int16 fontId) = 0;
+	virtual void loadFontArr(Common::File &in) = 0;
 
 	int16    fontHeight();
 	int16    stringLength(const char *s);
@@ -61,6 +62,7 @@
 	void     drawRectangle(bool filledFl, uint16 x1, uint16 y1, uint16 x2, uint16 y2, int color);
 	void     drawShape(int x, int y, int color1, int color2);
 	void     drawStatusText();
+	void     freeFonts();
 	void     freePalette();
 	void     initDisplay();
 	void     initNewScreenDisplay();
@@ -98,14 +100,18 @@
 protected:
 	HugoEngine *_vm;
 
+	bool fontLoadedFl[NUM_FONTS];
+
 	// Fonts used in dib (non-GDI)
+	byte *_arrayFont[NUM_FONTS];
 	byte  _fnt;                                     // Current font number
 	byte  _fontdata[NUM_FONTS][FONTSIZE];           // Font data
 	byte *_font[NUM_FONTS][FONT_LEN];               // Ptrs to each char
 	byte *_palette;
-
 	byte  _paletteSize;
 
+	int16 _arrayFontSize[NUM_FONTS];
+
 private:
 	viewdib_t _frontBuffer;
 	viewdib_t _backBuffer;
@@ -126,6 +132,7 @@
 	~Screen_v1d();
 
 	void loadFont(int16 fontId);
+	void loadFontArr(Common::File &in);
 };
 
 class Screen_v1w : public Screen {
@@ -134,6 +141,7 @@
 	~Screen_v1w();
 
 	void loadFont(int16 fontId);
+	void loadFontArr(Common::File &in);
 };
 
 } // End of namespace Hugo

Modified: scummvm/trunk/engines/hugo/display_v1d.cpp
===================================================================
--- scummvm/trunk/engines/hugo/display_v1d.cpp	2010-11-06 13:21:18 UTC (rev 54102)
+++ scummvm/trunk/engines/hugo/display_v1d.cpp	2010-11-07 00:02:48 UTC (rev 54103)
@@ -54,19 +54,19 @@
 void Screen_v1d::loadFont(int16 fontId) {
 	debugC(2, kDebugDisplay, "loadFont(%d)", fontId);
 
-	static bool fontLoadedFl[NUM_FONTS] = {false, false, false};
+	assert(fontId < NUM_FONTS);
 
 	_fnt = fontId - FIRST_FONT;                     // Set current font number
 
-	if (fontLoadedFl[_fnt])                             // If already loaded, return
+	if (fontLoadedFl[_fnt])                         // If already loaded, return
 		return;
 
 	fontLoadedFl[_fnt] = true;
 
-	memcpy(_fontdata[_fnt], _vm->_arrayFont[_fnt], _vm->_arrayFontSize[_fnt]);
+	memcpy(_fontdata[_fnt], _arrayFont[_fnt], _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)
+	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++) {
@@ -81,5 +81,20 @@
 		offset += 2 + size;
 	}
 }
+
+/**
+* Load fonts from Hugo.dat
+* These fonts are a workaround to avoid handling TTF fonts used by DOS versions
+* TODO: Properly handle the vector based font files (win31)
+*/
+void Screen_v1d::loadFontArr(Common::File &in) {
+	for (int i = 0; i < NUM_FONTS; i++) {
+		_arrayFontSize[i] = in.readUint16BE();
+		_arrayFont[i] = (byte *)malloc(sizeof(byte) * _arrayFontSize[i]);
+		for (int j = 0; j < _arrayFontSize[i]; j++) {
+			_arrayFont[i][j] = in.readByte();
+		}
+	}
+}
 } // End of namespace Hugo
 

Modified: scummvm/trunk/engines/hugo/display_v1w.cpp
===================================================================
--- scummvm/trunk/engines/hugo/display_v1w.cpp	2010-11-06 13:21:18 UTC (rev 54102)
+++ scummvm/trunk/engines/hugo/display_v1w.cpp	2010-11-07 00:02:48 UTC (rev 54103)
@@ -53,8 +53,6 @@
 void Screen_v1w::loadFont(int16 fontId) {
 	debugC(2, kDebugDisplay, "loadFont(%d)", fontId);
 
-	static bool fontLoadedFl[NUM_FONTS] = {false, false, false};
-
 	_fnt = fontId - FIRST_FONT;                     // Set current font number
 
 	if (fontLoadedFl[_fnt])                             // If already loaded, return
@@ -81,5 +79,16 @@
 		offset += 2 + size;
 	}
 }
+
+/**
+* Skips the fonts used by the DOS versions
+*/
+void Screen_v1w::loadFontArr(Common::File &in) {
+	for (int i = 0; i < NUM_FONTS; i++) {
+		uint16 numElem = in.readUint16BE();
+		for (int j = 0; j < numElem; j++)
+			in.readByte();
+	}
+}
 } // End of namespace Hugo
 

Modified: scummvm/trunk/engines/hugo/hugo.cpp
===================================================================
--- scummvm/trunk/engines/hugo/hugo.cpp	2010-11-06 13:21:18 UTC (rev 54102)
+++ scummvm/trunk/engines/hugo/hugo.cpp	2010-11-07 00:02:48 UTC (rev 54103)
@@ -79,8 +79,6 @@
 	DebugMan.addDebugChannel(kDebugInventory, "Inventory", "Inventory debug level");
 	DebugMan.addDebugChannel(kDebugObject, "Object", "Object debug level");
 
-	for (int j = 0; j < NUM_FONTS; j++)
-		_arrayFont[j] = 0;
 }
 
 HugoEngine::~HugoEngine() {
@@ -135,15 +133,8 @@
 	free(_defltTunes);
 	free(_screenStates);
 
-	if (_arrayFont[0])
-		free(_arrayFont[0]);
+	_screen->freeFonts();
 
-	if (_arrayFont[1])
-		free(_arrayFont[1]);
-
-	if (_arrayFont[2])
-		free(_arrayFont[2]);
-
 	delete _object;
 	delete _sound;
 	delete _route;
@@ -729,35 +720,8 @@
 	}
 
 	_scheduler->loadAlNewscrIndex(in);
+	_screen->loadFontArr(in);
 
-	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-11-06 13:21:18 UTC (rev 54102)
+++ scummvm/trunk/engines/hugo/hugo.h	2010-11-07 00:02:48 UTC (rev 54103)
@@ -126,8 +126,6 @@
 	byte  *_introX;
 	byte  *_introY;
 	byte  *_screenStates;
-	byte  *_arrayFont[3];
-	int16  _arrayFontSize[3];
 	char  **_textData;
 	char  **_stringtData;
 	char  **_screenNames;


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