From: sparky4 <sparky4@cock.li>
Date: Wed, 22 Feb 2017 21:56:11 +0000 (-0600)
Subject: ==== bcexmm.exe works again! yay! ==== wwww
X-Git-Url: http://4ch.mooo.com/gitweb/?a=commitdiff_plain;h=504952db812eb43b41636db1da125be946cfd35f;p=16.git

==== bcexmm.exe works again! yay! ==== wwww
---

diff --git a/BCEXMM.L16 b/BCEXMM.L16
new file mode 100755
index 00000000..41d44021
--- /dev/null
+++ b/BCEXMM.L16
@@ -0,0 +1,68 @@
+-------------------------------------------------------------------------------
+&main()=	1228:0FFA
+buffer:
+	0004:0000	&0AC8:2EB2
+	     0000	&     2eb2
+-------------------------------------------------------------------------------
+
+
+press any key to continue!
+======================================load======================================
+===============================================================================
+		CA_LoadFile
+===============================================================================
+	ptr=0AC8:2EB2
+	*ptr=110D:0000
+	&ptr=1228:0FCE
+MM_GetPtr
+	baseptr=0AC8:2EB2	useptr=0AC8:2EB2
+	*baseptr=1C52:0000	*useptr=1C52:0000
+	&baseptr=1228:0FB2	&useptr=0AC8:3797
+---------------------------------------
+	ptr=0AC8:2EB2
+	*ptr=110D:7900
+	&ptr=1228:0FCE
+-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
+&main()=	1228:0FFA
+buffer:
+	0001:7900	&0AC8:2EB2
+	     7900	&     2eb2
+-------------------------------------------------------------------------------
+
+yay!
+press any key to continue!
+========================================
+		DebugMemory_
+========================================
+Memory Usage
+------------
+Total:		558k
+Free:		150k
+With purge:	550k
+------------
+MMDUMP.16 created.
+========================================
+		MM_Report_
+========================================
+	ÉLIMEMS	1
+	ÇÄEMM v4.0 available
+	ÇÄtotalEMSpages:	4032	freeEMSpages:	3939
+	ÇÄEMSPageFrame:	e000
+	ÓÄEMSmem:	64536576
+	ÉXMS	1
+	ÇÄXMS v3.0 available
+	ÇÄXMSDriver:	C83F:0010
+	ÇÄXMSHandle:	0800
+	ÓÄXMSmem:	2097152
+	ÉConv.	1
+	ÓÄTotal:	558k	Free:	150k	With purge:550k
+nearheap:	50852		farheap:	521204
+========================================
+near=	1373:0004 far=	1FFF:0004
+&near=	0AC8:30E5 &far=	0AC8:30E1
+bigb=	0001:0000 &bigb=0AC8:2EB2 
+========================================
+Project 16 bcexmm.exe. This is just a test file!
+version Feb 22 2017 14:48:22
+debugmm: 1	
diff --git a/DEBUG.16B b/DEBUG.16B
new file mode 100755
index 00000000..629832b7
--- /dev/null
+++ b/DEBUG.16B
@@ -0,0 +1,210 @@
+Seg:0	Size:4864	Owner:0x0
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++0
+Seg:1300	Size:256	Owner:0x2e21
+++++
+Seg:1400	Size:256	Owner:0x2c24
+++++
+Seg:1500	Size:256	Owner:0x2c26
+++++
+Seg:1600	Size:256	Owner:0x2c28
+++++
+Seg:1700	Size:256	Owner:0x2c2a
+++++
+Seg:1800	Size:256	Owner:0x2c2c
+++++
+Seg:1900	Size:256	Owner:0x2c2e
+++++
+Seg:1a00	Size:256	Owner:0x2c30
+++++
+Seg:1b00	Size:256	Owner:0x2c32
+++++
+Seg:1c00	Size:256	Owner:0x2c34
+++++
+Seg:1d00	Size:256	Owner:0x2c36
+++++
+Seg:1e00	Size:256	Owner:0x2c38
+++++
+Seg:1fde	Size:34	Owner:0x0
+++
+Seg:2000	Size:256	Owner:0x2c3a
+++++
+Seg:2100	Size:256	Owner:0x2c3c
+++++
+Seg:2200	Size:256	Owner:0x2c3e
+++++
+Seg:2300	Size:256	Owner:0x2c40
+++++
+Seg:2400	Size:256	Owner:0x2c42
+++++
+Seg:2500	Size:256	Owner:0x2c44
+++++
+Seg:2600	Size:256	Owner:0x2c46
+++++
+Seg:2700	Size:256	Owner:0x2c48
+++++
+Seg:2800	Size:256	Owner:0x2c4a
+++++
+Seg:2900	Size:256	Owner:0x2c4c
+++++
+Seg:2a00	Size:256	Owner:0x2c4e
+++++
+Seg:2b00	Size:256	Owner:0x2c50
+++++
+Seg:2c00	Size:256	Owner:0x2c52
+++++
+Seg:2d00	Size:256	Owner:0x2c54
+++++
+Seg:2e00	Size:256	Owner:0x2c56
+++++
+Seg:2f00	Size:256	Owner:0x2c58
+++++
+Seg:3000	Size:256	Owner:0x2c5a
+++++
+Seg:3100	Size:256	Owner:0x2c5c
+++++
+Seg:3200	Size:256	Owner:0x2c5e
+++++
+Seg:3300	Size:256	Owner:0x2c60
+++++
+Seg:3400	Size:256	Owner:0x2c62
+++++
+Seg:3500	Size:256	Owner:0x2c64
+++++
+Seg:3600	Size:256	Owner:0x2c66
+++++
+Seg:3700	Size:256	Owner:0x2c68
+++++
+Seg:3800	Size:256	Owner:0x2c6a
+++++
+Seg:3900	Size:256	Owner:0x2c6c
+++++
+Seg:3a00	Size:256	Owner:0x2c6e
+++++
+Seg:3b00	Size:256	Owner:0x2c70
+++++
+Seg:3c00	Size:256	Owner:0x2c72
+++++
+Seg:3d00	Size:256	Owner:0x2c74
+++++
+Seg:3e00	Size:256	Owner:0x2c76
+++++
+Seg:3f00	Size:256	Owner:0x2c78
+++++
+Seg:4000	Size:256	Owner:0x2c7a
+++++
+Seg:4100	Size:256	Owner:0x2c7c
+++++
+Seg:4200	Size:256	Owner:0x2c7e
+++++
+Seg:4300	Size:256	Owner:0x2c80
+++++
+Seg:4400	Size:256	Owner:0x2c82
+++++
+Seg:4500	Size:256	Owner:0x2c84
+++++
+Seg:4600	Size:256	Owner:0x2c86
+++++
+Seg:4700	Size:256	Owner:0x2c88
+++++
+Seg:4800	Size:256	Owner:0x2c8a
+++++
+Seg:4900	Size:256	Owner:0x2c8c
+++++
+Seg:4a00	Size:256	Owner:0x2c8e
+++++
+Seg:4b00	Size:256	Owner:0x2c90
+++++
+Seg:4c00	Size:256	Owner:0x2c92
+++++
+Seg:4d00	Size:256	Owner:0x2c94
+++++
+Seg:4e00	Size:256	Owner:0x2c96
+++++
+Seg:4f00	Size:256	Owner:0x2c98
+++++
+Seg:5000	Size:256	Owner:0x2c9a
+++++
+Seg:5100	Size:256	Owner:0x2c9c
+++++
+Seg:5200	Size:256	Owner:0x2c9e
+++++
+Seg:5300	Size:256	Owner:0x2ca0
+++++
+Seg:5400	Size:256	Owner:0x2ca2
+++++
+Seg:5500	Size:256	Owner:0x2ca4
+++++
+Seg:5600	Size:256	Owner:0x2ca6
+++++
+Seg:5700	Size:256	Owner:0x2ca8
+++++
+Seg:5800	Size:256	Owner:0x2caa
+++++
+Seg:5900	Size:256	Owner:0x2cac
+++++
+Seg:5a00	Size:256	Owner:0x2cae
+++++
+Seg:5b00	Size:256	Owner:0x2cb0
+++++
+Seg:5c00	Size:256	Owner:0x2cb2
+++++
+Seg:5d00	Size:256	Owner:0x2cb4
+++++
+Seg:5e00	Size:256	Owner:0x2cb6
+++++
+Seg:5f00	Size:256	Owner:0x2cb8
+++++
+Seg:6000	Size:256	Owner:0x2cba
+++++
+Seg:6100	Size:256	Owner:0x2cbc
+++++
+Seg:6200	Size:256	Owner:0x2cbe
+++++
+Seg:6300	Size:256	Owner:0x2cc0
+++++
+Seg:6400	Size:256	Owner:0x2cc2
+++++
+Seg:6500	Size:256	Owner:0x2cc4
+++++
+Seg:6600	Size:256	Owner:0x2cc6
+++++
+Seg:6700	Size:256	Owner:0x2cc8
+++++
+Seg:6800	Size:256	Owner:0x2cca
+++++
+Seg:6900	Size:256	Owner:0x2ccc
+++++
+Seg:6a00	Size:256	Owner:0x2cce
+++++
+Seg:6b00	Size:256	Owner:0x2cd0
+++++
+Seg:6c00	Size:256	Owner:0x2cd2
+++++
+Seg:6d00	Size:256	Owner:0x2cd4
+++++
+Seg:6e00	Size:256	Owner:0x2cd6
+++++
+Seg:6f00	Size:256	Owner:0x2cd8
+++++
+Seg:7000	Size:256	Owner:0x2cda
+++++
+Seg:7100	Size:256	Owner:0x2cdc
+++++
+Seg:7200	Size:256	Owner:0x2cde
+++++
+Seg:7300	Size:256	Owner:0x2ce0
+++++
+Seg:7400	Size:256	Owner:0x2ce2
+++++
+Seg:7500	Size:256	Owner:0x2ce4
+++++
+Seg:7600	Size:256	Owner:0x2ce6
+++++
+Seg:7700	Size:256	Owner:0x2ce8
+++++
+Seg:7800	Size:256	Owner:0x2cea
+++++
+Seg:7900	Size:273	Owner:0x2bfa
+++++
+Seg:9f3f	Size:24768	Owner:0x0
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
\ No newline at end of file
diff --git a/DEBUG.16W b/DEBUG.16W
new file mode 100755
index 00000000..f401ae96
--- /dev/null
+++ b/DEBUG.16W
@@ -0,0 +1,210 @@
+Seg:0	Size:8973	Owner:0x0
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++0000
+Seg:23fe	Size:39	Owner:0x0
++
+Seg:2425	Size:256	Owner:0x1dc4
+++++
+Seg:2525	Size:256	Owner:0x1bb6
++++++
+Seg:2625	Size:256	Owner:0x1bb8
+++++
+Seg:2725	Size:256	Owner:0x1bba
+++++
+Seg:2825	Size:256	Owner:0x1bbc
+++++
+Seg:2925	Size:256	Owner:0x1bbe
+++++
+Seg:2a25	Size:256	Owner:0x1bc0
++++++
+Seg:2b25	Size:256	Owner:0x1bc2
+++++
+Seg:2c25	Size:256	Owner:0x1bc4
+++++
+Seg:2d25	Size:256	Owner:0x1bc6
+++++
+Seg:2e25	Size:256	Owner:0x1bc8
+++++
+Seg:2f25	Size:256	Owner:0x1bca
++++++
+Seg:3025	Size:256	Owner:0x1bcc
+++++
+Seg:3125	Size:256	Owner:0x1bce
+++++
+Seg:3225	Size:256	Owner:0x1bd0
+++++
+Seg:3325	Size:256	Owner:0x1bd2
+++++
+Seg:3425	Size:256	Owner:0x1bd4
++++++
+Seg:3525	Size:256	Owner:0x1bd6
+++++
+Seg:3625	Size:256	Owner:0x1bd8
+++++
+Seg:3725	Size:256	Owner:0x1bda
+++++
+Seg:3825	Size:256	Owner:0x1bdc
+++++
+Seg:3925	Size:256	Owner:0x1bde
++++++
+Seg:3a25	Size:256	Owner:0x1be0
+++++
+Seg:3b25	Size:256	Owner:0x1be2
+++++
+Seg:3c25	Size:256	Owner:0x1be4
+++++
+Seg:3d25	Size:256	Owner:0x1be6
+++++
+Seg:3e25	Size:256	Owner:0x1be8
++++++
+Seg:3f25	Size:256	Owner:0x1bea
+++++
+Seg:4025	Size:256	Owner:0x1bec
+++++
+Seg:4125	Size:256	Owner:0x1bee
+++++
+Seg:4225	Size:256	Owner:0x1bf0
+++++
+Seg:4325	Size:256	Owner:0x1bf2
++++++
+Seg:4425	Size:256	Owner:0x1bf4
+++++
+Seg:4525	Size:256	Owner:0x1bf6
+++++
+Seg:4625	Size:256	Owner:0x1bf8
+++++
+Seg:4725	Size:256	Owner:0x1bfa
+++++
+Seg:4825	Size:256	Owner:0x1bfc
++++++
+Seg:4925	Size:256	Owner:0x1bfe
+++++
+Seg:4a25	Size:256	Owner:0x1c00
+++++
+Seg:4b25	Size:256	Owner:0x1c02
+++++
+Seg:4c25	Size:256	Owner:0x1c04
+++++
+Seg:4d25	Size:256	Owner:0x1c06
++++++
+Seg:4e25	Size:256	Owner:0x1c08
+++++
+Seg:4f25	Size:256	Owner:0x1c0a
+++++
+Seg:5025	Size:256	Owner:0x1c0c
+++++
+Seg:5125	Size:256	Owner:0x1c0e
+++++
+Seg:5225	Size:256	Owner:0x1c10
++++++
+Seg:5325	Size:256	Owner:0x1c12
+++++
+Seg:5425	Size:256	Owner:0x1c14
+++++
+Seg:5525	Size:256	Owner:0x1c16
+++++
+Seg:5625	Size:256	Owner:0x1c18
+++++
+Seg:5725	Size:256	Owner:0x1c1a
++++++
+Seg:5825	Size:256	Owner:0x1c1c
+++++
+Seg:5925	Size:256	Owner:0x1c1e
+++++
+Seg:5a25	Size:256	Owner:0x1c20
+++++
+Seg:5b25	Size:256	Owner:0x1c22
+++++
+Seg:5c25	Size:256	Owner:0x1c24
++++++
+Seg:5d25	Size:256	Owner:0x1c26
+++++
+Seg:5e25	Size:256	Owner:0x1c28
+++++
+Seg:5f25	Size:256	Owner:0x1c2a
+++++
+Seg:6025	Size:256	Owner:0x1c2c
+++++
+Seg:6125	Size:256	Owner:0x1c2e
++++++
+Seg:6225	Size:256	Owner:0x1c30
+++++
+Seg:6325	Size:256	Owner:0x1c32
+++++
+Seg:6425	Size:256	Owner:0x1c34
+++++
+Seg:6525	Size:256	Owner:0x1c36
+++++
+Seg:6625	Size:256	Owner:0x1c38
++++++
+Seg:6725	Size:256	Owner:0x1c3a
+++++
+Seg:6825	Size:256	Owner:0x1c3c
+++++
+Seg:6925	Size:256	Owner:0x1c3e
+++++
+Seg:6a25	Size:256	Owner:0x1c40
+++++
+Seg:6b25	Size:256	Owner:0x1c42
++++++
+Seg:6c25	Size:256	Owner:0x1c44
+++++
+Seg:6d25	Size:256	Owner:0x1c46
+++++
+Seg:6e25	Size:256	Owner:0x1c48
+++++
+Seg:6f25	Size:256	Owner:0x1c4a
+++++
+Seg:7025	Size:256	Owner:0x1c4c
++++++
+Seg:7125	Size:256	Owner:0x1c4e
+++++
+Seg:7225	Size:256	Owner:0x1c50
+++++
+Seg:7325	Size:256	Owner:0x1c52
+++++
+Seg:7425	Size:256	Owner:0x1c54
+++++
+Seg:7525	Size:256	Owner:0x1c56
++++++
+Seg:7625	Size:256	Owner:0x1c58
+++++
+Seg:7725	Size:256	Owner:0x1c5a
+++++
+Seg:7825	Size:256	Owner:0x1c5c
+++++
+Seg:7925	Size:256	Owner:0x1c5e
+++++
+Seg:7a25	Size:256	Owner:0x1c60
++++++
+Seg:7b25	Size:256	Owner:0x1c62
+++++
+Seg:7c25	Size:256	Owner:0x1c64
+++++
+Seg:7d25	Size:256	Owner:0x1c66
+++++
+Seg:7e25	Size:256	Owner:0x1c68
+++++
+Seg:7f25	Size:256	Owner:0x1c6a
++++++
+Seg:8025	Size:256	Owner:0x1c6c
+++++
+Seg:8125	Size:256	Owner:0x1c6e
+++++
+Seg:8225	Size:256	Owner:0x1c70
+++++
+Seg:8325	Size:256	Owner:0x1c72
+++++
+Seg:8425	Size:256	Owner:0x1c74
++++++
+Seg:8525	Size:256	Owner:0x1c76
+++++
+Seg:8625	Size:256	Owner:0x1c78
+++++
+Seg:8725	Size:256	Owner:0x1c7a
+++++
+Seg:8825	Size:256	Owner:0x1c7c
+++++
+Seg:8925	Size:273	Owner:0x1b88
++++++
+Seg:9d64	Size:25243	Owner:0x0
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
\ No newline at end of file
diff --git a/EXMMTEST.L16 b/EXMMTEST.L16
new file mode 100755
index 00000000..5c2f9577
--- /dev/null
+++ b/EXMMTEST.L16
@@ -0,0 +1,472 @@
+MM_GetPtr
+	baseptr=1430:1db4	useptr=1430:1db4
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec62	&useptr=1430:1e20
+MM_GetPtr
+	baseptr=1430:1ba6	useptr=1430:1ba6
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:1e30
+MM_GetPtr
+	baseptr=1430:1ba8	useptr=1430:1ba8
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:1e40
+MM_GetPtr
+	baseptr=1430:1baa	useptr=1430:1baa
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:1e50
+MM_GetPtr
+	baseptr=1430:1bac	useptr=1430:1bac
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:1e60
+MM_GetPtr
+	baseptr=1430:1bae	useptr=1430:1bae
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:1e70
+MM_GetPtr
+	baseptr=1430:1bb0	useptr=1430:1bb0
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:1e80
+MM_GetPtr
+	baseptr=1430:1bb2	useptr=1430:1bb2
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:1e90
+MM_GetPtr
+	baseptr=1430:1bb4	useptr=1430:1bb4
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:1ea0
+MM_GetPtr
+	baseptr=1430:1bb6	useptr=1430:1bb6
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:1eb0
+MM_GetPtr
+	baseptr=1430:1bb8	useptr=1430:1bb8
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:1ec0
+MM_GetPtr
+	baseptr=1430:1bba	useptr=1430:1bba
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:1ed0
+MM_GetPtr
+	baseptr=1430:1bbc	useptr=1430:1bbc
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:1ee0
+MM_GetPtr
+	baseptr=1430:1bbe	useptr=1430:1bbe
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:1ef0
+MM_GetPtr
+	baseptr=1430:1bc0	useptr=1430:1bc0
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:1f00
+MM_GetPtr
+	baseptr=1430:1bc2	useptr=1430:1bc2
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:1f10
+MM_GetPtr
+	baseptr=1430:1bc4	useptr=1430:1bc4
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:1f20
+MM_GetPtr
+	baseptr=1430:1bc6	useptr=1430:1bc6
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:1f30
+MM_GetPtr
+	baseptr=1430:1bc8	useptr=1430:1bc8
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:1f40
+MM_GetPtr
+	baseptr=1430:1bca	useptr=1430:1bca
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:1f50
+MM_GetPtr
+	baseptr=1430:1bcc	useptr=1430:1bcc
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:1f60
+MM_GetPtr
+	baseptr=1430:1bce	useptr=1430:1bce
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:1f70
+MM_GetPtr
+	baseptr=1430:1bd0	useptr=1430:1bd0
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:1f80
+MM_GetPtr
+	baseptr=1430:1bd2	useptr=1430:1bd2
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:1f90
+MM_GetPtr
+	baseptr=1430:1bd4	useptr=1430:1bd4
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:1fa0
+MM_GetPtr
+	baseptr=1430:1bd6	useptr=1430:1bd6
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:1fb0
+MM_GetPtr
+	baseptr=1430:1bd8	useptr=1430:1bd8
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:1fc0
+MM_GetPtr
+	baseptr=1430:1bda	useptr=1430:1bda
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:1fd0
+MM_GetPtr
+	baseptr=1430:1bdc	useptr=1430:1bdc
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:1fe0
+MM_GetPtr
+	baseptr=1430:1bde	useptr=1430:1bde
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:1ff0
+MM_GetPtr
+	baseptr=1430:1be0	useptr=1430:1be0
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:2000
+MM_GetPtr
+	baseptr=1430:1be2	useptr=1430:1be2
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:2010
+MM_GetPtr
+	baseptr=1430:1be4	useptr=1430:1be4
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:2020
+MM_GetPtr
+	baseptr=1430:1be6	useptr=1430:1be6
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:2030
+MM_GetPtr
+	baseptr=1430:1be8	useptr=1430:1be8
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:2040
+MM_GetPtr
+	baseptr=1430:1bea	useptr=1430:1bea
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:2050
+MM_GetPtr
+	baseptr=1430:1bec	useptr=1430:1bec
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:2060
+MM_GetPtr
+	baseptr=1430:1bee	useptr=1430:1bee
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:2070
+MM_GetPtr
+	baseptr=1430:1bf0	useptr=1430:1bf0
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:2080
+MM_GetPtr
+	baseptr=1430:1bf2	useptr=1430:1bf2
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:2090
+MM_GetPtr
+	baseptr=1430:1bf4	useptr=1430:1bf4
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:20a0
+MM_GetPtr
+	baseptr=1430:1bf6	useptr=1430:1bf6
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:20b0
+MM_GetPtr
+	baseptr=1430:1bf8	useptr=1430:1bf8
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:20c0
+MM_GetPtr
+	baseptr=1430:1bfa	useptr=1430:1bfa
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:20d0
+MM_GetPtr
+	baseptr=1430:1bfc	useptr=1430:1bfc
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:20e0
+MM_GetPtr
+	baseptr=1430:1bfe	useptr=1430:1bfe
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:20f0
+MM_GetPtr
+	baseptr=1430:1c00	useptr=1430:1c00
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:2100
+MM_GetPtr
+	baseptr=1430:1c02	useptr=1430:1c02
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:2110
+MM_GetPtr
+	baseptr=1430:1c04	useptr=1430:1c04
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:2120
+MM_GetPtr
+	baseptr=1430:1c06	useptr=1430:1c06
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:2130
+MM_GetPtr
+	baseptr=1430:1c08	useptr=1430:1c08
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:2140
+MM_GetPtr
+	baseptr=1430:1c0a	useptr=1430:1c0a
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:2150
+MM_GetPtr
+	baseptr=1430:1c0c	useptr=1430:1c0c
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:2160
+MM_GetPtr
+	baseptr=1430:1c0e	useptr=1430:1c0e
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:2170
+MM_GetPtr
+	baseptr=1430:1c10	useptr=1430:1c10
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:2180
+MM_GetPtr
+	baseptr=1430:1c12	useptr=1430:1c12
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:2190
+MM_GetPtr
+	baseptr=1430:1c14	useptr=1430:1c14
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:21a0
+MM_GetPtr
+	baseptr=1430:1c16	useptr=1430:1c16
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:21b0
+MM_GetPtr
+	baseptr=1430:1c18	useptr=1430:1c18
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:21c0
+MM_GetPtr
+	baseptr=1430:1c1a	useptr=1430:1c1a
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:21d0
+MM_GetPtr
+	baseptr=1430:1c1c	useptr=1430:1c1c
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:21e0
+MM_GetPtr
+	baseptr=1430:1c1e	useptr=1430:1c1e
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:21f0
+MM_GetPtr
+	baseptr=1430:1c20	useptr=1430:1c20
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:2200
+MM_GetPtr
+	baseptr=1430:1c22	useptr=1430:1c22
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:2210
+MM_GetPtr
+	baseptr=1430:1c24	useptr=1430:1c24
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:2220
+MM_GetPtr
+	baseptr=1430:1c26	useptr=1430:1c26
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:2230
+MM_GetPtr
+	baseptr=1430:1c28	useptr=1430:1c28
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:2240
+MM_GetPtr
+	baseptr=1430:1c2a	useptr=1430:1c2a
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:2250
+MM_GetPtr
+	baseptr=1430:1c2c	useptr=1430:1c2c
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:2260
+MM_GetPtr
+	baseptr=1430:1c2e	useptr=1430:1c2e
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:2270
+MM_GetPtr
+	baseptr=1430:1c30	useptr=1430:1c30
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:2280
+MM_GetPtr
+	baseptr=1430:1c32	useptr=1430:1c32
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:2290
+MM_GetPtr
+	baseptr=1430:1c34	useptr=1430:1c34
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:22a0
+MM_GetPtr
+	baseptr=1430:1c36	useptr=1430:1c36
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:22b0
+MM_GetPtr
+	baseptr=1430:1c38	useptr=1430:1c38
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:22c0
+MM_GetPtr
+	baseptr=1430:1c3a	useptr=1430:1c3a
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:22d0
+MM_GetPtr
+	baseptr=1430:1c3c	useptr=1430:1c3c
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:22e0
+MM_GetPtr
+	baseptr=1430:1c3e	useptr=1430:1c3e
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:22f0
+MM_GetPtr
+	baseptr=1430:1c40	useptr=1430:1c40
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:2300
+MM_GetPtr
+	baseptr=1430:1c42	useptr=1430:1c42
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:2310
+MM_GetPtr
+	baseptr=1430:1c44	useptr=1430:1c44
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:2320
+MM_GetPtr
+	baseptr=1430:1c46	useptr=1430:1c46
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:2330
+MM_GetPtr
+	baseptr=1430:1c48	useptr=1430:1c48
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:2340
+MM_GetPtr
+	baseptr=1430:1c4a	useptr=1430:1c4a
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:2350
+MM_GetPtr
+	baseptr=1430:1c4c	useptr=1430:1c4c
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:2360
+MM_GetPtr
+	baseptr=1430:1c4e	useptr=1430:1c4e
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:2370
+MM_GetPtr
+	baseptr=1430:1c50	useptr=1430:1c50
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:2380
+MM_GetPtr
+	baseptr=1430:1c52	useptr=1430:1c52
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:2390
+MM_GetPtr
+	baseptr=1430:1c54	useptr=1430:1c54
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:23a0
+MM_GetPtr
+	baseptr=1430:1c56	useptr=1430:1c56
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:23b0
+MM_GetPtr
+	baseptr=1430:1c58	useptr=1430:1c58
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:23c0
+MM_GetPtr
+	baseptr=1430:1c5a	useptr=1430:1c5a
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:23d0
+MM_GetPtr
+	baseptr=1430:1c5c	useptr=1430:1c5c
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:23e0
+MM_GetPtr
+	baseptr=1430:1c5e	useptr=1430:1c5e
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:23f0
+MM_GetPtr
+	baseptr=1430:1c60	useptr=1430:1c60
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:2400
+MM_GetPtr
+	baseptr=1430:1c62	useptr=1430:1c62
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:2410
+MM_GetPtr
+	baseptr=1430:1c64	useptr=1430:1c64
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:2420
+MM_GetPtr
+	baseptr=1430:1c66	useptr=1430:1c66
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:2430
+MM_GetPtr
+	baseptr=1430:1c68	useptr=1430:1c68
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:2440
+MM_GetPtr
+	baseptr=1430:1c6a	useptr=1430:1c6a
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:2450
+MM_GetPtr
+	baseptr=1430:1c6c	useptr=1430:1c6c
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec48	&useptr=1430:2460
+-------------------------------------------------------------------------------
+&main()=	1430:6cc1
+buffer:
+	1430:0000	&1430:1b78
+	     0000	&     1b78
+-------------------------------------------------------------------------------
+press any key to continue!
+======================================load======================================
+MM_GetPtr
+	baseptr=1430:1b78	useptr=1430:1b78
+	*baseptr=1430:0000	*useptr=1430:0000
+	&baseptr=1430:ec64	&useptr=1430:2470
+-------------------------------------------------------------------------------
+&main()=	1430:6cc1
+buffer:
+	1430:893b	&1430:1b78
+	     893b	&     1b78
+-------------------------------------------------------------------------------
+
+yay!
+======================================read======================================
+-------------------------------------------------------------------------------
+&main()=	1430:6cc1
+buffer:
+	1430:893b	&1430:1b78
+	     893b	&     1b78
+-------------------------------------------------------------------------------
+
+yay!
+========================================
+		DebugMemory_
+========================================
+Memory Usage
+------------
+Total:		578k
+Free:		170k
+With purge:	570k
+------------
+MMDUMP.16 created.
+========================================
+		MM_Report_
+========================================
+	ÉLIMEMS	1
+	ÇÄEMM v4.0 available
+	ÇÄtotalEMSpages:	4032	freeEMSpages:	3939
+	ÇÄEMSPageFrame:	e000
+	ÓÄEMSmem:	64536576
+	ÉXMS	1
+	ÇÄXMS v3.0 available
+	ÇÄXMSDriver:	c83f:0010
+	ÇÄXMSHandle:	0800
+	ÓÄXMSmem:	2097152
+	ÉConv.	1
+	ÓÄTotal:	578k	Free:	170k	With purge:570k
+nearheap:	3884		farheap:	588812
+========================================
+near=	1430:eec8 far=	2431:009c
+&near=	1430:1dc0 &far=	1430:1dbc
+bigb=	1430:0000 &bigb=1430:1b78 
+========================================
+
+_memavl():			4404
+HC_farcoreleft():			962022
+HC_GetNearFreeSize():		4406
+HC_GetFarFreeSize():			40134
+Project 16 exmmtest.exe. This is just a test file!
+version Feb 22 2017 12:35:11
+debugmm: 1	
diff --git a/HEAP.16W b/HEAP.16W
new file mode 100755
index 00000000..e4332ea9
--- /dev/null
+++ b/HEAP.16W
@@ -0,0 +1,47 @@
+
+	== default ==
+
+  USED block at 24200016 of size 26
+  USED block at 24200030 of size 26
+  FREE block at 2420004a of size 38914
+  USED block at 2420984c of size 136
+  USED block at 242098d4 of size 20
+  FREE block at 242098e8 of size 7972
+OK - end of heap
+
+	== near ==
+
+  USED block at 141fece6 of size 12
+  USED block at 141fecf2 of size 332
+  USED block at 141fee3e of size 52
+  USED block at 141fee72 of size 20
+  USED block at 141fee86 of size 20
+  USED block at 141fee9a of size 20
+  USED block at 141feeae of size 20
+  USED block at 141feec2 of size 20
+  USED block at 141feed6 of size 4390
+OK - end of heap
+
+	== far ==
+
+  USED block at 24200016 of size 26
+  USED block at 24200030 of size 26
+  USED block at 2420004a of size 38914
+  USED block at 2420984c of size 136
+  USED block at 242098d4 of size 20
+  USED block at 242098e8 of size 7972
+OK - end of heap
+
+Memory Type         Total      Used       Free
+----------------  --------   --------   --------
+Default		   47094	208	  46886
+Near		   4886		496	  4390
+Far		   47094	208	  46886
+----------------  --------   --------   --------
+HC_coreleft = 4388
+HC_farcoreleft = 458752
+HC_GetFreeSize = 46886
+HC_GetNearFreeSize = 4390
+HC_GetFarFreeSize = 46886
+memavl = 4388
+stackavail = 31606
diff --git a/MEMINFO.16B b/MEMINFO.16B
new file mode 100755
index 00000000..e69de29b
diff --git a/MEMINFO.16W b/MEMINFO.16W
new file mode 100755
index 00000000..e69de29b
diff --git a/MMDUMP.16B b/MMDUMP.16B
new file mode 100755
index 00000000..2cb68d4d
Binary files /dev/null and b/MMDUMP.16B differ
diff --git a/MMDUMP.16W b/MMDUMP.16W
new file mode 100755
index 00000000..4c1c8fe9
Binary files /dev/null and b/MMDUMP.16W differ
diff --git a/bcexmm.exe b/bcexmm.exe
index d5f755b1..5376f8fc 100755
Binary files a/bcexmm.exe and b/bcexmm.exe differ
diff --git a/src/exmmtest.c b/src/exmmtest.c
index 94599daf..b6efd4eb 100755
--- a/src/exmmtest.c
+++ b/src/exmmtest.c
@@ -22,6 +22,7 @@
 /*
 	exmm test
 */
+#include <malloc.h>		// for _memavl()
 #include "src/lib/16_head.h"
 #include "src/lib/16_tail.h"
 #include "src/lib/16_pm.h"
@@ -29,31 +30,52 @@
 #include "src/lib/16_mm.h"
 #include "src/lib/16_hc.h"
 //#include "src/lib/16_vl.h"
+#include "src/lib/16_dbg.h"
+
 #pragma hdrstop
 
 #pragma warn -pro
 #pragma warn -use
 
 //file load or read definition
+#define FILEREADLOAD
 #define FILEREAD
-#define EXMMVERBOSE
-//#ifdef __BORLANDC__
+//#define EXMMVERBOSE
+//#define BUFFDUMPPAUSE
+//#define EXMMVERBOSE__
+//	#define PRINTBBDUMP
 #define BUFFDUMP
-//#endif
 
-#define BBUF bigbuffer//gvar.ca.tinf[0]
+#define BBUFNAME gvar.ca.tinf[0]//bigbuffer
+//#define INITBBUF static memptr BBUFNAME;
+#define BBUFPTR	&BBUFNAME
+
+#ifdef __BORLANDC__
+#define BBUF		(memptr *)BBUFPTR//
+#define BBUFSTRING	(memptr *)BBUFNAME
+#endif
+#ifdef __WATCOMC__
+#define BBUF		BBUFNAME
+#define BBUFSTRING	BBUF
+#endif
+
 
 void VGAmodeX(sword vq, boolean cmem, global_game_variables_t *gv)
 {
 	printf("VGAmodeX dummy:\n	%Fp	%Fp	%Fp\n", &vq, &cmem, gv);
 }
+
+//printf("*	%Fp\t", *BBUF);
+//printf("*	     %04x\t", *BBUF);
 #define PRINTBB {\
+	printf("-------------------------------------------------------------------------------\n");\
 	printf("&main()=	%Fp\n", argv[0]);\
-	printf("BBUF:\n");\
+	printf("buffer:\n");\
 	printf("	%Fp\t", BBUF);\
-	printf("&%Fp\n", &BBUF);\
+	printf("&%Fp\n", BBUFPTR);\
 	printf("	     %04x\t", BBUF);\
-	printf("&     %04x\n", &BBUF);\
+	printf("&     %04x\n", BBUFPTR);\
+	printf("-------------------------------------------------------------------------------\n");\
 }
 	//printf("&main()=	%Fp\n", *argv[0]);
 	//printf("bigbuffer=	%Fp\n", bigbuffer);
@@ -86,9 +108,11 @@ void segatesuto()
 void
 main(int argc, char *argv[])
 {
-	byte w=1;
+	byte w;
 	static global_game_variables_t gvar;
-	memptr BBUF;
+#ifdef INITBBUF
+	INITBBUF
+#endif
 //#ifdef __WATCOMC__
 //	__segment sega;
 //#endif
@@ -100,8 +124,8 @@ main(int argc, char *argv[])
 	argc=argc;
 #endif
 	//file name //
-	bakapee1 = malloc(64);
-	bakapee2 = malloc(64);
+	bakapee1 = malloc(24);
+	bakapee2 = malloc(24);
 	//file name //
 
 #ifdef __16_PM__
@@ -110,7 +134,12 @@ main(int argc, char *argv[])
 #endif
 #endif
 
-	//PRINTBB
+#ifdef __DEBUG_CA__
+	dbg_debugca=1;
+#endif
+#ifdef PRINTBBDUMP
+//0000PRINTBB; printf("press any key to continue!\n"); getch();
+#endif
 	if(argv[1]){ bakapee1 = argv[1];
 	if(argv[2]) bakapee2 = argv[2]; }
 	else{
@@ -119,63 +148,85 @@ main(int argc, char *argv[])
 		bakapee2 = "data/test.map";
 	}
 	//printf("main()=%Fp	start MM\n", *argv[0]);
-	MM_Startup(&gvar);
-	//printf("ok\n");
+	MM_Startup(&gvar); //printf("ok\n");
 #ifdef __16_PM__
 #ifdef __DEBUG_PM__
 	if(dbg_debugpm>0)
 	{
 #endif
 		PM_Startup(&gvar); PM_CheckMainMem(&gvar); PM_UnlockMainMem(&gvar);
+//0000		printf("PM Started\n"); printf("press any key to continue!\n"); getch();
 #ifdef __DEBUG_PM__
 	}
 #endif
+#endif
+
+#ifdef __DEBUG_MM__
+	dbg_debugmm=0;
 #endif
 	CA_Startup(&gvar);
 //	printf("		done!\n");
-	//0000
-	PRINTBB; printf("press any key to continue!\n"); getch();
+#ifdef PRINTBBDUMP
+//0000
+PRINTBB; printf("\n\npress any key to continue!\n"); getch();
+#endif
+#ifdef __DEBUG_MM__
+	dbg_debugmm=1;
+#endif
+
+	w=0;
+#ifdef FILEREADLOAD
 #ifdef FILEREAD
-for(w=0;w<2;w++)
-{
-//	printf("size of big buffer~=%u\n", _bmsize(segu, BBUF));
-	if(w>0)
+	for(;w<2;w++)
 	{
-		printf("		read\n");
-		if(CA_ReadFile(bakapee2, &BBUF, &gvar)) baka=1; else baka=0;
-	}
+	//	printf("size of big buffer~=%u\n", _bmsize(segu, BBUF));
+		if(w>0)
+		{
+			printf("======================================read=====================================\n");
+			if(CA_ReadFile(bakapee2, BBUFPTR, &gvar)) baka=1; else baka=0;
+			printf("====================================read end===================================\n");
+		}
 #endif
-	if(w==0)
-	{
-		printf("		load\n");
-		if(CA_LoadFile(bakapee1, &BBUF, &gvar)) baka=1; else baka=0;
-	}
+		if(w==0)
+		{
+			printf("======================================load=====================================\n");
+			if(CA_LoadFile(bakapee1, BBUFPTR, &gvar)) baka=1; else baka=0;
+			printf("====================================load end===================================\n");
+		}
 //#ifdef __WATCOMC__
 //	printf("\nsize of big buffer~=%u\n", _bmsize(sega, BBUF));
 //#endif
 #ifdef BUFFDUMP
-	printf("contents of the buffer\n[\n%s\n]\n", (BBUF));
+		printf("contents of the buffer\n[\n%s\n]\n", BBUFSTRING);
 #endif// #else
-	PRINTBB;
-// #endif
-	//printf("dark purple = purgable\n");
-	//printf("medium blue = non purgable\n");
-	//printf("red = locked\n");
-//	printf("press any key to continue!\n");
-//	DebugMemory_(&gvar, 1);
-	if(baka) printf("\nyay!\n");
-	else printf("\npoo!\n");
-	printf("press any key to continue!\n");
-	getch();
+#ifdef PRINTBBDUMP
+		PRINTBB;
+#endif
+//endif // BUFFDUMP
+
+		//printf("dark purple = purgable\n");
+		//printf("medium blue = non purgable\n");
+		//printf("red = locked\n");
+	//	printf("press any key to continue!\n");
+	//	DebugMemory_(&gvar, 1);
+		if(baka) printf("\nyay!\n");
+		else printf("\npoo!\n");
+#ifdef BUFFDUMPPAUSE
+		printf("press any key to continue!\n"); getch();
+#endif
 #ifdef FILEREAD
-}
+	}
 #endif
+#ifndef BUFFDUMPPAUSE
+	printf("press any key to continue!\n"); getch();
+#endif
+#endif	//filereadload
 	DebugMemory_(&gvar, 1);
 	MM_DumpData(&gvar);
 	MM_Report_(&gvar);
 	//printf("bakapee1=%s\n", bakapee1);
 	//printf("bakapee2=%s\n", bakapee2);
-	MM_FreePtr(&BBUF, &gvar);
+	MM_FreePtr(BBUFPTR, &gvar);
 #ifdef __16_PM__
 #ifdef __DEBUG_PM__
 	if(dbg_debugpm>0)
@@ -196,30 +247,48 @@ for(w=0;w<2;w++)
 	printf("bigb=	%Fp ", BBUF);
 	//printf("bigbr=	%04x", BBUF);
 	//printf("\n");
-	printf("&bigb=%Fp ", &BBUF);
-	//printf("&bigb=%04x", &BBUF);
+	printf("&bigb=%Fp ", BBUFPTR);
+	//printf("&bigb=%04x", BBUFPTR);
 	printf("\n");
+#endif
 	printf("========================================\n");
+
+#ifdef EXMMVERBOSE__
+	printf("coreleft():			%u\n", _memavl());
+	printf("farcoreleft():			%lu\n", (dword)HC_farcoreleft());
 #endif
-	printf("\n");
-	printf("HC_coreleft():			%u\n", HC_coreleft());
 #ifdef __WATCOMC__
 //this is far	printf("Total free:			%lu\n", (dword)(HC_GetFreeSize()));
-	printf("HC_GetNearFreeSize():		%u\n", HC_GetNearFreeSize());
-	printf("HC_GetFarFreeSize():			%lub\n", (dword)HC_GetFarFreeSize());
+//super buggy	printf("HC_coreleft():			%u\n", HC_coreleft());
+//	printf("HC_farcoreleft():			%lu\n", (dword)HC_farcoreleft());
+	//printf("HC_GetNearFreeSize():		%u\n", HC_GetNearFreeSize());
+	//printf("HC_GetFarFreeSize():			%lu\n", (dword)HC_GetFarFreeSize());
 	HC_heapdump(&gvar);
 //	segatesuto();
 #endif
-#ifdef __BORLANDC__
+/*#ifdef __BORLANDC__
 	//printf("core left:			%lu\n", (dword)HC_coreleft());
 	//printf("far core left:			%lu\n", (dword)HC_farcoreleft());
-	printf("coreleft():			%u\n", coreleft());
-	printf("farcoreleft():			%lu\n", (dword)farcoreleft());
+//	printf("\nfarcoreleft():			%lu\n", farcoreleft());
+#endif*/
+	printf("Project 16 ");
+#ifdef __WATCOMC__
+	printf("exmmtest");
+#endif
+#ifdef __BORLANDC__
+	printf("bcexmm");
 #endif
-	printf("Project 16 exmmtest.exe. This is just a test file!\n");
+	printf(".exe. This is just a test file!\n");
 	printf("version %s\n", VERSION);
-	//printf("\n");
-
+#if defined(__DEBUG__) && ( defined(__DEBUG_PM__) || defined(__DEBUG_MM__) )
+#ifdef __DEBUG_MM__
+	printf("debugmm: %u\t", dbg_debugmm);
+#endif
+#ifdef __DEBUG_PM__
+	printf("debugpm: %u", dbg_ddebugpm);
+#endif
+	printf("\n");
+#endif
 	//printf("based core left:			%lu\n", (dword)_basedcoreleft());
 	//printf("huge core left:			%lu\n", (dword)_hugecoreleft());
 }
diff --git a/src/lib/16_ca.c b/src/lib/16_ca.c
index 9e984899..c08ef434 100755
--- a/src/lib/16_ca.c
+++ b/src/lib/16_ca.c
@@ -305,7 +305,7 @@ boolean CA_FarWrite(int handle, byte far *source, dword length, global_game_vari
 		//segm=(length%0xfffflu)-1;
 		//fat=segm*0xfffflu;
 		//length-=fat;
-		printf("CA_FarRead doesn't support 64K reads yet!\n");
+		printf("CA_FarWrite doesn't support 64K reads yet!\n");
 		return 0;
 	}
 
@@ -377,10 +377,10 @@ boolean CA_ReadFile(char *filename, memptr *ptr, global_game_variables_t *gvar)
 	size = filelength(handle);
 	if(!CA_FarRead(handle,*ptr,size, gvar))
 	{
-		close (handle);
+		close(handle);
 		return false;
 	}
-	close (handle);
+	close(handle);
 	return true;
 }
 
@@ -438,7 +438,28 @@ boolean CA_LoadFile(char *filename, memptr *ptr, global_game_variables_t *gvar)
 		return false;
 
 	size = filelength(handle);
+#ifdef __DEBUG_CA__
+	if(dbg_debugca>0){
+		printf("===============================================================================\n");
+		printf("		CA_LoadFile\n");
+		printf("===============================================================================\n");
+		//%04x
+		printf("	ptr=%Fp\n", ptr);
+		printf("	*ptr=%Fp\n", *ptr);
+		printf("	&ptr=%Fp\n", &ptr);
+	}
+#endif
 	MM_GetPtr(ptr,size, gvar);
+#ifdef __DEBUG_CA__
+	if(dbg_debugca>0){
+		//%04x
+		printf("---------------------------------------\n");
+		printf("	ptr=%Fp\n", ptr);
+		printf("	*ptr=%Fp\n", *ptr);
+		printf("	&ptr=%Fp\n", &ptr);
+		printf("-------------------------------------------------------------------------------\n");
+	}
+#endif
 	if(!CA_FarRead(handle,*ptr,size, gvar))
 	{
 		close(handle);
diff --git a/src/lib/16_dbg.c b/src/lib/16_dbg.c
index 634003a6..bfa55a53 100755
--- a/src/lib/16_dbg.c
+++ b/src/lib/16_dbg.c
@@ -1,9 +1,15 @@
 #include "src/lib/16_dbg.h"
 
 #ifdef __DEBUG__
+#ifdef __DEBUG_MM__
+boolean dbg_debugmm=0;
+#endif
 #ifdef __DEBUG_PM__
 boolean dbg_debugpm=0;
 #endif
+#ifdef __DEBUG_CA__
+boolean dbg_debugca=0;
+#endif
 #ifdef __DEBUG_InputMgr__
 boolean dbg_testkeyin=0,dbg_testcontrolnoisy=0,dbg_nointest=0;
 #endif
@@ -13,7 +19,7 @@ byte *dbg_mapdata;
 #endif
 #endif
 
-
+#ifdef __WATCOMC__
 // TODO: Could we also provide a build mode to emit debug to the "Bochs E9 hack?"
 #ifdef DEBUGSERIAL
 # include <stdarg.h>
@@ -85,5 +91,5 @@ void _DEBUGF(const char *fmt,...) {
 	_DEBUG(_DEBUGF_TMP);
 	va_end(va);
 }
+#endif	//watcomc
 #endif
-
diff --git a/src/lib/16_dbg.h b/src/lib/16_dbg.h
index 1abc2bce..5340313a 100755
--- a/src/lib/16_dbg.h
+++ b/src/lib/16_dbg.h
@@ -8,14 +8,21 @@
 #define __DEBUG__
 #define __DEBUG_InputMgr__
 #define __DEBUG_MAP__
+//#define __DEBUG_CA__
 //#define __DEBUG_PM__
 //#define __DEBUG_MM__
 
 
 #ifdef __DEBUG__
+#ifdef __DEBUG_MM__
+extern boolean dbg_debugmm;
+#endif
 #ifdef __DEBUG_PM__
 extern boolean dbg_debugpm;
 #endif
+#ifdef __DEBUG_CA__
+extern boolean dbg_debugca;
+#endif
 #ifdef __DEBUG_InputMgr__
 extern boolean dbg_testkeyin,dbg_testcontrolnoisy,dbg_nointest;
 #endif
@@ -25,6 +32,7 @@ extern byte *dbg_mapdata;
 #endif
 #endif
 
+#ifdef __WATCOMC__
 # ifdef DEBUGSERIAL
 #  include <hw/8250/8250.h>
 
@@ -44,5 +52,5 @@ static inline int _DEBUG_INIT() {
 	return -1;
 }
 # endif
+#endif //watcomc
 #endif // _SRC_LIB_16_DBG
-
diff --git a/src/lib/16_hc.c b/src/lib/16_hc.c
index 8c9f9396..f2963158 100755
--- a/src/lib/16_hc.c
+++ b/src/lib/16_hc.c
@@ -26,30 +26,94 @@
 #include "src/lib/16_hc.h"
 #include <malloc.h>
 
-//functions
-void CHIKAKU* HC_LargestFreeBlock(size_t* Size)
+//from ftp://213.85.246.177/pub/FreeBSD/ports/archivers/arj/work/arj-3.10.22/environ.c
+//#ifdef __WATCOMC__
+#define FARCORELEFTPTR __huge
+long HC_farcoreleft()
+{
+	void FARCORELEFTPTR *hp;
+	static long rc=736L;
+	long s_rc;
+
+	s_rc=rc;
+	rc+=2L;
+	do
+		hp=halloc(rc-=2L, 1024);
+	while(hp==NULL&&rc>0L);
+	if(hp!=NULL)
+		hfree(hp);
+	if(rc<s_rc)
+		return(rc*1024L);
+	do
+	{
+		hp=halloc(rc+=16L, 1024);
+		if(hp!=NULL)
+			hfree(hp);
+	} while(hp!=NULL);
+	return((rc-16L)*1024L);
+}
+//#endif
+
+void
+#ifdef __BORLANDC__
+ *
+#endif
+#ifdef __WATCOMC__
+ __near*
+#endif
+HC_LargestFreeBlock(size_t* Size)
 {
 	size_t s0, s1;
-	void CHIKAKU* p;
+#ifdef __BORLANDC__
+	void * p;
+#endif
+#ifdef __WATCOMC__
+	void __near* p;
+#endif
 
 	s0 = ~(size_t)0 ^ (~(size_t)0 >> 1);
+#ifdef __BORLANDC__
+	while (s0 && (p = malloc(s0)) == NULL)
+#endif
+#ifdef __WATCOMC__
 	while (s0 && (p = _nmalloc(s0)) == NULL)
+#endif
 		s0 >>= 1;
 
 	if (p)
+#ifdef __BORLANDC__
+		free(p);
+#endif
+#ifdef __WATCOMC__
 		_nfree(p);
+#endif
 
 	s1 = s0 >> 1;
 	while (s1)
 	{
+#ifdef __BORLANDC__
+		if ((p = malloc(s0 + s1)) != NULL)
+#endif
+#ifdef __WATCOMC__
 		if ((p = _nmalloc(s0 + s1)) != NULL)
+#endif
 		{
 			s0 += s1;
+#ifdef __BORLANDC__
+			free(p);
+#endif
+#ifdef __WATCOMC__
 			_nfree(p);
+#endif
 		}
 	s1 >>= 1;
 	}
+#ifdef __BORLANDC__
+	while (s0 && (p = malloc(s0)) == NULL)
+#endif
+#ifdef __WATCOMC__
 	while (s0 && (p = _nmalloc(s0)) == NULL)
+#endif
 		s0 ^= s0 & -s0;
 
 	*Size = s0;
@@ -59,34 +123,42 @@ void CHIKAKU* HC_LargestFreeBlock(size_t* Size)
 size_t HC_coreleft(void)
 {
 	size_t total = 0;
-	void CHIKAKU* pFirst = NULL;
-	void CHIKAKU* pLast = NULL;
+	void __near* pFirst = NULL;
+	void __near* pLast = NULL;
 	for(;;)
 	{
 		size_t largest;
-		void CHIKAKU* p = (void CHIKAKU *)HC_LargestFreeBlock(&largest);
-		if (largest < sizeof(void CHIKAKU*))
+		void __near* p = (void __near *)HC_LargestFreeBlock(&largest);
+		if (largest < sizeof(void __near*))
 		{
 			if (p != NULL)
+#ifdef __BORLANDC__
+			free(p);
+#endif
+#ifdef __WATCOMC__
 			_nfree(p);
-
+#endif
 			break;
 		}
-		*(void CHIKAKU* CHIKAKU*)p = NULL;
+		*(void __near* __near*)p = NULL;
 		total += largest;
 		if (pFirst == NULL)
 			pFirst = p;
 
 		if (pLast != NULL)
-			*(void CHIKAKU* CHIKAKU*)pLast = p;
+			*(void __near* __near*)pLast = p;
 		pLast = p;
 	}
 
 	while (pFirst != NULL)
 	{
-		void CHIKAKU* p = *(void CHIKAKU* CHIKAKU*)pFirst;
+		void __near* p = *(void __near* __near*)pFirst;
+#ifdef __BORLANDC__
+		free(pFirst);
+#endif
+#ifdef __WATCOMC__
 		_nfree(pFirst);
-
+#endif
 		pFirst = p;
 	}
 	return total;
@@ -121,7 +193,7 @@ void far* HC_LargestFarFreeBlock(size_t* Size)
 	return p;
 }
 
-size_t HC_farcoreleft(void)
+size_t HC_farcoreleft_(void)
 {
 	size_t total = 0;
 	void far* pFirst = NULL;
@@ -156,8 +228,7 @@ size_t HC_farcoreleft(void)
 }
 
 #ifdef __WATCOMC__
-/*
-void huge* HC_LargestHugeFreeBlock(size_t* Size)
+/*void huge* LargestHugeFreeBlock(size_t* Size)
 {
 	size_t s0, s1;
 	void huge* p;
@@ -186,7 +257,7 @@ void huge* HC_LargestHugeFreeBlock(size_t* Size)
 	return p;
 }
 
-size_t HC_hugecoreleft(void)
+size_t _hugecoreleft(void)
 {
 	size_t total = 0;
 	void huge* pFirst = NULL;
@@ -194,7 +265,7 @@ size_t HC_hugecoreleft(void)
 	for(;;)
 	{
 		size_t largest;
-		void huge* p = HC_LargestHugeFreeBlock(&largest);
+		void huge* p = LargestHugeFreeBlock(&largest);
 		if (largest < sizeof(void huge*))
 		{
 			if (p != NULL)
@@ -257,7 +328,7 @@ size_t _basedcoreleft(void)
 	void __based(segu)* pFirst = NULL;
 	void __based(segu)* pLast = NULL;
 	// allocate based heap
-	segu = _bheapseg( 1024 );
+	segu = _bHC_heapseg( 1024 );
 	if( segu == _NULLSEG ) {
 		printf( "Unable to allocate based heap\n" );
 		return 0;
@@ -353,7 +424,7 @@ void HC_heapdump(global_game_variables_t *gvar)
 	struct _heapinfo fh_info, nh_info, h_info;
 	int heap_status;
 	size_t h_free, nh_free, fh_free, h_total, nh_total, fh_total, h_used, nh_used, fh_used;
-	byte    scratch[1024],str[16];
+	byte	scratch[1024],str[16];
 
 	HC_OpenDebug(gvar);
 
@@ -417,11 +488,11 @@ fh_info._pentry, fh_info._size );*/
 	printmeminfoline(&scratch, "Near", nh_total, nh_used, nh_free);
 	printmeminfoline(&scratch, "Far", fh_total, fh_used, fh_free);
 	strcat(scratch,"----------------  --------   --------   --------\n");
-	strcat(scratch,"coreleft = ");			ultoa((dword)HC_coreleft(),str,10);		strcat(scratch,str);	strcat(scratch,"\n");
-	strcat(scratch,"farcoreleft = ");		ultoa((dword)HC_farcoreleft(),str,10);	strcat(scratch,str);	strcat(scratch,"\n");
-	strcat(scratch,"GetFreeSize = ");		ultoa((dword)HC_GetFreeSize(),str,10);		strcat(scratch,str);	strcat(scratch,"\n");
-	strcat(scratch,"GetNearFreeSize = ");	ultoa((dword)HC_GetNearFreeSize(),str,10);	strcat(scratch,str);	strcat(scratch,"\n");
-	strcat(scratch,"GetFarFreeSize = "); 	ultoa((dword)HC_GetFarFreeSize(),str,10);	strcat(scratch,str);	strcat(scratch,"\n");
+	strcat(scratch,"HC_coreleft = ");			ultoa((dword)HC_coreleft(),str,10);		strcat(scratch,str);	strcat(scratch,"\n");
+	strcat(scratch,"HC_farcoreleft = ");		ultoa((dword)HC_farcoreleft(),str,10);	strcat(scratch,str);	strcat(scratch,"\n");
+	strcat(scratch,"HC_GetFreeSize = ");		ultoa((dword)HC_GetFreeSize(),str,10);		strcat(scratch,str);	strcat(scratch,"\n");
+	strcat(scratch,"HC_GetNearFreeSize = ");	ultoa((dword)HC_GetNearFreeSize(),str,10);	strcat(scratch,str);	strcat(scratch,"\n");
+	strcat(scratch,"HC_GetFarFreeSize = "); 	ultoa((dword)HC_GetFarFreeSize(),str,10);	strcat(scratch,str);	strcat(scratch,"\n");
 	strcat(scratch,"memavl = ");			ultoa((dword)_memavl(),str,10);			strcat(scratch,str);	strcat(scratch,"\n");
 	strcat(scratch,"stackavail = ");		ultoa((dword)stackavail(),str,10);		strcat(scratch,str);	strcat(scratch,"\n");
 	write(gvar->handle.heaphandle,scratch,strlen(scratch));
diff --git a/src/lib/16_hc.h b/src/lib/16_hc.h
index 1dac364b..5924d2a5 100755
--- a/src/lib/16_hc.h
+++ b/src/lib/16_hc.h
@@ -28,27 +28,20 @@
 
 #include "src/lib/16_head.h"
 
+long HC_farcoreleft();
 #ifdef __BORLANDC__
-#define CHIKAKU			near
-#define _nmalloc(size)          malloc(size)
-#define _nfree(block)           free(block)
-#define _nrealloc(block,size)   realloc(block,size)
-#define _ncalloc(num,size)      calloc(num,size)
-#define _nheapmin()             0
+void * HC_LargestFreeBlock(size_t* Size);
 #endif
 #ifdef __WATCOMC__
-//#define SETTOUJ I_CHIKAKU	_n
-#define CHIKAKU			__near
+void __near* HC_LargestFreeBlock(size_t* Size);
 #endif
-
-void CHIKAKU* HC_LargestFreeBlock(size_t* Size);
 size_t HC_coreleft(void);
 void far* HC_LargestFarFreeBlock(size_t* Size);
-size_t HC_farcoreleft(void);
-//void huge* HC_LargestHugeFreeBlock(size_t* Size);
-//size_t HC_hugecoreleft(void);
-//void __based(__self)* LargestBasedFreeBlock(size_t* Size);
-//size_t _basedcoreleft(void);
+size_t HC_farcoreleft_(void);
+/*void huge* LargestHugeFreeBlock(size_t* Size);
+size_t _hugecoreleft(void);
+void __based(__self)* LargestBasedFreeBlock(size_t* Size);
+size_t _basedcoreleft(void);*/
 size_t HC_GetFreeSize(void);
 size_t HC_GetFarFreeSize(void);
 size_t HC_GetNearFreeSize(void);
diff --git a/src/lib/16_head.c b/src/lib/16_head.c
index 2dadb971..20321e28 100755
--- a/src/lib/16_head.c
+++ b/src/lib/16_head.c
@@ -84,6 +84,8 @@ char *remove_ext (char* mystr, char dot, char sep) {
 	return retstr;
 }
 
+
+
 //from http://quiz.geeksforgeeks.org/c-program-cyclically-rotate-array-one/
 void rotateR(byte *arr, byte n)
 {
diff --git a/src/lib/16_head.h b/src/lib/16_head.h
index 251d0b6b..81af81c5 100755
--- a/src/lib/16_head.h
+++ b/src/lib/16_head.h
@@ -49,7 +49,6 @@
 #include <unistd.h>
 #include <alloca.h>
 #include <stdint.h> //16_vrs.h
-#include "src/lib/16_dbg.h"
 #endif
 #ifdef __BORLANDC__
 #include <values.h>
@@ -59,6 +58,7 @@
 #include "src/lib/16_t.h"
 #include "src/lib/16_tdef.h"
 #include "src/lib/nyan/kitten.h"
+#include "src/lib/16_dbg.h"
 
 #define VERSION __DATE__ " " __TIME__
 
@@ -161,11 +161,13 @@ extern	int			profilehandle,debughandle;	//make it into game global
 
 #define	nil	((void *)0)
 #ifdef __BORLANDC__
-#define _FCORELEFT 0x90000UL-16UL
+//#define _FCORELEFT 0x90000UL-16UL
+#define _FCORELEFT HC_farcoreleft()
 #define sprite
 #endif
 #ifdef __WATCOMC__
-#define _FCORELEFT 0x90000UL+16UL
+//#define _FCORELEFT 0x90000UL+16UL
+#define _FCORELEFT HC_farcoreleft()
 /*static union REGS CPURegs;
 
 #define _AX CPURegs.x.ax
diff --git a/src/lib/16_map.h b/src/lib/16_map.h
index 4c6b9a8c..abaf525f 100755
--- a/src/lib/16_map.h
+++ b/src/lib/16_map.h
@@ -31,9 +31,8 @@
 #include "src/lib/16_vl.h"
 #include "src/lib/16_ca.h"
 #include "src/lib/16_mm.h"
-#ifdef __WATCOMC__
 #include "src/lib/16_pm.h"
-#endif
+
 
 //#define DEBUG_MAPDATA
 //#define DEBUG_MAPVARS
diff --git a/src/lib/16_mm.c b/src/lib/16_mm.c
index 72ab5ae0..5f8bb38e 100755
--- a/src/lib/16_mm.c
+++ b/src/lib/16_mm.c
@@ -562,30 +562,7 @@ void MML_ShutdownXMS(global_game_variables_t *gvar)
 ======================
 */
 
-/*void MML_UseSpace(word segstart, dword seglength, global_game_variables_t *gvar)
-{
-	mmblocktype far *scan,far *last;
-	word		segm=1;
-	word	oldend;
-	dword		segmlen;
-	dword		extra;
-
-	scan = last = gvar->mm.mmhead;
-	gvar->mm.mmrover = gvar->mm.mmhead;		// reset rover to start of memory
-
-//
-// search for the block that contains the range of segments
-//
-	while(scan->start+scan->length < segstart)
-	{
-		last = scan;
-		scan = scan->next;
-	}
-
-//
-// take the given range out of the block
-//
-	oldend = scan->start + scan->length;
+/*
 	extra = oldend - (segstart+seglength);
 
 	segmlen=extra;
@@ -610,28 +587,7 @@ void MML_ShutdownXMS(global_game_variables_t *gvar)
 	printf("segmlen=%lu\n", segmlen);
 	}
 //++++todo: linked list of segment!
-	if(segstart == scan->start)
-	{
-		last->next = scan->next;			// unlink block
-		FREEBLOCK(scan);
-		scan = last;
-	}
-	else
-		scan->length = segstart-scan->start;	// shorten block
-
-	if(extra > 0)
-	{
-		GETNEWBLOCK;
-		gvar->mm.mmnew->useptr = NULL;
-
-		gvar->mm.mmnew->next = scan->next;
-		scan->next = gvar->mm.mmnew;
-		gvar->mm.mmnew->start = segstart+seglength;
-		gvar->mm.mmnew->length = extra;
-		gvar->mm.mmnew->attributes = LOCKBIT;
-	}//else if(segm>0) goto segu;
-
-}*/
+*/
 void MML_UseSpace(word segstart, dword seglength, global_game_variables_t *gvar)
 {
 	mmblocktype far *scan,far *last;
@@ -699,7 +655,7 @@ void MML_UseSpace(word segstart, dword seglength, global_game_variables_t *gvar)
 		gvar->mm.mmnew->start = segstart+seglength;
 		gvar->mm.mmnew->length = extra;
 		gvar->mm.mmnew->attributes = LOCKBIT;
-	}
+	}//else if(segm>0) goto segu;
 
 }
 
@@ -788,15 +744,15 @@ void MM_Startup(global_game_variables_t *gvar)
 #ifdef __WATCOMC__
 	_nheapgrow();
 #endif
-
-	length=(word)_memavl();//(word)coreleft();//(dword)GetFreeSize();
-
+	length=(word)_memavl();//(word)coreleft();
+	//start = gvar->mm.nearheap = _fmalloc(length);
 #ifdef __WATCOMC__
 	start = (void __far *)(gvar->mm.nearheap = _nmalloc(length));
 #endif
 #ifdef __BORLANDC__
 	start = (void far *)(gvar->mm.nearheap = malloc(length));
 #endif
+
 	length -= 16-(FP_OFF(start)&15);
 	length -= SAVENEARHEAP;
 	seglength = length / 16;			// now in paragraphs
@@ -808,18 +764,16 @@ void MM_Startup(global_game_variables_t *gvar)
 //
 // get all available far conventional memory segments
 //
-	//printf("_FARCORELEFT				%lu\n", _FCORELEFT);
 #ifdef __WATCOMC__
 	_fheapgrow();
-	length=_FCORELEFT;//_fcoreleft();//(dword)GetFarFreeSize();//0xffffUL*4UL;
 #endif
 #ifdef __BORLANDC__
-//0000	printf("farcoreleft()				%lu\n", farcoreleft());
-//0000	printf("(farcoreleft()+32)-_FCORELEFT	%d\n", (sword)((farcoreleft()+32)-_FCORELEFT));
-	length=farcoreleft();//_fcoreleft();//(dword)GetFarFreeSize();//0xffffUL*4UL;
+//	printf("farcoreleft()				%lu\n", farcoreleft());
+//	printf("(farcoreleft()+32)-_FCORELEFT	%d\n", (sword)((farcoreleft()+32)-_FCORELEFT));
 #endif
-	start = gvar->mm.farheap = _fmalloc(length);
-	//start = gvar->mm.farheap = halloc(length, 1);
+	length=_FCORELEFT;
+	start = gvar->mm.farheap = _fmalloc(length);//start = gvar->mm.farheap = halloc(length, 1);
+
 	length -= 16-(FP_OFF(start)&15);
 	length -= SAVEFARHEAP;
 	seglength = length / 16;			// now in paragraphs
@@ -941,11 +895,13 @@ void MM_GetPtr (memptr *baseptr, dword size, global_game_variables_t *gvar)
 	gvar->mm.mmnew->useptr = baseptr;
 	//if(gvar->mm.mmnew->useptr==NULL){
 #ifdef __DEBUG_MM__
+	if(dbg_debugmm>0){
 		printf("MM_GetPtr\n");
 		//%04x
 		printf("	baseptr=%Fp	", baseptr); printf("useptr=%Fp\n", gvar->mm.mmnew->useptr);
 		printf("	*baseptr=%Fp	", *baseptr); printf("*useptr=%Fp\n", *(gvar->mm.mmnew->useptr));
 		printf("	&baseptr=%Fp	", &baseptr); printf("&useptr=%Fp\n", &(gvar->mm.mmnew->useptr));
+	}
 #endif
 	//Quit(gvar, "gvar->mm.mmnew->useptr==NULL"); }
 	gvar->mm.mmnew->attributes = BASEATTRIBUTES;
@@ -1062,8 +1018,8 @@ void MM_FreePtr(memptr *baseptr, global_game_variables_t *gvar)
 
 	if(!scan)
 	{
-		printf("MM_FreePtr: Block not found!\n");
-		return;
+		Quit(gvar, "MM_FreePtr: Block not found!\n");
+		//printf("MM_FreePtr: Block not found!\n"); return;
 	}
 
 	last->next = scan->next;
@@ -1441,7 +1397,12 @@ void MM_DumpData(global_game_variables_t *gvar)
 	byte	lock,purge;
 	FILE	*dumpfile;
 
+#ifdef __WATCOMC__
+	_nfree(gvar->mm.nearheap);
+#endif
+#ifdef __BORLANDC__
 	free(gvar->mm.nearheap);
+#endif
 #ifdef __BORLANDC__
 		dumpfile = fopen ("mmdump.16b","w");
 #endif
diff --git a/src/lib/16_t.h b/src/lib/16_t.h
index 0a6dff9a..d04b382d 100755
--- a/src/lib/16_t.h
+++ b/src/lib/16_t.h
@@ -53,19 +53,18 @@ memptr should be replaced by memseg in code.
 on usage where you need pointer convert memseg type (segment) to far pointer by
 MK_FP(segment value, 0)*/
 #ifdef __WATCOMC__
+//typedef void __based( void ) * memptr;	////old //----typedef void __based(__self) * memptr;
 //typedef unsigned short _seg; // it will contains segment value (as Borland _seg)
 #define _seg __based( void )
 #define __SEGA __segment
 #endif
 #ifdef __BORLANDC__
-//typedef void _seg * memptr;
+#define _memavl()               coreleft()
 #define __SEGA _seg
 #endif
 
-typedef void _seg * memptr;//typedef void __based( void ) * memptr;	////old //----typedef void __based(__self) * memptr;
-#ifdef __BORLANDC__
-#define _memavl()               coreleft()
-#endif
+typedef void _seg * memptr;
+
 #ifdef __WATCOMC__
 #define _argv __argv
 #define _argc __argc
diff --git a/src/lib/16_tail.h b/src/lib/16_tail.h
index a07d5ec3..08c03d0a 100755
--- a/src/lib/16_tail.h
+++ b/src/lib/16_tail.h
@@ -29,6 +29,7 @@
 #include "src/lib/16_mm.h"
 #include "src/lib/16_ca.h"
 #include "src/lib/16_in.h"
+#include "src/lib/16_dbg.h"
 #include "src/lib/16_vl.h"
 #include "src/lib/testpatt.h"
 
diff --git a/src/lib/16_tdef.h b/src/lib/16_tdef.h
index 28f35c01..dbda778a 100755
--- a/src/lib/16_tdef.h
+++ b/src/lib/16_tdef.h
@@ -376,7 +376,7 @@ typedef struct
 	boolean		mmstarted, bombonerror, mmerror;
 	void far	*farheap;
 #ifdef __BORLANDC__
-	void far	*nearheap;
+	void		*nearheap;
 #endif
 #ifdef __WATCOMC__
 	void __near	*nearheap;
@@ -493,7 +493,7 @@ typedef struct
 					PMNumBlocks;
 	long			PMFrameCount;
 	PageListStruct	far *PMPages;
-	__SEGA *PMSegPages;
+	memptr/*__SEGA*/ *PMSegPages;
 	pm_mmi_t	mm;
 	pm_emmi_t	emm;
 	pm_xmmi_t	xmm;