[Scummvm-cvs-logs] CVS: scummvm/queen graphics.h,1.16,1.17 graphics.cpp,1.17,1.18 resource.h,1.12,1.13 resource.cpp,1.12,1.13

Gregory Montoir cyx at users.sourceforge.net
Mon Oct 13 09:51:05 CEST 2003


Update of /cvsroot/scummvm/scummvm/queen
In directory sc8-pr-cvs1:/tmp/cvs-serv16424

Modified Files:
	graphics.h graphics.cpp resource.h resource.cpp 
Log Message:
dynalum implementation

Index: graphics.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/graphics.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- graphics.h	13 Oct 2003 14:21:17 -0000	1.16
+++ graphics.h	13 Oct 2003 16:49:53 -0000	1.17
@@ -101,6 +101,14 @@
 };
 
 
+struct Dynalum {
+	uint8 msk[50 * 160]; // mask
+	int8 lum[8 * 3]; // rgb
+	int8 oldColMask;
+	Dynalum(): oldColMask(-1) {}
+};
+
+
 //class Display;
 
 class Graphics {
@@ -155,10 +163,14 @@
 	void displayText(const TextSlot *pts, uint16 y); // FIXME: move to Display class
 	void displayChar(uint16 x, uint16 y, uint8 color, const uint8 *chr); // FIXME: move to Display class
 	static void displayBlit(uint8 *dst_buf, uint16 dst_x, uint16 dst_y, uint16 dst_pitch, const uint8 *src_buf, uint16 src_w, uint16 src_h, uint16 src_pitch, bool xflip, bool masked); // FIXME: move to Display class
-	void displaySetPal(uint8 *pal, int start, int end);
 	void displayScreen();
 
 	void setScreenMode(int comPanel, bool inCutaway);
+	void setRoomPal(const uint8 *pal, int start, int end);
+
+	void dynalumInit(const char* roomPrefix, uint16 room);
+	void dynalumUpdate(uint16 x, uint16 y); // dynalum()
+
 
 private:
 
@@ -188,6 +200,7 @@
 	//! bobs to display
 	BobSlot *_sortedBobs[MAX_BOBS_NUMBER];
 
+	//! number of bobs to display
 	uint16 _sortedBobsCount;
 
 	//! used to scale a BobFrame
@@ -212,13 +225,16 @@
 
 	uint16 _horizontalScroll;
 
-	uint8 *_palette;
+	uint8 *_paletteRoom; // palette
+	uint8 *_paletteScreen; // tpal
 
 	//! panel storage area
 	uint8 *_panel;
 
 	Resource *_resource;
 //	Display *_display;
+
+	Dynalum _dynalum;
 
 	//! font used to render the text
 	static const uint8 FONT[]; // FIXME: move to Display class

Index: graphics.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/graphics.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- graphics.cpp	13 Oct 2003 14:21:17 -0000	1.17
+++ graphics.cpp	13 Oct 2003 16:49:53 -0000	1.18
@@ -280,7 +280,8 @@
 	_screen = new uint8[ SCREEN_W * SCREEN_H ];
 	_fullscreen = true;
 	_horizontalScroll = 0;
-	_palette = new uint8[ 256 * 4 ];
+	_paletteRoom = new uint8[ 256 * 3 ];
+	_paletteScreen = new uint8[ 256 * 4 ];
 }
 
 
@@ -294,7 +295,8 @@
 	delete[] _backdrop;
 	delete[] _panel;
 	delete[] _screen;
-	delete[] _palette;
+	delete[] _paletteRoom;
+	delete[] _paletteScreen;
 }
 
 
@@ -711,7 +713,7 @@
 	for (int32 index = 0; index < _sortedBobsCount - 1; ++index) {
 		int32 smallest = index;
 		for (int32 compare = index + 1; compare <= _sortedBobsCount - 1; ++compare) {
-			if (_sortedBobs[compare]->y < _sortedBobs[compare]->y) {
+			if (_sortedBobs[compare]->y < _sortedBobs[smallest]->y) {
 				smallest = compare;
 			}
 		}
@@ -853,7 +855,7 @@
 	char roomPrefix[20];
 	strcpy(roomPrefix, name);
 	roomPrefix[ strlen(roomPrefix) - 4 ] = '\0';
-//	_display->dynalumInit(_resource, roomPrefix, room);
+	dynalumInit(roomPrefix, room);
 
 	uint8 *pcxbuf = _resource->loadFile(name);
 	if (pcxbuf == NULL) {
@@ -861,7 +863,7 @@
 	}
 
 	uint32 size = _resource->fileSize(name);
-	displaySetPal(pcxbuf + size - 768, 0, (room <= 144) ? 144 : 256);
+	setRoomPal(pcxbuf + size - 768, 0, (room <= 144) ? 144 : 256);
 
 	_backdropWidth  = READ_LE_UINT16(pcxbuf +  12);
 	_backdropHeight = READ_LE_UINT16(pcxbuf +  14);
@@ -901,7 +903,7 @@
 		error("Unable to open panel file");
 	}
 	uint32 size = _resource->fileSize("panel.pcx");
-	displaySetPal(pcxbuf + size - 768, 144, 256);
+	setRoomPal(pcxbuf + size - 768, 144, 256);
 	readPCX(pcxbuf + 128, _panel + PANEL_W * 10, PANEL_W, PANEL_W, PANEL_H - 10);
 	delete[] pcxbuf;
 }
@@ -1022,6 +1024,9 @@
 	backdropDraw();
 	bobDrawAll();
 	textDrawAll();
+	if (_bobs[0].active) {
+		dynalumUpdate(_bobs[0].x, _bobs[0].y);
+	}
 	displayScreen();
 	g_system->delay_msecs(100); // TEMP: move to Logic::update()
 }
@@ -1114,21 +1119,9 @@
 }
 
 
-void Graphics::displaySetPal(uint8 *pal, int start, int end) {
-	int i;
-	pal += start * 3;
-	for (i = start; i < end; ++i, pal += 3) {
-		_palette[i << 2 | 0] = *(pal + 0);
-		_palette[i << 2 | 1] = *(pal + 1);
-		_palette[i << 2 | 2] = *(pal + 2);
-		_palette[i << 2 | 3] = 0;
-	}
-}
-
-
 void Graphics::displayScreen() {
 	// FIXME: temporary code ; cleanup/move to Display class.
-	g_system->set_palette(_palette, 0, 256);
+	g_system->set_palette(_paletteScreen, 0, 256);
 	g_system->copy_rect(_screen, SCREEN_W, 0, 0, SCREEN_W, SCREEN_H);
 	g_system->update_screen();
 }
@@ -1151,6 +1144,62 @@
 	}
 }
 
+
+void Graphics::setRoomPal(const uint8 *pal, int start, int end) {
+	int i;
+	pal += start * 3;
+	for (i = start; i < end; ++i, pal += 3) {
+		_paletteScreen[i << 2 | 0] = _paletteRoom[i * 3 + 0] = *(pal + 0);
+		_paletteScreen[i << 2 | 1] = _paletteRoom[i * 3 + 1] = *(pal + 1);
+		_paletteScreen[i << 2 | 2] = _paletteRoom[i * 3 + 2] = *(pal + 2);
+		_paletteScreen[i << 2 | 3] = 0;
+	}
+}
+
+
+void Graphics::dynalumInit(const char* roomPrefix, uint16 room) {
+	// io.c l.2063-2089
+	memset(_dynalum.msk, 0, sizeof(_dynalum.msk));
+	memset(_dynalum.lum, 0, sizeof(_dynalum.lum));
+	if (room < 90 || ((room > 94) && (room < 114))) {
+		char filename[80];
+		sprintf(filename, "%s.msk", roomPrefix);
+		_resource->loadFile(filename, 0, (uint8*)_dynalum.msk);
+		sprintf(filename, "%s.lum", roomPrefix);
+		_resource->loadFile(filename, 0, (uint8*)_dynalum.lum);
+	}
+}
+
+
+void Graphics::dynalumUpdate(uint16 x, uint16 y) {
+
+	if (x >= _backdropWidth) {
+		x = _backdropWidth;
+	}
+	if (y >= ROOM_ZONE_HEIGHT - 1) {
+		y = ROOM_ZONE_HEIGHT - 1;
+	}
+	uint16 colMask = _dynalum.msk[(y / 4) * 160 + (x / 4)];
+	debug(9, "Graphics::dynalumUpdate(%d, %d) - colMask = %d", x, y, colMask);
+	if (colMask != _dynalum.oldColMask) {
+		uint8 i;
+		for (i = 0; i < 16; ++i) {
+			uint8 j;
+			for (j = 0; j < 3; ++j) {
+				int16 c = (int16)(_paletteRoom[(144 + i) * 3 + j] + _dynalum.lum[colMask * 3 + j] * 4);
+				if (c < 0) {
+					c = 0;
+				}
+				else if (c > 255) {
+					c = 255;
+				}
+				_paletteScreen[(144 + i) * 4 + j] = (uint8)c;
+			}
+		}
+		_dynalum.oldColMask = colMask;
+		// TODO: handle dirty colors (lopal, hipal)
+	}
+}
 
 
 } // End of namespace Queen

Index: resource.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/resource.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- resource.h	12 Oct 2003 18:44:44 -0000	1.12
+++ resource.h	13 Oct 2003 16:49:53 -0000	1.13
@@ -60,7 +60,7 @@
 public:
 	Resource(const Common::String &datafilePath);
 	~Resource(void);
-	uint8 *loadFile(const char *filename, uint32 skipBytes = 0);
+	uint8 *loadFile(const char *filename, uint32 skipBytes = 0, byte *dstBuf = NULL);
 	char *getJAS2Line();
 	bool exists(const char *filename);
 	bool isDemo();

Index: resource.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/resource.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- resource.cpp	12 Oct 2003 19:17:26 -0000	1.12
+++ resource.cpp	13 Oct 2003 16:49:53 -0000	1.13
@@ -139,13 +139,15 @@
 	return _resourceTable[resourceIndex(filename)].offset;
 }
 
-uint8 *Resource::loadFile(const char *filename, uint32 skipBytes) {
+uint8 *Resource::loadFile(const char *filename, uint32 skipBytes, byte *dstBuf) {
 	uint32 size = fileSize(filename);
-	byte *mem = new byte[size];
+	if (dstBuf == NULL) {
+		dstBuf = new byte[size];
+	}
 	// skip 'skipBytes' bytes (useful for headers)
 	_resourceFile->seek(fileOffset(filename) + skipBytes, SEEK_SET);
-	_resourceFile->read(mem, size - skipBytes);
-	return mem;
+	_resourceFile->read(dstBuf, size - skipBytes);
+	return dstBuf;
 }
 
 bool Resource::exists(const char *filename) {





More information about the Scummvm-git-logs mailing list