DataReader inline for OGL/DX9 and moved to VideoCommon. Large clean up.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@760 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
memberTwo.mb2
2008-10-03 22:05:28 +00:00
parent 8997f9cb3e
commit 8d0f6d40f4
20 changed files with 284 additions and 931 deletions

View File

@ -1,91 +0,0 @@
// 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/
#include <stdlib.h>
#include "Utils.h"
#include "Common.h"
#include "main.h"
#include "DataReader.h"
// =================================================================================================
// CDataReader_Fifo
// =================================================================================================
IDataReader* g_pDataReader = NULL;
extern u8 FAKE_ReadFifo8();
extern u16 FAKE_ReadFifo16();
extern u32 FAKE_ReadFifo32();
CDataReader_Fifo::CDataReader_Fifo(void)
{
m_szName = "CDataReader_Fifo";
}
u8 CDataReader_Fifo::Read8(void)
{
return FAKE_ReadFifo8();
};
u16 CDataReader_Fifo::Read16(void)
{
return FAKE_ReadFifo16();
};
u32 CDataReader_Fifo::Read32(void)
{
return FAKE_ReadFifo32();
};
// =================================================================================================
// CDataReader_Memory
// =================================================================================================
CDataReader_Memory::CDataReader_Memory(u32 _uAddress) :
m_uReadAddress(_uAddress)
{
// F|RES: this wont work anymore caused by Mem2
// m_pMemory = g_VideoInitialize.pGetMemoryPointer(0x00);
m_szName = "CDataReader_Memory";
}
u32 CDataReader_Memory::GetReadAddress(void)
{
return m_uReadAddress;
}
u8 CDataReader_Memory::Read8(void)
{
u8 tmp = Memory_Read_U8(m_uReadAddress); //m_pMemory[m_uReadAddress];
m_uReadAddress++;
return tmp;
}
u16 CDataReader_Memory::Read16(void)
{
u16 tmp = Memory_Read_U16(m_uReadAddress); //_byteswap_ushort(*(u16*)&m_pMemory[m_uReadAddress]);
m_uReadAddress += 2;
return tmp;
}
u32 CDataReader_Memory::Read32(void)
{
u32 tmp =Memory_Read_U32(m_uReadAddress); // _byteswap_ulong(*(u32*)&m_pMemory[m_uReadAddress]);
m_uReadAddress += 4;
return tmp;
}

View File

@ -1,76 +0,0 @@
// 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 _DATAREADER_H
#define _DATAREADER_H
// =================================================================================================
// IDataReader
// =================================================================================================
class IDataReader
{
protected:
const char *m_szName;
public:
virtual u8 Read8 (void) = NULL;
virtual u16 Read16(void) = NULL;
virtual u32 Read32(void) = NULL;
};
// =================================================================================================
// CDataReader_Fifo
// =================================================================================================
class CDataReader_Fifo : public IDataReader
{
private:
public:
CDataReader_Fifo(void);
virtual u8 Read8(void);
virtual u16 Read16(void);
virtual u32 Read32(void);
};
// =================================================================================================
// CDataReader_Memory
// =================================================================================================
class CDataReader_Memory : public IDataReader
{
private:
// u8* m_pMemory;
u32 m_uReadAddress;
public:
CDataReader_Memory(u32 _uAddress);
u32 GetReadAddress(void);
virtual u8 Read8(void);
virtual u16 Read16(void);
virtual u32 Read32(void);
};
extern IDataReader* g_pDataReader;
#endif

View File

@ -46,20 +46,15 @@
#include "DLCompiler.h"
#define CMDBUFFER_SIZE 1024*1024
DecodedVArray tempvarray;
// TODO (mb2): all! DataReader inline for DX9
#ifdef DATAREADER_INLINE
u8 *g_pVideoData = 0;
#endif
extern u8* FAKE_GetFifoStartPtr();
extern u8* FAKE_GetFifoEndPtr();
void Decode();
extern u8 FAKE_PeekFifo8(u32 _uOffset);
extern u16 FAKE_PeekFifo16(u32 _uOffset);
extern u32 FAKE_PeekFifo32(u32 _uOffset);
extern int FAKE_GetFifoSize();
CDataReader_Fifo g_fifoReader;
template <class T>
void Xchg(T& a, T&b)
{
@ -70,11 +65,10 @@ void Xchg(T& a, T&b)
void ExecuteDisplayList(u32 address, u32 size)
{
IDataReader* pOldReader = g_pDataReader;
u8* old_pVideoData = g_pVideoData;
// address &= 0x01FFFFFF; // phys address
CDataReader_Memory memoryReader(address);
g_pDataReader = &memoryReader;
u8* startAddress = Memory_GetPtr(address);
g_pVideoData = startAddress;
// temporarily swap dl and non-dl(small "hack" for the stats)
Xchg(stats.thisFrame.numDLPrims, stats.thisFrame.numPrims);
@ -82,10 +76,10 @@ void ExecuteDisplayList(u32 address, u32 size)
Xchg(stats.thisFrame.numCPLoadsInDL, stats.thisFrame.numCPLoads);
Xchg(stats.thisFrame.numBPLoadsInDL, stats.thisFrame.numBPLoads);
while((memoryReader.GetReadAddress() - address) < size)
{
Decode();
}
while((u32)(g_pVideoData - startAddress) < size)
{
Decode();
}
INCSTAT(stats.numDListsCalled);
INCSTAT(stats.thisFrame.numDListsCalled);
@ -95,33 +89,17 @@ void ExecuteDisplayList(u32 address, u32 size)
Xchg(stats.thisFrame.numCPLoadsInDL, stats.thisFrame.numCPLoads);
Xchg(stats.thisFrame.numBPLoadsInDL, stats.thisFrame.numBPLoads);
// reset to the old reader
g_pDataReader = pOldReader;
// reset to the old pointer
g_pVideoData = old_pVideoData;
}
inline u8 PeekFifo8(u32 _uOffset)
{
return FAKE_PeekFifo8(_uOffset);
}
inline u16 PeekFifo16(u32 _uOffset)
{
return FAKE_PeekFifo16(_uOffset);
}
inline u32 PeekFifo32(u32 _uOffset)
{
return FAKE_PeekFifo32(_uOffset);
}
bool FifoCommandRunnable(void)
{
u32 iBufferSize = FAKE_GetFifoSize();
u32 iBufferSize = (u32)(FAKE_GetFifoEndPtr()-g_pVideoData);
if (iBufferSize == 0)
return false; // can't peek
u8 Cmd = PeekFifo8(0);
u8 Cmd = DataPeek8(0);
u32 iCommandSize = 0;
switch(Cmd)
@ -165,7 +143,7 @@ bool FifoCommandRunnable(void)
if (iBufferSize >= 5)
{
iCommandSize = 1 + 4;
u32 Cmd2 = PeekFifo32(1);
u32 Cmd2 = DataPeek32(1);
int dwTransferSize = ((Cmd2 >> 16) & 15) + 1;
iCommandSize += dwTransferSize * 4;
}
@ -183,7 +161,7 @@ bool FifoCommandRunnable(void)
if (iBufferSize >= 3)
{
iCommandSize = 1 + 2;
u16 numVertices = PeekFifo16(1);
u16 numVertices = DataPeek16(1);
VertexLoader& vtxLoader = g_VertexLoaders[Cmd & GX_VAT_MASK];
vtxLoader.Setup();
int vsize = vtxLoader.GetVertexSize();
@ -254,7 +232,7 @@ bool FifoCommandRunnable(void)
void Decode(void)
{
int Cmd = g_pDataReader->Read8();
int Cmd = DataReadU8();
switch(Cmd)
{
case GX_NOP:
@ -262,42 +240,42 @@ void Decode(void)
case GX_LOAD_CP_REG: //0x08
{
u32 SubCmd = g_pDataReader->Read8();
u32 Value = g_pDataReader->Read32();
u32 SubCmd = DataReadU8();
u32 Value = DataReadU32();
LoadCPReg(SubCmd,Value);
}
break;
case GX_LOAD_XF_REG:
{
u32 Cmd2 = g_pDataReader->Read32();
u32 Cmd2 = DataReadU32();
int dwTransferSize = ((Cmd2>>16)&15) + 1;
u32 dwAddress = Cmd2 & 0xFFFF;
static u32 pData[16];
for (int i=0; i<dwTransferSize; i++)
pData[i] = g_pDataReader->Read32();
pData[i] = DataReadU32();
LoadXFReg(dwTransferSize,dwAddress,pData);
}
break;
case GX_LOAD_INDX_A: //used for position matrices
LoadIndexedXF(g_pDataReader->Read32(),0xC);
LoadIndexedXF(DataReadU32(),0xC);
break;
case GX_LOAD_INDX_B: //used for normal matrices
LoadIndexedXF(g_pDataReader->Read32(),0xD);
LoadIndexedXF(DataReadU32(),0xD);
break;
case GX_LOAD_INDX_C: //used for postmatrices
LoadIndexedXF(g_pDataReader->Read32(),0xE);
LoadIndexedXF(DataReadU32(),0xE);
break;
case GX_LOAD_INDX_D: //used for lights
LoadIndexedXF(g_pDataReader->Read32(),0xF);
LoadIndexedXF(DataReadU32(),0xF);
break;
case GX_CMD_CALL_DL:
{
u32 dwAddr = g_pDataReader->Read32();
u32 dwCount = g_pDataReader->Read32();
u32 dwAddr = DataReadU32();
u32 dwCount = DataReadU32();
ExecuteDisplayList(dwAddr, dwCount);
}
break;
@ -312,7 +290,7 @@ void Decode(void)
case GX_LOAD_BP_REG: //0x61
{
u32 cmd = g_pDataReader->Read32();
u32 cmd = DataReadU32();
LoadBPReg(cmd);
}
break;
@ -322,7 +300,7 @@ void Decode(void)
if (Cmd&0x80)
{
// load vertices
u16 numVertices = g_pDataReader->Read16();
u16 numVertices = DataReadU16();
tempvarray.Reset();
VertexLoader::SetVArray(&tempvarray);
VertexLoader& vtxLoader = g_VertexLoaders[Cmd & GX_VAT_MASK];
@ -371,7 +349,7 @@ void Decode(void)
void OpcodeDecoder_Init()
{
g_pDataReader = &g_fifoReader;
g_pVideoData = FAKE_GetFifoStartPtr();
tempvarray.Create(65536*3, 1, 8, 3, 2, 8);
}

View File

@ -69,29 +69,6 @@ void VertexLoader::SetVArray(DecodedVArray *_varray)
varray = _varray;
}
inline u8 ReadBuffer8()
{
return g_pDataReader->Read8();
}
inline u16 ReadBuffer16()
{
//PowerPC byte ordering :(
return g_pDataReader->Read16();
}
inline u32 ReadBuffer32()
{
//PowerPC byte ordering :(
return g_pDataReader->Read32();
}
inline float ReadBuffer32F()
{
u32 temp = g_pDataReader->Read32();
return *(float*)(&temp);
}
#include "VertexLoader_MtxIndex.h"
#include "VertexLoader_Position.h"
#include "VertexLoader_Normal.h"

View File

@ -45,6 +45,7 @@ int ComputeVertexSize(u32 components);
#include "CPStructs.h"
#include "DecodedVArray.h"
#include "DataReader.h"
#define LOADERDECL __cdecl
typedef void (LOADERDECL *TPipelineFunction)(void*);
@ -215,10 +216,6 @@ public:
extern VertexLoader g_VertexLoaders[8];
extern DecodedVArray* varray;
extern inline u8 ReadBuffer8();
extern inline u16 ReadBuffer16();
extern inline u32 ReadBuffer32();
extern inline float ReadBuffer32F();
#endif

View File

@ -84,32 +84,32 @@ inline u32 _Read32(u32 iAddress)
void LOADERDECL Color_ReadDirect_24b_888(void* _p)
{
u32 col = ReadBuffer8()<<RSHIFT;
col |= ReadBuffer8()<<GSHIFT;
col |= ReadBuffer8()<<BSHIFT;
u32 col = DataReadU8()<<RSHIFT;
col |= DataReadU8()<<GSHIFT;
col |= DataReadU8()<<BSHIFT;
_SetCol(col | (0xFF<<ASHIFT));
}
void LOADERDECL Color_ReadDirect_32b_888x(void* _p){
u32 col = ReadBuffer8()<<RSHIFT;
col |= ReadBuffer8()<<GSHIFT;
col |= ReadBuffer8()<<BSHIFT;
u32 col = DataReadU8()<<RSHIFT;
col |= DataReadU8()<<GSHIFT;
col |= DataReadU8()<<BSHIFT;
_SetCol(col | (0xFF<<ASHIFT));
ReadBuffer8();
DataReadU8();
}
void LOADERDECL Color_ReadDirect_16b_565(void* _p)
{
_SetCol565(ReadBuffer16());
_SetCol565(DataReadU16());
}
void LOADERDECL Color_ReadDirect_16b_4444(void *_p)
{
_SetCol4444(ReadBuffer16());
_SetCol4444(DataReadU16());
}
void LOADERDECL Color_ReadDirect_24b_6666(void* _p)
{
u32 val = ReadBuffer8()<<16;
val|=ReadBuffer8()<<8;
val|=ReadBuffer8();
u32 val = DataReadU8()<<16;
val|=DataReadU8()<<8;
val|=DataReadU8();
_SetCol6666(val);
}
@ -122,10 +122,10 @@ void LOADERDECL Color_ReadDirect_24b_6666(void* _p)
//
void LOADERDECL Color_ReadDirect_32b_8888(void* _p)
{
u32 col = ReadBuffer8()<<RSHIFT;
col |= ReadBuffer8()<<GSHIFT;
col |= ReadBuffer8()<<BSHIFT;
col |= ReadBuffer8()<<ASHIFT;
u32 col = DataReadU8()<<RSHIFT;
col |= DataReadU8()<<GSHIFT;
col |= DataReadU8()<<BSHIFT;
col |= DataReadU8()<<ASHIFT;
// "kill" the alpha
if (!colElements[colIndex])
@ -138,33 +138,33 @@ void LOADERDECL Color_ReadDirect_32b_8888(void* _p)
//////////////////////////////////////////////////////////////////////////
void LOADERDECL Color_ReadIndex8_16b_565(void* _p)
{
u8 Index = ReadBuffer8();
u8 Index = DataReadU8();
u32 iAddress = arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR+colIndex]);
u16 val = Memory_Read_U16(iAddress);
_SetCol565(val);
}
void LOADERDECL Color_ReadIndex8_24b_888(void* _p)
{
u8 Index = ReadBuffer8();
u8 Index = DataReadU8();
u32 iAddress = arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR+colIndex]);
_SetCol(_Read24(iAddress));
}
void LOADERDECL Color_ReadIndex8_32b_888x(void* _p)
{
u8 Index = ReadBuffer8();
u8 Index = DataReadU8();
u32 iAddress = arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR]+colIndex);
_SetCol(_Read24(iAddress));
}
void LOADERDECL Color_ReadIndex8_16b_4444(void* _p)
{
u8 Index = ReadBuffer8();
u8 Index = DataReadU8();
u32 iAddress = arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR+colIndex]);
u16 val = Memory_Read_U16(iAddress);
_SetCol4444(val);
}
void LOADERDECL Color_ReadIndex8_24b_6666(void* _p)
{
u8 Index = ReadBuffer8();
u8 Index = DataReadU8();
u32 iAddress = arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR+colIndex]);
u32 val = Memory_Read_U8(iAddress+2) |
(Memory_Read_U8(iAddress+1)<<8) |
@ -174,7 +174,7 @@ void LOADERDECL Color_ReadIndex8_24b_6666(void* _p)
}
void LOADERDECL Color_ReadIndex8_32b_8888(void* _p)
{
u8 Index = ReadBuffer8();
u8 Index = DataReadU8();
u32 iAddress = arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR+colIndex]);
_SetCol(_Read32(iAddress));
}
@ -183,33 +183,33 @@ void LOADERDECL Color_ReadIndex8_32b_8888(void* _p)
//////////////////////////////////////////////////////////////////////////
void LOADERDECL Color_ReadIndex16_16b_565(void* _p)
{
u16 Index = ReadBuffer16();
u16 Index = DataReadU16();
u32 iAddress = arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR+colIndex]);
u16 val = Memory_Read_U16(iAddress);
_SetCol565(val);
}
void LOADERDECL Color_ReadIndex16_24b_888(void* _p)
{
u16 Index = ReadBuffer16();
u16 Index = DataReadU16();
u32 iAddress = arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR+colIndex]);
_SetCol(_Read24(iAddress));
}
void LOADERDECL Color_ReadIndex16_32b_888x(void* _p)
{
u16 Index = ReadBuffer16();
u16 Index = DataReadU16();
u32 iAddress = arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR+colIndex]);
_SetCol(_Read24(iAddress));
}
void LOADERDECL Color_ReadIndex16_16b_4444(void* _p)
{
u16 Index = ReadBuffer16();
u16 Index = DataReadU16();
u32 iAddress = arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR+colIndex]);
u16 val = Memory_Read_U16(iAddress);
_SetCol4444(val);
}
void LOADERDECL Color_ReadIndex16_24b_6666(void* _p)
{
u16 Index = ReadBuffer16();
u16 Index = DataReadU16();
u32 iAddress = arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR+colIndex]);
u32 val = Memory_Read_U8(iAddress+2) |
(Memory_Read_U8(iAddress+1)<<8) |
@ -218,7 +218,7 @@ void LOADERDECL Color_ReadIndex16_24b_6666(void* _p)
}
void LOADERDECL Color_ReadIndex16_32b_8888(void* _p)
{
u16 Index = ReadBuffer16();
u16 Index = DataReadU16();
u32 iAddress = arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR+colIndex]);
_SetCol(_Read32(iAddress));
}

View File

@ -27,7 +27,7 @@
void LOADERDECL PosMtx_ReadDirect_UByte(void* _p)
{
TVtxAttr* pVtxAttr = (TVtxAttr*)_p;
int index = ReadBuffer8() & 0x3f;
int index = DataReadU8() & 0x3f;
float *flipmem = (float *)xfmem;
varray->SetPosNrmIdx(index);
}
@ -36,6 +36,6 @@ int s_texmtxread = 0, s_texmtxwrite = 0;
void LOADERDECL TexMtx_ReadDirect_UByte(void* _p)
{
TVtxAttr* pVtxAttr = (TVtxAttr*)_p;
int index = ReadBuffer8() & 0x3f;
int index = DataReadU8() & 0x3f;
varray->SetTcIdx(s_texmtxread++, index);
}

View File

@ -130,9 +130,9 @@ VertexLoader_Normal::GetFunction(unsigned int _type, unsigned int _format, unsig
void LOADERDECL
VertexLoader_Normal::Normal_DirectByte(void* _p)
{
varray->SetNormalX(0, ((float)(signed char)ReadBuffer8()+0.5f) / 127.5f);
varray->SetNormalY(0, ((float)(signed char)ReadBuffer8()+0.5f) / 127.5f);
varray->SetNormalZ(0, ((float)(signed char)ReadBuffer8()+0.5f) / 127.5f);
varray->SetNormalX(0, ((float)(signed char)DataReadU8()+0.5f) / 127.5f);
varray->SetNormalY(0, ((float)(signed char)DataReadU8()+0.5f) / 127.5f);
varray->SetNormalZ(0, ((float)(signed char)DataReadU8()+0.5f) / 127.5f);
}
// __________________________________________________________________________________________________
@ -141,9 +141,9 @@ VertexLoader_Normal::Normal_DirectByte(void* _p)
void LOADERDECL
VertexLoader_Normal::Normal_DirectShort(void* _p)
{
varray->SetNormalX(0, ((float)(signed short)ReadBuffer16()+0.5f) / 32767.5f);
varray->SetNormalY(0, ((float)(signed short)ReadBuffer16()+0.5f) / 32767.5f);
varray->SetNormalZ(0, ((float)(signed short)ReadBuffer16()+0.5f) / 32767.5f);
varray->SetNormalX(0, ((float)(signed short)DataReadU16()+0.5f) / 32767.5f);
varray->SetNormalY(0, ((float)(signed short)DataReadU16()+0.5f) / 32767.5f);
varray->SetNormalZ(0, ((float)(signed short)DataReadU16()+0.5f) / 32767.5f);
}
// __________________________________________________________________________________________________
@ -152,9 +152,9 @@ VertexLoader_Normal::Normal_DirectShort(void* _p)
void LOADERDECL
VertexLoader_Normal::Normal_DirectFloat(void* _p)
{
varray->SetNormalX(0, ReadBuffer32F());
varray->SetNormalY(0, ReadBuffer32F());
varray->SetNormalZ(0, ReadBuffer32F());
varray->SetNormalX(0, DataReadF32());
varray->SetNormalY(0, DataReadF32());
varray->SetNormalZ(0, DataReadF32());
}
// __________________________________________________________________________________________________
@ -165,9 +165,9 @@ VertexLoader_Normal::Normal_DirectByte3(void* _p)
{
for (int i=0; i<3; i++)
{
varray->SetNormalX(i, ((float)(signed char)ReadBuffer8()+0.5f) / 127.5f);
varray->SetNormalY(i, ((float)(signed char)ReadBuffer8()+0.5f) / 127.5f);
varray->SetNormalZ(i, ((float)(signed char)ReadBuffer8()+0.5f) / 127.5f);
varray->SetNormalX(i, ((float)(signed char)DataReadU8()+0.5f) / 127.5f);
varray->SetNormalY(i, ((float)(signed char)DataReadU8()+0.5f) / 127.5f);
varray->SetNormalZ(i, ((float)(signed char)DataReadU8()+0.5f) / 127.5f);
}
}
@ -179,9 +179,9 @@ VertexLoader_Normal::Normal_DirectShort3(void* _p)
{
for (int i=0; i<3; i++)
{
varray->SetNormalX(i, ((float)(signed short)ReadBuffer16()+0.5f) / 32767.5f);
varray->SetNormalY(i, ((float)(signed short)ReadBuffer16()+0.5f) / 32767.5f);
varray->SetNormalZ(i, ((float)(signed short)ReadBuffer16()+0.5f) / 32767.5f);
varray->SetNormalX(i, ((float)(signed short)DataReadU16()+0.5f) / 32767.5f);
varray->SetNormalY(i, ((float)(signed short)DataReadU16()+0.5f) / 32767.5f);
varray->SetNormalZ(i, ((float)(signed short)DataReadU16()+0.5f) / 32767.5f);
}
}
@ -193,9 +193,9 @@ VertexLoader_Normal::Normal_DirectFloat3(void* _p)
{
for (int i=0; i<3; i++)
{
varray->SetNormalX(i, ReadBuffer32F());
varray->SetNormalY(i, ReadBuffer32F());
varray->SetNormalZ(i, ReadBuffer32F());
varray->SetNormalX(i, DataReadF32());
varray->SetNormalY(i, DataReadF32());
varray->SetNormalZ(i, DataReadF32());
}
}
@ -211,7 +211,7 @@ VertexLoader_Normal::Normal_DirectFloat3(void* _p)
void LOADERDECL
VertexLoader_Normal::Normal_Index8_Byte(void* _p)
{
u8 Index = ReadBuffer8();
u8 Index = DataReadU8();
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]);
varray->SetNormalX(0, ((float)(signed char)Memory_Read_U8(iAddress )+0.5f) / 127.5f);
@ -225,7 +225,7 @@ VertexLoader_Normal::Normal_Index8_Byte(void* _p)
void LOADERDECL
VertexLoader_Normal::Normal_Index8_Short(void* _p)
{
u8 Index = ReadBuffer8();
u8 Index = DataReadU8();
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]);
varray->SetNormalX(0, ((float)(signed short)Memory_Read_U16(iAddress )+0.5f) / 32767.5f);
@ -239,7 +239,7 @@ VertexLoader_Normal::Normal_Index8_Short(void* _p)
void LOADERDECL
VertexLoader_Normal::Normal_Index8_Float(void* _p)
{
u8 Index = ReadBuffer8();
u8 Index = DataReadU8();
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]);
varray->SetNormalX(0, Memory_Read_Float(iAddress));
@ -257,7 +257,7 @@ VertexLoader_Normal::Normal_Index8_Byte3(void* _p)
{
for (int i=0; i<3; i++)
{
u8 Index = ReadBuffer8();
u8 Index = DataReadU8();
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]) + 1*3*i;
varray->SetNormalX(i, ((float)(signed char)Memory_Read_U8(iAddress )+0.5f) / 127.5f);
@ -267,7 +267,7 @@ VertexLoader_Normal::Normal_Index8_Byte3(void* _p)
}
else
{
u8 Index = ReadBuffer8();
u8 Index = DataReadU8();
for (int i=0; i<3; i++)
{
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]) + 1*3*i;
@ -289,7 +289,7 @@ VertexLoader_Normal::Normal_Index8_Short3(void* _p)
{
for (int i=0; i<3; i++)
{
u8 Index = ReadBuffer8();
u8 Index = DataReadU8();
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]) + 2*3*i;
varray->SetNormalX(i, ((float)(signed short)Memory_Read_U16(iAddress )+0.5f) / 32767.5f);
@ -299,7 +299,7 @@ VertexLoader_Normal::Normal_Index8_Short3(void* _p)
}
else
{
u8 Index = ReadBuffer8();
u8 Index = DataReadU8();
for (int i=0; i<3; i++)
{
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]) + 2*3*i;
@ -321,7 +321,7 @@ VertexLoader_Normal::Normal_Index8_Float3(void* _p)
{
for (int i=0; i<3; i++)
{
u8 Index = ReadBuffer8();
u8 Index = DataReadU8();
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]) + 4*3*i;
varray->SetNormalX(i, Memory_Read_Float(iAddress));
@ -331,7 +331,7 @@ VertexLoader_Normal::Normal_Index8_Float3(void* _p)
}
else
{
u8 Index = ReadBuffer8();
u8 Index = DataReadU8();
for (int i=0; i<3; i++)
{
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]) + 4*3*i;
@ -355,7 +355,7 @@ VertexLoader_Normal::Normal_Index8_Float3(void* _p)
void LOADERDECL
VertexLoader_Normal::Normal_Index16_Byte(void* _p)
{
u16 Index = ReadBuffer16();
u16 Index = DataReadU16();
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]);
varray->SetNormalX(0, ((float)(signed char)Memory_Read_U8(iAddress )+0.5f) / 127.5f);
@ -369,7 +369,7 @@ VertexLoader_Normal::Normal_Index16_Byte(void* _p)
void LOADERDECL
VertexLoader_Normal::Normal_Index16_Short(void* _p)
{
u16 Index = ReadBuffer16();
u16 Index = DataReadU16();
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]);
varray->SetNormalX(0, ((float)(signed short)Memory_Read_U16(iAddress )+0.5f) / 32767.5f);
@ -383,7 +383,7 @@ VertexLoader_Normal::Normal_Index16_Short(void* _p)
void LOADERDECL
VertexLoader_Normal::Normal_Index16_Float(void* _p)
{
u16 Index = ReadBuffer16();
u16 Index = DataReadU16();
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]);
varray->SetNormalX(0, Memory_Read_Float(iAddress));
@ -401,7 +401,7 @@ VertexLoader_Normal::Normal_Index16_Byte3(void* _p)
{
for (int i=0; i<3; i++)
{
u16 Index = ReadBuffer16();
u16 Index = DataReadU16();
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]) + 1*3*i;
varray->SetNormalX(i, ((float)(signed char)Memory_Read_U8(iAddress )+0.5f) / 127.5f);
@ -411,7 +411,7 @@ VertexLoader_Normal::Normal_Index16_Byte3(void* _p)
}
else
{
u16 Index = ReadBuffer16();
u16 Index = DataReadU16();
for (int i=0; i<3; i++)
{
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]) + 1*3*i;
@ -433,7 +433,7 @@ VertexLoader_Normal::Normal_Index16_Short3(void* _p)
{
for (int i=0; i<3; i++)
{
u16 Index = ReadBuffer16();
u16 Index = DataReadU16();
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]) + 2*3*i;
varray->SetNormalX(i, ((float)(signed short)Memory_Read_U16(iAddress )+0.5f) / 32767.5f);
@ -443,7 +443,7 @@ VertexLoader_Normal::Normal_Index16_Short3(void* _p)
}
else
{
u16 Index = ReadBuffer16();
u16 Index = DataReadU16();
for (int i=0; i<3; i++)
{
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]) + 2*3*i;
@ -465,7 +465,7 @@ VertexLoader_Normal::Normal_Index16_Float3(void* _p)
{
for (int i=0; i<3; i++)
{
u16 Index = ReadBuffer16();
u16 Index = DataReadU16();
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]) + 4*3*i;
varray->SetNormalX(i, Memory_Read_Float(iAddress ));
@ -475,7 +475,7 @@ VertexLoader_Normal::Normal_Index16_Float3(void* _p)
}
else
{
u16 Index = ReadBuffer16();
u16 Index = DataReadU16();
for (int i=0; i<3; i++)
{
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]) + 4*3*i;

View File

@ -66,11 +66,11 @@ void LOADERDECL _ReadPosFloatMem(int iAddress, TVtxAttr* pVtxAttr)
void LOADERDECL Pos_ReadDirect_UByte(void* _p)
{
TVtxAttr* pVtxAttr = (TVtxAttr*)_p;
varray->SetPosX((float)ReadBuffer8() * posScale);
varray->SetPosY((float)ReadBuffer8() * posScale);
varray->SetPosX((float)DataReadU8() * posScale);
varray->SetPosY((float)DataReadU8() * posScale);
if (pVtxAttr->PosElements)
varray->SetPosZ((float)ReadBuffer8() * posScale);
varray->SetPosZ((float)DataReadU8() * posScale);
else
varray->SetPosZ(1.0);
}
@ -78,11 +78,11 @@ void LOADERDECL Pos_ReadDirect_UByte(void* _p)
void LOADERDECL Pos_ReadDirect_Byte(void* _p)
{
TVtxAttr* pVtxAttr = (TVtxAttr*)_p;
varray->SetPosX((float)(s8)ReadBuffer8() * posScale);
varray->SetPosY((float)(s8)ReadBuffer8() * posScale);
varray->SetPosX((float)(s8)DataReadU8() * posScale);
varray->SetPosY((float)(s8)DataReadU8() * posScale);
if (pVtxAttr->PosElements)
varray->SetPosZ((float)(s8)ReadBuffer8() * posScale);
varray->SetPosZ((float)(s8)DataReadU8() * posScale);
else
varray->SetPosZ(1.0);
}
@ -91,11 +91,11 @@ void LOADERDECL Pos_ReadDirect_UShort(void* _p)
{
TVtxAttr* pVtxAttr = (TVtxAttr*)_p;
varray->SetPosX((float)ReadBuffer16() * posScale);
varray->SetPosY((float)ReadBuffer16() * posScale);
varray->SetPosX((float)DataReadU16() * posScale);
varray->SetPosY((float)DataReadU16() * posScale);
if (pVtxAttr->PosElements)
varray->SetPosZ((float)ReadBuffer16() * posScale);
varray->SetPosZ((float)DataReadU16() * posScale);
else
varray->SetPosZ(1.0);
}
@ -104,11 +104,11 @@ void LOADERDECL Pos_ReadDirect_Short(void* _p)
{
TVtxAttr* pVtxAttr = (TVtxAttr*)_p;
varray->SetPosX((float)(s16)ReadBuffer16() * posScale);
varray->SetPosY((float)(s16)ReadBuffer16() * posScale);
varray->SetPosX((float)(s16)DataReadU16() * posScale);
varray->SetPosY((float)(s16)DataReadU16() * posScale);
if (pVtxAttr->PosElements)
varray->SetPosZ((float)(s16)ReadBuffer16() * posScale);
varray->SetPosZ((float)(s16)DataReadU16() * posScale);
else
varray->SetPosZ(1.0);
}
@ -117,11 +117,11 @@ void LOADERDECL Pos_ReadDirect_Float(void* _p)
{
TVtxAttr* pVtxAttr = (TVtxAttr*)_p;
varray->SetPosX(ReadBuffer32F());
varray->SetPosY(ReadBuffer32F());
varray->SetPosX(DataReadF32());
varray->SetPosY(DataReadF32());
if (pVtxAttr->PosElements)
varray->SetPosZ(ReadBuffer32F());
varray->SetPosZ(DataReadF32());
else
varray->SetPosZ(1.0);
}
@ -133,14 +133,14 @@ void LOADERDECL Pos_ReadDirect_Float(void* _p)
void LOADERDECL Pos_ReadIndex8_UByte(void* _p)
{
TVtxAttr* pVtxAttr = (TVtxAttr*)_p;
u8 Index = ReadBuffer8();
u8 Index = DataReadU8();
u32 iAddress = arraybases[ARRAY_POSITION] + (Index * arraystrides[ARRAY_POSITION]);
_ReadPos8Mem<u8>(iAddress, pVtxAttr);
}
void LOADERDECL Pos_ReadIndex8_Byte(void* _p)
{
TVtxAttr* pVtxAttr = (TVtxAttr*)_p;
u8 Index = ReadBuffer8();
u8 Index = DataReadU8();
u32 iAddress = arraybases[ARRAY_POSITION] + (Index * arraystrides[ARRAY_POSITION]);
_ReadPos8Mem<s8>(iAddress, pVtxAttr);
}
@ -148,7 +148,7 @@ void LOADERDECL Pos_ReadIndex8_Byte(void* _p)
void LOADERDECL Pos_ReadIndex8_UShort(void* _p)
{
TVtxAttr* pVtxAttr = (TVtxAttr*)_p;
u8 Index = ReadBuffer8();
u8 Index = DataReadU8();
u32 iAddress = arraybases[ARRAY_POSITION] + (Index * arraystrides[ARRAY_POSITION]);
_ReadPos16Mem<u16>(iAddress, pVtxAttr);
}
@ -156,7 +156,7 @@ void LOADERDECL Pos_ReadIndex8_UShort(void* _p)
void LOADERDECL Pos_ReadIndex8_Short(void* _p)
{
TVtxAttr* pVtxAttr = (TVtxAttr*)_p;
u8 Index = ReadBuffer8();
u8 Index = DataReadU8();
u32 iAddress = arraybases[ARRAY_POSITION] + (Index * arraystrides[ARRAY_POSITION]);
_ReadPos16Mem<s16>(iAddress, pVtxAttr);
}
@ -164,7 +164,7 @@ void LOADERDECL Pos_ReadIndex8_Short(void* _p)
void LOADERDECL Pos_ReadIndex8_Float(void* _p)
{
TVtxAttr* pVtxAttr = (TVtxAttr*)_p;
u8 Index = ReadBuffer8();
u8 Index = DataReadU8();
u32 iAddress = arraybases[ARRAY_POSITION] + (Index * arraystrides[ARRAY_POSITION]);
_ReadPosFloatMem(iAddress, pVtxAttr);
}
@ -175,21 +175,21 @@ void LOADERDECL Pos_ReadIndex8_Float(void* _p)
void LOADERDECL Pos_ReadIndex16_UByte(void* _p){
TVtxAttr* pVtxAttr = (TVtxAttr*)_p;
u16 Index = ReadBuffer16();
u16 Index = DataReadU16();
u32 iAddress = arraybases[ARRAY_POSITION] + (Index * arraystrides[ARRAY_POSITION]);
_ReadPos8Mem<u8>(iAddress, pVtxAttr);
}
void LOADERDECL Pos_ReadIndex16_Byte(void* _p){
TVtxAttr* pVtxAttr = (TVtxAttr*)_p;
u16 Index = ReadBuffer16();
u16 Index = DataReadU16();
u32 iAddress = arraybases[ARRAY_POSITION] + (Index * arraystrides[ARRAY_POSITION]);
_ReadPos8Mem<s8>(iAddress, pVtxAttr);
}
void LOADERDECL Pos_ReadIndex16_UShort(void* _p){
TVtxAttr* pVtxAttr = (TVtxAttr*)_p;
u16 Index = ReadBuffer16();
u16 Index = DataReadU16();
u32 iAddress = arraybases[ARRAY_POSITION] + (Index * arraystrides[ARRAY_POSITION]);
_ReadPos16Mem<u16>(iAddress, pVtxAttr);
}
@ -197,7 +197,7 @@ void LOADERDECL Pos_ReadIndex16_UShort(void* _p){
void LOADERDECL Pos_ReadIndex16_Short(void* _p)
{
TVtxAttr* pVtxAttr = (TVtxAttr*)_p;
u16 Index = ReadBuffer16();
u16 Index = DataReadU16();
u32 iAddress = arraybases[ARRAY_POSITION] + (Index * arraystrides[ARRAY_POSITION]);
_ReadPos16Mem<s16>(iAddress, pVtxAttr);
}
@ -205,7 +205,7 @@ void LOADERDECL Pos_ReadIndex16_Short(void* _p)
void LOADERDECL Pos_ReadIndex16_Float(void* _p)
{
TVtxAttr* pVtxAttr = (TVtxAttr*)_p;
u16 Index = ReadBuffer16();
u16 Index = DataReadU16();
u32 iAddress = arraybases[ARRAY_POSITION] + (Index * arraystrides[ARRAY_POSITION]);
_ReadPosFloatMem(iAddress, pVtxAttr);
}

View File

@ -22,47 +22,47 @@ extern int tcIndex;
void LOADERDECL TexCoord_ReadDirect_UByte(void* _p)
{
varray->SetU(tcIndex, ReadBuffer8() * tcScaleU[tcIndex]);
varray->SetU(tcIndex, DataReadU8() * tcScaleU[tcIndex]);
if (tcElements[tcIndex])
varray->SetV(tcIndex, ReadBuffer8() * tcScaleV[tcIndex]);
varray->SetV(tcIndex, DataReadU8() * tcScaleV[tcIndex]);
tcIndex++;
}
void LOADERDECL TexCoord_ReadDirect_Byte(void* _p)
{
varray->SetU(tcIndex, (s8)ReadBuffer8() * tcScaleU[tcIndex]);
varray->SetU(tcIndex, (s8)DataReadU8() * tcScaleU[tcIndex]);
if (tcElements[tcIndex])
varray->SetV(tcIndex, (s8)ReadBuffer8() * tcScaleV[tcIndex]);
varray->SetV(tcIndex, (s8)DataReadU8() * tcScaleV[tcIndex]);
tcIndex++;
}
void LOADERDECL TexCoord_ReadDirect_UShort(void* _p)
{
varray->SetU(tcIndex, ReadBuffer16() * tcScaleU[tcIndex]);
varray->SetU(tcIndex, DataReadU16() * tcScaleU[tcIndex]);
if (tcElements[tcIndex])
varray->SetV(tcIndex, ReadBuffer16() * tcScaleV[tcIndex]);
varray->SetV(tcIndex, DataReadU16() * tcScaleV[tcIndex]);
tcIndex++;
}
void LOADERDECL TexCoord_ReadDirect_Short(void* _p)
{
varray->SetU(tcIndex, (s16)ReadBuffer16() * tcScaleU[tcIndex]);
varray->SetU(tcIndex, (s16)DataReadU16() * tcScaleU[tcIndex]);
if (tcElements[tcIndex])
varray->SetV(tcIndex, (s16)ReadBuffer16() * tcScaleV[tcIndex]);
varray->SetV(tcIndex, (s16)DataReadU16() * tcScaleV[tcIndex]);
tcIndex++;
}
void LOADERDECL TexCoord_ReadDirect_Float(void* _p)
{
varray->SetU(tcIndex, ReadBuffer32F() * tcScaleU[tcIndex]);
varray->SetU(tcIndex, DataReadF32() * tcScaleU[tcIndex]);
if (tcElements[tcIndex])
varray->SetV(tcIndex, ReadBuffer32F() * tcScaleV[tcIndex]);
varray->SetV(tcIndex, DataReadF32() * tcScaleV[tcIndex]);
tcIndex++;
}
// ==================================================================================
void LOADERDECL TexCoord_ReadIndex8_UByte(void* _p)
{
u8 Index = ReadBuffer8();
u8 Index = DataReadU8();
u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
varray->SetU(tcIndex, (float)(u8)Memory_Read_U8(iAddress) * tcScaleU[tcIndex]);
@ -72,7 +72,7 @@ void LOADERDECL TexCoord_ReadIndex8_UByte(void* _p)
}
void LOADERDECL TexCoord_ReadIndex8_Byte(void* _p)
{
u8 Index = ReadBuffer8();
u8 Index = DataReadU8();
u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
varray->SetU(tcIndex, (float)(s8)Memory_Read_U8(iAddress) * tcScaleU[tcIndex]);
@ -83,7 +83,7 @@ void LOADERDECL TexCoord_ReadIndex8_Byte(void* _p)
}
void LOADERDECL TexCoord_ReadIndex8_UShort(void* _p)
{
u8 Index = ReadBuffer8();
u8 Index = DataReadU8();
u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
varray->SetU(tcIndex, (float)(u16)Memory_Read_U16(iAddress) * tcScaleU[tcIndex]);
@ -93,7 +93,7 @@ void LOADERDECL TexCoord_ReadIndex8_UShort(void* _p)
}
void LOADERDECL TexCoord_ReadIndex8_Short(void* _p)
{
u8 Index = ReadBuffer8();
u8 Index = DataReadU8();
u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
varray->SetU(tcIndex, (float)(s16)Memory_Read_U16(iAddress) * tcScaleU[tcIndex]);
@ -103,7 +103,7 @@ void LOADERDECL TexCoord_ReadIndex8_Short(void* _p)
}
void LOADERDECL TexCoord_ReadIndex8_Float(void* _p)
{
u16 Index = ReadBuffer8();
u16 Index = DataReadU8();
u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
u32 uTemp;
uTemp = Memory_Read_U32(iAddress );
@ -120,7 +120,7 @@ void LOADERDECL TexCoord_ReadIndex8_Float(void* _p)
// ==================================================================================
void LOADERDECL TexCoord_ReadIndex16_UByte(void* _p)
{
u16 Index = ReadBuffer16();
u16 Index = DataReadU16();
u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
u32 uTemp;
@ -136,7 +136,7 @@ void LOADERDECL TexCoord_ReadIndex16_UByte(void* _p)
}
void LOADERDECL TexCoord_ReadIndex16_Byte(void* _p)
{
u16 Index = ReadBuffer16();
u16 Index = DataReadU16();
u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
u32 uTemp;
@ -154,7 +154,7 @@ void LOADERDECL TexCoord_ReadIndex16_Byte(void* _p)
void LOADERDECL TexCoord_ReadIndex16_UShort(void* _p)
{
TVtxAttr* pVtxAttr = (TVtxAttr*)_p;
u16 Index = ReadBuffer16();
u16 Index = DataReadU16();
u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
float uTemp;
@ -170,7 +170,7 @@ void LOADERDECL TexCoord_ReadIndex16_UShort(void* _p)
}
void LOADERDECL TexCoord_ReadIndex16_Short(void* _p)
{
u16 Index = ReadBuffer16();
u16 Index = DataReadU16();
u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
float uTemp;
@ -186,7 +186,7 @@ void LOADERDECL TexCoord_ReadIndex16_Short(void* _p)
}
void LOADERDECL TexCoord_ReadIndex16_Float(void* _p)
{
u16 Index = ReadBuffer16();
u16 Index = DataReadU16();
u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
u32 uTemp;
uTemp = Memory_Read_U32(iAddress );

View File

@ -206,8 +206,8 @@ void Video_Prepare(void)
BPInit();
CVertexHandler::Init();
OpcodeDecoder_Init();
Fifo_Init();
OpcodeDecoder_Init();
}
void Video_Shutdown(void)