#include #include static int debug=0; static void make_coord_line(int frame,int x,int y,int destx,int desty) { int status, xh,xl, yh,yl; double theta,dx,dy; int dxi,dyi,dxh,dxl,dyh,dyl; int closestx,closesty,distance,closest; // status frame x/x y/y dx/dx dy/dy destx desty/radius status=0; xl=0; xh=x; yl=0; yh=y; if ((destx-x)!=0) { theta=atan2((desty-y),(destx-x)); dx=cos(theta); dy=sin(theta); } else { if (debug) printf("; VERTICAL\n"); theta=0; dx=0; dy=1; } dxi=dx*256; dyi=dy*256; dxh=(dxi>>8)&0xff; dxl=dxi&0xff; dyh=(dyi>>8)&0xff; dyl=dyi&0xff; if (debug) { printf("; theta=%lf dx=%lf dy=%lf\n",theta,dx,dy); printf("; dxh=%d dxl=%d\n",dxh,dxl); printf("; dyh=%d dyl=%d\n",dyh,dyl); } { int i,blahx,blahy; blahx=xh*256; blahy=yh*256; closest=1000000; closestx=0; closesty=0; for (i=0;i<200;i++) { distance=sqrt((blahx/256-destx)*(blahx/256-destx)+ (blahy/256-desty)*(blahy/256-desty)); if (distancedestx) direction=-1; else direction=1; last=0,last2=0; if (debug) printf("; x=%d destx=%d y=%d height=%d\n", x,destx,y,height); if (debug) printf("; center_x=%d width=%d top=%d\n", (x+destx)/2, (x-destx), y-height); for(i=x;i!=destx;i+=direction) { current=func(i,x,destx,y,height); if (debug) printf("; %d %lf -- %lf %lf\n",i,current, current-last,last2-(current-last)); diff=(current-last)-last2; last2=current-last; last=current; } urgh=func(x+direction,x,destx,y,height)-func(x,x,destx,y,height); zurgh=diff; u=urgh*256; z=zurgh*256; if (debug) printf("; $%02X $%02X, $%02X $%02X\n",(u>>8)&0xff,u&0xff, (z>>8)&0xff,z&0xff); #if 0 { int i,blahx,blahy; blahx=xh*256; blahy=yh*256; closest=1000000; closestx=0; closesty=0; for (i=0;i<200;i++) { distance=sqrt((blahx/256-destx)*(blahx/256-destx)+ (blahy/256-desty)*(blahy/256-desty)); if (distance>8)&0xff,u&0xff, (z>>8)&0xff,z&0xff, destx,255); } int main(int argc, char **argv) { char string[BUFSIZ]; char *ptr; int x,y; int type, frame; int destx, desty; while(1) { ptr=fgets(string,BUFSIZ,stdin); if (ptr==NULL) break; if (string[0]=='#') continue; sscanf(string,"%d %d %d %d %d %d", &type,&frame,&x,&y,&destx,&desty); if (type==0) { make_coord_line(frame,x,y,destx,desty); } else if (type==1) { make_coord_parab(frame,x,y,destx,desty); } else { fprintf(stderr,"Error, unknown type %d\n",type); } } printf(".byte $FE\n"); return 0; } // 10,10 100,100 slope=90/90=1 // // // // // //