annotate Plugins/Input/adplug/core/mid.cpp @ 813:c8cf439179b8 trunk

[svn] - Fix a ton and a half of memory leaks, via the wonderful Leonardo Boshell <leonardop -at- gentoo.org>.
author nenolod
date Fri, 10 Mar 2006 08:20:15 -0800
parents 4ad3a5fe48bf
children f12d7e208b43
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
412
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1 /*
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
2 * Adplug - Replayer for many OPL2/OPL3 audio file formats.
428
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
3 * Copyright (C) 1999 - 2005 Simon Peter, <dn.tlp@gmx.net>, et al.
412
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
4 *
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
5 * This library is free software; you can redistribute it and/or
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
6 * modify it under the terms of the GNU Lesser General Public
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
7 * License as published by the Free Software Foundation; either
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
8 * version 2.1 of the License, or (at your option) any later version.
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
9 *
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
10 * This library is distributed in the hope that it will be useful,
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
13 * Lesser General Public License for more details.
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
14 *
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
15 * You should have received a copy of the GNU Lesser General Public
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
16 * License along with this library; if not, write to the Free Software
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
18 *
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
19 *
428
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
20 * MIDI & MIDI-like file player - Last Update: 10/15/2005
412
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
21 * by Phil Hassey - www.imitationpickles.org
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
22 * philhassey@hotmail.com
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
23 *
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
24 * Can play the following
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
25 * .LAA - a raw save of a Lucas Arts Adlib music
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
26 * or
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
27 * a raw save of a LucasFilm Adlib music
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
28 * .CMF - Creative Music Format
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
29 * .SCI - the sierra "midi" format.
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
30 * Files must be in the form
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
31 * xxxNAME.sci
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
32 * So that the loader can load the right patch file:
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
33 * xxxPATCH.003 (patch.003 must be saved from the
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
34 * sierra resource from each game.)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
35 *
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
36 * 1/9/2006: audacious libadplug
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
37 * Status: MID not as fine as originally thought. Removing general MIDI detector so timidity handles these files instead.
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
38 *
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
39 * 6/2/2000: v1.0 relased by phil hassey
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
40 * Status: LAA is almost perfect
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
41 * - some volumes are a bit off (intrument too quiet)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
42 * MID is fine (who wants to listen to MIDI vid adlib anyway)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
43 * CMF is okay (still needs the adlib rythm mode implemented
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
44 * for real)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
45 * 6/6/2000:
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
46 * Status: SCI: there are two SCI formats, orginal and advanced.
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
47 * original: (Found in SCI/EGA Sierra Adventures)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
48 * played almost perfectly, I believe
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
49 * there is one mistake in the instrument
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
50 * loader that causes some sounds to
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
51 * not be quite right. Most sounds are fine.
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
52 * advanced: (Found in SCI/VGA Sierra Adventures)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
53 * These are multi-track files. (Thus the
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
54 * player had to be modified to work with
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
55 * them.) This works fine.
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
56 * There are also multiple tunes in each file.
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
57 * I think some of them are supposed to be
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
58 * played at the same time, but I'm not sure
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
59 * when.
428
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
60 * 8/16/2000:
412
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
61 * Status: LAA: now EGA and VGA lucas games work pretty well
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
62 *
428
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
63 * 10/15/2005: Changes by Simon Peter
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
64 * Added rhythm mode support for CMF format.
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
65 *
412
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
66 * Other acknowledgements:
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
67 * Allegro - for the midi instruments and the midi volume table
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
68 * SCUMM Revisited - for getting the .LAA / .MIDs out of those
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
69 * LucasArts files.
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
70 * FreeSCI - for some information on the sci music files
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
71 * SD - the SCI Decoder (to get all .sci out of the Sierra files)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
72 */
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
73
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
74 #include <stdlib.h>
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
75 #include <stdio.h>
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
76 #include <math.h>
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
77 #include <string.h>
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
78 #include "mid.h"
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
79 #include "mididata.h"
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
80
428
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
81 /*#define TESTING*/
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
82 #ifdef TESTING
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
83 #define midiprintf printf
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
84 #else
412
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
85 void CmidPlayer::midiprintf(char *format, ...)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
86 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
87 }
428
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
88 #endif
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
89
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
90 #define LUCAS_STYLE 1
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
91 #define CMF_STYLE 2
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
92 #define MIDI_STYLE 4
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
93 #define SIERRA_STYLE 8
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
94
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
95 // AdLib melodic and rhythm mode defines
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
96 #define ADLIB_MELODIC 0
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
97 #define ADLIB_RYTHM 1
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
98
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
99 // File types
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
100 #define FILE_LUCAS 1
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
101 #define FILE_MIDI 2
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
102 #define FILE_CMF 3
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
103 #define FILE_SIERRA 4
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
104 #define FILE_ADVSIERRA 5
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
105 #define FILE_OLDLUCAS 6
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
106
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
107 // AdLib standard operator table
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
108 const unsigned char CmidPlayer::adlib_opadd[] = {0x00 ,0x01 ,0x02 ,0x08 ,0x09 ,0x0A ,0x10 ,0x11 ,0x12};
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
109
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
110 // dunno
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
111 const int CmidPlayer::ops[] = {0x20,0x20,0x40,0x40,0x60,0x60,0x80,0x80,0xe0,0xe0,0xc0};
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
112
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
113 // map CMF drum channels 12 - 15 to corresponding AdLib drum operators
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
114 // bass drum (channel 11) not mapped, cause it's handled like a normal instrument
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
115 const int CmidPlayer::map_chan[] = { 0x14, 0x12, 0x15, 0x11 };
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
116
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
117 // Standard AdLib frequency table
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
118 const int CmidPlayer::fnums[] = { 0x16b,0x181,0x198,0x1b0,0x1ca,0x1e5,0x202,0x220,0x241,0x263,0x287,0x2ae };
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
119
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
120 // Map CMF drum channels 11 - 15 to corresponding AdLib drum channels
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
121 const int CmidPlayer::percussion_map[] = { 6, 7, 8, 8, 7 };
412
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
122
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
123 CPlayer *CmidPlayer::factory(Copl *newopl)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
124 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
125 return new CmidPlayer(newopl);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
126 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
127
428
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
128 CmidPlayer::CmidPlayer(Copl *newopl)
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
129 : CPlayer(newopl), author(&emptystr), title(&emptystr), remarks(&emptystr),
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
130 emptystr('\0'), flen(0), data(0)
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
131 {
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
132 }
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
133
412
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
134 unsigned char CmidPlayer::datalook(long pos)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
135 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
136 if (pos<0 || pos >= flen) return(0);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
137 return(data[pos]);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
138 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
139
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
140 unsigned long CmidPlayer::getnexti(unsigned long num)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
141 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
142 unsigned long v=0;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
143 unsigned long i;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
144
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
145 for (i=0; i<num; i++)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
146 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
147 v+=(datalook(pos)<<(8*i)); pos++;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
148 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
149 return(v);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
150 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
151
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
152 unsigned long CmidPlayer::getnext(unsigned long num)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
153 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
154 unsigned long v=0;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
155 unsigned long i;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
156
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
157 for (i=0; i<num; i++)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
158 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
159 v<<=8;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
160 v+=datalook(pos); pos++;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
161 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
162 return(v);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
163 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
164
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
165 unsigned long CmidPlayer::getval()
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
166 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
167 int v=0;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
168 unsigned char b;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
169
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
170 b=(unsigned char)getnext(1);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
171 v=b&0x7f;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
172 while ((b&0x80) !=0)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
173 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
174 b=(unsigned char)getnext(1);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
175 v = (v << 7) + (b & 0x7F);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
176 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
177 return(v);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
178 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
179
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
180 bool CmidPlayer::load_sierra_ins(const std::string &fname, const CFileProvider &fp)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
181 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
182 long i,j,k,l;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
183 unsigned char ins[28];
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
184 char *pfilename;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
185 binistream *f;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
186
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
187 pfilename = (char *)malloc(fname.length()+9);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
188 strcpy(pfilename,fname.c_str());
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
189 j=0;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
190 for(i=strlen(pfilename)-1; i >= 0; i--)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
191 if(pfilename[i] == '/' || pfilename[i] == '\\') {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
192 j = i+1;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
193 break;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
194 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
195 sprintf(pfilename+j+3,"patch.003");
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
196
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
197 f = fp.open(pfilename);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
198 free(pfilename);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
199 if(!f) return false;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
200
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
201 f->ignore(2);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
202 stins = 0;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
203 for (i=0; i<2; i++)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
204 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
205 for (k=0; k<48; k++)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
206 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
207 l=i*48+k;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
208 midiprintf ("\n%2d: ",l);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
209 for (j=0; j<28; j++)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
210 ins[j] = f->readInt(1);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
211
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
212 myinsbank[l][0]=
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
213 (ins[9]*0x80) + (ins[10]*0x40) +
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
214 (ins[5]*0x20) + (ins[11]*0x10) +
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
215 ins[1]; //1=ins5
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
216 myinsbank[l][1]=
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
217 (ins[22]*0x80) + (ins[23]*0x40) +
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
218 (ins[18]*0x20) + (ins[24]*0x10) +
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
219 ins[14]; //1=ins18
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
220
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
221 myinsbank[l][2]=(ins[0]<<6)+ins[8];
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
222 myinsbank[l][3]=(ins[13]<<6)+ins[21];
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
223
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
224 myinsbank[l][4]=(ins[3]<<4)+ins[6];
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
225 myinsbank[l][5]=(ins[16]<<4)+ins[19];
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
226 myinsbank[l][6]=(ins[4]<<4)+ins[7];
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
227 myinsbank[l][7]=(ins[17]<<4)+ins[20];
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
228
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
229 myinsbank[l][8]=ins[26];
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
230 myinsbank[l][9]=ins[27];
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
231
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
232 myinsbank[l][10]=((ins[2]<<1))+(1-(ins[12]&1));
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
233 //(ins[12] ? 0:1)+((ins[2]<<1));
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
234
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
235 for (j=0; j<11; j++)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
236 midiprintf ("%02X ",myinsbank[l][j]);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
237 stins++;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
238 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
239 f->ignore(2);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
240 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
241
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
242 fp.close(f);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
243 memcpy(smyinsbank, myinsbank, 128 * 16);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
244 return true;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
245 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
246
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
247 void CmidPlayer::sierra_next_section()
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
248 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
249 int i,j;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
250
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
251 for (i=0; i<16; i++)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
252 track[i].on=0;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
253
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
254 midiprintf("\n\nnext adv sierra section:\n");
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
255
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
256 pos=sierra_pos;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
257 i=0;j=0;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
258 while (i!=0xff)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
259 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
260 getnext(1);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
261 curtrack=j; j++;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
262 track[curtrack].on=1;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
263 track[curtrack].spos = getnext(1);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
264 track[curtrack].spos += (getnext(1) << 8) + 4; //4 best usually +3? not 0,1,2 or 5
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
265 // track[curtrack].spos=getnext(1)+(getnext(1)<<8)+4; // dynamite!: doesn't optimize correctly!!
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
266 track[curtrack].tend=flen; //0xFC will kill it
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
267 track[curtrack].iwait=0;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
268 track[curtrack].pv=0;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
269 midiprintf ("track %d starts at %lx\n",curtrack,track[curtrack].spos);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
270
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
271 getnext(2);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
272 i=getnext(1);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
273 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
274 getnext(2);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
275 deltas=0x20;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
276 sierra_pos=pos;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
277 //getch();
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
278
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
279 fwait=0;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
280 doing=1;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
281 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
282
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
283 bool CmidPlayer::load(const std::string &filename, const CFileProvider &fp)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
284 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
285 binistream *f = fp.open(filename); if(!f) return false;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
286 int good;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
287 unsigned char s[6];
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
288
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
289 f->readString((char *)s, 6);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
290 good=0;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
291 subsongs=0;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
292 switch(s[0])
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
293 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
294 case 'A':
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
295 if (s[1]=='D' && s[2]=='L') good=FILE_LUCAS;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
296 break;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
297 case 'C':
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
298 if (s[1]=='T' && s[2]=='M' && s[3]=='F') good=FILE_CMF;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
299 break;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
300 case 0x84:
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
301 if (s[1]==0x00 && load_sierra_ins(filename, fp))
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
302 if (s[2]==0xf0)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
303 good=FILE_ADVSIERRA;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
304 else
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
305 good=FILE_SIERRA;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
306 break;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
307 default:
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
308 if (s[4]=='A' && s[5]=='D') good=FILE_OLDLUCAS;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
309 break;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
310 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
311
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
312 if (good!=0)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
313 subsongs=1;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
314 else {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
315 fp.close(f);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
316 return false;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
317 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
318
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
319 type=good;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
320 f->seek(0);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
321 flen = fp.filesize(f);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
322 data = new unsigned char [flen];
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
323 f->readString((char *)data, flen);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
324
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
325 fp.close(f);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
326 rewind(0);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
327 return true;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
328 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
329
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
330 void CmidPlayer::midi_write_adlib(unsigned int r, unsigned char v)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
331 {
428
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
332 opl->write(r,v);
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
333 adlib_data[r]=v;
412
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
334 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
335
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
336 void CmidPlayer::midi_fm_instrument(int voice, unsigned char *inst)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
337 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
338 if ((adlib_style&SIERRA_STYLE)!=0)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
339 midi_write_adlib(0xbd,0); //just gotta make sure this happens..
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
340 //'cause who knows when it'll be
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
341 //reset otherwise.
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
342
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
343
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
344 midi_write_adlib(0x20+adlib_opadd[voice],inst[0]);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
345 midi_write_adlib(0x23+adlib_opadd[voice],inst[1]);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
346
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
347 if ((adlib_style&LUCAS_STYLE)!=0)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
348 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
349 midi_write_adlib(0x43+adlib_opadd[voice],0x3f);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
350 if ((inst[10] & 1)==0)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
351 midi_write_adlib(0x40+adlib_opadd[voice],inst[2]);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
352 else
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
353 midi_write_adlib(0x40+adlib_opadd[voice],0x3f);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
354 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
355 else
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
356 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
357 if ((adlib_style&SIERRA_STYLE)!=0)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
358 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
359 midi_write_adlib(0x40+adlib_opadd[voice],inst[2]);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
360 midi_write_adlib(0x43+adlib_opadd[voice],inst[3]);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
361 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
362 else
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
363 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
364 midi_write_adlib(0x40+adlib_opadd[voice],inst[2]);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
365 if ((inst[10] & 1)==0)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
366 midi_write_adlib(0x43+adlib_opadd[voice],inst[3]);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
367 else
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
368 midi_write_adlib(0x43+adlib_opadd[voice],0);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
369 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
370 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
371
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
372 midi_write_adlib(0x60+adlib_opadd[voice],inst[4]);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
373 midi_write_adlib(0x63+adlib_opadd[voice],inst[5]);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
374 midi_write_adlib(0x80+adlib_opadd[voice],inst[6]);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
375 midi_write_adlib(0x83+adlib_opadd[voice],inst[7]);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
376 midi_write_adlib(0xe0+adlib_opadd[voice],inst[8]);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
377 midi_write_adlib(0xe3+adlib_opadd[voice],inst[9]);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
378
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
379 midi_write_adlib(0xc0+voice,inst[10]);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
380 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
381
428
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
382 void CmidPlayer::midi_fm_percussion(int ch, unsigned char *inst)
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
383 {
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
384 int opadd = map_chan[ch - 12];
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
385
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
386 midi_write_adlib(0x20 + opadd, inst[0]);
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
387 midi_write_adlib(0x40 + opadd, inst[2]);
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
388 midi_write_adlib(0x60 + opadd, inst[4]);
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
389 midi_write_adlib(0x80 + opadd, inst[6]);
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
390 midi_write_adlib(0xe0 + opadd, inst[8]);
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
391 midi_write_adlib(0xc0 + opadd, inst[10]);
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
392 }
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
393
412
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
394 void CmidPlayer::midi_fm_volume(int voice, int volume)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
395 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
396 int vol;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
397
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
398 if ((adlib_style&SIERRA_STYLE)==0) //sierra likes it loud!
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
399 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
400 vol=volume>>2;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
401
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
402 if ((adlib_style&LUCAS_STYLE)!=0)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
403 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
404 if ((adlib_data[0xc0+voice]&1)==1)
428
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
405 midi_write_adlib(0x40+adlib_opadd[voice], (unsigned char)((63-vol) |
412
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
406 (adlib_data[0x40+adlib_opadd[voice]]&0xc0)));
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
407 midi_write_adlib(0x43+adlib_opadd[voice], (unsigned char)((63-vol) |
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
408 (adlib_data[0x43+adlib_opadd[voice]]&0xc0)));
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
409 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
410 else
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
411 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
412 if ((adlib_data[0xc0+voice]&1)==1)
428
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
413 midi_write_adlib(0x40+adlib_opadd[voice], (unsigned char)((63-vol) |
412
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
414 (adlib_data[0x40+adlib_opadd[voice]]&0xc0)));
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
415 midi_write_adlib(0x43+adlib_opadd[voice], (unsigned char)((63-vol) |
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
416 (adlib_data[0x43+adlib_opadd[voice]]&0xc0)));
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
417 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
418 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
419 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
420
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
421 void CmidPlayer::midi_fm_playnote(int voice, int note, int volume)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
422 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
423 int freq=fnums[note%12];
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
424 int oct=note/12;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
425 int c;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
426
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
427 midi_fm_volume(voice,volume);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
428 midi_write_adlib(0xa0+voice,(unsigned char)(freq&0xff));
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
429
428
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
430 c=((freq&0x300) >> 8)+(oct<<2) + (adlib_mode == ADLIB_MELODIC || voice < 6 ? (1<<5) : 0);
412
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
431 midi_write_adlib(0xb0+voice,(unsigned char)c);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
432 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
433
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
434 void CmidPlayer::midi_fm_endnote(int voice)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
435 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
436 //midi_fm_volume(voice,0);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
437 //midi_write_adlib(0xb0+voice,0);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
438
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
439 midi_write_adlib(0xb0+voice,(unsigned char)(adlib_data[0xb0+voice]&(255-32)));
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
440 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
441
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
442 void CmidPlayer::midi_fm_reset()
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
443 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
444 int i;
428
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
445
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
446 opl->init();
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
447
412
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
448 for (i=0; i<256; i++)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
449 midi_write_adlib(i,0);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
450
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
451 midi_write_adlib(0x01, 0x20);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
452 midi_write_adlib(0xBD,0xc0);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
453 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
454
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
455 bool CmidPlayer::update()
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
456 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
457 long w,v,note,vel,ctrl,nv,x,l,lnum;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
458 int i=0,j,c;
428
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
459 int on,onl,numchan;
412
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
460 int ret;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
461
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
462 if (doing == 1)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
463 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
464 // just get the first wait and ignore it :>
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
465 for (curtrack=0; curtrack<16; curtrack++)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
466 if (track[curtrack].on)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
467 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
468 pos=track[curtrack].pos;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
469 if (type != FILE_SIERRA && type !=FILE_ADVSIERRA)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
470 track[curtrack].iwait+=getval();
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
471 else
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
472 track[curtrack].iwait+=getnext(1);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
473 track[curtrack].pos=pos;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
474 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
475 doing=0;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
476 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
477
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
478 iwait=0;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
479 ret=1;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
480
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
481 while (iwait==0 && ret==1)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
482 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
483 for (curtrack=0; curtrack<16; curtrack++)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
484 if (track[curtrack].on && track[curtrack].iwait==0 &&
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
485 track[curtrack].pos < track[curtrack].tend)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
486 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
487 pos=track[curtrack].pos;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
488
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
489 v=getnext(1);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
490
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
491 // This is to do implied MIDI events.
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
492 if (v<0x80) {v=track[curtrack].pv; pos--;}
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
493 track[curtrack].pv=(unsigned char)v;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
494
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
495 c=v&0x0f;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
496 midiprintf ("[%2X]",v);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
497 switch(v&0xf0)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
498 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
499 case 0x80: /*note off*/
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
500 note=getnext(1); vel=getnext(1);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
501 for (i=0; i<9; i++)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
502 if (chp[i][0]==c && chp[i][1]==note)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
503 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
504 midi_fm_endnote(i);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
505 chp[i][0]=-1;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
506 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
507 break;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
508 case 0x90: /*note on*/
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
509 // doing=0;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
510 note=getnext(1); vel=getnext(1);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
511
428
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
512 if(adlib_mode == ADLIB_RYTHM)
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
513 numchan = 6;
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
514 else
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
515 numchan = 9;
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
516
412
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
517 if (ch[c].on!=0)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
518 {
428
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
519 for (i=0; i<18; i++)
412
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
520 chp[i][2]++;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
521
428
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
522 if(c < 11 || adlib_mode == ADLIB_MELODIC) {
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
523 j=0;
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
524 on=-1;onl=0;
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
525 for (i=0; i<numchan; i++)
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
526 if (chp[i][0]==-1 && chp[i][2]>onl)
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
527 { onl=chp[i][2]; on=i; j=1; }
412
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
528
428
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
529 if (on==-1)
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
530 {
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
531 onl=0;
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
532 for (i=0; i<numchan; i++)
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
533 if (chp[i][2]>onl)
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
534 { onl=chp[i][2]; on=i; }
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
535 }
412
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
536
428
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
537 if (j==0)
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
538 midi_fm_endnote(on);
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
539 } else
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
540 on = percussion_map[c - 11];
412
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
541
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
542 if (vel!=0 && ch[c].inum>=0 && ch[c].inum<128)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
543 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
544 if (adlib_mode == ADLIB_MELODIC || c < 12)
428
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
545 midi_fm_instrument(on,ch[c].ins);
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
546 else
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
547 midi_fm_percussion(c, ch[c].ins);
412
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
548
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
549 if ((adlib_style&MIDI_STYLE)!=0)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
550 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
551 nv=((ch[c].vol*vel)/128);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
552 if ((adlib_style&LUCAS_STYLE)!=0)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
553 nv*=2;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
554 if (nv>127) nv=127;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
555 nv=my_midi_fm_vol_table[nv];
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
556 if ((adlib_style&LUCAS_STYLE)!=0)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
557 nv=(int)((float)sqrt((float)nv)*11);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
558 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
559 else
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
560 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
561 nv=vel;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
562 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
563
428
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
564 midi_fm_playnote(on,note+ch[c].nshift,nv*2);
412
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
565 chp[on][0]=c;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
566 chp[on][1]=note;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
567 chp[on][2]=0;
428
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
568
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
569 if(adlib_mode == ADLIB_RYTHM && c >= 11) {
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
570 midi_write_adlib(0xbd, adlib_data[0xbd] & ~(0x10 >> (c - 11)));
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
571 midi_write_adlib(0xbd, adlib_data[0xbd] | (0x10 >> (c - 11)));
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
572 }
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
573
412
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
574 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
575 else
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
576 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
577 if (vel==0) //same code as end note
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
578 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
579 for (i=0; i<9; i++)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
580 if (chp[i][0]==c && chp[i][1]==note)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
581 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
582 // midi_fm_volume(i,0); // really end the note
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
583 midi_fm_endnote(i);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
584 chp[i][0]=-1;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
585 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
586 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
587 else
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
588 { // i forget what this is for.
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
589 chp[on][0]=-1;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
590 chp[on][2]=0;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
591 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
592 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
593 midiprintf(" [%d:%d:%d:%d]\n",c,ch[c].inum,note,vel);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
594 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
595 else
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
596 midiprintf ("off");
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
597 break;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
598 case 0xa0: /*key after touch */
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
599 note=getnext(1); vel=getnext(1);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
600 /* //this might all be good
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
601 for (i=0; i<9; i++)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
602 if (chp[i][0]==c & chp[i][1]==note)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
603
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
604 midi_fm_playnote(i,note+cnote[c],my_midi_fm_vol_table[(cvols[c]*vel)/128]*2);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
605 */
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
606 break;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
607 case 0xb0: /*control change .. pitch bend? */
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
608 ctrl=getnext(1); vel=getnext(1);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
609
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
610 switch(ctrl)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
611 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
612 case 0x07:
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
613 midiprintf ("(pb:%d: %d %d)",c,ctrl,vel);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
614 ch[c].vol=vel;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
615 midiprintf("vol");
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
616 break;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
617 case 0x67:
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
618 midiprintf ("\n\nhere:%d\n\n",vel);
428
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
619 if ((adlib_style&CMF_STYLE)!=0) {
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
620 adlib_mode=vel;
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
621 if(adlib_mode == ADLIB_RYTHM)
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
622 midi_write_adlib(0xbd, adlib_data[0xbd] | (1 << 5));
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
623 else
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
624 midi_write_adlib(0xbd, adlib_data[0xbd] & ~(1 << 5));
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
625 }
412
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
626 break;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
627 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
628 break;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
629 case 0xc0: /*patch change*/
428
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
630 x=getnext(1);
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
631 ch[c].inum=x;
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
632 for (j=0; j<11; j++)
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
633 ch[c].ins[j]=myinsbank[ch[c].inum][j];
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
634 break;
412
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
635 case 0xd0: /*chanel touch*/
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
636 x=getnext(1);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
637 break;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
638 case 0xe0: /*pitch wheel*/
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
639 x=getnext(1);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
640 x=getnext(1);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
641 break;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
642 case 0xf0:
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
643 switch(v)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
644 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
645 case 0xf0:
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
646 case 0xf7: /*sysex*/
428
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
647 l=getval();
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
648 if (datalook(pos+l)==0xf7)
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
649 i=1;
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
650 midiprintf("{%d}",l);
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
651 midiprintf("\n");
412
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
652
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
653 if (datalook(pos)==0x7d &&
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
654 datalook(pos+1)==0x10 &&
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
655 datalook(pos+2)<16)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
656 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
657 adlib_style=LUCAS_STYLE|MIDI_STYLE;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
658 for (i=0; i<l; i++)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
659 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
660 midiprintf ("%x ",datalook(pos+i));
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
661 if ((i-3)%10 == 0) midiprintf("\n");
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
662 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
663 midiprintf ("\n");
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
664 getnext(1);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
665 getnext(1);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
666 c=getnext(1);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
667 getnext(1);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
668
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
669 // getnext(22); //temp
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
670 ch[c].ins[0]=(unsigned char)((getnext(1)<<4)+getnext(1));
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
671 ch[c].ins[2]=(unsigned char)(0xff-(((getnext(1)<<4)+getnext(1))&0x3f));
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
672 ch[c].ins[4]=(unsigned char)(0xff-((getnext(1)<<4)+getnext(1)));
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
673 ch[c].ins[6]=(unsigned char)(0xff-((getnext(1)<<4)+getnext(1)));
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
674 ch[c].ins[8]=(unsigned char)((getnext(1)<<4)+getnext(1));
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
675
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
676 ch[c].ins[1]=(unsigned char)((getnext(1)<<4)+getnext(1));
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
677 ch[c].ins[3]=(unsigned char)(0xff-(((getnext(1)<<4)+getnext(1))&0x3f));
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
678 ch[c].ins[5]=(unsigned char)(0xff-((getnext(1)<<4)+getnext(1)));
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
679 ch[c].ins[7]=(unsigned char)(0xff-((getnext(1)<<4)+getnext(1)));
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
680 ch[c].ins[9]=(unsigned char)((getnext(1)<<4)+getnext(1));
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
681
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
682 i=(getnext(1)<<4)+getnext(1);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
683 ch[c].ins[10]=i;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
684
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
685 //if ((i&1)==1) ch[c].ins[10]=1;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
686
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
687 midiprintf ("\n%d: ",c);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
688 for (i=0; i<11; i++)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
689 midiprintf ("%2X ",ch[c].ins[i]);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
690 getnext(l-26);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
691 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
692 else
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
693 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
694 midiprintf("\n");
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
695 for (j=0; j<l; j++)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
696 midiprintf ("%2X ",getnext(1));
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
697 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
698
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
699 midiprintf("\n");
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
700 if(i==1)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
701 getnext(1);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
702 break;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
703 case 0xf1:
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
704 break;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
705 case 0xf2:
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
706 getnext(2);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
707 break;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
708 case 0xf3:
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
709 getnext(1);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
710 break;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
711 case 0xf4:
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
712 break;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
713 case 0xf5:
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
714 break;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
715 case 0xf6: /*something*/
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
716 case 0xf8:
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
717 case 0xfa:
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
718 case 0xfb:
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
719 case 0xfc:
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
720 //this ends the track for sierra.
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
721 if (type == FILE_SIERRA ||
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
722 type == FILE_ADVSIERRA)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
723 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
724 track[curtrack].tend=pos;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
725 midiprintf ("endmark: %ld -- %lx\n",pos,pos);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
726 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
727 break;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
728 case 0xfe:
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
729 break;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
730 case 0xfd:
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
731 break;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
732 case 0xff:
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
733 v=getnext(1);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
734 l=getval();
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
735 midiprintf ("\n");
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
736 midiprintf("{%X_%X}",v,l);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
737 if (v==0x51)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
738 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
739 lnum=getnext(l);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
740 msqtr=lnum; /*set tempo*/
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
741 midiprintf ("(qtr=%ld)",msqtr);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
742 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
743 else
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
744 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
745 for (i=0; i<l; i++)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
746 midiprintf ("%2X ",getnext(1));
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
747 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
748 break;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
749 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
750 break;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
751 default: midiprintf("!",v); /* if we get down here, a error occurred */
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
752 break;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
753 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
754
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
755 if (pos < track[curtrack].tend)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
756 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
757 if (type != FILE_SIERRA && type !=FILE_ADVSIERRA)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
758 w=getval();
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
759 else
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
760 w=getnext(1);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
761 track[curtrack].iwait=w;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
762 /*
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
763 if (w!=0)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
764 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
765 midiprintf("\n<%d>",w);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
766 f =
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
767 ((float)w/(float)deltas)*((float)msqtr/(float)1000000);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
768 if (doing==1) f=0; //not playing yet. don't wait yet
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
769 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
770 */
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
771 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
772 else
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
773 track[curtrack].iwait=0;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
774
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
775 track[curtrack].pos=pos;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
776 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
777
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
778
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
779 ret=0; //end of song.
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
780 iwait=0;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
781 for (curtrack=0; curtrack<16; curtrack++)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
782 if (track[curtrack].on == 1 &&
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
783 track[curtrack].pos < track[curtrack].tend)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
784 ret=1; //not yet..
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
785
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
786 if (ret==1)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
787 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
788 iwait=0xffffff; // bigger than any wait can be!
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
789 for (curtrack=0; curtrack<16; curtrack++)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
790 if (track[curtrack].on == 1 &&
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
791 track[curtrack].pos < track[curtrack].tend &&
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
792 track[curtrack].iwait < iwait)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
793 iwait=track[curtrack].iwait;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
794 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
795 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
796
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
797
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
798 if (iwait !=0 && ret==1)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
799 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
800 for (curtrack=0; curtrack<16; curtrack++)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
801 if (track[curtrack].on)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
802 track[curtrack].iwait-=iwait;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
803
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
804
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
805 fwait=1.0f/(((float)iwait/(float)deltas)*((float)msqtr/(float)1000000));
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
806 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
807 else
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
808 fwait=50; // 1/50th of a second
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
809
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
810 midiprintf ("\n");
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
811 for (i=0; i<16; i++)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
812 if (track[i].on)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
813 if (track[i].pos < track[i].tend)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
814 midiprintf ("<%d>",track[i].iwait);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
815 else
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
816 midiprintf("stop");
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
817
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
818 /*
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
819 if (ret==0 && type==FILE_ADVSIERRA)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
820 if (datalook(sierra_pos-2)!=0xff)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
821 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
822 midiprintf ("next sectoin!");
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
823 sierra_next_section(p);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
824 fwait=50;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
825 ret=1;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
826 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
827 */
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
828
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
829 if(ret)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
830 return true;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
831 else
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
832 return false;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
833 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
834
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
835 float CmidPlayer::getrefresh()
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
836 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
837 return (fwait > 0.01f ? fwait : 0.01f);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
838 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
839
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
840 void CmidPlayer::rewind(int subsong)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
841 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
842 long i,j,n,m,l;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
843 long o_sierra_pos;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
844 unsigned char ins[16];
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
845
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
846 pos=0; tins=0;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
847 adlib_style=MIDI_STYLE|CMF_STYLE;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
848 adlib_mode=ADLIB_MELODIC;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
849 for (i=0; i<128; i++)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
850 for (j=0; j<16; j++)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
851 myinsbank[i][j]=midi_fm_instruments[i][j];
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
852 for (i=0; i<16; i++)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
853 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
854 ch[i].inum=0;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
855 for (j=0; j<11; j++)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
856 ch[i].ins[j]=myinsbank[ch[i].inum][j];
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
857 ch[i].vol=127;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
858 ch[i].nshift=-25;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
859 ch[i].on=1;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
860 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
861
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
862 /* General init */
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
863 for (i=0; i<9; i++)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
864 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
865 chp[i][0]=-1;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
866 chp[i][2]=0;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
867 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
868
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
869 deltas=250; // just a number, not a standard
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
870 msqtr=500000;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
871 fwait=123; // gotta be a small thing.. sorta like nothing
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
872 iwait=0;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
873
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
874 subsongs=1;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
875
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
876 for (i=0; i<16; i++)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
877 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
878 track[i].tend=0;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
879 track[i].spos=0;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
880 track[i].pos=0;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
881 track[i].iwait=0;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
882 track[i].on=0;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
883 track[i].pv=0;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
884 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
885 curtrack=0;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
886
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
887 /* specific to file-type init */
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
888
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
889 pos=0;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
890 i=getnext(1);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
891 switch(type)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
892 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
893 case FILE_LUCAS:
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
894 getnext(24); //skip junk and get to the midi.
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
895 adlib_style=LUCAS_STYLE|MIDI_STYLE;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
896 //note: no break, we go right into midi headers...
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
897 case FILE_MIDI:
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
898 if (type != FILE_LUCAS)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
899 tins=128;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
900 getnext(11); /*skip header*/
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
901 deltas=getnext(2);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
902 midiprintf ("deltas:%ld\n",deltas);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
903 getnext(4);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
904
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
905 curtrack=0;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
906 track[curtrack].on=1;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
907 track[curtrack].tend=getnext(4);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
908 track[curtrack].spos=pos;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
909 midiprintf ("tracklen:%ld\n",track[curtrack].tend);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
910 break;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
911 case FILE_CMF:
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
912 getnext(3); // ctmf
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
913 getnexti(2); //version
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
914 n=getnexti(2); // instrument offset
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
915 m=getnexti(2); // music offset
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
916 deltas=getnexti(2); //ticks/qtr note
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
917 msqtr=1000000/getnexti(2)*deltas;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
918 //the stuff in the cmf is click ticks per second..
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
919
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
920 i=getnexti(2);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
921 if(i) title = (char *)data+i;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
922 i=getnexti(2);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
923 if(i) author = (char *)data+i;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
924 i=getnexti(2);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
925 if(i) remarks = (char *)data+i;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
926
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
927 getnext(16); // channel in use table ..
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
928 i=getnexti(2); // num instr
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
929 if (i>128) i=128; // to ward of bad numbers...
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
930 getnexti(2); //basic tempo
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
931
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
932 midiprintf("\nioff:%d\nmoff%d\ndeltas:%ld\nmsqtr:%ld\nnumi:%d\n",
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
933 n,m,deltas,msqtr,i);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
934 pos=n; // jump to instruments
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
935 tins=i;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
936 for (j=0; j<i; j++)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
937 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
938 midiprintf ("\n%d: ",j);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
939 for (l=0; l<16; l++)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
940 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
941 myinsbank[j][l]=(unsigned char)getnext(1);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
942 midiprintf ("%2X ",myinsbank[j][l]);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
943 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
944 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
945
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
946 for (i=0; i<16; i++)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
947 ch[i].nshift=-13;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
948
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
949 adlib_style=CMF_STYLE;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
950
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
951 curtrack=0;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
952 track[curtrack].on=1;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
953 track[curtrack].tend=flen; // music until the end of the file
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
954 track[curtrack].spos=m; //jump to midi music
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
955 break;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
956 case FILE_OLDLUCAS:
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
957 msqtr=250000;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
958 pos=9;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
959 deltas=getnext(1);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
960
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
961 i=8;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
962 pos=0x19; // jump to instruments
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
963 tins=i;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
964 for (j=0; j<i; j++)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
965 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
966 midiprintf ("\n%d: ",j);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
967 for (l=0; l<16; l++)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
968 ins[l]=(unsigned char)getnext(1);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
969
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
970 myinsbank[j][10]=ins[2];
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
971 myinsbank[j][0]=ins[3];
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
972 myinsbank[j][2]=ins[4];
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
973 myinsbank[j][4]=ins[5];
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
974 myinsbank[j][6]=ins[6];
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
975 myinsbank[j][8]=ins[7];
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
976 myinsbank[j][1]=ins[8];
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
977 myinsbank[j][3]=ins[9];
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
978 myinsbank[j][5]=ins[10];
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
979 myinsbank[j][7]=ins[11];
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
980 myinsbank[j][9]=ins[12];
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
981
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
982 for (l=0; l<11; l++)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
983 midiprintf ("%2X ",myinsbank[j][l]);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
984 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
985
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
986 for (i=0; i<16; i++)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
987 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
988 if (i<tins)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
989 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
990 ch[i].inum=i;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
991 for (j=0; j<11; j++)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
992 ch[i].ins[j]=myinsbank[ch[i].inum][j];
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
993 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
994 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
995
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
996 adlib_style=LUCAS_STYLE|MIDI_STYLE;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
997
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
998 curtrack=0;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
999 track[curtrack].on=1;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1000 track[curtrack].tend=flen; // music until the end of the file
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1001 track[curtrack].spos=0x98; //jump to midi music
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1002 break;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1003 case FILE_ADVSIERRA:
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1004 memcpy(myinsbank, smyinsbank, 128 * 16);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1005 tins = stins;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1006 deltas=0x20;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1007 getnext(11); //worthless empty space and "stuff" :)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1008
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1009 o_sierra_pos=sierra_pos=pos;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1010 sierra_next_section();
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1011 while (datalook(sierra_pos-2)!=0xff)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1012 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1013 sierra_next_section();
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1014 subsongs++;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1015 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1016
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1017 if (subsong < 0 || subsong >= subsongs) subsong=0;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1018
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1019 sierra_pos=o_sierra_pos;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1020 sierra_next_section();
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1021 i=0;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1022 while (i != subsong)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1023 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1024 sierra_next_section();
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1025 i++;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1026 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1027
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1028 adlib_style=SIERRA_STYLE|MIDI_STYLE; //advanced sierra tunes use volume
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1029 break;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1030 case FILE_SIERRA:
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1031 memcpy(myinsbank, smyinsbank, 128 * 16);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1032 tins = stins;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1033 getnext(2);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1034 deltas=0x20;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1035
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1036 curtrack=0;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1037 track[curtrack].on=1;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1038 track[curtrack].tend=flen; // music until the end of the file
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1039
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1040 for (i=0; i<16; i++)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1041 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1042 ch[i].nshift=-13;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1043 ch[i].on=getnext(1);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1044 ch[i].inum=getnext(1);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1045 for (j=0; j<11; j++)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1046 ch[i].ins[j]=myinsbank[ch[i].inum][j];
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1047 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1048
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1049 track[curtrack].spos=pos;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1050 adlib_style=SIERRA_STYLE|MIDI_STYLE;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1051 break;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1052 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1053
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1054
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1055 /* sprintf(info,"%s\r\nTicks/Quarter Note: %ld\r\n",info,deltas);
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1056 sprintf(info,"%sms/Quarter Note: %ld",info,msqtr); */
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1057
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1058 for (i=0; i<16; i++)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1059 if (track[i].on)
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1060 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1061 track[i].pos=track[i].spos;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1062 track[i].pv=0;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1063 track[i].iwait=0;
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1064 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1065
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1066 doing=1;
428
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents: 412
diff changeset
1067 midi_fm_reset();
412
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1068 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1069
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1070 std::string CmidPlayer::gettype()
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1071 {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1072 switch(type) {
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1073 case FILE_LUCAS:
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1074 return std::string("LucasArts AdLib MIDI");
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1075 case FILE_MIDI:
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1076 return std::string("General MIDI");
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1077 case FILE_CMF:
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1078 return std::string("Creative Music Format (CMF MIDI)");
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1079 case FILE_OLDLUCAS:
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1080 return std::string("Lucasfilm Adlib MIDI");
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1081 case FILE_ADVSIERRA:
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1082 return std::string("Sierra On-Line VGA MIDI");
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1083 case FILE_SIERRA:
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1084 return std::string("Sierra On-Line EGA MIDI");
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1085 default:
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1086 return std::string("MIDI unknown");
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1087 }
451d2dc68ba8 [svn] Support .cmf .sci & .laa without stealing .mid from timidity.
chainsaw
parents:
diff changeset
1088 }