test sprite scaling
[gbajam21] / tools / mmutil / mas.h
1 /****************************************************************************
2  *                                                          __              *
3  *                ____ ___  ____ __  ______ ___  ____  ____/ /              *
4  *               / __ `__ \/ __ `/ |/ / __ `__ \/ __ \/ __  /               *
5  *              / / / / / / /_/ />  </ / / / / / /_/ / /_/ /                *
6  *             /_/ /_/ /_/\__,_/_/|_/_/ /_/ /_/\____/\__,_/                 *
7  *                                                                          *
8  *         Copyright (c) 2008, Mukunda Johnson (mukunda@maxmod.org)         *
9  *                                                                          *
10  * Permission to use, copy, modify, and/or distribute this software for any *
11  * purpose with or without fee is hereby granted, provided that the above   *
12  * copyright notice and this permission notice appear in all copies.        *
13  *                                                                          *
14  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES *
15  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF         *
16  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR  *
17  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES   *
18  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN    *
19  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF  *
20  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.           *
21  ****************************************************************************/
22
23 #ifndef MAS_H
24 #define MAS_H
25
26 //#define SAMPLE_FORMAT_U8              3
27 //#define SAMPLE_FORMAT_S8              0
28 //#define SAMPLE_FORMAT_S16             1
29 //#define SAMPLE_FORMAT_ADPCM           2
30
31 #define SAMPF_16BIT                     0x001
32 #define SAMPF_SIGNED            0x002
33 #define SAMPF_COMP                      0x004
34
35 #define SAMP_FORMAT_U8          (0 )
36 #define SAMP_FORMAT_U16         (SAMPF_16BIT)
37 #define SAMP_FORMAT_S8          ( SAMPF_SIGNED  )
38 #define SAMP_FORMAT_S16         (SAMPF_16BIT | SAMPF_SIGNED )
39 #define SAMP_FORMAT_ADPCM       (SAMPF_COMP)
40
41 #define MAS_TYPE_SONG                   0
42 #define MAS_TYPE_SAMPLE_GBA             1
43 #define MAS_TYPE_SAMPLE_NDS             2
44
45 typedef struct tInstrument_Envelope
46 {
47         u8      loop_start;
48         u8      loop_end;
49         u8      sus_start;
50         u8      sus_end;
51         u8      node_count;
52         u16     node_x[25];
53         u8      node_y[25];
54         bool env_filter;
55         bool env_valid;
56         bool env_enabled;
57 } Instrument_Envelope;
58
59 typedef struct tInstrument
60 {
61         u32             parapointer;
62
63         u8              global_volume;
64         u8              setpan;
65         u16             fadeout;
66         u8              random_volume;
67         u8              nna;
68         u8              dct;
69         u8              dca;
70         u8              env_flags;
71         u16             notemap[120];
72
73         char    name[32];
74
75         Instrument_Envelope             envelope_volume;
76         Instrument_Envelope             envelope_pan;
77         Instrument_Envelope             envelope_pitch;
78 } Instrument;
79
80 typedef struct tSample
81 {
82         u32             parapointer;
83         
84         u8              global_volume;
85         u8              default_volume;
86         u8              default_panning;
87         u32             sample_length;
88         u32             loop_start;
89         u32             loop_end;
90         u8              loop_type;
91         u32             frequency;
92         void*   data;
93         
94         u8              vibtype;
95         u8              vibdepth;
96         u8              vibspeed;
97         u8              vibrate;
98         u16             msl_index;
99         u8              rsamp_index;
100         
101         u8              format;
102 //      bool    samp_signed;
103         
104         // file info
105         u32             datapointer;
106 //      bool    bit16;
107 //      bool    samp_unsigned;
108         u8              it_compression;
109         char    name[32];
110         char    filename[12];
111 } Sample;
112
113 typedef struct tPatternEntry
114 {
115         u8              note;
116         u8              inst;
117         u8              vol;
118         u8              fx;
119         u8              param;
120 } PatternEntry;
121
122 typedef struct tPattern
123 {
124         u32             parapointer;
125         u16             nrows;
126         int             clength;
127         PatternEntry    data[MAX_CHANNELS*256];
128         bool    cmarks[256];
129 } Pattern;
130
131 typedef struct tMAS_Module
132 {
133         char    title[32];
134         u16             order_count;
135         u8              inst_count;
136         u8              samp_count;
137         u8              patt_count;
138         u8              restart_pos;
139         bool    stereo;
140         bool    inst_mode;
141         u8              freq_mode;
142         bool    old_effects;
143         bool    link_gxx;
144         bool    xm_mode;
145         bool    old_mode;
146         u8              global_volume;
147         u8              initial_speed;
148         u8              initial_tempo;
149         u8              channel_volume[MAX_CHANNELS];
150         u8              channel_panning[MAX_CHANNELS];
151         u8              orders[256];
152         Instrument*     instruments;
153         Sample*         samples;
154         Pattern*        patterns;
155 } MAS_Module;
156
157 void Write_Instrument_Envelope( Instrument_Envelope* env );
158 void Write_Instrument( Instrument* inst );
159 void Write_SampleData( Sample* samp );
160 void Write_Sample( Sample* samp );
161 void Write_Pattern( Pattern* patt, bool xm_vol );
162 int Write_MAS( MAS_Module* mod, bool verbose, bool msl_dep );
163 void Delete_Module( MAS_Module* mod );
164
165 extern u32 MAS_FILESIZE;
166
167 #endif