1 /* ResidualVM - A 3D game interpreter
2 *
3 * ResidualVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the AUTHORS
5 * file distributed with this source distribution.
6 *
7 * Additional copyright for this file:
8 * Copyright (C) 1999-2000 Revolution Software Ltd.
9 * This code is based on source code created by Revolution Software,
10 * used with permission.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25 *
26 */
27
28 #include "engines/icb/common/px_common.h"
29 #include "engines/icb/p4_generic.h"
30 #include "engines/icb/set.h"
31 #include "engines/icb/debug.h"
32 #include "engines/icb/mission.h"
33 #include "engines/icb/session.h"
34 #include "engines/icb/common/px_string.h"
35 #include "engines/icb/res_man.h"
36 #include "engines/icb/global_objects.h"
37 #include "engines/icb/global_switches.h"
38 #include "engines/icb/surface_manager.h"
39 #include "engines/icb/p4.h"
40 #include "engines/icb/text.h"
41
42 namespace ICB {
43
GetSelectedMegaId(void)44 int32 _game_session::GetSelectedMegaId(void) {
45 selected_mega_id = -1;
46 if ((g_px->mega_hilite) && (player.interact_selected)) {
47 int32 sel_id = player.cur_interact_id;
48 if (logic_structs[sel_id]->image_type != PROP) {
49 selected_mega_id = player.cur_interact_id;
50 }
51 }
52 return selected_mega_id;
53 }
54
GetSelectedMegaRGB(uint8 & r,uint8 & g,uint8 & b)55 void _game_session::GetSelectedMegaRGB(uint8 &r, uint8 &g, uint8 &b) {
56 int32 newr = (uint8)g_mega_select_r + r;
57 int32 newg = (uint8)g_mega_select_g + g;
58 int32 newb = (uint8)g_mega_select_b + b;
59
60 if (newr > 150)
61 newr = 150;
62 if (newg > 150)
63 newg = 150;
64 if (newb > 150)
65 newb = 150;
66
67 r = (uint8)newr;
68 g = (uint8)newg;
69 b = (uint8)newb;
70
71 g_mega_select_r += 8;
72 g_mega_select_g += 8;
73 g_mega_select_b += 8;
74
75 if (g_mega_select_r > 128)
76 g_mega_select_r = 40;
77 if (g_mega_select_g > 128)
78 g_mega_select_g = 40;
79 if (g_mega_select_b > 128)
80 g_mega_select_b = 40;
81 }
82
GetSelectedPropId(void)83 int32 _game_session::GetSelectedPropId(void) {
84 selected_prop_id = -1;
85 if ((g_px->prop_hilite) && (player.interact_selected)) {
86 int32 sel_id = player.cur_interact_id;
87 if (logic_structs[sel_id]->image_type == PROP) {
88 selected_prop_id = player.cur_interact_id;
89 }
90 }
91 return selected_prop_id;
92 }
93
GetSelectedPropRGB(uint8 & r,uint8 & g,uint8 & b)94 void _game_session::GetSelectedPropRGB(uint8 &r, uint8 &g, uint8 &b) {
95 r = (uint8)g_prop_select_r;
96 g = (uint8)g_prop_select_g;
97 b = (uint8)g_prop_select_b;
98
99 g_prop_select_r += 4;
100 g_prop_select_g += 4;
101 g_prop_select_b += 4;
102
103 if (g_prop_select_r > 255)
104 g_prop_select_r = 100;
105 if (g_prop_select_g > 255)
106 g_prop_select_g = 100;
107 if (g_prop_select_b > 255)
108 g_prop_select_b = 100;
109 }
110
IsPropSelected(const char * propName)111 bool8 _game_session::IsPropSelected(const char *propName) {
112 uint32 prop_number = objects->Fetch_item_number_by_name(propName);
113
114 if (prop_number == 0xFFFFFFFF)
115 return FALSE8;
116
117 // Does this prop's id match the seleced_prop's id ?
118 if (prop_number == (uint)selected_prop_id)
119 return TRUE8;
120
121 return FALSE8;
122 }
123
124 #if CD_MODE == 0
125
Render_3d_nicos()126 void _game_session::Render_3d_nicos() {
127 _feature_info *feature;
128 uint32 j;
129 uint32 pitch; // backbuffer pitch
130 uint8 *ad;
131
132 _rgb pen = {// rgb
133 0, 230, 255, 0};
134
135 // is this mode switched on
136 if (g_px->nicos_displayed == FALSE8)
137 return;
138
139 ad = surface_manager->Lock_surface(working_buffer_id);
140 pitch = surface_manager->Get_pitch(working_buffer_id);
141
142 for (j = 0; j < features->Fetch_number_of_items(); j++) {
143 // get nico
144 feature = (_feature_info *)MS->features->Fetch_item_by_number(j);
145
146 // setup camera : have to do this once per frame because
147 // clip_text_print does a Res_open and in principal this
148 // could move the camera about due to defragging etc.
149 PXcamera &camera = GetCamera();
150
151 // set up nico world coords
152 PXvector pos;
153 pos.x = feature->x;
154 pos.y = feature->y;
155 pos.z = feature->z;
156
157 // yesno
158 bool8 result = FALSE8;
159
160 // screen pos
161 PXvector filmpos;
162
163 // compute screen coord
164 PXWorldToFilm(pos, camera, result, filmpos);
165
166 // print name if on screen
167 if (result) {
168 Clip_text_print(&pen, (uint32)(filmpos.x + (SCREEN_WIDTH / 2)), (uint32)((SCREEN_DEPTH / 2) - filmpos.y), ad, pitch, "%s %3.1f",
169 (char *)features->Fetch_items_name_by_number(j), feature->direction);
170 }
171 }
172
173 surface_manager->Unlock_surface(working_buffer_id);
174 }
175
176 #else
177
Render_3d_nicos()178 void _game_session::Render_3d_nicos() {}
179
180 #endif // #if CD_MODE == 0
181
182 } // End of namespace ICB
183