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 |
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 |
|
|
37 |
+ |
#ifdef POWERPC_ROM |
38 |
+ |
#include "thunks.h" |
39 |
+ |
#endif |
40 |
+ |
|
41 |
|
#define DEBUG 0 |
42 |
|
#include "debug.h" |
43 |
|
|
62 |
|
static uint8 key_reg_2[2] = {0xff, 0xff}; // Keyboard ADB register 2 |
63 |
|
static uint8 key_reg_3[2] = {0x62, 0x05}; // Keyboard ADB register 3 |
64 |
|
|
65 |
+ |
static uint8 m_keyboard_type = 0x05; |
66 |
+ |
|
67 |
|
// ADB mouse motion lock (for platforms that use separate input thread) |
68 |
|
static B2_mutex *mouse_lock; |
69 |
|
|
75 |
|
void ADBInit(void) |
76 |
|
{ |
77 |
|
mouse_lock = B2_create_mutex(); |
78 |
+ |
m_keyboard_type = (uint8)PrefsFindInt32("keyboardtype"); |
79 |
+ |
key_reg_3[1] = m_keyboard_type; |
80 |
|
} |
81 |
|
|
82 |
|
|
108 |
|
key_reg_2[0] = 0xff; |
109 |
|
key_reg_2[1] = 0xff; |
110 |
|
key_reg_3[0] = 0x62; |
111 |
< |
key_reg_3[1] = 0x05; |
111 |
> |
key_reg_3[1] = m_keyboard_type; |
112 |
|
return; |
113 |
|
} |
114 |
|
|
381 |
|
// Update mouse position (absolute) |
382 |
|
if (mx != old_mouse_x || my != old_mouse_y) { |
383 |
|
#ifdef POWERPC_ROM |
384 |
< |
static const uint16 proc[] = { |
385 |
< |
0x2f08, // move.l a0,-(sp) |
386 |
< |
0x2f00, // move.l d0,-(sp) |
387 |
< |
0x2f01, // move.l d1,-(sp) |
388 |
< |
0x7001, // moveq #1,d0 (MoveTo) |
389 |
< |
0xaadb, // CursorDeviceDispatch |
390 |
< |
M68K_RTS |
384 |
> |
static const uint8 proc_template[] = { |
385 |
> |
0x2f, 0x08, // move.l a0,-(sp) |
386 |
> |
0x2f, 0x00, // move.l d0,-(sp) |
387 |
> |
0x2f, 0x01, // move.l d1,-(sp) |
388 |
> |
0x70, 0x01, // moveq #1,d0 (MoveTo) |
389 |
> |
0xaa, 0xdb, // CursorDeviceDispatch |
390 |
> |
M68K_RTS >> 8, M68K_RTS |
391 |
|
}; |
392 |
+ |
BUILD_SHEEPSHAVER_PROCEDURE(proc); |
393 |
|
r.a[0] = ReadMacInt32(mouse_base + 4); |
394 |
|
r.d[0] = mx; |
395 |
|
r.d[1] = my; |
396 |
< |
Execute68k((uint32)proc, &r); |
396 |
> |
Execute68k(proc, &r); |
397 |
|
#else |
398 |
|
WriteMacInt16(0x82a, mx); |
399 |
|
WriteMacInt16(0x828, my); |