jhhoward / WolfensteinCGA

Wolfenstein 3D with a CGA renderer
325 stars 10 forks source link

Demo Mode does not work on HP 200LX Palmtop "Something about the LX keyboard being scanned and acting as a key being pressed." #10

Open gamer85 opened 1 year ago

gamer85 commented 1 year ago

First, thank you @jhhoward for this amazing port to the HP 200LX! Wanted to say how grateful I am for your work. Second, I wanted to report a bug that I am able to create on several HP 200LX Palmtops. Others can also recreate this bug.

The issue is the gam will not go into the normal demo mode / attract mode when the game first loads and the user does not press a key. An insightful HP200LX owner suggested "Something about the keyboard on the LX is being scanned and acting as a key being pressed. I imagine a work around for this would be to somehow remap what the game is looking for."

My workflow is I run "wolf3dc.exe lcd wide" at the DOS prompt. I see the game title screen flash on screen for 2 seconds but then I get returned to the menu screen. I did not hit a key. Game plays but I an after trying to get the demo mode that should run when no key press occurs. Demo mode works fine on DOSBox on a Windows box.

Seems like the shadow key array isn't zero'd on startup (the game keeps an in-memory representation of key states - and updates it on keydown/up interrupts).

Possible Ideas - Issuing a IN_ClearKeysDown() call before the demo loop starts would probably be the best way to make sure that is taken care of. If that doesn't work then we need to get some info on how the keyboard interrupts are handled on the HP.

May I request this keyboard scanning bug be fixed? Thank you

ZXDunny commented 1 year ago

Working with Gamer85, we've narrowed it down to an unattached port read in ID_IN.C, in the IN_JoyButtons() function. Fix is:

byte    IN_JoyButtons (void)
{
    unsigned joybits;

    if (joystickenabled)
    {
        joybits = inportb(0x201);        // Get all the joystick buttons
        joybits >>= 4;                // only the high bits are useful
        joybits ^= 15;                // return with 1=pressed

        return joybits;
    }
    else
        return 0;
}

i.e., just add a check to see if the joystick is enabled before attempting to read the joystick port.