-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmouse2.asm
88 lines (73 loc) · 1.32 KB
/
mouse2.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
; mouse drawing.
; press left mouse button to draw.
; for a real test click external->run from the emulator's menu.
name "mouse2"
org 100h
jmp start
oldX dw -1
oldY dw 0
start:
mov ah, 00
mov al, 13h ; set screen to 256 colors, 320x200 pixels.
int 10h
; reset mouse and get its status:
mov ax, 0
int 33h
cmp ax, 0
; display mouse cursor:
;mov ax, 1
;int 33h
check_mouse_button:
mov ax, 3
int 33h
shr cx, 1 ; x/2 - in this mode the value of CX is doubled.
cmp bx, 1
jne xor_cursor:
mov al, 1010b ; pixel color
jmp draw_pixel
xor_cursor:
cmp oldX, -1
je not_required
push cx
push dx
mov cx, oldX
mov dx, oldY
mov ah, 0dh ; get pixel.
int 10h
xor al, 1111b ; pixel color
mov ah, 0ch ; set pixel
int 10h
pop dx
pop cx
not_required:
mov ah, 0dh ; get pixel.
int 10h
xor al, 1111b ; pixel color
mov oldX, cx
mov oldY, dx
draw_pixel:
mov ah, 0ch ; set pixel
int 10h
check_esc_key:
mov dl, 255
mov ah, 6
int 21h
cmp al, 27 ; esc?
jne check_mouse_button
stop:
;mov ax, 2 ; hide mouse cursor.
;int 33h
mov ax, 3 ; back to text mode: 80x25
int 10h
; show box-shaped blinking text cursor:
mov ah, 1
mov ch, 0
mov cl, 8
int 10h
mov dx, offset msg
mov ah, 9
int 21h
mov ah, 0
int 16h
ret
msg db " press any key.... $"