![]() |
![]() |
#1 |
Wolf-bear thing
Join Date: Jan 2014
Location: Finland
Age: 40
Posts: 56
![]() |
Reading the second fire button
I'd like to have my game support the second fire button available on some joypads/joysticks (such as the C button on a Sega Megadrive joypad, which is all I have to test it with.)
To initialize that (along with the right mouse button), I do a Code:
lea CUSTOM, a6 move.w #BIT15|BIT14|BIT11|BIT10, POTGO(a6) ; OUTRY+DATRY+OUTLY+DATLY Code:
btst #14-8, POTGOR+CUSTOM ; was secondary fire button hit? bz .Fire2 ; yes The real problem is that it doesn't work at all on my A1200. I'm seeing nothing in POTGOR when pressing the second fire button. The right mouse button is read fine. The pad is in working condition and the second button works in other games that support it. Any pointers please? Last edited by hukka; 03 September 2014 at 14:59. |
![]() |
![]() |
#2 |
Glastonbridge Software
Join Date: Jan 2012
Location: Edinburgh/Scotland
Posts: 2,242
|
all the many hardware eccentricities are not emulated exactly (i'm sure Toni Wilen can furnish us with the details) but you have to introduce a small delay between writing to POTGO and reading POTGOR because of physical electronics, there is a capacitor that has to charge up or something. It's to do with the way it handles these pins being both input and output capable. Why they didn't abstract this away from the programmer i don't know but there you go.
It is like a DMA wait, a few scanlines should do it i think although i've never tried it myself. |
![]() |
![]() |
#3 | ||
Natteravn
![]() Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,318
|
Quote:
Quote:
|
||
![]() |
![]() |
#4 |
Glastonbridge Software
Join Date: Jan 2012
Location: Edinburgh/Scotland
Posts: 2,242
|
"Mapping the Amiga" on p467 recommends waiting 300 microseconds between writing POTGO and reading POTGOR
|
![]() |
![]() |
#5 | |
AMOS Extensions Developer
Join Date: Jun 2007
Location: near Cambridge, UK
Age: 43
Posts: 1,924
|
A quote from Toni from a thread somewhere on EAB (sorry I didn't record the exact location in my source code):
Quote:
Here's my calculations from my own keyboard reading routine. In order to wait ~300uS, 4 scanlines should be sufficient assuming that 1) my calculations are correct and 2) you are designing this for a PAL system ![]() Code:
; ; ; PAL ; === ; ; 50 VBLs / second = 0.02 seconds per VBL ; 250 scanlines per VBL = 0.00008 seconds per scanline ; 0.00008 seconds = 0.08 milliseconds (mS)= 80 micro seconds (uS) ; |
|
![]() |
![]() |
#6 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 48
Posts: 25,814
|
Only need to set second button data direction and data bit to one. You sure your BITxx macro works? It looks like data direction is in input mode (only works if button has pullup resistor)
|
![]() |
![]() |
#7 |
68k
![]() Join Date: Sep 2005
Location: Somewhere
Posts: 807
|
In Solomon's Key I used following code and as far as I remember it works. I tested it with cd32 pad on my a1200.
Code:
btst #14,$dff016 bne.b .exit st fireballKey .exit or.w #$c001,$dff034 |
![]() |
![]() |
#8 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 48
Posts: 25,814
|
That code reads from write-only register! (EDIT: It becomes write FFFF to POTGO!)
There is no need to write to bit 0 (only needed if other than red or blue CD32 pad needs to be read) or to write it each frame. Note that KS vblank routine will reset POTGO: do not update POTGO until you have taken over the system or you will need to update it each frame to override KS POTGO write. Last edited by Toni Wilen; 03 September 2014 at 21:37. |
![]() |
![]() |
#9 | |
68k
![]() Join Date: Sep 2005
Location: Somewhere
Posts: 807
|
Quote:
Code:
btst #14,$dff016 bne.b .exit st fireballKey .exit move.w #$c000,$dff034 |
|
![]() |
![]() |
#10 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 48
Posts: 25,814
|
It should work but if it does not, you probably have some other write to POTGO somewhere else and bit 0 write side-effect "overrides" it. (For example because pot capacitor is forced to discharge. POT lines are quite special, they have both digital and analog components)
|
![]() |
![]() |
#11 |
Wolf-bear thing
Join Date: Jan 2014
Location: Finland
Age: 40
Posts: 56
![]() |
Thanks everyone for the replies!
So if I'm understanding correctly, although I have system enabled while running, this should still work: Code:
VBL_interrupt: lea CUSTOM, a6 move.w POTGOR(a6), Pot ; (some other stuff) move.w #$C000, POTGO(a6) |
![]() |
![]() |
#12 | |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 48
Posts: 25,814
|
Quote:
Normally your VBL routine (if it is added using exec routines) has lower priority than OS routine that sets POTGO "incorrectly". You can also try using very high priority for your VBL routine. |
|
![]() |
![]() |
#13 |
Wolf-bear thing
Join Date: Jan 2014
Location: Finland
Age: 40
Posts: 56
![]() |
Okay, I took it out of the vbl routine and into the mainloop which does this now:
Code:
WaitLine 270 move.w #$CC00, POTGO+CUSTOM WaitLine 276 move.w POTGOR+CUSTOM, Pot ![]() Thanks for the tip - does anyone happen to have info on how to set the priority? |
![]() |
![]() |
#14 | ||
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 48
Posts: 25,814
|
Quote:
Quote:
![]() |
||
![]() |
![]() |
#15 | ||
Wolf-bear thing
Join Date: Jan 2014
Location: Finland
Age: 40
Posts: 56
![]() |
Quote:
And a clarification because I'm not sure I mentioned this, I'm seeing the POTGOR register change from $5500 to $1500 when pressing the second fire button in WinUAE. But not on the Amiga. And those aren't the values I should be getting anyway, right? Quote:
|
||
![]() |
![]() |
#16 | |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 48
Posts: 25,814
|
Quote:
Does bit 10 toggle when pressing right mouse button? If yes, does joystick port also work if you insert mouse in joystick port and press right mouse button? |
|
![]() |
![]() |
#17 |
Wolf-bear thing
Join Date: Jan 2014
Location: Finland
Age: 40
Posts: 56
![]() |
Yes to both. But nothing with either pads I tested with (a Megadrive pad and a brand new clone pad). I just tried the WHDload version of Great Giana Sisters which has the option of using the second button for jumping and it worked great with the MD pad, so I know it's not the hardware at fault.
|
![]() |
![]() |
#18 | |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 48
Posts: 25,814
|
Quote:
|
|
![]() |
![]() |
#19 |
Wolf-bear thing
Join Date: Jan 2014
Location: Finland
Age: 40
Posts: 56
![]() |
|
![]() |
![]() |
#20 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 48
Posts: 25,814
|
I think I start to understand what is going on.. (Megadrive pad does not really work like everything else..) But first we need to confirm all 3 possibilies:
- second button with pull up resistor, some game pads, original Commodore mice, 3rd party mice may not have it. (not pressed = second button pin pulled to +5v via 10k resistor, pressed = shorted to ground). CD32 pad in 2-button mode should be like this case too. - second button without pull up resistor. (not pressed = second button pin is floating, pressed = shorted to ground) - Megadrive pad which has TTL chip which apparently can't override signal when Paula is programmed to output mode = "pullup emulation". Do you have all test cases? Could you check if your mouse has pullup? (Measure resistance between pin 9 and pin 7: infinite = no pullup, about 10k = pullup) I still assume single read mode can't handle all 3 cases. |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Fire button configuration | Rogue | support.Amiga Forever | 0 | 18 January 2014 12:38 |
Configure button 1 as fire and button 2 as autofire | Harry | support.WinUAE | 1 | 21 December 2013 13:37 |
Can I configure second fire button on keyboard? | NLS | support.WinUAE | 2 | 18 January 2008 23:00 |
Fire-Button | oldpx | Amiga websites reviews | 19 | 30 September 2002 08:48 |
2nd Fire Button | Doozy | support.WinUAE | 7 | 22 January 2002 19:21 |
|
|