alekmaul/pvsneslib

Potential Hyperkin mouse read errors with FastROM

Opened this issue · 3 comments

The SNESdev wiki states the Hyperkin mouse requires at least 170 master cycles between $4017/$4018 reads (Source).

I manually m-cycle counted the _MouseData read-loop with the aid of Nova's SNES instruction speed compare tool

  • Read loop is: lda REG_JOYA,x ; lsr ; rol mouse_x,x ; rol mouse_y,x ; dey ; bne @_m30
  • SlowROM: 36 + 14 + 52 + 52 + 14 + 22 = 190 (should work)
  • FastROM: 30 + 12 + 46 + 46 + 12 + 18 = 164 (too short)

I'll fix the FastROM read-loop over the weekend but I will need to find and coordinate with someone who owns a hyperkin mouse to verify the fix works.

I also do not know if a Hyperkin mouse is compatible with how the new VBlank ISR handles lag frames. So I will need to test that as well.

Following.

I've coded a fix with the necessary delay to the mouse read loop in commit 8bb8ac8

I've also written a test ROM that displays the mouse state. To prevent lag it only reads the mouse from port 2. The test also includes a button to deliberately lag the test when the B button on controller port 1 is held.

We will need to find someone with a Hyperkin mouse to test it. They should test the 3 speed settings (set by pressing Y, X or A with controller 1) and test mouse movement with lag (hold B on controller 1 while moving the mouse).

Test ROM source code: https://gist.github.com/undisbeliever/fa6d1b0407a64556cb400250eb10646e
mouse-data-test.zip

I tested this with an FXPak Pro and the Hyperkin mouse and I was able to move the cursor around and detect button presses just fine, with or without the B button pressed. The Hyperkin mouse ignores attempts to change the speed, which is a known thing, but I was able to change the speed and move the cursor similarly on a Nintendo branded mouse.