An issue came up in the Plutiedev discord with the mouse. He took out the mouse support, but accidentally left the mouse support activated. When you activate the mouse or the tap and there isn't one plugged in, the current code has to timeout before it returns, which wastes a LOT of time. The very first nibble of the header is made while the device is deactivated, so a quick check should be made for the first value of the mouse and tap as an early out to get around the timeout. Something like this
Code: Select all
/* make sure port is deselected to start at first phase */
pb = (vu8 *)0xa10003 + port*2;
*pb = 0x60;
asm volatile ("nop");
asm volatile ("nop");
/* quick check for at least initial mouse/tap value to cut the amount
* of time spent if a mouse/tap isn't really plugged in, but the game
* still activates the support
*/
i = *pb & 0x0F;
if ((i != 0) && (i != 3))
return -1;
hdr[0] = THREELINE_HANDSHAKE(pb, 0x60);
That should return almost instantly if the mouse or tap isn't plugged in. If keyboard support is ever added, it should also check for 1, the first nibble of the keyboard header.