 |
SpritesMind.Net Sega Megadrive/Genesis development
|
| View previous topic :: View next topic |
| Author |
Message |
TmEE co.(TM) Very interested

Joined: 05 Dec 2006 Posts: 1947 Location: Estonia, Mahtra village
|
Posted: Sat May 19, 2007 7:51 pm Post subject: Analog controller for MD |
|
|
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 :
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):
 _________________ Mida sa loed ? Nagunii aru ei saa  |
|
| Back to top |
|
 |
KanedaFr Administrateur

Joined: 29 Aug 2006 Posts: 635
|
Posted: Mon May 21, 2007 12:36 pm Post subject: |
|
|
oh cool!!!
It's something I tried to do
even if I'm more after the MD->USB pad  |
|
| Back to top |
|
 |
TmEE co.(TM) Very interested

Joined: 05 Dec 2006 Posts: 1947 Location: Estonia, Mahtra village
|
Posted: Mon May 21, 2007 2:44 pm Post subject: |
|
|
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  _________________ Mida sa loed ? Nagunii aru ei saa  |
|
| Back to top |
|
 |
TmEE co.(TM) Very interested

Joined: 05 Dec 2006 Posts: 1947 Location: Estonia, Mahtra village
|
Posted: Mon May 21, 2007 3:04 pm Post subject: |
|
|
one thing I forgot, the source code
| Code: | 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  |
|
| Back to top |
|
 |
KanedaFr Administrateur

Joined: 29 Aug 2006 Posts: 635
|
Posted: Wed May 23, 2007 5:12 pm Post subject: |
|
|
| 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 |
|
| Back to top |
|
 |
Huge Very interested

Joined: 13 Dec 2008 Posts: 148
|
Posted: Tue Jun 09, 2009 3:50 pm Post subject: |
|
|
| Huh, for a minute I thought this was about those analog megadrive pads used by, I think, AfterburnerII. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|