STARTUP.CPP 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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. ** 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 **
  20. ***************************************************************************
  21. * *
  22. * Project Name : Library startup routine. *
  23. * *
  24. * File Name : STARTUP.CPP *
  25. * *
  26. * Programmer : Scott K. Bowen *
  27. * *
  28. * Start Date : July 14, 1994 *
  29. * *
  30. * Last Update : August 1, 1994 [SKB] *
  31. * *
  32. *-------------------------------------------------------------------------*
  33. * Functions: *
  34. * Prog_End -- Called to shutdown Westood's library. *
  35. * main -- Programs main entry point. *
  36. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  37. #include "function.h"
  38. #include <stdio.h>
  39. #include <stdlib.h>
  40. #define GRAPHICS TRUE
  41. void *ShapeBuffer = NULL;
  42. /***************************************************************************
  43. * MAIN -- Programs main entry point. *
  44. * *
  45. * *
  46. * *
  47. * INPUT: *
  48. * *
  49. * OUTPUT: *
  50. * *
  51. * WARNINGS: *
  52. * *
  53. * HISTORY: *
  54. * 08/01/1994 SKB : Created. *
  55. *=========================================================================*/
  56. #pragma argsused
  57. WORD main(WORD argc, BYTE *argv[])
  58. {
  59. void *fontptr;
  60. /*======================================================================*/
  61. /* Install page fault handle in case of fatal crash. */
  62. /*======================================================================*/
  63. Install_Page_Fault_Handle ();
  64. /*======================================================================*/
  65. /* Setup the monochrome monitor for testing. */
  66. /*======================================================================*/
  67. MonoEnabled = (Find_Argv("-MONO") ? TRUE : FALSE);
  68. Mono_Clear_Screen();
  69. /*======================================================================*/
  70. /* Initialize the file data table. */
  71. /*======================================================================*/
  72. WWDOS_Init(200, NULL, NULL);
  73. /*======================================================================*/
  74. /* Initialize the system font. */
  75. /*======================================================================*/
  76. #if GRAPHICS
  77. fontptr = Load_Font("STD6P.FNT");
  78. if (!fontptr) {
  79. printf("Unable to load font.");
  80. exit(1);
  81. }
  82. Set_Font(fontptr);
  83. #endif
  84. /*======================================================================*/
  85. /* Setup the timer system. */
  86. /*======================================================================*/
  87. if (Find_Argv("-NOTIME")) {
  88. NoTimer = TRUE;
  89. } else {
  90. Init_Timer_System(USER_TIMER_FREQ);
  91. NoTimer = FALSE;
  92. }
  93. /*======================================================================*/
  94. /* Get the initial graphic mode. */
  95. /*======================================================================*/
  96. #if GRAPHICS
  97. if ( Set_Video_Mode(MCGA_MODE) == FALSE )
  98. {
  99. printf("Unable to Set Graphic Mode\n");
  100. exit ( 0 ) ;
  101. }
  102. #endif
  103. /*======================================================================*/
  104. /* Now we get a keyboard handler. */
  105. /*======================================================================*/
  106. if (Find_Argv("-NOKEY")) {
  107. NoKeyBoard = TRUE;
  108. } else {
  109. NoKeyBoard = FALSE;
  110. Install_Keyboard_Interrupt( Get_RM_Keyboard_Address(), Get_RM_Keyboard_Size());
  111. ShapeBuffer = Alloc(5000, MEM_NORMAL);
  112. Set_Shape_Buffer(ShapeBuffer, 5000);
  113. Install_Mouse(20, 20, 320, 200);
  114. }
  115. /*======================================================================*/
  116. /* Give the game some variance. */
  117. /*======================================================================*/
  118. randomize();
  119. /*======================================================================*/
  120. /* Call the user main program. */
  121. /*======================================================================*/
  122. Main_Program(argc, argv);
  123. /*======================================================================*/
  124. /* Exit gracefully. */
  125. /*======================================================================*/
  126. Prog_End();
  127. return(0);
  128. }
  129. /***************************************************************************
  130. * PROG_END -- Called to shutdown Westood's library. *
  131. * *
  132. * *
  133. * INPUT: *
  134. * *
  135. * OUTPUT: *
  136. * *
  137. * WARNINGS: exit() should not be called until this has been called *
  138. * *
  139. * HISTORY: *
  140. * 08/01/1994 SKB : Created. *
  141. *=========================================================================*/
  142. VOID Prog_End(VOID)
  143. {
  144. /*======================================================================*/
  145. /* Get rid of the keyboard handler. */
  146. /*======================================================================*/
  147. if (!NoKeyBoard) {
  148. Remove_Mouse();
  149. Free(ShapeBuffer);
  150. Remove_Keyboard_Interrupt();
  151. }
  152. /*======================================================================*/
  153. /* Get rid of the timer system. */
  154. /*======================================================================*/
  155. if (!NoTimer) {
  156. Remove_Timer_System();
  157. }
  158. /*======================================================================*/
  159. /* Restore the Video mode. */
  160. /*======================================================================*/
  161. #if GRAPHICS
  162. Set_Video_Mode(RESET_MODE);
  163. #endif
  164. /*======================================================================*/
  165. /* Close down the file system. */
  166. /*======================================================================*/
  167. WWDOS_Shutdown();
  168. }