1 ////////////////////////////////////////////////////
3 // XMS routines - uses the MENU.C & LIB.C routines for output
5 ////////////////////////////////////////////////////
14 ////////////////////////////////////////////////////
16 // CALL the XMSdriver with a function #
18 ////////////////////////////////////////////////////
19 void CallXMS(char func)
22 asm call [DWORD PTR XMSdriver]
25 ////////////////////////////////////////////////////
27 // Initialize the XMS memory
29 ////////////////////////////////////////////////////
33 // See if XMS driver is present...
37 asm cmp al,0x80 // installed?
40 ErrDialog("You poor bastard! I refuse\n"
41 "to work without Extended\n"
42 "Memory! Goodbye!"," I Suck ");
43 Quit("No Extended Memory Driver found!");
46 // YES! We found an XMS driver! Now we
47 // need to get the XMS driver's entry address...
52 asm mov WORD PTR XMSdriver,bx
53 asm mov WORD PTR XMSdriver+2,es
59 ////////////////////////////////////////////////////
61 // Report an XMS error, if any
63 ////////////////////////////////////////////////////
69 case 0x80: Quit("Function not implemented!");
70 case 0x81: Quit("VDISK device driver was detected!");
71 case 0x82: Quit("A20 error occurred!");
72 case 0x8e: Quit("General driver error!");
73 case 0x8f: Quit("Unrecoverable driver error!");
75 case 0x90: Quit("High memory area does not exist!");
76 case 0x91: Quit("High memory area already in use!");
77 case 0x92: Quit("DX is less than /HMAMIN= parameter!");
78 case 0x93: Quit("High memory area not allocated!");
79 case 0x94: Quit("A20 line still enabled!");
81 case 0xa0: Quit("Not enough Extended Memory available!");
82 case 0xa1: Quit("Extended memory handles exhausted!");
83 case 0xa2: Quit("Invalid handle!");
84 case 0xa3: Quit("Invalid source handle!");
85 case 0xa4: Quit("Invalid source offset!");
86 case 0xa5: Quit("Invalid destination handle!");
87 case 0xa6: Quit("Invalid destination offset!");
88 case 0xa7: Quit("Invalid length!");
89 case 0xa8: Quit("Invalid overlap in move request!");
90 case 0xa9: Quit("Parity error detected!");
91 case 0xaa: Quit("Block is not locked!");
92 case 0xab: Quit("Block is locked!");
93 case 0xac: Quit("Lock count overflowed!");
94 case 0xad: Quit("Lock failed!");
96 case 0xb0: Quit("Smaller UMB is available!");
97 case 0xb1: Quit("No UMBs are available!");
98 case 0xb2: Quit("Invalid UMB segment number!");
100 default: Quit("Unknown XMS Memory Error! I'm totally stumped!");
104 ////////////////////////////////////////////////////
106 // Allocate XMS memory
108 ////////////////////////////////////////////////////
109 int XMSAllocate(long size)
112 static int allocnum=0;
117 print("XMS allocation #");
118 printint(allocnum++);
120 printint((1023L+size)/1024L);
122 while(!keydown[0x1c]);
128 _DX=(size+1023)/1024;
132 TTLxms=1024L*XMSTotalFree();
137 ////////////////////////////////////////////////////
141 ////////////////////////////////////////////////////
142 void XMSFreeMem(int handle)
147 TTLxms=1024L*XMSTotalFree();
151 ////////////////////////////////////////////////////
153 // Return XMS memory available
155 ////////////////////////////////////////////////////
156 unsigned XMSTotalFree(void)
164 ////////////////////////////////////////////////////
168 ////////////////////////////////////////////////////
169 void XMSmove(int srchandle,long srcoff,int desthandle,long destoff,long size)
178 unsigned DSreg,SIreg;
180 XMSparms.bsize=size+(size&1);
181 XMSparms.shandle=srchandle;
182 XMSparms.dhandle=desthandle;
183 XMSparms.soff=srcoff;
184 XMSparms.doff=destoff;
186 DSreg=FP_SEG(&XMSparms);
187 SIreg=FP_OFF(&XMSparms);