Ejemplo n.º 1
0
/****************************************************************************
REMARKS:
VxD implementation of the ANSI C fread function. Note that the VxD file I/O
functions are layered on DOS, so can only read up to 64K at a time. Since
we are expected to handle much larger chunks than this, we handle larger
blocks automatically in here.
****************************************************************************/
size_t fread(
    void *ptr,
    size_t size,
    size_t n,
    FILE *f)
{
    char    *buf = ptr;
    WORD    error;
    int     bytes = size * n;
    int     readbytes,totalbytes = 0;

    while (bytes > 0x10000) {
	if (initComplete) {
	    readbytes  = R0_ReadFile(false,(HANDLE)f->handle,buf,0x8000,f->offset,&error);
	    readbytes += R0_ReadFile(false,(HANDLE)f->handle,buf+0x8000,0x8000,f->offset+0x8000,&error);
	    }
	else {
	    readbytes  = i_read(f->handle,buf,0x8000);
	    readbytes += i_read(f->handle,buf+0x8000,0x8000);
	    }
	totalbytes += readbytes;
	f->offset += readbytes;
	buf += 0x10000;
	bytes -= 0x10000;
	}
    if (bytes) {
	if (initComplete)
	    readbytes = R0_ReadFile(false,(HANDLE)f->handle,buf,bytes,f->offset,&error);
	else
	    readbytes = i_read(f->handle,buf,bytes);
	totalbytes += readbytes;
	f->offset += readbytes;
	}
    return totalbytes / size;
}
Ejemplo n.º 2
0
void ICVM_read(void){
	R_R0=i_read(
		rSTKs32(0),
		Nptr(rSTKu32(1)),
		rSTKu32(2));
	icvm_returnerr();
}
Ejemplo n.º 3
0
/****************************************************************************
REMARKS:
VxD implementation of the ANSI C fread function. Note that the VxD file I/O
functions are layered on DOS, so can only read up to 64K at a time. Since
we are expected to handle much larger chunks than this, we handle larger
blocks automatically in here.
****************************************************************************/
size_t fread(
	void *ptr,
	size_t size,
	size_t n,
	FILE *f)
{
	char	*buf = ptr;
	WORD 	error;
	int		bytes,readbytes,totalbytes = 0;

	/* First copy any data already read into our buffer */
	if ((bytes = (f->curp - f->startp)) > 0) {
		memcpy(buf,f->curp,bytes);
		f->startp = f->curp = f->buf;
		buf += bytes;
		totalbytes += bytes;
		bytes = (size * n) - bytes;
		}
	else
		bytes = size * n;
	while (bytes > 0x10000) {
		if (initComplete) {
			readbytes  = R0_ReadFile(false,(HANDLE)f->handle,buf,0x8000,f->offset,&error);
			readbytes += R0_ReadFile(false,(HANDLE)f->handle,buf+0x8000,0x8000,f->offset+0x8000,&error);
			}
		else {
			readbytes  = i_read(f->handle,buf,0x8000);
			readbytes += i_read(f->handle,buf+0x8000,0x8000);
			}
		totalbytes += readbytes;
		f->offset += readbytes;
		buf += 0x10000;
		bytes -= 0x10000;
		}
	if (bytes) {
		if (initComplete)
			readbytes = R0_ReadFile(false,(HANDLE)f->handle,buf,bytes,f->offset,&error);
		else
			readbytes = i_read(f->handle,buf,bytes);
		totalbytes += readbytes;
		f->offset += readbytes;
		}
	return totalbytes / size;
}
Ejemplo n.º 4
0
int main( void )
{
	 puts("starting MAIN execution\n");
	 //unsigned char data[16] = {12, 15, 20, 210, 124, 16, 54, 156, 134, 21, 7, 15, 46, 97, 84, 161}; 

    unsigned short tmp;

	 unsigned char max, min;
	 unsigned short beta;
	 unsigned int data_pack, min_max_pack;
	 unsigned int beta_mini;
	 unsigned char mini, maxi;
	 int i;
	 unsigned int start_c, stop_c;
	 
	 unsigned int col_nb, row_nb, pixel_nb;
	 unsigned int A_row_ix, A_col_ix, B_row_ix, B_col_ix, row, col; 
	 volatile unsigned int dump;
	 A_row_ix = 25;
	 A_col_ix = 50;
	 B_row_ix = 75;
	 B_col_ix = 100;
	 
	 // on récupère le nombre de colonnes dans l'image
	 col_nb = i_read();
	 my_printf("nbre de colonnes dans l'image: ", col_nb);
	 
	 // on récupère le nombre de lignes dans l'image
	 row_nb = i_read();
	 my_printf("nbre de lignes dans l'image: ", row_nb);
	 
	 pixel_nb=col_nb*row_nb;
	 my_printf("nbre de pixel dans l'image: ", pixel_nb);

	 if(pixel_nb > 32768){
		  puts("WARNING :image trop volumineuse, taille max = 32768 octets");		  
	 }
	 
	 
#ifdef CROP
 row=col=i=0;
 
 while( i_empty() == 0 )//tant que la FIFO d'entrée n'est pas vide
  {	 
	 //if the pixel is in the zoom area, we store it
	 if(row < B_row_ix && row > A_row_ix && col < B_col_ix && col > A_col_ix){
		R[i] = i_read();
		G[i] = i_read();
		B[i] = i_read(); 
	   i++;
	 }
	 // otherwise, we dump 
	 else{
		dump = i_read();
		dump = i_read();
		dump = i_read();
	 }
	 col++;
	 if(col >= col_nb){
		col = 0;
		row++;
	 }
  }  
puts("Lecture de la FIFO d'entrée terminée\n");

  col_nb = B_col_ix-A_col_ix;
  my_printf("col_nb cropped: ", col_nb);
  row_nb = B_row_ix-A_row_ix;
  my_printf("row_nb cropped: ", row_nb);
  pixel_nb = row_nb*col_nb;
  my_printf("pixel_nb cropped: ", pixel_nb);
  
  o_write( col_nb);
  o_write( row_nb);
  o_write( 255 );
  for(i=0;i<pixel_nb;i++){ // pour chaque échantillon 
	 o_write( R[i] );
	 o_write( G[i] );
	 o_write( B[i] );
	 //my_printf("dataout", data[i]);
  } 
puts("Ecriture des resultats dans la FIFO de sortie\n");
#endif


  
#ifdef RED
  o_write( col_nb);
  o_write( row_nb);
  o_write( 255 );
  for(i=0;i<pixel_nb;i++){ // pour chaque échantillon 
	 o_write( i_read() );
	 o_write( 0 );
	 o_write( 0 );
	 dump = i_read();
	 dump = i_read();
	 //my_printf("dataout", data[i]);
  } 
  /*while( i_empty() == 0 )//tant que la FIFO d'entrée n'est pas vide
  {	 
	 o_write( i_read());
  }*/  
  
#endif

#ifdef DEBUG
  // Affichage des valeurs de sortie sur la sortie standard
	for(i=0;i<pixel_nb;i++){
		my_printf(" scaled val=> ", data[i]);
	}
#endif

  // arrêt du programme
  puts("Fin du programme\n");
  stop();
}