3 * Copyright (C) 1998 Brainchild Design - http://brainchilddesign.com/
5 * Copyright (C) 2001 tarzeau@space.ch
7 * Copyright (C) 2002 Florian Schulze - crow@icculus.org
9 * Portions of this code are from the MPEG software simulation group
10 * idct implementation. This code will be replaced with a new
11 * implementation soon.
13 * This file is part of Jump'n'Bump.
15 * Jump'n'Bump is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
20 * Jump'n'Bump is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32 static int num_mouse_buttons;
40 if ((inportb(0x201) & 1) == 0)
58 c1 = x = y = flag = 0;
88 if (joy.raw_x < joy.calib_data.x2)
89 joy.x = ((long) (joy.raw_x - joy.calib_data.x2) << 10) / (joy.calib_data.x2 - joy.calib_data.x1);
91 joy.x = ((long) (joy.raw_x - joy.calib_data.x2) << 10) / (joy.calib_data.x3 - joy.calib_data.x2);
92 if (joy.raw_y < joy.calib_data.y2)
93 joy.y = ((long) (joy.raw_y - joy.calib_data.y2) << 10) / (joy.calib_data.y2 - joy.calib_data.y1);
95 joy.y = ((long) (joy.raw_y - joy.calib_data.y2) << 10) / (joy.calib_data.y3 - joy.calib_data.y2);
107 joy.but1 = (((s1 >> 4) & 1) ^ 1);
108 joy.but2 = (((s1 >> 5) & 1) ^ 1);
110 joy.raw_x = joy.calib_data.x2;
111 joy.raw_y = joy.calib_data.y2;
115 joy.but1 = joy.but2 = 0;
121 int calib_joy(int type)
129 while (joy.but1 == 1) {
131 joy.but1 = (((s1 >> 4) & 1) ^ 1);
132 if (key_pressed(1) == 1) {
133 while (key_pressed(1) == 1);
140 while (joy.but1 == 0) {
142 c1 = x = y = flag = 0;
157 if (x != 0 && y != 0)
172 joy.but1 = (((s1 >> 4) & 1) ^ 1);
174 if (num_times < 0x7fffffff)
180 if (key_pressed(1) == 1) {
181 while (key_pressed(1) == 1);
194 joy.calib_data.x1 = joy.raw_x;
195 joy.calib_data.y1 = joy.raw_y;
198 joy.calib_data.x3 = joy.raw_x;
199 joy.calib_data.y3 = joy.raw_y;
202 joy.calib_data.x2 = joy.raw_x;
203 joy.calib_data.y2 = joy.raw_y;
207 while (joy.but1 == 1) {
209 joy.but1 = (((s1 >> 4) & 1) ^ 1);
219 int init_mouse(int *_num_buttons)
222 int mouse_enabled, num_mouse_buttons;
225 __dpmi_int(0x33, ®s);
226 if (regs.x.ax == 0xffff) {
228 num_mouse_buttons = regs.x.bx;
230 num_mouse_buttons = 2;
232 num_mouse_buttons = 3;
237 _num_buttons = num_mouse_buttons;
239 return mouse_enabled;
243 void read_mouse(void)
247 __dpmi_int(0x33, ®s);
248 mouse.but1 = regs.x.bx & 1;
249 mouse.but2 = (regs.x.bx & 2) >> 1;
250 mouse.but3 = (regs.x.bx & 4) >> 2;
255 void update_player_actions(void)
257 if (main_info.mouse_enabled == 1)
259 if (main_info.joy_enabled == 1)
261 player[0].action_left = key_pressed(KEY_PL1_LEFT) == 1;
262 player[0].action_right = key_pressed(KEY_PL1_RIGHT) == 1;
263 player[0].action_up = key_pressed(KEY_PL1_JUMP) == 1;
264 player[1].action_left = key_pressed(KEY_PL2_LEFT) == 1;
265 player[1].action_right = key_pressed(KEY_PL2_RIGHT) == 1;
266 player[1].action_up = key_pressed(KEY_PL2_JUMP) == 1;
267 player[2].action_left = key_pressed(KEY_PL3_LEFT) == 1;
268 player[2].action_right = key_pressed(KEY_PL3_RIGHT) == 1;
269 player[2].action_up = key_pressed(KEY_PL3_JUMP) == 1;
270 player[3].action_left = key_pressed(KEY_PL4_LEFT) == 1;
271 player[3].action_right = key_pressed(KEY_PL4_RIGHT) == 1;
272 player[3].action_up = key_pressed(KEY_PL4_JUMP) == 1;
276 void init_inputs(void)
278 main_info.mouse_enabled = init_mouse(&num_mouse_buttons);
279 main_info.joy_enabled = init_joy(&num_mouse_buttons);