XMODEPG.CPP 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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. /****************************************************************************
  19. *
  20. * 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
  21. *
  22. *----------------------------------------------------------------------------
  23. *
  24. * FILE
  25. * xmodepg.c
  26. *
  27. * DESCRIPTION
  28. * Xmode page access. (32-Bit protected mode)
  29. *
  30. * PROGRAMMER
  31. * Bill Randolph
  32. * Denzil E. Long, Jr.
  33. *
  34. * DATE
  35. * January 26, 1995
  36. *
  37. *----------------------------------------------------------------------------
  38. *
  39. * PUBLIC
  40. * SetupXPaging - Setup Xmode paging variables.
  41. * FlipXPage - Page flip to next Xmode page.
  42. * ShowXPage - Show the specified Xmode page.
  43. * GetXHidPage - Get the address of the current Xmode HidPage.
  44. * GetXSeenPage - Get the address of the current Xmode SeenPage.
  45. *
  46. ****************************************************************************/
  47. #include <dos.h>
  48. #include "video.h"
  49. /*---------------------------------------------------------------------------
  50. * PRIVATE DECLARATIONS
  51. *-------------------------------------------------------------------------*/
  52. #define PAGE0_START_OFFSET 0
  53. #define PAGE1_START_OFFSET ((320 * 240) / 4)
  54. /* PageFlip page values. */
  55. static unsigned long PageStartOffsets[2] = {
  56. PAGE0_START_OFFSET,
  57. PAGE1_START_OFFSET
  58. };
  59. static long DisplayedPage;
  60. static long NonDisplayedPage;
  61. /****************************************************************************
  62. *
  63. * NAME
  64. * SetupXPaging - Setup Xmode paging variables.
  65. *
  66. * SYNOPSIS
  67. * SetupXPaging()
  68. *
  69. * void SetupXPaging(void);
  70. *
  71. * FUNCTION
  72. *
  73. * INPUTS
  74. * NONE
  75. *
  76. * RESULT
  77. * NONE
  78. *
  79. ****************************************************************************/
  80. void SetupXPaging(void)
  81. {
  82. DisplayedPage = 1;
  83. NonDisplayedPage = DisplayedPage ^ 1;
  84. }
  85. /****************************************************************************
  86. *
  87. * NAME
  88. * FlipXPage - Page flip to next Xmode page.
  89. *
  90. * SYNOPSIS
  91. * FlipXPage()
  92. *
  93. * void FlipXPage(void);
  94. *
  95. * FUNCTION
  96. *
  97. * INPUTS
  98. * NONE
  99. *
  100. * RESULT
  101. * NONE
  102. *
  103. ****************************************************************************/
  104. void FlipXPage(void)
  105. {
  106. ShowXPage(PageStartOffsets[NonDisplayedPage]);
  107. DisplayedPage = NonDisplayedPage;
  108. NonDisplayedPage = DisplayedPage ^ 1;
  109. }
  110. /****************************************************************************
  111. *
  112. * NAME
  113. * ShowXPage - Show the specified Xmode page.
  114. *
  115. * SYNOPSIS
  116. * ShowXPage(page)
  117. *
  118. * void ShowXPage(long);
  119. *
  120. * FUNCTION
  121. *
  122. * INPUTS
  123. * Page - Xmode page number to show.
  124. *
  125. * RESULT
  126. * NONE
  127. *
  128. ****************************************************************************/
  129. void DisplayXPage(long page)
  130. {
  131. ShowXPage(PageStartOffsets[page & 1]);
  132. DisplayedPage = page;
  133. NonDisplayedPage = DisplayedPage ^ 1;
  134. }
  135. /****************************************************************************
  136. *
  137. * NAME
  138. * GetXHidPage - Get the address of the current Xmode HidPage.
  139. *
  140. * SYNOPSIS
  141. * HidPage = GetXHidPage()
  142. *
  143. * unsigned char *GetXHidPage(void);
  144. *
  145. * FUNCTION
  146. *
  147. * INPUTS
  148. * NONE
  149. *
  150. * RESULT
  151. * HidPage - Address of Xmode HidPage.
  152. *
  153. ****************************************************************************/
  154. unsigned char *GetXHidPage(void)
  155. {
  156. return((unsigned char *)PageStartOffsets[NonDisplayedPage]);
  157. }
  158. /****************************************************************************
  159. *
  160. * NAME
  161. * GetXSeenPage - Get the address of the current Xmode SeenPage.
  162. *
  163. * SYNOPSIS
  164. * SeenPage = GetXSeenPage()
  165. *
  166. * unsigned char *GetXSeenPage(void);
  167. *
  168. * FUNCTION
  169. *
  170. * INPUTS
  171. * NONE
  172. *
  173. * RESULT
  174. * SeePage - Address of the Xmode SeenPage.
  175. *
  176. ****************************************************************************/
  177. unsigned char *GetXSeenPage(void)
  178. {
  179. return ((unsigned char *)PageStartOffsets[DisplayedPage]);
  180. }