Fixed compilation on gcc (gotos cannot cross variable declarations)

This commit is contained in:
Bart Trzynadlowski 2016-05-05 22:01:59 +00:00
parent da4bab5f9b
commit fee1cfb126

View file

@ -550,8 +550,8 @@ void CNew3D::InitMatrixStack(UINT32 matrixBaseAddr, Mat4& mat)
// Draws viewports of the given priority
void CNew3D::RenderViewport(UINT32 addr)
{
GLfloat color[8][3] = // RGB1 translation
{
static const GLfloat color[8][3] =
{ // RGB1 color translation
{ 0.0, 0.0, 0.0 }, // off
{ 0.0, 0.0, 1.0 }, // blue
{ 0.0, 1.0, 0.0 }, // green
@ -561,16 +561,9 @@ void CNew3D::RenderViewport(UINT32 addr)
{ 1.0, 1.0, 0.0 }, // yellow
{ 1.0, 1.0, 1.0 } // white
};
const UINT32 *vpnode;
UINT32 nextAddr, nodeAddr, matrixBase;
int curPri;
int vpX, vpY, vpWidth, vpHeight;
int spotColorIdx;
GLfloat scrollFog, scrollAtt;
Viewport* vp;
// Translate address and obtain pointer
vpnode = TranslateCullingAddress(addr);
const uint32_t *vpnode = TranslateCullingAddress(addr);
if (NULL == vpnode) {
return;
@ -580,29 +573,25 @@ void CNew3D::RenderViewport(UINT32 addr)
return;
}
if (vpnode[0]&0x20) {
goto next; // skip this viewport
}
curPri = (vpnode[0x00] >> 3) & 3; // viewport priority
nextAddr = vpnode[0x01] & 0xFFFFFF; // next viewport
nodeAddr = vpnode[0x02]; // scene database node pointer
if (!(vpnode[0] & 0x20)) { // only if viewport enabled
uint32_t curPri = (vpnode[0x00] >> 3) & 3; // viewport priority
uint32_t nodeAddr = vpnode[0x02]; // scene database node pointer
// create node object
m_nodes.emplace_back(Node());
m_nodes.back().models.reserve(2048); // create space for models
// get pointer to its viewport
vp = &m_nodes.back().viewport;
Viewport *vp = &m_nodes.back().viewport;
vp->priority = curPri;
// Fetch viewport parameters (TO-DO: would rounding make a difference?)
vpX = (int)(((vpnode[0x1A] & 0xFFFF) / 16.0f) + 0.5f); // viewport X (12.4 fixed point)
vpY = (int)(((vpnode[0x1A] >> 16) / 16.0f) + 0.5f); // viewport Y (12.4)
vpWidth = (int)(((vpnode[0x14] & 0xFFFF) / 4.0f) + 0.5f); // width (14.2)
vpHeight = (int)(((vpnode[0x14] >> 16) / 4.0f) + 0.5f); // height (14.2)
matrixBase = vpnode[0x16] & 0xFFFFFF; // matrix base address
int vpX = (int)(((vpnode[0x1A] & 0xFFFF) / 16.0f) + 0.5f); // viewport X (12.4 fixed point)
int vpY = (int)(((vpnode[0x1A] >> 16) / 16.0f) + 0.5f); // viewport Y (12.4)
int vpWidth = (int)(((vpnode[0x14] & 0xFFFF) / 4.0f) + 0.5f); // width (14.2)
int vpHeight = (int)(((vpnode[0x14] >> 16) / 4.0f) + 0.5f); // height (14.2)
uint32_t matrixBase = vpnode[0x16] & 0xFFFFFF; // matrix base address
if (vpX) {
vpX += 2;
@ -665,7 +654,7 @@ void CNew3D::RenderViewport(UINT32 addr)
vp->lightingParams[5] = 0.0; // reserved
// Spotlight
spotColorIdx = (vpnode[0x20] >> 11) & 7; // spotlight color index
int spotColorIdx = (vpnode[0x20] >> 11) & 7; // spotlight color index
vp->spotEllipse[0] = (float)((vpnode[0x1E] >> 3) & 0x1FFF); // spotlight X position (fractional component?)
vp->spotEllipse[1] = (float)((vpnode[0x1D] >> 3) & 0x1FFF); // spotlight Y
vp->spotEllipse[2] = (float)((vpnode[0x1E] >> 16) & 0xFFFF); // spotlight X size (16-bit? May have fractional component below bit 16)
@ -702,8 +691,8 @@ void CNew3D::RenderViewport(UINT32 addr)
}
// Unknown light/fog parameters
scrollFog = (float)(vpnode[0x20] & 0xFF) * (1.0f / 255.0f); // scroll fog
scrollAtt = (float)(vpnode[0x24] & 0xFF) * (1.0f / 255.0f); // scroll attenuation
// float scrollFog = (float)(vpnode[0x20] & 0xFF) * (1.0f / 255.0f); // scroll fog
// float scrollAtt = (float)(vpnode[0x24] & 0xFF) * (1.0f / 255.0f); // scroll attenuation
// Clear texture offsets before proceeding
m_nodeAttribs.Reset();
@ -735,8 +724,7 @@ void CNew3D::RenderViewport(UINT32 addr)
// Descend down the node link: Use recursive traversal
DescendNodePtr(nodeAddr);
next:
}
// render next viewport
if (vpnode[0x01] != 0x01000000) {