1.apilib.h添加, //本人是真正的小白, 不会通过结构体传值, 只能把鼠标的X, Y, 和点击 一个个传了
int api_getmousex(void);
int api_getmousey(void);
int api_getmousebtn(void);
void api_sleep(int time);
2. apilib目录下添加
1) api030.nas (文件名自己定义)
[FORMAT "WCOFF"]
[INSTRSET "i486p"]
[BITS 32]
[FILE "api030.nas"]
GLOBAL_api_getmousex
[SECTION .text]
_api_getmousex:; int api_getmousex(void);
MOVEDX,30
INT0x40
RET
2) api031.nas (文件名自己定义)
[FORMAT "WCOFF"]
[INSTRSET "i486p"]
[BITS 32]
[FILE "api031.nas"]
GLOBAL_api_getmousey
[SECTION .text]
_api_getmousey:; int api_getmousey(void);
MOVEDX,31
INT0x40
RET
3) api032.nas (文件名自己定义)
[FORMAT "WCOFF"]
[INSTRSET "i486p"]
[BITS 32]
[FILE "api032.nas"]
GLOBAL_api_getmousebtn
[SECTION .text]
_api_getmousebtn:; int api_getmousebtn(void);
MOVEDX,32
INT0x40
RET
4) api033.nas (文件名自己定义)
[FORMAT "WCOFF"]
[INSTRSET "i486p"]
[BITS 32]
[FILE "api033.nas"]
GLOBAL_api_sleep
[SECTION .text]
_api_sleep:; void api_sleep(int time);
PUSHEBX
MOVEDX,33
MOVECX,[ESP+8]; time
INT0x40
POPEBX
RET
3. bootpack.h 添加
extern int MOUSEX, MOUSEY, MOUSEBTN;
4. bootpack.c 添加
int MOUSEX, MOUSEY, MOUSEBTN; (在void HariMain()前)
在for循环里
new_mx = mx;
new_my = my;
的下面添加
MOUSEX = mx;
MOUSEY = my;
MOUSEBTN = mdec.btn;
5. 在 console.c 中添加
void api33_sleep(struct CONSOLE *cons, struct TASK *task, int time); //最上面添加
在hrb_api() 中添加
extern int MOUSEX, MOUSEY, MOUSEBTN;
//中略
if(edx == 1){
//中略
} else if (edx == 30) { /* 鼠标X坐标 */ /*这里的edx值对应apilib文件名中的api编号,如我的是api030.nas文件中的30, 下同*/
reg[7] = MOUSEX; //(int) &mdec; //我不会结构体传值, 有哪位大佬愿意赐教的,小弟不胜感激, 如果能传结构体,那鼠标API只需要一个接口就可以了
} else if (edx == 31) { /* 鼠标Y坐标 */
reg[7] = MOUSEY;
} else if (edx == 32) { /* 鼠标按键值 */
reg[7] = MOUSEBTN;
} else if (edx == 33) { /* 休眠 */
api33_sleep(cons->timer, task, ecx);
}
return 0;
}
/* 实现sleep功能 */
void api33_sleep(struct CONSOLE *cons, struct TASK *task, int time) {
int i;
cons->timer = timer_alloc();
cons->timer->flags2 = 1;
timer_init(cons->timer, &task->fifo, 128);
timer_settime(cons->timer, time); //等待0.01 * ecx 秒
for (;;) {
io_cli();
if (fifo32_status(&task->fifo) == 0) { //
task_sleep(task); /* FIFO为空,休眠并等待*/
}
i = fifo32_get(&task->fifo); //
io_sti();
if(i == 128) {
break;
}
}
timer_free(cons->timer);
}
6. app中的调用
void HariMain(void){
int i, mx=0, my=0, mbtn=0, mx0=0, my0=0, mbtn0=0;
//中略
for(;;) {
mx = api_getmousex();
my = api_getmousey();
mbtn = api_getmousebtn();
if((mx == mx0) && (my == my0) && (mbtn == mbtn0)) {
api_sleep(1);
continue;
}
mx0 = mx;
my0 = my;
mbtn0 = mbtn;
//拿到了鼠标的值, 下面该干嘛干嘛^_^
}
int api_getmousex(void);
int api_getmousey(void);
int api_getmousebtn(void);
void api_sleep(int time);
2. apilib目录下添加
1) api030.nas (文件名自己定义)
[FORMAT "WCOFF"]
[INSTRSET "i486p"]
[BITS 32]
[FILE "api030.nas"]
GLOBAL_api_getmousex
[SECTION .text]
_api_getmousex:; int api_getmousex(void);
MOVEDX,30
INT0x40
RET
2) api031.nas (文件名自己定义)
[FORMAT "WCOFF"]
[INSTRSET "i486p"]
[BITS 32]
[FILE "api031.nas"]
GLOBAL_api_getmousey
[SECTION .text]
_api_getmousey:; int api_getmousey(void);
MOVEDX,31
INT0x40
RET
3) api032.nas (文件名自己定义)
[FORMAT "WCOFF"]
[INSTRSET "i486p"]
[BITS 32]
[FILE "api032.nas"]
GLOBAL_api_getmousebtn
[SECTION .text]
_api_getmousebtn:; int api_getmousebtn(void);
MOVEDX,32
INT0x40
RET
4) api033.nas (文件名自己定义)
[FORMAT "WCOFF"]
[INSTRSET "i486p"]
[BITS 32]
[FILE "api033.nas"]
GLOBAL_api_sleep
[SECTION .text]
_api_sleep:; void api_sleep(int time);
PUSHEBX
MOVEDX,33
MOVECX,[ESP+8]; time
INT0x40
POPEBX
RET
3. bootpack.h 添加
extern int MOUSEX, MOUSEY, MOUSEBTN;
4. bootpack.c 添加
int MOUSEX, MOUSEY, MOUSEBTN; (在void HariMain()前)
在for循环里
new_mx = mx;
new_my = my;
的下面添加
MOUSEX = mx;
MOUSEY = my;
MOUSEBTN = mdec.btn;
5. 在 console.c 中添加
void api33_sleep(struct CONSOLE *cons, struct TASK *task, int time); //最上面添加
在hrb_api() 中添加
extern int MOUSEX, MOUSEY, MOUSEBTN;
//中略
if(edx == 1){
//中略
} else if (edx == 30) { /* 鼠标X坐标 */ /*这里的edx值对应apilib文件名中的api编号,如我的是api030.nas文件中的30, 下同*/
reg[7] = MOUSEX; //(int) &mdec; //我不会结构体传值, 有哪位大佬愿意赐教的,小弟不胜感激, 如果能传结构体,那鼠标API只需要一个接口就可以了
} else if (edx == 31) { /* 鼠标Y坐标 */
reg[7] = MOUSEY;
} else if (edx == 32) { /* 鼠标按键值 */
reg[7] = MOUSEBTN;
} else if (edx == 33) { /* 休眠 */
api33_sleep(cons->timer, task, ecx);
}
return 0;
}
/* 实现sleep功能 */
void api33_sleep(struct CONSOLE *cons, struct TASK *task, int time) {
int i;
cons->timer = timer_alloc();
cons->timer->flags2 = 1;
timer_init(cons->timer, &task->fifo, 128);
timer_settime(cons->timer, time); //等待0.01 * ecx 秒
for (;;) {
io_cli();
if (fifo32_status(&task->fifo) == 0) { //
task_sleep(task); /* FIFO为空,休眠并等待*/
}
i = fifo32_get(&task->fifo); //
io_sti();
if(i == 128) {
break;
}
}
timer_free(cons->timer);
}
6. app中的调用
void HariMain(void){
int i, mx=0, my=0, mbtn=0, mx0=0, my0=0, mbtn0=0;
//中略
for(;;) {
mx = api_getmousex();
my = api_getmousey();
mbtn = api_getmousebtn();
if((mx == mx0) && (my == my0) && (mbtn == mbtn0)) {
api_sleep(1);
continue;
}
mx0 = mx;
my0 = my;
mbtn0 = mbtn;
//拿到了鼠标的值, 下面该干嘛干嘛^_^
}