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