home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #6 / amigaacscoverdisc1998-061998.iso / games / descent / source / main / bm.c < prev    next >
Text File  |  1998-06-08  |  6KB  |  191 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/rcs/bm.c $
  15.  * $Revision: 2.3 $
  16.  * $Author: john $
  17.  * $Date: 1995/03/14 16:22:04 $
  18.  *
  19.  * Bitmap and palette loading functions.
  20.  *
  21.  * $Log: bm.c $
  22.  * Revision 2.3  1995/03/14  16:22:04  john
  23.  * Added cdrom alternate directory stuff.
  24.  * 
  25.  * Revision 2.2  1995/03/07  16:51:48  john
  26.  * Fixed robots not moving without edtiro bug.
  27.  * 
  28.  * Revision 2.1  1995/03/06  15:23:06  john
  29.  * New screen techniques.
  30.  * 
  31.  * Revision 2.0  1995/02/27  11:27:05  john
  32.  * New version 2.0, which has no anonymous unions, builds with
  33.  * Watcom 10.0, and doesn't require parsing BITMAPS.TBL.
  34.  * 
  35.  * 
  36.  */
  37.  
  38. #pragma off (unreferenced)
  39. static char rcsid[] = "$Id: bm.c 2.3 1995/03/14 16:22:04 john Exp $";
  40. #pragma on (unreferenced)
  41.  
  42. #include <stdio.h>
  43. #include <stdlib.h>
  44.  
  45. #include "types.h"
  46. #include "inferno.h"
  47. #include "gr.h"
  48. #include "bm.h"
  49. #include "mem.h"
  50. #include "cflib.h"
  51. #include "mono.h"
  52. #include "error.h"
  53. #include "object.h"
  54. #include "vclip.h"
  55. #include "effects.h"
  56. #include "polyobj.h"
  57. #include "wall.h"
  58. #include "textures.h"
  59. #include "game.h"
  60. #include "multi.h"
  61. #include "iff.h"
  62. #include "cfile.h"
  63. #include "hostage.h"
  64. #include "powerup.h"
  65. #include "sounds.h"
  66. #include "piggy.h"
  67. #include "aistruct.h"
  68. #include "robot.h"
  69. #include "weapon.h"
  70. #include "gauges.h"
  71. #include "player.h"
  72. #include "fuelcen.h"
  73. #include "endlevel.h"
  74. #include "cntrlcen.h"
  75.  
  76. ubyte Sounds[MAX_SOUNDS];
  77. ubyte AltSounds[MAX_SOUNDS];
  78.  
  79. int Num_total_object_types;
  80.  
  81. byte    ObjType[MAX_OBJTYPE];
  82. byte    ObjId[MAX_OBJTYPE];
  83. fix    ObjStrength[MAX_OBJTYPE];
  84.  
  85. //for each model, a model number for dying & dead variants, or -1 if none
  86. int Dying_modelnums[MAX_POLYGON_MODELS];
  87. int Dead_modelnums[MAX_POLYGON_MODELS];
  88.  
  89. //right now there's only one player ship, but we can have another by 
  90. //adding an array and setting the pointer to the active ship.
  91. player_ship only_player_ship,*Player_ship=&only_player_ship;
  92.  
  93. //----------------- Miscellaneous bitmap pointers ---------------
  94. int                    Num_cockpits = 0;
  95. bitmap_index        cockpit_bitmap[N_COCKPIT_BITMAPS];
  96.  
  97. //---------------- Variables for wall textures ------------------
  98. int                     Num_tmaps;
  99. tmap_info             TmapInfo[MAX_TEXTURES];
  100.  
  101. //---------------- Variables for object textures ----------------
  102.  
  103. int                    First_multi_bitmap_num=-1;
  104.  
  105. bitmap_index        ObjBitmaps[MAX_OBJ_BITMAPS];
  106. ushort                ObjBitmapPtrs[MAX_OBJ_BITMAPS];        // These point back into ObjBitmaps, since some are used twice.
  107.  
  108. //-----------------------------------------------------------------
  109. // Initializes all bitmaps from BITMAPS.TBL file.
  110. int bm_init()
  111. {
  112.     init_polygon_models();
  113.     piggy_init();                // This calls bm_read_all
  114.     piggy_read_sounds();
  115.     return 0;
  116. }
  117.  
  118. void bm_read_all(CFILE * fp)
  119. {
  120.     int i;
  121.  
  122.     cfread( &NumTextures, sizeof(int), 1, fp );
  123.     cfread( Textures, sizeof(bitmap_index), MAX_TEXTURES, fp );
  124.     cfread( TmapInfo, sizeof(tmap_info), MAX_TEXTURES, fp );
  125.     
  126.     cfread( Sounds, sizeof(ubyte), MAX_SOUNDS, fp );
  127.     cfread( AltSounds, sizeof(ubyte), MAX_SOUNDS, fp );
  128.  
  129.     cfread( &Num_vclips, sizeof(int), 1, fp );
  130.     cfread( Vclip, sizeof(vclip), VCLIP_MAXNUM, fp );
  131.  
  132.     cfread( &Num_effects, sizeof(int), 1, fp );
  133.     cfread( Effects, sizeof(eclip), MAX_EFFECTS, fp );
  134.  
  135.     cfread( &Num_wall_anims, sizeof(int), 1, fp );
  136.     cfread( WallAnims, sizeof(wclip), MAX_WALL_ANIMS, fp );
  137.  
  138.     cfread( &N_robot_types, sizeof(int), 1, fp );
  139.     cfread( Robot_info, sizeof(robot_info), MAX_ROBOT_TYPES, fp );
  140.  
  141.     cfread( &N_robot_joints, sizeof(int), 1, fp );
  142.     cfread( Robot_joints, sizeof(jointpos), MAX_ROBOT_JOINTS, fp );
  143.  
  144.     cfread( &N_weapon_types, sizeof(int), 1, fp );
  145.     cfread( Weapon_info, sizeof(weapon_info), MAX_WEAPON_TYPES, fp );
  146.  
  147.     cfread( &N_powerup_types, sizeof(int), 1, fp );
  148.     cfread( Powerup_info, sizeof(powerup_type_info), MAX_POWERUP_TYPES, fp );
  149.     
  150.     cfread( &N_polygon_models, sizeof(int), 1, fp );
  151.     cfread( Polygon_models, sizeof(polymodel), N_polygon_models, fp );
  152.  
  153.     for (i=0; i<N_polygon_models; i++ )    {
  154.         Polygon_models[i].model_data = malloc(Polygon_models[i].model_data_size);
  155.         Assert( Polygon_models[i].model_data != NULL );
  156.         cfread( Polygon_models[i].model_data, sizeof(ubyte), Polygon_models[i].model_data_size, fp );
  157.     }
  158.  
  159.     cfread( Gauges, sizeof(bitmap_index), MAX_GAUGE_BMS, fp );
  160.  
  161.     cfread( Dying_modelnums, sizeof(int), MAX_POLYGON_MODELS, fp );
  162.     cfread( Dead_modelnums, sizeof(int), MAX_POLYGON_MODELS, fp );
  163.  
  164.     cfread( ObjBitmaps, sizeof(bitmap_index), MAX_OBJ_BITMAPS, fp );
  165.     cfread( ObjBitmapPtrs, sizeof(ushort), MAX_OBJ_BITMAPS, fp );
  166.  
  167.     cfread( &only_player_ship, sizeof(player_ship), 1, fp );
  168.  
  169.     cfread( &Num_cockpits, sizeof(int), 1, fp );
  170.     cfread( cockpit_bitmap, sizeof(bitmap_index), N_COCKPIT_BITMAPS, fp );
  171.  
  172.     cfread( Sounds, sizeof(ubyte), MAX_SOUNDS, fp );
  173.     cfread( AltSounds, sizeof(ubyte), MAX_SOUNDS, fp );
  174.  
  175.     cfread( &Num_total_object_types, sizeof(int), 1, fp );
  176.     cfread( ObjType, sizeof(byte), MAX_OBJTYPE, fp );
  177.     cfread( ObjId, sizeof(byte), MAX_OBJTYPE, fp );
  178.     cfread( ObjStrength, sizeof(fix), MAX_OBJTYPE, fp );
  179.  
  180.     cfread( &First_multi_bitmap_num, sizeof(int), 1, fp );
  181.  
  182.     cfread( &N_controlcen_guns, sizeof(int), 1, fp );
  183.     cfread( controlcen_gun_points, sizeof(vms_vector), MAX_CONTROLCEN_GUNS, fp );
  184.     cfread( controlcen_gun_dirs, sizeof(vms_vector), MAX_CONTROLCEN_GUNS, fp );
  185.     cfread( &exit_modelnum, sizeof(int), 1, fp );
  186.     cfread( &destroyed_exit_modelnum, sizeof(int), 1, fp );
  187. }
  188.  
  189.  
  190. 
  191.