Re: [stella] button questions

Subject: Re: [stella] button questions
From: "Eckhard Stolberg" <Eckhard_Stolberg@xxxxxx>
Date: Wed, 17 Jul 2002 18:08:05 +0200
> Ok, I figured I should try to get a better understanding of 
> the INPT4/INPT5/VBLANK thing...
> in my experiment, it doesn't seem to matter if I
> LDA #%01000000
> before
> instead of just letting it be #0
> So I guess I don't get the implication of the
> whole latch thing...

The problem isn't with the latch, it's with the
"undefined" bits of the TIA read registers. For
reading the joystick buttons the latches are pretty
much unnessesary. As long as you check the joystick
at least once per frame, it's better to leave bit D6
of VBLANK zero all the time.

If you set bit D6 of VBLANK to one, and someone presses
the left joystick button, then D7 of INPT4 will always
read 0, even after the button has been released again.
This is the case, as long as D6 of VBLANK stays at one.
So if you wanted to check for a new button press, you'd
have to reset the latches by dropping D6 of VBLANK to
zero and then setting it to one again.

Since almost no-one can press and release the joystick
button during one frame, it is much easier to leave
D6 of VBLANK at zero all the time, which allows you
to read the button directly.

> Also, I guess I'm still dumb about the bits...
> if it's just setting D7 of INPT4, can't you still
> use the usual BEQ/BNE, or do you have to use BMI ?
> Doesn't LDAing a D7 value effect Z? (actually, I'm
> really confused, 

As I've briefly mention in an other message to you,
only the two top-most bits are defined for the TIA
read registers like INPT4. The state of the other six
bits depends on the console you are using.

On most 2600s and on the emulators the state of the
undefined bits stays at what was on the data bus before.
So if you do LDA INPT4, the last thing on the data bus
before the joystick button is actually read is %00001100,
which is the address of the INPT4 register.

So the value you will read from INPT4 is %x0 001100, where
x is the state of the joystick button, and the left-most 0
is set by the TIA. The other bits in this case are taken from
the address of the register, as you can see.

Therefore the values you will be reading will be $0c or $8c.
As you can see, a BNE/BEQ test won't work. You better use
BMI/BPL instead.

I think that on most 7800s the undefined bits are set to
zero instead. So on this console your BNE/BEQ test *might*
work. But to be sure it's still better to use BPL/BMI

Ciao, Eckhard Stolberg

Archives (includes files) at
Unsub & more at

Current Thread