Exemple #1
0
MicrocodeInfo *GBI_DetectMicrocode( u32 uc_start, u32 uc_dstart, u16 uc_dsize )
{
    MicrocodeInfo *current;

    for (unsigned int i = 0; i < GBI.numMicrocodes; i++)
    {
        current = GBI.top;

        while (current)
        {
            if ((current->address == uc_start) && (current->dataAddress == uc_dstart) && (current->dataSize == uc_dsize))
                return current;

            current = current->lower;
        }
    }

    current = GBI_AddMicrocode();

    current->address = uc_start;
    current->dataAddress = uc_dstart;
    current->dataSize = uc_dsize;
    current->NoN = FALSE;
    current->type = NONE;

    // See if we can identify it by CRC
    uc_crc = CRC_Calculate( 0xFFFFFFFF, &RDRAM[uc_start & 0x1FFFFFFF], 4096);
    LOG(LOG_MINIMAL, "UCODE CRC=0x%x\n", uc_crc);

    for (u32 i = 0; i < sizeof( specialMicrocodes ) / sizeof( SpecialMicrocodeInfo ); i++)
    {
        if (uc_crc == specialMicrocodes[i].crc)
        {
            current->type = specialMicrocodes[i].type;
            return current;
        }
    }

    // See if we can identify it by text
    char uc_data[2048];
    UnswapCopy( &RDRAM[uc_dstart & 0x1FFFFFFF], uc_data, 2048 );
    strcpy( uc_str, "Not Found" );

    for (u32 i = 0; i < 2048; i++)
    {
        if ((uc_data[i] == 'R') && (uc_data[i+1] == 'S') && (uc_data[i+2] == 'P'))
        {
            u32 j = 0;
            while (uc_data[i+j] > 0x0A)
            {
                uc_str[j] = uc_data[i+j];
                j++;
            }

            uc_str[j] = 0x00;

            int type = NONE;

            if (strncmp( &uc_str[4], "SW", 2 ) == 0)
            {
                type = F3D;
            }
            else if (strncmp( &uc_str[4], "Gfx", 3 ) == 0)
            {
                current->NoN = (strncmp( &uc_str[20], ".NoN", 4 ) == 0);

                if (strncmp( &uc_str[14], "F3D", 3 ) == 0)
                {
                    if (uc_str[28] == '1')
                        type = F3DEX;
                    else if (uc_str[31] == '2')
                        type = F3DEX2;
                }
                else if (strncmp( &uc_str[14], "L3D", 3 ) == 0)
                {
                    if (uc_str[28] == '1')
                        type = L3DEX;
                    else if (uc_str[31] == '2')
                        type = L3DEX2;
                }
                else if (strncmp( &uc_str[14], "S2D", 3 ) == 0)
                {
                    if (uc_str[28] == '1')
                        type = S2DEX;
                    else if (uc_str[31] == '2')
                        type = S2DEX2;
                }
            }

            LOG(LOG_VERBOSE, "UCODE STRING=%s\n", uc_str);

            if (type != NONE)
            {
                current->type = type;
                return current;
            }

            break;
        }
    }


    for (u32 i = 0; i < sizeof( specialMicrocodes ) / sizeof( SpecialMicrocodeInfo ); i++)
    {
        if (strcmp( uc_str, specialMicrocodes[i].text ) == 0)
        {
            current->type = specialMicrocodes[i].type;
            return current;
        }
    }

    // Let the user choose the microcode
    LOG(LOG_ERROR, "[gles2n64]: Warning - unknown ucode!!!\n");
    if(last_good_ucode != (u32)-1)
    {
        current->type=last_good_ucode;
    }
    else
    {
        current->type = MicrocodeDialog();
    }
    return current;
}
Exemple #2
0
MicrocodeInfo *GBI_DetectMicrocode( u32 uc_start, u32 uc_dstart, u16 uc_dsize )
{
	MicrocodeInfo *current;

	for (unsigned int i = 0; i < GBI.numMicrocodes; i++)
	{
		current = GBI.top;

		while (current)
		{
			if ((current->address == uc_start) && (current->dataAddress == uc_dstart) && (current->dataSize == uc_dsize))
				return current;

			current = current->lower;
		}
	}

	current = GBI_AddMicrocode();

	current->address = uc_start;
	current->dataAddress = uc_dstart;
	current->dataSize = uc_dsize;
	current->NoN = FALSE;
	current->type = NONE;

	// See if we can identify it by CRC
	uc_crc = CRC_Calculate( 0xFFFFFFFF, &RDRAM[uc_start & 0x1FFFFFFF], 4096 );
#if 0 //def __GX__
	sprintf(txtbuffer,"GBI:uc_crc: %x", uc_crc);
	DEBUG_print(txtbuffer,3); 
#endif // __GX__
	for (u32 i = 0; i < sizeof( specialMicrocodes ) / sizeof( SpecialMicrocodeInfo ); i++)
	{
		if (uc_crc == specialMicrocodes[i].crc)
		{
			current->type = specialMicrocodes[i].type;
			return current;
		}
	}

	// See if we can identify it by text
	char uc_data[2048];
#ifndef _BIG_ENDIAN
	UnswapCopy( &RDRAM[uc_dstart & 0x1FFFFFFF], uc_data, 2048 );
#else // !_BIG_ENDIAN
	memcpy( uc_data, &RDRAM[uc_dstart & 0x1FFFFFFF], 2048 );
#endif
	strcpy( uc_str, "Not Found" );

	for (u32 i = 0; i < 2048; i++)
	{
		if ((uc_data[i] == 'R') && (uc_data[i+1] == 'S') && (uc_data[i+2] == 'P'))
		{
			u32 j = 0;
			while (uc_data[i+j] > 0x0A)
			{
				uc_str[j] = uc_data[i+j];
				j++;
			}

			uc_str[j] = 0x00;

#if 0 //def __GX__
			sprintf(txtbuffer,"GBI:uc_str(i=%i): %s", i, uc_str);
			DEBUG_print(txtbuffer,4);
#endif // __GX__

			int type = NONE;

			if (strncmp( &uc_str[4], "SW", 2 ) == 0)
			{
				type = F3D;
			}
			else if (strncmp( &uc_str[4], "Gfx", 3 ) == 0)
			{
				current->NoN = (strncmp( &uc_str[20], ".NoN", 4 ) == 0);

				if (strncmp( &uc_str[14], "F3D", 3 ) == 0)
				{
					if (uc_str[28] == '1')
						type = F3DEX;
					else if (uc_str[31] == '2')
						type = F3DEX2;
				}
				else if (strncmp( &uc_str[14], "L3D", 3 ) == 0)
				{
					if (uc_str[28] == '1')
						type = L3DEX;
					else if (uc_str[31] == '2')
						type = L3DEX2;
				}
				else if (strncmp( &uc_str[14], "S2D", 3 ) == 0)
				{
					if (uc_str[28] == '1')
						type = S2DEX;
					else if (uc_str[31] == '2')
						type = S2DEX2;
				}
			}

			if (type != NONE)
			{
				current->type = type;
				return current;
			}

			break;
		}
	}

	for (u32 i = 0; i < sizeof( specialMicrocodes ) / sizeof( SpecialMicrocodeInfo ); i++)
	{
		if (strcmp( uc_str, specialMicrocodes[i].text ) == 0)
		{
			current->type = specialMicrocodes[i].type;
			return current;
		}
	}

	// Let the user choose the microcode
#ifndef __LINUX__
	current->type = DialogBox( hInstance, MAKEINTRESOURCE( IDD_MICROCODEDLG ), hWnd, MicrocodeDlgProc );
#else // !__LINUX__
	printf( "glN64: Warning - unknown ucode!!!\n" );
# ifndef __GX__
	//TODO: Make sure having ucode = NONE is ok
	current->type = MicrocodeDialog();
# endif // !__GX__
#endif // __LINUX__
	return current;
}
Exemple #3
0
void GBIInfo::loadMicrocode(u32 uc_start, u32 uc_dstart, u16 uc_dsize)
{
	for (Microcodes::iterator iter = m_list.begin(); iter != m_list.end(); ++iter) {
		if (iter->address == uc_start && iter->dataAddress == uc_dstart && iter->dataSize == uc_dsize) {
			_makeCurrent(&(*iter));
			return;
		}
	}

	m_list.emplace_front();
	MicrocodeInfo & current = m_list.front();
	current.address = uc_start;
	current.dataAddress = uc_dstart;
	current.dataSize = uc_dsize;
	current.NoN = false;
	current.textureGen = true;
	current.branchLessZ = true;
	current.type = NONE;

	// See if we can identify it by CRC
	const u32 uc_crc = CRC_Calculate( 0xFFFFFFFF, &RDRAM[uc_start & 0x1FFFFFFF], 4096 );
	const u32 numSpecialMicrocodes = sizeof(specialMicrocodes) / sizeof(SpecialMicrocodeInfo);
	for (u32 i = 0; i < numSpecialMicrocodes; ++i) {
		if (uc_crc == specialMicrocodes[i].crc) {
			current.type = specialMicrocodes[i].type;
			current.NoN = specialMicrocodes[i].NoN;
			_makeCurrent(&current);
			return;
		}
	}

	// See if we can identify it by text
	char uc_data[2048];
	UnswapCopyWrap(RDRAM, uc_dstart & 0x1FFFFFFF, (u8*)uc_data, 0, 0x7FF, 2048);
	char uc_str[256];
	strcpy(uc_str, "Not Found");

	for (u32 i = 0; i < 2048; ++i) {
		if ((uc_data[i] == 'R') && (uc_data[i+1] == 'S') && (uc_data[i+2] == 'P')) {
			u32 j = 0;
			while (uc_data[i+j] > 0x0A) {
				uc_str[j] = uc_data[i+j];
				j++;
			}

			uc_str[j] = 0x00;

			int type = NONE;

			if (strncmp( &uc_str[4], "SW", 2 ) == 0)
				type = F3D;
			else if (strncmp( &uc_str[4], "Gfx", 3 ) == 0) {
				current.NoN = (strstr( uc_str + 4, ".NoN") != NULL);

				if (strncmp( &uc_str[14], "F3D", 3 ) == 0) {
					if (uc_str[28] == '1' || strncmp(&uc_str[28], "0.95", 4) == 0 || strncmp(&uc_str[28], "0.96", 4) == 0)
						type = F3DEX;
					else if (uc_str[31] == '2')
						type = F3DEX2;
					if (strncmp(&uc_str[14], "F3DF", 4) == 0)
						current.textureGen = false;
					else if (strncmp(&uc_str[14], "F3DZ", 4) == 0)
						current.branchLessZ = false;
				}
				else if (strncmp( &uc_str[14], "L3D", 3 ) == 0) {
					u32 t = 22;
					while (!_isDigit(uc_str[t]) && t++ < j);
					if (uc_str[t] == '1')
						type = L3DEX;
					else if (uc_str[t] == '2')
						type = L3DEX2;
				}
				else if (strncmp( &uc_str[14], "S2D", 3 ) == 0) {
					u32 t = 20;
					while (!_isDigit(uc_str[t]) && t++ < j);
					if (uc_str[t] == '1')
						type = S2DEX;
					else if (uc_str[t] == '2')
						type = S2DEX2;
				}
				else if (strncmp(&uc_str[14], "ZSortp", 6) == 0) {
					type = ZSortp;
				}
			}

			if (type != NONE) {
				current.type = type;
				_makeCurrent(&current);
				return;
			}

			break;
		}
	}

	assert(false && "unknown ucode!!!'n");
	_makeCurrent(&current);
}