MPLIB.CPP 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /*
  2. ** Command & Conquer Red Alert(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  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 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #include "types.h"
  19. #include "mgenord.h"
  20. #include "magic.h"
  21. #include "rtq.h"
  22. #include <mem.h>
  23. #include <i86.h>
  24. #include <assert.h>
  25. #include "mplib.h"
  26. #define CHUNNEL_INT 0x48
  27. typedef union REGS REGISTERS;
  28. void
  29. Yield(void)
  30. {
  31. REGISTERS regs;
  32. regs.w.ax = 0x1680;
  33. int386(0x2f, &regs, &regs);
  34. }
  35. void
  36. PostWindowsMessage(void)
  37. {
  38. REGISTERS regs;
  39. regs.x.eax = DPMIAPI_POST_WINDOWS_ORD << 16 | MGENVXD_DEVICE_ID;
  40. regs.x.ebx = 0;
  41. regs.x.ecx = 0;
  42. int386(CHUNNEL_INT, &regs, &regs);
  43. }
  44. int MGenGetQueueCtr(int qNo)
  45. {
  46. REGISTERS regs;
  47. regs.x.eax = MGENVXD_GETQUEUECTR_ORD << 16 | MGENVXD_DEVICE_ID;
  48. regs.x.ebx = qNo;
  49. int386(CHUNNEL_INT, &regs, &regs);
  50. return regs.x.eax;
  51. }
  52. RTQ_NODE *MGenMoveTo(int qFrom, int qTo)
  53. {
  54. REGISTERS regs;
  55. regs.x.eax = MGENVXD_MOVENODE_ORD << 16 | MGENVXD_DEVICE_ID;
  56. regs.x.ebx = qFrom;
  57. regs.x.ecx = qTo;
  58. int386(CHUNNEL_INT, &regs, &regs);
  59. return (RTQ_NODE *) regs.x.eax;
  60. }
  61. RTQ_NODE *MGenGetNode(int q)
  62. {
  63. REGISTERS regs;
  64. regs.x.eax = MGENVXD_GETNODE_ORD << 16 | MGENVXD_DEVICE_ID;
  65. regs.x.ebx = q;
  66. int386(CHUNNEL_INT, &regs, &regs);
  67. return (RTQ_NODE *) regs.x.eax;
  68. }
  69. RTQ_NODE *MGenGetMasterNode(unsigned *size)
  70. {
  71. REGISTERS regs;
  72. regs.x.eax = MGENVXD_MASTERNODE_ORD << 16 | MGENVXD_DEVICE_ID;
  73. int386(CHUNNEL_INT, &regs, &regs);
  74. *size = regs.x.ecx;
  75. return (RTQ_NODE *) regs.x.eax;
  76. }
  77. int MGenFlushNodes(int qFrom, int qTo)
  78. {
  79. REGISTERS regs;
  80. regs.x.eax = MGENVXD_FLUSHNODE_ORD << 16 | MGENVXD_DEVICE_ID;
  81. regs.x.ebx = qFrom;
  82. regs.x.ecx = qTo;
  83. int386(CHUNNEL_INT, &regs, &regs);
  84. return regs.x.eax;
  85. }
  86. int MGenMCount(unsigned lowerOrderBits, unsigned upperOrderBits)
  87. {
  88. REGISTERS regs;
  89. regs.x.eax = MGENVXD_MCOUNT_ORD << 16 | MGENVXD_DEVICE_ID;
  90. regs.x.ebx = lowerOrderBits;
  91. regs.x.ecx = upperOrderBits;
  92. int386(CHUNNEL_INT, &regs, &regs);
  93. return regs.x.eax;
  94. }
  95. int MGenSanityCheck(void)
  96. {
  97. REGISTERS regs;
  98. regs.x.eax = MGENVXD_SANITYCHECK_ORD << 16 | MGENVXD_DEVICE_ID;
  99. int386(CHUNNEL_INT, &regs, &regs);
  100. return regs.x.eax;
  101. }
  102.