PCE CDL: fix for street fighter 2 and 384K games. arcade card still not supported

This commit is contained in:
goyuken 2014-02-10 02:47:23 +00:00
parent f80ac18e1f
commit d15c867693
5 changed files with 50 additions and 9 deletions

View File

@ -38,6 +38,7 @@ namespace BizHawk.Client.EmuHawk
emu = (PCEngine)Global.Emulator;
checkBox1.Checked = emu.Cpu.CDLLoggingActive;
CDL = emu.Cpu.CDL;
emu.InitCDLMappings();
UpdateDisplay();
}
else

View File

@ -72,8 +72,8 @@ namespace BizHawk.Emulation.Cores.Components.H6280
Dictionary<string, int> sizes = new Dictionary<string, int>();
foreach (var m in mm)
{
if (!sizes.ContainsKey(m.Name) || m.Offs >= sizes[m.Name])
sizes[m.Name] = m.Offs;
if (!sizes.ContainsKey(m.Name) || m.MaxOffs >= sizes[m.Name])
sizes[m.Name] = m.MaxOffs;
}
foreach (var kvp in sizes)
@ -91,7 +91,10 @@ namespace BizHawk.Emulation.Cores.Components.H6280
{
public string Name;
public int Offs;
public int VOffs; // if non-zero, specifies a larger potential offset
public int MaxOffs { get { return Math.Max(Offs, VOffs); } }
}
public MemMapping[] Mappings; // = new MemMapping[256];
public CodeDataLog CDL = null;

View File

@ -9,9 +9,9 @@ namespace BizHawk.Emulation.Cores.PCEngine
{
partial class PCEngine
{
static void CDLMappingApplyRange(HuC6280.MemMapping[] mm, string name, int block, int len)
static void CDLMappingApplyRange(HuC6280.MemMapping[] mm, string name, int block, int len, int initialoffs = 0)
{
for (int i = block, offs = 0; i < 256 && len > offs; i++, offs += 8192)
for (int i = block, offs = initialoffs; i < 256 && len > (offs - initialoffs); i++, offs += 8192)
{
mm[i].Name = name;
mm[i].Offs = offs;
@ -21,15 +21,44 @@ namespace BizHawk.Emulation.Cores.PCEngine
/// <summary>
/// informs the CPU of the general memory layout, so it can do CDL
/// </summary>
void InitCDLMappings()
public void InitCDLMappings()
{
// todo: arcade card
if (Cpu.Mappings != null)
return;
SF2UpdateCDLMappings = true;
var mm = new HuC6280.MemMapping[256];
CDLMappingApplyRange(mm, "ROM", 0x00, RomLength);
CDLMappingApplyRange(mm, "ROM", 0x00, Math.Min(RomLength, 1024 * 1024));
if (PopulousRAM != null)
CDLMappingApplyRange(mm, "Cart Battery RAM",, 0x40, PopulousRAM.Length);
CDLMappingApplyRange(mm, "Cart Battery RAM", 0x40, PopulousRAM.Length);
// actual games came in 128K, 256K, 384K, 512K, 768K, 1024K, and Street Fighter sizes
// except street fighter, games were on 1 or 2 mask roms
// 1 maskrom: POT size rom, high address lines ignored, mirrored throughout 1M
// 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++)
{
// mark as unknown mirrors
mm[i].Name = null;
}
for (int i = 0x40; i < 0x50; i++)
{
// rebase
mm[i].Offs -= 0x40000;
}
}
if (RomLength > 1024 * 1024)
{
mm[0x7f].VOffs = 0x27e000; // hint that the total size of this domain will be 2.5MiB
}
if (SuperRam != null)
CDLMappingApplyRange(mm, "Super System Card RAM", 0x68, SuperRam.Length);

View File

@ -9,6 +9,9 @@ namespace BizHawk.Emulation.Cores.PCEngine
byte SF2MapperLatch;
// when true, every mapper register write is propogated to the vtable that the CDL uses
bool SF2UpdateCDLMappings = false;
byte ReadMemorySF2(int addr)
{
if (addr < 0x7FFFF) // read ROM
@ -43,6 +46,12 @@ namespace BizHawk.Emulation.Cores.PCEngine
{
// Set SF2 pager.
SF2MapperLatch = (byte)(addr & 0x03);
if (SF2UpdateCDLMappings)
{
CDLMappingApplyRange(Cpu.Mappings, "ROM", 0x40, 0x80000, (SF2MapperLatch + 1) * 0x80000);
}
return;
}

View File

@ -236,7 +236,6 @@ namespace BizHawk.Emulation.Cores.PCEngine
Cpu.ResetPC();
SetupMemoryDomains();
SetupStateBuff();
InitCDLMappings();
}
int _lagcount = 0;