home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #6 / amigaacscoverdisc1998-061998.iso / games / descent / source / main / editor / info.c < prev    next >
Text File  |  1998-06-08  |  15KB  |  489 lines

  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.  * $Source: f:/miner/source/main/editor/rcs/info.c $
  15.  * $Revision: 2.0 $
  16.  * $Author: john $
  17.  * $Date: 1995/02/27 11:35:34 $
  18.  * 
  19.  * Print debugging info in ui.
  20.  * 
  21.  * $Log: info.c $
  22.  * Revision 2.0  1995/02/27  11:35:34  john
  23.  * Version 2.0! No anonymous unions, Watcom 10.0, with no need
  24.  * for bitmaps.tbl.
  25.  * 
  26.  * Revision 1.42  1995/02/22  15:12:50  allender
  27.  * remove anonymous unions from object structure
  28.  * 
  29.  * Revision 1.41  1994/12/08  13:59:39  matt
  30.  * *** empty log message ***
  31.  * 
  32.  * Revision 1.40  1994/09/30  00:38:30  mike
  33.  * Fix some diagnostic messages
  34.  * 
  35.  * Revision 1.39  1994/09/29  20:13:12  mike
  36.  * Clean up some text, prevent it from writing outside canvas.
  37.  * 
  38.  * Revision 1.38  1994/09/29  09:32:17  mike
  39.  * Fix text clipping problem in UI keypad info text.
  40.  * 
  41.  * Revision 1.37  1994/09/25  23:42:20  matt
  42.  * Took out references to obsolete constants
  43.  * 
  44.  * Revision 1.36  1994/08/25  21:57:05  mike
  45.  * IS_CHILD stuff.
  46.  * 
  47.  * Revision 1.35  1994/08/23  16:39:50  mike
  48.  * mode replaced by behavior in ai_info.
  49.  * 
  50.  * Revision 1.34  1994/07/18  10:45:23  mike
  51.  * Fix erase window in texture pads after adding more click-boxes.
  52.  * 
  53.  * Revision 1.33  1994/07/15  12:34:10  mike
  54.  * Remove use of AIM_FOLLOW_PATH_CIRCULAR.
  55.  * 
  56.  * Revision 1.32  1994/06/17  17:13:46  yuan
  57.  * Fixed text so it doesn't overflow screen
  58.  * 
  59.  * Revision 1.31  1994/06/01  17:22:31  matt
  60.  * Set font color before drawing info; got rid of superfluous %d
  61.  * 
  62.  * Revision 1.30  1994/05/29  23:40:29  matt
  63.  * Killed reference to now-unused movement type
  64.  * 
  65.  * Revision 1.29  1994/05/29  22:52:32  matt
  66.  * Deleted unused stuff
  67.  * 
  68.  * Revision 1.28  1994/05/27  10:34:16  yuan
  69.  * Added new Dialog boxes for Walls and Triggers.
  70.  * 
  71.  * Revision 1.27  1994/05/17  10:34:35  matt
  72.  * Changed Num_objects to num_objects, since it's not really global anymore
  73.  * 
  74.  * Revision 1.26  1994/05/14  17:17:59  matt
  75.  * Got rid of externs in source (non-header) files
  76.  * 
  77.  * Revision 1.25  1994/05/12  14:47:07  mike
  78.  * Adjust for Ai_states killed, replaced by field in object structure.
  79.  * 
  80.  * Revision 1.24  1994/05/06  12:52:11  yuan
  81.  * Adding some gamesave checks...
  82.  * 
  83.  * Revision 1.23  1994/05/03  19:21:28  matt
  84.  * Removed reference to robot flythrough mode, which doesn't exist anymore
  85.  * 
  86.  * Revision 1.22  1994/05/03  11:03:06  mike
  87.  * Customize text for segment sizing keypad.
  88.  * 
  89.  * Revision 1.21  1994/04/29  15:05:40  yuan
  90.  * More info added...
  91.  * 
  92.  * Revision 1.20  1994/04/22  17:45:58  john
  93.  * MAde top 2 bits of paste-ons pick the 
  94.  * orientation of the bitmap.
  95.  * 
  96.  * Revision 1.19  1994/04/20  17:29:30  yuan
  97.  * Added tmap_num info.
  98.  * 
  99.  * Revision 1.18  1994/04/13  19:12:55  mike
  100.  * Fix font color problems in keypads.
  101.  * 
  102.  * Revision 1.17  1994/04/13  13:26:37  mike
  103.  * Kill a mprintf.
  104.  * 
  105.  * Revision 1.16  1994/04/13  13:24:44  mike
  106.  * Separate info display, customize for each keypad.
  107.  * 
  108.  * Revision 1.15  1994/03/19  17:21:31  yuan
  109.  * Wall system implemented until specific features need to be added...
  110.  * (Needs to be hammered on though.)
  111.  * 
  112.  * Revision 1.14  1994/02/22  18:13:13  yuan
  113.  * Added tmap number field.
  114.  * 
  115.  * Revision 1.13  1994/02/17  09:46:27  matt
  116.  * Removed include of slew.h
  117.  * 
  118.  * Revision 1.12  1994/02/16  19:58:56  yuan
  119.  * Added type to info
  120.  * 
  121.  * Revision 1.11  1994/02/16  16:48:08  yuan
  122.  * Added Curside.
  123.  * 
  124.  * Revision 1.10  1994/02/03  17:26:43  yuan
  125.  * Fixed formatting of vertex numbering.
  126.  * 
  127.  * Revision 1.9  1994/01/31  12:17:06  yuan
  128.  * Make sure Num_segments, etc. are drawn.
  129.  * 
  130.  * Revision 1.8  1994/01/22  13:43:12  yuan
  131.  * Cosmetic fixes.
  132.  * 
  133.  * Revision 1.7  1994/01/21  12:14:59  yuan
  134.  * Fixed cosmetic problem
  135.  * 
  136.  * Revision 1.6  1994/01/21  12:01:03  yuan
  137.  * Added segment and vertex info
  138.  * 
  139.  * Revision 1.5  1994/01/20  11:28:11  john
  140.  * *** empty log message ***
  141.  * 
  142.  * Revision 1.4  1994/01/19  10:44:42  john
  143.  * *** empty log message ***
  144.  * 
  145.  * Revision 1.3  1994/01/19  10:32:36  john
  146.  * *** empty log message ***
  147.  * 
  148.  * Revision 1.2  1994/01/19  09:34:31  john
  149.  * First version.
  150.  * 
  151.  * Revision 1.1  1994/01/19  09:30:43  john
  152.  * Initial revision
  153.  * 
  154.  * 
  155.  */
  156.  
  157.  
  158. #pragma off (unreferenced)
  159. static char rcsid[] = "$Id: info.c 2.0 1995/02/27 11:35:34 john Exp $";
  160. #pragma on (unreferenced)
  161.  
  162. #include <i86.h>
  163. #include <stdio.h>
  164. #include <stdlib.h>
  165. #include <string.h>                                                  
  166. #include <malloc.h>
  167.  
  168. #include "inferno.h"
  169. #include "segment.h"
  170. #include "gr.h"
  171. #include "ui.h"
  172. #include "editor.h"
  173.  
  174. #include "mono.h"
  175. #include "error.h"
  176. #include "textures.h"
  177. #include "object.h"
  178. #include "ai.h"
  179.  
  180. #include "texpage.h"        // Textue selection paging stuff
  181. #include "objpage.h"        // Object selection paging stuff
  182.  
  183. #include "wall.h"
  184. #include "switch.h"
  185.  
  186. int init_info;
  187.  
  188. struct meminfo {
  189.     int LargestBlockAvail;
  190.     int MaxUnlockedPage;
  191.     int LargestLockablePage;
  192.     int LinAddrSpace;
  193.     int NumFreePagesAvail;
  194.     int NumPhysicalPagesFree;
  195.     int TotalPhysicalPages;
  196.     int FreeLinAddrSpace;
  197.     int SizeOfPageFile;
  198.     int Reserved[3];
  199. } MemInfo;
  200.  
  201. #define DPMI_INT        0x31
  202.  
  203. void read_mem_info()
  204. {
  205.     union REGS regs;
  206.     struct SREGS sregs;
  207.  
  208.     regs.x.eax = 0x00000500;
  209.     memset( &sregs, 0, sizeof(sregs) );
  210.     sregs.es = FP_SEG( &MemInfo );
  211.     regs.x.edi = FP_OFF( &MemInfo );
  212.  
  213.     int386x( DPMI_INT, ®s, ®s, &sregs );
  214. }
  215.  
  216. char * get_object_type(int num, char *name)
  217. {
  218.     switch (num) {
  219.         case OBJ_NONE:            strcpy(name, "OBJ_NONE    ");    break;
  220.         case OBJ_WALL:         strcpy(name, "OBJ_WALL    ");    break;
  221.         case OBJ_FIREBALL:     strcpy(name, "OBJ_FIREBALL");    break;
  222.         case OBJ_ROBOT:         strcpy(name, "OBJ_ROBOT   ");    break;
  223.         case OBJ_HOSTAGE:     strcpy(name, "OBJ_HOSTAGE ");    break;
  224.         case OBJ_PLAYER:         strcpy(name, "OBJ_PLAYER  ");    break;
  225.         case OBJ_WEAPON:         strcpy(name, "OBJ_WEAPON  ");    break;
  226.         case OBJ_CAMERA:         strcpy(name, "OBJ_CAMERA  ");    break;
  227.         case OBJ_POWERUP:     strcpy(name, "OBJ_POWERUP ");    break;
  228.         default:                    strcpy(name, " (unknown)  ");    break;
  229.     }
  230.  
  231.     return name;
  232. }
  233.  
  234. char * get_control_type(int num, char *name)
  235. {
  236.     switch (num) {
  237.         case CT_NONE:                    strcpy(name, "CT_NONE       ");    break;
  238.         case CT_AI:                        strcpy(name, "CT_AI         ");    break;
  239.         case CT_EXPLOSION:            strcpy(name, "CT_EXPLOSION  ");    break;
  240.         //case CT_MULTIPLAYER:            strcpy(name, "CT_MULTIPLAYER");    break;
  241.         case CT_FLYING:                strcpy(name, "CT_FLYING     ");    break;
  242.         case CT_SLEW:                    strcpy(name, "CT_SLEW       ");    break;
  243.         case CT_FLYTHROUGH:            strcpy(name, "CT_FLYTHROUGH ");    break;
  244.         //case CT_DEMO:                    strcpy(name, "CT_DEMO       ");    break;
  245.         //case CT_ROBOT_FLYTHROUGH:    strcpy(name, "CT_FLYTHROUGH ");    break;
  246.         case CT_WEAPON:                strcpy(name, "CT_WEAPON     ");    break;
  247.         default:                            strcpy(name, " (unknown)    ");    break;
  248.     }
  249.     return name;
  250. }
  251.  
  252. char * get_movement_type(int num, char *name)
  253. {
  254.     switch (num) {
  255.         case MT_NONE:            strcpy(name, "MT_NONE       ");    break;
  256.         case MT_PHYSICS:        strcpy(name, "MT_PHYSICS    ");    break;
  257.         //case MT_MULTIPLAYER:    strcpy(name, "MT_MULTIPLAYER");    break;
  258.         default:                    strcpy(name, " (unknown)    ");    break;
  259.     }
  260.     return name;
  261. }
  262.  
  263. char * get_ai_behavior(int num, char *name)
  264. {
  265. #define    AIB_STILL                        0x80
  266. #define    AIB_NORMAL                        0x81
  267. #define    AIB_HIDE                            0x82
  268. #define    AIB_RUN_FROM                    0x83
  269. #define    AIB_FOLLOW_PATH                0x84
  270.  
  271.     switch (num) {
  272.         case AIB_STILL:                strcpy(name, "STILL       ");    break;
  273.         case AIB_NORMAL:                strcpy(name, "NORMAL      ");    break;
  274.         case AIB_HIDE:                    strcpy(name, "HIDE        ");    break;
  275.         case AIB_RUN_FROM:            strcpy(name, "RUN_FROM    ");    break;
  276.         case AIB_FOLLOW_PATH:        strcpy(name, "FOLLOW_PATH ");    break;
  277.         default:                            strcpy(name, " (unknown)  ");    break;
  278.     }
  279.     return name;
  280. }
  281.  
  282. //    ---------------------------------------------------------------------------------------------------
  283. void info_display_object_placement(int show_all)
  284. {
  285.     static    int    old_Cur_object_index;
  286.     static    int    old_type;
  287.     static    int    old_movement_type;
  288.     static    int    old_control_type;
  289.     static    int    old_mode;
  290.  
  291.     char        name[30];
  292.  
  293.     if (init_info | show_all) {
  294.         old_Cur_object_index = -2;
  295.         old_type = -2;
  296.         old_movement_type = -2;
  297.         old_control_type = -2;
  298.         old_mode = -2;
  299.     }
  300.  
  301.     if ( ( Cur_object_index != old_Cur_object_index) || 
  302.             ( Objects[Cur_object_index].type != old_type) || 
  303.             ( Objects[Cur_object_index].movement_type != old_movement_type) || 
  304.             ( Objects[Cur_object_index].control_type != old_control_type) || 
  305.             ( Objects[Cur_object_index].ctype.ai_info.behavior != old_mode) ) {
  306.  
  307.         gr_uprintf( 0, 0, "Object id: %4d\n", Cur_object_index);
  308.         gr_uprintf( 0, 16, "Type: %s\n", get_object_type(Objects[Cur_object_index].type , name));
  309.         gr_uprintf( 0, 32, "Movmnt: %s\n", get_movement_type(Objects[Cur_object_index].movement_type, name));
  310.         gr_uprintf( 0, 48, "Cntrl: %s\n", get_control_type(Objects[Cur_object_index].control_type, name));
  311.         gr_uprintf( 0, 64, "Mode: %s\n", get_ai_behavior(Objects[Cur_object_index].ctype.ai_info.behavior, name));
  312.  
  313.         old_Cur_object_index = Cur_object_index;
  314.         old_type = Objects[Cur_object_index].type;
  315.         old_movement_type = Objects[Cur_object_index].movement_type;
  316.         old_mode = Objects[Cur_object_index].control_type;
  317.         old_mode = Objects[Cur_object_index].ctype.ai_info.behavior;
  318.     }
  319.  
  320. }
  321.  
  322. //    ---------------------------------------------------------------------------------------------------
  323. void info_display_segsize(int show_all)
  324. {
  325.     static    int    old_SegSizeMode;
  326.  
  327.     char        name[30];
  328.  
  329.     if (init_info | show_all) {
  330.         old_SegSizeMode = -2;
  331.     }
  332.  
  333.     if (old_SegSizeMode != SegSizeMode  ) {
  334.         switch (SegSizeMode) {
  335.             case SEGSIZEMODE_FREE:        strcpy(name, "free   ");    break;
  336.             case SEGSIZEMODE_ALL:        strcpy(name, "all    ");    break;
  337.             case SEGSIZEMODE_CURSIDE:    strcpy(name, "curside");    break;
  338.             case SEGSIZEMODE_EDGE:        strcpy(name, "edge   ");    break;
  339.             case SEGSIZEMODE_VERTEX:    strcpy(name, "vertex ");    break;
  340.             default:
  341.                 Error("Illegal value for SegSizeMode in info.c/info_display_segsize\n");
  342.         }
  343.  
  344.         gr_uprintf( 0, 0, "Mode: %s\n", name);
  345.  
  346.         old_SegSizeMode = SegSizeMode;
  347.     }
  348.  
  349. }
  350.  
  351. extern int num_objects;
  352.  
  353. //    ---------------------------------------------------------------------------------------------------
  354. void info_display_default(int show_all)
  355. {
  356.     static int old_Num_segments = -1;
  357.     static int old_Num_vertices = -1;
  358.     static int old_Num_objects = -1;
  359.     static int old_Cursegp_num = -1;
  360.     static int old_Curside = -1;
  361.     static int old_Cursegp_num_for_verts = -1;
  362.     static int old_CurrentTexture = -1;
  363.     static int old_Num_walls = -1;
  364.     static int old_Num_triggers = -1;
  365.  
  366.     if (init_info | show_all) {
  367.         init_info = 0;
  368.         old_Num_segments = -1;
  369.         old_Num_vertices = -1;
  370.         old_Num_objects = -1;
  371.         old_Cursegp_num = -1;
  372.         old_Cursegp_num_for_verts = -1;
  373.         old_Curside = -1;
  374.         old_CurrentTexture = -1;
  375.         old_Num_walls = -1;
  376.         old_Num_triggers = -1;
  377.     }
  378.  
  379.     gr_set_fontcolor(CBLACK,CWHITE);
  380.  
  381.     //--------------- Number of segments ----------------
  382.  
  383.     if ( old_Num_segments != Num_segments )    {
  384.         gr_uprintf( 0, 0, "Segments: %4d/%4d", Num_segments, MAX_SEGMENTS );
  385.         old_Num_segments = Num_segments;
  386.     }
  387.  
  388.     //---------------- Number of vertics -----------------
  389.     
  390.     if ( old_Num_vertices != Num_vertices )    {
  391.         gr_uprintf( 0, 16, "Vertices: %4d/%4d", Num_vertices, MAX_VERTICES );
  392.         old_Num_vertices = Num_vertices;
  393.     }
  394.  
  395.     //---------------- Number of objects -----------------
  396.     
  397.     if ( old_Num_objects != num_objects )    {
  398.         gr_uprintf( 0, 32, "Objs: %3d/%3d", num_objects, MAX_OBJECTS );
  399.         old_Num_objects = num_objects;
  400.     }
  401.  
  402.       //--------------- Current_segment_number -------------
  403.     //--------------- Current_side_number -------------
  404.  
  405.     if (( old_Cursegp_num != Cursegp-Segments ) || ( old_Curside != Curside ))    {
  406.         gr_uprintf( 0, 48, "Cursegp/side: %3d/%1d", Cursegp-Segments, Curside);
  407.         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);
  408.         old_Cursegp_num = Cursegp-Segments;
  409.         old_Curside = Curside;
  410.     }
  411.  
  412.     //--------------- Current_vertex_numbers -------------
  413.  
  414.     if ( old_Cursegp_num_for_verts != Cursegp-Segments )    {
  415.  
  416.         gr_uprintf( 0, 64, "{%3d,%3d,%3d,%3d,", Cursegp->verts[0],Cursegp->verts[1],
  417.                                                                                              Cursegp->verts[2],Cursegp->verts[3] );
  418.         gr_uprintf( 0, 80," %3d,%3d,%3d,%3d}", Cursegp->verts[4],Cursegp->verts[5],
  419.                                                                                              Cursegp->verts[6],Cursegp->verts[7] );
  420.         old_Cursegp_num_for_verts = Cursegp-Segments;
  421.     }
  422.  
  423.     //--------------- Num walls/links/triggers -------------------------
  424.  
  425.     if ( old_Num_walls != Num_walls ) {
  426. //        gr_uprintf( 0, 96, "Walls/Links %d/%d", Num_walls, Num_links );
  427.         gr_uprintf( 0, 96, "Walls %3d", Num_walls );
  428.         old_Num_walls = Num_walls;
  429.     }
  430.  
  431.     //--------------- Num triggers ----------------------
  432.  
  433.     if ( old_Num_triggers != Num_triggers ) {
  434.         gr_uprintf( 0, 112, "Num_triggers %2d", Num_triggers );
  435.         old_Num_triggers = Num_triggers;
  436.     }
  437.  
  438.     //--------------- Current texture number -------------
  439.  
  440.     if ( old_CurrentTexture != CurrentTexture )    {
  441.         gr_uprintf( 0, 144, "Tex/Light: %3d %5.2f", CurrentTexture, f2fl(TmapInfo[CurrentTexture].lighting));
  442.         old_CurrentTexture = CurrentTexture;
  443.     }
  444.  
  445. }
  446.  
  447. //    ------------------------------------------------------------------------------------
  448. void clear_pad_display(void)
  449. {
  450.     gr_clear_canvas(CWHITE);
  451.    gr_set_fontcolor( CBLACK, CWHITE );
  452. }
  453.  
  454. //    ------------------------------------------------------------------------------------
  455. void info_display_all( UI_WINDOW * wnd )
  456. {
  457.     static    old_padnum = -1;
  458.     int        padnum,show_all = 0;
  459.     grs_canvas *save_canvas = grd_curcanv;
  460.  
  461.     wnd++;        //kill warning
  462.  
  463.     grd_curcanv = Pad_text_canvas;
  464.  
  465.     padnum = ui_pad_get_current();
  466.     Assert(padnum <= MAX_PAD_ID);
  467.  
  468.     if (padnum != old_padnum) {
  469.         clear_pad_display();
  470.         old_padnum = padnum;
  471.         show_all = 1;
  472.     }
  473.  
  474.     switch (padnum) {
  475.         case OBJECT_PAD_ID:            // Object placement
  476.             info_display_object_placement(show_all);
  477.             break;
  478.         case SEGSIZE_PAD_ID:            // Segment sizing
  479.             info_display_segsize(show_all);
  480.             break;
  481.         default:
  482.             info_display_default(show_all);
  483.             break;
  484.     }
  485.     grd_curcanv = save_canvas;
  486. }
  487.  
  488. 
  489.