[Scummvm-cvs-logs] SF.net SVN: scummvm:[47249] scummvm/trunk/backends/platform/n64

Hkz at users.sourceforge.net Hkz at users.sourceforge.net
Mon Jan 11 12:37:11 CET 2010


Revision: 47249
          http://scummvm.svn.sourceforge.net/scummvm/?rev=47249&view=rev
Author:   Hkz
Date:     2010-01-11 11:37:11 +0000 (Mon, 11 Jan 2010)

Log Message:
-----------
N64: optimizations in cursor drawing code

Modified Paths:
--------------
    scummvm/trunk/backends/platform/n64/Makefile
    scummvm/trunk/backends/platform/n64/osys_n64.h
    scummvm/trunk/backends/platform/n64/osys_n64_base.cpp

Modified: scummvm/trunk/backends/platform/n64/Makefile
===================================================================
--- scummvm/trunk/backends/platform/n64/Makefile	2010-01-11 11:34:43 UTC (rev 47248)
+++ scummvm/trunk/backends/platform/n64/Makefile	2010-01-11 11:37:11 UTC (rev 47249)
@@ -53,7 +53,7 @@
 
 ENABLED=STATIC_PLUGIN
 
-#ENABLE_SCUMM=$(ENABLED)
+ENABLE_SCUMM=$(ENABLED)
 #ENABLE_SKY=$(ENABLED)
 #ENABLE_SCI=$(ENABLED)
 #ENABLE_GOB=$(ENABLED)

Modified: scummvm/trunk/backends/platform/n64/osys_n64.h
===================================================================
--- scummvm/trunk/backends/platform/n64/osys_n64.h	2010-01-11 11:34:43 UTC (rev 47248)
+++ scummvm/trunk/backends/platform/n64/osys_n64.h	2010-01-11 11:37:11 UTC (rev 47249)
@@ -101,6 +101,7 @@
 	int _shakeOffset;
 
 	uint8 *_cursor_pal; // Cursor buffer, palettized
+	uint16 *_cursor_hic; // Cursor buffer, 16bit
 	bool _cursorPaletteDisabled;
 	bool _dirtyPalette;
 
@@ -191,6 +192,7 @@
 	FilesystemFactory *getFilesystemFactory();
 
 	void rebuildOffscreenGameBuffer(void);
+	void rebuildOffscreenMouseBuffer(void);
 	void switchGraphicModeId(int mode);
 
 	void setupMixer(void);

Modified: scummvm/trunk/backends/platform/n64/osys_n64_base.cpp
===================================================================
--- scummvm/trunk/backends/platform/n64/osys_n64_base.cpp	2010-01-11 11:34:43 UTC (rev 47248)
+++ scummvm/trunk/backends/platform/n64/osys_n64_base.cpp	2010-01-11 11:37:11 UTC (rev 47249)
@@ -90,6 +90,7 @@
 	_overlayBuffer = (uint16*)memalign(8, _overlayWidth * _overlayHeight * sizeof(OverlayColor));
 
 	_cursor_pal = NULL;
+	_cursor_hic = NULL;
 
 	_cursorWidth = -1;
 	_cursorHeight = -1;
@@ -346,6 +347,9 @@
 		colors += 4;
 	}
 
+	if (_cursorPaletteDisabled)
+		rebuildOffscreenMouseBuffer();
+
 	_dirtyPalette = true;
 	_dirtyOffscreen = true;
 }
@@ -372,6 +376,17 @@
 		}
 }
 
+void OSystem_N64::rebuildOffscreenMouseBuffer(void) {
+	uint16 width, height;
+	uint16 *_pal_src = _cursorPaletteDisabled ? _screenPalette : _cursorPalette;
+
+	for (height = 0; height < _cursorHeight; height++) {
+		for (width = 0; width < _cursorWidth; width++) {
+			_cursor_hic[(_cursorWidth * height) + width] = _pal_src[_cursor_pal[(_cursorWidth * height) + width]];
+		}
+	}
+}
+
 void OSystem_N64::grabPalette(byte *colors, uint start, uint num) {
 	uint32 i;
 	uint16 color;
@@ -396,12 +411,17 @@
 	}
 
 	_cursorPaletteDisabled = false;
+
+	rebuildOffscreenMouseBuffer();
+
 	_dirtyOffscreen = true;
 }
 
 void OSystem_N64::disableCursorPalette(bool disable) {
 	_cursorPaletteDisabled = disable;
 
+	rebuildOffscreenMouseBuffer();
+
 	_dirtyOffscreen = true;
 }
 
@@ -533,22 +553,24 @@
 		int mX = _mouseX - _mouseHotspotX;
 		int mY = _mouseY - _mouseHotspotY;
 
-		uint16 *_cursorSource = _cursorPaletteDisabled ? _screenPalette : _cursorPalette;
 		for (int h = 0; h < _cursorHeight; h++)
 			for (int w = 0; w < _cursorWidth; w++) {
-				uint8 index = _cursor_pal[(h * _cursorWidth) + w];
+				// Draw pixel
+				if (((mY + h) >= 0) && ((mY + h) < _mouseMaxY) && ((mX + w) >= 0) && ((mX + w) < _mouseMaxX)) {
+					uint16 cursor_pixel_hic = _cursor_hic[(h * _cursorWidth) + w];
+					uint8 cursor_pixel_pal = _cursor_pal[(h * _cursorWidth) + w];
 
-				// Draw pixel
-				if ((index != _cursorKeycolor) && ((mY + h) >= 0) && ((mY + h) < _mouseMaxY) && ((mX + w) >= 0) && ((mX + w) < _mouseMaxX))
-					mouse_framebuffer[((mY + h) * _frameBufferWidth) + ((mX + w) + _offscrPixels + horiz_pix_skip)] = _cursorSource[index];
+					if (cursor_pixel_pal != _cursorKeycolor)
+						mouse_framebuffer[((mY + h) * _frameBufferWidth) + ((mX + w) + _offscrPixels + horiz_pix_skip)] = cursor_pixel_hic;
+				}
 			}
 	}
 
-#ifndef _ENABLE_DEBUG_
-	showDisplay(_dc);
-#else
+//#ifndef _ENABLE_DEBUG_
+//	showDisplay(_dc);
+//#else
 	showDisplayAndText(_dc);
-#endif
+//#endif
 
 	_dc = NULL;
 	_dirtyOffscreen = false;
@@ -723,11 +745,14 @@
 
 	if (_cursor_pal && ((w != _cursorWidth) || (h != _cursorHeight))) {
 		free(_cursor_pal);
+		free(_cursor_hic);
 		_cursor_pal = NULL;
+		_cursor_hic = NULL;
 	}
 
 	if (!_cursor_pal) {
 		_cursor_pal = (uint8*)malloc(w * h);
+		_cursor_hic = (uint16*)malloc(w * h * sizeof(uint16));
 	}
 
 	_cursorWidth = w;
@@ -737,6 +762,8 @@
 
 	_cursorKeycolor = keycolor & 0xFF;
 
+	rebuildOffscreenMouseBuffer();
+
 	_dirtyOffscreen = true;
 
 	return;


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