annotate playercode/mplayer.c @ 7:de95ce2eacfd

Initial revision
author darius
date Fri, 23 Jan 1998 16:05:09 +0000
parents
children 437e8455d862
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1 /*
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2 --> The Protracker Player Driver
de95ce2eacfd Initial revision
darius
parents:
diff changeset
3 -> Part of the SPLAYER pack for MikMod 3.0
de95ce2eacfd Initial revision
darius
parents:
diff changeset
4
de95ce2eacfd Initial revision
darius
parents:
diff changeset
5 The protracker driver supports all base Protracker 3.x commands and fea-
de95ce2eacfd Initial revision
darius
parents:
diff changeset
6 tures.
de95ce2eacfd Initial revision
darius
parents:
diff changeset
7 */
de95ce2eacfd Initial revision
darius
parents:
diff changeset
8
de95ce2eacfd Initial revision
darius
parents:
diff changeset
9 #include <string.h>
de95ce2eacfd Initial revision
darius
parents:
diff changeset
10 #include <stdarg.h>
de95ce2eacfd Initial revision
darius
parents:
diff changeset
11 #include "mikmod.h"
de95ce2eacfd Initial revision
darius
parents:
diff changeset
12
de95ce2eacfd Initial revision
darius
parents:
diff changeset
13
de95ce2eacfd Initial revision
darius
parents:
diff changeset
14 static void DoNNAEffects(UBYTE dat);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
15
de95ce2eacfd Initial revision
darius
parents:
diff changeset
16 // Set forbid to 1 when you want to modify any of the pf->sngpos, pf->patpos etc.
de95ce2eacfd Initial revision
darius
parents:
diff changeset
17 // variables and clear it when you're done. This prevents getting strange
de95ce2eacfd Initial revision
darius
parents:
diff changeset
18 // results due to intermediate interrupts.
de95ce2eacfd Initial revision
darius
parents:
diff changeset
19
de95ce2eacfd Initial revision
darius
parents:
diff changeset
20 static UNIMOD *pf; // <- this modfile is being played
de95ce2eacfd Initial revision
darius
parents:
diff changeset
21 static SWORD mp_channel; // channel it's working on
de95ce2eacfd Initial revision
darius
parents:
diff changeset
22 static MP_CONTROL *a; // current AUDTMP it's working on
de95ce2eacfd Initial revision
darius
parents:
diff changeset
23 static int isfirst;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
24
de95ce2eacfd Initial revision
darius
parents:
diff changeset
25 static MP_VOICE aout_dummy;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
26
de95ce2eacfd Initial revision
darius
parents:
diff changeset
27 static UWORD mytab[12] =
de95ce2eacfd Initial revision
darius
parents:
diff changeset
28 { 1712*16, 1616*16, 1524*16, 1440*16, 1356*16, 1280*16,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
29 1208*16, 1140*16, 1076*16, 1016*16, 960*16, 907*16
de95ce2eacfd Initial revision
darius
parents:
diff changeset
30 };
de95ce2eacfd Initial revision
darius
parents:
diff changeset
31
de95ce2eacfd Initial revision
darius
parents:
diff changeset
32
de95ce2eacfd Initial revision
darius
parents:
diff changeset
33 static UBYTE VibratoTable[32] =
de95ce2eacfd Initial revision
darius
parents:
diff changeset
34 { 0,24,49,74,97,120,141,161,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
35 180,197,212,224,235,244,250,253,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
36 255,253,250,244,235,224,212,197,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
37 180,161,141,120,97,74,49,24
de95ce2eacfd Initial revision
darius
parents:
diff changeset
38 };
de95ce2eacfd Initial revision
darius
parents:
diff changeset
39
de95ce2eacfd Initial revision
darius
parents:
diff changeset
40
de95ce2eacfd Initial revision
darius
parents:
diff changeset
41 static UBYTE avibtab[128] =
de95ce2eacfd Initial revision
darius
parents:
diff changeset
42 { 0,1,3,4,6,7,9,10,12,14,15,17,18,20,21,23,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
43 24,25,27,28,30,31,32,34,35,36,38,39,40,41,42,44,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
44 45,46,47,48,49,50,51,52,53,54,54,55,56,57,57,58,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
45 59,59,60,60,61,61,62,62,62,63,63,63,63,63,63,63,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
46 64,63,63,63,63,63,63,63,62,62,62,61,61,60,60,59,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
47 59,58,57,57,56,55,54,54,53,52,51,50,49,48,47,46,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
48 45,44,42,41,40,39,38,36,35,34,32,31,30,28,27,25,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
49 24,23,21,20,18,17,15,14,12,10,9,7,6,4,3,1
de95ce2eacfd Initial revision
darius
parents:
diff changeset
50 };
de95ce2eacfd Initial revision
darius
parents:
diff changeset
51
de95ce2eacfd Initial revision
darius
parents:
diff changeset
52
de95ce2eacfd Initial revision
darius
parents:
diff changeset
53 // ** Triton's linear periods to frequency translation table (for
de95ce2eacfd Initial revision
darius
parents:
diff changeset
54 // ** Fast Tracker 2 [XM] modules):
de95ce2eacfd Initial revision
darius
parents:
diff changeset
55
de95ce2eacfd Initial revision
darius
parents:
diff changeset
56 static ULONG lintab[768] =
de95ce2eacfd Initial revision
darius
parents:
diff changeset
57 { 535232,534749,534266,533784,533303,532822,532341,531861,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
58 531381,530902,530423,529944,529466,528988,528511,528034,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
59 527558,527082,526607,526131,525657,525183,524709,524236,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
60 523763,523290,522818,522346,521875,521404,520934,520464,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
61 519994,519525,519057,518588,518121,517653,517186,516720,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
62 516253,515788,515322,514858,514393,513929,513465,513002,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
63 512539,512077,511615,511154,510692,510232,509771,509312,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
64 508852,508393,507934,507476,507018,506561,506104,505647,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
65 505191,504735,504280,503825,503371,502917,502463,502010,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
66 501557,501104,500652,500201,499749,499298,498848,498398,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
67 497948,497499,497050,496602,496154,495706,495259,494812,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
68 494366,493920,493474,493029,492585,492140,491696,491253,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
69 490809,490367,489924,489482,489041,488600,488159,487718,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
70 487278,486839,486400,485961,485522,485084,484647,484210,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
71 483773,483336,482900,482465,482029,481595,481160,480726,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
72 480292,479859,479426,478994,478562,478130,477699,477268,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
73 476837,476407,475977,475548,475119,474690,474262,473834,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
74 473407,472979,472553,472126,471701,471275,470850,470425,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
75 470001,469577,469153,468730,468307,467884,467462,467041,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
76 466619,466198,465778,465358,464938,464518,464099,463681,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
77 463262,462844,462427,462010,461593,461177,460760,460345,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
78 459930,459515,459100,458686,458272,457859,457446,457033,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
79 456621,456209,455797,455386,454975,454565,454155,453745,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
80 453336,452927,452518,452110,451702,451294,450887,450481,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
81 450074,449668,449262,448857,448452,448048,447644,447240,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
82 446836,446433,446030,445628,445226,444824,444423,444022,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
83 443622,443221,442821,442422,442023,441624,441226,440828,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
84 440430,440033,439636,439239,438843,438447,438051,437656,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
85 437261,436867,436473,436079,435686,435293,434900,434508,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
86 434116,433724,433333,432942,432551,432161,431771,431382,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
87 430992,430604,430215,429827,429439,429052,428665,428278,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
88 427892,427506,427120,426735,426350,425965,425581,425197,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
89 424813,424430,424047,423665,423283,422901,422519,422138,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
90 421757,421377,420997,420617,420237,419858,419479,419101,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
91 418723,418345,417968,417591,417214,416838,416462,416086,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
92 415711,415336,414961,414586,414212,413839,413465,413092,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
93 412720,412347,411975,411604,411232,410862,410491,410121,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
94 409751,409381,409012,408643,408274,407906,407538,407170,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
95 406803,406436,406069,405703,405337,404971,404606,404241,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
96 403876,403512,403148,402784,402421,402058,401695,401333,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
97 400970,400609,400247,399886,399525,399165,398805,398445,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
98 398086,397727,397368,397009,396651,396293,395936,395579,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
99 395222,394865,394509,394153,393798,393442,393087,392733,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
100 392378,392024,391671,391317,390964,390612,390259,389907,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
101 389556,389204,388853,388502,388152,387802,387452,387102,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
102 386753,386404,386056,385707,385359,385012,384664,384317,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
103 383971,383624,383278,382932,382587,382242,381897,381552,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
104 381208,380864,380521,380177,379834,379492,379149,378807,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
105
de95ce2eacfd Initial revision
darius
parents:
diff changeset
106 378466,378124,377783,377442,377102,376762,376422,376082,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
107 375743,375404,375065,374727,374389,374051,373714,373377,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
108 373040,372703,372367,372031,371695,371360,371025,370690,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
109 370356,370022,369688,369355,369021,368688,368356,368023,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
110 367691,367360,367028,366697,366366,366036,365706,365376,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
111 365046,364717,364388,364059,363731,363403,363075,362747,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
112 362420,362093,361766,361440,361114,360788,360463,360137,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
113 359813,359488,359164,358840,358516,358193,357869,357547,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
114 357224,356902,356580,356258,355937,355616,355295,354974,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
115 354654,354334,354014,353695,353376,353057,352739,352420,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
116 352103,351785,351468,351150,350834,350517,350201,349885,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
117 349569,349254,348939,348624,348310,347995,347682,347368,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
118 347055,346741,346429,346116,345804,345492,345180,344869,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
119 344558,344247,343936,343626,343316,343006,342697,342388,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
120 342079,341770,341462,341154,340846,340539,340231,339924,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
121 339618,339311,339005,338700,338394,338089,337784,337479,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
122 337175,336870,336566,336263,335959,335656,335354,335051,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
123 334749,334447,334145,333844,333542,333242,332941,332641,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
124 332341,332041,331741,331442,331143,330844,330546,330247,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
125 329950,329652,329355,329057,328761,328464,328168,327872,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
126 327576,327280,326985,326690,326395,326101,325807,325513,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
127 325219,324926,324633,324340,324047,323755,323463,323171,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
128 322879,322588,322297,322006,321716,321426,321136,320846,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
129 320557,320267,319978,319690,319401,319113,318825,318538,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
130 318250,317963,317676,317390,317103,316817,316532,316246,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
131 315961,315676,315391,315106,314822,314538,314254,313971,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
132 313688,313405,313122,312839,312557,312275,311994,311712,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
133 311431,311150,310869,310589,310309,310029,309749,309470,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
134 309190,308911,308633,308354,308076,307798,307521,307243,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
135 306966,306689,306412,306136,305860,305584,305308,305033,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
136 304758,304483,304208,303934,303659,303385,303112,302838,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
137 302565,302292,302019,301747,301475,301203,300931,300660,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
138 300388,300117,299847,299576,299306,299036,298766,298497,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
139 298227,297958,297689,297421,297153,296884,296617,296349,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
140 296082,295815,295548,295281,295015,294749,294483,294217,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
141 293952,293686,293421,293157,292892,292628,292364,292100,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
142 291837,291574,291311,291048,290785,290523,290261,289999,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
143 289737,289476,289215,288954,288693,288433,288173,287913,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
144 287653,287393,287134,286875,286616,286358,286099,285841,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
145 285583,285326,285068,284811,284554,284298,284041,283785,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
146 283529,283273,283017,282762,282507,282252,281998,281743,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
147 281489,281235,280981,280728,280475,280222,279969,279716,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
148 279464,279212,278960,278708,278457,278206,277955,277704,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
149 277453,277203,276953,276703,276453,276204,275955,275706,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
150 275457,275209,274960,274712,274465,274217,273970,273722,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
151 273476,273229,272982,272736,272490,272244,271999,271753,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
152 271508,271263,271018,270774,270530,270286,270042,269798,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
153 269555,269312,269069,268826,268583,268341,268099,267857
de95ce2eacfd Initial revision
darius
parents:
diff changeset
154 };
de95ce2eacfd Initial revision
darius
parents:
diff changeset
155
de95ce2eacfd Initial revision
darius
parents:
diff changeset
156
de95ce2eacfd Initial revision
darius
parents:
diff changeset
157 #define LOGFAC 2*16
de95ce2eacfd Initial revision
darius
parents:
diff changeset
158
de95ce2eacfd Initial revision
darius
parents:
diff changeset
159 static UWORD logtab[104] =
de95ce2eacfd Initial revision
darius
parents:
diff changeset
160 { LOGFAC*907,LOGFAC*900,LOGFAC*894,LOGFAC*887,LOGFAC*881,LOGFAC*875,LOGFAC*868,LOGFAC*862,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
161 LOGFAC*856,LOGFAC*850,LOGFAC*844,LOGFAC*838,LOGFAC*832,LOGFAC*826,LOGFAC*820,LOGFAC*814,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
162 LOGFAC*808,LOGFAC*802,LOGFAC*796,LOGFAC*791,LOGFAC*785,LOGFAC*779,LOGFAC*774,LOGFAC*768,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
163 LOGFAC*762,LOGFAC*757,LOGFAC*752,LOGFAC*746,LOGFAC*741,LOGFAC*736,LOGFAC*730,LOGFAC*725,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
164 LOGFAC*720,LOGFAC*715,LOGFAC*709,LOGFAC*704,LOGFAC*699,LOGFAC*694,LOGFAC*689,LOGFAC*684,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
165 LOGFAC*678,LOGFAC*675,LOGFAC*670,LOGFAC*665,LOGFAC*660,LOGFAC*655,LOGFAC*651,LOGFAC*646,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
166 LOGFAC*640,LOGFAC*636,LOGFAC*632,LOGFAC*628,LOGFAC*623,LOGFAC*619,LOGFAC*614,LOGFAC*610,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
167 LOGFAC*604,LOGFAC*601,LOGFAC*597,LOGFAC*592,LOGFAC*588,LOGFAC*584,LOGFAC*580,LOGFAC*575,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
168 LOGFAC*570,LOGFAC*567,LOGFAC*563,LOGFAC*559,LOGFAC*555,LOGFAC*551,LOGFAC*547,LOGFAC*543,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
169 LOGFAC*538,LOGFAC*535,LOGFAC*532,LOGFAC*528,LOGFAC*524,LOGFAC*520,LOGFAC*516,LOGFAC*513,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
170 LOGFAC*508,LOGFAC*505,LOGFAC*502,LOGFAC*498,LOGFAC*494,LOGFAC*491,LOGFAC*487,LOGFAC*484,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
171 LOGFAC*480,LOGFAC*477,LOGFAC*474,LOGFAC*470,LOGFAC*467,LOGFAC*463,LOGFAC*460,LOGFAC*457,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
172 LOGFAC*453,LOGFAC*450,LOGFAC*447,LOGFAC*443,LOGFAC*440,LOGFAC*437,LOGFAC*434,LOGFAC*431
de95ce2eacfd Initial revision
darius
parents:
diff changeset
173 };
de95ce2eacfd Initial revision
darius
parents:
diff changeset
174
de95ce2eacfd Initial revision
darius
parents:
diff changeset
175 static SBYTE PanbrelloTable[256] =
de95ce2eacfd Initial revision
darius
parents:
diff changeset
176 { 0,2,3,5,6,8,9,11,12,14,16,17,19,20,22,23,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
177 24,26,27,29,30,32,33,34,36,37,38,39,41,42,43,44,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
178 45,46,47,48,49,50,51,52,53,54,55,56,56,57,58,59,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
179 59,60,60,61,61,62,62,62,63,63,63,64,64,64,64,64,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
180 64,64,64,64,64,64,63,63,63,62,62,62,61,61,60,60,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
181 59,59,58,57,56,56,55,54,53,52,51,50,49,48,47,46,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
182 45,44,43,42,41,39,38,37,36,34,33,32,30,29,27,26,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
183 24,23,22,20,19,17,16,14,12,11,9,8,6,5,3,2,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
184 0,-2,-3,-5,-6,-8,-9,-11,-12,-14,-16,-17,-19,-20,-22,-23,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
185 -24,-26,-27,-29,-30,-32,-33,-34,-36,-37,-38,-39,-41,-42,-43,-44,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
186 -45,-46,-47,-48,-49,-50,-51,-52,-53,-54,-55,-56,-56,-57,-58,-59,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
187 -59,-60,-60,-61,-61,-62,-62,-62,-63,-63,-63,-64,-64,-64,-64,-64,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
188 -64,-64,-64,-64,-64,-64,-63,-63,-63,-62,-62,-62,-61,-61,-60,-60,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
189 -59,-59,-58,-57,-56,-56,-55,-54,-53,-52,-51,-50,-49,-48,-47,-46,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
190 -45,-44,-43,-42,-41,-39,-38,-37,-36,-34,-33,-32,-30,-29,-27,-26,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
191 -24,-23,-22,-20,-19,-17,-16,-14,-12,-11,-9,-8,-6,-5,-3,-2
de95ce2eacfd Initial revision
darius
parents:
diff changeset
192 };
de95ce2eacfd Initial revision
darius
parents:
diff changeset
193
de95ce2eacfd Initial revision
darius
parents:
diff changeset
194
de95ce2eacfd Initial revision
darius
parents:
diff changeset
195 /* New Note Action Scoring System:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
196 ---------------------------------
de95ce2eacfd Initial revision
darius
parents:
diff changeset
197 1) total-volume (fadevol, chanvol, volume) is the main scorer.
de95ce2eacfd Initial revision
darius
parents:
diff changeset
198 2) a looping sample is a bonus x2
de95ce2eacfd Initial revision
darius
parents:
diff changeset
199 3) a forground channel is a bonus x4
de95ce2eacfd Initial revision
darius
parents:
diff changeset
200 4) an active envelope with keyoff is a handicap -x2
de95ce2eacfd Initial revision
darius
parents:
diff changeset
201 */
de95ce2eacfd Initial revision
darius
parents:
diff changeset
202 static int MP_FindEmptyChannel(int curchan) // returns mp_control index of free channel
de95ce2eacfd Initial revision
darius
parents:
diff changeset
203 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
204 MP_VOICE *a;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
205 ULONG t,k,tvol,p,pp;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
206
de95ce2eacfd Initial revision
darius
parents:
diff changeset
207 /*for(t=md_sngchn; t; t--, audpool++)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
208 { if(audpool == md_sngchn) audpool = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
209 if(!(pf->voice[audpool].kick) && Voice_Stopped(audpool))
de95ce2eacfd Initial revision
darius
parents:
diff changeset
210 { audpool++;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
211 return audpool-1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
212 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
213 }*/
de95ce2eacfd Initial revision
darius
parents:
diff changeset
214
de95ce2eacfd Initial revision
darius
parents:
diff changeset
215 for(t=0; t<md_sngchn; t++)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
216 { if(!(pf->voice[t].kick) && Voice_Stopped(t))
de95ce2eacfd Initial revision
darius
parents:
diff changeset
217 { return t;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
218 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
219 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
220
de95ce2eacfd Initial revision
darius
parents:
diff changeset
221 tvol = 0xffffffUL; t = 0; p = 0; a = pf->voice;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
222 for(k=0; k<md_sngchn; k++, a++)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
223 { if(!a->kick)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
224 { pp = a->totalvol << ((a->s->flags & SF_LOOP) ? 1 : 0);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
225 if((a->master!=NULL) && (a==a->master->slave))
de95ce2eacfd Initial revision
darius
parents:
diff changeset
226 pp <<= 2;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
227
de95ce2eacfd Initial revision
darius
parents:
diff changeset
228 /*if(a->volflg & EF_ON)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
229 { if(a->volflg & (EF_SUSTAIN | EF_LOOP))
de95ce2eacfd Initial revision
darius
parents:
diff changeset
230 { if(a->keyoff & KEY_OFF)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
231 { pp >>= 1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
232 if(a->venv.env[a->venv.end].val < 32) pp>>=1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
233 } else
de95ce2eacfd Initial revision
darius
parents:
diff changeset
234 pp <<= 1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
235 } else pp <<= 1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
236 }*/
de95ce2eacfd Initial revision
darius
parents:
diff changeset
237
de95ce2eacfd Initial revision
darius
parents:
diff changeset
238 if(pp < tvol)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
239 { tvol = pp;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
240 t = k;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
241 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
242 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
243 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
244
de95ce2eacfd Initial revision
darius
parents:
diff changeset
245 if(tvol>8000*7) return -1; //mp_channel;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
246
de95ce2eacfd Initial revision
darius
parents:
diff changeset
247 return t;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
248 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
249
de95ce2eacfd Initial revision
darius
parents:
diff changeset
250
de95ce2eacfd Initial revision
darius
parents:
diff changeset
251 static SWORD Interpolate(SWORD p, SWORD p1, SWORD p2, SWORD v1, SWORD v2)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
252 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
253 SWORD dp,dv,di;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
254
de95ce2eacfd Initial revision
darius
parents:
diff changeset
255 if(p1==p2) return v1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
256
de95ce2eacfd Initial revision
darius
parents:
diff changeset
257 dv = v2-v1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
258 dp = p2-p1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
259 di = p-p1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
260
de95ce2eacfd Initial revision
darius
parents:
diff changeset
261 return v1 + ((SLONG)(di*dv) / dp);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
262 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
263
de95ce2eacfd Initial revision
darius
parents:
diff changeset
264
de95ce2eacfd Initial revision
darius
parents:
diff changeset
265 UWORD getlinearperiod(UBYTE note, ULONG fine)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
266 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
267 return((10L*12*16*4)-((ULONG)note*16*4)-(fine/2)+64);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
268 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
269
de95ce2eacfd Initial revision
darius
parents:
diff changeset
270
de95ce2eacfd Initial revision
darius
parents:
diff changeset
271 static UWORD getlogperiod(UBYTE note,ULONG fine)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
272 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
273 UBYTE n,o;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
274 UWORD p1,p2;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
275 ULONG i;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
276
de95ce2eacfd Initial revision
darius
parents:
diff changeset
277 n = note%12;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
278 o = note/12;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
279 i = (n<<3) + (fine>>4); // n*8 + fine/16
de95ce2eacfd Initial revision
darius
parents:
diff changeset
280
de95ce2eacfd Initial revision
darius
parents:
diff changeset
281 p1 = logtab[i];
de95ce2eacfd Initial revision
darius
parents:
diff changeset
282 p2 = logtab[i+1];
de95ce2eacfd Initial revision
darius
parents:
diff changeset
283
de95ce2eacfd Initial revision
darius
parents:
diff changeset
284 return(Interpolate(fine/16,0,15,p1,p2)>>o);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
285 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
286
de95ce2eacfd Initial revision
darius
parents:
diff changeset
287
de95ce2eacfd Initial revision
darius
parents:
diff changeset
288 static UWORD getoldperiod(UBYTE note, ULONG speed)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
289 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
290 UBYTE n, o;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
291 ULONG period;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
292
de95ce2eacfd Initial revision
darius
parents:
diff changeset
293 if(!speed) return 4242; // <- prevent divide overflow.. (42 eheh)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
294
de95ce2eacfd Initial revision
darius
parents:
diff changeset
295 n = note % 12;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
296 o = note / 12;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
297 period = ((8363l*(ULONG)mytab[n]) >> o ) / speed;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
298 return period;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
299 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
300
de95ce2eacfd Initial revision
darius
parents:
diff changeset
301
de95ce2eacfd Initial revision
darius
parents:
diff changeset
302 static UWORD GetPeriod(UBYTE note, ULONG speed)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
303 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
304 if(pf->flags & UF_XMPERIODS)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
305 return (pf->flags & UF_LINEAR) ? getlinearperiod(note,speed) : getlogperiod(note,speed);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
306
de95ce2eacfd Initial revision
darius
parents:
diff changeset
307 return getoldperiod(note,speed);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
308 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
309
de95ce2eacfd Initial revision
darius
parents:
diff changeset
310
de95ce2eacfd Initial revision
darius
parents:
diff changeset
311 static SWORD InterpolateEnv(SWORD p, ENVPT *a, ENVPT *b)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
312 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
313 return(Interpolate(p,a->pos,b->pos,a->val,b->val));
de95ce2eacfd Initial revision
darius
parents:
diff changeset
314 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
315
de95ce2eacfd Initial revision
darius
parents:
diff changeset
316
de95ce2eacfd Initial revision
darius
parents:
diff changeset
317 static SWORD DoPan(SWORD envpan, SWORD pan)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
318 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
319 return(pan + (((envpan-128)*(128-abs(pan-128)))/128));
de95ce2eacfd Initial revision
darius
parents:
diff changeset
320 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
321
de95ce2eacfd Initial revision
darius
parents:
diff changeset
322
de95ce2eacfd Initial revision
darius
parents:
diff changeset
323 static void StartEnvelope(ENVPR *t, UBYTE flg, UBYTE pts, UBYTE susbeg, UBYTE susend, UBYTE beg, UBYTE end, ENVPT *p, UBYTE keyoff)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
324 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
325 t->flg = flg;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
326 t->pts = pts;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
327 t->susbeg = susbeg;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
328 t->susend = susend;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
329 t->beg = beg;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
330 t->end = end;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
331 t->env = p;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
332 t->p = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
333 t->a = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
334 t->b = ((t->flg & EF_SUSTAIN) && !(keyoff & KEY_OFF)) ? 0 : 1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
335 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
336
de95ce2eacfd Initial revision
darius
parents:
diff changeset
337
de95ce2eacfd Initial revision
darius
parents:
diff changeset
338 static SWORD ProcessEnvelope(ENVPR *t, SWORD v, UBYTE keyoff)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
339
de95ce2eacfd Initial revision
darius
parents:
diff changeset
340 // This procedure processes all envelope types, include volume, pitch, and
de95ce2eacfd Initial revision
darius
parents:
diff changeset
341 // panning. Envelopes are defined by a set of points, each with a magnitude
de95ce2eacfd Initial revision
darius
parents:
diff changeset
342 // [relating either to volume, panniong position, or pitch modifier] and a
de95ce2eacfd Initial revision
darius
parents:
diff changeset
343 // tick position.
de95ce2eacfd Initial revision
darius
parents:
diff changeset
344 //
de95ce2eacfd Initial revision
darius
parents:
diff changeset
345 // Envelopes work in the following manner:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
346 //
de95ce2eacfd Initial revision
darius
parents:
diff changeset
347 // (a) Each tick the envelope is moved a point further in its progression.
de95ce2eacfd Initial revision
darius
parents:
diff changeset
348 // 1. For an accurate progression, magnitudes between two envelope points
de95ce2eacfd Initial revision
darius
parents:
diff changeset
349 // are interpolated.
de95ce2eacfd Initial revision
darius
parents:
diff changeset
350 //
de95ce2eacfd Initial revision
darius
parents:
diff changeset
351 // (b) When progression reaches a defined point on the envelope, values
de95ce2eacfd Initial revision
darius
parents:
diff changeset
352 // are shifted to interpolate between this point and the next,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
353 // and checks for loops or envelope end are done.
de95ce2eacfd Initial revision
darius
parents:
diff changeset
354 //
de95ce2eacfd Initial revision
darius
parents:
diff changeset
355 // Misc:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
356 // Sustain loops are loops that are only active as long as the keyoff
de95ce2eacfd Initial revision
darius
parents:
diff changeset
357 // flag is clear. When a volume envelope terminates, so does the current
de95ce2eacfd Initial revision
darius
parents:
diff changeset
358 // fadeout.
de95ce2eacfd Initial revision
darius
parents:
diff changeset
359
de95ce2eacfd Initial revision
darius
parents:
diff changeset
360 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
361 if(t->flg & EF_ON)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
362 { UBYTE a, b; // actual points in the envelope
de95ce2eacfd Initial revision
darius
parents:
diff changeset
363 UWORD p; // the 'tick counter' - real point being played
de95ce2eacfd Initial revision
darius
parents:
diff changeset
364
de95ce2eacfd Initial revision
darius
parents:
diff changeset
365 a = t->a;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
366 b = t->b;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
367 p = t->p;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
368
de95ce2eacfd Initial revision
darius
parents:
diff changeset
369 // compute the current envelope value between points a and b
de95ce2eacfd Initial revision
darius
parents:
diff changeset
370
de95ce2eacfd Initial revision
darius
parents:
diff changeset
371 if(a == b)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
372 v = t->env[a].val;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
373 else
de95ce2eacfd Initial revision
darius
parents:
diff changeset
374 v = InterpolateEnv(p, &t->env[a], &t->env[b]);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
375
de95ce2eacfd Initial revision
darius
parents:
diff changeset
376 p++;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
377
de95ce2eacfd Initial revision
darius
parents:
diff changeset
378 // pointer reached point b?
de95ce2eacfd Initial revision
darius
parents:
diff changeset
379
de95ce2eacfd Initial revision
darius
parents:
diff changeset
380 if(p >= t->env[b].pos)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
381 { a = b++; // shift points a and b
de95ce2eacfd Initial revision
darius
parents:
diff changeset
382
de95ce2eacfd Initial revision
darius
parents:
diff changeset
383 // Check for loops, sustain loops, or end of envelope.
de95ce2eacfd Initial revision
darius
parents:
diff changeset
384
de95ce2eacfd Initial revision
darius
parents:
diff changeset
385 if((t->flg & EF_SUSTAIN) && !(keyoff & KEY_OFF) && (b > t->susend))
de95ce2eacfd Initial revision
darius
parents:
diff changeset
386 { a = t->susbeg;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
387 if(t->susbeg == t->susend) b = a; else b = a + 1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
388 p = t->env[a].pos;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
389 } else if((t->flg & EF_LOOP) && (b > t->end))
de95ce2eacfd Initial revision
darius
parents:
diff changeset
390 { a = t->beg;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
391 if(t->beg == t->end) b = a; else b = a + 1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
392 p = t->env[a].pos;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
393 } else
de95ce2eacfd Initial revision
darius
parents:
diff changeset
394 { if(b >= t->pts)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
395 { if((t->flg & EF_VOLENV) && (mp_channel != -1))
de95ce2eacfd Initial revision
darius
parents:
diff changeset
396 { pf->voice[mp_channel].keyoff |= KEY_FADE;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
397 if(v==0)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
398 pf->voice[mp_channel].fadevol = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
399 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
400 b--; p--;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
401 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
402 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
403 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
404 t->a = a;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
405 t->b = b;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
406 t->p = p;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
407 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
408 return v;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
409 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
410
de95ce2eacfd Initial revision
darius
parents:
diff changeset
411
de95ce2eacfd Initial revision
darius
parents:
diff changeset
412 ULONG getfrequency(UBYTE flags, ULONG period)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
413
de95ce2eacfd Initial revision
darius
parents:
diff changeset
414 // XM linear period to frequency conversion
de95ce2eacfd Initial revision
darius
parents:
diff changeset
415
de95ce2eacfd Initial revision
darius
parents:
diff changeset
416 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
417 ULONG result;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
418
de95ce2eacfd Initial revision
darius
parents:
diff changeset
419 if(flags & UF_LINEAR)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
420 result = lintab[period % 768] >> (period / 768);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
421 else
de95ce2eacfd Initial revision
darius
parents:
diff changeset
422 result = (8363L*1712L) / period;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
423
de95ce2eacfd Initial revision
darius
parents:
diff changeset
424 return result;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
425 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
426
de95ce2eacfd Initial revision
darius
parents:
diff changeset
427
de95ce2eacfd Initial revision
darius
parents:
diff changeset
428 static void DoEEffects(UBYTE dat)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
429 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
430 UBYTE nib;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
431
de95ce2eacfd Initial revision
darius
parents:
diff changeset
432 nib = dat & 0xf;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
433
de95ce2eacfd Initial revision
darius
parents:
diff changeset
434 switch(dat>>4)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
435 { case 0x0: // filter toggle, not supported
de95ce2eacfd Initial revision
darius
parents:
diff changeset
436 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
437
de95ce2eacfd Initial revision
darius
parents:
diff changeset
438 case 0x1: // fineslide up
de95ce2eacfd Initial revision
darius
parents:
diff changeset
439 if(!pf->vbtick) a->tmpperiod-=(nib<<2);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
440 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
441
de95ce2eacfd Initial revision
darius
parents:
diff changeset
442 case 0x2: // fineslide dn
de95ce2eacfd Initial revision
darius
parents:
diff changeset
443 if(!pf->vbtick) a->tmpperiod+=(nib<<2);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
444 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
445
de95ce2eacfd Initial revision
darius
parents:
diff changeset
446 case 0x3: // glissando ctrl
de95ce2eacfd Initial revision
darius
parents:
diff changeset
447 a->glissando = nib;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
448 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
449
de95ce2eacfd Initial revision
darius
parents:
diff changeset
450 case 0x4: // set vibrato waveform
de95ce2eacfd Initial revision
darius
parents:
diff changeset
451 a->wavecontrol &= 0xf0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
452 a->wavecontrol |= nib;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
453 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
454
de95ce2eacfd Initial revision
darius
parents:
diff changeset
455 case 0x5: // set finetune
de95ce2eacfd Initial revision
darius
parents:
diff changeset
456 // a->speed=finetune[nib];
de95ce2eacfd Initial revision
darius
parents:
diff changeset
457 // a->tmpperiod=GetPeriod(a->note,pf->samples[a->sample].transpose,a->speed);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
458 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
459
de95ce2eacfd Initial revision
darius
parents:
diff changeset
460 case 0x6: // set patternloop
de95ce2eacfd Initial revision
darius
parents:
diff changeset
461 if(pf->vbtick) break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
462 // hmm.. this one is a real kludge. But now it
de95ce2eacfd Initial revision
darius
parents:
diff changeset
463 // works
de95ce2eacfd Initial revision
darius
parents:
diff changeset
464 if(nib) // set reppos or repcnt ?
de95ce2eacfd Initial revision
darius
parents:
diff changeset
465 { // set repcnt, so check if repcnt already is set,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
466 // which means we are already looping
de95ce2eacfd Initial revision
darius
parents:
diff changeset
467
de95ce2eacfd Initial revision
darius
parents:
diff changeset
468 if(pf->pat_repcnt > 0)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
469 pf->pat_repcnt--; // already looping, decrease counter
de95ce2eacfd Initial revision
darius
parents:
diff changeset
470 else
de95ce2eacfd Initial revision
darius
parents:
diff changeset
471 pf->pat_repcnt = nib; // not yet looping, so set repcnt
de95ce2eacfd Initial revision
darius
parents:
diff changeset
472
de95ce2eacfd Initial revision
darius
parents:
diff changeset
473 if(pf->pat_repcnt) // jump to reppos if repcnt>0
de95ce2eacfd Initial revision
darius
parents:
diff changeset
474 pf->patpos = pf->pat_reppos;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
475 } else
de95ce2eacfd Initial revision
darius
parents:
diff changeset
476 { pf->pat_reppos = pf->patpos-1; // set reppos
de95ce2eacfd Initial revision
darius
parents:
diff changeset
477 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
478 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
479
de95ce2eacfd Initial revision
darius
parents:
diff changeset
480
de95ce2eacfd Initial revision
darius
parents:
diff changeset
481 case 0x7: // set tremolo waveform
de95ce2eacfd Initial revision
darius
parents:
diff changeset
482 a->wavecontrol &= 0x0f;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
483 a->wavecontrol |= nib << 4;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
484 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
485
de95ce2eacfd Initial revision
darius
parents:
diff changeset
486 case 0x8: // set panning
de95ce2eacfd Initial revision
darius
parents:
diff changeset
487 if(pf->panflag)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
488 { if(nib<=8) nib*=16; else nib*=17;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
489 a->panning = nib;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
490 pf->panning[mp_channel] = nib;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
491 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
492 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
493
de95ce2eacfd Initial revision
darius
parents:
diff changeset
494 case 0x9: // retrig note
de95ce2eacfd Initial revision
darius
parents:
diff changeset
495 // only retrigger if
de95ce2eacfd Initial revision
darius
parents:
diff changeset
496 // data nibble > 0
de95ce2eacfd Initial revision
darius
parents:
diff changeset
497
de95ce2eacfd Initial revision
darius
parents:
diff changeset
498 if(nib > 0)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
499 { if(a->retrig==0)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
500 { // when retrig counter reaches 0,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
501 // reset counter and restart the sample
de95ce2eacfd Initial revision
darius
parents:
diff changeset
502 a->kick = 1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
503 a->retrig = nib;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
504 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
505 a->retrig--; // countdown
de95ce2eacfd Initial revision
darius
parents:
diff changeset
506 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
507 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
508
de95ce2eacfd Initial revision
darius
parents:
diff changeset
509 case 0xa: // fine volume slide up
de95ce2eacfd Initial revision
darius
parents:
diff changeset
510 if(pf->vbtick) break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
511
de95ce2eacfd Initial revision
darius
parents:
diff changeset
512 a->tmpvolume += nib;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
513 if(a->tmpvolume > 64) a->tmpvolume = 64;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
514 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
515
de95ce2eacfd Initial revision
darius
parents:
diff changeset
516 case 0xb: // fine volume slide dn
de95ce2eacfd Initial revision
darius
parents:
diff changeset
517 if(pf->vbtick) break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
518
de95ce2eacfd Initial revision
darius
parents:
diff changeset
519 a->tmpvolume -= nib;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
520 if(a->tmpvolume < 0) a->tmpvolume = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
521 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
522
de95ce2eacfd Initial revision
darius
parents:
diff changeset
523 case 0xc: // cut note
de95ce2eacfd Initial revision
darius
parents:
diff changeset
524 // When pf->vbtick reaches the cut-note value,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
525 // turn the volume to zero ( Just like
de95ce2eacfd Initial revision
darius
parents:
diff changeset
526 // on the amiga)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
527 if(pf->vbtick>=nib)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
528 a->tmpvolume = 0; // just turn the volume down
de95ce2eacfd Initial revision
darius
parents:
diff changeset
529 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
530
de95ce2eacfd Initial revision
darius
parents:
diff changeset
531 case 0xd: // note delay
de95ce2eacfd Initial revision
darius
parents:
diff changeset
532 // delay the start of the
de95ce2eacfd Initial revision
darius
parents:
diff changeset
533 // sample until pf->vbtick==nib
de95ce2eacfd Initial revision
darius
parents:
diff changeset
534 if(pf->vbtick==nib)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
535 { //a->kick = 1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
536 a->notedelay = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
537 } else if(pf->vbtick==0)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
538 { //a->kick = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
539 a->notedelay = 1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
540 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
541 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
542
de95ce2eacfd Initial revision
darius
parents:
diff changeset
543 case 0xe: // pattern delay
de95ce2eacfd Initial revision
darius
parents:
diff changeset
544 if(pf->vbtick) break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
545 if(!pf->patdly2) pf->patdly = nib+1; // only once (when pf->vbtick=0)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
546 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
547
de95ce2eacfd Initial revision
darius
parents:
diff changeset
548 case 0xf: // invert loop, not supported
de95ce2eacfd Initial revision
darius
parents:
diff changeset
549 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
550 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
551 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
552
de95ce2eacfd Initial revision
darius
parents:
diff changeset
553
de95ce2eacfd Initial revision
darius
parents:
diff changeset
554 static void DoVibrato(void)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
555 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
556 UBYTE q;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
557 UWORD temp;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
558
de95ce2eacfd Initial revision
darius
parents:
diff changeset
559 q = (a->vibpos>>2)&0x1f;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
560
de95ce2eacfd Initial revision
darius
parents:
diff changeset
561 switch(a->wavecontrol&3)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
562 { case 0: // sine
de95ce2eacfd Initial revision
darius
parents:
diff changeset
563 temp = VibratoTable[q];
de95ce2eacfd Initial revision
darius
parents:
diff changeset
564 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
565
de95ce2eacfd Initial revision
darius
parents:
diff changeset
566 case 1: // ramp down
de95ce2eacfd Initial revision
darius
parents:
diff changeset
567 q<<=3;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
568 if(a->vibpos<0) q = 255-q;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
569 temp = q;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
570 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
571
de95ce2eacfd Initial revision
darius
parents:
diff changeset
572 case 2: // square wave
de95ce2eacfd Initial revision
darius
parents:
diff changeset
573 temp = 255;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
574 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
575
de95ce2eacfd Initial revision
darius
parents:
diff changeset
576 case 3: // Evil random wave
de95ce2eacfd Initial revision
darius
parents:
diff changeset
577 temp = rand() & 255;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
578 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
579 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
580
de95ce2eacfd Initial revision
darius
parents:
diff changeset
581 temp*=a->vibdepth;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
582 temp>>=7;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
583 temp<<=2;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
584
de95ce2eacfd Initial revision
darius
parents:
diff changeset
585 if(a->vibpos>=0)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
586 a->period = a->tmpperiod+temp;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
587 else
de95ce2eacfd Initial revision
darius
parents:
diff changeset
588 a->period = a->tmpperiod-temp;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
589
de95ce2eacfd Initial revision
darius
parents:
diff changeset
590 if(pf->vbtick) a->vibpos+=a->vibspd; // do not update when pf->vbtick==0
de95ce2eacfd Initial revision
darius
parents:
diff changeset
591 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
592
de95ce2eacfd Initial revision
darius
parents:
diff changeset
593
de95ce2eacfd Initial revision
darius
parents:
diff changeset
594 static void DoTremolo(void)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
595 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
596 UBYTE q;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
597 UWORD temp;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
598
de95ce2eacfd Initial revision
darius
parents:
diff changeset
599 q = (a->trmpos>>2) & 0x1f;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
600
de95ce2eacfd Initial revision
darius
parents:
diff changeset
601 switch((a->wavecontrol>>4) & 3)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
602 { case 0: // sine
de95ce2eacfd Initial revision
darius
parents:
diff changeset
603 temp = VibratoTable[q];
de95ce2eacfd Initial revision
darius
parents:
diff changeset
604 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
605
de95ce2eacfd Initial revision
darius
parents:
diff changeset
606 case 1: // ramp down
de95ce2eacfd Initial revision
darius
parents:
diff changeset
607 q<<=3;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
608 if(a->trmpos<0) q = 255-q;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
609 temp = q;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
610 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
611
de95ce2eacfd Initial revision
darius
parents:
diff changeset
612 case 2: // square wave
de95ce2eacfd Initial revision
darius
parents:
diff changeset
613 temp = 255;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
614 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
615
de95ce2eacfd Initial revision
darius
parents:
diff changeset
616 case 3: // Evil random wave
de95ce2eacfd Initial revision
darius
parents:
diff changeset
617 temp = rand() & 255;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
618 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
619 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
620
de95ce2eacfd Initial revision
darius
parents:
diff changeset
621 temp *= a->trmdepth;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
622 temp >>= 6;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
623
de95ce2eacfd Initial revision
darius
parents:
diff changeset
624 if(a->trmpos >= 0)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
625 { a->volume = a->tmpvolume + temp;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
626 if(a->volume > 64) a->volume = 64;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
627 } else
de95ce2eacfd Initial revision
darius
parents:
diff changeset
628 { a->volume = a->tmpvolume - temp;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
629 if(a->volume < 0) a->volume = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
630 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
631
de95ce2eacfd Initial revision
darius
parents:
diff changeset
632 if(pf->vbtick) a->trmpos+=a->trmspd; // do not update when pf->vbtick==0
de95ce2eacfd Initial revision
darius
parents:
diff changeset
633 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
634
de95ce2eacfd Initial revision
darius
parents:
diff changeset
635
de95ce2eacfd Initial revision
darius
parents:
diff changeset
636 static void DoVolSlide(UBYTE dat)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
637 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
638 if(!pf->vbtick) return; // do not update when pf->vbtick==0
de95ce2eacfd Initial revision
darius
parents:
diff changeset
639
de95ce2eacfd Initial revision
darius
parents:
diff changeset
640 a->tmpvolume += dat >> 4; // volume slide
de95ce2eacfd Initial revision
darius
parents:
diff changeset
641 a->tmpvolume -= dat & 0xf;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
642 if(a->tmpvolume < 0) a->tmpvolume = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
643 if(a->tmpvolume > 64) a->tmpvolume = 64;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
644 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
645
de95ce2eacfd Initial revision
darius
parents:
diff changeset
646
de95ce2eacfd Initial revision
darius
parents:
diff changeset
647 static void DoToneSlide(void)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
648 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
649 int dist;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
650
de95ce2eacfd Initial revision
darius
parents:
diff changeset
651 if(a->period==0) return;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
652
de95ce2eacfd Initial revision
darius
parents:
diff changeset
653 if(!pf->vbtick)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
654 { a->tmpperiod = a->period;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
655 return;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
656 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
657
de95ce2eacfd Initial revision
darius
parents:
diff changeset
658 // We have to slide a->period towards a->wantedperiod, so
de95ce2eacfd Initial revision
darius
parents:
diff changeset
659 // compute the difference between those two values
de95ce2eacfd Initial revision
darius
parents:
diff changeset
660
de95ce2eacfd Initial revision
darius
parents:
diff changeset
661 dist = a->period-a->wantedperiod;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
662
de95ce2eacfd Initial revision
darius
parents:
diff changeset
663 if( dist==0 || a->portspeed>abs(dist) ) // if they are equal or if portamentospeed is too big
de95ce2eacfd Initial revision
darius
parents:
diff changeset
664 a->period = a->wantedperiod; // make tmpperiod equal tperiod
de95ce2eacfd Initial revision
darius
parents:
diff changeset
665 else if(dist>0) // dist>0 ?
de95ce2eacfd Initial revision
darius
parents:
diff changeset
666 a->period-=a->portspeed; // then slide up
de95ce2eacfd Initial revision
darius
parents:
diff changeset
667 else
de95ce2eacfd Initial revision
darius
parents:
diff changeset
668 a->period+=a->portspeed; // dist<0 -> slide down
de95ce2eacfd Initial revision
darius
parents:
diff changeset
669
de95ce2eacfd Initial revision
darius
parents:
diff changeset
670 a->tmpperiod = a->period;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
671 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
672
de95ce2eacfd Initial revision
darius
parents:
diff changeset
673
de95ce2eacfd Initial revision
darius
parents:
diff changeset
674 static void DoPTEffect0(UBYTE dat)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
675 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
676 UBYTE note;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
677
de95ce2eacfd Initial revision
darius
parents:
diff changeset
678 note = a->note;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
679
de95ce2eacfd Initial revision
darius
parents:
diff changeset
680 if(dat!=0)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
681 { switch(pf->vbtick%3)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
682 { case 1:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
683 note+=(dat>>4); break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
684 case 2:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
685 note+=(dat&0xf); break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
686 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
687 a->period = GetPeriod(note,a->speed);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
688 a->ownper = 1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
689 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
690 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
691
de95ce2eacfd Initial revision
darius
parents:
diff changeset
692
de95ce2eacfd Initial revision
darius
parents:
diff changeset
693 // -----------------------------------------
de95ce2eacfd Initial revision
darius
parents:
diff changeset
694 // --> ScreamTreacker 3 Specific Effects <--
de95ce2eacfd Initial revision
darius
parents:
diff changeset
695 // -----------------------------------------
de95ce2eacfd Initial revision
darius
parents:
diff changeset
696
de95ce2eacfd Initial revision
darius
parents:
diff changeset
697 static void DoS3MVolSlide(UBYTE inf)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
698 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
699 UBYTE lo, hi;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
700
de95ce2eacfd Initial revision
darius
parents:
diff changeset
701 if(inf) a->s3mvolslide = inf;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
702
de95ce2eacfd Initial revision
darius
parents:
diff changeset
703 inf = a->s3mvolslide;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
704 lo = inf & 0xf;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
705 hi = inf >> 4;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
706
de95ce2eacfd Initial revision
darius
parents:
diff changeset
707 if(hi==0) a->tmpvolume -= lo;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
708 else if(lo==0) a->tmpvolume += hi;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
709 else if(hi==0xf)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
710 { if(!pf->vbtick) a->tmpvolume -= lo;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
711 } else if(lo==0xf)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
712 { if(!pf->vbtick) a->tmpvolume += hi;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
713 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
714 if(a->tmpvolume < 0) a->tmpvolume = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
715 if(a->tmpvolume > 64) a->tmpvolume = 64;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
716 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
717
de95ce2eacfd Initial revision
darius
parents:
diff changeset
718
de95ce2eacfd Initial revision
darius
parents:
diff changeset
719 static void DoS3MSlideDn(UBYTE inf)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
720 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
721 UBYTE hi,lo;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
722
de95ce2eacfd Initial revision
darius
parents:
diff changeset
723 if(inf!=0) a->slidespeed = inf;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
724 else inf = a->slidespeed;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
725
de95ce2eacfd Initial revision
darius
parents:
diff changeset
726 hi = inf>>4;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
727 lo = inf&0xf;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
728
de95ce2eacfd Initial revision
darius
parents:
diff changeset
729 if(hi==0xf)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
730 { if(!pf->vbtick) a->tmpperiod+=(UWORD)lo<<2;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
731 } else if(hi==0xe)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
732 { if(!pf->vbtick) a->tmpperiod+=lo;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
733 } else
de95ce2eacfd Initial revision
darius
parents:
diff changeset
734 { if(pf->vbtick) a->tmpperiod+=(UWORD)inf<<2;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
735 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
736 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
737
de95ce2eacfd Initial revision
darius
parents:
diff changeset
738
de95ce2eacfd Initial revision
darius
parents:
diff changeset
739 static void DoS3MSlideUp(UBYTE inf)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
740 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
741 UBYTE hi,lo;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
742
de95ce2eacfd Initial revision
darius
parents:
diff changeset
743 if(inf!=0) a->slidespeed = inf;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
744 else inf = a->slidespeed;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
745
de95ce2eacfd Initial revision
darius
parents:
diff changeset
746 hi = inf>>4;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
747 lo = inf&0xf;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
748
de95ce2eacfd Initial revision
darius
parents:
diff changeset
749 if(hi==0xf)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
750 { if(!pf->vbtick) a->tmpperiod-=(UWORD)lo<<2;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
751 } else if(hi==0xe)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
752 { if(!pf->vbtick) a->tmpperiod-=lo;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
753 } else
de95ce2eacfd Initial revision
darius
parents:
diff changeset
754 { if(pf->vbtick) a->tmpperiod-=(UWORD)inf<<2;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
755 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
756 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
757
de95ce2eacfd Initial revision
darius
parents:
diff changeset
758
de95ce2eacfd Initial revision
darius
parents:
diff changeset
759 static void DoS3MTremor(UBYTE inf)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
760 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
761 UBYTE on,off;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
762
de95ce2eacfd Initial revision
darius
parents:
diff changeset
763 if(inf!=0) a->s3mtronof = inf;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
764 else inf = a->s3mtronof;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
765
de95ce2eacfd Initial revision
darius
parents:
diff changeset
766 if(!pf->vbtick) return;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
767
de95ce2eacfd Initial revision
darius
parents:
diff changeset
768 on = (inf>>4)+1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
769 off = (inf&0xf)+1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
770
de95ce2eacfd Initial revision
darius
parents:
diff changeset
771 a->s3mtremor %= (on+off);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
772 a->volume = (a->s3mtremor < on ) ? a->tmpvolume : 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
773 a->s3mtremor++;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
774 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
775
de95ce2eacfd Initial revision
darius
parents:
diff changeset
776
de95ce2eacfd Initial revision
darius
parents:
diff changeset
777 static void DoS3MRetrig(UBYTE inf)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
778 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
779 UBYTE hi,lo;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
780
de95ce2eacfd Initial revision
darius
parents:
diff changeset
781 hi = inf >> 4;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
782 lo = inf & 0xf;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
783
de95ce2eacfd Initial revision
darius
parents:
diff changeset
784 if(inf)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
785 { a->s3mrtgslide = hi;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
786 a->s3mrtgspeed = lo;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
787 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
788
de95ce2eacfd Initial revision
darius
parents:
diff changeset
789 // only retrigger if
de95ce2eacfd Initial revision
darius
parents:
diff changeset
790 // lo nibble > 0
de95ce2eacfd Initial revision
darius
parents:
diff changeset
791
de95ce2eacfd Initial revision
darius
parents:
diff changeset
792 if(a->s3mrtgspeed > 0)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
793 { if(a->retrig == 0)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
794 { // when retrig counter reaches 0,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
795 // reset counter and restart the sample
de95ce2eacfd Initial revision
darius
parents:
diff changeset
796
de95ce2eacfd Initial revision
darius
parents:
diff changeset
797 if(!a->kick) a->kick = 2;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
798 a->retrig = a->s3mrtgspeed;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
799
de95ce2eacfd Initial revision
darius
parents:
diff changeset
800 if(pf->vbtick) // don't slide on first retrig
de95ce2eacfd Initial revision
darius
parents:
diff changeset
801 { switch(a->s3mrtgslide)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
802 { case 1:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
803 case 2:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
804 case 3:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
805 case 4:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
806 case 5:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
807 a->tmpvolume-=(1<<(a->s3mrtgslide-1));
de95ce2eacfd Initial revision
darius
parents:
diff changeset
808 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
809
de95ce2eacfd Initial revision
darius
parents:
diff changeset
810 case 6:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
811 a->tmpvolume = (2*a->tmpvolume)/3;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
812 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
813
de95ce2eacfd Initial revision
darius
parents:
diff changeset
814 case 7:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
815 a->tmpvolume = a->tmpvolume>>1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
816 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
817
de95ce2eacfd Initial revision
darius
parents:
diff changeset
818 case 9:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
819 case 0xa:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
820 case 0xb:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
821 case 0xc:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
822 case 0xd:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
823 a->tmpvolume+=(1<<(a->s3mrtgslide-9));
de95ce2eacfd Initial revision
darius
parents:
diff changeset
824 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
825
de95ce2eacfd Initial revision
darius
parents:
diff changeset
826 case 0xe:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
827 a->tmpvolume=(3*a->tmpvolume)/2;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
828 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
829
de95ce2eacfd Initial revision
darius
parents:
diff changeset
830 case 0xf:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
831 a->tmpvolume=a->tmpvolume<<1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
832 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
833 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
834 if(a->tmpvolume<0) a->tmpvolume = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
835 if(a->tmpvolume>64) a->tmpvolume = 64;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
836 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
837 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
838 a->retrig--; // countdown
de95ce2eacfd Initial revision
darius
parents:
diff changeset
839 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
840 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
841
de95ce2eacfd Initial revision
darius
parents:
diff changeset
842
de95ce2eacfd Initial revision
darius
parents:
diff changeset
843 static void DoS3MSpeed(UBYTE speed)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
844 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
845 if(pf->vbtick || pf->patdly2) return;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
846
de95ce2eacfd Initial revision
darius
parents:
diff changeset
847 if(speed)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
848 { pf->sngspd = speed;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
849 pf->vbtick = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
850 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
851 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
852
de95ce2eacfd Initial revision
darius
parents:
diff changeset
853
de95ce2eacfd Initial revision
darius
parents:
diff changeset
854 static void DoS3MTempo(UBYTE tempo)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
855 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
856 if(pf->vbtick || pf->patdly2) return;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
857 pf->bpm = tempo;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
858 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
859
de95ce2eacfd Initial revision
darius
parents:
diff changeset
860
de95ce2eacfd Initial revision
darius
parents:
diff changeset
861 static void DoS3MFineVibrato(void)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
862 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
863 UBYTE q;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
864 UWORD temp;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
865
de95ce2eacfd Initial revision
darius
parents:
diff changeset
866 q = (a->vibpos>>2)&0x1f;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
867
de95ce2eacfd Initial revision
darius
parents:
diff changeset
868 switch(a->wavecontrol&3)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
869 { case 0: // sine
de95ce2eacfd Initial revision
darius
parents:
diff changeset
870 temp=VibratoTable[q];
de95ce2eacfd Initial revision
darius
parents:
diff changeset
871 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
872
de95ce2eacfd Initial revision
darius
parents:
diff changeset
873 case 1: // ramp down
de95ce2eacfd Initial revision
darius
parents:
diff changeset
874 q<<=3;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
875 if(a->vibpos<0) q=255-q;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
876 temp=q;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
877 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
878
de95ce2eacfd Initial revision
darius
parents:
diff changeset
879 case 2: // square wave
de95ce2eacfd Initial revision
darius
parents:
diff changeset
880 temp=255;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
881 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
882
de95ce2eacfd Initial revision
darius
parents:
diff changeset
883 case 3: // evil random
de95ce2eacfd Initial revision
darius
parents:
diff changeset
884 temp = rand() & 255; // (range 0 to 255)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
885 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
886
de95ce2eacfd Initial revision
darius
parents:
diff changeset
887 temp*=a->vibdepth;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
888 temp>>=8;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
889
de95ce2eacfd Initial revision
darius
parents:
diff changeset
890 if(a->vibpos>=0)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
891 a->period = a->tmpperiod+temp;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
892 else
de95ce2eacfd Initial revision
darius
parents:
diff changeset
893 a->period = a->tmpperiod-temp;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
894
de95ce2eacfd Initial revision
darius
parents:
diff changeset
895 a->vibpos += a->vibspd;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
896 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
897
de95ce2eacfd Initial revision
darius
parents:
diff changeset
898
de95ce2eacfd Initial revision
darius
parents:
diff changeset
899 static void DoS3MTremolo(void)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
900 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
901 UBYTE q;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
902 UWORD temp;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
903
de95ce2eacfd Initial revision
darius
parents:
diff changeset
904 q = (a->trmpos>>2)&0x1f;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
905
de95ce2eacfd Initial revision
darius
parents:
diff changeset
906 switch((a->wavecontrol>>4)&3)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
907 { case 0: // sine
de95ce2eacfd Initial revision
darius
parents:
diff changeset
908 temp = VibratoTable[q];
de95ce2eacfd Initial revision
darius
parents:
diff changeset
909 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
910
de95ce2eacfd Initial revision
darius
parents:
diff changeset
911 case 1: // ramp down
de95ce2eacfd Initial revision
darius
parents:
diff changeset
912 q<<=3;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
913 if(a->trmpos<0) q = 255-q;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
914 temp = q;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
915 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
916
de95ce2eacfd Initial revision
darius
parents:
diff changeset
917 case 2: // square wave
de95ce2eacfd Initial revision
darius
parents:
diff changeset
918 temp=255;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
919 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
920
de95ce2eacfd Initial revision
darius
parents:
diff changeset
921 case 3: // evil random
de95ce2eacfd Initial revision
darius
parents:
diff changeset
922 temp = rand() & 255; // (range 0 to 255)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
923 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
924
de95ce2eacfd Initial revision
darius
parents:
diff changeset
925 temp*=a->trmdepth;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
926 temp>>=7;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
927
de95ce2eacfd Initial revision
darius
parents:
diff changeset
928 if(a->trmpos>=0)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
929 { a->volume = a->tmpvolume + temp;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
930 if(a->volume>64) a->volume = 64;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
931 } else
de95ce2eacfd Initial revision
darius
parents:
diff changeset
932 { a->volume = a->tmpvolume - temp;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
933 if(a->volume<0) a->volume = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
934 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
935
de95ce2eacfd Initial revision
darius
parents:
diff changeset
936 if(pf->vbtick) a->trmpos += a->trmspd; // do not update when pf->vbtick==0
de95ce2eacfd Initial revision
darius
parents:
diff changeset
937 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
938
de95ce2eacfd Initial revision
darius
parents:
diff changeset
939
de95ce2eacfd Initial revision
darius
parents:
diff changeset
940 // --------------------------------------
de95ce2eacfd Initial revision
darius
parents:
diff changeset
941 // --> FastTracker 2 Specific Effects <--
de95ce2eacfd Initial revision
darius
parents:
diff changeset
942 // --------------------------------------
de95ce2eacfd Initial revision
darius
parents:
diff changeset
943
de95ce2eacfd Initial revision
darius
parents:
diff changeset
944 static void DoXMVolSlide(UBYTE inf)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
945 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
946 UBYTE lo,hi;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
947
de95ce2eacfd Initial revision
darius
parents:
diff changeset
948 if(inf)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
949 a->s3mvolslide = inf;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
950
de95ce2eacfd Initial revision
darius
parents:
diff changeset
951 inf = a->s3mvolslide;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
952 if(!pf->vbtick) return;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
953
de95ce2eacfd Initial revision
darius
parents:
diff changeset
954 lo = inf&0xf;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
955 hi = inf>>4;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
956
de95ce2eacfd Initial revision
darius
parents:
diff changeset
957 if(hi==0)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
958 a->tmpvolume-=lo;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
959 else
de95ce2eacfd Initial revision
darius
parents:
diff changeset
960 a->tmpvolume+=hi;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
961
de95ce2eacfd Initial revision
darius
parents:
diff changeset
962 if(a->tmpvolume<0) a->tmpvolume=0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
963 else if(a->tmpvolume>64) a->tmpvolume=64;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
964 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
965
de95ce2eacfd Initial revision
darius
parents:
diff changeset
966
de95ce2eacfd Initial revision
darius
parents:
diff changeset
967 static void DoXMGlobalSlide(UBYTE inf)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
968 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
969 if(pf->vbtick)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
970 { if(inf) pf->globalslide=inf; else inf=pf->globalslide;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
971 if(inf & 0xf0) inf &= 0xf0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
972 pf->volume = pf->volume + ((inf >> 4) - (inf & 0xf))*2;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
973
de95ce2eacfd Initial revision
darius
parents:
diff changeset
974 if(pf->volume<0) pf->volume = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
975 else if(pf->volume>128) pf->volume = 128;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
976 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
977 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
978
de95ce2eacfd Initial revision
darius
parents:
diff changeset
979
de95ce2eacfd Initial revision
darius
parents:
diff changeset
980 static void DoXMPanSlide(UBYTE inf)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
981 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
982 UBYTE lo,hi;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
983 SWORD pan;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
984
de95ce2eacfd Initial revision
darius
parents:
diff changeset
985
de95ce2eacfd Initial revision
darius
parents:
diff changeset
986 if(inf!=0) a->pansspd = inf;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
987 else inf = a->pansspd;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
988
de95ce2eacfd Initial revision
darius
parents:
diff changeset
989 if(!pf->vbtick) return;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
990
de95ce2eacfd Initial revision
darius
parents:
diff changeset
991 lo = inf & 0xf;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
992 hi = inf >> 4;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
993
de95ce2eacfd Initial revision
darius
parents:
diff changeset
994 // slide right has absolute priority:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
995
de95ce2eacfd Initial revision
darius
parents:
diff changeset
996 if(hi) lo = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
997
de95ce2eacfd Initial revision
darius
parents:
diff changeset
998 pan = (a->panning == PAN_SURROUND) ? 128 : a->panning;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
999
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1000 pan -= lo;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1001 pan += hi;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1002
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1003 if(pan < 0) pan = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1004 if(pan > 255) pan = 255;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1005
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1006 a->panning = pan;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1007 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1008
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1009
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1010 static void DoXMExtraFineSlideUp(UBYTE inf)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1011 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1012 if(!pf->vbtick)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1013 { if(inf) a->ffportupspd = inf; else inf = a->ffportupspd;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1014 a->period -= inf;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1015 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1016 a->tmpperiod = a->period;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1017 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1018
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1019
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1020 static void DoXMExtraFineSlideDown(UBYTE inf)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1021 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1022 if(!pf->vbtick)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1023 { if(inf) a->ffportdnspd = inf; else inf = a->ffportdnspd;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1024 a->period += inf;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1025 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1026 a->tmpperiod = a->period;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1027 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1028
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1029
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1030 // ---------------------------------------
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1031 // --> ImpulseTracker Player Functions <--
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1032 // ---------------------------------------
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1033
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1034 static void DoITChanVolSlide(UBYTE inf)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1035 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1036 UBYTE lo, hi;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1037
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1038 if(inf) a->chanvolslide = inf;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1039 inf = a->chanvolslide;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1040
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1041 lo = inf&0xf;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1042 hi = inf>>4;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1043
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1044 if(hi==0)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1045 { a->chanvol-=lo;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1046 } else if(lo==0)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1047 { a->chanvol+=hi;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1048 } else if(hi==0xf)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1049 { if(!pf->vbtick) a->chanvol-=lo;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1050 } else if(lo==0xf)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1051 { if(!pf->vbtick) a->chanvol+=hi;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1052 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1053
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1054 if(a->chanvol<0) a->chanvol = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1055 if(a->chanvol>64) a->chanvol = 64;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1056 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1057
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1058
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1059 static void DoITGlobalSlide(UBYTE inf)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1060 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1061 UBYTE lo,hi;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1062
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1063 if(inf) pf->globalslide = inf;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1064 inf = pf->globalslide;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1065
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1066 lo = inf&0xf;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1067 hi = inf>>4;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1068
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1069 if(lo==0)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1070 { pf->volume += hi;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1071 } else if(hi==0)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1072 { pf->volume -= lo;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1073 } else if(lo==0xf)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1074 { if(!pf->vbtick) pf->volume += hi;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1075 } else if(hi==0xf)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1076 { if(!pf->vbtick) pf->volume -= lo;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1077 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1078
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1079 if(pf->volume < 0) pf->volume = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1080 if(pf->volume > 128) pf->volume = 128;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1081 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1082
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1083
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1084 static void DoITPanSlide(UBYTE inf)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1085 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1086 UBYTE lo,hi;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1087 SWORD pan;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1088
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1089 if(inf) a->pansspd = inf;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1090 inf = a->pansspd;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1091
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1092 lo = inf & 0xf;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1093 hi = inf >> 4;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1094
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1095 pan = (a->panning == PAN_SURROUND) ? 128 : a->panning;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1096
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1097 if(hi==0)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1098 { pan += lo << 2;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1099 } else if(lo==0)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1100 { pan -= hi << 2;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1101 } else if(hi==0xf)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1102 { if(!pf->vbtick) pan += lo << 2;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1103 } else if(lo==0xf)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1104 { if(!pf->vbtick) pan -= hi << 2;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1105 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1106 if(pan > 255) pan = 255;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1107 if(pan < 0) pan = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1108 a->panning = /*pf->panning[mp_channel] =*/ pan;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1109 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1110
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1111
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1112 static void DoITVibrato(void)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1113 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1114 UBYTE q;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1115 UWORD temp;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1116
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1117 q = (a->vibpos>>2)&0x1f;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1118
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1119 switch(a->wavecontrol&3)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1120 { case 0: // sine
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1121 temp=VibratoTable[q];
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1122 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1123
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1124 case 1: // ramp down
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1125 q<<=3;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1126 if(a->vibpos<0) q=255-q;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1127 temp=q;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1128 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1129
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1130 case 2: // square wave
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1131 temp=255;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1132 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1133
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1134 case 3: // evil random
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1135 temp = rand() & 255; // (range 0 to 255)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1136 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1137 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1138
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1139 temp*=a->vibdepth;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1140 temp>>=8;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1141 temp<<=2;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1142
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1143 if(a->vibpos>=0)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1144 a->period = a->tmpperiod+temp;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1145 else
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1146 a->period = a->tmpperiod-temp;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1147
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1148 a->vibpos+=a->vibspd;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1149 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1150
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1151
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1152 static void DoITFineVibrato(void)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1153 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1154 UBYTE q;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1155 UWORD temp;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1156
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1157 q = (a->vibpos>>2)&0x1f;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1158
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1159 switch(a->wavecontrol&3)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1160 { case 0: // sine
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1161 temp=VibratoTable[q];
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1162 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1163
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1164 case 1: // ramp down
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1165 q<<=3;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1166 if(a->vibpos<0) q = 255-q;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1167 temp = q;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1168 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1169
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1170 case 2: // square wave
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1171 temp = 255;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1172 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1173
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1174 case 3: // evil random
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1175 temp = rand() & 255; // (range 0 to 255)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1176 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1177 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1178
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1179 temp*=a->vibdepth;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1180 temp>>=8;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1181
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1182 if(a->vibpos>=0)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1183 a->period = a->tmpperiod+temp;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1184 else
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1185 a->period = a->tmpperiod-temp;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1186
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1187 a->vibpos+=a->vibspd;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1188 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1189
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1190
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1191 static void DoITTremor(UBYTE inf)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1192 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1193 UBYTE on,off;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1194
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1195 if(inf!=0) a->s3mtronof = inf;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1196 else inf = a->s3mtronof;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1197
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1198 if(!pf->vbtick) return;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1199
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1200 on=(inf>>4);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1201 off=(inf&0xf);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1202
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1203 a->s3mtremor%=(on+off);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1204 a->volume = (a->s3mtremor < on ) ? a->tmpvolume : 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1205 a->s3mtremor++;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1206 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1207
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1208
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1209 static void DoITPanbrello(void)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1210 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1211 UBYTE q;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1212 static SLONG temp;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1213
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1214 q = a->panbpos;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1215
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1216 switch(a->panbwave)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1217 { case 0: // sine
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1218 temp = PanbrelloTable[q];
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1219 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1220
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1221 // only sinewave is correctly supported right now
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1222
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1223 case 1: // ramp down
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1224 q<<=3;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1225 temp = q;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1226 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1227
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1228 case 2: // square wave
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1229 temp = 64;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1230 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1231
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1232 case 3: // evil random
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1233 if(a->panbpos >= a->panbspd)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1234 { a->panbpos = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1235 temp = rand() & 255;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1236 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1237 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1238
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1239 temp*=a->panbdepth;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1240 temp/=8;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1241
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1242 a->panning = pf->panning[mp_channel] + temp;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1243 a->panbpos += a->panbspd;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1244 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1245
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1246
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1247 static void DoITToneSlide(void)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1248 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1249 int dist;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1250
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1251 if(a->period == 0) return;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1252
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1253 if(!pf->vbtick)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1254 { a->tmpperiod = a->period;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1255 return;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1256 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1257
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1258 // We have to slide a->period towards a->wantedperiod,
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1259 // compute the difference between those two values
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1260
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1261 dist = a->period - a->wantedperiod;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1262
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1263 if( (dist == 0) || // if they are equal
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1264 ((a->slidespeed<<2) > abs(dist)) ) // or if portamentospeed is too big
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1265 { a->period = a->wantedperiod; // make tmpperiod equal tperiod
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1266 } else if(dist > 0) // dist>0 ?
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1267 { a->period -= a->slidespeed << 2; // then slide up
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1268 } else
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1269 { a->period += a->slidespeed << 2; // dist<0 -> slide down
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1270 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1271 a->tmpperiod = a->period;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1272 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1273
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1274
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1275 static void DoSSEffects(UBYTE dat)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1276
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1277 // Impulse/Scream Tracker Sxx effects.
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1278 // All Sxx effects share the same memory space.
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1279
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1280 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1281 UBYTE inf,c;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1282
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1283 inf = dat&0xf;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1284 c = dat>>4;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1285
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1286 if(dat==0)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1287 { c = a->sseffect;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1288 inf = a->ssdata;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1289 } else
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1290 { a->sseffect = c;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1291 a->ssdata = inf;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1292 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1293
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1294 switch(c)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1295 { case SS_GLISSANDO: // S1x set glissando voice
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1296 DoEEffects(0x30|inf);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1297 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1298
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1299 case SS_FINETUNE: // S2x set finetune
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1300 DoEEffects(0x50|inf);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1301 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1302
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1303 case SS_VIBWAVE: // S3x set vibrato waveform
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1304 DoEEffects(0x40|inf);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1305 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1306
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1307 case SS_TREMWAVE: // S4x set tremolo waveform
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1308 DoEEffects(0x70|inf);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1309 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1310
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1311 case SS_PANWAVE: // The Satanic Panbrello waveform
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1312 a->panbwave = (UniGetByte());
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1313 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1314
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1315 case SS_FRAMEDELAY: // S6x Delay x number of frames (patdly)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1316 DoEEffects(0xe0|inf);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1317 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1318
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1319 case SS_S7EFFECTS: // S7x Instrument / NNA commands
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1320 DoNNAEffects(UniGetByte());
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1321 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1322
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1323 case SS_PANNING: // S8x set panning position
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1324 DoEEffects(0x80 | inf);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1325 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1326
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1327 case SS_SURROUND: // S9x Set Surround Sound
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1328 a->panning = pf->panning[mp_channel] = PAN_SURROUND;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1329 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1330
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1331 case SS_HIOFFSET: // SAy Set high order sample offset yxx00h
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1332 a->hioffset |= UniGetByte() << 16;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1333 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1334
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1335 case SS_PATLOOP: // SBx pattern loop
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1336 DoEEffects(0x60|inf);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1337 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1338
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1339 case SS_NOTECUT: // SCx notecut
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1340 DoEEffects(0xC0|inf);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1341 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1342
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1343 case SS_NOTEDELAY: // SDx notedelay
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1344 DoEEffects(0xD0|inf);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1345 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1346
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1347 case SS_PATDELAY: // SEx patterndelay
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1348 DoEEffects(0xE0|inf);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1349 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1350 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1351 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1352
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1353
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1354 static void DoVolEffects(UBYTE c)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1355
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1356 // Impulse Tracker Volume/Pan Column effects.
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1357 // All volume/pan column effects share the same memory space.
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1358
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1359 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1360 UBYTE inf;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1361
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1362 inf = UniGetByte();
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1363
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1364 if(c==0 && inf==0)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1365 { c = a->voleffect;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1366 inf = a->voldata;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1367 } else
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1368 { a->voleffect = c;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1369 a->voldata = inf;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1370 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1371
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1372 switch(c)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1373 { case 0: break; // do nothing
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1374 case VOL_VOLUME:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1375 if(pf->vbtick) break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1376 if(inf>64) inf = 64;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1377 a->tmpvolume = inf;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1378 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1379
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1380 case VOL_PANNING:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1381 if(pf->panflag)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1382 { a->panning = inf;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1383 pf->panning[mp_channel] = inf;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1384 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1385 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1386
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1387 case VOL_VOLSLIDE:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1388 DoS3MVolSlide(inf);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1389 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1390
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1391 case VOL_PITCHSLIDEDN:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1392 DoS3MSlideDn(UniGetByte());
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1393 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1394
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1395 case VOL_PITCHSLIDEUP:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1396 DoS3MSlideUp(UniGetByte());
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1397 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1398
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1399 case VOL_PORTAMENTO:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1400 if(inf != 0) a->slidespeed = inf;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1401
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1402 if(a->period != 0)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1403 { if(!(pf->vbtick==pf->sngspd-1) && (a->newsamp))
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1404 { a->kick = 1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1405 a->start = -1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1406 //a->period *= a->speed * a->newsamp;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1407 } else
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1408 a->kick = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1409
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1410 DoITToneSlide();
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1411 a->ownper = 1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1412 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1413 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1414
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1415 case VOL_VIBRATO:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1416 if(inf & 0x0f) a->vibdepth = inf & 0xf;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1417 if(inf & 0xf0) a->vibspd = (inf & 0xf0) >> 2;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1418 DoITVibrato();
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1419 a->ownper = 1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1420 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1421 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1422 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1423
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1424
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1425
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1426 // --------------------------------
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1427 // --> General Player Functions <--
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1428 // --------------------------------
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1429
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1430 static void pt_playeffects(void)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1431 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1432 UBYTE dat,c;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1433
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1434 while(c = UniGetByte())
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1435 switch(c)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1436 { case UNI_NOTE:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1437 case UNI_INSTRUMENT:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1438 UniSkipOpcode(c);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1439 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1440
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1441 case UNI_PTEFFECT0:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1442 DoPTEffect0(UniGetByte());
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1443 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1444
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1445 case UNI_PTEFFECT1:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1446 dat = UniGetByte();
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1447 if(dat != 0) a->slidespeed = (UWORD)dat << 2;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1448 if(pf->vbtick) a->tmpperiod -= a->slidespeed;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1449 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1450
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1451 case UNI_PTEFFECT2:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1452 dat = UniGetByte();
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1453 if(dat != 0) a->slidespeed = (UWORD)dat << 2;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1454 if(pf->vbtick) a->tmpperiod += a->slidespeed;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1455 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1456
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1457 case UNI_PTEFFECT3:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1458 dat = UniGetByte();
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1459
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1460 if(dat!=0)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1461 { a->portspeed = dat;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1462 a->portspeed <<= 2;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1463 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1464
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1465 if(a->period != 0)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1466 { a->kick = 0; // temp XM fix
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1467 DoToneSlide();
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1468 a->ownper = 1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1469 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1470 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1471
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1472 case UNI_PTEFFECT4:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1473 dat = UniGetByte();
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1474 if(dat & 0x0f) a->vibdepth = dat & 0xf;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1475 if(dat & 0xf0) a->vibspd = (dat & 0xf0) >> 2;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1476 DoVibrato();
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1477 a->ownper = 1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1478 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1479
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1480 case UNI_PTEFFECT5:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1481 dat = UniGetByte();
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1482 a->kick = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1483 DoToneSlide();
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1484 DoVolSlide(dat);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1485 a->ownper = 1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1486 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1487
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1488 case UNI_PTEFFECT6:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1489 dat = UniGetByte();
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1490 DoVibrato();
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1491 DoVolSlide(dat);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1492 a->ownper = 1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1493 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1494
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1495 case UNI_PTEFFECT7:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1496 dat = UniGetByte();
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1497 if(dat & 0x0f) a->trmdepth = dat & 0xf;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1498 if(dat & 0xf0) a->trmspd = (dat & 0xf0) >> 2;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1499 DoTremolo();
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1500 a->ownvol = 1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1501 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1502
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1503 case UNI_PTEFFECT8:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1504 dat = UniGetByte();
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1505 if(pf->panflag)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1506 { a->panning = dat;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1507 pf->panning[mp_channel] = dat;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1508 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1509 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1510
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1511 case UNI_PTEFFECT9:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1512 dat = UniGetByte();
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1513 if(dat) a->soffset = (UWORD)dat << 8;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1514 a->start = a->hioffset | a->soffset;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1515 if((a->s != NULL) && (a->start > a->s->length)) a->start = a->s->loopstart;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1516 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1517
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1518 case UNI_PTEFFECTA:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1519 DoVolSlide(UniGetByte());
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1520 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1521
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1522 case UNI_PTEFFECTB:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1523 dat = UniGetByte();
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1524 if(pf->patdly2) break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1525 pf->patbrk = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1526 pf->sngpos = dat-1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1527 pf->posjmp = 3;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1528 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1529
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1530 case UNI_PTEFFECTC:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1531 dat = UniGetByte();
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1532 if(pf->vbtick) break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1533 if(dat>64) dat = 64;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1534 a->tmpvolume = dat;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1535 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1536
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1537 case UNI_PTEFFECTD:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1538 dat = UniGetByte();
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1539 if(pf->patdly2) break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1540 pf->patbrk = dat;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1541 if(pf->patbrk>pf->pattrows[mp_channel])
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1542 pf->patbrk = pf->pattrows[mp_channel];
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1543 pf->posjmp = 3;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1544 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1545
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1546 case UNI_PTEFFECTE:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1547 DoEEffects(UniGetByte());
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1548 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1549
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1550 case UNI_PTEFFECTF:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1551 dat = UniGetByte();
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1552
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1553 if(pf->vbtick || pf->patdly2) break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1554
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1555 if(pf->extspd && (dat >= 0x20))
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1556 pf->bpm = dat;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1557 else
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1558 { if(dat)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1559 { pf->sngspd = dat;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1560 pf->vbtick = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1561 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1562 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1563 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1564
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1565 case UNI_S3MEFFECTA:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1566 DoS3MSpeed(UniGetByte());
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1567 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1568
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1569 case UNI_S3MEFFECTD:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1570 DoS3MVolSlide(UniGetByte());
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1571 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1572
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1573 case UNI_S3MEFFECTE:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1574 DoS3MSlideDn(UniGetByte());
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1575 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1576
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1577 case UNI_S3MEFFECTF:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1578 DoS3MSlideUp(UniGetByte());
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1579 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1580
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1581 case UNI_S3MEFFECTI:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1582 DoS3MTremor(UniGetByte());
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1583 a->ownvol = 1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1584 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1585
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1586 case UNI_S3MEFFECTQ:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1587 DoS3MRetrig(UniGetByte());
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1588 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1589
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1590 case UNI_S3MEFFECTR:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1591 dat = UniGetByte();
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1592 if(dat & 0x0f) a->trmdepth = dat & 0xf;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1593 if(dat & 0xf0) a->trmspd = (dat & 0xf0) >> 2;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1594 DoS3MTremolo();
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1595 a->ownvol = 1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1596 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1597
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1598 case UNI_S3MEFFECTT:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1599 DoS3MTempo(UniGetByte());
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1600 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1601
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1602 case UNI_S3MEFFECTU:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1603 dat = UniGetByte();
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1604 if(dat & 0x0f) a->vibdepth = dat & 0xf;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1605 if(dat & 0xf0) a->vibspd = (dat & 0xf0) >> 2;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1606 DoS3MFineVibrato();
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1607 a->ownper = 1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1608 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1609
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1610 case UNI_KEYOFF:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1611 a->keyoff |= KEY_OFF;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1612 if(a->i != NULL)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1613 { if(!(a->i->volflg & EF_ON) || (a->i->volflg & EF_LOOP))
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1614 a->keyoff = KEY_KILL;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1615 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1616 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1617
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1618 case UNI_KEYFADE:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1619 if(pf->vbtick >= UniGetByte())
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1620 { a->keyoff = KEY_KILL;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1621 if((a->i != NULL) && !(a->i->volflg & EF_ON))
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1622 a->fadevol = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1623 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1624 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1625
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1626 case UNI_VOLEFFECTS:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1627 DoVolEffects(UniGetByte());
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1628 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1629
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1630 case UNI_XMEFFECT4:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1631 dat = UniGetByte();
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1632 if(pf->vbtick)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1633 { if(dat & 0x0f) a->vibdepth = dat & 0xf;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1634 if(dat & 0xf0) a->vibspd = (dat & 0xf0) >> 2;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1635 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1636 DoVibrato();
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1637 a->ownper = 1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1638 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1639
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1640 case UNI_XMEFFECTA:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1641 DoXMVolSlide(UniGetByte());
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1642 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1643
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1644 case UNI_XMEFFECTE1: // xm fineslide up
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1645 dat = UniGetByte();
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1646 if(!pf->vbtick)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1647 { if(dat) a->fportupspd = dat; else dat = a->fportupspd;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1648 a->tmpperiod -= (dat << 2);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1649 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1650 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1651
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1652 case UNI_XMEFFECTE2: // xm fineslide dn
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1653 dat = UniGetByte();
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1654 if(!pf->vbtick)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1655 { if(dat) a->fportdnspd = dat; else dat = a->fportdnspd;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1656 a->tmpperiod += (dat<<2);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1657 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1658 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1659
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1660 case UNI_XMEFFECTEA: // fine volume slide up
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1661 dat = UniGetByte();
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1662 if(pf->vbtick) break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1663 if(dat) a->fslideupspd = dat; else dat = a->fslideupspd;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1664 a->tmpvolume+=dat;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1665 if(a->tmpvolume>64) a->tmpvolume = 64;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1666 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1667
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1668 case UNI_XMEFFECTEB: // fine volume slide dn
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1669 dat = UniGetByte();
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1670 if(pf->vbtick) break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1671 if(dat) a->fslidednspd = dat; else dat = a->fslidednspd;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1672 a->tmpvolume-=dat;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1673 if(a->tmpvolume<0) a->tmpvolume = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1674 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1675
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1676 case UNI_XMEFFECTG:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1677 pf->volume = UniGetByte();
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1678 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1679
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1680 case UNI_XMEFFECTH:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1681 DoXMGlobalSlide(UniGetByte());
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1682 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1683
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1684 case UNI_XMEFFECTL:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1685 dat = UniGetByte();
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1686 if(!pf->vbtick && a->i!=NULL)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1687 { UWORD points;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1688 INSTRUMENT *i = a->i;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1689 MP_VOICE *aout;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1690
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1691 if((aout = a->slave) != NULL)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1692 { points = i->volenv[i->volpts-1].pos;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1693 aout->venv.p = aout->venv.env[(dat>points) ? points : dat].pos;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1694
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1695 points = i->panenv[i->panpts-1].pos;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1696 aout->penv.p = aout->penv.env[(dat>points) ? points : dat].pos;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1697 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1698 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1699 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1700
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1701 case UNI_XMEFFECTP:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1702 DoXMPanSlide(UniGetByte());
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1703 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1704
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1705 case UNI_XMEFFECTX1:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1706 DoXMExtraFineSlideUp(UniGetByte());
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1707 a->ownper = 1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1708 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1709
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1710 case UNI_XMEFFECTX2:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1711 DoXMExtraFineSlideDown(UniGetByte());
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1712 a->ownper = 1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1713 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1714
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1715 case UNI_ITEFFECTG:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1716 dat = UniGetByte();
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1717 if(dat != 0) a->slidespeed = dat;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1718
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1719 if(a->period != 0)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1720 { if((pf->vbtick < 1) && (a->newsamp))
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1721 { a->kick = 1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1722 a->start = -1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1723 //a->period *= a->speed * a->newsamp;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1724 } else
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1725 a->kick = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1726
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1727 DoITToneSlide();
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1728 a->ownper = 1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1729 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1730 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1731
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1732 case UNI_ITEFFECTH: // it vibrato
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1733 dat = UniGetByte();
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1734 if(dat & 0x0f) a->vibdepth = dat & 0xf;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1735 if(dat & 0xf0) a->vibspd = (dat & 0xf0) >> 2;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1736 DoITVibrato();
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1737 a->ownper = 1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1738 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1739
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1740 case UNI_ITEFFECTI: // it tremor
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1741 DoITTremor(UniGetByte());
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1742 a->ownvol = 1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1743 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1744
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1745 case UNI_ITEFFECTM:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1746 a->chanvol = UniGetByte();
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1747 if(a->chanvol > 64) a->chanvol = 64;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1748 else if(a->chanvol < 0) a->chanvol = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1749 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1750
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1751 case UNI_ITEFFECTN: // Slide / Fineslide Channel Volume
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1752 DoITChanVolSlide(UniGetByte());
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1753 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1754
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1755 case UNI_ITEFFECTP: // slide / fineslide channel panning
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1756 DoITPanSlide(UniGetByte());
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1757 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1758
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1759 case UNI_ITEFFECTU: // fine vibrato
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1760 dat = UniGetByte();
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1761 if(dat & 0x0f) a->vibdepth = dat & 0xf;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1762 if(dat & 0xf0) a->vibspd = (dat & 0xf0) >> 2;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1763 DoITFineVibrato();
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1764 a->ownper = 1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1765 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1766
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1767 case UNI_ITEFFECTW: // Slide / Fineslide Global volume
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1768 DoITGlobalSlide(UniGetByte());
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1769 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1770
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1771 case UNI_ITEFFECTY: // The Satanic Panbrello
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1772 dat = UniGetByte();
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1773 if(dat & 0x0f) a->panbdepth = (dat & 0xf);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1774 if(dat & 0xf0) a->panbspd = (dat & 0xf0) >> 4;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1775 DoITPanbrello();
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1776 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1777
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1778 case UNI_ITEFFECTS0:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1779 DoSSEffects(UniGetByte());
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1780 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1781
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1782 default:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1783 UniSkipOpcode(c);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1784 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1785 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1786 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1787
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1788
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1789 static void DoNNAEffects(UBYTE dat)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1790 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1791 int t;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1792 MP_VOICE *aout;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1793
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1794 dat &= 0xf;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1795 aout = (a->slave==NULL) ? &aout_dummy : a->slave;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1796
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1797 switch(dat)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1798 { case 0x0: // Past note cut
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1799 for(t=0; t<md_sngchn; t++)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1800 if(pf->voice[t].master == a)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1801 pf->voice[t].fadevol = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1802 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1803
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1804 case 0x1: // Past note off
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1805 for(t=0; t<md_sngchn; t++)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1806 if(pf->voice[t].master == a)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1807 { pf->voice[t].keyoff |= KEY_OFF;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1808 if(!(pf->voice[t].venv.flg & EF_ON))
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1809 pf->voice[t].keyoff = KEY_KILL;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1810 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1811 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1812
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1813 case 0x2: // Past note fade
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1814 for(t=0; t<md_sngchn; t++)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1815 if(pf->voice[t].master == a)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1816 pf->voice[t].keyoff |= KEY_FADE;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1817 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1818
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1819 case 0x3: // set NNA note cut
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1820 a->nna = (a->nna & ~0x3f) | NNA_CUT;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1821 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1822
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1823 case 0x4: // set NNA note continue
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1824 a->nna = (a->nna & ~0x3f) | NNA_CONTINUE;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1825 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1826
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1827 case 0x5: // set NNA note off
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1828 a->nna = (a->nna & ~0x3f) | NNA_OFF;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1829 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1830
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1831 case 0x6: // set NNA note fade
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1832 a->nna = (a->nna & ~0x3f) | NNA_FADE;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1833 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1834
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1835 case 0x7: // disable volume envelope
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1836 aout->volflg &= ~EF_ON;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1837 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1838
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1839 case 0x8: // enable volume envelope
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1840 aout->volflg |= EF_ON;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1841 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1842
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1843 case 0x9: // disable panning envelope
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1844 aout->panflg &= ~EF_ON;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1845 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1846
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1847 case 0xa: // enable panning envelope
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1848 aout->panflg |= EF_ON;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1849 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1850
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1851 case 0xb: // disable pitch envelope
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1852 aout->pitflg &= ~EF_ON;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1853 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1854
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1855 case 0xc: // enable pitch envelope
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1856 aout->pitflg |= EF_ON;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1857 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1858 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1859 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1860
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1861
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1862 void Player_HandleTick(void)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1863 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1864 MP_VOICE *aout; // current audout (slave of audtmp) it's working on
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1865 int t, tr, t2, k;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1866 ULONG tmpvol, period;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1867 UBYTE c;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1868 BOOL funky;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1869 SAMPLE *s;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1870 INSTRUMENT *i;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1871
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1872 if(isfirst)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1873 { // don't handle the very first ticks, this allows the
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1874 // other hardware to settle down so we don't loose any
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1875 // starting notes
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1876 isfirst--;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1877 return;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1878 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1879
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1880 if(pf==NULL || pf->forbid) return;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1881
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1882 if(++pf->vbtick >= pf->sngspd)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1883 { pf->patpos++;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1884 pf->vbtick = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1885
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1886 // process pattern-delay. pf->patdly2 is the counter and pf->patdly
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1887 // is the command memory.
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1888
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1889 if(pf->patdly)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1890 { pf->patdly2 = pf->patdly;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1891 pf->patdly = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1892 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1893
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1894 if(pf->patdly2)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1895 { // patterndelay active
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1896 if(--pf->patdly2) pf->patpos--; // so turn back pf->patpos by 1
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1897 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1898
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1899 // Do we have to get a new patternpointer ?
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1900 // (when pf->patpos reaches 64 or when
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1901 // a patternbreak is active)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1902
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1903 if(pf->patpos == pf->numrow) pf->posjmp = 3;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1904
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1905 if(pf->posjmp)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1906 { pf->patpos = pf->patbrk;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1907 pf->sngpos+=(pf->posjmp-2);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1908 pf->patbrk = pf->posjmp = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1909 if(pf->sngpos>=pf->numpos)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1910 { if(!pf->loop) return;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1911 if((pf->sngpos = pf->reppos) == 0)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1912 { pf->volume = pf->initvolume;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1913 pf->sngspd = pf->initspeed;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1914 pf->bpm = pf->inittempo;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1915 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1916 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1917 if(pf->sngpos<0) pf->sngpos = pf->numpos-1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1918 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1919
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1920 if(!pf->patdly2)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1921 { for(t=0; t<pf->numchn; t++)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1922 { UBYTE inst;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1923
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1924 tr = pf->patterns[(pf->positions[pf->sngpos]*pf->numchn)+t];
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1925 pf->numrow = pf->pattrows[pf->positions[pf->sngpos]];
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1926
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1927 mp_channel = t;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1928 a = &pf->control[t];
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1929 a->row = (tr < pf->numtrk) ? UniFindRow(pf->tracks[tr],pf->patpos) : NULL;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1930 a->newsamp = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1931
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1932 if(a->row==NULL) continue;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1933 UniSetRow(a->row);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1934 funky = 0; // Funky is set to indicate note or inst change
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1935
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1936 while(c = UniGetByte())
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1937 { switch(c)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1938 { case UNI_NOTE:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1939 funky |= 1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1940 a->anote = UniGetByte();
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1941 a->kick = 1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1942 a->start = -1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1943
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1944 // retrig tremolo and vibrato waves ?
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1945
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1946 if(!(a->wavecontrol & 0x80)) a->trmpos = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1947 if(!(a->wavecontrol & 0x08)) a->vibpos = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1948 if(!a->panbwave) a->panbpos = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1949 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1950
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1951 case UNI_INSTRUMENT:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1952 funky |= 2;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1953 inst = UniGetByte();
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1954 if(inst >= pf->numins) break; // <- safety valve
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1955
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1956 a->i = (pf->flags & UF_INST) ? &pf->instruments[inst] : NULL;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1957 a->retrig = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1958 a->s3mtremor = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1959 a->sample = inst;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1960 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1961
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1962 default:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1963 UniSkipOpcode(c);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1964 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1965 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1966 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1967
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1968 if(funky)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1969 { i = a->i;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1970 if(i != NULL)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1971 { if(i->samplenumber[a->anote] >= pf->numsmp) continue;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1972 s = &pf->samples[i->samplenumber[a->anote]];
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1973 a->note = i->samplenote[a->anote];
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1974 } else
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1975 { a->note = a->anote;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1976 s = &pf->samples[a->sample];
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1977 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1978
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1979 if(a->s != s)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1980 { a->s = s;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1981 a->newsamp = a->period;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1982 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1983
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1984 // channel or instrument determined panning ?
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1985
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1986 a->panning = pf->panning[t];
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1987 if(s->flags & SF_OWNPAN)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1988 a->panning = s->panning;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1989 else if((i != NULL) && (i->flags & IF_OWNPAN))
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1990 a->panning = i->panning;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1991
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1992 a->handle = s->handle;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1993 a->speed = s->speed;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1994
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1995 if(i != NULL)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1996 { if(i->flags & IF_PITCHPAN)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1997 a->panning += ((a->anote-i->pitpancenter) * i->pitpansep) / 8;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1998 a->pitflg = i->pitflg;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
1999 a->volflg = i->volflg;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2000 a->panflg = i->panflg;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2001 a->nna = i->nnatype;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2002 a->dca = i->dca;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2003 a->dct = i->dct;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2004 } else
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2005 { a->pitflg = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2006 a->volflg = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2007 a->panflg = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2008 a->nna = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2009 a->dca = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2010 a->dct = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2011 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2012
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2013 if(funky & 2)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2014 { // IT's random volume variations: 0:8 bit fixed, and one bit for sign.
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2015 a->volume = s->volume;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2016 a->tmpvolume = s->volume;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2017 if((s != NULL) && (i != NULL))
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2018 { a->volume = a->tmpvolume = s->volume + ((s->volume * ((SLONG)i->rvolvar * (SLONG)((rand() & 511)-255))) / 25600);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2019 if(a->panning != PAN_SURROUND) a->panning += ((a->panning * ((SLONG)i->rpanvar * (SLONG)((rand() & 511)-255))) / 25600);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2020 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2021 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2022
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2023 period = GetPeriod(a->note, a->speed);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2024 a->wantedperiod = period;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2025 a->tmpperiod = period;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2026 a->keyoff = KEY_KICK;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2027 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2028 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2029 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2030 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2031
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2032 // Update effects
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2033
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2034 for(t=0; t<pf->numchn; t++)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2035 { mp_channel = t;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2036 a = &pf->control[t];
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2037
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2038 if((aout = a->slave) != NULL)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2039 { a->fadevol = aout->fadevol;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2040 a->period = aout->period;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2041 if(a->kick != 1) a->keyoff = aout->keyoff;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2042 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2043
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2044 if(a->row == NULL) continue;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2045 UniSetRow(a->row);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2046
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2047 a->ownper = a->ownvol = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2048 pt_playeffects();
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2049 if(!a->ownper) a->period = a->tmpperiod;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2050 if(!a->ownvol) a->volume = a->tmpvolume;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2051
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2052 if(a->s != NULL)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2053 { if(a->i != NULL)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2054 a->outvolume = (a->volume * a->s->globvol * a->i->globvol) / 1024; // max val: 256
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2055 else
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2056 a->outvolume = (a->volume * a->s->globvol) / 16; // max val: 256
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2057 if(a->outvolume > 256) a->volume = 256;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2058 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2059 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2060
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2061
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2062 a = pf->control;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2063 if(pf->flags & UF_NNA)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2064 { for(t=0; t<pf->numchn; t++, a++)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2065 { if(a->kick == 1)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2066 { if(a->slave != NULL)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2067 { aout = a->slave;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2068 if(aout->nna & 0x3f)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2069 { // oh boy, we have to do an NNA
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2070 // Make sure the old MP_VOICE channel knows it has no master now!
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2071
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2072 a->slave = NULL; // assume the channel is taken by NNA
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2073 aout->mflag = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2074
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2075 switch(aout->nna)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2076 { case NNA_CONTINUE:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2077 break; // continue note, do nothing
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2078
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2079 case NNA_OFF: // note off
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2080 aout->keyoff |= KEY_OFF;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2081 if(!(aout->volflg & EF_ON) || (aout->volflg & EF_LOOP))
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2082 aout->keyoff = KEY_KILL;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2083 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2084
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2085 case NNA_FADE:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2086 aout->keyoff |= KEY_FADE;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2087 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2088 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2089 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2090 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2091
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2092 k = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2093 if(a->dct != DCT_OFF)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2094 { for(t2=0; t2<md_sngchn; t2++)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2095 { if(!(Voice_Stopped(t2)) && (pf->voice[t2].masterchn == t) && (a->sample == pf->voice[t2].sample))
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2096 { switch(a->dct)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2097 { case DCT_NOTE:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2098 if(a->note == pf->voice[t2].note)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2099 k = 1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2100 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2101
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2102 case DCT_SAMPLE:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2103 if(a->handle == pf->voice[t2].handle)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2104 k = 1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2105 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2106
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2107 case DCT_INST:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2108 k = 1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2109 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2110 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2111
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2112 if(k==1)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2113 { k = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2114 switch(a->dca)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2115 { case DCA_CUT :
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2116 pf->voice[t2].fadevol = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2117 a->slave = &pf->voice[a->slavechn=t2];
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2118 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2119
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2120 case DCA_OFF :
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2121 //a->slave = &pf->voice[newchn];
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2122 pf->voice[t2].keyoff |= KEY_OFF;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2123 if(!(pf->voice[t2].volflg & EF_ON) || (pf->voice[t2].volflg & EF_LOOP))
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2124 pf->voice[t2].keyoff = KEY_KILL;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2125 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2126
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2127 case DCA_FADE:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2128 //a->slave = &pf->voice[newchn];
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2129 pf->voice[t2].keyoff |= KEY_FADE;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2130 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2131 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2132 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2133 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2134 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2135 } // DCT checking
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2136 } // if a->kick
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2137 } // for loop
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2138 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2139
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2140 a = pf->control;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2141 for(t=0; t<pf->numchn; t++, a++)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2142 { int newchn;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2143
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2144 if(a->notedelay) continue;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2145
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2146 if(a->kick == 1)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2147 { // If no channel was cut above, find an empty or quiet channel here
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2148 if(pf->flags & UF_NNA)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2149 { if(a->slave==NULL)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2150 { if((newchn = MP_FindEmptyChannel(t)) != -1)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2151 a->slave = &pf->voice[a->slavechn=newchn];
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2152 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2153 } else
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2154 a->slave = &pf->voice[a->slavechn=t];
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2155
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2156 // Assign parts of MP_VOICE only done for a KICK!
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2157
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2158 if((aout = a->slave) != NULL)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2159 { if(aout->mflag && (aout->master!=NULL)) aout->master->slave = NULL;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2160 a->slave = aout;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2161 aout->master = a;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2162 aout->masterchn = t;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2163 aout->mflag = 1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2164 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2165 } else
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2166 { aout = a->slave;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2167 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2168
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2169 if(aout != NULL)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2170 { aout->kick = a->kick;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2171 aout->i = a->i;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2172 aout->s = a->s;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2173 aout->sample = a->sample;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2174 aout->handle = a->handle;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2175 aout->period = a->period;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2176 aout->panning = a->panning;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2177 aout->chanvol = a->chanvol;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2178 aout->fadevol = a->fadevol;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2179 aout->start = a->start;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2180 aout->volflg = a->volflg;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2181 aout->panflg = a->panflg;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2182 aout->pitflg = a->pitflg;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2183 aout->volume = a->outvolume;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2184 aout->keyoff = a->keyoff;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2185 aout->note = a->note;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2186 aout->nna = a->nna;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2187 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2188 a->kick = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2189
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2190 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2191
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2192 // Now set up the actual hardware channel playback information
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2193
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2194 for(t=0; t<md_sngchn; t++)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2195 { SWORD envpan, envvol = 256, envpit = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2196 SLONG vibval, vibdpt;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2197
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2198 aout = &pf->voice[mp_channel = t];
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2199 i = aout->i;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2200 s = aout->s;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2201
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2202 if(s==NULL) continue;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2203
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2204 if(aout->period < 40) aout->period = 40;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2205 if(aout->period > 50000) aout->period = 50000;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2206
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2207 if(aout->kick)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2208 { Voice_Play(t,s,(aout->start == -1) ? ((s->flags & SF_UST_LOOP) ? s->loopstart : 0) : aout->start);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2209 //aout->keyoff = KEY_KICK;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2210 aout->fadevol = 32768;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2211 aout->aswppos = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2212
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2213 if((i != NULL) && (aout->kick != 2))
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2214 { StartEnvelope(&aout->venv, aout->volflg, i->volpts, i->volsusbeg, i->volsusend, i->volbeg, i->volend, i->volenv, aout->keyoff);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2215 StartEnvelope(&aout->penv, aout->panflg, i->panpts, i->pansusbeg, i->pansusend, i->panbeg, i->panend, i->panenv, aout->keyoff);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2216 StartEnvelope(&aout->cenv, aout->pitflg, i->pitpts, i->pitsusbeg, i->pitsusend, i->pitbeg, i->pitend, i->pitenv, aout->keyoff);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2217 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2218 aout->kick = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2219 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2220
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2221 if(i != NULL)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2222 { envvol = ProcessEnvelope(&aout->venv,256,aout->keyoff);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2223 envpan = ProcessEnvelope(&aout->penv,128,aout->keyoff);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2224 envpit = ProcessEnvelope(&aout->cenv,32,aout->keyoff);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2225 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2226
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2227 tmpvol = aout->fadevol; // max 32768
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2228 tmpvol *= aout->chanvol; // * max 64
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2229 tmpvol *= aout->volume; // * max 256
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2230 tmpvol /= 16384L; // tmpvol is max 32768
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2231 aout->totalvol = tmpvol>>2; // totalvolume used to determine samplevolume
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2232 tmpvol *= envvol; // * max 256
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2233 tmpvol *= pf->volume; // * max 128
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2234 tmpvol /= 4194304UL;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2235
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2236 if((aout->masterchn != -1) && pf->control[aout->masterchn].muted) // Channel Muting Line
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2237 Voice_SetVolume(t,0);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2238 else
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2239 Voice_SetVolume(t,tmpvol);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2240
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2241
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2242 if(aout->panning == PAN_SURROUND)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2243 Voice_SetPanning(t, PAN_SURROUND);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2244 else
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2245 { if(aout->penv.flg & EF_ON)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2246 Voice_SetPanning(t,DoPan(envpan,aout->panning));
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2247 else
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2248 Voice_SetPanning(t,aout->panning);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2249 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2250
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2251 if(aout->period && s->vibdepth)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2252 { switch(s->vibtype)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2253 { case 0:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2254 vibval = avibtab[s->avibpos & 127];
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2255 if(s->avibpos & 0x80) vibval=-vibval;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2256 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2257
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2258 case 1:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2259 vibval = 64;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2260 if(s->avibpos & 0x80) vibval=-vibval;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2261 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2262
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2263 case 2:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2264 vibval = 63-(((s->avibpos + 128) & 255) >> 1);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2265 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2266
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2267 case 3:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2268 vibval = (((s->avibpos + 128) & 255) >> 1) - 64;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2269 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2270 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2271 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2272
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2273 if(s->vibflags & AV_IT)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2274 { if((aout->aswppos >> 8) < s->vibdepth)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2275 { aout->aswppos += s->vibsweep;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2276 vibdpt = aout->aswppos;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2277 } else
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2278 vibdpt = s->vibdepth << 8;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2279 vibval = (vibval*vibdpt) >> 16;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2280 if(aout->mflag)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2281 { if(!(pf->flags & UF_LINEAR)) vibval>>=1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2282 aout->period -= vibval;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2283 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2284 } else // do XM style auto-vibrato
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2285 { if(!(aout->keyoff & KEY_OFF))
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2286 { if(aout->aswppos < s->vibsweep)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2287 { vibdpt = (aout->aswppos*s->vibdepth) / s->vibsweep;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2288 aout->aswppos++;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2289 } else
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2290 vibdpt = s->vibdepth;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2291 } else
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2292 { // key-off -> depth becomes 0 if final depth wasn't reached
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2293 // or stays at final level if depth WAS reached
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2294 if(aout->aswppos>=s->vibsweep)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2295 vibdpt = s->vibdepth;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2296 else
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2297 vibdpt = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2298 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2299 vibval = (vibval*vibdpt)>>8;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2300 aout->period -= vibval;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2301 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2302
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2303 // update vibrato position
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2304 s->avibpos = (s->avibpos+s->vibrate) & 0xff;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2305
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2306 if(aout->cenv.flg & EF_ON)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2307 { envpit = envpit-32;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2308 aout->period -= envpit;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2309 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2310
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2311 Voice_SetFrequency(t,getfrequency(pf->flags,aout->period));
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2312
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2313 if(aout->fadevol == 0) // check for a dead note (fadevol = 0)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2314 Voice_Stop(t);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2315 else
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2316 { // if keyfade, start substracting
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2317 // fadeoutspeed from fadevol:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2318
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2319 if((i != NULL) && (aout->keyoff & KEY_FADE))
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2320 { if(aout->fadevol >= i->volfade)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2321 aout->fadevol -= i->volfade;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2322 else
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2323 aout->fadevol = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2324 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2325 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2326
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2327 MD_SetBPM(pf->bpm);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2328 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2329 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2330
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2331
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2332 BOOL Player_Init(UNIMOD *mf)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2333 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2334 int t;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2335
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2336 mf->extspd = 1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2337 mf->panflag = 1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2338 mf->loop = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2339
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2340 mf->pat_reppos = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2341 mf->pat_repcnt = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2342 mf->sngpos = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2343 mf->sngspd = mf->initspeed;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2344 mf->volume = mf->initvolume;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2345
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2346 mf->vbtick = mf->sngspd;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2347 mf->patdly = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2348 mf->patdly2 = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2349 mf->bpm = mf->inittempo;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2350
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2351 mf->patpos = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2352 mf->posjmp = 2; // <- make sure the player fetches the first note
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2353 mf->patbrk = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2354
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2355 // Make sure the player doesn't start with garbage:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2356
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2357 if((mf->control=(MP_CONTROL *)_mm_calloc(mf->numchn,sizeof(MP_CONTROL)))==NULL) return 1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2358 if((mf->voice=(MP_VOICE *)_mm_calloc(md_sngchn,sizeof(MP_VOICE)))==NULL) return 1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2359
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2360 for(t=0; t<mf->numchn; t++)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2361 { mf->control[t].chanvol = mf->chanvol[t];
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2362 mf->control[t].panning = mf->panning[t];
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2363 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2364
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2365 return 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2366 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2367
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2368
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2369 void Player_Exit(UNIMOD *mf)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2370 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2371 if(mf==NULL) return;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2372 if(mf==pf)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2373 { Player_Stop();
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2374 pf = NULL;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2375 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2376 if(mf->control!=NULL) free(mf->control);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2377 if(mf->voice!=NULL) free(mf->voice);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2378 mf->control = NULL;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2379 mf->voice = NULL;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2380
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2381 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2382
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2383
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2384 void Player_SetVolume(int volume)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2385 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2386 if(pf==NULL) return;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2387
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2388 if(volume > 128) volume = 128;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2389 if(volume < 0) volume = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2390
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2391 pf->volume = volume;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2392 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2393
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2394
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2395 UNIMOD *Player_GetUnimod(void)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2396 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2397 return pf;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2398 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2399
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2400
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2401 void Player_Start(UNIMOD *mf)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2402 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2403 int t;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2404
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2405 if(!MikMod_Active())
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2406 { isfirst = 2;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2407 MikMod_EnableOutput();
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2408 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2409
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2410 if(mf==NULL) return;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2411
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2412 mf->forbid = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2413 if(pf != mf)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2414 { // new song is being started, so completely stop out the old one.
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2415 if(pf!=NULL) pf->forbid = 1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2416 for(t=0; t<md_sngchn; t++) Voice_Stop(t);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2417 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2418
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2419 pf = mf;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2420 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2421
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2422
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2423 void Player_Stop(void)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2424 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2425 if(md_sfxchn==0) MikMod_DisableOutput();
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2426 if(pf != NULL) pf->forbid = 1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2427 pf = NULL;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2428 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2429
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2430
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2431 BOOL MP_Playing(UNIMOD *mf)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2432 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2433 if((mf==NULL) || (mf!=pf)) return 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2434 return(!(mf->sngpos>=mf->numpos));
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2435 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2436
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2437
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2438 BOOL Player_Active(void)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2439 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2440 if(pf==NULL) return 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2441 return(!(pf->sngpos>=pf->numpos));
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2442 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2443
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2444
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2445 void MP_NextPosition(UNIMOD *mf)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2446 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2447 int t;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2448
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2449 if(mf==NULL) return;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2450 mf->forbid = 1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2451 mf->posjmp = 3;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2452 mf->patbrk = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2453 mf->vbtick = mf->sngspd;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2454
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2455 for(t=0; t<md_sngchn; t++)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2456 { Voice_Stop(t);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2457 mf->voice[t].i = NULL;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2458 mf->voice[t].s = NULL;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2459 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2460
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2461 for(t=0; t<mf->numchn; t++)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2462 { mf->control[t].i = NULL;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2463 mf->control[t].s = NULL;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2464 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2465 mf->forbid = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2466 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2467
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2468
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2469 void Player_NextPosition(void)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2470 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2471 MP_NextPosition(pf);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2472 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2473
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2474
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2475 void MP_PrevPosition(UNIMOD *mf)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2476 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2477 int t;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2478
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2479 if(mf==NULL) return;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2480 mf->forbid = 1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2481 mf->posjmp = 1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2482 mf->patbrk = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2483 mf->vbtick = mf->sngspd;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2484
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2485 for(t=0; t<md_sngchn; t++)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2486 { Voice_Stop(t);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2487 mf->voice[t].i = NULL;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2488 mf->voice[t].s = NULL;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2489 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2490
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2491 for(t=0; t<mf->numchn; t++)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2492 { mf->control[t].i = NULL;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2493 mf->control[t].s = NULL;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2494 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2495
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2496 mf->forbid = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2497 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2498
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2499
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2500 void Player_PrevPosition(void)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2501 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2502 MP_PrevPosition(pf);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2503 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2504
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2505
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2506 void MP_SetPosition(UNIMOD *mf, UWORD pos)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2507 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2508 int t;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2509
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2510 if(mf==NULL) return;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2511 mf->forbid = 1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2512 if(pos>=mf->numpos) pos = mf->numpos;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2513 mf->posjmp = 2;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2514 mf->patbrk = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2515 mf->sngpos = pos;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2516 mf->vbtick = mf->sngspd;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2517
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2518 for(t=0; t<md_sngchn; t++)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2519 { Voice_Stop(t);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2520 mf->voice[t].i = NULL;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2521 mf->voice[t].s = NULL;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2522 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2523
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2524 for(t=0; t<mf->numchn; t++)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2525 { mf->control[t].i = NULL;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2526 mf->control[t].s = NULL;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2527 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2528
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2529 mf->forbid = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2530 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2531
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2532
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2533 void Player_SetPosition(UWORD pos)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2534 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2535 MP_SetPosition(pf,pos);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2536 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2537
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2538
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2539 void MP_Unmute(UNIMOD *mf, SLONG arg1, ...)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2540 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2541 va_list ap;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2542 SLONG t, arg2, arg3;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2543
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2544 va_start(ap,arg1);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2545
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2546 if(mf != NULL)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2547 { switch(arg1)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2548 { case MUTE_INCLUSIVE:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2549 if((!(arg2=va_arg(ap,SLONG))) && (!(arg3=va_arg(ap,SLONG))) || (arg2 > arg3) || (arg3 >= mf->numchn))
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2550 { va_end(ap);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2551 return;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2552 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2553 for(;arg2<mf->numchn && arg2<=arg3;arg2++)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2554 mf->control[arg2].muted = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2555 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2556
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2557 case MUTE_EXCLUSIVE:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2558 if((!(arg2=va_arg(ap,SLONG))) && (!(arg3=va_arg(ap,SLONG))) || (arg2 > arg3) || (arg3 >= mf->numchn))
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2559 { va_end(ap);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2560 return;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2561 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2562 for(t=0;t<mf->numchn;t++)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2563 { if ((t>=arg2) && (t<=arg3)) continue;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2564 mf->control[t].muted = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2565 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2566 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2567
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2568 default:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2569 if(arg1<mf->numchn) mf->control[arg1].muted = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2570 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2571 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2572 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2573 va_end(ap);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2574
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2575 return;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2576 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2577
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2578
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2579 void Player_Unmute(SLONG arg1, ...)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2580 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2581 va_list argptr;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2582 MP_Unmute(pf,arg1, argptr);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2583 va_end(argptr);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2584 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2585
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2586
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2587 void MP_Mute(UNIMOD *mf, SLONG arg1, ...)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2588 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2589 va_list ap;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2590 SLONG t, arg2, arg3;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2591
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2592 va_start(ap,arg1);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2593
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2594 if(mf != NULL)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2595 { switch (arg1)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2596 { case MUTE_INCLUSIVE:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2597 if ((!(arg2=va_arg(ap,SLONG))) && (!(arg3=va_arg(ap,SLONG))) || (arg2 > arg3) || (arg3 >= mf->numchn))
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2598 { va_end(ap);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2599 return;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2600 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2601 for(;arg2<mf->numchn && arg2<=arg3;arg2++)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2602 mf->control[arg2].muted = 1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2603 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2604
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2605 case MUTE_EXCLUSIVE:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2606 if ((!(arg2=va_arg(ap,SLONG))) && (!(arg3=va_arg(ap,SLONG))) || (arg2 > arg3) || (arg3 >= mf->numchn))
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2607 { va_end(ap);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2608 return;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2609 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2610 for (t=0; t<mf->numchn; t++)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2611 { if ((t>=arg2) && (t<=arg3)) continue;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2612 mf->control[t].muted = 1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2613 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2614 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2615
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2616 default:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2617 if(arg1<mf->numchn)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2618 mf->control[arg1].muted = 1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2619 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2620 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2621 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2622 va_end(ap);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2623
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2624 return;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2625 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2626
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2627
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2628 void Player_Mute(SLONG arg1, ...)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2629 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2630 va_list argptr;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2631 MP_Mute(pf,arg1, argptr);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2632 va_end(argptr);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2633 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2634
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2635
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2636 void MP_ToggleMute(UNIMOD *mf, SLONG arg1, ...)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2637 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2638 va_list ap;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2639 SLONG arg2, arg3;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2640 ULONG t;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2641
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2642 va_start(ap,arg1);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2643
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2644 if(mf != NULL)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2645 { switch (arg1)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2646 { case MUTE_INCLUSIVE:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2647 if ((!(arg2=va_arg(ap,SLONG))) && (!(arg3=va_arg(ap,SLONG))) || (arg2 > arg3) || (arg3 >= mf->numchn))
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2648 { va_end(ap);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2649 return;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2650 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2651 for(; arg2<mf->numchn && arg2<=arg3; arg2++)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2652 mf->control[arg2].muted = (mf->control[arg2].muted) ? 0 : 1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2653
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2654 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2655
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2656 case MUTE_EXCLUSIVE:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2657 if ((!(arg2=va_arg(ap,SLONG))) && (!(arg3=va_arg(ap,SLONG))) || (arg2 > arg3) || (arg3 >= mf->numchn))
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2658 { va_end(ap);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2659 return;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2660 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2661 for (t=0;t<mf->numchn;t++)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2662 { if((t>=arg2) && (t<=arg3)) continue;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2663 mf->control[t].muted = (mf->control[t].muted) ? 0 : 1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2664 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2665 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2666
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2667 default:
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2668 if(arg1<mf->numchn)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2669 mf->control[arg1].muted = (mf->control[arg1].muted) ? 0 : 1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2670 break;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2671 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2672 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2673 va_end(ap);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2674
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2675 return;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2676 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2677
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2678
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2679 void Player_ToggleMute(SLONG arg1, ...)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2680 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2681 va_list argptr;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2682 MP_ToggleMute(pf,arg1, argptr);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2683 va_end(argptr);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2684 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2685
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2686
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2687 BOOL MP_Muted(UNIMOD *mf, int chan)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2688 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2689 if(mf==NULL) return 1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2690 return (chan<mf->numchn) ? mf->control[chan].muted : 1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2691 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2692
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2693
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2694 BOOL Player_Muted(int chan)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2695 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2696 if(pf==NULL) return 1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2697 return (chan<pf->numchn) ? pf->control[chan].muted : 1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2698 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2699
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2700
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2701 int MP_GetChannelVoice(UNIMOD *mf, int chan)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2702 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2703 if(mf==NULL) return 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2704 return mf->control[chan].slavechn;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2705 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2706
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2707
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2708 int Player_GetChannelVoice(int chan)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2709 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2710 if(pf==NULL) return 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2711 return pf->control[chan].slavechn;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2712 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2713
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2714
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2715 void Player_TogglePause(void)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2716 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2717 if(pf==NULL) return;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2718 if(pf->forbid == 1)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2719 pf->forbid = 0;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2720 else
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2721 pf->forbid = 1;
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2722 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2723
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2724
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2725 // --> The following procedures were taken from UNITRK because they
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2726 // -> are ProTracker format specific.
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2727
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2728 void UniInstrument(UBYTE ins)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2729 // Appends UNI_INSTRUMENT opcode to the unitrk stream.
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2730 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2731 UniWrite(UNI_INSTRUMENT);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2732 UniWrite(ins);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2733 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2734
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2735 void UniNote(UBYTE note)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2736 // Appends UNI_NOTE opcode to the unitrk stream.
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2737 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2738 UniWrite(UNI_NOTE);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2739 UniWrite(note);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2740 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2741
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2742 void UniPTEffect(UBYTE eff, UBYTE dat)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2743 // Appends UNI_PTEFFECTX opcode to the unitrk stream.
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2744 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2745 if(eff!=0 || dat!=0) // don't write empty effect
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2746 { UniWrite(UNI_PTEFFECT0+eff);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2747 UniWrite(dat);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2748 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2749 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2750
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2751 void UniVolEffect(UWORD eff, UBYTE dat)
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2752 // Appends UNI_VOLEFFECT + effect/dat to unistream.
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2753 {
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2754 if(eff!=0 || dat!=0) // don't write empty effect
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2755 { UniWrite(UNI_VOLEFFECTS);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2756 UniWrite(eff); UniWrite(dat);
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2757 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2758 }
de95ce2eacfd Initial revision
darius
parents:
diff changeset
2759