Analog controller for MD

For hardware talk only (please avoid ROM dumper stuff)
Post Reply
TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Analog controller for MD

Post by TmEE co.(TM) » Sat May 19, 2007 7:51 pm

Yesterday I started to build an adaptor which lets you use PC 4-button gamepads that plug into gameport with MD. Here's the adaptor :
Image
Sorry for the low quality, my scanner is broken, and that "digicam" is without zoom and only 1.3MP :/

It is not compatible with standard control pads, but I thought it is nice for homebrew games...

Schematic (scanner broke, no schematic drawing software):
Image
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

KanedaFr
Administrateur
Posts: 1139
Joined: Tue Aug 29, 2006 10:56 am
Contact:

Post by KanedaFr » Mon May 21, 2007 12:36 pm

oh cool!!!
It's something I tried to do ;)

even if I'm more after the MD->USB pad ;)

TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Mon May 21, 2007 2:44 pm

Are you willing to emulate it in Kmod ?

I'm not familiar with USB, but I believe it is not too hard to get USB pad working with MD, maybe a PIC(don't have experience with these either) ?

I used standard 4-button PC gameport gamepad as I know exactly how these work and I've built several for myself, and I was bored and thought that maybe I could hook up one to my MD :wink:
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Mon May 21, 2007 3:04 pm

one thing I forgot, the source code :wink:

Code: Select all

DetectAnalog1:          ; Detects the presence of analog controller
 JSR    WaitOneFrame    ; Wait a little (poll may have been in progress)
 MOVE.B ($A10003), D0
 AND.B  #3, D0          ; First step: axe bits must be unset
 BEQ    NextAnalogStep1
 CLR.L  D0
 RTS
NextAnalogStep1:
 MOVE.B #$40, ($A10003) ; Next step: pulse TH so timers start and axe
 NOP    #4              ; bits are set
 MOVE.B #$00, ($A10003)
 MOVE.W #31, D0
AnalogInitLoop1:
 DBRA   D0, AnalogInitLoop1
 MOVE.B ($A10003), D0
 AND.B  #3, D0          ; Bits must be set now
 BNE    WeHaveAnalog1
 CLR.L  D0
 RTS
WeHaveAnalog1:
 MOVEQ  #1, D0
 RTS

DetectAnalog2:          ; Detects the presence of analog controller
 JSR    WaitOneFrame    ; Wait a little (poll may have been in progress)
 MOVE.B ($A10005), D0
 AND.B  #3, D0          ; First step: axe bits must be unset
 BEQ    NextAnalogStep2
 CLR.L  D0
 RTS
NextAnalogStep2:
 MOVE.B #$40, ($A10005) ; Next step: pulse TH so timers start and axe
 NOP    #4              ; bits are set
 MOVE.B #$00, ($A10005)
 MOVE.W #31, D0
AnalogInitLoop2:
 DBRA   D0, AnalogInitLoop2
 MOVE.B ($A10005), D0
 AND.B  #3, D0          ; Bits must be set now
 BNE    WeHaveAnalog2
 CLR.L  D0
 RTS
WeHaveAnalog2:
 MOVEQ  #1, D0
 RTS

ReadAnalog1:            ; Reads analog gamepad button and axe status
 CLR.W  D1              ; X counter
 CLR.W  D2              ; Y counter
 MOVE.B #$40, ($A10003)
 NOP    #4
 MOVE.B #$00, ($A10003)
 MOVE.B ($A10003), D0
 NOT.B  D0
 MOVE.W D0, (P1CTRL)
PollJoy1:
 MOVE.B ($A10003), D0
 AND.B  #3, D0          ; Check if poll is done
 BEQ    PollDone1
 BTST   #0, D0          ; Check X
 BEQ    DummyAxe11
 ADDQ.W #1, D1
 BRA    NextAxe1
DummyAxe11:
 ADDQ.W #1, D3
 BRA    NextAxe1
NextAxe1:
 BTST   #1, D0          ; Check Y
 BEQ    DummyAxe21
 ADDQ.W #1, D2
 BRA    PollJoy1
DummyAxe21:
 ADDQ.W #1, D3
 BRA    PollJoy1
PollDone1:
 MOVE.W D1, (JOYX1)
 MOVE.W D2, (JOYY1)
 RTS

ReadAnalog2:            ; Reads analog gamepad button and axe status
 CLR.W  D1              ; D1=X counter
 CLR.W  D2              ; D2=Y counter
 MOVE.B #$40, ($A10005) ; D3=Dummy counter
 NOP    #4
 MOVE.B #$00, ($A10005)
 MOVE.B ($A10005), D0
 NOT.B  D0
 MOVE.W D0, (P2CTRL)
PollJoy2:
 MOVE.B ($A10005), D0
 AND.B  #3, D0          ; Check if poll is done
 BEQ    PollDone2
 BTST   #0, D0          ; Check X
 BEQ    DummyAxe12
 ADDQ.W #1, D1
 BRA    NextAxe2
DummyAxe12:
 ADDQ.W #1, D3
 BRA    NextAxe2
NextAxe2:
 BTST   #1, D0          ; Check Y
 BEQ    DummyAxe22
 ADDQ.W #1, D2
 BRA    PollJoy2
DummyAxe22:
 ADDQ.W #1, D3
 BRA    PollJoy2
PollDone2:
 MOVE.W D1, (JOYX2)
 MOVE.W D2, (JOYY2)
 RTS
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

KanedaFr
Administrateur
Posts: 1139
Joined: Tue Aug 29, 2006 10:56 am
Contact:

Post by KanedaFr » Wed May 23, 2007 5:12 pm

TmEE co.(TM) wrote:I'm not familiar with USB, but I believe it is not too hard to get USB pad working with MD, maybe a PIC(don't have experience with these either) ?
it's not that hard...I made some research and find stuff
but i'm not a electronic guy and I don't have the tools to burn eprom or write pic

Huge
Very interested
Posts: 197
Joined: Sat Dec 13, 2008 11:50 pm

Post by Huge » Tue Jun 09, 2009 3:50 pm

Huh, for a minute I thought this was about those analog megadrive pads used by, I think, AfterburnerII.

Post Reply