⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mouse.asm

📁 学分管理系统的分析
💻 ASM
字号:
include macro.lib
extrn	 readpoint:far, writepoint:far,printf:far
extrn    drawline:far,vertical:far,drawline_y:far,draw_jiao:far
extrn    horizontal:far,rectangle:far
extrn	 putimmage:far,getimmage:far
extrn    random:far
extrn    tonghua:far,goout:far ,selectmenu:far
public	 drawmouse,store_m,restore_m,initmouse,intr8mouse
public	 mousex,mousey,busy,color,openkeyboard
public	 old_pos_x,new_pos_x,old_pos_y,new_pos_y ,movflag_key
public   closeintr
data     segment para public  'data'
closeintr   db  0

buf      dw  300 dup(?)
mousex   dw  200
mousey   dw  100
busy     db  0
movflag  db  0
error_a  db  '您未安装鼠标,无法使用',0,0

button1flag  db  0
button2flag  db  0

color  	      dw   0ef0h
count	      db   0
openkeyboard  db   0
movflag_key   db   0
old_pos_x     dw   ?
old_pos_y     dw   ?
new_pos_x     dw   ?
new_pos_y     dw   ?
guangbiao     dw   200 dup(?)

data     ends

code 	 segment  public 'code'
	assume  cs:code,ds:data
.386
;===============================================================
;初始化鼠标
initmouse  proc far
	pusha
	push  ds
	mov   ax, data
	mov   ds, ax

	mov  ax,0000h
	int  33h
	cmp  ax,0
	jne  next
	out_hz	200,300,error_a,<RGB 255,0,0>
	delay 20
	jmp  exit
next:	
	mov  ax,0004h
	mov  cx,mousex
	mov  dx,mousey
	int  33h
	mov  ax,mousey
	mov  bx,mousex
	call store_m
	call drawmouse
exit:	pop  ds
	popa	
	ret
initmouse  endp	
;===============================================================
;鼠标移动中断子程序
intr8mouse  proc  far
	pusha
	push   ds
	push   es
	mov    ax, data
	mov    ds, ax
	
	cmp    closeintr, 1
	je     exit
	
	cmp    openkeyboard ,1
	jne    mouse
	cmp    movflag_key,1
	jne    nomoving
	call restore_b
	call store_b
	mov  ax,  new_pos_x
	mov  old_pos_x,ax
	mov  movflag, 0	
nomoving:

	call disppear_b
	inc    count
	cmp    count, 4
	jne    next_key
	mov    color,0h
next_key:
        cmp    count, 8
	jne    mouse
	mov    count, 0
	mov    color, 0ef0h	
	
mouse:	cmp    busy,1
	je     exit
	mov    ax,11
	int    33h
	
	cmp    cx,0     ;判断是否发生移动
	jne    next
	cmp    dx,0
	je     exit
next:
	mov    ax,mousey
	mov    bx,mousex
	call   restore_m
	add    mousex, cx
	add    mousey, dx		

	cmp    mousex, 0
	jge    next1
	mov    mousex, 0
next1:	cmp    mousex, 770
	jle    next2
	mov    mousex, 770
next2:	cmp    mousey, 0
	jge    next3
	mov    mousey, 0
next3:	cmp    mousey, 570
	jle    next4
	mov    mousey, 570
next4:
	mov    ax,  mousey
	mov    bx,  mousex
	call   store_m
	call   drawmouse
exit:	pop    es
	pop    ds
	popa
	iret
intr8mouse   endp			
;===============================================================
	

;===============================================================

;画鼠标
;入口参数:mousex,mousey,鼠标热点位置
;出口参数:无
drawmouse   proc   far
	pusha
	push ds
	
	mov  dx,data
	mov  ds,dx
	mov  ax,mousey
	mov  bx,mousex
	mov  si,P_COPY
	RGB  0,255,0
	mov  cx,30
	call vertical
	mov  dx,2
	mov  cx,30
	call draw_jiao
	
	add  ax,20
	add  bx,10
	mov  dx,1
	mov  cx,10
	call draw_jiao
	mov  cx,10
	call drawline_y
	
	pop  ds
	popa
	ret
drawmouse   endp	

;===============================================================
;保存鼠标覆盖的区域

store_m  proc   far
        pusha
        push  ds
        mov  ax,mousey
        mov  bx,mousex
        mov  dx,data
        mov  ds,dx
        lea  di,buf
        mov  cx,30
lopa:   call readpoint
	inc  ax      
	loop  lopa
	
	mov  cx,10
lopb:   call readpoint
	dec  ax
	inc  bx
	loop lopb

	mov  cx,9
lopc:   call readpoint
	inc  ax
	inc  bx
	call readpoint
	inc  bx
	loop lopc		
	call readpoint
	inc  bx

	mov  cx, 30
lopd:   call readpoint
	dec  ax
	dec  bx
	loop lopd
	
	pop  ds
	popa
	ret
store_m  endp
		
;===============================================================
;恢复鼠标覆盖的区域
;AX--Y,BX---X
restore_m  proc   far
        pusha
        push  ds
        mov   ax, data
	mov   ds, ax
        
        mov  ax,mousey
        mov  bx,mousex
        mov  dx,data
	mov  ds,dx
	mov  si,P_COPY
        lea  di,buf
        mov  cx,30
lopa:   mov  bp,[di]
	call writepoint
	add  di,2
	inc  ax      
	loop  lopa
	
	mov  cx,10
lopb:   mov  bp,[di]
	call writepoint
	add  di,2
	dec  ax
	inc  bx
	loop lopb

	mov  cx,9
lopc:   mov  bp,[di]
	call writepoint
	add  di,2
	inc  ax
	inc  bx
	mov  bp,[di]
	call writepoint
	add  di,2
	inc  bx
	loop lopc	
	mov  bp,[di]
	call writepoint
	add  di, 2
	inc  bx
	mov  cx, 30
lopd:   mov  bp, [di]
	call writepoint
	add  di,2
	dec  ax
	dec  bx
	loop lopd
	
	pop  ds
	popa
	ret
restore_m  endp
		
;===============================================================
;恢复光标原位置的图像
restore_b      proc    far
	pusha
	push   ds
	mov    ax,    data
	mov    ds,    ax
	mov    bx,    old_pos_x
	mov    dx,    bx
	mov    ax,    old_pos_y
	mov    cx,    ax
	add    cx,    20
	mov    si,    P_COPY
	lea    di,    guangbiao
	call   putimmage
	pop   ds
	popa
	ret
restore_b       endp

;===============================================================
;保存光标位置区域
store_b       proc     far
	pusha
	push   ds
	mov    ax,   data
	mov    ds,   ax
	mov    bx,   new_pos_x
	mov    dx,   bx
	mov    ax,   new_pos_y	
	mov    cx,   ax

	add    cx,   20
	lea    di,   guangbiao
	call   getimmage
	pop   ds
	popa
	ret
store_b      endp
;===============================================================
;显示光标
disppear_b    proc    far
	pusha
	push  ds
	mov   ax,    data
	mov   ds,    ax
	mov   si,    P_COPY
	mov   bp,    color
	mov   ax,    new_pos_y
	mov   bx,    new_pos_x
	mov   cx,    20
	call  vertical
	pop   ds
	popa
	ret
disppear_b     endp
;===============================================================       



code   	 ends
	 end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -