DPMI.CPP 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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. /* $Header: F:\projects\c&c0\vcs\code\dpmi.cpv 4.41 04 Jul 1996 16:12:42 JOE_BOSTIC $ */
  15. /***********************************************************************************************
  16. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  17. ***********************************************************************************************
  18. * *
  19. * Project Name : Command & Conquer *
  20. * *
  21. * File Name : DPMI.CPP *
  22. * *
  23. * Programmer : Joe L. Bostic *
  24. * *
  25. * Start Date : July 2, 1994 *
  26. * *
  27. * Last Update : July 2, 1994 [JLB] *
  28. * *
  29. *---------------------------------------------------------------------------------------------*
  30. * Functions: *
  31. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  32. #if (0)
  33. #ifdef __FLAT__
  34. #pragma inline
  35. #endif
  36. //#include "function.h"
  37. #include "dpmi.h"
  38. #ifndef __FLAT__
  39. void DOSSegmentClass::Swap(DOSSegmentClass &src, int soffset, DOSSegmentClass &dest, int doffset, int size)
  40. {
  41. if (!size) return;
  42. unsigned short ssel = src.Selector;
  43. unsigned short dsel = dest.Selector;
  44. asm {
  45. push es
  46. push ds
  47. mov si,soffset
  48. mov di,doffset
  49. mov cx,size
  50. mov ax,ssel
  51. mov dx,dsel
  52. mov ds,ax
  53. mov es,dx
  54. }
  55. again:
  56. asm {
  57. mov al,ds:[si]
  58. mov ah,es:[di]
  59. mov ds:[si],ah
  60. mov es:[di],al
  61. inc di
  62. inc si
  63. dec cx
  64. jnz again
  65. pop ds
  66. pop es
  67. }
  68. }
  69. #endif
  70. void DOSSegmentClass::Swap(DOSSegmentClass &src, int soffset, DOSSegmentClass &dest, int doffset, int size)
  71. {
  72. extern void dss_swap(char *src, char *dest, int size);
  73. #pragma aux dss_swap = \
  74. "again: mov al,[esi]" \
  75. "mov ah,[edi]" \
  76. "mov [esi],ah" \
  77. "stosb" \
  78. "inc esi" \
  79. "loop again" \
  80. parm [esi] [edi] [ecx] \
  81. modify [ax];
  82. if (!size) return;
  83. dss_swap((char *)(src.Selector + soffset), (char *)(dest.Selector + doffset), size);
  84. }
  85. #ifdef OBSOLETE
  86. void DOSSegmentClass::Copy(DOSSegmentClass &src, int soffset, DOSSegmentClass &dest, int doffset, int size)
  87. {
  88. extern void dss_copy(char *src, char *dest, int size);
  89. #pragma aux dss_copy = \
  90. "mov ebx,ecx" \
  91. "shr ecx,2" \
  92. "jecxz copskip1" \
  93. "rep movsd" \
  94. "copskip1: mov ecx,ebx" \
  95. "and ecx,3" \
  96. "jecxz copskip2" \
  97. "rep movsb" \
  98. "copskip2:" \
  99. parm [esi edi ecx] \
  100. modify [ebx];
  101. if (!size) return;
  102. dss_copy((char *)(src.Selector + soffset), (char *)(dest.Selector + doffset), size);
  103. }
  104. #endif
  105. #ifdef OBSOLETE
  106. void DOSSegmentClass::Copy_To(void *source, int dest, int size)
  107. {
  108. extern void dss_copy_to(void *src, (void *)dest, int size);
  109. #pragma aux dss_copy_to = \
  110. "mov ebx,ecx" \
  111. "shr ecx,2" \
  112. "jecxz cop2skip1" \
  113. "rep movsd" \
  114. "cop2skip1: mov ecx,ebx" \
  115. "and ecx,3" \
  116. "jecxz cop2skip2" \
  117. "rep movsb" \
  118. "cop2skip2:" \
  119. parm [esi edi ecx] \
  120. modify [ebx];
  121. if (!size) return;
  122. dss_copy_to(src, (void *)(Selector + dest), size);
  123. }
  124. #endif
  125. #ifdef OBSOLETE
  126. void DOSSegmentClass::Copy_From(void *dest, int source, int size)
  127. {
  128. extern void dss_copy_from(void *dest, (void *)source, int size);
  129. #pragma aux dss_copy_from = \
  130. "mov ebx,ecx" \
  131. "shr ecx,2" \
  132. "jecxz copfskip1" \
  133. "rep movsd" \
  134. "copfskip1: mov ecx,ebx" \
  135. "and ecx,3" \
  136. "jecxz copfskip2" \
  137. "rep movsb" \
  138. "copfskip2:" \
  139. parm [edi esi ecx] \
  140. modify [ebx];
  141. if (!size) return;
  142. dss_copy_from(dest, (void *)(Selector + source), size);
  143. }
  144. #endif
  145. #endif