DiBR
обычная кошмарная
домашняя страничка
Ежекакполучится околокомпьютерное обозрение
 
  <<<  предыдущий Tech! archive #159 следующий  >>>  
   Последний выпуск       Архив       Ссылки       Полезности       humor.filtered       Фотки       О сайте   
          Это - достаточно беспорядочный архив сообщений конференций сети fidonet, которые на момент их прочтения мной показались полезными или интересными. Многие устарели, многие узкоспецифичны и малоинтересны, но может оказаться и что-то новое...
         
- __techs (2:5015/42) ----------------------------------------------- __techs -
Msg  : 159 of 1000                         Rcv Pvt
From : Alexander Krasilnikoff              2:5015/45.2     13 Jun 96  00:04:16
To   : Dmitry Radishev                                     13 Jun 96  02:11:02
Subj : Game port
-------------------------------------------------------------------------------
@AREA:NETMAIL

*** Changed by Dmitry Radishev (2:5015/42), Thursday June 13 1996 00:04.

Good day, Dmytry!

Отвечаю на искpеннее любопытство по поводу сабжа.;)

15-pin D-shell connector:

PIN SIGNAL  PIN SIGNAL
--- ------  --- ------
 1 +5V       8 +5V
 2 button 1  9 +5V
 3 stick 1  10 button 3
 4 GND      11 stick 3
 5 GND      12 GND
 6 stick 2  13 stick 4
 7 button 2 14 button 4
            15 +5V

Game card has a female connector;
Joystick cable has male connector.
Joystick wiring:

 +5 ________________
                         |
 stick1 ________ |
   | 100K  |
      _/\\/\\/\\_____|
 stick2 ________ |
   | 100K  |
      _/\\/\\/\\_____|
 stick3 ________ |
   | 100K  |
      _/\\/\\/\\_____|
 stick4 ________  |
   | 100K  |
      _/\\/\\/\\_____|
        ___
 button1 ______o o_______
        ___       |
 button2 ______o o_______|
        ___       |
 button3 ______o o_______|
        ___       |
 button4 ______o o_______|
    |
 GND ________________|


You need to do byte I/O to and from port 201h.
To read the joysticks (or your slide pot positions), you
must first write a byte to port 201h.  It doesn't matter
what value you send, as long as you perform an I/O write.
This triggers the 558 timer on the game adapter.

Game port 201h byte:
 _______________________________________________________
|   7  |   6  |   5  |   4  |   3  |   2  |   1  |   0  |
| but4 | but3 | but2 | but1 | stk4 | stk3 | stk2 | stk1 |
|______|______|______|______|______|______|______|______|

The most machine-independent way to sample the game port
is to use a timer.  Note the time (e.g., read the countdown
register in Timer 0, you need pretty fine resolution and this
timer performs 65535 counts every 55 ms) just before you
trigger the 558.  After triggering, sit in a loop reading
port 201h and examining bits 0-3.  For those bits that have
a joystick pot attached, you'll see them sit for a while at 0,
then become 1.  As each bit flips back to 1, note the time
again.  When all bit 0-3 have flipped back to 1, you're almost
done.  Compute elapsed time for each bit, and you end up with
a value that is proportional to pot position.

If you're lazy and don't care about machine independence,
you can just trigger the card, then sit in a loop and count
up from zero.  As each bit flips back to 1, save the count
for that bit.  I've seen a few games that probably use
this method.  Problem is that if you then run the same code
on a faster/slower machine, your calibration can get very
easily messed up.

Buttons can be read at any time just by reading port 201h
and looking at bits 4-7.  No triggering is required.
Button bits are normally 1; while a button is depressed,
its bit will flip to 0.

___________________________________________

Bill Frolik             Hewlett-Packard Co.
hp-pcd!bill             Corvallis, Oregon
bill@hpcvlx.cv.hp.com   (503)750-4082
=== Cut ===

See you later.Alexander

--- GoldED 2.50.A0611+
* Origin: <Humanum errare est.> (FidoNet 2:5015/45.2)






<<<

архив dibr

>>>'