Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added new value to write callback. #25

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libgambatte/include/gambatte.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace gambatte {

enum { BG_PALETTE = 0, SP1_PALETTE = 1, SP2_PALETTE = 2 };

typedef void (*MemoryCallback)(int32_t address, int64_t cycleOffset);
typedef void (*MemoryCallback)(int32_t address, int64_t cycleOffset, uint32_t data);
typedef void (*CDCallback)(int32_t addr, int32_t addrtype, int32_t flags);

enum eCDLog_AddrType {
Expand Down
10 changes: 5 additions & 5 deletions libgambatte/src/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class Memory {
template <bool callbacksActive>
unsigned ff_read(unsigned p, unsigned long cc) {
if (callbacksActive && readCallback_)
readCallback_(p, callbackCycleOffset(cc));
readCallback_(p, callbackCycleOffset(cc), 0);

return p < 0x80 ? nontrivial_ff_read(p, cc) : ioamhram_[p + 0x100];
}
Expand Down Expand Up @@ -145,9 +145,9 @@ class Memory {
template <bool peek, bool execute, bool opcode, bool callbacksActive>
unsigned read(unsigned p, unsigned long cc) {
if (!peek && callbacksActive && !execute && readCallback_)
readCallback_(p, callbackCycleOffset(cc));
readCallback_(p, callbackCycleOffset(cc), 0);
else if (!peek && callbacksActive && execute && opcode && execCallback_)
execCallback_(p, callbackCycleOffset(cc));
execCallback_(p, callbackCycleOffset(cc), 0);

if (biosMode_ && p < bios_.size() && !(p >= 0x100 && p < 0x200))
return readBios(p);
Expand Down Expand Up @@ -223,7 +223,7 @@ class Memory {

if (!poke && callbacksActive) {
if (writeCallback_)
writeCallback_(p, callbackCycleOffset(cc));
writeCallback_(p, callbackCycleOffset(cc), data);

if (cdCallback_ && !biosMode_) {
CDMapResult map = CDMap(p);
Expand All @@ -241,7 +241,7 @@ class Memory {
nontrivial_ff_write(p, data, cc);

if (callbacksActive && writeCallback_)
writeCallback_(mm_io_begin + p, callbackCycleOffset(cc));
writeCallback_(mm_io_begin + p, callbackCycleOffset(cc), data);
if (callbacksActive && cdCallback_ && !biosMode_) {
CDMapResult map = CDMap(mm_io_begin + p);
if (map.type != eCDLog_AddrType_None)
Expand Down