add CARTROM-DB and CARTROM-D blocks to libsnes CDL
This commit is contained in:
parent
b7c821f8d6
commit
f580773342
|
@ -28,7 +28,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
|||
{
|
||||
static LibsnesApi()
|
||||
{
|
||||
if (sizeof(CommStruct) != 280)
|
||||
if (sizeof(CommStruct) != 376)
|
||||
{
|
||||
throw new InvalidOperationException("sizeof(comm)");
|
||||
}
|
||||
|
@ -340,19 +340,19 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
|||
|
||||
[FieldOffset(128)]
|
||||
//bleck. this is a long so that it can be a 32/64bit pointer
|
||||
public fixed long cdl_ptr[8];
|
||||
[FieldOffset(192)]
|
||||
public fixed int cdl_size[8];
|
||||
public fixed long cdl_ptr[16];
|
||||
[FieldOffset(256)]
|
||||
public fixed int cdl_size[16];
|
||||
|
||||
[FieldOffset(224)]
|
||||
[FieldOffset(320)]
|
||||
public CPURegs cpuregs;
|
||||
[FieldOffset(260)]
|
||||
[FieldOffset(356)]
|
||||
public LayerEnables layerEnables;
|
||||
|
||||
[FieldOffset(272)]
|
||||
[FieldOffset(368)]
|
||||
//static configuration-type information which can be grabbed off the core at any time without even needing a QUERY command
|
||||
public SNES_REGION region;
|
||||
[FieldOffset(276)]
|
||||
[FieldOffset(372)]
|
||||
public SNES_MAPPER mapper;
|
||||
|
||||
//utilities
|
||||
|
|
|
@ -158,7 +158,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
|||
|
||||
using (_exe.EnterExit())
|
||||
{
|
||||
for (int i = 0; i < 8; i++)
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
_comm->cdl_ptr[i] = 0;
|
||||
_comm->cdl_size[i] = 0;
|
||||
|
@ -166,37 +166,57 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
|||
|
||||
if (cdl != null)
|
||||
{
|
||||
_comm->cdl_ptr[0] = cdl.GetPin("CARTROM").ToInt64();
|
||||
_comm->cdl_size[0] = cdl["CARTROM"].Length;
|
||||
int zz = 0;
|
||||
|
||||
_comm->cdl_ptr[zz] = cdl.GetPin("CARTROM").ToInt64();
|
||||
_comm->cdl_size[zz] = cdl["CARTROM"].Length;
|
||||
zz++;
|
||||
|
||||
_comm->cdl_ptr[zz] = cdl.GetPin("CARTROM-DB").ToInt64();
|
||||
_comm->cdl_size[zz] = cdl["CARTROM"].Length;
|
||||
zz++;
|
||||
|
||||
_comm->cdl_ptr[zz] = cdl.GetPin("CARTROM-D").ToInt64();
|
||||
_comm->cdl_size[zz] = cdl["CARTROM"].Length;
|
||||
zz++;
|
||||
|
||||
if (cdl.Has("CARTRAM"))
|
||||
{
|
||||
_comm->cdl_ptr[1] = cdl.GetPin("CARTRAM").ToInt64();
|
||||
_comm->cdl_size[1] = cdl["CARTRAM"].Length;
|
||||
_comm->cdl_ptr[zz] = cdl.GetPin("CARTRAM").ToInt64();
|
||||
_comm->cdl_size[zz] = cdl["CARTRAM"].Length;
|
||||
}
|
||||
zz++;
|
||||
|
||||
_comm->cdl_ptr[2] = cdl.GetPin("WRAM").ToInt64();
|
||||
_comm->cdl_size[2] = cdl["WRAM"].Length;
|
||||
_comm->cdl_ptr[zz] = cdl.GetPin("WRAM").ToInt64();
|
||||
_comm->cdl_size[zz] = cdl["WRAM"].Length;
|
||||
zz++;
|
||||
|
||||
_comm->cdl_ptr[3] = cdl.GetPin("APURAM").ToInt64();
|
||||
_comm->cdl_size[3] = cdl["APURAM"].Length;
|
||||
_comm->cdl_ptr[zz] = cdl.GetPin("APURAM").ToInt64();
|
||||
_comm->cdl_size[zz] = cdl["APURAM"].Length;
|
||||
zz++;
|
||||
|
||||
if (cdl.Has("SGB_CARTROM"))
|
||||
{
|
||||
_comm->cdl_ptr[4] = cdl.GetPin("SGB_CARTROM").ToInt64();
|
||||
_comm->cdl_size[4] = cdl["SGB_CARTROM"].Length;
|
||||
_comm->cdl_ptr[zz] = cdl.GetPin("SGB_CARTROM").ToInt64();
|
||||
_comm->cdl_size[zz] = cdl["SGB_CARTROM"].Length;
|
||||
zz++;
|
||||
|
||||
if (cdl.Has("SGB_CARTRAM"))
|
||||
{
|
||||
_comm->cdl_ptr[5] = cdl.GetPin("SGB_CARTRAM").ToInt64();
|
||||
_comm->cdl_size[5] = cdl["SGB_CARTRAM"].Length;
|
||||
_comm->cdl_ptr[zz] = cdl.GetPin("SGB_CARTRAM").ToInt64();
|
||||
_comm->cdl_size[zz] = cdl["SGB_CARTRAM"].Length;
|
||||
}
|
||||
zz++;
|
||||
|
||||
_comm->cdl_ptr[6] = cdl.GetPin("SGB_WRAM").ToInt64();
|
||||
_comm->cdl_size[6] = cdl["SGB_WRAM"].Length;
|
||||
_comm->cdl_ptr[zz] = cdl.GetPin("SGB_WRAM").ToInt64();
|
||||
_comm->cdl_size[zz] = cdl["SGB_WRAM"].Length;
|
||||
zz++;
|
||||
|
||||
_comm->cdl_ptr[7] = cdl.GetPin("SGB_HRAM").ToInt64();
|
||||
_comm->cdl_size[7] = cdl["SGB_HRAM"].Length;
|
||||
_comm->cdl_ptr[zz] = cdl.GetPin("SGB_HRAM").ToInt64();
|
||||
_comm->cdl_size[zz] = cdl["SGB_HRAM"].Length;
|
||||
zz++;
|
||||
}
|
||||
else zz += 4;
|
||||
}
|
||||
|
||||
_core.Message(eMessage.eMessage_QUERY_set_cdl);
|
||||
|
|
|
@ -18,6 +18,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
|||
public void NewCDL(ICodeDataLog cdl)
|
||||
{
|
||||
cdl["CARTROM"] = new byte[_memoryDomains["CARTROM"].Size];
|
||||
cdl["CARTROM-DB"] = new byte[_memoryDomains["CARTROM"].Size];
|
||||
cdl["CARTROM-D"] = new byte[_memoryDomains["CARTROM"].Size*2];
|
||||
cdl["WRAM"] = new byte[_memoryDomains["WRAM"].Size];
|
||||
cdl["APURAM"] = new byte[_memoryDomains["APURAM"].Size];
|
||||
|
||||
|
|
|
@ -1,3 +1,12 @@
|
|||
#include "base.hpp"
|
||||
|
||||
#include "snes/snes.hpp"
|
||||
|
||||
CDLInfo cdlInfo;
|
||||
|
||||
void CDLInfo::dorom(uint32_t addr)
|
||||
{
|
||||
blocks[eCDLog_AddrType_CARTROM_DB][addr] = SNES::cpu.regs.db;
|
||||
blocks[eCDLog_AddrType_CARTROM_D][addr*2+0] = SNES::cpu.regs.d;
|
||||
blocks[eCDLog_AddrType_CARTROM_D][addr*2+1] = SNES::cpu.regs.d>>8;
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ template<typename R, typename... P> struct hook<R (P...)> {
|
|||
|
||||
enum eCDLog_AddrType
|
||||
{
|
||||
eCDLog_AddrType_CARTROM, eCDLog_AddrType_CARTRAM, eCDLog_AddrType_WRAM, eCDLog_AddrType_APURAM,
|
||||
eCDLog_AddrType_CARTROM, eCDLog_AddrType_CARTROM_DB, eCDLog_AddrType_CARTROM_D, eCDLog_AddrType_CARTRAM, eCDLog_AddrType_WRAM, eCDLog_AddrType_APURAM,
|
||||
eCDLog_AddrType_SGB_CARTROM, eCDLog_AddrType_SGB_CARTRAM, eCDLog_AddrType_SGB_WRAM, eCDLog_AddrType_SGB_HRAM,
|
||||
eCDLog_AddrType_NUM
|
||||
};
|
||||
|
@ -76,15 +76,20 @@ enum eCDLog_Flags
|
|||
struct CDLInfo
|
||||
{
|
||||
eCDLog_Flags currFlags;
|
||||
uint8_t* blocks[eCDLog_AddrType_NUM]; //[0]==nullptr -> disabled
|
||||
uint32_t blockSizes[eCDLog_AddrType_NUM];
|
||||
uint8_t* blocks[16]; //[0]==nullptr -> disabled
|
||||
uint32_t blockSizes[16];
|
||||
void set(eCDLog_AddrType addrType, uint32_t addr)
|
||||
{
|
||||
if(!blocks[0]) return;
|
||||
if(addr >= blockSizes[addrType])
|
||||
return;
|
||||
blocks[addrType][addr] |= currFlags;
|
||||
if(addrType == eCDLog_AddrType_CARTROM)
|
||||
{
|
||||
dorom(addr);
|
||||
}
|
||||
}
|
||||
void dorom(uint32_t addr);
|
||||
};
|
||||
|
||||
extern CDLInfo cdlInfo;
|
||||
|
|
|
@ -109,7 +109,7 @@ enum eStatus : int32
|
|||
#endif
|
||||
struct CPURegsComm {
|
||||
u32 pc;
|
||||
u16 a, x, y, z, s, d, vector; //7x
|
||||
u16 a, x, y, s, d, vector; //7x
|
||||
u8 p, nothing;
|
||||
u32 aa, rd;
|
||||
u8 sp, dp, db, mdr;
|
||||
|
@ -165,8 +165,8 @@ struct CommStruct
|
|||
|
||||
int32 padding3;
|
||||
|
||||
int64 cdl_ptr[8];
|
||||
int32 cdl_size[8];
|
||||
int64 cdl_ptr[16];
|
||||
int32 cdl_size[16];
|
||||
|
||||
CPURegsComm cpuregs;
|
||||
LayerEnablesComm layerEnables;
|
||||
|
@ -525,10 +525,9 @@ void QUERY_peek_cpu_regs() {
|
|||
comm.cpuregs.a = SNES::cpu.regs.a;
|
||||
comm.cpuregs.x = SNES::cpu.regs.x;
|
||||
comm.cpuregs.y = SNES::cpu.regs.y;
|
||||
comm.cpuregs.z = SNES::cpu.regs.z;
|
||||
comm.cpuregs.s = SNES::cpu.regs.s;
|
||||
comm.cpuregs.d = SNES::cpu.regs.d;
|
||||
comm.cpuregs.aa = (u32)SNES::cpu.aa;
|
||||
//comm.cpuregs.aa = (u32)SNES::cpu.aa;
|
||||
comm.cpuregs.rd = (u32)SNES::cpu.rd;
|
||||
comm.cpuregs.sp = SNES::cpu.sp;
|
||||
comm.cpuregs.dp = SNES::cpu.dp;
|
||||
|
@ -541,7 +540,7 @@ void QUERY_peek_cpu_regs() {
|
|||
comm.cpuregs.h = SNES::cpu.hdot();
|
||||
}
|
||||
void QUERY_peek_set_cdl() {
|
||||
for (int i = 0; i<eCDLog_AddrType_NUM; i++)
|
||||
for (int i = 0; i<16; i++)
|
||||
{
|
||||
cdlInfo.blocks[i] = (uint8*)comm.cdl_ptr[i];
|
||||
cdlInfo.blockSizes[i] = comm.cdl_size[i];
|
||||
|
@ -624,13 +623,13 @@ EXPORT void* DllInit()
|
|||
T(buf, 88);
|
||||
T(buf_size, 112);
|
||||
T(cdl_ptr, 128);
|
||||
T(cdl_size, 192);
|
||||
T(cpuregs, 224);
|
||||
T(layerEnables, 260);
|
||||
T(region, 272);
|
||||
T(mapper, 276);
|
||||
T(cdl_size, 256);
|
||||
T(cpuregs, 320);
|
||||
T(layerEnables, 356);
|
||||
T(region, 368);
|
||||
T(mapper, 372);
|
||||
// start of private stuff
|
||||
T(privbuf, 280);
|
||||
T(privbuf, 376);
|
||||
#undef T
|
||||
|
||||
memset(&comm, 0, sizeof(comm));
|
||||
|
|
Loading…
Reference in New Issue