English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General > Coders. Releases

 
 
Thread Tools
Old 23 October 2012, 09:01   #101
Asman
68k
 
Asman's Avatar
 
Join Date: Sep 2005
Location: Somewhere
Posts: 828
Quote:
That can't be right, 300ms = 15 PAL frames!
Thank you.

Quote:
It is bit 6+8=14 that is checked. btst that accesses memory is always byte wide.
If I see 6 that think about 6

Quote:
It advances CD32 pad's shift register by one so that next button can be read.
Thank you

Quote:
Where did FFFF POTGO write originate? Lowlevel.library or some other routine?
For sure I saw that in ReadJoyPad. As I checked Lowlevel.library yesterday then I think I do not saw $ffff - but for sure I will check. Furthermore I do not checked how works WritePotgo ( potgo.resource ) and I assume that is simple write to POTGO with value and mask and I'm not sure if START (bit 0 ) is set or not.
Asman is offline  
Old 23 October 2012, 15:01   #102
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,521
Quote:
Originally Posted by Toni Wilen View Post
Output mode: Write FF00 once (or multiple times, it does not matter), read normally, anytime.
But I guess I need the input mode to read the 2nd button?
When will you need output mode? To clock a CD32 game controller perhaps?

Quote:
Input mode using method in linked example:
There was no linked example. Or do you mean asman's source?

Quote:
in vblank, set 2nd button to input mode by writing to POTGO, read normally, write FF01 (or FFFF) to POTGO. (I am still not sure whats the point of this extra complexity. I guess I must be missing something.)
Perhaps to achieve a pullup effect when pin 9 is not connected?

Now I'm doing this at the beginning of each frame:
Code:
POTGO = $7700 (pin 5 and pin 9 to input)
Read POTGOR (bit 14 is button 2 of the second controller)
POTGO = $ff01 (all pins output again, recharge capacitors?)
This seems to work on a real A1200, but E-UAE is going crazy now. In all odd frames bit 14 is cleared and in the even frames it is set, although nobody touches the button!
phx is offline  
Old 23 October 2012, 15:32   #103
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,542
Quote:
Originally Posted by phx View Post
But I guess I need the input mode to read the 2nd button?
When will you need output mode? To clock a CD32 game controller perhaps?
Output mode is the official way to read buttons which works with or without pullups. (It does not damage the hardware or something, it is designed that way)

Check HRM, "Digital I/O on the controller port", second to last chapter that begins with "These lines can also be used for button inputs".

Quote:
There was no linked example. Or do you mean asman's source?
Yes

Not surprising that older UAE versions get confused, emulation was originally made to emulate "standard" usage, it didn't emulate hardware behavior.
Toni Wilen is offline  
Old 23 October 2012, 16:22   #104
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,521
Quote:
Originally Posted by Toni Wilen View Post
Output mode is the official way to read buttons which works with or without pullups. (It does not damage the hardware or something, it is designed that way)
Right. That would be my favourite solution. Unfortunately a tester wrote that the 2nd button didn't work any longer, when setting POTGO to all outputs.

But wait, I wrote $ffff, not $ff00. Should that make a difference?
phx is offline  
Old 23 October 2012, 16:37   #105
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,542
Quote:
Originally Posted by phx View Post
Right. That would be my favourite solution. Unfortunately a tester wrote that the 2nd button didn't work any longer, when setting POTGO to all outputs.

But wait, I wrote $ffff, not $ff00. Should that make a difference?
It most likely does if written every frame.

Quote:
read in some book about 300 miliseconds
HRM says 300 microseconds which is only few scan lines.
Toni Wilen is offline  
Old 23 October 2012, 20:21   #106
Asman
68k
 
Asman's Avatar
 
Join Date: Sep 2005
Location: Somewhere
Posts: 828
Quote:
Originally Posted by phx View Post
Right. That would be my favourite solution. Unfortunately a tester wrote that the 2nd button didn't work any longer, when setting POTGO to all outputs.

But wait, I wrote $ffff, not $ff00. Should that make a difference?
You are 100% sure that tester has 100% working controller/pad ? In other games ( like The Lost Vikings CD32 version - but not WHDLoad ) controller works ok ?
Asman is offline  
Old 24 October 2012, 09:41   #107
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,521
Of course I'm not 100% sure about that tester. But I have seen the problems myself, last evening, while testing on my A3000.

In my case it works for several seconds and then fails for several seconds again. The state often flips between working (2nd button is recognized) and non-working (2nd button is ignored) after I used a different direction.

Although, in the absence of a joypad, I used a mouse for testing the 2nd button.

This is hopeless.
phx is offline  
Old 24 October 2012, 11:00   #108
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,542
Just confirming: you do have OS completely disabled? OS vblank routine may write to POTGO.

What kind of mouse? Commodore original or some 3rd party (with possible Amiga/Atari switch). 3rd party mice generally have pullup resistors in button lines, Commodore mice don't.
Toni Wilen is offline  
Old 24 October 2012, 11:33   #109
Asman
68k
 
Asman's Avatar
 
Join Date: Sep 2005
Location: Somewhere
Posts: 828
@phx
Can you sent source or program to test it on my machine ( I should have cd32 pad ). Then I will test it this evening.

Information: potgo.resource. As I understand correctly WritePotgo function disable ints before write POTGO. but I think that disabling/enabling ints is not necessary if you disabled OS.
Asman is offline  
Old 24 October 2012, 13:02   #110
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,521
Quote:
Originally Posted by Toni Wilen View Post
Just confirming: you do have OS completely disabled? OS vblank routine may write to POTGO.
Yes. Everything disabled.

Quote:
What kind of mouse? Commodore original or some 3rd party (with possible Amiga/Atari switch). 3rd party mice generally have pullup resistors in button lines, Commodore mice don't.
It's an original Commodore mouse. One of the later models. Similar to this one, but the buttons have equal size:
http://www.the-liberator.net/site-fi...-044-Mouse.JPG

I wonder why the 2nd mouse button is always working fine on the first port...
phx is offline  
Old 24 October 2012, 13:15   #111
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,521
Quote:
Originally Posted by Asman View Post
@phx
Can you sent source or program to test it on my machine ( I should have cd32 pad ). Then I will test it this evening.
Unfortunately I can only publish parts of the source, which I have written from scratch. I am not allowed to publish my 68k port of the original game engine in C. This is closed source.

My joystick routine, current state. Does work on UAE. Does not work on a tester's A1200. Does work on a tester's A2000. Does work sometimes on my A3000. Called every frame:
Code:
*
* Input devices
*
* initControllers()
* d0=status = readController(d0=port)
*

        include "custom.i"

CIAA_PRA        equ     $bfe001



        near    a4

        code


;---------------------------------------------------------------------------
        xdef    initControllers
initControllers:
; Initialize joystick/joypad controllers.
; Set all POTGO lines to output and pull them up to logical 1. This makes
; sure the 2nd button signal is stable, even when no joypad is connected.

        move.w  #$ff00,POTGO(a6)
        rts


;---------------------------------------------------------------------------
        xdef    readController
readController:
; Read joystick button and directions for port d0.
; Left is -1, right is 1. Up is -1, down is 1.
; d0 = port (0 or 1)
; -> d0.l = button.b << 24 | updown.b << 16 | leftright.b

;       move.w  #$7700,POTGO(a6)
        move.w  #$ff00,POTGO(a6)
        move.l  d2,a0
        tst.b   d0
        bne     .2

        ; port 0, check button
        moveq   #0,d0
        btst    #2,POTGOR(a6)
        seq     d0              ; 2nd button is 'up' in Sqrxz
        btst    #6,CIAA_PRA
        bne     .1
        or.w    #$ff00,d0
.1:     move.w  JOY0DAT(a6),d1
        bra     .4

        ; port 1, check button
.2:     moveq   #0,d0
        btst    #6,POTGOR(a6)
        seq     d0              ; 2nd button is 'up' in Sqrxz
        btst    #7,CIAA_PRA
        bne     .3
        or.w    #$ff00,d0
.3:     move.w  JOY1DAT(a6),d1

.4:     move.w  d1,d2
        lsr.w   #1,d2
        eor.w   d1,d2
;       tst.b   d0
;       bne     .6              ; do not check up/down, when 2nd button pressed

        and.b   #$01,d2
        beq     .5
        addq.b  #1,d0           ; down
        bra     .6
.5:     and.w   #$0100,d2
        beq     .6
        subq.b  #1,d0           ; up

.6:     swap    d0

        and.b   #$02,d1
        beq     .7
        addq.b  #1,d0           ; right
        bra     .8
.7:     and.w   #$0200,d1
        beq     .8
        subq.b  #1,d0           ; left

.8:     move.l  a0,d2
;       move.w  #$ff01,POTGO(a6)
        rts
And here is the current Sqrxz V1.2beta binary for testing:
http://www.hasenbraten.de/~frank/sqrxz_2ndbutton.lha

Quote:
Information: potgo.resource. As I understand correctly WritePotgo function disable ints before write POTGO. but I think that disabling/enabling ints is not necessary if you disabled OS.
Exactly.
phx is offline  
Old 24 October 2012, 16:46   #112
Asman
68k
 
Asman's Avatar
 
Join Date: Sep 2005
Location: Somewhere
Posts: 828
@phx

Thank you for source I will do tests today evening on my A1200. For sure I will change move.w #$ff00,POTGO(a6) in begin of readController into move.w #$6600,POTGO(a6) and on end of this routine I will uncomment move.w #$ff01,POTGO(a6).
Asman is offline  
Old 24 October 2012, 16:53   #113
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,542
Quote:
Originally Posted by Asman View Post
@phx

Thank you for source I will do tests today evening on my A1200. For sure I will change move.w #$ff00,POTGO(a6) in begin of readController into move.w #$6600,POTGO(a6) and on end of this routine I will uncomment move.w #$ff01,POTGO(a6).
Note that CD32 pad does have pullups. Make also sure it works with mouse right button (if you have original Commodore mouse), only this test guarantees it works with every pad type!
Toni Wilen is offline  
Old 24 October 2012, 16:57   #114
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,521
Quote:
Originally Posted by Asman View Post
For sure I will change move.w #$ff00,POTGO(a6) in begin of readController into move.w #$6600,POTGO(a6) and on end of this routine I will uncomment move.w #$ff01,POTGO(a6).
This was the version which confused UAE. It will oscillate between button pressed/released.
phx is offline  
Old 25 October 2012, 14:58   #115
Asman
68k
 
Asman's Avatar
 
Join Date: Sep 2005
Location: Somewhere
Posts: 828
Quote:
Originally Posted by Toni Wilen View Post
Note that CD32 pad does have pullups. Make also sure it works with mouse right button (if you have original Commodore mouse), only this test guarantees it works with every pad type!
Hi Toni,

I checked my source code with A1200 mouse ( mouse looks like phx mouse ). And I don't have good news. Left mouse button is ok. By when I pressed right mouse button then my code detect also left mouse (same behaviour on my A1200 and on WinUAE 2.4) - I do not check if other bits were set, I just check if bit for LMB (bit $17 in d0 as result of my routine ) is set and check if bit for RMB ($16) is set.
When I commented block of code with reading CD32 buttons then mouse works nice on A1200 and on WinUAE 2.4.
So I checked how worsk lowlevel.library and .... ReadJoyPort works fine for mouse. I spent some time to figure out ( after some debugging without success I read lowlevel.library autodocs ) that ReadJoyPort routine sense what kind of controller is attached ( but I still don't know where is recognization of controller type). And then it (ReadJoyPort) works like my routine with commented block of code of cd32 pad. But when I call SetJoyPortAttrsA with SJA_Type == SJA_TYPE_GAMECTLR then lowlevel.library (ReadJoyPort call) behave like my original routine (uncommented block of code of cd32 buttons), mean when RMB is pressed then LMB is also pressed.

I checked phx code and it works fine on WinUAE 2.4, today I will check with cd32 pad on my A1200.

I still don't understand why both mouse button were detected, because my routine checks pins: 5 and 9. Why pin 6 was detected ??? Perhaps my code has some error.

Regards

Last edited by Asman; 25 October 2012 at 15:06. Reason: added some explanation
Asman is offline  
Old 25 October 2012, 22:47   #116
Asman
68k
 
Asman's Avatar
 
Join Date: Sep 2005
Location: Somewhere
Posts: 828
@phx

I checked your routine (with commented section about joystick direction ) with cd32 pad and mouse and works fine ( with or without writting to the potgo) on my A1200.

I must recheck my routine, because I'm not sure if works as I expect.
Asman is offline  
Old 26 October 2012, 10:35   #117
Leffmann
 
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
What I do is write $FF00 to POTGO and %11 to CIAADDRA once for the remainder of the program. I can then read the primary buttons on both ports of course, and the secondary buttons on both ports on a 1D4 A1200, a very early A500, and a late A500 from 1992 (in case the motherboard revision has an effect on these things).

I've only tried this with a 2-button mouse, a regular 1-button joystick and the CD32 joypad though, and I have no controller that connects middle mouse-button or third fire-button on pin 5 to test with.
Leffmann is offline  
Old 26 October 2012, 11:06   #118
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,542
Quote:
Originally Posted by Leffmann View Post
What I do is write $FF00 to POTGO and %11 to CIAADDRA once for the remainder of the program. I can then read the primary buttons on both ports of course, and the secondary buttons on both ports on a 1D4 A1200, a very early A500, and a late A500 from 1992 (in case the motherboard revision has an effect on these things).

I've only tried this with a 2-button mouse, a regular 1-button joystick and the CD32 joypad though, and I have no controller that connects middle mouse-button or third fire-button on pin 5 to test with.
Yeah, this is the easiest and also method documented in HRM. Only if you need to read all CD32 pad buttons you need more complex routine (that can break this method if you aren't careful with IO pin direction and side-effects caused by POT capacitors)
Toni Wilen is offline  
Old 26 October 2012, 11:08   #119
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,521
Even if it works for you, both variants (also Asman's test) already failed on some Amigas, so I cannot rely on them. Maybe this POTGO pullup effect depends on good capacitors, and some Amigas have aged ones...?

Setting CIAADDRA to $03 is the default, so I don't think it is required to write that explicitely?
phx is offline  
Old 26 October 2012, 11:13   #120
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,542
Quote:
Originally Posted by phx View Post
Even if it works for you, both variants (also Asman's test) already failed on some Amigas, so I cannot rely on them. Maybe this POTGO pullup effect depends on good capacitors, and some Amigas have aged ones...?

Setting CIAADDRA to $03 is the default, so I don't think it is required to write that explicitely?
AOS uses exact same method to read right and middle mouse button (pin direction=output). Something else must be broken.
Toni Wilen 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
Sqrxz 2 for AmigaOCS vitux Amiga scene 11 25 November 2013 02:21
WTB: Plastic Dust Cover for Amiga 500 & Amiga 600 S0nic MarketPlace 0 14 February 2013 16:41
Compatibility with Amiga 500 and 500+ games ErickDF Amiga scene 2 23 May 2008 20:16
WTB: Amiga 600, 500, 500 +, 1200 (NTSC) JeremyDay MarketPlace 2 30 November 2006 03:27
Will the Amiga 500 or Amiga 1000 run workbench 2? anim8 support.Hardware 12 18 August 2001 05:02

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 18:49.

Top

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