Release 941210

Wed Dec  7 14:52:25 1994  Alexandre Julliard  (julliard@lamisun.epfl.ch)

	* [controls/listbox.c]
	Fixed problems due to new scroll-bar code.

	* [loader/signal.c] [miscemu/ioports.c]
	Handle I/O opcodes that use an absolute address.

	* [objects/text.c]
	Implemented TabbedTextOut().

Sat Dec  3 18:53:08 1994  Kenneth MacDonald  <K.MacDonald@ed.ac.uk>

	* [objects/metafile.c]
	Implemented GetMetafile().
	Fixed bug in PlayMetaFile() when reading disc based metafile records.
	Added META_POLYPOLYGON, META_DELETEOBJECT and META_EOF to 
	PlayMetaFileRecord().
	
Wed Nov 30 06:32:25 1994  Martin von Loewis  (martin@cs.csufresno.edu)

	* [Imakefile]
	wine.sym: Remove gcc2_compiled and friends

	* [controls/listbox.c][if1632/relay.c][if1632/relay.c]
	  [loader/resource.c][memory/heap.c][objects/dib.c][windows/dialog.c]
	Replace #ifdef DEBUG_XXX with if(debugging_xxx){

	* [if1632/call.S]
	CallToLibMain: New function

	* [if1632/relay.c][include/options.h][misc/main.c]
	  [miscemu/int1a.c][miscemu/int21.c][miscemu/kernel.c]
	removed Options.relay_debug

	* [include/heap.h]
	HEAP_OWNER: Use ds instead of cs:ip

	* [loader/ne_image.c]
	LoadNEImage: Remember current exe, handle nodata dlls
	InitNEDLL: handle nodata dlls, call CallToLibMain

	* [loader/selector.c]
	CreateSelectors: Initialize auto_data_sel with 0

	* [memory/heap.c]
	HEAP_CheckHeap: Check prev
	HEAP_CheckLocalHeaps: new function

	* [misc/profile]
	Remember and dump only changed profiles

	* [tools/makedebug]
	Introduce debugging_xxx flags

Sun Nov 27 23:13:22 MET 1994	<erik@xs4all.nl>

	* [clipboard.h color.h dc.h dos_fs.h event.h font.h graphics.h
	if1632.h kernel.h library.h miscemu.h ne_image.h nonclient.h 
	pe_image.h selectors.h wintypes.h]
	Added.

	* [*/*]
	- Commented all 'static char copyright statements', see misc/main.c
	- moved prototypes to headers files, fixed wrong prototypes.
	- *please* add a header file for each .c if you need to export
	  things.

	* [misc/main.c]
	Added one static string which list the names of the contributors.

Fri Nov 25 16:24:27 MET 1994		  Dag Asheim (dash@ifi.uio.no)

	* [Configure]
	Made the support for multiple languages more automatic.  Added
	a [fonts] section to the wine.conf file.  Made the defaults
	better.  Generally cleaned it up.

	* [rc/sysres_No.rc] [rc/sysres_De.rc] [rc/sysres.c]
	Norwegian resources and small fixes to the german resources.

Wed Nov 23 20:28:59 1994  Martin von Loewis  (martin@cs.csufresno.edu)

	* [debugger/break.c]
	bark(), toggle_next(), should_continue(): New functions
	insert_break(): Fixed, adds write access to page before writing
	wine_bp.next_addr: new structure field

	* [debugger/dbg.y]
	Changed symbol's value to be it's value instead of the value
	pointed to by the symbol.
	Changed SIGTRAP handling to allow continuation after break point

	* [misc/shell.c]
	ShellAbout(): Load resource from memory
diff --git a/ChangeLog b/ChangeLog
index f9dc5d2..b5b9a04 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,101 @@
 ----------------------------------------------------------------------
+Wed Dec  7 14:52:25 1994  Alexandre Julliard  (julliard@lamisun.epfl.ch)
+
+	* [controls/listbox.c]
+	Fixed problems due to new scroll-bar code.
+
+	* [loader/signal.c] [miscemu/ioports.c]
+	Handle I/O opcodes that use an absolute address.
+
+	* [objects/text.c]
+	Implemented TabbedTextOut().
+
+Sat Dec  3 18:53:08 1994  Kenneth MacDonald  <K.MacDonald@ed.ac.uk>
+
+	* [objects/metafile.c]
+	Implemented GetMetafile().
+	Fixed bug in PlayMetaFile() when reading disc based metafile records.
+	Added META_POLYPOLYGON, META_DELETEOBJECT and META_EOF to 
+	PlayMetaFileRecord().
+	
+Wed Nov 30 06:32:25 1994  Martin von Loewis  (martin@cs.csufresno.edu)
+
+	* [Imakefile]
+	wine.sym: Remove gcc2_compiled and friends
+
+	* [controls/listbox.c][if1632/relay.c][if1632/relay.c]
+	  [loader/resource.c][memory/heap.c][objects/dib.c][windows/dialog.c]
+	Replace #ifdef DEBUG_XXX with if(debugging_xxx){
+
+	* [if1632/call.S]
+	CallToLibMain: New function
+
+	* [if1632/relay.c][include/options.h][misc/main.c]
+	  [miscemu/int1a.c][miscemu/int21.c][miscemu/kernel.c]
+	removed Options.relay_debug
+
+	* [include/heap.h]
+	HEAP_OWNER: Use ds instead of cs:ip
+
+	* [loader/ne_image.c]
+	LoadNEImage: Remember current exe, handle nodata dlls
+	InitNEDLL: handle nodata dlls, call CallToLibMain
+
+	* [loader/selector.c]
+	CreateSelectors: Initialize auto_data_sel with 0
+
+	* [memory/heap.c]
+	HEAP_CheckHeap: Check prev
+	HEAP_CheckLocalHeaps: new function
+
+	* [misc/profile]
+	Remember and dump only changed profiles
+
+	* [tools/makedebug]
+	Introduce debugging_xxx flags
+
+Sun Nov 27 23:13:22 MET 1994	<erik@xs4all.nl>
+
+	* [clipboard.h color.h dc.h dos_fs.h event.h font.h graphics.h
+	if1632.h kernel.h library.h miscemu.h ne_image.h nonclient.h 
+	pe_image.h selectors.h wintypes.h]
+	Added.
+
+	* [*/*]
+	- Commented all 'static char copyright statements', see misc/main.c
+	- moved prototypes to headers files, fixed wrong prototypes.
+	- *please* add a header file for each .c if you need to export
+	  things.
+
+	* [misc/main.c]
+	Added one static string which list the names of the contributors.
+
+Fri Nov 25 16:24:27 MET 1994		  Dag Asheim (dash@ifi.uio.no)
+
+	* [Configure]
+	Made the support for multiple languages more automatic.  Added
+	a [fonts] section to the wine.conf file.  Made the defaults
+	better.  Generally cleaned it up.
+
+	* [rc/sysres_No.rc] [rc/sysres_De.rc] [rc/sysres.c]
+	Norwegian resources and small fixes to the german resources.
+
+Wed Nov 23 20:28:59 1994  Martin von Loewis  (martin@cs.csufresno.edu)
+
+	* [debugger/break.c]
+	bark(), toggle_next(), should_continue(): New functions
+	insert_break(): Fixed, adds write access to page before writing
+	wine_bp.next_addr: new structure field
+
+	* [debugger/dbg.y]
+	Changed symbol's value to be it's value instead of the value
+	pointed to by the symbol.
+	Changed SIGTRAP handling to allow continuation after break point
+
+	* [misc/shell.c]
+	ShellAbout(): Load resource from memory
+
+----------------------------------------------------------------------
 Sun Nov 20 18:30:06 1994  Alexandre Julliard  (julliard@lamisun.epfl.ch)
 
 	* [controls/scroll.c] [include/scroll.h]
diff --git a/Configure b/Configure
index d402582..d95d508 100644
--- a/Configure
+++ b/Configure
@@ -5,9 +5,14 @@
 : ${EDITOR:=vi}
 : ${PAGER:=more}
 
+WINELIB=''
+SHORTNAMES=''
+XPM=''
+LANG=not_matching
+NEWBUILD=''
 ALLDEFINES=''
 
-# Ask question 'str' and sets 'var' reply (defaulting to 'def' on CR)
+# Ask question 'str' and set 'var' to reply (defaulting to 'def' on CR)
 prompt ()
 {
 	str="$1"
@@ -30,29 +35,6 @@
 then
 	WINELIB='#define WINELIB -DWINELIB'
 	ALLDEFINES="$ALLDEFINES -DWINELIB"
-else
-	WINELIB=''
-
-#	Commented out until the processor emulator starts to work.
-#
-#	echo
-#	echo -n 'Use processor emulator (*DOES*NOT*WORK*YET*) (Y/N) [N]? '
-#	read input
-#	if [ "$input" = 'y' -o "$input" = 'Y' ]
-#	then
-#		PROCEMU='#define PROCEMU'
-#		ALLDEFINES="$ALLDEFINES -DPROCEMU"
-#		echo
-#		echo -n 'bochs directory [/usr/src/bochs]? '
-#		read input
-#		if [ "$input" = '' ]
-#		then
-#			ALLDEFINES="$ALLDEFINES -DPROC_EMU_DIR=/usr/src/bochs"
-#		else
-#			ALLDEFINES="$ALLDEFINES -DPROC_EMU_DIR="$input
-#		fi
-#	fi
-
 fi
 
 echo
@@ -62,8 +44,6 @@
 then
 	SHORTNAMES='#define ShortNames -DSHORTNAMES'
 	ALLDEFINES="$ALLDEFINES -DSHORTNAMES"
-else
-	SHORTNAMES=''
 fi
 
 echo
@@ -73,14 +53,33 @@
 then
 	XPM='#define USE_XPM'
 	ALLDEFINES="$ALLDEFINES -DUSE_XPM"
-else
-	XPM=''
+fi
+
+LANGS=`echo En rc/sysres_*.rc | sed -e 's/rc\/sysres_//g' -e 's/\.rc//g' -e 's/ /\//g;'`
+while	expr "$LANGS" : ".*$LANG" == 0 > /dev/null
+do
+	prompt "Language ($LANGS)" LANG En
+	if	expr "$LANGS" : ".*$LANG" == 0 > /dev/null
+	then
+		echo "\"$LANG\" is not a supported language."
+	fi
+done
+ALLDEFINES="$ALLDEFINES -ALANG\($LANG\)"
+
+if [ "`(domainname)`" = 'amscons.com' ]
+then
+	echo
+	echo -n 'New build program (Y/N) [N]? '
+	read input
+	if [ "$input" = 'y' -o "$input" = 'Y' ]
+	then
+		NEWBUILD='#define NewBuild -DNEWBUILD'
+		ALLDEFINES="$ALLDEFINES -DNEWBUILD"
+	fi
 fi
 
 prompt "Global configfile name" WINE_CONFIGFILE /usr/local/etc/wine.conf
 
-WINE_INI_GLOBAL='#define WINE_INI_GLOBAL "'$WINE_CONFIGFILE'"'
-
 if [ -r $WINE_CONFIGFILE ]
 then
 	DEFAULT_ANS=N
@@ -108,18 +107,22 @@
 		fi
 	fi
 
-	case `awk 'BEGIN {s=0} {if ($3=="msdos") s++} END {print s}' /etc/fstab` in
-	0)	CF_C=/c;;
-	1)	CF_C=`awk '{if ($3=="msdos") print $2}' /etc/fstab`;;
-	*)	CF_C=`awk '{if ($3=="msdos") {print $2;exit}}' /etc/fstab`;;
-	esac
-
-	prompt "Which directory do you want to use as A:" CF_A /a
+	CF_A=`mount | awk '/^\/dev\/fd/ {print $3;exit} END {print "/a"}'`
+	prompt "Which directory do you want to use as A:" CF_A $CF_A
+	CF_C=`awk '{if ($3=="msdos") {print $2;exit}} END {print "/c"}' /etc/fstab`
 	prompt "Which directory do you want to use as C:" CF_C $CF_C
 	prompt "Where is the Windows directory" CF_Windows 'c:\windows'
 	prompt "Where is the System directory" CF_System 'c:\windows\system'
-	prompt "Where should Windows apps store temp files" CF_Temp 'c:\temp'
-	prompt "Which path should be used to find executables and DLL's" CF_Path 'c:\windows;c:\windows\system'
+	if [ -r "$CF_C/autoexec.bat" ]
+	then
+		CF_Temp=`tr A-Z a-z < "$CF_C/autoexec.batX" | sed -n 's/^ *set *temp= *\(c:.*[a-z]\).*/\1/p'`
+	fi
+	if [ -z "$CF_Temp" ]
+	then
+		CF_Temp='c:\temp'
+	fi
+	prompt "Where should Windows apps store temp files" CF_Temp $CF_Temp
+	prompt "Which path should be used to find progs/DLL's" CF_Path "$CF_Windows;$CF_System"
 	prompt "Where is sysres.dll" CF_SystemResources `pwd`/sysres.dll
 	prompt "Where is COM1" CF_Com1 '/dev/cua0'
 	prompt "Where is COM2" CF_Com2 '/dev/cua1'
@@ -135,9 +138,7 @@
 
 	prompt "Exclude which messages from the log" CF_Exclude 'WM_SIZE;WM_TIMER'
 
-	echo
-	echo "The config file $WINE_CONFIGFILE now looks like this:"
-	tee $WINE_CONFIGFILE << EOF
+	cat >  $WINE_CONFIGFILE << EOF
 [drives]
 A=$CF_A
 C=$CF_C
@@ -149,6 +150,16 @@
 Path=$CF_Path
 SystemResources=$CF_SystemResources
 
+[fonts]
+system=*-helvetica
+mssansserif=*-helvetica
+msserif=*-times
+fixedsys=*-fixed
+arial=*-helvetica
+helv=*-helvetica
+roman=*-times
+default=*-*
+
 [serialports]
 Com1=$CF_Com1
 Com2=$CF_Com2
@@ -162,6 +173,12 @@
 EOF
 
 	echo
+	sed '1 i\
+The config file '"$WINE_CONFIGFILE"' now looks like this:\
+\
+' < $WINE_CONFIGFILE | $PAGER
+
+	echo
 	echo -n "Do you want to edit it using $EDITOR (Y/N) [N]? "
 	read input
 	if [ "$input" = 'y' -o "$input" = 'Y' ]
@@ -175,23 +192,6 @@
 	fi
 fi
 
-prompt "Language (En/De)" LANG En
-ALLDEFINES="$ALLDEFINES -ALANG\($LANG\)"
-
-NEWBUILD=''
-if [ "`(domainname)`" = 'amscons.com' ]
-then
-    echo
-    echo -n 'New build program (Y/N) [N]? '
-    read input
-    if [ "$input" = 'y' -o "$input" = 'Y' ]
-    then
-	NEWBUILD='#define NewBuild -DNEWBUILD'
-	ALLDEFINES="$ALLDEFINES -DNEWBUILD"
-    fi
-fi
-
-NEWLINUXLDT=''
 if grep -s seg_not_present /usr/include/linux/ldt.h 2> /dev/null
 then
 	ALLDEFINES="$ALLDEFINES -DNEW_LDT_STRUCT"
@@ -203,12 +203,12 @@
 $SHORTNAMES
 $XPM
 $NEWBUILD
-$WINE_INI_GLOBAL
-$ENDIAN
-$PROCEMUDIR
+#define WINE_INI_GLOBAL "$WINE_CONFIGFILE"
 #define AutoDefines $ALLDEFINES
 EOF
 
+echo
+echo "Creating Makefiles.  This may take a while."
 xmkmf -a
 
 if [ 0 -lt `find . -name "*.rej" -print | wc -l` ]
@@ -223,5 +223,8 @@
 
 EOF
 	find . -name "*.rej" -print
-	echo
+	exit 1
 fi
+
+echo
+echo "Configure finished.  Do 'make' to compile Wine."
diff --git a/DEVELOPERS-HINTS b/DEVELOPERS-HINTS
index d95d87d..ecca5a0 100644
--- a/DEVELOPERS-HINTS
+++ b/DEVELOPERS-HINTS
@@ -107,6 +107,19 @@
 #define DEBUG_XXXX or #undefine DEBUG_XXXX between #include<stddebug.h> and
 #include <debug.h> in that specific file. In addition you can change the 
 types of displayed messages by supplying the "-debugmsg" option to Wine. 
+If your debugging code is more complex than just printf, you can use the
+symbols debugging_XXX as well. These are true when XXX is enabled, either
+permanent or in the command line. So instead of writing
+
+#ifdef DEBUG_WIN
+	DumpSomeStructure(&str);
+#endif
+
+write
+	if(debugging_win)DumpSomeStructure(&str);
+Don't worry about the inefficiency of the test. If it is permanently 
+disabled (thus debugging_win is 0 at compile time), the compiler will 
+eliminate the dead code.
 
 The file handle "stddeb" is intended for displaying standard informational
 messages, whereas "stdnimp" is intended for displaying messages concerning
diff --git a/Imakefile b/Imakefile
index c358d67..1f0b13b 100644
--- a/Imakefile
+++ b/Imakefile
@@ -106,7 +106,7 @@
 #endif
 
 wine.sym: wine
-	nm wine|sort >wine.sym
+	nm wine|grep -v _compiled|sort >wine.sym
 
 clean::
 	$(RM) wine.sym
diff --git a/controls/button.c b/controls/button.c
index 2c7fd61..2e4ab5e 100644
--- a/controls/button.c
+++ b/controls/button.c
@@ -3,23 +3,17 @@
  * Copyright (C) 1993 Johannes Ruscheinski
  * Copyright (C) 1993 David Metcalfe
  * Copyright (C) 1994 Alexandre Julliard
- */
 
 static char Copyright1[] = "Copyright Johannes Ruscheinski, 1993";
 static char Copyright2[] = "Copyright David Metcalfe, 1993";
 static char Copyright3[] = "Copyright Alexandre Julliard, 1994";
+*/
 
-#include "button.h"
 #include "win.h"
 #include "user.h"
 #include "syscolor.h"
-
-
-  /* windows/graphics.c */
-extern void GRAPH_DrawReliefRect( HDC hdc, RECT *rect, int highlight_size,
-                                  int shadow_size, BOOL pressed );
-extern BOOL GRAPH_DrawBitmap( HDC hdc, HBITMAP hbitmap, int xdest, int ydest,
-                          int xsrc, int ysrc, int width, int height, int rop );
+#include "graphics.h"
+#include "button.h"
 
 extern void DEFWND_SetText( HWND hwnd, LPSTR text );  /* windows/defwnd.c */
 
diff --git a/controls/combo.c b/controls/combo.c
index ed8f07d..b5c9186 100644
--- a/controls/combo.c
+++ b/controls/combo.c
@@ -3,9 +3,8 @@
  *
  * Copyright  Martin Ayotte, 1993
  *
- */
-
 static char Copyright[] = "Copyright Martin Ayotte, 1993";
+*/
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -20,15 +19,8 @@
 #include "prototypes.h"
 #include "stddebug.h"
 /* #define DEBUG_COMBO */
-/* #undef  DEBUG_COMBO */
 #include "debug.h"
-
-  /* windows/graphics.c */
-extern void GRAPH_DrawReliefRect( HDC hdc, RECT *rect, int highlight_size,
-                                  int shadow_size, BOOL pressed );
-extern BOOL GRAPH_DrawBitmap( HDC hdc, HBITMAP hbitmap, int xdest, int ydest,
-                          int xsrc, int ysrc, int width, int height, int rop );
-
+#include "graphics.h"
 
 HBITMAP hComboBit = 0;
 
diff --git a/controls/desktop.c b/controls/desktop.c
index 53579f1..e075bee 100644
--- a/controls/desktop.c
+++ b/controls/desktop.c
@@ -2,9 +2,9 @@
  * Desktop window class.
  *
  * Copyright 1994 Alexandre Julliard
- */
 
 static char Copyright[] = "Copyright  Alexandre Julliard, 1994";
+*/
 
 #include <fcntl.h>
 #include <stdio.h>
@@ -13,11 +13,8 @@
 #include <unistd.h>
 #include "win.h"
 #include "desktop.h"
-#include "prototypes.h"
-
-extern BOOL GRAPH_DrawBitmap( HDC hdc, HBITMAP hbitmap, int xdest, int ydest,
-			      int xsrc, int ysrc, int width, int height,
-			      int rop );                     /* graphics.c */
+#include "dos_fs.h"
+#include "graphics.h"
 
 /***********************************************************************
  *           DESKTOP_LoadBitmap
@@ -35,7 +32,7 @@
 
       /* Read all the file into memory */
 
-    if (!(unixFileName = GetUnixFileName( filename ))) return 0;
+    if (!(unixFileName = DOS_GetUnixFileName( filename ))) return 0;
     if ((file = open( unixFileName, O_RDONLY )) == -1) return 0;
     size = lseek( file, 0, SEEK_END );
     if (!(buffer = (char *)malloc( size )))
@@ -151,7 +148,7 @@
 /***********************************************************************
  *           SetDeskPattern   (USER.279)
  */
-BOOL SetDeskPattern()
+BOOL SetDeskPattern(void)
 {
     char buffer[100];
     GetProfileString( "desktop", "Pattern", "(None)", buffer, 100 );
diff --git a/controls/edit.c b/controls/edit.c
index b907f49..a04b2b9 100644
--- a/controls/edit.c
+++ b/controls/edit.c
@@ -4,9 +4,9 @@
  * Copyright  David W. Metcalfe, 1994
  *
  * Release 3, July 1994
- */
 
 static char Copyright[] = "Copyright  David W. Metcalfe, 1994";
+*/
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/controls/listbox.c b/controls/listbox.c
index 185142b..86c3940 100644
--- a/controls/listbox.c
+++ b/controls/listbox.c
@@ -3,10 +3,8 @@
  *
  * Copyright  Martin Ayotte, 1993
  *
- */
-
-
 static char Copyright[] = "Copyright Martin Ayotte, 1993";
+*/
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -17,12 +15,9 @@
 #include "heap.h"
 #include "win.h"
 #include "msdos.h"
-#include "wine.h"
 #include "listbox.h"
-#include "prototypes.h"
+#include "dos_fs.h"
 #include "stddebug.h"
-/* #define DEBUG_LISTBOX */
-/* #undef  DEBUG_LISTBOX */
 #include "debug.h"
 
 #define GMEM_ZEROINIT 0x0040
@@ -91,14 +86,8 @@
 			lphl->hWndLogicParent = GetParent(hwnd);
 		lphl->hFont = GetStockObject(SYSTEM_FONT);
 		lphl->ColumnsWidth = wndPtr->rectClient.right - wndPtr->rectClient.left;
-		if (wndPtr->dwStyle & WS_VSCROLL) {
-			SetScrollRange(hwnd, SB_VERT, 1, ListMaxFirstVisible(lphl), TRUE);
-			ShowScrollBar(hwnd, SB_VERT, FALSE);
-			}
-		if (wndPtr->dwStyle & WS_HSCROLL) {
-			SetScrollRange(hwnd, SB_HORZ, 1, 1, TRUE);
-			ShowScrollBar(hwnd, SB_HORZ, FALSE);
-			}
+                SetScrollRange(hwnd, SB_VERT, 1, ListMaxFirstVisible(lphl), TRUE);
+                SetScrollRange(hwnd, SB_HORZ, 1, 1, TRUE);
 		if ((wndPtr->dwStyle & LBS_OWNERDRAWFIXED) == LBS_OWNERDRAWFIXED) {
 			}
 		return 0;
@@ -242,7 +231,6 @@
 			if (y < 4) {
 				if (lphl->FirstVisible > 1) {
 					lphl->FirstVisible--;
-					if (wndPtr->dwStyle & WS_VSCROLL)
 					SetScrollPos(hwnd, SB_VERT, lphl->FirstVisible, TRUE);
 					InvalidateRect(hwnd, NULL, TRUE);
 					UpdateWindow(hwnd);
@@ -253,7 +241,6 @@
 			if (y > (rect.bottom - 4)) {
 				if (lphl->FirstVisible < ListMaxFirstVisible(lphl)) {
 					lphl->FirstVisible++;
-					if (wndPtr->dwStyle & WS_VSCROLL)
 					SetScrollPos(hwnd, SB_VERT, lphl->FirstVisible, TRUE);
 					InvalidateRect(hwnd, NULL, TRUE);
 					UpdateWindow(hwnd);
@@ -287,12 +274,12 @@
 				hWndCtl = GetNextDlgTabItem(lphl->hWndLogicParent,
 					hwnd, !(GetKeyState(VK_SHIFT) < 0));
 				SetFocus(hWndCtl);
-#ifdef DEBUG_LISTBOX
+				if(debugging_listbox){
 				if ((GetKeyState(VK_SHIFT) < 0))
 					dprintf_listbox(stddeb,"ListBox PreviousDlgTabItem %04X !\n", hWndCtl);
 				else
 					dprintf_listbox(stddeb,"ListBox NextDlgTabItem %04X !\n", hWndCtl);
-#endif
+				}
 				break;
 			case VK_HOME:
 				lphl->ItemFocused = 0;
@@ -342,8 +329,7 @@
 				SendMessage(lphl->hWndLogicParent, WM_COMMAND, 
 	    	    wndPtr->wIDmenu, MAKELONG(hwnd, LBN_SELCHANGE));
 			}
-		if (wndPtr->dwStyle & WS_VSCROLL)
-			SetScrollPos(hwnd, SB_VERT, lphl->FirstVisible, TRUE);
+                SetScrollPos(hwnd, SB_VERT, lphl->FirstVisible, TRUE);
 		InvalidateRect(hwnd, NULL, TRUE);
 		UpdateWindow(hwnd);
 		break;
@@ -357,9 +343,7 @@
 		if (wParam == 0) break;
 		break;
 	case WM_SETREDRAW:
-#ifdef DEBUG_LISTBOX
-		printf("ListBox WM_SETREDRAW hWnd=%04X w=%04X !\n", hwnd, wParam);
-#endif
+		dprintf_listbox(stddeb,"ListBox WM_SETREDRAW hWnd=%04X w=%04X !\n", hwnd, wParam);
 		lphl = ListBoxGetWindowAndStorage(hwnd, &wndPtr);
 		if (lphl == NULL) return 0;
 		lphl->bRedrawFlag = wParam;
@@ -489,9 +473,7 @@
 				wParam);
 		lphl = ListBoxGetStorageHeader(hwnd);
 		lphl->FirstVisible = wParam;
-		wndPtr = WIN_FindWndPtr(hwnd);
-		if (wndPtr->dwStyle & WS_VSCROLL)
-		    SetScrollPos(hwnd, SB_VERT, lphl->FirstVisible, TRUE);
+                SetScrollPos(hwnd, SB_VERT, lphl->FirstVisible, TRUE);
 		InvalidateRect(hwnd, NULL, TRUE);
 		UpdateWindow(hwnd);
 		break;
@@ -553,10 +535,6 @@
 		    MAKELONG(hwnd, CTLCOLOR_LISTBOX));
 	if (hBrush == (HBRUSH)NULL)  hBrush = GetStockObject(WHITE_BRUSH);
 	GetClientRect(hwnd, &rect);
-/*
-	if (wndPtr->dwStyle & WS_VSCROLL) rect.right -= 16;
-	if (wndPtr->dwStyle & WS_HSCROLL) rect.bottom -= 16;
-*/
 	FillRect(hdc, &rect, hBrush);
 	maxwidth = rect.right;
 	rect.right = lphl->ColumnsWidth;
@@ -608,13 +586,6 @@
 	}
 EndOfPaint:
     EndPaint( hwnd, &ps );
-    if ((lphl->ItemsCount > lphl->ItemsVisible) &
-	(wndPtr->dwStyle & WS_VSCROLL)) {
-/*
-        InvalidateRect(wndPtr->hWndVScroll, NULL, TRUE);
-        UpdateWindow(wndPtr->hWndVScroll);
-*/
- 	}
 }
 
 
@@ -644,8 +615,6 @@
 		    MAKELONG(hwnd, CTLCOLOR_LISTBOX));
 	if (hBrush == (HBRUSH)NULL)  hBrush = GetStockObject(WHITE_BRUSH);
 	GetClientRect(hwnd, &rect);
-	if (wndPtr->dwStyle & WS_VSCROLL) rect.right -= 16;
-	if (wndPtr->dwStyle & WS_HSCROLL) rect.bottom -= 16;
 	FillRect(hdc, &rect, hBrush);
 	maxwidth = rect.right;
 	rect.right = lphl->ColumnsWidth;
@@ -704,14 +673,6 @@
 	}
 EndOfPaint:
     EndPaint( hwnd, &ps );
-    if ((lphl->ItemsCount > lphl->ItemsVisible) &
-		(wndPtr->dwStyle & WS_VSCROLL)) {
-/*
-        InvalidateRect(wndPtr->hWndVScroll, NULL, TRUE);
-        UpdateWindow(wndPtr->hWndVScroll);
-*/
-        }
-
 }
 
 
@@ -729,8 +690,6 @@
     lpls = lphl->lpFirst;
     if (lpls == NULL) return LB_ERR;
     GetClientRect(hwnd, &rect);
-    if (wndPtr->dwStyle & WS_VSCROLL) rect.right -= 16;
-    if (wndPtr->dwStyle & WS_HSCROLL) rect.bottom -= 16;
     h = w2 = 0;
     w = lphl->ColumnsWidth;
     for(i = 1; i <= lphl->ItemsCount; i++) {
@@ -882,18 +841,12 @@
 	if (((wndPtr->dwStyle & LBS_OWNERDRAWVARIABLE) == LBS_OWNERDRAWVARIABLE) ||
 		((wndPtr->dwStyle & LBS_OWNERDRAWFIXED) == LBS_OWNERDRAWFIXED))
 		ListBoxAskMeasure(wndPtr, lphl, lplsnew);
-	if (wndPtr->dwStyle & WS_VSCROLL)
-		SetScrollRange(hwnd, SB_VERT, 1, ListMaxFirstVisible(lphl), 
-		    (lphl->FirstVisible != 1 && lphl->bRedrawFlag));
-	if ((wndPtr->dwStyle & WS_HSCROLL) && lphl->ItemsPerColumn != 0)
+        SetScrollRange(hwnd, SB_VERT, 1, ListMaxFirstVisible(lphl), 
+                       (lphl->FirstVisible != 1 && lphl->bRedrawFlag));
+	if (lphl->ItemsPerColumn != 0)
 		SetScrollRange(hwnd, SB_HORZ, 1, lphl->ItemsVisible / 
 			lphl->ItemsPerColumn + 1,
 			(lphl->FirstVisible != 1 && lphl->bRedrawFlag));
-	if (((lphl->ItemsCount - lphl->FirstVisible) == lphl->ItemsVisible) && 
-		(lphl->ItemsVisible != 0)) {
-		if (wndPtr->dwStyle & WS_VSCROLL) ShowScrollBar(hwnd, SB_VERT, TRUE);
-		if (wndPtr->dwStyle & WS_HSCROLL) ShowScrollBar(hwnd, SB_HORZ, TRUE);
-		}
 	if ((lphl->FirstVisible <= uIndex) &&
 		((lphl->FirstVisible + lphl->ItemsVisible) >= uIndex)) {
 		InvalidateRect(hwnd, NULL, TRUE);
@@ -977,17 +930,10 @@
     lphl->ItemsCount--;
     if (lpls->hData != 0) LIST_HEAP_FREE(lphl, lpls->hData);
     if (lpls->hMem != 0) LIST_HEAP_FREE(lphl, lpls->hMem);
-    if (wndPtr->dwStyle & WS_VSCROLL)
-	SetScrollRange(hwnd, SB_VERT, 1, ListMaxFirstVisible(lphl), TRUE);
-    if ((wndPtr->dwStyle & WS_HSCROLL) && lphl->ItemsPerColumn != 0)
+    SetScrollRange(hwnd, SB_VERT, 1, ListMaxFirstVisible(lphl), TRUE);
+    if (lphl->ItemsPerColumn != 0)
 	SetScrollRange(hwnd, SB_HORZ, 1, lphl->ItemsVisible / 
 	    lphl->ItemsPerColumn + 1, TRUE);
-    if (lphl->ItemsCount < lphl->ItemsVisible) {
-	if (wndPtr->dwStyle & WS_VSCROLL)
-	    ShowScrollBar(hwnd, SB_VERT, FALSE);
-	if (wndPtr->dwStyle & WS_HSCROLL)
-	    ShowScrollBar(hwnd, SB_HORZ, FALSE);
-	}
     if ((lphl->FirstVisible <= uIndex) &&
         ((lphl->FirstVisible + lphl->ItemsVisible) >= uIndex)) {
         InvalidateRect(hwnd, NULL, TRUE);
@@ -1056,15 +1002,10 @@
     if ((wndPtr->dwStyle && LBS_NOTIFY) != 0)
 	SendMessage(lphl->hWndLogicParent, WM_COMMAND, 
     	    wndPtr->wIDmenu, MAKELONG(hwnd, LBN_SELCHANGE));
-    if (wndPtr->dwStyle & WS_VSCROLL)
-	SetScrollRange(hwnd, SB_VERT, 1, ListMaxFirstVisible(lphl), TRUE);
-    if ((wndPtr->dwStyle & WS_HSCROLL) && lphl->ItemsPerColumn != 0)
+    SetScrollRange(hwnd, SB_VERT, 1, ListMaxFirstVisible(lphl), TRUE);
+    if (lphl->ItemsPerColumn != 0)
 	SetScrollRange(hwnd, SB_HORZ, 1, lphl->ItemsVisible / 
 	    lphl->ItemsPerColumn + 1, TRUE);
-    if (wndPtr->dwStyle & WS_VSCROLL)
-	ShowScrollBar(hwnd, SB_VERT, FALSE);
-    if (wndPtr->dwStyle & WS_HSCROLL)
-	ShowScrollBar(hwnd, SB_HORZ, FALSE);
     InvalidateRect(hwnd, NULL, TRUE);
     UpdateWindow(hwnd);
     return TRUE;
diff --git a/controls/menu.c b/controls/menu.c
index 8bc650f..3ac8946 100644
--- a/controls/menu.c
+++ b/controls/menu.c
@@ -1,9 +1,9 @@
 /*
  *        Menus functions
- */
 static char RCSId[] = "$Id$";
 static char Copyright[] = "Copyright  Martin Ayotte, 1993";
 static char Copyright2[] = "Copyright  Alexandre Julliard, 1994";
+*/
 
 /*
  * Note: the style MF_MOUSESELECT is used to mark popup items that
@@ -11,7 +11,6 @@
  * This is probably not the meaning this style has in MS-Windows.
  */
 
-
 #include <ctype.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -23,14 +22,13 @@
 #include "menu.h"
 #include "user.h"
 #include "win.h"
+#include "library.h"
 #include "message.h"
+#include "graphics.h"
 #include "stddebug.h"
 /* #define DEBUG_MENU */
-/* #undef DEBUG_MENU */
 /* #define DEBUG_MENUCALC */
-/* #undef DEBUG_MENUCALC */
 /* #define DEBUG_MENUSHORTCUT */
-/* #undef DEBUG_MENUSHORTCUT */
 #include "debug.h"
 
 
@@ -60,12 +58,6 @@
 
 
 extern void NC_DrawSysButton(HWND hwnd, HDC hdc, BOOL down);  /* nonclient.c */
-extern void CURSOR_SetWinCursor( HWND hwnd, HCURSOR hcursor );   /* cursor.c */
-extern BOOL GRAPH_DrawBitmap( HDC hdc, HBITMAP hbitmap, int xdest, int ydest,
-			      int xsrc, int ysrc, int width, int height,
-			      int rop );                     /* graphics.c */
-
-extern HINSTANCE hSysRes;
 
 static HBITMAP hStdCheck = 0;
 static HBITMAP hStdMnArrow = 0;
diff --git a/controls/scroll.c b/controls/scroll.c
index 168c964..e28347a 100644
--- a/controls/scroll.c
+++ b/controls/scroll.c
@@ -2,13 +2,12 @@
  * Interface code to SCROLLBAR widget
  *
  * Copyright  Martin Ayotte, 1993
+ * Copyright  Alexandre Julliard, 1994
  *
  * Small fixes and implemented SB_THUMBPOSITION
  * by Peter Broadhurst, 940611
  */
 
-static char Copyright[] = "Copyright Martin Ayotte, 1993";
-
 #include <stdlib.h>
 #include <stdio.h>
 #include <sys/types.h>
@@ -18,10 +17,10 @@
 #include "sysmetrics.h"
 #include "scroll.h"
 #include "user.h"
+#include "graphics.h"
 #include "win.h"
 #include "stddebug.h"
 /* #define DEBUG_SCROLL */
-/* #undef  DEBUG_SCROLL */
 #include "debug.h"
 
 
@@ -48,10 +47,6 @@
    (((flags)&ESB_DISABLE_RIGHT) ? hRgArrowI : ((pressed) ? hRgArrowD:hRgArrow))
 
 
-  /* windows/graphics.c */
-extern void GRAPH_DrawReliefRect( HDC hdc, RECT *rect, int highlight_size,
-                                  int shadow_size, BOOL pressed );
-
   /* Minimum size of the rectangle between the arrows */
 #define SCROLL_MIN_RECT  4  
 
@@ -805,7 +800,8 @@
 
     if (!(infoPtr = SCROLL_GetScrollInfo( hwnd, nBar ))) return;
 
-    dprintf_scroll( stddeb,"SetScrollRange min=%d max=%d\n", MinVal, MaxVal );
+    dprintf_scroll( stddeb,"SetScrollRange hwnd=%x bar=%d min=%d max=%d\n",
+                    hwnd, nBar, MinVal, MaxVal );
 
       /* Invalid range -> range is set to (0,0) */
     if ((MinVal > MaxVal) || ((long)MaxVal - MinVal > 32767L))
@@ -815,8 +811,8 @@
     infoPtr->MinVal = MinVal;
     infoPtr->MaxVal = MaxVal;
 
-      /* Non-client scroll-bar is hidden iff range is (0,0) */
-    if (nBar != SB_CTL) ShowScrollBar( hwnd, nBar, (MinVal || MaxVal) );
+      /* Non-client scroll-bar is hidden if min==max */
+    if (nBar != SB_CTL) ShowScrollBar( hwnd, nBar, (MinVal != MaxVal) );
     if (bRedraw) SCROLL_RefreshScrollBar( hwnd, nBar );
 }
 
@@ -842,7 +838,7 @@
     WND *wndPtr = WIN_FindWndPtr( hwnd );
 
     if (!wndPtr) return;
-    dprintf_scroll( stddeb, "ShowScrollBar: %x %d %d\n", hwnd, wBar, fShow );
+    dprintf_scroll( stddeb, "ShowScrollBar: hwnd=%x bar=%d on=%d\n", hwnd, wBar, fShow );
 
     switch(wBar)
     {
diff --git a/controls/static.c b/controls/static.c
index 110817f..9089095 100644
--- a/controls/static.c
+++ b/controls/static.c
@@ -3,9 +3,8 @@
  *
  * Copyright  David W. Metcalfe, 1993
  *
- */
-
 static char Copyright[] = "Copyright  David W. Metcalfe, 1993";
+*/
 
 #include <stdio.h>
 #include <windows.h>
@@ -98,10 +97,12 @@
             return DefWindowProc(hWnd, uMsg, wParam, lParam);
 
 	case WM_CREATE:
-	    if (style < 0L || style > LAST_STATIC_TYPE) {
+	    if (style < 0L || style > LAST_STATIC_TYPE)
+            {
+                fprintf( stderr, "STATIC: Unknown style 0x%02lx\n", style );
 		lResult = -1L;
 		break;
-		}
+            }
 	    /* initialise colours */
 	    color_windowframe  = GetSysColor(COLOR_WINDOWFRAME);
 	    color_background   = GetSysColor(COLOR_BACKGROUND);
@@ -116,11 +117,11 @@
             break;
 
 	case WM_PAINT:
-	    if (staticPaintFunc[style])
             {
                 PAINTSTRUCT ps;
                 BeginPaint( hWnd, &ps );
-		(staticPaintFunc[style])( hWnd, ps.hdc );
+                if (staticPaintFunc[style])
+                    (staticPaintFunc[style])( hWnd, ps.hdc );
                 EndPaint( hWnd, &ps );
             }
 	    break;
diff --git a/controls/widgets.c b/controls/widgets.c
index 838d09e..932594e 100644
--- a/controls/widgets.c
+++ b/controls/widgets.c
@@ -2,9 +2,9 @@
  * Windows widgets (built-in window classes)
  *
  * Copyright 1993 Alexandre Julliard
- */
 
 static char Copyright[] = "Copyright  Alexandre Julliard, 1993";
+*/
 
 #include "win.h"
 #include "button.h"
diff --git a/debugger/break.c b/debugger/break.c
index 705528c..2c276da 100644
--- a/debugger/break.c
+++ b/debugger/break.c
@@ -1,11 +1,19 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <sys/mman.h>
+#ifdef linux
+#include <sys/utsname.h>
+#endif
+#include <windows.h>
 
 #define N_BP 25
 
+extern int dbg_mode;
+
 struct wine_bp{
   unsigned long addr;
+  unsigned long next_addr;
   char in_use;
   char enabled;
   unsigned char databyte;
@@ -13,13 +21,19 @@
 
 static struct wine_bp wbp[N_BP] = {{0,},};
 
-void info_break()
+static int current_bp = -1;
+static int cont_mode=0;	/* 0 - continuous execution
+			   1 - advancing after breakpoint
+			   2 - single step - not implemented
+			*/
+
+void info_break(void)
 {
   int j;
   fprintf(stderr,"Breakpoint status\n");
   for(j=0; j<N_BP; j++)
     if(wbp[j].in_use)
-      fprintf(stderr,"%d: %c %8.8x\n", j, (wbp[j].enabled ? 'y' : 'n'),
+      fprintf(stderr,"%d: %c %8lx\n", j, (wbp[j].enabled ? 'y' : 'n'),
 	      wbp[j].addr);
 }
 
@@ -48,11 +62,34 @@
 	wbp[j].in_use = 1;
 	wbp[j].enabled = 1;
 	wbp[j].addr = addr;
+	wbp[j].next_addr = 0;
 	return;
       }
   fprintf(stderr,"No more breakpoints\n");
 }
 
+static void bark()
+{
+  static int barked=0;
+  if(barked)return;
+  barked=1;
+  perror("Sorry, can't set break point");
+#ifdef linux
+  {struct utsname buf;
+  uname(&buf);
+  if(strcmp(buf.sysname,"Linux")==0)
+  {	if(strcmp(buf.release,"1.1.62")<0)
+	  fprintf(stderr,"Your current Linux release is %s. "
+		"You should upgrade to 1.1.62 or higher\n"
+		"Alternatively, in /usr/src/linux/fs/exec.c,"
+		" change MAP_SHARED to MAP_PRIVATE.\n", buf.release);
+  } else
+  fprintf(stderr,"Why did you compile for Linux, while your system is"
+   " actually %s?\n",buf.sysname);
+  }
+#endif
+}
+  
 void insert_break(int flag)
 {
   unsigned char * pnt;
@@ -61,6 +98,20 @@
   for(j=0; j<N_BP; j++)
     if(wbp[j].enabled)
       {
+        /* There are a couple of problems with this. On Linux prior to
+           1.1.62, this call fails (ENOACCESS) due to a bug in fs/exec.c.
+           This code is currently not tested at all on BSD.
+           How do I determine the page size in a more symbolic manner?
+           And why does mprotect need that start address of the page
+           in the first place?
+           Not that portability matters, this code is i386 only anyways...
+           How do I get the old protection in order to restore it later on?
+        */
+	if(mprotect((caddr_t)(wbp[j].addr & (~4095)), 4096, 
+	  PROT_READ|PROT_WRITE|PROT_EXEC) == -1){
+	    bark();
+            return;
+	}
 	pnt = (unsigned char *) wbp[j].addr;
 	if(flag) {
 	  wbp[j].databyte = *pnt;
@@ -68,6 +119,7 @@
 	} else {
 	  *pnt = wbp[j].databyte;
 	}
+	mprotect((caddr_t)(wbp[j].addr & ~4095), 4096, PROT_READ|PROT_EXEC);
       }
 }
 
@@ -82,3 +134,27 @@
 
   return -1;
 }
+
+void toggle_next(int num)
+{
+   unsigned int addr;
+   addr=wbp[num].addr;
+   if(wbp[num].next_addr == 0)
+	wbp[num].next_addr=addr+print_insn(addr,addr,stderr,dbg_mode);
+   wbp[num].addr=wbp[num].next_addr;
+   wbp[num].next_addr=addr;
+}
+
+int should_continue(int bpnum)
+{
+    if(bpnum<0)return 0;
+    toggle_next(bpnum);
+    if(bpnum==current_bp){
+        current_bp=-1;
+	cont_mode=0;
+	return 1;
+    }
+    cont_mode=1;
+    current_bp=bpnum;
+    return 0;
+}
diff --git a/debugger/dbg.y b/debugger/dbg.y
index f09de83..b2d2ab8 100644
--- a/debugger/dbg.y
+++ b/debugger/dbg.y
@@ -30,6 +30,7 @@
 %token BACKTRACE
 %token INFO
 %token STACK
+%token SEGMENTS
 %token REG
 %token REGS
 %token NUM
@@ -83,7 +84,7 @@
 
 print:
 	  'p'
-	| print
+	| PRINT
 	
  print_command:
 	  print expr '\n' { examine_memory(((unsigned int) &$2 ), 1, 'x'); }
@@ -107,15 +108,16 @@
 
  expr:  NUM			{ $$ = $1;	}
 	| REG			{ if(regval) $$ = regval[$1]; else application_not_running();}
-	| symbol   		{ $$ = *((unsigned int *) $1); }
+	| symbol   		{ $$ = $1; }
 	| expr '+' NUM		{ $$ = $1 + $3; }
 	| expr '-' NUM		{ $$ = $1 - $3; }
 	| '(' expr ')'		{ $$ = $2; }
 	| '*' expr		{ $$ = *((unsigned int *) $2); }
 	
- infocmd: INFO REGS { info_reg(); }
-	| INFO STACK  { info_stack(); }
-	| INFO BREAK  { info_break(); }
+ infocmd: INFO REGS     { info_reg(); }
+	| INFO STACK    { info_stack(); }
+	| INFO BREAK    { info_break(); }
+	| INFO SEGMENTS { print_ldt(); }
 
 
 %%
@@ -187,17 +189,21 @@
 	}
 
 	/* Remove the breakpoints from memory... */
-	fprintf(stderr,"Removing BPs\n");
 	insert_break(0);
 
 	/* If we stopped on a breakpoint, report this fact */
 	if(signal == SIGTRAP)
 	  {
 	    unsigned int addr;
+	    int bpnum;
 	    addr = SC_EIP(dbg_mask);
 	    if((addr & 0xffff0000) == 0 && dbg_mode == 16)
 	      addr |= SC_CS << 16;
-	    fprintf(stderr,"Stopped on breakpoint %d\n", get_bpnum(addr));
+	    if(should_continue(bpnum=get_bpnum(addr))){
+		insert_break(1);
+		return;
+	    }
+	    fprintf(stderr,"Stopped on breakpoint %d\n", bpnum);
 	  }
 
 	/* Show where we crashed */
diff --git a/debugger/debug.l b/debugger/debug.l
index 4713516..fb5c4fb 100644
--- a/debugger/debug.l
+++ b/debugger/debug.l
@@ -1,5 +1,3 @@
-
-
 /* Lexical scanner for command line parsing in the Wine debugger
  *
  * Version 1.0
@@ -53,12 +51,12 @@
 "?"		{ return HELP; }
 
 "0x"+{HEXDIGIT}+   {
-		sscanf(yytext, "%lx", &yylval);
+		sscanf(yytext, "%x", &yylval);
 		return NUM;
 		}
 
 {DIGIT}+   {
-		sscanf(yytext, "%ld", &yylval);
+		sscanf(yytext, "%d", &yylval);
 		return NUM;
 		}
 
@@ -80,7 +78,7 @@
 $ss		{ yylval = RN_SS;  return REG;}
 
 info|inf|in		{ return INFO; }
-
+segments|segm           { return SEGMENTS; }
 break|brea|bre          { return BREAK; }
 enable|enabl|enab|ena   { return ENABLE;}
 disable|disabl|disab|disa|dis { return DISABLE; }
@@ -183,8 +181,7 @@
 }
 
 /* Strip whitespace from the start and end of STRING. */
-stripwhite (string)
-     char *string;
+void stripwhite (char *string)
 {
   register int i = 0;
 
diff --git a/debugger/hash.c b/debugger/hash.c
index 468446e..600cf34 100644
--- a/debugger/hash.c
+++ b/debugger/hash.c
@@ -12,6 +12,7 @@
 #include <neexe.h>
 #include <segmem.h>
 #include <prototypes.h>
+#include "selectors.h"
 #include <wine.h>
 #include <dlls.h>
 
diff --git a/debugger/info.c b/debugger/info.c
index bb65bec..e4e4432 100644
--- a/debugger/info.c
+++ b/debugger/info.c
@@ -202,7 +202,7 @@
 		pnt = (char *) addr;
 		for(i=0; i<count; i++) 
 		{
-			fprintf(stderr," %02.2x", (*pnt++) & 0xff);
+			fprintf(stderr," %02x", (*pnt++) & 0xff);
 			if ((i % 32) == 7) {
 				fprintf(stderr,"\n");
 				print_address((unsigned int) pnt, stderr);
diff --git a/debugger/opcodes/i386-dis.c b/debugger/opcodes/i386-dis.c
index 409a756..0d18311 100644
--- a/debugger/opcodes/i386-dis.c
+++ b/debugger/opcodes/i386-dis.c
@@ -1565,7 +1565,7 @@
     {
       if (mod == 0 && rm == 6)
 	{
-	  sprintf (scratchbuf, "0x%04.4x", get16 ());
+	  sprintf (scratchbuf, "0x%04x", get16 ());
 	  oappend (scratchbuf);
 	  return 0;
 	}
diff --git a/debugger/readline/complete.c b/debugger/readline/complete.c
index 0cd029c..c5cbaaa 100644
--- a/debugger/readline/complete.c
+++ b/debugger/readline/complete.c
@@ -2,9 +2,9 @@
 **
 **  History and file completion functions for editline library.
 */
+#include <stdlib.h>
 #include "editline.h"
 
-
 #if	defined(NEED_STRDUP)
 /*
 **  Return an allocated copy of a string.
diff --git a/if1632/call.S b/if1632/call.S
index 2d5ed8d..e36f093 100644
--- a/if1632/call.S
+++ b/if1632/call.S
@@ -163,9 +163,17 @@
  *			10	target cs
  *			12	target ds
  *			14      target cx  (only CallTo16cx)
+ *                      16      target di
  */
 	.align	4
-	.globl A(CallTo16), A(CallTo16cx)
+	.globl A(CallTo16), A(CallTo16cx), A(CallToLibMain)
+A(CallToLibMain:)
+        pushl   %ebp
+        movl    %esp,%ebp
+        movw    16(%ebp),%di
+        movw    0,%si
+        movw    0,%es
+        jmp     L1
 A(CallTo16:)
 A(CallTo16cx:)
 	pushl	%ebp
@@ -174,7 +182,7 @@
 	/*
 	 * Get target address and new ds
 	 */
-	movl	8(%ebp),%eax
+L1:	movl	8(%ebp),%eax
 	movl	%eax,jump_target
 	lea	jump_target,%edx
 	movw	12(%ebp),%ax
diff --git a/if1632/callback.c b/if1632/callback.c
index 5e8d5eb..aef1d53 100644
--- a/if1632/callback.c
+++ b/if1632/callback.c
@@ -1,6 +1,8 @@
 #ifndef WINELIB
+/*
 static char RCSId[] = "$Id: wine.c,v 1.2 1993/07/04 04:04:21 root Exp root $";
 static char Copyright[] = "Copyright  Robert J. Amstadt, 1993";
+*/
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -11,10 +13,8 @@
 #include <setjmp.h>
 #include "dlls.h"
 #include "stddebug.h"
-/* #define DEBUG_CALLBACK */
-/* #undef  DEBUG_CALLBACK */
 #include "debug.h"
-
+#include "if1632.h"
 
 extern SEGDESC Segments[];
 extern unsigned short IF1632_Saved16_ss;
@@ -188,13 +188,15 @@
 	/* default */
 	else
 	{
-	    fprintf(stderr, "wine: Unknown wine callback %08x\n", func);
+	    fprintf(stderr, "wine: Unknown wine callback %08x\n", 
+	    	(unsigned int) func);
 	    exit(1);
 	}
     }
     else if (IS_16_BIT_ADDRESS(func))
     {	
-	dprintf_callback(stddeb, "CallWindowProc // 16bit func=%p !\n", func);
+	dprintf_callback(stddeb, "CallWindowProc // 16bit func=%p !\n", 
+		(unsigned int) func);
 	PushOn16( CALLBACK_SIZE_WORD, hwnd );
 	PushOn16( CALLBACK_SIZE_WORD, message );
 	PushOn16( CALLBACK_SIZE_WORD, wParam );
@@ -204,7 +206,8 @@
     }
     else
     {
-	dprintf_callback(stddeb, "CallWindowProc // 32bit func=%08X !\n", func);
+	dprintf_callback(stddeb, "CallWindowProc // 32bit func=%08X !\n",
+		(unsigned int) func);
 	return (*func)(hwnd, message, wParam, lParam);
     }
 }
@@ -319,11 +322,12 @@
 
 		memcpy (stack16, sb -> stack_part, STACK_DEPTH_16);
 		dprintf_catch (stddeb, "Been thrown here: %d, retval = %d\n", 
-			sb, retval);
+			(int) sb, (int) retval);
 		free ((void *) sb);
 		return (retval);
 	} else {
-		dprintf_catch (stddeb, "Will somtime get thrown here: %d\n", sb);
+		dprintf_catch (stddeb, "Will somtime get thrown here: %d\n", 
+			(int) sb);
 		return (retval);
 	}
 }
@@ -331,7 +335,7 @@
 void Throw (LPCATCHBUF cbuf, int val)
 {
 	sb = *((struct special_buffer **)cbuf);
-	dprintf_catch (stddeb, "Throwing to: %d\n", sb);
+	dprintf_catch (stddeb, "Throwing to: %d\n", (int) sb);
 	longjmp (sb -> buffer, val);
 }
 #endif /* !WINELIB */
diff --git a/if1632/gdi.spec b/if1632/gdi.spec
index 7eb7ebe..45f5c94 100644
--- a/if1632/gdi.spec
+++ b/if1632/gdi.spec
@@ -129,7 +129,7 @@
 #121 pascal Death
 #122 pascal ReSurRection
 123 pascal16 PlayMetaFile(word word) PlayMetaFile(1 2)
-#124 pascal GetMetaFile
+124 pascal16 GetMetaFile(ptr) GetMetaFile(1)
 125 pascal16 CreateMetaFile(ptr) CreateMetaFile(1)
 126 pascal16 CloseMetaFile(word) CloseMetaFile(1)
 127 pascal16 DeleteMetaFile(word) DeleteMetaFile(1)
diff --git a/if1632/relay.c b/if1632/relay.c
index 8036697..0118a12 100644
--- a/if1632/relay.c
+++ b/if1632/relay.c
@@ -1,5 +1,7 @@
+/*
 static char RCSId[] = "$Id: relay.c,v 1.2 1993/07/04 04:04:21 root Exp root $";
 static char Copyright[] = "Copyright  Robert J. Amstadt, 1993";
+*/
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -8,21 +10,29 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <unistd.h>
+#include <errno.h>
 #ifdef linux
 #include <linux/unistd.h>
 #include <linux/head.h>
 #include <linux/ldt.h>
 #include <linux/segment.h>
 #endif
-#include <errno.h>
 
 #include "neexe.h"
 #include "segmem.h"
 #include "prototypes.h"
 #include "dlls.h"
 #include "options.h"
+#include "stddebug.h"
+/* #define DEBUG_RELAY /* */
+/* #define DEBUG_STACK /* */
+#include "debug.h"
 
-#define DEBUG_RELAY /* */
+#if 0
+/* Make make_debug think these were really used */
+dprintf_relay
+dprintf_stack
+#endif
 
 #ifdef WINELIB
 #define WineLibSkip(x) 0
@@ -103,11 +113,9 @@
     ordinal = func_num & 0xffff;
     dll_p   = &dll_builtin_table[dll_id].dll_table[ordinal];
 
-#ifdef DEBUG_RELAY
-    if (Options.relay_debug)
+    if (debugging_relay)
     {
 	unsigned int *ret_addr;
-	unsigned short *stack_p;
 	
 	ret_addr = (unsigned int *) ((char *) seg_off + 0x14);
 	printf("Call %s (%s.%d), stack=%04x:%04x, ",
@@ -119,18 +127,18 @@
 	       IF1632_Saved16_esp, IF1632_Saved16_ebp,
 	       IF1632_Saved16_ss);
 
-#ifdef DEBUG_STACK
-	stack_p = (unsigned short *) seg_off;
-	for (i = 0; i < 24; i++, stack_p++)
-	{
-            printf("%04x ", *stack_p);
-	    if ((i & 7) == 7)
-		printf("\n");
+	if(debugging_stack)
+        {
+            unsigned short *stack_p = (unsigned short *) seg_off;
+            for (i = 0; i < 24; i++, stack_p++)
+            {
+                printf("%04x ", *stack_p);
+                if ((i & 7) == 7)
+                    printf("\n");
+            }
+            printf("\n");
 	}
-	printf("\n");
-#endif /* DEBUG_STACK */
-    }
-#endif /* DEBUG_RELAY */
+    } /* DEBUG_RELAY */
 
     /*
      * Make sure we have a handler defined for this call.
@@ -206,15 +214,13 @@
 			  arg_table[12], arg_table[13], arg_table[14], 
 			  arg_table[15]);
 
-#ifdef DEBUG_RELAY
-    if (Options.relay_debug)
+    if (debugging_relay)
     {
 	printf("Returning %08x from %s (%s.%d)\n",
 	       ret_val,
 	       dll_p->export_name,
 	       dll_builtin_table[dll_id].dll_name, ordinal);
     }
-#endif
 
     Stack16Frame = saved_Stack16Frame;
     return ret_val;
diff --git a/if1632/winsock.spec b/if1632/winsock.spec
index 84ade1d..12913f2 100644
--- a/if1632/winsock.spec
+++ b/if1632/winsock.spec
@@ -7,65 +7,61 @@
 id	9
 length	155
 
-1   pascal accept(word ptr ptr) Winsock_accept(1 2 3)
-2   pascal bind(word ptr word) Winsock_bind(1 2 3)
-3   pascal closesocket(word) Winsock_closesocket(1)
-4   pascal connect(word ptr word) Winsock_connect(1 2 3)
-5   pascal getpeername(word ptr ptr) Winsock_getpeername(1 2 3)
-6   pascal getsockname(word ptr ptr) Winsock_getsockname(1 2 3)
-7   pascal getsockopt(word word word ptr ptr)
-           Winsock_getsockopt(1 2 3 4 5)
-8   pascal htonl(long) Winsock_htonl(1)
-9   pascal htons(word) Winsock_htons(1)
-10  pascal inet_addr(long) Winsock_inet_addr(1)
-11  pascal inet_ntoa(long) Winsock_inet_ntoa(1)
-12  pascal ioctlsocket(word long ptr) Winsock_ioctlsocket(1 2 3)
-13  pascal listen(word word) Winsock_listen(1 2)
-14  pascal ntohl(long) Winsock_ntohl(1)
-15  pascal ntohs(word) Winsock_ntohs(1)
-16  pascal recv(word ptr word word) Winsock_recv(1 2 3 4)
-17  pascal recvfrom(word ptr word word ptr ptr)
-           Winsock_recvfrom(1 2 3 4 5 6)
-18  pascal select(word ptr ptr ptr ptr word)
-           Winsock_select(1 2 3 4 5 6)
-19  pascal send(word ptr word word) Winsock_send(1 2 3 4)
-20  pascal sendto(word ptr word word ptr ptr)
-           Winsock_sendto(1 2 3 4 5 6)
-21  pascal setsockopt(word word word ptr word)
-           Winsock_setsockopt(1 2 3 4 5)
-22  pascal shutdown(word word) Winsock_shutdown(1 2)
-23  pascal socket(word word word) Winsock_socket(1 2 3)
-
-51  pascal gethostbyaddr(ptr word word) Winsock_gethostbyaddr(1 2 3)
-52  pascal gethostbyname(ptr) Winsock_gethostbyname(1)
-53  pascal getprotobyname(ptr) Winsock_getprotobyname(1)
-54  pascal getprotobynumber(word) Winsock_getprotobynumber(1)
-55  pascal getservbyname(ptr ptr) Winsock_getservbyname(1 2)
-56  pascal getservbyport(word ptr) Winsock_getservbyport(1 2)
-57  pascal gethostname(ptr word) Winsock_gethostname(1 2)
-
-101 pascal WSAAsyncSelect(word word word long)
-           WSAAsyncSelect(1 2 3 4)
-102 pascal WSAAsyncGetHostByAddr(word word ptr word word ptr word)
-           WSAAsyncGetHostByAddr(1 2 3 4 5 6 7)
-103 pascal WSAAsyncGetHostByName(word word ptr ptr word)
-           WSAAsyncGetHostByName(1 2 3 4 5)
-104 pascal WSAAsyncGetProtoByNumber(word word word ptr word)
-           WSAAsyncGetProtoByNumber(1 2 3 4 5)
-105 pascal WSAAsyncGetProtoByName(word word ptr ptr word)
-           WSAAsyncGetProtoByName(1 2 3 4 5)
-106 pascal WSAAsyncGetServByPort(word word word ptr ptr word)
-           WSAAsyncGetServByPort(1 2 3 4 5 6)
-107 pascal WSAAsyncGetServByName(word word ptr ptr ptr word)
-           WSAAsyncGetServByName(1 2 3 4 5 6)
-108 pascal WSACancelAsyncRequest(word) WSACancelAsyncRequest(1)
-109 pascal WSASetBlockingHook() WSASetBlockingHook()
-110 pascal WSAUnhookBlockingHook() WSAUnhookBlockingHook()
-111 pascal WSAGetLastError() WSAGetLastError()
-112 pascal WSASetLastError(word) WSASetLastError(1)
-113 pascal WSACancelBlockingCall() WSACancelBlockingCall()
-114 pascal WSAIsBlocking() WSAIsBlocking()
-115 pascal WSAStartup(word ptr) WSAStartup(1 2)
-116 pascal WSACleanup() WSACleanup()
-
-151 pascal __WSAFDIsSet(word ptr) WSAFDIsSet(1 2)
+1   pascal16 accept(word ptr ptr) WINSOCK_accept(1 2 3)
+2   pascal16 bind(word ptr word) WINSOCK_bind(1 2 3)
+3   pascal16 closesocket(word) WINSOCK_closesocket(1)
+4   pascal16 connect(word ptr word) WINSOCK_connect(1 2 3)
+5   pascal16 getpeername(word ptr ptr) WINSOCK_getpeername(1 2 3)
+6   pascal16 getsockname(word ptr ptr) WINSOCK_getsockname(1 2 3)
+7   pascal16 getsockopt(word word word ptr ptr) WINSOCK_getsockopt(1 2 3 4 5)
+8   pascal   htonl(long) WINSOCK_htonl(1)
+9   pascal16 htons(word) WINSOCK_htons(1)
+10  pascal   inet_addr(long) WINSOCK_inet_addr(1)
+11  pascal   inet_ntoa(long) WINSOCK_inet_ntoa(1)
+12  pascal16 ioctlsocket(word long ptr) WINSOCK_ioctlsocket(1 2 3)
+13  pascal16 listen(word word) WINSOCK_listen(1 2)
+14  pascal   ntohl(long) WINSOCK_ntohl(1)
+15  pascal16 ntohs(word) WINSOCK_ntohs(1)
+16  pascal16 recv(word ptr word word) WINSOCK_recv(1 2 3 4)
+17  pascal16 recvfrom(word ptr word word ptr ptr)
+             WINSOCK_recvfrom(1 2 3 4 5 6)
+18  pascal16 select(word ptr ptr ptr ptr word)
+             WINSOCK_select(1 2 3 4 5 6)
+19  pascal16 send(word ptr word word) WINSOCK_send(1 2 3 4)
+20  pascal16 sendto(word ptr word word ptr ptr)
+             WINSOCK_sendto(1 2 3 4 5 6)
+21  pascal16 setsockopt(word word word ptr word)
+             WINSOCK_setsockopt(1 2 3 4 5)
+22  pascal16 shutdown(word word) WINSOCK_shutdown(1 2)
+23  pascal16 socket(word word word) WINSOCK_socket(1 2 3)
+51  pascal   gethostbyaddr(ptr word word) WINSOCK_gethostbyaddr(1 2 3)
+52  pascal   gethostbyname(ptr) WINSOCK_gethostbyname(1)
+53  pascal   getprotobyname(ptr) WINSOCK_getprotobyname(1)
+54  pascal   getprotobynumber(word) WINSOCK_getprotobynumber(1)
+55  pascal   getservbyname(ptr ptr) WINSOCK_getservbyname(1 2)
+56  pascal   getservbyport(word ptr) WINSOCK_getservbyport(1 2)
+57  pascal   gethostname(ptr word) WINSOCK_gethostname(1 2)
+101 pascal16 WSAAsyncSelect(word word word long)
+             WSAAsyncSelect(1 2 3 4)
+102 pascal16 WSAAsyncGetHostByAddr(word word ptr word word ptr word)
+             WSAAsyncGetHostByAddr(1 2 3 4 5 6 7)
+103 pascal16 WSAAsyncGetHostByName(word word ptr ptr word)
+             WSAAsyncGetHostByName(1 2 3 4 5)
+104 pascal16 WSAAsyncGetProtoByNumber(word word word ptr word)
+             WSAAsyncGetProtoByNumber(1 2 3 4 5)
+105 pascal16 WSAAsyncGetProtoByName(word word ptr ptr word)
+             WSAAsyncGetProtoByName(1 2 3 4 5)
+106 pascal16 WSAAsyncGetServByPort(word word word ptr ptr word)
+             WSAAsyncGetServByPort(1 2 3 4 5 6)
+107 pascal16 WSAAsyncGetServByName(word word ptr ptr ptr word)
+             WSAAsyncGetServByName(1 2 3 4 5 6)
+108 pascal16 WSACancelAsyncRequest(word) WSACancelAsyncRequest(1)
+109 pascal16 WSASetBlockingHook() WSASetBlockingHook()
+110 pascal16 WSAUnhookBlockingHook() WSAUnhookBlockingHook()
+111 pascal16 WSAGetLastError() WSAGetLastError()
+112 pascal   WSASetLastError(word) WSASetLastError(1)
+113 pascal16 WSACancelBlockingCall() WSACancelBlockingCall()
+114 pascal16 WSAIsBlocking() WSAIsBlocking()
+115 pascal   WSAStartup(word ptr) WSAStartup(1 2)
+116 pascal   WSACleanup() WSACleanup()
+151 pascal16 __WSAFDIsSet(word ptr) WSAFDIsSet(1 2)
diff --git a/include/arch.h b/include/arch.h
index c929a3e..ad1865c 100644
--- a/include/arch.h
+++ b/include/arch.h
@@ -19,6 +19,6 @@
 #define CONV_CHAR_TO_LONG(a) (a)
 #define CONV_SHORT_TO_LONG(a) (a)
 
-#define CONV_BITMAPINFO
-#define CONV_BITMAPCOREHEADER
+#define CONV_BITMAPINFO(a)		/* */
+#define CONV_BITMAPCOREHEADER(a)	/* */
 #endif
diff --git a/include/atom.h b/include/atom.h
index 9182769..0336837 100644
--- a/include/atom.h
+++ b/include/atom.h
@@ -9,6 +9,8 @@
 
 #include "windows.h"
 
+extern BOOL ATOM_Init(void);
+
 typedef struct
 {
     HANDLE      next;
diff --git a/include/bitmap.h b/include/bitmap.h
index 9a2acfa..280946f 100644
--- a/include/bitmap.h
+++ b/include/bitmap.h
@@ -10,6 +10,8 @@
 #include <X11/Xlib.h>
 #include "windows.h"
 
+extern BOOL BITMAP_Init(void);
+
   /* GCs used for B&W and color bitmap operations */
 extern GC BITMAP_monoGC, BITMAP_colorGC;
 
diff --git a/include/callback.h b/include/callback.h
index ba84573..18206c9 100644
--- a/include/callback.h
+++ b/include/callback.h
@@ -16,5 +16,6 @@
 extern int CallTo16(unsigned int csip, unsigned short ds);
 extern int CallBack16(void *func, int n_args, ...);
 
+extern BOOL CallGrayStringProc(FARPROC func, HDC hdc, LPARAM lParam, INT cch);
 
 #endif /* CALLBACK_H */
diff --git a/include/clipboard.h b/include/clipboard.h
new file mode 100644
index 0000000..502e314
--- /dev/null
+++ b/include/clipboard.h
@@ -0,0 +1,7 @@
+#ifndef __WINE_CLIPBOARD_H
+#define __WINE_CLIPBOARD_H
+
+extern void CLIPBOARD_ReadSelection(Window w,Atom prop);
+void CLIPBOARD_ReleaseSelection(HWND hwnd);
+
+#endif /* __WINE_CLIPBOARD_H */
diff --git a/include/color.h b/include/color.h
new file mode 100644
index 0000000..faf9fd7
--- /dev/null
+++ b/include/color.h
@@ -0,0 +1,14 @@
+#ifndef __WINE_COLOR_H
+#define __WINE_COLOR_H
+
+#include "gdi.h"
+
+extern HPALETTE COLOR_Init(void);
+extern int COLOR_ToPhysical( DC *dc, COLORREF color );
+extern void COLOR_SetMapping( DC *dc, HANDLE, WORD );
+extern BOOL COLOR_IsSolid( COLORREF color );
+
+extern Colormap COLOR_WinColormap;
+extern int COLOR_mapEGAPixel[16];
+
+#endif /* __WINE_COLOR_H */
diff --git a/include/comm.h b/include/comm.h
index 785a7b7..af2d3f01 100644
--- a/include/comm.h
+++ b/include/comm.h
@@ -1,13 +1,6 @@
-/*
- * Communications header
- *
- * 93 Erik Bos (erik@trashcan.hacktic.nl)
- */
-
 #ifndef COMM_H
 #define COMM_H
 
-
 #define MAX_PORTS   16
 
 struct DosDeviceStruct {
@@ -19,4 +12,7 @@
     int baudrate;
 };
 
+extern void Comm_Init(void);
+extern void Comm_DeInit(void);
+
 #endif  /* COMM_H */
diff --git a/include/cursor.h b/include/cursor.h
index c70df90..a65f965 100644
--- a/include/cursor.h
+++ b/include/cursor.h
@@ -4,6 +4,8 @@
  * Copyright  Martin Ayotte, 1993
  *
  */
+#ifndef __WINE_CURSOR_H
+#define __WINE_CURSOR_H
 
 typedef struct {
 	BYTE	Width;
@@ -25,3 +27,6 @@
 	Cursor		xcursor;
 	} CURSORALLOC;
 
+extern void CURSOR_SetWinCursor( HWND hwnd, HCURSOR hcursor );   /* cursor.c */
+
+#endif /* __WINE_CURSOR_H */
diff --git a/include/dc.h b/include/dc.h
new file mode 100644
index 0000000..5723fa8
--- /dev/null
+++ b/include/dc.h
@@ -0,0 +1,13 @@
+#ifndef __WINE_DC_H
+#define __WINE_DC_H
+
+#include "gdi.h"
+
+extern void DC_InitDC( HDC hdc );
+extern int DC_SetupGCForBrush( DC * dc );
+extern int DC_SetupGCForPen( DC * dc );
+extern int DC_SetupGCForText( DC * dc );
+
+extern const int DC_XROPfunction[];
+
+#endif /* __WINE_DC_H */
diff --git a/include/debug.h b/include/debug.h
index 6bdc132..61713ce 100644
--- a/include/debug.h
+++ b/include/debug.h
@@ -1,7 +1,7 @@
 #include <stdio.h>
 
 #define stddeb stdout
-#define stdnimp stderr
+#define stdnimp stdout
 
 /* Do not remove this line or change anything below this line */
 
@@ -59,9 +59,11 @@
 #undef DEBUG_PROP
 #undef DEBUG_REG
 #undef DEBUG_REGION
+#undef DEBUG_RELAY
 #undef DEBUG_RESOURCE
 #undef DEBUG_SCROLL
 #undef DEBUG_SELECTORS
+#undef DEBUG_STACK
 #undef DEBUG_STRESS
 #undef DEBUG_SYSCOLOR
 #undef DEBUG_TASK
@@ -126,9 +128,11 @@
 #define DEBUG_PROP
 #define DEBUG_REG
 #define DEBUG_REGION
+#define DEBUG_RELAY
 #define DEBUG_RESOURCE
 #define DEBUG_SCROLL
 #define DEBUG_SELECTORS
+#define DEBUG_STACK
 #define DEBUG_STRESS
 #define DEBUG_SYSCOLOR
 #define DEBUG_TASK
@@ -407,6 +411,11 @@
 #else
     0,
 #endif
+#ifdef DEBUG_RELAY
+    1,
+#else
+    0,
+#endif
 #ifdef DEBUG_RESOURCE
     1,
 #else
@@ -422,6 +431,11 @@
 #else
     0,
 #endif
+#ifdef DEBUG_STACK
+    1,
+#else
+    0,
+#endif
 #ifdef DEBUG_STRESS
     1,
 #else
@@ -471,641 +485,859 @@
 
 #ifdef DEBUG_RUNTIME
 #define dprintf_accel if(debug_msg_enabled[0]) fprintf
+#define debugging_accel debug_msg_enabled[0]
 #else
 #ifdef DEBUG_ACCEL
 #define dprintf_accel fprintf
+#define debugging_accel 1
 #else
 #define dprintf_accel
+#define debugging_accel 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
 #define dprintf_bitmap if(debug_msg_enabled[1]) fprintf
+#define debugging_bitmap debug_msg_enabled[1]
 #else
 #ifdef DEBUG_BITMAP
 #define dprintf_bitmap fprintf
+#define debugging_bitmap 1
 #else
 #define dprintf_bitmap
+#define debugging_bitmap 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
 #define dprintf_callback if(debug_msg_enabled[2]) fprintf
+#define debugging_callback debug_msg_enabled[2]
 #else
 #ifdef DEBUG_CALLBACK
 #define dprintf_callback fprintf
+#define debugging_callback 1
 #else
 #define dprintf_callback
+#define debugging_callback 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
 #define dprintf_caret if(debug_msg_enabled[3]) fprintf
+#define debugging_caret debug_msg_enabled[3]
 #else
 #ifdef DEBUG_CARET
 #define dprintf_caret fprintf
+#define debugging_caret 1
 #else
 #define dprintf_caret
+#define debugging_caret 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
 #define dprintf_catch if(debug_msg_enabled[4]) fprintf
+#define debugging_catch debug_msg_enabled[4]
 #else
 #ifdef DEBUG_CATCH
 #define dprintf_catch fprintf
+#define debugging_catch 1
 #else
 #define dprintf_catch
+#define debugging_catch 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
 #define dprintf_cdaudio if(debug_msg_enabled[5]) fprintf
+#define debugging_cdaudio debug_msg_enabled[5]
 #else
 #ifdef DEBUG_CDAUDIO
 #define dprintf_cdaudio fprintf
+#define debugging_cdaudio 1
 #else
 #define dprintf_cdaudio
+#define debugging_cdaudio 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
 #define dprintf_class if(debug_msg_enabled[6]) fprintf
+#define debugging_class debug_msg_enabled[6]
 #else
 #ifdef DEBUG_CLASS
 #define dprintf_class fprintf
+#define debugging_class 1
 #else
 #define dprintf_class
+#define debugging_class 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
 #define dprintf_clipboard if(debug_msg_enabled[7]) fprintf
+#define debugging_clipboard debug_msg_enabled[7]
 #else
 #ifdef DEBUG_CLIPBOARD
 #define dprintf_clipboard fprintf
+#define debugging_clipboard 1
 #else
 #define dprintf_clipboard
+#define debugging_clipboard 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
 #define dprintf_clipping if(debug_msg_enabled[8]) fprintf
+#define debugging_clipping debug_msg_enabled[8]
 #else
 #ifdef DEBUG_CLIPPING
 #define dprintf_clipping fprintf
+#define debugging_clipping 1
 #else
 #define dprintf_clipping
+#define debugging_clipping 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
 #define dprintf_combo if(debug_msg_enabled[9]) fprintf
+#define debugging_combo debug_msg_enabled[9]
 #else
 #ifdef DEBUG_COMBO
 #define dprintf_combo fprintf
+#define debugging_combo 1
 #else
 #define dprintf_combo
+#define debugging_combo 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
 #define dprintf_comm if(debug_msg_enabled[10]) fprintf
+#define debugging_comm debug_msg_enabled[10]
 #else
 #ifdef DEBUG_COMM
 #define dprintf_comm fprintf
+#define debugging_comm 1
 #else
 #define dprintf_comm
+#define debugging_comm 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
 #define dprintf_cursor if(debug_msg_enabled[11]) fprintf
+#define debugging_cursor debug_msg_enabled[11]
 #else
 #ifdef DEBUG_CURSOR
 #define dprintf_cursor fprintf
+#define debugging_cursor 1
 #else
 #define dprintf_cursor
+#define debugging_cursor 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
 #define dprintf_dc if(debug_msg_enabled[12]) fprintf
+#define debugging_dc debug_msg_enabled[12]
 #else
 #ifdef DEBUG_DC
 #define dprintf_dc fprintf
+#define debugging_dc 1
 #else
 #define dprintf_dc
+#define debugging_dc 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
 #define dprintf_dialog if(debug_msg_enabled[13]) fprintf
+#define debugging_dialog debug_msg_enabled[13]
 #else
 #ifdef DEBUG_DIALOG
 #define dprintf_dialog fprintf
+#define debugging_dialog 1
 #else
 #define dprintf_dialog
+#define debugging_dialog 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
 #define dprintf_dll if(debug_msg_enabled[14]) fprintf
+#define debugging_dll debug_msg_enabled[14]
 #else
 #ifdef DEBUG_DLL
 #define dprintf_dll fprintf
+#define debugging_dll 1
 #else
 #define dprintf_dll
+#define debugging_dll 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
 #define dprintf_dosfs if(debug_msg_enabled[15]) fprintf
+#define debugging_dosfs debug_msg_enabled[15]
 #else
 #ifdef DEBUG_DOSFS
 #define dprintf_dosfs fprintf
+#define debugging_dosfs 1
 #else
 #define dprintf_dosfs
+#define debugging_dosfs 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
 #define dprintf_driver if(debug_msg_enabled[16]) fprintf
+#define debugging_driver debug_msg_enabled[16]
 #else
 #ifdef DEBUG_DRIVER
 #define dprintf_driver fprintf
+#define debugging_driver 1
 #else
 #define dprintf_driver
+#define debugging_driver 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
 #define dprintf_edit if(debug_msg_enabled[17]) fprintf
+#define debugging_edit debug_msg_enabled[17]
 #else
 #ifdef DEBUG_EDIT
 #define dprintf_edit fprintf
+#define debugging_edit 1
 #else
 #define dprintf_edit
+#define debugging_edit 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
 #define dprintf_enum if(debug_msg_enabled[18]) fprintf
+#define debugging_enum debug_msg_enabled[18]
 #else
 #ifdef DEBUG_ENUM
 #define dprintf_enum fprintf
+#define debugging_enum 1
 #else
 #define dprintf_enum
+#define debugging_enum 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
 #define dprintf_event if(debug_msg_enabled[19]) fprintf
+#define debugging_event debug_msg_enabled[19]
 #else
 #ifdef DEBUG_EVENT
 #define dprintf_event fprintf
+#define debugging_event 1
 #else
 #define dprintf_event
+#define debugging_event 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
 #define dprintf_exec if(debug_msg_enabled[20]) fprintf
+#define debugging_exec debug_msg_enabled[20]
 #else
 #ifdef DEBUG_EXEC
 #define dprintf_exec fprintf
+#define debugging_exec 1
 #else
 #define dprintf_exec
+#define debugging_exec 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
 #define dprintf_file if(debug_msg_enabled[21]) fprintf
+#define debugging_file debug_msg_enabled[21]
 #else
 #ifdef DEBUG_FILE
 #define dprintf_file fprintf
+#define debugging_file 1
 #else
 #define dprintf_file
+#define debugging_file 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
 #define dprintf_fixup if(debug_msg_enabled[22]) fprintf
+#define debugging_fixup debug_msg_enabled[22]
 #else
 #ifdef DEBUG_FIXUP
 #define dprintf_fixup fprintf
+#define debugging_fixup 1
 #else
 #define dprintf_fixup
+#define debugging_fixup 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
 #define dprintf_font if(debug_msg_enabled[23]) fprintf
+#define debugging_font debug_msg_enabled[23]
 #else
 #ifdef DEBUG_FONT
 #define dprintf_font fprintf
+#define debugging_font 1
 #else
 #define dprintf_font
+#define debugging_font 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
 #define dprintf_gdi if(debug_msg_enabled[24]) fprintf
+#define debugging_gdi debug_msg_enabled[24]
 #else
 #ifdef DEBUG_GDI
 #define dprintf_gdi fprintf
+#define debugging_gdi 1
 #else
 #define dprintf_gdi
+#define debugging_gdi 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
 #define dprintf_graphics if(debug_msg_enabled[25]) fprintf
+#define debugging_graphics debug_msg_enabled[25]
 #else
 #ifdef DEBUG_GRAPHICS
 #define dprintf_graphics fprintf
+#define debugging_graphics 1
 #else
 #define dprintf_graphics
+#define debugging_graphics 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
 #define dprintf_heap if(debug_msg_enabled[26]) fprintf
+#define debugging_heap debug_msg_enabled[26]
 #else
 #ifdef DEBUG_HEAP
 #define dprintf_heap fprintf
+#define debugging_heap 1
 #else
 #define dprintf_heap
+#define debugging_heap 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
 #define dprintf_icon if(debug_msg_enabled[27]) fprintf
+#define debugging_icon debug_msg_enabled[27]
 #else
 #ifdef DEBUG_ICON
 #define dprintf_icon fprintf
+#define debugging_icon 1
 #else
 #define dprintf_icon
+#define debugging_icon 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
 #define dprintf_int if(debug_msg_enabled[28]) fprintf
+#define debugging_int debug_msg_enabled[28]
 #else
 #ifdef DEBUG_INT
 #define dprintf_int fprintf
+#define debugging_int 1
 #else
 #define dprintf_int
+#define debugging_int 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
 #define dprintf_key if(debug_msg_enabled[29]) fprintf
+#define debugging_key debug_msg_enabled[29]
 #else
 #ifdef DEBUG_KEY
 #define dprintf_key fprintf
+#define debugging_key 1
 #else
 #define dprintf_key
+#define debugging_key 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
 #define dprintf_keyboard if(debug_msg_enabled[30]) fprintf
+#define debugging_keyboard debug_msg_enabled[30]
 #else
 #ifdef DEBUG_KEYBOARD
 #define dprintf_keyboard fprintf
+#define debugging_keyboard 1
 #else
 #define dprintf_keyboard
+#define debugging_keyboard 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
 #define dprintf_ldt if(debug_msg_enabled[31]) fprintf
+#define debugging_ldt debug_msg_enabled[31]
 #else
 #ifdef DEBUG_LDT
 #define dprintf_ldt fprintf
+#define debugging_ldt 1
 #else
 #define dprintf_ldt
+#define debugging_ldt 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
 #define dprintf_listbox if(debug_msg_enabled[32]) fprintf
+#define debugging_listbox debug_msg_enabled[32]
 #else
 #ifdef DEBUG_LISTBOX
 #define dprintf_listbox fprintf
+#define debugging_listbox 1
 #else
 #define dprintf_listbox
+#define debugging_listbox 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
 #define dprintf_mci if(debug_msg_enabled[33]) fprintf
+#define debugging_mci debug_msg_enabled[33]
 #else
 #ifdef DEBUG_MCI
 #define dprintf_mci fprintf
+#define debugging_mci 1
 #else
 #define dprintf_mci
+#define debugging_mci 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
 #define dprintf_mcianim if(debug_msg_enabled[34]) fprintf
+#define debugging_mcianim debug_msg_enabled[34]
 #else
 #ifdef DEBUG_MCIANIM
 #define dprintf_mcianim fprintf
+#define debugging_mcianim 1
 #else
 #define dprintf_mcianim
+#define debugging_mcianim 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
 #define dprintf_mciwave if(debug_msg_enabled[35]) fprintf
+#define debugging_mciwave debug_msg_enabled[35]
 #else
 #ifdef DEBUG_MCIWAVE
 #define dprintf_mciwave fprintf
+#define debugging_mciwave 1
 #else
 #define dprintf_mciwave
+#define debugging_mciwave 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
 #define dprintf_mdi if(debug_msg_enabled[36]) fprintf
+#define debugging_mdi debug_msg_enabled[36]
 #else
 #ifdef DEBUG_MDI
 #define dprintf_mdi fprintf
+#define debugging_mdi 1
 #else
 #define dprintf_mdi
+#define debugging_mdi 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
 #define dprintf_menu if(debug_msg_enabled[37]) fprintf
+#define debugging_menu debug_msg_enabled[37]
 #else
 #ifdef DEBUG_MENU
 #define dprintf_menu fprintf
+#define debugging_menu 1
 #else
 #define dprintf_menu
+#define debugging_menu 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
 #define dprintf_menucalc if(debug_msg_enabled[38]) fprintf
+#define debugging_menucalc debug_msg_enabled[38]
 #else
 #ifdef DEBUG_MENUCALC
 #define dprintf_menucalc fprintf
+#define debugging_menucalc 1
 #else
 #define dprintf_menucalc
+#define debugging_menucalc 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
 #define dprintf_message if(debug_msg_enabled[39]) fprintf
+#define debugging_message debug_msg_enabled[39]
 #else
 #ifdef DEBUG_MESSAGE
 #define dprintf_message fprintf
+#define debugging_message 1
 #else
 #define dprintf_message
+#define debugging_message 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
 #define dprintf_metafile if(debug_msg_enabled[40]) fprintf
+#define debugging_metafile debug_msg_enabled[40]
 #else
 #ifdef DEBUG_METAFILE
 #define dprintf_metafile fprintf
+#define debugging_metafile 1
 #else
 #define dprintf_metafile
+#define debugging_metafile 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
 #define dprintf_midi if(debug_msg_enabled[41]) fprintf
+#define debugging_midi debug_msg_enabled[41]
 #else
 #ifdef DEBUG_MIDI
 #define dprintf_midi fprintf
+#define debugging_midi 1
 #else
 #define dprintf_midi
+#define debugging_midi 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
 #define dprintf_mmio if(debug_msg_enabled[42]) fprintf
+#define debugging_mmio debug_msg_enabled[42]
 #else
 #ifdef DEBUG_MMIO
 #define dprintf_mmio fprintf
+#define debugging_mmio 1
 #else
 #define dprintf_mmio
+#define debugging_mmio 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
 #define dprintf_mmtime if(debug_msg_enabled[43]) fprintf
+#define debugging_mmtime debug_msg_enabled[43]
 #else
 #ifdef DEBUG_MMTIME
 #define dprintf_mmtime fprintf
+#define debugging_mmtime 1
 #else
 #define dprintf_mmtime
+#define debugging_mmtime 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
 #define dprintf_module if(debug_msg_enabled[44]) fprintf
+#define debugging_module debug_msg_enabled[44]
 #else
 #ifdef DEBUG_MODULE
 #define dprintf_module fprintf
+#define debugging_module 1
 #else
 #define dprintf_module
+#define debugging_module 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
 #define dprintf_msg if(debug_msg_enabled[45]) fprintf
+#define debugging_msg debug_msg_enabled[45]
 #else
 #ifdef DEBUG_MSG
 #define dprintf_msg fprintf
+#define debugging_msg 1
 #else
 #define dprintf_msg
+#define debugging_msg 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
 #define dprintf_msgbox if(debug_msg_enabled[46]) fprintf
+#define debugging_msgbox debug_msg_enabled[46]
 #else
 #ifdef DEBUG_MSGBOX
 #define dprintf_msgbox fprintf
+#define debugging_msgbox 1
 #else
 #define dprintf_msgbox
+#define debugging_msgbox 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
 #define dprintf_nonclient if(debug_msg_enabled[47]) fprintf
+#define debugging_nonclient debug_msg_enabled[47]
 #else
 #ifdef DEBUG_NONCLIENT
 #define dprintf_nonclient fprintf
+#define debugging_nonclient 1
 #else
 #define dprintf_nonclient
+#define debugging_nonclient 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
 #define dprintf_palette if(debug_msg_enabled[48]) fprintf
+#define debugging_palette debug_msg_enabled[48]
 #else
 #ifdef DEBUG_PALETTE
 #define dprintf_palette fprintf
+#define debugging_palette 1
 #else
 #define dprintf_palette
+#define debugging_palette 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
 #define dprintf_profile if(debug_msg_enabled[49]) fprintf
+#define debugging_profile debug_msg_enabled[49]
 #else
 #ifdef DEBUG_PROFILE
 #define dprintf_profile fprintf
+#define debugging_profile 1
 #else
 #define dprintf_profile
+#define debugging_profile 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
 #define dprintf_prop if(debug_msg_enabled[50]) fprintf
+#define debugging_prop debug_msg_enabled[50]
 #else
 #ifdef DEBUG_PROP
 #define dprintf_prop fprintf
+#define debugging_prop 1
 #else
 #define dprintf_prop
+#define debugging_prop 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
 #define dprintf_reg if(debug_msg_enabled[51]) fprintf
+#define debugging_reg debug_msg_enabled[51]
 #else
 #ifdef DEBUG_REG
 #define dprintf_reg fprintf
+#define debugging_reg 1
 #else
 #define dprintf_reg
+#define debugging_reg 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
 #define dprintf_region if(debug_msg_enabled[52]) fprintf
+#define debugging_region debug_msg_enabled[52]
 #else
 #ifdef DEBUG_REGION
 #define dprintf_region fprintf
+#define debugging_region 1
 #else
 #define dprintf_region
+#define debugging_region 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
-#define dprintf_resource if(debug_msg_enabled[53]) fprintf
+#define dprintf_relay if(debug_msg_enabled[53]) fprintf
+#define debugging_relay debug_msg_enabled[53]
+#else
+#ifdef DEBUG_RELAY
+#define dprintf_relay fprintf
+#define debugging_relay 1
+#else
+#define dprintf_relay
+#define debugging_relay 0
+#endif
+#endif
+
+#ifdef DEBUG_RUNTIME
+#define dprintf_resource if(debug_msg_enabled[54]) fprintf
+#define debugging_resource debug_msg_enabled[54]
 #else
 #ifdef DEBUG_RESOURCE
 #define dprintf_resource fprintf
+#define debugging_resource 1
 #else
 #define dprintf_resource
+#define debugging_resource 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
-#define dprintf_scroll if(debug_msg_enabled[54]) fprintf
+#define dprintf_scroll if(debug_msg_enabled[55]) fprintf
+#define debugging_scroll debug_msg_enabled[55]
 #else
 #ifdef DEBUG_SCROLL
 #define dprintf_scroll fprintf
+#define debugging_scroll 1
 #else
 #define dprintf_scroll
+#define debugging_scroll 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
-#define dprintf_selectors if(debug_msg_enabled[55]) fprintf
+#define dprintf_selectors if(debug_msg_enabled[56]) fprintf
+#define debugging_selectors debug_msg_enabled[56]
 #else
 #ifdef DEBUG_SELECTORS
 #define dprintf_selectors fprintf
+#define debugging_selectors 1
 #else
 #define dprintf_selectors
+#define debugging_selectors 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
-#define dprintf_stress if(debug_msg_enabled[56]) fprintf
+#define dprintf_stack if(debug_msg_enabled[57]) fprintf
+#define debugging_stack debug_msg_enabled[57]
+#else
+#ifdef DEBUG_STACK
+#define dprintf_stack fprintf
+#define debugging_stack 1
+#else
+#define dprintf_stack
+#define debugging_stack 0
+#endif
+#endif
+
+#ifdef DEBUG_RUNTIME
+#define dprintf_stress if(debug_msg_enabled[58]) fprintf
+#define debugging_stress debug_msg_enabled[58]
 #else
 #ifdef DEBUG_STRESS
 #define dprintf_stress fprintf
+#define debugging_stress 1
 #else
 #define dprintf_stress
+#define debugging_stress 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
-#define dprintf_syscolor if(debug_msg_enabled[57]) fprintf
+#define dprintf_syscolor if(debug_msg_enabled[59]) fprintf
+#define debugging_syscolor debug_msg_enabled[59]
 #else
 #ifdef DEBUG_SYSCOLOR
 #define dprintf_syscolor fprintf
+#define debugging_syscolor 1
 #else
 #define dprintf_syscolor
+#define debugging_syscolor 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
-#define dprintf_task if(debug_msg_enabled[58]) fprintf
+#define dprintf_task if(debug_msg_enabled[60]) fprintf
+#define debugging_task debug_msg_enabled[60]
 #else
 #ifdef DEBUG_TASK
 #define dprintf_task fprintf
+#define debugging_task 1
 #else
 #define dprintf_task
+#define debugging_task 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
-#define dprintf_text if(debug_msg_enabled[59]) fprintf
+#define dprintf_text if(debug_msg_enabled[61]) fprintf
+#define debugging_text debug_msg_enabled[61]
 #else
 #ifdef DEBUG_TEXT
 #define dprintf_text fprintf
+#define debugging_text 1
 #else
 #define dprintf_text
+#define debugging_text 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
-#define dprintf_timer if(debug_msg_enabled[60]) fprintf
+#define dprintf_timer if(debug_msg_enabled[62]) fprintf
+#define debugging_timer debug_msg_enabled[62]
 #else
 #ifdef DEBUG_TIMER
 #define dprintf_timer fprintf
+#define debugging_timer 1
 #else
 #define dprintf_timer
+#define debugging_timer 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
-#define dprintf_utility if(debug_msg_enabled[61]) fprintf
+#define dprintf_utility if(debug_msg_enabled[63]) fprintf
+#define debugging_utility debug_msg_enabled[63]
 #else
 #ifdef DEBUG_UTILITY
 #define dprintf_utility fprintf
+#define debugging_utility 1
 #else
 #define dprintf_utility
+#define debugging_utility 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
-#define dprintf_win if(debug_msg_enabled[62]) fprintf
+#define dprintf_win if(debug_msg_enabled[64]) fprintf
+#define debugging_win debug_msg_enabled[64]
 #else
 #ifdef DEBUG_WIN
 #define dprintf_win fprintf
+#define debugging_win 1
 #else
 #define dprintf_win
+#define debugging_win 0
 #endif
 #endif
 
 #ifdef DEBUG_RUNTIME
-#define dprintf_winsock if(debug_msg_enabled[63]) fprintf
+#define dprintf_winsock if(debug_msg_enabled[65]) fprintf
+#define debugging_winsock debug_msg_enabled[65]
 #else
 #ifdef DEBUG_WINSOCK
 #define dprintf_winsock fprintf
+#define debugging_winsock 1
 #else
 #define dprintf_winsock
+#define debugging_winsock 0
 #endif
 #endif
 
@@ -1166,9 +1398,11 @@
     "prop",
     "reg",
     "region",
+    "relay",
     "resource",
     "scroll",
     "selectors",
+    "stack",
     "stress",
     "syscolor",
     "task",
diff --git a/include/dialog.h b/include/dialog.h
index 1c9cf34..ad4b9de 100644
--- a/include/dialog.h
+++ b/include/dialog.h
@@ -9,6 +9,11 @@
 
 #include "windows.h"
 
+extern BOOL DIALOG_Init(void);
+extern HWND DIALOG_GetFirstTabItem( HWND hwndDlg );
+extern int DialogBoxIndirectPtr( HINSTANCE hInst, LPCSTR dlgTemplate,
+                          HWND owner, WNDPROC dlgProc);
+
 #pragma pack(1)
 
   /* Dialog info structure.
diff --git a/include/dos_fs.h b/include/dos_fs.h
new file mode 100644
index 0000000..79b5ce4
--- /dev/null
+++ b/include/dos_fs.h
@@ -0,0 +1,35 @@
+#ifndef __WINE_DOS_FS_H
+#define __WINE_DOS_FS_H
+
+#include <wintypes.h>
+
+extern void DOS_InitFS(void);
+extern WORD DOS_GetEquipment(void);
+extern int DOS_ValidDrive(int drive);
+extern int DOS_GetDefaultDrive(void); 
+extern void DOS_SetDefaultDrive(int drive);
+extern void ToUnix(char *s); 
+extern void ToDos(char *s); 
+extern void ChopOffSlash(char *string);
+extern int DOS_DisableDrive(int drive);
+extern int DOS_EnableDrive(int drive); 
+extern char *DOS_GetUnixFileName(char *dosfilename);
+extern char *DOS_GetDosFileName(char *unixfilename);
+extern char *DOS_GetCurrentDir(int drive);
+extern int DOS_ChangeDir(int drive, char *dirname);
+extern int DOS_MakeDir(int drive, char *dirname);
+extern int DOS_GetSerialNumber(int drive, unsigned long *serialnumber); 
+extern int DOS_SetSerialNumber(int drive, unsigned long serialnumber); 
+extern char *DOS_GetVolumeLabel(int drive);
+extern int DOS_SetVolumeLabel(int drive, char *label);
+extern int DOS_GetFreeSpace(int drive, long *size, long *available);
+extern char *DOS_FindFile(char *buffer, int buflen, char *rootname, char **extensions, char *path);
+extern char *WineIniFileName(void);
+extern char *WinIniFileName(void); 
+extern struct dosdirent *DOS_opendir(char *dosdirname); 
+extern struct dosdirent *DOS_readdir(struct dosdirent *de);
+extern void DOS_closedir(struct dosdirent *de);
+
+extern char WindowsPath[256];
+
+#endif /* __WINE_DOS_FS_H */
diff --git a/include/event.h b/include/event.h
new file mode 100644
index 0000000..0d1689f
--- /dev/null
+++ b/include/event.h
@@ -0,0 +1,7 @@
+#ifndef __WINE_EVENT_H
+#define __WINE_EVENT_H
+
+extern void EVENT_ProcessEvent( XEvent *event );  /* event.c */
+extern void EVENT_RegisterWindow( Window w, HWND hwnd );  /* event.c */
+
+#endif /* __WINE_EVENT_H */
diff --git a/include/font.h b/include/font.h
new file mode 100644
index 0000000..40c24d6
--- /dev/null
+++ b/include/font.h
@@ -0,0 +1,8 @@
+#ifndef __WINE_FONT_H
+#define __WINE_FONT_H
+
+extern void Font_Init( void );
+extern int FONT_GetObject( FONTOBJ * font, int count, LPSTR buffer );
+extern HFONT FONT_SelectObject( DC * dc, HFONT hfont, FONTOBJ * font );
+
+#endif /* __WINE_FONT_H */
diff --git a/include/gdi.h b/include/gdi.h
index b689035..6aae216 100644
--- a/include/gdi.h
+++ b/include/gdi.h
@@ -299,6 +299,7 @@
 
 #endif
 
+extern BOOL GDI_Init(void);
 extern HANDLE GDI_AllocObject( WORD, WORD );
 extern BOOL GDI_FreeObject( HANDLE );
 extern GDIOBJHDR * GDI_GetObjPtr( HANDLE, WORD );
@@ -307,5 +308,6 @@
 extern Screen * screen;
 extern Window rootWindow;
 extern int screenWidth, screenHeight, screenDepth;
+extern int desktopX, desktopY;   /* misc/main.c */
 
 #endif  /* GDI_H */
diff --git a/include/graphics.h b/include/graphics.h
new file mode 100644
index 0000000..a9580f5
--- /dev/null
+++ b/include/graphics.h
@@ -0,0 +1,9 @@
+#ifndef __WINE_GRAPHICS_H
+#define __WINE_GRAPHICS_H
+
+extern void GRAPH_DrawReliefRect( HDC hdc, RECT *rect, int highlight_size,
+                                  int shadow_size, BOOL pressed );
+extern BOOL GRAPH_DrawBitmap( HDC hdc, HBITMAP hbitmap, int xdest, int ydest,
+                          int xsrc, int ysrc, int width, int height, int rop );
+
+#endif /* __WINE_GRAPHICS */
diff --git a/include/heap.h b/include/heap.h
index ff4321a..fd234de 100644
--- a/include/heap.h
+++ b/include/heap.h
@@ -35,11 +35,24 @@
 extern int  HEAP_Free(MDESC **free_list, void *block);
 extern void *HEAP_ReAlloc(MDESC **free_list, void *old_block, 
 			  int new_size, unsigned int flags);
+
 extern LHEAP *HEAP_LocalFindHeap(unsigned short owner);
 extern unsigned int HEAP_LocalSize(MDESC **free_list, unsigned int handle);
 extern void HEAP_LocalInit(unsigned short owner, void *start, int length);
 
+extern void *WIN16_LocalAlloc(int flags, int bytes);
+extern int WIN16_LocalCompact(int min_free);
+extern unsigned int WIN16_LocalFlags(unsigned int handle);
+extern unsigned int WIN16_LocalFree(unsigned int handle);
+extern void *WIN16_LocalLock(unsigned int handle);
+extern void *WIN16_LocalReAlloc(unsigned int handle, int flags, int bytes);
+extern unsigned int WIN16_LocalUnlock(unsigned int handle);
+
+#if 0
 #define HEAP_OWNER	(Segments[Stack16Frame[11] >> 3].owner)
+#endif
+/* Use ds instead of owner of cs */
+#define HEAP_OWNER	Stack16Frame[6]
 #define LOCALHEAP()	(&HEAP_LocalFindHeap(HEAP_OWNER)->free_list)
 #define LOCALATOMTABLE() (&HEAP_LocalFindHeap(HEAP_OWNER)->local_table)
 
diff --git a/include/if1632.h b/include/if1632.h
new file mode 100644
index 0000000..1cf7637
--- /dev/null
+++ b/include/if1632.h
@@ -0,0 +1,19 @@
+#ifndef __WINE_IF1632_H
+#define __WINE_IF1632_H
+
+#include <wintypes.h>
+
+extern int CallToInit16(unsigned long csip, unsigned long sssp, 
+			unsigned short ds);
+extern int CallTo16cx(unsigned long csip, unsigned long dscx);
+extern int CallToDllEntry(unsigned long csip, unsigned long dscx, unsigned short di);
+extern int CallBack16(void *func, int n_args, ...);
+extern void *CALLBACK_MakeProcInstance(void *func, int instance);
+extern void CallLineDDAProc(FARPROC func, short xPos, short yPos, long lParam);
+extern void winestat(void);
+extern int DLLRelay(unsigned int func_num, unsigned int seg_off);
+extern struct dll_table_entry_s *FindDLLTable(char *dll_name);
+extern int FindOrdinalFromName(struct dll_table_entry_s *dll_table, char *func_name);
+extern int ReturnArg(int arg);
+
+#endif /* __WINE_IF1632_H */
diff --git a/include/kernel.h b/include/kernel.h
new file mode 100644
index 0000000..f8bf0f5
--- /dev/null
+++ b/include/kernel.h
@@ -0,0 +1,4 @@
+extern int KERNEL_LockSegment(int segment);
+extern int KERNEL_UnlockSegment(int segment);
+extern KERNEL_InitTask(void);
+extern int KERNEL_WaitEvent(int task);
diff --git a/include/library.h b/include/library.h
new file mode 100644
index 0000000..e161d66
--- /dev/null
+++ b/include/library.h
@@ -0,0 +1,14 @@
+#ifndef __WINE_LIBRARY_H
+#define __WINE_LIBRARY_H
+
+extern HINSTANCE hInstMain;
+extern HINSTANCE hSysRes;
+extern struct w_files *GetFileInfo(unsigned short instance);
+extern int IsDLLLoaded(char *name);
+extern void InitDLL(struct w_files *wpnt);
+extern void InitializeLoadedDLLs(struct w_files *wpnt);
+extern HINSTANCE LoadImage(char *module, int filetype, int change_dir);
+
+extern struct dll_name_table_entry_s dll_builtin_table[];
+
+#endif /* __WINE_LIBRARY_H */
diff --git a/include/listbox.h b/include/listbox.h
index 7000943..1e56b7f 100644
--- a/include/listbox.h
+++ b/include/listbox.h
@@ -14,8 +14,8 @@
 
 
 typedef struct tagHEADLIST {
-	short	FirstVisible;
-	short	ItemsCount;
+	UINT	FirstVisible;
+	UINT	ItemsCount;
 	short	ItemsVisible;
 	short	ColumnsVisible;
 	short	ItemsPerColumn;
diff --git a/include/mdi.h b/include/mdi.h
index 40f4399..73ebb4d 100644
--- a/include/mdi.h
+++ b/include/mdi.h
@@ -11,6 +11,9 @@
 #include "windows.h"
 
 #define MDI_MAXLISTLENGTH	64
+extern LONG MDIClientWndProc(HWND hwnd, WORD message, 
+			     WORD wParam, LONG lParam); /* mdi.c */
+
 
 typedef struct mdi_child_info_s
 {
diff --git a/include/menu.h b/include/menu.h
index fad8bb1..d471eec 100644
--- a/include/menu.h
+++ b/include/menu.h
@@ -8,6 +8,15 @@
 
 #define MENU_MAGIC   0x554d  /* 'MU' */
 
+extern BOOL MENU_Init(void);
+extern WORD MENU_GetMenuBarHeight( HWND hwnd, WORD menubarWidth,
+				   int orgX, int orgY );         /* menu.c */
+extern void MENU_TrackMouseMenuBar( HWND hwnd, POINT pt );       /* menu.c */
+extern void MENU_TrackKbdMenuBar( HWND hwnd, WORD wParam );      /* menu.c */
+extern WORD MENU_DrawMenuBar( HDC hDC, LPRECT lprect,
+			      HWND hwnd, BOOL suppress_draw );   /* menu.c */
+extern HMENU CopySysMenu(); /* menu.c */
+
 
 typedef struct tagMENUITEM
 {
diff --git a/include/miscemu.h b/include/miscemu.h
new file mode 100644
index 0000000..a24bfae
--- /dev/null
+++ b/include/miscemu.h
@@ -0,0 +1,25 @@
+#ifndef __WINE_MISCEMU_H
+#define __WINE_MISCEMU_H
+
+extern int do_int10(struct sigcontext_struct *);
+extern int do_int13(struct sigcontext_struct *);
+extern int do_int15(struct sigcontext_struct *);
+extern int do_int16(struct sigcontext_struct *);
+extern int do_int1a(struct sigcontext_struct *);
+extern int do_int21(struct sigcontext_struct *);
+extern int do_int25(struct sigcontext_struct *);
+extern int do_int26(struct sigcontext_struct *);
+extern int do_int2a(struct sigcontext_struct *);
+extern int do_int2f(struct sigcontext_struct *);
+extern int do_int31(struct sigcontext_struct *);
+
+extern void inportb(struct sigcontext_struct *context);
+extern void inport(struct sigcontext_struct *context);
+extern void outportb(struct sigcontext_struct *context);
+extern void outport(struct sigcontext_struct *context);
+
+extern void IntBarf(int i, struct sigcontext_struct *context);
+
+extern void INT21_Init(void);
+
+#endif /* __WINE_MISCEMU_H */
diff --git a/include/msdos.h b/include/msdos.h
index 0529883..31bf3fb 100644
--- a/include/msdos.h
+++ b/include/msdos.h
@@ -1,7 +1,9 @@
 #ifndef __MSDOS_H
 #define __MSDOS_H
+
 #include <dirent.h>
 #include <windows.h>
+#include "comm.h"
 
 struct dosdirent {
 	int  inuse;
@@ -30,6 +32,10 @@
 #define DOSVERSION 0x0330;
 #define MAX_DOS_DRIVES	26
 
+extern WORD ExtendedError;
+extern struct DosDeviceStruct COM[MAX_PORTS];
+extern struct DosDeviceStruct LPT[MAX_PORTS];
+
 #define segment(a) 	((DWORD)(a) >> 16)
 #define offset(a)	((DWORD)(a) & 0xffff)
 
diff --git a/include/ne_image.h b/include/ne_image.h
new file mode 100644
index 0000000..df89336
--- /dev/null
+++ b/include/ne_image.h
@@ -0,0 +1,10 @@
+#ifndef __WINE_NE_IMAGE_H
+#define __WINE_NE_IMAGE_H
+
+extern int NE_FixupSegment(struct w_files *wpnt, int segment_num);
+extern int NE_unloadImage(struct w_files *wpnt);
+extern int NE_StartProgram(struct w_files *wpnt);
+extern void NE_InitDLL(struct w_files *wpnt);
+extern HINSTANCE NE_LoadImage(struct w_files *wpnt);
+
+#endif /* __WINE_NE_IMAGE_H */
diff --git a/include/nonclient.h b/include/nonclient.h
new file mode 100644
index 0000000..87bc71e
--- /dev/null
+++ b/include/nonclient.h
@@ -0,0 +1,13 @@
+#ifndef __WINE_NONCLIENT_H
+#define __WINE_NONCLIENT_H
+
+extern LONG NC_HandleNCPaint( HWND hwnd, HRGN hrgn );
+extern LONG NC_HandleNCActivate( HWND hwnd, WORD wParam );
+extern LONG NC_HandleNCCalcSize( HWND hwnd, NCCALCSIZE_PARAMS *params );
+extern LONG NC_HandleNCHitTest( HWND hwnd, POINT pt );
+extern LONG NC_HandleNCLButtonDown( HWND hwnd, WORD wParam, LONG lParam );
+extern LONG NC_HandleNCLButtonDblClk( HWND hwnd, WORD wParam, LONG lParam );
+extern LONG NC_HandleSysCommand( HWND hwnd, WORD wParam, POINT pt );
+extern LONG NC_HandleSetCursor( HWND hwnd, WORD wParam, LONG lParam );
+
+#endif /* __WINE_NONCLIENT_H */
diff --git a/include/options.h b/include/options.h
index e8bed9f..317f9c1 100644
--- a/include/options.h
+++ b/include/options.h
@@ -16,7 +16,6 @@
     int    synchronous;     /* X synchronous mode */
     int    backingstore;    /* Use backing store */
     short  cmdShow;
-    int    relay_debug;
     int    debug;
 };
 
diff --git a/include/pe_image.h b/include/pe_image.h
new file mode 100644
index 0000000..5259603
--- /dev/null
+++ b/include/pe_image.h
@@ -0,0 +1,10 @@
+#ifndef __WINE_PE_IMAGE_H
+#define __WINE_PE_IMAGE_H
+
+extern int PE_unloadImage(struct w_files *wpnt);
+extern int PE_StartProgram(struct w_files *wpnt);
+extern void PE_InitDLL(struct w_files *wpnt);
+extern HINSTANCE PE_LoadImage(struct w_files *wpnt);
+extern void my_wcstombs(char * result, u_short * source, int len);
+
+#endif /* __WINE_PE_IMAGE_H */
diff --git a/include/prototypes.h b/include/prototypes.h
index 2b94d25..ebde9cd 100644
--- a/include/prototypes.h
+++ b/include/prototypes.h
@@ -10,22 +10,12 @@
 
 #include "neexe.h"
 #include "segmem.h"
-#include "wine.h"
 #include "heap.h"
 #include "msdos.h"
 #include "windows.h"
 
 #ifndef WINELIB
 
-/* loader/dump.c */
-
-extern void PrintFileHeader(struct ne_header_s *ne_header);
-extern void PrintSegmentTable(struct ne_segment_table_entry_s *seg_table, 
-				int nentries);
-extern void PrintRelocationTable(char *exe_ptr, 
-				struct ne_segment_table_entry_s *seg_entry_p, 
-				int segment);
-
 /* loader/ldtlib.c */
 
 struct segment_descriptor *
@@ -37,153 +27,40 @@
 
 /* loader/resource.c */
 
-extern int OpenResourceFile(HANDLE instance);
 extern HBITMAP ConvertCoreBitmap( HDC hdc, BITMAPCOREHEADER * image );
 extern HBITMAP ConvertInfoBitmap( HDC hdc, BITMAPINFO * image );
 
-/* loader/selector.c */
-
-extern int FindUnusedSelectors(int n_selectors);
-extern int IPCCopySelector(int i_old, unsigned long new, int swap_type);
-extern WORD AllocSelector(WORD old_selector);
-extern unsigned int PrestoChangoSelector(unsigned src_selector, unsigned dst_selector);
-extern WORD AllocDStoCSAlias(WORD ds_selector);
-extern WORD FreeSelector(WORD sel);
-extern SEGDESC *CreateNewSegments(int code_flag, int read_only, int length, 
-					int n_segments);
-extern SEGDESC *GetNextSegment(unsigned int flags, unsigned int limit);
-extern unsigned int GetEntryDLLName(char *dll_name, char *function, int *sel,
-					int *addr);
-extern unsigned int GetEntryDLLOrdinal(char *dll_name, int ordinal, int *sel,
-					int *addr);
-
 /* loader/signal.c */
 
 extern int init_wine_signals(void);
+extern void wine_debug(int signal, int * regs);
 
 /* loader/wine.c */
 
 extern void myerror(const char *s);
-extern void load_mz_header (int, struct mz_header_s *);
-extern void load_ne_header (int, struct ne_header_s *);
 
 extern char *GetFilenameFromInstance(unsigned short instance);
 extern HINSTANCE LoadImage(char *modulename, int filetype, int change_dir);
 extern int _WinMain(int argc, char **argv);
 extern void InitializeLoadedDLLs();
 
-/* if1632/relay.c */
-
-extern int CallBack16(void *func, int n_args, ...);
-extern void *CALLBACK_MakeProcInstance(void *func, int instance);
-extern void CallLineDDAProc(FARPROC func, short xPos, short yPos, long lParam);
-extern void winestat(void);
-
-/* if1632/callback.c */
-
-extern int DLLRelay(unsigned int func_num, unsigned int seg_off);
-extern struct dll_table_entry_s *FindDLLTable(char *dll_name);
-extern int FindOrdinalFromName(struct dll_table_entry_s *dll_table, char *func_name);
-extern int ReturnArg(int arg);
-
-/* miscemu/int1a.c */
-
-extern do_int1A(struct sigcontext_struct *context);
-
-/* miscemu/int21.c */
-
-extern do_int21(struct sigcontext_struct *context);
-
-/* miscemu/kernel.c */
-
 extern int KERNEL_LockSegment(int segment);
 extern int KERNEL_UnlockSegment(int segment);
-extern KERNEL_InitTask();
+extern void KERNEL_InitTask(void);
 extern int KERNEL_WaitEvent(int task);
 
-/* misc/comm.c */
-
-void Comm_Init(void);
-void Comm_DeInit(void);
-
-/* misc/dos_fs.c */
-
-extern void DOS_InitFS(void);
-extern WORD DOS_GetEquipment(void);
-extern int DOS_ValidDrive(int drive);
-extern int DOS_GetDefaultDrive(void); 
-extern void DOS_SetDefaultDrive(int drive);
-extern void ToUnix(char *s); 
-extern void ToDos(char *s); 
-extern void ChopOffSlash(char *string);
-extern int DOS_DisableDrive(int drive);
-extern int DOS_EnableDrive(int drive); 
-extern char *GetUnixFileName(char *dosfilename);
-extern char *DOS_GetCurrentDir(int drive);
-extern int DOS_ChangeDir(int drive, char *dirname);
-extern int DOS_MakeDir(int drive, char *dirname);
-extern int DOS_GetSerialNumber(int drive, unsigned long *serialnumber); 
-extern int DOS_SetSerialNumber(int drive, unsigned long serialnumber); 
-extern char *DOS_GetVolumeLabel(int drive);
-extern int DOS_SetVolumeLabel(int drive, char *label);
-extern int DOS_GetFreeSpace(int drive, long *size, long *available);
-extern char *FindFile(char *buffer, int buflen, char *rootname, char **extensions, char *path);
-extern char *WineIniFileName(void);
-extern char *WinIniFileName(void); 
-extern struct dosdirent *DOS_opendir(char *dosdirname); 
-extern struct dosdirent *DOS_readdir(struct dosdirent *de);
-extern void DOS_closedir(struct dosdirent *de);
-
-/* misc/profile.c */
-
-extern void sync_profiles(void);
-
 /* misc/spy.c */
 
 extern void SpyInit(void);
 
-/* controls/desktop.c */
-
-extern BOOL DESKTOP_SetPattern(char *pattern);
-
 /* controls/widget.c */
 
 extern BOOL WIDGETS_Init(void);
 
-/* memory/heap.c */
-
-extern void HEAP_Init(MDESC **free_list, void *start, int length);
-extern void *HEAP_Alloc(MDESC **free_list, int flags, int bytes);
-extern void *HEAP_ReAlloc(MDESC **free_list, void *old_block, int new_size, unsigned int flags);
-extern int HEAP_Free(MDESC **free_list, void *block);
-extern LHEAP *HEAP_LocalFindHeap(unsigned short owner);
-extern void HEAP_LocalInit(unsigned short owner, void *start, int length);
-extern void *WIN16_LocalAlloc(int flags, int bytes);
-extern int WIN16_LocalCompact(int min_free);
-extern unsigned int WIN16_LocalFlags(unsigned int handle);
-extern unsigned int WIN16_LocalFree(unsigned int handle);
-extern unsigned int WIN16_LocalInit(unsigned int segment, unsigned int start, unsigned int end);
-extern void *WIN16_LocalLock(unsigned int handle);
-extern void *WIN16_LocalReAlloc(unsigned int handle, int flags, int bytes);
-extern unsigned int WIN16_LocalSize(unsigned int handle);
-extern unsigned int WIN16_LocalUnlock(unsigned int handle);
-
-/* objects/bitmaps.c */
-
-extern BOOL BITMAP_Init(void);
-
-/* objects/color.c */
-
-extern BOOL COLOR_Init(void);
-
 /* objects/dib.c */
 
 extern int DIB_BitmapInfoSize(BITMAPINFO *info, WORD coloruse);
 
-/* objects/gdiobj.c */
-
-extern BOOL GDI_Init(void);
-
 /* objects/palette.c */
 
 extern BOOL PALETTE_Init(void);
@@ -200,17 +77,5 @@
 
 extern void DCE_Init(void);
 
-/* windows/dialog.c */
-
-extern BOOL DIALOG_Init(void);
-
-/* windows/syscolor.c */
-
-extern void SYSCOLOR_Init(void);
-
-/* windows/sysmetrics.c */
-
-extern void SYSMETRICS_Init(void);
-
 #endif /* WINELIB */
 #endif /* _WINE_PROTOTYPES_H */
diff --git a/include/registers.h b/include/registers.h
index 26a7774..ce06a0f 100644
--- a/include/registers.h
+++ b/include/registers.h
@@ -29,8 +29,8 @@
 #define ES context->sc_es
 #define SS context->sc_ss
 
-#define DI context->sc_edi
-#define SI context->sc_esi
+#define DI ((WORD)context->sc_edi)
+#define SI ((WORD)context->sc_esi)
 #define SP context->sc_esp
 #ifndef __FreeBSD__
 #define EFL context->sc_eflags
diff --git a/include/scroll.h b/include/scroll.h
index f80eefd..681d4d1 100644
--- a/include/scroll.h
+++ b/include/scroll.h
@@ -20,7 +20,8 @@
 } SCROLLINFO;
 
 extern LONG ScrollBarWndProc( HWND hwnd, WORD uMsg, WORD wParam, LONG lParam );
-
 extern void SCROLL_DrawScrollBar( HWND hwnd, HDC hdc, int nBar );
+extern void SCROLL_HandleScrollEvent( HWND hwnd, int nBar,
+                                      WORD msg, POINT pt);       /* scroll.c */
 
 #endif  /* SCROLL_H */
diff --git a/include/selectors.h b/include/selectors.h
new file mode 100644
index 0000000..aac6fa9
--- /dev/null
+++ b/include/selectors.h
@@ -0,0 +1,25 @@
+#ifndef __WINE_SELECTORS_H
+#define __WINE_SELECTORS_H
+
+#include "dlls.h"
+
+extern int FindUnusedSelectors(int n_selectors);
+extern int IPCCopySelector(int i_old, unsigned long new, int swap_type);
+extern WORD AllocSelector(WORD old_selector);
+extern unsigned int PrestoChangoSelector(unsigned src_selector, unsigned dst_selector);
+extern WORD AllocDStoCSAlias(WORD ds_selector);
+extern SEGDESC *CreateSelectors(struct  w_files * wpnt);
+extern WORD FreeSelector(WORD sel);
+
+extern SEGDESC *CreateNewSegments(int code_flag, int read_only, int length, 
+					int n_segments);
+extern SEGDESC *GetNextSegment(unsigned int flags, unsigned int limit);
+
+extern unsigned int GetEntryDLLName(char *dll_name, char *function, int *sel,
+					int *addr);
+extern unsigned int GetEntryDLLOrdinal(char *dll_name, int ordinal, int *sel,
+					int *addr);
+extern unsigned int GetEntryPointFromOrdinal(struct w_files * wpnt, 
+					int ordinal);
+
+#endif /* __WINE_SELECTORS_H */
diff --git a/include/stddebug.h b/include/stddebug.h
index 7c5ccbf..48348c4 100644
--- a/include/stddebug.h
+++ b/include/stddebug.h
@@ -129,9 +129,11 @@
 #undef DEBUG_PROP
 #undef DEBUG_REG
 #undef DEBUG_REGION
+#undef DEBUG_RELAY
 #undef DEBUG_RESOURCE
 #undef DEBUG_SCROLL
 #undef DEBUG_SELECTORS
+#undef DEBUG_STACK
 #undef DEBUG_STRESS
 #undef DEBUG_SYSCOLOR
 #undef DEBUG_TASK
@@ -196,9 +198,11 @@
 #define DEBUG_PROP
 #define DEBUG_REG
 #define DEBUG_REGION
+#define DEBUG_RELAY
 #define DEBUG_RESOURCE
 #define DEBUG_SCROLL
 #define DEBUG_SELECTORS
+#define DEBUG_STACK
 #define DEBUG_STRESS
 #define DEBUG_SYSCOLOR
 #define DEBUG_TASK
diff --git a/include/syscolor.h b/include/syscolor.h
index 7001448..0144953 100644
--- a/include/syscolor.h
+++ b/include/syscolor.h
@@ -34,6 +34,7 @@
     HBRUSH hbrushBtnHighlight;     /* COLOR_BTNHIGHLIGHT        */
 };
 
+extern void SYSCOLOR_Init(void);
 extern struct SysColorObjects sysColorObjects;
 
 #endif  /* SYSCOLOR_H */
diff --git a/include/sysmetrics.h b/include/sysmetrics.h
index 186d213..f9e73e7 100644
--- a/include/sysmetrics.h
+++ b/include/sysmetrics.h
@@ -48,8 +48,7 @@
 #define SYSMETRICS_CYDOUBLECLK         sysMetrics[SM_CYDOUBLECLK]
 #define SYSMETRICS_MENUDROPALIGNMENT   sysMetrics[SM_MENUDROPALIGNMENT]
 
-
+extern void SYSMETRICS_Init(void);
 extern short sysMetrics[SM_CMETRICS];
 
-
 #endif
diff --git a/include/win.h b/include/win.h
index 8e093ba..d47cb2c 100644
--- a/include/win.h
+++ b/include/win.h
@@ -72,6 +72,7 @@
 BOOL WIN_UnlinkWindow( HWND hwnd );
 BOOL WIN_LinkWindow( HWND hwnd, HWND hwndInsertAfter );
 HWND WIN_FindWinToRepaint( HWND hwnd );
+BOOL WIN_CreateDesktopWindow(void);
 BOOL WINPOS_IsAnActiveWindow( HWND hwnd );
 void WINPOS_ActivateChild( HWND hwnd );
 
diff --git a/include/windows.h b/include/windows.h
index d4ef6e1..cb60ce0 100644
--- a/include/windows.h
+++ b/include/windows.h
@@ -3,87 +3,14 @@
 #ifndef WINDOWS_H
 #define WINDOWS_H
 
-#ifndef _WINARGS
+#include <wintypes.h>
 
-typedef short	INT;
-typedef unsigned short UINT;
-typedef unsigned short WORD;
-typedef unsigned long DWORD;
-typedef unsigned short BOOL;
-typedef unsigned char BYTE;
-typedef long LONG;
-typedef UINT WPARAM;
-typedef LONG LPARAM;
-typedef LONG LRESULT;
-typedef WORD HANDLE;
-typedef DWORD HHOOK;
-typedef char *LPSTR;
-typedef const char *LPCSTR;
-typedef char *NPSTR;
-typedef INT *LPINT;
-typedef UINT *LPUINT;
-typedef WORD *LPWORD;
-typedef DWORD *LPDWORD;
-typedef LONG *LPLONG;
-typedef void *LPVOID;
-typedef long (*FARPROC)();
-typedef FARPROC DLGPROC;
-typedef int CATCHBUF[9];
-typedef int *LPCATCHBUF;
-typedef FARPROC HOOKPROC;
-#define DECLARE_HANDLE(a) typedef HANDLE a;
+#pragma pack(1)
 
-DECLARE_HANDLE(HTASK);
-DECLARE_HANDLE(HDRVR);
-DECLARE_HANDLE(HWND);
-DECLARE_HANDLE(HDC);
-DECLARE_HANDLE(HCLASS);
-DECLARE_HANDLE(HCURSOR);
-DECLARE_HANDLE(HFONT);
-DECLARE_HANDLE(HPEN);
-DECLARE_HANDLE(HRGN);
-DECLARE_HANDLE(HPALETTE);
-DECLARE_HANDLE(HICON);
-DECLARE_HANDLE(HINSTANCE);
-DECLARE_HANDLE(HMENU);
-DECLARE_HANDLE(HBITMAP);
-DECLARE_HANDLE(HBRUSH);
-DECLARE_HANDLE(LOCALHANDLE);
-DECLARE_HANDLE(HMETAFILE);
-DECLARE_HANDLE(HDWP);
-
-#define TRUE 1
-#define FALSE 0
-#define CW_USEDEFAULT ((INT)0x8000)
-#define FAR
-#define NEAR
-#define PASCAL
-#define VOID                void
-#define WINAPI              PASCAL
-#define CALLBACK            PASCAL
-#ifndef NULL
-#define NULL (void *)0
-#endif
-
-#define LOBYTE(w)           ((BYTE)(w))
-#define HIBYTE(w)           ((BYTE)((UINT)(w) >> 8))
-
-#define LOWORD(l)           ((WORD)(l))
-#define HIWORD(l)           ((WORD)((DWORD)(l) >> 16))
-
-#define MAKELONG(low, high) ((LONG)(((WORD)(low)) | \
-				    (((DWORD)((WORD)(high))) << 16)))
-
-#ifndef max
-#define max(a,b) (((a) > (b)) ? (a) : (b))
-#endif
-
-#ifndef min
-#define min(a,b) (((a) < (b)) ? (a) : (b))
-#endif
-
-
-typedef struct { INT x, y; } POINT;
+typedef struct { 
+	INT x;
+	INT y; 
+} POINT;
 typedef POINT *PPOINT;
 typedef POINT *NPPOINT;
 typedef POINT *LPPOINT;
@@ -116,13 +43,6 @@
 typedef PAINTSTRUCT *NPPAINTSTRUCT;
 typedef PAINTSTRUCT *LPPAINTSTRUCT;
 
-#ifdef WINELIB
-#define WINE_PACKED
-#else
-#define WINE_PACKED __attribute__ ((packed))
-#endif
-
-#pragma pack(1)
 
   /* Window classes */
 
@@ -2363,7 +2283,6 @@
 #define Fn(ret,name,t1,a1,t2,a2,t3,a3,t4,a4,t5,a5,t6,a6,t7,a7,t8,a8,t9,a9,t10,a10,t11,a11,t12,a12,t13,a13,t14,a14) ret name(t1 a1,t2 a2,t3 a3,t4 a4,t5 a5,t6 a6,t7 a7,t8 a8,t9 a9,t10 a10,t11 a11,t12 a12,t13 a13,t14 a14);
 
 int wsprintf(LPSTR a,LPSTR b,...);
-#endif
 
 /* Implemented functions */
 
diff --git a/include/wine.h b/include/wine.h
index cc2ef88..cf7dfdc 100644
--- a/include/wine.h
+++ b/include/wine.h
@@ -32,21 +32,16 @@
 	unsigned long oldmask;
 	unsigned long cr2;
 };
-#endif
-
-#ifdef linux
 #define WINE_DATA_SELECTOR 0x2b
 #define WINE_CODE_SELECTOR 0x23
 #endif
-#if defined(__NetBSD__) || defined(__FreeBSD__)
-#define WINE_DATA_SELECTOR 0x27
-#define WINE_CODE_SELECTOR 0x1f
-#endif
 
 #if defined(__NetBSD__) || defined(__FreeBSD__)
 #include <signal.h>
 #define sigcontext_struct sigcontext
 #define HZ 100
+#define WINE_DATA_SELECTOR 0x27
+#define WINE_CODE_SELECTOR 0x1f
 #endif
 
 #endif /* WINE_H */
diff --git a/include/winpos.h b/include/winpos.h
index 837a5b3..0d58c53 100644
--- a/include/winpos.h
+++ b/include/winpos.h
@@ -9,6 +9,15 @@
 
 #define DWP_MAGIC  0x5057  /* 'WP' */
 
+extern HWND WINPOS_ChangeActiveWindow( HWND hwnd, BOOL mouseMsg ); /*winpos.c*/
+extern void WINPOS_GetMinMaxInfo( HWND hwnd, POINT *maxSize, POINT *maxPos,
+			    POINT *minTrack, POINT *maxTrack );  /* winpos.c */
+extern LONG WINPOS_SendNCCalcSize( HWND hwnd, BOOL calcValidRect,
+				   RECT *newWindowRect, RECT *oldWindowRect,
+				   RECT *oldClientRect, WINDOWPOS *winpos,
+				   RECT *newClientRect );  /* winpos.c */
+extern LONG WINPOS_HandleWindowPosChanging( WINDOWPOS *winpos ); /* winpos.c */
+
 typedef struct
 {
     WORD        actualCount;
diff --git a/include/wintypes.h b/include/wintypes.h
new file mode 100644
index 0000000..da99fed
--- /dev/null
+++ b/include/wintypes.h
@@ -0,0 +1,92 @@
+#ifndef __WINE_WINTYPES_H
+#define __WINE_WINTYPES_H
+
+typedef short	INT;
+typedef unsigned short UINT;
+typedef unsigned short WORD;
+typedef unsigned long DWORD;
+typedef unsigned short BOOL;
+typedef unsigned char BYTE;
+typedef long LONG;
+typedef UINT WPARAM;
+typedef LONG LPARAM;
+typedef LONG LRESULT;
+typedef WORD HANDLE;
+typedef DWORD HHOOK;
+typedef char *LPSTR;
+typedef const char *LPCSTR;
+typedef char *NPSTR;
+typedef INT *LPINT;
+typedef UINT *LPUINT;
+typedef WORD *LPWORD;
+typedef DWORD *LPDWORD;
+typedef LONG *LPLONG;
+typedef void *LPVOID;
+typedef long (*FARPROC)();
+typedef FARPROC DLGPROC;
+typedef int CATCHBUF[9];
+typedef int *LPCATCHBUF;
+typedef FARPROC HOOKPROC;
+
+#define DECLARE_HANDLE(a) typedef HANDLE a;
+
+DECLARE_HANDLE(HTASK);
+DECLARE_HANDLE(HDRVR);
+DECLARE_HANDLE(HWND);
+DECLARE_HANDLE(HDC);
+DECLARE_HANDLE(HCLASS);
+DECLARE_HANDLE(HCURSOR);
+DECLARE_HANDLE(HFONT);
+DECLARE_HANDLE(HPEN);
+DECLARE_HANDLE(HRGN);
+DECLARE_HANDLE(HPALETTE);
+DECLARE_HANDLE(HICON);
+DECLARE_HANDLE(HINSTANCE);
+DECLARE_HANDLE(HMENU);
+DECLARE_HANDLE(HBITMAP);
+DECLARE_HANDLE(HBRUSH);
+DECLARE_HANDLE(LOCALHANDLE);
+DECLARE_HANDLE(HMETAFILE);
+DECLARE_HANDLE(HDWP);
+DECLARE_HANDLE(HDROP);
+
+#define TRUE 1
+#define FALSE 0
+#define CW_USEDEFAULT ((INT)0x8000)
+#define FAR
+#define NEAR
+#define PASCAL
+#define VOID                void
+#define WINAPI              PASCAL
+#define CALLBACK            PASCAL
+
+#ifndef NULL
+#define NULL (void *)0
+#endif
+
+#ifdef WINELIB
+#define WINE_PACKED
+#else
+#define WINE_PACKED __attribute__ ((packed))
+#endif
+
+#pragma pack(1)
+
+#define LOBYTE(w)           ((BYTE)(w))
+#define HIBYTE(w)           ((BYTE)((UINT)(w) >> 8))
+
+#define LOWORD(l)           ((WORD)(l))
+#define HIWORD(l)           ((WORD)((DWORD)(l) >> 16))
+
+#define MAKELONG(low, high) ((LONG)(((WORD)(low)) | \
+				    (((DWORD)((WORD)(high))) << 16)))
+
+#ifndef max
+#define max(a,b) (((a) > (b)) ? (a) : (b))
+#endif
+
+#ifndef min
+#define min(a,b) (((a) < (b)) ? (a) : (b))
+#endif
+
+#endif /* __WINE_WINTYPES_H */
diff --git a/loader/dump.c b/loader/dump.c
index 1cf84fa..c811e44 100644
--- a/loader/dump.c
+++ b/loader/dump.c
@@ -1,7 +1,8 @@
 #ifndef WINELIB
+/*
 static char RCSId[] = "$Id: dump.c,v 1.2 1993/07/04 04:04:21 root Exp root $";
 static char Copyright[] = "Copyright  Robert J. Amstadt, 1993";
-
+*/
 #include <stdio.h>
 #include <stdlib.h>
 #include <sys/types.h>
diff --git a/loader/ldt.c b/loader/ldt.c
index 0fd4c00..45b6ae4 100644
--- a/loader/ldt.c
+++ b/loader/ldt.c
@@ -1,6 +1,8 @@
 #ifndef WINELIB
+/*
 static char RCSId[] = "$Id: ldt.c,v 1.2 1993/07/04 04:04:21 root Exp root $";
 static char Copyright[] = "Copyright  Robert J. Amstadt, 1993";
+*/
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/loader/ldtlib.c b/loader/ldtlib.c
index 4546560..eb13508 100644
--- a/loader/ldtlib.c
+++ b/loader/ldtlib.c
@@ -1,13 +1,13 @@
 #ifndef WINELIB
+/*
 static char RCSId[] = "$Id: ldtlib.c,v 1.2 1993/07/04 04:04:21 root Exp root $";
 static char Copyright[] = "Copyright  Robert J. Amstadt, 1993";
+*/
 
 #include <stdio.h>
 #include <stdlib.h>
 #include <errno.h>
 #include "stddebug.h"
-/* #define DEBUG_LDT */
-/* #undef DEBUG_LDT  */
 #include "debug.h"
 
 #ifdef linux
diff --git a/loader/library.c b/loader/library.c
index 3b13860..6d7e973 100644
--- a/loader/library.c
+++ b/loader/library.c
@@ -1,7 +1,7 @@
 /*
  *        Module & Library functions
- */
 static char Copyright[] = "Copyright 1993, 1994 Martin Ayotte, Robert J. Amstadt, Erik Bos";
+*/
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -13,24 +13,21 @@
 #include "neexe.h"
 #include "segmem.h"
 #include "dlls.h"
-#include "wine.h"
+#include "if1632.h"
 #include "wineopts.h"
 #include "arch.h"
 #include "options.h"
-#include "prototypes.h"
+#include "dos_fs.h"
 #include "windows.h"
 #include "task.h"
 #include "toolhelp.h"
+#include "selectors.h"
 #include "stddebug.h"
-/* #define DEBUG_MODULE */
-/* #undef DEBUG_MODULE  */
 #include "debug.h"
-
-extern char WindowsPath[256];
-extern struct dll_name_table_entry_s dll_builtin_table[];
-extern char *GetDosFileName(char *);
-
-extern HANDLE hSysRes;
+#include "prototypes.h"
+#include "library.h"
+#include "ne_image.h"
+#include "pe_image.h"
 
 struct w_files *wine_files = NULL;
 static char *DLL_Extensions[] = { "dll", NULL };
@@ -58,8 +55,7 @@
 	}
 }
 
-struct w_files *
-GetFileInfo(unsigned short instance)
+struct w_files *GetFileInfo(unsigned short instance)
 {
     register struct w_files *w = wine_files;
 
@@ -86,9 +82,9 @@
 void InitDLL(struct w_files *wpnt)
 {
 	if (wpnt->ne) 
-		InitNEDLL(wpnt);
+		NE_InitDLL(wpnt);
 	else
-		InitPEDLL(wpnt);
+		PE_InitDLL(wpnt);
 }
 
 void InitializeLoadedDLLs(struct w_files *wpnt)
@@ -154,7 +150,7 @@
     /*
      * search file
      */
-    fullname = FindFile(buffer, sizeof(buffer), module, 
+    fullname = DOS_FindFile(buffer, sizeof(buffer), module, 
 			(filetype == EXE ? EXE_Extensions : DLL_Extensions), 
 			WindowsPath);
     if (fullname == NULL)
@@ -164,7 +160,7 @@
 	return 2;
     }
 
-    fullname = GetDosFileName(fullname);
+    fullname = DOS_GetDosFileName(fullname);
     
     dprintf_module(stddeb,"LoadImage: loading %s (%s)\n           [%s]\n", 
 	    module, buffer, fullname);
@@ -225,7 +221,7 @@
     /* 
      * Stick this file into the list of loaded files so we don't try to reload
      * it again if another module references this module.  Do this before
-     * calling loadNEImage because we might get back here before loadNEImage
+     * calling NE_LoadImage because we might get back here before NE_loadImage
      * returns.
      */
     if(wine_files == NULL)
@@ -239,9 +235,9 @@
     wpnt->next = NULL;
 
     if (header[0] == 'N' && header[1] == 'E')
-    	handle = LoadNEImage(wpnt);
+    	handle = NE_LoadImage(wpnt);
     if (header[0] == 'P' && header[1] == 'E')
-        handle = LoadPEImage(wpnt);
+        handle = PE_LoadImage(wpnt);
     wpnt->hinstance = handle;
 
     if (handle > 32) {
@@ -365,7 +361,7 @@
     /* check loaded dlls */
     if ((w = GetFileInfo(hModule)) == NULL)
     	return 0;
-    str = GetDosFileName(w->filename);
+    str = DOS_GetDosFileName(w->filename);
     if (nSize > strlen(str)) nSize = strlen(str) + 1;
     strncpy(lpFileName, str, nSize);
     dprintf_module(stddeb,"GetModuleFileName copied '%s' return %d \n", lpFileName, nSize);
@@ -406,9 +402,9 @@
 			if (lpMod->Count == 1) {
 				wpnt = GetFileInfo(hLib);
 				if (wpnt->ne)
-					NEunloadImage(wpnt);
+					NE_UnloadImage(wpnt);
 				else
-					PEunloadImage(wpnt);
+					PE_UnloadImage(wpnt);
 				if (hLib != (HANDLE)NULL) GlobalFree(hLib);
 				if (lpMod->ModuleName != NULL) free(lpMod->ModuleName);
 				if (lpMod->FileName != NULL) free(lpMod->FileName);
diff --git a/loader/main.c b/loader/main.c
index 5721a52..10dd883 100644
--- a/loader/main.c
+++ b/loader/main.c
@@ -1,6 +1,7 @@
+/*
 static char RCSId[] = "$Id: wine.c,v 1.2 1993/07/04 04:04:21 root Exp root $";
 static char Copyright[] = "Copyright  Robert J. Amstadt, 1993";
-
+*/
 #include <stdio.h>
 #include <stdlib.h>
 #include <sys/types.h>
@@ -11,26 +12,24 @@
 #include <errno.h>
 #include "neexe.h"
 #include "segmem.h"
-#include "prototypes.h"
+#include "dos_fs.h"
 #include "dlls.h"
-#include "wine.h"
+#include "library.h"
 #include "windows.h"
 #include "wineopts.h"
-#include "arch.h"
+#include "dos_fs.h"
 #include "task.h"
+#include "prototypes.h"
 #include "options.h"
+#include "if1632.h"
+#include "ne_image.h"
+#include "pe_image.h"
 #include "stddebug.h"
-/* #define DEBUG_DLL */
-/* #undef  DEBUG_DLL */
 #include "debug.h"
 
-
-char *GetDosFileName(char *unixfilename);
-extern char WindowsPath[256];
-
 char **Argv;
 int Argc;
-HINSTANCE hSysRes;
+HINSTANCE hSysRes, hInstMain;
 unsigned short WIN_StackSize;
 unsigned short WIN_HeapSize;
 
@@ -55,8 +54,8 @@
 int _WinMain(int argc, char **argv)
 {
 	char *p, filename[256];
-	HANDLE		hTaskMain;
-	HINSTANCE	hInstMain;
+	HANDLE	hTaskMain;
+
 	struct w_files *wpnt;
 #ifdef WINESTAT
 	char * cp;
@@ -73,11 +72,11 @@
 	    filename[p - Argv[0]] = '\0';
 	    strcat(WindowsPath, ";");
 	    if (strchr(filename, '/'))
-		    strcat(WindowsPath, GetDosFileName(filename));
+		    strcat(WindowsPath, DOS_GetDosFileName(filename));
 	    else
 	    	    strcat(WindowsPath, filename);
 	}
-	
+
 	if ((hInstMain = LoadImage(Argv[0], EXE, 1)) < 32) {
 		fprintf(stderr, "wine: can't load %s!.\n", Argv[0]);
 		exit(1);
@@ -97,6 +96,7 @@
  	    dprintf_dll(stddeb,"System Resources Loaded // hSysRes='%04X'\n",
 			hSysRes);
 	
+
 #ifdef WINESTAT
     cp = strrchr(argv[0], '/');
     if(!cp) cp = argv[0];
@@ -117,9 +117,9 @@
 	wine_debug(0, NULL);
 
     if (wpnt->ne)
-	StartNEprogram(wpnt);
+	return(NE_StartProgram(wpnt));
     else
-	StartPEprogram(wpnt);
+	return(PE_StartProgram(wpnt));
 }
 
 #endif /* #ifndef WINELIB */
diff --git a/loader/ne_image.c b/loader/ne_image.c
index 8cf62a9..9e10ae9 100644
--- a/loader/ne_image.c
+++ b/loader/ne_image.c
@@ -1,6 +1,7 @@
+/*
 static char RCSId[] = "$Id: wine.c,v 1.2 1993/07/04 04:04:21 root Exp root $";
 static char Copyright[] = "Copyright  Robert J. Amstadt, 1993";
-
+*/
 #include <stdio.h>
 #include <stdlib.h>
 #include <sys/types.h>
@@ -8,180 +9,63 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <ctype.h>
-#ifdef linux
-#include <linux/head.h>
-#include <linux/ldt.h>
-#include <linux/segment.h>
-#endif
 #include <string.h>
 #include <errno.h>
 #include "neexe.h"
 #include "segmem.h"
-#include "prototypes.h"
 #include "dlls.h"
-#include "wine.h"
 #include "windows.h"
-#include "wineopts.h"
 #include "arch.h"
-#include "options.h"
+#include "library.h"
+#include "if1632.h"
+#include "selectors.h"
+#include "ne_image.h"
+#include "prototypes.h"
 #include "stddebug.h"
 #include "debug.h"
 
-extern HANDLE CreateNewTask(HINSTANCE hInst);
-extern void InitializeLoadedDLLs(struct w_files *wpnt);
-extern int CallToInit16(unsigned long csip, unsigned long sssp, 
-			unsigned short ds);
-extern int CallTo16cx(unsigned long csip, unsigned long dscx);
-extern void CallTo32();
-extern char WindowsPath[256];
 extern unsigned short WIN_StackSize;
 extern unsigned short WIN_HeapSize;
 
-int FixupSegment(struct w_files *, int);
 void FixupFunctionPrologs(struct w_files *);
-char *GetModuleName(struct w_files * wpnt, int index, char *buffer);
-
-#ifndef WINELIB
-
-/**********************************************************************/
-
-void load_ne_header (int fd, struct ne_header_s *ne_header)
-{
-    if (read(fd, ne_header, sizeof(struct ne_header_s)) 
-	!= sizeof(struct ne_header_s))
-    {
-	myerror("Unable to read NE header from file");
-    }
-}
-#endif
-
-/**********************************************************************
- *			LoadNEImage
- * Load one NE format executable into memory
- */
-HINSTANCE LoadNEImage(struct w_files *wpnt)
-{
-    unsigned int read_size, status, segment;
-    int i;
-
-    wpnt->ne = malloc(sizeof(struct ne_data));
-    wpnt->ne->resnamtab = NULL;
-    wpnt->ne->ne_header = malloc(sizeof(struct ne_header_s));
-    lseek(wpnt->fd, wpnt->mz_header->ne_offset, SEEK_SET);
-    load_ne_header(wpnt->fd, wpnt->ne->ne_header);
-
-#ifndef WINELIB
-    /*
-     * Create segment selectors.
-     */
-    status = lseek(wpnt->fd, wpnt->mz_header->ne_offset + 
-		   wpnt->ne->ne_header->segment_tab_offset,
-		   SEEK_SET);
-    read_size  = wpnt->ne->ne_header->n_segment_tab *
-	sizeof(struct ne_segment_table_entry_s);
-    wpnt->ne->seg_table = (struct ne_segment_table_entry_s *) malloc(read_size);
-    if (read(wpnt->fd, wpnt->ne->seg_table, read_size) != read_size)
-	myerror("Unable to read segment table header from file");
-    wpnt->ne->selector_table = CreateSelectors(wpnt);
-    wpnt->hinstance = (wpnt->ne->
-		       selector_table[wpnt->ne->ne_header->auto_data_seg-1].
-		       selector);
-#endif
-    /* Get the lookup  table.  This is used for looking up the addresses
-       of functions that are exported */
-
-    read_size  = wpnt->ne->ne_header->entry_tab_length;
-    wpnt->ne->lookup_table = (char *) malloc(read_size);
-    lseek(wpnt->fd, wpnt->mz_header->ne_offset + 
-	  wpnt->ne->ne_header->entry_tab_offset, SEEK_SET);
-    if (read(wpnt->fd, wpnt->ne->lookup_table, read_size) != read_size)
-	myerror("Unable to read lookup table header from file");
-
-    /* Get the iname table.  This is used for looking up the names
-       of functions that are exported */
-
-    status = lseek(wpnt->fd, wpnt->ne->ne_header->nrname_tab_offset,  SEEK_SET);
-    read_size  = wpnt->ne->ne_header->nrname_tab_length;
-    wpnt->ne->nrname_table = (char *) malloc(read_size);
-    if (read(wpnt->fd, wpnt->ne->nrname_table, read_size) != read_size)
-	myerror("Unable to read nrname table header from file");
-
-    status = lseek(wpnt->fd, wpnt->mz_header->ne_offset + 
-		   wpnt->ne->ne_header->rname_tab_offset,  SEEK_SET);
-    read_size  = wpnt->ne->ne_header->moduleref_tab_offset - 
-	    wpnt->ne->ne_header->rname_tab_offset;
-    wpnt->ne->rname_table = (char *) malloc(read_size);
-    if (read(wpnt->fd, wpnt->ne->rname_table, read_size) != read_size)
-	myerror("Unable to read rname table header from file");
-
-    /*
-     * Now load any DLLs that  this module refers to.
-     */
-    for(i=0; i<wpnt->ne->ne_header->n_mod_ref_tab; i++)
-    {
-      char buff[14];
-      GetModuleName(wpnt, i + 1, buff);
-
-      if (strcasecmp(buff, wpnt->name) != 0 )
-	LoadImage(buff, DLL, 0);
-    }
-#ifndef WINELIB
-    /* fixup references */
-
-    for (segment = 0; segment < wpnt->ne->ne_header->n_segment_tab; segment++)
-	if (FixupSegment(wpnt, segment) < 0)
-		myerror("fixup failed.");
-
-    FixupFunctionPrologs(wpnt);
-    InitializeLoadedDLLs(wpnt);
-#endif
-    return(wpnt->hinstance);
-}
 
 /**********************************************************************
  *					GetImportedName
  */
-char *
-GetImportedName(int fd, struct mz_header_s *mz_header, 
-		struct ne_header_s *ne_header, int name_offset, char *buffer)
+static
+char *NE_GetImportedName(struct w_files *wpnt, int name_offset, char *buffer)
 {
-    int length;
-    int status;
-    
-    status = lseek(fd, mz_header->ne_offset + ne_header->iname_tab_offset +
-		   name_offset, SEEK_SET);
-    length = 0;
-    read(fd, &length, 1);  /* Get the length byte */
-    length = CONV_CHAR_TO_LONG (length);
-    read(fd, buffer, length);
+    BYTE length;
+
+    lseek(wpnt->fd, wpnt->mz_header->ne_offset + 
+    	wpnt->ne->ne_header->iname_tab_offset + name_offset, SEEK_SET);
+    read(wpnt->fd, &length, 1);  /* Get the length byte */
+    read(wpnt->fd, buffer, length);
     buffer[length] = 0;
+
     return buffer;
 }
 
+struct w_files *current_exe;
+WORD current_nodata=0xfd00;
 /**********************************************************************
  *					GetModuleName
  */
-char *
-GetModuleName(struct w_files * wpnt, int index, char *buffer)
+static char *NE_GetModuleName(struct w_files *wpnt, int index, char *buffer)
 {
-    int fd = wpnt->fd;
-    struct mz_header_s *mz_header = wpnt->mz_header; 
-    struct ne_header_s *ne_header = wpnt->ne->ne_header;
-    int length;
-    WORD name_offset, status;
+    BYTE length;
+    WORD name_offset;
     int i;
     
-    status = lseek(fd, mz_header->ne_offset + ne_header->moduleref_tab_offset +
-		   2*(index - 1), SEEK_SET);
-    name_offset = 0;
-    read(fd, &name_offset, 2);
+    lseek(wpnt->fd, wpnt->mz_header->ne_offset +
+    	wpnt->ne->ne_header->moduleref_tab_offset + 2 * (index - 1), SEEK_SET);
+    read(wpnt->fd, &name_offset, 2);
     name_offset = CONV_SHORT (name_offset);
-    status = lseek(fd, mz_header->ne_offset + ne_header->iname_tab_offset +
-		   name_offset, SEEK_SET);
-    length = 0;
-    read(fd, &length, 1);  /* Get the length byte */
-    length = CONV_CHAR_TO_LONG (length);
-    read(fd, buffer, length);
+
+    lseek(wpnt->fd, wpnt->mz_header->ne_offset + 
+    	wpnt->ne->ne_header->iname_tab_offset + name_offset, SEEK_SET);
+    read(wpnt->fd, &length, 1);  /* Get the length byte */
+    read(wpnt->fd, buffer, length);
     buffer[length] = 0;
 
     /* Module names  are always upper case */
@@ -191,33 +75,23 @@
 
     return buffer;
 }
-
 
 #ifndef WINELIB
 /**********************************************************************
- *					FixupSegment
+ *				NE_FixupSegment
  */
-int
-FixupSegment(struct w_files * wpnt, int segment_num)
+int NE_FixupSegment(struct w_files *wpnt, int segment_num)
 {
-    struct mz_header_s *mz_header = wpnt->mz_header;
-    struct ne_header_s *ne_header =  wpnt->ne->ne_header;
-    struct ne_segment_table_entry_s *seg_table = wpnt->ne->seg_table;
     struct segment_descriptor_s *selector_table = wpnt->ne->selector_table;
     struct relocation_entry_s *rep, *rep1;
     struct ne_segment_table_entry_s *seg;
     struct segment_descriptor_s *sel;
-    int status;
+    int status, ordinal, i, n_entries, additive;
     unsigned short *sp;
-    unsigned int selector, address;
-    unsigned int next_addr;
-    int ordinal;
-    char dll_name[257];
-    char func_name[257];
-    int i, n_entries;
-    int additive;
+    unsigned int selector, address, next_addr;
+    unsigned char dll_name[257], func_name[257];
 
-    seg = &seg_table[segment_num];
+    seg = &wpnt->ne->seg_table[segment_num];
     sel = &selector_table[segment_num];
 
     dprintf_fixup(stddeb, "Segment fixups for %s, segment %d, selector %x\n", 
@@ -235,7 +109,7 @@
 	i = 0x10000;
 
     status = lseek(wpnt->fd, seg->seg_data_offset * 
-		       (1 << ne_header->align_shift_count) + i, SEEK_SET);
+		(1 << wpnt->ne->ne_header->align_shift_count) + i, SEEK_SET);
     n_entries = 0;
     read(wpnt->fd, &n_entries, sizeof(short int));
     rep = (struct relocation_entry_s *)
@@ -262,7 +136,7 @@
 	    additive = 1;
 	    
 	  case NE_RELTYPE_ORDINAL:
-	    if (GetModuleName(wpnt, rep->target1,
+	    if (NE_GetModuleName(wpnt, rep->target1,
 			      dll_name) == NULL)
 	    {
 	      fprintf(stderr, "NE_RELTYPE_ORDINAL failed");
@@ -290,17 +164,13 @@
 	    additive = 1;
 	    
 	  case NE_RELTYPE_NAME:
-	    if (GetModuleName(wpnt, rep->target1, dll_name)
-		== NULL)
-	    {
-	      fprintf(stderr,"NE_RELTYPE_NAME failed");
+	    if (NE_GetModuleName(wpnt, rep->target1, dll_name) == NULL) {
+	        fprintf(stderr,"NE_RELTYPE_NAME failed");
 		return -1;
 	    }
 
-	    if (GetImportedName(wpnt->fd, mz_header, ne_header, 
-				rep->target2, func_name) == NULL)
-	    {
-	      fprintf(stderr,"getimportedname failed");
+	    if (NE_GetImportedName(wpnt, rep->target2, func_name) == NULL) {
+	        fprintf(stderr,"NE_getimportedname failed");
 		return -1;
 	    }
 
@@ -314,9 +184,8 @@
 		myerror(s);
 		return -1;
 	    }
-
-	    dprintf_fixup(stddeb,"%d: %s %s.%d: %04x:%04x\n", i + 1, 
-                   func_name, dll_name, ordinal, selector, address);
+/*	    dprintf_fixup(stddeb,"%d: %s %s.%d: %04x:%04x\n", i + 1, 
+                   func_name, dll_name, ordinal, selector, address);*/
 	    break;
 	    
 	  case NE_RELTYPE_INTERNAL:
@@ -443,14 +312,14 @@
     return 0;
 }
 
-int NEunloadImage(struct w_files *wpnt)
+int NE_unloadImage(struct w_files *wpnt)
 {
 	dprintf_fixup(stdnimp, "NEunloadImage() called!\n");
 	/* free resources, image */
 	return 1;
 }
 
-int StartNEprogram(struct w_files *wpnt)
+int NE_StartProgram(struct w_files *wpnt)
 {
     int cs_reg, ds_reg, ss_reg, ip_reg, sp_reg;
     /*
@@ -468,28 +337,37 @@
     return CallToInit16(cs_reg << 16 | ip_reg, ss_reg << 16 | sp_reg, ds_reg);
 }
 
-void InitNEDLL(struct w_files *wpnt)
+void NE_InitDLL(struct w_files *wpnt)
 {
-	int cs_reg, ds_reg, ip_reg, cx_reg, rv;
+	int cs_reg, ds_reg, ip_reg, cx_reg, di_reg, rv;
+	extern struct w_files *current_exe;
 	/* 
 	 * Is this a library? 
 	 */
 	if (wpnt->ne->ne_header->format_flags & 0x8000)
 	{
-	    if (!(wpnt->ne->ne_header->format_flags & 0x0001))
-	    {
-		/* Not SINGLEDATA */
-		fprintf(stderr, "Library is not marked SINGLEDATA\n");
-		exit(1);
-	    }
-
-	    ds_reg = wpnt->ne->selector_table[wpnt->ne->
+  	    if (!(wpnt->ne->ne_header->format_flags & 0x0001))
+	    if(wpnt->ne->ne_header->format_flags & NE_FFLAGS_MULTIPLEDATA
+		|| wpnt->ne->ne_header->auto_data_seg)
+  	    {
+  		/* Not SINGLEDATA */
+  		fprintf(stderr, "Library is not marked SINGLEDATA\n");
+  		exit(1);
+	    } else { /* DATA NONE DLL */
+		ds_reg = current_exe->ne->selector_table[
+		        current_exe->ne->ne_header->auto_data_seg-1].selector;
+		cx_reg = 0;
+	    } else { /* DATA SINGLE DLL */
+		    ds_reg = wpnt->ne->selector_table[wpnt->ne->
 					  ne_header->auto_data_seg-1].selector;
-	    cs_reg = wpnt->ne->selector_table[wpnt->ne->ne_header->cs-1].selector;
-	    ip_reg = wpnt->ne->ne_header->ip;
-
-	    cx_reg = wpnt->ne->ne_header->local_heap_length;
-
+		    cx_reg = wpnt->ne->ne_header->local_heap_length;
+  	    }
+  
+  	    cs_reg = wpnt->ne->selector_table[wpnt->ne->ne_header->cs-1].selector;
+  	    ip_reg = wpnt->ne->ne_header->ip;
+  
+            di_reg = wpnt->hinstance;
+  
 	    if (cs_reg) {
 		dprintf_dll(stddeb,"Initializing %s, cs:ip %04x:%04x, ds %04x, cx %04x\n", 
 		    wpnt->name, cs_reg, ip_reg, ds_reg, cx_reg);
@@ -501,4 +379,101 @@
 	}
 }
 
+/**********************************************************************
+ *			NE_LoadImage
+ * Load one NE format executable into memory
+ */
+HINSTANCE NE_LoadImage(struct w_files *wpnt)
+{
+    unsigned int read_size, status, segment;
+    int i;
+
+    wpnt->ne = malloc(sizeof(struct ne_data));
+    wpnt->ne->resnamtab = NULL;
+    wpnt->ne->ne_header = malloc(sizeof(struct ne_header_s));
+
+    lseek(wpnt->fd, wpnt->mz_header->ne_offset, SEEK_SET);
+    if (read(wpnt->fd, wpnt->ne->ne_header, sizeof(struct ne_header_s)) 
+	!= sizeof(struct ne_header_s))
+	myerror("Unable to read NE header from file");
+    if(!(wpnt->ne->ne_header->format_flags & NE_FFLAGS_LIBMODULE)){
+	if(current_exe)printf("Warning: more than one EXE\n");
+        current_exe=wpnt;
+    }
+
+#ifndef WINELIB
+    /*
+     * Create segment selectors.
+     */
+    status = lseek(wpnt->fd, wpnt->mz_header->ne_offset + 
+		   wpnt->ne->ne_header->segment_tab_offset,
+		   SEEK_SET);
+    read_size  = wpnt->ne->ne_header->n_segment_tab *
+	sizeof(struct ne_segment_table_entry_s);
+    wpnt->ne->seg_table = (struct ne_segment_table_entry_s *) malloc(read_size);
+    if (read(wpnt->fd, wpnt->ne->seg_table, read_size) != read_size)
+	myerror("Unable to read segment table header from file");
+    wpnt->ne->selector_table = CreateSelectors(wpnt);
+    if(wpnt->ne->ne_header->auto_data_seg==0)
+    {
+        printf("DATA NONE DLL %s\n",wpnt->name);
+        wpnt->hinstance=current_nodata++;
+    } else
+    wpnt->hinstance = (wpnt->ne->
+		       selector_table[wpnt->ne->ne_header->auto_data_seg-1].
+		       selector);
+    if (wpnt->hinstance == 0)
+    	wpnt->hinstance = 0xf000;
+#endif
+    /* Get the lookup  table.  This is used for looking up the addresses
+       of functions that are exported */
+
+    read_size  = wpnt->ne->ne_header->entry_tab_length;
+    wpnt->ne->lookup_table = (char *) malloc(read_size);
+    lseek(wpnt->fd, wpnt->mz_header->ne_offset + 
+	  wpnt->ne->ne_header->entry_tab_offset, SEEK_SET);
+    if (read(wpnt->fd, wpnt->ne->lookup_table, read_size) != read_size)
+	myerror("Unable to read lookup table header from file");
+
+    /* Get the iname table.  This is used for looking up the names
+       of functions that are exported */
+
+    status = lseek(wpnt->fd, wpnt->ne->ne_header->nrname_tab_offset,  SEEK_SET);
+    read_size  = wpnt->ne->ne_header->nrname_tab_length;
+    wpnt->ne->nrname_table = (char *) malloc(read_size);
+    if (read(wpnt->fd, wpnt->ne->nrname_table, read_size) != read_size)
+	myerror("Unable to read nrname table header from file");
+
+    status = lseek(wpnt->fd, wpnt->mz_header->ne_offset + 
+		   wpnt->ne->ne_header->rname_tab_offset,  SEEK_SET);
+    read_size  = wpnt->ne->ne_header->moduleref_tab_offset - 
+	    wpnt->ne->ne_header->rname_tab_offset;
+    wpnt->ne->rname_table = (char *) malloc(read_size);
+    if (read(wpnt->fd, wpnt->ne->rname_table, read_size) != read_size)
+	myerror("Unable to read rname table header from file");
+
+    /*
+     * Now load any DLLs that  this module refers to.
+     */
+    for(i=0; i<wpnt->ne->ne_header->n_mod_ref_tab; i++)
+    {
+      char buff[14];
+      NE_GetModuleName(wpnt, i + 1, buff);
+
+      if (strcasecmp(buff, wpnt->name) != 0 )
+	LoadImage(buff, DLL, 0);
+    }
+#ifndef WINELIB
+    /* fixup references */
+
+    for (segment = 0; segment < wpnt->ne->ne_header->n_segment_tab; segment++)
+	if (NE_FixupSegment(wpnt, segment) < 0)
+		myerror("fixup failed.");
+
+    FixupFunctionPrologs(wpnt);
+    InitializeLoadedDLLs(wpnt);
+#endif
+    return(wpnt->hinstance);
+}
+
 #endif /* !WINELIB */
diff --git a/loader/ne_resource.c b/loader/ne_resource.c
index aeeab19..9a3e56d 100644
--- a/loader/ne_resource.c
+++ b/loader/ne_resource.c
@@ -1,6 +1,7 @@
+/*
 static char RCSId[] = "$Id: ne_resource.c,v 1.4 1993/07/04 04:04:21 root Exp root $";
 static char Copyright[] = "Copyright  Robert J. Amstadt, 1993";
-
+*/
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -13,6 +14,8 @@
 #include "peexe.h"
 #include "arch.h"
 #include "dlls.h"
+#include "library.h"
+#include "heap.h"
 #include "resource.h"
 #include "stddebug.h"
 #include "debug.h"
diff --git a/loader/pe_image.c b/loader/pe_image.c
index 78b536b..9caded6 100644
--- a/loader/pe_image.c
+++ b/loader/pe_image.c
@@ -17,6 +17,7 @@
 #include "dlls.h"
 #include "neexe.h"
 #include "peexe.h"
+#include "pe_image.h"
 
 #define MAP_ANONYMOUS	0x20
 
@@ -133,10 +134,10 @@
 }
 
 /**********************************************************************
- *			LoadPEImage
+ *			PE_LoadImage
  * Load one PE format executable into memory
  */
-HINSTANCE LoadPEImage(struct w_files *wpnt)
+HINSTANCE PE_LoadImage(struct w_files *wpnt)
 {
 	int i, result;
 
@@ -159,8 +160,8 @@
 	for(i=0; i < wpnt->pe->pe_header->coff.NumberOfSections; i++)
 	{
 	if(!load_addr) {
-		result = xmmap(0, wpnt->pe->pe_seg[i].Size_Of_Raw_Data, 7, MAP_PRIVATE, 
-		      wpnt->fd, wpnt->pe->pe_seg[i].PointerToRawData);
+		result = xmmap((char *)0, wpnt->pe->pe_seg[i].Size_Of_Raw_Data, 7,
+			MAP_PRIVATE, wpnt->fd, wpnt->pe->pe_seg[i].PointerToRawData);
 		load_addr = (unsigned int) result -  wpnt->pe->pe_seg[i].Virtual_Address;
 	} else {
 		result = xmmap((char *) load_addr + wpnt->pe->pe_seg[i].Virtual_Address, 
@@ -190,20 +191,20 @@
 	return (wpnt->hinstance);
 }
 
-int PEunloadImage(struct w_files *wpnt)
+int PE_UnloadImage(struct w_files *wpnt)
 {
 	printf("PEunloadImage() called!\n");
 	/* free resources, image, unmap */
 	return 1;
 }
 
-int StartPEprogram(struct w_files *wpnt)
+int PE_StartProgram(struct w_files *wpnt)
 {
 	printf("StartPEprogram() called!\n");
 	return 0;
 }
 
-void InitPEDLL(struct w_files *wpnt)
+void PE_InitDLL(struct w_files *wpnt)
 {
 	/* Is this a library? */
 	if (wpnt->pe->pe_header->coff.Characteristics & IMAGE_FILE_DLL) {
diff --git a/loader/pe_resource.c b/loader/pe_resource.c
index 41fa92d..9efec34 100644
--- a/loader/pe_resource.c
+++ b/loader/pe_resource.c
@@ -1,5 +1,5 @@
 /*
- *	(c) 1994	Erik Bos	<erik@hacktic.nl>
+ *	(c) 1994	Erik Bos	<erik@xs4all.nl>
  *
  *	based on Eric Youndale's pe-test and:
  *
@@ -17,10 +17,10 @@
 #include "neexe.h"
 #include "peexe.h"
 #include "dlls.h"
+#include "pe_image.h"
 #include "resource.h"
 #include "stddebug.h"
 /* #define DEBUG_RESOURCE */
-/* #undef  DEBUG_RESOURCE */
 #include "debug.h"
 
 
diff --git a/loader/resource.c b/loader/resource.c
index 2c4238b..adee0cf 100644
--- a/loader/resource.c
+++ b/loader/resource.c
@@ -1,6 +1,7 @@
+/*
 static char RCSId[] = "$Id: resource.c,v 1.4 1993/07/04 04:04:21 root Exp root $";
 static char Copyright[] = "Copyright  Robert J. Amstadt, 1993";
-
+*/
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -9,27 +10,22 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include "arch.h"
-#include "prototypes.h"
 #include "windows.h"
 #include "gdi.h"
-#include "wine.h"
+#include "neexe.h"
 #include "icon.h"
 #include "menu.h"
 #include "accel.h"
 #include "dlls.h"
 #include "resource.h"
+#include "library.h"
 #include "stddebug.h"
-/* #define DEBUG_RESOURCE */
-/* #undef  DEBUG_RESOURCE */
-/* #define DEBUG_ACCEL    */
-/* #undef  DEBUG_ACCEL    */
 #include "debug.h"
 #include "../rc/sysresbm.h"
 
 #define MIN(a,b)	((a) < (b) ? (a) : (b))
 
 RESOURCE *Top = NULL;
-extern HINSTANCE hSysRes;
 
 extern int NE_FindResource(HANDLE, LPSTR, LPSTR, RESOURCE *);
 extern int PE_FindResource(HANDLE, LPSTR, LPSTR, RESOURCE *);
@@ -50,13 +46,13 @@
 	RESOURCE *r;
 	HANDLE rh;
 
-#ifdef DEBUG_RESOURCE 
+	if(debugging_resource){
 	printf("FindResource(%04X", instance);
 	PrintId(name);
 	PrintId(type);
 	printf(")\n");
-#endif
-
+	}
+	
 	if (instance == (HANDLE)NULL)
 		instance = hSysRes;
 
@@ -364,11 +360,11 @@
     int 	image_size;
     HBITMAP     hbmpOld1, hbmpOld2;
 
-#ifdef DEBUG_RESOURCE
+    if(debugging_resource){
 	printf("LoadIcon(%04X", instance);
 	PrintId(icon_name);
 	printf(")\n");
-#endif
+    }
     
     if (!(hdc = GetDC(GetDesktopWindow()))) return 0;
     rsc_mem = RSC_LoadResource(instance, icon_name, (LPSTR) NE_RSCTYPE_GROUP_ICON, 
@@ -545,11 +541,11 @@
     ACCELHEADER	*lpAccelTbl;
     int 	i, image_size, n;
 
-#ifdef DEBUG_ACCEL
+    if(debugging_accel){
 	printf("LoadAccelerators(%04X", instance);
 	PrintId(lpTableName);
 	printf(")\n");
-#endif
+    }
 
     rsc_mem = RSC_LoadResource(instance, lpTableName, (LPSTR) NE_RSCTYPE_ACCELERATOR, 
 			       &image_size);
@@ -696,11 +692,11 @@
 	HANDLE		hMenu_desc;
 	MENU_HEADER 	*menu_desc;
 
-#ifdef DEBUG_MENU
+	if(debugging_menu){
 	printf("LoadMenu(%04X", instance);
 	PrintId(menu_name);
 	printf(")\n");
-#endif
+	}
 	if (menu_name == NULL)
 		return 0;
 
@@ -725,11 +721,11 @@
     int image_size;
     int size;
     
-#ifdef DEBUG_RESOURCE
+    if(debugging_resource){
 	printf("LoadBitmap(%04X", instance);
 	PrintId(bmp_name);
 	printf(")\n");
-#endif
+    }
 
     if (!instance) {
 	struct ResourceTable *it;
@@ -737,7 +733,7 @@
 	if (hbitmap)
 		return hbitmap;
 	/* Load from sysresbm */
-	dprintf_resource(stddeb,"Searching for %d\n",bmp_name);
+	dprintf_resource(stddeb,"Searching for %d\n", (int) bmp_name);
 	for(it=sysresbmTable;it->value;it++){
 	    if(it->type==NE_RSCTYPE_BITMAP)
 	    if((((int)bmp_name & 0xFFFF0000) == 0))
diff --git a/loader/selector.c b/loader/selector.c
index adb9e69..fe9ec2a 100644
--- a/loader/selector.c
+++ b/loader/selector.c
@@ -1,7 +1,8 @@
 #ifndef WINELIB
+/*
 static char RCSId[] = "$Id: selector.c,v 1.3 1993/07/04 04:04:21 root Exp root $";
 static char Copyright[] = "Copyright  Robert J. Amstadt, 1993";
-
+*/
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -10,7 +11,6 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <errno.h>
-
 #ifdef __linux__
 #include <sys/mman.h>
 #include <linux/unistd.h>
@@ -27,11 +27,11 @@
 #include "neexe.h"
 #include "segmem.h"
 #include "wine.h"
+#include "if1632.h"
 #include "windows.h"
 #include "prototypes.h"
 #include "stddebug.h"
 /* #define DEBUG_SELECTORS */
-/* #undef DEBUG_SELECTORS */
 #include "debug.h"
 
 
@@ -854,6 +854,7 @@
     int old_length, file_image_length;
     int saved_old_length;
 
+    auto_data_sel=0;
     /*
      * Allocate memory for the table to keep track of all selectors.
      */
@@ -966,6 +967,7 @@
 	}
     }
 
+    if(!auto_data_sel)dprintf_selectors(stddeb,"Warning: No auto_data_sel\n");
     s = selectors;
     for (i = 0; i < ne_header->n_segment_tab; i++, s++)
     {
diff --git a/loader/signal.c b/loader/signal.c
index 6527f1e..3cc7461 100644
--- a/loader/signal.c
+++ b/loader/signal.c
@@ -2,6 +2,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <signal.h>
+#include <string.h>
 #include <errno.h>
 #include <time.h>
 #include <setjmp.h>
@@ -20,20 +21,12 @@
 #endif
 
 #include "wine.h"
+#include "dos_fs.h"
 #include "segmem.h"
 #include "prototypes.h"
+#include "miscemu.h"
 #include "win.h"
 
-extern int do_int10(struct sigcontext_struct *);
-extern int do_int13(struct sigcontext_struct *);
-extern int do_int15(struct sigcontext_struct *);
-extern int do_int16(struct sigcontext_struct *);
-extern int do_int25(struct sigcontext_struct *);
-extern int do_int26(struct sigcontext_struct *);
-extern int do_int2a(struct sigcontext_struct *);
-extern int do_int2f(struct sigcontext_struct *);
-extern int do_int31(struct sigcontext_struct *);
- 
 #if !defined(BSD4_4) || defined(linux) || defined(__FreeBSD__)
 char * cstack[4096];
 #endif
@@ -75,7 +68,7 @@
               case 0x13: return do_int13(scp);
 	      case 0x15: return do_int15(scp);
 	      case 0x16: return do_int16(scp);
-	      case 0x1A: return do_int1A(scp);
+	      case 0x1a: return do_int1a(scp);
 	      case 0x21: return do_int21(scp);
 
 	      case 0x22:
@@ -157,6 +150,26 @@
 	    scp->sc_eip += 2;  /* Bypass the int instruction */
             break;
             
+      case 0xe4: /* inb al,XX */
+            inportb_abs(scp);
+	    scp->sc_eip += 2;
+            break;
+
+      case 0xe5: /* in ax,XX */
+            inport_abs(scp);
+	    scp->sc_eip += 2;
+            break;
+
+      case 0xe6: /* outb XX,al */
+            outportb_abs(scp);
+	    scp->sc_eip += 2;
+            break;
+
+      case 0xe7: /* out XX,ax */
+            outport_abs(scp);
+	    scp->sc_eip += 2;
+            break;
+
       case 0xec: /* inb al,dx */
             inportb(scp);
 	    scp->sc_eip++;
diff --git a/loader/task.c b/loader/task.c
index 4f99921..de42cc3 100644
--- a/loader/task.c
+++ b/loader/task.c
@@ -1,30 +1,26 @@
 /*
  *        Tasks functions
- */
+ *
 static char Copyright[] = "Copyright  Martin Ayotte, 1994";
-
-
+*/
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <sys/types.h>
 #include <unistd.h>
 #include "windows.h"
-#include "wine.h"
+#include "if1632.h"
 #include "task.h"
 #include "stddebug.h"
-/* #define DEBUG_TASK */
-/* #undef DEBUG_TASK */
 #include "debug.h"
 
-
 static LPWINETASKENTRY lpTaskList = NULL;
 static int nTaskCount = 0;
 
 /**********************************************************************
  *				GetCurrentTask	[KERNEL.36]
  */
-HTASK GetCurrentTask()
+HTASK GetCurrentTask(void)
 {
 	LPWINETASKENTRY lpTask = lpTaskList;
 	int pid = getpid();
@@ -43,7 +39,7 @@
 /**********************************************************************
  *				GetNumTasks	[KERNEL.152]
  */
-WORD GetNumTasks()
+WORD GetNumTasks(void)
 {
 	dprintf_task(stddeb,"GetNumTasks() returned %d !\n", nTaskCount);
 	return nTaskCount;
@@ -89,7 +85,8 @@
 	BOOL	bRet;
 	int		count = 0;
 	LPWINETASKENTRY lpTask = lpTaskList;
-	dprintf_task(stddeb,"EnumTaskWindows(%04X, %08X, %08X) !\n", hTask, lpEnumFunc, lParam);
+	dprintf_task(stddeb,"EnumTaskWindows(%04X, %08X, %08X) !\n", hTask, 
+		(unsigned int) lpEnumFunc, (unsigned int) lParam);
 	while (TRUE) {
 		if (lpTask->te.hTask == hTask) break;
 		if (lpTask == NULL) {
diff --git a/memory/global.c b/memory/global.c
index 9450c95..e6b0f00 100644
--- a/memory/global.c
+++ b/memory/global.c
@@ -1,18 +1,21 @@
+/*
 static char RCSId[] = "$Id: global.c,v 1.2 1993/07/04 04:04:21 root Exp root $";
 static char Copyright[] = "Copyright  Robert J. Amstadt, 1993";
+*/
 
 #define GLOBAL_SOURCE
 
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include "windows.h"
 #include "prototypes.h"
 #include "toolhelp.h"
 #include "heap.h"
 #include "segmem.h"
+#include "selectors.h"
 #include "stddebug.h"
-/* #define DEBUG_HEAP /* */
-/* #undef  DEBUG_HEAP /* */
+/* #define DEBUG_HEAP */
 #include "debug.h"
 
 
@@ -182,7 +185,7 @@
     GDESC *g_prev;
     void *m;
 
-    dprintf_heap(stddeb,"GlobalAlloc flags %4X, size %d\n", flags, size);
+    dprintf_heap(stddeb,"GlobalAlloc flags %4X, size %ld\n", flags, size);
 
     if (size == 0) size = 1;
 
@@ -259,7 +262,7 @@
 	 * We have a new block.  Let's create a GDESC entry for it.
 	 */
 	g = malloc(sizeof(*g));
-	dprintf_heap(stddeb,"New GDESC %08x\n", g);
+	dprintf_heap(stddeb,"New GDESC %08x\n", (unsigned int) g);
 	if (g == NULL)
 	    return 0;
 
@@ -356,7 +359,7 @@
 
     g->lock_count++;
 
-    dprintf_heap(stddeb,"GlobalLock: returning %08x\n", g->addr);
+    dprintf_heap(stddeb,"GlobalLock: returning %08x\n",(unsigned int)g->addr);
     return g->addr;
 }
 
@@ -621,7 +624,7 @@
 	{
 	    GDESC *g_new;
 	    GDESC *g_start = g;
-	    int old_segments = g_start->length;
+/*	    int old_segments = g_start->length;*/
 	    unsigned short next_handle = g_start->handle;
 	    
 	    for (i = 1; i <= n_segments; i++, g = g->next)
@@ -815,7 +818,7 @@
 	if (free_map[i] == 1)
 	    total_free++;
 
-    dprintf_heap(stddeb,"GetFreeSpace // return %ld !\n", total_free << 16);
+    dprintf_heap(stddeb,"GetFreeSpace // return %ld !\n", (long) (total_free << 16));
     return total_free << 16;
 }
 
diff --git a/memory/heap.c b/memory/heap.c
index 722e32d..56474e7 100644
--- a/memory/heap.c
+++ b/memory/heap.c
@@ -1,5 +1,7 @@
+/*
 static char RCSId[] = "$Id: heap.c,v 1.3 1993/07/04 04:04:21 root Exp root $";
 static char Copyright[] = "Copyright  Robert J. Amstadt, 1993";
+*/
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -8,9 +10,9 @@
 #include "segmem.h"
 #include "heap.h"
 #include "regfunc.h"
+#include "dlls.h"
 #include "stddebug.h"
-/* #define DEBUG_HEAP /* */
-/* #undef  DEBUG_HEAP /* */
+/* #define DEBUG_HEAP */
 #include "debug.h"
 
 
@@ -22,8 +24,16 @@
     MDESC *m;
 
     for (m = *free_list; m != NULL; m = m->next)
+    {
 	if (((int) m & 0xffff0000) != ((int) *free_list & 0xffff0000))
+	{   dprintf_heap(stddeb,"Invalid block %08x\n",m);
 	    *(char *)0 = 0;
+	}
+	if (m->prev && (((int) m->prev & 0xffff0000) != ((int) *free_list & 0xffff0000)))
+	{   dprintf_heap(stddeb,"Invalid prev %08x from %08x\n", m->prev, m);
+	    *(char *)0 = 0;
+	}
+    }
 }
 
 /**********************************************************************
@@ -49,11 +59,9 @@
 {
     MDESC *m, *m_new;
     
-    dprintf_heap(stddeb,"HeapAlloc: free_list %08x, flags %x, bytes %d\n", 
-	   free_list, flags, bytes);
-#ifdef DEBUG_HEAP
-    HEAP_CheckHeap(free_list);
-#endif
+    dprintf_heap(stddeb,"HeapAlloc: free_list %08x(%08x), flags %x, bytes %d\n", 
+	   (unsigned int) free_list, (unsigned int) *free_list, flags, bytes);
+    if(debugging_heap)HEAP_CheckHeap(free_list);
 
     /*
      * Find free block big enough.
@@ -86,10 +94,9 @@
 	    m->flags = 0;
 	    if (flags & GLOBAL_FLAGS_ZEROINIT)
 		memset(m + 1, 0, bytes);
-	    dprintf_heap(stddeb,"HeapAlloc: returning %08x\n", (m + 1));
-#ifdef DEBUG_HEAP
-	    HEAP_CheckHeap(free_list);
-#endif
+	    dprintf_heap(stddeb,"HeapAlloc: returning %08x\n", 
+	    	(unsigned int) (m + 1));
+	    if(debugging_heap)HEAP_CheckHeap(free_list);
 	    return (void *) (m + 1);
 	}
     }
@@ -110,17 +117,14 @@
 	m->flags = 0;
 	if (flags & GLOBAL_FLAGS_ZEROINIT)
 	    memset(m + 1, 0, bytes);
-	dprintf_heap(stddeb,"HeapAlloc: returning %08x\n", (m + 1));
-#ifdef DEBUG_HEAP
-	HEAP_CheckHeap(free_list);
-#endif
+	dprintf_heap(stddeb,"HeapAlloc: returning %08x\n",
+	    	(unsigned int)  (m + 1));
+        if(debugging_heap)HEAP_CheckHeap(free_list);
 	return (void *) (m + 1);
     }
 
     dprintf_heap(stddeb,"HeapAlloc: returning %08x\n", 0);
-#ifdef DEBUG_HEAP
-    HEAP_CheckHeap(free_list);
-#endif
+    if(debugging_heap)HEAP_CheckHeap(free_list);
     return 0;
 }
 
@@ -143,15 +147,19 @@
      */
     m = (MDESC *) old_block - 1;
 
-    dprintf_heap(stddeb,"HEAP_ReAlloc new_size=%d !\n", new_size);
-    dprintf_heap(stddeb,"HEAP_ReAlloc old_block=%08X !\n", old_block);
-    dprintf_heap(stddeb,"HEAP_ReAlloc m=%08X free_list=%08X !\n", m,free_list);
-    dprintf_heap(stddeb,"HEAP_ReAlloc m->prev=%08X !\n", m->prev);
-    dprintf_heap(stddeb,"HEAP_ReAlloc m->next=%08X !\n", m->next);
-    dprintf_heap(stddeb,"HEAP_ReAlloc *free_list=%08X !\n", *free_list);
-#ifdef DEBUG_HEAP
-    HEAP_CheckHeap(free_list);
-#endif
+    dprintf_heap(stddeb,"HEAP_ReAlloc new_size=%d !\n", 
+	    	(unsigned int) new_size);
+    dprintf_heap(stddeb,"HEAP_ReAlloc old_block=%08X !\n",
+	    	(unsigned int)  old_block);
+    dprintf_heap(stddeb,"HEAP_ReAlloc m=%08X free_list=%08X !\n", 
+	    	(unsigned int) m, (unsigned int) free_list);
+    dprintf_heap(stddeb,"HEAP_ReAlloc m->prev=%08X !\n",
+    	 (unsigned int)  m->prev);
+    dprintf_heap(stddeb,"HEAP_ReAlloc m->next=%08X !\n",
+    	 (unsigned int)  m->next);
+    dprintf_heap(stddeb,"HEAP_ReAlloc *free_list=%08X !\n",
+    	 (unsigned int)  *free_list);
+    if(debugging_heap)HEAP_CheckHeap(free_list);
 
     if (m->prev != m || m->next != m || 
 	((int) m & 0xffff0000) != ((int) *free_list & 0xffff0000))
@@ -179,9 +187,7 @@
 		return NULL;
 	    memcpy(new_p, old_block, m->length);
 	    HEAP_Free(free_list, old_block);
-#ifdef DEBUG_HEAP
-	    HEAP_CheckHeap(free_list);
-#endif
+	    if(debugging_heap)HEAP_CheckHeap(free_list);
 	    return new_p;
 	}
 
@@ -214,9 +220,7 @@
 	HEAP_Free(free_list, m_free + 1);
     }
     
-#ifdef DEBUG_HEAP
-    HEAP_CheckHeap(free_list);
-#endif
+    if(debugging_heap)HEAP_CheckHeap(free_list);
     return old_block;
 }
 
@@ -233,9 +237,7 @@
 
     dprintf_heap(stddeb,"HeapFree: free_list %08x, block %08x\n", 
 	   free_list, block);
-#ifdef DEBUG_HEAP
-    HEAP_CheckHeap(free_list);
-#endif
+    if(debugging_heap)HEAP_CheckHeap(free_list);
 
     /*
      * Validate pointer.
@@ -332,28 +334,44 @@
 	m_free->next = NULL;
     }
 
-#ifdef DEBUG_HEAP
-    HEAP_CheckHeap(free_list);
-#endif
+    if(debugging_heap)HEAP_CheckHeap(free_list);
     return 0;
 }
 
 /**********************************************************************
+ *					HEAP_CheckLocalHeaps
+ */
+void
+HEAP_CheckLocalHeaps(char *file,int line)
+{
+    LHEAP *lh;
+    dprintf_heap(stddeb,"CheckLocalHeaps called from %s %d\n",file,line);
+    for(lh=LocalHeaps; lh!=NULL; lh = lh->next)
+    {	dprintf_heap(stddeb,"Checking heap %08x, free_list %08x\n",
+		lh,lh->free_list);
+	HEAP_CheckHeap(&lh->free_list);
+    }
+}
+
+
+/**********************************************************************
  *					HEAP_LocalFindHeap
  */
 LHEAP *
 HEAP_LocalFindHeap(unsigned short owner)
 {
     LHEAP *lh;
+    extern struct w_files *current_exe;
     
     dprintf_heap(stddeb,"HEAP_LocalFindHeap: owner %04x\n", owner);
-    
+
     for (lh = LocalHeaps; lh != NULL; lh = lh->next)
     {
 	if (lh->selector == owner)
 	    return lh;
     }
 
+    dprintf_heap(stddeb,"Warning: Local heap not found\n");
     return NULL;
 }
 
@@ -380,6 +398,7 @@
     lh->local_table = NULL;
     lh->delta       = 0x20;
     HEAP_Init(&lh->free_list, start, length);
+    dprintf_heap(stddeb,"HEAP_LocalInit: free_list %08x, length %04x, prev %08x, next %08x\n",&lh->free_list,lh->free_list->length, lh->free_list->prev,lh->free_list->next);
     LocalHeaps = lh;
 }
 
@@ -408,7 +427,7 @@
     void *m;
     
     dprintf_heap(stddeb,"WIN16_LocalAlloc: flags %x, bytes %d\n", flags,bytes);
-    dprintf_heap(stddeb,"    called from segment %04x\n", Stack16Frame[11]);
+    dprintf_heap(stddeb,"    called from segment %04x, ds=%04x\n", Stack16Frame[11],Stack16Frame[6]);
 
     m = HEAP_Alloc(LOCALHEAP(), flags, bytes);
 	
diff --git a/memory/linear.c b/memory/linear.c
index 1ebb17b..cab6fb9 100644
--- a/memory/linear.c
+++ b/memory/linear.c
@@ -1,6 +1,7 @@
+/*
 static char RCSId[] = "$Id$";
 static char Copyright[] = "Copyright  Robert J. Amstadt, 1994";
-
+*/
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/misc/atom.c b/misc/atom.c
index 2822350..d6fa988 100644
--- a/misc/atom.c
+++ b/misc/atom.c
@@ -73,7 +73,7 @@
     }
     else
     {
-	handle = LocalAlign ( LMEM_MOVEABLE, sizeof(ATOMTABLE) +
+	handle = (HANDLE) LocalAlign ( LMEM_MOVEABLE, sizeof(ATOMTABLE) +
 			     (entries-1) * sizeof(HANDLE) );
 	if (!handle) 
 	    return FALSE;
diff --git a/misc/clipboard.c b/misc/clipboard.c
index 5e82d52..e8a0cf9 100644
--- a/misc/clipboard.c
+++ b/misc/clipboard.c
@@ -2,9 +2,8 @@
  * 'Wine' Clipboard function handling
  *
  * Copyright 1994 Martin Ayotte
- */
-
 static char Copyright[] = "Copyright Martin Ayotte, 1994";
+*/
 
 #include <stdlib.h>
 #include <stdio.h>
@@ -18,9 +17,8 @@
 #include "prototypes.h"
 #include "heap.h"
 #include "win.h"
+#include "clipboard.h"
 #include "stddebug.h"
-/* #define DEBUG_CLIPBOARD /* */
-/* #undef  DEBUG_CLIPBOARD /* */
 #include "debug.h"
 
 typedef struct tagCLIPFORMAT {
@@ -304,6 +302,8 @@
 {
     dprintf_clipboard(stdnimp,
 		"ChangeClipboardChain(%04X, %04X) !\n", hWnd, hWndNext);
+
+     return 0;
 }
 
 
@@ -343,6 +343,8 @@
 {
     dprintf_clipboard(stdnimp,
 	"GetPriorityClipboardFormat(%p, %d) !\n", lpPriorityList, nCount);
+
+    return 0;
 }
 
 
diff --git a/misc/commdlg.c b/misc/commdlg.c
index aa1614b..f9a6298 100644
--- a/misc/commdlg.c
+++ b/misc/commdlg.c
@@ -2,19 +2,22 @@
  * COMMDLG functions
  *
  * Copyright 1994 Martin Ayotte
- */
 static char Copyright[] = "Copyright  Martin Ayotte, 1994";
+*/
 
 /*
 #define DEBUG_OPENDLG
 #define DEBUG_OPENDLG_DRAW
 */
 
-#include "stdio.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 #include "dialog.h"
 #include "win.h"
 #include "user.h"
 #include "message.h"
+#include "library.h"
 #include "heap.h"
 #include "commdlg.h"
 #include "dlgs.h"
@@ -22,8 +25,6 @@
 #define OPENFILEDLG2			11
 #define SAVEFILEDLG2			12
 
-
-extern 	HINSTANCE 	hSysRes;
 static	DWORD 		CommDlgLastError = 0;
 
 static	HBITMAP		hFolder = 0;
diff --git a/misc/dos_fs.c b/misc/dos_fs.c
index ae19ea3..54bf564 100644
--- a/misc/dos_fs.c
+++ b/misc/dos_fs.c
@@ -25,9 +25,10 @@
 #include <sys/mount.h>
 #endif
 
+#include "wine.h"
 #include "windows.h"
 #include "msdos.h"
-#include "prototypes.h"
+/* #include "dos_fs.h" */
 #include "autoconf.h"
 #include "comm.h"
 #include "stddebug.h"
@@ -178,8 +179,6 @@
 	int parallelports = 0;
 	int serialports = 0;
 	int x;
-	extern struct DosDeviceStruct COM[MAX_PORTS];
-	extern struct DosDeviceStruct LPT[MAX_PORTS];
 
 /* borrowed from Ralph Brown's interrupt lists 
 
@@ -255,7 +254,7 @@
 	char *dirname;
 	struct stat s;
 	dprintf_dosfs(stddeb, "DOS_ValidDirectory: '%s'\n", name);
-	if ((dirname = GetUnixFileName(name)) == NULL)
+	if ((dirname = DOS_GetUnixFileName(name)) == NULL)
 		return 0;
 	if (stat(dirname,&s))
 		return 0;
@@ -392,7 +391,7 @@
 
 }
 
-char *GetUnixFileName(char *dosfilename)
+char *DOS_GetUnixFileName(char *dosfilename)
 { 
 	/*   a:\windows\system.ini  =>  /dos/windows/system.ini */
 	
@@ -418,7 +417,7 @@
 	return(temp);
 }
 
-char *GetDosFileName(char *unixfilename)
+char *DOS_GetDosFileName(char *unixfilename)
 { 
 	int i;
 	static char temp[256], rootdir[256];
@@ -555,7 +554,7 @@
 	return 1;
 }
 
-char *FindFile(char *buffer, int buflen, char *filename, char **extensions, 
+char *DOS_FindFile(char *buffer, int buflen, char *filename, char **extensions, 
 		char *path)
 {
     char *workingpath, *dirname, *rootname, **e;
@@ -566,7 +565,7 @@
 
     if (strchr(filename, '\\') != NULL)
     {
-	strncpy(buffer, GetUnixFileName(filename), buflen);
+	strncpy(buffer, DOS_GetUnixFileName(filename), buflen);
 	stat( buffer, &filestat);
 	if (S_ISREG(filestat.st_mode))
 	    return buffer;
@@ -580,7 +579,7 @@
 	return buffer;
     }
 
-    dprintf_dosfs(stddeb,"FindFile: looking for %s\n", filename);
+    dprintf_dosfs(stddeb,"DOS_FindFile: looking for %s\n", filename);
     rootnamelen = strlen(filename);
     rootname = strdup(filename);
     ToUnix(rootname);
@@ -591,7 +590,7 @@
 	dirname = strtok(NULL, ";"))
     {
 	if (strchr(dirname, '\\') != NULL)
-		d = opendir( GetUnixFileName(dirname) );
+		d = opendir( DOS_GetUnixFileName(dirname) );
 	else
 		d = opendir( dirname );
 
@@ -618,7 +617,7 @@
 		    if (found)
 		    {
 			if (strchr(dirname, '\\') != NULL)
-				strncpy(buffer, GetUnixFileName(dirname), buflen);
+				strncpy(buffer, DOS_GetUnixFileName(dirname), buflen);
 			else
 				strncpy(buffer, dirname, buflen);
 
@@ -679,7 +678,7 @@
 		
 	name = malloc(1024);
 
-	strcpy(name, GetUnixFileName(WindowsDirectory));
+	strcpy(name, DOS_GetUnixFileName(WindowsDirectory));
 	strcat(name, "/");
 	strcat(name, "win.ini");
 
@@ -732,7 +731,7 @@
 	if (x == MAX_OPEN_DIRS)
 		return NULL;
 
-	if ((unixdirname = GetUnixFileName(dosdirname)) == NULL)
+	if ((unixdirname = DOS_GetUnixFileName(dosdirname)) == NULL)
 		return NULL;
 
 	strcpy(temp, unixdirname);
diff --git a/misc/driver.c b/misc/driver.c
index 425638f..c39c3e7 100644
--- a/misc/driver.c
+++ b/misc/driver.c
@@ -2,9 +2,8 @@
  * Wine Drivers functions
  *
  * Copyright 1994 Martin Ayotte
- */
-
 static char Copyright[] = "Copyright  Martin Ayotte, 1994";
+*/
 
 #include <stdio.h>
 #include "windows.h"
@@ -13,13 +12,11 @@
 #include "dlls.h"
 #include "driver.h"
 #include "stddebug.h"
-/* #define DEBUG_DRIVER /* */
-/* #undef  DEBUG_DRIVER /* */
 #include "debug.h"
 
 LPDRIVERITEM lpDrvItemList = NULL;
 
-void LoadStartupDrivers()
+void LoadStartupDrivers(void)
 {
 	HDRVR	hDrv;
 	char	str[256];
diff --git a/misc/escape.c b/misc/escape.c
index a4f6a6f..b848f3a 100644
--- a/misc/escape.c
+++ b/misc/escape.c
@@ -2,9 +2,9 @@
  * Escape() function.
  *
  * Copyright 1994  Bob Amstadt
- */
-
+ *
 static char Copyright[] = "Copyright  Bob Amstadt, 1994";
+*/
 
 #include <stdlib.h>
 #include <stdio.h>
diff --git a/misc/exec.c b/misc/exec.c
index c1b9605..df0bee6 100644
--- a/misc/exec.c
+++ b/misc/exec.c
@@ -11,11 +11,12 @@
 #include "segmem.h"
 #include "prototypes.h"
 #include "dlls.h"
-#include "wine.h"
 #include "windows.h"
+#include "if1632.h"
+#include "callback.h"
+#include "library.h"
+#include "ne_image.h"
 #include "stddebug.h"
-/* #define DEBUG_EXEC /* */
-/* #undef  DEBUG_EXEC /* */
 #include "debug.h"
 
 #define HELP_CONTEXT      0x0001
@@ -33,8 +34,6 @@
 #define HELP_MULTIKEY     0x0201
 #define HELP_SETWINPOS    0x0203
 
-extern struct  w_files * wine_files;
-
 typedef struct {
 	WORD	wEnvSeg;
 	LPSTR	lpCmdLine;
@@ -44,9 +43,6 @@
 
 typedef BOOL (CALLBACK * LPFNWINMAIN)(HANDLE, HANDLE, LPSTR, int);
 
-
-extern int CallToInit16(unsigned long csip, unsigned long sssp, 
-			unsigned short ds);
 HANDLE CreateNewTask(HINSTANCE hInst);
 
 #ifndef WINELIB
@@ -113,7 +109,7 @@
     	dprintf_exec(stddeb,"StartNewTask() // before FixupSegment !\n");
 	for(w = wpnt; w; w = w->next)	{
 		for (segment = 0; segment < w->ne->ne_header->n_segment_tab; segment++) {
-			if (FixupSegment(w, segment) < 0) {
+			if (NE_FixupSegment(w, segment) < 0) {
 				myerror("fixup failed.");
 				}
 			}
@@ -227,6 +223,8 @@
 {
     dprintf_exec(stdnimp,"EMPTY STUB !!! ExitWindows(%08lX, %04X) !\n", 
 		dwReserved, wRetCode);
+
+   exit(wRetCode);
 }
 
 
diff --git a/misc/file.c b/misc/file.c
index 5a9ecee..f97e28f 100644
--- a/misc/file.c
+++ b/misc/file.c
@@ -8,7 +8,7 @@
  * NOV 93 Erik Bos (erik@xs4all.nl)
  *		- removed ParseDosFileName, and DosDrive structures.
  *		- structures dynamically configured at runtime.
- *		- _lopen modified to use GetUnixFileName.
+ *		- _lopen modified to use DOS_GetUnixFileName.
  *		- Existing functions modified to use dosfs functions.
  *		- Added _llseek, _lcreat, GetDriveType, GetTempDrive, 
  *		  GetWindowsDirectory, GetSystemDirectory, GetTempFileName.
@@ -22,7 +22,7 @@
 #include <time.h>
 #include <sys/stat.h>
 #include <string.h>
-#include "prototypes.h"
+#include "dos_fs.h"
 #include "regfunc.h"
 #include "windows.h"
 #include "wine.h"
@@ -30,20 +30,11 @@
 #include "registers.h"
 #include "options.h"
 #include "stddebug.h"
-/* #define DEBUG_FILE /* */
-/* #undef  DEBUG_FILE /* */
 #include "debug.h"
 
 #define MAX_PATH 255
 
 char WindowsDirectory[256], SystemDirectory[256], TempDirectory[256];
-extern char WindowsPath[256];
-
-extern char WindowsPath[];
-extern WORD ExtendedError;
-
-
-char *GetDosFileName(char *unixfilename);
 
 /***************************************************************************
  _lopen 
@@ -56,7 +47,7 @@
   char *UnixFileName;
 
   dprintf_file(stddeb, "_lopen: open('%s', %X);\n", lpPathName, iReadWrite);
-  if ((UnixFileName = GetUnixFileName(lpPathName)) == NULL)
+  if ((UnixFileName = DOS_GetUnixFileName(lpPathName)) == NULL)
   	return HFILE_ERROR;
   iReadWrite &= 0x000F;
   handle =  open (UnixFileName, iReadWrite);
@@ -122,7 +113,6 @@
  **************************************************************************/
 INT OpenFile (LPSTR lpFileName, LPOFSTRUCT ofs, WORD wStyle)
 {
-    int		              handle;
 #ifndef PROCEMU
     struct sigcontext_struct  ccontext;
                               /* To make macros like EAX happy */
@@ -155,7 +145,7 @@
       ofs->nErrCode = 0;
       *((int*)ofs->reserved) = 0;
 
-      if ((unixfilename = GetUnixFileName (ofs->szPathName)) == NULL)
+      if ((unixfilename = DOS_GetUnixFileName (ofs->szPathName)) == NULL)
       {
         errno_to_doserr();
 	ofs->nErrCode = ExtendedError;
@@ -181,23 +171,23 @@
 	{
 	  char temp[MAX_PATH+1];
 	  strcpy (filename, lpFileName);
-	  if ( (!stat(GetUnixFileName(filename), &s)) && (S_ISREG(s.st_mode)) )
+	  if ( (!stat(DOS_GetUnixFileName(filename), &s)) && (S_ISREG(s.st_mode)) )
 	    break;
 	  GetWindowsDirectory (filename,MAX_PATH);
 	  if ((!filename[0])||(filename[strlen(filename)-1]!='\\'))
             strcat(filename, "\\");
 	  strcat (filename, lpFileName);
-	  if ( (!stat(GetUnixFileName(filename), &s)) && (S_ISREG(s.st_mode)) )
+	  if ( (!stat(DOS_GetUnixFileName(filename), &s)) && (S_ISREG(s.st_mode)) )
 	    break;
 	  GetSystemDirectory (filename,MAX_PATH);
 	  if ((!filename[0])||(filename[strlen(filename)-1]!='\\'))
  	    strcat(filename, "\\");
 	  strcat (filename, lpFileName);
-	  if ( (!stat(GetUnixFileName(filename), &s)) && (S_ISREG(s.st_mode)) )
+	  if ( (!stat(DOS_GetUnixFileName(filename), &s)) && (S_ISREG(s.st_mode)) )
 	    break;
-	  if (!FindFile(temp,MAX_PATH,lpFileName,NULL,WindowsPath))
+	  if (!DOS_FindFile(temp,MAX_PATH,lpFileName,NULL,WindowsPath))
 	    {
-	      strcpy(filename, GetDosFileName(temp));
+	      strcpy(filename, DOS_GetDosFileName(temp));
 	      break;
 	    }
 	  strcpy (filename, lpFileName);
@@ -224,7 +214,7 @@
 
     /* Now on to getting some information about that file */
 
-    if (res = stat(GetUnixFileName(ofs->szPathName), &s))
+    if ((res = stat(DOS_GetUnixFileName(ofs->szPathName), &s)))
       {
       errno_to_doserr();
       ofs->nErrCode = ExtendedError;
@@ -232,21 +222,21 @@
     }
     
     now = localtime (&s.st_mtime);
-  
+
     if (action & OF_VERIFY)
       verify_time = *((int*)ofs->reserved);
-  
+    
     *((WORD*)(&ofs->reserved[2]))=
          ((now->tm_hour * 0x2000) + (now->tm_min * 0x20) + (now->tm_sec / 2));
     *((WORD*)(&ofs->reserved[0]))=
          ((now->tm_year * 0x200) + (now->tm_mon * 0x20) + now->tm_mday);
-    
-    if (action & OF_EXIST)
-      return 0;
+
 
     if (action & OF_VERIFY)
       return (verify_time != *((int*)ofs->reserved));
-    
+
+    if (action & OF_EXIST)
+      return 0;
     
    /* Now we are actually going to open the file. According to Microsoft's
        Knowledge Basis, this is done by calling int 21h, ax=3dh. */    
@@ -317,7 +307,7 @@
 
     	dprintf_file(stddeb, "_lcreat: filename %s, attributes %d\n",
 		lpszFilename, fnAttribute);
-	if ((UnixFileName = GetUnixFileName(lpszFilename)) == NULL)
+	if ((UnixFileName = DOS_GetUnixFileName(lpszFilename)) == NULL)
   		return HFILE_ERROR;
 	handle =  open (UnixFileName, O_CREAT | O_TRUNC | O_WRONLY, 426);
 
@@ -422,6 +412,8 @@
 WORD SetErrorMode(WORD x)
 {
     dprintf_file(stdnimp,"wine: SetErrorMode %4x (ignored)\n",x);
+
+    return 1;
 }
 
 /***************************************************************************
diff --git a/misc/keyboard.c b/misc/keyboard.c
index 778dea1..9a07198 100644
--- a/misc/keyboard.c
+++ b/misc/keyboard.c
@@ -1,5 +1,7 @@
+/*
 static char RCSId[] = "$Id: keyboard.c,v 1.2 1993/09/13 18:52:02 scott Exp $";
 static char Copyright[] = "Copyright  Scott A. Laird, Erik Bos  1993, 1994";
+*/
 
 #include <stdlib.h>
 #include <stdio.h>
@@ -8,8 +10,7 @@
 #include "windows.h"
 #include "keyboard.h"
 #include "stddebug.h"
-/* #define DEBUG_KEYBOARD /* */
-/* #undef  DEBUG_KEYBOARD /* */
+/* #define DEBUG_KEYBOARD */
 #include "debug.h"
 
 int ToAscii(WORD wVirtKey, WORD wScanCode, LPSTR lpKeyState, 
diff --git a/misc/lstr.c b/misc/lstr.c
index 41174f3..aaf47f3 100644
--- a/misc/lstr.c
+++ b/misc/lstr.c
@@ -1,5 +1,6 @@
+/*
 static char Copyright[] = "Copyright  Yngvi Sigurjonsson (yngvi@hafro.is), 1993";
-
+*/
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -164,15 +165,14 @@
   return (current==start)?start:current-1;
 }
 
-static char Oem2Ansi[256];
-static char Ansi2Oem[256];
+BYTE Oem2Ansi[256], Ansi2Oem[256];
 
 void InitOemAnsiTranslations(void)
 {
   static int inited=0; /* should called called in some init function*/
   int transfile,i;
   if(inited) return;
-  if(transfile=open("oem2ansi.trl",O_RDONLY)){
+  if((transfile=open("oem2ansi.trl",O_RDONLY))){
     read(transfile,Oem2Ansi,256);
     close(transfile);
   }
@@ -180,7 +180,7 @@
     for(i=0;i<256;i++)  /* Needs some fixing */
       Oem2Ansi[i]=i;  
   }
-  if(transfile=open("ansi2oem.trl",O_RDONLY)){
+  if((transfile=open("ansi2oem.trl",O_RDONLY))){
     read(transfile,Ansi2Oem,256);
     close(transfile);
   }
diff --git a/misc/main.c b/misc/main.c
index 3b9250e..74a8778 100644
--- a/misc/main.c
+++ b/misc/main.c
@@ -2,10 +2,9 @@
  * Main function.
  *
  * Copyright 1994 Alexandre Julliard
- */
-
+ *
 static char Copyright[] = "Copyright  Alexandre Julliard, 1994";
-
+*/
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -15,15 +14,30 @@
 #include <X11/Xresource.h>
 #include <X11/Xutil.h>
 #include <X11/cursorfont.h>
+#include "wine.h"
 #include "msdos.h"
 #include "windows.h"
+#include "comm.h"
+#include "miscemu.h"
+#include "winsock.h"
 #include "options.h"
+#include "dos_fs.h"
+#include "desktop.h"
 #include "prototypes.h"
 #include "texts.h"
 #define DEBUG_DEFINE_VARIABLES
 #include "stddebug.h"
 #include "debug.h"
 
+extern ButtonTexts ButtonText;
+
+static char people[] = "People who have generously donated time to the Wine " \
+"project include Bob Amstadt, Martin Ayotte, Erik Bos, John Brezak, "\
+"Andrew Bulhak, John Burton, Peter Galbavy, Jeffery Hsu, Miguel de Icaza, " \
+"Alexandre Julliard, Scott A. Laird, Peter MacDonald, David Metcalfe, " \
+"John Richardson, Johannes Ruscheinski, Yngvi Sigurjonsson, Linus Torvalds, " \
+"Carl Williams, Karl Guenter Wuensch, and Eric Youngdale. ";
+
 #define WINE_CLASS    "Wine"    /* Class name for resources */
 
 typedef struct tagENVENTRY {
@@ -44,8 +58,6 @@
 int screenDepth = 0;  /* Screen depth to use */
 int desktopX = 0, desktopY = 0;  /* Desktop window position (if any) */
 
-extern ButtonTexts ButtonText;
-
 struct options Options =
 {  /* default options */
     NULL,           /* spyFilename */
@@ -71,7 +83,6 @@
     { "-synchronous",   ".synchronous",     XrmoptionNoArg,  (caddr_t)"on" },
     { "-spy",           ".spy",             XrmoptionSepArg, (caddr_t)NULL },
     { "-debug",         ".debug",           XrmoptionNoArg,  (caddr_t)"on" },
-    { "-relaydbg",      ".relaydbg",        XrmoptionNoArg,  (caddr_t)"on" },
     { "-debugmsg",      ".debugmsg",        XrmoptionSepArg, (caddr_t)NULL }
 };
 
@@ -91,7 +102,7 @@
   "    -synchronous    Turn on synchronous display mode\n" \
   "    -backingstore   Turn on backing store\n" \
   "    -spy file       Turn on message spying to the specified file\n" \
-  "    -relaydbg       Display call relay information\n" \
+  "    -relaydbg       Obsolete. Use -debugmsg +relay instead\n" \
   "    -debugmsg name  Turn debugging-messages on or off\n"
 
 
@@ -165,7 +176,6 @@
 static void MAIN_GetButtonText( XrmDatabase db, char *name, ButtonDesc *Button)
 {
     XrmValue value;
-    char Hotkey;
     char *i;
 
     if (MAIN_GetResource( db, name, &value))
@@ -294,8 +304,6 @@
 	Options.synchronous = TRUE;
     if (MAIN_GetResource( db, ".backingstore", &value ))
 	Options.backingstore = TRUE;	
-    if (MAIN_GetResource( db, ".relaydbg", &value ))
-	Options.relay_debug = TRUE;
     if (MAIN_GetResource( db, ".debug", &value ))
 	Options.debug = TRUE;
     if (MAIN_GetResource( db, ".spy", &value))
@@ -346,9 +354,9 @@
     int flags;
     unsigned int width = 640, height = 480;  /* Default size = 640x480 */
     char *name = "Wine desktop";
-    XSizeHints size_hints;
-    XWMHints wm_hints;
-    XClassHint class_hints;
+    XSizeHints *size_hints;
+    XWMHints   *wm_hints;
+    XClassHint *class_hints;
     XSetWindowAttributes win_attr;
     XTextProperty window_name;
 
@@ -372,22 +380,33 @@
 
       /* Set window manager properties */
 
-    size_hints.min_width = size_hints.max_width = width;
-    size_hints.min_height = size_hints.max_height = height;
-    size_hints.flags = PMinSize | PMaxSize;
-    if (flags & (XValue | YValue)) size_hints.flags |= USPosition;
-    if (flags & (WidthValue | HeightValue)) size_hints.flags |= USSize;
-    else size_hints.flags |= PSize;
+    size_hints  = XAllocSizeHints();
+    wm_hints    = XAllocWMHints();
+    class_hints = XAllocClassHint();
+    if (!size_hints || !wm_hints || !class_hints)
+    {
+        fprintf( stderr, "Not enough memory for window manager hints.\n" );
+        exit(1);
+    }
+    size_hints->min_width = size_hints->max_width = width;
+    size_hints->min_height = size_hints->max_height = height;
+    size_hints->flags = PMinSize | PMaxSize;
+    if (flags & (XValue | YValue)) size_hints->flags |= USPosition;
+    if (flags & (WidthValue | HeightValue)) size_hints->flags |= USSize;
+    else size_hints->flags |= PSize;
 
-    wm_hints.flags = InputHint | StateHint;
-    wm_hints.input = True;
-    wm_hints.initial_state = NormalState;
-    class_hints.res_name = argv[0];
-    class_hints.res_class = "Wine";
+    wm_hints->flags = InputHint | StateHint;
+    wm_hints->input = True;
+    wm_hints->initial_state = NormalState;
+    class_hints->res_name = argv[0];
+    class_hints->res_class = "Wine";
 
     XStringListToTextProperty( &name, 1, &window_name );
     XSetWMProperties( display, rootWindow, &window_name, &window_name,
-		      argv, argc, &size_hints, &wm_hints, &class_hints );
+                      argv, argc, size_hints, wm_hints, class_hints );
+    XFree( size_hints );
+    XFree( wm_hints );
+    XFree( class_hints );
 
       /* Map window */
 
diff --git a/misc/message.c b/misc/message.c
index 976c86b..2134464 100644
--- a/misc/message.c
+++ b/misc/message.c
@@ -2,10 +2,9 @@
  * 'Wine' MessageBox function handling
  *
  * Copyright 1993 Martin Ayotte
- */
-
+ *
 static char Copyright[] = "Copyright Martin Ayotte, 1993";
-
+*/
 
 #include <stdlib.h>
 #include <stdio.h>
@@ -18,11 +17,11 @@
 #include <unistd.h>
 #include "prototypes.h"
 #include "heap.h"
+#include "library.h"
 #include "win.h"
 #include "texts.h"
 #include "stddebug.h"
 /* #define DEBUG_MSGBOX */
-/* #undef  DEBUG_MSGBOX */ 
 #include "debug.h"
 
 
@@ -40,7 +39,6 @@
   "&Ignore", 'I'
 };
 
-extern HINSTANCE hSysRes;
 extern HBITMAP hUpArrow;
 
 typedef struct tagMSGBOX {
@@ -80,13 +78,13 @@
 	wndPtr = WIN_FindWndPtr(hWnd);
 	if (wndPtr == NULL) {
 		hInst = hSysRes;
-		dprintf_msgbox(stddeb,"MessageBox(NULL, %08X='%s', %08X='%s', %04X)\n", 
-									str, str, title, title, type);
+		dprintf_msgbox(stddeb,"MessageBox(NULL, str='%s', title='%s', %04X)\n", 
+			str, title, type);
 		}
 	else {
 		hInst = wndPtr->hInstance;
-		dprintf_msgbox(stddeb,"MessageBox(%04X, %08X='%s', %08X='%s', %04X)\n", 
-							hWnd, str, str, title, title, type);
+		dprintf_msgbox(stddeb,"MessageBox(%04X, str='%s', title='%s', %04X)\n", 
+			hWnd, str, title, type);
 		}
     lpmb = (LPMSGBOX) malloc(sizeof(MSGBOX));
 	memset(lpmb, 0, sizeof(MSGBOX));
diff --git a/misc/profile.c b/misc/profile.c
index d4f5af1..d30774f 100644
--- a/misc/profile.c
+++ b/misc/profile.c
@@ -14,23 +14,21 @@
  *         has a NULL KeyValue returning a list of KeyNames, and a NULL
  *         AppName undefined.  I changed GetSetProfile to match.  This makes
  *         PROGMAN.EXE do the right thing.
- */
-
+ *
 static char Copyright [] = "Copyright (C) 1993 Miguel de Icaza";
-
+*/
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
 #include "wine.h"
 #include "windows.h"
+#include "dos_fs.h"
 #include "prototypes.h"
 #include "stddebug.h"
 /* #define DEBUG_PROFILE */
-/* #undef  DEBUG_PROFILE */
 #include "debug.h"
 
-
 #define STRSIZE 255
 #define xmalloc(x) malloc(x)
 #define overflow (next == &CharBuffer [STRSIZE-1])
@@ -53,6 +51,7 @@
     char *FileName;
     TSecHeader *Section;
     struct TProfile *link;
+    int changed;
 } TProfile;
 
 TProfile *Current = 0;
@@ -80,13 +79,13 @@
 		return name;
 
 	if (strchr(name, '\\'))
-		return GetUnixFileName(name);
+		return DOS_GetUnixFileName(name);
 		
 	GetWindowsDirectory(temp, sizeof(temp) );
 	strcat(temp, "\\");
 	strcat(temp, name);
 	
-	return GetUnixFileName(temp);
+	return DOS_GetUnixFileName(temp);
 }
 
 static TSecHeader *load (char *filename)
@@ -223,6 +222,7 @@
 	New->link = Base;
 	New->FileName = strdup (FileName);
 	New->Section = load (FileName);
+	New->changed = FALSE;
 	Base = New;
 	section = New->Section;
 	Current = New;
@@ -253,9 +253,7 @@
 		p += slen;
 	    }
 		*p = '\0';
-#ifdef DEBUG_PROFILE
-		printf("GetSetProfile // normal end of enum !\n");
-#endif
+		dprintf_profile(stddeb,"GetSetProfile // normal end of enum !\n");
 	    return (Size - 2 - left);
 	}
 	for (key = section->Keys; key; key = key->link){
@@ -264,6 +262,7 @@
 	    if (set){
 		free (key->Value);
 		key->Value = strdup (Default ? Default : "");
+		Current->changed=TRUE;
 		return 1;
 	    }
 	    ReturnedString [Size-1] = 0;
@@ -289,6 +288,7 @@
 	new_key (section, KeyName, Default);
 	section->link = Current->Section;
 	Current->Section = section;
+	Current->changed = TRUE;
     } else {
 	ReturnedString [Size-1] = 0;
 	strncpy (ReturnedString, Default, Size-1);
@@ -375,6 +375,8 @@
     if (!p)
 	return;
     dump_profile (p->link);
+    if(!p->changed)
+	return;
     if ((profile = fopen (GetIniFileName(p->FileName), "w")) != NULL){
 	dump_sections (profile, p->Section);
 	fclose (profile);
diff --git a/misc/property.c b/misc/property.c
index 9733ae1..4a93716 100644
--- a/misc/property.c
+++ b/misc/property.c
@@ -1,8 +1,8 @@
 /*
  * 				Windows Properties Functions
- */
+ *
 static char Copyright[] = "Copyright Martin Ayotte, 1994";
-
+*/
 
 #include <stdlib.h>
 #include <stdio.h>
@@ -158,7 +158,8 @@
 		GlobalUnlock(wndPtr->hProp);
     	return FALSE;
 		}
-    dprintf_prop(stddeb, "SetProp // entry allocated %08X\n", lpNewProp);
+	dprintf_prop(stddeb, "SetProp // entry allocated %08X\n", 
+    		(unsigned int) lpNewProp);
 	if (lpProp == NULL) {
 		wndPtr->hProp = hNewProp;
 		lpNewProp->lpPrevProp = NULL;
@@ -199,7 +200,7 @@
 	LPPROPENTRY lpProp;
 	LPSTR		str;
 	int			nRet;
-	printf("EnumProps(%04X, %08X)\n", hWnd, lpEnumFunc);
+	printf("EnumProps(%04X, %08X)\n", hWnd, (unsigned int) lpEnumFunc);
 	wndPtr = WIN_FindWndPtr(hWnd);
     if (wndPtr == NULL) {
     	printf("EnumProps // Bad Window handle !\n");
diff --git a/misc/rect.c b/misc/rect.c
index b5c0fc5..0b5133b 100644
--- a/misc/rect.c
+++ b/misc/rect.c
@@ -2,9 +2,9 @@
  * Rectangle-related functions
  *
  * Copyright 1993 Alexandre Julliard
- */
-
+ *
 static char Copyright[] = "Copyright  Alexandre Julliard, 1993";
+*/
 
 #include "windows.h"
 
diff --git a/misc/shell.c b/misc/shell.c
index 71af863..0c6091e 100644
--- a/misc/shell.c
+++ b/misc/shell.c
@@ -7,19 +7,15 @@
 #include <unistd.h>
 #include "prototypes.h"
 #include "windows.h"
+#include "library.h"
 #include "shell.h"
+#include "../rc/sysres.h"
 #include "stddebug.h"
 /* #define DEBUG_REG */
-/* #undef  DEBUG_REG */
 #include "debug.h"
 
-
 LPKEYSTRUCT	lphRootKey = NULL;
 
-DECLARE_HANDLE(HDROP);
-
-extern HINSTANCE hSysRes;
-
 /*************************************************************************
  *				RegOpenKey		[SHELL.1]
  */
@@ -344,7 +340,7 @@
 	else
 		*AppMisc = 0;
 
-	return DialogBox(hSysRes, "SHELL_ABOUT_MSGBOX", hWnd, (WNDPROC)AboutDlgProc);
+	return DialogBoxIndirectPtr(hSysRes, sysres_DIALOG_SHELL_ABOUT_MSGBOX, hWnd, (WNDPROC)AboutDlgProc);
 }
 
 
diff --git a/misc/sound.c b/misc/sound.c
index 0728953..6d1b321 100644
--- a/misc/sound.c
+++ b/misc/sound.c
@@ -1,5 +1,7 @@
+/*
 static char RCSId[] = "$Id: heap.c,v 1.3 1993/07/04 04:04:21 root Exp root $";
 static char Copyright[] = "Copyright  Robert J. Amstadt, 1993";
+*/
 
 #include <stdlib.h>
 #include <stdio.h>
@@ -68,7 +70,7 @@
 	fprintf(stderr, "WaitSoundState(%d)\n", x);
 }
 
-SyncAllVoices(void)
+int SyncAllVoices(void)
 {
 	fprintf(stderr, "SyncAllVoices()\n");
 }
@@ -83,7 +85,7 @@
 	fprintf(stderr, "GetThresholdEvent()\n");
 }
 
-GetThresholdStatus(void)
+int GetThresholdStatus(void)
 {
 	fprintf(stderr, "GetThresholdStatus()\n");
 }
diff --git a/misc/user.c b/misc/user.c
index 609e5ec..b32b57c 100644
--- a/misc/user.c
+++ b/misc/user.c
@@ -1,30 +1,31 @@
+/*
 static char RCSId[] = "$Id: user.c,v 1.2 1993/07/04 04:04:21 root Exp root $";
 static char Copyright[] = "Copyright  Robert J. Amstadt, 1993";
-
+*/
 #include <stdio.h>
 #include <stdlib.h>
-#include "prototypes.h"
+#include "atom.h"
+#include "gdi.h"
+#include "dlls.h"
+#include "selectors.h"
+#include "sysmetrics.h"
+#include "menu.h"
+#include "dialog.h"
+#include "syscolor.h"
+#include "win.h"
 #include "windows.h"
+#include "prototypes.h"
 #include "user.h"
 #include "message.h"
 
 #define USER_HEAP_SIZE          0x10000
-
-
 MDESC *USER_Heap = NULL;
 
-
-extern BOOL ATOM_Init();
-extern BOOL GDI_Init();
-extern void SYSMETRICS_Init();
-extern BOOL MENU_Init();
-extern BOOL WIN_CreateDesktopWindow();
-
 #ifndef WINELIB
 /***********************************************************************
  *           USER_HeapInit
  */
-static BOOL USER_HeapInit()
+static BOOL USER_HeapInit(void)
 {
     struct segment_descriptor_s * s;
     s = GetNextSegment( 0, 0x10000 );
diff --git a/misc/winsocket.c b/misc/winsocket.c
index f9e2b1d..6aea8a7 100644
--- a/misc/winsocket.c
+++ b/misc/winsocket.c
@@ -10,6 +10,8 @@
 #include <signal.h>
 #include <sys/types.h>
 #include <sys/ipc.h>
+#include <sys/ioctl.h>
+#include <sys/msg.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
@@ -20,11 +22,8 @@
 #include "heap.h"
 #include "winsock.h"
 #include "stddebug.h"
-/* #define DEBUG_WINSOCK */
-/* #undef  DEBUG_WINSOCK */
 #include "debug.h"
 
-
 static WORD wsa_errno;
 static int wsa_initted;
 static key_t wine_key = 0;
@@ -39,25 +38,48 @@
 	LONG	lParam;
 };
 #define IPC_PACKET_SIZE (sizeof(struct ipc_packet) - sizeof(long))
-
 #define MTYPE 0xb0b0eb05
+#define WINE_PACKED __attribute__ ((packed))
+
+struct WIN_hostent  {
+	char	*h_name WINE_PACKED;		/* official name of host */
+	char	**h_aliases WINE_PACKED;	/* alias list */
+	int	h_addrtype WINE_PACKED;		/* host address type */
+	int	h_length WINE_PACKED;		/* length of address */
+	char	**h_addr_list WINE_PACKED;	/* list of addresses from name server */
+	char	*names[2];
+	char    hostname[200];
+};
+
+struct	WIN_protoent {
+	char	*p_name WINE_PACKED;		/* official protocol name */
+	char	**p_aliases WINE_PACKED;	/* alias list */
+	int	p_proto WINE_PACKED;		/* protocol # */
+};
+
+struct	WIN_servent {
+	char	*s_name WINE_PACKED;		/* official service name */
+	char	**s_aliases WINE_PACKED;	/* alias list */
+	int	s_port WINE_PACKED;		/* port # */
+	char	*s_proto WINE_PACKED;		/* protocol to use */
+};
 
 struct WinSockHeap {
 	char	ntoa_buffer[32];
 
-	struct	hostent hostent_addr;
-	struct	hostent hostent_name;
-	struct	protoent protoent_name;
-	struct	protoent protoent_number;
-	struct	servent servent_name;
-	struct	servent servent_port;
+	struct	WIN_hostent hostent_addr;
+	struct	WIN_hostent hostent_name;
+	struct	WIN_protoent protoent_name;
+	struct	WIN_protoent protoent_number;
+	struct	WIN_servent servent_name;
+	struct	WIN_servent servent_port;
 
-	struct	hostent WSAhostent_addr;
-	struct	hostent WSAhostent_name;
-	struct	protoent WSAprotoent_name;
-	struct	protoent WSAprotoent_number;	
-	struct	servent WSAservent_name;
-	struct	servent WSAservent_port;
+	struct	WIN_hostent WSAhostent_addr;
+	struct	WIN_hostent WSAhostent_name;
+	struct	WIN_protoent WSAprotoent_name;
+	struct	WIN_protoent WSAprotoent_number;	
+	struct	WIN_servent WSAservent_name;
+	struct	WIN_servent WSAservent_port;
 };
 static struct WinSockHeap *heap;
 
@@ -123,7 +145,9 @@
 	case EHOSTDOWN:		return WSAEHOSTDOWN;
 	case EHOSTUNREACH:	return WSAEHOSTUNREACH;
 	case ENOTEMPTY:		return WSAENOTEMPTY;
-/*	case EPROCLIM:		return WSAEPROCLIM; */
+#ifdef EPROCLIM
+	case EPROCLIM:		return WSAEPROCLIM;
+#endif
 	case EUSERS:		return WSAEUSERS;
 	case EDQUOT:		return WSAEDQUOT;
 	case ESTALE:		return WSAESTALE;
@@ -135,7 +159,7 @@
 	}
 }
 
-static WORD errno_to_wsaerrno(void)
+static void errno_to_wsaerrno(void)
 {
 	wsa_errno = wsaerrno();
 }
@@ -170,8 +194,8 @@
 					break;
 			case 0x1008:	*optname = SO_TYPE;
 					break;
-				default: 
-					fprintf(stderr, "convert_sockopt() unknown optname %d\n", optname);
+			default: 
+					fprintf(stderr, "convert_sockopt() unknown optname %d\n", *optname);
 					break;
 			}
 			break;
@@ -179,11 +203,32 @@
 	}
 }
 
-SOCKET Winsock_accept(SOCKET s, struct sockaddr *addr, INT *addrlen)
+#ifndef WINELIB
+static void CONVERT_HOSTENT(struct WIN_hostent *heap, struct hostent *host)
+{
+
+}
+
+static void CONVERT_PROTOENT(struct WIN_protoent *heap, struct protoent *proto)
+{
+
+}
+
+static void CONVERT_SERVENT(struct WIN_servent *heap, struct servent *serv)
+{
+
+}
+#else
+#define CONVERT_HOSTENT(a,b)	memcpy(&a, &b, sizeof(a))
+#define CONVERT_PROTOENT(a,b)	memcpy(&a, &b, sizeof(a))
+#define CONVERT_SERVENT(a,b)	memcpy(&a, &b, sizeof(a))
+#endif
+
+SOCKET WINSOCK_accept(SOCKET s, struct sockaddr *addr, INT *addrlen)
 {
 	int sock;
 
-	dprintf_winsock(stddeb, "WSA_accept: socket %d, ptr %8x, length %d\n", s, (int) addr, addrlen);
+	dprintf_winsock(stddeb, "WSA_accept: socket %d, ptr %8x, length %d\n", s, (int) addr, *addrlen);
 
 	if ((sock = accept(s, addr, (int *) addrlen)) < 0) {
         	errno_to_wsaerrno();
@@ -192,7 +237,7 @@
 	return sock;
 }
 
-INT Winsock_bind(SOCKET s, struct sockaddr *name, INT namelen)
+INT WINSOCK_bind(SOCKET s, struct sockaddr *name, INT namelen)
 {
 	dprintf_winsock(stddeb, "WSA_bind: socket %d, ptr %8x, length %d\n", s, (int) name, namelen);
 	dump_sockaddr(name);
@@ -204,7 +249,7 @@
 	return 0;
 }
 
-INT Winsock_closesocket(SOCKET s)
+INT WINSOCK_closesocket(SOCKET s)
 {
 	dprintf_winsock(stddeb, "WSA_closesocket: socket %d\n", s);
 
@@ -217,7 +262,7 @@
 	return 0;
 }
 
-INT Winsock_connect(SOCKET s, struct sockaddr *name, INT namelen)
+INT WINSOCK_connect(SOCKET s, struct sockaddr *name, INT namelen)
 {
 	dprintf_winsock(stddeb, "WSA_connect: socket %d, ptr %8x, length %d\n", s, (int) name, namelen);
 	dump_sockaddr(name);
@@ -229,7 +274,7 @@
 	return 0;
 }
 
-INT Winsock_getpeername(SOCKET s, struct sockaddr *name, INT *namelen)
+INT WINSOCK_getpeername(SOCKET s, struct sockaddr *name, INT *namelen)
 {
 	dprintf_winsock(stddeb, "WSA_getpeername: socket: %d, ptr %8x, ptr %8x\n", s, (int) name, *namelen);
 	dump_sockaddr(name);
@@ -241,7 +286,7 @@
 	return 0;
 }
 
-INT Winsock_getsockname(SOCKET s, struct sockaddr *name, INT *namelen)
+INT WINSOCK_getsockname(SOCKET s, struct sockaddr *name, INT *namelen)
 {
 	dprintf_winsock(stddeb, "WSA_getsockname: socket: %d, ptr %8x, ptr %8x\n", s, (int) name, (int) *namelen);
 	if (getsockname(s, name, (int *) namelen) < 0) {
@@ -252,7 +297,7 @@
 }
 
 INT
-Winsock_getsockopt(SOCKET s, INT level, INT optname, char *optval, INT *optlen)
+WINSOCK_getsockopt(SOCKET s, INT level, INT optname, char *optval, INT *optlen)
 {
 	dprintf_winsock(stddeb, "WSA_getsockopt: socket: %d, opt %d, ptr %8x, ptr %8x\n", s, level, (int) optval, (int) *optlen);
 	convert_sockopt(&level, &optname);
@@ -264,26 +309,26 @@
 	return 0;
 }
 
-u_long Winsock_htonl(u_long hostlong)
+u_long WINSOCK_htonl(u_long hostlong)
 {
 	return( htonl(hostlong) );
 }         
 
-u_short Winsock_htons(u_short hostshort)
+u_short WINSOCK_htons(u_short hostshort)
 {
 	return( htons(hostshort) );
 }
 
-u_long Winsock_inet_addr(char *cp)
+u_long WINSOCK_inet_addr(char *cp)
 {
 	return( inet_addr(cp) );
 }
 
-char *Winsock_inet_ntoa(struct in_addr in)
+char *WINSOCK_inet_ntoa(struct in_addr in)
 {
 	char *s;
 
-	dprintf_winsock(stddeb, "WSA_inet_ntoa: %8x\n", in);
+/*	dprintf_winsock(stddeb, "WSA_inet_ntoa: %8lx\n", (int) in);*/
 
 	if ((s = inet_ntoa(in)) == NULL) {
         	errno_to_wsaerrno();
@@ -295,9 +340,9 @@
 	return (char *) &heap->ntoa_buffer;
 }
 
-INT Winsock_ioctlsocket(SOCKET s, long cmd, u_long *argp)
+INT WINSOCK_ioctlsocket(SOCKET s, long cmd, u_long *argp)
 {
-	dprintf_winsock(stddeb, "WSA_ioctl: socket %d, cmd %d, ptr %8x\n", s, cmd, (int) argp);
+	dprintf_winsock(stddeb, "WSA_ioctl: socket %d, cmd %ld, ptr %8x\n", s, cmd, (int) argp);
 
 	if (ioctl(s, cmd, argp) < 0) {
         	errno_to_wsaerrno();
@@ -306,7 +351,7 @@
 	return 0;
 }
 
-INT Winsock_listen(SOCKET s, INT backlog)
+INT WINSOCK_listen(SOCKET s, INT backlog)
 {
 	dprintf_winsock(stddeb, "WSA_listen: socket %d, backlog %d\n", s, backlog);
 
@@ -317,17 +362,17 @@
 	return 0;
 }
 
-u_long Winsock_ntohl(u_long netlong)
+u_long WINSOCK_ntohl(u_long netlong)
 {
 	return( ntohl(netlong) );
 }
 
-u_short Winsock_ntohs(u_short netshort)
+u_short WINSOCK_ntohs(u_short netshort)
 {
 	return( ntohs(netshort) );
 }
 
-INT Winsock_recv(SOCKET s, char *buf, INT len, INT flags)
+INT WINSOCK_recv(SOCKET s, char *buf, INT len, INT flags)
 {
 	int length;
 
@@ -340,12 +385,12 @@
 	return length;
 }
 
-INT Winsock_recvfrom(SOCKET s, char *buf, INT len, INT flags, 
+INT WINSOCK_recvfrom(SOCKET s, char *buf, INT len, INT flags, 
 		struct sockaddr *from, int *fromlen)
 {
 	int length;
 
-	dprintf_winsock(stddeb, "WSA_recvfrom: socket %d, ptr %8x, length %d, flags %d\n", s, buf, len, flags);
+	dprintf_winsock(stddeb, "WSA_recvfrom: socket %d, ptr %8lx, length %d, flags %d\n", s, (unsigned long)buf, len, flags);
 
 	if ((length = recvfrom(s, buf, len, flags, from, fromlen)) < 0) {
         	errno_to_wsaerrno();
@@ -354,19 +399,19 @@
 	return length;
 }
 
-INT Winsock_select(INT nfds, fd_set *readfds, fd_set *writefds,
+INT WINSOCK_select(INT nfds, fd_set *readfds, fd_set *writefds,
 	fd_set *exceptfds, struct timeval *timeout)
 {
-	dprintf_winsock(stddeb, "WSA_select: fd # %d, ptr %8x, ptr %8x, ptr %*X\n", nfds, readfds, writefds, exceptfds);
+	dprintf_winsock(stddeb, "WSA_select: fd # %d, ptr %8lx, ptr %8lx, ptr %8lX\n", nfds, (unsigned long) readfds, (unsigned long) writefds, (unsigned long) exceptfds);
 
 	return(select(nfds, readfds, writefds, exceptfds, timeout));
 }
 
-INT Winsock_send(SOCKET s, char *buf, INT len, INT flags)
+INT WINSOCK_send(SOCKET s, char *buf, INT len, INT flags)
 {
 	int length;
 
-	dprintf_winsock(stddeb, "WSA_send: socket %d, ptr %8x, length %d, flags %d\n", s, buf, len, flags);
+	dprintf_winsock(stddeb, "WSA_send: socket %d, ptr %8lx, length %d, flags %d\n", s, (unsigned long) buf, len, flags);
 
 	if ((length = send(s, buf, len, flags)) < 0) {
         	errno_to_wsaerrno();
@@ -375,12 +420,12 @@
 	return length;
 }
 
-INT Winsock_sendto(SOCKET s, char *buf, INT len, INT flags,
+INT WINSOCK_sendto(SOCKET s, char *buf, INT len, INT flags,
 		struct sockaddr *to, INT tolen)
 {
 	int length;
 
-	dprintf_winsock(stddeb, "WSA_sendto: socket %d, ptr %8x, length %d, flags %d\n", s, buf, len, flags);
+	dprintf_winsock(stddeb, "WSA_sendto: socket %d, ptr %8lx, length %d, flags %d\n", s, (unsigned long) buf, len, flags);
 
 	if ((length = sendto(s, buf, len, flags, to, tolen)) < 0) {
         	errno_to_wsaerrno();
@@ -389,7 +434,7 @@
 	return length;
 }
 
-INT Winsock_setsockopt(SOCKET s, INT level, INT optname, const char *optval, 
+INT WINSOCK_setsockopt(SOCKET s, INT level, INT optname, const char *optval, 
 			INT optlen)
 {
 	dprintf_winsock(stddeb, "WSA_setsockopt: socket %d, level %d, opt %d, ptr %8x, len %d\n", s, level, optname, (int) optval, optlen);
@@ -402,7 +447,7 @@
 	return 0;
 }                                         
 
-INT Winsock_shutdown(SOCKET s, INT how)
+INT WINSOCK_shutdown(SOCKET s, INT how)
 {
 	dprintf_winsock(stddeb, "WSA_shutdown: socket s %d, how %d\n", s, how);
 
@@ -413,7 +458,7 @@
 	return 0;
 }
 
-SOCKET Winsock_socket(INT af, INT type, INT protocol)
+SOCKET WINSOCK_socket(INT af, INT type, INT protocol)
 {
     int sock;
 
@@ -421,7 +466,7 @@
 
     if ((sock = socket(af, type, protocol)) < 0) {
             errno_to_wsaerrno();
-    dprintf_winsock(stddeb, "WSA_socket: failed !\n");
+            dprintf_winsock(stddeb, "WSA_socket: failed !\n");
             return INVALID_SOCKET;
     }
     
@@ -436,7 +481,7 @@
     return sock;
 }
 
-struct hostent *Winsock_gethostbyaddr(const char *addr, INT len, INT type)
+struct WIN_hostent *WINSOCK_gethostbyaddr(const char *addr, INT len, INT type)
 {
 	struct hostent *host;
 
@@ -446,30 +491,29 @@
         	errno_to_wsaerrno();
         	return NULL;
 	}
-	memcpy(&heap->hostent_addr, host, sizeof(struct hostent));
+	CONVERT_HOSTENT(&heap->hostent_addr, host);
 
-	return (struct hostent *) &heap->hostent_addr;
+	return &heap->hostent_addr;
 }
 
-struct hostent *Winsock_gethostbyname(const char *name)
+struct WIN_hostent *WINSOCK_gethostbyname(const char *name)
 {
 	struct hostent *host;
 
-	dprintf_winsock(stddeb, "WSA_gethostbyname: name %s\n", name);
+	dprintf_winsock(stddeb, "WSA_gethostbyname: %s\n", name);
 
 	if ((host = gethostbyname(name)) == NULL) {
         	errno_to_wsaerrno();
         	return NULL;
 	}
-	memcpy(&heap->hostent_name, host, sizeof(struct hostent));
+	CONVERT_HOSTENT(&heap->hostent_name, host);
 
-	return (struct hostent *) &heap->hostent_name;
+	return &heap->hostent_name;
 }
 
-int Winsock_gethostname(char *name, INT namelen)
+INT WINSOCK_gethostname(char *name, INT namelen)
 {
-
-	dprintf_winsock(stddeb, "WSA_gethostname: name %d, len %d\n", name, namelen);
+	dprintf_winsock(stddeb, "WSA_gethostname: name %s, len %d\n", name, namelen);
 
 	if (gethostname(name, namelen) < 0) {
         	errno_to_wsaerrno();
@@ -478,7 +522,7 @@
 	return 0;
 }          
 
-struct protoent *Winsock_getprotobyname(char *name)
+struct WIN_protoent *WINSOCK_getprotobyname(char *name)
 {
 	struct protoent *proto;
 
@@ -488,12 +532,12 @@
         	errno_to_wsaerrno();
         	return NULL;
 	}
-	memcpy(&heap->protoent_name, proto, sizeof(struct protoent));
+	CONVERT_PROTOENT(&heap->protoent_name, proto);
 
-	return (struct protoent *) &heap->protoent_name;
+	return &heap->protoent_name;
 }
 
-struct protoent *Winsock_getprotobynumber(INT number)
+struct WIN_protoent *WINSOCK_getprotobynumber(INT number)
 {
 	struct protoent *proto;
 
@@ -503,27 +547,30 @@
         	errno_to_wsaerrno();
         	return NULL;
 	}
-	memcpy(&heap->protoent_number, proto, sizeof(struct protoent));
+	CONVERT_PROTOENT(&heap->protoent_number, proto);
 
-	return (struct protoent *) &heap->protoent_number;
+	return &heap->protoent_number;
 }
 
-struct servent *Winsock_getservbyname(const char *name, const char *proto)
+struct WIN_servent *WINSOCK_getservbyname(const char *name, const char *proto)
 {
 	struct servent *service;
 
+	if (proto == NULL)
+		proto = "tcp";
+
 	dprintf_winsock(stddeb, "WSA_getservbyname: name %s, proto %s\n", name, proto);
 
 	if ((service = getservbyname(name, proto)) == NULL) {
         	errno_to_wsaerrno();
         	return NULL;
 	}
-	memcpy(&heap->servent_name, service, sizeof(struct servent));
+	CONVERT_SERVENT(&heap->servent_name, service);
 
-	return (struct servent *) &heap->servent_name;
+	return &heap->servent_name;
 }
 
-struct servent *Winsock_getservbyport(INT port, const char *proto)
+struct WIN_servent *WINSOCK_getservbyport(INT port, const char *proto)
 {
 	struct servent *service;
 
@@ -533,9 +580,9 @@
         	errno_to_wsaerrno();
         	return NULL;
 	}
-	memcpy(&heap->servent_port, service, sizeof(struct servent));
+	CONVERT_SERVENT(&heap->servent_port, service);
 
-	return (struct servent *) &heap->servent_port;
+	return &heap->servent_port;
 }
 
 /******************** winsock specific functions ************************
@@ -543,7 +590,7 @@
  */
 static HANDLE new_handle = 0;
 
-HANDLE AllocWSAHandle(void)
+static HANDLE AllocWSAHandle(void)
 {
 	return new_handle++;
 }
@@ -556,7 +603,7 @@
 		perror("wine: msgrcv");
 
 	fprintf(stderr, 
-		"WSA: PostMessage (hwnd %d, wMsg %d, wParam %d, lParam %d)\n",
+		"WSA: PostMessage (hwnd %d, wMsg %d, wParam %d, lParam %ld)\n",
 		message.hWnd,
 		message.wMsg,
 		message.handle,
@@ -579,7 +626,7 @@
 	message.lParam = lParam;
 
 	fprintf(stderr, 
-		"WSA: send (hwnd %d, wMsg %d, handle %d, lParam %d)\n",
+		"WSA: send (hwnd %d, wMsg %d, handle %d, lParam %ld)\n",
 		hWnd, wMsg, handle, lParam);
 	
 	if (msgsnd(wine_key, &message,  IPC_PACKET_SIZE, IPC_NOWAIT) == -1)
@@ -725,7 +772,7 @@
 	long event;
 	fd_set read_fds, write_fds, except_fds;
 
-	dprintf_winsock(stddeb, "WSA_AsyncSelect: socket %d, HWND %d, wMsg %d, event %d\n", s, hWnd, wMsg, lEvent);
+	dprintf_winsock(stddeb, "WSA_AsyncSelect: socket %d, HWND %d, wMsg %d, event %ld\n", s, hWnd, wMsg, lEvent);
 
 	/* remove outstanding asyncselect() processes */
 	/* kill */
@@ -795,14 +842,16 @@
 BOOL WSAIsBlocking(void)
 {
 	dprintf_winsock(stddeb, "WSA_IsBlocking\n");
+
+	return 0;
 }
 
 FARPROC WSASetBlockingHook(FARPROC lpBlockFunc)
 {
-	dprintf_winsock(stddeb, "WSA_SetBlockHook %8x, STUB!\n", lpBlockFunc);
+	dprintf_winsock(stddeb, "WSA_SetBlockHook %8lx, STUB!\n", (unsigned long) lpBlockFunc);
 	BlockFunction = lpBlockFunc;
 
-	return lpBlockFunc;
+	return (FARPROC) lpBlockFunc;
 }
 
 INT WSAUnhookBlockingHook(void)
@@ -813,7 +862,7 @@
 	return 0;
 }
 
-WSADATA Winsock_data = {
+WSADATA WINSOCK_data = {
         0x0101,
         0x0101,
         "WINE Sockets",
@@ -855,7 +904,7 @@
 #ifndef WINELIB
     HEAP_Init(&MyHeap, heap, sizeof(struct WinSockHeap));
 #endif
-    bcopy(&Winsock_data, lpWSAData, sizeof(Winsock_data));
+    bcopy(&WINSOCK_data, lpWSAData, sizeof(WINSOCK_data));
 
     /* ipc stuff */
 
diff --git a/miscemu/emulate.c b/miscemu/emulate.c
index bf2c868..c014887 100644
--- a/miscemu/emulate.c
+++ b/miscemu/emulate.c
@@ -4,7 +4,6 @@
 #include "regfunc.h"
 #include "stddebug.h"
 /* #define DEBUG_INT */
-/* #undef  DEBUG_INT */
 #include "debug.h"
 
 struct Win87EmInfoStruct {
@@ -19,7 +18,7 @@
 int
 WIN87_fpmath()
 {
-  dprintf_int(stddeb, "_fpmath: (%x:%x %x %x)\n",_CONTEXT->sc_cs, 
+  dprintf_int(stddeb, "_fpmath: (%x:%lx %lx %x)\n",_CONTEXT->sc_cs, 
 	 _CONTEXT->sc_eip, _CONTEXT->sc_es, _BX & 0xffff);
 
   switch(_BX & 0xffff)
diff --git a/miscemu/int10.c b/miscemu/int10.c
index 123ddbb..8bd9545 100644
--- a/miscemu/int10.c
+++ b/miscemu/int10.c
@@ -2,9 +2,9 @@
 #include <stdlib.h>
 #include "registers.h"
 #include "wine.h"
+#include "miscemu.h"
 #include "stddebug.h"
 /* #define DEBUG_INT */
-/* #undef  DEBUG_INT */
 #include "debug.h"
 
 void IntBarf(int i, struct sigcontext_struct *context)
diff --git a/miscemu/int13.c b/miscemu/int13.c
index 1c08233..294f48d 100644
--- a/miscemu/int13.c
+++ b/miscemu/int13.c
@@ -2,13 +2,11 @@
 #include <stdlib.h>
 #include "registers.h"
 #include "wine.h"
+#include "miscemu.h"
 #include "stddebug.h"
 /* #define DEBUG_INT */
-/* #undef  DEBUG_INT */
 #include "debug.h"
 
-void IntBarf(int i, struct sigcontext_struct *context);
-
 int do_int13(struct sigcontext_struct *context)
 {
 	switch(AH) {
diff --git a/miscemu/int15.c b/miscemu/int15.c
index 3858e8f..9efc47c 100644
--- a/miscemu/int15.c
+++ b/miscemu/int15.c
@@ -2,13 +2,11 @@
 #include <stdlib.h>
 #include "registers.h"
 #include "wine.h"
+#include "miscemu.h"
 #include "stddebug.h"
 /* #define DEBUG_INT */
-/* #undef  DEBUG_INT */
 #include "debug.h"
 
-void IntBarf(int i, struct sigcontext_struct *context);
-
 int do_int15(struct sigcontext_struct *context)
 {
 	switch(AH) {
diff --git a/miscemu/int16.c b/miscemu/int16.c
index c1294f8..b3cc06e 100644
--- a/miscemu/int16.c
+++ b/miscemu/int16.c
@@ -2,13 +2,11 @@
 #include <stdlib.h>
 #include "registers.h"
 #include "wine.h"
+#include "miscemu.h"
 #include "stddebug.h"
 /* #define DEBUG_INT */
-/* #undef  DEBUG_INT */
 #include "debug.h"
 
-void IntBarf(int i, struct sigcontext_struct *context);
-
 int do_int16(struct sigcontext_struct *context)
 {
 	switch(AH) {
diff --git a/miscemu/int1a.c b/miscemu/int1a.c
index 0e0a9fa..a8739f0 100644
--- a/miscemu/int1a.c
+++ b/miscemu/int1a.c
@@ -4,9 +4,9 @@
 #include "registers.h"
 #include "wine.h"
 #include "options.h"
+#include "miscemu.h"
 #include "stddebug.h"
 /* #define DEBUG_INT */
-/* #undef  DEBUG_INT */
 #include "debug.h"
 
 #ifdef linux
@@ -18,14 +18,11 @@
 #define	BCD_TO_BIN(x) ((x&15) + (x>>4)*10)
 #define BIN_TO_BCD(x) ((x%10) + ((x/10)<<4))
 
-void IntBarf(int i, struct sigcontext_struct *context);
-
-int do_int1A(struct sigcontext_struct * context){
-	time_t ltime;
+int do_int1a(struct sigcontext_struct * context){
+	time_t ltime, ticks;
 	struct tm *bdtime;
-	int ticks;
 
-    if (Options.relay_debug) {
+    if (debugging_relay) {
 	fprintf(stddeb,"int1A: AX %04x, BX %04x, CX %04x, DX %04x, "
 	       "SI %04x, DI %04x, DS %04x, ES %04x\n",
 	       AX, BX, CX, DX, SI, DI, DS, ES);
diff --git a/miscemu/int21.c b/miscemu/int21.c
index 5756d8a..5ab5c11 100644
--- a/miscemu/int21.c
+++ b/miscemu/int21.c
@@ -15,16 +15,17 @@
 #include <unistd.h>
 #include <utime.h>
 #include <ctype.h>
-#include "prototypes.h"
+#include "dos_fs.h"
 #include "regfunc.h"
 #include "windows.h"
-#include "wine.h"
+#include "heap.h"
 #include "msdos.h"
 #include "registers.h"
 #include "options.h"
+#include "prototypes.h"
+#include "miscemu.h"
 #include "stddebug.h"
 /* #define DEBUG_INT */
-/* #undef  DEBUG_INT */
 #include "debug.h"
 
 WORD ExtendedError, CodePage = 437;
@@ -42,7 +43,6 @@
 WORD sharing_pause = 1;        /* pause between retries */
 
 extern char TempDirectory[];
-void IntBarf(int i, struct sigcontext_struct *context);
 
 static int Error(int e, int class, int el)
 {
@@ -180,7 +180,6 @@
 
 static void GetDriveAllocInfo(struct sigcontext_struct *context)
 {
-	int drive;
 	long size, available;
 	BYTE mediaID;
 	
@@ -436,7 +435,7 @@
 {
 	int handle;
 
-	if ((handle = open(GetUnixFileName( SAFEMAKEPTR(DS,DX)), 
+	if ((handle = open(DOS_GetUnixFileName( SAFEMAKEPTR(DS,DX)), 
            O_CREAT | O_TRUNC | O_RDWR )) == -1) {
 		errno_to_doserr();
 		AL = ExtendedError;
@@ -469,7 +468,7 @@
 	    break;
 	}
 
-	if ((handle = open(GetUnixFileName(SAFEMAKEPTR(DS,DX)), mode)) == -1) {
+	if ((handle = open(DOS_GetUnixFileName(SAFEMAKEPTR(DS,DX)), mode)) == -1) {
 		errno_to_doserr();
 		AL = ExtendedError;
 		SetCflag;
@@ -552,8 +551,8 @@
 	dprintf_int(stddeb,"int21: renaming %s to %s\n",
 			SAFEMAKEPTR(DS,DX), SAFEMAKEPTR(ES,DI) );
 	
-	oldname = GetUnixFileName( SAFEMAKEPTR(DS,DX) );
-	newname = GetUnixFileName( SAFEMAKEPTR(ES,DI) );
+	oldname = DOS_GetUnixFileName( SAFEMAKEPTR(DS,DX) );
+	newname = DOS_GetUnixFileName( SAFEMAKEPTR(ES,DI) );
 
 	rename( oldname, newname);
 	ResetCflag;
@@ -566,7 +565,7 @@
 
 	dprintf_int(stddeb,"int21: makedir %s\n", SAFEMAKEPTR(DS,DX) );
 	
-	if ((dirname = GetUnixFileName( SAFEMAKEPTR(DS,DX) ))== NULL) {
+	if ((dirname = DOS_GetUnixFileName( SAFEMAKEPTR(DS,DX) ))== NULL) {
 		AL = CanNotMakeDir;
 		SetCflag;
 		return;
@@ -603,7 +602,7 @@
 
 	dprintf_int(stddeb,"int21: removedir %s\n", SAFEMAKEPTR(DS,DX) );
 
-	if ((dirname = GetUnixFileName( SAFEMAKEPTR(DS,DX) ))== NULL) {
+	if ((dirname = DOS_GetUnixFileName( SAFEMAKEPTR(DS,DX) ))== NULL) {
 		AL = CanNotMakeDir;
 		SetCflag;
 		return;
@@ -624,7 +623,7 @@
 
 static void ExecProgram(struct sigcontext_struct *context)
 {
-	execl("wine", GetUnixFileName( SAFEMAKEPTR(DS,DX)) );
+	execl("wine", DOS_GetUnixFileName( SAFEMAKEPTR(DS,DX)) );
 }
 
 static void FindNext(struct sigcontext_struct *context)
@@ -704,7 +703,7 @@
 	struct stat filestat;
 	struct tm *now;
 
-	if ((filename = GetUnixFileName( SAFEMAKEPTR(DS,DX) ))== NULL) {
+	if ((filename = DOS_GetUnixFileName( SAFEMAKEPTR(DS,DX) ))== NULL) {
 		AL = FileNotFound;
 		SetCflag;
 		return;
@@ -724,7 +723,7 @@
 	char *filename;
 	struct utimbuf filetime;
 	
-	filename = GetUnixFileName( SAFEMAKEPTR(DS,DX) );
+	filename = DOS_GetUnixFileName( SAFEMAKEPTR(DS,DX) );
 
 	filetime.actime = 0L;
 	filetime.modtime = filetime.actime;
@@ -742,7 +741,7 @@
 
 	dprintf_int(stddeb,"CreateTempFile %s\n",temp);
 
-	handle = open(GetUnixFileName(temp), O_CREAT | O_TRUNC | O_RDWR);
+	handle = open(DOS_GetUnixFileName(temp), O_CREAT | O_TRUNC | O_RDWR);
 
 	if (handle == -1) {
 		AL = WriteProtected;
@@ -760,7 +759,7 @@
 {
 	int handle;
 	
-	if ((handle = open(GetUnixFileName( SAFEMAKEPTR(DS,DX) ), O_CREAT | O_EXCL | O_RDWR)) == -1) {
+	if ((handle = open(DOS_GetUnixFileName( SAFEMAKEPTR(DS,DX) ), O_CREAT | O_EXCL | O_RDWR)) == -1) {
 		AL = WriteProtected;
 		SetCflag;
 		return;
@@ -961,7 +960,7 @@
 	{
 		strcpy(ptr, dp->filename);
 		dprintf_int(stddeb, "int21: delete file %s\n", temp);
-		/* unlink(GetUnixFileName(temp)); */
+		/* unlink(DOS_GetUnixFileName(temp)); */
 	}
 	DOS_closedir(dp);
 	AL = 0;
@@ -1073,7 +1072,7 @@
   struct stat s;
   int res,cx; 
 
-  res = stat(GetUnixFileName(filename), &s);
+  res = stat(DOS_GetUnixFileName(filename), &s);
   if (res==-1)
   {
     errno_to_doserr();
@@ -1099,7 +1098,7 @@
 
 int do_int21(struct sigcontext_struct * context)
 {
-    if (Options.relay_debug)
+    if (debugging_relay)
     {
 	fprintf(stddeb,"int21: AX %04x, BX %04x, CX %04x, DX %04x, "
 	       "SI %04x, DI %04x, DS %04x, ES %04x\n",
@@ -1336,7 +1335,7 @@
 	    break;
 	
 	  case 0x41: /* "UNLINK" - DELETE FILE */
-		if (unlink( GetUnixFileName( SAFEMAKEPTR(DS,DX)) ) == -1) {
+		if (unlink( DOS_GetUnixFileName( SAFEMAKEPTR(DS,DX)) ) == -1) {
 			errno_to_doserr();
 			AL = ExtendedError;
 			SetCflag;
@@ -1590,7 +1589,7 @@
 /**********************************************************************
  *			DOS3Call
  */
-void DOS3Call()
+void DOS3Call(void)
 {
     do_int21((struct sigcontext_struct *) _CONTEXT);
     ReturnFromRegisterFunc();
diff --git a/miscemu/int25.c b/miscemu/int25.c
index 67c2ec6..54cdbc6 100644
--- a/miscemu/int25.c
+++ b/miscemu/int25.c
@@ -1,12 +1,13 @@
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include "registers.h"
 #include "msdos.h"
 #include "segmem.h"
 #include "wine.h"
+#include "miscemu.h"
 #include "stddebug.h"
 /* #define DEBUG_INT */
-/* #undef  DEBUG_INT */
 #include "debug.h"
 
 int do_int25(struct sigcontext_struct *context)
@@ -23,8 +24,8 @@
 		begin = DX;
 		length = CX;
 	}
-	dprintf_int(stdnimp, "int25: abs diskread, drive %d, sector %d, "
-	"count %d, buffer %d\n", EAX & 0xff, begin, length, (int) dataptr);
+	dprintf_int(stdnimp, "int25: abs diskread, drive %d, sector %ld, "
+	"count %ld, buffer %d\n", EAX & 0xff, begin, length, (int) dataptr);
 
 	memset(dataptr, 0, length * 512);
 
diff --git a/miscemu/int26.c b/miscemu/int26.c
index 2b262ed..e6a7da8 100644
--- a/miscemu/int26.c
+++ b/miscemu/int26.c
@@ -4,13 +4,11 @@
 #include "msdos.h"
 #include "segmem.h"
 #include "wine.h"
+#include "miscemu.h"
 #include "stddebug.h"
 /* #define DEBUG_INT */
-/* #undef  DEBUG_INT */
 #include "debug.h"
 
-void IntBarf(int i, struct sigcontext_struct *context);
-
 int do_int26(struct sigcontext_struct *context)
 {
 	BYTE *dataptr = SAFEMAKEPTR(DS, BX);
@@ -26,8 +24,8 @@
 		length = CX;
 	}
 		
-	dprintf_int(stdnimp,"int26: abs diskwrite, drive %d, sector %d, count %d,"
-		" buffer %d\n", EAX & 0xff, begin, length, (int) dataptr);
+	dprintf_int(stdnimp,"int26: abs diskwrite, drive %d, sector %ld, "
+	"count %ld, buffer %d\n", EAX & 0xff, begin, length, (int) dataptr);
 
 	ResetCflag;
 
diff --git a/miscemu/int2a.c b/miscemu/int2a.c
index 74ed60f..63ed11d 100644
--- a/miscemu/int2a.c
+++ b/miscemu/int2a.c
@@ -2,13 +2,11 @@
 #include <stdlib.h>
 #include "msdos.h"
 #include "wine.h"
+#include "miscemu.h"
 #include "stddebug.h"
 /* #define DEBUG_INT */
-/* #undef  DEBUG_INT */
 #include "debug.h"
 
-void IntBarf(int i, struct sigcontext_struct *context);
-
 int do_int2a(struct sigcontext_struct *context)
 {
 	switch((context->sc_eax >> 8) & 0xff)
diff --git a/miscemu/int2f.c b/miscemu/int2f.c
index e41fd5b..25d9acd 100644
--- a/miscemu/int2f.c
+++ b/miscemu/int2f.c
@@ -2,12 +2,11 @@
 #include <stdlib.h>
 #include "registers.h"
 #include "wine.h"
+#include "miscemu.h"
 #include "stddebug.h"
 /* #define DEBUG_INT */
-/* #undef  DEBUG_INT */
 #include "debug.h"
 
-void IntBarf(int i, struct sigcontext_struct *context);
 int do_int2f_16(struct sigcontext_struct *context);
 
 int do_int2f(struct sigcontext_struct *context)
diff --git a/miscemu/int31.c b/miscemu/int31.c
index f38b362..7aa7dfd 100644
--- a/miscemu/int31.c
+++ b/miscemu/int31.c
@@ -2,9 +2,9 @@
 #include <stdlib.h>
 #include "registers.h"
 #include "wine.h"
+#include "miscemu.h"
 #include "stddebug.h"
 /* #define DEBUG_INT */
-/* #undef  DEBUG_INT */
 #include "debug.h"
 
 typedef struct {
@@ -48,7 +48,8 @@
 		context->sc_eax = DPMI_FreeSelector(context->sc_ebx);
 		break;
 	case 0x000C:
-		lpDesc = MAKELONG(context->sc_edi, context->sc_es);
+		lpDesc = (LPDESCRIPTOR) MAKELONG(context->sc_edi,
+                                                 context->sc_es);
 		context->sc_eax = DPMI_SetDescriptor(context->sc_ebx, lpDesc);
 		break;
 	default:
diff --git a/miscemu/ioports.c b/miscemu/ioports.c
index d8b09f3..fe86fc1 100644
--- a/miscemu/ioports.c
+++ b/miscemu/ioports.c
@@ -5,7 +5,6 @@
 #include "wine.h"
 #include "stddebug.h"
 /* #define DEBUG_INT */
-/* #undef  DEBUG_INT */
 #include "debug.h"
 
 static BYTE cmosaddress;
@@ -42,6 +41,18 @@
 	AX = 0xffff;
 }
 
+void inportb_abs(struct sigcontext_struct *context)
+{
+	dprintf_int(stdnimp, "IO: in (%x)\n", *(BYTE *)(EIP+1));
+	AL = 0xff;
+}
+
+void inport_abs(struct sigcontext_struct *context)
+{
+	dprintf_int(stdnimp, "IO: in (%x)\n", *(BYTE *)(EIP+1));
+	AX = 0xffff;
+}
+
 void outportb(struct sigcontext_struct *context)
 {
 	dprintf_int(stdnimp, "IO: outb (%x), %x\n", DX, AX);
@@ -62,3 +73,13 @@
 {
 	dprintf_int(stdnimp, "IO: out (%x), %x\n", DX, AX);
 }
+
+void outportb_abs(struct sigcontext_struct *context)
+{
+    dprintf_int(stdnimp, "IO: out (%x), %x\n", *(BYTE *)(EIP+1), AL);
+}
+
+void outport_abs(struct sigcontext_struct *context)
+{
+    dprintf_int(stdnimp, "IO: out (%x), %x\n", *(BYTE *)(EIP+1), AX);
+}
diff --git a/miscemu/kernel.c b/miscemu/kernel.c
index a2a559f..27b08b5 100644
--- a/miscemu/kernel.c
+++ b/miscemu/kernel.c
@@ -1,5 +1,7 @@
+/*
 static char RCSId[] = "$Id: kernel.c,v 1.2 1993/07/04 04:04:21 root Exp root $";
 static char Copyright[] = "Copyright  Robert J. Amstadt, 1993";
+*/
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -20,7 +22,7 @@
     if (segment == -1)
 	segment = *(Stack16Frame + 6);
 
-    if (Options.relay_debug)
+    if (debugging_relay)
 	fprintf(stddeb,"LockSegment: segment %x\n", segment);
 
     return segment;
@@ -35,7 +37,7 @@
     if (segment == -1)
 	segment = *(Stack16Frame + 6);
 
-    if (Options.relay_debug)
+    if (debugging_relay)
     	fprintf(stddeb,"UnlockSegment: segment %x\n", segment);
 
     return segment;
@@ -44,7 +46,7 @@
 /**********************************************************************
  *					KERNEL_InitTask
  */
-KERNEL_InitTask()
+void KERNEL_InitTask(void)
 {
     _BX = 0x81;
     _AX = 1;
@@ -66,7 +68,7 @@
 int
 KERNEL_WaitEvent(int task)
 {
-    if (Options.relay_debug)
+    if (debugging_relay)
     	fprintf(stddeb,"WaitEvent: task %d\n", task);
     return 0;
 }
diff --git a/multimedia/audio.c b/multimedia/audio.c
index 3f7cd4e..e005b86 100644
--- a/multimedia/audio.c
+++ b/multimedia/audio.c
@@ -2,9 +2,9 @@
  * Sample Wine Driver for Linux
  *
  * Copyright 1994 Martin Ayotte
- */
+ *
 static char Copyright[] = "Copyright  Martin Ayotte, 1994";
-
+*/
 #ifndef WINELIB
 #define BUILTIN_MMSYSTEM
 #endif 
@@ -28,8 +28,6 @@
 #endif
 
 #include "stddebug.h"
-/* #define DEBUG_MCIWAVE /* */
-/* #undef  DEBUG_MCIWAVE /* */
 #include "debug.h"
 
 #ifdef linux
@@ -79,7 +77,7 @@
 	} LINUX_MCIWAVE;
 
 static LINUX_WAVEOUT	WOutDev[MAX_WAVOUTDRV];
-static LINUX_WAVEIN		WInDev[MAX_WAVOUTDRV];
+static LINUX_WAVEIN	WInDev[MAX_WAVOUTDRV];
 static LINUX_MCIWAVE	MCIWavDev[MAX_MCIWAVDRV];
 #endif
 
@@ -190,14 +188,12 @@
 DWORD WAVE_mciOpen(DWORD dwFlags, LPMCI_WAVE_OPEN_PARMS lpParms)
 {
 #ifdef linux
-	int			hFile;
 	UINT 		wDevID;
-	OFSTRUCT	OFstruct;
 	LPPCMWAVEFORMAT	lpWaveFormat;
 	WAVEOPENDESC 	WaveDesc;
 	DWORD		dwRet;
 	char		str[128];
-	LPSTR		ptr;
+
 	dprintf_mciwave(stddeb,"WAVE_mciOpen(%08X, %08X)\n", dwFlags, lpParms);
 	if (lpParms == NULL) return MCIERR_INTERNAL;
 	wDevID = lpParms->wDeviceID;
@@ -406,7 +402,8 @@
 	int			count;
 	int			start, end;
 	LPWAVEHDR		lpWaveHdr;
-	DWORD		dwRet;
+	DWORD			dwRet;
+
 	dprintf_mciwave(stddeb,
 		"WAVE_mciRecord(%u, %08X, %08X);\n", wDevID, dwFlags, lpParms);
 	if (MCIWavDev[wDevID].hFile == 0) {
diff --git a/multimedia/mcianim.c b/multimedia/mcianim.c
index 7a191d4..ce2ddc2 100644
--- a/multimedia/mcianim.c
+++ b/multimedia/mcianim.c
@@ -2,9 +2,9 @@
  * Sample MCI ANIMATION Wine Driver for Linux
  *
  * Copyright 1994 Martin Ayotte
- */
+ *
 static char Copyright[] = "Copyright  Martin Ayotte, 1994";
-
+*/
 #ifndef WINELIB
 #define BUILTIN_MMSYSTEM
 #endif 
@@ -22,8 +22,7 @@
 #include "driver.h"
 #include "mmsystem.h"
 #include "stddebug.h"
-/* #define DEBUG_MCIANIM /* */
-/* #undef  DEBUG_MCIANIM /* */
+/* #define DEBUG_MCIANIM */
 #define DEBUG_MCIANIM
 #include "debug.h"
 
diff --git a/multimedia/mcicda.c b/multimedia/mcicda.c
index de2a3d8..6775335 100644
--- a/multimedia/mcicda.c
+++ b/multimedia/mcicda.c
@@ -2,9 +2,9 @@
  * Sample MCI CDAUDIO Wine Driver for Linux
  *
  * Copyright 1994 Martin Ayotte
- */
+ *
 static char Copyright[] = "Copyright  Martin Ayotte, 1994";
-
+*/
 #ifndef WINELIB
 #define BUILTIN_MMSYSTEM
 #endif 
@@ -22,8 +22,7 @@
 #include "driver.h"
 #include "mmsystem.h"
 #include "stddebug.h"
-/* #define DEBUG_CDAUDIO /* */
-/* #undef  DEBUG_CDAUDIO /* */
+/* #define DEBUG_CDAUDIO */
 #include "debug.h"
 
 #ifdef linux
diff --git a/multimedia/midi.c b/multimedia/midi.c
index d334290..df24045 100644
--- a/multimedia/midi.c
+++ b/multimedia/midi.c
@@ -2,16 +2,16 @@
  * Sample MIDI Wine Driver for Linux
  *
  * Copyright 1994 Martin Ayotte
- */
+ *
 static char Copyright[] = "Copyright  Martin Ayotte, 1994";
-
+*/
 #ifndef WINELIB
 #define BUILTIN_MMSYSTEM
 #endif 
 
 #ifdef BUILTIN_MMSYSTEM
 
-#include "stdio.h"
+#include <stdio.h>
 #include "win.h"
 #include "user.h"
 #include "driver.h"
@@ -20,8 +20,7 @@
 #include <sys/ioctl.h>
 
 #include "stddebug.h"
-/* #define DEBUG_MIDI /* */
-/* #undef  DEBUG_MIDI /* */
+/* #define DEBUG_MIDI */
 
 #define DEBUG_MIDI
 #include "debug.h"
diff --git a/multimedia/mmaux.c b/multimedia/mmaux.c
index ef69eed..a3ab0a8 100644
--- a/multimedia/mmaux.c
+++ b/multimedia/mmaux.c
@@ -2,9 +2,9 @@
  * Sample AUXILARY Wine Driver for Linux
  *
  * Copyright 1994 Martin Ayotte
- */
+ *
 static char Copyright[] = "Copyright  Martin Ayotte, 1994";
-
+*/
 #ifndef WINELIB
 #define BUILTIN_MMSYSTEM
 #endif 
diff --git a/multimedia/mmsystem.c b/multimedia/mmsystem.c
index e9322fd..28f67cb 100644
--- a/multimedia/mmsystem.c
+++ b/multimedia/mmsystem.c
@@ -2,9 +2,9 @@
  * MMSYTEM functions
  *
  * Copyright 1993 Martin Ayotte
- */
+ *
 static char Copyright[] = "Copyright  Martin Ayotte, 1993";
-
+*/
 #ifndef WINELIB
 
 #include <stdio.h>
diff --git a/objects/bitblt.c b/objects/bitblt.c
index fa58dad..e945faf 100644
--- a/objects/bitblt.c
+++ b/objects/bitblt.c
@@ -2,30 +2,26 @@
  * GDI bit-blit operations
  *
  * Copyright 1993 Alexandre Julliard
- */
-
+ *
 static char Copyright[] = "Copyright  Alexandre Julliard, 1993";
-
+*/
 #include <stdio.h>
 #include <stdlib.h>
 #include <X11/Xlib.h>
 #include <X11/Intrinsic.h>
-
+#include "windows.h"
+#include "dc.h"
 #include "gdi.h"
+#include "color.h"
 #include "metafile.h"
 #include "options.h"
 #include "stddebug.h"
 /* #define DEBUG_GDI */
-/* #undef  DEBUG_GDI */
 #include "debug.h"
 
-extern const int DC_XROPfunction[];
-extern Colormap COLOR_WinColormap;
-
 #define MIN(a,b) ((a) < (b) ? (a) : (b))
 #define MAX(a,b) ((a) > (b) ? (a) : (b))
 
-
 /***********************************************************************
  *           BITBLT_GetImage
  */
diff --git a/objects/bitmap.c b/objects/bitmap.c
index 14bdd1f..7766826 100644
--- a/objects/bitmap.c
+++ b/objects/bitmap.c
@@ -2,33 +2,30 @@
  * GDI bitmap objects
  *
  * Copyright 1993 Alexandre Julliard
- */
-
+ *
 static char Copyright[] = "Copyright  Alexandre Julliard, 1993";
-
+*/
 #include <stdio.h>
 #include <stdlib.h>
 #include <X11/Xlib.h>
 #include <X11/Xutil.h>
 #include "gdi.h"
+#include "dc.h"
 #include "bitmap.h"
 #include "stddebug.h"
 /* #define DEBUG_GDI    */
-/* #undef  DEBUG_GDI    */
-/* #define DEBUG_BITMAP */
 /* #define DEBUG_BITMAP */
 #include "debug.h"
 
   /* GCs used for B&W and color bitmap operations */
 GC BITMAP_monoGC = 0, BITMAP_colorGC = 0;
 
-extern void DC_InitDC( HDC hdc );                /* objects/dc.c */
 extern void CLIPPING_UpdateGCRegion( DC * dc );  /* objects/clipping.c */
 
 /***********************************************************************
  *           BITMAP_Init
  */
-BOOL BITMAP_Init()
+BOOL BITMAP_Init(void)
 {
     Pixmap tmpPixmap;
     
diff --git a/objects/brush.c b/objects/brush.c
index 4403353..75de5d6 100644
--- a/objects/brush.c
+++ b/objects/brush.c
@@ -2,17 +2,16 @@
  * GDI brush objects
  *
  * Copyright 1993 Alexandre Julliard
- */
-
+ *
 static char Copyright[] = "Copyright  Alexandre Julliard, 1993";
+*/
 
 #include "gdi.h"
 #include "bitmap.h"
 #include "prototypes.h"
 #include "metafile.h"
 #include "stddebug.h"
-/* #define DEBUG_GDI */
-/* #undef  DEBUG_GDI */
+#include "color.h"
 #include "debug.h"
 
 #define NB_HATCH_STYLES  6
@@ -27,8 +26,6 @@
     { 0x81, 0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x81 }  /* HS_DIAGCROSS  */
 };
 
-extern WORD COLOR_ToPhysical( DC *dc, COLORREF color );
-
 
 /***********************************************************************
  *           CreateBrushIndirect    (GDI.50)
@@ -180,7 +177,7 @@
  */
 static void BRUSH_SelectSolidBrush( DC *dc, COLORREF color )
 {
-    if ((dc->w.bitsPerPixel > 1) && !COLOR_IsSolid( color ))
+    if ((dc->w.bitsPerPixel > 1) && (screenDepth <= 8) && !COLOR_IsSolid( color ))
     {
 	  /* Dithered brush */
 	dc->u.x.brush.pixmap = DITHER_DitherColor( dc, color );
diff --git a/objects/clipping.c b/objects/clipping.c
index d6d8bba..d0c3e13 100644
--- a/objects/clipping.c
+++ b/objects/clipping.c
@@ -2,10 +2,9 @@
  * DC clipping functions
  *
  * Copyright 1993 Alexandre Julliard
- */
-
+ *
 static char Copyright[] = "Copyright  Alexandre Julliard, 1993";
-
+*/
 #include <stdio.h>
 #include "gdi.h"
 #include "metafile.h"
diff --git a/objects/color.c b/objects/color.c
index 545169b..500eac2 100644
--- a/objects/color.c
+++ b/objects/color.c
@@ -2,16 +2,16 @@
  * Color functions
  *
  * Copyright 1993 Alexandre Julliard
- */
-
+ *
 static char Copyright[] = "Copyright  Alexandre Julliard, 1993";
-
+*/
 #include <stdlib.h>
 #include <X11/Xlib.h>
 #include <stdio.h>
 #include "windows.h"
 #include "options.h"
 #include "gdi.h"
+#include "color.h"
 
 
 Colormap COLOR_WinColormap = 0;
@@ -91,7 +91,7 @@
  *
  * Create the system palette.
  */
-static HPALETTE COLOR_InitPalette()
+static HPALETTE COLOR_InitPalette(void)
 {
     int i, size;
     XColor color;
@@ -162,7 +162,7 @@
  *
  * Initialize color map and system palette.
  */
-HPALETTE COLOR_Init()
+HPALETTE COLOR_Init(void)
 {
     Visual * visual = DefaultVisual( display, DefaultScreen(display) );
     
@@ -227,7 +227,7 @@
  *
  * Return the physical color closest to 'color'.
  */
-WORD COLOR_ToPhysical( DC *dc, COLORREF color )
+int COLOR_ToPhysical( DC *dc, COLORREF color )
 {
     WORD index = 0;
     WORD *mapping;
@@ -292,7 +292,8 @@
     WORD index;
     DC *dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
     if (!dc) return 0;
-    index = COLOR_ToPhysical( dc, color & 0xffffff );
+    if (screenDepth > 8) return color;
+    index = (WORD)(COLOR_ToPhysical( dc, color & 0xffffff ) & 0xffff);
     return PALETTEINDEX( index );
 }
 
diff --git a/objects/dc.c b/objects/dc.c
index a38906c..87d8006 100644
--- a/objects/dc.c
+++ b/objects/dc.c
@@ -2,29 +2,23 @@
  * GDI Device Context functions
  *
  * Copyright 1993 Alexandre Julliard
- */
-
+ *
 static char Copyright[] = "Copyright  Alexandre Julliard, 1993";
-
+*/
 #include <stdlib.h>
 #include <string.h>
 #include "gdi.h"
 #include "bitmap.h"
 #include "metafile.h"
 #include "stddebug.h"
-/* #define DEBUG_DC /* */
-/* #undef  DEBUG_DC /* */
+#include "color.h"
 #include "debug.h"
-
+#include "font.h"
 
 static DeviceCaps * displayDevCaps = NULL;
 
 extern const WIN_DC_INFO DCVAL_defaultValues;
-
 extern void CLIPPING_UpdateGCRegion( DC * dc );     /* objects/clipping.c */
-extern WORD COLOR_ToPhysical( DC *dc, COLORREF color );/* objects/color.c */
-extern void COLOR_SetMapping( DC *dc, HANDLE, WORD );  /* objects/color.c */
-
 
   /* ROP code to GC function conversion */
 const int DC_XROPfunction[16] =
diff --git a/objects/dcvalues.c b/objects/dcvalues.c
index 2def05b..801b6df 100644
--- a/objects/dcvalues.c
+++ b/objects/dcvalues.c
@@ -2,10 +2,9 @@
  * DC device-independent Get/SetXXX functions
  *
  * Copyright 1993 Alexandre Julliard
- */
-
+ *
 static char Copyright[] = "Copyright  Alexandre Julliard, 1993";
-
+*/
 #include "gdi.h"
 #include "metafile.h"
 
diff --git a/objects/dib.c b/objects/dib.c
index afb79be..d841f01 100644
--- a/objects/dib.c
+++ b/objects/dib.c
@@ -2,27 +2,37 @@
  * GDI device independent bitmaps
  *
  * Copyright 1993 Alexandre Julliard
- */
-
+ *
 static char Copyright[] = "Copyright  Alexandre Julliard, 1993";
-
+*/
 #include <stdio.h>
 #include <stdlib.h>
 #include <X11/Xlib.h>
 #include <X11/Xutil.h>
+#include "dc.h"
 #include "gdi.h"
 #include "bitmap.h"
 #include "icon.h"
 #include "stddebug.h"
-/* #define DEBUG_ICON /* */
-/* #undef  DEBUG_ICON /* */
-/* #define DEBUG_BITMAP /* */
-/* #undef  DEBUG_BIYMAP /* */
+#include "color.h"
 #include "debug.h"
 
-extern const int DC_XROPfunction[];
-
-extern WORD COLOR_ToPhysical( DC *dc, COLORREF color );  /* color.c */
+static int get_bpp(int depth)
+{
+	switch(depth) {
+		case 4:
+		case 8:	
+			return 1;
+		case 15:
+		case 16:
+			return 2;
+		case 24:
+			return 4;
+		default:
+			fprintf(stderr, "DIB: unsupported depth %d!\n", depth);
+			exit(1);
+	}		
+}
 
 /***********************************************************************
  *           DIB_BitmapInfoSize
@@ -51,9 +61,8 @@
 {
     extern void _XInitImageFuncPtrs( XImage* );
     XImage * image;
-    int bytesPerLine = ((bmp->biBitCount == 24 ? 32 : bmp->biBitCount)
-                        * bmp->biWidth + 31) / 32 * 4;
-    
+    int bytesPerLine = bmp->biWidth * get_bpp(bmp->biBitCount);
+
     image = XCreateImage( display, DefaultVisualOfScreen( screen ),
 			  bmp->biBitCount, ZPixmap, 0, bmpData,
 			  bmp->biWidth, bmp->biHeight, 32, bytesPerLine );
@@ -72,7 +81,7 @@
  * SetDIBits for a 1-bit deep DIB.
  */
 static void DIB_SetImageBits_1( WORD lines, BYTE *bits, WORD width,
-			        WORD *colors, XImage *bmpImage )
+                                int *colors, XImage *bmpImage )
 {
     WORD i, x;
     BYTE pad, pix;
@@ -116,7 +125,7 @@
  * SetDIBits for a 4-bit deep DIB.
  */
 static void DIB_SetImageBits_4( WORD lines, BYTE *bits, WORD width,
-			        WORD *colors, XImage *bmpImage )
+                                int *colors, XImage *bmpImage )
 {
     WORD i, x;
     BYTE pad;
@@ -150,7 +159,7 @@
  * SetDIBits for a 4-bit deep compressed DIB.
  */
 static void DIB_SetImageBits_RLE4( WORD lines, BYTE *bits, WORD width,
-			        WORD *colors, XImage *bmpImage )
+                                   int *colors, XImage *bmpImage )
 {
 	int x = 0, c, length;
 	BYTE *begin = bits;
@@ -209,7 +218,7 @@
  * SetDIBits for an 8-bit deep DIB.
  */
 static void DIB_SetImageBits_8( WORD lines, BYTE *bits, WORD width,
-			        WORD *colors, XImage *bmpImage )
+                                int *colors, XImage *bmpImage )
 {
     WORD x;
     BYTE pad = (4 - (width & 3)) & 3;
@@ -256,7 +265,7 @@
 static void DIB_SetImageBits_RLE8(WORD lines, 
 				  BYTE *bits, 
 				  WORD width,
-				  WORD *colors, 
+				  int *colors, 
 				  XImage *bmpImage)
 {
     int x;			/* X-positon on each line.  Increases. */
@@ -437,7 +446,7 @@
 			     Drawable drawable, GC gc, int xSrc, int ySrc,
 			     int xDest, int yDest, int width, int height )
 {
-    WORD *colorMapping;
+    int *colorMapping;
     XImage *bmpImage;
     void *bmpData;
     int i, colors, widthBytes;
@@ -449,7 +458,7 @@
     {
 	colors = info->bmiHeader.biClrUsed;
 	if (!colors) colors = 1 << info->bmiHeader.biBitCount;
-	if (!(colorMapping = (WORD *)malloc( colors * sizeof(WORD) )))
+	if (!(colorMapping = (int *)malloc( colors * sizeof(int) )))
 	    return 0;
 	if (coloruse == DIB_RGB_COLORS)
 	{
@@ -468,9 +477,8 @@
     }
 
       /* Transfer the pixels */
+    widthBytes = info->bmiHeader.biWidth * get_bpp(depth);
 
-    widthBytes = ((depth == 24 ? 32 : depth) * info->bmiHeader.biWidth + 31)
-                  / 32 * 4;
     bmpData  = malloc( lines * widthBytes );
     bmpImage = XCreateImage( display, DefaultVisualOfScreen(screen),
 			     depth, ZPixmap, 0, bmpData,
@@ -655,7 +663,7 @@
     BITMAP	bm;
     HBITMAP	hBitTemp;
     HDC		hMemDC;
-    HDC		hMemDC2;
+
     dprintf_icon(stddeb,"DrawIcon(%04X, %d, %d, %04X) \n", hDC, x, y, hIcon);
     if (hIcon == (HICON)NULL) return FALSE;
     lpico = (ICONALLOC *)GlobalLock(hIcon);
@@ -674,17 +682,17 @@
     dprintf_icon(stddeb,"DrawIcon / bitmap bmWidth=%d bmHeight=%d\n", 
 		 bm.bmWidth, bm.bmHeight);
     hMemDC = CreateCompatibleDC(hDC);
-#ifdef DEBUG_ICON
+    if(debugging_icon){
     hBitTemp = SelectObject(hMemDC, lpico->hBitmap);
     BitBlt(hDC, x, y, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
     SelectObject(hMemDC, lpico->hBitMask);
     BitBlt(hDC, x, y + bm.bmHeight, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
-#else
+    }else{
     hBitTemp = SelectObject(hMemDC, lpico->hBitMask);
     BitBlt(hDC, x, y, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCAND);
     SelectObject(hMemDC, lpico->hBitmap);
     BitBlt(hDC, x, y, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCPAINT);
-#endif
+    }
     SelectObject( hMemDC, hBitTemp );
     DeleteDC(hMemDC);
     return TRUE;
diff --git a/objects/dither.c b/objects/dither.c
index 5210106..d90396d 100644
--- a/objects/dither.c
+++ b/objects/dither.c
@@ -2,14 +2,14 @@
  * Dithering functions
  *
  * Copyright 1994 Alexandre Julliard
- */
-
+ *
 static char Copyright[] = "Copyright  Alexandre Julliard, 1994";
+*/
 
 #include <stdlib.h>
 #include <X11/Xlib.h>
 #include <X11/Xutil.h>
-
+#include "color.h"
 #include "gdi.h"
 #include "bitmap.h"
 
@@ -70,9 +70,6 @@
     15  /* ffffff -> ffffff */
 };
 
-   /* Map an EGA index (0..15) to a pixel value */
-extern int COLOR_mapEGAPixel[16];  /* in color.c */
-
 #define PIXEL_VALUE(r,g,b) \
     COLOR_mapEGAPixel[EGAmapping[((r)*PRIMARY_LEVELS+(g))*PRIMARY_LEVELS+(b)]]
 
@@ -86,7 +83,7 @@
  *
  * Create the X image used for dithering.
  */
-BOOL DITHER_Init()
+BOOL DITHER_Init(void)
 {
     int bytes_per_line = (screenDepth * MATRIX_SIZE + 7) / 8;
     if (!(imageData = (char *) malloc( bytes_per_line * MATRIX_SIZE )))
@@ -116,7 +113,7 @@
 	int b = GetBValue( color ) * DITHER_LEVELS;
 	const int *pmatrix = dither_matrix;
 
-	WORD *mapping = (WORD *) GDI_HEAP_ADDR( dc->u.x.pal.hMapping );
+/*	WORD *mapping = (WORD *) GDI_HEAP_ADDR( dc->u.x.pal.hMapping );*/
 
 	for (y = 0; y < MATRIX_SIZE; y++)
 	{
diff --git a/objects/font.c b/objects/font.c
index f051b8a..f03962f 100644
--- a/objects/font.c
+++ b/objects/font.c
@@ -2,9 +2,9 @@
  * GDI font objects
  *
  * Copyright 1993 Alexandre Julliard
- */
-
+ *
 static char Copyright[] = "Copyright  Alexandre Julliard, 1993";
+*/
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -12,9 +12,10 @@
 #include <X11/Xatom.h>
 #include "user.h"
 #include "gdi.h"
+#include "metafile.h"
+#include "callback.h"
 #include "stddebug.h"
 /* #define DEBUG_FONT */
-/* #undef  DEBUG_FONT */
 #include "debug.h"
 
 #define MAX_FONTS	256
@@ -429,7 +430,7 @@
 {
     SIZE size;
     if (!GetTextExtentPoint( hdc, str, count, &size )) return 0;
-    return size.cx | (size.cy << 16);
+    return MAKELONG( size.cx, size.cy );
 }
 
 
@@ -582,7 +583,7 @@
 /*************************************************************************
  *				InitFontsList		[internal]
  */
-void InitFontsList()
+void InitFontsList(void)
 {
     char 	str[32];
     char 	pattern[100];
diff --git a/objects/gdiobj.c b/objects/gdiobj.c
index 992c935..6e8fa39 100644
--- a/objects/gdiobj.c
+++ b/objects/gdiobj.c
@@ -2,18 +2,20 @@
  * GDI functions
  *
  * Copyright 1993 Alexandre Julliard
- */
-
+ *
 static char Copyright[] = "Copyright  Alexandre Julliard, 1993";
+*/
 
 #include <stdlib.h>
 #include <stdio.h>
 #include "user.h"
 #include "gdi.h"
+#include "color.h"
 #include "prototypes.h"
 #include "stddebug.h"
+#include "bitmap.h"
+#include "font.h"
 /* #define DEBUG_GDI */
-/* #undef  DEBUG_GDI */
 #include "debug.h"
 
 MDESC *GDI_Heap = NULL;
@@ -25,8 +27,6 @@
 #define MAX_OBJ 			1024
 HANDLE *lpPenBrushList = NULL;
 
-extern HPALETTE COLOR_Init();  /* color.c */
-
 /***********************************************************************
  *          GDI stock objects 
  */
@@ -155,7 +155,7 @@
  *
  * GDI initialisation.
  */
-BOOL GDI_Init()
+BOOL GDI_Init(void)
 {
     HPALETTE hpalette;
     struct segment_descriptor_s * s;
@@ -429,8 +429,8 @@
  */
 int EnumObjects(HDC hDC, int nObjType, FARPROC lpEnumFunc, LPSTR lpData)
 {
-    HANDLE 		handle;
-    DC 			*dc;
+/*    HANDLE 		handle;
+    DC 			*dc;*/
 	HANDLE		*lphObj;
 	GDIOBJHDR 	*header;
 	WORD  		wMagic;
diff --git a/objects/linedda.c b/objects/linedda.c
index e61290d..729f9ec 100644
--- a/objects/linedda.c
+++ b/objects/linedda.c
@@ -2,12 +2,13 @@
  * LineDDA
  *
  * Copyright 1993 Bob Amstadt
- */
-
+ *
 static char Copyright[] = "Copyright  Bob Amstadt, 1993";
+*/
 
 #include <stdlib.h>
 #include "windows.h"
+#include "if1632.h"
 
 /**********************************************************************
  *		LineDDA		(GDI.100)
diff --git a/objects/metafile.c b/objects/metafile.c
index 8715bf7..debdf23 100644
--- a/objects/metafile.c
+++ b/objects/metafile.c
@@ -2,9 +2,9 @@
  * Metafile functions
  *
  * Copyright  David W. Metcalfe, 1994
- */
-
+ *
 static char Copyright[] = "Copyright  David W. Metcalfe, 1994";
+*/
 
 #include <string.h>
 #include "windows.h"
@@ -12,8 +12,7 @@
 #include "metafile.h"
 #include "prototypes.h"
 #include "stddebug.h"
-/* #define DEBUG_METAFILE /* */
-/* #undef  DEBUG_METAFILE /* */
+/* #define DEBUG_METAFILE */
 #include "debug.h"
 
 #define HTINCR  10      /* handle table allocation size increment */
@@ -22,6 +21,58 @@
 static int HTLen;       /* allocated length of handle table */
 
 /******************************************************************
+ *         GetMetafile         GDI.124 By Kenny MacDonald 30 Nov 94
+ */
+HMETAFILE GetMetaFile(LPSTR lpFilename)
+{
+
+  DC *dc;
+  HMETAFILE hmf;
+  METAFILE *mf;
+  METAHEADER *mh;
+
+  dprintf_metafile(stddeb,"GetMetaFile: %s\n", lpFilename);
+
+  if (!lpFilename)
+    return 0;
+
+  hmf = GlobalAlloc(GMEM_MOVEABLE, sizeof(METAFILE));
+  mf = (METAFILE *)GlobalLock(hmf);
+  if (!mf) {
+    GlobalFree(hmf);
+    return 0;
+  }
+
+  mf->hMetaHdr = GlobalAlloc(GMEM_MOVEABLE, MFHEADERSIZE);
+  mh = (METAHEADER *)GlobalLock(mf->hMetaHdr);
+  if (!mh) {
+    GlobalFree(mf->hMetaHdr);
+    GlobalFree(hmf);
+    return 0;
+  }
+  strcpy(mf->Filename, lpFilename);
+  mf->wMagic = METAFILE_MAGIC;
+  if ((mf->hFile = _lopen(lpFilename, OF_READ)) == HFILE_ERROR) {
+    GlobalFree(hmf);
+    return 0;
+  }
+  if (_lread(mf->hFile, (char *)mh, MFHEADERSIZE) == HFILE_ERROR) {
+    GlobalFree(mf->hMetaHdr);
+    GlobalFree(hmf);
+    return 0;
+  }
+  _lclose(mf->hFile);
+
+
+  GlobalUnlock(mf->hMetaHdr);
+  GlobalUnlock(hmf);
+  if (mh->mtType != 1)
+    return 0;
+  else
+    return hmf;
+}
+
+/******************************************************************
  *         CreateMetafile         GDI.125
  */
 HANDLE CreateMetaFile(LPSTR lpFilename)
@@ -93,7 +144,7 @@
     METAHEADER *mh;
     HMETAFILE hmf;
     char buffer[15];
-    METARECORD *mr = (METARECORD *)&buffer;
+/*    METARECORD *mr = (METARECORD *)&buffer;*/
 
     dprintf_metafile(stddeb,"CloseMetaFile\n");
 
@@ -194,7 +245,7 @@
 	if (mh->mtType == 1)   /* disk based metafile */
 	{
 	    _lread(mf->hFile, buffer, sizeof(METARECORD));
-	    mr = (METARECORD *)&buffer;
+	    mr = (METARECORD *)buffer;
 	    _lread(mf->hFile, (char *)(mr->rdParam + 1), (mr->rdSize * 2) -
 		                                       sizeof(METARECORD));
 	    mf->MetaOffset += mr->rdSize * 2;
@@ -234,6 +285,13 @@
 
     switch (mr->rdFunction)
     {
+    case META_EOF:
+      break;
+
+    case META_DELETEOBJECT:
+      DeleteObject(*(ht->objectHandle + *(mr->rdParam)));
+      break;
+
     case META_SETBKCOLOR:
 	SetBkColor(hdc, *(mr->rdParam));
 	break;
@@ -381,6 +439,11 @@
 	Polygon(hdc, (LPPOINT)(mr->rdParam + 1), *(mr->rdParam));
 	break;
 
+    case META_POLYPOLYGON:
+      PolyPolygon(hdc, (LPPOINT)(mr->rdParam + *(mr->rdParam) + 1),
+		  (mr->rdParam + 1), *(mr->rdParam)); 
+      break;
+
     case META_POLYLINE:
 	Polyline(hdc, (LPPOINT)(mr->rdParam + 1), *(mr->rdParam));
 	break;
diff --git a/objects/oembitmap.c b/objects/oembitmap.c
index 0c5a96c..883d092 100644
--- a/objects/oembitmap.c
+++ b/objects/oembitmap.c
@@ -2,10 +2,9 @@
  * GDI OEM bitmap objects
  *
  * Copyright 1994 Alexandre Julliard
- */
-
+ *
 static char Copyright[] = "Copyright  Alexandre Julliard, 1994";
-
+*/
 #include <X11/Xlib.h>
 #include <X11/Xutil.h>
 #ifdef USE_XPM
@@ -14,7 +13,7 @@
 #include "gdi.h"
 #include "bitmap.h"
 #include "stddebug.h"
-/* #define DEBUG_BITMAP */
+#include "color.h"
 #include "debug.h"
 
 #define OBM_FIRST  OBM_LFARROWI    /* First OEM bitmap */
@@ -188,10 +187,6 @@
 
 #endif /* USE_XPM */
 
-extern WORD COLOR_ToPhysical( DC *dc, COLORREF color );  /* color.c */
-
-extern Colormap COLOR_WinColormap;
-
 
 /***********************************************************************
  *           OBM_InitColorSymbols
diff --git a/objects/palette.c b/objects/palette.c
index 7a8cde4..c28cb60 100644
--- a/objects/palette.c
+++ b/objects/palette.c
@@ -2,10 +2,9 @@
  * GDI palette objects
  *
  * Copyright 1993,1994 Alexandre Julliard
- */
-
+ *
 static char Copyright[] = "Copyright  Alexandre Julliard, 1993,1994";
-
+*/
 #include <stdlib.h>
 #include <string.h>
 #include <limits.h>
@@ -17,16 +16,11 @@
 
 #include <X11/Xlib.h>
 #include "gdi.h"
+#include "color.h"
 #include "stddebug.h"
 /* #define DEBUG_PALETTE */
-/* #undef  DEBUG_PALETTE */
 #include "debug.h"
 
-extern void COLOR_SetMapping( DC *dc, HANDLE map, WORD size );  /* color.c */
-
-extern Colormap COLOR_WinColormap;
-
-
 /***********************************************************************
  *           CreatePalette    (GDI.360)
  */
diff --git a/objects/pen.c b/objects/pen.c
index df5f55c..2293182 100644
--- a/objects/pen.c
+++ b/objects/pen.c
@@ -2,19 +2,15 @@
  * GDI pen objects
  *
  * Copyright 1993 Alexandre Julliard
- */
-
+ *
 static char Copyright[] = "Copyright  Alexandre Julliard, 1993";
-
+*/
 #include "gdi.h"
 #include "metafile.h"
 #include "stddebug.h"
-/* #define DEBUG_GDI */
-/* #undef  DEBUG_GDI */
+#include "color.h"
 #include "debug.h"
 
-extern WORD COLOR_ToPhysical( DC *dc, COLORREF color );
-
 /***********************************************************************
  *           CreatePen    (GDI.61)
  */
diff --git a/objects/region.c b/objects/region.c
index ad3379b..5d1d1d9 100644
--- a/objects/region.c
+++ b/objects/region.c
@@ -2,17 +2,15 @@
  * GDI region objects
  *
  * Copyright 1993, 1994 Alexandre Julliard
- */
-
+ *
 static char Copyright[] = "Copyright  Alexandre Julliard, 1993, 1994";
-
+*/
 #include <stdlib.h>
 #include <stdio.h>
 
 #include "gdi.h"
 #include "stddebug.h"
-/* #define DEBUG_REGION /* */
-/* #undef  DEBUG_REGION /* */
+/* #define DEBUG_REGION */
 #include "debug.h"
 
   /* GC used for region operations */
@@ -21,7 +19,7 @@
 /***********************************************************************
  *           REGION_Init
  */
-BOOL REGION_Init()
+BOOL REGION_Init(void)
 {
     Pixmap tmpPixmap;
 
diff --git a/objects/text.c b/objects/text.c
index d07d2b9..c28f3b0 100644
--- a/objects/text.c
+++ b/objects/text.c
@@ -2,18 +2,18 @@
  * text functions
  *
  * Copyright 1993, 1994 Alexandre Julliard
- */
-
+ *
 static char Copyright[] = "Copyright  Alexandre Julliard, 1993, 1994";
-
+*/
 #include <stdlib.h>
 #include <X11/Xatom.h>
 #include "windows.h"
+#include "dc.h"
 #include "gdi.h"
+#include "callback.h"
 #include "metafile.h"
 #include "stddebug.h"
-/* #define DEBUG_TEXT /* */
-/* #undef  DEBUG_TEXT /* */
+/* #define DEBUG_TEXT */
 #include "debug.h"
 
 #define TAB     9
@@ -505,29 +505,81 @@
 
 
 /***********************************************************************
- *			TabbedTextOut		[USER.196]
+ *           TEXT_TabbedTextOut
+ *
+ * Helper function for TabbedTextOut() and GetTabbedTextExtent().
+ * Note: this doesn't work too well for text-alignment modes other
+ *       than TA_LEFT|TA_TOP. But we want bug-for-bug compatibility :-)
  */
-LONG TabbedTextOut(HDC hDC, short x, short y, LPSTR lpStr, short nCount, 
-		short nTabCount, LPINT lpTabPos, short nTabOrg)
+LONG TEXT_TabbedTextOut( HDC hdc, int x, int y, LPSTR lpstr, int count, 
+                         int cTabStops, LPINT lpTabPos, int nTabOrg,
+                         BOOL fDisplayText)
 {
-	WORD 	width, height;
-	dprintf_text(stdnimp,"EMPTY STUB !!! TabbedTextOut(); ! call TextOut() for now !\n");
-	height = HIWORD(GetTextExtent(hDC, lpStr, nCount));
-	width = LOWORD(GetTextExtent(hDC, lpStr, nCount));
-	TextOut(hDC, x, y, lpStr, nCount);
-	return MAKELONG(width, height);
+    WORD defWidth;
+    DWORD extent;
+    int i, tabPos = 0;
+
+    if (cTabStops == 1) defWidth = *lpTabPos;
+    else
+    {
+        TEXTMETRIC tm;
+        GetTextMetrics( hdc, &tm );
+        defWidth = 8 * tm.tmAveCharWidth;
+    }
+    
+    while (count > 0)
+    {
+        for (i = 0; i < count; i++)
+            if (lpstr[i] == '\t') break;
+        extent = GetTextExtent( hdc, lpstr, i );
+        while ((cTabStops > 0) && (nTabOrg + *lpTabPos < x + LOWORD(extent)))
+        {
+            lpTabPos++;
+            cTabStops--;
+        }
+        if (lpstr[i] != '\t')
+            tabPos = x + LOWORD(extent);
+        else if (cTabStops > 0)
+            tabPos = nTabOrg + *lpTabPos;
+        else
+            tabPos = (x + LOWORD(extent) + defWidth - 1) / defWidth * defWidth;
+        if (fDisplayText)
+        {
+            RECT r;
+            SetRect( &r, x, y, tabPos, y+HIWORD(extent) );
+            ExtTextOut( hdc, x, y,
+                        GetBkMode(hdc) == OPAQUE ? ETO_OPAQUE : 0,
+                        &r, lpstr, i, NULL );
+        }
+        x = tabPos;
+        count -= i+1;
+        lpstr += i+1;
+    }
+    return tabPos;
 }
 
 
 /***********************************************************************
- *			GetTabbedTextExtent		[USER.197]
+ *           TabbedTextOut    (USER.196)
  */
-DWORD GetTabbedTextExtent(HDC hDC, LPSTR lpString, int nCount, 
-	int nTabPositions, LPINT lpnTabStopPositions)
+LONG TabbedTextOut( HDC hdc, short x, short y, LPSTR lpstr, short count, 
+                    short cTabStops, LPINT lpTabPos, short nTabOrg )
 {
-	dprintf_text(stdnimp,"EMPTY STUB !!! GetTabbedTextExtent(); !\n");
-
-	return (18 << 16) | (nCount * 18);
+    dprintf_text( stddeb, "TabbedTextOut: %x %d,%d '%s' %d\n",
+                  hdc, x, y, lpstr, count );
+    return TEXT_TabbedTextOut( hdc, x, y, lpstr, count, cTabStops,
+                               lpTabPos, nTabOrg, TRUE );
 }
 
 
+/***********************************************************************
+ *           GetTabbedTextExtent    (USER.197)
+ */
+DWORD GetTabbedTextExtent( HDC hdc, LPSTR lpstr, int count, 
+                          int cTabStops, LPINT lpTabPos )
+{
+    dprintf_text( stddeb, "GetTabbedTextExtent: %x '%s' %d\n",
+                  hdc, lpstr, count );
+    return TEXT_TabbedTextOut( hdc, 0, 0, lpstr, count, cTabStops,
+                               lpTabPos, 0, FALSE );
+}
diff --git a/rc/rc.l b/rc/rc.l
index a09819f..2773820 100644
--- a/rc/rc.l
+++ b/rc/rc.l
@@ -4,7 +4,6 @@
  * Copyright  Martin von Loewis, 1994
  *
  */
-
 static char Copyright[] = "Copyright Martin von Loewis, 1994";
 
 #include <string.h>
diff --git a/rc/rc.y b/rc/rc.y
index ee7fccf..3844e39 100644
--- a/rc/rc.y
+++ b/rc/rc.y
@@ -2,7 +2,6 @@
 /*
  *
  * Copyright  Martin von Loewis, 1994
- *
  */
 
 static char Copyright[] = "Copyright Martin von Loewis, 1994";
@@ -204,7 +203,7 @@
 		| '(' style ')' {$$=$2;}
 		| style '|' style {$$=$1;$$->or|=$3->or;$$->and&=$3->and;}
 %%
-yyerror(char *s)
+int yyerror(char *s)
 {
 	puts(s);
 }
diff --git a/rc/sysres.rc b/rc/sysres.rc
index 8cb9791..674df65 100644
--- a/rc/sysres.rc
+++ b/rc/sysres.rc
@@ -1,269 +1,271 @@
 #if #LANG(En)
 
-SYSMENU MENU LOADONCALL MOVEABLE DISCARDABLE 

-{

- MENUITEM "&Restore", 61728

- MENUITEM "&Move", 61456

- MENUITEM "&Size", 61440

- MENUITEM "Mi&nimize", 61472

- MENUITEM "Ma&ximize", 61488

- MENUITEM SEPARATOR

- MENUITEM "&Close\tAlt-F4", 61536

- MENUITEM SEPARATOR

- MENUITEM "&Switch to ...\tCtrl-Esc", 61744

- MENUITEM SEPARATOR

- MENUITEM "&About WINE ...", 61761

-}

-

-

-2 DIALOG LOADONCALL MOVEABLE DISCARDABLE 80, 80, 150, 170

-STYLE WS_POPUP | WS_VISIBLE | WS_DLGFRAME

-{

- PUSHBUTTON "Credit & License", 6, 30, 150, 40, 14, WS_GROUP | WS_TABSTOP

- PUSHBUTTON "Cancel", 2, 60, 250, 40, 14, WS_GROUP | WS_TABSTOP

- DEFPUSHBUTTON "Ok", 1, 80, 150, 40, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP

-}

-

-

-STOP_MSGBOX DIALOG LOADONCALL MOVEABLE DISCARDABLE 80, 80, 150, 75

-STYLE WS_POPUP | WS_VISIBLE | WS_DLGFRAME

-{

- ICON "SYSIDI_HAND", -1, 16, 16, 0, 0

-}

-

-

-QUESTION_MSGBOX DIALOG LOADONCALL MOVEABLE DISCARDABLE 80, 80, 150, 75

-STYLE WS_POPUP | WS_VISIBLE | WS_DLGFRAME

-{

- ICON "SYSIDI_QUESTION", -1, 16, 16, 0, 0

-}

-

-

-EXCLAMATION_MSGBOX DIALOG LOADONCALL MOVEABLE DISCARDABLE 80, 80, 150, 75

-STYLE WS_POPUP | WS_VISIBLE | WS_DLGFRAME

-{

- ICON "SYSIDI_EXCLAMATION", -1, 16, 16, 0, 0

-}

-

-

-SHELL_ABOUT_MSGBOX DIALOG LOADONCALL MOVEABLE DISCARDABLE 50, 44, 213, 149

-STYLE DS_LOCALEDIT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU

-CAPTION "about X"

-FONT 10, "System"

-{

- DEFPUSHBUTTON "OK", 1, 86, 130, 40, 14

- CONTROL "", -1, "STATIC", SS_BLACKFRAME | WS_CHILD | WS_VISIBLE | WS_DISABLED, 4, 35, 205, 90

- LTEXT "Text", 100, 11, 40, 190, 80, SS_NOPREFIX | WS_GROUP

- ICON "WINEICON", -1, 185, 10, 18, 20

-}

-

-

-3 DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 275, 134

-STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU

-CAPTION "Open"

-FONT 8, "Helv"

-{

- LTEXT "File &Name:", 1090, 6, 6, 76, 9

- EDITTEXT 1152, 6, 16, 90, 12, ES_AUTOHSCROLL | ES_OEMCONVERT | WS_BORDER | WS_TABSTOP

- LISTBOX 1120, 6, 32, 90, 68, LBS_STANDARD | LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_DISABLENOSCROLL | WS_TABSTOP

- LTEXT "&Directories:", -1, 110, 6, 92, 9

- LTEXT "", 1088, 110, 18, 92, 9, SS_NOPREFIX | WS_GROUP

- LISTBOX 1121, 110, 32, 92, 68, LBS_STANDARD | LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_DISABLENOSCROLL | WS_TABSTOP

- LTEXT "List Files of &Type:", 1089, 6, 104, 90, 9

- COMBOBOX 1136, 6, 114, 90, 36, CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | WS_BORDER | WS_VSCROLL | WS_TABSTOP

- LTEXT "Dri&ves:", 1091, 110, 104, 92, 9

- COMBOBOX 1137, 110, 114, 92, 68, CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED | CBS_AUTOHSCROLL | CBS_SORT | CBS_HASSTRINGS | WS_BORDER | WS_VSCROLL | WS_TABSTOP

- DEFPUSHBUTTON "Open", 1, 208, 6, 56, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP

- PUSHBUTTON "Cancel", 2, 208, 24, 56, 14, WS_GROUP | WS_TABSTOP

- PUSHBUTTON "&Help", 1038, 208, 46, 56, 14, WS_GROUP | WS_TABSTOP

- CHECKBOX "&Read Only", 1040, 208, 68, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP

-}

-

-

-4 DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 275, 134

-STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU

-CAPTION "Save As ..."

-FONT 8, "Helv"

-{

- LTEXT "File &Name:", 1090, 6, 6, 76, 9

- EDITTEXT 1152, 6, 16, 90, 12, ES_AUTOHSCROLL | ES_OEMCONVERT | WS_BORDER | WS_TABSTOP

- LISTBOX 1120, 6, 32, 90, 68, LBS_STANDARD | LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_DISABLENOSCROLL | WS_TABSTOP

- LTEXT "&Directories:", -1, 110, 6, 92, 9

- LTEXT "", 1088, 110, 18, 92, 9, SS_NOPREFIX | WS_GROUP

- LISTBOX 1121, 110, 32, 92, 68, LBS_STANDARD | LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_DISABLENOSCROLL | WS_TABSTOP

- LTEXT "List Files of &Type:", 1089, 6, 104, 90, 9

- COMBOBOX 1136, 6, 114, 90, 36, CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | WS_BORDER | WS_VSCROLL | WS_TABSTOP

- LTEXT "Dri&ves:", 1091, 110, 104, 92, 9

- COMBOBOX 1137, 110, 114, 92, 68, CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED | CBS_AUTOHSCROLL | CBS_SORT | CBS_HASSTRINGS | WS_BORDER | WS_VSCROLL | WS_TABSTOP

- DEFPUSHBUTTON "Save As", 1, 208, 6, 56, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP

- PUSHBUTTON "Cancel", 2, 208, 24, 56, 14, WS_GROUP | WS_TABSTOP

- PUSHBUTTON "&Help", 1038, 208, 46, 56, 14, WS_GROUP | WS_TABSTOP

- CHECKBOX "&Read Only", 1040, 208, 68, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP

-}

-

-

-11 DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 275, 134

-STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU

-CAPTION "Open"

-FONT 8, "Helv"

-{

- LTEXT "File &Name:", 1090, 6, 6, 76, 9

- LTEXT "", 1152, 6, 16, 90, 12

- LISTBOX 1120, 6, 32, 90, 68, LBS_STANDARD | LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_DISABLENOSCROLL | WS_TABSTOP

- LTEXT "&Directories:", -1, 110, 6, 92, 9

- LTEXT "", 1088, 110, 18, 92, 9, SS_NOPREFIX | WS_GROUP

- LISTBOX 1121, 110, 32, 92, 68, LBS_STANDARD | LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_DISABLENOSCROLL | WS_TABSTOP

- LTEXT "List Files of &Type:", 1089, 6, 104, 90, 9

- COMBOBOX 1136, 6, 114, 90, 36, CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | WS_BORDER | WS_VSCROLL | WS_TABSTOP

- LTEXT "Dri&ves:", 1091, 110, 104, 92, 9

- COMBOBOX 1137, 110, 114, 92, 68, CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED | CBS_AUTOHSCROLL | CBS_SORT | CBS_HASSTRINGS | WS_BORDER | WS_VSCROLL | WS_TABSTOP

- DEFPUSHBUTTON "Open", 1, 208, 6, 56, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP

- PUSHBUTTON "Cancel", 2, 208, 24, 56, 14, WS_GROUP | WS_TABSTOP

- PUSHBUTTON "&Help", 1038, 208, 46, 56, 14, WS_GROUP | WS_TABSTOP

- CHECKBOX "&Read Only", 1040, 208, 68, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP

-}

-

-

-12 DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 275, 134

-STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU

-CAPTION "Save As ..."

-FONT 8, "Helv"

-{

- LTEXT "File &Name:", 1090, 6, 6, 76, 9

- LTEXT "", 1152, 6, 16, 90, 12

- LISTBOX 1120, 6, 32, 90, 68, LBS_STANDARD | LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_DISABLENOSCROLL | WS_TABSTOP

- LTEXT "&Directories:", -1, 110, 6, 92, 9

- LTEXT "", 1088, 110, 18, 92, 9, SS_NOPREFIX | WS_GROUP

- LISTBOX 1121, 110, 32, 92, 68, LBS_STANDARD | LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_DISABLENOSCROLL | WS_TABSTOP

- LTEXT "List Files of &Type:", 1089, 6, 104, 90, 9

- COMBOBOX 1136, 6, 114, 90, 36, CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | WS_BORDER | WS_VSCROLL | WS_TABSTOP

- LTEXT "Dri&ves:", 1091, 110, 104, 92, 9

- COMBOBOX 1137, 110, 114, 92, 68, CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED | CBS_AUTOHSCROLL | CBS_SORT | CBS_HASSTRINGS | WS_BORDER | WS_VSCROLL | WS_TABSTOP

- DEFPUSHBUTTON "Save As", 1, 208, 6, 56, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP

- PUSHBUTTON "Cancel", 2, 208, 24, 56, 14, WS_GROUP | WS_TABSTOP

- PUSHBUTTON "&Help", 1038, 208, 46, 56, 14, WS_GROUP | WS_TABSTOP

- CHECKBOX "&Read Only", 1040, 208, 68, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP

-}

-

-

-5 DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 264, 134

-STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU

-CAPTION "Print"

-FONT 8, "Helv"

-{

- LTEXT "Printer:", 1088, 6, 6, 40, 9

- LTEXT "", 1089, 60, 6, 150, 9

- GROUPBOX "Print Range", 1072, 6, 30, 160, 65, BS_GROUPBOX

- RADIOBUTTON "&All", 1056, 16, 45, 60, 12

- RADIOBUTTON "S&election", 1057, 16, 60, 60, 12

- RADIOBUTTON "&Pages", 1058, 16, 75, 60, 12

- DEFPUSHBUTTON "Print", 1, 206, 6, 56, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP

- PUSHBUTTON "Cancel", 2, 206, 24, 56, 14, WS_GROUP | WS_TABSTOP

- PUSHBUTTON "&Setup", 1024, 206, 46, 56, 14, WS_GROUP | WS_TABSTOP

- LTEXT "&From:", 1090, 60, 80, 30, 9

- LTEXT "&To:", 1091, 120, 80, 30, 9

- LTEXT "Print &Quality:", 1092, 6, 100, 76, 9

- COMBOBOX 1136, 80, 100, 92, 68, CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED | CBS_AUTOHSCROLL | CBS_SORT | CBS_HASSTRINGS | WS_BORDER | WS_VSCROLL | WS_TABSTOP

- CHECKBOX "Print to Fi&le", 1040, 20, 100, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP

- CHECKBOX "Condensed", 1041, 160, 100, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP

-}

-

-

-6 DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 264, 134

-STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU

-CAPTION "Print Setup"

-FONT 8, "Helv"

-{

- GROUPBOX "Printer", 1072, 6, 10, 180, 65, BS_GROUPBOX

- RADIOBUTTON "&Default Printer", 1056, 16, 20, 80, 12

- LTEXT "[none]", 1088, 35, 35, 120, 9

- RADIOBUTTON "Specific &Printer", 1057, 16, 50, 80, 12

- COMBOBOX 1136, 35, 65, 149, 68, CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED | CBS_AUTOHSCROLL | CBS_SORT | CBS_HASSTRINGS | WS_BORDER | WS_VSCROLL | WS_TABSTOP

- DEFPUSHBUTTON "Ok", 1, 206, 6, 56, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP

- PUSHBUTTON "Cancel", 2, 206, 24, 56, 14, WS_GROUP | WS_TABSTOP

- PUSHBUTTON "&Setup", 1024, 206, 46, 56, 14, WS_GROUP | WS_TABSTOP

- GROUPBOX "Orientation", 1073, 6, 85, 100, 50, BS_GROUPBOX

- RADIOBUTTON "Po&rtrait", 1058, 50, 100, 40, 12

- RADIOBUTTON "&Landscape", 1059, 50, 115, 40, 12

- ICON "LANDSCAP", 1097, 10, 95, 32, 32

- ICON "PORTRAIT", 1098, 10, 95, 32, 32

- GROUPBOX "Paper", 1074, 120, 85, 180, 50, BS_GROUPBOX

- LTEXT "Si&ze", 1089, 130, 95, 30, 9

- LTEXT "&Source", 1090, 130, 110, 30, 9

- COMBOBOX 1137, 155, 95, 92, 68, CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED | CBS_AUTOHSCROLL | CBS_SORT | CBS_HASSTRINGS | WS_BORDER | WS_VSCROLL | WS_TABSTOP

- COMBOBOX 1138, 155, 110, 92, 68, CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED | CBS_AUTOHSCROLL | CBS_SORT | CBS_HASSTRINGS | WS_BORDER | WS_VSCROLL | WS_TABSTOP

-}

-

-

-7 DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 264, 134

-STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU

-CAPTION "Font"

-FONT 8, "Helv"

-{

- LTEXT "Font:", 1088, 6, 6, 40, 9

- LTEXT "", 1089, 60, 6, 150, 9

- DEFPUSHBUTTON "Ok", 1, 206, 6, 56, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP

- PUSHBUTTON "Cancel", 2, 206, 24, 56, 14, WS_GROUP | WS_TABSTOP

-}

-

-

-8 DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 264, 200

-STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU

-CAPTION "Color"

-FONT 8, "Helv"

-{

- LTEXT "&Basic Colors:", 1088, 6, 6, 40, 9

- LTEXT "&Custom Colors:", 1089, 6, 126, 40, 9

- LTEXT "Color|Sol&id", 1090, 100, 146, 40, 9

- LTEXT "&Hue:", 1091, 150, 126, 40, 9

- LTEXT "&Sat:", 1092, 150, 146, 40, 9

- LTEXT "&Lum:", 1093, 150, 166, 40, 9

- LTEXT "&Red:", 1094, 150, 126, 40, 9

- LTEXT "&Green:", 1095, 150, 146, 40, 9

- LTEXT "Bl&ue:", 1096, 150, 166, 40, 9

- DEFPUSHBUTTON "Ok", 1, 6, 182, 56, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP

- PUSHBUTTON "&Add to Custom Colors", 1024, 120, 182, 100, 14, WS_GROUP | WS_TABSTOP

- PUSHBUTTON "&Delete Custom Colors", 1025, 6, 164, 56, 14, WS_GROUP | WS_TABSTOP

- PUSHBUTTON "Cancel", 2, 76, 182, 56, 14, WS_GROUP | WS_TABSTOP

-}

-

-

-9 DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 264, 84

-STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU

-CAPTION "Find"

-FONT 8, "Helv"

-{

- LTEXT "Fi&nd What:", 1088, 6, 6, 40, 9

- LTEXT "", 1089, 60, 6, 150, 9

- CHECKBOX "Match &Whole Word Only", 1040, 20, 30, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP

- CHECKBOX "Match &Case", 1041, 20, 50, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP

- GROUPBOX "Direction", 1072, 90, 40, 80, 40, BS_GROUPBOX

- RADIOBUTTON "&Up", 1056, 100, 50, 50, 12

- RADIOBUTTON "&Down", 1057, 150, 50, 50, 12

- DEFPUSHBUTTON "&Find Next", 1, 206, 6, 56, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP

- PUSHBUTTON "Cancel", 2, 206, 24, 56, 14, WS_GROUP | WS_TABSTOP

-}

-

-

-10 DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 264, 114

-STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU

-CAPTION "Replace"

-FONT 8, "Helv"

-{

- LTEXT "Fi&nd What:", 1088, 6, 6, 40, 9

- LTEXT "", 1089, 60, 6, 150, 9

- LTEXT "Re&place With:", 1090, 6, 26, 40, 9

- LTEXT "", 1091, 60, 26, 150, 9

- CHECKBOX "Match &Whole Word Only", 1040, 20, 40, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP

- CHECKBOX "Match &Case", 1041, 20, 60, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP

- DEFPUSHBUTTON "&Find Next", 1, 206, 6, 56, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP

- PUSHBUTTON "&Replace", 1024, 206, 24, 56, 14, WS_GROUP | WS_TABSTOP

- PUSHBUTTON "Replace &All", 1025, 206, 44, 56, 14, WS_GROUP | WS_TABSTOP

- PUSHBUTTON "Cancel", 2, 206, 64, 56, 14, WS_GROUP | WS_TABSTOP

-}

-

-#endif /*LANG=En*/
+SYSMENU MENU LOADONCALL MOVEABLE DISCARDABLE
+{
+ MENUITEM "&Restore", 61728
+ MENUITEM "&Move", 61456
+ MENUITEM "&Size", 61440
+ MENUITEM "Mi&nimize", 61472
+ MENUITEM "Ma&ximize", 61488
+ MENUITEM SEPARATOR
+ MENUITEM "&Close\tAlt-F4", 61536
+ MENUITEM SEPARATOR
+ MENUITEM "&Switch to ...\tCtrl-Esc", 61744
+ MENUITEM SEPARATOR
+ MENUITEM "&About WINE ...", 61761
+}
 
-#if #LANG(De)
+
+2 DIALOG LOADONCALL MOVEABLE DISCARDABLE 80, 80, 150, 170
+STYLE WS_POPUP | WS_VISIBLE | WS_DLGFRAME
+{
+ PUSHBUTTON "Credit & License", 6, 30, 150, 40, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "Cancel", 2, 60, 250, 40, 14, WS_GROUP | WS_TABSTOP
+ DEFPUSHBUTTON "Ok", 1, 80, 150, 40, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
+}
+
+
+STOP_MSGBOX DIALOG LOADONCALL MOVEABLE DISCARDABLE 80, 80, 150, 75
+STYLE WS_POPUP | WS_VISIBLE | WS_DLGFRAME
+{
+ ICON "SYSIDI_HAND", -1, 16, 16, 0, 0
+}
+
+
+QUESTION_MSGBOX DIALOG LOADONCALL MOVEABLE DISCARDABLE 80, 80, 150, 75
+STYLE WS_POPUP | WS_VISIBLE | WS_DLGFRAME
+{
+ ICON "SYSIDI_QUESTION", -1, 16, 16, 0, 0
+}
+
+
+EXCLAMATION_MSGBOX DIALOG LOADONCALL MOVEABLE DISCARDABLE 80, 80, 150, 75
+STYLE WS_POPUP | WS_VISIBLE | WS_DLGFRAME
+{
+ ICON "SYSIDI_EXCLAMATION", -1, 16, 16, 0, 0
+}
+
+
+SHELL_ABOUT_MSGBOX DIALOG LOADONCALL MOVEABLE DISCARDABLE 50, 44, 213, 149
+STYLE DS_LOCALEDIT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+CAPTION "About X"
+FONT 10, "System"
+{
+ DEFPUSHBUTTON "OK", 1, 86, 130, 40, 14
+ CONTROL "", -1, "STATIC", SS_BLACKFRAME | WS_CHILD | WS_VISIBLE | WS_DISABLED, 4, 35, 205, 90
+ LTEXT "Text", 100, 11, 40, 190, 80, SS_NOPREFIX | WS_GROUP
+ ICON "WINEICON", -1, 185, 10, 18, 20
+}
+
+
+3 DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 275, 134
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Open"
+FONT 8, "Helv"
+{
+ LTEXT "File &Name:", 1090, 6, 6, 76, 9
+ EDITTEXT 1152, 6, 16, 90, 12, ES_AUTOHSCROLL | ES_OEMCONVERT | WS_BORDER | WS_TABSTOP
+ LISTBOX 1120, 6, 32, 90, 68, LBS_STANDARD | LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_DISABLENOSCROLL | WS_TABSTOP
+ LTEXT "&Directories:", -1, 110, 6, 92, 9
+ LTEXT "", 1088, 110, 18, 92, 9, SS_NOPREFIX | WS_GROUP
+ LISTBOX 1121, 110, 32, 92, 68, LBS_STANDARD | LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_DISABLENOSCROLL | WS_TABSTOP
+ LTEXT "List Files of &Type:", 1089, 6, 104, 90, 9
+ COMBOBOX 1136, 6, 114, 90, 36, CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | WS_BORDER | WS_VSCROLL | WS_TABSTOP
+ LTEXT "Dri&ves:", 1091, 110, 104, 92, 9
+ COMBOBOX 1137, 110, 114, 92, 68, CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED | CBS_AUTOHSCROLL | CBS_SORT | CBS_HASSTRINGS | WS_BORDER | WS_VSCROLL | WS_TABSTOP
+ DEFPUSHBUTTON "Open", 1, 208, 6, 56, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "Cancel", 2, 208, 24, 56, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "&Help", 1038, 208, 46, 56, 14, WS_GROUP | WS_TABSTOP
+ CHECKBOX "&Read Only", 1040, 208, 68, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
+}
+
+
+4 DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 275, 134
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Save As ..."
+FONT 8, "Helv"
+{
+ LTEXT "File &Name:", 1090, 6, 6, 76, 9
+ EDITTEXT 1152, 6, 16, 90, 12, ES_AUTOHSCROLL | ES_OEMCONVERT | WS_BORDER | WS_TABSTOP
+ LISTBOX 1120, 6, 32, 90, 68, LBS_STANDARD | LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_DISABLENOSCROLL | WS_TABSTOP
+ LTEXT "&Directories:", -1, 110, 6, 92, 9
+ LTEXT "", 1088, 110, 18, 92, 9, SS_NOPREFIX | WS_GROUP
+ LISTBOX 1121, 110, 32, 92, 68, LBS_STANDARD | LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_DISABLENOSCROLL | WS_TABSTOP
+ LTEXT "List Files of &Type:", 1089, 6, 104, 90, 9
+ COMBOBOX 1136, 6, 114, 90, 36, CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | WS_BORDER | WS_VSCROLL | WS_TABSTOP
+ LTEXT "Dri&ves:", 1091, 110, 104, 92, 9
+ COMBOBOX 1137, 110, 114, 92, 68, CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED | CBS_AUTOHSCROLL | CBS_SORT | CBS_HASSTRINGS | WS_BORDER | WS_VSCROLL | WS_TABSTOP
+ DEFPUSHBUTTON "Save As", 1, 208, 6, 56, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "Cancel", 2, 208, 24, 56, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "&Help", 1038, 208, 46, 56, 14, WS_GROUP | WS_TABSTOP
+ CHECKBOX "&Read Only", 1040, 208, 68, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
+}
+
+
+11 DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 275, 134
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Open"
+FONT 8, "Helv"
+{
+ LTEXT "File &Name:", 1090, 6, 6, 76, 9
+ LTEXT "", 1152, 6, 16, 90, 12
+ LISTBOX 1120, 6, 32, 90, 68, LBS_STANDARD | LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_DISABLENOSCROLL | WS_TABSTOP
+ LTEXT "&Directories:", -1, 110, 6, 92, 9
+ LTEXT "", 1088, 110, 18, 92, 9, SS_NOPREFIX | WS_GROUP
+ LISTBOX 1121, 110, 32, 92, 68, LBS_STANDARD | LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_DISABLENOSCROLL | WS_TABSTOP
+ LTEXT "List Files of &Type:", 1089, 6, 104, 90, 9
+ COMBOBOX 1136, 6, 114, 90, 36, CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | WS_BORDER | WS_VSCROLL | WS_TABSTOP
+ LTEXT "Dri&ves:", 1091, 110, 104, 92, 9
+ COMBOBOX 1137, 110, 114, 92, 68, CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED | CBS_AUTOHSCROLL | CBS_SORT | CBS_HASSTRINGS | WS_BORDER | WS_VSCROLL | WS_TABSTOP
+ DEFPUSHBUTTON "Open", 1, 208, 6, 56, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "Cancel", 2, 208, 24, 56, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "&Help", 1038, 208, 46, 56, 14, WS_GROUP | WS_TABSTOP
+ CHECKBOX "&Read Only", 1040, 208, 68, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
+}
+
+
+12 DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 275, 134
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Save As ..."
+FONT 8, "Helv"
+{
+ LTEXT "File &Name:", 1090, 6, 6, 76, 9
+ LTEXT "", 1152, 6, 16, 90, 12
+ LISTBOX 1120, 6, 32, 90, 68, LBS_STANDARD | LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_DISABLENOSCROLL | WS_TABSTOP
+ LTEXT "&Directories:", -1, 110, 6, 92, 9
+ LTEXT "", 1088, 110, 18, 92, 9, SS_NOPREFIX | WS_GROUP
+ LISTBOX 1121, 110, 32, 92, 68, LBS_STANDARD | LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_DISABLENOSCROLL | WS_TABSTOP
+ LTEXT "List Files of &Type:", 1089, 6, 104, 90, 9
+ COMBOBOX 1136, 6, 114, 90, 36, CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | WS_BORDER | WS_VSCROLL | WS_TABSTOP
+ LTEXT "Dri&ves:", 1091, 110, 104, 92, 9
+ COMBOBOX 1137, 110, 114, 92, 68, CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED | CBS_AUTOHSCROLL | CBS_SORT | CBS_HASSTRINGS | WS_BORDER | WS_VSCROLL | WS_TABSTOP
+ DEFPUSHBUTTON "Save As", 1, 208, 6, 56, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "Cancel", 2, 208, 24, 56, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "&Help", 1038, 208, 46, 56, 14, WS_GROUP | WS_TABSTOP
+ CHECKBOX "&Read Only", 1040, 208, 68, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
+}
+
+
+5 DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 264, 134
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Print"
+FONT 8, "Helv"
+{
+ LTEXT "Printer:", 1088, 6, 6, 40, 9
+ LTEXT "", 1089, 60, 6, 150, 9
+ GROUPBOX "Print Range", 1072, 6, 30, 160, 65, BS_GROUPBOX
+ RADIOBUTTON "&All", 1056, 16, 45, 60, 12
+ RADIOBUTTON "S&election", 1057, 16, 60, 60, 12
+ RADIOBUTTON "&Pages", 1058, 16, 75, 60, 12
+ DEFPUSHBUTTON "Print", 1, 206, 6, 56, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "Cancel", 2, 206, 24, 56, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "&Setup", 1024, 206, 46, 56, 14, WS_GROUP | WS_TABSTOP
+ LTEXT "&From:", 1090, 60, 80, 30, 9
+ LTEXT "&To:", 1091, 120, 80, 30, 9
+ LTEXT "Print &Quality:", 1092, 6, 100, 76, 9
+ COMBOBOX 1136, 80, 100, 92, 68, CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED | CBS_AUTOHSCROLL | CBS_SORT | CBS_HASSTRINGS | WS_BORDER | WS_VSCROLL | WS_TABSTOP
+ CHECKBOX "Print to Fi&le", 1040, 20, 100, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
+ CHECKBOX "Condensed", 1041, 160, 100, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
+}
+
+
+6 DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 264, 134
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Print Setup"
+FONT 8, "Helv"
+{
+ GROUPBOX "Printer", 1072, 6, 10, 180, 65, BS_GROUPBOX
+ RADIOBUTTON "&Default Printer", 1056, 16, 20, 80, 12
+ LTEXT "[none]", 1088, 35, 35, 120, 9
+ RADIOBUTTON "Specific &Printer", 1057, 16, 50, 80, 12
+ COMBOBOX 1136, 35, 65, 149, 68, CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED | CBS_AUTOHSCROLL | CBS_SORT | CBS_HASSTRINGS | WS_BORDER | WS_VSCROLL | WS_TABSTOP
+ DEFPUSHBUTTON "Ok", 1, 206, 6, 56, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "Cancel", 2, 206, 24, 56, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "&Setup", 1024, 206, 46, 56, 14, WS_GROUP | WS_TABSTOP
+ GROUPBOX "Orientation", 1073, 6, 85, 100, 50, BS_GROUPBOX
+ RADIOBUTTON "Po&rtrait", 1058, 50, 100, 40, 12
+ RADIOBUTTON "&Landscape", 1059, 50, 115, 40, 12
+ ICON "LANDSCAP", 1097, 10, 95, 32, 32
+ ICON "PORTRAIT", 1098, 10, 95, 32, 32
+ GROUPBOX "Paper", 1074, 120, 85, 180, 50, BS_GROUPBOX
+ LTEXT "Si&ze", 1089, 130, 95, 30, 9
+ LTEXT "&Source", 1090, 130, 110, 30, 9
+ COMBOBOX 1137, 155, 95, 92, 68, CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED | CBS_AUTOHSCROLL | CBS_SORT | CBS_HASSTRINGS | WS_BORDER | WS_VSCROLL | WS_TABSTOP
+ COMBOBOX 1138, 155, 110, 92, 68, CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED | CBS_AUTOHSCROLL | CBS_SORT | CBS_HASSTRINGS | WS_BORDER | WS_VSCROLL | WS_TABSTOP
+}
+
+
+7 DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 264, 134
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Font"
+FONT 8, "Helv"
+{
+ LTEXT "Font:", 1088, 6, 6, 40, 9
+ LTEXT "", 1089, 60, 6, 150, 9
+ DEFPUSHBUTTON "Ok", 1, 206, 6, 56, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "Cancel", 2, 206, 24, 56, 14, WS_GROUP | WS_TABSTOP
+}
+
+
+8 DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 264, 200
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Color"
+FONT 8, "Helv"
+{
+ LTEXT "&Basic Colors:", 1088, 6, 6, 40, 9
+ LTEXT "&Custom Colors:", 1089, 6, 126, 40, 9
+ LTEXT "Color|Sol&id", 1090, 100, 146, 40, 9
+ LTEXT "&Hue:", 1091, 150, 126, 40, 9
+ LTEXT "&Sat:", 1092, 150, 146, 40, 9
+ LTEXT "&Lum:", 1093, 150, 166, 40, 9
+ LTEXT "&Red:", 1094, 150, 126, 40, 9
+ LTEXT "&Green:", 1095, 150, 146, 40, 9
+ LTEXT "Bl&ue:", 1096, 150, 166, 40, 9
+ DEFPUSHBUTTON "Ok", 1, 6, 182, 56, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "&Add to Custom Colors", 1024, 120, 182, 100, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "&Delete Custom Colors", 1025, 6, 164, 56, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "Cancel", 2, 76, 182, 56, 14, WS_GROUP | WS_TABSTOP
+}
+
+
+9 DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 264, 84
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Find"
+FONT 8, "Helv"
+{
+ LTEXT "Fi&nd What:", 1088, 6, 6, 40, 9
+ LTEXT "", 1089, 60, 6, 150, 9
+ CHECKBOX "Match &Whole Word Only", 1040, 20, 30, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
+ CHECKBOX "Match &Case", 1041, 20, 50, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
+ GROUPBOX "Direction", 1072, 90, 40, 80, 40, BS_GROUPBOX
+ RADIOBUTTON "&Up", 1056, 100, 50, 50, 12
+ RADIOBUTTON "&Down", 1057, 150, 50, 50, 12
+ DEFPUSHBUTTON "&Find Next", 1, 206, 6, 56, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "Cancel", 2, 206, 24, 56, 14, WS_GROUP | WS_TABSTOP
+}
+
+
+10 DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 264, 114
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Replace"
+FONT 8, "Helv"
+{
+ LTEXT "Fi&nd What:", 1088, 6, 6, 40, 9
+ LTEXT "", 1089, 60, 6, 150, 9
+ LTEXT "Re&place With:", 1090, 6, 26, 40, 9
+ LTEXT "", 1091, 60, 26, 150, 9
+ CHECKBOX "Match &Whole Word Only", 1040, 20, 40, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
+ CHECKBOX "Match &Case", 1041, 20, 60, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
+ DEFPUSHBUTTON "&Find Next", 1, 206, 6, 56, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "&Replace", 1024, 206, 24, 56, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "Replace &All", 1025, 206, 44, 56, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "Cancel", 2, 206, 64, 56, 14, WS_GROUP | WS_TABSTOP
+}
+
+#elif #LANG(De)
 #include "sysres_De.rc"
+#elif #LANG(No)
+#include "sysres_No.rc"
+#else
+#error LANG not set to an implemented language.
 #endif
diff --git a/rc/sysres_De.rc b/rc/sysres_De.rc
index 9e54d47..03852bc 100644
--- a/rc/sysres_De.rc
+++ b/rc/sysres_De.rc
@@ -46,7 +46,7 @@
 
 SHELL_ABOUT_MSGBOX DIALOG LOADONCALL MOVEABLE DISCARDABLE 50, 44, 213, 149
 STYLE DS_LOCALEDIT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
-CAPTION "Über X"
+CAPTION ""
 FONT 10, "System"
 {
  DEFPUSHBUTTON "OK", 1, 86, 130, 40, 14
@@ -95,7 +95,7 @@
  COMBOBOX 1137, 110, 114, 92, 68, CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED | CBS_AUTOHSCROLL | CBS_SORT | CBS_HASSTRINGS | WS_BORDER | WS_VSCROLL | WS_TABSTOP
  DEFPUSHBUTTON "Speichern als", 1, 208, 6, 56, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
  PUSHBUTTON "Abbrechen", 2, 208, 24, 56, 14, WS_GROUP | WS_TABSTOP
- PUSHBUTTON "&Help", 1038, 208, 46, 56, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "&Hilfe", 1038, 208, 46, 56, 14, WS_GROUP | WS_TABSTOP
  CHECKBOX "&Schreibgeschützt", 1040, 208, 68, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
 }
 
@@ -117,7 +117,7 @@
  COMBOBOX 1137, 110, 114, 92, 68, CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED | CBS_AUTOHSCROLL | CBS_SORT | CBS_HASSTRINGS | WS_BORDER | WS_VSCROLL | WS_TABSTOP
  DEFPUSHBUTTON "Öffnen", 1, 208, 6, 56, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
  PUSHBUTTON "Abbrechen", 2, 208, 24, 56, 14, WS_GROUP | WS_TABSTOP
- PUSHBUTTON "&Help", 1038, 208, 46, 56, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "&Hilfe", 1038, 208, 46, 56, 14, WS_GROUP | WS_TABSTOP
  CHECKBOX "&Schreibgeschützt", 1040, 208, 68, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
 }
 
@@ -139,7 +139,7 @@
  COMBOBOX 1137, 110, 114, 92, 68, CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED | CBS_AUTOHSCROLL | CBS_SORT | CBS_HASSTRINGS | WS_BORDER | WS_VSCROLL | WS_TABSTOP
  DEFPUSHBUTTON "Speichern als", 1, 208, 6, 56, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
  PUSHBUTTON "Abbrechen", 2, 208, 24, 56, 14, WS_GROUP | WS_TABSTOP
- PUSHBUTTON "&Help", 1038, 208, 46, 56, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "&Hilfe", 1038, 208, 46, 56, 14, WS_GROUP | WS_TABSTOP
  CHECKBOX "&Schreibgeschützt", 1040, 208, 68, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
 }
 
@@ -186,7 +186,7 @@
  ICON "LANDSCAP", 1097, 10, 95, 32, 32
  ICON "PORTRAIT", 1098, 10, 95, 32, 32
  GROUPBOX "Paper", 1074, 120, 85, 180, 50, BS_GROUPBOX
- LTEXT "&GrÖße", 1089, 130, 95, 30, 9
+ LTEXT "&Größe", 1089, 130, 95, 30, 9
  LTEXT "P&apierquelle", 1090, 130, 110, 30, 9
  COMBOBOX 1137, 155, 95, 92, 68, CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED | CBS_AUTOHSCROLL | CBS_SORT | CBS_HASSTRINGS | WS_BORDER | WS_VSCROLL | WS_TABSTOP
  COMBOBOX 1138, 155, 110, 92, 68, CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED | CBS_AUTOHSCROLL | CBS_SORT | CBS_HASSTRINGS | WS_BORDER | WS_VSCROLL | WS_TABSTOP
diff --git a/rc/sysres_No.rc b/rc/sysres_No.rc
new file mode 100644
index 0000000..afa2b58
--- /dev/null
+++ b/rc/sysres_No.rc
@@ -0,0 +1,261 @@
+SYSMENU MENU LOADONCALL MOVEABLE DISCARDABLE
+{
+ MENUITEM "&Gjenopprett", 61728
+ MENUITEM "&Flytt", 61456
+ MENUITEM "&Størrelse", 61440
+ MENUITEM "&Minimer", 61472
+ MENUITEM "Ma&ksimer", 61488
+ MENUITEM SEPARATOR
+ MENUITEM "&Avslutt\tAlt-F4", 61536
+ MENUITEM SEPARATOR
+ MENUITEM "&Bytt til ...\tCtrl-Esc", 61744
+ MENUITEM SEPARATOR
+ MENUITEM "&Om WINE ...", 61761
+}
+
+
+2 DIALOG LOADONCALL MOVEABLE DISCARDABLE 80, 80, 150, 170
+STYLE WS_POPUP | WS_VISIBLE | WS_DLGFRAME
+{
+ PUSHBUTTON "Lisens osv.", 6, 30, 150, 40, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "Avbryt", 2, 60, 250, 40, 14, WS_GROUP | WS_TABSTOP
+ DEFPUSHBUTTON "Ok", 1, 80, 150, 40, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
+}
+
+
+STOP_MSGBOX DIALOG LOADONCALL MOVEABLE DISCARDABLE 80, 80, 150, 75
+STYLE WS_POPUP | WS_VISIBLE | WS_DLGFRAME
+{
+ ICON "SYSIDI_HAND", -1, 16, 16, 0, 0
+}
+
+
+QUESTION_MSGBOX DIALOG LOADONCALL MOVEABLE DISCARDABLE 80, 80, 150, 75
+STYLE WS_POPUP | WS_VISIBLE | WS_DLGFRAME
+{
+ ICON "SYSIDI_QUESTION", -1, 16, 16, 0, 0
+}
+
+
+EXCLAMATION_MSGBOX DIALOG LOADONCALL MOVEABLE DISCARDABLE 80, 80, 150, 75
+STYLE WS_POPUP | WS_VISIBLE | WS_DLGFRAME
+{
+ ICON "SYSIDI_EXCLAMATION", -1, 16, 16, 0, 0
+}
+
+
+SHELL_ABOUT_MSGBOX DIALOG LOADONCALL MOVEABLE DISCARDABLE 50, 44, 213, 149
+STYLE DS_LOCALEDIT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+CAPTION "Om X"
+FONT 10, "System"
+{
+ DEFPUSHBUTTON "OK", 1, 86, 130, 40, 14
+ CONTROL "", -1, "STATIC", SS_BLACKFRAME | WS_CHILD | WS_VISIBLE | WS_DISABLED, 4, 35, 205, 90
+ LTEXT "Tekst", 100, 11, 40, 190, 80, SS_NOPREFIX | WS_GROUP
+ ICON "WINEICON", -1, 185, 10, 18, 20
+}
+
+
+3 DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 275, 134
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Åpne"
+FONT 8, "Helv"
+{
+ LTEXT "&Filnavn:", 1090, 6, 6, 76, 9
+ EDITTEXT 1152, 6, 16, 90, 12, ES_AUTOHSCROLL | ES_OEMCONVERT | WS_BORDER | WS_TABSTOP
+ LISTBOX 1120, 6, 32, 90, 68, LBS_STANDARD | LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_DISABLENOSCROLL | WS_TABSTOP
+ LTEXT "&Kataloger:", -1, 110, 6, 92, 9
+ LTEXT "", 1088, 110, 18, 92, 9, SS_NOPREFIX | WS_GROUP
+ LISTBOX 1121, 110, 32, 92, 68, LBS_STANDARD | LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_DISABLENOSCROLL | WS_TABSTOP
+ LTEXT "Liste over filer av &type:", 1089, 6, 104, 90, 9
+ COMBOBOX 1136, 6, 114, 90, 36, CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | WS_BORDER | WS_VSCROLL | WS_TABSTOP
+ LTEXT "&Kataloger:", 1091, 110, 104, 92, 9
+ COMBOBOX 1137, 110, 114, 92, 68, CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED | CBS_AUTOHSCROLL | CBS_SORT | CBS_HASSTRINGS | WS_BORDER | WS_VSCROLL | WS_TABSTOP
+ DEFPUSHBUTTON "Åpne", 1, 208, 6, 56, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "Avbryt", 2, 208, 24, 56, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "&Hjelp", 1038, 208, 46, 56, 14, WS_GROUP | WS_TABSTOP
+ CHECKBOX "&Skrivebeskyttet", 1040, 208, 68, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
+}
+
+
+4 DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 275, 134
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Lagre som ..."
+FONT 8, "Helv"
+{
+ LTEXT "&Filnavn:", 1090, 6, 6, 76, 9
+ EDITTEXT 1152, 6, 16, 90, 12, ES_AUTOHSCROLL | ES_OEMCONVERT | WS_BORDER | WS_TABSTOP
+ LISTBOX 1120, 6, 32, 90, 68, LBS_STANDARD | LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_DISABLENOSCROLL | WS_TABSTOP
+ LTEXT "&Kataloger:", -1, 110, 6, 92, 9
+ LTEXT "", 1088, 110, 18, 92, 9, SS_NOPREFIX | WS_GROUP
+ LISTBOX 1121, 110, 32, 92, 68, LBS_STANDARD | LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_DISABLENOSCROLL | WS_TABSTOP
+ LTEXT "Liste over filer av &type:", 1089, 6, 104, 90, 9
+ COMBOBOX 1136, 6, 114, 90, 36, CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | WS_BORDER | WS_VSCROLL | WS_TABSTOP
+ LTEXT "&Kataloger:", 1091, 110, 104, 92, 9
+ COMBOBOX 1137, 110, 114, 92, 68, CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED | CBS_AUTOHSCROLL | CBS_SORT | CBS_HASSTRINGS | WS_BORDER | WS_VSCROLL | WS_TABSTOP
+ DEFPUSHBUTTON "Lagre som", 1, 208, 6, 56, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "Avbryt", 2, 208, 24, 56, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "&Hjelp", 1038, 208, 46, 56, 14, WS_GROUP | WS_TABSTOP
+ CHECKBOX "&Skrivebeskyttet", 1040, 208, 68, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
+}
+
+
+11 DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 275, 134
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Åpne"
+FONT 8, "Helv"
+{
+ LTEXT "&Filnavn:", 1090, 6, 6, 76, 9
+ LTEXT "", 1152, 6, 16, 90, 12
+ LISTBOX 1120, 6, 32, 90, 68, LBS_STANDARD | LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_DISABLENOSCROLL | WS_TABSTOP
+ LTEXT "&Kataloger:", -1, 110, 6, 92, 9
+ LTEXT "", 1088, 110, 18, 92, 9, SS_NOPREFIX | WS_GROUP
+ LISTBOX 1121, 110, 32, 92, 68, LBS_STANDARD | LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_DISABLENOSCROLL | WS_TABSTOP
+ LTEXT "Liste over filer av &type:", 1089, 6, 104, 90, 9
+ COMBOBOX 1136, 6, 114, 90, 36, CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | WS_BORDER | WS_VSCROLL | WS_TABSTOP
+ LTEXT "&Kataloger:", 1091, 110, 104, 92, 9
+ COMBOBOX 1137, 110, 114, 92, 68, CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED | CBS_AUTOHSCROLL | CBS_SORT | CBS_HASSTRINGS | WS_BORDER | WS_VSCROLL | WS_TABSTOP
+ DEFPUSHBUTTON "Åpne", 1, 208, 6, 56, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "Avbryt", 2, 208, 24, 56, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "&Hjelp", 1038, 208, 46, 56, 14, WS_GROUP | WS_TABSTOP
+ CHECKBOX "&Skrivebeskyttet", 1040, 208, 68, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
+}
+
+
+12 DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 275, 134
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Lagre som ..."
+FONT 8, "Helv"
+{
+ LTEXT "&Filnavn:", 1090, 6, 6, 76, 9
+ LTEXT "", 1152, 6, 16, 90, 12
+ LISTBOX 1120, 6, 32, 90, 68, LBS_STANDARD | LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_DISABLENOSCROLL | WS_TABSTOP
+ LTEXT "&Kataloger:", -1, 110, 6, 92, 9
+ LTEXT "", 1088, 110, 18, 92, 9, SS_NOPREFIX | WS_GROUP
+ LISTBOX 1121, 110, 32, 92, 68, LBS_STANDARD | LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_DISABLENOSCROLL | WS_TABSTOP
+ LTEXT "Liste over filer av &type:", 1089, 6, 104, 90, 9
+ COMBOBOX 1136, 6, 114, 90, 36, CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | WS_BORDER | WS_VSCROLL | WS_TABSTOP
+ LTEXT "&Kataloger:", 1091, 110, 104, 92, 9
+ COMBOBOX 1137, 110, 114, 92, 68, CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED | CBS_AUTOHSCROLL | CBS_SORT | CBS_HASSTRINGS | WS_BORDER | WS_VSCROLL | WS_TABSTOP
+ DEFPUSHBUTTON "Lagre som", 1, 208, 6, 56, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "Avbryt", 2, 208, 24, 56, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "&Hjelp", 1038, 208, 46, 56, 14, WS_GROUP | WS_TABSTOP
+ CHECKBOX "&Skrivebeskyttet", 1040, 208, 68, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
+}
+
+
+5 DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 264, 134
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Skriv"
+FONT 8, "Helv"
+{
+ LTEXT "Skriver:", 1088, 6, 6, 40, 9
+ LTEXT "", 1089, 60, 6, 150, 9
+ GROUPBOX "Skriv del", 1072, 6, 30, 160, 65, BS_GROUPBOX
+ RADIOBUTTON "&Alle", 1056, 16, 45, 60, 12
+ RADIOBUTTON "&Markert", 1057, 16, 60, 60, 12
+ RADIOBUTTON "&Sider", 1058, 16, 75, 60, 12
+ DEFPUSHBUTTON "Skriv", 1, 206, 6, 56, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "Avbryt", 2, 206, 24, 56, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "&Oppsett", 1024, 206, 46, 56, 14, WS_GROUP | WS_TABSTOP
+ LTEXT "&Fra:", 1090, 60, 80, 30, 9
+ LTEXT "&Til:", 1091, 120, 80, 30, 9
+ LTEXT "&Utskriftskvalitet:", 1092, 6, 100, 76, 9
+ COMBOBOX 1136, 80, 100, 92, 68, CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED | CBS_AUTOHSCROLL | CBS_SORT | CBS_HASSTRINGS | WS_BORDER | WS_VSCROLL | WS_TABSTOP
+ CHECKBOX "&Skriv til fil", 1040, 20, 100, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
+ CHECKBOX "Sammentrykket", 1041, 160, 100, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
+}
+
+
+6 DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 264, 134
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Skriveoppsett"
+FONT 8, "Helv"
+{
+ GROUPBOX "Skriver", 1072, 6, 10, 180, 65, BS_GROUPBOX
+ RADIOBUTTON "&Standardskriver", 1056, 16, 20, 80, 12
+ LTEXT "[ingen]", 1088, 35, 35, 120, 9
+ RADIOBUTTON "Spesifikk &skriver", 1057, 16, 50, 80, 12
+ COMBOBOX 1136, 35, 65, 149, 68, CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED | CBS_AUTOHSCROLL | CBS_SORT | CBS_HASSTRINGS | WS_BORDER | WS_VSCROLL | WS_TABSTOP
+ DEFPUSHBUTTON "Ok", 1, 206, 6, 56, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "Avbryt", 2, 206, 24, 56, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "&Oppsett", 1024, 206, 46, 56, 14, WS_GROUP | WS_TABSTOP
+ GROUPBOX "Orientering", 1073, 6, 85, 100, 50, BS_GROUPBOX
+ RADIOBUTTON "&Portrett", 1058, 50, 100, 40, 12
+ RADIOBUTTON "&Landskap", 1059, 50, 115, 40, 12
+ ICON "LANDSCAP", 1097, 10, 95, 32, 32
+ ICON "PORTRAIT", 1098, 10, 95, 32, 32
+ GROUPBOX "Papir", 1074, 120, 85, 180, 50, BS_GROUPBOX
+ LTEXT "&Størrelse", 1089, 130, 95, 30, 9
+ LTEXT "&Kilde", 1090, 130, 110, 30, 9
+ COMBOBOX 1137, 155, 95, 92, 68, CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED | CBS_AUTOHSCROLL | CBS_SORT | CBS_HASSTRINGS | WS_BORDER | WS_VSCROLL | WS_TABSTOP
+ COMBOBOX 1138, 155, 110, 92, 68, CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED | CBS_AUTOHSCROLL | CBS_SORT | CBS_HASSTRINGS | WS_BORDER | WS_VSCROLL | WS_TABSTOP
+}
+
+
+7 DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 264, 134
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Font"
+FONT 8, "Helv"
+{
+ LTEXT "Font:", 1088, 6, 6, 40, 9
+ LTEXT "", 1089, 60, 6, 150, 9
+ DEFPUSHBUTTON "Ok", 1, 206, 6, 56, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "Avbryt", 2, 206, 24, 56, 14, WS_GROUP | WS_TABSTOP
+}
+
+
+8 DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 264, 200
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Farge"
+FONT 8, "Helv"
+{
+ LTEXT "&Grunnleggende farger:", 1088, 6, 6, 40, 9
+ LTEXT "&Egendefinerte farger:", 1089, 6, 126, 40, 9
+ LTEXT "&Ensfarget", 1090, 100, 146, 40, 9
+ LTEXT "&Int:", 1091, 150, 126, 40, 9
+ LTEXT "&Met:", 1092, 150, 146, 40, 9
+ LTEXT "&Lum:", 1093, 150, 166, 40, 9
+ LTEXT "&Rød:", 1094, 150, 126, 40, 9
+ LTEXT "&Grønn:", 1095, 150, 146, 40, 9
+ LTEXT "&Blå:", 1096, 150, 166, 40, 9
+ DEFPUSHBUTTON "Ok", 1, 6, 182, 56, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "&Legg til egendefinert farge", 1024, 120, 182, 100, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "&Fjern egendefinerte farger", 1025, 6, 164, 56, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "Avbryt", 2, 76, 182, 56, 14, WS_GROUP | WS_TABSTOP
+}
+
+
+9 DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 264, 84
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Finn"
+FONT 8, "Helv"
+{
+ LTEXT "&Finn hva:", 1088, 6, 6, 40, 9
+ LTEXT "", 1089, 60, 6, 150, 9
+ CHECKBOX "&Kun hele ord", 1040, 20, 30, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
+ CHECKBOX "&Skill på store/små bokstaver", 1041, 20, 50, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
+ GROUPBOX "Retning", 1072, 90, 40, 80, 40, BS_GROUPBOX
+ RADIOBUTTON "&Opp", 1056, 100, 50, 50, 12
+ RADIOBUTTON "&Ned", 1057, 150, 50, 50, 12
+ DEFPUSHBUTTON "&Finn neste", 1, 206, 6, 56, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "Avbryt", 2, 206, 24, 56, 14, WS_GROUP | WS_TABSTOP
+}
+
+
+10 DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 264, 114
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Bytt"
+FONT 8, "Helv"
+{
+ LTEXT "&Finn hva:", 1088, 6, 6, 40, 9
+ LTEXT "", 1089, 60, 6, 150, 9
+ LTEXT "&Bytt med:", 1090, 6, 26, 40, 9
+ LTEXT "", 1091, 60, 26, 150, 9
+ CHECKBOX "&Kun hele ord", 1040, 20, 40, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
+ CHECKBOX "&Skill på store/små bokstaver", 1041, 20, 60, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
+ DEFPUSHBUTTON "&Finn neste", 1, 206, 6, 56, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "&Bytt", 1024, 206, 24, 56, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "&Bytt alt", 1025, 206, 44, 56, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "Avbryt", 2, 206, 64, 56, 14, WS_GROUP | WS_TABSTOP
+}
diff --git a/rc/winerc.c b/rc/winerc.c
index b20ca32..06dc7df 100644
--- a/rc/winerc.c
+++ b/rc/winerc.c
@@ -3,7 +3,6 @@
  * Copyright  Martin von Loewis, 1994
  *
  */
-
 static char Copyright[] = "Copyright Martin von Loewis, 1994";
 
 #include <stdio.h>
@@ -11,6 +10,8 @@
 #include <sys/stat.h>
 #include <sys/fcntl.h>
 #include <sys/types.h>
+#include <unistd.h>
+#include <string.h>
 #include <windows.h>
 #include <neexe.h>
 #include "rc.h"
@@ -25,7 +26,7 @@
 FILE *header,*code;
 char hname[256],sname[256];
 
-main(int argc,char *argv[])
+int main(int argc,char *argv[])
 {  
 	extern int yydebug;
 	extern char* optarg;
diff --git a/tools/build.c b/tools/build.c
index 22778b0..958995d 100644
--- a/tools/build.c
+++ b/tools/build.c
@@ -313,9 +313,7 @@
     char *token;
     ORDDEF *odp;
     ORDFUNCDEF *fdp;
-    int arg_types[16];
     int i;
-    int arg_num;
     int current_offset;
     int arg_size;
 	
@@ -469,7 +467,6 @@
     ORDRETDEF *rdp;
     char *token;
     char *endptr;
-    int value;
     
     if (ordinal >= MAX_ORDINALS)
     {
@@ -604,11 +601,11 @@
     return 0;
 }
 
-InitContext()
+void
+InitContext(void)
 {
     struct sigcontext_struct context;
     int i;
-    int j;
     
     n_context_strings = sizeof(context) / 4;
     context_strings   = (char **) malloc(n_context_strings * sizeof(char **));
@@ -707,10 +704,7 @@
     ORDRETDEF *rdp;
     FILE *fp;
     char filename[80];
-    char buffer[80];
-    char *p;
-    int i, ci;
-    int add_count;
+    int i, ci, add_count;
     
     if (argc < 2)
     {
@@ -971,5 +965,6 @@
     fprintf(fp, "};\n");
 
     fclose(fp);
+    return 0;
 }
 
diff --git a/tools/make_debug b/tools/make_debug
index e7d5460..dc1ec09 100755
--- a/tools/make_debug
+++ b/tools/make_debug
@@ -90,11 +90,14 @@
 	cat <<++EOF++ >>$DEBUG_H
 #ifdef DEBUG_RUNTIME
 #define dprintf_$x if(debug_msg_enabled[$i]) fprintf
+#define debugging_$x debug_msg_enabled[$i]
 #else
 #ifdef DEBUG_$y
 #define dprintf_$x fprintf
+#define debugging_$x 1
 #else
 #define dprintf_$x
+#define debugging_$x 0
 #endif
 #endif
 
diff --git a/windows/caret.c b/windows/caret.c
index bc09e22..5c31d19 100644
--- a/windows/caret.c
+++ b/windows/caret.c
@@ -2,14 +2,13 @@
  * Caret functions
  *
  * Copyright 1993 David Metcalfe
- */
-
+ *
 static char Copyright[] = "Copyright  David Metcalfe, 1993";
+*/
 
 #include "windows.h"
 #include "stddebug.h"
 /* #define DEBUG_CARET */
-/* #undef  DEBUG_CARET */
 #include "debug.h"
 
 
diff --git a/windows/class.c b/windows/class.c
index 6c6ae7b..7f937bb 100644
--- a/windows/class.c
+++ b/windows/class.c
@@ -2,9 +2,9 @@
  * Window classes functions
  *
  * Copyright 1993 Alexandre Julliard
- */
-
+ *
 static char Copyright[] = "Copyright  Alexandre Julliard, 1993";
+*/
 
 #include <stdlib.h>
 #include <stdio.h>
@@ -15,7 +15,6 @@
 #include "dce.h"
 #include "stddebug.h"
 /* #define DEBUG_CLASS */
-/* #undef  DEBUG_CLASS */
 #include "debug.h"
 
 
diff --git a/windows/cursor.c b/windows/cursor.c
index 4aa8a06..4d3628a 100644
--- a/windows/cursor.c
+++ b/windows/cursor.c
@@ -1,7 +1,7 @@
 /*
  *    WINE
-*/
 static char Copyright[] = "Copyright  Martin Ayotte, 1993";
+*/
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -16,21 +16,18 @@
 #include "windows.h"
 #include "win.h"
 #include "gdi.h"
+#include "library.h"
 #include "wine.h"
 #include "cursor.h"
 #include "stddebug.h"
 /* #define DEBUG_CURSOR   */
-/* #undef  DEBUG_CURSOR   */
 /* #define DEBUG_RESOURCE */
-/* #undef  DEBUG_RESOURCE */
 #include "debug.h"
 
 static int ShowCursCount = 0;
 static HCURSOR hActiveCursor;
 static HCURSOR hEmptyCursor = 0;
 RECT	ClipCursorRect;
-extern HINSTANCE hSysRes;
-extern int desktopX, desktopY;   /* misc/main.c */
 
 static struct { LPSTR name; HCURSOR cursor; } system_cursor[] =
 {
diff --git a/windows/dce.c b/windows/dce.c
index 9ddc1f4..3148ba2 100644
--- a/windows/dce.c
+++ b/windows/dce.c
@@ -2,9 +2,9 @@
  * USER DCE functions
  *
  * Copyright 1993 Alexandre Julliard
- */
-
+ *
 static char Copyright[] = "Copyright  Alexandre Julliard, 1993";
+*/
 
 #include "dce.h"
 #include "class.h"
@@ -14,14 +14,10 @@
 #include "sysmetrics.h"
 #include "stddebug.h"
 /* #define DEBUG_DC */
-/* #undef  DEBUG_DC */
 #include "debug.h"
 
-
 #define NB_DCE    5  /* Number of DCEs created at startup */
 
-extern Display * display;
-
 static HANDLE firstDCE = 0;
 static HDC defaultDCstate = 0;
 
diff --git a/windows/defdlg.c b/windows/defdlg.c
index cadc47e..4bd8592 100644
--- a/windows/defdlg.c
+++ b/windows/defdlg.c
@@ -2,22 +2,17 @@
  * Default dialog procedure
  *
  * Copyright 1993 Alexandre Julliard
- */
-
+ *
 static char Copyright[] = "Copyright  Alexandre Julliard, 1993";
+*/
 
 #include "windows.h"
 #include "dialog.h"
 #include "win.h"
 #include "stddebug.h"
-/* #define DEBUG_DIALOG /* */
-/* #undef  DEBUG_DIALOG /* */
+/* #define DEBUG_DIALOG */
 #include "debug.h"
 
-
-extern HWND DIALOG_GetFirstTabItem( HWND hwndDlg );  /* windows/dialog.c */
-
-
 /***********************************************************************
  *           DEFDLG_SetFocus
  *
diff --git a/windows/defwnd.c b/windows/defwnd.c
index a23d764..b02a371 100644
--- a/windows/defwnd.c
+++ b/windows/defwnd.c
@@ -2,9 +2,9 @@
  * Default window procedure
  *
  * Copyright 1993 Alexandre Julliard
- */
 
 static char Copyright[] = "Copyright  Alexandre Julliard, 1993";
+*/
 
 #include <stdlib.h>
 #include <stdio.h>
@@ -12,27 +12,16 @@
 #include "win.h"
 #include "class.h"
 #include "user.h"
+#include "nonclient.h"
+#include "winpos.h"
 #include "syscolor.h"
 #include "stddebug.h"
 /* #define DEBUG_MESSAGE */
-/* #undef  DEBUG_MESSAGE */
 #include "debug.h"
 
-
   /* Last COLOR id */
 #define COLOR_MAX   COLOR_BTNHIGHLIGHT
 
-extern LONG NC_HandleNCPaint( HWND hwnd, HRGN hrgn );
-extern LONG NC_HandleNCActivate( HWND hwnd, WORD wParam );
-extern LONG NC_HandleNCCalcSize( HWND hwnd, NCCALCSIZE_PARAMS *params );
-extern LONG NC_HandleNCHitTest( HWND hwnd, POINT pt );
-extern LONG NC_HandleNCLButtonDown( HWND hwnd, WORD wParam, LONG lParam );
-extern LONG NC_HandleNCLButtonDblClk( HWND hwnd, WORD wParam, LONG lParam );
-extern LONG NC_HandleSysCommand( HWND hwnd, WORD wParam, POINT pt );
-extern LONG NC_HandleSetCursor( HWND hwnd, WORD wParam, LONG lParam );
-extern LONG WINPOS_HandleWindowPosChanging( WINDOWPOS *winpos ); /* winpos.c */
-
-
 /***********************************************************************
  *           DEFWND_SetText
  *
diff --git a/windows/dialog.c b/windows/dialog.c
index c5c1096..bd05034 100644
--- a/windows/dialog.c
+++ b/windows/dialog.c
@@ -2,10 +2,9 @@
  * Dialog functions
  *
  * Copyright 1993, 1994 Alexandre Julliard
- */
-
-
+ *
 static char Copyright[] = "Copyright  Alexandre Julliard, 1993, 1994";
+*/
 
 #include <stdlib.h>
 #include <stdio.h>
@@ -18,10 +17,8 @@
 #include "heap.h"
 #include "stddebug.h"
 /* #define DEBUG_DIALOG */
-/* #undef  DEBUG_DIALOG */
 #include "debug.h"
 
-
   /* Dialog base units */
 static WORD xBaseUnit = 0, yBaseUnit = 0;
 
@@ -151,7 +148,6 @@
 /***********************************************************************
  *           DIALOG_DisplayTemplate
  */
-#ifdef DEBUG_DIALOG
 static void DIALOG_DisplayTemplate( DLGTEMPLATE * result )
 {
     dprintf_dialog(stddeb, "DIALOG %d, %d, %d, %d\n", result->header->x, result->header->y,
@@ -166,7 +162,6 @@
     if (result->header->style & DS_SETFONT)
 	dprintf_dialog(stddeb, " FONT %d,'%s'\n", result->pointSize, result->faceName );
 }
-#endif  /* DEBUG_DIALOG */
 
 
 /***********************************************************************
@@ -236,9 +231,7 @@
 
     if (!dlgTemplate) return 0;
     header = DIALOG_ParseTemplate( dlgTemplate, &template );
-#ifdef DEBUG_DIALOG
-    DIALOG_DisplayTemplate( &template );
-#endif    
+    if(debugging_dialog)DIALOG_DisplayTemplate( &template );
 
       /* Load menu */
 
diff --git a/windows/event.c b/windows/event.c
index 11467ba..71469b7 100644
--- a/windows/event.c
+++ b/windows/event.c
@@ -2,9 +2,9 @@
  * X events handling functions
  *
  * Copyright 1993 Alexandre Julliard
- */
-
+ *
 static char Copyright[] = "Copyright  Alexandre Julliard, 1993";
+*/
 
 #include <stdlib.h>
 #include <stdio.h>
@@ -12,16 +12,16 @@
 #include <X11/Xresource.h>
 #include <X11/Xutil.h>
 #include <X11/Xatom.h>
-
+#include "gdi.h"
 #include "windows.h"
 #include "win.h"
 #include "class.h"
 #include "message.h"
+#include "clipboard.h"
+#include "winpos.h"
 #include "stddebug.h"
-/* #define DEBUG_EVENT /* */
-/* #undef  DEBUG_EVENT /* */
-/* #define DEBUG_KEY   /* */
-/* #undef  DEBUG_KEY   /* */
+/* #define DEBUG_EVENT */
+/* #define DEBUG_KEY   */
 #include "debug.h"
 
 
@@ -38,10 +38,6 @@
 
 #define NB_BUTTONS      3     /* Windows can handle 3 buttons */
 
-extern int desktopX, desktopY;   /* misc/main.c */
-
-extern void WINPOS_ChangeActiveWindow( HWND hwnd, BOOL mouseMsg ); /*winpos.c*/
-
   /* X context to associate a hwnd to an X window */
 static XContext winContext = 0;
 
@@ -519,7 +515,7 @@
 static void EVENT_SelectionClear(HWND hwnd, XSelectionClearEvent *event)
 {
     if(event->selection!=XA_PRIMARY)return;
-    CLIPBOARD_ReleaseSelection(); 
+    CLIPBOARD_ReleaseSelection(hwnd); 
 }
 
 /**********************************************************************
diff --git a/windows/focus.c b/windows/focus.c
index 0418ad9..7dc8897 100644
--- a/windows/focus.c
+++ b/windows/focus.c
@@ -3,18 +3,16 @@
  *
  * Copyright 1993 David Metcalfe
  * Copyright 1994 Alexandre Julliard
- */
-
+ *
 static char Copyright[] = "Copyright  David Metcalfe, 1993";
 static char Copyright2[] = "Copyright  Alexandre Julliard, 1994";
+*/
 
 #include "win.h"
-
-extern Colormap COLOR_WinColormap;
+#include "color.h"
 
 static HWND hWndFocus = 0;
 
-
 /*****************************************************************
  *               FOCUS_SetXFocus
  *
diff --git a/windows/graphics.c b/windows/graphics.c
index c052efe..6f48148 100644
--- a/windows/graphics.c
+++ b/windows/graphics.c
@@ -14,19 +14,14 @@
 #ifndef PI
 #define PI M_PI
 #endif
-
+#include "dc.h"
 #include "gdi.h"
+#include "metafile.h"
 #include "syscolor.h"
 #include "stddebug.h"
-/* #define DEBUG_GRAPHICS /* */
-/* #undef  DEBUG_GRAPHICS /* */
+#include "color.h"
 #include "debug.h"
 
-
-extern const int DC_XROPfunction[];
-
-extern int COLOR_ToPhysical( DC *dc, COLORREF color );
-
 static __inline__ void swap_int(int *a, int *b)
 {
 	int c;
@@ -109,7 +104,7 @@
  * Helper functions for Arc(), Chord() and Pie().
  * 'lines' is the number of lines to draw: 0 for Arc, 1 for Chord, 2 for Pie.
  */
-BOOL GRAPH_DrawArc( HDC hdc, int left, int top, int right, int bottom,
+static BOOL GRAPH_DrawArc( HDC hdc, int left, int top, int right, int bottom,
 		    int xstart, int ystart, int xend, int yend, int lines )
 {
     int xcenter, ycenter, istart_angle, idiff_angle;
@@ -453,7 +448,7 @@
  */
 COLORREF SetPixel( HDC hdc, short x, short y, COLORREF color )
 {
-    int pixel;
+    Pixel pixel;
     PALETTEENTRY entry;
     
     DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
@@ -468,13 +463,17 @@
     x = dc->w.DCOrgX + XLPTODP( dc, x );
     y = dc->w.DCOrgY + YLPTODP( dc, y );
     pixel = COLOR_ToPhysical( dc, color );
-    GetPaletteEntries( dc->w.hPalette, pixel, 1, &entry );
     
     XSetForeground( display, dc->u.x.gc, pixel );
     XSetFunction( display, dc->u.x.gc, GXcopy );
     XDrawPoint( display, dc->u.x.drawable, dc->u.x.gc, x, y );
 
-    return RGB( entry.peRed, entry.peGreen, entry.peBlue );
+    if (screenDepth <= 8)
+    {
+        GetPaletteEntries( dc->w.hPalette, pixel, 1, &entry );
+        return RGB( entry.peRed, entry.peGreen, entry.peBlue );
+    }
+    else return (COLORREF)pixel;
 }
 
 
diff --git a/windows/mapping.c b/windows/mapping.c
index 07e4bbc..b3f96d1 100644
--- a/windows/mapping.c
+++ b/windows/mapping.c
@@ -9,8 +9,7 @@
 #include "gdi.h"
 #include "metafile.h"
 #include "stddebug.h"
-/* #define DEBUG_GDI /* */
-/* #undef  DEBUG_GDI /* */
+/* #define DEBUG_GDI */
 #include "debug.h"
 
 
diff --git a/windows/mdi.c b/windows/mdi.c
index 6c5927d..ed6ca96 100644
--- a/windows/mdi.c
+++ b/windows/mdi.c
@@ -11,16 +11,12 @@
 #include "win.h"
 #include "mdi.h"
 #include "user.h"
+#include "menu.h"
 #include "sysmetrics.h"
 #include "stddebug.h"
-/* #define DEBUG_MDI /* */
-/* #undef  DEBUG_MDI /* */
+/* #define DEBUG_MDI */
 #include "debug.h"
 
-
-extern WORD MENU_DrawMenuBar( HDC hDC, LPRECT lprect,
-			      HWND hwnd, BOOL suppress_draw );  /* menu.c */
-
 /**********************************************************************
  *					MDIRecreateMenuList
  */
@@ -31,14 +27,14 @@
     char buffer[128];
     int id, n, index;
 
-    dprintf_mdi(stddeb, "MDIRecreateMenuList: hWindowMenu %04.4x\n", 
+    dprintf_mdi(stddeb, "MDIRecreateMenuList: hWindowMenu %0x\n", 
 	    ci->hWindowMenu);
     
     id = ci->idFirstChild; 
     while (DeleteMenu(ci->hWindowMenu, id, MF_BYCOMMAND))
 	id++;
 
-    dprintf_mdi(stddeb, "MDIRecreateMenuList: id %04.4x, idFirstChild %04.4x\n", 
+    dprintf_mdi(stddeb, "MDIRecreateMenuList: id %04x, idFirstChild %04x\n", 
 	    id, ci->idFirstChild);
 
     if (!ci->flagMenuAltered)
@@ -54,7 +50,7 @@
 	n = sprintf(buffer, "%d ", index++);
 	GetWindowText(chi->hwnd, buffer + n, sizeof(buffer) - n - 1);
 
-	dprintf_mdi(stddeb, "MDIRecreateMenuList: id %04.4x, '%s'\n", 
+	dprintf_mdi(stddeb, "MDIRecreateMenuList: id %04x, '%s'\n", 
 		id, buffer);
 
 	AppendMenu(ci->hWindowMenu, MF_STRING, id++, buffer);
@@ -157,7 +153,7 @@
     w  = WIN_FindWndPtr(parent);
     ci = (MDICLIENTINFO *) w->wExtra;
     
-    dprintf_mdi(stddeb, "MDIBringToTop: id %04.4x, by_id %d\n", id, by_id);
+    dprintf_mdi(stddeb, "MDIBringToTop: id %04x, by_id %d\n", id, by_id);
 
     if (by_id)
 	id -= ci->idFirstChild;
@@ -179,7 +175,7 @@
 	if (!chi)
 	    return;
 
-	dprintf_mdi(stddeb, "MDIBringToTop: child %04.4x\n", chi->hwnd);
+	dprintf_mdi(stddeb, "MDIBringToTop: child %04x\n", chi->hwnd);
 	if (chi != ci->infoActiveChildren)
 	{
 	    if (ci->flagChildMaximized)
@@ -241,7 +237,7 @@
 	    SendMessage(parent, WM_CHILDACTIVATE, 0, 0);
 	}
 	
-	dprintf_mdi(stddeb, "MDIBringToTop: pos %04.4x, hwnd %04.4x\n", 
+	dprintf_mdi(stddeb, "MDIBringToTop: pos %04x, hwnd %04x\n", 
 		id, chi->hwnd);
     }
 }
@@ -318,7 +314,7 @@
     HWND          act_hwnd;
     LONG          lParam;
 
-    dprintf_mdi(stddeb, "MDIChildActivate: top %04.4x\n", w->hwndChild);
+    dprintf_mdi(stddeb, "MDIChildActivate: top %04x\n", w->hwndChild);
 
     chi = ci->infoActiveChildren;
     if (chi)
@@ -327,7 +323,7 @@
 	act_hwnd   = chi->hwnd;
 	lParam     = ((LONG) deact_hwnd << 16) | act_hwnd;
 
-	dprintf_mdi(stddeb, "MDIChildActivate: deact %04.4x, act %04.4x\n",
+	dprintf_mdi(stddeb, "MDIChildActivate: deact %04x, act %04x\n",
 	       deact_hwnd, act_hwnd);
 
 	ci->hwndActiveChild = act_hwnd;
@@ -377,12 +373,12 @@
     for (chi = ci->infoActiveChildren; chi->next != NULL; chi = chi->next)
 	;
     
-    dprintf_mdi(stddeb, "MDICascade: last child is %04.4x\n", chi->hwnd);
+    dprintf_mdi(stddeb, "MDICascade: last child is %04x\n", chi->hwnd);
     x = 0;
     y = 0;
     for ( ; chi != NULL; chi = chi->prev)
     {
-	dprintf_mdi(stddeb, "MDICascade: move %04.4x to (%d,%d) size [%d,%d]\n", 
+	dprintf_mdi(stddeb, "MDICascade: move %04x to (%d,%d) size [%d,%d]\n", 
 		chi->hwnd, x, y, xsize, ysize);
 	SetWindowPos(chi->hwnd, 0, x, y, xsize, ysize, 
 		     SWP_DRAWFRAME | SWP_NOACTIVATE | SWP_NOZORDER);
diff --git a/windows/message.c b/windows/message.c
index 304a8f9..b4d6458 100644
--- a/windows/message.c
+++ b/windows/message.c
@@ -17,12 +17,15 @@
 
 #include "message.h"
 #include "win.h"
+#include "gdi.h"
 #include "wineopts.h"
 #include "sysmetrics.h"
 #include "hook.h"
+#include "win.h"
+#include "event.h"
+#include "winpos.h"
 #include "stddebug.h"
 /* #define DEBUG_MSG */
-/* #undef  DEBUG_MSG */
 #include "debug.h"
 
 
@@ -33,12 +36,6 @@
 
 extern BOOL TIMER_CheckTimer( LONG *next, MSG *msg,
 			      HWND hwnd, BOOL remove );  /* timer.c */
-extern void EVENT_ProcessEvent( XEvent *event );  /* event.c */
-extern void WINPOS_ChangeActiveWindow( HWND hwnd, BOOL mouseMsg ); /*winpos.c*/
-extern void WIN_SendParentNotify( HWND hwnd, WORD event,
-				  LONG lParam );  /* win.c */
-
-extern Display * display;
 
   /* System message queue (for hardware events) */
 static HANDLE hmemSysMsgQueue = 0;
diff --git a/windows/nonclient.c b/windows/nonclient.c
index 929c1f1..f91eb12 100644
--- a/windows/nonclient.c
+++ b/windows/nonclient.c
@@ -2,9 +2,9 @@
  * Non-client area window functions
  *
  * Copyright 1994 Alexandre Julliard
- */
-
+ *
 static char Copyright[] = "Copyright  Alexandre Julliard, 1994";
+*/
 
 #include "win.h"
 #include "class.h"
@@ -12,10 +12,16 @@
 #include "scroll.h"
 #include "sysmetrics.h"
 #include "user.h"
+#include "dialog.h"
 #include "syscolor.h"
+#include "library.h"
+#include "menu.h"
+#include "winpos.h"
+#include "scroll.h"
+#include "nonclient.h"
+#include "graphics.h"
 #include "stddebug.h"
 /* #define DEBUG_NONCLIENT */
-/* #undef  DEBUG_NONCLIENT */
 #include "debug.h"
 
 
@@ -28,24 +34,8 @@
 static HBITMAP hbitmapRestoreD = 0;
 
 #define SC_ABOUTWINE    	(SC_SCREENSAVE+1)
-extern HINSTANCE hSysRes;
 extern BOOL AboutWine_Proc( HWND hDlg, WORD msg, WORD wParam, LONG lParam );
 
-extern void WINPOS_GetMinMaxInfo( HWND hwnd, POINT *maxSize, POINT *maxPos,
-			    POINT *minTrack, POINT *maxTrack );  /* winpos.c */
-extern BOOL GRAPH_DrawBitmap( HDC hdc, HBITMAP hbitmap, int xdest, int ydest,
-			      int xsrc, int ysrc, int width, int height,
-			      int rop );                     /* graphics.c */
-extern WORD MENU_GetMenuBarHeight( HWND hwnd, WORD menubarWidth,
-				   int orgX, int orgY );         /* menu.c */
-extern void MENU_TrackMouseMenuBar( HWND hwnd, POINT pt );       /* menu.c */
-extern void MENU_TrackKbdMenuBar( HWND hwnd, WORD wParam );      /* menu.c */
-extern WORD MENU_DrawMenuBar( HDC hDC, LPRECT lprect,
-			      HWND hwnd, BOOL suppress_draw );   /* menu.c */
-extern void SCROLL_HandleScrollEvent( HWND hwnd, int nBar,
-                                      WORD msg, POINT pt);       /* scroll.c */
-
-
   /* Some useful macros */
 #define HAS_DLGFRAME(style,exStyle) \
     (((style) & WS_DLGFRAME) && \
diff --git a/windows/scroll.c b/windows/scroll.c
index 39fead6..2710c30 100644
--- a/windows/scroll.c
+++ b/windows/scroll.c
@@ -10,9 +10,9 @@
 #include <stdlib.h>
 #include "windows.h"
 #include "gdi.h"
+#include "scroll.h"
 #include "stddebug.h"
-/* #define DEBUG_SCROLL /* */
-/* #undef  DEBUG_SCROLL /* */
+/* #define DEBUG_SCROLL */
 #include "debug.h"
 
 
diff --git a/windows/syscolor.c b/windows/syscolor.c
index de92afc..bcf5397 100644
--- a/windows/syscolor.c
+++ b/windows/syscolor.c
@@ -14,11 +14,9 @@
 #include "windows.h"
 #include "syscolor.h"
 #include "stddebug.h"
-/* #define DEBUG_SYSCOLOR /* */
-/* #undef  DEBUG_SYSCOLOR /* */
+/* #define DEBUG_SYSCOLOR */
 #include "debug.h"
 
-
 struct SysColorObjects sysColorObjects = { 0, };
 
 static char * DefSysColors[] =
@@ -134,7 +132,7 @@
 /*************************************************************************
  *             SYSCOLOR_Init
  */
-void SYSCOLOR_Init()
+void SYSCOLOR_Init(void)
 {
     int i, r, g, b;
     char **p;
@@ -155,7 +153,7 @@
 
 COLORREF GetSysColor(short nIndex)
 {
-    dprintf_syscolor(stddeb,"System Color %d = %6x\n", 
+    dprintf_syscolor(stddeb,"System Color %d = %8lx\n", 
 		    nIndex, SysColors[nIndex]);
     return SysColors[nIndex];
 }
diff --git a/windows/sysmetrics.c b/windows/sysmetrics.c
index 71413c7..3aa9bb3 100644
--- a/windows/sysmetrics.c
+++ b/windows/sysmetrics.c
@@ -2,26 +2,22 @@
  * System metrics functions
  *
  * Copyright 1994 Alexandre Julliard
- */
-
+ *
 static char Copyright[] = "Copyright  Alexandre Julliard, 1994";
+*/
 
 #include <X11/Xlib.h>
-
+#include "gdi.h"
 #include "sysmetrics.h"
 
-
 short sysMetrics[SM_CMETRICS];
 
-extern Display * display;
-extern int screenWidth, screenHeight;
-
 /***********************************************************************
  *           SYSMETRICS_Init
  *
  * Initialisation of the system metrics array.
  */
-void SYSMETRICS_Init()
+void SYSMETRICS_Init(void)
 {
     sysMetrics[SM_CXSCREEN] = screenWidth;
     sysMetrics[SM_CYSCREEN] = screenHeight;
@@ -77,6 +73,3 @@
     if (index >= SM_CMETRICS) return 0;
     else return sysMetrics[index];    
 }
-
-
-
diff --git a/windows/timer.c b/windows/timer.c
index b95b99b..9c54240 100644
--- a/windows/timer.c
+++ b/windows/timer.c
@@ -9,8 +9,7 @@
 #include "windows.h"
 #include "message.h"
 #include "stddebug.h"
-/* #define DEBUG_TIMER /* */
-/* #undef  DEBUG_TIMER /* */
+/* #define DEBUG_TIMER */
 #include "debug.h"
 
 
diff --git a/windows/utility.c b/windows/utility.c
index 5f9fcad..75b779d 100644
--- a/windows/utility.c
+++ b/windows/utility.c
@@ -14,8 +14,7 @@
 #include <stdlib.h>
 #include "windows.h"
 #include "stddebug.h"
-/* #define DEBUG_UTILITY /* */
-/* #undef  DEBUG_UTILITY /* */
+/* #define DEBUG_UTILITY */
 #include "debug.h"
 
 
diff --git a/windows/win.c b/windows/win.c
index 142e279..28131ec 100644
--- a/windows/win.c
+++ b/windows/win.c
@@ -16,29 +16,18 @@
 #include "user.h"
 #include "dce.h"
 #include "sysmetrics.h"
+#include "menu.h"
 #include "icon.h"
 #include "cursor.h"
+#include "event.h"
+#include "winpos.h"
+#include "color.h"
 #include "stddebug.h"
 #include "callback.h"
-/* #define DEBUG_WIN  /* */ 
-/* #undef  DEBUG_WIN  /* */
-/* #define DEBUG_MENU /* */
-/* #undef  DEBUG_MENU /* */
+/* #define DEBUG_WIN  */ 
+/* #define DEBUG_MENU */
 #include "debug.h"
 
-extern Colormap COLOR_WinColormap;
-
-extern void EVENT_RegisterWindow( Window w, HWND hwnd );  /* event.c */
-extern void WINPOS_ChangeActiveWindow( HWND hwnd, BOOL mouseMsg ); /*winpos.c*/
-extern LONG WINPOS_SendNCCalcSize( HWND hwnd, BOOL calcValidRect,
-				   RECT *newWindowRect, RECT *oldWindowRect,
-				   RECT *oldClientRect, WINDOWPOS *winpos,
-				   RECT *newClientRect );  /* winpos.c */
-
-extern HMENU CopySysMenu(); /* menu.c */
-extern LONG MDIClientWndProc(HWND hwnd, WORD message, 
-			     WORD wParam, LONG lParam); /* mdi.c */
-
 static HWND hwndDesktop = 0;
 static HWND hWndSysModal = 0;
 
@@ -981,8 +970,6 @@
     dprintf_enum(stddeb,"EnumWindows\n");
 
     while (hwnd) {
-      char *ptr;
-
         if ( !(wndPtr=WIN_FindWndPtr(hwnd)) ) {
               return 0;
       }
@@ -1015,11 +1002,8 @@
 static BOOL WIN_EnumChildWin(HWND hwnd, FARPROC wndenumprc, LPARAM lParam)
 {
     WND *wndPtr;
-    int result;
-
 
     while (hwnd) {
-      char *ptr;
       if ( !(wndPtr=WIN_FindWndPtr(hwnd)) ) {
             return 0;
         }
diff --git a/windows/winpos.c b/windows/winpos.c
index 80d3bad..8a1ebd1 100644
--- a/windows/winpos.c
+++ b/windows/winpos.c
@@ -687,32 +687,42 @@
 
     if (!(flags & SWP_NOSIZE))
     {
-	newWindowRect.right  = newWindowRect.left + winpos->cx;
-	newWindowRect.bottom = newWindowRect.top + winpos->cy;
-	winChanges.width     = winpos->cx;
-	winChanges.height    = winpos->cy;
-	changeMask |= CWWidth | CWHeight;
+        if ((newWindowRect.right != newWindowRect.left + winpos->cx) ||
+            (newWindowRect.bottom != newWindowRect.top + winpos->cy))
+        {
+            newWindowRect.right  = newWindowRect.left + winpos->cx;
+            newWindowRect.bottom = newWindowRect.top + winpos->cy;
+            winChanges.width     = winpos->cx;
+            winChanges.height    = winpos->cy;
+            changeMask |= CWWidth | CWHeight;
+        }
+        else flags = winpos->flags |= SWP_NOSIZE;
     }
     if (!(flags & SWP_NOMOVE))
     {
-	newWindowRect.left    = winpos->x;
-	newWindowRect.top     = winpos->y;
-	newWindowRect.right  += winpos->x - wndPtr->rectWindow.left;
-	newWindowRect.bottom += winpos->y - wndPtr->rectWindow.top;
-	if (wndPtr->dwStyle & WS_CHILD)
-	{
-	    WND *parentPtr = WIN_FindWndPtr(wndPtr->hwndParent);
-	    winChanges.x = winpos->x + parentPtr->rectClient.left 
-		           - parentPtr->rectWindow.left;
-	    winChanges.y = winpos->y + parentPtr->rectClient.top
-		           - parentPtr->rectWindow.top;
-	}
-	else
-	{
-	    winChanges.x = winpos->x;
-	    winChanges.y = winpos->y;
-	}
-	changeMask |= CWX | CWY;
+        if ((newWindowRect.left != winpos->x) ||
+            (newWindowRect.top != winpos->y))
+        {
+            newWindowRect.left    = winpos->x;
+            newWindowRect.top     = winpos->y;
+            newWindowRect.right  += winpos->x - wndPtr->rectWindow.left;
+            newWindowRect.bottom += winpos->y - wndPtr->rectWindow.top;
+            if (wndPtr->dwStyle & WS_CHILD)
+            {
+                WND *parentPtr = WIN_FindWndPtr(wndPtr->hwndParent);
+                winChanges.x = winpos->x + parentPtr->rectClient.left 
+                                - parentPtr->rectWindow.left;
+                winChanges.y = winpos->y + parentPtr->rectClient.top
+                                - parentPtr->rectWindow.top;
+            }
+            else
+            {
+                winChanges.x = winpos->x;
+                winChanges.y = winpos->y;
+            }
+            changeMask |= CWX | CWY;
+        }
+        else flags = winpos->flags |= SWP_NOMOVE;
     }
 
       /* Reposition window in Z order */