How to rewrite the SGDK lightguns support module (src/joy.c) for BEX?

SGDK only sub forum

Moderator: Stef

Post Reply
Tomahomae
Interested
Posts: 36
Joined: Sat Jan 27, 2018 2:50 am
Location: Russia

How to rewrite the SGDK lightguns support module (src/joy.c) for BEX?

Post by Tomahomae » Mon Sep 20, 2021 4:14 pm

To be correct, is it possible at all? I'm not even sure, that BEX allows to work with a certain registers directly. There is an example of lightgun interaction for BEX, but it lets to move a "crosshair" only. How to make it to react on the trigger pull, is absolutely unclear. There is a no code of lightgun model recognising in this sample also.

Chilly Willy
Very interested
Posts: 2860
Joined: Fri Aug 17, 2007 9:33 pm

Re: How to rewrite the SGDK lightguns support module (src/joy.c) for BEX?

Post by Chilly Willy » Mon Oct 04, 2021 7:57 pm

Getting a position from a lightgun is "easy" - all you do is enable the external interrupt and then in the int handler get the latched video beam position registers. Reading the buttons is harder as every gun uses a different method of toggling the port bits to read their gun buttons. The Menacer also needs very specific timing in addition. That's where all the inline assembly in joy.c comes in - getting that Menacer timing right.

Post Reply