@Mensie22:
mov word ptr [cs:@IncDec+2], Sirka / 4 {treba prestavit na dec(Y)}
jmp @Dalej
@Vacsie22:
mov word ptr [cs:@IncDec+2], -Sirka / 4 {treba prestavit na dec(Y)}
@Dalej: {** v ax je hodnota ax = deltay = abs(y1-y2)}
{** v dx je hodnota dx = deltax = abs(x1-x2)}
shl ax,1 {** v ax je deltay = zbytocne, preto dame ax=konst1=2*deltay}
mov word ptr [cs:@Konst1+2],ax {Ok}
sub ax,dx {ax=predikce na chvilu=2*deltay-deltax; pre mna aj zaporne(?)}
mov cx,ax {cx=predikce na dlhodlbo=ax}
sub ax,dx {ax=konst2, lebo=2*deltay-deltax-deltax=2*(deltay-deltax)}
mov word ptr [cs:@Konst2+2],ax {Ok}
{opakovanie: V ax = konst2 = zbytocne = uvolnene pre plain(?), ktory pixel}
{ x1 bx = x1 = mensie x = zvacsovanie}
{ pr cx = predikce zvacsovanie}
{ V dx = deltax = treba uvolnit pre porty}
{ ! di = kam bachnut pixel}
mov ah,00010001b
mov dx,cx
mov cx,bx
and cx,00000011b
shl ah,cl
mov cx,dx
pop si { x2 si = x2 = vacsie x}
mov al,02h
mov dx,03c4h
out dx,ax
mov al,colorka
mov byte ptr [ds:di],al
push bp
{hlavny cyklus}
@Hlavny:
cmp bx,si
je @DostBolo
shl ah,1
jnc @Rotuj
mov ah,00010001b
inc di {incni di ak prerotoval plainsy}
@Rotuj:
inc bx
test cx,1000000000000000b {if predikce<0 }
jz @Vacsie3 {if not je = preco by jedla = 0 = nie je = je tam 0}
@Konst1:
add cx,1234h {predikce:=predikce+konst1 => konst1 sa meni-modifikuje}
jmp @Pixelaz
@Vacsie3:
@IncDec:
db 81h,0C7h {add di,...}
dw Sirka/4 {modifikovany 320 ak od 0 na vacsie=4 a 8 qvdr.; -320 ak z vacsieho mensie 0,0 je vlavo hore}
@Konst2:
add cx,1234h {predikce:=predikce+konst2 => konst2 sa meni-modifikuje}
mov word ptr [cs:@ShiftY],0ECD0h {treba prestavit na shr ah,1}
mov byte ptr [cs:@MaskaY+1],10001000b {treba prestavit na shr di,1}
mov byte ptr [cs:@IncDecY],4Fh {treba prestavit inc di}
jmp @Dalejsi
@JeMensi: {ciara ide zhora dole od 0, +320 preto ide doprava, hore sort}
add ax,cx {ax = y1-y2 +y2 = y1}
xchg ax,cx
mov si,bx
mov word ptr [cs:@ShiftY],0E4D0h {treba prestavit na shr ah,1}
mov byte ptr [cs:@MaskaY+1],00010001b {treba prestavit na shr di,1}
mov byte ptr [cs:@IncDecY],47h {treba prestavit inc di}
@Dalejsi:
pop bx {treba popnut x2 ..., (bx je nedolezite bolo tam x1)}
push cx {a dat tam y2 => pojde do si, do vacsieho }
mov bx,ax {bx - od neho sa pojde, +320 ... az do <-\- push cx do cx=y2}
{povodna rutinka:}
sub ax,cx {do ax treba dat cx-ax = -(ax-cx)}
neg ax
{** v ax je hodnota ax = deltay = abs(y1-y2)}
{** v dx je hodnota dx = deltax = abs(x1-x2)}
shl dx,1 {** v dx je deltax = zbytocne, preto dame dx=konst1=2*deltax}
mov word ptr [cs:@Konst1Y+2],dx {Ok}
sub dx,ax {dx=predikce na chvilu=2*deltax-deltay; pre mna aj zaporne(?)}
mov cx,dx {cx=predikce na dlhodlbo=dx}
sub dx,ax {dx=konst2, lebo=2*deltax-deltay -deltay=2*(deltax-deltay)}
mov word ptr [cs:@Konst2Y+2],dx {Ok}
{opakovanie: V ax = deltax = zbytocne = uvolnene pre plain(?), ktory pixel}
{ x1 bx = y1 = mensie y = zvacsovanie}
{ pr cx = predikce zvacsovanie}
{ V dx = konst2 = zbytocne = treba uvolnit pre porty}
{ ! di = kam bachnut pixel}
mov ah,00010001b
mov dx,cx
mov cx,si
and cx,00000011b
shl ah,cl {zisti masku plainsy}
mov cx,dx
pop si { y2 si = y2 = vacsie y}
mov dx,03c4h
mov al,02h
out dx,ax
mov al,colorka
mov [ds:di],al
push bp
{hlavny cyklus}
@HlavnyY:
cmp bx,si
je @DostBoloY
inc bx
add di,Sirka /4
test cx,1000000000000000b {if predikce<0 }
jz @Vacsie3Y {if not je = preco by jedla = 0 = nie je = je tam 0}
@Konst1Y:
add cx,1234h {predikce:=predikce+konst1 => konst1 sa meni-modifikuje}
jmp @PixelazY
@Vacsie3Y:
@ShiftY:
shl ah,1
jnc @Konst2Y
@MaskaY:
mov ah,00010001b
@IncDecY:
inc di {add di,1234h modifikovany 1 ak od 0 na vacsie; -1 ak z vacsieho mensie 0,0 je vlavo hore}
@Konst2Y:
add cx,1234h {predikce:=predikce+konst2 => konst2 sa meni-modifikuje}
mov dx,03c4h
mov ax,0604h
out dx,ax { disable chain4 mode }
mov ax,0100h
out dx,ax { synchronous reset while setting Misc }
{ Output for safety, even though clock }
{ unchanged }
mov si,offset @X376Y282
lodsb
mov dx,03c2h
out dx,al { select the dot clock and Horiz }
{ scanning rate }
mov dx,03c4h
mov ax,0300h
out dx,ax { undo reset (restart sequencer) }
mov dx,03d4h { reprogram the CRT Controller }
mov al,11h { VSync End reg contains register write }
out dx,al { protect bit }
inc dx { CRT Controller Data register }
in al,dx { get current VSync End register setting}
and al,07fh { remove write protect on various }
out dx,al { CRTC registers }
dec dx { CRT Controller Index }
cld
xor ch,ch
lodsb
mov cl,al
@@SetCRTParmsLoop:
lodsw { get the next CRT Index/Data pair }
out dx,ax { set the next CRT Index/Data pair }
loop @@SetCRTParmsLoop
{ clear all of display memory }
mov dx,03c4h
mov ax,0f02h
out dx,ax { enable writes to all four planes }
mov ax,0a000h { now clear all display memory, 8 pixels}
mov es,ax { at a time }
xor di,di { point ES:DI to display memory }
xor ax,ax { clear to zero-value pixels }
mov cx,8000h { # of words in display memory }
rep stosw
mov dx,3c4h
mov ax,0101h
out dx,ax
pop ds
pop bp
ret
@X376Y282:
db 0e7h
db 18
dw 06e00h { horz total }
dw 05d01h { horz displayed }
dw 05e02h { start horz blanking }
dw 09103h { end horz blanking }
dw 06204h { start h sync }
dw 08f05h { {nd h sync }
dw 06206h { vertical total }
dw 0f007h { overflow }
dw 06109h { cell height }
dw 0310fh { }
dw 03710h { v sync start }
dw 08911h { v sync end and protect cr0-cr7}
dw 03312h { vertical displayed }
dw 02f13h { offset }
dw 00014h { turn off dword mode }
dw 03c15h { v blank start }
dw 05c16h { v blank end }
dw 0e317h { turn on byte mode }
@X360Y480:
DB 0e7h
DB 17
DW 06b00h { horz total }
DW 05901h { horz displayed }
DW 05a02h { start horz blanking }
DW 08e03h { end horz blanking }
DW 05e04h { start h sync }
DW 08a05h { end h sync }
DW 00d06h { vertical total }
DW 03e07h { overflow }
DW 04009h { cell height }
DW 0ea10h { v sync start }
DW 0ac11h { v sync end and protect cr0-cr7}
DW 0df12h { vertical displayed }
DW 02d13h { offset }
DW 00014h { turn off DWord mode }
DW 0e715h { v blank start }
DW 00616h { v blank end }
DW 0e317h { turn on byte mode }
end;
PROCEDURE XMode2; assembler;
asm
mov ax, 2101h
mov dx, 3c4h
out dx, ax
mov ax, 13h
int 10h
mov dx, 3c4h
mov ax, 604h {spristupnenie nad 64k image memory}
out dx, ax
mov ax, 0f02h {zapis do 00001111 = vsetkych bit plains}
out dx, ax
PROCEDURE Berier(X1,Y1,X2,Y2,X3,Y3:integer;st:integer);
begin
if st=0 then
begin
{$IfDef Lines}
DLine(X1 shr 1+(X1 and 1),Y1 shr 1+(Y1 and 1),X3 shr 1+(X3 and 1),Y3 shr 1+(Y3 and 1),f);
{$Else}
PutPixel(X1 shr 1+(X1 and 1),Y1 shr 1+(Y1 and 1),f);
PutPixel(X3 shr 1+(X3 and 1),Y3 shr 1+(Y3 and 1),f);
{$EndIf}
exit;
end;
PX1:=((((X1+X3) shr 1)+X2) shr 1); PX1:=PX1 shr 1+(PX1 and 1);
PY1:=((((Y1+Y3) shr 1)+Y2) shr 1); PY1:=PY1 shr 1+(PY1 and 1);
PutPixel(PX1,PY1,f);
PROCEDURE Bezier(X1,Y1,X2,Y2,X3,Y3:integer);
var t:real;
X,Y:integer;
begin
t:=0;
repeat
X:=round(X1+t*(2*X2-2*X1)+t*t*(X1+X3-2*X2));
Y:=round(Y1+t*(2*Y2-2*Y1)+t*t*(Y1+Y3-2*Y2));
PutPixel(X,Y,15);
t:=t+step;
until t>=1;
end;
PROCEDURE Triangel(X1z,Y1z,X2z,Y2z,X3z,Y3z:integer);
var XN,YN,X1,X2,X3,Y1,Y2,Y3,Xd1,Yd1,Xd2,Yd2:integer;
X1p,X2p,X3p,Y1p,Y2p,Y3p:integer;
X1p2,X2p2,X3p2,Y1p2,Y2p2,Y3p2:integer;
X,Y:integer;
c:char;
t2:real;
begin
while t2-krokt<=1 do
begin
{$IfDef Test}
if tria=1 then
asm
mov dx,03c0h
mov al,11h+32
out dx,al
mov al,12
out dx,al
End;
{$EndIf}
Berier(X1p shl 1,Y1p shl 1,X2p shl 1,Y2p shl 1,X3p shl 1,Y3p shl 1,BerierSt);
{Bezier(X1p,Y1p,X2p,Y2p,X3p,Y3p);}
{$IfDef Test}
if tria=1 then
asm
mov dx,03c0h
mov al,11h+32
out dx,al
mov al,15
out dx,al
End;
{$EndIf}
t2:=t2+krokt;
asm
mov cx,PSeg
and cx,$0fff
shl cx,1
shl cx,1
shl cx,1
shl cx,1
mov dx,3d4h
mov al,0ch
mov ah,ch
out dx,ax
mov al,0dh
mov ah,cl
out dx,ax
mov dx,03dah
@Retrace: in al,dx
test al,08h
jnz @Retrace
@NoRetrace: in al,dx
test al,08h
jz @NoRetrace
end;
PSeg:=PSeg xor $800;
asm
mov dx,03c4h
mov ax,0f02h
out dx,ax { enable writes to all four planes }
mov ax,PSeg { now clear all display memory, 8 pixels}
mov es,ax { at a time }
xor di,di { point ES:DI to display memory }
xor ax,ax { clear to zero-value pixels }
mov cx,3500h { # of words in display memory }
rep stosw
end;
Yd:=Yd+Xd;
If Yd>=(X2st-X1st)*0.25 then Xd:=-stx;
if Yd<=Xd then Xd:=stx;
a:=a+2*pi/30;
{
XSSt:=XSSt+Xd;
YSSt:=YSSt+Yd;
If XSSt<=X1st+round((X2st-X1st)*((1-0.5)/2)) then Xd:=stx;
If YSSt<=Y4st+round((Y1st-Y3st)*((1-0.5)/2)) then Yd:=sty;
If XSSt>=X1st+round((X2st-X1st)*0.5)+round((X2st-X1st)*((1-0.5)/2)) then Xd:=-stx;
If YSSt>=Y4st+round((Y1st-Y3st)*0.5)+round((Y1st-Y3st)*((1-0.5)/2)) then Yd:=-sty;
}
tria:=1;
{$IfDef Test}
asm
mov dx,03dah
@Retrace: in al,dx
test al,08h
jz @Retrace
@NoRetrace: in al,dx
test al,08h
jnz @NoRetrace
mov dx,03c0h
mov al,11h+32
out dx,al
mov al,15
out dx,al
End;
{$EndIf}
Triangel(X1st,Y1st,XSst,YSst,X2st,Y2st);
{$IfDef Test}
asm
mov dx,03c0h
mov al,11h+32
out dx,al
mov al,0
out dx,al
End;
tria:=0;
{$EndIf}