📄 car.asm
字号:
;宏定义
;>>>>>>>>>>>>清屏>>>>>>>>>>>>>>>>>
clear macro al1,ch1,cl1,dh1,dl1,bh1
push ax
push bx
push cx
push dx
mov ah,6
mov al,al1
mov ch,ch1
mov cl,cl1
mov dh,dh1
mov dl,dl1
mov bh,bh1
int 10h
pop dx
pop cx
pop bx
pop ax
endm
;>>>>>>>>>>>>>光标定位>>>>>>>>>>>>>>>>>>>>>>>>
SetGb macro dh1,dl1
push ax
push bx
push dx
mov dh,dh1
mov dl,dl1
mov bh,0
mov ah,02h
int 10h
pop dx
pop bx
pop ax
endm
;>>>>>>>>>>>>>>>>>>提示信息>>>>>>>>>>>>>>>>>>>>>>>
ShowMess macro mess
push ax
push dx
mov ah,09
lea dx,mess
int 21h
pop dx
pop ax
endm
dataseg segment
musfreq dw 440,440,440,587,587,587,523,587,659,587
dw 597,659,587,659,587,440,523,494,440,440
dw 440,440,880,880,784,880,988,880,880,988
dw 880,988,880,659,784,698,659,-1
mustime dw 50,25,25,50,25,25,25,25,25,25
dw 100,50,25,25,25,25,25,25,200,50
dw 25,25,50,50,25,25,25,25,100,50,25
dw 25,25,25,25,25,200
car db 7
db 52h,70h,0,0
db 0b1h,70h,0,1
db 0dbh,7h,0,1
db 0dbh,7h,0,1
db 4fh,7,1,0
db 4fh,7,0,-3
db 2,7,-2,1
sign db 0
speed dw 4
charcnt dw ?
pointer dw ?
lineon db ?
colon db ?
Tital1 DB '********************************************************************$'
Tital2 DB '** Program of Car and Music **$'
Tital3 DB '** Designed by ZhaoJun **$'
Tital4 DB '** Computer 05-1 of shz University of Science & Technology **$'
Tital5 DB '********************************************************************$'
mess0 db 'Press Anter key to begin.....$'
mess1 db 'Welcome to My Car$'
mess2 db 'U--Speed,D--Down,Esc--Exit$'
dataseg ends
codeseg segment
assume cs:codeseg,ds:dataseg
main proc far
push ds
sub ax,ax
mov ax,dataseg
mov ds,ax
clear 0,0,0,24,79,7
clear 0,0,6,5,75,04h ;标题外为红色
;显示标题
SetGb 1,6
ShowMess Tital1
clear 0,2,10,2,70,01h ;文字为蓝色
SetGb 2,6
ShowMess Tital2
clear 0,3,10,3,70,01h
SetGb 3,6
ShowMess Tital3
clear 0,4,8,4,70,01h
SetGb 4,6
ShowMess Tital4
SetGb 5,6
ShowMess Tital5
clear 0,16,20,16,70,04h
SetGb 16, 23
ShowMess mess0
GetTwo: ;选择是否开始
SetGb 17,53
mov ah,08h
int 21h
cmp al,1bh
je leave1
cmp al,0dh
je begin
jmp GetTwo
leave1:
jmp leave
begin:
clear 0,16,20,16,70,7 ;清除提示信息
clear 0,8,8,13,70,33h
SetGb 20,30
ShowMess mess1
SetGb 22,40
ShowMess mess2
lea di,car
mov dh,10
mov dl,10
lea si,musfreq
lea bp,mustime
call moveshape
jmp begin
ret
main endp
leave:
mov ah,4ch
int 21h
moveshape proc near
push ax
push bx
push cx
push dx
push di
mov ah,0fh
int 10h
sub ch,ch
mov cl,[di]
inc di
mov charcnt,cx
mov pointer,di
mov lineon,dh
mov colon,dl
plotnext:
add dh,[di+2]
add dl,[di+3]
cmp dl,67
jb movcrsr
call erase
pop di
pop dx
pop cx
pop bx
pop ax
exit: ret
movcrsr:
mov ah,2
int 10h
mov al,[di]
mov bl,[di+1]
push cx
mov cx,1
mov ah,09
int 10h
pop cx
add di,4
loop plotnext
push ax
push bx
push cx
push dx
push di
mov cx,speed
freq:mov di,[si]
cmp di,-1
jne next
lea si,musfreq
lea bp,mustime
next: mov bx,ds:[bp]
call sound
add si,2
add bp,2
mov al,sign
cmp al,1bh
je leave0
loop freq
jmp nexto
leave0:
jmp leave
nexto:
pop di
pop dx
pop cx
pop bx
pop ax
call erase
jmp short plotnext
moveshape endp
erase proc near
mov cx,charcnt
mov di,pointer
mov dh,lineon
mov dl,colon
erasenext:
add dh,[di+2]
add dl,[di+3]
mov ah,2
int 10h
mov al,[di]
mov bl,0
push cx
mov cx,1
mov ah,9
int 10h
pop cx
add di,4
loop erasenext
mov cx,charcnt
mov di,pointer
mov dh,lineon
inc colon
mov dl,colon
ret
erase endp
sound proc
push ax
push bx
push cx
push dx
push di
mov al,0b6h
out 43h,al
mov dx,12h
mov ax,348ch
div di
out 42h,al
mov al,ah
out 42h,al
in al,61h
mov ah,al
or al,03h
out 61h,al
wait1:mov cx,663
call waitf
dec bx
jnz wait1
mov al,ah
out 61h,al
pop di
pop dx
pop cx
pop bx
pop ax
ret
sound endp
waitf proc near
push ax
waitf1:mov dl,0ffh
mov ah,06h
int 21h
cmp al,'u'
je A11
cmp al,'d'
je A12
cmp al,1bh
je A13
jmp A14
A11:mov ax,speed
sub ax,1
mov speed,ax
jmp A14
A12:mov ax,speed
add ax,1
mov speed,ax
jmp A14
A13:mov sign,al
A14: in al,61h
and al,10h
cmp al,ah
je waitf1
mov ah,al
loop waitf1
pop ax
ret
waitf endp
codeseg ends
end main
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -