English Amiga Board


Go Back   English Amiga Board > Support > support.Hardware

 
 
Thread Tools
Old 04 February 2024, 20:56   #61
ross
Defendit numerus
 
ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,476
New version (a consistent, usable, one) attached.

This time also the source:
Code:
joyread
; input, mandatory:
;  POTGO = #$FF00, CIAA PRA = #%11xxxxxx, CIAA DDRA = #%00xxxxxx
;  usually CIA bit are right (any KS sets it this way for various reasons)
;  but POTGO is a job for your main code
;  if you take over the system you can do it once during setup
;  at routine exit the regs are at the right state, no need for a setup
; output: d0.w (Port 0), d1.w (Port 1)  = Joystick/Gamepad/CD32pad status
;  bits: 0000rlduBRYGFWPm (logic: 1=open/non-pressed, 0=closed/pressed)
;   r=right, l=left, d=down, u=up, B=blue/fire2, R=red/fire1, Y=yellow/fire3
;   CD32pad only: G=green button, F=FFW, W=RWD, P=play/pause; else #%1111
;   m=mode (0=Joystick/Gamepad, 1=CD32pad)

    movem.l d2-d7,-(sp)
    lea $bfe001,a0
    lea $dff00a,a1

    moveq   #$3f,d6             ; main idea is to sync inputs at best
    move.w  (a1)+,d2            ; read Port0 stick/pad directions
    move.w  (a1)+,d3            ; read Port1 stick/pad directions
    addq.l  #8,a1
    move.w  (a1),d7             ; read 2nd/3rd button (both stick)
    move.b  (a0),d7             ; read 1st button (both stick)
    and.b   d6,(a0)             ; prepare 0 in latch (for output mode)
    move.w  #$6600,($34-$16,a1) ; freeze 74165 state (CD32pad buttons)
    ori.b   #$c0,($200,a0)      ; [1/2] prepare clock from '?' to low

    ; offline code (all data is already available/in frozen state here) 
    bsr.b   .parse_dpad         ; convert hw to bit-flags (Port0)
    move.w  d1,d0
    move.w  d3,d2
    bsr.b   .parse_dpad         ; (Port1)

    moveq   #6,d2
    moveq   #10,d3              ; 10-8
    moveq   #9-1,d4
    bsr.b   .dread_pbut

    move.b  d1,d0
    moveq   #7,d2
    moveq   #14,d3              ; 14-8
    moveq   #9-1,d4
    bsr.b   .fread_pbut

    and.b   d6,($200,a0)        ; both first buttons in input mode
    move.w  #$ff00,($34-$16,a1) ; rest
    movem.l (sp)+,d2-d7
    rts

.parse_dpad                     ; of course table bit could be adapted
;   move.w  (a1)+,d1
    ror.b   #2,d2
    lsr.w   #5,d2
    and.w   #%11110,d2
    move.w  .dir_tab(pc,d2.w),d1
    rts

;   moveq   #9-1,d4
.nextbit
    bclr    d2,(a0)     ; [1/2] pulse, CLK in low state
.dread_pbut             ; start (Port0), skip 2E thanks to DDRA setup
    tst.b   (a0)        ; [3] ~1.4us
    tst.b   (a0)        ; [4]
    tst.b   (a0)        ; [5]
    tst.b   (a0)        ; [6]
    tst.b   (a0)        ; [7]
    tst.b   (a0)        ; [8]
    tst.b   (a0)        ; [9]
    tst.b   (a0)        ; [10] ~14us min. (capacitors)
.fread_pbut             ; accelerated start (Port1), long time pre-set
    btst    d3,(a1)
    sne     d5          ; collect bit

    bset    d2,(a0)     ; CLK rising edge, next serial bit
    add.b   d5,d5
    addx.b  d1,d1       ; fills the buffer
    dbra    d4,.nextbit

    move.b  d1,d5       ; full flag byte in Joystick mode (2nd button)
    roxr.b  #1,d1       ; first bit (now in X) is blue button
    eor.b   d1,d5       ; trick for stick/pad recognition (10 prot.)
    bne.b   .bx         ; stick?

.firebs_trick           ; a/b optimization, -6c -6b from my routine :)
    btst    d3,d7
    sne     d4
    add.w   d4,d4       ;  a aaaaaaa0
    btst    d2,d7
    sne     d4
    add.w   d4,d4       ; ab bbbbbbb0
    subq.w  #2,d3
    btst    d3,d7
    sne     d4          ; ab cccccccc
    lsr.w   #2,d4       ; abcccccc
    or.b    #$1f,d4     ; abc11111
    or.b    d6,d1       ; ??111111
    add.b   d1,d1       ; ?1111110
    and.b   d4,d1       ; abc11110
.bx rts
 
.dir_tab
    dc.w    %111100000000,%110100000000,%010100000000,%011100000000
    dc.w    %111000000000,%110100000000,%010100000000,%011000000000
    dc.w    %101000000000,%100100000000,%010100000000,%011000000000
    dc.w    %101100000000,%100100000000,%010100000000,%011100000000
Thanks to all testers (Lamaman71, fgh, paraj and who I forgot), Jope, a/b for a nice optimization and Toni for tests and hw hints

Of course this does not mean that the tests and suggestions must end, on the contrary!
Attached Files
File Type: 68k joytest1.5.68k (788 Bytes, 16 views)

Last edited by ross; 04 February 2024 at 23:51. Reason: re-pasted the code, the indentations looked wrong..
ross is offline  
Old 05 February 2024, 14:13   #62
a/b
Registered User
 
Join Date: Jun 2016
Location: europe
Posts: 1,039

Still haven't received my payment, though. Next time please use a fishing boat across the Adriatic, that's the fastest and safest way these days (you even get a governmental protection).
a/b is online now  
Old 05 February 2024, 14:28   #63
ross
Defendit numerus
 
ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,476
Quote:
Originally Posted by a/b View Post

Still haven't received my payment, though. Next time please use a fishing boat across the Adriatic, that's the fastest and safest way these days (you even get a governmental protection).
I take my beautiful yellow dinghy out of the garage, wait for me on the other side, I'll be there soon
ross is offline  
Old 05 February 2024, 15:30   #64
hooverphonique
ex. demoscener "Bigmama"
 
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,624
Quote:
Originally Posted by a/b View Post

Still haven't received my payment, though. Next time please use a fishing boat across the Adriatic, that's the fastest and safest way these days (you even get a governmental protection).
In the case of Ross, you need to wait for him at the brink of the Rubicon, however
hooverphonique is offline  
Old 05 February 2024, 22:40   #65
Muzza
Registered User
 
Muzza's Avatar
 
Join Date: Sep 2019
Location: Sydney
Posts: 357
ross, I put your code in T2AGA and it appears to have solved the OPs problem. Great work!
Muzza is offline  
Old 06 February 2024, 08:49   #66
ross
Defendit numerus
 
ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,476
Quote:
Originally Posted by Muzza View Post
ross, I put your code in T2AGA and it appears to have solved the OPs problem. Great work!
I'm glad to hear it.

ross is offline  
Old 06 February 2024, 15:15   #67
Lamaman71
Registered User
 
Join Date: Sep 2021
Location: Katy, USA
Posts: 154
So just a quick update - I'm currently testing out Ross' code on Muzza's T2 remake - its all seems to work really well on my "difficult" A4000. It also works reliably on my "not difficult" CD32.

This is amazing work all around - the unfortunate side effect is I lost my A4000 to my 10 year old who is now overjoyed to be playing Turrican 2 on a "proper" gamepad again. Kids eh?

I would add that my A4000 is a delicate flower and does seem to be super sensitive to those ports. I put a short, straight through 9pin male to female extension to save wear on the ports while I was testing and it did not like that AT ALL! Even with Ross' code the CD32 pad would not work in any way reliably. Took it out and all was well again. The extender works on a regular amiga, I use them all the time.

So, I aim to test again tonight to be extra sure before I get back to Muzza with a final thumbs up - from my end at least - but to all intents and purposes it looks like you lot have solved the mystery One day it would be good to understand the hardware inconsistency though - CIA's perhaps?
Lamaman71 is offline  
Old 06 February 2024, 15:44   #68
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,215
adding an extension adds noise/delay, it's never good and can break some hardware that is sensitive. I had a HDMI cable that worked only if plugged directly on my PC. Failed if plugged on a hub...
jotd is offline  
Old 06 February 2024, 16:02   #69
ross
Defendit numerus
 
ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,476
I would add that I have positive reports on on-the-fly insertion / port swap between Joystick and/or CD32pad.
There may be a very brief moment before complete insertion in which the hw is undecided between the two types of devices (with the test program you notice a brief flash between cyan and beige on the recognition bit, but then it immediately becomes steady stable and right).
But it does not cause anything serious, or require special user code handling, since it shares the return bits.

Even Gamepads with 3 buttons don't seem to have any problems.
What worried me the most was the second button with its 3 recognition possibilities, but I have no negative reports yet.
ross is offline  
Old 10 February 2024, 13:37   #70
Lamaman71
Registered User
 
Join Date: Sep 2021
Location: Katy, USA
Posts: 154
Well, been using the new code on Turrican 2 AGA for about a week - no issues at all, all the buttons work just fine without any issues. Awesome work by all involved.
Lamaman71 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
Simon CD32 on a 2x cd Amiga 4000 haymigga support.Games 7 23 October 2022 17:41
Amiga CD32 joypad lambrettadave support.Hardware 12 06 August 2022 03:47
Amiga cd32 joypad triggers 3d model moulder625 support.Hardware 0 13 June 2022 22:46
Joypad that's 100% compatible with CD32 Joypad? ancalimon Retrogaming General Discussion 26 15 September 2015 08:49
Selling: Prototype CD32 adapter / Amiga 4000 broken gehtjanx MarketPlace 10 26 July 2011 10:20

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 12:40.

Top

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