home *** CD-ROM | disk | FTP | other *** search
- { SPX Library Version 3.0 Copyright 1993 Scott D. Ramsay }
-
- SPX_EMS is a simple expanded memory unit. It calls only the basic expanded
- memory manager interrupt functions. Does not work in protected mode
-
- Expanded memory is accessed through a 64k window. When you want to
- access or place data in expanded memory, the at least 16k of the window
- must be mapped "point" to its location. Once the window is mapped, you can
- place or read data from the window location and the memory managager
- automatically does the transfer.
-
- ───────────────────────────────────────────────────────────────────────────
- function emsINSTALLED:boolean;
-
- Returns TRUE if expanded memory is installed.
- ───────────────────────────────────────────────────────────────────────────
- procedure emsVERSION(var st:string);
-
- Returns the expanded memory version string
-
- st String name of the memory version
- ───────────────────────────────────────────────────────────────────────────
- function emsSTATUS:boolean;
-
- Returns TRUE if expanded memory is ok.
- ───────────────────────────────────────────────────────────────────────────
- procedure emsPAGES(var totalpages,pagesavailable:word);
-
- Gets the number of 16k pages of expanded memory you have and how
- many are free.
-
- totalpages Number of 16k pages are free
- pagesavailable Number of pages available
- ───────────────────────────────────────────────────────────────────────────
- procedure emsADDRESS(var address:word);
-
- Get the segment address of the 64k window.
-
- address segment address of the 64k window
-
- The offset of the 64k window always ranges from 0 to $FFFF (64k) ;)
- ───────────────────────────────────────────────────────────────────────────
- procedure emsGETMEM(pagesneeded:word;var handle:word);
-
- Allocates expanded memory. Retuns a handle value to the allocated area.
-
- pagesneeded The number of 16k pages to allocate
- handle The handle to the number of pages.
- ───────────────────────────────────────────────────────────────────────────
- procedure emsFREEMEM(handle:word);
-
- Deallocates expanded memory. All allocated memory must be deallocated
- after use or program end. Expanded memory is not automatically deallocated
- at program exit.
- ───────────────────────────────────────────────────────────────────────────
- procedure emsMAP(handle,logicalpage,physicalpage:word);
-
- Map expanded memory to the 64k window.
-
- handle Handle to the allocated memory to map
- logicalpage Logical page of the memory. Always (0..n)
- where n = number_of_pages_allocated - 1;
- physicalpage Physical page of the window. Always (0..3)
- where 0..3 specifies the 16k region of the
- window.
- ───────────────────────────────────────────────────────────────────────────
- uses spx_ems;
-
- var
- segment, { 64k window address }
- handle, { allocated handle }
- tp,pa, { total pages, pages available }
- na : word; { number of pages to allocate }
- d : integer; { counter }
- s : string; { test data }
- begin
- if not emsINSTALLED { check for expanded memory }
- then
- begin
- writeln('No expanded memory');
- halt;
- end;
- emsADDRESS(segment); { get window segment }
- emsPAGES(tp,pa); { get expanded size }
- writeln('expanded memory');
- writeln(' Total : ',longint(tp)*$FFFF,' bytes');
- writeln(' Free : ',longint(pa)*$FFFF,' bytes');
- if pa=0
- then
- begin
- writeln('You have no expanded memory free');
- halt;
- end;
- na := 4; { Allocate 64k byte }
- if na>pa
- then na := pa; { make sure we only allocate up to what is available }
- emsGETMEM(handle,na); { allocate some memory }
- emsMAP(handle,0,0); { map 16k of ems memory to 1st 16k of window }
- s := 'This is a test'; { test data }
- move(s,mem[segment:0],sizeof(s)); { move string to 1st 16k in window }
- s := ''; { clear S }
- move(mem[segment:0],s,sizeof(s)); { move ems memory to S }
- writeln(s);
- emsFREEMEM(handle); { deallocate expanded memory }
- end.
-