8 ====================================================
10 Doom control structure
12 The keybaord and joystick will add to the values set by the cyberman,
13 to a maximum of 0x19000 for forwardmove and sidemove. Angleturn is
18 forwardmove 0xc800 0x19000
19 sidemove 0xc000 0x14000
20 angleturn 0x2800000 0x5000000
22 The keyboard and joystick have a 1/3 second slow turn of 0x1400000 under
23 normal speed to help aiming.
27 ====================================================
32 char forwardmove; // *2048 for move
33 char sidemove; // *2048 for move
34 short angleturn; // <<16 for angle delta
35 short consistancy; // checks for net game
36 unsigned char chatchar;
37 unsigned char buttons;
42 #define BT_CHANGE 4 // if true, the next 3 bits hold weapon num
43 #define BT_WEAPONMASK (8+16+32)
44 #define BT_WEAPONSHIFT 3
48 //==================================================
50 // CyberMan detection and usage info
52 //==================================================
54 #define MOUSE_INT 0x33
56 #define DOSMEMSIZE 64 // enough for any SWIFT structure
68 // DPMI real mode interrupt structure
69 static struct rminfo {
73 long reserved_by_system;
79 short ES,DS,FS,GS,IP,CS,SP,SS;
83 unsigned char deviceType;
84 unsigned char majorVersion;
85 unsigned char minorVersion;
86 unsigned char absRelFlags;
87 unsigned char centeringFlags;
88 unsigned char reserved[5];
91 // values for deviceType:
92 #define DEVTYPE_CYBERMAN 1
95 unsigned short segment; // segment of DOS memory block
96 SWIFT_3DStatus *cyberstat;
97 int isCyberPresent; // is CyberMan present?
100 static union REGS regs;
101 static struct SREGS sregs;
104 extern int mousepresent;
106 //===========================================================
110 // If a cyberman is present, init it and set isCyberPresent to 1
111 //===========================================================
112 void I_StartupCyberMan(void)
114 StaticDeviceData *pbuf;
119 cyberstat = (SWIFT_3DStatus *)I_AllocLow (DOSMEMSIZE);
120 segment = (int)cyberstat>>4;
122 pbuf = (StaticDeviceData *)cyberstat;
123 memset(pbuf, 0, sizeof (StaticDeviceData));
125 // Use DPMI call 300h to issue mouse interrupt
126 memset(&RMI, 0, sizeof(RMI));
127 RMI.EAX = 0x53C1; // SWIFT: Get Static Device Data
130 memset(&sregs, 0, sizeof (sregs));
131 regs.w.ax = 0x0300; // DPMI: simulate interrupt
132 regs.w.bx = MOUSE_INT;
134 regs.x.edi = FP_OFF(&RMI);
135 sregs.es = FP_SEG(&RMI);
136 int386x( DPMI_INT, ®s, ®s, &sregs );
138 if ((short)RMI.EAX != 1)
140 // SWIFT functions not present
141 tprintf("CyberMan: Wrong mouse driver - no SWIFT support (AX=%04x).\n",
142 (unsigned)(short)RMI.EAX);
145 if (pbuf->deviceType != DEVTYPE_CYBERMAN)
147 // no SWIFT device, or not CyberMan
148 if (pbuf->deviceType == 0)
150 tprintf("CyberMan: no SWIFT device connected.\n");
154 tprintf("CyberMan: SWIFT device is not a CyberMan! (type=%d)\n",
160 tprintf("CyberMan: CyberMan %d.%02d connected.\n",
161 pbuf->majorVersion, pbuf->minorVersion);
180 void I_ReadCyberCmd (ticcmd_t *cmd)
184 // Use DPMI call 300h to issue mouse interrupt
185 memset(&RMI, 0, sizeof(RMI));
186 RMI.EAX = 0x5301; // SWIFT: Get Position and Buttons
189 memset(&sregs, 0, sizeof (sregs));
190 regs.w.ax = 0x0300; // DPMI: simulate interrupt
191 regs.w.bx = MOUSE_INT;
193 regs.x.edi = FP_OFF(&RMI);
194 sregs.es = FP_SEG(&RMI);
195 int386x( DPMI_INT, ®s, ®s, &sregs );
197 if (cyberstat->y < -7900)
198 cmd->forwardmove = 0xc800/2048;
199 else if (cyberstat->y > 7900)
200 cmd->forwardmove = -0xc800/2048;
202 if (cyberstat->buttons & 4)
203 cmd->buttons |= BT_ATTACK;
204 if (cyberstat->buttons & 2)
205 cmd->buttons |= BT_USE;
207 delta = cyberstat->x - oldpos;
208 oldpos = cyberstat->x;
210 if (cyberstat->buttons & 1)
212 if (cyberstat->x < -7900)
213 cmd->sidemove = -0xc800/2048;
214 else if (cyberstat->x > 7900)
215 cmd->sidemove = 0xc800/2048;
217 cmd->sidemove = delta*40/2048;
221 if (cyberstat->x < -7900)
222 cmd->angleturn = 0x280;
223 else if (cyberstat->x > 7900)
224 cmd->angleturn = -0x280;
226 cmd->angleturn = -delta*0xa/16;
233 void I_Tactile (int on, int off, int total)
248 memset(&RMI, 0, sizeof(RMI));
249 RMI.EAX = 0x5330; // SWIFT: Get Position and Buttons
250 RMI.EBX = on*256+off;
252 memset(&sregs, 0, sizeof (sregs));
253 regs.w.ax = 0x0300; // DPMI: simulate interrupt
254 regs.w.bx = MOUSE_INT;
256 regs.x.edi = FP_OFF(&RMI);
257 sregs.es = FP_SEG(&RMI);
258 int386x( DPMI_INT, ®s, ®s, &sregs );