Skip to content

Commit e91da0f

Browse files
committed
Scripting: Expose currentCycle in debugger builds
The global time is only maintained in debugger builds for performance reasons. While it can be reconstructed on GBA, this is not the case on GB, so limit it to debugger builds only.
1 parent cd22c14 commit e91da0f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/core/scripting.c

+7
Original file line numberDiff line numberDiff line change
@@ -938,6 +938,10 @@ static bool _mScriptCoreAdapterClearBreakpoint(struct mScriptCoreAdapter* adapte
938938
}
939939
return true;
940940
}
941+
942+
uint64_t _mScriptCoreAdapterCurrentCycle(struct mScriptCoreAdapter* adapter) {
943+
return mTimingGlobalTime(adapter->core->timing);
944+
}
941945
#endif
942946

943947
static void _mScriptCoreAdapterDeinit(struct mScriptCoreAdapter* adapter) {
@@ -1085,6 +1089,7 @@ mSCRIPT_DECLARE_STRUCT_VOID_METHOD(mScriptCoreAdapter, write16, _mScriptCoreAdap
10851089
mSCRIPT_DECLARE_STRUCT_VOID_METHOD(mScriptCoreAdapter, write32, _mScriptCoreAdapterWrite32, 2, U32, address, U32, value);
10861090

10871091
#ifdef ENABLE_DEBUGGERS
1092+
mSCRIPT_DECLARE_STRUCT_METHOD(mScriptCoreAdapter, U64, currentCycle, _mScriptCoreAdapterCurrentCycle, 0);
10881093
mSCRIPT_DECLARE_STRUCT_METHOD_WITH_DEFAULTS(mScriptCoreAdapter, S64, setBreakpoint, _mScriptCoreAdapterSetBreakpoint, 3, WRAPPER, callback, U32, address, S32, segment);
10891094
mSCRIPT_DECLARE_STRUCT_METHOD_WITH_DEFAULTS(mScriptCoreAdapter, S64, setWatchpoint, _mScriptCoreAdapterSetWatchpoint, 4, WRAPPER, callback, U32, address, S32, type, S32, segment);
10901095
mSCRIPT_DECLARE_STRUCT_METHOD_WITH_DEFAULTS(mScriptCoreAdapter, S64, setRangeWatchpoint, _mScriptCoreAdapterSetRangeWatchpoint, 5, WRAPPER, callback, U32, minAddress, U32, maxAddress, S32, type, S32, segment);
@@ -1150,6 +1155,8 @@ mSCRIPT_DEFINE_STRUCT(mScriptCoreAdapter)
11501155
mSCRIPT_DEFINE_STRUCT_METHOD(mScriptCoreAdapter, write16)
11511156
mSCRIPT_DEFINE_STRUCT_METHOD(mScriptCoreAdapter, write32)
11521157
#ifdef ENABLE_DEBUGGERS
1158+
mSCRIPT_DEFINE_DOCSTRING("Get the current execution cycle")
1159+
mSCRIPT_DEFINE_STRUCT_METHOD(mScriptCoreAdapter, currentCycle)
11531160
mSCRIPT_DEFINE_DOCSTRING("Set a breakpoint at a given address")
11541161
mSCRIPT_DEFINE_STRUCT_METHOD(mScriptCoreAdapter, setBreakpoint)
11551162
mSCRIPT_DEFINE_DOCSTRING("Clear a breakpoint or watchpoint for a given id returned by a previous call")

0 commit comments

Comments
 (0)