1 // NOTE: Apologies for the quality of this code, this is really from pre-opensource Dolphin - that is, 2003. 2 3 #pragma once 4 5 ////////////////////////////////////////////////////////////////////////// 6 //CtrlRegisterList 7 // CtrlRegisterList.cpp 8 ////////////////////////////////////////////////////////////////////////// 9 //This Win32 control is made to be flexible and usable with 10 //every kind of CPU architechture that has fixed width instruction words. 11 //Just supply it an instance of a class derived from Debugger, with all methods 12 //overridden for full functionality. Look at the ppc one for an example. 13 // 14 //To add to a dialog box, just draw a User Control in the dialog editor, 15 //and set classname to "CtrlRegisterList". you also need to call CtrlRegisterList::init() 16 //before opening this dialog, to register the window class. 17 // 18 //To get a class instance to be able to access it, just use 19 // CtrlRegisterList::getFrom(GetDlgItem(yourdialog, IDC_yourid)). 20 21 #include "../../Core/Debugger/DebugInterface.h" 22 23 class CtrlRegisterList 24 { 25 HWND wnd; 26 HFONT font; 27 RECT rect; 28 29 int rowHeight; 30 int selection = 0; 31 int category = 0; 32 33 int oldSelection = 0; 34 35 bool selecting = false; 36 bool hasFocus = false; 37 DebugInterface *cpu = nullptr; 38 static TCHAR szClassName[]; 39 40 u32 lastPC = 0; 41 u32 *lastCat0Values = nullptr; 42 bool *changedCat0Regs = nullptr; 43 bool ctrlDown = false; 44 45 u32 getSelectedRegValue(char *out, size_t size); 46 void copyRegisterValue(); 47 void editRegisterValue(); 48 public: 49 CtrlRegisterList(HWND _wnd); 50 ~CtrlRegisterList(); 51 static void init(); 52 static void deinit(); 53 static LRESULT CALLBACK wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); 54 static CtrlRegisterList * getFrom(HWND wnd); 55 56 void onPaint(WPARAM wParam, LPARAM lParam); 57 void onKeyDown(WPARAM wParam, LPARAM lParam); 58 void onMouseDown(WPARAM wParam, LPARAM lParam, int button); 59 void onMouseUp(WPARAM wParam, LPARAM lParam, int button); 60 void onMouseMove(WPARAM wParam, LPARAM lParam, int button); 61 void redraw(); 62 63 int yToIndex(int y); 64 setCPU(DebugInterface * deb)65 void setCPU(DebugInterface *deb) 66 { 67 cpu = deb; 68 69 int regs = cpu->GetNumRegsInCategory(0); 70 lastCat0Values = new u32[regs+3]; 71 changedCat0Regs = new bool[regs+3]; 72 memset(lastCat0Values, 0, (regs+3) * sizeof(u32)); 73 memset(changedCat0Regs, 0, (regs+3) * sizeof(bool)); 74 } getCPU()75 DebugInterface *getCPU() 76 { 77 return cpu; 78 } 79 }; 80