go32smsg.inc 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. {
  2. System independent system interface for go32v2
  3. Copyright (c) 2000 by Pierre Muller
  4. This library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public
  6. License as published by the Free Software Foundation; either
  7. version 2 of the License, or (at your option) any later version.
  8. This library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Library General Public License for more details.
  12. You should have received a copy of the GNU Library General Public
  13. License along with this library; if not, write to the Free
  14. Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. }
  16. Const
  17. SystemEventActive : Boolean = false;
  18. procedure InitSystemMsg;
  19. var
  20. res : word;
  21. begin
  22. if SystemEventActive then
  23. exit;
  24. { enable close }
  25. asm
  26. movl $0x168f,%eax
  27. movl $1,%edx
  28. int $0x2f
  29. movw %ax,Res
  30. end;
  31. SystemEventActive:=(Res=0);
  32. end;
  33. procedure DoneSystemMsg;
  34. begin
  35. if not SystemEventActive then
  36. exit;
  37. { disable close }
  38. asm
  39. movl $0x168f,%eax
  40. movl $0,%edx
  41. int $0x2f
  42. end;
  43. SystemEventActive:=false;
  44. end;
  45. procedure GetSystemEvent(var SystemEvent: TSystemEvent);
  46. begin
  47. PollSystemEvent(SystemEvent);
  48. end;
  49. function PollSystemEvent(var SystemEvent: TSystemEvent):boolean;
  50. var
  51. CloseState : word;
  52. begin
  53. SystemEvent.typ:=SysNothing;
  54. if not SystemEventActive then
  55. exit(false);
  56. { Query close }
  57. asm
  58. movl $0x168f,%eax
  59. movl $100,%edx
  60. int $0x2f
  61. movw %ax,CloseState
  62. end;
  63. if (CloseState = 0) then
  64. begin
  65. { acknowledge Close }
  66. asm
  67. movl $0x168f,%eax
  68. movl $200,%edx
  69. int $0x2f
  70. movw %ax,CloseState
  71. end;
  72. { non zero means error ! }
  73. if CloseState=0 then
  74. begin
  75. PollSystemEvent:=true;
  76. SystemEvent.typ:=SysClose;
  77. end;
  78. end;
  79. end;