📄 00204112.asm
字号:
;a program to imitate window screensaver
data segment
prompt1 db 'time to start screensaver:(1-99)','$'
buffer db 5,5 dup(?)
buffer1 db '$','$','$'
buffer2 db 50,50 dup('$')
buffer2p db 0
cflag db 0
data ends
code segment
main proc far
assume cs:code,ds:data
start:mov ax,data
mov ds,ax
mov es,ax
mov ah,00h
mov al,03h
int 10h ;set text mode
mov ah,9
mov dx,offset prompt1
int 21h ;output a sentence
mov ah,0ah
mov dl,offset buffer
int 21h
mov ah,2
mov dl,13
int 21h
mov ah,2
mov dl,10
int 21h ;input timeout
mov ax,0
mov al,buffer+2
mov buffer1,al
sub ax,30h
mov bx,0
mov bl,buffer+1
cmp bx,1
jz a
mov cx,0
mov cl,buffer+3
mov buffer1+1,cl
sub cx,30h
mov dx,cx
mov bx,10h
mul bx
add ax,dx
a:mov di,ax
mov ax,100
mul di
mov di,ax ;di stores the timeout value
starttimer:mov cx,di
contimer:mov si,1
call timer ;start the timer
mov ah,01h
int 16h ;get keyboard buffer status
jnz hasinput
loop contimer
call screensaver ;start the screensaver
jmp starttimer ;start timer again
hasinput:mov ah,01h
int 21h ;output the key and clear buffer
mov bx,0
mov bl,buffer2p
inc bl
mov buffer2p,bl
dec bl
add bl,offset buffer2
mov [bx],al ;store the input key
jmp starttimer ;start the timer again
mov ah,01h
int 21h
mov ah,4ch
int 21h
timer proc
push ax
push bx
push cx
push dx
mov cx,si
loop1:mov ax,1000
loop2:mov bx,1000
loop3:dec bx
cmp bx,0
jne loop3
dec ax
cmp ax,0
jne loop2
loop loop1
pop dx
pop cx
pop bx
pop ax
ret
timer endp
screensaver proc
push bx
push cx
push dx
mov ah,0
mov al,4
int 10h ;set 320*200 color graphic mode
mov ah,0bh
mov bh,0
mov bl,0fh
int 10h ;set background color
mov ah,0bh
mov bh,1
mov bl,0
int 10h ;choose color pallete0(1 for green,2 for red,3 for yellow)
startdraw:mov al,cflag
inc al
cmp al,3
jb con
mov al,1
con:mov cflag,al ;choose pen color
mov cx,1
tloop1:mov dx,1
tloop2:mov ah,0ch
mov al,cflag
int 10h ;draw a pixel
add dx,10
cmp dx,200
jb tloop2
mov ah,1 ;get keyboard status
int 16h
jnz quitss
mov si,1
call timer ;call timer
inc cx
cmp cx,320
jb tloop1
jmp startdraw
quitss:mov ah,07h
int 21h ;clear buffer
mov ah,00h
mov al,03h
int 10h ;text mode
mov ah,09h
mov dl,offset prompt1
int 21h
mov ah,09h
mov dl,offset buffer1
int 21h ;restore the screen
mov ah,02h
mov dl,013
int 21h
mov ah,02h
mov dl,010
int 21h
mov bx,0
mov bl,buffer2p
cmp bx,0
je zerobuffer ;if the buffer has no content
mov ah,09h
mov dl,offset buffer2
int 21h
zerobuffer:pop dx
pop cx
pop bx
ret
screensaver endp
code ends
end start
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -