CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
hrydgard

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: hrydgard/ppsspp
Path: blob/master/Windows/GEDebugger/TabDisplayLists.cpp
Views: 1401
1
#include "Windows/GEDebugger/TabDisplayLists.h"
2
#include "Windows/GEDebugger/GEDebugger.h"
3
#include "Windows/GEDebugger/CtrlDisplayListView.h"
4
#include "Windows/MainWindow.h"
5
#include "Windows/main.h"
6
#include "GPU/GPUInterface.h"
7
#include "GPU/Common/GPUDebugInterface.h"
8
#include "GPU/GPUState.h"
9
#include "Core/Config.h"
10
#include <windowsx.h>
11
#include <commctrl.h>
12
13
enum { WM_GEDBG_LISTS_CHANGELIST = WM_USER+400, WM_GEDBG_LISTS_GOTOSTACKPC };
14
15
//
16
// CtrlDisplayListStack
17
//
18
19
enum { DLS_PC = 0, DLS_BASE, DLS_OFFSET, DLS_COLUMNCOUNT };
20
21
const GenericListViewColumn displayListStackColumns[3] = {
22
{ L"PC", 0.34f },
23
{ L"Base", 0.33f },
24
{ L"Offset", 0.33f },
25
};
26
27
GenericListViewDef displayListStackListDef = {
28
displayListStackColumns, ARRAY_SIZE(displayListStackColumns), NULL, false
29
};
30
31
CtrlDisplayListStack::CtrlDisplayListStack(HWND hwnd): GenericListControl(hwnd,displayListStackListDef)
32
{
33
list.stackptr = 0;
34
Update();
35
}
36
37
void CtrlDisplayListStack::GetColumnText(wchar_t* dest, int row, int col)
38
{
39
if (row < 0 || row >= (int)ARRAY_SIZE(list.stack)) {
40
return;
41
}
42
DisplayListStackEntry value = list.stack[row];
43
44
switch (col)
45
{
46
case DLS_BASE:
47
wsprintf(dest,L"0x%08X",value.baseAddr);
48
break;
49
case DLS_OFFSET:
50
wsprintf(dest,L"0x%08X",value.offsetAddr);
51
break;
52
case DLS_PC:
53
wsprintf(dest,L"0x%08X",value.pc);
54
break;
55
}
56
}
57
58
void CtrlDisplayListStack::OnDoubleClick(int itemIndex, int column)
59
{
60
SendMessage(GetParent(GetHandle()),WM_GEDBG_LISTS_GOTOSTACKPC,itemIndex,0);
61
}
62
63
64
//
65
// CtrlDisplayListStack
66
//
67
68
enum { ADL_STARTPC = 0, ADL_PC, ADL_STALL, ADL_STATE, APL_STARTED, APL_INTERRUPTED, ADL_COLUMNCOUNT };
69
70
const GenericListViewColumn allDisplayListsColumns[ADL_COLUMNCOUNT] = {
71
{ L"Start PC", 0.18f },
72
{ L"PC", 0.18f },
73
{ L"Stall", 0.18f },
74
{ L"State", 0.16f },
75
{ L"Started", 0.15f },
76
{ L"Interrupted", 0.15f },
77
};
78
79
GenericListViewDef allDisplayListsListDef = {
80
allDisplayListsColumns, ARRAY_SIZE(allDisplayListsColumns), NULL, false
81
};
82
83
CtrlAllDisplayLists::CtrlAllDisplayLists(HWND hwnd): GenericListControl(hwnd,allDisplayListsListDef)
84
{
85
Update();
86
}
87
88
void CtrlAllDisplayLists::GetColumnText(wchar_t* dest, int row, int col)
89
{
90
if (row < 0 || row >= (int)lists.size()) {
91
return;
92
}
93
DisplayList& list = lists[row];
94
95
switch (col)
96
{
97
case ADL_STALL:
98
wsprintf(dest,L"0x%08X",list.stall);
99
break;
100
case ADL_PC:
101
wsprintf(dest,L"0x%08X",list.pc);
102
break;
103
case ADL_STARTPC:
104
wsprintf(dest,L"0x%08X",list.startpc);
105
break;
106
case ADL_STATE:
107
switch (list.state)
108
{
109
case PSP_GE_DL_STATE_NONE:
110
wcscpy(dest,L"None");
111
break;
112
case PSP_GE_DL_STATE_QUEUED:
113
wcscpy(dest,L"Queued");
114
break;
115
case PSP_GE_DL_STATE_RUNNING:
116
wcscpy(dest,L"Running");
117
break;
118
case PSP_GE_DL_STATE_COMPLETED:
119
wcscpy(dest,L"Completed");
120
break;
121
case PSP_GE_DL_STATE_PAUSED:
122
wcscpy(dest,L"Paused");
123
break;
124
}
125
break;
126
case APL_STARTED:
127
wcscpy(dest,list.started ? L"Yes" : L"No");
128
break;
129
case APL_INTERRUPTED:
130
wcscpy(dest,list.interrupted ? L"Yes" : L"No");
131
break;
132
}
133
}
134
135
bool CtrlAllDisplayLists::WindowMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT& returnValue)
136
{
137
switch (msg)
138
{
139
case WM_KEYDOWN:
140
if (wParam == VK_RETURN)
141
{
142
int item = GetSelectedIndex();
143
SendMessage(GetParent(GetHandle()),WM_GEDBG_LISTS_CHANGELIST,item,0);
144
}
145
break;
146
case WM_GETDLGCODE:
147
if (lParam && ((MSG*)lParam)->message == WM_KEYDOWN)
148
{
149
if (wParam == VK_RETURN)
150
{
151
returnValue = DLGC_WANTMESSAGE;
152
return true;
153
}
154
}
155
}
156
157
return false;
158
}
159
160
void CtrlAllDisplayLists::OnDoubleClick(int itemIndex, int column)
161
{
162
SendMessage(GetParent(GetHandle()),WM_GEDBG_LISTS_CHANGELIST,itemIndex,0);
163
}
164
165
166
//
167
// TabDisplayLists
168
//
169
170
TabDisplayLists::TabDisplayLists(HINSTANCE _hInstance, HWND _hParent)
171
: Dialog((LPCSTR)IDD_TABDISPLAYLISTS, _hInstance, _hParent)
172
{
173
displayList = CtrlDisplayListView::getFrom(GetDlgItem(m_hDlg,IDC_GEDBG_LISTS_SELECTEDLIST));
174
175
stack = new CtrlDisplayListStack(GetDlgItem(m_hDlg,IDC_GEDBG_LISTS_STACK));
176
allLists = new CtrlAllDisplayLists(GetDlgItem(m_hDlg,IDC_GEDBG_LISTS_ALLLISTS));
177
178
activeList = -1;
179
}
180
181
TabDisplayLists::~TabDisplayLists()
182
{
183
delete stack;
184
delete allLists;
185
}
186
187
void TabDisplayLists::UpdateSize(WORD width, WORD height)
188
{
189
struct Position
190
{
191
int x,y;
192
int w,h;
193
};
194
195
Position positions[3];
196
int borderMargin = 5;
197
int betweenControlsMargin = 5;
198
199
// All Lists
200
positions[0].x = borderMargin;
201
positions[0].y = borderMargin;
202
positions[0].w = width*2/3;
203
positions[0].h = std::min(height * 2 / 5, 200);
204
205
// Stack
206
positions[1].x = positions[0].x+positions[0].w+betweenControlsMargin;
207
positions[1].y = borderMargin;
208
positions[1].w = width-positions[1].x-borderMargin;
209
positions[1].h = positions[0].h;
210
211
// Current List
212
positions[2].x = borderMargin;
213
positions[2].y = positions[0].y+positions[0].h+betweenControlsMargin;
214
positions[2].w = width-2*borderMargin;
215
positions[2].h = height-positions[2].y-borderMargin;
216
217
HWND handles[3] = {
218
GetDlgItem(m_hDlg,IDC_GEDBG_LISTS_ALLLISTS),
219
GetDlgItem(m_hDlg,IDC_GEDBG_LISTS_STACK),
220
GetDlgItem(m_hDlg,IDC_GEDBG_LISTS_SELECTEDLIST)
221
};
222
223
for (int i = 0; i < 3; i++)
224
{
225
MoveWindow(handles[i],positions[i].x,positions[i].y,positions[i].w,positions[i].h,TRUE);
226
}
227
}
228
229
void TabDisplayLists::Update(bool reload)
230
{
231
if (reload && gpuDebug != NULL)
232
{
233
lists = gpuDebug->ActiveDisplayLists();
234
}
235
236
if (activeList != -1)
237
{
238
DisplayList currentList = lists[activeList];
239
240
displayList->setDisplayList(currentList);
241
stack->setDisplayList(currentList);
242
}
243
244
allLists->setDisplayLists(lists);
245
}
246
247
BOOL TabDisplayLists::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) {
248
switch (message) {
249
case WM_INITDIALOG:
250
return TRUE;
251
252
case WM_SIZE:
253
UpdateSize(LOWORD(lParam), HIWORD(lParam));
254
return TRUE;
255
256
case WM_NOTIFY:
257
switch (wParam)
258
{
259
case IDC_GEDBG_LISTS_STACK:
260
SetWindowLongPtr(m_hDlg, DWLP_MSGRESULT, stack->HandleNotify(lParam));
261
return TRUE;
262
case IDC_GEDBG_LISTS_ALLLISTS:
263
SetWindowLongPtr(m_hDlg, DWLP_MSGRESULT, allLists->HandleNotify(lParam));
264
return TRUE;
265
}
266
break;
267
268
case WM_GEDBG_LISTS_CHANGELIST:
269
activeList = wParam;
270
Update();
271
break;
272
273
case WM_GEDBG_LISTS_GOTOSTACKPC:
274
{
275
u32 pc = lists[activeList].stack[wParam].pc;
276
displayList->gotoAddr(pc);
277
}
278
break;
279
280
case WM_GEDBG_TOGGLEPCBREAKPOINT:
281
SendMessage(GetParent(m_hDlg),message,wParam,lParam);
282
break;
283
284
}
285
286
return FALSE;
287
}
288
289