Lethal Weapon (Ch) [U][!].unf zapper support
Moderator: Moderators
Lethal Weapon (Ch) [U][!].unf zapper support
The unlicensed game Lethal Weapon (Ch) [!].unf works in FCEUX and Nestopia; however, the Zapper support only works accurately in FCEUX. Both react to the Zapper trigger. But, Nestopia seems to register the hits only 20% of the time.
Since there is no wiki page on mapper UNL-TF1201, I used the FCEUX source as a guide to add a mapper to my emulator. Interestingly, the result behaves likes Nestopia. This suggests that the Zapper implementation in FCEUX is different from the wiki description. Anyone have any idea on how I can improve my Zapper implementation to enable this game to function? Lethal Weapon (Ch) [!].unf actually looks like a really awesome Zapper game worth supporting.
Since there is no wiki page on mapper UNL-TF1201, I used the FCEUX source as a guide to add a mapper to my emulator. Interestingly, the result behaves likes Nestopia. This suggests that the Zapper implementation in FCEUX is different from the wiki description. Anyone have any idea on how I can improve my Zapper implementation to enable this game to function? Lethal Weapon (Ch) [!].unf actually looks like a really awesome Zapper game worth supporting.
Re: Lethal Weapon (Ch) [U][!].unf zapper support
Random Q: do other zapper-based games work fine for you (ex. Bayou Billy, Duck Hunt, Freedom Force, Operation Wolf (I intentionally picked games from 4 different companies))?
- rainwarrior
- Posts: 8735
- Joined: Sun Jan 22, 2012 12:03 pm
- Location: Canada
- Contact:
Re: Lethal Weapon (Ch) [U][!].unf zapper support
Just curious, how do you implement the trigger bit? Do you fill it with the state of the mouse button, or do you make it turn off a few frames after a click?
The real zapper trigger generates a trigger-on signal only for a few frames after you pull it, doesn't matter how long you hold it down. There's also a lot of noise/bounce on this action so you might get spurious trigger-off frames in the middle; many games have some sort of software de-bounce filter to deal with this, which might interact poorly with your implementation, depending on how you did it.
FCEUX doesn't track the position of the mouse except when you click the mouse for some reason, which is kind of a poor way to do it (I have no idea why it isn't tracking all the time), but games in general don't try to read the light sensor except in response to a zap anyway.
The real zapper trigger generates a trigger-on signal only for a few frames after you pull it, doesn't matter how long you hold it down. There's also a lot of noise/bounce on this action so you might get spurious trigger-off frames in the middle; many games have some sort of software de-bounce filter to deal with this, which might interact poorly with your implementation, depending on how you did it.
FCEUX doesn't track the position of the mouse except when you click the mouse for some reason, which is kind of a poor way to do it (I have no idea why it isn't tracking all the time), but games in general don't try to read the light sensor except in response to a zap anyway.
Re: Lethal Weapon (Ch) [U][!].unf zapper support
Yes. Thanks for the suggestion and I just tested those games to confirm. I can hit those targets with the click of a mouse.koitsu wrote:Random Q: do other zapper-based games work fine for you (ex. Bayou Billy, Duck Hunt, Freedom Force, Operation Wolf (I intentionally picked games from 4 different companies))?
For NTSC, my emulator keeps the sensor active for 26 scanlines and the trigger is active for 6 frames regardless of how long the mouse button is held.rainwarrior wrote:Just curious, how do you implement the trigger bit? Do you fill it with the state of the mouse button, or do you make it turn off a few frames after a click?
The real zapper trigger generates a trigger-on signal only for a few frames after you pull it, doesn't matter how long you hold it down. There's also a lot of noise/bounce on this action so you might get spurious trigger-off frames in the middle; many games have some sort of software de-bounce filter to deal with this, which might interact poorly with your implementation, depending on how you did it.
FCEUX doesn't track the position of the mouse except when you click the mouse for some reason, which is kind of a poor way to do it (I have no idea why it isn't tracking all the time), but games in general don't try to read the light sensor except in response to a zap anyway.
I experimenting with those values, but it did not seem to have a significant effect. FCEUX appears to be doing something special.
Re: Lethal Weapon (Ch) [U][!].unf zapper support
There should be no contact bounce in the zapper.rainwarrior wrote:There's also a lot of noise/bounce on this action so you might get spurious trigger-off frames in the middle
Obviously, I can't speak to clones, but the first-party Zapper has the following circuit for the trigger:
Code: Select all
+5V -- 10kΩ -+
|
401X.4 ------+-//--+---+
| |
10µF trigger
| |
Gnd -----------//--+---+
The 10kΩ resistor inside the console, combined with the 10µF capacitor inside the zapper, makes a time constant of 0.1 seconds; the properties of the 74'368 in the console(¹) mean that once the trigger has been released it should then take somewhere around one time constant after the trigger has been released to read as +5V (i.e. 0, '368 is inverting), or approximately 6 frames on NTSC decks.
¹: Phillips 74HC family VIL = 30-47% of Vdd @ Vdd = 4.5-6V ; VIH = 53%-70% of Vdd @ Vdd = 4.5-6V ; one time constant ≔ 63%
Last edited by lidnariq on Thu Jun 02, 2016 4:53 pm, edited 1 time in total.
Re: Lethal Weapon (Ch) [U][!].unf zapper support
That's exactly what my emulator does and it ends up behaving like Nestopia instead of FCEUX.lidnariq wrote:The on resistance of the trigger switch is more or less 0; when triggered it basically discharges the capacitor entirely and immediately.
The 10kΩ resistor inside the console, combined with the 10µF capacitor inside the zapper, makes a time constant of 0.1 seconds; the properties of the 74'368 in the console(¹) mean that once the trigger has been released it should then take somewhere around one time constant after the trigger has been released to read as +5V (i.e. 0, '368 is inverting), or approximately 6 frames on NTSC decks.
Re: Lethal Weapon (Ch) [U][!].unf zapper support
No it doesn't - I have a real Zapper (one of the orange ones), and if you pull the trigger slowly until it makes a soft click it sends trigger-on as long as you hold it there, but if you pull it the rest of the way it will click much more loudly and clear the trigger signal. It's sort of like a double-action revolver, where the trigger-on signal corresponds to the hammer being pulled back all the way.rainwarrior wrote:The real zapper trigger generates a trigger-on signal only for a few frames after you pull it, doesn't matter how long you hold it down.
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.
P.S. If you don't get this note, let me know and I'll write you another.
- rainwarrior
- Posts: 8735
- Joined: Sun Jan 22, 2012 12:03 pm
- Location: Canada
- Contact:
Re: Lethal Weapon (Ch) [U][!].unf zapper support
Maybe "bounce" is an incorrect way to describe it, but I think the problem is seen on the leading edge of engagement if you pull the trigger slowly, or wiggle on the point of engagement.lidnariq wrote:There should be no contact bounce in the zapper.rainwarrior wrote:There's also a lot of noise/bounce on this action so you might get spurious trigger-off frames in the middle
Maybe the blips are 6 frames, my testing wasn't rigorous. I could write a ROM to measure it better...
(This was seen with an original orange Nintendo zapper, I don't have a clone.)
Last edited by rainwarrior on Thu Jun 02, 2016 5:58 pm, edited 1 time in total.
- rainwarrior
- Posts: 8735
- Joined: Sun Jan 22, 2012 12:03 pm
- Location: Canada
- Contact:
Re: Lethal Weapon (Ch) [U][!].unf zapper support
Yeah, that's a better description. I was just trying to describe the typical case of a complete pull (the kind that FCEUX is emulating).Quietust wrote:No it doesn't - I have a real Zapper (one of the orange ones), and if you pull the trigger slowly until it makes a soft click it sends trigger-on as long as you hold it there, but if you pull it the rest of the way it will click much more loudly and clear the trigger signal. It's sort of like a double-action revolver, where the trigger-on signal corresponds to the hammer being pulled back all the way.rainwarrior wrote:The real zapper trigger generates a trigger-on signal only for a few frames after you pull it, doesn't matter how long you hold it down.
Re: Lethal Weapon (Ch) [U][!].unf zapper support
Out of curiosity, zeroone, how does your implementation behave with tepples's Zap Ruder characterization tests?
Re: Lethal Weapon (Ch) [U][!].unf zapper support
I just looked at the Zapper article on the wiki, and it states it fairly well:
The official Zapper's trigger returns "pulled" while it is halfway in, and "not pulled" once it has been pulled all the way to where it goes clunk. The large capacitor (10µF) inside the Zapper when combined with the 10kΩ pullup inside the console means that it will take approximately 100ms to change to "released" after the trigger has been fully pulled.
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.
P.S. If you don't get this note, let me know and I'll write you another.
- rainwarrior
- Posts: 8735
- Joined: Sun Jan 22, 2012 12:03 pm
- Location: Canada
- Contact:
Re: Lethal Weapon (Ch) [U][!].unf zapper support
Okay, after running a test, here's what I see happening when measuring the trigger once per frame:
1. Fast pull and hold: 3 or 4 frames of trigger. I can't produce a burst of 1s shorter than this, and they do seem to be "clean".
2. Pulling slowly, there's a little "click" point that when I reach it produces usually 1 to 3 frames of trigger when I reach it, then goes back to 0s. I can wiggle on this point to produce many short bursts of 1s.
3. Pulling a little farther, there's a point where the trigger goes full on (no click) and you can hold it there as long as you like.
4. Moving from the "hold" position, to the final BANG is clean.
Basically with slow pulls I get noise, due to that transition area between the initial small click and the point where it just holds. Particularly with loose/slower pulls I might get a frame or two of 0s in the middle of a block of 1s. If I play with the early click point I can produce single frame 1s too.
I don't know if my zapper is defective or different in some way from other zappers, but I don't have any others here to test at the moment. It's an original Nintendo orange zapper, says 1985 on the side. (Anybody could use the test ROM I linked above though.)
I analizyed Duck Hunt's trigger code a while back, and it was definitely doing software filtering to reject noise like this (but the specifics are a bit hazy at the moment; I seem to recall it waits at least 5 frames before allowing a new trigger), so it makes sense to me that this might be typical/expected behaviour.
1. Fast pull and hold: 3 or 4 frames of trigger. I can't produce a burst of 1s shorter than this, and they do seem to be "clean".
2. Pulling slowly, there's a little "click" point that when I reach it produces usually 1 to 3 frames of trigger when I reach it, then goes back to 0s. I can wiggle on this point to produce many short bursts of 1s.
3. Pulling a little farther, there's a point where the trigger goes full on (no click) and you can hold it there as long as you like.
4. Moving from the "hold" position, to the final BANG is clean.
Basically with slow pulls I get noise, due to that transition area between the initial small click and the point where it just holds. Particularly with loose/slower pulls I might get a frame or two of 0s in the middle of a block of 1s. If I play with the early click point I can produce single frame 1s too.
I don't know if my zapper is defective or different in some way from other zappers, but I don't have any others here to test at the moment. It's an original Nintendo orange zapper, says 1985 on the side. (Anybody could use the test ROM I linked above though.)
I analizyed Duck Hunt's trigger code a while back, and it was definitely doing software filtering to reject noise like this (but the specifics are a bit hazy at the moment; I seem to recall it waits at least 5 frames before allowing a new trigger), so it makes sense to me that this might be typical/expected behaviour.
Re: Lethal Weapon (Ch) [U][!].unf zapper support
Just tried out that test ROM with my own (orange 1985) Zapper, and your above described points 2 and 3 are extremely close together, to the point that getting the short noisy bursts is nearly impossible - for the most part, when I hear the click, it switches between constant 0 and constant 1. When I do a fast trigger pull, I get four frames worth of 1s, occasionally five.
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.
P.S. If you don't get this note, let me know and I'll write you another.
Re: Lethal Weapon (Ch) [U][!].unf zapper support
Hm. So, it is an electrolytic capacitor inside the zapper there, and so probably has a typical Equivalent Series Resistance of somewhere around 10Ω, give or take.rainwarrior wrote:I don't know if my zapper is defective or different in some way from other zappers, but I don't have any others here to test at the moment.
So if you somehow manage to keep your finger right on the near edge of the make/break threshold, and you manage to intentionally/accidentally use muscle tremors to keep it making contact with a 1% duty cycle, you'll manage to keep the voltage across the capacitor in the middle of the relevant range for the 74HC368 to toggle between logic 1 and 0.
But given how much effort this takes, I have to wonder if this:
is because the original famicom zapper could be missing the capacitor altogether?rainwarrior wrote:I analyzed Duck Hunt's trigger code a while back, and it was definitely doing software filtering to reject noise like this
Re: Lethal Weapon (Ch) [U][!].unf zapper support
I discovered something important about the problem with Lethal Weapon (Ch) [!].unf: The color of the pixel at the mouse coordinates on the frame prior to the white-silhouettes frame determines the response rather than the white-silhouette. In other words, it's reacting too early.
That explains why it hits the target only 20% of the time. It was varying based on the pixel color that I happened to click on.
It'll study this further.
That explains why it hits the target only 20% of the time. It was varying based on the pixel color that I happened to click on.
It'll study this further.