Re: [stella] Reading joystick buttons & VBLANK -- a lesson for a newbie

Subject: Re: [stella] Reading joystick buttons & VBLANK -- a lesson for a newbie
From: "Eckhard Stolberg" <Eckhard_Stolberg@xxxxxx>
Date: Thu, 4 Jul 2002 14:49:41 +0200
> In this code we're going to be sticking #%00000000 into WSYNC & VBLANK --
> which wipes out your ability to read the joystick buttons.  I changed it
to
> the following, using a 1 in D6 and 0's everywhere else (like what would
> happen by default in HtDaP):
>
> Am I messing anything up there?  What are these other ports good for (the
> whole "dump bit" thing)?  Why would I want to ground these latches?
>
> Anyhow, lesson learned -- if you want to read the joystick, HtDaP needs a
> little line change.

Actually it's the other way around. If you want to be able to read
the joystick buttons, you need to put a 0 in D6 of VBLANK. Otherwise
the button ports get latched. This means, that once you have pressed
the joystick button, INPT4 and INPT5 will always give this result
until you remove the latches by puttin a 0 in D6 of VBLANK, even
if you aren't pressing the joystick buttons anymore.

This can be usefull, if you are only checking for the buttons every
couple of frames and don't want to miss a pressed button inbetween.
But if you are reading the button at least once per frame, it's
better to leave them unlatched, since you don't have to reset the
latches constantly. Very few people can press and unpress a joystick
button within a single frame, so the risk of missing a pressed button
is probably very small. ;-)

The dumped ports are for reading the paddles. You discharge the
capacitors by dumping them to ground at the start of a frame for
a couple of scanlines. When you remove the dumped ground, the
capacitors start to recharge through the potentiometers in the
paddle controlers. Depending on how far the paddles are turned
it takes longer or shorter until the capacitors are fully charged.
When they are fully charged the reading on INPT0 to INPT3 will
change from 0 to 1. So to read a paddle controller you have to
check it's INPT port periodicly and count how long it takes to
read 1 again.


Ciao, Eckhard Stolberg


----------------------------------------------------------------------------------------------
Archives (includes files) at http://www.biglist.com/lists/stella/archives/
Unsub & more at http://www.biglist.com/lists/stella/


Current Thread