How to access joystick without using BIOS ?

By Metalion

Paragon (1622)

Аватар пользователя Metalion

08-02-2011, 19:34

Hi,

I can't seem to find any information about how to access joysticks outside of the BIOS routines (via GTSTCK and GTTRIG).
Is there a safe way to do that ?
Can someone show me the way ?

Thanks.

Tongue

Для того, чтобы оставить комментарий, необходимо регистрация или !login

By Edwin

Paragon (1182)

Аватар пользователя Edwin

08-02-2011, 19:39

I'll start with a hint. Check the PSG documentation. Wink

By Metalion

Paragon (1622)

Аватар пользователя Metalion

08-02-2011, 19:44

Yes, I read the PSG documentation but it is very light on the subject :

5.2 Joystick Use

Figure 5.23 shows the joystick circuit. As the circuit shows, sending "0" to 
the 8th terminal and reading the 1st to 4th and 6th to 7th terminals enable 
information about the stick and the trigger buttons to be obtained. However, 
it is advisable to use BIOS for accessing the joystick, in order to give 
portability to the program.

They don't say what value we get back from that procedure.
And they are clearly against doing it outside BIOS ...

Which brings me back to square one Eek!

By Edwin

Paragon (1182)

Аватар пользователя Edwin

08-02-2011, 19:58

Well, This page does tell you.

By hap

Paragon (2042)

Аватар пользователя hap

08-02-2011, 20:11

and I use map.grauw.nl if I need to refresh my mind on a specific MSX detail, here's the ports: http://map.grauw.nl/resources/msx_io_ports.php

By Metalion

Paragon (1622)

Аватар пользователя Metalion

08-02-2011, 21:01

Thanks to both of you
Tongue

By mth

Champion (507)

Аватар пользователя mth

09-02-2011, 17:51

You can find some example code for writing the joystick related PSG registers in the JoyNet test program.

The triggers can be written, but you shouldn't do that when using the joystick port with an actual joystick, because the trigger status can no longer be read if the value written is wrong. I'm not sure of the details, but I think that the value of the triggers should be set to 1, so it can be pulled down to 0 when the corresponding joystick trigger is pressed, as pressing connects the pin to the ground. If you write 0 to a trigger, you will always read 0 for that trigger, regardless of whether the button is pressed or not.

By Metalion

Paragon (1622)

Аватар пользователя Metalion

09-02-2011, 20:09

Well, for the time being, I will stick with the BIOS calls.
When the time comes for optimizing, I will switch to a direct I/O access.

By mth

Champion (507)

Аватар пользователя mth

13-02-2011, 18:05

To effectively optimize, you should first figure out where most time is spent: if you make a routine that takes up 1% of the execution time twice as fast, you have only gained 0.5%. For a game, it's unlikely that the joystick reading routines are the bottleneck.

By Metalion

Paragon (1622)

Аватар пользователя Metalion

13-02-2011, 18:28

Yes, you're right, and furthermore, I don't need super fast joystick access, because player imput is very slow compared to machine code routines. At the moment, I even had to had a waiting loop so that the game does not go into crazy mode oO