home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 December / macformat-031.iso / mac / Go Faster Shareware / sm.source Folder / Speedy mouse ƒ / speedy mouse VBL.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-17  |  2.6 KB  |  114 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        speedy mouse VBL.c
  4.  
  5. Purpose:    This module handles setting low-level globals that make
  6.             the mouse move twice as fast as normal.
  7.             
  8.  
  9. Speedy Mouse -=- all the mouse and twice the speed
  10. Copyright (C) 1993 Mark Pilgrim
  11.  
  12. This program is free software; you can redistribute it and/or modify
  13. it under the terms of the GNU General Public License as published by
  14. the Free Software Foundation; either version 2 of the License, or
  15. (at your option) any later version.
  16.  
  17. This program is distributed in the hope that it will be useful,
  18. but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. GNU General Public License for more details.
  21.  
  22. You should have received a copy of the GNU General Public License
  23. along with this program in a file named "GNU General Public License".
  24. If not, write to the Free Software Foundation, 675 Mass Ave,
  25. Cambridge, MA 02139, USA.
  26.  
  27. \**********************************************************************/
  28.  
  29. #include "Retrace.h"
  30. #include "GestaltEQU.h"
  31.  
  32. extern Boolean CrsrNew : 0x8CE;
  33. extern Point mTemp : 0x828;
  34. extern Point RawMouse : 0x82C;
  35. extern unsigned int keymap[8] : 0x174;
  36. extern Rect ts: 0x09ce;
  37.  
  38. Rect            gMainScreenBounds;
  39. unsigned long    me;
  40. int                oldX, oldY;
  41.  
  42. void header(void);
  43. void main(void);
  44.  
  45. void header(void)
  46. {
  47.     asm {
  48.         dc.l    0
  49.         move.l a0, d0
  50.         lea header, a0
  51.         jmp main
  52.     }
  53. }
  54.  
  55. #include "SetUpA4.h"
  56.  
  57. void main(void)
  58. {
  59.     VBLTask*        myVBL;
  60.     int                vx,vy;
  61.     long            gestalt_temp;
  62.     OSErr            isHuman;
  63.     
  64.     RememberA0();
  65.     SetUpA4();
  66.     
  67.     asm
  68.     {
  69.         move.l d0, myVBL
  70.     }
  71.     
  72.     if (me != '©MSG')
  73.     {
  74.         me = '©MSG';
  75.         oldX=RawMouse.h;
  76.         oldY=RawMouse.v;
  77.         isHuman = Gestalt(gestaltQuickdrawVersion, &gestalt_temp);
  78.         gMainScreenBounds=(isHuman || (gestalt_temp < gestalt8BitQD)) ? screenBits.bounds :
  79.             (**GetMainDevice()).gdRect;
  80.     }
  81.     
  82.     vx=RawMouse.h-oldX;
  83.     vy=RawMouse.v-oldY;
  84.     
  85.     if ((vx>=-200) && (vx<=200) && (vy>=-200) && (vy<=200) && ((vx!=0) || (vy!=0)) &&
  86.         (!(keymap[3]&2)))
  87.     {
  88.         if (PtInRect(RawMouse, &gMainScreenBounds))
  89.         {
  90.             if (RawMouse.h+vx<gMainScreenBounds.left)
  91.                 vx=gMainScreenBounds.left-RawMouse.h;
  92.             else if (RawMouse.h+vx>=gMainScreenBounds.right)
  93.                 vx=gMainScreenBounds.right-RawMouse.h-1;
  94.             if (RawMouse.v+vy<gMainScreenBounds.top)
  95.                 vy=gMainScreenBounds.top-RawMouse.v;
  96.             else if (RawMouse.v+vy>=gMainScreenBounds.bottom)
  97.                 vy=gMainScreenBounds.bottom-RawMouse.v-1;
  98.         }
  99.         
  100.         RawMouse.h+=vx;
  101.         mTemp.h+=vx;
  102.         RawMouse.v+=vy;
  103.         mTemp.v+=vy;
  104.         
  105.         CrsrNew = TRUE;
  106.     }
  107.     
  108.     oldX=RawMouse.h;
  109.     oldY=RawMouse.v;
  110.     
  111.     myVBL->vblCount = 1;
  112.     RestoreA4();
  113. }
  114.