'=========================================================================== ' Subject: PB ROTATE & SMOOTH EFFECT Date: 05-01-97 (22:01) ' Author: Angelo Ken Pesce Code: PB ' Origin: ken@uniserv.uniplan.it Packet: GRAPHICS.ABC '=========================================================================== ' APSOFTWARE 1997 ' POWERBASIC ROTATE+SMOOTH EFFECT TEST ' ------------------------------------------------------------ ' This is only a test version ' to do list: ' I have to build a new set of points (including mirrored negative points...) ' I have to use shift left instead of constant mult (*320) ' I have to make a better smooth effect ' ------------------------------------------------------------ $OPTIMIZE SPEED $CPU 80386 $FLOAT PROCEDURE $LIB ALL OFF ' ------------------------------------------------------------ ' Some math constants pi = 3.1415 ' Multiplication factor mult = 20 ' Number of points in data pts = 26 ' Look up tables DIM r(pts) DIM alpha(pts) ' Points x,y arrays DIM xp(pts) DIM yp(pts) ' TEST DATA (X,Y) DATA 3,1,4,1,1,2,2,2,3,2,4,2,5,2,6,2,1,3,2,3,5,3,6,3,1,4,2,4,3,4,4,4,5,4 data 6,4,1,5,2,5,5,5,6,5,1,6,2,6,5,6,6,6 ' ------------------------------------------------------------ ' ------------------------------------------------------------ FOR i = 1 TO pts READ b, a xp(i) = a * mult yp(i) = b * mult NEXT FOR i = 1 TO pts r(i) = SQR((xp(i) ^ 2) + (yp(i) ^ 2)) NEXT FOR i = 1 TO pts alpha(i) = ATN(yp(i) / xp(i)) NEXT ' ------------------------------------------------------------ GOTO maincode ' ------------------------------------------------------------ ' Subroutine: RotatePoints(D,COL) rotp: FOR k = 1 TO pts angle = alpha(k) + d radius = r(k) x = INT(radius * SIN(angle)) y = INT(radius * COS(angle)) IF x < 0 OR y < 0 THEN GOTO skipd ' SLOW MULT --- TO BE REPLACED using shift left...--- yy=y*320 POKE (yy + x), 63 poke ((y-1)*320+x),63 poke ((y+1)*320+x),63 poke (yy+x+1),63 poke (yy+x-1),63 skipd: NEXT RETURN ' Subroutine: Waitkpress wkp: DO: LOOP UNTIL INKEY$ <> "" RETURN ' Subroutine: Flame flm: for y=0 to 198 ym=y*320 ym2=(y+1)*320 for x=0 to 319 ymm=ym+x cl%=peek(ymm+1)+peek(ymm) if cl%=0 then goto skpf else cl%=cl%+peek(ymm-1)+peek(ym2+x) shift right cl%,2 poke (ym+x),cl% skpf: next next return ' ------------------------------------------------------------ maincode: ! mov ax,&h13 ! int &h10 OUT &H03c8,0 for i=0 to 63 out &h03c9,i out &h03c9,0 out &h03c9,0 next DEF SEG = &HA000 do FOR d = 0 TO pi*2 STEP .05 GOSUB rotp gosub flm NEXT loop END