libretro / mame2003-libretro

MAME 0.78 for libretro. Compatible with MAME 0.78 sets.
Other
90 stars 74 forks source link

Workaround invalid rotate code #504

Closed zorro2055 closed 10 months ago

zorro2055 commented 10 months ago

@mahoneyt944

Hi, thanks for getting back to me and offering to review. Here is the patch for the issue submitted as a pull request as directed. I have also pasted what I posted in the issue here below. Let me know if there are questions.

I investigated this, and it looks like this issue is caused by a bug fix which intentionally feeds a invalid code to avoid a bug with Guerilla War.

I also came up with a patch (now this pull request) that automatically rotates to the next code (which is a good code) that the character was rotating to in the next frame. So, the bug fix for Guerilla war still works, but the user never perceives the character did not rotate when the 12 way joystick is rotated.

Let me know if there are issues with the patch, method of fixing this bug, etc. I'm willing to correct as needed.

Reference: Some code in src/drivers/snk.c intentionally introducing the invalid code (0xf0):

        const int dial_12[13] = {
        0xb0,0xa0,0x90,0x80,0x70,0x60,
        0xf0,
        /* 0xf0 isn't a valid direction, but avoids the "joystick error"
        protection
        ** in Guerilla War which happens when direction changes directly from
        ** 0x50<->0x60 8 times.
        */
        0x50,0x40,0x30,0x20,0x10,0x00
        };

patchSNKFixRotate.txt

Thank you wanting to make a contribution to this project!

Please note that by contributing code or other intellectual to this project you are allowing the project to make unlimited use of your contribution. As with the rest of the project, new contributions will be made available freely under the classic MAME Non-Commercial License.

This license can be viewed at https://raw.githubusercontent.com/libretro/mame2003-libretro/master/LICENSE.md.

mahoneyt944 commented 10 months ago

@zorro2055 This fix would also work for mame2003-plus. A updated version of mame2003. We'd be happy to accept a PR for that repo as well. Thank you for contributing.

zorro2055 commented 10 months ago

@mahoneyt944 Thanks for accepting this pull request. I'll definitely submit a PR for this same issue for mame2003-plus. That might not be until next week though. Also, after I do more research, I'll probably submit a PR for a different issue with the 12 way rotary joystick having to do with the fact that libretro appears to poll for buttons only at a new frame, and the fact that a twist of the rotary joystick is a button press of a certain length which can sometimes cause one twist to rotate the character twice. That one will probably take some discussion if I submit that which I hope to do after more testing.