As long as you want to listen to CDs, it's at any time (DOS, games can be activated with the mouse, mouse control, for you to play. and provides a choice and pause function, which is not directly on the CD-ROM on the construction of friends to provide a great convenience. The program is ingenious, using an int 33H of existing mouse function, cleverly extended, Ability to activate under any conditions!! If you are interested, you can change him to mouse control xxxxxx program, at any time to activate, convenient incomparable!!!
The source code is as follows:
; mcd.asm
.286
Code segment
Assume Cs:code,ds:code
Org 100h
Start
JMP INIT_CD; to initialization
Cd_command db DUP (0); Cd-audio Control Area
Cd_state db DUP (0); Cd-audio State Area
Max_track db 0,0; CD on the Boulevard
Min_track db 0,0; CD Most Trails
Lead_track DW 0
Track DW?
Track_buff db 40*4 dup (?); CD Audio channel data area (scheduled for 40)
Int33_off DW?; The original mouse interrupt vector
Int33_seg DW?
USER_DX DW?; user Mouse event vector
User_es DW?
Mark DB 0
CTRL DB 0; CD control mode
Next equ 1; forward
Back equ 0;
Stop equ 2;
Cd_rom_driver DW?; CD drive letter
Red_max_h DW?
red_max_l DW?
CD_INT macro control of Cd-audio macros
MOV ax,1510h
MOV cx,cd_rom_driver
int 2FH
Endm
my:; This program's Mouse event my
Pushf
CMP bx,7 if three keys are pressed at the same time
JNZ TTT
MOV cs:ctrl,stop; stop
JMP LL
Ttt
CMP bx,3 If two keys are pressed at the same time
JNZ q
CMP dx,1 the top of the mouse
JNB Other
MOV cs:ctrl,stop; stop
JMP LL
Other
CMP cx,599, mouse on the right
JB QQQ
MOV Cs:ctrl,next; forward
JMP LL
Qqq
CMP cx,1
Jae Q
mov cs:ctrl,back; Mouse in the left, backwards
ll
Pusha
Push DS
Push ES
Push CS
Pop ds
Push CS
Pop es
Call MEDIACHG, whether to replace the CD
CMP AL,0FFH
Jnz che
Call Init; the initialization after replacing the CD
Che
Call check; CD status Check
CMP Cs:ctrl,next
JZ FF
CMP Cs:ctrl,back
JZ Rew
FF:; forward
CMP Al,max_track; is more than the maximum track
JB Goo
MOV al,0; if more than, start with the first track
Goo:
Inc Al; Audio Track plus One
JMP Okk
Rew:; backward
CMP al,1 is less than the minimum track
JA dy
MOV al,max_track, such as less than, starting from the largest track
JMP Okk
Dy:
Dec al; Audio track minus One
Okk:
mov byte ptr cs:track,al
Call pause; pause
CMP Cs:ctrl,stop
JZ exit
Call play;
Exit
Pop es
Pop ds
Popa
Q:
CMP cs:mark,1; user events are valid
JNZ QQ
Popf
JMP DWORD ptr cs:user_dx; turn (simulate) User mouse events
Qq:
Popf
RETF; My mouse event returns
NEW_33 proc near; new Mouse interrupt
CMP ax,8888h
JNZ l005
mov ax, ' ZD ';
Iret; break back
L005:
CMP ax,000ch
JZ l_000; Set mouse events, turn l_000
CMP ax,0
JZ MRE
CMP ax,0021h
JNZ l001; mouse initialization
MRe
MOV cs:mark,0
Pushf
Call DWORD ptr Cs:int33_off, calling the original mouse interrupt initialization
Pusha
Push ES
MOV Ax,cs
MOV Es,ax
mov ax,000ch 0Ch function, setting mouse events
MOV cx,00001010b
mov dx,offset my; point to my
Pushf
Call DWORD ptr Cs:int33_off; Set this program mouse event my
Pop es
Popa
Iret; break back
L001:
JMP DWORD ptr Cs:int33_off; invoke other mouse functions
l_000:;
MOV cs:user_dx,dx
mov cs:user_es,es; Save user mouse event vector
Push ES
Push DX
Push CS
Pop es
mov dx,offset my; point to my
MOV cs:mark,1; Set flag to indicate user event
Pushf
Call DWORD ptr Cs:int33_off, setting user mouse events,
; The essence is pointing to this program event my
Pop DX
Pop es
Iret; break back
New_33 ENDP
INIT proc near initialization, reading Cd-audio information
MOV track,1
MOV Di,offset track_buff
mov byte ptr cd_command[0],1ah
mov byte ptr cd_command[1],0
mov byte ptr cd_command[2],03
mov byte ptr cd_command[13],00
mov word ptr cd_command[20],0000h
mov word ptr cd_command[24],0000h
mov word ptr cd_command[22],0000h
mov word ptr cd_command[16],es
mov word ptr cd_command[14],offset cd_state
mov word ptr cd_command[18],0007h
mov byte ptr cd_state[0],0ah
MOV Ax,ds
MOV Es,ax
MOV Bx,offset Cd_command
Cd_int, calling the CD service program
mov al,byte ptr cd_state[1]
mov min_track,al min. track number
mov al,byte ptr cd_state[2]
MOV max_track,al; maximum track number
mov al,byte ptr cd_state[5]
XOR Ah,ah
XOR DX,DX
XOR cx,cx
MOV bx,4500; number of sectors per minute
Call SZD
Push DX
Push AX
mov al,byte ptr cd_state[4]
XOR Ah,ah
XOR DX,DX
XOR cx,cx
MOV bx,75; number of sectors per second
Call SZD
Pop bx
Pop CX
Add Bx,ax
ADC CX,DX
mov al,byte ptr cd_state[3]
XOR Ah,ah
XOR DX,DX
Add Bx,ax
ADC CX,DX
Add Bx,0ff6ah
ADC cx,-01
MOV red_max_h,cx
mov red_max_l,bx; Maximum number of sectors saved
Test word ptr cd_command[3],8000h
Je bza
mov ax,0ffffh; error AX=FFFF
JMP quit_2
Bza
MOV Ax,ds
XOR DX,DX
mov word ptr cd_command[16],es
mov word ptr cd_command[14],offset cd_state
mov word ptr cd_command[18],0007h
mov byte ptr cd_state[0],0bh
mov Si,word ptr min_track
JMP BZB
BZC:
MOV Ax,si
mov byte ptr cd_state[1],al al for track number
MOV Ax,ds
MOV Es,ax
MOV Ax,offset Cd_command
MOV Bx,ax
Cd_int
mov al,byte ptr cd_state[4]
XOR Ah,ah
XOR DX,DX
XOR cx,cx
MOV bx,4500
Call SZD
Push DX
Push AX
mov al,byte ptr cd_state[3]
XOR Ah,ah
XOR DX,DX
XOR cx,cx
MOV bx,75
Call SZD
Pop bx
Pop CX
Add Bx,ax
ADC CX,DX
mov al,byte ptr cd_state[2]
XOR Ah,ah
XOR DX,DX
Add Bx,ax
ADC CX,DX
Add Bx,0ff6ah
ADC cx,-01
mov word ptr [di+2],cx
mov word ptr [di+0],bx
Add di,4
Test word ptr cd_command[3],8000h
Je bzd
MOV ax,0ffffh;
JMP quit_2
Bzd
Inc SI; track number plus 1
BZB:
CMP Si,word PTR max_track whether the maximum track number is exceeded
JA quit_2
JMP BZC
Quit_2:ret
Init ENDP
SZD proc near; multiplication calculation
Push SI
Xchg Ax,si
Xchg AX,DX
Test Ax,ax
Je bzz
Mul BX
Bzz
Xchg AX,CX
Test Ax,ax
Je bzx
Mul si
Add Cx,ax
BZX:
Xchg Ax,si
Mul BX
Add DX,CX
Pop si
Ret
SZD ENDP
Play proc near CD
mov byte ptr cd_command[0],16h
mov byte ptr cd_command[1],0
mov byte ptr cd_command[2],84h
mov byte ptr cd_command[4],0
mov byte ptr cd_command[13],00
MOV Di,offset track_buff
MOV Bx,track
Dec BX
SHL bx,1
SHL bx,1
MOV dx,red_max_h
MOV ax,red_max_l
SBB Dx,[di+bx+2]
Sub Ax,[di+bx+0]
mov word ptr cd_command[20],dx; number of sectors to play
mov word ptr cd_command[18],ax
mov Dx,word ptr [di+bx+2]
mov Ax,word ptr [di+bx+0]
mov word ptr cd_command[16],dx
mov word ptr cd_command[14],ax; number of starting sectors
MOV Bx,offset Cd_command
Cd_int
Test word ptr cd_command[3],8000h
Jne err_p; error
XOR Ax,ax
JMP quit_1
Err_p:mov AX,0FFFFH; error
Quit_1:ret
Play ENDP
Pause proc near; pause
mov byte ptr cd_command[0],16h
MOV al,7
mov byte ptr cd_command[1],al
mov byte ptr cd_command[2],85h
MOV Bx,offset Cd_command
Cd_int
Ret
Pause ENDP
Check proc near, checking CD status
mov byte ptr cd_command[0],1ah
mov byte ptr cd_command[1],0
mov byte ptr cd_command[2],3h
mov byte ptr cd_command[13],0
mov word ptr cd_command[20],0
mov word ptr cd_command[24],0
mov word ptr cd_command[18],0bh
MOV Cd_command[16],ds
mov word ptr cd_command[14],offset cd_state
mov byte ptr cd_state[0],0ch
MOV Bx,offset Cd_command
Cd_int
XOR Ax,ax
MOV al,cd_state[2]
MOV bl,al; BCD to 16 in-process conversion
MOV cl,4
and bl,11110000b
JZ quit
SHR BL,CL
and al,00001111b
Crep:
Add al,10
Dec BL
JNZ crep
Quit:ret; Returns the current track number
Check ENDP
MEDIACHG proc Near
mov byte ptr cd_command[0],1ah
mov byte ptr cd_command[1],0
mov byte ptr cd_command[2],03
mov word ptr cd_command[14],0000h
mov word ptr cd_command[16],0000h
mov word ptr cd_command[18],0000h
mov word ptr cd_command[16],es
mov word ptr cd_command[14],offset cd_state
mov word ptr cd_command[18],0002h
mov byte ptr cd_state[0],09h
MOV Ax,ds
MOV Es,ax
MOV Bx,offset Cd_command
Cd_int, calling the CD service program
MOV al,cd_state[1]
ret; Returning to AL=0FFH, the CD slice has been replaced
Mediachg ENDP
INIT_CD:
MOV ax,8888h
int 33h
CMP ax, ' ZD '
Jnz l004; Resident check
MOV Dx,offset mess
MOV ah,9
int 21h
JMP _quit; is already resident, exit
L004:
mov ax,0; reset mouse
int 33h
CMP Ax,0ffffh; mouse driver Check
JZ OK
MOV Dx,offset mess2
MOV ah,9
int 21h
MOV Dx,offset mess1
MOV ah,9
int 21h
_quit:
MOV ah,4ch
int 21h
Ok:
MOV ax,1500h
MOV bx,0
XOR cx,cx
int 2FH; Take CD-ROM drive letter
CMP cx,2
JG NEXT1
MOV Dx,offset mess2
MOV ah,9
int 21h
mov Dx,offset err; CD-ROM Error
MOV ah,9
int 21h
JMP _quit; exit
NEXT1:
MOV cd_rom_driver,cx
Call init; Initialize CD-ROM
CMP AX,0FFFFH
JNZ checkcd
MOV Dx,offset mess2
MOV ah,9
int 21h
mov Dx,offset err; CD-ROM Error
MOV ah,9
int 21h
JMP _quit
CHECKCD:
MOV ah,9
mov dx,offset mess2; display information
int 21h
MOV ah,9
MOV dx,offset usage
int 21h
Call check; Cd-audio status Check
mov byte ptr track,al
Call pause; pause
Call play;
mov ax,000ch; mouse event settings
MOV cx,00001010b
MOV Dx,ds
MOV es,dx
mov dx,offset my; point to my
int 33h
MOV ax,3533h
int 21h; mouse interrupt vector
MOV cs:int33_off,bx
MOV cs:int33_seg,es; Save the original mouse interrupt vector
MOV ax,2533h
MOV Dx,offset new_33
Push CS
Pop ds
int 21h; Setting a new mouse interrupt, pointing to new_33
mov Dx,offset INIT_CD; resident memory
int 27h
Mess1 db ' MOUSE not installed! ', 0dh,0ah, ' $ '
Mess2 db ' MOUSE cd-player Ver 1.01 Copyright (c) zdsoft. ', 0dh,0ah
DB ' Write by Zou dan,1995,8 ', 0dh,0ah
DB ' TELE (023) 65311989-6023,post code:630045 ', 0dh,0ah
DB ' Address:no.80-7-2,east village,architectural university,chongqing ', 0AH,0DH
DB ' OR no.51 postbox,math department,east part of Shichuan University ', 0dh,0ah
DB ' Post Code:610064,shichuan ', 0dh,0ah, ' $ '
Mess db ' MOUSE Cd-player already installed ', 0dh,0ah, ' $ '
Usage db ' usage: ', 0dh,0ah
DB ' stop:press left,middle,right botton at the same time. ', 0dh,0ah
DB ' (for Three-botton Mouse). ', 0dh,0ah
DB ' OR move the mouse to the same time. ', 0dh,0ah
DB ' (this is special designed for Two-botton Mouse.) ', 0dh,0ah
DB ' Play Pre. Track:move the mouse to the left side and ', 0dh,0ah
DB ' press left and right botton in the same time. ', 0dh,0ah
DB ' Play Next track:move the mouse to the right side and ', 0dh,0ah
DB ' press left and right botton in the same time. ', 0dh,0ah, ' $ '
Err db ' CD-ROM error! ', 0dh,0ah, ' $ '
Code ends
End Start