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

SMS Phaser Light Gun fires to the right #16

Open
thorr2 opened this issue Sep 9, 2023 · 43 comments
Open

SMS Phaser Light Gun fires to the right #16

thorr2 opened this issue Sep 9, 2023 · 43 comments

Comments

@thorr2
Copy link

thorr2 commented Sep 9, 2023

In the SMS core, using SNAC the Phaser Light Gun hits the target. In the new MegaDrive core, the gun fires to the right and inch or two of where you aim. This can easily be seen in the SMS game Gangster Town when shooting at the letters to type in your name. Perhaps there is a bit of lag. I am using a CRT with direct video.

@birdybro
Copy link
Member

birdybro commented Sep 9, 2023

https://www.smspower.org/forums/17543-LightGunAccuracyBetweenCRTs

This kind of behavior can be seen normally in more modern CRT's on real hardware. What kind of CRT do you have? Sony WEGA Trinitrons had significant delay and someone even patched the same game you tested with to offset the delay manually.

Someone also got different results by just tweaking the brightness on their display. The original lightgun for the SMS had a series of filters which added delay on purpose, here's a schematic someone drew up, which might be helpful:

lightphaser3050_145

The official algorithm that was supposed to be used in roms is referenced in this thread:

https://www.smspower.org/forums/17367-LightPhaserCodeAlgorithm

Gangster Town apparently didn't use the identical official Sega algorithm, and some other games didn't either. Do you see a difference between Safari Hunt and Gangster Town?

EDIT: From one of the comments in the algo thread:

I remember I had some similar problem with a CRT that had a DNR (Digital Noise Reduction) system. I turned that off and it disappeared.

I suggest you tweak the settings on your CRT to see if that changes the results first.

@thorr2
Copy link
Author

thorr2 commented Sep 9, 2023

Thanks. I tried several games and the "SMS" core (originally part of the Game Gear core perhaps) works perfect with the same CRT. The "MegaDrive" core loading various SMS games always fires slightly to the right. So changing the CRT wouldn't help since it already works accurately with the SMS core. I have a 27" JVC iArt flatscreen. I just tried Safari Hunt and it is the same. Works in SMS, and fires to the right in MegaDrive. Thanks again.

@sorgelig
Copy link
Member

probably lightgun delay need to be adjusted but i have no lightgun neither crt tv...

@sorgelig
Copy link
Member

I've changed sensor delay for SMS games. Please try unstable build.

@thorr2
Copy link
Author

thorr2 commented Sep 10, 2023

Ok, I will look for it and report back...

@thorr2
Copy link
Author

thorr2 commented Sep 10, 2023

Currently the one on discord and github is 9 hours old. I will keep checking...

@thorr2
Copy link
Author

thorr2 commented Sep 10, 2023

Thank you for trying. Unfortunately, it does not appear to have made any difference. The gun fires to the same spot to the right in the new unstable version as before.

@sorgelig
Copy link
Member

Ok, i see.. That delay is for emulated lightgun. When real one is used over SNAC, then it interacts directly with VDP.
Not sure if it can be fixed to suit all TVs.

@thorr2
Copy link
Author

thorr2 commented Sep 10, 2023

Thanks again. It's only a guess, but I am thinking there might be a tiny bit of lag to the display in the core in general where the SMS core doesn't have any lag. I am not sure how to test for display lag though.

@thorr2
Copy link
Author

thorr2 commented Sep 10, 2023

The third post here is interesting. It might be input lag, although he might mean lag between the TV's video input and when it reaches the display, not sure. https://www.smspower.org/forums/17543-LightGunAccuracyBetweenCRTs It's also possible that the real MegaDrive running SMS games has the lag. I don't have real console hardware to test with.

@sorgelig
Copy link
Member

Thanks again. It's only a guess, but I am thinking there might be a tiny bit of lag to the display in the core in general where the SMS core doesn't have any lag. I am not sure how to test for display lag though.

if you are using SNAC for input and VGA output then there is no additional delay involved. So it must be how original Megadrive HW is working.

@birdybro
Copy link
Member

birdybro commented Sep 10, 2023

Thanks. I tried several games and the "SMS" core (originally part of the Game Gear core perhaps) works perfect with the same CRT. The "MegaDrive" core loading various SMS games always fires slightly to the right. So changing the CRT wouldn't help since it already works accurately with the SMS core. I have a 27" JVC iArt flatscreen. I just tried Safari Hunt and it is the same. Works in SMS, and fires to the right in MegaDrive. Thanks again.

The SMS core has a report of SNAC drift as the axis is moved around the screen.

MiSTer-devel/SMS_MiSTer#162

Even the Analogue Mega SG's SMS core has the same problem. The user did confirm that it was very accurate on the power base converter on real hardware. The observed drift when moving to the right indicates clearly that the delay is higher than original hardware on the Analogue Mega SG because the scanlines move left to right, so it must go over some threshold and begin to be visible to the player.

You can see how the SMS core in this case actually has too little delay, and this person is not using the same CRT tv that you are. There are too many confounding factors.

If the Megadrive core's response is to the right of where you aim regardless of where you are in the screen, that means there must be some delay added. It could be from your TV, distance from the phaser to the TV, the phaser itself potentially having failing components (unlikely for just resistors, but it's possible a failing resistor could increase or decrease the delay). If you move right up next to the TV does it become more accurate? etc...

There's too many confounding factors. If the delay cannot be reduced at all in the core, then it might even be "faster" than original hardware which would mean it would be too far to the left of the gun when in the center of the screen (all other things being equal). But all other things can't be tested equally in this instance, so any adjustment is going to solve it for one person, but potentially cause inaccuracies for another.

@thorr2
Copy link
Author

thorr2 commented Sep 10, 2023

Thanks! That is great information about the other reported issue, and the idea of firing at point blank range at the CRT. I have two Phaser Light Guns. I found that one is accurate in the SMS core, and the other is a bit off. Neither is accurate in the MegaDrive core. I was basing my above posts on that information. After reading your latest post, I tried them both at point blank range on both cores which should bring them both to within nearly the same accuracy because they don't have far to travel, and this seemed to be the case. At point blank range, BOTH cores experience the problem reported in the SMS_MiSTer#162 link where left to right on the screen affects the accuracy. There is an exact horizontal shift between the SMS and MegaDrive core that is uniform across the screen. The MegaDrive is always 1-2 inches to the right of where the SMS is when shooting at any given spot. The SMS core is the one that is most accurate between the two by far though. Even when shooting all the way on the left side of the screen, the MegaDrive still fires a good 3/4 of an inch at least to the right. On the right side, it is a good 1.5 inches. With the SMS core, the left side is 3/4 of an inch to the left, and the right side is spot on.

In summary, the SMS core accuracy is .75 inches to the left to spot on. The MegaDrive core accuracy is .75 inches to the right to 1.5 inches to the right. I have no idea if this is the same as real hardware or not. I wish there was a way to test this without buying a MegaDrive console and SMS adapter.

My main concern is about accuracy of the core, not so much about accuracy of the light gun. If there is a hidden lag somewhere in the code, I want to expose that and get it fixed. Thanks again both of you!

@birdybro
Copy link
Member

Are the two phaser light guns easy to non-destructively open up and take pictures of? I'm just curious whether or not the electronics inside are identical. Given it was 1980's Sega, it wouldn't surprise me if there were significant hardware variations randomly on the same model. :P

@thorr2
Copy link
Author

thorr2 commented Sep 10, 2023

No, my accurate one was actually broken a bit in shipping and I was able to take it apart and adjust it to perfect accuracy when putting it back together and the back plate is hot-glued in place. There is a plastic lens inside that looks like the shape of two big contact lenses back to back so it bows outward on both sides. I am not surprised there are differences between guns because the sensor position is bendable/adjustable. Once I got the lens in the right place and orientation (not sure if it can be backwards or not) I bent the sensor until the gun was accurate and hot-glued it. I don't think non-broken ones are easily taken apart.

@sorgelig
Copy link
Member

Since i cannot test it because i have no CRT TV neither Lightgun, i can give an idea to those who can modify the code and test. If you need a negative sensor delay then you can delay the sensor signal for a whole line minus required delay.

@thorr2
Copy link
Author

thorr2 commented Sep 16, 2023

Thanks! You found a way to potentially affect this through SNAC? I am home again and can test for you if you want. The required delay should be pretty short. You could try changing it and I can tell you if it makes any difference and in what way. Eventually I would like to learn how to compile it myself and then I could change and test it myself, but I think that might be a much larger project. Another idea would be to have a core menu setting for the delay, and then everyone would be able to adjust it for their particular situation. This could be implemented after initial testing to make sure it affects it at all before going through the trouble of making a core menu setting.

@birdybro
Copy link
Member

@thorr2 I'm looking into it to make you a test build. I don't have a way to test it either, but I thought of way to make it variable and attach it to an OSD option. Sorg's hint gave me the good idea ;)

@birdybro
Copy link
Member

Okay @thorr2 I have a testing task for you :)

Download this core, make a list of light gun games on SMS to test, then go to the input submenu and adjust the Gun Delay Adj option to whatever works best for each game. Please take note of what the number is that worked best for each game. Some of the lower delay numbers might not even register the position because they might be too fast, that is somewhat expected.

I'm betting it's going to be 34 that is the best fit, since that's the same delay as the SMS core, but we'll see. Then I could just add an automatic toggle upon loading SMS games that switches the delay conditionally.

Then post that list.

Here's the core you can test for me, in a zip:

MegaDrive.zip

@thorr2
Copy link
Author

thorr2 commented Sep 17, 2023

Thanks! Sorry for the delay in testing. I extensively tried Gangster Town which is the easiest to use because it has a nice grid and you can see the bullet, and unfortunately I don't think the delay is doing anything. I tried saving the settings and reloading the core after each adjustment just to be sure. Are you sure you aren't adjusting the "emulated light gun" delay, as Sorgelig mentioned above?

@birdybro
Copy link
Member

birdybro commented Sep 17, 2023

Probably that's what I'm doing. I'll look at it again. I'm doing too many different things in parallel, like an FPGA design with crossed clock domains! :D

@birdybro
Copy link
Member

@thorr2

Try this one for me. I might have successfully adjusted the timing slightly.

MegaDrive.zip

@thorr2
Copy link
Author

thorr2 commented Sep 24, 2023

@birdybro

Thanks for trying. It didn't make any difference. At point blank range, I can consistently hit the same pixel and it is the same on the released core as this one.

The way I see Sorgelig's idea above is a bit of a hack to get around the problem and I don't know if it is even possible, but the idea as I understand it would be to somehow detect if the Phaser is being used via SNAC, and when the trigger is pulled, wait for a scanline plus or minus an adjustment delay before reacting to it. You wouldn't want to have this delay if a normal controller is plugged in though. Instead of this, my main hope was that there was a small latency built into the core that is causing the light gun to be off, and that could be found and fixed, and that would automatically fix the light gun.

@birdybro
Copy link
Member

birdybro commented Sep 24, 2023

There is no latency that I can see baked into the core at all like that for SNAC. The phaser's TH (sensor) and TL (trigger) signals are just wired directly into the chips that nukey decapped. If there is some kind of delay than it's either matching original hardware (MegaDrive + Power Base Converter) or it's something nukey will have to mess with. I would hesitate to even ask nukey to look into it until we had confirmation from original hardware that is comparable to what this core is simulating. All I did was assume that the 2x mclk was too fast and you might have been seeing it one scanline above and to the right (meaning it was too fast), so I wired the 54mhz clock to the chip that handles gamepad IO stuff. I will mess with a delay hack as well, that was my other thought, to do a counter for per quart of a scanline timing and then make that adjustable fo rsnac and see how it goes. I'll mess with it some more. thanks for testing!

@thorr2
Copy link
Author

thorr2 commented Sep 24, 2023

I am thinking the latency would be between the chip and the display, not the Phaser and the chip. There is at least one Youtube video that I saw where a person tested a lightgun with the MegaDrive and Power Base Converter. I will see if I can contact them and have them try it at point blank range with Gangster Town and see if it is lined up or to the right.

@birdybro
Copy link
Member

birdybro commented Sep 24, 2023

The delay could be anywhere from trigger --> io chip --> vdp --> display --> sensor --> io chip --> vdp

The issue is, it's SNAC, so there is no added delay external to the core by the framework and the glue logic modules. That's the reason why I'm skeptical that it's an added delay that is different than original hardware, that's all I mean :)

@thorr2
Copy link
Author

thorr2 commented Sep 24, 2023

I actually sort of hope the real hardware is the same way, so it is confirmed to be "perfect", and if not, I hope we can track down the cause of the issue.

@thorr2
Copy link
Author

thorr2 commented Sep 24, 2023

I am still searching for the Youtube video, but I found this one that shows the inside of the light gun: https://www.youtube.com/watch?v=r5rw2ZACPcs

Edit: He has the Genesis and Power Base Converter, and at the end of the video, he said it was pretty accurate.

So now the question is, is the SMS core accurate, or is the Megadrive core accurate? Both my guns at point blank range are accurate in the SMS core especially on the right side of the screen, and quite a bit off to the right in the Megadrive core.

@thorr2
Copy link
Author

thorr2 commented Sep 24, 2023

I found the video I was thinking of, but he doesn't have a CRT: https://www.youtube.com/watch?v=vPwMPb-XN_0&t=612s I posted a comment on the previous video so hopefully he can help test. The video is pretty old though.

@birdybro
Copy link
Member

I had watched that video too :P I was looking for some example somewhere of this. Going to ask some sms power! community people.

@skooterblog
Copy link

I just got my Genesis SNAC today and I can confirm this issue.
In the Mega Drive core, the shots always register a little to the right.
With the Master System core it registers a little to the left.
I'm using MiSTer through SCART RGB.
With the same CRT TV, same lightgun, and real hardware through SCART RGB the shots register correctly.
On the other hand, real hardware through Composite Video in this same TV also registers shots a little to the right, like the Mega Drive core.

@thorr2
Copy link
Author

thorr2 commented Sep 30, 2023

On the other hand, real hardware through Composite Video in this same TV also registers shots a little to the right, like the Mega Drive core.

Thanks! A few questions:

  • What real hardware do you have? A Sega Master System or a Genesis/Mega Drive with Power Base Converter?
  • Using Gangster Town, if you shoot the gun point blank at the screen, do you see a difference between the left side of the screen and the right side of the screen for where the bullet lands? How do the cores and the real hardware compare? Do you have Gangster Town for your real hardware, or what are you using to test?
  • On your real hardware, is the screen shifted left/right when you compare Composite and SCART RGB, or do all the pixels line up the same on the screen?

@skooterblog
Copy link

I have a Sega Genesis (model 1, VA6) and a Tec Toy Master System II (composite only). I don't have the Gangster Town cartridge. I'm using a Mega Everdrive Pro and a Master Everdrive X7. For the other questions, I'll have to test and come back later.

@thorr2
Copy link
Author

thorr2 commented Oct 1, 2023

Thanks! I had to look those up. It appears that the Mega Everdrive Pro will allow the Genesis to play SMS games, and the Tectoy Master System II is a Brazil distributed SMS.

When you answered the questions above, which hardware did you use for composite?

I am curious if the two real systems act differently using composite. That would give an apples to apples comparison between the Genesis and the SMS. If they both act the same, then the cores should also act the same. If the Genesis is to the right of the SMS, both in composite, then they will be acting like the cores are acting.

@skooterblog
Copy link

Thanks! I had to look those up. It appears that the Mega Everdrive Pro will allow the Genesis to play SMS games, and the Tectoy Master System II is a Brazil distributed SMS.

Correct.

When you answered the questions above, which hardware did you use for composite?

Both. I can't see any difference between the Master System II and the Sega Genesis through composite.

I made a video to show the differences more clearly:

https://youtu.be/vhREE67D7lc

@thorr2
Copy link
Author

thorr2 commented Oct 1, 2023

Thanks! The video is super helpful. From the video, here is what I see:

  • Both the Genesis with Component and the MiSTer Megadrive core with Component fire in the same spot (slightly to the right). This leads me to believe that there is no issue with the Megadrive core to be fixed.
  • You stated that Composite is consistent between SMS and Genesis. Composite SMS fires quite a bit to the right. So does Composite Genesis if they are the same as you stated (not available in the video).
  • As mentioned above, Genesis Component is slightly to the right. MiSTer Megadrive Component is slightly to the right (matching). MiSTer SMS Component is quite a bit to the left. They should be matching, since Genesis and SMS composite match. This leads me to believe the problem is actually with the SMS core, not the Megadrive core.
  • SMS with composite has 33 dots on the left, 25 dots on the right side of margin space
  • Genesis with component has 32 dots on the left, 26 dots on the right of margin space
  • SMS core with component has 29 dots on the left, 26 dots on the right of margin space
  • Megadrive core has 31 dots on the left, 26 dots on the right of margin space
  • Different lines can have different pixel counts and it was impossible to get the same line every time for comparison in the video but I expect either side to only be off by at most one pixel. The SMS core seems to be the most "off" in terms of pixel count.
  • After rewatching it, it seems the Genesis Component might be ever so slightly more accurate where the MiSTer Megadrive is ever so slightly more to the right, but it is close.

Bottom line is, I should recalibrate the aim of my Phaser to the Megadrive core. The Megadrive core seems to be accurate. The SMS core is not, and it might have to do with the video mode having fewer pixels on the left side than it should. I think I calibrated my Phaser to the SMS core previously which is why that one was accurate when I aimed. It will be interesting to see how it behaves at point blank range after recalibrating.

@thorr2
Copy link
Author

thorr2 commented Apr 3, 2024

Just a quick and hopefully informative update. I got a different CRT TV because the flat screen CRT I was using had horizontal linearity issues. For example, when playing Super Mario Bros or Castlevania II and walking left or right, pipes and other vertical objects would stretch and contract depending on where they were horizontally positioned on the screen. When putting up a grid test pattern and measuring the squares, different squares were wider than others. My new CRT TV has a rounded tube, and I now have nearly perfect geometry on the screen.

Now when I test the Phaser light gun with the "SMS" core, one of my two guns is almost perfectly accurate no matter where on the screen I shoot. My other light gun is always a bit to the right. I think it needs to be re-aimed internally by bending the metal mount for the sensor inside which is what I did with the first gun when only the SMS core was available and the Nuked Megadrive core didn't exist yet.

When I test with the Megadrive core, the gun that was previously perfectly accurate (and the other one) are way off to the right. If I aim at the middle of a letter, they hit in the blank space between the two of letters (in the middle between the letter I aimed at and the letter to its right). This is true across the whole screen.

In my previous post, I came to the conclusion that the Megadrive core was better than the SMS core. However my gun is calibrated to the SMS core. I think if I bent the internal sensor to point properly with the Megadrive core, that would be the best solution.

The point of this post is that bad horizontal linearity on different CRT's can and will affect the accuracy of the Phaser light gun with different accuracy when shooting at different spots left to right on the TV. Flat TV's will almost always have more problems with this than rounded TV's. Bottom line, with a properly physically internally calibrated light gun, there is most likely nothing to fix in this core, but maybe in the SMS core there is. If that core ever gets a nuked core version, it might work better.

@birdybro
Copy link
Member

birdybro commented Apr 3, 2024

The phenomenon you are describing from your first CRT can also be exacerbated by wear and tear on the components or even a different design. Some models of the early 2000's trinitrons had a variation in the size of objects on the screen relative to their brightness so you could see a grid pattern "breathing" as you increase brightness, etc... Some within the same year had a different design and you wouldn't observe this.

@thorr2
Copy link
Author

thorr2 commented Apr 3, 2024

Yep, my previous CRT also had heavy breathing issues when the screen would go from black to white for example. It would grow and shrink with the brightness. There are ways to fix this but I didn't want to open the back of the TV to adjust the G2 on the flyback. It was just too much of a pain with the huge TV and not having anyone to help lift it. Thankfully my new CRT solved (well enough anyway) all of the previous issues and only introduced one - a slightly noisy flyback that can be heard when there is no sound playing from the TV to drown it out.

@hugonl31
Copy link

Is there an SMS core available that addresses the Phaser shooting left? If I understand it correctly, adding a slight delay should fix this?

@thorr2
Copy link
Author

thorr2 commented Apr 25, 2024

Try the Megadrive core.

@hugonl31
Copy link

Will my SMS SNAC work with the genesis and also the Atari 7800 btw? Or does the Atari have different pinout.. Sorry for offtopic

@skooterblog
Copy link

It is the same SNAC for Atari, SMS and Genesis.

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

No branches or pull requests

5 participants