MPLIB.CPP 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. //
  2. // Copyright 2020 Electronic Arts Inc.
  3. //
  4. // TiberianDawn.DLL and RedAlert.dll and corresponding source code is free
  5. // software: you can redistribute it and/or modify it under the terms of
  6. // the GNU General Public License as published by the Free Software Foundation,
  7. // either version 3 of the License, or (at your option) any later version.
  8. // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
  9. // in the hope that it will be useful, but with permitted additional restrictions
  10. // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
  11. // distributed with this program. You should have received a copy of the
  12. // GNU General Public License along with permitted additional restrictions
  13. // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
  14. #include "types.h"
  15. #include "mgenord.h"
  16. #include "magic.h"
  17. #include "rtq.h"
  18. #include <mem.h>
  19. #include <i86.h>
  20. #include <assert.h>
  21. #include "mplib.h"
  22. #define CHUNNEL_INT 0x48
  23. typedef union REGS REGISTERS;
  24. void
  25. Yield(void)
  26. {
  27. REGISTERS regs;
  28. regs.w.ax = 0x1680;
  29. int386(0x2f, &regs, &regs);
  30. }
  31. void
  32. PostWindowsMessage(void)
  33. {
  34. REGISTERS regs;
  35. regs.x.eax = DPMIAPI_POST_WINDOWS_ORD << 16 | MGENVXD_DEVICE_ID;
  36. regs.x.ebx = 0;
  37. regs.x.ecx = 0;
  38. int386(CHUNNEL_INT, &regs, &regs);
  39. }
  40. int MGenGetQueueCtr(int qNo)
  41. {
  42. REGISTERS regs;
  43. regs.x.eax = MGENVXD_GETQUEUECTR_ORD << 16 | MGENVXD_DEVICE_ID;
  44. regs.x.ebx = qNo;
  45. int386(CHUNNEL_INT, &regs, &regs);
  46. return regs.x.eax;
  47. }
  48. RTQ_NODE *MGenMoveTo(int qFrom, int qTo)
  49. {
  50. REGISTERS regs;
  51. regs.x.eax = MGENVXD_MOVENODE_ORD << 16 | MGENVXD_DEVICE_ID;
  52. regs.x.ebx = qFrom;
  53. regs.x.ecx = qTo;
  54. int386(CHUNNEL_INT, &regs, &regs);
  55. return (RTQ_NODE *) regs.x.eax;
  56. }
  57. RTQ_NODE *MGenGetNode(int q)
  58. {
  59. REGISTERS regs;
  60. regs.x.eax = MGENVXD_GETNODE_ORD << 16 | MGENVXD_DEVICE_ID;
  61. regs.x.ebx = q;
  62. int386(CHUNNEL_INT, &regs, &regs);
  63. return (RTQ_NODE *) regs.x.eax;
  64. }
  65. RTQ_NODE *MGenGetMasterNode(unsigned *size)
  66. {
  67. REGISTERS regs;
  68. regs.x.eax = MGENVXD_MASTERNODE_ORD << 16 | MGENVXD_DEVICE_ID;
  69. int386(CHUNNEL_INT, &regs, &regs);
  70. *size = regs.x.ecx;
  71. return (RTQ_NODE *) regs.x.eax;
  72. }
  73. int MGenFlushNodes(int qFrom, int qTo)
  74. {
  75. REGISTERS regs;
  76. regs.x.eax = MGENVXD_FLUSHNODE_ORD << 16 | MGENVXD_DEVICE_ID;
  77. regs.x.ebx = qFrom;
  78. regs.x.ecx = qTo;
  79. int386(CHUNNEL_INT, &regs, &regs);
  80. return regs.x.eax;
  81. }
  82. int MGenMCount(unsigned lowerOrderBits, unsigned upperOrderBits)
  83. {
  84. REGISTERS regs;
  85. regs.x.eax = MGENVXD_MCOUNT_ORD << 16 | MGENVXD_DEVICE_ID;
  86. regs.x.ebx = lowerOrderBits;
  87. regs.x.ecx = upperOrderBits;
  88. int386(CHUNNEL_INT, &regs, &regs);
  89. return regs.x.eax;
  90. }
  91. int MGenSanityCheck(void)
  92. {
  93. REGISTERS regs;
  94. regs.x.eax = MGENVXD_SANITYCHECK_ORD << 16 | MGENVXD_DEVICE_ID;
  95. int386(CHUNNEL_INT, &regs, &regs);
  96. return regs.x.eax;
  97. }
  98.