Using the lightgun...

edited December 2013 in Development
I am thinking of developing a game for the Sinclair/Cheetah lightguns, how do I go about reading the data from it (Basic and MC)?

I am under the impression that it will only input screen position data when fire is pressed, is that correct?

The same routine to read the data only work on 128K models and require separate routines for 48K?
Post edited by daveysludge on

Comments

  • ZupZup
    edited December 2013
    AFAIK, the truth is that there's no position (and no spoon, either).

    The gun only detects if there's light or not. So when you press fire, the gun will say if there is light or not. To check if you've hit anything you must:

    - Wait to "fire".
    - Black out the screen (if your gun says "light" on this step, somebody is doing cheats).
    - Light the first sprite ("light"=hit)
    - If there is no light, light the next sprite and repeat until you find a hit or run out of sprites.
    - If there is no light, is a miss.

    Or at least, I think that it was the process. I guess somebody will correct me.
    I was there, too
    An' you know what they said?
    Well, some of it was true!
  • edited December 2013
    Just be aware that the lightgun is only going to work with the old CRT televisions. As the screen is drawn, the electron beam will cause the brightest glow at the current position.

    The gun itself will have a photodiode in it with a lens, that when aimed at the TV will be able to detect when the light becomes momentarily brighter which is when the raster scan is passing by.

    So I think, without knowing anything about it, the gun is read by waiting for interrupt then counting how many cycles it takes before the gun gets a reading. If they were kind, they had hardware do the counting. But this is the ZX, I am confident it is done cheaply so the counting has to be done in software which nearly makes the thing useless :)

    I wait to hear what the actual situation is from someone who knows.
  • edited December 2013
    yes you will have to wait for the interrupt, then sit in a counter loop polling the AY until you see the appropriate bit.

    The trigger is the same deal as a keyboard. If you want to know if it is pressed you have to poll the AY. There are no interrupts or flags.
Sign In or Register to comment.