comparison src/adplug/core/temuopl.cxx @ 955:4709ce4e209e trunk

[svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
author chainsaw
date Sat, 14 Apr 2007 15:23:50 -0700
parents 48ebfc711a8c
children
comparison
equal deleted inserted replaced
954:d7a6fd179cd2 955:4709ce4e209e
19 * temuopl.cpp - Tatsuyuki Satoh's OPL2 emulator, by Simon Peter <dn.tlp@gmx.net> 19 * temuopl.cpp - Tatsuyuki Satoh's OPL2 emulator, by Simon Peter <dn.tlp@gmx.net>
20 */ 20 */
21 21
22 #include "temuopl.h" 22 #include "temuopl.h"
23 23
24 CTemuopl::CTemuopl(int rate, bool bit16, bool usestereo) 24 CTemuopl::CTemuopl (int rate, bool bit16, bool usestereo):
25 : use16bit(bit16), stereo(usestereo) 25 use16bit (bit16),
26 stereo (usestereo)
26 { 27 {
27 opl = OPLCreate(OPL_TYPE_YM3812, 3579545, rate); 28 opl = OPLCreate (OPL_TYPE_YM3812, 3579545, rate);
28 } 29 }
29 30
30 CTemuopl::~CTemuopl() 31 CTemuopl::~CTemuopl ()
31 { 32 {
32 OPLDestroy(opl); 33 OPLDestroy (opl);
33 } 34 }
34 35
35 void CTemuopl::update(short *buf, int samples) 36 void
37 CTemuopl::update (short *buf, int samples)
36 { 38 {
37 int i; 39 int i;
38 40
39 if(use16bit) { 41 if (use16bit)
40 YM3812UpdateOne(opl,buf,samples); 42 {
43 YM3812UpdateOne (opl, buf, samples);
41 44
42 if(stereo) 45 if (stereo)
43 for(i=samples-1;i>=0;i--) { 46 for (i = samples - 1; i >= 0; i--)
44 buf[i*2] = buf[i]; 47 {
45 buf[i*2+1] = buf[i]; 48 buf[i * 2] = buf[i];
49 buf[i * 2 + 1] = buf[i];
46 } 50 }
47 } else { 51 }
48 short *tempbuf = new short[stereo ? samples*2 : samples]; 52 else
53 {
54 short *tempbuf = new short[stereo ? samples * 2 : samples];
49 int i; 55 int i;
50 56
51 YM3812UpdateOne(opl,tempbuf,samples); 57 YM3812UpdateOne (opl, tempbuf, samples);
52 58
53 if(stereo) 59 if (stereo)
54 for(i=samples-1;i>=0;i--) { 60 for (i = samples - 1; i >= 0; i--)
55 tempbuf[i*2] = tempbuf[i]; 61 {
56 tempbuf[i*2+1] = tempbuf[i]; 62 tempbuf[i * 2] = tempbuf[i];
63 tempbuf[i * 2 + 1] = tempbuf[i];
57 } 64 }
58 65
59 for(i=0;i<(stereo ? samples*2 : samples);i++) 66 for (i = 0; i < (stereo ? samples * 2 : samples); i++)
60 ((char *)buf)[i] = (tempbuf[i] >> 8) ^ 0x80; 67 ((char *) buf)[i] = (tempbuf[i] >> 8) ^ 0x80;
61 68
62 delete [] tempbuf; tempbuf = 0; 69 delete[]tempbuf;
70 tempbuf = 0;
63 } 71 }
64 } 72 }
65 73
66 void CTemuopl::write(int reg, int val) 74 void
75 CTemuopl::write (int reg, int val)
67 { 76 {
68 OPLWrite(opl,0,reg); 77 OPLWrite (opl, 0, reg);
69 OPLWrite(opl,1,val); 78 OPLWrite (opl, 1, val);
70 } 79 }
71 80
72 void CTemuopl::init() 81 void
82 CTemuopl::init ()
73 { 83 {
74 OPLResetChip(opl); 84 OPLResetChip (opl);
75 } 85 }