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 __WARES_H
20 #define __WARES_H
21 
22 #include "gamesys.h"
23 
24 /*
25  * $Source: r:/prj/cit/src/inc/RCS/wares.h $
26  * $Revision: 1.27 $
27  * $Author: xemu $
28  * $Date: 1994/08/07 21:00:48 $
29  *
30  *
31  */
32 
33 // Includes
34 
35 // ------
36 // Macros
37 // ------
38 
39 #define WareActive(status) ((status)&WARE_ON)
40 
41 // -------
42 // Defines
43 // -------
44 
45 #define WARE_HARD         0
46 #define WARE_SOFT_COMBAT  1
47 #define WARE_SOFT_DEFENSE 2
48 #define WARE_SOFT_MISC    3
49 #define NUM_WARE_TYPES    4
50 
51 #define WARE_UPDATE_FREQ 280 // How often all wares updated
52 
53 #define WARE_ON      0x01u // Player_struct status flags
54 #define WARE_DAMAGED 0x02u
55 #define WARE_FLASH   0x04u
56 
57 #define WARE_FLAGS_NONE 0x00 // Here will go various flag bits
58 
59 // ----------
60 // Ware Types
61 // ----------
62 
63 // HARDWARE
64 
65 #define FIRST_GOGGLE_WARE 0
66 #define LAST_GOGGLE_WARE  4
67 
68 #define HARDWARE_GOGGLE_INFRARED 0
69 #define HARDWARE_TARGET          1
70 #define HARDWARE_360             2
71 #define HARDWARE_AIM             3
72 #define HARDWARE_HUD             4
73 #define HARDWARE_BIOWARE         5
74 #define HARDWARE_AUTOMAP         6
75 #define HARDWARE_SHIELD          7
76 #define HARDWARE_EMAIL           8
77 #define HARDWARE_LANTERN         9
78 #define HARDWARE_FULLSCREEN     10
79 #define HARDWARE_ENVIROSUIT     11
80 #define HARDWARE_MOTION         12
81 #define HARDWARE_SKATES         13
82 #define HARDWARE_STATUS         14
83 
84 // Wacky ware-specific defines
85 #define LAMP_MASK 0xC0u
86 #define LAMP_SHF 6u
87 #define LAMP_SETTING(status) (((status)&LAMP_MASK) >> LAMP_SHF)
88 #define LAMP_SETTING_SET(status, val) ((status) = (((status) & ~LAMP_MASK) | ((val) << LAMP_SHF)))
89 #define LAMP_VERSIONS 3
90 #define SHIELD_SETTING LAMP_SETTING
91 #define SHIELD_SETTING_SET LAMP_SETTING_SET
92 #define SHIELD_VERSIONS 4
93 
94 // ----------
95 // Structures
96 // ----------
97 
98 typedef struct {
99     ubyte flags;                                     // Do we have a sideicon, etc.
100     ubyte sideicon;                                  // Which sideicon corresponds
101     void (*turnon)(uchar visible, uchar real_start); // Function slots for turn on, etc.
102     void (*effect)();
103     void (*turnoff)(uchar visible, uchar real_stop);
104     bool (*check)();
105 } WARE;
106 
107 typedef struct {
108     ushort timestamp;
109     ushort type;
110     byte light_value;
111     ubyte previous; // was the light on before ??
112     ubyte filler;
113 } LightSchedEvent;
114 
115 // ----------
116 // Prototypes
117 // ----------
118 
119 void get_ware_pointers(int type, ubyte **player_wares, ubyte **player_status, WARE **wares, int *n);
120 // Sets several pointers as appropriate to a ware type: the approp. player_struct
121 // arrays, the approp. global wares property array, and the number of different
122 // wares for that type
123 
124 char *get_ware_name(int waretype, int num, char *buf, int bufsz);
125 // Fills the buffer with the SHORT name of the ware, specified by
126 // one of the of the four ware types (hard,combat,def,misc),
127 // and "subtype"
128 
129 int get_ware_triple(int waretype, int num);
130 // converts a (waretype,num) pair into a triple.
131 
132 void use_ware(int waretype, int num);
133 // Uses a ware from the player's inventory, same format
134 
135 int get_player_ware_version(int waretype, int num);
136 // get_player_ware_version returns the version number
137 // of a ware in the player's inventory.  zero means
138 // the player doesn't have it.
139 
140 void wares_init();
141 // sets up the wares system
142 
143 void wares_update();
144 // called from the game loop
145 
146 // -------
147 // Globals
148 // -------
149 
150 // what mode are we using.
151 extern ubyte motionware_mode;
152 #define MOTION_INACTIVE 0
153 #define MOTION_SKATES   1
154 #define MOTION_BOOST    2
155 #define MOTION_JUMP     3
156 
157 #endif // __WARES_H
158