📄 mouse256.h
字号:
#include<dos.h>
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<bmp256.h>
#ifndef __MOUSE256_H
#define __MOUSE256_H
#define programsize 400
#define TIMEHZ 31000000
#define OLDTIMEHZ 18200000
void interrupt (*oldtimer)(...);
void interrupt newtimer(...);
void install();
void drawcursor();
static struct SREGS seg;
unsigned int showmouse_flag;
unsigned intsp,intss;
unsigned myss,stack,x0,y0;
int busy=0;
struct Cursor
{
int x,y,oldx,oldy;
int oldbuf[1000];
int buf[1000];
int height,width;
}cursor;
void on_timer(p)
int (*p)();
{
segread(&seg);
stack=programsize*16;
myss=_SS;
oldtimer=getvect(0x1c);
}
void install(void interrupt (*faddr)(...))
{
disable();
setvect(0x1c,faddr);
enable();
}
void initmouse16()
{
union REGS regs;
regs.x.ax=0;
int86(0x33,®s,®s);
showmouse_flag=0;
regs.x.ax=7;
regs.x.cx=0;
regs.x.dx=639;
int86(0x33,®s,®s);
regs.x.ax=8;
regs.x.cx=0;
regs.x.dx=479;
int86(0x33,®s,®s);
}
void readmouse(int *f,int *mx,int *my)
{
union REGS regs;
regs.x.ax=3;
int86(0x33,®s,®s);
*f=regs.x.bx;
*mx=regs.x.cx;
*my=regs.x.dx;
}
void showmouse()
{
int f,x,y;
readmouse(&f,&x,&y);
showmouse_flag=1;
getimage(x,y,x+cursor.x,y+cursor.y,cursor.oldbuf);
}
void hidemouse()
{
showmouse_flag=0;
}
void initmouse256()
{
char *p;
cursor.height=15;
cursor.width=10;
outportb(0x43,0x3c);
outportb(0x40,TIMEHZ>>16);
outportb(0x40,TIMEHZ&0XFFFF);
initmouse16();
//ShowBmp256("d:\\tc\\tiim\\mouse.bmp",0,0);
//getimage(0,0,24,26,cursor.buf);
//setcolor(25);
//line(10,10,525,420);
p=(char *)newtimer;
on_timer(p);
install(newtimer);
}
void closemouse256()
{
install(*oldtimer);
outportb(0x43,0x3c);
outportb(0x40,OLDTIMEHZ>>16);
outportb(0x40,OLDTIMEHZ&0XFFFF);
}
void interrupt newtimer(...)
{
(*oldtimer)();
if(busy==0){
busy=1;
disable();
intsp=_SP;
intss=_SS;
_SP=stack;
_SS=myss;
enable();
/*--------your own code------------*/
if(showmouse_flag==1)
drawcursor();
else
putimage(cursor.oldx,cursor.oldy,cursor.oldbuf,COPY_PUT);
/*------------------------------*/
disable();
_SP=intsp;
_SS=intss;
enable();
busy=0;
}
}
void drawcursor()
{ int key,mx,my;
asm{
mov ax,3
int 0x33
mov mx,cx
mov my,dx
mov key,bx
}
if(mx!=cursor.oldx&&my!=cursor.oldy)
{
putimage(cursor.oldx,cursor.oldy,cursor.oldbuf,COPY_PUT);
cursor.oldx=mx;
cursor.oldy=my;
getimage(cursor.oldx,cursor.oldy,cursor.oldx+cursor.width,cursor.oldy+cursor.height,cursor.oldbuf);
setcolor(15);
line(cursor.oldx,cursor.oldy,cursor.oldx,cursor.oldy+cursor.height);
line(cursor.oldx,cursor.oldy,cursor.oldx+cursor.width,cursor.oldy+(int)(0.75*cursor.height));
line(cursor.oldx,cursor.oldy+cursor.height,cursor.oldx+cursor.width,(cursor.oldy+(int)(0.75*cursor.height)));
}
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -