Project64: Code cleanup

This commit is contained in:
zilmar 2022-09-26 12:01:54 +09:30
parent a65086579f
commit 179282043f
151 changed files with 11511 additions and 9945 deletions

View File

@ -1,16 +1,16 @@
#include "stdafx.h"
#include <Common/path.h>
#include <Common/Trace.h>
#include <Common/Util.h>
#include <Common/path.h>
#include "Settings/SettingType/SettingsType-Application.h"
#include <Project64-core/N64System/Enhancement/Enhancements.h>
#include <Project64-core/N64System/Mips/MemoryVirtualMem.h>
#include <Project64-core/N64System/N64Disk.h>
#include <Project64-core/N64System/N64Rom.h>
#include <Project64-core/N64System/SystemGlobals.h>
#include <Project64-core/Plugins/Plugin.h>
#include <Project64-core/N64System/N64Rom.h>
#include <Project64-core/N64System/N64Disk.h>
#include <Project64-core/N64System/Enhancement/Enhancements.h>
#include "Settings/SettingType/SettingsType-Application.h"
static void FixDirectories(void);
void SetTraceModuleNames(void);
@ -164,7 +164,11 @@ void CleanupTrace(void)
void TraceDone(void)
{
CloseTrace();
if (g_LogFile) { delete g_LogFile; g_LogFile = nullptr; }
if (g_LogFile)
{
delete g_LogFile;
g_LogFile = nullptr;
}
}
const char * AppName(void)
@ -173,7 +177,7 @@ const char * AppName(void)
return ApplicationName.c_str();
}
static bool ParseCommand(int32_t argc, char **argv)
static bool ParseCommand(int32_t argc, char ** argv)
{
if (argc <= 1)
{
@ -213,7 +217,7 @@ static bool ParseCommand(int32_t argc, char **argv)
return false;
}
bool AppInit(CNotification * Notify, const char * BaseDirectory, int argc, char **argv)
bool AppInit(CNotification * Notify, const char * BaseDirectory, int argc, char ** argv)
{
try
{
@ -283,13 +287,41 @@ void AppCleanup(void)
WriteTrace(TraceAppCleanup, TraceDebug, "Cleaning up global objects");
CleanupTrace();
if (g_Enhancements) { delete g_Enhancements; g_Enhancements = nullptr; }
if (g_Rom) { delete g_Rom; g_Rom = nullptr; }
if (g_DDRom) { delete g_DDRom; g_DDRom = nullptr; }
if (g_Disk) { delete g_Disk; g_Disk = nullptr; }
if (g_Plugins) { delete g_Plugins; g_Plugins = nullptr; }
if (g_Settings) { delete g_Settings; g_Settings = nullptr; }
if (g_Lang) { delete g_Lang; g_Lang = nullptr; }
if (g_Enhancements)
{
delete g_Enhancements;
g_Enhancements = nullptr;
}
if (g_Rom)
{
delete g_Rom;
g_Rom = nullptr;
}
if (g_DDRom)
{
delete g_DDRom;
g_DDRom = nullptr;
}
if (g_Disk)
{
delete g_Disk;
g_Disk = nullptr;
}
if (g_Plugins)
{
delete g_Plugins;
g_Plugins = nullptr;
}
if (g_Settings)
{
delete g_Settings;
g_Settings = nullptr;
}
if (g_Lang)
{
delete g_Lang;
g_Lang = nullptr;
}
CMipsMemoryVM::FreeReservedMemory();
TraceDone();

View File

@ -1,12 +1,12 @@
#include "stdafx.h"
#include <Project64-core/Logging.h>
#include <stdio.h>
#include <stdarg.h>
#include <Common/path.h>
#include <Project64-core/N64System/SystemGlobals.h>
#include <Project64-core/N64System/Mips/MemoryVirtualMem.h>
#include <Project64-core/N64System/N64Rom.h>
#include <Project64-core/N64System/SystemGlobals.h>
#include <stdarg.h>
#include <stdio.h>
CFile * CLogging::m_hLogFile = nullptr;

View File

@ -1,8 +1,8 @@
#include "stdafx.h"
#include <Project64-core/N64System/Mips/MemoryVirtualMem.h>
#include <Project64-core/N64System/N64System.h>
#include <Project64-core/N64System/Recompiler/Recompiler.h>
#include <Project64-core/N64System/SystemGlobals.h>
#include <Project64-core/N64System/N64System.h>
#ifndef _WIN32
#include <stdlib.h>
#endif

View File

@ -1,13 +1,14 @@
#include "stdafx.h"
#include <stdio.h>
#include <stdint.h>
#include <Common/path.h>
#include <stdint.h>
#include <stdio.h>
CLanguage * g_Lang = nullptr;
void CLanguage::LoadDefaultStrings(void)
{
#define DEF_STR(ID,str) m_DefaultStrings.insert(LANG_STRINGS::value_type(ID,str))
#define DEF_STR(ID, str) m_DefaultStrings.insert(LANG_STRINGS::value_type(ID, str))
DEF_STR(EMPTY_STRING, "");
@ -105,7 +106,7 @@ void CLanguage::LoadDefaultStrings(void)
DEF_STR(POPUP_CHEATS, "Edit Cheats");
DEF_STR(POPUP_GFX_PLUGIN, "Graphics Plugin");
DEF_STR(POPUP_PLAYDISK, "Play Game with Disk");
DEF_STR(POPUP_ENHANCEMENTS, "Pick Enhancements");
DEF_STR(POPUP_ENHANCEMENTS, "Pick Enhancements");
// Alternate name to save slot
DEF_STR(SAVE_SLOT_DEFAULT, "Save Slot - Default");
@ -610,7 +611,7 @@ bool CLanguage::LoadCurrentStrings(void)
}
// Process the file
FILE *file = fopen(Filename.c_str(), "rb");
FILE * file = fopen(Filename.c_str(), "rb");
if (file == nullptr)
{
return false;
@ -696,7 +697,7 @@ const std::string & CLanguage::GetString(LanguageStringID StringID)
std::string CLanguage::GetLangString(const char * FileName, LanguageStringID ID)
{
FILE *file = fopen(FileName, "rb");
FILE * file = fopen(FileName, "rb");
if (file == nullptr)
{
return "";
@ -729,9 +730,12 @@ std::string CLanguage::GetLangString(const char * FileName, LanguageStringID ID)
LANG_STR CLanguage::GetNextLangString(void * OpenFile)
{
enum { MAX_STRING_LEN = 800 };
int32_t StringID;
char szString[MAX_STRING_LEN]; // Temporarily store the string from the file
enum
{
MAX_STRING_LEN = 800
};
int32_t StringID;
char szString[MAX_STRING_LEN]; // Temporarily store the string from the file
FILE * file = (FILE *)OpenFile;
@ -762,7 +766,8 @@ LANG_STR CLanguage::GetNextLangString(void * OpenFile)
}
if (feof(file))
{
StringID = EMPTY_STRING; return LANG_STR(0, "");
StringID = EMPTY_STRING;
return LANG_STR(0, "");
}
// Search for start of string '"'
@ -772,7 +777,8 @@ LANG_STR CLanguage::GetNextLangString(void * OpenFile)
}
if (feof(file))
{
StringID = EMPTY_STRING; return LANG_STR(0, "");
StringID = EMPTY_STRING;
return LANG_STR(0, "");
}
int32_t pos = 0;

View File

@ -1,13 +1,13 @@
#include "stdafx.h"
#include <Project64-core/N64System/Enhancement/Enhancement.h>
#include <Project64-core/Settings/SettingType/SettingsType-GameSetting.h>
#include <Project64-core/N64System/SystemGlobals.h>
#include <Project64-core/N64System/N64System.h>
#include <Project64-core/N64System/SystemGlobals.h>
#include <Project64-core/Settings/SettingType/SettingsType-GameSetting.h>
const char * CEnhancement::CheatIdent = "Cheat";
const char * CEnhancement::EnhancementIdent = "Enhancement";
#pragma warning(disable:4996)
#pragma warning(disable : 4996)
static std::string GenerateKeyName(const char * Name, const char * Ident, const char * PostIdent)
{
@ -26,7 +26,7 @@ class CSettingEnhancementActive :
{
public:
CSettingEnhancementActive(const char * Name, const char * Ident, bool Default) :
CSettingTypeGame("",false),
CSettingTypeGame("", false),
m_Default(Default)
{
m_KeyNameIdex = GenerateKeyName(Name, Ident, "Active");
@ -90,7 +90,7 @@ public:
Flush();
}
bool SelectedValue(uint16_t &Value)
bool SelectedValue(uint16_t & Value)
{
uint32_t StoredValue = 0;
if (!Load(0, StoredValue))
@ -281,8 +281,14 @@ void CEnhancement::SetName(const char * Name)
CSettingEnhancementSelectedOption(m_Name.c_str(), m_Ident.c_str()).Delete();
m_Name = stdstr(Name != nullptr ? Name : "").Trim("\t ,");
m_NameAndExtension = m_Name;
if (m_Active != m_OnByDefault) { CSettingEnhancementActive(m_Name.c_str(), m_Ident.c_str(), m_OnByDefault).SetActive(m_OnByDefault); }
if (OptionSelected()) { CSettingEnhancementSelectedOption(m_Name.c_str(), m_Ident.c_str()).SetOption(SelectedOption()); }
if (m_Active != m_OnByDefault)
{
CSettingEnhancementActive(m_Name.c_str(), m_Ident.c_str(), m_OnByDefault).SetActive(m_OnByDefault);
}
if (OptionSelected())
{
CSettingEnhancementSelectedOption(m_Name.c_str(), m_Ident.c_str()).SetOption(SelectedOption());
}
CheckValid();
}

View File

@ -1,18 +1,19 @@
#include "stdafx.h"
#include <Project64-core/N64System/Enhancement/Enhancements.h>
#include <Common/Util.h>
#include <Common/path.h>
#include <Project64-core/N64System/Enhancement/EnhancementFile.h>
#include <Project64-core/N64System/Enhancement/Enhancements.h>
#include <Project64-core/N64System/Mips/MemoryVirtualMem.h>
#include <Project64-core/N64System/Recompiler/Recompiler.h>
#include <Project64-core/N64System/SystemGlobals.h>
#include <Project64-core/Plugins/Plugin.h>
#include <Project64-core/Plugins/GFXPlugin.h>
#include <Project64-core/Plugins/AudioPlugin.h>
#include <Project64-core/Plugins/RSPPlugin.h>
#include <Project64-core/Plugins/ControllerPlugin.h>
#include <Common/path.h>
#include <Common/Util.h>
#include <Project64-core/Plugins/GFXPlugin.h>
#include <Project64-core/Plugins/Plugin.h>
#include <Project64-core/Plugins/RSPPlugin.h>
CEnhancements::GAMESHARK_CODE::GAMESHARK_CODE(const GAMESHARK_CODE&rhs)
CEnhancements::GAMESHARK_CODE::GAMESHARK_CODE(const GAMESHARK_CODE & rhs)
{
m_Command = rhs.m_Command;
m_Value = rhs.m_Value;
@ -72,7 +73,8 @@ void CEnhancements::ApplyGSButton(CMipsMemoryVM & MMU, bool /*UpdateChanges*/)
for (size_t CurrentEntry = 0; CurrentEntry < CodeEntry.size(); CurrentEntry++)
{
const GAMESHARK_CODE & Code = CodeEntry[CurrentEntry];
switch (Code.Command() & 0xFF000000) {
switch (Code.Command() & 0xFF000000)
{
case 0x88000000:
ModifyMemory8(MMU, 0x80000000 | (Code.Command() & 0xFFFFFF), (uint8_t)Code.Value(), Code.HasDisableValue(), (uint8_t)Code.DisableValue());
break;
@ -147,7 +149,7 @@ void CEnhancements::UpdateEnhancements(const CEnhancementList & Enhancements)
#endif
CGuard Guard(m_CS);
if (m_EnhancementFile.get() == nullptr ||strcmp(m_EnhancementFile->FileName(), OutFile) != 0)
if (m_EnhancementFile.get() == nullptr || strcmp(m_EnhancementFile->FileName(), OutFile) != 0)
{
if (!OutFile.DirectoryExists())
{
@ -426,7 +428,8 @@ void CEnhancements::ApplyGameSharkCodes(CMipsMemoryVM & MMU, CODES & CodeEntry,
int incr = Code.Value();
int i;
switch (NextCodeEntry.Command() & 0xFF000000) {
switch (NextCodeEntry.Command() & 0xFF000000)
{
case 0x10000000: // Xplorer64
case 0x80000000:
Address = 0x80000000 | (NextCodeEntry.Command() & 0xFFFFFF);
@ -620,7 +623,6 @@ void CEnhancements::ModifyMemory16(CMipsMemoryVM & MMU, uint32_t Address, uint16
}
}
void CEnhancements::ScanFileThread(void)
{
SectionFiles CheatFiles;

View File

@ -1,15 +1,16 @@
#include "stdafx.h"
#include "InterpreterCPU.h"
#include <Project64-core/N64System/SystemGlobals.h>
#include <Project64-core/N64System/N64System.h>
#include <Project64-core/N64System/Mips/MemoryVirtualMem.h>
#include <Project64-core/N64System/Interpreter/InterpreterOps32.h>
#include <Project64-core/N64System/Mips/R4300iInstruction.h>
#include <Project64-core/Plugins/Plugin.h>
#include <Project64-core/Plugins/GFXPlugin.h>
#include <Project64-core/ExceptionHandler.h>
#include <Project64-core/Debugger.h>
#include <Project64-core/ExceptionHandler.h>
#include <Project64-core/N64System/Interpreter/InterpreterOps32.h>
#include <Project64-core/N64System/Mips/MemoryVirtualMem.h>
#include <Project64-core/N64System/Mips/R4300iInstruction.h>
#include <Project64-core/N64System/N64System.h>
#include <Project64-core/N64System/SystemGlobals.h>
#include <Project64-core/Plugins/GFXPlugin.h>
#include <Project64-core/Plugins/Plugin.h>
R4300iOp::Func * CInterpreterCPU::m_R4300i_Opcode = nullptr;
@ -36,9 +37,9 @@ void CInterpreterCPU::InPermLoop()
{
if (EndOnPermLoop() &&
((g_Reg->STATUS_REGISTER & STATUS_IE) == 0 ||
(g_Reg->STATUS_REGISTER & STATUS_EXL) != 0 ||
(g_Reg->STATUS_REGISTER & STATUS_ERL) != 0 ||
(g_Reg->STATUS_REGISTER & 0xFF00) == 0))
(g_Reg->STATUS_REGISTER & STATUS_EXL) != 0 ||
(g_Reg->STATUS_REGISTER & STATUS_ERL) != 0 ||
(g_Reg->STATUS_REGISTER & 0xFF00) == 0))
{
if (g_Plugins->Gfx()->UpdateScreen != nullptr)
{
@ -117,7 +118,10 @@ void CInterpreterCPU::ExecuteCPU()
_GPR[0].DW = 0; // MIPS $zero hard-wired to 0
NextTimer -= CountPerOp;
if (CDebugSettings::HaveDebugger()) { g_Debugger->CPUStepEnded(); }
if (CDebugSettings::HaveDebugger())
{
g_Debugger->CPUStepEnded();
}
PROGRAM_COUNTER += 4;
switch (PipelineStage)
@ -127,10 +131,10 @@ void CInterpreterCPU::ExecuteCPU()
case PIPELINE_STAGE_DELAY_SLOT:
PipelineStage = PIPELINE_STAGE_JUMP;
break;
case PIPELINE_STAGE_PERMLOOP_DO_DELAY:
case PIPELINE_STAGE_PERMLOOP_DO_DELAY:
PipelineStage = PIPELINE_STAGE_PERMLOOP_DELAY_DONE;
break;
case PIPELINE_STAGE_JUMP:
case PIPELINE_STAGE_JUMP:
CheckTimer = (JumpToLocation < PROGRAM_COUNTER - 4 || TestTimer);
PROGRAM_COUNTER = JumpToLocation;
PipelineStage = PIPELINE_STAGE_NORMAL;
@ -172,11 +176,11 @@ void CInterpreterCPU::ExecuteCPU()
void CInterpreterCPU::ExecuteOps(int32_t Cycles)
{
bool & Done = g_System->m_EndEmulation;
uint32_t & PROGRAM_COUNTER = *_PROGRAM_COUNTER;
uint32_t & PROGRAM_COUNTER = *_PROGRAM_COUNTER;
R4300iOpcode & Opcode = R4300iOp::m_Opcode;
PIPELINE_STAGE & PipelineStage = g_System->m_PipelineStage;
uint32_t & JumpToLocation = g_System->m_JumpToLocation;
bool & TestTimer = R4300iOp::m_TestTimer;
bool & TestTimer = R4300iOp::m_TestTimer;
const int32_t & DoSomething = g_SystemEvents->DoSomething();
uint32_t CountPerOp = g_System->CountPerOp();
bool CheckTimer = false;

View File

@ -1,14 +1,15 @@
#include "stdafx.h"
#include <Project64-core/Debugger.h>
#include <Project64-core/Logging.h>
#include <Project64-core/N64System/Interpreter/InterpreterCPU.h>
#include <Project64-core/N64System/Interpreter/InterpreterOps.h>
#include <Project64-core/N64System/SystemGlobals.h>
#include <Project64-core/N64System/N64System.h>
#include <Project64-core/N64System/Mips/MemoryVirtualMem.h>
#include <Project64-core/N64System/Mips/R4300iInstruction.h>
#include <Project64-core/N64System/Mips/SystemTiming.h>
#include <Project64-core/N64System/Mips/TLB.h>
#include <Project64-core/N64System/Mips/R4300iInstruction.h>
#include <Project64-core/N64System/Interpreter/InterpreterCPU.h>
#include <Project64-core/Logging.h>
#include <Project64-core/Debugger.h>
#include <Project64-core/N64System/N64System.h>
#include <Project64-core/N64System/SystemGlobals.h>
#include <float.h>
#include <math.h>
@ -39,22 +40,24 @@ R4300iOp::Func R4300iOp::Jump_CoP1_D[64];
R4300iOp::Func R4300iOp::Jump_CoP1_W[64];
R4300iOp::Func R4300iOp::Jump_CoP1_L[64];
const uint32_t R4300iOp::SWL_MASK[4] = { 0x00000000, 0xFF000000, 0xFFFF0000, 0xFFFFFF00 };
const uint32_t R4300iOp::SWR_MASK[4] = { 0x00FFFFFF, 0x0000FFFF, 0x000000FF, 0x00000000 };
const uint32_t R4300iOp::LWL_MASK[4] = { 0x00000000, 0x000000FF, 0x0000FFFF, 0x00FFFFFF };
const uint32_t R4300iOp::LWR_MASK[4] = { 0xFFFFFF00, 0xFFFF0000, 0xFF000000, 0x0000000 };
const uint32_t R4300iOp::SWL_MASK[4] = {0x00000000, 0xFF000000, 0xFFFF0000, 0xFFFFFF00};
const uint32_t R4300iOp::SWR_MASK[4] = {0x00FFFFFF, 0x0000FFFF, 0x000000FF, 0x00000000};
const uint32_t R4300iOp::LWL_MASK[4] = {0x00000000, 0x000000FF, 0x0000FFFF, 0x00FFFFFF};
const uint32_t R4300iOp::LWR_MASK[4] = {0xFFFFFF00, 0xFFFF0000, 0xFF000000, 0x0000000};
const int32_t R4300iOp::SWL_SHIFT[4] = { 0, 8, 16, 24 };
const int32_t R4300iOp::SWR_SHIFT[4] = { 24, 16, 8, 0 };
const int32_t R4300iOp::LWL_SHIFT[4] = { 0, 8, 16, 24 };
const int32_t R4300iOp::LWR_SHIFT[4] = { 24, 16, 8, 0 };
const int32_t R4300iOp::SWL_SHIFT[4] = {0, 8, 16, 24};
const int32_t R4300iOp::SWR_SHIFT[4] = {24, 16, 8, 0};
const int32_t R4300iOp::LWL_SHIFT[4] = {0, 8, 16, 24};
const int32_t R4300iOp::LWR_SHIFT[4] = {24, 16, 8, 0};
#define TEST_COP1_USABLE_EXCEPTION() \
if ((g_Reg->STATUS_REGISTER & STATUS_CU1) == 0) {\
g_Reg->DoCopUnusableException(g_System->m_PipelineStage == PIPELINE_STAGE_JUMP,1);\
g_System->m_PipelineStage = PIPELINE_STAGE_JUMP;\
g_System->m_JumpToLocation = (*_PROGRAM_COUNTER);\
return;}\
#define TEST_COP1_USABLE_EXCEPTION() \
if ((g_Reg->STATUS_REGISTER & STATUS_CU1) == 0) \
{ \
g_Reg->DoCopUnusableException(g_System->m_PipelineStage == PIPELINE_STAGE_JUMP, 1); \
g_System->m_PipelineStage = PIPELINE_STAGE_JUMP; \
g_System->m_JumpToLocation = (*_PROGRAM_COUNTER); \
return; \
}
void R4300iOp::SPECIAL()
{
@ -996,7 +999,6 @@ void R4300iOp::DADDI()
return;
}
_GPR[m_Opcode.rt].DW = sum;
}
void R4300iOp::DADDIU()
@ -1004,8 +1006,8 @@ void R4300iOp::DADDIU()
_GPR[m_Opcode.rt].DW = _GPR[m_Opcode.rs].DW + (int64_t)((int16_t)m_Opcode.immediate);
}
uint64_t LDL_MASK[8] = { 0, 0xFF, 0xFFFF, 0xFFFFFF, 0xFFFFFFFF, 0xFFFFFFFFFF, 0xFFFFFFFFFFFF, 0xFFFFFFFFFFFFFF };
int32_t LDL_SHIFT[8] = { 0, 8, 16, 24, 32, 40, 48, 56 };
uint64_t LDL_MASK[8] = {0, 0xFF, 0xFFFF, 0xFFFFFF, 0xFFFFFFFF, 0xFFFFFFFFFF, 0xFFFFFFFFFFFF, 0xFFFFFFFFFFFFFF};
int32_t LDL_SHIFT[8] = {0, 8, 16, 24, 32, 40, 48, 56};
void R4300iOp::LDL()
{
@ -1019,11 +1021,11 @@ void R4300iOp::LDL()
}
}
uint64_t LDR_MASK[8] = { 0xFFFFFFFFFFFFFF00, 0xFFFFFFFFFFFF0000,
0xFFFFFFFFFF000000, 0xFFFFFFFF00000000,
0xFFFFFF0000000000, 0xFFFF000000000000,
0xFF00000000000000, 0 };
int32_t LDR_SHIFT[8] = { 56, 48, 40, 32, 24, 16, 8, 0 };
uint64_t LDR_MASK[8] = {0xFFFFFFFFFFFFFF00, 0xFFFFFFFFFFFF0000,
0xFFFFFFFFFF000000, 0xFFFFFFFF00000000,
0xFFFFFF0000000000, 0xFFFF000000000000,
0xFF00000000000000, 0};
int32_t LDR_SHIFT[8] = {56, 48, 40, 32, 24, 16, 8, 0};
void R4300iOp::LDR()
{
@ -1161,15 +1163,15 @@ void R4300iOp::SW()
g_MMU->SW_Memory(Address, _GPR[m_Opcode.rt].UW[0]);
}
uint64_t SDL_MASK[8] = { 0, 0xFF00000000000000,
0xFFFF000000000000,
0xFFFFFF0000000000,
0xFFFFFFFF00000000,
0xFFFFFFFFFF000000,
0xFFFFFFFFFFFF0000,
0xFFFFFFFFFFFFFF00 };
uint64_t SDL_MASK[8] = {0, 0xFF00000000000000,
0xFFFF000000000000,
0xFFFFFF0000000000,
0xFFFFFFFF00000000,
0xFFFFFFFFFF000000,
0xFFFFFFFFFFFF0000,
0xFFFFFFFFFFFFFF00};
int32_t SDL_SHIFT[8] = { 0, 8, 16, 24, 32, 40, 48, 56 };
int32_t SDL_SHIFT[8] = {0, 8, 16, 24, 32, 40, 48, 56};
void R4300iOp::SDL()
{
@ -1188,16 +1190,16 @@ void R4300iOp::SDL()
}
}
uint64_t SDR_MASK[8] = { 0x00FFFFFFFFFFFFFF,
0x0000FFFFFFFFFFFF,
0x000000FFFFFFFFFF,
0x00000000FFFFFFFF,
0x0000000000FFFFFF,
0x000000000000FFFF,
0x00000000000000FF,
0x0000000000000000 };
uint64_t SDR_MASK[8] = {0x00FFFFFFFFFFFFFF,
0x0000FFFFFFFFFFFF,
0x000000FFFFFFFFFF,
0x00000000FFFFFFFF,
0x0000000000FFFFFF,
0x000000000000FFFF,
0x00000000000000FF,
0x0000000000000000};
int32_t SDR_SHIFT[8] = { 56, 48, 40, 32, 24, 16, 8, 0 };
int32_t SDR_SHIFT[8] = {56, 48, 40, 32, 24, 16, 8, 0};
void R4300iOp::SDR()
{
@ -1232,7 +1234,6 @@ void R4300iOp::SWR()
{
GenerateTLBWriteException(Address, __FUNCTION__);
}
}
void R4300iOp::CACHE()

View File

@ -1,27 +1,27 @@
#include "stdafx.h"
#include <Common/Platform.h>
#include "Settings/SettingType/SettingsType-Application.h"
#include "Settings/SettingType/SettingsType-ApplicationPath.h"
#include "Settings/SettingType/SettingsType-ApplicationIndex.h"
#include "Settings/SettingType/SettingsType-ApplicationPath.h"
#include "Settings/SettingType/SettingsType-GameSetting.h"
#include "Settings/SettingType/SettingsType-GameSettingIndex.h"
#include "Settings/SettingType/SettingsType-RelativePath.h"
#include "Settings/SettingType/SettingsType-RomDatabase.h"
#include "Settings/SettingType/SettingsType-RomDatabaseSetting.h"
#include "Settings/SettingType/SettingsType-RomDatabaseIndex.h"
#include "Settings/SettingType/SettingsType-RDBCpuType.h"
#include "Settings/SettingType/SettingsType-RDBOnOff.h"
#include "Settings/SettingType/SettingsType-RDBRamSize.h"
#include "Settings/SettingType/SettingsType-RDBSaveChip.h"
#include "Settings/SettingType/SettingsType-RDBYesNo.h"
#include "Settings/SettingType/SettingsType-RDBOnOff.h"
#include "Settings/SettingType/SettingsType-RelativePath.h"
#include "Settings/SettingType/SettingsType-RomDatabase.h"
#include "Settings/SettingType/SettingsType-RomDatabaseIndex.h"
#include "Settings/SettingType/SettingsType-RomDatabaseSetting.h"
#include "Settings/SettingType/SettingsType-SelectedDirectory.h"
#include "Settings/SettingType/SettingsType-TempString.h"
#include "Settings/SettingType/SettingsType-TempNumber.h"
#include "Settings/SettingType/SettingsType-TempBool.h"
#include <Project64-core/Settings.h>
#include <Project64-core/N64System/N64Types.h>
#include "Settings/SettingType/SettingsType-TempNumber.h"
#include "Settings/SettingType/SettingsType-TempString.h"
#include <Common/Platform.h>
#include <Common/Trace.h>
#include <Project64-core/N64System/N64Types.h>
#include <Project64-core/Settings.h>
CSettings * g_Settings = nullptr;
@ -95,53 +95,53 @@ void CSettings::AddHowToHandleSetting(const char * BaseDirectory)
AddHandler(SupportFile_EnhancementDirDefault, new CSettingTypeRelativePath("Config\\Enhancements", ""));
AddHandler(SupportFile_UserEnhancementDir, new CSettingTypeApplicationPath("Settings", "UserEnhancementDir", SupportFile_UserEnhancementDirDefault));
AddHandler(SupportFile_UserEnhancementDirDefault, new CSettingTypeRelativePath("Config\\Enhancements-User", ""));
AddHandler(SupportFile_Notes, new CSettingTypeApplicationPath("Settings", "Notes", SupportFile_NotesDefault));
AddHandler(SupportFile_Notes, new CSettingTypeApplicationPath("Settings", "Notes", SupportFile_NotesDefault));
AddHandler(SupportFile_NotesDefault, new CSettingTypeRelativePath("Config", "Project64.rdn"));
AddHandler(SupportFile_ExtInfo, new CSettingTypeApplicationPath("Settings", "ExtInfo", SupportFile_ExtInfoDefault));
AddHandler(SupportFile_ExtInfoDefault, new CSettingTypeRelativePath("Config", "Project64.rdx"));
// Settings location
AddHandler(Setting_ApplicationName, new CSettingTypeTempString(""));
AddHandler(Setting_UseFromRegistry, new CSettingTypeApplication("Settings", "Use Registry", (uint32_t)false));
AddHandler(Setting_UseFromRegistry, new CSettingTypeApplication("Settings", "Use Registry", (uint32_t) false));
AddHandler(Setting_RdbEditor, new CSettingTypeApplication("Settings", "Rdb Editor", false));
AddHandler(Setting_CN64TimeCritical, new CSettingTypeApplication("Settings", "CN64TimeCritical", false));
AddHandler(Setting_AutoStart, new CSettingTypeApplication("Settings", "Auto Start", (uint32_t)true));
AddHandler(Setting_AutoZipInstantSave, new CSettingTypeApplication("Settings", "Auto Zip Saves", (uint32_t)true));
AddHandler(Setting_EraseGameDefaults, new CSettingTypeApplication("Settings", "Erase on default", (uint32_t)true));
AddHandler(Setting_CheckEmuRunning, new CSettingTypeApplication("Settings", "Check Running", (uint32_t)true));
AddHandler(Setting_AutoStart, new CSettingTypeApplication("Settings", "Auto Start", (uint32_t) true));
AddHandler(Setting_AutoZipInstantSave, new CSettingTypeApplication("Settings", "Auto Zip Saves", (uint32_t) true));
AddHandler(Setting_EraseGameDefaults, new CSettingTypeApplication("Settings", "Erase on default", (uint32_t) true));
AddHandler(Setting_CheckEmuRunning, new CSettingTypeApplication("Settings", "Check Running", (uint32_t) true));
#ifndef _M_X64
AddHandler(Setting_ForceInterpreterCPU, new CSettingTypeApplication("Settings", "Force Interpreter CPU", false));
#else
AddHandler(Setting_ForceInterpreterCPU, new CSettingTypeApplication("Settings", "Force Interpreter CPU", true));
#endif
AddHandler(Setting_FixedRdramAddress, new CSettingTypeApplication("Settings", "Fixed Rdram Address", (uint32_t)0));
AddHandler(Setting_Enhancement, new CSettingTypeApplication("Settings", "Enable Enhancement", (uint32_t)true));
AddHandler(Setting_RememberCheats, new CSettingTypeApplication("Settings", "Remember Cheats", (bool)false));
AddHandler(Setting_Enhancement, new CSettingTypeApplication("Settings", "Enable Enhancement", (uint32_t) true));
AddHandler(Setting_RememberCheats, new CSettingTypeApplication("Settings", "Remember Cheats", (bool)false));
AddHandler(Setting_UniqueSaveDir, new CSettingTypeApplication("Settings", "Unique Game Dir", true));
AddHandler(Setting_CurrentLanguage, new CSettingTypeApplication("Settings", "Current Language", ""));
AddHandler(Setting_EnableDisk, new CSettingTypeTempBool(false));
AddHandler(Setting_LanguageDirDefault, new CSettingTypeRelativePath("Lang", ""));
AddHandler(Setting_LanguageDir, new CSettingTypeApplicationPath("Lang Directory", "Directory", Setting_LanguageDirDefault));
AddHandler(Setting_SyncViaAudioEnabled, new CSettingTypeTempBool(false, "SyncViaAudioEnabled"));
AddHandler(Setting_SyncViaAudioEnabled, new CSettingTypeTempBool(false, "SyncViaAudioEnabled"));
AddHandler(Setting_DiskSaveType, new CSettingTypeApplication("Settings", "Disk Save Type", (uint32_t)1));
AddHandler(Setting_UpdateControllerOnRefresh, new CSettingTypeTempBool(false));
AddHandler(Default_RDRamSize, new CSettingTypeApplication("Defaults", "RDRAM Size", 0x800000u));
AddHandler(Default_UseHleGfx, new CSettingTypeApplication("Defaults", "HLE GFX Default", true));
AddHandler(Default_ViRefreshRate, new CSettingTypeApplication("Defaults", "ViRefresh", 1500u));
AddHandler(Default_AiCountPerBytes, new CSettingTypeApplication("Defaults", "AiCountPerBytes", 0u));
AddHandler(Default_CounterFactor, new CSettingTypeApplication("Defaults", "Counter Factor", 2u));
AddHandler(Default_32Bit, new CSettingTypeApplication("Defaults", "32bit", false));
AddHandler(Default_SyncViaAudio, new CSettingTypeApplication("Defaults", "Audio-Sync Audio", true));
AddHandler(Default_FixedAudio, new CSettingTypeApplication("Defaults", "Fixed Audio", true));
AddHandler(Default_UnalignedDMA, new CSettingTypeApplication("Defaults", "Unaligned DMA", false));
AddHandler(Default_RandomizeSIPIInterrupts, new CSettingTypeApplication("Defaults", "Randomize SI/PI Interrupts", true));
AddHandler(Default_SMM_Protect_Memory, new CSettingTypeApplication("Defaults", "SMM-Protect", false));
AddHandler(Default_RDRamSize, new CSettingTypeApplication("Defaults", "RDRAM Size", 0x800000u));
AddHandler(Default_UseHleGfx, new CSettingTypeApplication("Defaults", "HLE GFX Default", true));
AddHandler(Default_ViRefreshRate, new CSettingTypeApplication("Defaults", "ViRefresh", 1500u));
AddHandler(Default_AiCountPerBytes, new CSettingTypeApplication("Defaults", "AiCountPerBytes", 0u));
AddHandler(Default_CounterFactor, new CSettingTypeApplication("Defaults", "Counter Factor", 2u));
AddHandler(Default_32Bit, new CSettingTypeApplication("Defaults", "32bit", false));
AddHandler(Default_SyncViaAudio, new CSettingTypeApplication("Defaults", "Audio-Sync Audio", true));
AddHandler(Default_FixedAudio, new CSettingTypeApplication("Defaults", "Fixed Audio", true));
AddHandler(Default_UnalignedDMA, new CSettingTypeApplication("Defaults", "Unaligned DMA", false));
AddHandler(Default_RandomizeSIPIInterrupts, new CSettingTypeApplication("Defaults", "Randomize SI/PI Interrupts", true));
AddHandler(Default_SMM_Protect_Memory, new CSettingTypeApplication("Defaults", "SMM-Protect", false));
AddHandler(Default_DiskSeekTiming, new CSettingTypeApplication("Defaults", "Disk Seek Timing", (uint32_t)DiskSeek_Turbo));
AddHandler(Rdb_GoodName, new CSettingTypeRomDatabase("Good Name", Game_GameName));
AddHandler(Rdb_RPCKey, new CSettingTypeRomDatabase("RPC Key", Game_RPCKey));
AddHandler(Rdb_RPCKey, new CSettingTypeRomDatabase("RPC Key", Game_RPCKey));
AddHandler(Rdb_SaveChip, new CSettingTypeRDBSaveChip("Save Type", (uint32_t)SaveChip_Auto));
AddHandler(Rdb_CpuType, new CSettingTypeRDBCpuType("CPU Type", CPU_Recompiler));
AddHandler(Rdb_RDRamSize, new CSettingTypeRDBRDRamSize("RDRAM Size", Default_RDRamSize));
@ -164,9 +164,9 @@ void CSettings::AddHowToHandleSetting(const char * BaseDirectory)
#ifdef ANDROID
AddHandler(Rdb_BlockLinking, new CSettingTypeRDBOnOff("Linking", false));
#else
AddHandler(Rdb_BlockLinking, new CSettingTypeRDBOnOff("Linking", true));
AddHandler(Rdb_BlockLinking, new CSettingTypeRDBOnOff("Linking", true));
#endif
AddHandler(Rdb_SMM_Cache, new CSettingTypeRomDatabase("SMM-Cache", true));
AddHandler(Rdb_SMM_Cache, new CSettingTypeRomDatabase("SMM-Cache", true));
AddHandler(Rdb_SMM_StoreInstruc, new CSettingTypeRomDatabase("SMM-StoreInstr", false));
AddHandler(Rdb_SMM_PIDMA, new CSettingTypeRomDatabase("SMM-PI DMA", true));
AddHandler(Rdb_SMM_TLB, new CSettingTypeRomDatabase("SMM-TLB", true));
@ -238,12 +238,12 @@ void CSettings::AddHowToHandleSetting(const char * BaseDirectory)
AddHandler(Game_FullSpeed, new CSettingTypeTempBool(true, "Full Speed"));
AddHandler(Game_UnalignedDMA, new CSettingTypeGame("Unaligned DMA", Rdb_UnalignedDMA));
AddHandler(Game_RandomizeSIPIInterrupts, new CSettingTypeGame("Randomize SI/PI Interrupts", Rdb_RandomizeSIPIInterrupts));
AddHandler(Game_RPCKey, new CSettingTypeTempString(""));
AddHandler(Game_RPCKey, new CSettingTypeTempString(""));
AddHandler(Game_DiskSeekTiming, new CSettingTypeGame("DiskSeekTiming", Rdb_DiskSeekTiming));
// User interface
AddHandler(UserInterface_ShowCPUPer, new CSettingTypeApplication("Settings", "Display CPU Usage", (uint32_t)false));
AddHandler(UserInterface_DisplayFrameRate, new CSettingTypeApplication("Settings", "Display Frame Rate", (uint32_t)false));
AddHandler(UserInterface_ShowCPUPer, new CSettingTypeApplication("Settings", "Display CPU Usage", (uint32_t) false));
AddHandler(UserInterface_DisplayFrameRate, new CSettingTypeApplication("Settings", "Display Frame Rate", (uint32_t) false));
AddHandler(UserInterface_FrameDisplayType, new CSettingTypeApplication("Settings", "Frame Rate Display Type", (uint32_t)FR_VIs));
AddHandler(Directory_Plugin, new CSettingTypeSelectedDirectory("Dir:Plugin", Directory_PluginInitial, Directory_PluginSelected, Directory_PluginUseSelected, Directory_Plugin));
#ifndef _M_X64
@ -313,7 +313,7 @@ void CSettings::AddHowToHandleSetting(const char * BaseDirectory)
AddHandler(GameRunning_ScreenHertz, new CSettingTypeTempNumber(60));
AddHandler(GameRunning_InReset, new CSettingTypeTempBool(false));
AddHandler(UserInterface_BasicMode, new CSettingTypeApplication("Settings", "Basic Mode", (uint32_t)true));
AddHandler(UserInterface_BasicMode, new CSettingTypeApplication("Settings", "Basic Mode", (uint32_t) true));
AddHandler(File_DiskIPLPath, new CSettingTypeApplicationPath("Settings", "Disk IPL ROM Path", Default_None));
AddHandler(File_DiskIPLUSAPath, new CSettingTypeApplicationPath("Settings", "Disk IPL USA ROM Path", Default_None));
AddHandler(File_DiskIPLTOOLPath, new CSettingTypeApplicationPath("Settings", "Disk IPL TOOL ROM Path", Default_None));
@ -342,7 +342,7 @@ void CSettings::AddHowToHandleSetting(const char * BaseDirectory)
AddHandler(Debugger_IntrBreakpoints, new CSettingTypeApplication("Debugger", "Interrupt Breakpoints", (uint32_t)0));
AddHandler(Debugger_RcpIntrBreakpoints, new CSettingTypeApplication("Debugger", "RCP Interrupt Breakpoints", (uint32_t)0));
AddHandler(Debugger_DebugLanguage, new CSettingTypeApplication("Debugger", "Debug Language", false));
AddHandler(Debugger_AppLogFlush, new CSettingTypeApplication("Logging", "Log Auto Flush", (uint32_t)false));
AddHandler(Debugger_AppLogFlush, new CSettingTypeApplication("Logging", "Log Auto Flush", (uint32_t) false));
AddHandler(Debugger_RecordRecompilerAsm, new CSettingTypeApplication("Debugger", "Record Recompiler Asm", false));
AddHandler(Debugger_AutorunScripts, new CSettingTypeApplication("Debugger", "Autorun Scripts", ""));
@ -375,8 +375,8 @@ void CSettings::AddHowToHandleSetting(const char * BaseDirectory)
AddHandler(Plugin_RSP_Current, new CSettingTypeApplication("Plugin", "RSP Dll", "RSP\\RSP 1.7.dll"));
#ifdef _DEBUG
AddHandler(Plugin_GFX_Default, new CSettingTypeApplication("Plugin", "Graphics Dll Default", "GFX\\Project64-Video_d.dll"));
AddHandler(Plugin_GFX_Current, new CSettingTypeApplication("Plugin", "Graphics Dll", Plugin_GFX_Default));
AddHandler(Plugin_AUDIO_Current, new CSettingTypeApplication("Plugin", "Audio Dll", "Audio\\Project64-Audio_d.dll"));
AddHandler(Plugin_GFX_Current, new CSettingTypeApplication("Plugin", "Graphics Dll", Plugin_GFX_Default));
AddHandler(Plugin_AUDIO_Current, new CSettingTypeApplication("Plugin", "Audio Dll", "Audio\\Project64-Audio_d.dll"));
AddHandler(Plugin_CONT_Current, new CSettingTypeApplication("Plugin", "Controller Dll", "Input\\Project64-Input_d.dll"));
#else
AddHandler(Plugin_GFX_Default, new CSettingTypeApplication("Plugin", "Graphics Dll Default", "GFX\\Project64-Video.dll"));
@ -395,7 +395,7 @@ void CSettings::AddHowToHandleSetting(const char * BaseDirectory)
AddHandler(Plugin_AUDIO_CurVer, new CSettingTypeApplication("Plugin", "Audio Dll Ver", ""));
AddHandler(Plugin_CONT_CurVer, new CSettingTypeApplication("Plugin", "Controller Dll Ver", ""));
AddHandler(Plugin_UseHleGfx, new CSettingTypeApplication("RSP", "HLE GFX Plugin", Default_UseHleGfx));
AddHandler(Plugin_UseHleGfx, new CSettingTypeApplication("RSP", "HLE GFX Plugin", Default_UseHleGfx));
AddHandler(Plugin_UseHleAudio, new CSettingTypeApplication("RSP", "HLE Audio Plugin", false));
AddHandler(Plugin_EnableAudio, new CSettingTypeApplication("Audio", "Enable Audio", true));
@ -426,12 +426,12 @@ void CSettings::AddHowToHandleSetting(const char * BaseDirectory)
AddHandler(Logging_LogRomHeader, new CSettingTypeApplication("Logging", "Generate Log Files", false));
AddHandler(Logging_LogUnknown, new CSettingTypeApplication("Logging", "Log Rom Header", false));
WriteTrace(TraceAppInit, TraceDebug, "Done");
WriteTrace(TraceAppInit, TraceDebug, "Done");
}
uint32_t CSettings::FindSetting(CSettings * _this, const char * Name)
{
uint32_t setting_id = 0;
uint32_t setting_id = 0;
for (SETTING_MAP::iterator iter = _this->m_SettingInfo.begin(); iter != _this->m_SettingInfo.end(); iter++)
{
CSettingType * Setting = iter->second;
@ -442,11 +442,11 @@ uint32_t CSettings::FindSetting(CSettings * _this, const char * Name)
{
continue;
}
if (setting_id != 0)
{
g_Notify->BreakPoint(__FILE__, __LINE__);
}
setting_id = iter->first;
if (setting_id != 0)
{
g_Notify->BreakPoint(__FILE__, __LINE__);
}
setting_id = iter->first;
}
else if (Setting->GetSettingType() == SettingType_CfgFile)
{
@ -455,11 +455,11 @@ uint32_t CSettings::FindSetting(CSettings * _this, const char * Name)
{
continue;
}
if (setting_id != 0)
{
g_Notify->BreakPoint(__FILE__, __LINE__);
}
setting_id = iter->first;
if (setting_id != 0)
{
g_Notify->BreakPoint(__FILE__, __LINE__);
}
setting_id = iter->first;
}
else if (Setting->GetSettingType() == SettingType_SelectedDirectory)
{
@ -468,11 +468,11 @@ uint32_t CSettings::FindSetting(CSettings * _this, const char * Name)
{
continue;
}
if (setting_id != 0)
{
g_Notify->BreakPoint(__FILE__, __LINE__);
}
setting_id = iter->first;
if (setting_id != 0)
{
g_Notify->BreakPoint(__FILE__, __LINE__);
}
setting_id = iter->first;
}
else if (Setting->GetSettingType() == SettingType_BoolVariable)
{
@ -481,11 +481,11 @@ uint32_t CSettings::FindSetting(CSettings * _this, const char * Name)
{
continue;
}
if (setting_id != 0)
{
g_Notify->BreakPoint(__FILE__, __LINE__);
}
setting_id = iter->first;
if (setting_id != 0)
{
g_Notify->BreakPoint(__FILE__, __LINE__);
}
setting_id = iter->first;
}
}
return setting_id;
@ -532,8 +532,8 @@ void CSettings::SetSettingSz(CSettings * _this, SettingID ID, const char * Value
}
void CSettings::RegisterSetting(CSettings * _this, SettingID ID, SettingID DefaultID, SettingDataType DataType,
SettingType Type, const char * Category, const char * DefaultStr,
uint32_t Value)
SettingType Type, const char * Category, const char * DefaultStr,
uint32_t Value)
{
SettingID RdbSetting;
stdstr Name;
@ -921,7 +921,7 @@ void CSettings::LoadDefaultBoolIndex(SettingID /*Type*/, uint32_t /*index*/, boo
g_Notify->BreakPoint(__FILE__, __LINE__);
}
uint32_t CSettings::LoadDefaultDword(SettingID Type)
uint32_t CSettings::LoadDefaultDword(SettingID Type)
{
uint32_t Value = 0;
LoadDefaultDword(Type, Value);

View File

@ -1,34 +1,35 @@
#pragma once
#include <Project64-core\Settings\SettingType\SettingsType-RomDatabase.h>
class CSettingTypeRDBCpuType :
public CSettingTypeRomDatabase
{
public:
CSettingTypeRDBCpuType(const char * Name, SettingID DefaultSetting );
CSettingTypeRDBCpuType(const char * Name, uint32_t DefaultValue );
CSettingTypeRDBCpuType(const char * Name, SettingID DefaultSetting);
CSettingTypeRDBCpuType(const char * Name, uint32_t DefaultValue);
~CSettingTypeRDBCpuType();
// Return the values
virtual bool Load (uint32_t Index, bool & Value ) const;
virtual bool Load (uint32_t Index, uint32_t & Value ) const;
virtual bool Load (uint32_t Index, std::string & Value ) const;
virtual bool Load(uint32_t Index, bool & Value) const;
virtual bool Load(uint32_t Index, uint32_t & Value) const;
virtual bool Load(uint32_t Index, std::string & Value) const;
// Return the default values
virtual void LoadDefault (uint32_t Index, bool & Value ) const;
virtual void LoadDefault (uint32_t Index, uint32_t & Value ) const;
virtual void LoadDefault (uint32_t Index, std::string & Value ) const;
virtual void LoadDefault(uint32_t Index, bool & Value) const;
virtual void LoadDefault(uint32_t Index, uint32_t & Value) const;
virtual void LoadDefault(uint32_t Index, std::string & Value) const;
// Update the settings
virtual void Save (uint32_t Index, bool Value );
virtual void Save (uint32_t Index, uint32_t Value );
virtual void Save (uint32_t Index, const std::string & Value );
virtual void Save (uint32_t Index, const char * Value );
virtual void Save(uint32_t Index, bool Value);
virtual void Save(uint32_t Index, uint32_t Value);
virtual void Save(uint32_t Index, const std::string & Value);
virtual void Save(uint32_t Index, const char * Value);
// Delete the setting
virtual void Delete (uint32_t Index );
virtual void Delete(uint32_t Index);
private:
CSettingTypeRDBCpuType(void);
CSettingTypeRDBCpuType(const CSettingTypeRDBCpuType&);
CSettingTypeRDBCpuType& operator=(const CSettingTypeRDBCpuType&);
CSettingTypeRDBCpuType(const CSettingTypeRDBCpuType &);
CSettingTypeRDBCpuType & operator=(const CSettingTypeRDBCpuType &);
};

View File

@ -1,9 +1,9 @@
#pragma once
#include "Support.h"
#include <string> // Needed for stl string (std::string)
#include <float.h>
#include <math.h>
#include <string>
#include "UserInterface.h"
#include <Project64-core/N64System/N64Types.h>
@ -12,9 +12,9 @@
// General MIPS information
#include <Project64-core/N64System/N64Rom.h>
#include <Project64-core/N64System/SpeedLimiter.h>
#include <Project64-core/N64System/Mips/R4300iOpcode.h>
#include <Project64-core/N64System/Recompiler/x86/x86ops.h>
#include <Project64-core/N64System/N64Rom.h>
#include <Project64-core/N64System/N64System.h>
#include <Project64-core/N64System/Recompiler/x86/x86ops.h>
#include <Project64-core/N64System/SpeedLimiter.h>
#include <Project64-core/N64System/SystemGlobals.h>

View File

@ -8,24 +8,24 @@ public:
typedef struct
{
PLUGIN_INFO Info;
bool AboutFunction;
CPath FullPath;
stdstr FileName;
bool AboutFunction;
CPath FullPath;
stdstr FileName;
} PLUGIN;
public:
CPluginList(bool bAutoFill = true);
~CPluginList();
bool LoadList(void);
int GetPluginCount(void) const;
bool LoadList(void);
int GetPluginCount(void) const;
const PLUGIN * GetPluginInfo(int indx) const;
private:
typedef std::vector<PLUGIN> PluginList;
typedef std::vector<PLUGIN> PluginList;
PluginList m_PluginList;
CPath m_PluginDir;
CPath m_PluginDir;
void AddPluginFromDir(CPath Dir);
};

View File

@ -3,18 +3,23 @@
class CGuiSettings
{
protected:
CGuiSettings();
virtual ~CGuiSettings();
static inline bool bCPURunning ( void) { return m_bCPURunning; }
static inline bool bAutoSleep ( void) { return m_bAutoSleep; }
CGuiSettings();
virtual ~CGuiSettings();
static inline bool bCPURunning(void)
{
return m_bCPURunning;
}
static inline bool bAutoSleep(void)
{
return m_bAutoSleep;
}
private:
static void RefreshSettings (void *);
static void RefreshSettings(void *);
static bool m_bCPURunning;
static bool m_bAutoSleep;
static int m_RefCount;
static bool m_bCPURunning;
static bool m_bAutoSleep;
static int m_RefCount;
};

View File

@ -16,5 +16,8 @@ protected:
virtual ~CNotificationSettings();
void RegisterNotifications(void);
inline bool InFullScreen(void) const { return m_bInFullScreen; }
inline bool InFullScreen(void) const
{
return m_bInFullScreen;
}
};

View File

@ -1,6 +1,6 @@
#pragma once
#include <string>
#include <stdint.h>
#include <string>
enum UISettingID
{
@ -16,7 +16,7 @@ enum UISettingID
// Settings location
Setting_PluginPageFirst,
Setting_DisableScrSaver,
Setting_EnableDiscordRPC,
Setting_EnableDiscordRPC,
Setting_AutoSleep,
Setting_AutoFullscreen,
@ -71,7 +71,7 @@ enum UISettingID
};
float DPIScale(void);
void RegisterUISettings (void);
void RegisterUISettings(void);
void UISettingsSaveBool(UISettingID Type, bool Value);
void UISettingsSaveBoolIndex(UISettingID Type, int32_t index, bool Value);
void UISettingsSaveDword(UISettingID Type, uint32_t Value);

View File

@ -2,12 +2,12 @@
#include <windows.h>
#endif
#include <Common/MemTest.h>
#include <Common/CriticalSection.h>
#include <Common/StdString.h>
#include <Common/File.h>
#include <Common/Log.h>
#include <Common/Trace.h>
#include <Common/path.h>
#include <Common/IniFile.h>
#include <Common/Log.h>
#include <Common/MemTest.h>
#include <Common/StdString.h>
#include <Common/Trace.h>
#include <Common/md5.h>
#include <Common/path.h>

View File

@ -1,20 +1,20 @@
#pragma once
#pragma warning(disable:4786)
#pragma warning(disable : 4786)
#include "Support.h"
#include <Project64-core/Multilanguage.h>
#include <Project64-core/Settings.h>
#include "WTLApp.h"
#include "UserInterface/MenuShortCuts.h"
#include "UserInterface/RomBrowser.h"
#include "UserInterface/CheatUI.h"
#include "UserInterface/MainMenu.h"
#include "UserInterface/MainWindow.h"
#include "UserInterface/MenuItem.h"
#include "UserInterface/MainMenu.h"
#include "UserInterface/MenuShortCuts.h"
#include "UserInterface/Notification.h"
#include <Project64-core/N64System/FramePerSecond.h>
#include "UserInterface/resource.h"
#include "UserInterface/RomBrowser.h"
#include "UserInterface/SettingsConfig.h"
#include "UserInterface/CheatUI.h"
#include "UserInterface/SupportWindow.h"
#include "UserInterface/resource.h"
#include "WTLApp.h"
#include <Project64-core/N64System/FramePerSecond.h>

View File

@ -1,29 +1,34 @@
#pragma once
#include <Project64\UserInterface\WTLControls\wtl-BitmapPicture.h>
#include "resource.h"
#include <Project64\UserInterface\WTLControls\wtl-BitmapPicture.h>
class CAboutDlg :
public CDialogImpl<CAboutDlg>
{
public:
BEGIN_MSG_MAP_EX(CAboutDlg)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
MESSAGE_HANDLER(WM_CTLCOLORSTATIC, OnColorStatic)
MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBackground)
COMMAND_ID_HANDLER(IDOK, OnOkCmd)
COMMAND_ID_HANDLER(IDCANCEL, OnOkCmd)
{
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog);
MESSAGE_HANDLER(WM_CTLCOLORSTATIC, OnColorStatic);
MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBackground);
COMMAND_ID_HANDLER(IDOK, OnOkCmd);
COMMAND_ID_HANDLER(IDCANCEL, OnOkCmd);
}
END_MSG_MAP()
enum { IDD = IDD_About };
enum
{
IDD = IDD_About
};
CAboutDlg(CProjectSupport & Support);
private:
CAboutDlg(void);
CAboutDlg(const CAboutDlg&);
CAboutDlg& operator=(const CAboutDlg&);
CAboutDlg(const CAboutDlg &);
CAboutDlg & operator=(const CAboutDlg &);
void SetWindowDetais(int nIDDlgItem, int nAboveIDDlgItem, const wchar_t * Text, const HFONT &font);
void SetWindowDetais(int nIDDlgItem, int nAboveIDDlgItem, const wchar_t * Text, const HFONT & font);
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled);
LRESULT OnColorStatic(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled);

View File

@ -322,7 +322,10 @@ LRESULT CCheatList::OnTreeClicked(NMHDR * lpnmh)
LRESULT CCheatList::OnTreeRClicked(NMHDR * lpnmh)
{
if (g_Settings->LoadBool(UserInterface_BasicMode)) { return true; }
if (g_Settings->LoadBool(UserInterface_BasicMode))
{
return true;
}
// Work out what item is selected
TVHITTESTINFO ht = {0};
@ -397,7 +400,10 @@ LRESULT CCheatList::OnTreeSelChanged(NMHDR * /*lpnmh*/)
void CCheatList::RefreshItems()
{
if (m_hWnd == nullptr) { return; }
if (m_hWnd == nullptr)
{
return;
}
m_DeleteingEntries = true;
m_hCheatTree.DeleteAllItems();
@ -419,9 +425,15 @@ void CCheatList::AddCodeLayers(LPARAM Enhancement, const std::wstring & Name, HT
TV_INSERTSTRUCT tv;
wchar_t Text[500], Item[500];
if (Name.length() > ((sizeof(Text) / sizeof(Text[0])) - 5)) { g_Notify->BreakPoint(__FILE__, __LINE__); }
if (Name.length() > ((sizeof(Text) / sizeof(Text[0])) - 5))
{
g_Notify->BreakPoint(__FILE__, __LINE__);
}
wcscpy(Text, Name.c_str());
if (wcschr(Text, L'\\') > 0) { *wcschr(Text, L'\\') = 0; }
if (wcschr(Text, L'\\') > 0)
{
*wcschr(Text, L'\\') = 0;
}
tv.item.mask = TVIF_TEXT;
tv.item.pszText = Item;
@ -457,7 +469,10 @@ void CCheatList::AddCodeLayers(LPARAM Enhancement, const std::wstring & Name, HT
hParent = TreeView_InsertItem(m_hCheatTree, &tv);
TV_SetCheckState(hParent, CheatActive ? TV_STATE_CHECKED : TV_STATE_CLEAR);
if (wcscmp(Text, Name.c_str()) == 0) { return; }
if (wcscmp(Text, Name.c_str()) == 0)
{
return;
}
AddCodeLayers(Enhancement, Name.substr(wcslen(Text) + 1), hParent, CheatActive);
}
@ -466,9 +481,12 @@ void CCheatList::ChangeChildrenStatus(HTREEITEM hParent, bool Checked)
HTREEITEM hItem = m_hCheatTree.GetChildItem(hParent);
if (hItem == nullptr)
{
if (hParent == TVI_ROOT) { return; }
if (hParent == TVI_ROOT)
{
return;
}
TVITEM item = { 0 };
TVITEM item = {0};
item.mask = TVIF_PARAM;
item.hItem = hParent;
m_hCheatTree.GetItem(&item);
@ -494,14 +512,19 @@ void CCheatList::ChangeChildrenStatus(HTREEITEM hParent, bool Checked)
while (hItem != nullptr)
{
TV_CHECK_STATE ChildState = TV_GetCheckState(hItem);
if ((ChildState != TV_STATE_CHECKED || !Checked) &&
(ChildState != TV_STATE_CLEAR || Checked))
if ((ChildState != TV_STATE_CHECKED || !Checked) && (ChildState != TV_STATE_CLEAR || Checked))
{
ChangeChildrenStatus(hItem, Checked);
}
ChildState = TV_GetCheckState(hItem);
if (state == TV_STATE_UNKNOWN) { state = ChildState; }
if (state != ChildState) { state = TV_STATE_INDETERMINATE; }
if (state == TV_STATE_UNKNOWN)
{
state = ChildState;
}
if (state != ChildState)
{
state = TV_STATE_INDETERMINATE;
}
hItem = m_hCheatTree.GetNextSiblingItem(hItem);
}
if (state != TV_STATE_UNKNOWN)
@ -603,8 +626,14 @@ void CCheatList::MenuSetText(HMENU hMenu, int MenuPos, const wchar_t * Title, co
GetMenuItemInfo(hMenu, MenuPos, true, &MenuInfo);
wcscpy(String, Title);
if (wcschr(String, '\t') != nullptr) { *(wcschr(String, '\t')) = '\0'; }
if (ShortCut) { _swprintf(String, L"%s\t%s", String, ShortCut); }
if (wcschr(String, '\t') != nullptr)
{
*(wcschr(String, '\t')) = '\0';
}
if (ShortCut)
{
_swprintf(String, L"%s\t%s", String, ShortCut);
}
SetMenuItemInfo(hMenu, MenuPos, true, &MenuInfo);
}
@ -865,10 +894,7 @@ bool CEditCheat::ValuesChanged(void)
bool Changed = false;
if (m_hWnd != nullptr)
{
if (m_EditName != GetCWindowText(GetDlgItem(IDC_CODE_NAME)) ||
m_EditCode != GetCWindowText(GetDlgItem(IDC_CHEAT_CODES)) ||
m_EditOptions != GetCWindowText(GetDlgItem(IDC_CHEAT_OPTIONS)) ||
m_EditNotes != GetCWindowText(GetDlgItem(IDC_NOTES)))
if (m_EditName != GetCWindowText(GetDlgItem(IDC_CODE_NAME)) || m_EditCode != GetCWindowText(GetDlgItem(IDC_CHEAT_CODES)) || m_EditOptions != GetCWindowText(GetDlgItem(IDC_CHEAT_OPTIONS)) || m_EditNotes != GetCWindowText(GetDlgItem(IDC_NOTES)))
{
Changed = true;
}

View File

@ -1,7 +1,7 @@
#pragma once
#include <Project64\WTLApp.h>
#include <Project64-core/N64System/Enhancement/Enhancement.h>
#include <Project64-core/N64System/Enhancement/EnhancementList.h>
#include <Project64\WTLApp.h>
class CEditCheat;
class CCheatsUI;
@ -16,18 +16,23 @@ class CCheatList :
public:
BEGIN_MSG_MAP_EX(CCheatList)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
MESSAGE_HANDLER(UM_CHANGECODEEXTENSION, OnChangeCodeExtension)
COMMAND_ID_HANDLER(IDC_UNMARK, OnUnmark)
COMMAND_ID_HANDLER(ID_POPUP_DELETE, OnPopupDelete)
NOTIFY_HANDLER_EX(IDC_MYTREE, NM_CLICK, OnTreeClicked)
NOTIFY_HANDLER_EX(IDC_MYTREE, NM_RCLICK, OnTreeRClicked)
NOTIFY_HANDLER_EX(IDC_MYTREE, NM_DBLCLK, OnTreeDClicked)
NOTIFY_HANDLER_EX(IDC_MYTREE, TVN_SELCHANGED, OnTreeSelChanged)
{
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog);
MESSAGE_HANDLER(WM_DESTROY, OnDestroy);
MESSAGE_HANDLER(UM_CHANGECODEEXTENSION, OnChangeCodeExtension);
COMMAND_ID_HANDLER(IDC_UNMARK, OnUnmark);
COMMAND_ID_HANDLER(ID_POPUP_DELETE, OnPopupDelete);
NOTIFY_HANDLER_EX(IDC_MYTREE, NM_CLICK, OnTreeClicked);
NOTIFY_HANDLER_EX(IDC_MYTREE, NM_RCLICK, OnTreeRClicked);
NOTIFY_HANDLER_EX(IDC_MYTREE, NM_DBLCLK, OnTreeDClicked);
NOTIFY_HANDLER_EX(IDC_MYTREE, TVN_SELCHANGED, OnTreeSelChanged);
}
END_MSG_MAP()
enum { IDD = IDD_Cheats_List };
enum
{
IDD = IDD_Cheats_List
};
CCheatList(CEnhancementList & Cheats, CEditCheat & EditCheat);
~CCheatList();
@ -36,21 +41,27 @@ public:
private:
CCheatList(void);
CCheatList(const CCheatList&);
CCheatList& operator=(const CCheatList&);
CCheatList(const CCheatList &);
CCheatList & operator=(const CCheatList &);
enum TV_CHECK_STATE { TV_STATE_UNKNOWN, TV_STATE_CLEAR, TV_STATE_CHECKED, TV_STATE_INDETERMINATE };
enum TV_CHECK_STATE
{
TV_STATE_UNKNOWN,
TV_STATE_CLEAR,
TV_STATE_CHECKED,
TV_STATE_INDETERMINATE
};
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnChangeCodeExtension(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnUnmark(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnPopupDelete(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnTreeClicked(NMHDR* lpnmh);
LRESULT OnTreeRClicked(NMHDR* lpnmh);
LRESULT OnTreeDClicked(NMHDR* lpnmh);
LRESULT OnTreeSelChanged(NMHDR* lpnmh);
void AddCodeLayers(LPARAM ListID, const std::wstring &Name, HTREEITEM hParent, bool CheatActive);
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled);
LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled);
LRESULT OnChangeCodeExtension(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled);
LRESULT OnUnmark(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL & bHandled);
LRESULT OnPopupDelete(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL & bHandled);
LRESULT OnTreeClicked(NMHDR * lpnmh);
LRESULT OnTreeRClicked(NMHDR * lpnmh);
LRESULT OnTreeDClicked(NMHDR * lpnmh);
LRESULT OnTreeSelChanged(NMHDR * lpnmh);
void AddCodeLayers(LPARAM ListID, const std::wstring & Name, HTREEITEM hParent, bool CheatActive);
void ChangeChildrenStatus(HTREEITEM hParent, bool Checked);
void CheckParentStatus(HTREEITEM hParent);
void DeleteCheat(LPARAM Enhancement);
@ -58,7 +69,10 @@ private:
bool TV_SetCheckState(HTREEITEM hItem, TV_CHECK_STATE state);
static void MenuSetText(HMENU hMenu, int MenuPos, const wchar_t * Title, const wchar_t * ShortCut);
enum { IDC_MYTREE = 0x500 };
enum
{
IDC_MYTREE = 0x500
};
CEnhancementList & m_Cheats;
CEditCheat & m_EditCheat;
@ -79,32 +93,35 @@ public:
};
BEGIN_MSG_MAP_EX(CEditCheat)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
MESSAGE_HANDLER(WM_EDITCHEAT, OnEditCheat)
COMMAND_ID_HANDLER(IDC_ADD, OnAddCheat)
COMMAND_ID_HANDLER(IDC_NEWCHEAT, OnNewCheat)
COMMAND_HANDLER(IDC_CODE_NAME, EN_CHANGE, OnCodeNameChanged)
COMMAND_HANDLER(IDC_CHEAT_CODES, EN_CHANGE, OnCheatCodeChanged)
COMMAND_HANDLER(IDC_CHEAT_OPTIONS, EN_CHANGE, OnCheatOptionsChanged)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
MESSAGE_HANDLER(WM_EDITCHEAT, OnEditCheat)
COMMAND_ID_HANDLER(IDC_ADD, OnAddCheat)
COMMAND_ID_HANDLER(IDC_NEWCHEAT, OnNewCheat)
COMMAND_HANDLER(IDC_CODE_NAME, EN_CHANGE, OnCodeNameChanged)
COMMAND_HANDLER(IDC_CHEAT_CODES, EN_CHANGE, OnCheatCodeChanged)
COMMAND_HANDLER(IDC_CHEAT_OPTIONS, EN_CHANGE, OnCheatOptionsChanged)
END_MSG_MAP()
enum { IDD = IDD_Cheats_Add };
enum
{
IDD = IDD_Cheats_Add
};
CEditCheat(CEnhancementList & Cheats, CCheatList & CheatList);
~CEditCheat();
private:
CEditCheat();
CEditCheat(const CEditCheat&);
CEditCheat& operator=(const CEditCheat&);
CEditCheat(const CEditCheat &);
CEditCheat & operator=(const CEditCheat &);
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnEditCheat(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnAddCheat(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnNewCheat(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnCodeNameChanged(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnCheatCodeChanged(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnCheatOptionsChanged(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled);
LRESULT OnEditCheat(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled);
LRESULT OnAddCheat(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL & bHandled);
LRESULT OnNewCheat(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL & bHandled);
LRESULT OnCodeNameChanged(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL & bHandled);
LRESULT OnCheatCodeChanged(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL & bHandled);
LRESULT OnCheatOptionsChanged(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL & bHandled);
bool ReadEnhancement(CEnhancement & Enhancement);
@ -126,25 +143,28 @@ class CEnhancementCodeEx :
{
public:
BEGIN_MSG_MAP_EX(CEnhancementCodeEx)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
COMMAND_HANDLER(IDC_CHEAT_LIST, LBN_DBLCLK, OnListDblClick)
COMMAND_ID_HANDLER(IDOK, OnOkCmd)
COMMAND_ID_HANDLER(IDCANCEL, OnCloseCmd)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
COMMAND_HANDLER(IDC_CHEAT_LIST, LBN_DBLCLK, OnListDblClick)
COMMAND_ID_HANDLER(IDOK, OnOkCmd)
COMMAND_ID_HANDLER(IDCANCEL, OnCloseCmd)
END_MSG_MAP()
enum { IDD = IDD_Cheats_CodeEx };
enum
{
IDD = IDD_Cheats_CodeEx
};
CEnhancementCodeEx(CEnhancement * Enhancement);
private:
CEnhancementCodeEx();
CEnhancementCodeEx(const CEnhancementCodeEx&);
CEnhancementCodeEx& operator=(const CEnhancementCodeEx&);
CEnhancementCodeEx(const CEnhancementCodeEx &);
CEnhancementCodeEx & operator=(const CEnhancementCodeEx &);
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnListDblClick(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnOkCmd(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnCloseCmd(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled);
LRESULT OnListDblClick(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL & bHandled);
LRESULT OnOkCmd(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL & bHandled);
LRESULT OnCloseCmd(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL & bHandled);
CEnhancement * m_Enhancement;
};
@ -158,13 +178,18 @@ class CCheatsUI :
public:
BEGIN_MSG_MAP_EX(CCheatsUI)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
COMMAND_ID_HANDLER(IDC_STATE, OnStateChange)
COMMAND_ID_HANDLER(IDCANCEL, OnCloseCmd)
{
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog);
MESSAGE_HANDLER(WM_DESTROY, OnDestroy);
COMMAND_ID_HANDLER(IDC_STATE, OnStateChange);
COMMAND_ID_HANDLER(IDCANCEL, OnCloseCmd);
}
END_MSG_MAP()
enum { IDD = IDD_Cheats_Select };
enum
{
IDD = IDD_Cheats_Select
};
CCheatsUI(void);
~CCheatsUI(void);
@ -172,17 +197,21 @@ public:
void Display(HWND hParent, bool BlockExecution);
private:
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnCloseCmd(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnStateChange(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled);
LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled);
LRESULT OnCloseCmd(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL & bHandled);
LRESULT OnStateChange(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL & bHandled);
CEnhancementList m_Cheats;
CEditCheat m_EditCheat;
CCheatList m_SelectCheat;
CButton m_StateBtn;
int m_MinSizeDlg, m_MaxSizeDlg;
int m_MinSizeDlg, m_MaxSizeDlg;
bool m_bModal;
enum Dialog_State { CONTRACTED, EXPANDED } m_DialogState;
enum Dialog_State
{
CONTRACTED,
EXPANDED
} m_DialogState;
};

View File

@ -35,262 +35,366 @@ const ASM_SYNTAX_FN CAssembler::syn_cop_mv[] = {arg_reg_t, arg_reg_d, nullptr};
const ASM_SYNTAX_FN CAssembler::syn_cache[] = {arg_cache_op, arg_imm16, arg_reg_s, nullptr};
const ASM_SYNTAX_FN CAssembler::syn_syscall[] = {arg_syscall_code, nullptr};
const ASM_INSTRUCTION CAssembler::m_Instructions[] =
{
{ "j", R4300i_J, base_op, syn_jump },
{ "jal", R4300i_JAL, base_op, syn_jump },
{ "beq", R4300i_BEQ, base_op, syn_branch },
{ "beqz", R4300i_BEQ, base_op, syn_branch_z },
{ "b", R4300i_BEQ, base_op, syn_branch_unc },
{ "bne", R4300i_BNE, base_op, syn_branch },
{ "bnez", R4300i_BNE, base_op, syn_branch_z },
{ "blez", R4300i_BLEZ, base_op, syn_branch_z },
{ "bgtz", R4300i_BGTZ, base_op, syn_branch_z },
{ "addi", R4300i_ADDI, base_op, syn_arith_i },
{ "addiu", R4300i_ADDIU, base_op, syn_arith_i },
{ "slti", R4300i_SLTI, base_op, syn_arith_i },
{ "sltiu", R4300i_SLTIU, base_op, syn_arith_i },
{ "andi", R4300i_ANDI, base_op, syn_arith_i },
{ "ori", R4300i_ORI, base_op, syn_arith_i },
{ "xori", R4300i_XORI, base_op, syn_arith_i },
{ "lui", R4300i_LUI, base_op, syn_load_i },
{ "beql", R4300i_BEQL, base_op, syn_branch },
{ "beqzl", R4300i_BEQL, base_op, syn_branch_z },
{ "bnel", R4300i_BNEL, base_op, syn_branch },
{ "bnezl", R4300i_BNEL, base_op, syn_branch_z },
{ "blezl", R4300i_BLEZL, base_op, syn_branch_z },
{ "bgtzl", R4300i_BGTZL, base_op, syn_branch_z },
{ "daddi", R4300i_DADDI, base_op, syn_arith_i },
{ "daddiu", R4300i_DADDIU, base_op, syn_arith_i },
{ "ldl", R4300i_LDL, base_op, syn_loadstore },
{ "ldr", R4300i_LDR, base_op, syn_loadstore },
{ "lb", R4300i_LB, base_op, syn_loadstore },
{ "lh", R4300i_LH, base_op, syn_loadstore },
{ "lwl", R4300i_LWL, base_op, syn_loadstore },
{ "lw", R4300i_LW, base_op, syn_loadstore },
{ "lbu", R4300i_LBU, base_op, syn_loadstore },
{ "lhu", R4300i_LHU, base_op, syn_loadstore },
{ "lwr", R4300i_LWR, base_op, syn_loadstore },
{ "lwu", R4300i_LWU, base_op, syn_loadstore },
{ "sb", R4300i_SB, base_op, syn_loadstore },
{ "sh", R4300i_SH, base_op, syn_loadstore },
{ "swl", R4300i_SWL, base_op, syn_loadstore },
{ "sw", R4300i_SW, base_op, syn_loadstore },
{ "sdl", R4300i_SDL, base_op, syn_loadstore },
{ "sdr", R4300i_SDR, base_op, syn_loadstore },
{ "swr", R4300i_SWR, base_op, syn_loadstore },
{ "cache", R4300i_CACHE, base_op, syn_cache },
{ "ll", R4300i_LL, base_op, syn_loadstore },
{ "lwc1", R4300i_LWC1, base_op, syn_loadstore },
{ "ldc1", R4300i_LDC1, base_op, syn_loadstore },
{ "ld", R4300i_LD, base_op, syn_loadstore },
{ "sc", R4300i_SC, base_op, syn_loadstore },
{ "swc1", R4300i_SWC1, base_op, syn_loadstore },
{ "sdc1", R4300i_SDC1, base_op, syn_loadstore },
{ "sdc2", R4300i_SDC2, base_op, syn_loadstore },
{ "sd", R4300i_SD, base_op, syn_loadstore },
const ASM_INSTRUCTION CAssembler::m_Instructions[] = {
{"j", R4300i_J, base_op, syn_jump},
{"jal", R4300i_JAL, base_op, syn_jump},
{"beq", R4300i_BEQ, base_op, syn_branch},
{"beqz", R4300i_BEQ, base_op, syn_branch_z},
{"b", R4300i_BEQ, base_op, syn_branch_unc},
{"bne", R4300i_BNE, base_op, syn_branch},
{"bnez", R4300i_BNE, base_op, syn_branch_z},
{"blez", R4300i_BLEZ, base_op, syn_branch_z},
{"bgtz", R4300i_BGTZ, base_op, syn_branch_z},
{"addi", R4300i_ADDI, base_op, syn_arith_i},
{"addiu", R4300i_ADDIU, base_op, syn_arith_i},
{"slti", R4300i_SLTI, base_op, syn_arith_i},
{"sltiu", R4300i_SLTIU, base_op, syn_arith_i},
{"andi", R4300i_ANDI, base_op, syn_arith_i},
{"ori", R4300i_ORI, base_op, syn_arith_i},
{"xori", R4300i_XORI, base_op, syn_arith_i},
{"lui", R4300i_LUI, base_op, syn_load_i},
{"beql", R4300i_BEQL, base_op, syn_branch},
{"beqzl", R4300i_BEQL, base_op, syn_branch_z},
{"bnel", R4300i_BNEL, base_op, syn_branch},
{"bnezl", R4300i_BNEL, base_op, syn_branch_z},
{"blezl", R4300i_BLEZL, base_op, syn_branch_z},
{"bgtzl", R4300i_BGTZL, base_op, syn_branch_z},
{"daddi", R4300i_DADDI, base_op, syn_arith_i},
{"daddiu", R4300i_DADDIU, base_op, syn_arith_i},
{"ldl", R4300i_LDL, base_op, syn_loadstore},
{"ldr", R4300i_LDR, base_op, syn_loadstore},
{"lb", R4300i_LB, base_op, syn_loadstore},
{"lh", R4300i_LH, base_op, syn_loadstore},
{"lwl", R4300i_LWL, base_op, syn_loadstore},
{"lw", R4300i_LW, base_op, syn_loadstore},
{"lbu", R4300i_LBU, base_op, syn_loadstore},
{"lhu", R4300i_LHU, base_op, syn_loadstore},
{"lwr", R4300i_LWR, base_op, syn_loadstore},
{"lwu", R4300i_LWU, base_op, syn_loadstore},
{"sb", R4300i_SB, base_op, syn_loadstore},
{"sh", R4300i_SH, base_op, syn_loadstore},
{"swl", R4300i_SWL, base_op, syn_loadstore},
{"sw", R4300i_SW, base_op, syn_loadstore},
{"sdl", R4300i_SDL, base_op, syn_loadstore},
{"sdr", R4300i_SDR, base_op, syn_loadstore},
{"swr", R4300i_SWR, base_op, syn_loadstore},
{"cache", R4300i_CACHE, base_op, syn_cache},
{"ll", R4300i_LL, base_op, syn_loadstore},
{"lwc1", R4300i_LWC1, base_op, syn_loadstore},
{"ldc1", R4300i_LDC1, base_op, syn_loadstore},
{"ld", R4300i_LD, base_op, syn_loadstore},
{"sc", R4300i_SC, base_op, syn_loadstore},
{"swc1", R4300i_SWC1, base_op, syn_loadstore},
{"sdc1", R4300i_SDC1, base_op, syn_loadstore},
{"sdc2", R4300i_SDC2, base_op, syn_loadstore},
{"sd", R4300i_SD, base_op, syn_loadstore},
{ "sll", R4300i_SPECIAL_SLL, base_spec, syn_shift },
{ "nop", R4300i_SPECIAL_SLL, base_spec, nullptr },
{ "srl", R4300i_SPECIAL_SRL, base_spec, syn_shift },
{ "sra", R4300i_SPECIAL_SRA, base_spec, syn_shift },
{ "sllv", R4300i_SPECIAL_SLLV, base_spec, syn_shiftv },
{ "srlv", R4300i_SPECIAL_SRLV, base_spec, syn_shiftv },
{ "srav", R4300i_SPECIAL_SRAV, base_spec, syn_shiftv },
{ "jr", R4300i_SPECIAL_JR, base_spec, syn_jr },
{ "jalr", R4300i_SPECIAL_JALR, base_spec, syn_jalr },
{ "jalr", R4300i_SPECIAL_JALR, base_spec_jalr_ra, syn_jr },
{ "syscall", R4300i_SPECIAL_SYSCALL, base_spec, syn_syscall },
{ "break", R4300i_SPECIAL_BREAK, base_spec, syn_syscall },
{ "sync", R4300i_SPECIAL_SYNC, base_spec, nullptr },
{ "mfhi", R4300i_SPECIAL_MFHI, base_spec, syn_mf },
{ "mthi", R4300i_SPECIAL_MTHI, base_spec, syn_mf },
{ "mflo", R4300i_SPECIAL_MFLO, base_spec, syn_mf },
{ "mtlo", R4300i_SPECIAL_MTLO, base_spec, syn_mf },
{ "dsllv", R4300i_SPECIAL_DSLLV, base_spec, syn_shiftv },
{ "dsrlv", R4300i_SPECIAL_DSRLV, base_spec, syn_shiftv },
{ "dsrav", R4300i_SPECIAL_DSRAV, base_spec, syn_shiftv },
{ "mult", R4300i_SPECIAL_MULT, base_spec, syn_arith2 },
{ "multu", R4300i_SPECIAL_MULTU, base_spec, syn_arith2 },
{ "div", R4300i_SPECIAL_DIV, base_spec, syn_arith2 },
{ "divu", R4300i_SPECIAL_DIVU, base_spec, syn_arith2 },
{ "dmult", R4300i_SPECIAL_DMULT, base_spec, syn_arith2 },
{ "dmultu", R4300i_SPECIAL_DMULTU, base_spec, syn_arith2 },
{ "ddiv", R4300i_SPECIAL_DDIV, base_spec, syn_arith2 },
{ "ddivu", R4300i_SPECIAL_DDIVU, base_spec, syn_arith2 },
{ "add", R4300i_SPECIAL_ADD, base_spec, syn_arith },
{ "addu", R4300i_SPECIAL_ADDU, base_spec, syn_arith },
{ "sub", R4300i_SPECIAL_SUB, base_spec, syn_arith },
{ "subu", R4300i_SPECIAL_SUBU, base_spec, syn_arith },
{ "and", R4300i_SPECIAL_AND, base_spec, syn_arith },
{ "or", R4300i_SPECIAL_OR, base_spec, syn_arith },
{ "xor", R4300i_SPECIAL_XOR, base_spec, syn_arith },
{ "nor", R4300i_SPECIAL_NOR, base_spec, syn_arith },
{ "slt", R4300i_SPECIAL_SLT, base_spec, syn_arith },
{ "sltu", R4300i_SPECIAL_SLTU, base_spec, syn_arith },
{ "dadd", R4300i_SPECIAL_DADD, base_spec, syn_arith },
{ "daddu", R4300i_SPECIAL_DADDU, base_spec, syn_arith },
{ "dsub", R4300i_SPECIAL_DSUB, base_spec, syn_arith },
{ "dsubu", R4300i_SPECIAL_DSUBU, base_spec, syn_arith },
{ "tge", R4300i_SPECIAL_TGE, base_spec, syn_arith2 }, // Note: no code field
{ "tgeu", R4300i_SPECIAL_TGEU, base_spec, syn_arith2 }, //
{ "tlt", R4300i_SPECIAL_TLT, base_spec, syn_arith2 }, //
{ "tltu", R4300i_SPECIAL_TLTU, base_spec, syn_arith2 }, //
{ "teq", R4300i_SPECIAL_TEQ, base_spec, syn_arith2 }, //
{ "tne", R4300i_SPECIAL_TNE, base_spec, syn_arith2 }, //
{ "dsll", R4300i_SPECIAL_DSLL, base_spec, syn_shift },
{ "dsrl", R4300i_SPECIAL_DSRL, base_spec, syn_shift },
{ "dsra", R4300i_SPECIAL_DSRA, base_spec, syn_shift },
{ "dsll32", R4300i_SPECIAL_DSLL32, base_spec, syn_shift },
{ "dsrl32", R4300i_SPECIAL_DSRL32, base_spec, syn_shift },
{ "dsra32", R4300i_SPECIAL_DSRA32, base_spec, syn_shift },
{"sll", R4300i_SPECIAL_SLL, base_spec, syn_shift},
{"nop", R4300i_SPECIAL_SLL, base_spec, nullptr},
{"srl", R4300i_SPECIAL_SRL, base_spec, syn_shift},
{"sra", R4300i_SPECIAL_SRA, base_spec, syn_shift},
{"sllv", R4300i_SPECIAL_SLLV, base_spec, syn_shiftv},
{"srlv", R4300i_SPECIAL_SRLV, base_spec, syn_shiftv},
{"srav", R4300i_SPECIAL_SRAV, base_spec, syn_shiftv},
{"jr", R4300i_SPECIAL_JR, base_spec, syn_jr},
{"jalr", R4300i_SPECIAL_JALR, base_spec, syn_jalr},
{"jalr", R4300i_SPECIAL_JALR, base_spec_jalr_ra, syn_jr},
{"syscall", R4300i_SPECIAL_SYSCALL, base_spec, syn_syscall},
{"break", R4300i_SPECIAL_BREAK, base_spec, syn_syscall},
{"sync", R4300i_SPECIAL_SYNC, base_spec, nullptr},
{"mfhi", R4300i_SPECIAL_MFHI, base_spec, syn_mf},
{"mthi", R4300i_SPECIAL_MTHI, base_spec, syn_mf},
{"mflo", R4300i_SPECIAL_MFLO, base_spec, syn_mf},
{"mtlo", R4300i_SPECIAL_MTLO, base_spec, syn_mf},
{"dsllv", R4300i_SPECIAL_DSLLV, base_spec, syn_shiftv},
{"dsrlv", R4300i_SPECIAL_DSRLV, base_spec, syn_shiftv},
{"dsrav", R4300i_SPECIAL_DSRAV, base_spec, syn_shiftv},
{"mult", R4300i_SPECIAL_MULT, base_spec, syn_arith2},
{"multu", R4300i_SPECIAL_MULTU, base_spec, syn_arith2},
{"div", R4300i_SPECIAL_DIV, base_spec, syn_arith2},
{"divu", R4300i_SPECIAL_DIVU, base_spec, syn_arith2},
{"dmult", R4300i_SPECIAL_DMULT, base_spec, syn_arith2},
{"dmultu", R4300i_SPECIAL_DMULTU, base_spec, syn_arith2},
{"ddiv", R4300i_SPECIAL_DDIV, base_spec, syn_arith2},
{"ddivu", R4300i_SPECIAL_DDIVU, base_spec, syn_arith2},
{"add", R4300i_SPECIAL_ADD, base_spec, syn_arith},
{"addu", R4300i_SPECIAL_ADDU, base_spec, syn_arith},
{"sub", R4300i_SPECIAL_SUB, base_spec, syn_arith},
{"subu", R4300i_SPECIAL_SUBU, base_spec, syn_arith},
{"and", R4300i_SPECIAL_AND, base_spec, syn_arith},
{"or", R4300i_SPECIAL_OR, base_spec, syn_arith},
{"xor", R4300i_SPECIAL_XOR, base_spec, syn_arith},
{"nor", R4300i_SPECIAL_NOR, base_spec, syn_arith},
{"slt", R4300i_SPECIAL_SLT, base_spec, syn_arith},
{"sltu", R4300i_SPECIAL_SLTU, base_spec, syn_arith},
{"dadd", R4300i_SPECIAL_DADD, base_spec, syn_arith},
{"daddu", R4300i_SPECIAL_DADDU, base_spec, syn_arith},
{"dsub", R4300i_SPECIAL_DSUB, base_spec, syn_arith},
{"dsubu", R4300i_SPECIAL_DSUBU, base_spec, syn_arith},
{"tge", R4300i_SPECIAL_TGE, base_spec, syn_arith2}, // Note: no code field
{"tgeu", R4300i_SPECIAL_TGEU, base_spec, syn_arith2}, //
{"tlt", R4300i_SPECIAL_TLT, base_spec, syn_arith2}, //
{"tltu", R4300i_SPECIAL_TLTU, base_spec, syn_arith2}, //
{"teq", R4300i_SPECIAL_TEQ, base_spec, syn_arith2}, //
{"tne", R4300i_SPECIAL_TNE, base_spec, syn_arith2}, //
{"dsll", R4300i_SPECIAL_DSLL, base_spec, syn_shift},
{"dsrl", R4300i_SPECIAL_DSRL, base_spec, syn_shift},
{"dsra", R4300i_SPECIAL_DSRA, base_spec, syn_shift},
{"dsll32", R4300i_SPECIAL_DSLL32, base_spec, syn_shift},
{"dsrl32", R4300i_SPECIAL_DSRL32, base_spec, syn_shift},
{"dsra32", R4300i_SPECIAL_DSRA32, base_spec, syn_shift},
{ "bltz", R4300i_REGIMM_BLTZ, base_regimm, syn_branch_z },
{ "bgez", R4300i_REGIMM_BGEZ, base_regimm, syn_branch_z },
{ "bltzl", R4300i_REGIMM_BLTZL, base_regimm, syn_branch_z },
{ "bgezl", R4300i_REGIMM_BGEZL, base_regimm, syn_branch_z },
{ "tgei", R4300i_REGIMM_TGEI, base_regimm, syn_trap_i },
{ "tgeiu", R4300i_REGIMM_TGEIU, base_regimm, syn_trap_i },
{ "tlti", R4300i_REGIMM_TLTI, base_regimm, syn_trap_i },
{ "tltiu", R4300i_REGIMM_TLTIU, base_regimm, syn_trap_i },
{ "teqi", R4300i_REGIMM_TEQI, base_regimm, syn_trap_i },
{ "tnei", R4300i_REGIMM_TNEI, base_regimm, syn_trap_i },
{ "bltzal", R4300i_REGIMM_BLTZAL, base_regimm, syn_branch_z },
{ "bgezal", R4300i_REGIMM_BGEZAL, base_regimm, syn_branch_z },
{ "bal", R4300i_REGIMM_BGEZAL, base_regimm, syn_branch_unc },
{ "bltzall", R4300i_REGIMM_BLTZALL, base_regimm, syn_branch_z },
{ "bgezall", R4300i_REGIMM_BGEZALL, base_regimm, syn_branch_z },
{"bltz", R4300i_REGIMM_BLTZ, base_regimm, syn_branch_z},
{"bgez", R4300i_REGIMM_BGEZ, base_regimm, syn_branch_z},
{"bltzl", R4300i_REGIMM_BLTZL, base_regimm, syn_branch_z},
{"bgezl", R4300i_REGIMM_BGEZL, base_regimm, syn_branch_z},
{"tgei", R4300i_REGIMM_TGEI, base_regimm, syn_trap_i},
{"tgeiu", R4300i_REGIMM_TGEIU, base_regimm, syn_trap_i},
{"tlti", R4300i_REGIMM_TLTI, base_regimm, syn_trap_i},
{"tltiu", R4300i_REGIMM_TLTIU, base_regimm, syn_trap_i},
{"teqi", R4300i_REGIMM_TEQI, base_regimm, syn_trap_i},
{"tnei", R4300i_REGIMM_TNEI, base_regimm, syn_trap_i},
{"bltzal", R4300i_REGIMM_BLTZAL, base_regimm, syn_branch_z},
{"bgezal", R4300i_REGIMM_BGEZAL, base_regimm, syn_branch_z},
{"bal", R4300i_REGIMM_BGEZAL, base_regimm, syn_branch_unc},
{"bltzall", R4300i_REGIMM_BLTZALL, base_regimm, syn_branch_z},
{"bgezall", R4300i_REGIMM_BGEZALL, base_regimm, syn_branch_z},
{ "mfc0", R4300i_COP0_MF , base_cop0_mv, syn_cop_mv },
{ "mtc0", R4300i_COP0_MT , base_cop0_mv, syn_cop_mv },
{"mfc0", R4300i_COP0_MF, base_cop0_mv, syn_cop_mv},
{"mtc0", R4300i_COP0_MT, base_cop0_mv, syn_cop_mv},
{ "tlbr", R4300i_COP0_CO_TLBR, base_cop0_co, nullptr },
{ "tlbwi", R4300i_COP0_CO_TLBWI, base_cop0_co, nullptr },
{ "tlbwr", R4300i_COP0_CO_TLBWR, base_cop0_co, nullptr },
{ "tlbp", R4300i_COP0_CO_TLBP, base_cop0_co, nullptr },
{ "eret", R4300i_COP0_CO_ERET, base_cop0_co, nullptr },
{"tlbr", R4300i_COP0_CO_TLBR, base_cop0_co, nullptr},
{"tlbwi", R4300i_COP0_CO_TLBWI, base_cop0_co, nullptr},
{"tlbwr", R4300i_COP0_CO_TLBWR, base_cop0_co, nullptr},
{"tlbp", R4300i_COP0_CO_TLBP, base_cop0_co, nullptr},
{"eret", R4300i_COP0_CO_ERET, base_cop0_co, nullptr},
{ "mfc1", R4300i_COP1_MF, base_cop1_mv, syn_cop_mv },
{ "dmfc1", R4300i_COP1_DMF, base_cop1_mv, syn_cop_mv },
{ "cfc1", R4300i_COP1_CF, base_cop1_mv, syn_cop_mv },
{ "mtc1", R4300i_COP1_MT, base_cop1_mv, syn_cop_mv },
{ "dmtc1", R4300i_COP1_DMT, base_cop1_mv, syn_cop_mv },
{ "ctc1", R4300i_COP1_CT, base_cop1_mv, syn_cop_mv },
{"mfc1", R4300i_COP1_MF, base_cop1_mv, syn_cop_mv},
{"dmfc1", R4300i_COP1_DMF, base_cop1_mv, syn_cop_mv},
{"cfc1", R4300i_COP1_CF, base_cop1_mv, syn_cop_mv},
{"mtc1", R4300i_COP1_MT, base_cop1_mv, syn_cop_mv},
{"dmtc1", R4300i_COP1_DMT, base_cop1_mv, syn_cop_mv},
{"ctc1", R4300i_COP1_CT, base_cop1_mv, syn_cop_mv},
{ "bc1f", R4300i_COP1_BC_BCF, base_cop1_bc, syn_branch_unc },
{ "bc1t", R4300i_COP1_BC_BCT, base_cop1_bc, syn_branch_unc },
{ "bc1fl", R4300i_COP1_BC_BCFL, base_cop1_bc, syn_branch_unc },
{ "bc1tl", R4300i_COP1_BC_BCTL, base_cop1_bc, syn_branch_unc },
{"bc1f", R4300i_COP1_BC_BCF, base_cop1_bc, syn_branch_unc},
{"bc1t", R4300i_COP1_BC_BCT, base_cop1_bc, syn_branch_unc},
{"bc1fl", R4300i_COP1_BC_BCFL, base_cop1_bc, syn_branch_unc},
{"bc1tl", R4300i_COP1_BC_BCTL, base_cop1_bc, syn_branch_unc},
{ "add.s", R4300i_COP1_FUNCT_ADD, base_cop1_s, syn_cop1_arith },
{ "sub.s", R4300i_COP1_FUNCT_SUB, base_cop1_s, syn_cop1_arith },
{ "mul.s", R4300i_COP1_FUNCT_MUL, base_cop1_s, syn_cop1_arith },
{ "div.s", R4300i_COP1_FUNCT_DIV, base_cop1_s, syn_cop1_arith },
{ "sqrt.s", R4300i_COP1_FUNCT_SQRT, base_cop1_s, syn_cop1 },
{ "abs.s", R4300i_COP1_FUNCT_ABS, base_cop1_s, syn_cop1 },
{ "mov.s", R4300i_COP1_FUNCT_MOV, base_cop1_s, syn_cop1 },
{ "neg.s", R4300i_COP1_FUNCT_NEG, base_cop1_s, syn_cop1 },
{ "round.l.s", R4300i_COP1_FUNCT_ROUND_L, base_cop1_s, syn_cop1 },
{ "trunc.l.s", R4300i_COP1_FUNCT_TRUNC_L, base_cop1_s, syn_cop1 },
{ "ceil.l.s", R4300i_COP1_FUNCT_CEIL_L, base_cop1_s, syn_cop1 },
{ "floor.l.s", R4300i_COP1_FUNCT_FLOOR_L, base_cop1_s, syn_cop1 },
{ "round.w.s", R4300i_COP1_FUNCT_ROUND_W, base_cop1_s, syn_cop1 },
{ "trunc.w.s", R4300i_COP1_FUNCT_TRUNC_W, base_cop1_s, syn_cop1 },
{ "ceil.w.s", R4300i_COP1_FUNCT_CEIL_W, base_cop1_s, syn_cop1 },
{ "floor.w.s", R4300i_COP1_FUNCT_FLOOR_W, base_cop1_s, syn_cop1 },
{ "cvt.s.s", R4300i_COP1_FUNCT_CVT_S, base_cop1_s, syn_cop1 },
{ "cvt.d.s", R4300i_COP1_FUNCT_CVT_D, base_cop1_s, syn_cop1 },
{ "cvt.w.s", R4300i_COP1_FUNCT_CVT_W, base_cop1_s, syn_cop1 },
{ "cvt.l.s", R4300i_COP1_FUNCT_CVT_L, base_cop1_s, syn_cop1 },
{ "c.f.s", R4300i_COP1_FUNCT_C_F, base_cop1_s, syn_cop1_cmp },
{ "c.un.s", R4300i_COP1_FUNCT_C_UN, base_cop1_s, syn_cop1_cmp },
{ "c.eq.s", R4300i_COP1_FUNCT_C_EQ, base_cop1_s, syn_cop1_cmp },
{ "c.ueq.s", R4300i_COP1_FUNCT_C_UEQ, base_cop1_s, syn_cop1_cmp },
{ "c.olt.s", R4300i_COP1_FUNCT_C_OLT, base_cop1_s, syn_cop1_cmp },
{ "c.ult.s", R4300i_COP1_FUNCT_C_ULT, base_cop1_s, syn_cop1_cmp },
{ "c.ole.s", R4300i_COP1_FUNCT_C_OLE, base_cop1_s, syn_cop1_cmp },
{ "c.ule.s", R4300i_COP1_FUNCT_C_ULE, base_cop1_s, syn_cop1_cmp },
{ "c.sf.s", R4300i_COP1_FUNCT_C_SF, base_cop1_s, syn_cop1_cmp },
{ "c.ngle.s", R4300i_COP1_FUNCT_C_NGLE, base_cop1_s, syn_cop1_cmp },
{ "c.seq.s", R4300i_COP1_FUNCT_C_SEQ, base_cop1_s, syn_cop1_cmp },
{ "c.ngl.s", R4300i_COP1_FUNCT_C_NGL, base_cop1_s, syn_cop1_cmp },
{ "c.lt.s", R4300i_COP1_FUNCT_C_LT, base_cop1_s, syn_cop1_cmp },
{ "c.nge.s", R4300i_COP1_FUNCT_C_NGE, base_cop1_s, syn_cop1_cmp },
{ "c.le.s", R4300i_COP1_FUNCT_C_LE, base_cop1_s, syn_cop1_cmp },
{ "c.ngt.s", R4300i_COP1_FUNCT_C_NGT, base_cop1_s, syn_cop1_cmp },
{"add.s", R4300i_COP1_FUNCT_ADD, base_cop1_s, syn_cop1_arith},
{"sub.s", R4300i_COP1_FUNCT_SUB, base_cop1_s, syn_cop1_arith},
{"mul.s", R4300i_COP1_FUNCT_MUL, base_cop1_s, syn_cop1_arith},
{"div.s", R4300i_COP1_FUNCT_DIV, base_cop1_s, syn_cop1_arith},
{"sqrt.s", R4300i_COP1_FUNCT_SQRT, base_cop1_s, syn_cop1},
{"abs.s", R4300i_COP1_FUNCT_ABS, base_cop1_s, syn_cop1},
{"mov.s", R4300i_COP1_FUNCT_MOV, base_cop1_s, syn_cop1},
{"neg.s", R4300i_COP1_FUNCT_NEG, base_cop1_s, syn_cop1},
{"round.l.s", R4300i_COP1_FUNCT_ROUND_L, base_cop1_s, syn_cop1},
{"trunc.l.s", R4300i_COP1_FUNCT_TRUNC_L, base_cop1_s, syn_cop1},
{"ceil.l.s", R4300i_COP1_FUNCT_CEIL_L, base_cop1_s, syn_cop1},
{"floor.l.s", R4300i_COP1_FUNCT_FLOOR_L, base_cop1_s, syn_cop1},
{"round.w.s", R4300i_COP1_FUNCT_ROUND_W, base_cop1_s, syn_cop1},
{"trunc.w.s", R4300i_COP1_FUNCT_TRUNC_W, base_cop1_s, syn_cop1},
{"ceil.w.s", R4300i_COP1_FUNCT_CEIL_W, base_cop1_s, syn_cop1},
{"floor.w.s", R4300i_COP1_FUNCT_FLOOR_W, base_cop1_s, syn_cop1},
{"cvt.s.s", R4300i_COP1_FUNCT_CVT_S, base_cop1_s, syn_cop1},
{"cvt.d.s", R4300i_COP1_FUNCT_CVT_D, base_cop1_s, syn_cop1},
{"cvt.w.s", R4300i_COP1_FUNCT_CVT_W, base_cop1_s, syn_cop1},
{"cvt.l.s", R4300i_COP1_FUNCT_CVT_L, base_cop1_s, syn_cop1},
{"c.f.s", R4300i_COP1_FUNCT_C_F, base_cop1_s, syn_cop1_cmp},
{"c.un.s", R4300i_COP1_FUNCT_C_UN, base_cop1_s, syn_cop1_cmp},
{"c.eq.s", R4300i_COP1_FUNCT_C_EQ, base_cop1_s, syn_cop1_cmp},
{"c.ueq.s", R4300i_COP1_FUNCT_C_UEQ, base_cop1_s, syn_cop1_cmp},
{"c.olt.s", R4300i_COP1_FUNCT_C_OLT, base_cop1_s, syn_cop1_cmp},
{"c.ult.s", R4300i_COP1_FUNCT_C_ULT, base_cop1_s, syn_cop1_cmp},
{"c.ole.s", R4300i_COP1_FUNCT_C_OLE, base_cop1_s, syn_cop1_cmp},
{"c.ule.s", R4300i_COP1_FUNCT_C_ULE, base_cop1_s, syn_cop1_cmp},
{"c.sf.s", R4300i_COP1_FUNCT_C_SF, base_cop1_s, syn_cop1_cmp},
{"c.ngle.s", R4300i_COP1_FUNCT_C_NGLE, base_cop1_s, syn_cop1_cmp},
{"c.seq.s", R4300i_COP1_FUNCT_C_SEQ, base_cop1_s, syn_cop1_cmp},
{"c.ngl.s", R4300i_COP1_FUNCT_C_NGL, base_cop1_s, syn_cop1_cmp},
{"c.lt.s", R4300i_COP1_FUNCT_C_LT, base_cop1_s, syn_cop1_cmp},
{"c.nge.s", R4300i_COP1_FUNCT_C_NGE, base_cop1_s, syn_cop1_cmp},
{"c.le.s", R4300i_COP1_FUNCT_C_LE, base_cop1_s, syn_cop1_cmp},
{"c.ngt.s", R4300i_COP1_FUNCT_C_NGT, base_cop1_s, syn_cop1_cmp},
{ "add.d", R4300i_COP1_FUNCT_ADD, base_cop1_d, syn_cop1_arith },
{ "sub.d", R4300i_COP1_FUNCT_SUB, base_cop1_d, syn_cop1_arith },
{ "mul.d", R4300i_COP1_FUNCT_MUL, base_cop1_d, syn_cop1_arith },
{ "div.d", R4300i_COP1_FUNCT_DIV, base_cop1_d, syn_cop1_arith },
{ "sqrt.d", R4300i_COP1_FUNCT_SQRT, base_cop1_d, syn_cop1 },
{ "abs.d", R4300i_COP1_FUNCT_ABS, base_cop1_d, syn_cop1 },
{ "mov.d", R4300i_COP1_FUNCT_MOV, base_cop1_d, syn_cop1 },
{ "neg.d", R4300i_COP1_FUNCT_NEG, base_cop1_d, syn_cop1 },
{ "round.l.d", R4300i_COP1_FUNCT_ROUND_L, base_cop1_d, syn_cop1 },
{ "trunc.l.d", R4300i_COP1_FUNCT_TRUNC_L, base_cop1_d, syn_cop1 },
{ "ceil.l.d", R4300i_COP1_FUNCT_CEIL_L, base_cop1_d, syn_cop1 },
{ "floor.l.d", R4300i_COP1_FUNCT_FLOOR_L, base_cop1_d, syn_cop1 },
{ "round.w.d", R4300i_COP1_FUNCT_ROUND_W, base_cop1_d, syn_cop1 },
{ "trunc.w.d", R4300i_COP1_FUNCT_TRUNC_W, base_cop1_d, syn_cop1 },
{ "ceil.w.d", R4300i_COP1_FUNCT_CEIL_W, base_cop1_d, syn_cop1 },
{ "floor.w.d", R4300i_COP1_FUNCT_FLOOR_W, base_cop1_d, syn_cop1 },
{ "cvt.s.d", R4300i_COP1_FUNCT_CVT_S, base_cop1_d, syn_cop1 },
{ "cvt.d.d", R4300i_COP1_FUNCT_CVT_D, base_cop1_d, syn_cop1 },
{ "cvt.w.d", R4300i_COP1_FUNCT_CVT_W, base_cop1_d, syn_cop1 },
{ "cvt.l.d", R4300i_COP1_FUNCT_CVT_L, base_cop1_d, syn_cop1 },
{ "c.f.d", R4300i_COP1_FUNCT_C_F, base_cop1_d, syn_cop1_cmp },
{ "c.un.d", R4300i_COP1_FUNCT_C_UN, base_cop1_d, syn_cop1_cmp },
{ "c.eq.d", R4300i_COP1_FUNCT_C_EQ, base_cop1_d, syn_cop1_cmp },
{ "c.ueq.d", R4300i_COP1_FUNCT_C_UEQ, base_cop1_d, syn_cop1_cmp },
{ "c.olt.d", R4300i_COP1_FUNCT_C_OLT, base_cop1_d, syn_cop1_cmp },
{ "c.ult.d", R4300i_COP1_FUNCT_C_ULT, base_cop1_d, syn_cop1_cmp },
{ "c.ole.d", R4300i_COP1_FUNCT_C_OLE, base_cop1_d, syn_cop1_cmp },
{ "c.ule.d", R4300i_COP1_FUNCT_C_ULE, base_cop1_d, syn_cop1_cmp },
{ "c.sf.d", R4300i_COP1_FUNCT_C_SF, base_cop1_d, syn_cop1_cmp },
{ "c.ngle.d", R4300i_COP1_FUNCT_C_NGLE, base_cop1_d, syn_cop1_cmp },
{ "c.seq.d", R4300i_COP1_FUNCT_C_SEQ, base_cop1_d, syn_cop1_cmp },
{ "c.ngl.d", R4300i_COP1_FUNCT_C_NGL, base_cop1_d, syn_cop1_cmp },
{ "c.lt.d", R4300i_COP1_FUNCT_C_LT, base_cop1_d, syn_cop1_cmp },
{ "c.nge.d", R4300i_COP1_FUNCT_C_NGE, base_cop1_d, syn_cop1_cmp },
{ "c.le.d", R4300i_COP1_FUNCT_C_LE, base_cop1_d, syn_cop1_cmp },
{ "c.ngt.d", R4300i_COP1_FUNCT_C_NGT, base_cop1_d, syn_cop1_cmp },
{"add.d", R4300i_COP1_FUNCT_ADD, base_cop1_d, syn_cop1_arith},
{"sub.d", R4300i_COP1_FUNCT_SUB, base_cop1_d, syn_cop1_arith},
{"mul.d", R4300i_COP1_FUNCT_MUL, base_cop1_d, syn_cop1_arith},
{"div.d", R4300i_COP1_FUNCT_DIV, base_cop1_d, syn_cop1_arith},
{"sqrt.d", R4300i_COP1_FUNCT_SQRT, base_cop1_d, syn_cop1},
{"abs.d", R4300i_COP1_FUNCT_ABS, base_cop1_d, syn_cop1},
{"mov.d", R4300i_COP1_FUNCT_MOV, base_cop1_d, syn_cop1},
{"neg.d", R4300i_COP1_FUNCT_NEG, base_cop1_d, syn_cop1},
{"round.l.d", R4300i_COP1_FUNCT_ROUND_L, base_cop1_d, syn_cop1},
{"trunc.l.d", R4300i_COP1_FUNCT_TRUNC_L, base_cop1_d, syn_cop1},
{"ceil.l.d", R4300i_COP1_FUNCT_CEIL_L, base_cop1_d, syn_cop1},
{"floor.l.d", R4300i_COP1_FUNCT_FLOOR_L, base_cop1_d, syn_cop1},
{"round.w.d", R4300i_COP1_FUNCT_ROUND_W, base_cop1_d, syn_cop1},
{"trunc.w.d", R4300i_COP1_FUNCT_TRUNC_W, base_cop1_d, syn_cop1},
{"ceil.w.d", R4300i_COP1_FUNCT_CEIL_W, base_cop1_d, syn_cop1},
{"floor.w.d", R4300i_COP1_FUNCT_FLOOR_W, base_cop1_d, syn_cop1},
{"cvt.s.d", R4300i_COP1_FUNCT_CVT_S, base_cop1_d, syn_cop1},
{"cvt.d.d", R4300i_COP1_FUNCT_CVT_D, base_cop1_d, syn_cop1},
{"cvt.w.d", R4300i_COP1_FUNCT_CVT_W, base_cop1_d, syn_cop1},
{"cvt.l.d", R4300i_COP1_FUNCT_CVT_L, base_cop1_d, syn_cop1},
{"c.f.d", R4300i_COP1_FUNCT_C_F, base_cop1_d, syn_cop1_cmp},
{"c.un.d", R4300i_COP1_FUNCT_C_UN, base_cop1_d, syn_cop1_cmp},
{"c.eq.d", R4300i_COP1_FUNCT_C_EQ, base_cop1_d, syn_cop1_cmp},
{"c.ueq.d", R4300i_COP1_FUNCT_C_UEQ, base_cop1_d, syn_cop1_cmp},
{"c.olt.d", R4300i_COP1_FUNCT_C_OLT, base_cop1_d, syn_cop1_cmp},
{"c.ult.d", R4300i_COP1_FUNCT_C_ULT, base_cop1_d, syn_cop1_cmp},
{"c.ole.d", R4300i_COP1_FUNCT_C_OLE, base_cop1_d, syn_cop1_cmp},
{"c.ule.d", R4300i_COP1_FUNCT_C_ULE, base_cop1_d, syn_cop1_cmp},
{"c.sf.d", R4300i_COP1_FUNCT_C_SF, base_cop1_d, syn_cop1_cmp},
{"c.ngle.d", R4300i_COP1_FUNCT_C_NGLE, base_cop1_d, syn_cop1_cmp},
{"c.seq.d", R4300i_COP1_FUNCT_C_SEQ, base_cop1_d, syn_cop1_cmp},
{"c.ngl.d", R4300i_COP1_FUNCT_C_NGL, base_cop1_d, syn_cop1_cmp},
{"c.lt.d", R4300i_COP1_FUNCT_C_LT, base_cop1_d, syn_cop1_cmp},
{"c.nge.d", R4300i_COP1_FUNCT_C_NGE, base_cop1_d, syn_cop1_cmp},
{"c.le.d", R4300i_COP1_FUNCT_C_LE, base_cop1_d, syn_cop1_cmp},
{"c.ngt.d", R4300i_COP1_FUNCT_C_NGT, base_cop1_d, syn_cop1_cmp},
{ "cvt.s.w", R4300i_COP1_FUNCT_CVT_S, base_cop1_w, syn_cop1 },
{ "cvt.d.w", R4300i_COP1_FUNCT_CVT_D, base_cop1_w, syn_cop1 },
{ "cvt.s.l", R4300i_COP1_FUNCT_CVT_S, base_cop1_l, syn_cop1 },
{ "cvt.d.l", R4300i_COP1_FUNCT_CVT_D, base_cop1_l, syn_cop1 },
{ nullptr }
{"cvt.s.w", R4300i_COP1_FUNCT_CVT_S, base_cop1_w, syn_cop1},
{"cvt.d.w", R4300i_COP1_FUNCT_CVT_D, base_cop1_w, syn_cop1},
{"cvt.s.l", R4300i_COP1_FUNCT_CVT_S, base_cop1_l, syn_cop1},
{"cvt.d.l", R4300i_COP1_FUNCT_CVT_D, base_cop1_l, syn_cop1},
{nullptr},
};
const ASM_REGISTER CAssembler::m_Registers[] =
{
{ "r0", 0 },{ "at", 1 },{ "v0", 2 },{ "v1", 3 },{ "a0", 4 },{ "a1", 5 },{ "a2", 6 },{ "a3", 7 },
{ "t0", 8 },{ "t1", 9 },{ "t2", 10 },{ "t3", 11 },{ "t4", 12 },{ "t5", 13 },{ "t6", 14 },{ "t7", 15 },
{ "s0", 16 },{ "s1", 17 },{ "s2", 18 },{ "s3", 19 },{ "s4", 20 },{ "s5", 21 },{ "s6", 22 },{ "s7", 23 },
{ "t8", 24 },{ "t9", 25 },{ "k0", 26 },{ "k1", 27 },{ "gp", 28 },{ "sp", 29 },{ "s8", 30 },{ "ra", 31 },
const ASM_REGISTER CAssembler::m_Registers[] = {
{"r0", 0},
{"at", 1},
{"v0", 2},
{"v1", 3},
{"a0", 4},
{"a1", 5},
{"a2", 6},
{"a3", 7},
{"t0", 8},
{"t1", 9},
{"t2", 10},
{"t3", 11},
{"t4", 12},
{"t5", 13},
{"t6", 14},
{"t7", 15},
{"s0", 16},
{"s1", 17},
{"s2", 18},
{"s3", 19},
{"s4", 20},
{"s5", 21},
{"s6", 22},
{"s7", 23},
{"t8", 24},
{"t9", 25},
{"k0", 26},
{"k1", 27},
{"gp", 28},
{"sp", 29},
{"s8", 30},
{"ra", 31},
{ "fp", 30 },
{"fp", 30},
{ "r0", 0 },{ "r1", 1 },{ "r2", 2 },{ "r3", 3 },{ "r4", 4 },{ "r5", 5 },{ "r6", 6 },{ "r7", 7 },
{ "r8", 8 },{ "r9", 9 },{ "r10", 10 },{ "r11", 11 },{ "r12", 12 },{ "r13", 13 },{ "r14", 14 },{ "r15", 15 },
{ "r16", 16 },{ "r17", 17 },{ "r18", 18 },{ "r19", 19 },{ "r20", 20 },{ "r21", 21 },{ "r22", 22 },{ "r23", 23 },
{ "r24", 24 },{ "r25", 25 },{ "r26", 26 },{ "r27", 27 },{ "r28", 28 },{ "r29", 29 },{ "r30", 30 },{ "r31", 31 },
{"r0", 0},
{"r1", 1},
{"r2", 2},
{"r3", 3},
{"r4", 4},
{"r5", 5},
{"r6", 6},
{"r7", 7},
{"r8", 8},
{"r9", 9},
{"r10", 10},
{"r11", 11},
{"r12", 12},
{"r13", 13},
{"r14", 14},
{"r15", 15},
{"r16", 16},
{"r17", 17},
{"r18", 18},
{"r19", 19},
{"r20", 20},
{"r21", 21},
{"r22", 22},
{"r23", 23},
{"r24", 24},
{"r25", 25},
{"r26", 26},
{"r27", 27},
{"r28", 28},
{"r29", 29},
{"r30", 30},
{"r31", 31},
{ "f0", 0 },{ "f1", 1 },{ "f2", 2 },{ "f3", 3 },{ "f4", 4 },{ "f5", 5 },{ "f6", 6 },{ "f7", 7 },
{ "f8", 8 },{ "f9", 9 },{ "f10", 10 },{ "f11", 11 },{ "f12", 12 },{ "f13", 13 },{ "f14", 14 },{ "f15", 15 },
{ "f16", 16 },{ "f17", 17 },{ "f18", 18 },{ "f19", 19 },{ "f20", 20 },{ "f21", 21 },{ "f22", 22 },{ "f23", 23 },
{ "f24", 24 },{ "f25", 25 },{ "f26", 26 },{ "f27", 27 },{ "f28", 28 },{ "f29", 29 },{ "f30", 30 },{ "f31", 31 },
{"f0", 0},
{"f1", 1},
{"f2", 2},
{"f3", 3},
{"f4", 4},
{"f5", 5},
{"f6", 6},
{"f7", 7},
{"f8", 8},
{"f9", 9},
{"f10", 10},
{"f11", 11},
{"f12", 12},
{"f13", 13},
{"f14", 14},
{"f15", 15},
{"f16", 16},
{"f17", 17},
{"f18", 18},
{"f19", 19},
{"f20", 20},
{"f21", 21},
{"f22", 22},
{"f23", 23},
{"f24", 24},
{"f25", 25},
{"f26", 26},
{"f27", 27},
{"f28", 28},
{"f29", 29},
{"f30", 30},
{"f31", 31},
{ "revision", 0 },{ "fcsr", 31 },{ "fcs", 31 },
{"revision", 0},
{"fcsr", 31},
{"fcs", 31},
{ "index", 0 },{ "random", 1 },{ "entrylo0", 2 },{ "entrylo1", 3 },{ "context", 4 },{ "pagemask", 5 },
{ "wired", 6 },{ "badvaddr", 8 },{ "count", 9 },{ "entryhi", 10 },{ "compare", 11 },{ "status", 12 },
{ "cause", 13 },{ "epc", 14 },{ "prid", 15 },{ "config", 16 },{ "lladdr", 17 },{ "watchlo", 18 },
{ "watchhi", 19 },{ "xcontext", 20 },{ "ecc", 26 },{ "cacheerr", 27 },{ "taglo", 28 },{ "taghi", 29 },
{ "errepc", 30 },
{"index", 0},
{"random", 1},
{"entrylo0", 2},
{"entrylo1", 3},
{"context", 4},
{"pagemask", 5},
{"wired", 6},
{"badvaddr", 8},
{"count", 9},
{"entryhi", 10},
{"compare", 11},
{"status", 12},
{"cause", 13},
{"epc", 14},
{"prid", 15},
{"config", 16},
{"lladdr", 17},
{"watchlo", 18},
{"watchhi", 19},
{"xcontext", 20},
{"ecc", 26},
{"cacheerr", 27},
{"taglo", 28},
{"taghi", 29},
{"errepc", 30},
{ nullptr }
{nullptr},
};
bool CAssembler::AssembleLine(const char * line, uint32_t * opcode, uint32_t address)

View File

@ -2,17 +2,19 @@
#include <stdint.h>
typedef void(*ASM_SYNTAX_FN)(uint32_t* opcode);
typedef void (*ASM_SYNTAX_FN)(uint32_t * opcode);
typedef struct {
const char* name;
typedef struct
{
const char * name;
uint32_t val;
uint32_t(*base)(uint32_t val); // Value shift
const ASM_SYNTAX_FN* syntax; // Arguments
uint32_t (*base)(uint32_t val); // Value shift
const ASM_SYNTAX_FN * syntax; // Arguments
} ASM_INSTRUCTION;
typedef struct {
const char* name;
typedef struct
{
const char * name;
uint32_t val;
} ASM_REGISTER;
@ -32,7 +34,7 @@ private:
static ASM_PARSE_ERROR m_ParseError;
public:
static bool AssembleLine(const char* line, uint32_t* opcode, uint32_t address = 0x00000000);
static bool AssembleLine(const char * line, uint32_t * opcode, uint32_t address = 0x00000000);
private:
static const ASM_SYNTAX_FN syn_jump[];
@ -60,16 +62,16 @@ private:
static const ASM_INSTRUCTION m_Instructions[];
static const ASM_REGISTER m_Registers[];
static char* m_TokContext;
static char * m_TokContext;
static const ASM_REGISTER* LookupRegister(char* name);
static const ASM_INSTRUCTION* LookupInstruction(char* name, int nFallback);
static void StrToLower(char* str);
static const ASM_REGISTER * LookupRegister(char * name);
static const ASM_INSTRUCTION * LookupInstruction(char * name, int nFallback);
static void StrToLower(char * str);
static uint32_t pop_reg();
static uint32_t pop_val();
static uint32_t base_op(uint32_t val);
static uint32_t base_spec(uint32_t val);
static uint32_t base_spec_jalr_ra(uint32_t val);
@ -83,16 +85,16 @@ private:
static uint32_t base_cop0_mv(uint32_t val);
static uint32_t base_cop1_mv(uint32_t val);
static void arg_reg_t(uint32_t* opcode);
static void arg_reg_s(uint32_t* opcode);
static void arg_reg_d(uint32_t* opcode);
static void arg_reg_ft(uint32_t* opcode);
static void arg_reg_fs(uint32_t* opcode);
static void arg_reg_fd(uint32_t* opcode);
static void arg_jump(uint32_t* opcode);
static void arg_imm16(uint32_t* opcode);
static void arg_bra_target(uint32_t* opcode);
static void arg_shamt(uint32_t* opcode);
static void arg_cache_op(uint32_t* opcode);
static void arg_syscall_code(uint32_t* opcode);
static void arg_reg_t(uint32_t * opcode);
static void arg_reg_s(uint32_t * opcode);
static void arg_reg_d(uint32_t * opcode);
static void arg_reg_ft(uint32_t * opcode);
static void arg_reg_fs(uint32_t * opcode);
static void arg_reg_fd(uint32_t * opcode);
static void arg_jump(uint32_t * opcode);
static void arg_imm16(uint32_t * opcode);
static void arg_bra_target(uint32_t * opcode);
static void arg_shamt(uint32_t * opcode);
static void arg_cache_op(uint32_t * opcode);
static void arg_syscall_code(uint32_t * opcode);
};

View File

@ -354,12 +354,41 @@ void CBreakpoints::UpdateHaveRegBP(void)
m_bHaveRegBP = HaveAnyGPRWriteBP() || HaveAnyGPRReadBP() || HaveHIWriteBP() || HaveHIReadBP() || HaveLOWriteBP() || HaveLOReadBP();
}
void CBreakpoints::ToggleGPRWriteBP(int nReg) { m_GPRWriteBP ^= (1 << nReg); UpdateHaveRegBP(); }
void CBreakpoints::ToggleGPRReadBP(int nReg) { m_GPRReadBP ^= (1 << nReg); UpdateHaveRegBP(); }
void CBreakpoints::ToggleHIWriteBP(void) { m_HIWriteBP = !m_HIWriteBP; UpdateHaveRegBP(); }
void CBreakpoints::ToggleHIReadBP(void) { m_HIReadBP = !m_HIReadBP; UpdateHaveRegBP(); }
void CBreakpoints::ToggleLOWriteBP(void) { m_LOWriteBP = !m_LOWriteBP; UpdateHaveRegBP(); }
void CBreakpoints::ToggleLOReadBP(void) { m_LOReadBP = !m_LOReadBP; UpdateHaveRegBP(); }
void CBreakpoints::ToggleGPRWriteBP(int nReg)
{
m_GPRWriteBP ^= (1 << nReg);
UpdateHaveRegBP();
}
void CBreakpoints::ToggleGPRReadBP(int nReg)
{
m_GPRReadBP ^= (1 << nReg);
UpdateHaveRegBP();
}
void CBreakpoints::ToggleHIWriteBP(void)
{
m_HIWriteBP = !m_HIWriteBP;
UpdateHaveRegBP();
}
void CBreakpoints::ToggleHIReadBP(void)
{
m_HIReadBP = !m_HIReadBP;
UpdateHaveRegBP();
}
void CBreakpoints::ToggleLOWriteBP(void)
{
m_LOWriteBP = !m_LOWriteBP;
UpdateHaveRegBP();
}
void CBreakpoints::ToggleLOReadBP(void)
{
m_LOReadBP = !m_LOReadBP;
UpdateHaveRegBP();
}
void CBreakpoints::PreUpdateBP()
{

View File

@ -1,6 +1,6 @@
#pragma once
#include <stdint.h>
#include <map>
#include <stdint.h>
class CBreakpoints :
private CDebugSettings
@ -20,9 +20,18 @@ public:
CBreakpoints();
const breakpoints_t & ReadMem(void) const { return m_ReadMem; }
const breakpoints_t & WriteMem(void) const { return m_WriteMem; }
const breakpoints_t & Execution(void) const { return m_Execution; }
const breakpoints_t & ReadMem(void) const
{
return m_ReadMem;
}
const breakpoints_t & WriteMem(void) const
{
return m_WriteMem;
}
const breakpoints_t & Execution(void) const
{
return m_Execution;
}
BPSTATE ReadBPExists8(uint32_t address);
BPSTATE ReadBPExists16(uint32_t address);
@ -57,15 +66,42 @@ public:
void ClearMemLocks(void);
size_t NumMemLocks(void);
inline bool HaveRegBP(void) { return m_bHaveRegBP; }
inline bool HaveAnyGPRWriteBP(void) { return m_GPRWriteBP != 0; }
inline bool HaveAnyGPRReadBP(void) { return m_GPRReadBP != 0; }
inline bool HaveGPRWriteBP(int nReg) { return (m_GPRWriteBP & (1 << nReg)) != 0; }
inline bool HaveGPRReadBP(int nReg) { return (m_GPRReadBP & (1 << nReg)) != 0; }
inline bool HaveHIWriteBP(void) { return m_HIWriteBP; }
inline bool HaveHIReadBP(void) { return m_HIReadBP; }
inline bool HaveLOWriteBP(void) { return m_LOWriteBP; }
inline bool HaveLOReadBP(void) { return m_LOReadBP; }
inline bool HaveRegBP(void)
{
return m_bHaveRegBP;
}
inline bool HaveAnyGPRWriteBP(void)
{
return m_GPRWriteBP != 0;
}
inline bool HaveAnyGPRReadBP(void)
{
return m_GPRReadBP != 0;
}
inline bool HaveGPRWriteBP(int nReg)
{
return (m_GPRWriteBP & (1 << nReg)) != 0;
}
inline bool HaveGPRReadBP(int nReg)
{
return (m_GPRReadBP & (1 << nReg)) != 0;
}
inline bool HaveHIWriteBP(void)
{
return m_HIWriteBP;
}
inline bool HaveHIReadBP(void)
{
return m_HIReadBP;
}
inline bool HaveLOWriteBP(void)
{
return m_LOWriteBP;
}
inline bool HaveLOReadBP(void)
{
return m_LOReadBP;
}
void UpdateHaveRegBP(void);
void ToggleGPRWriteBP(int nReg);
@ -74,7 +110,7 @@ public:
void ToggleHIReadBP(void);
void ToggleLOWriteBP(void);
void ToggleLOReadBP(void);
private:
void PreUpdateBP();
void PostUpdateBP();

View File

@ -16,7 +16,7 @@ class CCPULog
size_t m_Size;
bool m_bMaxed;
size_t m_Index;
CPUState* m_Array;
CPUState * m_Array;
public:
CCPULog(size_t size = 0);
@ -24,8 +24,8 @@ public:
void PushState(void);
size_t GetCount(void);
size_t GetSize(void);
CPUState* GetEntry(size_t index);
CPUState * GetEntry(size_t index);
void Reset(void);
CCPULog* Clone(void);
void DumpToFile(const char* path);
CCPULog * Clone(void);
void DumpToFile(const char * path);
};

View File

@ -13,12 +13,12 @@ private:
vector<DMALOGENTRY> m_Log;
public:
void AddEntry(uint32_t romAddr, uint32_t ramAddr, uint32_t length);
void ClearEntries();
size_t GetNumEntries();
DMALOGENTRY* GetEntryByIndex(uint32_t index);
DMALOGENTRY* GetEntryByRamAddress(uint32_t ramAddr);
DMALOGENTRY* GetEntryByRamAddress(uint32_t ramAddr, uint32_t* lpRomAddr, uint32_t* lpOffset);
DMALOGENTRY* GetEntryByRomAddress(uint32_t romAddr);
DMALOGENTRY* GetEntryByRomAddress(uint32_t romAddr, uint32_t* lpRamAddr, uint32_t* lpOffset);
void AddEntry(uint32_t romAddr, uint32_t ramAddr, uint32_t length);
void ClearEntries();
size_t GetNumEntries();
DMALOGENTRY * GetEntryByIndex(uint32_t index);
DMALOGENTRY * GetEntryByRamAddress(uint32_t ramAddr);
DMALOGENTRY * GetEntryByRamAddress(uint32_t ramAddr, uint32_t * lpRomAddr, uint32_t * lpOffset);
DMALOGENTRY * GetEntryByRomAddress(uint32_t romAddr);
DMALOGENTRY * GetEntryByRomAddress(uint32_t romAddr, uint32_t * lpRamAddr, uint32_t * lpOffset);
};

View File

@ -3,14 +3,14 @@
#include <Project64-core/Settings/SettingType/SettingsType-Application.h>
template <class T>
class CDebugDialog :
public CDialogImpl < T >
public CDialogImpl<T>
{
protected:
CDebuggerUI * m_Debugger;
HANDLE m_CreatedEvent;
HANDLE m_DialogThread;
UISettingID m_UISettingID;
bool m_bInitialized;
HANDLE m_CreatedEvent;
HANDLE m_DialogThread;
UISettingID m_UISettingID;
bool m_bInitialized;
static DWORD CreateDebuggerWindow(CDebugDialog<T> * pThis)
{
@ -38,7 +38,7 @@ protected:
return;
}
T* pT = static_cast<T*>(this);
T * pT = static_cast<T *>(this);
std::string str = UISettingsLoadStringVal(m_UISettingID);
int left, top, width, height;
int nParams = sscanf(str.c_str(), "%d,%d,%d,%d", &left, &top, &width, &height);
@ -47,7 +47,8 @@ protected:
pT->SetWindowPos(nullptr, left, top, width, height, 0);
pT->RedrawWindow();
}
if (nParams == 2) {
if (nParams == 2)
{
pT->SetWindowPos(nullptr, left, top, width, height, 1);
pT->RedrawWindow();
}
@ -60,13 +61,15 @@ protected:
return;
}
T* pT = static_cast<T*>(this);
T * pT = static_cast<T *>(this);
CRect rect;
pT->GetWindowRect(&rect);
if (!bSaveSize) {
if (!bSaveSize)
{
UISettingsSaveString(m_UISettingID, stdstr_f("%d,%d", rect.left, rect.top).c_str());
}
else {
else
{
UISettingsSaveString(m_UISettingID, stdstr_f("%d,%d,%d,%d", rect.left, rect.top, rect.Width(), rect.Height()).c_str());
}
}
@ -122,15 +125,16 @@ public:
}
if (m_hWnd)
{
if (::IsIconic((HWND)m_hWnd))
if (::IsIconic((HWND)m_hWnd))
{
SendMessage(m_hWnd, WM_SYSCOMMAND, SC_RESTORE, NULL);
}
SetForegroundWindow((HWND)m_hWnd);
}
}
private:
bool m_SaveWnd;
LONG m_SaveWndTop;
LONG m_SaveWndLeft;
bool m_SaveWnd;
LONG m_SaveWndTop;
LONG m_SaveWndLeft;
};

View File

@ -3,16 +3,17 @@
class CDebugMMU
{
public:
size_t ReadPhysical(uint32_t paddr, size_t length, uint8_t* buffer);
size_t ReadVirtual(uint32_t vaddr, size_t length, uint8_t* buffer);
size_t WritePhysical(uint32_t paddr, size_t length, uint8_t* buffer);
size_t WriteVirtual(uint32_t vaddr, size_t length, uint8_t* buffer);
size_t ReadPhysical(uint32_t paddr, size_t length, uint8_t * buffer);
size_t ReadVirtual(uint32_t vaddr, size_t length, uint8_t * buffer);
size_t WritePhysical(uint32_t paddr, size_t length, uint8_t * buffer);
size_t WriteVirtual(uint32_t vaddr, size_t length, uint8_t * buffer);
template<typename T>
bool DebugLoad_PAddr(uint32_t paddr, T& value)
template <typename T>
bool DebugLoad_PAddr(uint32_t paddr, T & value)
{
union {
T word;
union
{
T word;
uint8_t bytes[sizeof(T)];
} buffer;
@ -25,11 +26,12 @@ public:
return false;
}
template<typename T>
bool DebugLoad_VAddr(uint32_t vaddr, T& value)
template <typename T>
bool DebugLoad_VAddr(uint32_t vaddr, T & value)
{
union {
T word;
union
{
T word;
uint8_t bytes[sizeof(T)];
} buffer;
@ -42,39 +44,41 @@ public:
return false;
}
template<typename T>
template <typename T>
bool DebugStore_PAddr(uint32_t paddr, T value)
{
union {
T word;
union
{
T word;
uint8_t bytes[sizeof(T)];
} buffer = { ByteSwap<T>(value) };
} buffer = {ByteSwap<T>(value)};
return (WritePhysical(paddr, sizeof(buffer), buffer.bytes) == sizeof(buffer));
}
template<typename T>
template <typename T>
bool DebugStore_VAddr(uint32_t vaddr, T value)
{
union {
T word;
union
{
T word;
uint8_t bytes[sizeof(T)];
} buffer = { ByteSwap<T>(value) };
} buffer = {ByteSwap<T>(value)};
return (WriteVirtual(vaddr, sizeof(buffer), buffer.bytes) == sizeof(buffer));
}
private:
uint8_t* GetPhysicalPtr(uint32_t paddr, WORD* flags = nullptr);
bool GetPhysicalByte(uint32_t paddr, uint8_t* value);
bool SetPhysicalByte(uint32_t paddr, uint8_t value);
uint8_t * GetPhysicalPtr(uint32_t paddr, WORD * flags = nullptr);
bool GetPhysicalByte(uint32_t paddr, uint8_t * value);
bool SetPhysicalByte(uint32_t paddr, uint8_t value);
template<typename T>
template <typename T>
T ByteSwap(T value)
{
union
{
T value;
T value;
uint16_t u16;
uint32_t u32;
uint64_t u64;
@ -84,15 +88,15 @@ private:
switch (sizeof(T))
{
case sizeof(uint8_t) :
case sizeof(uint8_t):
break;
case sizeof(uint16_t) :
case sizeof(uint16_t):
bytes.u16 = _byteswap_ushort(bytes.u16);
break;
case sizeof(uint32_t) :
case sizeof(uint32_t):
bytes.u32 = _byteswap_ulong(bytes.u32);
break;
case sizeof(uint64_t) :
case sizeof(uint64_t):
bytes.u64 = _byteswap_uint64(bytes.u64);
break;
default:

View File

@ -3,32 +3,37 @@
class CAddBreakpointDlg : public CDialogImpl<CAddBreakpointDlg>
{
public:
enum { IDD = IDD_Debugger_AddBreakpoint };
enum
{
IDD = IDD_Debugger_AddBreakpoint
};
INT_PTR CAddBreakpointDlg::DoModal(CDebuggerUI* debugger)
INT_PTR CAddBreakpointDlg::DoModal(CDebuggerUI * debugger)
{
m_Debugger = debugger;
return CDialogImpl<CAddBreakpointDlg>::DoModal();
}
private:
CDebuggerUI* m_Debugger;
CDebuggerUI * m_Debugger;
CButton m_ReadCheck;
CButton m_WriteCheck;
CButton m_ExecuteCheck;
CEdit m_AddressEdit;
CEdit m_AddressEdit;
LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
LRESULT OnClicked(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & /*bHandled*/);
LRESULT OnClicked(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL & bHandled);
LRESULT OnDestroy(void)
{
return 0;
}
BEGIN_MSG_MAP_EX(CAddBreakpointDlg)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
COMMAND_CODE_HANDLER(BN_CLICKED, OnClicked)
MSG_WM_DESTROY(OnDestroy)
{
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog);
COMMAND_CODE_HANDLER(BN_CLICKED, OnClicked);
MSG_WM_DESTROY(OnDestroy);
}
END_MSG_MAP()
};

View File

@ -3,14 +3,17 @@
class CAddSymbolDlg : public CDialogImpl<CAddSymbolDlg>
{
public:
enum { IDD = IDD_Debugger_AddSymbol };
enum
{
IDD = IDD_Debugger_AddSymbol
};
INT_PTR DoModal(CDebuggerUI* debugger);
INT_PTR DoModal(CDebuggerUI* debugger, uint32_t initAddress);
INT_PTR DoModal(CDebuggerUI* debugger, uint32_t initAddress, int initType);
INT_PTR DoModal(CDebuggerUI * debugger);
INT_PTR DoModal(CDebuggerUI * debugger, uint32_t initAddress);
INT_PTR DoModal(CDebuggerUI * debugger, uint32_t initAddress, int initType);
private:
CDebuggerUI* m_Debugger;
CDebuggerUI * m_Debugger;
bool m_bHaveAddress;
bool m_bHaveType;
@ -18,20 +21,22 @@ private:
int m_InitType;
CEditNumber32 m_AddressEdit;
CComboBox m_TypeComboBox;
CEdit m_NameEdit;
CEdit m_DescriptionEdit;
CComboBox m_TypeComboBox;
CEdit m_NameEdit;
CEdit m_DescriptionEdit;
LRESULT OnClicked(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
LRESULT OnClicked(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL & bHandled);
LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & /*bHandled*/);
LRESULT OnDestroy(void)
{
return 0;
}
BEGIN_MSG_MAP_EX(CAddSymbolDlg)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
COMMAND_CODE_HANDLER(BN_CLICKED, OnClicked)
MSG_WM_DESTROY(OnDestroy)
END_MSG_MAP()
{
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog);
COMMAND_CODE_HANDLER(BN_CLICKED, OnClicked);
MSG_WM_DESTROY(OnDestroy);
}
END_MSG_MAP()
};

View File

@ -428,8 +428,5 @@ bool CDebugCPULogView::MouseHovering(WORD ctrlId, int xMargin, int yMargin)
::GetCursorPos(&pointerPos);
return (
pointerPos.x >= rect.left - xMargin &&
pointerPos.x <= rect.right + xMargin &&
pointerPos.y >= rect.top - yMargin &&
pointerPos.y <= rect.bottom + yMargin);
pointerPos.x >= rect.left - xMargin && pointerPos.x <= rect.right + xMargin && pointerPos.y >= rect.top - yMargin && pointerPos.y <= rect.bottom + yMargin);
}

View File

@ -1,5 +1,6 @@
#pragma once
#include "DebuggerUI.h"
#include <Project64\UserInterface\WTLControls\TooltipDialog.h>
class CDebugCPULogView :
public CDebugDialog<CDebugCPULogView>,
@ -7,7 +8,10 @@ class CDebugCPULogView :
public CToolTipDialog<CDebugCPULogView>
{
public:
enum { IDD = IDD_Debugger_CPULog };
enum
{
IDD = IDD_Debugger_CPULog
};
CDebugCPULogView(CDebuggerUI * debugger);
virtual ~CDebugCPULogView(void);
@ -15,32 +19,31 @@ public:
void RefreshList(bool bUpdateBuffer = true);
private:
CCPULog* m_CPULogCopy;
CCPULog * m_CPULogCopy;
int m_RowHeight;
int m_LogStartIndex;
int m_RowHeight;
int m_LogStartIndex;
CListViewCtrl m_CPUListView;
CEdit m_StateInfoEdit;
CEdit m_StateInfoEdit;
CEditNumber32 m_BuffSizeEdit;
CButton m_EnabledChk;
CScrollBar m_Scrollbar;
CButton m_ExportBtn;
CButton m_EnabledChk;
CScrollBar m_Scrollbar;
CButton m_ExportBtn;
LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
LRESULT OnClicked(WORD wNotifyCode, WORD wID, HWND /*hWndCtl*/, BOOL& bHandled);
LRESULT OnActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnListDblClicked(NMHDR* pNMHDR);
LRESULT OnListItemChanged(NMHDR* pNMHDR);
LRESULT OnMeasureItem(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/);
LRESULT OnScroll(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/);
void OnExitSizeMove(void);
LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & /*bHandled*/);
LRESULT OnClicked(WORD wNotifyCode, WORD wID, HWND /*hWndCtl*/, BOOL & bHandled);
LRESULT OnActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled);
LRESULT OnListDblClicked(NMHDR * pNMHDR);
LRESULT OnListItemChanged(NMHDR * pNMHDR);
LRESULT OnMeasureItem(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL & /*bHandled*/);
LRESULT OnScroll(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL & /*bHandled*/);
void OnExitSizeMove(void);
LRESULT OnDestroy(void);
void InterceptMouseWheel(WPARAM wParam, LPARAM lParam);
static CDebugCPULogView* _this;
static CDebugCPULogView * _this;
static HHOOK hWinMessageHook;
static LRESULT CALLBACK HookProc(int nCode, WPARAM wParam, LPARAM lParam);
@ -48,29 +51,31 @@ private:
void ShowRegStates(size_t stateIndex);
void Export(void);
int GetNumVisibleRows(CListViewCtrl& list);
int GetNumVisibleRows(CListViewCtrl & list);
bool MouseHovering(WORD ctrlId, int xMargin = 0, int yMargin = 0);
BEGIN_MSG_MAP_EX(CDebugCPULogView)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
COMMAND_CODE_HANDLER(BN_CLICKED, OnClicked)
MESSAGE_HANDLER(WM_ACTIVATE, OnActivate)
NOTIFY_HANDLER_EX(IDC_CPU_LIST, NM_DBLCLK, OnListDblClicked)
NOTIFY_HANDLER_EX(IDC_CPU_LIST, LVN_ITEMCHANGED, OnListItemChanged)
MESSAGE_HANDLER(WM_MEASUREITEM, OnMeasureItem)
MESSAGE_HANDLER(WM_VSCROLL, OnScroll)
MSG_WM_EXITSIZEMOVE(OnExitSizeMove)
CHAIN_MSG_MAP(CDialogResize<CDebugCPULogView>)
{
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog);
COMMAND_CODE_HANDLER(BN_CLICKED, OnClicked);
MESSAGE_HANDLER(WM_ACTIVATE, OnActivate);
NOTIFY_HANDLER_EX(IDC_CPU_LIST, NM_DBLCLK, OnListDblClicked);
NOTIFY_HANDLER_EX(IDC_CPU_LIST, LVN_ITEMCHANGED, OnListItemChanged);
MESSAGE_HANDLER(WM_MEASUREITEM, OnMeasureItem);
MESSAGE_HANDLER(WM_VSCROLL, OnScroll);
MSG_WM_EXITSIZEMOVE(OnExitSizeMove);
CHAIN_MSG_MAP(CDialogResize<CDebugCPULogView>);
}
END_MSG_MAP()
BEGIN_DLGRESIZE_MAP(CDebugCPULogView)
DLGRESIZE_CONTROL(IDC_CPU_LIST, DLSZ_SIZE_X | DLSZ_SIZE_Y)
DLGRESIZE_CONTROL(IDC_REGSTATES_GRP, DLSZ_MOVE_X | DLSZ_SIZE_Y)
DLGRESIZE_CONTROL(IDC_STATEINFO_EDIT, DLSZ_MOVE_X | DLSZ_SIZE_Y)
DLGRESIZE_CONTROL(IDC_SCRL_BAR, DLSZ_SIZE_Y)
DLGRESIZE_CONTROL(IDC_CPU_LIST, DLSZ_SIZE_X | DLSZ_SIZE_Y)
DLGRESIZE_CONTROL(IDC_REGSTATES_GRP, DLSZ_MOVE_X | DLSZ_SIZE_Y)
DLGRESIZE_CONTROL(IDC_STATEINFO_EDIT, DLSZ_MOVE_X | DLSZ_SIZE_Y)
DLGRESIZE_CONTROL(IDC_SCRL_BAR, DLSZ_SIZE_Y)
END_DLGRESIZE_MAP()
BEGIN_TOOLTIP_MAP()
TOOLTIP(IDC_BUFFSIZE_EDIT, "Maximum number of states to keep (1024 = 416kB)") // sizeof(CPUState)
TOOLTIP(IDC_BUFFSIZE_EDIT, "Maximum number of states to keep (1024 = 416kB)") // sizeof(CPUState)
END_TOOLTIP_MAP()
};

View File

@ -161,9 +161,7 @@ void CDebugCommandsView::RecompilerCheck(void)
return;
}
if (g_Settings->LoadBool(Debugger_Enabled) &&
!g_Settings->LoadBool(Setting_ForceInterpreterCPU) &&
(CPU_TYPE)g_Settings->LoadDword(Game_CpuType) != CPU_Interpreter)
if (g_Settings->LoadBool(Debugger_Enabled) && !g_Settings->LoadBool(Setting_ForceInterpreterCPU) && (CPU_TYPE)g_Settings->LoadDword(Game_CpuType) != CPU_Interpreter)
{
// TODO: Remove this or fix?
MessageBox(L"Debugger support for the recompiler core is experimental.\n\n"
@ -264,9 +262,7 @@ void CDebugCommandsView::AddBranchArrow(int startPos, int endPos)
BRANCHARROW arrow = m_BranchArrows[j];
// Arrow's start or end position within another arrow's stride
if ((startPos >= arrow.startPos && startPos <= arrow.endPos) ||
(endPos >= arrow.startPos && endPos <= arrow.endPos) ||
(arrow.startPos <= startPos && arrow.startPos >= endPos))
if ((startPos >= arrow.startPos && startPos <= arrow.endPos) || (endPos >= arrow.startPos && endPos <= arrow.endPos) || (arrow.startPos <= startPos && arrow.startPos >= endPos))
{
if (margin <= arrow.margin)
{
@ -485,8 +481,7 @@ void CDebugCommandsView::ShowAddress(uint32_t address, bool top, bool bUserInput
}
else
{
bool bOutOfView = address < m_StartAddress ||
address > m_StartAddress + (m_CommandListRows - 1) * 4;
bool bOutOfView = address < m_StartAddress || address > m_StartAddress + (m_CommandListRows - 1) * 4;
if (bOutOfView)
{
@ -704,17 +699,13 @@ LRESULT CDebugCommandsView::OnCustomDrawList(NMHDR * pNMHDR)
{
// Breakpoint
pLVCD->clrTextBk = RGB(0x44, 0x00, 0x00);
pLVCD->clrText = (address == pc && isDebugging()) ?
RGB(0xFF, 0xFF, 0x00) : // Breakpoint and current PC
RGB(0xFF, 0xCC, 0xCC);
pLVCD->clrText = (address == pc && isDebugging()) ? RGB(0xFF, 0xFF, 0x00) : RGB(0xFF, 0xCC, 0xCC);
}
else if (bpState == CBreakpoints::BP_SET_TEMP)
{
// Breakpoint
pLVCD->clrTextBk = RGB(0x66, 0x44, 0x00);
pLVCD->clrText = (address == pc && isDebugging()) ?
RGB(0xFF, 0xFF, 0x00) : // Breakpoint and current PC
RGB(0xFF, 0xEE, 0xCC);
pLVCD->clrText = (address == pc && isDebugging()) ? RGB(0xFF, 0xFF, 0x00) : RGB(0xFF, 0xEE, 0xCC);
}
else if (address == pc && isStepping())
{
@ -867,19 +858,18 @@ LRESULT CDebugCommandsView::OnMeasureItem(UINT /*uMsg*/, WPARAM wParam, LPARAM l
// Draw branch arrows
void CDebugCommandsView::DrawBranchArrows(HDC listDC)
{
COLORREF colors[] =
{
RGB(240, 240, 240), // White
RGB(30, 135, 255), // Blue
RGB(255, 0, 200), // Pink
RGB(215, 155, 0), // Yellow
RGB(100, 180, 0), // Green
RGB(200, 100, 255), // Purple
RGB(120, 120, 120), // Gray
RGB(0, 220, 160), // Cyan
RGB(255, 100, 0), // Orange
RGB(255, 255, 0), // Yellow
};
COLORREF colors[] = {
RGB(240, 240, 240), // White
RGB(30, 135, 255), // Blue
RGB(255, 0, 200), // Pink
RGB(215, 155, 0), // Yellow
RGB(100, 180, 0), // Green
RGB(200, 100, 255), // Purple
RGB(120, 120, 120), // Gray
RGB(0, 220, 160), // Cyan
RGB(255, 100, 0), // Orange
RGB(255, 255, 0), // Yellow
};
int nColors = sizeof(colors) / sizeof(COLORREF);

View File

@ -1,9 +1,9 @@
#pragma once
#include "OpInfo.h"
#include "Breakpoints.h"
#include "Debugger-AddBreakpoint.h"
#include "Debugger-RegisterTabs.h"
#include "OpInfo.h"
#include <Project64/UserInterface/WTLControls/TooltipDialog.h>
@ -32,10 +32,10 @@ class CDebugCommandsView;
class CEditOp : public CWindowImpl<CEditOp, CEdit>
{
private:
CDebugCommandsView* m_CommandsWindow;
CDebugCommandsView * m_CommandsWindow;
LRESULT OnKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnKeyUp(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled)
LRESULT OnKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled);
LRESULT OnKeyUp(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL & bHandled)
{
if (wParam == VK_RETURN || wParam == VK_ESCAPE)
{
@ -47,13 +47,15 @@ private:
}
BEGIN_MSG_MAP_EX(CEditOp)
MESSAGE_HANDLER(WM_KEYDOWN, OnKeyDown)
MESSAGE_HANDLER(WM_KEYUP, OnKeyUp)
MESSAGE_HANDLER(WM_CHAR, OnKeyUp)
{
MESSAGE_HANDLER(WM_KEYDOWN, OnKeyDown);
MESSAGE_HANDLER(WM_KEYUP, OnKeyUp);
MESSAGE_HANDLER(WM_CHAR, OnKeyUp);
}
END_MSG_MAP()
public:
void SetCommandsWindow(CDebugCommandsView* commandsWindow);
void SetCommandsWindow(CDebugCommandsView * commandsWindow);
BOOL Attach(HWND hWndNew);
};
@ -66,9 +68,12 @@ class CDebugCommandsView :
friend class CEditOp;
public:
enum { IDD = IDD_Debugger_Commands };
enum
{
IDD = IDD_Debugger_Commands
};
CDebugCommandsView(CDebuggerUI * debugger, SyncEvent &StepEvent);
CDebugCommandsView(CDebuggerUI * debugger, SyncEvent & StepEvent);
virtual ~CDebugCommandsView(void);
void ShowAddress(uint32_t address, bool top, bool bUserInput = false);
@ -78,136 +83,144 @@ public:
private:
BEGIN_MSG_MAP_EX(CDebugCommandsView)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
MESSAGE_HANDLER(WM_ACTIVATE, OnActivate)
MESSAGE_HANDLER(WM_SIZING, OnSizing)
MESSAGE_HANDLER(WM_GETMINMAXINFO, OnGetMinMaxInfo)
MESSAGE_HANDLER(WM_VSCROLL, OnScroll)
MESSAGE_HANDLER(WM_MEASUREITEM, OnMeasureItem)
COMMAND_HANDLER(IDC_ADDR_EDIT, EN_CHANGE, OnAddrChanged)
COMMAND_HANDLER(IDC_PC_EDIT, EN_CHANGE, OnPCChanged)
COMMAND_CODE_HANDLER(LBN_DBLCLK, OnListBoxClicked)
COMMAND_HANDLER(IDC_BACK_BTN, BN_CLICKED, OnBackButton)
COMMAND_HANDLER(IDC_FORWARD_BTN, BN_CLICKED, OnForwardButton)
COMMAND_HANDLER(IDC_VIEWPC_BTN, BN_CLICKED, OnViewPCButton)
COMMAND_HANDLER(IDC_SYMBOLS_BTN, BN_CLICKED, OnSymbolsButton)
COMMAND_HANDLER(ID_POPUPMENU_RUNTO, BN_CLICKED, OnPopupmenuRunTo)
COMMAND_HANDLER(IDC_GO_BTN, BN_CLICKED, OnGoButton)
COMMAND_HANDLER(IDC_STEP_BTN, BN_CLICKED, OnStepButton)
COMMAND_HANDLER(IDC_STEPOVER_BTN, BN_CLICKED, OnStepOverButton)
COMMAND_HANDLER(IDC_SKIP_BTN, BN_CLICKED, OnSkipButton)
COMMAND_HANDLER(IDC_CLEARBP_BTN, BN_CLICKED, OnClearBPButton)
COMMAND_HANDLER(IDC_ADDBP_BTN, BN_CLICKED, OnAddBPButton)
COMMAND_HANDLER(IDC_RMBP_BTN, BN_CLICKED, OnRemoveBPButton)
COMMAND_HANDLER(IDC_COPYTABREGISTERS_BTN, BN_CLICKED, OnCopyTabRegistersButton)
COMMAND_HANDLER(IDC_COPYALLREGISTERS_BTN, BN_CLICKED, OnCopyAllRegistersButton)
COMMAND_HANDLER(IDCANCEL, BN_CLICKED, OnCancel)
COMMAND_HANDLER(ID_POPUPMENU_EDIT, BN_CLICKED, OnPopupmenuEdit)
COMMAND_HANDLER(ID_POPUPMENU_INSERTNOP, BN_CLICKED, OnPopupmenuInsertNOP)
COMMAND_HANDLER(ID_POPUPMENU_RESTORE, BN_CLICKED, OnPopupmenuRestore)
COMMAND_HANDLER(ID_POPUPMENU_RESTOREALL, BN_CLICKED, OnPopupmenuRestoreAll)
COMMAND_HANDLER(ID_POPUPMENU_ADDSYMBOL, BN_CLICKED, OnPopupmenuAddSymbol)
COMMAND_HANDLER(ID_POPUPMENU_FOLLOWJUMP, BN_CLICKED, OnPopupmenuFollowJump)
COMMAND_HANDLER(ID_POPUPMENU_VIEWMEMORY, BN_CLICKED, OnPopupmenuViewMemory)
COMMAND_HANDLER(ID_POPUPMENU_TOGGLEBP, BN_CLICKED, OnPopupmenuToggleBP)
COMMAND_HANDLER(ID_POPUPMENU_CLEARBPS, BN_CLICKED, OnPopupmenuClearBP)
COMMAND_HANDLER(IDC_OP_EDIT, EN_CHANGE, OnOpEditChanged)
{
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog);
MESSAGE_HANDLER(WM_ACTIVATE, OnActivate);
MESSAGE_HANDLER(WM_SIZING, OnSizing);
MESSAGE_HANDLER(WM_GETMINMAXINFO, OnGetMinMaxInfo);
MESSAGE_HANDLER(WM_VSCROLL, OnScroll);
MESSAGE_HANDLER(WM_MEASUREITEM, OnMeasureItem);
COMMAND_HANDLER(IDC_ADDR_EDIT, EN_CHANGE, OnAddrChanged);
COMMAND_HANDLER(IDC_PC_EDIT, EN_CHANGE, OnPCChanged);
COMMAND_CODE_HANDLER(LBN_DBLCLK, OnListBoxClicked);
COMMAND_HANDLER(IDC_BACK_BTN, BN_CLICKED, OnBackButton);
COMMAND_HANDLER(IDC_FORWARD_BTN, BN_CLICKED, OnForwardButton);
COMMAND_HANDLER(IDC_VIEWPC_BTN, BN_CLICKED, OnViewPCButton);
COMMAND_HANDLER(IDC_SYMBOLS_BTN, BN_CLICKED, OnSymbolsButton);
COMMAND_HANDLER(ID_POPUPMENU_RUNTO, BN_CLICKED, OnPopupmenuRunTo);
COMMAND_HANDLER(IDC_GO_BTN, BN_CLICKED, OnGoButton);
COMMAND_HANDLER(IDC_STEP_BTN, BN_CLICKED, OnStepButton);
COMMAND_HANDLER(IDC_STEPOVER_BTN, BN_CLICKED, OnStepOverButton);
COMMAND_HANDLER(IDC_SKIP_BTN, BN_CLICKED, OnSkipButton);
COMMAND_HANDLER(IDC_CLEARBP_BTN, BN_CLICKED, OnClearBPButton);
COMMAND_HANDLER(IDC_ADDBP_BTN, BN_CLICKED, OnAddBPButton);
COMMAND_HANDLER(IDC_RMBP_BTN, BN_CLICKED, OnRemoveBPButton);
COMMAND_HANDLER(IDC_COPYTABREGISTERS_BTN, BN_CLICKED, OnCopyTabRegistersButton);
COMMAND_HANDLER(IDC_COPYALLREGISTERS_BTN, BN_CLICKED, OnCopyAllRegistersButton);
COMMAND_HANDLER(IDCANCEL, BN_CLICKED, OnCancel);
COMMAND_HANDLER(ID_POPUPMENU_EDIT, BN_CLICKED, OnPopupmenuEdit);
COMMAND_HANDLER(ID_POPUPMENU_INSERTNOP, BN_CLICKED, OnPopupmenuInsertNOP);
COMMAND_HANDLER(ID_POPUPMENU_RESTORE, BN_CLICKED, OnPopupmenuRestore);
COMMAND_HANDLER(ID_POPUPMENU_RESTOREALL, BN_CLICKED, OnPopupmenuRestoreAll);
COMMAND_HANDLER(ID_POPUPMENU_ADDSYMBOL, BN_CLICKED, OnPopupmenuAddSymbol);
COMMAND_HANDLER(ID_POPUPMENU_FOLLOWJUMP, BN_CLICKED, OnPopupmenuFollowJump);
COMMAND_HANDLER(ID_POPUPMENU_VIEWMEMORY, BN_CLICKED, OnPopupmenuViewMemory);
COMMAND_HANDLER(ID_POPUPMENU_TOGGLEBP, BN_CLICKED, OnPopupmenuToggleBP);
COMMAND_HANDLER(ID_POPUPMENU_CLEARBPS, BN_CLICKED, OnPopupmenuClearBP);
COMMAND_HANDLER(IDC_OP_EDIT, EN_CHANGE, OnOpEditChanged);
NOTIFY_HANDLER_EX(IDC_CMD_LIST, NM_CLICK, OnCommandListClicked)
NOTIFY_HANDLER_EX(IDC_CMD_LIST, NM_DBLCLK, OnCommandListDblClicked)
NOTIFY_HANDLER_EX(IDC_CMD_LIST, NM_RCLICK, OnCommandListRightClicked)
NOTIFY_HANDLER_EX(IDC_REG_TABS, TCN_SELCHANGE, OnRegisterTabChange)
NOTIFY_HANDLER_EX(IDC_CMD_LIST, NM_CUSTOMDRAW, OnCustomDrawList)
MSG_WM_DESTROY(OnDestroy)
CHAIN_MSG_MAP(CDialogResize<CDebugCommandsView>)
MSG_WM_EXITSIZEMOVE(OnExitSizeMove)
NOTIFY_HANDLER_EX(IDC_CMD_LIST, NM_CLICK, OnCommandListClicked);
NOTIFY_HANDLER_EX(IDC_CMD_LIST, NM_DBLCLK, OnCommandListDblClicked);
NOTIFY_HANDLER_EX(IDC_CMD_LIST, NM_RCLICK, OnCommandListRightClicked);
NOTIFY_HANDLER_EX(IDC_REG_TABS, TCN_SELCHANGE, OnRegisterTabChange);
NOTIFY_HANDLER_EX(IDC_CMD_LIST, NM_CUSTOMDRAW, OnCustomDrawList);
MSG_WM_DESTROY(OnDestroy);
CHAIN_MSG_MAP(CDialogResize<CDebugCommandsView>);
MSG_WM_EXITSIZEMOVE(OnExitSizeMove);
}
END_MSG_MAP()
BEGIN_DLGRESIZE_MAP(CDebugCommandsView)
DLGRESIZE_CONTROL(IDC_GO_BTN, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_STEP_BTN, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_STEPOVER_BTN, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_SKIP_BTN, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_ADDR_EDIT, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_SYMBOLS_BTN, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_OPCODE_BOX, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_BP_LIST, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_ADDBP_BTN, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_RMBP_BTN, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_CLEARBP_BTN, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_COPYTABREGISTERS_BTN, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_COPYALLREGISTERS_BTN, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_REG_TABS, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_BACK_BTN, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_FORWARD_BTN, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_PC_STATIC, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_PC_EDIT, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_VIEWPC_BTN, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_CMD_LIST, DLSZ_SIZE_X | DLSZ_SIZE_Y)
DLGRESIZE_CONTROL(IDC_SCRL_BAR, DLSZ_MOVE_X | DLSZ_SIZE_Y)
DLGRESIZE_CONTROL(IDC_GO_BTN, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_STEP_BTN, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_STEPOVER_BTN, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_SKIP_BTN, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_ADDR_EDIT, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_SYMBOLS_BTN, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_OPCODE_BOX, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_BP_LIST, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_ADDBP_BTN, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_RMBP_BTN, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_CLEARBP_BTN, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_COPYTABREGISTERS_BTN, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_COPYALLREGISTERS_BTN, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_REG_TABS, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_BACK_BTN, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_FORWARD_BTN, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_PC_STATIC, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_PC_EDIT, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_VIEWPC_BTN, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_CMD_LIST, DLSZ_SIZE_X | DLSZ_SIZE_Y)
DLGRESIZE_CONTROL(IDC_SCRL_BAR, DLSZ_MOVE_X | DLSZ_SIZE_Y)
END_DLGRESIZE_MAP()
BEGIN_TOOLTIP_MAP()
TOOLTIP(IDC_SKIP_BTN, "Skip (F1)")
TOOLTIP(IDC_STEP_BTN, "Step (F2)")
TOOLTIP(IDC_STEPOVER_BTN, "Step Over (F3)")
TOOLTIP(IDC_GO_BTN, "Go (F4)")
TOOLTIP(IDC_ADDBP_BTN, "Add breakpoint...")
TOOLTIP(IDC_RMBP_BTN, "Remove selected breakpoint")
TOOLTIP(IDC_CLEARBP_BTN, "Remove all breakpoints")
TOOLTIP(IDC_VIEWPC_BTN, "Jump to program counter")
TOOLTIP(IDC_BP_LIST, "Active breakpoints")
TOOLTIP(IDC_SYMBOLS_BTN, "Symbols...")
TOOLTIP(IDC_SKIP_BTN, "Skip (F1)")
TOOLTIP(IDC_STEP_BTN, "Step (F2)")
TOOLTIP(IDC_STEPOVER_BTN, "Step Over (F3)")
TOOLTIP(IDC_GO_BTN, "Go (F4)")
TOOLTIP(IDC_ADDBP_BTN, "Add breakpoint...")
TOOLTIP(IDC_RMBP_BTN, "Remove selected breakpoint")
TOOLTIP(IDC_CLEARBP_BTN, "Remove all breakpoints")
TOOLTIP(IDC_VIEWPC_BTN, "Jump to program counter")
TOOLTIP(IDC_BP_LIST, "Active breakpoints")
TOOLTIP(IDC_SYMBOLS_BTN, "Symbols...")
END_TOOLTIP_MAP()
static void StaticSteppingOpsChanged(CDebugCommandsView * __this) { __this->SteppingOpsChanged(); }
static void StaticWaitingForStepChanged(CDebugCommandsView * __this) { __this->WaitingForStepChanged(); }
static void GameCpuRunningChanged(CDebugCommandsView* _this);
static void StaticSteppingOpsChanged(CDebugCommandsView * __this)
{
__this->SteppingOpsChanged();
}
static void StaticWaitingForStepChanged(CDebugCommandsView * __this)
{
__this->WaitingForStepChanged();
}
static void GameCpuRunningChanged(CDebugCommandsView * _this);
void RecompilerCheck(void);
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnSizing(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnScroll(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnMeasureItem(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnAddrChanged(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnPCChanged(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnListBoxClicked(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnBackButton(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnForwardButton(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnViewPCButton(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnSymbolsButton(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnPopupmenuRunTo(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnGoButton(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnStepButton(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnStepOverButton(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnSkipButton(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnClearBPButton(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnAddBPButton(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnRemoveBPButton(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnCopyTabRegistersButton(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnCopyAllRegistersButton(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnCancel(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnPopupmenuEdit(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnPopupmenuInsertNOP(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnPopupmenuRestore(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnPopupmenuRestoreAll(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnPopupmenuAddSymbol(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnPopupmenuFollowJump(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnPopupmenuViewMemory(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnPopupmenuToggleBP(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnPopupmenuClearBP(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnClicked(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnOpEditChanged(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnOpEditKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled);
LRESULT OnActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled);
LRESULT OnSizing(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled);
LRESULT OnScroll(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled);
LRESULT OnMeasureItem(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled);
LRESULT OnAddrChanged(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL & bHandled);
LRESULT OnPCChanged(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL & bHandled);
LRESULT OnListBoxClicked(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL & bHandled);
LRESULT OnBackButton(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL & bHandled);
LRESULT OnForwardButton(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL & bHandled);
LRESULT OnViewPCButton(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL & bHandled);
LRESULT OnSymbolsButton(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL & bHandled);
LRESULT OnPopupmenuRunTo(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL & bHandled);
LRESULT OnGoButton(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL & bHandled);
LRESULT OnStepButton(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL & bHandled);
LRESULT OnStepOverButton(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL & bHandled);
LRESULT OnSkipButton(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL & bHandled);
LRESULT OnClearBPButton(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL & bHandled);
LRESULT OnAddBPButton(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL & bHandled);
LRESULT OnRemoveBPButton(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL & bHandled);
LRESULT OnCopyTabRegistersButton(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL & bHandled);
LRESULT OnCopyAllRegistersButton(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL & bHandled);
LRESULT OnCancel(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL & bHandled);
LRESULT OnPopupmenuEdit(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL & bHandled);
LRESULT OnPopupmenuInsertNOP(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL & bHandled);
LRESULT OnPopupmenuRestore(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL & bHandled);
LRESULT OnPopupmenuRestoreAll(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL & bHandled);
LRESULT OnPopupmenuAddSymbol(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL & bHandled);
LRESULT OnPopupmenuFollowJump(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL & bHandled);
LRESULT OnPopupmenuViewMemory(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL & bHandled);
LRESULT OnPopupmenuToggleBP(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL & bHandled);
LRESULT OnPopupmenuClearBP(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL & bHandled);
LRESULT OnClicked(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL & bHandled);
LRESULT OnOpEditChanged(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL & bHandled);
LRESULT OnOpEditKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled);
LRESULT OnCommandListClicked(NMHDR* pNMHDR);
LRESULT OnCommandListDblClicked(NMHDR* pNMHDR);
LRESULT OnCommandListRightClicked(NMHDR* pNMHDR);
LRESULT OnRegisterTabChange(NMHDR* pNMHDR);
LRESULT OnCustomDrawList(NMHDR* pNMHDR);
LRESULT OnCommandListClicked(NMHDR * pNMHDR);
LRESULT OnCommandListDblClicked(NMHDR * pNMHDR);
LRESULT OnCommandListRightClicked(NMHDR * pNMHDR);
LRESULT OnRegisterTabChange(NMHDR * pNMHDR);
LRESULT OnCustomDrawList(NMHDR * pNMHDR);
LRESULT OnDestroy(void);
void OnExitSizeMove(void);
@ -225,14 +238,14 @@ private:
void HistoryPushState();
void ToggleHistoryButtons();
static CDebugCommandsView* _this;
static CDebugCommandsView * _this;
static HHOOK hWinMessageHook;
static LRESULT CALLBACK HookProc(int nCode, WPARAM wParam, LPARAM lParam);
void InterceptKeyDown(WPARAM wParam, LPARAM lParam);
void InterceptMouseWheel(WPARAM wParam, LPARAM lParam);
static const char* GetCodeAddressNotes(uint32_t vAddr);
static const char* GetDataAddressNotes(uint32_t vAddr);
static const char * GetCodeAddressNotes(uint32_t vAddr);
static const char * GetDataAddressNotes(uint32_t vAddr);
void CPUSkip();
void CPUResume();
@ -246,7 +259,7 @@ private:
void RedrawCommandsAndRegisters();
CBreakpoints* m_Breakpoints;
CBreakpoints * m_Breakpoints;
vector<uint32_t> m_History;
int m_HistoryIndex;
@ -278,11 +291,11 @@ private:
CButton m_GoButton;
bool m_bEditing;
CEditOp m_OpEdit;
CEditOp m_OpEdit;
uint32_t m_SelectedAddress;
COpInfo m_SelectedOpInfo;
R4300iOpcode& m_SelectedOpCode = m_SelectedOpInfo.m_OpCode;
COpInfo m_SelectedOpInfo;
R4300iOpcode & m_SelectedOpCode = m_SelectedOpInfo.m_OpCode;
uint32_t m_FollowAddress;
uint32_t m_RowHeight;

View File

@ -136,11 +136,7 @@ void CDebugDMALogView::Export(void)
wsprintf(filePath, L"*.csv");
const TCHAR * filters = (
/*1*/ L"Comma separated values (*.csv)\0*.csv;\0"
/*2*/ L"Plain text (*.txt)\0*.txt;\0"
);
const TCHAR * filters = L"Comma separated values (*.csv)\0*.csv;\0Plain text (*.txt)\0*.txt;\0";
const char * extensions[] = {"", ".csv", ".txt"};
openfilename.lStructSize = sizeof(openfilename);

View File

@ -6,7 +6,10 @@ class CDebugDMALogView :
public CDialogResize<CDebugDMALogView>
{
public:
enum { IDD = IDD_Debugger_DMALog };
enum
{
IDD = IDD_Debugger_DMALog
};
CDebugDMALogView(CDebuggerUI * debugger);
virtual ~CDebugDMALogView(void);
@ -22,7 +25,7 @@ private:
void RefreshList(void);
void Export(void);
CDMALog* m_DMALog;
CDMALog * m_DMALog;
int m_nLastStartIndex;
bool m_bConvertingAddress;
@ -34,43 +37,45 @@ private:
bool FilterEntry(int dmaLogIndex);
CListViewCtrl m_DMAList;
CEdit m_DMARamEdit;
CEdit m_DMARomEdit;
CStatic m_BlockInfo;
CEdit m_DMARamEdit;
CEdit m_DMARomEdit;
CStatic m_BlockInfo;
bool m_bCustomDrawClrNext;
LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
LRESULT OnRefresh(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/);
LRESULT OnClicked(WORD wNotifyCode, WORD wID, HWND /*hWndCtl*/, BOOL& bHandled);
LRESULT OnActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnRamAddrChanged(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnRomAddrChanged(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnCustomDrawList(NMHDR* pNMHDR);
LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & /*bHandled*/);
LRESULT OnRefresh(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL & /*bHandled*/);
LRESULT OnClicked(WORD wNotifyCode, WORD wID, HWND /*hWndCtl*/, BOOL & bHandled);
LRESULT OnActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled);
LRESULT OnRamAddrChanged(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL & bHandled);
LRESULT OnRomAddrChanged(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL & bHandled);
LRESULT OnCustomDrawList(NMHDR * pNMHDR);
LRESULT OnDestroy(void);
void OnExitSizeMove(void);
BEGIN_MSG_MAP_EX(CDebugDMALogView)
MESSAGE_HANDLER(WM_REFRESH, OnRefresh)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
COMMAND_CODE_HANDLER(BN_CLICKED, OnClicked)
MESSAGE_HANDLER(WM_ACTIVATE, OnActivate)
COMMAND_HANDLER(IDC_DMA_RAM_EDIT, EN_CHANGE, OnRamAddrChanged)
COMMAND_HANDLER(IDC_DMA_ROM_EDIT, EN_CHANGE, OnRomAddrChanged)
NOTIFY_HANDLER_EX(IDC_DMA_LIST, NM_CUSTOMDRAW, OnCustomDrawList)
CHAIN_MSG_MAP(CDialogResize<CDebugDMALogView>)
MSG_WM_EXITSIZEMOVE(OnExitSizeMove)
{
MESSAGE_HANDLER(WM_REFRESH, OnRefresh);
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog);
COMMAND_CODE_HANDLER(BN_CLICKED, OnClicked);
MESSAGE_HANDLER(WM_ACTIVATE, OnActivate);
COMMAND_HANDLER(IDC_DMA_RAM_EDIT, EN_CHANGE, OnRamAddrChanged);
COMMAND_HANDLER(IDC_DMA_ROM_EDIT, EN_CHANGE, OnRomAddrChanged);
NOTIFY_HANDLER_EX(IDC_DMA_LIST, NM_CUSTOMDRAW, OnCustomDrawList);
CHAIN_MSG_MAP(CDialogResize<CDebugDMALogView>);
MSG_WM_EXITSIZEMOVE(OnExitSizeMove);
}
END_MSG_MAP()
BEGIN_DLGRESIZE_MAP(CDebugDMALogView)
DLGRESIZE_CONTROL(IDC_DMA_LIST, DLSZ_SIZE_X | DLSZ_SIZE_Y)
DLGRESIZE_CONTROL(IDC_TRACE_STATIC, DLSZ_MOVE_Y)
DLGRESIZE_CONTROL(IDC_BLOCK_INFO, DLSZ_MOVE_Y)
DLGRESIZE_CONTROL(IDC_RAM_STATIC, DLSZ_MOVE_Y)
DLGRESIZE_CONTROL(IDC_ROM_STATIC, DLSZ_MOVE_Y)
DLGRESIZE_CONTROL(IDC_DMA_ROM_EDIT, DLSZ_MOVE_Y)
DLGRESIZE_CONTROL(IDC_DMA_RAM_EDIT, DLSZ_MOVE_Y)
DLGRESIZE_CONTROL(IDC_CLEAR_BTN, DLSZ_MOVE_X | DLSZ_MOVE_Y)
DLGRESIZE_CONTROL(IDC_EXPORT_BTN, DLSZ_MOVE_X | DLSZ_MOVE_Y)
DLGRESIZE_CONTROL(IDC_DMA_LIST, DLSZ_SIZE_X | DLSZ_SIZE_Y)
DLGRESIZE_CONTROL(IDC_TRACE_STATIC, DLSZ_MOVE_Y)
DLGRESIZE_CONTROL(IDC_BLOCK_INFO, DLSZ_MOVE_Y)
DLGRESIZE_CONTROL(IDC_RAM_STATIC, DLSZ_MOVE_Y)
DLGRESIZE_CONTROL(IDC_ROM_STATIC, DLSZ_MOVE_Y)
DLGRESIZE_CONTROL(IDC_DMA_ROM_EDIT, DLSZ_MOVE_Y)
DLGRESIZE_CONTROL(IDC_DMA_RAM_EDIT, DLSZ_MOVE_Y)
DLGRESIZE_CONTROL(IDC_CLEAR_BTN, DLSZ_MOVE_X | DLSZ_MOVE_Y)
DLGRESIZE_CONTROL(IDC_EXPORT_BTN, DLSZ_MOVE_X | DLSZ_MOVE_Y)
END_DLGRESIZE_MAP()
};

View File

@ -21,7 +21,7 @@ CDebugExcBreakpoints::ExcCheckboxMeta CDebugExcBreakpoints::ExcCheckboxMap[] = {
{IDC_CHK_FPE, 15},
{IDC_CHK_WATCH, 23},
{IDC_CHK_VCED, 31},
{ 0, 0 }
{0, 0},
};
CDebugExcBreakpoints::ExcCheckboxMeta CDebugExcBreakpoints::FpExcCheckboxMap[] = {
@ -31,7 +31,7 @@ CDebugExcBreakpoints::ExcCheckboxMeta CDebugExcBreakpoints::FpExcCheckboxMap[] =
{IDC_CHK_FP_CZ, (1 << 3)},
{IDC_CHK_FP_CV, (1 << 4)},
{IDC_CHK_FP_CE, (1 << 5)},
{ 0, 0 }
{0, 0},
};
CDebugExcBreakpoints::ExcCheckboxMeta CDebugExcBreakpoints::IntrCheckboxMap[] = {
@ -43,7 +43,7 @@ CDebugExcBreakpoints::ExcCheckboxMeta CDebugExcBreakpoints::IntrCheckboxMap[] =
{IDC_CHK_INTR_IP5, (1 << 5)},
{IDC_CHK_INTR_IP6, (1 << 6)},
{IDC_CHK_INTR_IP7, (1 << 7)},
{ 0, 0 }
{0, 0},
};
CDebugExcBreakpoints::ExcCheckboxMeta CDebugExcBreakpoints::RcpIntrCheckboxMap[] = {
@ -53,7 +53,7 @@ CDebugExcBreakpoints::ExcCheckboxMeta CDebugExcBreakpoints::RcpIntrCheckboxMap[]
{IDC_CHK_INTR_VI, (1 << 3)},
{IDC_CHK_INTR_PI, (1 << 4)},
{IDC_CHK_INTR_DP, (1 << 5)},
{ 0, 0 }
{0, 0},
};
CDebugExcBreakpoints::CDebugExcBreakpoints(CDebuggerUI * debugger) :

View File

@ -1,7 +1,6 @@
#pragma once
#include "DebuggerUI.h"
class CDebugExcBreakpoints :
public CDebugDialog<CDebugExcBreakpoints>
{
@ -12,7 +11,10 @@ class CDebugExcBreakpoints :
} ExcCheckboxMeta;
public:
enum { IDD = IDD_Debugger_ExceptionBP };
enum
{
IDD = IDD_Debugger_ExceptionBP
};
CDebugExcBreakpoints(CDebuggerUI * debugger);
virtual ~CDebugExcBreakpoints(void);
@ -23,20 +25,22 @@ private:
static ExcCheckboxMeta IntrCheckboxMap[];
static ExcCheckboxMeta RcpIntrCheckboxMap[];
void InitCheckboxes(ExcCheckboxMeta* checkboxMap, SettingID settingID, bool bShift = false);
void UpdateBpSetting(ExcCheckboxMeta* checkboxMap, SettingID settingID, WORD wID, bool bChecked, bool bShift = false);
void EnableCheckboxes(ExcCheckboxMeta* checkboxMap, bool bEnable);
void InitCheckboxes(ExcCheckboxMeta * checkboxMap, SettingID settingID, bool bShift = false);
void UpdateBpSetting(ExcCheckboxMeta * checkboxMap, SettingID settingID, WORD wID, bool bChecked, bool bShift = false);
void EnableCheckboxes(ExcCheckboxMeta * checkboxMap, bool bEnable);
LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
LRESULT OnClicked(WORD wNotifyCode, WORD wID, HWND /*hWndCtl*/, BOOL& bHandled);
void OnExitSizeMove(void);
LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & /*bHandled*/);
LRESULT OnClicked(WORD wNotifyCode, WORD wID, HWND /*hWndCtl*/, BOOL & bHandled);
void OnExitSizeMove(void);
LRESULT OnDestroy(void);
BEGIN_MSG_MAP_EX(CDebugExcBreakpoints)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
COMMAND_CODE_HANDLER(BN_CLICKED, OnClicked)
MSG_WM_EXITSIZEMOVE(OnExitSizeMove)
MSG_WM_DESTROY(OnDestroy)
{
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog);
COMMAND_CODE_HANDLER(BN_CLICKED, OnClicked);
MSG_WM_EXITSIZEMOVE(OnExitSizeMove);
MSG_WM_DESTROY(OnDestroy);
}
END_MSG_MAP()
};

View File

@ -1,18 +1,21 @@
#pragma once
class CDumpMemory :
public CDebugDialog < CDumpMemory >
public CDebugDialog<CDumpMemory>
{
public:
enum { IDD = IDD_Cheats_DumpMemory };
enum
{
IDD = IDD_Cheats_DumpMemory
};
CDumpMemory(CDebuggerUI * debugger);
virtual ~CDumpMemory(void);
private:
CDumpMemory(void);
CDumpMemory(const CDumpMemory&);
CDumpMemory& operator=(const CDumpMemory&);
CDumpMemory(const CDumpMemory &);
CDumpMemory & operator=(const CDumpMemory &);
enum DumpFormat
{
@ -21,18 +24,20 @@ private:
};
BEGIN_MSG_MAP_EX(CDumpMemory)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
COMMAND_CODE_HANDLER(BN_CLICKED, OnClicked)
{
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog);
COMMAND_CODE_HANDLER(BN_CLICKED, OnClicked);
MSG_WM_EXITSIZEMOVE(OnExitSizeMove);
END_MSG_MAP()
}
END_MSG_MAP()
LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
LRESULT OnClicked(WORD wNotifyCode, WORD wID, HWND /*hWndCtl*/, BOOL& bHandled);
LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & /*bHandled*/);
LRESULT OnClicked(WORD wNotifyCode, WORD wID, HWND /*hWndCtl*/, BOOL & bHandled);
void OnExitSizeMove(void);
bool DumpMemory(LPCTSTR FileName, DumpFormat Format, DWORD StartPC, DWORD EndPC, DWORD DumpPC);
CComboBox m_FormatList;
CEdit m_FileName;
CComboBox m_FormatList;
CEdit m_FileName;
CEditNumber32 m_StartAddress, m_EndAddress, m_PC;
};

View File

@ -18,7 +18,7 @@ const CSetValueDlg::ComboItem CDebugMemorySearch::ModalChangeTypeItems[] = {
{"float", ValueType_float},
{"double", ValueType_double},
{"string", ValueType_string},
{ nullptr, 0 }
{nullptr, 0},
};
CDebugMemorySearch::CDebugMemorySearch(CDebuggerUI * debugger) :
@ -1448,10 +1448,7 @@ bool CDebugMemorySearch::MouseHovering(WORD ctrlId, int hMargin, int vMargin)
::GetWindowRect(GetDlgItem(ctrlId), &ctrlRect);
return (
pointerPos.x >= ctrlRect.left - hMargin &&
pointerPos.x <= ctrlRect.right + hMargin &&
pointerPos.y >= ctrlRect.top - vMargin &&
pointerPos.y <= ctrlRect.bottom + vMargin);
pointerPos.x >= ctrlRect.left - hMargin && pointerPos.x <= ctrlRect.right + hMargin && pointerPos.y >= ctrlRect.top - vMargin && pointerPos.y <= ctrlRect.bottom + vMargin);
}
void CDebugMemorySearch::SeparatorMoveCtrl(WORD ctrlId, int yChange, bool bResize)
@ -1757,10 +1754,7 @@ void CDebugMemorySearch::UpdateOptions(void)
m_SearchValue.EnableWindow(TRUE);
if (searchType == SearchType_JalTo ||
valueType == ValueType_string ||
valueType == ValueType_istring ||
valueType == ValueType_unkstring)
if (searchType == SearchType_JalTo || valueType == ValueType_string || valueType == ValueType_istring || valueType == ValueType_unkstring)
{
// Complex search types, disable next search
::EnableWindow(GetDlgItem(IDC_BTN_SEARCH), false);

View File

@ -1,7 +1,7 @@
#pragma once
#include "MemoryScanner.h"
#include "Debugger-AddSymbol.h"
#include "MemoryScanner.h"
class CEditMixed :
public CWindowImpl<CEditMixed, CEdit>,
@ -16,18 +16,18 @@ public:
DisplayFormat GetDisplayFormat(void);
void SetDisplayFormat(DisplayFormat fmt);
bool GetValue(uint8_t& value);
bool GetValue(int8_t& value);
bool GetValue(uint16_t& value);
bool GetValue(int16_t& value);
bool GetValue(uint32_t& value);
bool GetValue(int32_t& value);
bool GetValue(uint64_t& value);
bool GetValue(int64_t& value);
bool GetValue(float& value);
bool GetValue(double& value);
bool GetValueString(const wchar_t*& value, int& length);
bool GetValueHexString(const wchar_t*& value, int& length);
bool GetValue(uint8_t & value);
bool GetValue(int8_t & value);
bool GetValue(uint16_t & value);
bool GetValue(int16_t & value);
bool GetValue(uint32_t & value);
bool GetValue(int32_t & value);
bool GetValue(uint64_t & value);
bool GetValue(int64_t & value);
bool GetValue(float & value);
bool GetValue(double & value);
bool GetValueString(const wchar_t *& value, int & length);
bool GetValueHexString(const wchar_t *& value, int & length);
BEGIN_MSG_MAP_EX(CEditMixed)
END_MSG_MAP()
@ -35,7 +35,7 @@ public:
private:
ValueType m_Type;
DisplayFormat m_DisplayFormat;
wchar_t *m_String;
wchar_t * m_String;
int m_StringLength;
void ReloadString(void);
};
@ -44,33 +44,38 @@ class CSetValueDlg : public CDialogImpl<CSetValueDlg>
{
public:
BEGIN_MSG_MAP_EX(CSetValueDlg)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
COMMAND_HANDLER(IDOK, BN_CLICKED, OnOK)
COMMAND_HANDLER(IDCANCEL, BN_CLICKED, OnCancel)
MSG_WM_DESTROY(OnDestroy)
{
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog);
COMMAND_HANDLER(IDOK, BN_CLICKED, OnOK);
COMMAND_HANDLER(IDCANCEL, BN_CLICKED, OnCancel);
MSG_WM_DESTROY(OnDestroy);
}
END_MSG_MAP()
enum { IDD = IDD_Debugger_Search_SetValue };
enum
{
IDD = IDD_Debugger_Search_SetValue
};
typedef struct
{
const char* str;
const char * str;
DWORD_PTR data;
} ComboItem;
CSetValueDlg(void);
virtual ~CSetValueDlg(void);
INT_PTR DoModal(const char* caption, const char* label, const char* initialText);
INT_PTR DoModal(const char* caption, const char* label, DWORD_PTR initialData, const ComboItem items[]);
INT_PTR DoModal(const char * caption, const char * label, const char * initialText);
INT_PTR DoModal(const char * caption, const char * label, DWORD_PTR initialData, const ComboItem items[]);
const std::string & GetEnteredString(void);
DWORD_PTR GetEnteredData(void);
private:
LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & /*bHandled*/);
LRESULT OnDestroy(void);
LRESULT OnOK(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnCancel(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnOK(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL & bHandled);
LRESULT OnCancel(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL & bHandled);
enum Mode
{
@ -79,10 +84,10 @@ private:
};
Mode m_Mode;
const char* m_Caption;
const char* m_Label;
const ComboItem* m_ComboItems;
const char * m_Caption;
const char * m_Label;
const ComboItem * m_ComboItems;
const char * m_InitialText;
std::string m_EnteredString;
@ -100,7 +105,10 @@ class CDebugMemorySearch :
public CDialogResize<CDebugMemorySearch>
{
public:
enum { IDD = IDD_Debugger_Search };
enum
{
IDD = IDD_Debugger_Search
};
CDebugMemorySearch(CDebuggerUI * debugger);
virtual ~CDebugMemorySearch(void);
@ -113,7 +121,8 @@ private:
WM_GAMERESET = WM_USER + 1
};
enum {
enum
{
TIMER_ID_AUTO_REFRESH
};
@ -123,7 +132,8 @@ private:
GS_TWOBYTE = 0x01000000
};
enum {
enum
{
WatchListCtrl_Col_Lock,
WatchListCtrl_Col_BP,
WatchListCtrl_Col_Address,
@ -133,75 +143,76 @@ private:
WatchListCtrl_Num_Columns
};
enum {
enum
{
ResultsListCtrl_Col_Address,
ResultsListCtrl_Col_Value,
ResultsListCtrl_Col_Previous
};
CDebugMemorySearch(void);
CDebugMemorySearch(const CDebugMemorySearch&);
CDebugMemorySearch& operator=(const CDebugMemorySearch&);
CDebugMemorySearch(const CDebugMemorySearch &);
CDebugMemorySearch & operator=(const CDebugMemorySearch &);
static LRESULT CALLBACK HookProc(int nCode, WPARAM wParam, LPARAM lParam);
static CDebugMemorySearch* _this;
static CDebugMemorySearch * _this;
static HHOOK hWinMessageHook;
static const CSetValueDlg::ComboItem ModalChangeTypeItems[];
LRESULT OnSetFont(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnSetFont(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled);
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled);
LRESULT OnDestroy(void);
LRESULT OnGameReset(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
void OnExitSizeMove(void);
void OnSizing(UINT fwSide, LPRECT pRect);
void OnTimer(UINT_PTR nIDEvent);
LRESULT OnScroll(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnMouseDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnMouseUp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
void OnInterceptMouseWheel(WPARAM wParam, LPARAM lParam);
void OnInterceptMouseMove(WPARAM wParam, LPARAM lParam);
LRESULT OnMeasureItem(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnCancel(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnHexCheckbox(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnSearchButton(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnResetButton(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnRdramButton(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnRomButton(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnSpmemButton(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnScanTypeChanged(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnValueTypeChanged(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnGameReset(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled);
void OnExitSizeMove(void);
void OnSizing(UINT fwSide, LPRECT pRect);
void OnTimer(UINT_PTR nIDEvent);
LRESULT OnScroll(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled);
LRESULT OnMouseDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled);
LRESULT OnMouseUp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled);
void OnInterceptMouseWheel(WPARAM wParam, LPARAM lParam);
void OnInterceptMouseMove(WPARAM wParam, LPARAM lParam);
LRESULT OnMeasureItem(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled);
LRESULT OnCancel(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL & bHandled);
LRESULT OnHexCheckbox(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL & bHandled);
LRESULT OnSearchButton(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL & bHandled);
LRESULT OnResetButton(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL & bHandled);
LRESULT OnRdramButton(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL & bHandled);
LRESULT OnRomButton(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL & bHandled);
LRESULT OnSpmemButton(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL & bHandled);
LRESULT OnScanTypeChanged(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL & bHandled);
LRESULT OnValueTypeChanged(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL & bHandled);
LRESULT OnResultsCustomDraw(LPNMHDR lpnmh);
LRESULT OnResultsDblClick(LPNMHDR lpnmh);
LRESULT OnResultsRClick(LPNMHDR lpnmh);
LRESULT OnResultsPopupViewMemory(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnResultsPopupAddToWatchList(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnResultsPopupAddAllToWatchList(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnResultsPopupSetValue(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnResultsPopupRemove(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnResultsPopupViewMemory(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL & bHandled);
LRESULT OnResultsPopupAddToWatchList(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL & bHandled);
LRESULT OnResultsPopupAddAllToWatchList(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL & bHandled);
LRESULT OnResultsPopupSetValue(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL & bHandled);
LRESULT OnResultsPopupRemove(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL & bHandled);
LRESULT OnWatchListItemChanged(LPNMHDR lpnmh);
LRESULT OnWatchListCustomDraw(LPNMHDR lpnmh);
LRESULT OnWatchListRClick(LPNMHDR lpnmh);
LRESULT OnWatchListDblClick(LPNMHDR lpnmh);
LRESULT OnWatchListPopupLock(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnWatchListPopupReadBP(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnWatchListPopupWriteBP(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnWatchListPopupViewMemory(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnWatchListPopupAddSymbol(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnWatchListPopupHexadecimal(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnWatchListPopupChangeValue(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnWatchListPopupChangeDescription(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnWatchListPopupChangeType(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnWatchListPopupChangeAddress(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnWatchListPopupChangeAddressBy(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnWatchListPopupRemove(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnWatchListPopupRemoveAll(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnWatchListPopupCopyGamesharkCode(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnWatchListPopupCopyAddressAndDescription(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnWatchListPopupLock(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL & bHandled);
LRESULT OnWatchListPopupReadBP(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL & bHandled);
LRESULT OnWatchListPopupWriteBP(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL & bHandled);
LRESULT OnWatchListPopupViewMemory(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL & bHandled);
LRESULT OnWatchListPopupAddSymbol(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL & bHandled);
LRESULT OnWatchListPopupHexadecimal(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL & bHandled);
LRESULT OnWatchListPopupChangeValue(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL & bHandled);
LRESULT OnWatchListPopupChangeDescription(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL & bHandled);
LRESULT OnWatchListPopupChangeType(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL & bHandled);
LRESULT OnWatchListPopupChangeAddress(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL & bHandled);
LRESULT OnWatchListPopupChangeAddressBy(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL & bHandled);
LRESULT OnWatchListPopupRemove(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL & bHandled);
LRESULT OnWatchListPopupRemoveAll(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL & bHandled);
LRESULT OnWatchListPopupCopyGamesharkCode(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL & bHandled);
LRESULT OnWatchListPopupCopyAddressAndDescription(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL & bHandled);
CScanResult * GetFirstSelectedScanResult(void);
CScanResult * GetFirstSelectedWatchListResult(void);
CScanResult* GetFirstSelectedScanResult(void);
CScanResult* GetFirstSelectedWatchListResult(void);
void ResetResults(void);
void Search(void);
void UpdateOptions(void);
@ -222,11 +233,11 @@ private:
CPath GetWatchListPath(void);
// Generic UI utility
void FixListHeader(CListViewCtrl& listCtrl);
void SetComboBoxSelByData(CComboBox& cb, DWORD_PTR data);
void FixListHeader(CListViewCtrl & listCtrl);
void SetComboBoxSelByData(CComboBox & cb, DWORD_PTR data);
bool MouseHovering(WORD ctrlId, int hMargin = 0, int vMargin = 0);
int GetNumVisibleRows(CListViewCtrl& list);
int GetNumVisibleRows(CListViewCtrl & list);
bool m_bJalSelected;
bool m_bJalHexWasChecked;
bool m_bJalUnsignedWasChecked;
@ -235,105 +246,107 @@ private:
DWORD m_ThreadId;
CFile m_WatchListFile;
CSetValueDlg m_SetValueDlg;
CSetValueDlg m_SetValueDlg;
CAddSymbolDlg m_AddSymbolDlg;
CEditMixed m_SearchValue;
CEditMixed m_SearchValue;
CEditNumber32 m_AddrStart, m_AddrEnd;
CComboBox m_SearchTypeOptions, m_ValueTypeOptions;
CComboBox m_SearchTypeOptions, m_ValueTypeOptions;
CListViewCtrl m_ResultsListCtrl, m_WatchListCtrl;
CScrollBar m_ResultsScrollbar, m_WatchListScrollbar;
CButton m_PhysicalCheckbox, m_HexCheckbox;
CButton m_UnsignedCheckbox, m_IgnoreCaseCheckbox, m_UnkEncodingCheckbox;
CScrollBar m_ResultsScrollbar, m_WatchListScrollbar;
CButton m_PhysicalCheckbox, m_HexCheckbox;
CButton m_UnsignedCheckbox, m_IgnoreCaseCheckbox, m_UnkEncodingCheckbox;
CMemoryScanner m_MemoryScanner;
std::vector<CScanResult> m_WatchList;
bool m_bDraggingSeparator;
bool m_bDraggingSeparator;
CRect m_InitialSeparatorRect, m_LastSeparatorRect;
int m_ListCtrlRowHeight;
int m_ListCtrlRowHeight;
HCURSOR m_hCursorSizeNS;
BEGIN_MSG_MAP_EX(CDebugMemorySearch)
MESSAGE_HANDLER(WM_GAMERESET, OnGameReset)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
MSG_WM_DESTROY(OnDestroy)
MSG_WM_EXITSIZEMOVE(OnExitSizeMove)
MSG_WM_SIZING(OnSizing)
MSG_WM_TIMER(OnTimer)
COMMAND_HANDLER(IDCANCEL, BN_CLICKED, OnCancel)
MESSAGE_HANDLER(WM_VSCROLL, OnScroll)
MESSAGE_HANDLER(WM_LBUTTONDOWN, OnMouseDown)
MESSAGE_HANDLER(WM_LBUTTONUP, OnMouseUp)
MESSAGE_HANDLER(WM_MEASUREITEM, OnMeasureItem)
MESSAGE_HANDLER(WM_SETFONT, OnSetFont)
COMMAND_HANDLER(IDC_CHK_HEX, BN_CLICKED, OnHexCheckbox)
COMMAND_HANDLER(IDC_BTN_SEARCH, BN_CLICKED, OnSearchButton)
COMMAND_HANDLER(IDC_BTN_RESET, BN_CLICKED, OnResetButton)
COMMAND_HANDLER(IDC_CMB_SCANTYPE, CBN_SELCHANGE, OnScanTypeChanged)
COMMAND_HANDLER(IDC_CMB_VALUETYPE, CBN_SELCHANGE, OnValueTypeChanged)
COMMAND_HANDLER(IDC_BTN_RDRAM, BN_CLICKED, OnRdramButton)
COMMAND_HANDLER(IDC_BTN_ROM, BN_CLICKED, OnRomButton)
COMMAND_HANDLER(IDC_BTN_SPMEM, BN_CLICKED, OnSpmemButton)
NOTIFY_HANDLER_EX(IDC_LST_RESULTS, NM_CUSTOMDRAW, OnResultsCustomDraw)
NOTIFY_HANDLER_EX(IDC_LST_RESULTS, NM_DBLCLK, OnResultsDblClick)
NOTIFY_HANDLER_EX(IDC_LST_RESULTS, NM_RCLICK, OnResultsRClick)
COMMAND_HANDLER(ID_RESULTS_VIEWMEMORY, BN_CLICKED, OnResultsPopupViewMemory)
COMMAND_HANDLER(ID_RESULTS_ADDTOWATCHLIST, BN_CLICKED, OnResultsPopupAddToWatchList)
COMMAND_HANDLER(ID_RESULTS_ADDALLTOWATCHLIST, BN_CLICKED, OnResultsPopupAddAllToWatchList)
COMMAND_HANDLER(ID_RESULTS_CHANGEVALUE, BN_CLICKED, OnResultsPopupSetValue)
COMMAND_HANDLER(ID_RESULTS_REMOVE, BN_CLICKED, OnResultsPopupRemove)
NOTIFY_HANDLER_EX(IDC_LST_WATCHLIST, LVN_ITEMCHANGED, OnWatchListItemChanged)
NOTIFY_HANDLER_EX(IDC_LST_WATCHLIST, NM_CUSTOMDRAW, OnWatchListCustomDraw)
NOTIFY_HANDLER_EX(IDC_LST_WATCHLIST, NM_DBLCLK, OnWatchListDblClick)
NOTIFY_HANDLER_EX(IDC_LST_WATCHLIST, NM_RCLICK, OnWatchListRClick)
COMMAND_HANDLER(ID_WATCHLIST_VIEWMEMORY, BN_CLICKED, OnWatchListPopupViewMemory)
COMMAND_HANDLER(ID_WATCHLIST_LOCKVALUE, BN_CLICKED, OnWatchListPopupLock)
COMMAND_HANDLER(ID_WATCHLIST_READBP, BN_CLICKED, OnWatchListPopupReadBP)
COMMAND_HANDLER(ID_WATCHLIST_WRITEBP, BN_CLICKED, OnWatchListPopupWriteBP)
COMMAND_HANDLER(ID_WATCHLIST_ADDSYMBOL, BN_CLICKED, OnWatchListPopupAddSymbol)
COMMAND_HANDLER(ID_WATCHLIST_HEXADECIMAL, BN_CLICKED, OnWatchListPopupHexadecimal)
COMMAND_HANDLER(ID_WATCHLIST_CHANGE_VALUE, BN_CLICKED, OnWatchListPopupChangeValue)
COMMAND_HANDLER(ID_WATCHLIST_CHANGE_DESCRIPTION, BN_CLICKED, OnWatchListPopupChangeDescription)
COMMAND_HANDLER(ID_WATCHLIST_CHANGE_TYPE, BN_CLICKED, OnWatchListPopupChangeType)
COMMAND_HANDLER(ID_WATCHLIST_CHANGE_ADDRESS, BN_CLICKED, OnWatchListPopupChangeAddress)
COMMAND_HANDLER(ID_WATCHLIST_CHANGE_ADDRESSBY, BN_CLICKED, OnWatchListPopupChangeAddressBy)
COMMAND_HANDLER(ID_WATCHLIST_REMOVE, BN_CLICKED, OnWatchListPopupRemove)
COMMAND_HANDLER(ID_WATCHLIST_REMOVEALL, BN_CLICKED, OnWatchListPopupRemoveAll)
COMMAND_HANDLER(ID_WATCHLIST_COPY_GSCODE, BN_CLICKED, OnWatchListPopupCopyGamesharkCode)
COMMAND_HANDLER(ID_WATCHLIST_COPY_ADDRDESC, BN_CLICKED, OnWatchListPopupCopyAddressAndDescription)
CHAIN_MSG_MAP(CDialogResize<CDebugMemorySearch>)
{
MESSAGE_HANDLER(WM_GAMERESET, OnGameReset);
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog);
MSG_WM_DESTROY(OnDestroy);
MSG_WM_EXITSIZEMOVE(OnExitSizeMove);
MSG_WM_SIZING(OnSizing);
MSG_WM_TIMER(OnTimer);
COMMAND_HANDLER(IDCANCEL, BN_CLICKED, OnCancel);
MESSAGE_HANDLER(WM_VSCROLL, OnScroll);
MESSAGE_HANDLER(WM_LBUTTONDOWN, OnMouseDown);
MESSAGE_HANDLER(WM_LBUTTONUP, OnMouseUp);
MESSAGE_HANDLER(WM_MEASUREITEM, OnMeasureItem);
MESSAGE_HANDLER(WM_SETFONT, OnSetFont);
COMMAND_HANDLER(IDC_CHK_HEX, BN_CLICKED, OnHexCheckbox);
COMMAND_HANDLER(IDC_BTN_SEARCH, BN_CLICKED, OnSearchButton);
COMMAND_HANDLER(IDC_BTN_RESET, BN_CLICKED, OnResetButton);
COMMAND_HANDLER(IDC_CMB_SCANTYPE, CBN_SELCHANGE, OnScanTypeChanged);
COMMAND_HANDLER(IDC_CMB_VALUETYPE, CBN_SELCHANGE, OnValueTypeChanged);
COMMAND_HANDLER(IDC_BTN_RDRAM, BN_CLICKED, OnRdramButton);
COMMAND_HANDLER(IDC_BTN_ROM, BN_CLICKED, OnRomButton);
COMMAND_HANDLER(IDC_BTN_SPMEM, BN_CLICKED, OnSpmemButton);
NOTIFY_HANDLER_EX(IDC_LST_RESULTS, NM_CUSTOMDRAW, OnResultsCustomDraw);
NOTIFY_HANDLER_EX(IDC_LST_RESULTS, NM_DBLCLK, OnResultsDblClick);
NOTIFY_HANDLER_EX(IDC_LST_RESULTS, NM_RCLICK, OnResultsRClick);
COMMAND_HANDLER(ID_RESULTS_VIEWMEMORY, BN_CLICKED, OnResultsPopupViewMemory);
COMMAND_HANDLER(ID_RESULTS_ADDTOWATCHLIST, BN_CLICKED, OnResultsPopupAddToWatchList);
COMMAND_HANDLER(ID_RESULTS_ADDALLTOWATCHLIST, BN_CLICKED, OnResultsPopupAddAllToWatchList);
COMMAND_HANDLER(ID_RESULTS_CHANGEVALUE, BN_CLICKED, OnResultsPopupSetValue);
COMMAND_HANDLER(ID_RESULTS_REMOVE, BN_CLICKED, OnResultsPopupRemove);
NOTIFY_HANDLER_EX(IDC_LST_WATCHLIST, LVN_ITEMCHANGED, OnWatchListItemChanged);
NOTIFY_HANDLER_EX(IDC_LST_WATCHLIST, NM_CUSTOMDRAW, OnWatchListCustomDraw);
NOTIFY_HANDLER_EX(IDC_LST_WATCHLIST, NM_DBLCLK, OnWatchListDblClick);
NOTIFY_HANDLER_EX(IDC_LST_WATCHLIST, NM_RCLICK, OnWatchListRClick);
COMMAND_HANDLER(ID_WATCHLIST_VIEWMEMORY, BN_CLICKED, OnWatchListPopupViewMemory);
COMMAND_HANDLER(ID_WATCHLIST_LOCKVALUE, BN_CLICKED, OnWatchListPopupLock);
COMMAND_HANDLER(ID_WATCHLIST_READBP, BN_CLICKED, OnWatchListPopupReadBP);
COMMAND_HANDLER(ID_WATCHLIST_WRITEBP, BN_CLICKED, OnWatchListPopupWriteBP);
COMMAND_HANDLER(ID_WATCHLIST_ADDSYMBOL, BN_CLICKED, OnWatchListPopupAddSymbol);
COMMAND_HANDLER(ID_WATCHLIST_HEXADECIMAL, BN_CLICKED, OnWatchListPopupHexadecimal);
COMMAND_HANDLER(ID_WATCHLIST_CHANGE_VALUE, BN_CLICKED, OnWatchListPopupChangeValue);
COMMAND_HANDLER(ID_WATCHLIST_CHANGE_DESCRIPTION, BN_CLICKED, OnWatchListPopupChangeDescription);
COMMAND_HANDLER(ID_WATCHLIST_CHANGE_TYPE, BN_CLICKED, OnWatchListPopupChangeType);
COMMAND_HANDLER(ID_WATCHLIST_CHANGE_ADDRESS, BN_CLICKED, OnWatchListPopupChangeAddress);
COMMAND_HANDLER(ID_WATCHLIST_CHANGE_ADDRESSBY, BN_CLICKED, OnWatchListPopupChangeAddressBy);
COMMAND_HANDLER(ID_WATCHLIST_REMOVE, BN_CLICKED, OnWatchListPopupRemove);
COMMAND_HANDLER(ID_WATCHLIST_REMOVEALL, BN_CLICKED, OnWatchListPopupRemoveAll);
COMMAND_HANDLER(ID_WATCHLIST_COPY_GSCODE, BN_CLICKED, OnWatchListPopupCopyGamesharkCode);
COMMAND_HANDLER(ID_WATCHLIST_COPY_ADDRDESC, BN_CLICKED, OnWatchListPopupCopyAddressAndDescription);
CHAIN_MSG_MAP(CDialogResize<CDebugMemorySearch>);
}
END_MSG_MAP()
BEGIN_DLGRESIZE_MAP(CDebugMemorySearch)
DLGRESIZE_CONTROL(IDC_LST_WATCHLIST, DLSZ_SIZE_X | DLSZ_SIZE_Y)
DLGRESIZE_CONTROL(IDC_SCRL_WATCHLIST, DLSZ_MOVE_X | DLSZ_SIZE_Y)
DLGRESIZE_CONTROL(IDC_NUM_RESULTS, DLSZ_SIZE_X)
DLGRESIZE_CONTROL(IDC_LST_RESULTS, DLSZ_SIZE_X)
DLGRESIZE_CONTROL(IDC_SCRL_RESULTS, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_SEPARATOR, DLSZ_SIZE_X)
DLGRESIZE_CONTROL(IDC_BTN_SEARCH, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_BTN_RESET, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_GRP_SEARCH, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_CHK_HEX, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_CHK_UNSIGNED, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_CHK_IGNORECASE, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_CHK_UNKENCODING, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_SEARCH_VALUE, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_LBL_SCANTYPE, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_LBL_VALUETYPE, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_CMB_SCANTYPE, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_CMB_VALUETYPE, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_LBL_ADDRSTART, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_LBL_ADDREND, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_ADDR_START, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_ADDR_END, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_CHK_PHYSICAL, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_BTN_RDRAM, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_BTN_ROM, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_BTN_SPMEM, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_GRP_ADDR, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_LST_WATCHLIST, DLSZ_SIZE_X | DLSZ_SIZE_Y)
DLGRESIZE_CONTROL(IDC_SCRL_WATCHLIST, DLSZ_MOVE_X | DLSZ_SIZE_Y)
DLGRESIZE_CONTROL(IDC_NUM_RESULTS, DLSZ_SIZE_X)
DLGRESIZE_CONTROL(IDC_LST_RESULTS, DLSZ_SIZE_X)
DLGRESIZE_CONTROL(IDC_SCRL_RESULTS, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_SEPARATOR, DLSZ_SIZE_X)
DLGRESIZE_CONTROL(IDC_BTN_SEARCH, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_BTN_RESET, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_GRP_SEARCH, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_CHK_HEX, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_CHK_UNSIGNED, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_CHK_IGNORECASE, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_CHK_UNKENCODING, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_SEARCH_VALUE, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_LBL_SCANTYPE, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_LBL_VALUETYPE, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_CMB_SCANTYPE, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_CMB_VALUETYPE, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_LBL_ADDRSTART, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_LBL_ADDREND, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_ADDR_START, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_ADDR_END, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_CHK_PHYSICAL, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_BTN_RDRAM, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_BTN_ROM, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_BTN_SPMEM, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_GRP_ADDR, DLSZ_MOVE_X)
END_DLGRESIZE_MAP()
};

View File

@ -12,9 +12,9 @@ using FieldPairCallback = std::function<void(const CWindow & Label, const CWindo
struct TabRecord
{
const size_t FieldCount = 0;
const FieldPair* Fields = nullptr;
const FieldPair * Fields = nullptr;
constexpr TabRecord(size_t arraySize, const FieldPair *pairs) :
constexpr TabRecord(size_t arraySize, const FieldPair * pairs) :
FieldCount{arraySize / sizeof(*pairs)},
Fields{pairs}
{
@ -24,7 +24,7 @@ struct TabRecord
{
for (int i = 0, end = FieldCount; i < end; i++)
{
const FieldPair *pair = (Fields + i);
const FieldPair * pair = (Fields + i);
if (pair->LabelId == ctrl)
{
return i;
@ -37,7 +37,7 @@ struct TabRecord
{
for (int i = 0, end = FieldCount; i < end; i++)
{
const FieldPair *pair = (Fields + i);
const FieldPair * pair = (Fields + i);
if (pair->EditId == ctrl)
{
return i;
@ -50,7 +50,7 @@ struct TabRecord
{
for (size_t i = 0, end = FieldCount; i < end; i++)
{
const FieldPair *pair = (Fields + i);
const FieldPair * pair = (Fields + i);
if (callback(parent.GetDescendantWindow(pair->LabelId), parent.GetDescendantWindow(pair->EditId)))
{
break;
@ -62,7 +62,7 @@ struct TabRecord
{
for (size_t i = 0, end = FieldCount; i < end; i++)
{
const FieldPair *pair = (Fields + i);
const FieldPair * pair = (Fields + i);
callback(parent.GetDescendantWindow(pair->LabelId), parent.GetDescendantWindow(pair->EditId));
}
}

View File

@ -733,8 +733,7 @@ CWindow CRegisterTabs::AddTab(char * caption, int dialogId, DLGPROC dlgProc)
pageRect.top,
pageRect.Width(),
pageRect.Height(),
SWP_HIDEWINDOW
);
SWP_HIDEWINDOW);
m_TabWindows.push_back(tabWin);
@ -920,9 +919,8 @@ stdstr CRegisterTabs::CopyTabRegisters(int id)
break;
}
record->Iterate(tab, [&str](const CWindow & label, const CWindow & edit)
{
str += stdstr_f( "\r\n%s %s", GetCWindowText(label).c_str(), GetCWindowText(edit).c_str());
record->Iterate(tab, [&str](const CWindow & label, const CWindow & edit) {
str += stdstr_f("\r\n%s %s", GetCWindowText(label).c_str(), GetCWindowText(edit).c_str());
});
switch (id)

View File

@ -2,26 +2,28 @@
#include "Breakpoints.h"
#include "Debugger-RegisterTabData.h"
class CEditReg64 :
class CEditReg64 :
public CWindowImpl<CEditReg64, CEdit>,
private CDebugSettings
{
public:
static uint64_t ParseValue(const char* wordPair);
static uint64_t ParseValue(const char * wordPair);
BOOL Attach(HWND hWndNew);
LRESULT OnChar(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnLostFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnChar(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled);
LRESULT OnLostFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled);
uint64_t GetValue();
void SetValue(uint32_t h, uint32_t l);
void SetValue(uint64_t value);
BEGIN_MSG_MAP_EX(CRegEdit64)
MESSAGE_HANDLER(WM_CHAR, OnChar)
MESSAGE_HANDLER(WM_KILLFOCUS, OnLostFocus)
{
MESSAGE_HANDLER(WM_CHAR, OnChar);
MESSAGE_HANDLER(WM_KILLFOCUS, OnLostFocus);
}
END_MSG_MAP()
};
class CRegisterTabs :
class CRegisterTabs :
public CTabCtrl,
public CDebugSettings
{
@ -36,10 +38,10 @@ public:
CRegisterTabs(void);
~CRegisterTabs();
void Attach(HWND hWndNew, CDebuggerUI* debugger);
void Attach(HWND hWndNew, CDebuggerUI * debugger);
HWND Detach();
CWindow AddTab(char* caption, int dialogId, DLGPROC dlgProc);
CWindow AddTab(char * caption, int dialogId, DLGPROC dlgProc);
void ShowTab(int nPage);
CRect GetPageRect();
void RedrawCurrentTab();
@ -49,8 +51,8 @@ public:
void CopyAllRegisters();
private:
CRegisterTabs(const CRegisterTabs&);
CRegisterTabs& operator=(const CRegisterTabs&);
CRegisterTabs(const CRegisterTabs &);
CRegisterTabs & operator=(const CRegisterTabs &);
stdstr CopyTabRegisters(int id);
@ -60,16 +62,15 @@ private:
static INT_PTR CALLBACK TabProcGPR(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);
static INT_PTR CALLBACK TabProcFPR(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);
static void InitRegisterEdit(CWindow & tab, CEditNumber32 & edit, FieldPair ctrl);
static void InitRegisterEdits(CWindow & tab, CEditNumber32 * edits, const TabRecord * ctrlIds);
static void InitRegisterEdit64(CWindow & tab, CEditReg64 & edit, FieldPair ctrl);
static void InitRegisterEdits64(CWindow & tab, CEditReg64 * edits, const TabRecord * ctrlIds);
static void InitRegisterEdit(CWindow& tab, CEditNumber32& edit, FieldPair ctrl);
static void InitRegisterEdits(CWindow& tab, CEditNumber32* edits, const TabRecord* ctrlIds);
static void InitRegisterEdit64(CWindow& tab, CEditReg64& edit, FieldPair ctrl);
static void InitRegisterEdits64(CWindow& tab, CEditReg64* edits, const TabRecord* ctrlIds);
static void ZeroRegisterEdit(CEditNumber32& edit);
static void ZeroRegisterEdits(CEditNumber32* edits, uint32_t ctrlIdsCount);
static void ZeroRegisterEdit64(CEditReg64& edit);
static void ZeroRegisterEdits64(CEditReg64* edits, uint32_t ctrlIdsCount);
static void ZeroRegisterEdit(CEditNumber32 & edit);
static void ZeroRegisterEdits(CEditNumber32 * edits, uint32_t ctrlIdsCount);
static void ZeroRegisterEdit64(CEditReg64 & edit);
static void ZeroRegisterEdits64(CEditReg64 * edits, uint32_t ctrlIdsCount);
typedef union
{
@ -128,12 +129,12 @@ private:
"? 28",
"? 29",
"? 30",
"Virtual coherency (data)"
"Virtual coherency (data)",
};
// For static dlgprocs, assumes single instance
static bool m_bColorsEnabled;
static CDebuggerUI* m_Debugger;
static CDebuggerUI * m_Debugger;
vector<CWindow> m_TabWindows;
bool m_attached;

View File

@ -441,8 +441,7 @@ LRESULT CDebugScripts::OnRefreshList(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*
}
} while (searchPath.FindNext());
fileNames.sort([](stdstr a, stdstr b)
{ return a.ToLower() < b.ToLower(); });
fileNames.sort([](stdstr a, stdstr b) { return a.ToLower() < b.ToLower(); });
m_ScriptList.SetRedraw(false);
m_ScriptList.DeleteAllItems();

View File

@ -1,9 +1,9 @@
#pragma once
#include "Debugger-ScriptsAutorun.h"
#include "DebuggerUI.h"
#include "ScriptSystem.h"
#include <Project64/UserInterface/WTLControls/EditConInput.h>
#include <Project64/UserInterface/WTLControls/TooltipDialog.h>
#include "Debugger-ScriptsAutorun.h"
#include <string>
#include <vector>
@ -13,14 +13,16 @@ class CDebugScripts :
public CToolTipDialog<CDebugScripts>
{
private:
enum {
enum
{
WM_REFRESH_LIST = WM_USER + 1,
WM_SCRIPT_STATUS = WM_USER + 2,
WM_CONSOLE_PRINT = WM_USER + 3,
WM_CONSOLE_CLEAR = WM_USER + 4
};
enum {
enum
{
CONFLUSH_TIMER_ID = 0,
CONFLUSH_TIMER_INTERVAL = 50
};
@ -38,14 +40,14 @@ private:
stdstr m_ScriptsDir;
stdstr m_SelectedScriptName;
std::vector<wchar_t*> m_InputHistory;
std::vector<wchar_t *> m_InputHistory;
size_t m_InputHistoryIndex;
stdstr m_ConOutputBuffer;
HANDLE m_hQuitScriptDirWatchEvent;
HANDLE m_hScriptDirWatchThread;
static DWORD WINAPI ScriptDirWatchProc(void *ctx);
static DWORD WINAPI ScriptDirWatchProc(void * ctx);
void RunSelected();
void StopSelected();
@ -54,72 +56,77 @@ private:
void RefreshStatus();
void ConsoleCopy();
void SendInput(const char* name, const char* code);
void SendInput(const char * name, const char * code);
public:
enum { IDD = IDD_Debugger_Scripts };
enum
{
IDD = IDD_Debugger_Scripts
};
CDebugScripts(CDebuggerUI * debugger);
virtual ~CDebugScripts(void);
void ConsolePrint(const char* text);
void ConsolePrint(const char * text);
void ConsoleClear();
void RefreshList();
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnCtlColorStatic(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnCtlColorEdit(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled);
LRESULT OnCtlColorStatic(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled);
LRESULT OnCtlColorEdit(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled);
LRESULT OnDestroy(void);
LRESULT OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
LRESULT OnScriptListDblClicked(NMHDR* pNMHDR);
LRESULT OnScriptListRClicked(NMHDR* pNMHDR);
LRESULT OnScriptListCustomDraw(NMHDR* pNMHDR);
LRESULT OnScriptListItemChanged(NMHDR* pNMHDR);
LRESULT OnInputSpecialKey(NMHDR* pNMHDR);
LRESULT OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL & /*bHandled*/);
LRESULT OnScriptListDblClicked(NMHDR * pNMHDR);
LRESULT OnScriptListRClicked(NMHDR * pNMHDR);
LRESULT OnScriptListCustomDraw(NMHDR * pNMHDR);
LRESULT OnScriptListItemChanged(NMHDR * pNMHDR);
LRESULT OnInputSpecialKey(NMHDR * pNMHDR);
void OnExitSizeMove(void);
void OnTimer(UINT_PTR nIDEvent);
LRESULT OnConsolePrint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnConsoleClear(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnRefreshList(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnConsolePrint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled);
LRESULT OnConsoleClear(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled);
LRESULT OnRefreshList(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled);
BEGIN_MSG_MAP_EX(CDebugScripts)
COMMAND_CODE_HANDLER(BN_CLICKED, OnClicked)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
MESSAGE_HANDLER(WM_CTLCOLORSTATIC, OnCtlColorStatic)
MESSAGE_HANDLER(WM_CTLCOLOREDIT, OnCtlColorEdit)
NOTIFY_HANDLER_EX(IDC_SCRIPT_LIST, NM_DBLCLK, OnScriptListDblClicked)
NOTIFY_HANDLER_EX(IDC_SCRIPT_LIST, NM_RCLICK, OnScriptListRClicked)
NOTIFY_HANDLER_EX(IDC_SCRIPT_LIST, NM_CUSTOMDRAW, OnScriptListCustomDraw)
NOTIFY_HANDLER_EX(IDC_SCRIPT_LIST, LVN_ITEMCHANGED, OnScriptListItemChanged)
NOTIFY_HANDLER_EX(IDC_EVAL_EDIT, CIN_SPECIALKEY, OnInputSpecialKey)
MSG_WM_TIMER(OnTimer)
MSG_WM_DESTROY(OnDestroy)
{
COMMAND_CODE_HANDLER(BN_CLICKED, OnClicked);
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog);
MESSAGE_HANDLER(WM_CTLCOLORSTATIC, OnCtlColorStatic);
MESSAGE_HANDLER(WM_CTLCOLOREDIT, OnCtlColorEdit);
NOTIFY_HANDLER_EX(IDC_SCRIPT_LIST, NM_DBLCLK, OnScriptListDblClicked);
NOTIFY_HANDLER_EX(IDC_SCRIPT_LIST, NM_RCLICK, OnScriptListRClicked);
NOTIFY_HANDLER_EX(IDC_SCRIPT_LIST, NM_CUSTOMDRAW, OnScriptListCustomDraw);
NOTIFY_HANDLER_EX(IDC_SCRIPT_LIST, LVN_ITEMCHANGED, OnScriptListItemChanged);
NOTIFY_HANDLER_EX(IDC_EVAL_EDIT, CIN_SPECIALKEY, OnInputSpecialKey);
MSG_WM_TIMER(OnTimer);
MSG_WM_DESTROY(OnDestroy);
MSG_WM_EXITSIZEMOVE(OnExitSizeMove);
MESSAGE_HANDLER(WM_CONSOLE_PRINT, OnConsolePrint)
MESSAGE_HANDLER(WM_CONSOLE_CLEAR, OnConsoleClear)
MESSAGE_HANDLER(WM_REFRESH_LIST, OnRefreshList)
CHAIN_MSG_MAP(CDialogResize<CDebugScripts>)
MESSAGE_HANDLER(WM_CONSOLE_PRINT, OnConsolePrint);
MESSAGE_HANDLER(WM_CONSOLE_CLEAR, OnConsoleClear);
MESSAGE_HANDLER(WM_REFRESH_LIST, OnRefreshList);
CHAIN_MSG_MAP(CDialogResize<CDebugScripts>);
}
END_MSG_MAP()
BEGIN_DLGRESIZE_MAP(CDebugScripts)
DLGRESIZE_CONTROL(IDC_CONSOLE_EDIT, DLSZ_SIZE_X | DLSZ_SIZE_Y)
DLGRESIZE_CONTROL(IDC_SCRIPT_LIST, DLSZ_SIZE_Y)
DLGRESIZE_CONTROL(IDC_CLEAR_BTN, DLSZ_MOVE_X | DLSZ_MOVE_Y)
DLGRESIZE_CONTROL(IDC_COPY_BTN, DLSZ_MOVE_X | DLSZ_MOVE_Y)
DLGRESIZE_CONTROL(IDC_SCRIPTS_GRP, DLSZ_SIZE_Y)
DLGRESIZE_CONTROL(IDC_OUTPUT_GRP, DLSZ_SIZE_X | DLSZ_SIZE_Y)
DLGRESIZE_CONTROL(IDC_EVAL_LBL, DLSZ_MOVE_Y)
DLGRESIZE_CONTROL(IDC_EVAL_EDIT, DLSZ_SIZE_X | DLSZ_MOVE_Y)
DLGRESIZE_CONTROL(IDC_RUN_BTN, DLSZ_MOVE_Y)
DLGRESIZE_CONTROL(IDC_SCRIPTDIR_BTN, DLSZ_MOVE_Y)
DLGRESIZE_CONTROL(IDC_STATUSBAR, DLSZ_SIZE_X | DLSZ_MOVE_Y)
DLGRESIZE_CONTROL(IDC_CONSOLE_EDIT, DLSZ_SIZE_X | DLSZ_SIZE_Y)
DLGRESIZE_CONTROL(IDC_SCRIPT_LIST, DLSZ_SIZE_Y)
DLGRESIZE_CONTROL(IDC_CLEAR_BTN, DLSZ_MOVE_X | DLSZ_MOVE_Y)
DLGRESIZE_CONTROL(IDC_COPY_BTN, DLSZ_MOVE_X | DLSZ_MOVE_Y)
DLGRESIZE_CONTROL(IDC_SCRIPTS_GRP, DLSZ_SIZE_Y)
DLGRESIZE_CONTROL(IDC_OUTPUT_GRP, DLSZ_SIZE_X | DLSZ_SIZE_Y)
DLGRESIZE_CONTROL(IDC_EVAL_LBL, DLSZ_MOVE_Y)
DLGRESIZE_CONTROL(IDC_EVAL_EDIT, DLSZ_SIZE_X | DLSZ_MOVE_Y)
DLGRESIZE_CONTROL(IDC_RUN_BTN, DLSZ_MOVE_Y)
DLGRESIZE_CONTROL(IDC_SCRIPTDIR_BTN, DLSZ_MOVE_Y)
DLGRESIZE_CONTROL(IDC_STATUSBAR, DLSZ_SIZE_X | DLSZ_MOVE_Y)
END_DLGRESIZE_MAP()
BEGIN_TOOLTIP_MAP()
TOOLTIP(IDC_CLEAR_BTN, "Clear console output")
TOOLTIP(IDC_COPY_BTN, "Copy console output to the clipboard")
TOOLTIP(IDC_RUN_BTN, "Toggle selected script")
TOOLTIP(IDC_SCRIPTDIR_BTN, "Open scripts directory in file explorer")
TOOLTIP(IDC_CLEAR_BTN, "Clear console output")
TOOLTIP(IDC_COPY_BTN, "Copy console output to the clipboard")
TOOLTIP(IDC_RUN_BTN, "Toggle selected script")
TOOLTIP(IDC_SCRIPTDIR_BTN, "Open scripts directory in file explorer")
END_TOOLTIP_MAP()
};

View File

@ -137,8 +137,7 @@ LRESULT CScriptsAutorunDlg::OnRefreshScriptList(UINT /*uMsg*/, WPARAM /*wParam*/
do
{
stdstr fileName = searchPath.GetNameExtension();
if (searchPath.GetExtension() == "js" &&
m_ScriptSystem->AutorunList().count(fileName) == 0)
if (searchPath.GetExtension() == "js" && m_ScriptSystem->AutorunList().count(fileName) == 0)
{
fileNames.push_back(searchPath.GetNameExtension());
}

View File

@ -5,36 +5,41 @@ class CScriptsAutorunDlg :
public CDialogImpl<CScriptsAutorunDlg>
{
public:
enum { IDD = IDD_Debugger_ScriptsAutorun };
enum
{
IDD = IDD_Debugger_ScriptsAutorun
};
CScriptsAutorunDlg();
virtual ~CScriptsAutorunDlg();
INT_PTR DoModal(CDebuggerUI* debugger, stdstr selectedScriptName);
INT_PTR DoModal(CDebuggerUI * debugger, stdstr selectedScriptName);
LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & /*bHandled*/);
LRESULT OnDestroy(void);
LRESULT OnOKCancel(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnAdd(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnRemove(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
LRESULT OnScriptListDblClicked(NMHDR* pNMHDR);
LRESULT OnAutorunListDblClicked(NMHDR* pNMHDR);
LRESULT OnCtrlSetFocus(NMHDR* pNMHDR);
LRESULT OnRefreshScriptList(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnRefreshAutorunList(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnOKCancel(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL & bHandled);
LRESULT OnAdd(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL & bHandled);
LRESULT OnRemove(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL & bHandled);
LRESULT OnScriptListDblClicked(NMHDR * pNMHDR);
LRESULT OnAutorunListDblClicked(NMHDR * pNMHDR);
LRESULT OnCtrlSetFocus(NMHDR * pNMHDR);
LRESULT OnRefreshScriptList(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled);
LRESULT OnRefreshAutorunList(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled);
BEGIN_MSG_MAP_EX(CAddBreakpointDlg)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
MSG_WM_DESTROY(OnDestroy)
COMMAND_HANDLER(IDOK, BN_CLICKED, OnOKCancel)
COMMAND_HANDLER(IDCANCEL, BN_CLICKED, OnOKCancel)
COMMAND_HANDLER(IDC_ADD_BTN, BN_CLICKED, OnAdd)
COMMAND_HANDLER(IDC_REMOVE_BTN, BN_CLICKED, OnRemove)
NOTIFY_HANDLER_EX(IDC_SCRIPT_LIST, NM_DBLCLK, OnScriptListDblClicked)
NOTIFY_HANDLER_EX(IDC_AUTORUN_LIST, NM_DBLCLK, OnAutorunListDblClicked)
NOTIFY_CODE_HANDLER_EX(NM_SETFOCUS, OnCtrlSetFocus)
MESSAGE_HANDLER(WM_REFRESH_LIST, OnRefreshScriptList)
MESSAGE_HANDLER(WM_REFRESH_AUTORUN_LIST, OnRefreshAutorunList)
{
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog);
MSG_WM_DESTROY(OnDestroy);
COMMAND_HANDLER(IDOK, BN_CLICKED, OnOKCancel);
COMMAND_HANDLER(IDCANCEL, BN_CLICKED, OnOKCancel);
COMMAND_HANDLER(IDC_ADD_BTN, BN_CLICKED, OnAdd);
COMMAND_HANDLER(IDC_REMOVE_BTN, BN_CLICKED, OnRemove);
NOTIFY_HANDLER_EX(IDC_SCRIPT_LIST, NM_DBLCLK, OnScriptListDblClicked);
NOTIFY_HANDLER_EX(IDC_AUTORUN_LIST, NM_DBLCLK, OnAutorunListDblClicked);
NOTIFY_CODE_HANDLER_EX(NM_SETFOCUS, OnCtrlSetFocus);
MESSAGE_HANDLER(WM_REFRESH_LIST, OnRefreshScriptList);
MESSAGE_HANDLER(WM_REFRESH_AUTORUN_LIST, OnRefreshAutorunList);
}
END_MSG_MAP()
private:
@ -43,9 +48,9 @@ private:
WM_REFRESH_LIST = WM_USER + 1,
WM_REFRESH_AUTORUN_LIST = WM_USER + 2
};
CDebuggerUI* m_Debugger;
CScriptSystem* m_ScriptSystem;
CDebuggerUI * m_Debugger;
CScriptSystem * m_ScriptSystem;
stdstr m_InitSelectedScriptName;
//std::set<std::string> m_AutorunSet;
@ -58,7 +63,7 @@ private:
HANDLE m_hQuitScriptDirWatchEvent;
HANDLE m_hScriptDirWatchThread;
static DWORD WINAPI ScriptDirWatchProc(void* ctx);
static DWORD WINAPI ScriptDirWatchProc(void * ctx);
void AddSelected();
void RemoveSelected();

View File

@ -3,7 +3,8 @@
#define STACKTRACE_MAX_ENTRIES 100
typedef struct {
typedef struct
{
uint32_t routineAddress;
uint32_t callingAddress;
} STACKTRACE_ENTRY;
@ -14,7 +15,10 @@ class CDebugStackTrace :
private CDebugSettings
{
public:
enum { IDD = IDD_Debugger_StackTrace };
enum
{
IDD = IDD_Debugger_StackTrace
};
CDebugStackTrace(CDebuggerUI * debugger);
virtual ~CDebugStackTrace(void);
@ -25,7 +29,7 @@ public:
{
if (m_EntriesIndex < STACKTRACE_MAX_ENTRIES)
{
m_Entries[m_EntriesIndex] = { routineAddress, callingAddress };
m_Entries[m_EntriesIndex] = {routineAddress, callingAddress};
m_EntriesIndex++;
}
}
@ -44,30 +48,31 @@ public:
}
private:
STACKTRACE_ENTRY m_Entries[STACKTRACE_MAX_ENTRIES];
int m_EntriesIndex;
CListViewCtrl m_List;
LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
LRESULT OnActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
LRESULT OnListDblClicked(NMHDR* pNMHDR);
LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & /*bHandled*/);
LRESULT OnActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled);
LRESULT OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL & /*bHandled*/);
LRESULT OnListDblClicked(NMHDR * pNMHDR);
LRESULT OnDestroy(void);
void OnExitSizeMove(void);
BEGIN_MSG_MAP_EX(CDebugStackTrace)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
MSG_WM_DESTROY(OnDestroy)
MESSAGE_HANDLER(WM_ACTIVATE, OnActivate)
COMMAND_CODE_HANDLER(BN_CLICKED, OnClicked)
NOTIFY_HANDLER_EX(IDC_STACKTRACE_LIST, NM_DBLCLK, OnListDblClicked)
CHAIN_MSG_MAP(CDialogResize<CDebugStackTrace>)
MSG_WM_EXITSIZEMOVE(OnExitSizeMove)
END_MSG_MAP()
{
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog);
MSG_WM_DESTROY(OnDestroy);
MESSAGE_HANDLER(WM_ACTIVATE, OnActivate);
COMMAND_CODE_HANDLER(BN_CLICKED, OnClicked);
NOTIFY_HANDLER_EX(IDC_STACKTRACE_LIST, NM_DBLCLK, OnListDblClicked);
CHAIN_MSG_MAP(CDialogResize<CDebugStackTrace>);
MSG_WM_EXITSIZEMOVE(OnExitSizeMove);
}
END_MSG_MAP()
BEGIN_DLGRESIZE_MAP(CDebugStackTrace)
DLGRESIZE_CONTROL(IDC_STACKTRACE_LIST, DLSZ_SIZE_X | DLSZ_SIZE_Y)
DLGRESIZE_CONTROL(IDC_STACKTRACE_LIST, DLSZ_SIZE_X | DLSZ_SIZE_Y)
END_DLGRESIZE_MAP()
};

View File

@ -5,7 +5,10 @@ class CDebugStackView :
public CDialogResize<CDebugStackView>
{
public:
enum { IDD = IDD_Debugger_Stack };
enum
{
IDD = IDD_Debugger_Stack
};
CDebugStackView(CDebuggerUI * debugger);
virtual ~CDebugStackView(void);
@ -16,20 +19,22 @@ private:
CListViewCtrl m_StackList;
CStatic m_SPStatic;
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled);
LRESULT OnDestroy(void);
LRESULT OnClicked(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnClicked(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL & bHandled);
void OnExitSizeMove(void);
BEGIN_MSG_MAP_EX(CDebugStackView)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
MSG_WM_DESTROY(OnDestroy)
COMMAND_CODE_HANDLER(BN_CLICKED, OnClicked)
CHAIN_MSG_MAP(CDialogResize<CDebugStackView>)
{
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog);
MSG_WM_DESTROY(OnDestroy);
COMMAND_CODE_HANDLER(BN_CLICKED, OnClicked);
CHAIN_MSG_MAP(CDialogResize<CDebugStackView>);
MSG_WM_EXITSIZEMOVE(OnExitSizeMove);
END_MSG_MAP()
}
END_MSG_MAP()
BEGIN_DLGRESIZE_MAP(CDebugStackView)
DLGRESIZE_CONTROL(IDC_STACK_LIST, DLSZ_SIZE_X | DLSZ_SIZE_Y)
DLGRESIZE_CONTROL(IDC_STACK_LIST, DLSZ_SIZE_X | DLSZ_SIZE_Y)
END_DLGRESIZE_MAP()
};

View File

@ -23,7 +23,7 @@ const CSetValueDlg::ComboItem CDebugSymbols::ModalChangeTypeItems[] = {
{"v2", SYM_VECTOR2},
{"v3", SYM_VECTOR3},
{"v4", SYM_VECTOR4},
{ nullptr, 0 }
{nullptr, 0},
};
CDebugSymbols::CDebugSymbols(CDebuggerUI * debugger) :
@ -396,8 +396,7 @@ void CDebugSymbols::UpdateFilteredSymbols()
std::wstring strName = stdstr(symbol.m_Name).ToUTF16();
std::wstring strDesc = stdstr(symbol.m_Description).ToUTF16();
if (strName.find(m_FilterText) != std::wstring::npos ||
strDesc.find(m_FilterText) != std::wstring::npos)
if (strName.find(m_FilterText) != std::wstring::npos || strDesc.find(m_FilterText) != std::wstring::npos)
{
SymbolCacheItem item(symbol, m_SymbolTable);
m_FilteredSymbols.push_back(item);

View File

@ -8,7 +8,8 @@ class CDebugSymbols :
public CDialogResize<CDebugSymbols>
{
private:
enum {
enum
{
SymbolsListView_Col_Address,
SymbolsListView_Col_Type,
SymbolsListView_Col_Name,
@ -17,15 +18,16 @@ private:
SymbolsListView_Num_Columns
};
struct SymbolCacheItem {
int m_Id;
struct SymbolCacheItem
{
int m_Id;
wchar_t m_Address[16];
wchar_t m_Type[16];
wchar_t m_Name[48];
wchar_t m_Value[64];
wchar_t m_Description[256];
SymbolCacheItem(CSymbol& symbol, CSymbolTable* symbolTable)
SymbolCacheItem(CSymbol & symbol, CSymbolTable * symbolTable)
{
char szValue[64];
symbolTable->GetValueString(szValue, &symbol);
@ -46,9 +48,9 @@ private:
static const CSetValueDlg::ComboItem ModalChangeTypeItems[];
CSymbolTable* m_SymbolTable;
CSymbolTable * m_SymbolTable;
CListViewCtrl m_SymbolsListView;
CSetValueDlg m_SetValueDlg;
CSetValueDlg m_SetValueDlg;
CAddSymbolDlg m_AddSymbolDlg;
size_t m_SymbolCacheStartIndex;
@ -59,45 +61,53 @@ private:
std::vector<SymbolCacheItem> m_FilteredSymbols;
public:
enum { IDD = IDD_Debugger_Symbols };
enum { TIMER_ID_AUTO_REFRESH };
enum
{
IDD = IDD_Debugger_Symbols
};
enum
{
TIMER_ID_AUTO_REFRESH
};
CDebugSymbols(CDebuggerUI * debugger);
//virtual ~CDebugSymbols(void);
void Refresh();
void UpdateFilteredSymbols();
int GetListItemSymbolId(int nItem);
int ColumnHitTest(POINT& pt);
int GetListItemSymbolId(int nItem);
int ColumnHitTest(POINT & pt);
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
LRESULT OnFilterChanged(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
LRESULT OnListDblClicked(NMHDR* pNMHDR);
LRESULT OnListGetDispInfo(NMHDR* pNMHDR);
LRESULT OnListCacheHint(NMHDR* pNMHDR);
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled);
LRESULT OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL & /*bHandled*/);
LRESULT OnFilterChanged(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL & /*bHandled*/);
LRESULT OnListDblClicked(NMHDR * pNMHDR);
LRESULT OnListGetDispInfo(NMHDR * pNMHDR);
LRESULT OnListCacheHint(NMHDR * pNMHDR);
LRESULT OnDestroy(void);
void OnExitSizeMove(void);
void OnTimer(UINT_PTR nIDEvent);
BEGIN_MSG_MAP_EX(CDebugSymbols)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
COMMAND_CODE_HANDLER(BN_CLICKED, OnClicked)
COMMAND_HANDLER(IDC_FILTER_EDIT, EN_CHANGE, OnFilterChanged)
NOTIFY_HANDLER_EX(IDC_SYMBOLS_LIST, NM_DBLCLK, OnListDblClicked)
NOTIFY_HANDLER_EX(IDC_SYMBOLS_LIST, LVN_GETDISPINFO, OnListGetDispInfo)
NOTIFY_HANDLER_EX(IDC_SYMBOLS_LIST, LVN_ODCACHEHINT, OnListCacheHint)
MSG_WM_TIMER(OnTimer)
MSG_WM_EXITSIZEMOVE(OnExitSizeMove)
MSG_WM_DESTROY(OnDestroy)
CHAIN_MSG_MAP(CDialogResize<CDebugSymbols>)
{
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog);
COMMAND_CODE_HANDLER(BN_CLICKED, OnClicked);
COMMAND_HANDLER(IDC_FILTER_EDIT, EN_CHANGE, OnFilterChanged);
NOTIFY_HANDLER_EX(IDC_SYMBOLS_LIST, NM_DBLCLK, OnListDblClicked);
NOTIFY_HANDLER_EX(IDC_SYMBOLS_LIST, LVN_GETDISPINFO, OnListGetDispInfo);
NOTIFY_HANDLER_EX(IDC_SYMBOLS_LIST, LVN_ODCACHEHINT, OnListCacheHint);
MSG_WM_TIMER(OnTimer);
MSG_WM_EXITSIZEMOVE(OnExitSizeMove);
MSG_WM_DESTROY(OnDestroy);
CHAIN_MSG_MAP(CDialogResize<CDebugSymbols>);
}
END_MSG_MAP()
BEGIN_DLGRESIZE_MAP(CDebugSymbols)
DLGRESIZE_CONTROL(IDC_FILTER_EDIT, DLSZ_MOVE_Y)
DLGRESIZE_CONTROL(IDC_FILTER_STATIC, DLSZ_MOVE_Y)
DLGRESIZE_CONTROL(IDC_REMOVESYMBOL_BTN, DLSZ_MOVE_X | DLSZ_MOVE_Y)
DLGRESIZE_CONTROL(IDC_ADDSYMBOL_BTN, DLSZ_MOVE_X | DLSZ_MOVE_Y)
DLGRESIZE_CONTROL(IDC_SYMBOLS_LIST, DLSZ_SIZE_X | DLSZ_SIZE_Y)
DLGRESIZE_CONTROL(IDC_FILTER_EDIT, DLSZ_MOVE_Y)
DLGRESIZE_CONTROL(IDC_FILTER_STATIC, DLSZ_MOVE_Y)
DLGRESIZE_CONTROL(IDC_REMOVESYMBOL_BTN, DLSZ_MOVE_X | DLSZ_MOVE_Y)
DLGRESIZE_CONTROL(IDC_ADDSYMBOL_BTN, DLSZ_MOVE_X | DLSZ_MOVE_Y)
DLGRESIZE_CONTROL(IDC_SYMBOLS_LIST, DLSZ_SIZE_X | DLSZ_SIZE_Y)
END_DLGRESIZE_MAP()
};

View File

@ -1,20 +1,25 @@
#pragma once
class CDebugTlb :
public CDebugDialog < CDebugTlb >
public CDebugDialog<CDebugTlb>
{
BEGIN_MSG_MAP_EX(CDebugTlb)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
COMMAND_CODE_HANDLER(BN_CLICKED, OnClicked)
MSG_WM_EXITSIZEMOVE(OnExitSizeMove)
{
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog);
COMMAND_CODE_HANDLER(BN_CLICKED, OnClicked);
MSG_WM_EXITSIZEMOVE(OnExitSizeMove);
}
END_MSG_MAP()
LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
LRESULT OnClicked(WORD wNotifyCode, WORD wID, HWND /*hWndCtl*/, BOOL& bHandled);
LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & /*bHandled*/);
LRESULT OnClicked(WORD wNotifyCode, WORD wID, HWND /*hWndCtl*/, BOOL & bHandled);
void OnExitSizeMove(void);
public:
enum { IDD = IDD_Debugger_TLB };
enum
{
IDD = IDD_Debugger_TLB
};
CDebugTlb(CDebuggerUI * debugger);
virtual ~CDebugTlb(void);

View File

@ -28,7 +28,7 @@ CDebugMemoryView::jump_item_t CDebugMemoryView::JumpItems[] = {
{0xB0000000, 0x10000000, 0xFC00000, "Cartridge ROM"},
{0xBFC00000, 0x1FC00000, 0x00007C0, "PIF ROM"},
{0xBFC007C0, 0x1FC007C0, 0x0000040, "PIF RAM"},
{ 0, NULL}
{0, NULL},
};
CDebugMemoryView::CDebugMemoryView(CDebuggerUI * debugger) :
@ -117,9 +117,7 @@ void CDebugMemoryView::CopyBytesToClipboard(uint32_t startAddress, uint32_t endA
if (bIncludeAddresses)
{
if ((bRowAddresses && offsetFromBase % rowSize == 0) ||
(!bRowAddresses && offsetFromBase % groupSize == 0) ||
(offsetFromSelStart == 0))
if ((bRowAddresses && offsetFromBase % rowSize == 0) || (!bRowAddresses && offsetFromBase % groupSize == 0) || (offsetFromSelStart == 0))
{
str += stdstr_f("%08X: ", address);
}
@ -341,7 +339,7 @@ LRESULT CDebugMemoryView::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM
(int)(MEMSB_BLOCK_W * dpiScale),
(int)(MEMSB_BLOCKLEN_W * dpiScale),
(int)(MEMSB_DMAINFO_W * dpiScale),
(int)(MEMSB_SAFEMODE_W * dpiScale)
(int)(MEMSB_SAFEMODE_W * dpiScale),
};
m_StatusBar.SetParts(MEMSB_NUM_PANES, statusPaneWidths);
@ -371,7 +369,7 @@ LRESULT CDebugMemoryView::OnDestroy(void)
return 0;
}
LRESULT CDebugMemoryView::OnShowAddress(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/)
LRESULT CDebugMemoryView::OnShowAddress(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL & /*bHandled*/)
{
uint32_t address = (uint32_t)wParam;
bool bVirtual = (lParam != 0);
@ -385,7 +383,7 @@ void CDebugMemoryView::OnExitSizeMove()
SaveWindowPos(true);
}
LRESULT CDebugMemoryView::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND, BOOL& /*bHandled*/)
LRESULT CDebugMemoryView::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND, BOOL & /*bHandled*/)
{
switch (wID)
{
@ -432,26 +430,26 @@ LRESULT CDebugMemoryView::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND, BOOL&
m_HexEditCtrl.Copy();
break;
case ID_POPUPMENU_COPYGAMESHARKCODE:
{
{
uint32_t startAddress, endAddress;
m_HexEditCtrl.GetSelectionRange(&startAddress, &endAddress);
CopyGameSharkCodeToClipboard(startAddress, endAddress);
}
break;
}
case ID_POPUPMENU_COPYDATAWITHGROUPADDRESSES:
{
{
uint32_t startAddress, endAddress;
m_HexEditCtrl.GetSelectionRange(&startAddress, &endAddress);
CopyBytesToClipboard(startAddress, endAddress, m_HexEditCtrl.GetFocusedColumn() == HX_COL_HEXDATA, true, false);
}
break;
}
case ID_POPUPMENU_COPYDATAWITHROWADDRESSES:
{
{
uint32_t startAddress, endAddress;
m_HexEditCtrl.GetSelectionRange(&startAddress, &endAddress);
CopyBytesToClipboard(startAddress, endAddress, m_HexEditCtrl.GetFocusedColumn() == HX_COL_HEXDATA, true, true);
}
break;
}
case ID_POPUPMENU_PASTE:
m_HexEditCtrl.Paste();
break;
@ -590,16 +588,16 @@ LRESULT CDebugMemoryView::OnHxCtrlKeyPressed(LPNMHDR lpNMHDR)
FollowPointer(false);
break;
case VK_TAB:
{
int curSel = m_TabCtrl.GetCurSel();
if (m_TabCtrl.SetCurSel(curSel + 1) == -1)
{
int curSel = m_TabCtrl.GetCurSel();
if (m_TabCtrl.SetCurSel(curSel + 1) == -1)
{
m_TabCtrl.SetCurSel(0);
}
TabSelChanged();
m_TabCtrl.SetCurSel(0);
}
TabSelChanged();
break;
}
}
return FALSE;
}

View File

@ -1,13 +1,13 @@
#pragma once
#include "Debugger-AddSymbol.h"
#include <UserInterface/WTLControls/HexEditCtrl.h>
#include <Project64/UserInterface/WTLControls/TooltipDialog.h>
#include <UserInterface/WTLControls/HexEditCtrl.h>
typedef struct
{
NMHDR nmh;
int nItem;
int nItem;
} NMMTRCLICK;
enum
@ -35,13 +35,13 @@ public:
private:
void OnLButtonDblClk(UINT /*nFlags*/, CPoint /*point*/)
{
NMHDR nmh = { m_hWnd, (UINT_PTR)::GetDlgCtrlID(m_hWnd), NM_DBLCLK };
NMHDR nmh = {m_hWnd, (UINT_PTR)::GetDlgCtrlID(m_hWnd), NM_DBLCLK};
::SendMessage(::GetParent(m_hWnd), WM_NOTIFY, NM_DBLCLK, (LPARAM)&nmh);
}
void OnRButtonDown(UINT /*nFlags*/, CPoint point)
{
TCHITTESTINFO ht = { point, 0};
TCHITTESTINFO ht = {point, 0};
int nItem = ::SendMessage(m_hWnd, TCM_HITTEST, 0, (LPARAM)&ht);
if (nItem != -1)
{
@ -51,21 +51,23 @@ private:
void OnRButtonUp(UINT /*nFlags*/, CPoint point)
{
TCHITTESTINFO ht = { point, 0 };
TCHITTESTINFO ht = {point, 0};
int nItem = ::SendMessage(m_hWnd, TCM_HITTEST, 0, (LPARAM)&ht);
if (nItem != -1 && nItem == m_nItemRClick)
{
NMMTRCLICK nmrc = { { m_hWnd, (UINT_PTR)::GetDlgCtrlID(m_hWnd), MTCN_RCLICK }, nItem };
NMMTRCLICK nmrc = {{m_hWnd, (UINT_PTR)::GetDlgCtrlID(m_hWnd), MTCN_RCLICK}, nItem};
::SendMessage(::GetParent(m_hWnd), WM_NOTIFY, MTCN_RCLICK, (LPARAM)&nmrc);
}
m_nItemRClick = -1;
}
BEGIN_MSG_MAP_EX(CMemTabCtrl)
MSG_WM_LBUTTONDBLCLK(OnLButtonDblClk)
MSG_WM_RBUTTONDOWN(OnRButtonDown)
MSG_WM_RBUTTONUP(OnRButtonUp)
MSG_WM_RBUTTONDBLCLK(OnRButtonDown)
{
MSG_WM_LBUTTONDBLCLK(OnLButtonDblClk);
MSG_WM_RBUTTONDOWN(OnRButtonDown);
MSG_WM_RBUTTONUP(OnRButtonUp);
MSG_WM_RBUTTONDBLCLK(OnRButtonDown);
}
END_MSG_MAP()
};
@ -75,7 +77,10 @@ class CDebugMemoryView :
public CToolTipDialog<CDebugMemoryView>
{
public:
enum { IDD = IDD_Debugger_Memory };
enum
{
IDD = IDD_Debugger_Memory
};
CDebugMemoryView(CDebuggerUI * debugger);
virtual ~CDebugMemoryView(void);
@ -120,11 +125,11 @@ private:
enum
{
MEMSB_HOTADDR_W = 160,
MEMSB_BLOCK_W = 120 + MEMSB_HOTADDR_W,
MEMSB_BLOCKLEN_W = 60 + MEMSB_BLOCK_W,
MEMSB_DMAINFO_W = 60 + MEMSB_BLOCKLEN_W,
MEMSB_SAFEMODE_W = -1
MEMSB_HOTADDR_W = 160,
MEMSB_BLOCK_W = 120 + MEMSB_HOTADDR_W,
MEMSB_BLOCKLEN_W = 60 + MEMSB_BLOCK_W,
MEMSB_DMAINFO_W = 60 + MEMSB_BLOCKLEN_W,
MEMSB_SAFEMODE_W = -1
};
enum edit_type_t
@ -138,7 +143,7 @@ private:
edit_type_t type;
uint32_t startAddress;
uint32_t endAddress;
uint8_t value;
uint8_t value;
//uint8_t* data;
} edit_t;
@ -147,133 +152,135 @@ private:
uint32_t vaddr;
uint32_t paddr;
uint32_t size;
const char* caption;
const char * caption;
} jump_item_t;
typedef struct
{
uint32_t address;
bool bVirtual;
int numBytesPerGroup;
bool bVirtual;
int numBytesPerGroup;
} tab_info_t;
static jump_item_t JumpItems[];
static int GetJumpItemIndex(uint32_t address, bool bVirtual);
CHexEditCtrl m_HexEditCtrl;
CEditNumber32 m_MemAddr;
CAddSymbolDlg m_AddSymbolDlg;
CButton m_VirtualCheckbox;
CMemTabCtrl m_TabCtrl;
CHexEditCtrl m_HexEditCtrl;
CEditNumber32 m_MemAddr;
CAddSymbolDlg m_AddSymbolDlg;
CButton m_VirtualCheckbox;
CMemTabCtrl m_TabCtrl;
CStatusBarCtrl m_StatusBar;
CComboBox m_CmbJump;
CComboBox m_CmbJump;
std::vector<tab_info_t> m_TabData;
CBreakpoints* m_Breakpoints;
CBreakpoints * m_Breakpoints;
int m_WriteTargetColorStride;
int m_ReadTargetColorStride;
int m_SymbolColorStride;
int m_SymbolColorPhase;
uint32_t m_ContextMenuAddress;
uint32_t m_HotAddress;
bool m_bIgnoreAddressInput;
bool m_bVirtualMemory;
int m_WriteTargetColorStride;
int m_ReadTargetColorStride;
int m_SymbolColorStride;
int m_SymbolColorPhase;
uint32_t m_ContextMenuAddress;
uint32_t m_HotAddress;
bool m_bIgnoreAddressInput;
bool m_bVirtualMemory;
bool m_bSafeEditMode;
bool m_bSafeEditMode;
std::vector<edit_t> m_SafeEditQueue;
bool GetByte(uint32_t address, uint8_t* value);
bool SetByte(uint32_t address, uint8_t value);
void SetupJumpMenu(bool bVirtual);
bool GetSafeEditValue(uint32_t address, uint8_t* value);
void ApplySafeEdits(void);
void CopyTextToClipboard(const char* text);
void CopyBytesToClipboard(uint32_t startAddress, uint32_t endAddress, bool bHex, bool bIncludeAddresses = false, bool bRowAddresses = false);
void CopyGameSharkCodeToClipboard(uint32_t startAddress, uint32_t endAddress);
void FillRange(uint32_t startAddress, uint32_t endAddress, uint8_t value);
void FollowPointer(bool bContextMenuAddress = true);
void JumpToSelection(void);
int AddTab(uint32_t address, bool bVirtual, int numBytesPerGroup);
int InsertTab(int nItem, uint32_t address, bool bVirtual, int numBytesPerGroup);
void DeleteTab(int index);
void UpdateCurrentTab(uint32_t address);
void OpenNewTab(uint32_t address, bool bVirtual, int numBytesPerGroup, bool bInsert = false, bool bOpenExisting = false);
void OpenDuplicateTab(void);
void CloseTab(int nItem);
void CloseCurrentTab(void);
void TabSelChanged(void);
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnShowAddress(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnClicked(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
void OnAddrChanged(UINT Code, int id, HWND ctl);
void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar pScrollBar);
void OnExitSizeMove(void);
LRESULT OnDestroy(void);
LRESULT OnHxGetByteInfo(LPNMHDR lpNMHDR);
LRESULT OnHxSetNibble(LPNMHDR lpNMHDR);
LRESULT OnHxSetByte(LPNMHDR lpNMHDR);
LRESULT OnHxRightClick(LPNMHDR lpNMHDR);
LRESULT OnHxEnterPressed(LPNMHDR lpNMHDR);
LRESULT OnHxRedrawStarted(LPNMHDR lpNMHDR);
LRESULT OnHxBaseAddrChanged(LPNMHDR lpNMHDR);
LRESULT OnHxHotAddrChanged(LPNMHDR lpNMHDR);
LRESULT OnHxCopy(LPNMHDR lpNMHDR);
LRESULT OnHxPaste(LPNMHDR lpNMHDR);
LRESULT OnHxCtrlKeyPressed(LPNMHDR lpNMHDR);
LRESULT OnHxFillRange(LPNMHDR lpNMHDR);
LRESULT OnHxInsertModeChanged(LPNMHDR lpNMHDR);
LRESULT OnHxSelectionChanged(LPNMHDR lpNMHDR);
LRESULT OnHxGroupSizeChanged(LPNMHDR lpNMHDR);
LRESULT OnTabSelChange(LPNMHDR lpNMHDR);
LRESULT OnTabDblClick(LPNMHDR lpNMHDR);
LRESULT OnTabRClick(LPNMHDR lpNMHDR);
LRESULT OnStatusBarClick(LPNMHDR lpNMHDR);
void OnJumpComboSelChange(UINT uNotifyCode, int nID, CWindow wndCtl);
bool GetByte(uint32_t address, uint8_t * value);
bool SetByte(uint32_t address, uint8_t value);
void SetupJumpMenu(bool bVirtual);
bool GetSafeEditValue(uint32_t address, uint8_t * value);
void ApplySafeEdits(void);
void CopyTextToClipboard(const char * text);
void CopyBytesToClipboard(uint32_t startAddress, uint32_t endAddress, bool bHex, bool bIncludeAddresses = false, bool bRowAddresses = false);
void CopyGameSharkCodeToClipboard(uint32_t startAddress, uint32_t endAddress);
void FillRange(uint32_t startAddress, uint32_t endAddress, uint8_t value);
void FollowPointer(bool bContextMenuAddress = true);
void JumpToSelection(void);
int AddTab(uint32_t address, bool bVirtual, int numBytesPerGroup);
int InsertTab(int nItem, uint32_t address, bool bVirtual, int numBytesPerGroup);
void DeleteTab(int index);
void UpdateCurrentTab(uint32_t address);
void OpenNewTab(uint32_t address, bool bVirtual, int numBytesPerGroup, bool bInsert = false, bool bOpenExisting = false);
void OpenDuplicateTab(void);
void CloseTab(int nItem);
void CloseCurrentTab(void);
void TabSelChanged(void);
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled);
LRESULT OnShowAddress(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled);
LRESULT OnClicked(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL & bHandled);
void OnAddrChanged(UINT Code, int id, HWND ctl);
void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar pScrollBar);
void OnExitSizeMove(void);
LRESULT OnDestroy(void);
LRESULT OnHxGetByteInfo(LPNMHDR lpNMHDR);
LRESULT OnHxSetNibble(LPNMHDR lpNMHDR);
LRESULT OnHxSetByte(LPNMHDR lpNMHDR);
LRESULT OnHxRightClick(LPNMHDR lpNMHDR);
LRESULT OnHxEnterPressed(LPNMHDR lpNMHDR);
LRESULT OnHxRedrawStarted(LPNMHDR lpNMHDR);
LRESULT OnHxBaseAddrChanged(LPNMHDR lpNMHDR);
LRESULT OnHxHotAddrChanged(LPNMHDR lpNMHDR);
LRESULT OnHxCopy(LPNMHDR lpNMHDR);
LRESULT OnHxPaste(LPNMHDR lpNMHDR);
LRESULT OnHxCtrlKeyPressed(LPNMHDR lpNMHDR);
LRESULT OnHxFillRange(LPNMHDR lpNMHDR);
LRESULT OnHxInsertModeChanged(LPNMHDR lpNMHDR);
LRESULT OnHxSelectionChanged(LPNMHDR lpNMHDR);
LRESULT OnHxGroupSizeChanged(LPNMHDR lpNMHDR);
LRESULT OnTabSelChange(LPNMHDR lpNMHDR);
LRESULT OnTabDblClick(LPNMHDR lpNMHDR);
LRESULT OnTabRClick(LPNMHDR lpNMHDR);
LRESULT OnStatusBarClick(LPNMHDR lpNMHDR);
void OnJumpComboSelChange(UINT uNotifyCode, int nID, CWindow wndCtl);
BEGIN_MSG_MAP_EX(CDebugMemoryView)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
MESSAGE_HANDLER(WM_SHOWADDRESS, OnShowAddress)
COMMAND_CODE_HANDLER(BN_CLICKED, OnClicked)
COMMAND_HANDLER_EX(IDC_ADDR_EDIT, EN_CHANGE, OnAddrChanged)
MSG_WM_EXITSIZEMOVE(OnExitSizeMove)
MSG_WM_DESTROY(OnDestroy)
MSG_WM_VSCROLL(OnVScroll)
COMMAND_HANDLER_EX(IDC_CMB_JUMP, CBN_SELCHANGE, OnJumpComboSelChange)
NOTIFY_HANDLER_EX(IDC_STATUSBAR, NM_CLICK, OnStatusBarClick)
NOTIFY_HANDLER_EX(IDC_MEMTABS, NM_DBLCLK, OnTabDblClick)
NOTIFY_HANDLER_EX(IDC_MEMTABS, TCN_SELCHANGE, OnTabSelChange)
NOTIFY_HANDLER_EX(IDC_MEMTABS, MTCN_RCLICK, OnTabRClick)
NOTIFY_HANDLER_EX(IDC_HEXEDIT, HXN_GETBYTEINFO, OnHxGetByteInfo)
NOTIFY_HANDLER_EX(IDC_HEXEDIT, HXN_SETNIBBLE, OnHxSetNibble)
NOTIFY_HANDLER_EX(IDC_HEXEDIT, HXN_SETBYTE, OnHxSetByte)
NOTIFY_HANDLER_EX(IDC_HEXEDIT, HXN_RCLICK, OnHxRightClick)
NOTIFY_HANDLER_EX(IDC_HEXEDIT, HXN_HOTADDRCHANGED, OnHxHotAddrChanged)
NOTIFY_HANDLER_EX(IDC_HEXEDIT, HXN_REDRAWSTARTED, OnHxRedrawStarted)
NOTIFY_HANDLER_EX(IDC_HEXEDIT, HXN_BASEADDRCHANGED, OnHxBaseAddrChanged)
NOTIFY_HANDLER_EX(IDC_HEXEDIT, HXN_HOTADDRCHANGED, OnHxHotAddrChanged)
NOTIFY_HANDLER_EX(IDC_HEXEDIT, HXN_PASTE, OnHxPaste)
NOTIFY_HANDLER_EX(IDC_HEXEDIT, HXN_CTRLKEYPRESSED, OnHxCtrlKeyPressed)
NOTIFY_HANDLER_EX(IDC_HEXEDIT, HXN_FILLRANGE, OnHxFillRange)
NOTIFY_HANDLER_EX(IDC_HEXEDIT, HXN_COPY, OnHxCopy)
NOTIFY_HANDLER_EX(IDC_HEXEDIT, HXN_INSERTMODECHANGED, OnHxInsertModeChanged)
NOTIFY_HANDLER_EX(IDC_HEXEDIT, HXN_ENTERPRESSED, OnHxEnterPressed)
NOTIFY_HANDLER_EX(IDC_HEXEDIT, HXN_SELCHANGED, OnHxSelectionChanged)
NOTIFY_HANDLER_EX(IDC_HEXEDIT, HXN_GROUPSIZECHANGED, OnHxGroupSizeChanged)
CHAIN_MSG_MAP(CDialogResize<CDebugMemoryView>)
{
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog);
MESSAGE_HANDLER(WM_SHOWADDRESS, OnShowAddress);
COMMAND_CODE_HANDLER(BN_CLICKED, OnClicked);
COMMAND_HANDLER_EX(IDC_ADDR_EDIT, EN_CHANGE, OnAddrChanged);
MSG_WM_EXITSIZEMOVE(OnExitSizeMove);
MSG_WM_DESTROY(OnDestroy);
MSG_WM_VSCROLL(OnVScroll);
COMMAND_HANDLER_EX(IDC_CMB_JUMP, CBN_SELCHANGE, OnJumpComboSelChange);
NOTIFY_HANDLER_EX(IDC_STATUSBAR, NM_CLICK, OnStatusBarClick);
NOTIFY_HANDLER_EX(IDC_MEMTABS, NM_DBLCLK, OnTabDblClick);
NOTIFY_HANDLER_EX(IDC_MEMTABS, TCN_SELCHANGE, OnTabSelChange);
NOTIFY_HANDLER_EX(IDC_MEMTABS, MTCN_RCLICK, OnTabRClick);
NOTIFY_HANDLER_EX(IDC_HEXEDIT, HXN_GETBYTEINFO, OnHxGetByteInfo);
NOTIFY_HANDLER_EX(IDC_HEXEDIT, HXN_SETNIBBLE, OnHxSetNibble);
NOTIFY_HANDLER_EX(IDC_HEXEDIT, HXN_SETBYTE, OnHxSetByte);
NOTIFY_HANDLER_EX(IDC_HEXEDIT, HXN_RCLICK, OnHxRightClick);
NOTIFY_HANDLER_EX(IDC_HEXEDIT, HXN_HOTADDRCHANGED, OnHxHotAddrChanged);
NOTIFY_HANDLER_EX(IDC_HEXEDIT, HXN_REDRAWSTARTED, OnHxRedrawStarted);
NOTIFY_HANDLER_EX(IDC_HEXEDIT, HXN_BASEADDRCHANGED, OnHxBaseAddrChanged);
NOTIFY_HANDLER_EX(IDC_HEXEDIT, HXN_HOTADDRCHANGED, OnHxHotAddrChanged);
NOTIFY_HANDLER_EX(IDC_HEXEDIT, HXN_PASTE, OnHxPaste);
NOTIFY_HANDLER_EX(IDC_HEXEDIT, HXN_CTRLKEYPRESSED, OnHxCtrlKeyPressed);
NOTIFY_HANDLER_EX(IDC_HEXEDIT, HXN_FILLRANGE, OnHxFillRange);
NOTIFY_HANDLER_EX(IDC_HEXEDIT, HXN_COPY, OnHxCopy);
NOTIFY_HANDLER_EX(IDC_HEXEDIT, HXN_INSERTMODECHANGED, OnHxInsertModeChanged);
NOTIFY_HANDLER_EX(IDC_HEXEDIT, HXN_ENTERPRESSED, OnHxEnterPressed);
NOTIFY_HANDLER_EX(IDC_HEXEDIT, HXN_SELCHANGED, OnHxSelectionChanged);
NOTIFY_HANDLER_EX(IDC_HEXEDIT, HXN_GROUPSIZECHANGED, OnHxGroupSizeChanged);
CHAIN_MSG_MAP(CDialogResize<CDebugMemoryView>);
}
END_MSG_MAP()
BEGIN_DLGRESIZE_MAP(CDebugMemoryView)
DLGRESIZE_CONTROL(IDC_CMB_JUMP, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_STATUSBAR, DLSZ_SIZE_X | DLSZ_MOVE_Y)
DLGRESIZE_CONTROL(IDC_HEXEDIT, DLSZ_SIZE_X | DLSZ_SIZE_Y)
DLGRESIZE_CONTROL(IDC_MEMTABS, DLSZ_SIZE_X)
DLGRESIZE_CONTROL(IDC_SCRL_BAR, DLSZ_MOVE_X | DLSZ_SIZE_Y)
DLGRESIZE_CONTROL(IDC_CMB_JUMP, DLSZ_MOVE_X)
DLGRESIZE_CONTROL(IDC_STATUSBAR, DLSZ_SIZE_X | DLSZ_MOVE_Y)
DLGRESIZE_CONTROL(IDC_HEXEDIT, DLSZ_SIZE_X | DLSZ_SIZE_Y)
DLGRESIZE_CONTROL(IDC_MEMTABS, DLSZ_SIZE_X)
DLGRESIZE_CONTROL(IDC_SCRL_BAR, DLSZ_MOVE_X | DLSZ_SIZE_Y)
END_DLGRESIZE_MAP()
BEGIN_TOOLTIP_MAP()
TOOLTIP(IDC_SYMBOLS_BTN, "Symbols...")
TOOLTIP(IDC_CHK_VADDR, "Checked = Use virtual address space (CPU), Unchecked = Use physical address space (RCP)")
TOOLTIP(IDC_SYMBOLS_BTN, "Symbols...")
TOOLTIP(IDC_CHK_VADDR, "Checked = Use virtual address space (CPU), Unchecked = Use physical address space (RCP)")
END_TOOLTIP_MAP()
};

View File

@ -613,13 +613,11 @@ void CDebuggerUI::CPUStepStarted()
m_ScriptSystem->InvokeAppCallbacks(JS_HOOK_CPU_EXEC, (void *)&hookEnv);
}
if (hookEnv.opInfo.IsLoadCommand() &&
m_ScriptSystem->HaveCpuReadCallbacks(hookEnv.opInfo.GetLoadStoreAddress()))
if (hookEnv.opInfo.IsLoadCommand() && m_ScriptSystem->HaveCpuReadCallbacks(hookEnv.opInfo.GetLoadStoreAddress()))
{
m_ScriptSystem->InvokeAppCallbacks(JS_HOOK_CPU_READ, (void *)&hookEnv);
}
else if (hookEnv.opInfo.IsStoreCommand() &&
m_ScriptSystem->HaveCpuWriteCallbacks(hookEnv.opInfo.GetLoadStoreAddress()))
else if (hookEnv.opInfo.IsStoreCommand() && m_ScriptSystem->HaveCpuWriteCallbacks(hookEnv.opInfo.GetLoadStoreAddress()))
{
m_ScriptSystem->InvokeAppCallbacks(JS_HOOK_CPU_WRITE, (void *)&hookEnv);
}
@ -629,8 +627,7 @@ void CDebuggerUI::CPUStepStarted()
{
uint32_t pc = g_Reg->m_PROGRAM_COUNTER;
if (pc == 0x80000000 || pc == 0x80000080 ||
pc == 0xA0000100 || pc == 0x80000180)
if (pc == 0x80000000 || pc == 0x80000080 || pc == 0xA0000100 || pc == 0x80000180)
{
if ((g_Reg->STATUS_REGISTER >> 1) & 3) // If EXL/ERL bits are set
{
@ -659,17 +656,13 @@ void CDebuggerUI::CPUStepStarted()
int nReg1 = 0, nReg2 = 0;
opInfo.ReadsGPR(&nReg1, &nReg2);
if ((nReg1 != 0 && m_Breakpoints->HaveGPRReadBP(nReg1)) ||
(nReg2 != 0 && m_Breakpoints->HaveGPRReadBP(nReg2)))
if ((nReg1 != 0 && m_Breakpoints->HaveGPRReadBP(nReg1)) || (nReg2 != 0 && m_Breakpoints->HaveGPRReadBP(nReg2)))
{
g_Settings->SaveBool(Debugger_SteppingOps, true);
}
}
if (m_Breakpoints->HaveHIWriteBP() && opInfo.WritesHI() ||
m_Breakpoints->HaveLOWriteBP() && opInfo.WritesLO() ||
m_Breakpoints->HaveHIReadBP() && opInfo.ReadsHI() ||
m_Breakpoints->HaveLOReadBP() && opInfo.ReadsLO())
if (m_Breakpoints->HaveHIWriteBP() && opInfo.WritesHI() || m_Breakpoints->HaveLOWriteBP() && opInfo.WritesLO() || m_Breakpoints->HaveHIReadBP() && opInfo.ReadsHI() || m_Breakpoints->HaveLOReadBP() && opInfo.ReadsLO())
{
g_Settings->SaveBool(Debugger_SteppingOps, true);
}

View File

@ -1,20 +1,20 @@
#pragma once
#include "../../WTLApp.h"
#include "../../N64System.h"
#include "../../WTLApp.h"
#include "DebugDialog.h"
#include "Debugger-MemorySearch.h"
#include "Debugger-ViewMemory.h"
#include "Debugger-MemoryDump.h"
#include "Debugger-TLB.h"
#include "Debugger-Commands.h"
#include "Debugger-Scripts.h"
#include "Debugger-ScriptsAutorun.h"
#include "Debugger-Symbols.h"
#include "Debugger-AddBreakpoint.h"
#include "Debugger-AddSymbol.h"
#include "Debugger-DMALogView.h"
#include "Debugger-CPULogView.h"
#include "Debugger-StackView.h"
#include "Debugger-StackTrace.h"
#include "Debugger-Commands.h"
#include "Debugger-DMALogView.h"
#include "Debugger-ExceptionBreakpoints.h"
#include "Debugger-MemoryDump.h"
#include "Debugger-MemorySearch.h"
#include "Debugger-Scripts.h"
#include "Debugger-ScriptsAutorun.h"
#include "Debugger-StackTrace.h"
#include "Debugger-StackView.h"
#include "Debugger-Symbols.h"
#include "Debugger-TLB.h"
#include "Debugger-ViewMemory.h"

View File

@ -16,7 +16,7 @@ CMixed::TypeNameEntry CMixed::TypeNames[] = {
{"char", ValueType_string},
{"char", ValueType_unkstring},
{"char", ValueType_unkstring},
{ nullptr, ValueType_invalid}
{nullptr, ValueType_invalid},
};
const char * CMixed::GetTypeName(void)
@ -231,9 +231,7 @@ int CScanResult::GetMemoryValueString(char * buffer, size_t size, bool bIgnoreHe
uint8_t * mem = CMemoryScanner::GetMemoryPool(paddr);
if (m_Type == ValueType_istring ||
m_Type == ValueType_string ||
m_Type == ValueType_unkstring)
if (m_Type == ValueType_istring || m_Type == ValueType_string || m_Type == ValueType_unkstring)
{
if (bHex)
{
@ -407,9 +405,7 @@ bool CScanResult::SetAddressSafe(uint32_t address)
return false;
}
if (!CMemoryScanner::RangeCheck(paddrStart, paddrEnd, 0x00000000, ramSize - 1) &&
!CMemoryScanner::RangeCheck(paddrStart, paddrEnd, 0x10000000, 0x10000000 + romSize - 1) &&
!CMemoryScanner::RangeCheck(paddrStart, paddrEnd, 0x04000000, 0x04001FFF))
if (!CMemoryScanner::RangeCheck(paddrStart, paddrEnd, 0x00000000, ramSize - 1) && !CMemoryScanner::RangeCheck(paddrStart, paddrEnd, 0x10000000, 0x10000000 + romSize - 1) && !CMemoryScanner::RangeCheck(paddrStart, paddrEnd, 0x04000000, 0x04001FFF))
{
return false;
}
@ -432,9 +428,7 @@ bool CScanResult::SetStrLengthSafe(int length)
uint32_t paddrStart = m_Address & 0x1FFFFFFF;
uint32_t paddrEnd = (paddrStart + length) - 1;
if (!CMemoryScanner::RangeCheck(paddrStart, paddrEnd, 0x00000000, ramSize - 1) &&
!CMemoryScanner::RangeCheck(paddrStart, paddrEnd, 0x10000000, 0x10000000 + romSize - 1) &&
!CMemoryScanner::RangeCheck(paddrStart, paddrEnd, 0x04000000, 0x04001FFF))
if (!CMemoryScanner::RangeCheck(paddrStart, paddrEnd, 0x00000000, ramSize - 1) && !CMemoryScanner::RangeCheck(paddrStart, paddrEnd, 0x10000000, 0x10000000 + romSize - 1) && !CMemoryScanner::RangeCheck(paddrStart, paddrEnd, 0x04000000, 0x04001FFF))
{
return false;
}
@ -488,16 +482,12 @@ bool CMemoryScanner::PAddrValid(uint32_t physAddr)
uint32_t ramSize = g_MMU->RdramSize();
uint32_t romSize = g_Rom->GetRomSize();
return (AddrCheck(physAddr, 0x00000000, 0x00000000 + ramSize - 1) ||
AddrCheck(physAddr, 0x10000000, 0x10000000 + romSize - 1) ||
AddrCheck(physAddr, 0x04000000, 0x04001FFF));
return (AddrCheck(physAddr, 0x00000000, 0x00000000 + ramSize - 1) || AddrCheck(physAddr, 0x10000000, 0x10000000 + romSize - 1) || AddrCheck(physAddr, 0x04000000, 0x04001FFF));
}
bool CMemoryScanner::PAddrRangeValid(uint32_t physAddrStart, uint32_t physAddrEnd)
{
return (RangeCheck(physAddrStart, physAddrEnd, 0x00000000, g_MMU->RdramSize()) ||
RangeCheck(physAddrStart, physAddrEnd, 0x04000000, 0x04001FFF) ||
RangeCheck(physAddrStart, physAddrEnd, 0x10000000, 0x15FFFFFF));
return (RangeCheck(physAddrStart, physAddrEnd, 0x00000000, g_MMU->RdramSize()) || RangeCheck(physAddrStart, physAddrEnd, 0x04000000, 0x04001FFF) || RangeCheck(physAddrStart, physAddrEnd, 0x10000000, 0x15FFFFFF));
}
void CMemoryScanner::SetAddressType(AddressType addressType)
@ -587,8 +577,7 @@ uint8_t * CMemoryScanner::GetMemoryPool(uint32_t physAddr)
return nullptr;
}
if ((physAddr >= 0x00000000 && physAddr < g_MMU->RdramSize()) ||
(physAddr >= 0x04000000 && physAddr <= 0x04001FFF))
if ((physAddr >= 0x00000000 && physAddr < g_MMU->RdramSize()) || (physAddr >= 0x04000000 && physAddr <= 0x04001FFF))
{
return g_MMU->Rdram();
}

View File

@ -49,18 +49,19 @@ enum DisplayFormat
DisplayHex
};
typedef union {
uint8_t _uint8;
int8_t _sint8;
uint16_t _uint16;
int16_t _sint16;
uint32_t _uint32;
int32_t _sint32;
uint64_t _uint64;
int64_t _sint64;
float _float;
double _double;
const wchar_t* _string;
typedef union
{
uint8_t _uint8;
int8_t _sint8;
uint16_t _uint16;
int16_t _sint16;
uint32_t _uint32;
int32_t _sint32;
uint64_t _uint64;
int64_t _sint64;
float _float;
double _double;
const wchar_t * _string;
} MixedValue;
class CMixed
@ -79,47 +80,136 @@ public:
m_Type = ValueType_uint64;
}
inline void SetType(ValueType t) { m_Type = t; }
inline ValueType GetType(void) { return m_Type; }
inline void SetType(ValueType t)
{
m_Type = t;
}
inline ValueType GetType(void)
{
return m_Type;
}
inline void SetStrLength(int length) { m_StrLength = length; }
inline int GetStrLength(void) { return m_StrLength; }
inline void SetStrLength(int length)
{
m_StrLength = length;
}
inline int GetStrLength(void)
{
return m_StrLength;
}
inline void Set(uint8_t v) { SetType(ValueType_uint8); m_Value._uint8 = v; }
inline void Set(int8_t v) { SetType(ValueType_int8); m_Value._sint8 = v; }
inline void Set(uint16_t v) { SetType(ValueType_uint16); m_Value._uint16 = v; }
inline void Set(int16_t v) { SetType(ValueType_int16); m_Value._sint16 = v; }
inline void Set(uint32_t v) { SetType(ValueType_uint32); m_Value._uint32 = v; }
inline void Set(int32_t v) { SetType(ValueType_int32); m_Value._sint32 = v; }
inline void Set(uint64_t v) { SetType(ValueType_uint64); m_Value._uint64 = v; }
inline void Set(int64_t v) { SetType(ValueType_int64); m_Value._sint64 = v; }
inline void Set(float v) { SetType(ValueType_float); m_Value._float = v; }
inline void Set(double v) { SetType(ValueType_double); m_Value._double = v; }
inline void Set(const wchar_t* v) { SetType(ValueType_string); m_Value._string = v; }
inline void Set(uint8_t v)
{
SetType(ValueType_uint8);
m_Value._uint8 = v;
}
inline void Set(int8_t v)
{
SetType(ValueType_int8);
m_Value._sint8 = v;
}
inline void Set(uint16_t v)
{
SetType(ValueType_uint16);
m_Value._uint16 = v;
}
inline void Set(int16_t v)
{
SetType(ValueType_int16);
m_Value._sint16 = v;
}
inline void Set(uint32_t v)
{
SetType(ValueType_uint32);
m_Value._uint32 = v;
}
inline void Set(int32_t v)
{
SetType(ValueType_int32);
m_Value._sint32 = v;
}
inline void Set(uint64_t v)
{
SetType(ValueType_uint64);
m_Value._uint64 = v;
}
inline void Set(int64_t v)
{
SetType(ValueType_int64);
m_Value._sint64 = v;
}
inline void Set(float v)
{
SetType(ValueType_float);
m_Value._float = v;
}
inline void Set(double v)
{
SetType(ValueType_double);
m_Value._double = v;
}
inline void Set(const wchar_t * v)
{
SetType(ValueType_string);
m_Value._string = v;
}
inline void Get(uint8_t* v) { *v = m_Value._uint8; }
inline void Get(int8_t* v) { *v = m_Value._sint8; }
inline void Get(uint16_t* v) { *v = m_Value._uint16; }
inline void Get(int16_t* v) { *v = m_Value._sint16; }
inline void Get(uint32_t* v) { *v = m_Value._uint32; }
inline void Get(int32_t* v) { *v = m_Value._sint32; }
inline void Get(uint64_t* v) { *v = m_Value._uint64; }
inline void Get(int64_t* v) { *v = m_Value._sint64; }
inline void Get(float* v) { *v = m_Value._float; }
inline void Get(double* v) { *v = m_Value._double; }
inline void Get(const wchar_t** v) { *v = m_Value._string; }
inline void Get(uint8_t * v)
{
*v = m_Value._uint8;
}
inline void Get(int8_t * v)
{
*v = m_Value._sint8;
}
inline void Get(uint16_t * v)
{
*v = m_Value._uint16;
}
inline void Get(int16_t * v)
{
*v = m_Value._sint16;
}
inline void Get(uint32_t * v)
{
*v = m_Value._uint32;
}
inline void Get(int32_t * v)
{
*v = m_Value._sint32;
}
inline void Get(uint64_t * v)
{
*v = m_Value._uint64;
}
inline void Get(int64_t * v)
{
*v = m_Value._sint64;
}
inline void Get(float * v)
{
*v = m_Value._float;
}
inline void Get(double * v)
{
*v = m_Value._double;
}
inline void Get(const wchar_t ** v)
{
*v = m_Value._string;
}
const char* GetTypeName(void);
const char * GetTypeName(void);
int GetTypeSize(void);
bool IsStringType(void);
int ToString(char* buffer, bool bHex, size_t size);
int ToString(char * buffer, bool bHex, size_t size);
static ValueType GetTypeFromString(const char* name, int* typeArraySize);
static ValueType GetTypeFromString(const char * name, int * typeArraySize);
private:
typedef struct
{
const char* name;
const char * name;
ValueType type;
} TypeNameEntry;
@ -139,17 +229,17 @@ public:
std::string m_Description;
public:
int GetValueString(char* buffer, size_t size);
int GetMemoryValueString(char* buffer, size_t size, bool bIgnoreHex = false);
int GetAddressString(char *buffer);
int GetValueString(char * buffer, size_t size);
int GetMemoryValueString(char * buffer, size_t size, bool bIgnoreHex = false);
int GetAddressString(char * buffer);
uint32_t GetVirtualAddress(void);
bool SetMemoryValueFromString(const char* str);
bool SetMemoryValueFromString(const char * str);
//bool IsSelected(void);
//void SetSelected(bool bSelected);
void SetDescription(const char* str);
const char* GetDescription(void);
void SetDescription(const char * str);
const char * GetDescription(void);
void DeleteDescription(void);
bool GetMemoryValue(CMixed* v);
bool GetMemoryValue(CMixed * v);
bool SetAddressSafe(uint32_t address);
bool SetStrLengthSafe(int length);
@ -165,7 +255,7 @@ public:
bool SetSearchType(SearchType searchType);
void SetAddressType(AddressType addressType);
static int ParseHexString(char* dst, const char* src);
static int ParseHexString(char * dst, const char * src);
static bool AddrCheck(uint32_t addr, uint32_t rangeStart, uint32_t rangeEnd);
static bool RangeCheck(uint32_t addrStart, uint32_t addrEnd, uint32_t rangeStart, uint32_t rangeEnd);
@ -175,7 +265,7 @@ public:
template <class T>
void SetValue(T value)
{
*(T*)&m_Value = value;
*(T *)&m_Value = value;
}
void SetStringValueLength(int length);
@ -187,15 +277,15 @@ public:
bool DidFirstScan(void);
size_t GetNumResults(void);
CScanResult* GetResult(size_t index);
CScanResult * GetResult(size_t index);
void RemoveResult(size_t index);
private:
static int HexDigitVal(char c);
uint8_t* m_Memory;
uint8_t * m_Memory;
bool m_DidFirstScan;
uint32_t m_RangeStartAddress;
uint32_t m_RangeEndAddress;
@ -204,32 +294,60 @@ private:
SearchType m_SearchType;
AddressType m_AddressType;
uint32_t m_VAddrBits;
std::vector<CScanResult> m_Results;
std::vector<CScanResult> m_NewResults;
MixedValue m_Value;
int m_StringValueLength;
friend class CScanResult;
static uint8_t* GetMemoryPool(uint32_t physAddr);
static uint8_t * GetMemoryPool(uint32_t physAddr);
template <class T> static bool CompareLessThan(T a, T b) { return a < b; }
template <class T> static bool CompareLessThanOrEqual(T a, T b) { return a <= b; }
template <class T> static bool CompareGreaterThan(T a, T b) { return a > b; }
template <class T> static bool CompareGreaterThanOrEqual(T a, T b) { return a >= b; }
template <class T> static bool CompareEqual(T a, T b) { return a == b; }
template <class T> static bool CompareNotEqual(T a, T b) { return a != b; }
template <class T> static bool NoCompare(T /*a*/, T /*b*/) { return true; }
template <class T>
static bool CompareLessThan(T a, T b)
{
return a < b;
}
template <class T>
static bool CompareLessThanOrEqual(T a, T b)
{
return a <= b;
}
template <class T>
static bool CompareGreaterThan(T a, T b)
{
return a > b;
}
template <class T>
static bool CompareGreaterThanOrEqual(T a, T b)
{
return a >= b;
}
template <class T>
static bool CompareEqual(T a, T b)
{
return a == b;
}
template <class T>
static bool CompareNotEqual(T a, T b)
{
return a != b;
}
template <class T>
static bool NoCompare(T /*a*/, T /*b*/)
{
return true;
}
void FirstScanLoopString(DisplayFormat resultDisplayFormat);
void FirstScanLoopIString(DisplayFormat resultDisplayFormat);
void FirstScanLoopUnkString(void);
template <class T>
void FirstScanLoopPrimitive(bool(*CompareFunc)(T, T), DisplayFormat resultDisplayFormat)
void FirstScanLoopPrimitive(bool (*CompareFunc)(T, T), DisplayFormat resultDisplayFormat)
{
T searchValue = *(T*)&m_Value;
T searchValue = *(T *)&m_Value;
uint32_t startAddr = ((m_RangeStartAddress - 1) | (sizeof(T) - 1)) + 1;
uint32_t endAddr = m_RangeEndAddress;
@ -238,7 +356,7 @@ private:
for (uint32_t addr = startAddr; addr <= endAddr; addr += sizeof(T))
{
uint32_t leAddr = (addr ^ (4 - sizeof(T)));
T memValue = *(T*)&m_Memory[leAddr];
T memValue = *(T *)&m_Memory[leAddr];
if (CompareFunc(memValue, searchValue))
{
@ -248,12 +366,12 @@ private:
}
}
}
// For int64 and double
template <class T>
void FirstScanLoopPrimitive64(bool(*CompareFunc)(T, T), DisplayFormat resultDisplayFormat)
void FirstScanLoopPrimitive64(bool (*CompareFunc)(T, T), DisplayFormat resultDisplayFormat)
{
T searchValue = *(T*)&m_Value;
T searchValue = *(T *)&m_Value;
uint32_t startAddr = ((m_RangeStartAddress - 1) | (sizeof(T) - 1)) + 1;
uint32_t endAddr = m_RangeEndAddress;
@ -263,8 +381,8 @@ private:
{
T memValue;
*((uint32_t*)(&memValue) + 1) = *(uint32_t*) &m_Memory[addr];
*((uint32_t*)(&memValue) + 0) = *(uint32_t*) &m_Memory[addr + 4];
*((uint32_t *)(&memValue) + 1) = *(uint32_t *)&m_Memory[addr];
*((uint32_t *)(&memValue) + 0) = *(uint32_t *)&m_Memory[addr + 4];
if (CompareFunc(memValue, searchValue))
{
@ -277,17 +395,17 @@ private:
// Compare result's current value in memory against m_Value
template <class T>
void NextScanLoopPrimitive(bool(*CompareFunc)(T, T))
void NextScanLoopPrimitive(bool (*CompareFunc)(T, T))
{
T searchValue = *(T*)&m_Value;
T searchValue = *(T *)&m_Value;
for (size_t index = 0; index < m_Results.size(); index++)
{
CScanResult* presult = &m_Results[index];
CScanResult * presult = &m_Results[index];
uint32_t addr = presult->m_Address & 0x1FFFFFFF;
uint32_t leAddr = (addr ^ (4 - sizeof(T)));
T memValue = *(T*) &m_Memory[leAddr];
T memValue = *(T *)&m_Memory[leAddr];
if (CompareFunc(memValue, searchValue))
{
@ -302,19 +420,19 @@ private:
// Compare result's current value in memory against m_Value (for 64-bit types)
template <class T>
void NextScanLoopPrimitive64(bool(*CompareFunc)(T, T))
void NextScanLoopPrimitive64(bool (*CompareFunc)(T, T))
{
T searchValue = *(T*)&m_Value;
T searchValue = *(T *)&m_Value;
for (size_t index = 0; index < m_Results.size(); index++)
{
CScanResult* presult = &m_Results[index];
CScanResult * presult = &m_Results[index];
uint32_t addr = presult->m_Address & 0x1FFFFFFF;
T memValue;
*((uint32_t*)(&memValue) + 1) = *(uint32_t*) &m_Memory[addr];
*((uint32_t*)(&memValue) + 0) = *(uint32_t*) &m_Memory[addr + 4];
*((uint32_t *)(&memValue) + 1) = *(uint32_t *)&m_Memory[addr];
*((uint32_t *)(&memValue) + 0) = *(uint32_t *)&m_Memory[addr + 4];
if (CompareFunc(memValue, searchValue))
{
@ -329,17 +447,17 @@ private:
// Compare result's current value in memory against result's old value
template <class T>
void NextScanLoopPrimitiveResults(bool(*CompareFunc)(T, T))
void NextScanLoopPrimitiveResults(bool (*CompareFunc)(T, T))
{
for (size_t index = 0; index < m_Results.size(); index++)
{
CScanResult* presult = &m_Results[index];
CScanResult * presult = &m_Results[index];
uint32_t addr = presult->m_Address & 0x1FFFFFFF;
uint32_t leAddr = (addr ^ (4 - sizeof(T)));
T memValue, oldValue;
memValue = *(T*)&m_Memory[leAddr];
memValue = *(T *)&m_Memory[leAddr];
presult->Get(&oldValue);
if (CompareFunc(memValue, oldValue))
@ -355,18 +473,18 @@ private:
// Compare result's current value in memory against result's old value (for 64-bit types)
template <class T>
void NextScanLoopPrimitiveResults64(bool(*CompareFunc)(T, T))
void NextScanLoopPrimitiveResults64(bool (*CompareFunc)(T, T))
{
for (size_t index = 0; index < m_Results.size(); index++)
{
CScanResult* presult = &m_Results[index];
CScanResult * presult = &m_Results[index];
uint32_t addr = presult->m_Address & 0x1FFFFFFF;
T memValue, oldValue;
*((uint32_t*)(&memValue) + 1) = *(uint32_t*)&m_Memory[addr];
*((uint32_t*)(&memValue) + 0) = *(uint32_t*)&m_Memory[addr + 4];
*((uint32_t *)(&memValue) + 1) = *(uint32_t *)&m_Memory[addr];
*((uint32_t *)(&memValue) + 0) = *(uint32_t *)&m_Memory[addr + 4];
presult->Get(&oldValue);

View File

@ -5,14 +5,13 @@
class COpInfo
{
public:
R4300iOpcode m_OpCode;
COpInfo()
{
}
inline COpInfo(R4300iOpcode opcode):
inline COpInfo(R4300iOpcode opcode) :
m_OpCode(opcode)
{
}
@ -135,14 +134,12 @@ public:
inline bool IsLoadCommand()
{
return (m_OpCode.op >= R4300i_LDL && m_OpCode.op <= R4300i_LWU ||
m_OpCode.op >= R4300i_LL && m_OpCode.op <= R4300i_LD);
return (m_OpCode.op >= R4300i_LDL && m_OpCode.op <= R4300i_LWU || m_OpCode.op >= R4300i_LL && m_OpCode.op <= R4300i_LD);
}
inline bool IsStoreCommand()
{
return (m_OpCode.op >= R4300i_SB && m_OpCode.op <= R4300i_SWR ||
m_OpCode.op >= R4300i_SC && m_OpCode.op <= R4300i_SD);
return (m_OpCode.op >= R4300i_SB && m_OpCode.op <= R4300i_SWR || m_OpCode.op >= R4300i_SC && m_OpCode.op <= R4300i_SD);
}
// ADDIU SP, SP, X
@ -152,7 +149,7 @@ public:
}
// ADDIU SP, SP, <negative value>
bool IsStackAlloc()
bool IsStackAlloc()
{
if (!IsStackShift())
{
@ -163,7 +160,7 @@ public:
}
// ADDIU SP, SP, <positive value>
bool IsStackFree()
bool IsStackFree()
{
if (!IsStackShift())
{
@ -173,7 +170,7 @@ public:
return (short)m_OpCode.immediate > 0;
}
void ReadsGPR(int* nReg1, int* nReg2)
void ReadsGPR(int * nReg1, int * nReg2)
{
uint32_t op = m_OpCode.op;
@ -181,25 +178,21 @@ public:
{
uint32_t fn = m_OpCode.funct;
if (fn >= R4300i_SPECIAL_SLLV && fn <= R4300i_SPECIAL_SRAV ||
fn >= R4300i_SPECIAL_DSLLV && fn <= R4300i_SPECIAL_DSRAV ||
fn >= R4300i_SPECIAL_MULT && fn <= R4300i_SPECIAL_TNE)
if (fn >= R4300i_SPECIAL_SLLV && fn <= R4300i_SPECIAL_SRAV || fn >= R4300i_SPECIAL_DSLLV && fn <= R4300i_SPECIAL_DSRAV || fn >= R4300i_SPECIAL_MULT && fn <= R4300i_SPECIAL_TNE)
{
*nReg1 = m_OpCode.rs;
*nReg2 = m_OpCode.rt;
return;
}
if (fn == R4300i_SPECIAL_MTLO || fn == R4300i_SPECIAL_MTHI ||
fn == R4300i_SPECIAL_JR || fn == R4300i_SPECIAL_JALR)
if (fn == R4300i_SPECIAL_MTLO || fn == R4300i_SPECIAL_MTHI || fn == R4300i_SPECIAL_JR || fn == R4300i_SPECIAL_JALR)
{
*nReg1 = m_OpCode.rs;
*nReg2 = 0;
return;
}
if (fn >= R4300i_SPECIAL_SLL && fn <= R4300i_SPECIAL_SRA ||
fn >= R4300i_SPECIAL_DSLL && fn <= R4300i_SPECIAL_DSRA32)
if (fn >= R4300i_SPECIAL_SLL && fn <= R4300i_SPECIAL_SRA || fn >= R4300i_SPECIAL_DSLL && fn <= R4300i_SPECIAL_DSRA32)
{
*nReg1 = m_OpCode.rt;
*nReg2 = 0;
@ -211,21 +204,14 @@ public:
return;
}
if (op >= R4300i_SB && op <= R4300i_SWR ||
op == R4300i_SC || op == R4300i_SD ||
op == R4300i_BEQ || op == R4300i_BEQL ||
op == R4300i_BNE || op == R4300i_BNEL)
if (op >= R4300i_SB && op <= R4300i_SWR || op == R4300i_SC || op == R4300i_SD || op == R4300i_BEQ || op == R4300i_BEQL || op == R4300i_BNE || op == R4300i_BNEL)
{
*nReg1 = m_OpCode.rs;
*nReg2 = m_OpCode.rt;
return;
}
if (op >= R4300i_BLEZL && op <= R4300i_LWU ||
op >= R4300i_BLEZ && op <= R4300i_XORI ||
op >= R4300i_CACHE && op <= R4300i_LD ||
op >= R4300i_SWC1 && op <= R4300i_SDC2 ||
op == R4300i_REGIMM)
if (op >= R4300i_BLEZL && op <= R4300i_LWU || op >= R4300i_BLEZ && op <= R4300i_XORI || op >= R4300i_CACHE && op <= R4300i_LD || op >= R4300i_SWC1 && op <= R4300i_SDC2 || op == R4300i_REGIMM)
{
*nReg1 = m_OpCode.rs;
*nReg2 = 0;
@ -241,9 +227,7 @@ public:
if (op == R4300i_CP1)
{
if (m_OpCode.fmt == R4300i_COP1_MT ||
m_OpCode.fmt == R4300i_COP1_DMT ||
m_OpCode.fmt == R4300i_COP1_CT)
if (m_OpCode.fmt == R4300i_COP1_MT || m_OpCode.fmt == R4300i_COP1_DMT || m_OpCode.fmt == R4300i_COP1_CT)
{
*nReg1 = m_OpCode.rt;
*nReg2 = 0;
@ -255,7 +239,7 @@ public:
*nReg2 = 0;
}
inline void WritesGPR(int* nReg)
inline void WritesGPR(int * nReg)
{
uint32_t op = m_OpCode.op;
@ -263,12 +247,7 @@ public:
{
uint32_t fn = m_OpCode.funct;
if (fn >= R4300i_SPECIAL_SLL && fn <= R4300i_SPECIAL_SRAV ||
fn >= R4300i_SPECIAL_DSLLV && fn <= R4300i_SPECIAL_DSRAV ||
fn >= R4300i_SPECIAL_DIVU && fn <= R4300i_SPECIAL_DSUBU ||
fn >= R4300i_SPECIAL_DSLL && fn <= R4300i_SPECIAL_DSRA32 ||
fn == R4300i_SPECIAL_JALR || fn == R4300i_SPECIAL_MFLO ||
fn == R4300i_SPECIAL_MFHI)
if (fn >= R4300i_SPECIAL_SLL && fn <= R4300i_SPECIAL_SRAV || fn >= R4300i_SPECIAL_DSLLV && fn <= R4300i_SPECIAL_DSRAV || fn >= R4300i_SPECIAL_DIVU && fn <= R4300i_SPECIAL_DSUBU || fn >= R4300i_SPECIAL_DSLL && fn <= R4300i_SPECIAL_DSRA32 || fn == R4300i_SPECIAL_JALR || fn == R4300i_SPECIAL_MFLO || fn == R4300i_SPECIAL_MFHI)
{
*nReg = m_OpCode.rd;
return;
@ -278,12 +257,7 @@ public:
return;
}
if (op >= R4300i_DADDI && op <= R4300i_LWU ||
op >= R4300i_ADDI && op <= R4300i_LUI ||
op == R4300i_LL || op == R4300i_LD ||
(op == R4300i_CP0 && m_OpCode.fmt == R4300i_COP0_MF) ||
(op == R4300i_CP1 && m_OpCode.fmt == R4300i_COP1_MF) ||
(op == R4300i_CP1 && m_OpCode.fmt == R4300i_COP1_CF))
if (op >= R4300i_DADDI && op <= R4300i_LWU || op >= R4300i_ADDI && op <= R4300i_LUI || op == R4300i_LL || op == R4300i_LD || (op == R4300i_CP0 && m_OpCode.fmt == R4300i_COP0_MF) || (op == R4300i_CP1 && m_OpCode.fmt == R4300i_COP1_MF) || (op == R4300i_CP1 && m_OpCode.fmt == R4300i_COP1_CF))
{
*nReg = m_OpCode.rt;
return;
@ -312,8 +286,7 @@ public:
{
if (m_OpCode.op == R4300i_SPECIAL)
{
if (m_OpCode.funct == R4300i_SPECIAL_MTHI ||
m_OpCode.funct >= R4300i_SPECIAL_MULT && m_OpCode.funct <= R4300i_SPECIAL_DDIVU)
if (m_OpCode.funct == R4300i_SPECIAL_MTHI || m_OpCode.funct >= R4300i_SPECIAL_MULT && m_OpCode.funct <= R4300i_SPECIAL_DDIVU)
{
return true;
}
@ -325,8 +298,7 @@ public:
{
if (m_OpCode.op == R4300i_SPECIAL)
{
if (m_OpCode.funct == R4300i_SPECIAL_MTLO ||
m_OpCode.funct >= R4300i_SPECIAL_MULT && m_OpCode.funct <= R4300i_SPECIAL_DDIVU)
if (m_OpCode.funct == R4300i_SPECIAL_MTLO || m_OpCode.funct >= R4300i_SPECIAL_MULT && m_OpCode.funct <= R4300i_SPECIAL_DDIVU)
{
return true;
}

View File

@ -2,13 +2,15 @@
#pragma once
class CJSIntervalWorker : public CScriptWorker {
class CJSIntervalWorker : public CScriptWorker
{
private:
int m_DelayMS;
bool m_bOnce;
HANDLE m_hTimerQuitEvent;
public:
CJSIntervalWorker(CScriptInstance* inst, void* dukObjectHeapPtr, int delayMS, bool bOnce);
CJSIntervalWorker(CScriptInstance * inst, void * dukObjectHeapPtr, int delayMS, bool bOnce);
virtual ~CJSIntervalWorker();
virtual void WorkerProc();

View File

@ -3,7 +3,7 @@
#include "JSServerWorker.h"
#include "JSSocketWorker.h"
CJSServerWorker::CJSServerWorker(CScriptInstance* instance, void* dukObjectHeapPtr) :
CJSServerWorker::CJSServerWorker(CScriptInstance * instance, void * dukObjectHeapPtr) :
CScriptWorker(instance, dukObjectHeapPtr),
m_bWinsockOK(false),
m_ServerSocket(INVALID_SOCKET)
@ -22,7 +22,7 @@ CJSServerWorker::~CJSServerWorker()
}
}
void CJSServerWorker::Init(const char* address, unsigned short port)
void CJSServerWorker::Init(const char * address, unsigned short port)
{
m_Queue.listenAddress = address;
m_Queue.listenPort = port;
@ -32,9 +32,10 @@ void CJSServerWorker::WorkerProc()
{
int rc;
union {
SOCKADDR service;
SOCKADDR_IN service_ipv4;
union
{
SOCKADDR service;
SOCKADDR_IN service_ipv4;
SOCKADDR_IN6 service_ipv6;
};
@ -74,8 +75,8 @@ void CJSServerWorker::WorkerProc()
goto stop_cleanup;
}
rc = ::bind(m_ServerSocket, (const SOCKADDR*)&service,
service.sa_family == AF_INET ? sizeof(service_ipv4) : sizeof(service_ipv6));
rc = ::bind(m_ServerSocket, (const SOCKADDR *)&service,
service.sa_family == AF_INET ? sizeof(service_ipv4) : sizeof(service_ipv6));
if (rc == SOCKET_ERROR)
{
@ -143,12 +144,12 @@ void CJSServerWorker::WorkerProc()
}
stop_cleanup:
{
CGuard guard(m_CS);
strncpy(m_Address.address, "", sizeof(m_Address.address));
m_Address.port = 0;
m_Address.family = "";
}
{
CGuard guard(m_CS);
strncpy(m_Address.address, "", sizeof(m_Address.address));
m_Address.port = 0;
m_Address.family = "";
}
if (m_ServerSocket != INVALID_SOCKET)
{

View File

@ -1,27 +1,34 @@
#pragma once
#include "ScriptAPI.h"
#include <windows.h>
#include <winsock2.h>
#include <ws2tcpip.h>
#include <windows.h>
#include "ScriptAPI.h"
class CJSServerWorker : public CScriptWorker
{
private:
enum { TIMEOUT_MS = 1 };
enum
{
TIMEOUT_MS = 1
};
struct ServerQueue {
struct ServerQueue
{
CriticalSection cs;
std::string listenAddress;
unsigned short listenPort;
bool bClosePending;
ServerQueue() : listenAddress(""), listenPort(0), bClosePending(false) {}
ServerQueue() :
listenAddress(""), listenPort(0), bClosePending(false)
{
}
} m_Queue;
struct JSServerAddrInfo
{
char address[INET6_ADDRSTRLEN];
const char* family;
const char * family;
unsigned short port;
JSServerAddrInfo() :
@ -37,24 +44,24 @@ private:
JSServerAddrInfo m_Address;
public:
CJSServerWorker(CScriptInstance* instance, void* dukObjectHeapPtr);
CJSServerWorker(CScriptInstance * instance, void * dukObjectHeapPtr);
virtual ~CJSServerWorker();
void Init(const char* address, unsigned short port);
void Init(const char * address, unsigned short port);
void WorkerProc();
std::string GetAddress();
unsigned short GetPort();
const char* GetFamily();
const char * GetFamily();
private:
void JSEmitConnection(SOCKET c);
void JSEmitClose();
void JSEmitListening();
void JSEmitError(const char* errMessage);
void JSEmitError(const char * errMessage);
static duk_idx_t CbArgs_EmitConnection(duk_context* ctx, void* _env);
static duk_idx_t CbArgs_EmitClose(duk_context* ctx, void* _env);
static duk_idx_t CbArgs_EmitListening(duk_context* ctx, void* _env);
static duk_idx_t CbArgs_EmitError(duk_context* ctx, void* _env);
static duk_idx_t CbArgs_EmitConnection(duk_context * ctx, void * _env);
static duk_idx_t CbArgs_EmitClose(duk_context * ctx, void * _env);
static duk_idx_t CbArgs_EmitListening(duk_context * ctx, void * _env);
static duk_idx_t CbArgs_EmitError(duk_context * ctx, void * _env);
};

View File

@ -69,9 +69,7 @@ bool CJSSocketWorker::Write(const char * data, size_t length, duk_int_t callback
{
CGuard guard(m_Queue.cs);
if (m_Queue.bFullClosePending ||
m_Queue.bSendClosePending ||
m_Queue.bSendClosed)
if (m_Queue.bFullClosePending || m_Queue.bSendClosePending || m_Queue.bSendClosed)
{
return false;
}
@ -313,8 +311,7 @@ void CJSSocketWorker::ProcSendData()
JSEmitError("send() error");
}
if (m_Queue.writes.size() == 0 &&
m_Queue.bSendClosePending)
if (m_Queue.writes.size() == 0 && m_Queue.bSendClosePending)
{
shutdown(m_Socket, SD_SEND);
m_Queue.bSendClosePending = false;

View File

@ -1,20 +1,23 @@
#include "../ScriptWorker.h"
#include "ScriptAPI.h"
#include <windows.h>
#include <winsock2.h>
#include <ws2tcpip.h>
#include <windows.h>
#include "ScriptAPI.h"
#include "../ScriptWorker.h"
#pragma comment (lib, "Ws2_32.lib")
#pragma comment(lib, "Ws2_32.lib")
#pragma once
class CJSSocketWorker : public CScriptWorker
{
private:
enum { TIMEOUT_MS = 1 };
enum
{
TIMEOUT_MS = 1
};
struct JSSocketAddrInfo
{
char address[INET6_ADDRSTRLEN];
const char* family;
const char * family;
unsigned short port;
JSSocketAddrInfo() :
@ -32,8 +35,9 @@ private:
duk_int_t callbackId;
};
struct JSEmitDataEnv {
char* data;
struct JSEmitDataEnv
{
char * data;
size_t size;
};
@ -63,29 +67,29 @@ private:
}
};
SOCKET m_Socket;
bool m_bWinsockOK;
bool m_bAllowHalfOpen;
SOCKET m_Socket;
bool m_bWinsockOK;
bool m_bAllowHalfOpen;
JSSocketAddrInfo m_LocalAddress;
JSSocketAddrInfo m_RemoteAddress;
JSSocketQueue m_Queue;
JSSocketQueue m_Queue;
public:
CJSSocketWorker(CScriptInstance* inst, void* objectHeapPtr, bool bAllowHalfOpen);
CJSSocketWorker(CScriptInstance * inst, void * objectHeapPtr, bool bAllowHalfOpen);
virtual ~CJSSocketWorker();
bool Init(SOCKET sock);
bool Init(const char* host, unsigned short port);
bool Init(const char * host, unsigned short port);
void WorkerProc();
bool Write(const char* data, size_t length, duk_int_t callbackId, bool bEnd = false);
bool Write(const char * data, size_t length, duk_int_t callbackId, bool bEnd = false);
//bool GetAddress(JSSocketAddrInfo& address);
std::string GetLocalAddress();
unsigned short GetLocalPort();
std::string GetRemoteAddress();
unsigned short GetRemotePort();
const char* GetFamily();
const char * GetFamily();
private:
bool ProcConnect();
@ -97,19 +101,19 @@ private:
void ClearQueue();
void JSEmitConnect();
void JSEmitData(const char* data, size_t size);
void JSEmitData(const char * data, size_t size);
void JSEmitEnd();
void JSEmitClose();
void JSEmitDrain();
void JSEmitLookup(JSSocketAddrInfo& addr);
void JSEmitError(const char* errMessage);
void JSEmitLookup(JSSocketAddrInfo & addr);
void JSEmitError(const char * errMessage);
static duk_idx_t CbArgs_EmitConnect(duk_context* ctx, void* _env);
static duk_idx_t CbArgs_EmitData(duk_context* ctx, void* _env);
static duk_idx_t CbArgs_EmitEnd(duk_context* ctx, void* _env);
static duk_idx_t CbArgs_EmitClose(duk_context* ctx, void* _env);
static duk_idx_t CbArgs_EmitDrain(duk_context* ctx, void* _env);
static duk_idx_t CbArgs_EmitLookup(duk_context* ctx, void* _env);
static duk_idx_t CbArgs_EmitError(duk_context* ctx, void* _env);
static duk_idx_t CbArgs_Write(duk_context* ctx, void* _env);
static duk_idx_t CbArgs_EmitConnect(duk_context * ctx, void * _env);
static duk_idx_t CbArgs_EmitData(duk_context * ctx, void * _env);
static duk_idx_t CbArgs_EmitEnd(duk_context * ctx, void * _env);
static duk_idx_t CbArgs_EmitClose(duk_context * ctx, void * _env);
static duk_idx_t CbArgs_EmitDrain(duk_context * ctx, void * _env);
static duk_idx_t CbArgs_EmitLookup(duk_context * ctx, void * _env);
static duk_idx_t CbArgs_EmitError(duk_context * ctx, void * _env);
static duk_idx_t CbArgs_Write(duk_context * ctx, void * _env);
};

View File

@ -510,7 +510,7 @@ const char * CN64Image::ResultCodeName(int resultCode)
{N64IMG_PNG_HEADER_MISSING, "ERR_PNG_HEADER_MISSING"},
{N64IMG_PNG_OUT_OF_MEMORY, "ERR_PNG_OUT_OF_MEMORY"},
{N64IMG_PNG_EXCEPTION, "ERR_PNG_EXCEPTION"},
{ N64IMG_PNG_PARSER_FAILED, "ERR_PNG_PARSER_FAILED" }
{N64IMG_PNG_PARSER_FAILED, "ERR_PNG_PARSER_FAILED"},
};
if (names.count(resultCode) != 0)

View File

@ -1,7 +1,8 @@
#pragma once
#include "ScriptAPI.h"
enum {
enum
{
G_IM_FMT_RGBA,
G_IM_FMT_YUV,
G_IM_FMT_CI,
@ -9,20 +10,23 @@ enum {
G_IM_FMT_I
};
enum {
enum
{
G_IM_SIZ_4b,
G_IM_SIZ_8b,
G_IM_SIZ_16b,
G_IM_SIZ_32b
};
enum {
enum
{
G_TT_NONE = 0x0000,
G_TT_RGBA16 = 0x8000,
G_TT_IA16 = 0xC000,
};
enum {
enum
{
IMG_RGBA16 = (G_IM_FMT_RGBA << 3 | G_IM_SIZ_16b),
IMG_RGBA32 = (G_IM_FMT_RGBA << 3 | G_IM_SIZ_32b),
IMG_CI4_RGBA16 = (G_IM_FMT_CI << 3 | G_IM_SIZ_4b) | G_TT_RGBA16,
@ -36,7 +40,8 @@ enum {
IMG_I8 = (G_IM_FMT_I << 3 | G_IM_SIZ_8b),
};
enum N64ImageResult {
enum N64ImageResult
{
N64IMG_OK,
N64IMG_DATA_SIZE_INCORRECT,
N64IMG_INVALID_COLOR_INDEX,
@ -67,40 +72,40 @@ public:
CN64Image();
int Init(int format, size_t width, size_t height,
void* pixelData = nullptr, size_t pixelDataSize = 0,
void* paletteData = nullptr, size_t paletteDataSize = 0);
void * pixelData = nullptr, size_t pixelDataSize = 0,
void * paletteData = nullptr, size_t paletteDataSize = 0);
int Init(int format, uint8_t* pngData, size_t pngSize);
void ToPNG(std::vector<uint8_t>& outPngImage);
int Init(int format, uint8_t * pngData, size_t pngSize);
void ToPNG(std::vector<uint8_t> & outPngImage);
int UpdateBitmap();
std::vector<uint8_t>& PaletteData();
std::vector<uint8_t>& PixelData();
std::vector<uint8_t>& Bitmap();
std::vector<uint8_t> & PaletteData();
std::vector<uint8_t> & PixelData();
std::vector<uint8_t> & Bitmap();
size_t Width();
size_t Height();
int Format();
bool UsesPalette();
static int ReadPNG(uint8_t* pngData, size_t pngSize, size_t* width, size_t* height, std::vector<uint8_t>& outRGBA32);
static void WritePNG(uint8_t* rgba32, size_t width, size_t height, std::vector<uint8_t>& buffer);
static int ReadPNG(uint8_t * pngData, size_t pngSize, size_t * width, size_t * height, std::vector<uint8_t> & outRGBA32);
static void WritePNG(uint8_t * rgba32, size_t width, size_t height, std::vector<uint8_t> & buffer);
static unsigned int ColorFromRgba32(int dstFormat, uint32_t rgba32);
static uint32_t ColorToRgba32(int srcFormat, unsigned int color);
static int BitsPerPixel(int format);
static int PaletteColorCount(int format);
static bool UsesPalette(int format);
static const char* ResultCodeName(int resultCode);
static const char * ResultCodeName(int resultCode);
private:
uint16_t* PalettePtr(size_t index);
void* TexelPtr(size_t index);
uint32_t* BitmapPtr(size_t index);
uint16_t * PalettePtr(size_t index);
void * TexelPtr(size_t index);
uint32_t * BitmapPtr(size_t index);
unsigned int GetTexel(size_t index);
void SetTexel(size_t index, unsigned int value);
bool GetPaletteColor(size_t index, unsigned int* color);
bool GetPaletteColor(size_t index, unsigned int * color);
bool SetPaletteColor(size_t index, unsigned int color);
bool GetBitmapColor(size_t index, uint32_t* color);
bool GetBitmapColor(size_t index, uint32_t * color);
bool SetBitmapColor(size_t index, unsigned int color);
int UpdatePixelsAndPaletteFromBitmap();
};

View File

@ -841,8 +841,7 @@ void ScriptAPI::DukPutPropList(duk_context * ctx, duk_idx_t obj_idx, const DukPr
}
else
{
if (prop.typeId == Type_DukGetter ||
prop.typeId == Type_DukGetterSetter)
if (prop.typeId == Type_DukGetter || prop.typeId == Type_DukGetterSetter)
{
// not compatible
g_Notify->BreakPoint(__FILE__, __LINE__);

View File

@ -1,462 +1,552 @@
#include "../ScriptTypes.h"
#include "../ScriptSystem.h"
#include "../ScriptInstance.h"
#include "../ScriptSystem.h"
#include "../ScriptTypes.h"
#pragma once
#define PJ64_JSAPI_VERSION "jsapi-2"
#define HS_gAppCallbacks DUK_HIDDEN_SYMBOL("gAppCallbacks")
#define HS_gInstancePtr DUK_HIDDEN_SYMBOL("gInstancePtr")
#define HS_gInputListener DUK_HIDDEN_SYMBOL("gInputListener")
#define HS_gOpenFileDescriptors DUK_HIDDEN_SYMBOL("gOpenFileDescriptors")
#define HS_gKeepAlive DUK_HIDDEN_SYMBOL("gKeepAlive")
#define HS_gPrivateCallEnabled DUK_HIDDEN_SYMBOL("gPrivateCallEnabled")
#define HS_gNativeModules DUK_HIDDEN_SYMBOL("gNativeModules")
#define HS_gObjectRefs DUK_HIDDEN_SYMBOL("gObjectRefs")
#define HS_gNextObjectRefId DUK_HIDDEN_SYMBOL("gNextObjectRefId")
#define HS_gIntervals DUK_HIDDEN_SYMBOL("gIntervals")
#define HS_gNextInvervalId DUK_HIDDEN_SYMBOL("gNextIntervalId")
#define HS_gAppCallbacks DUK_HIDDEN_SYMBOL("gAppCallbacks")
#define HS_gInstancePtr DUK_HIDDEN_SYMBOL("gInstancePtr")
#define HS_gInputListener DUK_HIDDEN_SYMBOL("gInputListener")
#define HS_gOpenFileDescriptors DUK_HIDDEN_SYMBOL("gOpenFileDescriptors")
#define HS_gKeepAlive DUK_HIDDEN_SYMBOL("gKeepAlive")
#define HS_gPrivateCallEnabled DUK_HIDDEN_SYMBOL("gPrivateCallEnabled")
#define HS_gNativeModules DUK_HIDDEN_SYMBOL("gNativeModules")
#define HS_gObjectRefs DUK_HIDDEN_SYMBOL("gObjectRefs")
#define HS_gNextObjectRefId DUK_HIDDEN_SYMBOL("gNextObjectRefId")
#define HS_gIntervals DUK_HIDDEN_SYMBOL("gIntervals")
#define HS_gNextInvervalId DUK_HIDDEN_SYMBOL("gNextIntervalId")
#define HS_objectRefId DUK_HIDDEN_SYMBOL("objectRefId")
#define HS_emitterListeners DUK_HIDDEN_SYMBOL("emitterListeners")
#define HS_emitterNextListenerId DUK_HIDDEN_SYMBOL("emitterNextListenerId")
#define HS_socketWorkerPtr DUK_HIDDEN_SYMBOL("socketWorkerPtr")
#define HS_objectRefId DUK_HIDDEN_SYMBOL("objectRefId")
#define HS_emitterListeners DUK_HIDDEN_SYMBOL("emitterListeners")
#define HS_emitterNextListenerId DUK_HIDDEN_SYMBOL("emitterNextListenerId")
#define HS_socketWorkerPtr DUK_HIDDEN_SYMBOL("socketWorkerPtr")
#define HS_socketNextWriteCallbackId DUK_HIDDEN_SYMBOL("nextWriteCallbackId")
#define HS_socketWriteCallbacks DUK_HIDDEN_SYMBOL("writeCallbacks")
#define HS_socketWriteEndCallbacks DUK_HIDDEN_SYMBOL("endCallbacks")
#define HS_serverWorkerPtr DUK_HIDDEN_SYMBOL("serverWorkerPtr")
#define HS_renderWindowPtr DUK_HIDDEN_SYMBOL("renderWindowPtr")
#define HS_n64ImagePtr DUK_HIDDEN_SYMBOL("n64ImagePtr")
#define HS_socketWriteCallbacks DUK_HIDDEN_SYMBOL("writeCallbacks")
#define HS_socketWriteEndCallbacks DUK_HIDDEN_SYMBOL("endCallbacks")
#define HS_serverWorkerPtr DUK_HIDDEN_SYMBOL("serverWorkerPtr")
#define HS_renderWindowPtr DUK_HIDDEN_SYMBOL("renderWindowPtr")
#define HS_n64ImagePtr DUK_HIDDEN_SYMBOL("n64ImagePtr")
namespace ScriptAPI
{
struct DukPropListEntry;
struct DukPropListEntry;
enum MemType {
U8, U16, U32, S8, S16, S32, F32, F64,
U64, S64
};
enum MemType
{
U8,
U16,
U32,
S8,
S16,
S32,
F32,
F64,
U64,
S64
};
enum ArgType {
Arg_Any,
Arg_Number,
Arg_BufferData,
Arg_String,
Arg_Function,
Arg_Object,
Arg_Array,
Arg_Boolean,
enum ArgType
{
Arg_Any,
Arg_Number,
Arg_BufferData,
Arg_String,
Arg_Function,
Arg_Object,
Arg_Array,
Arg_Boolean,
ArgAttr_Optional = (1 << 31),
Arg_OptAny = Arg_Any | ArgAttr_Optional,
Arg_OptNumber = Arg_Number | ArgAttr_Optional,
Arg_OptBufferData = Arg_BufferData | ArgAttr_Optional,
Arg_OptString = Arg_String | ArgAttr_Optional,
Arg_OptFunction = Arg_Function | ArgAttr_Optional,
Arg_OptObject = Arg_Object | ArgAttr_Optional,
Arg_OptArray = Arg_Array | ArgAttr_Optional,
Arg_OptBoolean = Arg_Boolean | ArgAttr_Optional,
ArgAttr_Optional = (1 << 31),
Arg_OptAny = Arg_Any | ArgAttr_Optional,
Arg_OptNumber = Arg_Number | ArgAttr_Optional,
Arg_OptBufferData = Arg_BufferData | ArgAttr_Optional,
Arg_OptString = Arg_String | ArgAttr_Optional,
Arg_OptFunction = Arg_Function | ArgAttr_Optional,
Arg_OptObject = Arg_Object | ArgAttr_Optional,
Arg_OptArray = Arg_Array | ArgAttr_Optional,
Arg_OptBoolean = Arg_Boolean | ArgAttr_Optional,
ArgAttrs = ArgAttr_Optional
};
ArgAttrs = ArgAttr_Optional
};
// ScriptAPI
void InitEnvironment(duk_context* ctx, CScriptInstance* inst);
void DefineGlobalConstants(duk_context* ctx);
// ScriptAPI
void InitEnvironment(duk_context * ctx, CScriptInstance * inst);
void DefineGlobalConstants(duk_context * ctx);
void DefineGlobalClass(duk_context* ctx, const char* className,
duk_c_function constructorFunc,
const DukPropListEntry* prototypeProps = nullptr,
const DukPropListEntry* staticProps = nullptr);
void DefineGlobalClass(duk_context * ctx, const char * className,
duk_c_function constructorFunc,
const DukPropListEntry * prototypeProps = nullptr,
const DukPropListEntry * staticProps = nullptr);
void DefineGlobalInterface(duk_context* ctx, const char* name, const DukPropListEntry* props);
void DefineGlobalFunction(duk_context* ctx, const char* name, duk_c_function func);
void DefineGlobalInterface(duk_context * ctx, const char * name, const DukPropListEntry * props);
CScriptInstance* GetInstance(duk_context* ctx);
void DefineGlobalFunction(duk_context * ctx, const char * name, duk_c_function func);
JSAppCallbackID AddAppCallback(duk_context* ctx, duk_idx_t callbackFuncIdx,
JSAppHookID hookId,
JSDukArgSetupFunc argSetupFunc = nullptr,
JSAppCallbackCondFunc conditionFunc = nullptr,
JSAppCallbackCleanupFunc cleanupFunc = nullptr);
CScriptInstance * GetInstance(duk_context * ctx);
JSAppCallbackID AddAppCallback(duk_context* ctx, JSAppHookID hookId, JSAppCallback& callback);
JSAppCallbackID AddAppCallback(duk_context * ctx, duk_idx_t callbackFuncIdx,
JSAppHookID hookId,
JSDukArgSetupFunc argSetupFunc = nullptr,
JSAppCallbackCondFunc conditionFunc = nullptr,
JSAppCallbackCleanupFunc cleanupFunc = nullptr);
bool RemoveAppCallback(duk_context* ctx, JSAppCallbackID callbackId);
duk_ret_t js__AppCallbackFinalizer(duk_context* ctx);
JSAppCallbackID AddAppCallback(duk_context * ctx, JSAppHookID hookId, JSAppCallback & callback);
void RefObject(duk_context* ctx, duk_idx_t idx);
void UnrefObject(duk_context* ctx, duk_idx_t idx);
duk_ret_t js__UnrefObject(duk_context* ctx);
bool RemoveAppCallback(duk_context * ctx, JSAppCallbackID callbackId);
duk_ret_t js__AppCallbackFinalizer(duk_context * ctx);
void InitEmitter(duk_context* ctx, duk_idx_t obj_idx, const std::vector<std::string>& eventNames);
duk_ret_t js__Emitter_emit(duk_context* ctx);
duk_ret_t js__Emitter_on(duk_context* ctx);
duk_ret_t js__Emitter_off(duk_context* ctx);
void RefObject(duk_context * ctx, duk_idx_t idx);
void UnrefObject(duk_context * ctx, duk_idx_t idx);
duk_ret_t js__UnrefObject(duk_context * ctx);
duk_ret_t js_Duktape_modSearch(duk_context* ctx); // require()
void RegisterNativeModule(duk_context* ctx, HMODULE hModule);
duk_ret_t js__NativeModuleFinalizer(duk_context* ctx);
void InitEmitter(duk_context * ctx, duk_idx_t obj_idx, const std::vector<std::string> & eventNames);
duk_ret_t js__Emitter_emit(duk_context * ctx);
duk_ret_t js__Emitter_on(duk_context * ctx);
duk_ret_t js__Emitter_off(duk_context * ctx);
void AllowPrivateCall(duk_context* ctx, bool bAllow);
bool PrivateCallAllowed(duk_context* ctx);
duk_ret_t js_Duktape_modSearch(duk_context * ctx); // require()
void RegisterNativeModule(duk_context * ctx, HMODULE hModule);
duk_ret_t js__NativeModuleFinalizer(duk_context * ctx);
void PushNewDummyConstructor(duk_context* ctx, bool bFrozen = true);
void DefineGlobalDummyConstructors(duk_context* ctx, const char* constructorNames[], bool bFreeze = true);
void SetDummyConstructor(duk_context* ctx, duk_idx_t obj_idx, const char* globalConstructorName);
duk_ret_t js_DummyConstructor(duk_context* ctx);
void AllowPrivateCall(duk_context * ctx, bool bAllow);
bool PrivateCallAllowed(duk_context * ctx);
const char* ArgTypeName(ArgType argType);
duk_bool_t ArgTypeMatches(duk_context* ctx, duk_idx_t idx, ArgType wantType);
duk_ret_t CheckArgs(duk_context* ctx, const std::vector<ArgType>& argTypes);
duk_ret_t CheckSetterAssignment(duk_context* ctx, ArgType wantType);
void PushNewDummyConstructor(duk_context * ctx, bool bFrozen = true);
void DefineGlobalDummyConstructors(duk_context * ctx, const char * constructorNames[], bool bFreeze = true);
void SetDummyConstructor(duk_context * ctx, duk_idx_t obj_idx, const char * globalConstructorName);
duk_ret_t js_DummyConstructor(duk_context * ctx);
duk_ret_t ThrowInvalidArgsError(duk_context* ctx);
duk_ret_t ThrowInvalidArgError(duk_context* ctx, duk_idx_t idx, ArgType wantType);
duk_ret_t ThrowTooManyArgsError(duk_context* ctx);
duk_ret_t ThrowInvalidAssignmentError(duk_context* ctx, ArgType wantType);
duk_ret_t ThrowNotCallableError(duk_context* ctx);
const char * ArgTypeName(ArgType argType);
duk_bool_t ArgTypeMatches(duk_context * ctx, duk_idx_t idx, ArgType wantType);
duk_ret_t CheckArgs(duk_context * ctx, const std::vector<ArgType> & argTypes);
duk_ret_t CheckSetterAssignment(duk_context * ctx, ArgType wantType);
void DebugStack(duk_context* ctx, const char* file, int line);
duk_ret_t ThrowInvalidArgsError(duk_context * ctx);
duk_ret_t ThrowInvalidArgError(duk_context * ctx, duk_idx_t idx, ArgType wantType);
duk_ret_t ThrowTooManyArgsError(duk_context * ctx);
duk_ret_t ThrowInvalidAssignmentError(duk_context * ctx, ArgType wantType);
duk_ret_t ThrowNotCallableError(duk_context * ctx);
// ScriptAPI_events
void Define_events(duk_context* ctx);
duk_ret_t js_events_onstatechange(duk_context* ctx);
duk_ret_t js_events_onexec(duk_context* ctx);
duk_ret_t js_events_onread(duk_context* ctx);
duk_ret_t js_events_onwrite(duk_context* ctx);
duk_ret_t js_events_onopcode(duk_context* ctx);
duk_ret_t js_events_ongprvalue(duk_context* ctx);
duk_ret_t js_events_onpifread(duk_context* ctx);
duk_ret_t js_events_onsptask(duk_context* ctx);
duk_ret_t js_events_onpidma(duk_context* ctx);
duk_ret_t js_events_onmouseup(duk_context* ctx);
duk_ret_t js_events_onmousedown(duk_context* ctx);
duk_ret_t js_events_onmousemove(duk_context* ctx);
duk_ret_t js_events_remove(duk_context* ctx);
void DebugStack(duk_context * ctx, const char * file, int line);
// ScriptAPI_console
void Define_console(duk_context* ctx);
duk_ret_t js_console_print(duk_context* ctx);
duk_ret_t js_console_log(duk_context* ctx);
duk_ret_t js_console_error(duk_context* ctx);
duk_ret_t js_console_clear(duk_context* ctx);
duk_ret_t js_console_listen(duk_context* ctx);
// ScriptAPI_events
void Define_events(duk_context * ctx);
duk_ret_t js_events_onstatechange(duk_context * ctx);
duk_ret_t js_events_onexec(duk_context * ctx);
duk_ret_t js_events_onread(duk_context * ctx);
duk_ret_t js_events_onwrite(duk_context * ctx);
duk_ret_t js_events_onopcode(duk_context * ctx);
duk_ret_t js_events_ongprvalue(duk_context * ctx);
duk_ret_t js_events_onpifread(duk_context * ctx);
duk_ret_t js_events_onsptask(duk_context * ctx);
duk_ret_t js_events_onpidma(duk_context * ctx);
duk_ret_t js_events_onmouseup(duk_context * ctx);
duk_ret_t js_events_onmousedown(duk_context * ctx);
duk_ret_t js_events_onmousemove(duk_context * ctx);
duk_ret_t js_events_remove(duk_context * ctx);
// ScriptAPI_mem
void Define_mem(duk_context* ctx);
template <class T> duk_ret_t js_mem__get(duk_context* ctx);
template <class T> duk_ret_t js_mem__set(duk_context* ctx);
duk_ret_t js_mem__boundget(duk_context* ctx);
duk_ret_t js_mem__boundset(duk_context* ctx);
duk_ret_t js_mem__type_constructor(duk_context* ctx);
duk_ret_t js_mem__get_ramsize(duk_context* ctx);
duk_ret_t js_mem__get_romsize(duk_context* ctx);
duk_ret_t js_mem__get_ptr(duk_context* ctx);
duk_ret_t js_mem_getblock(duk_context* ctx);
duk_ret_t js_mem_getstring(duk_context* ctx);
duk_ret_t js_mem_setblock(duk_context* ctx);
duk_ret_t js_mem_bindvar(duk_context* ctx);
duk_ret_t js_mem_bindvars(duk_context* ctx);
duk_ret_t js_mem_bindstruct(duk_context* ctx);
duk_ret_t js_mem_typedef(duk_context* ctx);
// ScriptAPI_console
void Define_console(duk_context * ctx);
duk_ret_t js_console_print(duk_context * ctx);
duk_ret_t js_console_log(duk_context * ctx);
duk_ret_t js_console_error(duk_context * ctx);
duk_ret_t js_console_clear(duk_context * ctx);
duk_ret_t js_console_listen(duk_context * ctx);
// ScriptAPI_Server
void Define_Server(duk_context* ctx);
duk_ret_t js_Server__constructor(duk_context* ctx);
duk_ret_t js_Server__finalizer(duk_context* ctx);
duk_ret_t js_Server__get_port(duk_context* ctx);
duk_ret_t js_Server__get_address(duk_context* ctx);
duk_ret_t js_Server__get_addressFamily(duk_context* ctx);
duk_ret_t js_Server_listen(duk_context* ctx);
duk_ret_t js_Server_close(duk_context* ctx);
// ScriptAPI_mem
void Define_mem(duk_context * ctx);
template <class T>
duk_ret_t js_mem__get(duk_context * ctx);
template <class T>
duk_ret_t js_mem__set(duk_context * ctx);
duk_ret_t js_mem__boundget(duk_context * ctx);
duk_ret_t js_mem__boundset(duk_context * ctx);
duk_ret_t js_mem__type_constructor(duk_context * ctx);
duk_ret_t js_mem__get_ramsize(duk_context * ctx);
duk_ret_t js_mem__get_romsize(duk_context * ctx);
duk_ret_t js_mem__get_ptr(duk_context * ctx);
duk_ret_t js_mem_getblock(duk_context * ctx);
duk_ret_t js_mem_getstring(duk_context * ctx);
duk_ret_t js_mem_setblock(duk_context * ctx);
duk_ret_t js_mem_bindvar(duk_context * ctx);
duk_ret_t js_mem_bindvars(duk_context * ctx);
duk_ret_t js_mem_bindstruct(duk_context * ctx);
duk_ret_t js_mem_typedef(duk_context * ctx);
// ScriptAPI_Socket
void Define_Socket(duk_context* ctx);
duk_ret_t js_Socket__constructor(duk_context* ctx);
duk_ret_t js_Socket__finalizer(duk_context* ctx);
duk_ret_t js_Socket__invokeWriteCallback(duk_context* ctx);
duk_ret_t js_Socket__invokeWriteEndCallbacks(duk_context* ctx);
duk_ret_t js_Socket_connect(duk_context* ctx);
duk_ret_t js_Socket_write(duk_context* ctx);
duk_ret_t js_Socket_end(duk_context* ctx);
duk_ret_t js_Socket_close(duk_context* ctx);
duk_ret_t js_Socket__get_localAddress(duk_context* ctx);
duk_ret_t js_Socket__get_localPort(duk_context* ctx);
duk_ret_t js_Socket__get_remoteAddress(duk_context* ctx);
duk_ret_t js_Socket__get_remotePort(duk_context* ctx);
duk_ret_t js_Socket__get_addressFamily(duk_context* ctx);
// ScriptAPI_script
void Define_script(duk_context* ctx);
duk_ret_t js_script_keepalive(duk_context* ctx);
duk_ret_t js_script_timeout(duk_context* ctx);
duk_ret_t js_script_abort(duk_context* ctx);
// ScriptAPI_Server
void Define_Server(duk_context * ctx);
duk_ret_t js_Server__constructor(duk_context * ctx);
duk_ret_t js_Server__finalizer(duk_context * ctx);
duk_ret_t js_Server__get_port(duk_context * ctx);
duk_ret_t js_Server__get_address(duk_context * ctx);
duk_ret_t js_Server__get_addressFamily(duk_context * ctx);
duk_ret_t js_Server_listen(duk_context * ctx);
duk_ret_t js_Server_close(duk_context * ctx);
// ScriptAPI_fs
void Define_fs(duk_context* ctx);
duk_ret_t js_fs_open(duk_context* ctx);
duk_ret_t js_fs_close(duk_context* ctx);
duk_ret_t js_fs_write(duk_context* ctx);
duk_ret_t js_fs_writefile(duk_context* ctx);
duk_ret_t js_fs_read(duk_context* ctx);
duk_ret_t js_fs_readfile(duk_context* ctx);
duk_ret_t js_fs_exists(duk_context* ctx);
duk_ret_t js_fs_fstat(duk_context* ctx);
duk_ret_t js_fs_stat(duk_context* ctx);
duk_ret_t js_fs_unlink(duk_context* ctx);
duk_ret_t js_fs_mkdir(duk_context* ctx);
duk_ret_t js_fs_rmdir(duk_context* ctx);
duk_ret_t js_fs_readdir(duk_context* ctx);
duk_ret_t js_fs_Stats__constructor(duk_context* ctx);
duk_ret_t js_fs_Stats_isDirectory(duk_context* ctx);
duk_ret_t js_fs_Stats_isFile(duk_context* ctx);
// ScriptAPI_Socket
void Define_Socket(duk_context * ctx);
duk_ret_t js_Socket__constructor(duk_context * ctx);
duk_ret_t js_Socket__finalizer(duk_context * ctx);
duk_ret_t js_Socket__invokeWriteCallback(duk_context * ctx);
duk_ret_t js_Socket__invokeWriteEndCallbacks(duk_context * ctx);
duk_ret_t js_Socket_connect(duk_context * ctx);
duk_ret_t js_Socket_write(duk_context * ctx);
duk_ret_t js_Socket_end(duk_context * ctx);
duk_ret_t js_Socket_close(duk_context * ctx);
duk_ret_t js_Socket__get_localAddress(duk_context * ctx);
duk_ret_t js_Socket__get_localPort(duk_context * ctx);
duk_ret_t js_Socket__get_remoteAddress(duk_context * ctx);
duk_ret_t js_Socket__get_remotePort(duk_context * ctx);
duk_ret_t js_Socket__get_addressFamily(duk_context * ctx);
// ScriptAPI_debug
void Define_debug(duk_context* ctx);
duk_ret_t js_debug__get_paused(duk_context* ctx);
duk_ret_t js_debug_breakhere(duk_context* ctx);
duk_ret_t js_debug_step(duk_context* ctx);
duk_ret_t js_debug_skip(duk_context* ctx);
duk_ret_t js_debug_resume(duk_context* ctx);
duk_ret_t js_debug_showmemory(duk_context* ctx);
duk_ret_t js_debug_showcommands(duk_context* ctx);
// ScriptAPI_script
void Define_script(duk_context * ctx);
duk_ret_t js_script_keepalive(duk_context * ctx);
duk_ret_t js_script_timeout(duk_context * ctx);
duk_ret_t js_script_abort(duk_context * ctx);
// ScriptAPI_asm
void Define_asm(duk_context* ctx);
duk_ret_t js_asm_gprname(duk_context* ctx);
duk_ret_t js_asm_encode(duk_context* ctx);
duk_ret_t js_asm_decode(duk_context* ctx);
// ScriptAPI_fs
void Define_fs(duk_context * ctx);
duk_ret_t js_fs_open(duk_context * ctx);
duk_ret_t js_fs_close(duk_context * ctx);
duk_ret_t js_fs_write(duk_context * ctx);
duk_ret_t js_fs_writefile(duk_context * ctx);
duk_ret_t js_fs_read(duk_context * ctx);
duk_ret_t js_fs_readfile(duk_context * ctx);
duk_ret_t js_fs_exists(duk_context * ctx);
duk_ret_t js_fs_fstat(duk_context * ctx);
duk_ret_t js_fs_stat(duk_context * ctx);
duk_ret_t js_fs_unlink(duk_context * ctx);
duk_ret_t js_fs_mkdir(duk_context * ctx);
duk_ret_t js_fs_rmdir(duk_context * ctx);
duk_ret_t js_fs_readdir(duk_context * ctx);
duk_ret_t js_fs_Stats__constructor(duk_context * ctx);
duk_ret_t js_fs_Stats_isDirectory(duk_context * ctx);
duk_ret_t js_fs_Stats_isFile(duk_context * ctx);
// ScriptAPI_cpu
void Define_cpu(duk_context* ctx);
duk_ret_t js_cpu_get(duk_context* ctx);
duk_ret_t js_cpu_set(duk_context* ctx);
duk_ret_t js_cpu_gpr_get(duk_context* ctx);
duk_ret_t js_cpu_gpr_set(duk_context* ctx);
duk_ret_t js_cpu_ugpr_get(duk_context* ctx);
duk_ret_t js_cpu_ugpr_set(duk_context* ctx);
duk_ret_t js_cpu_fpr_get(duk_context* ctx);
duk_ret_t js_cpu_fpr_set(duk_context* ctx);
duk_ret_t js_cpu_dfpr_get(duk_context* ctx);
duk_ret_t js_cpu_dfpr_set(duk_context* ctx);
duk_ret_t js_cpu_cop0_get(duk_context* ctx);
duk_ret_t js_cpu_cop0_set(duk_context* ctx);
// ScriptAPI_debug
void Define_debug(duk_context * ctx);
duk_ret_t js_debug__get_paused(duk_context * ctx);
duk_ret_t js_debug_breakhere(duk_context * ctx);
duk_ret_t js_debug_step(duk_context * ctx);
duk_ret_t js_debug_skip(duk_context * ctx);
duk_ret_t js_debug_resume(duk_context * ctx);
duk_ret_t js_debug_showmemory(duk_context * ctx);
duk_ret_t js_debug_showcommands(duk_context * ctx);
// ScriptAPI_pj64
void Define_pj64(duk_context* ctx);
duk_ret_t js_pj64_open(duk_context* ctx);
duk_ret_t js_pj64_close(duk_context* ctx);
duk_ret_t js_pj64_reset(duk_context* ctx);
duk_ret_t js_pj64_pause(duk_context* ctx);
duk_ret_t js_pj64_resume(duk_context* ctx);
duk_ret_t js_pj64_limitfps(duk_context* ctx);
duk_ret_t js_pj64__get_installDirectory(duk_context* ctx);
duk_ret_t js_pj64__get_scriptsDirectory(duk_context* ctx);
duk_ret_t js_pj64__get_modulesDirectory(duk_context* ctx);
duk_ret_t js_pj64__get_romDirectory(duk_context* ctx);
duk_ret_t js_pj64__get_romInfo(duk_context* ctx);
duk_ret_t js_pj64_romInfo__get_goodName(duk_context* ctx);
duk_ret_t js_pj64_romInfo__get_fileName(duk_context* ctx);
duk_ret_t js_pj64_romInfo__get_filePath(duk_context* ctx);
duk_ret_t js_pj64_romInfo__get_headerCrc1(duk_context* ctx);
duk_ret_t js_pj64_romInfo__get_headerCrc2(duk_context* ctx);
duk_ret_t js_pj64_romInfo__get_headerName(duk_context* ctx);
duk_ret_t js_pj64_romInfo__get_headerMediaFormat(duk_context* ctx);
duk_ret_t js_pj64_romInfo__get_headerId(duk_context* ctx);
duk_ret_t js_pj64_romInfo__get_headerCountryCode(duk_context* ctx);
duk_ret_t js_pj64_romInfo__get_headerVersion(duk_context* ctx);
// ScriptAPI_asm
void Define_asm(duk_context * ctx);
duk_ret_t js_asm_gprname(duk_context * ctx);
duk_ret_t js_asm_encode(duk_context * ctx);
duk_ret_t js_asm_decode(duk_context * ctx);
// ScriptAPI_AddressRange
void Define_AddressRange(duk_context* ctx);
duk_ret_t js_AddressRange__constructor(duk_context* ctx);
duk_ret_t js_AddressRange_size(duk_context* ctx);
duk_ret_t js_AddressRange_includes(duk_context* ctx);
duk_ret_t js_AddressRange_offset(duk_context* ctx);
duk_ret_t js_AddressRange_address(duk_context* ctx);
// ScriptAPI_cpu
void Define_cpu(duk_context * ctx);
duk_ret_t js_cpu_get(duk_context * ctx);
duk_ret_t js_cpu_set(duk_context * ctx);
duk_ret_t js_cpu_gpr_get(duk_context * ctx);
duk_ret_t js_cpu_gpr_set(duk_context * ctx);
duk_ret_t js_cpu_ugpr_get(duk_context * ctx);
duk_ret_t js_cpu_ugpr_set(duk_context * ctx);
duk_ret_t js_cpu_fpr_get(duk_context * ctx);
duk_ret_t js_cpu_fpr_set(duk_context * ctx);
duk_ret_t js_cpu_dfpr_get(duk_context * ctx);
duk_ret_t js_cpu_dfpr_set(duk_context * ctx);
duk_ret_t js_cpu_cop0_get(duk_context * ctx);
duk_ret_t js_cpu_cop0_set(duk_context * ctx);
// ScriptAPI_Number_hex
void Define_Number_prototype_hex(duk_context* ctx);
duk_ret_t js_Number_prototype_hex(duk_context* ctx);
// ScriptAPI_pj64
void Define_pj64(duk_context * ctx);
duk_ret_t js_pj64_open(duk_context * ctx);
duk_ret_t js_pj64_close(duk_context * ctx);
duk_ret_t js_pj64_reset(duk_context * ctx);
duk_ret_t js_pj64_pause(duk_context * ctx);
duk_ret_t js_pj64_resume(duk_context * ctx);
duk_ret_t js_pj64_limitfps(duk_context * ctx);
duk_ret_t js_pj64__get_installDirectory(duk_context * ctx);
duk_ret_t js_pj64__get_scriptsDirectory(duk_context * ctx);
duk_ret_t js_pj64__get_modulesDirectory(duk_context * ctx);
duk_ret_t js_pj64__get_romDirectory(duk_context * ctx);
duk_ret_t js_pj64__get_romInfo(duk_context * ctx);
duk_ret_t js_pj64_romInfo__get_goodName(duk_context * ctx);
duk_ret_t js_pj64_romInfo__get_fileName(duk_context * ctx);
duk_ret_t js_pj64_romInfo__get_filePath(duk_context * ctx);
duk_ret_t js_pj64_romInfo__get_headerCrc1(duk_context * ctx);
duk_ret_t js_pj64_romInfo__get_headerCrc2(duk_context * ctx);
duk_ret_t js_pj64_romInfo__get_headerName(duk_context * ctx);
duk_ret_t js_pj64_romInfo__get_headerMediaFormat(duk_context * ctx);
duk_ret_t js_pj64_romInfo__get_headerId(duk_context * ctx);
duk_ret_t js_pj64_romInfo__get_headerCountryCode(duk_context * ctx);
duk_ret_t js_pj64_romInfo__get_headerVersion(duk_context * ctx);
// ScriptAPI_N64Image
void Define_N64Image(duk_context* ctx);
duk_ret_t js_N64Image__constructor(duk_context* ctx);
duk_ret_t js_N64Image__finalizer(duk_context* ctx);
duk_ret_t js_N64Image_static_fromPNG(duk_context* ctx);
duk_ret_t js_N64Image_static_format(duk_context* ctx);
duk_ret_t js_N64Image_static_bpp(duk_context* ctx);
duk_ret_t js_N64Image_toPNG(duk_context* ctx);
duk_ret_t js_N64Image_update(duk_context* ctx);
// ScriptAPI_AddressRange
void Define_AddressRange(duk_context * ctx);
duk_ret_t js_AddressRange__constructor(duk_context * ctx);
duk_ret_t js_AddressRange_size(duk_context * ctx);
duk_ret_t js_AddressRange_includes(duk_context * ctx);
duk_ret_t js_AddressRange_offset(duk_context * ctx);
duk_ret_t js_AddressRange_address(duk_context * ctx);
// ScriptAPI_exec
void Define_exec(duk_context* ctx);
duk_ret_t js_exec(duk_context* ctx);
// ScriptAPI_Number_hex
void Define_Number_prototype_hex(duk_context * ctx);
duk_ret_t js_Number_prototype_hex(duk_context * ctx);
// ScriptAPI_alert
void Define_alert(duk_context* ctx);
duk_ret_t js_alert(duk_context* ctx);
// ScriptAPI_N64Image
void Define_N64Image(duk_context * ctx);
duk_ret_t js_N64Image__constructor(duk_context * ctx);
duk_ret_t js_N64Image__finalizer(duk_context * ctx);
duk_ret_t js_N64Image_static_fromPNG(duk_context * ctx);
duk_ret_t js_N64Image_static_format(duk_context * ctx);
duk_ret_t js_N64Image_static_bpp(duk_context * ctx);
duk_ret_t js_N64Image_toPNG(duk_context * ctx);
duk_ret_t js_N64Image_update(duk_context * ctx);
// ScriptAPI_interval
void Define_interval(duk_context* ctx);
duk_ret_t js_setInterval(duk_context* ctx);
duk_ret_t js_clearInterval(duk_context* ctx);
duk_ret_t js_setTimeout(duk_context* ctx);
duk_ret_t js_clearTimeout(duk_context* ctx);
duk_ret_t js__IntervalContext_invokeFunc(duk_context* ctx);
duk_ret_t js__IntervalContext_remove(duk_context* ctx);
duk_ret_t js__IntervalContext_finalizer(duk_context* ctx);
// ScriptAPI_exec
void Define_exec(duk_context * ctx);
duk_ret_t js_exec(duk_context * ctx);
enum {
R0, AT, V0, V1, A0, A1, A2, A3,
T0, T1, T2, T3, T4, T5, T6, T7,
S0, S1, S2, S3, S4, S5, S6, S7,
T8, T9, K0, K1, GP, SP, FP, RA,
//S8 = FP
};
// ScriptAPI_alert
void Define_alert(duk_context * ctx);
duk_ret_t js_alert(duk_context * ctx);
enum {
GPR_R0 = (1 << R0),
GPR_AT = (1 << AT),
GPR_V0 = (1 << V0),
GPR_V1 = (1 << V1),
GPR_A0 = (1 << A0),
GPR_A1 = (1 << A1),
GPR_A2 = (1 << A2),
GPR_A3 = (1 << A3),
GPR_T0 = (1 << T0),
GPR_T1 = (1 << T1),
GPR_T2 = (1 << T2),
GPR_T3 = (1 << T3),
GPR_T4 = (1 << T4),
GPR_T5 = (1 << T5),
GPR_T6 = (1 << T6),
GPR_T7 = (1 << T7),
GPR_S0 = (1 << S0),
GPR_S1 = (1 << S1),
GPR_S2 = (1 << S2),
GPR_S3 = (1 << S3),
GPR_S4 = (1 << S4),
GPR_S5 = (1 << S5),
GPR_S6 = (1 << S6),
GPR_S7 = (1 << S7),
GPR_T8 = (1 << T8),
GPR_T9 = (1 << T9),
GPR_K0 = (1 << K0),
GPR_K1 = (1 << K1),
GPR_GP = (1 << GP),
GPR_SP = (1 << SP),
GPR_FP = (1 << FP),
GPR_RA = (1 << RA),
//GPR_S8 = GPR_FP,
GPR_ANY = 0xFFFFFFFF
};
// ScriptAPI_interval
void Define_interval(duk_context * ctx);
duk_ret_t js_setInterval(duk_context * ctx);
duk_ret_t js_clearInterval(duk_context * ctx);
duk_ret_t js_setTimeout(duk_context * ctx);
duk_ret_t js_clearTimeout(duk_context * ctx);
duk_ret_t js__IntervalContext_invokeFunc(duk_context * ctx);
duk_ret_t js__IntervalContext_remove(duk_context * ctx);
duk_ret_t js__IntervalContext_finalizer(duk_context * ctx);
enum
{
R0,
AT,
V0,
V1,
A0,
A1,
A2,
A3,
T0,
T1,
T2,
T3,
T4,
T5,
T6,
T7,
S0,
S1,
S2,
S3,
S4,
S5,
S6,
S7,
T8,
T9,
K0,
K1,
GP,
SP,
FP,
RA,
//S8 = FP
};
enum
{
GPR_R0 = (1 << R0),
GPR_AT = (1 << AT),
GPR_V0 = (1 << V0),
GPR_V1 = (1 << V1),
GPR_A0 = (1 << A0),
GPR_A1 = (1 << A1),
GPR_A2 = (1 << A2),
GPR_A3 = (1 << A3),
GPR_T0 = (1 << T0),
GPR_T1 = (1 << T1),
GPR_T2 = (1 << T2),
GPR_T3 = (1 << T3),
GPR_T4 = (1 << T4),
GPR_T5 = (1 << T5),
GPR_T6 = (1 << T6),
GPR_T7 = (1 << T7),
GPR_S0 = (1 << S0),
GPR_S1 = (1 << S1),
GPR_S2 = (1 << S2),
GPR_S3 = (1 << S3),
GPR_S4 = (1 << S4),
GPR_S5 = (1 << S5),
GPR_S6 = (1 << S6),
GPR_S7 = (1 << S7),
GPR_T8 = (1 << T8),
GPR_T9 = (1 << T9),
GPR_K0 = (1 << K0),
GPR_K1 = (1 << K1),
GPR_GP = (1 << GP),
GPR_SP = (1 << SP),
GPR_FP = (1 << FP),
GPR_RA = (1 << RA),
//GPR_S8 = GPR_FP,
GPR_ANY = 0xFFFFFFFF
};
#define DUK_TYPE_ID(id) \
static const DukPropTypeID _TYPE = DukPropTypeID::Type_ ## id;
static const DukPropTypeID _TYPE = DukPropTypeID::Type_##id;
#define DUK_DECLVAL_MEMBER(structName, memberName) \
structName memberName; Value(structName v) : memberName(v) {}
structName memberName; \
Value(structName v) : memberName(v) \
{ \
}
#define DUK_SCALARTYPE_IMPL(structName, primitiveType) \
DUK_TYPE_ID(structName) primitiveType value; structName(primitiveType value) : value(value){}
DUK_TYPE_ID(structName) \
primitiveType value; \
structName(primitiveType value) : value(value) \
{ \
}
enum DukPropTypeID
{
Type_DukInt,
Type_DukUInt,
Type_DukNumber,
Type_DukString,
Type_DukBoolean,
Type_DukPointer,
Type_DukCFunction,
Type_DukDupIndex,
Type_DukGetter,
Type_DukGetterSetter,
Type_DukObject,
Type_DukProxy
};
struct DukInt { DUK_SCALARTYPE_IMPL(DukInt, duk_int_t) };
struct DukUInt { DUK_SCALARTYPE_IMPL(DukUInt, duk_uint_t) };
struct DukNumber { DUK_SCALARTYPE_IMPL(DukNumber, duk_double_t) };
struct DukBoolean { DUK_SCALARTYPE_IMPL(DukBoolean, duk_bool_t) };
struct DukString { DUK_SCALARTYPE_IMPL(DukString, const char*) };
struct DukPointer { DUK_SCALARTYPE_IMPL(DukPointer, void*) };
struct DukDupIndex { DUK_SCALARTYPE_IMPL(DukDupIndex, duk_idx_t) };
//struct DukObject { DUK_SCALARTYPE_IMPL(DukObject, duk_idx_t) };
struct DukCFunction {
DUK_TYPE_ID(DukCFunction)
duk_c_function func;
duk_int_t nargs;
DukCFunction(duk_c_function func, duk_int_t nargs = DUK_VARARGS) :
func(func), nargs(nargs) {}
};
struct DukObject {
DUK_TYPE_ID(DukObject)
const DukPropListEntry* props;
DukObject(const DukPropListEntry* props = nullptr) :
props(props) {}
};
struct DukGetter {
DUK_SCALARTYPE_IMPL(DukGetter, duk_c_function)
};
struct DukGetterSetter {
DUK_TYPE_ID(DukGetterSetter)
duk_c_function getter, setter;
DukGetterSetter(duk_c_function getter, duk_c_function setter) :
getter(getter), setter(setter) {}
};
struct DukProxy {
DUK_TYPE_ID(DukProxy)
duk_c_function getter, setter;
DukProxy(duk_c_function getter, duk_c_function setter) :
getter(getter), setter(setter) {}
};
struct DukPropListEntry
{
const char* key;
DukPropTypeID typeId;
bool writable, enumerable;
union Value {
DUK_DECLVAL_MEMBER(DukInt, dukInt)
DUK_DECLVAL_MEMBER(DukUInt, dukUInt)
DUK_DECLVAL_MEMBER(DukNumber, dukNumber)
DUK_DECLVAL_MEMBER(DukBoolean, dukBoolean)
DUK_DECLVAL_MEMBER(DukString, dukString)
DUK_DECLVAL_MEMBER(DukPointer, dukPointer)
DUK_DECLVAL_MEMBER(DukCFunction, dukCFunction)
DUK_DECLVAL_MEMBER(DukGetter, dukGetter)
DUK_DECLVAL_MEMBER(DukGetterSetter, dukGetterSetter)
DUK_DECLVAL_MEMBER(DukDupIndex, dukDupIndex)
DUK_DECLVAL_MEMBER(DukObject, dukObject)
DUK_DECLVAL_MEMBER(DukProxy, dukProxy)
} value;
template<class T>
DukPropListEntry(const char* key, T value, bool writable = false, bool enumerable = true) :
key(key), typeId(T::_TYPE), writable(writable), enumerable(enumerable), value(value) {}
DukPropListEntry(nullptr_t) :
key(nullptr), value(DukInt(0)) {}
DukPropListEntry(const char* key) :
key(key), typeId(Type_DukInt), writable(false), enumerable(false), value(DukInt(0)) {}
};
// todo proxy object
// todo DukObjectConfig_DummyConstructor
// todo DukObjectConfig_Finalizer
// todo DukObjectConfig_Freeze
void DukPutPropList(duk_context* ctx, duk_idx_t obj_idx, const DukPropListEntry* props);
enum DukPropTypeID
{
Type_DukInt,
Type_DukUInt,
Type_DukNumber,
Type_DukString,
Type_DukBoolean,
Type_DukPointer,
Type_DukCFunction,
Type_DukDupIndex,
Type_DukGetter,
Type_DukGetterSetter,
Type_DukObject,
Type_DukProxy
};
struct DukInt
{
DUK_SCALARTYPE_IMPL(DukInt, duk_int_t)
};
struct DukUInt
{
DUK_SCALARTYPE_IMPL(DukUInt, duk_uint_t)
};
struct DukNumber
{
DUK_SCALARTYPE_IMPL(DukNumber, duk_double_t)
};
struct DukBoolean
{
DUK_SCALARTYPE_IMPL(DukBoolean, duk_bool_t)
};
struct DukString
{
DUK_SCALARTYPE_IMPL(DukString, const char *)
};
struct DukPointer
{
DUK_SCALARTYPE_IMPL(DukPointer, void *)
};
struct DukDupIndex
{
DUK_SCALARTYPE_IMPL(DukDupIndex, duk_idx_t)
};
//struct DukObject { DUK_SCALARTYPE_IMPL(DukObject, duk_idx_t) };
struct DukCFunction
{
DUK_TYPE_ID(DukCFunction)
duk_c_function func;
duk_int_t nargs;
DukCFunction(duk_c_function func, duk_int_t nargs = DUK_VARARGS) :
func(func), nargs(nargs)
{
}
};
struct DukObject
{
DUK_TYPE_ID(DukObject)
const DukPropListEntry * props;
DukObject(const DukPropListEntry * props = nullptr) :
props(props)
{
}
};
struct DukGetter
{
DUK_SCALARTYPE_IMPL(DukGetter, duk_c_function)
};
struct DukGetterSetter
{
DUK_TYPE_ID(DukGetterSetter)
duk_c_function getter, setter;
DukGetterSetter(duk_c_function getter, duk_c_function setter) :
getter(getter), setter(setter)
{
}
};
struct DukProxy
{
DUK_TYPE_ID(DukProxy)
duk_c_function getter, setter;
DukProxy(duk_c_function getter, duk_c_function setter) :
getter(getter), setter(setter)
{
}
};
struct DukPropListEntry
{
const char * key;
DukPropTypeID typeId;
bool writable, enumerable;
union Value
{
DUK_DECLVAL_MEMBER(DukInt, dukInt)
DUK_DECLVAL_MEMBER(DukUInt, dukUInt)
DUK_DECLVAL_MEMBER(DukNumber, dukNumber)
DUK_DECLVAL_MEMBER(DukBoolean, dukBoolean)
DUK_DECLVAL_MEMBER(DukString, dukString)
DUK_DECLVAL_MEMBER(DukPointer, dukPointer)
DUK_DECLVAL_MEMBER(DukCFunction, dukCFunction)
DUK_DECLVAL_MEMBER(DukGetter, dukGetter)
DUK_DECLVAL_MEMBER(DukGetterSetter, dukGetterSetter)
DUK_DECLVAL_MEMBER(DukDupIndex, dukDupIndex)
DUK_DECLVAL_MEMBER(DukObject, dukObject)
DUK_DECLVAL_MEMBER(DukProxy, dukProxy)
} value;
template <class T>
DukPropListEntry(const char * key, T value, bool writable = false, bool enumerable = true) :
key(key), typeId(T::_TYPE), writable(writable), enumerable(enumerable), value(value)
{
}
DukPropListEntry(nullptr_t) :
key(nullptr), value(DukInt(0))
{
}
DukPropListEntry(const char * key) :
key(key), typeId(Type_DukInt), writable(false), enumerable(false), value(DukInt(0))
{
}
};
// todo proxy object
// todo DukObjectConfig_DummyConstructor
// todo DukObjectConfig_Finalizer
// todo DukObjectConfig_Freeze
void DukPutPropList(duk_context * ctx, duk_idx_t obj_idx, const DukPropListEntry * props);
}; // namespace ScriptAPI

View File

@ -13,7 +13,7 @@ void ScriptAPI::Define_AddressRange(duk_context * ctx)
{"includes", DukCFunction(js_AddressRange_includes)},
{"offset", DukCFunction(js_AddressRange_offset)},
{"address", DukCFunction(js_AddressRange_address)},
{ nullptr }
{nullptr},
};
DefineGlobalClass(ctx, "AddressRange", js_AddressRange__constructor, prototype);
@ -32,9 +32,9 @@ void ScriptAPI::Define_AddressRange(duk_context * ctx)
{"ADDR_ANY_RDRAM_UNC", 0xA0000000, 0xA07FFFFF},
{"ADDR_ANY_CART_ROM", 0x90000000, 0x95FFFFFF},
{"ADDR_ANY_CART_ROM_UNC", 0xB0000000, 0xB5FFFFFF},
{ nullptr, 0, 0 }
{nullptr, 0, 0},
};
duk_push_global_object(ctx);
for (int i = 0; ranges[i].key != nullptr; i++)

View File

@ -28,14 +28,14 @@ void ScriptAPI::Define_N64Image(duk_context * ctx)
const DukPropListEntry prototype[] = {
{"toPNG", DukCFunction(js_N64Image_toPNG)},
{"update", DukCFunction(js_N64Image_update)},
{ nullptr}
{nullptr},
};
const DukPropListEntry staticProps[] = {
{"fromPNG", DukCFunction(js_N64Image_static_fromPNG)},
{"format", DukCFunction(js_N64Image_static_format)},
{"bpp", DukCFunction(js_N64Image_static_bpp)},
{ nullptr }
{nullptr},
};
DefineGlobalClass(ctx, "N64Image", js_N64Image__constructor, prototype, staticProps);
@ -72,7 +72,7 @@ static void InitImageObjectProps(duk_context * ctx, duk_idx_t idx, CN64Image * i
{"palette", DukDupIndex(palette_idx)},
{"width", DukUInt(image->Width())},
{"height", DukUInt(image->Height())},
{ nullptr }
{nullptr},
};
DukPutPropList(ctx, idx, props);

View File

@ -15,9 +15,9 @@ void ScriptAPI::Define_Server(duk_context * ctx)
{"port", DukGetter(js_Server__get_port)},
{"address", DukGetter(js_Server__get_address)},
{"addressFamily", DukGetter(js_Server__get_addressFamily)},
{ nullptr }
{nullptr},
};
DefineGlobalClass(ctx, "Server", js_Server__constructor, prototype);
}

View File

@ -24,7 +24,7 @@ void ScriptAPI::Define_Socket(duk_context * ctx)
{"remoteAddress", DukGetter(js_Socket__get_remoteAddress)},
{"remotePort", DukGetter(js_Socket__get_remotePort)},
{"addressFamily", DukGetter(js_Socket__get_addressFamily)},
{ nullptr }
{nullptr},
};
DefineGlobalClass(ctx, "Socket", js_Socket__constructor, prototype, nullptr);

View File

@ -10,7 +10,7 @@ void ScriptAPI::Define_asm(duk_context * ctx)
{"gprname", DukCFunction(js_asm_gprname)},
{"encode", DukCFunction(js_asm_encode)},
{"decode", DukCFunction(js_asm_decode)},
{ nullptr }
{nullptr},
};
DefineGlobalInterface(ctx, "asm", props);
@ -19,10 +19,38 @@ void ScriptAPI::Define_asm(duk_context * ctx)
duk_ret_t ScriptAPI::js_asm_gprname(duk_context * ctx)
{
const char * names[32] = {
"r0", "at", "v0", "v1", "a0", "a1", "a2", "a3",
"t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7",
"s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7",
"t8", "t9", "k0", "k1", "gp", "sp", "fp", "ra"
"r0",
"at",
"v0",
"v1",
"a0",
"a1",
"a2",
"a3",
"t0",
"t1",
"t2",
"t3",
"t4",
"t5",
"t6",
"t7",
"s0",
"s1",
"s2",
"s3",
"s4",
"s5",
"s6",
"s7",
"t8",
"t9",
"k0",
"k1",
"gp",
"sp",
"fp",
"ra",
};
CheckArgs(ctx, {Arg_Number});

View File

@ -13,7 +13,7 @@ void ScriptAPI::Define_console(duk_context * ctx)
{"error", DukCFunction(js_console_error)},
{"clear", DukCFunction(js_console_clear)},
{"listen", DukCFunction(js_console_listen)},
{ nullptr }
{nullptr},
};
DefineGlobalInterface(ctx, "console", props);

View File

@ -39,7 +39,7 @@ void ScriptAPI::Define_cpu(duk_context * ctx)
{"fpr", REG_PROXY_FUNCTIONS(js_cpu_fpr_get, js_cpu_fpr_set)},
{"dfpr", REG_PROXY_FUNCTIONS(js_cpu_dfpr_get, js_cpu_dfpr_set)},
{"cop0", REG_PROXY_FUNCTIONS(js_cpu_cop0_get, js_cpu_cop0_set)},
{ nullptr, nullptr }
{nullptr, nullptr},
};
const duk_function_list_entry cpufuncs[] = REG_PROXY_FUNCTIONS(js_cpu_get, js_cpu_set);
@ -368,10 +368,38 @@ static duk_ret_t FPRSetImpl(duk_context * ctx, bool bDouble)
static int GPRIndex(const char * regName)
{
const char * names[] = {
"r0", "at", "v0", "v1", "a0", "a1", "a2", "a3",
"t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7",
"s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7",
"t8", "t9", "k0", "k1", "gp", "sp", "fp", "ra"
"r0",
"at",
"v0",
"v1",
"a0",
"a1",
"a2",
"a3",
"t0",
"t1",
"t2",
"t3",
"t4",
"t5",
"t6",
"t7",
"s0",
"s1",
"s2",
"s3",
"s4",
"s5",
"s6",
"s7",
"t8",
"t9",
"k0",
"k1",
"gp",
"sp",
"fp",
"ra",
};
for (int i = 0; i < 32; i++)
@ -388,10 +416,38 @@ static int GPRIndex(const char * regName)
static int FPRIndex(const char * regName)
{
const char * names[32] = {
"f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8",
"f9", "f10", "f11", "f12", "f13", "f14", "f15", "f16",
"f17", "f18", "f19", "f20", "f21", "f22", "f23", "f24",
"f25", "f26", "f27", "f28", "f29", "f30", "f31"
"f0",
"f1",
"f2",
"f3",
"f4",
"f5",
"f6",
"f7",
"f8",
"f9",
"f10",
"f11",
"f12",
"f13",
"f14",
"f15",
"f16",
"f17",
"f18",
"f19",
"f20",
"f21",
"f22",
"f23",
"f24",
"f25",
"f26",
"f27",
"f28",
"f29",
"f30",
"f31",
};
for (int i = 0; i < 32; i++)
@ -435,9 +491,9 @@ static uint32_t * COP0RegPtr(const char * regName)
{"taglo", (uint32_t *)&g_Reg->TAGLO_REGISTER},
{"taghi", (uint32_t *)&g_Reg->TAGHI_REGISTER},
{"errorepc", (uint32_t *)&g_Reg->ERROREPC_REGISTER},
{ nullptr, nullptr }
{nullptr, nullptr},
};
for (int i = 0; names[i].name != nullptr; i++)
{
if (strcmp(regName, names[i].name) == 0)

View File

@ -12,8 +12,8 @@ void ScriptAPI::Define_debug(duk_context * ctx)
{"resume", DukCFunction(js_debug_resume)},
{"showmemory", DukCFunction(js_debug_showmemory)},
{"showcommands", DukCFunction(js_debug_showcommands)},
{ "paused", DukGetter(js_debug__get_paused) },
{ nullptr }
{"paused", DukGetter(js_debug__get_paused)},
{nullptr},
};
DefineGlobalInterface(ctx, "debug", props);
@ -35,8 +35,7 @@ duk_ret_t ScriptAPI::js_debug_step(duk_context * ctx)
{
CheckArgs(ctx, {});
if (g_Settings->LoadBool(Debugger_SteppingOps) &&
CDebugSettings::WaitingForStep())
if (g_Settings->LoadBool(Debugger_SteppingOps) && CDebugSettings::WaitingForStep())
{
g_Settings->SaveBool(Debugger_SilentBreak, true);
GetInstance(ctx)->Debugger()->StepEvent().Trigger();
@ -50,8 +49,7 @@ duk_ret_t ScriptAPI::js_debug_skip(duk_context * ctx)
g_Settings->SaveBool(Debugger_SkipOp, true);
if (g_Settings->LoadBool(Debugger_SteppingOps) &&
CDebugSettings::WaitingForStep())
if (g_Settings->LoadBool(Debugger_SteppingOps) && CDebugSettings::WaitingForStep())
{
GetInstance(ctx)->Debugger()->StepEvent().Trigger();
}

View File

@ -43,7 +43,7 @@ void ScriptAPI::Define_events(duk_context * ctx)
{"onmousedown", DukCFunction(js_events_onmousedown)},
{"onmousemove", DukCFunction(js_events_onmousemove)},
{"remove", DukCFunction(js_events_remove)},
{ nullptr }
{nullptr},
};
DefineGlobalInterface(ctx, "events", props);
@ -63,7 +63,7 @@ void ScriptAPI::Define_events(duk_context * ctx)
{"LEFT", DukNumber(0)},
{"MIDDLE", DukNumber(1)},
{"RIGHT", DukNumber(2)},
{nullptr}
{nullptr},
};
DefineGlobalClass(ctx, "MouseEvent", js_DummyConstructor, nullptr, mouseEventStaticProps);
@ -266,8 +266,7 @@ bool CbCond_ReadAddrBetween(JSAppCallback * cb, void * _env)
uint32_t addr = env->opInfo.GetLoadStoreAddress();
return (addr >= cb->m_Params.addrStart &&
addr <= cb->m_Params.addrEnd);
return (addr >= cb->m_Params.addrStart && addr <= cb->m_Params.addrEnd);
}
bool CbCond_WriteAddrBetween(JSAppCallback * cb, void * _env)
@ -281,15 +280,13 @@ bool CbCond_WriteAddrBetween(JSAppCallback * cb, void * _env)
uint32_t addr = env->opInfo.GetLoadStoreAddress();
return (addr >= cb->m_Params.addrStart &&
addr <= cb->m_Params.addrEnd);
return (addr >= cb->m_Params.addrStart && addr <= cb->m_Params.addrEnd);
}
bool CbCond_PcBetween(JSAppCallback * cb, void * _env)
{
JSHookCpuStepEnv * env = (JSHookCpuStepEnv *)_env;
return (env->pc >= cb->m_Params.addrStart &&
env->pc <= cb->m_Params.addrEnd);
return (env->pc >= cb->m_Params.addrStart && env->pc <= cb->m_Params.addrEnd);
}
bool CbCond_PcBetween_OpcodeEquals(JSAppCallback * cb, void * _env)
@ -337,7 +334,7 @@ duk_idx_t CbArgs_EmuStateChangeEventObject(duk_context * ctx, void * _env)
const DukPropListEntry props[] = {
{"callbackId", DukUInt(inst->CallbackId())},
{"state", DukUInt(env->state)},
{ nullptr }
{nullptr},
};
DukPutPropList(ctx, -1, props);
@ -353,7 +350,7 @@ duk_idx_t CbArgs_GenericEventObject(duk_context * ctx, void * /*_env*/)
const DukPropListEntry props[] = {
{"callbackId", DukUInt(inst->CallbackId())},
{ nullptr }
{nullptr},
};
DukPutPropList(ctx, -1, props);
@ -371,7 +368,7 @@ duk_idx_t CbArgs_ExecEventObject(duk_context * ctx, void * _env)
const DukPropListEntry props[] = {
{"callbackId", DukUInt(inst->CallbackId())},
{"pc", DukUInt(env->pc)},
{ nullptr }
{nullptr},
};
DukPutPropList(ctx, -1, props);
@ -400,7 +397,7 @@ duk_idx_t CbArgs_ReadEventObject(duk_context * ctx, void * _env)
{"address", DukUInt(address)},
{"reg", DukUInt(rt)},
{"fpu", DukBoolean(bFPU)},
{ nullptr }
{nullptr},
};
DukPutPropList(ctx, -1, props);
@ -470,7 +467,7 @@ duk_idx_t CbArgs_ReadEventObject(duk_context * ctx, void * _env)
bNeedUpper32 = true;
break;
case R4300i_LDL:
{
{
int shift = (address & 7) * 8;
uint64_t mask = ~(((uint64_t)-1) << shift);
debugger->DebugLoad_VAddr(address & ~7, value.u64);
@ -478,10 +475,10 @@ duk_idx_t CbArgs_ReadEventObject(duk_context * ctx, void * _env)
duk_push_number(ctx, (duk_double_t)(value.u64 & 0xFFFFFFFF));
duk_push_int(ctx, U64);
bNeedUpper32 = true;
}
break;
}
case R4300i_LDR:
{
{
int shift = 56 - ((address & 7) * 8);
uint64_t mask = ~(((uint64_t)-1) >> shift);
debugger->DebugLoad_VAddr(address & ~7, value.u64);
@ -489,28 +486,28 @@ duk_idx_t CbArgs_ReadEventObject(duk_context * ctx, void * _env)
duk_push_number(ctx, (duk_double_t)(value.u64 & 0xFFFFFFFF));
duk_push_int(ctx, U64);
bNeedUpper32 = true;
}
break;
}
case R4300i_LWL:
{
{
int shift = (address & 3) * 8;
uint32_t mask = ~(((uint32_t)-1) << shift);
debugger->DebugLoad_VAddr(address & ~3, value.s32);
value.s32 = (g_Reg->m_GPR[rt].W[0] & mask) + (value.s32 << shift);
duk_push_number(ctx, value.s32);
duk_push_int(ctx, S32);
}
break;
}
case R4300i_LWR:
{
{
int shift = 24 - ((address & 3) * 8);
uint32_t mask = ~(((uint32_t)-1) >> shift);
debugger->DebugLoad_VAddr(address & ~3, value.s32);
value.s32 = (g_Reg->m_GPR[rt].W[0] & mask) + (value.s32 >> shift);
duk_push_number(ctx, value.s32);
duk_push_int(ctx, S32);
}
break;
}
default:
duk_push_number(ctx, 0);
duk_push_number(ctx, 0);
@ -551,7 +548,7 @@ duk_idx_t CbArgs_WriteEventObject(duk_context * ctx, void * _env)
{"address", DukUInt(address)},
{"reg", DukUInt(rt)},
{"fpu", DukBoolean(bFPU)},
{ nullptr }
{nullptr},
};
DukPutPropList(ctx, -1, props);
@ -587,7 +584,7 @@ duk_idx_t CbArgs_WriteEventObject(duk_context * ctx, void * _env)
bNeedUpper32 = true;
break;
case R4300i_SWL:
{
{
int shift = (address & 3) * 8;
uint32_t mask = ~(((uint32_t)-1) >> shift);
uint32_t value;
@ -595,10 +592,10 @@ duk_idx_t CbArgs_WriteEventObject(duk_context * ctx, void * _env)
value = (value & mask) + (g_Reg->m_GPR[rt].UW[0] >> shift);
duk_push_number(ctx, value);
duk_push_int(ctx, S32);
}
break;
}
case R4300i_SWR:
{
{
int shift = 24 - ((address & 3) * 8);
uint32_t mask = ~(((uint32_t)-1) << shift);
uint32_t value;
@ -606,17 +603,18 @@ duk_idx_t CbArgs_WriteEventObject(duk_context * ctx, void * _env)
value = (value & mask) + (g_Reg->m_GPR[rt].UW[0] >> shift);
duk_push_number(ctx, value);
duk_push_int(ctx, S32);
}
break;
}
case R4300i_SDL:
{
{
int shift = (address & 7) * 8;
uint64_t mask = ~(((uint64_t)-1) >> shift);
debugger->DebugLoad_VAddr(address & ~7, value64);
value64 = (value64 & mask) + (g_Reg->m_GPR[rt].UDW >> shift);
duk_push_number(ctx, (duk_double_t)(value64 & 0xFFFFFFFF));
duk_push_int(ctx, U64);
}
break;
}
case R4300i_SDR:
{
int shift = 56 - ((address & 7) * 8);
@ -625,6 +623,7 @@ duk_idx_t CbArgs_WriteEventObject(duk_context * ctx, void * _env)
value64 = (value64 & mask) + (g_Reg->m_GPR[rt].UDW >> shift);
duk_push_number(ctx, (duk_double_t)(value64 & 0xFFFFFFFF));
duk_push_int(ctx, U64);
break;
}
default:
duk_push_number(ctx, 0);
@ -657,7 +656,7 @@ duk_idx_t CbArgs_OpcodeEventObject(duk_context * ctx, void * _env)
{"callbackId", DukUInt(inst->CallbackId())},
{"pc", DukUInt(env->pc)},
{"opcode", DukUInt(env->opInfo.m_OpCode.Value)},
{ nullptr }
{nullptr},
};
DukPutPropList(ctx, -1, props);
@ -677,7 +676,7 @@ duk_idx_t CbArgs_RegValueEventObject(duk_context * ctx, void * _env)
{"pc", DukUInt(env->pc)},
{"value", DukUInt(g_Reg->m_GPR[env->outAffectedRegIndex].UW[0])},
{"reg", DukUInt(env->outAffectedRegIndex)},
{ nullptr }
{nullptr},
};
DukPutPropList(ctx, -1, props);
@ -697,9 +696,9 @@ static duk_idx_t CbArgs_MouseEventObject(duk_context * ctx, void * _env)
{"button", DukInt(env->button)},
{"x", DukInt(env->x)},
{"y", DukInt(env->y)},
{ nullptr }
{nullptr},
};
DukPutPropList(ctx, -1, props);
duk_freeze(ctx, -1);
return 1;
@ -730,7 +729,7 @@ static duk_idx_t CbArgs_SPTaskEventObject(duk_context * ctx, void * _env)
{"dataSize", DukUInt(env->dataSize)},
{"yieldDataAddress", DukUInt(env->yieldDataAddress | 0x80000000)},
{"yieldDataSize", DukUInt(env->yieldDataSize)},
{ nullptr }
{nullptr},
};
DukPutPropList(ctx, -1, props);
@ -751,7 +750,7 @@ static duk_idx_t CbArgs_PIEventObject(duk_context * ctx, void * _env)
{"dramAddress", DukUInt(env->dramAddress | 0x80000000)},
{"cartAddress", DukUInt(env->cartAddress | 0xA0000000)},
{"length", DukUInt(env->length + 1)},
{ nullptr }
{nullptr},
};
DukPutPropList(ctx, -1, props);
@ -778,8 +777,7 @@ duk_ret_t RequireAddressOrAddressRange(duk_context * ctx, duk_idx_t idx, uint32_
if (duk_is_object(ctx, idx))
{
if (!duk_has_prop_string(ctx, idx, "start") ||
!duk_has_prop_string(ctx, idx, "end"))
if (!duk_has_prop_string(ctx, idx, "start") || !duk_has_prop_string(ctx, idx, "end"))
{
duk_push_error_object(ctx, DUK_ERR_REFERENCE_ERROR,
"object is missing 'start' or 'end' property");
@ -789,8 +787,7 @@ duk_ret_t RequireAddressOrAddressRange(duk_context * ctx, duk_idx_t idx, uint32_
duk_get_prop_string(ctx, idx, "start");
duk_get_prop_string(ctx, idx, "end");
if (!duk_is_number(ctx, -2) ||
!duk_is_number(ctx, -1))
if (!duk_is_number(ctx, -2) || !duk_is_number(ctx, -1))
{
duk_pop_n(ctx, 2);
duk_push_error_object(ctx, DUK_ERR_REFERENCE_ERROR,
@ -798,8 +795,7 @@ duk_ret_t RequireAddressOrAddressRange(duk_context * ctx, duk_idx_t idx, uint32_
return duk_throw(ctx);
}
if (abs(duk_get_number(ctx, -2)) > 0xFFFFFFFF ||
abs(duk_get_number(ctx, -1)) > 0xFFFFFFFF)
if (abs(duk_get_number(ctx, -2)) > 0xFFFFFFFF || abs(duk_get_number(ctx, -1)) > 0xFFFFFFFF)
{
duk_push_error_object(ctx, DUK_ERR_RANGE_ERROR,
"'start' or 'end' property out of range");
@ -819,8 +815,7 @@ duk_ret_t RequireAddressOrAddressRange(duk_context * ctx, duk_idx_t idx, uint32_
duk_ret_t RequireInterpreterCPU(duk_context * ctx)
{
if (!g_Settings->LoadBool(Setting_ForceInterpreterCPU) &&
(CPU_TYPE)g_Settings->LoadDword(Game_CpuType) != CPU_Interpreter)
if (!g_Settings->LoadBool(Setting_ForceInterpreterCPU) && (CPU_TYPE)g_Settings->LoadDword(Game_CpuType) != CPU_Interpreter)
{
duk_push_error_object(ctx, DUK_ERR_ERROR,
"this feature requires the interpreter core");

View File

@ -135,7 +135,7 @@ duk_ret_t ScriptAPI::js_exec(duk_context * ctx)
{"stdout", DukString(resultStdOut.c_str())},
{"stderr", DukString(resultStdErr.c_str())},
{"pid", DukUInt(processInfo.dwProcessId)},
{ nullptr }
{nullptr},
};
duk_push_error_object(ctx, resultExitCode, "exec(): process returned %d", resultExitCode);

View File

@ -1,39 +1,44 @@
#include <stdafx.h>
#include "ScriptAPI.h"
#include <sys/stat.h>
#pragma warning(disable: 4702) // disable unreachable code warning
#pragma warning(disable : 4702) // disable unreachable code warning
enum fsop { FS_READ, FS_WRITE };
static duk_ret_t ReadWriteImpl(duk_context *ctx, fsop op); // (fd, buffer, offset, length, position)
static duk_ret_t js__FileFinalizer(duk_context *ctx);
enum fsop
{
FS_READ,
FS_WRITE
};
static duk_ret_t ReadWriteImpl(duk_context * ctx, fsop op); // (fd, buffer, offset, length, position)
static duk_ret_t js__FileFinalizer(duk_context * ctx);
void ScriptAPI::Define_fs(duk_context *ctx)
void ScriptAPI::Define_fs(duk_context * ctx)
{
// todo DukPutProps DukClass
const duk_function_list_entry funcs[] = {
{ "open", js_fs_open, DUK_VARARGS },
{ "close", js_fs_close, DUK_VARARGS },
{ "write", js_fs_write, DUK_VARARGS },
{ "writefile", js_fs_writefile, DUK_VARARGS },
{ "read", js_fs_read, DUK_VARARGS },
{ "readfile", js_fs_readfile, DUK_VARARGS },
{ "exists", js_fs_exists, DUK_VARARGS },
{ "fstat", js_fs_fstat, DUK_VARARGS },
{ "stat", js_fs_stat, DUK_VARARGS },
{ "unlink", js_fs_unlink, DUK_VARARGS },
{ "mkdir", js_fs_mkdir, DUK_VARARGS },
{ "rmdir", js_fs_rmdir, DUK_VARARGS },
{ "readdir", js_fs_readdir, DUK_VARARGS },
{ "Stats", js_fs_Stats__constructor, DUK_VARARGS },
{ nullptr, nullptr, 0 }
{"open", js_fs_open, DUK_VARARGS},
{"close", js_fs_close, DUK_VARARGS},
{"write", js_fs_write, DUK_VARARGS},
{"writefile", js_fs_writefile, DUK_VARARGS},
{"read", js_fs_read, DUK_VARARGS},
{"readfile", js_fs_readfile, DUK_VARARGS},
{"exists", js_fs_exists, DUK_VARARGS},
{"fstat", js_fs_fstat, DUK_VARARGS},
{"stat", js_fs_stat, DUK_VARARGS},
{"unlink", js_fs_unlink, DUK_VARARGS},
{"mkdir", js_fs_mkdir, DUK_VARARGS},
{"rmdir", js_fs_rmdir, DUK_VARARGS},
{"readdir", js_fs_readdir, DUK_VARARGS},
{"Stats", js_fs_Stats__constructor, DUK_VARARGS},
{nullptr, nullptr, 0},
};
const duk_function_list_entry Stats_funcs[] = {
{ "isFile", js_fs_Stats_isFile, DUK_VARARGS },
{ "isDirectory", js_fs_Stats_isDirectory, DUK_VARARGS },
{ nullptr, nullptr, 0 }
{"isFile", js_fs_Stats_isFile, DUK_VARARGS},
{"isDirectory", js_fs_Stats_isDirectory, DUK_VARARGS},
{nullptr, nullptr, 0},
};
duk_push_global_object(ctx);
@ -52,16 +57,16 @@ void ScriptAPI::Define_fs(duk_context *ctx)
duk_pop(ctx);
}
duk_ret_t ScriptAPI::js_fs_open(duk_context *ctx)
duk_ret_t ScriptAPI::js_fs_open(duk_context * ctx)
{
CheckArgs(ctx, { Arg_String, Arg_String });
CheckArgs(ctx, {Arg_String, Arg_String});
const char* path = duk_get_string(ctx, 0);
const char* mode = duk_get_string(ctx, 1);
const char * path = duk_get_string(ctx, 0);
const char * mode = duk_get_string(ctx, 1);
bool bModeValid = false;
const char* validModes[] = {
const char * validModes[] = {
"r", "rb",
"w", "wb",
"a", "ab",
@ -86,9 +91,9 @@ duk_ret_t ScriptAPI::js_fs_open(duk_context *ctx)
return duk_throw(ctx);
}
FILE *fp = fopen(path, mode);
FILE * fp = fopen(path, mode);
if(fp == nullptr)
if (fp == nullptr)
{
duk_push_error_object(ctx, DUK_ERR_ERROR, "could not open '%s' (mode: '%s')", path, mode);
return duk_throw(ctx);
@ -113,26 +118,26 @@ duk_ret_t ScriptAPI::js_fs_open(duk_context *ctx)
return 1;
}
duk_ret_t ScriptAPI::js_fs_close(duk_context *ctx)
duk_ret_t ScriptAPI::js_fs_close(duk_context * ctx)
{
CheckArgs(ctx, { Arg_Number });
CheckArgs(ctx, {Arg_Number});
int fd = duk_get_int(ctx, 0);
int rc = -1;
duk_get_global_string(ctx, HS_gOpenFileDescriptors);
if(duk_has_prop_index(ctx, -1, fd))
if (duk_has_prop_index(ctx, -1, fd))
{
duk_get_prop_index(ctx, -1, fd);
duk_get_prop_string(ctx, -1, "fp");
FILE* fp = (FILE*)duk_get_pointer(ctx, -1);
FILE * fp = (FILE *)duk_get_pointer(ctx, -1);
rc = fclose(fp);
// unset finalizer before deleting
duk_push_undefined(ctx);
duk_set_finalizer(ctx, -3);
duk_set_finalizer(ctx, -3);
duk_del_prop_index(ctx, -3, fd);
duk_pop_n(ctx, 2);
@ -148,26 +153,26 @@ duk_ret_t ScriptAPI::js_fs_close(duk_context *ctx)
return 1;
}
duk_ret_t ScriptAPI::js_fs_write(duk_context *ctx)
duk_ret_t ScriptAPI::js_fs_write(duk_context * ctx)
{
CheckArgs(ctx, { Arg_Number, Arg_Any, Arg_OptNumber, Arg_OptNumber, Arg_OptNumber });
CheckArgs(ctx, {Arg_Number, Arg_Any, Arg_OptNumber, Arg_OptNumber, Arg_OptNumber});
return ReadWriteImpl(ctx, FS_WRITE);
}
duk_ret_t ScriptAPI::js_fs_writefile(duk_context *ctx)
duk_ret_t ScriptAPI::js_fs_writefile(duk_context * ctx)
{
CheckArgs(ctx, { Arg_String, Arg_Any });
CheckArgs(ctx, {Arg_String, Arg_Any});
const char* path = duk_get_string(ctx, 0);
const char * path = duk_get_string(ctx, 0);
void* buffer;
void * buffer;
duk_size_t bufferSize;
if(duk_is_string(ctx, 1))
if (duk_is_string(ctx, 1))
{
buffer = (void*)duk_get_lstring(ctx, 1, &bufferSize);
buffer = (void *)duk_get_lstring(ctx, 1, &bufferSize);
}
else if(duk_is_buffer_data(ctx, 1))
else if (duk_is_buffer_data(ctx, 1))
{
buffer = duk_get_buffer_data(ctx, 1, &bufferSize);
}
@ -176,15 +181,15 @@ duk_ret_t ScriptAPI::js_fs_writefile(duk_context *ctx)
return ThrowInvalidArgsError(ctx);
}
FILE* fp = fopen(path, "wb");
FILE * fp = fopen(path, "wb");
if(fp == nullptr)
if (fp == nullptr)
{
duk_push_error_object(ctx, DUK_ERR_ERROR, "could not open '%s' (mode: 'wb')", path);
return duk_throw(ctx);
}
if(fwrite(buffer, 1, bufferSize, fp) != bufferSize)
if (fwrite(buffer, 1, bufferSize, fp) != bufferSize)
{
fclose(fp);
return DUK_RET_ERROR;
@ -194,37 +199,37 @@ duk_ret_t ScriptAPI::js_fs_writefile(duk_context *ctx)
return 0;
}
duk_ret_t ScriptAPI::js_fs_read(duk_context *ctx)
duk_ret_t ScriptAPI::js_fs_read(duk_context * ctx)
{
CheckArgs(ctx, { Arg_Number, Arg_Any, Arg_Number, Arg_Number, Arg_Number });
CheckArgs(ctx, {Arg_Number, Arg_Any, Arg_Number, Arg_Number, Arg_Number});
return ReadWriteImpl(ctx, FS_READ);
}
duk_ret_t ScriptAPI::js_fs_readfile(duk_context *ctx)
duk_ret_t ScriptAPI::js_fs_readfile(duk_context * ctx)
{
CheckArgs(ctx, { Arg_String });
CheckArgs(ctx, {Arg_String});
const char* path = duk_get_string(ctx, 0);
const char * path = duk_get_string(ctx, 0);
FILE* fp = fopen(path, "rb");
FILE * fp = fopen(path, "rb");
if(fp == nullptr)
if (fp == nullptr)
{
duk_push_error_object(ctx, DUK_ERR_ERROR, "could not open '%s' (mode: 'rb')", path);
return duk_throw(ctx);
}
struct stat stats;
if(fstat(_fileno(fp), &stats) != 0)
if (fstat(_fileno(fp), &stats) != 0)
{
fclose(fp);
return DUK_RET_ERROR;
}
void *data = duk_push_fixed_buffer(ctx, stats.st_size);
void * data = duk_push_fixed_buffer(ctx, stats.st_size);
duk_push_buffer_object(ctx, -1, 0, stats.st_size, DUK_BUFOBJ_NODEJS_BUFFER);
if(fread(data, 1, stats.st_size, fp) != (size_t)stats.st_size)
if (fread(data, 1, stats.st_size, fp) != (size_t)stats.st_size)
{
duk_pop(ctx);
fclose(fp);
@ -235,17 +240,17 @@ duk_ret_t ScriptAPI::js_fs_readfile(duk_context *ctx)
return 1;
}
duk_ret_t ScriptAPI::js_fs_exists(duk_context* ctx)
duk_ret_t ScriptAPI::js_fs_exists(duk_context * ctx)
{
CheckArgs(ctx, { Arg_String });
const char* path = duk_get_string(ctx, 0);
CheckArgs(ctx, {Arg_String});
const char * path = duk_get_string(ctx, 0);
duk_push_boolean(ctx, PathFileExistsA(path) ? 1 : 0);
return 1;
}
duk_ret_t ScriptAPI::js_fs_fstat(duk_context *ctx)
duk_ret_t ScriptAPI::js_fs_fstat(duk_context * ctx)
{
CheckArgs(ctx, { Arg_Number });
CheckArgs(ctx, {Arg_Number});
int fd = duk_get_int(ctx, 0);
@ -257,11 +262,11 @@ duk_ret_t ScriptAPI::js_fs_fstat(duk_context *ctx)
return 1;
}
duk_ret_t ScriptAPI::js_fs_stat(duk_context *ctx)
duk_ret_t ScriptAPI::js_fs_stat(duk_context * ctx)
{
CheckArgs(ctx, { Arg_String });
CheckArgs(ctx, {Arg_String});
const char *path = duk_get_string(ctx, 0);
const char * path = duk_get_string(ctx, 0);
duk_push_global_object(ctx);
duk_get_prop_string(ctx, -1, "fs");
@ -271,39 +276,39 @@ duk_ret_t ScriptAPI::js_fs_stat(duk_context *ctx)
return 1;
}
duk_ret_t ScriptAPI::js_fs_unlink(duk_context *ctx)
duk_ret_t ScriptAPI::js_fs_unlink(duk_context * ctx)
{
CheckArgs(ctx, { Arg_String });
CheckArgs(ctx, {Arg_String});
const char *path = duk_get_string(ctx, 0);
const char * path = duk_get_string(ctx, 0);
duk_push_boolean(ctx, DeleteFileA(path) != 0);
return 1;
}
duk_ret_t ScriptAPI::js_fs_mkdir(duk_context *ctx)
duk_ret_t ScriptAPI::js_fs_mkdir(duk_context * ctx)
{
CheckArgs(ctx, { Arg_String });
CheckArgs(ctx, {Arg_String});
const char *path = duk_get_string(ctx, 0);
const char * path = duk_get_string(ctx, 0);
duk_push_boolean(ctx, CreateDirectoryA(path, nullptr) != 0);
return 1;
}
duk_ret_t ScriptAPI::js_fs_rmdir(duk_context *ctx)
duk_ret_t ScriptAPI::js_fs_rmdir(duk_context * ctx)
{
CheckArgs(ctx, { Arg_String });
CheckArgs(ctx, {Arg_String});
const char *path = duk_get_string(ctx, 0);
const char * path = duk_get_string(ctx, 0);
duk_push_boolean(ctx, RemoveDirectoryA(path) != 0);
return 1;
}
// todo make sure failure behavior is similar to nodejs's fs.readdirSync
duk_ret_t ScriptAPI::js_fs_readdir(duk_context *ctx)
duk_ret_t ScriptAPI::js_fs_readdir(duk_context * ctx)
{
CheckArgs(ctx, { Arg_String });
CheckArgs(ctx, {Arg_String});
const char* path = duk_get_string(ctx, 0);
const char * path = duk_get_string(ctx, 0);
char findFileName[MAX_PATH];
snprintf(findFileName, sizeof(findFileName), "%s%s", path, "\\*");
@ -311,7 +316,7 @@ duk_ret_t ScriptAPI::js_fs_readdir(duk_context *ctx)
WIN32_FIND_DATAA ffd;
HANDLE hFind = FindFirstFileA(findFileName, &ffd);
if(hFind == INVALID_HANDLE_VALUE)
if (hFind == INVALID_HANDLE_VALUE)
{
return DUK_RET_ERROR;
}
@ -321,45 +326,44 @@ duk_ret_t ScriptAPI::js_fs_readdir(duk_context *ctx)
do
{
if(strcmp(ffd.cFileName, ".") == 0 ||
strcmp(ffd.cFileName, "..") == 0)
if (strcmp(ffd.cFileName, ".") == 0 || strcmp(ffd.cFileName, "..") == 0)
{
continue;
}
duk_push_string(ctx, ffd.cFileName);
duk_put_prop_index(ctx, -2, idx++);
} while(FindNextFileA(hFind, &ffd));
} while (FindNextFileA(hFind, &ffd));
FindClose(hFind);
return 1;
}
duk_ret_t ScriptAPI::js_fs_Stats__constructor(duk_context *ctx)
duk_ret_t ScriptAPI::js_fs_Stats__constructor(duk_context * ctx)
{
if(!duk_is_constructor_call(ctx))
if (!duk_is_constructor_call(ctx))
{
return DUK_RET_TYPE_ERROR;
}
if(duk_get_top(ctx) != 1)
if (duk_get_top(ctx) != 1)
{
return ThrowInvalidArgsError(ctx);
}
struct stat stats;
if(duk_is_number(ctx, 0))
if (duk_is_number(ctx, 0))
{
int fd = duk_get_int(ctx, 0);
if(fstat(fd, &stats) != 0)
if (fstat(fd, &stats) != 0)
{
return DUK_RET_ERROR;
}
}
else if(duk_is_string(ctx, 0))
else if (duk_is_string(ctx, 0))
{
const char *path = duk_get_string(ctx, 0);
if(stat(path, &stats) != 0)
const char * path = duk_get_string(ctx, 0);
if (stat(path, &stats) != 0)
{
return DUK_RET_ERROR;
}
@ -370,24 +374,24 @@ duk_ret_t ScriptAPI::js_fs_Stats__constructor(duk_context *ctx)
}
const duk_number_list_entry numbers[] = {
{ "dev", (double)stats.st_dev },
{ "ino", (double)stats.st_ino },
{ "mode", (double)stats.st_mode },
{ "nlink", (double)stats.st_nlink },
{ "uid", (double)stats.st_uid },
{ "gid", (double)stats.st_gid },
{ "rdev", (double)stats.st_rdev },
{ "size", (double)stats.st_size },
{ "atimeMs", (double)stats.st_atime * 1000 },
{ "mtimeMs", (double)stats.st_mtime * 1000 },
{ "ctimeMs", (double)stats.st_ctime * 1000 },
{ nullptr, 0 }
{"dev", (double)stats.st_dev},
{"ino", (double)stats.st_ino},
{"mode", (double)stats.st_mode},
{"nlink", (double)stats.st_nlink},
{"uid", (double)stats.st_uid},
{"gid", (double)stats.st_gid},
{"rdev", (double)stats.st_rdev},
{"size", (double)stats.st_size},
{"atimeMs", (double)stats.st_atime * 1000},
{"mtimeMs", (double)stats.st_mtime * 1000},
{"ctimeMs", (double)stats.st_ctime * 1000},
{nullptr, 0},
};
struct { const char *key; time_t time; } dates[3] = {
{ "atime", stats.st_atime * 1000 },
{ "mtime", stats.st_mtime * 1000 },
{ "ctime", stats.st_ctime * 1000 },
{"atime", stats.st_atime * 1000},
{"mtime", stats.st_mtime * 1000},
{"ctime", stats.st_ctime * 1000},
};
duk_push_global_object(ctx);
@ -397,7 +401,7 @@ duk_ret_t ScriptAPI::js_fs_Stats__constructor(duk_context *ctx)
duk_push_this(ctx);
duk_put_number_list(ctx, -1, numbers);
for(int i = 0; i < 3; i++)
for (int i = 0; i < 3; i++)
{
duk_dup(ctx, -2);
duk_push_number(ctx, (duk_double_t)dates[i].time);
@ -410,7 +414,7 @@ duk_ret_t ScriptAPI::js_fs_Stats__constructor(duk_context *ctx)
return 0;
}
duk_ret_t ScriptAPI::js_fs_Stats_isDirectory(duk_context *ctx)
duk_ret_t ScriptAPI::js_fs_Stats_isDirectory(duk_context * ctx)
{
CheckArgs(ctx, {});
@ -421,7 +425,7 @@ duk_ret_t ScriptAPI::js_fs_Stats_isDirectory(duk_context *ctx)
return 1;
}
duk_ret_t ScriptAPI::js_fs_Stats_isFile(duk_context *ctx)
duk_ret_t ScriptAPI::js_fs_Stats_isFile(duk_context * ctx)
{
CheckArgs(ctx, {});
@ -432,33 +436,33 @@ duk_ret_t ScriptAPI::js_fs_Stats_isFile(duk_context *ctx)
return 1;
}
static duk_ret_t ReadWriteImpl(duk_context *ctx, fsop op)
static duk_ret_t ReadWriteImpl(duk_context * ctx, fsop op)
{
int fd;
const char* buffer;
const char * buffer;
size_t offset = 0;
size_t length = 0;
size_t position = 0;
bool bHavePos = false;
duk_size_t bufferSize;
FILE* fp;
FILE * fp;
size_t rc;
duk_idx_t nargs = duk_get_top(ctx);
if(nargs < 2 || !duk_is_number(ctx, 0))
if (nargs < 2 || !duk_is_number(ctx, 0))
{
goto err_invalid_args;
}
fd = duk_get_int(ctx, 0);
if(duk_is_buffer_data(ctx, 1))
if (duk_is_buffer_data(ctx, 1))
{
buffer = (const char*)duk_get_buffer_data(ctx, 1, &bufferSize);
buffer = (const char *)duk_get_buffer_data(ctx, 1, &bufferSize);
}
else if(duk_is_string(ctx, 1) && op == FS_WRITE)
else if (duk_is_string(ctx, 1) && op == FS_WRITE)
{
buffer = duk_get_lstring(ctx, 1, &bufferSize);
}
@ -467,16 +471,16 @@ static duk_ret_t ReadWriteImpl(duk_context *ctx, fsop op)
goto err_invalid_args;
}
if(nargs >= 3)
if (nargs >= 3)
{
if(!duk_is_number(ctx, 2))
if (!duk_is_number(ctx, 2))
{
goto err_invalid_args;
}
offset = duk_get_uint(ctx, 2);
if(offset >= bufferSize)
if (offset >= bufferSize)
{
goto err_invalid_range;
}
@ -484,18 +488,18 @@ static duk_ret_t ReadWriteImpl(duk_context *ctx, fsop op)
length = bufferSize - offset;
if(nargs >= 4)
if (nargs >= 4)
{
if(!duk_is_number(ctx, 3))
if (!duk_is_number(ctx, 3))
{
goto err_invalid_args;
}
length = duk_get_uint(ctx, 3);
}
if(nargs >= 5)
if (nargs >= 5)
{
if(!duk_is_number(ctx, 4))
if (!duk_is_number(ctx, 4))
{
goto err_invalid_args;
}
@ -503,36 +507,36 @@ static duk_ret_t ReadWriteImpl(duk_context *ctx, fsop op)
bHavePos = true;
}
if(offset + length > bufferSize)
if (offset + length > bufferSize)
{
goto err_invalid_range;
}
duk_get_global_string(ctx, HS_gOpenFileDescriptors);
if(!duk_has_prop_index(ctx, -1, fd))
if (!duk_has_prop_index(ctx, -1, fd))
{
goto err_invalid_fd;
}
duk_get_prop_index(ctx, -1, fd);
duk_get_prop_string(ctx, -1, "fp");
fp = (FILE*)duk_get_pointer(ctx, -1);
fp = (FILE *)duk_get_pointer(ctx, -1);
duk_pop_n(ctx, 3);
if(bHavePos)
if (bHavePos)
{
fseek(fp, position, SEEK_SET);
}
switch(op)
switch (op)
{
case FS_READ:
rc = fread((void*)&buffer[offset], 1, length, fp);
rc = fread((void *)&buffer[offset], 1, length, fp);
break;
case FS_WRITE:
rc = fwrite((void*)&buffer[offset], 1, length, fp);
rc = fwrite((void *)&buffer[offset], 1, length, fp);
break;
default:
return DUK_RET_ERROR;
@ -553,17 +557,17 @@ err_invalid_fd:
return duk_throw(ctx);
}
static duk_ret_t js__FileFinalizer(duk_context *ctx)
static duk_ret_t js__FileFinalizer(duk_context * ctx)
{
CScriptInstance* inst = ScriptAPI::GetInstance(ctx);
CScriptInstance * inst = ScriptAPI::GetInstance(ctx);
duk_get_prop_string(ctx, 0, "fp");
FILE *fp = (FILE *)duk_get_pointer(ctx, -1);
FILE * fp = (FILE *)duk_get_pointer(ctx, -1);
duk_pop(ctx);
fclose(fp);
inst->System()->ConsoleLog("[SCRIPTSYS]: warning ('%s'): gc closed leftover file descriptor",
inst->Name().c_str());
inst->Name().c_str());
return 0;
}

View File

@ -37,7 +37,7 @@ void ScriptAPI::Define_mem(duk_context * ctx)
{"s8", DukProxy(MEM_PROXY_FUNCS(int8_t))},
{"f64", DukProxy(MEM_PROXY_FUNCS(double))},
{"f32", DukProxy(MEM_PROXY_FUNCS(float))},
{ nullptr }
{nullptr},
};
DefineGlobalInterface(ctx, "mem", props);
@ -109,8 +109,7 @@ duk_ret_t ScriptAPI::js_mem_getblock(duk_context * ctx)
memsrc = g_MMU->Rdram();
offsetStart = paddr;
}
else if (g_Rom && paddr >= 0x10000000 &&
((paddr - 0x10000000) + length) <= g_Rom->GetRomSize())
else if (g_Rom && paddr >= 0x10000000 && ((paddr - 0x10000000) + length) <= g_Rom->GetRomSize())
{
memsrc = g_Rom->GetRomAddress();
offsetStart = paddr - 0x10000000;
@ -282,9 +281,15 @@ duk_ret_t ScriptAPI::js_mem__boundget(duk_context * ctx)
double f64;
} retval;
#define MEM_BOUNDGET_TRY(addr, T, result, dukpush) \
if(debugger->DebugLoad_VAddr<T>(addr, result)) { dukpush(ctx, result); } \
else { goto memory_error; }
#define MEM_BOUNDGET_TRY(addr, T, result, dukpush) \
if (debugger->DebugLoad_VAddr<T>(addr, result)) \
{ \
dukpush(ctx, result); \
} \
else \
{ \
goto memory_error; \
}
switch (type)
{
@ -325,9 +330,15 @@ duk_ret_t ScriptAPI::js_mem__boundset(duk_context * ctx)
uint32_t addr = duk_get_uint(ctx, 0);
duk_int_t type = duk_get_int(ctx, 1);
#define MEM_BOUNDSET_TRY(addr, T, value) \
if(debugger->DebugStore_VAddr<T>(addr, value)) { return 1; } \
else { goto memory_error; }
#define MEM_BOUNDSET_TRY(addr, T, value) \
if (debugger->DebugStore_VAddr<T>(addr, value)) \
{ \
return 1; \
} \
else \
{ \
goto memory_error; \
}
switch (type)
{
@ -404,8 +415,7 @@ duk_ret_t ScriptAPI::js_mem_bindvars(duk_context * ctx)
for (duk_uarridx_t i = 0; i < length; i++)
{
duk_get_prop_index(ctx, 1, i);
if (!duk_is_array(ctx, -1) ||
duk_get_length(ctx, -1) != 3)
if (!duk_is_array(ctx, -1) || duk_get_length(ctx, -1) != 3)
{
return DUK_RET_TYPE_ERROR;
}

View File

@ -17,7 +17,7 @@ void ScriptAPI::Define_pj64(duk_context * ctx)
{"id", DukGetter(js_pj64_romInfo__get_headerId)},
{"countryCode", DukGetter(js_pj64_romInfo__get_headerCountryCode)},
{"version", DukGetter(js_pj64_romInfo__get_headerVersion)},
{ nullptr }
{nullptr},
};
const DukPropListEntry props[] = {
@ -35,7 +35,7 @@ void ScriptAPI::Define_pj64(duk_context * ctx)
{"romDirectory", DukGetter(js_pj64__get_romDirectory)},
{DUK_HIDDEN_SYMBOL("romInfo"), DukObject(romInfoProps)},
{"romInfo", DukGetter(js_pj64__get_romInfo)},
{ nullptr }
{nullptr},
};
DefineGlobalInterface(ctx, "pj64", props);

View File

@ -1,45 +1,46 @@
#include <stdafx.h>
#include "ScriptAPI.h"
#pragma warning(disable: 4702) // disable unreachable code warning
#pragma warning(disable : 4702) // disable unreachable code warning
void ScriptAPI::Define_script(duk_context *ctx)
void ScriptAPI::Define_script(duk_context * ctx)
{
const DukPropListEntry props[] = {
{ "timeout", DukCFunction(js_script_timeout) },
{ "keepalive", DukCFunction(js_script_keepalive) },
{ "abort", DukCFunction(js_script_abort) },
{ nullptr }
{"timeout", DukCFunction(js_script_timeout)},
{"keepalive", DukCFunction(js_script_keepalive)},
{"abort", DukCFunction(js_script_abort)},
{nullptr},
};
DefineGlobalInterface(ctx, "script", props);
}
duk_ret_t ScriptAPI::js_script_timeout(duk_context *ctx)
duk_ret_t ScriptAPI::js_script_timeout(duk_context * ctx)
{
CheckArgs(ctx, { Arg_Number });
CScriptInstance* inst = GetInstance(ctx);
CheckArgs(ctx, {Arg_Number});
CScriptInstance * inst = GetInstance(ctx);
inst->SetExecTimeout((uint64_t)duk_get_number(ctx, 0));
return 0;
}
duk_ret_t ScriptAPI::js_script_keepalive(duk_context *ctx)
duk_ret_t ScriptAPI::js_script_keepalive(duk_context * ctx)
{
CheckArgs(ctx, { Arg_Boolean });
CScriptInstance* inst = GetInstance(ctx);
CheckArgs(ctx, {Arg_Boolean});
CScriptInstance * inst = GetInstance(ctx);
duk_bool_t bKeepAlive = duk_get_boolean(ctx, 0);
duk_push_global_object(ctx);
duk_bool_t bHaveProp = duk_has_prop_string(ctx, -1, HS_gKeepAlive);
if(bKeepAlive && !bHaveProp)
if (bKeepAlive && !bHaveProp)
{
duk_push_boolean(ctx, 1);
duk_put_prop_string(ctx, -2, HS_gKeepAlive);
inst->IncRefCount();
}
else if(!bKeepAlive && bHaveProp)
else if (!bKeepAlive && bHaveProp)
{
duk_del_prop_string(ctx, -1, HS_gKeepAlive);
inst->DecRefCount();
@ -50,10 +51,10 @@ duk_ret_t ScriptAPI::js_script_keepalive(duk_context *ctx)
return 0;
}
duk_ret_t ScriptAPI::js_script_abort(duk_context* ctx)
duk_ret_t ScriptAPI::js_script_abort(duk_context * ctx)
{
CheckArgs(ctx, {});
CScriptInstance* inst = GetInstance(ctx);
CScriptInstance * inst = GetInstance(ctx);
if (inst->PrepareAbort())
{
return duk_fatal(ctx, "aborted");

View File

@ -99,8 +99,7 @@ bool CScriptInstance::Run(const char * path)
try
{
duk_push_string(m_Ctx, m_InstanceName.c_str());
if (duk_pcompile_string_filename(m_Ctx, DUK_COMPILE_STRICT, m_SourceCode) != 0 ||
duk_pcall(m_Ctx, 0) == DUK_EXEC_ERROR)
if (duk_pcompile_string_filename(m_Ctx, DUK_COMPILE_STRICT, m_SourceCode) != 0 || duk_pcall(m_Ctx, 0) == DUK_EXEC_ERROR)
{
duk_get_prop_string(m_Ctx, -1, "stack");
m_System->ConsoleLog("%s", duk_safe_to_string(m_Ctx, -1));
@ -211,8 +210,7 @@ void CScriptInstance::RawConsoleInput(const char * code)
m_ExecStartTime = Timestamp();
duk_push_string(m_Ctx, stdstr_f("<input:%s>", m_InstanceName.c_str()).c_str());
if (duk_pcompile_string_filename(m_Ctx, DUK_COMPILE_STRICT, code) != 0 ||
duk_pcall(m_Ctx, 0) == DUK_EXEC_ERROR)
if (duk_pcompile_string_filename(m_Ctx, DUK_COMPILE_STRICT, code) != 0 || duk_pcall(m_Ctx, 0) == DUK_EXEC_ERROR)
{
duk_get_prop_string(m_Ctx, -1, "stack");
m_System->ConsoleLog("%s", duk_safe_to_string(m_Ctx, -1));

View File

@ -1,5 +1,5 @@
#include "ScriptTypes.h"
#include "ScriptSystem.h"
#include "ScriptTypes.h"
#include "ScriptWorker.h"
#pragma once
@ -7,44 +7,50 @@
class CScriptInstance
{
private:
JSInstanceName m_InstanceName;
CScriptSystem* m_System;
duk_context* m_Ctx;
size_t m_RefCount;
uint64_t m_ExecTimeout;
uint64_t m_ExecStartTime;
std::ifstream m_SourceFile;
char* m_SourceCode;
JSInstanceName m_InstanceName;
CScriptSystem * m_System;
duk_context * m_Ctx;
size_t m_RefCount;
uint64_t m_ExecTimeout;
uint64_t m_ExecStartTime;
std::ifstream m_SourceFile;
char * m_SourceCode;
JSAppCallbackID m_CurExecCallbackId;
std::vector<CScriptWorker*> m_Workers;
bool m_bStopping;
bool m_bAborting;
std::vector<CScriptWorker *> m_Workers;
bool m_bStopping;
bool m_bAborting;
public:
CScriptInstance(CScriptSystem* sys, const char* name);
CScriptInstance(CScriptSystem * sys, const char * name);
~CScriptInstance();
JSInstanceName& Name();
CScriptSystem* System();
CDebuggerUI* Debugger();
JSInstanceName & Name();
CScriptSystem * System();
CDebuggerUI * Debugger();
JSAppCallbackID CallbackId();
bool Run(const char* path);
void SetExecTimeout(uint64_t timeout);
bool IsTimedOut();
bool Run(const char * path);
void SetExecTimeout(uint64_t timeout);
bool IsTimedOut();
inline size_t GetRefCount() { return m_RefCount; }
void IncRefCount();
void DecRefCount();
void SetStopping(bool bStopping);
inline bool IsStopping() { return m_bStopping; }
bool PrepareAbort();
inline size_t GetRefCount()
{
return m_RefCount;
}
void IncRefCount();
void DecRefCount();
void SetStopping(bool bStopping);
inline bool IsStopping()
{
return m_bStopping;
}
bool PrepareAbort();
bool RegisterWorker(CScriptWorker* worker);
void UnregisterWorker(CScriptWorker* worker);
bool RegisterWorker(CScriptWorker * worker);
void UnregisterWorker(CScriptWorker * worker);
void StopRegisteredWorkers();
inline void RawInvokeAppCallback(JSAppCallback& cb, void* _hookEnv)
inline void RawInvokeAppCallback(JSAppCallback & cb, void * _hookEnv)
{
m_CurExecCallbackId = cb.m_CallbackId;
@ -58,7 +64,7 @@ public:
m_CurExecCallbackId = JS_INVALID_CALLBACK;
}
inline void RawCall(void *dukFuncHeapPtr, JSDukArgSetupFunc argSetupFunc, void *param = nullptr)
inline void RawCall(void * dukFuncHeapPtr, JSDukArgSetupFunc argSetupFunc, void * param = nullptr)
{
m_ExecStartTime = Timestamp();
duk_push_heapptr(m_Ctx, dukFuncHeapPtr);
@ -75,24 +81,24 @@ public:
duk_pop(m_Ctx);
}
catch (std::runtime_error& exc)
catch (std::runtime_error & exc)
{
FatalHandler(exc);
}
}
void RawCMethodCall(void* dukThisHeapPtr, duk_c_function func,
JSDukArgSetupFunc argSetupFunc = nullptr,
void* argSetupParam = nullptr);
void RawCMethodCall(void * dukThisHeapPtr, duk_c_function func,
JSDukArgSetupFunc argSetupFunc = nullptr,
void * argSetupParam = nullptr);
void PostCMethodCall(void* dukThisHeapPtr, duk_c_function func,
JSDukArgSetupFunc argSetupFunc = nullptr,
void* argSetupParam = nullptr, size_t argSetupParamSize = 0);
void PostCMethodCall(void * dukThisHeapPtr, duk_c_function func,
JSDukArgSetupFunc argSetupFunc = nullptr,
void * argSetupParam = nullptr, size_t argSetupParamSize = 0);
void RawConsoleInput(const char* code);
void RawConsoleInput(const char * code);
private:
void FatalHandler(std::runtime_error& exc);
void FatalHandler(std::runtime_error & exc);
static uint64_t Timestamp();
void Cleanup();
};

View File

@ -162,8 +162,7 @@ bool CScriptSystem::HaveAppCallbacks(JSAppHookID hookId)
{
CGuard guard(m_InstancesCS);
return (hookId < JS_NUM_APP_HOOKS &&
m_AppCallbackHooks[hookId].size() > 0);
return (hookId < JS_NUM_APP_HOOKS && m_AppCallbackHooks[hookId].size() > 0);
}
void CScriptSystem::InvokeAppCallbacks(JSAppHookID hookId, void * env)
@ -180,10 +179,7 @@ void CScriptSystem::InvokeAppCallbacks(JSAppHookID hookId, void * env)
JSAppCallback & callback = callbacks[i];
CScriptInstance * instance = callback.m_Instance;
if (callback.m_bDisabled ||
instance->IsStopping() ||
m_StopsIssued.count(instance->Name()) != 0 ||
!callback.m_ConditionFunc(&callback, env))
if (callback.m_bDisabled || instance->IsStopping() || m_StopsIssued.count(instance->Name()) != 0 || !callback.m_ConditionFunc(&callback, env))
{
continue;
}
@ -215,10 +211,7 @@ void CScriptSystem::UpdateCpuCbListInfo(volatile JSCpuCbListInfo & info, JSAppCa
for (i = 0; i < numCacheEntries; i++)
{
// combine adjacent/overlapping ranges
if ((callback.m_Params.addrStart >= info.rangeCache[i].addrStart &&
callback.m_Params.addrStart <= info.rangeCache[i].addrEnd + 1) ||
(callback.m_Params.addrEnd >= info.rangeCache[i].addrStart - 1 &&
callback.m_Params.addrEnd <= info.rangeCache[i].addrEnd))
if ((callback.m_Params.addrStart >= info.rangeCache[i].addrStart && callback.m_Params.addrStart <= info.rangeCache[i].addrEnd + 1) || (callback.m_Params.addrEnd >= info.rangeCache[i].addrStart - 1 && callback.m_Params.addrEnd <= info.rangeCache[i].addrEnd))
{
info.rangeCache[i].addrStart = min(info.rangeCache[i].addrStart, callback.m_Params.addrStart);
info.rangeCache[i].addrEnd = max(info.rangeCache[i].addrEnd, callback.m_Params.addrEnd);

View File

@ -1,6 +1,6 @@
#include <windows.h>
#include <fstream>
#include <map>
#include <windows.h>
#include "ScriptTypes.h"
#include "debugger.h"
@ -12,49 +12,53 @@
class CScriptSystem
{
typedef std::map<JSInstanceName, CScriptInstance*> JSInstanceMap;
typedef std::map<JSInstanceName, CScriptInstance *> JSInstanceMap;
typedef std::vector<JSAppCallback> JSAppCallbackList;
typedef std::map<JSInstanceName, JSInstanceStatus> JSInstanceStatusMap;
typedef std::vector<JSSysCommand> JSSysCommandQueue;
enum { JS_CPU_CB_RANGE_CACHE_SIZE = 256 };
enum
{
JS_CPU_CB_RANGE_CACHE_SIZE = 256
};
struct JSCpuCbListInfo
{
size_t numCallbacks;
size_t numCallbacks;
uint32_t minAddrStart;
uint32_t maxAddrEnd;
size_t numRangeCacheEntries;
bool bRangeCacheExceeded;
struct {
size_t numRangeCacheEntries;
bool bRangeCacheExceeded;
struct
{
uint32_t addrStart;
uint32_t addrEnd;
} rangeCache[JS_CPU_CB_RANGE_CACHE_SIZE];
};
HANDLE m_hThread;
HANDLE m_hThread;
CriticalSection m_CmdQueueCS;
JSSysCommandQueue m_CmdQueue;
HANDLE m_hCmdEvent;
CriticalSection m_CmdQueueCS;
JSSysCommandQueue m_CmdQueue;
HANDLE m_hCmdEvent;
std::set<JSInstanceName> m_StopsIssued;
CriticalSection m_InstancesCS;
JSInstanceMap m_Instances;
JSAppCallbackList m_AppCallbackHooks[JS_NUM_APP_HOOKS];
JSAppCallbackID m_NextAppCallbackId;
volatile size_t m_AppCallbackCount;
CriticalSection m_InstancesCS;
JSInstanceMap m_Instances;
JSAppCallbackList m_AppCallbackHooks[JS_NUM_APP_HOOKS];
JSAppCallbackID m_NextAppCallbackId;
volatile size_t m_AppCallbackCount;
volatile JSCpuCbListInfo m_CpuExecCbInfo;
volatile JSCpuCbListInfo m_CpuReadCbInfo;
volatile JSCpuCbListInfo m_CpuWriteCbInfo;
CriticalSection m_UIStateCS;
JSInstanceStatusMap m_UIInstanceStatus;
stdstr m_UILog;
CDebuggerUI* m_Debugger;
CriticalSection m_UIStateCS;
JSInstanceStatusMap m_UIInstanceStatus;
stdstr m_UILog;
CDebuggerUI * m_Debugger;
std::set<std::string> m_AutorunList;
@ -63,35 +67,38 @@ class CScriptSystem
stdstr m_ModulesDirFullPath;
public:
CScriptSystem(CDebuggerUI* debugger);
CScriptSystem(CDebuggerUI * debugger);
~CScriptSystem();
CDebuggerUI* Debugger();
CDebuggerUI * Debugger();
void StartScript(const char* instanceName, const char* path);
void StopScript(const char* instanceName);
void Input(const char* instanceName, const char* code);
void StartScript(const char * instanceName, const char * path);
void StopScript(const char * instanceName);
void Input(const char * instanceName, const char * code);
stdstr InstallDirPath();
stdstr ScriptsDirPath();
stdstr ModulesDirPath();
JSInstanceStatus GetStatus(const char* instanceName);
void NotifyStatus(const char* instanceName, JSInstanceStatus status);
void ConsoleLog(const char* format, ...);
void ConsolePrint(const char* format, ...);
JSInstanceStatus GetStatus(const char * instanceName);
void NotifyStatus(const char * instanceName, JSInstanceStatus status);
void ConsoleLog(const char * format, ...);
void ConsolePrint(const char * format, ...);
void ConsoleClear();
stdstr GetConsoleBuffer();
void PostCMethodCall(const char* instanceName, void* dukThisHeapPtr, duk_c_function func,
JSDukArgSetupFunc argSetupFunc = nullptr,
void* argSetupParam = nullptr,
size_t argSetupParamSize = 0);
void PostCMethodCall(const char * instanceName, void * dukThisHeapPtr, duk_c_function func,
JSDukArgSetupFunc argSetupFunc = nullptr,
void * argSetupParam = nullptr,
size_t argSetupParamSize = 0);
bool HaveAppCallbacks(JSAppHookID hookId);
// Note: Unguarded for speed, shouldn't matter
inline bool HaveAppCallbacks() { return m_AppCallbackCount != 0; }
inline bool HaveAppCallbacks()
{
return m_AppCallbackCount != 0;
}
inline bool HaveCpuExecCallbacks(uint32_t address)
{
@ -107,22 +114,22 @@ public:
{
return HaveCpuCallbacks(m_CpuWriteCbInfo, m_AppCallbackHooks[JS_HOOK_CPU_WRITE], address);
}
static void UpdateCpuCbListInfo(volatile JSCpuCbListInfo& info, JSAppCallbackList& callbacks);
static void UpdateCpuCbListInfo(volatile JSCpuCbListInfo & info, JSAppCallbackList & callbacks);
void DoMouseEvent(JSAppHookID hookId, int x, int y, DWORD uMsg = (DWORD)-1);
void InvokeAppCallbacks(JSAppHookID hookId, void* env = nullptr);
void InvokeAppCallbacks(JSAppHookID hookId, void * env = nullptr);
void ExecAutorunList();
std::set<std::string>& AutorunList();
std::set<std::string> & AutorunList();
void LoadAutorunList();
void SaveAutorunList();
JSAppCallbackID RawAddAppCallback(JSAppHookID hookId, JSAppCallback& callback);
JSAppCallbackID RawAddAppCallback(JSAppHookID hookId, JSAppCallback & callback);
void RawRemoveAppCallback(JSAppHookID hookId, JSAppCallbackID callbackId);
private:
inline bool HaveCpuCallbacks(volatile JSCpuCbListInfo& info, JSAppCallbackList& callbacks, uint32_t address)
inline bool HaveCpuCallbacks(volatile JSCpuCbListInfo & info, JSAppCallbackList & callbacks, uint32_t address)
{
if (info.numCallbacks == 0 || address < info.minAddrStart || address > info.maxAddrEnd)
{
@ -133,8 +140,7 @@ private:
{
for (size_t i = 0; i < info.numRangeCacheEntries; i++)
{
if (address >= info.rangeCache[i].addrStart &&
address <= info.rangeCache[i].addrEnd)
if (address >= info.rangeCache[i].addrStart && address <= info.rangeCache[i].addrEnd)
{
return true;
}
@ -145,10 +151,9 @@ private:
CGuard guard(m_InstancesCS);
for (JSAppCallback& callback : callbacks)
for (JSAppCallback & callback : callbacks)
{
if (address >= callback.m_Params.addrStart &&
address <= callback.m_Params.addrEnd)
if (address >= callback.m_Params.addrStart && address <= callback.m_Params.addrEnd)
{
return true;
}
@ -159,23 +164,23 @@ private:
void InitDirectories();
void PostCommand(JSSysCommandID id, stdstr paramA = "", stdstr paramB = "", void* paramC = nullptr);
void PostCommand(JSSysCommandID id, stdstr paramA = "", stdstr paramB = "", void * paramC = nullptr);
static DWORD WINAPI ThreadProc(void* _this);
static DWORD WINAPI ThreadProc(void * _this);
void ThreadProc();
bool ProcessCommand(JSSysCommand& cmd);
bool ProcessCommandQueue(std::vector<JSSysCommand>& queue);
void PullCommands(JSSysCommandID id, std::vector<JSSysCommand>& out);
bool ProcessCommand(JSSysCommand & cmd);
bool ProcessCommandQueue(std::vector<JSSysCommand> & queue);
void PullCommands(JSSysCommandID id, std::vector<JSSysCommand> & out);
void OnStartScript(const char* name, const char* path);
void OnStopScript(const char* name);
void OnInput(const char* name, const char* code);
void OnCMethodCall(const char* name, JSSysCMethodCall* methodCall);
void OnStartScript(const char * name, const char * path);
void OnStopScript(const char * name);
void OnInput(const char * name, const char * code);
void OnCMethodCall(const char * name, JSSysCMethodCall * methodCall);
void OnSweep(bool bIfDone);
bool RawRemoveInstance(const char* key);
bool RawRemoveInstance(const char * key);
void RefreshCallbackMaps();
static stdstr FixStringReturns(const char* str);
static stdstr FixStringReturns(const char * str);
};

View File

@ -1,5 +1,5 @@
#include <3rdparty/duktape/duktape.h>
#include <3rdparty/duktape/duk_module_duktape.h>
#include <3rdparty/duktape/duktape.h>
#include <cstdint>
#include <string>
@ -66,9 +66,9 @@ class CScriptInstance;
typedef std::string JSInstanceName;
struct JSAppCallback;
typedef duk_idx_t (*JSDukArgSetupFunc)(duk_context *ctx, void *argSetupParam);
typedef bool (*JSAppCallbackCondFunc)(JSAppCallback* cb, void* hookEnv);
typedef void (*JSAppCallbackCleanupFunc)(duk_context* ctx, void *hookEnv);
typedef duk_idx_t (*JSDukArgSetupFunc)(duk_context * ctx, void * argSetupParam);
typedef bool (*JSAppCallbackCondFunc)(JSAppCallback * cb, void * hookEnv);
typedef void (*JSAppCallbackCleanupFunc)(duk_context * ctx, void * hookEnv);
typedef size_t JSAppCallbackID;
#define JS_INVALID_CALLBACK ((JSAppCallbackID)(-1))
@ -76,26 +76,37 @@ typedef size_t JSAppCallbackID;
struct JSAppCallback
{
// assigned by scriptsys when this is added to a callback map
JSAppCallbackID m_CallbackId;
bool m_bDisabled;
JSAppCallbackID m_CallbackId;
bool m_bDisabled;
CScriptInstance *m_Instance;
void *m_DukFuncHeapPtr;
JSAppCallbackCondFunc m_ConditionFunc;
JSDukArgSetupFunc m_DukArgSetupFunc;
CScriptInstance * m_Instance;
void * m_DukFuncHeapPtr;
JSAppCallbackCondFunc m_ConditionFunc;
JSDukArgSetupFunc m_DukArgSetupFunc;
JSAppCallbackCleanupFunc m_CleanupFunc;
struct {
struct
{
uint32_t addrStart, addrEnd;
union {
struct { uint32_t opcode, opcodeMask; };
struct { uint32_t regIndices, regValue; };
union
{
struct
{
uint32_t opcode, opcodeMask;
};
struct
{
uint32_t regIndices, regValue;
};
};
} m_Params;
static bool CbCondTrue(JSAppCallback*, void*) { return true; }
static bool CbCondTrue(JSAppCallback *, void *)
{
return true;
}
JSAppCallback(CScriptInstance* instance, void* dukFuncHeapPtr,
JSAppCallback(CScriptInstance * instance, void * dukFuncHeapPtr,
JSAppCallbackCondFunc condFunc = nullptr,
JSDukArgSetupFunc argSetupFunc = nullptr,
JSAppCallbackCleanupFunc cleanupFunc = nullptr) :
@ -135,9 +146,9 @@ struct JSAppCallback
struct JSHookCpuStepEnv
{
uint32_t pc;
COpInfo opInfo;
int outAffectedRegIndex; // set by the condition function
uint32_t pc;
COpInfo opInfo;
int outAffectedRegIndex; // set by the condition function
};
struct JSHookMouseEnv
@ -168,7 +179,7 @@ struct JSHookSpTaskEnv
struct JSHookPiDmaEnv
{
int direction;
int direction;
uint32_t dramAddress;
uint32_t cartAddress;
uint32_t length;
@ -182,21 +193,21 @@ struct JSHookEmuStateChangeEnv
struct JSSysCommand
{
JSSysCommandID id;
stdstr paramA;
stdstr paramB;
void* paramC;
stdstr paramA;
stdstr paramB;
void * paramC;
};
struct JSSysCMethodCall
{
void* m_DukThisHeapPtr;
duk_c_function m_Func;
JSDukArgSetupFunc m_ArgSetupFunc;
void* m_ArgSetupParam;
void * m_DukThisHeapPtr;
duk_c_function m_Func;
JSDukArgSetupFunc m_ArgSetupFunc;
void * m_ArgSetupParam;
JSSysCMethodCall(void* dukThisHeapPtr, duk_c_function func,
JSSysCMethodCall(void * dukThisHeapPtr, duk_c_function func,
JSDukArgSetupFunc argSetupFunc = nullptr,
void* argSetupParam = nullptr,
void * argSetupParam = nullptr,
size_t argSetupParamSize = 0) :
m_DukThisHeapPtr(dukThisHeapPtr),
m_Func(func),
@ -205,7 +216,7 @@ struct JSSysCMethodCall
{
if (argSetupParam != nullptr && argSetupParamSize != 0)
{
m_ArgSetupParam = (void*)(new char[argSetupParamSize]);
m_ArgSetupParam = (void *)(new char[argSetupParamSize]);
memcpy(m_ArgSetupParam, argSetupParam, argSetupParamSize);
}
}
@ -214,7 +225,7 @@ struct JSSysCMethodCall
{
if (m_ArgSetupParam != nullptr)
{
delete[](char*)m_ArgSetupParam;
delete[](char *) m_ArgSetupParam;
}
}
};

View File

@ -8,19 +8,19 @@ class CScriptWorker
private:
bool m_bStopping;
bool m_bRegistered;
static DWORD WINAPI ThreadProc(void* _this);
static DWORD WINAPI ThreadProc(void * _this);
public:
CScriptWorker(CScriptInstance* instance, void* dukObjectHeapPtr);
CScriptWorker(CScriptInstance * instance, void * dukObjectHeapPtr);
virtual ~CScriptWorker();
void StartWorkerProc();
virtual void StopWorkerProc();
protected:
CScriptInstance* m_Instance;
void* m_DukObjectHeapPtr;
CriticalSection m_CS;
HANDLE m_hThread;
CScriptInstance * m_Instance;
void * m_DukObjectHeapPtr;
CriticalSection m_CS;
HANDLE m_hThread;
// Implementation should return when StopRequested() is true
virtual void WorkerProc() = 0;

View File

@ -38,7 +38,7 @@ symbol_type_info_t CSymbolTable::m_SymbolTypes[] = {
{SYM_VECTOR2, "v2", 8},
{SYM_VECTOR3, "v3", 12},
{SYM_VECTOR4, "v4", 16},
{ SYM_INVALID, nullptr, 0 }
{SYM_INVALID, nullptr, 0},
};
symbol_type_id_t CSymbolTable::GetTypeId(char * typeName)

View File

@ -2,7 +2,8 @@
class CSymbol;
typedef enum {
typedef enum
{
SYM_INVALID = -1,
SYM_CODE,
SYM_DATA,
@ -24,12 +25,13 @@ typedef enum {
typedef struct
{
symbol_type_id_t id;
const char* name;
int size;
symbol_type_id_t id;
const char * name;
int size;
} symbol_type_info_t;
typedef enum {
typedef enum
{
ERR_SUCCESS,
ERR_INVALID_TYPE,
ERR_INVALID_ADDR,
@ -40,62 +42,63 @@ typedef enum {
class CSymbolTable
{
public:
CSymbolTable(CDebuggerUI* debugger);
CSymbolTable(CDebuggerUI * debugger);
~CSymbolTable();
private:
CSymbolTable();
CDebuggerUI* m_Debugger;
CDebuggerUI * m_Debugger;
CriticalSection m_CS;
std::vector<CSymbol> m_Symbols;
std::map<uint32_t, size_t> m_AddressMap; // address -> symbol index
int m_NextSymbolId;
int m_NextSymbolId;
CFile m_SymFileHandle;
char* m_SymFileBuffer;
CFile m_SymFileHandle;
char * m_SymFileBuffer;
size_t m_SymFileSize;
char* m_ParserToken;
char * m_ParserToken;
size_t m_ParserTokenLength;
char* m_TokPos;
char m_ParserDelimeter;
char* m_SymFileParseBuffer;
bool m_bHaveFirstToken;
char * m_TokPos;
char m_ParserDelimeter;
char * m_SymFileParseBuffer;
bool m_bHaveFirstToken;
void ParserFetchToken(const char* delim);
void ParserFetchToken(const char * delim);
void UpdateAddressMap();
public:
static symbol_type_info_t m_SymbolTypes[];
static const char* GetTypeName(int typeId);
static const char * GetTypeName(int typeId);
static int GetTypeSize(int typeId);
static symbol_type_id_t GetTypeId(char* typeName);
static bool CmpSymbolAddresses(CSymbol& a, CSymbol& b);
static symbol_type_id_t GetTypeId(char * typeName);
static bool CmpSymbolAddresses(CSymbol & a, CSymbol & b);
void GetValueString(char* dst, CSymbol* symbol);
void GetValueString(char * dst, CSymbol * symbol);
CPath GetSymFilePath();
void Load();
void Save();
void ParseErrorAlert(char* message, int lineNumber);
void ParseErrorAlert(char * message, int lineNumber);
void AddSymbol(int type, uint32_t address, const char* name, const char* description = nullptr, bool bSortAfter = true);
void AddSymbol(int type, uint32_t address, const char * name, const char * description = nullptr, bool bSortAfter = true);
void Reset();
int GetCount();
bool GetSymbolById(int id, CSymbol* symbol);
bool GetSymbolByIndex(size_t index, CSymbol* symbol);
bool GetSymbolByAddress(uint32_t address, CSymbol* symbol);
int GetCount();
bool GetSymbolById(int id, CSymbol * symbol);
bool GetSymbolByIndex(size_t index, CSymbol * symbol);
bool GetSymbolByAddress(uint32_t address, CSymbol * symbol);
bool RemoveSymbolById(int id);
};
class CSymbol {
class CSymbol
{
public:
int m_Id;
int m_Type;
int m_Id;
int m_Type;
uint32_t m_Address;
char* m_Name;
char* m_Description;
char * m_Name;
char * m_Description;
CSymbol() :
m_Id(0),
@ -106,7 +109,7 @@ public:
{
}
CSymbol(int id, int type, uint32_t address, const char* name, const char* description) :
CSymbol(int id, int type, uint32_t address, const char * name, const char * description) :
m_Id(id),
m_Type(type),
m_Address(address),
@ -124,7 +127,7 @@ public:
}
}
CSymbol(const CSymbol& symbol):
CSymbol(const CSymbol & symbol) :
m_Id(symbol.m_Id),
m_Type(symbol.m_Type),
m_Address(symbol.m_Address),
@ -135,7 +138,7 @@ public:
m_Description = symbol.m_Description ? _strdup(symbol.m_Description) : nullptr;
}
CSymbol& operator= (const CSymbol& symbol)
CSymbol & operator=(const CSymbol & symbol)
{
if (m_Name != nullptr)
{
@ -168,7 +171,7 @@ public:
}
}
const char* TypeName()
const char * TypeName()
{
return CSymbolTable::GetTypeName(m_Type);
}

View File

@ -1,8 +1,8 @@
#pragma once
#include <Project64-core/Debugger.h>
#include <Common/SyncEvent.h>
#include <Project64-core/Settings/DebugSettings.h>
#include "DebugMMU.h"
#include <Common/SyncEvent.h>
#include <Project64-core/Debugger.h>
#include <Project64-core/Settings/DebugSettings.h>
class CDumpMemory;
class CDebugMemoryView;
@ -43,7 +43,7 @@ public:
void OpenCommandWindow(void);
void Debug_ShowCommandsLocation(uint32_t address, bool top);
void OpenScriptsWindow(void);
void Debug_LogScriptsWindow(const char* text);
void Debug_LogScriptsWindow(const char * text);
void Debug_ClearScriptsWindow(void);
void Debug_RefreshScriptsWindow(void);
void Debug_RefreshSymbolsWindow(void);
@ -71,14 +71,14 @@ public:
bool WriteBP64(uint32_t address);
void WaitForStep(void);
CBreakpoints* Breakpoints();
CDebugSymbols* Symbols();
CScriptSystem* ScriptSystem();
CDebugScripts* ScriptConsole();
CDMALog* DMALog();
CCPULog* CPULog();
CSymbolTable* SymbolTable();
SyncEvent& StepEvent();
CBreakpoints * Breakpoints();
CDebugSymbols * Symbols();
CScriptSystem * ScriptSystem();
CDebugScripts * ScriptConsole();
CDMALog * DMALog();
CCPULog * CPULog();
CSymbolTable * SymbolTable();
SyncEvent & StepEvent();
static void GameReset(CDebuggerUI * _this);
static void GameCpuRunningChanged(CDebuggerUI * _this);
@ -101,27 +101,27 @@ protected:
void EmulationStopped(void);
private:
CDebuggerUI(const CDebuggerUI&);
CDebuggerUI& operator=(const CDebuggerUI&);
CDebuggerUI(const CDebuggerUI &);
CDebuggerUI & operator=(const CDebuggerUI &);
CDumpMemory * m_MemoryDump;
CDebugMemoryView * m_MemoryView;
CDebugMemorySearch * m_MemorySearch;
CDebugTlb * m_DebugTLB;
CDebugCommandsView * m_CommandsView;
CDebugScripts * m_Scripts;
CDebugSymbols * m_Symbols;
CDebugDMALogView * m_DMALogView;
CDebugCPULogView * m_CPULogView;
CDebugStackTrace * m_StackTrace;
CDebugStackView * m_StackView;
CDumpMemory * m_MemoryDump;
CDebugMemoryView * m_MemoryView;
CDebugMemorySearch * m_MemorySearch;
CDebugTlb * m_DebugTLB;
CDebugCommandsView * m_CommandsView;
CDebugScripts * m_Scripts;
CDebugSymbols * m_Symbols;
CDebugDMALogView * m_DMALogView;
CDebugCPULogView * m_CPULogView;
CDebugStackTrace * m_StackTrace;
CDebugStackView * m_StackView;
CDebugExcBreakpoints * m_ExcBreakpoints;
CBreakpoints * m_Breakpoints;
CScriptSystem * m_ScriptSystem;
CSymbolTable * m_SymbolTable;
CDMALog * m_DMALog;
CCPULog * m_CPULog;
CBreakpoints * m_Breakpoints;
CScriptSystem * m_ScriptSystem;
CSymbolTable * m_SymbolTable;
CDMALog * m_DMALog;
CCPULog * m_CPULog;
SyncEvent m_StepEvent;

View File

@ -4,10 +4,10 @@
class CDiscord
{
private:
static int64_t Timestamp(void);
static int64_t Timestamp(void);
public:
static void Init(void);
static void Shutdown(void);
static void Update(bool bHaveGame = true);
static void Init(void);
static void Shutdown(void);
static void Update(bool bHaveGame = true);
};

View File

@ -1,36 +1,41 @@
#include "stdafx.h"
#include <Project64\UserInterface\EnhancementUI.h>
#include <Project64-core/N64System/Enhancement/Enhancements.h>
#include <Project64\UserInterface\EnhancementUI.h>
class CEditEnhancement :
public CDialogImpl < CEditEnhancement >
public CDialogImpl<CEditEnhancement>
{
public:
BEGIN_MSG_MAP_EX(CEditEnhancement)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
COMMAND_HANDLER_EX(IDC_GAMESHARK, BN_CLICKED, OnGamesharkBtn)
COMMAND_HANDLER_EX(IDC_OVERCLOCK, BN_CLICKED, OnOverClockBtn)
COMMAND_ID_HANDLER(IDC_BTN_GAMESHARK, OnEditGameshark)
COMMAND_ID_HANDLER(IDOK, OnOkCmd)
COMMAND_ID_HANDLER(IDCANCEL, OnCloseCmd)
{
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog);
COMMAND_HANDLER_EX(IDC_GAMESHARK, BN_CLICKED, OnGamesharkBtn);
COMMAND_HANDLER_EX(IDC_OVERCLOCK, BN_CLICKED, OnOverClockBtn);
COMMAND_ID_HANDLER(IDC_BTN_GAMESHARK, OnEditGameshark);
COMMAND_ID_HANDLER(IDOK, OnOkCmd);
COMMAND_ID_HANDLER(IDCANCEL, OnCloseCmd);
}
END_MSG_MAP()
enum { IDD = IDD_Enhancement_Edit };
enum
{
IDD = IDD_Enhancement_Edit
};
CEditEnhancement(CEnhancementUI & EnhancementUI, CEnhancement * Enhancement);
private:
CEditEnhancement(void);
CEditEnhancement(const CEditEnhancement&);
CEditEnhancement& operator=(const CEditEnhancement&);
CEditEnhancement(const CEditEnhancement &);
CEditEnhancement & operator=(const CEditEnhancement &);
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled);
LRESULT OnGamesharkBtn(UINT Code, int id, HWND ctl);
LRESULT OnOverClockBtn(UINT Code, int id, HWND ctl);
LRESULT OnEditGameshark(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnOkCmd(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnCloseCmd(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnEditGameshark(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL & bHandled);
LRESULT OnOkCmd(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL & bHandled);
LRESULT OnCloseCmd(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL & bHandled);
CEnhancementUI & m_EnhancementUI;
CEnhancement::CodeEntries m_Entries;
@ -43,26 +48,31 @@ class CEditGS :
{
public:
BEGIN_MSG_MAP_EX(CEditGS)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
COMMAND_HANDLER(IDC_CHEAT_CODES, EN_CHANGE, OnCheatChanged)
COMMAND_HANDLER_EX(IDC_CHK_LIMIT_PLUGINS, BN_CLICKED, OnPluginBtn)
COMMAND_ID_HANDLER(IDC_BTN_PLUGIN, OnEditPlugins)
COMMAND_ID_HANDLER(IDOK, OnOkCmd)
COMMAND_ID_HANDLER(IDCANCEL, OnCloseCmd)
{
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog);
COMMAND_HANDLER(IDC_CHEAT_CODES, EN_CHANGE, OnCheatChanged);
COMMAND_HANDLER_EX(IDC_CHK_LIMIT_PLUGINS, BN_CLICKED, OnPluginBtn);
COMMAND_ID_HANDLER(IDC_BTN_PLUGIN, OnEditPlugins);
COMMAND_ID_HANDLER(IDOK, OnOkCmd);
COMMAND_ID_HANDLER(IDCANCEL, OnCloseCmd);
}
END_MSG_MAP()
enum { IDD = IDD_Enhancement_GS };
enum
{
IDD = IDD_Enhancement_GS
};
CEditGS(CEnhancement::CodeEntries & Entries, CEnhancement::PluginList & PluginList);
private:
CEditGS();
CEditGS(const CEditGS&);
CEditGS& operator=(const CEditGS&);
CEditGS(const CEditGS &);
CEditGS & operator=(const CEditGS &);
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled);
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled);
LRESULT OnPluginBtn(UINT Code, int id, HWND ctl);
LRESULT OnEditPlugins(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnEditPlugins(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL & bHandled);
LRESULT OnCloseCmd(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL & bHandled);
LRESULT OnOkCmd(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL & bHandled);
LRESULT OnCheatChanged(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL & bHandled);
@ -78,28 +88,33 @@ class CEditPluginList :
{
public:
BEGIN_MSG_MAP_EX(CEditPluginList)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
COMMAND_ID_HANDLER(IDC_ADD, OnAddBtn)
COMMAND_ID_HANDLER(IDC_REMOVE, OnRemoveBtn)
COMMAND_ID_HANDLER(IDOK, OnOkCmd)
COMMAND_ID_HANDLER(IDCANCEL, OnCloseCmd)
{
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog);
COMMAND_ID_HANDLER(IDC_ADD, OnAddBtn);
COMMAND_ID_HANDLER(IDC_REMOVE, OnRemoveBtn);
COMMAND_ID_HANDLER(IDOK, OnOkCmd);
COMMAND_ID_HANDLER(IDCANCEL, OnCloseCmd);
}
END_MSG_MAP()
enum { IDD = IDD_Enhancement_Plugins };
enum
{
IDD = IDD_Enhancement_Plugins
};
CEditPluginList(CEnhancement::PluginList & List);
private:
CEditPluginList();
CEditPluginList(const CEditPluginList&);
CEditPluginList& operator=(const CEditPluginList&);
CEditPluginList(const CEditPluginList &);
CEditPluginList & operator=(const CEditPluginList &);
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled);
LRESULT OnAddBtn(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnRemoveBtn(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled);
LRESULT OnAddBtn(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL & bHandled);
LRESULT OnRemoveBtn(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL & bHandled);
LRESULT OnCloseCmd(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL & bHandled);
LRESULT OnOkCmd(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL & bHandled);
CListBox m_PluginListBox;
CEnhancement::PluginList & m_PluginList;
};
@ -132,7 +147,7 @@ void CEnhancementUI::Display(HWND hParent, bool BlockExecution)
}
}
LRESULT CEnhancementUI::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
LRESULT CEnhancementUI::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & /*bHandled*/)
{
SetWindowText(wGS(ENHANCEMENT_TITLE).c_str());
@ -157,7 +172,7 @@ LRESULT CEnhancementUI::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*
int32_t X = (((rcParent.Width()) - DlgWidth) / 2) + rcParent.left;
int32_t Y = (((rcParent.Height()) - DlgHeight) / 2) + rcParent.top;
SetWindowPos(nullptr, X, Y, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
RefreshList();
ShowWindow(SW_SHOW);
return TRUE;
@ -169,7 +184,7 @@ LRESULT CEnhancementUI::OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lPa
return 0;
}
LRESULT CEnhancementUI::OnCloseCmd(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
LRESULT CEnhancementUI::OnCloseCmd(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL & /*bHandled*/)
{
if (g_BaseSystem)
{
@ -186,9 +201,9 @@ LRESULT CEnhancementUI::OnCloseCmd(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hW
return TRUE;
}
LRESULT CEnhancementUI::OnEditEnhancement(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
LRESULT CEnhancementUI::OnEditEnhancement(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL & /*bHandled*/)
{
TVITEM item = { 0 };
TVITEM item = {0};
item.mask = TVIF_PARAM;
item.hItem = m_hSelectedItem;
if (!m_TreeList.GetItem(&item) || item.lParam == NULL)
@ -200,17 +215,17 @@ LRESULT CEnhancementUI::OnEditEnhancement(WORD /*wNotifyCode*/, WORD /*wID*/, HW
return TRUE;
}
LRESULT CEnhancementUI::OnAddEnhancement(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
LRESULT CEnhancementUI::OnAddEnhancement(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL & /*bHandled*/)
{
CEditEnhancement(*this, nullptr).DoModal(m_hWnd);
RefreshList();
return TRUE;
}
LRESULT CEnhancementUI::OnEnhancementListClicked(NMHDR* lpnmh)
LRESULT CEnhancementUI::OnEnhancementListClicked(NMHDR * lpnmh)
{
uint32_t dwpos = GetMessagePos();
TVHITTESTINFO ht = { 0 };
TVHITTESTINFO ht = {0};
ht.pt.x = GET_X_LPARAM(dwpos);
ht.pt.y = GET_Y_LPARAM(dwpos);
::MapWindowPoints(HWND_DESKTOP, lpnmh->hwndFrom, &ht.pt, 1);
@ -248,7 +263,7 @@ LRESULT CEnhancementUI::OnEnhancementListClicked(NMHDR* lpnmh)
return 0;
}
LRESULT CEnhancementUI::OnPopupDelete(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
LRESULT CEnhancementUI::OnPopupDelete(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL & bHandled)
{
int Response = MessageBox(wGS(MSG_DEL_SURE).c_str(), wGS(MSG_DEL_TITLE).c_str(), MB_YESNO | MB_ICONQUESTION);
if (Response != IDYES)
@ -256,7 +271,7 @@ LRESULT CEnhancementUI::OnPopupDelete(WORD wNotifyCode, WORD wID, HWND hWndCtl,
return 0;
}
TVITEM item = { 0 };
TVITEM item = {0};
item.hItem = m_hSelectedItem;
item.mask = TVIF_PARAM;
m_TreeList.GetItem(&item);
@ -276,9 +291,9 @@ LRESULT CEnhancementUI::OnPopupDelete(WORD wNotifyCode, WORD wID, HWND hWndCtl,
return 0;
}
LRESULT CEnhancementUI::OnEnhancementListRClicked(NMHDR* pNMHDR)
LRESULT CEnhancementUI::OnEnhancementListRClicked(NMHDR * pNMHDR)
{
TVHITTESTINFO ht = { 0 };
TVHITTESTINFO ht = {0};
uint32_t dwpos = GetMessagePos();
ht.pt.x = GET_X_LPARAM(dwpos);
ht.pt.y = GET_Y_LPARAM(dwpos);
@ -307,7 +322,7 @@ LRESULT CEnhancementUI::OnEnhancementListRClicked(NMHDR* pNMHDR)
LRESULT CEnhancementUI::OnEnhancementListDClicked(NMHDR * lpnmh)
{
uint32_t dwpos = GetMessagePos();
TVHITTESTINFO ht = { 0 };
TVHITTESTINFO ht = {0};
ht.pt.x = GET_X_LPARAM(dwpos);
ht.pt.y = GET_Y_LPARAM(dwpos);
::MapWindowPoints(HWND_DESKTOP, lpnmh->hwndFrom, &ht.pt, 1);
@ -318,7 +333,7 @@ LRESULT CEnhancementUI::OnEnhancementListDClicked(NMHDR * lpnmh)
{
return 0;
}
TVITEM item = { 0 };
TVITEM item = {0};
item.mask = TVIF_PARAM;
item.hItem = (HTREEITEM)ht.hItem;
if (!m_TreeList.GetItem(&item) || item.lParam == NULL)
@ -337,7 +352,7 @@ LRESULT CEnhancementUI::OnEnhancementListSelChanged(NMHDR * /*lpnmh*/)
GetDlgItem(IDC_NOTES).SetWindowText(L"");
if (m_TreeList.GetChildItem(hItem) == nullptr)
{
TVITEM item = { 0 };
TVITEM item = {0};
item.mask = TVIF_PARAM;
item.hItem = hItem;
m_TreeList.GetItem(&item);
@ -355,9 +370,15 @@ void CEnhancementUI::AddCodeLayers(LPARAM Enhancement, const std::wstring & Name
TV_INSERTSTRUCT tv;
wchar_t Text[500], Item[500];
if (Name.length() > ((sizeof(Text) / sizeof(Text[0])) - 5)) { g_Notify->BreakPoint(__FILE__, __LINE__); }
if (Name.length() > ((sizeof(Text) / sizeof(Text[0])) - 5))
{
g_Notify->BreakPoint(__FILE__, __LINE__);
}
wcscpy(Text, Name.c_str());
if (wcschr(Text, L'\\') > 0) { *wcschr(Text, L'\\') = 0; }
if (wcschr(Text, L'\\') > 0)
{
*wcschr(Text, L'\\') = 0;
}
tv.item.mask = TVIF_TEXT;
tv.item.pszText = Item;
@ -393,18 +414,25 @@ void CEnhancementUI::AddCodeLayers(LPARAM Enhancement, const std::wstring & Name
hParent = m_TreeList.InsertItem(&tv);
TV_SetCheckState(hParent, Active ? TV_STATE_CHECKED : TV_STATE_CLEAR);
if (wcscmp(Text, Name.c_str()) == 0) { return; }
if (wcscmp(Text, Name.c_str()) == 0)
{
return;
}
AddCodeLayers(Enhancement, Name.substr(wcslen(Text) + 1), hParent, Active);
}
void CEnhancementUI::ChangeChildrenStatus(HTREEITEM hParent, bool Checked)
{
HTREEITEM hItem = m_TreeList.GetChildItem(hParent);;
HTREEITEM hItem = m_TreeList.GetChildItem(hParent);
;
if (hItem == nullptr)
{
if (hParent == TVI_ROOT) { return; }
if (hParent == TVI_ROOT)
{
return;
}
TVITEM item = { 0 };
TVITEM item = {0};
item.mask = TVIF_PARAM;
item.hItem = hParent;
m_TreeList.GetItem(&item);
@ -430,14 +458,19 @@ void CEnhancementUI::ChangeChildrenStatus(HTREEITEM hParent, bool Checked)
while (hItem != nullptr)
{
TV_CHECK_STATE ChildState = TV_GetCheckState(hItem);
if ((ChildState != TV_STATE_CHECKED || !Checked) &&
(ChildState != TV_STATE_CLEAR || Checked))
if ((ChildState != TV_STATE_CHECKED || !Checked) && (ChildState != TV_STATE_CLEAR || Checked))
{
ChangeChildrenStatus(hItem, Checked);
}
ChildState = TV_GetCheckState(hItem);
if (state == TV_STATE_UNKNOWN) { state = ChildState; }
if (state != ChildState) { state = TV_STATE_INDETERMINATE; }
if (state == TV_STATE_UNKNOWN)
{
state = ChildState;
}
if (state != ChildState)
{
state = TV_STATE_INDETERMINATE;
}
hItem = m_TreeList.GetNextSiblingItem(hItem);
}
if (state != TV_STATE_UNKNOWN)
@ -487,7 +520,7 @@ void CEnhancementUI::RefreshList()
CEnhancementUI::TV_CHECK_STATE CEnhancementUI::TV_GetCheckState(HTREEITEM hItem)
{
TVITEM tvItem = { 0 };
TVITEM tvItem = {0};
tvItem.mask = TVIF_HANDLE | TVIF_STATE;
tvItem.hItem = hItem;
tvItem.stateMask = TVIS_STATEIMAGEMASK;
@ -505,7 +538,7 @@ CEnhancementUI::TV_CHECK_STATE CEnhancementUI::TV_GetCheckState(HTREEITEM hItem)
bool CEnhancementUI::TV_SetCheckState(HTREEITEM hItem, TV_CHECK_STATE state)
{
TVITEM tvItem = { 0 };
TVITEM tvItem = {0};
tvItem.mask = TVIF_HANDLE | TVIF_STATE;
tvItem.hItem = (HTREEITEM)hItem;
tvItem.stateMask = TVIS_STATEIMAGEMASK;
@ -526,7 +559,7 @@ CEditEnhancement::CEditEnhancement(CEnhancementUI & EnhancementUI, CEnhancement
{
}
LRESULT CEditEnhancement::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
LRESULT CEditEnhancement::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & /*bHandled*/)
{
m_Entries = m_EditEnhancement != nullptr ? m_EditEnhancement->GetEntries() : CEnhancement::CodeEntries();
m_PluginList = m_EditEnhancement != nullptr ? m_EditEnhancement->GetPluginList() : CEnhancement::PluginList();
@ -536,7 +569,7 @@ LRESULT CEditEnhancement::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM
CButton(GetDlgItem(IDC_AUTOON)).SetCheck(m_EditEnhancement != nullptr ? (m_EditEnhancement->GetOnByDefault() ? BST_CHECKED : BST_UNCHECKED) : BST_UNCHECKED);
CButton(GetDlgItem(IDC_GAMESHARK)).SetCheck(m_Entries.size() > 0 ? BST_CHECKED : BST_UNCHECKED);
CButton(GetDlgItem(IDC_OVERCLOCK)).SetCheck(m_EditEnhancement != nullptr ? (m_EditEnhancement->OverClock() ? BST_CHECKED : BST_UNCHECKED) : BST_UNCHECKED);
GetDlgItem(IDC_OVER_CLOCK_MODIFIER).SetWindowText(m_EditEnhancement != nullptr ? stdstr_f("%d",m_EditEnhancement->OverClockModifier()).ToUTF16().c_str() : L"1");
GetDlgItem(IDC_OVER_CLOCK_MODIFIER).SetWindowText(m_EditEnhancement != nullptr ? stdstr_f("%d", m_EditEnhancement->OverClockModifier()).ToUTF16().c_str() : L"1");
GetDlgItem(IDC_OVER_CLOCK_MODIFIER).EnableWindow(m_EditEnhancement != nullptr ? m_EditEnhancement->OverClock() : false);
return TRUE;
@ -556,19 +589,19 @@ LRESULT CEditEnhancement::OnOverClockBtn(UINT /*Code*/, int /*id*/, HWND /*ctl*/
return 0;
}
LRESULT CEditEnhancement::OnEditGameshark(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
LRESULT CEditEnhancement::OnEditGameshark(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL & /*bHandled*/)
{
OnGamesharkBtn(0, 0, 0);
return TRUE;
}
LRESULT CEditEnhancement::OnCloseCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
LRESULT CEditEnhancement::OnCloseCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL & /*bHandled*/)
{
EndDialog(wID);
return TRUE;
}
LRESULT CEditEnhancement::OnOkCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
LRESULT CEditEnhancement::OnOkCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL & /*bHandled*/)
{
CEnhancement TempEnhancement(CEnhancement::EnhancementIdent);
CEnhancement & Enhancement = m_EditEnhancement != nullptr ? *m_EditEnhancement : TempEnhancement;
@ -597,7 +630,7 @@ CEditGS::CEditGS(CEnhancement::CodeEntries & Entries, CEnhancement::PluginList &
{
}
LRESULT CEditGS::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
LRESULT CEditGS::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & /*bHandled*/)
{
stdstr Buffer;
for (size_t i = 0, n = m_Entries.size(); i < n; i++)
@ -623,20 +656,20 @@ LRESULT CEditGS::OnPluginBtn(UINT /*Code*/, int /*id*/, HWND /*ctl*/)
return 0;
}
LRESULT CEditGS::OnEditPlugins(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
LRESULT CEditGS::OnEditPlugins(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL & /*bHandled*/)
{
OnPluginBtn(0, 0, 0);
return 0;
}
LRESULT CEditGS::OnCheatChanged(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
LRESULT CEditGS::OnCheatChanged(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL & /*bHandled*/)
{
CEnhancement::CodeEntries Entries;
GetDlgItem(IDOK).EnableWindow(CheatCode(Entries));
return true;
}
LRESULT CEditGS::OnOkCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
LRESULT CEditGS::OnOkCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL & /*bHandled*/)
{
CEnhancement::CodeEntries Entries;
if (CheatCode(Entries))
@ -647,7 +680,7 @@ LRESULT CEditGS::OnOkCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL&
return TRUE;
}
LRESULT CEditGS::OnCloseCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
LRESULT CEditGS::OnCloseCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL & /*bHandled*/)
{
EndDialog(wID);
return TRUE;
@ -665,15 +698,18 @@ bool CEditGS::CheatCode(CEnhancement::CodeEntries & Entries)
{
const char * formatnormal = "XXXXXXXX XXXX";
wchar_t wstr[128] = { 0 };
wchar_t wstr[128] = {0};
*(LPWORD)wstr = sizeof(wstr) / sizeof(wstr[0]);
uint32_t len = CheatCodes.GetLine(line, wstr);
wstr[len] = 0;
if (len <= 0) { continue; }
if (len <= 0)
{
continue;
}
std::string str = stdstr().FromUTF16(wstr);
char tempformat[128] = { 0 };
char tempformat[128] = {0};
for (uint32_t i = 0; i < sizeof(tempformat); i++)
{
if (isxdigit(str[i]))
@ -684,7 +720,10 @@ bool CEditGS::CheatCode(CEnhancement::CodeEntries & Entries)
{
tempformat[i] = str[i];
}
if (str[i] == 0) { break; }
if (str[i] == 0)
{
break;
}
}
if (strcmp(tempformat, formatnormal) == 0)
@ -728,7 +767,7 @@ CEditPluginList::CEditPluginList(CEnhancement::PluginList & List) :
{
}
LRESULT CEditPluginList::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & /*bHandled*/)
LRESULT CEditPluginList::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & /*bHandled*/)
{
m_PluginListBox.Attach(GetDlgItem(IDC_PLUGIN_LIST));
for (size_t i = 0, n = m_PluginList.size(); i < n; i++)
@ -740,7 +779,7 @@ LRESULT CEditPluginList::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /
LRESULT CEditPluginList::OnAddBtn(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL & /*bHandled*/)
{
CWindow hEdit = GetDlgItem(IDC_ADD_EDIT);
CWindow hEdit = GetDlgItem(IDC_ADD_EDIT);
stdstr PluginName = stdstr(GetCWindowText(hEdit)).Trim();
std::wstring wPluginName = PluginName.ToUTF16();
if (PluginName.empty())

View File

@ -16,19 +16,24 @@ class CEnhancementUI :
public:
BEGIN_MSG_MAP_EX(CEnhancementUI)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
COMMAND_ID_HANDLER(IDCANCEL, OnCloseCmd)
COMMAND_ID_HANDLER(ID_POPUP_EDIT, OnEditEnhancement)
COMMAND_ID_HANDLER(ID_POPUP_ADDENHANCEMENT, OnAddEnhancement)
COMMAND_ID_HANDLER(ID_POPUP_DELETE, OnPopupDelete)
NOTIFY_HANDLER_EX(IDC_ENHANCEMENTLIST, NM_CLICK, OnEnhancementListClicked)
NOTIFY_HANDLER_EX(IDC_ENHANCEMENTLIST, NM_RCLICK, OnEnhancementListRClicked)
NOTIFY_HANDLER_EX(IDC_ENHANCEMENTLIST, NM_DBLCLK, OnEnhancementListDClicked)
NOTIFY_HANDLER_EX(IDC_ENHANCEMENTLIST, TVN_SELCHANGED, OnEnhancementListSelChanged)
{
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog);
MESSAGE_HANDLER(WM_DESTROY, OnDestroy);
COMMAND_ID_HANDLER(IDCANCEL, OnCloseCmd);
COMMAND_ID_HANDLER(ID_POPUP_EDIT, OnEditEnhancement);
COMMAND_ID_HANDLER(ID_POPUP_ADDENHANCEMENT, OnAddEnhancement);
COMMAND_ID_HANDLER(ID_POPUP_DELETE, OnPopupDelete);
NOTIFY_HANDLER_EX(IDC_ENHANCEMENTLIST, NM_CLICK, OnEnhancementListClicked);
NOTIFY_HANDLER_EX(IDC_ENHANCEMENTLIST, NM_RCLICK, OnEnhancementListRClicked);
NOTIFY_HANDLER_EX(IDC_ENHANCEMENTLIST, NM_DBLCLK, OnEnhancementListDClicked);
NOTIFY_HANDLER_EX(IDC_ENHANCEMENTLIST, TVN_SELCHANGED, OnEnhancementListSelChanged);
}
END_MSG_MAP()
enum { IDD = IDD_Enhancement_Config };
enum
{
IDD = IDD_Enhancement_Config
};
CEnhancementUI();
@ -37,15 +42,15 @@ public:
private:
friend CEditEnhancement;
CEnhancementUI(const CEnhancementUI&);
CEnhancementUI& operator=(const CEnhancementUI&);
CEnhancementUI(const CEnhancementUI &);
CEnhancementUI & operator=(const CEnhancementUI &);
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled);
LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled);
LRESULT OnEditEnhancement(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL & bHandled);
LRESULT OnAddEnhancement(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL & bHandled );
LRESULT OnAddEnhancement(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL & bHandled);
LRESULT OnCloseCmd(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL & bHandled);
LRESULT OnPopupDelete(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnPopupDelete(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL & bHandled);
LRESULT OnEnhancementListClicked(NMHDR * lpnmh);
LRESULT OnEnhancementListRClicked(NMHDR * lpnmh);
LRESULT OnEnhancementListDClicked(NMHDR * lpnmh);

View File

@ -61,18 +61,45 @@ LRESULT CALLBACK LogGeneralProc(HWND hDlg, UINT uMsg, WPARAM /*wParam*/, LPARAM
{
case WM_INITDIALOG:
{
if (CLogSettings::LogCP0changes()) { CheckDlgButton(hDlg, IDC_CP0_WRITE, BST_CHECKED); }
if (CLogSettings::LogCP0reads()) { CheckDlgButton(hDlg, IDC_CP0_READ, BST_CHECKED); }
if (CLogSettings::LogCache()) { CheckDlgButton(hDlg, IDC_CACHE, BST_CHECKED); }
if (CLogSettings::LogExceptions()) { CheckDlgButton(hDlg, IDC_EXCEPTIONS, BST_CHECKED); }
if (CLogSettings::LogNoInterrupts()) { CheckDlgButton(hDlg, IDC_INTERRUPTS, BST_CHECKED); }
if (CLogSettings::LogTLB()) { CheckDlgButton(hDlg, IDC_TLB, BST_CHECKED); }
if (CLogSettings::LogRomHeader()) { CheckDlgButton(hDlg, IDC_ROM_HEADER, BST_CHECKED); }
if (CLogSettings::LogUnknown()) { CheckDlgButton(hDlg, IDC_UNKOWN, BST_CHECKED); }
if (CLogSettings::LogCP0changes())
{
CheckDlgButton(hDlg, IDC_CP0_WRITE, BST_CHECKED);
}
if (CLogSettings::LogCP0reads())
{
CheckDlgButton(hDlg, IDC_CP0_READ, BST_CHECKED);
}
if (CLogSettings::LogCache())
{
CheckDlgButton(hDlg, IDC_CACHE, BST_CHECKED);
}
if (CLogSettings::LogExceptions())
{
CheckDlgButton(hDlg, IDC_EXCEPTIONS, BST_CHECKED);
}
if (CLogSettings::LogNoInterrupts())
{
CheckDlgButton(hDlg, IDC_INTERRUPTS, BST_CHECKED);
}
if (CLogSettings::LogTLB())
{
CheckDlgButton(hDlg, IDC_TLB, BST_CHECKED);
}
if (CLogSettings::LogRomHeader())
{
CheckDlgButton(hDlg, IDC_ROM_HEADER, BST_CHECKED);
}
if (CLogSettings::LogUnknown())
{
CheckDlgButton(hDlg, IDC_UNKOWN, BST_CHECKED);
}
}
break;
case WM_NOTIFY:
if (((NMHDR FAR *) lParam)->code != PSN_APPLY) { break; }
if (((NMHDR FAR *)lParam)->code != PSN_APPLY)
{
break;
}
g_Settings->SaveBool(Logging_LogCP0changes, IsDlgButtonChecked(hDlg, IDC_CP0_WRITE) == BST_CHECKED ? true : false);
g_Settings->SaveBool(Logging_LogCP0reads, IsDlgButtonChecked(hDlg, IDC_CP0_READ) == BST_CHECKED ? true : false);
g_Settings->SaveBool(Logging_LogCache, IsDlgButtonChecked(hDlg, IDC_CACHE) == BST_CHECKED ? true : false);
@ -94,12 +121,30 @@ LRESULT CALLBACK LogPifProc(HWND hDlg, UINT uMsg, WPARAM /*wParam*/, LPARAM lPar
{
case WM_INITDIALOG:
{
if (CLogSettings::LogPRDMAOperations()) { CheckDlgButton(hDlg, IDC_SI_DMA, BST_CHECKED); }
if (CLogSettings::LogPRDirectMemLoads()) { CheckDlgButton(hDlg, IDC_DIRECT_WRITE, BST_CHECKED); }
if (CLogSettings::LogPRDMAMemLoads()) { CheckDlgButton(hDlg, IDC_DMA_WRITE, BST_CHECKED); }
if (CLogSettings::LogPRDirectMemStores()) { CheckDlgButton(hDlg, IDC_DIRECT_READ, BST_CHECKED); }
if (CLogSettings::LogPRDMAMemStores()) { CheckDlgButton(hDlg, IDC_DMA_READ, BST_CHECKED); }
if (CLogSettings::LogControllerPak()) { CheckDlgButton(hDlg, IDC_CONT_PAK, BST_CHECKED); }
if (CLogSettings::LogPRDMAOperations())
{
CheckDlgButton(hDlg, IDC_SI_DMA, BST_CHECKED);
}
if (CLogSettings::LogPRDirectMemLoads())
{
CheckDlgButton(hDlg, IDC_DIRECT_WRITE, BST_CHECKED);
}
if (CLogSettings::LogPRDMAMemLoads())
{
CheckDlgButton(hDlg, IDC_DMA_WRITE, BST_CHECKED);
}
if (CLogSettings::LogPRDirectMemStores())
{
CheckDlgButton(hDlg, IDC_DIRECT_READ, BST_CHECKED);
}
if (CLogSettings::LogPRDMAMemStores())
{
CheckDlgButton(hDlg, IDC_DMA_READ, BST_CHECKED);
}
if (CLogSettings::LogControllerPak())
{
CheckDlgButton(hDlg, IDC_CONT_PAK, BST_CHECKED);
}
}
break;
case WM_NOTIFY:
@ -126,16 +171,46 @@ LRESULT CALLBACK LogRegProc(HWND hDlg, UINT uMsg, WPARAM /*wParam*/, LPARAM lPar
{
case WM_INITDIALOG:
{
if (CLogSettings::LogRDRamRegisters()) { CheckDlgButton(hDlg, IDC_RDRAM, BST_CHECKED); }
if (CLogSettings::LogSPRegisters()) { CheckDlgButton(hDlg, IDC_SP_REG, BST_CHECKED); }
if (CLogSettings::LogDPCRegisters()) { CheckDlgButton(hDlg, IDC_DPC_REG, BST_CHECKED); }
if (CLogSettings::LogDPSRegisters()) { CheckDlgButton(hDlg, IDC_DPS_REG, BST_CHECKED); }
if (CLogSettings::LogMIPSInterface()) { CheckDlgButton(hDlg, IDC_MI_REG, BST_CHECKED); }
if (CLogSettings::LogVideoInterface()) { CheckDlgButton(hDlg, IDC_VI_REG, BST_CHECKED); }
if (CLogSettings::LogAudioInterface()) { CheckDlgButton(hDlg, IDC_AI_REG, BST_CHECKED); }
if (CLogSettings::LogPerInterface()) { CheckDlgButton(hDlg, IDC_PI_REG, BST_CHECKED); }
if (CLogSettings::LogRDRAMInterface()) { CheckDlgButton(hDlg, IDC_RI_REG, BST_CHECKED); }
if (CLogSettings::LogSerialInterface()) { CheckDlgButton(hDlg, IDC_SI_REG, BST_CHECKED); }
if (CLogSettings::LogRDRamRegisters())
{
CheckDlgButton(hDlg, IDC_RDRAM, BST_CHECKED);
}
if (CLogSettings::LogSPRegisters())
{
CheckDlgButton(hDlg, IDC_SP_REG, BST_CHECKED);
}
if (CLogSettings::LogDPCRegisters())
{
CheckDlgButton(hDlg, IDC_DPC_REG, BST_CHECKED);
}
if (CLogSettings::LogDPSRegisters())
{
CheckDlgButton(hDlg, IDC_DPS_REG, BST_CHECKED);
}
if (CLogSettings::LogMIPSInterface())
{
CheckDlgButton(hDlg, IDC_MI_REG, BST_CHECKED);
}
if (CLogSettings::LogVideoInterface())
{
CheckDlgButton(hDlg, IDC_VI_REG, BST_CHECKED);
}
if (CLogSettings::LogAudioInterface())
{
CheckDlgButton(hDlg, IDC_AI_REG, BST_CHECKED);
}
if (CLogSettings::LogPerInterface())
{
CheckDlgButton(hDlg, IDC_PI_REG, BST_CHECKED);
}
if (CLogSettings::LogRDRAMInterface())
{
CheckDlgButton(hDlg, IDC_RI_REG, BST_CHECKED);
}
if (CLogSettings::LogSerialInterface())
{
CheckDlgButton(hDlg, IDC_SI_REG, BST_CHECKED);
}
}
break;
case WM_NOTIFY:

View File

@ -1,3 +1,3 @@
#pragma once
void EnterLogOptions ( HWND hwndOwner );
void EnterLogOptions(HWND hwndOwner);

View File

@ -94,7 +94,10 @@ int CMainMenu::ProcessAccelerator(HWND hWnd, void * lpMsg)
m_ResetAccelerators = false;
RebuildAccelerators();
}
if (!m_AccelTable) { return false; }
if (!m_AccelTable)
{
return false;
}
return TranslateAccelerator((HWND)hWnd, (HACCEL)m_AccelTable, (LPMSG)lpMsg);
}
@ -604,8 +607,7 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI
if (MenuID >= ID_RECENT_ROM_START && MenuID < ID_RECENT_ROM_END)
{
stdstr FileName;
if (UISettingsLoadStringIndex(File_RecentGameFileIndex, MenuID - ID_RECENT_ROM_START, FileName) &&
FileName.length() > 0)
if (UISettingsLoadStringIndex(File_RecentGameFileIndex, MenuID - ID_RECENT_ROM_START, FileName) && FileName.length() > 0)
{
if ((CPath(FileName).GetExtension() != "ndd") && (CPath(FileName).GetExtension() != "d64"))
g_BaseSystem->RunFileImage(FileName.c_str());
@ -692,7 +694,10 @@ std::wstring CMainMenu::GetSaveSlotString(int Slot)
case 10: SlotName = GS(MENU_SLOT_10); break;
}
if (!g_Settings->LoadBool(GameRunning_CPU_Running)) { return SlotName.ToUTF16(); }
if (!g_Settings->LoadBool(GameRunning_CPU_Running))
{
return SlotName.ToUTF16();
}
stdstr LastSaveTime;
@ -880,38 +885,71 @@ void CMainMenu::FillOutMenu(HMENU hMenu)
MenuItemList CurrentSaveMenu;
DWORD _CurrentSaveState = g_Settings->LoadDword(Game_CurrentSaveState);
Item.Reset(ID_CURRENT_SAVE_DEFAULT, EMPTY_STRING, m_ShortCuts.ShortCutString(ID_CURRENT_SAVE_DEFAULT, RunningState), nullptr, GetSaveSlotString(0));
if (_CurrentSaveState == 0) { Item.SetItemTicked(true); }
if (_CurrentSaveState == 0)
{
Item.SetItemTicked(true);
}
CurrentSaveMenu.push_back(Item);
CurrentSaveMenu.push_back(MENU_ITEM(SPLITER));
Item.Reset(ID_CURRENT_SAVE_1, EMPTY_STRING, m_ShortCuts.ShortCutString(ID_CURRENT_SAVE_1, RunningState), nullptr, GetSaveSlotString(1));
if (_CurrentSaveState == 1) { Item.SetItemTicked(true); }
if (_CurrentSaveState == 1)
{
Item.SetItemTicked(true);
}
CurrentSaveMenu.push_back(Item);
Item.Reset(ID_CURRENT_SAVE_2, EMPTY_STRING, m_ShortCuts.ShortCutString(ID_CURRENT_SAVE_2, RunningState), nullptr, GetSaveSlotString(2));
if (_CurrentSaveState == 2) { Item.SetItemTicked(true); }
if (_CurrentSaveState == 2)
{
Item.SetItemTicked(true);
}
CurrentSaveMenu.push_back(Item);
Item.Reset(ID_CURRENT_SAVE_3, EMPTY_STRING, m_ShortCuts.ShortCutString(ID_CURRENT_SAVE_3, RunningState), nullptr, GetSaveSlotString(3));
if (_CurrentSaveState == 3) { Item.SetItemTicked(true); }
if (_CurrentSaveState == 3)
{
Item.SetItemTicked(true);
}
CurrentSaveMenu.push_back(Item);
Item.Reset(ID_CURRENT_SAVE_4, EMPTY_STRING, m_ShortCuts.ShortCutString(ID_CURRENT_SAVE_4, RunningState), nullptr, GetSaveSlotString(4));
if (_CurrentSaveState == 4) { Item.SetItemTicked(true); }
if (_CurrentSaveState == 4)
{
Item.SetItemTicked(true);
}
CurrentSaveMenu.push_back(Item);
Item.Reset(ID_CURRENT_SAVE_5, EMPTY_STRING, m_ShortCuts.ShortCutString(ID_CURRENT_SAVE_5, RunningState), nullptr, GetSaveSlotString(5));
if (_CurrentSaveState == 5) { Item.SetItemTicked(true); }
if (_CurrentSaveState == 5)
{
Item.SetItemTicked(true);
}
CurrentSaveMenu.push_back(Item);
Item.Reset(ID_CURRENT_SAVE_6, EMPTY_STRING, m_ShortCuts.ShortCutString(ID_CURRENT_SAVE_6, RunningState), nullptr, GetSaveSlotString(6));
if (_CurrentSaveState == 6) { Item.SetItemTicked(true); }
if (_CurrentSaveState == 6)
{
Item.SetItemTicked(true);
}
CurrentSaveMenu.push_back(Item);
Item.Reset(ID_CURRENT_SAVE_7, EMPTY_STRING, m_ShortCuts.ShortCutString(ID_CURRENT_SAVE_7, RunningState), nullptr, GetSaveSlotString(7));
if (_CurrentSaveState == 7) { Item.SetItemTicked(true); }
if (_CurrentSaveState == 7)
{
Item.SetItemTicked(true);
}
CurrentSaveMenu.push_back(Item);
Item.Reset(ID_CURRENT_SAVE_8, EMPTY_STRING, m_ShortCuts.ShortCutString(ID_CURRENT_SAVE_8, RunningState), nullptr, GetSaveSlotString(8));
if (_CurrentSaveState == 8) { Item.SetItemTicked(true); }
if (_CurrentSaveState == 8)
{
Item.SetItemTicked(true);
}
CurrentSaveMenu.push_back(Item);
Item.Reset(ID_CURRENT_SAVE_9, EMPTY_STRING, m_ShortCuts.ShortCutString(ID_CURRENT_SAVE_9, RunningState), nullptr, GetSaveSlotString(9));
if (_CurrentSaveState == 9) { Item.SetItemTicked(true); }
if (_CurrentSaveState == 9)
{
Item.SetItemTicked(true);
}
CurrentSaveMenu.push_back(Item);
Item.Reset(ID_CURRENT_SAVE_10, EMPTY_STRING, m_ShortCuts.ShortCutString(ID_CURRENT_SAVE_10, RunningState), nullptr, GetSaveSlotString(10));
if (_CurrentSaveState == 10) { Item.SetItemTicked(true); }
if (_CurrentSaveState == 10)
{
Item.SetItemTicked(true);
}
CurrentSaveMenu.push_back(Item);
// System menu
@ -940,12 +978,18 @@ void CMainMenu::FillOutMenu(HMENU hMenu)
if (!inBasicMode)
{
Item.Reset(ID_SYSTEM_LIMITFPS, MENU_LIMIT_FPS, m_ShortCuts.ShortCutString(ID_SYSTEM_LIMITFPS, RunningState));
if (g_Settings->LoadBool(GameRunning_LimitFPS)) { Item.SetItemTicked(true); }
if (g_Settings->LoadBool(GameRunning_LimitFPS))
{
Item.SetItemTicked(true);
}
SystemMenu.push_back(Item);
SystemMenu.push_back(MENU_ITEM(SPLITER));
}
Item.Reset(ID_SYSTEM_SWAPDISK, MENU_SWAPDISK, m_ShortCuts.ShortCutString(ID_SYSTEM_SWAPDISK, RunningState));
if (g_Disk == nullptr) { Item.SetItemEnabled(false); }
if (g_Disk == nullptr)
{
Item.SetItemEnabled(false);
}
SystemMenu.push_back(Item);
SystemMenu.push_back(MENU_ITEM(SPLITER));
SystemMenu.push_back(MENU_ITEM(ID_SYSTEM_SAVE, MENU_SAVE, m_ShortCuts.ShortCutString(ID_SYSTEM_SAVE, RunningState)));
@ -980,7 +1024,10 @@ void CMainMenu::FillOutMenu(HMENU hMenu)
if (!inBasicMode)
{
Item.Reset(ID_OPTIONS_ALWAYSONTOP, MENU_ON_TOP, m_ShortCuts.ShortCutString(ID_OPTIONS_ALWAYSONTOP, RunningState));
if (UISettingsLoadDword(UserInterface_AlwaysOnTop)) { Item.SetItemTicked(true); }
if (UISettingsLoadDword(UserInterface_AlwaysOnTop))
{
Item.SetItemTicked(true);
}
Item.SetItemEnabled(CPURunning);
OptionMenu.push_back(Item);
}
@ -1018,7 +1065,10 @@ void CMainMenu::FillOutMenu(HMENU hMenu)
if (!inBasicMode)
{
Item.Reset(ID_OPTIONS_CPU_USAGE, MENU_SHOW_CPU, m_ShortCuts.ShortCutString(ID_OPTIONS_CPU_USAGE, RunningState));
if (g_Settings->LoadDword(UserInterface_ShowCPUPer)) { Item.SetItemTicked(true); }
if (g_Settings->LoadDword(UserInterface_ShowCPUPer))
{
Item.SetItemTicked(true);
}
OptionMenu.push_back(Item);
}
OptionMenu.push_back(MENU_ITEM(ID_OPTIONS_SETTINGS, MENU_SETTINGS, m_ShortCuts.ShortCutString(ID_OPTIONS_SETTINGS, RunningState)));
@ -1028,13 +1078,22 @@ void CMainMenu::FillOutMenu(HMENU hMenu)
if (HaveDebugger())
{
Item.Reset(ID_PROFILE_PROFILE, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"Record Execution Times");
if (g_Settings->LoadBool(Debugger_RecordExecutionTimes)) { Item.SetItemTicked(true); }
if (g_Settings->LoadBool(Debugger_RecordExecutionTimes))
{
Item.SetItemTicked(true);
}
DebugProfileMenu.push_back(Item);
Item.Reset(ID_PROFILE_RESETCOUNTER, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"Reset Counters");
if (!CPURunning) { Item.SetItemEnabled(false); }
if (!CPURunning)
{
Item.SetItemEnabled(false);
}
DebugProfileMenu.push_back(Item);
Item.Reset(ID_PROFILE_GENERATELOG, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"Generate Log File");
if (!CPURunning) { Item.SetItemEnabled(false); }
if (!CPURunning)
{
Item.SetItemEnabled(false);
}
DebugProfileMenu.push_back(Item);
}
@ -1156,7 +1215,7 @@ void CMainMenu::FillOutMenu(HMENU hMenu)
DebugAppLoggingMenu.push_back(Item);
Item.Reset(ID_DEBUGGER_TRACE_PLUGINS, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"Plugins");
Item.SetItemTicked(g_Settings->LoadDword(Debugger_TracePlugins) == TraceVerbose);;
Item.SetItemTicked(g_Settings->LoadDword(Debugger_TracePlugins) == TraceVerbose);
DebugAppLoggingMenu.push_back(Item);
Item.Reset(ID_DEBUGGER_TRACE_GFXPLUGIN, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"GFX plugin");
@ -1172,7 +1231,7 @@ void CMainMenu::FillOutMenu(HMENU hMenu)
DebugAppLoggingMenu.push_back(Item);
Item.Reset(ID_DEBUGGER_TRACE_RSPPLUGIN, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"RSP plugin");
Item.SetItemTicked(g_Settings->LoadDword(Debugger_TraceRSPPlugin) == TraceVerbose);;
Item.SetItemTicked(g_Settings->LoadDword(Debugger_TraceRSPPlugin) == TraceVerbose);
DebugAppLoggingMenu.push_back(Item);
Item.Reset(ID_DEBUGGER_TRACE_RSP, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"RSP");
@ -1206,7 +1265,10 @@ void CMainMenu::FillOutMenu(HMENU hMenu)
DebugAppLoggingMenu.push_back(MENU_ITEM(SPLITER));
Item.Reset(ID_DEBUGGER_APPLOG_FLUSH, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"Auto flush file");
if (g_Settings->LoadBool(Debugger_AppLogFlush)) { Item.SetItemTicked(true); }
if (g_Settings->LoadBool(Debugger_AppLogFlush))
{
Item.SetItemTicked(true);
}
DebugAppLoggingMenu.push_back(Item);
// Debug - logging
@ -1214,7 +1276,10 @@ void CMainMenu::FillOutMenu(HMENU hMenu)
DebugLoggingMenu.push_back(Item);
Item.Reset(ID_DEBUGGER_GENERATELOG, EMPTY_STRING, EMPTY_STDSTR, nullptr, L"Generate log");
if (g_Settings->LoadBool(Logging_GenerateLog)) { Item.SetItemTicked(true); }
if (g_Settings->LoadBool(Logging_GenerateLog))
{
Item.SetItemTicked(true);
}
DebugLoggingMenu.push_back(Item);
// Debugger main menu
@ -1305,28 +1370,43 @@ void CMainMenu::FillOutMenu(HMENU hMenu)
// Main title bar Menu
MenuItemList MainTitleMenu;
Item.Reset(SUB_MENU, MENU_FILE, EMPTY_STDSTR, &FileMenu);
if (RomLoading) { Item.SetItemEnabled(false); }
if (RomLoading)
{
Item.SetItemEnabled(false);
}
MainTitleMenu.push_back(Item);
if (CPURunning)
{
Item.Reset(SUB_MENU, MENU_SYSTEM, EMPTY_STDSTR, &SystemMenu);
if (RomLoading) { Item.SetItemEnabled(false); }
if (RomLoading)
{
Item.SetItemEnabled(false);
}
MainTitleMenu.push_back(Item);
}
Item.Reset(SUB_MENU, MENU_OPTIONS, EMPTY_STDSTR, &OptionMenu);
if (RomLoading) { Item.SetItemEnabled(false); }
if (RomLoading)
{
Item.SetItemEnabled(false);
}
MainTitleMenu.push_back(Item);
if (!inBasicMode)
{
if (HaveDebugger())
{
Item.Reset(SUB_MENU, MENU_DEBUGGER, EMPTY_STDSTR, &DebugMenu);
if (RomLoading) { Item.SetItemEnabled(false); }
if (RomLoading)
{
Item.SetItemEnabled(false);
}
MainTitleMenu.push_back(Item);
}
}
Item.Reset(SUB_MENU, MENU_HELP, EMPTY_STDSTR, &HelpMenu);
if (RomLoading) { Item.SetItemEnabled(false); }
if (RomLoading)
{
Item.SetItemEnabled(false);
}
MainTitleMenu.push_back(Item);
if (UISettingsLoadBool(UserInterface_ShowingNagWindow))

View File

@ -1,62 +1,144 @@
#pragma once
#include <Project64-core/Settings/DebugSettings.h>
#include <Project64/Settings/UISettings.h>
#include <Project64/UserInterface/MenuItem.h>
#include <Project64/UserInterface/MenuShortCuts.h>
enum MainMenuID
{
// File menu
ID_FILE_OPEN_ROM = 4000, ID_FILE_OPEN_COMBO, ID_FILE_ROM_INFO, ID_FILE_STARTEMULATION, ID_FILE_ENDEMULATION,
ID_FILE_ROMDIRECTORY, ID_FILE_REFRESHROMLIST, ID_FILE_EXIT,
ID_FILE_OPEN_ROM = 4000,
ID_FILE_OPEN_COMBO,
ID_FILE_ROM_INFO,
ID_FILE_STARTEMULATION,
ID_FILE_ENDEMULATION,
ID_FILE_ROMDIRECTORY,
ID_FILE_REFRESHROMLIST,
ID_FILE_EXIT,
// Language
ID_LANG_START, ID_LANG_END = ID_LANG_START + 100,
ID_LANG_START,
ID_LANG_END = ID_LANG_START + 100,
// Recent files
ID_RECENT_ROM_START, ID_RECENT_ROM_END = ID_RECENT_ROM_START + 20,
ID_RECENT_ROM_START,
ID_RECENT_ROM_END = ID_RECENT_ROM_START + 20,
// Recent directory
ID_RECENT_DIR_START, ID_RECENT_DIR_END = ID_RECENT_DIR_START + 20,
ID_RECENT_DIR_START,
ID_RECENT_DIR_END = ID_RECENT_DIR_START + 20,
// System menu
ID_SYSTEM_RESET_SOFT, ID_SYSTEM_RESET_HARD, ID_SYSTEM_PAUSE, ID_SYSTEM_BITMAP,
ID_SYSTEM_LIMITFPS, ID_SYSTEM_SWAPDISK, ID_SYSTEM_RESTORE, ID_SYSTEM_LOAD, ID_SYSTEM_SAVE,
ID_SYSTEM_SAVEAS, ID_SYSTEM_ENHANCEMENT, ID_SYSTEM_CHEAT, ID_SYSTEM_GSBUTTON,
ID_SYSTEM_RESET_SOFT,
ID_SYSTEM_RESET_HARD,
ID_SYSTEM_PAUSE,
ID_SYSTEM_BITMAP,
ID_SYSTEM_LIMITFPS,
ID_SYSTEM_SWAPDISK,
ID_SYSTEM_RESTORE,
ID_SYSTEM_LOAD,
ID_SYSTEM_SAVE,
ID_SYSTEM_SAVEAS,
ID_SYSTEM_ENHANCEMENT,
ID_SYSTEM_CHEAT,
ID_SYSTEM_GSBUTTON,
//Current save slot
ID_CURRENT_SAVE_1, ID_CURRENT_SAVE_2, ID_CURRENT_SAVE_3, ID_CURRENT_SAVE_4, ID_CURRENT_SAVE_5,
ID_CURRENT_SAVE_6, ID_CURRENT_SAVE_7, ID_CURRENT_SAVE_8, ID_CURRENT_SAVE_9, ID_CURRENT_SAVE_10,
ID_CURRENT_SAVE_1,
ID_CURRENT_SAVE_2,
ID_CURRENT_SAVE_3,
ID_CURRENT_SAVE_4,
ID_CURRENT_SAVE_5,
ID_CURRENT_SAVE_6,
ID_CURRENT_SAVE_7,
ID_CURRENT_SAVE_8,
ID_CURRENT_SAVE_9,
ID_CURRENT_SAVE_10,
ID_CURRENT_SAVE_DEFAULT,
// Option menu
ID_OPTIONS_FULLSCREEN, ID_OPTIONS_FULLSCREEN2, ID_OPTIONS_ALWAYSONTOP, ID_OPTIONS_CONFIG_GFX,
ID_OPTIONS_CONFIG_AUDIO, ID_OPTIONS_CONFIG_CONT, ID_OPTIONS_CONFIG_RSP, ID_OPTIONS_CPU_USAGE,
ID_OPTIONS_SETTINGS, ID_OPTIONS_DISPLAY_FR, ID_OPTIONS_CHANGE_FR, ID_OPTIONS_INCREASE_SPEED,
ID_OPTIONS_FULLSCREEN,
ID_OPTIONS_FULLSCREEN2,
ID_OPTIONS_ALWAYSONTOP,
ID_OPTIONS_CONFIG_GFX,
ID_OPTIONS_CONFIG_AUDIO,
ID_OPTIONS_CONFIG_CONT,
ID_OPTIONS_CONFIG_RSP,
ID_OPTIONS_CPU_USAGE,
ID_OPTIONS_SETTINGS,
ID_OPTIONS_DISPLAY_FR,
ID_OPTIONS_CHANGE_FR,
ID_OPTIONS_INCREASE_SPEED,
ID_OPTIONS_DECREASE_SPEED,
// Debugger menu
ID_DEBUG_END_ON_PERM_LOOP, ID_DEBUG_STEP_ON_BREAK_OPCODE,
ID_DEBUG_BREAK_ON_UNHANDLED_MEM, ID_DEBUG_BREAK_ON_ADDRESS_ERROR, ID_DEBUG_SHOW_PIF_ERRORS,
ID_DEBUG_SHOW_DLIST_COUNT, ID_DEBUG_SHOW_RECOMP_MEM_SIZE,
ID_DEBUG_RECORD_RECOMPILER_ASM, ID_DEBUG_DISABLE_GAMEFIX, ID_DEBUG_LANGUAGE,
ID_DEBUGGER_LOGOPTIONS, ID_DEBUGGER_GENERATELOG, ID_DEBUGGER_DUMPMEMORY, ID_DEBUGGER_SEARCHMEMORY,
ID_DEBUGGER_TLBENTRIES, ID_DEBUGGER_BREAKPOINTS, ID_DEBUGGER_MEMORY, ID_DEBUGGER_R4300REGISTERS,
ID_DEBUGGER_INTERRUPT_SP, ID_DEBUGGER_INTERRUPT_SI, ID_DEBUGGER_INTERRUPT_AI, ID_DEBUGGER_INTERRUPT_VI,
ID_DEBUGGER_INTERRUPT_PI, ID_DEBUGGER_INTERRUPT_DP, ID_DEBUGGER_SCRIPTS, ID_DEBUGGER_SYMBOLS, ID_DEBUGGER_DMALOG,
ID_DEBUGGER_EXCBREAKPOINTS, ID_DEBUGGER_CPULOG, ID_DEBUGGER_STACKTRACE, ID_DEBUGGER_STACKVIEW,
ID_DEBUG_END_ON_PERM_LOOP,
ID_DEBUG_STEP_ON_BREAK_OPCODE,
ID_DEBUG_BREAK_ON_UNHANDLED_MEM,
ID_DEBUG_BREAK_ON_ADDRESS_ERROR,
ID_DEBUG_SHOW_PIF_ERRORS,
ID_DEBUG_SHOW_DLIST_COUNT,
ID_DEBUG_SHOW_RECOMP_MEM_SIZE,
ID_DEBUG_RECORD_RECOMPILER_ASM,
ID_DEBUG_DISABLE_GAMEFIX,
ID_DEBUG_LANGUAGE,
ID_DEBUGGER_LOGOPTIONS,
ID_DEBUGGER_GENERATELOG,
ID_DEBUGGER_DUMPMEMORY,
ID_DEBUGGER_SEARCHMEMORY,
ID_DEBUGGER_TLBENTRIES,
ID_DEBUGGER_BREAKPOINTS,
ID_DEBUGGER_MEMORY,
ID_DEBUGGER_R4300REGISTERS,
ID_DEBUGGER_INTERRUPT_SP,
ID_DEBUGGER_INTERRUPT_SI,
ID_DEBUGGER_INTERRUPT_AI,
ID_DEBUGGER_INTERRUPT_VI,
ID_DEBUGGER_INTERRUPT_PI,
ID_DEBUGGER_INTERRUPT_DP,
ID_DEBUGGER_SCRIPTS,
ID_DEBUGGER_SYMBOLS,
ID_DEBUGGER_DMALOG,
ID_DEBUGGER_EXCBREAKPOINTS,
ID_DEBUGGER_CPULOG,
ID_DEBUGGER_STACKTRACE,
ID_DEBUGGER_STACKVIEW,
// App logging
ID_DEBUGGER_APPLOG_FLUSH, ID_DEBUGGER_TRACE_MD5, ID_DEBUGGER_TRACE_SETTINGS, ID_DEBUGGER_TRACE_UNKNOWN, ID_DEBUGGER_TRACE_APPINIT,
ID_DEBUGGER_TRACE_APPCLEANUP, ID_DEBUGGER_TRACE_N64SYSTEM, ID_DEBUGGER_TRACE_PLUGINS, ID_DEBUGGER_TRACE_GFXPLUGIN,
ID_DEBUGGER_TRACE_AUDIOPLUGIN, ID_DEBUGGER_TRACE_CONTROLLERPLUGIN, ID_DEBUGGER_TRACE_RSPPLUGIN, ID_DEBUGGER_TRACE_RSP,
ID_DEBUGGER_TRACE_AUDIO, ID_DEBUGGER_TRACE_REGISTERCACHE, ID_DEBUGGER_TRACE_RECOMPILER, ID_DEBUGGER_TRACE_TLB,
ID_DEBUGGER_TRACE_PROTECTEDMEM, ID_DEBUGGER_TRACE_USERINTERFACE,
ID_DEBUGGER_APPLOG_FLUSH,
ID_DEBUGGER_TRACE_MD5,
ID_DEBUGGER_TRACE_SETTINGS,
ID_DEBUGGER_TRACE_UNKNOWN,
ID_DEBUGGER_TRACE_APPINIT,
ID_DEBUGGER_TRACE_APPCLEANUP,
ID_DEBUGGER_TRACE_N64SYSTEM,
ID_DEBUGGER_TRACE_PLUGINS,
ID_DEBUGGER_TRACE_GFXPLUGIN,
ID_DEBUGGER_TRACE_AUDIOPLUGIN,
ID_DEBUGGER_TRACE_CONTROLLERPLUGIN,
ID_DEBUGGER_TRACE_RSPPLUGIN,
ID_DEBUGGER_TRACE_RSP,
ID_DEBUGGER_TRACE_AUDIO,
ID_DEBUGGER_TRACE_REGISTERCACHE,
ID_DEBUGGER_TRACE_RECOMPILER,
ID_DEBUGGER_TRACE_TLB,
ID_DEBUGGER_TRACE_PROTECTEDMEM,
ID_DEBUGGER_TRACE_USERINTERFACE,
// Profile menu
ID_PROFILE_PROFILE, ID_PROFILE_RESETCOUNTER, ID_PROFILE_GENERATELOG,
ID_PROFILE_PROFILE,
ID_PROFILE_RESETCOUNTER,
ID_PROFILE_GENERATELOG,
// Help menu
ID_HELP_SUPPORT_PROJECT64, ID_HELP_DISCORD, ID_HELP_WEBSITE, ID_HELP_ABOUT,
ID_HELP_SUPPORT_PROJECT64,
ID_HELP_DISCORD,
ID_HELP_WEBSITE,
ID_HELP_ABOUT,
};
class CMainGui;
class CMainMenu :
public CBaseMenu,
private CDebugSettings
@ -68,12 +150,15 @@ public:
int ProcessAccelerator(HWND hWnd, void * lpMsg);
bool ProcessMessage(HWND hWnd, DWORD wNotifyCode, DWORD wID);
void ResetMenu(void);
void ResetAccelerators(void) { m_ResetAccelerators = true; }
void ResetAccelerators(void)
{
m_ResetAccelerators = true;
}
private:
CMainMenu();
CMainMenu(const CMainMenu&);
CMainMenu& operator=(const CMainMenu&);
CMainMenu(const CMainMenu &);
CMainMenu & operator=(const CMainMenu &);
void OnOpenRom(HWND hWnd);
void OnOpenCombo(HWND hWnd);
@ -98,7 +183,10 @@ private:
void ShortCutsChanged(void);
static void SettingsChanged(CMainMenu * _this);
static void stShortCutsChanged(CMainMenu * _this) { return _this->ShortCutsChanged(); }
static void stShortCutsChanged(CMainMenu * _this)
{
return _this->ShortCutsChanged();
}
typedef std::list<SettingID> SettingList;
typedef std::list<UISettingID> UISettingList;

View File

@ -113,7 +113,10 @@ bool CMainGui::RegisterWinClass(void)
void CMainGui::AddRecentRom(const char * ImagePath)
{
if (HIWORD(ImagePath) == NULL) { return; }
if (HIWORD(ImagePath) == NULL)
{
return;
}
// Get information about the stored ROM list
size_t MaxRememberedFiles = UISettingsLoadDword(File_RecentGameFileCount);
@ -413,12 +416,14 @@ WPARAM CMainGui::ProcessAllMessages(void)
SetEvent(m_ResetInfo->hEvent);
m_ResetInfo = nullptr;
}
if ((m_CheatsUI.m_hWnd != nullptr && IsDialogMessage(m_CheatsUI.m_hWnd, &msg)) ||
(m_EnhancementUI.m_hWnd != nullptr && IsDialogMessage(m_EnhancementUI.m_hWnd, &msg)))
if ((m_CheatsUI.m_hWnd != nullptr && IsDialogMessage(m_CheatsUI.m_hWnd, &msg)) || (m_EnhancementUI.m_hWnd != nullptr && IsDialogMessage(m_EnhancementUI.m_hWnd, &msg)))
{
continue;
}
if (m_Menu->ProcessAccelerator(m_hMainWindow, &msg))
{
continue;
}
if (m_Menu->ProcessAccelerator(m_hMainWindow, &msg)) { continue; }
TranslateMessage(&msg);
DispatchMessage(&msg);
}
@ -440,7 +445,10 @@ bool CMainGui::ProcessGuiMessages(void)
return true;
}
PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE);
if (m_Menu->ProcessAccelerator(m_hMainWindow, &msg)) { continue; }
if (m_Menu->ProcessAccelerator(m_hMainWindow, &msg))
{
continue;
}
TranslateMessage(&msg);
DispatchMessage(&msg);
}
@ -485,7 +493,10 @@ void CMainGui::EnterLogOptions(void)
int CMainGui::Height(void)
{
if (!m_hMainWindow) { return 0; }
if (!m_hMainWindow)
{
return 0;
}
RECT rect;
GetWindowRect(m_hMainWindow, &rect);
@ -494,7 +505,10 @@ int CMainGui::Height(void)
int CMainGui::Width(void)
{
if (!m_hMainWindow) { return 0; }
if (!m_hMainWindow)
{
return 0;
}
RECT rect;
GetWindowRect(m_hMainWindow, &rect);
@ -532,7 +546,10 @@ void CMainGui::SetWindowMenu(CBaseMenu * Menu)
void CMainGui::RefreshMenu(void)
{
if (!m_Menu) { return; }
if (!m_Menu)
{
return;
}
m_Menu->ResetMenu();
}
@ -622,10 +639,7 @@ LRESULT CALLBACK CMainGui::MainGui_Proc(HWND hWnd, DWORD uMsg, DWORD wParam, DWO
case SC_MONITORPOWER:
{
CMainGui * _this = (CMainGui *)GetProp(hWnd, L"Class");
if (_this &&
_this->bCPURunning() &&
!g_Settings->LoadBool(GameRunning_CPU_Paused) &&
UISettingsLoadBool(Setting_DisableScrSaver))
if (_this && _this->bCPURunning() && !g_Settings->LoadBool(GameRunning_CPU_Paused) && UISettingsLoadBool(Setting_DisableScrSaver))
{
return 0;
}
@ -650,12 +664,7 @@ LRESULT CALLBACK CMainGui::MainGui_Proc(HWND hWnd, DWORD uMsg, DWORD wParam, DWO
{
CMainGui * _this = (CMainGui *)GetProp(hWnd, L"Class");
if (!_this->m_bMainWindow ||
!_this->m_Created ||
_this->m_AttachingMenu ||
_this->m_MakingVisible ||
IsIconic(hWnd) ||
_this->ShowingRomBrowser())
if (!_this->m_bMainWindow || !_this->m_Created || _this->m_AttachingMenu || _this->m_MakingVisible || IsIconic(hWnd) || _this->ShowingRomBrowser())
{
break;
}
@ -711,7 +720,10 @@ LRESULT CALLBACK CMainGui::MainGui_Proc(HWND hWnd, DWORD uMsg, DWORD wParam, DWO
case WM_SIZE:
{
CMainGui * _this = (CMainGui *)GetProp(hWnd, L"Class");
if (_this) { _this->Resize(wParam, LOWORD(lParam), HIWORD(lParam)); }
if (_this)
{
_this->Resize(wParam, LOWORD(lParam), HIWORD(lParam));
}
if (_this)
{
if (wParam == SIZE_MAXIMIZED)
@ -875,11 +887,17 @@ LRESULT CALLBACK CMainGui::MainGui_Proc(HWND hWnd, DWORD uMsg, DWORD wParam, DWO
case WM_HIDE_CUROSR:
if (!wParam)
{
while (ShowCursor(FALSE) >= 0) { Sleep(0); }
while (ShowCursor(FALSE) >= 0)
{
Sleep(0);
}
}
else
{
while (ShowCursor(TRUE) < 0) { Sleep(0); }
while (ShowCursor(TRUE) < 0)
{
Sleep(0);
}
}
break;
case WM_MAKE_FOCUS:
@ -927,8 +945,7 @@ LRESULT CALLBACK CMainGui::MainGui_Proc(HWND hWnd, DWORD uMsg, DWORD wParam, DWO
{
char * romPath = (char *)lParam;
stdstr ext = CPath(romPath).GetExtension();
if ((_stricmp(ext.c_str(), "ndd") != 0) &&
(_stricmp(ext.c_str(), "d64") != 0))
if ((_stricmp(ext.c_str(), "ndd") != 0) && (_stricmp(ext.c_str(), "d64") != 0))
{
g_BaseSystem->RunFileImage(romPath);
}
@ -1006,7 +1023,10 @@ LRESULT CALLBACK CMainGui::MainGui_Proc(HWND hWnd, DWORD uMsg, DWORD wParam, DWO
case WM_COMMAND:
{
CMainGui * _this = (CMainGui *)GetProp(hWnd, L"Class");
if (_this == nullptr) { break; }
if (_this == nullptr)
{
break;
}
switch (LOWORD(wParam))
{

Some files were not shown because too many files have changed in this diff Show More