From 456d6fac30509ba7a286d1c409e826fe1393608c Mon Sep 17 00:00:00 2001
From: sparky4 <sparky4@cock.li>
Date: Fri, 26 Jun 2015 19:03:14 -0500
Subject: [PATCH] /dev/zero done it again!! ^^ modified:   16/cawat/16_mm.c

---
 16/cawat/16_mm.c | 80 ++++++++++++++++++++++++------------------------
 1 file changed, 40 insertions(+), 40 deletions(-)

diff --git a/16/cawat/16_mm.c b/16/cawat/16_mm.c
index 2da0d658..8c28277a 100644
--- a/16/cawat/16_mm.c
+++ b/16/cawat/16_mm.c
@@ -42,8 +42,8 @@ EMS / XMS unmanaged routines
 =============================================================================
 */
 
-//#include "LIB_HEAD.H"
-#include "16_mm.h"
+//#include "LIB_HEAD.H"
+#include "16_mm.h"
 
 /*
 =============================================================================
@@ -97,7 +97,7 @@ void		(* aftersort) (void);
 */
 
 boolean		mmstarted;
-
+
 void huge	*hugeheap;
 void far	*farheap;
 void		*nearheap;
@@ -125,12 +125,12 @@ unsigned	numUMBs,UMBbase[MAXUMBS];
 */
 
 boolean MML_CheckForEMS (void)
-{
-	boolean emmcfems;
-	char	emmname[] = "EMMXXXX0";
-
-	__asm {
-		mov	dx,OFF=emmname
+{
+	boolean emmcfems;
+	char	emmname[] = "EMMXXXX0";
+//		mov	dx,OFFSET emmname
+	__asm {
+		LEA	DX, emmname	//fix by andrius4669
 		mov	ax,0x3d00
 		int	0x21		// try to open EMMXXXX0 device
 		jc	error
@@ -153,19 +153,19 @@ boolean MML_CheckForEMS (void)
 
 		mov	ah,0x3e
 		int	0x21		// close handle
-		jc	error
+		jc	error
 		//
 		// EMS is good
-		//
-		mov     emmcfems,1
-		jmp End
-		error:
+		//
+		mov     emmcfems,1
+		jmp End
+		error:
 		//
 		// EMS is bad
 		//
-		mov     emmcfems,0
-		End:
-	}
+		mov     emmcfems,0
+		End:
+	}
 	return(emmcfems);
 }
 
@@ -181,12 +181,12 @@ boolean MML_CheckForEMS (void)
 void MML_SetupEMS (void)
 {
 	char	str[80],str2[10];
-	unsigned	err;
+	unsigned	err;
 	struct REGS CPURegs;
 
 	totalEMSpages = freeEMSpages = EMSpageframe = EMSpagesmapped = 0;
 
-	__asm
+	__asm
 		{
 		mov	ah,EMS_STATUS
 		int	EMS_INT						// make sure EMS hardware is present
@@ -217,24 +217,24 @@ void MML_SetupEMS (void)
 
 		cmp	bx,4
 		jle	getpages					// there is only 1,2,3,or 4 pages
-		mov	bx,4						// we can't use more than 4 pages
-
-getpages:
+		mov	bx,4						// we can't use more than 4 pages
+
+getpages:
 		mov	[EMSpagesmapped],bx
 		mov	ah,EMS_ALLOCPAGES			// allocate up to 64k of EMS
 		int	EMS_INT
 		or	ah,ah
 		jnz	error
-		mov	[EMShandle],dx
-		jmp End
+		mov	[EMShandle],dx
+		jmp End
 error:
 //		err = CPURegs.h.ah;
 //		strcpy (str,"MML_SetupEMS: EMS error 0x");
 //		itoa(err,str2,16);
 //		strcpy (str,str2);
-//		printf("%s\n",str);
-		jmp End
-noEMS:
+//		printf("%s\n",str);
+		jmp End
+noEMS:
 End:
 	}
 }
@@ -253,14 +253,14 @@ void MML_ShutdownEMS (void)
 	if (!EMShandle)
 		return;
 
-	__asm
+	__asm
 	{
 		mov	ah,EMS_FREEPAGES
 		mov	dx,[EMShandle]
 		int	EMS_INT
 		or	ah,ah
-		jz	ok
-		printf("MML_ShutdownEMS: Error freeing EMS!");
+		jz	ok
+		printf("MML_ShutdownEMS: Error freeing EMS!");
 		ok:
 	}
 }
@@ -285,7 +285,7 @@ void MM_MapEMS (void)
 
 	for (i=0;i<EMSpagesmapped;i++)
 	{
-		__asm
+		__asm
 		{
 			mov	ah,EMS_MAPPAGE
 			mov	bx,[i]			// logical page
@@ -293,14 +293,14 @@ void MM_MapEMS (void)
 			mov	dx,[EMShandle]	// handle
 			int	EMS_INT
 			or	ah,ah
-			jnz	error
-			jmp End
+			jnz	error
+			jmp End
 			error:
 			error = _AH;
 			strcpy (str,"MM_MapEMS: EMS error 0x");
 			itoa(error,str2,16);
 			strcpy (str,str2);
-			printf("%s\n",str);
+			printf("%s\n",str);
 			End:
 		}
 	}
@@ -323,12 +323,12 @@ boolean MML_CheckForXMS (void)
 {
 	numUMBs = 0;
 
-	__asm
+	__asm
 	{
 		mov	ax,0x4300
 		int	0x2f				// query status of installed diver
 		cmp	al,0x80
-		je	good
+		je	good
 		good:
 	}
 /*	return false;
@@ -351,7 +351,7 @@ void MML_SetupXMS (void)
 {
 	unsigned	base,size;
 
-	__asm
+	__asm
 	{
 		mov	ax,0x4310
 		int	0x2f
@@ -375,7 +375,7 @@ getmemory:
 
 gotone:
 	mov	[base],bx
-	mov	[size],dx
+	mov	[size],dx
 	done:
 	}
 	MML_UseSpace (base,size);
@@ -403,11 +403,11 @@ void MML_ShutdownXMS (void)
 	for (i=0;i<numUMBs;i++)
 	{
 		base = UMBbase[i];
-		__asm
+		__asm
 		{
 			mov	ah,XMS_FREEUMB
 			mov	dx,[base]
-			call	[DWORD PTR XMSaddr]
+			call	[DWORD PTR XMSaddr]
 		}
 	}
 }
-- 
2.39.5