3 * Copyright (C) 1998 Brainchild Design - http://brainchilddesign.com/
5 * Copyright (C) 2002 Florian Schulze - crow@icculus.org
7 * This file is part of Jump'n'Bump.
9 * Jump'n'Bump is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * Jump'n'Bump is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 static int num_mouse_buttons;
34 if ((inportb(0x201) & 1) == 0)
52 c1 = x = y = flag = 0;
82 if (joy.raw_x < joy.calib_data.x2)
83 joy.x = ((long) (joy.raw_x - joy.calib_data.x2) << 10) / (joy.calib_data.x2 - joy.calib_data.x1);
85 joy.x = ((long) (joy.raw_x - joy.calib_data.x2) << 10) / (joy.calib_data.x3 - joy.calib_data.x2);
86 if (joy.raw_y < joy.calib_data.y2)
87 joy.y = ((long) (joy.raw_y - joy.calib_data.y2) << 10) / (joy.calib_data.y2 - joy.calib_data.y1);
89 joy.y = ((long) (joy.raw_y - joy.calib_data.y2) << 10) / (joy.calib_data.y3 - joy.calib_data.y2);
101 joy.but1 = (((s1 >> 4) & 1) ^ 1);
102 joy.but2 = (((s1 >> 5) & 1) ^ 1);
104 joy.raw_x = joy.calib_data.x2;
105 joy.raw_y = joy.calib_data.y2;
109 joy.but1 = joy.but2 = 0;
115 int calib_joy(int type)
123 while (joy.but1 == 1) {
125 joy.but1 = (((s1 >> 4) & 1) ^ 1);
126 if (key_pressed(1) == 1) {
127 while (key_pressed(1) == 1);
134 while (joy.but1 == 0) {
136 c1 = x = y = flag = 0;
151 if (x != 0 && y != 0)
166 joy.but1 = (((s1 >> 4) & 1) ^ 1);
168 if (num_times < 0x7fffffff)
174 if (key_pressed(1) == 1) {
175 while (key_pressed(1) == 1);
188 joy.calib_data.x1 = joy.raw_x;
189 joy.calib_data.y1 = joy.raw_y;
192 joy.calib_data.x3 = joy.raw_x;
193 joy.calib_data.y3 = joy.raw_y;
196 joy.calib_data.x2 = joy.raw_x;
197 joy.calib_data.y2 = joy.raw_y;
201 while (joy.but1 == 1) {
203 joy.but1 = (((s1 >> 4) & 1) ^ 1);
213 int init_mouse(int *_num_buttons)
216 int mouse_enabled, num_mouse_buttons;
219 __dpmi_int(0x33, ®s);
220 if (regs.x.ax == 0xffff) {
222 num_mouse_buttons = regs.x.bx;
224 num_mouse_buttons = 2;
226 num_mouse_buttons = 3;
231 _num_buttons = num_mouse_buttons;
233 return mouse_enabled;
237 void read_mouse(void)
241 __dpmi_int(0x33, ®s);
242 mouse.but1 = regs.x.bx & 1;
243 mouse.but2 = (regs.x.bx & 2) >> 1;
244 mouse.but3 = (regs.x.bx & 4) >> 2;
249 void update_player_actions(void)
251 if (main_info.mouse_enabled == 1)
253 if (main_info.joy_enabled == 1)
255 player[0].action_left = key_pressed(KEY_PL1_LEFT) == 1;
256 player[0].action_right = key_pressed(KEY_PL1_RIGHT) == 1;
257 player[0].action_up = key_pressed(KEY_PL1_JUMP) == 1;
258 player[1].action_left = key_pressed(KEY_PL2_LEFT) == 1;
259 player[1].action_right = key_pressed(KEY_PL2_RIGHT) == 1;
260 player[1].action_up = key_pressed(KEY_PL2_JUMP) == 1;
261 player[2].action_left = key_pressed(KEY_PL3_LEFT) == 1;
262 player[2].action_right = key_pressed(KEY_PL3_RIGHT) == 1;
263 player[2].action_up = key_pressed(KEY_PL3_JUMP) == 1;
264 player[3].action_left = key_pressed(KEY_PL4_LEFT) == 1;
265 player[3].action_right = key_pressed(KEY_PL4_RIGHT) == 1;
266 player[3].action_up = key_pressed(KEY_PL4_JUMP) == 1;
270 void init_inputs(void)
272 main_info.mouse_enabled = init_mouse(&num_mouse_buttons);
273 main_info.joy_enabled = init_joy(&num_mouse_buttons);