From 298c5256e3450ba2f8c45d6e4757c1ff10d2995b Mon Sep 17 00:00:00 2001 From: zeromus Date: Thu, 18 Mar 2010 18:57:36 +0000 Subject: [PATCH] debug: get rid of excessive "Reading beyond end of cart" messages --- desmume/src/MMU.cpp | 2 +- desmume/src/NDSSystem.cpp | 1 + desmume/src/debug.cpp | 36 +++++++++++++++++++++++++++++++++++- desmume/src/debug.h | 21 ++++++++++++++++++++- 4 files changed, 57 insertions(+), 3 deletions(-) diff --git a/desmume/src/MMU.cpp b/desmume/src/MMU.cpp index 61440ac79..9f22e30c6 100644 --- a/desmume/src/MMU.cpp +++ b/desmume/src/MMU.cpp @@ -1343,7 +1343,7 @@ u32 MMU_readFromGC() if(card.address >= gameInfo.romsize) { - INFO("Reading beyond end of cart! ... %08X > %08X\n",card.address, gameInfo.romsize); + DEBUG_Notify.ReadBeyondEndOfCart(card.address,gameInfo.romsize); } //but, this is actually handled by the cart rom buffer being oversized and full of 0xFF. //is this a good idea? We think so. diff --git a/desmume/src/NDSSystem.cpp b/desmume/src/NDSSystem.cpp index 270e0fd1b..798d59a2a 100644 --- a/desmume/src/NDSSystem.cpp +++ b/desmume/src/NDSSystem.cpp @@ -1911,6 +1911,7 @@ void NDS_exec(s32 nb) lagframecounter = 0; } currFrameCounter++; + DEBUG_Notify.NextFrame(); if (cheats) cheats->process(); } diff --git a/desmume/src/debug.cpp b/desmume/src/debug.cpp index b2403f988..c6255d59c 100644 --- a/desmume/src/debug.cpp +++ b/desmume/src/debug.cpp @@ -203,6 +203,7 @@ void DEBUG_reset() debugFlag = 1; #endif + DEBUG_Notify = DebugNotify(); DEBUG_statistics = DebugStatistics(); printf("DEBUG_reset: %08X\n",&DebugStatistics::print); //force a reference to this function } @@ -346,4 +347,37 @@ void NocashMessage(armcpu_t* cpu) sprintf(tmp,"%lld",nds_timer); todo = mass_replace(todo,"%totalclks%",tmp); printf("%s",todo.c_str()); -} \ No newline at end of file +} + +//------- +DebugNotify DEBUG_Notify; + +//enable bits arent being used right now. +//if you want exhaustive logging, move the print before the early return (or comment the early return) + +//the intent of this system is to provide a compact dialog box showing which debug notifies have been +//triggered in this frame (with a glowing LED!) and which debug notifies have been triggered EVER +//which can be cleared, like a clip indicator in an audio tool. +//obviously all this isnt implemented yet. + +void DebugNotify::NextFrame() +{ +#ifdef DEVELOPER + pingBits.reset(); +#endif +} + +void DebugNotify::ReadBeyondEndOfCart(u32 addr, u32 romsize) +{ +#ifdef DEVELOPER + if(!ping(DEBUG_NOTIFY_READ_BEYOND_END_OF_CART)) return; + INFO("Reading beyond end of cart! ... %08X > %08X\n",addr,romsize); +#endif +} + +bool DebugNotify::ping(EDEBUG_NOTIFY which) +{ + bool wasPinged = pingBits[(int)which]; + pingBits[(int)which] = true; + return !wasPinged; +} diff --git a/desmume/src/debug.h b/desmume/src/debug.h index e966add2e..9a3aeb181 100644 --- a/desmume/src/debug.h +++ b/desmume/src/debug.h @@ -24,6 +24,7 @@ #include #include #include +#include #include "types.h" #include "mem.h" @@ -146,9 +147,27 @@ enum EDEBUG_EVENT DEBUG_EVENT_WRITE=2, //write on arm9 or arm7 bus DEBUG_EVENT_EXECUTE=4, //prefetch on arm9 or arm7, triggered after the read event DEBUG_EVENT_ACL_EXCEPTION=8, //acl exception on arm9 - }; +enum EDEBUG_NOTIFY +{ + DEBUG_NOTIFY_READ_BEYOND_END_OF_CART, + DEBUG_NOTIFY_MAX +}; + +class DebugNotify +{ +public: + void NextFrame(); + void ReadBeyondEndOfCart(u32 addr, u32 romsize); +private: + std::bitset pingBits; + std::bitset enableBits; + bool ping(EDEBUG_NOTIFY which); +}; + +extern DebugNotify DEBUG_Notify; + //information about a debug event will be stuffed into here by the generator struct TDebugEventData {