1 /*************************************************************************/
2 /*  cp_loader_s3m.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_S3M_H
32 #define CP_LOADER_S3M_H
33 
34 #include "cp_loader.h"
35 
36 /**
37   *@author Juan Linietsky
38   */
39 /******************************
40  loader_s3m.h
41  ----------
42 Scream Tracker Module CPLoader!
43 It lacks support for
44 individual sample loading
45 and reorganizing the columns.
46 ********************************/
47 
48 class CPLoader_S3M : public CPLoader {
49 
50 	struct S3M_Header {
51 		char songname[28];
52 		uint8_t t1a;
53 		uint8_t type;
54 		uint8_t unused1[2];
55 		uint16_t ordnum;
56 		uint16_t insnum;
57 		uint16_t patnum;
58 		uint16_t flags;
59 		uint16_t tracker;
60 		uint16_t fileformat;
61 		char scrm[5];
62 		uint8_t mastervol;
63 		uint8_t initspeed;
64 		uint8_t inittempo;
65 		uint8_t mastermult;
66 		uint8_t ultraclick;
67 		uint8_t pantable;
68 		uint8_t unused2[8];
69 		uint16_t special;
70 		uint8_t channels[32];
71 		uint8_t pannings[32];
72 		uint8_t orderlist[300];
73 	};
74 
75 	int sample_parapointers[CPSong::MAX_SAMPLES];
76 	int pattern_parapointers[CPSong::MAX_PATTERNS];
77 
78 	Error load_header();
79 	void set_header();
80 	Error load_sample(CPSample *p_sample);
81 	Error load_pattern(CPPattern *p_pattern);
82 	Error load_patterns();
83 
84 	Error load_samples();
85 
86 	S3M_Header header;
87 	int sample_count;
88 	int pattern_count;
89 
90 	CPFileAccessWrapper *file;
91 	CPSong *song;
92 
93 public:
can_load_song()94 	bool can_load_song() { return true; }
can_load_sample()95 	bool can_load_sample() { return false; }
can_load_instrument()96 	bool can_load_instrument() { return false; }
97 
98 	Error load_song(const char *p_file, CPSong *p_song, bool p_sampleset);
99 	Error load_sample(const char *p_file, CPSample *p_sample);
100 	Error load_instrument(const char *p_file, CPSong *p_song, int p_instr_idx);
101 
102 	CPLoader_S3M(CPFileAccessWrapper *p_file);
103 	~CPLoader_S3M();
104 };
105 
106 #endif
107