Subversion Repositories Games.Carmageddon

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. #include "main.h"
  2. #include <stdlib.h>
  3.  
  4. #include "controls.h"
  5. #include "cutscene.h"
  6. #include "drmem.h"
  7. #include "errors.h"
  8. #include "globvars.h"
  9. #include "globvrpb.h"
  10. #include "graphics.h"
  11. #include "harness/config.h"
  12. #include "harness/trace.h"
  13. #include "init.h"
  14. #include "input.h"
  15. #include "loading.h"
  16. #include "loadsave.h"
  17. #include "network.h"
  18. #include "pd/sys.h"
  19. #include "s3/s3.h"
  20. #include "sound.h"
  21. #include "structur.h"
  22. #include "utility.h"
  23.  
  24. // IDA: void __cdecl QuitGame()
  25. void QuitGame(void) {
  26.     LOG_TRACE("()");
  27.  
  28.     if (harness_game_info.mode == eGame_carmageddon_demo || harness_game_info.mode == eGame_splatpack_demo || harness_game_info.mode == eGame_splatpack_xmas_demo) {
  29.         DoDemoGoodbye();
  30.     }
  31.  
  32.     gProgram_state.racing = 0;
  33.     SaveOptions();
  34.     if (gNet_mode != eNet_mode_none) {
  35.         NetLeaveGame(gCurrent_net_game);
  36.     }
  37.     ShutdownNetIfRequired();
  38.     if (gSound_available) {
  39.         DRS3ShutDown();
  40.     }
  41.     if (gBr_initialized) {
  42.         ClearEntireScreen();
  43.     }
  44.     PDRevertPalette();
  45.     StopMusic();
  46.     PDShutdownSystem();
  47.     CloseDiagnostics();
  48.     exit(0);
  49. }
  50.  
  51. // IDA: tU32 __cdecl TrackCount(br_actor *pActor, tU32 *pCount)
  52. tU32 TrackCount(br_actor* pActor, tU32* pCount) {
  53.     //unsigned int x; // Pierre-Marie Baty -- unused variable
  54.     //unsigned int z; // Pierre-Marie Baty -- unused variable
  55.     //int ad; // Pierre-Marie Baty -- unused variable
  56.     //float e; // Pierre-Marie Baty -- unused variable
  57.     LOG_TRACE("(%p, %p)", pActor, pCount);
  58.     NOT_IMPLEMENTED();
  59. }
  60.  
  61. // IDA: void __cdecl CheckNumberOfTracks()
  62. void CheckNumberOfTracks(void) {
  63.     //tU32 track_count; // Pierre-Marie Baty -- unused variable
  64.     LOG_TRACE("()");
  65.     NOT_IMPLEMENTED();
  66. }
  67.  
  68. // IDA: void __usercall ServiceTheGame(int pRacing@<EAX>)
  69. void ServiceTheGame(int pRacing) {
  70.  
  71.     CheckMemory();
  72.     if (!pRacing) {
  73.         CyclePollKeys();
  74.     }
  75.     PollKeys();
  76.     rand();
  77.     if (PDServiceSystem(gFrame_period)) {
  78.         QuitGame();
  79.     }
  80.     if (!pRacing) {
  81.         CheckSystemKeys(0);
  82.     }
  83.     if (!pRacing && gSound_enabled) {
  84.         if (gProgram_state.cockpit_on && gProgram_state.cockpit_image_index >= 0) {
  85.             S3Service(1, 2);
  86.         } else {
  87.             S3Service(0, 2);
  88.         }
  89.     }
  90.     NetService(pRacing);
  91. }
  92.  
  93. // IDA: void __cdecl ServiceGame()
  94. void ServiceGame(void) {
  95.     ServiceTheGame(0);
  96. }
  97.  
  98. // IDA: void __cdecl ServiceGameInRace()
  99. void ServiceGameInRace(void) {
  100.     LOG_TRACE("()");
  101.  
  102.     ServiceTheGame(1);
  103.     CheckKevKeys();
  104. }
  105.  
  106. // IDA: void __usercall GameMain(int pArgc@<EAX>, char **pArgv@<EDX>)
  107. void GameMain(int pArgc, char** pArgv) {
  108.     tPath_name CD_dir;
  109.  
  110.     PDSetFileVariables();
  111.     PDBuildAppPath(gApplication_path);
  112.     OpenDiagnostics();
  113.  
  114.     strcat(gApplication_path, "DATA");
  115.  
  116.     UsePathFileToDetermineIfFullInstallation();
  117.     if (!gCD_fully_installed && GetCDPathFromPathsTxtFile(CD_dir) && !PDCheckDriveExists(CD_dir)) {
  118.         PDInitialiseSystem();
  119.         fprintf(stderr, "Can't find the Carmageddon CD\n");
  120.         exit(1);
  121.     }
  122.     InitialiseDeathRace(pArgc, pArgv);
  123.     DoProgram();
  124.     QuitGame();
  125. }
  126.