home *** CD-ROM | disk | FTP | other *** search
-
- mouse::togmouse()
- {
-
- if ( mouseon )
- {
-
- asm mov ax , 0002 ;
- asm INT 0x33 ;
- mouseon = false ;
-
- }
- else
- {
-
- asm mov ax,0001 ;
- asm INT 0x33 ;
- mouseon = true ;
-
- }
- return 1;
-
- }
-
- mouse::onmouse()
- {
-
- asm mov ax,0001 ;
- asm INT 0x33 ;
- mouseon = true ;
- return(0);
- }
-
- mouse::offmouse()
- {
- asm mov ax , 0002 ;
- asm INT 0x33 ;
- mouseon = false ;
- return(0);
- }
-
- enum tf mouse::wheremouse(void)
- {
- int a,b,c;
- asm MOV AX,5; // function 5
- asm MOV BX,0; // bx 0 check for right mouse click
- asm INT 0x33; // pass on to mouse driver
-
- asm MOV a,BX; // save number of events in a
- asm MOV AX,3; // get current mouse location
- asm INT 0x33;
- asm MOV b,CX; // save current pos
- asm MOV c,DX;
-
- x=b; // these 2 make it fit arena area
- y=c*2.4;
-
- if(bitmap_flag)
- {
- if((oldmx!=x)||(oldmy!=y))
- {
- drawmouse(x,y,current_map);
- }
- oldmx=x;oldmy=y;
- }
-
-
-
-
- if (a==0)
- return false;
- return true;
-
- }
-
- enum tf mouse::nearby(int a,int b,int c)
- {
- float d;
- d=sqrt((a-x)*(a-x)+(b-y)*(b-y));
- if (c>d) return true;
- return false;
- }
-
-
- mouse::~mouse()
- {
- free(bitmap_0);
- free(bitmap_1);
- free(bitmap_2);
- free(bitmap_3);
- free(background);
-
- asm MOV AX,2;
- asm INT 0x33;
- }
- enum tf mouse::wherelastclick(void)
- {
- int a,b,c;
- asm MOV AX,5;
- asm MOV BX,0;
- asm INT 0x33;
-
- asm MOV a,BX;
- asm MOV b,CX;
- asm MOV c,DX;
-
- b>464?x=464:x=b;
- y=c*2.4;
-
- if (a==0)
- return false;
- return true;
- }
- enum tf mouse::right(void) // xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-
- {
- int a;
- asm MOV AX,5;
- asm MOV BX,1;
- asm INT 0x33;
- asm MOV a,BX;
-
- if (a==0)
- return false;
- return true;
- }
-
- mouse::mouse(void)
- {
- FILE *in;
- int i;
- x=0;
- y=0;
- l=19,r=624,u=19,d=464;
- noputat=0;
- flip=0;
- printf("Checking mouse...\n");
- asm MOV AX,0000;
- asm INT 0x33;
- printf("still doing it\n");
- asm MOV AX,0001;
- asm INT 0x33;
- printf("how long?\n");
- // asm MOV AX,0008;
- // asm MOV cx,0;
- // asm mov dx,0800;
- // asm INT 0x33;
- mouseon = true;
-
- bitmap_0=(char *)malloc(0x400);
- bitmap_1=(char *)malloc(0x400);
- bitmap_2=(char *)malloc(0x400);
- bitmap_3=(char *)malloc(0x400);
-
- background=malloc(0x500); // just to be safe.
-
- in=fopen("mouse0.dat","rb");
- for (i=0;i<0x400;++i)
- {
- fscanf(in,"%c",&bitmap_0[i]);
-
- }
- in=fopen("mouse1.dat","rb");
- for (i=0;i<0x400;++i)
- {
- fscanf(in,"%c",&bitmap_1[i]);
-
- }
- fclose(in);
- in=fopen("mouse2.dat","rb");
- for (i=0;i<0x400;++i)
- {
- fscanf(in,"%c",&bitmap_2[i]);
-
- }
- fclose(in);
- in=fopen("mouse3.dat","rb");
- for (i=0;i<0x400;++i)
- {
- fscanf(in,"%c",&bitmap_3[i]);
-
- }
- fclose(in);
- current_map=bitmap_0;
- return;
- }
-
- mouse::dobounds()
- {
-
- int ll,rl,ul,dol;
- ll=l;rl=r;ul=u/2.4;dol=d/2.4;
- asm mov ax,0x07;
- asm mov cx,ll;
- asm mov dx,rl;
- asm INT 0x33;
- asm mov ax,0x08;
- asm mov cx,ul;
- asm mov dx,dol;
- asm INT 0x33;
-
- return(0);
-
- }
-
- mouse::setbounds(int centrex,int centrey)
- {
-
- l=(7-centrex)*32+16;
- r=((width-centrex)+7)*32-16;
- u=(7-centrey)*32+16;
- d=((height-centrey)+7)*32-16;
-
- if(r>464)r=464;
- if(d>464)d=464;
- if(l<19)l=19; // left and up limits needed for getimage and putimage
- if(u<19)u=19; // which crash on negative values
- dobounds();
-
- return(0);
-
-
-
-
-
-
- }
-
-
- mouse::unsetbounds()
- {
- l=19;r=634;u=19;d=464;
-
- dobounds();
-
- return(0);
- }
-
-
- void mouse::drawmouse(int ax,int ay, unsigned char * which)
- {
- int i,px,py;
- ax-=16;ay-=16;
- putimage(oldmx-16,oldmy-16,background,0);
-
- getimage(ax,ay,ax+32,ay+32,background);
-
- if(!flip)
- {
- for(i=0;i<0x400;++i)
- {
- px=ax+i%32;py=ay+i/32;
-
- if(which[i]<254)putpixel(px,py,which[i]);
- if(which[i]==254)putpixel(px,py,colour);
- }
- }
- else //flip over tile if it is a portrait of a left-facing monster
- {
- for(i=0;i<0x400;++i)
- {
- px=ax+32-i%32;py=ay+i/32;
-
- if(which[i]<254)putpixel(px,py,which[i]);
- if(which[i]==254)putpixel(px,py,colour);
- }
- }
- }
-
- mouse::bitmapon(int which,int col)
- {
- int i,px,py;
- flip=0;
- if(which==0)current_map=bitmap_0;
- if(which==1)current_map=bitmap_1;
- if(which==2)current_map=bitmap_2;
- if(which==3)current_map=bitmap_3;
- if(which==5){current_map=tile[mon[curpla][curmon].graphic];if(curpla%2)flip=1;}
- oldmx=x;oldmy=y;
- getimage(oldmx-16,oldmy-16,oldmx+16,oldmy+16,background);
-
- if(!flip)
- {
- for(i=0;i<0x400;++i)
- {
- px=x+i%32-16;py=y+i/32-16;
- if(current_map[i]<254)putpixel(px,py,current_map[i]);
- if(current_map[i]==254)putpixel(px,py,col);
- }
- }
- else
- {
- for(i=0;i<0x400;++i)
- {
- px=x+32-i%32-16;py=y+i/32-16;
- if(current_map[i]<254)putpixel(px,py,current_map[i]);
- if(current_map[i]==254)putpixel(px,py,col);
- }
- }
- bitmap_flag=1;
- colour=col;
- }
-
- mouse::bitmapoff()
- {
- putimage(x-16,y-16,background,0);
- bitmap_flag=0;
-
- }
-
- mouse::initbitmap(int ya_want_centering_with_that)
- {
- if(ya_want_centering_with_that==1)noputat=1;
- getimage(0,0,32,32,background); //just in case the first thing it does
- // is bitmapoff(), requiring a putimage...
- }
-
-
- mouse::putat(int newx, int newy)
- {
- if(noputat)return(0);
- int tempx,tempy;
- tempx=x=newx;
- tempy=y=newy/2.4;
-
-
- asm mov ax,0x04;
- asm mov cx,tempx;
- asm mov dx,tempy;
- asm INT 0x33;
-
- }