ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/adb.cpp
(Generate patch)

Comparing BasiliskII/src/adb.cpp (file contents):
Revision 1.6 by cebix, 2001-07-03T15:59:45Z vs.
Revision 1.12 by cebix, 2004-01-12T15:29:21Z

# Line 1 | Line 1
1   /*
2   *  adb.cpp - ADB emulation (mouse/keyboard)
3   *
4 < *  Basilisk II (C) 1997-2001 Christian Bauer
4 > *  Basilisk II (C) 1997-2004 Christian Bauer
5   *
6   *  This program is free software; you can redistribute it and/or modify
7   *  it under the terms of the GNU General Public License as published by
# Line 28 | Line 28
28  
29   #include "sysdeps.h"
30   #include "cpu_emulation.h"
31 #include "main.h"
31   #include "emul_op.h"
32 + #include "main.h"
33 + #include "prefs.h"
34   #include "video.h"
35   #include "adb.h"
36  
# Line 57 | Line 58 | static uint8 mouse_reg_3[2] = {0x63, 0x0
58   static uint8 key_reg_2[2] = {0xff, 0xff};       // Keyboard ADB register 2
59   static uint8 key_reg_3[2] = {0x62, 0x05};       // Keyboard ADB register 3
60  
61 < // ADB mouse input state lock (for platforms that use separate input thread)
61 > static uint8 m_keyboard_type = 0x05;
62 >
63 > // ADB mouse motion lock (for platforms that use separate input thread)
64   static B2_mutex *mouse_lock;
65  
66  
# Line 68 | Line 71 | static B2_mutex *mouse_lock;
71   void ADBInit(void)
72   {
73          mouse_lock = B2_create_mutex();
74 +        m_keyboard_type = (uint8)PrefsFindInt32("keyboardtype");
75 +        key_reg_3[1] = m_keyboard_type;
76   }
77  
78  
# Line 99 | Line 104 | void ADBOp(uint8 op, uint8 *data)
104                  key_reg_2[0] = 0xff;
105                  key_reg_2[1] = 0xff;
106                  key_reg_3[0] = 0x62;
107 <                key_reg_3[1] = 0x05;
107 >                key_reg_3[1] = m_keyboard_type;
108                  return;
109          }
110  
# Line 231 | Line 236 | void ADBMouseMoved(int x, int y)
236                  mouse_x = x; mouse_y = y;
237          }
238          B2_unlock_mutex(mouse_lock);
239 +        SetInterruptFlag(INTFLAG_ADB);
240 +        TriggerInterrupt();
241   }
242  
243  
# Line 240 | Line 247 | void ADBMouseMoved(int x, int y)
247  
248   void ADBMouseDown(int button)
249   {
243        B2_lock_mutex(mouse_lock);
250          mouse_button[button] = true;
251 <        B2_unlock_mutex(mouse_lock);
251 >        SetInterruptFlag(INTFLAG_ADB);
252 >        TriggerInterrupt();
253   }
254  
255  
256   /*
257 < *  First mouse button released
257 > *  Mouse button released
258   */
259  
260   void ADBMouseUp(int button)
261   {
255        B2_lock_mutex(mouse_lock);
262          mouse_button[button] = false;
263 <        B2_unlock_mutex(mouse_lock);
263 >        SetInterruptFlag(INTFLAG_ADB);
264 >        TriggerInterrupt();
265   }
266  
267  
# Line 264 | Line 271 | void ADBMouseUp(int button)
271  
272   void ADBSetRelMouseMode(bool relative)
273   {
274 <        relative_mouse = relative;
274 >        if (relative_mouse != relative) {
275 >                relative_mouse = relative;
276 >                mouse_x = mouse_y = 0;
277 >        }
278   }
279  
280  
# Line 280 | Line 290 | void ADBKeyDown(int code)
290  
291          // Set key in matrix
292          key_states[code >> 3] |= (1 << (~code & 7));
293 +
294 +        // Trigger interrupt
295 +        SetInterruptFlag(INTFLAG_ADB);
296 +        TriggerInterrupt();
297   }
298  
299  
# Line 295 | Line 309 | void ADBKeyUp(int code)
309  
310          // Clear key in matrix
311          key_states[code >> 3] &= ~(1 << (~code & 7));
312 +
313 +        // Trigger interrupt
314 +        SetInterruptFlag(INTFLAG_ADB);
315 +        TriggerInterrupt();
316   }
317  
318  
# Line 360 | Line 378 | void ADBInterrupt(void)
378                  if (mx != old_mouse_x || my != old_mouse_y) {
379   #ifdef POWERPC_ROM
380                          static const uint16 proc[] = {
381 <                                0x2f08,         // move.l a0,-(sp)
382 <                                0x2f00,         // move.l d0,-(sp)
383 <                                0x2f01,         // move.l d1,-(sp)
384 <                                0x7001,         // moveq #1,d0 (MoveTo)
385 <                                0xaadb,         // CursorDeviceDispatch
386 <                                M68K_RTS
381 >                                PW(0x2f08),             // move.l a0,-(sp)
382 >                                PW(0x2f00),             // move.l d0,-(sp)
383 >                                PW(0x2f01),             // move.l d1,-(sp)
384 >                                PW(0x7001),             // moveq #1,d0 (MoveTo)
385 >                                PW(0xaadb),             // CursorDeviceDispatch
386 >                                PW(M68K_RTS)
387                          };
388                          r.a[0] = ReadMacInt32(mouse_base + 4);
389                          r.d[0] = mx;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines