diff --git a/BizHawk.Emulation/Consoles/PC Engine/ADPCM.cs b/BizHawk.Emulation/Consoles/PC Engine/ADPCM.cs
index 65f966eca5..71e520b738 100644
--- a/BizHawk.Emulation/Consoles/PC Engine/ADPCM.cs
+++ b/BizHawk.Emulation/Consoles/PC Engine/ADPCM.cs
@@ -11,9 +11,13 @@ namespace BizHawk.Emulation.Consoles.TurboGrafx
public ushort adpcm_io_address;
public ushort adpcm_read_address;
public ushort adpcm_write_address;
+ public ushort adpcm_length;
+
+ public long adpcm_read_timer, adpcm_write_timer;
+ public byte adpcm_read_buffer, adpcm_write_buffer;
+ public bool adpcm_read_pending, adpcm_write_pending;
public byte[] ADPCM_RAM;
- public byte adpcm_data_read_buffer;
public void AdpcmControlWrite(byte value)
{
@@ -23,55 +27,62 @@ namespace BizHawk.Emulation.Consoles.TurboGrafx
Log.Note("CD", "Reset ADPCM!");
adpcm_read_address = 0;
adpcm_write_address = 0;
- adpcm_io_address = 0; // ???? does this happen?
+ adpcm_io_address = 0;
}
else if ((value & 8) != 0)
{
adpcm_read_address = adpcm_io_address;
- if ((value & 4) != 0)
- throw new Exception("nibble offset set. BLUH");
+ if ((value & 4) == 0)
+ adpcm_read_address--;
}
- else if ((CdIoPorts[0x0D] & 2) != 0 && (value & 2) != 0)
+ else if ((CdIoPorts[0x0D] & 2) == 0 && (value & 2) != 0)
{
adpcm_write_address = adpcm_io_address;
- if ((value & 1) != 0)
- throw new Exception("nibble offset set. we should probably do something about that.");
-
- Log.Error("CD", "Set ADPCM WRITE ADDRESS = {0:X4}", adpcm_write_address);
+ if ((value & 1) == 0)
+ adpcm_write_address--;
}
}
public void AdpcmDataWrite(byte value)
{
- // TODO this should probably be buffered, but for now we do it instantly
- //Console.WriteLine("ADPCM[{0:X4}] = {1:X2}", adpcm_write_address, value);
- ADPCM_RAM[adpcm_write_address++] = value;
+ adpcm_write_buffer = value;
+ adpcm_write_timer = Cpu.TotalExecutedCycles + 24;
+ adpcm_write_pending = true;
}
public byte AdpcmDataRead()
{
- byte returnValue = adpcm_data_read_buffer;
- adpcm_data_read_buffer = ADPCM_RAM[adpcm_read_address++];
- return returnValue;
+ adpcm_read_pending = true;
+ adpcm_read_timer = Cpu.TotalExecutedCycles + 24;
+ return adpcm_read_buffer;
}
- public bool AdpcmIsPlaying { get { return false; } }
+ public bool AdpcmIsPlaying { get { return false; } }
public bool AdpcmBusyWriting { get { return AdpcmCdDmaRequested; } }
- public bool AdpcmBusyReading { get { return false; } }
+ public bool AdpcmBusyReading { get { return adpcm_read_pending; } }
public void AdpcmThink()
{
+ if (adpcm_read_pending && Cpu.TotalExecutedCycles >= adpcm_read_timer)
+ {
+ adpcm_read_buffer = ADPCM_RAM[adpcm_read_address++];
+ adpcm_read_pending = false;
+ }
+
+ if (adpcm_write_pending && Cpu.TotalExecutedCycles >= adpcm_write_timer)
+ {
+ ADPCM_RAM[adpcm_write_address++] = adpcm_write_buffer;
+ adpcm_write_pending = false;
+ }
+
if (AdpcmCdDmaRequested)
{
//Console.WriteLine("CD->ADPCM dma...");
if (SCSI.REQ && SCSI.IO && !SCSI.CD && !SCSI.ACK)
{
byte dmaByte = SCSI.DataBits;
- if (adpcm_write_address == 0xFFF9)
- adpcm_write_address = 0xFFF9;
- //Console.WriteLine("ADPCM[{0:X4}] = {1:X2}", adpcm_write_address, dmaByte);
ADPCM_RAM[adpcm_write_address++] = dmaByte;
SCSI.ACK = false;
@@ -82,6 +93,7 @@ namespace BizHawk.Emulation.Consoles.TurboGrafx
if (SCSI.DataTransferInProgress == false)
{
CdIoPorts[0x0B] = 0;
+ Console.WriteLine(" ADPCM DMA COMPLETED");
}
}
diff --git a/BizHawk.Emulation/Consoles/PC Engine/TurboCD.cs b/BizHawk.Emulation/Consoles/PC Engine/TurboCD.cs
index 1817ee7528..f9c0845041 100644
--- a/BizHawk.Emulation/Consoles/PC Engine/TurboCD.cs
+++ b/BizHawk.Emulation/Consoles/PC Engine/TurboCD.cs
@@ -105,12 +105,22 @@ namespace BizHawk.Emulation.Consoles.TurboGrafx
case 0x1808: // ADPCM address LSB
adpcm_io_address &= 0xFF00;
adpcm_io_address |= value;
+ if ((CdIoPorts[0x0D] & 0x10) != 0)
+ {
+ Console.WriteLine("doing silly thing");
+ adpcm_length = adpcm_io_address;
+ }
Log.Error("CD", "adpcm address = {0:X4}", adpcm_io_address);
break;
case 0x1809: // ADPCM address MSB
adpcm_io_address &= 0x00FF;
adpcm_io_address |= (ushort)(value << 8);
+ if ((CdIoPorts[0x0D] & 0x10) != 0)
+ {
+ Console.WriteLine("doing silly thing");
+ adpcm_length = adpcm_io_address;
+ }
Log.Error("CD", "adpcm address = {0:X4}", adpcm_io_address);
break;
@@ -228,8 +238,7 @@ namespace BizHawk.Emulation.Consoles.TurboGrafx
return returnValue;
case 0x180A: // ADPCM Memory Read/Write Port
- //Log.Error("CD", "Read ADPCM Data Transfer Control");
- return CdIoPorts[0x0B];
+ return AdpcmDataRead();
case 0x180B: // ADPCM Data Transfer Control
//Log.Error("CD", "Read ADPCM Data Transfer Control");
diff --git a/BizHawk.UnmanagedCore/BizHawk.UnmanagedCore.vcxproj b/BizHawk.UnmanagedCore/BizHawk.UnmanagedCore.vcxproj
index c789464357..0a82bc661c 100644
--- a/BizHawk.UnmanagedCore/BizHawk.UnmanagedCore.vcxproj
+++ b/BizHawk.UnmanagedCore/BizHawk.UnmanagedCore.vcxproj
@@ -36,7 +36,7 @@
- <_ProjectFileVersion>10.0.40219.1
+ <_ProjectFileVersion>10.0.30319.1
$(Configuration)\
$(Configuration)\
$(Configuration)\
diff --git a/PsxHawk.Core/PsxHawk.Core.vcxproj b/PsxHawk.Core/PsxHawk.Core.vcxproj
index 997e4b24ba..2c07e838d6 100644
--- a/PsxHawk.Core/PsxHawk.Core.vcxproj
+++ b/PsxHawk.Core/PsxHawk.Core.vcxproj
@@ -36,7 +36,7 @@
- <_ProjectFileVersion>10.0.40219.1
+ <_ProjectFileVersion>10.0.30319.1
$(Configuration)\
$(Configuration)\
true
@@ -66,10 +66,9 @@
true
- false
+ true
Windows
MachineX86
- $(SolutionDir)\BizHawk.UnmanagedCore\$(ConfigurationName)\BizHawk.UnmanagedCore.lib;%(AdditionalDependencies)
copy $(TargetPath) $(SolutionDir)\BizHawk.MultiClient\output
@@ -95,7 +94,6 @@
true
true
MachineX86
- $(SolutionDir)\BizHawk.UnmanagedCore\$(ConfigurationName)\BizHawk.UnmanagedCore.lib;%(AdditionalDependencies)
copy $(TargetPath) $(SolutionDir)\BizHawk.MultiClient\output
@@ -107,6 +105,12 @@
+
+
+ {1ce74e20-b345-4126-aacb-a21fa23149de}
+ false
+
+