Attached is my modified dosdef.moc (you would need to rename it .com to execute 
it, if you dare!).

It seems to me that the bug is that the function:

static bool joystick_detected()
{
    struct joystick joystick;
    joystick_read(&joystick);
    return joystick.axis[0] != 0 || joystick.axis[1] != 0;
}
in dosdef.c, does not work properly...

I modified it a bit to rather test for AH=0x86 when there is no joystick:
static bool joystick_detected()
{
    struct joystick joystick;
    joystick_read(&joystick);
    return (joystick.axis[0] & 0xff00) != 0x8600;
}

I believe this fix it... a bit.

Here is the referenced function:
static void joystick_read(struct joystick *joystick)
{
    asm volatile ("mov  $0x84, %%ah\n"
                  "mov  $1, %%dx\n"
                  "int  $0x15\n"
                  : "=a"(joystick->axis[0]), "=b"(joystick->axis[1]),
                    "=c"(joystick->axis[2]), "=d"(joystick->axis[3]));
    for (int i = 0; i < 4; i++) {
        joystick_config.min[i] =
            min(joystick_config.min[i], joystick->axis[i]);
        joystick_config.max[i] =
            max(joystick_config.max[i], joystick->axis[i]);
    }
    uint16_t buttons = 0;
    asm volatile ("mov  $0x84, %%ah\n"
                  "mov  $0, %%dx\n"
                  "int  $0x15\n"
                  : "=a"(buttons)
                  : /**/
                  : "bx", "cx", "dx");
    for (int i = 0; i < 4; i++)
        joystick->button[i] = !(buttons & (1 << (i + 4)));
}

Attachment: dosdef.moc
Description: Binary data

_______________________________________________
Freedos-devel mailing list
Freedos-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-devel

Reply via email to