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