Модуль работы с видео-адаптером.
Unit Scroll;
interface
Procedure mScrollUp; { Сдвиг экрана вверх на 1 пиксел }
Procedure mScrollDown; { Сдвиг экрана вниз на 1 пиксел }
Procedure mScrollReset;
Procedure mWaitRetRace; { Ожидание обратного хода луча }
implementation
var ScrollPosition1,ScrollPosition2 :Word;
Procedure mScrollReset;Assembler;
Asm
xor ax,ax
xor bx,bx
mov [ScrollPosition1],ax
mov [ScrollPosition2],ax
push ax
mov dx, 3d4h
mov al, 0ch
mov ah, bh
out dx, ax
mov al, 0dh
mov ah, bl
out dx, ax
pop ax
xchg ah, al
mov al, 8
out dx, ax
xchg ah, al
End;
Procedure mScrollUp;Assembler;
Asm
mov ax,[ScrollPosition1]
mov bx,[ScrollPosition2]
cmp al, 15
jnz @NoLimit
xor ax, ax
add bx, 80
@NoLimit:
inc ax
push ax
mov dx, 3d4h
mov al, 0ch
mov ah, bh
out dx, ax
mov al, 0dh
mov ah, bl
out dx, ax
pop ax
xchg ah, al
mov al, 8
out dx, ax
xchg ah, al
mov [ScrollPosition1],ax
mov [ScrollPosition2],bx
End;
Procedure mScrollDown;Assembler;
Asm
mov ax,[ScrollPosition1]
mov bx,[ScrollPosition2]
or al, al
jnz @NoLimit2
mov al, 15
sub bx, 80
@NoLimit2:
dec ax
push ax
mov dx, 3d4h
mov al, 0ch
mov ah, bh
out dx, ax
mov al, 0dh
mov ah, bl
out dx, ax
pop ax
xchg ah, al
mov al, 8
out dx, ax
xchg ah, al
mov [ScrollPosition1],ax
mov [ScrollPosition2],bx
End;
Procedure mWaitRetRace;Assembler;
Asm
mov dx,03DAh
@Cikl1: in al,dx
test al,08h
jne @Cikl1
@Cikl2: in al,dx
test al,08h
je @Cikl2
End;
End.
Главный модуль.
Program Demo;
uses Scroll,Crt;
var A :Word;
Begin
mScrollReset;
For A:=0 to 160 do
Begin
Delay(25);
mScrollUp;
End;
For A:=0 to 160 do
Begin
Delay(25);
mScrollDown;
End;
mScrollReset;
End.