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-2019 Juan Linietsky, Ariel Manzur. */ 9 /* Copyright (c) 2014-2019 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 31 #ifndef CP_LOADER_IT_H 32 #define CP_LOADER_IT_H 33 34 #include "cp_loader.h" 35 /** 36 *@author Juan Linietsky 37 */ 38 39 /****************************** 40 loader_it.h 41 ---------- 42 Impulse Tracker Module CPLoader! 43 It lacks support for old 44 instrument files methinks... 45 and some other things like 46 midi. 47 ********************************/ 48 49 class AuxSampleData; //used for internal crap 50 51 class CPLoader_IT : public CPLoader { 52 53 CPFileAccessWrapper *file; 54 CPSong *song; 55 56 struct IT_Header { 57 uint8_t blank01[2]; 58 uint16_t ordnum; 59 uint16_t insnum; 60 uint16_t smpnum; 61 uint16_t patnum; 62 uint16_t cwt; /* Created with tracker (y.xx = 0x0yxx) */ 63 uint16_t cmwt; /* Compatible with tracker ver > than val. */ 64 uint16_t flags; 65 uint16_t special; /* bit 0 set = song message attached */ 66 uint16_t msglength; 67 uint32_t msgoffset; 68 bool is_chibi; 69 }; 70 71 /* Variables to store temp data */ 72 IT_Header header; 73 74 /* CPSong Info Methods */ 75 Error load_header(bool p_dont_set); 76 Error load_orders(); 77 Error load_message(); 78 79 /* CPPattern Methods */ 80 Error load_patterns(); 81 82 /* CPSample Methods */ 83 84 Error load_samples(); 85 Error load_sample(CPSample *p_sample); 86 CPSample_ID load_sample_data(AuxSampleData &p_sample_data); 87 88 // CPSample decompression 89 90 uint32_t read_n_bits_from_IT_compressed_block(uint8_t p_bits_to_read); 91 bool read_IT_compressed_block(bool p_16bits); 92 void free_IT_compressed_block(); 93 bool load_sample_8bits_IT_compressed(void *p_dest_buffer, int p_buffsize); 94 bool load_sample_16bits_IT_compressed(void *p_dest_buffer, int p_buffsize); 95 uint32_t *source_buffer; /* source buffer */ 96 uint32_t *source_position; /* actual reading position */ 97 uint8_t source_remaining_bits; /* bits remaining in read dword */ 98 uint8_t *pat_data; 99 100 /* CPInstruments Methods */ 101 Error load_effects(); 102 Error load_instruments(); 103 Error load_instrument(CPInstrument *p_instrument, int *p_samples = 0); 104 void load_envelope(CPEnvelope *p_envelope, bool *p_has_filter_flag = 0); 105 106 public: 107 bool can_load_song(); 108 bool can_load_sample(); 109 bool can_load_instrument(); 110 111 Error load_song(const char *p_file, CPSong *p_song, bool p_sampleset = false); 112 Error load_sample(const char *p_file, CPSample *p_sample); 113 Error load_instrument(const char *p_file, CPSong *p_song, int p_instr_idx); 114 115 CPLoader_IT(CPFileAccessWrapper *p_file); 116 }; 117 118 #endif 119