Working on fixing up MartyPC's light pen emulation - I can't really be the light pen expert and not have my own emulator do it right.

This fixes the latching logic so we can latch the light pen strobe regardless of whether the pen switch is pressed. So now we have the live cursor!

#retrocomputing #emulation #lightpen

#retrocomputing #emulation #lightpen

The main issue remaining is that the pen works in dark regions of the screen, where it really shouldn't. You might just think this is a harmless improvement, but the software actually expects the pen not to work - if i tap the pen in a dark area it takes it as a valid selection from the four options in that menu.

...which one did we actually select? No idea. So that's not good.

#retrocomputing #emulation #lightpen

I could do a simple pixel hit test to check for lit pixels, but a real pen will pick up light from what I imagine is a small cone around the tip, so I'm guessing a 3x3 or 5x5 averaged kernel might work best.

A good time to do this would be right before we draw the crosshairs indicating the light pen position. Then I can just set a flag like 'pen_light'.

This puts a bit more device logic in the front end then i'd prefer, but it also means i don't have to add light sampling to each video card implementation, so there's a tradeoff either way.

actually the light sampling should go in the monitor emulation that i've been meaning to factor out. :(

Light Pen Luma sampling implemented! The little blue rectangle shows the 5x5 sampling kernel.

Will probably end up tweaking that a bit, but for now, it feels close enough to the real thing.

now here's the thing i am pondering. if i hook up a VGA CRT monitor, can I operate MartyPC's light pen emulation with an actual light pen? 🤔

In the twilight hours of FTG's website www.fastpoint.com, they published beta drivers for a USB light pen interface. There's a good chance they didn't even release hardware. I've never seen it on eBay, anyway.

Well, nothing a Pi Pico can't solve, right?

Oh, I just thought of something. I'm calculating luma with the standard formula, but I really should be weighting toward blue like the photodiode is...

Now I just need to trace out enough of the card to figure out how the IO protocol works. It has to be pretty basic, since the entire card is 74 series logic.

Then I can have the only high-resolution PC light pen emulation on earth. Woo.

At which point you have something almost as good as just using the mouse!

All three light pen fans will be thrilled.

@gloriouscow As someone who has absolutely no interest in going down this particular rabbit hole myself - I have my own, and no time to explore _them_ thanks - I'm definitely thrilled to follow along. I have a surprisingly crisp, sensory memory of using a light pen when I was no more than 4 years old and can entirely see the appeal!