I've been trying to edit the classic 3button reading function so it can handle 6buttons as well.
The idea is to always read twice the joypad (even if its 3button), and look if the second read is different than the first (if so, its 6button joypad, ORRRRR bad contacts!).
That sounds like a horrible idea, heh?
My idea was to get the stuff done as fast as possible (without the trick to query the joypad).
It works, but it has some glitches time to time (like once every 10 minutes of play).
Is there anyway to improve it without loosing too much speed?
C, still.
Since I'm not relying on Vint, it would be awesome to have workaround for the famous "bad result if read more than once per frame" syndrome.
Bellow is my current code.
I'm storing result in WORDS, instead of the good old BYTE of Kaneda's routines
I'm never really fresh when it comes to such stuff ^^ And programming in general, seems
Code: Select all
pb = (uchar *) 0xa10003;
*pb = 0x40;
asm("nop");
asm("nop");
asm("nop");
i = *pb & 0x3f; //6 lower bits
*pb = 0;
asm("nop");
asm("nop");
asm("nop");
j = (*pb & 0x30) << 2; //2 top bits
fvr_joypad_result[1]=(i|j); /*p1*/
//Other read
*pb = 0x40;
asm("nop");
asm("nop");
*pb = 0;
asm("nop");
asm("nop");
//Other read to enable 6 button
*pb = 0x40;
asm("nop");
asm("nop");
j=(*pb);
*pb = 0;
if((fvr_joypad_result[1]&0xF)!=(j&0xF))//6 button pad :)
{
j<<=8;//Shift J result
fvr_joypad_result[1]|=j;
fvr_joypad_result[1]=~fvr_joypad_result[1];
fvr_joypad_result[1]=fvr_joypad_result[1]&0xFFF;
}
else
{
fvr_joypad_result[1]=~fvr_joypad_result[1];
fvr_joypad_result[1]=fvr_joypad_result[1]&0xFF;
}
Thanks for your help.
Fonzie