cp_loader_it.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*************************************************************************/
  2. /* cp_loader_it.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #ifndef CP_LOADER_IT_H
  31. #define CP_LOADER_IT_H
  32. #include "cp_loader.h"
  33. /**
  34. *@author Juan Linietsky
  35. */
  36. /******************************
  37. loader_it.h
  38. ----------
  39. Impulse Tracker Module CPLoader!
  40. It lacks support for old
  41. instrument files methinks...
  42. and some other things like
  43. midi.
  44. ********************************/
  45. class AuxSampleData; //used for internal crap
  46. class CPLoader_IT : public CPLoader {
  47. CPFileAccessWrapper *file;
  48. CPSong *song;
  49. struct IT_Header {
  50. uint8_t blank01[2];
  51. uint16_t ordnum;
  52. uint16_t insnum;
  53. uint16_t smpnum;
  54. uint16_t patnum;
  55. uint16_t cwt; /* Created with tracker (y.xx = 0x0yxx) */
  56. uint16_t cmwt; /* Compatible with tracker ver > than val. */
  57. uint16_t flags;
  58. uint16_t special; /* bit 0 set = song message attached */
  59. uint16_t msglength;
  60. uint32_t msgoffset;
  61. bool is_chibi;
  62. };
  63. /* Variables to store temp data */
  64. IT_Header header;
  65. /* CPSong Info Methods */
  66. Error load_header(bool p_dont_set);
  67. Error load_orders();
  68. Error load_message();
  69. /* CPPattern Methods */
  70. Error load_patterns();
  71. /* CPSample Methods */
  72. Error load_samples();
  73. Error load_sample(CPSample *p_sample);
  74. CPSample_ID load_sample_data(AuxSampleData &p_sample_data);
  75. // CPSample decompression
  76. uint32_t read_n_bits_from_IT_compressed_block(uint8_t p_bits_to_read);
  77. bool read_IT_compressed_block(bool p_16bits);
  78. void free_IT_compressed_block();
  79. bool load_sample_8bits_IT_compressed(void *p_dest_buffer, int p_buffsize);
  80. bool load_sample_16bits_IT_compressed(void *p_dest_buffer, int p_buffsize);
  81. uint32_t *source_buffer; /* source buffer */
  82. uint32_t *source_position; /* actual reading position */
  83. uint8_t source_remaining_bits; /* bits remaining in read dword */
  84. uint8_t *pat_data;
  85. /* CPInstruments Methods */
  86. Error load_effects();
  87. Error load_instruments();
  88. Error load_instrument(CPInstrument *p_instrument, int *p_samples = 0);
  89. void load_envelope(CPEnvelope *p_envelope, bool *p_has_filter_flag = 0);
  90. public:
  91. bool can_load_song();
  92. bool can_load_sample();
  93. bool can_load_instrument();
  94. Error load_song(const char *p_file, CPSong *p_song, bool p_sampleset = false);
  95. Error load_sample(const char *p_file, CPSample *p_sample);
  96. Error load_instrument(const char *p_file, CPSong *p_song, int p_instr_idx);
  97. CPLoader_IT(CPFileAccessWrapper *p_file);
  98. };
  99. #endif