1 /* 2 3 Copyright (C) 2015-2018 Night Dive Studios, LLC. 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 */ 19 #ifndef __OBJSIM_H 20 #define __OBJSIM_H 21 22 /* 23 * $Source: r:/prj/cit/src/inc/RCS/objsim.h $ 24 * $Revision: 1.60 $ 25 * $Author: xemu $ 26 * $Date: 1994/09/06 23:47:57 $ 27 * 28 * 29 */ 30 31 // Includes 32 #include "objects.h" 33 34 #define ID2SPEC(id) (objs[(id)].specID) 35 36 #ifdef __OBJSIM_SRC 37 int ObjBaseArray[255]; 38 int ClassBaseArray[16][16]; 39 #else 40 extern int ObjBaseArray[255]; 41 extern int ClassBaseArray[16][16]; 42 #endif 43 44 #define OBJ_PLAYER_CAMERA 0 45 #define OBJ_STATIC_CAMERA 1 46 #define OBJ_CURRENT_CAMERA 2 47 #define OBJ_DYNAMIC_CAMERA 3 48 49 #define FIND_TRIPLE 0 50 #define FIND_SUBCLASS 1 51 #define FIND_CLASS 2 52 #define FIND_ALL 3 53 54 // Functions for getting the bitmap for a given critter on a specific frame, from a specific view 55 // macros for now -- this is basically a cheap interface to the resource system's LRU cache 56 #define get_critter_bitmap(id, triple, posture, frame, view) \ 57 (lock_bitmap_from_ref(ref_from_critter_data((id), (triple), (posture), (frame), (view)))) 58 #define release_critter_bitmap(triple, posture, frame, view) \ 59 (RefUnlock(ref_from_critter_data((triple), (posture), (frame), (view)))) 60 61 #define get_critter_bitmap_fast(id, triple, posture, frame, view, pref, panch) \ 62 (lock_bitmap_from_ref_anchor(*(pref) = ref_from_critter_data((id), (triple), (posture), (frame), (view)), (panch))) 63 #define release_critter_bitmap_fast(ref) (RefUnlock((ref))) 64 65 // macros for calling those other macros with only an object ID 66 #define get_critter_bitmap_obj(id, view) \ 67 (get_critter_bitmap((id), ID2TRIP((id)), get_crit_posture(ID2SPEC(id)), objs[(id)].info.current_frame, (view))) 68 #define release_critter_bitmap_obj(id, view) \ 69 (release_critter_bitmap(ID2TRIP((id)), get_crit_posture(ID2SPEC(id)), objs[(id)].info.current_frame, (view))) 70 #define get_critter_bitmap_obj_fast(id, view, pref, panch) \ 71 (get_critter_bitmap_fast((id), ID2TRIP((id)), get_crit_posture(ID2SPEC(id)), objs[(id)].info.current_frame, \ 72 (view), (pref), (panch))) 73 74 #define DOOR_ID_BASE 2400 75 #define door_id(id) (DOOR_ID_BASE + CPTRIP(ID2TRIP(id))) 76 77 Ref obj_cache_ref(ObjID id); 78 #define get_obj_cache_bitmap(id, pref) (lock_bitmap_from_ref(*(pref) = obj_cache_ref(id))) 79 #define release_obj_cache_bitmap(ref) (RefUnlock((ref))) 80 81 // Animation 82 #define get_anim_bitmap(triple, frame) (obj_bitmaps[ObjProps[OPTRIP((triple))].bitmap_3d + (frame)]) 83 #define get_anim_bitmap_obj(id) (get_anim_bitmap(ID2TRIP((id)), objAnimatings[ID2SPEC(id)].current_frame)) 84 // keep starting index in lower two bytes, keep # of anim frames in next-to-top byte. 85 // wow, this has become gruesomely complex 86 // we will consider the possbility of just moving all the other flags around in order to 87 // steal that top bit, rather than this gruesome nightmare 88 #define BMAP_NUM_3D(x) (((x)&0x3FF) + (((x) & (0x8000)) >> 5)) 89 #define FRAME_NUM_3D(x) (((x)&0x7000) >> 12) 90 #define REPEAT_3D(x) (((x)&0x0800) >> 11) 91 #define ANIM_3D(x) (((x)&0x0400) >> 10) 92 93 // Textured Polygons 94 grs_bitmap *bitmap_from_tpoly_data(int tpdata, ubyte *scale, int *index, uchar *type, Ref *ref); 95 96 // Prototypes 97 errtype obj_init(); 98 errtype obj_shutdown(); 99 ObjID obj_create_base(int triple); 100 ObjID obj_create_clone(ObjID dna); 101 errtype obj_move_to_vel(ObjID id, ObjLoc *newloc, uchar phys_tel, fix x_dot, fix y_dot, fix z_dot); 102 errtype obj_move_to(ObjID id, ObjLoc *newloc, uchar phys_tel); 103 uchar obj_destroy(ObjID id); 104 errtype obj_holocaust(); 105 uchar obj_holocaust_func(short keycode, ulong context, void *data); 106 errtype obj_load_properties(); 107 errtype obj_create_player(ObjLoc *plr_loc); 108 Ref ref_from_critter_data(ObjID oid, int triple, byte posture, short frame, short view); 109 errtype obj_zero_unused(); 110 errtype obj_model_hack(ObjID id, uchar *hack_x, uchar *hack_y, uchar *hack_z, uchar *hack_type); 111 uchar obj_combat_destroy(ObjID id); 112 ObjID object_place(int triple, LGPoint square); 113 ushort obj_floor_compute(ObjID id, uchar flrh); 114 ushort obj_floor_height(ObjID id); 115 errtype obj_physics_refresh_area(short x, short y, uchar use_floor); 116 117 ObjID physics_handle_to_id(physics_handle p); 118 119 #ifdef __OBJSIM_SRC 120 ObjID current_object = OBJ_NULL; 121 #else 122 extern ObjID current_object; 123 #endif 124 125 #endif // __OBJSIM_H 126