Only in scummvmdx-0.1.0b: Makefile
Only in scummvmdx-0.1.0b: Release
Only in scummvmdx-0.1.0b: _windows.cpp
Only in scummvmdx-0.1.0b: actor.cpp
Only in scummvmdx-0.1.0b: akos.cpp
Only in scummvmdx-0.1.0b: boxes.cpp
Only in scummvmdx-0.1.0b: copying.txt
Only in scummvmdx-0.1.0b: costume.cpp
Only in scummvmdx-0.1.0b: debug.cpp
Only in scummvmdx-0.1.0b: debugrl.cpp
Only in scummvmdx-0.1.0b: debugrl.h
Only in scummvmdx-0.1.0b: gfx.cpp
Only in scummvmdx-0.1.0b: gui.cpp
Only in scummvmdx-0.1.0b: gui.h
Only in scummvmdx-0.1.0b: object.cpp
Only in scummvmdx-0.1.0b: readme.txt
Only in scummvmdx-0.1.0b: resource.cpp
Only in scummvmdx-0.1.0b: saveload.cpp
Only in scummvmdx-0.1.0b: script.cpp
Only in scummvmdx-0.1.0b: script_v1.cpp
Only in scummvmdx-0.1.0b: script_v2.cpp
Only in scummvmdx-0.1.0b: scumm.h
Only in scummvmdx-0.1.0b: scummsys.h
Only in scummvmdx-0.1.0b: scummvm.cpp
Only in scummvmdx-0.1.0b: scummvm.dsp
Only in scummvmdx-0.1.0b: scummvm.dsw
Only in scummvmdx-0.1.0b: scummvm.ncb
Only in scummvmdx-0.1.0b: scummvm.opt
Only in scummvmdx-0.1.0b: sdl.cpp
Only in scummvmdx-0.1.0b: sound
Only in scummvmdx-0.1.0b: sound.cpp
Only in scummvmdx-0.1.0b: sound.h
Only in scummvmdx-0.1.0b: stdafx.cpp
diff -u scummvm-0.1.0b/stdafx.h scummvmdx-0.1.0b/stdafx.h
--- scummvm-0.1.0b/stdafx.h	Tue Nov 20 07:13:02 2001
+++ scummvmdx-0.1.0b/stdafx.h	Wed Feb 13 20:12:14 2002
@@ -44,8 +44,8 @@
 #define NOCTLMGR
 #define NOCLIPBOARD
 #define NOMEMMGR
-#define NOSYSMETRICS
-#define NOMENUS
+//#define NOSYSMETRICS // DIRECTX
+//#define NOMENUS // DIRECTX
 #define NOOPENFILE
 #define NOWH
 #define NOSOUND
@@ -53,6 +53,7 @@
 
 #include <SDL.h>
 #include <windows.h>
+#include <windowsx.h> // DIRECTX
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
Only in scummvmdx-0.1.0b: string.cpp
Only in scummvmdx-0.1.0b: sys.cpp
Only in scummvmdx-0.1.0b: verbs.cpp
Only in scummvmdx-0.1.0b: whatsnew.txt
diff -u scummvm-0.1.0b/windows.cpp scummvmdx-0.1.0b/windows.cpp
--- scummvm-0.1.0b/windows.cpp	Fri Dec 28 15:26:28 2001
+++ scummvmdx-0.1.0b/windows.cpp	Fri Feb 15 01:24:30 2002
@@ -18,6 +18,13 @@
  * $Header: /cvsroot/scummvm/scummvm/windows.cpp,v 1.24 2001/12/28 15:26:28 strigeus Exp $
  */
 
+/*
+   (Very ugly) DirectX additions by Gregory Montoir (cyx@frenchkiss.net)
+   2002.02.12 - started
+   2002.02.13 - corrected screen bounds, play screen is now completely displayed
+   2002.02.15 - added mouse cursor
+ */
+
 #include "stdafx.h"
 #include <assert.h>
 
@@ -36,15 +43,19 @@
 #define DEST_WIDTH 320
 #define DEST_HEIGHT 200
 
-#define USE_DIRECTX 0
+#define USE_DIRECTX 1
 #define USE_DRAWDIB 0
-#define USE_GDI 1
+#define USE_GDI 0
+
+#if USE_DIRECTX
+#include <ddraw.h>
+#endif
 
 #define SAMPLES_PER_SEC 22050
 #define BUFFER_SIZE (8192)
 #define BITS_PER_SAMPLE 16
 
-static bool shutdown;
+//static bool shutdown;
 
 
 #if USE_GDI
@@ -63,6 +74,12 @@
 
 	bool terminated;	
 
+#if USE_DIRECTX
+	LPDIRECTDRAW lpdd;
+	LPDIRECTDRAWSURFACE lpddsPrimary;
+	LPDIRECTDRAWSURFACE lpddsSecondary;
+#endif
+
 #if USE_GDI
 public:
 	DIB dib;
@@ -94,6 +111,15 @@
 #if USE_GDI
 	bool allocateDIB(int w, int h);
 #endif
+
+#if USE_DIRECTX
+	byte _realbuf[SRC_WIDTH*SRC_HEIGHT];
+	BOOL ddrawInit();
+	void ddrawReleaseSurfaces();
+	void ddrawRestoreSurfaces();
+	void ddrawRelease();
+	void ddrawUpdateBuffer();
+#endif
 };
 
 void Error(const char *msg) {
@@ -164,8 +190,15 @@
 			break;
 
 		case WM_MOUSEMOVE:
+#if USE_DIRECTX
+			RECT r;
+			GetClientRect(hWnd, &r);
+			wm->_scumm->mouse.x = (SRC_WIDTH * GET_X_LPARAM(lParam)) / (r.right - r.left);
+			wm->_scumm->mouse.y = (SRC_HEIGHT * GET_Y_LPARAM(lParam)) / (r.bottom - r.top);
+#else
 			wm->_scumm->mouse.x = ((int16*)&lParam)[0];
 			wm->_scumm->mouse.y = ((int16*)&lParam)[1];
+#endif
 			break;
 		case WM_LBUTTONDOWN:
 			wm->_scumm->_leftBtnPressed |= msClicked|msDown;
@@ -303,8 +336,179 @@
 	ShowWindow(hWnd, SW_SHOW);
 #endif
 
+
+#if USE_DIRECTX
+
+  HWND hwnd;
+  globWnd = hwnd = CreateWindow("ScummVM", "ScummVM",
+					  WS_POPUP|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX|WS_SIZEBOX,
+					  0, 0, 0, 0,  NULL, NULL, hInst, NULL);
+  SetWindowLong(hwnd, GWL_USERDATA, (long)this);
+
+  RECT r;
+  SetRect(&r, 0, 0, SRC_WIDTH, SRC_HEIGHT);
+  AdjustWindowRectEx(&r, GetWindowStyle(hwnd), GetMenu(hwnd) != NULL, GetWindowExStyle(hwnd));
+  MoveWindow(hwnd,
+			 (GetSystemMetrics(SM_CXSCREEN) - SRC_WIDTH) / 2, 
+             (GetSystemMetrics(SM_CYSCREEN) - SRC_HEIGHT) / 2, 
+             r.right - r.left, r.bottom - r.top, FALSE);
+  if(!ddrawInit())
+	Error("DirectDraw init failed!");
+  ShowWindow(hwnd, SW_SHOW);
+
+#endif
+
+}
+
+
+#ifdef USE_DIRECTX
+
+static unsigned char GetLowestBit(unsigned long p)
+{
+  unsigned char pos = 0;
+  while((p & 1) == 0) {
+	++pos;
+	p >>= 1;
+  }
+  return pos;
+}
+
+
+void WndMan::ddrawUpdateBuffer()
+{
+  DDSURFACEDESC ddsd;
+  memset(&ddsd, '\0', sizeof(ddsd));
+  ddsd.dwSize = sizeof(ddsd);
+
+  HRESULT hr;
+  hr = lpddsSecondary->Lock(NULL, &ddsd, DDLOCK_WAIT|DDLOCK_WRITEONLY|DDLOCK_SURFACEMEMORYPTR, NULL);
+  if(hr == DDERR_SURFACELOST)
+	ddrawRestoreSurfaces();
+  else if(hr == DD_OK) {
+	_scumm->drawMouse();
+	byte *p = _vgabuf ? _vgabuf : _realbuf;
+
+	DDPIXELFORMAT ddpf = ddsd.ddpfPixelFormat;
+	int Rshift = GetLowestBit(ddpf.dwRBitMask);
+	int Gshift = GetLowestBit(ddpf.dwGBitMask);
+	int Bshift = GetLowestBit(ddpf.dwBBitMask);
+
+	BYTE *dst = (BYTE*)ddsd.lpSurface;
+
+	int size = ddsd.dwHeight * ddsd.dwWidth;
+	int i = 0;
+	while(i < size) { 
+	  BYTE r = _scumm->_currentPalette[p[i]*3];
+	  BYTE g = _scumm->_currentPalette[p[i]*3+1];
+	  BYTE b = _scumm->_currentPalette[p[i]*3+2];
+
+	  DWORD pixel = (r << Rshift) | (g << Gshift) | (b << Bshift);
+
+	  switch(ddpf.dwRGBBitCount) {
+	  case 32:
+		*((DWORD*)dst) = pixel;
+	    break;
+	  case 24:
+	    dst[0] = (BYTE)((pixel & 0xFF0000) >> 16);
+	    dst[1] = (BYTE)((pixel & 0x00FF00) >> 8);
+	    dst[2] = (BYTE)((pixel & 0x0000FF));
+	    break;
+	  case 16:
+		*((WORD*)dst) = (WORD)pixel;
+	    break;
+	  }
+	  dst += ddpf.dwRGBBitCount >> 3;
+	  i++;
+	}
+    lpddsSecondary->Unlock(NULL);
+  }
+}
+
+
+void WndMan::writeToScreen()
+{
+  ddrawUpdateBuffer();
+  RECT r;
+  GetClientRect(globWnd, &r);
+  POINT p;
+  p.x = r.left;
+  p.y = r.top;
+  ClientToScreen(globWnd, &p);
+  r.left   = p.x;
+  r.top    = p.y;
+  r.right  += r.left;
+  r.bottom += r.top;
+  HRESULT hr = lpddsPrimary->Blt(&r, lpddsSecondary, NULL, DDBLT_WAIT, NULL);
+  if(hr == DDERR_SURFACELOST)
+	ddrawRestoreSurfaces();
+}
+
+
+BOOL WndMan::ddrawInit()
+{
+  DDSURFACEDESC ddsd;
+  LPDIRECTDRAWCLIPPER lpddc;
+
+  if(DirectDrawCreate(NULL, &lpdd, NULL) != DD_OK)
+	return FALSE;
+
+  if(lpdd->SetCooperativeLevel(globWnd, DDSCL_NORMAL) != DD_OK)
+	return FALSE;
+  
+  memset(&ddsd, '\0', sizeof(ddsd));
+  ddsd.dwSize = sizeof(ddsd);
+  ddsd.dwFlags = DDSD_CAPS;
+  ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE|DDSCAPS_VIDEOMEMORY;
+  if(lpdd->CreateSurface(&ddsd, &lpddsPrimary, NULL) != DD_OK)
+	return FALSE;
+
+  if(lpdd->CreateClipper(0, &lpddc, NULL) != DD_OK)
+	return FALSE;
+  if(lpddc->SetHWnd(0, globWnd) != DD_OK)
+	return FALSE;
+  if(lpddsPrimary->SetClipper(lpddc) != DD_OK)
+	return FALSE;
+  lpddc->Release();
+
+  memset(&ddsd, '\0', sizeof(ddsd));
+  ddsd.dwSize = sizeof(ddsd);
+  ddsd.dwFlags = DDSD_CAPS|DDSD_WIDTH|DDSD_HEIGHT;
+  ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
+  ddsd.dwWidth = SRC_WIDTH;
+  ddsd.dwHeight = SRC_HEIGHT;
+  if(lpdd->CreateSurface(&ddsd, &lpddsSecondary, NULL) != DD_OK)
+	return FALSE;
+
+  memset(_realbuf, '\0', sizeof(_realbuf));
+  return TRUE;
+}
+
+
+void WndMan::ddrawReleaseSurfaces()
+{
+  if(lpddsPrimary != NULL) lpddsPrimary->Release();
+  if(lpddsSecondary != NULL) lpddsSecondary->Release();
+}
+
+
+void WndMan::ddrawRestoreSurfaces()
+{
+  if(lpddsPrimary->IsLost() == DDERR_SURFACELOST)
+	lpddsPrimary->Restore();
+  if(lpddsSecondary->IsLost() == DDERR_SURFACELOST)
+	lpddsSecondary->Restore();
+}
+
+
+void WndMan::ddrawRelease()
+{
+  ddrawReleaseSurfaces();
+  if(lpdd != NULL) lpdd->Release();
 }
 
+#endif
+
+
 
 bool WndMan::handleMessage() {
 	MSG msg;
@@ -365,7 +569,12 @@
 void outputlittlemask(byte *mask, int w, int h) {
 	byte *old = wm->_vgabuf;
 	wm->_vgabuf = NULL;
+#if !USE_DIRECTX
 	decompressMask(wm->dib.buf, mask, w, h);
+#else
+	memset(wm->_realbuf, '\0', sizeof(wm->_realbuf));
+	decompressMask(wm->_realbuf, mask, w, h);
+#endif
 	wm->writeToScreen();	
 	wm->_vgabuf = old;
 }
@@ -388,19 +597,39 @@
 		break;
 	case 2:
 		wm->_vgabuf = NULL;
+#if !USE_DIRECTX
 		decompressMask(wm->dib.buf, s->getResourceAddress(rtBuffer, 9)+s->_screenStartStrip);
+#else
+		memset(wm->_realbuf, '\0', sizeof(wm->_realbuf));
+		decompressMask(wm->_realbuf, s->getResourceAddress(rtBuffer, 9)+s->_screenStartStrip);
+#endif
 		break;
 	case 3:
 		wm->_vgabuf = NULL;
+#if !USE_DIRECTX
 		decompressMask(wm->dib.buf, s->getResourceAddress(rtBuffer, 9)+8160+s->_screenStartStrip);
+#else
+		memset(wm->_realbuf, '\0', sizeof(wm->_realbuf));
+		decompressMask(wm->_realbuf, s->getResourceAddress(rtBuffer, 9)+8160+s->_screenStartStrip);
+#endif
 		break;
 	case 4:
 		wm->_vgabuf = NULL;
+#if !USE_DIRECTX
 		decompressMask(wm->dib.buf, s->getResourceAddress(rtBuffer, 9)+8160*2+s->_screenStartStrip);
+#else
+		memset(wm->_realbuf, '\0', sizeof(wm->_realbuf));
+		decompressMask(wm->_realbuf, s->getResourceAddress(rtBuffer, 9)+8160*2+s->_screenStartStrip);
+#endif
 		break;
 	case 5:
 		wm->_vgabuf = NULL;
+#if !USE_DIRECTX
 		decompressMask(wm->dib.buf, s->getResourceAddress(rtBuffer, 9)+8160*3+s->_screenStartStrip);
+#else
+		memset(wm->_realbuf, '\0', sizeof(wm->_realbuf));
+		decompressMask(wm->_realbuf, s->getResourceAddress(rtBuffer, 9)+8160*2+s->_screenStartStrip);
+#endif
 		break;
 	}
 	wm->writeToScreen();	
@@ -409,9 +638,8 @@
 
 void blitToScreen(Scumm *s, byte *src,int x, int y, int w, int h) {
 	byte *dst;
-	SDL_Rect *r;
+//	SDL_Rect *r;
 	int i;
-
 	dst = (byte*)wm->_vgabuf + y*320 + x;
 
 	do {
@@ -429,7 +657,9 @@
 
 void updateScreen(Scumm *s) {
 	if (s->_palDirtyMax != -1) {
-		wm->setPalette(s->_currentPalette, 0, 256);	
+#if !USE_DIRECTX
+	  wm->setPalette(s->_currentPalette, 0, 256);	
+#endif
 		s->_palDirtyMax = -1;
 	}
 
@@ -455,6 +685,39 @@
 }
 
 void drawMouse(Scumm *s, int x, int y, int w, int h, byte *buf, bool visible) {
+#ifdef USE_DIRECTX
+  static struct {
+	int offset;
+	int color;
+  } old_mouse[4000];
+  static int nb = 0;
+
+  if(wm->_vgabuf) {
+	if(visible) {
+	  /* clear previous mouse cursor positions */
+	  int i, j;
+
+	  for(i = 0; i < nb; ++i)
+		wm->_vgabuf[old_mouse[i].offset] = old_mouse[i].color;
+	  nb = 0;
+
+	  for(j = 0; j < h && y + j < SRC_HEIGHT && y + j >= 0; ++j, buf+=w) {
+		for(i = 0; i < w && x + i < SRC_WIDTH && x + i >= 0; ++i) {
+		  byte color = buf[i];
+		  if(color != 0xFF) {
+			int off = (y + j) * SRC_WIDTH + (x + i);;
+			if(nb < 4000) {
+			  old_mouse[nb].offset = off;
+			  old_mouse[nb].color  = wm->_vgabuf[off];
+			  wm->_vgabuf[off] = color;
+			  ++nb;
+			}
+		  }
+		}
+	  }
+	}
+  }
+#endif
 }
 
 void fill_buffer(int16 *buf, int len) {
