parent
91f36bf638
commit
3f3828455c
|
@ -16,7 +16,7 @@ namespace BizHawk.Emulation.Cores.Intellivision
|
||||||
|
|
||||||
public ISyncSoundProvider SyncSoundProvider
|
public ISyncSoundProvider SyncSoundProvider
|
||||||
{
|
{
|
||||||
get { return new FakeSyncSound(_dcfilter, 3733); }
|
get { return new FakeSyncSound(_dcfilter, 735); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool StartAsyncSound()
|
public bool StartAsyncSound()
|
||||||
|
@ -70,7 +70,7 @@ namespace BizHawk.Emulation.Cores.Intellivision
|
||||||
while (_cpu.GetPendingCycles() > 0)
|
while (_cpu.GetPendingCycles() > 0)
|
||||||
{
|
{
|
||||||
int cycles = _cpu.Execute();
|
int cycles = _cpu.Execute();
|
||||||
_psg.generate_sound(cycles);
|
//_psg.generate_sound(cycles);
|
||||||
Connect();
|
Connect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,11 +11,14 @@ namespace BizHawk.Emulation.Cores.Intellivision
|
||||||
|
|
||||||
public void Reset()
|
public void Reset()
|
||||||
{
|
{
|
||||||
// reset audio if needed later
|
sq_per_A = sq_per_B = sq_per_C = 0x1000;
|
||||||
|
noise_per = 64;
|
||||||
|
env_per = 0x20000;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DiscardSamples()
|
public void DiscardSamples()
|
||||||
{
|
{
|
||||||
|
|
||||||
sample_count = 0;
|
sample_count = 0;
|
||||||
|
|
||||||
for (int i = 0; i < 3733; i++)
|
for (int i = 0; i < 3733; i++)
|
||||||
|
@ -28,7 +31,9 @@ namespace BizHawk.Emulation.Cores.Intellivision
|
||||||
{
|
{
|
||||||
for (int i = 0; i < samples.Length / 2; i++)
|
for (int i = 0; i < samples.Length / 2; i++)
|
||||||
{
|
{
|
||||||
samples[i * 2] = audio_samples[i];
|
//smooth out audio sample by averging
|
||||||
|
samples[i * 2] = (short)(audio_samples[(int)Math.Floor(3.7904 * i)]);
|
||||||
|
|
||||||
samples[(i * 2) + 1] = samples[i * 2];
|
samples[(i * 2) + 1] = samples[i * 2];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +52,6 @@ namespace BizHawk.Emulation.Cores.Intellivision
|
||||||
public int PendingCycles;
|
public int PendingCycles;
|
||||||
|
|
||||||
public int psg_clock;
|
public int psg_clock;
|
||||||
public int psg_noise;
|
|
||||||
|
|
||||||
public int sq_per_A, sq_per_B, sq_per_C;
|
public int sq_per_A, sq_per_B, sq_per_C;
|
||||||
public int clock_A, clock_B, clock_C;
|
public int clock_A, clock_B, clock_C;
|
||||||
|
@ -76,6 +80,19 @@ namespace BizHawk.Emulation.Cores.Intellivision
|
||||||
ser.Sync("Toal_executed_cycles", ref TotalExecutedCycles);
|
ser.Sync("Toal_executed_cycles", ref TotalExecutedCycles);
|
||||||
ser.Sync("Pending Cycles", ref PendingCycles);
|
ser.Sync("Pending Cycles", ref PendingCycles);
|
||||||
|
|
||||||
|
ser.Sync("sample_count", ref sample_count);
|
||||||
|
ser.Sync("psg_clock", ref psg_clock);
|
||||||
|
ser.Sync("clock_A", ref clock_A);
|
||||||
|
ser.Sync("clock_B", ref clock_B);
|
||||||
|
ser.Sync("clock_C", ref clock_C);
|
||||||
|
ser.Sync("noise clock", ref noise_clock);
|
||||||
|
ser.Sync("A_up", ref A_up);
|
||||||
|
ser.Sync("B_up", ref B_up);
|
||||||
|
ser.Sync("C_up", ref C_up);
|
||||||
|
ser.Sync("noise", ref noise);
|
||||||
|
|
||||||
|
sync_psg_state();
|
||||||
|
|
||||||
ser.EndSection();
|
ser.EndSection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,74 +105,52 @@ namespace BizHawk.Emulation.Cores.Intellivision
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool WritePSG(ushort addr, ushort value)
|
public void sync_psg_state()
|
||||||
{
|
|
||||||
if (addr >= 0x01F0 && addr <= 0x01FF)
|
|
||||||
{
|
|
||||||
Register[addr - 0x01F0] = value;
|
|
||||||
var reg = addr - 0x01F0;
|
|
||||||
if (reg==0 || reg==4)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
sq_per_A = (Register[0] & 0xFF) | (((Register[4] & 0xF) << 8));
|
sq_per_A = (Register[0] & 0xFF) | (((Register[4] & 0xF) << 8));
|
||||||
if (sq_per_A == 0)
|
if (sq_per_A == 0)
|
||||||
sq_per_A = 0x1000;
|
sq_per_A = 0x1000;
|
||||||
else
|
//else
|
||||||
sq_per_A *= 2;
|
//sq_per_A *= 2;
|
||||||
//clock_A = 0;
|
//clock_A = 0;
|
||||||
}
|
|
||||||
if (reg == 1 || reg == 5)
|
|
||||||
{
|
|
||||||
sq_per_B = (Register[1] & 0xFF) | (((Register[5] & 0xF) << 8));
|
sq_per_B = (Register[1] & 0xFF) | (((Register[5] & 0xF) << 8));
|
||||||
if (sq_per_B == 0)
|
if (sq_per_B == 0)
|
||||||
sq_per_B = 0x1000;
|
sq_per_B = 0x1000;
|
||||||
else
|
//else
|
||||||
sq_per_B *= 2;
|
//sq_per_B *= 2;
|
||||||
//clock_B = 0;
|
//clock_B = 0;
|
||||||
}
|
|
||||||
if (reg == 2 || reg == 6)
|
|
||||||
{
|
|
||||||
sq_per_C = (Register[2] & 0xFF) | (((Register[6] & 0xF) << 8));
|
sq_per_C = (Register[2] & 0xFF) | (((Register[6] & 0xF) << 8));
|
||||||
if (sq_per_C == 0)
|
if (sq_per_C == 0)
|
||||||
sq_per_C = 0x1000;
|
sq_per_C = 0x1000;
|
||||||
else
|
//else
|
||||||
sq_per_C *= 2;
|
//sq_per_C *= 2;
|
||||||
//clock_C = 0;
|
//clock_C = 0;
|
||||||
}
|
|
||||||
if (reg == 3 || reg == 7)
|
|
||||||
{
|
|
||||||
env_per = (Register[3] & 0xFF) | (((Register[7] & 0xFF) << 8));
|
env_per = (Register[3] & 0xFF) | (((Register[7] & 0xFF) << 8));
|
||||||
if (env_per == 0)
|
if (env_per == 0)
|
||||||
env_per = 0x20000;
|
env_per = 0x20000;
|
||||||
else
|
else
|
||||||
env_per *= 2;
|
env_per *= 2;
|
||||||
}
|
|
||||||
|
|
||||||
if (reg==8)
|
|
||||||
{
|
|
||||||
A_on = Register[8].Bit(0);
|
A_on = Register[8].Bit(0);
|
||||||
B_on = Register[8].Bit(1);
|
B_on = Register[8].Bit(1);
|
||||||
C_on = Register[8].Bit(2);
|
C_on = Register[8].Bit(2);
|
||||||
A_noise = Register[8].Bit(3);
|
A_noise = Register[8].Bit(3);
|
||||||
B_noise = Register[8].Bit(4);
|
B_noise = Register[8].Bit(4);
|
||||||
C_noise = Register[8].Bit(5);
|
C_noise = Register[8].Bit(5);
|
||||||
}
|
|
||||||
|
|
||||||
if (reg==9)
|
|
||||||
{
|
|
||||||
noise_per = Register[9] & 0x1F;
|
noise_per = Register[9] & 0x1F;
|
||||||
if (noise_per == 0)
|
if (noise_per == 0)
|
||||||
{
|
{
|
||||||
noise_per = 64;
|
noise_per = 64;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
noise_per *= 2;
|
noise_per *= 2;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (reg==10)
|
|
||||||
{
|
|
||||||
//writing to register 10 resets the envelope
|
|
||||||
env_clock = 0;
|
|
||||||
|
|
||||||
var shape_select = Register[10] & 0xF;
|
var shape_select = Register[10] & 0xF;
|
||||||
|
|
||||||
|
@ -165,26 +160,29 @@ namespace BizHawk.Emulation.Cores.Intellivision
|
||||||
env_shape = 1;
|
env_shape = 1;
|
||||||
else
|
else
|
||||||
env_shape = 2 + (shape_select - 8);
|
env_shape = 2 + (shape_select - 8);
|
||||||
}
|
|
||||||
|
|
||||||
if (reg==11)
|
|
||||||
{
|
|
||||||
vol_A = Register[11] & 0xF;
|
vol_A = Register[11] & 0xF;
|
||||||
env_vol_A = (Register[11] >> 4) & 0x3;
|
env_vol_A = (Register[11] >> 4) & 0x3;
|
||||||
}
|
|
||||||
|
|
||||||
if (reg == 12)
|
|
||||||
{
|
|
||||||
vol_B = Register[12] & 0xF;
|
vol_B = Register[12] & 0xF;
|
||||||
env_vol_B = (Register[12] >> 4) & 0x3;
|
env_vol_B = (Register[12] >> 4) & 0x3;
|
||||||
}
|
|
||||||
|
|
||||||
if (reg == 13)
|
|
||||||
{
|
|
||||||
vol_C = Register[13] & 0xF;
|
vol_C = Register[13] & 0xF;
|
||||||
env_vol_C = (Register[13] >> 4) & 0x3;
|
env_vol_C = (Register[13] >> 4) & 0x3;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool WritePSG(ushort addr, ushort value)
|
||||||
|
{
|
||||||
|
if (addr >= 0x01F0 && addr <= 0x01FF)
|
||||||
|
{
|
||||||
|
Register[addr - 0x01F0] = value;
|
||||||
|
if (addr - 0x01F0 == 10)
|
||||||
|
env_clock = 0;
|
||||||
|
|
||||||
|
sync_psg_state();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -204,9 +202,22 @@ namespace BizHawk.Emulation.Cores.Intellivision
|
||||||
if (psg_clock==4)
|
if (psg_clock==4)
|
||||||
{
|
{
|
||||||
psg_clock = 0;
|
psg_clock = 0;
|
||||||
|
|
||||||
|
if (vol_A!=0)
|
||||||
clock_A++;
|
clock_A++;
|
||||||
|
else if (env_vol_A!=0)
|
||||||
|
clock_A++;
|
||||||
|
|
||||||
|
if (vol_B != 0)
|
||||||
clock_B++;
|
clock_B++;
|
||||||
|
else if (env_vol_B != 0)
|
||||||
|
clock_B++;
|
||||||
|
|
||||||
|
if (vol_C != 0)
|
||||||
clock_C++;
|
clock_C++;
|
||||||
|
else if (env_vol_C != 0)
|
||||||
|
clock_C++;
|
||||||
|
|
||||||
env_clock++;
|
env_clock++;
|
||||||
noise_clock++;
|
noise_clock++;
|
||||||
|
|
||||||
|
@ -217,19 +228,19 @@ namespace BizHawk.Emulation.Cores.Intellivision
|
||||||
noise_clock = 0;
|
noise_clock = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (clock_A >= sq_per_A/2)
|
if (clock_A >= sq_per_A)
|
||||||
{
|
{
|
||||||
A_up = !A_up;
|
A_up = !A_up;
|
||||||
clock_A = 0;
|
clock_A = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (clock_B >= sq_per_B/2)
|
if (clock_B >= sq_per_B)
|
||||||
{
|
{
|
||||||
B_up = !B_up;
|
B_up = !B_up;
|
||||||
clock_B = 0;
|
clock_B = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (clock_C >= sq_per_C/2)
|
if (clock_C >= sq_per_C)
|
||||||
{
|
{
|
||||||
C_up = !C_up;
|
C_up = !C_up;
|
||||||
clock_C = 0;
|
clock_C = 0;
|
||||||
|
|
Loading…
Reference in New Issue