mc2movie.cpp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. //===========================================================================//
  2. // Copyright (C) Microsoft Corporation. All rights reserved. //
  3. //===========================================================================//
  4. #ifndef MC2MOVIE_H
  5. #include "mc2movie.h"
  6. #endif
  7. #ifndef TXMMGR_H
  8. #include "txmmgr.h"
  9. #endif
  10. #ifndef FILE_H
  11. #include "file.h"
  12. #endif
  13. #ifndef GAMESOUND_H
  14. #include "gamesound.h"
  15. #endif
  16. #ifndef PREFS_H
  17. #include "prefs.h"
  18. #endif
  19. #include "..\resource.h"
  20. #include <gameos.hpp>
  21. //-----------------------------------------------------------------------
  22. const DWORD MAX_TEXTURE_WIDTH = 256;
  23. const DWORD MAX_TEXTURE_HEIGHT = 256;
  24. const DWORD MAX_MOVIE_WIDTH = 640;
  25. const DWORD MAX_MOVIE_HEIGHT = 480;
  26. const float TEXTURE_ADJUST_MIN = (0.4f / MAX_TEXTURE_WIDTH);
  27. const float TEXTURE_ADJUST_MAX = (1.0f - TEXTURE_ADJUST_MIN);
  28. float averageFrameRate = 0.0f;
  29. long currentFrameNum = 0;
  30. float last30Frames[30] = {
  31. 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
  32. 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
  33. 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
  34. 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
  35. 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
  36. 0.0f, 0.0f, 0.0f, 0.0f, 0.0f
  37. };
  38. extern char CDInstallPath[];
  39. void EnterWindowMode();
  40. void EnterFullScreenMode();
  41. void __stdcall ExitGameOS();
  42. //-----------------------------------------------------------------------
  43. // Class MC2Movie
  44. void MC2Movie::init (char *MC2Name, RECT mRect, bool useWaveFile)
  45. {
  46. char MOVIEName[1024];
  47. _splitpath(MC2Name,NULL,NULL,MOVIEName,NULL);
  48. m_MC2Name = new char [strlen(MOVIEName)+1];
  49. memset(m_MC2Name,0,strlen(MOVIEName)+1);
  50. strcpy(m_MC2Name,MOVIEName);
  51. //Set the volume based on master system volume.
  52. // ONLY if we want silence!!!
  53. if (useWaveFile && (prefs.DigitalMasterVolume != 0.0f))
  54. {
  55. separateWAVE = true;
  56. soundStarted = false;
  57. char MOVIEName[1024];
  58. _splitpath(MC2Name,NULL,NULL,MOVIEName,NULL);
  59. waveName = new char [strlen(MOVIEName)+1];
  60. memset(waveName,0,strlen(MOVIEName)+1);
  61. strcpy(waveName,MOVIEName);
  62. }
  63. numHigh = 1;
  64. totalTexturesUsed = numWide * numHigh;
  65. }
  66. //-----------------------------------------------------------------------
  67. //Changes rect. If resize, calls malloc which will be QUITE painful during a MC2 playback
  68. // If just move, its awfully fast.
  69. void MC2Movie::setRect (RECT vRect)
  70. {
  71. if (((vRect.right - vRect.left) != (MC2Rect.right - MC2Rect.left)) ||
  72. ((vRect.bottom - vRect.top) != (MC2Rect.bottom - MC2Rect.top)))
  73. {
  74. //Size changed. STOP for now to tell people this is bad!
  75. // May be impossible to do when MC2 is running because MC2 counts on previous frame's contents not changing
  76. STOP(("Tried to change MC2 Movie Rect size to different one from starting value"));
  77. }
  78. else
  79. {
  80. //Otherwise, just update the MC2Rect.
  81. MC2Rect = vRect;
  82. }
  83. }
  84. //-----------------------------------------------------------------------
  85. //Handles tickling MC2 to make sure we keep playing back
  86. bool MC2Movie::update (void)
  87. {
  88. if (!soundStarted && separateWAVE)
  89. {
  90. soundStarted = true;
  91. soundSystem->playDigitalStream(waveName);
  92. }
  93. if (
  94. stillPlaying)
  95. {
  96. if (forceStop)
  97. {
  98. stillPlaying = false;
  99. if (separateWAVE)
  100. soundSystem->stopSupportSample();
  101. return true;
  102. }
  103. return false;
  104. }
  105. return true;
  106. }
  107. //-----------------------------------------------------------------------
  108. //Actually moves frame data from MC2 to surface and/or texture(s)
  109. void MC2Movie::BltMovieFrame (void)
  110. {
  111. }
  112. //-----------------------------------------------------------------------
  113. //Actually draws the MC2 texture using gos_DrawTriangle.
  114. void MC2Movie::render (void)
  115. {
  116. if (!stillPlaying)
  117. return;
  118. }
  119. //--