libretro / mame2003-plus-libretro

Updated 2018 version of MAME (0.78) for libretro. with added game support plus many fixes and improvements
Other
183 stars 109 forks source link

Fix time soldiers character init direction and precession #1742

Closed zorro2055 closed 1 month ago

zorro2055 commented 1 month ago

Hi @mahoneyt944

Here is a pull request to fix a small detail on Time Soldiers and Battlefield (same as Time Soldiers, but with Japanese text).

This fix has the character pointing straight up instead of the initial 30 degrees to the left (Time Soldiers uses 12-way rotary joystick to rotate the character every 30 degrees instead of every 45 degrees like Ikari Warriors).

This fix also passes the adjusted port value so it initially points to the middle of the port range (235-255) that represents pointing straight up. This will keep the character from skipping or missing a step from precession since the port numbers are integers and 256 is not evenly divisible by 12. With an optimal key / joy step of 21 or 22, a step will not be skipped for ~10 360 degree revolutions in one direction which is unlikely to happen.

The initial port value is 0 which is just in the range for the character to point 30 degrees to the left. This PR subtracts 10 from the port number when passing to the game. If that ends up being less than 0, 255 is then added to cause it to "wrap" around. So when the port is initially 0, subtracting 10 = -10, then add 255 since it is negative = 245. This is in the middle of the port range of 235-255 for pointing straight up.

Port 5 is for the rotation of player 1 and port 6 is for the rotation of player 2.

You can see from this video (time 0:52) of arcade play that the character does start facing straight up: https://www.youtube.com/watch?v=C9omf1-iO7M

Showing that these two games are the only ones that using analog, ie rotate or IPT_DIAL controls. None of the other games in apha68k.c have PORT_ANALOG or PORT_ANALOGX defined. Time Soldiers: https://github.com/libretro/mame2003-plus-libretro/blob/2a2ba583af473b74376f580a4ee9cb41a50b478f/src/drivers/alpha68k.c#L1088 https://github.com/libretro/mame2003-plus-libretro/blob/2a2ba583af473b74376f580a4ee9cb41a50b478f/src/drivers/alpha68k.c#L1134-L1139

Battlefield: https://github.com/libretro/mame2003-plus-libretro/blob/2a2ba583af473b74376f580a4ee9cb41a50b478f/src/drivers/alpha68k.c#L1142 https://github.com/libretro/mame2003-plus-libretro/blob/2a2ba583af473b74376f580a4ee9cb41a50b478f/src/drivers/alpha68k.c#L1188-L1193

And lastly, here is an image showing the port number ranges to discrete 30 degree character positions for reference. image

Hopefully that is clear, but let me know if there are any questions. Thanks.

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-plus-libretro/master/LICENSE.md.

mahoneyt944 commented 1 month ago

@zorro2055 did you try just setting the default of ANALOGX to 0xf5? Instead of 0? If that works it would be better to revert this and submit that.

zorro2055 commented 1 month ago

Ah, good point. I'll try that now.

zorro2055 commented 1 month ago

Yeah, that worked. I'll submit a new PR with just that change referencing this one for you to revert like you suggested.