Initial support for tools tracking memory reads&writes.
This commit is contained in:
parent
44ea956424
commit
f4ab095a5e
|
@ -12,6 +12,7 @@ file.cpp
|
|||
filter.cpp
|
||||
ines.cpp
|
||||
input.cpp
|
||||
mem-cb.cpp
|
||||
netplay.cpp
|
||||
nsf.cpp
|
||||
palette.cpp
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
#include "types.h"
|
||||
#include "mem-cb.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
struct MEMCALLBACKS memCallbacks;
|
||||
MEMCALLBACKS::~MEMCALLBACKS()
|
||||
{
|
||||
delete read_cb;
|
||||
delete write_cb;
|
||||
}
|
||||
|
||||
void FCEU_AddressReadCallback(uint32 A, readfunc cb)
|
||||
{
|
||||
if (!memCallbacks. read_cb) memCallbacks. read_cb = new map<uint32, readfunc>;
|
||||
(*memCallbacks. read_cb)[FCEU_AddressCanonicalize(A)] = cb;
|
||||
}
|
||||
|
||||
void FCEU_AddressWriteCallback(uint32 A, writefunc cb)
|
||||
{
|
||||
if (!memCallbacks.write_cb) memCallbacks.write_cb = new map<uint32, writefunc>;
|
||||
(*memCallbacks.write_cb)[FCEU_AddressCanonicalize(A)] = cb;
|
||||
}
|
||||
|
||||
uint32 FCEU_AddressCanonicalize(uint32 A)
|
||||
{
|
||||
if (A >= 0x0800 && A < 0x2000) return (A & 0x07FF);
|
||||
return A;
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
#ifndef MEM_CB_H
|
||||
#define MEM_CB_H
|
||||
|
||||
#include <map>
|
||||
|
||||
void FCEU_AddressReadCallback(uint32 A, readfunc cb);
|
||||
void FCEU_AddressWriteCallback(uint32 A, writefunc cb);
|
||||
uint32 FCEU_AddressCanonicalize(uint32 A);
|
||||
|
||||
extern struct MEMCALLBACKS
|
||||
{
|
||||
std::map<uint32, readfunc> * read_cb;
|
||||
std::map<uint32, writefunc> *write_cb;
|
||||
~MEMCALLBACKS();
|
||||
} memCallbacks;
|
||||
|
||||
#endif
|
|
@ -24,6 +24,7 @@
|
|||
#include "fceu.h"
|
||||
#include "debug.h"
|
||||
#include "sound.h"
|
||||
#include "mem-cb.h"
|
||||
|
||||
X6502 X;
|
||||
uint32 timestamp;
|
||||
|
@ -37,39 +38,65 @@ void FP_FASTAPASS(1) (*MapIRQHook)(int a);
|
|||
timestamp+=__x; \
|
||||
}
|
||||
|
||||
static INLINE void RdRunCB(unsigned int A)
|
||||
{
|
||||
if (memCallbacks.read_cb)
|
||||
{
|
||||
std::map<uint32, readfunc>::const_iterator i =
|
||||
memCallbacks.read_cb->find(FCEU_AddressCanonicalize(A));
|
||||
if (i != memCallbacks.read_cb->end()) (i->second)(A);
|
||||
}
|
||||
}
|
||||
|
||||
static INLINE void WrRunCB(unsigned int A, uint8 V)
|
||||
{
|
||||
if (memCallbacks.write_cb)
|
||||
{
|
||||
std::map<uint32, writefunc>::const_iterator i =
|
||||
memCallbacks.write_cb->find(FCEU_AddressCanonicalize(A));
|
||||
if (i != memCallbacks.write_cb->end()) (i->second)(A, V);
|
||||
}
|
||||
}
|
||||
|
||||
//normal memory read
|
||||
static INLINE uint8 RdMem(unsigned int A)
|
||||
{
|
||||
RdRunCB(A);
|
||||
return(_DB=ARead[A](A));
|
||||
}
|
||||
|
||||
//normal memory write
|
||||
static INLINE void WrMem(unsigned int A, uint8 V)
|
||||
{
|
||||
WrRunCB(A, V);
|
||||
BWrite[A](A,V);
|
||||
}
|
||||
|
||||
static INLINE uint8 RdRAM(unsigned int A)
|
||||
{
|
||||
//bbit edited: this was changed so cheat substituion would work
|
||||
RdRunCB(A);
|
||||
return(_DB=ARead[A](A));
|
||||
// return(_DB=RAM[A]);
|
||||
}
|
||||
|
||||
static INLINE void WrRAM(unsigned int A, uint8 V)
|
||||
{
|
||||
WrRunCB(A, V);
|
||||
RAM[A]=V;
|
||||
}
|
||||
|
||||
uint8 FASTAPASS(1) X6502_DMR(uint32 A)
|
||||
{
|
||||
ADDCYC(1);
|
||||
RdRunCB(A);
|
||||
return(X.DB=ARead[A](A));
|
||||
}
|
||||
|
||||
void FASTAPASS(2) X6502_DMW(uint32 A, uint8 V)
|
||||
{
|
||||
ADDCYC(1);
|
||||
WrRunCB(A, V);
|
||||
BWrite[A](A,V);
|
||||
}
|
||||
|
||||
|
|
|
@ -1526,6 +1526,10 @@
|
|||
RelativePath="..\src\input.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\mem-cb.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\memory.h"
|
||||
>
|
||||
|
@ -2256,6 +2260,10 @@
|
|||
RelativePath="..\src\input.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\mem-cb.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\movie.cpp"
|
||||
>
|
||||
|
|
Loading…
Reference in New Issue