Hi dunno about coding.. but maybe help you the program "Joytest" on aminet
http://aminet.net/search?query=Joytest
Also i found this hardware mod on single Joy,s for working the second fire button for a lot Whdload games like ..
.Bubble and Squeak
.Banshee
.BCKid
.LionHeart
.Leader
.and more..
needed pull-up resistor on pin 9 to working well the second fire button.