]> icculus.org git repositories - btb/d2x.git/blob - main/editor/info.c
remove rcs tags
[btb/d2x.git] / main / editor / info.c
1 /*
2 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
3 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
4 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
5 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
6 IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
7 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
8 FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
9 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
10 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
11 COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
12 */
13
14 /*
15  *
16  * Print debugging info in ui.
17  *
18  */
19
20 #ifdef HAVE_CONFIG_H
21 #include "conf.h"
22 #endif
23
24 #include <stdio.h>
25 #include <stdlib.h>
26 #include <string.h>
27
28 #ifdef DO_MEMINFO
29 #include <i86.h>
30 #include <malloc.h>
31 #endif
32
33 #include "inferno.h"
34 #include "segment.h"
35 #include "gr.h"
36 #include "ui.h"
37 #include "editor.h"
38
39 #include "mono.h"
40 #include "error.h"
41 #include "textures.h"
42 #include "object.h"
43 #include "ai.h"
44
45 #include "texpage.h"            // Textue selection paging stuff
46 #include "objpage.h"            // Object selection paging stuff
47
48 #include "wall.h"
49 #include "switch.h"
50
51 int init_info;
52
53 #ifdef DO_MEMINFO
54 struct meminfo {
55     int LargestBlockAvail;
56     int MaxUnlockedPage;
57     int LargestLockablePage;
58     int LinAddrSpace;
59     int NumFreePagesAvail;
60     int NumPhysicalPagesFree;
61     int TotalPhysicalPages;
62     int FreeLinAddrSpace;
63     int SizeOfPageFile;
64     int Reserved[3];
65 } MemInfo;
66
67 #define DPMI_INT        0x31
68
69 void read_mem_info()
70 {
71     union REGS regs;
72     struct SREGS sregs;
73
74     regs.x.eax = 0x00000500;
75     memset( &sregs, 0, sizeof(sregs) );
76     sregs.es = FP_SEG( &MemInfo );
77     regs.x.edi = FP_OFF( &MemInfo );
78
79     int386x( DPMI_INT, &regs, &regs, &sregs );
80 }
81 #endif
82
83 char * get_object_type(int num, char *name)
84 {
85         switch (num) {
86                 case OBJ_NONE:                  strcpy(name, "OBJ_NONE    ");   break;
87                 case OBJ_WALL:          strcpy(name, "OBJ_WALL    ");   break;
88                 case OBJ_FIREBALL:      strcpy(name, "OBJ_FIREBALL");   break;
89                 case OBJ_ROBOT:                 strcpy(name, "OBJ_ROBOT   ");   break;
90                 case OBJ_HOSTAGE:       strcpy(name, "OBJ_HOSTAGE ");   break;
91                 case OBJ_PLAYER:                strcpy(name, "OBJ_PLAYER  ");   break;
92                 case OBJ_WEAPON:                strcpy(name, "OBJ_WEAPON  ");   break;
93                 case OBJ_CAMERA:                strcpy(name, "OBJ_CAMERA  ");   break;
94                 case OBJ_POWERUP:       strcpy(name, "OBJ_POWERUP ");   break;
95                 default:                                        strcpy(name, " (unknown)  ");   break;
96         }
97
98         return name;
99 }
100
101 char * get_control_type(int num, char *name)
102 {
103         switch (num) {
104                 case CT_NONE:                                   strcpy(name, "CT_NONE       "); break;
105                 case CT_AI:                                             strcpy(name, "CT_AI         "); break;
106                 case CT_EXPLOSION:                      strcpy(name, "CT_EXPLOSION  "); break;
107                 //case CT_MULTIPLAYER:                  strcpy(name, "CT_MULTIPLAYER"); break;
108                 case CT_FLYING:                         strcpy(name, "CT_FLYING     "); break;
109                 case CT_SLEW:                                   strcpy(name, "CT_SLEW       "); break;
110                 case CT_FLYTHROUGH:                     strcpy(name, "CT_FLYTHROUGH "); break;
111                 //case CT_DEMO:                                 strcpy(name, "CT_DEMO       "); break;
112                 //case CT_ROBOT_FLYTHROUGH:     strcpy(name, "CT_FLYTHROUGH "); break;
113                 case CT_WEAPON:                         strcpy(name, "CT_WEAPON     "); break;
114                 default:                                                        strcpy(name, " (unknown)    "); break;
115         }
116         return name;
117 }
118
119 char * get_movement_type(int num, char *name)
120 {
121         switch (num) {
122                 case MT_NONE:                   strcpy(name, "MT_NONE       "); break;
123                 case MT_PHYSICS:                strcpy(name, "MT_PHYSICS    "); break;
124                 //case MT_MULTIPLAYER:  strcpy(name, "MT_MULTIPLAYER"); break;
125                 default:                                        strcpy(name, " (unknown)    "); break;
126         }
127         return name;
128 }
129
130 char * get_ai_behavior(int num, char *name)
131 {
132 #define AIB_STILL                                               0x80
133 #define AIB_NORMAL                                              0x81
134 #define AIB_HIDE                                                        0x82
135 #define AIB_RUN_FROM                                    0x83
136 #define AIB_FOLLOW_PATH                         0x84
137
138         switch (num) {
139                 case AIB_STILL:                         strcpy(name, "STILL       ");   break;
140                 case AIB_NORMAL:                                strcpy(name, "NORMAL      ");   break;
141                 case AIB_HIDE:                                  strcpy(name, "HIDE        ");   break;
142                 case AIB_RUN_FROM:                      strcpy(name, "RUN_FROM    ");   break;
143                 case AIB_FOLLOW_PATH:           strcpy(name, "FOLLOW_PATH ");   break;
144                 default:                                                        strcpy(name, " (unknown)  ");   break;
145         }
146         return name;
147 }
148
149 //      ---------------------------------------------------------------------------------------------------
150 void info_display_object_placement(int show_all)
151 {
152         static  int     old_Cur_object_index;
153         static  int     old_type;
154         static  int     old_movement_type;
155         static  int     old_control_type;
156         static  int     old_mode;
157
158         char            name[30];
159
160         if (init_info | show_all) {
161                 old_Cur_object_index = -2;
162                 old_type = -2;
163                 old_movement_type = -2;
164                 old_control_type = -2;
165                 old_mode = -2;
166         }
167
168         if ( ( Cur_object_index != old_Cur_object_index) || 
169                         ( Objects[Cur_object_index].type != old_type) || 
170                         ( Objects[Cur_object_index].movement_type != old_movement_type) || 
171                         ( Objects[Cur_object_index].control_type != old_control_type) || 
172                         ( Objects[Cur_object_index].ctype.ai_info.behavior != old_mode) ) {
173
174                 gr_uprintf( 0, 0, "Object id: %4d\n", Cur_object_index);
175                 gr_uprintf( 0, 16, "Type: %s\n", get_object_type(Objects[Cur_object_index].type , name));
176                 gr_uprintf( 0, 32, "Movmnt: %s\n", get_movement_type(Objects[Cur_object_index].movement_type, name));
177                 gr_uprintf( 0, 48, "Cntrl: %s\n", get_control_type(Objects[Cur_object_index].control_type, name));
178                 gr_uprintf( 0, 64, "Mode: %s\n", get_ai_behavior(Objects[Cur_object_index].ctype.ai_info.behavior, name));
179
180                 old_Cur_object_index = Cur_object_index;
181                 old_type = Objects[Cur_object_index].type;
182                 old_movement_type = Objects[Cur_object_index].movement_type;
183                 old_mode = Objects[Cur_object_index].control_type;
184                 old_mode = Objects[Cur_object_index].ctype.ai_info.behavior;
185         }
186
187 }
188
189 //      ---------------------------------------------------------------------------------------------------
190 void info_display_segsize(int show_all)
191 {
192         static  int     old_SegSizeMode;
193
194         char            name[30];
195
196         if (init_info | show_all) {
197                 old_SegSizeMode = -2;
198         }
199
200         if (old_SegSizeMode != SegSizeMode  ) {
201                 switch (SegSizeMode) {
202                         case SEGSIZEMODE_FREE:          strcpy(name, "free   ");        break;
203                         case SEGSIZEMODE_ALL:           strcpy(name, "all    ");        break;
204                         case SEGSIZEMODE_CURSIDE:       strcpy(name, "curside");        break;
205                         case SEGSIZEMODE_EDGE:          strcpy(name, "edge   ");        break;
206                         case SEGSIZEMODE_VERTEX:        strcpy(name, "vertex ");        break;
207                         default:
208                                 Error("Illegal value for SegSizeMode in info.c/info_display_segsize\n");
209                 }
210
211                 gr_uprintf( 0, 0, "Mode: %s\n", name);
212
213                 old_SegSizeMode = SegSizeMode;
214         }
215
216 }
217
218 extern int num_objects;
219
220 //      ---------------------------------------------------------------------------------------------------
221 void info_display_default(int show_all)
222 {
223         static int old_Num_segments = -1;
224         static int old_Num_vertices = -1;
225         static int old_Num_objects = -1;
226         static int old_Cursegp_num = -1;
227         static int old_Curside = -1;
228         static int old_Cursegp_num_for_verts = -1;
229         static int old_CurrentTexture = -1;
230         static int old_Num_walls = -1;
231         static int old_Num_triggers = -1;
232
233         if (init_info | show_all) {
234                 init_info = 0;
235                 old_Num_segments = -1;
236                 old_Num_vertices = -1;
237                 old_Num_objects = -1;
238                 old_Cursegp_num = -1;
239                 old_Cursegp_num_for_verts = -1;
240                 old_Curside = -1;
241                 old_CurrentTexture = -1;
242                 old_Num_walls = -1;
243                 old_Num_triggers = -1;
244         }
245
246         gr_set_fontcolor(CBLACK,CWHITE);
247
248         //--------------- Number of segments ----------------
249
250         if ( old_Num_segments != Num_segments ) {
251                 gr_uprintf( 0, 0, "Segments: %4d/%4d", Num_segments, MAX_SEGMENTS );
252                 old_Num_segments = Num_segments;
253         }
254
255         //---------------- Number of vertics -----------------
256         
257         if ( old_Num_vertices != Num_vertices ) {
258                 gr_uprintf( 0, 16, "Vertices: %4d/%4d", Num_vertices, MAX_VERTICES );
259                 old_Num_vertices = Num_vertices;
260         }
261
262         //---------------- Number of objects -----------------
263         
264         if ( old_Num_objects != num_objects )   {
265                 gr_uprintf( 0, 32, "Objs: %3d/%3d", num_objects, MAX_OBJECTS );
266                 old_Num_objects = num_objects;
267         }
268
269         //--------------- Current_segment_number -------------
270         //--------------- Current_side_number -------------
271
272         if ( (old_Cursegp_num != SEGMENT_NUMBER(Cursegp)) || (old_Curside != Curside) ) {
273                 gr_uprintf( 0, 48, "Cursegp/side: %3d/%1d", SEGMENT_NUMBER(Cursegp), Curside );
274                 gr_uprintf( 0, 128, " tmap1,2,o: %3d/%3dx%1d", Cursegp->sides[Curside].tmap_num, Cursegp->sides[Curside].tmap_num2 & 0x3FFF, (Cursegp->sides[Curside].tmap_num2 >> 14) & 3);
275                 old_Cursegp_num = SEGMENT_NUMBER(Cursegp);
276                 old_Curside = Curside;
277         }
278
279         //--------------- Current_vertex_numbers -------------
280
281         if ( old_Cursegp_num_for_verts != SEGMENT_NUMBER(Cursegp) ) {
282
283                 gr_uprintf( 0, 64, "{%3d,%3d,%3d,%3d,", Cursegp->verts[0],Cursegp->verts[1],
284                                                                                                                                                                                          Cursegp->verts[2],Cursegp->verts[3] );
285                 gr_uprintf( 0, 80," %3d,%3d,%3d,%3d}", Cursegp->verts[4],Cursegp->verts[5],
286                                                                                                                                                                                          Cursegp->verts[6],Cursegp->verts[7] );
287                 old_Cursegp_num_for_verts = SEGMENT_NUMBER(Cursegp);
288         }
289
290         //--------------- Num walls/links/triggers -------------------------
291
292         if ( old_Num_walls != Num_walls ) {
293 //              gr_uprintf( 0, 96, "Walls/Links %d/%d", Num_walls, Num_links );
294                 gr_uprintf( 0, 96, "Walls %3d", Num_walls );
295                 old_Num_walls = Num_walls;
296         }
297
298         //--------------- Num triggers ----------------------
299
300         if ( old_Num_triggers != Num_triggers ) {
301                 gr_uprintf( 0, 112, "Num_triggers %2d", Num_triggers );
302                 old_Num_triggers = Num_triggers;
303         }
304
305         //--------------- Current texture number -------------
306
307         if ( old_CurrentTexture != CurrentTexture )     {
308                 gr_uprintf( 0, 144, "Tex/Light: %3d %5.2f", CurrentTexture, f2fl(TmapInfo[CurrentTexture].lighting));
309                 old_CurrentTexture = CurrentTexture;
310         }
311
312 }
313
314 //      ------------------------------------------------------------------------------------
315 void clear_pad_display(void)
316 {
317         gr_clear_canvas(CWHITE);
318    gr_set_fontcolor( CBLACK, CWHITE );
319 }
320
321 //      ------------------------------------------------------------------------------------
322 void info_display_all( UI_WINDOW * wnd )
323 {
324         static int old_padnum = -1;
325         int        padnum,show_all = 0;
326         grs_canvas *save_canvas = grd_curcanv;
327
328         wnd++;          //kill warning
329
330         grd_curcanv = Pad_text_canvas;
331
332         padnum = ui_pad_get_current();
333         Assert(padnum <= MAX_PAD_ID);
334
335         if (padnum != old_padnum) {
336                 clear_pad_display();
337                 old_padnum = padnum;
338                 show_all = 1;
339         }
340
341         switch (padnum) {
342                 case OBJECT_PAD_ID:                     // Object placement
343                         info_display_object_placement(show_all);
344                         break;
345                 case SEGSIZE_PAD_ID:                    // Segment sizing
346                         info_display_segsize(show_all);
347                         break;
348                 default:
349                         info_display_default(show_all);
350                         break;
351         }
352         grd_curcanv = save_canvas;
353 }
354