MediaDataInstaller.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /*
  2. * Copyright (C) 2022 The V-Gears Team
  3. *
  4. * This file is part of V-Gears
  5. *
  6. * V-Gears is free software: you can redistribute it and/or modify it under
  7. * terms of the GNU General Public License as published by the Free Software
  8. * Foundation, version 3.0 (GPLv3) of the License.
  9. *
  10. * V-Gears 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. #pragma once
  16. #include <unordered_map>
  17. #include "data/VGearsLGPArchive.h"
  18. #include "common/BinGZipFile.h"
  19. #include "TexFile.h"
  20. /**
  21. * The media data installer.
  22. */
  23. class MediaDataInstaller{
  24. public:
  25. /**
  26. * Constructor
  27. *
  28. * @param[in] input_dir Path to the directory containing the original data to parse.
  29. * @param[out] input_dir Path to the directory of the installation data.
  30. */
  31. MediaDataInstaller(const std::string input_dir, const std::string output_dir);
  32. /**
  33. * Destructor.
  34. */
  35. ~MediaDataInstaller();
  36. /**
  37. * Populates the audio name maps.
  38. */
  39. void PopulateMaps();
  40. /**
  41. * Extracts all images contained in the menu LGP file and installs them.
  42. *
  43. * For composed textures, it extracts individual images. All images are saved under the
  44. * "images" directory. This also includes font maps.
  45. */
  46. void InstallSprites();
  47. /**
  48. * Extracts all sound files contained in the audio.dat file and installs them.
  49. *
  50. */
  51. void InstallSounds();
  52. /**
  53. * Writes the XML file with all audio entries.
  54. */
  55. void WriteSoundIndex();
  56. private:
  57. /**
  58. * Number of sound files to extract.
  59. */
  60. static int TOTAL_SOUNDS;
  61. /**
  62. * The standard WAV header.
  63. *
  64. * 78 bytes to be written to every wav file before anything else.
  65. */
  66. static u8 WAV_HEADER[78];
  67. /**
  68. * The structure of each audio file pointer in a sound FMT file. 74 bytes.
  69. */
  70. struct FmtFile{
  71. /**
  72. * Size of the wav file in the dat. 4 bytes.
  73. */
  74. u32 size;
  75. /**
  76. * Offset of the wav file in the dat. 4 bytes.
  77. */
  78. u32 offset;
  79. /**
  80. * Information for sound looping. 12 bytes.
  81. */
  82. u8 loop_metadata[16];
  83. /**
  84. * Microsoft WAVFORMATEX header for the wav file. 44 bytes.
  85. */
  86. u8 wav_header[18];
  87. /**
  88. * Samples per block. 2 bytes.
  89. */
  90. u16 samples_per_block;
  91. /**
  92. * Number of ADPCM coefficients (used for compression, should always be 7). 2 bytes.
  93. */
  94. u16 adpcm;
  95. /**
  96. * Standard Microsoft ADPCMCoefSets. 28 bytes.
  97. */
  98. u8 adpcm_sets[28];
  99. };
  100. /**
  101. * The path to the directory from which to read the PC game data.
  102. */
  103. std::string input_dir_;
  104. /**
  105. * The path to the directory where to save the V-Gears data.
  106. */
  107. std::string output_dir_;
  108. /**
  109. * The menu.lgp file.
  110. */
  111. VGears::LGPArchive menu_;
  112. /**
  113. * The WINDOW.BIN file.
  114. */
  115. BinGZipFile window_;
  116. /**
  117. * Map for sound files with descriptive names.
  118. */
  119. std::unordered_map<int, std::string> sound_map_;
  120. /**
  121. * Sound data for each entry to write to the XML file
  122. */
  123. std::vector<std::string> sounds_;
  124. };