Fast Pixels

Started by
13 comments, last by Blackstream 23 years, 5 months ago

Here''s some code that may speed up your application (this assumes you have MMX on your CPU)

    void DrawMMX( DDSURFACEDESC *dest, BYTE *src, RECT &area, int bpp ){	int w=(area.right-area.left)*bpp/8;	int h=area.bottom-area.top;	char *sptr=(char*)src;	char *dptr=(char*)(unsigned char*)((unsigned char*)dest->lpSurface);	DWORD adddpos=dest->lPitch-w*8;	DWORD addspos=bpp*(area.right-area.left)-w*8;	__asm	{		mov edx,h		mov esi,sptr		mov edi,dptr		NextLine:		mov ecx,w		NextPixels:		movq mm0,[esi]		movq [edi],mm0		add esi,8		add edi,8		dec ecx		jnz NextPixels		add edi,adddpos		add esi,addspos		dec edx		jnz NextLine		emms	}}////// EXAMPLE of use:////		if ( g_bMMX_Enabled )		{			DDSURFACEDESC	ddsd;			ddsd.dwSize = sizeof(ddsd);			if ( DD_OK != g_pDDSPrimary->Lock(NULL, &ddsd, DDLOCK_WAIT, NULL))			{				return FALSE;			}			RECT rc={0,0,CSDScreen::GetWidth(), CSDScreen::GetHeight()};			DrawMMX( &ddsd, CSDScreen::GetDib()->GetBits(), rc, 3 );			g_pDDSPrimary->Unlock( NULL );		}    


Advertisement
For your information, Doom and Doom2 used ModeX.

Also the speed increase from 640x400x8 to 320x200x8 is due the fact you are filling 4 times less pixels (45x4 = 180fps - overhead for copying = 160fps).

Nice trick Neocron - got any more of that?


Stay Lucky, Graham "Mournblade" Reeds.
http://homepage.dtn.ntl.com/grahamr
Stay Lucky, Graham "Mournblade" Reeds.The Ivory Tower
I thought that Doom and DoomII were not really true 3D. Didn''t it use a type of ray casting engine? Maybe I am just confusing myself!



"If at first you DO succeed...try not to look astonished!!"

BASSOFeeSH@aol.com
><>
-- What would Sweetness do?
you are right, DOOM and DOOM2 are not real 3d games.....
They were not true 3D as such, no, as in the walls were in fact lines. It used BSP based on lines, rather than based on planes like Quake, which is true 3D. However, the Display was 3D, even though the levels and monsters weren''t.


Please state the nature of the debugging emergency.


sharewaregames.20m.com

This topic is closed to new replies.

Advertisement