annotate playercode/mplayer.c @ 17:80fa6dd10e14

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