UPDATE: Issue solved with workaround, see below.
I have only one issue left, and that is getting to make the joystick routine work properly.
TL;DR: How to avoid the joystick registring more than once on one joystick move or fire press?
I settled on the IJK library from ISS' openOricLibrary as I found that one to be the easiest to implement. Also, porting the OSDK lib for joystick support from Dbug to CC65 was looking way more difficult as I have no clue how to do IRQ handlers in CC65.
Good news: the IJK routines work perfectly testing in Oricutron with the keyboard emulation on the keypad for joy1 (do not have controllers or joysticks on the PC yet).
Bad news: if I test on real hardware with the IJK joystick interface from Raxiss, every joystick move is registered many times, making navigation trough the menus virtually impossible.
Any way to solve that?
I already did implement code to wait until the joystick is neutral again (until doing so I had the issue in Oricutron as well). That works in Oricutron, but not on real hardware. No clue why.
My present code:
Code: Select all
unsigned char getkey(unsigned char* allowedkeys, unsigned char joyallowed)
{
/* Function to wait on valid key or joystick press/move
Input: allowedkeys = string with valid key press options
Output: key value (or joystick converted to key value) */
unsigned char key;
do
{
key = 0;
if(joyinterface && joyallowed)
{
ijk_read();
if(ijk_ljoy&4) { key = C_ENTER; }
if(ijk_ljoy&1) { key = C_RIGHT; }
if(ijk_ljoy&2) { key = C_LEFT; }
if(ijk_ljoy&8) { key = C_DOWN; }
if(ijk_ljoy&16) { key = C_UP; }
if(ijk_rjoy&4) { key = C_ENTER; }
if(ijk_rjoy&1) { key = C_RIGHT; }
if(ijk_rjoy&2) { key = C_LEFT; }
if(ijk_rjoy&8) { key = C_DOWN; }
if(ijk_rjoy&16) { key = C_UP; }
if(key){
do
{
ijk_read();
} while (ijk_ljoy || ijk_rjoy);
}
}
if(key == 0)
{
if(kbhit()) { key = cgetc();}
}
} while (strchr(allowedkeys, key)==0 || key == 0);
return key;
}
Code: Select all
do
{
ijk_read();
} while (ijk_ljoy || ijk_rjoy);