Using the lightgun...
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?
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
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.
An' you know what they said?
Well, some of it was true!
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.
Write games in C using Z88DK and SP1
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.