Initial commit.
[amiga/xmodule.git] / XModulePriv.h
1 #ifndef XMODULE_PRIV_H
2 #define XMODULE_PRIV_H
3 /*
4 **      XModulePriv.h
5 **
6 **      Copyright (C) 1993,94,95,96,97 Bernardo Innocenti
7 **
8 **      Use 4 chars wide TABs to read this source
9 **
10 **      Private definitions for internal XModule use
11 */
12
13 #ifndef EXEC_NODES_H
14 #include <exec/nodes.h>
15 #endif /* !EXEC_NODES_H */
16
17 #ifndef EXEC_LIBRARIES_H
18 #include <exec/libraries.h>
19 #endif /* !EXEC_LIBRARIES_H */
20
21 #ifndef DOS_DOS_H
22 #include <dos/dos.h>
23 #endif /* !DOS_DOS_H */
24
25 #ifndef DOS_DOS_H
26 #include <dos/dos.h>
27 #endif /* !DOS_DOS_H */
28
29 #ifndef LIBRARIES_IFFPARSE_H
30 #include "libraries/iffparse.h"
31 #endif /* LIBRARIES_IFFPARSE_H */
32
33 #ifndef LIBRARIES_XMODULE_H
34 #include <libraries/xmodule.h>
35 #endif /* !LIBRARIES_XMODULE_H */
36
37 #ifndef LIBRARIES_SONGCLASS_H
38 #include <libraries/songclass.h>
39 #endif /* !LIBRARIES_SONGCLASS_H */
40
41 #include "XModule_rev.h"
42 #include "LocaleStrings.h"
43 #include "ListMacros.h"
44 #include "CompilerSpecific.h"
45 #include "Debug.h"                      /* Debug support */
46
47 /* Single object compilation requires different attributes for global symbols */
48 #ifdef SINGLE_OBJECT
49         #undef XREF
50         #undef XDEF
51         #undef GLOBALCALL
52         #define XREF            extern
53         #define XDEF            static
54         #define GLOBALCALL      static
55         #ifdef __SASC
56 //              #pragma msg 72 ignore
57                 #pragma msg 181 ignore
58         #endif
59 #endif
60
61
62 /* Version information: updated auto-magically on every compilation ;-) */
63
64 #define XMODULEVER      VERS
65 #define XMODULEDATE     "(" DATE ")"
66 #define XMODULECOPY     "Copyright © 1993,94,95,96,97 by Bernardo Innocenti"
67
68 #ifdef OS30_ONLY
69         #ifdef _M68020
70                 #define BUILDMODE "[M68020 OS3.0]"
71         #else
72                 #define BUILDMODE "[M68000 OS3.0]"
73         #endif
74 #else
75         #ifdef _M68020
76                 #define BUILDMODE "[M68020 OS2.0]"
77         #else
78                 #define BUILDMODE "[M68000 OS2.0]"
79         #endif
80 #endif
81
82
83
84 /*************************/
85 /* Constants Definitions */
86 /*************************/
87
88 /* Maximum values */
89 #define MAXTABLEEFFECTS  20                     /* Number of entries in effect conversion table */
90 #define PATHNAME_MAX    108                     /* Maximum length of an AmigaDOS path name              */
91
92
93 /* Specific error codes */
94 #define ERROR_NOTMODULE ERROR_OBJECT_WRONG_TYPE /* File format not recognized           */
95 #define ERROR_IOERR             RETURN_FAIL                             /* A DOS call (e.g.: Read()) failed.
96                                                                                                  * check IoErr() for specific error.
97                                                                                                  */
98
99 /* Default directory for external hooks */
100 #define DEF_HOOKSDIR "PROGDIR:Hooks/"
101
102
103 /***********************/
104 /* Function Prototypes */
105 /***********************/
106
107 /* From "Audio.c" */
108 GLOBALCALL void         HandleAudio                             (void);
109 GLOBALCALL void         PlaySample                              (BYTE *samp, ULONG len, UWORD vol, UWORD per);
110 GLOBALCALL ULONG        SetupAudio                              (void);
111 GLOBALCALL void         CleanupAudio                    (void);
112
113 /* From "Misc.c" */
114 GLOBALCALL struct Library *MyOpenLibrary        (CONST_STRPTR name, ULONG ver);
115 GLOBALCALL void         CantOpenLib                             (CONST_STRPTR name, LONG vers);
116 GLOBALCALL void         KillMsgPort                             (struct MsgPort *mp);
117 GLOBALCALL struct TextAttr *CopyTextAttrPooled  (void *pool, const struct TextAttr *source, struct TextAttr *dest);
118 GLOBALCALL UWORD        CmpTextAttr                             (const struct TextAttr *ta1, const struct TextAttr *ta2);
119 GLOBALCALL STRPTR       DupStringPooled                 (void *pool, CONST_STRPTR source, STRPTR *dest);
120 GLOBALCALL void         FilterName                              (STRPTR name);
121 GLOBALCALL struct DiskObject *GetProgramIcon (void);
122 GLOBALCALL LONG         PutIcon                                 (CONST_STRPTR source, CONST_STRPTR dest);
123 GLOBALCALL LONG         BackupFile                              (CONST_STRPTR src, CONST_STRPTR template, ULONG versions);
124
125 /* From "Gui.c" (More functions prototyped in "Gui.h") */
126 GLOBALCALL LONG         HandleGui                               (void);
127
128 /* From "Rexx.c" */
129 GLOBALCALL void         HandleRexxMsg                   (void);
130 GLOBALCALL LONG         CreateRexxPort                  (void);
131 GLOBALCALL void         DeleteRexxPort                  (void);
132
133 /* From "ToolBoxWin.c" */
134 GLOBALCALL void         ToolBoxOpenModule               (CONST_STRPTR file, ULONG num, ULONG count);
135
136 /* From "Help.c" */
137 GLOBALCALL void         HandleHelp                              (struct IntuiMessage *msg);
138 GLOBALCALL void         HandleAmigaGuide                (void);
139 GLOBALCALL void         CleanupHelp                             (void);
140
141 /* From "Cx.c" */
142 GLOBALCALL LONG         SetupCx                                 (void);
143 GLOBALCALL void         HandleCx                                (void);
144 GLOBALCALL void         CleanupCx                               (void);
145
146 /* From "ProgressWin.c" */
147 GLOBALCALL void         DisplayAction                   (ULONG msg);
148 GLOBALCALL void         DisplayActionStr                (CONST_STRPTR str);
149 GLOBALCALL LONG         DisplayProgress                 (LONG Num, LONG Max);
150 GLOBALCALL void         ShowMessage                             (ULONG msg, ...);
151 GLOBALCALL void         ShowString                              (CONST_STRPTR s, LONG *args);
152
153 /* From "PlayWin.c" */
154 GLOBALCALL LONG         SetupPlayer                             (void);
155 GLOBALCALL void         CleanupPlayer                   (void);
156
157 /* From "Compress.c" */
158 GLOBALCALL BPTR         DecompressFile                  (CONST_STRPTR name, UWORD type);
159 GLOBALCALL void         DecompressFileDone              (void);
160 GLOBALCALL LONG         CruncherType                    (BPTR file);
161
162 /* From "Song.c" */
163 GLOBALCALL Class *      InitSongClass                   (void);
164 GLOBALCALL void         FreeSongClass                   (Class *cl);
165 GLOBALCALL void         FixSong                                 (struct SongInfo *si);
166 GLOBALCALL ULONG        CalcInstSize                    (struct SongInfo *si);
167 GLOBALCALL ULONG        CalcSongSize                    (struct SongInfo *si);
168 GLOBALCALL ULONG        CalcSongTime                    (struct SongInfo *si);
169
170 /* From "Instr.c" */
171 GLOBALCALL LONG         LoadInstrument                  (struct SongInfo *si, ULONG num, CONST_STRPTR filename);
172 GLOBALCALL LONG         SaveInstrument                  (struct Instrument *inst, CONST_STRPTR filename);
173 GLOBALCALL LONG         Load8SVXInstrument              (struct SongInfo *si, ULONG num, struct IFFHandle *iff, CONST_STRPTR filename);
174 GLOBALCALL LONG         Save8SVXInstrument              (struct Instrument *inst, ULONG num, struct IFFHandle *iff);
175 GLOBALCALL void         OptimizeInstruments             (struct SongInfo *si);
176 GLOBALCALL void         RemDupInstruments               (struct SongInfo *si);
177 GLOBALCALL void         RemUnusedInstruments    (struct SongInfo *si);
178 GLOBALCALL void         RemapInstruments                (struct SongInfo *si);
179 GLOBALCALL void         SampChangeSign8                 (UBYTE *samp, ULONG len);
180
181 /* From "Operators.c" */
182 GLOBALCALL ULONG        InsertPattern                   (struct SongInfo *si, struct Pattern *patt, UWORD patnum);
183 GLOBALCALL struct SongInfo *MergeSongs          (struct SongInfo *songa, struct SongInfo *songb);
184 GLOBALCALL struct SongInfo *JoinSongs           (struct SongInfo *songa, struct SongInfo *songb);
185 GLOBALCALL void         RemDupPatterns                  (struct SongInfo *si);
186 GLOBALCALL void         DiscardPatterns                 (struct SongInfo *si);
187 GLOBALCALL void         CutPatterns                             (struct SongInfo *si);
188 GLOBALCALL LONG         ResizePatterns                  (struct SongInfo *si, ULONG min, ULONG max);
189 GLOBALCALL struct Pattern       *CopyPattern    (struct SongInfo *si, struct Pattern *src, ULONG destNum);
190
191 /* From "Prefs.c" */
192 GLOBALCALL LONG         LoadPrefs                               (CONST_STRPTR filename);
193 GLOBALCALL LONG         SavePrefs                               (CONST_STRPTR filename);
194
195 /* From "Library.c" */
196 GLOBALCALL ULONG        MakeXModuleLibrary              (void);
197 GLOBALCALL void         DisposeXModuleLibrary   (void);
198
199 /* From "Locale.c" */
200 GLOBALCALL void         SetupLocale                             (void);
201 GLOBALCALL void         CleanupLocale                   (void);
202
203 /* From "XModuleHook.c" */
204 GLOBALCALL void         AddXModuleHooks                 (void);
205 GLOBALCALL LONG         LoadSong                                (struct IFFHandle *iff, struct SongInfo *si);
206 GLOBALCALL struct Pattern *LoadPattern          (struct SongInfo *si, ULONG num, struct IFFHandle *iff);
207 GLOBALCALL LONG         SaveSong                                (struct IFFHandle *iff, struct SongInfo *si);
208 GLOBALCALL LONG         SaveSequence                    (struct IFFHandle *iff, struct SongInfo *si);
209 GLOBALCALL LONG         SavePatterns                    (struct IFFHandle *iff, struct SongInfo *si);
210 GLOBALCALL LONG         SaveInstruments                 (struct IFFHandle *iff, struct SongInfo *si);
211 GLOBALCALL LONG         SavePattern                             (struct IFFHandle *iff, struct Pattern *patt);
212 GLOBALCALL LONG         WriteStringChunk                (struct IFFHandle *iff, CONST_STRPTR name, ULONG id);
213
214 /* From "TrackerHook.c" */
215 GLOBALCALL void AddTrackerHooks (void);
216
217 /* From "Startup.asm" */
218 extern void                     _XCEXIT         (LONG err);
219 extern void                     SPrintf         (UBYTE *buf, CONST_STRPTR formatstr, ...);
220 extern void STDARGS     VSPrintf        (UBYTE *buf, CONST_STRPTR formatstr, void *argv);
221 extern struct WBStartup *WBenchMsg;
222 extern struct Process   *ThisTask;
223
224
225 #ifndef OS30_ONLY
226
227 /* Memory pools support for pre-V39 OS */
228
229 #define CreatePool(f,p,t)       LibCreatePool((f),(p),(t))
230 #define DeletePool(p)           LibDeletePool(p)
231 #define AllocPooled(p,s)        AsmAllocPooled((p), (s), SysBase)
232 #define FreePooled(p,m,s)       AsmFreePooled((p), (m), (s), SysBase)
233
234 extern ASMCALL void *AsmAllocPooled             (REG(a0, void *pool), REG(d0, ULONG size), REG(a6, struct ExecBase *SysBase));
235 extern ASMCALL void *AsmFreePooled              (REG(a0, void *pool), REG(a1, void *drop), REG(d0, ULONG size), REG(a6, struct ExecBase *SysBase));
236
237 #endif /* !OS30_ONLY */
238
239
240 /* More memory pools support */
241
242 #ifdef PORTABLE
243         GLOBALCALL void *CAllocPooled   (void *pool, ULONG size);
244         GLOBALCALL void *AllocVecPooled (void *pool, ULONG size);
245         GLOBALCALL void FreeVecPooled   (void *pool, void *drop);
246 #else
247         #define AllocVecPooled(p,s)     AsmAllocVecPooled((p), (s), SysBase)
248         #define FreeVecPooled(p,m)      AsmFreeVecPooled((p), (m), SysBase)
249         #define CAllocPooled(p,s)       AsmCAllocPooled((p), (s), SysBase)
250
251         extern ASMCALL void *AsmCAllocPooled    (REG(a0, void *pool), REG(d0, ULONG size), REG(a6, struct ExecBase *SysBase));
252         extern ASMCALL void *AsmAllocVecPooled  (REG(a0, void *pool), REG(d0, ULONG size), REG(a6, struct ExecBase *SysBase));
253         extern ASMCALL void AsmFreeVecPooled    (REG(a0, void *pool), REG(a1, void *drop), REG(a6, struct ExecBase *SysBase));
254 #endif
255
256
257 /* Use these macros when the corresponding functions are not available.
258  * GLOBALCALL void      InstallGfxFunctions             (void);
259  * GLOBALCALL ULONG (*ReadAPen)(struct RastPort *RPort);
260  * GLOBALCALL ULONG (*ReadBPen)(struct RastPort *RPort);
261  * GLOBALCALL ULONG (*ReadDrMd)(struct RastPort *RPort);
262  */
263
264
265
266 /********************/
267 /* Global variables */
268 /********************/
269
270 XREF struct Catalog     *Catalog;
271 XREF void                       *Pool;
272 XREF STRPTR                      AppStrings[];
273 XREF BOOL                        Verbose;
274 XREF BPTR                        StdOut;
275 XREF LONG                        LastErr;
276 XREF UBYTE                       PubPortName[];
277
278 XREF BYTE                        CxPri;
279 XREF UBYTE                       CxPopKey[32];
280 XREF BOOL                        CxPopup;
281
282 XREF LONG                        IconX;
283 XREF LONG                        IconY;
284 XREF UBYTE                       IconName[16];
285
286 XREF const UBYTE         Version[];
287 XREF const UBYTE         BaseName[];    /* All caps             */
288 XREF const UBYTE         PrgName[];             /* Mixed case   */
289
290 #endif /* !XMODULE_PRIV_H */