--- BasiliskII/src/adb.cpp 1999/10/03 14:16:25 1.1 +++ BasiliskII/src/adb.cpp 2001/02/02 20:52:56 1.5 @@ -1,7 +1,7 @@ /* * adb.cpp - ADB emulation (mouse/keyboard) * - * Basilisk II (C) 1997-1999 Christian Bauer + * Basilisk II (C) 1997-2001 Christian Bauer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -29,6 +29,7 @@ #include "sysdeps.h" #include "cpu_emulation.h" #include "main.h" +#include "emul_op.h" #include "video.h" #include "adb.h" @@ -192,7 +193,7 @@ void ADBOp(uint8 op, uint8 *data) /* - * Mouse was moved (x/y are absolute or relative, depending on ADBSetMouseMode()) + * Mouse was moved (x/y are absolute or relative, depending on ADBSetRelMouseMode()) */ void ADBMouseMoved(int x, int y) @@ -283,25 +284,26 @@ void ADBInterrupt(void) int mx = mouse_x; int my = mouse_y; + uint32 key_base = adb_base + 4; + uint32 mouse_base = adb_base + 16; + if (relative_mouse) { // Mouse movement (relative) and buttons if (mx != 0 || my != 0 || mouse_button[0] != old_mouse_button[0] || mouse_button[1] != old_mouse_button[1] || mouse_button[2] != old_mouse_button[2]) { - uint32 mouse_base = adb_base + 16; - uint8 *mouse_data = Mac2HostAddr(tmp_data); // Call mouse ADB handler if (mouse_reg_3[1] == 4) { // Extended mouse protocol - mouse_data[0] = 3; - mouse_data[1] = (my & 0x7f) | (mouse_button[0] ? 0 : 0x80); - mouse_data[2] = (mx & 0x7f) | (mouse_button[1] ? 0 : 0x80); - mouse_data[3] = ((my >> 3) & 0x70) | ((mx >> 7) & 0x07) | (mouse_button[2] ? 0x08 : 0x88); + WriteMacInt8(tmp_data, 3); + WriteMacInt8(tmp_data + 1, (my & 0x7f) | (mouse_button[0] ? 0 : 0x80)); + WriteMacInt8(tmp_data + 2, (mx & 0x7f) | (mouse_button[1] ? 0 : 0x80)); + WriteMacInt8(tmp_data + 3, ((my >> 3) & 0x70) | ((mx >> 7) & 0x07) | (mouse_button[2] ? 0x08 : 0x88)); } else { // 100/200 dpi mode - mouse_data[0] = 2; - mouse_data[1] = (my & 0x7f) | (mouse_button[0] ? 0 : 0x80); - mouse_data[2] = (mx & 0x7f) | (mouse_button[1] ? 0 : 0x80); + WriteMacInt8(tmp_data, 2); + WriteMacInt8(tmp_data + 1, (my & 0x7f) | (mouse_button[0] ? 0 : 0x80)); + WriteMacInt8(tmp_data + 2, (mx & 0x7f) | (mouse_button[1] ? 0 : 0x80)); } r.a[0] = tmp_data; r.a[1] = ReadMacInt32(mouse_base); @@ -320,11 +322,26 @@ void ADBInterrupt(void) // Update mouse position (absolute) if (mx != old_mouse_x || my != old_mouse_y) { +#ifdef POWERPC_ROM + static const uint16 proc[] = { + 0x2f08, // move.l a0,-(sp) + 0x2f00, // move.l d0,-(sp) + 0x2f01, // move.l d1,-(sp) + 0x7001, // moveq #1,d0 (MoveTo) + 0xaadb, // CursorDeviceDispatch + M68K_RTS + }; + r.a[0] = ReadMacInt32(mouse_base + 4); + r.d[0] = mx; + r.d[1] = my; + Execute68k((uint32)proc, &r); +#else WriteMacInt16(0x82a, mx); WriteMacInt16(0x828, my); WriteMacInt16(0x82e, mx); WriteMacInt16(0x82c, my); WriteMacInt8(0x8ce, ReadMacInt8(0x8cf)); // CrsrCouple -> CrsrNew +#endif old_mouse_x = mx; old_mouse_y = my; } @@ -332,20 +349,19 @@ void ADBInterrupt(void) // Send mouse button events if (mouse_button[0] != old_mouse_button[0]) { uint32 mouse_base = adb_base + 16; - uint8 *mouse_data = Mac2HostAddr(tmp_data); // Call mouse ADB handler if (mouse_reg_3[1] == 4) { // Extended mouse protocol - mouse_data[0] = 3; - mouse_data[1] = mouse_button[0] ? 0 : 0x80; - mouse_data[2] = mouse_button[1] ? 0 : 0x80; - mouse_data[3] = mouse_button[2] ? 0x08 : 0x88; + WriteMacInt8(tmp_data, 3); + WriteMacInt8(tmp_data + 1, mouse_button[0] ? 0 : 0x80); + WriteMacInt8(tmp_data + 2, mouse_button[1] ? 0 : 0x80); + WriteMacInt8(tmp_data + 3, mouse_button[2] ? 0x08 : 0x88); } else { // 100/200 dpi mode - mouse_data[0] = 2; - mouse_data[1] = mouse_button[0] ? 0 : 0x80; - mouse_data[2] = mouse_button[1] ? 0 : 0x80; + WriteMacInt8(tmp_data, 2); + WriteMacInt8(tmp_data + 1, mouse_button[0] ? 0 : 0x80); + WriteMacInt8(tmp_data + 2, mouse_button[1] ? 0 : 0x80); } r.a[0] = tmp_data; r.a[1] = ReadMacInt32(mouse_base); @@ -361,8 +377,6 @@ void ADBInterrupt(void) } // Process accumulated keyboard events - uint32 key_base = adb_base + 4; - uint8 *key_data = Mac2HostAddr(tmp_data); while (key_read_ptr != key_write_ptr) { // Read keyboard event @@ -370,9 +384,9 @@ void ADBInterrupt(void) key_read_ptr = (key_read_ptr + 1) % KEY_BUFFER_SIZE; // Call keyboard ADB handler - key_data[0] = 2; - key_data[1] = mac_code; - key_data[2] = mac_code == 0x7f ? 0x7f : 0xff; // Power key is special + WriteMacInt8(tmp_data, 2); + WriteMacInt8(tmp_data + 1, mac_code); + WriteMacInt8(tmp_data + 2, mac_code == 0x7f ? 0x7f : 0xff); // Power key is special r.a[0] = tmp_data; r.a[1] = ReadMacInt32(key_base); r.a[2] = ReadMacInt32(key_base + 4);