Debian Codegraph @

Descent3/debuggraph.cpp

raw symbols SCIP
1 /*
2 * Descent 3
3 * Copyright (C) 2024 Parallax Software
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 --- HISTORICAL COMMENTS FOLLOW ---
19
20 * $Logfile: /DescentIII/main/debuggraph.cpp $
21 * $Revision: 4 $
22 * $Date: 9/23/99 12:02p $
23 * $Author: Jeff $
24 *
25 * Debug graph visual log
26 *
27 * $Log: /DescentIII/main/debuggraph.cpp $
28 *
29 * 4 9/23/99 12:02p Jeff
30 * include stdlib for atexit
31 *
32 * 3 5/10/99 10:21p Ardussi
33 * changes to compile on Mac
34 *
35 * 2 4/04/99 8:14p Jeff
36 * added debug graph stuff
37 *
38 * $NoKeywords: $
39 */
40
41 #include <stdlib.h>
42 #include "debuggraph.h"cxx . . $ `<file>/Descent3/debuggraph.h`/
43 #include "grdefs.h"cxx . . $ `<file>/lib/grdefs.h`/
44 #include "mono.h"cxx . . $ `<file>/ddebug/mono.h`/
45 #include <memory.h>
46 #include "pserror.h"cxx . . $ `<file>/misc/pserror.h`/
47 #include "bitmap.h"cxx . . $ `<file>/lib/bitmap.h`/
48 #include "renderer.h"cxx . . $ `<file>/lib/renderer.h`/
49 #include "pstypes.h"cxx . . $ `<file>/lib/pstypes.h`/
50 #include "stringtable.h"cxx . . $ `<file>/Descent3/stringtable.h`/
51 #include "newui.h"cxx . . $ `<file>/Descent3/newui.h`/
52 #include "newui_core.h"cxx . . $ `<file>/Descent3/newui_core.h`/
53 #include "mem.h"cxx . . $ `<file>/mem/mem.h`/
54 #include <string.h>
55 #include "game.h"cxx . . $ `<file>/Descent3/game.h`/
56
57 #define DATA_TYPE_INTcxx . . $ `Descent3/debuggraph.cpp:57:9`! 0
58 #define DATA_TYPE_FLOATcxx . . $ `Descent3/debuggraph.cpp:58:9`! 1
59 #define NUM_FRAMES_TO_DISPLAYcxx . . $ `Descent3/debuggraph.cpp:59:9`! 128
60 #define MAX_GRAPH_NODEScxx . . $ `Descent3/debuggraph.cpp:60:9`! 16
61 #define MAX_NAMEcxx . . $ `Descent3/debuggraph.cpp:61:9`! 38
62
63 int graph_bmpcxx . . $ graph_bmp. = -1;
64 int graph_maskcxx . . $ graph_mask. = 0;
65 int graph_num_nodescxx . . $ graph_num_nodes. = 0;
66
67 struct tGraphColorcxx . . $ tGraphColor# {
68 const char *color_namecxx . . $ tGraphColor#color_name.;
69 ddgr_colorcxx . . $ ddgr_color# colorcxx . . $ tGraphColor#color.;
70 };
71
72 tGraphColorcxx . . $ tGraphColor# GraphColorscxx . . $ GraphColors.[MAX_GRAPH_NODEScxx . . $ `Descent3/debuggraph.cpp:60:9`!] = {
73 {"Green", GR_RGBcxx . . $ GR_RGB(530956271a9518a5).(40, 255, 40)}, {"Red", GR_RGBcxx . . $ GR_RGB(530956271a9518a5).(255, 40, 40)}, {"Blue", GR_RGBcxx . . $ GR_RGB(530956271a9518a5).(40, 40, 255)},
74 {"Yellow", GR_RGBcxx . . $ GR_RGB(530956271a9518a5).(255, 255, 40)}, {"Purple", GR_RGBcxx . . $ GR_RGB(530956271a9518a5).(255, 40, 255)}, {"White", GR_RGBcxx . . $ GR_RGB(530956271a9518a5).(255, 255, 255)},
75 {"Lt.Grey", GR_RGBcxx . . $ GR_RGB(530956271a9518a5).(180, 180, 180)}, {"Dk.Grey", GR_RGBcxx . . $ GR_RGB(530956271a9518a5).(80, 80, 80)}, {"Orange", GR_RGBcxx . . $ GR_RGB(530956271a9518a5).(255, 140, 5)},
76 {"Pink", GR_RGBcxx . . $ GR_RGB(530956271a9518a5).(250, 147, 147)}, {"Brown", GR_RGBcxx . . $ GR_RGB(530956271a9518a5).(119, 68, 2)}, {"Dk.Blue", GR_RGBcxx . . $ GR_RGB(530956271a9518a5).(3, 20, 124)},
77 {"Dk.Red", GR_RGBcxx . . $ GR_RGB(530956271a9518a5).(100, 2, 2)}, {"Dk.Green", GR_RGBcxx . . $ GR_RGB(530956271a9518a5).(2, 100, 9)}, {"Turquoise", GR_RGBcxx . . $ GR_RGB(530956271a9518a5).(14, 229, 202)},
78 {"Dk.Purple", GR_RGBcxx . . $ GR_RGB(530956271a9518a5).(100, 4, 104)}};
79
80 struct tAddDebugGraphcxx . . $ tAddDebugGraph# {
81 uint8_tcxx . . $ uint8_t# data_inputcxx . . $ tAddDebugGraph#data_input.;
82 int flagscxx . . $ tAddDebugGraph#flags.;
83
84 unioncxx . . $ tAddDebugGraph#$anonymous_type_0# {
85 int i_min_valuecxx . . $ tAddDebugGraph#$anonymous_type_0#i_min_value.;
86 float f_min_valuecxx . . $ tAddDebugGraph#$anonymous_type_0#f_min_value.;
87 };
88 unioncxx . . $ tAddDebugGraph#$anonymous_type_1# {
89 int i_max_valuecxx . . $ tAddDebugGraph#$anonymous_type_1#i_max_value.;
90 float f_max_valuecxx . . $ tAddDebugGraph#$anonymous_type_1#f_max_value.;
91 };
92
93 };
94
95 class tGraphNodecxx . . $ tGraphNode# {
96 public:
97 tGraphNodecxx . . $ tGraphNode#tGraphNode(49f6e7a06ebc5aa8).() {}
98 ~cxx . . $ tGraphNode#`~tGraphNode`(ced63f7c635d850d).tGraphNodecxx . . $ tGraphNode#() {}
99
100 ddgr_colorcxx . . $ ddgr_color# colorcxx . . $ tGraphNode#color.;
101
102 void Initializecxx . . $ tGraphNode#Initialize(82871d694ba7d2d7).(tAddDebugGraphcxx . . $ tAddDebugGraph# *data);
103 void Updatecxx . . $ tGraphNode#Update(d4f767463ce0a6b3).(int value);
104 void Updatecxx . . $ tGraphNode#Update(9364e6e7bff7660).(float value);
105 void Rendercxx . . $ tGraphNode#Render(49f6e7a06ebc5aa8).(void);
106
107 char namecxx . . $ tGraphNode#name.[MAX_NAMEcxx . . $ `Descent3/debuggraph.cpp:61:9`!];
108 tAddDebugGraphcxx . . $ tAddDebugGraph# init_datacxx . . $ tGraphNode#init_data.;
109
110 private:
111 int cur_write_poscxx . . $ tGraphNode#cur_write_pos.;
112 int first_poscxx . . $ tGraphNode#first_pos.;
113 int num_items_storedcxx . . $ tGraphNode#num_items_stored.;
114
115 unioncxx . . $ tGraphNode#$anonymous_type_2# {
116 int i_datacxx . . $ tGraphNode#$anonymous_type_2#i_data.[NUM_FRAMES_TO_DISPLAYcxx . . $ `Descent3/debuggraph.cpp:59:9`!];
117 float f_datacxx . . $ tGraphNode#$anonymous_type_2#f_data.[NUM_FRAMES_TO_DISPLAYcxx . . $ `Descent3/debuggraph.cpp:59:9`!];
118 };
119 };
120
121 struct tDebugGraphNodecxx . . $ tDebugGraphNode# {
122 tGraphNodecxx . . $ tGraphNode# *nodecxx . . $ tDebugGraphNode#node.;
123 tDebugGraphNodecxx . . $ tDebugGraphNode# *nextcxx . . $ tDebugGraphNode#next.;
124 };
125
126 tDebugGraphNodecxx . . $ tDebugGraphNode# *DebugGraphNode_rootcxx . . $ DebugGraphNode_root. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
127
128 tGraphNodecxx . . $ tGraphNode# *DebugGraph_AddNodecxx . . $ DebugGraph_AddNode(318ea0407f386a57).(void) {
129 if (graph_num_nodescxx . . $ graph_num_nodes. == MAX_GRAPH_NODEScxx . . $ `Descent3/debuggraph.cpp:60:9`!)
130 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
131
132 tDebugGraphNodecxx . . $ tDebugGraphNode# *curr = DebugGraphNode_rootcxx . . $ DebugGraphNode_root.;
133
134 if (!curr) {
135 curr = DebugGraphNode_rootcxx . . $ DebugGraphNode_root. = (tDebugGraphNodecxx . . $ tDebugGraphNode# *)mem_malloccxx . . $ `mem/mem.h:79:9`!(sizeof(tDebugGraphNode));
136 } else {
137 while (curr->nextcxx . . $ tDebugGraphNode#next.) {
138 curr = curr->nextcxx . . $ tDebugGraphNode#next.;
139 }
140 curr->nextcxx . . $ tDebugGraphNode#next. = (tDebugGraphNodecxx . . $ tDebugGraphNode# *)mem_malloccxx . . $ `mem/mem.h:79:9`!(sizeof(tDebugGraphNode));
141 curr = curr->nextcxx . . $ tDebugGraphNode#next.;
142 }
143
144 if (!curr) {
145 Errorcxx . . $ Error(326aeb464d16410c).("Out of Memory");
146 }
147
148 graph_num_nodescxx . . $ graph_num_nodes.++;
149 curr->nextcxx . . $ tDebugGraphNode#next. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
150 curr->nodecxx . . $ tDebugGraphNode#node. = new tGraphNodecxx . . $ tGraphNode#;
151
152 if (!curr->nodecxx . . $ tDebugGraphNode#node.) {
153 Errorcxx . . $ Error(326aeb464d16410c).("Out of Memory");
154 }
155
156 return curr->nodecxx . . $ tDebugGraphNode#node.;
157 }
158
159 tGraphNodecxx . . $ tGraphNode# *DebugGraph_FindNodecxx . . $ DebugGraph_FindNode(697322566d5470f7).(int index) {
160 if (index >= graph_num_nodescxx . . $ graph_num_nodes.)
161 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
162 tDebugGraphNodecxx . . $ tDebugGraphNode# *curr = DebugGraphNode_rootcxx . . $ DebugGraphNode_root.;
163 int ci = 0;
164 while (curr) {
165 if (ci == index) {
166 return curr->nodecxx . . $ tDebugGraphNode#node.;
167 }
168 curr = curr->nextcxx . . $ tDebugGraphNode#next.;
169 ci++;
170 }
171
172 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
173 }
174
175 void DebugGraph_Freecxx . . $ DebugGraph_Free(49f6e7a06ebc5aa8).(void) {
176 tDebugGraphNodecxx . . $ tDebugGraphNode# *curr, *next;
177 curr = DebugGraphNode_rootcxx . . $ DebugGraphNode_root.;
178
179 while (curr) {
180 delete curr->nodecxx . . $ tDebugGraphNode#node.;
181 next = curr->nextcxx . . $ tDebugGraphNode#next.;
182 mem_freecxx . . $ `mem/mem.h:80:9`!(curr);
183 curr = next;
184 }
185
186 DebugGraphNode_rootcxx . . $ DebugGraphNode_root. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
187
188 if (graph_bmpcxx . . $ graph_bmp. > BAD_BITMAP_HANDLEcxx . . $ `lib/bitmap.h:42:9`!) {
189 bm_FreeBitmapcxx . . $ bm_FreeBitmap(d4f767463ce0a6b3).(graph_bmpcxx . . $ graph_bmp.);
190 }
191 graph_bmpcxx . . $ graph_bmp. = -1;
192 graph_num_nodescxx . . $ graph_num_nodes. = 0;
193 }
194
195 void DebugGraph_Initializecxx . . $ DebugGraph_Initialize(49f6e7a06ebc5aa8).(void) {
196 atexitcxx . . $ atexit(cc8c495369588262).(DebugGraph_Freecxx . . $ DebugGraph_Free(49f6e7a06ebc5aa8).);
197 DebugGraphNode_rootcxx . . $ DebugGraphNode_root. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
198 graph_bmpcxx . . $ graph_bmp. = -1;
199 graph_maskcxx . . $ graph_mask. = 0;
200 graph_num_nodescxx . . $ graph_num_nodes. = 0;
201 }
202
203 int DebugGraph_Addcxx . . $ DebugGraph_Add(b9ead6aff293bd59).(int min, int max, const char *name, int flags) {
204 tAddDebugGraphcxx . . $ tAddDebugGraph# data;
205 tGraphNodecxx . . $ tGraphNode# *node = DebugGraph_AddNodecxx . . $ DebugGraph_AddNode(318ea0407f386a57).();
206 if (!node)
207 return -1;
208
209 int index = graph_num_nodescxx . . $ graph_num_nodes. - 1;
210 data.data_inputcxx . . $ tAddDebugGraph#data_input. = DATA_TYPE_INTcxx . . $ `Descent3/debuggraph.cpp:57:9`!;
211 data.i_max_valuecxx . . $ tAddDebugGraph#$anonymous_type_1#i_max_value. = max;
212 data.i_min_valuecxx . . $ tAddDebugGraph#$anonymous_type_0#i_min_value. = min;
213 data.flagscxx . . $ tAddDebugGraph#flags. = flags;
214 node->Initializecxx . . $ tGraphNode#Initialize(82871d694ba7d2d7).(&data);
215 node->colorcxx . . $ tGraphNode#color. = GraphColorscxx . . $ GraphColors.[index].colorcxx . . $ tGraphColor#color.;
216 strncpy(node->namecxx . . $ tGraphNode#name., name, MAX_NAMEcxx . . $ `Descent3/debuggraph.cpp:61:9`! - 1);
217 node->namecxx . . $ tGraphNode#name.[MAX_NAMEcxx . . $ `Descent3/debuggraph.cpp:61:9`! - 1] = '\0';
218 return index;
219 }
220
221 int DebugGraph_Addcxx . . $ DebugGraph_Add(9bc3e79dc6ad0d07).(float min, float max, const char *name, int flags) {
222 tAddDebugGraphcxx . . $ tAddDebugGraph# data;
223 tGraphNodecxx . . $ tGraphNode# *node = DebugGraph_AddNodecxx . . $ DebugGraph_AddNode(318ea0407f386a57).();
224 if (!node)
225 return -1;
226
227 int index = graph_num_nodescxx . . $ graph_num_nodes. - 1;
228 data.data_inputcxx . . $ tAddDebugGraph#data_input. = DATA_TYPE_FLOATcxx . . $ `Descent3/debuggraph.cpp:58:9`!;
229 data.f_max_valuecxx . . $ tAddDebugGraph#$anonymous_type_1#f_max_value. = max;
230 data.f_min_valuecxx . . $ tAddDebugGraph#$anonymous_type_0#f_min_value. = min;
231 data.flagscxx . . $ tAddDebugGraph#flags. = flags;
232 node->Initializecxx . . $ tGraphNode#Initialize(82871d694ba7d2d7).(&data);
233 node->colorcxx . . $ tGraphNode#color. = GraphColorscxx . . $ GraphColors.[index].colorcxx . . $ tGraphColor#color.;
234 strncpy(node->namecxx . . $ tGraphNode#name., name, MAX_NAMEcxx . . $ `Descent3/debuggraph.cpp:61:9`! - 1);
235 node->namecxx . . $ tGraphNode#name.[MAX_NAMEcxx . . $ `Descent3/debuggraph.cpp:61:9`! - 1] = '\0';
236 return index;
237 }
238
239 void DebugGraph_Enablecxx . . $ DebugGraph_Enable(d4f767463ce0a6b3).(int id) {
240 int bit = 0x01 << id;
241 graph_maskcxx . . $ graph_mask. |= bit;
242 }
243
244 void DebugGraph_Disablecxx . . $ DebugGraph_Disable(d4f767463ce0a6b3).(int id) {
245 int bit = 0x01 << id;
246 graph_maskcxx . . $ graph_mask. &= ~bit;
247 }
248
249 void DebugGraph_Updatecxx . . $ DebugGraph_Update(3e454b8ccf442868).(int id, int value) {
250 if (id < 0 || id >= graph_num_nodescxx . . $ graph_num_nodes.)
251 return;
252
253 tGraphNodecxx . . $ tGraphNode# *node = DebugGraph_FindNodecxx . . $ DebugGraph_FindNode(697322566d5470f7).(id);
254 if (!node)
255 return;
256
257 node->Updatecxx . . $ tGraphNode#Update(d4f767463ce0a6b3).(value);
258 }
259
260 void DebugGraph_Updatecxx . . $ DebugGraph_Update(43c79ee2f1b9aefe).(int id, float value) {
261 if (id < 0 || id >= graph_num_nodescxx . . $ graph_num_nodes.)
262 return;
263
264 tGraphNodecxx . . $ tGraphNode# *node = DebugGraph_FindNodecxx . . $ DebugGraph_FindNode(697322566d5470f7).(id);
265 if (!node)
266 return;
267
268 node->Updatecxx . . $ tGraphNode#Update(9364e6e7bff7660).(value);
269 }
270
271 #define TOP_Lcxx . . $ `Descent3/debuggraph.cpp:271:9`! 10
272 #define TOP_Tcxx . . $ `Descent3/debuggraph.cpp:272:9`! 50
273
274 void DebugGraph_Rendercxx . . $ DebugGraph_Render(49f6e7a06ebc5aa8).(void) {
275 if (graph_bmpcxx . . $ graph_bmp. == -1) {
276 // create the bitmap
277 graph_bmpcxx . . $ graph_bmp. = bm_AllocBitmapcxx . . $ bm_AllocBitmap(2326284602b0bb2d).(64, 64, 0);
278 if (graph_bmpcxx . . $ graph_bmp. > BAD_BITMAP_HANDLEcxx . . $ `lib/bitmap.h:42:9`!) {
279 uint16_tcxx . . $ uint16_t# *data = bm_datacxx . . $ bm_data(501e1bc9f482c6bd).(graph_bmpcxx . . $ graph_bmp., 0);
280 for (int i = 0; i < 64 * 64; i++) {
281 data[i] = GR_RGB16cxx . . $ GR_RGB16(6461fafb79bad5b9).(0, 0, 0) | OPAQUE_FLAGcxx . . $ `lib/grdefs.h:72:9`!;
282 }
283 }
284 }
285 if (graph_bmpcxx . . $ graph_bmp. <= BAD_BITMAP_HANDLEcxx . . $ `lib/bitmap.h:42:9`!)
286 return;
287
288 if (graph_maskcxx . . $ graph_mask. == 0)
289 return;
290
291 rend_SetAlphaTypecxx . . $ rend_SetAlphaType(4af4fd0e2b26c4ac).(AT_CONSTANT_TEXTUREcxx . . $ `lib/renderer.h:402:9`!);
292 rend_SetAlphaValuecxx . . $ rend_SetAlphaValue(ac50b47256ae7414).(240);
293 rend_SetLightingcxx . . $ rend_SetLighting(e55526c9d3dd1656).(LS_NONEcxx . . $ LS_NONE.);
294 rend_SetColorModelcxx . . $ rend_SetColorModel(e3c5062d5af601c7).(CM_MONOcxx . . $ CM_MONO.);
295 rend_SetOverlayTypecxx . . $ rend_SetOverlayType(ac50b47256ae7414).(OT_NONEcxx . . $ `lib/renderer.h:333:9`!);
296 rend_SetWrapTypecxx . . $ rend_SetWrapType(da524b148887c0e7).(WT_CLAMPcxx . . $ WT_CLAMP.);
297 rend_SetFilteringcxx . . $ rend_SetFiltering(4af4fd0e2b26c4ac).(0);
298
299 rend_DrawScaledBitmapcxx . . $ rend_DrawScaledBitmap(bffd21ce5f93b71b).(TOP_Lcxx . . $ `Descent3/debuggraph.cpp:271:9`!, TOP_Tcxx . . $ `Descent3/debuggraph.cpp:272:9`!, TOP_Lcxx . . $ `Descent3/debuggraph.cpp:271:9`! + 256, TOP_Tcxx . . $ `Descent3/debuggraph.cpp:272:9`! + 64, graph_bmpcxx . . $ graph_bmp., 0, 0, 1, 1);
300
301 int bit = 0x01;
302 tGraphNodecxx . . $ tGraphNode# *node;
303 bool multi_game = (bool)((Game_modecxx . . $ Game_mode. & GM_MULTIcxx . . $ `Descent3/game.h:288:9`!) != 0);
304 bool ok_to_render;
305
306 for (int i = 0; i < graph_num_nodescxx . . $ graph_num_nodes.; i++) {
307 node = DebugGraph_FindNodecxx . . $ DebugGraph_FindNode(697322566d5470f7).(i);
308 ok_to_render = true;
309
310 if (node && (graph_maskcxx . . $ graph_mask. & bit)) {
311 if (multi_game) {
312 if (!(node->init_datacxx . . $ tGraphNode#init_data..flagscxx . . $ tAddDebugGraph#flags. & DGF_MULTIPLAYERcxx . . $ `Descent3/debuggraph.h:39:9`!))
313 ok_to_render = false;
314 } else {
315 if (!(node->init_datacxx . . $ tGraphNode#init_data..flagscxx . . $ tAddDebugGraph#flags. & DGF_SINGLEPLAYERcxx . . $ `Descent3/debuggraph.h:40:9`!))
316 ok_to_render = false;
317 }
318
319 if (ok_to_render)
320 node->Rendercxx . . $ tGraphNode#Render(49f6e7a06ebc5aa8).();
321 }
322 bit = bit << 1;
323 }
324
325 rend_SetFilteringcxx . . $ rend_SetFiltering(4af4fd0e2b26c4ac).(1);
326 }
327
328 ////////////////////////////////////////////
329 void tGraphNodecxx . . $ tGraphNode#::Initializecxx . . $ tGraphNode#Initialize(82871d694ba7d2d7).(tAddDebugGraphcxx . . $ tAddDebugGraph# *data) {
330 if (!data)
331 return;
332
333 memcpy(&init_datacxx . . $ tGraphNode#init_data., data, sizeof(tAddDebugGraphcxx . . $ tAddDebugGraph#));
334 cur_write_poscxx . . $ tGraphNode#cur_write_pos. = 0;
335 first_poscxx . . $ tGraphNode#first_pos. = 0;
336 num_items_storedcxx . . $ tGraphNode#num_items_stored. = 0;
337
338 colorcxx . . $ tGraphNode#color. = GR_RGBcxx . . $ GR_RGB(530956271a9518a5).(255, 40, 40);
339 memset(i_datacxx . . $ tGraphNode#$anonymous_type_2#i_data., 0, sizeof(int) * NUM_FRAMES_TO_DISPLAYcxx . . $ `Descent3/debuggraph.cpp:59:9`!);
340 }
341
342 void tGraphNodecxx . . $ tGraphNode#::Updatecxx . . $ tGraphNode#Update(d4f767463ce0a6b3).(int value) {
343 ASSERTcxx . . $ `misc/pserror.h:246:9`!(init_data.data_input == DATA_TYPE_INTcxx . . $ `Descent3/debuggraph.cpp:57:9`!);
344
345 bool multi_game = (bool)((Game_modecxx . . $ Game_mode. & GM_MULTIcxx . . $ `Descent3/game.h:288:9`!) != 0);
346 if (multi_game) {
347 if (!(init_datacxx . . $ tGraphNode#init_data..flagscxx . . $ tAddDebugGraph#flags. & DGF_MULTIPLAYERcxx . . $ `Descent3/debuggraph.h:39:9`!))
348 return;
349 } else {
350 if (!(init_datacxx . . $ tGraphNode#init_data..flagscxx . . $ tAddDebugGraph#flags. & DGF_SINGLEPLAYERcxx . . $ `Descent3/debuggraph.h:40:9`!))
351 return;
352 }
353
354 if (cur_write_poscxx . . $ tGraphNode#cur_write_pos. != 0 && (cur_write_poscxx . . $ tGraphNode#cur_write_pos. % NUM_FRAMES_TO_DISPLAYcxx . . $ `Descent3/debuggraph.cpp:59:9`!) == 0) {
355 cur_write_poscxx . . $ tGraphNode#cur_write_pos. = 0;
356 }
357
358 if (num_items_storedcxx . . $ tGraphNode#num_items_stored. == NUM_FRAMES_TO_DISPLAYcxx . . $ `Descent3/debuggraph.cpp:59:9`!) {
359 first_poscxx . . $ tGraphNode#first_pos.++;
360 if (first_poscxx . . $ tGraphNode#first_pos. != 0 && (first_poscxx . . $ tGraphNode#first_pos. % NUM_FRAMES_TO_DISPLAYcxx . . $ `Descent3/debuggraph.cpp:59:9`!) == 0) {
361 first_poscxx . . $ tGraphNode#first_pos. = 0;
362 }
363 } else {
364 num_items_storedcxx . . $ tGraphNode#num_items_stored.++;
365 }
366
367 if (value < init_datacxx . . $ tGraphNode#init_data..i_min_valuecxx . . $ tAddDebugGraph#$anonymous_type_0#i_min_value.)
368 value = init_datacxx . . $ tGraphNode#init_data..i_min_valuecxx . . $ tAddDebugGraph#$anonymous_type_0#i_min_value.;
369 if (value > init_datacxx . . $ tGraphNode#init_data..i_max_valuecxx . . $ tAddDebugGraph#$anonymous_type_1#i_max_value.)
370 value = init_datacxx . . $ tGraphNode#init_data..i_max_valuecxx . . $ tAddDebugGraph#$anonymous_type_1#i_max_value.;
371
372 i_datacxx . . $ tGraphNode#$anonymous_type_2#i_data.[cur_write_poscxx . . $ tGraphNode#cur_write_pos.] = value;
373 cur_write_poscxx . . $ tGraphNode#cur_write_pos.++;
374 }
375
376 void tGraphNodecxx . . $ tGraphNode#::Updatecxx . . $ tGraphNode#Update(9364e6e7bff7660).(float value) {
377 ASSERTcxx . . $ `misc/pserror.h:246:9`!(init_data.data_input == DATA_TYPE_FLOATcxx . . $ `Descent3/debuggraph.cpp:58:9`!);
378
379 bool multi_game = (bool)((Game_modecxx . . $ Game_mode. & GM_MULTIcxx . . $ `Descent3/game.h:288:9`!) != 0);
380 if (multi_game) {
381 if (!(init_datacxx . . $ tGraphNode#init_data..flagscxx . . $ tAddDebugGraph#flags. & DGF_MULTIPLAYERcxx . . $ `Descent3/debuggraph.h:39:9`!))
382 return;
383 } else {
384 if (!(init_datacxx . . $ tGraphNode#init_data..flagscxx . . $ tAddDebugGraph#flags. & DGF_SINGLEPLAYERcxx . . $ `Descent3/debuggraph.h:40:9`!))
385 return;
386 }
387
388 if (cur_write_poscxx . . $ tGraphNode#cur_write_pos. != 0 && (cur_write_poscxx . . $ tGraphNode#cur_write_pos. % NUM_FRAMES_TO_DISPLAYcxx . . $ `Descent3/debuggraph.cpp:59:9`!) == 0) {
389 cur_write_poscxx . . $ tGraphNode#cur_write_pos. = 0;
390 }
391
392 if (num_items_storedcxx . . $ tGraphNode#num_items_stored. == NUM_FRAMES_TO_DISPLAYcxx . . $ `Descent3/debuggraph.cpp:59:9`!) {
393 first_poscxx . . $ tGraphNode#first_pos.++;
394 if (first_poscxx . . $ tGraphNode#first_pos. != 0 && (first_poscxx . . $ tGraphNode#first_pos. % NUM_FRAMES_TO_DISPLAYcxx . . $ `Descent3/debuggraph.cpp:59:9`!) == 0) {
395 first_poscxx . . $ tGraphNode#first_pos. = 0;
396 }
397 } else {
398 num_items_storedcxx . . $ tGraphNode#num_items_stored.++;
399 }
400
401 if (value < init_datacxx . . $ tGraphNode#init_data..f_min_valuecxx . . $ tAddDebugGraph#$anonymous_type_0#f_min_value.)
402 value = init_datacxx . . $ tGraphNode#init_data..f_min_valuecxx . . $ tAddDebugGraph#$anonymous_type_0#f_min_value.;
403 if (value > init_datacxx . . $ tGraphNode#init_data..f_max_valuecxx . . $ tAddDebugGraph#$anonymous_type_1#f_max_value.)
404 value = init_datacxx . . $ tGraphNode#init_data..f_max_valuecxx . . $ tAddDebugGraph#$anonymous_type_1#f_max_value.;
405
406 f_datacxx . . $ tGraphNode#$anonymous_type_2#f_data.[cur_write_poscxx . . $ tGraphNode#cur_write_pos.] = value;
407
408 cur_write_poscxx . . $ tGraphNode#cur_write_pos.++;
409 }
410
411 void GetGraphYcxx . . $ GetGraphY(85f43d39f7fbe01b).(int *y, int value, int max, int min) {
412 float range;
413 range = float(value - min) / float(max - min);
414
415 *y = TOP_Tcxx . . $ `Descent3/debuggraph.cpp:272:9`! + 64 - int(range * 64.0);
416 }
417
418 void GetGraphYcxx . . $ GetGraphY(e9571b20ecbe08c9).(int *y, float value, float max, float min) {
419 float range;
420 range = (value - min) / (max - min);
421
422 *y = TOP_Tcxx . . $ `Descent3/debuggraph.cpp:272:9`! + 64 - int(range * 64.0);
423 }
424
425 void tGraphNodecxx . . $ tGraphNode#::Rendercxx . . $ tGraphNode#Render(49f6e7a06ebc5aa8).(void) {
426 if (num_items_storedcxx . . $ tGraphNode#num_items_stored. < 2)
427 return;
428 rend_SetFlatColorcxx . . $ rend_SetFlatColor(cb2f890c2fdad230).(colorcxx . . $ tGraphNode#color.);
429
430 int last_x, last_y = 0, y;
431 int index = first_poscxx . . $ tGraphNode#first_pos.;
432 int count = num_items_storedcxx . . $ tGraphNode#num_items_stored.;
433 count--;
434
435 switch (init_datacxx . . $ tGraphNode#init_data..data_inputcxx . . $ tAddDebugGraph#data_input.) {
436 case DATA_TYPE_FLOATcxx . . $ `Descent3/debuggraph.cpp:58:9`!:
437 GetGraphYcxx . . $ GetGraphY(e9571b20ecbe08c9).(&last_y, f_datacxx . . $ tGraphNode#$anonymous_type_2#f_data.[index], init_datacxx . . $ tGraphNode#init_data..f_max_valuecxx . . $ tAddDebugGraph#$anonymous_type_1#f_max_value., init_datacxx . . $ tGraphNode#init_data..f_min_valuecxx . . $ tAddDebugGraph#$anonymous_type_0#f_min_value.);
438 break;
439 case DATA_TYPE_INTcxx . . $ `Descent3/debuggraph.cpp:57:9`!:
440 GetGraphYcxx . . $ GetGraphY(85f43d39f7fbe01b).(&last_y, i_datacxx . . $ tGraphNode#$anonymous_type_2#i_data.[index], init_datacxx . . $ tGraphNode#init_data..i_max_valuecxx . . $ tAddDebugGraph#$anonymous_type_1#i_max_value., init_datacxx . . $ tGraphNode#init_data..i_min_valuecxx . . $ tAddDebugGraph#$anonymous_type_0#i_min_value.);
441 break;
442 };
443 index++;
444 last_x = TOP_Lcxx . . $ `Descent3/debuggraph.cpp:271:9`!;
445
446 while (count > 0) {
447 if (index != 0 && (index % NUM_FRAMES_TO_DISPLAYcxx . . $ `Descent3/debuggraph.cpp:59:9`!) == 0) {
448 index = 0;
449 }
450
451 switch (init_datacxx . . $ tGraphNode#init_data..data_inputcxx . . $ tAddDebugGraph#data_input.) {
452 case DATA_TYPE_FLOATcxx . . $ `Descent3/debuggraph.cpp:58:9`!:
453 GetGraphYcxx . . $ GetGraphY(e9571b20ecbe08c9).(&y, f_datacxx . . $ tGraphNode#$anonymous_type_2#f_data.[index], init_datacxx . . $ tGraphNode#init_data..f_max_valuecxx . . $ tAddDebugGraph#$anonymous_type_1#f_max_value., init_datacxx . . $ tGraphNode#init_data..f_min_valuecxx . . $ tAddDebugGraph#$anonymous_type_0#f_min_value.);
454 break;
455 case DATA_TYPE_INTcxx . . $ `Descent3/debuggraph.cpp:57:9`!:
456 GetGraphYcxx . . $ GetGraphY(85f43d39f7fbe01b).(&y, i_datacxx . . $ tGraphNode#$anonymous_type_2#i_data.[index], init_datacxx . . $ tGraphNode#init_data..i_max_valuecxx . . $ tAddDebugGraph#$anonymous_type_1#i_max_value., init_datacxx . . $ tGraphNode#init_data..i_min_valuecxx . . $ tAddDebugGraph#$anonymous_type_0#i_min_value.);
457 break;
458 };
459
460 rend_DrawLinecxx . . $ rend_DrawLine(748afa4755bc9595).(last_x, last_y, last_x + 1, y);
461 count--;
462 last_x += 2;
463 last_y = y;
464 index++;
465 }
466 }
467
468 /*
469 ***********************************************************************
470 */
471
472 void DebugGraph_DisplayOptionscxx . . $ DebugGraph_DisplayOptions(49f6e7a06ebc5aa8).(void) {
473 if (graph_num_nodescxx . . $ graph_num_nodes. == 0)
474 return;
475
476 newuiTiledWindowcxx . . $ newuiTiledWindow# windowcxx . . $ newuiTiledWindow#newuiTiledWindow(49f6e7a06ebc5aa8).;
477 newuiSheetcxx . . $ newuiSheet# *sheet;
478
479 bool **bool_values = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
480 bool exit_menu = false;
481 tGraphNodecxx . . $ tGraphNode# *node;
482
483 bool_values = (bool **)mem_malloccxx . . $ `mem/mem.h:79:9`!(sizeof(bool *) * graph_num_nodes);
484 if (!bool_values)
485 return;
486
487 window.Createcxx . . $ newuiTiledWindow#Create(9860cac3d762132).("Debug Graph", 0, 0, 256, 384);
488 sheet = window.GetSheetcxx . . $ newuiTiledWindow#GetSheet(661381a276e5b628).();
489
490 sheet->NewGroupcxx . . $ newuiSheet#NewGroup(465b27e37ce794b1).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, 0, 0);
491 char buffer[256];
492 int bit = 0x01;
493
494 bool multi_game = (bool)((Game_modecxx . . $ Game_mode. & GM_MULTIcxx . . $ `Descent3/game.h:288:9`!) != 0);
495
496 for (int i = 0; i < graph_num_nodescxx . . $ graph_num_nodes.; i++) {
497 bool_values[i] = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
498 node = DebugGraph_FindNodecxx . . $ DebugGraph_FindNode(697322566d5470f7).(i);
499 if (!node) {
500 bit = bit << 1;
501 continue;
502 }
503
504 // see if we should add it
505 if (multi_game) {
506 if (!(node->init_datacxx . . $ tGraphNode#init_data..flagscxx . . $ tAddDebugGraph#flags. & DGF_MULTIPLAYERcxx . . $ `Descent3/debuggraph.h:39:9`!)) {
507 bit = bit << 1;
508 continue;
509 }
510 } else {
511 if (!(node->init_datacxx . . $ tGraphNode#init_data..flagscxx . . $ tAddDebugGraph#flags. & DGF_SINGLEPLAYERcxx . . $ `Descent3/debuggraph.h:40:9`!)) {
512 bit = bit << 1;
513 continue;
514 }
515 }
516
517 snprintf(buffer, sizeof(buffer), "%s (%s)", node->namecxx . . $ tGraphNode#name., GraphColorscxx . . $ GraphColors.[i].color_namecxx . . $ tGraphColor#color_name.);
518 bool_values[i] = sheet->AddLongCheckBoxcxx . . $ newuiSheet#AddLongCheckBox(b1b99af17a84c782).(buffer);
519 if (bool_values[i]) {
520 *bool_values[i] = (bool)((graph_maskcxx . . $ graph_mask. & bit) != 0);
521 }
522
523 bit = bit << 1;
524 }
525
526 sheet->NewGroupcxx . . $ newuiSheet#NewGroup(465b27e37ce794b1).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, 50, 200);
527 sheet->AddButtoncxx . . $ newuiSheet#AddButton(680bf41633375800).(TXT_OKcxx . . $ `Descent3/stringtable.h:34:9`!, UID_OKcxx . . $ `ui/ui.h:368:9`!);
528
529 // process
530 window.Opencxx . . $ UIWindow#Open(49f6e7a06ebc5aa8).();
531
532 while (!exit_menu) {
533 int res = window.DoUIcxx . . $ newuiTiledWindow#DoUI(b126dc7c1de90089).();
534
535 // handle all UI results.
536 switch (res) {
537 case UID_OKcxx . . $ `ui/ui.h:368:9`!: {
538 for (int x = 0; x < graph_num_nodescxx . . $ graph_num_nodes.; x++) {
539 if (bool_values[x]) {
540 (*bool_values[x]) ? DebugGraph_Enablecxx . . $ DebugGraph_Enable(d4f767463ce0a6b3).(x) : DebugGraph_Disablecxx . . $ DebugGraph_Disable(d4f767463ce0a6b3).(x);
541 }
542 }
543
544 exit_menu = true;
545 }
546 };
547 }
548
549 window.Closecxx . . $ UIWindow#Close(49f6e7a06ebc5aa8).();
550 window.Destroycxx . . $ UIWindow#Destroy(49f6e7a06ebc5aa8).();
551
552 mem_freecxx . . $ `mem/mem.h:80:9`!(bool_values);
553 }