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 __OBJCLASS_H
20 #define __OBJCLASS_H
21 
22 /*
23  * $Source: n:/project/cit/src/inc/RCS/objclass.h $
24  * $Revision: 1.6 $
25  * $Author: dc $
26  * $Date: 1994/04/03 05:59:14 $
27  *
28  * $Log: objclass.h $
29  * Revision 1.6  1994/04/03  05:59:14  dc
30  * OPNUM and the other ??NUM three, running a bit faster, still should probably change
31  * to inline assembler, along with the other main macros...
32  * perhaps just make ObjProps[OPNUM(id)] an inlined asm thing
33  *
34  * Revision 1.5  1994/01/02  21:09:50  xemu
35  * new containers
36  *
37  * Revision 1.4  1993/10/01  23:55:13  xemu
38  * new object regime
39  *
40  * Revision 1.3  1993/09/02  23:08:12  xemu
41  * angle me baby
42  *
43  * Revision 1.2  1993/08/17  21:54:15  minman
44  * added prototype for nth_after_triple and get_nth_from_triple
45  *
46  * Revision 1.1  1993/08/05  14:05:20  minman
47  * Initial revision
48  *
49  *
50  */
51 
52 // Includes
53 #include "objects.h"
54 
55 // Some macros...
56 #define MAKETRIP(obclass, subclass, type) ((obclass << 16u) + (subclass << 8u) + type)
57 #define ID2TRIP(id) MAKETRIP(objs[id].obclass, objs[id].subclass, objs[id].info.type)
58 
59 #define TRIP2CL(trip) ((ObjClass)(trip >> 16))
60 #define TRIP2SC(trip) ((trip & 0xFF00) >> 8)
61 #define TRIP2TY(trip) (trip & 0xFF)
62 #define OBJBASE(triple) (((TRIP2CL(triple) & 0xF) << 4) + (TRIP2SC(triple) & 0xF))
63 
64 #define OPTRIP(triple) (ObjBaseArray[OBJBASE(triple)] + TRIP2TY(triple))
65 #define CPTRIP(triple) (ClassBaseArray[TRIP2CL(triple)][TRIP2SC(triple)] + TRIP2TY(triple))
66 #define SCTRIP(triple) TRIP2TY(triple)
67 
68 #define OPNUM(id) (ObjBaseArray[(objs[id].obclass << 4u) + (objs[id].subclass)] + objs[id].info.type)
69 #define CPNUM(id) (ClassBaseArray[objs[id].obclass][objs[id].subclass] + objs[id].info.type)
70 #define SCNUM(id) (objs[id].info.type)
71 
72 #ifdef SLOW
73 #define OPNUM(id) OPTRIP(ID2TRIP(id))
74 #define CPNUM(id) CPTRIP(ID2TRIP(id))
75 #define SCNUM(id) SCTRIP(ID2TRIP(id))
76 #endif
77 
78 // Prototypes
79 short num_types(uchar obclass, uchar subclass);
80 
81 // Told to find the nth object of class "class", will return appropriate
82 // triple or -1 if nth object didn't exist
83 int get_triple_from_class_nth_item(uchar obclass, uchar n);
84 
85 // returns the triple which is n past the given base
86 int nth_after_triple(int base, uchar n);
87 
88 // given a triple, returns n which represents the count
89 // past the first of its class
90 int get_nth_from_triple(int triple);
91 
92 // Defines
93 /*
94 #define COMMON_OBJSPEC_FIELDS 	\
95    union {                       \
96                 ObjID id;						\
97                 ObjSpecID headused;        \
98         };                            \
99         union {                       \
100                 ObjSpecID next;				\
101                 ObjSpecID headfree;        \
102         };                            \
103         ObjSpecID prev
104 
105 #define COMMON_OBJSPEC_SIZE   (sizeof(ObjSpecID) * 3)
106 */
107 
108 #endif // __OBJCLASS_H
109