EmulatorArchive / genplus-gx

Automatically exported from code.google.com/p/genplus-gx
Other
1 stars 0 forks source link

Analog controls for games that have support for it #156

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
There are some games (6 if I'm not wrong) that have analog support with the use 
of an special joystick(XE-1AP), Two notable game that support it are 
Afterburner II and Super Monaco GP, no other emulator implemented this function 
yet).

Original issue reported on code.google.com by Rodrigo....@gmail.com on 9 Mar 2011 at 10:20

GoogleCodeExporter commented 9 years ago
Interesting, I never heard about this controller before, seems like it was only 
released in Japan.

Thanks for heads up anyway but still, without more informations about this 
special joystick, it is a little hard to emulate it. Only solution is again to 
disassemble games said to support it and look for special I/O detection & 
access routines.

Do you have an exhaustive list of games supporting this controller ? I have 
quickly looked into Afterburner II disassembled code but did not found any 
special handling code inside it...

Original comment by ekeeke31@gmail.com on 9 Mar 2011 at 11:35

GoogleCodeExporter commented 9 years ago
Here is a list:

MEGA DRIVE/GENESIS

Afterburner II
M.U.S.H.A Aleste
Fastest One
Galaxy Force II
Ayrton Senna Super Monaco GP II

32X

Afterburner
Space Harrier

------------------

I don't know if it helps but the Afterburner and Super Monaco GP games detect 
and show in the title screen if it is a normal or analog joystick. As this 
joystick was only released in japan, maybe only the japanese roms are 
compatible.

Original comment by Rodrigo....@gmail.com on 9 Mar 2011 at 11:55

GoogleCodeExporter commented 9 years ago
Sorry for the double post, couldn't find an edit button

Here's is the title screen, in the lower left appears the name "Control Pad" if 
you use a standard controller
[IMG]http://i306.photobucket.com/albums/nn262/Rebirfh/AfterBurnerIIJapan000.jpg[
/IMG]

Here is a picture of the japanese manual for afterburner, it clearly shows a 
sensibility options for the analog pad that isn't acessible normally.
[IMG]http://i306.photobucket.com/albums/nn262/Rebirfh/Clipboard01-9.jpg[/IMG]

Original comment by Rodrigo....@gmail.com on 10 Mar 2011 at 12:05

GoogleCodeExporter commented 9 years ago
Thanks for the pictures, it helps figuring what kind of data the game is going 
to read. And yes, I already figured it would display "Control Pad" on title 
screen and always wondered why, I thought it was to make it more 
"arcade-feeling"...

I actually found the analog pad routine in After Burner 2 code. It is similar 
to the Sega Mouse protocol except that the game only "initializes" the 
acquisition sequence then the controller automatically sends all the info about 
button status, analog values, etc in a sequential way.  The game looks at 2 
input lines (TR/TL) to know which part of the data is returned and use some 
kind of tempo to wait for analog controller to return next set of data.

I/O port mapping seems to be like this:

D6: 0 = start acquisition sequence, 1 = end of acquisition (output)
D5: indicates if D0-D3 are high or low bits of 8-bit data (input)
D4: same as D5
D3-D0: high or low nibble of 8-bit data

There is a total of four 8-bit data acquired which are (I guess):
- horizontal stick position (0-255)
- vertical stick position (0-255)
- buttons status (4 buttons = 4 bits, are the 4 remaining bits used ?)
- analog speed (0-255), I'm not sure to understand what this is, a translation 
of the manual would help.

This is a preliminary analysis of the code, still need to figure the order of 
data acquisition and the position of each buttons in the data field, their 
state when pressed, etc, but I guess this should be possible to emulate ;-)

Original comment by ekeeke31@gmail.com on 10 Mar 2011 at 12:30

GoogleCodeExporter commented 9 years ago
I've put in some places hoping for someone to translate correctly.
While this doesn't happen, I typed ad google-translated it:

This game was released for the Company "XE-1AP" (analog joypad from now on 
"AP"), Making possible the delicate operation of your ship. The operation is 
shown below, AP connected to "CONTROL1",

How AP works

Control stick : moves ship 

Start Button 
Select and in-game pause menu 

Speed ​​control throttle 

A trigger: missile 

B trigger: fire vulcan  

-------------- 

Connected to an AP-mode option "CONTROL" in the field of a center position can 
be adjusted.

Stick in each direction, so that reading from the throttle began to view 
numbers, please make sure to move.

While none hands
Usually "STICK", "SPEED" 127 to 128 both
Adjust the circle to take the AP or the volume adjustment done on the back of 
the AP Please see the manual for detailed instructions.

Original comment by Rodrigo....@gmail.com on 10 Mar 2011 at 5:11

GoogleCodeExporter commented 9 years ago
Speed is actually the Throttle Analog Stick, seems like its adds a third analog 
direction, i.e depth, for games using a first-person view.

From pictures, it seems there are 14 buttons on that thing (2x2 on each side, 
6x at bottom, 4x on top), some of them must be auto-fire or stuff like that 
since only 8 buttons status can be returned. Need more informations about 
these, the AP user manual would also help a lot but it seems very rare (there 
is apparently one on ebay)

Original comment by ekeeke31@gmail.com on 10 Mar 2011 at 7:45

GoogleCodeExporter commented 9 years ago
More info:
This joystick isn't exclusive for Mega Drive, it is in the box advertised also 
for PC's X68000, MSX, PC8801,PC9801 and FM-TOWNS.

Images

http://www.gigaoldgames.com.br/16bits/imagens/md_xe1ap_03.jpg
http://www.gigaoldgames.com.br/16bits/imagens/md_xe1ap_00.jpg
http://www.gigaoldgames.com.br/16bits/imagens/md_xe1ap_01.jpg
http://www.gigaoldgames.com.br/16bits/imagens/md_xe1ap_02.jpg

The third analog (slider) looks like it can be rotated if you compare the 
box/afterburner manual with the actual photos.

Buttons:

A
B
A¹ (same function as A?)
B¹ (same function as B?)
C
D
E¹ (?)
E² (?)
Start
Select
Analog Slider
Analog Stick
Mode 1 (Personal computer <--> Mega Drive)
Mode 2 (Digital <--> Analog)
Autofire Button A (ON <--> OFF>
Autofire Button B (ON <--> OFF>

Original comment by Rodrigo....@gmail.com on 10 Mar 2011 at 8:48

GoogleCodeExporter commented 9 years ago
This could be useful:

While normally a 9-pin DSUB connector won't fit in the PC Engine's 6-pin 
mini-DIN, there was an adaptor (The XHE-3) which allowed the use of MSX, X68000 
and FM-Towns1) pads on the PCE. When connected, the XE-1AP offered real 
analogue control to all of four PC Engine games:

Comparison of Japanese PC, Sega + Amiga DB9 pinouts
http://www.gamesx.com/wiki/doku.php?id=controls:sega_atari_msx_x68000

------------------------------
Translated from a japanese web site:

"distinctive look reminiscent of a back and forth 256 degrees in each direction 
(8bit) with the control stick and the output of stage 256 in the longitudinal 
direction (8bit) with the output of the throttle lever, trigger button 8 + 
start, equipped with the select button."

"Before using the XE-1AP, without a center control stick and throttle lever 
should not be first. "AFTER BURNER" Since the configuration of the screen shows 
you the analog input to quantify the situation, it is easy to use and implement 
it. Because the hexadecimal stage I 256 & H7F ~ & H80 around the center point. 
Centering on the rear of CH0 ~ CH2 done by turning the volume adjustment 
screwdriver.

After adjustments are immediately verified.

"AFTER BURNER" after boot "OPT1" Switch to note that the analog control is 
pressed."

Original comment by Rodrigo....@gmail.com on 10 Mar 2011 at 9:08

GoogleCodeExporter commented 9 years ago
Ok, so the 8-bit input data would be status of A,B,C,D,E1,E2,SELECT,START 
buttons
The three other 8-bit data are the 3 analog values.

Mode 1 & Mode 2 buttons are not needed for emulation (default would be Analog 
and Mega Drive): Digital mode is probably to make the controller works like a 
3-Button (or Maybe 6-Button controller), Personal Computer mode to handle 
compatibility with X68000.

Auto Fire could be emulated just like any other controller with Auto Fire, in a 
generic way (currently not handle in Genesis Plus GX)

Original comment by ekeeke31@gmail.com on 10 Mar 2011 at 11:45

GoogleCodeExporter commented 9 years ago
Hum, 8-bit input data is more like status of A,B,C,D,A1,B1,E1,E2 buttons, with 
START & SELECT handled differently (other bits maybe).

Original comment by ekeeke31@gmail.com on 10 Mar 2011 at 12:06

GoogleCodeExporter commented 9 years ago
I really know nothing about programming or hardware interface, but making an 
educated guess, as afterbuner came out in Japan in 1988, I think it's safe to 
asssume that A,B and Start are probably directly correlated with their 3 button 
controller counterpart and this joystick (XE-1AP) has no correlation with the 6 
button controller as it was planned only with the release of Street Fighter II.

Original comment by Rodrigo....@gmail.com on 10 Mar 2011 at 3:55

GoogleCodeExporter commented 9 years ago
A more accurate translation from the manual:

This game uses the [XE-1AP] (Analog Joypad. Henceforth: "AP") that we at (this 
company) sell. Because of that, you can move the player in very delicate ways. 
The illustration below shows that if you take AP and plug it into controller 1 
then reset the consule, you become able to use AP.

Once you've plugged AP into your controller, head to Option Mode, and go to 
"Control". There, you can adjust the callibration for the centered sticks 
(*note: I'm somewhat guessing here). Once you've done that for both sticks, a 
number will be indicated on screen. Once it does, move a stick to confirm. When 
you don't move the sticks, a normal reading for "Stick" and "Speed" should be 
about 127-128. If you need to adjust anything, on the back side of AP there is 
a volume adjuster you can use. For details on that, please read AP's 
instruction manual.

Original comment by Rodrigo....@gmail.com on 10 Mar 2011 at 4:05

GoogleCodeExporter commented 9 years ago
After some reverse-analysing of XE-1AP input code in AFter Burner 2, I finally 
managed to figure which data was returned in which order. Only 4 buttons are 
used by the game so I could not figure the position of unused buttons in 
returned data.

Here are some screenshots from the SDL port of genesis plus I'm using to test 
changes :

For informations, here are some infos about data returned by the controller (Th 
is set as output and is used to control acquisition cycles):

TH TR TL D3 D2 D1 D0

1  x  x  x  x  x  x

0  x  x  x  x  x  x
x  0  0  ?  ?  B4 ?     cycle = 0
x  1  1  B3 B2 B1 ?     cycle = 1

1  x  x  x  x  x  x
x  0  0  X7 X6 X5 X4    cycle = 2
x  1  1  Y7 Y6 Y5 Y4    cycle = 3

1  x  x  x  x  x  x
x  0  0  ?  ?  ?  ?     cycle = 4
x  1  1  Z7 Z6 Z5 Z4    cycle = 5

1  x  x  x  x  x  x
x  0  0  X3 X2 X1 X0    cycle = 6
x  1  1  Y3 Y2 Y1 Y0    cycle = 7

1  x  x  x  x  x  x
x  0  0  ?  ?  ?  ?     cycle = 8
x  1  1  Z3 Z2 Z1 Z0    cycle = 9

1  x  x  x  x  x  x

Original comment by ekeeke31@gmail.com on 11 Mar 2011 at 9:14

Attachments:

GoogleCodeExporter commented 9 years ago
After more analyzing of other games input engines, I think I got the 
communication protocol pretty much correct now (it was not exactly as stated in 
previous comment), all five games (including revisions) work fine with analog 
controller now.

Musha Aleste seems buggy, it does not read analog sticks on the main screen so 
you can't go to option menu. If you wait for the in-game demo loop before 
hitting a button, it won't detect analog controller buttons anymore and you 
need to reset the game manually. Everything works fine IN game though which 
confirms it's not an issue with my emulation code but game's code.

It indeed seems that the right stick can be rotated: racing games use it as 
left/right steering stick. It's unidirectional though, all games always get the 
same data from cycles 5&9 above, cycles 4&10 are never used so it's not really 
known which data is returned there (I initially thought it behaves like the 
left stick with the ability to return X & Y axis data but it's not the case).

For both sticks:
Vertically, top position is 0, bottom position is 255, 128 is middle.
Horizontally, left position is 0, right position is 256, 128 is middle.

Buttons data returned in cycles 0 & 1 is:
 ? ? START SELECT A B C D
0 means button is pressed, 1 means it's released
Unknown buttons are probably E1 & E2 but since no games use these, there is no 
way to be sure.

Original comment by ekeeke31@gmail.com on 14 Mar 2011 at 9:10

Attachments:

GoogleCodeExporter commented 9 years ago
Correction: Horizontally, right position is 255

Original comment by ekeeke31@gmail.com on 14 Mar 2011 at 9:16

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks! and congratulations for being the first emu author to support this 
function.

Original comment by Rodrigo....@gmail.com on 14 Mar 2011 at 10:34

GoogleCodeExporter commented 9 years ago
For completeness, here's a more accurate protocol description, this could help 
other emu authors supporting this analog controller:

 TH  TR  TL  D3  D2  D1  D0
------------------------------
 1   x   x   x   x   x   x     (write)
 0   x   x   x   x   x   x     (write) reset acquisition

 1   x   x   x   x   x   x     (write) sequence #1 (some games do not send this)
 x   1   0   x   x   x   x      (read) data not ready 
 x   0   0   ?   ? Start Select (read) START & SELECT buttons status (active low)
 x   1   1   x   x   x   x      (read) data not ready 
 x   0   1   A   B   C   D      (read) A,B,C,D buttons status (active low)
...

0/1  x   x   x   x   x   x     (write) sequence #2 (some games write 0, others 
1)
 x   1   0   x   x   x   x      (read) data not ready 
 x   0   0   X7  X6  X5  X4     (read) left stick X axis value (msb)
 x   1   1   x   x   x   x      (read) data not ready 
 x   0   1   Y7  Y6  Y5  Y4     (read) left stick Y axis value (msb)
...

0/1  x   x   x   x   x   x     (write) sequence #3 (some games write 0, others 
1)
 x   1   0   x   x   x   x      (read) data not ready 
 x   0   0   ?   ?   ?   ?      (read) unused by games, maybe same value as below
 x   1   1   x   x   x   x      (read) data not ready 
 x   0   1   Z7  Z6  Z5  Z4     (read) right stick axis value (msb)
...

0/1  x   x   x   x   x   x     (write) sequence #4 (some games write 0, others 
1)
 x   1   0   x   x   x   x      (read) data not ready 
 x   0   0   X3  X2  X1  X0     (read) left stick X axis value (lsb)
 x   1   1   x   x   x   x      (read) data not ready 
 x   0   1   Y3  Y2  Y1  Y0     (read) left stick Y axis value (lsb)
...

0/1  x   x   x   x   x   x     (write) sequence #5 (some games write 0, others 
1)
 x   1   0   x   x   x   x      (read) data not ready 
 x   0   0   ?   ?   ?   ?      (read) unused by games, maybe same value as below
 x   1   1   x   x   x   x      (read) data not ready 
 x   0   1   Z3  Z2  Z1  Z0     (read) right stick axis value (lsb)
...

Within a sequence, the controller alternatively & automatically outputs the 1st 
(TL=0) and 2nd (TL=1) 4-bit data.

TR indicates if data is valid (0) or if controller is still busy processing 
data (1).

Writing 1 or 0 to TH will program next acquisition sequence (out of 5).
A transition from 1 to 0 on TH will restart first acquisition sequence.

Original comment by ekeeke31@gmail.com on 14 Mar 2011 at 5:04

GoogleCodeExporter commented 9 years ago
Implemented in 1.5.0

Original comment by ekeeke31@gmail.com on 31 Mar 2011 at 10:44

GoogleCodeExporter commented 9 years ago
Sorry for the extremely late response, but I was thinking with regard to Musha 
Aleste, perhaps the "MODE 2" switch as discussed above should be implemented 
after all? Presumably the developers originally intended for players to use the 
digital mode to navigate the menu, then turn the switch to analog to play. If 
this switch could be set in the menu like a button then it would be closer to 
normal play, without having to exit to the menu to switch control types on the 
fly.

That said, the analog controls in Musha are /horrible/ (not your fault, just 
bad design), so from that perspective it's probably not worth it because nobody 
wants to use it anyway. It also poses a problem for control schemes, e.g. I 
don't think there are any spare buttons on the Wiimote+Nunchuk or GameCube 
controller schemes, so it might have to be left out for those controls and only 
work on Classic Controller, which seems limiting.

If you want to leave it as is, that seems reasonable due to the small usage 
case here. Changing it would bring the experience a little closer to what's had 
on hardware ... but still terrible and unlikely to be used for very long. 
Obviously depends on your priorities, undoubtedly this would be a pretty low 
one.

Original comment by vaguerant on 29 Mar 2013 at 9:36

GoogleCodeExporter commented 9 years ago
Continuing on from the above, it seems that XE-1AP support is currently 
nonworking on Sega/Mega-CD games in genplus-gx. Three games were released which 
supported the controller: After Burner III, Night Striker (Japan-only) and Star 
Blade. However, I haven't been able to use the emulated 1AP with any of these 
titles. Though I'm not sure of the exact reason, a couple of potential sticking 
points come to mind:

1. XE-1AP input does not seem to be registered in the Sega/Mega-CD BIOS. With 
apologies, I can't confirm if the same is true on hardware. It is possible 
players would have been required to use the "MODE 2" switch set to Digital to 
start the game before switching back to analog?

2. Games which support the XE-1AP seem to require that the controller is 
connected on startup. e.g. If After Burner II (stock Mega Drive) is started 
with a standard 3-button pad inserted, it will not respond to inputs from the 
XE-1AP. Instead, the 1AP must be set, then the game launched. Due to point 1, 
it's impossible to start games with the 1AP set. I've tried "hot-swapping" by 
launching the game and immediately dropping out to the menu to switch 
controllers, but with no results.

In my testing of XE-1AP support in stock Mega Drive games, all international 
(e.g. USA) releases do still include analog support. However, it's possible 
that the feature could have been removed from the international releases of 
After Burner III and Star Blade. To confirm that this wasn't the issue, I have 
also been testing with Japanese version games, which are known to support the 
controller. However, just like their USA counterparts, Japanese BIOSes and 
games do not work with the XE-1AP in genplus-gx.

Original comment by vaguerant on 18 Jun 2013 at 9:24

GoogleCodeExporter commented 9 years ago
Thanks, I didn't know it was supported in some CD games as well, I will have a 
look but I doubt the software support implementation is different from cart 
games and I do not see why my emulation code would not work for CD games 
specifically.
To be sure if this controller is really supported and it was meant to be used, 
the best way would be to find the game manuals.

However, there are zero chances that this controller is supported by CD bootrom 
(any model) so, in the case of japanese bios which requires you to enter the CD 
player interface to start the game, i guess you would have to start with a 
normal gamepad and switch to xe-1ap when the CD is being loaded, before game 
initializayion program really starts.

Original comment by ekeeke31@gmail.com on 18 Jun 2013 at 12:19

GoogleCodeExporter commented 9 years ago
I just managed to get Japanese After Burner III working with the XE-1AP, so it 
looks like you're correct and there's no issue with your code. Apologies for 
the false report. AF3 does the controller check on the title screen, 
specifically. If you switch early, during the attract sequence, any input will 
be ignored (but if you let it sit long enough, you'll eventually reach the 
title screen and the XE-1AP is picked up). Once the XE-1AP has been recognised, 
"ANALOG PAD" is displayed on the title screen, in place of "CONTROL PAD" for a 
normal 3/6-button pad.

Notably, the USA version does /not/ support the XE-1AP. Instead, it uses the 
controller detection code to add support for the 6-button controller--the 
Japanese game is limited to three buttons. The title screen thus displays 
"CONTROL PAD" (3-button) or "6 BUTTON PAD". The XE-1AP is not registered at 
all, with no notation on the title screen, as if all controllers have been 
removed.

While it now seems unlikely that genplus-gx is the issue, I still haven't been 
able to successfully use the XE-1AP in Night Striker or Star Blade. They have 
no obvious display of the currently used controller and either don't register 
1AP inputs at all or do it wrong in my testing (in theory you could play Night 
Striker--it's just that you're constantly firing, Mode maps to Up, Start maps 
to Down, B maps to D-pad right and C maps to D-pad left). If these games do 
indeed support the controller, it's likely a matter of finding the correct time 
and place to insert it.

Original comment by vaguerant on 22 Jun 2013 at 6:20

GoogleCodeExporter commented 9 years ago
Well that's convenient. This post was made three weeks ago on Sega-16, by an 
XE-1AP owner:

http://www.sega-16.com/forum/showthread.php?4367-Official-Sega-16-Haul-Thread-4-
0&p=584579&viewfull=1#post584579

In it, the poster states that Night Striker requires the 1AP to be in the 
second controller slot, with a standard pad in slot one. genplus-gx currently 
only supports putting the analog controller in slot one, so this change is 
likely necessary to allow use of the controller.

Notably, the post also claims that compatibility spans all game versions of 1AP 
titles, which seems to be wrong from my experience with After Burner III. It 
also again lists Star Blade as a 1AP game, though I've had no success using it 
there as yet.

Original comment by vaguerant on 22 Jun 2013 at 6:51

GoogleCodeExporter commented 9 years ago
Bah, Starblade is a jerk. If you have the XE-1AP in slot 1 and a standard MD 
pad in slot two, it will ignore the analog controller's inputs entirely, 
handing control over to player two's digital pad. I pretty much always have a 
standard pad set in slot 2 because a full cycle of slot 1's inputs leaves it 
there by default. Messing around with the slot 2 controls in r810 I found that 
setting it to someone other than a standard pad (e.g. none, the Activator, 
another XE-1AP) makes the game start listening to the inputs on slot 1 again. 
No idea why they would have made this design choice, assuming it was 
intentional. Same behaviour on Japanese and USA version games.

I can also confirm the slot 2 XE-1AP support working perfectly for Night 
Striker, as I'm sure you're already aware. That means all games currently 
expected to work are working, with the only exceptions being whatever 32X games 
use the 1AP. Thanks for the excellent support of such a niche accessory.

Original comment by vaguerant on 9 Jul 2013 at 11:07