Skip to content

Commit

Permalink
Debugger: GBA - Fixed performance issue with trace logger
Browse files Browse the repository at this point in the history
  • Loading branch information
SourMesen committed Mar 30, 2024
1 parent 4794934 commit 6468f37
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 9 deletions.
4 changes: 4 additions & 0 deletions Core/GBA/GbaConsole.cpp
Expand Up @@ -11,6 +11,7 @@
#include "GBA/GbaDefaultVideoFilter.h"
#include "GBA/Cart/GbaCart.h"
#include "GBA/APU/GbaApu.h"
#include "GBA/Debugger/DummyGbaCpu.h"
#include "Debugger/DebugTypes.h"
#include "Shared/CheatManager.h"
#include "Shared/BatteryManager.h"
Expand All @@ -26,6 +27,9 @@
GbaConsole::GbaConsole(Emulator* emu)
{
_emu = emu;

GbaCpu::StaticInit();
DummyGbaCpu::StaticInit();
}

GbaConsole::~GbaConsole()
Expand Down
3 changes: 2 additions & 1 deletion Core/GBA/GbaCpu.Arm.cpp
Expand Up @@ -3,7 +3,8 @@
#include "GBA/GbaMemoryManager.h"
#include "Shared/Emulator.h"

static GbaArmOpCategory _armCategory[0x1000] = {};
GbaArmOpCategory GbaCpu::_armCategory[0x1000];
GbaCpu::Func GbaCpu::_armTable[0x1000];

GbaArmOpCategory GbaCpu::GetArmOpCategory(uint32_t opCode)
{
Expand Down
3 changes: 2 additions & 1 deletion Core/GBA/GbaCpu.Thumb.cpp
Expand Up @@ -2,7 +2,8 @@
#include "GBA/GbaCpu.h"
#include "GBA/GbaMemoryManager.h"

static GbaThumbOpCategory _thumbCategory[0x100] = {};
GbaThumbOpCategory GbaCpu::_thumbCategory[0x100];
GbaCpu::Func GbaCpu::_thumbTable[0x100];

GbaThumbOpCategory GbaCpu::GetThumbOpCategory(uint16_t _opCode)
{
Expand Down
9 changes: 6 additions & 3 deletions Core/GBA/GbaCpu.cpp
Expand Up @@ -10,9 +10,6 @@ void GbaCpu::Init(Emulator* emu, GbaMemoryManager* memoryManager)
_emu = emu;
_memoryManager = memoryManager;

InitArmOpTable();
InitThumbOpTable();

_state = {};
_state.Pipeline.ReloadRequested = true;

Expand All @@ -37,6 +34,12 @@ GbaCpu::~GbaCpu()
{
}

void GbaCpu::StaticInit()
{
InitArmOpTable();
InitThumbOpTable();
}

void GbaCpu::SwitchMode(GbaCpuMode mode)
{
//High bit of mode is always set according to psr test
Expand Down
12 changes: 8 additions & 4 deletions Core/GBA/GbaCpu.h
Expand Up @@ -25,8 +25,10 @@ class GbaCpu : public ISerializable
Emulator* _emu = nullptr;

typedef void(GbaCpu::* Func)();
Func _armTable[0x1000] = {};
Func _thumbTable[0x100] = {};
static Func _armTable[0x1000];
static Func _thumbTable[0x100];
static GbaArmOpCategory _armCategory[0x1000];
static GbaThumbOpCategory _thumbCategory[0x100];

uint32_t Add(uint32_t op1, uint32_t op2, bool carry, bool updateFlags);
uint32_t Sub(uint32_t op1, uint32_t op2, bool carry, bool updateFlags);
Expand All @@ -52,7 +54,7 @@ class GbaCpu : public ISerializable

GbaCpuFlags& GetSpsr();

void InitArmOpTable();
static void InitArmOpTable();
void ArmBranchExchangeRegister();
void ArmBranch();
void ArmMsr();
Expand All @@ -69,7 +71,7 @@ class GbaCpu : public ISerializable

bool CheckConditions(uint32_t condCode);

void InitThumbOpTable();
static void InitThumbOpTable();
void ThumbMoveShiftedRegister();
void ThumbAddSubtract();
void ThumbMoveCmpAddSub();
Expand Down Expand Up @@ -120,6 +122,8 @@ class GbaCpu : public ISerializable
public:
virtual ~GbaCpu();

static void StaticInit();

void Init(Emulator* emu, GbaMemoryManager* memoryManager);

static GbaArmOpCategory GetArmOpCategory(uint32_t opCode);
Expand Down

0 comments on commit 6468f37

Please sign in to comment.