예제 #1
0
파일: TileManager.cpp 프로젝트: nuvie/nuvie
const char *TileManager::lookAtTile(uint16 tile_num, uint16 qty, bool show_prefix)
{
 const char *desc;
 bool plural;
 Tile *tile;

 tile = get_original_tile(tile_num);

 if(qty > 1)
   plural = true;
 else
  plural = false;

 desc = look->get_description(tile->tile_num,&plural);
 if(show_prefix == false)
   return desc;

 if(qty > 0 &&
	(plural || Game::get_game()->get_game_type() == NUVIE_GAME_SE))
   sprintf(desc_buf,"%u %s",qty, desc);
 else
   sprintf(desc_buf,"%s%s",article_tbl[tile->article_n], desc);

 DEBUG(0,LEVEL_DEBUGGING,"%s (%d): flags1:",desc_buf,tile_num);
 print_b(LEVEL_INFORMATIONAL,tile->flags1);
 DEBUG(1,LEVEL_DEBUGGING," f2:");
 print_b(LEVEL_INFORMATIONAL,tile->flags2);
 DEBUG(1,LEVEL_DEBUGGING," f3:");
 print_b(LEVEL_INFORMATIONAL,tile->flags3);
 DEBUG(1,LEVEL_DEBUGGING,"\n");
 
 return desc_buf;
}
예제 #2
0
파일: stats.c 프로젝트: andreiw/superalign
void stats_print(struct stats *stats)
{
	if (stats->repeats > 1) {
		printf("Average of repeat averages: ");
		print_ns(stats->avg_per_time / stats->repeats, "s\n");
	}

	if (stats->gindex) {
		printf("Global stats:\n");
		if (stats->verbose)
			printf("\tProcessed: %ju\n", stats->gindex);
		printf("\tMin %s latency: ", stats->op);
		print_ns(stats->min, "s\n");
		printf("\tMax %s latency: ", stats->op);
		print_ns(stats->max, "s\n");
		printf("\tMean %s latency: ", stats->op);
		print_ns(stats->newm, "s\n");
		printf("\tLatency variance: %LG ns^2\n", stats->news / (stats->gindex - 1));
		printf("\tLatency stddev: %LG ns\n", sqrtl(stats->news / (stats->gindex - 1)));
		printf("\tMin %s speed: ", stats->op);
		print_b((1000000000.0 / stats->max) * stats->size, "B/s\n");
		printf("\tMax %s speed: ", stats->op);
		print_b((1000000000.0 / stats->min) * stats->size, "B/s\n");
		printf("\tAverage %s speed: ", stats->op);
		print_b((1000000000.0 / stats->newm) * stats->size, "B/s\n");
	}
}
예제 #3
0
int main()
{
/*
        int a[ROW][COL] = {
                                {1, 2},
                                {3, 4},
                                {5, 6},
                                {7, 8}
                          };
*/
        int a[ROW][COL] = {
                                {1},
                                {3},
                                {5},
                                {7}
                          };


        print_a(a, ROW, COL);
        int **b = rotate_90(a, ROW, COL);
        print_b(b, COL, ROW);

        cleanup(b, COL, ROW);

        return 0;
}
예제 #4
0
파일: c_client.c 프로젝트: 3112517927/otp
static void print_bseq(m_bseq *b)
{
    int i;

    fprintf(stdout, "\nm_bseq size: %ld  --------\n",b->_length);
    for (i = 0; i < b->_length; i++)
	print_b(&(b->_buffer[i]));
}
예제 #5
0
파일: mt.c 프로젝트: cran/multtest
void  get1pvalue(GENE_DATA* pdata,int* L,float* T,float* P,
		 FUNC_STAT func_stat,FUNC_SAMPLE func_first_sample, 
		 FUNC_SAMPLE func_next_sample,FUNC_CMP func_cmp,const void* extra)
{
  int b=0,*bL,i,is_next,*total;
  float *bT, *count;
  int ncol=pdata->ncol;
  int nrow=pdata->nrow;
  int B=(*func_first_sample)(NULL);
  /*allocate the space and initialziation*/
  assert(bT=(float*)Calloc(nrow,float));
  assert(bL=(int*)Calloc(ncol,int));
  assert(count=(float*)Calloc(nrow,float));
  memset(count,0,sizeof(float)*nrow); 
  assert(total=(int*)Calloc(nrow,int));
  memset(total,0,sizeof(int)*nrow);

  /*comuter the original one first*/
  compute_test_stat(pdata,L,T,func_stat,extra);

  /*iteration for permutaion*/
  (*func_first_sample)(bL);
  is_next=1;
  b=0;
  while(is_next){
    compute_test_stat(pdata,bL,bT,func_stat,extra);
    for(i=0;i<nrow;i++){
      if(bT[i]==NA_FLOAT) continue;
      if(T[i]==NA_FLOAT) continue;
      /* right now I only implements the 3 cases, which are pretty common*/
      if((func_cmp==cmp_high) &&(bT[i]>=T[i]-EPSILON)){
	count[i]+=1;
      }else if((func_cmp==cmp_low) &&(bT[i]<=T[i]+EPSILON)){
	count[i]+=1;
      }else if ((func_cmp==cmp_abs) &&(fabs(bT[i])>=fabs(T[i])-EPSILON)){
	count[i]+=1;
      }	      
      total[i]++;
     }
    b++;
    print_b(b,B,"b=");
    is_next=(*func_next_sample)(bL);
  }

  /*summarize the results*/
  for(i=0;i<nrow;i++){ 
    if(total[i]==0) 
      P[i]=NA_FLOAT;
    else P[i]=count[i]*1.0/total[i];
  }

  /*free the spaces*/
  Free(bT);
  Free(count);
  Free(total);
  Free(bL);
}
예제 #6
0
파일: print_b.c 프로젝트: jencce/stuff
int main()
{
	struct hs hs;
	hs.b = 129;
	hs.v = 12;

	printf("hs.t offset %d\n", (size_t)(&((struct hs *)0)->t));
	printf("hs.t offset %d\n", (&((struct hs *)0)->t));
	print_b(&hs.v);
	print_b1(&hs.v);
	print_b3(&hs.v);
	return 0;
}
예제 #7
0
파일: c_client.c 프로젝트: 3112517927/otp
static int struct_test(IC_Env *env)
{
    m_b b = {4711, 'a'}, bo, br;

    fprintf(stdout, "\n======== m_i_struct test ======\n\n");
    br = m_i_struct_test(NULL, &b, &bo, env);
    CHECK_EXCEPTION(env);
    RETURN_IF_OK(cmp_b(&b, &bo) && cmp_b(&b, &br));
    if (!cmp_b(&b, &bo)) {
	fprintf(stdout, " out parameter error, sent:\n");
	print_b(&b);
	fprintf(stdout, " got:\n");
	print_b(&bo);
	fprintf(stdout, "\n");
    }
    if (!cmp_b(&b, &br)) {
	fprintf(stdout, " result error, sent:\n");
	print_b(&b);
	fprintf(stdout, " got:\n");
	print_b(&br);
	fprintf(stdout, "\n");
    }
    return -1;
}
예제 #8
0
int main(int argc, const char *argv[])
{
    int flag=0;
    while(1)
    {
        info();
        scanf("%d",&flag);
        getchar();
        if(flag==1)
        {
            print_b();    
            continu();
        }
        if(flag==2)
        {
            mul();
            continu();
        }
        if(flag==3)
        {
            flag=0;
            exchange_s();
            continu();
        }
        if(flag==4)
        {
            encryption();
            continu();
        }
        if(flag==5)
        {
            break;
        }
    }
    return 0;
}
예제 #9
0
파일: mt.c 프로젝트: cran/multtest
void  adj_by_T(GENE_DATA* pdata,float* T,float* P,float*Adj_P,
		 FUNC_STAT func_stat,FUNC_SAMPLE func_first_sample, 
		 FUNC_SAMPLE func_next_sample,FUNC_CMP func_cmp,const void* extra)
{
  int b=0,*bL,i,is_next,*total1,*R,*total2;
  float *bT, *count1,*count2,qT;/*qT is the successiv maxima*/
  int ncol=pdata->ncol;
  int nrow=pdata->nrow;
  int B=(*func_first_sample)(NULL);
  /*allocate the space and initialziation*/
  assert(bT=(float*)Calloc(nrow,float));
  assert(bL=(int*)Calloc(ncol,int));
  assert(count1=(float*)Calloc(nrow,float));
  memset(count1,0,sizeof(float)*nrow); 
  assert(total1=(int*)Calloc(nrow,int));
  memset(total1,0,sizeof(int)*nrow);
  assert(count2=(float*)Calloc(nrow,float));
  memset(count2,0,sizeof(float)*nrow); 
  assert(total2=(int*)Calloc(nrow,int));
  memset(total2,0,sizeof(int)*nrow);

  assert(R=(int*)Calloc(nrow,int));
   /*comuter the original t-statfirst*/

  compute_test_stat(pdata,pdata->L,T,func_stat,extra);

  /*sort the T*/  
  order_data(T,R,nrow,func_cmp);
  sort_gene_data(pdata,R);
  sort_vector(T,R,nrow);
  
  /*iteration for permutaion*/
  (*func_first_sample)(bL);

  /*changed to the orignal stat, which is monotone of t and centered*/
  is_next=1;
  b=0;
  while(is_next){
    compute_test_stat(pdata,bL,bT,func_stat,extra);
    /*deal with unajdused value first*/
    for(i=0;i<nrow;i++){
      if(T[i]==NA_FLOAT) continue;
      if(bT[i]!=NA_FLOAT){
	if((func_cmp==cmp_high)&&(bT[i]+EPSILON>=T[i])) count2[i]++;
	if((func_cmp==cmp_low)&&(bT[i]<=T[i]+EPSILON)) count2[i]++;
	if((func_cmp==cmp_abs)&&(fabs(bT[i])>=fabs(T[i])-EPSILON)) count2[i]++;
	total2[i]++;
      }
    }

    /*deal with adjusted values*/
    qT=NA_FLOAT;/*intitalize the qT*/
    for(i=nrow-1;i>=0;i--){ /*looping the row reversely*/
      if(T[i]==NA_FLOAT) continue;
        /* right now I only implements the 3 cases, which are pretty common*/
      if(func_cmp==cmp_high){
	if((bT[i]!=NA_FLOAT)&&(qT!=NA_FLOAT)&&(bT[i]>qT))
	  qT=bT[i];
	if((bT[i]!=NA_FLOAT)&&(qT==NA_FLOAT))
	  qT=bT[i];
	if((qT!=NA_FLOAT)&&(qT>=T[i]-EPSILON)) count1[i]+=1;
      }else if(func_cmp==cmp_low){
	if((bT[i]!=NA_FLOAT)&&(qT!=NA_FLOAT)&&(bT[i]<qT))
	  qT=bT[i];
	if((bT[i]!=NA_FLOAT)&&(qT==NA_FLOAT))
	  qT=bT[i];
	if((qT!=NA_FLOAT)&&(qT<=T[i]+EPSILON)) count1[i]+=1;
      }else if (func_cmp==cmp_abs) {
	if((bT[i]!=NA_FLOAT)&&(qT!=NA_FLOAT)&&(fabs(bT[i])>qT))
	  qT=fabs(bT[i]);
	if((bT[i]!=NA_FLOAT)&&(qT==NA_FLOAT))
	  qT=fabs(bT[i]);
	if((qT!=NA_FLOAT)&&(qT>=fabs(T[i])-EPSILON)) count1[i]+=1;
      }	      
      if(qT!=NA_FLOAT) total1[i]++;
    }
    b++;
    print_b(b,B,"b=");
    is_next=(*func_next_sample)(bL);
  }

  /*summarize the results*/
  /*unadjusted one*/
  for(i=0;i<nrow;i++){ 
    if(total2[i]==0) 
      P[i]=NA_FLOAT;
    else P[i]=count2[i]*1.0/total2[i];
  }
  /*adjused one*/
  for(i=0;i<nrow;i++){ 
    if(total1[i]==0) 
      Adj_P[i]=NA_FLOAT;
    else Adj_P[i]=count1[i]*1.0/total1[i];
  }
  /*enforce the montonicity*/
  for(i=1;i<nrow;i++)
    if(Adj_P[i]<Adj_P[i-1])
      Adj_P[i]=Adj_P[i-1];
  /*free the spaces*/
  Free(bT);
  Free(count1);
  Free(total1);
  Free(count2);
  Free(total2);
  Free(bL);
  Free(R);
}      
예제 #10
0
파일: mt.c 프로젝트: cran/multtest
void adj_pvalue_quick(GENE_DATA* pdata,float*T, float* P, 
		      float* Adj_P,float* Adj_Lower,
		      FUNC_STAT func_stat,FUNC_STAT func_stat_T,
		      FUNC_SAMPLE func_first_sample, 
		      FUNC_SAMPLE func_next_sample,FUNC_CMP func_cmp,const void* extra)
{

  int *L,b,B,B_new,i,*R,neq; /*b for simulation*, neq is for the number of equal signs*/
  float* all_P,*all_Q,count;
  int ncol=pdata->ncol,nrow=pdata->nrow;
   
  /*allocate the space*/
  B=(*func_first_sample)(NULL);
  assert(L=(int*)Calloc(ncol,int)); 
  assert(R=(int*)Calloc(nrow,int));
  assert(all_P=(float*)Calloc(B,float));
  assert(all_Q=(float*)Calloc(B,float));

  /*get the original unadjusted p-values first
   we'll use the normalized t-statistics*/
  get1pvalue(pdata,pdata->L,T,P,func_stat_T,func_first_sample,func_next_sample,func_cmp,extra);
  if(myDEBUG)
    {
      print_farray(stderr,T,pdata->nrow);
      print_farray(stderr,P,pdata->nrow);
    }
  /*sort the test_stat*/
  order_mult_data(R,nrow,2,P,cmp_low,T,func_cmp);
  /*order_data(P,R,nrow,func_cmp);*/

  /*rearrange the data according the unadjusted p-values*/
  sort_gene_data(pdata,R);
  sort_vector(T,R,nrow);
  sort_vector(P,R,nrow);
  
  /*initialze all_Q[]=NA_FLOAT*/
  for(b=0;b<B;b++)
    all_Q[b]=NA_FLOAT;

  /*loop for each gene*/
  for(i=nrow-1;i>=0;i--){
    get_all_samples_P(pdata->d[i],ncol,all_P,pdata->na,
		      func_stat,func_first_sample,func_next_sample,func_cmp,extra);
    if(myDEBUG)
      print_farray(stderr,all_P,B);

    /*update all_Q*/
    count=0;
    B_new=0;
    neq=0;

    for(b=0;b<B;b++){
      if (all_P[b]==NA_FLOAT) break;/*we don't need care about NA pvlaues*/
      if(all_Q[b]>all_P[b])
	all_Q[b]=all_P[b];/*update q* by the value p*/
      if(all_Q[b]==NA_FLOAT) continue;/*skip NA q*/
      if(all_Q[b]<P[i]){
	count+=1;
      }else if (all_Q[b]<=P[i]+EPSILON)/*it'd already > */
	 neq++;
      B_new++;
    }

    if(myDEBUG)
      {
	print_farray(stderr,all_Q,B);
	fprintf(stderr,"P[%d]=%5.3f,count=%5.2f,neq=%d\n",i,P[i],count,neq);
      }

    /*assign the Adj_P and Adj_Lower for gene i */
    if(B_new!=0) {
      Adj_P[i]=(count+neq)/B_new;

      if(neq==0) 
	Adj_Lower[i]=count/B_new;
      else Adj_Lower[i]=(count+1)/B_new;
    }
    else {
      Adj_P[i]=NA_FLOAT;
      Adj_Lower[i]=NA_FLOAT; 
    }
    /*************************** */
    print_b((nrow-i),nrow,"r="); 
  }

  /* to make monotone of Adj_P and Adj_Lower*/
  for(i=1;i<nrow;i++)
    if(Adj_P[i]<Adj_P[i-1])
      Adj_P[i]=Adj_P[i-1];

  for(i=1;i<nrow;i++)
    if(Adj_Lower[i]<Adj_Lower[i-1])
      Adj_Lower[i]=Adj_Lower[i-1];

  /*free the spaces*/
  Free(L);
  Free(R);
  Free(all_P);
  Free(all_Q);
}
예제 #11
0
파일: TileManager.cpp 프로젝트: nuvie/nuvie
bool TileManager::loadTiles()
{
 std::string maptiles_path, masktype_path, path;
 NuvieIOFileRead objtiles_vga;
 NuvieIOFileRead tileindx_vga;
 NuvieIOFileRead file;
 U6Lib_n lib_file;
 U6Lzw *lzw;
 uint32 tile_offset;

 unsigned char *tile_data = NULL;
 uint32 maptiles_size = 0;
 uint32 objtiles_size;

 unsigned char *masktype = NULL;
 uint32 masktype_size;
 uint16 i;

 Dither *dither;
 
 dither = Game::get_game()->get_dither();
 

 config_get_path(config,"maptiles.vga",maptiles_path);
 config_get_path(config,"masktype.vga",masktype_path);

 lzw = new U6Lzw();

 switch(game_type)
   {
    case NUVIE_GAME_U6 :
                         tile_data = lzw->decompress_file(maptiles_path,maptiles_size);
                         if(tile_data == NULL)
                         {
                            ConsoleAddError("Decompressing " + maptiles_path);
                            return false;
                         }

                         masktype = lzw->decompress_file(masktype_path,masktype_size);
                         if(masktype == NULL)
                         {
                        	 ConsoleAddError("Decompressing " + masktype_path);
                        	 return false;
                         }
                         break;
    case NUVIE_GAME_MD :
    case NUVIE_GAME_SE : if(lib_file.open(maptiles_path,4,game_type) == false)
                         {
                             ConsoleAddError("Opening " + maptiles_path);
                             return false;
                         }
                         maptiles_size = lib_file.get_item_size(0);

                         tile_data = lib_file.get_item(0);
                         lib_file.close();

                         if(lib_file.open(masktype_path,4,game_type) == false)
                         {
                        	 ConsoleAddError("Opening " + masktype_path);
                        	 return false;
                         }
                         //masktype_size = lib_file.get_item_size(0);

                         masktype = lib_file.get_item(0);
                         lib_file.close();
                         break;
   }

 if(tile_data == NULL)
 {
   ConsoleAddError("Loading maptiles.vga");
   return false;
 }

 if(masktype == NULL)
 {
   ConsoleAddError("Loading masktype.vga");
   return false;
 }

 config_get_path(config,"objtiles.vga",path);
 if(objtiles_vga.open(path) == false)
 {
	 ConsoleAddError("Opening " + path);
	 return false;
 }

 objtiles_size = objtiles_vga.get_size();

 tile_data = (unsigned char *)nuvie_realloc(tile_data,maptiles_size + objtiles_size);

 objtiles_vga.readToBuf(&tile_data[maptiles_size], objtiles_size);

 config_get_path(config,"tileindx.vga",path);

 if(tileindx_vga.open(path) == false)
 {
	 ConsoleAddError("Opening " + path);
	 return false;
 }

 for(i=0;i<2048;i++)
  {
   tile_offset = tileindx_vga.read2() * 16;
   tile[i].tile_num = i;

   tile[i].transparent = false;

   switch(masktype[i])
    {
     case U6TILE_TRANS : tile[i].transparent = true;
                         memcpy(tile[i].data, &tile_data[tile_offset], 256);
                         break;

     case U6TILE_PLAIN : memcpy(tile[i].data, &tile_data[tile_offset], 256);
                         break;

     case U6TILE_PBLCK : tile[i].transparent = true;
                         decodePixelBlockTile(&tile_data[tile_offset],i);
                         break;
    }

   dither->dither_bitmap(tile[i].data,16,16,tile[i].transparent);
   
   tileindex[i] = i; //set all tile indexs to default value. this is changed in update() for animated tiles
  }

 loadAnimData();
 loadTileFlag();

 free(masktype);
 free(tile_data);

 look = new Look(config);
 if(look->init() == false)
 {
   ConsoleAddError("Initialising Look Class");
   return false;
 }

 desc_buf = (char *)malloc(look->get_max_len() + 6); // add space for "%03d \n\0" or "the \n\0"
 if(desc_buf == NULL)
 {
   ConsoleAddError("Allocating desc_buf");
   return false;
 }

 loadAnimMask();

#ifdef TILEMANAGER_DEBUG

 look->print();

 DEBUG(0,LEVEL_DEBUGGING,"Dumping tile flags:");
 for(i=0;i<2048;i++)
  {
   bool plural;
   DEBUG(1,LEVEL_DEBUGGING,"%04d : ",i);
   print_b(LEVEL_DEBUGGING, tile[i].flags1);
   DEBUG(1,LEVEL_DEBUGGING," ");
   print_b(LEVEL_DEBUGGING, tile[i].flags2);
   DEBUG(1,LEVEL_DEBUGGING," ");
   print_b(LEVEL_DEBUGGING, tile[i].flags3);
   DEBUG(1,LEVEL_DEBUGGING," %s\n",look->get_description(i,&plural));
  }
#endif

 delete lzw;

 return true;
}
예제 #12
0
파일: gauss.c 프로젝트: parliamnt101/Matrix
int main(int argc, char **argv)
{
/*This function simply initializes the pointers that will be passed throughout all of the subroutines
 * and calls each subroutine in order.*/
  int *n,*size, sizeb=0, sizem=0;
  double *m,*b;
  m = NULL;
  b = NULL;
  n = NULL;
  size = NULL;
  m=b=0;

//Checks to make sure that enough arguments have been supplied. If not, exit.
  if(argc<3)
  {
    printf("You have not supplied enough arguments.\nPlease input the name of the file containing the matrix and the name of the file containing the solution vector\n");
    exit(EXIT_FAILURE);
  }


    size = malloc(sizeof(int));
    n = malloc(sizeof(int));

if(argc == 4)
{
  if(0 == strcmp ("-np",argv[3]))
  {
//reads in the solution vector
    readin(argv[2],&b,size);

//records the size of the solution vector
    sizeb = *size;

//reads in the matrix
    readin(argv[1],&m,size);

//records the dimension of the matrix
    sizem = sqrt(*size);
    if(pow(sizem,2) != *size)
    {
      printf("This matrix is not square!\n");
      exit(EXIT_FAILURE);
    }

//checks that the matrix dimension and the size of the solution vector are the same
    if(sizem != sizeb)
    {
      printf("The matrix is not the same size as the solution vector!!\n");
      exit(EXIT_FAILURE);
    }

    *n = sizem;

    no_pivot(m,b,n);

    print_matrix(m,n);

    print_b(b,n);

    answer(m,b,n);
  }
  else printf("%s is not a valid flag\n",argv[4]);
}


//---------------------------------------------------------------------------------


//If there are only 3 arguments, default to pivoting
if(argc == 3)
{
    readin(argv[2],&b,size);

//records the size of the solution vector
    sizeb = *size;

    readin(argv[1],&m,size);

//records the dimension of the matrix
    sizem = sqrt(*size);
    if(pow(sizem,2) != *size)
    {
      printf("This matrix is not square!\n");
      exit(EXIT_FAILURE);
    }

//checks that the matrix dimension and the size of the solution vector are the same
    if(sizem != sizeb)
    {
      printf("The matrix is not the same size as the solution vector!!\n");
      exit(EXIT_FAILURE);
    }

    *n = sizem;

    pivoting(m,b,n);

    print_b(b,n);

    answer(m,b,n);

    print_matrix(m,n);
}

  free (m);
  free (b);
  free (n);
  free (size);
return (0);
}
예제 #13
0
void ReadFont(FILE *fin)
{
	char b[128];

	int ch;

	int w = 0, h = 0;

	int ch_h = 0;

	bool open = false;

	printf("#include <stdint.h>\n");
	printf("#ifdef ARDUINO\n");
	printf("#include \"fonts.hpp\"\n");
	printf("#include <avr/pgmspace.h>\n");
	printf("#endif\n");
	printf("#ifndef PROGMEM\n");
	printf("#define PROGMEM\n");
	printf("#endif\n");
	printf("\n");

	while (fgets(b, sizeof(b), fin))
	{
		if (sscanf(b, "// w=%d h=%d", &w, &h) == 2)
		{
			if (open)
				printf("};\n\n");

			printf("const uint8_t font_%02dx%02d[] PROGMEM = {\n", w, h);
			printf("\t%d, %d,\n", w, h);
			open = true;
			continue;
		}

		if (sscanf(b, "// ch=%d", &ch) == 1)
		{
			continue;
		}

		if (b[0] == '.' || b[0] == 'X')
		{
			uint16_t r = 0;
			uint16_t m = 1;

			for (int i = w-1; i >= 0; --i)
			{
				if (b[i] == 'X')
					r |= m;
				m <<= 1;
			}


			if (false)
			{
				if (ch_h == 0) printf("\t");
				if (w <= 8)
					printf("0x%02x,", r);
				else
				{
					printf("0x%02x,", r>>8);
					printf("0x%02x,", r&0xff);
				}

				ch_h += 1;
				if (ch_h == h)
				{
					printf(" // %3d %c\n", ch, ch);
					ch_h = 0;
				}
			}
			else
			{
				if (w <= 8)
				{
					printf("\t"); print_b(r, 8); printf(","); 
					if (ch_h == 0) printf(" // %3d %c", ch, ch);
				}
				else
				{
					printf("\t"); 
					print_b(r >> 8, 8); printf(","); 
					print_b(r & 0xff, 8); printf(","); 
					if (ch_h == 0) printf(" // %3d %c", ch, ch);
				}
				printf("\n"); 
				ch_h += 1;
				if (ch_h == h) { ch_h = 0; printf("\n"); }
			}
		}