Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Naomi) Controls investigation #115

Closed
barbudreadmon opened this issue Jul 3, 2018 · 12 comments
Closed

(Naomi) Controls investigation #115

barbudreadmon opened this issue Jul 3, 2018 · 12 comments

Comments

@barbudreadmon
Copy link
Collaborator

barbudreadmon commented Jul 3, 2018

As mentioned in 55b25a4, naomi controls are only partially working.

I think i got the general idea of what is wrong.

This is how we handle naomi inputs in reicast :
https://github.com/libretro/reicast-emulator/blob/master/core/hw/maple/maple_devs.cpp#L1136-L1161

This is extremely similar to how mame is handling dreamcast controls :
https://github.com/mamedev/mame/blob/master/src/mame/drivers/dccons.cpp#L428-L459

But mame is actually handling naomi controls differently, see this :
https://github.com/mamedev/mame/blob/master/src/mame/drivers/naomi.cpp#L2038-L2064

My guess is that the naomi controls in reicast are based on how the dreamcast controls work, but we actually need to figure out how to port the lines from naomi.cpp in the link above to reicast.

@barbudreadmon
Copy link
Collaborator Author

Ok, i did a few interesting discoveries :

  • i was wrong, i compared and our code is equivalent
  • i think we need to replace

ADDFEAT(1, 2, 12, 0); //Feat 1=Digital Inputs. 2 Players. 10 bits
ADDFEAT(2, 2, 0, 0); //Feat 2=Coin inputs. 2 Inputs
ADDFEAT(3, 2, 0, 0); //Feat 3=Analog. 2 Chans
ADDFEAT(0, 0, 0, 0); //End of list

by

ADDFEAT(1, 2, 13, 0); //Feat 1=Digital Inputs. 2 Players. 10 bits
ADDFEAT(2, 2, 0, 0); //Feat 2=Coin inputs. 2 Inputs
ADDFEAT(3, 8, 16, 0); //Feat 3=Analog. 2 Chans
ADDFEAT(12, 6, 0, 0); //End of list

Source :
https://github.com/mamedev/mame/blob/927623bb1811e029ff8666d8db447f2d9dbed6ae/src/mame/machine/jvs13551.cpp#L105-L118

This is probably necessary to get working analogs, and perhaps fix other input issues

  • For whatever reason ~kcode[1] doesn't contain a valid content when running GG XX Accent Core, Akatsuki, ... It is supposed to be filed by the libretro frontend, so i guess the issue with P2 not working in some games could be related to a frontend issue. Add the following code

if (keycode2&NAOMI_START_KEY) printf("TEST !!!!!!!!!!!!!!!!!!!!!!\n");

after
https://github.com/libretro/reicast-emulator/blob/9170ed26130ad16bf83667c7d3e0300c50f70998/core/hw/maple/maple_devs.cpp#L1018-L1020
And you'll understand what i mean.

@barbudreadmon
Copy link
Collaborator Author

AFAIK the following code is never called for P2 controls with those games :
https://github.com/libretro/reicast-emulator/blob/85553efec4c34dfdc4ab76c48cff6c068350494d/core/hw/maple/maple_devs.cpp#L1014
So inputs aren't polled for P2 controls in libretro.cpp, and ~kcode[1] is left empty.
Could be related to the following code being wrong for those games :
https://github.com/libretro/reicast-emulator/blob/85553efec4c34dfdc4ab76c48cff6c068350494d/core/hw/maple/maple_cfg.cpp#L96

@barbudreadmon
Copy link
Collaborator Author

The 2nd player issue should be fixed with #121. I still need to implement analogs.

@barbudreadmon
Copy link
Collaborator Author

Also, i'm 99% sure analogs go in there :
https://github.com/libretro/reicast-emulator/blob/85553efec4c34dfdc4ab76c48cff6c068350494d/core/hw/maple/maple_devs.cpp#L1221-L1228
Not exactly sure "how" though, and the changes to the ADD_FEAT calls i mentioned above are most likely necessary too (those calls are some kind of setup for the jamma I/O board if i understood well).

@barbudreadmon
Copy link
Collaborator Author

@twinaphex This is just crazy how bad i'm with bitwise arythmetics and type conversion, tell me how i can convert a signed char ( -127 to 128) to an unsigned short (0 to 65536) properly, and analog controls will be fixed 5 minutes later.

@flyinghead
Copy link

Would that work? -127 -> 0 and 128 -> 65280

char c;
u16 u = (c + 127) << 8;

@barbudreadmon
Copy link
Collaborator Author

@flyinghead i opened a PR, controls finaly working in monkey ball, feel free to rewrite the lines i mention in the PR properly (i did it "the way i understand").

@barbudreadmon
Copy link
Collaborator Author

u16 u = (c + 127) << 8;

@flyinghead Nope, that's one of the things i tried, it doesn't work properly (extreme left analog would move right).

@flyinghead
Copy link

Then you could try:

char c;
u16 u = (127 - c) << 8;

converts: -128 to 65280, 0 to 32512 and 127 to 0

Or:

u16 u = 32767 − (c * 256);

converts: -128 to 65535, 0 to 32767 and 127 to 255

@barbudreadmon
Copy link
Collaborator Author

@flyinghead u16 u = 32767 − (c * 256); is basically what i did, so i guess it's fine.

@flyinghead
Copy link

It's all good then.

@barbudreadmon
Copy link
Collaborator Author

For future reference about 4P mode : https://www.solvalou.com/arcade_naomicapcom.php

Basically, the second Jamma I/O board will be useless for most (all ?) games, we need to emulate a Capcom Naomi I/O board for this, and AFAIK, there is no emulator who knows how to do that (didn't find anything in MAME).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants