summaryrefslogtreecommitdiff
path: root/apps/plugins/mikmod/mlutil.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/mikmod/mlutil.c')
-rw-r--r--apps/plugins/mikmod/mlutil.c44
1 files changed, 19 insertions, 25 deletions
diff --git a/apps/plugins/mikmod/mlutil.c b/apps/plugins/mikmod/mlutil.c
index ddaddc7871..328b1d4089 100644
--- a/apps/plugins/mikmod/mlutil.c
+++ b/apps/plugins/mikmod/mlutil.c
@@ -6,12 +6,12 @@
6 it under the terms of the GNU Library General Public License as 6 it under the terms of the GNU Library General Public License as
7 published by the Free Software Foundation; either version 2 of 7 published by the Free Software Foundation; either version 2 of
8 the License, or (at your option) any later version. 8 the License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Library General Public License for more details. 13 GNU Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public 15 You should have received a copy of the GNU Library General Public
16 License along with this library; if not, write to the Free Software 16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
@@ -20,7 +20,7 @@
20 20
21/*============================================================================== 21/*==============================================================================
22 22
23 $Id: mlutil.c,v 1.3 2007/12/06 17:43:10 denis111 Exp $ 23 $Id$
24 24
25 Utility functions for the module loader 25 Utility functions for the module loader
26 26
@@ -43,13 +43,13 @@ extern int fprintf(FILE *, const char *, ...);
43 43
44/*========== Shared tracker identifiers */ 44/*========== Shared tracker identifiers */
45 45
46CHAR *STM_Signatures[STM_NTRACKERS] = { 46const CHAR *STM_Signatures[STM_NTRACKERS] = {
47 "!Scream!", 47 "!Scream!",
48 "BMOD2STM", 48 "BMOD2STM",
49 "WUZAMOD!" 49 "WUZAMOD!"
50}; 50};
51 51
52CHAR *STM_Version[STM_NTRACKERS] = { 52const CHAR *STM_Version[STM_NTRACKERS] = {
53 "Screamtracker 2", 53 "Screamtracker 2",
54 "Converted by MOD2STM (STM format)", 54 "Converted by MOD2STM (STM format)",
55 "Wuzamod (STM format)" 55 "Wuzamod (STM format)"
@@ -71,29 +71,27 @@ FILTER filtersettings[UF_MAXFILTER]; /* computed filter settings */
71/*========== Linear periods stuff */ 71/*========== Linear periods stuff */
72 72
73int* noteindex=NULL; /* remap value for linear period modules */ 73int* noteindex=NULL; /* remap value for linear period modules */
74static int noteindexcount=0; 74static unsigned noteindexcount=0;
75 75
76int *AllocLinear(void) 76int *AllocLinear(void)
77{ 77{
78 if(of.numsmp>noteindexcount) { 78 if(of.numsmp>noteindexcount) {
79 noteindexcount=of.numsmp; 79 noteindexcount=of.numsmp;
80 noteindex=MikMod_realloc(noteindex,noteindexcount*sizeof(int)); 80 noteindex=(int*)MikMod_realloc(noteindex,noteindexcount*sizeof(int));
81 } 81 }
82 return noteindex; 82 return noteindex;
83} 83}
84 84
85void FreeLinear(void) 85void FreeLinear(void)
86{ 86{
87 if(noteindex) { 87 MikMod_free(noteindex);
88 MikMod_free(noteindex); 88 noteindex=NULL;
89 noteindex=NULL;
90 }
91 noteindexcount=0; 89 noteindexcount=0;
92} 90}
93 91
94int speed_to_finetune(ULONG speed,int sample) 92int speed_to_finetune(ULONG speed,int sample)
95{ 93{
96 ULONG ctmp=0,tmp,note=1,finetune=0; 94 ULONG ctmp=0,tmp,note=1,ft=0;
97 95
98 speed>>=1; 96 speed>>=1;
99 while((tmp=getfrequency(of.flags,getlinearperiod(note<<1,0)))<speed) { 97 while((tmp=getfrequency(of.flags,getlinearperiod(note<<1,0)))<speed) {
@@ -104,16 +102,16 @@ int speed_to_finetune(ULONG speed,int sample)
104 if(tmp!=speed) { 102 if(tmp!=speed) {
105 if((tmp-speed)<(speed-ctmp)) 103 if((tmp-speed)<(speed-ctmp))
106 while(tmp>speed) 104 while(tmp>speed)
107 tmp=getfrequency(of.flags,getlinearperiod(note<<1,--finetune)); 105 tmp=getfrequency(of.flags,getlinearperiod(note<<1,--ft));
108 else { 106 else {
109 note--; 107 note--;
110 while(ctmp<speed) 108 while(ctmp<speed)
111 ctmp=getfrequency(of.flags,getlinearperiod(note<<1,++finetune)); 109 ctmp=getfrequency(of.flags,getlinearperiod(note<<1,++ft));
112 } 110 }
113 } 111 }
114 112
115 noteindex[sample]=note-4*OCTAVE; 113 noteindex[sample]=note-4*OCTAVE;
116 return finetune; 114 return ft;
117} 115}
118 116
119/*========== Order stuff */ 117/*========== Order stuff */
@@ -141,13 +139,9 @@ void S3MIT_CreateOrders(int curious)
141/*========== Effect stuff */ 139/*========== Effect stuff */
142 140
143/* handles S3M and IT effects */ 141/* handles S3M and IT effects */
144void S3MIT_ProcessCmd(UBYTE cmd,UBYTE inf,unsigned int flags) 142void S3MIT_ProcessCmd(UBYTE cmd, UBYTE inf, unsigned int flags)
145{ 143{
146 UBYTE /* hi,*/ lo; 144 UBYTE lo = inf&0xF;
147
148 lo=inf&0xf;
149 /* hi=inf>>4; */
150
151 /* process S3M / IT specific command structure */ 145 /* process S3M / IT specific command structure */
152 146
153 if(cmd!=255) { 147 if(cmd!=255) {
@@ -196,7 +190,7 @@ void S3MIT_ProcessCmd(UBYTE cmd,UBYTE inf,unsigned int flags)
196 case 9: /* Ixy tremor, ontime x, offtime y */ 190 case 9: /* Ixy tremor, ontime x, offtime y */
197 if (flags & S3MIT_OLDSTYLE) 191 if (flags & S3MIT_OLDSTYLE)
198 UniEffect(UNI_S3MEFFECTI,inf); 192 UniEffect(UNI_S3MEFFECTI,inf);
199 else 193 else
200 UniEffect(UNI_ITEFFECTI,inf); 194 UniEffect(UNI_ITEFFECTI,inf);
201 break; 195 break;
202 case 0xa: /* Jxy arpeggio */ 196 case 0xa: /* Jxy arpeggio */
@@ -204,7 +198,7 @@ void S3MIT_ProcessCmd(UBYTE cmd,UBYTE inf,unsigned int flags)
204 break; 198 break;
205 case 0xb: /* Kxy Dual command H00 & Dxy */ 199 case 0xb: /* Kxy Dual command H00 & Dxy */
206 if (flags & S3MIT_OLDSTYLE) 200 if (flags & S3MIT_OLDSTYLE)
207 UniPTEffect(0x4,0); 201 UniPTEffect(0x4,0);
208 else 202 else
209 UniEffect(UNI_ITEFFECTH,0); 203 UniEffect(UNI_ITEFFECTH,0);
210 UniEffect(UNI_S3MEFFECTD,inf); 204 UniEffect(UNI_S3MEFFECTD,inf);
@@ -218,7 +212,7 @@ void S3MIT_ProcessCmd(UBYTE cmd,UBYTE inf,unsigned int flags)
218 break; 212 break;
219 case 0xd: /* Mxx Set Channel Volume */ 213 case 0xd: /* Mxx Set Channel Volume */
220 UniEffect(UNI_ITEFFECTM,inf); 214 UniEffect(UNI_ITEFFECTM,inf);
221 break; 215 break;
222 case 0xe: /* Nxy Slide Channel Volume */ 216 case 0xe: /* Nxy Slide Channel Volume */
223 UniEffect(UNI_ITEFFECTN,inf); 217 UniEffect(UNI_ITEFFECTN,inf);
224 break; 218 break;
@@ -233,7 +227,7 @@ void S3MIT_ProcessCmd(UBYTE cmd,UBYTE inf,unsigned int flags)
233 if(inf && !lo && !(flags & S3MIT_OLDSTYLE)) 227 if(inf && !lo && !(flags & S3MIT_OLDSTYLE))
234 UniWriteByte(1); 228 UniWriteByte(1);
235 else 229 else
236 UniWriteByte(inf); 230 UniWriteByte(inf);
237 break; 231 break;
238 case 0x12: /* Rxy tremolo speed x, depth y */ 232 case 0x12: /* Rxy tremolo speed x, depth y */
239 UniEffect(UNI_S3MEFFECTR,inf); 233 UniEffect(UNI_S3MEFFECTR,inf);