misc cleanups on PCEngine
This commit is contained in:
parent
15a25bdd87
commit
eee0ba69dc
|
@ -267,7 +267,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
return value;
|
||||
}
|
||||
|
||||
void DecodeAdpcmSample()
|
||||
private void DecodeAdpcmSample()
|
||||
{
|
||||
byte sample = ReadNibble();
|
||||
bool positive = (sample & 8) == 0;
|
||||
|
@ -279,7 +279,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
playingSample = AddClamped(playingSample, adjustment, 0, 4095);
|
||||
}
|
||||
|
||||
void AdpcmEmitSample()
|
||||
private void AdpcmEmitSample()
|
||||
{
|
||||
if (AdpcmIsPlaying == false)
|
||||
SoundProvider.Buffer.enqueue_sample(0, 0);
|
||||
|
|
|
@ -7,9 +7,9 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
// The Populous HuCard is the only traditional HuCard to have battery-backed saveRAM
|
||||
// built into it. There is 32k of save-RAM mapped at pages $40 - $44.
|
||||
|
||||
byte[] PopulousRAM;
|
||||
private byte[] PopulousRAM;
|
||||
|
||||
byte ReadMemoryPopulous(int addr)
|
||||
private byte ReadMemoryPopulous(int addr)
|
||||
{
|
||||
if (addr >= 0x80000 && addr < 0x88000)
|
||||
return PopulousRAM[addr & 0x7FFF];
|
||||
|
@ -37,7 +37,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
return 0xFF;
|
||||
}
|
||||
|
||||
void WriteMemoryPopulous(int addr, byte value)
|
||||
private void WriteMemoryPopulous(int addr, byte value)
|
||||
{
|
||||
if (addr >= 0x1F0000 && addr < 0x1F8000) // write RAM.
|
||||
Ram[addr & 0x1FFF] = value;
|
||||
|
|
|
@ -6,13 +6,12 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
{
|
||||
// Street Fighter 2 was a 20-megabit HuCard. The PCE has a maximum 8-megabit addressable ROM space.
|
||||
// Therefore SF2 had a special mapper to make this work.
|
||||
|
||||
byte SF2MapperLatch;
|
||||
private byte SF2MapperLatch;
|
||||
|
||||
// when true, every mapper register write is propogated to the vtable that the CDL uses
|
||||
bool SF2UpdateCDLMappings = false;
|
||||
private bool SF2UpdateCDLMappings = false;
|
||||
|
||||
byte ReadMemorySF2(int addr)
|
||||
private byte ReadMemorySF2(int addr)
|
||||
{
|
||||
if (addr < 0x7FFFF) // read ROM
|
||||
return RomData[addr];
|
||||
|
@ -40,7 +39,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
return 0xFF;
|
||||
}
|
||||
|
||||
void WriteMemorySF2(int addr, byte value)
|
||||
private void WriteMemorySF2(int addr, byte value)
|
||||
{
|
||||
if ((addr & 0x1FFC) == 0x1FF0)
|
||||
{
|
||||
|
|
|
@ -40,7 +40,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
return 0xFF;
|
||||
}
|
||||
|
||||
void WriteMemorySGX(int addr, byte value)
|
||||
private void WriteMemorySGX(int addr, byte value)
|
||||
{
|
||||
if (addr >= 0x1F0000 && addr < 0x1F8000) // write RAM.
|
||||
Ram[addr & 0x7FFF] = value;
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
{
|
||||
public partial class PCEngine
|
||||
{
|
||||
byte ReadMemoryCD(int addr)
|
||||
private byte ReadMemoryCD(int addr)
|
||||
{
|
||||
if (addr < 0x80000) // read ROM
|
||||
return RomData[addr % RomLength];
|
||||
|
@ -51,7 +51,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
return 0xFF;
|
||||
}
|
||||
|
||||
void WriteMemoryCD(int addr, byte value)
|
||||
private void WriteMemoryCD(int addr, byte value)
|
||||
{
|
||||
if (addr >= 0x1F0000 && addr < 0x1F8000) // write RAM.
|
||||
Ram[addr & 0x1FFF] = value;
|
||||
|
|
|
@ -4,9 +4,9 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
{
|
||||
public partial class PCEngine
|
||||
{
|
||||
byte IOBuffer;
|
||||
private byte IOBuffer;
|
||||
|
||||
byte ReadMemory(int addr)
|
||||
private byte ReadMemory(int addr)
|
||||
{
|
||||
if (addr < 0xFFFFF) // read ROM
|
||||
return RomData[addr % RomLength];
|
||||
|
@ -41,11 +41,12 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
return 0xFF;
|
||||
}
|
||||
|
||||
void WriteMemory(int addr, byte value)
|
||||
private void WriteMemory(int addr, byte value)
|
||||
{
|
||||
if (addr >= 0x1F0000 && addr < 0x1F8000) // write RAM.
|
||||
{
|
||||
Ram[addr & 0x1FFF] = value;
|
||||
|
||||
}
|
||||
else if (addr >= 0x1FE000) // hardware page.
|
||||
{
|
||||
if (addr < 0x1FE400) VDC1.WriteVDC(addr, value);
|
||||
|
@ -60,8 +61,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
else if (addr >= 0x1FF800) { WriteCD(addr, value); }
|
||||
else Log.Error("MEM", "unhandled hardware write [{0:X6}] : {1:X2}", addr, value);
|
||||
}
|
||||
|
||||
else if (addr >= 0x1EE000 && addr <= 0x1EE7FF) // BRAM
|
||||
else if (addr >= 0x1EE000 && addr <= 0x1EE7FF) // BRAM
|
||||
{
|
||||
if (BramEnabled && BramLocked == false)
|
||||
{
|
||||
|
@ -69,9 +69,10 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
SaveRamModified = true;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
Log.Error("MEM", "UNHANDLED WRITE: {0:X6}:{1:X2}", addr, value);
|
||||
}
|
||||
|
||||
//CoreComm.MemoryCallbackSystem.CallWrite((uint)addr);
|
||||
}
|
||||
|
|
|
@ -1,20 +1,17 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Globalization;
|
||||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.PCEngine
|
||||
{
|
||||
partial class PCEngine
|
||||
{
|
||||
bool ArcadeCard, ArcadeCardRewindHack;
|
||||
int ShiftRegister;
|
||||
byte ShiftAmount;
|
||||
byte RotateAmount;
|
||||
ArcadeCardPage[] ArcadePage = new ArcadeCardPage[4];
|
||||
private bool ArcadeCard, ArcadeCardRewindHack;
|
||||
private int ShiftRegister;
|
||||
private byte ShiftAmount;
|
||||
private byte RotateAmount;
|
||||
|
||||
class ArcadeCardPage
|
||||
private readonly ArcadeCardPage[] ArcadePage = new ArcadeCardPage[4];
|
||||
|
||||
private class ArcadeCardPage
|
||||
{
|
||||
public byte Control;
|
||||
public int Base;
|
||||
|
@ -49,9 +46,13 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
}
|
||||
}
|
||||
|
||||
void WriteArcadeCard(int addr, byte value)
|
||||
private void WriteArcadeCard(int addr, byte value)
|
||||
{
|
||||
if (ArcadeCard == false) return;
|
||||
if (ArcadeCard == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var page = ArcadePage[(addr >> 4) & 3];
|
||||
switch (addr & 0x0F)
|
||||
{
|
||||
|
@ -111,7 +112,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
}
|
||||
}
|
||||
|
||||
byte ReadArcadeCard(int addr)
|
||||
private byte ReadArcadeCard(int addr)
|
||||
{
|
||||
if (ArcadeCard == false) return 0xFF;
|
||||
var page = ArcadePage[(addr >> 4) & 3];
|
||||
|
@ -132,6 +133,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
case 9: return (byte)(page.Control >> 0);
|
||||
case 10: return 0;
|
||||
}
|
||||
|
||||
return 0xFF;
|
||||
}
|
||||
|
||||
|
@ -143,7 +145,9 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
ser.Sync("RotateAmount", ref RotateAmount);
|
||||
|
||||
if (ArcadeCardRewindHack == false || ser.IsText)
|
||||
{
|
||||
ser.Sync("ArcadeRAM", ref ArcadeRam, false);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
|
@ -155,6 +159,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
ser.Sync("IncrementValue", ref ArcadePage[i].IncrementValue);
|
||||
ser.EndSection();
|
||||
}
|
||||
|
||||
ser.EndSection();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,7 +66,6 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
// 2 maskrom: (POT + POT) size rom, high address lines ignored, one chip enabled in first 512K,
|
||||
// second chip enabled in second 512K
|
||||
// this means that for the one case of 384K, there's not a mirror of everything contiguous starting from org 0
|
||||
|
||||
if (RomLength == 640 * 1024) // 384K has been preprocessed up to 640K, including some dummy areas
|
||||
{
|
||||
for (int i = 0x20; i < 0x40; i++)
|
||||
|
|
|
@ -33,16 +33,19 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IMemoryCallbackSystem MemoryCallbacks { get; private set; }
|
||||
public IMemoryCallbackSystem MemoryCallbacks { get; }
|
||||
|
||||
public bool CanStep(StepType type) { return false; }
|
||||
public bool CanStep(StepType type)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
[FeatureNotImplemented]
|
||||
public void Step(StepType type) { throw new NotImplementedException(); }
|
||||
|
||||
public int TotalExecutedCycles
|
||||
public void Step(StepType type)
|
||||
{
|
||||
get { return (int)Cpu.TotalExecutedCycles; }
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public int TotalExecutedCycles => (int)Cpu.TotalExecutedCycles;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
{
|
||||
public sealed partial class PCEngine : IDriveLight
|
||||
{
|
||||
public bool DriveLightEnabled { get; private set; }
|
||||
public bool DriveLightEnabled { get; }
|
||||
|
||||
public bool DriveLightOn { get; internal set; }
|
||||
}
|
||||
|
|
|
@ -6,10 +6,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
{
|
||||
public IEmulatorServiceProvider ServiceProvider { get; private set; }
|
||||
|
||||
public ControllerDefinition ControllerDefinition
|
||||
{
|
||||
get { return PCEngineController; }
|
||||
}
|
||||
public ControllerDefinition ControllerDefinition => PCEngineController;
|
||||
|
||||
public IController Controller { get; set; }
|
||||
|
||||
|
@ -47,21 +44,15 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
|
||||
public int Frame
|
||||
{
|
||||
get { return frame; }
|
||||
set { frame = value; }
|
||||
get { return _frame; }
|
||||
set { _frame = value; }
|
||||
}
|
||||
|
||||
public string SystemId { get; private set; }
|
||||
public string SystemId { get; }
|
||||
|
||||
public bool DeterministicEmulation
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
public bool DeterministicEmulation => true;
|
||||
|
||||
public string BoardName
|
||||
{
|
||||
get { return null; }
|
||||
}
|
||||
public string BoardName => null;
|
||||
|
||||
public void ResetCounters()
|
||||
{
|
||||
|
@ -71,14 +62,11 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
_isLag = false;
|
||||
}
|
||||
|
||||
public CoreComm CoreComm { get; private set; }
|
||||
public CoreComm CoreComm { get; }
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (disc != null)
|
||||
{
|
||||
disc.Dispose();
|
||||
}
|
||||
disc?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,6 +78,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
{
|
||||
ret.Controllers[i].IsConnected = Controllers[i].IsConnected;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -91,8 +92,11 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
for (int i = 0; i < x.Controllers.Length; i++)
|
||||
{
|
||||
if (x.Controllers[i].IsConnected != y.Controllers[i].IsConnected)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,10 +7,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
{
|
||||
public sealed partial class PCEngine : IStatable
|
||||
{
|
||||
public bool BinarySaveStatesPreferred
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
public bool BinarySaveStatesPreferred => false;
|
||||
|
||||
public void SaveStateBinary(BinaryWriter bw)
|
||||
{
|
||||
|
@ -94,7 +91,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
ser.Sync("CdIoPorts", ref CdIoPorts, false);
|
||||
ser.Sync("BramLocked", ref BramLocked);
|
||||
|
||||
ser.Sync("Frame", ref frame);
|
||||
ser.Sync("Frame", ref _frame);
|
||||
ser.Sync("Lag", ref _lagCount);
|
||||
ser.Sync("IsLag", ref _isLag);
|
||||
if (Cpu.ReadMemory21 == ReadMemorySF2)
|
||||
|
|
|
@ -4,18 +4,18 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
{
|
||||
public partial class PCEngine
|
||||
{
|
||||
public readonly ControllerDefinition PCEngineController = new ControllerDefinition
|
||||
private readonly ControllerDefinition PCEngineController = new ControllerDefinition
|
||||
{
|
||||
Name = "PC Engine Controller",
|
||||
BoolButtons =
|
||||
{
|
||||
Name = "PC Engine Controller",
|
||||
BoolButtons =
|
||||
{
|
||||
"P1 Up", "P1 Down", "P1 Left", "P1 Right", "P1 Select", "P1 Run", "P1 B2", "P1 B1",
|
||||
"P2 Up", "P2 Down", "P2 Left", "P2 Right", "P2 Select", "P2 Run", "P2 B2", "P2 B1",
|
||||
"P3 Up", "P3 Down", "P3 Left", "P3 Right", "P3 Select", "P3 Run", "P3 B2", "P3 B1",
|
||||
"P4 Up", "P4 Down", "P4 Left", "P4 Right", "P4 Select", "P4 Run", "P4 B2", "P4 B1",
|
||||
"P5 Up", "P5 Down", "P5 Left", "P5 Right", "P5 Select", "P5 Run", "P5 B2", "P5 B1"
|
||||
}
|
||||
};
|
||||
"P1 Up", "P1 Down", "P1 Left", "P1 Right", "P1 Select", "P1 Run", "P1 B2", "P1 B1",
|
||||
"P2 Up", "P2 Down", "P2 Left", "P2 Right", "P2 Select", "P2 Run", "P2 B2", "P2 B1",
|
||||
"P3 Up", "P3 Down", "P3 Left", "P3 Right", "P3 Select", "P3 Run", "P3 B2", "P3 B1",
|
||||
"P4 Up", "P4 Down", "P4 Left", "P4 Right", "P4 Select", "P4 Run", "P4 B2", "P4 B1",
|
||||
"P5 Up", "P5 Down", "P5 Left", "P5 Right", "P5 Select", "P5 Run", "P5 B2", "P5 B1"
|
||||
}
|
||||
};
|
||||
|
||||
private void SetControllerButtons()
|
||||
{
|
||||
|
@ -41,25 +41,29 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
}
|
||||
}
|
||||
|
||||
int SelectedController;
|
||||
byte InputByte;
|
||||
private int SelectedController;
|
||||
private byte InputByte;
|
||||
|
||||
public bool SEL { get { return ((InputByte & 1) != 0); } }
|
||||
public bool CLR { get { return ((InputByte & 2) != 0); } }
|
||||
public bool SEL => (InputByte & 1) != 0;
|
||||
public bool CLR => (InputByte & 2) != 0;
|
||||
|
||||
void WriteInput(byte value)
|
||||
private void WriteInput(byte value)
|
||||
{
|
||||
bool prevSEL = SEL;
|
||||
InputByte = value;
|
||||
|
||||
if (SEL && CLR)
|
||||
{
|
||||
SelectedController = 0;
|
||||
}
|
||||
|
||||
if (CLR == false && prevSEL == false && SEL == true)
|
||||
{
|
||||
SelectedController = (SelectedController + 1);
|
||||
}
|
||||
}
|
||||
|
||||
byte ReadInput()
|
||||
private byte ReadInput()
|
||||
{
|
||||
InputCallbacks.Call();
|
||||
byte value = 0x3F;
|
||||
|
@ -85,10 +89,15 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
}
|
||||
}
|
||||
|
||||
if (Region == "Japan") value |= 0x40;
|
||||
if (Region == "Japan")
|
||||
{
|
||||
value |= 0x40;
|
||||
}
|
||||
|
||||
if (Type != NecSystemType.TurboCD && BramEnabled == false)
|
||||
{
|
||||
value |= 0x80;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
|
|
@ -12,28 +12,32 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
get { return (CdIoPorts[3] & 0x04) != 0; }
|
||||
set { CdIoPorts[3] = (byte)((CdIoPorts[3] & ~0x04) | (value ? 0x04 : 0x00)); }
|
||||
}
|
||||
|
||||
public bool IntStop // INTSTOP
|
||||
{
|
||||
get { return (CdIoPorts[3] & 0x08) != 0; }
|
||||
set { CdIoPorts[3] = (byte)((CdIoPorts[3] & ~0x08) | (value ? 0x8 : 0x00)); }
|
||||
}
|
||||
|
||||
public bool IntSubchannel // INTSUB
|
||||
{
|
||||
get { return (CdIoPorts[3] & 0x10) != 0; }
|
||||
set { CdIoPorts[3] = (byte)((CdIoPorts[3] & ~0x10) | (value ? 0x10 : 0x00)); }
|
||||
}
|
||||
|
||||
public bool IntDataTransferComplete // INTM
|
||||
{
|
||||
get { return (CdIoPorts[3] & 0x20) != 0; }
|
||||
set { CdIoPorts[3] = (byte)((CdIoPorts[3] & ~0x20) | (value ? 0x20 : 0x00)); }
|
||||
}
|
||||
|
||||
public bool IntDataTransferReady // INTD
|
||||
{
|
||||
get { return (CdIoPorts[3] & 0x40) != 0; }
|
||||
set { CdIoPorts[3] = (byte)((CdIoPorts[3] & ~0x40) | (value ? 0x40 : 0x00)); }
|
||||
}
|
||||
|
||||
void SetCDAudioCallback()
|
||||
private void SetCDAudioCallback()
|
||||
{
|
||||
CDAudio.CallbackAction = () =>
|
||||
{
|
||||
|
@ -43,7 +47,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
};
|
||||
}
|
||||
|
||||
void WriteCD(int addr, byte value)
|
||||
private void WriteCD(int addr, byte value)
|
||||
{
|
||||
if (!TurboCD && !BramEnabled)
|
||||
return; // flee if no turboCD hooked up
|
||||
|
@ -68,7 +72,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
|
||||
case 0x1802: // ACK and Interrupt Control
|
||||
CdIoPorts[2] = value;
|
||||
SCSI.ACK = ((value & 0x80) != 0);
|
||||
SCSI.ACK = (value & 0x80) != 0;
|
||||
|
||||
SCSI.Think();
|
||||
RefreshIRQ2();
|
||||
|
@ -76,7 +80,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
|
||||
case 0x1804: // CD Reset Command
|
||||
CdIoPorts[4] = value;
|
||||
SCSI.RST = ((value & 0x02) != 0);
|
||||
SCSI.RST = (value & 0x02) != 0;
|
||||
SCSI.Think();
|
||||
if (SCSI.RST)
|
||||
{
|
||||
|
@ -192,7 +196,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
public byte ReadCD(int addr)
|
||||
{
|
||||
if (!TurboCD && !BramEnabled)
|
||||
return 0xFF; //bail if no TurboCD.
|
||||
return 0xFF; // bail if no TurboCD.
|
||||
if (!TurboCD && addr != 0x1FF803) // only allow access to $1803 unless full TurboCD mode.
|
||||
return 0xFF;
|
||||
|
||||
|
@ -307,7 +311,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
public void RefreshIRQ2()
|
||||
{
|
||||
int mask = CdIoPorts[2] & CdIoPorts[3] & 0x7C;
|
||||
Cpu.IRQ2Assert = (mask != 0);
|
||||
Cpu.IRQ2Assert = mask != 0;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -15,8 +15,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
"PCEHawk",
|
||||
"Vecna",
|
||||
isPorted: false,
|
||||
isReleased: true
|
||||
)]
|
||||
isReleased: true)]
|
||||
public sealed partial class PCEngine : IEmulator, ISaveRam, IStatable, IInputPollable,
|
||||
IDebuggable, ISettable<PCEngine.PCESettings, PCEngine.PCESyncSettings>, IDriveLight, ICodeDataLogger
|
||||
{
|
||||
|
@ -39,6 +38,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
Type = NecSystemType.SuperGrafx;
|
||||
break;
|
||||
}
|
||||
|
||||
this.Settings = (PCESettings)Settings ?? new PCESettings();
|
||||
_syncSettings = (PCESyncSettings)syncSettings ?? new PCESyncSettings();
|
||||
Init(game, rom);
|
||||
|
@ -73,8 +73,8 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
}
|
||||
else if (biosInfo["BIOS"] == false)
|
||||
{
|
||||
//zeromus says: someone please write a note about how this could possibly happen.
|
||||
//it seems like this is a relic of using gameDB for storing whether something is a bios? firmwareDB should be handling it now.
|
||||
// zeromus says: someone please write a note about how this could possibly happen.
|
||||
// it seems like this is a relic of using gameDB for storing whether something is a bios? firmwareDB should be handling it now.
|
||||
CoreComm.ShowMessage(
|
||||
"The PCE-CD System Card you have selected is not a BIOS image. You may have selected the wrong rom. FYI-Please report this to developers, I don't think this error message should happen.");
|
||||
}
|
||||
|
@ -94,6 +94,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
game.FirmwareHash = rom.HashSHA1();
|
||||
|
||||
Init(game, rom);
|
||||
|
||||
// the default RomStatusDetails don't do anything with Disc
|
||||
CoreComm.RomStatusDetails = string.Format("{0}\r\nDisk partial hash:{1}", game.Name, new DiscSystem.DiscHasher(disc).OldHash());
|
||||
SetControllerButtons();
|
||||
|
@ -117,9 +118,9 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
internal CDAudio CDAudio;
|
||||
private SoundMixer SoundMixer;
|
||||
|
||||
private bool TurboGrafx { get { return Type == NecSystemType.TurboGrafx; } }
|
||||
private bool SuperGrafx { get { return Type == NecSystemType.SuperGrafx; } }
|
||||
private bool TurboCD { get { return Type == NecSystemType.TurboCD; } }
|
||||
private bool TurboGrafx => Type == NecSystemType.TurboGrafx;
|
||||
private bool SuperGrafx => Type == NecSystemType.SuperGrafx;
|
||||
private bool TurboCD => Type == NecSystemType.TurboCD;
|
||||
|
||||
// BRAM
|
||||
private bool BramEnabled = false;
|
||||
|
@ -136,7 +137,6 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
|
||||
// 21,477,270 Machine clocks / sec
|
||||
// 7,159,090 Cpu cycles / sec
|
||||
|
||||
private ITraceable Tracer { get; set; }
|
||||
|
||||
private void Init(GameInfo game, byte[] rom)
|
||||
|
@ -148,7 +148,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
PSG = new HuC6280PSG();
|
||||
SCSI = new ScsiCDBus(this, disc);
|
||||
|
||||
Cpu.Logger = (s) => Tracer.Put(s);
|
||||
Cpu.Logger = s => Tracer.Put(s);
|
||||
|
||||
if (TurboGrafx)
|
||||
{
|
||||
|
@ -156,7 +156,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
Cpu.ReadMemory21 = ReadMemory;
|
||||
Cpu.WriteMemory21 = WriteMemory;
|
||||
Cpu.WriteVDC = VDC1.WriteVDC;
|
||||
soundProvider = new FakeSyncSound(PSG, 735);
|
||||
_soundProvider = new FakeSyncSound(PSG, 735);
|
||||
CDAudio = new CDAudio(null, 0);
|
||||
}
|
||||
|
||||
|
@ -168,7 +168,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
Cpu.ReadMemory21 = ReadMemorySGX;
|
||||
Cpu.WriteMemory21 = WriteMemorySGX;
|
||||
Cpu.WriteVDC = VDC1.WriteVDC;
|
||||
soundProvider = new FakeSyncSound(PSG, 735);
|
||||
_soundProvider = new FakeSyncSound(PSG, 735);
|
||||
CDAudio = new CDAudio(null, 0);
|
||||
}
|
||||
|
||||
|
@ -184,7 +184,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
SetCDAudioCallback();
|
||||
PSG.MaxVolume = short.MaxValue * 3 / 4;
|
||||
SoundMixer = new SoundMixer(PSG, CDAudio, ADPCM);
|
||||
soundProvider = new FakeSyncSound(SoundMixer, 735);
|
||||
_soundProvider = new FakeSyncSound(SoundMixer, 735);
|
||||
Cpu.ThinkAction = (cycles) => { SCSI.Think(); ADPCM.Think(cycles); };
|
||||
}
|
||||
|
||||
|
@ -207,11 +207,12 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
Cpu.WriteMemory21 = WriteMemorySF2;
|
||||
RomData = rom;
|
||||
RomLength = RomData.Length;
|
||||
|
||||
// user request: current value of the SF2MapperLatch on the tracelogger
|
||||
Cpu.Logger = (s) => Tracer.Put(new TraceInfo
|
||||
{
|
||||
Disassembly = string.Format("{0:X1}:{1}", SF2MapperLatch, s),
|
||||
RegisterInfo = ""
|
||||
Disassembly = $"{SF2MapperLatch:X1}:{s}",
|
||||
RegisterInfo = string.Empty
|
||||
});
|
||||
}
|
||||
else
|
||||
|
@ -232,7 +233,9 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
}
|
||||
|
||||
if (game["SuperSysCard"])
|
||||
{
|
||||
SuperRam = new byte[0x30000];
|
||||
}
|
||||
|
||||
if (game["ArcadeCard"])
|
||||
{
|
||||
|
@ -240,7 +243,9 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
ArcadeCard = true;
|
||||
ArcadeCardRewindHack = Settings.ArcadeCardRewindHack;
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
ArcadePage[i] = new ArcadeCardPage();
|
||||
}
|
||||
}
|
||||
|
||||
if (game["PopulousSRAM"])
|
||||
|
@ -252,17 +257,30 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
|
||||
// the gamedb can force sprite limit on, ignoring settings
|
||||
if (game["ForceSpriteLimit"] || game.NotInDatabase)
|
||||
{
|
||||
ForceSpriteLimit = true;
|
||||
}
|
||||
|
||||
if (game["CdVol"])
|
||||
{
|
||||
CDAudio.MaxVolume = int.Parse(game.OptionValue("CdVol"));
|
||||
}
|
||||
|
||||
if (game["PsgVol"])
|
||||
{
|
||||
PSG.MaxVolume = int.Parse(game.OptionValue("PsgVol"));
|
||||
}
|
||||
|
||||
if (game["AdpcmVol"])
|
||||
{
|
||||
ADPCM.MaxVolume = int.Parse(game.OptionValue("AdpcmVol"));
|
||||
}
|
||||
|
||||
// the gamedb can also force equalizevolumes on
|
||||
if (TurboCD && (Settings.EqualizeVolume || game["EqualizeVolumes"] || game.NotInDatabase))
|
||||
{
|
||||
SoundMixer.EqualizeVolumes();
|
||||
}
|
||||
|
||||
// Ok, yes, HBlankPeriod's only purpose is game-specific hax.
|
||||
// 1) At least they're not coded directly into the emulator, but instead data-driven.
|
||||
|
@ -272,14 +290,16 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
// The proper fix is cycle-accurate/bus-accurate timing. That isn't coming to the C#
|
||||
// version of this core. Let's just acknolwedge that the timing is imperfect and fix
|
||||
// it in the least intrusive and most honest way we can.
|
||||
|
||||
if (game["HBlankPeriod"])
|
||||
{
|
||||
VDC1.HBlankCycles = game.GetIntValue("HBlankPeriod");
|
||||
}
|
||||
|
||||
// This is also a hack. Proper multi-res/TV emulation will be a native-code core feature.
|
||||
|
||||
if (game["MultiResHack"])
|
||||
{
|
||||
VDC1.MultiResHack = game.GetIntValue("MultiResHack");
|
||||
}
|
||||
|
||||
Cpu.ResetPC();
|
||||
|
||||
|
@ -289,19 +309,21 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
ser.Register<ITraceable>(Tracer);
|
||||
ser.Register<IDisassemblable>(Cpu);
|
||||
ser.Register<IVideoProvider>((IVideoProvider)VPC ?? VDC1);
|
||||
ser.Register<ISoundProvider>(soundProvider);
|
||||
ser.Register<ISoundProvider>(_soundProvider);
|
||||
SetupMemoryDomains();
|
||||
}
|
||||
|
||||
private int frame;
|
||||
private int _frame;
|
||||
|
||||
private static Dictionary<string, int> SizesFromHuMap(IEnumerable<HuC6280.MemMapping> mm)
|
||||
{
|
||||
Dictionary<string, int> sizes = new Dictionary<string, int>();
|
||||
foreach (var m in mm)
|
||||
{
|
||||
if (!sizes.ContainsKey(m.Name) || m.MaxOffs >= sizes[m.Name])
|
||||
sizes[m.Name] = m.MaxOffs;
|
||||
if (!sizes.ContainsKey(m.Name) || m.MaxOffs >= sizes[m.Name])
|
||||
{
|
||||
sizes[m.Name] = m.MaxOffs;
|
||||
}
|
||||
}
|
||||
|
||||
var keys = new List<string>(sizes.Keys);
|
||||
|
@ -310,6 +332,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
// becase we were looking at offsets, and each bank is 8192 big, we need to add that size
|
||||
sizes[key] += 8192;
|
||||
}
|
||||
|
||||
return sizes;
|
||||
}
|
||||
|
||||
|
@ -318,10 +341,12 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
bool spriteLimit = ForceSpriteLimit | Settings.SpriteLimit;
|
||||
VDC1.PerformSpriteLimit = spriteLimit;
|
||||
if (VDC2 != null)
|
||||
{
|
||||
VDC2.PerformSpriteLimit = spriteLimit;
|
||||
}
|
||||
}
|
||||
|
||||
private ISoundProvider soundProvider;
|
||||
private ISoundProvider _soundProvider;
|
||||
|
||||
private string Region { get; set; }
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
// TODO we can adjust this to have Think take the number of cycles and not require
|
||||
// a reference to Cpu.TotalExecutedCycles
|
||||
// which incidentally would allow us to put it back to an int from a long if we wanted to
|
||||
|
||||
public sealed class ScsiCDBus
|
||||
{
|
||||
const int STATUS_GOOD = 0;
|
||||
|
@ -40,6 +39,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
bsy = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool SEL
|
||||
{
|
||||
get { return sel; }
|
||||
|
@ -49,6 +49,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
sel = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool CD // CONTROL = true, DATA = false
|
||||
{
|
||||
get { return cd; }
|
||||
|
@ -58,6 +59,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
cd = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IO // INPUT = true, OUTPUT = false
|
||||
{
|
||||
get { return io; }
|
||||
|
@ -67,6 +69,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
io = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool MSG
|
||||
{
|
||||
get { return msg; }
|
||||
|
@ -76,6 +79,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
msg = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool REQ
|
||||
{
|
||||
get { return req; }
|
||||
|
@ -85,6 +89,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
req = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool ACK
|
||||
{
|
||||
get { return ack; }
|
||||
|
@ -94,6 +99,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
ack = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool ATN
|
||||
{
|
||||
get { return atn; }
|
||||
|
@ -103,6 +109,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
atn = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool RST
|
||||
{
|
||||
get { return rst; }
|
||||
|
@ -112,6 +119,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
rst = value;
|
||||
}
|
||||
}
|
||||
|
||||
public byte DataBits;
|
||||
|
||||
const byte BusPhase_BusFree = 0;
|
||||
|
@ -143,12 +151,12 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
|
||||
// ******** Resources ********
|
||||
|
||||
PCEngine pce;
|
||||
private PCEngine pce;
|
||||
public Disc disc;
|
||||
DiscSectorReader DiscSectorReader;
|
||||
SubchannelQ subchannelQ;
|
||||
int audioStartLBA;
|
||||
int audioEndLBA;
|
||||
private DiscSectorReader DiscSectorReader;
|
||||
private SubchannelQ subchannelQ;
|
||||
private int audioStartLBA;
|
||||
private int audioEndLBA;
|
||||
|
||||
public ScsiCDBus(PCEngine pce, Disc disc)
|
||||
{
|
||||
|
@ -173,7 +181,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
if (DataIn.Count == 0)
|
||||
{
|
||||
// read in a sector and shove it in the queue
|
||||
DiscSystem.DiscSectorReader dsr = new DiscSectorReader(disc); //TODO - cache reader
|
||||
DiscSystem.DiscSectorReader dsr = new DiscSectorReader(disc); // TODO - cache reader
|
||||
dsr.ReadLBA_2048(CurrentReadingSector, DataIn.GetBuffer(), 0);
|
||||
DataIn.SignalBufferFilled(2048);
|
||||
CurrentReadingSector++;
|
||||
|
@ -187,15 +195,16 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
// but lets get some basic functionality before we go crazy.
|
||||
// Idunno, maybe they do come in a sector at a time.
|
||||
|
||||
//note to vecna: maybe not at the sector level, but at a level > 1 sample and <= 1 sector, samples come out in blocks
|
||||
//due to the way they are jumbled up (seriously, like put into a blender) for error correction purposes.
|
||||
//we may as well assume that the cd audio decoding magic works at the level of one sector, but it isnt one sample.
|
||||
// note to vecna: maybe not at the sector level, but at a level > 1 sample and <= 1 sector, samples come out in blocks
|
||||
// due to the way they are jumbled up (seriously, like put into a blender) for error correction purposes.
|
||||
// we may as well assume that the cd audio decoding magic works at the level of one sector, but it isnt one sample.
|
||||
|
||||
if (SectorsLeftToRead == 0)
|
||||
{
|
||||
DataReadInProgress = false;
|
||||
DataTransferWasDone = true;
|
||||
}
|
||||
|
||||
SetPhase(BusPhase_DataIn);
|
||||
}
|
||||
}
|
||||
|
@ -226,7 +235,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
} while (signalsChanged || busPhaseChanged);
|
||||
}
|
||||
|
||||
void ResetDevice()
|
||||
private void ResetDevice()
|
||||
{
|
||||
CD = false;
|
||||
IO = false;
|
||||
|
@ -243,7 +252,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
pce.CDAudio.Stop();
|
||||
}
|
||||
|
||||
void ThinkCommandPhase()
|
||||
private void ThinkCommandPhase()
|
||||
{
|
||||
if (REQ && ACK)
|
||||
{
|
||||
|
@ -266,7 +275,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
}
|
||||
}
|
||||
|
||||
void ThinkDataInPhase()
|
||||
private void ThinkDataInPhase()
|
||||
{
|
||||
if (REQ && ACK)
|
||||
{
|
||||
|
@ -295,13 +304,13 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
}
|
||||
}
|
||||
|
||||
void ThinkDataOutPhase()
|
||||
private void ThinkDataOutPhase()
|
||||
{
|
||||
Console.WriteLine("*********** DATA OUT PHASE, DOES THIS HAPPEN? ****************");
|
||||
SetPhase(BusPhase_BusFree);
|
||||
}
|
||||
|
||||
void ThinkMessageInPhase()
|
||||
private void ThinkMessageInPhase()
|
||||
{
|
||||
if (REQ && ACK)
|
||||
{
|
||||
|
@ -316,19 +325,20 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
}
|
||||
}
|
||||
|
||||
void ThinkMessageOutPhase()
|
||||
private void ThinkMessageOutPhase()
|
||||
{
|
||||
Console.WriteLine("******* IN MESSAGE OUT PHASE. DOES THIS EVER HAPPEN? ********");
|
||||
SetPhase(BusPhase_BusFree);
|
||||
}
|
||||
|
||||
void ThinkStatusPhase()
|
||||
private void ThinkStatusPhase()
|
||||
{
|
||||
if (REQ && ACK)
|
||||
{
|
||||
REQ = false;
|
||||
StatusCompleted = true;
|
||||
}
|
||||
|
||||
if (!REQ && !ACK && StatusCompleted)
|
||||
{
|
||||
StatusCompleted = false;
|
||||
|
@ -338,7 +348,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
}
|
||||
|
||||
// returns true if command completed, false if more data bytes needed
|
||||
bool CheckCommandBuffer()
|
||||
private bool CheckCommandBuffer()
|
||||
{
|
||||
switch (CommandBuffer[0])
|
||||
{
|
||||
|
@ -385,7 +395,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
return false;
|
||||
}
|
||||
|
||||
void CommandRead()
|
||||
private void CommandRead()
|
||||
{
|
||||
int sector = (CommandBuffer[1] & 0x1f) << 16;
|
||||
sector |= CommandBuffer[2] << 8;
|
||||
|
@ -403,7 +413,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
pce.CDAudio.Stop();
|
||||
}
|
||||
|
||||
void CommandAudioStartPos()
|
||||
private void CommandAudioStartPos()
|
||||
{
|
||||
switch (CommandBuffer[9] & 0xC0)
|
||||
{
|
||||
|
@ -438,7 +448,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
pce.IntDataTransferComplete = true;
|
||||
}
|
||||
|
||||
void CommandAudioEndPos()
|
||||
private void CommandAudioEndPos()
|
||||
{
|
||||
switch (CommandBuffer[9] & 0xC0)
|
||||
{
|
||||
|
@ -486,13 +496,13 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
SetStatusMessage(STATUS_GOOD, 0);
|
||||
}
|
||||
|
||||
void CommandPause()
|
||||
private void CommandPause()
|
||||
{
|
||||
pce.CDAudio.Stop();
|
||||
SetStatusMessage(STATUS_GOOD, 0);
|
||||
}
|
||||
|
||||
void CommandReadSubcodeQ()
|
||||
private void CommandReadSubcodeQ()
|
||||
{
|
||||
bool playing = pce.CDAudio.Mode != CDAudio.CDAudioMode_Stopped;
|
||||
int sectorNum = playing ? pce.CDAudio.CurrentSector : CurrentReadingSector;
|
||||
|
@ -507,7 +517,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
}
|
||||
|
||||
DiscSectorReader.ReadLBA_SubQ(sectorNum, out subchannelQ);
|
||||
DataIn.Enqueue(subchannelQ.q_status); //status (control and q-mode; control is useful to know if it's a data or audio track)
|
||||
DataIn.Enqueue(subchannelQ.q_status); // status (control and q-mode; control is useful to know if it's a data or audio track)
|
||||
DataIn.Enqueue(subchannelQ.q_tno.BCDValue); // track //zero 03-jul-2015 - did I adapt this right>
|
||||
DataIn.Enqueue(subchannelQ.q_index.BCDValue); // index //zero 03-jul-2015 - did I adapt this right>
|
||||
DataIn.Enqueue(subchannelQ.min.BCDValue); // M(rel)
|
||||
|
@ -520,7 +530,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
SetPhase(BusPhase_DataIn);
|
||||
}
|
||||
|
||||
void CommandReadTOC()
|
||||
private void CommandReadTOC()
|
||||
{
|
||||
switch (CommandBuffer[1])
|
||||
{
|
||||
|
@ -534,7 +544,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
}
|
||||
case 1: // return total disc length in minutes/seconds/frames
|
||||
{
|
||||
//zero 07-jul-2015 - I may have broken this
|
||||
// zero 07-jul-2015 - I may have broken this
|
||||
int totalLbaLength = disc.Session1.LeadoutLBA;
|
||||
|
||||
byte m, s, f;
|
||||
|
@ -583,7 +593,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
}
|
||||
}
|
||||
|
||||
void SetStatusMessage(byte status, byte message)
|
||||
private void SetStatusMessage(byte status, byte message)
|
||||
{
|
||||
MessageValue = message;
|
||||
StatusCompleted = false;
|
||||
|
@ -592,10 +602,12 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
SetPhase(BusPhase_Status);
|
||||
}
|
||||
|
||||
void SetPhase(byte phase)
|
||||
private void SetPhase(byte phase)
|
||||
{
|
||||
if (Phase == phase)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Phase = phase;
|
||||
busPhaseChanged = true;
|
||||
|
|
|
@ -1,8 +1,4 @@
|
|||
using System;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.PCEngine
|
||||
{
|
||||
|
@ -14,7 +10,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
public int[] Palette = new int[512];
|
||||
public byte CR;
|
||||
|
||||
public int NumberOfScanlines { get { return ((CR & 4) != 0) ? 263 : 262; } }
|
||||
public int NumberOfScanlines => (CR & 4) != 0 ? 263 : 262;
|
||||
|
||||
public void WriteVCE(int port, byte value)
|
||||
{
|
||||
|
@ -64,7 +60,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
}
|
||||
}
|
||||
|
||||
static readonly byte[] PalConvert = { 0, 36, 72, 109, 145, 182, 218, 255 };
|
||||
private static readonly byte[] PalConvert = { 0, 36, 72, 109, 145, 182, 218, 255 };
|
||||
|
||||
public void PrecomputePalette(int slot)
|
||||
{
|
||||
|
@ -83,8 +79,12 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
ser.EndSection();
|
||||
|
||||
if (ser.IsReader)
|
||||
{
|
||||
for (int i = 0; i < VceData.Length; i++)
|
||||
{
|
||||
PrecomputePalette(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,11 +4,10 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
{
|
||||
// This rendering code is only used for TurboGrafx/TurboCD Mode.
|
||||
// In SuperGrafx mode, separate rendering functions in the VPC class are used.
|
||||
|
||||
public partial class VDC
|
||||
{
|
||||
/* There are many line-counters here. Here is a breakdown of what they each are:
|
||||
|
||||
|
||||
+ ScanLine is the current NTSC scanline. It has a range from 0 to 262.
|
||||
+ ActiveLine is the current offset into the framebuffer. 0 is the first
|
||||
line of active display, and the last value will be BufferHeight-1.
|
||||
|
@ -26,8 +25,8 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
public int HBlankCycles = 79;
|
||||
public bool PerformSpriteLimit;
|
||||
|
||||
byte[] PriorityBuffer = new byte[512];
|
||||
byte[] InterSpritePriorityBuffer = new byte[512];
|
||||
private readonly byte[] PriorityBuffer = new byte[512];
|
||||
private readonly byte[] InterSpritePriorityBuffer = new byte[512];
|
||||
|
||||
public void ExecFrame(bool render)
|
||||
{
|
||||
|
@ -69,6 +68,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
BackgroundY++;
|
||||
BackgroundY &= 0x01FF;
|
||||
}
|
||||
|
||||
if (render) RenderScanLine();
|
||||
}
|
||||
|
||||
|
@ -112,9 +112,9 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
RenderSpritesScanline(pce.Settings.ShowOBJ1);
|
||||
}
|
||||
|
||||
Action<bool> RenderBackgroundScanline;
|
||||
private readonly Action<bool> RenderBackgroundScanline;
|
||||
|
||||
unsafe void RenderBackgroundScanlineUnsafe(bool show)
|
||||
private unsafe void RenderBackgroundScanlineUnsafe(bool show)
|
||||
{
|
||||
Array.Clear(PriorityBuffer, 0, FrameWidth);
|
||||
|
||||
|
@ -127,6 +127,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
for (int i = 0; i < FrameWidth; i++)
|
||||
*dst++ = p;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -193,7 +194,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
}
|
||||
}
|
||||
|
||||
void RenderBackgroundScanlineSafe(bool show)
|
||||
private void RenderBackgroundScanlineSafe(bool show)
|
||||
{
|
||||
Array.Clear(PriorityBuffer, 0, FrameWidth);
|
||||
|
||||
|
@ -233,12 +234,14 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
}
|
||||
}
|
||||
|
||||
byte[] heightTable = { 16, 32, 64, 64 };
|
||||
private readonly byte[] heightTable = { 16, 32, 64, 64 };
|
||||
|
||||
public void RenderSpritesScanline(bool show)
|
||||
{
|
||||
if (SpritesEnabled == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Array.Clear(InterSpritePriorityBuffer, 0, FrameWidth);
|
||||
bool Sprite4ColorMode = Sprite4ColorModeEnabled;
|
||||
|
@ -343,6 +346,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (hflip == false)
|
||||
{
|
||||
if (x + width > 0 && y + height > 0)
|
||||
|
@ -419,17 +423,21 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
}
|
||||
}
|
||||
|
||||
int FramePitch = 256;
|
||||
int FrameWidth = 256;
|
||||
int FrameHeight = 240;
|
||||
int[] FrameBuffer = new int[256 * 240];
|
||||
private int FramePitch = 256;
|
||||
private int FrameWidth = 256;
|
||||
private int FrameHeight = 240;
|
||||
private int[] FrameBuffer = new int[256 * 240];
|
||||
|
||||
public int[] GetVideoBuffer() { return FrameBuffer; }
|
||||
// IVideoProvider implementation
|
||||
public int[] GetVideoBuffer()
|
||||
{
|
||||
return FrameBuffer;
|
||||
}
|
||||
|
||||
public int VirtualWidth { get { return FramePitch; } }
|
||||
public int VirtualHeight { get { return FrameHeight; } }
|
||||
public int BufferWidth { get { return FramePitch; } }
|
||||
public int BufferHeight { get { return FrameHeight; } }
|
||||
public int BackgroundColor { get { return vce.Palette[256]; } }
|
||||
public int VirtualWidth => FramePitch;
|
||||
public int VirtualHeight => FrameHeight;
|
||||
public int BufferWidth => FramePitch;
|
||||
public int BufferHeight => FrameHeight;
|
||||
public int BackgroundColor => vce.Palette[256];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,21 +1,16 @@
|
|||
using System;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Emulation.Cores.Components.H6280;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.PCEngine
|
||||
{
|
||||
// HuC6270 Video Display Controller
|
||||
|
||||
public sealed partial class VDC : IVideoProvider
|
||||
{
|
||||
public ushort[] VRAM = new ushort[0x8000];
|
||||
public ushort[] SpriteAttributeTable = new ushort[256];
|
||||
public byte[] PatternBuffer = new byte[0x20000];
|
||||
public byte[] SpriteBuffer = new byte[0x20000];
|
||||
public readonly byte[] PatternBuffer = new byte[0x20000];
|
||||
public readonly byte[] SpriteBuffer = new byte[0x20000];
|
||||
public byte RegisterLatch;
|
||||
public ushort[] Registers = new ushort[0x20];
|
||||
public ushort ReadBuffer;
|
||||
|
@ -35,49 +30,49 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
case 2: return 64;
|
||||
case 3: return 128;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
public bool BackgroundEnabled { get { return (Registers[CR] & 0x80) != 0; } }
|
||||
public bool SpritesEnabled { get { return (Registers[CR] & 0x40) != 0; } }
|
||||
public bool VBlankInterruptEnabled { get { return (Registers[CR] & 0x08) != 0; } }
|
||||
public bool RasterCompareInterruptEnabled { get { return (Registers[CR] & 0x04) != 0; } }
|
||||
public bool SpriteOverflowInterruptEnabled { get { return (Registers[CR] & 0x02) != 0; } }
|
||||
public bool SpriteCollisionInterruptEnabled { get { return (Registers[CR] & 0x01) != 0; } }
|
||||
public bool Sprite4ColorModeEnabled { get { return (Registers[MWR] & 0x0C) == 4; } }
|
||||
public bool BackgroundEnabled => (Registers[CR] & 0x80) != 0;
|
||||
public bool SpritesEnabled => (Registers[CR] & 0x40) != 0;
|
||||
public bool VBlankInterruptEnabled => (Registers[CR] & 0x08) != 0;
|
||||
public bool RasterCompareInterruptEnabled => (Registers[CR] & 0x04) != 0;
|
||||
public bool SpriteOverflowInterruptEnabled => (Registers[CR] & 0x02) != 0;
|
||||
public bool SpriteCollisionInterruptEnabled => (Registers[CR] & 0x01) != 0;
|
||||
public bool Sprite4ColorModeEnabled => (Registers[MWR] & 0x0C) == 4;
|
||||
|
||||
public int BatWidth { get { switch ((Registers[MWR] >> 4) & 3) { case 0: return 32; case 1: return 64; default: return 128; } } }
|
||||
public int BatHeight { get { return ((Registers[MWR] & 0x40) == 0) ? 32 : 64; } }
|
||||
public int BatHeight => (Registers[MWR] & 0x40) == 0 ? 32 : 64;
|
||||
|
||||
public int RequestedFrameWidth { get { return ((Registers[HDR] & 0x3F) + 1) * 8; } }
|
||||
public int RequestedFrameHeight { get { return ((Registers[VDW] & 0x1FF) + 1); } }
|
||||
public int RequestedFrameWidth => ((Registers[HDR] & 0x3F) + 1) * 8;
|
||||
public int RequestedFrameHeight => (Registers[VDW] & 0x1FF) + 1;
|
||||
public int DisplayStartLine => (Registers[VPR] >> 8) + (Registers[VPR] & 0x1F);
|
||||
|
||||
public int DisplayStartLine { get { return (Registers[VPR] >> 8) + (Registers[VPR] & 0x1F); } }
|
||||
private const int MAWR = 0; // Memory Address Write Register
|
||||
private const int MARR = 1; // Memory Address Read Register
|
||||
private const int VRR = 2; // VRAM Read Register
|
||||
private const int VWR = 2; // VRAM Write Register
|
||||
private const int CR = 5; // Control Register
|
||||
private const int RCR = 6; // Raster Compare Register
|
||||
private const int BXR = 7; // Background X-scroll Register
|
||||
private const int BYR = 8; // Background Y-scroll Register
|
||||
private const int MWR = 9; // Memory-access Width Register
|
||||
private const int HSR = 10; // Horizontal Sync Register
|
||||
private const int HDR = 11; // Horizontal Display Register
|
||||
private const int VPR = 12; // Vertical synchronous register
|
||||
private const int VDW = 13; // Vertical display register
|
||||
private const int VCR = 14; // Vertical display END position register;
|
||||
private const int DCR = 15; // DMA Control Register
|
||||
private const int SOUR = 16; // Source address for DMA
|
||||
private const int DESR = 17; // Destination address for DMA
|
||||
private const int LENR = 18; // Length of DMA transfer. Writing this will initiate DMA.
|
||||
private const int SATB = 19; // Sprite Attribute Table base location in VRAM
|
||||
|
||||
const int MAWR = 0; // Memory Address Write Register
|
||||
const int MARR = 1; // Memory Address Read Register
|
||||
const int VRR = 2; // VRAM Read Register
|
||||
const int VWR = 2; // VRAM Write Register
|
||||
const int CR = 5; // Control Register
|
||||
const int RCR = 6; // Raster Compare Register
|
||||
const int BXR = 7; // Background X-scroll Register
|
||||
const int BYR = 8; // Background Y-scroll Register
|
||||
const int MWR = 9; // Memory-access Width Register
|
||||
const int HSR = 10; // Horizontal Sync Register
|
||||
const int HDR = 11; // Horizontal Display Register
|
||||
const int VPR = 12; // Vertical synchronous register
|
||||
const int VDW = 13; // Vertical display register
|
||||
const int VCR = 14; // Vertical display END position register;
|
||||
const int DCR = 15; // DMA Control Register
|
||||
const int SOUR = 16; // Source address for DMA
|
||||
const int DESR = 17; // Destination address for DMA
|
||||
const int LENR = 18; // Length of DMA transfer. Writing this will initiate DMA.
|
||||
const int SATB = 19; // Sprite Attribute Table base location in VRAM
|
||||
|
||||
const int RegisterSelect = 0;
|
||||
const int LSB = 2;
|
||||
const int MSB = 3;
|
||||
private const int RegisterSelect = 0;
|
||||
private const int LSB = 2;
|
||||
private const int MSB = 3;
|
||||
|
||||
public const byte StatusVerticalBlanking = 0x20;
|
||||
public const byte StatusVramVramDmaComplete = 0x10;
|
||||
|
@ -88,9 +83,9 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
|
||||
const int VramSize = 0x8000;
|
||||
|
||||
PCEngine pce;
|
||||
HuC6280 cpu;
|
||||
VCE vce;
|
||||
private readonly PCEngine pce;
|
||||
private readonly HuC6280 cpu;
|
||||
private readonly VCE vce;
|
||||
|
||||
public int MultiResHack = 0;
|
||||
|
||||
|
@ -134,7 +129,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
}
|
||||
}
|
||||
|
||||
void RegisterCommit(int register, bool msbComplete)
|
||||
private void RegisterCommit(int register, bool msbComplete)
|
||||
{
|
||||
switch (register)
|
||||
{
|
||||
|
@ -210,8 +205,10 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
Registers[MARR] += IncrementWidth;
|
||||
ReadBuffer = VRAM[Registers[MARR] & 0x7FFF];
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -264,8 +261,8 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
|
||||
public void UpdatePatternData(ushort addr)
|
||||
{
|
||||
int tileNo = (addr >> 4);
|
||||
int tileLineOffset = (addr & 0x7);
|
||||
int tileNo = addr >> 4;
|
||||
int tileLineOffset = addr & 0x7;
|
||||
|
||||
int bitplane01 = VRAM[(tileNo * 16) + tileLineOffset];
|
||||
int bitplane23 = VRAM[(tileNo * 16) + tileLineOffset + 8];
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
@ -23,12 +22,12 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
|
||||
public byte[] Registers = { 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
|
||||
public int Window1Width { get { return ((Registers[3] & 3) << 8) | Registers[2]; } }
|
||||
public int Window2Width { get { return ((Registers[5] & 3) << 8) | Registers[4]; } }
|
||||
public int PriorityModeSlot0 { get { return Registers[0] & 0x0F; } }
|
||||
public int PriorityModeSlot1 { get { return (Registers[0] >> 4) & 0x0F; } }
|
||||
public int PriorityModeSlot2 { get { return Registers[1] & 0x0F; } }
|
||||
public int PriorityModeSlot3 { get { return (Registers[1] >> 4) & 0x0F; } }
|
||||
public int Window1Width => ((Registers[3] & 3) << 8) | Registers[2];
|
||||
public int Window2Width => ((Registers[5] & 3) << 8) | Registers[4];
|
||||
public int PriorityModeSlot0 => Registers[0] & 0x0F;
|
||||
public int PriorityModeSlot1 => (Registers[0] >> 4) & 0x0F;
|
||||
public int PriorityModeSlot2 => Registers[1] & 0x0F;
|
||||
public int PriorityModeSlot3 => (Registers[1] >> 4) & 0x0F;
|
||||
|
||||
public VPC(PCEngine pce, VDC vdc1, VDC vdc2, VCE vce, HuC6280 cpu)
|
||||
{
|
||||
|
@ -107,8 +106,8 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
int FrameWidth;
|
||||
int[] FrameBuffer;
|
||||
|
||||
byte[] PriorityBuffer = new byte[512];
|
||||
byte[] InterSpritePriorityBuffer = new byte[512];
|
||||
private readonly byte[] PriorityBuffer = new byte[512];
|
||||
private readonly byte[] InterSpritePriorityBuffer = new byte[512];
|
||||
|
||||
public void ExecFrame(bool render)
|
||||
{
|
||||
|
@ -188,6 +187,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
VDC2.BackgroundY++;
|
||||
VDC2.BackgroundY &= 0x01FF;
|
||||
}
|
||||
|
||||
if (render) RenderScanLine();
|
||||
}
|
||||
|
||||
|
@ -236,7 +236,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
}
|
||||
}
|
||||
|
||||
void RenderScanLine()
|
||||
private void RenderScanLine()
|
||||
{
|
||||
if (VDC1.ActiveLine >= FrameHeight)
|
||||
return;
|
||||
|
@ -260,7 +260,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
}
|
||||
}
|
||||
|
||||
void InitializeScanLine(int scanline)
|
||||
private void InitializeScanLine(int scanline)
|
||||
{
|
||||
// Clear priority buffer
|
||||
Array.Clear(PriorityBuffer, 0, FrameWidth);
|
||||
|
@ -270,7 +270,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
FrameBuffer[(scanline * FrameWidth) + i] = VCE.Palette[256];
|
||||
}
|
||||
|
||||
unsafe void RenderBackgroundScanline(VDC vdc, byte priority, bool show)
|
||||
private unsafe void RenderBackgroundScanline(VDC vdc, byte priority, bool show)
|
||||
{
|
||||
if (vdc.BackgroundEnabled == false)
|
||||
return;
|
||||
|
@ -339,9 +339,9 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
}
|
||||
}
|
||||
|
||||
static byte[] heightTable = { 16, 32, 64, 64 };
|
||||
private static readonly byte[] heightTable = { 16, 32, 64, 64 };
|
||||
|
||||
void RenderSpritesScanline(VDC vdc, byte lowPriority, byte highPriority, bool show)
|
||||
private void RenderSpritesScanline(VDC vdc, byte lowPriority, byte highPriority, bool show)
|
||||
{
|
||||
if (vdc.SpritesEnabled == false)
|
||||
return;
|
||||
|
@ -517,12 +517,16 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
|||
}
|
||||
}
|
||||
|
||||
public int[] GetVideoBuffer() { return FrameBuffer; }
|
||||
// IVideoProvider implementation
|
||||
public int[] GetVideoBuffer()
|
||||
{
|
||||
return FrameBuffer;
|
||||
}
|
||||
|
||||
public int VirtualWidth { get { return FrameWidth; } }
|
||||
public int VirtualHeight { get { return FrameHeight; } }
|
||||
public int BufferWidth { get { return FrameWidth; } }
|
||||
public int BufferHeight { get { return FrameHeight; } }
|
||||
public int BackgroundColor { get { return VCE.Palette[0]; } }
|
||||
public int VirtualWidth => FrameWidth;
|
||||
public int VirtualHeight => FrameHeight;
|
||||
public int BufferWidth => FrameWidth;
|
||||
public int BufferHeight => FrameHeight;
|
||||
public int BackgroundColor => VCE.Palette[0];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantCaseLabel/@EntryIndexedValue">DO_NOT_SHOW</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantExtendsListEntry/@EntryIndexedValue">DO_NOT_SHOW</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=StyleCop_002ESA1101/@EntryIndexedValue">DO_NOT_SHOW</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=StyleCop_002ESA1108/@EntryIndexedValue">DO_NOT_SHOW</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=StyleCop_002ESA1126/@EntryIndexedValue">DO_NOT_SHOW</s:String>
|
||||
|
|
Loading…
Reference in New Issue