About Peripherals

For anything related to IO (joypad, serial, XE...)

Moderator: BigEvilCorporation

Eke
Very interested
Posts: 821
Joined: Wed Feb 28, 2007 2:57 pm
Contact:

About Peripherals

Post by Eke » Tue Jun 05, 2007 9:00 am

Hi folks,
again, I'm looking for some informations to improve the compatibility of the NGC Genesis PLus port and it looks like this forum is the only one around that is still really active for Megadrive technical stuff :)

Actually, I have some questions about special peripherals such as the Sega Menacer and the Multiplayer adapters.

First, about the Menacer (and other compatible lightguns),I only found infos in the Charles Mc Donald's VDP documentation, and if I'm not getting wrong, it works quite like the MS Light Phaser except that the console uses INT2 to inform the software that TH input value has changed (no more polling needed on the input ports) which means that the pixel lightbeam has been detected.
For people who know how software usually do to support lightgun on the Megadrive, do you think the following implementation in an emulator could work ?
1) at the beginning of each frame, use analog input to update the current X and Y position of the "simulated" lightgun

2) in the main loop, at each line, test the distance between the current line and the lightgun Y pos

3) if the distance is less than a determined range (let say 5 lines) and TH is set as an input then:

. set TH bit in IO data port to zero.

. if Hcount latch is set in VDP register, then fix the value of Hcounter that must be returned on next HVC read (made some calculations according to the current lightgun Hposition and the former calculated Vertical distance to simulate a "circular" area)

. if INT level 2 is enabled, trigger it


Secondly, about multiplayer adapters, I didn't found any technical informations on how software use them. I could directly read in Gens sourcecode for TeamPlay support but I was wondering if technical notes exist ?


Any suggestions or help would be greatly appreciated :wink:
thanks

ob1
Very interested
Posts: 407
Joined: Wed Dec 06, 2006 9:01 am
Location: Aix-en-Provence, France

Re: About Peripherals

Post by ob1 » Tue Jun 05, 2007 10:04 am

Eke wrote:Secondly, about multiplayer adapters, I didn't found any technical informations on how software use them.
Have you looked at Saturn pad management (http://www.antime.org/sega/docs.html)? If I read it right, you should find something useful.

Eke
Very interested
Posts: 821
Joined: Wed Feb 28, 2007 2:57 pm
Contact:

Post by Eke » Tue Jun 05, 2007 1:37 pm

Thank you, I would never have the idea to look in saturn's documentation :oops:
I finally found it in the SMPC user manual, referred as Sega TAP 3-line handshake protocol

Eke
Very interested
Posts: 821
Joined: Wed Feb 28, 2007 2:57 pm
Contact:

Post by Eke » Wed Jun 06, 2007 9:00 am

I also found some infos about the EA 4-Way Play in this "hidden" link:
http://cgfm2.emuviews.com/txt/io.htm

apparently, the first Sega Tap was not compatible with EA multiplayer games so they made the Sega Team Player which could be configured to be compatible with EA games (EXTRA mode) or with other multiplayer games (MULTI mode)
I wonder if Gens is supporting both modes

I'm also still trying to find programming infos about the Justifier and the Menacer, I wonder why they were not compatible between each other as they apparently use the same "lightbeam detection" technique :?:

Fonzie
Genny lover
Posts: 323
Joined: Tue Aug 29, 2006 11:17 am
Contact:

Post by Fonzie » Wed Jun 06, 2007 9:16 am

Yeah, strange thing around those guns.
Maybe one of those don't use the INT pin... They preferred pooling the H/V counter instead...

A strange thing is that some games let you choose the TV-border color... I don't recall the games but it is a bit weird to me assuming that the gun just generate an INT when crossing the TV beam (which is only visible when the screen flash white, maybe?).

Eke
Very interested
Posts: 821
Joined: Wed Feb 28, 2007 2:57 pm
Contact:

Post by Eke » Wed Jun 06, 2007 9:58 am

If I'm not mistaken, the INT is generated by the VDP when detecting a high to low transition on the TH input ... and this is only done if level 2 interrupt has been enabled by the software.
In complement (or alternatively), the VDP can also freeze the Hcounter if the software previously configured VDP register properly

So, everything is up to the software but the only one way for any lightgun to interract with the sytem is always to set TH input to 0. So, in my opininon, there is no reason for any software to have compatibility problem with this, it's probably more something with intial gun detection or maybe inverted inputs, who knows


EDIT: I disassembled the Menacer 6-in-1 ROM with IDA and the M.IDA script from this website.

1/ it seems that CTRL2 port is configured to B0h which means:
- D0, D1, D2, D3 and TH are inputs
- TL & TR are outputs
- the VDP detection for "high to low TH transition" is activated

It appears to be a common CTRL2 setting for all lightgun games (same configuration is used in Konami games), that's why lightgun always need to be plugged into PORT B.
This also means that the eventual additional buttons (I'm not sure how many press buttons the both lightguns have) could only be mapped to D0,D1,D2 or D3 pins (usually Left,Right,Up & Down for controllers)
If LightGun need to be configured or initialized , software could use TL and TR outputs.


2/ it seems that ANY of the DATA port are never accessed (which is not the case in games using the Justifier).
If the disassembly was correct (I don't know about the reliability of IDA ?), it makes me think that perhaps the Menacer switch the TH state to 0 only if it detected the light beam AND if the fire button has been pressed, which makes him uncompatible with Justifier's softwares that are probably waiting for one of the input to tell them that the button has been pressed ...

User avatar
TmEE co.(TM)
Very interested
Posts: 2307
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Wed Jun 06, 2007 4:29 pm

How does these light guns work ? I'll pull the trigger, INT2 happens, then soft reads the gun status (if gun sees the beam, it has some signal high)
then according to H and V raster pos, it determines if an target needs to be destroyed or not ?
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

Mask of Destiny
Very interested
Posts: 566
Joined: Thu Nov 30, 2006 6:30 am

Post by Mask of Destiny » Wed Jun 06, 2007 7:31 pm

TmEE co.(TM) wrote:How does these light guns work ? I'll pull the trigger, INT2 happens, then soft reads the gun status (if gun sees the beam, it has some signal high)
then according to H and V raster pos, it determines if an target needs to be destroyed or not ?
INT2 doesn't happen when you pull the trigger. INT2 happens when the gun senses the raster beam from your TV. Since the raster beam position is directly linked to the incoming signal on a CRT SDTV, you know that the gun is pointing at the pixel you're currently outputting. So the VDP locks the H/V counter (assuming the appropriate register bit is set correctly) when this happens providing a record of which pixel the gun was aiming at. Pulling the trigger is just like pushing a button on a standard pad.

User avatar
TmEE co.(TM)
Very interested
Posts: 2307
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Wed Jun 06, 2007 9:40 pm

Hmmm... it sounds so unefficient... but least it works I don't quite get it... On NES, you whiten up the whole screen, leaving black box where the target is and the rest is up to soft to determine what gun sees. Each target requires one frame... I'll try to interface NES gun clone to MD...

Slightly offtopic: Could be INT2 used to interface PS/2 keyboard with MD ?
CLK is connected to TH, and DATA to any other signal, when the keyboard shows activity, INT2 happens, and software does the rest...
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

Fonzie
Genny lover
Posts: 323
Joined: Tue Aug 29, 2006 11:17 am
Contact:

Post by Fonzie » Wed Jun 06, 2007 9:51 pm

Wow, mad nes method LOL! :D
mmm... it sounds so unefficient...
No, I think it is quite efficient :D
For exemple, you could even use the gun as a real mouse pointer (like in the ending of Snatcher/megacd) to pick letters on screen ;)
because you get a quite precise X/Y coordinates :)

I did not know you could use the INT to lock H/V counter, I thought you had to quickly pool the H/V + add a correction value. Nice to know, thx!

commodorejohn
Very interested
Posts: 70
Joined: Tue Mar 06, 2007 6:30 pm

Post by commodorejohn » Thu Jun 07, 2007 5:17 pm

Here's a different peripheral question: I've read that Saturn controllers are compatible with the Genesis; do they function as 6-button controllers, or what?

Mask of Destiny
Very interested
Posts: 566
Joined: Thu Nov 30, 2006 6:30 am

Post by Mask of Destiny » Thu Jun 07, 2007 5:24 pm

They're electrically compatible in the sense that the Saturn controller port and the Genesis controller port are both 7-bit bi-directional I/O ports. Unfortunately, the protocol is different so a Genesis game won't know what to do with a Saturn controller. You could support them in code you write however.

I'm not sure if the same is true of the reverse though. The Saturn hardware manual documents all the Genesis peripheral protocols (with the exception of the A1-XE). I doubt there are any games using direct I/O mode that support Genesis peripherals, but it's possible that games using the SMPC for I/O might.

Eke
Very interested
Posts: 821
Joined: Wed Feb 28, 2007 2:57 pm
Contact:

Post by Eke » Thu Jun 07, 2007 7:48 pm

I was wrong about the Menacer game, it did read the DATA2 register and i've been able to simualte lightgun by triggering a level2 interrupt and mapping the Fire Button to D1 (0x02 mask). START button (pause) is mapped to D3 input (0x08 mask)

I'm still having problem to understand how the TeamPlayer works sadly :(

TascoDLX
Very interested
Posts: 248
Joined: Tue Feb 06, 2007 8:18 pm

Post by TascoDLX » Fri Jun 08, 2007 5:49 am

Eke wrote:I was wrong about the Menacer game, it did read the DATA2 register and i've been able to simualte lightgun by triggering a level2 interrupt and mapping the Fire Button to D1 (0x02 mask). START button (pause) is mapped to D3 input (0x08 mask)
I believe a common mapping of buttons is SCAB -- from D3 down to D0: START, C, A, B -- with the trigger mapped to the A button. This, however, is merely a formality since the Menacer's buttons aren't labelled. But it can be useful if you want your game to support either the gamepad or the Menacer.

For the more curious among us, the Menacer is covered in US patent 5,351,969.

Funny thing about the Menacer is that there seems to be a significant delay between the gun sending its signal and the HV counter latch. The software needs to translate the HV value into more accurate coordinates.

Even funnier is that the delay seems to vary from game to game. For instance, the correction for Menacer 6-in-1 is different than that of T2 - The Arcade Game, even though you'd expect it to be the same. There's some unknown factor that affects this delay, whether it's I/O, VDP, or whatnot.

This is also the official reason that Fusion doesn't draw its own cursor when emulating the Menacer.

Eke
Very interested
Posts: 821
Joined: Wed Feb 28, 2007 2:57 pm
Contact:

Post by Eke » Fri Jun 08, 2007 8:07 am

Thanks a lot for these precisions... and for the patent number ;)

Because i'm limited to emulate the lightgun with the analog stick, I will only need this feature in the Menacer 6-in-1 game, since other "lightgun" games are also playable using D-Pad (which is already controlled by the analog stick ;) )


Here's what it said:
The mobile transceiver includes an electro-optic detector for observing when a scan line crosses a target area. Each time a scan line is detected, the mobile transceiver transmits a pulse to the fixed unit, based upon which the gaming unit translate the pulse into position data based on the time of its detection.
So, maybe the pulse length for TH input is indeed important, which means that INT2 or HVC latch doesn't occur immediately and that the software has to make some "correction" after reading the latched value.
What is sure is that the 6-in-1 game read the HV counter in the INT2 handler.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest