home *** CD-ROM | disk | FTP | other *** search
/ Falcon 030 Power 2 / F030_POWER2.iso / ST_STE / MAGS / ICTARI08.ARJ / ictari.08 / ASSEMBLY / MOUSPROB / MOUSE.DOC next >
Text File  |  1992-03-04  |  4KB  |  72 lines

  1.     About MOUSE.S, MOUSE.TOS & MOUSE.DOC, (this).
  2.  
  3.     Hi folks. I'm MIC and I'm teaching myself to program in assembler. Just
  4.     about. One of the first things I want  to  do is to write a basic shell
  5.     with a mouse pointer on it.  The  games  I like are the Dungeon Master,
  6.     Civilisation type games, no joysticks usually. And, as I'm getting into
  7.     programming they are the type of game I'd like to end up writing.
  8.  
  9.     GEM is probably great if you need  windows,  but I won't. So, I need to
  10.     access the bit of the ST which  works  the  mouse at TOS level. Low low
  11.     low down inside the Operating  System.  Books  (great aren't they, they
  12.     don't answer back and insist you  switch  off your computer at 2am like
  13.     my wife sometimes does!), books  tell  me  that  I  need to look at the
  14.     Intelligent KeyBoarD (IKBD) for the answer. So I have.
  15.  
  16.     As I understand it, there is a separate mini-computer inside our casing
  17.     using a 6301 processor. All it  does  is look at the keyboard, joystick
  18.     ports, and mouse  port.  If  anything  interesting  happens  it creates
  19.     within itself a  'packet'  of  data  about  the  event,  then causes an
  20.     interrupt (what level I wonder?). At the appropriate time the processor
  21.     calls a routine (pointed to by a  vector table) who's job is to process
  22.     this packet. In my case, all I need  to do is move the packet into safe
  23.     storage for later.
  24.  
  25.     XBIOS 34 returns a longword. This is  the address of the first entry in
  26.     a 7 entry table of  addresses,  a  vector  array.  The 5th entry, or 16
  27.     bytes into the table, is the address  of  a routine to handle the data,
  28.     and is the routine  called  by  the  IKBD  interrupt. I've replaced the
  29.     original address with the address  of  my routine. The original address
  30.     is restored at the end.
  31.  
  32.     The OS points a0 to  the  start  of  the  data  packet. My routine just
  33.     copies this packet to a  buffer.  I  use  the data later. (This routine
  34.     must end in RTS and use no more than 1 milisecond of processor time, or
  35.     8,000 cycles. Or so more books tell me.).
  36.  
  37.     There are two types of packet for the mouse, absolute and relative. The
  38.     default (GEM) type is  relative.  This  relative  packet  consists of a
  39.     header byte which includes bit  data  about  the  buttons, a relative X
  40.     position byte, signed, and a Y  position  byte, signed. I'm sticking to
  41.     relative for now as it's good enough for GEM.
  42.  
  43.     I hold two variables in memory for  the  x and y position of the mouse.
  44.     At the moment I print the values rather than attempt to draw and undraw
  45.     the pointer. At a time  within  the  program  that is convenient to the
  46.     programmer a routine to alter these variables according to the contents
  47.     of the latest data packet  is  called.  Then they're printed on screen.
  48.     Simple?
  49.  
  50.     1.  In the  background,  under  interrupt,  the  IKBD  loads  my buffer
  51.     'packet' with a data packet if the  mouse is moved or a button pressed.
  52.     The main program does nothing  about  getting the packets after setting
  53.     this up, it just watches the packets roll in.
  54.  
  55.     2. The main program does it's job, playing the game, making the sounds,
  56.     and being generally very  good.  Of  course.  When  we  have decided to
  57.     redraw the mouse pointer the main  program  looks at the currently held
  58.     packet, uses its data to vary the  mouse x/y variables, undraws the old
  59.     pointer and redraws the new.
  60.  
  61.     That's the theory. My listing  MOUSE.S  and  program MOUSE.TOS tries to
  62.     put it into practice. But  it  reacts  strangely.  If  I move the mouse
  63.     slowly, then I get the  whole  range  of  movement  in a short distance
  64.     across the mat. Great. But if I move the mouse quickly, I can cross the
  65.     whole mat and not change the variables a lot. I thought it was meant to
  66.     be the other way around? Please examine my code and comment! Thanks.
  67.  
  68.     MIC.
  69.     Mike Barnard, 52 Westbourne Avenue, Worthing, West Sussex.
  70.     BN14 8DF.
  71.  
  72.