go32smsg.inc 2.1 KB

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