annotate Plugins/Input/adplug/core/temuopl.cpp @ 919:c19c3ea7d29d trunk

[svn] - fading fix
author nenolod
date Thu, 06 Apr 2006 11:03:26 -0700
parents 15ca2ea93a30
children f12d7e208b43
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
1 /*
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
2 * AdPlug - Replayer for many OPL2/OPL3 audio file formats.
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
3 * Copyright (C) 1999 - 2004 Simon Peter <dn.tlp@gmx.net>, et al.
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
4 *
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
5 * This library is free software; you can redistribute it and/or
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
6 * modify it under the terms of the GNU Lesser General Public
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
7 * License as published by the Free Software Foundation; either
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
8 * version 2.1 of the License, or (at your option) any later version.
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
9 *
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
10 * This library is distributed in the hope that it will be useful,
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
13 * Lesser General Public License for more details.
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
14 *
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
15 * You should have received a copy of the GNU Lesser General Public
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
16 * License along with this library; if not, write to the Free Software
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
18 *
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
19 * temuopl.cpp - Tatsuyuki Satoh's OPL2 emulator, by Simon Peter <dn.tlp@gmx.net>
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
20 */
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
21
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
22 #include "temuopl.h"
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
23
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
24 CTemuopl::CTemuopl(int rate, bool bit16, bool usestereo)
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
25 : use16bit(bit16), stereo(usestereo)
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
26 {
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
27 opl = OPLCreate(OPL_TYPE_YM3812, 3579545, rate);
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
28 }
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
29
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
30 CTemuopl::~CTemuopl()
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
31 {
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
32 OPLDestroy(opl);
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
33 }
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
34
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
35 void CTemuopl::update(short *buf, int samples)
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
36 {
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
37 int i;
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
38
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
39 if(use16bit) {
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
40 YM3812UpdateOne(opl,buf,samples);
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
41
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
42 if(stereo)
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
43 for(i=samples-1;i>=0;i--) {
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
44 buf[i*2] = buf[i];
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
45 buf[i*2+1] = buf[i];
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
46 }
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
47 } else {
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
48 short *tempbuf = new short[stereo ? samples*2 : samples];
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
49 int i;
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
50
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
51 YM3812UpdateOne(opl,tempbuf,samples);
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
52
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
53 if(stereo)
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
54 for(i=samples-1;i>=0;i--) {
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
55 tempbuf[i*2] = tempbuf[i];
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
56 tempbuf[i*2+1] = tempbuf[i];
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
57 }
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
58
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
59 for(i=0;i<(stereo ? samples*2 : samples);i++)
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
60 ((char *)buf)[i] = (tempbuf[i] >> 8) ^ 0x80;
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
61
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
62 delete [] tempbuf;
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
63 }
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
64 }
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
65
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
66 void CTemuopl::write(int reg, int val)
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
67 {
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
68 OPLWrite(opl,0,reg);
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
69 OPLWrite(opl,1,val);
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
70 }
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
71
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
72 void CTemuopl::init()
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
73 {
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
74 OPLResetChip(opl);
15ca2ea93a30 [svn] Sync with upstream CVS. This implements RIX playback.
chainsaw
parents:
diff changeset
75 }