コード例 #1
0
ファイル: state.c プロジェクト: swarzesherz/mame-test
state_save_error state_save_read_file(running_machine *machine, mame_file *file)
{
	state_private *global = machine->state_data;
	UINT32 signature = get_signature(machine);
	UINT8 header[HEADER_SIZE];
	state_callback *func;
	state_entry *entry;
	int flip;

	/* if we have illegal registrations, return an error */
	if (global->illegal_regs > 0)
		return STATERR_ILLEGAL_REGISTRATIONS;

	/* read the header and turn on compression for the rest of the file */
	mame_fcompress(file, FCOMPRESS_NONE);
	mame_fseek(file, 0, SEEK_SET);
	if (mame_fread(file, header, sizeof(header)) != sizeof(header))
		return STATERR_READ_ERROR;
	mame_fcompress(file, FCOMPRESS_MEDIUM);

	/* verify the header and report an error if it doesn't match */
	if (validate_header(header, machine->gamedrv->name, signature, popmessage, _("Error: "))  != STATERR_NONE)
		return STATERR_INVALID_HEADER;

	/* determine whether or not to flip the data when done */
	flip = NATIVE_ENDIAN_VALUE_LE_BE((header[9] & SS_MSB_FIRST) != 0, (header[9] & SS_MSB_FIRST) == 0);

	/* read all the data, flipping if necessary */
	for (entry = global->entrylist; entry != NULL; entry = entry->next)
	{
		UINT32 totalsize = entry->typesize * entry->typecount;
		if (mame_fread(file, entry->data, totalsize) != totalsize)
			return STATERR_READ_ERROR;

		/* handle flipping */
		if (flip)
			flip_data(entry);
	}

	/* call the post-load functions */
	for (func = global->postfunclist; func != NULL; func = func->next)
		(*func->func.postload)(machine, func->param);

	return STATERR_NONE;
}
コード例 #2
0
GLuint texture_load_data(unsigned char *data, int width, int height, 
                         int components, int pitch,
                         GLint internalFormat, GLenum format, GLenum type)
{
    GLuint id;
    int alignment;
    int row_length;
	
    /* If pitch is negative, flip order of rows from top-to-bottom to
	 bottom-to-top. */
    if (pitch < 0)
    {
        pitch = -pitch;
        flip_data(data, pitch, height);
    }
	
    if (pitch & 0x1)
        alignment = 1;
    else if (pitch & 0x2)
        alignment = 2;
    else
        alignment = 4;
    row_length = pitch / components;
	
    glPushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT);
    glPixelStorei(GL_UNPACK_ALIGNMENT, alignment);
    glPixelStorei(GL_UNPACK_ROW_LENGTH, row_length);
	
    glGenTextures(1, &id);
    glBindTexture(GL_TEXTURE_2D, id);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	
	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP);      //we repeat the pixels in the edge of the texture, it will hide that 1px wide line at the edge of the cube, which you have seen in the video
	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP);      //we do it for vertically and horizontally (previous line)
	glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, width, height, 0, format, 
                 type, data);

    glFinish();
	
    glPopClientAttrib();
	
    return id;
}
コード例 #3
0
ファイル: tetra_eval.c プロジェクト: RJHudspith/Knick_Knacks
// tetra computation
void
tetra_eval( double **xavg ,
	    struct resampled **bootavg ,
	    struct mom_info **mominfo ,
	    struct mom_info *moms ,
	    struct input_params *INPARAMS ,
	    const int NSLICES ,
	    const int LT )
{
  // Diquark-Diquark is in Slice #0 and Dimeson is in #1
  // Vector Meson is in #2
  // Pseudoscalar Meson is in #3
  size_t j ;
#ifdef COMPUTE_BINDING
  if( NSLICES == 4 ) {
    // take product of vector and pseudoscalar put into 2
    for( j = 0 ; j < INPARAMS -> NDATA[2] ; j++ ) {
      mult( &bootavg[2][j] , bootavg[3][j] ) ;
      mult_constant( &bootavg[2][j] , -1 ) ;
    }
  } else if( NSLICES == 8 ) {
    // take product of vector and pseudoscalar
    for( j = 0 ; j < INPARAMS -> NDATA[2] ; j++ ) {
      mult( &bootavg[2][j] , bootavg[3][j] ) ;
      mult_constant( &bootavg[2][j] , -1 ) ;
      
      mult( &bootavg[6][j] , bootavg[7][j] ) ;
      mult_constant( &bootavg[6][j] , -1 ) ;
    }

    // backwards data needs to b time flipped
    flip_data( bootavg[3] , bootavg[4] , INPARAMS -> NDATA[4] ) ;
    flip_data( bootavg[4] , bootavg[5] , INPARAMS -> NDATA[4] ) ;
    flip_data( bootavg[5] , bootavg[6] , INPARAMS -> NDATA[4] ) ;

    // average the data
    average_data( bootavg[0] , bootavg[3] , INPARAMS -> NDATA[0] ) ;
    average_data( bootavg[1] , bootavg[4] , INPARAMS -> NDATA[0] ) ;
    average_data( bootavg[2] , bootavg[5] , INPARAMS -> NDATA[0] ) ;
  }

  for( j = 0 ; j < INPARAMS -> NDATA[2] ; j++ ) {
    // divide correlator #0 by this result
    divide( &bootavg[0][j] , bootavg[2][j] ) ;
    divide( &bootavg[1][j] , bootavg[2][j] ) ;
  }
  
  // evaluate the correlator now
  correlator_eval( xavg , bootavg , mominfo , moms , 
		   INPARAMS , 2 , LT ) ;
#else
  // take product of vector and pseudoscalar put into 2
  for( j = 0 ; j < INPARAMS -> NDATA[2] ; j++ ) {
    mult( &bootavg[2][j] , bootavg[3][j] ) ;
    mult_constant( &bootavg[2][j] , -1 ) ;
  }
  // evaluate the correlator now
  correlator_eval( xavg , bootavg , mominfo , moms , 
		   INPARAMS , 3 , LT ) ;
#endif

  return ;
}