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

MOUSE port "3" #122

Open
dansanderson opened this issue Feb 24, 2024 · 5 comments
Open

MOUSE port "3" #122

dansanderson opened this issue Feb 24, 2024 · 5 comments
Labels
enhancement New feature or request

Comments

@dansanderson
Copy link
Collaborator

The original C65 design doc proposed that the MOUSE command could accept a port value of "3" meaning "try to read a mouse from both ports." This was never implemented, so this is a feature request to consider adding it.

The pot lines give a movement delta, so we can imagine that a full implementation would be to read both sets of pot lines, sum the deltas, and logical-or the button states. In practice, this would allow for a single mouse to be read from either port, so the user doesn't have to switch ports.

(Aside: There currently is no accommodation for connecting two mice to separate BASIC-managed pointers. There is only ever one active mouse pointer.)

@dansanderson dansanderson added the new New report, not classified yet label Feb 24, 2024
@dansanderson
Copy link
Collaborator Author

We might as well support JOY(3) while we're at it, with similar functionality: perform a logical OR of ports 1 and 2, and translate the result to the direction table and button bit.

@dansanderson dansanderson added enhancement New feature or request and removed new New report, not classified yet labels Feb 25, 2024
@dansanderson
Copy link
Collaborator Author

@dansanderson
Copy link
Collaborator Author

A combined MOUSE port "3" would need to take the form of enhancing system.src:mouse_irq to detect when mouse_enable bits 7 and 6 are both set, then perform the 1.6ms movement delta check for each port, one at a time. As written, this merely sets DC00 bits 7 and 6 per mouse_enable to select which joystick port is connected to the SID ADC, and it cannot connect both ports simultaneously. The positional delta is reported by the mouse on POTX/POTY at a steady rate, and the read routine must test the register values twice after a brief delay, then add the delta to the mouse position. Enabling port "3" would require two delays. I doubt this would be a problem but we'll have to try it to find out.

As far as I can tell no other changes will be needed. I just need to take a deep breath and refactor mouse_irq. 😅

@dansanderson
Copy link
Collaborator Author

A quick attempt to pull the meat of the routine into a subroutine and call it once for each set bit of 7 and 6 didn't quite work out, in ways I don't have time to look into right now. Port 1 worked fine, port 2 stuck to the top of the screen, port "3" could see movement but was adding arbitrary values to the mouse position. It's acting as if something needs to get reset between the two checks but I haven't figured out what yet.

I'm going to set this aside for now. Someone else can take a crack at it if they feel like it.

@gurcei
Copy link
Collaborator

gurcei commented Sep 24, 2024

For me, I'm not super-enthusiastic to work on getting MOUSE "3" support working, but will copy/paste some thoughts that came out of this discord thread:

https://discord.com/channels/719326990221574164/781481205639020554/1287949293071761512

So my suggestion for anyone considering this is, let's leave the vhdl behaviour as-is, and if anyone is enthusiastic to get MOUSE "3" working, they can instead try to update the logic inside mouse_irq: to access the potx/y lines the new mega65 way (via c65uart io registers), and not the old CIA way:
image

I.e., read both pairs of potx/y signals via these new mega65 io registers (from $D620 to $D623):
image

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

No branches or pull requests

2 participants