diff --git a/Core/BarcodeBattlerReader.h b/Core/BarcodeBattlerReader.h index 8cd0b423..27f31a50 100644 --- a/Core/BarcodeBattlerReader.h +++ b/Core/BarcodeBattlerReader.h @@ -12,7 +12,7 @@ private: uint32_t _newBarcodeDigitCount = 0; uint8_t _barcodeStream[BarcodeBattlerReader::StreamSize]; - int32_t _insertCycle = 0; + uint64_t _insertCycle = 0; protected: void StreamState(bool saving) override @@ -88,10 +88,10 @@ public: uint8_t ReadRAM(uint16_t addr) override { if(addr == 0x4017) { - int32_t elapsedCycles = _console->GetCpu()->GetElapsedCycles(_insertCycle); + uint64_t elapsedCycles = _console->GetCpu()->GetCycleCount() - _insertCycle; constexpr uint32_t cyclesPerBit = CPU::ClockRateNtsc / 1200; - uint32_t streamPosition = elapsedCycles / cyclesPerBit; + uint32_t streamPosition = (uint32_t)(elapsedCycles / cyclesPerBit); if(streamPosition < BarcodeBattlerReader::StreamSize) { return _barcodeStream[streamPosition] << 2; } diff --git a/Core/CPU.h b/Core/CPU.h index 9fc2e6d2..bc963a36 100644 --- a/Core/CPU.h +++ b/Core/CPU.h @@ -31,7 +31,7 @@ public: private: typedef void(CPU::*Func)(); - int32_t _cycleCount; + uint64_t _cycleCount; uint16_t _operand; Func _opTable[256]; @@ -777,17 +777,7 @@ protected: public: CPU(shared_ptr console); - int32_t GetCycleCount() { return _cycleCount; } - - int32_t GetElapsedCycles(int32_t prevCycleCount) - { - if(prevCycleCount > _cycleCount) { - return 0xFFFFFFFF - prevCycleCount + _cycleCount + 1; - } else { - return _cycleCount - prevCycleCount; - } - } - + uint64_t GetCycleCount() { return _cycleCount; } void SetNmiFlag() { _state.NMIFlag = true; } void ClearNmiFlag() { _state.NMIFlag = false; } void SetIrqMask(uint8_t mask) { _irqMask = mask; } diff --git a/Core/Console.cpp b/Core/Console.cpp index b7bc6a96..baa4953e 100644 --- a/Core/Console.cpp +++ b/Core/Console.cpp @@ -687,11 +687,11 @@ void Console::RunSingleFrame() void Console::RunSlaveCpu() { - int32_t cycleGap; + int64_t cycleGap; while(true) { //Run the slave until it catches up to the master CPU (and take into account the CPU count overflow that occurs every ~20mins) - cycleGap = _cpu->GetCycleCount() - _slave->_cpu->GetCycleCount(); - if(cycleGap > 5 || cycleGap < -10000 || _ppu->GetFrameCount() > _slave->_ppu->GetFrameCount()) { + cycleGap = (int64_t)(_cpu->GetCycleCount() - _slave->_cpu->GetCycleCount()); + if(cycleGap > 5 || _ppu->GetFrameCount() > _slave->_ppu->GetFrameCount()) { _slave->_cpu->Exec(); } else { break; diff --git a/Core/DatachBarcodeReader.h b/Core/DatachBarcodeReader.h index 9e9589f0..d207689c 100644 --- a/Core/DatachBarcodeReader.h +++ b/Core/DatachBarcodeReader.h @@ -9,7 +9,7 @@ class DatachBarcodeReader : public BaseControlDevice, public IBarcodeReader { private: vector _data; - int32_t _insertCycle = 0; + uint64_t _insertCycle = 0; uint64_t _newBarcode = 0; uint32_t _newBarcodeDigitCount = 0; @@ -53,9 +53,9 @@ public: uint8_t GetOutput() { - int32_t elapsedCycles = _console->GetCpu()->GetElapsedCycles(_insertCycle); - int32_t bitNumber = elapsedCycles / 1000; - if(bitNumber < (int32_t)_data.size()) { + uint64_t elapsedCycles = _console->GetCpu()->GetCycleCount() - _insertCycle; + uint32_t bitNumber = (uint32_t)(elapsedCycles / 1000); + if(bitNumber < (uint32_t)_data.size()) { return _data[bitNumber]; } else { return 0; diff --git a/Core/Debugger.h b/Core/Debugger.h index 28aacd24..02962a18 100644 --- a/Core/Debugger.h +++ b/Core/Debugger.h @@ -130,13 +130,13 @@ private: uint16_t _ppuScrollX; uint16_t _ppuScrollY; - int32_t _prevInstructionCycle; - int32_t _curInstructionCycle; - int32_t _runToCycle; + uint64_t _prevInstructionCycle; + uint64_t _curInstructionCycle; + uint64_t _runToCycle; bool _needRewind; vector _rewindCache; - vector _rewindPrevInstructionCycleCache; + vector _rewindPrevInstructionCycleCache; uint32_t _inputOverride[4]; diff --git a/Core/FamilyBasicDataRecorder.h b/Core/FamilyBasicDataRecorder.h index c89f8a51..92c8ef1c 100644 --- a/Core/FamilyBasicDataRecorder.h +++ b/Core/FamilyBasicDataRecorder.h @@ -13,7 +13,7 @@ private: vector _fileData; bool _enabled = false; bool _isPlaying = false; - int32_t _cycle = -1; + uint64_t _cycle = 0; bool _isRecording = false; string _recordFilePath; @@ -115,9 +115,9 @@ public: uint8_t ReadRAM(uint16_t addr) override { if(addr == 0x4016 && _isPlaying) { - int32_t readPos = _console->GetCpu()->GetElapsedCycles(_cycle) / FamilyBasicDataRecorder::SamplingRate; + uint32_t readPos = (uint32_t)((_console->GetCpu()->GetCycleCount() / _cycle) / FamilyBasicDataRecorder::SamplingRate); - if((int32_t)_data.size() > readPos / 8) { + if((uint32_t)_data.size() > readPos / 8) { uint8_t value = ((_data[readPos / 8] >> (readPos % 8)) & 0x01) << 1; return _enabled ? value : 0; } else { @@ -133,7 +133,7 @@ public: _enabled = (value & 0x04) != 0; if(_isRecording) { - while(_console->GetCpu()->GetElapsedCycles(_cycle) > FamilyBasicDataRecorder::SamplingRate) { + while(_console->GetCpu()->GetCycleCount() - _cycle > FamilyBasicDataRecorder::SamplingRate) { _data.push_back(value & 0x01); _cycle += 88; } diff --git a/Core/MMC1.h b/Core/MMC1.h index f602c35e..050c4872 100644 --- a/Core/MMC1.h +++ b/Core/MMC1.h @@ -44,7 +44,7 @@ class MMC1 : public BaseMapper uint8_t _chrReg1; uint8_t _prgReg; - int32_t _lastWriteCycle = -1; + uint64_t _lastWriteCycle = 0; bool _forceWramOn; MMC1Registers _lastChrReg; @@ -195,10 +195,10 @@ class MMC1 : public BaseMapper virtual void WriteRegister(uint16_t addr, uint8_t value) override { - int32_t currentCycle = _console->GetCpu()->GetCycleCount(); + uint64_t currentCycle = _console->GetCpu()->GetCycleCount(); //Ignore write if within 2 cycles of another write (i.e the real write after a dummy write) - if(abs(currentCycle - _lastWriteCycle) >= 2) { + if(currentCycle - _lastWriteCycle >= 2) { if(IsBufferFull(value)) { switch((MMC1Registers)((addr & 0x6000) >> 13)) { case MMC1Registers::Reg8000: _state.Reg8000 = _writeBuffer; break; diff --git a/Core/MemoryAccessCounter.cpp b/Core/MemoryAccessCounter.cpp index fe3c61ef..3d6352f4 100644 --- a/Core/MemoryAccessCounter.cpp +++ b/Core/MemoryAccessCounter.cpp @@ -58,7 +58,7 @@ vector& MemoryAccessCounter::GetCountArray(MemoryOperationType operatio } } -vector& MemoryAccessCounter::GetStampArray(MemoryOperationType operationType, AddressType addressType) +vector& MemoryAccessCounter::GetStampArray(MemoryOperationType operationType, AddressType addressType) { switch(operationType) { case MemoryOperationType::Read: return _readStamps[(int)addressType]; @@ -75,7 +75,7 @@ vector& MemoryAccessCounter::GetPpuCountArray(MemoryOperationType opera return operationType == MemoryOperationType::Write ? _ppuWriteCounts[(int)addressType] : _ppuReadCounts[(int)addressType]; } -vector& MemoryAccessCounter::GetPpuStampArray(MemoryOperationType operationType, PpuAddressType addressType) +vector& MemoryAccessCounter::GetPpuStampArray(MemoryOperationType operationType, PpuAddressType addressType) { return operationType == MemoryOperationType::Write ? _ppuWriteStamps[(int)addressType] : _ppuReadStamps[(int)addressType]; } @@ -89,23 +89,23 @@ bool MemoryAccessCounter::IsAddressUninitialized(AddressTypeInfo &addressInfo) return false; } -void MemoryAccessCounter::ProcessPpuMemoryAccess(PpuAddressTypeInfo &addressInfo, MemoryOperationType operation, int32_t cpuCycle) +void MemoryAccessCounter::ProcessPpuMemoryAccess(PpuAddressTypeInfo &addressInfo, MemoryOperationType operation, uint64_t cpuCycle) { if(addressInfo.Address >= 0) { vector &counts = GetPpuCountArray(operation, addressInfo.Type); counts.data()[addressInfo.Address]++; - vector &stamps = GetPpuStampArray(operation, addressInfo.Type); + vector &stamps = GetPpuStampArray(operation, addressInfo.Type); stamps.data()[addressInfo.Address] = cpuCycle; } } -bool MemoryAccessCounter::ProcessMemoryAccess(AddressTypeInfo &addressInfo, MemoryOperationType operation, int32_t cpuCycle) +bool MemoryAccessCounter::ProcessMemoryAccess(AddressTypeInfo &addressInfo, MemoryOperationType operation, uint64_t cpuCycle) { vector &counts = GetCountArray(operation, addressInfo.Type); counts.data()[addressInfo.Address]++; - vector &stamps = GetStampArray(operation, addressInfo.Type); + vector &stamps = GetStampArray(operation, addressInfo.Type); stamps.data()[addressInfo.Address] = cpuCycle; if(operation == MemoryOperationType::Read && (addressInfo.Type == AddressType::InternalRam || addressInfo.Type == AddressType::WorkRam) && !_writeCounts[(int)addressInfo.Type][addressInfo.Address]) { @@ -125,9 +125,9 @@ void MemoryAccessCounter::ResetCounts() memset(_writeCounts[i].data(), 0, _writeCounts[i].size() * sizeof(uint32_t)); memset(_execCounts[i].data(), 0, _execCounts[i].size() * sizeof(uint32_t)); - memset(_readStamps[i].data(), 0, _readStamps[i].size() * sizeof(uint32_t)); - memset(_writeStamps[i].data(), 0, _writeStamps[i].size() * sizeof(uint32_t)); - memset(_execStamps[i].data(), 0, _execStamps[i].size() * sizeof(uint32_t)); + memset(_readStamps[i].data(), 0, _readStamps[i].size() * sizeof(uint64_t)); + memset(_writeStamps[i].data(), 0, _writeStamps[i].size() * sizeof(uint64_t)); + memset(_execStamps[i].data(), 0, _execStamps[i].size() * sizeof(uint64_t)); memset(_ppuReadCounts[i].data(), 0, _ppuReadCounts[i].size() * sizeof(uint32_t)); memset(_ppuWriteCounts[i].data(), 0, _ppuWriteCounts[i].size() * sizeof(uint32_t)); @@ -136,41 +136,41 @@ void MemoryAccessCounter::ResetCounts() } } -void MemoryAccessCounter::GetAccessStamps(uint32_t offset, uint32_t length, DebugMemoryType memoryType, MemoryOperationType operationType, uint32_t stamps[]) +void MemoryAccessCounter::GetAccessStamps(uint32_t offset, uint32_t length, DebugMemoryType memoryType, MemoryOperationType operationType, uint64_t stamps[]) { switch(memoryType) { default: break; case DebugMemoryType::InternalRam: - memcpy(stamps, GetStampArray(operationType, AddressType::InternalRam).data() + offset, length * sizeof(uint32_t)); + memcpy(stamps, GetStampArray(operationType, AddressType::InternalRam).data() + offset, length * sizeof(uint64_t)); break; case DebugMemoryType::WorkRam: - memcpy(stamps, GetStampArray(operationType, AddressType::WorkRam).data() + offset, length * sizeof(uint32_t)); + memcpy(stamps, GetStampArray(operationType, AddressType::WorkRam).data() + offset, length * sizeof(uint64_t)); break; case DebugMemoryType::SaveRam: - memcpy(stamps, GetStampArray(operationType, AddressType::SaveRam).data() + offset, length * sizeof(uint32_t)); + memcpy(stamps, GetStampArray(operationType, AddressType::SaveRam).data() + offset, length * sizeof(uint64_t)); break; case DebugMemoryType::PrgRom: - memcpy(stamps, GetStampArray(operationType, AddressType::PrgRom).data() + offset, length * sizeof(uint32_t)); + memcpy(stamps, GetStampArray(operationType, AddressType::PrgRom).data() + offset, length * sizeof(uint64_t)); break; case DebugMemoryType::ChrRom: - memcpy(stamps, GetPpuStampArray(operationType, PpuAddressType::ChrRom).data() + offset, length * sizeof(uint32_t)); + memcpy(stamps, GetPpuStampArray(operationType, PpuAddressType::ChrRom).data() + offset, length * sizeof(uint64_t)); break; case DebugMemoryType::ChrRam: - memcpy(stamps, GetPpuStampArray(operationType, PpuAddressType::ChrRam).data() + offset, length * sizeof(uint32_t)); + memcpy(stamps, GetPpuStampArray(operationType, PpuAddressType::ChrRam).data() + offset, length * sizeof(uint64_t)); break; case DebugMemoryType::NametableRam: - memcpy(stamps, GetPpuStampArray(operationType, PpuAddressType::NametableRam).data() + offset, length * sizeof(uint32_t)); + memcpy(stamps, GetPpuStampArray(operationType, PpuAddressType::NametableRam).data() + offset, length * sizeof(uint64_t)); break; case DebugMemoryType::PaletteMemory: - memcpy(stamps, GetPpuStampArray(operationType, PpuAddressType::PaletteRam).data() + offset, length * sizeof(uint32_t)); + memcpy(stamps, GetPpuStampArray(operationType, PpuAddressType::PaletteRam).data() + offset, length * sizeof(uint64_t)); break; case DebugMemoryType::CpuMemory: @@ -194,7 +194,7 @@ void MemoryAccessCounter::GetAccessStamps(uint32_t offset, uint32_t length, Debu void MemoryAccessCounter::GetNametableChangedData(bool ntChangedData[]) { PpuAddressTypeInfo addressInfo; - int32_t cpuCycle = _debugger->GetConsole()->GetCpu()->GetCycleCount(); + uint64_t cpuCycle = _debugger->GetConsole()->GetCpu()->GetCycleCount(); NesModel model = _debugger->GetConsole()->GetModel(); double frameRate = model == NesModel::NTSC ? 60.1 : 50.01; double overclockRate = _debugger->GetConsole()->GetPpu()->GetOverclockRate() * (_debugger->GetConsole()->GetSettings()->GetOverclockRate() / 100); diff --git a/Core/MemoryAccessCounter.h b/Core/MemoryAccessCounter.h index 9e6aae9a..daa2c18b 100644 --- a/Core/MemoryAccessCounter.h +++ b/Core/MemoryAccessCounter.h @@ -13,28 +13,28 @@ private: vector _writeCounts[4]; vector _execCounts[4]; - vector _readStamps[4]; - vector _writeStamps[4]; - vector _execStamps[4]; + vector _readStamps[4]; + vector _writeStamps[4]; + vector _execStamps[4]; vector _uninitReads[4]; vector _ppuReadCounts[4]; vector _ppuWriteCounts[4]; - vector _ppuReadStamps[4]; - vector _ppuWriteStamps[4]; + vector _ppuReadStamps[4]; + vector _ppuWriteStamps[4]; vector& GetCountArray(MemoryOperationType operationType, AddressType addressType); - vector& GetStampArray(MemoryOperationType operationType, AddressType addressType); + vector& GetStampArray(MemoryOperationType operationType, AddressType addressType); vector& GetPpuCountArray(MemoryOperationType operationType, PpuAddressType addressType); - vector& GetPpuStampArray(MemoryOperationType operationType, PpuAddressType addressType); + vector& GetPpuStampArray(MemoryOperationType operationType, PpuAddressType addressType); public: MemoryAccessCounter(Debugger* debugger); - void ProcessPpuMemoryAccess(PpuAddressTypeInfo &addressInfo, MemoryOperationType operation, int32_t cpuCycle); - bool ProcessMemoryAccess(AddressTypeInfo &addressInfo, MemoryOperationType operation, int32_t cpuCycle); + void ProcessPpuMemoryAccess(PpuAddressTypeInfo &addressInfo, MemoryOperationType operation, uint64_t cpuCycle); + bool ProcessMemoryAccess(AddressTypeInfo &addressInfo, MemoryOperationType operation, uint64_t cpuCycle); void ResetCounts(); bool IsAddressUninitialized(AddressTypeInfo &addressInfo); @@ -42,5 +42,5 @@ public: void GetUninitMemoryReads(DebugMemoryType memoryType, int32_t counts[]); void GetNametableChangedData(bool ntChangedData[]); void GetAccessCounts(uint32_t offset, uint32_t length, DebugMemoryType memoryType, MemoryOperationType operationType, int32_t counts[]); - void GetAccessStamps(uint32_t offset, uint32_t length, DebugMemoryType memoryType, MemoryOperationType operationType, uint32_t stamps[]); + void GetAccessStamps(uint32_t offset, uint32_t length, DebugMemoryType memoryType, MemoryOperationType operationType, uint64_t stamps[]); }; \ No newline at end of file diff --git a/Core/PPU.cpp b/Core/PPU.cpp index 7d6482d5..abb891a0 100644 --- a/Core/PPU.cpp +++ b/Core/PPU.cpp @@ -1092,8 +1092,8 @@ uint8_t PPU::ReadSpriteRam(uint8_t addr) if(!_enableOamDecay) { return _spriteRAM[addr]; } else { - int32_t elapsedCycle = _console->GetCpu()->GetElapsedCycles(_oamDecayCycles[addr >> 3]); - if(elapsedCycle <= PPU::OamDecayCycleCount) { + uint64_t elapsedCycles = _console->GetCpu()->GetCycleCount() - _oamDecayCycles[addr >> 3]; + if(elapsedCycles <= PPU::OamDecayCycleCount) { _oamDecayCycles[addr >> 3] = _console->GetCpu()->GetCycleCount(); return _spriteRAM[addr]; } else { @@ -1325,7 +1325,7 @@ uint8_t* PPU::GetSpriteRam() if(_enableOamDecay) { for(int i = 0; i < 0x100; i++) { //Apply OAM decay to sprite RAM before letting debugger access it - if(_console->GetCpu()->GetElapsedCycles(_oamDecayCycles[i >> 3]) > PPU::OamDecayCycleCount) { + if((_console->GetCpu()->GetCycleCount() - _oamDecayCycles[i >> 3]) > PPU::OamDecayCycleCount) { _spriteRAM[i] = 0x10; } } diff --git a/Core/PPU.h b/Core/PPU.h index 66fcbe0b..23ecabdd 100644 --- a/Core/PPU.h +++ b/Core/PPU.h @@ -101,7 +101,7 @@ class PPU : public IMemoryHandler, public Snapshotable uint32_t _minimumDrawSpriteCycle; uint32_t _minimumDrawSpriteStandardCycle; - int32_t _oamDecayCycles[0x40]; + uint64_t _oamDecayCycles[0x40]; bool _enableOamDecay; void UpdateStatusFlag(); diff --git a/Core/SaveStateManager.h b/Core/SaveStateManager.h index 5b936177..cc868bc1 100644 --- a/Core/SaveStateManager.h +++ b/Core/SaveStateManager.h @@ -14,7 +14,7 @@ private: string GetStateFilepath(int stateIndex); public: - static constexpr uint32_t FileFormatVersion = 10; + static constexpr uint32_t FileFormatVersion = 11; SaveStateManager(shared_ptr console); diff --git a/Core/TraceLogger.cpp b/Core/TraceLogger.cpp index 64963719..4c50bf9b 100644 --- a/Core/TraceLogger.cpp +++ b/Core/TraceLogger.cpp @@ -151,7 +151,7 @@ void TraceLogger::StopLogging() } } -void TraceLogger::LogExtraInfo(const char *log, uint32_t cycleCount) +void TraceLogger::LogExtraInfo(const char *log, uint64_t cycleCount) { if(_logToFile && _options.ShowExtraInfo) { //Flush current buffer diff --git a/Core/TraceLogger.h b/Core/TraceLogger.h index 9a3f4fd2..ad455b2e 100644 --- a/Core/TraceLogger.h +++ b/Core/TraceLogger.h @@ -104,7 +104,7 @@ public: void StartLogging(string filename); void StopLogging(); - void LogExtraInfo(const char *log, uint32_t cycleCount); + void LogExtraInfo(const char *log, uint64_t cycleCount); const char* GetExecutionTrace(uint32_t lineCount); }; \ No newline at end of file diff --git a/Core/Types.h b/Core/Types.h index 33b8e1ba..50c62fc4 100644 --- a/Core/Types.h +++ b/Core/Types.h @@ -60,7 +60,7 @@ struct State uint8_t Y = 0; uint8_t PS = 0; uint32_t IRQFlag = 0; - int32_t CycleCount = 0; + uint64_t CycleCount = 0; bool NMIFlag = false; //Used by debugger diff --git a/GUI.NET/Debugger/ByteColorProvider.cs b/GUI.NET/Debugger/ByteColorProvider.cs index d0aa3711..0ab5d9fc 100644 --- a/GUI.NET/Debugger/ByteColorProvider.cs +++ b/GUI.NET/Debugger/ByteColorProvider.cs @@ -9,9 +9,9 @@ namespace Mesen.GUI.Debugger public class ByteColorProvider : IByteColorProvider { DebugMemoryType _memoryType; - Int32[] _readStamps; - Int32[] _writeStamps; - Int32[] _execStamps; + UInt64[] _readStamps; + UInt64[] _writeStamps; + UInt64[] _execStamps; Int32[] _readCounts; Int32[] _writeCounts; Int32[] _execCounts; diff --git a/GUI.NET/Debugger/ChrByteColorProvider.cs b/GUI.NET/Debugger/ChrByteColorProvider.cs index af1b1ed8..f4a5b46f 100644 --- a/GUI.NET/Debugger/ChrByteColorProvider.cs +++ b/GUI.NET/Debugger/ChrByteColorProvider.cs @@ -9,8 +9,8 @@ namespace Mesen.GUI.Debugger public class ChrByteColorProvider : IByteColorProvider { DebugMemoryType _memoryType; - Int32[] _readStamps; - Int32[] _writeStamps; + UInt64[] _readStamps; + UInt64[] _writeStamps; Int32[] _readCounts; Int32[] _writeCounts; DebugState _state = new DebugState(); diff --git a/GUI.NET/Debugger/Controls/ctrlConsoleStatus.Designer.cs b/GUI.NET/Debugger/Controls/ctrlConsoleStatus.Designer.cs index 4acb43a1..b12f5c46 100644 --- a/GUI.NET/Debugger/Controls/ctrlConsoleStatus.Designer.cs +++ b/GUI.NET/Debugger/Controls/ctrlConsoleStatus.Designer.cs @@ -1180,7 +1180,7 @@ this.txtCycleCount.Margin = new System.Windows.Forms.Padding(0); this.txtCycleCount.MaxLength = 11; this.txtCycleCount.Name = "txtCycleCount"; - this.txtCycleCount.Size = new System.Drawing.Size(77, 20); + this.txtCycleCount.Size = new System.Drawing.Size(85, 20); this.txtCycleCount.TabIndex = 9; this.txtCycleCount.TextChanged += new System.EventHandler(this.OnOptionChanged); // diff --git a/GUI.NET/Debugger/frmDebugger.cs b/GUI.NET/Debugger/frmDebugger.cs index 76b5a94a..70ba2fe4 100644 --- a/GUI.NET/Debugger/frmDebugger.cs +++ b/GUI.NET/Debugger/frmDebugger.cs @@ -23,7 +23,7 @@ namespace Mesen.GUI.Debugger private bool _firstBreak = true; private bool _wasPaused = false; private bool _executionIsStopped = false; //Flag used to break on the first instruction after power cycle/reset if execution was stopped before the reset - private int _previousCycle = 0; + private UInt64 _previousCycle = 0; private InteropEmu.NotificationListener _notifListener; private ICodeViewer _lastCodeWindow; diff --git a/GUI.NET/Debugger/frmTraceLogger.cs b/GUI.NET/Debugger/frmTraceLogger.cs index 44dc1e88..0b417256 100644 --- a/GUI.NET/Debugger/frmTraceLogger.cs +++ b/GUI.NET/Debugger/frmTraceLogger.cs @@ -20,7 +20,7 @@ namespace Mesen.GUI.Debugger private bool _loggingEnabled = false; private string _lastFilename; private EntityBinder _entityBinder = new EntityBinder(); - private int _previousCycleCount; + private UInt64 _previousCycleCount; private string _previousTrace; private volatile bool _refreshRunning; private bool _initialized; diff --git a/GUI.NET/InteropEmu.cs b/GUI.NET/InteropEmu.cs index b84ee754..eb470a8c 100644 --- a/GUI.NET/InteropEmu.cs +++ b/GUI.NET/InteropEmu.cs @@ -532,7 +532,7 @@ namespace Mesen.GUI return InteropEmu.DebugGetMemoryAccessCounts(0, (uint)size, type, operationType); } - public static Int32[] DebugGetMemoryAccessStamps(DebugMemoryType type, MemoryOperationType operationType) + public static UInt64[] DebugGetMemoryAccessStamps(DebugMemoryType type, MemoryOperationType operationType) { int size = InteropEmu.DebugGetMemorySize(type); return InteropEmu.DebugGetMemoryAccessStamps(0, (uint)size, type, operationType); @@ -561,9 +561,9 @@ namespace Mesen.GUI } [DllImport(DLLPath, EntryPoint = "DebugGetMemoryAccessStamps")] private static extern void DebugGetMemoryAccessStampsWrapper(UInt32 offset, UInt32 length, DebugMemoryType type, MemoryOperationType operationType, IntPtr stamps); - public static Int32[] DebugGetMemoryAccessStamps(UInt32 offset, UInt32 length, DebugMemoryType type, MemoryOperationType operationType) + public static UInt64[] DebugGetMemoryAccessStamps(UInt32 offset, UInt32 length, DebugMemoryType type, MemoryOperationType operationType) { - Int32[] stamps = new Int32[length]; + UInt64[] stamps = new UInt64[length]; GCHandle hStamps = GCHandle.Alloc(stamps, GCHandleType.Pinned); try { @@ -1448,7 +1448,7 @@ namespace Mesen.GUI public Byte Y; public Byte PS; public IRQSource IRQFlag; - public Int32 CycleCount; + public UInt64 CycleCount; [MarshalAs(UnmanagedType.I1)] public bool NMIFlag; diff --git a/InteropDLL/DebugWrapper.cpp b/InteropDLL/DebugWrapper.cpp index 9ce1762f..42be1acf 100644 --- a/InteropDLL/DebugWrapper.cpp +++ b/InteropDLL/DebugWrapper.cpp @@ -112,7 +112,7 @@ extern "C" DllExport void __stdcall DebugSetMemoryValues(DebugMemoryType type, uint32_t address, uint8_t* data, int32_t length) { return GetDebugger()->GetMemoryDumper()->SetMemoryValues(type, address, data, length); } DllExport void __stdcall DebugResetMemoryAccessCounts() { GetDebugger()->GetMemoryAccessCounter()->ResetCounts(); } - DllExport void __stdcall DebugGetMemoryAccessStamps(uint32_t offset, uint32_t length, DebugMemoryType memoryType, MemoryOperationType operationType, uint32_t* stamps) { GetDebugger()->GetMemoryAccessCounter()->GetAccessStamps(offset, length, memoryType, operationType, stamps); } + DllExport void __stdcall DebugGetMemoryAccessStamps(uint32_t offset, uint32_t length, DebugMemoryType memoryType, MemoryOperationType operationType, uint64_t* stamps) { GetDebugger()->GetMemoryAccessCounter()->GetAccessStamps(offset, length, memoryType, operationType, stamps); } DllExport void __stdcall DebugGetMemoryAccessCounts(uint32_t offset, uint32_t length, DebugMemoryType memoryType, MemoryOperationType operationType, int32_t* counts) { GetDebugger()->GetMemoryAccessCounter()->GetAccessCounts(offset, length, memoryType, operationType, counts); } DllExport void __stdcall DebugGetUninitMemoryReads(DebugMemoryType memoryType, int32_t* counts) { GetDebugger()->GetMemoryAccessCounter()->GetUninitMemoryReads(memoryType, counts); } DllExport void __stdcall DebugGetNametableChangedData(bool* ntChangedData) { GetDebugger()->GetMemoryAccessCounter()->GetNametableChangedData(ntChangedData); } diff --git a/Utilities/HexUtilities.cpp b/Utilities/HexUtilities.cpp index 0697b33c..cf6660ae 100644 --- a/Utilities/HexUtilities.cpp +++ b/Utilities/HexUtilities.cpp @@ -64,6 +64,20 @@ string HexUtilities::ToHex(uint32_t value, bool fullSize) } } +string HexUtilities::ToHex(uint64_t value, bool fullSize) +{ + if(fullSize) { + return ToHex((uint32_t)(value >> 32), true) + ToHex((uint32_t)value, true); + } else { + string result; + while(value > 0) { + result = _hexCache[value & 0xFF] + result; + value >>= 8; + } + return result; + } +} + string HexUtilities::ToHex(vector &data) { string result; diff --git a/Utilities/HexUtilities.h b/Utilities/HexUtilities.h index b6f1a989..c21dc3d1 100644 --- a/Utilities/HexUtilities.h +++ b/Utilities/HexUtilities.h @@ -10,6 +10,7 @@ public: static string ToHex(uint8_t value); static string ToHex(uint16_t value); static string ToHex(uint32_t value, bool fullSize = false); + static string ToHex(uint64_t value, bool fullSize = false); static string ToHex(int32_t value, bool fullSize = false); static string ToHex(vector &data);