void CGUIEnvironment::loadBuidInFont()
{
	const c8* filename = "#DefaultFont";

#ifdef PPC
	for (int i=0; i<sizeof(BuildInFontData)/sizeof(s32); i++) BuildInFontData[i] = OSReadSwapInt32(&BuildInFontData[i],0);
#endif

	io::IReadFile* file = io::createMemoryReadFile(BuildInFontData, BuildInFontDataSize, filename, false);

	CGUIFont* font = new CGUIFont(Driver);
	if (!font->load(file))
	{
		os::Printer::log("Error: Could not load built-in Font.", ELL_ERROR);
		font->drop();
		file->drop();
		return;
	}

	SFont f;
	f.Filename = filename;
	f.Font = font;
	Fonts.push_back(f);

	file->drop();
}
Beispiel #2
0
int Load3ds::ReadChunk(Chunk * aChunk)
{
	aChunk->mBytesRead = fread(&aChunk->mID, 1, 2, mFile);
	aChunk->mBytesRead += fread(&aChunk->mLength, 1, 4, mFile);
#ifdef __BIG_ENDIAN__
	aChunk->mID = OSReadSwapInt16(&aChunk->mID,0);
	aChunk->mLength = OSReadSwapInt32(&aChunk->mLength,0);
#endif
	
	return 1;
}
Beispiel #3
0
int Load3ds::FillVertexBuffer(Chunk * aPreviousChunk)
{
	size_t numberOfBytesRead;
	
	aPreviousChunk->mBytesRead += numberOfBytesRead = fread(&mModelData->mVertexCount, 1, 2, mFile);
#ifdef __BIG_ENDIAN__
	mModelData->mVertexCount = OSReadSwapInt16(&mModelData->mVertexCount,0);
#endif	

	
//	size = aPreviousChunk->mLength - aPreviousChunk->mBytesRead;
//	aPreviousChunk->mBytesRead += size = fread(mBuffer, 1,aPreviousChunk->mLength - aPreviousChunk->mBytesRead, mFile);
//#ifdef __BIG_ENDIAN__
//	for (int i = 0; i < size ;i++)
//		{
//		static_cast<short *>(mBuffer)[i] = OSReadSwapInt16(&static_cast<short*>(mBuffer)[i],0);
//		}
//#endif	
	// allocate space for the vertices in the temporary object, and read that information
	mModelData->mVertices = static_cast<float*>( malloc( aPreviousChunk->mLength - aPreviousChunk->mBytesRead ) );

	// read the information into the object
	aPreviousChunk->mBytesRead += numberOfBytesRead = fread(mModelData->mVertices, 1, aPreviousChunk->mLength - aPreviousChunk->mBytesRead, mFile);
#ifdef __BIG_ENDIAN__
	for (int i=0;i<mModelData->mVertexCount * 3;i++)
	{
		*((long*)&mModelData->mVertices[i]) = OSReadSwapInt32(&mModelData->mVertices[i],0);
	}
#endif
	
	// mModelData->mVertices now contains a list of vertex coordinates (3 floats)

#ifdef GRAPHICS_DEBUG
	// the * 3 is temporary
	FILE* file = NULL;
	file = fopen("vertices.out", "w+");
	assert( file );
	for (int i = 0; i < mModelData->mVertexCount * 3; i+=3)
	{
		fprintf(file, "%d: X: %f, Y: %f, Z: %f\n", i/3, mModelData->mVertices[i], mModelData->mVertices[i+1], 
			mModelData->mVertices[i+2]);
		//printf("X: %f, Y: %f, Z: %f\n", mModelData->mVertices[i], mModelData->mVertices[i+1], 
		//	mModelData->mVertices[i+2]);
	}
	fclose( file );
#endif
	return 1;
}
Beispiel #4
0
int Load3ds::FillTexCoordBuffer(Chunk * aPreviousChunk)
{
	size_t numberOfBytesRead;
	unsigned short lNumTexCoords;

	aPreviousChunk->mBytesRead += numberOfBytesRead = fread(&lNumTexCoords, 1, 2, mFile);
#ifdef __BIG_ENDIAN__
	lNumTexCoords = OSReadSwapInt16(&lNumTexCoords,0);
#endif	
	
//	aPreviousChunk->mBytesRead += size = fread(mBuffer, 1, aPreviousChunk->mLength - aPreviousChunk->mBytesRead, mFile);
//#ifdef __BIG_ENDIAN__
//	for (int i = 0; i < size ;i++)
//		{
//		static_cast<short *>(mBuffer)[i] = OSReadSwapInt16(&static_cast<short*>(mBuffer)[i],0);
//		}
//#endif		

	// allocate space for the vertices in the temporary object, and read that information
	mModelData->mTexCoords = static_cast<float*>( malloc( aPreviousChunk->mLength - aPreviousChunk->mBytesRead ) );

	// read the information into the object
	aPreviousChunk->mBytesRead += numberOfBytesRead = fread(mModelData->mTexCoords, 1, aPreviousChunk->mLength - aPreviousChunk->mBytesRead, mFile);
#ifdef __BIG_ENDIAN__
	for (int i=0;i<lNumTexCoords*2;i++)
	{
		*((long*)&mModelData->mTexCoords[i]) = OSReadSwapInt32(&mModelData->mTexCoords[i],0);
	}
#endif
	
	mModelData->mContainsTexCoords = true;

	// mBuffer now contains a list of UV coordinates (2 floats)

	return 1;
}
Beispiel #5
0
bool AppleMacIO::selfTest( void )
{
    IODBDMADescriptor			*dmaDescriptors;
    UInt32				dmaDescriptorsPhys;
    UInt32				i;
    UInt32				status;
    IODBDMADescriptor			*dmaDesc;
    IOBufferMemoryDescriptor		*buffer;
    volatile IODBDMAChannelRegisters	*ioBaseDMA;
    bool				ok = false;
    enum { 				kTestChannel = 0x8000 };

    ioBaseDMA = (volatile IODBDMAChannelRegisters *)
		(((UInt32)fMemory->getVirtualAddress())
		+ kTestChannel );

    do {
	buffer = IOBufferMemoryDescriptor::withCapacity(page_size, kIODirectionOutIn, true);
	dmaDescriptors = (IODBDMADescriptor*)buffer->getBytesNoCopy();

        if (!dmaDescriptors)
	    continue;

        if ( (UInt32)dmaDescriptors & (page_size - 1) ) {
            IOLog("AppleMacIO::%s() - DMA Descriptor memory not page aligned!!", __FUNCTION__);
	    continue;
        }

        bzero( dmaDescriptors, page_size );

        IODBDMAReset( ioBaseDMA );

        dmaDesc = dmaDescriptors;

        IOMakeDBDMADescriptor( dmaDesc,
                            kdbdmaNop,
                            kdbdmaKeyStream0,
                            kdbdmaIntNever,
                            kdbdmaBranchNever,
                            kdbdmaWaitNever,
                            0,
                            0 );

        dmaDesc++;

	dmaDescriptorsPhys = (UInt32) (buffer->getPhysicalSegment(0, NULL, 0));

        IOMakeDBDMADescriptorDep( dmaDesc,
                                kdbdmaStoreQuad,
                                kdbdmaKeySystem,
                                kdbdmaIntNever,
                                kdbdmaBranchNever,
                                kdbdmaWaitNever,
                                4,
                                dmaDescriptorsPhys+16*sizeof(IODBDMADescriptor),
                                0x12345678 );

        dmaDesc++;

        IOMakeDBDMADescriptor( dmaDesc,
                            kdbdmaStop,
                            kdbdmaKeyStream0,
                            kdbdmaIntNever,
                            kdbdmaBranchNever,
                            kdbdmaWaitNever,
                            0,
                            0 );


        for ( i = 0; (!ok) && (i < 3); i++ )
        {
            dmaDescriptors[16].operation = 0;

            IOSetDBDMACommandPtr( ioBaseDMA, dmaDescriptorsPhys );
            IODBDMAContinue( ioBaseDMA );

            IODelay( 200 );

            status = IOGetDBDMAChannelStatus( ioBaseDMA );

            if ( ((status & kdbdmaActive) == 0)
                &&  ((status & kdbdmaDead) == 0)
                    && (OSReadSwapInt32( &dmaDescriptors[16].operation, 0 ) == 0x12345678 ))
                ok = true;
        }

        IODBDMAReset( ioBaseDMA );

    } while (false);

    if (buffer)
	    buffer->release();

    return ok;
}