annotate Plugins/Input/adplug/core/protrack.cpp @ 991:3eff4f35b39d trunk

[svn] Declare variables in a different order, as GCC feels that the current order was wrong.
author chainsaw
date Sun, 30 Apr 2006 16:48:20 -0700
parents 8df427a314a8
children 6ad7eb96dd26
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
359
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
1 /*
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
2 * Adplug - Replayer for many OPL2/OPL3 audio file formats.
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
3 * Copyright (C) 1999 - 2002 Simon Peter, <dn.tlp@gmx.net>, et al.
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
4 *
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
5 * This library is free software; you can redistribute it and/or
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
6 * modify it under the terms of the GNU Lesser General Public
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
7 * License as published by the Free Software Foundation; either
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
8 * version 2.1 of the License, or (at your option) any later version.
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
9 *
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
10 * This library is distributed in the hope that it will be useful,
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
13 * Lesser General Public License for more details.
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
14 *
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
15 * You should have received a copy of the GNU Lesser General Public
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
16 * License along with this library; if not, write to the Free Software
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
18 *
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
19 * protrack.cpp - Generic Protracker Player
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
20 * Copyright (C) 2000 - 2002 Simon Peter <dn.tlp@gmx.net>
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
21 *
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
22 * NOTES:
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
23 * This is a generic Protracker-based formats player. It offers all Protracker
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
24 * features, plus a good set of extensions to be compatible to other Protracker
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
25 * derivatives. It is derived from the original SA2 player by me. If you got a
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
26 * Protracker-like format, this is most certainly the player you want to use.
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
27 *
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
28 * USAGE:
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
29 * Read the file 'Protracker.txt' in the 'doc' subdirectory.
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
30 */
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
31
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
32 #include "protrack.h"
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
33 #include "debug.h"
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
34
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
35 #define SPECIALARPLEN 256 // Standard length of special arpeggio lists
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
36 #define JUMPMARKER 0x80 // Orderlist jump marker
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
37
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
38 // SA2 compatible adlib note table
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
39 const unsigned short CmodPlayer::sa2_notetable[12] =
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
40 {340,363,385,408,432,458,485,514,544,577,611,647};
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
41
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
42 // SA2 compatible vibrato rate table
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
43 const unsigned char CmodPlayer::vibratotab[32] =
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
44 {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1};
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
45
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
46 /*** public methods *************************************/
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
47
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
48 CmodPlayer::CmodPlayer(Copl *newopl)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
49 : CPlayer(newopl), inst(0), order(0), arplist(0), arpcmd(0), initspeed(6),
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
50 activechan(0xffff), flags(Standard), nop(0), nrows(0), npats(0), nchans(0)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
51 {
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
52 realloc_order(128);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
53 realloc_patterns(64, 64, 9);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
54 realloc_instruments(250);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
55 init_notetable(sa2_notetable);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
56 }
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
57
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
58 CmodPlayer::~CmodPlayer()
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
59 {
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
60 dealloc();
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
61 }
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
62
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
63 bool CmodPlayer::update()
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
64 {
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
65 unsigned char pattbreak=0,donote; // remember vars
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
66 unsigned char pattnr,chan,info1,info2,info; // cache vars
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
67 unsigned short track;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
68 unsigned long row;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
69
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
70 if(!speed) // song full stop
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
71 return !songend;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
72
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
73 // effect handling (timer dependant)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
74 for(chan=0;chan<nchans;chan++) {
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
75 if(arplist && arpcmd && inst[channel[chan].inst].arpstart) // special arpeggio
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
76 if(channel[chan].arpspdcnt)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
77 channel[chan].arpspdcnt--;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
78 else
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
79 if(arpcmd[channel[chan].arppos] != 255) {
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
80 switch(arpcmd[channel[chan].arppos]) {
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
81 case 252: channel[chan].vol1 = arplist[channel[chan].arppos]; // set volume
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
82 if(channel[chan].vol1 > 63) // ?????
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
83 channel[chan].vol1 = 63;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
84 channel[chan].vol2 = channel[chan].vol1;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
85 setvolume(chan);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
86 break;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
87 case 253: channel[chan].key = 0; setfreq(chan); break; // release sustaining note
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
88 case 254: channel[chan].arppos = arplist[channel[chan].arppos]; break; // arpeggio loop
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
89 default: if(arpcmd[channel[chan].arppos]) {
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
90 if(arpcmd[channel[chan].arppos] / 10)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
91 opl->write(0xe3 + op_table[chan], arpcmd[channel[chan].arppos] / 10 - 1);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
92 if(arpcmd[channel[chan].arppos] % 10)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
93 opl->write(0xe0 + op_table[chan], (arpcmd[channel[chan].arppos] % 10) - 1);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
94 if(arpcmd[channel[chan].arppos] < 10) // ?????
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
95 opl->write(0xe0 + op_table[chan], arpcmd[channel[chan].arppos] - 1);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
96 }
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
97 }
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
98 if(arpcmd[channel[chan].arppos] != 252) {
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
99 if(arplist[channel[chan].arppos] <= 96)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
100 setnote(chan,channel[chan].note + arplist[channel[chan].arppos]);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
101 if(arplist[channel[chan].arppos] >= 100)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
102 setnote(chan,arplist[channel[chan].arppos] - 100);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
103 } else
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
104 setnote(chan,channel[chan].note);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
105 setfreq(chan);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
106 if(arpcmd[channel[chan].arppos] != 255)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
107 channel[chan].arppos++;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
108 channel[chan].arpspdcnt = inst[channel[chan].inst].arpspeed - 1;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
109 }
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
110
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
111 info1 = channel[chan].info1;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
112 info2 = channel[chan].info2;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
113 if(flags & Decimal)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
114 info = channel[chan].info1 * 10 + channel[chan].info2;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
115 else
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
116 info = (channel[chan].info1 << 4) + channel[chan].info2;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
117 switch(channel[chan].fx) {
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
118 case 0: if(info) { // arpeggio
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
119 if(channel[chan].trigger < 2)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
120 channel[chan].trigger++;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
121 else
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
122 channel[chan].trigger = 0;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
123 switch(channel[chan].trigger) {
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
124 case 0: setnote(chan,channel[chan].note); break;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
125 case 1: setnote(chan,channel[chan].note + info1); break;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
126 case 2: setnote(chan,channel[chan].note + info2);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
127 }
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
128 setfreq(chan);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
129 }
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
130 break;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
131 case 1: slide_up(chan,info); setfreq(chan); break; // slide up
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
132 case 2: slide_down(chan,info); setfreq(chan); break; // slide down
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
133 case 3: tone_portamento(chan,channel[chan].portainfo); break; // tone portamento
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
134 case 4: vibrato(chan,channel[chan].vibinfo1,channel[chan].vibinfo2); break; // vibrato
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
135 case 5: // tone portamento & volume slide
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
136 case 6: if(channel[chan].fx == 5) // vibrato & volume slide
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
137 tone_portamento(chan,channel[chan].portainfo);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
138 else
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
139 vibrato(chan,channel[chan].vibinfo1,channel[chan].vibinfo2);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
140 case 10: if(del % 4) // SA2 volume slide
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
141 break;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
142 if(info1)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
143 vol_up(chan,info1);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
144 else
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
145 vol_down(chan,info2);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
146 setvolume(chan);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
147 break;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
148 case 14: if(info1 == 3) // retrig note
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
149 if(!(del % (info2+1)))
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
150 playnote(chan);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
151 break;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
152 case 16: if(del % 4) // AMD volume slide
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
153 break;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
154 if(info1)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
155 vol_up_alt(chan,info1);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
156 else
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
157 vol_down_alt(chan,info2);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
158 setvolume(chan);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
159 break;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
160 case 20: // RAD volume slide
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
161 if(info < 50)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
162 vol_down_alt(chan,info);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
163 else
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
164 vol_up_alt(chan,info - 50);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
165 setvolume(chan);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
166 break;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
167 case 26: // volume slide
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
168 if(info1)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
169 vol_up(chan,info1);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
170 else
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
171 vol_down(chan,info2);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
172 setvolume(chan);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
173 break;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
174 case 28:
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
175 if (info1) {
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
176 slide_up(chan,1); channel[chan].info1--;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
177 }
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
178 if (info2) {
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
179 slide_down(chan,1); channel[chan].info2--;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
180 }
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
181 setfreq(chan);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
182 break;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
183 }
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
184 }
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
185
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
186 if(del) { // speed compensation
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
187 del--;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
188 return !songend;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
189 }
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
190
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
191 // arrangement handling
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
192 if(ord >= length) {
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
193 songend = 1; // set end-flag
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
194 ord = restartpos;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
195 }
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
196 pattnr = order[ord];
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
197
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
198 if(!rw) AdPlug_LogWrite("\nCmodPlayer::update(): Pattern: %d, Order: %d\n", pattnr, ord);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
199 AdPlug_LogWrite("CmodPlayer::update():%3d|", rw);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
200
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
201 // play row
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
202 row = rw;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
203 for(chan=0;chan<nchans;chan++) {
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
204 if(!(activechan >> (15 - chan)) & 1) { // channel active?
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
205 AdPlug_LogWrite("N/A|");
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
206 continue;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
207 }
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
208 if(!(track = trackord[pattnr][chan])) { // resolve track
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
209 AdPlug_LogWrite("------------|");
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
210 continue;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
211 } else
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
212 track--;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
213
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
214 AdPlug_LogWrite("%3d%3d%2X%2X%2X|", tracks[track][row].note,
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
215 tracks[track][row].inst, tracks[track][row].command,
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
216 tracks[track][row].param1, tracks[track][row].param2);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
217
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
218 donote = 0;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
219 if(tracks[track][row].inst) {
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
220 channel[chan].inst = tracks[track][row].inst - 1;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
221 if (!(flags & Faust)) {
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
222 channel[chan].vol1 = 63 - (inst[channel[chan].inst].data[10] & 63);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
223 channel[chan].vol2 = 63 - (inst[channel[chan].inst].data[9] & 63);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
224 setvolume(chan);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
225 }
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
226 }
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
227
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
228 if(tracks[track][row].note && tracks[track][row].command != 3) { // no tone portamento
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
229 channel[chan].note = tracks[track][row].note;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
230 setnote(chan,tracks[track][row].note);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
231 channel[chan].nextfreq = channel[chan].freq;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
232 channel[chan].nextoct = channel[chan].oct;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
233 channel[chan].arppos = inst[channel[chan].inst].arpstart;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
234 channel[chan].arpspdcnt = 0;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
235 if(tracks[track][row].note != 127) // handle key off
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
236 donote = 1;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
237 }
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
238 channel[chan].fx = tracks[track][row].command;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
239 channel[chan].info1 = tracks[track][row].param1;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
240 channel[chan].info2 = tracks[track][row].param2;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
241
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
242 if(donote)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
243 playnote(chan);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
244
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
245 // command handling (row dependant)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
246 info1 = channel[chan].info1;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
247 info2 = channel[chan].info2;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
248 if(flags & Decimal)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
249 info = channel[chan].info1 * 10 + channel[chan].info2;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
250 else
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
251 info = (channel[chan].info1 << 4) + channel[chan].info2;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
252 switch(channel[chan].fx) {
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
253 case 3: if(tracks[track][row].note) { // tone portamento
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
254 if(tracks[track][row].note < 13)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
255 channel[chan].nextfreq = notetable[tracks[track][row].note - 1];
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
256 else
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
257 if(tracks[track][row].note % 12 > 0)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
258 channel[chan].nextfreq = notetable[(tracks[track][row].note % 12) - 1];
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
259 else
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
260 channel[chan].nextfreq = notetable[11];
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
261 channel[chan].nextoct = (tracks[track][row].note - 1) / 12;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
262 if(tracks[track][row].note == 127) { // handle key off
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
263 channel[chan].nextfreq = channel[chan].freq;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
264 channel[chan].nextoct = channel[chan].oct;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
265 }
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
266 }
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
267 if(info) // remember vars
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
268 channel[chan].portainfo = info;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
269 break;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
270 case 4: if(info) { // vibrato (remember vars)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
271 channel[chan].vibinfo1 = info1;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
272 channel[chan].vibinfo2 = info2;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
273 }
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
274 break;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
275 case 7: tempo = info; break; // set tempo
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
276 case 8: channel[chan].key = 0; setfreq(chan); break; // release sustaining note
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
277 case 9: // set carrier/modulator volume
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
278 if(info1)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
279 channel[chan].vol1 = info1 * 7;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
280 else
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
281 channel[chan].vol2 = info2 * 7;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
282 setvolume(chan);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
283 break;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
284 case 11: pattbreak = 1; rw = 0; if(info < ord) songend = 1; ord = info; break; // position jump
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
285 case 12: // set volume
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
286 channel[chan].vol1 = info;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
287 channel[chan].vol2 = info;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
288 if(channel[chan].vol1 > 63)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
289 channel[chan].vol1 = 63;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
290 if(channel[chan].vol2 > 63)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
291 channel[chan].vol2 = 63;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
292 setvolume(chan);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
293 break;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
294 case 13: if(!pattbreak) { pattbreak = 1; rw = info; ord++; } break; // pattern break
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
295 case 14: // extended command
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
296 switch(info1) {
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
297 case 0: if(info2) // define cell-tremolo
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
298 regbd |= 128;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
299 else
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
300 regbd &= 127;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
301 opl->write(0xbd,regbd);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
302 break;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
303 case 1: if(info2) // define cell-vibrato
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
304 regbd |= 64;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
305 else
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
306 regbd &= 191;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
307 opl->write(0xbd,regbd);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
308 break;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
309 case 4: vol_up_alt(chan,info2); // increase volume fine
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
310 setvolume(chan);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
311 break;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
312 case 5: vol_down_alt(chan,info2); // decrease volume fine
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
313 setvolume(chan);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
314 break;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
315 case 6: slide_up(chan,info2); // manual slide up
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
316 setfreq(chan);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
317 break;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
318 case 7: slide_down(chan,info2); // manual slide down
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
319 setfreq(chan);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
320 break;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
321 }
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
322 break;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
323 case 15: // SA2 set speed
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
324 if(info <= 0x1f)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
325 speed = info;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
326 if(info >= 0x32)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
327 tempo = info;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
328 if(!info)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
329 songend = 1;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
330 break;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
331 case 17: // alternate set volume
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
332 channel[chan].vol1 = info;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
333 if(channel[chan].vol1 > 63)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
334 channel[chan].vol1 = 63;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
335 if(inst[channel[chan].inst].data[0] & 1) {
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
336 channel[chan].vol2 = info;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
337 if(channel[chan].vol2 > 63)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
338 channel[chan].vol2 = 63;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
339 }
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
340 setvolume(chan);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
341 break;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
342 case 18: // AMD set speed
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
343 if(info <= 31 && info > 0)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
344 speed = info;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
345 if(info > 31 || !info)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
346 tempo = info;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
347 break;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
348 case 19: // RAD/A2M set speed
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
349 speed = (info ? info : info + 1);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
350 break;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
351 case 21: // set modulator volume
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
352 if(info <= 63)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
353 channel[chan].vol2 = info;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
354 else
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
355 channel[chan].vol2 = 63;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
356 setvolume(chan);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
357 break;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
358 case 22: // set carrier volume
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
359 if(info <= 63)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
360 channel[chan].vol1 = info;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
361 else
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
362 channel[chan].vol1 = 63;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
363 setvolume(chan);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
364 break;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
365 case 23: // fine frequency slide up
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
366 slide_up(chan,info);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
367 setfreq(chan);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
368 break;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
369 case 24: // fine frequency slide down
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
370 slide_down(chan,info);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
371 setfreq(chan);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
372 break;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
373 case 25: // set carrier/modulator waveform
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
374 if(info1 != 0x0f)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
375 opl->write(0xe3 + op_table[chan],info1);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
376 if(info2 != 0x0f)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
377 opl->write(0xe0 + op_table[chan],info2);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
378 break;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
379 case 27: // set chip tremolo/vibrato
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
380 if (info1)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
381 regbd |= 128;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
382 else
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
383 regbd &= 127;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
384 if (info2)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
385 regbd |= 64;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
386 else
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
387 regbd &= 191;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
388 opl->write(0xbd,regbd);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
389 break;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
390 }
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
391 }
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
392
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
393 del = speed - 1; // speed compensation
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
394 if(!pattbreak) { // next row (only if no manual advance)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
395 rw++;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
396 if(rw >= nrows) {
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
397 rw = 0;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
398 ord++;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
399 }
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
400 }
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
401 if(ord < length) {
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
402 if(order[ord] >= JUMPMARKER) { // jump to order
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
403 ord = order[ord] - JUMPMARKER;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
404 songend = 1;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
405 }
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
406 } else
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
407 songend = 1;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
408
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
409 AdPlug_LogWrite("\n");
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
410 return !songend;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
411 }
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
412
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
413 void CmodPlayer::rewind(int subsong)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
414 {
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
415 unsigned long i;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
416
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
417 // Reset playing variables
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
418 songend = del = ord = rw = regbd = 0;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
419 tempo = bpm; speed = initspeed;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
420
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
421 // Reset channel data
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
422 memset(channel,0,sizeof(Channel)*nchans);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
423
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
424 // Compute number of patterns, if needed
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
425 if(!nop)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
426 for(i=0;i<length;i++)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
427 nop = (order[i] > nop ? order[i] : nop);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
428
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
429 opl->init(); // Reset OPL chip
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
430 opl->write(1,32); // Go to ym3812 mode
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
431 }
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
432
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
433 float CmodPlayer::getrefresh()
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
434 {
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
435 return (float) (tempo / 2.5);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
436 }
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
437
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
438 void CmodPlayer::init_trackord()
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
439 {
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
440 unsigned long i;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
441
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
442 for(i=0;i<npats*nchans;i++)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
443 trackord[i / nchans][i % nchans] = i + 1;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
444 }
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
445
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
446 bool CmodPlayer::init_specialarp()
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
447 {
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
448 arplist = new unsigned char[SPECIALARPLEN];
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
449 arpcmd = new unsigned char[SPECIALARPLEN];
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
450
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
451 return true;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
452 }
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
453
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
454 void CmodPlayer::init_notetable(const unsigned short *newnotetable)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
455 {
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
456 memcpy(notetable, newnotetable, 12 * 2);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
457 }
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
458
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
459 bool CmodPlayer::realloc_order(unsigned long len)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
460 {
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
461 if(order) delete [] order;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
462 order = new unsigned char[len];
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
463 return true;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
464 }
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
465
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
466 bool CmodPlayer::realloc_patterns(unsigned long pats, unsigned long rows, unsigned long chans)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
467 {
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
468 unsigned long i;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
469
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
470 dealloc_patterns();
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
471
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
472 // set new number of tracks, rows and channels
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
473 npats = pats; nrows = rows; nchans = chans;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
474
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
475 // alloc new patterns
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
476 tracks = new Tracks *[pats * chans];
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
477 for(i=0;i<pats*chans;i++) tracks[i] = new Tracks[rows];
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
478 trackord = new unsigned short *[pats];
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
479 for(i=0;i<pats;i++) trackord[i] = new unsigned short[chans];
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
480 channel = new Channel[chans];
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
481
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
482 // initialize new patterns
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
483 for(i=0;i<pats*chans;i++) memset(tracks[i],0,sizeof(Tracks)*rows);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
484 for(i=0;i<pats;i++) memset(trackord[i],0,chans*2);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
485
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
486 return true;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
487 }
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
488
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
489 void CmodPlayer::dealloc_patterns()
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
490 {
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
491 unsigned long i;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
492
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
493 // dealloc everything previously allocated
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
494 if(npats && nrows && nchans) {
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
495 for(i=0;i<npats*nchans;i++) delete [] tracks[i];
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
496 delete [] tracks;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
497 for(i=0;i<npats;i++) delete [] trackord[i];
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
498 delete [] trackord;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
499 delete [] channel;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
500 }
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
501 }
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
502
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
503 bool CmodPlayer::realloc_instruments(unsigned long len)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
504 {
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
505 // dealloc previous instance, if any
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
506 if(inst) delete [] inst;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
507
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
508 inst = new Instrument[len];
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
509 memset(inst,0,sizeof(Instrument)*len); // reset instruments
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
510 return true;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
511 }
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
512
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
513 void CmodPlayer::dealloc()
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
514 {
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
515 if(inst) delete [] inst;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
516 if(order) delete [] order;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
517 if(arplist) delete [] arplist;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
518 if(arpcmd) delete [] arpcmd;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
519 dealloc_patterns();
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
520 }
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
521
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
522 /*** private methods *************************************/
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
523
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
524 void CmodPlayer::setvolume(unsigned char chan)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
525 {
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
526 if (flags & Faust)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
527 setvolume_alt(chan);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
528 else {
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
529 opl->write(0x40 + op_table[chan], 63-channel[chan].vol2 + (inst[channel[chan].inst].data[9] & 192));
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
530 opl->write(0x43 + op_table[chan], 63-channel[chan].vol1 + (inst[channel[chan].inst].data[10] & 192));
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
531 }
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
532 }
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
533
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
534 void CmodPlayer::setvolume_alt(unsigned char chan)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
535 {
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
536 unsigned char ivol2 = inst[channel[chan].inst].data[9] & 63;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
537 unsigned char ivol1 = inst[channel[chan].inst].data[10] & 63;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
538
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
539 opl->write(0x40 + op_table[chan], (((63 - channel[chan].vol2 & 63) + ivol2) >> 1) + (inst[channel[chan].inst].data[9] & 192));
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
540 opl->write(0x43 + op_table[chan], (((63 - channel[chan].vol1 & 63) + ivol1) >> 1) + (inst[channel[chan].inst].data[10] & 192));
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
541 }
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
542
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
543 void CmodPlayer::setfreq(unsigned char chan)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
544 {
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
545 opl->write(0xa0 + chan, channel[chan].freq & 255);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
546 if(channel[chan].key)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
547 opl->write(0xb0 + chan, ((channel[chan].freq & 768) >> 8) + (channel[chan].oct << 2) | 32);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
548 else
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
549 opl->write(0xb0 + chan, ((channel[chan].freq & 768) >> 8) + (channel[chan].oct << 2));
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
550 }
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
551
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
552 void CmodPlayer::playnote(unsigned char chan)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
553 {
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
554 unsigned char op = op_table[chan], insnr = channel[chan].inst;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
555
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
556 if(!(flags & NoKeyOn))
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
557 opl->write(0xb0 + chan, 0); // stop old note
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
558
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
559 // set instrument data
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
560 opl->write(0x20 + op, inst[insnr].data[1]);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
561 opl->write(0x23 + op, inst[insnr].data[2]);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
562 opl->write(0x60 + op, inst[insnr].data[3]);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
563 opl->write(0x63 + op, inst[insnr].data[4]);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
564 opl->write(0x80 + op, inst[insnr].data[5]);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
565 opl->write(0x83 + op, inst[insnr].data[6]);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
566 opl->write(0xe0 + op, inst[insnr].data[7]);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
567 opl->write(0xe3 + op, inst[insnr].data[8]);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
568 opl->write(0xc0 + chan, inst[insnr].data[0]);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
569 opl->write(0xbd, inst[insnr].misc); // set misc. register
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
570
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
571 // set frequency, volume & play
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
572 channel[chan].key = 1;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
573 setfreq(chan);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
574
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
575 if (flags & Faust) {
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
576 channel[chan].vol2 = 63;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
577 channel[chan].vol1 = 63;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
578 }
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
579 setvolume(chan);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
580 }
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
581
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
582 void CmodPlayer::setnote(unsigned char chan, int note)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
583 {
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
584 if(note > 96)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
585 if(note == 127) { // key off
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
586 channel[chan].key = 0;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
587 setfreq(chan);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
588 return;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
589 } else
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
590 note = 96;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
591
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
592 if(note < 13)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
593 channel[chan].freq = notetable[note - 1];
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
594 else
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
595 if(note % 12 > 0)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
596 channel[chan].freq = notetable[(note % 12) - 1];
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
597 else
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
598 channel[chan].freq = notetable[11];
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
599 channel[chan].oct = (note - 1) / 12;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
600 channel[chan].freq += inst[channel[chan].inst].slide; // apply pre-slide
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
601 }
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
602
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
603 void CmodPlayer::slide_down(unsigned char chan, int amount)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
604 {
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
605 channel[chan].freq -= amount;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
606 if(channel[chan].freq <= 342)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
607 if(channel[chan].oct) {
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
608 channel[chan].oct--;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
609 channel[chan].freq <<= 1;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
610 } else
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
611 channel[chan].freq = 342;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
612 }
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
613
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
614 void CmodPlayer::slide_up(unsigned char chan, int amount)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
615 {
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
616 channel[chan].freq += amount;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
617 if(channel[chan].freq >= 686)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
618 if(channel[chan].oct < 7) {
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
619 channel[chan].oct++;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
620 channel[chan].freq >>= 1;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
621 } else
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
622 channel[chan].freq = 686;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
623 }
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
624
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
625 void CmodPlayer::tone_portamento(unsigned char chan, unsigned char info)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
626 {
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
627 if(channel[chan].freq + (channel[chan].oct << 10) < channel[chan].nextfreq +
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
628 (channel[chan].nextoct << 10)) {
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
629 slide_up(chan,info);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
630 if(channel[chan].freq + (channel[chan].oct << 10) > channel[chan].nextfreq +
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
631 (channel[chan].nextoct << 10)) {
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
632 channel[chan].freq = channel[chan].nextfreq;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
633 channel[chan].oct = channel[chan].nextoct;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
634 }
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
635 }
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
636 if(channel[chan].freq + (channel[chan].oct << 10) > channel[chan].nextfreq +
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
637 (channel[chan].nextoct << 10)) {
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
638 slide_down(chan,info);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
639 if(channel[chan].freq + (channel[chan].oct << 10) < channel[chan].nextfreq +
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
640 (channel[chan].nextoct << 10)) {
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
641 channel[chan].freq = channel[chan].nextfreq;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
642 channel[chan].oct = channel[chan].nextoct;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
643 }
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
644 }
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
645 setfreq(chan);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
646 }
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
647
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
648 void CmodPlayer::vibrato(unsigned char chan, unsigned char speed, unsigned char depth)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
649 {
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
650 int i;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
651
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
652 if(!speed || !depth)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
653 return;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
654
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
655 if(depth > 14)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
656 depth = 14;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
657
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
658 for(i=0;i<speed;i++) {
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
659 channel[chan].trigger++;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
660 while(channel[chan].trigger >= 64)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
661 channel[chan].trigger -= 64;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
662 if(channel[chan].trigger >= 16 && channel[chan].trigger < 48)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
663 slide_down(chan,vibratotab[channel[chan].trigger - 16] / (16-depth));
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
664 if(channel[chan].trigger < 16)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
665 slide_up(chan,vibratotab[channel[chan].trigger + 16] / (16-depth));
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
666 if(channel[chan].trigger >= 48)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
667 slide_up(chan,vibratotab[channel[chan].trigger - 48] / (16-depth));
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
668 }
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
669 setfreq(chan);
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
670 }
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
671
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
672 void CmodPlayer::vol_up(unsigned char chan, int amount)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
673 {
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
674 if(channel[chan].vol1 + amount < 63)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
675 channel[chan].vol1 += amount;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
676 else
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
677 channel[chan].vol1 = 63;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
678
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
679 if(channel[chan].vol2 + amount < 63)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
680 channel[chan].vol2 += amount;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
681 else
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
682 channel[chan].vol2 = 63;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
683 }
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
684
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
685 void CmodPlayer::vol_down(unsigned char chan, int amount)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
686 {
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
687 if(channel[chan].vol1 - amount > 0)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
688 channel[chan].vol1 -= amount;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
689 else
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
690 channel[chan].vol1 = 0;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
691
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
692 if(channel[chan].vol2 - amount > 0)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
693 channel[chan].vol2 -= amount;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
694 else
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
695 channel[chan].vol2 = 0;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
696 }
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
697
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
698 void CmodPlayer::vol_up_alt(unsigned char chan, int amount)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
699 {
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
700 if(channel[chan].vol1 + amount < 63)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
701 channel[chan].vol1 += amount;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
702 else
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
703 channel[chan].vol1 = 63;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
704 if(inst[channel[chan].inst].data[0] & 1)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
705 if(channel[chan].vol2 + amount < 63)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
706 channel[chan].vol2 += amount;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
707 else
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
708 channel[chan].vol2 = 63;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
709 }
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
710
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
711 void CmodPlayer::vol_down_alt(unsigned char chan, int amount)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
712 {
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
713 if(channel[chan].vol1 - amount > 0)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
714 channel[chan].vol1 -= amount;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
715 else
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
716 channel[chan].vol1 = 0;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
717 if(inst[channel[chan].inst].data[0] & 1)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
718 if(channel[chan].vol2 - amount > 0)
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
719 channel[chan].vol2 -= amount;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
720 else
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
721 channel[chan].vol2 = 0;
8df427a314a8 [svn] Adlib synthesizer (AdPlug) support.
chainsaw
parents:
diff changeset
722 }