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