MEGA65 / mega65-rom-public

MEGA65 ROM public issue reporting
4 stars 0 forks source link

MOUSE port "3" #122

Open dansanderson opened 4 months ago

dansanderson commented 4 months ago

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 commented 4 months ago

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 commented 1 month ago

JOY(3) implemented: https://github.com/MEGA65/mega65-rom/commit/70e3a9bb0b39c426b66b3eeda262cb61c10944c3

dansanderson commented 1 month ago

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 commented 1 month ago

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.