gba: implement tracelogging. also disable _ITERATOR_DEBUG_LEVEL even in debug builds as the disassembler blows it up ><
This commit is contained in:
parent
bde940ad0b
commit
6d7ae2574d
|
@ -132,5 +132,19 @@ namespace BizHawk.Emulation.Consoles.Nintendo.GBA
|
|||
/// <returns>IntPtr.Zero if which is unrecognized</returns>
|
||||
[DllImport("libmeteor.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr libmeteor_getmemoryarea(MemoryArea which);
|
||||
|
||||
/// <summary>
|
||||
/// core callback for tracelogging
|
||||
/// </summary>
|
||||
/// <param name="msg">disassembly of an instruction about to be run</param>
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void TraceCallback(string msg);
|
||||
|
||||
/// <summary>
|
||||
/// set callback to run before each instruction is executed
|
||||
/// </summary>
|
||||
/// <param name="callback">null to clear</param>
|
||||
[DllImport("libmeteor.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void libmeteor_settracecallback(TraceCallback callback);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,6 +40,8 @@ namespace BizHawk.Emulation.Consoles.Nintendo.GBA
|
|||
|
||||
if (Controller["Power"])
|
||||
LibMeteor.libmeteor_hardreset();
|
||||
// due to the design of the tracing api, we have to poll whether it's active each frame
|
||||
LibMeteor.libmeteor_settracecallback(CoreInputComm.Tracer.Enabled ? tracecallback : null);
|
||||
if (!coredead)
|
||||
LibMeteor.libmeteor_frameadvance();
|
||||
if (IsLagFrame)
|
||||
|
@ -111,7 +113,8 @@ namespace BizHawk.Emulation.Consoles.Nintendo.GBA
|
|||
CoreOutputComm _CoreOutputComm = new CoreOutputComm
|
||||
{
|
||||
VsyncNum = 262144,
|
||||
VsyncDen = 4389
|
||||
VsyncDen = 4389,
|
||||
CpuTraceAvailable = true
|
||||
};
|
||||
|
||||
public CoreOutputComm CoreOutputComm { get { return _CoreOutputComm; } }
|
||||
|
@ -181,6 +184,8 @@ namespace BizHawk.Emulation.Consoles.Nintendo.GBA
|
|||
LibMeteor.InputCallback inputcallback;
|
||||
/// <summary>true if libmeteor aborted</summary>
|
||||
bool coredead = false;
|
||||
/// <summary>hold pointer to trace callback so it won't get GCed</summary>
|
||||
LibMeteor.TraceCallback tracecallback;
|
||||
|
||||
LibMeteor.Buttons GetInput()
|
||||
{
|
||||
|
@ -279,6 +284,11 @@ namespace BizHawk.Emulation.Consoles.Nintendo.GBA
|
|||
|
||||
#endregion
|
||||
|
||||
void Trace(string msg)
|
||||
{
|
||||
CoreInputComm.Tracer.Put(msg);
|
||||
}
|
||||
|
||||
void Init()
|
||||
{
|
||||
if (attachedcore != null)
|
||||
|
@ -286,6 +296,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo.GBA
|
|||
|
||||
messagecallback = PrintMessage;
|
||||
inputcallback = GetInput;
|
||||
tracecallback = Trace; // don't set this callback now, only set if enabled
|
||||
LibMeteor.libmeteor_setmessagecallback(messagecallback);
|
||||
LibMeteor.libmeteor_setkeycallback(inputcallback);
|
||||
|
||||
|
@ -315,8 +326,10 @@ namespace BizHawk.Emulation.Consoles.Nintendo.GBA
|
|||
LibMeteor.libmeteor_setbuffers(IntPtr.Zero, 240 * 160 * 4, IntPtr.Zero, 4);
|
||||
messagecallback = null;
|
||||
inputcallback = null;
|
||||
tracecallback = null;
|
||||
LibMeteor.libmeteor_setmessagecallback(messagecallback);
|
||||
LibMeteor.libmeteor_setkeycallback(inputcallback);
|
||||
LibMeteor.libmeteor_settracecallback(tracecallback);
|
||||
_MemoryDomains.Clear();
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
|
@ -42,6 +42,21 @@ EXPORT void libmeteor_setkeycallback(uint16_t (*callback)())
|
|||
keycallback = callback;
|
||||
}
|
||||
|
||||
bool traceenabled = false;
|
||||
void (*tracecallback)(const char *msg) = NULL;
|
||||
|
||||
EXPORT void libmeteor_settracecallback(void (*callback)(const char*msg))
|
||||
{
|
||||
tracecallback = callback;
|
||||
traceenabled = tracecallback != NULL;
|
||||
}
|
||||
|
||||
void trace_bizhawk(std::string msg)
|
||||
{
|
||||
if (tracecallback)
|
||||
tracecallback(msg.c_str());
|
||||
}
|
||||
|
||||
EXPORT void libmeteor_hardreset()
|
||||
{
|
||||
AMeteor::Reset(AMeteor::UNIT_ALL ^ (AMeteor::UNIT_MEMORY_BIOS | AMeteor::UNIT_MEMORY_ROM));
|
||||
|
@ -105,17 +120,16 @@ EXPORT void libmeteor_init()
|
|||
static bool first = true;
|
||||
if (first)
|
||||
{
|
||||
// TODO: saveram stuff
|
||||
//AMeteor::_memory.LoadCartInferred();
|
||||
AMeteor::_lcd.GetScreen().GetRenderer().SetFrameSlot(syg::ptr_fun(videocb));
|
||||
AMeteor::_sound.GetSpeaker().SetFrameSlot(syg::ptr_fun(soundcb));
|
||||
// TODO: input
|
||||
first = false;
|
||||
}
|
||||
}
|
||||
|
||||
EXPORT void libmeteor_frameadvance()
|
||||
{
|
||||
//AMeteor::_keypad.SetPadState(0x3ff);
|
||||
AMeteor::Run(10000000);
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBMETEOR_EXPORTS;%(PreprocessorDefinitions);METDEBUG;METDEBUGLOG</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBMETEOR_EXPORTS;%(PreprocessorDefinitions);METDEBUG;METDEBUGLOG;_ITERATOR_DEBUG_LEVEL=0</PreprocessorDefinitions>
|
||||
<DisableSpecificWarnings>4800;4396</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
|
|
|
@ -30,6 +30,8 @@ void print_bizhawk(const char *msg);
|
|||
void print_bizhawk(std::string &msg);
|
||||
void abort_bizhawk(const char *msg);
|
||||
void keyupdate_bizhawk();
|
||||
extern bool traceenabled;
|
||||
void trace_bizhawk(std::string msg);
|
||||
|
||||
#if 0
|
||||
#define met_abort(str) \
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "ameteor.hpp"
|
||||
|
||||
#include "debug.hpp"
|
||||
#include <sstream>
|
||||
|
||||
namespace AMeteor
|
||||
{
|
||||
|
@ -70,7 +71,12 @@ namespace AMeteor
|
|||
met_abort("PC not 16 bit aligned : " << IOS_ADD << R(15));
|
||||
|
||||
code = MEM.Read16(R(15)-2);
|
||||
//std::cerr << IOS_ADD << R(15) << ' ' << Disassembler::Instruction(R(15), (uint16_t)code).ToString() << std::endl;
|
||||
if (traceenabled)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << IOS_ADD << R(15) << ' ' << Disassembler::Instruction(R(15), (uint16_t)code).ToString();
|
||||
trace_bizhawk(ss.str());
|
||||
}
|
||||
R(15) += 2;
|
||||
t_Code();
|
||||
}
|
||||
|
@ -108,7 +114,12 @@ namespace AMeteor
|
|||
else
|
||||
{
|
||||
code = MEM.Read32(R(15)-4);
|
||||
//std::cerr << IOS_ADD << R(15) << ' ' << Disassembler::Instruction(R(15), (uint32_t)code).ToString() << std::endl;
|
||||
if (traceenabled)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << IOS_ADD << R(15) << ' ' << Disassembler::Instruction(R(15), (uint32_t)code).ToString();
|
||||
trace_bizhawk(ss.str());
|
||||
}
|
||||
R(15) += 4;
|
||||
a_Code();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue