dolphin/Source/Plugins/Plugin_VideoDX9/Src/VertexLoader_TextCoord.h

202 lines
6.5 KiB
C

// Copyright (C) 2003-2008 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#ifndef VERTEXHANDLER_TEXCOORD_H
#define VERTEXHANDLER_TEXCOORD_H
extern int tcIndex;
void LOADERDECL TexCoord_ReadDirect_UByte(void* _p)
{
varray->SetU(tcIndex, ReadBuffer8() * tcScaleU[tcIndex]);
if (tcElements[tcIndex])
varray->SetV(tcIndex, ReadBuffer8() * tcScaleV[tcIndex]);
tcIndex++;
}
void LOADERDECL TexCoord_ReadDirect_Byte(void* _p)
{
varray->SetU(tcIndex, (s8)ReadBuffer8() * tcScaleU[tcIndex]);
if (tcElements[tcIndex])
varray->SetV(tcIndex, (s8)ReadBuffer8() * tcScaleV[tcIndex]);
tcIndex++;
}
void LOADERDECL TexCoord_ReadDirect_UShort(void* _p)
{
varray->SetU(tcIndex, ReadBuffer16() * tcScaleU[tcIndex]);
if (tcElements[tcIndex])
varray->SetV(tcIndex, ReadBuffer16() * tcScaleV[tcIndex]);
tcIndex++;
}
void LOADERDECL TexCoord_ReadDirect_Short(void* _p)
{
varray->SetU(tcIndex, (s16)ReadBuffer16() * tcScaleU[tcIndex]);
if (tcElements[tcIndex])
varray->SetV(tcIndex, (s16)ReadBuffer16() * tcScaleV[tcIndex]);
tcIndex++;
}
void LOADERDECL TexCoord_ReadDirect_Float(void* _p)
{
varray->SetU(tcIndex, ReadBuffer32F() * tcScaleU[tcIndex]);
if (tcElements[tcIndex])
varray->SetV(tcIndex, ReadBuffer32F() * tcScaleV[tcIndex]);
tcIndex++;
}
// ==================================================================================
void LOADERDECL TexCoord_ReadIndex8_UByte(void* _p)
{
u8 Index = ReadBuffer8();
u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
varray->SetU(tcIndex, (float)(u8)Memory_Read_U8(iAddress) * tcScaleU[tcIndex]);
if (tcElements[tcIndex])
varray->SetV(tcIndex, (float)(u8)Memory_Read_U8(iAddress+1) * tcScaleV[tcIndex]);
tcIndex++;
}
void LOADERDECL TexCoord_ReadIndex8_Byte(void* _p)
{
u8 Index = ReadBuffer8();
u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
varray->SetU(tcIndex, (float)(s8)Memory_Read_U8(iAddress) * tcScaleU[tcIndex]);
if (tcElements[tcIndex])
varray->SetV(tcIndex, (float)(s8)Memory_Read_U8(iAddress+1) * tcScaleV[tcIndex]);
tcIndex++;
}
void LOADERDECL TexCoord_ReadIndex8_UShort(void* _p)
{
u8 Index = ReadBuffer8();
u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
varray->SetU(tcIndex, (float)(u16)Memory_Read_U16(iAddress) * tcScaleU[tcIndex]);
if (tcElements[tcIndex])
varray->SetV(tcIndex, (float)(u16)Memory_Read_U16(iAddress+2) * tcScaleV[tcIndex]);
tcIndex++;
}
void LOADERDECL TexCoord_ReadIndex8_Short(void* _p)
{
u8 Index = ReadBuffer8();
u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
varray->SetU(tcIndex, (float)(s16)Memory_Read_U16(iAddress) * tcScaleU[tcIndex]);
if (tcElements[tcIndex])
varray->SetV(tcIndex, (float)(s16)Memory_Read_U16(iAddress+2) * tcScaleV[tcIndex]);
tcIndex++;
}
void LOADERDECL TexCoord_ReadIndex8_Float(void* _p)
{
u16 Index = ReadBuffer8();
u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
u32 uTemp;
uTemp = Memory_Read_U32(iAddress );
varray->SetU(tcIndex, *(float*)&uTemp * tcScaleU[tcIndex]);
if (tcElements[tcIndex])
{
uTemp = Memory_Read_U32(iAddress+4);
varray->SetV(tcIndex, *(float*)&uTemp * tcScaleV[tcIndex]);
}
tcIndex++;
}
// ==================================================================================
void LOADERDECL TexCoord_ReadIndex16_UByte(void* _p)
{
u16 Index = ReadBuffer16();
u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
u32 uTemp;
uTemp = (u8)Memory_Read_U8(iAddress );
varray->SetU(tcIndex, float(uTemp)* tcScaleU[tcIndex]);
if (tcElements[tcIndex])
{
uTemp = (u8)Memory_Read_U8(iAddress+1);
varray->SetV(tcIndex, float(uTemp)* tcScaleV[tcIndex]);
}
tcIndex++;
}
void LOADERDECL TexCoord_ReadIndex16_Byte(void* _p)
{
u16 Index = ReadBuffer16();
u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
u32 uTemp;
uTemp = (s8)Memory_Read_U8(iAddress );
varray->SetU(tcIndex, float(uTemp)* tcScaleU[tcIndex]);
if (tcElements[tcIndex])
{
uTemp = (s8)Memory_Read_U8(iAddress+1);
varray->SetV(tcIndex, float(uTemp)* tcScaleV[tcIndex]);
}
tcIndex++;
}
void LOADERDECL TexCoord_ReadIndex16_UShort(void* _p)
{
TVtxAttr* pVtxAttr = (TVtxAttr*)_p;
u16 Index = ReadBuffer16();
u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
float uTemp;
uTemp = (float)(u16)Memory_Read_U16(iAddress );
varray->SetU(tcIndex, uTemp * tcScaleU[tcIndex]);
if (tcElements[tcIndex])
{
uTemp = (float)(u16)Memory_Read_U16(iAddress+2);
varray->SetV(tcIndex, uTemp * tcScaleV[tcIndex]);
}
tcIndex++;
}
void LOADERDECL TexCoord_ReadIndex16_Short(void* _p)
{
u16 Index = ReadBuffer16();
u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
float uTemp;
uTemp = (float)(s16)Memory_Read_U16(iAddress );
varray->SetU(tcIndex, uTemp * tcScaleU[tcIndex]);
if (tcElements[tcIndex])
{
uTemp = (float)(s16)Memory_Read_U16(iAddress+2);
varray->SetV(tcIndex, uTemp * tcScaleV[tcIndex]);
}
tcIndex++;
}
void LOADERDECL TexCoord_ReadIndex16_Float(void* _p)
{
u16 Index = ReadBuffer16();
u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
u32 uTemp;
uTemp = Memory_Read_U32(iAddress );
varray->SetU(tcIndex, *(float*)&uTemp * tcScaleU[tcIndex]);
if (tcElements[tcIndex])
{
uTemp = Memory_Read_U32(iAddress+4);
varray->SetV(tcIndex, *(float*)&uTemp * tcScaleV[tcIndex]);
}
tcIndex++;
}
#endif