< -->

;fadeout.asm
; Выполнфет плавное гашение экрана
	.model tiny
	.code
	.186
	org 100h
 start:
cld
mov di, offset palettes
call read_palette

mov di, offset palettes+256*3
call read_palette

mov cx, 64
main_loop:
push cx
call wait_retrace
mov di, offset palettes+256*3
mov si, di
call dec_palette
call wait_retrace
mov si, offset palettes+256*3
call write_palette
pop cx
loop main_loop

mov si, offset palettes
call write_palette
ret

read_palette proc near
mov dx, 03C7h
mov al, 0
out dx, al
mov dl, 0C9h
mov cx, 256*3
rep insb
ret
read_palette endp

write_palette proc near
mov dx, 03C8h
mov al, 0
out dx, al
mov dl, 0C9h
mov cx, 256*3
rep outsb
ret
write_palette endp

dec_palette proc near
mov cx, 256*3
dec_loop:
lodsb
test al, al
jz already_zero
dec ax
already_zero:
stosb
loop dec_loop
ret
dec_palette endp

wait_retrace proc near
             push dx
             mov  dx, 03DAh
VRTL1:
             in   al, dx
             test al, 8
             jnz  VRTL1
VRTL2:
             in al, dx
             test   al, 8
             jz     VRTL2
             pop    dx
             ret
wait_retrace endp

palettes:
	end start

Назад