libretro / opera-libretro

Port of 4DO/libfreedo to libretro.
66 stars 38 forks source link

Enable second player for SAOT #185

Closed StormedBubbles closed 1 year ago

StormedBubbles commented 1 year ago

Hello,

As per previous discussion, the lightgun implementation in lr-opera has some issues. However, by rearranging a couple lines of code in the existing arcade-lightgun implementation, I got 2 guns to work properly in Shootout at Old Tucson. Each player can independently aim, add coins, press start, shoot, reload, and access the service menu properly with these changes. Previously, the second gun would interfere with the operation of the first, but that is not the case anymore with these changes.

The calibration menu is a bit misleading. You have to press the button you assigned to Libretro's "Gun Start" input in order to fire a calibration shot. Shooting using the "Gun Trigger" input just tests the calibration. You will likely need to calibrate both players before jumping into a game.

Here are the controls, in case anyone is wondering:

Gun Trigger = shoot Gun Aux A = toggle service menu and cycle service-menu items Gun Select = coin Gun Start = in-game start, select service-menu items, and (during gameplay) switch weapons Gun Reload = simulated offscreen shot (can also point the gun offscreen and shoot to reload)

I suggest changing the coin options from the default since player 1 (left) has to add multiple coins to get a single credit with the default settings.

An issue that remains is that the port number does not correspond to player number, so port 1 controls player 2 and port 2 controls player 1.

Additionally, these exact same changes do not appear to allow 2 guns to work fully with 3DO games in the 3DO-lightgun implementation, though I do get two independent sets of shots appearing on screen (just can't aim properly). I can investigate that separately. For now, the 3DO portion of the lightgun implementation is unchanged.

phasermaniac83 commented 1 year ago

Nice! I think the inverted ports are not actually an issue, as if I'm not wrong, American Laser Games cabs had first player on the left and second one on the right

trapexit commented 1 year ago

I'm not sure I want to merge this because we know the reason the controls are messed up and this doesn't really address it.

The issue is that this implementation (by me) was reverse engineered incorrectly originally. The interpretation of the size of the pbus data packet and content was off. I've properly got it now: https://3dodev.com/documentation/hardware/opera/pbus#lightgun but haven't had the time to really fix it. Particularly translation of RA's mouse data to the counter and line pulse count.

The data stream is wrong but my incorrect algo to calculate location + happenstance of ordering allowed it to work'ish.

Widge-5 commented 1 year ago

I respectfully suggest that perhaps an incorrect implementation that works is better than an incorrect implementation that's broken, for the short term at least until the issue is correctly addressed.

StormedBubbles commented 1 year ago

Thanks for looking it over! Yes, this is definitely just meant to be a BAND-AID until a more proper solution is implemented. I did read over that documentation, but it is quite beyond my comfort zone to be able to help directly with that. I do have familiarity with RA's lightgun API (and touch/pointer, if that's desired to have too), so I'd be able to help a bit with that if need be.

StormedBubbles commented 1 year ago

I am reading through the linked documentation and have a couple of questions because I think I may be able to lend some help here.

First, in the formula for x, I think I am misunderstanding the syntax. Is the % symbol supposed to be /? If so, then that implies a few things that are confusing me. Just by rearranging the variables in the formula for y, the result is:

counter = (y * NTSC_DEFAULT_YSCANTIME) / 10

However, this also means that x is just a constant multiple of y, i.e.,

x / y = NTSC_WIDTH / (NTSC_DEFAULT_XSCANTIME * 10)

This doesn't make sense to me. It says that x / y is always the same constant.

trapexit commented 1 year ago

. Is the % symbol supposed to be /?

No. It is modulus. Not divide.

StormedBubbles commented 1 year ago

Got it; thank you. I seem learn new code syntax every day 😆.

Then the y formula can be rearranged to give

10 * counter = (y * NTSC_DEFAULT_YSCANTIME)

which can go into the formula for x:

x = ((((y * NTSC_DEFAULT_YSCANTIME) % NTSC_DEFAULT_YSCANTIME) * NTSC_WIDTH) / (NTSC_DEFAULT_XSCANTIME * 10))

and seems to suggest that x = 0 whenever y is an integer.

EDIT: does this just mean that x and y are floats with a purely decimal range? (So something like 0 to 1?)

trapexit commented 1 year ago

No, it isn't float. Nothing on the console is a float. Everything is normal 2s compliment integers or fixed point. The system provides the counter. You can write a simple program to see what x,y would be according to the input of counter. The data provided on 3dodev.com is everything I have found on it.