Example #1
0
void PACK_APIENTRY crPackMap2dSWAP(GLenum target, GLdouble u1, 
        GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, 
        GLint vstride, GLint vorder, const GLdouble *points)
{
    unsigned char *data_ptr;
    int u,v;
    int comp;
    GLdouble *dest_data, *src_data;
    int packet_length = 
        sizeof(target) + 
        sizeof(u1) +
        sizeof(u2) +
        sizeof(uorder) +
        sizeof(ustride) +
        sizeof(v1) +
        sizeof(v2) + 
        sizeof(vorder) +
        sizeof(vstride);

    int num_components = __gl_Map2NumComponents(target);
    if (num_components < 0)
    {
        __PackError(__LINE__, __FILE__, GL_INVALID_ENUM,
                                 "crPackMap2d(bad target)");
        return;
    }

    packet_length += num_components*uorder*vorder*sizeof(*points);

    data_ptr = (unsigned char *) crPackAlloc(packet_length);

    WRITE_DATA(0, GLenum, SWAP32(target));
    WRITE_SWAPPED_DOUBLE(4, u1);
    WRITE_SWAPPED_DOUBLE(12, u2);
    WRITE_DATA(20, GLint, SWAP32(num_components));
    WRITE_DATA(24, GLint, SWAP32(uorder));
    WRITE_SWAPPED_DOUBLE(28, v1);
    WRITE_SWAPPED_DOUBLE(36, v2);
    WRITE_DATA(44, GLint, SWAP32(num_components*uorder));
    WRITE_DATA(48, GLint, SWAP32(vorder));

    dest_data = (GLdouble *) (data_ptr + 52);
    src_data = (GLdouble *) points;
    for (v = 0 ; v < vorder ; v++)
    {
        for (u = 0 ; u < uorder ; u++)
        {
            for (comp = 0 ; comp < num_components ; comp++)
            {
                WRITE_SWAPPED_DOUBLE(((unsigned char *) dest_data + comp*sizeof(*points)) - data_ptr, *(src_data + comp));
            }
            dest_data += num_components;
            src_data += ustride;
        }
        src_data += vstride - ustride*uorder;
    }

    crHugePacket(CR_MAP2D_OPCODE, data_ptr);
    crPackFree(data_ptr);
}
//------------------------------------------------------------------------------
void ofxJitterNetworkSender::sendText(const string& txt) {
    m_messageHeader.id = SWAP32(JIT_MESSAGE_PACKET_ID);
    m_messageHeader.size = SWAP32(sizeof(long) + // size
                                  sizeof(long) + // ac
                                  sizeof(char) + // type
                                  sizeof(char)*txt.length() + // number
                                  sizeof(char)); // null terminator
    
    sendRawBytes((char *)&m_messageHeader.id, sizeof(long));
    sendRawBytes((char *)&m_messageHeader.size, sizeof(long));
    
    // the packet
    long messageSizeBytes = m_messageHeader.size; //	32-bit integer that contains the size of the serialized message in bytes. 
    long ac = SWAP32(0);      //    Following that another 32-bit integer gives the argument count for the atoms. 
    /// Following that comes the message atoms themselves, starting with the leading symbol if it exists. 
    //  Each atom is represented in memory first with a char that indicates what type of atom it is:
    //		's' for symbol, 'l' for long, and 'f' for float. 
    //		For long and float atoms, the next 4 bytes contain the value of the atom; 
    //		for symbol atoms a null terminated character string follows. 
    
    
    char atomType = 's'; //'s' for symbol, 'l' for long, and 'f' for float. 
    const char *cp = txt.c_str(); // seriously
    char nullTerm = '\0';
    sendRawBytes((char *)&messageSizeBytes, sizeof(long));
    sendRawBytes((char *)&ac, sizeof(long));
    sendRawBytes((char *)&atomType, sizeof(char));
    sendRawBytes((char *)cp, txt.length()*sizeof(char));
    sendRawBytes((char *)&nullTerm, sizeof(char));
    
    //readResponse();
}
Example #3
0
void SaveFile( char* filename, void* buf, int size )
{
	FILE	*file;
	int		i, *buf2;

	/* エンディアン変換 */
	buf2 = (int*)buf;
	for ( i = 0 ; i < size / 4 ; i ++ )
	{
		buf2[i] = SWAP32(buf2[i]);
	}

	file = fopen(filename, "wb");
	if ( file )
	{
		fwrite(buf, 1, size, file);
		fclose(file);
	}

	/* もどす */
	for ( i = 0 ; i < size / 4 ; i ++ )
	{
		buf2[i] = SWAP32(buf2[i]);
	}
}
/* This little function converts a little endian tag to a big endian tag.
 * NOTE: The tag is not usable after this other than calculating the CRC
 * with.
 */
static void little_to_big_endian(yaffs_PackedTags2 *pt)
{
	pt->t.sequenceNumber = SWAP32(pt->t.sequenceNumber);
	pt->t.objectId = SWAP32(pt->t.objectId);
	pt->t.chunkId = SWAP32(pt->t.chunkId);
	pt->t.byteCount = SWAP32(pt->t.byteCount);
}
Example #5
0
static unsigned char * __gl_HandlePixelMapData( GLenum map, GLsizei mapsize, int size_of_value, const GLvoid *values )
{
	int i;

	int packet_length = 
		sizeof( map ) + 
		sizeof( mapsize ) + 
		mapsize*size_of_value;
	unsigned char *data_ptr = (unsigned char *) crPackAlloc( packet_length );

	WRITE_DATA( 0, GLenum, SWAP32(map) );
	WRITE_DATA( 4, GLsizei, SWAP32(mapsize) );

	for (i = 0 ; i < mapsize ; i++)
	{
		switch( size_of_value )
		{
			case 2:
				WRITE_DATA( 8 + i*sizeof(GLshort), GLshort, SWAP16(*((GLshort *)values + i) ));
				break;
			case 4:
				WRITE_DATA( 8 + i*sizeof(GLint), GLint, SWAP32(*((GLint *)values + i) ));
				break;
		}
	}
	return data_ptr;
}
Example #6
0
static CRMessageOpcodes *
__prependHeader( CRPackBuffer *buf, unsigned int *len, unsigned int senderID )
{
	int num_opcodes;
	CRMessageOpcodes *hdr;

	CRASSERT( buf );
	CRASSERT( buf->opcode_current < buf->opcode_start );
	CRASSERT( buf->opcode_current >= buf->opcode_end );
	CRASSERT( buf->data_current > buf->data_start );
	CRASSERT( buf->data_current <= buf->data_end );

	num_opcodes = buf->opcode_start - buf->opcode_current;
	hdr = (CRMessageOpcodes *) 
		( buf->data_start - ( ( num_opcodes + 3 ) & ~0x3 ) - sizeof(*hdr) );

	CRASSERT(buf->pack);
	CRASSERT( (void *) hdr >= buf->pack );

	if (replicate_spu.swap)
	{
		hdr->header.type = (CRMessageType) SWAP32(CR_MESSAGE_OPCODES);
		hdr->numOpcodes  = SWAP32(num_opcodes);
	}
	else
	{
		hdr->header.type = CR_MESSAGE_OPCODES;
		hdr->numOpcodes  = num_opcodes;
	}

	*len = buf->data_current - (unsigned char *) hdr;

	return hdr;
}
Example #7
0
void PACK_APIENTRY crPackAreTexturesResidentSWAP( GLsizei n, const GLuint *textures, GLboolean *residences, GLboolean *return_val, int *writeback )
{
	GET_PACKER_CONTEXT(pc);
	unsigned char *data_ptr;
	int packet_length;
	int i;

	packet_length = 
		sizeof( int ) +            /* packet length */
		sizeof( GLenum ) +       /* extend-o opcode */
		sizeof( n ) +            /* num_textures */
		n*sizeof( *textures ) +  /* textures */
		8 + 8 + 8;               /* return pointers */

	GET_BUFFERED_POINTER(pc, packet_length);
	WRITE_DATA( 0, int, SWAP32(packet_length) );
	WRITE_DATA( sizeof( int ) + 0, GLenum, SWAP32(CR_ARETEXTURESRESIDENT_EXTEND_OPCODE) );
	WRITE_DATA( sizeof( int ) + 4, GLsizei, SWAP32(n) );
	for (i = 0 ; i < n ; i++)
	{
		WRITE_DATA( (i+1)*sizeof( int ) + 8, GLuint, SWAP32(textures[i]) );
	}
	WRITE_NETWORK_POINTER( sizeof( int ) + 8 + n*sizeof( *textures ), (void *) residences );
	WRITE_NETWORK_POINTER( sizeof( int ) + 16 + n*sizeof( *textures ), (void *) return_val );
	WRITE_NETWORK_POINTER( sizeof( int ) + 24 + n*sizeof( *textures ), (void *) writeback );
	WRITE_OPCODE( pc, CR_EXTEND_OPCODE );
}
Example #8
0
void PACK_APIENTRY
crPackBufferDataARBSWAP( GLenum target, GLsizeiptrARB size,
                                         const GLvoid * data, GLenum usage )
{
    unsigned char *data_ptr, *start_ptr;
    int packet_length;

    packet_length = sizeof(GLenum)
        + sizeof(target) + sizeof(GLuint) + sizeof(usage) + sizeof(GLint);

    /*Note: it's valid to pass a NULL pointer here, which tells GPU drivers to allocate memory for the VBO*/
    if (data) packet_length += size;

    start_ptr = data_ptr = (unsigned char *) crPackAlloc( packet_length );

    WRITE_DATA_AI(GLenum, SWAP32(CR_BUFFERDATAARB_EXTEND_OPCODE) );
    WRITE_DATA_AI(GLenum, SWAP32(target) );
    WRITE_DATA_AI(GLuint, SWAP32((GLuint) size) );
    WRITE_DATA_AI(GLenum, SWAP32(usage) );
    WRITE_DATA_AI(GLint, SWAP32((GLint) (data!=NULL)) );
    if (data)
         crMemcpy(data_ptr, data, size);

    crHugePacket( CR_EXTEND_OPCODE, start_ptr );
    crPackFree( start_ptr );
}
Example #9
0
void PACK_APIENTRY crPackPrioritizeTexturesSWAP( GLsizei n,
		const GLuint *textures, const GLclampf *priorities )
{
	unsigned char *data_ptr;
	int packet_length = 
		sizeof( n ) + 
		n*sizeof( *textures ) + 
		n*sizeof( *priorities );
	int i;

	data_ptr = (unsigned char *) crPackAlloc( packet_length );
	WRITE_DATA( 0, GLsizei, SWAP32(n) );
	for ( i = 0 ; i < n ; i++)
	{
		WRITE_DATA( i*sizeof(int) + 4, GLint, SWAP32(textures[i]));
	}
	for ( i = 0 ; i < n ; i++)
	{
		WRITE_DATA( i*sizeof(int) + 4 + n*sizeof( *textures ),
				GLuint, SWAPFLOAT(priorities[i]));
	}

	crHugePacket( CR_PRIORITIZETEXTURES_OPCODE, data_ptr );
	crPackFree( data_ptr );
}
Example #10
0
static void __handleTexEnvData( GLenum target, GLenum pname, const GLfloat *params )
{
	GET_PACKER_CONTEXT(pc);
	unsigned char *data_ptr;
	int num_params;
	int i;

	int packet_length = 
		sizeof( int ) + 
		sizeof( target ) + 
		sizeof( pname );

	num_params = 1;
	if ( pname == GL_TEXTURE_ENV_COLOR )
	{
		num_params = 4;
	}

	packet_length += num_params*sizeof(*params);

	GET_BUFFERED_POINTER(pc, packet_length );
	WRITE_DATA( 0, int, SWAP32(packet_length) );
	WRITE_DATA( sizeof( int ) + 0, GLenum, SWAP32(target) );
	WRITE_DATA( sizeof( int ) + 4, GLenum, SWAP32(pname) );
	for ( i = 0 ; i < num_params ; i++)
	{
		WRITE_DATA( (i+1)*sizeof( int ) + 8, GLuint, SWAPFLOAT( params[i] ) );
	}
}
void write_all_hash_blocks(FILE *f, unsigned int filesize)
{
    unsigned int i, j=1, off, blockoff;
    unsigned int idval, block = 1;

    off = BLOCK_HASH_START;
    for(i = 0; i < 0xAA; i++)
    {
        idval = get_id(f, block);
        write_hash(f, (off+24*i), (FILE_HEADER_OFFSET+(BLOCK_SIZE*i)), BLOCK_SIZE, SWAP32(idval));
        block++;
    }

    while(1)
    {
         off = FILE_START_OFFSET + (0xAA * BLOCK_SIZE * j) + (BLOCK_SIZE * (j-1));
         if (off > filesize) break;
         for(i = 0; i < 0xAA; i++)
         {
             idval = get_id(f, block);

             blockoff = FILE_START_OFFSET+(BLOCK_SIZE*((0xAB*j)+i));
             if (blockoff > (filesize-1)) break;

             write_hash(f, (off+24*i), blockoff, BLOCK_SIZE, SWAP32(idval));
             block++;
         }

         j++;
     }
}
Example #12
0
static void
crSDPSend( CRConnection *conn, void **bufp,
           const void *start, unsigned int len )
{
	CRSDPBuffer *sdp_buffer;
	unsigned int      *lenp;
  
	if ( !conn || conn->type == CR_NO_CONNECTION )
		return;
  
	if ( bufp == NULL )
	{
		/* we are doing synchronous sends from user memory, so no need
		 * to get fancy.  Simply write the length & the payload and
		 * return. */
		const int sendable_len = conn->swap ? SWAP32(len) : len;
    
		crSDPWriteExact( conn, &sendable_len, sizeof(len) );
		if ( !conn || conn->type == CR_NO_CONNECTION) return;
		crSDPWriteExact( conn, start, len );
		return;
	}
	sdp_buffer = (CRSDPBuffer *)(*bufp) - 1;
  
	CRASSERT( sdp_buffer->magic == CR_SDP_BUFFER_MAGIC );
  
	/* All of the buffers passed to the send function were allocated
	 * with crSDPAlloc(), which includes a header with a 4 byte
	 * length field, to insure that we always have a place to write
	 * the length field, even when start == *bufp. */
	lenp = (unsigned int *) start - 1;
	if (conn->swap)
	{
		*lenp = SWAP32(len);
	}
	else
	{
		*lenp = len;
	}
  
	if ( __sdp_write_exact( conn->sdp_socket, lenp, len + sizeof(int) ) < 0 )
	{
		__sdp_dead_connection( conn );
	}
	/* reclaim this pointer for reuse and try to keep the client from
		 accidentally reusing it directly */
#ifdef CHROMIUM_THREADSAFE
	crLockMutex(&cr_sdp.mutex);
#endif
	crBufferPoolPush( cr_sdp.bufpool, sdp_buffer, sdp_buffer->allocated );
	/* Since the buffer's now in the 'free' buffer pool, the caller can't
	 * use it any more.  Setting bufp to NULL will make sure the caller
	 * doesn't try to re-use the buffer.
	 */
	*bufp = NULL;
#ifdef CHROMIUM_THREADSAFE
	crUnlockMutex(&cr_sdp.mutex);
#endif
}
Example #13
0
INT
PAL_MKFGetDecompressedSize(
   UINT    uiChunkNum,
   FILE   *fp
)
/*++
  Purpose:

    Get the decompressed size of a compressed chunk in an MKF archive.

  Parameters:

    [IN]  uiChunkNum - the number of the chunk in the MKF archive.

    [IN]  fp - pointer to the fopen'ed MKF file.

  Return value:

    Integer value which indicates the size of the chunk.
    -1 if the chunk does not exist.

--*/
{
   DWORD         buf[2];
   UINT          uiOffset;
   UINT          uiChunkCount;

   if (fp == NULL)
   {
      return -1;
   }

   //
   // Get the total number of chunks.
   //
   uiChunkCount = PAL_MKFGetChunkCount(fp);
   if (uiChunkNum >= uiChunkCount)
   {
      return -1;
   }

   //
   // Get the offset of the chunk.
   //
   fseek(fp, 4 * uiChunkNum, SEEK_SET);
   fread(&uiOffset, 4, 1, fp);
   uiOffset = SWAP32(uiOffset);

   //
   // Read the header.
   //
   fseek(fp, uiOffset, SEEK_SET);
   fread(buf, sizeof(DWORD), 2, fp);

   buf[0] = SWAP32(buf[0]);
   buf[1] = SWAP32(buf[1]);

   return (buf[0] != 0x315f4a59) ? -1 : (INT)buf[1];
}
Example #14
0
static void fixup_fmtchunk(struct fmtChunk *fmtchunk)
{
     fmtchunk->encoding = SWAP16(fmtchunk->encoding);
     fmtchunk->channels = SWAP16(fmtchunk->channels);
     fmtchunk->frequency = SWAP32(fmtchunk->frequency);
     fmtchunk->byterate = SWAP32(fmtchunk->byterate);
     fmtchunk->blockalign = SWAP16(fmtchunk->blockalign);
     fmtchunk->bitspersample = SWAP16(fmtchunk->bitspersample);
}
Example #15
0
/**
 * Send a huge buffer to one server, or all if server==-1.
 */
void
replicatespuHugeOne(CROpcode opcode, void *buf, int server)
{
	unsigned int          len;
	unsigned char        *src;
	CRMessageOpcodes *msg;
	int i;

	/* packet length is indicated by the variable length field, and
	   includes an additional word for the opcode (with alignment) and
	   a header */
	len = ((unsigned int *) buf)[-1];
	if (replicate_spu.swap)
	{
		/* It's already been swapped, swap it back. */
		len = SWAP32(len);
	}
	len += 4 + sizeof(CRMessageOpcodes);

	/* write the opcode in just before the length */
	((unsigned char *) buf)[-5] = (unsigned char) opcode;

	/* fix up the pointer to the packet to include the length & opcode
       & header */
	src = (unsigned char *) buf - 8 - sizeof(CRMessageOpcodes);

	msg = (CRMessageOpcodes *) src;

	if (replicate_spu.swap)
	{
		msg->header.type = (CRMessageType) SWAP32(CR_MESSAGE_OPCODES);
		msg->numOpcodes  = SWAP32(1);
	}
	else
	{
		msg->header.type = CR_MESSAGE_OPCODES;
		msg->numOpcodes  = 1;
	}

	if (server >= 0) {
		/* send to just one */
		if (IS_CONNECTED(replicate_spu.rserver[server].conn))	{
			crNetSend( replicate_spu.rserver[server].conn, NULL, src, len );
		}
	}
	else {
		/* send to all */
		for (i = 1; i < CR_MAX_REPLICANTS; i++) 
		{
			if (IS_CONNECTED(replicate_spu.rserver[i].conn))
			{
				crNetSend( replicate_spu.rserver[i].conn, NULL, src, len );
			}
		}
	}
}
Example #16
0
void initPakFile()
{
	#if defined(PAK_FILE) && DEV == 0
		int32_t offset;
		FILE *fp;
		int i;

		snprintf(pakFile, sizeof(pakFile), "%s%s", INSTALL_PATH, PAK_FILE);

		fp = fopen(pakFile, "rb");

		if (fp == NULL)
		{
			printf(_("Failed to open PAK file %s"), pakFile);
			printf("\n");
			printf("%s", _("If you compiled the game from source, you need to do a make install"));
			printf("\n");

			exit(0);
		}

		fseek(fp, -(sizeof(int32_t) + sizeof(int32_t)), SEEK_END);

		fread(&offset, sizeof(int32_t), 1, fp);
		fread(&fileCount, sizeof(int32_t), 1, fp);

		offset = SWAP32(offset);
		fileCount = SWAP32(fileCount);

		fileData = malloc(fileCount * sizeof(FileData));

		if (fileData == NULL)
		{
			showErrorAndExit("Failed to allocate %d bytes for FileData", fileCount * (int)sizeof(FileData));
		}

		fseek(fp, offset, SEEK_SET);

		fread(fileData, sizeof(FileData), fileCount, fp);

		printf("Loaded up PAK file with %d entries\n", fileCount);

		for (i=0;i<fileCount;i++)
		{
			fileData[i].offset = SWAP32(fileData[i].offset);
			fileData[i].compressedSize = SWAP32(fileData[i].compressedSize);
			fileData[i].fileSize = SWAP32(fileData[i].fileSize);
		}

		fclose(fp);
	#else
		pakFile[0] = '\0';
		fileCount = 0;
		fileData = NULL;
	#endif
}
Example #17
0
void psxHwReset() {
    if (Config.SioIrq) psxHu32ref(0x1070) |= SWAP32(0x80);
    if (Config.SpuIrq) psxHu32ref(0x1070) |= SWAP32(0x200);

    memset(psxH, 0, 0x10000);

    mdecInit(); // initialize mdec decoder
    cdrReset();
    psxRcntInit();
}
Example #18
0
int aifFile::ReadChunk() {
	if (fd == NULL)
		return -1;

	// Read the common header for all aif chunks
	aifHeader header;
	if (fcbs->read(&header, 1, sizeof(aifHeader), fd) != sizeof(aifHeader)) {
		fcbs->close(fd);
		fd = NULL;
		return -1;
	}

	switch (header.id) {
		case FORM_ID:
			int aifId;
			if (fcbs->read(&aifId, 1, sizeof(int), fd) != sizeof(int))
				return -1;

			// Check aifId signature for valid file
			if (aifId != AIFF_ID)
				return -1;
			break;

		case COMM_ID:
			commHeader comm;
			if (fcbs->read(&comm, 1, sizeof(commHeader), fd) != sizeof(commHeader))
				return -1;

			channels = SWAP16(comm.channels);
			samplesPerSec = (int)ConvertFromIeeeExtended(comm.sampleRate80);
			bitsPerSample = SWAP16(comm.sampleSize);
			status = 1;
			break;

		case SSND_ID:
			ssndHeader ssnd;
			if (fcbs->read(&ssnd, 1, sizeof(ssndHeader), fd) != sizeof(ssndHeader))
				return -1;

			if (ssnd.offset) {
				fcbs->seek(fd, SWAP32(ssnd.offset), SEEK_CUR);
			}

			chunkSize = SWAP32(header.size) - 8;
			totalSamples = chunkSize / (bitsPerSample/8);
			status = 2;
			break;

		default:
			fcbs->seek(fd, SWAP32(header.size), SEEK_CUR);
			break;
	}

	return 0;
}
Example #19
0
static void
swap_apple_blockzeroblock(struct apple_blockzeroblock *ap)
{
        SWAP32(bzbMagic);
        SWAP16(bzbBadBlockInode);
        SWAP16(bzbFlags);
        SWAP16(bzbReserved);
        SWAP32(bzbCreationTime);
        SWAP32(bzbMountTime);
        SWAP32(bzbUMountTime);
}
Example #20
0
void PACK_APIENTRY crPackEndListSWAP( void )
{
    GET_PACKER_CONTEXT(pc);
    unsigned char *data_ptr;
    (void) pc;
    GET_BUFFERED_POINTER( pc, 8 );
    WRITE_DATA( 0, GLint, SWAP32(8) );
    WRITE_DATA( 4, GLenum, SWAP32(CR_ENDLIST_EXTEND_OPCODE) );
    WRITE_OPCODE( pc, CR_EXTEND_OPCODE );
    pc->buffer.in_List = GL_FALSE;
}
static u32
INL(unsigned long addr)
{
	volatile io32_t *rp, val;

	rp = (volatile io32_t *) ADDR(addr);
	ENABLE32();
	val = *rp;
	DISABLE32();
	DBGIDE("%s(addr=%lx) = 0x%lx\n", __FUNCTION__, addr, SWAP32(val));
	return(SWAP32(val));
}
Example #22
0
void PACK_APIENTRY crPackCallListsSWAP(GLint n, GLenum type,
                                       const GLvoid *lists )
{
    unsigned char *data_ptr;
    int packet_length;
    GLshort *shortPtr;
    GLint   *intPtr;
    int i;

    int bytesPerList = __gl_CallListsNumBytes( type );
    int numBytes = bytesPerList * n;

    if (numBytes < 0)
    {
        __PackError( __LINE__, __FILE__, GL_INVALID_ENUM,
                     "crPackCallLists(bad type)" );
        return;
    }

    packet_length = sizeof( n ) +
                    sizeof( type ) +
                    numBytes;

    data_ptr = (unsigned char *) crPackAlloc( packet_length );
    WRITE_DATA( 0, GLint, SWAP32(n) );
    WRITE_DATA( 4, GLenum, SWAP32(type) );

    crMemcpy( data_ptr + 8, lists, numBytes );
    shortPtr = (GLshort *) (data_ptr + 8);
    intPtr   = (GLint *) (data_ptr + 8);

    if (bytesPerList > 1)
    {
        for ( i = 0 ; i < n ; i++)
        {
            switch( bytesPerList )
            {
            case 2:
                *shortPtr = SWAP16(*shortPtr);
                shortPtr+=1;
                break;
            case 4:
                *intPtr = SWAP32(*intPtr);
                intPtr+=1;
                break;
            }
        }
    }

    crHugePacket( CR_CALLLISTS_OPCODE, data_ptr );
    crPackFree( data_ptr );
}
Example #23
0
void PACK_APIENTRY crPackNewListSWAP( GLuint list, GLenum mode )
{
    GET_PACKER_CONTEXT(pc);
    unsigned char *data_ptr;
    (void) pc;
    GET_BUFFERED_POINTER( pc, 16 );
    WRITE_DATA( 0, GLint, SWAP32(16) );
    WRITE_DATA( 4, GLenum, SWAP32(CR_NEWLIST_EXTEND_OPCODE) );
    WRITE_DATA( 8, GLuint, SWAP32(list) );
    WRITE_DATA( 12, GLenum, SWAP32(mode) );
    WRITE_OPCODE( pc, CR_EXTEND_OPCODE );
    pc->buffer.in_List = GL_TRUE;
    pc->buffer.holds_List = GL_TRUE;
}
Example #24
0
INT
PAL_MKFGetChunkSize(
   UINT    uiChunkNum,
   FILE   *fp
)
/*++
  Purpose:

    Get the size of a chunk in an MKF archive.

  Parameters:

    [IN]  uiChunkNum - the number of the chunk in the MKF archive.

    [IN]  fp - pointer to the fopen'ed MKF file.

  Return value:

    Integer value which indicates the size of the chunk.
    -1 if the chunk does not exist.

--*/
{
   UINT    uiOffset       = 0;
   UINT    uiNextOffset   = 0;
   UINT    uiChunkCount   = 0;

   //
   // Get the total number of chunks.
   //
   uiChunkCount = PAL_MKFGetChunkCount(fp);
   if (uiChunkNum >= uiChunkCount)
   {
      return -1;
   }

   //
   // Get the offset of the specified chunk and the next chunk.
   //
   fseek(fp, 4 * uiChunkNum, SEEK_SET);
   fread(&uiOffset, sizeof(UINT), 1, fp);
   fread(&uiNextOffset, sizeof(UINT), 1, fp);
   uiOffset = SWAP32(uiOffset);
   uiNextOffset = SWAP32(uiNextOffset);

   //
   // Return the length of the chunk.
   //
   return uiNextOffset - uiOffset;
}
Example #25
0
void
__swap_segment_command(struct segment_command* segment)
{
	SWAP32(segment->cmd);
	SWAP32(segment->cmdsize);
	SWAP32(segment->vmaddr);
	SWAP32(segment->vmsize);
	SWAP32(segment->fileoff);
	SWAP32(segment->filesize);
	SWAP32(segment->maxprot);
	SWAP32(segment->initprot);
	SWAP32(segment->nsects);
	SWAP32(segment->flags);
}
Example #26
0
void PACK_APIENTRY crPackMap1fSWAP(GLenum target, GLfloat u1,
        GLfloat u2, GLint stride, GLint order, const GLfloat *points)
{
    unsigned char *data_ptr;
    int packet_length = 
        sizeof(target) + 
        sizeof(u1) +
        sizeof(u2) + 
        sizeof(stride) + 
        sizeof(order);

    int num_components = __gl_Map1NumComponents(target);
    GLfloat *src_data, *dest_data;
    int u;
    int comp;

    if (num_components < 0)
    {
        __PackError(__LINE__, __FILE__, GL_INVALID_ENUM,
                                 "crPackMap1f(bad target)");
        return;
    }

    packet_length += num_components * order * sizeof(*points);

    data_ptr = (unsigned char *) crPackAlloc(packet_length);

    WRITE_DATA(0, GLenum, SWAP32(target));
    WRITE_DATA(4, GLuint, SWAPFLOAT(u1));
    WRITE_DATA(8, GLuint, SWAPFLOAT(u2));
    WRITE_DATA(12, GLint, SWAP32(num_components));
    WRITE_DATA(16, GLint, SWAP32(order));

    dest_data = (GLfloat *) (data_ptr + 20);
    src_data = (GLfloat *) points;
    for (u = 0 ; u < order ; u++)
    {
        for (comp = 0 ; comp < num_components ; comp++)
        {
            WRITE_DATA((unsigned char *) dest_data + comp*sizeof(*points) - data_ptr, GLuint, SWAPFLOAT(*(src_data + comp)));
        }
        dest_data += num_components;
        src_data += stride;
    }

    crHugePacket(CR_MAP1F_OPCODE, data_ptr);
    crPackFree(data_ptr);
}
Example #27
0
INT
PAL_MKFGetChunkCount(
   FILE *fp
)
/*++
  Purpose:

    Get the number of chunks in an MKF archive.

  Parameters:

    [IN]  fp - pointer to an fopen'ed MKF file.

  Return value:

    Integer value which indicates the number of chunks in the specified MKF file.

--*/
{
   INT iNumChunk;
   if (fp == NULL)
   {
      return 0;
   }

   fseek(fp, 0, SEEK_SET);
   fread(&iNumChunk, sizeof(INT), 1, fp);

   iNumChunk = (SWAP32(iNumChunk) - 4) / 4;
   return iNumChunk;
}
Example #28
0
void PACK_APIENTRY
crPackDeleteBuffersARBSWAP(GLsizei n, const GLuint * buffers)
{
	unsigned char *data_ptr;
	int packet_length = sizeof(GLenum) + sizeof(n) + n * sizeof(*buffers);

	if (!buffers)
		return;

	data_ptr = (unsigned char *) crPackAlloc(packet_length);
	WRITE_DATA( 0, GLenum, SWAP32(CR_DELETEBUFFERSARB_EXTEND_OPCODE) );
	WRITE_DATA( 4, GLsizei, SWAP32(n) );
	crMemcpy( data_ptr + 8, buffers, n * sizeof(*buffers) );
	crHugePacket( CR_EXTEND_OPCODE, data_ptr );
    crPackFree( data_ptr );
}
/* misc wite - not increase address */
I32S Tcc353xMiscWriteEx(I32S _moduleIndex, I32S _diversityIndex,
		      I08U _miscConfig, I08U *_startAddress, 
		      I32U *_data, I32U _size)
{
	Tcc353xHandle_t *h;
	I32U i;
	I32U temp;
	
	if (Tcc353xHandle[_moduleIndex][_diversityIndex].handleOpen == 0)
		return TCC353X_RETURN_FAIL_INVALID_HANDLE;

	h = &Tcc353xHandle[_moduleIndex][_diversityIndex];

	TcpalSemaphoreLock(&Tcc353xInterfaceSema);

	Tcc353xSetRegMiscConfig(h, _miscConfig | 1, _UNLOCK_);

	for (i = 0; i< _size; i++)	{
		Tcc353xSetRegMiscAddress(h, _startAddress[i], _UNLOCK_);
		temp = _data[i];
		temp = SWAP32(temp);
		Tcc353xSetRegMiscData(h, (I08U *) (&temp), _UNLOCK_);
		Tcc353xSetRegMiscAction(h, TC3XREG_MISC_ACTION, _UNLOCK_);
	}
	/* warning : please reset to opcontrol miscconfig0 */
	Tcc353xSetRegMiscConfig(h, 0, _UNLOCK_);

	TcpalSemaphoreUnLock(&Tcc353xInterfaceSema);
	return TCC353X_RETURN_SUCCESS;
}
Example #30
0
static GLint packspu_GetUniformLocationUncached(GLuint program, const char * name)
{
    GET_THREAD(thread);
    int writeback = 1;
    GLint return_val = (GLint) 0;
    if (!CRPACKSPU_IS_WDDM_CRHGSMI() && !(pack_spu.thread[pack_spu.idxThreadInUse].netServer.conn->actual_network))
    {
        crError("packspu_GetUniformLocation doesn't work when there's no actual network involved!\nTry using the simplequery SPU in your chain!");
    }
    if (pack_spu.swap)
    {
        crPackGetUniformLocationSWAP(program, name, &return_val, &writeback);
    }
    else
    {
        crPackGetUniformLocation(program, name, &return_val, &writeback);
    }
    packspuFlush((void *) thread);
    CRPACKSPU_WRITEBACK_WAIT(thread, writeback);
    if (pack_spu.swap)
    {
        return_val = (GLint) SWAP32(return_val);
    }
    return return_val;
}