Valery wrote:
> 
> Hi all,
> 
> Who know information about MSX mouse intreface and protocol (time
> diagramm )?
> 
> Valery

Hi,
I don't know exact timing, but I can tell about how to access. It is
done through PSG, registers 14 and 15.
Just in case you don't know: PSG is written to in the following way:

Don't ever use this method for register 14! It is said to kill you PSG!
LD A,register_number
OUT (&HA0),A
LD A,data
OUT (&HA1),A

For register 14, it should be:
LD A,14
OUT (&HA0),A
IN A,(&HA2)

As you can see, PSG 0-13 and 15 are write only, while 14 is read only.
Register 14 has the following form:
Bit Function
 0  up
 1  down
 2  left
 3  right
 4  button A
 5  button B
 6  I don't remember
 7  cassette input
bit 0-5 refer to the joystick selected by register 15, bit 6

Register 15:
Bit Function
 0  button A joystick port 1
 1  button B joystick port 1
 2  button A joystick port 2
 3  button B joystick port 2
 4  strobe joystick port 1
 5  strobe joystick port 2
 6  joystick select (0=port 1, 1=port 2)
 7  kana-led (at least that is what I was told, I don't have a japanese
MSX myself, so I couldn't test it)

I'm not sure if I mixed up bit 1 and 2... Anyway, when using this keep
the following in mind:
R15, bit 0-5 are used to put 0 or let-go-high on the pins. If you push a
button on the joystick, it will connect the pin to earth (0). By reading
the stick (through R14), it checks the voltage on the pin. If it is
high, it returns 1, if it is earth, it returns 0. This means that if you
write 0 to R15, bit 0-3, and than read the button status, it will always
be low (forced by the computer itself), so it will return low as well
(code for pressed button). You have to watch out with that. Even worse:
The joysicks I have at home (arcade they are called, not official MSX,
but they work good) have their switches connected to strobe in stead of
earth. This means that if you set the strobe bit to 1 and than try to
read the stick (buttons or direction), it will always return 1 (except
if they are forced to 0 by writing 0 in bit 0-3, in that case it will
always be 0). So even when reading joystick, don't play with the strobe
bit...

Now why do I tell this, when you ask about reading the mouse? Because
the MSX-computer uses what is called a joystick-mouse. It is read out as
a joystick. The mouse returns the displacement from last read-out, not
the position or something like that. If 2 programs both read out the
mouse, 1 of them probably doesn't work, because the same data is not
output twice.
Anyway, how to read it? It is easy. There is 16 bit output (one byte for
each direction) and it is read as follows:

set strobe to 1
wait k clockpulses
read data xl
set strobe to 0
wait n clockpulses
read data xh
set strobe to 1
wait n clockpulses
read data yl
set strobe to 0
wait n clockpulses
read data yh

This makes clear why sometimes you have to unplug a mouse from the
computer and than plug it in again. The mouse cannot see if you are
asking for x or y data, so if it gets mixed up once, it will stay that
way.
By the way, MSX mouse does, of course connect the pins to earth. So
don't worry about reading it with strobe high.

The data is read from R14. Bit 0-3 are the wanted data, bit 4+5 are
button-status, as usual.

Other people might have wanted to know this, but I think this is not the
answer to your question. I think this, because you ask for a time
diagramm. That means you want to know the minimum values of k and n. I'm
sorry, those values I don't know. I have seen programs with the
following wait-loop:
       LD B,xx
LABEL: NOP
       DJNZ LABEL
for k, xx was taken 40 and for n 20, but this is probably not minimum.
Therefore, I also want to ask the question: What are the minimum values? 

By the way: using minimum values might of course give problems to 7MHz
(Ok Alwin, it's not 7, it's 3.59*2=7.2Mhz) MSX's and TR's. Since I don't
have any of them, I don't know if there is a built in hardware solution
for such problems, but if not, it would be advisible to make it a bit
slower. Of course TR _can_ run on it's Z80, but the users will not like
to do this just to make the mouse work a fraction faster on other MSX's.
Still, it is the choice of the programmer. If you make it working fast
on a 'normal' MSX, it is standard. So everything that doesn't work than,
is not a MSX... But of course, this is not a very nice way to look at
it.

Bye,
shevek

****
MSX Mailinglist. To unsubscribe, send an email to [EMAIL PROTECTED] and put
in the body (not subject) "unsubscribe msx [EMAIL PROTECTED]" (without the
quotes :-) Problems? contact [EMAIL PROTECTED] (www.stack.nl/~wiebe/mailinglist/)
****

Reply via email to