Improve CD-Audio w/ volume/fade support; put error messages in client when invalid system card selected
This commit is contained in:
parent
a731504e5b
commit
afaf5879f6
|
@ -477,7 +477,7 @@ throw new Exception("requesting 0 sectors read.............................");
|
|||
Console.WriteLine("STOP MODE 2 ENGAGED, BUT NOTE. IRQ WILL NOT FIRE YET.");
|
||||
pce.CDAudio.PlayStartingAtLba(audioStartLBA);
|
||||
pce.CDAudio.EndLBA = audioEndLBA;
|
||||
pce.CDAudio.PlayMode = CDAudio.PlaybackMode.IRQOnCompletion;
|
||||
pce.CDAudio.PlayMode = CDAudio.PlaybackMode.CallbackOnCompletion;
|
||||
break;
|
||||
case 3: // Play normal
|
||||
Console.WriteLine("*** SET END POS, IN PLAY NORMAL MODE? STARTING AT _START_ POS. IS THAT RIGHT?");
|
||||
|
|
|
@ -121,7 +121,8 @@ namespace BizHawk.Emulation.Consoles.TurboGrafx
|
|||
case 0x180B: // ADPCM DMA Control
|
||||
CdIoPorts[0x0B] = value;
|
||||
Log.Error("CD", "Write to ADPCM DMA Control [B] {0:X2}", value);
|
||||
// TODO... there is DMA to be done
|
||||
if (AdpcmCdDmaRequested)
|
||||
Console.WriteLine(" ADPCM DMA REQUESTED");
|
||||
break;
|
||||
|
||||
case 0x180D: // ADPCM Address Control
|
||||
|
@ -131,13 +132,32 @@ namespace BizHawk.Emulation.Consoles.TurboGrafx
|
|||
|
||||
case 0x180E: // ADPCM Playback Rate
|
||||
CdIoPorts[0x0E] = value;
|
||||
Log.Error("CD", "Write to ADPCM Address Control [E] {0:X2}", value);
|
||||
Log.Error("CD", "Write to ADPCM Sample Rate [E] {0:X2}", value);
|
||||
break;
|
||||
|
||||
case 0x180F: // Audio Fade Timer
|
||||
CdIoPorts[0x0F] = value;
|
||||
Log.Error("CD", "Write to CD Audio fade timer [F] {0:X2}", value);
|
||||
// TODO: hook this up to audio system. and to your mother
|
||||
// TODO ADPCM fades/vol control also.
|
||||
|
||||
switch (value)
|
||||
{
|
||||
case 0:
|
||||
CDAudio.LogicalVolume = 100;
|
||||
break;
|
||||
|
||||
case 8:
|
||||
case 9:
|
||||
if (CDAudio.FadeOutFramesRemaining == 0)
|
||||
CDAudio.FadeOut(360); // 6 seconds
|
||||
break;
|
||||
|
||||
case 12:
|
||||
case 13:
|
||||
if (CDAudio.FadeOutFramesRemaining == 0)
|
||||
CDAudio.FadeOut(120); // 2 seconds
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -116,7 +116,7 @@ namespace BizHawk
|
|||
return new GameInfo(cgi);
|
||||
|
||||
// rom is not in database. make some best-guesses
|
||||
var Game = new GameInfo { Hash = hash, Status = RomStatus.NotInDatabase };
|
||||
var Game = new GameInfo { Hash = hash, Status = RomStatus.NotInDatabase, NotInDatabase = true };
|
||||
Console.WriteLine("Game was not in DB. CRC: {0:X8} MD5: {1}",
|
||||
CRC32.Calculate(RomData),
|
||||
Util.BytesToHexString(System.Security.Cryptography.MD5.Create().ComputeHash(RomData)));
|
||||
|
|
|
@ -21,11 +21,13 @@ namespace BizHawk.Emulation.Sound
|
|||
public enum PlaybackMode
|
||||
{
|
||||
StopOnCompletion,
|
||||
IRQOnCompletion,
|
||||
LoopOnCompletion,
|
||||
NextTrackOnCompletion
|
||||
NextTrackOnCompletion,
|
||||
LoopOnCompletion,
|
||||
CallbackOnCompletion
|
||||
}
|
||||
|
||||
public Action CallbackAction = delegate { };
|
||||
|
||||
public Disc Disc;
|
||||
public CDAudioMode Mode = CDAudioMode.Stopped;
|
||||
public PlaybackMode PlayMode = PlaybackMode.LoopOnCompletion;
|
||||
|
@ -40,6 +42,9 @@ namespace BizHawk.Emulation.Sound
|
|||
private int CachedSector;
|
||||
private byte[] SectorCache = new byte[2352];
|
||||
|
||||
public int FadeOutOverFrames = 0;
|
||||
public int FadeOutFramesRemaining = 0;
|
||||
|
||||
public CDAudio(Disc disc, int maxVolume)
|
||||
{
|
||||
Disc = disc;
|
||||
|
@ -57,6 +62,9 @@ namespace BizHawk.Emulation.Sound
|
|||
CurrentSector = StartLBA;
|
||||
SectorOffset = 0;
|
||||
Mode = CDAudioMode.Playing;
|
||||
FadeOutOverFrames = 0;
|
||||
FadeOutFramesRemaining = 0;
|
||||
LogicalVolume = 100;
|
||||
}
|
||||
|
||||
public void PlayStartingAtLba(int lba)
|
||||
|
@ -69,11 +77,17 @@ namespace BizHawk.Emulation.Sound
|
|||
CurrentSector = StartLBA;
|
||||
SectorOffset = 0;
|
||||
Mode = CDAudioMode.Playing;
|
||||
FadeOutOverFrames = 0;
|
||||
FadeOutFramesRemaining = 0;
|
||||
LogicalVolume = 100;
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
Mode = CDAudioMode.Stopped;
|
||||
FadeOutOverFrames = 0;
|
||||
FadeOutFramesRemaining = 0;
|
||||
LogicalVolume = 100;
|
||||
}
|
||||
|
||||
public void Pause()
|
||||
|
@ -81,6 +95,9 @@ namespace BizHawk.Emulation.Sound
|
|||
if (Mode != CDAudioMode.Playing)
|
||||
return;
|
||||
Mode = CDAudioMode.Paused;
|
||||
FadeOutOverFrames = 0;
|
||||
FadeOutFramesRemaining = 0;
|
||||
LogicalVolume = 100;
|
||||
}
|
||||
|
||||
public void Resume()
|
||||
|
@ -97,6 +114,12 @@ namespace BizHawk.Emulation.Sound
|
|||
else if (Mode == CDAudioMode.Stopped) return;
|
||||
}
|
||||
|
||||
public void FadeOut(int frames)
|
||||
{
|
||||
FadeOutOverFrames = frames;
|
||||
FadeOutFramesRemaining = frames;
|
||||
}
|
||||
|
||||
private void EnsureSector()
|
||||
{
|
||||
if (CachedSector != CurrentSector)
|
||||
|
@ -111,6 +134,12 @@ namespace BizHawk.Emulation.Sound
|
|||
if (Mode != CDAudioMode.Playing)
|
||||
return;
|
||||
|
||||
if (FadeOutFramesRemaining > 0)
|
||||
{
|
||||
FadeOutFramesRemaining--;
|
||||
LogicalVolume = FadeOutFramesRemaining * 100 / FadeOutOverFrames;
|
||||
}
|
||||
|
||||
EnsureSector();
|
||||
|
||||
int sampleLen = samples.Length / 2;
|
||||
|
@ -118,21 +147,45 @@ namespace BizHawk.Emulation.Sound
|
|||
for (int s = 0; s < sampleLen; s++)
|
||||
{
|
||||
int sectorOffset = SectorOffset * 4;
|
||||
samples[offset++] += (short)((SectorCache[sectorOffset + 1] << 8) | (SectorCache[sectorOffset + 0]));
|
||||
samples[offset++] += (short)((SectorCache[sectorOffset + 3] << 8) | (SectorCache[sectorOffset + 2]));
|
||||
short left = (short)((SectorCache[sectorOffset + 1] << 8) | (SectorCache[sectorOffset + 0]));
|
||||
short right = (short)((SectorCache[sectorOffset + 3] << 8) | (SectorCache[sectorOffset + 2]));
|
||||
|
||||
// TODO absolute volume (for setting relative volumes between sound sources)
|
||||
|
||||
samples[offset++] += (short) (left * LogicalVolume / 100);
|
||||
samples[offset++] += (short) (right * LogicalVolume / 100);
|
||||
SectorOffset++;
|
||||
// TODO, volume adjustments
|
||||
|
||||
if (SectorOffset == 588)
|
||||
{
|
||||
CurrentSector++;
|
||||
SectorOffset = 0;
|
||||
EnsureSector();
|
||||
}
|
||||
|
||||
if (CurrentSector == EndLBA)
|
||||
{
|
||||
// TODO... end-playback-area logic
|
||||
if (CurrentSector == EndLBA)
|
||||
{
|
||||
switch (PlayMode)
|
||||
{
|
||||
case PlaybackMode.NextTrackOnCompletion:
|
||||
PlayTrack(PlayingTrack + 1);
|
||||
break;
|
||||
|
||||
case PlaybackMode.StopOnCompletion:
|
||||
Stop();
|
||||
return;
|
||||
|
||||
case PlaybackMode.LoopOnCompletion:
|
||||
CurrentSector = StartLBA;
|
||||
break;
|
||||
|
||||
case PlaybackMode.CallbackOnCompletion:
|
||||
CallbackAction();
|
||||
if (Mode != CDAudioMode.Playing)
|
||||
return;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
EnsureSector();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -141,12 +194,12 @@ namespace BizHawk.Emulation.Sound
|
|||
{
|
||||
get
|
||||
{
|
||||
// TODO apply the damn volume
|
||||
if (Mode != CDAudioMode.Playing)
|
||||
return 0;
|
||||
|
||||
int offset = SectorOffset * 4;
|
||||
return (short)((SectorCache[offset + 1] << 8) | (SectorCache[offset + 0]));
|
||||
short sample = (short)((SectorCache[offset + 1] << 8) | (SectorCache[offset + 0]));
|
||||
return (short) (sample * LogicalVolume / 100);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -159,7 +212,8 @@ namespace BizHawk.Emulation.Sound
|
|||
return 0;
|
||||
|
||||
int offset = SectorOffset * 4;
|
||||
return (short)((SectorCache[offset + 3] << 8) | (SectorCache[offset + 2]));
|
||||
short sample = (short) ((SectorCache[offset + 3] << 8) | (SectorCache[offset + 2]));
|
||||
return (short)(sample * LogicalVolume / 100);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -973,6 +973,17 @@ namespace BizHawk.MultiClient
|
|||
return false;
|
||||
}
|
||||
rom = new RomGame(new HawkFile(Global.Config.PathPCEBios));
|
||||
|
||||
if (rom.GameInfo.Status == RomStatus.BadDump)
|
||||
MessageBox.Show("The PCE-CD System Card you have selected is known to be a bad dump. This may cause problems playing PCE-CD games.\n\n"+
|
||||
"It is recommended that you find a good dump of the system card. Sorry to be the bearer of bad news!");
|
||||
|
||||
else if (rom.GameInfo.NotInDatabase)
|
||||
MessageBox.Show("The PCE-CD System Card you have selected is not recognized in our database. That might mean it's a bad dump, or isn't the correct rom.");
|
||||
|
||||
else if (rom.GameInfo["BIOS"] == false)
|
||||
MessageBox.Show("The PCE-CD System Card you have selected is not a BIOS image. You may have selected the wrong rom.");
|
||||
|
||||
if (rom.GameInfo["SuperSysCard"])
|
||||
game.AddOption("SuperSysCard");
|
||||
if ((game["NeedSuperSysCard"]) && game["SuperSysCard"] == false)
|
||||
|
|
|
@ -1583,19 +1583,20 @@ C52D23DE777B1A6ADD4DA0CD559EF1F7 Daimakaimura Sounds SGX
|
|||
|
||||
; ************ TurboCD System Cards ************
|
||||
|
||||
A645A0E7E12AD57C3B34271E6E67590E V CD-ROM System V1.00 (J) [b1] PCE BRAM
|
||||
2B7CCB3D86BAA18F6402C176F3065082 I CD-ROM System V1.00 (J) PCE BRAM
|
||||
4A2A32A17DF3A9199213C8B9E7437E9C H CD-ROM System V2.00 (J) (reports V1) [h1] PCE BRAM
|
||||
3A456F0ECCFF039EB5FF045F56EC1C3B V CD-ROM System V2.00 (J) PCE BRAM
|
||||
94279F315E8B52904F65AB3108542AFE I CD-ROM System V2.00 (U) PCE BRAM
|
||||
FFD159AF6240051B15867476B6A9B808 I CD-ROM System V2.01 (U) PCE BRAM
|
||||
F544FEE6DCD0162A40C2C612DF360B2D H CD-ROM System V2.10 (J) (reports V1) [h1] PCE BRAM
|
||||
34C93E053615758218FAC19A3900723E V CD-ROM System V2.10 (J) [b1] PCE BRAM
|
||||
3CDD6614A918616BFC41C862E889DD79 I CD-ROM System V2.10 (J) PCE BRAM
|
||||
FC3D75364EF8CCCB4FA6B633E4BD5258 V Super CD-ROM2 System V3.00 (J) [o1] PCE BRAM;SuperSysCard
|
||||
CB65B86FAABF0F4717CF8C84230B187C V Super CD-ROM2 System V3.00 (J) [o2] PCE BRAM;SuperSysCard
|
||||
0FD6A4CFD78F2242025370D39AA3F287 V Super CD-ROM2 System V3.00 (J) [o3] PCE BRAM;SuperSysCard
|
||||
D3A12A001E22EFB1436EC509D453A10F V Super CD-ROM2 System V3.00 (J) [o4] PCE BRAM;SuperSysCard
|
||||
38179DF8F4AC870017DB21EBCBF53114 I Super CD-ROM2 System V3.00 (J) PCE BRAM;SuperSysCard
|
||||
0754F903B52E3B3342202BDAFB13EFA5 I Super CD-ROM2 System V3.00 (U) PCE BRAM;SuperSysCard
|
||||
98D43A097A165B03DF170FD5C2AD2C2F I Super CD-ROM2 System V3.01 (U) PCE BRAM;SuperSysCard
|
||||
A645A0E7E12AD57C3B34271E6E67590E V CD-ROM System V1.00 (J) [b1] PCE BRAM;BIOS
|
||||
2B7CCB3D86BAA18F6402C176F3065082 I CD-ROM System V1.00 (J) PCE BRAM;BIOS
|
||||
4A2A32A17DF3A9199213C8B9E7437E9C H CD-ROM System V2.00 (J) (reports V1) [h1] PCE BRAM;BIOS
|
||||
3A456F0ECCFF039EB5FF045F56EC1C3B V CD-ROM System V2.00 (J) PCE BRAM;BIOS
|
||||
94279F315E8B52904F65AB3108542AFE I CD-ROM System V2.00 (U) PCE BRAM;BIOS
|
||||
FFD159AF6240051B15867476B6A9B808 I CD-ROM System V2.01 (U) PCE BRAM;BIOS
|
||||
F544FEE6DCD0162A40C2C612DF360B2D H CD-ROM System V2.10 (J) (reports V1) [h1] PCE BRAM;BIOS
|
||||
34C93E053615758218FAC19A3900723E V CD-ROM System V2.10 (J) [b1] PCE BRAM;BIOS
|
||||
3CDD6614A918616BFC41C862E889DD79 I CD-ROM System V2.10 (J) PCE BRAM;BIOS
|
||||
FC3D75364EF8CCCB4FA6B633E4BD5258 V Super CD-ROM2 System V3.00 (J) [o1] PCE BRAM;SuperSysCard;BIOS
|
||||
CB65B86FAABF0F4717CF8C84230B187C V Super CD-ROM2 System V3.00 (J) [o2] PCE BRAM;SuperSysCard;BIOS
|
||||
0FD6A4CFD78F2242025370D39AA3F287 V Super CD-ROM2 System V3.00 (J) [o3] PCE BRAM;SuperSysCard;BIOS
|
||||
D3A12A001E22EFB1436EC509D453A10F V Super CD-ROM2 System V3.00 (J) [o4] PCE BRAM;SuperSysCard;BIOS
|
||||
38179DF8F4AC870017DB21EBCBF53114 I Super CD-ROM2 System V3.00 (J) PCE BRAM;SuperSysCard;BIOS
|
||||
0754F903B52E3B3342202BDAFB13EFA5 I Super CD-ROM2 System V3.00 (U) PCE BRAM;SuperSysCard;BIOS
|
||||
98D43A097A165B03DF170FD5C2AD2C2F V Super CD-ROM2 System V3.01 (U) [b1] PCE BRAM;SuperSysCard;BIOS
|
||||
|
||||
|
|
Loading…
Reference in New Issue