'=========================================================================== ' Subject: ANIMATED BLOB Date: 05-22-97 (17:01) ' Author: Angelo Ken Pesce Code: PB ' Origin: ken@uniserv.uniplan.it Packet: GRAPHICS.ABC '=========================================================================== ' TO DO LIST: ' ADD TWO SIDE FIREEFFECT ' OPTIMIZE BLOB ROUTINE ' ANIM OTHER PARAMETRERS ' INIT ----------------------------------------------------------------- $optimize speed ' 286 is REQUIRED... $cpu 80386 ' ...But 386 is better $lib all off $error all off $float npx ' Init mode 13 call mode13h call palset ' ---------------------------------------------------------------------- ' INIT VARS -------* TYPE blob x AS INTEGER y AS INTEGER radius AS integer radius64 as integer strength AS integer END TYPE defint a-z DIM tblob AS SINGLE, threshold AS single, t AS single xmin = 50: ymin = 0: xmax = 270: ymax = 200:threshold = .65:' Screen dimens. ' and threshold DIM blobs(3) AS blob dim deg1 as single, deg2 as single, deg3 as single dim aps(3) as single dim rpr(900) as single: ' THIS IS FOR BLOBS PRECALC (R<=300) ' INIT BLOBS -------* gosub blobpreset do ' UPDATE BLOBS POSITIONS incr deg1,0.05 incr deg2,0.1 incr deg3,0.2 blobs(1).x=160+sin(deg1*2)*80 blobs(2).x=160+sin(deg2*2)*80 blobs(3).x=160+sin(deg3*2)*80 blobs(1).y=100+cos(deg1)*80 blobs(2).y=100+cos(deg2)*80 blobs(3).y=100+cos(deg3)*80 ' DO BLOBS -------* FOR j = 0 TO ymax STEP 4 y = ymax-j for k=1 to 3 aps(k)=(y-blobs(k).y)^2 next FOR i = 0 TO xmax STEP 4 x = i + xmin t = 0 FOR k = 1 TO 3 r=((x-blobs(k).x)^2+aps(k))^0.5 IF r <= blobs(k).radius THEN t = t + rpr(k*300+r) END IF NEXT k ' DISPLAY BLOBS IF t >= threshold THEN col=t*63 ! mov al,col ! mov bx,y ' SHL BX,6 ! dw &he3c1 ! db 6 ! mov dx,&hA000 ! mov di,y ! mov cx,x ' SHL DI,8 ! dw &he7c1 ! db 8 ! mov es,dx ! add di,bx ! add di,cx ! stosb ! stosb ! add di,318 ! stosb ! mov es:[di],al else ! mov al,0 ! mov bx,y ' SHL BX,6 ! dw &he3c1 ! db 6 ! mov dx,&hA000 ! mov di,y ! mov cx,x ' SHL DI,8 ! dw &he7c1 ! db 8 ! mov es,dx ! add di,bx ! add di,cx ! stosb ! stosb ! add di,318 ! stosb ! mov es:[di],al end if NEXT NEXT loop until inkey$<>"" END ' ------------------------------------------------------------------------ ' SUBS ------------------------------------------------------------------- ' ------------------------------------------------------------------------ sub mode13h ! mov ax,&h13 ! int &h10 end sub sub palset dim k as byte out &h3c8,0 for k=0 to 63 out &h3c9,0 out &h3c9,0 out &h3c9,k next out &h3c8,64 for k=64 to 64+63 out &h3c9,k-64 out &h3c9,0 out &h3c9,0 next out &h3c8,127 for k=127 to 127+63 out &h3c9,0 out &h3c9,k-127 out &h3c9,0 next end sub blobpreset: blobs(1).radius = 90 blobs(1).strength = 1 blobs(2).radius = 70 blobs(2).strength = 1 blobs(3).radius = 50 blobs(3).strength = 1 ' PRECALCS for k=1 to 3 for r=0 to 300 rpr(k*300+r)=blobs(k).strength*((1-(r/blobs(k).radius)^2)^2) next next return