2019-05-15 14:52:37 +00:00
|
|
|
#include "common.h"
|
|
|
|
#include "patcher.h"
|
|
|
|
#include "RenderBuffer.h"
|
|
|
|
|
|
|
|
int32 &TempBufferVerticesStored = *(int32*)0x8F5F78;
|
|
|
|
int32 &TempBufferIndicesStored = *(int32*)0x8F1A4C;
|
|
|
|
|
2019-07-11 00:22:01 +00:00
|
|
|
RwIm3DVertex *TempBufferRenderVertices = (RwIm3DVertex*)0x862330;
|
2019-05-15 14:52:37 +00:00
|
|
|
RwImVertexIndex *TempBufferRenderIndexList = (RwImVertexIndex*)0x846288;
|
|
|
|
|
|
|
|
int RenderBuffer::VerticesToBeStored;
|
|
|
|
int RenderBuffer::IndicesToBeStored;
|
|
|
|
|
|
|
|
void
|
|
|
|
RenderBuffer::ClearRenderBuffer(void)
|
|
|
|
{
|
|
|
|
TempBufferVerticesStored = 0;
|
|
|
|
TempBufferIndicesStored = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
RenderBuffer::StartStoring(int numIndices, int numVertices, RwImVertexIndex **indexStart, RwIm3DVertex **vertexStart)
|
|
|
|
{
|
2019-07-11 00:22:01 +00:00
|
|
|
if(TempBufferIndicesStored + numIndices >= TEMPBUFFERINDEXSIZE)
|
2019-05-15 14:52:37 +00:00
|
|
|
RenderStuffInBuffer();
|
2019-07-11 00:22:01 +00:00
|
|
|
if(TempBufferVerticesStored + numVertices >= TEMPBUFFERVERTSIZE)
|
2019-05-15 14:52:37 +00:00
|
|
|
RenderStuffInBuffer();
|
|
|
|
*indexStart = &TempBufferRenderIndexList[TempBufferIndicesStored];
|
2019-07-11 00:22:01 +00:00
|
|
|
*vertexStart = &TempBufferRenderVertices[TempBufferVerticesStored];
|
2019-05-15 14:52:37 +00:00
|
|
|
IndicesToBeStored = numIndices;
|
|
|
|
VerticesToBeStored = numVertices;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
RenderBuffer::StopStoring(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for(i = TempBufferIndicesStored; i < TempBufferIndicesStored+IndicesToBeStored; i++)
|
|
|
|
TempBufferRenderIndexList[i] += TempBufferVerticesStored;
|
|
|
|
TempBufferIndicesStored += IndicesToBeStored;
|
|
|
|
TempBufferVerticesStored += VerticesToBeStored;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
RenderBuffer::RenderStuffInBuffer(void)
|
|
|
|
{
|
2019-07-11 00:22:01 +00:00
|
|
|
if(TempBufferVerticesStored && RwIm3DTransform(TempBufferRenderVertices, TempBufferVerticesStored, nil, rwIM3D_VERTEXUV)){
|
2019-05-15 14:52:37 +00:00
|
|
|
RwIm3DRenderIndexedPrimitive(rwPRIMTYPETRILIST, TempBufferRenderIndexList, TempBufferIndicesStored);
|
|
|
|
RwIm3DEnd();
|
|
|
|
}
|
|
|
|
ClearRenderBuffer();
|
|
|
|
}
|
|
|
|
|
|
|
|
STARTPATCHES
|
|
|
|
InjectHook(0x517620, RenderBuffer::ClearRenderBuffer, PATCH_JUMP);
|
|
|
|
InjectHook(0x517640, RenderBuffer::StartStoring, PATCH_JUMP);
|
|
|
|
InjectHook(0x5176B0, RenderBuffer::StopStoring, PATCH_JUMP);
|
|
|
|
InjectHook(0x5177C0, RenderBuffer::RenderStuffInBuffer, PATCH_JUMP);
|
|
|
|
ENDPATCHES
|