English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Asm / Hardware

 
 
Thread Tools
Old 12 June 2019, 20:52   #1
dissident
Registered User
 
Join Date: Sep 2015
Location: Germany
Posts: 260
Right mouse button check

Hi,

something trivial but actually I'm confrontated with a behaviour of the Paula hardware I don't understand.

I wrote a routine which is nested in memory and survives a reset via the CoolCapture-Vector of the Exec-Base. The interrupts or DMA are untouched by my routine.

In this routine I check if the right mouse button was pressed during the reset like this:

Code:
...
btst   #2,$dff016   ;Check for the DATLY-bit (Paula Pin 36) of the POTINP-register
beq.s  rmb_pressed    ;If bit2 of the upper byte=low then button is pressed
...
On different machines like an A1200/030, an A1200/060 and an A4000/060 this method was successful.

But on the config A4000 CS Mk II 060, Picasso IV my test failed. Everytime the button was not pressed, the DATLY bit of POTINP was low.

I read a little bit in the HRM an found the part DIGITAL I/O ON THE CONTROLLER PORT with this passage:

Quote:
If you set the output enable for any pin to a 1, the Amiga disconnects the potentiometer control circuitry from the port, and configures the pin for output. The state of the data bit controls the logic level on the output pin. This register must be written to at the POTGO address, and read from the POTGOR address. There are large capacitors on these lines, and it can take up to 300 microseconds for the line to change state. To use the entire register as an input, sensing the current state of the pot pins, write all 0s to POTGO. Thereafter you can read the current state by using read-only address POTGOR. Note that bits set as inputs will be connected to the proportional counters (See the description of the START bit in POTGO). These lines can also be used for button inputs. A button is a normally open switch that shorts to ground. The Amiga must provide a pull-up resistance on the sense pin. To do this, set the proper pin to output, and drive the line high (set both OUT... and DAT... to 1). Reading POTGOR will produce a 0 if the button is pressed, a 1 if it is not.
So does this mean I have to set bits OUTLY (11) AND DATLY (10) of the POTGO register before I check the right mousebutton? Is it necessary to wait 300 us after I wrote to the POTGO register if I want to check the state of the DATLY bit of POTINP?

Maybe someone can enlighten me.

Last edited by dissident; 12 June 2019 at 21:27.
dissident is offline  
Old 12 June 2019, 21:32   #2
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,519
This is not the first time this topic has been discussed here but here is quick reply:

First the standard reply:

KS ROM sets mouse port data direction=output automatically because with standard mice and input mode would cause stuck button read after first press (button pressed = shorted to ground, button release = floating, there is nothing to recharge the POT capacitor after release). BUT there are 3rd party mice (usually they have Amiga/ST switch) that have pullup resistors in button lines and they work without output mode.

Joystick port is not set to output mode by default if KS 2.0+ (but KS 1.x does).

Check that you didn't accidentally clear data direction/data bits and/or check type of your mouse by measuring resistance between button pin and gnd and +5v.

Non-standard bonus reply:

in your case reset may change register contents (I am not sure if POTGO gets reset) but if it does, you need to set it correctly and wait a bit before checking button state. It is also possible CSMK SCSI boot rom or Picasso IV boot rom pokes POTGO. (Perhaps they have "do/don't do something if right button is pressed" early boot checks?). I am also quite sure KS resets it early before it gets initialized (when input.device starts?)

2nd/3rd button handling is always tricky because as long as POT capacitor is charged, button press can work once even if POTGO is "incorrectly" configured.
Toni Wilen is online now  
Old 14 June 2019, 22:49   #3
dissident
Registered User
 
Join Date: Sep 2015
Location: Germany
Posts: 260
Quote:
Originally Posted by Toni Wilen View Post
This is not the first time this topic has been discussed here but here is quick reply:

First the standard reply:

KS ROM sets mouse port data direction=output automatically because with standard mice and input mode would cause stuck button read after first press (button pressed = shorted to ground, button release = floating, there is nothing to recharge the POT capacitor after release). BUT there are 3rd party mice (usually they have Amiga/ST switch) that have pullup resistors in button lines and they work without output mode.

Joystick port is not set to output mode by default if KS 2.0+ (but KS 1.x does).

Check that you didn't accidentally clear data direction/data bits and/or check type of your mouse by measuring resistance between button pin and gnd and +5v.

Non-standard bonus reply:

in your case reset may change register contents (I am not sure if POTGO gets reset) but if it does, you need to set it correctly and wait a bit before checking button state. It is also possible CSMK SCSI boot rom or Picasso IV boot rom pokes POTGO. (Perhaps they have "do/don't do something if right button is pressed" early boot checks?). I am also quite sure KS resets it early before it gets initialized (when input.device starts?)

2nd/3rd button handling is always tricky because as long as POT capacitor is charged, button press can work once even if POTGO is "incorrectly" configured.

Hi Toni, many thanks for your very detailed reply. It's always a pleasure discussing about hardware details with you. This is the background information I needed and it confirms my theory.

I changed my routine and set POTGO to the OS standard value $0F00 so that DATLX (middle mousebutton) & DATLY (right mousebutton) have the data direction out and are set to high. Then I wait 5 rasterlines (about 320 us). This delay could be also done via the CIA timers. After that I check the right mouse button. That's all. Now tested successfully on the config A4000 CS Mk II 060, Picasso IV + Commodore 327124-15 mouse.

Here's the code:

Code:
  MOVE.L  #$DFF000,A5
  MOVE.W  #%0000111100000000,$34(A5) ;POTGO Set standard OS value

  MOVEQ   #5-1,D2            ;Wait 5 rasterlines (~320 µs)
  MOVE.L  #$0001FF00,D3      ;Mask for vertical beam position V0-V8
wait_loop1
  MOVE.W  6(A5),D0           ;Get VHPOSR content
  SWAP    D0                 ;Move content to the upper word
  MOVE.W  4(A5),D0           ;Get VPOSR content
  AND.L   D3,D0              ;Only bits V0-V8
wait_loop2
  MOVE.W  6(A5),D1           ;Get VHPOSR content
  SWAP    D1                 ;Move content to the upper word
  MOVE.W  4(A5),D1           ;Get VPOSR content
  AND.L   D3,D1              ;Only bits V0-V8
  CMP.L   D1,D0              ;Still the same vertical position?
  BEQ.S   wait_loop2         ;Yes -> loop
  dbf     d2,wait_loop1

  BTST    #2,$16(A5)         ;POTINP Test bit 2 for the right mouse button
  BEQ.S   RMB_pressed        ;If low then branch
dissident is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
A1200 mouse movement issues - check my working out SpocksBeer support.Hardware 5 02 September 2023 19:38
A2000 left mouse button use in workbench causes mouse to stop responding. gary_nz support.Hardware 5 17 September 2017 10:03
A600 right mouse button not working protek support.Hardware 48 18 March 2013 14:57
Right mouse button not working? NovaCoder project.ClassicWB 3 09 May 2011 06:26
Problem right mouse button 3dfx4ever support.Hardware 3 17 February 2011 08:33

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 21:06.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.25577 seconds with 15 queries