[Scummvm-cvs-logs] CVS: scummvm/scumm gfx.cpp,1.93,1.94 nut_renderer.cpp,1.4,1.5 nut_renderer.h,1.1,1.2 script.cpp,1.26,1.27 script_v8.cpp,2.42,2.43

Max Horn fingolfin at users.sourceforge.net
Wed Dec 25 12:08:02 CET 2002


Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1:/tmp/cvs-serv32319

Modified Files:
	gfx.cpp nut_renderer.cpp nut_renderer.h script.cpp 
	script_v8.cpp 
Log Message:
two good rules of thumb: don't use typecasts if you don't have to - type cast have a nasty habit of hiding and causing problems. When a method takes a pointer argument, if possible make it const. :-). Cleanup. Fixed font rendering in CMI: you need to call updateDirtyRect() if you modify the screen...

Index: gfx.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/gfx.cpp,v
retrieving revision 1.93
retrieving revision 1.94
diff -u -d -r1.93 -r1.94
--- gfx.cpp	25 Dec 2002 14:46:38 -0000	1.93
+++ gfx.cpp	25 Dec 2002 20:07:08 -0000	1.94
@@ -331,7 +331,7 @@
 		_system->copy_rect(src, _realWidth, 0, vs->topline, _realWidth, vs->height - _screenTop);
 
 		for (i = 0; i < gdi._numStrips; i++) {
-			vs->tdirty[i] = (byte)vs->height;
+			vs->tdirty[i] = vs->height;
 			vs->bdirty[i] = 0;
 		}
 	}
@@ -372,9 +372,9 @@
 	
 			if (bottom) {
 				top = vs->tdirty[i];
-				vs->tdirty[i] = (byte)vs->height;
+				vs->tdirty[i] = vs->height;
 				vs->bdirty[i] = 0;
-				if (i != (_numStrips - 1) && vs->bdirty[i + 1] == (byte)bottom && vs->tdirty[i + 1] == (byte)top) {
+				if (i != (_numStrips - 1) && vs->bdirty[i + 1] == bottom && vs->tdirty[i + 1] == top) {
 					// Simple optimizations: if two or more neighbouring strips form one bigger rectangle,
 					// blit them all at once.
 					w += 8;

Index: nut_renderer.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/nut_renderer.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- nut_renderer.cpp	25 Dec 2002 14:59:33 -0000	1.4
+++ nut_renderer.cpp	25 Dec 2002 20:07:09 -0000	1.5
@@ -1,5 +1,4 @@
 /* ScummVM - Scumm Interpreter
- * Copyright (C) 2001  Ludvig Strigeus
  * Copyright (C) 2001/2002 The ScummVM project
  *
  * This program is free software; you can redistribute it and/or
@@ -20,10 +19,11 @@
  */
 
 #include "stdafx.h"
-#include "engine.h"
+#include "scumm.h"
 #include "nut_renderer.h"
 
-NutRenderer::NutRenderer() {
+NutRenderer::NutRenderer(Scumm *vm) {
+	_vm = vm;
 	_initialized = false;
 	_loaded = false;
 	_dataSrc = NULL;
@@ -81,7 +81,7 @@
 	_initialized = true;
 }
 
-bool NutRenderer::loadFont(char *filename, char *dir) {
+bool NutRenderer::loadFont(const char *filename, const char *dir) {
 	debug(2,  "NutRenderer::loadFont() called");
 	if (_loaded == true) {
 		debug(2, "NutRenderer::loadFont() Font already loaded, ok, loading...");
@@ -177,31 +177,37 @@
 	return length;
 }
 
-void NutRenderer::drawString(char *string, int32 x, int32 y, byte color, int32 mode) {
-	debug(2,  "NutRenderer::getDrawString() called");
+void NutRenderer::drawString(const char *string, int32 x, int32 y, byte color, int32 mode) {
+	debug(2,  "NutRenderer::drawString() called");
 	if (_loaded == false) {
-		debug(2, "NutRenderer::getDrawString() Font is not loaded");
+		debug(2, "NutRenderer::drawString() Font is not loaded");
 		return;
 	}
 
-	int32 l = 0;
+	int l = 0;
+	int left = x;
+	int height = 0, tmp;
 	do {
 		if ((x < 0) || (y < 0) || (x > _dstWidth) || (y > _dstHeight)) {
-			debug(2, "NutRenderer::getDrawString() position x, y out of range");
+			debug(2, "NutRenderer::drawString() position x, y out of range");
 			return;
 		}
 
 		drawChar(string[l], x, y, color);
 		x += getCharWidth(string[l]);
+		tmp = getCharHeight(string[l]);
+		if (height < tmp)
+			height = tmp;
 		l++;
 	} while (string[l] != 0);
 
+	_vm->updateDirtyRect(0, left, x, y, y + height, 0);
 }
 
 void NutRenderer::drawChar(char c, int32 x, int32 y, byte color) {
-	debug(2,  "NutRenderer::getDrawChar() called");
+	debug(2,  "NutRenderer::drawChar('%c', %d, %d, %d) called", c, x, y, (int)color);
 	if (_loaded == false) {
-		debug(2, "NutRenderer::getDrawChar() Font is not loaded");
+		debug(2, "NutRenderer::drawChar() Font is not loaded");
 		return;
 	}
 
@@ -231,6 +237,5 @@
 			}
 		}
 	}
-
 }
 

Index: nut_renderer.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/nut_renderer.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- nut_renderer.h	25 Dec 2002 13:04:01 -0000	1.1
+++ nut_renderer.h	25 Dec 2002 20:07:09 -0000	1.2
@@ -1,5 +1,4 @@
 /* ScummVM - Scumm Interpreter
- * Copyright (C) 2001  Ludvig Strigeus
  * Copyright (C) 2001/2002 The ScummVM project
  *
  * This program is free software; you can redistribute it and/or
@@ -24,8 +23,11 @@
 
 #include "common/file.h"
 
+class Scumm;
+
 class NutRenderer {
 private:
+	Scumm *_vm;
 	int32 _offsets[256];
 	byte _tmpCodecBuffer[2000];
 	byte *_dataSrc;
@@ -37,13 +39,13 @@
 	void decodeCodec44(byte *dst, byte *src, uint32 length);
 
 public:
-	NutRenderer();
+	NutRenderer(Scumm *vm);
 	~NutRenderer();
 
 	void bindDisplay(byte *dst, int32 width, int32 height, int32 pitch);
-	bool loadFont(char *filename, char *dir);
+	bool loadFont(const char *filename, const char *dir);
 	void drawChar(char c, int32 x, int32 y, byte color);
-	void drawString(char *string, int32 x, int32 y, byte color, int32 mode);
+	void drawString(const char *string, int32 x, int32 y, byte color, int32 mode);
 	int32 getCharWidth(char c);
 	int32 getCharHeight(char c);
 	int32 getStringWidth(char *string);

Index: script.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script.cpp,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- script.cpp	25 Dec 2002 19:06:31 -0000	1.26
+++ script.cpp	25 Dec 2002 20:07:09 -0000	1.27
@@ -285,7 +285,7 @@
 		_opcode = fetchScriptByte();
 		_scriptPointerStart = _scriptPointer;
 		vm.slot[_currentScript].didexec = 1;
-		debug(1, "Script %d, offset 0x%x: [%X] %s()",
+		debug(3, "Script %d, offset 0x%x: [%X] %s()",
 				vm.slot[_currentScript].number,
 				_scriptPointer - _scriptOrgPointer,
 				_opcode,

Index: script_v8.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v8.cpp,v
retrieving revision 2.42
retrieving revision 2.43
diff -u -d -r2.42 -r2.43
--- script_v8.cpp	25 Dec 2002 19:30:59 -0000	2.42
+++ script_v8.cpp	25 Dec 2002 20:07:09 -0000	2.43
@@ -38,17 +38,17 @@
 
 // FIXME: Move this somewhere better :)
 void Scumm_v8::loadCharset(int charset) {
-	char fontname[255];
+	char fontname[256];
 	sprintf(fontname, "resource/font%d.nut", charset);
 	warning("Loading charset %s\n", fontname);
-	_fr[charset] = new NutRenderer;
-	if (!(_fr[charset]->loadFont(fontname, (char*)getGameDataPath()))) {
+	_fr[charset] = new NutRenderer(this);
+	if (!(_fr[charset]->loadFont(fontname, getGameDataPath()))) {
 		delete _fr[charset];
 		_fr[charset] = NULL;
 		return;
 	}
 
-	_fr[charset]->bindDisplay((byte*)virtscr[0].screenPtr, (int32)_realWidth, (int32)_realHeight, (int32)_realWidth);
+	_fr[charset]->bindDisplay(virtscr[0].screenPtr, _realWidth, _realHeight, _realWidth);
 }
 
 void Scumm_v8::setupOpcodes()





More information about the Scummvm-git-logs mailing list