Initial commit.
[amiga/xmodule.git] / include / libraries / xmodule.h
1 #ifndef LIBRARIES_XMODULE_H
2 #define LIBRARIES_XMODULE_H
3 /*
4 **      XModule.h
5 **
6 **      Copyright (C) 1995,96,97 Bernardo Innocenti
7 **
8 **      Set TAB size to 8 chars to read this header file
9 **
10 **      Public structures and constants for the xmodule.library
11 */
12
13 #ifndef DOS_DOS_H
14 #include <dos/dos.h>
15 #endif /* DOS_DOS_H */
16
17 #ifndef EXEC_LISTS_H
18 #include <exec/lists.h>
19 #endif /* EXEC_LISTS_H */
20
21 #ifndef EXEC_LIBRARIES_H
22 #include <exec/libraries.h>
23 #endif /* EXEC_LIBRARIES_H */
24
25 #ifndef EXEC_SEMAPHORES_H
26 #include <exec/semaphores.h>
27 #endif /* EXEC_SEMAPHORES_H */
28
29 #ifndef INTUITION_CLASSES_H
30 #include <intuition/classes.h>
31 #endif /* INTUITION_CLASSES_H */
32
33 #ifndef COMPILERSPECIFIC_H
34 #include "CompilerSpecific.h"
35 #endif /* COMPILERSPECIFIC_H */
36
37
38 /***************/
39 /* XModuleBase */
40 /***************/
41
42 struct XModuleBase
43 {
44         struct Library                   xm_Library;            /* Standard Library node structure      */
45         UWORD                                    xm_Pad0;                       /* Struct Library is misaligned!        */
46         struct SignalSemaphore   xm_BaseLock;           /* Obtain this before browsing
47                                                                                                  * in any of the fields!
48                                                                                                  */
49         UWORD                                    xm_Pad1;                       /* SignalSemaphore is misaligned!       */
50
51         /* The following data is longword aligned */
52
53         struct MinList                   xm_Songs;                      /* List of public SongInfo structs      */
54         struct MinList                   xm_Loaders;            /* List of available loaders            */
55         struct MinList                   xm_Savers;                     /* List of available savers                     */
56
57         void                                    *xm_Pool;                       /* Public mem pool used by XModule      */
58         Class                                   *xm_SongClass;          /* Song boopsi class                            */
59         struct SongInfo                 *xm_CurrentSong;        /* Pointer to currently active song     */
60         struct XMHook                   *xm_DefaultSaver;       /* Currently selected saver hook        */
61         struct Screen                   *xm_Screen;                     /* XModule screen (might be NULL)       */
62         ULONG                                    xm_Flags;                      /* See definitions below                        */
63         STRPTR                                   xm_ScreenName;         /* Name of XModule's public screen      */
64         STRPTR                                   xm_RexxName;           /* Name of XModule's ARexx port         */
65
66         ULONG                                    xm_Reserved[4];
67
68         struct DosLibrary               *xm_DOSBase;            /* Some useful library bases that       */
69         struct UtilityBase              *xm_UtilityBase;        /* can be grabbed and used by           */
70         struct Library                  *xm_IFFParseBase;       /* external hooks.  These four are      */
71         struct IntuitionBase    *xm_IntuitionBase;      /* guaranteed to be always open.        */
72 };
73
74
75
76 struct XMHook
77 {
78         struct Node     xmh_Link;                                       /* Link to other hooks in a list.
79                                                                                          * ln_Name contains the Hook name.
80                                                                                          */
81         UWORD           xmh_Version;                            /* Will be set to XMHOOK_VERSION        */
82         STRPTR          xmh_Descr;                                      /* Short description of this hook       */
83         STRPTR          xmh_Author;                                     /* Author's name                                        */
84         ULONG           xmh_Flags;                                      /* See below for definitions            */
85         ULONG           xmh_ID;                                         /* IFF-style ID.  Set it to the FORM
86                                                                                          * type for IFF loaders/savers.
87                                                                                          */
88         APTR            xmh_UserData;                           /* User's private data                          */
89         struct Library *xmh_LibraryBase;                /* External hook's library base         */
90         ASMCALL void    (*xmh_RemoveHook) (
91                 REG(a0,struct XMHook *hook));           /* Hook remotion entrypoint                     */
92         ASMCALL LONG    (*xmh_LoadMod) (
93                 REG(d0, BPTR fh),
94                 REG(a0, struct SongInfo *song),
95                 REG(a1, struct XMHook *loader),
96                 REG(a2, struct TagItem *tags));         /* Module loader entrypoint                     */
97         ASMCALL LONG    (*xmh_SaveMod) (
98                 REG(d0, BPTR fh),
99                 REG(a0, struct SongInfo *song),
100                 REG(a1, struct XMHook *saver),
101                 REG(a2, struct TagItem *tags));         /* Module saver entrypoint                      */
102         ASMCALL struct XMHook * (*xmh_IdentifyMod) (
103                 REG(d0, BPTR fh),
104                 REG(a0, struct XMHook *hook),
105                 REG(a1, struct TagItem *tags));         /* Module identification entrypoint     */
106
107         ULONG           xmh_MaxTracks;                          /* Max. number of tracks                        */
108         ULONG           xmh_MaxPatterns;                        /* Max. number of patterns                      */
109         ULONG           xmh_MaxInstruments;                     /* Max. number of instruments           */
110         ULONG           xmh_MaxLength;                          /* Max. number of positions                     */
111         ULONG           xmh_MaxSampleLen;                       /* Max. length of each sample           */
112         ULONG           xmh_MaxPattLen;                         /* Max. lines in a pattern                      */
113
114         ULONG           xmh_Reserved[2];                        /* Avoid recompilation :-)                      */
115 };
116
117
118
119 #define XMHOOK_VERSION          0
120
121 #define NT_XMSONG               'X'
122 #define NT_XMLOADER             'L'
123 #define NT_XMSAVER              'S'
124
125
126
127 /* Flag definitions for XMHook->xmh_Flags */
128
129 /* Basic type */
130 #define XMHF_BINARY                                     0x0000
131 #define XMHF_ASCII                                      0x0001
132 #define XMHF_IFF                                        0x0002
133 #define XMHF_MISC                                       0x0003
134
135 /* These specify that the saver is able to exclude
136  * the corresponding items when saving in its own format.
137  */
138 #define XMHF_EXCLUDE_SEQUENCE           (1<<5)
139 #define XMHF_EXCLUDE_INSTRUMENTS        (1<<6)
140 #define XMHF_EXCLUDE_PATTERNS           (1<<7)
141 #define XMHF_EXCLUDE_NAMES                      (1<<8)
142
143 /* This module format does not support variable length
144  * patterns.  Use in conjunction with XMHOOK_MaxPattLen tag.
145  */
146 #define XMHF_FIXED_PATT_LEN                     (1<<9)
147
148 /* This is an internal hook */
149 #define XMHF_INTERNAL   (1<<31)
150
151
152
153 /* Flags for xmDisplayMessage() */
154
155
156
157 #define XMDMF_ALERT                     0x00000000
158 #define XMDMF_FAIL                      0x00000001
159 #define XMDMF_ERROR                     0x00000002
160 #define XMDMF_WARNING           0x00000003
161 #define XMDMF_NOTE                      0x00000004
162 #define XMDMF_INFORMATION       0x00000005
163 #define XMDMF_COMMENT           0x00000006
164 #define XMDMF_DEBUG                     0x00000007
165 #define XMDMF_LEVELMASK         0x00000007
166
167 #define XMDMF_DOSERRORMASK      0x0000FFFF
168 #define XMDMF_DOSFAULT          (1<<28)
169 #define XMDMF_ACTION            (1<<29)
170 #define XMDMF_USEREQUESTER      (1<<30)
171 #define XMDMF_USECATALOG        (1<<31)
172
173
174
175 /* Specific error codes */
176
177 #define ERROR_NOTMODULE ERROR_OBJECT_WRONG_TYPE /* File format not recognized           */
178 #define ERROR_IOERR             RETURN_FAIL                             /* A DOS call (e.g.: Read()) failed.
179                                                                                                  * check IoErr() for specific error.
180                                                                                                  */
181
182
183 /********/
184 /* Tags */
185 /********/
186
187 #define XMSNG_Dummy                             (TAG_USER + 'XS'<<8)
188
189 #define XMSNG_AddToList                 (XMSNG_Dummy + 1)
190 #define XMSNG_OldSong                   (XMSNG_Dummy + 2)
191 #define XMSNG_Loader                    (XMSNG_Dummy + 3)
192 #define XMSNG_FileHandle                (XMSNG_Dummy + 4)
193 #define XMSNG_Active                    (XMSNG_Dummy + 5)
194
195 /* Tags for xmOptimizeSongA() */
196
197 #define XMSNG_Optimize                  (XMSNG_Dummy + 16)
198 #define XMSNG_RemapInstruments  (XMSNG_Dummy + 17)
199 #define XMSNG_LimitPatterns             (XMSNG_Dummy + 18)
200 #define XMSNG_Join                              (XMSNG_Dummy + 19)
201 #define XMSNG_Merge                             (XMSNG_Dummy + 20)
202
203 /* Flags for XMSNG_Optimize */
204 #define XMOF_DEFAULT                            (1<<0)
205 #define XMOF_REM_UNUSED_PATTERNS        (1<<1)
206 #define XMOF_REM_DUP_PATTERNS           (1<<2)
207 #define XMOF_REM_UNUSED_INSTRS          (1<<3)
208 #define XMOF_REM_DUP_INSTRS                     (1<<4)
209 #define XMOF_CUT_INSTR_LOOPS            (1<<5)
210 #define XMOF_CUT_INSTR_TAILS            (1<<6)
211 #define XMOF_CUT_PATTERNS                       (1<<7)
212 #define XMOF_REMAP_INSTRS                       (1<<8)
213
214
215 /* XModule hook tags */
216
217 #define XMHOOK_Dummy                    (TAG_USER + 'XH'<<8)
218
219 #define XMHOOK_Type                             (XMHOOK_Dummy + 1)
220 #define XMHOOK_Name                             (XMHOOK_Dummy + 2)
221 #define XMHOOK_Priority                 (XMHOOK_Dummy + 3)
222 #define XMHOOK_Descr                    (XMHOOK_Dummy + 4)
223 #define XMHOOK_Author                   (XMHOOK_Dummy + 5)
224 #define XMHOOK_ID                               (XMHOOK_Dummy + 6)
225 #define XMHOOK_Flags                    (XMHOOK_Dummy + 7)
226 #define XMHOOK_UserData                 (XMHOOK_Dummy + 8)
227 #define XMHOOK_LibraryBase              (XMHOOK_Dummy + 9)
228 #define XMHOOK_RemoveFunc               (XMHOOK_Dummy + 10)
229 #define XMHOOK_LoadModFunc              (XMHOOK_Dummy + 11)
230 #define XMHOOK_SaveModFunc              (XMHOOK_Dummy + 12)
231 #define XMHOOK_IdentifyModFunc  (XMHOOK_Dummy + 13)
232 #define XMHOOK_MaxTracks                (XMHOOK_Dummy + 14)
233 #define XMHOOK_MaxPatterns              (XMHOOK_Dummy + 15)
234 #define XMHOOK_MaxInstruments   (XMHOOK_Dummy + 16)
235 #define XMHOOK_MaxLength                (XMHOOK_Dummy + 17)
236 #define XMHOOK_MaxSampleLen             (XMHOOK_Dummy + 18)
237 #define XMHOOK_MaxPattLen               (XMHOOK_Dummy + 19)
238
239
240 #endif /* !LIBRARIES_XMODULE_H */