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