OSDN Git Service

new file: 16/v2/CONSOLE.TXT
[proj16/16.git] / 16 / v2 / source / verge / MAPED / MOUSE.C
1 /*\r
2 Copyright (C) 1998 BJ Eirich (aka vecna)\r
3 This program is free software; you can redistribute it and/or\r
4 modify it under the terms of the GNU General Public License\r
5 as published by the Free Software Foundation; either version 2\r
6 of the License, or (at your option) any later version.\r
7 This program is distributed in the hope that it will be useful,\r
8 but WITHOUT ANY WARRANTY; without even the implied warranty of\r
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\r
10 See the GNU General Public Lic\r
11 See the GNU General Public License for more details.\r
12 You should have received a copy of the GNU General Public License\r
13 along with this program; if not, write to the Free Software\r
14 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.\r
15 */\r
16 \r
17 #include <stdio.h>\r
18 #include <i86.h>\r
19 #include <string.h>\r
20 \r
21 #include "timer.h"\r
22 #include "vdriver.h"\r
23 \r
24 // ================================= Data ====================================\r
25 \r
26 extern char mousepic[]; // blah\r
27 \r
28 static union REGS regs;\r
29 \r
30 int mx=0,my=0,mb=0;\r
31 int rb=0,wb=0;\r
32 int lmx=0,lmy=0,lmb=0;\r
33 \r
34 // ================================= Code ====================================\r
35 \r
36 void PutMouse(int x, int y)\r
37 {\r
38   lmx=mx; lmy=my; lmb=mb;\r
39   memset(&regs, 0, sizeof regs);\r
40   regs.w.ax=4;\r
41   regs.w.cx=x*2;\r
42   regs.w.dx=y*2;\r
43   int386(0x33,&regs,&regs);\r
44 \r
45   mx=x; my=y;\r
46 }\r
47 \r
48 void InitMouse()\r
49 {\r
50   memset(&regs, 0, sizeof regs);\r
51   int386(0x33,&regs,&regs);\r
52 \r
53   regs.w.ax=7;\r
54   regs.w.cx=0;\r
55   regs.w.dx=640; /*320;*/ /* -- ric:13/Jun/98 - fix horizontal jumps -- */\r
56   int386(0x33,&regs,&regs);\r
57 \r
58   regs.w.ax=8;\r
59   regs.w.cx=0;\r
60   regs.w.dx=sy; // aen\r
61   int386(0x33,&regs,&regs);\r
62 \r
63   PutMouse(sx/2,(sy/2) /2); // aen\r
64 }\r
65 \r
66 void ReadMouse()\r
67 {\r
68   lmx=mx; lmy=my; lmb=mb;\r
69   memset(&regs, 0, sizeof regs);\r
70   regs.w.ax=3;\r
71   int386(0x33,&regs,&regs);\r
72 \r
73   mx=((regs.w.cx)>>1)+16;  /* -- ric:13/Jun/98 - fix horizontal jumps -- */\r
74   my=(regs.w.dx)+16;\r
75   rb=regs.w.bx;\r
76 \r
77   if (rb && wb) { mb=0; return; }\r
78   if (wb && !rb) wb=0;\r
79   mb=rb;\r
80 \r
81   if ((lmx!=mx) || (lmy!=my) || (lmb!=mb)) idlect=0;\r
82 }\r
83 \r
84 void DrawMouse()\r
85 {\r
86   ReadMouse();\r
87   TCopySprite(mx,my,4,5,mousepic);\r
88 }\r
89 \r
90 void WaitRelease()\r
91 {\r
92   wb=1;\r
93   mb=0;\r
94 }\r