1 // ---------------------------------------------------------------------------
2 // PSG Sound Implementation
3 // Copyright (C) cisc 1997, 1999.
4 // ---------------------------------------------------------------------------
5 // $Id: psg.cpp,v 1.10 2002/05/15 21:38:01 cisc Exp $
9 #include "./psg_ay_3_891x.h"
13 #include "../../fileio.h"
15 PSG_AY_3_891X::PSG_AY_3_891X() : PSG()
20 PSG_AY_3_891X::~PSG_AY_3_891X()
24 bool PSG_AY_3_891X::Init(uint c, uint r)
34 void PSG_AY_3_891X::SetPrescaler(int factor)
36 static const char table[3][2] = { { 6, 4 }, { 3, 2 }, { 2, 1 } };
37 static const uint8 table2[8] = { 108, 77, 71, 67, 62, 44, 8, 5 };
38 if((factor < 0) || (factor >= 3)) return;
39 if(prescale != factor)
42 SetClock(clock / table[factor][1], psgrate);
46 void PSG_AY_3_891X::SetVolume(int volume_l, int volume_r)
48 double base_l = 0x4000 / 3.0 * pow(10.0, volume_l / 40.0);
49 double base_r = 0x4000 / 3.0 * pow(10.0, volume_r / 40.0);
50 //#if defined(HAS_AY_3_8910) || defined(HAS_AY_3_8912)
51 // AY-3-8190/8192 (PSG): 16step
52 for (int i=31; i>=3; i-=2)
54 EmitTableL[i] = EmitTableL[i-1] = int(base_l);
55 EmitTableR[i] = EmitTableR[i-1] = int(base_r);
56 base_l /= 1.189207115;
57 base_l /= 1.189207115;
58 base_r /= 1.189207115;
59 base_r /= 1.189207115;
68 SetChannelMask(~mask);