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