/* Bubble */ #include #include #include #include #include #include #include "gr-sim.h" #include "tfv_utils.h" #include "tfv_zp.h" #define NUM 32 static double fixed_to_float(int8_t hi, uint8_t lo) { int temp=(hi<<8)|lo; return temp/256.0; } static void float_to_fixed(double input, int8_t *hi, uint8_t *lo) { int temp; if (input>255) printf("float_to_fixed: %lf too big\n",input); if (input<-255) printf("float_to_fixed: %lf too small\n",input); temp=input*256; *hi=temp>>8; *lo=temp&0xff; return; } static void fixed_add(int8_t add1h,uint8_t add1l, int8_t add2h,uint8_t add2l, int8_t *outh,uint8_t *outl) { int a1,a2,s; a1=(add1h<<8)|add1l; a2=(add2h<<8)|add2l; s=a1+a2; *outh=(s>>8)&0xff; *outl=(s&0xff); } int main(int argc, char **argv) { int ch; int i,j; double r,u=0; int8_t th,xh,rxh,ivh,vh,uh,rh[NUM]; uint8_t tl,xl,rxl,ivl,vl,ul,rl[NUM]; grsim_init(); // HCOLOR=7 hcolor_equals(7); // N=200:R=6.28/235:T=0:SZ=200:SW=280/SZ:SH=SCRH/SZ r=6.28/256.0; th=0; tl=0; uh=0; ul=0; vh=0; vl=0; xh=0; xl=0; rxh=0; rxl=0; for(i=0;i=0xf8) th=th+1; tl=tl+0x08; // printf("%x %x\n",th,tl); } return 0; }