ppovin.pas 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. {
  2. $Id$
  3. Copyright (c) 1997-98 by Daniel Mantione
  4. Handles the overlay initialisation for a TP7 compiled version
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************
  17. }
  18. unit ppovin;
  19. interface
  20. var
  21. ovrminsize:longint;
  22. procedure InitOverlay;
  23. implementation
  24. uses overlay;
  25. function _heaperror(size:word):integer;far;
  26. type
  27. heaprecord=record
  28. next:pointer;
  29. values:longint;
  30. end;
  31. var
  32. l,m:longint;
  33. begin
  34. l:=ovrgetbuf-ovrminsize;
  35. if (size>maxavail) and (l>=size) then
  36. begin
  37. m:=((longint(size)+$3fff) and $ffffc000);
  38. {Clear the overlay buffer.}
  39. ovrclearbuf;
  40. {Shrink it.}
  41. ovrheapend:=ovrheapend-m shr 4;
  42. heaprecord(ptr(ovrheapend,0)^).next:=freelist;
  43. heaprecord(ptr(ovrheapend,0)^).values:=m shl 12;
  44. heaporg:=ptr(ovrheapend,0);
  45. freelist:=heaporg;
  46. Writeln('Warning: Overlay buffer shrinked, because of memory shortage');
  47. _heaperror:=2;
  48. end
  49. else
  50. _heaperror:=0;
  51. end;
  52. procedure InitOverlay;
  53. begin
  54. heaperror:=@_heaperror;
  55. end;
  56. var
  57. s:string;
  58. begin
  59. s:=paramstr(0);
  60. ovrinit(copy(s,1,length(s)-3)+'ovr');
  61. if ovrresult=ovrok then
  62. begin
  63. {May fail if no EMS memory is available. No need for error
  64. checking, though, as the overlay manager happily runs without
  65. EMS.}
  66. ovrinitEMS;
  67. ovrminsize:=ovrgetbuf;
  68. ovrsetbuf(ovrminsize+$20000);
  69. end
  70. else
  71. runerror($da);
  72. end.
  73. {
  74. $Log$
  75. Revision 1.2 1998-08-10 10:18:33 peter
  76. + Compiler,Comphook unit which are the new interface units to the
  77. compiler
  78. }