PCE tweaks

finish up memory domains
make bram behave like pcehawk, instead of giving it to every game, only give it to games that had it
finish up ppu view
This commit is contained in:
nattthebear 2020-05-27 07:35:51 -04:00
parent 0891e448d7
commit b0620ca79d
4 changed files with 72 additions and 27 deletions

Binary file not shown.

View File

@ -21,6 +21,8 @@ namespace BizHawk.Emulation.Cores.Consoles.NEC.PCE
NymaSettings settings, NymaSyncSettings syncSettings)
: base(comm, "PCE", "PC Engine Controller", settings, syncSettings)
{
if (game["BRAM"])
SettingsOverrides["pce.disable_bram_hucard"] = "0";
_terboGrafix = DoInit<LibTerboGrafix>(game, rom, null, "pce.wbx", extension);
}
public TerboGrafix(GameInfo game, Disc[] discs, CoreComm comm,
@ -39,14 +41,16 @@ namespace BizHawk.Emulation.Cores.Consoles.NEC.PCE
public override string SystemId => IsSgx ? "SGX" : "PCE";
protected override ICollection<string> HiddenSettings { get; } = new[]
protected override IDictionary<string, string> SettingsOverrides { get; } = new Dictionary<string, string>
{
// handled by hawk
"pce.cdbios",
"pce.gecdbios",
{ "pce.cdbios", null },
{ "pce.gecdbios", null },
// so fringe i don't want people bothering me about it
"pce.resamp_rate_error",
"pce.vramsize",
{ "pce.resamp_rate_error", null },
{ "pce.vramsize", null },
// match hawk behavior on BRAM, instead of giving every game BRAM
{ "pce.disable_bram_hucard", "1" },
};
// pce always has two layers, sgx always has 4, and mednafen knows this

View File

@ -14,8 +14,9 @@ namespace BizHawk.Emulation.Cores.Waterbox
{
/// <summary>
/// Settings that we shouldn't show the user
/// If the value is null, use the default value, otherwise override it
/// </summary>
protected virtual ICollection<string> HiddenSettings { get; } = new string[0];
protected virtual IDictionary<string, string> SettingsOverrides { get; } = new Dictionary<string, string>();
public NymaSettingsInfo SettingsInfo { get; private set; }
private NymaSettings _settings;
private NymaSyncSettings _syncSettings;
@ -96,17 +97,22 @@ namespace BizHawk.Emulation.Cores.Waterbox
private void SettingsQuery(string name, IntPtr dest)
{
if (!_syncSettingsActual.MednafenValues.TryGetValue(name, out var val) || HiddenSettings.Contains(name))
SettingsOverrides.TryGetValue(name, out var val);
if (val == null)
{
if (SettingsInfo.SettingsByKey.TryGetValue(name, out var info))
if (!_syncSettingsActual.MednafenValues.TryGetValue(name, out val))
{
val = info.DefaultValue;
}
else
{
throw new InvalidOperationException($"Core asked for setting {name} which was not found in the defaults");
if (SettingsInfo.SettingsByKey.TryGetValue(name, out var info))
{
val = info.DefaultValue;
}
else
{
throw new InvalidOperationException($"Core asked for setting {name} which was not found in the defaults");
}
}
}
var bytes = Encoding.UTF8.GetBytes(val);
if (bytes.Length > 255)
throw new InvalidOperationException($"Value {val} for setting {name} was too long");
@ -313,7 +319,7 @@ namespace BizHawk.Emulation.Cores.Waterbox
}
}
s.HiddenSettings = new HashSet<string>(HiddenSettings);
s.HiddenSettings = new HashSet<string>(SettingsOverrides.Keys);
SettingsInfo = s;
}
}

View File

@ -20,6 +20,7 @@ void SetupMDFNGameInfo()
#define DEFUN(N,R,W)\
static void Access##N(uint8_t* buffer, int64_t address, int64_t count, bool write)\
{\
PCE_InDebug = 1;\
if (write)\
{\
while (count--)\
@ -30,10 +31,12 @@ static void Access##N(uint8_t* buffer, int64_t address, int64_t count, bool writ
while (count--)\
*buffer++ = R(address++);\
}\
PCE_InDebug = 0;\
}
#define DEFRG(N,R,W)\
static void Access##N(uint8_t* buffer, int64_t address, int64_t count, bool write)\
{\
PCE_InDebug = 1;\
if (write)\
{\
W(address, count, buffer);\
@ -42,6 +45,7 @@ static void Access##N(uint8_t* buffer, int64_t address, int64_t count, bool writ
{\
R(address, count, buffer);\
}\
PCE_InDebug = 0;\
}
namespace MDFN_IEN_PCE
@ -56,8 +60,8 @@ namespace MDFN_IEN_PCE
}
}
// DEFUN(ShortBus, HuCPU.PeekLogical, HuCPU.PokeLogical);
// DEFUN(LongBus, HuCPU.PeekPhysical, HuCPU.PokePhysical);
DEFUN(ShortBus, HuCPU.PeekLogical, HuCPU.PokeLogical);
DEFUN(LongBus, HuCPU.PeekPhysical, HuCPU.PokePhysical);
DEFUN(BRAM, HuC_PeekBRAM, HuC_PokeBRAM);
DEFRG(ADPCM, ADPCM_PeekRAM, ADPCM_PokeRAM);
@ -66,18 +70,17 @@ ECL_EXPORT void GetMemoryAreas(MemoryArea* m)
CheatArea* c;
int i = 0;
// TOOD: These two cause the core to assert with a timestamp problem?
// m[i].Data = (void*)(MemoryFunctionHook)AccessLongBus;
// m[i].Name = "System Bus (21 bit)";
// m[i].Size = 1 << 21;
// m[i].Flags = MEMORYAREA_FLAGS_WRITABLE | MEMORYAREA_FLAGS_WORDSIZE1 | MEMORYAREA_FLAGS_FUNCTIONHOOK;
// i++;
m[i].Data = (void*)(MemoryFunctionHook)AccessLongBus;
m[i].Name = "System Bus (21 bit)";
m[i].Size = 1 << 21;
m[i].Flags = MEMORYAREA_FLAGS_WRITABLE | MEMORYAREA_FLAGS_WORDSIZE1 | MEMORYAREA_FLAGS_FUNCTIONHOOK;
i++;
// m[i].Data = (void*)(MemoryFunctionHook)AccessShortBus;
// m[i].Name = "System Bus";
// m[i].Size = 1 << 16;
// m[i].Flags = MEMORYAREA_FLAGS_WRITABLE | MEMORYAREA_FLAGS_WORDSIZE1 | MEMORYAREA_FLAGS_FUNCTIONHOOK;
// i++;
m[i].Data = (void*)(MemoryFunctionHook)AccessShortBus;
m[i].Name = "System Bus";
m[i].Size = 1 << 16;
m[i].Flags = MEMORYAREA_FLAGS_WRITABLE | MEMORYAREA_FLAGS_WORDSIZE1 | MEMORYAREA_FLAGS_FUNCTIONHOOK;
i++;
c = FindCheatArea(0xf8 * 8192);
m[i].Data = c->data;
@ -170,4 +173,36 @@ ECL_EXPORT void GetVramInfo(VramInfo& v, int vdcIndex)
v.BackgroundCache = (uint8_t*)vdc.bg_tile_cache;
v.SpriteCache = SpriteCache;
v.Vram = vdc.VRAM;
uint16_t* ssrc = vdc.VRAM;
uint8_t* sdst = SpriteCache;
for (int spriteNum = 0; spriteNum < 512; spriteNum++)
{
auto lsrc = ssrc;
auto ldst = sdst;
for (int line = 0; line < 16; line++)
{
auto a = lsrc[0], b = lsrc[16], c = lsrc[32], d = lsrc[48];
*ldst++ = a >> 15 & 1 | b >> 14 & 2 | c >> 13 & 4 | d >> 12 & 8;
*ldst++ = a >> 14 & 1 | b >> 13 & 2 | c >> 12 & 4 | d >> 11 & 8;
*ldst++ = a >> 13 & 1 | b >> 12 & 2 | c >> 11 & 4 | d >> 10 & 8;
*ldst++ = a >> 12 & 1 | b >> 11 & 2 | c >> 10 & 4 | d >> 9 & 8;
*ldst++ = a >> 11 & 1 | b >> 10 & 2 | c >> 9 & 4 | d >> 8 & 8;
*ldst++ = a >> 10 & 1 | b >> 9 & 2 | c >> 8 & 4 | d >> 7 & 8;
*ldst++ = a >> 9 & 1 | b >> 8 & 2 | c >> 7 & 4 | d >> 6 & 8;
*ldst++ = a >> 8 & 1 | b >> 7 & 2 | c >> 6 & 4 | d >> 5 & 8;
*ldst++ = a >> 7 & 1 | b >> 6 & 2 | c >> 5 & 4 | d >> 4 & 8;
*ldst++ = a >> 6 & 1 | b >> 5 & 2 | c >> 4 & 4 | d >> 3 & 8;
*ldst++ = a >> 5 & 1 | b >> 4 & 2 | c >> 3 & 4 | d >> 2 & 8;
*ldst++ = a >> 4 & 1 | b >> 3 & 2 | c >> 2 & 4 | d >> 1 & 8;
*ldst++ = a >> 3 & 1 | b >> 2 & 2 | c >> 1 & 4 | d >> 0 & 8;
*ldst++ = a >> 2 & 1 | b >> 1 & 2 | c >> 0 & 4 | d << 1 & 8;
*ldst++ = a >> 1 & 1 | b >> 0 & 2 | c << 1 & 4 | d << 2 & 8;
*ldst++ = a >> 0 & 1 | b << 1 & 2 | c << 2 & 4 | d << 3 & 8;
lsrc += 1;
}
ssrc += 64;
sdst += 256;
}
}