Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential Hyperkin mouse read errors with FastROM #287

Open
undisbeliever opened this issue Jun 14, 2024 · 3 comments · Fixed by #291
Open

Potential Hyperkin mouse read errors with FastROM #287

undisbeliever opened this issue Jun 14, 2024 · 3 comments · Fixed by #291

Comments

@undisbeliever
Copy link
Contributor

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.

@danboid
Copy link

danboid commented Jun 14, 2024

Following.

@undisbeliever
Copy link
Contributor Author

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

@NovaSquirrel
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants