diff options
| -rw-r--r-- | engines/scumm/charset.cpp | 6 | ||||
| -rw-r--r-- | engines/scumm/insane/insane.cpp | 12 | ||||
| -rw-r--r-- | engines/scumm/nut_renderer.cpp | 54 | ||||
| -rw-r--r-- | engines/scumm/nut_renderer.h | 11 | ||||
| -rw-r--r-- | engines/scumm/smush/smush_font.cpp | 12 | ||||
| -rw-r--r-- | engines/scumm/smush/smush_font.h | 2 | ||||
| -rw-r--r-- | engines/scumm/smush/smush_player.cpp | 9 | 
7 files changed, 28 insertions, 78 deletions
diff --git a/engines/scumm/charset.cpp b/engines/scumm/charset.cpp index 165eead6e7..a50e749d0f 100644 --- a/engines/scumm/charset.cpp +++ b/engines/scumm/charset.cpp @@ -1610,8 +1610,6 @@ CharsetRendererNut::CharsetRendererNut(ScummEngine *vm)  CharsetRendererNut::~CharsetRendererNut() {  	for (int i = 0; i < 5; i++) { -		if ((_vm->_game.id == GID_CMI) && (_vm->_game.features & GF_DEMO) && (i == 4)) -			break;  		delete _fr[i];  	}  } @@ -1621,11 +1619,9 @@ void CharsetRendererNut::setCurID(byte id) {  	assert(id < numFonts);  	_curId = id;  	if (!_fr[id]) { -		_fr[id] = new NutRenderer(_vm);  		char fontname[11];  		sprintf(fontname, "font%d.nut", id); -		_fr[id] = new NutRenderer(_vm); -		_fr[id]->loadFont(fontname, true); +		_fr[id] = new NutRenderer(_vm, fontname, true);  	}  	_current = _fr[id];  	assert(_current); diff --git a/engines/scumm/insane/insane.cpp b/engines/scumm/insane/insane.cpp index 505ade1453..eaca1da4e7 100644 --- a/engines/scumm/insane/insane.cpp +++ b/engines/scumm/insane/insane.cpp @@ -65,16 +65,12 @@ Insane::Insane(ScummEngine_v7 *scumm) {  		readFileToMem("toranch.flu", &_smush_toranchFlu);  		readFileToMem("minedriv.flu", &_smush_minedrivFlu);  		readFileToMem("minefite.flu", &_smush_minefiteFlu); -		_smush_bensgoggNut = new NutRenderer(_vm); -		_smush_bensgoggNut->loadFont("bensgogg.nut", false); -		_smush_bencutNut = new NutRenderer(_vm); -		_smush_bencutNut->loadFont("bencut.nut", false); +		_smush_bensgoggNut = new NutRenderer(_vm, "bensgogg.nut", false); +		_smush_bencutNut = new NutRenderer(_vm, "bencut.nut", false);  	} -	_smush_iconsNut = new NutRenderer(_vm); -	_smush_iconsNut->loadFont("icons.nut", false); -	_smush_icons2Nut = new NutRenderer(_vm); -	_smush_icons2Nut->loadFont("icons2.nut", false); +	_smush_iconsNut = new NutRenderer(_vm, "icons.nut", false); +	_smush_icons2Nut = new NutRenderer(_vm, "icons2.nut", false);  }  Insane::~Insane(void) { diff --git a/engines/scumm/nut_renderer.cpp b/engines/scumm/nut_renderer.cpp index 6a78e4dd95..caa4671328 100644 --- a/engines/scumm/nut_renderer.cpp +++ b/engines/scumm/nut_renderer.cpp @@ -27,19 +27,20 @@  namespace Scumm { -NutRenderer::NutRenderer(ScummEngine *vm) : +NutRenderer::NutRenderer(ScummEngine *vm, const char *filename, bool bitmap) :  	_vm(vm), -	_loaded(false), +	_bitmapFont(bitmap),  	_numChars(0),  	_decodedData(0) {  	memset(_chars, 0, sizeof(_chars)); +	loadFont(filename);  }  NutRenderer::~NutRenderer() {  	delete [] _decodedData;  } -void NutRenderer::codec1(bool bitmap, byte *dst, const byte *src, int width, int height, int pitch) { +void NutRenderer::codec1(byte *dst, const byte *src, int width, int height, int pitch) {  	byte val, code;  	int32 length;  	int h = height, size_line; @@ -56,7 +57,7 @@ void NutRenderer::codec1(bool bitmap, byte *dst, const byte *src, int width, int  			if (code & 1) {  				val = *src++;  				size_line--; -				if (bitmap) { +				if (_bitmapFont) {  					for (int i = 0; i < length; i++) {  						if (val)  							*dst |= bit; @@ -75,7 +76,7 @@ void NutRenderer::codec1(bool bitmap, byte *dst, const byte *src, int width, int  				size_line -= length;  				while (length--) {  					val = *src++; -					if (bitmap) { +					if (_bitmapFont) {  						if (val)  							*dst |= bit;  						bit >>= 1; @@ -95,7 +96,7 @@ void NutRenderer::codec1(bool bitmap, byte *dst, const byte *src, int width, int  	}  } -void NutRenderer::codec21(bool bitmap, byte *dst, const byte *src, int width, int height, int pitch) { +void NutRenderer::codec21(byte *dst, const byte *src, int width, int height, int pitch) {  	while (height--) {  		byte *dstPtrNext = dst + pitch;  		const byte *srcPtrNext = src + 2 + READ_LE_UINT16(src); @@ -105,7 +106,7 @@ void NutRenderer::codec21(bool bitmap, byte *dst, const byte *src, int width, in  		do {  			int i;  			int offs = READ_LE_UINT16(src); src += 2; -			if (bitmap) { +			if (_bitmapFont) {  				for (i = 0; i < offs; i++) {  					bit >>= 1;  					if (!bit) { @@ -129,7 +130,7 @@ void NutRenderer::codec21(bool bitmap, byte *dst, const byte *src, int width, in  			//  src bytes equal to 255 are replaced by 0 in dst  			//  src bytes equal to 1 are replaced by a color passed as an argument in the original function  			//  other src bytes values are copied as-is -			if (bitmap) { +			if (_bitmapFont) {  				for (i = 0; i < w; i++) {  					if (src[i])  						*dst |= bit; @@ -150,24 +151,16 @@ void NutRenderer::codec21(bool bitmap, byte *dst, const byte *src, int width, in  	}  } -bool NutRenderer::loadFont(const char *filename, bool bitmap) { -	if (_loaded) { -		debug(0, "NutRenderer::loadFont() Font already loaded, ok, loading..."); -	} - -	_bitmapFont = bitmap; - +void NutRenderer::loadFont(const char *filename) {  	ScummFile file;  	_vm->openFile(file, filename);  	if (!file.isOpen()) {  		error("NutRenderer::loadFont() Can't open font file: %s", filename); -		return false;  	}  	uint32 tag = file.readUint32BE();  	if (tag != 'ANIM') {  		error("NutRenderer::loadFont() there is no ANIM chunk in font header"); -		return false;  	}  	uint32 length = file.readUint32BE(); @@ -177,8 +170,6 @@ bool NutRenderer::loadFont(const char *filename, bool bitmap) {  	if (READ_BE_UINT32(dataSrc) != 'AHDR') {  		error("NutRenderer::loadFont() there is no AHDR chunk in font header"); -		free(dataSrc); -		return false;  	}  	// We pre-decode the font, which may seem wasteful at first. Actually, @@ -242,11 +233,11 @@ bool NutRenderer::loadFont(const char *filename, bool bitmap) {  		const uint8 *fobjptr = dataSrc + offset + 22;  		switch (codec) {  		case 1: -			codec1(_bitmapFont, _chars[l].src, fobjptr, _chars[l].width, _chars[l].height, pitch); +			codec1(_chars[l].src, fobjptr, _chars[l].width, _chars[l].height, pitch);  			break;  		case 21:  		case 44: -			codec21(_bitmapFont, _chars[l].src, fobjptr, _chars[l].width, _chars[l].height, pitch); +			codec21(_chars[l].src, fobjptr, _chars[l].width, _chars[l].height, pitch);  			break;  		default:  			error("NutRenderer::loadFont: unknown codec: %d", codec); @@ -254,16 +245,9 @@ bool NutRenderer::loadFont(const char *filename, bool bitmap) {  	}  	delete [] dataSrc; -	_loaded = true; -	return true;  }  int NutRenderer::getCharWidth(byte c) const { -	if (!_loaded) { -		error("NutRenderer::getCharWidth() Font is not loaded"); -		return 0; -	} -  	if (c >= 0x80 && _vm->_useCJKMode)  		return _vm->_2byteWidth / 2; @@ -274,11 +258,6 @@ int NutRenderer::getCharWidth(byte c) const {  }  int NutRenderer::getCharHeight(byte c) const { -	if (!_loaded) { -		error("NutRenderer::getCharHeight() Font is not loaded"); -		return 0; -	} -  	if (c >= 0x80 && _vm->_useCJKMode)  		return _vm->_2byteHeight; @@ -289,10 +268,6 @@ int NutRenderer::getCharHeight(byte c) const {  }  void NutRenderer::drawShadowChar(const Graphics::Surface &s, int c, int x, int y, byte color, bool showShadow) { -	if (!_loaded) { -		error("NutRenderer::drawShadowChar() Font is not loaded"); -		return; -	}  	// We draw the character a total of 7 times: 6 times shifted and in black  	// for the shadow, and once in the right color and position. This way we @@ -405,11 +380,6 @@ void NutRenderer::drawChar(const Graphics::Surface &s, byte c, int x, int y, byt  }  void NutRenderer::draw2byte(const Graphics::Surface &s, int c, int x, int y, byte color) { -	if (!_loaded) { -		error("NutRenderer::draw2byte() Font is not loaded"); -		return; -	} -  	byte *dst = (byte *)s.pixels + y * s.pitch + x;  	const int width = _vm->_2byteWidth;  	const int height = MIN(_vm->_2byteHeight, s.h - y); diff --git a/engines/scumm/nut_renderer.h b/engines/scumm/nut_renderer.h index c3bc68477a..26a3f0a302 100644 --- a/engines/scumm/nut_renderer.h +++ b/engines/scumm/nut_renderer.h @@ -32,7 +32,6 @@ class ScummEngine;  class NutRenderer {  protected:  	ScummEngine *_vm; -	bool _loaded;  	bool _bitmapFont;  	int _numChars;  	byte *_decodedData; @@ -42,19 +41,19 @@ protected:  		byte *src;  	} _chars[256]; -	static void codec1(bool bitmap, byte *dst, const byte *src, int width, int height, int pitch); -	static void codec21(bool bitmap, byte *dst, const byte *src, int width, int height, int pitch); +	void codec1(byte *dst, const byte *src, int width, int height, int pitch); +	void codec21(byte *dst, const byte *src, int width, int height, int pitch);  	void drawChar(const Graphics::Surface &s, byte c, int x, int y, byte color);  	void draw2byte(const Graphics::Surface &s, int c, int x, int y, byte color); +	void loadFont(const char *filename); +  public: -	NutRenderer(ScummEngine *vm); +	NutRenderer(ScummEngine *vm, const char *filename, bool bitmap);  	virtual ~NutRenderer();  	int getNumChars() const { return _numChars; } -	bool loadFont(const char *filename, bool bitmap); -  	void drawFrame(byte *dst, int c, int x, int y);  	void drawShadowChar(const Graphics::Surface &s, int c, int x, int y, byte color, bool showShadow); diff --git a/engines/scumm/smush/smush_font.cpp b/engines/scumm/smush/smush_font.cpp index 59caaeea61..de7fe9c460 100644 --- a/engines/scumm/smush/smush_font.cpp +++ b/engines/scumm/smush/smush_font.cpp @@ -29,8 +29,8 @@  namespace Scumm { -SmushFont::SmushFont(ScummEngine *vm, bool use_original_colors, bool new_colors) : -	NutRenderer(vm), +SmushFont::SmushFont(ScummEngine *vm, const char *filename, bool use_original_colors, bool new_colors) : +	NutRenderer(vm, filename, false),  	_color(-1),  	_new_colors(new_colors),  	_original(use_original_colors) { @@ -38,10 +38,6 @@ SmushFont::SmushFont(ScummEngine *vm, bool use_original_colors, bool new_colors)  int SmushFont::getStringWidth(const char *str) {  	assert(str); -	if (!_loaded) { -		error("SmushFont::getStringWidth() Font is not loaded"); -		return 0; -	}  	int width = 0;  	while (*str) { @@ -56,10 +52,6 @@ int SmushFont::getStringWidth(const char *str) {  int SmushFont::getStringHeight(const char *str) {  	assert(str); -	if (!_loaded) { -		error("SmushFont::getStringHeight() Font is not loaded"); -		return 0; -	}  	int height = 0;  	while (*str) { diff --git a/engines/scumm/smush/smush_font.h b/engines/scumm/smush/smush_font.h index 724eb46658..65bee940c2 100644 --- a/engines/scumm/smush/smush_font.h +++ b/engines/scumm/smush/smush_font.h @@ -42,7 +42,7 @@ protected:  	void drawSubstring(const char *str, byte *buffer, int dst_width, int x, int y);  public: -	SmushFont(ScummEngine *vm, bool use_original_colors, bool new_colors); +	SmushFont(ScummEngine *vm, const char *filename, bool use_original_colors, bool new_colors);  	void setColor(byte c) { _color = c; }  	void drawString    (const char *str, byte *buffer, int dst_width, int dst_height, int x, int y, bool center); diff --git a/engines/scumm/smush/smush_player.cpp b/engines/scumm/smush/smush_player.cpp index 38febf8a29..8363868d09 100644 --- a/engines/scumm/smush/smush_player.cpp +++ b/engines/scumm/smush/smush_player.cpp @@ -1051,24 +1051,21 @@ SmushFont *SmushPlayer::getFont(int font) {  			assert(font >= 0 && font < ARRAYSIZE(ft_fonts)); -			_sf[font] = new SmushFont(_vm, true, false); -			_sf[font]->loadFont(ft_fonts[font], false); +			_sf[font] = new SmushFont(_vm, ft_fonts[font], true, false);  		}  	} else if (_vm->_game.id == GID_DIG) {  		if (!(_vm->_game.features & GF_DEMO)) {  			assert(font >= 0 && font < 4);  			sprintf(file_font, "font%d.nut", font); -			_sf[font] = new SmushFont(_vm, font != 0, false); -			_sf[font]->loadFont(file_font, false); +			_sf[font] = new SmushFont(_vm, file_font, font != 0, false);  		}  	} else if (_vm->_game.id == GID_CMI) {  		int numFonts = (_vm->_game.features & GF_DEMO) ? 4 : 5;  		assert(font >= 0 && font < numFonts);  		sprintf(file_font, "font%d.nut", font); -		_sf[font] = new SmushFont(_vm, false, true); -		_sf[font]->loadFont(file_font, false); +		_sf[font] = new SmushFont(_vm, file_font, false, true);  	} else {  		error("SmushPlayer::getFont() Unknown font setup for game");  	}  | 
