|
这是我学习assembly language第一周所写的一份PS/2 for 鼠标测试程序(DOS)。其中Mouse驱动部分我参照网上的一些代码,但已无从知道出处。呵呵,你还能找到这样好的PS/2的代码吗?如能帮助到您,希望您也能共享一些东西让大家分享。。6 j5 {8 A2 s. M# D6 B$ J6 d
9 j; B9 `4 j. P5 F0 M7 A
代码很乱,我不重新排版了。 Download回去,你们自己排!这样也好多看看代码- ;
+ o1 Q1 Y/ _7 T6 p - ; Ufoit PS2 Mouse test program Ver 0.99 V+ k0 d1 D* N+ F8 O7 M! R
- ; By Bini.Yi 易祝兵
" ^! e% w$ T+ \, S2 } - ; http://www.ufoit.com 计匠网
% \6 _5 f* c$ `2 H1 u - ; 2002/04/06 YYYY/MM/DD) T" E7 I+ Z2 `& P% b; j w8 \! A/ V
- ;
# j! s$ r" t. }3 Z$ ~ - ; 8 J, {& O [1 x$ N! Z4 P
- ; This program test the mouse button click and move.
6 e/ k S- Y3 |# w - ;) ?; v6 y6 o) p. B8 ?4 U
' Q" Y# I* o; r' ~4 q- .model tiny
& s: K* c8 A- T - .586
" o* S6 ]' Z% m9 Z$ Y+ M - .code! U* u0 a; |/ h3 D9 `# C6 M5 h: ?& v
- .stack 100h2 S, z% X* @. t! @+ Y5 t r
- .startup$ g8 M" h/ A' i
- pusha
a0 z9 P) G- q. ]5 V' o+ q8 a. s - mov ax, 3533h
6 V% R8 s- s( M+ m - int 21h" A# i; t$ Q/ B" ?& v
- mov word ptr cs:[old331],es- }: Q# f; } h S
- mov word ptr cs:[old332],bx
6 b6 d9 N3 d8 w. I+ @4 I4 K - mov ax, 3574h
/ S: k+ ~( t$ N* F; O o - int 21h& I4 k, _2 d- J5 h; M
- mov word ptr cs:[old741],es1 j* y% z: w: f; l4 Y8 E6 g
- mov word ptr cs:[old742],bx
$ C. p t$ L/ V0 t - popa9 F7 S7 T- @& B+ e- Y! L
- call memmouse; `2 Y2 z5 ~6 q* h! B5 B m$ `
- mov ah, 005 u4 g N8 u; h/ o5 }7 D
- mov al, 03( t4 g: j7 n* `. |6 F* J
- int 10h
4 |$ R! o" m% S. V5 x - mov ah, 06/ z% U6 P! K# Y! ~& o6 V0 Z
- mov al, 01 @3 _, [+ Q; D
- mov cx, 08 ^- U% V" k: p, R: j) v
- mov dh, 247 P& x8 W* n- }5 n& e9 f: Q
- mov dl, 79, i: |1 }/ b/ N, i5 H
- mov bh, 07h1 {" X6 E/ A: n* K
- int 10h
% _3 D) k5 \9 k/ r - mov ax, 0000% {: ]" z/ z5 e @1 _" m
- mov bx, 00022 T9 U' o+ d2 T8 F! ^* a
- int 33h
0 S- C$ l7 A4 ^1 } - cmp ax, 0000 ;if no mouse drive install
5 L7 k! s4 }+ Q* f7 B1 \' c# S7 ^ - je errormsg ;show error MSG
/ M2 m- f+ h! C' g - mov ah, 02
+ i) N% v) M: Y) m) t - mov bh, 00' z# S& W2 t3 @8 F6 F# V" n
- mov dh, 25 ;Move point out screen
9 z3 Q; c7 i. n8 U4 H6 | - mov dl, 79
1 V8 l8 B* s$ q$ a - int 10h
7 N: G' a- R$ ^2 }, H; r) r - call showmsg ;Show info5 } [% X2 V" H: q9 Q
- mov ax, 0001
4 s* r7 F' o3 T5 l7 [% T# x/ n - int 33h
2 v X7 E: e: M( c/ @ - ; mov ax, 000ah
( |6 f, X+ s" r1 J - ; mov bx, 0000
# V6 z9 C) h. d5 u) l2 J D - ; mov cl, 0h
4 z$ A1 x) t; F& M3 i6 o$ b - ; mov ch, 0F0h
; T8 a+ P8 _; ] - ; mov dl, 0h6 Z& T/ p( O- W( ^' N0 P7 _
- ; mov dh, 0F0h9 O0 O( W' a+ ^
- ; int 33h
; Q) P! t4 Z* C3 v4 P - mov ax, 0004h0 {- z" x8 n# G, p' S7 w" y5 U( r
- mov cx, 0319" l$ T4 l! e2 s9 {) _6 t5 \9 g
- mov dx, 0103
7 e2 w, m8 U, n( w$ L - int 33h
9 ^0 O7 G# F' j" R - casemo: ;Case button click and point move 9 \7 \+ h' g. j" s# X; K4 v
- mov ax, 000bh ;and keyboard press
. g( e+ V: L/ \, q: e - int 33h# ?+ I9 f1 R. L, `% o
- cmp cx, 00h ;if point move....X
1 G# h* q& a8 x - jne xmov
) k+ a* T0 L. E" a% S - cmp dx, 00h ;if point move....Y( Q( ]% I4 ] s1 v, }& t
- jne ymov
& R$ S4 U |% N! A/ a - xymovend: ;X.Y move end7 C( [' C' Y* w! S0 F
- mov ax, 0003
- _3 Y, r5 w1 c! q8 Y3 g - int 33h& T5 ]0 g" |8 ^( E' {
- cmp bx, 0001 ;if left button click show ON
3 s* X \, k% X; Q Y - mov si, 1828
2 L! @" x0 x3 a9 @) \7 Y' b - je listl2 Q* Q% H& g* V7 Y& b
- mov si, 1828
6 Q9 ], e- v3 q2 P3 y6 ]0 u! W - jne nlistl ;if left no click show OFF$ f/ l- ] ^% l( N
- testr:
0 c+ s, K$ s/ m# h8 o) k* f - cmp bx, 0002 ;if right button click show ON
( ?* m9 a) u# c: w8 {$ s - mov si,1842
' u. d s* v2 u - je listr& e1 ~2 [$ }+ `8 g' T/ J) Z* j
- mov si,1842 ;if right no click show OFF
; e- B7 a0 p, J, q0 d - jne nlistl
8 @! K/ \# Z: _2 E: s, s1 ~( w - casekey:
1 }. @+ t9 ~: Q% I - mov ah, 01 ;if any key press jump check
) f2 W" A8 ~4 P4 F! D - int 16h3 P( w3 e3 M' m/ C( O5 Q X
- jne kpress1 ?( F1 f" R( o9 h, D# Q
- mov al, [chkl] ;check x flag
/ k# k. V; r: v+ L - cmp al, 02h0 b# x6 b. d8 c @7 M5 x
- jnb chkok0 q: j& F, \6 M$ w( s# W
- jmp casemo. t% D: u" z% I! P9 g
- xmov: ;if X moved, get the X flag+19 G& Y8 }1 x$ r2 q$ B5 A
- mov al, [chkl]! ~, Z8 I/ q& H
- inc al- C4 e! _! S, B1 b8 \+ B9 G4 ]- Z
- mov [chkl], al
% C6 G( n/ U$ M& K6 z% R6 f I - call passok7 ]" H! v* \' {, A2 k
- jmp xymovend. P& t6 X& q. p2 L |4 j4 ]/ I
- ymov: ;if Y moved, get the X flag+15 k2 O/ `% B, ?( `$ v+ ~8 S: T
- mov al, [chkr]
: v* s; p: H2 z- W5 `+ n - inc al6 K4 z9 r# P9 f
- mov [chkr], al
0 H0 T- i1 D- e2 O - call passok
' r/ \& W5 t# Q* T% a - jmp xymovend+ B/ o! `, m" T- L" ^0 p* w1 Q# ~
- ( N7 ~. k9 u# V. I& c
- passok proc near
3 G8 j9 |0 i' F' K# M* W - mov al, [okcheck]
4 n. n4 Z4 b3 e. X$ o& v - cmp al, 18 ~2 H; ^6 D8 q- O/ }$ z7 f) f
- je let0
8 z# G! c6 C. Z+ s1 f - jmp passret9 c. E/ h0 ~8 N. S6 q+ y. ^
- let0:
2 f/ K4 E7 B+ l' V( R$ t+ Z9 g - mov [pass], 1; @ z3 i$ f D h5 h% V3 |
- passret:. }- ~: y+ l: B, ^+ [, P
- ret2 h# A8 u0 u p6 m* m* E5 `
- passok endp ' j& d2 G' b2 M0 L. w1 p
9 |/ P( t$ N: b# C. ~- }1 s- chkok: ;if x flag and y flag>=2 and... then PASS
# h g Z9 o* G: c - mov al, [chkr]+ b5 S6 ]1 D5 s# ?6 ?) m
- cmp al, 02h, J, H2 @. d) \' v
- jb casemo
9 @1 S2 v$ W9 m - mov al, [lk]
! j% ~8 ]1 {4 R% y- B. c - cmp al, 1
6 @* R+ L ?! L) \. b - jne casemo" c2 o2 o& T o) D& _. j+ a0 N
- mov al, [rk]
$ `7 A, F) H4 ? - cmp al, 1
: _1 a) v+ s8 l2 |3 ?9 m+ A - jne casemo; R+ ?# y( ~ U X# I
- mov [okcheck], 1& L- `1 Q& N+ s9 A" A; S, A
- mov al, [pass]
: Q3 h) V# C4 c- o - cmp al, 19 S4 B7 w5 D) J& H/ i$ v
- jne casemo
( C# t- [- X, N& I* ~/ x( i - mov ax,0002h4 q' v: |9 L! | p
- int 33h
5 T$ H0 [3 L5 F- G - call cleascr
4 D: T7 t' U3 e- e+ P* J
1 z, M* \' v% a, ~8 q- call oldint6 L" l' b3 ?1 ]0 g. m
- mov ax, 04c00h8 o$ U/ {, c- `* N8 ?
- int 21h. C$ P" L- k8 [% N* h8 A
# h- c- e+ e; r- okexit:& Q4 U+ Y9 n1 i" @! o
- mov ah, 4ch
" X8 O4 u& c4 r! k% B8 b - mov al, 08 X$ j% j$ O% v( q8 X& A& |
- int 21h
2 ]3 k! d0 ?. c - listl: ;Show ON
$ ?3 q" `% o C9 `: z, y - pusha
- ^2 }8 z# p. B" N* \) [ - mov ax, 0b800h5 _2 \8 f" K2 |% Q+ c
- mov es, ax1 ~% _2 X; W, m, [, T9 U
- mov ah, 47h& E, B0 V3 F% ?) j
- mov al, 20h
6 Q3 g6 ^ R$ E( [ j3 g# M) u - mov es:[si], ax2 [9 q, J! p$ k f
- add si, 02) g& B V) L* x. ~' r5 x
- mov al, 4fh
' ?9 r' ~7 W% Q+ ]3 P - mov es:[si], ax
8 Z+ p) g, \$ x2 J - mov al, 4eh
( B2 F( C/ E) O* i" o - add si, 02
x1 m% I. @. v* k+ B: { - mov es:[si], ax
0 F5 c+ V+ u/ y. m4 p! s7 v. ~4 Q - mov [lk], 1
1 l* z" w0 R7 X; F - popa7 v& L/ C$ M1 r% z! n$ Z
- jmp testr( a3 d- i% ? K+ I- x
- listr: ;Show ON4 V* L. G3 A7 J; X( O
- pusha
3 X% I& R; t1 h# u# U - mov ax, 0b800h( @; g' {7 |9 N' f0 s% W8 ?
- mov es, ax
- z6 V" x: ]2 ?* Z6 {" z, z5 v - mov ah, 47h
7 [0 l9 B; a6 C, H' P" b$ K" Y - mov al, 20h
+ Z! V. @& |" h6 i - mov es:[si], ax
6 H. P% T+ ]: ], I0 G9 Q1 z6 v6 z - add si, 02+ A4 W r' b9 I1 M0 T( K
- mov al, 4fh
G, w: @6 I/ L. x - mov es:[si], ax
+ X' s! `+ _/ C - mov al, 4eh( b% v1 h+ k. t4 O7 v7 i+ U
- add si, 02
! B, U& a) x; z0 Z - mov es:[si], ax
3 @' c7 j! n" I2 \: J2 P: _ - mov [rk], 1
/ l5 M8 E) S2 {+ [ - popa
' t7 n7 o3 y( p - jmp casekey2 [# p4 n/ `. Z
- 2 s; X8 G9 v7 c
- nlistl: ;Show OFF
5 e0 a- s1 P4 u) \ - pusha
% l) u* d' y+ k( G - mov ax, 0b800h+ M1 `+ }2 \, p8 Q4 M
- mov es, ax* w* F' }& I& \9 l* e
- mov ah, 17h
2 ^3 k7 K' l8 a7 o& \ L - mov al, 4fh
: {; @) t! l0 N) Z3 ` - mov es:[si], ax
$ ~7 h+ H6 a3 b - add si, 02
2 r9 R- a) U! _ - mov al, 46h& _; h& \2 j& ^$ O1 I& f P5 K( X* v3 I
- mov es:[si], ax
( v; _0 I z# G$ K" }4 p4 y - mov al, 46h
5 U7 X* W; T6 Q, K: S6 R - add si, 02 u) V; S0 J5 S! }
- mov es:[si], ax
# X3 @, w+ Q7 M# g8 f; Z1 D& G - popa
3 f i( w1 t& x9 B - cmp si, 1840
4 I: a: N) v# n - jae casekey) c# }* N: k& V4 m+ s5 }
- jmp testr
+ A) n# Z$ w7 ^! _9 ?# u m* D - 8 @* g) Z7 j2 x& @/ @' f, `
- kpress: ;Check key press if press<ESC> then EXIT
2 V; H' R( T4 F3 T - cmp ah, 01h ;and return a error
) |- g# r9 u9 z2 R - je exit11 A7 A: Q; v5 ~
- mov ah, 0ch ;if press other key then clear* _ l2 K2 n' b% c- n/ n8 R' v
- mov al, 00 ;keyboard buffer
% { z8 L7 p. u: D2 c - int 21h
6 s: F1 N$ b; L# ^- J3 C' } - jmp casemo ( g7 U$ R4 o6 S5 j
. n% l& |* `' z% T: f0 N* u2 e4 `. R- errormsg: ;if mouse driver no install
4 q" }& t5 N8 t Z& S) o+ i' W# T9 g - call oldint
/ P8 y6 N6 f7 s4 P; V3 f - lea dx, offset emsg
1 T& ?8 a; }& i5 C) e( M+ W. w - mov ah, 09h% p( S6 X- [# ~- A3 F) F
- int 21h
# r# j% l- y/ m2 i( m0 ^. Q - mov ah, 4ch
! L" T/ c: B5 t1 o' M - mov al, 2% z+ I! K" c& k
- int 21h4 q! ?2 I3 S" C0 m9 d
: `7 f3 w6 B4 u. \) w- exit1: ;error exit
' d7 k+ w: D3 z* ^ - mov ax, 0002h% q- N8 G; W, y/ s# Q
- int 33h
0 V! G# \8 }) {: ^7 e - call cleascr' \) q' { {2 M% ~/ ]
- call oldint! @5 b7 J$ P _! G+ P0 q7 t7 G1 H
- mov ah, 4ch
2 s: {2 f9 i F+ t Y - mov al, 01
/ ]' K% ]6 m5 X' i! u$ s4 k4 T5 m/ q Z - int 21h! H% g ~3 h* a/ L% N7 B; m# u) ?
$ i" N1 s6 P S O" L; ^4 G- cleascr proc near ;clear screen7 T% u' `. v5 n0 W9 s5 Q
- pusha$ v# E0 ]. B8 j+ o$ \: r
- mov ah, 067 y! ?' E0 p4 h7 S, E) j
- mov al, 0# {: N( z8 }3 h- D
- mov cx, 0
* U+ E5 I* ?8 }6 A& w+ x - mov dh, 24
5 l6 w0 A9 x; T - mov dl, 793 {) `+ x) X, y( y
- mov bh, 07h
& v c% v3 A1 G3 O - int 10h3 @+ X) K# D: s, k
- mov ah, 02
" [5 {; v5 T |9 F6 e8 O% [9 h6 b - mov bh, 00: p7 \3 K9 W. P9 M6 w
- mov dh, 0
" d% [" k* w* A- d0 z7 ~' n - mov dl, 01 m- G2 j2 H4 q3 ?
- int 10h
H6 E [4 o0 \6 v. P - popa: l- D6 h3 N( @3 y; C( b2 D
- ret
' m( t8 d% ?! I, Q) T7 T - cleascr endp" y0 V2 d' b* ?: D4 T9 r w
- 5 g. T0 P( i$ v8 C1 y+ @0 Y4 I
- showmsg proc near ;Show info. z" j6 E& {* y. `& I! @
- pusha% I A. U3 F3 ]
- lea di, offset showms/ a7 a5 K6 \: B) F) h7 |( ?
- mov ax, 0b800h
, K; p5 R* W! D3 A( R# M, j* n/ L - mov es, ax0 l, ]- W* O' W7 P0 Y( m
- mov si, 0/ m8 ^# R) n5 y4 s. `& r* m( |& Y
- mov cx, 480
3 w4 L$ s5 r/ j0 t8 s6 ?: Y - mov ah, 07h, I: A+ Z* X8 u6 t0 T) S0 r
- @@:/ x- s% w% y& V8 M
- mov al, 20h4 r1 U) E0 ~* y9 w
- mov es:[si], ax" a5 ^3 e2 _- ]% a# J
- add si, 2) W: S9 ~ N4 i- H% l4 v# n
- loop @b+ ^2 j. X" u9 n$ ^, d+ U
- mov cx,880& r: s( d" K4 m; b
- @@:
5 u; D4 z; ^6 }6 P, g- y6 U4 H& t+ W% S - mov al, [di]. p( R. Z/ }4 l+ J% `
- inc di7 @4 ^* D, Q+ h! x& p6 f- ?. C |
- cmp al,20h
- d: w; w( U7 t2 f - je showch1
! x. s$ t8 \2 {; a. [8 x0 O! x( w - mov ah, 17h
5 X+ D* x, o7 q% p; d8 Y - jmp showch3 + z- p$ ~9 _6 T3 {8 S
- showch1: ]* ~( C& z" e _' a
- mov ah, 07h 9 I0 E j% u3 }- T! D
- showch3:: n ~! _4 {( P+ p8 q
- mov es:[si], ax+ u: [. [1 ` G$ E5 ]
- add si, 2
, C6 q# i" R- b6 H8 T( @% ` - loop @b
- K/ Z. d' F% @5 h - popa$ E2 q$ Z+ c$ }/ C( K. m d$ E
- ret3 h& h- P: {' q1 ^
- showmsg endp! K! ~" [4 h2 `" |$ x3 p. Z4 \4 n
- * X! d( _& `5 t S
- oldint proc
: P, ?& W0 M% ^& ?8 Z& b. ^ - pusha% P* T+ L; F2 z5 s: U9 W# P
- mov ds, word ptr cs:[old331]
/ b! D- g( I- U - mov dx, word ptr cs:[old332]' l3 k8 K5 ~* S4 j9 R/ [
- mov ax, 2533h, g4 I0 n/ ~# c5 o- [* }
- int 21h
# b& x T$ C2 h& u7 q - mov ds, word ptr cs:[old741]
2 o9 n3 I" q. x - mov dx, word ptr cs:[old742]
$ v8 i) k3 X& F# W - mov ax, 2574h6 T8 I! N& y- e' `
- int 21h
( q1 U' b2 S& V: Q4 q - popa
$ P9 z5 ^4 |: y+ g' P; Y - ret
2 f; x; {: d! W3 ?% U) h$ E - oldint endp
) h4 s5 \" c9 b4 @1 O/ [
' j4 P& p* `; s6 o3 T0 w( b; j- memmouse proc8 Y( Q" }4 r& `0 Z9 d
- xor ax,ax
, ^& j X& ^" O' \. q - int 33h
7 B; F( m* z+ b# R9 }! U. A - cmp ax,0ffffh$ F9 x# v, g( R2 L% j
- jne not_loaded
: T$ m; S$ Q- E& s+ T - mov [memcopy], 1
5 ~5 s- `6 {$ o/ y - ret
$ c9 t: A5 C7 F7 [* K -
, b+ t8 f; m X. y; b( ? - not_loaded:
8 Q: H& ]3 d, b5 O1 |) v4 x5 h; _& T - ! W, k2 y; b# K. h( c
- mov ax,2574h
3 O: e! C) R% \$ k; N5 @ - mov dx,offset new_isr
z0 e/ f. W- a# {7 v - int 21h: h% q/ X4 T1 B. A9 d
& `5 z" T8 v# z9 @: F7 }! _6 N5 u- mov ax,2533h
: B* [2 ~; c9 L$ s2 J! {. g - mov dx,offset new_33
0 X8 e1 B1 U. s8 b - int 21h
: M$ ^% p n8 Q; \8 C% [1 u - , v( F; O" s' F- B6 B; D: o; w
- cli* K( O( S- }8 B6 z1 }! b! J+ z
5 D6 H- f: F3 x w+ J- mov bl,0a8h
' Q2 x8 O/ U9 Q) w/ I1 Z% O - call keyboard_cmd
: ?6 K( S) j6 u$ ^/ O
5 S# a7 }! x2 `* C) ]5 J3 Z. V- mov bl,20h+ V0 J$ e! T2 x3 B: `
- call keyboard_cmd
9 M- _% b/ d j* G" C6 b% ` - call keyboard_read- D* l- ^0 R3 R# n* f2 y; W( R7 \
- or al,2
* Z: d/ W: }( z# ~ - mov bl,60h
) J* `) }+ f. c5 p* W R( H - push ax
% G9 r5 _; ~- j0 r& g+ ^& d - call keyboard_cmd
6 M0 t# U/ i6 x5 e - pop ax' q3 B4 s3 W: }2 n3 r4 r
- call keyboard_write/ q( R I5 z" e/ |+ Q* P1 L
! P! O6 E# p5 U5 G8 Z; W- mov bl,0d4h
& f' |1 e3 s9 n; g( ?. e4 Q: j( Y7 m - call keyboard_cmd/ I' v. Q: M* b3 I- I) r: |! [1 `
- mov al,0f4h D$ C% W$ v4 ^1 A# W
- call keyboard_write
% m" J( x# i# K' G" f0 ]
/ j# s6 t7 m9 r) c0 `- sti
' ^0 _' x4 x6 s - ret1 r2 C- ~1 @, J P! y h2 n M
- call_user_isr:
/ N* H# ~. g1 {' N. ` - db 60h# S* f: h+ {9 ~% n' j
- mov cx,cs:[pos_x]5 D; g+ u0 V& e3 y$ U/ V5 u4 ?8 ]
- mov dx,cs:[pos_y]
# x) s+ O/ c7 D - mov di,0 ;cs:[x_move]$ Y5 w% b7 p' C1 u0 Z
- mov si,0 ;cs:[y_move]% {, @9 E' I" M9 U7 z
- mov word ptr cs:[x_move],0
/ W. ^7 b" Q; O" r4 W - mov word ptr cs:[y_move],0' S( K& d) a6 i6 |1 A$ ~, \
- mov bl,byte ptr cs:[buttons]
5 w) H: g) l5 U7 Y# C o/ `3 |# S - xor bh,bh1 r8 j0 o8 ~) M; B
- call dword ptr cs:[user_subroutine]
1 Q' |7 I# D5 L, V: b - db 61h7 ~" Y$ Q' j' a' z* ^& V. E
- ret
3 M% y4 H+ ^5 `2 _! Z - new_isr:
8 h$ U. S9 B! i& A; j: N% d, d - pushf
* v/ X6 p/ Y0 W! t/ y+ C - cli+ M2 W: U" d6 |5 w
- push ax
6 H& e) f8 m0 B! u - push bx. p+ ^6 g- \1 W; E4 z5 X# R
- push cx
+ ?) o6 `, h, F2 v - push dx! U( b1 B7 Q d; P, h; G% Y6 R
- push di
8 U. r* L! _5 z6 e, Q - push si
& a0 t2 i: u- W( d/ d& w - push es" M" G9 v& e% U% L9 @0 I
- push ds
/ g1 ]5 N2 [ t" O - 6 [& O0 b5 F% t5 N' Y
- push cs
! ~# ~# _$ ~/ {% y/ ` - pop ds
0 Z1 j* }2 u3 K3 z, z
, w6 _+ w( B4 ]7 l$ C, Y- mov bl,0adh
9 G! E$ ~; \$ ^) Y& \( o - call keyboard_cmd. x$ s4 G* O" s
- . E2 u1 f0 D5 D6 f1 ]& i; ?
- cmp byte ptr [first_time],0
+ C' p- V6 k! i# E9 F& q) {! \ - je not_first_time) b$ T) v& N# ^$ ]9 g
: P, O4 o6 k5 J: @- mov byte ptr [first_time],0+ m2 [3 h% X$ W
- call keyboard_read
! W, [+ ~: u" t$ `2 F8 w - call keyboard_read9 H4 F( a" Y* Y, m! O6 x
- call keyboard_read/ a, N/ t: U- |! I# d7 W8 g( g, Z
- jmp no_show
* z; ~3 h' D5 F8 K, T/ l - ; P, q \8 ^ v3 L3 r& p9 O* j
- not_first_time:) ]) I7 W, W" J4 ] ~3 p% h
- mov word ptr [temp_mask],0
8 I# A/ h8 x# @5 F& L+ q - ' Z, j: M6 R5 l/ ]3 ^ Y. T
- mov cx,[pos_x]3 _3 [" [% {$ \$ Y
- mov dx,[pos_y] F7 y7 r/ B/ t7 U, h( L |( `6 L
- `4 v1 u5 w2 x4 [, Z9 t- call keyboard_read
- X* f2 L+ S7 N, V* o - and al,7 ;3: E8 P6 m, a+ V1 e& S$ O0 x" ^
- mov ah,[buttons]
4 G" B4 D! p% N. U - mov [buttons],al8 b3 ^6 `. o$ |3 S7 r: x$ ^ x
- cmp al,ah
& c/ n: }% l# e8 X, V0 U T+ | - je no_button_change
3 @( m: U! m! C/ ^ - and al,3
W$ O$ w5 V: `! V% m( C - and ah,3+ C# K1 F1 j+ j- n) Q+ r
- xor al,ah
9 H5 h1 b/ o- [/ z' n: ` - xor bx,bx
' N% m V% |% q; u+ f
7 F/ K( C8 [& L" X/ o" h g- push ax: p$ Q: j$ T9 v' g1 Z
- test al,2
( l/ _9 Y, {5 d: [5 K8 b0 | - jz no_right_button_change
3 u w5 L9 b( h/ ? - and ah,2" ^0 j$ L6 S, G( A
- jz right_button_pressed, Z+ N3 ^* v \) @# `- k- b
- or bx,16: ~- p: e* n# U c3 @
- jmp no_right_button_change
$ n8 z0 N) k! B1 \& h9 d - right_button_pressed:1 d* x6 `; l7 J% M$ @7 l! t
- or bx,8
0 G1 ^ E6 \3 A0 N) ?: v r - no_right_button_change:
: O8 x* ^, X1 B2 N g
0 s3 U- i5 [5 y% T- H! X- pop ax6 l% r4 o; s6 ^
6 o: J# y) X+ ~* _$ J- test al,1
) k" K' }$ V, \: Z - jz no_left_button_change9 c$ @' e: H3 k I$ u% H
- and ah,1
$ D6 _0 E# X: H - jz left_button_pressed
2 E. X/ `) N% D: |* T# N - or bx,4
; A B8 I7 i1 ` - jmp no_left_button_change- F: h: [9 l! S7 I
- left_button_pressed:: B& ]0 u6 J3 O3 n: F5 O( m5 p
- or bx,2
" a" L- q4 T2 H3 Z: | - no_left_button_change:0 \. U" Z1 y* w6 K4 }
- ; T9 @& j. N$ {+ c; l
- mov [temp_mask],bx
" Q% J- ]1 E, y3 a4 [) F$ B9 C - 0 I) e& v: M4 z8 M
- no_button_change:8 u4 E; f* v( ^1 _1 q4 ~
- call keyboard_read
2 V3 V1 S3 |- T8 T0 {7 y - cbw& m5 ]! ^+ O. S8 l3 C" J
- add [pos_x],ax
% X9 N8 N: R9 ]/ @# o - add [x_move],ax
/ y4 n! S. U% q8 M; b! i, z - mov ax,[x_min]
' _$ J8 S' B+ S - cmp [pos_x],ax) G" ^$ ]! |& @) x1 z) b M% }3 L
- jg good_hor1
' k- m) L8 c/ R2 x; t1 Q6 P - mov [pos_x],ax
" y. L( p! H- X6 O, P' I - good_hor1:
6 K3 O x3 [6 k - mov ax,[x_max]
+ A0 q0 I# r8 S* B& V - cmp [pos_x],ax
; f1 ]& k _ t5 w/ q3 n7 r+ D/ b; _% f - jle good_hor2: G9 I6 G0 [# R1 q1 o6 G
- mov [pos_x],ax
1 Y4 W# }; a5 X3 {: c4 s/ O - good_hor2:$ e, \) Y* u. O2 v, Y, h; E4 Q) L
0 D" N" i6 t% F4 W- call keyboard_read
: q M5 v. m- a J3 `2 W5 v8 w - neg al
1 J0 q7 E: @0 K- Z. j- G; M6 m8 U& H; e - cbw
0 F$ v' m; U% N$ z; `% s, o - add [pos_y],ax
" s) \* N. m' `0 v9 j- I) A4 H$ x - add [y_move],ax8 L3 P! q' b$ ]; H: D+ A4 T
- mov ax,[y_min]# s. i5 F& L0 Q+ X3 a
- cmp [pos_y],ax& u/ k9 k: [" S) _
- jg good_ver1
7 a M- O$ ^2 q; r' a. N0 o - mov [pos_y],ax& L; J. ^% K4 E2 K U7 |; U
- good_ver1:
8 a1 `7 U1 I( J& p. T, I - mov ax,[y_max]
+ p2 k4 S' l$ ?! C+ T - cmp [pos_y],ax
& T a# b. y, t3 N6 X) ^* s* j9 b+ L - jle good_ver2: ?9 s" L, Z/ x% E+ l) s
- mov [pos_y],ax
9 h' R' C6 T1 U" e# M/ x, t$ p - good_ver2:
) |: k; D9 N$ e" x) l - : E: E8 U5 ^" f" h! U
- mov ax,[x_move]5 @+ j$ E8 S. V/ O7 e0 v5 e; a3 b1 {6 q
- or ax,[y_move]
. v$ [: U. P3 j% ?( ^" }& h' Z - or ax,ax
1 l+ I- U* C5 J' l$ s) z - jz no_change_position; d( i* \( u8 a7 J$ f
- or word ptr [temp_mask],1
0 M7 L! }7 W+ T% A; G. g& |: J - no_change_position:
6 C9 X- o& T* @0 p v" I
% y E2 u' ~" T9 ~6 M* s% y2 C- mov ax,[temp_mask]
. M( Z$ t, l" d4 k P6 ?$ D - and ax,[user_mask]
, G0 D9 w, X9 p' @/ S# H/ ? - jz no_call_user
: h. a B; B9 N# O( a( i - call call_user_isr
2 ~: P9 W0 S# G - no_call_user:' F3 g" t: m8 O
* R& I2 l7 F- P8 P. a- cmp byte ptr [sm_flag],19 F' a6 R# g& R1 p; T" i
- jne no_show
8 i+ C3 q3 K$ @' R, T# {
/ f$ @2 c, _% _7 P% p* k, p& d* P- shr cx,3
' `' Y$ I3 @. {5 m# N0 M" p - shr dx,3) b& ~- t3 U$ W1 i. F. L- G
- mov ax,80
9 H% j* ?6 z O, i - mul dl
8 ~2 |; b' [' G4 _) X0 ^ - add ax,cx
' t2 |( L4 A. q0 d - shl ax,1
4 v; E: N5 ?$ K6 f5 @1 A - mov di,ax
% [# |( o9 b7 _2 t - mov ax,0b800h+ L; Z- k6 F2 t: s% y+ ]* x( q2 v
- mov es,ax0 ]& Y9 }- M0 H: ^
- mov ax,[save_char]% {" J$ ^/ z( ], ~1 \2 `8 q
- stosw% X6 g$ r* F& g8 ^2 F
- ; {" Q0 C& J1 _: K
- mov cx,[pos_x]8 c7 Y/ H! C% g/ y1 {* y
- mov dx,[pos_y], t7 a, R1 U8 t' A
- shr cx,3
0 P, K1 D- C: `! [! d3 v: _ B8 v - shr dx,3
$ Z; ?: f7 f" G$ `( t$ Y - mov ax,80
3 O7 P# G" E+ R- S3 s( i' y - mul dl
( W. I/ O9 T; _9 w- l - add ax,cx
0 u! x" R$ n. ` - shl ax,1& Z& o! g# D5 s6 @, ?! f7 j
- mov di,ax/ Z2 O' r4 V/ z2 R) A m) j5 \
- mov ax,0b800h2 I( X' d( k9 m& T7 @
- mov es,ax
' D& r/ N* P$ H" K - mov ax,es:[di]
m8 N' X' O2 \+ k# N T3 j - mov [save_char],ax
" X5 f o; o- O" Y$ n - not ah
5 [5 q3 \1 O; ^ - and ah,7fh
8 O/ X) N; `: E) [2 O$ s* R& q% ` - stosw J$ y. g3 \( l1 {4 [
- no_show:
( L H8 H4 s: S1 r4 W - mov bl,0aeh/ S+ P. U0 a! h
- call keyboard_cmd3 J; ]! j: r, u, s2 i" a
* w8 k( R m* O2 {( B- mov al,20h* K6 p" w$ E: E# O
- out 0a0h,al
; @$ `% P* }' {) @* h* s - out 20h,al
% M Z0 t4 T' A - 9 X: v8 M, C* X$ L
- pop ds1 ^9 O% \4 ?1 T! e# ~
- pop es
0 n7 C2 x8 k7 S/ |; c - pop si
: {9 _& K) G# J# T! a( C: R9 g - pop di
0 Y0 a) Q4 k C3 A4 [ - pop dx
6 r% ^1 T1 o/ E& S) N; w6 I - pop cx: _! z0 N1 v0 Z/ z; ]2 g
- pop bx& I8 v6 O/ K, }7 F8 C7 N9 R
- pop ax
R1 K x; ^" ^. ^+ |- i8 E - popf
: v. z; H- ]7 [' Z+ h - iret8 a F7 {. `' R' s$ u
- + z5 M2 E, ?. K0 E' d$ T
- first_time db 1( k" r7 a0 ]4 _, F I
- buttons db 0
I, x. t& I9 W3 Z0 r - pos_x dw 0
& s; ]9 K& C2 G+ S9 T1 C, i: M - pos_y dw 0: @5 a5 ^6 N, k0 M, d0 k) V
- sm_flag dw 03 c7 b' R1 C1 e) ?
- save_char dw 0
) v- k8 h% c( v+ N( U6 }; Q/ V5 [0 k - x_move dw 02 k! H+ e/ g/ N& g% q: r5 f# }" U
- y_move dw 0( j5 e7 V; {% R: d
- x_max dw 639
! w) y. U, O* | H. D' h% S - x_min dw 0
( V3 @9 [; I8 W& B* d - y_max dw 199
. P' _4 h3 p+ i+ Y' y$ b- k0 |; R" u - y_min dw 0
6 }6 S: Q, c. P+ m3 A - user_subroutine dw 0,0* ], A9 ^. {/ C' G+ Z
- user_mask dw 0
, \1 i$ J- `4 Z$ `) f; S - temp_mask dw 0
! Q6 s2 S9 x" \6 c* C
8 d. d6 `6 z' d, p2 P- d, Y) r5 x- keyboard_read:
! {! W' Q2 p/ d. F8 ~& G. w - push cx! w3 T7 g8 V9 `$ y. k5 D, S+ W
- push dx m* |# O9 d. ]
- xor cx,cx: E( f) L3 ^8 `! J0 ?" |
- key_read_loop:
6 E7 a# i9 x" Y' H: ? - in al,64h+ a( T1 @! O& f2 Q) v
- jmp $+2
2 l. V: W) c9 O: ] - jmp $+2
1 p5 o% c6 B% K4 l% g* F - test al,1
) X j, @2 l$ V* O2 C* a6 c- w* U - jnz key_read_ready
% W) T+ s' b* _2 p - loop key_read_loop( U4 C% e s& d* _0 f2 o" H9 b3 c
- mov ah,1
8 e+ Z1 Z; Q1 f6 w - jmp key_read_exit7 W6 `& m4 ?. M. {, H: u" k9 O
- key_read_ready:8 @5 \' Q! y# H0 I0 E1 ]
- push cx' D: v2 c3 X. k2 n
- mov cx,32& T# d4 C J0 m
- key_read_delay:( j+ H6 l* F. f
- jmp $+2) z0 t8 V+ Y" e" R9 R1 T0 R
- jmp $+2
- Y$ v; c' c" D/ j2 I: M' v! z - loop key_read_delay; {9 m1 i; j9 s& ]
- , I- W: c8 g5 f$ @' y
- pop cx
9 m! V* X, d* T' ^2 y( v6 q* _ - 3 f2 d5 `1 c/ |
- in al,60h
& l9 b& V, O5 S( k1 [# P - jmp $+2
4 y6 f9 W: [3 M, a1 G4 { - jmp $+2
7 w* @( t5 n& X$ H3 n# O - xor ah,ah
; y% b$ K! ^. }; M! i - key_read_exit:4 a% [$ p8 P+ p- q! A* I3 v
- pop dx
- Z! C9 _2 g) o- ]/ e0 ? - pop cx
4 i$ c; v+ ^5 F2 J! s6 K% H - ret
3 e% S* x% ]& Q
' I1 r) j9 C+ E1 B2 \+ A- keyboard_write:- s# w$ U* ]7 Z+ J: V: S
- push cx
% m& |8 t' k0 [9 b7 e% a2 v - push dx
6 ]; a. Z* i% U- I - mov dl,al9 s! \& Q; Z2 ]0 t
- xor cx,cx5 v' o) }- k2 m
- kbd_wrt_loop1:% c: [0 F6 n1 l$ s$ |. q
- in al,64h
2 x- ]" q( {" J" D5 R O5 R; ? - jmp $+2
9 ]# B% }3 L! x+ u$ G1 E' m - jmp $+23 G; j& q! H$ g0 l5 T, n" a
- test al,20h
3 q/ }$ f0 b: J/ a. ~ - jz kbd_wrt_ok15 K/ K" ?% n( o
# @4 r) H' a+ d7 T- loop kbd_wrt_loop19 i2 X" s( e; w# k' G! v! U
- * L9 g, S# c' P8 n/ B
- mov ah,1$ i5 P! j ]; v0 }# ?
- jmp kbd_wrt_exit4 k: Y2 d% ?% `. Y& Y+ w% D2 l
- / Q, c- h3 H3 \8 r/ d
- kbd_wrt_ok1:
1 U# e4 w8 [' P- V8 v - in al,60h$ J, i" h6 B4 d3 y& X
- / H# ]' ?4 p. B. c8 r$ T' _
- xor cx,cx8 c$ b8 u$ D, ?+ ?2 o
- kbd_wrt_loop:/ y" i/ Q/ |+ M& ^
- in al,64h6 y$ p/ t! [( B9 u/ O" K
- jmp $+2
+ C. D) s! m" r' @ - jmp $+2" s4 O- D( c2 @, P) e
- test al,2; b% D/ C- ]* y, x+ d
- jz kbd_wrt_ok
: k3 `/ s( j8 A% j# x' K6 ?. }) ~4 h
7 Y S) {' V, f8 C$ H$ @4 K1 I- loop kbd_wrt_loop' q" k8 y" h3 i
+ E! {& E4 E y7 V+ b" w- mov ah,1
& h( \1 o) }8 X) Z - jmp kbd_wrt_exit
$ t+ z+ y+ O7 k/ j: X4 P- ?$ Y% g
# D) ^ R' V7 s8 t0 M+ x- kbd_wrt_ok:! C$ g2 j) N+ t1 O8 D: C
- mov al,dl
! R8 i! P' k! B - out 60h,al
4 l2 B! b) B8 u8 B! ^: S - jmp $+2
S, T' Y' J6 Z' P" Z& B9 R - jmp $+2
$ B) W; E/ l* D9 d* w% a4 u) b
3 J) W) v" e3 A5 I' p: ]. j- xor cx,cx8 y( i8 r; \) h6 O& M- M
- kbd_wrt_loop3:
s! D3 ~ @% M1 |' f3 l) a - in al,64h
$ Q5 N. l @, ~! m6 e4 d - jmp $+2& \; F$ {# _* H/ g* M) b: r+ T$ ?
- jmp $+2
( @5 w3 A+ @) H2 K# C/ Z! K0 y) k; i% Z - test al,2
& l. n( y O3 `( B( N! @; f8 Y - jz kbd_wrt_ok3
7 x* @, ` R5 ^# q% e
7 o. S: V8 X5 m H1 b- loop kbd_wrt_loop3
8 v* z. `2 S1 z; w# G
2 Z! M, v5 e* H W- x5 k9 t$ g( F- mov ah,11 }6 y" j+ {6 `; f e
- jmp kbd_wrt_exit4 D1 `2 |# p y2 B; a
* L; {- i/ C* {' b, r- kbd_wrt_ok3:" i1 v4 ]3 E6 F1 P
- mov ah,8) \1 }/ ~- Q2 T6 X7 m0 t
- kbd_wrt_loop4:6 L0 P7 S1 z) h: q
- xor cx,cx
. ?7 q3 v( L4 ?$ \# v& p - kbd_wrt_loop5:
1 _# A+ p, M- P* [1 } - in al,64h
9 ` A. k9 d# }: M7 f$ _/ M - jmp $+2! T# S3 I; z9 i9 J8 P8 R. N+ m
- jmp $+2
+ @$ L4 ?* ` A; {- ] - test al,1+ d% k( U' }7 R; H: r
- jnz kbd_wrt_ok48 L- V$ B: [4 F
3 \) x E2 s) y8 r- loop kbd_wrt_loop5
' M+ X# L0 ~( r, R0 v9 \" N - / W2 h- e4 B( K) E
- dec ah- T2 ?% G0 [3 O% i
- jnz kbd_wrt_loop47 A, N6 F4 N- R! \6 h0 E
' _' G* f% ?2 i5 w7 p+ w( E" p' {0 }- kbd_wrt_ok4:
7 d {$ b3 |# b3 ?5 V6 p - xor ah,ah
6 h( g! e9 S: N; s( R1 u a! o - kbd_wrt_exit:' ^! {2 ]: p* `! ?- y
- pop dx% {. v3 k7 y+ e \: a8 P0 i# D
- pop cx9 c. ?% Z# i1 {& C% S% P% S: A0 K' U
- ret
* a5 M5 ?* E1 J7 X, i' Y - 6 r0 [7 T( Y$ Z6 s; d; `
- keyboard_cmd:3 O& h; V7 |0 C- B, A5 C
- xor cx,cx- S2 N; r- C$ b
- cmd_wait:
) Q6 B/ e K! _# c' `( V. f! [ - in al,64h
# q {3 Y- K- {% O2 Y: I( C - jmp $+2! A# o2 a! c1 x( T
- jmp $+2
2 D4 @7 m4 |9 o$ F, \ - test al,2
! ^& k, R: `" R3 [7 ^ - jz cmd_send, P% q2 o2 F. m( n
- loop cmd_wait# E* P) L/ V& P2 N
4 J( E" ], q5 G1 p- jmp cmd_error! q! o5 M" q7 O& |
- - A+ D. ~% `, Y! O: s
- cmd_send:$ n$ @6 y) j' M& V& q8 s, p1 s4 \
- mov al,bl
$ a, z( y4 }( f - out 64h,al5 J1 S) i9 {: v) d: ?
- jmp $+2
?1 y7 z1 ~+ D; I3 \/ F3 r - jmp $+2
- I9 p; ~( L P, {; A q- H: f - S" c% } ?5 \* Z
- xor cx,cx
! y2 k% b4 G, a9 r. R - cmd_accept:2 Z1 Y1 Y5 p+ w D8 O/ y
- in al,64h
4 B# I. t; K4 W' b$ g! W% q - jmp $+21 `; R& q, r. \0 f; I0 S
- jmp $+2
9 M& k; E5 c! C2 O7 J7 |, v" ~ - test al,2
& ^2 b6 U6 k5 }, J7 Z - jz cmd_ok/ s7 J4 q& @: ?5 F9 ?
- loop cmd_accept
! p$ }1 ^% y+ V' r) Y
. I- g( v* D f4 W7 Y- cmd_error:
- s. [. c: ]4 }. @' @2 P2 e - mov ah,1. R6 }# K }1 F/ O) T8 W4 w9 z
- jmp cmd_exit. ~8 x. T* j1 v3 J0 y V
- cmd_ok:
% u& e7 M( n3 N - xor ah,ah
0 G9 `3 Y8 q* x# Y A/ A4 [ - cmd_exit:4 u4 [, d& `6 U/ q# M
- ret
5 _1 e. Z" ?) ?5 W
) u8 Y. b& g. D2 x9 p8 p- new_33:
0 i5 @ @2 r- v! Y) j4 s7 l - cli. p B/ Z" Q/ `1 c3 p/ P. r
- cmp al,0" M# S$ w1 ^: P9 h2 l* v( y' X4 y
- je reset_mouse- r* W5 Y0 {) ?9 |4 \! j. w
- cmp al,1
$ U) ]% l) }" c) r% W0 B" o8 O - je show_mouse
, F5 W! w7 [; \" n) [& c# W- ?2 Q - cmp al,29 c' a' q( J; j8 |9 Y$ O: `
- je hide_mouse
) q( h3 ^# E J, [0 t$ Z9 Y - cmp al,3
2 Z5 c6 i0 w& i5 l! `; y; ] - je get_pos
+ |: w" i9 H2 h# v - cmp al,46 V6 U; s+ O. e. H* `! c& c
- je set_pos0 A/ o+ }% F( u# N& L
- cmp al,72 B8 }7 S* Q; q. ?( C- ^$ u7 w9 B
- je set_hor_pos
) K2 c3 j- }9 j4 s - cmp al,8/ }1 ]* e3 j/ J& W& [( U& K6 |
- je set_ver_pos5 z, x' |4 y0 j9 c8 n
- cmp al,0bh
8 _0 g( [6 Q) G3 V, I2 X - je get_mouse_movement
% c' B0 p" r* F. P9 H- Q* q - cmp al,0ch
6 n/ H# @+ {% v; D2 o$ p2 T( H; ~ - je set_subroutines" m* y: {1 {+ D D/ K; o
- cmp al,14h/ t2 v4 H- y( {4 ?
- je swap_subroutines% y( L8 U) V, e' X3 u& p, _ p( ]
- iret9 L+ g) T5 w \# P8 i9 T
5 @. u5 F2 W' k- reset_mouse:
1 S: E% X! y7 @% R/ B) x - jmp _reset_mouse% ?8 z4 [/ O- v$ F5 E$ z
- show_mouse:
9 i1 c. E3 T: e" k* q - jmp _show_mouse
5 d: G& F( D& G, o2 o - hide_mouse:
, K9 F% A0 c0 x! l - jmp _hide_mouse
$ L( t! n# y. j/ y' j% C8 R$ m - get_pos:
! M' F; H. ^/ n+ ^7 Q- V7 j - jmp _get_pos0 l8 `2 Z1 c/ [! X
- set_pos:
: u$ C) `. z/ E9 k" s0 O/ F - jmp _set_pos9 u- R: W/ o" t- A. S
- set_hor_pos:/ y% {) G( l8 `; Q. B. j3 a
- jmp _set_hor_pos
2 i% W: x( m3 o( L" v - set_ver_pos: V. y/ C5 j9 {/ C/ d. }# O
- jmp _set_ver_pos8 {! _& Q4 s: O) {- h2 H2 L& c; j% {* p
- get_mouse_movement:. I1 b1 x& F) k! l! ~7 s7 `
- jmp _get_mouse_movement; [8 A a p s6 S, |
- set_subroutines:3 p) R: C8 @" s; W T
- jmp _set_subroutines; p) j, e" P/ C
- swap_subroutines:/ E1 |- l0 w$ d% D: d5 A% ^
- jmp _swap_subroutines
' }" x- p# v% g0 ^7 b - 3 j* \+ ]$ f6 e: S$ u/ \7 b/ n5 c
- _reset_mouse:- ~! P. y# b( r! r& l& o4 v
- mov byte ptr cs:[buttons],06 i8 Q+ r3 z9 {0 G7 M
- mov word ptr cs:[pos_x],0: |8 s! `& ]6 P+ Z
- mov word ptr cs:[pos_y],0
. k: B4 B, H) e' O - mov word ptr cs:[x_move],0" ^/ N6 o8 w4 }/ r# J1 G1 F
- mov word ptr cs:[y_move],0
8 f' Y" `; H0 [( Y - mov word ptr cs:[x_max],639! l( r( |. |$ C2 ^& O$ j8 }7 C: n
- mov word ptr cs:[x_min],06 q8 g7 m1 D1 f1 F
- mov word ptr cs:[y_max],199
: Q P) D' D2 o# O4 J9 P - mov word ptr cs:[y_min],0# _, R5 M/ u: x' n1 _7 F, p7 u" C: |
- mov word ptr cs:[user_mask],0
3 m) M' w) Z# w$ [" J0 ^ - mov word ptr cs:[user_subroutine],0; L" K9 z E8 J! q9 S
- mov word ptr cs:[user_subroutine+2],0
/ T4 }3 c( J5 }% e - mov ax,0ffffh
- A+ v! @4 W2 v. M& u - mov bx,3
- j( Q$ `1 _ P0 O. h+ e$ x8 v - iret
4 E# _; L6 `4 L8 e - ) S5 k2 c1 L/ r" i$ o
- _get_pos:
/ Z/ n4 T3 X2 @ M! }6 X - mov cx,cs:[pos_x]
$ A, e @7 w/ j, p - mov dx,cs:[pos_y]
: z! ^! j3 E/ H( P7 C - mov bx,word ptr cs:[buttons]
% j' F1 Z7 O$ |8 m1 J- @$ Z - xor bh,bh
1 e5 M, E. b) g: Y9 n" q" F - iret( O; X7 m' O# [' f( {4 F; \; X3 P
0 F4 u1 Z, w1 i* T: ~8 C) ?- _get_mouse_movement:4 {0 _% [; K, p- i
- mov cx,cs:[x_move]
' P8 X7 W" O* ? - mov dx,cs:[y_move]3 i/ O" C# o; h
- mov word ptr cs:[x_move],03 G( X% D4 G$ |. L: h
- mov word ptr cs:[y_move],0
$ }) ?% U% A! Q: y - iret) _# G6 A3 K; j; [9 k* @2 b" h
. z9 ~ V; w: m% S- |$ t3 x( C, |, }% Y- _show_mouse:
* I6 Y' y( |5 g) e2 o, a2 W/ b* p6 f% s - push ax
6 M; d. [# j7 \ g4 E& G - push bx* L4 C- v4 a# v9 E! R( `
- push di
) w' ~3 F& z" a# c. C3 b: _ - push es) y; r0 P7 J+ Y) w, I/ }' o. K! j& O
- mov byte ptr cs:[sm_flag],1
8 F+ P$ R/ k" M, G3 Y/ ] - mov ax,cs:[pos_y]
+ @# o; D7 h- ]) ^7 z, r! l - shr ax,34 t0 ?# J) o: T8 i) s
- mov bl,80
) l0 P( P: H U) j. E2 v5 a - mul bl
8 z; ~# v8 h g6 o; A' c/ V* C - mov bx,[pos_x]6 P* B2 W( J9 p/ j1 D3 v0 o( j% I6 E
- shr bx,3+ |7 h: J/ z- J c- P
- add ax,bx
- d7 W. G* ]4 ]4 n; o - shl ax,1- v3 s. {! m0 y: I2 t( t! g1 G
- mov di,ax6 t( Q" [5 a2 \, z ?
- mov ax,0b800h
, O; X( w! H/ o - mov es,ax
A0 g( p; B5 U' _ - mov ax,es:[di]- H+ k D/ I( Y! a
- mov cs:[save_char],ax5 _+ f% f* _& c
- not ah# ~% c0 v! }; `- Q9 j
- and ah,7fh. r) k) v) C7 t' Q( S$ L# w
- mov es:[di],ax
. x F. W5 e& u - pop es
! M) T2 U/ M9 Q+ z* u" j+ U3 X - pop di
6 X! i$ E# q+ q2 F5 q: s' ?8 f" ] - pop bx U9 `; E" l$ T/ [
- pop ax8 x4 T5 N; c. V) w$ _
- iret
. \4 c5 r c, A& S - 1 Q" {/ i' P4 K( }! S; ? t9 i
- _hide_mouse:4 ~; V5 L# F) z* U4 P% d
- push ax
: A" G D5 x7 M4 J) @. ~# @" @1 A - push bx
% f4 o- u; Z; l0 I2 }$ r! O1 P - push di
6 k/ L9 }: g& N0 Y - push es
7 Y$ _5 O' A, R3 J6 q0 f - mov byte ptr cs:[sm_flag],0+ u# g) H1 M2 {' n* Z
- mov ax,cs:[pos_y]
! _0 J& E1 Q9 D- \1 r- F - shr ax,3
2 x4 j$ }5 M' D u/ o5 T - mov bl,80
- ?7 F2 L) }( J) E - mul bl$ Y: U2 X% m3 ]7 v9 }* n
- mov bx,[pos_x]
/ ^! Q( j# {* [6 O% t( y - shr bx,3
5 T- o0 U$ ?8 h! d) W9 i - add ax,bx
+ _; y3 K) U9 @2 K( k - shl ax,1
. k) e H) ^9 P. T( v - mov di,ax6 w% v/ O5 l! g+ o
- mov ax,0b800h% c. W" G7 w: O0 D/ @
- mov es,ax
& ~ F3 x9 ?( L7 | D6 h* N H - mov ax,cs:[save_char]
% G. |: E8 O8 d& y x - mov es:[di],ax8 N6 \& {( U7 N& V; u1 ~ v6 l
- pop es
$ {8 ]0 d2 ]6 p8 H! X) [/ p - pop di
/ L2 d- {- Q' J. Q - pop bx
. [: m1 y4 Q3 J& ]0 ~6 Z+ [+ c - pop ax
6 f) z& i1 V, Z3 G/ ?. ? - iret
) @* {& m7 a* X( t% C! T' ^" o - ; \/ D* \& m4 ]5 D. ]7 X
- _set_pos:* E. A" d0 j9 X# x
- mov cx,cs:[pos_x]; F- I' f& z* K: I
- mov dx,cs:[pos_y]) P% J/ ? w/ E% q, Z. ]
- mov word ptr cs:[x_move],0- i; {9 g6 M7 r7 b; O
- mov word ptr cs:[y_move],0
t. y& H$ ~* u) v; c8 O0 [ - iret7 l) X- @$ d. r
- \: p1 T2 \3 l: k, K- _set_hor_pos:! Z% w6 W) ~7 O* l* M
- call max_min
' x5 ~4 k L" n* O - mov cs:[x_min],cx: C0 o }- ] {4 f* Q, M
- mov cs:[x_max],dx
# b* _! e4 u1 h _2 a# \/ a - cmp cs:[pos_x],cx2 e' n8 ]- [9 J1 x# X& o$ P6 p5 {$ J
- jge good_hor_min- P* ]0 g( ^( h( O/ G
- mov cs:[pos_x],cx
3 p, c7 m. f' f+ V0 L* [ W - good_hor_min:: d/ ~' I, |/ |5 s
- cmp cs:[pos_x],dx
( x7 j8 w4 [, a% X& n - jle good_hor_max
6 U6 u3 _3 F: H, ?3 ~ - mov cs:[pos_x],dx1 `: k( v& R" a7 V
- good_hor_max:" \: i! q% `7 p' ?
- iret6 }& J% o+ W3 U: \6 \- B
9 D, y2 }+ }1 W/ v+ Q2 ^- _set_ver_pos:
/ i6 j: ?6 q. b0 g# r' R - call max_min4 p& i0 O w& h
- mov cs:[y_min],cx
$ L5 d0 }) j# G1 U& m - mov cs:[y_max],dx* q0 p- o: t" J5 x$ g" Y! a# g
- cmp cs:[pos_y],cx
" @' ?. q* e7 K$ L! j - jge good_ver_min; K- `. k0 m* k8 N7 S* s: q
- mov cs:[pos_y],cx( U+ I6 t% [7 p) i& s0 p# X
- good_ver_min:
. p4 W' K2 f- m0 w) Z2 ` x - cmp cs:[pos_y],dx/ I, U# U# Z- A6 x8 [# g! ?
- jle good_ver_max
. |" F! _8 P, Q - mov cs:[pos_y],dx9 b7 |$ a3 O9 m9 w( e
- good_ver_max:
# w! A: A6 C7 |3 `9 I2 I - iret
Y: O+ ?5 J7 f; o" x# P4 i - : P O Q! {# x; `3 w/ T! s
- max_min:
' P& f0 n4 v* @9 L! J$ _$ B9 I# O - cmp cx,dx
+ ?1 b9 }6 ~. I! N# o - jle no_swap) O5 P- Y* |4 T
- xchg cx,dx
( M& d- X5 [3 q7 `) O - no_swap:$ D! I8 l/ C1 @
- ret9 U1 B2 G5 H) T! W
4 _. ]( X0 P# {; t8 m# r0 H6 z- _set_subroutines:6 V4 J7 r: i' a
- mov cs:[user_subroutine],dx) C( w! f' K" J! K; [
- mov cs:[user_subroutine+2],es
( N! J% i# y$ O9 g; F - mov cs:[user_mask],cx
+ u+ C/ f4 {) X* k" \6 ` f. b9 e - iret9 I4 N5 Q# Q4 D8 H1 g! m
5 g3 W1 Y) M# ?7 o b- _swap_subroutines:
6 G. T, \8 v0 _5 z# M7 X3 y - push word ptr cs:[user_mask]) ^* j8 p7 g! G) P5 w1 K8 R5 ^, i, j
- push word ptr cs:[user_subroutine+2]# k9 T. z& A5 L4 P% ^+ W6 Z6 J
- push word ptr cs:[user_subroutine]4 G! {& q3 ^6 b9 o: w
- mov cs:[user_subroutine],dx
2 v7 i% {4 J* j9 v% ?5 z& [8 W& Z - mov cs:[user_subroutine+2],es
& i8 s: k7 W9 L( ?- ]9 s3 Z* A - mov cs:[user_mask],cx. X! M- K; ~ |$ K' ~9 ]% O8 a8 ^
- pop dx o0 M- w& c T% M. p9 ~
- pop es
9 Z5 u# e) a' N( W! L) O - pop cx2 S; A* E6 [& ~( E/ U# Y
- iret0 o, q4 u% m% O/ y" n6 l7 i; p
3 |- l/ T) [, w% U- memmouse endp$ g$ N& d" @- T0 N+ a1 e" D. A9 [
- 7 o' k: `4 ~( g: W
- endof_start:
, J% L) J4 A Z( x$ o
8 G+ c" a- T4 W0 Y2 X- emsg db 'No mouse driver install error!$'
# I, X+ D0 _2 R L - old331 dw 0
1 o7 Q/ k) ^4 C; c1 E; \ - old332 dw 03 ]9 B+ u k% X) Q7 E
- old741 dw 0
# }. M$ }) B, j8 _ - old742 dw 0
4 \9 }6 P3 ^* a' e1 d - memcopy db 0% h' c( ]2 W% X) v2 E4 w
- okcheck db 0
% [$ [. U7 j# Y5 @ t$ n - pass db 0
! g0 L" g; ?8 f( D. H3 E - chkl db 01 I3 _$ `0 W. L6 u# O5 m; }8 ]! I
- lk db 0( x9 O E$ [% v' K, M: b- K: m! G1 R5 T
- chkr db 0
0 u. H5 \& ]3 Y _7 C - rk db 0: b' S3 C e2 ? h( p8 e5 s
- showms db ' 赏屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯? '
& M0 `8 q f! Q0 ] - db ' ?UfoitmousetestVer0.9Bini.Yi? '( H/ F, U4 I1 `0 }3 w8 F
- db ' 韧屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯? '+ R1 k. W- x8 p+ d( v" }( m0 A8 Q
- db ' '- ]4 g$ k$ O$ h
- db ' 赏屯屯簧屯屯突 '
$ D0 g7 N6 X' x k) h0 C& t - db ' ?OFF汉OFF? '
' L" d; A, e0 e' A, H - db ' 韧屯屯既屯屯图 '- c6 Q6 k$ N) j7 D, m: i
- db ' '
L) ?% [9 m8 n1 }* E/ J - db ' 赏屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯突 '; G- b% D. z! A' U
- db ' ?IFFail,Press<Esc>toExit? ' 6 I2 d5 U) L# @* L2 j
- db ' 韧屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯图 '
+ h$ I, n) A$ ]
8 ]$ p3 V) ?: A& z- end
复制代码 |
|