source: abuse/tags/pd/imlib/port/oldports/evt_dos.c @ 49

Last change on this file since 49 was 49, checked in by Sam Hocevar, 15 years ago
  • Imported original public domain release, for future reference.
  • Property svn:keywords set to Id
File size: 1.6 KB
Line 
1#include "video.hpp"
2#include "sprite.hpp"
3#include "image.hpp"
4#include "filter.hpp"
5#include "mdlread.hpp"
6#include "monoprnt.hpp"
7#include "mouse.hpp"
8
9unsigned char def_mouse[]=
10    { 0,2,0,0,0,0,0,0,
11      2,1,2,0,0,0,0,0,
12      2,1,1,2,0,0,0,0,
13      2,1,1,1,2,0,0,0,
14      2,1,1,1,1,2,0,0,
15      2,1,1,1,1,1,2,0,
16      0,2,1,1,2,2,0,0,
17      0,0,2,1,1,2,0,0,
18      0,0,2,1,1,2,0,0,
19      0,0,0,2,2,0,0,0 };    // 8x10
20
21int Mbut,Mx,My;
22
23
24
25
26
27JCMouse::JCMouse(image *Screen, palette *pal)
28{
29  image *im;
30  int br,dr,h;
31  filter f;
32  but=0;
33  asm {
34    mov ax, 0             // detect the mouse
35    int 0x33
36    mov h, ax
37  }
38  here=h;
39  if (here)                     // is it here?
40  {
41    screen=Screen;
42    br=pal->brightest(1);
43    dr=pal->darkest(1);
44    f.set(1,br);
45    f.set(2,dr);
46    make_block(sizeof(image));
47    im=new image(8,10,def_mouse);
48    f.apply(im);
49    make_block(sizeof(sprite));
50    sp=new sprite(Screen,im,100,100);
51    asm {                // mouse the mouse pointer to 40,40
52      mov ax, 4
53      mov cx, 40
54      mov dx, 40
55      int 0x33
56    }
57  }
58}
59
60void JCMouse::update(int newx, int newy, int new_but)
61{
62  int butn,xx,yy;
63  if (newx<0)
64  {
65    if (here)
66    {
67      asm {
68        mov ax, 0x0b
69        int 0x33            // get the mouse movement
70        mov xx,cx
71        mov yy,dx
72        mov ax, 3
73        int 0x33           // get the mouse button status
74        mov butn,bx
75      }
76      lx=mx; ly=my; lbut=but;
77      but=butn;
78      mx+=xx;
79      my+=yy;
80      if (mx<0) mx=0;
81      if (my<0) my=0;
82      if (mx>=screen->width()) mx=screen->width()-1;
83      if (my>=screen->height()) my=screen->height()-1;
84    }
85  } else
86  { mx=newx; my=newy; but=new_but; }
87}
Note: See TracBrowser for help on using the repository browser.