ppovin.pas 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. {
  2. $Id$
  3. Copyright (c) 1998-2000 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 was shrunk 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. { only for real mode TP : runerror ok here PM }
  72. runerror($da);
  73. end.
  74. {
  75. $Log$
  76. Revision 1.6 2000-02-09 13:22:59 peter
  77. * log truncated
  78. Revision 1.5 2000/01/07 01:14:30 peter
  79. * updated copyright to 2000
  80. Revision 1.4 1999/09/16 11:34:58 pierre
  81. * typo correction
  82. }