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:
parent
8997f9cb3e
commit
8d0f6d40f4
|
@ -0,0 +1,80 @@
|
||||||
|
// 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
|
||||||
|
|
||||||
|
|
||||||
|
extern u8* g_pVideoData;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
inline u8 DataPeek8(u32 _uOffset)
|
||||||
|
{
|
||||||
|
return g_pVideoData[_uOffset];
|
||||||
|
}
|
||||||
|
|
||||||
|
inline u16 DataPeek16(u32 _uOffset)
|
||||||
|
{
|
||||||
|
return Common::swap16(*(u16*)&g_pVideoData[_uOffset]);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline u32 DataPeek32(u32 _uOffset)
|
||||||
|
{
|
||||||
|
return Common::swap32(*(u32*)&g_pVideoData[_uOffset]);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline u8 DataReadU8()
|
||||||
|
{
|
||||||
|
return *g_pVideoData++;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline u16 DataReadU16()
|
||||||
|
{
|
||||||
|
u16 tmp = Common::swap16(*(u16*)g_pVideoData);
|
||||||
|
g_pVideoData+=2;
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline u32 DataReadU32()
|
||||||
|
{
|
||||||
|
u32 tmp = Common::swap32(*(u32*)g_pVideoData);
|
||||||
|
g_pVideoData+=4;
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline float DataReadF32()
|
||||||
|
{
|
||||||
|
union {u32 i; float f;} temp;
|
||||||
|
temp.i = Common::swap32(*(u32*)g_pVideoData);
|
||||||
|
g_pVideoData+=4;
|
||||||
|
float tmp = temp.f;
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline u8* DataGetPosition()
|
||||||
|
{
|
||||||
|
return g_pVideoData;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void DataSkip(u32 skip)
|
||||||
|
{
|
||||||
|
g_pVideoData += skip;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -23,31 +23,23 @@
|
||||||
|
|
||||||
#include "Fifo.h"
|
#include "Fifo.h"
|
||||||
|
|
||||||
#if defined(DATAREADER_INLINE)
|
|
||||||
extern u8* g_pVideoData;
|
extern u8* g_pVideoData;
|
||||||
#else
|
|
||||||
FifoReader fifo;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool fifoStateRun = true;
|
bool fifoStateRun = true;
|
||||||
|
|
||||||
// STATE_TO_SAVE
|
// STATE_TO_SAVE
|
||||||
static u8 *videoBuffer;
|
static u8 *videoBuffer;
|
||||||
static int size = 0;
|
static int size = 0;
|
||||||
static int readptr = 0;
|
|
||||||
|
|
||||||
void Fifo_DoState(PointerWrap &p) {
|
void Fifo_DoState(PointerWrap &p)
|
||||||
|
{
|
||||||
p.DoArray(videoBuffer, FIFO_SIZE);
|
p.DoArray(videoBuffer, FIFO_SIZE);
|
||||||
p.Do(size);
|
p.Do(size);
|
||||||
p.Do(readptr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Fifo_Init()
|
void Fifo_Init()
|
||||||
{
|
{
|
||||||
videoBuffer = (u8*)AllocateMemoryPages(FIFO_SIZE);
|
videoBuffer = (u8*)AllocateMemoryPages(FIFO_SIZE);
|
||||||
#ifndef DATAREADER_INLINE
|
|
||||||
fifo.Init(videoBuffer, videoBuffer); //zero length. there is no data yet.
|
|
||||||
#endif
|
|
||||||
fifoStateRun = true;
|
fifoStateRun = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +49,8 @@ void Fifo_Shutdown()
|
||||||
fifoStateRun = false;
|
fifoStateRun = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Fifo_Stop() {
|
void Fifo_Stop()
|
||||||
|
{
|
||||||
fifoStateRun = false;
|
fifoStateRun = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,68 +59,11 @@ u8* FAKE_GetFifoStartPtr()
|
||||||
return videoBuffer;
|
return videoBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FAKE_GetFifoSize()
|
|
||||||
{
|
|
||||||
if (size < readptr)
|
|
||||||
{
|
|
||||||
PanicAlert("GFX Fifo underrun encountered (size = %i, readptr = %i)", size, readptr);
|
|
||||||
}
|
|
||||||
return (size - readptr);
|
|
||||||
}
|
|
||||||
u8* FAKE_GetFifoEndPtr()
|
u8* FAKE_GetFifoEndPtr()
|
||||||
{
|
{
|
||||||
return &videoBuffer[size];
|
return &videoBuffer[size];
|
||||||
}
|
}
|
||||||
|
|
||||||
u8 FAKE_PeekFifo8(u32 _uOffset)
|
|
||||||
{
|
|
||||||
return videoBuffer[readptr + _uOffset];
|
|
||||||
}
|
|
||||||
|
|
||||||
u16 FAKE_PeekFifo16(u32 _uOffset)
|
|
||||||
{
|
|
||||||
return Common::swap16(*(u16*)&videoBuffer[readptr + _uOffset]);
|
|
||||||
}
|
|
||||||
|
|
||||||
u32 FAKE_PeekFifo32(u32 _uOffset)
|
|
||||||
{
|
|
||||||
return Common::swap32(*(u32*)&videoBuffer[readptr + _uOffset]);
|
|
||||||
}
|
|
||||||
|
|
||||||
u8 FAKE_ReadFifo8()
|
|
||||||
{
|
|
||||||
return videoBuffer[readptr++];
|
|
||||||
}
|
|
||||||
|
|
||||||
int FAKE_GetPosition()
|
|
||||||
{
|
|
||||||
return readptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
u8* FAKE_GetFifoCurrentPtr()
|
|
||||||
{
|
|
||||||
return &videoBuffer[readptr];
|
|
||||||
}
|
|
||||||
|
|
||||||
u16 FAKE_ReadFifo16()
|
|
||||||
{
|
|
||||||
u16 val = Common::swap16(*(u16*)(videoBuffer+readptr));
|
|
||||||
readptr += 2;
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
|
|
||||||
u32 FAKE_ReadFifo32()
|
|
||||||
{
|
|
||||||
u32 val = Common::swap32(*(u32*)(videoBuffer+readptr));
|
|
||||||
readptr += 4;
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
|
|
||||||
void FAKE_SkipFifo(u32 skip)
|
|
||||||
{
|
|
||||||
readptr += skip;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Video_SendFifoData(u8* _uData)
|
void Video_SendFifoData(u8* _uData)
|
||||||
{
|
{
|
||||||
// TODO (mb2): unrolled loop faster than memcpy here?
|
// TODO (mb2): unrolled loop faster than memcpy here?
|
||||||
|
@ -135,24 +71,14 @@ void Video_SendFifoData(u8* _uData)
|
||||||
size += 32;
|
size += 32;
|
||||||
if (size + 32 >= FIFO_SIZE)
|
if (size + 32 >= FIFO_SIZE)
|
||||||
{
|
{
|
||||||
// TODO (mb2): Better and DataReader inline for DX9
|
int pos = (int)(g_pVideoData-videoBuffer);
|
||||||
#ifdef DATAREADER_INLINE
|
//if (size-pos > pos)
|
||||||
if (g_pVideoData) // for DX9 plugin "compatibility"
|
//{
|
||||||
readptr = (int)(g_pVideoData-videoBuffer);
|
// PanicAlert("FIFO out of bounds (sz = %i, at %08x)", FAKE_GetFifoSize(), readptr);
|
||||||
#endif
|
//}
|
||||||
if (FAKE_GetFifoSize() > readptr)
|
memmove(&videoBuffer[0], &videoBuffer[pos], size - pos );
|
||||||
{
|
size -= pos;
|
||||||
PanicAlert("FIFO out of bounds (sz = %i, at %08x)", FAKE_GetFifoSize(), readptr);
|
g_pVideoData = FAKE_GetFifoStartPtr();
|
||||||
}
|
|
||||||
// DebugLog("FAKE BUFFER LOOPS");
|
|
||||||
memmove(&videoBuffer[0], &videoBuffer[readptr], FAKE_GetFifoSize());
|
|
||||||
// memset(&videoBuffer[FAKE_GetFifoSize()], 0, FIFO_SIZE - FAKE_GetFifoSize());
|
|
||||||
size = FAKE_GetFifoSize();
|
|
||||||
readptr = 0;
|
|
||||||
#ifdef DATAREADER_INLINE
|
|
||||||
if (g_pVideoData) // for DX9 plugin "compatibility"
|
|
||||||
g_pVideoData = FAKE_GetFifoStartPtr();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
OpcodeDecoder_Run();
|
OpcodeDecoder_Run();
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,50 +23,8 @@
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
#include "ChunkFile.h"
|
#include "ChunkFile.h"
|
||||||
|
|
||||||
// TODO (mb2) clean this if ok
|
|
||||||
#define DATAREADER_INLINE // comment to use the previous IDataReader way
|
|
||||||
//#define DATAREADER_DEBUG // simple compare with the previous IDataReader way
|
|
||||||
|
|
||||||
#if defined(DATAREADER_DEBUG) && !defined(DATAREADER_INLINE)
|
|
||||||
#define DATAREADER_INLINE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#define FIFO_SIZE (1024*1024)
|
#define FIFO_SIZE (1024*1024)
|
||||||
|
|
||||||
#ifndef DATAREADER_INLINE
|
|
||||||
// inline for speed!
|
|
||||||
class FifoReader
|
|
||||||
{
|
|
||||||
u8 *ptr;
|
|
||||||
u8 *end;
|
|
||||||
u8 *tempPtr; //single element stack :P
|
|
||||||
u8 *tempEnd;
|
|
||||||
bool pushed;
|
|
||||||
public:
|
|
||||||
void Init(u8 *_ptr, u8 *_end)
|
|
||||||
{
|
|
||||||
ptr = _ptr; end = _end; pushed = false;
|
|
||||||
}
|
|
||||||
bool IsPushed() {return pushed;}
|
|
||||||
void Push(u8 *_ptr, u8 *_end) {pushed = true; tempPtr = ptr; tempEnd = end; ptr = _ptr; end = _end;}
|
|
||||||
void Pop() {pushed = false; ptr = tempPtr; end = tempEnd;}
|
|
||||||
u8 Peek8 (int offset) const { return ptr[offset]; }
|
|
||||||
u16 Peek16(int offset) const { return Common::swap16(*(u16*)(ptr+offset)); }
|
|
||||||
u32 Peek32(int offset) const { return Common::swap32(*(u32*)(ptr+offset)); }
|
|
||||||
u8 Read8 () {return *ptr++;}
|
|
||||||
u16 Read16() {const u16 value = Common::swap16(*((u16*)ptr)); ptr+=2; return value;}
|
|
||||||
u32 Read32() {const u32 value = Common::swap32(*((u32*)ptr)); ptr+=4; return value;}
|
|
||||||
float Read32F() {const u32 value = Common::swap32(*((u32*)ptr)); ptr+=4; return *(float*)&value;}
|
|
||||||
int GetRemainSize() const { return (int)(end - ptr); }
|
|
||||||
u8 *GetPtr() const { return ptr; }
|
|
||||||
void MoveEndForward() { end += 32; }
|
|
||||||
u8 *GetEnd() const { return end; }
|
|
||||||
};
|
|
||||||
|
|
||||||
extern FifoReader fifo;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
void Fifo_Init();
|
void Fifo_Init();
|
||||||
void Fifo_Shutdown();
|
void Fifo_Shutdown();
|
||||||
void Fifo_EnterLoop(const SVideoInitialize &video_initialize);
|
void Fifo_EnterLoop(const SVideoInitialize &video_initialize);
|
||||||
|
|
|
@ -418,6 +418,10 @@
|
||||||
RelativePath=".\Src\CPMemory.h"
|
RelativePath=".\Src\CPMemory.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\Src\DataReader.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\Src\Fifo.cpp"
|
RelativePath=".\Src\Fifo.cpp"
|
||||||
>
|
>
|
||||||
|
|
|
@ -1193,14 +1193,6 @@
|
||||||
RelativePath=".\Src\CPStructs.h"
|
RelativePath=".\Src\CPStructs.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath=".\Src\DataReader.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\Src\DataReader.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath=".\Src\DecodedVArray.cpp"
|
RelativePath=".\Src\DecodedVArray.cpp"
|
||||||
>
|
>
|
||||||
|
|
|
@ -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;
|
|
||||||
}
|
|
|
@ -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
|
|
|
@ -46,20 +46,15 @@
|
||||||
#include "DLCompiler.h"
|
#include "DLCompiler.h"
|
||||||
|
|
||||||
#define CMDBUFFER_SIZE 1024*1024
|
#define CMDBUFFER_SIZE 1024*1024
|
||||||
|
|
||||||
DecodedVArray tempvarray;
|
DecodedVArray tempvarray;
|
||||||
// TODO (mb2): all! DataReader inline for DX9
|
|
||||||
#ifdef DATAREADER_INLINE
|
|
||||||
u8 *g_pVideoData = 0;
|
u8 *g_pVideoData = 0;
|
||||||
#endif
|
|
||||||
|
extern u8* FAKE_GetFifoStartPtr();
|
||||||
|
extern u8* FAKE_GetFifoEndPtr();
|
||||||
|
|
||||||
void Decode();
|
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>
|
template <class T>
|
||||||
void Xchg(T& a, T&b)
|
void Xchg(T& a, T&b)
|
||||||
{
|
{
|
||||||
|
@ -70,11 +65,10 @@ void Xchg(T& a, T&b)
|
||||||
|
|
||||||
void ExecuteDisplayList(u32 address, u32 size)
|
void ExecuteDisplayList(u32 address, u32 size)
|
||||||
{
|
{
|
||||||
IDataReader* pOldReader = g_pDataReader;
|
u8* old_pVideoData = g_pVideoData;
|
||||||
|
|
||||||
// address &= 0x01FFFFFF; // phys address
|
u8* startAddress = Memory_GetPtr(address);
|
||||||
CDataReader_Memory memoryReader(address);
|
g_pVideoData = startAddress;
|
||||||
g_pDataReader = &memoryReader;
|
|
||||||
|
|
||||||
// temporarily swap dl and non-dl(small "hack" for the stats)
|
// temporarily swap dl and non-dl(small "hack" for the stats)
|
||||||
Xchg(stats.thisFrame.numDLPrims, stats.thisFrame.numPrims);
|
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.numCPLoadsInDL, stats.thisFrame.numCPLoads);
|
||||||
Xchg(stats.thisFrame.numBPLoadsInDL, stats.thisFrame.numBPLoads);
|
Xchg(stats.thisFrame.numBPLoadsInDL, stats.thisFrame.numBPLoads);
|
||||||
|
|
||||||
while((memoryReader.GetReadAddress() - address) < size)
|
while((u32)(g_pVideoData - startAddress) < size)
|
||||||
{
|
{
|
||||||
Decode();
|
Decode();
|
||||||
}
|
}
|
||||||
INCSTAT(stats.numDListsCalled);
|
INCSTAT(stats.numDListsCalled);
|
||||||
INCSTAT(stats.thisFrame.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.numCPLoadsInDL, stats.thisFrame.numCPLoads);
|
||||||
Xchg(stats.thisFrame.numBPLoadsInDL, stats.thisFrame.numBPLoads);
|
Xchg(stats.thisFrame.numBPLoadsInDL, stats.thisFrame.numBPLoads);
|
||||||
|
|
||||||
// reset to the old reader
|
// reset to the old pointer
|
||||||
g_pDataReader = pOldReader;
|
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)
|
bool FifoCommandRunnable(void)
|
||||||
{
|
{
|
||||||
u32 iBufferSize = FAKE_GetFifoSize();
|
u32 iBufferSize = (u32)(FAKE_GetFifoEndPtr()-g_pVideoData);
|
||||||
if (iBufferSize == 0)
|
if (iBufferSize == 0)
|
||||||
return false; // can't peek
|
return false; // can't peek
|
||||||
|
|
||||||
u8 Cmd = PeekFifo8(0);
|
u8 Cmd = DataPeek8(0);
|
||||||
u32 iCommandSize = 0;
|
u32 iCommandSize = 0;
|
||||||
|
|
||||||
switch(Cmd)
|
switch(Cmd)
|
||||||
|
@ -165,7 +143,7 @@ bool FifoCommandRunnable(void)
|
||||||
if (iBufferSize >= 5)
|
if (iBufferSize >= 5)
|
||||||
{
|
{
|
||||||
iCommandSize = 1 + 4;
|
iCommandSize = 1 + 4;
|
||||||
u32 Cmd2 = PeekFifo32(1);
|
u32 Cmd2 = DataPeek32(1);
|
||||||
int dwTransferSize = ((Cmd2 >> 16) & 15) + 1;
|
int dwTransferSize = ((Cmd2 >> 16) & 15) + 1;
|
||||||
iCommandSize += dwTransferSize * 4;
|
iCommandSize += dwTransferSize * 4;
|
||||||
}
|
}
|
||||||
|
@ -183,7 +161,7 @@ bool FifoCommandRunnable(void)
|
||||||
if (iBufferSize >= 3)
|
if (iBufferSize >= 3)
|
||||||
{
|
{
|
||||||
iCommandSize = 1 + 2;
|
iCommandSize = 1 + 2;
|
||||||
u16 numVertices = PeekFifo16(1);
|
u16 numVertices = DataPeek16(1);
|
||||||
VertexLoader& vtxLoader = g_VertexLoaders[Cmd & GX_VAT_MASK];
|
VertexLoader& vtxLoader = g_VertexLoaders[Cmd & GX_VAT_MASK];
|
||||||
vtxLoader.Setup();
|
vtxLoader.Setup();
|
||||||
int vsize = vtxLoader.GetVertexSize();
|
int vsize = vtxLoader.GetVertexSize();
|
||||||
|
@ -254,7 +232,7 @@ bool FifoCommandRunnable(void)
|
||||||
|
|
||||||
void Decode(void)
|
void Decode(void)
|
||||||
{
|
{
|
||||||
int Cmd = g_pDataReader->Read8();
|
int Cmd = DataReadU8();
|
||||||
switch(Cmd)
|
switch(Cmd)
|
||||||
{
|
{
|
||||||
case GX_NOP:
|
case GX_NOP:
|
||||||
|
@ -262,42 +240,42 @@ void Decode(void)
|
||||||
|
|
||||||
case GX_LOAD_CP_REG: //0x08
|
case GX_LOAD_CP_REG: //0x08
|
||||||
{
|
{
|
||||||
u32 SubCmd = g_pDataReader->Read8();
|
u32 SubCmd = DataReadU8();
|
||||||
u32 Value = g_pDataReader->Read32();
|
u32 Value = DataReadU32();
|
||||||
LoadCPReg(SubCmd,Value);
|
LoadCPReg(SubCmd,Value);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GX_LOAD_XF_REG:
|
case GX_LOAD_XF_REG:
|
||||||
{
|
{
|
||||||
u32 Cmd2 = g_pDataReader->Read32();
|
u32 Cmd2 = DataReadU32();
|
||||||
|
|
||||||
int dwTransferSize = ((Cmd2>>16)&15) + 1;
|
int dwTransferSize = ((Cmd2>>16)&15) + 1;
|
||||||
u32 dwAddress = Cmd2 & 0xFFFF;
|
u32 dwAddress = Cmd2 & 0xFFFF;
|
||||||
static u32 pData[16];
|
static u32 pData[16];
|
||||||
for (int i=0; i<dwTransferSize; i++)
|
for (int i=0; i<dwTransferSize; i++)
|
||||||
pData[i] = g_pDataReader->Read32();
|
pData[i] = DataReadU32();
|
||||||
LoadXFReg(dwTransferSize,dwAddress,pData);
|
LoadXFReg(dwTransferSize,dwAddress,pData);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GX_LOAD_INDX_A: //used for position matrices
|
case GX_LOAD_INDX_A: //used for position matrices
|
||||||
LoadIndexedXF(g_pDataReader->Read32(),0xC);
|
LoadIndexedXF(DataReadU32(),0xC);
|
||||||
break;
|
break;
|
||||||
case GX_LOAD_INDX_B: //used for normal matrices
|
case GX_LOAD_INDX_B: //used for normal matrices
|
||||||
LoadIndexedXF(g_pDataReader->Read32(),0xD);
|
LoadIndexedXF(DataReadU32(),0xD);
|
||||||
break;
|
break;
|
||||||
case GX_LOAD_INDX_C: //used for postmatrices
|
case GX_LOAD_INDX_C: //used for postmatrices
|
||||||
LoadIndexedXF(g_pDataReader->Read32(),0xE);
|
LoadIndexedXF(DataReadU32(),0xE);
|
||||||
break;
|
break;
|
||||||
case GX_LOAD_INDX_D: //used for lights
|
case GX_LOAD_INDX_D: //used for lights
|
||||||
LoadIndexedXF(g_pDataReader->Read32(),0xF);
|
LoadIndexedXF(DataReadU32(),0xF);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GX_CMD_CALL_DL:
|
case GX_CMD_CALL_DL:
|
||||||
{
|
{
|
||||||
u32 dwAddr = g_pDataReader->Read32();
|
u32 dwAddr = DataReadU32();
|
||||||
u32 dwCount = g_pDataReader->Read32();
|
u32 dwCount = DataReadU32();
|
||||||
ExecuteDisplayList(dwAddr, dwCount);
|
ExecuteDisplayList(dwAddr, dwCount);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -312,7 +290,7 @@ void Decode(void)
|
||||||
|
|
||||||
case GX_LOAD_BP_REG: //0x61
|
case GX_LOAD_BP_REG: //0x61
|
||||||
{
|
{
|
||||||
u32 cmd = g_pDataReader->Read32();
|
u32 cmd = DataReadU32();
|
||||||
LoadBPReg(cmd);
|
LoadBPReg(cmd);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -322,7 +300,7 @@ void Decode(void)
|
||||||
if (Cmd&0x80)
|
if (Cmd&0x80)
|
||||||
{
|
{
|
||||||
// load vertices
|
// load vertices
|
||||||
u16 numVertices = g_pDataReader->Read16();
|
u16 numVertices = DataReadU16();
|
||||||
tempvarray.Reset();
|
tempvarray.Reset();
|
||||||
VertexLoader::SetVArray(&tempvarray);
|
VertexLoader::SetVArray(&tempvarray);
|
||||||
VertexLoader& vtxLoader = g_VertexLoaders[Cmd & GX_VAT_MASK];
|
VertexLoader& vtxLoader = g_VertexLoaders[Cmd & GX_VAT_MASK];
|
||||||
|
@ -371,7 +349,7 @@ void Decode(void)
|
||||||
|
|
||||||
void OpcodeDecoder_Init()
|
void OpcodeDecoder_Init()
|
||||||
{
|
{
|
||||||
g_pDataReader = &g_fifoReader;
|
g_pVideoData = FAKE_GetFifoStartPtr();
|
||||||
tempvarray.Create(65536*3, 1, 8, 3, 2, 8);
|
tempvarray.Create(65536*3, 1, 8, 3, 2, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,29 +69,6 @@ void VertexLoader::SetVArray(DecodedVArray *_varray)
|
||||||
varray = _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_MtxIndex.h"
|
||||||
#include "VertexLoader_Position.h"
|
#include "VertexLoader_Position.h"
|
||||||
#include "VertexLoader_Normal.h"
|
#include "VertexLoader_Normal.h"
|
||||||
|
|
|
@ -45,6 +45,7 @@ int ComputeVertexSize(u32 components);
|
||||||
|
|
||||||
#include "CPStructs.h"
|
#include "CPStructs.h"
|
||||||
#include "DecodedVArray.h"
|
#include "DecodedVArray.h"
|
||||||
|
#include "DataReader.h"
|
||||||
|
|
||||||
#define LOADERDECL __cdecl
|
#define LOADERDECL __cdecl
|
||||||
typedef void (LOADERDECL *TPipelineFunction)(void*);
|
typedef void (LOADERDECL *TPipelineFunction)(void*);
|
||||||
|
@ -215,10 +216,6 @@ public:
|
||||||
|
|
||||||
extern VertexLoader g_VertexLoaders[8];
|
extern VertexLoader g_VertexLoaders[8];
|
||||||
extern DecodedVArray* varray;
|
extern DecodedVArray* varray;
|
||||||
extern inline u8 ReadBuffer8();
|
|
||||||
extern inline u16 ReadBuffer16();
|
|
||||||
extern inline u32 ReadBuffer32();
|
|
||||||
extern inline float ReadBuffer32F();
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -84,32 +84,32 @@ inline u32 _Read32(u32 iAddress)
|
||||||
|
|
||||||
void LOADERDECL Color_ReadDirect_24b_888(void* _p)
|
void LOADERDECL Color_ReadDirect_24b_888(void* _p)
|
||||||
{
|
{
|
||||||
u32 col = ReadBuffer8()<<RSHIFT;
|
u32 col = DataReadU8()<<RSHIFT;
|
||||||
col |= ReadBuffer8()<<GSHIFT;
|
col |= DataReadU8()<<GSHIFT;
|
||||||
col |= ReadBuffer8()<<BSHIFT;
|
col |= DataReadU8()<<BSHIFT;
|
||||||
_SetCol(col | (0xFF<<ASHIFT));
|
_SetCol(col | (0xFF<<ASHIFT));
|
||||||
}
|
}
|
||||||
|
|
||||||
void LOADERDECL Color_ReadDirect_32b_888x(void* _p){
|
void LOADERDECL Color_ReadDirect_32b_888x(void* _p){
|
||||||
u32 col = ReadBuffer8()<<RSHIFT;
|
u32 col = DataReadU8()<<RSHIFT;
|
||||||
col |= ReadBuffer8()<<GSHIFT;
|
col |= DataReadU8()<<GSHIFT;
|
||||||
col |= ReadBuffer8()<<BSHIFT;
|
col |= DataReadU8()<<BSHIFT;
|
||||||
_SetCol(col | (0xFF<<ASHIFT));
|
_SetCol(col | (0xFF<<ASHIFT));
|
||||||
ReadBuffer8();
|
DataReadU8();
|
||||||
}
|
}
|
||||||
void LOADERDECL Color_ReadDirect_16b_565(void* _p)
|
void LOADERDECL Color_ReadDirect_16b_565(void* _p)
|
||||||
{
|
{
|
||||||
_SetCol565(ReadBuffer16());
|
_SetCol565(DataReadU16());
|
||||||
}
|
}
|
||||||
void LOADERDECL Color_ReadDirect_16b_4444(void *_p)
|
void LOADERDECL Color_ReadDirect_16b_4444(void *_p)
|
||||||
{
|
{
|
||||||
_SetCol4444(ReadBuffer16());
|
_SetCol4444(DataReadU16());
|
||||||
}
|
}
|
||||||
void LOADERDECL Color_ReadDirect_24b_6666(void* _p)
|
void LOADERDECL Color_ReadDirect_24b_6666(void* _p)
|
||||||
{
|
{
|
||||||
u32 val = ReadBuffer8()<<16;
|
u32 val = DataReadU8()<<16;
|
||||||
val|=ReadBuffer8()<<8;
|
val|=DataReadU8()<<8;
|
||||||
val|=ReadBuffer8();
|
val|=DataReadU8();
|
||||||
_SetCol6666(val);
|
_SetCol6666(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,10 +122,10 @@ void LOADERDECL Color_ReadDirect_24b_6666(void* _p)
|
||||||
//
|
//
|
||||||
void LOADERDECL Color_ReadDirect_32b_8888(void* _p)
|
void LOADERDECL Color_ReadDirect_32b_8888(void* _p)
|
||||||
{
|
{
|
||||||
u32 col = ReadBuffer8()<<RSHIFT;
|
u32 col = DataReadU8()<<RSHIFT;
|
||||||
col |= ReadBuffer8()<<GSHIFT;
|
col |= DataReadU8()<<GSHIFT;
|
||||||
col |= ReadBuffer8()<<BSHIFT;
|
col |= DataReadU8()<<BSHIFT;
|
||||||
col |= ReadBuffer8()<<ASHIFT;
|
col |= DataReadU8()<<ASHIFT;
|
||||||
|
|
||||||
// "kill" the alpha
|
// "kill" the alpha
|
||||||
if (!colElements[colIndex])
|
if (!colElements[colIndex])
|
||||||
|
@ -138,33 +138,33 @@ void LOADERDECL Color_ReadDirect_32b_8888(void* _p)
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
void LOADERDECL Color_ReadIndex8_16b_565(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]);
|
u32 iAddress = arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR+colIndex]);
|
||||||
u16 val = Memory_Read_U16(iAddress);
|
u16 val = Memory_Read_U16(iAddress);
|
||||||
_SetCol565(val);
|
_SetCol565(val);
|
||||||
}
|
}
|
||||||
void LOADERDECL Color_ReadIndex8_24b_888(void* _p)
|
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]);
|
u32 iAddress = arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR+colIndex]);
|
||||||
_SetCol(_Read24(iAddress));
|
_SetCol(_Read24(iAddress));
|
||||||
}
|
}
|
||||||
void LOADERDECL Color_ReadIndex8_32b_888x(void* _p)
|
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);
|
u32 iAddress = arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR]+colIndex);
|
||||||
_SetCol(_Read24(iAddress));
|
_SetCol(_Read24(iAddress));
|
||||||
}
|
}
|
||||||
void LOADERDECL Color_ReadIndex8_16b_4444(void* _p)
|
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]);
|
u32 iAddress = arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR+colIndex]);
|
||||||
u16 val = Memory_Read_U16(iAddress);
|
u16 val = Memory_Read_U16(iAddress);
|
||||||
_SetCol4444(val);
|
_SetCol4444(val);
|
||||||
}
|
}
|
||||||
void LOADERDECL Color_ReadIndex8_24b_6666(void* _p)
|
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 iAddress = arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR+colIndex]);
|
||||||
u32 val = Memory_Read_U8(iAddress+2) |
|
u32 val = Memory_Read_U8(iAddress+2) |
|
||||||
(Memory_Read_U8(iAddress+1)<<8) |
|
(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)
|
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]);
|
u32 iAddress = arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR+colIndex]);
|
||||||
_SetCol(_Read32(iAddress));
|
_SetCol(_Read32(iAddress));
|
||||||
}
|
}
|
||||||
|
@ -183,33 +183,33 @@ void LOADERDECL Color_ReadIndex8_32b_8888(void* _p)
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
void LOADERDECL Color_ReadIndex16_16b_565(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]);
|
u32 iAddress = arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR+colIndex]);
|
||||||
u16 val = Memory_Read_U16(iAddress);
|
u16 val = Memory_Read_U16(iAddress);
|
||||||
_SetCol565(val);
|
_SetCol565(val);
|
||||||
}
|
}
|
||||||
void LOADERDECL Color_ReadIndex16_24b_888(void* _p)
|
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]);
|
u32 iAddress = arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR+colIndex]);
|
||||||
_SetCol(_Read24(iAddress));
|
_SetCol(_Read24(iAddress));
|
||||||
}
|
}
|
||||||
void LOADERDECL Color_ReadIndex16_32b_888x(void* _p)
|
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]);
|
u32 iAddress = arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR+colIndex]);
|
||||||
_SetCol(_Read24(iAddress));
|
_SetCol(_Read24(iAddress));
|
||||||
}
|
}
|
||||||
void LOADERDECL Color_ReadIndex16_16b_4444(void* _p)
|
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]);
|
u32 iAddress = arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR+colIndex]);
|
||||||
u16 val = Memory_Read_U16(iAddress);
|
u16 val = Memory_Read_U16(iAddress);
|
||||||
_SetCol4444(val);
|
_SetCol4444(val);
|
||||||
}
|
}
|
||||||
void LOADERDECL Color_ReadIndex16_24b_6666(void* _p)
|
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 iAddress = arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR+colIndex]);
|
||||||
u32 val = Memory_Read_U8(iAddress+2) |
|
u32 val = Memory_Read_U8(iAddress+2) |
|
||||||
(Memory_Read_U8(iAddress+1)<<8) |
|
(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)
|
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]);
|
u32 iAddress = arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR+colIndex]);
|
||||||
_SetCol(_Read32(iAddress));
|
_SetCol(_Read32(iAddress));
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
void LOADERDECL PosMtx_ReadDirect_UByte(void* _p)
|
void LOADERDECL PosMtx_ReadDirect_UByte(void* _p)
|
||||||
{
|
{
|
||||||
TVtxAttr* pVtxAttr = (TVtxAttr*)_p;
|
TVtxAttr* pVtxAttr = (TVtxAttr*)_p;
|
||||||
int index = ReadBuffer8() & 0x3f;
|
int index = DataReadU8() & 0x3f;
|
||||||
float *flipmem = (float *)xfmem;
|
float *flipmem = (float *)xfmem;
|
||||||
varray->SetPosNrmIdx(index);
|
varray->SetPosNrmIdx(index);
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,6 @@ int s_texmtxread = 0, s_texmtxwrite = 0;
|
||||||
void LOADERDECL TexMtx_ReadDirect_UByte(void* _p)
|
void LOADERDECL TexMtx_ReadDirect_UByte(void* _p)
|
||||||
{
|
{
|
||||||
TVtxAttr* pVtxAttr = (TVtxAttr*)_p;
|
TVtxAttr* pVtxAttr = (TVtxAttr*)_p;
|
||||||
int index = ReadBuffer8() & 0x3f;
|
int index = DataReadU8() & 0x3f;
|
||||||
varray->SetTcIdx(s_texmtxread++, index);
|
varray->SetTcIdx(s_texmtxread++, index);
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,9 +130,9 @@ VertexLoader_Normal::GetFunction(unsigned int _type, unsigned int _format, unsig
|
||||||
void LOADERDECL
|
void LOADERDECL
|
||||||
VertexLoader_Normal::Normal_DirectByte(void* _p)
|
VertexLoader_Normal::Normal_DirectByte(void* _p)
|
||||||
{
|
{
|
||||||
varray->SetNormalX(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)ReadBuffer8()+0.5f) / 127.5f);
|
varray->SetNormalY(0, ((float)(signed char)DataReadU8()+0.5f) / 127.5f);
|
||||||
varray->SetNormalZ(0, ((float)(signed char)ReadBuffer8()+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
|
void LOADERDECL
|
||||||
VertexLoader_Normal::Normal_DirectShort(void* _p)
|
VertexLoader_Normal::Normal_DirectShort(void* _p)
|
||||||
{
|
{
|
||||||
varray->SetNormalX(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)ReadBuffer16()+0.5f) / 32767.5f);
|
varray->SetNormalY(0, ((float)(signed short)DataReadU16()+0.5f) / 32767.5f);
|
||||||
varray->SetNormalZ(0, ((float)(signed short)ReadBuffer16()+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
|
void LOADERDECL
|
||||||
VertexLoader_Normal::Normal_DirectFloat(void* _p)
|
VertexLoader_Normal::Normal_DirectFloat(void* _p)
|
||||||
{
|
{
|
||||||
varray->SetNormalX(0, ReadBuffer32F());
|
varray->SetNormalX(0, DataReadF32());
|
||||||
varray->SetNormalY(0, ReadBuffer32F());
|
varray->SetNormalY(0, DataReadF32());
|
||||||
varray->SetNormalZ(0, ReadBuffer32F());
|
varray->SetNormalZ(0, DataReadF32());
|
||||||
}
|
}
|
||||||
|
|
||||||
// __________________________________________________________________________________________________
|
// __________________________________________________________________________________________________
|
||||||
|
@ -165,9 +165,9 @@ VertexLoader_Normal::Normal_DirectByte3(void* _p)
|
||||||
{
|
{
|
||||||
for (int i=0; i<3; i++)
|
for (int i=0; i<3; i++)
|
||||||
{
|
{
|
||||||
varray->SetNormalX(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)ReadBuffer8()+0.5f) / 127.5f);
|
varray->SetNormalY(i, ((float)(signed char)DataReadU8()+0.5f) / 127.5f);
|
||||||
varray->SetNormalZ(i, ((float)(signed char)ReadBuffer8()+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++)
|
for (int i=0; i<3; i++)
|
||||||
{
|
{
|
||||||
varray->SetNormalX(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)ReadBuffer16()+0.5f) / 32767.5f);
|
varray->SetNormalY(i, ((float)(signed short)DataReadU16()+0.5f) / 32767.5f);
|
||||||
varray->SetNormalZ(i, ((float)(signed short)ReadBuffer16()+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++)
|
for (int i=0; i<3; i++)
|
||||||
{
|
{
|
||||||
varray->SetNormalX(i, ReadBuffer32F());
|
varray->SetNormalX(i, DataReadF32());
|
||||||
varray->SetNormalY(i, ReadBuffer32F());
|
varray->SetNormalY(i, DataReadF32());
|
||||||
varray->SetNormalZ(i, ReadBuffer32F());
|
varray->SetNormalZ(i, DataReadF32());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,7 +211,7 @@ VertexLoader_Normal::Normal_DirectFloat3(void* _p)
|
||||||
void LOADERDECL
|
void LOADERDECL
|
||||||
VertexLoader_Normal::Normal_Index8_Byte(void* _p)
|
VertexLoader_Normal::Normal_Index8_Byte(void* _p)
|
||||||
{
|
{
|
||||||
u8 Index = ReadBuffer8();
|
u8 Index = DataReadU8();
|
||||||
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]);
|
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]);
|
||||||
|
|
||||||
varray->SetNormalX(0, ((float)(signed char)Memory_Read_U8(iAddress )+0.5f) / 127.5f);
|
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
|
void LOADERDECL
|
||||||
VertexLoader_Normal::Normal_Index8_Short(void* _p)
|
VertexLoader_Normal::Normal_Index8_Short(void* _p)
|
||||||
{
|
{
|
||||||
u8 Index = ReadBuffer8();
|
u8 Index = DataReadU8();
|
||||||
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]);
|
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]);
|
||||||
|
|
||||||
varray->SetNormalX(0, ((float)(signed short)Memory_Read_U16(iAddress )+0.5f) / 32767.5f);
|
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
|
void LOADERDECL
|
||||||
VertexLoader_Normal::Normal_Index8_Float(void* _p)
|
VertexLoader_Normal::Normal_Index8_Float(void* _p)
|
||||||
{
|
{
|
||||||
u8 Index = ReadBuffer8();
|
u8 Index = DataReadU8();
|
||||||
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]);
|
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]);
|
||||||
|
|
||||||
varray->SetNormalX(0, Memory_Read_Float(iAddress));
|
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++)
|
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;
|
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);
|
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
|
else
|
||||||
{
|
{
|
||||||
u8 Index = ReadBuffer8();
|
u8 Index = DataReadU8();
|
||||||
for (int i=0; i<3; i++)
|
for (int i=0; i<3; i++)
|
||||||
{
|
{
|
||||||
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]) + 1*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++)
|
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;
|
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);
|
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
|
else
|
||||||
{
|
{
|
||||||
u8 Index = ReadBuffer8();
|
u8 Index = DataReadU8();
|
||||||
for (int i=0; i<3; i++)
|
for (int i=0; i<3; i++)
|
||||||
{
|
{
|
||||||
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]) + 2*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++)
|
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;
|
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]) + 4*3*i;
|
||||||
|
|
||||||
varray->SetNormalX(i, Memory_Read_Float(iAddress));
|
varray->SetNormalX(i, Memory_Read_Float(iAddress));
|
||||||
|
@ -331,7 +331,7 @@ VertexLoader_Normal::Normal_Index8_Float3(void* _p)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
u8 Index = ReadBuffer8();
|
u8 Index = DataReadU8();
|
||||||
for (int i=0; i<3; i++)
|
for (int i=0; i<3; i++)
|
||||||
{
|
{
|
||||||
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]) + 4*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
|
void LOADERDECL
|
||||||
VertexLoader_Normal::Normal_Index16_Byte(void* _p)
|
VertexLoader_Normal::Normal_Index16_Byte(void* _p)
|
||||||
{
|
{
|
||||||
u16 Index = ReadBuffer16();
|
u16 Index = DataReadU16();
|
||||||
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]);
|
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]);
|
||||||
|
|
||||||
varray->SetNormalX(0, ((float)(signed char)Memory_Read_U8(iAddress )+0.5f) / 127.5f);
|
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
|
void LOADERDECL
|
||||||
VertexLoader_Normal::Normal_Index16_Short(void* _p)
|
VertexLoader_Normal::Normal_Index16_Short(void* _p)
|
||||||
{
|
{
|
||||||
u16 Index = ReadBuffer16();
|
u16 Index = DataReadU16();
|
||||||
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]);
|
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]);
|
||||||
|
|
||||||
varray->SetNormalX(0, ((float)(signed short)Memory_Read_U16(iAddress )+0.5f) / 32767.5f);
|
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
|
void LOADERDECL
|
||||||
VertexLoader_Normal::Normal_Index16_Float(void* _p)
|
VertexLoader_Normal::Normal_Index16_Float(void* _p)
|
||||||
{
|
{
|
||||||
u16 Index = ReadBuffer16();
|
u16 Index = DataReadU16();
|
||||||
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]);
|
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]);
|
||||||
|
|
||||||
varray->SetNormalX(0, Memory_Read_Float(iAddress));
|
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++)
|
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;
|
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);
|
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
|
else
|
||||||
{
|
{
|
||||||
u16 Index = ReadBuffer16();
|
u16 Index = DataReadU16();
|
||||||
for (int i=0; i<3; i++)
|
for (int i=0; i<3; i++)
|
||||||
{
|
{
|
||||||
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]) + 1*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++)
|
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;
|
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);
|
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
|
else
|
||||||
{
|
{
|
||||||
u16 Index = ReadBuffer16();
|
u16 Index = DataReadU16();
|
||||||
for (int i=0; i<3; i++)
|
for (int i=0; i<3; i++)
|
||||||
{
|
{
|
||||||
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]) + 2*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++)
|
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;
|
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]) + 4*3*i;
|
||||||
|
|
||||||
varray->SetNormalX(i, Memory_Read_Float(iAddress ));
|
varray->SetNormalX(i, Memory_Read_Float(iAddress ));
|
||||||
|
@ -475,7 +475,7 @@ VertexLoader_Normal::Normal_Index16_Float3(void* _p)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
u16 Index = ReadBuffer16();
|
u16 Index = DataReadU16();
|
||||||
for (int i=0; i<3; i++)
|
for (int i=0; i<3; i++)
|
||||||
{
|
{
|
||||||
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]) + 4*3*i;
|
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]) + 4*3*i;
|
||||||
|
|
|
@ -66,11 +66,11 @@ void LOADERDECL _ReadPosFloatMem(int iAddress, TVtxAttr* pVtxAttr)
|
||||||
void LOADERDECL Pos_ReadDirect_UByte(void* _p)
|
void LOADERDECL Pos_ReadDirect_UByte(void* _p)
|
||||||
{
|
{
|
||||||
TVtxAttr* pVtxAttr = (TVtxAttr*)_p;
|
TVtxAttr* pVtxAttr = (TVtxAttr*)_p;
|
||||||
varray->SetPosX((float)ReadBuffer8() * posScale);
|
varray->SetPosX((float)DataReadU8() * posScale);
|
||||||
varray->SetPosY((float)ReadBuffer8() * posScale);
|
varray->SetPosY((float)DataReadU8() * posScale);
|
||||||
|
|
||||||
if (pVtxAttr->PosElements)
|
if (pVtxAttr->PosElements)
|
||||||
varray->SetPosZ((float)ReadBuffer8() * posScale);
|
varray->SetPosZ((float)DataReadU8() * posScale);
|
||||||
else
|
else
|
||||||
varray->SetPosZ(1.0);
|
varray->SetPosZ(1.0);
|
||||||
}
|
}
|
||||||
|
@ -78,11 +78,11 @@ void LOADERDECL Pos_ReadDirect_UByte(void* _p)
|
||||||
void LOADERDECL Pos_ReadDirect_Byte(void* _p)
|
void LOADERDECL Pos_ReadDirect_Byte(void* _p)
|
||||||
{
|
{
|
||||||
TVtxAttr* pVtxAttr = (TVtxAttr*)_p;
|
TVtxAttr* pVtxAttr = (TVtxAttr*)_p;
|
||||||
varray->SetPosX((float)(s8)ReadBuffer8() * posScale);
|
varray->SetPosX((float)(s8)DataReadU8() * posScale);
|
||||||
varray->SetPosY((float)(s8)ReadBuffer8() * posScale);
|
varray->SetPosY((float)(s8)DataReadU8() * posScale);
|
||||||
|
|
||||||
if (pVtxAttr->PosElements)
|
if (pVtxAttr->PosElements)
|
||||||
varray->SetPosZ((float)(s8)ReadBuffer8() * posScale);
|
varray->SetPosZ((float)(s8)DataReadU8() * posScale);
|
||||||
else
|
else
|
||||||
varray->SetPosZ(1.0);
|
varray->SetPosZ(1.0);
|
||||||
}
|
}
|
||||||
|
@ -91,11 +91,11 @@ void LOADERDECL Pos_ReadDirect_UShort(void* _p)
|
||||||
{
|
{
|
||||||
TVtxAttr* pVtxAttr = (TVtxAttr*)_p;
|
TVtxAttr* pVtxAttr = (TVtxAttr*)_p;
|
||||||
|
|
||||||
varray->SetPosX((float)ReadBuffer16() * posScale);
|
varray->SetPosX((float)DataReadU16() * posScale);
|
||||||
varray->SetPosY((float)ReadBuffer16() * posScale);
|
varray->SetPosY((float)DataReadU16() * posScale);
|
||||||
|
|
||||||
if (pVtxAttr->PosElements)
|
if (pVtxAttr->PosElements)
|
||||||
varray->SetPosZ((float)ReadBuffer16() * posScale);
|
varray->SetPosZ((float)DataReadU16() * posScale);
|
||||||
else
|
else
|
||||||
varray->SetPosZ(1.0);
|
varray->SetPosZ(1.0);
|
||||||
}
|
}
|
||||||
|
@ -104,11 +104,11 @@ void LOADERDECL Pos_ReadDirect_Short(void* _p)
|
||||||
{
|
{
|
||||||
TVtxAttr* pVtxAttr = (TVtxAttr*)_p;
|
TVtxAttr* pVtxAttr = (TVtxAttr*)_p;
|
||||||
|
|
||||||
varray->SetPosX((float)(s16)ReadBuffer16() * posScale);
|
varray->SetPosX((float)(s16)DataReadU16() * posScale);
|
||||||
varray->SetPosY((float)(s16)ReadBuffer16() * posScale);
|
varray->SetPosY((float)(s16)DataReadU16() * posScale);
|
||||||
|
|
||||||
if (pVtxAttr->PosElements)
|
if (pVtxAttr->PosElements)
|
||||||
varray->SetPosZ((float)(s16)ReadBuffer16() * posScale);
|
varray->SetPosZ((float)(s16)DataReadU16() * posScale);
|
||||||
else
|
else
|
||||||
varray->SetPosZ(1.0);
|
varray->SetPosZ(1.0);
|
||||||
}
|
}
|
||||||
|
@ -117,11 +117,11 @@ void LOADERDECL Pos_ReadDirect_Float(void* _p)
|
||||||
{
|
{
|
||||||
TVtxAttr* pVtxAttr = (TVtxAttr*)_p;
|
TVtxAttr* pVtxAttr = (TVtxAttr*)_p;
|
||||||
|
|
||||||
varray->SetPosX(ReadBuffer32F());
|
varray->SetPosX(DataReadF32());
|
||||||
varray->SetPosY(ReadBuffer32F());
|
varray->SetPosY(DataReadF32());
|
||||||
|
|
||||||
if (pVtxAttr->PosElements)
|
if (pVtxAttr->PosElements)
|
||||||
varray->SetPosZ(ReadBuffer32F());
|
varray->SetPosZ(DataReadF32());
|
||||||
else
|
else
|
||||||
varray->SetPosZ(1.0);
|
varray->SetPosZ(1.0);
|
||||||
}
|
}
|
||||||
|
@ -133,14 +133,14 @@ void LOADERDECL Pos_ReadDirect_Float(void* _p)
|
||||||
void LOADERDECL Pos_ReadIndex8_UByte(void* _p)
|
void LOADERDECL Pos_ReadIndex8_UByte(void* _p)
|
||||||
{
|
{
|
||||||
TVtxAttr* pVtxAttr = (TVtxAttr*)_p;
|
TVtxAttr* pVtxAttr = (TVtxAttr*)_p;
|
||||||
u8 Index = ReadBuffer8();
|
u8 Index = DataReadU8();
|
||||||
u32 iAddress = arraybases[ARRAY_POSITION] + (Index * arraystrides[ARRAY_POSITION]);
|
u32 iAddress = arraybases[ARRAY_POSITION] + (Index * arraystrides[ARRAY_POSITION]);
|
||||||
_ReadPos8Mem<u8>(iAddress, pVtxAttr);
|
_ReadPos8Mem<u8>(iAddress, pVtxAttr);
|
||||||
}
|
}
|
||||||
void LOADERDECL Pos_ReadIndex8_Byte(void* _p)
|
void LOADERDECL Pos_ReadIndex8_Byte(void* _p)
|
||||||
{
|
{
|
||||||
TVtxAttr* pVtxAttr = (TVtxAttr*)_p;
|
TVtxAttr* pVtxAttr = (TVtxAttr*)_p;
|
||||||
u8 Index = ReadBuffer8();
|
u8 Index = DataReadU8();
|
||||||
u32 iAddress = arraybases[ARRAY_POSITION] + (Index * arraystrides[ARRAY_POSITION]);
|
u32 iAddress = arraybases[ARRAY_POSITION] + (Index * arraystrides[ARRAY_POSITION]);
|
||||||
_ReadPos8Mem<s8>(iAddress, pVtxAttr);
|
_ReadPos8Mem<s8>(iAddress, pVtxAttr);
|
||||||
}
|
}
|
||||||
|
@ -148,7 +148,7 @@ void LOADERDECL Pos_ReadIndex8_Byte(void* _p)
|
||||||
void LOADERDECL Pos_ReadIndex8_UShort(void* _p)
|
void LOADERDECL Pos_ReadIndex8_UShort(void* _p)
|
||||||
{
|
{
|
||||||
TVtxAttr* pVtxAttr = (TVtxAttr*)_p;
|
TVtxAttr* pVtxAttr = (TVtxAttr*)_p;
|
||||||
u8 Index = ReadBuffer8();
|
u8 Index = DataReadU8();
|
||||||
u32 iAddress = arraybases[ARRAY_POSITION] + (Index * arraystrides[ARRAY_POSITION]);
|
u32 iAddress = arraybases[ARRAY_POSITION] + (Index * arraystrides[ARRAY_POSITION]);
|
||||||
_ReadPos16Mem<u16>(iAddress, pVtxAttr);
|
_ReadPos16Mem<u16>(iAddress, pVtxAttr);
|
||||||
}
|
}
|
||||||
|
@ -156,7 +156,7 @@ void LOADERDECL Pos_ReadIndex8_UShort(void* _p)
|
||||||
void LOADERDECL Pos_ReadIndex8_Short(void* _p)
|
void LOADERDECL Pos_ReadIndex8_Short(void* _p)
|
||||||
{
|
{
|
||||||
TVtxAttr* pVtxAttr = (TVtxAttr*)_p;
|
TVtxAttr* pVtxAttr = (TVtxAttr*)_p;
|
||||||
u8 Index = ReadBuffer8();
|
u8 Index = DataReadU8();
|
||||||
u32 iAddress = arraybases[ARRAY_POSITION] + (Index * arraystrides[ARRAY_POSITION]);
|
u32 iAddress = arraybases[ARRAY_POSITION] + (Index * arraystrides[ARRAY_POSITION]);
|
||||||
_ReadPos16Mem<s16>(iAddress, pVtxAttr);
|
_ReadPos16Mem<s16>(iAddress, pVtxAttr);
|
||||||
}
|
}
|
||||||
|
@ -164,7 +164,7 @@ void LOADERDECL Pos_ReadIndex8_Short(void* _p)
|
||||||
void LOADERDECL Pos_ReadIndex8_Float(void* _p)
|
void LOADERDECL Pos_ReadIndex8_Float(void* _p)
|
||||||
{
|
{
|
||||||
TVtxAttr* pVtxAttr = (TVtxAttr*)_p;
|
TVtxAttr* pVtxAttr = (TVtxAttr*)_p;
|
||||||
u8 Index = ReadBuffer8();
|
u8 Index = DataReadU8();
|
||||||
u32 iAddress = arraybases[ARRAY_POSITION] + (Index * arraystrides[ARRAY_POSITION]);
|
u32 iAddress = arraybases[ARRAY_POSITION] + (Index * arraystrides[ARRAY_POSITION]);
|
||||||
_ReadPosFloatMem(iAddress, pVtxAttr);
|
_ReadPosFloatMem(iAddress, pVtxAttr);
|
||||||
}
|
}
|
||||||
|
@ -175,21 +175,21 @@ void LOADERDECL Pos_ReadIndex8_Float(void* _p)
|
||||||
|
|
||||||
void LOADERDECL Pos_ReadIndex16_UByte(void* _p){
|
void LOADERDECL Pos_ReadIndex16_UByte(void* _p){
|
||||||
TVtxAttr* pVtxAttr = (TVtxAttr*)_p;
|
TVtxAttr* pVtxAttr = (TVtxAttr*)_p;
|
||||||
u16 Index = ReadBuffer16();
|
u16 Index = DataReadU16();
|
||||||
u32 iAddress = arraybases[ARRAY_POSITION] + (Index * arraystrides[ARRAY_POSITION]);
|
u32 iAddress = arraybases[ARRAY_POSITION] + (Index * arraystrides[ARRAY_POSITION]);
|
||||||
_ReadPos8Mem<u8>(iAddress, pVtxAttr);
|
_ReadPos8Mem<u8>(iAddress, pVtxAttr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LOADERDECL Pos_ReadIndex16_Byte(void* _p){
|
void LOADERDECL Pos_ReadIndex16_Byte(void* _p){
|
||||||
TVtxAttr* pVtxAttr = (TVtxAttr*)_p;
|
TVtxAttr* pVtxAttr = (TVtxAttr*)_p;
|
||||||
u16 Index = ReadBuffer16();
|
u16 Index = DataReadU16();
|
||||||
u32 iAddress = arraybases[ARRAY_POSITION] + (Index * arraystrides[ARRAY_POSITION]);
|
u32 iAddress = arraybases[ARRAY_POSITION] + (Index * arraystrides[ARRAY_POSITION]);
|
||||||
_ReadPos8Mem<s8>(iAddress, pVtxAttr);
|
_ReadPos8Mem<s8>(iAddress, pVtxAttr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LOADERDECL Pos_ReadIndex16_UShort(void* _p){
|
void LOADERDECL Pos_ReadIndex16_UShort(void* _p){
|
||||||
TVtxAttr* pVtxAttr = (TVtxAttr*)_p;
|
TVtxAttr* pVtxAttr = (TVtxAttr*)_p;
|
||||||
u16 Index = ReadBuffer16();
|
u16 Index = DataReadU16();
|
||||||
u32 iAddress = arraybases[ARRAY_POSITION] + (Index * arraystrides[ARRAY_POSITION]);
|
u32 iAddress = arraybases[ARRAY_POSITION] + (Index * arraystrides[ARRAY_POSITION]);
|
||||||
_ReadPos16Mem<u16>(iAddress, pVtxAttr);
|
_ReadPos16Mem<u16>(iAddress, pVtxAttr);
|
||||||
}
|
}
|
||||||
|
@ -197,7 +197,7 @@ void LOADERDECL Pos_ReadIndex16_UShort(void* _p){
|
||||||
void LOADERDECL Pos_ReadIndex16_Short(void* _p)
|
void LOADERDECL Pos_ReadIndex16_Short(void* _p)
|
||||||
{
|
{
|
||||||
TVtxAttr* pVtxAttr = (TVtxAttr*)_p;
|
TVtxAttr* pVtxAttr = (TVtxAttr*)_p;
|
||||||
u16 Index = ReadBuffer16();
|
u16 Index = DataReadU16();
|
||||||
u32 iAddress = arraybases[ARRAY_POSITION] + (Index * arraystrides[ARRAY_POSITION]);
|
u32 iAddress = arraybases[ARRAY_POSITION] + (Index * arraystrides[ARRAY_POSITION]);
|
||||||
_ReadPos16Mem<s16>(iAddress, pVtxAttr);
|
_ReadPos16Mem<s16>(iAddress, pVtxAttr);
|
||||||
}
|
}
|
||||||
|
@ -205,7 +205,7 @@ void LOADERDECL Pos_ReadIndex16_Short(void* _p)
|
||||||
void LOADERDECL Pos_ReadIndex16_Float(void* _p)
|
void LOADERDECL Pos_ReadIndex16_Float(void* _p)
|
||||||
{
|
{
|
||||||
TVtxAttr* pVtxAttr = (TVtxAttr*)_p;
|
TVtxAttr* pVtxAttr = (TVtxAttr*)_p;
|
||||||
u16 Index = ReadBuffer16();
|
u16 Index = DataReadU16();
|
||||||
u32 iAddress = arraybases[ARRAY_POSITION] + (Index * arraystrides[ARRAY_POSITION]);
|
u32 iAddress = arraybases[ARRAY_POSITION] + (Index * arraystrides[ARRAY_POSITION]);
|
||||||
_ReadPosFloatMem(iAddress, pVtxAttr);
|
_ReadPosFloatMem(iAddress, pVtxAttr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,47 +22,47 @@ extern int tcIndex;
|
||||||
|
|
||||||
void LOADERDECL TexCoord_ReadDirect_UByte(void* _p)
|
void LOADERDECL TexCoord_ReadDirect_UByte(void* _p)
|
||||||
{
|
{
|
||||||
varray->SetU(tcIndex, ReadBuffer8() * tcScaleU[tcIndex]);
|
varray->SetU(tcIndex, DataReadU8() * tcScaleU[tcIndex]);
|
||||||
if (tcElements[tcIndex])
|
if (tcElements[tcIndex])
|
||||||
varray->SetV(tcIndex, ReadBuffer8() * tcScaleV[tcIndex]);
|
varray->SetV(tcIndex, DataReadU8() * tcScaleV[tcIndex]);
|
||||||
tcIndex++;
|
tcIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LOADERDECL TexCoord_ReadDirect_Byte(void* _p)
|
void LOADERDECL TexCoord_ReadDirect_Byte(void* _p)
|
||||||
{
|
{
|
||||||
varray->SetU(tcIndex, (s8)ReadBuffer8() * tcScaleU[tcIndex]);
|
varray->SetU(tcIndex, (s8)DataReadU8() * tcScaleU[tcIndex]);
|
||||||
if (tcElements[tcIndex])
|
if (tcElements[tcIndex])
|
||||||
varray->SetV(tcIndex, (s8)ReadBuffer8() * tcScaleV[tcIndex]);
|
varray->SetV(tcIndex, (s8)DataReadU8() * tcScaleV[tcIndex]);
|
||||||
tcIndex++;
|
tcIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LOADERDECL TexCoord_ReadDirect_UShort(void* _p)
|
void LOADERDECL TexCoord_ReadDirect_UShort(void* _p)
|
||||||
{
|
{
|
||||||
varray->SetU(tcIndex, ReadBuffer16() * tcScaleU[tcIndex]);
|
varray->SetU(tcIndex, DataReadU16() * tcScaleU[tcIndex]);
|
||||||
if (tcElements[tcIndex])
|
if (tcElements[tcIndex])
|
||||||
varray->SetV(tcIndex, ReadBuffer16() * tcScaleV[tcIndex]);
|
varray->SetV(tcIndex, DataReadU16() * tcScaleV[tcIndex]);
|
||||||
tcIndex++;
|
tcIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LOADERDECL TexCoord_ReadDirect_Short(void* _p)
|
void LOADERDECL TexCoord_ReadDirect_Short(void* _p)
|
||||||
{
|
{
|
||||||
varray->SetU(tcIndex, (s16)ReadBuffer16() * tcScaleU[tcIndex]);
|
varray->SetU(tcIndex, (s16)DataReadU16() * tcScaleU[tcIndex]);
|
||||||
if (tcElements[tcIndex])
|
if (tcElements[tcIndex])
|
||||||
varray->SetV(tcIndex, (s16)ReadBuffer16() * tcScaleV[tcIndex]);
|
varray->SetV(tcIndex, (s16)DataReadU16() * tcScaleV[tcIndex]);
|
||||||
tcIndex++;
|
tcIndex++;
|
||||||
}
|
}
|
||||||
void LOADERDECL TexCoord_ReadDirect_Float(void* _p)
|
void LOADERDECL TexCoord_ReadDirect_Float(void* _p)
|
||||||
{
|
{
|
||||||
varray->SetU(tcIndex, ReadBuffer32F() * tcScaleU[tcIndex]);
|
varray->SetU(tcIndex, DataReadF32() * tcScaleU[tcIndex]);
|
||||||
if (tcElements[tcIndex])
|
if (tcElements[tcIndex])
|
||||||
varray->SetV(tcIndex, ReadBuffer32F() * tcScaleV[tcIndex]);
|
varray->SetV(tcIndex, DataReadF32() * tcScaleV[tcIndex]);
|
||||||
tcIndex++;
|
tcIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==================================================================================
|
// ==================================================================================
|
||||||
void LOADERDECL TexCoord_ReadIndex8_UByte(void* _p)
|
void LOADERDECL TexCoord_ReadIndex8_UByte(void* _p)
|
||||||
{
|
{
|
||||||
u8 Index = ReadBuffer8();
|
u8 Index = DataReadU8();
|
||||||
u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
|
u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
|
||||||
|
|
||||||
varray->SetU(tcIndex, (float)(u8)Memory_Read_U8(iAddress) * tcScaleU[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)
|
void LOADERDECL TexCoord_ReadIndex8_Byte(void* _p)
|
||||||
{
|
{
|
||||||
u8 Index = ReadBuffer8();
|
u8 Index = DataReadU8();
|
||||||
u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
|
u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
|
||||||
|
|
||||||
varray->SetU(tcIndex, (float)(s8)Memory_Read_U8(iAddress) * tcScaleU[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)
|
void LOADERDECL TexCoord_ReadIndex8_UShort(void* _p)
|
||||||
{
|
{
|
||||||
u8 Index = ReadBuffer8();
|
u8 Index = DataReadU8();
|
||||||
u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
|
u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
|
||||||
|
|
||||||
varray->SetU(tcIndex, (float)(u16)Memory_Read_U16(iAddress) * tcScaleU[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)
|
void LOADERDECL TexCoord_ReadIndex8_Short(void* _p)
|
||||||
{
|
{
|
||||||
u8 Index = ReadBuffer8();
|
u8 Index = DataReadU8();
|
||||||
u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
|
u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
|
||||||
|
|
||||||
varray->SetU(tcIndex, (float)(s16)Memory_Read_U16(iAddress) * tcScaleU[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)
|
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 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
|
||||||
u32 uTemp;
|
u32 uTemp;
|
||||||
uTemp = Memory_Read_U32(iAddress );
|
uTemp = Memory_Read_U32(iAddress );
|
||||||
|
@ -120,7 +120,7 @@ void LOADERDECL TexCoord_ReadIndex8_Float(void* _p)
|
||||||
// ==================================================================================
|
// ==================================================================================
|
||||||
void LOADERDECL TexCoord_ReadIndex16_UByte(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 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
|
||||||
|
|
||||||
u32 uTemp;
|
u32 uTemp;
|
||||||
|
@ -136,7 +136,7 @@ void LOADERDECL TexCoord_ReadIndex16_UByte(void* _p)
|
||||||
}
|
}
|
||||||
void LOADERDECL TexCoord_ReadIndex16_Byte(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 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
|
||||||
|
|
||||||
u32 uTemp;
|
u32 uTemp;
|
||||||
|
@ -154,7 +154,7 @@ void LOADERDECL TexCoord_ReadIndex16_Byte(void* _p)
|
||||||
void LOADERDECL TexCoord_ReadIndex16_UShort(void* _p)
|
void LOADERDECL TexCoord_ReadIndex16_UShort(void* _p)
|
||||||
{
|
{
|
||||||
TVtxAttr* pVtxAttr = (TVtxAttr*)_p;
|
TVtxAttr* pVtxAttr = (TVtxAttr*)_p;
|
||||||
u16 Index = ReadBuffer16();
|
u16 Index = DataReadU16();
|
||||||
u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
|
u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
|
||||||
|
|
||||||
float uTemp;
|
float uTemp;
|
||||||
|
@ -170,7 +170,7 @@ void LOADERDECL TexCoord_ReadIndex16_UShort(void* _p)
|
||||||
}
|
}
|
||||||
void LOADERDECL TexCoord_ReadIndex16_Short(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]);
|
u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
|
||||||
|
|
||||||
float uTemp;
|
float uTemp;
|
||||||
|
@ -186,7 +186,7 @@ void LOADERDECL TexCoord_ReadIndex16_Short(void* _p)
|
||||||
}
|
}
|
||||||
void LOADERDECL TexCoord_ReadIndex16_Float(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 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
|
||||||
u32 uTemp;
|
u32 uTemp;
|
||||||
uTemp = Memory_Read_U32(iAddress );
|
uTemp = Memory_Read_U32(iAddress );
|
||||||
|
|
|
@ -206,8 +206,8 @@ void Video_Prepare(void)
|
||||||
|
|
||||||
BPInit();
|
BPInit();
|
||||||
CVertexHandler::Init();
|
CVertexHandler::Init();
|
||||||
OpcodeDecoder_Init();
|
|
||||||
Fifo_Init();
|
Fifo_Init();
|
||||||
|
OpcodeDecoder_Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Video_Shutdown(void)
|
void Video_Shutdown(void)
|
||||||
|
|
|
@ -728,14 +728,6 @@
|
||||||
RelativePath=".\Src\BPStructs.h"
|
RelativePath=".\Src\BPStructs.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath=".\Src\DataReader.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\Src\DataReader.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath=".\Src\OpcodeDecoding.cpp"
|
RelativePath=".\Src\OpcodeDecoding.cpp"
|
||||||
>
|
>
|
||||||
|
|
|
@ -1,122 +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 "Globals.h"
|
|
||||||
#include "DataReader.h"
|
|
||||||
|
|
||||||
#if !defined(DATAREADER_INLINE) || defined(DATAREADER_DEBUG)
|
|
||||||
// =================================================================================================
|
|
||||||
// CDataReader_Fifo
|
|
||||||
// =================================================================================================
|
|
||||||
|
|
||||||
IDataReader* g_pDataReader = NULL;
|
|
||||||
extern u8 FAKE_ReadFifo8();
|
|
||||||
extern u16 FAKE_ReadFifo16();
|
|
||||||
extern u32 FAKE_ReadFifo32();
|
|
||||||
extern int FAKE_GetPosition();
|
|
||||||
extern u8* FAKE_GetFifoCurrentPtr();
|
|
||||||
extern void FAKE_SkipFifo(u32 skip);
|
|
||||||
|
|
||||||
IDataReader::~IDataReader()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
CDataReader_Fifo::CDataReader_Fifo(void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
u8 CDataReader_Fifo::Read8(void)
|
|
||||||
{
|
|
||||||
return FAKE_ReadFifo8();
|
|
||||||
};
|
|
||||||
|
|
||||||
u16 CDataReader_Fifo::Read16(void)
|
|
||||||
{
|
|
||||||
return FAKE_ReadFifo16();
|
|
||||||
};
|
|
||||||
|
|
||||||
u32 CDataReader_Fifo::Read32(void)
|
|
||||||
{
|
|
||||||
return FAKE_ReadFifo32();
|
|
||||||
};
|
|
||||||
|
|
||||||
void CDataReader_Fifo::Skip(u32 skip)
|
|
||||||
{
|
|
||||||
return FAKE_SkipFifo(skip);
|
|
||||||
}
|
|
||||||
|
|
||||||
int CDataReader_Fifo::GetPosition()
|
|
||||||
{
|
|
||||||
return FAKE_GetPosition();
|
|
||||||
}
|
|
||||||
u8* CDataReader_Fifo::GetRealCurrentPtr()
|
|
||||||
{
|
|
||||||
return FAKE_GetFifoCurrentPtr();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// =================================================================================================
|
|
||||||
// CDataReader_Memory
|
|
||||||
// =================================================================================================
|
|
||||||
|
|
||||||
CDataReader_Memory::CDataReader_Memory(u32 _uAddress) :
|
|
||||||
m_uReadAddress(_uAddress)
|
|
||||||
{
|
|
||||||
//m_pMemory = g_VideoInitialize.pGetMemoryPointer(0x00);
|
|
||||||
}
|
|
||||||
|
|
||||||
u32 CDataReader_Memory::GetReadAddress()
|
|
||||||
{
|
|
||||||
return m_uReadAddress;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CDataReader_Memory::GetPosition()
|
|
||||||
{
|
|
||||||
return m_uReadAddress;
|
|
||||||
}
|
|
||||||
|
|
||||||
u8 CDataReader_Memory::Read8()
|
|
||||||
{
|
|
||||||
u8 tmp = Memory_Read_U8(m_uReadAddress);//m_pMemory[m_uReadAddress];
|
|
||||||
m_uReadAddress++;
|
|
||||||
return tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
u16 CDataReader_Memory::Read16()
|
|
||||||
{
|
|
||||||
u16 tmp = Memory_Read_U16(m_uReadAddress);//_byteswap_ushort(*(u16*)&m_pMemory[m_uReadAddress]);
|
|
||||||
m_uReadAddress += 2;
|
|
||||||
return tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
u32 CDataReader_Memory::Read32()
|
|
||||||
{
|
|
||||||
u32 tmp = Memory_Read_U32(m_uReadAddress);//_byteswap_ulong(*(u32*)&m_pMemory[m_uReadAddress]);
|
|
||||||
m_uReadAddress += 4;
|
|
||||||
return tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CDataReader_Memory::Skip(u32 skip)
|
|
||||||
{
|
|
||||||
m_uReadAddress += skip;
|
|
||||||
}
|
|
||||||
|
|
||||||
u8* CDataReader_Memory::GetRealCurrentPtr()
|
|
||||||
{
|
|
||||||
return Memory_GetPtr(m_uReadAddress);
|
|
||||||
}
|
|
||||||
#endif
|
|
|
@ -1,218 +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
|
|
||||||
|
|
||||||
#include "Fifo.h"
|
|
||||||
|
|
||||||
|
|
||||||
#if !defined(DATAREADER_INLINE) || defined(DATAREADER_DEBUG)
|
|
||||||
// =================================================================================================
|
|
||||||
// IDataReader
|
|
||||||
// =================================================================================================
|
|
||||||
|
|
||||||
class IDataReader
|
|
||||||
{
|
|
||||||
protected:
|
|
||||||
virtual ~IDataReader();
|
|
||||||
|
|
||||||
public:
|
|
||||||
virtual void Skip(u32) = 0;
|
|
||||||
virtual u8 Read8 () = 0;
|
|
||||||
virtual u16 Read16() = 0;
|
|
||||||
virtual u32 Read32() = 0;
|
|
||||||
|
|
||||||
virtual int GetPosition() = 0; // return values can be anything, as long as relative distances are correct
|
|
||||||
virtual u8* GetRealCurrentPtr() = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
// =================================================================================================
|
|
||||||
// CDataReader_Fifo
|
|
||||||
// =================================================================================================
|
|
||||||
|
|
||||||
class CDataReader_Fifo : public IDataReader
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
|
|
||||||
public:
|
|
||||||
CDataReader_Fifo();
|
|
||||||
|
|
||||||
virtual void Skip(u32);
|
|
||||||
virtual u8 Read8();
|
|
||||||
virtual u16 Read16();
|
|
||||||
virtual u32 Read32();
|
|
||||||
virtual int GetPosition();
|
|
||||||
virtual u8* GetRealCurrentPtr();
|
|
||||||
};
|
|
||||||
|
|
||||||
// =================================================================================================
|
|
||||||
// CDataReader_Memory
|
|
||||||
// =================================================================================================
|
|
||||||
|
|
||||||
class CDataReader_Memory : public IDataReader
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
|
|
||||||
//u8* m_pMemory;
|
|
||||||
u32 m_uReadAddress;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
CDataReader_Memory(u32 _uAddress);
|
|
||||||
|
|
||||||
u32 GetReadAddress();
|
|
||||||
|
|
||||||
virtual void Skip(u32);
|
|
||||||
virtual u8 Read8();
|
|
||||||
virtual u16 Read16();
|
|
||||||
virtual u32 Read32();
|
|
||||||
virtual int GetPosition();
|
|
||||||
virtual u8* GetRealCurrentPtr();
|
|
||||||
};
|
|
||||||
|
|
||||||
extern IDataReader* g_pDataReader;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef DATAREADER_INLINE
|
|
||||||
extern u8* g_pVideoData;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef DATAREADER_DEBUG
|
|
||||||
extern u8* g_pDataReaderRealPtr;
|
|
||||||
#define DATAREADER_DEBUG_CHECK_PTR g_pDataReaderRealPtr = g_pDataReader->GetRealCurrentPtr(); \
|
|
||||||
if (g_pDataReaderRealPtr!=g_pVideoData) _asm int 3
|
|
||||||
#define DATAREADER_DEBUG_CHECK_PTR_VAL g_pDataReaderRealPtr = g_pDataReader->GetRealCurrentPtr(); \
|
|
||||||
if ((g_pDataReaderRealPtr != g_pVideoData) || (tmp != tmpdb)) _asm int 3
|
|
||||||
//#define DATAREADER_DEBUG_CHECK_PTR_VAL DATAREADER_DEBUG_CHECK_PTR
|
|
||||||
#else
|
|
||||||
#define DATAREADER_DEBUG_CHECK_PTR
|
|
||||||
#define DATAREADER_DEBUG_CHECK_PTR_VAL
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef DATAREADER_INLINE
|
|
||||||
inline u8 DataPeek8(u32 _uOffset)
|
|
||||||
{
|
|
||||||
u8 tmp = *(u8*)(g_pVideoData + _uOffset);
|
|
||||||
return tmp;
|
|
||||||
}
|
|
||||||
inline u16 DataPeek16(u32 _uOffset)
|
|
||||||
{
|
|
||||||
u16 tmp = Common::swap16(*(u16*)(g_pVideoData + _uOffset));
|
|
||||||
return tmp;
|
|
||||||
}
|
|
||||||
inline u32 DataPeek32(u32 _uOffset) {
|
|
||||||
u32 tmp = Common::swap32(*(u32*)(g_pVideoData + _uOffset));
|
|
||||||
return tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline u8 DataReadU8()
|
|
||||||
{
|
|
||||||
u8 tmp = *g_pVideoData;
|
|
||||||
g_pVideoData++;
|
|
||||||
#ifdef DATAREADER_DEBUG
|
|
||||||
u8 tmpdb = g_pDataReader->Read8();
|
|
||||||
DATAREADER_DEBUG_CHECK_PTR_VAL;
|
|
||||||
#endif
|
|
||||||
return tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline u16 DataReadU16()
|
|
||||||
{
|
|
||||||
u16 tmp = Common::swap16(*(u16*)g_pVideoData);
|
|
||||||
g_pVideoData+=2;
|
|
||||||
#ifdef DATAREADER_DEBUG
|
|
||||||
u16 tmpdb = g_pDataReader->Read16();
|
|
||||||
DATAREADER_DEBUG_CHECK_PTR_VAL;
|
|
||||||
#endif
|
|
||||||
return tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline u32 DataReadU32()
|
|
||||||
{
|
|
||||||
u32 tmp = Common::swap32(*(u32*)g_pVideoData);
|
|
||||||
g_pVideoData+=4;
|
|
||||||
#ifdef DATAREADER_DEBUG
|
|
||||||
u32 tmpdb = g_pDataReader->Read32();
|
|
||||||
DATAREADER_DEBUG_CHECK_PTR_VAL;
|
|
||||||
#endif
|
|
||||||
return tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline float DataReadF32()
|
|
||||||
{
|
|
||||||
union {u32 i; float f;} temp;
|
|
||||||
temp.i = Common::swap32(*(u32*)g_pVideoData);
|
|
||||||
g_pVideoData+=4;
|
|
||||||
float tmp = temp.f;
|
|
||||||
#ifdef DATAREADER_DEBUG
|
|
||||||
//TODO clean up
|
|
||||||
u32 tmp3 = g_pDataReader->Read32();
|
|
||||||
float tmpdb = *(float*)(&tmp3);
|
|
||||||
DATAREADER_DEBUG_CHECK_PTR_VAL;
|
|
||||||
#endif
|
|
||||||
return tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline u8* DataGetPosition()
|
|
||||||
{
|
|
||||||
#ifdef DATAREADER_DEBUG
|
|
||||||
DATAREADER_DEBUG_CHECK_PTR;
|
|
||||||
#endif
|
|
||||||
return g_pVideoData;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void DataSkip(u32 skip)
|
|
||||||
{
|
|
||||||
g_pVideoData += skip;
|
|
||||||
#ifdef DATAREADER_DEBUG
|
|
||||||
g_pDataReader->Skip(skip);
|
|
||||||
DATAREADER_DEBUG_CHECK_PTR;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
inline u8 DataReadU8()
|
|
||||||
{
|
|
||||||
u8 tmp = g_pDataReader->Read8();
|
|
||||||
return tmp;
|
|
||||||
}
|
|
||||||
inline u16 DataReadU16()
|
|
||||||
{
|
|
||||||
u16 tmp = g_pDataReader->Read16();
|
|
||||||
return tmp;
|
|
||||||
}
|
|
||||||
inline u32 DataReadU32()
|
|
||||||
{
|
|
||||||
u32 tmp = g_pDataReader->Read32();
|
|
||||||
return tmp;
|
|
||||||
}
|
|
||||||
inline float DataReadF32()
|
|
||||||
{
|
|
||||||
u32 tmp2 = g_pDataReader->Read32();
|
|
||||||
float tmp = *(float*)(&tmp2);
|
|
||||||
return tmp;
|
|
||||||
}
|
|
||||||
inline void DataSkip(u32 skip)
|
|
||||||
{
|
|
||||||
g_pDataReader->Skip(skip);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
|
@ -16,11 +16,11 @@
|
||||||
// http://code.google.com/p/dolphin-emu/
|
// http://code.google.com/p/dolphin-emu/
|
||||||
|
|
||||||
//DL facts:
|
//DL facts:
|
||||||
// Ikaruga uses NO display lists!
|
// Ikaruga uses (nearly) NO display lists!
|
||||||
// Zelda WW uses TONS of display lists
|
// Zelda WW uses TONS of display lists
|
||||||
// Zelda TP uses almost 100% display lists except menus (we like this!)
|
// Zelda TP uses almost 100% display lists except menus (we like this!)
|
||||||
|
|
||||||
// Note that it IS NOT POSSIBLE to precompile display lists! You can compile them as they are
|
// Note that it IS NOT GENERALLY POSSIBLE to precompile display lists! You can compile them as they are
|
||||||
// and hope that the vertex format doesn't change, though, if you do it just when they are
|
// and hope that the vertex format doesn't change, though, if you do it just when they are
|
||||||
// called. The reason is that the vertex format affects the sizes of the vertices.
|
// called. The reason is that the vertex format affects the sizes of the vertices.
|
||||||
|
|
||||||
|
@ -37,31 +37,13 @@
|
||||||
|
|
||||||
#define CMDBUFFER_SIZE 1024*1024
|
#define CMDBUFFER_SIZE 1024*1024
|
||||||
|
|
||||||
#if ! defined(DATAREADER_INLINE) || defined(DATAREADER_DEBUG)
|
u8* g_pVideoData = 0;
|
||||||
CDataReader_Fifo g_fifoReader;
|
|
||||||
#endif
|
|
||||||
#ifdef DATAREADER_DEBUG
|
|
||||||
u8* g_pDataReaderRealPtr=0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef DATAREADER_INLINE
|
extern u8* FAKE_GetFifoStartPtr();
|
||||||
u8* g_pVideoData=0;
|
extern u8* FAKE_GetFifoEndPtr();
|
||||||
extern bool g_IsFifoRewinded;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void Decode();
|
void Decode();
|
||||||
|
|
||||||
#if !defined(DATAREADER_INLINE) || defined(DATAREADER_DEBUG)
|
|
||||||
extern u8 FAKE_PeekFifo8(u32 _uOffset);
|
|
||||||
extern u16 FAKE_PeekFifo16(u32 _uOffset);
|
|
||||||
extern u32 FAKE_PeekFifo32(u32 _uOffset);
|
|
||||||
extern int FAKE_GetFifoSize();
|
|
||||||
#endif
|
|
||||||
extern u8* FAKE_GetFifoEndPtr();
|
|
||||||
extern u8* FAKE_GetFifoStartPtr();
|
|
||||||
extern u8* FAKE_GetFifoCurrentPtr();
|
|
||||||
extern void FAKE_SkipFifo(u32 skip);
|
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
void Xchg(T& a, T&b)
|
void Xchg(T& a, T&b)
|
||||||
{
|
{
|
||||||
|
@ -72,30 +54,18 @@ void Xchg(T& a, T&b)
|
||||||
|
|
||||||
void ExecuteDisplayList(u32 address, u32 size)
|
void ExecuteDisplayList(u32 address, u32 size)
|
||||||
{
|
{
|
||||||
#if ! defined(DATAREADER_INLINE) || defined(DATAREADER_DEBUG)
|
|
||||||
IDataReader* pOldReader = g_pDataReader;
|
|
||||||
|
|
||||||
//address &= 0x01FFFFFF; // phys address
|
|
||||||
CDataReader_Memory memoryReader(address);
|
|
||||||
g_pDataReader = &memoryReader;
|
|
||||||
#endif
|
|
||||||
#ifdef DATAREADER_INLINE
|
|
||||||
u8* old_pVideoData = g_pVideoData;
|
u8* old_pVideoData = g_pVideoData;
|
||||||
|
|
||||||
u8* startAddress = Memory_GetPtr(address);
|
u8* startAddress = Memory_GetPtr(address);
|
||||||
g_pVideoData = startAddress;
|
g_pVideoData = startAddress;
|
||||||
#endif
|
|
||||||
// temporarily swap dl and non-dl(small "hack" for the stats)
|
// temporarily swap dl and non-dl(small "hack" for the stats)
|
||||||
Xchg(stats.thisFrame.numDLPrims, stats.thisFrame.numPrims);
|
Xchg(stats.thisFrame.numDLPrims, stats.thisFrame.numPrims);
|
||||||
Xchg(stats.thisFrame.numXFLoadsInDL, stats.thisFrame.numXFLoads);
|
Xchg(stats.thisFrame.numXFLoadsInDL, stats.thisFrame.numXFLoads);
|
||||||
Xchg(stats.thisFrame.numCPLoadsInDL, stats.thisFrame.numCPLoads);
|
Xchg(stats.thisFrame.numCPLoadsInDL, stats.thisFrame.numCPLoads);
|
||||||
Xchg(stats.thisFrame.numBPLoadsInDL, stats.thisFrame.numBPLoads);
|
Xchg(stats.thisFrame.numBPLoadsInDL, stats.thisFrame.numBPLoads);
|
||||||
|
|
||||||
#ifdef DATAREADER_INLINE
|
while((u32)(g_pVideoData - startAddress) < size)
|
||||||
while((g_pVideoData - startAddress) < size)
|
|
||||||
#else
|
|
||||||
while((memoryReader.GetReadAddress() - address) < size)
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
Decode();
|
Decode();
|
||||||
}
|
}
|
||||||
|
@ -108,38 +78,17 @@ void ExecuteDisplayList(u32 address, u32 size)
|
||||||
Xchg(stats.thisFrame.numCPLoadsInDL, stats.thisFrame.numCPLoads);
|
Xchg(stats.thisFrame.numCPLoadsInDL, stats.thisFrame.numCPLoads);
|
||||||
Xchg(stats.thisFrame.numBPLoadsInDL, stats.thisFrame.numBPLoads);
|
Xchg(stats.thisFrame.numBPLoadsInDL, stats.thisFrame.numBPLoads);
|
||||||
|
|
||||||
// reset to the old reader
|
// reset to the old pointer
|
||||||
#ifdef DATAREADER_INLINE
|
|
||||||
g_pVideoData = old_pVideoData;
|
g_pVideoData = old_pVideoData;
|
||||||
#endif
|
|
||||||
#if defined(DATAREADER_DEBUG) || !defined(DATAREADER_INLINE)
|
|
||||||
g_pDataReader = pOldReader;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FifoCommandRunnable(void)
|
bool FifoCommandRunnable(void)
|
||||||
{
|
{
|
||||||
#ifndef DATAREADER_INLINE
|
|
||||||
u32 iBufferSize = FAKE_GetFifoSize();
|
|
||||||
#else
|
|
||||||
u32 iBufferSize = (u32)(FAKE_GetFifoEndPtr()-g_pVideoData);
|
u32 iBufferSize = (u32)(FAKE_GetFifoEndPtr()-g_pVideoData);
|
||||||
#ifdef DATAREADER_DEBUG
|
|
||||||
u32 iBufferSizedb = FAKE_GetFifoSize();
|
|
||||||
if( iBufferSize != iBufferSizedb) _asm int 3
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
if (iBufferSize == 0)
|
if (iBufferSize == 0)
|
||||||
return false;
|
return false; // can't peek
|
||||||
|
|
||||||
#if !defined(DATAREADER_INLINE)
|
|
||||||
u8 Cmd = FAKE_PeekFifo8(0);
|
|
||||||
#else
|
|
||||||
u8 Cmd = DataPeek8(0);
|
u8 Cmd = DataPeek8(0);
|
||||||
#ifdef DATAREADER_DEBUG
|
|
||||||
if( Cmd != FAKE_PeekFifo8(0)) _asm int 3
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
u32 iCommandSize = 0;
|
u32 iCommandSize = 0;
|
||||||
|
|
||||||
switch(Cmd)
|
switch(Cmd)
|
||||||
|
@ -183,14 +132,7 @@ bool FifoCommandRunnable(void)
|
||||||
if (iBufferSize >= 5)
|
if (iBufferSize >= 5)
|
||||||
{
|
{
|
||||||
iCommandSize = 1 + 4;
|
iCommandSize = 1 + 4;
|
||||||
#if !defined(DATAREADER_INLINE) || defined(DATAREADER_DEBUG)
|
|
||||||
u32 Cmd2 = FAKE_PeekFifo32(1);
|
|
||||||
#ifdef DATAREADER_DEBUG
|
|
||||||
if( Cmd2 != DataPeek32(1)) _asm int 3
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
u32 Cmd2 = DataPeek32(1);
|
u32 Cmd2 = DataPeek32(1);
|
||||||
#endif
|
|
||||||
int dwTransferSize = ((Cmd2 >> 16) & 15) + 1;
|
int dwTransferSize = ((Cmd2 >> 16) & 15) + 1;
|
||||||
iCommandSize += dwTransferSize * 4;
|
iCommandSize += dwTransferSize * 4;
|
||||||
}
|
}
|
||||||
|
@ -208,22 +150,17 @@ bool FifoCommandRunnable(void)
|
||||||
if (iBufferSize >= 3)
|
if (iBufferSize >= 3)
|
||||||
{
|
{
|
||||||
iCommandSize = 1 + 2;
|
iCommandSize = 1 + 2;
|
||||||
#if !defined(DATAREADER_INLINE) || defined(DATAREADER_DEBUG)
|
|
||||||
u16 numVertices = FAKE_PeekFifo16(1);
|
|
||||||
#ifdef DATAREADER_DEBUG
|
|
||||||
if( numVertices != DataPeek16(1)) _asm int 3
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
u16 numVertices = DataPeek16(1);
|
u16 numVertices = DataPeek16(1);
|
||||||
#endif
|
|
||||||
VertexLoader& vtxLoader = g_VertexLoaders[Cmd & GX_VAT_MASK];
|
VertexLoader& vtxLoader = g_VertexLoaders[Cmd & GX_VAT_MASK];
|
||||||
iCommandSize += numVertices * vtxLoader.ComputeVertexSize();
|
iCommandSize += numVertices * vtxLoader.ComputeVertexSize();
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
char szTemp[1024];
|
char szTemp[1024];
|
||||||
sprintf(szTemp, "GFX: Unknown Opcode (0x%x).\n"
|
sprintf(szTemp, "GFX: Unknown Opcode (0x%x).\n"
|
||||||
"This means one of the following:\n"
|
"This means one of the following:\n"
|
||||||
|
@ -231,9 +168,38 @@ bool FifoCommandRunnable(void)
|
||||||
"* Command stream corrupted by some spurious memory bug\n"
|
"* Command stream corrupted by some spurious memory bug\n"
|
||||||
"* This really is an unknown opcode (unlikely)\n"
|
"* This really is an unknown opcode (unlikely)\n"
|
||||||
"* Some other sort of bug\n\n"
|
"* Some other sort of bug\n\n"
|
||||||
"Dolphin will now likely crash or hang. Enjoy.", Cmd);
|
"Dolphin will now likely crash or hang. Enjoy." , Cmd);
|
||||||
g_VideoInitialize.pSysMessage(szTemp);
|
g_VideoInitialize.pSysMessage(szTemp);
|
||||||
g_VideoInitialize.pLog(szTemp, TRUE);
|
g_VideoInitialize.pLog(szTemp, TRUE);
|
||||||
|
{
|
||||||
|
SCPFifoStruct &fifo = *g_VideoInitialize.pCPFifo;
|
||||||
|
|
||||||
|
char szTmp[256];
|
||||||
|
// sprintf(szTmp, "Illegal command %02x (at %08x)",Cmd,g_pDataReader->GetPtr());
|
||||||
|
sprintf(szTmp, "Illegal command %02x\n"
|
||||||
|
"CPBase: 0x%08x\n"
|
||||||
|
"CPEnd: 0x%08x\n"
|
||||||
|
"CPHiWatermark: 0x%08x\n"
|
||||||
|
"CPLoWatermark: 0x%08x\n"
|
||||||
|
"CPReadWriteDistance: 0x%08x\n"
|
||||||
|
"CPWritePointer: 0x%08x\n"
|
||||||
|
"CPReadPointer: 0x%08x\n"
|
||||||
|
"CPBreakpoint: 0x%08x\n"
|
||||||
|
"bFF_GPReadEnable: %s\n"
|
||||||
|
"bFF_BPEnable: %s\n"
|
||||||
|
"bFF_GPLinkEnable: %s\n"
|
||||||
|
"bFF_Breakpoint: %s\n"
|
||||||
|
"bPauseRead: %s\n"
|
||||||
|
,Cmd, fifo.CPBase, fifo.CPEnd, fifo.CPHiWatermark, fifo.CPLoWatermark, fifo.CPReadWriteDistance
|
||||||
|
,fifo.CPWritePointer, fifo.CPReadPointer, fifo.CPBreakpoint, fifo.bFF_GPReadEnable ? "true" : "false"
|
||||||
|
,fifo.bFF_BPEnable ? "true" : "false" ,fifo.bFF_GPLinkEnable ? "true" : "false"
|
||||||
|
,fifo.bFF_Breakpoint ? "true" : "false", fifo.bPauseRead ? "true" : "false");
|
||||||
|
|
||||||
|
g_VideoInitialize.pLog(szTmp, TRUE);
|
||||||
|
g_VideoInitialize.pLog(szTemp, TRUE);
|
||||||
|
// _assert_msg_(0,szTmp,"");
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -339,16 +305,7 @@ void Decode(void)
|
||||||
|
|
||||||
void OpcodeDecoder_Init()
|
void OpcodeDecoder_Init()
|
||||||
{
|
{
|
||||||
#if !defined(DATAREADER_INLINE)
|
|
||||||
g_pDataReader = &g_fifoReader;
|
|
||||||
#else
|
|
||||||
g_pVideoData = FAKE_GetFifoStartPtr();
|
g_pVideoData = FAKE_GetFifoStartPtr();
|
||||||
#if defined(DATAREADER_DEBUG)
|
|
||||||
g_pDataReader = &g_fifoReader;
|
|
||||||
g_pDataReaderRealPtr = g_pDataReader->GetRealCurrentPtr();
|
|
||||||
DATAREADER_DEBUG_CHECK_PTR;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -361,7 +318,6 @@ void OpcodeDecoder_Run()
|
||||||
DVSTARTPROFILE();
|
DVSTARTPROFILE();
|
||||||
while (FifoCommandRunnable())
|
while (FifoCommandRunnable())
|
||||||
{
|
{
|
||||||
DATAREADER_DEBUG_CHECK_PTR;
|
|
||||||
Decode();
|
Decode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue