8 #include "st_start.h" // For ST_Message()
12 unsigned char *I_AllocLow (int length);
16 ====================================================
18 Doom control structure
20 The keybaord and joystick will add to the values set by the cyberman,
21 to a maximum of 0x19000 for forwardmove and sidemove. Angleturn is
26 forwardmove 0xc800 0x19000
27 sidemove 0xc000 0x14000
28 angleturn 0x2800000 0x5000000
30 The keyboard and joystick have a 1/3 second slow turn of 0x1400000 under
31 normal speed to help aiming.
35 ====================================================
40 char forwardmove; // *2048 for move
41 char sidemove; // *2048 for move
42 short angleturn; // <<16 for angle delta
43 short consistancy; // checks for net game
44 unsigned char chatchar;
45 unsigned char buttons;
48 // ticcmd_t as it appears in h2def.h
55 unsigned char chatchar;
56 unsigned char buttons;
57 unsigned char lookfly;
64 #define BT_CHANGE 4 // if true, the next 3 bits hold weapon num
65 #define BT_WEAPONMASK (8+16+32)
66 #define BT_WEAPONSHIFT 3
68 //==================================================
70 // CyberMan detection and usage info
72 //==================================================
74 #define MOUSE_INT 0x33
76 #define DOSMEMSIZE 64 // enough for any SWIFT structure
88 // DPMI real mode interrupt structure
90 static struct rminfo {
94 long reserved_by_system;
100 short ES,DS,FS,GS,IP,CS,SP,SS;
104 unsigned char deviceType;
105 unsigned char majorVersion;
106 unsigned char minorVersion;
107 unsigned char absRelFlags;
108 unsigned char centeringFlags;
109 unsigned char reserved[5];
112 // values for deviceType:
113 #define DEVTYPE_CYBERMAN 1
116 unsigned short segment; // segment of DOS memory block
117 SWIFT_3DStatus *cyberstat;
118 int isCyberPresent; // is CyberMan present?
122 static union REGS regs;
123 static struct SREGS sregs;
127 extern int mousepresent;
129 //===========================================================
133 // If a cyberman is present, init it and set isCyberPresent to 1
134 //===========================================================
135 void I_StartupCyberMan(void)
140 StaticDeviceData *pbuf;
142 ST_Message(" CyberMan: ");
145 cyberstat = (SWIFT_3DStatus *)I_AllocLow (DOSMEMSIZE);
146 segment = (int)cyberstat>>4;
148 pbuf = (StaticDeviceData *)cyberstat;
149 memset(pbuf, 0, sizeof (StaticDeviceData));
152 // Use DPMI call 300h to issue mouse interrupt
153 memset(&RMI, 0, sizeof(RMI));
154 RMI.EAX = 0x53C1; // SWIFT: Get Static Device Data
157 memset(&sregs, 0, sizeof (sregs));
158 regs.w.ax = 0x0300; // DPMI: simulate interrupt
159 regs.w.bx = MOUSE_INT;
161 regs.x.edi = FP_OFF(&RMI);
162 sregs.es = FP_SEG(&RMI);
163 int386x( DPMI_INT, ®s, ®s, &sregs );
165 if ((short)RMI.EAX != 1)
167 // SWIFT functions not present
168 ST_Message("Wrong mouse driver - no SWIFT support (AX=%04x).\n",
169 (unsigned)(short)RMI.EAX);
171 else if (pbuf->deviceType != DEVTYPE_CYBERMAN)
173 // no SWIFT device, or not CyberMan
174 if (pbuf->deviceType == 0)
176 ST_Message("no SWIFT device connected.\n");
180 ST_Message("SWIFT device is not a CyberMan! (type=%d)\n",
186 ST_Message("CyberMan %d.%02d connected.\n",
187 pbuf->majorVersion, pbuf->minorVersion);
207 void I_ReadCyberCmd (ticcmd_t *cmd)
214 // Use DPMI call 300h to issue mouse interrupt
215 memset(&RMI, 0, sizeof(RMI));
216 RMI.EAX = 0x5301; // SWIFT: Get Position and Buttons
219 memset(&sregs, 0, sizeof (sregs));
220 regs.w.ax = 0x0300; // DPMI: simulate interrupt
221 regs.w.bx = MOUSE_INT;
223 regs.x.edi = FP_OFF(&RMI);
224 sregs.es = FP_SEG(&RMI);
225 int386x( DPMI_INT, ®s, ®s, &sregs );
227 if (cyberstat->y < -7900)
228 cmd->forwardmove = 0xc800/2048;
229 else if (cyberstat->y > 7900)
230 cmd->forwardmove = -0xc800/2048;
232 if (cyberstat->buttons & 4)
233 cmd->buttons |= BT_ATTACK;
234 if (cyberstat->buttons & 2)
235 cmd->buttons |= BT_USE;
237 delta = cyberstat->x - oldpos;
238 oldpos = cyberstat->x;
240 if (cyberstat->buttons & 1)
242 if (cyberstat->x < -7900)
243 cmd->sidemove = -0xc800/2048;
244 else if (cyberstat->x > 7900)
245 cmd->sidemove = 0xc800/2048;
247 cmd->sidemove = delta*40/2048;
251 if (cyberstat->x < -7900)
252 cmd->angleturn = 0x280;
253 else if (cyberstat->x > 7900)
254 cmd->angleturn = -0x280;
256 cmd->angleturn = -delta*0xa/16;
264 void I_Tactile (int on, int off, int total)
282 memset(&RMI, 0, sizeof(RMI));
283 RMI.EAX = 0x5330; // SWIFT: Get Position and Buttons
284 RMI.EBX = on*256+off;
286 memset(&sregs, 0, sizeof (sregs));
287 regs.w.ax = 0x0300; // DPMI: simulate interrupt
288 regs.w.bx = MOUSE_INT;
290 regs.x.edi = FP_OFF(&RMI);
291 sregs.es = FP_SEG(&RMI);
292 int386x( DPMI_INT, ®s, ®s, &sregs );