3 * Copyright (C) 1998 Brainchild Design - http://brainchilddesign.com/
5 * Copyright (C) 2002 Florian Schulze - crow@icculus.org
7 * Portions of this code are from the MPEG software simulation group
8 * idct implementation. This code will be replaced with a new
11 * This file is part of Jump'n'Bump.
13 * Jump'n'Bump is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * Jump'n'Bump is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 static int num_mouse_buttons;
38 if ((inportb(0x201) & 1) == 0)
56 c1 = x = y = flag = 0;
86 if (joy.raw_x < joy.calib_data.x2)
87 joy.x = ((long) (joy.raw_x - joy.calib_data.x2) << 10) / (joy.calib_data.x2 - joy.calib_data.x1);
89 joy.x = ((long) (joy.raw_x - joy.calib_data.x2) << 10) / (joy.calib_data.x3 - joy.calib_data.x2);
90 if (joy.raw_y < joy.calib_data.y2)
91 joy.y = ((long) (joy.raw_y - joy.calib_data.y2) << 10) / (joy.calib_data.y2 - joy.calib_data.y1);
93 joy.y = ((long) (joy.raw_y - joy.calib_data.y2) << 10) / (joy.calib_data.y3 - joy.calib_data.y2);
105 joy.but1 = (((s1 >> 4) & 1) ^ 1);
106 joy.but2 = (((s1 >> 5) & 1) ^ 1);
108 joy.raw_x = joy.calib_data.x2;
109 joy.raw_y = joy.calib_data.y2;
113 joy.but1 = joy.but2 = 0;
119 int calib_joy(int type)
127 while (joy.but1 == 1) {
129 joy.but1 = (((s1 >> 4) & 1) ^ 1);
130 if (key_pressed(1) == 1) {
131 while (key_pressed(1) == 1);
138 while (joy.but1 == 0) {
140 c1 = x = y = flag = 0;
155 if (x != 0 && y != 0)
170 joy.but1 = (((s1 >> 4) & 1) ^ 1);
172 if (num_times < 0x7fffffff)
178 if (key_pressed(1) == 1) {
179 while (key_pressed(1) == 1);
192 joy.calib_data.x1 = joy.raw_x;
193 joy.calib_data.y1 = joy.raw_y;
196 joy.calib_data.x3 = joy.raw_x;
197 joy.calib_data.y3 = joy.raw_y;
200 joy.calib_data.x2 = joy.raw_x;
201 joy.calib_data.y2 = joy.raw_y;
205 while (joy.but1 == 1) {
207 joy.but1 = (((s1 >> 4) & 1) ^ 1);
217 int init_mouse(int *_num_buttons)
220 int mouse_enabled, num_mouse_buttons;
223 __dpmi_int(0x33, ®s);
224 if (regs.x.ax == 0xffff) {
226 num_mouse_buttons = regs.x.bx;
228 num_mouse_buttons = 2;
230 num_mouse_buttons = 3;
235 _num_buttons = num_mouse_buttons;
237 return mouse_enabled;
241 void read_mouse(void)
245 __dpmi_int(0x33, ®s);
246 mouse.but1 = regs.x.bx & 1;
247 mouse.but2 = (regs.x.bx & 2) >> 1;
248 mouse.but3 = (regs.x.bx & 4) >> 2;
253 void update_player_actions(void)
255 if (main_info.mouse_enabled == 1)
257 if (main_info.joy_enabled == 1)
259 player[0].action_left = key_pressed(KEY_PL1_LEFT) == 1;
260 player[0].action_right = key_pressed(KEY_PL1_RIGHT) == 1;
261 player[0].action_up = key_pressed(KEY_PL1_JUMP) == 1;
262 player[1].action_left = key_pressed(KEY_PL2_LEFT) == 1;
263 player[1].action_right = key_pressed(KEY_PL2_RIGHT) == 1;
264 player[1].action_up = key_pressed(KEY_PL2_JUMP) == 1;
265 player[2].action_left = key_pressed(KEY_PL3_LEFT) == 1;
266 player[2].action_right = key_pressed(KEY_PL3_RIGHT) == 1;
267 player[2].action_up = key_pressed(KEY_PL3_JUMP) == 1;
268 player[3].action_left = key_pressed(KEY_PL4_LEFT) == 1;
269 player[3].action_right = key_pressed(KEY_PL4_RIGHT) == 1;
270 player[3].action_up = key_pressed(KEY_PL4_JUMP) == 1;
274 void init_inputs(void)
276 main_info.mouse_enabled = init_mouse(&num_mouse_buttons);
277 main_info.joy_enabled = init_joy(&num_mouse_buttons);